@vertebr/admin 0.8.1 → 0.10.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 +45 -2
- package/dist/database/connector.js.map +1 -1
- package/dist/database/types.d.ts +5 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/api/adapters/express.d.ts +10 -0
- package/dist/runtime/api/adapters/express.d.ts.map +1 -0
- package/dist/runtime/api/adapters/express.js +80 -0
- package/dist/runtime/api/adapters/express.js.map +1 -0
- package/dist/runtime/api/adapters/fastify.d.ts +31 -0
- package/dist/runtime/api/adapters/fastify.d.ts.map +1 -0
- package/dist/runtime/api/adapters/fastify.js +85 -0
- package/dist/runtime/api/adapters/fastify.js.map +1 -0
- package/dist/runtime/api/adapters/hapi.d.ts +6 -0
- package/dist/runtime/api/adapters/hapi.d.ts.map +1 -0
- package/dist/runtime/api/adapters/hapi.js +45 -0
- package/dist/runtime/api/adapters/hapi.js.map +1 -0
- package/dist/runtime/api/adapters/shared.d.ts +17 -0
- package/dist/runtime/api/adapters/shared.d.ts.map +1 -0
- package/dist/runtime/api/adapters/shared.js +37 -0
- package/dist/runtime/api/adapters/shared.js.map +1 -0
- package/dist/runtime/api/audit.d.ts +8 -0
- package/dist/runtime/api/audit.d.ts.map +1 -0
- package/dist/runtime/api/audit.js +30 -0
- package/dist/runtime/api/audit.js.map +1 -0
- package/dist/runtime/api/catalog.d.ts +56 -4
- package/dist/runtime/api/catalog.d.ts.map +1 -1
- package/dist/runtime/api/catalog.js +155 -74
- package/dist/runtime/api/catalog.js.map +1 -1
- package/dist/runtime/api/configs.d.ts +14 -0
- package/dist/runtime/api/configs.d.ts.map +1 -1
- package/dist/runtime/api/configs.js +128 -2
- package/dist/runtime/api/configs.js.map +1 -1
- package/dist/runtime/api/health.d.ts +7 -0
- package/dist/runtime/api/health.d.ts.map +1 -0
- package/dist/runtime/api/health.js +21 -0
- package/dist/runtime/api/health.js.map +1 -0
- package/dist/runtime/api/jobs.d.ts +12 -0
- package/dist/runtime/api/jobs.d.ts.map +1 -0
- package/dist/runtime/api/jobs.js +34 -0
- package/dist/runtime/api/jobs.js.map +1 -0
- package/dist/runtime/api/metrics.d.ts.map +1 -1
- package/dist/runtime/api/metrics.js +2 -0
- package/dist/runtime/api/metrics.js.map +1 -1
- package/dist/runtime/api/public.d.ts.map +1 -1
- package/dist/runtime/api/public.js +12 -4
- package/dist/runtime/api/public.js.map +1 -1
- package/dist/runtime/api/resources.d.ts +29 -0
- package/dist/runtime/api/resources.d.ts.map +1 -1
- package/dist/runtime/api/resources.js +247 -7
- package/dist/runtime/api/resources.js.map +1 -1
- package/dist/runtime/api/revisions.d.ts +35 -0
- package/dist/runtime/api/revisions.d.ts.map +1 -0
- package/dist/runtime/api/revisions.js +174 -0
- package/dist/runtime/api/revisions.js.map +1 -0
- package/dist/runtime/api/routes.d.ts +2 -5
- package/dist/runtime/api/routes.d.ts.map +1 -1
- package/dist/runtime/api/routes.js +62 -40
- package/dist/runtime/api/routes.js.map +1 -1
- package/dist/runtime/api/sync.d.ts +19 -0
- package/dist/runtime/api/sync.d.ts.map +1 -0
- package/dist/runtime/api/sync.js +213 -0
- package/dist/runtime/api/sync.js.map +1 -0
- package/dist/runtime/createAdmin.d.ts.map +1 -1
- package/dist/runtime/createAdmin.js +82 -2
- package/dist/runtime/createAdmin.js.map +1 -1
- package/dist/runtime/errors.d.ts +8 -0
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/errors.js +17 -1
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/services/access.d.ts +14 -0
- package/dist/runtime/services/access.d.ts.map +1 -0
- package/dist/runtime/services/access.js +49 -0
- package/dist/runtime/services/access.js.map +1 -0
- package/dist/runtime/services/audit.d.ts +16 -0
- package/dist/runtime/services/audit.d.ts.map +1 -0
- package/dist/runtime/services/audit.js +43 -0
- package/dist/runtime/services/audit.js.map +1 -0
- package/dist/runtime/services/environment.d.ts +4 -1
- package/dist/runtime/services/environment.d.ts.map +1 -1
- package/dist/runtime/services/environment.js +16 -2
- package/dist/runtime/services/environment.js.map +1 -1
- package/dist/runtime/services/state.d.ts +17 -0
- package/dist/runtime/services/state.d.ts.map +1 -1
- package/dist/runtime/types/access.d.ts +28 -0
- package/dist/runtime/types/access.d.ts.map +1 -0
- package/dist/runtime/types/access.js +3 -0
- package/dist/runtime/types/access.js.map +1 -0
- package/dist/runtime/types/actions.d.ts +2 -0
- package/dist/runtime/types/actions.d.ts.map +1 -1
- package/dist/runtime/types/addon.d.ts +31 -0
- package/dist/runtime/types/addon.d.ts.map +1 -0
- package/dist/runtime/types/addon.js +9 -0
- package/dist/runtime/types/addon.js.map +1 -0
- package/dist/runtime/types/admin.d.ts +50 -0
- package/dist/runtime/types/admin.d.ts.map +1 -1
- package/dist/runtime/types/audit.d.ts +35 -0
- package/dist/runtime/types/audit.d.ts.map +1 -0
- package/dist/runtime/types/audit.js +3 -0
- package/dist/runtime/types/audit.js.map +1 -0
- package/dist/runtime/types/auth.d.ts +6 -0
- package/dist/runtime/types/auth.d.ts.map +1 -1
- package/dist/runtime/types/config.d.ts +1 -1
- package/dist/runtime/types/config.d.ts.map +1 -1
- package/dist/runtime/types/events.d.ts +63 -0
- package/dist/runtime/types/events.d.ts.map +1 -0
- package/dist/runtime/types/events.js +3 -0
- package/dist/runtime/types/events.js.map +1 -0
- package/dist/runtime/types/health.d.ts +18 -0
- package/dist/runtime/types/health.d.ts.map +1 -0
- package/dist/runtime/types/health.js +3 -0
- package/dist/runtime/types/health.js.map +1 -0
- package/dist/runtime/types/index.d.ts +10 -2
- package/dist/runtime/types/index.d.ts.map +1 -1
- package/dist/runtime/types/jobs.d.ts +21 -0
- package/dist/runtime/types/jobs.d.ts.map +1 -0
- package/dist/runtime/types/jobs.js +3 -0
- package/dist/runtime/types/jobs.js.map +1 -0
- package/dist/runtime/types/resource.d.ts +30 -1
- package/dist/runtime/types/resource.d.ts.map +1 -1
- package/dist/runtime/types/revisions.d.ts +33 -0
- package/dist/runtime/types/revisions.d.ts.map +1 -0
- package/dist/runtime/types/revisions.js +3 -0
- package/dist/runtime/types/revisions.js.map +1 -0
- package/dist/runtime/types/sync.d.ts +99 -0
- package/dist/runtime/types/sync.d.ts.map +1 -0
- package/dist/runtime/types/sync.js +3 -0
- package/dist/runtime/types/sync.js.map +1 -0
- package/dist/runtime/utils/http.d.ts +2 -0
- package/dist/runtime/utils/http.d.ts.map +1 -1
- package/dist/runtime/utils/http.js +24 -0
- package/dist/runtime/utils/http.js.map +1 -1
- package/dist/schema.d.ts +20 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/store.d.ts +6 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +74 -0
- package/dist/store.js.map +1 -1
- package/package.json +1 -1
- package/static/assets/index-DIdeXSPR.js +340 -0
- package/static/assets/index-oaieFDp4.css +1 -0
- package/static/index.html +2 -2
- package/static/assets/index-D5BVgGQP.js +0 -337
- package/static/assets/index-DORD_jLa.css +0 -1
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
var dT=t=>{throw TypeError(t)};var fT=(t,e,n)=>e.has(t)||dT("Cannot "+n);var Zn=(t,e,n)=>(fT(t,e,"read from private field"),n?n.call(t):e.get(t)),hT=(t,e,n)=>e.has(t)?dT("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),cv=(t,e,n,r)=>(fT(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);function e$(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in t)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}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 s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function VN(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var uv={exports:{}},Uu={};var pT;function t$(){if(pT)return Uu;pT=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,i){var o=null;if(i!==void 0&&(o=""+i),s.key!==void 0&&(o=""+s.key),"key"in s){i={};for(var l in s)l!=="key"&&(i[l]=s[l])}else i=s;return s=i.ref,{$$typeof:t,type:r,key:o,ref:s!==void 0?s:null,props:i}}return Uu.Fragment=e,Uu.jsx=n,Uu.jsxs=n,Uu}var mT;function n$(){return mT||(mT=1,uv.exports=t$()),uv.exports}var m=n$(),dv={exports:{}},Qe={};var gT;function r$(){if(gT)return Qe;gT=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),y=Symbol.iterator;function b($){return $===null||typeof $!="object"?null:($=y&&$[y]||$["@@iterator"],typeof $=="function"?$:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,k={};function C($,Y,he){this.props=$,this.context=Y,this.refs=k,this.updater=he||x}C.prototype.isReactComponent={},C.prototype.setState=function($,Y){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,Y,"setState")},C.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function A(){}A.prototype=C.prototype;function R($,Y,he){this.props=$,this.context=Y,this.refs=k,this.updater=he||x}var _=R.prototype=new A;_.constructor=R,S(_,C.prototype),_.isPureReactComponent=!0;var N=Array.isArray;function M(){}var O={H:null,A:null,T:null,S:null},P=Object.prototype.hasOwnProperty;function D($,Y,he){var be=he.ref;return{$$typeof:t,type:$,key:Y,ref:be!==void 0?be:null,props:he}}function F($,Y){return D($.type,Y,$.props)}function te($){return typeof $=="object"&&$!==null&&$.$$typeof===t}function H($){var Y={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(he){return Y[he]})}var Z=/\/+/g;function G($,Y){return typeof $=="object"&&$!==null&&$.key!=null?H(""+$.key):Y.toString(36)}function ae($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(M,M):($.status="pending",$.then(function(Y){$.status==="pending"&&($.status="fulfilled",$.value=Y)},function(Y){$.status==="pending"&&($.status="rejected",$.reason=Y)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function z($,Y,he,be,Me){var Ce=typeof $;(Ce==="undefined"||Ce==="boolean")&&($=null);var He=!1;if($===null)He=!0;else switch(Ce){case"bigint":case"string":case"number":He=!0;break;case"object":switch($.$$typeof){case t:case e:He=!0;break;case h:return He=$._init,z(He($._payload),Y,he,be,Me)}}if(He)return Me=Me($),He=be===""?"."+G($,0):be,N(Me)?(he="",He!=null&&(he=He.replace(Z,"$&/")+"/"),z(Me,Y,he,"",function(me){return me})):Me!=null&&(te(Me)&&(Me=F(Me,he+(Me.key==null||$&&$.key===Me.key?"":(""+Me.key).replace(Z,"$&/")+"/")+He)),Y.push(Me)),1;He=0;var Ee=be===""?".":be+":";if(N($))for(var le=0;le<$.length;le++)be=$[le],Ce=Ee+G(be,le),He+=z(be,Y,he,Ce,Me);else if(le=b($),typeof le=="function")for($=le.call($),le=0;!(be=$.next()).done;)be=be.value,Ce=Ee+G(be,le++),He+=z(be,Y,he,Ce,Me);else if(Ce==="object"){if(typeof $.then=="function")return z(ae($),Y,he,be,Me);throw Y=String($),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return He}function L($,Y,he){if($==null)return $;var be=[],Me=0;return z($,be,"","",function(Ce){return Y.call(he,Ce,Me++)}),be}function W($){if($._status===-1){var Y=$._result;Y=Y(),Y.then(function(he){($._status===0||$._status===-1)&&($._status=1,$._result=he)},function(he){($._status===0||$._status===-1)&&($._status=2,$._result=he)}),$._status===-1&&($._status=0,$._result=Y)}if($._status===1)return $._result.default;throw $._result}var ce=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},pe={map:L,forEach:function($,Y,he){L($,function(){Y.apply(this,arguments)},he)},count:function($){var Y=0;return L($,function(){Y++}),Y},toArray:function($){return L($,function(Y){return Y})||[]},only:function($){if(!te($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return Qe.Activity=g,Qe.Children=pe,Qe.Component=C,Qe.Fragment=n,Qe.Profiler=s,Qe.PureComponent=R,Qe.StrictMode=r,Qe.Suspense=u,Qe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Qe.__COMPILER_RUNTIME={__proto__:null,c:function($){return O.H.useMemoCache($)}},Qe.cache=function($){return function(){return $.apply(null,arguments)}},Qe.cacheSignal=function(){return null},Qe.cloneElement=function($,Y,he){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var be=S({},$.props),Me=$.key;if(Y!=null)for(Ce in Y.key!==void 0&&(Me=""+Y.key),Y)!P.call(Y,Ce)||Ce==="key"||Ce==="__self"||Ce==="__source"||Ce==="ref"&&Y.ref===void 0||(be[Ce]=Y[Ce]);var Ce=arguments.length-2;if(Ce===1)be.children=he;else if(1<Ce){for(var He=Array(Ce),Ee=0;Ee<Ce;Ee++)He[Ee]=arguments[Ee+2];be.children=He}return D($.type,Me,be)},Qe.createContext=function($){return $={$$typeof:o,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:i,_context:$},$},Qe.createElement=function($,Y,he){var be,Me={},Ce=null;if(Y!=null)for(be in Y.key!==void 0&&(Ce=""+Y.key),Y)P.call(Y,be)&&be!=="key"&&be!=="__self"&&be!=="__source"&&(Me[be]=Y[be]);var He=arguments.length-2;if(He===1)Me.children=he;else if(1<He){for(var Ee=Array(He),le=0;le<He;le++)Ee[le]=arguments[le+2];Me.children=Ee}if($&&$.defaultProps)for(be in He=$.defaultProps,He)Me[be]===void 0&&(Me[be]=He[be]);return D($,Ce,Me)},Qe.createRef=function(){return{current:null}},Qe.forwardRef=function($){return{$$typeof:l,render:$}},Qe.isValidElement=te,Qe.lazy=function($){return{$$typeof:h,_payload:{_status:-1,_result:$},_init:W}},Qe.memo=function($,Y){return{$$typeof:d,type:$,compare:Y===void 0?null:Y}},Qe.startTransition=function($){var Y=O.T,he={};O.T=he;try{var be=$(),Me=O.S;Me!==null&&Me(he,be),typeof be=="object"&&be!==null&&typeof be.then=="function"&&be.then(M,ce)}catch(Ce){ce(Ce)}finally{Y!==null&&he.types!==null&&(Y.types=he.types),O.T=Y}},Qe.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Qe.use=function($){return O.H.use($)},Qe.useActionState=function($,Y,he){return O.H.useActionState($,Y,he)},Qe.useCallback=function($,Y){return O.H.useCallback($,Y)},Qe.useContext=function($){return O.H.useContext($)},Qe.useDebugValue=function(){},Qe.useDeferredValue=function($,Y){return O.H.useDeferredValue($,Y)},Qe.useEffect=function($,Y){return O.H.useEffect($,Y)},Qe.useEffectEvent=function($){return O.H.useEffectEvent($)},Qe.useId=function(){return O.H.useId()},Qe.useImperativeHandle=function($,Y,he){return O.H.useImperativeHandle($,Y,he)},Qe.useInsertionEffect=function($,Y){return O.H.useInsertionEffect($,Y)},Qe.useLayoutEffect=function($,Y){return O.H.useLayoutEffect($,Y)},Qe.useMemo=function($,Y){return O.H.useMemo($,Y)},Qe.useOptimistic=function($,Y){return O.H.useOptimistic($,Y)},Qe.useReducer=function($,Y,he){return O.H.useReducer($,Y,he)},Qe.useRef=function($){return O.H.useRef($)},Qe.useState=function($){return O.H.useState($)},Qe.useSyncExternalStore=function($,Y,he){return O.H.useSyncExternalStore($,Y,he)},Qe.useTransition=function(){return O.H.useTransition()},Qe.version="19.2.8",Qe}var yT;function tf(){return yT||(yT=1,dv.exports=r$()),dv.exports}var E=tf();const We=VN(E),nf=e$({__proto__:null,default:We},[E]);var fv={exports:{}},Fu={},hv={exports:{}},pv={};var bT;function s$(){return bT||(bT=1,(function(t){function e(z,L){var W=z.length;z.push(L);e:for(;0<W;){var ce=W-1>>>1,pe=z[ce];if(0<s(pe,L))z[ce]=L,z[W]=pe,W=ce;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],W=z.pop();if(W!==L){z[0]=W;e:for(var ce=0,pe=z.length,$=pe>>>1;ce<$;){var Y=2*(ce+1)-1,he=z[Y],be=Y+1,Me=z[be];if(0>s(he,W))be<pe&&0>s(Me,he)?(z[ce]=Me,z[be]=W,ce=be):(z[ce]=he,z[Y]=W,ce=Y);else if(be<pe&&0>s(Me,W))z[ce]=Me,z[be]=W,ce=be;else break e}}return L}function s(z,L){var W=z.sortIndex-L.sortIndex;return W!==0?W:z.id-L.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var u=[],d=[],h=1,g=null,y=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(d);L!==null;){if(L.callback===null)r(d);else if(L.startTime<=z)r(d),L.sortIndex=L.expirationTime,e(u,L);else break;L=n(d)}}function N(z){if(S=!1,_(z),!x)if(n(u)!==null)x=!0,M||(M=!0,H());else{var L=n(d);L!==null&&ae(N,L.startTime-z)}}var M=!1,O=-1,P=5,D=-1;function F(){return k?!0:!(t.unstable_now()-D<P)}function te(){if(k=!1,M){var z=t.unstable_now();D=z;var L=!0;try{e:{x=!1,S&&(S=!1,A(O),O=-1),b=!0;var W=y;try{t:{for(_(z),g=n(u);g!==null&&!(g.expirationTime>z&&F());){var ce=g.callback;if(typeof ce=="function"){g.callback=null,y=g.priorityLevel;var pe=ce(g.expirationTime<=z);if(z=t.unstable_now(),typeof pe=="function"){g.callback=pe,_(z),L=!0;break t}g===n(u)&&r(u),_(z)}else r(u);g=n(u)}if(g!==null)L=!0;else{var $=n(d);$!==null&&ae(N,$.startTime-z),L=!1}}break e}finally{g=null,y=W,b=!1}L=void 0}}finally{L?H():M=!1}}}var H;if(typeof R=="function")H=function(){R(te)};else if(typeof MessageChannel<"u"){var Z=new MessageChannel,G=Z.port2;Z.port1.onmessage=te,H=function(){G.postMessage(null)}}else H=function(){C(te,0)};function ae(z,L){O=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"):P=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return y},t.unstable_next=function(z){switch(y){case 1:case 2:case 3:var L=3;break;default:L=y}var W=y;y=L;try{return z()}finally{y=W}},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 W=y;y=z;try{return L()}finally{y=W}},t.unstable_scheduleCallback=function(z,L,W){var ce=t.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?ce+W:ce):W=ce,z){case 1:var pe=-1;break;case 2:pe=250;break;case 5:pe=1073741823;break;case 4:pe=1e4;break;default:pe=5e3}return pe=W+pe,z={id:h++,callback:L,priorityLevel:z,startTime:W,expirationTime:pe,sortIndex:-1},W>ce?(z.sortIndex=W,e(d,z),n(u)===null&&z===n(d)&&(S?(A(O),O=-1):S=!0,ae(N,W-ce))):(z.sortIndex=pe,e(u,z),x||b||(x=!0,M||(M=!0,H()))),z},t.unstable_shouldYield=F,t.unstable_wrapCallback=function(z){var L=y;return function(){var W=y;y=L;try{return z.apply(this,arguments)}finally{y=W}}}})(pv)),pv}var vT;function i$(){return vT||(vT=1,hv.exports=s$()),hv.exports}var mv={exports:{}},Yn={};var xT;function o$(){if(xT)return Yn;xT=1;var t=tf();function e(u){var d="https://react.dev/errors/"+u;if(1<arguments.length){d+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)d+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+u+"; visit "+d+" 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},s=Symbol.for("react.portal");function i(u,d,h){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:g==null?null:""+g,children:u,containerInfo:d,implementation:h}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(u,d){if(u==="font")return"";if(typeof d=="string")return d==="use-credentials"?d:""}return Yn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Yn.createPortal=function(u,d){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!d||d.nodeType!==1&&d.nodeType!==9&&d.nodeType!==11)throw Error(e(299));return i(u,d,null,h)},Yn.flushSync=function(u){var d=o.T,h=r.p;try{if(o.T=null,r.p=2,u)return u()}finally{o.T=d,r.p=h,r.d.f()}},Yn.preconnect=function(u,d){typeof u=="string"&&(d?(d=d.crossOrigin,d=typeof d=="string"?d==="use-credentials"?d:"":void 0):d=null,r.d.C(u,d))},Yn.prefetchDNS=function(u){typeof u=="string"&&r.d.D(u)},Yn.preinit=function(u,d){if(typeof u=="string"&&d&&typeof d.as=="string"){var h=d.as,g=l(h,d.crossOrigin),y=typeof d.integrity=="string"?d.integrity:void 0,b=typeof d.fetchPriority=="string"?d.fetchPriority:void 0;h==="style"?r.d.S(u,typeof d.precedence=="string"?d.precedence:void 0,{crossOrigin:g,integrity:y,fetchPriority:b}):h==="script"&&r.d.X(u,{crossOrigin:g,integrity:y,fetchPriority:b,nonce:typeof d.nonce=="string"?d.nonce:void 0})}},Yn.preinitModule=function(u,d){if(typeof u=="string")if(typeof d=="object"&&d!==null){if(d.as==null||d.as==="script"){var h=l(d.as,d.crossOrigin);r.d.M(u,{crossOrigin:h,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0})}}else d==null&&r.d.M(u)},Yn.preload=function(u,d){if(typeof u=="string"&&typeof d=="object"&&d!==null&&typeof d.as=="string"){var h=d.as,g=l(h,d.crossOrigin);r.d.L(u,h,{crossOrigin:g,integrity:typeof d.integrity=="string"?d.integrity:void 0,nonce:typeof d.nonce=="string"?d.nonce:void 0,type:typeof d.type=="string"?d.type:void 0,fetchPriority:typeof d.fetchPriority=="string"?d.fetchPriority:void 0,referrerPolicy:typeof d.referrerPolicy=="string"?d.referrerPolicy:void 0,imageSrcSet:typeof d.imageSrcSet=="string"?d.imageSrcSet:void 0,imageSizes:typeof d.imageSizes=="string"?d.imageSizes:void 0,media:typeof d.media=="string"?d.media:void 0})}},Yn.preloadModule=function(u,d){if(typeof u=="string")if(d){var h=l(d.as,d.crossOrigin);r.d.m(u,{as:typeof d.as=="string"&&d.as!=="script"?d.as:void 0,crossOrigin:h,integrity:typeof d.integrity=="string"?d.integrity:void 0})}else r.d.m(u)},Yn.requestFormReset=function(u){r.d.r(u)},Yn.unstable_batchedUpdates=function(u,d){return u(d)},Yn.useFormState=function(u,d,h){return o.H.useFormState(u,d,h)},Yn.useFormStatus=function(){return o.H.useHostTransitionStatus()},Yn.version="19.2.8",Yn}var wT;function HN(){if(wT)return mv.exports;wT=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(),mv.exports=o$(),mv.exports}var ST;function a$(){if(ST)return Fu;ST=1;var t=i$(),e=tf(),n=HN();function r(a){var c="https://react.dev/errors/"+a;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)c+="&args[]="+encodeURIComponent(arguments[f])}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 s(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function i(a){var c=a,f=a;if(a.alternate)for(;c.return;)c=c.return;else{a=c;do c=a,(c.flags&4098)!==0&&(f=c.return),a=c.return;while(a)}return c.tag===3?f: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(i(a)!==a)throw Error(r(188))}function d(a){var c=a.alternate;if(!c){if(c=i(a),c===null)throw Error(r(188));return c!==a?null:a}for(var f=a,p=c;;){var v=f.return;if(v===null)break;var w=v.alternate;if(w===null){if(p=v.return,p!==null){f=p;continue}break}if(v.child===w.child){for(w=v.child;w;){if(w===f)return u(v),a;if(w===p)return u(v),c;w=w.sibling}throw Error(r(188))}if(f.return!==p.return)f=v,p=w;else{for(var T=!1,j=v.child;j;){if(j===f){T=!0,f=v,p=w;break}if(j===p){T=!0,p=v,f=w;break}j=j.sibling}if(!T){for(j=w.child;j;){if(j===f){T=!0,f=w,p=v;break}if(j===p){T=!0,p=w,f=v;break}j=j.sibling}if(!T)throw Error(r(189))}}if(f.alternate!==p)throw Error(r(190))}if(f.tag!==3)throw Error(r(188));return f.stateNode.current===f?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 g=Object.assign,y=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"),N=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),F=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function H(a){return a===null||typeof a!="object"?null:(a=te&&a[te]||a["@@iterator"],typeof a=="function"?a:null)}var Z=Symbol.for("react.client.reference");function G(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===Z?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 N:return"Suspense";case M:return"SuspenseList";case D: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 O:return c=a.displayName||null,c!==null?c:G(a.type)||"Memo";case P:c=a._payload,a=a._init;try{return G(a(c))}catch{}}return null}var ae=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,W={pending:!1,data:null,method:null,action:null},ce=[],pe=-1;function $(a){return{current:a}}function Y(a){0>pe||(a.current=ce[pe],ce[pe]=null,pe--)}function he(a,c){pe++,ce[pe]=a.current,a.current=c}var be=$(null),Me=$(null),Ce=$(null),He=$(null);function Ee(a,c){switch(he(Ce,c),he(Me,a),he(be,null),c.nodeType){case 9:case 11:a=(a=c.documentElement)&&(a=a.namespaceURI)?DE(a):0;break;default:if(a=c.tagName,c=c.namespaceURI)c=DE(c),a=IE(c,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}Y(be),he(be,a)}function le(){Y(be),Y(Me),Y(Ce)}function me(a){a.memoizedState!==null&&he(He,a);var c=be.current,f=IE(c,a.type);c!==f&&(he(Me,a),he(be,f))}function De(a){Me.current===a&&(Y(be),Y(Me)),He.current===a&&(Y(He),$u._currentValue=W)}var Be,Ke;function mt(a){if(Be===void 0)try{throw Error()}catch(f){var c=f.stack.trim().match(/\n( *(at )?)/);Be=c&&c[1]||"",Ke=-1<f.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+Be+a+Ke}var ht=!1;function Wt(a,c){if(!a||ht)return"";ht=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(c){var de=function(){throw Error()};if(Object.defineProperty(de.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(de,[])}catch(ne){var Q=ne}Reflect.construct(a,[],de)}else{try{de.call()}catch(ne){Q=ne}a.call(de.prototype)}}else{try{throw Error()}catch(ne){Q=ne}(de=a())&&typeof de.catch=="function"&&de.catch(function(){})}}catch(ne){if(ne&&Q&&typeof ne.stack=="string")return[ne.stack,Q.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],j=w[1];if(T&&j){var V=T.split(`
|
|
4
|
+
`),J=j.split(`
|
|
5
|
+
`);for(v=p=0;p<V.length&&!V[p].includes("DetermineComponentFrameRoot");)p++;for(;v<J.length&&!J[v].includes("DetermineComponentFrameRoot");)v++;if(p===V.length||v===J.length)for(p=V.length-1,v=J.length-1;1<=p&&0<=v&&V[p]!==J[v];)v--;for(;1<=p&&0<=v;p--,v--)if(V[p]!==J[v]){if(p!==1||v!==1)do if(p--,v--,0>v||V[p]!==J[v]){var ie=`
|
|
6
|
+
`+V[p].replace(" at new "," at ");return a.displayName&&ie.includes("<anonymous>")&&(ie=ie.replace("<anonymous>",a.displayName)),ie}while(1<=p&&0<=v);break}}}finally{ht=!1,Error.prepareStackTrace=f}return(f=a?a.displayName||a.name:"")?mt(f):""}function Vt(a,c){switch(a.tag){case 26:case 27:case 5:return mt(a.type);case 16:return mt("Lazy");case 13:return a.child!==c&&c!==null?mt("Suspense Fallback"):mt("Suspense");case 19:return mt("SuspenseList");case 0:case 15:return Wt(a.type,!1);case 11:return Wt(a.type.render,!1);case 1:return Wt(a.type,!0);case 31:return mt("Activity");default:return""}}function Yt(a){try{var c="",f=null;do c+=Vt(a,f),f=a,a=a.return;while(a);return c}catch(p){return`
|
|
7
|
+
Error generating stack: `+p.message+`
|
|
8
|
+
`+p.stack}}var kn=Object.prototype.hasOwnProperty,jn=t.unstable_scheduleCallback,Dn=t.unstable_cancelCallback,Tr=t.unstable_shouldYield,js=t.unstable_requestPaint,Ht=t.unstable_now,pr=t.unstable_getCurrentPriorityLevel,Gn=t.unstable_ImmediatePriority,ds=t.unstable_UserBlockingPriority,rr=t.unstable_NormalPriority,ye=t.unstable_LowPriority,Ie=t.unstable_IdlePriority,I=t.log,B=t.unstable_setDisableYieldValue,U=null,se=null;function oe(a){if(typeof I=="function"&&B(a),se&&typeof se.setStrictMode=="function")try{se.setStrictMode(U,a)}catch{}}var xe=Math.clz32?Math.clz32:Ve,Se=Math.log,_e=Math.LN2;function Ve(a){return a>>>=0,a===0?32:31-(Se(a)/_e|0)|0}var st=256,kt=262144,an=4194304;function Xt(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 Wn(a,c,f){var p=a.pendingLanes;if(p===0)return 0;var v=0,w=a.suspendedLanes,T=a.pingedLanes;a=a.warmLanes;var j=p&134217727;return j!==0?(p=j&~w,p!==0?v=Xt(p):(T&=j,T!==0?v=Xt(T):f||(f=j&~a,f!==0&&(v=Xt(f))))):(j=p&~w,j!==0?v=Xt(j):T!==0?v=Xt(T):f||(f=p&~a,f!==0&&(v=Xt(f)))),v===0?0:c!==0&&c!==v&&(c&w)===0&&(w=v&-v,f=c&-c,w>=f||w===32&&(f&4194048)!==0)?c:v}function Ur(a,c){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&c)===0}function mr(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 ti(){var a=an;return an<<=1,(an&62914560)===0&&(an=4194304),a}function fs(a){for(var c=[],f=0;31>f;f++)c.push(a);return c}function hs(a,c){a.pendingLanes|=c,c!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function vl(a,c,f,p,v,w){var T=a.pendingLanes;a.pendingLanes=f,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=f,a.entangledLanes&=f,a.errorRecoveryDisabledLanes&=f,a.shellSuspendCounter=0;var j=a.entanglements,V=a.expirationTimes,J=a.hiddenUpdates;for(f=T&~f;0<f;){var ie=31-xe(f),de=1<<ie;j[ie]=0,V[ie]=-1;var Q=J[ie];if(Q!==null)for(J[ie]=null,ie=0;ie<Q.length;ie++){var ne=Q[ie];ne!==null&&(ne.lane&=-536870913)}f&=~de}p!==0&&xl(a,p,0),w!==0&&v===0&&a.tag!==0&&(a.suspendedLanes|=w&~(T&~c))}function xl(a,c,f){a.pendingLanes|=c,a.suspendedLanes&=~c;var p=31-xe(c);a.entangledLanes|=c,a.entanglements[p]=a.entanglements[p]|1073741824|f&261930}function ha(a,c){var f=a.entangledLanes|=c;for(a=a.entanglements;f;){var p=31-xe(f),v=1<<p;v&c|a[p]&c&&(a[p]|=c),f&=~v}}function pa(a,c){var f=c&-c;return f=(f&42)!==0?1:Xi(f),(f&(a.suspendedLanes|c))!==0?0:f}function Xi(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 Ji(a){return a&=-a,2<a?8<a?(a&134217727)!==0?32:268435456:8:2}function ge(){var a=L.p;return a!==0?a:(a=window.event,a===void 0?32:sT(a.type))}function Ae(a,c){var f=L.p;try{return L.p=a,c()}finally{L.p=f}}var Ct=Math.random().toString(36).slice(2),ee="__reactFiber$"+Ct,re="__reactProps$"+Ct,Te="__reactContainer$"+Ct,qe="__reactEvents$"+Ct,Dt="__reactListeners$"+Ct,Kn="__reactHandles$"+Ct,Ds="__reactResources$"+Ct,sr="__reactMarker$"+Ct;function ma(a){delete a[ee],delete a[re],delete a[qe],delete a[Dt],delete a[Kn]}function ni(a){var c=a[ee];if(c)return c;for(var f=a.parentNode;f;){if(c=f[Te]||f[ee]){if(f=c.alternate,c.child!==null||f!==null&&f.child!==null)for(a=HE(a);a!==null;){if(f=a[ee])return f;a=HE(a)}return c}a=f,f=a.parentNode}return null}function Is(a){if(a=a[ee]||a[Te]){var c=a.tag;if(c===5||c===6||c===13||c===31||c===26||c===27||c===3)return a}return null}function tu(a){var c=a.tag;if(c===5||c===26||c===27||c===6)return a.stateNode;throw Error(r(33))}function wl(a){var c=a[Ds];return c||(c=a[Ds]={hoistableStyles:new Map,hoistableScripts:new Map}),c}function Cn(a){a[sr]=!0}var Sk=new Set,kk={};function ga(a,c){Sl(a,c),Sl(a+"Capture",c)}function Sl(a,c){for(kk[a]=c,a=0;a<c.length;a++)Sk.add(c[a])}var q2=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]*$"),Ck={},Ek={};function G2(a){return kn.call(Ek,a)?!0:kn.call(Ck,a)?!1:q2.test(a)?Ek[a]=!0:(Ck[a]=!0,!1)}function Cf(a,c,f){if(G2(c))if(f===null)a.removeAttribute(c);else{switch(typeof f){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,""+f)}}function Ef(a,c,f){if(f===null)a.removeAttribute(c);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(c);return}a.setAttribute(c,""+f)}}function ri(a,c,f,p){if(p===null)a.removeAttribute(f);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(f);return}a.setAttributeNS(c,f,""+p)}}function Fr(a){switch(typeof a){case"bigint":case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function Tk(a){var c=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function W2(a,c,f){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){f=""+T,w.call(this,T)}}),Object.defineProperty(a,c,{enumerable:p.enumerable}),{getValue:function(){return f},setValue:function(T){f=""+T},stopTracking:function(){a._valueTracker=null,delete a[c]}}}}function ny(a){if(!a._valueTracker){var c=Tk(a)?"checked":"value";a._valueTracker=W2(a,c,""+a[c])}}function _k(a){if(!a)return!1;var c=a._valueTracker;if(!c)return!0;var f=c.getValue(),p="";return a&&(p=Tk(a)?a.checked?"true":"false":a.value),a=p,a!==f?(c.setValue(a),!0):!1}function Tf(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 K2=/[\n"\\]/g;function qr(a){return a.replace(K2,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function ry(a,c,f,p,v,w,T,j){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=""+Fr(c)):a.value!==""+Fr(c)&&(a.value=""+Fr(c)):T!=="submit"&&T!=="reset"||a.removeAttribute("value"),c!=null?sy(a,T,Fr(c)):f!=null?sy(a,T,Fr(f)):p!=null&&a.removeAttribute("value"),v==null&&w!=null&&(a.defaultChecked=!!w),v!=null&&(a.checked=v&&typeof v!="function"&&typeof v!="symbol"),j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?a.name=""+Fr(j):a.removeAttribute("name")}function Ak(a,c,f,p,v,w,T,j){if(w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(a.type=w),c!=null||f!=null){if(!(w!=="submit"&&w!=="reset"||c!=null)){ny(a);return}f=f!=null?""+Fr(f):"",c=c!=null?""+Fr(c):f,j||c===a.value||(a.value=c),a.defaultValue=c}p=p??v,p=typeof p!="function"&&typeof p!="symbol"&&!!p,a.checked=j?a.checked:!!p,a.defaultChecked=!!p,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(a.name=T),ny(a)}function sy(a,c,f){c==="number"&&Tf(a.ownerDocument)===a||a.defaultValue===""+f||(a.defaultValue=""+f)}function kl(a,c,f,p){if(a=a.options,c){c={};for(var v=0;v<f.length;v++)c["$"+f[v]]=!0;for(f=0;f<a.length;f++)v=c.hasOwnProperty("$"+a[f].value),a[f].selected!==v&&(a[f].selected=v),v&&p&&(a[f].defaultSelected=!0)}else{for(f=""+Fr(f),c=null,v=0;v<a.length;v++){if(a[v].value===f){a[v].selected=!0,p&&(a[v].defaultSelected=!0);return}c!==null||a[v].disabled||(c=a[v])}c!==null&&(c.selected=!0)}}function Rk(a,c,f){if(c!=null&&(c=""+Fr(c),c!==a.value&&(a.value=c),f==null)){a.defaultValue!==c&&(a.defaultValue=c);return}a.defaultValue=f!=null?""+Fr(f):""}function Nk(a,c,f,p){if(c==null){if(p!=null){if(f!=null)throw Error(r(92));if(ae(p)){if(1<p.length)throw Error(r(93));p=p[0]}f=p}f==null&&(f=""),c=f}f=Fr(c),a.defaultValue=f,p=a.textContent,p===f&&p!==""&&p!==null&&(a.value=p),ny(a)}function Cl(a,c){if(c){var f=a.firstChild;if(f&&f===a.lastChild&&f.nodeType===3){f.nodeValue=c;return}}a.textContent=c}var Z2=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 Mk(a,c,f){var p=c.indexOf("--")===0;f==null||typeof f=="boolean"||f===""?p?a.setProperty(c,""):c==="float"?a.cssFloat="":a[c]="":p?a.setProperty(c,f):typeof f!="number"||f===0||Z2.has(c)?c==="float"?a.cssFloat=f:a[c]=(""+f).trim():a[c]=f+"px"}function Ok(a,c,f){if(c!=null&&typeof c!="object")throw Error(r(62));if(a=a.style,f!=null){for(var p in f)!f.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)&&f[v]!==p&&Mk(a,v,p)}else for(var w in c)c.hasOwnProperty(w)&&Mk(a,w,c[w])}function iy(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 Y2=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"]]),X2=/^[\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 _f(a){return X2.test(""+a)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":a}function si(){}var oy=null;function ay(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var El=null,Tl=null;function jk(a){var c=Is(a);if(c&&(a=c.stateNode)){var f=a[re]||null;e:switch(a=c.stateNode,c.type){case"input":if(ry(a,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name),c=f.name,f.type==="radio"&&c!=null){for(f=a;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll('input[name="'+qr(""+c)+'"][type="radio"]'),c=0;c<f.length;c++){var p=f[c];if(p!==a&&p.form===a.form){var v=p[re]||null;if(!v)throw Error(r(90));ry(p,v.value,v.defaultValue,v.defaultValue,v.checked,v.defaultChecked,v.type,v.name)}}for(c=0;c<f.length;c++)p=f[c],p.form===a.form&&_k(p)}break e;case"textarea":Rk(a,f.value,f.defaultValue);break e;case"select":c=f.value,c!=null&&kl(a,!!f.multiple,c,!1)}}}var ly=!1;function Dk(a,c,f){if(ly)return a(c,f);ly=!0;try{var p=a(c);return p}finally{if(ly=!1,(El!==null||Tl!==null)&&(ph(),El&&(c=El,a=Tl,Tl=El=null,jk(c),a)))for(c=0;c<a.length;c++)jk(a[c])}}function nu(a,c){var f=a.stateNode;if(f===null)return null;var p=f[re]||null;if(p===null)return null;f=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(f&&typeof f!="function")throw Error(r(231,c,typeof f));return f}var ii=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),cy=!1;if(ii)try{var ru={};Object.defineProperty(ru,"passive",{get:function(){cy=!0}}),window.addEventListener("test",ru,ru),window.removeEventListener("test",ru,ru)}catch{cy=!1}var Qi=null,uy=null,Af=null;function Ik(){if(Af)return Af;var a,c=uy,f=c.length,p,v="value"in Qi?Qi.value:Qi.textContent,w=v.length;for(a=0;a<f&&c[a]===v[a];a++);var T=f-a;for(p=1;p<=T&&c[f-p]===v[w-p];p++);return Af=v.slice(a,1<p?1-p:void 0)}function Rf(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 Nf(){return!0}function Lk(){return!1}function gr(a){function c(f,p,v,w,T){this._reactName=f,this._targetInst=v,this.type=p,this.nativeEvent=w,this.target=T,this.currentTarget=null;for(var j in a)a.hasOwnProperty(j)&&(f=a[j],this[j]=f?f(w):w[j]);return this.isDefaultPrevented=(w.defaultPrevented!=null?w.defaultPrevented:w.returnValue===!1)?Nf:Lk,this.isPropagationStopped=Lk,this}return g(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=Nf)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=Nf)},persist:function(){},isPersistent:Nf}),c}var ya={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Mf=gr(ya),su=g({},ya,{view:0,detail:0}),J2=gr(su),dy,fy,iu,Of=g({},su,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:py,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!==iu&&(iu&&a.type==="mousemove"?(dy=a.screenX-iu.screenX,fy=a.screenY-iu.screenY):fy=dy=0,iu=a),dy)},movementY:function(a){return"movementY"in a?a.movementY:fy}}),Pk=gr(Of),Q2=g({},Of,{dataTransfer:0}),eP=gr(Q2),tP=g({},su,{relatedTarget:0}),hy=gr(tP),nP=g({},ya,{animationName:0,elapsedTime:0,pseudoElement:0}),rP=gr(nP),sP=g({},ya,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),iP=gr(sP),oP=g({},ya,{data:0}),zk=gr(oP),aP={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},lP={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"},cP={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function uP(a){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(a):(a=cP[a])?!!c[a]:!1}function py(){return uP}var dP=g({},su,{key:function(a){if(a.key){var c=aP[a.key]||a.key;if(c!=="Unidentified")return c}return a.type==="keypress"?(a=Rf(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?lP[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:py,charCode:function(a){return a.type==="keypress"?Rf(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Rf(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),fP=gr(dP),hP=g({},Of,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),$k=gr(hP),pP=g({},su,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:py}),mP=gr(pP),gP=g({},ya,{propertyName:0,elapsedTime:0,pseudoElement:0}),yP=gr(gP),bP=g({},Of,{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}),vP=gr(bP),xP=g({},ya,{newState:0,oldState:0}),wP=gr(xP),SP=[9,13,27,32],my=ii&&"CompositionEvent"in window,ou=null;ii&&"documentMode"in document&&(ou=document.documentMode);var kP=ii&&"TextEvent"in window&&!ou,Bk=ii&&(!my||ou&&8<ou&&11>=ou),Vk=" ",Hk=!1;function Uk(a,c){switch(a){case"keyup":return SP.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fk(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var _l=!1;function CP(a,c){switch(a){case"compositionend":return Fk(c);case"keypress":return c.which!==32?null:(Hk=!0,Vk);case"textInput":return a=c.data,a===Vk&&Hk?null:a;default:return null}}function EP(a,c){if(_l)return a==="compositionend"||!my&&Uk(a,c)?(a=Ik(),Af=uy=Qi=null,_l=!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 Bk&&c.locale!=="ko"?null:c.data;default:return null}}var TP={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 qk(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c==="input"?!!TP[a.type]:c==="textarea"}function Gk(a,c,f,p){El?Tl?Tl.push(p):Tl=[p]:El=p,c=wh(c,"onChange"),0<c.length&&(f=new Mf("onChange","change",null,f,p),a.push({event:f,listeners:c}))}var au=null,lu=null;function _P(a){AE(a,0)}function jf(a){var c=tu(a);if(_k(c))return a}function Wk(a,c){if(a==="change")return c}var Kk=!1;if(ii){var gy;if(ii){var yy="oninput"in document;if(!yy){var Zk=document.createElement("div");Zk.setAttribute("oninput","return;"),yy=typeof Zk.oninput=="function"}gy=yy}else gy=!1;Kk=gy&&(!document.documentMode||9<document.documentMode)}function Yk(){au&&(au.detachEvent("onpropertychange",Xk),lu=au=null)}function Xk(a){if(a.propertyName==="value"&&jf(lu)){var c=[];Gk(c,lu,a,ay(a)),Dk(_P,c)}}function AP(a,c,f){a==="focusin"?(Yk(),au=c,lu=f,au.attachEvent("onpropertychange",Xk)):a==="focusout"&&Yk()}function RP(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return jf(lu)}function NP(a,c){if(a==="click")return jf(c)}function MP(a,c){if(a==="input"||a==="change")return jf(c)}function OP(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var _r=typeof Object.is=="function"?Object.is:OP;function cu(a,c){if(_r(a,c))return!0;if(typeof a!="object"||a===null||typeof c!="object"||c===null)return!1;var f=Object.keys(a),p=Object.keys(c);if(f.length!==p.length)return!1;for(p=0;p<f.length;p++){var v=f[p];if(!kn.call(c,v)||!_r(a[v],c[v]))return!1}return!0}function Jk(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Qk(a,c){var f=Jk(a);a=0;for(var p;f;){if(f.nodeType===3){if(p=a+f.textContent.length,a<=c&&p>=c)return{node:f,offset:c-a};a=p}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=Jk(f)}}function eC(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?eC(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function tC(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var c=Tf(a.document);c instanceof a.HTMLIFrameElement;){try{var f=typeof c.contentWindow.location.href=="string"}catch{f=!1}if(f)a=c.contentWindow;else break;c=Tf(a.document)}return c}function by(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 jP=ii&&"documentMode"in document&&11>=document.documentMode,Al=null,vy=null,uu=null,xy=!1;function nC(a,c,f){var p=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;xy||Al==null||Al!==Tf(p)||(p=Al,"selectionStart"in p&&by(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}),uu&&cu(uu,p)||(uu=p,p=wh(vy,"onSelect"),0<p.length&&(c=new Mf("onSelect","select",null,c,f),a.push({event:c,listeners:p}),c.target=Al)))}function ba(a,c){var f={};return f[a.toLowerCase()]=c.toLowerCase(),f["Webkit"+a]="webkit"+c,f["Moz"+a]="moz"+c,f}var Rl={animationend:ba("Animation","AnimationEnd"),animationiteration:ba("Animation","AnimationIteration"),animationstart:ba("Animation","AnimationStart"),transitionrun:ba("Transition","TransitionRun"),transitionstart:ba("Transition","TransitionStart"),transitioncancel:ba("Transition","TransitionCancel"),transitionend:ba("Transition","TransitionEnd")},wy={},rC={};ii&&(rC=document.createElement("div").style,"AnimationEvent"in window||(delete Rl.animationend.animation,delete Rl.animationiteration.animation,delete Rl.animationstart.animation),"TransitionEvent"in window||delete Rl.transitionend.transition);function va(a){if(wy[a])return wy[a];if(!Rl[a])return a;var c=Rl[a],f;for(f in c)if(c.hasOwnProperty(f)&&f in rC)return wy[a]=c[f];return a}var sC=va("animationend"),iC=va("animationiteration"),oC=va("animationstart"),DP=va("transitionrun"),IP=va("transitionstart"),LP=va("transitioncancel"),aC=va("transitionend"),lC=new Map,Sy="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(" ");Sy.push("scrollEnd");function ps(a,c){lC.set(a,c),ga(c,[a])}var Df=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)},Gr=[],Nl=0,ky=0;function If(){for(var a=Nl,c=ky=Nl=0;c<a;){var f=Gr[c];Gr[c++]=null;var p=Gr[c];Gr[c++]=null;var v=Gr[c];Gr[c++]=null;var w=Gr[c];if(Gr[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&&cC(f,v,w)}}function Lf(a,c,f,p){Gr[Nl++]=a,Gr[Nl++]=c,Gr[Nl++]=f,Gr[Nl++]=p,ky|=p,a.lanes|=p,a=a.alternate,a!==null&&(a.lanes|=p)}function Cy(a,c,f,p){return Lf(a,c,f,p),Pf(a)}function xa(a,c){return Lf(a,null,null,c),Pf(a)}function cC(a,c,f){a.lanes|=f;var p=a.alternate;p!==null&&(p.lanes|=f);for(var v=!1,w=a.return;w!==null;)w.childLanes|=f,p=w.alternate,p!==null&&(p.childLanes|=f),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-xe(f),a=w.hiddenUpdates,p=a[v],p===null?a[v]=[c]:p.push(c),c.lane=f|536870912),w):null}function Pf(a){if(50<Ou)throw Ou=0,jb=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 PP(a,c,f,p){this.tag=a,this.key=f,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 Ar(a,c,f,p){return new PP(a,c,f,p)}function Ey(a){return a=a.prototype,!(!a||!a.isReactComponent)}function oi(a,c){var f=a.alternate;return f===null?(f=Ar(a.tag,c,a.key,a.mode),f.elementType=a.elementType,f.type=a.type,f.stateNode=a.stateNode,f.alternate=a,a.alternate=f):(f.pendingProps=c,f.type=a.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=a.flags&65011712,f.childLanes=a.childLanes,f.lanes=a.lanes,f.child=a.child,f.memoizedProps=a.memoizedProps,f.memoizedState=a.memoizedState,f.updateQueue=a.updateQueue,c=a.dependencies,f.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},f.sibling=a.sibling,f.index=a.index,f.ref=a.ref,f.refCleanup=a.refCleanup,f}function uC(a,c){a.flags&=65011714;var f=a.alternate;return f===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=f.childLanes,a.lanes=f.lanes,a.child=f.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=f.memoizedProps,a.memoizedState=f.memoizedState,a.updateQueue=f.updateQueue,a.type=f.type,c=f.dependencies,a.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext}),a}function zf(a,c,f,p,v,w){var T=0;if(p=a,typeof a=="function")Ey(a)&&(T=1);else if(typeof a=="string")T=Hz(a,f,be.current)?26:a==="html"||a==="head"||a==="body"?27:5;else e:switch(a){case D:return a=Ar(31,f,c,v),a.elementType=D,a.lanes=w,a;case S:return wa(f.children,v,w,c);case k:T=8,v|=24;break;case C:return a=Ar(12,f,c,v|2),a.elementType=C,a.lanes=w,a;case N:return a=Ar(13,f,c,v),a.elementType=N,a.lanes=w,a;case M:return a=Ar(19,f,c,v),a.elementType=M,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 O:T=14;break e;case P:T=16,p=null;break e}T=29,f=Error(r(130,a===null?"null":typeof a,"")),p=null}return c=Ar(T,f,c,v),c.elementType=a,c.type=p,c.lanes=w,c}function wa(a,c,f,p){return a=Ar(7,a,p,c),a.lanes=f,a}function Ty(a,c,f){return a=Ar(6,a,null,c),a.lanes=f,a}function dC(a){var c=Ar(18,null,null,0);return c.stateNode=a,c}function _y(a,c,f){return c=Ar(4,a.children!==null?a.children:[],a.key,c),c.lanes=f,c.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},c}var fC=new WeakMap;function Wr(a,c){if(typeof a=="object"&&a!==null){var f=fC.get(a);return f!==void 0?f:(c={value:a,source:c,stack:Yt(c)},fC.set(a,c),c)}return{value:a,source:c,stack:Yt(c)}}var Ol=[],jl=0,$f=null,du=0,Kr=[],Zr=0,eo=null,Ls=1,Ps="";function ai(a,c){Ol[jl++]=du,Ol[jl++]=$f,$f=a,du=c}function hC(a,c,f){Kr[Zr++]=Ls,Kr[Zr++]=Ps,Kr[Zr++]=eo,eo=a;var p=Ls;a=Ps;var v=32-xe(p)-1;p&=~(1<<v),f+=1;var w=32-xe(c)+v;if(30<w){var T=v-v%5;w=(p&(1<<T)-1).toString(32),p>>=T,v-=T,Ls=1<<32-xe(c)+v|f<<v|p,Ps=w+a}else Ls=1<<w|f<<v|p,Ps=a}function Ay(a){a.return!==null&&(ai(a,1),hC(a,1,0))}function Ry(a){for(;a===$f;)$f=Ol[--jl],Ol[jl]=null,du=Ol[--jl],Ol[jl]=null;for(;a===eo;)eo=Kr[--Zr],Kr[Zr]=null,Ps=Kr[--Zr],Kr[Zr]=null,Ls=Kr[--Zr],Kr[Zr]=null}function pC(a,c){Kr[Zr++]=Ls,Kr[Zr++]=Ps,Kr[Zr++]=eo,Ls=c.id,Ps=c.overflow,eo=a}var In=null,Ut=null,dt=!1,to=null,Yr=!1,Ny=Error(r(519));function no(a){var c=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw fu(Wr(c,a)),Ny}function mC(a){var c=a.stateNode,f=a.type,p=a.memoizedProps;switch(c[ee]=a,c[re]=p,f){case"dialog":lt("cancel",c),lt("close",c);break;case"iframe":case"object":case"embed":lt("load",c);break;case"video":case"audio":for(f=0;f<Du.length;f++)lt(Du[f],c);break;case"source":lt("error",c);break;case"img":case"image":case"link":lt("error",c),lt("load",c);break;case"details":lt("toggle",c);break;case"input":lt("invalid",c),Ak(c,p.value,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name,!0);break;case"select":lt("invalid",c);break;case"textarea":lt("invalid",c),Nk(c,p.value,p.defaultValue,p.children)}f=p.children,typeof f!="string"&&typeof f!="number"&&typeof f!="bigint"||c.textContent===""+f||p.suppressHydrationWarning===!0||OE(c.textContent,f)?(p.popover!=null&&(lt("beforetoggle",c),lt("toggle",c)),p.onScroll!=null&<("scroll",c),p.onScrollEnd!=null&<("scrollend",c),p.onClick!=null&&(c.onclick=si),c=!0):c=!1,c||no(a,!0)}function gC(a){for(In=a.return;In;)switch(In.tag){case 5:case 31:case 13:Yr=!1;return;case 27:case 3:Yr=!0;return;default:In=In.return}}function Dl(a){if(a!==In)return!1;if(!dt)return gC(a),dt=!0,!1;var c=a.tag,f;if((f=c!==3&&c!==27)&&((f=c===5)&&(f=a.type,f=!(f!=="form"&&f!=="button")||Kb(a.type,a.memoizedProps)),f=!f),f&&Ut&&no(a),gC(a),c===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(317));Ut=VE(a)}else if(c===31){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(317));Ut=VE(a)}else c===27?(c=Ut,yo(a.type)?(a=Qb,Qb=null,Ut=a):Ut=c):Ut=In?Jr(a.stateNode.nextSibling):null;return!0}function Sa(){Ut=In=null,dt=!1}function My(){var a=to;return a!==null&&(xr===null?xr=a:xr.push.apply(xr,a),to=null),a}function fu(a){to===null?to=[a]:to.push(a)}var Oy=$(null),ka=null,li=null;function ro(a,c,f){he(Oy,c._currentValue),c._currentValue=f}function ci(a){a._currentValue=Oy.current,Y(Oy)}function jy(a,c,f){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===f)break;a=a.return}}function Dy(a,c,f,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 j=w;w=v;for(var V=0;V<c.length;V++)if(j.context===c[V]){w.lanes|=f,j=w.alternate,j!==null&&(j.lanes|=f),jy(w.return,f,a),p||(T=null);break e}w=j.next}}else if(v.tag===18){if(T=v.return,T===null)throw Error(r(341));T.lanes|=f,w=T.alternate,w!==null&&(w.lanes|=f),jy(T,f,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 Il(a,c,f,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 j=v.type;_r(v.pendingProps.value,T.value)||(a!==null?a.push(j):a=[j])}}else if(v===He.current){if(T=v.alternate,T===null)throw Error(r(387));T.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(a!==null?a.push($u):a=[$u])}v=v.return}a!==null&&Dy(c,a,f,p),c.flags|=262144}function Bf(a){for(a=a.firstContext;a!==null;){if(!_r(a.context._currentValue,a.memoizedValue))return!0;a=a.next}return!1}function Ca(a){ka=a,li=null,a=a.dependencies,a!==null&&(a.firstContext=null)}function Ln(a){return yC(ka,a)}function Vf(a,c){return ka===null&&Ca(a),yC(a,c)}function yC(a,c){var f=c._currentValue;if(c={context:c,memoizedValue:f,next:null},li===null){if(a===null)throw Error(r(308));li=c,a.dependencies={lanes:0,firstContext:c},a.flags|=524288}else li=li.next=c;return f}var zP=typeof AbortController<"u"?AbortController:function(){var a=[],c=this.signal={aborted:!1,addEventListener:function(f,p){a.push(p)}};this.abort=function(){c.aborted=!0,a.forEach(function(f){return f()})}},$P=t.unstable_scheduleCallback,BP=t.unstable_NormalPriority,fn={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Iy(){return{controller:new zP,data:new Map,refCount:0}}function hu(a){a.refCount--,a.refCount===0&&$P(BP,function(){a.controller.abort()})}var pu=null,Ly=0,Ll=0,Pl=null;function VP(a,c){if(pu===null){var f=pu=[];Ly=0,Ll=$b(),Pl={status:"pending",value:void 0,then:function(p){f.push(p)}}}return Ly++,c.then(bC,bC),c}function bC(){if(--Ly===0&&pu!==null){Pl!==null&&(Pl.status="fulfilled");var a=pu;pu=null,Ll=0,Pl=null;for(var c=0;c<a.length;c++)(0,a[c])()}}function HP(a,c){var f=[],p={status:"pending",value:null,reason:null,then:function(v){f.push(v)}};return a.then(function(){p.status="fulfilled",p.value=c;for(var v=0;v<f.length;v++)(0,f[v])(c)},function(v){for(p.status="rejected",p.reason=v,v=0;v<f.length;v++)(0,f[v])(void 0)}),p}var vC=z.S;z.S=function(a,c){nE=Ht(),typeof c=="object"&&c!==null&&typeof c.then=="function"&&VP(a,c),vC!==null&&vC(a,c)};var Ea=$(null);function Py(){var a=Ea.current;return a!==null?a:It.pooledCache}function Hf(a,c){c===null?he(Ea,Ea.current):he(Ea,c.pool)}function xC(){var a=Py();return a===null?null:{parent:fn._currentValue,pool:a}}var zl=Error(r(460)),zy=Error(r(474)),Uf=Error(r(542)),Ff={then:function(){}};function wC(a){return a=a.status,a==="fulfilled"||a==="rejected"}function SC(a,c,f){switch(f=a[f],f===void 0?a.push(c):f!==c&&(c.then(si,si),c=f),c.status){case"fulfilled":return c.value;case"rejected":throw a=c.reason,CC(a),a;default:if(typeof c.status=="string")c.then(si,si);else{if(a=It,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,CC(a),a}throw _a=c,zl}}function Ta(a){try{var c=a._init;return c(a._payload)}catch(f){throw f!==null&&typeof f=="object"&&typeof f.then=="function"?(_a=f,zl):f}}var _a=null;function kC(){if(_a===null)throw Error(r(459));var a=_a;return _a=null,a}function CC(a){if(a===zl||a===Uf)throw Error(r(483))}var $l=null,mu=0;function qf(a){var c=mu;return mu+=1,$l===null&&($l=[]),SC($l,a,c)}function gu(a,c){c=c.props.ref,a.ref=c!==void 0?c:null}function Gf(a,c){throw c.$$typeof===y?Error(r(525)):(a=Object.prototype.toString.call(c),Error(r(31,a==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":a)))}function EC(a){function c(K,q){if(a){var X=K.deletions;X===null?(K.deletions=[q],K.flags|=16):X.push(q)}}function f(K,q){if(!a)return null;for(;q!==null;)c(K,q),q=q.sibling;return null}function p(K){for(var q=new Map;K!==null;)K.key!==null?q.set(K.key,K):q.set(K.index,K),K=K.sibling;return q}function v(K,q){return K=oi(K,q),K.index=0,K.sibling=null,K}function w(K,q,X){return K.index=X,a?(X=K.alternate,X!==null?(X=X.index,X<q?(K.flags|=67108866,q):X):(K.flags|=67108866,q)):(K.flags|=1048576,q)}function T(K){return a&&K.alternate===null&&(K.flags|=67108866),K}function j(K,q,X,ue){return q===null||q.tag!==6?(q=Ty(X,K.mode,ue),q.return=K,q):(q=v(q,X),q.return=K,q)}function V(K,q,X,ue){var Ue=X.type;return Ue===S?ie(K,q,X.props.children,ue,X.key):q!==null&&(q.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===P&&Ta(Ue)===q.type)?(q=v(q,X.props),gu(q,X),q.return=K,q):(q=zf(X.type,X.key,X.props,null,K.mode,ue),gu(q,X),q.return=K,q)}function J(K,q,X,ue){return q===null||q.tag!==4||q.stateNode.containerInfo!==X.containerInfo||q.stateNode.implementation!==X.implementation?(q=_y(X,K.mode,ue),q.return=K,q):(q=v(q,X.children||[]),q.return=K,q)}function ie(K,q,X,ue,Ue){return q===null||q.tag!==7?(q=wa(X,K.mode,ue,Ue),q.return=K,q):(q=v(q,X),q.return=K,q)}function de(K,q,X){if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return q=Ty(""+q,K.mode,X),q.return=K,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case b:return X=zf(q.type,q.key,q.props,null,K.mode,X),gu(X,q),X.return=K,X;case x:return q=_y(q,K.mode,X),q.return=K,q;case P:return q=Ta(q),de(K,q,X)}if(ae(q)||H(q))return q=wa(q,K.mode,X,null),q.return=K,q;if(typeof q.then=="function")return de(K,qf(q),X);if(q.$$typeof===R)return de(K,Vf(K,q),X);Gf(K,q)}return null}function Q(K,q,X,ue){var Ue=q!==null?q.key:null;if(typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint")return Ue!==null?null:j(K,q,""+X,ue);if(typeof X=="object"&&X!==null){switch(X.$$typeof){case b:return X.key===Ue?V(K,q,X,ue):null;case x:return X.key===Ue?J(K,q,X,ue):null;case P:return X=Ta(X),Q(K,q,X,ue)}if(ae(X)||H(X))return Ue!==null?null:ie(K,q,X,ue,null);if(typeof X.then=="function")return Q(K,q,qf(X),ue);if(X.$$typeof===R)return Q(K,q,Vf(K,X),ue);Gf(K,X)}return null}function ne(K,q,X,ue,Ue){if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return K=K.get(X)||null,j(q,K,""+ue,Ue);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case b:return K=K.get(ue.key===null?X:ue.key)||null,V(q,K,ue,Ue);case x:return K=K.get(ue.key===null?X:ue.key)||null,J(q,K,ue,Ue);case P:return ue=Ta(ue),ne(K,q,X,ue,Ue)}if(ae(ue)||H(ue))return K=K.get(X)||null,ie(q,K,ue,Ue,null);if(typeof ue.then=="function")return ne(K,q,X,qf(ue),Ue);if(ue.$$typeof===R)return ne(K,q,X,Vf(q,ue),Ue);Gf(q,ue)}return null}function Oe(K,q,X,ue){for(var Ue=null,gt=null,Pe=q,rt=q=0,ut=null;Pe!==null&&rt<X.length;rt++){Pe.index>rt?(ut=Pe,Pe=null):ut=Pe.sibling;var yt=Q(K,Pe,X[rt],ue);if(yt===null){Pe===null&&(Pe=ut);break}a&&Pe&&yt.alternate===null&&c(K,Pe),q=w(yt,q,rt),gt===null?Ue=yt:gt.sibling=yt,gt=yt,Pe=ut}if(rt===X.length)return f(K,Pe),dt&&ai(K,rt),Ue;if(Pe===null){for(;rt<X.length;rt++)Pe=de(K,X[rt],ue),Pe!==null&&(q=w(Pe,q,rt),gt===null?Ue=Pe:gt.sibling=Pe,gt=Pe);return dt&&ai(K,rt),Ue}for(Pe=p(Pe);rt<X.length;rt++)ut=ne(Pe,K,rt,X[rt],ue),ut!==null&&(a&&ut.alternate!==null&&Pe.delete(ut.key===null?rt:ut.key),q=w(ut,q,rt),gt===null?Ue=ut:gt.sibling=ut,gt=ut);return a&&Pe.forEach(function(So){return c(K,So)}),dt&&ai(K,rt),Ue}function Ge(K,q,X,ue){if(X==null)throw Error(r(151));for(var Ue=null,gt=null,Pe=q,rt=q=0,ut=null,yt=X.next();Pe!==null&&!yt.done;rt++,yt=X.next()){Pe.index>rt?(ut=Pe,Pe=null):ut=Pe.sibling;var So=Q(K,Pe,yt.value,ue);if(So===null){Pe===null&&(Pe=ut);break}a&&Pe&&So.alternate===null&&c(K,Pe),q=w(So,q,rt),gt===null?Ue=So:gt.sibling=So,gt=So,Pe=ut}if(yt.done)return f(K,Pe),dt&&ai(K,rt),Ue;if(Pe===null){for(;!yt.done;rt++,yt=X.next())yt=de(K,yt.value,ue),yt!==null&&(q=w(yt,q,rt),gt===null?Ue=yt:gt.sibling=yt,gt=yt);return dt&&ai(K,rt),Ue}for(Pe=p(Pe);!yt.done;rt++,yt=X.next())yt=ne(Pe,K,rt,yt.value,ue),yt!==null&&(a&&yt.alternate!==null&&Pe.delete(yt.key===null?rt:yt.key),q=w(yt,q,rt),gt===null?Ue=yt:gt.sibling=yt,gt=yt);return a&&Pe.forEach(function(Qz){return c(K,Qz)}),dt&&ai(K,rt),Ue}function Mt(K,q,X,ue){if(typeof X=="object"&&X!==null&&X.type===S&&X.key===null&&(X=X.props.children),typeof X=="object"&&X!==null){switch(X.$$typeof){case b:e:{for(var Ue=X.key;q!==null;){if(q.key===Ue){if(Ue=X.type,Ue===S){if(q.tag===7){f(K,q.sibling),ue=v(q,X.props.children),ue.return=K,K=ue;break e}}else if(q.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===P&&Ta(Ue)===q.type){f(K,q.sibling),ue=v(q,X.props),gu(ue,X),ue.return=K,K=ue;break e}f(K,q);break}else c(K,q);q=q.sibling}X.type===S?(ue=wa(X.props.children,K.mode,ue,X.key),ue.return=K,K=ue):(ue=zf(X.type,X.key,X.props,null,K.mode,ue),gu(ue,X),ue.return=K,K=ue)}return T(K);case x:e:{for(Ue=X.key;q!==null;){if(q.key===Ue)if(q.tag===4&&q.stateNode.containerInfo===X.containerInfo&&q.stateNode.implementation===X.implementation){f(K,q.sibling),ue=v(q,X.children||[]),ue.return=K,K=ue;break e}else{f(K,q);break}else c(K,q);q=q.sibling}ue=_y(X,K.mode,ue),ue.return=K,K=ue}return T(K);case P:return X=Ta(X),Mt(K,q,X,ue)}if(ae(X))return Oe(K,q,X,ue);if(H(X)){if(Ue=H(X),typeof Ue!="function")throw Error(r(150));return X=Ue.call(X),Ge(K,q,X,ue)}if(typeof X.then=="function")return Mt(K,q,qf(X),ue);if(X.$$typeof===R)return Mt(K,q,Vf(K,X),ue);Gf(K,X)}return typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint"?(X=""+X,q!==null&&q.tag===6?(f(K,q.sibling),ue=v(q,X),ue.return=K,K=ue):(f(K,q),ue=Ty(X,K.mode,ue),ue.return=K,K=ue),T(K)):f(K,q)}return function(K,q,X,ue){try{mu=0;var Ue=Mt(K,q,X,ue);return $l=null,Ue}catch(Pe){if(Pe===zl||Pe===Uf)throw Pe;var gt=Ar(29,Pe,null,K.mode);return gt.lanes=ue,gt.return=K,gt}}}var Aa=EC(!0),TC=EC(!1),so=!1;function $y(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function By(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 io(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function oo(a,c,f){var p=a.updateQueue;if(p===null)return null;if(p=p.shared,(xt&2)!==0){var v=p.pending;return v===null?c.next=c:(c.next=v.next,v.next=c),p.pending=c,c=Pf(a),cC(a,null,f),c}return Lf(a,p,c,f),Pf(a)}function yu(a,c,f){if(c=c.updateQueue,c!==null&&(c=c.shared,(f&4194048)!==0)){var p=c.lanes;p&=a.pendingLanes,f|=p,c.lanes=f,ha(a,f)}}function Vy(a,c){var f=a.updateQueue,p=a.alternate;if(p!==null&&(p=p.updateQueue,f===p)){var v=null,w=null;if(f=f.firstBaseUpdate,f!==null){do{var T={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};w===null?v=w=T:w=w.next=T,f=f.next}while(f!==null);w===null?v=w=c:w=w.next=c}else v=w=c;f={baseState:p.baseState,firstBaseUpdate:v,lastBaseUpdate:w,shared:p.shared,callbacks:p.callbacks},a.updateQueue=f;return}a=f.lastBaseUpdate,a===null?f.firstBaseUpdate=c:a.next=c,f.lastBaseUpdate=c}var Hy=!1;function bu(){if(Hy){var a=Pl;if(a!==null)throw a}}function vu(a,c,f,p){Hy=!1;var v=a.updateQueue;so=!1;var w=v.firstBaseUpdate,T=v.lastBaseUpdate,j=v.shared.pending;if(j!==null){v.shared.pending=null;var V=j,J=V.next;V.next=null,T===null?w=J:T.next=J,T=V;var ie=a.alternate;ie!==null&&(ie=ie.updateQueue,j=ie.lastBaseUpdate,j!==T&&(j===null?ie.firstBaseUpdate=J:j.next=J,ie.lastBaseUpdate=V))}if(w!==null){var de=v.baseState;T=0,ie=J=V=null,j=w;do{var Q=j.lane&-536870913,ne=Q!==j.lane;if(ne?(ct&Q)===Q:(p&Q)===Q){Q!==0&&Q===Ll&&(Hy=!0),ie!==null&&(ie=ie.next={lane:0,tag:j.tag,payload:j.payload,callback:null,next:null});e:{var Oe=a,Ge=j;Q=c;var Mt=f;switch(Ge.tag){case 1:if(Oe=Ge.payload,typeof Oe=="function"){de=Oe.call(Mt,de,Q);break e}de=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=Ge.payload,Q=typeof Oe=="function"?Oe.call(Mt,de,Q):Oe,Q==null)break e;de=g({},de,Q);break e;case 2:so=!0}}Q=j.callback,Q!==null&&(a.flags|=64,ne&&(a.flags|=8192),ne=v.callbacks,ne===null?v.callbacks=[Q]:ne.push(Q))}else ne={lane:Q,tag:j.tag,payload:j.payload,callback:j.callback,next:null},ie===null?(J=ie=ne,V=de):ie=ie.next=ne,T|=Q;if(j=j.next,j===null){if(j=v.shared.pending,j===null)break;ne=j,j=ne.next,ne.next=null,v.lastBaseUpdate=ne,v.shared.pending=null}}while(!0);ie===null&&(V=de),v.baseState=V,v.firstBaseUpdate=J,v.lastBaseUpdate=ie,w===null&&(v.shared.lanes=0),fo|=T,a.lanes=T,a.memoizedState=de}}function _C(a,c){if(typeof a!="function")throw Error(r(191,a));a.call(c)}function AC(a,c){var f=a.callbacks;if(f!==null)for(a.callbacks=null,a=0;a<f.length;a++)_C(f[a],c)}var Bl=$(null),Wf=$(0);function RC(a,c){a=bi,he(Wf,a),he(Bl,c),bi=a|c.baseLanes}function Uy(){he(Wf,bi),he(Bl,Bl.current)}function Fy(){bi=Wf.current,Y(Bl),Y(Wf)}var Rr=$(null),Xr=null;function ao(a){var c=a.alternate;he(ln,ln.current&1),he(Rr,a),Xr===null&&(c===null||Bl.current!==null||c.memoizedState!==null)&&(Xr=a)}function qy(a){he(ln,ln.current),he(Rr,a),Xr===null&&(Xr=a)}function NC(a){a.tag===22?(he(ln,ln.current),he(Rr,a),Xr===null&&(Xr=a)):lo()}function lo(){he(ln,ln.current),he(Rr,Rr.current)}function Nr(a){Y(Rr),Xr===a&&(Xr=null),Y(ln)}var ln=$(0);function Kf(a){for(var c=a;c!==null;){if(c.tag===13){var f=c.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||Xb(f)||Jb(f)))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 ui=0,nt=null,Rt=null,hn=null,Zf=!1,Vl=!1,Ra=!1,Yf=0,xu=0,Hl=null,UP=0;function en(){throw Error(r(321))}function Gy(a,c){if(c===null)return!1;for(var f=0;f<c.length&&f<a.length;f++)if(!_r(a[f],c[f]))return!1;return!0}function Wy(a,c,f,p,v,w){return ui=w,nt=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,z.H=a===null||a.memoizedState===null?h1:lb,Ra=!1,w=f(p,v),Ra=!1,Vl&&(w=OC(c,f,p,v)),MC(a),w}function MC(a){z.H=ku;var c=Rt!==null&&Rt.next!==null;if(ui=0,hn=Rt=nt=null,Zf=!1,xu=0,Hl=null,c)throw Error(r(300));a===null||pn||(a=a.dependencies,a!==null&&Bf(a)&&(pn=!0))}function OC(a,c,f,p){nt=a;var v=0;do{if(Vl&&(Hl=null),xu=0,Vl=!1,25<=v)throw Error(r(301));if(v+=1,hn=Rt=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=p1,w=c(f,p)}while(Vl);return w}function FP(){var a=z.H,c=a.useState()[0];return c=typeof c.then=="function"?wu(c):c,a=a.useState()[0],(Rt!==null?Rt.memoizedState:null)!==a&&(nt.flags|=1024),c}function Ky(){var a=Yf!==0;return Yf=0,a}function Zy(a,c,f){c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~f}function Yy(a){if(Zf){for(a=a.memoizedState;a!==null;){var c=a.queue;c!==null&&(c.pending=null),a=a.next}Zf=!1}ui=0,hn=Rt=nt=null,Vl=!1,xu=Yf=0,Hl=null}function ir(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return hn===null?nt.memoizedState=hn=a:hn=hn.next=a,hn}function cn(){if(Rt===null){var a=nt.alternate;a=a!==null?a.memoizedState:null}else a=Rt.next;var c=hn===null?nt.memoizedState:hn.next;if(c!==null)hn=c,Rt=a;else{if(a===null)throw nt.alternate===null?Error(r(467)):Error(r(310));Rt=a,a={memoizedState:Rt.memoizedState,baseState:Rt.baseState,baseQueue:Rt.baseQueue,queue:Rt.queue,next:null},hn===null?nt.memoizedState=hn=a:hn=hn.next=a}return hn}function Xf(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wu(a){var c=xu;return xu+=1,Hl===null&&(Hl=[]),a=SC(Hl,a,c),c=nt,(hn===null?c.memoizedState:hn.next)===null&&(c=c.alternate,z.H=c===null||c.memoizedState===null?h1:lb),a}function Jf(a){if(a!==null&&typeof a=="object"){if(typeof a.then=="function")return wu(a);if(a.$$typeof===R)return Ln(a)}throw Error(r(438,String(a)))}function Xy(a){var c=null,f=nt.updateQueue;if(f!==null&&(c=f.memoCache),c==null){var p=nt.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}),f===null&&(f=Xf(),nt.updateQueue=f),f.memoCache=c,f=c.data[c.index],f===void 0)for(f=c.data[c.index]=Array(a),p=0;p<a;p++)f[p]=F;return c.index++,f}function di(a,c){return typeof c=="function"?c(a):c}function Qf(a){var c=cn();return Jy(c,Rt,a)}function Jy(a,c,f){var p=a.queue;if(p===null)throw Error(r(311));p.lastRenderedReducer=f;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 j=T=null,V=null,J=c,ie=!1;do{var de=J.lane&-536870913;if(de!==J.lane?(ct&de)===de:(ui&de)===de){var Q=J.revertLane;if(Q===0)V!==null&&(V=V.next={lane:0,revertLane:0,gesture:null,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null}),de===Ll&&(ie=!0);else if((ui&Q)===Q){J=J.next,Q===Ll&&(ie=!0);continue}else de={lane:0,revertLane:J.revertLane,gesture:null,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null},V===null?(j=V=de,T=w):V=V.next=de,nt.lanes|=Q,fo|=Q;de=J.action,Ra&&f(w,de),w=J.hasEagerState?J.eagerState:f(w,de)}else Q={lane:de,revertLane:J.revertLane,gesture:J.gesture,action:J.action,hasEagerState:J.hasEagerState,eagerState:J.eagerState,next:null},V===null?(j=V=Q,T=w):V=V.next=Q,nt.lanes|=de,fo|=de;J=J.next}while(J!==null&&J!==c);if(V===null?T=w:V.next=j,!_r(w,a.memoizedState)&&(pn=!0,ie&&(f=Pl,f!==null)))throw f;a.memoizedState=w,a.baseState=T,a.baseQueue=V,p.lastRenderedState=w}return v===null&&(p.lanes=0),[a.memoizedState,p.dispatch]}function Qy(a){var c=cn(),f=c.queue;if(f===null)throw Error(r(311));f.lastRenderedReducer=a;var p=f.dispatch,v=f.pending,w=c.memoizedState;if(v!==null){f.pending=null;var T=v=v.next;do w=a(w,T.action),T=T.next;while(T!==v);_r(w,c.memoizedState)||(pn=!0),c.memoizedState=w,c.baseQueue===null&&(c.baseState=w),f.lastRenderedState=w}return[w,p]}function jC(a,c,f){var p=nt,v=cn(),w=dt;if(w){if(f===void 0)throw Error(r(407));f=f()}else f=c();var T=!_r((Rt||v).memoizedState,f);if(T&&(v.memoizedState=f,pn=!0),v=v.queue,nb(LC.bind(null,p,v,a),[a]),v.getSnapshot!==c||T||hn!==null&&hn.memoizedState.tag&1){if(p.flags|=2048,Ul(9,{destroy:void 0},IC.bind(null,p,v,f,c),null),It===null)throw Error(r(349));w||(ui&127)!==0||DC(p,c,f)}return f}function DC(a,c,f){a.flags|=16384,a={getSnapshot:c,value:f},c=nt.updateQueue,c===null?(c=Xf(),nt.updateQueue=c,c.stores=[a]):(f=c.stores,f===null?c.stores=[a]:f.push(a))}function IC(a,c,f,p){c.value=f,c.getSnapshot=p,PC(c)&&zC(a)}function LC(a,c,f){return f(function(){PC(c)&&zC(a)})}function PC(a){var c=a.getSnapshot;a=a.value;try{var f=c();return!_r(a,f)}catch{return!0}}function zC(a){var c=xa(a,2);c!==null&&wr(c,a,2)}function eb(a){var c=ir();if(typeof a=="function"){var f=a;if(a=f(),Ra){oe(!0);try{f()}finally{oe(!1)}}}return c.memoizedState=c.baseState=a,c.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:di,lastRenderedState:a},c}function $C(a,c,f,p){return a.baseState=f,Jy(a,Rt,typeof p=="function"?p:di)}function qP(a,c,f,p,v){if(nh(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?f(!0):w.isTransition=!1,p(w),f=c.pending,f===null?(w.next=c.pending=w,BC(c,w)):(w.next=f.next,c.pending=f.next=w)}}function BC(a,c){var f=c.action,p=c.payload,v=a.state;if(c.isTransition){var w=z.T,T={};z.T=T;try{var j=f(v,p),V=z.S;V!==null&&V(T,j),VC(a,c,j)}catch(J){tb(a,c,J)}finally{w!==null&&T.types!==null&&(w.types=T.types),z.T=w}}else try{w=f(v,p),VC(a,c,w)}catch(J){tb(a,c,J)}}function VC(a,c,f){f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(function(p){HC(a,c,p)},function(p){return tb(a,c,p)}):HC(a,c,f)}function HC(a,c,f){c.status="fulfilled",c.value=f,UC(c),a.state=f,c=a.pending,c!==null&&(f=c.next,f===c?a.pending=null:(f=f.next,c.next=f,BC(a,f)))}function tb(a,c,f){var p=a.pending;if(a.pending=null,p!==null){p=p.next;do c.status="rejected",c.reason=f,UC(c),c=c.next;while(c!==p)}a.action=null}function UC(a){a=a.listeners;for(var c=0;c<a.length;c++)(0,a[c])()}function FC(a,c){return c}function qC(a,c){if(dt){var f=It.formState;if(f!==null){e:{var p=nt;if(dt){if(Ut){t:{for(var v=Ut,w=Yr;v.nodeType!==8;){if(!w){v=null;break t}if(v=Jr(v.nextSibling),v===null){v=null;break t}}w=v.data,v=w==="F!"||w==="F"?v:null}if(v){Ut=Jr(v.nextSibling),p=v.data==="F!";break e}}no(p)}p=!1}p&&(c=f[0])}}return f=ir(),f.memoizedState=f.baseState=c,p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:FC,lastRenderedState:c},f.queue=p,f=u1.bind(null,nt,p),p.dispatch=f,p=eb(!1),w=ab.bind(null,nt,!1,p.queue),p=ir(),v={state:c,dispatch:null,action:a,pending:null},p.queue=v,f=qP.bind(null,nt,v,w,f),v.dispatch=f,p.memoizedState=a,[c,f,!1]}function GC(a){var c=cn();return WC(c,Rt,a)}function WC(a,c,f){if(c=Jy(a,c,FC)[0],a=Qf(di)[0],typeof c=="object"&&c!==null&&typeof c.then=="function")try{var p=wu(c)}catch(T){throw T===zl?Uf:T}else p=c;c=cn();var v=c.queue,w=v.dispatch;return f!==c.memoizedState&&(nt.flags|=2048,Ul(9,{destroy:void 0},GP.bind(null,v,f),null)),[p,w,a]}function GP(a,c){a.action=c}function KC(a){var c=cn(),f=Rt;if(f!==null)return WC(c,f,a);cn(),c=c.memoizedState,f=cn();var p=f.queue.dispatch;return f.memoizedState=a,[c,p,!1]}function Ul(a,c,f,p){return a={tag:a,create:f,deps:p,inst:c,next:null},c=nt.updateQueue,c===null&&(c=Xf(),nt.updateQueue=c),f=c.lastEffect,f===null?c.lastEffect=a.next=a:(p=f.next,f.next=a,a.next=p,c.lastEffect=a),a}function ZC(){return cn().memoizedState}function eh(a,c,f,p){var v=ir();nt.flags|=a,v.memoizedState=Ul(1|c,{destroy:void 0},f,p===void 0?null:p)}function th(a,c,f,p){var v=cn();p=p===void 0?null:p;var w=v.memoizedState.inst;Rt!==null&&p!==null&&Gy(p,Rt.memoizedState.deps)?v.memoizedState=Ul(c,w,f,p):(nt.flags|=a,v.memoizedState=Ul(1|c,w,f,p))}function YC(a,c){eh(8390656,8,a,c)}function nb(a,c){th(2048,8,a,c)}function WP(a){nt.flags|=4;var c=nt.updateQueue;if(c===null)c=Xf(),nt.updateQueue=c,c.events=[a];else{var f=c.events;f===null?c.events=[a]:f.push(a)}}function XC(a){var c=cn().memoizedState;return WP({ref:c,nextImpl:a}),function(){if((xt&2)!==0)throw Error(r(440));return c.impl.apply(void 0,arguments)}}function JC(a,c){return th(4,2,a,c)}function QC(a,c){return th(4,4,a,c)}function e1(a,c){if(typeof c=="function"){a=a();var f=c(a);return function(){typeof f=="function"?f():c(null)}}if(c!=null)return a=a(),c.current=a,function(){c.current=null}}function t1(a,c,f){f=f!=null?f.concat([a]):null,th(4,4,e1.bind(null,c,a),f)}function rb(){}function n1(a,c){var f=cn();c=c===void 0?null:c;var p=f.memoizedState;return c!==null&&Gy(c,p[1])?p[0]:(f.memoizedState=[a,c],a)}function r1(a,c){var f=cn();c=c===void 0?null:c;var p=f.memoizedState;if(c!==null&&Gy(c,p[1]))return p[0];if(p=a(),Ra){oe(!0);try{a()}finally{oe(!1)}}return f.memoizedState=[p,c],p}function sb(a,c,f){return f===void 0||(ui&1073741824)!==0&&(ct&261930)===0?a.memoizedState=c:(a.memoizedState=f,a=sE(),nt.lanes|=a,fo|=a,f)}function s1(a,c,f,p){return _r(f,c)?f:Bl.current!==null?(a=sb(a,f,p),_r(a,c)||(pn=!0),a):(ui&42)===0||(ui&1073741824)!==0&&(ct&261930)===0?(pn=!0,a.memoizedState=f):(a=sE(),nt.lanes|=a,fo|=a,c)}function i1(a,c,f,p,v){var w=L.p;L.p=w!==0&&8>w?w:8;var T=z.T,j={};z.T=j,ab(a,!1,c,f);try{var V=v(),J=z.S;if(J!==null&&J(j,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var ie=HP(V,p);Su(a,c,ie,jr(a))}else Su(a,c,p,jr(a))}catch(de){Su(a,c,{then:function(){},status:"rejected",reason:de},jr())}finally{L.p=w,T!==null&&j.types!==null&&(T.types=j.types),z.T=T}}function KP(){}function ib(a,c,f,p){if(a.tag!==5)throw Error(r(476));var v=o1(a).queue;i1(a,v,c,W,f===null?KP:function(){return a1(a),f(p)})}function o1(a){var c=a.memoizedState;if(c!==null)return c;c={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:di,lastRenderedState:W},next:null};var f={};return c.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:di,lastRenderedState:f},next:null},a.memoizedState=c,a=a.alternate,a!==null&&(a.memoizedState=c),c}function a1(a){var c=o1(a);c.next===null&&(c=a.alternate.memoizedState),Su(a,c.next.queue,{},jr())}function ob(){return Ln($u)}function l1(){return cn().memoizedState}function c1(){return cn().memoizedState}function ZP(a){for(var c=a.return;c!==null;){switch(c.tag){case 24:case 3:var f=jr();a=io(f);var p=oo(c,a,f);p!==null&&(wr(p,c,f),yu(p,c,f)),c={cache:Iy()},a.payload=c;return}c=c.return}}function YP(a,c,f){var p=jr();f={lane:p,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},nh(a)?d1(c,f):(f=Cy(a,c,f,p),f!==null&&(wr(f,a,p),f1(f,c,p)))}function u1(a,c,f){var p=jr();Su(a,c,f,p)}function Su(a,c,f,p){var v={lane:p,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if(nh(a))d1(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,j=w(T,f);if(v.hasEagerState=!0,v.eagerState=j,_r(j,T))return Lf(a,c,v,0),It===null&&If(),!1}catch{}if(f=Cy(a,c,v,p),f!==null)return wr(f,a,p),f1(f,c,p),!0}return!1}function ab(a,c,f,p){if(p={lane:2,revertLane:$b(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},nh(a)){if(c)throw Error(r(479))}else c=Cy(a,f,p,2),c!==null&&wr(c,a,2)}function nh(a){var c=a.alternate;return a===nt||c!==null&&c===nt}function d1(a,c){Vl=Zf=!0;var f=a.pending;f===null?c.next=c:(c.next=f.next,f.next=c),a.pending=c}function f1(a,c,f){if((f&4194048)!==0){var p=c.lanes;p&=a.pendingLanes,f|=p,c.lanes=f,ha(a,f)}}var ku={readContext:Ln,use:Jf,useCallback:en,useContext:en,useEffect:en,useImperativeHandle:en,useLayoutEffect:en,useInsertionEffect:en,useMemo:en,useReducer:en,useRef:en,useState:en,useDebugValue:en,useDeferredValue:en,useTransition:en,useSyncExternalStore:en,useId:en,useHostTransitionStatus:en,useFormState:en,useActionState:en,useOptimistic:en,useMemoCache:en,useCacheRefresh:en};ku.useEffectEvent=en;var h1={readContext:Ln,use:Jf,useCallback:function(a,c){return ir().memoizedState=[a,c===void 0?null:c],a},useContext:Ln,useEffect:YC,useImperativeHandle:function(a,c,f){f=f!=null?f.concat([a]):null,eh(4194308,4,e1.bind(null,c,a),f)},useLayoutEffect:function(a,c){return eh(4194308,4,a,c)},useInsertionEffect:function(a,c){eh(4,2,a,c)},useMemo:function(a,c){var f=ir();c=c===void 0?null:c;var p=a();if(Ra){oe(!0);try{a()}finally{oe(!1)}}return f.memoizedState=[p,c],p},useReducer:function(a,c,f){var p=ir();if(f!==void 0){var v=f(c);if(Ra){oe(!0);try{f(c)}finally{oe(!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=YP.bind(null,nt,a),[p.memoizedState,a]},useRef:function(a){var c=ir();return a={current:a},c.memoizedState=a},useState:function(a){a=eb(a);var c=a.queue,f=u1.bind(null,nt,c);return c.dispatch=f,[a.memoizedState,f]},useDebugValue:rb,useDeferredValue:function(a,c){var f=ir();return sb(f,a,c)},useTransition:function(){var a=eb(!1);return a=i1.bind(null,nt,a.queue,!0,!1),ir().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,c,f){var p=nt,v=ir();if(dt){if(f===void 0)throw Error(r(407));f=f()}else{if(f=c(),It===null)throw Error(r(349));(ct&127)!==0||DC(p,c,f)}v.memoizedState=f;var w={value:f,getSnapshot:c};return v.queue=w,YC(LC.bind(null,p,w,a),[a]),p.flags|=2048,Ul(9,{destroy:void 0},IC.bind(null,p,w,f,c),null),f},useId:function(){var a=ir(),c=It.identifierPrefix;if(dt){var f=Ps,p=Ls;f=(p&~(1<<32-xe(p)-1)).toString(32)+f,c="_"+c+"R_"+f,f=Yf++,0<f&&(c+="H"+f.toString(32)),c+="_"}else f=UP++,c="_"+c+"r_"+f.toString(32)+"_";return a.memoizedState=c},useHostTransitionStatus:ob,useFormState:qC,useActionState:qC,useOptimistic:function(a){var c=ir();c.memoizedState=c.baseState=a;var f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return c.queue=f,c=ab.bind(null,nt,!0,f),f.dispatch=c,[a,c]},useMemoCache:Xy,useCacheRefresh:function(){return ir().memoizedState=ZP.bind(null,nt)},useEffectEvent:function(a){var c=ir(),f={impl:a};return c.memoizedState=f,function(){if((xt&2)!==0)throw Error(r(440));return f.impl.apply(void 0,arguments)}}},lb={readContext:Ln,use:Jf,useCallback:n1,useContext:Ln,useEffect:nb,useImperativeHandle:t1,useInsertionEffect:JC,useLayoutEffect:QC,useMemo:r1,useReducer:Qf,useRef:ZC,useState:function(){return Qf(di)},useDebugValue:rb,useDeferredValue:function(a,c){var f=cn();return s1(f,Rt.memoizedState,a,c)},useTransition:function(){var a=Qf(di)[0],c=cn().memoizedState;return[typeof a=="boolean"?a:wu(a),c]},useSyncExternalStore:jC,useId:l1,useHostTransitionStatus:ob,useFormState:GC,useActionState:GC,useOptimistic:function(a,c){var f=cn();return $C(f,Rt,a,c)},useMemoCache:Xy,useCacheRefresh:c1};lb.useEffectEvent=XC;var p1={readContext:Ln,use:Jf,useCallback:n1,useContext:Ln,useEffect:nb,useImperativeHandle:t1,useInsertionEffect:JC,useLayoutEffect:QC,useMemo:r1,useReducer:Qy,useRef:ZC,useState:function(){return Qy(di)},useDebugValue:rb,useDeferredValue:function(a,c){var f=cn();return Rt===null?sb(f,a,c):s1(f,Rt.memoizedState,a,c)},useTransition:function(){var a=Qy(di)[0],c=cn().memoizedState;return[typeof a=="boolean"?a:wu(a),c]},useSyncExternalStore:jC,useId:l1,useHostTransitionStatus:ob,useFormState:KC,useActionState:KC,useOptimistic:function(a,c){var f=cn();return Rt!==null?$C(f,Rt,a,c):(f.baseState=a,[a,f.queue.dispatch])},useMemoCache:Xy,useCacheRefresh:c1};p1.useEffectEvent=XC;function cb(a,c,f,p){c=a.memoizedState,f=f(p,c),f=f==null?c:g({},c,f),a.memoizedState=f,a.lanes===0&&(a.updateQueue.baseState=f)}var ub={enqueueSetState:function(a,c,f){a=a._reactInternals;var p=jr(),v=io(p);v.payload=c,f!=null&&(v.callback=f),c=oo(a,v,p),c!==null&&(wr(c,a,p),yu(c,a,p))},enqueueReplaceState:function(a,c,f){a=a._reactInternals;var p=jr(),v=io(p);v.tag=1,v.payload=c,f!=null&&(v.callback=f),c=oo(a,v,p),c!==null&&(wr(c,a,p),yu(c,a,p))},enqueueForceUpdate:function(a,c){a=a._reactInternals;var f=jr(),p=io(f);p.tag=2,c!=null&&(p.callback=c),c=oo(a,p,f),c!==null&&(wr(c,a,f),yu(c,a,f))}};function m1(a,c,f,p,v,w,T){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(p,w,T):c.prototype&&c.prototype.isPureReactComponent?!cu(f,p)||!cu(v,w):!0}function g1(a,c,f,p){a=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(f,p),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(f,p),c.state!==a&&ub.enqueueReplaceState(c,c.state,null)}function Na(a,c){var f=c;if("ref"in c){f={};for(var p in c)p!=="ref"&&(f[p]=c[p])}if(a=a.defaultProps){f===c&&(f=g({},f));for(var v in a)f[v]===void 0&&(f[v]=a[v])}return f}function y1(a){Df(a)}function b1(a){console.error(a)}function v1(a){Df(a)}function rh(a,c){try{var f=a.onUncaughtError;f(c.value,{componentStack:c.stack})}catch(p){setTimeout(function(){throw p})}}function x1(a,c,f){try{var p=a.onCaughtError;p(f.value,{componentStack:f.stack,errorBoundary:c.tag===1?c.stateNode:null})}catch(v){setTimeout(function(){throw v})}}function db(a,c,f){return f=io(f),f.tag=3,f.payload={element:null},f.callback=function(){rh(a,c)},f}function w1(a){return a=io(a),a.tag=3,a}function S1(a,c,f,p){var v=f.type.getDerivedStateFromError;if(typeof v=="function"){var w=p.value;a.payload=function(){return v(w)},a.callback=function(){x1(c,f,p)}}var T=f.stateNode;T!==null&&typeof T.componentDidCatch=="function"&&(a.callback=function(){x1(c,f,p),typeof v!="function"&&(ho===null?ho=new Set([this]):ho.add(this));var j=p.stack;this.componentDidCatch(p.value,{componentStack:j!==null?j:""})})}function XP(a,c,f,p,v){if(f.flags|=32768,p!==null&&typeof p=="object"&&typeof p.then=="function"){if(c=f.alternate,c!==null&&Il(c,f,v,!0),f=Rr.current,f!==null){switch(f.tag){case 31:case 13:return Xr===null?mh():f.alternate===null&&tn===0&&(tn=3),f.flags&=-257,f.flags|=65536,f.lanes=v,p===Ff?f.flags|=16384:(c=f.updateQueue,c===null?f.updateQueue=new Set([p]):c.add(p),Lb(a,p,v)),!1;case 22:return f.flags|=65536,p===Ff?f.flags|=16384:(c=f.updateQueue,c===null?(c={transitions:null,markerInstances:null,retryQueue:new Set([p])},f.updateQueue=c):(f=c.retryQueue,f===null?c.retryQueue=new Set([p]):f.add(p)),Lb(a,p,v)),!1}throw Error(r(435,f.tag))}return Lb(a,p,v),mh(),!1}if(dt)return c=Rr.current,c!==null?((c.flags&65536)===0&&(c.flags|=256),c.flags|=65536,c.lanes=v,p!==Ny&&(a=Error(r(422),{cause:p}),fu(Wr(a,f)))):(p!==Ny&&(c=Error(r(423),{cause:p}),fu(Wr(c,f))),a=a.current.alternate,a.flags|=65536,v&=-v,a.lanes|=v,p=Wr(p,f),v=db(a.stateNode,p,v),Vy(a,v),tn!==4&&(tn=2)),!1;var w=Error(r(520),{cause:p});if(w=Wr(w,f),Mu===null?Mu=[w]:Mu.push(w),tn!==4&&(tn=2),c===null)return!0;p=Wr(p,f),f=c;do{switch(f.tag){case 3:return f.flags|=65536,a=v&-v,f.lanes|=a,a=db(f.stateNode,p,a),Vy(f,a),!1;case 1:if(c=f.type,w=f.stateNode,(f.flags&128)===0&&(typeof c.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(ho===null||!ho.has(w))))return f.flags|=65536,v&=-v,f.lanes|=v,v=w1(v),S1(v,a,f,p),Vy(f,v),!1}f=f.return}while(f!==null);return!1}var fb=Error(r(461)),pn=!1;function Pn(a,c,f,p){c.child=a===null?TC(c,null,f,p):Aa(c,a.child,f,p)}function k1(a,c,f,p,v){f=f.render;var w=c.ref;if("ref"in p){var T={};for(var j in p)j!=="ref"&&(T[j]=p[j])}else T=p;return Ca(c),p=Wy(a,c,f,T,w,v),j=Ky(),a!==null&&!pn?(Zy(a,c,v),fi(a,c,v)):(dt&&j&&Ay(c),c.flags|=1,Pn(a,c,p,v),c.child)}function C1(a,c,f,p,v){if(a===null){var w=f.type;return typeof w=="function"&&!Ey(w)&&w.defaultProps===void 0&&f.compare===null?(c.tag=15,c.type=w,E1(a,c,w,p,v)):(a=zf(f.type,null,p,c,c.mode,v),a.ref=c.ref,a.return=c,c.child=a)}if(w=a.child,!xb(a,v)){var T=w.memoizedProps;if(f=f.compare,f=f!==null?f:cu,f(T,p)&&a.ref===c.ref)return fi(a,c,v)}return c.flags|=1,a=oi(w,p),a.ref=c.ref,a.return=c,c.child=a}function E1(a,c,f,p,v){if(a!==null){var w=a.memoizedProps;if(cu(w,p)&&a.ref===c.ref)if(pn=!1,c.pendingProps=p=w,xb(a,v))(a.flags&131072)!==0&&(pn=!0);else return c.lanes=a.lanes,fi(a,c,v)}return hb(a,c,f,p,v)}function T1(a,c,f,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|f:f,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 _1(a,c,w,f,p)}if((f&536870912)!==0)c.memoizedState={baseLanes:0,cachePool:null},a!==null&&Hf(c,w!==null?w.cachePool:null),w!==null?RC(c,w):Uy(),NC(c);else return p=c.lanes=536870912,_1(a,c,w!==null?w.baseLanes|f:f,f,p)}else w!==null?(Hf(c,w.cachePool),RC(c,w),lo(),c.memoizedState=null):(a!==null&&Hf(c,null),Uy(),lo());return Pn(a,c,v,f),c.child}function Cu(a,c){return a!==null&&a.tag===22||c.stateNode!==null||(c.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.sibling}function _1(a,c,f,p,v){var w=Py();return w=w===null?null:{parent:fn._currentValue,pool:w},c.memoizedState={baseLanes:f,cachePool:w},a!==null&&Hf(c,null),Uy(),NC(c),a!==null&&Il(a,c,p,!0),c.childLanes=v,null}function sh(a,c){return c=oh({mode:c.mode,children:c.children},a.mode),c.ref=a.ref,a.child=c,c.return=a,c}function A1(a,c,f){return Aa(c,a.child,null,f),a=sh(c,c.pendingProps),a.flags|=2,Nr(c),c.memoizedState=null,a}function JP(a,c,f){var p=c.pendingProps,v=(c.flags&128)!==0;if(c.flags&=-129,a===null){if(dt){if(p.mode==="hidden")return a=sh(c,p),c.lanes=536870912,Cu(null,a);if(qy(c),(a=Ut)?(a=BE(a,Yr),a=a!==null&&a.data==="&"?a:null,a!==null&&(c.memoizedState={dehydrated:a,treeContext:eo!==null?{id:Ls,overflow:Ps}:null,retryLane:536870912,hydrationErrors:null},f=dC(a),f.return=c,c.child=f,In=c,Ut=null)):a=null,a===null)throw no(c);return c.lanes=536870912,null}return sh(c,p)}var w=a.memoizedState;if(w!==null){var T=w.dehydrated;if(qy(c),v)if(c.flags&256)c.flags&=-257,c=A1(a,c,f);else if(c.memoizedState!==null)c.child=a.child,c.flags|=128,c=null;else throw Error(r(558));else if(pn||Il(a,c,f,!1),v=(f&a.childLanes)!==0,pn||v){if(p=It,p!==null&&(T=pa(p,f),T!==0&&T!==w.retryLane))throw w.retryLane=T,xa(a,T),wr(p,a,T),fb;mh(),c=A1(a,c,f)}else a=w.treeContext,Ut=Jr(T.nextSibling),In=c,dt=!0,to=null,Yr=!1,a!==null&&pC(c,a),c=sh(c,p),c.flags|=4096;return c}return a=oi(a.child,{mode:p.mode,children:p.children}),a.ref=c.ref,c.child=a,a.return=c,a}function ih(a,c){var f=c.ref;if(f===null)a!==null&&a.ref!==null&&(c.flags|=4194816);else{if(typeof f!="function"&&typeof f!="object")throw Error(r(284));(a===null||a.ref!==f)&&(c.flags|=4194816)}}function hb(a,c,f,p,v){return Ca(c),f=Wy(a,c,f,p,void 0,v),p=Ky(),a!==null&&!pn?(Zy(a,c,v),fi(a,c,v)):(dt&&p&&Ay(c),c.flags|=1,Pn(a,c,f,v),c.child)}function R1(a,c,f,p,v,w){return Ca(c),c.updateQueue=null,f=OC(c,p,f,v),MC(a),p=Ky(),a!==null&&!pn?(Zy(a,c,w),fi(a,c,w)):(dt&&p&&Ay(c),c.flags|=1,Pn(a,c,f,w),c.child)}function N1(a,c,f,p,v){if(Ca(c),c.stateNode===null){var w=Ml,T=f.contextType;typeof T=="object"&&T!==null&&(w=Ln(T)),w=new f(p,w),c.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,w.updater=ub,c.stateNode=w,w._reactInternals=c,w=c.stateNode,w.props=p,w.state=c.memoizedState,w.refs={},$y(c),T=f.contextType,w.context=typeof T=="object"&&T!==null?Ln(T):Ml,w.state=c.memoizedState,T=f.getDerivedStateFromProps,typeof T=="function"&&(cb(c,f,T,p),w.state=c.memoizedState),typeof f.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&&ub.enqueueReplaceState(w,w.state,null),vu(c,p,w,v),bu(),w.state=c.memoizedState),typeof w.componentDidMount=="function"&&(c.flags|=4194308),p=!0}else if(a===null){w=c.stateNode;var j=c.memoizedProps,V=Na(f,j);w.props=V;var J=w.context,ie=f.contextType;T=Ml,typeof ie=="object"&&ie!==null&&(T=Ln(ie));var de=f.getDerivedStateFromProps;ie=typeof de=="function"||typeof w.getSnapshotBeforeUpdate=="function",j=c.pendingProps!==j,ie||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(j||J!==T)&&g1(c,w,p,T),so=!1;var Q=c.memoizedState;w.state=Q,vu(c,p,w,v),bu(),J=c.memoizedState,j||Q!==J||so?(typeof de=="function"&&(cb(c,f,de,p),J=c.memoizedState),(V=so||m1(c,f,V,p,Q,J,T))?(ie||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=J),w.props=p,w.state=J,w.context=T,p=V):(typeof w.componentDidMount=="function"&&(c.flags|=4194308),p=!1)}else{w=c.stateNode,By(a,c),T=c.memoizedProps,ie=Na(f,T),w.props=ie,de=c.pendingProps,Q=w.context,J=f.contextType,V=Ml,typeof J=="object"&&J!==null&&(V=Ln(J)),j=f.getDerivedStateFromProps,(J=typeof j=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(T!==de||Q!==V)&&g1(c,w,p,V),so=!1,Q=c.memoizedState,w.state=Q,vu(c,p,w,v),bu();var ne=c.memoizedState;T!==de||Q!==ne||so||a!==null&&a.dependencies!==null&&Bf(a.dependencies)?(typeof j=="function"&&(cb(c,f,j,p),ne=c.memoizedState),(ie=so||m1(c,f,ie,p,Q,ne,V)||a!==null&&a.dependencies!==null&&Bf(a.dependencies))?(J||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(p,ne,V),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(p,ne,V)),typeof w.componentDidUpdate=="function"&&(c.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof w.componentDidUpdate!="function"||T===a.memoizedProps&&Q===a.memoizedState||(c.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||T===a.memoizedProps&&Q===a.memoizedState||(c.flags|=1024),c.memoizedProps=p,c.memoizedState=ne),w.props=p,w.state=ne,w.context=V,p=ie):(typeof w.componentDidUpdate!="function"||T===a.memoizedProps&&Q===a.memoizedState||(c.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||T===a.memoizedProps&&Q===a.memoizedState||(c.flags|=1024),p=!1)}return w=p,ih(a,c),p=(c.flags&128)!==0,w||p?(w=c.stateNode,f=p&&typeof f.getDerivedStateFromError!="function"?null:w.render(),c.flags|=1,a!==null&&p?(c.child=Aa(c,a.child,null,v),c.child=Aa(c,null,f,v)):Pn(a,c,f,v),c.memoizedState=w.state,a=c.child):a=fi(a,c,v),a}function M1(a,c,f,p){return Sa(),c.flags|=256,Pn(a,c,f,p),c.child}var pb={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function mb(a){return{baseLanes:a,cachePool:xC()}}function gb(a,c,f){return a=a!==null?a.childLanes&~f:0,c&&(a|=Or),a}function O1(a,c,f){var p=c.pendingProps,v=!1,w=(c.flags&128)!==0,T;if((T=w)||(T=a!==null&&a.memoizedState===null?!1:(ln.current&2)!==0),T&&(v=!0,c.flags&=-129),T=(c.flags&32)!==0,c.flags&=-33,a===null){if(dt){if(v?ao(c):lo(),(a=Ut)?(a=BE(a,Yr),a=a!==null&&a.data!=="&"?a:null,a!==null&&(c.memoizedState={dehydrated:a,treeContext:eo!==null?{id:Ls,overflow:Ps}:null,retryLane:536870912,hydrationErrors:null},f=dC(a),f.return=c,c.child=f,In=c,Ut=null)):a=null,a===null)throw no(c);return Jb(a)?c.lanes=32:c.lanes=536870912,null}var j=p.children;return p=p.fallback,v?(lo(),v=c.mode,j=oh({mode:"hidden",children:j},v),p=wa(p,v,f,null),j.return=c,p.return=c,j.sibling=p,c.child=j,p=c.child,p.memoizedState=mb(f),p.childLanes=gb(a,T,f),c.memoizedState=pb,Cu(null,p)):(ao(c),yb(c,j))}var V=a.memoizedState;if(V!==null&&(j=V.dehydrated,j!==null)){if(w)c.flags&256?(ao(c),c.flags&=-257,c=bb(a,c,f)):c.memoizedState!==null?(lo(),c.child=a.child,c.flags|=128,c=null):(lo(),j=p.fallback,v=c.mode,p=oh({mode:"visible",children:p.children},v),j=wa(j,v,f,null),j.flags|=2,p.return=c,j.return=c,p.sibling=j,c.child=p,Aa(c,a.child,null,f),p=c.child,p.memoizedState=mb(f),p.childLanes=gb(a,T,f),c.memoizedState=pb,c=Cu(null,p));else if(ao(c),Jb(j)){if(T=j.nextSibling&&j.nextSibling.dataset,T)var J=T.dgst;T=J,p=Error(r(419)),p.stack="",p.digest=T,fu({value:p,source:null,stack:null}),c=bb(a,c,f)}else if(pn||Il(a,c,f,!1),T=(f&a.childLanes)!==0,pn||T){if(T=It,T!==null&&(p=pa(T,f),p!==0&&p!==V.retryLane))throw V.retryLane=p,xa(a,p),wr(T,a,p),fb;Xb(j)||mh(),c=bb(a,c,f)}else Xb(j)?(c.flags|=192,c.child=a.child,c=null):(a=V.treeContext,Ut=Jr(j.nextSibling),In=c,dt=!0,to=null,Yr=!1,a!==null&&pC(c,a),c=yb(c,p.children),c.flags|=4096);return c}return v?(lo(),j=p.fallback,v=c.mode,V=a.child,J=V.sibling,p=oi(V,{mode:"hidden",children:p.children}),p.subtreeFlags=V.subtreeFlags&65011712,J!==null?j=oi(J,j):(j=wa(j,v,f,null),j.flags|=2),j.return=c,p.return=c,p.sibling=j,c.child=p,Cu(null,p),p=c.child,j=a.child.memoizedState,j===null?j=mb(f):(v=j.cachePool,v!==null?(V=fn._currentValue,v=v.parent!==V?{parent:V,pool:V}:v):v=xC(),j={baseLanes:j.baseLanes|f,cachePool:v}),p.memoizedState=j,p.childLanes=gb(a,T,f),c.memoizedState=pb,Cu(a.child,p)):(ao(c),f=a.child,a=f.sibling,f=oi(f,{mode:"visible",children:p.children}),f.return=c,f.sibling=null,a!==null&&(T=c.deletions,T===null?(c.deletions=[a],c.flags|=16):T.push(a)),c.child=f,c.memoizedState=null,f)}function yb(a,c){return c=oh({mode:"visible",children:c},a.mode),c.return=a,a.child=c}function oh(a,c){return a=Ar(22,a,null,c),a.lanes=0,a}function bb(a,c,f){return Aa(c,a.child,null,f),a=yb(c,c.pendingProps.children),a.flags|=2,c.memoizedState=null,a}function j1(a,c,f){a.lanes|=c;var p=a.alternate;p!==null&&(p.lanes|=c),jy(a.return,c,f)}function vb(a,c,f,p,v,w){var T=a.memoizedState;T===null?a.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:p,tail:f,tailMode:v,treeForkCount:w}:(T.isBackwards=c,T.rendering=null,T.renderingStartTime=0,T.last=p,T.tail=f,T.tailMode=v,T.treeForkCount=w)}function D1(a,c,f){var p=c.pendingProps,v=p.revealOrder,w=p.tail;p=p.children;var T=ln.current,j=(T&2)!==0;if(j?(T=T&1|2,c.flags|=128):T&=1,he(ln,T),Pn(a,c,p,f),p=dt?du:0,!j&&a!==null&&(a.flags&128)!==0)e:for(a=c.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&j1(a,f,c);else if(a.tag===19)j1(a,f,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(f=c.child,v=null;f!==null;)a=f.alternate,a!==null&&Kf(a)===null&&(v=f),f=f.sibling;f=v,f===null?(v=c.child,c.child=null):(v=f.sibling,f.sibling=null),vb(c,!1,v,f,w,p);break;case"backwards":case"unstable_legacy-backwards":for(f=null,v=c.child,c.child=null;v!==null;){if(a=v.alternate,a!==null&&Kf(a)===null){c.child=v;break}a=v.sibling,v.sibling=f,f=v,v=a}vb(c,!0,f,null,w,p);break;case"together":vb(c,!1,null,null,void 0,p);break;default:c.memoizedState=null}return c.child}function fi(a,c,f){if(a!==null&&(c.dependencies=a.dependencies),fo|=c.lanes,(f&c.childLanes)===0)if(a!==null){if(Il(a,c,f,!1),(f&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,f=oi(a,a.pendingProps),c.child=f,f.return=c;a.sibling!==null;)a=a.sibling,f=f.sibling=oi(a,a.pendingProps),f.return=c;f.sibling=null}return c.child}function xb(a,c){return(a.lanes&c)!==0?!0:(a=a.dependencies,!!(a!==null&&Bf(a)))}function QP(a,c,f){switch(c.tag){case 3:Ee(c,c.stateNode.containerInfo),ro(c,fn,a.memoizedState.cache),Sa();break;case 27:case 5:me(c);break;case 4:Ee(c,c.stateNode.containerInfo);break;case 10:ro(c,c.type,c.memoizedProps.value);break;case 31:if(c.memoizedState!==null)return c.flags|=128,qy(c),null;break;case 13:var p=c.memoizedState;if(p!==null)return p.dehydrated!==null?(ao(c),c.flags|=128,null):(f&c.child.childLanes)!==0?O1(a,c,f):(ao(c),a=fi(a,c,f),a!==null?a.sibling:null);ao(c);break;case 19:var v=(a.flags&128)!==0;if(p=(f&c.childLanes)!==0,p||(Il(a,c,f,!1),p=(f&c.childLanes)!==0),v){if(p)return D1(a,c,f);c.flags|=128}if(v=c.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),he(ln,ln.current),p)break;return null;case 22:return c.lanes=0,T1(a,c,f,c.pendingProps);case 24:ro(c,fn,a.memoizedState.cache)}return fi(a,c,f)}function I1(a,c,f){if(a!==null)if(a.memoizedProps!==c.pendingProps)pn=!0;else{if(!xb(a,f)&&(c.flags&128)===0)return pn=!1,QP(a,c,f);pn=(a.flags&131072)!==0}else pn=!1,dt&&(c.flags&1048576)!==0&&hC(c,du,c.index);switch(c.lanes=0,c.tag){case 16:e:{var p=c.pendingProps;if(a=Ta(c.elementType),c.type=a,typeof a=="function")Ey(a)?(p=Na(a,p),c.tag=1,c=N1(null,c,a,p,f)):(c.tag=0,c=hb(null,c,a,p,f));else{if(a!=null){var v=a.$$typeof;if(v===_){c.tag=11,c=k1(null,c,a,p,f);break e}else if(v===O){c.tag=14,c=C1(null,c,a,p,f);break e}}throw c=G(a)||a,Error(r(306,c,""))}}return c;case 0:return hb(a,c,c.type,c.pendingProps,f);case 1:return p=c.type,v=Na(p,c.pendingProps),N1(a,c,p,v,f);case 3:e:{if(Ee(c,c.stateNode.containerInfo),a===null)throw Error(r(387));p=c.pendingProps;var w=c.memoizedState;v=w.element,By(a,c),vu(c,p,null,f);var T=c.memoizedState;if(p=T.cache,ro(c,fn,p),p!==w.cache&&Dy(c,[fn],f,!0),bu(),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=M1(a,c,p,f);break e}else if(p!==v){v=Wr(Error(r(424)),c),fu(v),c=M1(a,c,p,f);break e}else for(a=c.stateNode.containerInfo,a.nodeType===9?a=a.body:a=a.nodeName==="HTML"?a.ownerDocument.body:a,Ut=Jr(a.firstChild),In=c,dt=!0,to=null,Yr=!0,f=TC(c,null,p,f),c.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(Sa(),p===v){c=fi(a,c,f);break e}Pn(a,c,p,f)}c=c.child}return c;case 26:return ih(a,c),a===null?(f=GE(c.type,null,c.pendingProps,null))?c.memoizedState=f:dt||(f=c.type,a=c.pendingProps,p=Sh(Ce.current).createElement(f),p[ee]=c,p[re]=a,zn(p,f,a),Cn(p),c.stateNode=p):c.memoizedState=GE(c.type,a.memoizedProps,c.pendingProps,a.memoizedState),null;case 27:return me(c),a===null&&dt&&(p=c.stateNode=UE(c.type,c.pendingProps,Ce.current),In=c,Yr=!0,v=Ut,yo(c.type)?(Qb=v,Ut=Jr(p.firstChild)):Ut=v),Pn(a,c,c.pendingProps.children,f),ih(a,c),a===null&&(c.flags|=4194304),c.child;case 5:return a===null&&dt&&((v=p=Ut)&&(p=Rz(p,c.type,c.pendingProps,Yr),p!==null?(c.stateNode=p,In=c,Ut=Jr(p.firstChild),Yr=!1,v=!0):v=!1),v||no(c)),me(c),v=c.type,w=c.pendingProps,T=a!==null?a.memoizedProps:null,p=w.children,Kb(v,w)?p=null:T!==null&&Kb(v,T)&&(c.flags|=32),c.memoizedState!==null&&(v=Wy(a,c,FP,null,null,f),$u._currentValue=v),ih(a,c),Pn(a,c,p,f),c.child;case 6:return a===null&&dt&&((a=f=Ut)&&(f=Nz(f,c.pendingProps,Yr),f!==null?(c.stateNode=f,In=c,Ut=null,a=!0):a=!1),a||no(c)),null;case 13:return O1(a,c,f);case 4:return Ee(c,c.stateNode.containerInfo),p=c.pendingProps,a===null?c.child=Aa(c,null,p,f):Pn(a,c,p,f),c.child;case 11:return k1(a,c,c.type,c.pendingProps,f);case 7:return Pn(a,c,c.pendingProps,f),c.child;case 8:return Pn(a,c,c.pendingProps.children,f),c.child;case 12:return Pn(a,c,c.pendingProps.children,f),c.child;case 10:return p=c.pendingProps,ro(c,c.type,p.value),Pn(a,c,p.children,f),c.child;case 9:return v=c.type._context,p=c.pendingProps.children,Ca(c),v=Ln(v),p=p(v),c.flags|=1,Pn(a,c,p,f),c.child;case 14:return C1(a,c,c.type,c.pendingProps,f);case 15:return E1(a,c,c.type,c.pendingProps,f);case 19:return D1(a,c,f);case 31:return JP(a,c,f);case 22:return T1(a,c,f,c.pendingProps);case 24:return Ca(c),p=Ln(fn),a===null?(v=Py(),v===null&&(v=It,w=Iy(),v.pooledCache=w,w.refCount++,w!==null&&(v.pooledCacheLanes|=f),v=w),c.memoizedState={parent:p,cache:v},$y(c),ro(c,fn,v)):((a.lanes&f)!==0&&(By(a,c),vu(c,null,null,f),bu()),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),ro(c,fn,p)):(p=w.cache,ro(c,fn,p),p!==v.cache&&Dy(c,[fn],f,!0))),Pn(a,c,c.pendingProps.children,f),c.child;case 29:throw c.pendingProps}throw Error(r(156,c.tag))}function hi(a){a.flags|=4}function wb(a,c,f,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(lE())a.flags|=8192;else throw _a=Ff,zy}else a.flags&=-16777217}function L1(a,c){if(c.type!=="stylesheet"||(c.state.loading&4)!==0)a.flags&=-16777217;else if(a.flags|=16777216,!XE(c))if(lE())a.flags|=8192;else throw _a=Ff,zy}function ah(a,c){c!==null&&(a.flags|=4),a.flags&16384&&(c=a.tag!==22?ti():536870912,a.lanes|=c,Wl|=c)}function Eu(a,c){if(!dt)switch(a.tailMode){case"hidden":c=a.tail;for(var f=null;c!==null;)c.alternate!==null&&(f=c),c=c.sibling;f===null?a.tail=null:f.sibling=null;break;case"collapsed":f=a.tail;for(var p=null;f!==null;)f.alternate!==null&&(p=f),f=f.sibling;p===null?c||a.tail===null?a.tail=null:a.tail.sibling=null:p.sibling=null}}function Ft(a){var c=a.alternate!==null&&a.alternate.child===a.child,f=0,p=0;if(c)for(var v=a.child;v!==null;)f|=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;)f|=v.lanes|v.childLanes,p|=v.subtreeFlags,p|=v.flags,v.return=a,v=v.sibling;return a.subtreeFlags|=p,a.childLanes=f,c}function ez(a,c,f){var p=c.pendingProps;switch(Ry(c),c.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ft(c),null;case 1:return Ft(c),null;case 3:return f=c.stateNode,p=null,a!==null&&(p=a.memoizedState.cache),c.memoizedState.cache!==p&&(c.flags|=2048),ci(fn),le(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(a===null||a.child===null)&&(Dl(c)?hi(c):a===null||a.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,My())),Ft(c),null;case 26:var v=c.type,w=c.memoizedState;return a===null?(hi(c),w!==null?(Ft(c),L1(c,w)):(Ft(c),wb(c,v,null,p,f))):w?w!==a.memoizedState?(hi(c),Ft(c),L1(c,w)):(Ft(c),c.flags&=-16777217):(a=a.memoizedProps,a!==p&&hi(c),Ft(c),wb(c,v,a,p,f)),null;case 27:if(De(c),f=Ce.current,v=c.type,a!==null&&c.stateNode!=null)a.memoizedProps!==p&&hi(c);else{if(!p){if(c.stateNode===null)throw Error(r(166));return Ft(c),null}a=be.current,Dl(c)?mC(c):(a=UE(v,p,f),c.stateNode=a,hi(c))}return Ft(c),null;case 5:if(De(c),v=c.type,a!==null&&c.stateNode!=null)a.memoizedProps!==p&&hi(c);else{if(!p){if(c.stateNode===null)throw Error(r(166));return Ft(c),null}if(w=be.current,Dl(c))mC(c);else{var T=Sh(Ce.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[ee]=c,w[re]=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(zn(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&&hi(c)}}return Ft(c),wb(c,c.type,a===null?null:a.memoizedProps,c.pendingProps,f),null;case 6:if(a&&c.stateNode!=null)a.memoizedProps!==p&&hi(c);else{if(typeof p!="string"&&c.stateNode===null)throw Error(r(166));if(a=Ce.current,Dl(c)){if(a=c.stateNode,f=c.memoizedProps,p=null,v=In,v!==null)switch(v.tag){case 27:case 5:p=v.memoizedProps}a[ee]=c,a=!!(a.nodeValue===f||p!==null&&p.suppressHydrationWarning===!0||OE(a.nodeValue,f)),a||no(c,!0)}else a=Sh(a).createTextNode(p),a[ee]=c,c.stateNode=a}return Ft(c),null;case 31:if(f=c.memoizedState,a===null||a.memoizedState!==null){if(p=Dl(c),f!==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[ee]=c}else Sa(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Ft(c),a=!1}else f=My(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=f),a=!0;if(!a)return c.flags&256?(Nr(c),c):(Nr(c),null);if((c.flags&128)!==0)throw Error(r(558))}return Ft(c),null;case 13:if(p=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(v=Dl(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[ee]=c}else Sa(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Ft(c),v=!1}else v=My(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=v),v=!0;if(!v)return c.flags&256?(Nr(c),c):(Nr(c),null)}return Nr(c),(c.flags&128)!==0?(c.lanes=f,c):(f=p!==null,a=a!==null&&a.memoizedState!==null,f&&(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)),f!==a&&f&&(c.child.flags|=8192),ah(c,c.updateQueue),Ft(c),null);case 4:return le(),a===null&&Ub(c.stateNode.containerInfo),Ft(c),null;case 10:return ci(c.type),Ft(c),null;case 19:if(Y(ln),p=c.memoizedState,p===null)return Ft(c),null;if(v=(c.flags&128)!==0,w=p.rendering,w===null)if(v)Eu(p,!1);else{if(tn!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(w=Kf(a),w!==null){for(c.flags|=128,Eu(p,!1),a=w.updateQueue,c.updateQueue=a,ah(c,a),c.subtreeFlags=0,a=f,f=c.child;f!==null;)uC(f,a),f=f.sibling;return he(ln,ln.current&1|2),dt&&ai(c,p.treeForkCount),c.child}a=a.sibling}p.tail!==null&&Ht()>fh&&(c.flags|=128,v=!0,Eu(p,!1),c.lanes=4194304)}else{if(!v)if(a=Kf(w),a!==null){if(c.flags|=128,v=!0,a=a.updateQueue,c.updateQueue=a,ah(c,a),Eu(p,!0),p.tail===null&&p.tailMode==="hidden"&&!w.alternate&&!dt)return Ft(c),null}else 2*Ht()-p.renderingStartTime>fh&&f!==536870912&&(c.flags|=128,v=!0,Eu(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,f=ln.current,he(ln,v?f&1|2:f&1),dt&&ai(c,p.treeForkCount),a):(Ft(c),null);case 22:case 23:return Nr(c),Fy(),p=c.memoizedState!==null,a!==null?a.memoizedState!==null!==p&&(c.flags|=8192):p&&(c.flags|=8192),p?(f&536870912)!==0&&(c.flags&128)===0&&(Ft(c),c.subtreeFlags&6&&(c.flags|=8192)):Ft(c),f=c.updateQueue,f!==null&&ah(c,f.retryQueue),f=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(f=a.memoizedState.cachePool.pool),p=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(p=c.memoizedState.cachePool.pool),p!==f&&(c.flags|=2048),a!==null&&Y(Ea),null;case 24:return f=null,a!==null&&(f=a.memoizedState.cache),c.memoizedState.cache!==f&&(c.flags|=2048),ci(fn),Ft(c),null;case 25:return null;case 30:return null}throw Error(r(156,c.tag))}function tz(a,c){switch(Ry(c),c.tag){case 1:return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return ci(fn),le(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 26:case 27:case 5:return De(c),null;case 31:if(c.memoizedState!==null){if(Nr(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(Nr(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 Y(ln),null;case 4:return le(),null;case 10:return ci(c.type),null;case 22:case 23:return Nr(c),Fy(),a!==null&&Y(Ea),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 24:return ci(fn),null;case 25:return null;default:return null}}function P1(a,c){switch(Ry(c),c.tag){case 3:ci(fn),le();break;case 26:case 27:case 5:De(c);break;case 4:le();break;case 31:c.memoizedState!==null&&Nr(c);break;case 13:Nr(c);break;case 19:Y(ln);break;case 10:ci(c.type);break;case 22:case 23:Nr(c),Fy(),a!==null&&Y(Ea);break;case 24:ci(fn)}}function Tu(a,c){try{var f=c.updateQueue,p=f!==null?f.lastEffect:null;if(p!==null){var v=p.next;f=v;do{if((f.tag&a)===a){p=void 0;var w=f.create,T=f.inst;p=w(),T.destroy=p}f=f.next}while(f!==v)}}catch(j){Tt(c,c.return,j)}}function co(a,c,f){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,j=T.destroy;if(j!==void 0){T.destroy=void 0,v=c;var V=f,J=j;try{J()}catch(ie){Tt(v,V,ie)}}}p=p.next}while(p!==w)}}catch(ie){Tt(c,c.return,ie)}}function z1(a){var c=a.updateQueue;if(c!==null){var f=a.stateNode;try{AC(c,f)}catch(p){Tt(a,a.return,p)}}}function $1(a,c,f){f.props=Na(a.type,a.memoizedProps),f.state=a.memoizedState;try{f.componentWillUnmount()}catch(p){Tt(a,c,p)}}function _u(a,c){try{var f=a.ref;if(f!==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 f=="function"?a.refCleanup=f(p):f.current=p}}catch(v){Tt(a,c,v)}}function zs(a,c){var f=a.ref,p=a.refCleanup;if(f!==null)if(typeof p=="function")try{p()}catch(v){Tt(a,c,v)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(v){Tt(a,c,v)}else f.current=null}function B1(a){var c=a.type,f=a.memoizedProps,p=a.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":f.autoFocus&&p.focus();break e;case"img":f.src?p.src=f.src:f.srcSet&&(p.srcset=f.srcSet)}}catch(v){Tt(a,a.return,v)}}function Sb(a,c,f){try{var p=a.stateNode;kz(p,a.type,f,c),p[re]=c}catch(v){Tt(a,a.return,v)}}function V1(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&yo(a.type)||a.tag===4}function kb(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||V1(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&&yo(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,f){var p=a.tag;if(p===5||p===6)a=a.stateNode,c?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(a,c):(c=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,c.appendChild(a),f=f._reactRootContainer,f!=null||c.onclick!==null||(c.onclick=si));else if(p!==4&&(p===27&&yo(a.type)&&(f=a.stateNode,c=null),a=a.child,a!==null))for(Cb(a,c,f),a=a.sibling;a!==null;)Cb(a,c,f),a=a.sibling}function lh(a,c,f){var p=a.tag;if(p===5||p===6)a=a.stateNode,c?f.insertBefore(a,c):f.appendChild(a);else if(p!==4&&(p===27&&yo(a.type)&&(f=a.stateNode),a=a.child,a!==null))for(lh(a,c,f),a=a.sibling;a!==null;)lh(a,c,f),a=a.sibling}function H1(a){var c=a.stateNode,f=a.memoizedProps;try{for(var p=a.type,v=c.attributes;v.length;)c.removeAttributeNode(v[0]);zn(c,p,f),c[ee]=a,c[re]=f}catch(w){Tt(a,a.return,w)}}var pi=!1,mn=!1,Eb=!1,U1=typeof WeakSet=="function"?WeakSet:Set,En=null;function nz(a,c){if(a=a.containerInfo,Gb=Rh,a=tC(a),by(a)){if("selectionStart"in a)var f={start:a.selectionStart,end:a.selectionEnd};else e:{f=(f=a.ownerDocument)&&f.defaultView||window;var p=f.getSelection&&f.getSelection();if(p&&p.rangeCount!==0){f=p.anchorNode;var v=p.anchorOffset,w=p.focusNode;p=p.focusOffset;try{f.nodeType,w.nodeType}catch{f=null;break e}var T=0,j=-1,V=-1,J=0,ie=0,de=a,Q=null;t:for(;;){for(var ne;de!==f||v!==0&&de.nodeType!==3||(j=T+v),de!==w||p!==0&&de.nodeType!==3||(V=T+p),de.nodeType===3&&(T+=de.nodeValue.length),(ne=de.firstChild)!==null;)Q=de,de=ne;for(;;){if(de===a)break t;if(Q===f&&++J===v&&(j=T),Q===w&&++ie===p&&(V=T),(ne=de.nextSibling)!==null)break;de=Q,Q=de.parentNode}de=ne}f=j===-1||V===-1?null:{start:j,end:V}}else f=null}f=f||{start:0,end:0}}else f=null;for(Wb={focusedElem:a,selectionRange:f},Rh=!1,En=c;En!==null;)if(c=En,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,En=a;else for(;En!==null;){switch(c=En,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(f=0;f<a.length;f++)v=a[f],v.ref.impl=v.nextImpl;break;case 11:case 15:break;case 1:if((a&1024)!==0&&w!==null){a=void 0,f=c,v=w.memoizedProps,w=w.memoizedState,p=f.stateNode;try{var Oe=Na(f.type,v);a=p.getSnapshotBeforeUpdate(Oe,w),p.__reactInternalSnapshotBeforeUpdate=a}catch(Ge){Tt(f,f.return,Ge)}}break;case 3:if((a&1024)!==0){if(a=c.stateNode.containerInfo,f=a.nodeType,f===9)Yb(a);else if(f===1)switch(a.nodeName){case"HEAD":case"HTML":case"BODY":Yb(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,En=a;break}En=c.return}}function F1(a,c,f){var p=f.flags;switch(f.tag){case 0:case 11:case 15:gi(a,f),p&4&&Tu(5,f);break;case 1:if(gi(a,f),p&4)if(a=f.stateNode,c===null)try{a.componentDidMount()}catch(T){Tt(f,f.return,T)}else{var v=Na(f.type,c.memoizedProps);c=c.memoizedState;try{a.componentDidUpdate(v,c,a.__reactInternalSnapshotBeforeUpdate)}catch(T){Tt(f,f.return,T)}}p&64&&z1(f),p&512&&_u(f,f.return);break;case 3:if(gi(a,f),p&64&&(a=f.updateQueue,a!==null)){if(c=null,f.child!==null)switch(f.child.tag){case 27:case 5:c=f.child.stateNode;break;case 1:c=f.child.stateNode}try{AC(a,c)}catch(T){Tt(f,f.return,T)}}break;case 27:c===null&&p&4&&H1(f);case 26:case 5:gi(a,f),c===null&&p&4&&B1(f),p&512&&_u(f,f.return);break;case 12:gi(a,f);break;case 31:gi(a,f),p&4&&W1(a,f);break;case 13:gi(a,f),p&4&&K1(a,f),p&64&&(a=f.memoizedState,a!==null&&(a=a.dehydrated,a!==null&&(f=dz.bind(null,f),Mz(a,f))));break;case 22:if(p=f.memoizedState!==null||pi,!p){c=c!==null&&c.memoizedState!==null||mn,v=pi;var w=mn;pi=p,(mn=c)&&!w?yi(a,f,(f.subtreeFlags&8772)!==0):gi(a,f),pi=v,mn=w}break;case 30:break;default:gi(a,f)}}function q1(a){var c=a.alternate;c!==null&&(a.alternate=null,q1(c)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(c=a.stateNode,c!==null&&ma(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 Kt=null,yr=!1;function mi(a,c,f){for(f=f.child;f!==null;)G1(a,c,f),f=f.sibling}function G1(a,c,f){if(se&&typeof se.onCommitFiberUnmount=="function")try{se.onCommitFiberUnmount(U,f)}catch{}switch(f.tag){case 26:mn||zs(f,c),mi(a,c,f),f.memoizedState?f.memoizedState.count--:f.stateNode&&(f=f.stateNode,f.parentNode.removeChild(f));break;case 27:mn||zs(f,c);var p=Kt,v=yr;yo(f.type)&&(Kt=f.stateNode,yr=!1),mi(a,c,f),Lu(f.stateNode),Kt=p,yr=v;break;case 5:mn||zs(f,c);case 6:if(p=Kt,v=yr,Kt=null,mi(a,c,f),Kt=p,yr=v,Kt!==null)if(yr)try{(Kt.nodeType===9?Kt.body:Kt.nodeName==="HTML"?Kt.ownerDocument.body:Kt).removeChild(f.stateNode)}catch(w){Tt(f,c,w)}else try{Kt.removeChild(f.stateNode)}catch(w){Tt(f,c,w)}break;case 18:Kt!==null&&(yr?(a=Kt,zE(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,f.stateNode),tc(a)):zE(Kt,f.stateNode));break;case 4:p=Kt,v=yr,Kt=f.stateNode.containerInfo,yr=!0,mi(a,c,f),Kt=p,yr=v;break;case 0:case 11:case 14:case 15:co(2,f,c),mn||co(4,f,c),mi(a,c,f);break;case 1:mn||(zs(f,c),p=f.stateNode,typeof p.componentWillUnmount=="function"&&$1(f,c,p)),mi(a,c,f);break;case 21:mi(a,c,f);break;case 22:mn=(p=mn)||f.memoizedState!==null,mi(a,c,f),mn=p;break;default:mi(a,c,f)}}function W1(a,c){if(c.memoizedState===null&&(a=c.alternate,a!==null&&(a=a.memoizedState,a!==null))){a=a.dehydrated;try{tc(a)}catch(f){Tt(c,c.return,f)}}}function K1(a,c){if(c.memoizedState===null&&(a=c.alternate,a!==null&&(a=a.memoizedState,a!==null&&(a=a.dehydrated,a!==null))))try{tc(a)}catch(f){Tt(c,c.return,f)}}function rz(a){switch(a.tag){case 31:case 13:case 19:var c=a.stateNode;return c===null&&(c=a.stateNode=new U1),c;case 22:return a=a.stateNode,c=a._retryCache,c===null&&(c=a._retryCache=new U1),c;default:throw Error(r(435,a.tag))}}function ch(a,c){var f=rz(a);c.forEach(function(p){if(!f.has(p)){f.add(p);var v=fz.bind(null,a,p);p.then(v,v)}})}function br(a,c){var f=c.deletions;if(f!==null)for(var p=0;p<f.length;p++){var v=f[p],w=a,T=c,j=T;e:for(;j!==null;){switch(j.tag){case 27:if(yo(j.type)){Kt=j.stateNode,yr=!1;break e}break;case 5:Kt=j.stateNode,yr=!1;break e;case 3:case 4:Kt=j.stateNode.containerInfo,yr=!0;break e}j=j.return}if(Kt===null)throw Error(r(160));G1(w,T,v),Kt=null,yr=!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 ms=null;function Z1(a,c){var f=a.alternate,p=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:br(c,a),vr(a),p&4&&(co(3,a,a.return),Tu(3,a),co(5,a,a.return));break;case 1:br(c,a),vr(a),p&512&&(mn||f===null||zs(f,f.return)),p&64&&pi&&(a=a.updateQueue,a!==null&&(p=a.callbacks,p!==null&&(f=a.shared.hiddenCallbacks,a.shared.hiddenCallbacks=f===null?p:f.concat(p))));break;case 26:var v=ms;if(br(c,a),vr(a),p&512&&(mn||f===null||zs(f,f.return)),p&4){var w=f!==null?f.memoizedState:null;if(p=a.memoizedState,f===null)if(p===null)if(a.stateNode===null){e:{p=a.type,f=a.memoizedProps,v=v.ownerDocument||v;t:switch(p){case"title":w=v.getElementsByTagName("title")[0],(!w||w[sr]||w[ee]||w.namespaceURI==="http://www.w3.org/2000/svg"||w.hasAttribute("itemprop"))&&(w=v.createElement(p),v.head.insertBefore(w,v.querySelector("head > title"))),zn(w,p,f),w[ee]=a,Cn(w),p=w;break e;case"link":var T=ZE("link","href",v).get(p+(f.href||""));if(T){for(var j=0;j<T.length;j++)if(w=T[j],w.getAttribute("href")===(f.href==null||f.href===""?null:f.href)&&w.getAttribute("rel")===(f.rel==null?null:f.rel)&&w.getAttribute("title")===(f.title==null?null:f.title)&&w.getAttribute("crossorigin")===(f.crossOrigin==null?null:f.crossOrigin)){T.splice(j,1);break t}}w=v.createElement(p),zn(w,p,f),v.head.appendChild(w);break;case"meta":if(T=ZE("meta","content",v).get(p+(f.content||""))){for(j=0;j<T.length;j++)if(w=T[j],w.getAttribute("content")===(f.content==null?null:""+f.content)&&w.getAttribute("name")===(f.name==null?null:f.name)&&w.getAttribute("property")===(f.property==null?null:f.property)&&w.getAttribute("http-equiv")===(f.httpEquiv==null?null:f.httpEquiv)&&w.getAttribute("charset")===(f.charSet==null?null:f.charSet)){T.splice(j,1);break t}}w=v.createElement(p),zn(w,p,f),v.head.appendChild(w);break;default:throw Error(r(468,p))}w[ee]=a,Cn(w),p=w}a.stateNode=p}else YE(v,a.type,a.stateNode);else a.stateNode=KE(v,p,a.memoizedProps);else w!==p?(w===null?f.stateNode!==null&&(f=f.stateNode,f.parentNode.removeChild(f)):w.count--,p===null?YE(v,a.type,a.stateNode):KE(v,p,a.memoizedProps)):p===null&&a.stateNode!==null&&Sb(a,a.memoizedProps,f.memoizedProps)}break;case 27:br(c,a),vr(a),p&512&&(mn||f===null||zs(f,f.return)),f!==null&&p&4&&Sb(a,a.memoizedProps,f.memoizedProps);break;case 5:if(br(c,a),vr(a),p&512&&(mn||f===null||zs(f,f.return)),a.flags&32){v=a.stateNode;try{Cl(v,"")}catch(Oe){Tt(a,a.return,Oe)}}p&4&&a.stateNode!=null&&(v=a.memoizedProps,Sb(a,v,f!==null?f.memoizedProps:v)),p&1024&&(Eb=!0);break;case 6:if(br(c,a),vr(a),p&4){if(a.stateNode===null)throw Error(r(162));p=a.memoizedProps,f=a.stateNode;try{f.nodeValue=p}catch(Oe){Tt(a,a.return,Oe)}}break;case 3:if(Eh=null,v=ms,ms=kh(c.containerInfo),br(c,a),ms=v,vr(a),p&4&&f!==null&&f.memoizedState.isDehydrated)try{tc(c.containerInfo)}catch(Oe){Tt(a,a.return,Oe)}Eb&&(Eb=!1,Y1(a));break;case 4:p=ms,ms=kh(a.stateNode.containerInfo),br(c,a),vr(a),ms=p;break;case 12:br(c,a),vr(a);break;case 31:br(c,a),vr(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,ch(a,p)));break;case 13:br(c,a),vr(a),a.child.flags&8192&&a.memoizedState!==null!=(f!==null&&f.memoizedState!==null)&&(dh=Ht()),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,ch(a,p)));break;case 22:v=a.memoizedState!==null;var V=f!==null&&f.memoizedState!==null,J=pi,ie=mn;if(pi=J||v,mn=ie||V,br(c,a),mn=ie,pi=J,vr(a),p&8192)e:for(c=a.stateNode,c._visibility=v?c._visibility&-2:c._visibility|1,v&&(f===null||V||pi||mn||Ma(a)),f=null,c=a;;){if(c.tag===5||c.tag===26){if(f===null){V=f=c;try{if(w=V.stateNode,v)T=w.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none";else{j=V.stateNode;var de=V.memoizedProps.style,Q=de!=null&&de.hasOwnProperty("display")?de.display:null;j.style.display=Q==null||typeof Q=="boolean"?"":(""+Q).trim()}}catch(Oe){Tt(V,V.return,Oe)}}}else if(c.tag===6){if(f===null){V=c;try{V.stateNode.nodeValue=v?"":V.memoizedProps}catch(Oe){Tt(V,V.return,Oe)}}}else if(c.tag===18){if(f===null){V=c;try{var ne=V.stateNode;v?$E(ne,!0):$E(V.stateNode,!1)}catch(Oe){Tt(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;f===c&&(f=null),c=c.return}f===c&&(f=null),c.sibling.return=c.return,c=c.sibling}p&4&&(p=a.updateQueue,p!==null&&(f=p.retryQueue,f!==null&&(p.retryQueue=null,ch(a,f))));break;case 19:br(c,a),vr(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,ch(a,p)));break;case 30:break;case 21:break;default:br(c,a),vr(a)}}function vr(a){var c=a.flags;if(c&2){try{for(var f,p=a.return;p!==null;){if(V1(p)){f=p;break}p=p.return}if(f==null)throw Error(r(160));switch(f.tag){case 27:var v=f.stateNode,w=kb(a);lh(a,w,v);break;case 5:var T=f.stateNode;f.flags&32&&(Cl(T,""),f.flags&=-33);var j=kb(a);lh(a,j,T);break;case 3:case 4:var V=f.stateNode.containerInfo,J=kb(a);Cb(a,J,V);break;default:throw Error(r(161))}}catch(ie){Tt(a,a.return,ie)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function Y1(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var c=a;Y1(c),c.tag===5&&c.flags&1024&&c.stateNode.reset(),a=a.sibling}}function gi(a,c){if(c.subtreeFlags&8772)for(c=c.child;c!==null;)F1(a,c.alternate,c),c=c.sibling}function Ma(a){for(a=a.child;a!==null;){var c=a;switch(c.tag){case 0:case 11:case 14:case 15:co(4,c,c.return),Ma(c);break;case 1:zs(c,c.return);var f=c.stateNode;typeof f.componentWillUnmount=="function"&&$1(c,c.return,f),Ma(c);break;case 27:Lu(c.stateNode);case 26:case 5:zs(c,c.return),Ma(c);break;case 22:c.memoizedState===null&&Ma(c);break;case 30:Ma(c);break;default:Ma(c)}a=a.sibling}}function yi(a,c,f){for(f=f&&(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:yi(v,w,f),Tu(4,w);break;case 1:if(yi(v,w,f),p=w,v=p.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(J){Tt(p,p.return,J)}if(p=w,v=p.updateQueue,v!==null){var j=p.stateNode;try{var V=v.shared.hiddenCallbacks;if(V!==null)for(v.shared.hiddenCallbacks=null,v=0;v<V.length;v++)_C(V[v],j)}catch(J){Tt(p,p.return,J)}}f&&T&64&&z1(w),_u(w,w.return);break;case 27:H1(w);case 26:case 5:yi(v,w,f),f&&p===null&&T&4&&B1(w),_u(w,w.return);break;case 12:yi(v,w,f);break;case 31:yi(v,w,f),f&&T&4&&W1(v,w);break;case 13:yi(v,w,f),f&&T&4&&K1(v,w);break;case 22:w.memoizedState===null&&yi(v,w,f),_u(w,w.return);break;case 30:break;default:yi(v,w,f)}c=c.sibling}}function Tb(a,c){var f=null;a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(f=a.memoizedState.cachePool.pool),a=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(a=c.memoizedState.cachePool.pool),a!==f&&(a!=null&&a.refCount++,f!=null&&hu(f))}function _b(a,c){a=null,c.alternate!==null&&(a=c.alternate.memoizedState.cache),c=c.memoizedState.cache,c!==a&&(c.refCount++,a!=null&&hu(a))}function gs(a,c,f,p){if(c.subtreeFlags&10256)for(c=c.child;c!==null;)X1(a,c,f,p),c=c.sibling}function X1(a,c,f,p){var v=c.flags;switch(c.tag){case 0:case 11:case 15:gs(a,c,f,p),v&2048&&Tu(9,c);break;case 1:gs(a,c,f,p);break;case 3:gs(a,c,f,p),v&2048&&(a=null,c.alternate!==null&&(a=c.alternate.memoizedState.cache),c=c.memoizedState.cache,c!==a&&(c.refCount++,a!=null&&hu(a)));break;case 12:if(v&2048){gs(a,c,f,p),a=c.stateNode;try{var w=c.memoizedProps,T=w.id,j=w.onPostCommit;typeof j=="function"&&j(T,c.alternate===null?"mount":"update",a.passiveEffectDuration,-0)}catch(V){Tt(c,c.return,V)}}else gs(a,c,f,p);break;case 31:gs(a,c,f,p);break;case 13:gs(a,c,f,p);break;case 23:break;case 22:w=c.stateNode,T=c.alternate,c.memoizedState!==null?w._visibility&2?gs(a,c,f,p):Au(a,c):w._visibility&2?gs(a,c,f,p):(w._visibility|=2,Fl(a,c,f,p,(c.subtreeFlags&10256)!==0||!1)),v&2048&&Tb(T,c);break;case 24:gs(a,c,f,p),v&2048&&_b(c.alternate,c);break;default:gs(a,c,f,p)}}function Fl(a,c,f,p,v){for(v=v&&((c.subtreeFlags&10256)!==0||!1),c=c.child;c!==null;){var w=a,T=c,j=f,V=p,J=T.flags;switch(T.tag){case 0:case 11:case 15:Fl(w,T,j,V,v),Tu(8,T);break;case 23:break;case 22:var ie=T.stateNode;T.memoizedState!==null?ie._visibility&2?Fl(w,T,j,V,v):Au(w,T):(ie._visibility|=2,Fl(w,T,j,V,v)),v&&J&2048&&Tb(T.alternate,T);break;case 24:Fl(w,T,j,V,v),v&&J&2048&&_b(T.alternate,T);break;default:Fl(w,T,j,V,v)}c=c.sibling}}function Au(a,c){if(c.subtreeFlags&10256)for(c=c.child;c!==null;){var f=a,p=c,v=p.flags;switch(p.tag){case 22:Au(f,p),v&2048&&Tb(p.alternate,p);break;case 24:Au(f,p),v&2048&&_b(p.alternate,p);break;default:Au(f,p)}c=c.sibling}}var Ru=8192;function ql(a,c,f){if(a.subtreeFlags&Ru)for(a=a.child;a!==null;)J1(a,c,f),a=a.sibling}function J1(a,c,f){switch(a.tag){case 26:ql(a,c,f),a.flags&Ru&&a.memoizedState!==null&&Uz(f,ms,a.memoizedState,a.memoizedProps);break;case 5:ql(a,c,f);break;case 3:case 4:var p=ms;ms=kh(a.stateNode.containerInfo),ql(a,c,f),ms=p;break;case 22:a.memoizedState===null&&(p=a.alternate,p!==null&&p.memoizedState!==null?(p=Ru,Ru=16777216,ql(a,c,f),Ru=p):ql(a,c,f));break;default:ql(a,c,f)}}function Q1(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 Nu(a){var c=a.deletions;if((a.flags&16)!==0){if(c!==null)for(var f=0;f<c.length;f++){var p=c[f];En=p,tE(p,a)}Q1(a)}if(a.subtreeFlags&10256)for(a=a.child;a!==null;)eE(a),a=a.sibling}function eE(a){switch(a.tag){case 0:case 11:case 15:Nu(a),a.flags&2048&&co(9,a,a.return);break;case 3:Nu(a);break;case 12:Nu(a);break;case 22:var c=a.stateNode;a.memoizedState!==null&&c._visibility&2&&(a.return===null||a.return.tag!==13)?(c._visibility&=-3,uh(a)):Nu(a);break;default:Nu(a)}}function uh(a){var c=a.deletions;if((a.flags&16)!==0){if(c!==null)for(var f=0;f<c.length;f++){var p=c[f];En=p,tE(p,a)}Q1(a)}for(a=a.child;a!==null;){switch(c=a,c.tag){case 0:case 11:case 15:co(8,c,c.return),uh(c);break;case 22:f=c.stateNode,f._visibility&2&&(f._visibility&=-3,uh(c));break;default:uh(c)}a=a.sibling}}function tE(a,c){for(;En!==null;){var f=En;switch(f.tag){case 0:case 11:case 15:co(8,f,c);break;case 23:case 22:if(f.memoizedState!==null&&f.memoizedState.cachePool!==null){var p=f.memoizedState.cachePool.pool;p!=null&&p.refCount++}break;case 24:hu(f.memoizedState.cache)}if(p=f.child,p!==null)p.return=f,En=p;else e:for(f=a;En!==null;){p=En;var v=p.sibling,w=p.return;if(q1(p),p===f){En=null;break e}if(v!==null){v.return=w,En=v;break e}En=w}}}var sz={getCacheForType:function(a){var c=Ln(fn),f=c.data.get(a);return f===void 0&&(f=a(),c.data.set(a,f)),f},cacheSignal:function(){return Ln(fn).controller.signal}},iz=typeof WeakMap=="function"?WeakMap:Map,xt=0,It=null,at=null,ct=0,Et=0,Mr=null,uo=!1,Gl=!1,Ab=!1,bi=0,tn=0,fo=0,Oa=0,Rb=0,Or=0,Wl=0,Mu=null,xr=null,Nb=!1,dh=0,nE=0,fh=1/0,hh=null,ho=null,Sn=0,po=null,Kl=null,vi=0,Mb=0,Ob=null,rE=null,Ou=0,jb=null;function jr(){return(xt&2)!==0&&ct!==0?ct&-ct:z.T!==null?$b():ge()}function sE(){if(Or===0)if((ct&536870912)===0||dt){var a=kt;kt<<=1,(kt&3932160)===0&&(kt=262144),Or=a}else Or=536870912;return a=Rr.current,a!==null&&(a.flags|=32),Or}function wr(a,c,f){(a===It&&(Et===2||Et===9)||a.cancelPendingCommit!==null)&&(Zl(a,0),mo(a,ct,Or,!1)),hs(a,f),((xt&2)===0||a!==It)&&(a===It&&((xt&2)===0&&(Oa|=f),tn===4&&mo(a,ct,Or,!1)),$s(a))}function iE(a,c,f){if((xt&6)!==0)throw Error(r(327));var p=!f&&(c&127)===0&&(c&a.expiredLanes)===0||Ur(a,c),v=p?lz(a,c):Ib(a,c,!0),w=p;do{if(v===0){Gl&&!p&&mo(a,c,0,!1);break}else{if(f=a.current.alternate,w&&!oz(f)){v=Ib(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 j=a;v=Mu;var V=j.current.memoizedState.isDehydrated;if(V&&(Zl(j,T).flags|=256),T=Ib(j,T,!1),T!==2){if(Ab&&!V){j.errorRecoveryDisabledLanes|=w,Oa|=w,v=4;break e}w=xr,xr=v,w!==null&&(xr===null?xr=w:xr.push.apply(xr,w))}v=T}if(w=!1,v!==2)continue}}if(v===1){Zl(a,0),mo(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:mo(p,c,Or,!uo);break e;case 2:xr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((c&62914560)===c&&(v=dh+300-Ht(),10<v)){if(mo(p,c,Or,!uo),Wn(p,0,!0)!==0)break e;vi=c,p.timeoutHandle=LE(oE.bind(null,p,f,xr,hh,Nb,c,Or,Oa,Wl,uo,w,"Throttled",-0,0),v);break e}oE(p,f,xr,hh,Nb,c,Or,Oa,Wl,uo,w,null,-0,0)}}break}while(!0);$s(a)}function oE(a,c,f,p,v,w,T,j,V,J,ie,de,Q,ne){if(a.timeoutHandle=-1,de=c.subtreeFlags,de&8192||(de&16785408)===16785408){de={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:si},J1(c,w,de);var Oe=(w&62914560)===w?dh-Ht():(w&4194048)===w?nE-Ht():0;if(Oe=Fz(de,Oe),Oe!==null){vi=w,a.cancelPendingCommit=Oe(pE.bind(null,a,c,w,f,p,v,T,j,V,ie,de,null,Q,ne)),mo(a,w,T,!J);return}}pE(a,c,w,f,p,v,T,j,V)}function oz(a){for(var c=a;;){var f=c.tag;if((f===0||f===11||f===15)&&c.flags&16384&&(f=c.updateQueue,f!==null&&(f=f.stores,f!==null)))for(var p=0;p<f.length;p++){var v=f[p],w=v.getSnapshot;v=v.value;try{if(!_r(w(),v))return!1}catch{return!1}}if(f=c.child,c.subtreeFlags&16384&&f!==null)f.return=c,c=f;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 mo(a,c,f,p){c&=~Rb,c&=~Oa,a.suspendedLanes|=c,a.pingedLanes&=~c,p&&(a.warmLanes|=c),p=a.expirationTimes;for(var v=c;0<v;){var w=31-xe(v),T=1<<w;p[w]=-1,v&=~T}f!==0&&xl(a,f,c)}function ph(){return(xt&6)===0?(ju(0),!1):!0}function Db(){if(at!==null){if(Et===0)var a=at.return;else a=at,li=ka=null,Yy(a),$l=null,mu=0,a=at;for(;a!==null;)P1(a.alternate,a),a=a.return;at=null}}function Zl(a,c){var f=a.timeoutHandle;f!==-1&&(a.timeoutHandle=-1,Tz(f)),f=a.cancelPendingCommit,f!==null&&(a.cancelPendingCommit=null,f()),vi=0,Db(),It=a,at=f=oi(a.current,null),ct=c,Et=0,Mr=null,uo=!1,Gl=Ur(a,c),Ab=!1,Wl=Or=Rb=Oa=fo=tn=0,xr=Mu=null,Nb=!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-xe(p),w=1<<v;c|=a[v],p&=~w}return bi=c,If(),f}function aE(a,c){nt=null,z.H=ku,c===zl||c===Uf?(c=kC(),Et=3):c===zy?(c=kC(),Et=4):Et=c===fb?8:c!==null&&typeof c=="object"&&typeof c.then=="function"?6:1,Mr=c,at===null&&(tn=1,rh(a,Wr(c,a.current)))}function lE(){var a=Rr.current;return a===null?!0:(ct&4194048)===ct?Xr===null:(ct&62914560)===ct||(ct&536870912)!==0?a===Xr:!1}function cE(){var a=z.H;return z.H=ku,a===null?ku:a}function uE(){var a=z.A;return z.A=sz,a}function mh(){tn=4,uo||(ct&4194048)!==ct&&Rr.current!==null||(Gl=!0),(fo&134217727)===0&&(Oa&134217727)===0||It===null||mo(It,ct,Or,!1)}function Ib(a,c,f){var p=xt;xt|=2;var v=cE(),w=uE();(It!==a||ct!==c)&&(hh=null,Zl(a,c)),c=!1;var T=tn;e:do try{if(Et!==0&&at!==null){var j=at,V=Mr;switch(Et){case 8:Db(),T=6;break e;case 3:case 2:case 9:case 6:Rr.current===null&&(c=!0);var J=Et;if(Et=0,Mr=null,Yl(a,j,V,J),f&&Gl){T=0;break e}break;default:J=Et,Et=0,Mr=null,Yl(a,j,V,J)}}az(),T=tn;break}catch(ie){aE(a,ie)}while(!0);return c&&a.shellSuspendCounter++,li=ka=null,xt=p,z.H=v,z.A=w,at===null&&(It=null,ct=0,If()),T}function az(){for(;at!==null;)dE(at)}function lz(a,c){var f=xt;xt|=2;var p=cE(),v=uE();It!==a||ct!==c?(hh=null,fh=Ht()+500,Zl(a,c)):Gl=Ur(a,c);e:do try{if(Et!==0&&at!==null){c=at;var w=Mr;t:switch(Et){case 1:Et=0,Mr=null,Yl(a,c,w,1);break;case 2:case 9:if(wC(w)){Et=0,Mr=null,fE(c);break}c=function(){Et!==2&&Et!==9||It!==a||(Et=7),$s(a)},w.then(c,c);break e;case 3:Et=7;break e;case 4:Et=5;break e;case 7:wC(w)?(Et=0,Mr=null,fE(c)):(Et=0,Mr=null,Yl(a,c,w,7));break;case 5:var T=null;switch(at.tag){case 26:T=at.memoizedState;case 5:case 27:var j=at;if(T?XE(T):j.stateNode.complete){Et=0,Mr=null;var V=j.sibling;if(V!==null)at=V;else{var J=j.return;J!==null?(at=J,gh(J)):at=null}break t}}Et=0,Mr=null,Yl(a,c,w,5);break;case 6:Et=0,Mr=null,Yl(a,c,w,6);break;case 8:Db(),tn=6;break e;default:throw Error(r(462))}}cz();break}catch(ie){aE(a,ie)}while(!0);return li=ka=null,z.H=p,z.A=v,xt=f,at!==null?0:(It=null,ct=0,If(),tn)}function cz(){for(;at!==null&&!Tr();)dE(at)}function dE(a){var c=I1(a.alternate,a,bi);a.memoizedProps=a.pendingProps,c===null?gh(a):at=c}function fE(a){var c=a,f=c.alternate;switch(c.tag){case 15:case 0:c=R1(f,c,c.pendingProps,c.type,void 0,ct);break;case 11:c=R1(f,c,c.pendingProps,c.type.render,c.ref,ct);break;case 5:Yy(c);default:P1(f,c),c=at=uC(c,bi),c=I1(f,c,bi)}a.memoizedProps=a.pendingProps,c===null?gh(a):at=c}function Yl(a,c,f,p){li=ka=null,Yy(c),$l=null,mu=0;var v=c.return;try{if(XP(a,v,c,f,ct)){tn=1,rh(a,Wr(f,a.current)),at=null;return}}catch(w){if(v!==null)throw at=v,w;tn=1,rh(a,Wr(f,a.current)),at=null;return}c.flags&32768?(dt||p===1?a=!0:Gl||(ct&536870912)!==0?a=!1:(uo=a=!0,(p===2||p===9||p===3||p===6)&&(p=Rr.current,p!==null&&p.tag===13&&(p.flags|=16384))),hE(c,a)):gh(c)}function gh(a){var c=a;do{if((c.flags&32768)!==0){hE(c,uo);return}a=c.return;var f=ez(c.alternate,c,bi);if(f!==null){at=f;return}if(c=c.sibling,c!==null){at=c;return}at=c=a}while(c!==null);tn===0&&(tn=5)}function hE(a,c){do{var f=tz(a.alternate,a);if(f!==null){f.flags&=32767,at=f;return}if(f=a.return,f!==null&&(f.flags|=32768,f.subtreeFlags=0,f.deletions=null),!c&&(a=a.sibling,a!==null)){at=a;return}at=a=f}while(a!==null);tn=6,at=null}function pE(a,c,f,p,v,w,T,j,V){a.cancelPendingCommit=null;do yh();while(Sn!==0);if((xt&6)!==0)throw Error(r(327));if(c!==null){if(c===a.current)throw Error(r(177));if(w=c.lanes|c.childLanes,w|=ky,vl(a,f,w,T,j,V),a===It&&(at=It=null,ct=0),Kl=c,po=a,vi=f,Mb=w,Ob=v,rE=p,(c.subtreeFlags&10256)!==0||(c.flags&10256)!==0?(a.callbackNode=null,a.callbackPriority=0,hz(rr,function(){return vE(),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=xt,xt|=4;try{nz(a,c,f)}finally{xt=T,L.p=v,z.T=p}}Sn=1,mE(),gE(),yE()}}function mE(){if(Sn===1){Sn=0;var a=po,c=Kl,f=(c.flags&13878)!==0;if((c.subtreeFlags&13878)!==0||f){f=z.T,z.T=null;var p=L.p;L.p=2;var v=xt;xt|=4;try{Z1(c,a);var w=Wb,T=tC(a.containerInfo),j=w.focusedElem,V=w.selectionRange;if(T!==j&&j&&j.ownerDocument&&eC(j.ownerDocument.documentElement,j)){if(V!==null&&by(j)){var J=V.start,ie=V.end;if(ie===void 0&&(ie=J),"selectionStart"in j)j.selectionStart=J,j.selectionEnd=Math.min(ie,j.value.length);else{var de=j.ownerDocument||document,Q=de&&de.defaultView||window;if(Q.getSelection){var ne=Q.getSelection(),Oe=j.textContent.length,Ge=Math.min(V.start,Oe),Mt=V.end===void 0?Ge:Math.min(V.end,Oe);!ne.extend&&Ge>Mt&&(T=Mt,Mt=Ge,Ge=T);var K=Qk(j,Ge),q=Qk(j,Mt);if(K&&q&&(ne.rangeCount!==1||ne.anchorNode!==K.node||ne.anchorOffset!==K.offset||ne.focusNode!==q.node||ne.focusOffset!==q.offset)){var X=de.createRange();X.setStart(K.node,K.offset),ne.removeAllRanges(),Ge>Mt?(ne.addRange(X),ne.extend(q.node,q.offset)):(X.setEnd(q.node,q.offset),ne.addRange(X))}}}}for(de=[],ne=j;ne=ne.parentNode;)ne.nodeType===1&&de.push({element:ne,left:ne.scrollLeft,top:ne.scrollTop});for(typeof j.focus=="function"&&j.focus(),j=0;j<de.length;j++){var ue=de[j];ue.element.scrollLeft=ue.left,ue.element.scrollTop=ue.top}}Rh=!!Gb,Wb=Gb=null}finally{xt=v,L.p=p,z.T=f}}a.current=c,Sn=2}}function gE(){if(Sn===2){Sn=0;var a=po,c=Kl,f=(c.flags&8772)!==0;if((c.subtreeFlags&8772)!==0||f){f=z.T,z.T=null;var p=L.p;L.p=2;var v=xt;xt|=4;try{F1(a,c.alternate,c)}finally{xt=v,L.p=p,z.T=f}}Sn=3}}function yE(){if(Sn===4||Sn===3){Sn=0,js();var a=po,c=Kl,f=vi,p=rE;(c.subtreeFlags&10256)!==0||(c.flags&10256)!==0?Sn=5:(Sn=0,Kl=po=null,bE(a,a.pendingLanes));var v=a.pendingLanes;if(v===0&&(ho=null),Ji(f),c=c.stateNode,se&&typeof se.onCommitFiberRoot=="function")try{se.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 j=p[T];w(j.value,{componentStack:j.stack})}}finally{z.T=c,L.p=v}}(vi&3)!==0&&yh(),$s(a),v=a.pendingLanes,(f&261930)!==0&&(v&42)!==0?a===jb?Ou++:(Ou=0,jb=a):Ou=0,ju(0)}}function bE(a,c){(a.pooledCacheLanes&=c)===0&&(c=a.pooledCache,c!=null&&(a.pooledCache=null,hu(c)))}function yh(){return mE(),gE(),yE(),vE()}function vE(){if(Sn!==5)return!1;var a=po,c=Mb;Mb=0;var f=Ji(vi),p=z.T,v=L.p;try{L.p=32>f?32:f,z.T=null,f=Ob,Ob=null;var w=po,T=vi;if(Sn=0,Kl=po=null,vi=0,(xt&6)!==0)throw Error(r(331));var j=xt;if(xt|=4,eE(w.current),X1(w,w.current,T,f),xt=j,ju(0,!1),se&&typeof se.onPostCommitFiberRoot=="function")try{se.onPostCommitFiberRoot(U,w)}catch{}return!0}finally{L.p=v,z.T=p,bE(a,c)}}function xE(a,c,f){c=Wr(f,c),c=db(a.stateNode,c,2),a=oo(a,c,2),a!==null&&(hs(a,2),$s(a))}function Tt(a,c,f){if(a.tag===3)xE(a,a,f);else for(;c!==null;){if(c.tag===3){xE(c,a,f);break}else if(c.tag===1){var p=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(ho===null||!ho.has(p))){a=Wr(f,a),f=w1(2),p=oo(c,f,2),p!==null&&(S1(f,p,c,a),hs(p,2),$s(p));break}}c=c.return}}function Lb(a,c,f){var p=a.pingCache;if(p===null){p=a.pingCache=new iz;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(f)||(Ab=!0,v.add(f),a=uz.bind(null,a,c,f),c.then(a,a))}function uz(a,c,f){var p=a.pingCache;p!==null&&p.delete(c),a.pingedLanes|=a.suspendedLanes&f,a.warmLanes&=~f,It===a&&(ct&f)===f&&(tn===4||tn===3&&(ct&62914560)===ct&&300>Ht()-dh?(xt&2)===0&&Zl(a,0):Rb|=f,Wl===ct&&(Wl=0)),$s(a)}function wE(a,c){c===0&&(c=ti()),a=xa(a,c),a!==null&&(hs(a,c),$s(a))}function dz(a){var c=a.memoizedState,f=0;c!==null&&(f=c.retryLane),wE(a,f)}function fz(a,c){var f=0;switch(a.tag){case 31:case 13:var p=a.stateNode,v=a.memoizedState;v!==null&&(f=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),wE(a,f)}function hz(a,c){return jn(a,c)}var bh=null,Xl=null,Pb=!1,vh=!1,zb=!1,go=0;function $s(a){a!==Xl&&a.next===null&&(Xl===null?bh=Xl=a:Xl=Xl.next=a),vh=!0,Pb||(Pb=!0,mz())}function ju(a,c){if(!zb&&vh){zb=!0;do for(var f=!1,p=bh;p!==null;){if(a!==0){var v=p.pendingLanes;if(v===0)var w=0;else{var T=p.suspendedLanes,j=p.pingedLanes;w=(1<<31-xe(42|a)+1)-1,w&=v&~(T&~j),w=w&201326741?w&201326741|1:w?w|2:0}w!==0&&(f=!0,EE(p,w))}else w=ct,w=Wn(p,p===It?w:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(w&3)===0||Ur(p,w)||(f=!0,EE(p,w));p=p.next}while(f);zb=!1}}function pz(){SE()}function SE(){vh=Pb=!1;var a=0;go!==0&&Ez()&&(a=go);for(var c=Ht(),f=null,p=bh;p!==null;){var v=p.next,w=kE(p,c);w===0?(p.next=null,f===null?bh=v:f.next=v,v===null&&(Xl=f)):(f=p,(a!==0||(w&3)!==0)&&(vh=!0)),p=v}Sn!==0&&Sn!==5||ju(a),go!==0&&(go=0)}function kE(a,c){for(var f=a.suspendedLanes,p=a.pingedLanes,v=a.expirationTimes,w=a.pendingLanes&-62914561;0<w;){var T=31-xe(w),j=1<<T,V=v[T];V===-1?((j&f)===0||(j&p)!==0)&&(v[T]=mr(j,c)):V<=c&&(a.expiredLanes|=j),w&=~j}if(c=It,f=ct,f=Wn(a,a===c?f:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),p=a.callbackNode,f===0||a===c&&(Et===2||Et===9)||a.cancelPendingCommit!==null)return p!==null&&p!==null&&Dn(p),a.callbackNode=null,a.callbackPriority=0;if((f&3)===0||Ur(a,f)){if(c=f&-f,c===a.callbackPriority)return c;switch(p!==null&&Dn(p),Ji(f)){case 2:case 8:f=ds;break;case 32:f=rr;break;case 268435456:f=Ie;break;default:f=rr}return p=CE.bind(null,a),f=jn(f,p),a.callbackPriority=c,a.callbackNode=f,c}return p!==null&&p!==null&&Dn(p),a.callbackPriority=2,a.callbackNode=null,2}function CE(a,c){if(Sn!==0&&Sn!==5)return a.callbackNode=null,a.callbackPriority=0,null;var f=a.callbackNode;if(yh()&&a.callbackNode!==f)return null;var p=ct;return p=Wn(a,a===It?p:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),p===0?null:(iE(a,p,c),kE(a,Ht()),a.callbackNode!=null&&a.callbackNode===f?CE.bind(null,a):null)}function EE(a,c){if(yh())return null;iE(a,c,!0)}function mz(){_z(function(){(xt&6)!==0?jn(Gn,pz):SE()})}function $b(){if(go===0){var a=Ll;a===0&&(a=st,st<<=1,(st&261888)===0&&(st=256)),go=a}return go}function TE(a){return a==null||typeof a=="symbol"||typeof a=="boolean"?null:typeof a=="function"?a:_f(""+a)}function _E(a,c){var f=c.ownerDocument.createElement("input");return f.name=c.name,f.value=c.value,a.id&&f.setAttribute("form",a.id),c.parentNode.insertBefore(f,c),a=new FormData(a),f.parentNode.removeChild(f),a}function gz(a,c,f,p,v){if(c==="submit"&&f&&f.stateNode===v){var w=TE((v[re]||null).action),T=p.submitter;T&&(c=(c=T[re]||null)?TE(c.formAction):T.getAttribute("formAction"),c!==null&&(w=c,T=null));var j=new Mf("action","action",null,p,v);a.push({event:j,listeners:[{instance:null,listener:function(){if(p.defaultPrevented){if(go!==0){var V=T?_E(v,T):new FormData(v);ib(f,{pending:!0,data:V,method:v.method,action:w},null,V)}}else typeof w=="function"&&(j.preventDefault(),V=T?_E(v,T):new FormData(v),ib(f,{pending:!0,data:V,method:v.method,action:w},w,V))},currentTarget:v}]})}}for(var Bb=0;Bb<Sy.length;Bb++){var Vb=Sy[Bb],yz=Vb.toLowerCase(),bz=Vb[0].toUpperCase()+Vb.slice(1);ps(yz,"on"+bz)}ps(sC,"onAnimationEnd"),ps(iC,"onAnimationIteration"),ps(oC,"onAnimationStart"),ps("dblclick","onDoubleClick"),ps("focusin","onFocus"),ps("focusout","onBlur"),ps(DP,"onTransitionRun"),ps(IP,"onTransitionStart"),ps(LP,"onTransitionCancel"),ps(aC,"onTransitionEnd"),Sl("onMouseEnter",["mouseout","mouseover"]),Sl("onMouseLeave",["mouseout","mouseover"]),Sl("onPointerEnter",["pointerout","pointerover"]),Sl("onPointerLeave",["pointerout","pointerover"]),ga("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ga("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ga("onBeforeInput",["compositionend","keypress","textInput","paste"]),ga("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Du="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(" "),vz=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Du));function AE(a,c){c=(c&4)!==0;for(var f=0;f<a.length;f++){var p=a[f],v=p.event;p=p.listeners;e:{var w=void 0;if(c)for(var T=p.length-1;0<=T;T--){var j=p[T],V=j.instance,J=j.currentTarget;if(j=j.listener,V!==w&&v.isPropagationStopped())break e;w=j,v.currentTarget=J;try{w(v)}catch(ie){Df(ie)}v.currentTarget=null,w=V}else for(T=0;T<p.length;T++){if(j=p[T],V=j.instance,J=j.currentTarget,j=j.listener,V!==w&&v.isPropagationStopped())break e;w=j,v.currentTarget=J;try{w(v)}catch(ie){Df(ie)}v.currentTarget=null,w=V}}}}function lt(a,c){var f=c[qe];f===void 0&&(f=c[qe]=new Set);var p=a+"__bubble";f.has(p)||(RE(c,a,2,!1),f.add(p))}function Hb(a,c,f){var p=0;c&&(p|=4),RE(f,a,p,c)}var xh="_reactListening"+Math.random().toString(36).slice(2);function Ub(a){if(!a[xh]){a[xh]=!0,Sk.forEach(function(f){f!=="selectionchange"&&(vz.has(f)||Hb(f,!1,a),Hb(f,!0,a))});var c=a.nodeType===9?a:a.ownerDocument;c===null||c[xh]||(c[xh]=!0,Hb("selectionchange",!1,c))}}function RE(a,c,f,p){switch(sT(c)){case 2:var v=Wz;break;case 8:v=Kz;break;default:v=sv}f=v.bind(null,c,f,a),v=void 0,!cy||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(v=!0),p?v!==void 0?a.addEventListener(c,f,{capture:!0,passive:v}):a.addEventListener(c,f,!0):v!==void 0?a.addEventListener(c,f,{passive:v}):a.addEventListener(c,f,!1)}function Fb(a,c,f,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 j=p.stateNode.containerInfo;if(j===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(;j!==null;){if(T=ni(j),T===null)return;if(V=T.tag,V===5||V===6||V===26||V===27){p=w=T;continue e}j=j.parentNode}}p=p.return}Dk(function(){var J=w,ie=ay(f),de=[];e:{var Q=lC.get(a);if(Q!==void 0){var ne=Mf,Oe=a;switch(a){case"keypress":if(Rf(f)===0)break e;case"keydown":case"keyup":ne=fP;break;case"focusin":Oe="focus",ne=hy;break;case"focusout":Oe="blur",ne=hy;break;case"beforeblur":case"afterblur":ne=hy;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ne=Pk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ne=eP;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ne=mP;break;case sC:case iC:case oC:ne=rP;break;case aC:ne=yP;break;case"scroll":case"scrollend":ne=J2;break;case"wheel":ne=vP;break;case"copy":case"cut":case"paste":ne=iP;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ne=$k;break;case"toggle":case"beforetoggle":ne=wP}var Ge=(c&4)!==0,Mt=!Ge&&(a==="scroll"||a==="scrollend"),K=Ge?Q!==null?Q+"Capture":null:Q;Ge=[];for(var q=J,X;q!==null;){var ue=q;if(X=ue.stateNode,ue=ue.tag,ue!==5&&ue!==26&&ue!==27||X===null||K===null||(ue=nu(q,K),ue!=null&&Ge.push(Iu(q,ue,X))),Mt)break;q=q.return}0<Ge.length&&(Q=new ne(Q,Oe,null,f,ie),de.push({event:Q,listeners:Ge}))}}if((c&7)===0){e:{if(Q=a==="mouseover"||a==="pointerover",ne=a==="mouseout"||a==="pointerout",Q&&f!==oy&&(Oe=f.relatedTarget||f.fromElement)&&(ni(Oe)||Oe[Te]))break e;if((ne||Q)&&(Q=ie.window===ie?ie:(Q=ie.ownerDocument)?Q.defaultView||Q.parentWindow:window,ne?(Oe=f.relatedTarget||f.toElement,ne=J,Oe=Oe?ni(Oe):null,Oe!==null&&(Mt=i(Oe),Ge=Oe.tag,Oe!==Mt||Ge!==5&&Ge!==27&&Ge!==6)&&(Oe=null)):(ne=null,Oe=J),ne!==Oe)){if(Ge=Pk,ue="onMouseLeave",K="onMouseEnter",q="mouse",(a==="pointerout"||a==="pointerover")&&(Ge=$k,ue="onPointerLeave",K="onPointerEnter",q="pointer"),Mt=ne==null?Q:tu(ne),X=Oe==null?Q:tu(Oe),Q=new Ge(ue,q+"leave",ne,f,ie),Q.target=Mt,Q.relatedTarget=X,ue=null,ni(ie)===J&&(Ge=new Ge(K,q+"enter",Oe,f,ie),Ge.target=X,Ge.relatedTarget=Mt,ue=Ge),Mt=ue,ne&&Oe)t:{for(Ge=xz,K=ne,q=Oe,X=0,ue=K;ue;ue=Ge(ue))X++;ue=0;for(var Ue=q;Ue;Ue=Ge(Ue))ue++;for(;0<X-ue;)K=Ge(K),X--;for(;0<ue-X;)q=Ge(q),ue--;for(;X--;){if(K===q||q!==null&&K===q.alternate){Ge=K;break t}K=Ge(K),q=Ge(q)}Ge=null}else Ge=null;ne!==null&&NE(de,Q,ne,Ge,!1),Oe!==null&&Mt!==null&&NE(de,Mt,Oe,Ge,!0)}}e:{if(Q=J?tu(J):window,ne=Q.nodeName&&Q.nodeName.toLowerCase(),ne==="select"||ne==="input"&&Q.type==="file")var gt=Wk;else if(qk(Q))if(Kk)gt=MP;else{gt=RP;var Pe=AP}else ne=Q.nodeName,!ne||ne.toLowerCase()!=="input"||Q.type!=="checkbox"&&Q.type!=="radio"?J&&iy(J.elementType)&&(gt=Wk):gt=NP;if(gt&&(gt=gt(a,J))){Gk(de,gt,f,ie);break e}Pe&&Pe(a,Q,J),a==="focusout"&&J&&Q.type==="number"&&J.memoizedProps.value!=null&&sy(Q,"number",Q.value)}switch(Pe=J?tu(J):window,a){case"focusin":(qk(Pe)||Pe.contentEditable==="true")&&(Al=Pe,vy=J,uu=null);break;case"focusout":uu=vy=Al=null;break;case"mousedown":xy=!0;break;case"contextmenu":case"mouseup":case"dragend":xy=!1,nC(de,f,ie);break;case"selectionchange":if(jP)break;case"keydown":case"keyup":nC(de,f,ie)}var rt;if(my)e:{switch(a){case"compositionstart":var ut="onCompositionStart";break e;case"compositionend":ut="onCompositionEnd";break e;case"compositionupdate":ut="onCompositionUpdate";break e}ut=void 0}else _l?Uk(a,f)&&(ut="onCompositionEnd"):a==="keydown"&&f.keyCode===229&&(ut="onCompositionStart");ut&&(Bk&&f.locale!=="ko"&&(_l||ut!=="onCompositionStart"?ut==="onCompositionEnd"&&_l&&(rt=Ik()):(Qi=ie,uy="value"in Qi?Qi.value:Qi.textContent,_l=!0)),Pe=wh(J,ut),0<Pe.length&&(ut=new zk(ut,a,null,f,ie),de.push({event:ut,listeners:Pe}),rt?ut.data=rt:(rt=Fk(f),rt!==null&&(ut.data=rt)))),(rt=kP?CP(a,f):EP(a,f))&&(ut=wh(J,"onBeforeInput"),0<ut.length&&(Pe=new zk("onBeforeInput","beforeinput",null,f,ie),de.push({event:Pe,listeners:ut}),Pe.data=rt)),gz(de,a,J,f,ie)}AE(de,c)})}function Iu(a,c,f){return{instance:a,listener:c,currentTarget:f}}function wh(a,c){for(var f=c+"Capture",p=[];a!==null;){var v=a,w=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||w===null||(v=nu(a,f),v!=null&&p.unshift(Iu(a,v,w)),v=nu(a,c),v!=null&&p.push(Iu(a,v,w))),a.tag===3)return p;a=a.return}return[]}function xz(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5&&a.tag!==27);return a||null}function NE(a,c,f,p,v){for(var w=c._reactName,T=[];f!==null&&f!==p;){var j=f,V=j.alternate,J=j.stateNode;if(j=j.tag,V!==null&&V===p)break;j!==5&&j!==26&&j!==27||J===null||(V=J,v?(J=nu(f,w),J!=null&&T.unshift(Iu(f,J,V))):v||(J=nu(f,w),J!=null&&T.push(Iu(f,J,V)))),f=f.return}T.length!==0&&a.push({event:c,listeners:T})}var wz=/\r\n?/g,Sz=/\u0000|\uFFFD/g;function ME(a){return(typeof a=="string"?a:""+a).replace(wz,`
|
|
9
|
+
`).replace(Sz,"")}function OE(a,c){return c=ME(c),ME(a)===c}function Nt(a,c,f,p,v,w){switch(f){case"children":typeof p=="string"?c==="body"||c==="textarea"&&p===""||Cl(a,p):(typeof p=="number"||typeof p=="bigint")&&c!=="body"&&Cl(a,""+p);break;case"className":Ef(a,"class",p);break;case"tabIndex":Ef(a,"tabindex",p);break;case"dir":case"role":case"viewBox":case"width":case"height":Ef(a,f,p);break;case"style":Ok(a,p,w);break;case"data":if(c!=="object"){Ef(a,"data",p);break}case"src":case"href":if(p===""&&(c!=="a"||f!=="href")){a.removeAttribute(f);break}if(p==null||typeof p=="function"||typeof p=="symbol"||typeof p=="boolean"){a.removeAttribute(f);break}p=_f(""+p),a.setAttribute(f,p);break;case"action":case"formAction":if(typeof p=="function"){a.setAttribute(f,"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"&&(f==="formAction"?(c!=="input"&&Nt(a,c,"name",v.name,v,null),Nt(a,c,"formEncType",v.formEncType,v,null),Nt(a,c,"formMethod",v.formMethod,v,null),Nt(a,c,"formTarget",v.formTarget,v,null)):(Nt(a,c,"encType",v.encType,v,null),Nt(a,c,"method",v.method,v,null),Nt(a,c,"target",v.target,v,null)));if(p==null||typeof p=="symbol"||typeof p=="boolean"){a.removeAttribute(f);break}p=_f(""+p),a.setAttribute(f,p);break;case"onClick":p!=null&&(a.onclick=si);break;case"onScroll":p!=null&<("scroll",a);break;case"onScrollEnd":p!=null&<("scrollend",a);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(r(61));if(f=p.__html,f!=null){if(v.children!=null)throw Error(r(60));a.innerHTML=f}}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}f=_f(""+p),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);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(f,""+p):a.removeAttribute(f);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(f,""):a.removeAttribute(f);break;case"capture":case"download":p===!0?a.setAttribute(f,""):p!==!1&&p!=null&&typeof p!="function"&&typeof p!="symbol"?a.setAttribute(f,p):a.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":p!=null&&typeof p!="function"&&typeof p!="symbol"&&!isNaN(p)&&1<=p?a.setAttribute(f,p):a.removeAttribute(f);break;case"rowSpan":case"start":p==null||typeof p=="function"||typeof p=="symbol"||isNaN(p)?a.removeAttribute(f):a.setAttribute(f,p);break;case"popover":lt("beforetoggle",a),lt("toggle",a),Cf(a,"popover",p);break;case"xlinkActuate":ri(a,"http://www.w3.org/1999/xlink","xlink:actuate",p);break;case"xlinkArcrole":ri(a,"http://www.w3.org/1999/xlink","xlink:arcrole",p);break;case"xlinkRole":ri(a,"http://www.w3.org/1999/xlink","xlink:role",p);break;case"xlinkShow":ri(a,"http://www.w3.org/1999/xlink","xlink:show",p);break;case"xlinkTitle":ri(a,"http://www.w3.org/1999/xlink","xlink:title",p);break;case"xlinkType":ri(a,"http://www.w3.org/1999/xlink","xlink:type",p);break;case"xmlBase":ri(a,"http://www.w3.org/XML/1998/namespace","xml:base",p);break;case"xmlLang":ri(a,"http://www.w3.org/XML/1998/namespace","xml:lang",p);break;case"xmlSpace":ri(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<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=Y2.get(f)||f,Cf(a,f,p))}}function qb(a,c,f,p,v,w){switch(f){case"style":Ok(a,p,w);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(r(61));if(f=p.__html,f!=null){if(v.children!=null)throw Error(r(60));a.innerHTML=f}}break;case"children":typeof p=="string"?Cl(a,p):(typeof p=="number"||typeof p=="bigint")&&Cl(a,""+p);break;case"onScroll":p!=null&<("scroll",a);break;case"onScrollEnd":p!=null&<("scrollend",a);break;case"onClick":p!=null&&(a.onclick=si);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!kk.hasOwnProperty(f))e:{if(f[0]==="o"&&f[1]==="n"&&(v=f.endsWith("Capture"),c=f.slice(2,v?f.length-7:void 0),w=a[re]||null,w=w!=null?w[f]:null,typeof w=="function"&&a.removeEventListener(c,w,v),typeof p=="function")){typeof w!="function"&&w!==null&&(f in a?a[f]=null:a.hasAttribute(f)&&a.removeAttribute(f)),a.addEventListener(c,p,v);break e}f in a?a[f]=p:p===!0?a.setAttribute(f,""):Cf(a,f,p)}}}function zn(a,c,f){switch(c){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":lt("error",a),lt("load",a);var p=!1,v=!1,w;for(w in f)if(f.hasOwnProperty(w)){var T=f[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:Nt(a,c,w,T,f,null)}}v&&Nt(a,c,"srcSet",f.srcSet,f,null),p&&Nt(a,c,"src",f.src,f,null);return;case"input":lt("invalid",a);var j=w=T=v=null,V=null,J=null;for(p in f)if(f.hasOwnProperty(p)){var ie=f[p];if(ie!=null)switch(p){case"name":v=ie;break;case"type":T=ie;break;case"checked":V=ie;break;case"defaultChecked":J=ie;break;case"value":w=ie;break;case"defaultValue":j=ie;break;case"children":case"dangerouslySetInnerHTML":if(ie!=null)throw Error(r(137,c));break;default:Nt(a,c,p,ie,f,null)}}Ak(a,w,j,V,J,T,v,!1);return;case"select":lt("invalid",a),p=T=w=null;for(v in f)if(f.hasOwnProperty(v)&&(j=f[v],j!=null))switch(v){case"value":w=j;break;case"defaultValue":T=j;break;case"multiple":p=j;default:Nt(a,c,v,j,f,null)}c=w,f=T,a.multiple=!!p,c!=null?kl(a,!!p,c,!1):f!=null&&kl(a,!!p,f,!0);return;case"textarea":lt("invalid",a),w=v=p=null;for(T in f)if(f.hasOwnProperty(T)&&(j=f[T],j!=null))switch(T){case"value":p=j;break;case"defaultValue":v=j;break;case"children":w=j;break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:Nt(a,c,T,j,f,null)}Nk(a,p,v,w);return;case"option":for(V in f)f.hasOwnProperty(V)&&(p=f[V],p!=null)&&(V==="selected"?a.selected=p&&typeof p!="function"&&typeof p!="symbol":Nt(a,c,V,p,f,null));return;case"dialog":lt("beforetoggle",a),lt("toggle",a),lt("cancel",a),lt("close",a);break;case"iframe":case"object":lt("load",a);break;case"video":case"audio":for(p=0;p<Du.length;p++)lt(Du[p],a);break;case"image":lt("error",a),lt("load",a);break;case"details":lt("toggle",a);break;case"embed":case"source":case"link":lt("error",a),lt("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(J in f)if(f.hasOwnProperty(J)&&(p=f[J],p!=null))switch(J){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,c));default:Nt(a,c,J,p,f,null)}return;default:if(iy(c)){for(ie in f)f.hasOwnProperty(ie)&&(p=f[ie],p!==void 0&&qb(a,c,ie,p,f,void 0));return}}for(j in f)f.hasOwnProperty(j)&&(p=f[j],p!=null&&Nt(a,c,j,p,f,null))}function kz(a,c,f,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,j=null,V=null,J=null,ie=null;for(ne in f){var de=f[ne];if(f.hasOwnProperty(ne)&&de!=null)switch(ne){case"checked":break;case"value":break;case"defaultValue":V=de;default:p.hasOwnProperty(ne)||Nt(a,c,ne,null,p,de)}}for(var Q in p){var ne=p[Q];if(de=f[Q],p.hasOwnProperty(Q)&&(ne!=null||de!=null))switch(Q){case"type":w=ne;break;case"name":v=ne;break;case"checked":J=ne;break;case"defaultChecked":ie=ne;break;case"value":T=ne;break;case"defaultValue":j=ne;break;case"children":case"dangerouslySetInnerHTML":if(ne!=null)throw Error(r(137,c));break;default:ne!==de&&Nt(a,c,Q,ne,p,de)}}ry(a,T,j,V,J,ie,w,v);return;case"select":ne=T=j=Q=null;for(w in f)if(V=f[w],f.hasOwnProperty(w)&&V!=null)switch(w){case"value":break;case"multiple":ne=V;default:p.hasOwnProperty(w)||Nt(a,c,w,null,p,V)}for(v in p)if(w=p[v],V=f[v],p.hasOwnProperty(v)&&(w!=null||V!=null))switch(v){case"value":Q=w;break;case"defaultValue":j=w;break;case"multiple":T=w;default:w!==V&&Nt(a,c,v,w,p,V)}c=j,f=T,p=ne,Q!=null?kl(a,!!f,Q,!1):!!p!=!!f&&(c!=null?kl(a,!!f,c,!0):kl(a,!!f,f?[]:"",!1));return;case"textarea":ne=Q=null;for(j in f)if(v=f[j],f.hasOwnProperty(j)&&v!=null&&!p.hasOwnProperty(j))switch(j){case"value":break;case"children":break;default:Nt(a,c,j,null,p,v)}for(T in p)if(v=p[T],w=f[T],p.hasOwnProperty(T)&&(v!=null||w!=null))switch(T){case"value":Q=v;break;case"defaultValue":ne=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(r(91));break;default:v!==w&&Nt(a,c,T,v,p,w)}Rk(a,Q,ne);return;case"option":for(var Oe in f)Q=f[Oe],f.hasOwnProperty(Oe)&&Q!=null&&!p.hasOwnProperty(Oe)&&(Oe==="selected"?a.selected=!1:Nt(a,c,Oe,null,p,Q));for(V in p)Q=p[V],ne=f[V],p.hasOwnProperty(V)&&Q!==ne&&(Q!=null||ne!=null)&&(V==="selected"?a.selected=Q&&typeof Q!="function"&&typeof Q!="symbol":Nt(a,c,V,Q,p,ne));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 Ge in f)Q=f[Ge],f.hasOwnProperty(Ge)&&Q!=null&&!p.hasOwnProperty(Ge)&&Nt(a,c,Ge,null,p,Q);for(J in p)if(Q=p[J],ne=f[J],p.hasOwnProperty(J)&&Q!==ne&&(Q!=null||ne!=null))switch(J){case"children":case"dangerouslySetInnerHTML":if(Q!=null)throw Error(r(137,c));break;default:Nt(a,c,J,Q,p,ne)}return;default:if(iy(c)){for(var Mt in f)Q=f[Mt],f.hasOwnProperty(Mt)&&Q!==void 0&&!p.hasOwnProperty(Mt)&&qb(a,c,Mt,void 0,p,Q);for(ie in p)Q=p[ie],ne=f[ie],!p.hasOwnProperty(ie)||Q===ne||Q===void 0&&ne===void 0||qb(a,c,ie,Q,p,ne);return}}for(var K in f)Q=f[K],f.hasOwnProperty(K)&&Q!=null&&!p.hasOwnProperty(K)&&Nt(a,c,K,null,p,Q);for(de in p)Q=p[de],ne=f[de],!p.hasOwnProperty(de)||Q===ne||Q==null&&ne==null||Nt(a,c,de,Q,p,ne)}function jE(a){switch(a){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Cz(){if(typeof performance.getEntriesByType=="function"){for(var a=0,c=0,f=performance.getEntriesByType("resource"),p=0;p<f.length;p++){var v=f[p],w=v.transferSize,T=v.initiatorType,j=v.duration;if(w&&j&&jE(T)){for(T=0,j=v.responseEnd,p+=1;p<f.length;p++){var V=f[p],J=V.startTime;if(J>j)break;var ie=V.transferSize,de=V.initiatorType;ie&&jE(de)&&(V=V.responseEnd,T+=ie*(V<j?1:(j-J)/(V-J)))}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 Gb=null,Wb=null;function Sh(a){return a.nodeType===9?a:a.ownerDocument}function DE(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 IE(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 Kb(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 Zb=null;function Ez(){var a=window.event;return a&&a.type==="popstate"?a===Zb?!1:(Zb=a,!0):(Zb=null,!1)}var LE=typeof setTimeout=="function"?setTimeout:void 0,Tz=typeof clearTimeout=="function"?clearTimeout:void 0,PE=typeof Promise=="function"?Promise:void 0,_z=typeof queueMicrotask=="function"?queueMicrotask:typeof PE<"u"?function(a){return PE.resolve(null).then(a).catch(Az)}:LE;function Az(a){setTimeout(function(){throw a})}function yo(a){return a==="head"}function zE(a,c){var f=c,p=0;do{var v=f.nextSibling;if(a.removeChild(f),v&&v.nodeType===8)if(f=v.data,f==="/$"||f==="/&"){if(p===0){a.removeChild(v),tc(c);return}p--}else if(f==="$"||f==="$?"||f==="$~"||f==="$!"||f==="&")p++;else if(f==="html")Lu(a.ownerDocument.documentElement);else if(f==="head"){f=a.ownerDocument.head,Lu(f);for(var w=f.firstChild;w;){var T=w.nextSibling,j=w.nodeName;w[sr]||j==="SCRIPT"||j==="STYLE"||j==="LINK"&&w.rel.toLowerCase()==="stylesheet"||f.removeChild(w),w=T}}else f==="body"&&Lu(a.ownerDocument.body);f=v}while(f);tc(c)}function $E(a,c){var f=a;a=0;do{var p=f.nextSibling;if(f.nodeType===1?c?(f._stashedDisplay=f.style.display,f.style.display="none"):(f.style.display=f._stashedDisplay||"",f.getAttribute("style")===""&&f.removeAttribute("style")):f.nodeType===3&&(c?(f._stashedText=f.nodeValue,f.nodeValue=""):f.nodeValue=f._stashedText||""),p&&p.nodeType===8)if(f=p.data,f==="/$"){if(a===0)break;a--}else f!=="$"&&f!=="$?"&&f!=="$~"&&f!=="$!"||a++;f=p}while(f)}function Yb(a){var c=a.firstChild;for(c&&c.nodeType===10&&(c=c.nextSibling);c;){var f=c;switch(c=c.nextSibling,f.nodeName){case"HTML":case"HEAD":case"BODY":Yb(f),ma(f);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(f.rel.toLowerCase()==="stylesheet")continue}a.removeChild(f)}}function Rz(a,c,f,p){for(;a.nodeType===1;){var v=f;if(a.nodeName.toLowerCase()!==c.toLowerCase()){if(!p&&(a.nodeName!=="INPUT"||a.type!=="hidden"))break}else if(p){if(!a[sr])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=Jr(a.nextSibling),a===null)break}return null}function Nz(a,c,f){if(c==="")return null;for(;a.nodeType!==3;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!f||(a=Jr(a.nextSibling),a===null))return null;return a}function BE(a,c){for(;a.nodeType!==8;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!c||(a=Jr(a.nextSibling),a===null))return null;return a}function Xb(a){return a.data==="$?"||a.data==="$~"}function Jb(a){return a.data==="$!"||a.data==="$?"&&a.ownerDocument.readyState!=="loading"}function Mz(a,c){var f=a.ownerDocument;if(a.data==="$~")a._reactRetry=c;else if(a.data!=="$?"||f.readyState!=="loading")c();else{var p=function(){c(),f.removeEventListener("DOMContentLoaded",p)};f.addEventListener("DOMContentLoaded",p),a._reactRetry=p}}function Jr(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 Qb=null;function VE(a){a=a.nextSibling;for(var c=0;a;){if(a.nodeType===8){var f=a.data;if(f==="/$"||f==="/&"){if(c===0)return Jr(a.nextSibling);c--}else f!=="$"&&f!=="$!"&&f!=="$?"&&f!=="$~"&&f!=="&"||c++}a=a.nextSibling}return null}function HE(a){a=a.previousSibling;for(var c=0;a;){if(a.nodeType===8){var f=a.data;if(f==="$"||f==="$!"||f==="$?"||f==="$~"||f==="&"){if(c===0)return a;c--}else f!=="/$"&&f!=="/&"||c++}a=a.previousSibling}return null}function UE(a,c,f){switch(c=Sh(f),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 Lu(a){for(var c=a.attributes;c.length;)a.removeAttributeNode(c[0]);ma(a)}var Qr=new Map,FE=new Set;function kh(a){return typeof a.getRootNode=="function"?a.getRootNode():a.nodeType===9?a:a.ownerDocument}var xi=L.d;L.d={f:Oz,r:jz,D:Dz,C:Iz,L:Lz,m:Pz,X:$z,S:zz,M:Bz};function Oz(){var a=xi.f(),c=ph();return a||c}function jz(a){var c=Is(a);c!==null&&c.tag===5&&c.type==="form"?a1(c):xi.r(a)}var Jl=typeof document>"u"?null:document;function qE(a,c,f){var p=Jl;if(p&&typeof c=="string"&&c){var v=qr(c);v='link[rel="'+a+'"][href="'+v+'"]',typeof f=="string"&&(v+='[crossorigin="'+f+'"]'),FE.has(v)||(FE.add(v),a={rel:a,crossOrigin:f,href:c},p.querySelector(v)===null&&(c=p.createElement("link"),zn(c,"link",a),Cn(c),p.head.appendChild(c)))}}function Dz(a){xi.D(a),qE("dns-prefetch",a,null)}function Iz(a,c){xi.C(a,c),qE("preconnect",a,c)}function Lz(a,c,f){xi.L(a,c,f);var p=Jl;if(p&&a&&c){var v='link[rel="preload"][as="'+qr(c)+'"]';c==="image"&&f&&f.imageSrcSet?(v+='[imagesrcset="'+qr(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(v+='[imagesizes="'+qr(f.imageSizes)+'"]')):v+='[href="'+qr(a)+'"]';var w=v;switch(c){case"style":w=Ql(a);break;case"script":w=ec(a)}Qr.has(w)||(a=g({rel:"preload",href:c==="image"&&f&&f.imageSrcSet?void 0:a,as:c},f),Qr.set(w,a),p.querySelector(v)!==null||c==="style"&&p.querySelector(Pu(w))||c==="script"&&p.querySelector(zu(w))||(c=p.createElement("link"),zn(c,"link",a),Cn(c),p.head.appendChild(c)))}}function Pz(a,c){xi.m(a,c);var f=Jl;if(f&&a){var p=c&&typeof c.as=="string"?c.as:"script",v='link[rel="modulepreload"][as="'+qr(p)+'"][href="'+qr(a)+'"]',w=v;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":w=ec(a)}if(!Qr.has(w)&&(a=g({rel:"modulepreload",href:a},c),Qr.set(w,a),f.querySelector(v)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(zu(w)))return}p=f.createElement("link"),zn(p,"link",a),Cn(p),f.head.appendChild(p)}}}function zz(a,c,f){xi.S(a,c,f);var p=Jl;if(p&&a){var v=wl(p).hoistableStyles,w=Ql(a);c=c||"default";var T=v.get(w);if(!T){var j={loading:0,preload:null};if(T=p.querySelector(Pu(w)))j.loading=5;else{a=g({rel:"stylesheet",href:a,"data-precedence":c},f),(f=Qr.get(w))&&ev(a,f);var V=T=p.createElement("link");Cn(V),zn(V,"link",a),V._p=new Promise(function(J,ie){V.onload=J,V.onerror=ie}),V.addEventListener("load",function(){j.loading|=1}),V.addEventListener("error",function(){j.loading|=2}),j.loading|=4,Ch(T,c,p)}T={type:"stylesheet",instance:T,count:1,state:j},v.set(w,T)}}}function $z(a,c){xi.X(a,c);var f=Jl;if(f&&a){var p=wl(f).hoistableScripts,v=ec(a),w=p.get(v);w||(w=f.querySelector(zu(v)),w||(a=g({src:a,async:!0},c),(c=Qr.get(v))&&tv(a,c),w=f.createElement("script"),Cn(w),zn(w,"link",a),f.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},p.set(v,w))}}function Bz(a,c){xi.M(a,c);var f=Jl;if(f&&a){var p=wl(f).hoistableScripts,v=ec(a),w=p.get(v);w||(w=f.querySelector(zu(v)),w||(a=g({src:a,async:!0,type:"module"},c),(c=Qr.get(v))&&tv(a,c),w=f.createElement("script"),Cn(w),zn(w,"link",a),f.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},p.set(v,w))}}function GE(a,c,f,p){var v=(v=Ce.current)?kh(v):null;if(!v)throw Error(r(446));switch(a){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(c=Ql(f.href),f=wl(v).hoistableStyles,p=f.get(c),p||(p={type:"style",instance:null,count:0,state:null},f.set(c,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){a=Ql(f.href);var w=wl(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(Pu(a)))&&!w._p&&(T.instance=w,T.state.loading=5),Qr.has(a)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},Qr.set(a,f),w||Vz(v,a,f,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=f.async,f=f.src,typeof f=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=ec(f),f=wl(v).hoistableScripts,p=f.get(c),p||(p={type:"script",instance:null,count:0,state:null},f.set(c,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,a))}}function Ql(a){return'href="'+qr(a)+'"'}function Pu(a){return'link[rel="stylesheet"]['+a+"]"}function WE(a){return g({},a,{"data-precedence":a.precedence,precedence:null})}function Vz(a,c,f,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}),zn(c,"link",f),Cn(c),a.head.appendChild(c))}function ec(a){return'[src="'+qr(a)+'"]'}function zu(a){return"script[async]"+a}function KE(a,c,f){if(c.count++,c.instance===null)switch(c.type){case"style":var p=a.querySelector('style[data-href~="'+qr(f.href)+'"]');if(p)return c.instance=p,Cn(p),p;var v=g({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return p=(a.ownerDocument||a).createElement("style"),Cn(p),zn(p,"style",v),Ch(p,f.precedence,a),c.instance=p;case"stylesheet":v=Ql(f.href);var w=a.querySelector(Pu(v));if(w)return c.state.loading|=4,c.instance=w,Cn(w),w;p=WE(f),(v=Qr.get(v))&&ev(p,v),w=(a.ownerDocument||a).createElement("link"),Cn(w);var T=w;return T._p=new Promise(function(j,V){T.onload=j,T.onerror=V}),zn(w,"link",p),c.state.loading|=4,Ch(w,f.precedence,a),c.instance=w;case"script":return w=ec(f.src),(v=a.querySelector(zu(w)))?(c.instance=v,Cn(v),v):(p=f,(v=Qr.get(w))&&(p=g({},f),tv(p,v)),a=a.ownerDocument||a,v=a.createElement("script"),Cn(v),zn(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,f.precedence,a));return c.instance}function Ch(a,c,f){for(var p=f.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 j=p[T];if(j.dataset.precedence===c)w=j;else if(w!==v)break}w?w.parentNode.insertBefore(a,w.nextSibling):(c=f.nodeType===9?f.head:f,c.insertBefore(a,c.firstChild))}function ev(a,c){a.crossOrigin==null&&(a.crossOrigin=c.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=c.referrerPolicy),a.title==null&&(a.title=c.title)}function tv(a,c){a.crossOrigin==null&&(a.crossOrigin=c.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=c.referrerPolicy),a.integrity==null&&(a.integrity=c.integrity)}var Eh=null;function ZE(a,c,f){if(Eh===null){var p=new Map,v=Eh=new Map;v.set(f,p)}else v=Eh,p=v.get(f),p||(p=new Map,v.set(f,p));if(p.has(a))return p;for(p.set(a,null),f=f.getElementsByTagName(a),v=0;v<f.length;v++){var w=f[v];if(!(w[sr]||w[ee]||a==="link"&&w.getAttribute("rel")==="stylesheet")&&w.namespaceURI!=="http://www.w3.org/2000/svg"){var T=w.getAttribute(c)||"";T=a+T;var j=p.get(T);j?j.push(w):p.set(T,[w])}}return p}function YE(a,c,f){a=a.ownerDocument||a,a.head.insertBefore(f,c==="title"?a.querySelector("head > title"):null)}function Hz(a,c,f){if(f===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 XE(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function Uz(a,c,f,p){if(f.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var v=Ql(p.href),w=c.querySelector(Pu(v));if(w){c=w._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(a.count++,a=Th.bind(a),c.then(a,a)),f.state.loading|=4,f.instance=w,Cn(w);return}w=c.ownerDocument||c,p=WE(p),(v=Qr.get(v))&&ev(p,v),w=w.createElement("link"),Cn(w);var T=w;T._p=new Promise(function(j,V){T.onload=j,T.onerror=V}),zn(w,"link",p),f.instance=w}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(f,c),(c=f.state.preload)&&(f.state.loading&3)===0&&(a.count++,f=Th.bind(a),c.addEventListener("load",f),c.addEventListener("error",f))}}var nv=0;function Fz(a,c){return a.stylesheets&&a.count===0&&Ah(a,a.stylesheets),0<a.count||0<a.imgCount?function(f){var p=setTimeout(function(){if(a.stylesheets&&Ah(a,a.stylesheets),a.unsuspend){var w=a.unsuspend;a.unsuspend=null,w()}},6e4+c);0<a.imgBytes&&nv===0&&(nv=62500*Cz());var v=setTimeout(function(){if(a.waitingForImages=!1,a.count===0&&(a.stylesheets&&Ah(a,a.stylesheets),a.unsuspend)){var w=a.unsuspend;a.unsuspend=null,w()}},(a.imgBytes>nv?50:800)+c);return a.unsuspend=f,function(){a.unsuspend=null,clearTimeout(p),clearTimeout(v)}}:null}function Th(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ah(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var _h=null;function Ah(a,c){a.stylesheets=null,a.unsuspend!==null&&(a.count++,_h=new Map,c.forEach(qz,a),_h=null,Th.call(a))}function qz(a,c){if(!(c.state.loading&4)){var f=_h.get(a);if(f)var p=f.get(null);else{f=new Map,_h.set(a,f);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")&&(f.set(T.dataset.precedence,T),p=T)}p&&f.set(null,p)}v=c.instance,T=v.getAttribute("data-precedence"),w=f.get(T)||p,w===p&&f.set(null,v),f.set(T,v),this.count++,p=Th.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 $u={$$typeof:R,Provider:null,Consumer:null,_currentValue:W,_currentValue2:W,_threadCount:0};function Gz(a,c,f,p,v,w,T,j,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=fs(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fs(0),this.hiddenUpdates=fs(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 JE(a,c,f,p,v,w,T,j,V,J,ie,de){return a=new Gz(a,c,f,T,V,J,ie,de,j),c=1,w===!0&&(c|=24),w=Ar(3,null,null,c),a.current=w,w.stateNode=a,c=Iy(),c.refCount++,a.pooledCache=c,c.refCount++,w.memoizedState={element:p,isDehydrated:f,cache:c},$y(w),a}function QE(a){return a?(a=Ml,a):Ml}function eT(a,c,f,p,v,w){v=QE(v),p.context===null?p.context=v:p.pendingContext=v,p=io(c),p.payload={element:f},w=w===void 0?null:w,w!==null&&(p.callback=w),f=oo(a,p,c),f!==null&&(wr(f,a,c),yu(f,a,c))}function tT(a,c){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var f=a.retryLane;a.retryLane=f!==0&&f<c?f:c}}function rv(a,c){tT(a,c),(a=a.alternate)&&tT(a,c)}function nT(a){if(a.tag===13||a.tag===31){var c=xa(a,67108864);c!==null&&wr(c,a,67108864),rv(a,67108864)}}function rT(a){if(a.tag===13||a.tag===31){var c=jr();c=Xi(c);var f=xa(a,c);f!==null&&wr(f,a,c),rv(a,c)}}var Rh=!0;function Wz(a,c,f,p){var v=z.T;z.T=null;var w=L.p;try{L.p=2,sv(a,c,f,p)}finally{L.p=w,z.T=v}}function Kz(a,c,f,p){var v=z.T;z.T=null;var w=L.p;try{L.p=8,sv(a,c,f,p)}finally{L.p=w,z.T=v}}function sv(a,c,f,p){if(Rh){var v=iv(p);if(v===null)Fb(a,c,p,Nh,f),iT(a,p);else if(Yz(v,a,c,f,p))p.stopPropagation();else if(iT(a,p),c&4&&-1<Zz.indexOf(a)){for(;v!==null;){var w=Is(v);if(w!==null)switch(w.tag){case 3:if(w=w.stateNode,w.current.memoizedState.isDehydrated){var T=Xt(w.pendingLanes);if(T!==0){var j=w;for(j.pendingLanes|=2,j.entangledLanes|=2;T;){var V=1<<31-xe(T);j.entanglements[1]|=V,T&=~V}$s(w),(xt&6)===0&&(fh=Ht()+500,ju(0))}}break;case 31:case 13:j=xa(w,2),j!==null&&wr(j,w,2),ph(),rv(w,2)}if(w=iv(p),w===null&&Fb(a,c,p,Nh,f),w===v)break;v=w}v!==null&&p.stopPropagation()}else Fb(a,c,p,null,f)}}function iv(a){return a=ay(a),ov(a)}var Nh=null;function ov(a){if(Nh=null,a=ni(a),a!==null){var c=i(a);if(c===null)a=null;else{var f=c.tag;if(f===13){if(a=o(c),a!==null)return a;a=null}else if(f===31){if(a=l(c),a!==null)return a;a=null}else if(f===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;a=null}else c!==a&&(a=null)}}return Nh=a,null}function sT(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(pr()){case Gn:return 2;case ds:return 8;case rr:case ye:return 32;case Ie:return 268435456;default:return 32}default:return 32}}var av=!1,bo=null,vo=null,xo=null,Bu=new Map,Vu=new Map,wo=[],Zz="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 iT(a,c){switch(a){case"focusin":case"focusout":bo=null;break;case"dragenter":case"dragleave":vo=null;break;case"mouseover":case"mouseout":xo=null;break;case"pointerover":case"pointerout":Bu.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vu.delete(c.pointerId)}}function Hu(a,c,f,p,v,w){return a===null||a.nativeEvent!==w?(a={blockedOn:c,domEventName:f,eventSystemFlags:p,nativeEvent:w,targetContainers:[v]},c!==null&&(c=Is(c),c!==null&&nT(c)),a):(a.eventSystemFlags|=p,c=a.targetContainers,v!==null&&c.indexOf(v)===-1&&c.push(v),a)}function Yz(a,c,f,p,v){switch(c){case"focusin":return bo=Hu(bo,a,c,f,p,v),!0;case"dragenter":return vo=Hu(vo,a,c,f,p,v),!0;case"mouseover":return xo=Hu(xo,a,c,f,p,v),!0;case"pointerover":var w=v.pointerId;return Bu.set(w,Hu(Bu.get(w)||null,a,c,f,p,v)),!0;case"gotpointercapture":return w=v.pointerId,Vu.set(w,Hu(Vu.get(w)||null,a,c,f,p,v)),!0}return!1}function oT(a){var c=ni(a.target);if(c!==null){var f=i(c);if(f!==null){if(c=f.tag,c===13){if(c=o(f),c!==null){a.blockedOn=c,Ae(a.priority,function(){rT(f)});return}}else if(c===31){if(c=l(f),c!==null){a.blockedOn=c,Ae(a.priority,function(){rT(f)});return}}else if(c===3&&f.stateNode.current.memoizedState.isDehydrated){a.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Mh(a){if(a.blockedOn!==null)return!1;for(var c=a.targetContainers;0<c.length;){var f=iv(a.nativeEvent);if(f===null){f=a.nativeEvent;var p=new f.constructor(f.type,f);oy=p,f.target.dispatchEvent(p),oy=null}else return c=Is(f),c!==null&&nT(c),a.blockedOn=f,!1;c.shift()}return!0}function aT(a,c,f){Mh(a)&&f.delete(c)}function Xz(){av=!1,bo!==null&&Mh(bo)&&(bo=null),vo!==null&&Mh(vo)&&(vo=null),xo!==null&&Mh(xo)&&(xo=null),Bu.forEach(aT),Vu.forEach(aT)}function Oh(a,c){a.blockedOn===c&&(a.blockedOn=null,av||(av=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Xz)))}var jh=null;function lT(a){jh!==a&&(jh=a,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jh===a&&(jh=null);for(var c=0;c<a.length;c+=3){var f=a[c],p=a[c+1],v=a[c+2];if(typeof p!="function"){if(ov(p||f)===null)continue;break}var w=Is(f);w!==null&&(a.splice(c,3),c-=3,ib(w,{pending:!0,data:v,method:f.method,action:p},p,v))}}))}function tc(a){function c(V){return Oh(V,a)}bo!==null&&Oh(bo,a),vo!==null&&Oh(vo,a),xo!==null&&Oh(xo,a),Bu.forEach(c),Vu.forEach(c);for(var f=0;f<wo.length;f++){var p=wo[f];p.blockedOn===a&&(p.blockedOn=null)}for(;0<wo.length&&(f=wo[0],f.blockedOn===null);)oT(f),f.blockedOn===null&&wo.shift();if(f=(a.ownerDocument||a).$$reactFormReplay,f!=null)for(p=0;p<f.length;p+=3){var v=f[p],w=f[p+1],T=v[re]||null;if(typeof w=="function")T||lT(f);else if(T){var j=null;if(w&&w.hasAttribute("formAction")){if(v=w,T=w[re]||null)j=T.formAction;else if(ov(v)!==null)continue}else j=T.action;typeof j=="function"?f[p+1]=j:(f.splice(p,3),p-=3),lT(f)}}}function cT(){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(f,20)}function f(){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(f,100),function(){p=!0,navigation.removeEventListener("navigate",a),navigation.removeEventListener("navigatesuccess",c),navigation.removeEventListener("navigateerror",c),v!==null&&(v(),v=null)}}}function lv(a){this._internalRoot=a}Dh.prototype.render=lv.prototype.render=function(a){var c=this._internalRoot;if(c===null)throw Error(r(409));var f=c.current,p=jr();eT(f,p,a,c,null,null)},Dh.prototype.unmount=lv.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var c=a.containerInfo;eT(a.current,2,null,a,null,null),ph(),c[Te]=null}};function Dh(a){this._internalRoot=a}Dh.prototype.unstable_scheduleHydration=function(a){if(a){var c=ge();a={blockedOn:null,target:a,priority:c};for(var f=0;f<wo.length&&c!==0&&c<wo[f].priority;f++);wo.splice(f,0,a),f===0&&oT(a)}};var uT=e.version;if(uT!=="19.2.8")throw Error(r(527,uT,"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=d(c),a=a!==null?h(a):null,a=a===null?null:a.stateNode,a};var Jz={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Ih=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ih.isDisabled&&Ih.supportsFiber)try{U=Ih.inject(Jz),se=Ih}catch{}}return Fu.createRoot=function(a,c){if(!s(a))throw Error(r(299));var f=!1,p="",v=y1,w=b1,T=v1;return c!=null&&(c.unstable_strictMode===!0&&(f=!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=JE(a,1,!1,null,null,f,p,null,v,w,T,cT),a[Te]=c.current,Ub(a),new lv(c)},Fu.hydrateRoot=function(a,c,f){if(!s(a))throw Error(r(299));var p=!1,v="",w=y1,T=b1,j=v1,V=null;return f!=null&&(f.unstable_strictMode===!0&&(p=!0),f.identifierPrefix!==void 0&&(v=f.identifierPrefix),f.onUncaughtError!==void 0&&(w=f.onUncaughtError),f.onCaughtError!==void 0&&(T=f.onCaughtError),f.onRecoverableError!==void 0&&(j=f.onRecoverableError),f.formState!==void 0&&(V=f.formState)),c=JE(a,1,!0,c,f??null,p,v,V,w,T,j,cT),c.context=QE(null),f=c.current,p=jr(),p=Xi(p),v=io(p),v.callback=null,oo(f,v,p),f=p,c.current.lanes=f,hs(c,f),$s(c),a[Te]=c.current,Ub(a),new Dh(c)},Fu.version="19.2.8",Fu}var kT;function l$(){if(kT)return fv.exports;kT=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(),fv.exports=a$(),fv.exports}var c$=l$();const u$=()=>{};var CT={};const UN=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=s&63|128):(s&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(t.charCodeAt(++r)&1023),e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=s&63|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=s&63|128)}return e},d$=function(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=t[n++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=t[n++],o=t[n++],l=t[n++],u=((s&7)<<18|(i&63)<<12|(o&63)<<6|l&63)-65536;e[r++]=String.fromCharCode(55296+(u>>10)),e[r++]=String.fromCharCode(56320+(u&1023))}else{const i=t[n++],o=t[n++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|o&63)}}return e.join("")},FN={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 s=0;s<t.length;s+=3){const i=t[s],o=s+1<t.length,l=o?t[s+1]:0,u=s+2<t.length,d=u?t[s+2]:0,h=i>>2,g=(i&3)<<4|l>>4;let y=(l&15)<<2|d>>6,b=d&63;u||(b=64,o||(y=64)),r.push(n[h],n[g],n[y],n[b])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(UN(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):d$(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<t.length;){const i=n[t.charAt(s++)],l=s<t.length?n[t.charAt(s)]:0;++s;const d=s<t.length?n[t.charAt(s)]:64;++s;const g=s<t.length?n[t.charAt(s)]:64;if(++s,i==null||l==null||d==null||g==null)throw new f$;const y=i<<2|l>>4;if(r.push(y),d!==64){const b=l<<4&240|d>>2;if(r.push(b),g!==64){const x=d<<6&192|g;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 f$ extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const h$=function(t){const e=UN(t);return FN.encodeByteArray(e,!0)},qN=function(t){return h$(t).replace(/\./g,"")},GN=function(t){try{return FN.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function p$(){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 m$=()=>p$().__FIREBASE_DEFAULTS__,g$=()=>{if(typeof process>"u"||typeof CT>"u")return;const t=CT.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},y$=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=t&&GN(t[1]);return e&&JSON.parse(e)},mw=()=>{try{return u$()||m$()||g$()||y$()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},b$=t=>mw()?.emulatorHosts?.[t],WN=()=>mw()?.config,KN=t=>mw()?.[`_${t}`];class ZN{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 dr(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function v$(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(dr())}function x$(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function w$(){const t=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof t=="object"&&t.id!==void 0}function S$(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function k$(){const t=dr();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function C$(){try{return typeof indexedDB=="object"}catch{return!1}}function E$(){return new Promise((t,e)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0)},s.onupgradeneeded=()=>{n=!1},s.onerror=()=>{e(s.error?.message||"")}}catch(n){e(n)}})}const T$="FirebaseError";class oa extends Error{constructor(e,n,r){super(n),this.code=e,this.customData=r,this.name=T$,Object.setPrototypeOf(this,oa.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,rf.prototype.create)}}class rf{constructor(e,n,r){this.service=e,this.serviceName=n,this.errors=r}create(e,...n){const r=n[0]||{},s=`${this.service}/${e}`,i=this.errors[e],o=i?_$(i,r):"Error",l=`${this.serviceName}: ${o} (${s}).`;return new oa(s,l,r)}}function _$(t,e){try{let n=0,r="";for(;n<t.length;){const s=t.indexOf("{$",n);if(s===-1){r+=t.substring(n);break}const i=t.indexOf("}",s+2);if(i===-1){r+=t.substring(n);break}const o=t.substring(s+2,i),l=e[o];r+=t.substring(n,s)+(l!=null?String(l):`<${o}?>`),n=i+1}return r}catch{return t}}function A$(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Tc(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const s of n){if(!r.includes(s))return!1;const i=t[s],o=e[s];if(ET(i)&&ET(o)){if(!Tc(i,o))return!1}else if(i!==o)return!1}for(const s of r)if(!n.includes(s))return!1;return!0}function ET(t){return t!==null&&typeof t=="object"}function sf(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function sd(t){const e={};return t.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,i]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(i)}}),e}function id(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function R$(t,e){const n=new N$(t,e);return n.subscribe.bind(n)}class N${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 s;if(e===void 0&&n===void 0&&r===void 0)throw new Error("Missing Observer.");M$(e,["next","error","complete"])?s=e:s={next:e,error:n,complete:r},s.next===void 0&&(s.next=gv),s.error===void 0&&(s.error=gv),s.complete===void 0&&(s.complete=gv);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),i}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 M$(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 gv(){}function Ki(t){return t&&t._delegate?t._delegate:t}function gw(t){try{return(t.startsWith("http://")||t.startsWith("https://")?new URL(t).hostname:t).endsWith(".cloudworkstations.dev")}catch{return!1}}async function O$(t){return(await fetch(t,{credentials:"include"})).ok}class _c{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 Da="[DEFAULT]";class j${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 ZN;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:n});s&&r.resolve(s)}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(s){if(r)return null;throw s}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(I$(e))try{this.getOrInitializeService({instanceIdentifier:Da})}catch{}for(const[n,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(n);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=Da){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=Da){return this.instances.has(e)}getOptions(e=Da){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 s=this.getOrInitializeService({instanceIdentifier:r,options:n});for(const[i,o]of this.instancesDeferred.entries()){const l=this.normalizeInstanceIdentifier(i);r===l&&o.resolve(s)}return s}onInit(e,n){const r=this.normalizeInstanceIdentifier(n),s=this.onInitCallbacks.get(r)??new Set;s.add(e),this.onInitCallbacks.set(r,s);const i=this.instances.get(r);return i&&e(i,r),()=>{s.delete(e)}}invokeOnInitCallbacks(e,n){const r=this.onInitCallbacks.get(n);if(r)for(const s of r)try{s(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:D$(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=Da){return this.component?this.component.multipleInstances?e:Da:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function D$(t){return t===Da?void 0:t}function I$(t){return t.instantiationMode==="EAGER"}class L${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 j$(e,this);return this.providers.set(e,n),n}getProviders(){return Array.from(this.providers.values())}}var Lt;(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"})(Lt||(Lt={}));const P$={debug:Lt.DEBUG,verbose:Lt.VERBOSE,info:Lt.INFO,warn:Lt.WARN,error:Lt.ERROR,silent:Lt.SILENT},z$=Lt.INFO,$$={[Lt.DEBUG]:"log",[Lt.VERBOSE]:"log",[Lt.INFO]:"info",[Lt.WARN]:"warn",[Lt.ERROR]:"error"},B$=(t,e,...n)=>{if(e<t.logLevel)return;const r=new Date().toISOString(),s=$$[e];if(s)console[s](`[${r}] ${t.name}:`,...n);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class YN{constructor(e){this.name=e,this._logLevel=z$,this._logHandler=B$,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Lt))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?P$[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,Lt.DEBUG,...e),this._logHandler(this,Lt.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Lt.VERBOSE,...e),this._logHandler(this,Lt.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Lt.INFO,...e),this._logHandler(this,Lt.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Lt.WARN,...e),this._logHandler(this,Lt.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Lt.ERROR,...e),this._logHandler(this,Lt.ERROR,...e)}}const V$=(t,e)=>e.some(n=>t instanceof n);let TT,_T;function H$(){return TT||(TT=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function U$(){return _T||(_T=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const XN=new WeakMap,j0=new WeakMap,JN=new WeakMap,yv=new WeakMap,yw=new WeakMap;function F$(t){const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("success",i),t.removeEventListener("error",o)},i=()=>{n(Ho(t.result)),s()},o=()=>{r(t.error),s()};t.addEventListener("success",i),t.addEventListener("error",o)});return e.then(n=>{n instanceof IDBCursor&&XN.set(n,t)}).catch(()=>{}),yw.set(e,t),e}function q$(t){if(j0.has(t))return;const e=new Promise((n,r)=>{const s=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",o),t.removeEventListener("abort",o)},i=()=>{n(),s()},o=()=>{r(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",i),t.addEventListener("error",o),t.addEventListener("abort",o)});j0.set(t,e)}let D0={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return j0.get(t);if(e==="objectStoreNames")return t.objectStoreNames||JN.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Ho(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 G$(t){D0=t(D0)}function W$(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){const r=t.call(bv(this),e,...n);return JN.set(r,e.sort?e.sort():[e]),Ho(r)}:U$().includes(t)?function(...e){return t.apply(bv(this),e),Ho(XN.get(this))}:function(...e){return Ho(t.apply(bv(this),e))}}function K$(t){return typeof t=="function"?W$(t):(t instanceof IDBTransaction&&q$(t),V$(t,H$())?new Proxy(t,D0):t)}function Ho(t){if(t instanceof IDBRequest)return F$(t);if(yv.has(t))return yv.get(t);const e=K$(t);return e!==t&&(yv.set(t,e),yw.set(e,t)),e}const bv=t=>yw.get(t);function Z$(t,e,{blocked:n,upgrade:r,blocking:s,terminated:i}={}){const o=indexedDB.open(t,e),l=Ho(o);return r&&o.addEventListener("upgradeneeded",u=>{r(Ho(o.result),u.oldVersion,u.newVersion,Ho(o.transaction),u)}),n&&o.addEventListener("blocked",u=>n(u.oldVersion,u.newVersion,u)),l.then(u=>{i&&u.addEventListener("close",()=>i()),s&&u.addEventListener("versionchange",d=>s(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}const Y$=["get","getKey","getAll","getAllKeys","count"],X$=["put","add","delete","clear"],vv=new Map;function AT(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(vv.get(e))return vv.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,s=X$.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(s||Y$.includes(n)))return;const i=async function(o,...l){const u=this.transaction(o,s?"readwrite":"readonly");let d=u.store;return r&&(d=d.index(l.shift())),(await Promise.all([d[n](...l),s&&u.done]))[0]};return vv.set(e,i),i}G$(t=>({...t,get:(e,n,r)=>AT(e,n)||t.get(e,n,r),has:(e,n)=>!!AT(e,n)||t.has(e,n)}));class J${constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(Q$(n)){const r=n.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}}function Q$(t){return t.getComponent()?.type==="VERSION"}const I0="@firebase/app",RT="0.16.0";const Ui=new YN("@firebase/app"),eB="@firebase/app-compat",tB="@firebase/analytics-compat",nB="@firebase/analytics",rB="@firebase/app-check-compat",sB="@firebase/app-check",iB="@firebase/auth",oB="@firebase/auth-compat",aB="@firebase/database",lB="@firebase/data-connect",cB="@firebase/database-compat",uB="@firebase/functions",dB="@firebase/functions-compat",fB="@firebase/installations",hB="@firebase/installations-compat",pB="@firebase/messaging",mB="@firebase/messaging-compat",gB="@firebase/performance",yB="@firebase/performance-compat",bB="@firebase/remote-config",vB="@firebase/remote-config-compat",xB="@firebase/storage",wB="@firebase/storage-compat",SB="@firebase/firestore",kB="@firebase/ai",CB="@firebase/firestore-compat",EB="firebase",TB="12.17.0";const L0="[DEFAULT]",_B={[I0]:"fire-core",[eB]:"fire-core-compat",[nB]:"fire-analytics",[tB]:"fire-analytics-compat",[sB]:"fire-app-check",[rB]:"fire-app-check-compat",[iB]:"fire-auth",[oB]:"fire-auth-compat",[aB]:"fire-rtdb",[lB]:"fire-data-connect",[cB]:"fire-rtdb-compat",[uB]:"fire-fn",[dB]:"fire-fn-compat",[fB]:"fire-iid",[hB]:"fire-iid-compat",[pB]:"fire-fcm",[mB]:"fire-fcm-compat",[gB]:"fire-perf",[yB]:"fire-perf-compat",[bB]:"fire-rc",[vB]:"fire-rc-compat",[xB]:"fire-gcs",[wB]:"fire-gcs-compat",[SB]:"fire-fst",[CB]:"fire-fst-compat",[kB]:"fire-vertex","fire-js":"fire-js",[EB]:"fire-js-all"};const jd=new Map,AB=new Map,P0=new Map;function NT(t,e){try{t.container.addComponent(e)}catch(n){Ui.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function Dd(t){const e=t.name;if(P0.has(e))return Ui.debug(`There were multiple attempts to register component ${e}.`),!1;P0.set(e,t);for(const n of jd.values())NT(n,t);for(const n of AB.values())NT(n,t);return!0}function QN(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function ks(t){return t==null?!1:t.settings!==void 0}const RB={"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."},Mi=new rf("app","Firebase",RB);class NB{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 _c("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 Mi.create("app-deleted",{appName:this._name})}}const of=TB;function eM(t,e={}){let n=t;typeof e!="object"&&(e={name:e});const r={name:L0,automaticDataCollectionEnabled:!0,...e},s=r.name;if(typeof s!="string"||!s)throw Mi.create("bad-app-name",{appName:String(s)});if(n||(n=WN()),!n)throw Mi.create("no-options");const i=jd.get(s);if(i)if(Tc(n,i.options)){if(Tc(r,i.config))return i;throw Mi.create("duplicate-app",{appName:s,mismatchedParam:"config",oldValue:JSON.stringify(i.config),newValue:JSON.stringify(r)})}else throw Mi.create("duplicate-app",{appName:s,mismatchedParam:"options",oldValue:JSON.stringify(i.options),newValue:JSON.stringify(n)});const o=new L$(s);for(const u of P0.values())o.addComponent(u);const l=new NB(n,r,o);return jd.set(s,l),l}function tM(t=L0){const e=jd.get(t);if(!e&&t===L0&&WN())return eM();if(!e)throw Mi.create("no-app",{appName:t});return e}function MB(){return Array.from(jd.values())}function bc(t,e,n){let r=_B[t]??t;n&&(r+=`-${n}`);const s=r.match(/\s|\//),i=e.match(/\s|\//);if(s||i){const o=[`Unable to register library "${r}" with version "${e}":`];s&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&i&&o.push("and"),i&&o.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Ui.warn(o.join(" "));return}Dd(new _c(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}const OB="firebase-heartbeat-database",jB=1,Id="firebase-heartbeat-store";let xv=null;function nM(){return xv||(xv=Z$(OB,jB,{upgrade:(t,e)=>{switch(e){case 0:try{t.createObjectStore(Id)}catch(n){console.warn(n)}}}}).catch(t=>{throw Mi.create("idb-open",{originalErrorMessage:t.message})})),xv}async function DB(t){try{const n=(await nM()).transaction(Id),r=await n.objectStore(Id).get(rM(t));return await n.done,r}catch(e){if(e instanceof oa)Ui.warn(e.message);else{const n=Mi.create("idb-get",{originalErrorMessage:e?.message});Ui.warn(n.message)}}}async function MT(t,e){try{const r=(await nM()).transaction(Id,"readwrite");await r.objectStore(Id).put(e,rM(t)),await r.done}catch(n){if(n instanceof oa)Ui.warn(n.message);else{const r=Mi.create("idb-set",{originalErrorMessage:n?.message});Ui.warn(r.message)}}}function rM(t){return`${t.name}!${t.options.appId}`}const IB=1024,LB=30;class PB{constructor(e){this.container=e,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new $B(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=OT();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(s=>s.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:n}),this._heartbeatsCache.heartbeats.length>LB){const s=BB(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(s,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){Ui.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=OT(),{heartbeatsToSend:n,unsentEntries:r}=zB(this._heartbeatsCache.heartbeats),s=qN(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)),s}catch(e){return Ui.warn(e),""}}}function OT(){return new Date().toISOString().substring(0,10)}function zB(t,e=IB){const n=[];let r=t.slice();for(const s of t){const i=n.find(o=>o.agent===s.agent);if(i){if(i.dates.push(s.date),jT(n)>e){i.dates.pop();break}}else if(n.push({agent:s.agent,dates:[s.date]}),jT(n)>e){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}class $B{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return C$()?E$().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const n=await DB(this.app);return n?.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return MT(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 MT(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function jT(t){return qN(JSON.stringify({version:2,heartbeats:t})).length}function BB(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 VB(t){Dd(new _c("platform-logger",e=>new J$(e),"PRIVATE")),Dd(new _c("heartbeat",e=>new PB(e),"PRIVATE")),bc(I0,RT,t),bc(I0,RT,"esm2020"),bc("fire-js","")}VB("");var HB="firebase",UB="12.17.1";bc(HB,UB,"app");function sM(){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 FB=sM,iM=new rf("auth","Firebase",sM());const Vp=new YN("@firebase/auth");function oM(t,...e){Vp.logLevel<=Lt.WARN&&Vp.warn(`Auth (${of}): ${t}`,...e)}function Sp(t,...e){Vp.logLevel<=Lt.ERROR&&Vp.error(`Auth (${of}): ${t}`,...e)}function ls(t,...e){throw vw(t,...e)}function As(t,...e){return vw(t,...e)}function bw(t,e,n){const r={...FB(),[e]:n};return new rf("auth","Firebase",r).create(e,{appName:t.name})}function Uo(t){return bw(t,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function qB(t,e,n){const r=n;if(!(e instanceof r))throw r.name!==e.constructor.name&&ls(t,"argument-error"),bw(t,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function vw(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 iM.create(t,...e)}function Ze(t,e,...n){if(!t)throw vw(e,...n)}function Oi(t){const e="INTERNAL ASSERTION FAILED: "+t;throw Sp(e),new Error(e)}function Fi(t,e){t||Oi(e)}function z0(){return typeof self<"u"&&self.location?.href||""}function GB(){return DT()==="http:"||DT()==="https:"}function DT(){return typeof self<"u"&&self.location?.protocol||null}function WB(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(GB()||w$()||"connection"in navigator)?navigator.onLine:!0}function KB(){if(typeof navigator>"u")return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}class af{constructor(e,n){this.shortDelay=e,this.longDelay=n,Fi(n>e,"Short delay should be less than long delay!"),this.isMobile=v$()||S$()}get(){return WB()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function xw(t,e){Fi(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}class aM{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;Oi("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;Oi("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;Oi("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const ZB={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 YB=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],XB=new af(3e4,6e4);function dl(t,e){return t.tenantId&&!e.tenantId?{...e,tenantId:t.tenantId}:e}async function aa(t,e,n,r,s={}){return lM(t,s,async()=>{let i={},o={};r&&(e==="GET"?o=r:i={body:JSON.stringify(r)});const l=sf({...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 d={method:e,headers:u,...i};return x$()||(d.referrerPolicy="strict-origin-when-cross-origin"),t.emulatorConfig&&gw(t.emulatorConfig.host)&&(d.credentials="include"),aM.fetch()(await cM(t,t.config.apiHost,n,l),d)})}async function lM(t,e,n){t._canInitEmulator=!1;const r={...ZB,...e};try{const s=new QB(t),i=await Promise.race([n(),s.promise]);s.clearNetworkTimeout();const o=await i.json();if("needConfirmation"in o)throw Lh(t,"account-exists-with-different-credential",o);if(i.ok&&!("errorMessage"in o))return o;{const l=i.ok?o.errorMessage:o.error.message,[u,d]=l.split(" : ");if(u==="FEDERATED_USER_ID_ALREADY_LINKED")throw Lh(t,"credential-already-in-use",o);if(u==="EMAIL_EXISTS")throw Lh(t,"email-already-in-use",o);if(u==="USER_DISABLED")throw Lh(t,"user-disabled",o);const h=r[u]||u.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw bw(t,h,d);ls(t,h)}}catch(s){if(s instanceof oa)throw s;ls(t,"network-request-failed",{message:String(s)})}}async function ig(t,e,n,r,s={}){const i=await aa(t,e,n,r,s);return"mfaPendingCredential"in i&&ls(t,"multi-factor-auth-required",{_serverResponse:i}),i}async function cM(t,e,n,r){const s=`${e}${n}?${r}`,i=t,o=i.config.emulator?xw(t.config,s):`${t.config.apiScheme}://${s}`;return YB.includes(n)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?i._getPersistence()._getFinalTarget(o).toString():o}function JB(t){switch(t){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class QB{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((n,r)=>{this.timer=setTimeout(()=>r(As(this.auth,"network-request-failed")),XB.get())})}}function Lh(t,e,n){const r={appName:t.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const s=As(t,e,r);return s.customData._tokenResponse=n,s}function IT(t){return t!==void 0&&t.enterprise!==void 0}class e3{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 JB(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 t3(t,e){return aa(t,"GET","/v2/recaptchaConfig",dl(t,e))}async function n3(t,e){return aa(t,"POST","/v1/accounts:delete",e)}async function Hp(t,e){return aa(t,"POST","/v1/accounts:lookup",e)}function md(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function r3(t,e=!1){const n=Ki(t),r=await n.getIdToken(e),s=ww(r);Ze(s&&s.exp&&s.auth_time&&s.iat,n.auth,"internal-error");const i=typeof s.firebase=="object"?s.firebase:void 0,o=i?.sign_in_provider;return{claims:s,token:r,authTime:md(wv(s.auth_time)),issuedAtTime:md(wv(s.iat)),expirationTime:md(wv(s.exp)),signInProvider:o||null,signInSecondFactor:i?.sign_in_second_factor||null}}function wv(t){return Number(t)*1e3}function ww(t){const[e,n,r]=t.split(".");if(e===void 0||n===void 0||r===void 0)return Sp("JWT malformed, contained fewer than 3 sections"),null;try{const s=GN(n);return s?JSON.parse(s):(Sp("Failed to decode base64 JWT payload"),null)}catch(s){return Sp("Caught error parsing JWT payload as JSON",s?.toString()),null}}function LT(t){const e=ww(t);return Ze(e,"internal-error"),Ze(typeof e.exp<"u","internal-error"),Ze(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}async function Ld(t,e,n=!1){if(n)return e;try{return await e}catch(r){throw r instanceof oa&&s3(r)&&t.auth.currentUser===t&&await t.auth.signOut(),r}}function s3({code:t}){return t==="auth/user-disabled"||t==="auth/user-token-expired"}class i3{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 $0{constructor(e,n){this.createdAt=e,this.lastLoginAt=n,this._initializeTime()}_initializeTime(){this.lastSignInTime=md(this.lastLoginAt),this.creationTime=md(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function Up(t){const e=t.auth,n=await t.getIdToken(),r=await Ld(t,Hp(e,{idToken:n}));Ze(r?.users.length,e,"internal-error");const s=r.users[0];t._notifyReloadListener(s);const i=s.providerUserInfo?.length?uM(s.providerUserInfo):[],o=a3(t.providerData,i),l=t.isAnonymous,u=!(t.email&&s.passwordHash)&&!o?.length,d=l?u:!1,h={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:o,metadata:new $0(s.createdAt,s.lastLoginAt),isAnonymous:d};Object.assign(t,h)}async function o3(t){const e=Ki(t);await Up(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function a3(t,e){return[...t.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function uM(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 l3(t,e){const n=await lM(t,{},async()=>{const r=sf({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=t.config,o=await cM(t,s,"/v1/token",`key=${i}`),l=await t._getAdditionalHeaders();l["Content-Type"]="application/x-www-form-urlencoded";const u={method:"POST",headers:l,body:r};return t.emulatorConfig&&gw(t.emulatorConfig.host)&&(u.credentials="include"),aM.fetch()(o,u)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function c3(t,e){return aa(t,"POST","/v2/accounts:revokeToken",dl(t,e))}class vc{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){Ze(e.idToken,"internal-error"),Ze(typeof e.idToken<"u","internal-error"),Ze(typeof e.refreshToken<"u","internal-error");const n="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):LT(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,n)}updateFromIdToken(e){Ze(e.length!==0,"internal-error");const n=LT(e);this.updateTokensAndExpiration(e,null,n)}async getToken(e,n=!1){return!n&&this.accessToken&&!this.isExpired?this.accessToken:(Ze(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:s,expiresIn:i}=await l3(e,n);this.updateTokensAndExpiration(r,s,Number(i))}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:s,expirationTime:i}=n,o=new vc;return r&&(Ze(typeof r=="string","internal-error",{appName:e}),o.refreshToken=r),s&&(Ze(typeof s=="string","internal-error",{appName:e}),o.accessToken=s),i&&(Ze(typeof i=="number","internal-error",{appName:e}),o.expirationTime=i),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 vc,this.toJSON())}_performRefresh(){return Oi("not implemented")}}function ko(t,e){Ze(typeof t=="string"||typeof t>"u","internal-error",{appName:e})}class Ts{constructor({uid:e,auth:n,stsTokenManager:r,...s}){this.providerId="firebase",this.proactiveRefresh=new i3(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new $0(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const n=await Ld(this,this.stsTokenManager.getToken(this.auth,e));return Ze(n,this.auth,"internal-error"),this.accessToken!==n&&(this.accessToken=n,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),n}getIdTokenResult(e){return r3(this,e)}reload(){return o3(this)}_assign(e){this!==e&&(Ze(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 Ts({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return n.metadata._copy(this.metadata),n}_onReload(e){Ze(!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 Up(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(ks(this.auth.app))return Promise.reject(Uo(this.auth));const e=await this.getIdToken();return await Ld(this,n3(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,s=n.email??void 0,i=n.phoneNumber??void 0,o=n.photoURL??void 0,l=n.tenantId??void 0,u=n._redirectEventId??void 0,d=n.createdAt??void 0,h=n.lastLoginAt??void 0,{uid:g,emailVerified:y,isAnonymous:b,providerData:x,stsTokenManager:S}=n;Ze(g&&S,e,"internal-error");const k=vc.fromJSON(this.name,S);Ze(typeof g=="string",e,"internal-error"),ko(r,e.name),ko(s,e.name),Ze(typeof y=="boolean",e,"internal-error"),Ze(typeof b=="boolean",e,"internal-error"),ko(i,e.name),ko(o,e.name),ko(l,e.name),ko(u,e.name),ko(d,e.name),ko(h,e.name);const C=new Ts({uid:g,auth:e,email:s,emailVerified:y,displayName:r,isAnonymous:b,photoURL:o,phoneNumber:i,tenantId:l,stsTokenManager:k,createdAt:d,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 s=new vc;s.updateFromServerResponse(n);const i=new Ts({uid:n.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await Up(i),i}static async _fromGetAccountInfoResponse(e,n,r){const s=n.users[0];Ze(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?uM(s.providerUserInfo):[],o=!(s.email&&s.passwordHash)&&!i?.length,l=new vc;l.updateFromIdToken(r);const u=new Ts({uid:s.localId,auth:e,stsTokenManager:l,isAnonymous:o}),d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:i,metadata:new $0(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!i?.length};return Object.assign(u,d),u}}const PT=new Map;function ji(t){Fi(t instanceof Function,"Expected a class definition");let e=PT.get(t);return e?(Fi(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,PT.set(t,e),e)}class dM{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){}}dM.type="NONE";const zT=dM;function kp(t,e,n){return`firebase:${t}:${e}:${n}`}class xc{constructor(e,n,r){this.persistence=e,this.auth=n,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=kp(this.userKey,s.apiKey,i),this.fullPersistenceKey=kp("persistence",s.apiKey,i),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 Hp(this.auth,{idToken:e}).catch(()=>{});return n?Ts._fromGetAccountInfoResponse(this.auth,n,e):null}return Ts._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 xc(ji(zT),e,r);const s=(await Promise.all(n.map(async d=>{if(await d._isAvailable())return d}))).filter(d=>d);let i=s[0]||ji(zT);const o=kp(r,e.config.apiKey,e.name);let l=null;for(const d of n)try{const h=await d._get(o);if(h){let g;if(typeof h=="string"){const y=await Hp(e,{idToken:h}).catch(()=>{});if(!y)break;g=await Ts._fromGetAccountInfoResponse(e,y,h)}else g=Ts._fromJSON(e,h);d!==i&&(l=g),i=d;break}}catch{}const u=s.filter(d=>d._shouldAllowMigration);return!i._shouldAllowMigration||!u.length?new xc(i,e,r):(i=u[0],l&&await i._set(o,l.toJSON()),await Promise.all(n.map(async d=>{if(d!==i)try{await d._remove(o)}catch{}})),new xc(i,e,r))}}function $T(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(mM(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(fM(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(yM(e))return"Blackberry";if(bM(e))return"Webos";if(hM(e))return"Safari";if((e.includes("chrome/")||pM(e))&&!e.includes("edge/"))return"Chrome";if(gM(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 fM(t=dr()){return/firefox\//i.test(t)}function hM(t=dr()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function pM(t=dr()){return/crios\//i.test(t)}function mM(t=dr()){return/iemobile/i.test(t)}function gM(t=dr()){return/android/i.test(t)}function yM(t=dr()){return/blackberry/i.test(t)}function bM(t=dr()){return/webos/i.test(t)}function Sw(t=dr()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function u3(t=dr()){return Sw(t)&&!!window.navigator?.standalone}function d3(){return k$()&&document.documentMode===10}function vM(t=dr()){return Sw(t)||gM(t)||bM(t)||yM(t)||/windows phone/i.test(t)||mM(t)}function xM(t,e=[]){let n;switch(t){case"Browser":n=$T(dr());break;case"Worker":n=`${$T(dr())}-${t}`;break;default:n=t}const r=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${of}/${r}`}class f3{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,n){const r=i=>new Promise((o,l)=>{try{const u=e(i);o(u)}catch(u){l(u)}});r.onAbort=n,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>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 s of n)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r?.message})}}}async function h3(t,e={}){return aa(t,"GET","/v2/passwordPolicy",dl(t,e))}const p3=6;class m3{constructor(e){const n=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=n.minPasswordLength??p3,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,s=this.customStrengthOptions.maxPasswordLength;r&&(n.meetsMinPasswordLength=e.length>=r),s&&(n.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,n){this.updatePasswordCharacterOptionsStatuses(n,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(n,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,n,r,s,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=n)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class g3{constructor(e,n,r,s){this.app=e,this.heartbeatServiceProvider=n,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new BT(this),this.idTokenSubscription=new BT(this),this.beforeStateQueue=new f3(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=iM,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=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(i=>this._resolvePersistenceManagerAvailable=i)}_initializeWithPersistence(e,n){return n&&(this._popupRedirectResolver=ji(n)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await xc.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 Hp(this,{idToken:e}),r=await Ts._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(ks(this.app)){const i=this.app.settings.authIdToken;return i?new Promise(o=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(i).then(o,o))}):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let r=n,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const i=this.redirectUser?._redirectEventId,o=r?._redirectEventId,l=await this.tryRedirectSignIn(e);(!i||i===o)&&l?.user&&(r=l.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(i){r=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(i))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return Ze(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 Up(e)}catch(n){if(n?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=KB()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(ks(this.app))return Promise.reject(Uo(this));const n=e?Ki(e):null;return n&&Ze(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&&Ze(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 ks(this.app)?Promise.reject(Uo(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return ks(this.app)?Promise.reject(Uo(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(ji(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 h3(this),n=new m3(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 rf("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 c3(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&&ji(e)||this._popupRedirectResolver;Ze(n,this,"argument-error"),this.redirectPersistenceManager=await xc.create(this,[ji(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,s){if(this._deleted)return()=>{};const i=typeof n=="function"?n:n.next.bind(n);let o=!1;const l=this._isInitialized?Promise.resolve():this._initializationPromise;if(Ze(l,this,"internal-error"),l.then(()=>{o||i(this.currentUser)}),typeof n=="function"){const u=e.addObserver(n,r,s);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 Ze(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=xM(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(ks(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&oM(`Error while retrieving App Check token: ${e.error}`),e?.token}}function fl(t){return Ki(t)}class BT{constructor(e){this.auth=e,this.observer=null,this.addObserver=R$(n=>this.observer=n)}get next(){return Ze(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let og={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function y3(t){og=t}function wM(t){return og.loadJS(t)}function b3(){return og.recaptchaEnterpriseScript}function v3(){return og.gapiScript}function x3(t){return`__${t}${Math.floor(Math.random()*1e6)}`}class w3{constructor(){this.enterprise=new S3}ready(e){e()}execute(e,n){return Promise.resolve("token")}render(e,n){return""}}class S3{ready(e){e()}execute(e,n){return Promise.resolve("token")}render(e,n){return""}}const k3="recaptcha-enterprise",SM="NO_RECAPTCHA",VT="onFirebaseAuthREInstanceReady";class Mo{constructor(e){this.type=k3,this.auth=fl(e)}async verify(e="verify",n=!1){async function r(i){if(!n){if(i.tenantId==null&&i._agentRecaptchaConfig!=null)return i._agentRecaptchaConfig.siteKey;if(i.tenantId!=null&&i._tenantRecaptchaConfigs[i.tenantId]!==void 0)return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(o,l)=>{t3(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(u=>{if(u.recaptchaKey===void 0)l(new Error("recaptcha Enterprise site key undefined"));else{const d=new e3(u);return i.tenantId==null?i._agentRecaptchaConfig=d:i._tenantRecaptchaConfigs[i.tenantId]=d,o(d.siteKey)}}).catch(u=>{l(u)})})}function s(i,o,l){const u=window.grecaptcha;IT(u)?u.enterprise.ready(()=>{u.enterprise.execute(i,{action:e}).then(d=>{o(d)}).catch(()=>{o(SM)})}):l(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new w3().execute("siteKey",{action:"verify"}):new Promise((i,o)=>{r(this.auth).then(async l=>{if(!n&&IT(window.grecaptcha)&&Mo.scriptInjectionDeferred)await Mo.scriptInjectionDeferred.promise,s(l,i,o);else{if(typeof window>"u"){o(new Error("RecaptchaVerifier is only supported in browser"));return}let u=b3();u.length!==0&&(u+=l+`&onload=${VT}`),Mo.scriptInjectionDeferred=new ZN,window[VT]=()=>{Mo.scriptInjectionDeferred?.resolve()},wM(u).then(()=>Mo.scriptInjectionDeferred?.promise).then(()=>{s(l,i,o)}).catch(d=>{o(d)})}}).catch(l=>{o(l)})})}}Mo.scriptInjectionDeferred=null;async function HT(t,e,n,r=!1,s=!1){const i=new Mo(t);let o;if(s)o=SM;else try{o=await i.verify(n)}catch{o=await i.verify(n,!0)}const l={...e};if(n==="mfaSmsEnrollment"||n==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in l){const u=l.phoneEnrollmentInfo.phoneNumber,d=l.phoneEnrollmentInfo.recaptchaToken;Object.assign(l,{phoneEnrollmentInfo:{phoneNumber:u,recaptchaToken:d,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 UT(t,e,n,r,s){if(t._getRecaptchaConfig()?.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const i=await HT(t,e,n,n==="getOobCode");return r(t,i)}else return r(t,e).catch(async i=>{if(i.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 HT(t,e,n,n==="getOobCode");return r(t,o)}else return Promise.reject(i)})}function C3(t,e){const n=QN(t,"auth");if(n.isInitialized()){const s=n.getImmediate(),i=n.getOptions();if(Tc(i,e??{}))return s;ls(s,"already-initialized")}return n.initialize({options:e})}function E3(t,e){const n=e?.persistence||[],r=(Array.isArray(n)?n:[n]).map(ji);e?.errorMap&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,e?.popupRedirectResolver)}function T3(t,e,n){const r=fl(t);Ze(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,i=kM(e),{host:o,port:l}=_3(e),u=l===null?"":`:${l}`,d={url:`${i}//${o}${u}/`},h=Object.freeze({host:o,port:l,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){Ze(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),Ze(Tc(d,r.config.emulator)&&Tc(h,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=d,r.emulatorConfig=h,r.settings.appVerificationDisabledForTesting=!0,gw(o)?O$(`${i}//${o}${u}`):A3()}function kM(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function _3(t){const e=kM(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const i=s[1];return{host:i,port:FT(r.substr(i.length+1))}}else{const[i,o]=r.split(":");return{host:i,port:FT(o)}}}function FT(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}function A3(){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 kw{constructor(e,n){this.providerId=e,this.signInMethod=n}toJSON(){return Oi("not implemented")}_getIdTokenResponse(e){return Oi("not implemented")}_linkToIdToken(e,n){return Oi("not implemented")}_getReauthenticationResolver(e){return Oi("not implemented")}}async function R3(t,e){return aa(t,"POST","/v1/accounts:signUp",e)}async function N3(t,e){return ig(t,"POST","/v1/accounts:signInWithPassword",dl(t,e))}async function M3(t,e){return ig(t,"POST","/v1/accounts:signInWithEmailLink",dl(t,e))}async function O3(t,e){return ig(t,"POST","/v1/accounts:signInWithEmailLink",dl(t,e))}class Pd extends kw{constructor(e,n,r,s=null){super("password",r),this._email=e,this._password=n,this._tenantId=s}static _fromEmailAndPassword(e,n){return new Pd(e,n,"password")}static _fromEmailAndCode(e,n,r=null){return new Pd(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 UT(e,n,"signInWithPassword",N3);case"emailLink":return M3(e,{email:this._email,oobCode:this._password});default:ls(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 UT(e,r,"signUpPassword",R3);case"emailLink":return O3(e,{idToken:n,email:this._email,oobCode:this._password});default:ls(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function wc(t,e){return ig(t,"POST","/v1/accounts:signInWithIdp",dl(t,e))}const j3="http://localhost";class Ya extends kw{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const n=new Ya(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):ls("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:s,...i}=n;if(!r||!s)return null;const o=new Ya(r,s);return o.idToken=i.idToken||void 0,o.accessToken=i.accessToken||void 0,o.secret=i.secret,o.nonce=i.nonce,o.pendingToken=i.pendingToken||null,o}_getIdTokenResponse(e){const n=this.buildRequest();return wc(e,n)}_linkToIdToken(e,n){const r=this.buildRequest();return r.idToken=n,wc(e,r)}_getReauthenticationResolver(e){const n=this.buildRequest();return n.autoCreate=!1,wc(e,n)}buildRequest(){const e={requestUri:j3,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=sf(n)}return e}}function D3(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 I3(t){const e=sd(id(t)).link,n=e?sd(id(e)).deep_link_id:null,r=sd(id(t)).deep_link_id;return(r?sd(id(r)).link:null)||r||n||e||t}class Cw{constructor(e){const n=sd(id(e)),r=n.apiKey??null,s=n.oobCode??null,i=D3(n.mode??null);Ze(r&&s&&i,"argument-error"),this.apiKey=r,this.operation=i,this.code=s,this.continueUrl=n.continueUrl??null,this.languageCode=n.lang??null,this.tenantId=n.tenantId??null}static parseLink(e){const n=I3(e);try{return new Cw(n)}catch{return null}}}class Gc{constructor(){this.providerId=Gc.PROVIDER_ID}static credential(e,n){return Pd._fromEmailAndPassword(e,n)}static credentialWithLink(e,n){const r=Cw.parseLink(n);return Ze(r,"argument-error"),Pd._fromEmailAndCode(e,r.code,r.tenantId)}}Gc.PROVIDER_ID="password";Gc.EMAIL_PASSWORD_SIGN_IN_METHOD="password";Gc.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Ew{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 lf extends Ew{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Oo extends lf{constructor(){super("facebook.com")}static credential(e){return Ya._fromParams({providerId:Oo.PROVIDER_ID,signInMethod:Oo.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Oo.credentialFromTaggedObject(e)}static credentialFromError(e){return Oo.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Oo.credential(e.oauthAccessToken)}catch{return null}}}Oo.FACEBOOK_SIGN_IN_METHOD="facebook.com";Oo.PROVIDER_ID="facebook.com";class Ni extends lf{constructor(){super("google.com"),this.addScope("profile")}static credential(e,n){return Ya._fromParams({providerId:Ni.PROVIDER_ID,signInMethod:Ni.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:n})}static credentialFromResult(e){return Ni.credentialFromTaggedObject(e)}static credentialFromError(e){return Ni.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:n,oauthAccessToken:r}=e;if(!n&&!r)return null;try{return Ni.credential(n,r)}catch{return null}}}Ni.GOOGLE_SIGN_IN_METHOD="google.com";Ni.PROVIDER_ID="google.com";class jo extends lf{constructor(){super("github.com")}static credential(e){return Ya._fromParams({providerId:jo.PROVIDER_ID,signInMethod:jo.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return jo.credentialFromTaggedObject(e)}static credentialFromError(e){return jo.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return jo.credential(e.oauthAccessToken)}catch{return null}}}jo.GITHUB_SIGN_IN_METHOD="github.com";jo.PROVIDER_ID="github.com";class Do extends lf{constructor(){super("twitter.com")}static credential(e,n){return Ya._fromParams({providerId:Do.PROVIDER_ID,signInMethod:Do.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:n})}static credentialFromResult(e){return Do.credentialFromTaggedObject(e)}static credentialFromError(e){return Do.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:n,oauthTokenSecret:r}=e;if(!n||!r)return null;try{return Do.credential(n,r)}catch{return null}}}Do.TWITTER_SIGN_IN_METHOD="twitter.com";Do.PROVIDER_ID="twitter.com";class Ac{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,n,r,s=!1){const i=await Ts._fromIdTokenResponse(e,r,s),o=qT(r);return new Ac({user:i,providerId:o,_tokenResponse:r,operationType:n})}static async _forOperation(e,n,r){await e._updateTokensIfNecessary(r,!0);const s=qT(r);return new Ac({user:e,providerId:s,_tokenResponse:r,operationType:n})}}function qT(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}class Fp extends oa{constructor(e,n,r,s){super(n.code,n.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,Fp.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:n.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,n,r,s){return new Fp(e,n,r,s)}}function CM(t,e,n,r){return(e==="reauthenticate"?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?Fp._fromErrorAndOperation(t,i,e,r):i})}async function L3(t,e,n=!1){const r=await Ld(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return Ac._forOperation(t,"link",r)}async function P3(t,e,n=!1){const{auth:r}=t;if(ks(r.app))return Promise.reject(Uo(r));const s="reauthenticate";try{const i=await Ld(t,CM(r,s,e,t),n);Ze(i.idToken,r,"internal-error");const o=ww(i.idToken);Ze(o,r,"internal-error");const{sub:l}=o;return Ze(t.uid===l,r,"user-mismatch"),Ac._forOperation(t,s,i)}catch(i){throw i?.code==="auth/user-not-found"&&ls(r,"user-mismatch"),i}}async function EM(t,e,n=!1){if(ks(t.app))return Promise.reject(Uo(t));const r="signIn",s=await CM(t,r,e),i=await Ac._fromIdTokenResponse(t,r,s);return n||await t._updateCurrentUser(i.user),i}async function z3(t,e){return EM(fl(t),e)}async function $3(t){const e=fl(t);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}function B3(t,e,n){return ks(t.app)?Promise.reject(Uo(t)):z3(Ki(t),Gc.credential(e,n)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&$3(t),r})}function V3(t,e,n,r){return Ki(t).onIdTokenChanged(e,n,r)}function H3(t,e,n){return Ki(t).beforeAuthStateChanged(e,n)}function U3(t,e,n,r){return Ki(t).onAuthStateChanged(e,n,r)}function GT(t){return Ki(t).signOut()}const qp="__sak";class TM{constructor(e,n){this.storageRetriever=e,this.type=n}_isAvailable(){try{return this.storage?(this.storage.setItem(qp,"1"),this.storage.removeItem(qp),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 F3=1e3,q3=10;class _M extends TM{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,n)=>this.onStorageEvent(e,n),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=vM(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const n of Object.keys(this.listeners)){const r=this.storage.getItem(n),s=this.localCache[n];r!==s&&e(n,s,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 s=()=>{const o=this.storage.getItem(r);!n&&this.localCache[r]===o||this.notifyListeners(r,o)},i=this.storage.getItem(r);d3()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,q3):s()}notifyListeners(e,n){this.localCache[e]=n;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(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)})},F3)}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]}}_M.type="LOCAL";const G3=_M;class AM extends TM{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,n){}_removeListener(e,n){}}AM.type="SESSION";const RM=AM;function W3(t){return Promise.all(t.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(n){return{fulfilled:!1,reason:n}}}))}class ag{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const n=this.receivers.find(s=>s.isListeningto(e));if(n)return n;const r=new ag(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const n=e,{eventId:r,eventType:s,data:i}=n.data,o=this.handlersMap[s];if(!o?.size)return;n.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const l=Array.from(o).map(async d=>d(n.origin,i)),u=await W3(l);n.ports[0].postMessage({status:"done",eventId:r,eventType:s,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)}}ag.receivers=[];function Tw(t="",e=10){let n="";for(let r=0;r<e;r++)n+=Math.floor(Math.random()*10);return t+n}class K3{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 s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let i,o;return new Promise((l,u)=>{const d=Tw("",20);s.port1.start();const h=setTimeout(()=>{u(new Error("unsupported_event"))},r);o={messageChannel:s,onMessage(g){const y=g;if(y.data.eventId===d)switch(y.data.status){case"ack":clearTimeout(h),i=setTimeout(()=>{u(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),l(y.data.response);break;default:clearTimeout(h),clearTimeout(i),u(new Error("invalid_response"));break}}},this.handlers.add(o),s.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:d,data:n},[s.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}function Ks(){return window}function Z3(t){Ks().location.href=t}function NM(){return typeof Ks().WorkerGlobalScope<"u"&&typeof Ks().importScripts=="function"}async function Y3(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function X3(){return navigator?.serviceWorker?.controller||null}function J3(){return NM()?self:null}const MM="firebaseLocalStorageDb",Q3=1,Gp="firebaseLocalStorage",OM="fbase_key";class cf{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 lg(t,e){return t.transaction([Gp],e?"readwrite":"readonly").objectStore(Gp)}function eV(){const t=indexedDB.deleteDatabase(MM);return new cf(t).toPromise()}function jM(){const t=indexedDB.open(MM,Q3);return new Promise((e,n)=>{t.addEventListener("error",()=>{n(t.error)}),t.addEventListener("upgradeneeded",()=>{const r=t.result;try{r.createObjectStore(Gp,{keyPath:OM})}catch(s){n(s)}}),t.addEventListener("success",async()=>{const r=t.result;r.objectStoreNames.contains(Gp)?e(r):(r.close(),await eV(),e(await jM()))})})}async function WT(t,e,n){const r=lg(t,!0).put({[OM]:e,value:n});return new cf(r).toPromise()}async function tV(t,e){const n=lg(t,!1).get(e),r=await new cf(n).toPromise();return r===void 0?null:r.value}function KT(t,e){const n=lg(t,!0).delete(e);return new cf(n).toPromise()}const nV=800,rV=3;class DM{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=jM(),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++>rV)throw r;this.dbPromise&&((await this.dbPromise).close(),this.dbPromise=null)}}async initializeServiceWorkerMessaging(){return NM()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=ag._getInstance(J3()),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 Y3(),!this.activeServiceWorker)return;this.sender=new K3(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||X3()!==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 WT(e,qp,"1"),await KT(e,qp)}),!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=>WT(r,e,n)),this.localCache[e]=n,this.notifyServiceWorker(e)))}async _get(e){const n=await this._withRetries(r=>tV(r,e));return this.localCache[e]=n,n}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(n=>KT(n,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){if(this.isHiding)return[];try{const e=await this._withRetries(s=>{const i=lg(s,!1).getAll();return new cf(i).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:s,value:i}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(i)&&(this.notifyListeners(s,i),n.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),n.push(s));return n}catch(e){return this.isHiding||oM(`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 s of Array.from(r))s(n)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),nV)}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())}}DM.type="LOCAL";const sV=DM;new af(3e4,6e4);function IM(t,e){return e?ji(e):(Ze(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}class _w extends kw{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return wc(e,this._buildIdpRequest())}_linkToIdToken(e,n){return wc(e,this._buildIdpRequest(n))}_getReauthenticationResolver(e){return wc(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 iV(t){return EM(t.auth,new _w(t),t.bypassAuthState)}function oV(t){const{auth:e,user:n}=t;return Ze(n,e,"internal-error"),P3(n,new _w(t),t.bypassAuthState)}async function aV(t){const{auth:e,user:n}=t;return Ze(n,e,"internal-error"),L3(n,new _w(t),t.bypassAuthState)}class LM{constructor(e,n,r,s,i=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=i,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:s,tenantId:i,error:o,type:l}=e;if(o){this.reject(o);return}const u={auth:this.auth,requestUri:n,sessionId:r,tenantId:i||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(l)(u))}catch(d){this.reject(d)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return iV;case"linkViaPopup":case"linkViaRedirect":return aV;case"reauthViaPopup":case"reauthViaRedirect":return oV;default:ls(this.auth,"internal-error")}}resolve(e){Fi(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Fi(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 lV=new af(2e3,1e4);async function cV(t,e,n){if(ks(t.app))return Promise.reject(As(t,"operation-not-supported-in-this-environment"));const r=fl(t);qB(t,e,Ew);const s=IM(r,n);return new za(r,"signInViaPopup",e,s).executeNotNull()}class za extends LM{constructor(e,n,r,s,i){super(e,n,s,i),this.provider=r,this.authWindow=null,this.pollId=null,za.currentPopupAction&&za.currentPopupAction.cancel(),za.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return Ze(e,this.auth,"internal-error"),e}async onExecution(){Fi(this.filter.length===1,"Popup operations only handle one event");const e=Tw();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(As(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(As(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,za.currentPopupAction=null}pollUserCancellation(){const e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(As(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,lV.get())};e()}}za.currentPopupAction=null;const uV="pendingRedirect",Cp=new Map;class dV extends LM{constructor(e,n,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,r),this.eventId=null}async execute(){let e=Cp.get(this.auth._key());if(!e){try{const r=await fV(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(n){e=()=>Promise.reject(n)}Cp.set(this.auth._key(),e)}return this.bypassAuthState||Cp.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 fV(t,e){const n=mV(e),r=pV(t);if(!await r._isAvailable())return!1;const s=await r._get(n)==="true";return await r._remove(n),s}function hV(t,e){Cp.set(t._key(),e)}function pV(t){return ji(t._redirectPersistence)}function mV(t){return kp(uV,t.config.apiKey,t.name)}async function gV(t,e,n=!1){if(ks(t.app))return Promise.reject(Uo(t));const r=fl(t),s=IM(r,e),o=await new dV(r,s,n).execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,e)),o}const yV=600*1e3;class bV{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||!vV(e)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=e,n=!0)),n}sendToConsumer(e,n){if(e.error&&!PM(e)){const r=e.error.code?.split("auth/")[1]||"internal-error";n.onError(As(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>=yV&&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 PM({type:t,error:e}){return t==="unknown"&&e?.code==="auth/no-auth-event"}function vV(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return PM(t);default:return!1}}async function xV(t,e={}){return aa(t,"GET","/v1/projects",e)}const wV=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,SV=/^https?/;async function kV(t){if(t.config.emulator)return;const{authorizedDomains:e}=await xV(t);for(const n of e)try{if(CV(n))return}catch{}ls(t,"unauthorized-domain")}function CV(t){const e=z0(),{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(!SV.test(n))return!1;if(wV.test(t))return r===t;const s=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}const EV=new af(3e4,6e4);function YT(){const t=Ks().___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 TV(t){return new Promise((e,n)=>{function r(){YT(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{YT(),n(As(t,"network-request-failed"))},timeout:EV.get()})}if(Ks().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else if(Ks().gapi?.load)r();else{const s=x3("iframefcb");return Ks()[s]=()=>{gapi.load?r():n(As(t,"network-request-failed"))},wM(`${v3()}?onload=${s}`).catch(i=>n(i))}}).catch(e=>{throw Ep=null,e})}let Ep=null;function _V(t){return Ep=Ep||TV(t),Ep}const AV=new af(5e3,15e3),RV="__/auth/iframe",NV="emulator/auth/iframe",MV={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},OV=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function jV(t){const e=t.config;Ze(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?xw(e,NV):`https://${t.config.authDomain}/${RV}`,r={apiKey:e.apiKey,appName:t.name,v:of},s=OV.get(t.config.apiHost);s&&(r.eid=s);const i=t._getFrameworks();return i.length&&(r.fw=i.join(",")),`${n}?${sf(r).slice(1)}`}async function DV(t){const e=await _V(t),n=Ks().gapi;return Ze(n,t,"internal-error"),e.open({where:document.body,url:jV(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:MV,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const o=As(t,"network-request-failed"),l=Ks().setTimeout(()=>{i(o)},AV.get());function u(){Ks().clearTimeout(l),s(r)}r.ping(u).then(u,()=>{i(o)})}))}const IV={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},LV=500,PV=600,zV="_blank",$V="http://localhost";class XT{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function BV(t,e,n,r=LV,s=PV){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let l="";const u={...IV,width:r.toString(),height:s.toString(),top:i,left:o},d=dr().toLowerCase();n&&(l=pM(d)?zV:n),fM(d)&&(e=e||$V,u.scrollbars="yes");const h=Object.entries(u).reduce((y,[b,x])=>`${y}${b}=${x},`,"");if(u3(d)&&l!=="_self")return VV(e||"",l),new XT(null);const g=window.open(e||"",l,h);Ze(g,t,"popup-blocked");try{g.focus()}catch{}return new XT(g)}function VV(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 HV="__/auth/handler",UV="emulator/auth/handler",FV=encodeURIComponent("fac");async function JT(t,e,n,r,s,i){Ze(t.config.authDomain,t,"auth-domain-config-required"),Ze(t.config.apiKey,t,"invalid-api-key");const o={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:r,v:of,eventId:s};if(e instanceof Ew){e.setDefaultLanguage(t.languageCode),o.providerId=e.providerId||"",A$(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(const[h,g]of Object.entries({}))o[h]=g}if(e instanceof lf){const h=e.getScopes().filter(g=>g!=="");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(),d=u?`#${FV}=${encodeURIComponent(u)}`:"";return`${qV(t)}?${sf(l).slice(1)}${d}`}function qV({config:t}){return t.emulator?xw(t,UV):`https://${t.authDomain}/${HV}`}const Sv="webStorageSupport";class GV{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=RM,this._completeRedirectFn=gV,this._overrideRedirectResult=hV}async _openPopup(e,n,r,s){Fi(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");const i=await JT(e,n,r,z0(),s);return BV(e,i,Tw())}async _openRedirect(e,n,r,s){await this._originValidation(e);const i=await JT(e,n,r,z0(),s);return Z3(i),new Promise(()=>{})}_initialize(e){const n=e._key();if(this.eventManagers[n]){const{manager:s,promise:i}=this.eventManagers[n];return s?Promise.resolve(s):(Fi(i,"If manager is not set, promise should be"),i)}const r=this.initAndGetManager(e);return this.eventManagers[n]={promise:r},r.catch(()=>{delete this.eventManagers[n]}),r}async initAndGetManager(e){const n=await DV(e),r=new bV(e);return n.register("authEvent",s=>(Ze(s?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.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(Sv,{type:Sv},s=>{const i=s?.[0]?.[Sv];i!==void 0&&n(!!i),ls(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const n=e._key();return this.originValidationPromises[n]||(this.originValidationPromises[n]=kV(e)),this.originValidationPromises[n]}get _shouldInitProactively(){return vM()||hM()||Sw()}}const WV=GV;var QT="@firebase/auth",e_="1.13.4";class KV{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(){Ze(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function ZV(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 YV(t){Dd(new _c("auth",(e,{options:n})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:o,authDomain:l}=r.options;Ze(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:xM(t)},d=new g3(r,s,i,u);return E3(d,n),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,n,r)=>{e.getProvider("auth-internal").initialize()})),Dd(new _c("auth-internal",e=>{const n=fl(e.getProvider("auth").getImmediate());return(r=>new KV(r))(n)},"PRIVATE").setInstantiationMode("EXPLICIT")),bc(QT,e_,ZV(t)),bc(QT,e_,"esm2020")}const XV=300,JV=KN("authIdTokenMaxAge")||XV;let t_=null;const QV=t=>async e=>{const n=e&&await e.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>JV)return;const s=n?.token;t_!==s&&(t_=s,await fetch(t,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function eH(t=tM()){const e=QN(t,"auth");if(e.isInitialized())return e.getImmediate();const n=C3(t,{popupRedirectResolver:WV,persistence:[sV,G3,RM]}),r=KN("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const o=QV(i.toString());H3(n,o,()=>o(n.currentUser)),V3(n,l=>o(l))}}const s=b$("auth");return s&&T3(n,`http://${s}`),n}function tH(){return document.getElementsByTagName("head")?.[0]??document}y3({loadJS(t){return new Promise((e,n)=>{const r=document.createElement("script");r.setAttribute("src",t),r.onload=e,r.onerror=s=>{const i=As("internal-error");i.customData=s,n(i)},r.type="text/javascript",r.charset="UTF-8",tH().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="});YV("Browser");function nH(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 g=n.get(o);if(g)return g}const d=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,d),d}function s(o,l){e.set(o,{value:l,at:Date.now()})}function i(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:s,invalidate:i}}const rH="x-vertebr-env";async function qu(t,e){const n=await t.arrayBuffer(),r=new Uint8Array(n);let s="";const i=32768;for(let l=0;l<r.length;l+=i)s+=String.fromCharCode(...r.subarray(l,l+i));return{name:e||typeof File<"u"&&t instanceof File&&t.name||"upload",type:t.type||"application/octet-stream",data:btoa(s)}}function zM(t,e){if(e&&(e.q&&t.set("q",e.q),e.sort&&t.set("sort",e.sort),(e.order==="asc"||e.order==="desc")&&t.set("order",e.order),e.limit!=null&&Number.isFinite(e.limit)&&t.set("limit",String(e.limit)),e.offset!=null&&Number.isFinite(e.offset)&&t.set("offset",String(e.offset)),e.cursor&&t.set("cursor",e.cursor),e.filters))for(const[n,r]of Object.entries(e.filters))r!=null&&r!==""&&t.set(`filter.${n}`,r)}function sH(t,e){const n=new URLSearchParams;zM(n,e);const r=n.toString();return r?`resource:${t}?${r}`:`resource:${t}`}function B0(t,e){const n=typeof t=="string"?{apiBase:t,getEnvironment:(()=>"")}:t,r=n.apiBase.replace(/\/$/,""),s=nH(n.cacheTtlMs??6e4);async function i(o,l,u){const d=n.getEnvironment().trim(),g=(await n.getAccessToken?.())?.trim(),y=await fetch(`${r}${o}`,{...l,headers:{Accept:"application/json","Content-Type":"application/json",...d?{[rH]:d}:{},...u?.auth!==!1&&g?{Authorization:`Bearer ${g}`}:{},...l?.headers??{}}});if(!y.ok){const b=await y.text();let x=b||`Request failed (${y.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 y.json()}return{getBootstrap:o=>s.get("bootstrap",()=>i("/bootstrap",void 0,{auth:!1}),o),getCatalog:o=>s.get("catalog",()=>i(""),o),getMetrics:o=>{const l=o?.range?.trim()||"14d";return s.get(`metrics:${l}`,()=>i(`/metrics?range=${encodeURIComponent(l)}`),o)},getPublicControls:o=>s.get("controls",async()=>(await i("/public/controls",void 0,{auth:!1})).configs??{},o),getPublicResource:(o,l)=>s.get(`public-resource:${o}`,()=>i(`/public/resources/${encodeURIComponent(o)}`,void 0,{auth:!1}),l),listResource:(o,l)=>{const u=new URLSearchParams;zM(u,l);const d=u.toString(),h=`/resources/${encodeURIComponent(o)}${d?`?${d}`:""}`;return s.get(sH(o,l),()=>i(h),l)},createResource:async(o,l)=>{const u=await i(`/resources/${encodeURIComponent(o)}`,{method:"POST",body:JSON.stringify(l)});return s.invalidate(`resource:${o}`),s.invalidate(`public-resource:${o}`),u},updateResource:async(o,l,u)=>{const d=await i(`/resources/${encodeURIComponent(o)}/${encodeURIComponent(l)}`,{method:"PUT",body:JSON.stringify(u)});return s.invalidate(`resource:${o}`),s.invalidate(`public-resource:${o}`),d},deleteResource:async(o,l)=>{const u=await i(`/resources/${encodeURIComponent(o)}/${encodeURIComponent(l)}`,{method:"DELETE"});return s.invalidate(`resource:${o}`),s.invalidate(`public-resource:${o}`),u},runResourceAction:async(o,l,u,d)=>{const h=await i(`/resources/${encodeURIComponent(o)}/${encodeURIComponent(l)}/actions/${encodeURIComponent(u)}`,{method:"POST",body:JSON.stringify(d??{})});return s.invalidate(`resource:${o}`),s.invalidate(`public-resource:${o}`),h},runCollectionAction:async(o,l,u)=>{const d=await i(`/resources/${encodeURIComponent(o)}/collection-actions/${encodeURIComponent(l)}`,{method:"POST",body:JSON.stringify(u??{})});return s.invalidate(`resource:${o}`),s.invalidate(`public-resource:${o}`),d},runBulkAction:async(o,l,u)=>{const d=await i(`/resources/${encodeURIComponent(o)}/bulk-actions/${encodeURIComponent(l)}`,{method:"POST",body:JSON.stringify(u)});return s.invalidate(`resource:${o}`),s.invalidate(`public-resource:${o}`),d},previewResourceMail:async(o,l,u,d)=>i(`/resources/${encodeURIComponent(o)}/${encodeURIComponent(l)}/mail/${encodeURIComponent(u)}/preview`,{method:"POST",body:JSON.stringify(d??{})}),getEmails:o=>s.get("emails",()=>i("/emails"),o),previewEmails:async o=>i("/emails/preview",{method:"POST",body:JSON.stringify(o)}),sendEmails:async o=>{const l=await i("/emails/send",{method:"POST",body:JSON.stringify(o)});return s.invalidate("emails"),s.invalidate(`resource:${o.resourceId}`),l},scheduleEmails:async o=>{const l=await i("/emails/schedule",{method:"POST",body:JSON.stringify(o)});return s.invalidate("emails"),l},cancelEmailCampaign:async o=>{const l=await i(`/emails/campaigns/${encodeURIComponent(o)}`,{method:"DELETE"});return s.invalidate("emails"),l},saveEmailLibraryTemplate:async o=>{const l=await i("/emails/library",{method:"POST",body:JSON.stringify(o)});return s.invalidate("emails"),l},deleteEmailLibraryTemplate:async o=>{const l=await i(`/emails/library/${encodeURIComponent(o)}`,{method:"DELETE"});return s.invalidate("emails"),l},uploadResourceFile:async(o,l,u,d)=>{const h=await qu(u,d);return i(`/resources/${encodeURIComponent(o)}/uploads/${encodeURIComponent(l)}`,{method:"POST",body:JSON.stringify(h)})},uploadResourceFiles:async(o,l,u)=>{const d={files:await Promise.all(u.map(h=>qu(h)))};return i(`/resources/${encodeURIComponent(o)}/uploads/${encodeURIComponent(l)}/bulk`,{method:"POST",body:JSON.stringify(d)})},getGallery:o=>s.get("gallery",()=>i("/gallery"),o),uploadGalleryFile:async(o,l)=>{const u=await qu(o,l),d=await i("/gallery/upload",{method:"POST",body:JSON.stringify(u)});return s.invalidate("gallery"),d},uploadGalleryFiles:async o=>{const l={files:await Promise.all(o.map(d=>qu(d)))},u=await i("/gallery/upload/bulk",{method:"POST",body:JSON.stringify(l)});return s.invalidate("gallery"),u},deleteGalleryItem:async o=>{const l=await i(`/gallery/${encodeURIComponent(o)}`,{method:"DELETE"});return s.invalidate("gallery"),l},getFonts:o=>s.get("fonts",()=>i("/fonts"),o),getPublicFonts:async o=>{const l=o?.ids?.map(g=>g.trim()).filter(Boolean),u=l?.length?`?ids=${l.map(g=>encodeURIComponent(g)).join(",")}`:"",d=l?.length?`public:fonts:${[...l].sort().join(",")}`:"public:fonts";return(await s.get(d,()=>i(`/public/fonts${u}`),o)).items},uploadFontFile:async(o,l,u)=>{const d={...await qu(o,u),...l?.family?{family:l.family}:{},...l?.label?{label:l.label}:{},...l?.weight!=null?{weight:l.weight}:{}},h=await i("/fonts/upload",{method:"POST",body:JSON.stringify(d)});return s.invalidate("fonts"),s.invalidate("public:fonts"),h},importGoogleFont:async o=>{const l=await i("/fonts/import-google",{method:"POST",body:JSON.stringify(o)});return s.invalidate("fonts"),s.invalidate("public:fonts"),l},deleteFontItem:async o=>{const l=await i(`/fonts/${encodeURIComponent(o)}`,{method:"DELETE"});return s.invalidate("fonts"),s.invalidate("public:fonts"),l},getConfig:(o,l)=>s.get(`config:${o}`,()=>i(`/configs/${encodeURIComponent(o)}`),l),setConfig:async(o,l)=>{const u=await i(`/configs/${encodeURIComponent(o)}`,{method:"PUT",body:JSON.stringify(l)}),d={id:u.id,label:u.label,schema:u.schema??{},environment:u.environment,value:u.value,...u.etag?{etag:u.etag}:{},...u.draftRevisionId?{draftRevisionId:u.draftRevisionId}:{},...u.revisionsEnabled!=null?{revisionsEnabled:u.revisionsEnabled}:{}};return s.set(`config:${o}`,d),s.invalidate("controls"),s.invalidate("public:controls"),s.invalidate("public:fonts"),s.invalidate(`revisions:${o}`),d},listAudit:o=>{const l=new URLSearchParams;o?.limit!=null&&Number.isFinite(o.limit)&&l.set("limit",String(o.limit)),o?.cursor&&l.set("cursor",o.cursor),o?.targetType&&l.set("targetType",o.targetType),o?.targetId&&l.set("targetId",o.targetId);const u=l.toString();return s.get(`audit${u?`?${u}`:""}`,()=>i(`/audit${u?`?${u}`:""}`),o)},listRevisions:(o,l)=>s.get(`revisions:${o}`,()=>i(`/configs/${encodeURIComponent(o)}/revisions`),l),getRevision:(o,l,u)=>s.get(`revision:${o}:${l}`,()=>i(`/configs/${encodeURIComponent(o)}/revisions/${encodeURIComponent(l)}`),u),saveRevision:async(o,l)=>{const u=await i(`/configs/${encodeURIComponent(o)}/revisions`,{method:"POST",body:JSON.stringify(l)});return s.invalidate(`revisions:${o}`),s.invalidate(`config:${o}`),u},publishRevision:async(o,l)=>{const u=await i(`/configs/${encodeURIComponent(o)}/revisions/${encodeURIComponent(l)}/publish`,{method:"POST",body:JSON.stringify({})});return s.invalidate(`revisions:${o}`),s.invalidate(`config:${o}`),s.invalidate("controls"),u},restoreRevision:async(o,l)=>{const u=await i(`/configs/${encodeURIComponent(o)}/revisions/${encodeURIComponent(l)}/restore`,{method:"POST",body:JSON.stringify({})});return s.invalidate(`revisions:${o}`),s.invalidate(`config:${o}`),u},getHealth:o=>s.get("health",()=>i("/health"),o),listJobs:o=>s.get("jobs",()=>i("/jobs"),o),getJob:(o,l)=>s.get(`job:${o}`,()=>i(`/jobs/${encodeURIComponent(o)}`),l),getSyncPlan:o=>{const l=new URLSearchParams;l.set("from",o.from);for(const u of o.to)l.append("to",u);return o.targets?.length&&l.set("targets",o.targets.join(",")),i(`/environments/sync/plan?${l.toString()}`)},runSync:async o=>{const l=await i("/environments/sync/run",{method:"POST",body:JSON.stringify(o)});return s.invalidate(),l},invalidateCache:o=>s.invalidate(o)}}function Aw(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var hl=Aw();function $M(t){hl=t}var gd={exec:()=>null};function St(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(ar.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var ar={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")},iH=/^(?:[ \t]*(?:\n|$))+/,oH=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,aH=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,uf=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,lH=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Rw=/(?:[*+-]|\d{1,9}[.)])/,BM=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,VM=St(BM).replace(/bull/g,Rw).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(),cH=St(BM).replace(/bull/g,Rw).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(),Nw=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,uH=/^[^\n]+/,Mw=/(?!\s*\])(?:\\.|[^\[\]\\])+/,dH=St(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Mw).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),fH=St(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Rw).getRegex(),cg="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",Ow=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,hH=St("^ {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",Ow).replace("tag",cg).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),HM=St(Nw).replace("hr",uf).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",cg).getRegex(),pH=St(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",HM).getRegex(),jw={blockquote:pH,code:oH,def:dH,fences:aH,heading:lH,hr:uf,html:hH,lheading:VM,list:fH,newline:iH,paragraph:HM,table:gd,text:uH},n_=St("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",uf).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",cg).getRegex(),mH={...jw,lheading:cH,table:n_,paragraph:St(Nw).replace("hr",uf).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",n_).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",cg).getRegex()},gH={...jw,html:St(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ow).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:gd,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:St(Nw).replace("hr",uf).replace("heading",` *#{1,6} *[^
|
|
10
|
+
]`).replace("lheading",VM).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},yH=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,bH=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,UM=/^( {2,}|\\)\n(?!\s*$)/,vH=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ug=/[\p{P}\p{S}]/u,Dw=/[\s\p{P}\p{S}]/u,FM=/[^\s\p{P}\p{S}]/u,xH=St(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Dw).getRegex(),qM=/(?!~)[\p{P}\p{S}]/u,wH=/(?!~)[\s\p{P}\p{S}]/u,SH=/(?:[^\s\p{P}\p{S}]|~)/u,kH=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,GM=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,CH=St(GM,"u").replace(/punct/g,ug).getRegex(),EH=St(GM,"u").replace(/punct/g,qM).getRegex(),WM="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",TH=St(WM,"gu").replace(/notPunctSpace/g,FM).replace(/punctSpace/g,Dw).replace(/punct/g,ug).getRegex(),_H=St(WM,"gu").replace(/notPunctSpace/g,SH).replace(/punctSpace/g,wH).replace(/punct/g,qM).getRegex(),AH=St("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,FM).replace(/punctSpace/g,Dw).replace(/punct/g,ug).getRegex(),RH=St(/\\(punct)/,"gu").replace(/punct/g,ug).getRegex(),NH=St(/^<(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(),MH=St(Ow).replace("(?:-->|$)","-->").getRegex(),OH=St("^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",MH).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Wp=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,jH=St(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Wp).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),KM=St(/^!?\[(label)\]\[(ref)\]/).replace("label",Wp).replace("ref",Mw).getRegex(),ZM=St(/^!?\[(ref)\](?:\[\])?/).replace("ref",Mw).getRegex(),DH=St("reflink|nolink(?!\\()","g").replace("reflink",KM).replace("nolink",ZM).getRegex(),Iw={_backpedal:gd,anyPunctuation:RH,autolink:NH,blockSkip:kH,br:UM,code:bH,del:gd,emStrongLDelim:CH,emStrongRDelimAst:TH,emStrongRDelimUnd:AH,escape:yH,link:jH,nolink:ZM,punctuation:xH,reflink:KM,reflinkSearch:DH,tag:OH,text:vH,url:gd},IH={...Iw,link:St(/^!?\[(label)\]\((.*?)\)/).replace("label",Wp).getRegex(),reflink:St(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Wp).getRegex()},V0={...Iw,emStrongRDelimAst:_H,emStrongLDelim:EH,url:St(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},LH={...V0,br:St(UM).replace("{2,}","*").getRegex(),text:St(V0.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Ph={normal:jw,gfm:mH,pedantic:gH},Gu={normal:Iw,gfm:V0,breaks:LH,pedantic:IH},PH={"&":"&","<":"<",">":">",'"':""","'":"'"},r_=t=>PH[t];function Vs(t,e){if(e){if(ar.escapeTest.test(t))return t.replace(ar.escapeReplace,r_)}else if(ar.escapeTestNoEncode.test(t))return t.replace(ar.escapeReplaceNoEncode,r_);return t}function s_(t){try{t=encodeURI(t).replace(ar.percentDecode,"%")}catch{return null}return t}function i_(t,e){const n=t.replace(ar.findPipe,(i,o,l)=>{let u=!1,d=o;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),r=n.split(ar.splitPipe);let s=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(;s<r.length;s++)r[s]=r[s].trim().replace(ar.slashPipe,"|");return r}function Wu(t,e,n){const r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function zH(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 o_(t,e,n,r,s){const i=e.href,o=e.title||null,l=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;const u={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,u}function $H(t,e,n){const r=t.match(n.other.indentCodeCompensation);if(r===null)return e;const s=r[1];return e.split(`
|
|
11
|
+
`).map(i=>{const o=i.match(n.other.beginningSpace);if(o===null)return i;const[l]=o;return l.length>=s.length?i.slice(s.length):i}).join(`
|
|
12
|
+
`)}var Kp=class{options;rules;lexer;constructor(t){this.options=t||hl}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:Wu(n,`
|
|
13
|
+
`)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],r=$H(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=Wu(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:Wu(e[0],`
|
|
14
|
+
`)}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){let n=Wu(e[0],`
|
|
15
|
+
`).split(`
|
|
16
|
+
`),r="",s="";const i=[];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 d=l.join(`
|
|
17
|
+
`),h=d.replace(this.rules.other.blockquoteSetextReplace,`
|
|
18
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
19
|
+
${d}`:d,s=s?`${s}
|
|
20
|
+
${h}`:h;const g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=g,n.length===0)break;const y=i.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){const b=y,x=b.raw+`
|
|
21
|
+
`+n.join(`
|
|
22
|
+
`),S=this.blockquote(x);i[i.length-1]=S,r=r.substring(0,r.length-b.raw.length)+S.raw,s=s.substring(0,s.length-b.text.length)+S.text;break}else if(y?.type==="list"){const b=y,x=b.raw+`
|
|
23
|
+
`+n.join(`
|
|
24
|
+
`),S=this.list(x);i[i.length-1]=S,r=r.substring(0,r.length-y.raw.length)+S.raw,s=s.substring(0,s.length-b.raw.length)+S.raw,n=x.substring(i.at(-1).raw.length).split(`
|
|
25
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim();const r=n.length>1,s={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 i=this.rules.other.listItemRegex(n);let o=!1;for(;t;){let u=!1,d="",h="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;d=e[0],t=t.substring(d.length);let g=e[2].split(`
|
|
26
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,C=>" ".repeat(3*C.length)),y=t.split(`
|
|
27
|
+
`,1)[0],b=!g.trim(),x=0;if(this.options.pedantic?(x=2,h=g.trimStart()):b?x=e[1].length+1:(x=e[2].search(this.rules.other.nonSpaceChar),x=x>4?1:x,h=g.slice(x),x+=e[1].length),b&&this.rules.other.blankLine.test(y)&&(d+=y+`
|
|
28
|
+
`,t=t.substring(y.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),N=this.rules.other.htmlBeginRegex(x);for(;t;){const M=t.split(`
|
|
29
|
+
`,1)[0];let O;if(y=M,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),O=y):O=y.replace(this.rules.other.tabCharGlobal," "),R.test(y)||_.test(y)||N.test(y)||C.test(y)||A.test(y))break;if(O.search(this.rules.other.nonSpaceChar)>=x||!y.trim())h+=`
|
|
30
|
+
`+O.slice(x);else{if(b||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(g)||_.test(g)||A.test(g))break;h+=`
|
|
31
|
+
`+y}!b&&!y.trim()&&(b=!0),d+=M+`
|
|
32
|
+
`,t=t.substring(M.length+1),g=O.slice(x)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(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,""))),s.items.push({type:"list_item",raw:d,task:!!S,checked:k,loose:!1,text:h,tokens:[]}),s.raw+=d}const l=s.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let u=0;u<s.items.length;u++)if(this.lexer.state.top=!1,s.items[u].tokens=this.lexer.blockTokens(s.items[u].text,[]),!s.loose){const d=s.items[u].tokens.filter(g=>g.type==="space"),h=d.length>0&&d.some(g=>this.rules.other.anyLine.test(g.raw));s.loose=h}if(s.loose)for(let u=0;u<s.items.length;u++)s.items[u].loose=!0;return s}}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"):"",s=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:s}}}table(t){const e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const n=i_(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
33
|
+
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(const o of r)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<n.length;o++)i.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:i.align[o]});for(const o of s)i.rows.push(i_(o,i.header.length).map((l,u)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[u]})));return i}}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 i=Wu(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{const i=zH(e[2],"()");if(i===-2)return;if(i>-1){const l=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){const i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=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)),o_(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.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," "),s=e[r.toLowerCase()];if(!s){const i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return o_(n,s,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 i=[...r[0]].length-1;let o,l,u=i,d=0;const h=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*t.length+i);(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])&&i%3&&!((i+l)%3)){d+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+d);const g=[...r[0]][0].length,y=t.slice(0,i+r.index+g+l);if(Math.min(i,l)%2){const x=y.slice(1,-1);return{type:"em",raw:y,text:x,tokens:this.lexer.inlineTokens(x)}}const b=y.slice(2,-2);return{type:"strong",raw:y,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),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(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 s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==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}}}},Di=class H0{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||hl,this.options.tokenizer=this.options.tokenizer||new Kp,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:ar,block:Ph.normal,inline:Gu.normal};this.options.pedantic?(n.block=Ph.pedantic,n.inline=Gu.pedantic):this.options.gfm&&(n.block=Ph.gfm,this.options.breaks?n.inline=Gu.breaks:n.inline=Gu.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ph,inline:Gu}}static lex(e,n){return new H0(n).lex(e)}static lexInline(e,n){return new H0(n).inlineTokens(e)}lex(e){e=e.replace(ar.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(ar.tabCharGlobal," ").replace(ar.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(o=>(s=o.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);const o=n.at(-1);s.raw.length===1&&o!==void 0?o.raw+=`
|
|
36
|
+
`:n.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);const o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=`
|
|
37
|
+
`+s.raw,o.text+=`
|
|
38
|
+
`+s.text,this.inlineQueue.at(-1).src=o.text):n.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);const o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=`
|
|
39
|
+
`+s.raw,o.text+=`
|
|
40
|
+
`+s.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),n.push(s);continue}let i=e;if(this.options.extensions?.startBlock){let o=1/0;const l=e.slice(1);let u;this.options.extensions.startBlock.forEach(d=>{u=d.call({lexer:this},l),typeof u=="number"&&u>=0&&(o=Math.min(o,u))}),o<1/0&&o>=0&&(i=e.substring(0,o+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){const o=n.at(-1);r&&o?.type==="paragraph"?(o.raw+=`
|
|
41
|
+
`+s.raw,o.text+=`
|
|
42
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s),r=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);const o=n.at(-1);o?.type==="text"?(o.raw+=`
|
|
43
|
+
`+s.raw,o.text+=`
|
|
44
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s);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,s=null;if(this.tokens.links){const l=Object.keys(this.tokens.links);if(l.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)l.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,o="";for(;e;){i||(o=""),i=!1;let l;if(this.options.extensions?.inline?.some(d=>(l=d.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 d=n.at(-1);l.type==="text"&&d?.type==="text"?(d.raw+=l.raw,d.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 d=1/0;const h=e.slice(1);let g;this.options.extensions.startInline.forEach(y=>{g=y.call({lexer:this},h),typeof g=="number"&&g>=0&&(d=Math.min(d,g))}),d<1/0&&d>=0&&(u=e.substring(0,d+1))}if(l=this.tokenizer.inlineText(u)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(o=l.raw.slice(-1)),i=!0;const d=n.at(-1);d?.type==="text"?(d.raw+=l.raw,d.text+=l.text):n.push(l);continue}if(e){const d="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return n}},zd=class{options;parser;constructor(t){this.options=t||hl}space(t){return""}code({text:t,lang:e,escaped:n}){const r=(e||"").match(ar.notSpaceStart)?.[0],s=t.replace(ar.endingNewline,"")+`
|
|
45
|
+
`;return r?'<pre><code class="language-'+Vs(r)+'">'+(n?s:Vs(s,!0))+`</code></pre>
|
|
46
|
+
`:"<pre><code>"+(n?s:Vs(s,!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 s=e?"ol":"ul",i=e&&n!==1?' start="'+n+'"':"";return"<"+s+i+`>
|
|
52
|
+
`+r+"</"+s+`>
|
|
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+" "+Vs(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 s=0;s<t.header.length;s++)n+=this.tablecell(t.header[s]);e+=this.tablerow({text:n});let r="";for(let s=0;s<t.rows.length;s++){const i=t.rows[s];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[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>${Vs(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),s=s_(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+Vs(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));const s=s_(t);if(s===null)return Vs(n);t=s;let i=`<img src="${t}" alt="${n}"`;return e&&(i+=` title="${Vs(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Vs(t.text)}},Lw=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""}},Ii=class U0{options;renderer;textRenderer;constructor(e){this.options=e||hl,this.options.renderer=this.options.renderer||new zd,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Lw}static parse(e,n){return new U0(n).parse(e)}static parseInline(e,n){return new U0(n).parseInline(e)}parse(e,n=!0){let r="";for(let s=0;s<e.length;s++){const i=e[s];if(this.options.extensions?.renderers?.[i.type]){const l=i,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=i;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(;s+1<e.length&&e[s+1].type==="text";)l=e[++s],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 s=0;s<e.length;s++){const i=e[s];if(this.options.extensions?.renderers?.[i.type]){const l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=l||"";continue}}const o=i;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}},Tp=class{options;block;constructor(t){this.options=t||hl}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?Di.lex:Di.lexInline}provideParser(){return this.block?Ii.parse:Ii.parseInline}},YM=class{defaults=Aw();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ii;Renderer=zd;TextRenderer=Lw;Lexer=Di;Tokenizer=Kp;Hooks=Tp;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 s=r;for(const i of s.header)n=n.concat(this.walkTokens(i.tokens,e));for(const i of s.rows)for(const o of i)n=n.concat(this.walkTokens(o.tokens,e));break}case"list":{const s=r;n=n.concat(this.walkTokens(s.items,e));break}default:{const s=r;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>{const o=s[i].flat(1/0);n=n.concat(this.walkTokens(o,e))}):s.tokens&&(n=n.concat(this.walkTokens(s.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(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){const i=e.renderers[s.name];i?e.renderers[s.name]=function(...o){let l=s.renderer.apply(this,o);return l===!1&&(l=i.apply(this,o)),l}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){const s=this.defaults.renderer||new zd(this.defaults);for(const i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;const o=i,l=n.renderer[o],u=s[o];s[o]=(...d)=>{let h=l.apply(s,d);return h===!1&&(h=u.apply(s,d)),h||""}}r.renderer=s}if(n.tokenizer){const s=this.defaults.tokenizer||new Kp(this.defaults);for(const i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;const o=i,l=n.tokenizer[o],u=s[o];s[o]=(...d)=>{let h=l.apply(s,d);return h===!1&&(h=u.apply(s,d)),h}}r.tokenizer=s}if(n.hooks){const s=this.defaults.hooks||new Tp;for(const i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;const o=i,l=n.hooks[o],u=s[o];Tp.passThroughHooks.has(i)?s[o]=d=>{if(this.defaults.async)return Promise.resolve(l.call(s,d)).then(g=>u.call(s,g));const h=l.call(s,d);return u.call(s,h)}:s[o]=(...d)=>{let h=l.apply(s,d);return h===!1&&(h=u.apply(s,d)),h}}r.hooks=s}if(n.walkTokens){const s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(o){let l=[];return l.push(i.call(this,o)),s&&(l=l.concat(s.call(this,o))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Di.lex(t,e??this.defaults)}parser(t,e){return Ii.parse(t,e??this.defaults)}parseMarkdown(t){return(n,r)=>{const s={...r},i={...this.defaults,...s},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&s.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"));i.hooks&&(i.hooks.options=i,i.hooks.block=t);const l=i.hooks?i.hooks.provideLexer():t?Di.lex:Di.lexInline,u=i.hooks?i.hooks.provideParser():t?Ii.parse:Ii.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(n):n).then(d=>l(d,i)).then(d=>i.hooks?i.hooks.processAllTokens(d):d).then(d=>i.walkTokens?Promise.all(this.walkTokens(d,i.walkTokens)).then(()=>d):d).then(d=>u(d,i)).then(d=>i.hooks?i.hooks.postprocess(d):d).catch(o);try{i.hooks&&(n=i.hooks.preprocess(n));let d=l(n,i);i.hooks&&(d=i.hooks.processAllTokens(d)),i.walkTokens&&this.walkTokens(d,i.walkTokens);let h=u(d,i);return i.hooks&&(h=i.hooks.postprocess(h)),h}catch(d){return o(d)}}}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>"+Vs(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Xa=new YM;function Ot(t,e){return Xa.parse(t,e)}Ot.options=Ot.setOptions=function(t){return Xa.setOptions(t),Ot.defaults=Xa.defaults,$M(Ot.defaults),Ot};Ot.getDefaults=Aw;Ot.defaults=hl;Ot.use=function(...t){return Xa.use(...t),Ot.defaults=Xa.defaults,$M(Ot.defaults),Ot};Ot.walkTokens=function(t,e){return Xa.walkTokens(t,e)};Ot.parseInline=Xa.parseInline;Ot.Parser=Ii;Ot.parser=Ii.parse;Ot.Renderer=zd;Ot.TextRenderer=Lw;Ot.Lexer=Di;Ot.lexer=Di.lex;Ot.Tokenizer=Kp;Ot.Hooks=Tp;Ot.parse=Ot;Ot.options;Ot.setOptions;Ot.use;Ot.walkTokens;Ot.parseInline;Ii.parse;Di.lex;function Ku(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function a_(t){const e=t.trim();return e?e.startsWith("//")?`https:${e}`:/^(https?:|mailto:|\/|#)/i.test(e)?e:null:null}class BH extends zd{html(){return""}link({href:e,title:n,tokens:r}){const s=this.parser.parseInline(r),i=a_(e);if(!i)return s;const o=n?` title="${Ku(n)}"`:"";return`<a href="${Ku(i)}"${o} rel="noopener noreferrer">${s}</a>`}image({href:e,title:n,text:r}){const s=a_(e);if(!s)return"";const i=n?` title="${Ku(n)}"`:"";return`<img src="${Ku(s)}" alt="${Ku(r)}"${i} loading="lazy" />`}}new YM({gfm:!0,breaks:!1,renderer:new BH});const VH="vertebrPreview",HH="vertebrControl",XM="vertebr",UH="vertebr:preview-draft",FH="vertebr:preview-ready";function JM(t,e={}){const n=e.origin??(typeof window<"u"?window.location.origin:""),r=t.trim()||"/",s=new URL((r.startsWith("http"),r),n||"http://localhost");return s.searchParams.set(VH,"1"),e.controlId?.trim()&&s.searchParams.set(HH,e.controlId.trim()),n?s.toString():`${s.pathname}${s.search}${s.hash}`}function qH(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function GH(t){return qH(t)?t.source===XM&&t.type===FH:!1}function QM(t,e,n,r="*"){if(!t||!e)return;const s={source:XM,type:UH,controlId:e,value:n};t.postMessage(s,r)}function eO(t,e={}){if(typeof window>"u")return()=>{};const n=e.allowedOrigins?.filter(Boolean)??[],r=s=>{n.length>0&&!n.includes(s.origin)||GH(s.data)&&t(s.source)};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)}const l_=[{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 WH(t){switch(t){case"woff2":return"woff2";case"woff":return"woff";default:return"truetype"}}function tO(t){return(t.files??[]).map(e=>`@font-face{font-family:"${t.family.replace(/"/g,'\\"')}";src:url("${e.url}") format("${WH(e.format)}");font-weight:${e.weight};font-style:${e.style};font-display:swap;}`).join("")}function KH(t){switch(t){case"woff2":return"woff2";case"woff":return"woff";default:return"ttf"}}function ZH(t,e,n){const r=t.replace(/\/$/,""),s=n.style==="italic"?"-italic":"",i=KH(n.format);return`${r}/public/fonts/${encodeURIComponent(e)}/${n.weight}${s}.${i}`}function YH(t,e){return t.map(n=>({...n,files:(n.files??[]).map(r=>({...r,url:ZH(e,n.id,r)}))}))}const XH="vertebr:theme";function JH(t){try{const e=localStorage.getItem(t);if(e==="light"||e==="dark")return e}catch{}return null}function QH(t,e){try{localStorage.setItem(t,e)}catch{}}function eU(t){document.documentElement.setAttribute("data-vb-theme",t)}function tU(t=XH){const[e,n]=E.useState(()=>JH(t)??"dark");E.useEffect(()=>{eU(e),QH(t,e)},[e,t]);const r=E.useCallback(i=>{n(i)},[]),s=E.useCallback(()=>{n(i=>i==="dark"?"light":"dark")},[]);return{theme:e,setTheme:r,toggleTheme:s}}function Zp(t,e){const n=t?.capabilities;return!n?.length||n.includes("*")?!0:n.includes(e)}const nO=[{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"}],nU="14d",rU=new Set(nO.map(t=>t.id));function sU(t){return t&&rU.has(t)?t:nU}function cs(t){return{width:18,height:18,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,...t}}function iU(t){return m.jsx("svg",{...cs(t),children:m.jsx("path",{d:"M3 8.5 10 2.5l7 6v8.5a1 1 0 0 1-1 1h-4.5v-5H8.5v5H4a1 1 0 0 1-1-1V8.5z"})})}function oU(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("path",{d:"M3 6.5 10 2.5l7 4v9H3v-9z"}),m.jsx("path",{d:"M7 11.5h6M7 14h4"})]})}function aU(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("rect",{x:"2.5",y:"4.5",width:"15",height:"11",rx:"1.5"}),m.jsx("path",{d:"m3.5 13 3.5-3.5 2.5 2.5L12.5 9l4 4.5"}),m.jsx("circle",{cx:"7",cy:"7.5",r:"1",fill:"currentColor",stroke:"none"})]})}function lU(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("path",{d:"M5 16.5V5.5h10M7.5 16.5V9h5v7.5"}),m.jsx("path",{d:"M7 5.5h6"})]})}function cU(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("rect",{x:"2.5",y:"4.5",width:"15",height:"11",rx:"1.5"}),m.jsx("path",{d:"m3.5 6.5 6.5 4.5 3.5 2.5 6.5-2.5 6.5 4.5"})]})}function uU(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("path",{d:"M6 3.5h5.5L16 8v8.5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-12a1 1 0 0 1 1-1z"}),m.jsx("path",{d:"M11.5 3.5V8H16"})]})}function dU(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("circle",{cx:"10",cy:"10",r:"2.25"}),m.jsx("path",{d:"M10 2.5v2M10 15.5v2M3.5 10h2M14.5 10h2M5.4 5.4l1.4 1.4M13.2 13.2l1.4 1.4M5.4 14.6l1.4-1.4M13.2 6.8l1.4-1.4"})]})}function fU(t){return m.jsx("svg",{...cs(t),children:m.jsx("path",{d:"M4 16.5V12M8 16.5V8M12 16.5V10M16 16.5V5"})})}function rO(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("circle",{cx:"9",cy:"9",r:"4.75"}),m.jsx("path",{d:"M13 13l3.5 3.5"})]})}function Pw(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("path",{d:"M14.5 7.2A6 6 0 0 0 5.2 8.5"}),m.jsx("path",{d:"M5 5.5v3.2h3.2"}),m.jsx("path",{d:"M5.5 12.8A6 6 0 0 0 14.8 11.5"}),m.jsx("path",{d:"M15 14.5v-3.2h-3.2"})]})}function hU(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("path",{d:"M4 6.5h12"}),m.jsx("path",{d:"M4 10h12"}),m.jsx("path",{d:"M4 13.5h12"})]})}function c_(t){return m.jsxs("svg",{...cs(t),children:[m.jsx("path",{d:"M8 3.5h4v4H8z"}),m.jsx("path",{d:"M3.5 8h4v4h-4z"}),m.jsx("path",{d:"M12.5 8h4v4h-4z"}),m.jsx("path",{d:"M8 12.5h4v4H8z"})]})}function ys(t){return t==="overview"?iU:t==="audit"?fU:t.startsWith("resource:")?oU:t==="gallery"?aU:t==="fonts"?lU:t==="emails"?cU:t==="sync"?Pw:t==="addons:overview"||t.startsWith("addon:")?c_:t.startsWith("config:")?uU:dU}function pU(t){const e=[];t.metrics&&e.push({id:"overview",label:t.metrics.label,group:t.metrics.group??"Home",hint:"Overview and metrics",selection:{kind:"overview"}}),t.audit&&e.push({id:"audit",label:t.audit.label,group:t.audit.group??"Analytics",hint:"Audit log",selection:{kind:"audit"}});for(const n of t.resources)e.push({id:`resource:${n.id}`,label:n.label,group:n.group??"Resources",hint:"Resource table",selection:{kind:"resource",id:n.id}});t.gallery&&e.push({id:"gallery",label:t.gallery.label,group:t.gallery.group??"Resources",hint:"Media library",selection:{kind:"gallery"}}),t.fontLibrary&&e.push({id:"fonts",label:t.fontLibrary.label,group:t.fontLibrary.group??"Resources",hint:"Font library",selection:{kind:"fontLibrary"}}),t.emails&&(e.push({id:"emails:compose",label:"Compose email",group:t.emails.group??"Growth",hint:t.emails.label,selection:{kind:"emails",tab:"compose"}}),e.push({id:"emails:templates",label:"Email templates",group:t.emails.group??"Growth",hint:t.emails.label,selection:{kind:"emails",tab:"templates"}}),e.push({id:"emails:activity",label:"Email activity",group:t.emails.group??"Growth",hint:t.emails.label,selection:{kind:"emails",tab:"activity"}})),t.addons?.length&&e.push({id:"addons:overview",label:"Browse add-ons",group:"Add-ons",hint:"Preview and configure storefront features",selection:{kind:"addons"}});for(const n of t.addons??[])e.push({id:`addon:${n.id}`,label:n.label,group:n.group??"Add-ons",hint:n.description??"Storefront add-on",selection:{kind:"addon",id:n.id}});for(const n of t.configs){const r=n.section==="page"?"Pages":"Config";e.push({id:`config:${n.id}`,label:n.label,group:n.group??r,hint:n.section==="page"?"Page content":"Settings",selection:{kind:"config",id:n.id}})}return t.sync?.enabled&&e.push({id:"sync",label:"Sync environments",group:"Settings",hint:"Copy content between environments",selection:{kind:"sync"}}),e}function mU(t,e){const n=e.trim().toLowerCase();return n?t.filter(r=>[r.label,r.group,r.hint??"",r.id].join(" ").toLowerCase().includes(n)):t}function gU({catalog:t,onClose:e,onSelect:n}){const r=E.useRef(null),[s,i]=E.useState(""),[o,l]=E.useState(0),u=E.useMemo(()=>pU(t),[t]),d=E.useMemo(()=>mU(u,s),[u,s]);E.useEffect(()=>{r.current?.focus()},[]),E.useEffect(()=>{l(0)},[s]),E.useEffect(()=>{const b=x=>{if(x.key==="Escape"){x.preventDefault(),e();return}if(d.length!==0){if(x.key==="ArrowDown")x.preventDefault(),l(S=>(S+1)%d.length);else if(x.key==="ArrowUp")x.preventDefault(),l(S=>(S-1+d.length)%d.length);else if(x.key==="Enter"){x.preventDefault();const S=d[o];S&&(n(S.selection),e())}}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[o,e,n,d]);const h=b=>{n(b.selection),e()},g=E.useMemo(()=>{const b=new Map;for(const x of d){const S=b.get(x.group)??[];S.push(x),b.set(x.group,S)}return b},[d]);let y=-1;return m.jsx("div",{className:"vertebr-command-backdrop",role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&e()},children:m.jsxs("div",{className:"vertebr-command",role:"dialog","aria-modal":"true","aria-label":"Search admin",children:[m.jsxs("div",{className:"vertebr-command-input-wrap",children:[m.jsx(rO,{}),m.jsx("input",{ref:r,className:"vertebr-command-input",type:"search",placeholder:"Search pages, resources, settings…",value:s,onChange:b=>i(b.target.value),autoComplete:"off",spellCheck:!1}),m.jsx("kbd",{children:"esc"})]}),m.jsx("div",{className:"vertebr-command-results",role:"listbox",children:d.length===0?m.jsx("div",{className:"vertebr-command-empty",children:"No matches found."}):[...g.entries()].map(([b,x])=>m.jsxs("div",{className:"vertebr-command-group",children:[m.jsx("div",{className:"vertebr-command-group-label",children:b}),x.map(S=>{y+=1;const k=y;return m.jsxs("button",{type:"button",className:"vertebr-command-item",role:"option","aria-selected":k===o,"data-active":k===o||void 0,onMouseEnter:()=>l(k),onClick:()=>h(S),children:[m.jsx("span",{className:"vertebr-command-item-label",children:S.label}),S.hint?m.jsx("span",{className:"vertebr-command-item-hint",children:S.hint}):null]},S.id)})]},b))})]})})}var df=t=>t.type==="checkbox",dg=t=>t.type==="file",Po=t=>t instanceof Date,Vn=t=>t==null;const zw=t=>typeof t=="object";var Qt=t=>!Vn(t)&&!Array.isArray(t)&&zw(t)&&!Po(t),F0=t=>Qt(t)&&t.target?df(t.target)?t.target.checked:dg(t.target)?t.target.files:t.target.value:t,sO=(t,e)=>e.split(".").some((n,r,s)=>!isNaN(Number(n))&&t.has(s.slice(0,r).join("."))),iO=t=>{const e=t.constructor&&t.constructor.prototype;return Qt(e)&&e.hasOwnProperty("isPrototypeOf")},fg=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Jt(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(fg&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(Qt(t)&&iO(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[s]=Jt(t[s]));return r}const To={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},Cs={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},bs={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},oO="root",$w=["__proto__","constructor","prototype"],yU=/^\w*$/;var ff=t=>yU.test(t),Gt=t=>t===void 0;const bU=/[.[\]'"]/;var hg=t=>t.split(bU).filter(Boolean),ke=(t,e,n)=>{if(!e||!Qt(t))return n;const r=ff(e)?[e]:hg(e);if(r.some(i=>$w.includes(i)))return n;const s=r.reduce((i,o)=>Vn(i)?void 0:i[o],t);return Gt(s)||s===t?Gt(t[e])?n:t[e]:s},Lr=t=>typeof t=="boolean",Qn=t=>typeof t=="function",wt=(t,e,n)=>{let r=-1;const s=ff(e)?[e]:hg(e),i=s.length,o=i-1;for(;++r<i;){const l=s[r];let u=n;if(r!==o){const d=t[l];u=Qt(d)||Array.isArray(d)?d:isNaN(+s[r+1])?{}:[]}if($w.includes(l))return;t[l]=u,t=t[l]}};const aO=We.createContext(null);aO.displayName="HookFormControlContext";const Bw=()=>We.useContext(aO);var lO=(t,e,n,r=!0)=>{const s={};for(const i in t)Object.defineProperty(s,i,{get:()=>{const o=i;return e._proxyFormState[o]!==Cs.all&&(e._proxyFormState[o]=!r||Cs.all),n&&(n[o]=!0),t[o]}});return s};const Vw=fg?We.useLayoutEffect:We.useEffect;function vU(t){const e=Bw(),{control:n=e,disabled:r,name:s,exact:i}=t||{},[o,l]=We.useState(()=>({...n._formState,defaultValues:n._defaultValues})),u=We.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Vw(()=>n._subscribe({name:s,formState:u.current,exact:i,callback:d=>{!r&&l({...n._formState,...d,defaultValues:n._defaultValues})}}),[s,r,i]),We.useEffect(()=>{u.current.isValid&&n._setValid(!0)},[n]),We.useMemo(()=>lO(o,n,u.current,!1),[o,n])}var Hn=t=>typeof t=="string",q0=(t,e,n,r,s)=>Hn(t)?(r&&e.watch.add(t),ke(n,t,s)):Array.isArray(t)?t.map(i=>(r&&e.watch.add(i),ke(n,i))):(r&&(e.watchAll=!0),n),G0=t=>Vn(t)||!zw(t);const u_=(t,e)=>e.length===0&&!Array.isArray(t)&&!iO(t);function Pr(t,e,n=new WeakMap){if(t===e)return!0;if(G0(t)||G0(e))return Object.is(t,e);if(Po(t)&&Po(e))return Object.is(t.getTime(),e.getTime());const r=Object.keys(t),s=Object.keys(e);if(r.length!==s.length)return!1;if(u_(t,r)||u_(e,s))return Object.is(t,e);if(!r.length&&Array.isArray(t)!==Array.isArray(e))return!1;const i=n.get(t);if(i&&i.has(e))return!0;if(i)i.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(Po(l)&&Po(u)||(Qt(l)||Array.isArray(l))&&(Qt(u)||Array.isArray(u))?!Pr(l,u,n):!Object.is(l,u))return!1}}return!0}function cO(t){const e=Bw(),{control:n=e,name:r,defaultValue:s,disabled:i,exact:o,compute:l}=t||{},u=We.useRef(s),d=We.useRef(l),h=We.useRef(void 0),g=We.useRef(n),y=We.useRef(r);d.current=l;const[b,x]=We.useState(()=>{const _=n._getWatch(r,u.current);return d.current?d.current(_):_}),S=We.useCallback(_=>{const N=q0(r,n._names,_||n._formValues,!1,u.current);return d.current?d.current(N):N},[n._formValues,n._names,r]),k=We.useCallback(_=>{if(!i){const N=q0(r,n._names,_||n._formValues,!1,u.current);if(d.current){const M=d.current(N);Pr(M,h.current)||(x(M),h.current=M)}else x(N)}},[n._formValues,n._names,i,r]);Vw(()=>((g.current!==n||!Pr(y.current,r))&&(g.current=n,y.current=r,k()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:_=>{k(_.values)}})),[n,o,r,k]),We.useEffect(()=>n._removeUnmounted());const C=g.current!==n,A=y.current,R=We.useMemo(()=>{if(i)return null;const _=!C&&!Pr(A,r);return C||_?S():null},[i,C,r,A,S]);return R!==null?R:b}function xU(t){const e=Bw(),{name:n,disabled:r,control:s=e,shouldUnregister:i,defaultValue:o,exact:l=!0}=t,u=sO(s._names.array,n),d=We.useMemo(()=>ke(s._formValues,n,ke(s._defaultValues,n,o)),[s,n,o]),h=cO({control:s,name:n,defaultValue:d,exact:l}),g=vU({control:s,name:n,exact:l}),y=We.useRef(t),b=We.useRef(null),x=We.useRef(s.register(n,{...t.rules,value:h,...Lr(t.disabled)?{disabled:t.disabled}:{}}));y.current=t;const S=We.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!ke(g.errors,n)},isDirty:{enumerable:!0,get:()=>!!ke(g.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!ke(g.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!ke(g.validatingFields,n)},error:{enumerable:!0,get:()=>ke(g.errors,n)}}),[g,n]),k=We.useCallback(_=>{const N=F0(_);return ke(s._fields,n)||(x.current=s.register(n,{...y.current.rules,value:N})),x.current.onChange({target:{value:F0(_),name:n},type:To.CHANGE})},[n,s]),C=We.useCallback(()=>x.current.onBlur({target:{value:ke(s._formValues,n),name:n},type:To.BLUR}),[n,s._formValues]),A=We.useCallback(_=>{_&&(b.current={focus:()=>Qn(_.focus)&&_.focus(),select:()=>Qn(_.select)&&_.select(),setCustomValidity:M=>Qn(_.setCustomValidity)&&_.setCustomValidity(M),reportValidity:()=>Qn(_.reportValidity)&&_.reportValidity()});const N=ke(s._fields,n);N&&N._f&&_&&(N._f.ref=b.current)},[s._fields,n]),R=We.useMemo(()=>({name:n,value:h,...Lr(r)||g.disabled?{disabled:g.disabled||r}:{},onChange:k,onBlur:C,ref:A}),[n,r,g.disabled,k,C,A,h]);return We.useEffect(()=>{const _=s._options.shouldUnregister||i;x.current=s.register(n,{...y.current.rules,...Lr(y.current.disabled)?{disabled:y.current.disabled}:{}});const N=(M,O)=>{const P=ke(s._fields,M);P&&P._f&&(P._f.mount=O)};if(N(n,!0),_){const M=Jt(ke(i?s._defaultValues:s._options.values||s._defaultValues,n,ke(s._options.defaultValues,n,y.current.defaultValue)));wt(s._defaultValues,n,M),Gt(ke(s._formValues,n))&&wt(s._formValues,n,M)}if(!u&&s.register(n),b.current){const M=ke(s._fields,n);M&&M._f&&(M._f.ref=b.current)}return()=>{(u?_&&!s._state.action:_)?s.unregister(n):N(n,!1)}},[n,s,u,i]),We.useEffect(()=>{s._setDisabledField({disabled:r,name:n})},[r,n,s]),We.useMemo(()=>({field:R,formState:g,fieldState:S}),[R,g,S])}const Bs=t=>t.render(xU(t));var zh=t=>({isOnSubmit:!t||t===Cs.onSubmit,isOnBlur:t===Cs.onBlur,isOnChange:t===Cs.onChange,isOnAll:t===Cs.all,isOnTouch:t===Cs.onTouched}),kv=(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 yd=(t,e,n,r)=>{for(const s of n||Object.keys(t)){if(s==="_f")continue;const i=n?ke(t,s):t[s];if(i){const{_f:o}=i;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],s)&&!r)return!0;if(o.ref&&e(o.ref,o.name)&&!r)return!0;if(yd(i,e))break}else if((Qt(i)||Array.isArray(i))&&yd(i,e))break}}};var d_=(t,e,n)=>{const r=ke(t,n),s=Array.isArray(r)?r:[];return wt(s,oO,e[n]),wt(t,n,s),t},$n=t=>Qt(t)&&!Object.keys(t).length,Yp=t=>{if(!fg)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},Hw=t=>t.type==="radio",Xp=t=>t instanceof RegExp,Uw=(t,e,n,r,s)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:s||!0}}:{};const f_={value:!1,isValid:!1},h_={value:!0,isValid:!0};var uO=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&&!Gt(t[0].attributes.value)?Gt(t[0].value)||t[0].value===""?h_:{value:t[0].value,isValid:!0}:h_:f_}return f_};const p_={isValid:!1,value:null};var dO=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,p_):p_;function m_(t,e,n="validate"){if(Hn(t)||Array.isArray(t)&&t.every(Hn)||Lr(t)&&!t)return{type:n,message:Hn(t)?t:"",ref:e}}var nc=t=>Qt(t)&&!Xp(t)?t:{value:t,message:""},g_=async(t,e,n,r,s,i)=>{const{ref:o,refs:l,required:u,maxLength:d,minLength:h,min:g,max:y,pattern:b,validate:x,name:S,valueAsNumber:k,mount:C}=t._f,A=ke(n,S);if(!C||e.has(S))return{};const R=l?l[0]:o,_=H=>{if(s&&R.reportValidity){const Z=Lr(H)?"":H||"";l?l.forEach(G=>G.setCustomValidity(Z)):R.setCustomValidity(Z),R.reportValidity()}},N={},M=Hw(o),O=df(o),P=M||O,D=(k||dg(o))&&Gt(o.value)&&Gt(A)||Yp(o)&&o.value===""||A===""||Array.isArray(A)&&!A.length,F=Uw.bind(null,S,r,N),te=(H,Z,G,ae=bs.maxLength,z=bs.minLength)=>{const L=H?Z:G;N[S]={type:H?ae:z,message:L,ref:o,...F(H?ae:z,L)}};if(i?!Array.isArray(A)||!A.length:u&&(!P&&(D||Vn(A))||Lr(A)&&!A||O&&!uO(l).isValid||M&&!dO(l).isValid)){const{value:H,message:Z}=Hn(u)?{value:!!u,message:u}:nc(u);if(H&&(N[S]={type:bs.required,message:Z,ref:R,...F(bs.required,Z)},!r))return _(Z),N}if(!D&&(!Vn(g)||!Vn(y))){let H,Z;const G=nc(y),ae=nc(g);if(!Vn(A)&&!isNaN(A)){const z=o.valueAsNumber||A&&+A;Vn(G.value)||(H=z>G.value),Vn(ae.value)||(Z=z<ae.value)}else{const z=o.valueAsDate||new Date(A),L=pe=>new Date(new Date().toDateString()+" "+pe),W=o.type=="time",ce=o.type=="week";Hn(G.value)&&A&&(H=W?L(A)>L(G.value):ce?A>G.value:z>new Date(G.value)),Hn(ae.value)&&A&&(Z=W?L(A)<L(ae.value):ce?A<ae.value:z<new Date(ae.value))}if((H||Z)&&(te(!!H,G.message,ae.message,bs.max,bs.min),!r))return _(N[S].message),N}if((d||h)&&!D&&(Hn(A)||i&&Array.isArray(A))){const H=nc(d),Z=nc(h),G=!Vn(H.value)&&A.length>+H.value,ae=!Vn(Z.value)&&A.length<+Z.value;if((G||ae)&&(te(G,H.message,Z.message),!r))return _(N[S].message),N}if(b&&!D&&Hn(A)){const{value:H,message:Z}=nc(b);if(Xp(H)&&!A.match(H)&&(N[S]={type:bs.pattern,message:Z,ref:o,...F(bs.pattern,Z)},!r))return _(Z),N}if(x){if(Qn(x)){const H=await x(A,n),Z=m_(H,R);if(Z&&(N[S]={...Z,...F(bs.validate,Z.message)},!r))return _(Z.message),N}else if(Qt(x)){let H={};for(const Z in x){if(!$n(H)&&!r)break;const G=m_(await x[Z](A,n),R,Z);G&&(H={...G,...F(Z,G.message)},_(G.message),r&&(N[S]=H))}if(!$n(H)&&(N[S]={ref:R,...H},!r))return N}}return _(!0),N},_p=t=>Array.isArray(t)?t:[t],fO=t=>Array.isArray(t)?t.filter(Boolean):[];function wU(t,e){const n=e.length-1;let r=0;for(;r<n;){if(Vn(t)){t=void 0;break}t=t[e[r]],r++}return t}function SU(t){for(const e in t)if(t.hasOwnProperty(e)&&!Gt(t[e]))return!1;return!0}function un(t,e){if(Hn(e)&&Object.prototype.hasOwnProperty.call(t,e))return delete t[e],t;const n=Array.isArray(e)?e:ff(e)?[e]:hg(e);if(n.some(o=>$w.includes(String(o))))return t;const r=n.length===1?t:wU(t,n),s=n.length-1,i=n[s];return r&&delete r[i],s!==0&&(Qt(r)&&$n(r)||Array.isArray(r)&&SU(r))&&un(t,n.slice(0,-1)),t}const hO=t=>{const e={};for(const n of Object.keys(t))if(zw(t[n])&&t[n]!==null&&!Po(t[n])){const r=hO(t[n]);for(const s of Object.keys(r))e[`${n}.${s}`]=r[s]}else e[n]=t[n];return e},kU=We.createContext(null);kU.displayName="HookFormContext";var y_=()=>{let t=[];return{get observers(){return t},next:s=>{for(const i of t)i.next&&i.next(s)},subscribe:s=>(t.push(s),{unsubscribe:()=>{t=t.filter(i=>i!==s)}}),unsubscribe:()=>{t=[]}}};function pO(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const s=t[r],i=e[r];if(s&&Qt(s)&&i){const o=pO(s,i);Qt(o)&&(n[r]=o)}else t[r]&&(n[r]=i)}return n}var mO=t=>t.type==="select-multiple",CU=t=>Hw(t)||df(t),Cv=t=>Yp(t)&&t.isConnected;function b_(t){return Array.isArray(t)||Qt(t)}function gO(t,e,n="",r=[]){for(const s in t){const i=n?`${n}.${s}`:s,o=t[s];b_(o)&&b_(ke(e,i))?gO(o,e,i,r):r.push(i)}return r}var EU=t=>{for(const e in t)if(Qn(t[e]))return!0;return!1};function yO(t){return Array.isArray(t)||Qt(t)&&!EU(t)}function bO(t){return!!(t&&"_f"in t)}function vO(t){return Array.isArray(t)?!t.some(e=>!Gt(e)):!Object.keys(t).length}function W0(t,e){Array.isArray(t)?t[e]=void 0:delete t[e]}function K0(t,e={},n){for(const r in t){const s=t[r],i=n&&n[r];yO(s)&&(!Array.isArray(s)||!bO(i))?(e[r]=Array.isArray(s)?[]:{},K0(s,e[r],i),vO(e[r])&&W0(e,r)):Gt(s)||(e[r]=!0)}return e}function Ia(t,e,n,r){n||(n=K0(e,{},r));for(const s in t){const i=t[s],o=r&&r[s];yO(i)&&(!Array.isArray(i)||!bO(o))?(Gt(e)||G0(n[s])?n[s]=K0(i,Array.isArray(i)?[]:{},o):Ia(i,Vn(e)?{}:e[s],n[s],o),vO(n[s])&&W0(n,s)):Pr(i,e[s])?W0(n,s):n[s]=!0}return n}var xO=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>Gt(t)?t:e?t===""?NaN:t&&+t:n&&Hn(t)?new Date(t):r?r(t):t;function v_(t){const e=t.ref;return dg(e)?e.files:Hw(e)?dO(t.refs).value:mO(e)?[...e.selectedOptions].map(({value:n})=>n):df(e)?uO(t.refs).value:xO(e.value,t)}var TU=(t,e,n,r)=>{const s={};for(const i of t){const o=ke(e,i);o&&wt(s,i,o._f)}return{criteriaMode:n,names:[...t],fields:s,shouldUseNativeValidation:r}},Zu=t=>Gt(t)?t:Xp(t)?t.source:Qt(t)?Xp(t.value)?t.value.source:t.value:t;const x_="AsyncFunction";var _U=t=>{if(!t||!t.validate)return!1;if(Qn(t.validate))return t.validate.constructor.name===x_;if(Qt(t.validate)){for(const e in t.validate)if(t.validate[e].constructor.name===x_)return!0}return!1},AU=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate);function w_(t,e,n){const r=ke(t,n);if(r||ff(n))return{error:r,name:n};const s=n.split(".");for(;s.length;){const i=s.join("."),o=ke(e,i),l=ke(t,i);if(o&&!Array.isArray(o)&&n!==i)return{name:n};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};s.pop()}return{name:n}}var RU=(t,e,n,r)=>{n(t);const s=Object.keys(t).filter(i=>i!=="name");return!s.length||r&&s.length>=Object.keys(e).length||s.find(i=>e[i]===(!r||Cs.all))},NU=(t,e,n)=>!t||!e||t===e||_p(t).some(r=>r&&(n?r===e||r.startsWith(e+"."):r.startsWith(e)||e.startsWith(r))),MU=(t,e,n,r,s)=>s.isOnAll?!1:!n&&s.isOnTouch?!(e||t):(n?r.isOnBlur:s.isOnBlur)?!t:(n?r.isOnChange:s.isOnChange)?t:!0,OU=(t,e)=>!fO(ke(t,e)).length&&un(t,e);const jU={mode:Cs.onSubmit,reValidateMode:Cs.onChange,shouldFocusError:!0},Ev="form",DU=(t,e)=>{for(const n in t)n in e||delete t[n];Object.assign(t,e)},wO={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function IU(t={}){let e={...jU,...t},n={...Jt(wO),isLoading:Qn(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1},r={},s=Qt(e.defaultValues)||Qt(e.values)?Jt(e.defaultValues||e.values)||{}:{},i=e.shouldUnregister?{}:Jt(s),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={},d={};let h=0,g=zh(e.mode),y=zh(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:y_(),state:y_()};let C=0;const A=e.criteriaMode===Cs.all,R=(I,B)=>U=>{clearTimeout(d[I]),d[I]=setTimeout(B,U)},_=async I=>{if(!o.keepIsValid&&!e.disabled&&(x.isValid||S.isValid||I)){const B=++C;let U;e.resolver?(U=$n((await G()).errors),B===C&&N()):U=await L({fields:r,onlyCheckValid:!0,eventType:To.VALID}),B===C&&U!==n.isValid&&k.state.next({isValid:U})}},N=(I,B)=>{!e.disabled&&(x.isValidating||x.validatingFields||S.isValidating||S.validatingFields)&&((I||Array.from(l.mount)).forEach(U=>{U&&(B?wt(n.validatingFields,U,B):un(n.validatingFields,U))}),k.state.next({validatingFields:n.validatingFields,isValidating:!$n(n.validatingFields)}))},M=()=>{n.dirtyFields=Ia(s,i,void 0,r)},O=(I,B=[],U,se,oe=!0,xe=!0)=>{if(se&&U&&!e.disabled){if(o.action=!0,xe&&Array.isArray(ke(r,I))){const Se=U(ke(r,I),se.argA,se.argB);oe&&wt(r,I,Se)}if(xe&&Array.isArray(ke(n.errors,I))){const Se=U(ke(n.errors,I),se.argA,se.argB);oe&&wt(n.errors,I,Se),OU(n.errors,I)}if((x.touchedFields||S.touchedFields)&&xe&&Array.isArray(ke(n.touchedFields,I))){const Se=U(ke(n.touchedFields,I),se.argA,se.argB);oe&&wt(n.touchedFields,I,Se)}(x.dirtyFields||S.dirtyFields)&&M(),k.state.next({name:I,isDirty:ce(I,B),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else wt(i,I,B)},P=(I,B)=>{wt(n.errors,I,B),n.errors={...n.errors},k.state.next({errors:n.errors})},D=I=>{n.errors=I,k.state.next({errors:n.errors,isValid:!1})},F=I=>{const B=ff(I)?[I]:hg(I);let U=i,se=s;for(let oe=0;oe<B.length-1;oe++){const xe=B[oe];if(U=Vn(U)?U:U[xe],se=Vn(se)?se:se[xe],U===null&&se!==null)return!0}return!1},te=(I,B,U,se)=>{const oe=ke(r,I);if(oe){if(F(I))return;const xe=Gt(ke(i,I)),Se=ke(i,I,Gt(U)?ke(s,I):U);Gt(Se)||se&&se.defaultChecked||B?wt(i,I,B?Se:v_(oe._f)):Y(I,Se),o.mount&&!o.action&&(_(),xe&&n.isDirty&&(x.isDirty||S.isDirty)&&(ce()||(n.isDirty=!1,k.state.next({...n}))),t.shouldUnregister&&xe&&!Gt(ke(i,I))&&kv(I,l)&&(o.watch=!0))}},H=(I,B,U,se,oe)=>{let xe=!1,Se=!1;const _e={name:I};if(!e.disabled||se===!0){if(!U||se){const Ve=Pr(ke(s,I),B);(x.isDirty||S.isDirty)&&(Se=n.isDirty,n.isDirty=_e.isDirty=!Ve||ce(),xe=Se!==_e.isDirty),Se=!!ke(n.dirtyFields,I),Ve!==n.isDirty?DU(n.dirtyFields,Ia(s,i,void 0,r)):Ve?un(n.dirtyFields,I):wt(n.dirtyFields,I,!0),_e.dirtyFields=n.dirtyFields,xe=xe||(x.dirtyFields||S.dirtyFields)&&Se!==!Ve}if(U){const Ve=ke(n.touchedFields,I);Ve||(wt(n.touchedFields,I,U),_e.touchedFields=n.touchedFields,xe=xe||(x.touchedFields||S.touchedFields)&&Ve!==U)}xe&&oe&&k.state.next(_e)}return xe?_e:{}},Z=(I,B,U,se)=>{const oe=ke(n.errors,I),xe=(x.isValid||S.isValid)&&Lr(B)&&n.isValid!==B;if(e.delayError&&U?(u[I]=R(I,()=>P(I,U)),u[I](e.delayError)):(clearTimeout(d[I]),delete u[I],U?wt(n.errors,I,U):un(n.errors,I),n.errors={...n.errors}),(U?!Pr(oe,U):oe)||!$n(se)||xe){const Se={...se,...xe&&Lr(B)?{isValid:B}:{},errors:n.errors,name:I};n={...n,...Se},k.state.next(Se)}},G=async I=>(N(I,!0),await e.resolver(i,e.context,TU(I||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),ae=async I=>{const{errors:B}=await G(I);if(N(I),I){for(const U of I){const se=ke(B,U);se?l.array.has(U)&&Qt(se)&&!Object.keys(se).some(oe=>!Number.isNaN(Number(oe)))?d_(n.errors,{[U]:se},U):wt(n.errors,U,se):un(n.errors,U)}n.errors={...n.errors}}else n.errors=B;return B},z=async({name:I,eventType:B})=>{if(t.validate){const U=await t.validate({formValues:i,formState:n,name:I,eventType:B});if(Qt(U))for(const se in U){const oe=U[se];oe&&Ke(`${Ev}.${se}`,{message:Hn(oe.message)?oe.message:"",type:oe.type||bs.validate})}else Hn(U)||!U?Ke(Ev,{message:U||"",type:bs.validate}):Be(Ev);return U}return!0},L=async({fields:I,onlyCheckValid:B,name:U,eventType:se,context:oe={valid:!0,runRootValidation:!1}})=>{if(t.validate&&(oe.runRootValidation=!0,!await z({name:U,eventType:se})&&(oe.valid=!1,B)))return oe.valid;for(const xe in I){const Se=I[xe];if(Se){const{_f:_e,...Ve}=Se;if(_e){const st=l.array.has(_e.name),kt=Se._f&&_U(Se._f),an=x.validatingFields||x.isValidating||S.validatingFields||S.isValidating;kt&&an&&N([_e.name],!0);const Xt=await g_(Se,l.disabled,i,A,e.shouldUseNativeValidation&&!B,st);if(kt&&an&&N([_e.name]),Xt[_e.name]&&(oe.valid=!1,B)||(!B&&(ke(Xt,_e.name)?st?d_(n.errors,Xt,_e.name):wt(n.errors,_e.name,Xt[_e.name]):un(n.errors,_e.name)),t.shouldUseNativeValidation&&Xt[_e.name]))break}!$n(Ve)&&await L({context:oe,onlyCheckValid:B,fields:Ve,name:xe,eventType:se})}}return oe.valid},W=()=>{for(const I of l.unMount){const B=ke(r,I);B&&(B._f.refs?B._f.refs.every(U=>!Cv(U)):!Cv(B._f.ref))&&Vt(I)}l.unMount=new Set},ce=(I,B)=>(I&&B&&wt(i,I,B),!Pr(o.mount?i:s,s)),pe=(I,B,U)=>q0(I,l,{...o.mount?i:Gt(B)?s:Hn(I)?{[I]:B}:B},U,B),$=I=>fO(ke(o.mount?i:s,I,e.shouldUnregister?ke(s,I,[]):[])),Y=(I,B,U={},se=!1,oe=!1)=>{const xe=ke(r,I);let Se=B;if(xe){const _e=xe._f;_e&&(!_e.disabled&&wt(i,I,xO(B,_e)),Se=Yp(_e.ref)&&Vn(B)?"":B,mO(_e.ref)?[..._e.ref.options].forEach(Ve=>Ve.selected=Se.includes(Ve.value)):_e.refs?df(_e.ref)?_e.refs.forEach(Ve=>{(!Ve.defaultChecked||!Ve.disabled)&&(Array.isArray(Se)?Ve.checked=!!Se.find(st=>st===Ve.value):Ve.checked=Se===Ve.value||!!Se)}):_e.refs.forEach(Ve=>Ve.checked=Ve.value===Se):dg(_e.ref)?_e.ref.value="":(_e.ref.value=Se,!_e.ref.type&&!oe&&k.state.next({name:I,values:se?i:Jt(i)})))}(U.shouldDirty||U.shouldTouch)&&H(I,Se,U.shouldTouch,U.shouldDirty,!oe),U.shouldValidate&&le(I,{delayError:U.delayError})},he=(I,B,U,se=!1,oe=!1)=>{l.array.has(I)&&k.array.next({name:I,values:se?i:Jt(i)});for(const xe in B){if(!B.hasOwnProperty(xe))return;const Se=B[xe],_e=I+"."+xe,Ve=ke(r,_e);(l.array.has(I)||Qt(Se)||Ve&&!Ve._f)&&!Po(Se)?he(_e,Se,U,se,oe):Y(_e,Se,U,se,oe)}},be=(I,B,U,se,oe=!1)=>{const xe=ke(r,I),Se=l.array.has(I),_e=se?B:Jt(B),Ve=ke(i,I),st=Pr(Ve,_e);if(st||wt(i,I,_e),Se)k.array.next({name:I,values:se?i:Jt(i)}),(x.isDirty||x.dirtyFields||S.isDirty||S.dirtyFields)&&U.shouldDirty&&(M(),oe||k.state.next({name:I,dirtyFields:n.dirtyFields,isDirty:ce(I,_e)}));else{const kt=Array.isArray(_e)&&!_e.length||$n(_e);!xe||xe._f||Vn(_e)||kt?Y(I,_e,U,se,oe):he(I,_e,U,se,oe)}if(!st&&!oe){const kt=kv(I,l),an=se?i:Jt(i);k.state.next({...kt&&n,name:o.mount||kt?I:void 0,values:an})}},Me=(I,B,U={})=>be(I,B,U,!1),Ce=(I,B={})=>{const U=Qn(I)?I(i):I;if(!Pr(i,U)){i={...i,...U};const se=hO(U);for(const oe of l.mount)oe in se&&be(oe,se[oe],B,!0,!0);k.state.next({...n,name:void 0,type:void 0,...h?{values:i}:{}}),B.shouldValidate&&_()}},He=async I=>{o.mount=!0;const B=I.target;let U=B.name,se=!0;const oe=ke(r,U),xe=Se=>{se=Number.isNaN(Se)||Po(Se)&&isNaN(Se.getTime())||Pr(Se,ke(i,U,Se))};if(oe){let Se,_e;const Ve=B.type?v_(oe._f):F0(I),st=I.type===To.BLUR||I.type===To.FOCUS_OUT,kt=!AU(oe._f)&&!t.validate&&!e.resolver&&!ke(n.errors,U)&&!oe._f.deps,an=kt||MU(st,ke(n.touchedFields,U),n.isSubmitted,y,g),Xt=kv(U,l,st);if(wt(i,U,Ve),st){if(!B||!B.readOnly){oe._f.onBlur&&oe._f.onBlur(I);const mr=u[U];mr&&mr(0)}}else oe._f.onChange&&oe._f.onChange(I);const Wn=H(U,Ve,st),Ur=!$n(Wn)||Xt;if(!st&&k.state.next({name:U,type:I.type,...h?{values:Jt(i)}:{}}),an)return(!kt||!n.isValid)&&(x.isValid||S.isValid)&&(e.mode==="onBlur"?st&&_():st||_()),Ur&&k.state.next({name:U,...Xt?{}:Wn});if(!e.resolver&&t.validate&&await z({name:U,eventType:I.type}),!st&&Xt&&k.state.next({...n}),e.resolver){const{errors:mr}=await G([U]);if(N([U]),xe(Ve),!se){!$n(Wn)&&k.state.next(Wn);return}const ti=w_(n.errors,r,U),fs=w_(mr,r,ti.name||U);Se=fs.error,U=fs.name,_e=$n(mr)}else N([U],!0),Se=(await g_(oe,l.disabled,i,A,e.shouldUseNativeValidation))[U],N([U]),xe(Ve),se&&(Se?_e=!1:(x.isValid||S.isValid)&&(_e=await L({fields:r,onlyCheckValid:!0,name:U,eventType:I.type})));se&&(oe._f.deps&&(!Array.isArray(oe._f.deps)||oe._f.deps.length>0)&&le(oe._f.deps),Z(U,_e,Se,Wn))}},Ee=(I,B)=>{if(ke(n.errors,B)&&I.focus)return I.focus(),1},le=async(I,B={})=>{let U,se;const oe=_p(I);if(e.resolver){const xe=await ae(Gt(I)?I:oe);U=$n(xe),se=I?!oe.some(Se=>ke(xe,Se)):U}else I?(se=(await Promise.all(oe.map(async xe=>{const Se=ke(r,xe);return await L({fields:Se&&Se._f?{[xe]:Se}:Se,eventType:To.TRIGGER})}))).every(Boolean),!(!se&&!n.isValid)&&_()):se=U=await L({fields:r,name:I,eventType:To.TRIGGER});if(B.delayError&&e.delayError&&Hn(I)){const xe=ke(n.errors,I);xe?(un(n.errors,I),u[I]=R(I,()=>P(I,xe)),u[I](e.delayError)):(clearTimeout(d[I]),delete u[I])}return k.state.next({...!Hn(I)||(x.isValid||S.isValid)&&U!==n.isValid?{}:{name:I},...e.resolver||!I?{isValid:U}:{},errors:n.errors}),B.shouldFocus&&!se&&yd(r,Ee,I?oe:l.mount),se},me=(I,B)=>{let U={...o.mount?i:s};return B&&(U=pO(B.dirtyFields?n.dirtyFields:n.touchedFields,U)),Gt(I)?U:Hn(I)?ke(U,I):I.map(se=>ke(U,se))},De=(I,B)=>({invalid:!!ke((B||n).errors,I),isDirty:!!ke((B||n).dirtyFields,I),error:ke((B||n).errors,I),isValidating:!!ke(n.validatingFields,I),isTouched:!!ke((B||n).touchedFields,I)}),Be=I=>{const B=I?_p(I):void 0;B?.forEach(U=>un(n.errors,U)),B?B.forEach(U=>{k.state.next({name:U,errors:n.errors})}):(n.errors={},k.state.next({errors:n.errors}))},Ke=(I,B,U)=>{const se=(ke(r,I,{_f:{}})._f||{}).ref,oe=ke(n.errors,I)||{},{ref:xe,message:Se,type:_e,...Ve}=oe;wt(n.errors,I,{...Ve,...B,ref:se}),k.state.next({name:I,errors:n.errors,isValid:!1}),U&&U.shouldFocus&&se&&se.focus&&se.focus()},mt=(I,B)=>{if(Qn(I)){h++;const{unsubscribe:U}=k.state.subscribe({next:oe=>"values"in oe&&I(oe.values||pe(void 0,B),oe)});let se=!1;return{unsubscribe:()=>{se||(se=!0,h--,U())}}}return pe(I,B,!0)},ht=I=>{var B;const U=!!(!((B=I.formState)===null||B===void 0)&&B.values);U&&h++;const{unsubscribe:se}=k.state.subscribe({next:xe=>{if(NU(I.name,xe.name,I.exact)&&RU(xe,I.formState||x,ds,I.reRenderRoot)){const Se={...i};I.callback({values:Se,...n,...xe,defaultValues:s})}}});if(!U)return se;let oe=!1;return()=>{oe||(oe=!0,h--,se())}},Wt=I=>(o.mount=!0,S={...S,...I.formState},ht({...I,formState:{...b,...I.formState}})),Vt=(I,B={})=>{for(const U of I?_p(I):l.mount)l.mount.delete(U),l.array.delete(U),B.keepValue||(un(r,U),un(i,U)),!B.keepError&&un(n.errors,U),!B.keepDirty&&un(n.dirtyFields,U),!B.keepTouched&&un(n.touchedFields,U),!B.keepIsValidating&&un(n.validatingFields,U),!e.shouldUnregister&&!B.keepDefaultValue&&un(s,U);k.state.next({values:Jt(i)}),k.state.next({...n,...B.keepDirty?{isDirty:ce()}:{}}),!B.keepIsValid&&_()},Yt=({disabled:I,name:B})=>{if(Lr(I)&&o.mount||I||l.disabled.has(B)){const oe=l.disabled.has(B)!==!!I;I?l.disabled.add(B):l.disabled.delete(B),oe&&o.mount&&!o.action&&_()}},kn=(I,B={})=>{let U=ke(r,I);const se=Lr(B.disabled)||Lr(e.disabled),oe=!l.registerName.has(I)&&U&&U._f&&!U._f.mount;return wt(r,I,{...U||{},_f:{...U&&U._f?U._f:{ref:{name:I}},name:I,mount:!0,...B}}),l.mount.add(I),U&&!oe?Yt({disabled:Lr(B.disabled)?B.disabled:e.disabled,name:I}):te(I,!0,B.value),{...se?{disabled:B.disabled||e.disabled}:{},...e.progressive?{required:!!B.required,min:Zu(B.min),max:Zu(B.max),minLength:Zu(B.minLength),maxLength:Zu(B.maxLength),pattern:Zu(B.pattern)}:{},name:I,onChange:He,onBlur:He,ref:xe=>{if(xe){l.registerName.add(I),kn(I,B),l.registerName.delete(I),U=ke(r,I);const Se=Gt(xe.value)&&xe.querySelectorAll&&xe.querySelectorAll("input,select,textarea")[0]||xe,_e=CU(Se),Ve=U._f.refs||[];if(_e?Ve.find(kt=>kt===Se):Se===U._f.ref)return;const st={...U._f};_e?(st.refs=[...Ve.filter(Cv),Se,...Array.isArray(ke(s,I))?[{}]:[]],st.ref={type:Se.type,name:I}):(st.ref=Se,delete st.refs),wt(r,I,{_f:st}),te(I,!1,void 0,Se)}else U=ke(r,I,{}),U._f&&(U._f.mount=!1),(e.shouldUnregister||B.shouldUnregister)&&!(sO(l.array,I)&&o.action)&&l.unMount.add(I)}}},jn=()=>e.shouldFocusError&&!e.shouldUseNativeValidation&&yd(r,Ee,l.mount),Dn=I=>{Lr(I)&&(k.state.next({disabled:I}),yd(r,(B,U)=>{const se=ke(r,U);se&&(B.disabled=se._f.disabled||I,Array.isArray(se._f.refs)&&se._f.refs.forEach(oe=>{oe.disabled=se._f.disabled||I}))},0,!1))},Tr=(I,B)=>async U=>{let se,oe;U&&(U.preventDefault&&U.preventDefault(),U.persist&&U.persist());let xe=Jt(i);if(k.state.next({isSubmitting:!0}),e.resolver){const{errors:Se,values:_e}=await G();N(),n.errors=Se,xe=Jt(_e)}else await L({fields:r,eventType:To.SUBMIT});if(l.disabled.size)for(const Se of l.disabled)un(xe,Se);if(un(n.errors,oO),$n(n.errors)){k.state.next({errors:{}});try{se=await I(xe,U)}catch(Se){oe=Se}}else B&&await B({...n.errors},U),jn(),setTimeout(jn);if(k.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:$n(n.errors)&&!oe,submitCount:n.submitCount+1,errors:n.errors}),oe)throw oe;return se},js=(I,B={})=>{ke(r,I)&&(Gt(B.defaultValue)?Me(I,Jt(ke(s,I))):(Me(I,B.defaultValue),wt(s,I,Jt(B.defaultValue))),B.keepTouched||un(n.touchedFields,I),B.keepDirty||(un(n.dirtyFields,I),n.isDirty=B.defaultValue?ce(I,Jt(ke(s,I))):ce()),B.keepError||(un(n.errors,I),x.isValid&&_()),k.state.next({...n}))},Ht=(I,B={})=>{const U=I?Jt(I):s,se=Jt(U),oe=$n(I),xe=se,Se=r;if(B.keepDefaultValues||(s=U),!B.keepValues){if(B.keepDirtyValues){const _e=new Set([...l.mount,...gO(Ia(s,i,void 0,Se),n.dirtyFields)]);for(const Ve of Array.from(_e)){const st=ke(n.dirtyFields,Ve),kt=ke(i,Ve),an=ke(xe,Ve);st&&!Gt(kt)?wt(xe,Ve,kt):!st&&!Gt(an)&&Me(Ve,an)}}else{if(fg&&Gt(I))for(const _e of l.mount){const Ve=ke(r,_e);if(Ve&&Ve._f){const st=Array.isArray(Ve._f.refs)?Ve._f.refs[0]:Ve._f.ref;if(Yp(st)){const kt=st.closest("form");if(kt){kt.reset();break}}}}if(B.keepFieldsRef)for(const _e of l.mount)Me(_e,ke(xe,_e));else r={}}if(e.shouldUnregister){if(i=B.keepDefaultValues?Jt(s):{},B.keepFieldsRef)for(const _e of l.mount)wt(i,_e,ke(xe,_e))}else i=Jt(xe);k.array.next({values:{...xe}}),k.state.next({name:void 0,type:void 0,values:{...xe}})}l={mount:B.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||!!B.keepIsValid||!!B.keepDirtyValues||!e.shouldUnregister&&!$n(xe),o.watch=!!e.shouldUnregister,o.keepIsValid=!!B.keepIsValid,o.action=!1,B.keepErrors||(n.errors={}),k.state.next({submitCount:B.keepSubmitCount?n.submitCount:0,isDirty:oe?!1:B.keepDirty?n.isDirty:B.keepValues?ce():!!(B.keepDefaultValues&&!Pr(I,s)),isSubmitted:B.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:oe?{}:B.keepDirtyValues?B.keepDefaultValues&&i?Ia(s,i,void 0,Se):n.dirtyFields:B.keepDefaultValues&&I?Ia(s,I,void 0,Se):B.keepDirty?n.dirtyFields:{},touchedFields:B.keepTouched?n.touchedFields:{},errors:B.keepErrors?n.errors:{},isSubmitSuccessful:B.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},pr=(I,B)=>Ht(Qn(I)?I(i):I,{...e.resetOptions,...B}),Gn=(I,B={})=>{const U=ke(r,I),se=U&&U._f;if(se){const oe=se.refs?se.refs[0]:se.ref;oe.focus&&setTimeout(()=>{oe.focus(),B.shouldSelect&&Qn(oe.select)&&oe.select()})}},ds=I=>{const{name:B,type:U,values:se,...oe}=I;n={...n,...oe}},Ie={control:{register:kn,unregister:Vt,getFieldState:De,handleSubmit:Tr,setError:Ke,_subscribe:ht,_runSchema:G,_updateIsValidating:N,_focusError:jn,_getWatch:pe,_getDirty:ce,_setValid:_,_setFieldArray:O,_setDisabledField:Yt,_setErrors:D,_getFieldArray:$,_reset:Ht,_resetDefaultValues:()=>Qn(e.defaultValues)&&e.defaultValues().then(I=>{pr(I,e.resetOptions),k.state.next({isLoading:!1})}),_removeUnmounted:W,_disableForm:Dn,_subjects:k,_proxyFormState:x,get _fields(){return r},get _formValues(){return i},get _state(){return o},set _state(I){o=I},get _defaultValues(){return s},get _names(){return l},set _names(I){l=I},get _formState(){return n},get _options(){return e},set _options(I){e={...e,...I},g=zh(e.mode),y=zh(e.reValidateMode)}},subscribe:Wt,trigger:le,register:kn,handleSubmit:Tr,watch:mt,setValue:Me,setValues:Ce,getValues:me,reset:pr,resetField:js,resetDefaultValues:(I,B={})=>{if(s=Jt(I),!B.keepDirty){const U=Ia(s,i,void 0,r);n.dirtyFields=U,n.isDirty=!$n(U)}B.keepIsValid||_(),k.state.next({...n,defaultValues:s})},clearErrors:Be,unregister:Vt,setError:Ke,setFocus:Gn,getFieldState:De};return{...Ie,formControl:Ie}}function LU(t={}){const e=We.useRef(void 0),n=We.useRef(void 0),r=We.useRef(t.formControl),[s,i]=We.useState(()=>({...Jt(wO),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:s},t.defaultValues&&!Qn(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...u}=IU(t);e.current={...u,formState:s}}const o=e.current.control;return o._options=t,Vw(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return i(u=>({...u,isReady:!0})),o._formState.isReady=!0,l},[o]),We.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),We.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),We.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),We.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),We.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==s.isDirty&&o._subjects.state.next({isDirty:l})}},[o,s.isDirty]),We.useEffect(()=>{var l;t.values&&!Pr(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,i(u=>({...u}))):o._resetDefaultValues()},[o,t.values]),We.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=We.useMemo(()=>lO(s,o),[o,s]),e.current}const S_=(t,e,n)=>{if(t&&"reportValidity"in t){const r=ke(n,e);t.setCustomValidity(r&&r.message||""),t.reportValidity()}},Z0=(t,e)=>{for(const n in e.fields){const r=e.fields[n];r&&r.ref&&"reportValidity"in r.ref?S_(r.ref,n,t):r&&r.refs&&r.refs.forEach(s=>S_(s,n,t))}},k_=(t,e)=>{e.shouldUseNativeValidation&&Z0(t,e);const n={};for(const r in t){const s=ke(e.fields,r),i=Object.assign(t[r]||{},{ref:s&&s.refs?s.refs[0]:s&&s.ref});if(PU(e.names||Object.keys(t),r)){const o=Object.assign({},ke(n,r));wt(o,"root",i),wt(n,r,o)}else wt(n,r,i)}return n},PU=(t,e)=>{const n=C_(e).replace(/[.*+?^${}()|\\]/g,"\\$&");return t.some(r=>C_(r).match(`^${n}\\.\\d+`))};function C_(t){return t.replace(/[\[\]]/g,"")}function Y0(){return Y0=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},Y0.apply(null,arguments)}function E_(t,e){try{var n=t()}catch(r){return e(r)}return n&&n.then?n.then(void 0,e):n}function zU(t,e){for(var n=Object.create(null);t.length;){var r=t[0],s=r.code,i=r.message,o=r.path.join(".");if(!n[o])if("unionErrors"in r){var l,u,d=r.unionErrors.reduce(function(y,b){return b.errors.length<y.errors.length?b:y}).errors[0];n[o]={message:(l=d?.message)!=null?l:i,type:(u=d?.code)!=null?u:s}}else n[o]={message:i,type:s};if("unionErrors"in r&&r.unionErrors.forEach(function(y){return y.errors.forEach(function(b){return t.push(b)})}),e){var h=n[o].types,g=h&&h[r.code];n[o]=Uw(o,e,n,s,g?[].concat(g,r.message):r.message)}t.shift()}return n}function $U(t,e){for(var n=Object.create(null),r=function(){var s=t[0],i=s.code,o=s.message,l=s.path.join(".");if(!n[l])if(s.code==="invalid_union"&&s.errors.length>0){var u,d,h=s.errors.reduce(function(b,x){return x.length<b.length?x:b})[0];n[l]={message:(u=h?.message)!=null?u:o,type:(d=h?.code)!=null?d:i}}else n[l]={message:o,type:i};if(s.code==="invalid_union"&&s.errors.forEach(function(b){return b.forEach(function(x){return t.push(Y0({},x,{path:[].concat(s.path,x.path)}))})}),e){var g=n[l].types,y=g&&g[s.code];n[l]=Uw(l,e,n,i,y?[].concat(y,s.message):s.message)}t.shift()};t.length;)r();return n}function BU(t,e,n){if(n===void 0&&(n={}),(function(r){return"_zod"in r&&typeof r._zod=="object"})(t))return function(r,s,i){try{return Promise.resolve(E_(function(){function o(u){return i.shouldUseNativeValidation&&Z0({},i),{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:k_($U(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if((function(r){return"_def"in r&&typeof r._def=="object"})(t))return function(r,s,i){try{return Promise.resolve(E_(function(){return Promise.resolve(t[n.mode==="sync"?"parse":"parseAsync"](r,e)).then(function(o){return i.shouldUseNativeValidation&&Z0({},i),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return Array.isArray(l?.issues)})(o))return{values:{},errors:k_(zU(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const T_={visible:!1,isDirty:!1,saving:!1},SO=E.createContext(null);function VU({children:t}){const[e,n]=E.useState(T_),r=E.useCallback(o=>{n(l=>({...l,...o,visible:o.visible??!!(o.isDirty||o.saving)}))},[]),s=E.useCallback(()=>{n(T_)},[]),i=E.useMemo(()=>({state:e,register:r,clear:s}),[e,r,s]);return m.jsx(SO.Provider,{value:i,children:t})}function kO(){const t=E.useContext(SO);if(!t)throw new Error("useSaveBar must be used within SaveBarProvider");return t}const CO=E.createContext(null);function HU({children:t}){const[e,n]=E.useState([]),r=E.useCallback(o=>{n(l=>l.filter(u=>u.id!==o))},[]),s=E.useCallback((o,l="neutral")=>{const u=`${Date.now()}-${Math.random().toString(36).slice(2,7)}`;n(d=>[...d,{id:u,message:o,tone:l}]),window.setTimeout(()=>r(u),4e3)},[r]),i=E.useMemo(()=>({toasts:e,push:s,dismiss:r}),[e,s,r]);return m.jsx(CO.Provider,{value:i,children:t})}function pg(){const t=E.useContext(CO);if(!t)throw new Error("useToast must be used within ToastProvider");return t}var vt;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(l=>typeof s[s[l]]!="number"),o={};for(const l of i)o[l]=s[l];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(vt||(vt={}));var __;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(__||(__={}));const Le=vt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_o=t=>{switch(typeof t){case"undefined":return Le.undefined;case"string":return Le.string;case"number":return Number.isNaN(t)?Le.nan:Le.number;case"boolean":return Le.boolean;case"function":return Le.function;case"bigint":return Le.bigint;case"symbol":return Le.symbol;case"object":return Array.isArray(t)?Le.array:t===null?Le.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Le.promise:typeof Map<"u"&&t instanceof Map?Le.map:typeof Set<"u"&&t instanceof Set?Le.set:typeof Date<"u"&&t instanceof Date?Le.date:Le.object;default:return Le.unknown}},we=vt.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 qi 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(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(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 d=o.path[u];u===o.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(n(o))):l[d]=l[d]||{_errors:[]},l=l[d],u++}}};return s(this),r}static assert(e){if(!(e instanceof qi))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,vt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}qi.create=t=>new qi(t);const X0=(t,e)=>{let n;switch(t.code){case we.invalid_type:t.received===Le.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case we.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,vt.jsonStringifyReplacer)}`;break;case we.unrecognized_keys:n=`Unrecognized key(s) in object: ${vt.joinValues(t.keys,", ")}`;break;case we.invalid_union:n="Invalid input";break;case we.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${vt.joinValues(t.options)}`;break;case we.invalid_enum_value:n=`Invalid enum value. Expected ${vt.joinValues(t.options)}, received '${t.received}'`;break;case we.invalid_arguments:n="Invalid function arguments";break;case we.invalid_return_type:n="Invalid function return type";break;case we.invalid_date:n="Invalid date";break;case we.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}"`:vt.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case we.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 we.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 we.custom:n="Invalid input";break;case we.invalid_intersection_types:n="Intersection results could not be merged";break;case we.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case we.not_finite:n="Number must be finite";break;default:n=e.defaultError,vt.assertNever(t)}return{message:n}};let UU=X0;function FU(){return UU}const qU=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let l="";const u=r.filter(d=>!!d).slice().reverse();for(const d of u)l=d(o,{data:e,defaultError:l}).message;return{...s,path:i,message:l}};function Ne(t,e){const n=FU(),r=qU({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===X0?void 0:X0].filter(s=>!!s)});t.common.issues.push(r)}class Vr{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 s of n){if(s.status==="aborted")return et;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return Vr.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return et;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const et=Object.freeze({status:"aborted"}),od=t=>({status:"dirty",value:t}),us=t=>({status:"valid",value:t}),A_=t=>t.status==="aborted",R_=t=>t.status==="dirty",Rc=t=>t.status==="valid",Jp=t=>typeof Promise<"u"&&t instanceof Promise;var ze;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(ze||(ze={}));class Xo{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}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 N_=(t,e)=>{if(Rc(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 qi(t.common.issues);return this._error=n,this._error}}};function ot(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=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:s}:{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:s}}class pt{get description(){return this._def.description}_getType(e){return _o(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:_o(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Vr,ctx:{common:e.parent.common,data:e.data,parsedType:_o(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Jp(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:_o(e)},s=this._parseSync({data:e,path:r.path,parent:r});return N_(r,s)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_o(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:n});return Rc(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=>Rc(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:_o(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Jp(s)?s:Promise.resolve(s));return N_(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=e(s),l=()=>i.addIssue({code:we.custom,...r(s)});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,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new Oc({schema:this,typeName:tt.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 Fo.create(this,this._def)}nullable(){return jc.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Zs.create(this)}promise(){return nm.create(this,this._def)}or(e){return em.create([this,e],this._def)}and(e){return tm.create(this,e,this._def)}transform(e){return new Oc({...ot(this._def),schema:this,typeName:tt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ex({...ot(this._def),innerType:this,defaultValue:n,typeName:tt.ZodDefault})}brand(){return new pF({typeName:tt.ZodBranded,type:this,...ot(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new tx({...ot(this._def),innerType:this,catchValue:n,typeName:tt.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Fw.create(this,e)}readonly(){return nx.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const GU=/^c[^\s-]{8,}$/i,WU=/^[0-9a-z]+$/,KU=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ZU=/^[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,YU=/^[a-z0-9_-]{21}$/i,XU=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,JU=/^[-+]?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)?)??$/,QU=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,eF="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Tv;const tF=/^(?:(?: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])$/,nF=/^(?:(?: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])$/,rF=/^(([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]))$/,sF=/^(([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])$/,iF=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,oF=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,EO="((\\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])))",aF=new RegExp(`^${EO}$`);function TO(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 lF(t){return new RegExp(`^${TO(t)}$`)}function cF(t){let e=`${EO}T${TO(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 uF(t,e){return!!((e==="v4"||!e)&&tF.test(t)||(e==="v6"||!e)&&rF.test(t))}function dF(t,e){if(!XU.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,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function fF(t,e){return!!((e==="v4"||!e)&&nF.test(t)||(e==="v6"||!e)&&sF.test(t))}class zo extends pt{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Le.string){const i=this._getOrReturnCtx(e);return Ne(i,{code:we.invalid_type,expected:Le.string,received:i.parsedType}),et}const r=new Vr;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?Ne(s,{code:we.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&Ne(s,{code:we.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")QU.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"email",code:we.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Tv||(Tv=new RegExp(eF,"u")),Tv.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"emoji",code:we.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")ZU.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"uuid",code:we.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")YU.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"nanoid",code:we.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")GU.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"cuid",code:we.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")WU.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"cuid2",code:we.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")KU.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"ulid",code:we.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),Ne(s,{validation:"url",code:we.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"regex",code:we.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?cF(i).test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?aF.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?lF(i).test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?JU.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"duration",code:we.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?uF(e.data,i.version)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"ip",code:we.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?dF(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"jwt",code:we.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?fF(e.data,i.version)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"cidr",code:we.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?iF.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"base64",code:we.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?oF.test(e.data)||(s=this._getOrReturnCtx(e,s),Ne(s,{validation:"base64url",code:we.invalid_string,message:i.message}),r.dirty()):vt.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:we.invalid_string,...ze.errToObj(r)})}_addCheck(e){return new zo({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ze.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ze.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ze.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ze.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ze.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ze.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ze.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ze.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ze.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ze.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ze.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ze.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ze.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,...ze.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,...ze.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ze.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...ze.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...ze.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...ze.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...ze.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...ze.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...ze.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...ze.errToObj(n)})}nonempty(e){return this.min(1,ze.errToObj(e))}trim(){return new zo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new zo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new zo({...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}}zo.create=t=>new zo({checks:[],typeName:tt.ZodString,coerce:t?.coerce??!1,...ot(t)});function hF(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}class Nc extends pt{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)!==Le.number){const i=this._getOrReturnCtx(e);return Ne(i,{code:we.invalid_type,expected:Le.number,received:i.parsedType}),et}let r;const s=new Vr;for(const i of this._def.checks)i.kind==="int"?vt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),Ne(r,{code:we.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),Ne(r,{code:we.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),Ne(r,{code:we.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?hF(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),Ne(r,{code:we.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),Ne(r,{code:we.not_finite,message:i.message}),s.dirty()):vt.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,ze.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ze.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ze.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ze.toString(n))}setLimit(e,n,r,s){return new Nc({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ze.toString(s)}]})}_addCheck(e){return new Nc({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ze.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ze.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ze.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ze.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ze.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ze.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:ze.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ze.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ze.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"&&vt.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)}}Nc.create=t=>new Nc({checks:[],typeName:tt.ZodNumber,coerce:t?.coerce||!1,...ot(t)});class $d extends pt{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)!==Le.bigint)return this._getInvalidInput(e);let r;const s=new Vr;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),Ne(r,{code:we.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),Ne(r,{code:we.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),Ne(r,{code:we.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):vt.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return Ne(n,{code:we.invalid_type,expected:Le.bigint,received:n.parsedType}),et}gte(e,n){return this.setLimit("min",e,!0,ze.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ze.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ze.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ze.toString(n))}setLimit(e,n,r,s){return new $d({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ze.toString(s)}]})}_addCheck(e){return new $d({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ze.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ze.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ze.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ze.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ze.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}}$d.create=t=>new $d({checks:[],typeName:tt.ZodBigInt,coerce:t?.coerce??!1,...ot(t)});class J0 extends pt{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Le.boolean){const r=this._getOrReturnCtx(e);return Ne(r,{code:we.invalid_type,expected:Le.boolean,received:r.parsedType}),et}return us(e.data)}}J0.create=t=>new J0({typeName:tt.ZodBoolean,coerce:t?.coerce||!1,...ot(t)});class Qp extends pt{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Le.date){const i=this._getOrReturnCtx(e);return Ne(i,{code:we.invalid_type,expected:Le.date,received:i.parsedType}),et}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return Ne(i,{code:we.invalid_date}),et}const r=new Vr;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),Ne(s,{code:we.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):vt.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Qp({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:ze.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:ze.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}}Qp.create=t=>new Qp({checks:[],coerce:t?.coerce||!1,typeName:tt.ZodDate,...ot(t)});class M_ extends pt{_parse(e){if(this._getType(e)!==Le.symbol){const r=this._getOrReturnCtx(e);return Ne(r,{code:we.invalid_type,expected:Le.symbol,received:r.parsedType}),et}return us(e.data)}}M_.create=t=>new M_({typeName:tt.ZodSymbol,...ot(t)});class O_ extends pt{_parse(e){if(this._getType(e)!==Le.undefined){const r=this._getOrReturnCtx(e);return Ne(r,{code:we.invalid_type,expected:Le.undefined,received:r.parsedType}),et}return us(e.data)}}O_.create=t=>new O_({typeName:tt.ZodUndefined,...ot(t)});class j_ extends pt{_parse(e){if(this._getType(e)!==Le.null){const r=this._getOrReturnCtx(e);return Ne(r,{code:we.invalid_type,expected:Le.null,received:r.parsedType}),et}return us(e.data)}}j_.create=t=>new j_({typeName:tt.ZodNull,...ot(t)});class D_ extends pt{constructor(){super(...arguments),this._any=!0}_parse(e){return us(e.data)}}D_.create=t=>new D_({typeName:tt.ZodAny,...ot(t)});class I_ extends pt{constructor(){super(...arguments),this._unknown=!0}_parse(e){return us(e.data)}}I_.create=t=>new I_({typeName:tt.ZodUnknown,...ot(t)});class Jo extends pt{_parse(e){const n=this._getOrReturnCtx(e);return Ne(n,{code:we.invalid_type,expected:Le.never,received:n.parsedType}),et}}Jo.create=t=>new Jo({typeName:tt.ZodNever,...ot(t)});class L_ extends pt{_parse(e){if(this._getType(e)!==Le.undefined){const r=this._getOrReturnCtx(e);return Ne(r,{code:we.invalid_type,expected:Le.void,received:r.parsedType}),et}return us(e.data)}}L_.create=t=>new L_({typeName:tt.ZodVoid,...ot(t)});class Zs extends pt{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==Le.array)return Ne(n,{code:we.invalid_type,expected:Le.array,received:n.parsedType}),et;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,l=n.data.length<s.exactLength.value;(o||l)&&(Ne(n,{code:o?we.too_big:we.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(Ne(n,{code:we.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(Ne(n,{code:we.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,l)=>s.type._parseAsync(new Xo(n,o,n.path,l)))).then(o=>Vr.mergeArray(r,o));const i=[...n.data].map((o,l)=>s.type._parseSync(new Xo(n,o,n.path,l)));return Vr.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new Zs({...this._def,minLength:{value:e,message:ze.toString(n)}})}max(e,n){return new Zs({...this._def,maxLength:{value:e,message:ze.toString(n)}})}length(e,n){return new Zs({...this._def,exactLength:{value:e,message:ze.toString(n)}})}nonempty(e){return this.min(1,e)}}Zs.create=(t,e)=>new Zs({type:t,minLength:null,maxLength:null,exactLength:null,typeName:tt.ZodArray,...ot(e)});function hc(t){if(t instanceof yn){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Fo.create(hc(r))}return new yn({...t._def,shape:()=>e})}else return t instanceof Zs?new Zs({...t._def,type:hc(t.element)}):t instanceof Fo?Fo.create(hc(t.unwrap())):t instanceof jc?jc.create(hc(t.unwrap())):t instanceof Ja?Ja.create(t.items.map(e=>hc(e))):t}class yn extends pt{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=vt.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==Le.object){const d=this._getOrReturnCtx(e);return Ne(d,{code:we.invalid_type,expected:Le.object,received:d.parsedType}),et}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof Jo&&this._def.unknownKeys==="strip"))for(const d in s.data)o.includes(d)||l.push(d);const u=[];for(const d of o){const h=i[d],g=s.data[d];u.push({key:{status:"valid",value:d},value:h._parse(new Xo(s,g,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof Jo){const d=this._def.unknownKeys;if(d==="passthrough")for(const h of l)u.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(d==="strict")l.length>0&&(Ne(s,{code:we.unrecognized_keys,keys:l}),r.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const h of l){const g=s.data[h];u.push({key:{status:"valid",value:h},value:d._parse(new Xo(s,g,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const h of u){const g=await h.key,y=await h.value;d.push({key:g,value:y,alwaysSet:h.alwaysSet})}return d}).then(d=>Vr.mergeObjectSync(r,d)):Vr.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(e){return ze.errToObj,new yn({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{const s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:ze.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new yn({...this._def,unknownKeys:"strip"})}passthrough(){return new yn({...this._def,unknownKeys:"passthrough"})}extend(e){return new yn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new yn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:tt.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new yn({...this._def,catchall:e})}pick(e){const n={};for(const r of vt.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new yn({...this._def,shape:()=>n})}omit(e){const n={};for(const r of vt.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new yn({...this._def,shape:()=>n})}deepPartial(){return hc(this)}partial(e){const n={};for(const r of vt.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new yn({...this._def,shape:()=>n})}required(e){const n={};for(const r of vt.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Fo;)i=i._def.innerType;n[r]=i}return new yn({...this._def,shape:()=>n})}keyof(){return _O(vt.objectKeys(this.shape))}}yn.create=(t,e)=>new yn({shape:()=>t,unknownKeys:"strip",catchall:Jo.create(),typeName:tt.ZodObject,...ot(e)});yn.strictCreate=(t,e)=>new yn({shape:()=>t,unknownKeys:"strict",catchall:Jo.create(),typeName:tt.ZodObject,...ot(e)});yn.lazycreate=(t,e)=>new yn({shape:t,unknownKeys:"strip",catchall:Jo.create(),typeName:tt.ZodObject,...ot(e)});class em extends pt{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new qi(l.ctx.common.issues));return Ne(n,{code:we.invalid_union,unionErrors:o}),et}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const u of r){const d={...n,common:{...n.common,issues:[]},parent:null},h=u._parseSync({data:n.data,path:n.path,parent:d});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(u=>new qi(u));return Ne(n,{code:we.invalid_union,unionErrors:l}),et}}get options(){return this._def.options}}em.create=(t,e)=>new em({options:t,typeName:tt.ZodUnion,...ot(e)});function Q0(t,e){const n=_o(t),r=_o(e);if(t===e)return{valid:!0,data:t};if(n===Le.object&&r===Le.object){const s=vt.objectKeys(e),i=vt.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o={...t,...e};for(const l of i){const u=Q0(t[l],e[l]);if(!u.valid)return{valid:!1};o[l]=u.data}return{valid:!0,data:o}}else if(n===Le.array&&r===Le.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const o=t[i],l=e[i],u=Q0(o,l);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return n===Le.date&&r===Le.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class tm extends pt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(A_(i)||A_(o))return et;const l=Q0(i.value,o.value);return l.valid?((R_(i)||R_(o))&&n.dirty(),{status:n.value,value:l.data}):(Ne(r,{code:we.invalid_intersection_types}),et)};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(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}tm.create=(t,e,n)=>new tm({left:t,right:e,typeName:tt.ZodIntersection,...ot(n)});class Ja extends pt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==Le.array)return Ne(r,{code:we.invalid_type,expected:Le.array,received:r.parsedType}),et;if(r.data.length<this._def.items.length)return Ne(r,{code:we.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),et;!this._def.rest&&r.data.length>this._def.items.length&&(Ne(r,{code:we.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,l)=>{const u=this._def.items[l]||this._def.rest;return u?u._parse(new Xo(r,o,r.path,l)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Vr.mergeArray(n,o)):Vr.mergeArray(n,i)}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:tt.ZodTuple,rest:null,...ot(e)})};class P_ extends pt{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!==Le.map)return Ne(r,{code:we.invalid_type,expected:Le.map,received:r.parsedType}),et;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([l,u],d)=>({key:s._parse(new Xo(r,l,r.path,[d,"key"])),value:i._parse(new Xo(r,u,r.path,[d,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const u of o){const d=await u.key,h=await u.value;if(d.status==="aborted"||h.status==="aborted")return et;(d.status==="dirty"||h.status==="dirty")&&n.dirty(),l.set(d.value,h.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const u of o){const d=u.key,h=u.value;if(d.status==="aborted"||h.status==="aborted")return et;(d.status==="dirty"||h.status==="dirty")&&n.dirty(),l.set(d.value,h.value)}return{status:n.value,value:l}}}}P_.create=(t,e,n)=>new P_({valueType:e,keyType:t,typeName:tt.ZodMap,...ot(n)});class Bd extends pt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==Le.set)return Ne(r,{code:we.invalid_type,expected:Le.set,received:r.parsedType}),et;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(Ne(r,{code:we.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(Ne(r,{code:we.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(u){const d=new Set;for(const h of u){if(h.status==="aborted")return et;h.status==="dirty"&&n.dirty(),d.add(h.value)}return{status:n.value,value:d}}const l=[...r.data.values()].map((u,d)=>i._parse(new Xo(r,u,r.path,d)));return r.common.async?Promise.all(l).then(u=>o(u)):o(l)}min(e,n){return new Bd({...this._def,minSize:{value:e,message:ze.toString(n)}})}max(e,n){return new Bd({...this._def,maxSize:{value:e,message:ze.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Bd.create=(t,e)=>new Bd({valueType:t,minSize:null,maxSize:null,typeName:tt.ZodSet,...ot(e)});class z_ extends pt{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})}}z_.create=(t,e)=>new z_({getter:t,typeName:tt.ZodLazy,...ot(e)});class $_ extends pt{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return Ne(n,{received:n.data,code:we.invalid_literal,expected:this._def.value}),et}return{status:"valid",value:e.data}}get value(){return this._def.value}}$_.create=(t,e)=>new $_({value:t,typeName:tt.ZodLiteral,...ot(e)});function _O(t,e){return new Mc({values:t,typeName:tt.ZodEnum,...ot(e)})}class Mc extends pt{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return Ne(n,{expected:vt.joinValues(r),received:n.parsedType,code:we.invalid_type}),et}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 Ne(n,{received:n.data,code:we.invalid_enum_value,options:r}),et}return us(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=_O;class B_ extends pt{_parse(e){const n=vt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Le.string&&r.parsedType!==Le.number){const s=vt.objectValues(n);return Ne(r,{expected:vt.joinValues(s),received:r.parsedType,code:we.invalid_type}),et}if(this._cache||(this._cache=new Set(vt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=vt.objectValues(n);return Ne(r,{received:r.data,code:we.invalid_enum_value,options:s}),et}return us(e.data)}get enum(){return this._def.values}}B_.create=(t,e)=>new B_({values:t,typeName:tt.ZodNativeEnum,...ot(e)});class nm extends pt{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==Le.promise&&n.common.async===!1)return Ne(n,{code:we.invalid_type,expected:Le.promise,received:n.parsedType}),et;const r=n.parsedType===Le.promise?n.data:Promise.resolve(n.data);return us(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}nm.create=(t,e)=>new nm({type:t,typeName:tt.ZodPromise,...ot(e)});class Oc extends pt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===tt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{Ne(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async l=>{if(n.value==="aborted")return et;const u=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return u.status==="aborted"?et:u.status==="dirty"||n.value==="dirty"?od(u.value):u});{if(n.value==="aborted")return et;const l=this._def.schema._parseSync({data:o,path:r.path,parent:r});return l.status==="aborted"?et:l.status==="dirty"||n.value==="dirty"?od(l.value):l}}if(s.type==="refinement"){const o=l=>{const u=s.refinement(l,i);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"?et:(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"?et:(l.status==="dirty"&&n.dirty(),o(l.value).then(()=>({status:n.value,value:l.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Rc(o))return et;const l=s.transform(o.value,i);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=>Rc(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:n.value,value:l})):et);vt.assertNever(s)}}Oc.create=(t,e,n)=>new Oc({schema:t,typeName:tt.ZodEffects,effect:e,...ot(n)});Oc.createWithPreprocess=(t,e,n)=>new Oc({schema:e,effect:{type:"preprocess",transform:t},typeName:tt.ZodEffects,...ot(n)});class Fo extends pt{_parse(e){return this._getType(e)===Le.undefined?us(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Fo.create=(t,e)=>new Fo({innerType:t,typeName:tt.ZodOptional,...ot(e)});class jc extends pt{_parse(e){return this._getType(e)===Le.null?us(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}jc.create=(t,e)=>new jc({innerType:t,typeName:tt.ZodNullable,...ot(e)});class ex extends pt{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===Le.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ex.create=(t,e)=>new ex({innerType:t,typeName:tt.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ot(e)});class tx extends pt{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Jp(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new qi(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new qi(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}tx.create=(t,e)=>new tx({innerType:t,typeName:tt.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ot(e)});class V_ extends pt{_parse(e){if(this._getType(e)!==Le.nan){const r=this._getOrReturnCtx(e);return Ne(r,{code:we.invalid_type,expected:Le.nan,received:r.parsedType}),et}return{status:"valid",value:e.data}}}V_.create=t=>new V_({typeName:tt.ZodNaN,...ot(t)});class pF extends pt{_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 Fw extends pt{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?et:i.status==="dirty"?(n.dirty(),od(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?et:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new Fw({in:e,out:n,typeName:tt.ZodPipeline})}}class nx extends pt{_parse(e){const n=this._def.innerType._parse(e),r=s=>(Rc(s)&&(s.value=Object.freeze(s.value)),s);return Jp(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}nx.create=(t,e)=>new nx({innerType:t,typeName:tt.ZodReadonly,...ot(e)});var tt;(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"})(tt||(tt={}));const H_=zo.create,mF=Nc.create,gF=J0.create;Jo.create;const yF=Zs.create,bF=yn.create;em.create;tm.create;Ja.create;Mc.create;nm.create;Fo.create;jc.create;function vF(t){const e={};for(const[n,r]of Object.entries(t)){let s;switch(r.type){case"number":s=mF(),r.min!=null&&(s=s.min(r.min)),r.max!=null&&(s=s.max(r.max));break;case"boolean":s=gF();break;case"file[]":case"enum[]":s=yF(H_());break;default:s=H_()}r.required||(s=s.optional()),e[n]=s}return bF(e)}function mg(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim()}function bd(t,e){const n=e?.optionLabels?.[t]?.trim();return n||mg(t)}function xF(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wF(t,e,n){const r=e.label?.trim()||mg(t),s=r.replace(new RegExp(`^${xF(n)}\\s+`,"i"),"");if(/^inventory$/i.test(n)){const i=r.replace(/^stock\s+/i,"").trim();if(i&&i!==r)return i}return/^pricing$/i.test(n)&&/cents/i.test(r)?r.replace(/\s*\(cents\)/i,"").trim()||r:s||r}const SF=/(description|body|content|summary|bio|copy|caption|details)/i;function AO(t,e){if(e?.type==="richtext")return!0;const n=`${t} ${e?.label??""}`;return SF.test(n)}function U_(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 Vd(t){return/^https?:\/\//i.test(t)||t.startsWith("//")}function Qa(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 RO(t){if(typeof t=="string"&&Vd(t))return{url:t};if(t&&typeof t=="object"&&"url"in t){const e=t.url,n=t.name;if(typeof e=="string"&&Vd(e))return{url:e,name:typeof n=="string"?n:void 0}}return null}function kF(t,e){const n=[];for(const[r,s]of Object.entries(t)){if(!Qa(r,s))continue;const i=s.label?.trim()||r,o=e?.[r],l=Array.isArray(o)?o:[o];l.forEach((u,d)=>{const h=RO(u);h&&n.push({id:`${r}:${d}`,url:h.url,name:h.name||(l.length>1?`${i} ${d+1}`:i),field:r})})}return n}function rx(t){const e=Array.isArray(t)?t:t==null||t===""?[]:[t],n=[];for(const r of e){const s=RO(r);s&&n.push(s.url)}return n}function CF(t){return t.length>0&&t.every(([,e])=>e.type==="boolean")}function EF(t,e){const n=`${t} ${e?.label??""}`;return/(stock|inventory|qty|quantity)/i.test(n)}function gg(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 NO(t,e){const n=`${t} ${e?.label??""}`;return/(detail|notes|bio|bullets|body|message|html)/i.test(n)}function TF(t,e,n){if(e.type==="boolean"||e.type==="enum[]"||e.type==="richtext"||AO(t,e)||NO(t,e)||n==="record"&&Qa(t,e))return"full"}function qw(t){return`show${t.charAt(0).toUpperCase()}${t.slice(1)}`}function _F(t){const e={...t};for(const[n,r]of Object.entries(t)){if(r.type==="boolean"||!gg(n,r))continue;const s=qw(n);e[s]||(e[s]={type:"boolean",default:!0,label:`Show ${r.label??mg(n)}`})}return e}function AF(t,e){const n={...e};for(const[r,s]of Object.entries(t)){if(s.type==="boolean"||!gg(r,s))continue;const i=qw(r);!(i in n)||n[i]==null?n[i]=!0:n[i]=n[i]!==!1}return n}function RF(t){return t.charAt(0).toLowerCase()+t.slice(1)}function NF(t,e){const n=qw(t),r=[n];t==="priceCents"&&r.push("showPrice");for(const s of r)if(e[s]?.type==="boolean")return s;return gg(t,e[t])?n:null}const sx={Pricing:"showPrice",Inventory:"showStock",Content:"showDescription"};function MF(t){return Object.keys(sx).find(e=>sx[e]===t)}function OF(t,e){if(!/^show[A-Z]/.test(t)||e[t]?.type!=="boolean")return!1;if(MF(t))return!0;const n=RF(t.slice(4));return e[n]?!0:t==="showPrice"&&!!e.priceCents}function Gw(t,e){const n=sx[t];return n&&e[n]?.type==="boolean"?n:null}function jF(t,e,n){const r=NF(t,e);return!r||n&&Gw(n,e)===r?null:r}const F_=["Details","Content","Specs","Pricing","Inventory","Media","Display","Status"];function DF(t,e){if(e.group?.trim())return e.group.trim();const r=(e.label?.trim()||mg(t)).split(/\s+/).filter(Boolean);return r.length>=2?r[0]:"General"}function IF(t,e){if(e.group?.trim())return e.group.trim();const n=t.toLowerCase(),r=(e.label??"").toLowerCase(),s=`${n} ${r}`;return/(image|img|photo|avatar|thumbnail|thumb|cover|media_url)/i.test(s)?"Media":/(price|cost|cents|amount|msrp)/i.test(s)?"Pricing":/(stock|inventory|qty|quantity)/i.test(s)?"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(s)?"Content":gg(t,e)?"Specs":"Details"}function LF(t,e){if(e!=="record")return t;const n=r=>{const s=F_.indexOf(r);return s===-1?F_.length+1:s};return[...t].sort((r,s)=>n(r.id)-n(s.id))}function PF(t,e){const n=[],r=new Map,s=new Set;for(const o of Object.entries(t)){const[l,u]=o;if(OF(l,t))continue;const d=e==="record"?IF(l,u):DF(l,u);u.group?.trim()&&s.add(d),r.has(d)||(r.set(d,[]),n.push(d)),r.get(d).push(o)}if(e==="config")for(const[o,l]of[...r.entries()]){if(l.length>1||s.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 i=n.filter(o=>r.has(o)).map(o=>({id:o,label:o,fields:r.get(o)}));return LF(i,e)}function rm(t){const e=Array.isArray(t)?t:[t];for(const n of e){if(typeof n=="string"&&Vd(n))return n;if(n&&typeof n=="object"&&"url"in n){const r=n.url;if(typeof r=="string"&&Vd(r))return r}}return null}function zF(t,e){for(const[n,r]of Object.entries(t))if(Qa(n,r)&&rm(e?.[n]))return n;for(const[n,r]of Object.entries(t))if(Qa(n,r))return n;return null}function $F(t){return t.join(",")}function Wc({meta:t,disabled:e,multiple:n=!1,label:r,onUpload:s}){const i=E.useRef(null),[o,l]=E.useState(!1),[u,d]=E.useState(null),[h,g]=E.useState(!1),y=async b=>{if(!b||e||o)return;const x=Array.from(b);if(x.length){l(!0),d(null);try{await s(n?x:x.slice(0,1))}catch(S){d(S instanceof Error?S.message:"Upload failed")}finally{l(!1),i.current&&(i.current.value="")}}};return m.jsxs("div",{className:"vertebr-upload",children:[m.jsxs("div",{className:"vertebr-upload-drop","data-busy":o?"true":void 0,"data-drag":h?"true":void 0,onDragEnter:b=>{b.preventDefault(),g(!0)},onDragOver:b=>{b.preventDefault(),g(!0)},onDragLeave:b=>{b.preventDefault(),g(!1)},onDrop:b=>{b.preventDefault(),g(!1),y(b.dataTransfer.files)},children:[m.jsx("p",{className:"vertebr-upload-copy",children:o?"Uploading…":r??(n?"Drop images here or browse":"Drop an image here or browse")}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:e||o,onClick:()=>i.current?.click(),children:n?"Choose images":"Choose image"}),m.jsx("input",{ref:i,type:"file",accept:$F(t.accept),multiple:n,hidden:!0,onChange:b=>{y(b.target.files)}})]}),u?m.jsx("p",{className:"vertebr-upload-error",role:"alert",children:u}):null]})}var Kc=HN();const BF=VN(Kc);var VF=Object.defineProperty,Ww=(t,e)=>VF(t,"name",{value:e,configurable:!0});function ix(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Ww(ix,"setRef");function MO(...t){return e=>{let n=!1;const r=t.map(s=>{const i=ix(s,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let s=0;s<r.length;s++){const i=r[s];typeof i=="function"?i():ix(t[s],null)}}}}Ww(MO,"composeRefs");function dn(...t){return E.useCallback(MO(...t),t)}Ww(dn,"useComposedRefs");var HF=Object.defineProperty,Ms=(t,e)=>HF(t,"name",{value:e,configurable:!0});function el(t){const e=E.forwardRef((n,r)=>{let{children:s,...i}=n,o=null,l=!1;const u=[];ox(s)&&typeof $h=="function"&&(s=$h(s._payload)),E.Children.forEach(s,y=>{if(IO(y)){l=!0;const b=y;let x="child"in b.props?b.props.child:b.props.children;ox(x)&&typeof $h=="function"&&(x=$h(x._payload)),o=FF(b,x),u.push(o?.props?.children)}else u.push(y)}),o?o=E.cloneElement(o,void 0,u):!l&&E.Children.count(s)===1&&E.isValidElement(s)&&(o=s);const d=o?DO(o):void 0,h=dn(r,d);if(!o){if(s||s===0)throw new Error(l?WF(t):GF(t));return s}const g=jO(i,o.props??{});return o.type!==E.Fragment&&(g.ref=r?h:d),E.cloneElement(o,g)});return e.displayName=`${t}.Slot`,e}Ms(el,"createSlot");var OO=Symbol.for("radix.slottable");function UF(t){const e=Ms(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=OO,e}Ms(UF,"createSlottable");var FF=Ms((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 jO(t,e){const n={...e};for(const r in e){const s=t[r],i=e[r];/^on[A-Z]/.test(r)?s&&i?n[r]=(...l)=>{const u=i(...l);return s(...l),u}:s&&(n[r]=s):r==="style"?n[r]={...s,...i}:r==="className"&&(n[r]=[s,i].filter(Boolean).join(" "))}return{...t,...n}}Ms(jO,"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)}Ms(DO,"getElementRef");function IO(t){return E.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===OO}Ms(IO,"isSlottable");var qF=Symbol.for("react.lazy");function ox(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===qF&&"_payload"in t&&LO(t._payload)}Ms(ox,"isLazyComponent");function LO(t){return typeof t=="object"&&t!==null&&"then"in t}Ms(LO,"isPromiseLike");var GF=Ms(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),WF=Ms(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),$h=nf[" use ".trim().toString()],KF=Object.defineProperty,ZF=(t,e)=>KF(t,"name",{value:e,configurable:!0}),YF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Mn=YF.reduce((t,e)=>{const n=el(`Primitive.${e}`),r=E.forwardRef((s,i)=>{const{asChild:o,...l}=s,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function PO(t,e){t&&Kc.flushSync(()=>t.dispatchEvent(e))}ZF(PO,"dispatchDiscreteCustomEvent");var XF=Object.defineProperty,JF=(t,e)=>XF(t,"name",{value:e,configurable:!0}),QF=E.forwardRef(JF(function(e,n){return m.jsx(Mn.label,{...e,ref:n,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}})},"Label")),_v=QF,e4=Object.defineProperty,Zc=(t,e)=>e4(t,"name",{value:e,configurable:!0}),zO=!!(typeof window<"u"&&window.document&&window.document.createElement);function bn(t,e,{checkForDefaultPrevented:n=!0}={}){return Zc(function(s){if(t?.(s),n===!1||!s||!s.defaultPrevented)return e?.(s)},"handleEvent")}Zc(bn,"composeEventHandlers");function t4(t){if(!zO)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}Zc(t4,"getOwnerWindow");function ax(t){if(!zO)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}Zc(ax,"getOwnerDocument");function $O(t,e=!1){const{activeElement:n}=ax(t);if(!n?.nodeName)return null;if(BO(n)&&n.contentDocument)return $O(n.contentDocument.body,e);if(e){const r=n.getAttribute("aria-activedescendant");if(r){const s=ax(n).getElementById(r);if(s)return s}}return n}Zc($O,"getActiveElement");function BO(t){return t.tagName==="IFRAME"}Zc(BO,"isFrame");var n4=Object.defineProperty,rs=(t,e)=>n4(t,"name",{value:e,configurable:!0});function r4(t,e){const n=E.createContext(e);n.displayName=t+"Context";const r=rs(i=>{const{children:o,...l}=i,u=E.useMemo(()=>l,Object.values(l));return m.jsx(n.Provider,{value:u,children:o})},"Provider");r.displayName=t+"Provider";function s(i,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(`\`${i}\` must be used within \`${t}\``)}return rs(s,"useContext"),[r,s]}rs(r4,"createContext");function Yc(t,e=[]){let n=[];function r(i,o){const l=E.createContext(o);l.displayName=i+"Context";const u=n.length;n=[...n,o];const d=rs(g=>{const{scope:y,children:b,...x}=g,S=y?.[t]?.[u]||l,k=E.useMemo(()=>x,Object.values(x));return m.jsx(S.Provider,{value:k,children:b})},"Provider");d.displayName=i+"Provider";function h(g,y,b={}){const{optional:x=!1}=b,S=y?.[t]?.[u]||l,k=E.useContext(S);if(k)return k;if(o!==void 0)return o;if(!x)throw new Error(`\`${g}\` must be used within \`${i}\``)}return rs(h,"useContext"),[d,h]}rs(r,"createContext");const s=rs(()=>{const i=n.map(o=>E.createContext(o));return rs(function(l){const u=l?.[t]||i;return E.useMemo(()=>({[`__scope${t}`]:{...l,[t]:u}}),[l,u])},"useScope")},"createScope");return s.scopeName=t,[r,VO(s,...e)]}rs(Yc,"createContextScope");function VO(...t){const e=t[0];if(t.length===1)return e;const n=rs(()=>{const r=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return rs(function(i){const o=r.reduce((l,{useScope:u,scopeName:d})=>{const g=u(i)[`__scope${d}`];return{...l,...g}},{});return E.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=e.scopeName,n}rs(VO,"composeContextScopes");var ur=globalThis?.document?E.useLayoutEffect:()=>{},s4=Object.defineProperty,i4=(t,e)=>s4(t,"name",{value:e,configurable:!0}),q_=nf[" useEffectEvent ".trim().toString()],G_=nf[" useInsertionEffect ".trim().toString()];function HO(t){if(typeof q_=="function")return q_(t);const e=E.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof G_=="function"?G_(()=>{e.current=t}):ur(()=>{e.current=t}),E.useMemo(()=>((...n)=>e.current?.(...n)),[])}i4(HO,"useEffectEvent");var o4=Object.defineProperty,hf=(t,e)=>o4(t,"name",{value:e,configurable:!0}),a4=nf[" useInsertionEffect ".trim().toString()]||ur;function sm({prop:t,defaultProp:e,onChange:n=hf(()=>{},"onChange"),caller:r}){const[s,i,o]=UO({defaultProp:e,onChange:n}),l=t!==void 0,u=l?t:s,d=E.useCallback(h=>{if(l){const g=FO(h)?h(t):h;g!==t&&o.current?.(g)}else i(h)},[l,t,i,o]);return[u,d]}hf(sm,"useControllableState");function UO({defaultProp:t,onChange:e}){const[n,r]=E.useState(t),s=E.useRef(n),i=E.useRef(e);return a4(()=>{i.current=e},[e]),E.useEffect(()=>{s.current!==n&&(i.current?.(n),s.current=n)},[n,s]),[n,r,i]}hf(UO,"useUncontrolledState");function FO(t){return typeof t=="function"}hf(FO,"isFunction");var W_=Symbol("RADIX:SYNC_STATE");function l4(t,e,n,r){const{prop:s,defaultProp:i,onChange:o,caller:l}=e,u=s!==void 0,d=HO(o),h=[{...n,state:i}];r&&h.push(r);const[g,y]=E.useReducer((k,C)=>{if(C.type===W_)return{...k,state:C.state};const A=t(k,C);return u&&!Object.is(A.state,k.state)&&d(A.state),A},...h),b=g.state,x=E.useRef(b);E.useEffect(()=>{x.current!==b&&(x.current=b,u||d(b))},[b,x,u]);const S=E.useMemo(()=>s!==void 0?{...g,state:s}:g,[g,s]);return E.useEffect(()=>{u&&!Object.is(s,g.state)&&y({type:W_,state:s})},[s,g.state,u]),[S,y]}hf(l4,"useControllableStateReducer");var c4=Object.defineProperty,u4=(t,e)=>c4(t,"name",{value:e,configurable:!0});function Kw(t){const[e,n]=E.useState(void 0);return ur(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let o,l;if("borderBoxSize"in i){const u=i.borderBoxSize,d=Array.isArray(u)?u[0]:u;o=d.inlineSize,l=d.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}u4(Kw,"useSize");var d4=Object.defineProperty,Qo=(t,e)=>d4(t,"name",{value:e,configurable:!0}),Zw="Switch",[f4,tre]=Yc(Zw),[h4,Yw]=f4(Zw);function qO(t){const{__scopeSwitch:e,checked:n,children:r,defaultChecked:s,disabled:i,form:o,name:l,onCheckedChange:u,required:d,value:h="on",internal_do_not_use_render:g}=t,[y,b]=sm({prop:n,defaultProp:s??!1,onChange:u,caller:Zw}),[x,S]=E.useState(null),[k,C]=E.useState(null),A=E.useRef(!1),[R,_]=E.useReducer(O=>O+1,0),N=x?!!o||!!x.closest("form"):!0,M={checked:y,setChecked:b,disabled:i,control:x,setControl:S,name:l,form:o,value:h,hasConsumerStoppedPropagationRef:A,userInteractionCount:R,onUserInteraction:_,required:d,defaultChecked:s,isFormControl:N,bubbleInput:k,setBubbleInput:C};return m.jsx(h4,{scope:e,...M,children:GO(g)?g(M):r})}Qo(qO,"SwitchProvider");var p4="SwitchTrigger",m4=E.forwardRef(Qo(function({__scopeSwitch:e,onClick:n,...r},s){const{control:i,form:o,value:l,disabled:u,checked:d,required:h,setControl:g,setChecked:y,hasConsumerStoppedPropagationRef:b,onUserInteraction:x,isFormControl:S,bubbleInput:k}=Yw(p4,e),C=dn(s,g),A=E.useRef(d);return E.useEffect(()=>{const R=o?i?.ownerDocument.getElementById(o):i?.form;if(R instanceof HTMLFormElement){const _=Qo(()=>y(A.current),"reset");return R.addEventListener("reset",_),()=>R.removeEventListener("reset",_)}},[i,o,y]),m.jsx(Mn.button,{type:"button",role:"switch","aria-checked":d,"aria-required":h,"data-state":Xw(d),"data-disabled":u?"":void 0,disabled:u,value:l,...r,ref:C,onClick:bn(n,R=>{x(),y(_=>!_),k&&S&&(b.current=R.isPropagationStopped(),b.current||R.stopPropagation())})})},"SwitchTrigger")),K_=E.forwardRef(Qo(function(e,n){const{__scopeSwitch:r,name:s,checked:i,defaultChecked:o,required:l,disabled:u,value:d,onCheckedChange:h,form:g,...y}=e;return m.jsx(qO,{__scopeSwitch:r,checked:i,defaultChecked:o,disabled:u,required:l,onCheckedChange:h,name:s,form:g,value:d,internal_do_not_use_render:({isFormControl:b})=>m.jsxs(m.Fragment,{children:[m.jsx(m4,{...y,ref:n,__scopeSwitch:r}),b&&m.jsx(b4,{__scopeSwitch:r})]})})},"Switch")),g4="SwitchThumb",Z_=E.forwardRef(Qo(function(e,n){const{__scopeSwitch:r,...s}=e,i=Yw(g4,r);return m.jsx(Mn.span,{"data-state":Xw(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:n})},"SwitchThumb")),y4="SwitchBubbleInput",b4=E.forwardRef(Qo(function({__scopeSwitch:e,onClick:n,...r},s){const{control:i,hasConsumerStoppedPropagationRef:o,userInteractionCount:l,checked:u,defaultChecked:d,required:h,disabled:g,name:y,value:b,form:x,bubbleInput:S,setBubbleInput:k}=Yw(y4,e),C=dn(s,k),A=Kw(i),R=E.useRef(!1),_=E.useRef(u),N=E.useRef(l);E.useEffect(()=>{const O=S;if(!O)return;const P=window.HTMLInputElement.prototype,F=Object.getOwnPropertyDescriptor(P,"checked").set,te=l!==N.current;N.current=l;const H=_.current!==u;_.current=u;const Z=!(te&&o.current);if(H&&F){R.current=!te;const G=new Event("click",{bubbles:Z});F.call(O,u),O.dispatchEvent(G),R.current=!1}},[S,u,o,l]);const M=E.useRef(u);return m.jsx(Mn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:d??M.current,required:h,disabled:g,name:y,value:b,form:x,...r,tabIndex:-1,ref:C,onClick:bn(n,O=>{R.current&&O.stopPropagation()}),style:{...r.style,...A,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function GO(t){return typeof t=="function"}Qo(GO,"isFunction");function Xw(t){return t?"checked":"unchecked"}Qo(Xw,"getState");function WO({name:t,label:e,form:n}){const r=n.watch(t)!==!1;return E.useEffect(()=>{n.register(t)},[n,t]),m.jsx(KO,{visible:r,label:e,onChange:s=>n.setValue(t,s,{shouldDirty:!0,shouldTouch:!0})})}function KO({visible:t,label:e,dirty:n,disabled:r,onChange:s}){return m.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:i=>{i.stopPropagation(),s(!t)},children:t?m.jsx(v4,{}):m.jsx(x4,{})})}function v4(){return m.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:[m.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"}),m.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function x4(){return m.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:[m.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"}),m.jsx("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),m.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"}),m.jsx("path",{d:"m2 2 20 20"})]})}const w4=/(cents|priceCents|amountCents)/i,Y_=/(price|amount|cost|total|msrp)/i;function Jw(t,e){return w4.test(t)||/cents/i.test(e?.label??"")}function ZO(t,e){return Jw(t,e)?!0:Y_.test(t)||Y_.test(e?.label??"")}function YO(t,e){return e?t/100:t}function S4(t,e){return e?Math.round(t*100):t}function lx(t,e){const n=e?.asCents??!0,r=e?.currency??"USD",s=YO(t,n);try{return new Intl.NumberFormat(void 0,{style:"currency",currency:r,minimumFractionDigits:2,maximumFractionDigits:2}).format(s)}catch{return`$${s.toFixed(2)}`}}function Av(t,e=!0){return typeof t!="number"||!Number.isFinite(t)?"":YO(t,e).toFixed(2)}function k4(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 S4(r,e)}function Ap({family:t,bodyWeight:e=400,headingWeight:n=700,compact:r=!1}){const s=`"${t.replace(/"/g,"")}", ui-sans-serif, sans-serif`,i={fontFamily:s,fontWeight:n},o={fontFamily:s,fontWeight:e};return m.jsxs("div",{className:"vertebr-font-preview-sample","data-compact":r?"true":void 0,children:[m.jsx("span",{className:"vertebr-font-preview-eyebrow",style:i,children:"Eyebrow label"}),m.jsx("strong",{className:"vertebr-font-preview-heading",style:i,children:"The quick brown fox"}),m.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:m.jsxs(m.Fragment,{children:[m.jsxs("p",{className:"vertebr-font-preview-alphabet",style:o,children:["ABCDEFGHIJKLMNOPQRSTUVWXYZ",m.jsx("br",{}),"abcdefghijklmnopqrstuvwxyz",m.jsx("br",{}),"0123456789"]}),m.jsxs("div",{className:"vertebr-font-preview-weights",style:o,children:[m.jsx("span",{style:{fontWeight:400},children:"Regular 400"}),m.jsx("span",{style:{fontWeight:600},children:"Semibold 600"}),m.jsx("span",{style:{fontWeight:700},children:"Bold 700"})]})]})]})}function XO({items:t,apiBase:e="/admin/api"}){const n=E.useId().replace(/:/g,""),r=E.useMemo(()=>YH(t,e),[t,e]);return E.useEffect(()=>{const s=r.map(l=>tO(l)).join("");if(!s)return;const i=s.match(/url\("([^"]+)"\)/)?.[1]??null;console.info("[mm:fonts] FontFaceInjector",{items:r.length,cssRules:(s.match(/@font-face/g)??[]).length,apiBase:e,sampleUrl:i,usesFirebase:s.includes("firebasestorage.googleapis.com")});const o=document.createElement("style");return o.id=`vertebr-font-faces-${n}`,o.textContent=s,document.head.appendChild(o),()=>{o.remove()}},[r,n]),null}function Yu(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 C4({id:t,value:e,label:n,description:r,readOnly:s,fonts:i,loading:o,onChange:l,onRefreshFonts:u,fontApiBase:d="/admin/api"}){const[h,g]=E.useState(!1),[y,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=(N=!1)=>{N&&y!==x.current&&l(x.current),g(!1)},C=N=>{b(N),l(N)},A=E.useMemo(()=>i.find(N=>N.id===S)??null,[i,S]),R=E.useMemo(()=>y===""?null:i.find(N=>N.id===y)??null,[i,y]),_=E.useMemo(()=>{const N=[],M=new Set;for(const O of[A,R])!O||M.has(O.id)||(M.add(O.id),N.push(O));return N},[R,A]);return m.jsxs("div",{className:"vertebr-font-picker",children:[m.jsx(XO,{items:_,apiBase:d}),m.jsxs("div",{className:"vertebr-font-picker-current",children:[m.jsxs("div",{children:[m.jsx("strong",{children:A?.label??"Default system fonts"}),A?m.jsx("span",{children:A.family}):m.jsx("span",{children:"Manrope / Syne until a library font is chosen"})]}),s?m.jsx("span",{id:t,className:"vertebr-font-picker-ro-anchor"}):m.jsx("button",{id:t,type:"button",className:"vertebr-btn",onClick:()=>g(!0),children:"Choose font"})]}),A?m.jsx("div",{className:"vertebr-font-picker-preview",children:m.jsx(Ap,{family:A.family,bodyWeight:Yu(A,"body"),headingWeight:Yu(A,"heading"),compact:!0})}):null,h?m.jsx("div",{className:"vertebr-font-picker-modal-backdrop",onClick:()=>k(!0),children:m.jsxs("div",{className:"vertebr-font-picker-modal",role:"dialog","aria-labelledby":`${t}-font-picker-title`,onClick:N=>N.stopPropagation(),children:[m.jsxs("div",{className:"vertebr-font-picker-modal-head",children:[m.jsxs("div",{children:[m.jsx("h3",{id:`${t}-font-picker-title`,children:n??"Choose a font"}),r?m.jsx("p",{children:r}):null]}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>k(!0),children:"Close"})]}),o?m.jsx("div",{className:"vertebr-empty",children:"Loading fonts…"}):i.length===0?m.jsx("div",{className:"vertebr-empty",children:"No fonts in the library yet. Open Font Library to upload or add Google Fonts."}):m.jsxs("div",{className:"vertebr-font-picker-modal-body",children:[m.jsx("div",{className:"vertebr-font-picker-grid-scroll",children:m.jsxs("div",{className:"vertebr-font-picker-grid",children:[m.jsxs("button",{type:"button",className:"vertebr-font-picker-option","data-active":y===""||void 0,onClick:()=>C(""),children:[m.jsx("strong",{children:"Default"}),m.jsx("span",{children:"Manrope / Syne"})]}),i.map(N=>m.jsxs("button",{type:"button",className:"vertebr-font-picker-option","data-active":N.id===y||void 0,style:{fontFamily:`"${N.family}", ui-sans-serif, sans-serif`,fontWeight:Yu(N,"heading")},onClick:()=>C(N.id),children:[m.jsx("strong",{children:N.label}),m.jsx("span",{children:N.family}),m.jsx("em",{children:"The quick brown fox"})]},N.id))]})}),m.jsxs("aside",{className:"vertebr-font-picker-detail",children:[m.jsx("p",{className:"vertebr-font-picker-detail-label",children:"Preview"}),y===""?m.jsx(Ap,{family:"Manrope",bodyWeight:400,headingWeight:700}):R?m.jsx(Ap,{family:R.family,bodyWeight:Yu(R,"body"),headingWeight:Yu(R,"heading")}):m.jsx("div",{className:"vertebr-empty",children:"Select a font to preview."})]})]}),m.jsxs("div",{className:"vertebr-font-picker-modal-actions",children:[m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>k(!0),children:"Cancel"}),m.jsx("button",{type:"button",className:"vertebr-btn",disabled:o,onClick:()=>k(!1),children:"Done"})]})]})}):null]})}var Rv={exports:{}},Nv={};var X_;function E4(){if(X_)return Nv;X_=1;var t=tf();function e(g,y){return g===y&&(g!==0||1/g===1/y)||g!==g&&y!==y}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function l(g,y){var b=y(),x=r({inst:{value:b,getSnapshot:y}}),S=x[0].inst,k=x[1];return i(function(){S.value=b,S.getSnapshot=y,u(S)&&k({inst:S})},[g,b,y]),s(function(){return u(S)&&k({inst:S}),g(function(){u(S)&&k({inst:S})})},[g]),o(b),b}function u(g){var y=g.getSnapshot;g=g.value;try{var b=y();return!n(g,b)}catch{return!0}}function d(g,y){return y()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:l;return Nv.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Nv}var J_;function JO(){return J_||(J_=1,Rv.exports=E4()),Rv.exports}var QO=JO();function Bn(t){this.content=t}Bn.prototype={constructor:Bn,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new Bn(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Bn(n)},addToStart:function(t,e){return new Bn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Bn(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new Bn(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Bn.from(t),t.size?new Bn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Bn.from(t),t.size?new Bn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Bn.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}};Bn.from=function(t){if(t instanceof Bn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Bn(e)};function ej(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){let o=s.text,l=i.text,u=0;for(;o[u]==l[u];u++)n++;return u&&u<o.length&&u<l.length&&rj(o.charCodeAt(u-1))&&nj(o.charCodeAt(u))&&n--,n}if(s.content.size||i.content.size){let o=ej(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function tj(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),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 d=o.text,h=l.text,g=d.length,y=h.length;for(;g>0&&y>0&&d[g-1]==h[y-1];)g--,y--,n--,r--;return g&&y&&g<d.length&&rj(d.charCodeAt(g-1))&&nj(d.charCodeAt(g))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let d=tj(o.content,l.content,n-1,r-1);if(d)return d}n-=u,r-=u}}function nj(t){return t>=56320&&t<57344}function rj(t){return t>=55296&&t<56320}class fe{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let u=this.content[o],d=l+u.nodeSize;if(d>e&&r(u,s+l,i||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,s+h)}l=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,u)=>{let d=l.isText?l.text.slice(Math.max(e,u)-u,n-u):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&d||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=d},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new fe(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],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),s+=l.nodeSize),o=u}return new fe(r,s)}cutByIndex(e,n){return e==n?fe.empty:e==0&&n==this.content.length?this:new fe(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new fe(s,i)}addToStart(e){return new fe([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new fe(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return ej(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return tj(this,e,n,r)}findIndex(e){if(e==0)return Bh(0,e);if(e==this.size)return Bh(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?Bh(n+1,i):Bh(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return fe.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return fe.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return fe.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new fe(n||e,r)}static from(e){if(!e)return fe.empty;if(e instanceof fe)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new fe([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}fe.empty=new fe([],0);const Mv={index:0,offset:0};function Bh(t,e){return Mv.index=t,Mv.offset=e,Mv}function im(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(!im(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!im(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Pt=class cx{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&im(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return cx.none;if(e instanceof cx)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Pt.none=[];class Hd extends Error{}class Re{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=ij(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new Re(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Re(sj(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 Re.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Re(fe.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new Re(e,r,s)}}Re.empty=new Re(fe.empty,0,0);function sj(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.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,i.copy(sj(i.content,e-s-1,n-s-1)))}function ij(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),u=t.maybeChild(o);if(l==e||u.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let d=ij(u.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,u);return d&&t.replaceChild(o,u.copy(d))}function T4(t,e,n){if(n.openStart>t.depth)throw new Hd("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Hd("Inconsistent open depths");return oj(t,e,n,0)}function oj(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=oj(t,e,n,r+1);return i.copy(i.content.replaceChild(s,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 Ga(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=_4(n,t);return Ga(i,lj(t,o,l,e,r))}else return Ga(i,om(t,e,r))}function aj(t,e){if(!e.type.compatibleContent(t.type))throw new Hd("Cannot join "+e.type.name+" onto "+t.type.name)}function ux(t,e,n){let r=t.node(n);return aj(r,e.node(n)),r}function qa(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 vd(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(qa(t.nodeAfter,r),i++));for(let l=i;l<o;l++)qa(s.child(l),r);e&&e.depth==n&&e.textOffset&&qa(e.nodeBefore,r)}function Ga(t,e){if(!t.type.validContent(e))throw new Hd("Invalid content for node "+t.type.name);return t.copy(e)}function lj(t,e,n,r,s){let i=t.depth>s&&ux(t,e,s+1),o=r.depth>s&&ux(n,r,s+1),l=[];return vd(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(aj(i,o),qa(Ga(i,lj(t,e,n,r,s+1)),l)):(i&&qa(Ga(i,om(t,e,s+1)),l),vd(e,n,s,l),o&&qa(Ga(o,om(n,r,s+1)),l)),vd(r,null,s,l),new fe(l)}function om(t,e,n){let r=[];if(vd(null,t,n,r),t.depth>n){let s=ux(t,e,n+1);qa(Ga(s,om(t,e,n+1)),r)}return vd(e,null,n,r),new fe(r)}function _4(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(fe.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class Ud{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Pt.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new am(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:u}=o.content.findIndex(i),d=i-u;if(r.push(o,l,s+u),!d||(o=o.child(l),o.isText))break;i=d-1,s+=u+1}return new Ud(n,r,i)}static resolveCached(e,n){let r=Q_.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else Q_.set(e,r=new A4);let s=r.elts[r.i]=Ud.resolve(e,n);return r.i=(r.i+1)%R4,s}}class A4{constructor(){this.elts=[],this.i=0}}const R4=12,Q_=new WeakMap;class am{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 N4=Object.create(null);let qo=class dx{constructor(e,n,r,s=Pt.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||fe.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&im(this.attrs,n||e.defaultAttrs||N4)&&Pt.sameSet(this.marks,r||Pt.none)}copy(e=null){return e==this.content?this:new dx(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new dx(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 Re.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),d=s.node(o).content.cut(s.pos-l,i.pos-l);return new Re(d,s.depth-o,i.depth-o)}replace(e,n,r){return T4(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return Ud.resolveCached(this,e)}resolveNoCache(e){return Ud.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),cj(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=fe.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let u=s;u<i;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.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=Pt.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(!Pt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=fe.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};qo.prototype.text=void 0;class lm extends qo{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):cj(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 lm(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new lm(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 cj(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class tl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new M4(e,n);if(r.next==null)return tl.empty;let s=uj(r);r.next&&r.err("Unexpected trailing text");let i=z4(P4(s));return $4(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let u=o.matchFragment(e,r);if(u&&(!n||u.validEnd))return fe.from(l.map(d=>d.createAndFill()));for(let d=0;d<o.next.length;d++){let{type:h,next:g}=o.next[d];if(!(h.isText||h.hasRequiredAttrs())&&s.indexOf(g)==-1){s.push(g);let y=i(g,l.concat(h));if(y)return y}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:u}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||u.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
|
|
65
|
+
`)}}tl.empty=new tl(!0);class M4{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 uj(t){let e=[];do e.push(O4(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function O4(t){let e=[];do e.push(j4(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function j4(t){let e=L4(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=D4(t,e);else break;return e}function eA(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function D4(t,e){let n=eA(t),r=n;return t.eat(",")&&(t.next!="}"?r=eA(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function I4(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function L4(t){if(t.eat("(")){let e=uj(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=I4(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 P4(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,u){let d={term:u,to:l};return e[o].push(d),d}function s(o,l){o.forEach(u=>u.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((u,d)=>u.concat(i(d,l)),[]);if(o.type=="seq")for(let u=0;;u++){let d=i(o.exprs[u],l);if(u==o.exprs.length-1)return d;s(d,l=n())}else if(o.type=="star"){let u=n();return r(l,u),s(i(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return s(i(o.expr,l),u),s(i(o.expr,u),u),[r(u)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let u=l;for(let d=0;d<o.min;d++){let h=n();s(i(o.expr,u),h),u=h}if(o.max==-1)s(i(o.expr,u),u);else for(let d=o.min;d<o.max;d++){let h=n();r(u,h),s(i(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 dj(t,e){return e-t}function tA(t,e){let n=[];return r(e),n.sort(dj);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:u}=i[o];!l&&n.indexOf(u)==-1&&r(u)}}}function z4(t){let e=Object.create(null);return n(tA(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:u})=>{if(!l)return;let d;for(let h=0;h<s.length;h++)s[h][0]==l&&(d=s[h][1]);tA(t,u).forEach(h=>{d||s.push([l,d=[]]),d.indexOf(h)==-1&&d.push(h)})})});let i=e[r.join(",")]=new tl(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(dj);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function $4(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:u,next:d}=s.next[l];o.push(u.name),i&&!(u.isText||u.hasRequiredAttrs())&&(i=!1),r.indexOf(d)==-1&&r.push(d)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function fj(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 hj(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function pj(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in t)t[s].validate&&t[s].validate(e[s])}function mj(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new V4(t,r,e[r]);return n}let nA=class gj{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=mj(e,r.attrs),this.defaultAttrs=fj(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==tl.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:hj(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new qo(this,this.computeAttrs(e),fe.from(n),Pt.setFrom(r))}createChecked(e=null,n,r){return n=fe.from(n),this.checkContent(n),new qo(this,this.computeAttrs(e),n,Pt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=fe.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(fe.empty,!0);return i?new qo(this,e,n.append(i),Pt.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){pj(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:Pt.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new gj(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function B4(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class V4{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?B4(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class yg{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=mj(e,s.attrs),this.excluded=null;let i=fj(this.attrs);this.instance=i?new Pt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Pt(this,hj(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new yg(i,s++,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){pj(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class yj{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Bn.from(e.nodes),n.marks=Bn.from(e.marks||{}),this.nodes=nA.compile(this.spec.nodes,this),this.marks=yg.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=tl.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?rA(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:rA(this,o.split(" "))}this.nodeFromJSON=s=>qo.fromJSON(this,s),this.markFromJSON=s=>Pt.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof nA){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new lm(r,r.defaultAttrs,e,Pt.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 rA(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let u=t.marks[l];(s=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function H4(t){return t.tag!=null}function U4(t){return t.style!=null}class zi{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(H4(s))this.tags.push(s);else if(U4(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new iA(this,n,!1);return r.addAll(e,Pt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new iA(this,n,!0);return r.addAll(e,Pt.none,n.from,n.to),Re.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(G4(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],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(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=oA(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=oA(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new zi(e,zi.schemaRules(e)))}}const bj={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},F4={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},vj={ol:!0,ul:!0},Fd=1,fx=2,xd=4;function sA(t,e,n){return e!=null?(e?Fd:0)|(e==="full"?fx:0):t&&t.whitespace=="pre"?Fd|fx:n&~xd}class Vh{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Pt.none,this.match=i||(o&xd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(fe.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Fd)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=fe.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(fe.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&&!bj.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class iA{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=sA(null,n.preserveWhitespace,0)|(r?xd:0);s?i=new Vh(s.type,s.attrs,Pt.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Vh(null,null,Pt.none,!0,null,o):i=new Vh(e.schema.topNodeType,null,Pt.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&fx?"full":this.localPreserveWS||(s.options&Fd)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
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=s.content[s.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 s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;vj.hasOwnProperty(o)&&this.parser.normalizeLists&&q4(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(u?u.ignore:F4.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 d,h=this.needsBlock;if(bj.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),d=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let g=u&&u.skip?n:this.readStyles(e,n);g&&this.addAll(e,g),d&&this.sync(i),this.needsBlock=h}else{let d=this.readStyles(e,n);d&&this.addElementByRule(e,u,d,u.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
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 s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let u=this.parser.matchStyle(i,o,this,l);if(!u)break;if(u.ignore)return null;if(u.clearMark?n=n.filter(d=>!u.clearMark(d)):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,s){let i,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&&(i=!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(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let u=this.nodes[o],d=u.findWrapping(e);if(d&&(!s||s.length>d.length+l)&&(s=d,i=u,!d.length))break;if(u.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Pt.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):aA(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=sA(e,i,o.options);o.options&xd&&o.content.length==0&&(l|=xd);let u=Pt.none;return r=r.filter(d=>(o.type?o.type.allowsMarkType(d.type):aA(d.type,e))?(u=d.addToSet(u),!1):!0),this.nodes.push(new Vh(e,n,u,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Fd)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,u)=>{for(;l>=0;l--){let d=n[l];if(d==""){if(l==n.length-1||l==0)continue;for(;u>=i;u--)if(o(l-1,u))return!0;return!1}else{let h=u>0||u==0&&s?this.nodes[u].type:r&&u>=i?r.node(u-i).type:null;if(!h||h.name!=d&&!h.isInGroup(d))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 q4(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&vj.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function G4(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function oA(t){let e={};for(let n in t)e[n]=t[n];return e}function aA(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let u=0;u<l.edgeCount;u++){let{type:d,next:h}=l.edge(u);if(d==e||i.indexOf(h)<0&&o(h))return!0}};if(o(s.contentMatch))return!0}}class pl{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Hh(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,u=0;for(;l<i.length&&u<o.marks.length;){let d=o.marks[u];if(!this.marks[d.type.name]){u++;continue}if(!d.eq(i[l][0])||d.type.spec.spanning===!1)break;l++,u++}for(;l<i.length;)s=i.pop()[1];for(;u<o.marks.length;){let d=o.marks[u++],h=this.serializeMark(d,o.isInline,n);h&&(i.push([d,s]),s.appendChild(h.dom),s=h.contentDOM||h.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return Hh(n).createTextNode(e.text);let{dom:r,contentDOM:s}=Rp(Hh(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Rp(Hh(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:Rp(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new pl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=lA(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return lA(e.marks)}}function lA(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Hh(t){return t.document||window.document}const cA=new WeakMap;function W4(t){let e=cA.get(t);return e===void 0&&cA.set(t,e=K4(t)),e}function K4(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Rp(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=W4(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,u=n?t.createElementNS(n,s):t.createElement(s),d=e[1],h=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){h=2;for(let g in d)if(d[g]!=null){let y=g.indexOf(" ");y>0?u.setAttributeNS(g.slice(0,y),g.slice(y+1),d[g]):g=="style"&&u.style?u.style.cssText=d[g]:u.setAttribute(g,d[g])}}for(let g=h;g<e.length;g++){let y=e[g];if(y===0){if(g<e.length-1||g>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else if(typeof y=="string")u.appendChild(t.createTextNode(y));else{let{dom:b,contentDOM:x}=Rp(t,y,n,r);if(u.appendChild(b),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:u,contentDOM:l}}const xj=65535,wj=Math.pow(2,16);function Z4(t,e){return t+e*wj}function uA(t){return t&xj}function Y4(t){return(t-(t&xj))/wj}const Sj=1,kj=2,Np=4,Cj=8;class hx{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Cj)>0}get deletedBefore(){return(this.delInfo&(Sj|Np))>0}get deletedAfter(){return(this.delInfo&(kj|Np))>0}get deletedAcross(){return(this.delInfo&Np)>0}}class zr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&zr.empty)return zr.empty}recover(e){let n=0,r=uA(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+Y4(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let u=this.ranges[l]-(this.inverted?s:0);if(u>e)break;let d=this.ranges[l+i],h=this.ranges[l+o],g=u+d;if(e<=g){let y=d?e==u?-1:e==g?1:n:n,b=u+s+(y<0?0:h);if(r)return b;let x=e==(n<0?u:g)?null:Z4(l/3,e-u),S=e==u?kj:e==g?Sj:Np;return(n<0?e!=u:e!=g)&&(S|=Cj),new hx(b,S,x)}s+=h-d}return r?e+s:new hx(e+s,0,null)}touches(e,n){let r=0,s=uA(n),i=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 d=this.ranges[l+i],h=u+d;if(e<=h&&l==s*3)return!0;r+=this.ranges[l+o]-d}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),u=o+(this.inverted?0:i),d=this.ranges[s+n],h=this.ranges[s+r];e(l,l+d,u,u+h),i+=h-d}}invert(){return new zr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?zr.empty:new zr(e<0?[0,-e,0]:[0,0,e])}}zr.empty=new zr([]);class qd{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new qd(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new qd;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let u=this.getMirror(i);if(u!=null&&u>i&&u<this.to){i=u,e=this._maps[u].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new hx(e,s,null)}}const Ov=Object.create(null);class nr{getMap(){return zr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ov[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 Ov)throw new RangeError("Duplicate use of step JSON ID "+e);return Ov[e]=n,n.prototype.jsonID=e,n}}class xn{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new xn(e,null)}static fail(e){return new xn(null,e)}static fromReplace(e,n,r,s){try{return xn.ok(e.replace(n,r,s))}catch(i){if(i instanceof Hd)return xn.fail(i.message);throw i}}}function Qw(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Qw(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return fe.fromArray(r)}class $o extends nr{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new Re(Qw(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return xn.fromReplace(e,this.from,this.to,i)}invert(){return new _s(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 $o(n.pos,r.pos,this.mark)}merge(e){return e instanceof $o&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new $o(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 $o(n.from,n.to,e.markFromJSON(n.mark))}}nr.jsonID("addMark",$o);class _s extends nr{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 Re(Qw(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return xn.fromReplace(e,this.from,this.to,r)}invert(){return new $o(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 _s(n.pos,r.pos,this.mark)}merge(e){return e instanceof _s&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _s(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 _s(n.from,n.to,e.markFromJSON(n.mark))}}nr.jsonID("removeMark",_s);class Bo extends nr{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return xn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return xn.fromReplace(e,this.pos,this.pos+1,new Re(fe.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Bo(this.pos,n.marks[s]);return new Bo(this.pos,this.mark)}}return new nl(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Bo(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 Bo(n.pos,e.markFromJSON(n.mark))}}nr.jsonID("addNodeMark",Bo);class nl extends nr{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return xn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return xn.fromReplace(e,this.pos,this.pos+1,new Re(fe.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Bo(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new nl(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 nl(n.pos,e.markFromJSON(n.mark))}}nr.jsonID("removeNodeMark",nl);class vn extends nr{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&px(e,this.from,this.to)?xn.fail("Structure replace would overwrite content"):xn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new zr([this.from,this.to-this.from,this.slice.size])}invert(e){return new vn(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&&vn.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new vn(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof vn)||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?Re.empty:new Re(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new vn(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?Re.empty:new Re(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new vn(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 vn(n.from,n.to,Re.fromJSON(e,n.slice),!!n.structure)}}vn.MAP_BIAS=1;nr.jsonID("replace",vn);class Rn extends nr{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(px(e,this.from,this.gapFrom)||px(e,this.gapTo,this.to)))return xn.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return xn.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?xn.fromReplace(e,this.from,this.to,r):xn.fail("Content does not fit in gap")}getMap(){return new zr([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 Rn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Rn(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Rn(n.from,n.to,n.gapFrom,n.gapTo,Re.fromJSON(e,n.slice),n.insert,!!n.structure)}}nr.jsonID("replaceAround",Rn);function px(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function X4(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(u,d,h)=>{if(!u.isInline)return;let g=u.marks;if(!r.isInSet(g)&&h.type.allowsMarkType(r.type)){let y=Math.max(d,e),b=Math.min(d+u.nodeSize,n),x=r.addToSet(g);for(let S=0;S<g.length;S++)g[S].isInSet(x)||(o&&o.to==y&&o.mark.eq(g[S])?o.to=b:s.push(o=new _s(y,b,g[S])));l&&l.to==y?l.to=b:i.push(l=new $o(y,b,r))}}),s.forEach(u=>t.step(u)),i.forEach(u=>t.step(u))}function J4(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let u=null;if(r instanceof yg){let d=o.marks,h;for(;h=r.isInSet(d);)(u||(u=[])).push(h),d=h.removeFromSet(d)}else r?r.isInSet(o.marks)&&(u=[r]):u=o.marks;if(u&&u.length){let d=Math.min(l+o.nodeSize,n);for(let h=0;h<u.length;h++){let g=u[h],y;for(let b=0;b<s.length;b++){let x=s[b];x.step==i-1&&g.eq(s[b].style)&&(y=x)}y?(y.to=d,y.step=i):s.push({style:g,from:Math.max(l,e),to:d,step:i})}}}),s.forEach(o=>t.step(new _s(o.from,o.to,o.style)))}function eS(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let u=0;u<i.childCount;u++){let d=i.child(u),h=l+d.nodeSize,g=r.matchType(d.type);if(!g)o.push(new vn(l,h,Re.empty));else{r=g;for(let y=0;y<d.marks.length;y++)n.allowsMarkType(d.marks[y].type)||t.step(new _s(l,h,d.marks[y]));if(s&&d.isText&&n.whitespace!="pre"){let y,b=/\r?\n|\r/g,x;for(;y=b.exec(d.text);)x||(x=new Re(fe.from(n.schema.text(" ",n.allowedMarks(d.marks))),0,0)),o.push(new vn(l+y.index,l+y.index+y[0].length,x))}}l=h}if(!r.validEnd){let u=r.fillBefore(fe.empty,!0);t.replace(l,l,new Re(u,0,0))}for(let u=o.length-1;u>=0;u--)t.step(o[u])}function Q4(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Xc(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,u=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,u,n))return r;if(r==0||o.type.spec.isolating||!Q4(o,l,u))break;l&&(s=1),u<o.childCount&&(i=1)}return null}function e5(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),u=o,d=l,h=fe.empty,g=0;for(let x=i,S=!1;x>n;x--)S||r.index(x)>0?(S=!0,h=fe.from(r.node(x).copy(h)),g++):u--;let y=fe.empty,b=0;for(let x=i,S=!1;x>n;x--)S||s.after(x+1)<s.end(x)?(S=!0,y=fe.from(s.node(x).copy(y)),b++):d++;t.step(new Rn(u,d,o,l,new Re(h.append(y),g,b),h.size-g,!0))}function tS(t,e,n=null,r=t){let s=t5(t,e),i=s&&n5(r,e);return i?s.map(dA).concat({type:e,attrs:n}).concat(i.map(dA)):null}function dA(t){return{type:t,attrs:null}}function t5(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function n5(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let u=(o.length?o[o.length-1]:e).contentMatch;for(let d=r;u&&d<s;d++)u=u.matchType(n.child(d).type);return!u||!u.validEnd?null:o}function r5(t,e,n){let r=fe.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=fe.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Rn(s,i,s,i,new Re(r,0,0),n.length,!0))}function s5(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let u=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,u)&&i5(t.doc,t.mapping.slice(i).map(l),r)){let d=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!x?d=!1:!b&&x&&(d=!0)}d===!1&&Tj(t,o,l,i),eS(t,t.mapping.slice(i).map(l,1),r,void 0,d===null);let h=t.mapping.slice(i),g=h.map(l,1),y=h.map(l+o.nodeSize,1);return t.step(new Rn(g,y,g+1,y-1,new Re(fe.from(r.create(u,null,o.marks)),0,0),1,!0)),d===!0&&Ej(t,o,l,i),!1}})}function Ej(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let u=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function Tj(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
|
|
68
|
+
`))}})}function i5(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function o5(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Rn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Re(fe.from(o),0,0),1,!0))}function $i(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let d=s.depth-1,h=n-2;d>i;d--,h--){let g=s.node(d),y=s.index(d);if(g.type.spec.isolating)return!1;let b=g.content.cutByIndex(y,g.childCount),x=r&&r[h+1];x&&(b=b.replaceChild(0,x.type.create(x.attrs)));let S=r&&r[h]||g;if(!g.canReplace(y+1,g.childCount)||!S.type.validContent(b))return!1}let l=s.indexAfter(i),u=r&&r[0];return s.node(i).canReplaceWith(l,l,u?u.type:s.node(i+1).type)}function a5(t,e,n=1,r){let s=t.doc.resolve(e),i=fe.empty,o=fe.empty;for(let l=s.depth,u=s.depth-n,d=n-1;l>u;l--,d--){i=fe.from(s.node(l).copy(i));let h=r&&r[d];o=fe.from(h?h.type.create(h.attrs,o):s.node(l).copy(o))}t.step(new vn(e,e,new Re(i.append(o),n,n),!0))}function la(t,e){let n=t.resolve(e),r=n.index();return _j(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function l5(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function _j(t,e){return!!(t&&e&&!t.isLeaf&&l5(t,e))}function bg(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&_j(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function c5(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let h=o.whitespace=="pre",g=!!o.contentMatch.matchType(s);h&&!g?r=!1:!h&&g&&(r=!0)}let l=t.steps.length;if(r===!1){let h=t.doc.resolve(e+n);Tj(t,h.node(),h.before(),l)}o.inlineContent&&eS(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let u=t.mapping.slice(l),d=u.map(e-n);if(t.step(new vn(d,u.map(e+n,-1),Re.empty,!0)),r===!0){let h=t.doc.resolve(d);Ej(t,h.node(),h.before(),t.steps.length)}return t}function u5(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function Aj(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let 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),d=r.node(o),h=!1;if(i==1)h=d.canReplace(u,u,s);else{let g=d.contentMatchAt(u).findWrapping(s.firstChild.type);h=g&&d.canReplaceWith(u,u,g[0])}if(h)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function vg(t,e,n=e,r=Re.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return Rj(s,i,r)?new vn(e,n,r):new d5(s,i,r).fit()}function Rj(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class d5{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=fe.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=fe.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let u=new Re(i,o,l);return e>-1?new Rn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new vn(r.pos,s.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=jv(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:u,match:d}=this.frontier[l],h,g=null;if(n==1&&(o?d.matchType(o.type)||(g=d.fillBefore(fe.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:g};if(n==2&&o&&(h=d.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:h};if(i&&d.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=jv(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new Re(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=jv(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new Re(ad(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Re(ad(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let S=0;S<i.length;S++)this.openFrontierNode(i[S]);let o=this.unplaced,l=r?r.content:o.content,u=o.openStart-e,d=0,h=[],{match:g,type:y}=this.frontier[n];if(s){for(let S=0;S<s.childCount;S++)h.push(s.child(S));g=g.matchFragment(s)}let b=l.size+e-(o.content.size-o.openEnd);for(;d<l.childCount;){let S=l.child(d),k=g.matchType(S.type);if(!k)break;d++,(d>1||u==0||S.content.size)&&(g=k,h.push(Nj(S.mark(y.allowedMarks(S.marks)),d==1?u:0,d==l.childCount?b:-1)))}let x=d==l.childCount;x||(b=-1),this.placed=ld(this.placed,n,fe.from(h)),this.frontier[n].match=g,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?Re.empty:new Re(ad(o.content,e-1,1),e-1,b<0?o.openEnd:e-1):new Re(ad(o.content,e,d),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Dv(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Dv(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:u,type:d}=this.frontier[l],h=Dv(e,l,d,u,!0);if(!h||h.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ld(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=ld(this.placed,this.depth,fe.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(fe.empty,!0);n.childCount&&(this.placed=ld(this.placed,this.frontier.length,n))}}function ad(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ad(t.firstChild.content,e-1,n)))}function ld(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ld(t.lastChild.content,e-1,n)))}function jv(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Nj(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Nj(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(fe.empty,!0)))),t.copy(r)}function Dv(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!f5(n,i.content,o)?l:null}function f5(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function h5(t){return t.spec.defining||t.spec.definingForContent}function p5(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(Rj(s,i,r))return t.step(new vn(e,n,r));let o=Oj(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let y=s.depth,b=s.pos-1;y>0;y--,b--){let x=s.node(y).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(y)>-1?l=y:s.before(y)==b&&o.splice(1,0,-y)}let u=o.indexOf(l),d=[],h=r.openStart;for(let y=r.content,b=0;;b++){let x=y.firstChild;if(d.push(x),b==r.openStart)break;y=x.content}for(let y=h-1;y>=0;y--){let b=d[y],x=h5(b.type);if(x&&!b.sameMarkup(s.node(Math.abs(l)-1)))h=y;else if(x||!b.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let b=(y+h+1)%(r.openStart+1),x=d[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=s.node(k-1),R=s.index(k-1);if(A.canReplaceWith(R,R,x.type,x.marks))return t.replace(s.before(k),C?i.after(k):n,new Re(Mj(r.content,0,r.openStart,b),b,r.openEnd))}}let g=t.steps.length;for(let y=o.length-1;y>=0&&(t.replace(e,n,r),!(t.steps.length>g));y--){let b=o[y];b<0||(e=s.before(b),n=i.after(b))}}function Mj(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Mj(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(fe.empty,!0))}return t}function m5(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=u5(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new Re(fe.from(r),0,0))}function g5(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.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=s.depth;u>o;u--)s.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=s.depth;u>0&&n==s.start(u);u--)n=s.before(u);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=Oj(r,s);for(let o=0;o<i.length;o++){let l=i[o],u=o==i.length-1;if(u&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(u||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Oj(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class Sc extends nr{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 xn.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return xn.fromReplace(e,this.pos,this.pos+1,new Re(fe.from(s),0,n.isLeaf?0:1))}getMap(){return zr.empty}invert(e){return new Sc(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 Sc(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 Sc(n.pos,n.attr,n.value)}}nr.jsonID("attr",Sc);class Gd extends nr{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return xn.ok(r)}getMap(){return zr.empty}invert(e){return new Gd(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 Gd(n.attr,n.value)}}nr.jsonID("docAttr",Gd);let Dc=class extends Error{};Dc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Dc.prototype=Object.create(Error.prototype);Dc.prototype.constructor=Dc;Dc.prototype.name="TransformError";class nS{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new qd}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Dc(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,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=Re.empty){let s=vg(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new Re(fe.from(r),0,0))}delete(e,n){return this.replace(e,n,Re.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return p5(this,e,n,r),this}replaceRangeWith(e,n,r){return m5(this,e,n,r),this}deleteRange(e,n){return g5(this,e,n),this}lift(e,n){return e5(this,e,n),this}join(e,n=1){return c5(this,e,n),this}wrap(e,n){return r5(this,e,n),this}setBlockType(e,n=e,r,s=null){return s5(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return o5(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Sc(e,n,r)),this}setDocAttribute(e,n){return this.step(new Gd(e,n)),this}addNodeMark(e,n){return this.step(new Bo(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 Pt)n.isInSet(r.marks)&&this.step(new nl(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new nl(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return a5(this,e,n,r),this}addMark(e,n,r){return X4(this,e,n,r),this}removeMark(e,n,r){return J4(this,e,n,r),this}clearIncompatible(e,n,r){return eS(this,e,n,r),this}}const Iv=Object.create(null);class Ye{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new jj(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=Re.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:u,$to:d}=o[l],h=e.mapping.slice(i);e.replaceRange(h.map(u.pos),h.map(d.pos),l?Re.empty:n),l==0&&pA(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],u=e.mapping.slice(r),d=u.map(o.pos),h=u.map(l.pos);i?e.deleteRange(d,h):(e.replaceRangeWith(d,h,n),pA(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new $e(e):pc(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?pc(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):pc(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Br(e.node(0))}static atStart(e){return pc(e,e,0,0,1)||new Br(e)}static atEnd(e){return pc(e,e,e.content.size,e.childCount,-1)||new Br(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Iv[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 Iv)throw new RangeError("Duplicate use of selection JSON ID "+e);return Iv[e]=n,n.prototype.jsonID=e,n}getBookmark(){return $e.between(this.$anchor,this.$head).getBookmark()}}Ye.prototype.visible=!0;class jj{constructor(e,n){this.$from=e,this.$to=n}}let fA=!1;function hA(t){!fA&&!t.parent.inlineContent&&(fA=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class $e extends Ye{constructor(e,n=e){hA(e),hA(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Ye.near(r);let s=e.resolve(n.map(this.anchor));return new $e(s.parent.inlineContent?s:r,r)}replace(e,n=Re.empty){if(super.replace(e,n),n==Re.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof $e&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new xg(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 $e(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=Ye.findFrom(n,r,!0)||Ye.findFrom(n,-r,!0);if(i)n=i.$head;else return Ye.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Ye.findFrom(e,-r,!0)||Ye.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new $e(e,n)}}Ye.jsonID("text",$e);class xg{constructor(e,n){this.anchor=e,this.head=n}map(e){return new xg(e.map(this.anchor),e.map(this.head))}resolve(e){return $e.between(e.resolve(this.anchor),e.resolve(this.head))}}class Fe extends Ye{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?Ye.near(i):new Fe(i)}content(){return new Re(fe.from(this.node),0,0)}eq(e){return e instanceof Fe&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new rS(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Fe(e.resolve(n.anchor))}static create(e,n){return new Fe(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Fe.prototype.visible=!1;Ye.jsonID("node",Fe);class rS{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new xg(r,r):new rS(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Fe.isSelectable(r)?new Fe(n):Ye.near(n)}}class Br extends Ye{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Re.empty){if(n==Re.empty){e.delete(0,e.doc.content.size);let r=Ye.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Br(e)}map(e){return new Br(e)}eq(e){return e instanceof Br}getBookmark(){return y5}}Ye.jsonID("all",Br);const y5={map(){return this},resolve(t){return new Br(t)}};function pc(t,e,n,r,s,i=!1){if(e.inlineContent)return $e.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&Fe.isSelectable(l))return Fe.create(t,n-(s<0?l.nodeSize:0))}else{let u=pc(t,l,n+s,s<0?l.childCount:0,s,i);if(u)return u}n+=l.nodeSize*s}return null}function pA(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof vn||s instanceof Rn))return;let i=t.mapping.maps[r],o;i.forEach((l,u,d,h)=>{o==null&&(o=h)}),t.setSelection(Ye.near(t.doc.resolve(o),n))}const mA=1,Uh=2,gA=4;class b5 extends nS{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|mA)&~Uh,this.storedMarks=null,this}get selectionSet(){return(this.updated&mA)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Uh,this}ensureMarks(e){return Pt.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&Uh)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Uh,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)||Pt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ye.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=gA,this}get scrolledIntoView(){return(this.updated&gA)>0}}function yA(t,e){return!e||!t?t:t.bind(e)}class cd{constructor(e,n,r){this.name=e,this.init=yA(n.init,r),this.apply=yA(n.apply,r)}}const v5=[new cd("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new cd("selection",{init(t,e){return t.selection||Ye.atStart(e.doc)},apply(t){return t.selection}}),new cd("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new cd("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Lv{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=v5.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 cd(r.key,r.spec.state,r))})}}class $a{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let u=s?s[o].n:0,d=s?s[o].state:this,h=u<n.length&&l.spec.appendTransaction.call(l,u?n.slice(u):n,d,r);if(h&&r.filterTransaction(h,o)){if(h.setMeta("appendedTransaction",e),!s){s=[];for(let g=0;g<this.config.plugins.length;g++)s.push(g<o?{state:r,n:n.length}:{state:this,n:0})}n.push(h),r=r.applyInner(h),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new $a(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new b5(this)}static create(e){let n=new Lv(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new $a(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Lv(this.schema,e.plugins),r=n.fields,s=new $a(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Lv(e.schema,e.plugins),i=new $a(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=qo.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=Ye.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let u=r[l],d=u.spec.state;if(u.key==o.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=d.fromJSON.call(u,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Dj(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Dj(s,e,{})),n[r]=s}return n}class Bt{constructor(e){this.spec=e,this.props={},e.props&&Dj(e.props,this,this.props),this.key=e.key?e.key.key:Ij("plugin")}getState(e){return e[this.key]}}const Pv=Object.create(null);function Ij(t){return t in Pv?t+"$"+ ++Pv[t]:(Pv[t]=0,t+"$")}class on{constructor(e="key"){this.key=Ij(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Lj=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Pj(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const zj=(t,e,n)=>{let r=Pj(t,n);if(!r)return!1;let s=sS(r);if(!s){let o=r.blockRange(),l=o&&Xc(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Wj(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Ic(i,"end")||Fe.isSelectable(i)))for(let o=r.depth;;o--){let l=vg(t.doc,r.before(o),r.after(o),Re.empty);if(l&&l.slice.size<l.to-l.from){if(e){let u=t.tr.step(l);u.setSelection(Ic(i,"end")?Ye.findFrom(u.doc.resolve(u.mapping.map(s.pos,-1)),-1):Fe.create(u.doc,s.pos-i.nodeSize)),e(u.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},x5=(t,e,n)=>{let r=Pj(t,n);if(!r)return!1;let s=sS(r);return s?$j(t,s,e):!1},w5=(t,e,n)=>{let r=Vj(t,n);if(!r)return!1;let s=iS(r);return s?$j(t,s,e):!1};function $j(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let h=s.lastChild;if(!h)return!1;s=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 d=vg(t.doc,i,u,Re.empty);if(!d||d.from!=i||d instanceof vn&&d.slice.size>=u-i)return!1;if(n){let h=t.tr.step(d);h.setSelection($e.create(h.doc,i)),n(h.scrollIntoView())}return!0}function Ic(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 Bj=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=sS(r)}let o=i&&i.nodeBefore;return!o||!Fe.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Fe.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function sS(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 Vj(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Hj=(t,e,n)=>{let r=Vj(t,n);if(!r)return!1;let s=iS(r);if(!s)return!1;let i=s.nodeAfter;if(Wj(t,s,e,1))return!0;if(r.parent.content.size==0&&(Ic(i,"start")||Fe.isSelectable(i))){let o=vg(t.doc,r.before(),r.after(),Re.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ic(i,"start")?Ye.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):Fe.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Uj=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=iS(r)}let o=i&&i.nodeAfter;return!o||!Fe.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Fe.create(t.doc,i.pos)).scrollIntoView()),!0)};function iS(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 S5=(t,e)=>{let n=t.selection,r=n instanceof Fe,s;if(r){if(n.node.isTextblock||!la(t.doc,n.from))return!1;s=n.from}else if(s=bg(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(Fe.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},k5=(t,e)=>{let n=t.selection,r;if(n instanceof Fe){if(n.node.isTextblock||!la(t.doc,n.to))return!1;r=n.to}else if(r=bg(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},C5=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Xc(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},Fj=(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 oS(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 E5=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=oS(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),u=t.tr.replaceWith(l,l,o.createAndFill());u.setSelection(Ye.near(u.doc.resolve(l),1)),e(u.scrollIntoView())}return!0},qj=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof Br||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=oS(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection($e.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Gj=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if($i(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Xc(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function T5(t){return(e,n)=>{if(e.selection instanceof Fe&&e.selection.node.isBlock){let{$from:b}=e.selection;return!b.parentOffset||!$i(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 $e||e.selection instanceof Br)&&r.deleteSelection();let{$from:s}=r.selection,i=r.steps.length,o=[],l,u,d=!1,h=!1;for(let b=s.depth;;b--)if(s.node(b).isBlock){d=s.end(b)==s.pos+(s.depth-b),h=s.start(b)==s.pos-(s.depth-b),u=oS(s.node(b-1).contentMatchAt(s.indexAfter(b-1))),o.unshift(d&&u?{type:u}:null),l=b;break}else{if(b==1)return!1;o.unshift(null)}let g=s.pos,y=$i(r.doc,g,o.length,o);if(y||(o[0]=u?{type:u}:null,y=$i(r.doc,g,o.length,o)),!y)return!1;if(r.split(g,o.length,o),!d&&h&&s.node(l).type!=u){let b=r.mapping.slice(i),x=b.map(s.before(l)),S=r.doc.resolve(x);u&&s.node(l-1).canReplaceWith(S.index(),S.index()+1,u)&&r.setNodeMarkup(b.map(s.before(l)),u)}return n&&n(r.scrollIntoView()),!0}}const _5=T5(),A5=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(Fe.create(t.doc,s))),!0)};function R5(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||la(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Wj(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,u=s.type.spec.isolating||i.type.spec.isolating;if(!u&&R5(t,e,n))return!0;let d=!u&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let b=e.pos+i.nodeSize,x=fe.empty;for(let C=o.length-1;C>=0;C--)x=fe.from(o[C].create(null,x));x=fe.from(s.copy(x));let S=t.tr.step(new Rn(e.pos-1,b,e.pos,b,new Re(x,1,0),o.length,!0)),k=S.doc.resolve(b+2*o.length);k.nodeAfter&&k.nodeAfter.type==s.type&&la(S.doc,k.pos)&&S.join(k.pos),n(S.scrollIntoView())}return!0}let h=i.type.spec.isolating||r>0&&u?null:Ye.findFrom(e,1),g=h&&h.$from.blockRange(h.$to),y=g&&Xc(g);if(y!=null&&y>=e.depth)return n&&n(t.tr.lift(g,y).scrollIntoView()),!0;if(d&&Ic(i,"start",!0)&&Ic(s,"end")){let b=s,x=[];for(;x.push(b),!b.isTextblock;)b=b.lastChild;let S=i,k=1;for(;!S.isTextblock;S=S.firstChild)k++;if(b.canReplace(b.childCount,b.childCount,S.content)){if(n){let C=fe.empty;for(let R=x.length-1;R>=0;R--)C=fe.from(x[R].copy(C));let A=t.tr.step(new Rn(e.pos-x.length,e.pos+i.nodeSize,e.pos+k,e.pos+i.nodeSize-k,new Re(C,x.length,0),0,!0));n(A.scrollIntoView())}return!0}}return!1}function Kj(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection($e.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const N5=Kj(-1),M5=Kj(1);function O5(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&tS(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function bA(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(u,d)=>{if(s)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)s=!0;else{let h=n.doc.resolve(d),g=h.index();s=h.parent.canReplaceWith(g,g+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:u}}=n.selection.ranges[o];i.setBlockType(l,u,t,e)}r(i.scrollIntoView())}return!0}}function aS(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}aS(Lj,zj,Bj);aS(Lj,Hj,Uj);aS(Fj,qj,Gj,_5);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function j5(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return D5(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function D5(t,e,n,r=null){let s=!1,i=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);i=new am(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new am(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=tS(i,n,r,e);return l?(t&&I5(t,e,l,s,n),!0):!1}function I5(t,e,n,r,s){let i=fe.empty;for(let h=n.length-1;h>=0;h--)i=fe.from(n[h].type.create(n[h].attrs,i));t.step(new Rn(e.start-(r?2:0),e.end,e.start,e.end,new Re(i,0,0),n.length,!0));let o=0;for(let h=0;h<n.length;h++)n[h].type==s&&(o=h+1);let l=n.length-o,u=e.start+n.length-(r?2:0),d=e.parent;for(let h=e.startIndex,g=e.endIndex,y=!0;h<g;h++,y=!1)!y&&$i(t.doc,u,l)&&(t.split(u,l),u+=2*l),u+=d.child(h).nodeSize;return t}function L5(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?P5(e,n,t,i):z5(e,n,i):!0:!1}}function P5(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Rn(i-1,o,i,o,new Re(fe.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new am(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=Xc(r);if(l==null)return!1;s.lift(r,l);let u=s.doc.resolve(s.mapping.map(i,-1)-1);return la(s.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&s.join(u.pos),e(s.scrollIntoView()),!0}function z5(t,e,n){let r=t.tr,s=n.parent;for(let b=n.end,x=n.endIndex-1,S=n.startIndex;x>S;x--)b-=s.child(x).nodeSize,r.delete(b-1,b+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,u=n.endIndex==s.childCount,d=i.node(-1),h=i.index(-1);if(!d.canReplace(h+(l?0:1),h+1,o.content.append(u?fe.empty:fe.from(s))))return!1;let g=i.pos,y=g+o.nodeSize;return r.step(new Rn(g-(l?1:0),y+(u?1:0),g+1,y-1,new Re((l?fe.empty:fe.from(s.copy(fe.empty))).append(u?fe.empty:fe.from(s.copy(fe.empty))),l?0:1,u?0:1),l?0:1)),e(r.scrollIntoView()),!0}function $5(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,d=>d.childCount>0&&d.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,u=l.child(o-1);if(u.type!=t)return!1;if(n){let d=u.lastChild&&u.lastChild.type==l.type,h=fe.from(d?t.create():null),g=new Re(fe.from(t.create(null,fe.from(l.type.create(null,h)))),d?3:1,0),y=i.start,b=i.end;n(e.tr.step(new Rn(y-(d?3:1),b,y,b,g,1,!0)).scrollIntoView())}return!0}}const Un=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Lc=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let mx=null;const _i=function(t,e,n){let r=mx||(mx=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},B5=function(){mx=null},rl=function(t,e,n,r){return n&&(vA(t,e,n,r,-1)||vA(t,e,n,r,1))},V5=/^(img|br|input|textarea|hr)$/i;function vA(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:ss(t))){let o=t.parentNode;if(!o||o.nodeType!=1||pf(t)||V5.test(t.nodeName)||t.contentEditable=="false")return!1;e=Un(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?ss(t):0}else return!1}}function ss(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function H5(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=ss(t)}else if(t.parentNode&&!pf(t))e=Un(t),t=t.parentNode;else return null}}function U5(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&&!pf(t))e=Un(t)+1,t=t.parentNode;else return null}}function F5(t,e,n){for(let r=e==0,s=e==ss(t);r||s;){if(t==n)return!0;let i=Un(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==ss(t)}}function pf(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 wg=function(t){return t.focusNode&&rl(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function La(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function q5(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function G5(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(ss(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(ss(r.startContainer),r.startOffset)}}}const Ys=typeof navigator<"u"?navigator:null,xA=typeof document<"u"?document:null,ca=Ys&&Ys.userAgent||"",gx=/Edge\/(\d+)/.exec(ca),Zj=/MSIE \d/.exec(ca),yx=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ca),Cr=!!(Zj||yx||gx),Go=Zj?document.documentMode:yx?+yx[1]:gx?+gx[1]:0,is=!Cr&&/gecko\/(\d+)/i.test(ca);is&&+(/Firefox\/(\d+)/.exec(ca)||[0,0])[1];const bx=!Cr&&/Chrome\/(\d+)/.exec(ca),qn=!!bx,Yj=bx?+bx[1]:0,er=!Cr&&!!Ys&&/Apple Computer/.test(Ys.vendor),Pc=er&&(/Mobile\/\w+/.test(ca)||!!Ys&&Ys.maxTouchPoints>2),ns=Pc||(Ys?/Mac/.test(Ys.platform):!1),Xj=Ys?/Win/.test(Ys.platform):!1,Li=/Android \d/.test(ca),mf=!!xA&&"webkitFontSmoothing"in xA.documentElement.style,W5=mf?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function K5(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 wi(t,e){return typeof t=="number"?t:t[e]}function Z5(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 wA(t,e,n){if(!vx(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Lc(o);continue}let l=o,u=l==i.body,d=u?K5(i):Z5(l),h=0,g=0;if(e.top<d.top+wi(r,"top")?g=-(d.top-e.top+wi(s,"top")):e.bottom>d.bottom-wi(r,"bottom")&&(g=e.bottom-e.top>d.bottom-d.top?e.top+wi(s,"top")-d.top:e.bottom-d.bottom+wi(s,"bottom")),e.left<d.left+wi(r,"left")?h=-(d.left-e.left+wi(s,"left")):e.right>d.right-wi(r,"right")&&(h=e.right-d.right+wi(s,"right")),h||g)if(u)i.defaultView.scrollBy(h,g);else{let b=l.scrollLeft,x=l.scrollTop;g&&(l.scrollTop+=g),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 y=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(y))break;o=y=="absolute"?o.offsetParent:Lc(o)}}function Y5(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let u=l.getBoundingClientRect();if(u.top>=n-20){r=l,s=u.top;break}}return{refDOM:r,refTop:s,stack:Jj(t.dom)}}function Jj(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Lc(r));return e}function X5({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Qj(n,r==0?0:r-e)}function Qj(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let rc=null;function J5(t){if(t.setActive)return t.setActive();if(rc)return t.focus(rc);let e=Jj(t);t.focus(rc==null?{get preventScroll(){return rc={preventScroll:!0},!0}}:void 0),rc||(rc=!1,Qj(e,0))}function eD(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,u,d;for(let h=t.firstChild,g=0;h;h=h.nextSibling,g++){let y;if(h.nodeType==1)y=h.getClientRects();else if(h.nodeType==3)y=_i(h).getClientRects();else continue;for(let b=0;b<y.length;b++){let x=y[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,s=S&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,h.nodeType==1&&S&&(i=g+(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,d={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)&&(i=g+1)}}return!n&&u&&(n=u,s=d,r=0),n&&n.nodeType==3?Q5(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:eD(n,s)}function Q5(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=Eo(r,1);if(o.top!=o.bottom&&lS(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function lS(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function e6(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function t6(t,e,n){let{node:r,offset:s}=eD(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function n6(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!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?s=l.posBefore:(!o&&u.right<r.left||u.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<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;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function tD(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let u=0;u<l.length;u++){let d=l[u];if(lS(e,d))return tD(o,e,d)}}if((i=(i+1)%r)==s)break}return t}function r6(t,e){let n=t.dom.ownerDocument,r,s=0,i=G5(n,e.left,e.top);i&&({node:r,offset:s}=i);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 d=t.dom.getBoundingClientRect();if(!lS(e,d)||(o=tD(t.dom,e,d),!o))return null}if(er)for(let d=o;r&&d;d=Lc(d))d.draggable&&(r=void 0);if(o=e6(o,e),r){if(is&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let h=r.childNodes[s],g;h.nodeName=="IMG"&&(g=h.getBoundingClientRect()).right<=e.left&&g.bottom>e.top&&s++}let d;mf&&s&&r.nodeType==1&&(d=r.childNodes[s-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=n6(t,r,s,e))}l==null&&(l=t6(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:l,inside:u?u.posAtStart-u.border:-1}}function vx(t){return t.top<t.bottom||t.left<t.right}function Eo(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(vx(r))return r}return Array.prototype.find.call(n,vx)||t.getBoundingClientRect()}const s6=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function nD(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=mf||is;if(r.nodeType==3)if(o&&(s6.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let u=Eo(_i(r,s,s),n);if(is&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let d=Eo(_i(r,s-1,s-1),-1);if(d.top==u.top){let h=Eo(_i(r,s,s+1),-1);if(h.top!=u.top)return Xu(h,h.left<d.left)}}return u}else{let u=s,d=s,h=n<0?1:-1;return n<0&&!s?(d++,h=-1):n>=0&&s==r.nodeValue.length?(u--,h=1):n<0?u--:d++,Xu(Eo(_i(r,u,d),h),h<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==ss(r))){let u=r.childNodes[s-1];if(u.nodeType==1)return zv(u.getBoundingClientRect(),!1)}if(i==null&&s<ss(r)){let u=r.childNodes[s];if(u.nodeType==1)return zv(u.getBoundingClientRect(),!0)}return zv(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==ss(r))){let u=r.childNodes[s-1],d=u.nodeType==3?_i(u,ss(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(d)return Xu(Eo(d,1),!1)}if(i==null&&s<ss(r)){let u=r.childNodes[s];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let d=u?u.nodeType==3?_i(u,0,o?0:1):u.nodeType==1?u:null:null;if(d)return Xu(Eo(d,-1),!0)}return Xu(Eo(r.nodeType==3?_i(r):r,-n),n>=0)}function Xu(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 zv(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 rD(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function i6(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return rD(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=nD(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let u;if(l.nodeType==1)u=l.getClientRects();else if(l.nodeType==3)u=_i(l,0,l.nodeValue.length).getClientRects();else continue;for(let d=0;d<u.length;d++){let h=u[d];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 o6=/[\u0590-\u08ac]/;function a6(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!o6.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:rD(t,e,()=>{let{focusNode:u,focusOffset:d,anchorNode:h,anchorOffset:g}=t.domSelectionRange(),y=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&&d==S;try{l.collapse(h,g),u&&(u!=h||d!=g)&&l.extend&&l.extend(u,d)}catch{}return y!=null&&(l.caretBidiLevel=y),k}):r.pos==r.start()||r.pos==r.end()}let SA=null,kA=null,CA=!1;function l6(t,e,n){return SA==e&&kA==n?CA:(SA=e,kA=n,CA=n=="up"||n=="down"?i6(t,e,n):a6(t,e,n))}const as=0,EA=1,Ba=2,Rs=3;class gf{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=as,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 s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>Un(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof iD){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof sD&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Un(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?Un(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let u=this.children[l],d=o+u.size;if(s==-1&&e<=d){let h=o+u.border;if(e>=h&&n<=d-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,h);e=o;for(let g=l;g>0;g--){let y=this.children[g-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){s=Un(y.dom)+1;break}e-=y.size}s==-1&&(s=0)}if(s>-1&&(d>n||l==this.children.length-1)){n=d;for(let h=l+1;h<this.children.length;h++){let g=this.children[h];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(-1)){i=Un(g.dom);break}n+=g.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=d}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),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(i>x&&o<k)return S.setSelection(e-x-S.border,n-x-S.border,r,s);x=k}let l=this.domFromPos(e,e?-1:1),u=n==e?l:this.domFromPos(n,n?-1:1),d=r.root.getSelection(),h=r.domSelectionRange(),g=!1;if((is||er)&&e==n){let{node:b,offset:x}=l;if(b.nodeType==3){if(g=!!(x&&b.nodeValue[x-1]==`
|
|
70
|
+
`),g&&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:Un(k)+1});break}let C=S.pmViewDesc;if(C&&C.node&&C.node.isBlock)break}}else{let S=b.childNodes[x-1];g=S&&(S.nodeName=="BR"||S.contentEditable=="false")}}if(is&&h.focusNode&&h.focusNode!=u.node&&h.focusNode.nodeType==1){let b=h.focusNode.childNodes[h.focusOffset];b&&b.contentEditable=="false"&&(s=!0)}if(!(s||g&&er)&&rl(l.node,l.offset,h.anchorNode,h.anchorOffset)&&rl(u.node,u.offset,h.focusNode,h.focusOffset))return;let y=!1;if((d.extend||e==n)&&!(g&&is)){d.collapse(l.node,l.offset);try{e!=n&&d.extend(u.node,u.offset),y=!0}catch{}}if(!y){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),d.removeAllRanges(),d.addRange(b)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,u=o-i.border;if(e>=l&&n<=u){this.dirty=e==r||n==o?Ba:EA,e==l&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Rs:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ba:Rs}r=o}this.dirty=Ba}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ba:EA;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class sD extends gf{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!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,i=this}matchesWidget(e){return this.dirty==as&&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 c6 extends gf{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Wo extends gf{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=pl.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Wo(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Rs||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Rs&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=as){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=as}}slice(e,n,r){let s=Wo.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=wx(i,n,o,r)),e>0&&(i=wx(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ko extends gf{constructor(e,n,r,s,i,o,l){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],u,d=l&&l(n,i,()=>{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,s),h=d&&d.dom,g=d&&d.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:g}=pl.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!g&&!n.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),n.type.spec.draggable&&(h.draggable=!0));let y=h;return h=lD(h,r,n),d?u=new u6(e,n,r,s,h,g||null,y,d):n.isText?new Sg(e,n,r,s,h,y):new Ko(e,n,r,s,h,g||null,y)}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 s=this.children[r];if(this.dom.contains(s.dom.parentNode)){n.contentElement=s.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(s=>s.nodeType==1&&e.indexOf(s.parentNode)<0&&this.dom.contains(s));r?n.contentElement=r:n.getContent=()=>fe.empty}}return n}matchesNode(e,n,r){return this.dirty==as&&e.eq(this.node)&&cm(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,u=new f6(this,o&&o.node,e);m6(this.node,this.innerDeco,(d,h,g)=>{d.spec.marks?u.syncToMarks(d.spec.marks,r,e,h):d.type.side>=0&&!g&&u.syncToMarks(h==this.node.childCount?Pt.none:this.node.child(h).marks,r,e,h),u.placeWidget(d,e,s)},(d,h,g,y)=>{u.syncToMarks(d.marks,r,e,y);let b;u.findNodeMatch(d,h,g,y)||l&&e.state.selection.from>s&&e.state.selection.to<s+d.nodeSize&&(b=u.findIndexWithChild(i.node))>-1&&u.updateNodeAt(d,h,g,b,e)||u.updateNextNode(d,h,g,e,y,s)||u.addNode(d,h,g,e,s),s+=d.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==Ba)&&(o&&this.protectLocalComposition(e,o),oD(this.contentDOM,this.children,e),Pc&&g6(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof $e)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=y6(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new c6(this,i,n,s);e.input.compositionNodes.push(o),this.children=wx(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Rs||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=as}updateOuterDeco(e){if(cm(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=aD(this.dom,this.nodeDOM,xx(this.outerDeco,this.node,n),xx(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 TA(t,e,n,r,s){lD(r,e,t);let i=new Ko(void 0,t,e,n,r,r,r);return i.contentDOM&&i.updateChildren(s,0),i}class Sg extends Ko{constructor(e,n,r,s,i,o){super(e,n,r,s,i,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,s){return this.dirty==Rs||this.dirty!=as&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=as||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=as,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new Sg(this.parent,s,this.outerDeco,this.innerDeco,i,i)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Rs)}get domAtom(){return!1}isText(e){return this.node.text==e}}class iD extends gf{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==as&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class u6 extends Ko{constructor(e,n,r,s,i,o,l,u){super(e,n,r,s,i,o,l),this.spec=u}update(e,n,r,s){if(this.dirty==Rs)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function oD(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=_A(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof Wo){let u=r?r.previousSibling:t.lastChild;oD(o.contentDOM,o.children,n),r=u?u.nextSibling:t.firstChild}}for(;r;)r=_A(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const wd=function(t){t&&(this.nodeName=t)};wd.prototype=Object.create(null);const Va=[new wd];function xx(t,e,n){if(t.length==0)return Va;let r=n?Va[0]:new wd,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new wd(o.nodeName));for(let l in o){let u=o[l];u!=null&&(n&&s.length==1&&s.push(r=new wd(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 s}function aD(t,e,n,r){if(n==Va&&r==Va)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let u;l&&l.nodeName==o.nodeName&&s!=t&&(u=s.parentNode)&&u.nodeName.toLowerCase()==o.nodeName||(u=document.createElement(o.nodeName),u.pmIsDeco=!0,u.appendChild(s),l=Va[0]),s=u}d6(s,l||Va[0],o)}return s}function d6(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function lD(t,e,n){return aD(t,t,Va,xx(e,n,t.nodeType!=1))}function cm(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 _A(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class f6{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=h6(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=as,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,d=this.top.children.length;s<this.preMatch.index&&(d=Math.min(this.index+3,d));for(let h=this.index;h<d;h++){let g=this.top.children[h];if(g.matchesMark(e[o])&&!this.isLocked(g.dom)){u=h;break}}if(u<0&&this.index<this.top.children.length){let h=this.top.children[this.index];h instanceof Wo&&h.dirty!=Rs&&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=Wo.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,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=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 d=this.top.children[l];if(d.matchesNode(e,n,r)&&!this.preMatch.matched.has(d)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Rs&&o.dom==o.contentDOM&&(o.dirty=Ba),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let u=this.top.children[l];if(u instanceof Ko){let d=this.preMatch.matched.get(u);if(d!=null&&d!=i)return!1;let h=u.dom,g,y=this.isLocked(h)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=Rs&&cm(n,u.outerDeco));if(!y&&u.update(e,n,r,s))return this.destroyBetween(this.index,l),u.dom!=h&&(this.changed=!0),this.index++,!0;if(!y&&(g=this.recreateWrapper(u,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=g,g.contentDOM&&(g.dirty=Ba,g.updateChildren(s,o+1),g.dirty=as),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!cm(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Ko.create(this.top,n,r,s,i,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,s,i){let o=Ko.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new sD(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Wo;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Sg)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((er||qn)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new iD(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function h6(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let d=n.children[r-1];if(d instanceof Wo)n=d,r=d.children.length;else{l=d,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(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function p6(t,e){return t.type.side-e.type.side}function m6(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let d=0;d<t.childCount;d++){let h=t.child(d);r(h,s,e.forChild(i,h),d),i+=h.nodeSize}return}let o=0,l=[],u=null;for(let d=0;;){let h,g;for(;o<s.length&&s[o].to==i;){let k=s[o++];k.widget&&(h?(g||(g=[h])).push(k):h=k)}if(h)if(g){g.sort(p6);for(let k=0;k<g.length;k++)n(g[k],d,!!u)}else n(h,d,!!u);let y,b;if(u)b=-1,y=u,u=null;else if(d<t.childCount)b=d,y=t.child(d++);else break;for(let k=0;k<l.length;k++)l[k].to<=i&&l.splice(k--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let x=i+y.nodeSize;if(y.isText){let k=x;o<s.length&&s[o].from<k&&(k=s[o].from);for(let C=0;C<l.length;C++)l[C].to<k&&(k=l[C].to);k<x&&(u=y.cut(k-i),y=y.cut(0,k-i),x=k,b=-1)}else for(;o<s.length&&s[o].to<x;)o++;let S=y.isInline&&!y.isLeaf?l.filter(k=>!k.inline):l.slice();r(y,S,e.forChild(i,y),b),i=x}}function g6(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 y6(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let u=o.text;for(;s<t.childCount;){let d=t.child(s++);if(i+=d.nodeSize,!d.isText)break;u+=d.text}if(i>=n){if(i>=r&&u.slice(r-e.length-l,r-l)==e)return r-e.length;let d=l<r?u.lastIndexOf(e,r-l-1):-1;if(d>=0&&d+e.length+l>=n)return l+d;if(n==r&&u.length>=r+e.length-l&&u.slice(r-l,r-l+e.length)==e)return r}}return-1}function wx(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],d=l,h=l+=u.size;d>=n||h<=e?i.push(u):(d<e&&i.push(u.slice(0,e-d,r)),s&&(i.push(s),s=void 0),h>n&&i.push(u.slice(n-d,u.size,r)))}return i}function cS(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),u,d;if(wg(n)){for(u=o;s&&!s.node;)s=s.parent;let g=s.node;if(s&&g.isAtom&&Fe.isSelectable(g)&&s.parent&&!(g.isInline&&F5(n.focusNode,n.focusOffset,s.dom))){let y=s.posBefore;d=new Fe(o==y?l:r.resolve(y))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let g=o,y=o;for(let b=0;b<n.rangeCount;b++){let x=n.getRangeAt(b);g=Math.min(g,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),y=Math.max(y,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(g<0)return null;[u,o]=y==t.state.selection.anchor?[y,g]:[g,y],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(!d){let g=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;d=uS(t,h,l,g)}return d}function cD(t){return t.editable?t.hasFocus():dD(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Bi(t,e=!1){let n=t.state.selection;if(uD(t,n),!cD(t))return;let r=t.input.mouseDown;if(!e&&qn&&r){let s=t.domSelectionRange(),i=t.domObserver.currentSelection;if(s.anchorNode&&i.anchorNode&&rl(s.anchorNode,s.anchorOffset,i.anchorNode,i.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)v6(t);else{let{anchor:s,head:i}=n,o,l;AA&&!(n instanceof $e)&&(n.$from.parent.inlineContent||(o=RA(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=RA(t,n.to))),t.docView.setSelection(s,i,t,e),AA&&(o&&NA(o),l&&NA(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&b6(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const AA=er||qn&&Yj<63;function RA(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(er&&s&&s.contentEditable=="false")return $v(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return $v(s);if(i)return $v(i)}}function $v(t){return t.contentEditable="true",er&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function NA(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function b6(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!cD(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function v6(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Un(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Cr&&Go<=11&&(n.disabled=!0,n.disabled=!1)}function uD(t,e){if(e instanceof Fe){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(MA(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else MA(t)}function MA(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function uS(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||$e.between(e,n,r)}function OA(t){return t.editable&&!t.hasFocus()?!1:dD(t)}function dD(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 x6(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return rl(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Sx(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&Ye.findFrom(i,e)}function Ao(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function jA(t,e,n){let r=t.state.selection;if(r instanceof $e)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Ao(t,new $e(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Sx(t.state,e);return s&&s instanceof Fe?Ao(t,s):!1}else if(!(ns&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Fe.isSelectable(i)?Ao(t,new Fe(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):mf?Ao(t,new $e(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Fe&&r.node.isInline)return Ao(t,new $e(e>0?r.$to:r.$from));{let s=Sx(t.state,e);return s?Ao(t,s):!1}}}function um(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Sd(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function sc(t,e){return e<0?w6(t):S6(t)}function w6(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(is&&n.nodeType==1&&r<um(n)&&Sd(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Sd(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(fD(n))break;{let l=n.previousSibling;for(;l&&Sd(l,-1);)s=n.parentNode,i=Un(l),l=l.previousSibling;if(l)n=l,r=um(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?kx(t,n,r):s&&kx(t,s,i)}function S6(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=um(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Sd(l,1))i=n,o=++r;else break}else{if(fD(n))break;{let l=n.nextSibling;for(;l&&Sd(l,1);)i=l.parentNode,o=Un(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=um(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&kx(t,i,o)}function fD(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function k6(t,e){for(;t&&e==t.childNodes.length&&!pf(t);)e=Un(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 C6(t,e){for(;t&&!e&&!pf(t);)e=Un(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 kx(t,e,n){if(e.nodeType!=3){let i,o;(o=k6(e,n))?(e=o,n=0):(i=C6(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(wg(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&Bi(t)},50)}function DA(t,e){let n=t.state.doc.resolve(e);if(!(qn||Xj)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function IA(t,e,n){let r=t.state.selection;if(r instanceof $e&&!r.empty||n.indexOf("s")>-1||ns&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Sx(t.state,e);if(o&&o instanceof Fe)return Ao(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Br?Ye.near(o,e):Ye.findFrom(o,e);return l?Ao(t,l):!1}return!1}function LA(t,e){if(!(t.state.selection instanceof $e))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function PA(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function E6(t){if(!er||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;PA(t,r,"true"),setTimeout(()=>PA(t,r,"false"),20)}return!1}function T6(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function _6(t,e){let n=e.keyCode,r=T6(e);if(n==8||ns&&n==72&&r=="c")return LA(t,-1)||sc(t,-1);if(n==46&&!e.shiftKey||ns&&n==68&&r=="c")return LA(t,1)||sc(t,1);if(n==13||n==27)return!0;if(n==37||ns&&n==66&&r=="c"){let s=n==37?DA(t,t.state.selection.from)=="ltr"?-1:1:-1;return jA(t,s,r)||sc(t,s)}else if(n==39||ns&&n==70&&r=="c"){let s=n==39?DA(t,t.state.selection.from)=="ltr"?1:-1:1;return jA(t,s,r)||sc(t,s)}else{if(n==38||ns&&n==80&&r=="c")return IA(t,-1,r)||sc(t,-1);if(n==40||ns&&n==78&&r=="c")return E6(t)||IA(t,1,r)||sc(t,1);if(r==(ns?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function dS(t,e){t.someProp("transformCopied",b=>{e=b(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let b=r.firstChild;n.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),r=b.content}let o=t.someProp("clipboardSerializer")||pl.fromSchema(t.state.schema),l=bD(),u=l.createElement("div");u.appendChild(o.serializeFragment(r,{document:l}));let d=u.firstChild,h,g=0;for(;d&&d.nodeType==1&&(h=yD[d.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),g++}d=u.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${i}${g?` -${g}`:""} ${JSON.stringify(n)}`);let y=t.someProp("clipboardTextSerializer",b=>b(e,t))||e.content.textBetween(0,e.content.size,`
|
|
71
|
+
|
|
72
|
+
`);return{dom:u,text:y,slice:e}}function hD(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let u=!!e&&(r||i||!n);if(u){if(t.someProp("transformPastedText",y=>{e=y(e,i||r,t)}),i)return l=new Re(fe.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
73
|
+
`))),0,0),t.someProp("transformPasted",y=>{l=y(l,t,!0)}),l;let g=t.someProp("clipboardTextParser",y=>y(e,s,r,t));if(g)l=g;else{let y=s.marks(),{schema:b}=t.state,x=pl.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,y)))})}}else t.someProp("transformPastedHTML",g=>{n=g(n,t)}),o=M6(n),mf&&O6(o);let d=o&&o.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let g=+h[3];g>0;g--){let y=o.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;o=y}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||zi.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||h),context:s,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!A6.test(y.parentNode.nodeName)?{ignore:!0}:null}})),h)l=j6(zA(l,+h[1],+h[2]),h[4]);else if(l=Re.maxOpen(R6(l.content,s),!0),l.openStart||l.openEnd){let g=0,y=0;for(let b=l.content.firstChild;g<l.openStart&&!b.type.spec.isolating;g++,b=b.firstChild);for(let b=l.content.lastChild;y<l.openEnd&&!b.type.spec.isolating;y++,b=b.lastChild);l=zA(l,g,y)}return t.someProp("transformPasted",g=>{l=g(l,t,u)}),l}const A6=/^(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 R6(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let u=s.findWrapping(l.type),d;if(!u)return o=null;if(d=o.length&&i.length&&mD(u,i,l,o[o.length-1],0))o[o.length-1]=d;else{o.length&&(o[o.length-1]=gD(o[o.length-1],i.length));let h=pD(l,u);o.push(h),s=s.matchType(h.type),i=u}}),o)return fe.from(o)}return t}function pD(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,fe.from(t));return t}function mD(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=mD(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(fe.from(pD(n,t,s+1))))}}function gD(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,gD(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(fe.empty,!0);return t.copy(n.append(r))}function Cx(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=Cx(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(fe.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function zA(t,e,n){return e<t.openStart&&(t=new Re(Cx(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Re(Cx(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const yD={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 bD(){return document.implementation.createHTMLDocument("title")}let Bv=null;function N6(t){let e=window.trustedTypes;return e?(Bv||(Bv=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Bv.createHTML(t)):t}function M6(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=bD(),r=n.body,s=/<([a-z][^>\s]+)/i.exec(t),i;if((i=s&&yD[s[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=N6(t),i)for(let o=0;o<i.length;o++)r=r.querySelector(i[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 d=l.rules[u];if(d instanceof CSSStyleRule){let h=r.querySelectorAll(d.selectorText);for(let g=0;g<h.length;g++)h[g].style.cssText+=d.style.cssText}}}return r}function O6(t){let e=t.querySelectorAll(qn?"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 j6(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let u=n.nodes[r[l]];if(!u||u.hasRequiredAttrs())break;s=fe.from(u.create(r[l+1],s)),i++,o++}return new Re(s,i,o)}const fr={},hr={},D6={touchstart:!0,touchmove:!0};class I6{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 L6(t){for(let e in fr){let n=fr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{z6(t,r)&&!fS(t,r)&&(t.editable||!(r.type in hr))&&n(t,r)},D6[e]?{passive:!0}:void 0)}er&&t.dom.addEventListener("input",()=>null),Ex(t)}function Pi(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function P6(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 Ex(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>fS(t,r))})}function fS(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function z6(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 $6(t,e){!fS(t,e)&&fr[e.type]&&(t.editable||!(e.type in hr))&&fr[e.type](t,e)}hr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!SD(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Li&&qn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Pc&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,La(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||_6(t,n)?n.preventDefault():Pi(t,"key")};hr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};hr.keypress=(t,e)=>{let n=e;if(SD(t)||!n.charCode||n.ctrlKey&&!n.altKey||ns&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof $e)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function yf(t){return{left:t.clientX,top:t.clientY}}function B6(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function hS(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function bf(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 V6(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Fe.isSelectable(r)?(bf(t,new Fe(n)),!0):!1}function H6(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof Fe&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(Fe.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(bf(t,Fe.create(t.state.doc,s)),!0):!1}function U6(t,e,n,r,s){return hS(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?H6(t,n):V6(t,n))}function F6(t,e,n,r){return hS(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function q6(t,e,n,r){return hS(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||G6(t,n,r)}function G6(t,e,n){if(n.button!=0)return!1;let r=vD(t,e,!0),s=t.state.doc;return r?(bf(t,r),r instanceof $e&&s.eq(t.state.doc)&&(t.input.mouseDown=new K6(t,r)),!0):!1}function vD(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?$e.create(r,0,r.content.size):null;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)return $e.create(r,l+1,l+1+o.content.size);if(n&&Fe.isSelectable(o))return Fe.create(r,l)}return null}function pS(t){return dm(t)}const xD=ns?"metaKey":"ctrlKey";fr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=pS(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&B6(n,t.input.lastClick)&&!n[xD]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let o=t.posAtCoords(yf(n));o&&(i=="singleClick"?t.input.mouseDown=new W6(t,o,n,!!r):(i=="doubleClick"?F6:q6)(t,o.pos,o.inside,n)?n.preventDefault():Pi(t,"pointer"))};class wD{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 W6 extends wD{constructor(e,n,r,s){super(e),this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[xD],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let h=e.state.doc.resolve(n.pos);i=h.parent,o=h.depth?h.before():0}const l=s?null:r.target,u=l?e.docView.nearestDesc(l,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:d}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||d instanceof Fe&&d.from<=o&&d.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&is&&!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()),Pi(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||Bi(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(yf(e))),this.updateAllowDefault(e),this.allowDefault||!n?Pi(this.view,"pointer"):U6(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||er&&this.mightDrag&&!this.mightDrag.node.isAtom||qn&&!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)?(bf(this.view,Ye.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Pi(this.view,"pointer")}move(e){this.updateAllowDefault(e),Pi(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 K6 extends wD{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(),Pi(this.view,"pointer");let n=this.view.posAtCoords(yf(e)),r=n&&vD(this.view,n.inside,!1);if(!r)return;let{doc:s}=this.view.state,i=this.startSelection,[o,l]=r.from<i.from?[i.to,r.from]:[i.from,r.to];bf(this.view,$e.create(s,o,l))}}fr.touchstart=t=>{t.input.lastTouch=Date.now(),pS(t),Pi(t,"pointer")};fr.touchmove=t=>{t.input.lastTouch=Date.now(),Pi(t,"pointer")};fr.contextmenu=t=>pS(t);function SD(t,e){return t.composing?!0:er&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Z6=Li?5e3:-1;hr.compositionstart=hr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof $e&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||qn&&Xj&&Y6(t)))t.markCursor=t.state.storedMarks||n.marks(),dm(t,!0),t.markCursor=null;else if(dm(t,!e.selection.empty),is&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}kD(t,Z6)};function Y6(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"}hr.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++,kD(t,20))};function kD(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>dm(t),e))}function CD(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function X6(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=H5(e.focusNode,e.focusOffset),r=U5(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function dm(t,e=!1){if(!(Li&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),CD(t),e||t.docView&&t.docView.dirty){let n=cS(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 J6(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Wd=Cr&&Go<15||Pc&&W5<604;fr.copy=hr.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Wd?null:n.clipboardData,o=r.content(),{dom:l,text:u}=dS(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",u)):J6(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Q6(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function eq(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Kd(t,r.value,null,s,e):Kd(t,r.textContent,r.innerHTML,s,e)},50)}function Kd(t,e,n,r,s){let i=hD(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,s,i||Re.empty)))return!0;if(!i)return!1;let o=Q6(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ED(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," "):""}hr.paste=(t,e)=>{let n=e;if(t.composing&&!Li)return;let r=Wd?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Kd(t,ED(r),r.getData("text/html"),s,n)?n.preventDefault():eq(t,n)};class TD{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const tq=ns?"altKey":"ctrlKey";function _D(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[tq]}fr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(yf(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Fe?s.to-1:s.to))){if(r&&r.mightDrag)o=Fe.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let g=t.docView.nearestDesc(n.target,!0);g&&g.node.type.spec.draggable&&g!=t.docView&&(o=Fe.create(t.state.doc,g.posBefore))}}let l=(o||t.state.selection).content(),{dom:u,text:d,slice:h}=dS(t,l);(!n.dataTransfer.files.length||!qn||Yj>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Wd?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Wd||n.dataTransfer.setData("text/plain",d),t.dragging=new TD(h,_D(t,n),o)};fr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};hr.dragover=hr.dragenter=(t,e)=>e.preventDefault();hr.drop=(t,e)=>{try{nq(t,e,t.dragging)}finally{t.dragging=null}};function nq(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(yf(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",b=>{i=b(i,t,!1)}):i=hD(t,ED(e.dataTransfer),Wd?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&_D(t,e));if(t.someProp("handleDrop",b=>b(t,e,i||Re.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Aj(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let u=t.state.tr;if(o){let{node:b}=n;b?b.replace(u):u.deleteSelection()}let d=u.mapping.map(l),h=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,g=u.doc;if(h?u.replaceRangeWith(d,d,i.content.firstChild):u.replaceRange(d,d,i),u.doc.eq(g))return;let y=u.doc.resolve(d);if(h&&Fe.isSelectable(i.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new Fe(y));else{let b=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach((x,S,k,C)=>b=C),u.setSelection(uS(t,y,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}fr.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())&&Bi(t)},20))};fr.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)};fr.beforeinput=(t,e)=>{if(Li&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,La(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in hr)fr[t]=hr[t];function Zd(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 fm{constructor(e,n){this.toDOM=e,this.spec=n||Wa,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new An(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof fm&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Zd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Zo{constructor(e,n){this.attrs=e,this.spec=n||Wa}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new An(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Zo&&Zd(this.attrs,e.attrs)&&Zd(this.spec,e.spec)}static is(e){return e.type instanceof Zo}destroy(){}}class mS{constructor(e,n){this.attrs=e,this.spec=n||Wa}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new An(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof mS&&Zd(this.attrs,e.attrs)&&Zd(this.spec,e.spec)}destroy(){}}class An{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new An(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 An(e,e,new fm(n,r))}static inline(e,n,r,s){return new An(e,n,new Zo(r,s))}static node(e,n,r,s){return new An(e,n,new mS(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Zo}get widget(){return this.type instanceof fm}}const mc=[],Wa={};class _t{constructor(e,n){this.local=e.length?e:mc,this.children=n.length?n:mc}static create(e,n){return n.length?hm(n,e,0,Wa):Jn}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}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,s+l,i)}}map(e,n,r){return this==Jn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Wa)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let u=this.local[l].map(e,r,s);u&&u.type.valid(n,u)?(o||(o=[])).push(u):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?rq(this.children,o||[],e,n,r,s,i):o?new _t(o.sort(Ka),mc):Jn}add(e,n){return n.length?this==Jn?_t.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,u)=>{let d=u+r,h;if(h=RD(n,l,d)){for(s||(s=this.children.slice());i<s.length&&s[i]<u;)i+=3;s[i]==u?s[i+2]=s[i+2].addInner(l,h,d+1):s.splice(i,0,u,u+l.nodeSize,hm(h,l,d+1,Wa)),i+=3}});let o=AD(i?ND(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new _t(o.length?this.local.concat(o).sort(Ka):this.local,s||this.children)}remove(e){return e.length==0||this==Jn?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,u=r[i+1]+n;for(let h=0,g;h<e.length;h++)(g=e[h])&&g.from>l&&g.to<u&&(e[h]=null,(o||(o=[])).push(g));if(!o)continue;r==this.children&&(r=this.children.slice());let d=r[i+2].removeInner(o,l+1);d!=Jn?r[i+2]=d:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new _t(s,r):Jn}forChild(e,n){if(this==Jn)return this;if(n.isLeaf)return _t.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let u=this.local[l];if(u.from<o&&u.to>i&&u.type instanceof Zo){let d=Math.max(i,u.from)-i,h=Math.min(o,u.to)-i;d<h&&(s||(s=[])).push(u.copy(d,h))}}if(s){let l=new _t(s.sort(Ka),mc);return r?new Io([l,r]):l}return r||Jn}eq(e){if(this==e)return!0;if(!(e instanceof _t)||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 gS(this.localsInner(e))}localsInner(e){if(this==Jn)return mc;if(e.inlineContent||!this.local.some(Zo.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Zo||n.push(this.local[r]);return n}forEachSet(e){e(this)}}_t.empty=new _t([],[]);_t.removeOverlap=gS;const Jn=_t.empty;class Io{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Wa));return Io.from(r)}forChild(e,n){if(n.isLeaf)return _t.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Jn&&(i instanceof Io?r=r.concat(i.members):r.push(i))}return Io.from(r)}eq(e){if(!(e instanceof Io)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?gS(r?n:n.sort(Ka)):mc}static from(e){switch(e.length){case 0:return Jn;case 1:return e[0];default:return new Io(e.every(n=>n instanceof _t)?e:e.reduce((n,r)=>n.concat(r instanceof _t?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function rq(t,e,n,r,s,i,o){let l=t.slice();for(let d=0,h=i;d<n.maps.length;d++){let g=0;n.maps[d].forEach((y,b,x,S)=>{let k=S-x-(b-y);for(let C=0;C<l.length;C+=3){let A=l[C+1];if(A<0||y>A+h-g)continue;let R=l[C]+h-g;b>=R?l[C+1]=y<=R?-2:-1:y>=h&&k&&(l[C]+=k,l[C+1]+=k)}g+=k}),h=n.maps[d].map(h,-1)}let u=!1;for(let d=0;d<l.length;d+=3)if(l[d+1]<0){if(l[d+1]==-2){u=!0,l[d+1]=-1;continue}let h=n.map(t[d]+i),g=h-s;if(g<0||g>=r.content.size){u=!0;continue}let y=n.map(t[d+1]+i,-1),b=y-s,{index:x,offset:S}=r.content.findIndex(g),k=r.maybeChild(x);if(k&&S==g&&S+k.nodeSize==b){let C=l[d+2].mapInner(n,k,h+1,t[d]+i+1,o);C!=Jn?(l[d]=g,l[d+1]=b,l[d+2]=C):(l[d+1]=-2,u=!0)}else u=!0}if(u){let d=sq(l,t,e,n,s,i,o),h=hm(d,r,0,o);e=h.local;for(let g=0;g<l.length;g+=3)l[g+1]<0&&(l.splice(g,3),g-=3);for(let g=0,y=0;g<h.children.length;g+=3){let b=h.children[g];for(;y<l.length&&l[y]<b;)y+=3;l.splice(y,0,h.children[g],h.children[g+1],h.children[g+2])}}return new _t(e.sort(Ka),l)}function AD(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new An(s.from+e,s.to+e,s.type))}return n}function sq(t,e,n,r,s,i,o){function l(u,d){for(let h=0;h<u.local.length;h++){let g=u.local[h].map(r,s,d);g?n.push(g):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]+d+1)}for(let u=0;u<t.length;u+=3)t[u+1]==-1&&l(t[u+2],e[u]+i+1);return n}function RD(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function ND(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function hm(t,e,n,r){let s=[],i=!1;e.forEach((l,u)=>{let d=RD(t,l,u+n);if(d){i=!0;let h=hm(d,l,n+u+1,r);h!=Jn&&s.push(u,u+l.nodeSize,h)}});let o=AD(i?ND(t):t,-n).sort(Ka);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||s.length?new _t(o,s):Jn}function Ka(t,e){return t.from-e.from||t.to-e.to}function gS(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),$A(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),$A(e,s,r.copy(i.from,r.to)));break}}}return e}function $A(t,e,n){for(;e<t.length&&Ka(n,t[e])>0;)e++;t.splice(e,0,n)}function Vv(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Jn&&e.push(r)}),t.cursorWrapper&&e.push(_t.create(t.state.doc,[t.cursorWrapper.deco])),Io.from(e)}const iq={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},oq=Cr&&Go<=11;class aq{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 lq{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new aq,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Cr&&Go<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():er&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),oq&&(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,iq)),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(OA(this.view)){if(this.suppressingSelectionUpdates)return Bi(this.view);if(Cr&&Go<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&rl(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=Lc(i))n.add(i);for(let i=e.anchorNode;i;i=Lc(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&OA(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,u=[];if(e.editable)for(let h=0;h<n.length;h++){let g=this.registerMutation(n[h],u);g&&(i=i<0?g.from:Math.min(g.from,i),o=o<0?g.to:Math.max(g.to,o),g.typeOver&&(l=!0))}if(u.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||qn&&(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 g=h.nextSibling;for(;g&&g.nodeType==1;){if(g.contentEditable=="false"){h.parentNode.removeChild(h);break}g=g.firstChild}}}else if(is&&u.length){let h=u.filter(g=>g.nodeName=="BR");if(h.length==2){let[g,y]=h;g.parentNode&&g.parentNode.parentNode==y.parentNode?y.remove():g.remove()}else{let{focusNode:g}=this.currentSelection;for(let y of h){let b=y.parentNode;b&&b.nodeName=="LI"&&(!g||dq(e,g)!=b)&&y.remove()}}}let d=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&wg(r)&&(d=cS(e))&&d.eq(Ye.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Bi(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),cq(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,fq(e,u)),this.handleDOMChange(i,o,l,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Bi(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 g=e.addedNodes[h];n.push(g),g.nodeType==3&&(this.lastChangedTextNode=g)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Cr&&Go<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:g,nextSibling:y}=e.addedNodes[h];(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(s=g),(!y||Array.prototype.indexOf.call(e.addedNodes,y)<0)&&(i=y)}let o=s&&s.parentNode==e.target?Un(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),u=i&&i.parentNode==e.target?Un(i):e.target.childNodes.length,d=r.localPosFromDOM(e.target,u,1);return{from:l,to:d}}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 BA=new WeakMap,VA=!1;function cq(t){if(!BA.has(t)&&(BA.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=is,VA)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."),VA=!0}}function HA(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return rl(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function uq(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return HA(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?HA(t,n):null}function dq(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 fq(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.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(i,l.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function hq(t,e,n,r){let{node:s,fromOffset:i,toOffset:o,from:l,to:u}=t.docView.parseRange(e,n),d=t.domSelectionRange(),h,g=d.anchorNode;if(g&&t.dom.contains(g.nodeType==1?g:g.parentNode)&&(h=[{node:g,offset:d.anchorOffset}],wg(d)||h.push({node:d.focusNode,offset:d.focusOffset})),qn&&t.input.lastKeyCode===8)for(let C=o;C>i;C--){let A=s.childNodes[C-1],R=A.pmViewDesc;if(A.nodeName=="BR"&&!R){o=C;break}if(!R||R.size)break}let y=t.state.doc,b=t.someProp("domParser")||zi.fromSchema(t.state.schema),x=y.resolve(l),S=null,k=b.parse(s,{topNode:x.parent,topMatch:x.parent.contentMatchAt(x.index()),topOpen:!0,from:i,to:o,preserveWhitespace:x.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:pq(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 pq=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(er&&/^(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||er&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},mq=/^(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 gq(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let O=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,P=cS(t,O);if(P&&!t.state.selection.eq(P)){if(qn&&Li&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",F=>F(t,La(13,"Enter"))))return;let D=t.state.tr.setSelection(P);O=="pointer"?D.setMeta("pointer",!0):O=="key"&&D.scrollIntoView(),i&&D.setMeta("composition",i),t.dispatch(D)}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,d=hq(t,e,n,s),h=t.state.doc,g=h.slice(d.from,d.to),y,b;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(y=t.state.selection.to,b="end"):(y=t.state.selection.from,b="start"),t.input.lastKeyCode=null;let x=vq(g.content,d.doc.content,d.from,y,b);if(x&&t.input.domChangeCount++,(Pc&&t.input.lastIOSEnter>Date.now()-225||Li)&&s.some(O=>O.nodeType==1&&!mq.test(O.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",O=>O(t,La(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&u instanceof $e&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))x={start:u.from,endA:u.to,endB:u.to};else{if(d.sel){let O=UA(t,t.state.doc,d.sel);if(O&&!O.eq(t.state.selection)){let P=t.state.tr.setSelection(O);i&&P.setMeta("composition",i),t.dispatch(P)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof $e&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=d.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=d.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Cr&&Go<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>d.from&&d.doc.textBetween(x.start-d.from-1,x.start-d.from+1)==" "&&(x.start--,x.endA--,x.endB--);let S=d.doc.resolveNoCache(x.start-d.from),k=d.doc.resolveNoCache(x.endB-d.from),C=h.resolve(x.start),A=S.sameParent(k)&&S.parent.inlineContent&&C.end()>=x.endA;if((Pc&&t.input.lastIOSEnter>Date.now()-225&&(!A||s.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!A&&S.pos<d.doc.content.size&&(!S.sameParent(k)||!S.parent.inlineContent)&&S.pos<k.pos&&!/\S/.test(d.doc.textBetween(S.pos,k.pos,"","")))&&t.someProp("handleKeyDown",O=>O(t,La(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&bq(h,x.start,x.endA,S,k)&&t.someProp("handleKeyDown",O=>O(t,La(8,"Backspace")))){Li&&qn&&t.domObserver.suppressSelectionUpdates();return}qn&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Li&&!A&&S.start()!=k.start()&&k.parentOffset==0&&S.depth==k.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==x.endA&&(x.endB-=2,k=d.doc.resolveNoCache(x.endB-d.from),setTimeout(()=>{t.someProp("handleKeyDown",function(O){return O(t,La(13,"Enter"))})},20));let R=x.start,_=x.endA,N=O=>{let P=O||t.state.tr.replace(R,_,d.doc.slice(x.start-d.from,x.endB-d.from));if(d.sel){let D=UA(t,P.doc,d.sel);D&&!(qn&&t.composing&&D.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(D.head==R||D.head==P.mapping.map(_)-1)||Cr&&D.empty&&D.head==R)&&P.setSelection(D)}return i&&P.setMeta("composition",i),P.scrollIntoView()},M;if(A)if(S.pos==k.pos){Cr&&Go<=11&&S.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Bi(t),20));let O=N(t.state.tr.delete(R,_)),P=h.resolve(x.start).marksAcross(h.resolve(x.endA));P&&O.ensureMarks(P),t.dispatch(O)}else if(x.endA==x.endB&&(M=yq(S.parent.content.cut(S.parentOffset,k.parentOffset),C.parent.content.cut(C.parentOffset,x.endA-C.start())))){let O=N(t.state.tr);M.type=="add"?O.addMark(R,_,M.mark):O.removeMark(R,_,M.mark),t.dispatch(O)}else if(S.parent.child(S.index()).isText&&S.index()==k.index()-(k.textOffset?0:1)){let O=S.parent.textBetween(S.parentOffset,k.parentOffset),P=()=>N(t.state.tr.insertText(O,R,_));t.someProp("handleTextInput",D=>D(t,R,_,O,P))||t.dispatch(P())}else t.dispatch(N());else t.dispatch(N())}function UA(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:uS(t,e.resolve(n.anchor),e.resolve(n.head))}function yq(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,u;for(let h=0;h<r.length;h++)s=r[h].removeFromSet(s);for(let h=0;h<n.length;h++)i=n[h].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",u=h=>h.mark(l.addToSet(h.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",u=h=>h.mark(l.removeFromSet(h.marks));else return null;let d=[];for(let h=0;h<e.childCount;h++)d.push(u(e.child(h)));if(fe.from(d).eq(t))return{mark:l,type:o}}function bq(t,e,n,r,s){if(n-e<=s.pos-r.pos||Hv(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(Hv(i,!0,!0));return!o.parent.isTextblock||o.pos>n||Hv(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Hv(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function vq(t,e,n,r,s){let i=t.findDiffStart(e,n),o=n+t.size,l=n+e.size;if(i==null)return null;let{a:u,b:d}=t.findDiffEnd(e,o,l);if(s=="end"){let h=Math.max(0,i-Math.min(u,d));r-=u+h-i}if(u<i&&o<l){let h=r<=i&&r>=u?i-r:0;i-=h,d=i+(d-u),u=i}else if(d<i){let h=r<=i&&r>=d?i-r:0;i-=h,u=i+(u-d),d=i}return{start:i,endA:u,endB:d}}class MD{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 I6,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(KA),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=GA(this),qA(this),this.nodeViews=WA(this),this.docView=TA(this.state.doc,FA(this),Vv(this),this.dom,this),this.domObserver=new lq(this,(r,s,i,o)=>gq(this,r,s,i,o)),this.domObserver.start(),L6(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&&Ex(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(KA),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(CD(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let b=WA(this);wq(b,this.nodeViews)&&(this.nodeViews=b,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Ex(this),this.editable=GA(this),qA(this);let u=Vv(this),d=FA(this),h=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",g=i||!this.docView.matchesNode(e.doc,d,u);(g||!e.selection.eq(s.selection))&&(o=!0);let y=h=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Y5(this);if(o){this.domObserver.stop();let b=g&&(Cr||qn)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&xq(s.selection,e.selection);if(g){let S=qn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=X6(this)),(i||!this.docView.update(e.doc,d,u,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=TA(e.doc,d,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())&&x6(this)&&x.delaySelUpdate())?Bi(this,b):(uD(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():y&&X5(y)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Fe){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&wA(this,n.getBoundingClientRect(),e)}else wA(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new TD(e.slice,e.move,s<0?void 0:Fe.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(Cr){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&&J5(this.dom),Bi(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 r6(this,e)}coordsAtPos(e,n=1){return nD(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return l6(this,n||this.state,e)}pasteHTML(e,n){return Kd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Kd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return dS(this,e)}destroy(){this.docView&&(P6(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Vv(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,B5())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return $6(this,e)}domSelectionRange(){let e=this.domSelection();return e?er&&this.root.nodeType===11&&q5(this.dom.ownerDocument)==this.dom&&uq(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}MD.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function FA(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"),[An.node(0,t.state.doc.content.size,e)]}function qA(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:An.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function GA(t){return!t.someProp("editable",e=>e(t.state)===!1)}function xq(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 WA(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function wq(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function KA(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 ea={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:"'"},pm={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Sq=typeof navigator<"u"&&/Mac/.test(navigator.platform),kq=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Fn=0;Fn<10;Fn++)ea[48+Fn]=ea[96+Fn]=String(Fn);for(var Fn=1;Fn<=24;Fn++)ea[Fn+111]="F"+Fn;for(var Fn=65;Fn<=90;Fn++)ea[Fn]=String.fromCharCode(Fn+32),pm[Fn]=String.fromCharCode(Fn);for(var Uv in ea)pm.hasOwnProperty(Uv)||(pm[Uv]=ea[Uv]);function Cq(t){var e=Sq&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||kq&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?pm:ea)[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 Eq=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Tq=typeof navigator<"u"&&/Win/.test(navigator.platform);function _q(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,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))s=!0;else if(/^s(hift)?$/i.test(u))i=!0;else if(/^mod$/i.test(u))Eq?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function Aq(t){let e=Object.create(null);for(let n in t)e[_q(n)]=t[n];return e}function Fv(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 Rq(t){return new Bt({props:{handleKeyDown:yS(t)}})}function yS(t){let e=Aq(t);return function(n,r){let s=Cq(r),i,o=e[Fv(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Fv(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Tq&&r.ctrlKey&&r.altKey)&&(i=ea[r.keyCode])&&i!=s){let l=e[Fv(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var Nq=Object.defineProperty,bS=(t,e)=>{for(var n in e)Nq(t,n,{get:e[n],enumerable:!0})};function kg(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var Cg=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...d)=>{const h=l(...d)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,u=t||s.tr,d=()=>(!l&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),o.every(g=>g===!0)),h={...Object.fromEntries(Object.entries(n).map(([g,y])=>[g,(...x)=>{const S=this.buildProps(u,e),k=y(...x)(S);return o.push(k),h}])),run:d};return h}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,u])=>[l,(...d)=>u(...d)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:kg({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,u])=>[l,(...d)=>u(...d)(o)]))}};return o}},vs={};bS(vs,{blur:()=>Mq,clearContent:()=>Oq,clearNodes:()=>jq,command:()=>Dq,createParagraphNear:()=>Iq,cut:()=>Lq,deleteCurrentNode:()=>Pq,deleteNode:()=>zq,deleteRange:()=>$q,deleteSelection:()=>Hq,enter:()=>Uq,exitCode:()=>Fq,extendMarkRange:()=>qq,first:()=>Gq,focus:()=>Kq,forEach:()=>Zq,insertContent:()=>Yq,insertContentAt:()=>Jq,insertDefaultBlock:()=>Qq,joinBackward:()=>n9,joinDown:()=>t9,joinForward:()=>r9,joinItemBackward:()=>s9,joinItemForward:()=>i9,joinTextblockBackward:()=>o9,joinTextblockForward:()=>a9,joinUp:()=>e9,keyboardShortcut:()=>c9,lift:()=>u9,liftEmptyBlock:()=>d9,liftListItem:()=>f9,newlineInCode:()=>h9,resetAttributes:()=>p9,scrollIntoView:()=>m9,selectAll:()=>g9,selectNodeBackward:()=>y9,selectNodeForward:()=>b9,selectParentNode:()=>v9,selectTextblockEnd:()=>x9,selectTextblockStart:()=>w9,setContent:()=>S9,setMark:()=>V9,setMeta:()=>H9,setNode:()=>U9,setNodeSelection:()=>F9,setTextDirection:()=>q9,setTextSelection:()=>G9,sinkListItem:()=>W9,splitBlock:()=>K9,splitListItem:()=>Z9,toggleList:()=>X9,toggleMark:()=>J9,toggleNode:()=>Q9,toggleWrap:()=>e8,undoInputRule:()=>t8,unsetAllMarks:()=>n8,unsetMark:()=>r8,unsetTextDirection:()=>s8,updateAttributes:()=>i8,wrapIn:()=>o8,wrapInList:()=>a8});var Mq=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),Oq=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),jq=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,u)=>{if(l.type.isText)return;const{doc:d,mapping:h}=e,g=d.resolve(h.map(u)),y=d.resolve(h.map(u+l.nodeSize)),b=g.blockRange(y);if(!b)return;const x=Xc(b);if(l.type.isTextblock){const{defaultType:S}=g.parent.contentMatchAt(g.index());e.setNodeMarkup(b.start,S)}(x||x===0)&&e.lift(b,x)})}),!0},Dq=t=>e=>t(e),Iq=()=>({state:t,dispatch:e})=>qj(t,e),Lq=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new $e(r.doc.resolve(Math.max(o-1,0)))),!0},Pq=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),u=s.after(i);t.delete(l,u).scrollIntoView()}return!0}return!1};function wn(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 zq=t=>({tr:e,state:n,dispatch:r})=>{const s=wn(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const u=i.before(o),d=i.after(o);e.delete(u,d).scrollIntoView()}return!0}return!1},$q=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},Bq=t=>t.content?/^text(\*|\+)/.test(t.content):!1,ZA=(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 Bq(r)?n==="left"?t.start()-1:t.end()+1:t.pos},Vq=(t,e,n)=>{const r=ZA(t,n,"left"),s=ZA(e,n,"right");return{from:r,to:s}},Hq=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){const n=t.tr,{ranges:r}=t.selection,s=n.steps.length;r.forEach(i=>{const o=n.mapping.slice(s),l=n.doc.resolve(o.map(i.$from.pos)),u=n.doc.resolve(o.map(i.$to.pos)),{from:d,to:h}=Vq(l,u,t.schema);n.deleteRange(d,h)}),n.selection.empty||n.setSelection($e.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),e(n)}return!0},Uq=()=>({commands:t})=>t.keyboardShortcut("Enter"),Fq=()=>({state:t,dispatch:e})=>E5(t,e);function vS(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function mm(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:vS(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function OD(t,e,n={}){return t.find(r=>r.type===e&&mm(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function YA(t,e,n={}){return!!OD(t,e,n)}function xS(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(d=>d.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(d=>d.type===e))return;if(!n){const d=r.node.marks.find(h=>h.type===e);d&&(n=d.attrs)}if(!OD([...r.node.marks],e,n))return;let i=r.index,o=t.start()+r.offset,l=i+1,u=o+r.node.nodeSize;for(;i>0&&YA([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&YA([...t.parent.child(l).marks],e,n);)u+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:u}}function Zi(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 qq=(t,e)=>({tr:n,state:r,dispatch:s})=>{const i=Zi(t,r.schema),{doc:o,selection:l}=n,{$from:u,from:d,to:h}=l;if(s){const g=xS(u,i,e);if(g&&g.from<=d&&g.to>=h){const y=$e.create(o,g.from,g.to);n.setSelection(y)}}return!0},Gq=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 jD(t){return t instanceof $e}function Ha(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Tx(t,e=null){if(!e)return null;const n=Ye.atStart(t),r=Ye.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?$e.create(t,Ha(0,s,i),Ha(t.content.size,s,i)):$e.create(t,Ha(e,s,i),Ha(e,s,i))}function XA(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function gm(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Wq(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Kq=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(gm()||XA())&&r.dom.focus(),Wq()&&!gm()&&!XA()&&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(i&&t===null&&!jD(n.state.selection))return o(),!0;const l=Tx(s.doc,t)||n.state.selection,u=n.state.selection.eq(l);return i&&(u||s.setSelection(l),u&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},Zq=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),Yq=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),DD=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&&DD(r)}return t};function ud(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 DD(n)}function zc(t,e,n){if(t instanceof qo||t instanceof fe)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return fe.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),zc("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const u=new yj({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:d=>(o=!0,l=typeof d=="string"?d:d.outerHTML,null)}]}})});if(n.slice?zi.fromSchema(u).parseSlice(ud(t),n.parseOptions):zi.fromSchema(u).parse(ud(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=zi.fromSchema(e);return n.slice?i.parseSlice(ud(t),n.parseOptions).content:i.parse(ud(t),n.parseOptions)}return zc("",e,n)}function ID(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof vn||s instanceof Rn))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,u,d,h)=>{o===0&&(o=h)}),t.setSelection(Ye.near(t.doc.resolve(o),n))}var Xq=t=>!("type"in t),Jq=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const u=k=>{i.emit("contentError",{editor:i,error:k,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{zc(e,i.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(k){u(k)}try{l=zc(e,i.schema,{parseOptions:d,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(k){return u(k),!1}let{from:h,to:g}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,b=!0;if((Xq(l)?l:[l]).forEach(k=>{k.check(),y=y?k.isText&&k.marks.length===0:!1,b=b?k.isBlock:!1}),h===g&&b){const{parent:k}=r.doc.resolve(h);k.isTextblock&&!k.type.spec.code&&!k.childCount&&(h-=1,g+=1)}let S;if(y){if(Array.isArray(e))S=e.map(k=>k.text||"").join("");else if(e instanceof fe){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,g)}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,g,S)}n.updateSelection&&ID(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 LD(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 Qq=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{pos:s,attrs:i,content:o,updateSelection:l=!0}=t;let u;typeof s=="number"?u=e.doc.resolve(s):s?u=s:u=e.selection.$from;const d=LD(u.parent.contentMatchAt(u.index()));if(!d)return!1;const h=Object.keys(d.spec.attrs||{}),g=i?Object.fromEntries(Object.entries(i).filter(([b])=>h.includes(b))):{};let y;if(o){const b=zc(o,r.schema);y=d.createAndFill(g,b)}else y=d.createAndFill(g);return y?(n&&(e.insert(u.pos,y),l&&ID(e,e.steps.length-1,-1)),!0):!1},e9=()=>({state:t,dispatch:e})=>S5(t,e),t9=()=>({state:t,dispatch:e})=>k5(t,e),n9=()=>({state:t,dispatch:e})=>zj(t,e),r9=()=>({state:t,dispatch:e})=>Hj(t,e),s9=()=>({state:t,dispatch:e,tr:n})=>{try{const r=bg(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},i9=()=>({state:t,dispatch:e,tr:n})=>{try{const r=bg(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},o9=()=>({state:t,dispatch:e})=>x5(t,e),a9=()=>({state:t,dispatch:e})=>w5(t,e);function PD(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function l9(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,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))s=!0;else if(/^s(hift)?$/i.test(u))i=!0;else if(/^mod$/i.test(u))gm()||PD()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var c9=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=l9(t).split(/-(?!$)/),o=i.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,l))});return u?.steps.forEach(d=>{const h=d.map(r.mapping);h&&s&&r.maybeStep(h)}),!0};function ta(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?wn(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(g,y)=>{if(g.isText)return;const b=Math.max(r,y),x=Math.min(s,y+g.nodeSize);l.push({node:g,from:b,to:x})});const u=s-r,d=l.filter(g=>o?o.name===g.node.type.name:!0).filter(g=>mm(g.node.attrs,n,{strict:!1}));return i?!!d.length:d.reduce((g,y)=>g+y.to-y.from,0)>=u}var u9=(t,e={})=>({state:n,dispatch:r})=>{const s=wn(t,n.schema);return ta(n,s,e)?C5(n,r):!1},d9=()=>({state:t,dispatch:e})=>Gj(t,e),f9=t=>({state:e,dispatch:n})=>{const r=wn(t,e.schema);return L5(r)(e,n)},h9=()=>({state:t,dispatch:e})=>Fj(t,e);function Eg(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function JA(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var p9=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Eg(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=wn(t,r.schema)),l==="mark"&&(o=Zi(t,r.schema));let u=!1;return n.selection.ranges.forEach(d=>{r.doc.nodesBetween(d.$from.pos,d.$to.pos,(h,g)=>{i&&i===h.type&&(u=!0,s&&n.setNodeMarkup(g,void 0,JA(h.attrs,e))),o&&h.marks.length&&h.marks.forEach(y=>{o===y.type&&(u=!0,s&&n.addMark(g,g+h.nodeSize,o.create(JA(y.attrs,e))))})})}),u},m9=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),g9=()=>({tr:t,dispatch:e})=>{if(e){const n=new Br(t.doc);t.setSelection(n)}return!0},y9=()=>({state:t,dispatch:e})=>Bj(t,e),b9=()=>({state:t,dispatch:e})=>Uj(t,e),v9=()=>({state:t,dispatch:e})=>A5(t,e),x9=()=>({state:t,dispatch:e})=>M5(t,e),w9=()=>({state:t,dispatch:e})=>N5(t,e);function _x(t,e,n={},r={}){return zc(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var S9=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:u}=i;if(r.preserveWhitespace!=="full"){const d=_x(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,d).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function zD(t,e){const n=Zi(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,u=>{o.push(...u.marks)});const l=o.find(u=>u.type.name===n.name);return l?{...l.attrs}:{}}function $D(t,e){const n=new nS(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function k9(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function BD(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 Tg(t){return e=>BD(e.$from,t)}function je(t,e,n){return t.config[e]===void 0&&t.parent?je(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?je(t.parent,e,n):null}):t.config[e]}function _g(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=je(e,"addExtensions",n);return r?[e,..._g(r())]:e}).flat(10)}function wS(t,e){const n=pl.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function VD(t){return typeof t=="function"}function bt(t,e=void 0,...n){return VD(t)?e?t.bind(e)(...n):t(...n):t}function C9(t={}){return Object.keys(t).length===0&&t.constructor===Object}function $c(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function HD(t){const e=[],{nodeExtensions:n,markExtensions:r}=$c(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(d=>d.name!=="text").map(d=>d.name),l=r.map(d=>d.name),u=[...o,...l];return t.forEach(d=>{const h={name:d.name,options:d.options,storage:d.storage,extensions:s},g=je(d,"addGlobalAttributes",h);if(!g)return;g().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:{...i,...C}})})})})}),s.forEach(d=>{const h={name:d.name,options:d.options,storage:d.storage},g=je(d,"addAttributes",h);if(!g)return;const y=g();Object.entries(y).forEach(([b,x])=>{const S={...i,...x};typeof S?.default=="function"&&(S.default=S.default()),S?.isRequired&&S?.default===void 0&&delete S.default,e.push({type:d.name,name:b,attribute:S})})}),e}function E9(t){const e=[];let n="",r=!1,s=!1,i=0;const o=t.length;for(let l=0;l<o;l+=1){const u=t[l];if(u==="'"&&!s){r=!r,n+=u;continue}if(u==='"'&&!r){s=!s,n+=u;continue}if(!r&&!s){if(u==="("){i+=1,n+=u;continue}if(u===")"&&i>0){i-=1,n+=u;continue}if(u===";"&&i===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function QA(t){const e=[],n=E9(t||""),r=n.length;for(let s=0;s<r;s+=1){const i=n[s],o=i.indexOf(":");if(o===-1)continue;const l=i.slice(0,o).trim(),u=i.slice(o+1).trim();l&&u&&e.push([l,u])}return e}function $t(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],u=r[s]?r[s].split(" "):[],d=l.filter(h=>!u.includes(h));r[s]=[...u,...d].join(" ")}else if(s==="style"){const l=new Map([...QA(r[s]),...QA(i)]);r[s]=Array.from(l.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[s]=i}),r},{})}function Bc(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)=>$t(n,r),{})}function T9(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function eR(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):T9(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function tR(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&C9(n)?!1:n!=null))}function nR(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 UD(t,e){var n;const r=HD(t),{nodeExtensions:s,markExtensions:i}=$c(t),o=(n=s.find(d=>je(d,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(d=>{const h=r.filter(C=>C.type===d.name),g={name:d.name,options:d.options,storage:d.storage,editor:e},y=t.reduce((C,A)=>{const R=je(A,"extendNodeSchema",g);return{...C,...R?R(d):{}}},{}),b=tR({...y,content:bt(je(d,"content",g)),marks:bt(je(d,"marks",g)),group:bt(je(d,"group",g)),inline:bt(je(d,"inline",g)),atom:bt(je(d,"atom",g)),selectable:bt(je(d,"selectable",g)),draggable:bt(je(d,"draggable",g)),code:bt(je(d,"code",g)),whitespace:bt(je(d,"whitespace",g)),linebreakReplacement:bt(je(d,"linebreakReplacement",g)),defining:bt(je(d,"defining",g)),isolating:bt(je(d,"isolating",g)),attrs:Object.fromEntries(h.map(nR))}),x=bt(je(d,"parseHTML",g));x&&(b.parseDOM=x.map(C=>eR(C,h)));const S=je(d,"renderHTML",g);S&&(b.toDOM=C=>S({node:C,HTMLAttributes:Bc(C,h)}));const k=je(d,"renderText",g);return k&&(b.toText=k),[d.name,b]})),u=Object.fromEntries(i.map(d=>{const h=r.filter(k=>k.type===d.name),g={name:d.name,options:d.options,storage:d.storage,editor:e},y=t.reduce((k,C)=>{const A=je(C,"extendMarkSchema",g);return{...k,...A?A(d):{}}},{}),b=tR({...y,inclusive:bt(je(d,"inclusive",g)),excludes:bt(je(d,"excludes",g)),group:bt(je(d,"group",g)),spanning:bt(je(d,"spanning",g)),code:bt(je(d,"code",g)),attrs:Object.fromEntries(h.map(nR))}),x=bt(je(d,"parseHTML",g));x&&(b.parseDOM=x.map(k=>eR(k,h)));const S=je(d,"renderHTML",g);return S&&(b.toDOM=k=>S({mark:k,HTMLAttributes:Bc(k,h)})),[d.name,b]}));return new yj({topNode:o,nodes:l,marks:u})}function _9(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function kc(t){return t.sort((n,r)=>{const s=je(n,"priority")||100,i=je(r,"priority")||100;return s>i?-1:s<i?1:0})}function SS(t){const e=kc(_g(t)),n=_9(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 FD(t,e){const n=SS(t);return UD(n,e)}function A9(t,e){const n=FD(e),r=ud(t);return zi.fromSchema(n).parse(r).toJSON()}function qD(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
|
|
74
|
+
|
|
75
|
+
`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(u,d,h,g)=>{var y;u.isBlock&&d>r&&(l+=i);const b=o?.[u.type.name];if(b)return h&&(l+=b({node:u,pos:d,parent:h,index:g,range:e})),!1;u.isText&&(l+=(y=u?.text)==null?void 0:y.slice(Math.max(r,d)-d,s-d))}),l}function R9(t,e){const n={from:0,to:t.content.size};return qD(t,n,e)}function GD(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function N9(t,e){const n=wn(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function WD(t,e){const n=Eg(typeof e=="string"?e:e.name,t.schema);return n==="node"?N9(t,e):n==="mark"?zD(t,e):{}}function M9(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function O9(t){const e=M9(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function kS(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,u)=>{o.push({from:l,to:u})});else{const{from:l,to:u}=n[i];if(l===void 0||u===void 0)return;o.push({from:l,to:u})}o.forEach(({from:l,to:u})=>{const d=e.slice(i).map(l,-1),h=e.slice(i).map(u),g=e.invert().map(d,-1),y=e.invert().map(h);r.push({oldRange:{from:g,to:y},newRange:{from:d,to:h}})})}),O9(r)}function CS(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=xS(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var j9=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);l?.type.name===e?o=l:i-=1}return[o,i]};function Ju(t,e){return e.nodes[t]||e.marks[t]||null}function Mp(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var D9=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var u,d;const h=((d=(u=s.type.spec).toText)==null?void 0:d.call(u,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?h:h.slice(0,Math.max(0,r-i))}),n};function Ax(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Zi(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(g=>i?i.name===g.type.name:!0).find(g=>mm(g.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:g,$to:y})=>{const b=g.pos,x=y.pos;t.doc.nodesBetween(b,x,(S,k)=>{if(i&&S.inlineContent&&!S.type.allowsMarkType(i))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(g=>i?i.name===g.mark.type.name:!0).filter(g=>mm(g.mark.attrs,n,{strict:!1})).reduce((g,y)=>g+y.to-y.from,0),d=l.filter(g=>i?g.mark.type!==i&&g.mark.type.excludes(i):!0).reduce((g,y)=>g+y.to-y.from,0);return(u>0?u+d:u)>=o}function I9(t,e,n={}){if(!e)return ta(t,null,n)||Ax(t,null,n);const r=Eg(e,t.schema);return r==="node"?ta(t,e,n):r==="mark"?Ax(t,e,n):!1}var L9=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Tg(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},P9=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function rR(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function qv(t,e){const{nodeExtensions:n}=$c(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=bt(je(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function vf(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 s=!0;return t.content.forEach(i=>{s!==!1&&(vf(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function KD(t){return t instanceof Fe}var ZD=class YD{constructor(e){this.position=e}static fromJSON(e){return new YD(e.position)}toJSON(){return{position:this.position}}};function z9(t,e){const n=e.mapping.mapResult(t.position);return{position:new ZD(n.pos),mapResult:n}}function $9(t){return new ZD(t)}function B9(t,e,n){var r;const{selection:s}=e;let i=null;if(jD(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(d=>d.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:u})=>{let d=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,u.pos,(h,g,y)=>{if(d)return!1;if(h.isInline){const b=!y||y.type.allowsMarkType(n),x=!!n.isInSet(h.marks)||!h.marks.some(S=>S.type.excludes(n));d=b&&x}return!d}),d})}var V9=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,u=Zi(t,r.schema);if(s)if(o){const d=zD(r,u);n.addStoredMark(u.create({...d,...e}))}else l.forEach(d=>{const h=d.$from.pos,g=d.$to.pos;r.doc.nodesBetween(h,g,(y,b)=>{const x=Math.max(b,h),S=Math.min(b+y.nodeSize,g);y.marks.find(C=>C.type===u)?y.marks.forEach(C=>{u===C.type&&n.addMark(x,S,u.create({...C.attrs,...e}))}):n.addMark(x,S,u.create(e))})});return B9(r,n,u)},H9=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),U9=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=wn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>bA(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>bA(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},F9=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Ha(t,0,r.content.size),i=Fe.create(r,s);e.setSelection(i)}return!0},q9=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=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=i.from,l=i.to),s&&n.doc.nodesBetween(o,l,(u,d)=>{u.isText||n.setNodeMarkup(d,void 0,{...u.attrs,dir:t})}),!0},G9=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=$e.atStart(r).from,l=$e.atEnd(r).to,u=Ha(s,o,l),d=Ha(i,o,l),h=$e.create(r,u,d);e.setSelection(h)}return!0},W9=t=>({state:e,dispatch:n})=>{const r=wn(t,e.schema);return $5(r)(e,n)};function sR(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var K9=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:u}=i,d=s.extensionManager.attributes,h=Mp(d,l.node().type.name,l.node().attrs);if(i instanceof Fe&&i.node.isBlock)return!l.parentOffset||!$i(o,l.pos)?!1:(r&&(t&&sR(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const g=u.parentOffset===u.parent.content.size,y=l.depth===0?void 0:LD(l.node(-1).contentMatchAt(l.indexAfter(-1)));let b=g&&y?[{type:y,attrs:h}]:void 0,x=$i(e.doc,e.mapping.map(l.pos),1,b);if(!b&&!x&&$i(e.doc,e.mapping.map(l.pos),1,y?[{type:y}]:void 0)&&(x=!0,b=y?[{type:y,attrs:h}]:void 0),r){if(x&&(i instanceof $e&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,b),y&&!g&&!l.parentOffset&&l.parent.type!==y)){const S=e.mapping.map(l.before()),k=e.doc.resolve(S);l.node(-1).canReplaceWith(k.index(),k.index()+1,y)&&e.setNodeMarkup(e.mapping.map(l.before()),y)}t&&sR(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return x},Z9=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=wn(t,r.schema),{$from:u,$to:d}=r.selection,h=r.selection.node;if(h&&h.isBlock||u.depth<2||!u.sameParent(d))return!1;const g=u.node(-1);if(g.type!==l)return!1;const y=i.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==l||u.index(-2)!==u.node(-2).childCount-1)return!1;if(s){let C=fe.empty;const A=u.index(-1)?1:u.index(-2)?2:3;for(let P=u.depth-A;P>=u.depth-3;P-=1)C=fe.from(u.node(P).copy(C));const R=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,_={...Mp(y,u.node().type.name,u.node().attrs),...e},N=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(_))||void 0;C=C.append(fe.from(l.createAndFill(null,N)||void 0));const M=u.before(u.depth-(A-1));n.replace(M,u.after(-R),new Re(C,4-A,0));let O=-1;n.doc.nodesBetween(M,n.doc.content.size,(P,D)=>{if(O>-1)return!1;P.isTextblock&&P.content.size===0&&(O=D+1)}),O>-1&&n.setSelection($e.near(n.doc.resolve(O))),n.scrollIntoView()}return!0}const b=d.pos===u.end()?g.contentMatchAt(0).defaultType:null,x={...Mp(y,g.type.name,g.attrs),...e},S={...Mp(y,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,d.pos);const k=b?[{type:l,attrs:x},{type:b,attrs:S}]:[{type:l,attrs:x}];if(!$i(n.doc,u.pos,2))return!1;if(s){const{selection:C,storedMarks:A}=r,{splittableMarks:R}=i.extensionManager,_=A||C.$to.parentOffset&&C.$from.marks();if(n.split(u.pos,2,k).scrollIntoView(),!_||!s)return!0;const N=_.filter(M=>R.includes(M.type.name));n.ensureMarks(N)}return!0};function iR(t){return!t||t==="1"?null:t}function XD(t,e){return iR(t)===iR(e)}var Gv=(t,e)=>{const n=Tg(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 s=t.doc.nodeAt(r);return!(n.node.type===s?.type&&la(t.doc,n.pos))||!XD(n.node.attrs.type,s?.attrs.type)||t.join(n.pos),!0},Wv=(t,e)=>{const n=Tg(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 s=t.doc.nodeAt(r);return!(n.node.type===s?.type&&la(t.doc,r))||!XD(n.node.attrs.type,s?.attrs.type)||t.join(r),!0};function Y9(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),s=e.resolve(n.nodeSize-1);return $e.between(r,s)}var X9=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:u,commands:d,can:h})=>{const{extensions:g,splittableMarks:y}=s.extensionManager,b=wn(t,o.schema),x=wn(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 N=Tg(Z=>qv(Z.type.name,g))(S),M=S.from===0&&S.to===o.doc.content.size,O=o.doc.content.content,P=O.length===1?O[0]:null,D=M&&P&&qv(P.type.name,g)?{node:P,pos:0}:null,F=N??D,te=!!N&&R.depth>=1&&R.depth-N.depth<=1,H=!!D;if((te||H)&&F){if(F.node.type===b)return M&&H?u().command(({tr:Z,dispatch:G})=>{const ae=Y9(Z);return ae?(Z.setSelection(ae),G&&G(Z),!0):!1}).liftListItem(x).run():d.liftListItem(x);if(qv(F.node.type.name,g)&&b.validContent(F.node.content))return u().command(()=>(i.setNodeMarkup(F.pos,b),!0)).command(()=>Gv(i,b)).command(()=>Wv(i,b)).run()}return!n||!_||!l?u().command(()=>h().wrapInList(b,r)?!0:d.clearNodes()).wrapInList(b,r).command(()=>Gv(i,b)).command(()=>Wv(i,b)).run():u().command(()=>{const Z=h().wrapInList(b,r),G=_.filter(ae=>y.includes(ae.type.name));return i.ensureMarks(G),Z?!0:d.clearNodes()}).wrapInList(b,r).command(()=>Gv(i,b)).command(()=>Wv(i,b)).run()},J9=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Zi(t,r.schema);return Ax(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},Q9=(t,e,n={})=>({state:r,commands:s})=>{const i=wn(t,r.schema),o=wn(e,r.schema),l=ta(r,i,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),l?s.setNode(o,u):s.setNode(i,{...u,...n})},e8=(t,e={})=>({state:n,commands:r})=>{const s=wn(t,n.schema);return ta(n,s,e)?r.lift(s):r.wrapIn(s,e)},t8=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let u=l.steps.length-1;u>=0;u-=1)o.step(l.steps[u].invert(l.docs[u]));if(i.text){const u=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,u))}else o.delete(i.from,i.to)}return!0}}return!1},n8=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:o,ranges:l}=i;if(o)return!0;const{nonClearableMarks:u}=r.extensionManager;if(n){const d=Object.values(r.schema.marks).filter(h=>s||!u.includes(h.name));l.forEach(h=>{for(const g of d)e.removeMark(h.$from.pos,h.$to.pos,g)})}return!0},r8=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,u=Zi(t,r.schema),{$from:d,empty:h,ranges:g}=l;if(!s)return!0;if(h&&o){let{from:y,to:b}=l;const x=(i=d.marks().find(k=>k.type===u))==null?void 0:i.attrs,S=xS(d,u,x);S&&(y=S.from,b=S.to),n.removeMark(y,b,u)}else g.forEach(y=>{n.removeMark(y.$from.pos,y.$to.pos,u)});return n.removeStoredMark(u),!0},s8=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(l,u)=>{if(l.isText)return;const d={...l.attrs};delete d.dir,e.setNodeMarkup(u,void 0,d)}),!0},i8=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Eg(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=wn(t,r.schema)),l==="mark"&&(o=Zi(t,r.schema));let u=!1;return n.selection.ranges.forEach(d=>{const h=d.$from.pos,g=d.$to.pos;let y,b,x,S;n.selection.empty?r.doc.nodesBetween(h,g,(k,C)=>{i&&i===k.type&&(u=!0,x=Math.max(C,h),S=Math.min(C+k.nodeSize,g),y=C,b=k)}):r.doc.nodesBetween(h,g,(k,C)=>{C<h&&i&&i===k.type&&(u=!0,x=Math.max(C,h),S=Math.min(C+k.nodeSize,g),y=C,b=k),C>=h&&C<=g&&(i&&i===k.type&&(u=!0,s&&n.setNodeMarkup(C,void 0,{...k.attrs,...e})),o&&k.marks.length&&k.marks.forEach(A=>{if(o===A.type&&(u=!0,s)){const R=Math.max(C,h),_=Math.min(C+k.nodeSize,g);n.addMark(R,_,o.create({...A.attrs,...e}))}}))}),b&&(y!==void 0&&s&&n.setNodeMarkup(y,void 0,{...b.attrs,...e}),o&&b.marks.length&&b.marks.forEach(k=>{o===k.type&&s&&n.addMark(x,S,o.create({...k.attrs,...e}))}))}),u},o8=(t,e={})=>({state:n,dispatch:r})=>{const s=wn(t,n.schema);return O5(s,e)(n,r)},a8=(t,e={})=>({state:n,dispatch:r})=>{const s=wn(t,n.schema);return j5(s,e)(n,r)},l8=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 Vc(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(s=>Object.prototype.hasOwnProperty.call(e,s)&&Object.is(t[s],e[s]))}function c8(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Fe){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function u8(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}function oR(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")}function d8(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function f8(t){return typeof t=="number"}function h8(t){return Object.prototype.toString.call(t).slice(8,-1)}function Fh(t){return h8(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}var p8={};bS(p8,{createAtomBlockMarkdownSpec:()=>m8,createBlockMarkdownSpec:()=>g8,createInlineMarkdownSpec:()=>v8,parseAttributes:()=>ES,parseIndentedBlocks:()=>Rx,renderNestedMarkdownContent:()=>_S,serializeAttributes:()=>TS});function ES(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,d=>(n.push(d),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([\w-]+)/g);if(s){const d=s.map(h=>h.trim().slice(1));e.class=d.join(" ")}const i=r.match(/(?:^|\s)#([\w-]+)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,d,h])=>{var g;const y=parseInt(((g=h.match(/__QUOTED_(\d+)__/))==null?void 0:g[1])||"0",10),b=n[y];b&&(e[d]=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 TS(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 m8(t){const{nodeName:e,name:n,parseAttributes:r=ES,serializeAttributes:s=TS,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:l}=t,u=n||e,d=h=>{if(!l)return h;const g={};return l.forEach(y=>{y in h&&(g[y]=h[y])}),g};return{parseMarkdown:(h,g)=>{const y={...i,...h.attributes};return g.createNode(e,y,[])},markdownTokenizer:{name:e,level:"block",start(h){var g;const y=new RegExp(`^:::${u}(?:\\s|$)`,"m"),b=(g=h.match(y))==null?void 0:g.index;return b!==void 0?b:-1},tokenize(h,g,y){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 g=d(h.attrs||{}),y=s(g),b=y?` {${y}}`:"";return`:::${u}${b} :::`}}}function g8(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=ES,serializeAttributes:i=TS,defaultAttributes:o={},content:l="block",allowedAttributes:u}=t,d=n||e,h=g=>{if(!u)return g;const y={};return u.forEach(b=>{b in g&&(y[b]=g[b])}),y};return{parseMarkdown:(g,y)=>{let b;if(r){const S=r(g);b=typeof S=="string"?[{type:"text",text:S}]:S}else l==="block"?b=y.parseChildren(g.tokens||[]):b=y.parseInline(g.tokens||[]);const x={...o,...g.attributes};return y.createNode(e,x,b)},markdownTokenizer:{name:e,level:"block",start(g){var y;const b=new RegExp(`^:::${d}`,"m"),x=(y=g.match(b))==null?void 0:y.index;return x!==void 0?x:-1},tokenize(g,y,b){var x;const S=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),k=g.match(S);if(!k)return;const[C,A=""]=k,R=s(A);let _=1;const N=C.length;let M="";const O=/^:::([\w-]*)(\s.*)?/gm,P=g.slice(N);for(O.lastIndex=0;;){const D=O.exec(P);if(D===null)break;const F=D.index,te=D[1];if(!((x=D[2])!=null&&x.endsWith(":::"))){if(te)_+=1;else if(_-=1,_===0){const H=P.slice(0,F);M=H.trim();const Z=g.slice(0,N+F+D[0].length);let G=[];if(M)if(l==="block")for(G=b.blockTokens(H),G.forEach(ae=>{ae.text&&(!ae.tokens||ae.tokens.length===0)&&(ae.tokens=b.inlineTokens(ae.text))});G.length>0;){const ae=G[G.length-1];if(ae.type==="paragraph"&&(!ae.text||ae.text.trim()===""))G.pop();else break}else G=b.inlineTokens(M);return{type:e,raw:Z,attributes:R,content:M,tokens:G}}}}}},renderMarkdown:(g,y)=>{const b=h(g.attrs||{}),x=i(b),S=x?` {${x}}`:"",k=y.renderChildren(g.content||[],`
|
|
76
|
+
|
|
77
|
+
`);return`:::${d}${S}
|
|
78
|
+
|
|
79
|
+
${k}
|
|
80
|
+
|
|
81
|
+
:::`}}}function y8(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function b8(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function v8(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=y8,serializeAttributes:i=b8,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:u}=t,d=n||e,h=y=>{if(!u)return y;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 y){const C=y[S];if(k!==void 0&&C===k)return;b[S]=C}}),b},g=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(y,b)=>{const x={...o,...y.attributes};if(l)return b.createNode(e,x);const S=r?r(y):y.content||"";return S?b.createNode(e,x,[b.createTextNode(S)]):b.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(y){const b=l?new RegExp(`\\[${g}\\s*[^\\]]*\\]`):new RegExp(`\\[${g}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${g}\\]`),x=y.match(b),S=x?.index;return S!==void 0?S:-1},tokenize(y,b,x){const S=l?new RegExp(`^\\[${g}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${g}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${g}\\]`),k=y.match(S);if(!k)return;let C="",A="";if(l){const[,_]=k;A=_}else{const[,_,N]=k;A=_,C=N||""}const R=s(A.trim());return{type:e,raw:k[0],content:C.trim(),attributes:R}}},renderMarkdown:y=>{let b="";r?b=r(y):y.content&&y.content.length>0&&(b=y.content.filter(C=>C.type==="text").map(C=>C.text).join(""));const x=h(y.attrs||{}),S=i(x),k=S?` ${S}`:"";return l?`[${d}${k}]`:`[${d}${k}]${b}[/${d}]`}}}function Rx(t,e,n){var r,s,i,o;const l=t.split(`
|
|
82
|
+
`),u=[];let d="",h=0;const g=e.baseIndentSize||2;for(;h<l.length;){const y=l[h],b=y.match(e.itemPattern);if(!b){if(u.length>0)break;if(y.trim()===""){h+=1,d=`${d}${y}
|
|
83
|
+
`;continue}else return}const x=e.extractItemData(b),{indentLevel:S,mainContent:k}=x;d=`${d}${y}
|
|
84
|
+
`;const C=[k];for(h+=1;h<l.length;){const N=l[h];if(N.trim()===""){const O=l.slice(h+1).findIndex(F=>F.trim()!=="");if(O===-1)break;if((((s=(r=l[h+1+O].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>S){C.push(N),d=`${d}${N}
|
|
85
|
+
`,h+=1;continue}else break}if((((o=(i=N.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>S)C.push(N),d=`${d}${N}
|
|
86
|
+
`,h+=1;else break}let A;const R=C.slice(1);if(R.length>0){const N=R.map(M=>M.slice(S+g)).join(`
|
|
87
|
+
`);N.trim()&&(e.customNestedParser?A=e.customNestedParser(N):A=n.blockTokens(N))}const _=e.createToken(x,A);u.push(_)}if(u.length!==0)return{items:u,raw:d}}function _S(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,l=e.renderChildren([i]);let u=`${s}${l}`;return o&&o.length>0&&o.forEach((d,h)=>{var g,y;const b=(y=(g=e.renderChild)==null?void 0:g.call(e,d,h+1))!=null?y:e.renderChildren([d]);if(b!=null){const x=b.split(`
|
|
88
|
+
`).map(S=>S?e.indent(S):e.indent("")).join(`
|
|
89
|
+
`);u+=d.type==="paragraph"?`
|
|
90
|
+
|
|
91
|
+
${x}`:`
|
|
92
|
+
${x}`}}),u}function aR(t){return typeof t.type=="string"?t.type:t.type.name}function x8(t,e){if(t.length!==e.length)return!1;const n=Array.from({length:e.length},()=>!1);return t.every(r=>{const s=aR(r),i=e.findIndex((o,l)=>!n[l]&&s===aR(o)&&Vc(r.attrs,o.attrs));return i===-1?!1:(n[i]=!0,!0)})}function JD(t,e){const n={...t};return Fh(t)&&Fh(e)&&Object.keys(e).forEach(r=>{Fh(e[r])&&Fh(t[r])?n[r]=JD(t[r],e[r]):n[r]=e[r]}),n}function w8(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,u)=>{const d=i.mapping.map(u),h=i.mapping.map(u)+l.nodeSize;let g=null;if(l.marks.forEach(b=>{if(b!==o)return!1;g=b}),!g)return;let y=!1;if(Object.keys(n).forEach(b=>{n[b]!==g.attrs[b]&&(y=!0)}),y){const b=t.type.create({...t.attrs,...n});i.removeMark(d,h,t.type),i.addMark(d,h,b)}}),i.docChanged&&e.view.dispatch(i)}var xf=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},S8=(t,e)=>{if(vS(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 qh(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:u}=n;if(u.composing)return!1;const d=u.state.doc.resolve(r);if(d.parent.type.spec.code||(e=d.nodeBefore||d.nodeAfter)!=null&&e.marks.find(y=>y.type.spec.code))return!1;let h=!1;const g=D9(d)+i;return o.forEach(y=>{if(h)return;const b=S8(g,y.find);if(!b)return;const x=b[0].length-i.length;if(x>0){const M=d.parentOffset-x;if(M<0||d.parent.textBetween(M,d.parentOffset)!==b[0].slice(0,x))return}const S=u.state.tr,k=kg({state:u.state,transaction:S}),C={from:r-(b[0].length-i.length),to:s},{commands:A,chain:R,can:_}=new Cg({editor:n,state:k});y.handler({state:k,range:C,match:b,commands:A,chain:R,can:_})===null||!S.steps.length||(y.undoable&&S.setMeta(l,{transform:S,from:r,to:s,text:i}),u.dispatch(S),h=!0)}),h}function k8(t){const{editor:e,rules:n}=t,r=new Bt({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const u=s.getMeta("applyInputRules");return u&&setTimeout(()=>{let{text:h}=u;typeof h=="string"?h=h:h=wS(fe.from(h),o.schema);const{from:g}=u,y=g+h.length;qh({editor:e,from:g,to:y,text:h,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return qh({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&qh({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?qh({editor:e,from:o.pos,to:o.pos,text:`
|
|
93
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var AS=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{...bt(je(this,"addOptions",{name:this.name}))}}get storage(){return{...bt(je(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>JD(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}},ml=class QD extends AS{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new QD(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(d=>d?.type.name===n.name))return!1;const u=o.find(d=>d?.type.name===n.name);return u&&r.removeStoredMark(u),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},eI=class{constructor(t){this.find=t.find,this.handler=t.handler}},C8=(t,e,n)=>{if(vS(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function E8(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:u,chain:d,can:h}=new Cg({editor:e,state:n}),g=[];return n.doc.nodesBetween(r,s,(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,N=Math.max(r,x),M=Math.min(s,x+_);if(N>=M)return;const O=b.isText?b.text||"":b.textBetween(N-x,M-x,void 0,"");C8(O,i.find,o).forEach(D=>{if(D.index===void 0)return;const F=N+D.index+1,te=F+D[0].length,H={from:n.tr.mapping.map(F),to:n.tr.mapping.map(te)},Z=i.handler({state:n,range:H,match:D,commands:u,chain:d,can:h,pasteEvent:o,dropEvent:l});g.push(Z)})}),g.every(b=>b!==null)}var Gh=null,T8=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function _8(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!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:g,to:y,rule:b,pasteEvt:x})=>{const S=h.tr,k=kg({state:h,transaction:S});if(!(!E8({editor:e,state:k,from:Math.max(g-1,0),to:y.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 Bt({view(g){const y=x=>{var S;r=(S=g.dom.parentElement)!=null&&S.contains(x.target)?g.dom.parentElement:null,r&&(Gh=e)},b=()=>{Gh&&(Gh=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(g,y)=>{if(i=r===g.dom.parentElement,l=y,!i){const b=Gh;b?.isEditable&&setTimeout(()=>{const x=b.state.selection;x&&b.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(g,y)=>{var b;const x=(b=y.clipboardData)==null?void 0:b.getData("text/html");return o=y,s=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(g,y,b)=>{const x=g[0],S=x.getMeta("uiEvent")==="paste"&&!s,k=x.getMeta("uiEvent")==="drop"&&!i,C=x.getMeta("applyPasteRules"),A=!!C;if(!S&&!k&&!A)return;if(A){let{text:N}=C;typeof N=="string"?N=N:N=wS(fe.from(N),b.schema);const{from:M}=C,O=M+N.length,P=T8(N);return u({rule:h,state:b,from:M,to:{b:O},pasteEvt:P})}const R=y.doc.content.findDiffStart(b.doc.content),_=y.doc.content.findDiffEnd(b.doc.content);if(!(!f8(R)||!_||R===_.b))return u({rule:h,state:b,from:R,to:_,pasteEvt:o})}}))}var Ag=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=SS(t),this.schema=UD(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:Ju(e.name,this.schema)},r=je(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return kc([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Ju(r.name,this.schema)},i=[],o=je(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&je(r,"exitable",s)&&(l.ArrowRight=()=>ml.handleExit({editor:t,mark:r})),o){const y=Object.fromEntries(Object.entries(o()).map(([b,x])=>[b,()=>x({editor:t})]));l={...l,...y}}const u=Rq(l);i.push(u);const d=je(r,"addInputRules",s);if(rR(r,t.options.enableInputRules)&&d){const y=d();if(y&&y.length){const b=k8({editor:t,rules:y}),x=Array.isArray(b)?b:[b];i.push(...x)}}const h=je(r,"addPasteRules",s);if(rR(r,t.options.enablePasteRules)&&h){const y=h();if(y&&y.length){const b=_8({editor:t,rules:y});i.push(...b)}}const g=je(r,"addProseMirrorPlugins",s);if(g){const y=g();i.push(...y)}return i})}get attributes(){return HD(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=$c(this.extensions);return Object.fromEntries(e.filter(n=>!!je(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:wn(n.name,this.schema)},i=je(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(u,d,h,g,y)=>{const b=Bc(u,r);return o({node:u,view:d,getPos:h,decorations:g,innerDecorations:y,editor:t,extension:n,HTMLAttributes:b})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return kc([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Ju(s.name,this.schema)},o=je(s,"dispatchTransaction",i);return o?l=>{o.call(i,{transaction:l,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return kc([...this.extensions]).reduce((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Ju(s.name,this.schema)},o=je(s,"transformPastedHTML",i);return o?(l,u)=>{const d=r(l,u);return o.call(i,d)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=$c(this.extensions);return Object.fromEntries(e.filter(n=>!!je(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Zi(n.name,this.schema)},i=je(n,"addMarkView",s);if(!i)return[];const o=(l,u,d)=>{const h=Bc(l,r);return i()({mark:l,view:u,inline:d,editor:t,extension:n,HTMLAttributes:h,updateAttributes:g=>{w8(l,t,g)}})};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 s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ju(e.name,this.schema)};e.type==="mark"&&(((n=bt(je(e,"keepOnSplit",s)))==null||n)&&this.splittableMarks.push(e.name),(r=bt(je(e,"clearable",s)))==null||r||this.nonClearableMarks.push(e.name));const i=je(e,"onBeforeCreate",s),o=je(e,"onCreate",s),l=je(e,"onUpdate",s),u=je(e,"onSelectionUpdate",s),d=je(e,"onTransaction",s),h=je(e,"onFocus",s),g=je(e,"onBlur",s),y=je(e,"onDestroy",s);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),l&&this.editor.on("update",l),u&&this.editor.on("selectionUpdate",u),d&&this.editor.on("transaction",d),h&&this.editor.on("focus",h),g&&this.editor.on("blur",g),y&&this.editor.on("destroy",y)})}};Ag.resolve=SS;Ag.sort=kc;Ag.flatten=_g;var A8={};bS(A8,{ClipboardTextSerializer:()=>nI,Commands:()=>rI,Delete:()=>sI,Drop:()=>iI,Editable:()=>oI,FocusEvents:()=>lI,Keymap:()=>cI,Paste:()=>uI,Tabindex:()=>dI,TextDirection:()=>fI,focusEventsPluginKey:()=>aI});var Zt=class tI extends AS{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new tI(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},nI=Zt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Bt({key:new on("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,i=GD(n),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:i};return[...s.ranges].sort((d,h)=>d.$from.pos-h.$from.pos).map(({$from:d,$to:h})=>qD(r,{from:d.pos,to:h.pos},l)).join(o??`
|
|
94
|
+
|
|
95
|
+
`)}}})]}}),rI=Zt.create({name:"commands",addCommands(){return{...vs}}}),sI=Zt.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,l,u,d;if((d=(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?d:t.getMeta("y-sync$"))return;const h=$D(t.before,[t,...e]);kS(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 y=h.mapping;h.steps.forEach((b,x)=>{var S,k;if(b instanceof _s){const C=y.slice(x).map(b.from,-1),A=y.slice(x).map(b.to),R=y.invert().map(C,-1),_=y.invert().map(A),N=C>0?(S=h.doc.nodeAt(C-1))==null?void 0:S.marks.some(O=>O.eq(b.mark)):!1,M=(k=h.doc.nodeAt(A))==null?void 0:k.marks.some(O=>O.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:!!(M||N),editor:this.editor,transaction:t,combinedTransform:h})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),iI=Zt.create({name:"drop",addProseMirrorPlugins(){return[new Bt({key:new on("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),oI=Zt.create({name:"editable",addProseMirrorPlugins(){return[new Bt({key:new on("editable"),props:{editable:()=>this.editor.options.editable}})]}}),aI=new on("focusEvents"),lI=Zt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Bt({key:aI,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}}}})]}}),cI=Zt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:u,doc:d}=l,{empty:h,$anchor:g}=u,{pos:y,parent:b}=g,x=g.parent.isTextblock&&y>0?l.doc.resolve(y-1):g,S=x.parent.type.spec.isolating,k=g.pos-g.parentOffset,C=S&&x.parent.childCount===1?k===g.pos:Ye.atStart(d).from===y;return!h||!b.type.isTextblock||b.textContent.length||!C||C&&g.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()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return gm()||PD()?i:s},addProseMirrorPlugins(){return[new Bt({key:new on("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),s=t.some(S=>S.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,u=Ye.atStart(e.doc).from,d=Ye.atEnd(e.doc).to;if(i||!(o===u&&l===d)||!vf(n.doc))return;const y=n.tr,b=kg({state:n,transaction:y}),{commands:x}=new Cg({editor:this.editor,state:b});if(x.clearNodes(),!!y.steps.length)return y}})]}}),uI=Zt.create({name:"paste",addProseMirrorPlugins(){return[new Bt({key:new on("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),dI=Zt.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new Bt({key:new on("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),fI=Zt.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=$c(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 Bt({key:new on("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),R8=class dd{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new dd(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 dd(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 dd(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(l);if(!s&&!o&&u.depth<=this.depth)return;const d=new dd(u,this.editor,s,s||o?n:null);s&&(d.actualDepth=this.depth+1),e.push(d)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const u=o[l];if(i[u]!==n[u])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(u=>n[u]===o.node.attrs[u])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},N8=`.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
|
+
}`,M8=class extends l8{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:z9,createMappablePosition:$9},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:s})=>this.options.onDrop(n,r,s)),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=Tx(e,this.options.autofocus);this.editorState=$a.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=u8(N8,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=VD(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e,n,r;const i=[...this.options.enableCoreExtensions?[oI,nI.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),rI,lI,cI,dI.configure({value:(r=(n=this.options.coreExtensionOptions)==null?void 0:n.tabindex)==null?void 0:r.value}),iI,uI,sI,fI.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 Ag(i,this)}createCommandManager(){this.commandManager=new Cg({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=_x(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=_x(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=$a.create({doc:n,schema:this.schema,selection:Tx(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),s=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new MD(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:s,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(d=>{var h;return(h=this.capturedTransaction)==null?void 0:h.step(d)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(d=>d.getMeta("focus")||d.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(d=>d.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return WD(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return I9(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return wS(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
|
|
166
|
+
|
|
167
|
+
`,textSerializers:n={}}=t||{};return R9(this.state.doc,{blockSeparator:e,textSerializers:{...GD(this.schema),...n}})}get isEmpty(){return vf(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 R8(e,this,!1,n)}get $doc(){return this.$pos(0)}};function sl(t){return new xf({find:t.find,handler:({state:e,range:n,match:r})=>{const s=bt(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const u=l.search(/\S/),d=n.from+l.indexOf(o),h=d+o.length;if(CS(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>d).length)return null;h<n.to&&i.delete(h,n.to),d>n.from&&i.delete(n.from+u,d);const y=n.from+u+o.length;i.addMark(n.from+u,y,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function hI(t){return new xf({find:t.find,handler:({state:e,range:n,match:r})=>{const s=bt(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let l=n.to;const u=t.type.create(s);if(r[1]){const d=r[0].lastIndexOf(r[1]);let h=o+d;h>l?h=l:l=h+r[1].length;const g=r[0][r[0].length-1];i.insertText(g,o+r[0].length-1),i.replaceWith(h,l,u)}else if(r[0]){const d=t.type.isInline?o:o-1;i.insert(d,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function Nx(t){return new xf({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=bt(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Hc(t){return new xf({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=bt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),d=u&&tS(u,t.type,i);if(!d)return null;if(o.wrap(u,d),t.keepMarks&&t.editor){const{selection:g,storedMarks:y}=e,{splittableMarks:b}=t.editor.extensionManager,x=y||g.$to.parentOffset&&g.$from.marks();if(x){const S=x.filter(k=>b.includes(k.type.name));o.ensureMarks(S)}}if(t.keepAttributes){const g=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(g,i).run()}const h=o.doc.resolve(n.from-1).nodeBefore;h&&h.type===t.type&&la(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,h))&&o.join(n.from-1)},undoable:t.undoable})}var O8=t=>"touches"in t,j8=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,d=l.clientY-this.startY;this.handleResize(u,d)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const u=l.touches[0];if(!u)return;const d=u.clientX-this.startX,h=u.clientY-this.startY;this.handleResize(d,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,s,i,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),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(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"),s=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,O8(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,s,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const i=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),u=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),l?s=this.startHeight+n:u&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,o;if(!n){let d=Math.max(this.minSize.width,t),h=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(d=Math.min(this.maxSize.width,d)),(s=this.maxSize)!=null&&s.height&&(h=Math.min(this.maxSize.height,h)),{width:d,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),(i=this.maxSize)!=null&&i.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",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}},On=class pI extends AS{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new pI(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function na(t){return new eI({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=bt(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],u=r[0];let d=n.to;if(l){const h=u.search(/\S/),g=n.from+u.indexOf(l),y=g+l.length;if(CS(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>g).length)return null;y<n.to&&o.delete(y,n.to),g>n.from&&o.delete(n.from+h,g),d=n.from+h+l.length,o.addMark(n.from+h,d,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:D8,getOwnPropertySymbols:I8}=Object,{hasOwnProperty:L8}=Object.prototype;function Kv(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function Wh(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,o=i.get(n),l=i.get(r);if(o&&l)return o===r&&l===n;i.set(n,r),i.set(r,n);const u=t(n,r,s);return i.delete(n),i.delete(r),u}}function P8(t){return t?.[Symbol.toStringTag]}function lR(t){return D8(t).concat(I8(t))}const z8=Object.hasOwn||((t,e)=>L8.call(t,e));function gl(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const $8="__v",B8="__o",V8="_owner",{getOwnPropertyDescriptor:cR,keys:uR}=Object;function H8(t,e){return t.byteLength===e.byteLength&&ym(new Uint8Array(t),new Uint8Array(e))}function U8(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 F8(t,e){return t.byteLength===e.byteLength&&ym(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function q8(t,e){return gl(t.getTime(),e.getTime())}function G8(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function W8(t,e){return t===e}function dR(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let o,l,u=0;for(;(o=i.next())&&!o.done;){const d=e.entries();let h=!1,g=0;for(;(l=d.next())&&!l.done;){if(s[g]){g++;continue}const y=o.value,b=l.value;if(n.equals(y[0],b[0],u,g,t,e,n)&&n.equals(y[1],b[1],y[0],b[0],t,e,n)){h=s[g]=!0;break}g++}if(!h)return!1;u++}return!0}const K8=gl;function Z8(t,e,n){const r=uR(t);let s=r.length;if(uR(e).length!==s)return!1;for(;s-- >0;)if(!mI(t,e,n,r[s]))return!1;return!0}function Qu(t,e,n){const r=lR(t);let s=r.length;if(lR(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!mI(t,e,n,i)||(o=cR(t,i),l=cR(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function Y8(t,e){return gl(t.valueOf(),e.valueOf())}function X8(t,e){return t.source===e.source&&t.flags===e.flags}function fR(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let o,l;for(;(o=i.next())&&!o.done;){const u=e.values();let d=!1,h=0;for(;(l=u.next())&&!l.done;){if(!s[h]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){d=s[h]=!0;break}h++}if(!d)return!1}return!0}function ym(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 J8(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 mI(t,e,n,r){return(r===V8||r===B8||r===$8)&&(t.$$typeof||e.$$typeof)?!0:z8(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const Q8="[object ArrayBuffer]",eG="[object Arguments]",tG="[object Boolean]",nG="[object DataView]",rG="[object Date]",sG="[object Error]",iG="[object Map]",oG="[object Number]",aG="[object Object]",lG="[object RegExp]",cG="[object Set]",uG="[object String]",dG={"[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},fG="[object URL]",hG=Object.prototype.toString;function pG({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:u,arePrimitiveWrappersEqual:d,areRegExpsEqual:h,areSetsEqual:g,areTypedArraysEqual:y,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"?i(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 g(k,C,A);const N=hG.call(k);if(N===rG)return r(k,C,A);if(N===lG)return h(k,C,A);if(N===iG)return o(k,C,A);if(N===cG)return g(k,C,A);if(N===aG)return typeof k.then!="function"&&typeof C.then!="function"&&u(k,C,A);if(N===fG)return b(k,C,A);if(N===sG)return s(k,C,A);if(N===eG)return u(k,C,A);if(dG[N])return y(k,C,A);if(N===Q8)return t(k,C,A);if(N===nG)return n(k,C,A);if(N===tG||N===oG||N===uG)return d(k,C,A);if(x){let M=x[N];if(!M){const O=P8(k);O&&(M=x[O])}if(M)return M(k,C,A)}return!1}}function mG({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:H8,areArraysEqual:n?Qu:U8,areDataViewsEqual:F8,areDatesEqual:q8,areErrorsEqual:G8,areFunctionsEqual:W8,areMapsEqual:n?Kv(dR,Qu):dR,areNumbersEqual:K8,areObjectsEqual:n?Qu:Z8,arePrimitiveWrappersEqual:Y8,areRegExpsEqual:X8,areSetsEqual:n?Kv(fR,Qu):fR,areTypedArraysEqual:n?Kv(ym,Qu):ym,areUrlsEqual:J8,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=Wh(r.areArraysEqual),i=Wh(r.areMapsEqual),o=Wh(r.areObjectsEqual),l=Wh(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function gG(t){return function(e,n,r,s,i,o,l){return t(e,n,l)}}function yG({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(l,u){const{cache:d=t?new WeakMap:void 0,meta:h}=n();return e(l,u,{cache:d,equals:r,meta:h,strict:s})};if(t)return function(l,u){return e(l,u,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,u){return e(l,u,i)}}const bG=ua();ua({strict:!0});ua({circular:!0});ua({circular:!0,strict:!0});ua({createInternalComparator:()=>gl});ua({strict:!0,createInternalComparator:()=>gl});ua({circular:!0,createInternalComparator:()=>gl});ua({circular:!0,createInternalComparator:()=>gl,strict:!0});function ua(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=mG(t),o=pG(i),l=n?n(o):gG(o);return yG({circular:e,comparator:o,createState:r,equals:l,strict:s})}var Zv={exports:{}},Yv={};var hR;function vG(){if(hR)return Yv;hR=1;var t=tf(),e=JO();function n(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,l=t.useMemo,u=t.useDebugValue;return Yv.useSyncExternalStoreWithSelector=function(d,h,g,y,b){var x=i(null);if(x.current===null){var S={hasValue:!1,value:null};x.current=S}else S=x.current;x=l(function(){function C(M){if(!A){if(A=!0,R=M,M=y(M),b!==void 0&&S.hasValue){var O=S.value;if(b(O,M))return _=O}return _=M}if(O=_,r(R,M))return O;var P=y(M);return b!==void 0&&b(O,P)?(R=M,O):(R=M,_=P)}var A=!1,R,_,N=g===void 0?null:g;return[function(){return C(h())},N===null?void 0:function(){return C(N())}]},[h,g,y,b]);var k=s(d,x[0],x[1]);return o(function(){S.hasValue=!0,S.value=k},[k]),u(k),k},Yv}var pR;function xG(){return pR||(pR=1,Zv.exports=vG()),Zv.exports}var wG=xG(),SG=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},kG=({contentComponent:t})=>{const e=QO.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function CG(){const t=new Set;let e={},n=!1;const r=()=>{n||!t.size||(n=!0,queueMicrotask(()=>{n=!1,t.forEach(s=>s())}))};return{subscribe(s){return t.add(s),()=>{t.delete(s)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(s,i){e={...e,[s]:BF.createPortal(i.reactElement,i.element,s)},r()},removeRenderer(s){const i={...e};delete i[s],e=i,r()}}}var EG=class extends We.Component{constructor(t){super(t),this.editorContentRef=We.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=CG(),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 m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:SG(e,this.editorContentRef),...n}),t?.contentComponent&&m.jsx(kG,{contentComponent:t.contentComponent})]})}},TG=E.forwardRef((t,e)=>{const n=We.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return We.createElement(EG,{key:n,innerRef:e,...t})}),gI=We.memo(TG),_G=typeof window<"u"?E.useLayoutEffect:E.useEffect,AG=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=s=>{s?.transaction!==void 0&&s.transaction===e||(e=s?.transaction,this.transactionNumber+=1,this.subscribers.forEach(i=>i()))},r=this.editor;return r.on("transaction",n),r.on("update",n),()=>{r.off("transaction",n),r.off("update",n)}}}};function yI(t){var e;const[n]=E.useState(()=>new AG(t.editor)),r=wG.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:bG);return _G(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var RG=!1,bI=typeof window>"u",NG=bI||!!(typeof window<"u"&&window.next),MG=class vI{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 bI?(n&&RG&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),n=!1):NG&&e===void 0&&(n=!1),n?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)},onMount:(...r)=>{var s,i;return(i=(s=this.options.current).onMount)==null?void 0:i.call(s,...r)},onUnmount:(...r)=>{var s,i;return(i=(s=this.options.current).onUnmount)==null?void 0:i.call(s,...r)}};return new M8(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?vI.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function OG(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new MG(n)),s=QO.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),yI({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var xI=E.createContext({editor:null});xI.Consumer;var jG=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),DG=()=>E.useContext(jG);We.forwardRef((t,e)=>{const{onDragStart:n}=DG(),r=t.as||"div";return m.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});We.createContext({markViewContentRef:()=>{}});var RS=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});RS.displayName="TiptapContext";var IG=()=>E.useContext(RS);function wI({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]),s=E.useMemo(()=>({editor:n}),[n]);return m.jsx(xI.Provider,{value:s,children:m.jsx(RS.Provider,{value:r,children:t})})}wI.displayName="Tiptap";function SI({...t}){const{editor:e}=IG();return m.jsx(gI,{editor:e,...t})}SI.displayName="Tiptap.Content";Object.assign(wI,{Content:SI});var bm=(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]},LG=(t,e)=>{var n;const{state:r,view:s}=t,{selection:i}=r;if(!i.empty)return!1;const{$from:o}=i;if(o.parentOffset!==0)return!1;const l=o.depth-1;if(l<0)return!1;const u=o.node(l),d=o.index(l);if(d===0)return!1;if(u.type===e)return t.commands.lift(e.name);const h=u.child(d-1);if(h.type!==e||!((n=h.lastChild)!=null&&n.isTextblock))return!1;const g=o.before(),b=g-1-1,{tr:x}=r;return x.delete(g,o.after()).insert(b,o.parent.content),x.setSelection($e.create(x.doc,b)),s.dispatch(x.scrollIntoView()),!0},PG=/^\s*>\s$/,zG=On.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return bm("blockquote",{...$t(this.options.HTMLAttributes,t),children:bm("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((s,i)=>{var o,l;const h=((l=(o=e.renderChild)==null?void 0:o.call(e,s,i))!=null?l:e.renderChildren([s])).split(`
|
|
168
|
+
`).map(g=>g.trim()===""?n:`${n} ${g}`);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:()=>LG(this.editor,this.type)}},addInputRules(){return[Hc({find:PG,type:this.type})]}}),$G=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,BG=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,VG=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,HG=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,UG=ml.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 bm("strong",{...$t(this.options.HTMLAttributes,t),children:bm("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[sl({find:$G,type:this.type}),sl({find:VG,type:this.type})]},addPasteRules(){return[na({find:BG,type:this.type}),na({find:HG,type:this.type})]}}),FG=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},qG=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},GG=ml.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",$t(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[sl({find:FG,type:this.type})]},addPasteRules(){return[na({find:qG,type:this.type})]}}),Xv=4,WG=/^```([a-z]+)?[\s\n]$/,KG=/^~~~([a-z]+)?[\s\n]$/,ZG=On.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Xv,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",$t(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 s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
|
|
172
|
+
`):r=`\`\`\`${s}
|
|
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:Xv,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:u})=>{const{from:d,to:h}=s,b=r.doc.textBetween(d,h,`
|
|
175
|
+
`,`
|
|
176
|
+
`).split(`
|
|
177
|
+
`).map(x=>l+x).join(`
|
|
178
|
+
`);return u.replaceWith(d,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:Xv,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var u;const{pos:d}=i,h=i.start(),g=i.end(),b=r.doc.textBetween(h,g,`
|
|
179
|
+
`,`
|
|
180
|
+
`).split(`
|
|
181
|
+
`);let x=0,S=0;const k=d-h;for(let M=0;M<b.length;M+=1){if(S+b[M].length>=k){x=M;break}S+=b[M].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 M=0;M<x;M+=1)_+=b[M].length+1;return l.delete(_,_+R),d-_<=R&&l.setSelection($e.create(l.doc,_)),!0}):t.commands.command(({tr:l})=>{const{from:u,to:d}=s,y=r.doc.textBetween(u,d,`
|
|
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,d,r.schema.text(y)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
186
|
+
|
|
187
|
+
`);return!i||!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:s}=n;if(!s||r.parent.type!==this.type||r.parentOffset!==0)return!1;const i=r.before();return i>0?!1:t.commands.insertDefaultBlock({pos:i})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:d})=>(d.setSelection(Ye.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Nx({find:WG,type:this.type,getAttributes:t=>({language:t[1]})}),Nx({find:KG,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Bt({key:new on("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)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:i},u)),o.selection.$from.parent.type!==this.type&&o.setSelection($e.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),YG=On.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
189
|
+
|
|
190
|
+
`):""}),XG=On.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",$t(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:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,u=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:h})=>{if(h&&u&&o){const g=u.filter(y=>l.includes(y.type.name));d.ensureMarks(g)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),JG=On.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]}`,$t(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Nx({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),QG=On.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",$t(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!c8(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return KD(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:u}=o.selection,d=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection($e.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Fe.create(o.doc,u.pos)):o.setSelection($e.create(o.doc,u.pos));else{const h=i.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,g=h?.create();g&&(o.insert(d,g),o.setSelection($e.create(o.doc,d+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[hI({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),eW=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,tW=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,nW=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,rW=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,sW=ml.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",$t(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[sl({find:eW,type:this.type}),sl({find:nW,type:this.type})]},addPasteRules(){return[na({find:tW,type:this.type}),na({find:rW,type:this.type})]}});const iW="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",oW="ελ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",Ox="ascii",jx="alpha",kd="asciinumeric",fd="alphanumeric",Dx="domain",kI="emoji",aW="scheme",lW="slashscheme",Jv="whitespace";function cW(t,e){return t in e||(e[t]=[]),e[t]}function Ua(t,e,n){e[Mx]&&(e[kd]=!0,e[fd]=!0),e[Ox]&&(e[kd]=!0,e[jx]=!0),e[kd]&&(e[fd]=!0),e[jx]&&(e[fd]=!0),e[fd]&&(e[Dx]=!0),e[kI]&&(e[Dx]=!0);for(const r in e){const s=cW(r,n);s.indexOf(t)<0&&s.push(t)}}function uW(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function kr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}kr.groups={};kr.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||kr.groups;let s;return e&&e.j?s=e:(s=new kr(e),n&&r&&Ua(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||kr.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,l=s.go(t);if(l?(o=new kr,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new kr,i){if(r)if(o.t&&typeof o.t=="string"){const u=Object.assign(uW(o.t,r),n);Ua(i,u,r)}else n&&Ua(i,n,r);o.t=i}return s.j[t]=o,o}};const it=(t,e,n,r,s)=>t.ta(e,n,r,s),nn=(t,e,n,r,s)=>t.tr(e,n,r,s),mR=(t,e,n,r,s)=>t.ts(e,n,r,s),ve=(t,e,n,r,s)=>t.tt(e,n,r,s),Ei="WORD",Ix="UWORD",CI="ASCIINUMERICAL",EI="ALPHANUMERICAL",Yd="LOCALHOST",Lx="TLD",Px="UTLD",Op="SCHEME",gc="SLASH_SCHEME",NS="NUM",zx="WS",MS="NL",Cd="OPENBRACE",Ed="CLOSEBRACE",vm="OPENBRACKET",xm="CLOSEBRACKET",wm="OPENPAREN",Sm="CLOSEPAREN",km="OPENANGLEBRACKET",Cm="CLOSEANGLEBRACKET",Em="FULLWIDTHLEFTPAREN",Tm="FULLWIDTHRIGHTPAREN",_m="LEFTCORNERBRACKET",Am="RIGHTCORNERBRACKET",Rm="LEFTWHITECORNERBRACKET",Nm="RIGHTWHITECORNERBRACKET",Mm="FULLWIDTHLESSTHAN",Om="FULLWIDTHGREATERTHAN",jm="AMPERSAND",Dm="APOSTROPHE",Im="ASTERISK",Ro="AT",Lm="BACKSLASH",Pm="BACKTICK",zm="CARET",Fa="COLON",OS="COMMA",$m="DOLLAR",Us="DOT",Bm="EQUALS",jS="EXCLAMATION",ts="HYPHEN",Td="PERCENT",Vm="PIPE",Hm="PLUS",Um="POUND",_d="QUERY",DS="QUOTE",TI="FULLWIDTHMIDDLEDOT",IS="SEMI",Fs="SLASH",Ad="TILDE",Fm="UNDERSCORE",_I="EMOJI",qm="SYM";var AI=Object.freeze({__proto__:null,ALPHANUMERICAL:EI,AMPERSAND:jm,APOSTROPHE:Dm,ASCIINUMERICAL:CI,ASTERISK:Im,AT:Ro,BACKSLASH:Lm,BACKTICK:Pm,CARET:zm,CLOSEANGLEBRACKET:Cm,CLOSEBRACE:Ed,CLOSEBRACKET:xm,CLOSEPAREN:Sm,COLON:Fa,COMMA:OS,DOLLAR:$m,DOT:Us,EMOJI:_I,EQUALS:Bm,EXCLAMATION:jS,FULLWIDTHGREATERTHAN:Om,FULLWIDTHLEFTPAREN:Em,FULLWIDTHLESSTHAN:Mm,FULLWIDTHMIDDLEDOT:TI,FULLWIDTHRIGHTPAREN:Tm,HYPHEN:ts,LEFTCORNERBRACKET:_m,LEFTWHITECORNERBRACKET:Rm,LOCALHOST:Yd,NL:MS,NUM:NS,OPENANGLEBRACKET:km,OPENBRACE:Cd,OPENBRACKET:vm,OPENPAREN:wm,PERCENT:Td,PIPE:Vm,PLUS:Hm,POUND:Um,QUERY:_d,QUOTE:DS,RIGHTCORNERBRACKET:Am,RIGHTWHITECORNERBRACKET:Nm,SCHEME:Op,SEMI:IS,SLASH:Fs,SLASH_SCHEME:gc,SYM:qm,TILDE:Ad,TLD:Lx,UNDERSCORE:Fm,UTLD:Px,UWORD:Ix,WORD:Ei,WS:zx});const Si=/[a-z]/,ed=new RegExp("\\p{L}","u"),Qv=new RegExp("\\p{Emoji}","u"),ki=/\d/,e0=/\s/,gR="\r",t0=`
|
|
193
|
+
`,dW="️",fW="",n0="";let Kh=null,Zh=null;function hW(t=[]){const e={};kr.groups=e;const n=new kr;Kh==null&&(Kh=yR(iW)),Zh==null&&(Zh=yR(oW)),ve(n,"'",Dm),ve(n,"{",Cd),ve(n,"}",Ed),ve(n,"[",vm),ve(n,"]",xm),ve(n,"(",wm),ve(n,")",Sm),ve(n,"<",km),ve(n,">",Cm),ve(n,"(",Em),ve(n,")",Tm),ve(n,"「",_m),ve(n,"」",Am),ve(n,"『",Rm),ve(n,"』",Nm),ve(n,"<",Mm),ve(n,">",Om),ve(n,"&",jm),ve(n,"*",Im),ve(n,"@",Ro),ve(n,"`",Pm),ve(n,"^",zm),ve(n,":",Fa),ve(n,",",OS),ve(n,"$",$m),ve(n,".",Us),ve(n,"=",Bm),ve(n,"!",jS),ve(n,"-",ts),ve(n,"%",Td),ve(n,"|",Vm),ve(n,"+",Hm),ve(n,"#",Um),ve(n,"?",_d),ve(n,'"',DS),ve(n,"/",Fs),ve(n,";",IS),ve(n,"~",Ad),ve(n,"_",Fm),ve(n,"\\",Lm),ve(n,"・",TI);const r=nn(n,ki,NS,{[Mx]:!0});nn(r,ki,r);const s=nn(r,Si,CI,{[kd]:!0}),i=nn(r,ed,EI,{[fd]:!0}),o=nn(n,Si,Ei,{[Ox]:!0});nn(o,ki,s),nn(o,Si,o),nn(s,ki,s),nn(s,Si,s);const l=nn(n,ed,Ix,{[jx]:!0});nn(l,Si),nn(l,ki,i),nn(l,ed,l),nn(i,ki,i),nn(i,Si),nn(i,ed,i);const u=ve(n,t0,MS,{[Jv]:!0}),d=ve(n,gR,zx,{[Jv]:!0}),h=nn(n,e0,zx,{[Jv]:!0});ve(n,n0,h),ve(d,t0,u),ve(d,n0,h),nn(d,e0,h),ve(h,gR),ve(h,t0),nn(h,e0,h),ve(h,n0,h);const g=nn(n,Qv,_I,{[kI]:!0});ve(g,"#"),nn(g,Qv,g),ve(g,dW,g);const y=ve(g,fW);ve(y,"#"),nn(y,Qv,g);const b=[[Si,o],[ki,s]],x=[[Si,null],[ed,l],[ki,i]];for(let S=0;S<Kh.length;S++)Co(n,Kh[S],Lx,Ei,b);for(let S=0;S<Zh.length;S++)Co(n,Zh[S],Px,Ix,x);Ua(Lx,{tld:!0,ascii:!0},e),Ua(Px,{utld:!0,alpha:!0},e),Co(n,"file",Op,Ei,b),Co(n,"mailto",Op,Ei,b),Co(n,"http",gc,Ei,b),Co(n,"https",gc,Ei,b),Co(n,"ftp",gc,Ei,b),Co(n,"ftps",gc,Ei,b),Ua(Op,{scheme:!0,ascii:!0},e),Ua(gc,{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]?{[aW]:!0}:{[lW]:!0};k.indexOf("-")>=0?A[Dx]=!0:Si.test(k)?ki.test(k)?A[kd]=!0:A[Ox]=!0:A[Mx]=!0,mR(n,k,k,A)}return mR(n,"localhost",Yd,{ascii:!0}),n.jd=new kr(qm),{start:n,tokens:Object.assign({groups:e},AI)}}function RI(t,e){const n=pW(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let l=t,u=null,d=0,h=null,g=-1,y=-1;for(;o<r&&(u=l.go(n[o]));)l=u,l.accepts()?(g=0,y=0,h=l):g>=0&&(g+=n[o].length,y++),d+=n[o].length,i+=n[o].length,o++;i-=g,o-=y,d-=g,s.push({t:h.t,v:e.slice(i-d,i),s:i-d,e:i})}return s}function pW(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Co(t,e,n,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const u=e[l];t.j[u]?i=t.j[u]:(i=new kr(r),i.jr=s.slice(),t.j[u]=i),t=i}return i=new kr(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function yR(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Xd={defaultProtocol:"http",events:null,format:bR,formatHref:bR,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function LS(t,e=null){let n=Object.assign({},Xd);t&&(n=Object.assign(n,t instanceof LS?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}LS.prototype={o:Xd,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Xd[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function bR(t){return t}function NI(t,e){this.t="token",this.v=t,this.tk=e}NI.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=Xd.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},l=t.get("className",n,e),u=t.get("target",n,e),d=t.get("rel",n,e),h=t.getObj("attributes",n,e),g=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),u&&(o.target=u),d&&(o.rel=d),h&&Object.assign(o,h),{tagName:s,attributes:o,content:i,eventListeners:g}}};function Rg(t,e){class n extends NI{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const mW=Rg("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),vR=Rg("text"),gW=Rg("nl"),Yh=Rg("url",{isLink:!0,toHref(t=Xd.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Yd&&t[1].t===Fa}}),es=t=>new kr(t);function yW({groups:t}){const e=t.domain.concat([jm,Im,Ro,Lm,Pm,zm,$m,Bm,ts,NS,Td,Vm,Hm,Um,Fs,qm,Ad,Fm]),n=[Dm,Fa,OS,Us,jS,Td,_d,DS,IS,km,Cm,Cd,Ed,xm,vm,wm,Sm,Em,Tm,_m,Am,Rm,Nm,Mm,Om],r=[jm,Dm,Im,Lm,Pm,zm,$m,Bm,ts,Cd,Ed,Td,Vm,Hm,Um,_d,Fs,qm,Ad,Fm],s=es(),i=ve(s,Ad);it(i,r,i),it(i,t.domain,i);const o=es(),l=es(),u=es();it(s,t.domain,o),it(s,t.scheme,l),it(s,t.slashscheme,u),it(o,r,i),it(o,t.domain,o);const d=ve(o,Ro);ve(i,Ro,d),ve(l,Ro,d),ve(u,Ro,d);const h=ve(i,Us);it(h,r,i),it(h,t.domain,i);const g=es();it(d,t.domain,g),it(g,t.domain,g);const y=ve(g,Us);it(y,t.domain,g);const b=es(mW);it(y,t.tld,b),it(y,t.utld,b),ve(d,Yd,b);const x=ve(g,ts);ve(x,ts,x),it(x,t.domain,g),it(b,t.domain,g),ve(b,Us,y),ve(b,ts,x);const S=ve(o,ts),k=ve(o,Us);ve(S,ts,S),it(S,t.domain,o),it(k,r,i),it(k,t.domain,o);const C=es(Yh);it(k,t.tld,C),it(k,t.utld,C),it(C,t.domain,o),it(C,r,i),ve(C,Us,k),ve(C,ts,S),ve(C,Ro,d);const A=ve(C,Fa),R=es(Yh);it(A,t.numeric,R);const _=es(Yh),N=es();it(_,e,_),it(_,n,N),it(N,e,_),it(N,n,N),ve(C,Fs,_),ve(R,Fs,_);const M=ve(l,Fa),O=ve(u,Fa),P=ve(O,Fs),D=ve(P,Fs);it(l,t.domain,o),ve(l,Us,k),ve(l,ts,S),it(u,t.domain,o),ve(u,Us,k),ve(u,ts,S),it(M,t.domain,_),ve(M,Fs,_),ve(M,_d,_),it(D,t.domain,_),it(D,e,_),ve(D,Fs,_);const F=[[Cd,Ed],[vm,xm],[wm,Sm],[km,Cm],[Em,Tm],[_m,Am],[Rm,Nm],[Mm,Om]];for(let te=0;te<F.length;te++){const[H,Z]=F[te],G=ve(_,H);ve(N,H,G);const ae=es(Yh);it(G,e,ae);const z=es();it(G,n,z),ve(G,Z,_),it(ae,e,ae),it(ae,n,z),it(z,e,ae),it(z,n,z),ve(ae,Z,_),ve(z,Z,_)}return ve(s,Yd,C),ve(s,MS,gW),{start:s,tokens:AI}}function bW(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let l=t,u=null,d=null,h=0,g=null,y=-1;for(;s<r&&!(u=l.go(n[s].t));)o.push(n[s++]);for(;s<r&&(d=u||l.go(n[s].t));)u=null,l=d,l.accepts()?(y=0,g=l):y>=0&&y++,s++,h++;if(y<0)s-=h,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(r0(vR,e,o)),o=[]),s-=y,h-=y;const b=g.t,x=n.slice(s-h,s);i.push(r0(b,e,x))}}return o.length>0&&i.push(r0(vR,e,o)),i}function r0(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const vW=typeof console<"u"&&console&&console.warn||(()=>{}),xW="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",qt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function wW(){return kr.groups={},qt.scanner=null,qt.parser=null,qt.tokenQueue=[],qt.pluginQueue=[],qt.customSchemes=[],qt.initialized=!1,qt}function xR(t,e=!1){if(qt.initialized&&vW(`linkifyjs: already initialized - will not register custom scheme "${t}" ${xW}`),!/^[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`);qt.customSchemes.push([t,e])}function SW(){qt.scanner=hW(qt.customSchemes);for(let t=0;t<qt.tokenQueue.length;t++)qt.tokenQueue[t][1]({scanner:qt.scanner});qt.parser=yW(qt.scanner.tokens);for(let t=0;t<qt.pluginQueue.length;t++)qt.pluginQueue[t][1]({scanner:qt.scanner,parser:qt.parser});return qt.initialized=!0,qt}function PS(t){return qt.initialized||SW(),bW(qt.parser.start,t,RI(qt.scanner.start,t))}PS.scan=RI;function MI(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 LS(n),s=PS(t),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var zS="[\0- -\u2029 ]",kW=new RegExp(zS),CW=new RegExp(`${zS}$`),EW=new RegExp(zS,"g");function TW(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function _W(t){return new Bt({key:new on("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(d=>d.docChanged)&&!n.doc.eq(r.doc),i=e.some(d=>d.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=$D(n.doc,[...e]);if(kS(l).forEach(({newRange:d})=>{const h=k9(r.doc,d,b=>b.isTextblock);let g,y;if(h.length>1)g=h[0],y=r.doc.textBetween(g.pos,g.pos+g.node.nodeSize,void 0," ");else if(h.length){const b=r.doc.textBetween(d.from,d.to," "," ");if(!CW.test(b))return;g=h[0],y=r.doc.textBetween(g.pos,d.to,void 0," ")}if(g&&y){const b=y.split(kW).filter(Boolean);if(b.length<=0)return!1;const x=b[b.length-1],S=g.pos+y.lastIndexOf(x);if(!x)return!1;const k=PS(x).map(C=>C.toObject(t.defaultProtocol));if(!TW(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=>{CS(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 AW(t){return new Bt({key:new on("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;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 d=t.editor.view.dom;o=u.closest("a"),o&&!d.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=WD(e.state,t.type.name),d=(s=o.href)!=null?s:u.href,h=(i=o.target)!=null?i:u.target;d&&(window.open(d,h),l=!0)}return l}}})}var RW=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,NW=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function OI(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function MW(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&OI(t,r)){r+=1;continue}let s=0;for(;r<e&&t[r]==="`";)s+=1,r+=1;n===0?n=s:s===n&&(n=0)}return n>0}function jI(t,e,n){var r,s;const[,i,o]=e;return(e.index?t[e.index-1]:void 0)==="!"||OI(t,(r=e.index)!=null?r:0)||MW(t,(s=e.index)!=null?s:0)?!1:!!i.trim()&&n(o)}function DI(t){var e,n;const[r,s,i,,o,l,u]=t,d=(e=o??l)!=null?e:u;return{index:(n=t.index)!=null?n:0,text:r,replaceWith:s,data:{href:i,title:d||null,markdown:!0}}}function OW(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function II(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 jW(t){const e=sl({find:n=>{const r=RW.exec(n);return!r||!jI(n,r,t.isAllowedHref)?null:DI(r)},type:t.type,getAttributes:II});return new xf({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 DW(t){const e=na({find:n=>{var r,s;const i=[];for(const l of n.matchAll(NW))jI(n,l,t.isAllowedHref)&&i.push(DI(l));const o=((s=(r=t.findPlainUrls)==null?void 0:r.call(t,n))!=null?s:[]).filter(l=>!i.some(u=>OW(u,l)));return[...i,...o]},type:t.type,getAttributes:II});return new eI({find:e.find,handler:n=>{var r;const s=e.handler(n);return s!==null&&n.state.tr.steps.length&&((r=n.match.data)!=null&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),s}})}function IW(t){return new Bt({key:new on("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let u="";r.content.forEach(h=>{u+=h.textContent});const d=MI(u,{defaultProtocol:t.defaultProtocol}).find(h=>h.isLink&&h.value===u);return!u||!d||s!==void 0&&!s(d.value)?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}function Ci(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(EW,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var LW=ml.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"){xR(t);return}xR(t.scheme,t.optionalSlashes)})},onDestroy(){wW()},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)=>!!Ci(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){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=>!!Ci(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=>!!Ci(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",$t(this.options.HTMLAttributes,t),0]:["a",$t(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",l=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",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=>!!Ci(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=>!!Ci(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?[jW({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!Ci(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const t=e=>{const n=[];if(e){const{protocols:r,defaultProtocol:s}=this.options;MI(e).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!Ci(l,r),protocols:r,defaultProtocol:s})).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?[DW({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!Ci(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[na({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(_W({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Ci(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(AW({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(IW({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),PW=Object.defineProperty,zW=(t,e)=>{for(var n in e)PW(t,n,{get:e[n],enumerable:!0})},$W="listItem",wR="textStyle",SR=/^\s*([-+*])\s$/,LI=On.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",$t(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($W,this.editor.getAttributes(wR)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Hc({find:SR,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Hc({find:SR,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(wR),editor:this.editor})),[t]}}),BW=(t,e,n)=>{const{selection:r}=t;if(!r.empty)return null;const{$from:s}=r;if(!s.parent.isTextblock||s.parentOffset!==s.parent.content.size)return null;let i=-1;for(let b=s.depth;b>0;b-=1)if(s.node(b).type.name===e){i=b;break}if(i<0)return null;const o=s.node(i),l=s.index(i);if(l+1>=o.childCount)return null;const u=o.child(l+1);if(!n.includes(u.type.name))return null;const d=t.schema.nodes[e];let h=!1;if(u.forEach(b=>{b.type===d&&b.childCount>1&&(h=!0)}),!h)return null;const g=t.doc.resolve(s.after()).nodeAfter;if(!g||!n.includes(g.type.name))return null;const y=[];return g.forEach(b=>{y.push(b)}),y.length===0?null:{listItemDepth:i,nestedList:g,nestedListPos:s.after(),insertPos:s.after(i),items:y}},VW=(t,e,n,r)=>{const s=BW(t,n,r);if(!s)return!1;const{selection:i}=t,{nestedList:o,nestedListPos:l,insertPos:u,items:d}=s,h=t.tr;h.delete(l,l+o.nodeSize);const g=h.mapping.map(u);return h.insert(g,fe.from(d)),h.setSelection(i.map(h.doc,h.mapping)),e&&e(h),!0},HW=(t,e,n)=>VW(t.state,t.view.dispatch,e,n),PI=(t,e)=>Zt.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>HW(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),zI=[[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"]],Xh="abcdefghijklmnopqrstuvwxyz",UW="[a-zA-Z]{1,2}",$I=String.raw`\d+|[ivxlcdmIVXLCDM]+|${UW}`;function Ng(t){let e=t,n="";for(const[r,s]of zI)for(;e>=r;)n+=s,e-=r;return n}function $S(t){return Ng(t).toUpperCase()}function BI(t){const e=t.toLowerCase();let n=0,r=0;for(;n<e.length;){let s=!1;for(const[i,o]of zI)if(e.startsWith(o,n)){r+=i,n+=o.length,s=!0;break}if(!s)return 0}return r}function FW(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=BI(t);return e<=0?!1:(t===t.toLowerCase()?Ng(e):$S(e))===t}function qW(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 Gm(t){if(t<=26)return Xh[t-1];const e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Xh[n]:Xh[e]+Xh[n]}function Mg(t){if(!(!t||/^\d+$/.test(t))){if(FW(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 BS(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=Mg(t);if(e==="i"||e==="I")return BI(t);if(e==="a"||e==="A"){const r=qW(t);return r>0?r:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function GW(t,e){if(t==="numeric")return String(e);switch(t){case"a":return Gm(e);case"A":return Gm(e).toUpperCase();case"i":return Ng(e);case"I":return $S(e);default:return String(e)}}function WW(t){var e;if(t.length===0)return!1;const n=(e=Mg(t[0]))!=null?e:"numeric",r=BS(t[0]);if(r<1)return!1;for(let s=0;s<t.length;s++){const i=GW(n,r+s);if(t[s]!==i)return!1}return!0}function KW(t){return{type:Mg(t),start:BS(t)}}function ZW(t){const{type:e,start:n}=KW(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function YW(t,e,n=". "){const r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${Gm(r)}${n}`;case"A":return`${Gm(r).toUpperCase()}${n}`;case"i":return`${Ng(r)}${n}`;case"I":return`${$S(r)}${n}`;default:return`${r}${n}`}}function XW(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 JW(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var VI=On.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",$t(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 s=[];if(t.tokens&&t.tokens.length>0){if(XW(t))return{type:"listItem",content:[{type:"paragraph",content:JW(t.text||"",e)}]};if(t.tokens.some(o=>o.type==="paragraph"))s=r(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const u=t.tokens.slice(1),d=r(u);s.push(...d)}}else s=r(t.tokens)}}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(t,e,n)=>_S(t,e,r=>{var s,i,o,l;if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){const u=((i=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1,d=(l=(o=r.meta)==null?void 0:o.parentAttrs)==null?void 0:l.type,h=u-1+(r.index||0);return YW(d,h,". ")}return"- "},n),addExtensions(){return[PI(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)}}}),QW={};zW(QW,{findListItemPos:()=>Og,getNextListDepth:()=>VS,handleBackspace:()=>$x,handleDelete:()=>Bx,hasListBefore:()=>HI,hasListItemAfter:()=>e7,hasListItemBefore:()=>t7,listItemHasSubList:()=>n7,nextListIsDeeper:()=>UI,nextListIsHigher:()=>FI});var Og=(t,e)=>{const{$from:n}=e.selection,r=wn(t,e.schema);let s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},VS=(t,e)=>{const n=Og(t,e);if(!n)return!1;const[,r]=j9(e,t,n.$pos.pos+4);return r},HI=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},$x=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ta(t.state,e)&&HI(t.state,e,n)){const{$anchor:r}=t.state.selection,s=t.state.doc.resolve(r.before()-1),i=[];s.node().descendants((u,d)=>{u.type.name===e&&i.push({node:u,pos:d})});const o=i.at(-1);if(!o)return!1;const l=t.state.doc.resolve(s.start()+o.pos+1);return t.chain().cut({from:r.start()-1,to:r.end()+1},l.end()).joinForward().run()}return!ta(t.state,e)||!P9(t.state)?!1:t.chain().liftListItem(e).run()},UI=(t,e)=>{const n=VS(t,e),r=Og(t,e);return!r||!n?!1:n>r.depth},FI=(t,e)=>{const n=VS(t,e),r=Og(t,e);return!r||!n?!1:n<r.depth},Bx=(t,e)=>{if(!ta(t.state,e)||!L9(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:UI(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():FI(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},e7=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},t7=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},n7=(t,e,n)=>{if(!n)return!1;const r=wn(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},qI=Zt.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&&Bx(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&&Bx(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&&$x(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&&$x(t,n,r)&&(e=!0)}),e}}}}),Vx=new RegExp(`^(\\s*)(${$I})([.)])\\s+(.*)$`),r7=/^\s/,hd={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function s7(t){return Vx.test(t.trimStart())}function i7(t){const e=t.trimStart();return hd.bulletItem.test(e)||s7(e)||hd.heading.test(e)||hd.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||hd.codeFence.test(e)}function o7(t){return Object.values(hd).some(e=>e.test(t))}function a7(t){const e=[],n=[];let r=!1;return t.forEach(s=>{if(r){n.push(s);return}if(s.trim()===""){r=!0,n.push(s);return}if(e.length>0&&i7(s)){r=!0,n.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:n}}function l7(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Vx);if(!i)break;const[,o,l,u,d]=i,h=o.length,g=parseInt(l,10),y=isNaN(g)?Mg(l):void 0,b=isNaN(g)?BS(l):g,x=[d];let S=n+1;const k=[s];let C=!1;for(;S<t.length;){const A=t[S];if(A.match(Vx))break;if(A.trim()==="")k.push(A),x.push(""),C=!0,S+=1;else if(A.match(r7)){const _=A.length-A.trimStart().length,N=h+l.length+1;k.push(A),x.push(A.slice(Math.min(_,N))),S+=1}else{if(C||o7(A))break;k.push(A),x.push(A),S+=1}}e.push({indent:h,number:b,type:y,content:x.join(`
|
|
198
|
+
`).trim(),contentLines:x,raw:k.join(`
|
|
199
|
+
`)}),r=S,n=S}return[e,r]}var c7=new RegExp(`^(${$I})([.)])\\s+(.+)$`);function u7(t){const e=t.split(`
|
|
200
|
+
`).filter(i=>i.trim().length>0);if(e.length===0)return null;const n=[];for(const i of e){const o=i.trim().match(c7);if(!o)return null;n.push({marker:o[1],content:o[3]})}const r=n.map(i=>i.marker);return WW(r)?{type:"orderedList",attrs:ZW(n[0].marker),content:n.map(i=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:i.content}]}]}))}:null}function GI(t,e,n){const r=[];let s=0;for(;s<t.length;){const i=t[s];if(i.indent===e){const{paragraphLines:o,blockLines:l}=a7(i.contentLines),u=o.join(`
|
|
201
|
+
`).trim(),d=[];u&&d.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const h=l.join(`
|
|
202
|
+
`).trim();if(h){const b=n.blockTokens(h);d.push(...b)}let g=s+1;const y=[];for(;g<t.length&&t[g].indent>e;)y.push(t[g]),g+=1;if(y.length>0){const b=Math.min(...y.map(S=>S.indent)),x=GI(y,b,n);d.push({type:"list",ordered:!0,start:y[0].number,typeMarker:y[0].type,items:x,raw:y.map(S=>S.raw).join(`
|
|
203
|
+
`)})}r.push({type:"list_item",raw:i.raw,tokens:d}),s=g}else s+=1}return r}function d7(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var f7="listItem",kR="textStyle",CR=/^(\d+)\.\s$/;function ER(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 WI=On.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 s=ER(n);if(s)return s}const r=t.querySelector("li");if(r){const s=r.getAttribute("style");if(s){const i=ER(s);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,type:n,...r}=t,s=$t(this.options.HTMLAttributes,r);return e!==1&&(s.start=e),n&&n!=="1"&&(s.type=n),["ol",s,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.typeMarker,s=t.items?d7(t.items,e):[],i={};return n!==1&&(i.start=n),r&&(i.type=r),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:s}:{type:"orderedList",content:s}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
204
|
+
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,s;const i=t.split(`
|
|
205
|
+
`),[o,l]=l7(i);if(o.length===0)return;const u=GI(o,o[0].indent,n);if(u.length===0)return;const d=((r=o[0])==null?void 0:r.number)||1,h=(s=o[0])==null?void 0:s.type;return{type:"list",ordered:!0,start:d,typeMarker:h,items:u,raw:i.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(f7,this.editor.getAttributes(kR)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new Bt({props:{handlePaste:(t,e)=>{var n,r;const s=(n=e.clipboardData)==null?void 0:n.getData("text/html");if(s?.trim())return!1;const i=(r=e.clipboardData)==null?void 0:r.getData("text/plain");if(!i)return!1;const o=u7(i);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=Hc({find:CR,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Hc({find:CR,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(kR)}),joinPredicate:t,editor:this.editor})),[e]}}),h7=/^\s*(\[([( |x])?\])\s$/,p7=On.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",$t(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return _S(t,e,s)},addExtensions(){return this.options.nested?[PI(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 s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),u=document.createElement("div"),d=g=>{var y,b;l.ariaLabel=((b=(y=this.options.a11y)==null?void 0:y.checkboxLabel)==null?void 0:b.call(y,g,l.checked))||`Task item checkbox for ${g.textContent||"empty task item"}`};d(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",g=>g.preventDefault()),l.addEventListener("change",g=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:y}=g.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:y}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,y)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([g,y])=>{s.setAttribute(g,y)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,u),Object.entries(e).forEach(([g,y])=>{s.setAttribute(g,y)});let h=new Set(Object.keys(e));return{dom:s,contentDOM:u,update:g=>{if(g.type!==this.type)return!1;s.dataset.checked=g.attrs.checked,l.checked=g.attrs.checked,d(g);const y=r.extensionManager.attributes,b=Bc(g,y),x=new Set(Object.keys(b)),S=this.options.HTMLAttributes;return h.forEach(k=>{x.has(k)||(k in S?s.setAttribute(k,S[k]):s.removeAttribute(k))}),Object.entries(b).forEach(([k,C])=>{C==null?k in S?s.setAttribute(k,S[k]):s.removeAttribute(k):s.setAttribute(k,C)}),h=x,!0}}}},addInputRules(){return[Hc({find:h7,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),m7=On.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",$t(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=i=>{const o=Rx(i,{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=i.slice(o.raw.length);return u.trim()?[l,...n.blockTokens(u)]:[l]}return n.blockTokens(i)},s=Rx(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Zt.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(LI.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(VI.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(qI.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(WI.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(p7.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(m7.configure(this.options.taskList)),t}});var Jh=" ",s0=" ",g7=On.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",$t(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===Jh||n[0].text===Jh||n[0].raw===s0||n[0].text===s0)&&r.length===1&&r[0].type==="text"&&(r[0].text===Jh||r[0].text===s0)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,s;if(!t)return"";const i=Array.isArray(t.content)?t.content:[];if(i.length===0){const o=Array.isArray((r=n?.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((s=n?.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?Jh:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),y7=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,b7=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,v7=ml.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",$t(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[sl({find:y7,type:this.type})]},addPasteRules(){return[na({find:b7,type:this.type})]}}),x7=On.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),w7=ml.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",$t(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function S7(t={}){return new Bt({view(e){return new k7(e,t)}})}class k7{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(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){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,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let g=e.nodeBefore,y=e.nodeAfter;if(g||y){let b=this.editorView.nodeDOM(this.cursorPos-(g?g.nodeSize:0));if(b){let x=b.getBoundingClientRect(),S=g?x.bottom:x.top;g&&y&&(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 g=this.editorView.coordsAtPos(this.cursorPos),y=this.width/2*o;r={left:g.left-y,right:g.left+y,top:g.top,bottom:g.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 d,h;if(!u||u==document.body&&getComputedStyle(u).position=="static")d=-pageXOffset,h=-pageYOffset;else{let g=u.getBoundingClientRect(),y=g.width/u.offsetWidth,b=g.height/u.offsetHeight;d=g.left-u.scrollLeft*y,h=g.top-u.scrollTop*b}this.element.style.left=(r.left-d)/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),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(!n||i)return null;let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Aj(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 rn extends Ye{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return rn.valid(r)?new rn(r):Ye.near(r)}content(){return Re.empty}eq(e){return e instanceof rn&&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 rn(e.resolve(n.pos))}getBookmark(){return new HS(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!C7(e)||!E7(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&rn.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let u=e.doc.resolve(s);if(rn.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Fe.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(rn.valid(l))return l}return null}}}rn.prototype.visible=!1;rn.findFrom=rn.findGapCursorFrom;Ye.jsonID("gapcursor",rn);class HS{constructor(e){this.pos=e}map(e){return new HS(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return rn.valid(n)?new rn(n):Ye.near(n)}}function KI(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function C7(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||KI(s.type))return!0;if(s.inlineContent)return!1}}return!0}function E7(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||KI(s.type))return!0;if(s.inlineContent)return!1}}return!0}function T7(){return new Bt({props:{decorations:N7,createSelectionBetween(t,e,n){return e.pos==n.pos&&rn.valid(n)?new rn(n):null},handleClick:A7,handleKeyDown:_7,handleDOMEvents:{beforeinput:R7}}})}const _7=yS({ArrowLeft:Qh("horiz",-1),ArrowRight:Qh("horiz",1),ArrowUp:Qh("vert",-1),ArrowDown:Qh("vert",1)});function Qh(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,u=o.empty;if(o instanceof $e){if(!i.endOfTextblock(n)||l.depth==0)return!1;u=!1,l=r.doc.resolve(e>0?l.after():l.before())}let d=rn.findGapCursorFrom(l,e,u);return d?(s&&s(r.tr.setSelection(new rn(d))),!0):!1}}function A7(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!rn.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&Fe.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new rn(r))),!0)}function R7(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof rn))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=fe.empty;for(let o=r.length-1;o>=0;o--)s=fe.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new Re(s,0,0));return i.setSelection($e.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function N7(t){if(!(t.selection instanceof rn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",_t.create(t.doc,[An.widget(t.selection.head,e,{key:"gapcursor"})])}var Wm=200,Nn=function(){};Nn.prototype.append=function(e){return e.length?(e=Nn.from(e),!this.length&&e||e.length<Wm&&this.leafAppend(e)||this.length<Wm&&e.leafPrepend(this)||this.appendInner(e)):this};Nn.prototype.prepend=function(e){return e.length?Nn.from(e).append(this):this};Nn.prototype.appendInner=function(e){return new M7(this,e)};Nn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Nn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Nn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Nn.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)};Nn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};Nn.from=function(e){return e instanceof Nn?e:e&&e.length?new ZI(e):Nn.empty};var ZI=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var u=i;u<o;u++)if(s(this.values[u],l+u)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var u=i-1;u>=o;u--)if(s(this.values[u],l+u)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Wm)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Wm)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Nn);Nn.empty=new ZI([]);var M7=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Nn);const O7=500;class Es{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,u,d=[],h=[];return this.items.forEach((g,y)=>{if(!g.step){s||(s=this.remapping(r,y+1),i=s.maps.length),i--,h.push(g);return}if(s){h.push(new qs(g.map));let b=g.step.map(s.slice(i)),x;b&&o.maybeStep(b).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],d.push(new qs(x,void 0,void 0,d.length+h.length))),i--,x&&s.appendMap(x,i)}else o.maybeStep(g.step);if(g.selection)return l=s?g.selection.map(s.slice(i)):g.selection,u=new Es(this.items.slice(0,r).append(h.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,u=!s&&l.length?l.get(l.length-1):null;for(let h=0;h<e.steps.length;h++){let g=e.steps[h].invert(e.docs[h]),y=new qs(e.mapping.maps[h],g,n),b;(b=u&&u.merge(y))&&(y=b,h?i.pop():l=l.slice(0,l.length-1)),i.push(y),n&&(o++,n=void 0),s||(u=y)}let d=o-r.depth;return d>D7&&(l=j7(l,d),o-=d),new Es(l.append(i),o)}remapping(e,n){let r=new qd;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Es(this.items.append(e.map(n=>new qs(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(y=>{y.selection&&l--},s);let u=n;this.items.forEach(y=>{let b=i.getMirror(--u);if(b==null)return;o=Math.min(o,b);let x=i.maps[b];if(y.step){let S=e.steps[b].invert(e.docs[b]),k=y.selection&&y.selection.map(i.slice(u+1,b));k&&l++,r.push(new qs(x,S,k))}else r.push(new qs(x))},s);let d=[];for(let y=n;y<o;y++)d.push(new qs(i.maps[y]));let h=this.items.slice(0,s).append(d).append(r),g=new Es(h,l);return g.emptyItemCount()>O7&&(g=g.compress(this.items.length-r.length)),g}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let u=o.step.map(n.slice(r)),d=u&&u.getMap();if(r--,d&&n.appendMap(d,r),u){let h=o.selection&&o.selection.map(n.slice(r));h&&i++;let g=new qs(d.invert(),u,h),y,b=s.length-1;(y=s.length&&s[b].merge(g))?s[b]=y:s.push(g)}}else o.map&&r--},this.items.length,0),new Es(Nn.from(s.reverse()),i)}}Es.empty=new Es(Nn.empty,0);function j7(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class qs{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new qs(n.getMap().invert(),n,this.selection)}}}class No{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const D7=20;function I7(t,e,n,r){let s=n.getMeta(Za),i;if(s)return s.historyState;n.getMeta(z7)&&(t=new No(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Za))return o.getMeta(Za).redo?new No(t.done.addTransform(n,void 0,r,jp(e)),t.undone,TR(n.mapping.maps),t.prevTime,t.prevComposition):new No(t.done,t.undone.addTransform(n,void 0,r,jp(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||!L7(n,t.prevRanges)),d=o?i0(t.prevRanges,n.mapping):TR(n.mapping.maps);return new No(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,jp(e)),Es.empty,d,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new No(t.done.rebased(n,i),t.undone.rebased(n,i),i0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new No(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),i0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function L7(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function TR(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function i0(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function P7(t,e,n){let r=jp(e),s=Za.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),u=new No(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(Za,{redo:n,historyState:u})}let o0=!1,_R=null;function jp(t){let e=t.plugins;if(_R!=e){o0=!1,_R=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){o0=!0;break}}return o0}const Za=new on("history"),z7=new on("closeHistory");function $7(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Bt({key:Za,state:{init(){return new No(Es.empty,Es.empty,null,0,-1)},apply(e,n,r){return I7(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?XI:r=="historyRedo"?JI:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function YI(t,e){return(n,r)=>{let s=Za.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=P7(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const XI=YI(!1,!0),JI=YI(!0,!0);Zt.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 Bt({key:new on("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit,i=this.options.autoTrim;if(s==null||s===0||i===!1){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const l=o-s,u=0,d=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const h=r.tr.deleteRange(u,d);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 s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,u=i-r,d=l-u,h=l;return e.deleteRange(d,h),!(this.storage.characters({node:e.doc})>r)}})]}});var B7=Zt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[S7(this.options)]}});Zt.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Bt({key:new on("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return _t.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((u,d)=>{if(u.isText)return;if(!(s>=d&&s<=d+u.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((u,d)=>{if(u.isText||!(s>=d&&s<=d+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";i.push(An.node(d,d+u.nodeSize,{class:this.options.className}))}),_t.create(t,i)}}})]}});var V7=Zt.create({name:"gapCursor",addProseMirrorPlugins(){return[T7()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=bt(je(t,"allowGapCursor",n)))!=null?e:null}}}),QI="placeholder",AR=new on("tiptap__placeholder");function eL(t){const{editor:e,placeholder:n,dataAttribute:r,pos:s,node:i,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:u,emptyEditor:d}}=t,h=[u];return o&&h.push(d),An.node(s,s+i.nodeSize,{class:h.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:s,hasAnchor:l}):n})}function tL(t,e){return typeof t=="function"?t(e):t}function nL({editor:t,options:e,dataAttribute:n,doc:r,selection:s,from:i,to:o}){const{anchor:l}=s,u=[],d=t.isEmpty;return r.nodesBetween(i,o,(h,g)=>{const y=l>=g&&l<=g+h.nodeSize,b=!h.isLeaf&&vf(h);return h.type.isTextblock&&(y||!e.showOnlyCurrent)&&b&&u.push(eL({editor:t,isEmptyDoc:d,dataAttribute:n,hasAnchor:y,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:tL(e.emptyNodeClass,{editor:t,node:h,pos:g,hasAnchor:y})},node:h,pos:g})),e.includeChildren}),u}function rL({editor:t,options:e,dataAttribute:n,doc:r,selection:s}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:o}=s,l=[],u=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const h=r.resolve(o),g=h.depth>0?h.node(1):h.nodeAfter,y=h.depth>0?h.before(1):o;if(g&&g.type.isTextblock&&vf(g)){const b=o>=y&&o<=y+g.nodeSize;l.push(eL({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:b,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:tL(e.emptyNodeClass,{editor:t,node:g,pos:y,hasAnchor:b})},node:g,pos:y}))}}else l.push(...nL({editor:t,options:e,dataAttribute:n,doc:r,selection:s,from:0,to:r.content.size}));return _t.create(r,l)}function Rd(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 s=r.before(1),i=r.node(1);return{from:s,to:s+i.nodeSize}}function Nd(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function H7(t,e,n){const r=[];return t.forEach((s,i)=>{const o=i,l=o+s.nodeSize,u=o+1,d=l+1;u<n&&d>e&&r.push({from:o,to:l})}),r}function U7(t){if(t.length===0)return[];const e=[...t].sort((r,s)=>r.from-s.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){const s=n[n.length-1],i=e[r];i.from<=s.to?s.to=Math.max(s.to,i.to):n.push({...i})}return n}function F7(t,e){const n=H7(t,e.from,e.to);return n.push(Nd(t,Rd(t,e.from))),e.to>e.from?n.push(Nd(t,Rd(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(Nd(t,Rd(t,Math.min(e.from+1,t.content.size)))),n}function q7(t,e,n){const r=[];if(t.docChanged){const s=kS(t);for(const i of s)r.push(...F7(n.doc,i.newRange))}return t.selectionSet&&(r.push(Nd(n.doc,Rd(n.doc,t.mapping.map(e.selection.anchor)))),r.push(Nd(n.doc,Rd(n.doc,n.selection.anchor)))),U7(r)}function G7(t,e,n){const r=Math.max(0,Math.min(t,n.content.size)),s=Math.max(r,Math.min(e,n.content.size));return{from:r,to:s}}function W7({decorations:t,ranges:e,editor:n,options:r,dataAttribute:s,doc:i,selection:o}){let l=t;for(const u of e){const{from:d,to:h}=G7(u.from,u.to,i),g=l.find(d,h).filter(b=>b.from>=d&&b.to<=h);g.length&&(l=l.remove(g));const y=nL({editor:n,options:r,dataAttribute:s,doc:i,selection:o,from:d,to:h});y.length&&(l=l.add(i,y))}return l}function K7({editor:t,options:e,dataAttribute:n}){return{init(r,s){const i=rL({editor:t,options:e,dataAttribute:n,doc:s.doc,selection:s.selection});return i??_t.empty},apply(r,s,i,o){if(!r.docChanged&&!r.selectionSet)return s;const l=s.map(r.mapping,r.doc),u=q7(r,i,o);return W7({decorations:l,ranges:u,editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function Z7(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function Y7({editor:t,options:e}){const n=e.dataAttribute?`data-${Z7(e.dataAttribute)}`:`data-${QI}`,r=e.showOnlyCurrent&&!e.includeChildren;return new Bt({key:AR,...r?{}:{state:K7({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:s,selection:i})=>rL({editor:t,options:e,dataAttribute:n,doc:s,selection:i}):s=>{var i;return e.showOnlyWhenEditable&&!t.isEditable?_t.empty:(i=AR.getState(s))!=null?i:_t.empty}}})}var X7=Zt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:QI,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Y7({editor:this.editor,options:this.options})]}});function Hx(t,e){return!t.selection.empty&&!KD(t.selection)&&e.isEditable}function J7(t,e){return Hx(t,e)&&!e.isFocused&&!e.view.dragging}function Q7(){var t;(t=window.getSelection())==null||t.removeAllRanges()}function eK(t){t.focus()}Zt.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Bt({key:new on("selection"),props:{decorations(n){return J7(n,t)?_t.create(n.doc,[An.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return Hx(n.state,t)&&Q7(),!1},focus(n){return Hx(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&eK(n)}),!1}}}})]}});var tK="skipTrailingNode";function RR({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var nK=Zt.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new on(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new Bt({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:u,schema:d}=o,h=e.getState(o),g=l.content.size,y=d.nodes[n];if(!s.some(b=>b.getMeta(tK))&&h)return u.insert(g,y.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!RR({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!RR({node:o,types:r})}}})]}}),rK=Zt.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>XI(t,e),redo:()=>({state:t,dispatch:e})=>JI(t,e)}},addProseMirrorPlugins(){return[$7(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()}}}),sK=Zt.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(UG.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(zG.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(LI.configure(this.options.bulletList)),this.options.code!==!1&&s.push(GG.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(ZG.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(YG.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(B7.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(V7.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(XG.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(JG.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(rK.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(QG.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(sW.configure(this.options.italic)),this.options.listItem!==!1&&s.push(VI.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(qI.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(LW.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(WI.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(g7.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(v7.configure(this.options.strike)),this.options.text!==!1&&s.push(x7.configure(this.options.text)),this.options.underline!==!1&&s.push(w7.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(nK.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),iK=sK;function US(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var yl=US();function sL(t){yl=t}var Pa={exec:()=>null};function ft(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(s,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(lr.caret,"$1"),n=n.replace(s,o),r},getRegex:()=>new RegExp(n,e)};return r}var oK=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),lr={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)}}>`)},aK=/^(?:[ \t]*(?:\n|$))+/,lK=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,cK=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,wf=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,uK=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,FS=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,iL=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oL=ft(iL).replace(/bull/g,FS).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(),dK=ft(iL).replace(/bull/g,FS).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(),qS=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,fK=/^[^\n]+/,GS=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,hK=ft(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",GS).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),pK=ft(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,FS).getRegex(),jg="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",WS=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,mK=ft("^ {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",WS).replace("tag",jg).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),aL=ft(qS).replace("hr",wf).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",jg).getRegex(),gK=ft(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",aL).getRegex(),KS={blockquote:gK,code:lK,def:hK,fences:cK,heading:uK,hr:wf,html:mK,lheading:oL,list:pK,newline:aK,paragraph:aL,table:Pa,text:fK},NR=ft("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",wf).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",jg).getRegex(),yK={...KS,lheading:dK,table:NR,paragraph:ft(qS).replace("hr",wf).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",NR).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",jg).getRegex()},bK={...KS,html:ft(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",WS).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:Pa,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ft(qS).replace("hr",wf).replace("heading",` *#{1,6} *[^
|
|
208
|
+
]`).replace("lheading",oL).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},vK=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,xK=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,lL=/^( {2,}|\\)\n(?!\s*$)/,wK=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Jc=/[\p{P}\p{S}]/u,Dg=/[\s\p{P}\p{S}]/u,ZS=/[^\s\p{P}\p{S}]/u,SK=ft(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Dg).getRegex(),cL=/(?!~)[\p{P}\p{S}]/u,kK=/(?!~)[\s\p{P}\p{S}]/u,CK=/(?:[^\s\p{P}\p{S}]|~)/u,EK=ft(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",oK?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),uL=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,TK=ft(uL,"u").replace(/punct/g,Jc).getRegex(),_K=ft(uL,"u").replace(/punct/g,cL).getRegex(),dL="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",AK=ft(dL,"gu").replace(/notPunctSpace/g,ZS).replace(/punctSpace/g,Dg).replace(/punct/g,Jc).getRegex(),RK=ft(dL,"gu").replace(/notPunctSpace/g,CK).replace(/punctSpace/g,kK).replace(/punct/g,cL).getRegex(),NK=ft("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ZS).replace(/punctSpace/g,Dg).replace(/punct/g,Jc).getRegex(),MK=ft(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Jc).getRegex(),OK="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",jK=ft(OK,"gu").replace(/notPunctSpace/g,ZS).replace(/punctSpace/g,Dg).replace(/punct/g,Jc).getRegex(),DK=ft(/\\(punct)/,"gu").replace(/punct/g,Jc).getRegex(),IK=ft(/^<(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(),LK=ft(WS).replace("(?:-->|$)","-->").getRegex(),PK=ft("^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",LK).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Km=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,zK=ft(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Km).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),fL=ft(/^!?\[(label)\]\[(ref)\]/).replace("label",Km).replace("ref",GS).getRegex(),hL=ft(/^!?\[(ref)\](?:\[\])?/).replace("ref",GS).getRegex(),$K=ft("reflink|nolink(?!\\()","g").replace("reflink",fL).replace("nolink",hL).getRegex(),MR=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,YS={_backpedal:Pa,anyPunctuation:DK,autolink:IK,blockSkip:EK,br:lL,code:xK,del:Pa,delLDelim:Pa,delRDelim:Pa,emStrongLDelim:TK,emStrongRDelimAst:AK,emStrongRDelimUnd:NK,escape:vK,link:zK,nolink:hL,punctuation:SK,reflink:fL,reflinkSearch:$K,tag:PK,text:wK,url:Pa},BK={...YS,link:ft(/^!?\[(label)\]\((.*?)\)/).replace("label",Km).getRegex(),reflink:ft(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Km).getRegex()},Ux={...YS,emStrongRDelimAst:RK,emStrongLDelim:_K,delLDelim:MK,delRDelim:jK,url:ft(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",MR).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:ft(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",MR).getRegex()},VK={...Ux,br:ft(lL).replace("{2,}","*").getRegex(),text:ft(Ux.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ep={normal:KS,gfm:yK,pedantic:bK},td={normal:YS,gfm:Ux,breaks:VK,pedantic:BK},HK={"&":"&","<":"<",">":">",'"':""","'":"'"},OR=t=>HK[t];function Hs(t,e){if(e){if(lr.escapeTest.test(t))return t.replace(lr.escapeReplace,OR)}else if(lr.escapeTestNoEncode.test(t))return t.replace(lr.escapeReplaceNoEncode,OR);return t}function jR(t){try{t=encodeURI(t).replace(lr.percentDecode,"%")}catch{return null}return t}function DR(t,e){let n=t.replace(lr.findPipe,(i,o,l)=>{let u=!1,d=o;for(;--d>=0&&l[d]==="\\";)u=!u;return u?"|":" |"}),r=n.split(lr.splitPipe),s=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(;s<r.length;s++)r[s]=r[s].trim().replace(lr.slashPipe,"|");return r}function nd(t,e,n){let r=t.length;if(r===0)return"";let s=0;for(;s<r&&t.charAt(r-s-1)===e;)s++;return t.slice(0,r-s)}function UK(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 FK(t,e=0){let n=e,r="";for(let s of t)if(s===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=s,n++;return r}function IR(t,e,n,r,s){let i=e.href,o=e.title||null,l=t[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let u={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:o,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,u}function qK(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let s=r[1];return e.split(`
|
|
209
|
+
`).map(i=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[l]=o;return l.length>=s.length?i.slice(s.length):i}).join(`
|
|
210
|
+
`)}var Zm=class{options;rules;lexer;constructor(t){this.options=t||yl}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:nd(n,`
|
|
211
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=qK(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=nd(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:nd(e[0],`
|
|
212
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=nd(e[0],`
|
|
213
|
+
`).split(`
|
|
214
|
+
`),r="",s="",i=[];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 d=l.join(`
|
|
215
|
+
`),h=d.replace(this.rules.other.blockquoteSetextReplace,`
|
|
216
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
217
|
+
${d}`:d,s=s?`${s}
|
|
218
|
+
${h}`:h;let g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=g,n.length===0)break;let y=i.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){let b=y,x=b.raw+`
|
|
219
|
+
`+n.join(`
|
|
220
|
+
`),S=this.blockquote(x);i[i.length-1]=S,r=r.substring(0,r.length-b.raw.length)+S.raw,s=s.substring(0,s.length-b.text.length)+S.text;break}else if(y?.type==="list"){let b=y,x=b.raw+`
|
|
221
|
+
`+n.join(`
|
|
222
|
+
`),S=this.list(x);i[i.length-1]=S,r=r.substring(0,r.length-y.raw.length)+S.raw,s=s.substring(0,s.length-b.raw.length)+S.raw,n=x.substring(i.at(-1).raw.length).split(`
|
|
223
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:s}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,s={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 i=this.rules.other.listItemRegex(n),o=!1;for(;t;){let u=!1,d="",h="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;d=e[0],t=t.substring(d.length);let g=FK(e[2].split(`
|
|
224
|
+
`,1)[0],e[1].length),y=t.split(`
|
|
225
|
+
`,1)[0],b=!g.trim(),x=0;if(this.options.pedantic?(x=2,h=g.trimStart()):b?x=e[1].length+1:(x=g.search(this.rules.other.nonSpaceChar),x=x>4?1:x,h=g.slice(x),x+=e[1].length),b&&this.rules.other.blankLine.test(y)&&(d+=y+`
|
|
226
|
+
`,t=t.substring(y.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 N=t.split(`
|
|
227
|
+
`,1)[0],M;if(y=N,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),M=y):M=y.replace(this.rules.other.tabCharGlobal," "),C.test(y)||A.test(y)||R.test(y)||_.test(y)||S.test(y)||k.test(y))break;if(M.search(this.rules.other.nonSpaceChar)>=x||!y.trim())h+=`
|
|
228
|
+
`+M.slice(x);else{if(b||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||C.test(g)||A.test(g)||k.test(g))break;h+=`
|
|
229
|
+
`+y}b=!y.trim(),d+=N+`
|
|
230
|
+
`,t=t.substring(N.length+1),g=M.slice(x)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(o=!0)),s.items.push({type:"list_item",raw:d,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),s.raw+=d}let l=s.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;s.raw=s.raw.trimEnd();for(let u of s.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 d=this.rules.other.listTaskCheckbox.exec(u.raw);if(d){let h={type:"checkbox",raw:d[0]+" ",checked:d[0]!=="[ ]"};u.checked=h.checked,s.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(!s.loose){let d=u.tokens.filter(g=>g.type==="space"),h=d.length>0&&d.some(g=>this.rules.other.anyLine.test(g.raw));s.loose=h}}if(s.loose)for(let u of s.items){u.loose=!0;for(let d of u.tokens)d.type==="text"&&(d.type="paragraph")}return s}}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"):"",s=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:s}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=DR(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
231
|
+
`):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?i.align.push("right"):this.rules.other.tableAlignCenter.test(o)?i.align.push("center"):this.rules.other.tableAlignLeft.test(o)?i.align.push("left"):i.align.push(null);for(let o=0;o<n.length;o++)i.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:i.align[o]});for(let o of s)i.rows.push(DR(o,i.header.length).map((l,u)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:i.align[u]})));return i}}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 i=nd(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=UK(e[2],"()");if(i===-2)return;if(i>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],s="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],s=i[3])}else s=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)),IR(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:s&&s.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," "),s=e[r.toLowerCase()];if(!s){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return IR(n,s,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 s=[...r[0]].length-1,i,o,l=s,u=0,d=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,e=e.slice(-1*t.length+s);(r=d.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(o=[...i].length,r[3]||r[4]){l+=o;continue}else if((r[5]||r[6])&&s%3&&!((s+o)%3)){u+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+u);let h=[...r[0]][0].length,g=t.slice(0,s+r.index+h+o);if(Math.min(s,o)%2){let b=g.slice(1,-1);return{type:"em",raw:g,text:b,tokens:this.lexer.inlineTokens(b)}}let y=g.slice(2,-2);return{type:"strong",raw:g,text:y,tokens:this.lexer.inlineTokens(y)}}}}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),s=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&s&&(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 s=[...r[0]].length-1,i,o,l=s,u=this.rules.inline.delRDelim;for(u.lastIndex=0,e=e.slice(-1*t.length+s);(r=u.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(o=[...i].length,o!==s))continue;if(r[3]||r[4]){l+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l);let d=[...r[0]][0].length,h=t.slice(0,s+r.index+d+o),g=h.slice(s,-s);return{type:"del",raw:h,text:g,tokens:this.lexer.inlineTokens(g)}}}}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 s;do s=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(s!==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}}}},ws=class Fx{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||yl,this.options.tokenizer=this.options.tokenizer||new Zm,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:lr,block:ep.normal,inline:td.normal};this.options.pedantic?(n.block=ep.pedantic,n.inline=td.pedantic):this.options.gfm&&(n.block=ep.gfm,this.options.breaks?n.inline=td.breaks:n.inline=td.gfm),this.tokenizer.rules=n}static get rules(){return{block:ep,inline:td}}static lex(e,n){return new Fx(n).lex(e)}static lexInline(e,n){return new Fx(n).inlineTokens(e)}lex(e){e=e.replace(lr.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(lr.tabCharGlobal," ").replace(lr.spaceLine,""));e;){let s;if(this.options.extensions?.block?.some(o=>(s=o.call({lexer:this},e,n))?(e=e.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let o=n.at(-1);s.raw.length===1&&o!==void 0?o.raw+=`
|
|
234
|
+
`:n.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
235
|
+
`)?"":`
|
|
236
|
+
`)+s.raw,o.text+=`
|
|
237
|
+
`+s.text,this.inlineQueue.at(-1).src=o.text):n.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
238
|
+
`)?"":`
|
|
239
|
+
`)+s.raw,o.text+=`
|
|
240
|
+
`+s.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},n.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),n.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),n.push(s);continue}let i=e;if(this.options.extensions?.startBlock){let o=1/0,l=e.slice(1),u;this.options.extensions.startBlock.forEach(d=>{u=d.call({lexer:this},l),typeof u=="number"&&u>=0&&(o=Math.min(o,u))}),o<1/0&&o>=0&&(i=e.substring(0,o+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){let o=n.at(-1);r&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
|
|
241
|
+
`)?"":`
|
|
242
|
+
`)+s.raw,o.text+=`
|
|
243
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s),r=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
244
|
+
`)?"":`
|
|
245
|
+
`)+s.raw,o.text+=`
|
|
246
|
+
`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(s);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,s=null;if(this.tokens.links){let u=Object.keys(this.tokens.links);if(u.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)u.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,s.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(s=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)i=s[2]?s[2].length:0,r=r.slice(0,s.index+i)+"["+"a".repeat(s[0].length-i-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 d=e;if(this.options.extensions?.startInline){let h=1/0,g=e.slice(1),y;this.options.extensions.startInline.forEach(b=>{y=b.call({lexer:this},g),typeof y=="number"&&y>=0&&(h=Math.min(h,y))}),h<1/0&&h>=0&&(d=e.substring(0,h+1))}if(u=this.tokenizer.inlineText(d)){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}},Ym=class{options;parser;constructor(t){this.options=t||yl}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(lr.notSpaceStart)?.[0],s=t.replace(lr.endingNewline,"")+`
|
|
247
|
+
`;return r?'<pre><code class="language-'+Hs(r)+'">'+(n?s:Hs(s,!0))+`</code></pre>
|
|
248
|
+
`:"<pre><code>"+(n?s:Hs(s,!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 s=e?"ol":"ul",i=e&&n!==1?' start="'+n+'"':"";return"<"+s+i+`>
|
|
254
|
+
`+r+"</"+s+`>
|
|
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 s=0;s<t.header.length;s++)n+=this.tablecell(t.header[s]);e+=this.tablerow({text:n});let r="";for(let s=0;s<t.rows.length;s++){let i=t.rows[s];n="";for(let o=0;o<i.length;o++)n+=this.tablecell(i[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>${Hs(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),s=jR(t);if(s===null)return r;t=s;let i='<a href="'+t+'"';return e&&(i+=' title="'+Hs(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=jR(t);if(s===null)return Hs(n);t=s;let i=`<img src="${t}" alt="${Hs(n)}"`;return e&&(i+=` title="${Hs(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Hs(t.text)}},XS=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}},Ss=class qx{options;renderer;textRenderer;constructor(e){this.options=e||yl,this.options.renderer=this.options.renderer||new Ym,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new XS}static parse(e,n){return new qx(n).parse(e)}static parseInline(e,n){return new qx(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let o=s,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 i=s;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let o='Token with "'+i.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 s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=l||"";continue}}let o=i;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}},pd=class{options;block;constructor(t){this.options=t||yl}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?ws.lex:ws.lexInline}provideParser(t=this.block){return t?Ss.parse:Ss.parseInline}},GK=class{defaults=US();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ss;Renderer=Ym;TextRenderer=XS;Lexer=ws;Tokenizer=Zm;Hooks=pd;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 s=r;for(let i of s.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of s.rows)for(let o of i)n=n.concat(this.walkTokens(o.tokens,e));break}case"list":{let s=r;n=n.concat(this.walkTokens(s.items,e));break}default:{let s=r;this.defaults.extensions?.childTokens?.[s.type]?this.defaults.extensions.childTokens[s.type].forEach(i=>{let o=s[i].flat(1/0);n=n.concat(this.walkTokens(o,e))}):s.tokens&&(n=n.concat(this.walkTokens(s.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(s=>{if(!s.name)throw new Error("extension name required");if("renderer"in s){let i=e.renderers[s.name];i?e.renderers[s.name]=function(...o){let l=s.renderer.apply(this,o);return l===!1&&(l=i.apply(this,o)),l}:e.renderers[s.name]=s.renderer}if("tokenizer"in s){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[s.level];i?i.unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}"childTokens"in s&&s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),r.extensions=e),n.renderer){let s=this.defaults.renderer||new Ym(this.defaults);for(let i in n.renderer){if(!(i in s))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let o=i,l=n.renderer[o],u=s[o];s[o]=(...d)=>{let h=l.apply(s,d);return h===!1&&(h=u.apply(s,d)),h||""}}r.renderer=s}if(n.tokenizer){let s=this.defaults.tokenizer||new Zm(this.defaults);for(let i in n.tokenizer){if(!(i in s))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let o=i,l=n.tokenizer[o],u=s[o];s[o]=(...d)=>{let h=l.apply(s,d);return h===!1&&(h=u.apply(s,d)),h}}r.tokenizer=s}if(n.hooks){let s=this.defaults.hooks||new pd;for(let i in n.hooks){if(!(i in s))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let o=i,l=n.hooks[o],u=s[o];pd.passThroughHooks.has(i)?s[o]=d=>{if(this.defaults.async&&pd.passThroughHooksRespectAsync.has(i))return(async()=>{let g=await l.call(s,d);return u.call(s,g)})();let h=l.call(s,d);return u.call(s,h)}:s[o]=(...d)=>{if(this.defaults.async)return(async()=>{let g=await l.apply(s,d);return g===!1&&(g=await u.apply(s,d)),g})();let h=l.apply(s,d);return h===!1&&(h=u.apply(s,d)),h}}r.hooks=s}if(n.walkTokens){let s=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(o){let l=[];return l.push(i.call(this,o)),s&&(l=l.concat(s.call(this,o))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return ws.lex(t,e??this.defaults)}parser(t,e){return Ss.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},s={...this.defaults,...r},i=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&r.async===!1)return i(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 i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=t),s.async)return(async()=>{let o=s.hooks?await s.hooks.preprocess(e):e,l=await(s.hooks?await s.hooks.provideLexer(t):t?ws.lex:ws.lexInline)(o,s),u=s.hooks?await s.hooks.processAllTokens(l):l;s.walkTokens&&await Promise.all(this.walkTokens(u,s.walkTokens));let d=await(s.hooks?await s.hooks.provideParser(t):t?Ss.parse:Ss.parseInline)(u,s);return s.hooks?await s.hooks.postprocess(d):d})().catch(i);try{s.hooks&&(e=s.hooks.preprocess(e));let o=(s.hooks?s.hooks.provideLexer(t):t?ws.lex:ws.lexInline)(e,s);s.hooks&&(o=s.hooks.processAllTokens(o)),s.walkTokens&&this.walkTokens(o,s.walkTokens);let l=(s.hooks?s.hooks.provideParser(t):t?Ss.parse:Ss.parseInline)(o,s);return s.hooks&&(l=s.hooks.postprocess(l)),l}catch(o){return i(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>"+Hs(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},il=new GK;function At(t,e){return il.parse(t,e)}At.options=At.setOptions=function(t){return il.setOptions(t),At.defaults=il.defaults,sL(At.defaults),At};At.getDefaults=US;At.defaults=yl;At.use=function(...t){return il.use(...t),At.defaults=il.defaults,sL(At.defaults),At};At.walkTokens=function(t,e){return il.walkTokens(t,e)};At.parseInline=il.parseInline;At.Parser=Ss;At.parser=Ss.parse;At.Renderer=Ym;At.TextRenderer=XS;At.Lexer=ws;At.lexer=ws.lex;At.Tokenizer=Zm;At.Hooks=pd;At.parse=At;At.options;At.setOptions;At.use;At.walkTokens;At.parseInline;Ss.parse;ws.lex;var WK=/\n[^\S\n]*(?:\n[^\S\n]*)+$/;function KK(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 s=(e.raw||"").match(WK);return s?[{...e,raw:(e.raw||"").slice(0,-s[0].length)},{type:"space",raw:s[0]}]:[e]})}function ZK(t,e){const r=e.split(`
|
|
266
|
+
`).flatMap(s=>[s,""]).map(s=>`${t}${s}`).join(`
|
|
267
|
+
`);return r.slice(0,r.length-1)}function YK(t,e){const n=[];return Array.from(t.entries()).forEach(([r,s])=>{if(!e){n.push(r);return}(e.marks||[]).find(o=>o.type===r&&Vc(o.attrs,s.attrs))||n.push(r)}),n}function XK(t,e){const n=[];return Array.from(e.entries()).forEach(([r,s])=>{const i=t.get(r);(!i||!Vc(i.attrs,s.attrs))&&n.push({type:r,mark:s})}),n}function JK(t,e,n,r){const s=!n,i=n&&(!n.marks||n.marks.length===0),o=n&&n.marks&&!r(e,new Map(n.marks.map(u=>[u.type,u]))),l=[];return(s||i||o)&&(n&&n.marks?Array.from(t.entries()).reverse().forEach(([u,d])=>{n.marks.find(g=>g.type===u&&Vc(g.attrs,d.attrs))||l.push(u)}):(s||i)&&l.push(...Array.from(t.keys()).reverse())),l}function QK(t,e){let n="";return Array.from(t.keys()).reverse().forEach(r=>{const s=t.get(r),i=e(r,s);i&&(n=i+n)}),t.clear(),n}function eZ(t,e,n){let r="";return Array.from(t.entries()).forEach(([s,i])=>{const o=n(s,i);o&&(r+=o),e.set(s,i)}),r}function a0(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 tp(t,e){return typeof t!="string"?"json":e}var tZ=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"]),nZ=/<\/?([a-zA-Z][\w-]*)/g;function rZ(t){const e=[];let n;for(;(n=nZ.exec(t))!==null;)e.push(n[1].toLowerCase());return e}function sZ(t){const e=t.toLowerCase();return e.includes("-")?!1:!tZ.has(e)}function iZ(t,e){return rZ(t).some(r=>sZ(r)?!e.has(r):!1)}var oZ=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,s,i;this.markedInstance=(e=t?.marked)!=null?e:At,this.indentStyle=(r=(n=t?.indentation)==null?void 0:n.style)!=null?r:"space",this.indentSize=(i=(s=t?.indentation)==null?void 0:s.size)!=null?i: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,kc(_g(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=bt(je(t,"code")),s=t.name;r&&this.codeTypes.add(s),this.extensionRanks.has(s)||this.extensionRanks.set(s,this.extensionRanks.size);const i=je(t,"markdownTokenName")||s,o=je(t,"parseMarkdown"),l=je(t,"renderMarkdown"),u=je(t,"markdownTokenizer"),d=(e=je(t,"markdownOptions"))!=null?e:null,h=(n=d?.indentsContent)!=null?n:!1,g=d?.htmlReopen,y={tokenName:i,nodeName:s,parseMarkdown:o,renderMarkdown:l,isIndenting:h,htmlReopen:g,tokenizer:u};if(i&&o){const b=this.registry.get(i)||[];b.push(y),this.registry.set(i,b)}if(l){const b=this.nodeTypeRegistry.get(s)||[];b.push(y),this.nodeTypeRegistry.set(s,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:s}=t,i=this.createTokenizerHelpers.bind(this),o=this.createLexer.bind(this);let l;n?l=typeof n=="function"?n:d=>d.indexOf(n):l=d=>{const h=s(d,[],this.createTokenizerHelpers(this.createLexer()));return h&&h.raw?d.indexOf(h.raw):-1};const u={name:e,level:r,start:l,tokenizer(d,h){const g=this.lexer?i(this.lexer):i(o()),y=s(d,h,g);if(y&&y.type)return{...y,type:y.type||e,raw:y.raw||"",tokens:y.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?KK(t):t,r=n.reduce((o,l,u)=>(l.type!=="space"&&o.push(u),o),[]);let s=-1,i=0;return n.flatMap((o,l)=>{for(var u;i<r.length&&r[i]<l;)s=r[i],i+=1;if(e&&o.type==="space"){const h=(u=r[i])!=null?u:-1;return this.createImplicitEmptyParagraphsFromSpace(o,s,h)}const d=this.parseToken(o,e);return d===null?[]:Array.isArray(d)?d:[d]})}createImplicitEmptyParagraphsFromSpace(t,e,n){const r=this.countParagraphSeparators(t.raw||"");if(r===0)return[];const i=Math.max(r-(e===-1||n===-1?0:1),0);return Array.from({length:i},()=>({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(i=>{if(!i.parseMarkdown)return!1;const o=i.parseMarkdown(t,r),l=this.normalizeParseResult(o);return l&&(!Array.isArray(l)||l.length>0)?(this.lastParseResult=l,!0):!1})&&this.lastParseResult){const i=this.lastParseResult;return this.lastParseResult=null,i}return this.parseFallbackToken(t,e)}parseListToken(t){if(!t.items||t.items.length===0)return this.parseTokenWithHandlers(t);const e=t.items.some(l=>a0(l).isTask),n=t.items.some(l=>!a0(l).isTask);if(!e||!n||this.getHandlersForToken("taskList").length===0)return this.parseTokenWithHandlers(t);const r=[];let s=[],i=null;for(let l=0;l<t.items.length;l+=1){const u=t.items[l],{isTask:d,checked:h,indentLevel:g}=a0(u);let y=u;if(d){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),N=_.filter(M=>M.trim());if(N.length>0){const M=Math.min(...N.map(D=>D.length-D.trimStart().length)),P=_.map(D=>D.trim()?D.slice(M):"").join(`
|
|
271
|
+
`).trim();P&&(A=this.markedInstance.lexer(`${P}
|
|
272
|
+
`))}}y={type:"taskItem",raw:"",mainContent:C,indentLevel:g,checked:h??!1,text:C,tokens:this.tokenizeInline(C),nestedTokens:A}}const b=d?"taskList":"list";i!==b?(s.length>0&&r.push({type:i,items:s}),s=[y],i=b):s.push(y)}s.length>0&&r.push({type:i,items:s});const o=[];for(let l=0;l<r.length;l+=1){const u=r[l],d={...t,type:u.type,items:u.items},h=this.parseToken(d);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(s=>{if(!s.parseMarkdown)return!1;const i=s.parseMarkdown(t,n),o=this.normalizeParseResult(i);return o&&(!Array.isArray(o)||o.length>0)?(this.lastParseResult=o,!0):!1})&&this.lastParseResult){const s=this.lastParseResult;return this.lastParseResult=null,s}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,s;const i=[];for(let o=0;o<t.length;o+=1){const l=t[o];if(l.type==="text")i.push({type:"text",text:oR(l.text||"")});else if(l.type==="escape")i.push({type:"text",text:l.text||""});else if(l.type==="html"){const u=((n=(e=l.raw)!=null?e:l.text)!=null?n:"").toString(),d=/^<\/[\s]*[\w-]+/i.test(u),h=u.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!d&&h&&!/\/>$/.test(u)){const y=h[1],b=this.escapeRegex(y),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=((s=(r=A.raw)!=null?r:A.text)!=null?s:"").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(_)?i.push(..._):_&&i.push(_)}o=S;continue}}const g=this.parseHTMLToken(l);if(g){const y=this.normalizeParseResult(g);Array.isArray(y)?i.push(...y):y&&i.push(y)}}else if(l.type){const u=this.getHandlerForToken(l.type);if(u&&u.parseMarkdown){const d=this.createParseHelpers(),h=u.parseMarkdown(l,d);if(this.isMarkResult(h)){const g=this.applyMarkToContent(h.mark,h.content,h.attrs);i.push(...g)}else{const g=this.normalizeParseResult(h);Array.isArray(g)?i.push(...g):g&&i.push(g)}}else l.tokens&&i.push(...this.parseInlineTokens(l.tokens))}}for(let o=i.length-1;o>0;o-=1){const l=i[o],u=i[o-1];if(l.type==="text"&&u.type==="text"){const d=l.marks||[],h=u.marks||[];x8(d,h)&&(u.text=(u.text||"")+(l.text||""),i.splice(o,1))}}return i}applyMarkToContent(t,e,n){return e.map(r=>{if(r.type==="text"){const s=r.marks||[],i=n?{type:t,attrs:n}:{type:t};return{...r,marks:[...s,i]}}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:oR(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=A9(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 iZ(t,this.getSchemaParseDomTags())}getSchemaParseDomTags(){if(this.schemaParseDomTagsCache)return this.schemaParseDomTagsCache;const t=new Set;try{const e=FD(this.baseExtensions),n=r=>{const s=r?.parseDOM;Array.isArray(s)&&s.forEach(i=>{if(typeof i?.tag=="string"){const o=i.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(s=>this.codeTypes.has(typeof s=="string"?s:s.type))?t:this.escapeMarkdownSyntax(d8(t))}escapeMarkdownSyntax(t){return t.replace(/([\\`*_[\]~])/g,"\\$1")}renderNodeToMarkdown(t,e,n=0,r=0,s={}){var i;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:(g,y)=>{const b=o.isIndenting?r+1:r;return!Array.isArray(g)&&g.content?this.renderNodes(g.content,t,y||"",n,b):this.renderNodes(g,t,y||"",n,b)},renderChild:(g,y)=>{const b=o.isIndenting?r+1:r;return this.renderNodeToMarkdown(g,t,y,b)},indent:g=>this.indentString+g,wrapInBlock:ZK},d={index:n,level:r,parentType:e?.type,previousNode:l,meta:{parentAttrs:e?.attrs,...s}};return((i=o.renderMarkdown)==null?void 0:i.call(o,t,u,d))||""}renderNodes(t,e,n="",r=0,s=0){return Array.isArray(t)?this.renderNodesWithMarkBoundaries(t,e,n,s):t.type?this.renderNodeToMarkdown(t,e,r,s):""}renderNodesWithMarkBoundaries(t,e,n="",r=0){const s=[],i=new Map,o=new Set,l=new Map;return t.forEach((u,d)=>{const h=d<t.length-1?t[d+1]:null;if(u.type)if(u.type==="text"){let g=this.encodeTextForMarkdown(u.text||"",u,e);const y=new Map((u.marks||[]).map(N=>[N.type,N])),b=this.getMarksToOpenForSerialization(i,y,h),x=YK(y,h),S=x.filter(N=>i.has(N)),k=S.length>0&&b.length>0;let C="";if(x.length>0&&!k){const N=g.match(/(\s+)$/);N&&(C=N[1],g=g.slice(0,-C.length))}k||x.slice().reverse().forEach(N=>{if(!i.has(N))return;const M=y.get(N),O=this.getMarkClosing(N,M,l.get(N));O&&(g+=O),i.has(N)&&(i.delete(N),l.delete(N))});let A="";if(b.length>0){const N=g.match(/^(\s+)/);N&&(A=N[1],g=g.slice(A.length))}b.forEach(({type:N,mark:M})=>{const O=o.has(N)?"html":"markdown",P=this.getMarkOpening(N,M,O);P&&(g=P+g),l.set(N,O),o.delete(N)}),k||b.slice().reverse().forEach(({type:N,mark:M})=>{i.set(N,M)}),g=A+g;let R;if(k){const N=new Set((h?.marks||[]).map(P=>P.type));b.forEach(({type:P})=>{N.has(P)&&this.getHtmlReopenTags(P)&&o.add(P)});const M=Array.from(i.keys()),O=S.slice().sort((P,D)=>M.indexOf(D)-M.indexOf(P));R=[...b.map(P=>P.type),...O]}else R=JK(i,y,h,this.markSetsEqual.bind(this));let _="";if(R.length>0){const N=g.match(/(\s+)$/);N&&(_=N[1],g=g.slice(0,-_.length))}R.forEach(N=>{var M;const O=(M=i.get(N))!=null?M:y.get(N),P=this.getMarkClosing(N,O,l.get(N));P&&(g+=P),i.delete(N),l.delete(N)}),g+=_,g+=C,s.push(g)}else{const g=new Set((u.marks||[]).map(C=>C.type)),y=new Map,b=new Map;i.forEach((C,A)=>{var R;g.has(A)&&(y.set(A,C),b.set(A,(R=l.get(A))!=null?R:"markdown"))});const x=QK(i,(C,A)=>this.getMarkClosing(C,A,l.get(C)));l.clear();const S=this.renderNodeToMarkdown(u,e,d,r),k=u.type==="hardBreak"?"":eZ(y,i,(C,A)=>{var R;const _=(R=b.get(C))!=null?R:"markdown";return l.set(C,_),this.getMarkOpening(C,A,_)});s.push(x+S+k)}}),s.join(n)}getMarkOpening(t,e,n="markdown"){var r;if(n==="html")return((r=this.getHtmlReopenTags(t))==null?void 0:r.open)||"";const s=this.getHandlersForNodeType(t),i=s.length>0?s[0]:void 0;if(!i||!i.renderMarkdown)return"";const o="__TIPTAP_MARKDOWN_PLACEHOLDER__",l={type:t,attrs:e.attrs||{},content:[{type:"text",text:o}]};try{const u=i.renderMarkdown(l,{renderChildren:()=>o,renderChild:()=>o,indent:h=>h,wrapInBlock:(h,g)=>h+g},{index:0,level:0,parentType:"text",meta:{}}),d=u.indexOf(o);return d>=0?u.substring(0,d):""}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 s=this.getHandlersForNodeType(t),i=s.length>0?s[0]:void 0;if(!i||!i.renderMarkdown)return"";const o="__TIPTAP_MARKDOWN_PLACEHOLDER__",l={type:t,attrs:e.attrs||{},content:[{type:"text",text:o}]};try{const u=i.renderMarkdown(l,{renderChildren:()=>o,renderChild:()=>o,indent:g=>g,wrapInBlock:(g,y)=>g+y},{index:0,level:0,parentType:"text",meta:{}}),d=u.indexOf(o),h=d+o.length;return d>=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 s=e.get(n);return s&&Vc(r.attrs,s.attrs)})}getMarksToOpenForSerialization(t,e,n){const r=XK(t,e);if(r.length<=1)return r;const s=n?.marks||[],i=(d,h)=>s.some(g=>g.type===d&&Vc(g.attrs,h)),o=(d,h)=>{var g,y;const b=(g=this.extensionRanks.get(d.type))!=null?g:Number.MAX_SAFE_INTEGER,x=(y=this.extensionRanks.get(h.type))!=null?y:Number.MAX_SAFE_INTEGER;return b!==x?x-b:d.type.localeCompare(h.type)},l=r.filter(d=>!i(d.type,d.mark.attrs)).sort(o),u=r.filter(d=>i(d.type,d.mark.attrs)).sort(o);return[...l,...u]}},LR=oZ,aZ=Zt.create({name:"markdown",addOptions(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(t,e)=>{if(!e?.contentType||tp(t,e?.contentType)!=="markdown"||!this.editor.markdown)return vs.setContent(t,e);const r=this.editor.markdown.parse(t);return vs.setContent(r,e)},insertContent:(t,e)=>{if(!e?.contentType||tp(t,e?.contentType)!=="markdown"||!this.editor.markdown)return vs.insertContent(t,e);const r=this.editor.markdown.parse(t);return vs.insertContent(r,e)},insertContentAt:(t,e,n)=>{if(!n?.contentType||tp(e,n?.contentType)!=="markdown"||!this.editor.markdown)return vs.insertContentAt(t,e,n);const s=this.editor.markdown.parse(e);return vs.insertContentAt(t,s,n)}}},addStorage(){return{manager:new LR({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 LR({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||tp(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)}}),lZ=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,cZ=On.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",$t(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",d=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return d?``:``},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,s=new Set(["src","width","height"]);return({node:i,getPos:o,HTMLAttributes:l,editor:u})=>{const d=document.createElement("img");d.draggable=!1;const h=$t(this.options.HTMLAttributes,l);Object.entries(h).forEach(([k,C])=>{if(C!=null)switch(k){case"src":case"width":case"height":break;default:d.setAttribute(k,C);break}}),h.src!==null&&(d.src=h.src);let g={...l};const y=k=>{if(typeof k=="string"&&k!==""){d.getAttribute("src")!==k&&(d.src=k);return}d.hasAttribute("src")&&d.removeAttribute("src"),d.src!==""&&(d.src="")};y(l.src);const b=k=>{if(k.type!==i.type)return!1;const C=u.extensionManager.attributes.filter(R=>R.type===k.type.name),A=Bc(k,C);return Object.keys(g).forEach(R=>{!s.has(R)&&!(R in A)&&d.removeAttribute(R)}),Object.entries(A).forEach(([R,_])=>{s.has(R)||(_!=null?d.setAttribute(R,_):d.removeAttribute(R))}),y(A.src),g=A,!0},x=new j8({element:d,editor:u,node:i,getPos:o,onResize:(k,C)=>{d.style.width=`${k}px`,d.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",d.onload=()=>{S.style.visibility="",S.style.pointerEvents=""},x}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[hI({find:lZ,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),uZ=cZ;let Gx,Wx;if(typeof WeakMap<"u"){let t=new WeakMap;Gx=e=>t.get(e),Wx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Gx=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},Wx=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var sn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,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:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:u,bottom:d}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,u),right:Math.max(r,l),bottom:Math.max(i,d)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+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]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return Gx(t)||Wx(t,dZ(t))}};function dZ(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=fZ(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let d=0,h=e*n;d<h;d++)r[d]=0;for(let d=0,h=0;d<n;d++){const g=t.child(d);h++;for(let x=0;;x++){for(;s<r.length&&r[s]!=0;)s++;if(x==g.childCount)break;const S=g.child(x),{colspan:k,rowspan:C,colwidth:A}=S.attrs;for(let R=0;R<C;R++){if(R+d>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:h,n:C-R});break}const _=s+R*e;for(let N=0;N<k;N++){r[_+N]==0?r[_+N]=h:(i||(i=[])).push({type:"collision",row:d,pos:h,n:k-N});const M=A&&A[N];if(M){const O=(_+N)%e*2,P=o[O];P==null||P!=M&&o[O+1]==1?(o[O]=M,o[O+1]=1):P==M&&o[O+1]++}}}s+=k,h+=S.nodeSize}const y=(d+1)*e;let b=0;for(;s<y;)r[s++]==0&&b++;b&&(i||(i=[])).push({type:"missing",row:d,n:b}),h++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new sn(e,n,r,i);let u=!1;for(let d=0;!u&&d<o.length;d+=2)o[d]!=null&&o[d+1]<n&&(u=!0);return u&&hZ(l,o,t),l}function fZ(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let u=0;u<l.childCount;u++){const d=l.child(u);o+d.attrs.rowspan>r&&(i+=d.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function hZ(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const u=o.attrs;for(let d=0;d<u.colspan;d++){const h=e[(s+d)%t.width*2];h!=null&&(!u.colwidth||u.colwidth[d]!=h)&&((l||(l=pZ(u)))[d]=h)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function pZ(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function tr(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const Lo=new on("selectingCells");function ol(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 mZ(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 Os(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 Ig(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=ol(e.$head)||gZ(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function gZ(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 Kx(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function yZ(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 pL(t,e,n){const r=t.node(-1),s=sn.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function al(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function mL(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function bZ(t,e,n){const r=tr(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var zt=class Ti extends Ye{constructor(e,n=e){const r=e.node(-1),s=sn.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),u=s.cellsInRect(o).filter(h=>h!=n.pos-i);u.unshift(n.pos-i);const d=u.map(h=>{const g=r.nodeAt(h);if(!g)throw new RangeError(`No cell with offset ${h} found`);const y=i+h+1;return new jj(l.resolve(y),l.resolve(y+g.content.size))});super(d[0].$from,d[0].$to,d),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Kx(r)&&Kx(s)&&JS(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ti.rowSelection(r,s):i&&this.isColSelection()?Ti.colSelection(r,s):new Ti(r,s)}return $e.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=sn.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let u=s.top;u<s.bottom;u++){const d=[];for(let h=u*n.width+s.left,g=s.left;g<s.right;g++,h++){const y=n.map[h];if(i[y])continue;i[y]=!0;const b=n.findCell(y);let x=e.nodeAt(y);if(!x)throw new RangeError(`No cell with offset ${y} found`);const S=s.left-b.left,k=b.right-s.right;if(S>0||k>0){let C=x.attrs;if(S>0&&(C=al(C,0,S)),k>0&&(C=al(C,C.colspan-k,k)),b.left<s.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<s.top||b.bottom>s.bottom){const C={...x.attrs,rowspan:Math.min(b.bottom,s.bottom)-Math.max(b.top,s.top)};b.top<s.top?x=x.type.createAndFill(C):x=x.type.create(C,x.content)}d.push(x)}o.push(e.child(u).copy(fe.from(d)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Re(fe.from(l),1,1)}replace(e,n=Re.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:u}=s[o],d=e.mapping.slice(r);e.replace(d.map(l.pos),d.map(u.pos),o?Re.empty:n)}const i=Ye.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Re(fe.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=sn.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[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,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=sn.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),u=e.node(0);return o.top<=l.top?(o.top>0&&(e=u.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=u.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=u.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=u.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Ti(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=sn.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof Ti&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=sn.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),u=e.node(0);return o.left<=l.left?(o.left>0&&(e=u.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=u.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=u.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=u.resolve(i+s.map[s.width*(o.top+1)-1]))),new Ti(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Ti(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Ti(e.resolve(n),e.resolve(r))}getBookmark(){return new vZ(this.$anchorCell.pos,this.$headCell.pos)}};zt.prototype.visible=!1;Ye.jsonID("cell",zt);var vZ=class gL{constructor(e,n){this.anchor=e,this.head=n}map(e){return new gL(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 zt(n,r):Ye.near(r,1)}};function xZ(t){if(!(t.selection instanceof zt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(An.node(r,r+n.nodeSize,{class:"selectedCell"}))}),_t.create(t.doc,e)}function wZ({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function SZ({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function kZ(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof Fe&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=zt.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=zt.rowSelection(l,l)}else if(!n){const l=sn.get(r.node),u=r.from+1,d=u+l.map[l.width*l.height-1];i=zt.create(s,u+1,d)}}else r instanceof $e&&wZ(r)?i=$e.create(s,r.from):r instanceof $e&&SZ(r)&&(i=$e.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const CZ=new on("fix-tables");function yL(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const u=e.child(o);for(let d=l,h=Math.min(s,o+3);d<h;d++)if(t.child(d)==u){l=d+1,n+=u.nodeSize;continue e}r(u,n),l<s&&t.child(l).sameMarkup(u)?yL(t.child(l),u,n+1,r):u.nodesBetween(0,u.content.size,r,n+1),n+=u.nodeSize}}function bL(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=EZ(t,s,i,n))};return e?e.doc!=t.doc&&yL(e.doc,t.doc,0,r):t.doc.descendants(r),n}function EZ(t,e,n,r){const s=sn.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let u=0;u<s.height;u++)i.push(0);for(let u=0;u<s.problems.length;u++){const d=s.problems[u];if(d.type=="collision"){const h=e.nodeAt(d.pos);if(!h)continue;const g=h.attrs;for(let y=0;y<g.rowspan;y++)i[d.row+y]+=d.n;r.setNodeMarkup(r.mapping.map(n+1+d.pos),null,al(g,g.colspan-d.n,d.n))}else if(d.type=="missing")i[d.row]+=d.n;else if(d.type=="overlong_rowspan"){const h=e.nodeAt(d.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+d.pos),null,{...h.attrs,rowspan:h.attrs.rowspan-d.n})}else if(d.type=="colwidth mismatch"){const h=e.nodeAt(d.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+d.pos),null,{...h.attrs,colwidth:d.colwidth})}else if(d.type=="zero_sized"){const h=r.mapping.map(n);r.delete(h,h+e.nodeSize)}}let o,l;for(let u=0;u<i.length;u++)i[u]&&(o==null&&(o=u),l=u);for(let u=0,d=n+1;u<s.height;u++){const h=e.child(u),g=d+h.nodeSize,y=i[u];if(y>0){let b="cell";h.firstChild&&(b=h.firstChild.type.spec.tableRole);const x=[];for(let k=0;k<y;k++){const C=tr(t.schema)[b].createAndFill();C&&x.push(C)}const S=(u==0||o==u-1)&&l==u?d+1:g-1;r.insert(r.mapping.map(S),x)}d=g}return r.setMeta(CZ,{fixTables:!0})}function ei(t){const e=t.selection,n=Ig(t),r=n.node(-1),s=n.start(-1),i=sn.get(r);return{...e instanceof zt?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function vL(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;bZ(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const u=e.map[l],d=r.nodeAt(u);t.setNodeMarkup(t.mapping.map(n+u),null,mL(d.attrs,s-e.colCount(u))),o+=d.attrs.rowspan-1}else{const u=i==null?tr(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,d=e.positionAt(o,s,r);t.insert(t.mapping.map(n+d),u.createAndFill())}}return t}function TZ(t,e){if(!Os(t))return!1;if(e){const n=ei(t);e(vL(t.tr,n,n.left))}return!0}function _Z(t,e){if(!Os(t))return!1;if(e){const n=ei(t);e(vL(t.tr,n,n.right))}return!0}function AZ(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,u=e.map[l],d=n.nodeAt(u),h=d.attrs;if(s>0&&e.map[l-1]==u||s<e.width-1&&e.map[l+1]==u)t.setNodeMarkup(t.mapping.slice(i).map(r+u),null,al(h,s-e.colCount(u)));else{const g=t.mapping.slice(i).map(r+u);t.delete(g,g+d.nodeSize)}o+=h.rowspan}}function RZ(t,e){if(!Os(t))return!1;if(e){const n=ei(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;AZ(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=sn.get(i)}e(r)}return!0}function NZ(t,e,n){var r;const s=tr(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function xL(t,{map:e,tableStart:n,table:r},s){let i=n;for(let d=0;d<s;d++)i+=r.child(d).nodeSize;const o=[];let l=s>0?-1:0;NZ(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let d=0,h=e.width*s;d<e.width;d++,h++)if(s>0&&s<e.height&&e.map[h]==e.map[h-e.width]){const g=e.map[h],y=r.nodeAt(g).attrs;t.setNodeMarkup(n+g,null,{...y,rowspan:y.rowspan+1}),d+=y.colspan-1}else{var u;const g=l==null?tr(r.type.schema).cell:(u=r.nodeAt(e.map[h+l*e.width]))===null||u===void 0?void 0:u.type,y=g?.createAndFill();y&&o.push(y)}return t.insert(i,tr(r.type.schema).row.create(null,o)),t}function MZ(t,e){if(!Os(t))return!1;if(e){const n=ei(t);e(xL(t.tr,n,n.top))}return!0}function OZ(t,e){if(!Os(t))return!1;if(e){const n=ei(t);e(xL(t.tr,n,n.bottom))}return!0}function jZ(t,{map:e,table:n,tableStart:r},s){let i=0;for(let d=0;d<s;d++)i+=n.child(d).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const u=new Set;for(let d=0,h=s*e.width;d<e.width;d++,h++){const g=e.map[h];if(!u.has(g)){if(u.add(g),s>0&&g==e.map[h-e.width]){const y=n.nodeAt(g).attrs;t.setNodeMarkup(t.mapping.slice(l).map(g+r),null,{...y,rowspan:y.rowspan-1}),d+=y.colspan-1}else if(s<e.height&&g==e.map[h+e.width]){const y=n.nodeAt(g),b=y.attrs,x=y.type.create({...b,rowspan:y.attrs.rowspan-1},y.content),S=e.positionAt(s+1,d,n);t.insert(t.mapping.slice(l).map(r+S),x),d+=b.colspan-1}}}}function DZ(t,e){if(!Os(t))return!1;if(e){const n=ei(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;jZ(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=sn.get(n.table)}e(r)}return!0}function PR(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function IZ({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let u=r.top;u<r.bottom;u++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let u=r.left;u<r.right;u++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function zR(t,e){const n=t.selection;if(!(n instanceof zt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=ei(t),{map:s}=r;if(IZ(s,r))return!1;if(e){const i=t.tr,o={};let l=fe.empty,u,d;for(let h=r.top;h<r.bottom;h++)for(let g=r.left;g<r.right;g++){const y=s.map[h*s.width+g],b=r.table.nodeAt(y);if(!(o[y]||!b))if(o[y]=!0,u==null)u=y,d=b;else{PR(b)||(l=l.append(b.content));const x=i.mapping.map(y+r.tableStart);i.delete(x,x+b.nodeSize)}}if(u==null||d==null)return!0;if(i.setNodeMarkup(u+r.tableStart,null,{...mL(d.attrs,d.attrs.colspan,r.right-r.left-d.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const h=u+1+d.content.size,g=PR(d)?u+1:h;i.replaceWith(g+r.tableStart,h+r.tableStart,l)}i.setSelection(new zt(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function $R(t,e){const n=tr(t.schema);return LZ(({node:r})=>n[r.type.spec.tableRole])(t,e)}function LZ(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof zt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=mZ(r.$from),!s)return!1;i=(o=ol(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs;const u=[],d=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const h=ei(e),g=e.tr;for(let b=0;b<h.right-h.left;b++)u.push(d?{...l,colwidth:d&&d[b]?[d[b]]:null}:l);let y;for(let b=h.top;b<h.bottom;b++){let x=h.map.positionAt(b,h.left,h.table);b==h.top&&(x+=s.nodeSize);for(let S=h.left,k=0;S<h.right;S++,k++)S==h.left&&b==h.top||g.insert(y=g.mapping.map(x+h.tableStart,1),t({node:s,row:b,col:S}).createAndFill(u[k]))}g.setNodeMarkup(i,t({node:s,row:h.top,col:h.left}),u[0]),r instanceof zt&&g.setSelection(new zt(g.doc.resolve(r.$anchorCell.pos),y?g.doc.resolve(y):void 0)),n(g)}return!0}}function PZ(t,e){return function(n,r){if(!Os(n))return!1;const s=Ig(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof zt?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function zZ(t){return function(e,n){if(!Os(e))return!1;if(n){const r=tr(e.schema),s=ei(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(u=>s.table.nodeAt(u));for(let u=0;u<o.length;u++)l[u].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[u],r.cell,l[u].attrs);if(i.steps.length===0)for(let u=0;u<o.length;u++)i.setNodeMarkup(s.tableStart+o[u],r.header_cell,l[u].attrs);n(i)}return!0}}function BR(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function Jd(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?zZ(t):function(n,r){if(!Os(n))return!1;if(r){const s=tr(n.schema),i=ei(n),o=n.tr,l=BR("row",i,s),u=BR("column",i,s),d=(t==="column"?l:t==="row"&&u)?1:0,h=t=="column"?{left:0,top:d,right:1,bottom:i.map.height}:t=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,g=t=="column"?u?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(h).forEach(y=>{const b=y+i.tableStart,x=o.doc.nodeAt(b);x&&o.setNodeMarkup(b,g,x.attrs)}),r(o)}return!0}}Jd("row",{useDeprecatedLogic:!0});Jd("column",{useDeprecatedLogic:!0});const $Z=Jd("cell",{useDeprecatedLogic:!0});function BZ(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function VR(t){return function(e,n){if(!Os(e))return!1;const r=BZ(Ig(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection($e.between(s,yZ(s))).scrollIntoView())}return!0}}function VZ(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 np(t,e){const n=t.selection;if(!(n instanceof zt))return!1;if(e){const r=t.tr,s=tr(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new Re(s,0,0))}),r.docChanged&&e(r)}return!0}function HZ(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let u=0;u<e.childCount;u++){let d=e.child(u).content;const h=u?0:Math.max(0,n-1),g=u<e.childCount-1?0:Math.max(0,r-1);(h||g)&&(d=Zx(tr(o).row,new Re(d,h,g)).content),l.push(d)}else if(i=="cell"||i=="header_cell")l.push(n||r?Zx(tr(o).row,new Re(e,n,r)).content:e);else return null;return UZ(o,l)}function UZ(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:u}=i.child(o).attrs;for(let d=s;d<s+l;d++)n[d]=(n[d]||0)+u}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(fe.empty),n[s]<r){const i=tr(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(fe.from(o))}return{height:e.length,width:r,rows:e}}function Zx(t,e){const n=t.createAndFill();return new nS(n).replace(0,n.content.size,e).doc}function FZ({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const u=n[l],d=[];for(let h=i[l]||0,g=0;h<r;g++){let y=u.child(g%u.childCount);h+y.attrs.colspan>r&&(y=y.type.createChecked(al(y.attrs,y.attrs.colspan,h+y.attrs.colspan-r),y.content)),d.push(y),h+=y.attrs.colspan;for(let b=1;b<y.attrs.rowspan;b++)i[l+b]=(i[l+b]||0)+y.attrs.colspan}o.push(fe.from(d))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const u=[],d=n[l%e];for(let h=0;h<d.childCount;h++){let g=d.child(h);o+g.attrs.rowspan>s&&(g=g.type.create({...g.attrs,rowspan:Math.max(1,s-g.attrs.rowspan)},g.content)),u.push(g)}i.push(fe.from(u))}n=i,e=s}return{width:t,height:e,rows:n}}function qZ(t,e,n,r,s,i,o){const l=t.doc.type.schema,u=tr(l);let d,h;if(s>e.width)for(let g=0,y=0;g<e.height;g++){const b=n.child(g);y+=b.nodeSize;const x=[];let S;b.lastChild==null||b.lastChild.type==u.cell?S=d||(d=u.cell.createAndFill()):S=h||(h=u.header_cell.createAndFill());for(let k=e.width;k<s;k++)x.push(S);t.insert(t.mapping.slice(o).map(y-1+r),x)}if(i>e.height){const g=[];for(let x=0,S=(e.height-1)*e.width;x<Math.max(e.width,s);x++){const k=x>=e.width?!1:n.nodeAt(e.map[S+x]).type==u.header_cell;g.push(k?h||(h=u.header_cell.createAndFill()):d||(d=u.cell.createAndFill()))}const y=u.row.create(null,fe.from(g)),b=[];for(let x=e.height;x<i;x++)b.push(y);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),b)}return!!(d||h)}function HR(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let u=!1;for(let d=s;d<i;d++){const h=o*e.width+d,g=e.map[h];if(e.map[h-e.width]==g){u=!0;const y=n.nodeAt(g),{top:b,left:x}=e.findCell(g);t.setNodeMarkup(t.mapping.slice(l).map(g+r),null,{...y.attrs,rowspan:o-b}),t.insert(t.mapping.slice(l).map(e.positionAt(o,x,n)),y.type.createAndFill({...y.attrs,rowspan:b+y.attrs.rowspan-o})),d+=y.attrs.colspan-1}}return u}function UR(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let u=!1;for(let d=s;d<i;d++){const h=d*e.width+o,g=e.map[h];if(e.map[h-1]==g){u=!0;const y=n.nodeAt(g),b=e.colCount(g),x=t.mapping.slice(l).map(g+r);t.setNodeMarkup(x,null,al(y.attrs,o-b,y.attrs.colspan-(o-b))),t.insert(x+y.nodeSize,y.type.createAndFill(al(y.attrs,0,o-b))),d+=y.attrs.rowspan-1}}return u}function FR(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=sn.get(i);const{top:l,left:u}=r,d=u+s.width,h=l+s.height,g=t.tr;let y=0;function b(){if(i=n?g.doc.nodeAt(n-1):g.doc,!i)throw new Error("No table found");o=sn.get(i),y=g.mapping.maps.length}qZ(g,o,i,n,d,h,y)&&b(),HR(g,o,i,n,u,d,l,y)&&b(),HR(g,o,i,n,u,d,h,y)&&b(),UR(g,o,i,n,l,h,u,y)&&b(),UR(g,o,i,n,l,h,d,y)&&b();for(let x=l;x<h;x++){const S=o.positionAt(x,u,i),k=o.positionAt(x,d,i);g.replace(g.mapping.slice(y).map(S+n),g.mapping.slice(y).map(k+n),new Re(s.rows[x-l],0,0))}b(),g.setSelection(new zt(g.doc.resolve(n+o.positionAt(l,u,i)),g.doc.resolve(n+o.positionAt(h-1,d-1,i)))),e(g)}const GZ=yS({ArrowLeft:rp("horiz",-1),ArrowRight:rp("horiz",1),ArrowUp:rp("vert",-1),ArrowDown:rp("vert",1),"Shift-ArrowLeft":sp("horiz",-1),"Shift-ArrowRight":sp("horiz",1),"Shift-ArrowUp":sp("vert",-1),"Shift-ArrowDown":sp("vert",1),Backspace:np,"Mod-Backspace":np,Delete:np,"Mod-Delete":np});function Dp(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function rp(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof zt)return Dp(n,r,Ye.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=wL(s,t,e);if(o==null)return!1;if(t=="horiz")return Dp(n,r,Ye.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),u=pL(l,t,e);let d;return u?d=Ye.near(u,1):e<0?d=Ye.near(n.doc.resolve(l.before(-1)),-1):d=Ye.near(n.doc.resolve(l.after(-1)),1),Dp(n,r,d)}}}function sp(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof zt)o=i;else{const u=wL(s,t,e);if(u==null)return!1;o=new zt(n.doc.resolve(u))}const l=pL(o.$headCell,t,e);return l?Dp(n,r,new zt(o.$anchorCell,l)):!1}}function WZ(t,e){const n=t.state.doc,r=ol(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new zt(r))),!0):!1}function KZ(t,e,n){if(!Os(t.state))return!1;let r=HZ(n);const s=t.state.selection;if(s instanceof zt){r||(r={width:1,height:1,rows:[fe.from(Zx(tr(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=sn.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=FZ(r,l.right-l.left,l.bottom-l.top),FR(t.state,t.dispatch,o,l,r),!0}else if(r){const i=Ig(t.state),o=i.start(-1);return FR(t.state,t.dispatch,o,sn.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function ZZ(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=qR(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof zt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=ol(t.state.selection.$anchor))!=null&&((n=l0(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(u,d){let h=l0(t,d);const g=Lo.getState(t.state)==null;if(!h||!JS(u,h))if(g)h=u;else return;const y=new zt(u,h);if(g||!t.state.selection.eq(y)){const b=t.state.tr.setSelection(y);g&&b.setMeta(Lo,u.pos),t.dispatch(b)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),Lo.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Lo,-1))}function l(u){const d=u,h=Lo.getState(t.state);let g;if(h!=null)g=t.state.doc.resolve(h);else if(qR(t,d.target)!=r&&(g=l0(t,e),!g))return o();g&&i(g,d)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function wL(t,e,n){if(!(t.state.selection instanceof $e))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function qR(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function l0(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&ol(t.state.doc.resolve(r))||ol(t.state.doc.resolve(s))}var YZ=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")),Yx(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,Yx(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Yx(t,e,n,r,s,i){let o=0,l=!0,u=e.firstChild;const d=t.firstChild;if(d){for(let g=0,y=0;g<d.childCount;g++){const{colspan:b,colwidth:x}=d.child(g).attrs;for(let S=0;S<b;S++,y++){const k=s==y?i: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 g=u.nextSibling;(h=u.parentNode)===null||h===void 0||h.removeChild(u),u=g}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const $r=new on("tableColumnResizing");function XZ({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=YZ,lastColumnResizable:s=!0}={}){const i=new Bt({key:$r,state:{init(o,l){var u;const d=(u=i.spec)===null||u===void 0||(u=u.props)===null||u===void 0?void 0:u.nodeViews,h=tr(l.schema).table.name;return r&&d&&(d[h]=(g,y)=>new r(g,n,y)),new JZ(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=$r.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{QZ(o,l,t,s)},mouseleave:o=>{eY(o)},mousedown:(o,l)=>{tY(o,l,e,n)}},decorations:o=>{const l=$r.getState(o);if(l&&l.activeHandle>-1)return oY(o,l.activeHandle)},nodeViews:{}}});return i}var JZ=class Ip{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta($r);if(r&&r.setHandle!=null)return new Ip(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Ip(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return Kx(e.doc.resolve(s))||(s=-1),new Ip(s,n.dragging)}return n}};function QZ(t,e,n,r){if(!t.editable)return;const s=$r.getState(t.state);if(s&&!s.dragging){const i=rY(e.target);let o=-1;if(i){const{left:l,right:u}=i.getBoundingClientRect();e.clientX-l<=n?o=GR(t,e,"left",n):u-e.clientX<=n&&(o=GR(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),u=l.node(-1),d=sn.get(u),h=l.start(-1);if(d.colCount(l.pos-h)+l.nodeAfter.attrs.colspan-1==d.width-1)return}SL(t,o)}}}function eY(t){if(!t.editable)return;const e=$r.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&SL(t,-1)}function tY(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=$r.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),u=nY(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta($r,{setDragging:{startX:e.clientX,startWidth:u}}));function d(g){i.removeEventListener("mouseup",d),i.removeEventListener("mousemove",h);const y=$r.getState(t.state);y?.dragging&&(sY(t,y.activeHandle,WR(y.dragging,g,n)),t.dispatch(t.state.tr.setMeta($r,{setDragging:null})))}function h(g){if(!g.which)return d(g);const y=$r.getState(t.state);if(y&&y.dragging){const b=WR(y.dragging,g,n);KR(t,y.activeHandle,b,r)}}return KR(t,o.activeHandle,u,r),i.addEventListener("mouseup",d),i.addEventListener("mousemove",h),e.preventDefault(),!0}function nY(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let u=0;u<n;u++)r[u]&&(o-=r[u],l--);return o/l}function rY(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function GR(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=ol(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const u=sn.get(l.node(-1)),d=l.start(-1),h=u.map.indexOf(l.pos-d);return h%u.width==0?-1:d+u.map[h-1]}function WR(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function SL(t,e){t.dispatch(t.state.tr.setMeta($r,{setHandle:e}))}function sY(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=sn.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let d=0;d<i.height;d++){const h=d*i.width+l;if(d&&i.map[h]==i.map[h-i.width])continue;const g=i.map[h],y=s.nodeAt(g).attrs,b=y.colspan==1?0:l-i.colCount(g);if(y.colwidth&&y.colwidth[b]==n)continue;const x=y.colwidth?y.colwidth.slice():iY(y.colspan);x[b]=n,u.setNodeMarkup(o+g,null,{...y,colwidth:x})}u.docChanged&&t.dispatch(u)}function KR(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=sn.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let u=t.domAtPos(s.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&Yx(i,u.firstChild,u,r,l,n)}function iY(t){return Array(t).fill(0)}function oY(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return _t.empty;const i=sn.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let d=0;d<i.height;d++){const h=l+d*i.width;if((l==i.width-1||i.map[h]!=i.map[h+1])&&(d==0||i.map[h]!=i.map[h-i.width])){var u;const g=i.map[h],y=o+g+s.nodeAt(g).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((u=$r.getState(t))===null||u===void 0)&&u.dragging&&n.push(An.node(o+g,o+g+s.nodeAt(g).nodeSize,{class:"column-resize-dragging"})),n.push(An.widget(y,b))}}return _t.create(t.doc,n)}function aY({allowTableNodeSelection:t=!1}={}){return new Bt({key:Lo,state:{init(){return null},apply(e,n){const r=e.getMeta(Lo);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:xZ,handleDOMEvents:{mousedown:ZZ},createSelectionBetween(e){return Lo.getState(e.state)!=null?e.state.selection:null},handleTripleClick:WZ,handleKeyDown:GZ,handlePaste:KZ},appendTransaction(e,n,r){return kZ(r,bL(r,n),t)}})}function Xm(t){return t==="left"||t==="right"||t==="center"?t:null}function lY(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return Xm(e||n)}function cY(t){return Xm(t?.align)}function kL(){return{default:null,parseHTML:t=>lY(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}function uY(t){var e;const n=t.parentElement,r=t.closest("table");if(!n||!r)return null;const s=Array.from(n.children).indexOf(t),i=(e=r.querySelectorAll("colgroup > col")[s])==null?void 0:e.getAttribute("width");return i?[parseInt(i,10)]:null}function CL(t){const e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):uY(t)}var dY=/[ \t\r\n\f]+/g;function EL(t){var e;return t.children.length>0?!1:((e=t.textContent)!=null?e:"").replace(dY,"")===""}function TL(t){const e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}var fY=On.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:CL},align:kL()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>EL(t)?{}:!1,getContent:(t,e)=>TL(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",$t(this.options.HTMLAttributes,t),0]}}),hY=On.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:CL},align:kL()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>EL(t)?{}:!1,getContent:(t,e)=>TL(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",$t(this.options.HTMLAttributes,t),0]}}),pY=On.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",$t(this.options.HTMLAttributes,t),0]}});function Xx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function ZR(t,e,n,r,s,i){var o;let l=0,u=!0,d=e.firstChild;const h=t.firstChild;if(h!==null)for(let y=0,b=0;y<h.childCount;y+=1){const{colspan:x,colwidth:S}=h.child(y).attrs;for(let k=0;k<x;k+=1,b+=1){const C=s===b?i:S&&S[k],A=C?`${C}px`:"";if(l+=C||r,C||(u=!1),d){if(d.style.width!==A){const[R,_]=Xx(r,C);d.style.setProperty(R,_)}d=d.nextSibling}else{const R=document.createElement("col"),[_,N]=Xx(r,C);R.style.setProperty(_,N),e.appendChild(R)}}}for(;d;){const y=d.nextSibling;(o=d.parentNode)==null||o.removeChild(d),d=y}const g=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);u&&!g?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var mY=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[s,i]of Object.entries(r))i!=null&&(s==="style"?this.table.style.cssText=String(i):this.table.setAttribute(s,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ZR(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,ZR(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 gY(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let g=0,y=0;g<l.childCount;g+=1){const{colspan:b,colwidth:x}=l.child(g).attrs;for(let S=0;S<b;S+=1,y+=1){const k=n===y?r:x&&x[S];s+=k||e,k||(i=!1);const[C,A]=Xx(e,k);o.push(["col",{style:`${C}: ${A}`}])}}const u=i?`${s}px`:"",d=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:u,tableMinWidth:d}}function YR(t,e){return t.createAndFill()}function yY(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 bY(t,e,n,r,s){const i=yY(t),o=[],l=[];for(let d=0;d<n;d+=1){const h=YR(i.cell);if(h&&l.push(h),r){const g=YR(i.header_cell);g&&o.push(g)}}const u=[];for(let d=0;d<e;d+=1)u.push(i.row.createChecked(null,r&&d===0?o:l));return i.table.createChecked(null,u)}function vY(t){return t instanceof zt}var ip=({editor:t})=>{const{selection:e}=t.state;if(!vY(e))return!1;let n=0;const r=BD(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},xY="";function wY(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 s=n+r,i=!1;for(;s<t.length;){if(t[s]!=="`"){s+=1;continue}let o=0;for(;s+o<t.length&&t[s+o]==="`";)o+=1;if(o===r){const l=t.slice(n+r,s);e+=t.slice(n,n+r)+l.replace(new RegExp("(?<!\\\\)\\|","g"),"\\|")+t.slice(s,s+r),n=s+r,i=!0;break}s+=o}i||(e+=t.slice(n,n+r),n+=r)}return e}function SY(t){return t.split(`
|
|
273
|
+
`).map(e=>!e.includes("|")||!e.includes("`")?e:wY(e)).join(`
|
|
274
|
+
`)}function kY(t){return(t||"").replace(/\s+/g," ").trim()}function CY(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:xY;if(!t||!t.content||t.content.length===0)return"";const i=[];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(O=>e.renderChildren(O)).join(s):A=C.content?e.renderChildren(C.content):"";const R=kY(A.split(s).join(`
|
|
275
|
+
`).replace(/[ \t]*\r?\n[ \t]*/g,"<br>")),_=C.type==="tableHeader",N=cY(C.attrs);k.push({text:R,isHeader:_,align:N})}),i.push(k)});const o=i.reduce((S,k)=>Math.max(S,k.length),0);if(o===0)return"";const l=Array.from({length:o}).fill(0);i.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)),d=i[0],h=d.some(S=>S.isHeader),g=Array.from({length:o}).fill(null);i.forEach(S=>{var k;for(let C=0;C<o;C+=1)!g[C]&&((k=S[C])!=null&&k.align)&&(g[C]=S[C].align)});let y=`
|
|
276
|
+
`;const b=Array.from({length:o}).map((S,k)=>h&&d[k]&&d[k].text||"");return y+=`| ${b.map((S,k)=>u(S,l[k])).join(" | ")} |
|
|
277
|
+
`,y+=`| ${l.map((S,k)=>{const C=Math.max(3,S),A=g[k];return A==="left"?`:${"-".repeat(C)}`:A==="right"?`${"-".repeat(C)}:`:A==="center"?`:${"-".repeat(C)}:`:"-".repeat(C)}).join(" | ")} |
|
|
278
|
+
`,(h?i.slice(1):i).forEach(S=>{y+=`| ${Array.from({length:o}).fill(0).map((k,C)=>u(S[C]&&S[C].text||"",l[C])).join(" | ")} |
|
|
279
|
+
`}),y}var EY=CY,TY=On.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:mY,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=gY(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const l=["table",$t(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 s=[];t.header.forEach((i,o)=>{var l;const u=Xm((l=r[o])!=null?l:i.align),d=u?{align:u}:{};s.push(e.createNode("tableHeader",d,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const i=[];s.forEach((o,l)=>{var u;const d=Xm((u=r[l])!=null?u:o.align),h=d?{align:d}:{};i.push(e.createNode("tableCell",h,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>EY(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
|
+
`),s=r>=0?t.slice(0,r):t,i=s.split(`
|
|
283
|
+
`);if(i.length<2)return;const o=i[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes("|"))return;const l=SY(s);if(l===s)return;const d=n.blockTokens(l)[0];if(d?.type!=="table"||!d.raw)return;const h=d.raw.split(`
|
|
284
|
+
`).length,g=t.split(`
|
|
285
|
+
`).slice(0,h).join(`
|
|
286
|
+
`);return{...d,raw:g}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=bY(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection($e.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>TZ(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>_Z(t,e),deleteColumn:()=>({state:t,dispatch:e})=>RZ(t,e),addRowBefore:()=>({state:t,dispatch:e})=>MZ(t,e),addRowAfter:()=>({state:t,dispatch:e})=>OZ(t,e),deleteRow:()=>({state:t,dispatch:e})=>DZ(t,e),deleteTable:()=>({state:t,dispatch:e})=>VZ(t,e),mergeCells:()=>({state:t,dispatch:e})=>zR(t,e),splitCell:()=>({state:t,dispatch:e})=>$R(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Jd("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Jd("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>$Z(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>zR(t,e)?!0:$R(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>PZ(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>VR(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>VR(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&bL(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=zt.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:ip,"Mod-Backspace":ip,Delete:ip,"Mod-Delete":ip}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[XZ({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],aY({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:s})=>{const i=$t(this.options.HTMLAttributes,s);return new e(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:bt(je(t,"tableRole",e))}}}),_Y=Zt.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(TY.configure(this.options.table)),this.options.tableCell!==!1&&t.push(fY.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(hY.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(pY.configure(this.options.tableRow)),t}});function AY({recordImages:t=[],galleryUpload:e,onListGallery:n,onUploadGallery:r,onClose:s,onInsert:i}){const o=!!n,[l,u]=E.useState(t.length?"record":"gallery"),[d,h]=E.useState([]),[g,y]=E.useState(!1),[b,x]=E.useState(null),[S,k]=E.useState({}),[C,A]=E.useState("");E.useEffect(()=>{const F=H=>{H.key==="Escape"&&s()};window.addEventListener("keydown",F);const te=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",F),document.body.style.overflow=te}},[s]),E.useEffect(()=>{if(!o)return;let F=!1;return y(!0),x(null),n().then(te=>{F||h(te)}).catch(te=>{F||x(te instanceof Error?te.message:"Could not load gallery")}).finally(()=>{F||y(!1)}),()=>{F=!0}},[o,n]);const R=E.useMemo(()=>t.map(F=>({id:`record:${F.id}`,url:F.url,name:F.name,source:"record"})),[t]),_=E.useMemo(()=>d.map(F=>({id:`gallery:${F.id}`,url:F.url,name:F.name??F.id,source:"gallery"})),[d]),N=l==="record"?R:_,M=Object.values(S),O=!!(e&&r),P=F=>{k(te=>{const H={...te};return H[F.id]?delete H[F.id]:H[F.id]=F,H})},D=()=>{const F=C.trim();if(!F)return;const te={id:`url:${F}`,url:F,name:"Image",source:"url"};k(H=>({...H,[te.id]:te})),A("")};return m.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:s,children:m.jsxs("div",{className:"vertebr-modal",role:"dialog","aria-modal":"true","aria-label":"Insert images",onClick:F=>F.stopPropagation(),children:[m.jsxs("header",{className:"vertebr-modal-head",children:[m.jsxs("div",{className:"vertebr-modal-heading",children:[m.jsx("p",{className:"vertebr-modal-eyebrow",children:"Media"}),m.jsx("h2",{children:"Insert images"})]}),m.jsx("button",{type:"button",className:"vertebr-btn",onClick:s,children:"Close"})]}),m.jsxs("div",{className:"vertebr-modal-body vertebr-picker-body",children:[t.length>0&&o?m.jsxs("div",{className:"vertebr-picker-tabs",role:"tablist",children:[m.jsxs("button",{type:"button",role:"tab","aria-selected":l==="record","data-active":l==="record"||void 0,onClick:()=>u("record"),children:["Product photos",m.jsx("span",{children:R.length})]}),m.jsxs("button",{type:"button",role:"tab","aria-selected":l==="gallery","data-active":l==="gallery"||void 0,onClick:()=>u("gallery"),children:["Gallery",m.jsx("span",{children:g?"…":_.length})]})]}):null,l==="gallery"&&O?m.jsx(Wc,{meta:{field:"gallery",accept:e.accept,maxBytes:e.maxBytes},multiple:!0,label:"Drop images to add them to the gallery",onUpload:async F=>{const te=await r(F);h(H=>[...te,...H]),k(H=>{const Z={...H};for(const G of te){const ae={id:`gallery:${G.id}`,url:G.url,name:G.name??G.id,source:"gallery"};Z[ae.id]=ae}return Z})}}):null,m.jsxs("label",{className:"vertebr-field",children:[m.jsx("span",{children:"Or paste an image URL"}),m.jsxs("div",{className:"vertebr-picker-url",children:[m.jsx("input",{type:"url",value:C,placeholder:"https://",onChange:F=>A(F.target.value),onKeyDown:F=>{F.key==="Enter"&&(F.preventDefault(),D())}}),m.jsx("button",{type:"button",className:"vertebr-btn",disabled:!C.trim(),onClick:D,children:"Add"})]})]}),b?m.jsx("p",{className:"vertebr-status","data-tone":"danger",children:b}):null,g&&l==="gallery"?m.jsx("div",{className:"vertebr-empty",children:"Loading gallery…"}):N.length===0?m.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."}):m.jsx("div",{className:"vertebr-picker-grid",children:N.map(F=>{const te=!!S[F.id];return m.jsxs("button",{type:"button",className:"vertebr-picker-tile","data-selected":te||void 0,onClick:()=>P(F),children:[m.jsx("span",{className:"vertebr-picker-thumb",children:m.jsx("img",{src:F.url,alt:""})}),m.jsx("span",{className:"vertebr-picker-name",children:F.name})]},F.id)})})]}),m.jsxs("footer",{className:"vertebr-picker-foot",children:[m.jsxs("span",{className:"vertebr-picker-count",children:[M.length," selected"]}),m.jsxs("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",disabled:M.length===0,onClick:()=>i(M),children:["Insert ",M.length||"",M.length===1?" image":" images"]})]})]})})}function XR(t,e){t&&(typeof t=="function"?t(e):t.current=e)}function or({active:t,disabled:e,title:n,onClick:r,children:s}){return m.jsx("button",{type:"button",className:"vertebr-md-btn","data-active":t||void 0,disabled:e,title:n,onMouseDown:i=>i.preventDefault(),onClick:r,children:s})}function RY({id:t,name:e,value:n,readOnly:r,placeholder:s="Write a description…",recordImages:i,galleryUpload:o,onListGallery:l,onUploadGallery:u,onBlur:d,onChange:h,inputRef:g}){const y=typeof n=="string"?n:"",b=E.useRef(h),x=E.useRef(d),S=E.useRef(y),[k,C]=E.useState(!1);b.current=h,x.current=d;const A=OG({immediatelyRender:!1,shouldRerenderOnTransaction:!1,content:y,contentType:"markdown",editable:!r,extensions:[iK.configure({heading:{levels:[2,3]},underline:!1,link:{openOnClick:!1,defaultProtocol:"https"}}),uZ.configure({inline:!1,allowBase64:!1}),_Y.configure({table:{resizable:!1}}),X7.configure({placeholder:s}),aZ.configure({markedOptions:{gfm:!0}})],editorProps:{attributes:{id:t,class:"vertebr-md-content"}},onUpdate:({editor:P})=>{const D=P.getMarkdown();S.current=D,b.current(D)},onBlur:()=>{x.current?.()}});E.useEffect(()=>{if(A)return XR(g,A.view.dom),()=>XR(g,null)},[A,g]),E.useEffect(()=>{A&&A.setEditable(!r)},[A,r]),E.useEffect(()=>{if(A&&y!==S.current){if(y===A.getMarkdown()){S.current=y;return}A.commands.setContent(y,{contentType:"markdown",emitUpdate:!1}),S.current=y}},[A,y]);const R=yI({editor:A,selector:({editor:P})=>({bold:P?.isActive("bold")??!1,italic:P?.isActive("italic")??!1,strike:P?.isActive("strike")??!1,code:P?.isActive("code")??!1,codeBlock:P?.isActive("codeBlock")??!1,heading:P?.isActive("heading")??!1,quote:P?.isActive("blockquote")??!1,bullet:P?.isActive("bulletList")??!1,ordered:P?.isActive("orderedList")??!1,table:P?.isActive("table")??!1,link:P?.isActive("link")??!1,stats:U_(P?.getText()??y)})}),_=R?.stats??U_(y),N=r||!A,M=()=>{if(!A||r)return;const P=A.getAttributes("link").href,D=window.prompt("Link URL",typeof P=="string"&&P?P:"https://");if(D!==null){if(!D.trim()){A.chain().focus().extendMarkRange("link").unsetLink().run();return}A.chain().focus().extendMarkRange("link").setLink({href:D.trim()}).run()}},O=P=>{!A||P.length===0||(A.chain().focus().insertContent(P.map(D=>({type:"image",attrs:{src:D.url,alt:D.name}}))).run(),C(!1))};return m.jsxs("div",{className:"vertebr-field-prose",onKeyDown:P=>{(P.metaKey||P.ctrlKey)&&P.key.toLowerCase()==="k"&&(P.preventDefault(),M())},children:[e?m.jsx("input",{type:"hidden",name:e,value:y,readOnly:!0}):null,m.jsxs("div",{className:"vertebr-md-toolbar",role:"toolbar","aria-label":"Format",children:[m.jsx(or,{active:R?.bold,disabled:N,title:"Bold",onClick:()=>A?.chain().focus().toggleBold().run(),children:m.jsx("span",{className:"vertebr-md-glyph",children:"B"})}),m.jsx(or,{active:R?.italic,disabled:N,title:"Italic",onClick:()=>A?.chain().focus().toggleItalic().run(),children:m.jsx("span",{className:"vertebr-md-glyph vertebr-md-italic",children:"I"})}),m.jsx(or,{active:R?.strike,disabled:N,title:"Strikethrough",onClick:()=>A?.chain().focus().toggleStrike().run(),children:m.jsx("span",{className:"vertebr-md-glyph vertebr-md-strike",children:"S"})}),m.jsx(or,{active:R?.code,disabled:N,title:"Inline code",onClick:()=>A?.chain().focus().toggleCode().run(),children:"</>"}),m.jsx(or,{active:R?.codeBlock,disabled:N,title:"Code block",onClick:()=>A?.chain().focus().toggleCodeBlock().run(),children:"{ }"}),m.jsx("span",{className:"vertebr-md-sep","aria-hidden":"true"}),m.jsx(or,{active:R?.heading,disabled:N,title:"Heading",onClick:()=>A?.chain().focus().toggleHeading({level:2}).run(),children:"H"}),m.jsx(or,{active:R?.quote,disabled:N,title:"Quote",onClick:()=>A?.chain().focus().toggleBlockquote().run(),children:"“"}),m.jsx(or,{active:R?.bullet,disabled:N,title:"Bulleted list",onClick:()=>A?.chain().focus().toggleBulletList().run(),children:"•"}),m.jsx(or,{active:R?.ordered,disabled:N,title:"Numbered list",onClick:()=>A?.chain().focus().toggleOrderedList().run(),children:"1."}),m.jsx("span",{className:"vertebr-md-sep","aria-hidden":"true"}),m.jsx(or,{active:R?.table,disabled:N,title:"Table",onClick:()=>A?.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),children:"Table"}),R?.table?m.jsxs(m.Fragment,{children:[m.jsx(or,{disabled:N,title:"Add column",onClick:()=>A?.chain().focus().addColumnAfter().run(),children:"+Col"}),m.jsx(or,{disabled:N,title:"Add row",onClick:()=>A?.chain().focus().addRowAfter().run(),children:"+Row"}),m.jsx(or,{disabled:N,title:"Delete table",onClick:()=>A?.chain().focus().deleteTable().run(),children:"Del"})]}):null,m.jsx(or,{active:R?.link,disabled:N,title:"Link",onClick:M,children:"Link"}),m.jsx(or,{disabled:N,title:"Insert images",onClick:()=>C(!0),children:"Image"})]}),m.jsx(gI,{editor:A}),m.jsxs("p",{className:"vertebr-field-prose-meta",children:["Markdown",m.jsx("span",{"aria-hidden":"true",children:" · "}),_.words," ",_.words===1?"word":"words",m.jsx("span",{"aria-hidden":"true",children:" · "}),_.characters," ",_.characters===1?"character":"characters"]}),k?m.jsx(AY,{recordImages:i,galleryUpload:o,onListGallery:l,onUploadGallery:u,onClose:()=>C(!1),onInsert:O}):null]})}var NY=Object.defineProperty,MY=(t,e)=>NY(t,"name",{value:e,configurable:!0});function Jx(t,[e,n]){return Math.min(n,Math.max(e,t))}MY(Jx,"clamp");var OY=Object.defineProperty,_n=(t,e)=>OY(t,"name",{value:e,configurable:!0});function _L(t){const e=t+"CollectionProvider",[n,r]=Yc(e),[s,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=_n(S=>{const{scope:k,children:C}=S,A=E.useRef(null),R=E.useRef(new Map).current;return m.jsx(s,{scope:k,itemMap:R,collectionRef:A,children:C})},"CollectionProvider");o.displayName=e;const l=t+"CollectionSlot",u=el(l),d=E.forwardRef((S,k)=>{const{scope:C,children:A}=S,R=i(l,C),_=dn(k,R.collectionRef);return m.jsx(u,{ref:_,children:A})});d.displayName=l;const h=t+"CollectionItemSlot",g="data-radix-collection-item",y=el(h),b=E.forwardRef((S,k)=>{const{scope:C,children:A,...R}=S,_=E.useRef(null),N=dn(k,_),M=i(h,C);return E.useEffect(()=>(M.itemMap.set(_,{ref:_,...R}),()=>{M.itemMap.delete(_)})),m.jsx(y,{[g]:"",ref:N,children:A})});b.displayName=h;function x(S){const k=i(t+"CollectionConsumer",S);return E.useCallback(()=>{const A=k.collectionRef.current;if(!A)return[];const R=Array.from(A.querySelectorAll(`[${g}]`));return Array.from(k.itemMap.values()).sort((M,O)=>R.indexOf(M.ref.current)-R.indexOf(O.ref.current))},[k.collectionRef,k.itemMap])}return _n(x,"useCollection"),[{Provider:o,Slot:d,ItemSlot:b},x,r]}_n(_L,"createCollection");var JR=new WeakMap,gn,Ir,c0=(Ir=class extends Map{constructor(n){super(n);hT(this,gn);cv(this,gn,[...super.keys()]),JR.set(this,!0)}set(n,r){return JR.get(this)&&(this.has(n)?Zn(this,gn)[Zn(this,gn).indexOf(n)]=n:Zn(this,gn).push(n)),super.set(n,r),this}insert(n,r,s){const i=this.has(r),o=Zn(this,gn).length,l=QS(n);let u=l>=0?l:o+l;const d=u<0||u>=o?-1:u;if(d===this.size||i&&d===this.size-1||d===-1)return this.set(r,s),this;const h=this.size+(i?0:1);l<0&&u++;const g=[...Zn(this,gn)];let y,b=!1;for(let x=u;x<h;x++)if(u===x){let S=g[x];g[x]===r&&(S=g[x+1]),i&&this.delete(r),y=this.get(S),this.set(r,s)}else{!b&&g[x-1]===r&&(b=!0);const S=g[b?x:x-1],k=y;y=this.get(S),this.delete(S),this.set(S,k)}return this}with(n,r,s){const i=new Ir(this);return i.insert(n,r,s),i}before(n){const r=Zn(this,gn).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,s){const i=Zn(this,gn).indexOf(n);return i===-1?this:this.insert(i,r,s)}after(n){let r=Zn(this,gn).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,s){const i=Zn(this,gn).indexOf(n);return i===-1?this:this.insert(i+1,r,s)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return cv(this,gn,[]),super.clear()}delete(n){const r=super.delete(n);return r&&Zn(this,gn).splice(Zn(this,gn).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){const r=Lp(Zn(this,gn),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=Lp(Zn(this,gn),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return Zn(this,gn).indexOf(n)}keyAt(n){return Lp(Zn(this,gn),n)}from(n,r){const s=this.indexOf(n);if(s===-1)return;let i=s+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(n,r){const s=this.indexOf(n);if(s===-1)return;let i=s+r;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(n,r){let s=0;for(const i of this){if(Reflect.apply(n,r,[i,s,this]))return i;s++}}findIndex(n,r){let s=0;for(const i of this){if(Reflect.apply(n,r,[i,s,this]))return s;s++}return-1}filter(n,r){const s=[];let i=0;for(const o of this)Reflect.apply(n,r,[o,i,this])&&s.push(o),i++;return new Ir(s)}map(n,r){const s=[];let i=0;for(const o of this)s.push([o[0],Reflect.apply(n,r,[o,i,this])]),i++;return new Ir(s)}reduce(...n){const[r,s]=n;let i=0,o=s??this.at(0);for(const l of this)i===0&&n.length===1?o=l:o=Reflect.apply(r,this,[o,l,i,this]),i++;return o}reduceRight(...n){const[r,s]=n;let i=s??this.at(-1);for(let o=this.size-1;o>=0;o--){const l=this.at(o);o===this.size-1&&n.length===1?i=l:i=Reflect.apply(r,this,[i,l,o,this])}return i}toSorted(n){const r=[...this.entries()].sort(n);return new Ir(r)}toReversed(){const n=new Ir;for(let r=this.size-1;r>=0;r--){const s=this.keyAt(r),i=this.get(s);n.set(s,i)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new Ir(r)}slice(n,r){const s=new Ir;let i=this.size-1;if(n===void 0)return s;n<0&&(n=n+this.size),r!==void 0&&r>0&&(i=r-1);for(let o=n;o<=i;o++){const l=this.keyAt(o),u=this.get(l);s.set(l,u)}return s}every(n,r){let s=0;for(const i of this){if(!Reflect.apply(n,r,[i,s,this]))return!1;s++}return!0}some(n,r){let s=0;for(const i of this){if(Reflect.apply(n,r,[i,s,this]))return!0;s++}return!1}},gn=new WeakMap,_n(Ir,"OrderedDict"),Ir);function Lp(t,e){if("at"in Array.prototype)return Array.prototype.at.call(t,e);const n=AL(t,e);return n===-1?void 0:t[n]}_n(Lp,"at");function AL(t,e){const n=t.length,r=QS(e),s=r>=0?r:n+r;return s<0||s>=n?-1:s}_n(AL,"toSafeIndex");function QS(t){return t!==t||t===0?0:Math.trunc(t)}_n(QS,"toSafeInteger");function jY(t){const e=t+"CollectionProvider",[n,r]=Yc(e),[s,i]=n(e,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new c0,setItemMap:_n(()=>{},"setItemMap")}),o=_n(({state:R,..._})=>R?m.jsx(u,{..._,state:R}):m.jsx(l,{..._}),"CollectionProvider");o.displayName=e;const l=_n(R=>{const _=k();return m.jsx(u,{...R,state:_})},"CollectionInit");l.displayName=e+"Init";const u=_n(R=>{const{scope:_,children:N,state:M}=R,O=E.useRef(null),[P,D]=E.useState(null),F=dn(O,D),[te,H]=M;return E.useEffect(()=>{if(!P)return;const Z=ML(()=>{});return Z.observe(P,{childList:!0,subtree:!0}),()=>{Z.disconnect()}},[P]),m.jsx(s,{scope:_,itemMap:te,setItemMap:H,collectionRef:F,collectionRefObject:O,collectionElement:P,children:N})},"CollectionProviderImpl");u.displayName=e+"Impl";const d=t+"CollectionSlot",h=el(d),g=E.forwardRef((R,_)=>{const{scope:N,children:M}=R,O=i(d,N),P=dn(_,O.collectionRef);return m.jsx(h,{ref:P,children:M})});g.displayName=d;const y=t+"CollectionItemSlot",b="data-radix-collection-item",x=el(y),S=E.forwardRef((R,_)=>{const{scope:N,children:M,...O}=R,P=E.useRef(null),[D,F]=E.useState(null),te=dn(_,P,F),H=i(y,N),{setItemMap:Z}=H,G=E.useRef(O);RL(G.current,O)||(G.current=O);const ae=G.current;return E.useEffect(()=>{const z=ae;return Z(L=>D?L.has(D)?L.set(D,{...z,element:D}).toSorted(Qx):(L.set(D,{...z,element:D}),L.toSorted(Qx)):L),()=>{Z(L=>!D||!L.has(D)?L:(L.delete(D),new c0(L)))}},[D,ae,Z]),m.jsx(x,{[b]:"",ref:te,children:M})});S.displayName=y;function k(){return E.useState(new c0)}_n(k,"useInitCollection");function C(R){const{itemMap:_}=i(t+"CollectionConsumer",R);return _}return _n(C,"useCollection"),[{Provider:o,Slot:g,ItemSlot:S},{createCollectionScope:r,useCollection:C,useInitCollection:k}]}_n(jY,"createCollection");function RL(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 s of n)if(!Object.prototype.hasOwnProperty.call(e,s)||t[s]!==e[s])return!1;return!0}_n(RL,"shallowEqual");function NL(t,e){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}_n(NL,"isElementPreceding");function Qx(t,e){return!t[1].element||!e[1].element?0:NL(t[1].element,e[1].element)?-1:1}_n(Qx,"sortByDocumentPosition");function ML(t){return new MutationObserver(n=>{for(const r of n)if(r.type==="childList"){t();return}})}_n(ML,"getChildListObserver");var DY=Object.defineProperty,IY=(t,e)=>DY(t,"name",{value:e,configurable:!0}),LY=E.createContext(void 0);function OL(t){const e=E.useContext(LY);return t||e||"ltr"}IY(OL,"useDirection");var PY=Object.defineProperty,zY=(t,e)=>PY(t,"name",{value:e,configurable:!0});function Xs(t){const e=E.useRef(t);return E.useEffect(()=>{e.current=t}),E.useMemo(()=>((...n)=>e.current?.(...n)),[])}zY(Xs,"useCallbackRef");var $Y=Object.defineProperty,Tn=(t,e)=>$Y(t,"name",{value:e,configurable:!0}),ew="dismissableLayer.update",BY="dismissableLayer.pointerDownOutside",VY="dismissableLayer.focusOutside",QR,jL=E.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),HY=E.forwardRef(Tn(function(e,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:u,onDismiss:d,...h}=e,g=E.useContext(jL),[y,b]=E.useState(null),x=y?.ownerDocument??globalThis?.document,[,S]=E.useState({}),k=dn(n,b),C=Array.from(g.layers),[A]=[...g.layersWithOutsidePointerEventsDisabled].slice(-1),R=A?C.indexOf(A):-1,_=y?C.indexOf(y):-1,N=g.layersWithOutsidePointerEventsDisabled.size>0,M=_>=R,O=E.useRef(!1),P=DL(H=>{o?.(H),u?.(H),H.defaultPrevented||d?.()},{ownerDocument:x,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:O,dismissableSurfaces:g.dismissableSurfaces,shouldHandlePointerDownOutside:E.useCallback(H=>{if(!(H instanceof Node))return!1;const Z=[...g.branches].some(G=>G.contains(H));return M&&!Z},[g.branches,M])}),D=IL(H=>{if(s&&O.current)return;const Z=H.target;[...g.branches].some(ae=>ae.contains(Z))||(l?.(H),u?.(H),H.defaultPrevented||d?.())},x),F=y?_===C.length-1:!1,te=Xs(H=>{H.key==="Escape"&&(i?.(H),!H.defaultPrevented&&d&&(H.preventDefault(),d()))});return E.useEffect(()=>{if(F)return x.addEventListener("keydown",te,{capture:!0}),()=>x.removeEventListener("keydown",te,{capture:!0})},[x,F,te]),E.useEffect(()=>{if(y)return r&&(g.layersWithOutsidePointerEventsDisabled.size===0&&(QR=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),g.layersWithOutsidePointerEventsDisabled.add(y)),g.layers.add(y),tw(),()=>{r&&(g.layersWithOutsidePointerEventsDisabled.delete(y),g.layersWithOutsidePointerEventsDisabled.size===0&&(x.body.style.pointerEvents=QR))}},[y,x,r,g]),E.useEffect(()=>()=>{y&&(g.layers.delete(y),g.layersWithOutsidePointerEventsDisabled.delete(y),tw())},[y,g]),E.useEffect(()=>{const H=Tn(()=>S({}),"handleUpdate");return document.addEventListener(ew,H),()=>document.removeEventListener(ew,H)},[]),m.jsx(Mn.div,{...h,ref:k,style:{pointerEvents:N?M?"auto":"none":void 0,...e.style},onFocusCapture:bn(e.onFocusCapture,D.onFocusCapture),onBlurCapture:bn(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:bn(e.onPointerDownCapture,P.onPointerDownCapture)})},"DismissableLayer"));function UY(){const t=E.useContext(jL),[e,n]=E.useState(null);return E.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}Tn(UY,"useDismissableLayerSurface");var FY=Tn(()=>!0,"IS_TRUE");function DL(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:i,shouldHandlePointerDownOutside:o=FY}=e,l=Xs(t),u=E.useRef(!1),d=E.useRef(!1),h=E.useRef(new Map),g=E.useRef(()=>{});return E.useEffect(()=>{function y(){d.current=!1,s.current=!1,h.current.clear()}Tn(y,"resetOutsideInteraction");function b(){return Array.from(h.current.values()).some(Boolean)}Tn(b,"isOutsideInteractionIntercepted");function x(R){if(!d.current)return;const _=R.target;_ instanceof Node&&[...i].some(M=>M.contains(_))||h.current.set(R.type,!0),R.type==="click"&&window.setTimeout(()=>{d.current&&g.current()},0)}Tn(x,"handleInteractionCapture");function S(R){d.current&&h.current.set(R.type,!1)}Tn(S,"handleInteractionBubble");const k=Tn(R=>{if(R.target&&!u.current){let _=function(){n.removeEventListener("click",g.current);const M=b();y(),M||ek(BY,l,N,{discrete:!0})};if(Tn(_,"handleAndDispatchPointerDownOutsideEvent"),!o(R.target)){n.removeEventListener("click",g.current),y(),u.current=!1;return}const N={originalEvent:R};d.current=!0,s.current=r&&R.button===0,h.current.clear(),!r||R.button!==0?_():(n.removeEventListener("click",g.current),g.current=_,n.addEventListener("click",g.current,{once:!0}))}else n.removeEventListener("click",g.current),y();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",g.current);for(const R of C)n.removeEventListener(R,x,!0),n.removeEventListener(R,S)}},[n,l,r,s,i,o]),{onPointerDownCapture:Tn(()=>u.current=!0,"onPointerDownCapture")}}Tn(DL,"usePointerDownOutside");function IL(t,e=globalThis?.document){const n=Xs(t),r=E.useRef(!1);return E.useEffect(()=>{const s=Tn(i=>{i.target&&!r.current&&ek(VY,n,{originalEvent:i},{discrete:!1})},"handleFocus");return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,n]),{onFocusCapture:Tn(()=>r.current=!0,"onFocusCapture"),onBlurCapture:Tn(()=>r.current=!1,"onBlurCapture")}}Tn(IL,"useFocusOutside");function tw(){const t=new CustomEvent(ew);document.dispatchEvent(t)}Tn(tw,"dispatchUpdate");function ek(t,e,n,{discrete:r}){const s=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?PO(s,i):s.dispatchEvent(i)}Tn(ek,"handleAndDispatchCustomEvent");var qY=Object.defineProperty,tk=(t,e)=>qY(t,"name",{value:e,configurable:!0}),op=0,ic=null;function GY(t){return nk(),t.children}tk(GY,"FocusGuards");function nk(){E.useEffect(()=>{ic||(ic={start:nw(),end:nw()});const{start:t,end:e}=ic;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),op++,()=>{op===1&&(ic?.start.remove(),ic?.end.remove(),ic=null),op=Math.max(0,op-1)}},[])}tk(nk,"useFocusGuards");function nw(){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}tk(nw,"createFocusGuard");var WY=Object.defineProperty,cr=(t,e)=>WY(t,"name",{value:e,configurable:!0}),u0="focusScope.autoFocusOnMount",d0="focusScope.autoFocusOnUnmount",eN={bubbles:!1,cancelable:!0},KY=E.forwardRef(cr(function(e,n){const{loop:r=!1,trapped:s=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...l}=e,[u,d]=E.useState(null),h=Xs(i),g=Xs(o),y=E.useRef(null),b=dn(n,d),x=E.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;E.useEffect(()=>{if(s){let k=function(_){if(x.paused||!u)return;const N=_.target;u.contains(N)?y.current=N:Ai(y.current,{select:!0})},C=function(_){if(x.paused||!u)return;const N=_.relatedTarget;N!==null&&(u.contains(N)||Ai(y.current,{select:!0}))},A=function(_){if(document.activeElement===document.body)for(const M of _)M.removedNodes.length>0&&Ai(u)};cr(k,"handleFocusIn"),cr(C,"handleFocusOut"),cr(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()}}},[s,u,x.paused]),E.useEffect(()=>{if(u){tN.add(x);const k=document.activeElement;if(!u.contains(k)){const A=new CustomEvent(u0,eN);u.addEventListener(u0,h),u.dispatchEvent(A),A.defaultPrevented||(LL(VL(rk(u)),{select:!0}),document.activeElement===k&&Ai(u))}return()=>{u.removeEventListener(u0,h),setTimeout(()=>{const A=new CustomEvent(d0,eN);u.addEventListener(d0,g),u.dispatchEvent(A),A.defaultPrevented||Ai(k??document.body,{select:!0}),u.removeEventListener(d0,g),tN.remove(x)},0)}}},[u,h,g,x]);const S=E.useCallback(k=>{if(!r&&!s||x.paused)return;const C=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,A=document.activeElement;if(C&&A){const R=k.currentTarget,[_,N]=PL(R);_&&N?!k.shiftKey&&A===N?(k.preventDefault(),r&&Ai(_,{select:!0})):k.shiftKey&&A===_&&(k.preventDefault(),r&&Ai(N,{select:!0})):A===R&&k.preventDefault()}},[r,s,x.paused]);return m.jsx(Mn.div,{tabIndex:-1,...l,ref:b,onKeyDown:S})},"FocusScope"));function LL(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Ai(r,{select:e}),document.activeElement!==n)return}cr(LL,"focusFirst");function PL(t){const e=rk(t),n=rw(e,t),r=rw(e.reverse(),t);return[n,r]}cr(PL,"getTabbableEdges");function rk(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:cr(r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)e.push(n.currentNode);return e}cr(rk,"getTabbableCandidates");function rw(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const r of t)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):zL(r,{upTo:e})))return r}cr(rw,"findVisible");function zL(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}cr(zL,"isHidden");function $L(t){return t instanceof HTMLInputElement&&"select"in t}cr($L,"isSelectableInput");function Ai(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&$L(t)&&e&&t.select()}}cr(Ai,"focus");var tN=BL();function BL(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=sw(t,e),t.unshift(e)},remove(e){t=sw(t,e),t[0]?.resume()}}}cr(BL,"createFocusScopesStack");function sw(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}cr(sw,"arrayRemove");function VL(t){return t.filter(e=>e.tagName!=="A")}cr(VL,"removeLinks");var ZY=Object.defineProperty,YY=(t,e)=>ZY(t,"name",{value:e,configurable:!0}),XY=nf[" useId ".trim().toString()]||(()=>{}),JY=0;function sk(t){const[e,n]=E.useState(XY());return ur(()=>{t||n(r=>r??String(JY++))},[t]),t||(e?`radix-${e}`:"")}YY(sk,"useId");const QY=["top","right","bottom","left"],ra=Math.min,Vi=Math.max,Jm=Math.round,ap=Math.floor,Hi=t=>({x:t,y:t}),eX={left:"right",right:"left",bottom:"top",top:"bottom"};function HL(t,e,n){return Vi(t,ra(e,n))}function Gi(t,e){return typeof t=="function"?t(e):t}function sa(t){return t.split("-")[0]}function Qc(t){return t.split("-")[1]}function ik(t){return t==="x"?"y":"x"}function ok(t){return t==="y"?"height":"width"}function Ws(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function ak(t){return ik(Ws(t))}function tX(t,e,n){n===void 0&&(n=!1);const r=Qc(t),s=ak(t),i=ok(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=Qm(o)),[o,Qm(o)]}function nX(t){const e=Qm(t);return[iw(t),e,iw(e)]}function iw(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const nN=["left","right"],rN=["right","left"],rX=["top","bottom"],sX=["bottom","top"];function iX(t,e,n){switch(t){case"top":case"bottom":return n?e?rN:nN:e?nN:rN;case"left":case"right":return e?rX:sX;default:return[]}}function oX(t,e,n,r){const s=Qc(t);let i=iX(sa(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(iw)))),i}function Qm(t){const e=sa(t);return eX[e]+t.slice(e.length)}function aX(t){var e,n,r,s;return{top:(e=t.top)!=null?e:0,right:(n=t.right)!=null?n:0,bottom:(r=t.bottom)!=null?r:0,left:(s=t.left)!=null?s:0}}function UL(t){return typeof t!="number"?aX(t):{top:t,right:t,bottom:t,left:t}}function eg(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function sN(t,e,n){let{reference:r,floating:s}=t;const i=Ws(e),o=ak(e),l=ok(o),u=sa(e),d=i==="y",h=r.x+r.width/2-s.width/2,g=r.y+r.height/2-s.height/2,y=r[l]/2-s[l]/2;let b;switch(u){case"top":b={x:h,y:r.y-s.height};break;case"bottom":b={x:h,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:g};break;case"left":b={x:r.x-s.width,y:g};break;default:b={x:r.x,y:r.y}}const x=Qc(e);return x&&(b[o]+=y*(x==="end"?1:-1)*(n&&d?-1:1)),b}async function lX(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:u}=t,{boundary:d="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:y=!1,padding:b=0}=Gi(e,t),x=UL(b),k=l[y?g==="floating"?"reference":"floating":g],C=eg(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(k)))==null||n?k:k.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:h,strategy:u})),A=g==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),_=await(i.isElement==null?void 0:i.isElement(R))&&await(i.getScale==null?void 0:i.getScale(R))||{x:1,y:1},N=eg(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:A,offsetParent:R,strategy:u}):A);return{top:(C.top-N.top+x.top)/_.y,bottom:(N.bottom-C.bottom+x.bottom)/_.y,left:(C.left-N.left+x.left)/_.x,right:(N.right-C.right+x.right)/_.x}}const cX=50,uX=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:lX},u=await(o.isRTL==null?void 0:o.isRTL(e));let d=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:h,y:g}=sN(d,r,u),y=r,b=0;const x={};for(let S=0;S<i.length;S++){const k=i[S];if(!k)continue;const{name:C,fn:A}=k,{x:R,y:_,data:N,reset:M}=await A({x:h,y:g,initialPlacement:r,placement:y,strategy:s,middlewareData:x,rects:d,platform:l,elements:{reference:t,floating:e}});h=R??h,g=_??g,x[C]={...x[C],...N},M&&b<cX&&(b++,typeof M=="object"&&(M.placement&&(y=M.placement),M.rects&&(d=M.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):M.rects),{x:h,y:g}=sN(d,y,u)),S=-1)}return{x:h,y:g,placement:y,strategy:s,middlewareData:x}},dX=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:i,platform:o,elements:l,middlewareData:u}=e,{element:d,padding:h=0}=Gi(t,e)||{};if(d==null)return{};const g=UL(h),y={x:n,y:r},b=ak(s),x=ok(b),S=await o.getDimensions(d),k=b==="y",C=k?"top":"left",A=k?"bottom":"right",R=k?"clientHeight":"clientWidth",_=i.reference[x]+i.reference[b]-y[b]-i.floating[x],N=y[b]-i.reference[b],M=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let O=M?M[R]:0;(!O||!await(o.isElement==null?void 0:o.isElement(M)))&&(O=l.floating[R]||i.floating[x]);const P=_/2-N/2,D=O/2-S[x]/2-1,F=ra(g[C],D),te=ra(g[A],D),H=O-S[x]-te,Z=O/2-S[x]/2+P,G=HL(F,Z,H),ae=!u.arrow&&Qc(s)!=null&&Z!==G&&i.reference[x]/2-(Z<F?F:te)-S[x]/2<0,z=ae?Z<F?Z-F:Z-H:0;return{[b]:y[b]+z,data:{[b]:G,centerOffset:Z-G-z,...ae&&{alignmentOffset:z}},reset:ae}}}),fX=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:u,elements:d}=e,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:y,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:S=!0,...k}=Gi(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const C=sa(s),A=Ws(l),R=sa(l)===l,_=await(u.isRTL==null?void 0:u.isRTL(d.floating)),N=y||(R||!S?[Qm(l)]:nX(l)),M=x!=="none";!y&&M&&N.push(...oX(l,S,x,_));const O=[l,...N],P=await u.detectOverflow(e,k),D=[];let F=((r=i.flip)==null?void 0:r.overflows)||[];if(h&&D.push(P[C]),g){const G=tX(s,o,_);D.push(P[G[0]],P[G[1]])}if(F=[...F,{placement:s,overflows:D}],!D.every(G=>G<=0)){var te,H;const G=(((te=i.flip)==null?void 0:te.index)||0)+1,ae=O[G];if(ae&&(!(g==="alignment"?A!==Ws(ae):!1)||F.every(W=>Ws(W.placement)===A?W.overflows[0]>0:!0)))return{data:{index:G,overflows:F},reset:{placement:ae}};let z=(H=F.filter(L=>L.overflows[0]<=0).sort((L,W)=>L.overflows[1]-W.overflows[1])[0])==null?void 0:H.placement;if(!z)switch(b){case"bestFit":{var Z;const L=(Z=F.filter(W=>{if(M){const ce=Ws(W.placement);return ce===A||ce==="y"}return!0}).map(W=>[W.placement,W.overflows.filter(ce=>ce>0).reduce((ce,pe)=>ce+pe,0)]).sort((W,ce)=>W[1]-ce[1])[0])==null?void 0:Z[0];L&&(z=L);break}case"initialPlacement":z=l;break}if(s!==z)return{reset:{placement:z}}}return{}}}};function iN(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function oN(t){return QY.some(e=>t[e]>=0)}const hX=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:s="referenceHidden",...i}=Gi(t,e);switch(s){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),l=iN(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:oN(l)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),l=iN(o,n.floating);return{data:{escapedOffsets:l,escaped:oN(l)}}}default:return{}}}}},FL=new Set(["left","top"]);async function pX(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=sa(n),l=Qc(n),u=Ws(n)==="y",d=FL.has(o)?-1:1,h=i&&u?-1:1,g=Gi(e,t);let{mainAxis:y,crossAxis:b,alignmentAxis:x}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return l&&typeof x=="number"&&(b=l==="end"?x*-1:x),u?{x:b*h,y:y*d}:{x:y*d,y:b*h}}const mX=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,u=await pX(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+u.x,y:i+u.y,data:{...u,placement:o}}}}},gX=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:i}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:u={fn:A=>{let{x:R,y:_}=A;return{x:R,y:_}}},...d}=Gi(t,e),h={x:n,y:r},g=await i.detectOverflow(e,d),y=Ws(s),b=ik(y);let x=h[b],S=h[y];const k=(A,R)=>HL(R+g[A==="y"?"top":"left"],R,R-g[A==="y"?"bottom":"right"]);o&&(x=k(b,x)),l&&(S=k(y,S));const C=u.fn({...e,[b]:x,[y]:S});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[b]:o,[y]:l}}}}}},yX=function(t){return t===void 0&&(t={}),{options:t,fn(e){var n,r;const{x:s,y:i,placement:o,rects:l,middlewareData:u}=e,{offset:d=0,mainAxis:h=!0,crossAxis:g=!0}=Gi(t,e),y={x:s,y:i},b=Ws(o),x=ik(b);let S=y[x],k=y[b];const C=Gi(d,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 N=x==="y"?"height":"width",M=l.reference[x]-l.floating[N]+A.mainAxis,O=l.reference[x]+l.reference[N]-A.mainAxis;S<M?S=M:S>O&&(S=O)}if(g){var R,_;const N=x==="y"?"width":"height",M=FL.has(sa(o)),O=l.reference[b]-l.floating[N]+(M&&((R=u.offset)==null?void 0:R[b])||0)+(M?0:A.crossAxis),P=l.reference[b]+l.reference[N]+(M?0:((_=u.offset)==null?void 0:_[b])||0)-(M?A.crossAxis:0);k<O?k=O:k>P&&(k=P)}return{[x]:S,[b]:k}}}},bX=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:r,platform:s,elements:i}=e,{apply:o=()=>{},...l}=Gi(t,e),u=await s.detectOverflow(e,l),d=sa(n),h=Qc(n),g=Ws(n)==="y",{width:y,height:b}=r.floating;let x,S;d==="top"||d==="bottom"?(x=d,S=h===(await(s.isRTL==null?void 0:s.isRTL(i.floating))?"start":"end")?"left":"right"):(S=d,x=h==="end"?"top":"bottom");const k=b-u.top-u.bottom,C=y-u.left-u.right,A=ra(b-u[x],k),R=ra(y-u[S],C),_=e.middlewareData.shift,N=!_;let M=A,O=R;_!=null&&_.enabled.x&&(O=C),_!=null&&_.enabled.y&&(M=k),N&&!h&&(g?O=y-2*Vi(u.left,u.right):M=b-2*Vi(u.top,u.bottom)),await o({...e,availableWidth:O,availableHeight:M});const P=await s.getDimensions(i.floating);return y!==P.width||b!==P.height?{reset:{rects:!0}}:{}}}};function Lg(){return typeof window<"u"}function eu(t){return qL(t)?(t.nodeName||"").toLowerCase():"#document"}function Er(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Yi(t){var e;return(e=(qL(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function qL(t){return Lg()?t instanceof Node||t instanceof Er(t).Node:!1}function Js(t){return Lg()?t instanceof Element||t instanceof Er(t).Element:!1}function da(t){return Lg()?t instanceof HTMLElement||t instanceof Er(t).HTMLElement:!1}function aN(t){return!Lg()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Er(t).ShadowRoot}function Pg(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=Qs(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&s!=="inline"&&s!=="contents"}function vX(t){return/^(table|td|th)$/.test(eu(t))}function zg(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const xX=/transform|translate|scale|rotate|perspective|filter/,wX=/paint|layout|strict|content/,ja=t=>!!t&&t!=="none";let f0;function lk(t){const e=Js(t)?Qs(t):t;return ja(e.transform)||ja(e.translate)||ja(e.scale)||ja(e.rotate)||ja(e.perspective)||!ck()&&(ja(e.backdropFilter)||ja(e.filter))||xX.test(e.willChange||"")||wX.test(e.contain||"")}function SX(t){let e=ll(t);for(;da(e)&&!Qd(e);){if(lk(e))return e;if(zg(e))return null;e=ll(e)}return null}function ck(){return f0==null&&(f0=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),f0}function Qd(t){return/^(html|body|#document)$/.test(eu(t))}function Qs(t){return Er(t).getComputedStyle(t)}function $g(t){return Js(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ll(t){if(eu(t)==="html")return t;const e=t.assignedSlot||t.parentNode||aN(t)&&t.host||Yi(t);return aN(e)?e.host:e}function GL(t){const e=ll(t);return Qd(e)?(t.ownerDocument||t).body:da(e)&&Pg(e)?e:GL(e)}function ef(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=GL(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=Er(s);if(i){const l=ow(o);return e.concat(o,o.visualViewport||[],Pg(s)?s:[],l&&n?ef(l):[])}else return e.concat(s,ef(s,[],n))}function ow(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function WL(t){const e=Qs(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=da(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=Jm(n)!==i||Jm(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function uk(t){return Js(t)?t:t.contextElement}function Cc(t){const e=uk(t);if(!da(e))return Hi(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=WL(e);let o=(i?Jm(n.width):n.width)/r,l=(i?Jm(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const kX=Hi(0);function KL(t){const e=Er(t);return!ck()||!e.visualViewport?kX:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function CX(t,e,n){return e===void 0&&(e=!1),!!n&&e&&n===Er(t)}function cl(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=uk(t);let o=Hi(1);e&&(r?Js(r)&&(o=Cc(r)):o=Cc(t));const l=CX(i,n,r)?KL(i):Hi(0);let u=(s.left+l.x)/o.x,d=(s.top+l.y)/o.y,h=s.width/o.x,g=s.height/o.y;if(i&&r){const y=Er(i),b=Js(r)?Er(r):r;let x=y,S=ow(x);for(;S&&b!==x;){const k=Cc(S),C=S.getBoundingClientRect(),A=Qs(S),R=C.left+(S.clientLeft+parseFloat(A.paddingLeft))*k.x,_=C.top+(S.clientTop+parseFloat(A.paddingTop))*k.y;u*=k.x,d*=k.y,h*=k.x,g*=k.y,u+=R,d+=_,x=Er(S),S=ow(x)}}return eg({width:h,height:g,x:u,y:d})}function Bg(t,e){const n=$g(t).scrollLeft;return e?e.left+n:cl(Yi(t)).left+n}function ZL(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Bg(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function EX(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=Yi(r),l=e?zg(e.floating):!1;if(r===o||l&&i)return n;let u={scrollLeft:0,scrollTop:0},d=Hi(1);const h=Hi(0),g=da(r);if((g||!i)&&((eu(r)!=="body"||Pg(o))&&(u=$g(r)),g)){const b=cl(r);d=Cc(r),h.x=b.x+r.clientLeft,h.y=b.y+r.clientTop}const y=o&&!g&&!i?ZL(o,u):Hi(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+h.x+y.x,y:n.y*d.y-u.scrollTop*d.y+h.y+y.y}}function TX(t){return t.getClientRects?Array.from(t.getClientRects()):[]}function _X(t){const e=$g(t),n=t.ownerDocument.body,r=Vi(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=Vi(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let i=-e.scrollLeft+Bg(t);const o=-e.scrollTop;return Qs(n).direction==="rtl"&&(i+=Vi(t.clientWidth,n.clientWidth)-r),{width:r,height:s,x:i,y:o}}const AX=25;function RX(t,e,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",s=Er(t),i=Yi(t),o=s.visualViewport;let l=i.clientWidth,u=i.clientHeight,d=0,h=0;if(o){const y=!ck()||e==="fixed";r?y||(d=-o.offsetLeft,h=-o.offsetTop):(l=o.width,u=o.height,y&&(d=o.offsetLeft,h=o.offsetTop))}if(Bg(i)<=0){const y=i.ownerDocument,b=y.body,x=getComputedStyle(b),S=y.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,k=Math.abs(i.clientWidth-b.clientWidth-S),C=getComputedStyle(i).scrollbarGutter==="stable both-edges"?k/2:k;C<=AX&&(l-=C)}return{width:l,height:u,x:d,y:h}}function NX(t,e){const n=cl(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=Cc(t),o=t.clientWidth*i.x,l=t.clientHeight*i.y,u=s*i.x,d=r*i.y;return{width:o,height:l,x:u,y:d}}function lN(t,e,n){let r;if(e==="viewport"||e==="layoutViewport")r=RX(t,n,e);else if(e==="document")r=_X(Yi(t));else if(Js(e))r=NX(e,n);else{const s=KL(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return eg(r)}function MX(t,e){const n=e.get(t);if(n)return n;let r=ef(t,[],!1).filter(l=>Js(l)&&eu(l)!=="body"),s=null;const i=Qs(t).position==="fixed";let o=i?ll(t):t;for(;Js(o)&&!Qd(o);){const l=Qs(o),u=lk(o),d=s?s.position:i?"fixed":"";!u&&(d==="fixed"||d==="absolute"&&l.position==="static")?r=r.filter(g=>g!==o):s=l,o=ll(o)}return e.set(t,r),r}function OX(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?zg(e)?[]:MX(e,this._c):[].concat(n),r],l=lN(e,o[0],s);let u=l.top,d=l.right,h=l.bottom,g=l.left;for(let y=1;y<o.length;y++){const b=lN(e,o[y],s);u=Vi(b.top,u),d=ra(b.right,d),h=ra(b.bottom,h),g=Vi(b.left,g)}return{width:d-g,height:h-u,x:g,y:u}}function jX(t){const{width:e,height:n}=WL(t);return{width:e,height:n}}function DX(t,e,n){const r=da(e),s=Yi(e),i=n==="fixed",o=cl(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const u=Hi(0);if((r||!i)&&((eu(e)!=="body"||Pg(s))&&(l=$g(e)),r)){const y=cl(e,!0,i,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}!r&&s&&(u.x=Bg(s));const d=s&&!r&&!i?ZL(s,l):Hi(0),h=o.left+l.scrollLeft-u.x-d.x,g=o.top+l.scrollTop-u.y-d.y;return{x:h,y:g,width:o.width,height:o.height}}function h0(t){return Qs(t).position==="static"}function cN(t,e){if(!da(t)||Qs(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Yi(t)===n&&(n=n.ownerDocument.body),n}function YL(t,e){const n=Er(t);if(zg(t))return n;if(!da(t)){let s=ll(t);for(;s&&!Qd(s);){if(Js(s)&&!h0(s))return s;s=ll(s)}return n}let r=cN(t,e);for(;r&&vX(r)&&h0(r);)r=cN(r,e);return r&&Qd(r)&&h0(r)&&!lk(r)?n:r||SX(t)||n}const IX=async function(t){const e=this.getOffsetParent||YL,n=this.getDimensions,r=await n(t.floating);return{reference:DX(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function LX(t){return Qs(t).direction==="rtl"}const PX={convertOffsetParentRelativeRectToViewportRelativeRect:EX,getDocumentElement:Yi,getClippingRect:OX,getOffsetParent:YL,getElementRects:IX,getClientRects:TX,getDimensions:jX,getScale:Cc,isElement:Js,isRTL:LX};function XL(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function zX(t,e,n){let r=null,s;const i=Yi(t);function o(){var h;clearTimeout(s),(h=r)==null||h.disconnect(),r=null}function l(h,g){h===void 0&&(h=!1),g===void 0&&(g=1),o();const y=t.getBoundingClientRect(),{left:b,top:x,width:S,height:k}=y;if(h||e(),!S||!k)return;const C=ap(x),A=ap(i.clientWidth-(b+S)),R=ap(i.clientHeight-(x+k)),_=ap(b),M={rootMargin:-C+"px "+-A+"px "+-R+"px "+-_+"px",threshold:Vi(0,ra(1,g))||1};let O=!0;function P(D){const F=D[0].intersectionRatio;if(!XL(y,t.getBoundingClientRect()))return l();if(F!==g){if(!O)return l();F?l(!1,F):s=setTimeout(()=>{l(!1,1e-7)},1e3)}O=!1}try{r=new IntersectionObserver(P,{...M,root:i.ownerDocument})}catch{r=new IntersectionObserver(P,M)}r.observe(t)}const u=Er(t),d=()=>l(n);return u.addEventListener("resize",d),l(!0),()=>{u.removeEventListener("resize",d),o()}}function $X(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=uk(t),h=s||i?[...d?ef(d):[],...e?ef(e):[]]:[];h.forEach(C=>{s&&C.addEventListener("scroll",n),i&&C.addEventListener("resize",n)});const g=d&&l?zX(d,n,i):null;let y=-1,b=null;o&&(b=new ResizeObserver(C=>{let[A]=C;A&&A.target===d&&b&&e&&(b.unobserve(e),cancelAnimationFrame(y),y=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(e)})),n()}),d&&!u&&b.observe(d),e&&b.observe(e));let x,S=u?cl(t):null;u&&k();function k(){const C=cl(t);S&&!XL(S,C)&&n(),S=C,x=requestAnimationFrame(k)}return n(),()=>{var C;h.forEach(A=>{s&&A.removeEventListener("scroll",n),i&&A.removeEventListener("resize",n)}),g?.(),(C=b)==null||C.disconnect(),b=null,u&&cancelAnimationFrame(x)}}const BX=mX,VX=gX,HX=fX,UX=bX,FX=hX,uN=dX,qX=yX,GX=(t,e,n)=>{const r=new Map,s=n??{},i={...PX,...s.platform,_c:r};return uX(t,e,{...s,platform:i})};var WX=typeof document<"u",KX=function(){},Pp=WX?E.useLayoutEffect:KX;function tg(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!tg(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&t.$$typeof)&&!tg(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function JL(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function dN(t,e){const n=JL(t);return Math.round(e*n)/n}function p0(t){const e=E.useRef(t);return Pp(()=>{e.current=t}),e}function ZX(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:u,open:d}=t,[h,g]=E.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[y,b]=E.useState(r);tg(y,r)||b(r);const[x,S]=E.useState(null),[k,C]=E.useState(null),A=E.useCallback(W=>{W!==M.current&&(M.current=W,S(W))},[]),R=E.useCallback(W=>{W!==O.current&&(O.current=W,C(W))},[]),_=i||x,N=o||k,M=E.useRef(null),O=E.useRef(null),P=E.useRef(h),D=u!=null,F=p0(u),te=p0(s),H=p0(d),Z=E.useCallback(()=>{if(!M.current||!O.current)return;const W={placement:e,strategy:n,middleware:y};te.current&&(W.platform=te.current),GX(M.current,O.current,W).then(ce=>{const pe={...ce,isPositioned:H.current!==!1};G.current&&!tg(P.current,pe)&&(P.current=pe,Kc.flushSync(()=>{g(pe)}))})},[y,e,n,te,H]);Pp(()=>{d===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,g(W=>({...W,isPositioned:!1})))},[d]);const G=E.useRef(!1);Pp(()=>(G.current=!0,()=>{G.current=!1}),[]),Pp(()=>{if(_&&(M.current=_),N&&(O.current=N),_&&N){if(F.current)return F.current(_,N,Z);Z()}},[_,N,Z,F,D]);const ae=E.useMemo(()=>({reference:M,floating:O,setReference:A,setFloating:R}),[A,R]),z=E.useMemo(()=>({reference:_,floating:N}),[_,N]),L=E.useMemo(()=>{const W={position:n,left:0,top:0};if(!z.floating)return W;const ce=dN(z.floating,h.x),pe=dN(z.floating,h.y);return l?{...W,transform:"translate("+ce+"px, "+pe+"px)",...JL(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ce,top:pe}},[n,l,z.floating,h.x,h.y]);return E.useMemo(()=>({...h,update:Z,refs:ae,elements:z,floatingStyles:L}),[h,Z,ae,z,L])}const YX=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:s}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?uN({element:r.current,padding:s}).fn(n):{}:r?uN({element:r,padding:s}).fn(n):{}}}},XX=(t,e)=>{const n=BX(t);return{name:n.name,fn:n.fn,options:[t,e]}},JX=(t,e)=>{const n=VX(t);return{name:n.name,fn:n.fn,options:[t,e]}},QX=(t,e)=>({fn:qX(t).fn,options:[t,e]}),eJ=(t,e)=>{const n=HX(t);return{name:n.name,fn:n.fn,options:[t,e]}},tJ=(t,e)=>{const n=UX(t);return{name:n.name,fn:n.fn,options:[t,e]}},nJ=(t,e)=>{const n=FX(t);return{name:n.name,fn:n.fn,options:[t,e]}},rJ=(t,e)=>{const n=YX(t);return{name:n.name,fn:n.fn,options:[t,e]}};var sJ=Object.defineProperty,Yo=(t,e)=>sJ(t,"name",{value:e,configurable:!0}),QL="Popper",[e2,t2]=Yc(QL),[iJ,n2]=e2(QL),oJ=Yo(t=>{const{__scopePopper:e,children:n}=t,[r,s]=E.useState(null),[i,o]=E.useState(void 0);return m.jsx(iJ,{scope:e,anchor:r,onAnchorChange:s,placementState:i,setPlacementState:o,children:n})},"Popper"),aJ="PopperAnchor",lJ=E.forwardRef(Yo(function(e,n){const{__scopePopper:r,virtualRef:s,...i}=e,o=n2(aJ,r),l=E.useRef(null),u=o.onAnchorChange,d=E.useCallback(S=>{l.current=S,S&&u(S)},[u]),h=dn(n,d),g=E.useRef(null);E.useEffect(()=>{if(!s)return;const S=g.current;g.current=s.current,S!==g.current&&u(g.current)});const y=o.placementState&&Vg(o.placementState),b=y?.[0],x=y?.[1];return s?null:m.jsx(Mn.div,{"data-radix-popper-side":b,"data-radix-popper-align":x,...i,ref:h})},"PopperAnchor")),r2="PopperContent",[cJ,rre]=e2(r2),uJ=E.forwardRef(Yo(function(e,n){const{__scopePopper:r,side:s="bottom",sideOffset:i=0,align:o="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:g=0,sticky:y="partial",hideWhenDetached:b=!1,updatePositionStrategy:x="optimized",onPlaced:S,...k}=e,C=n2(r2,r),[A,R]=E.useState(null),_=dn(n,R),[N,M]=E.useState(null),O=Kw(N),P=O?.width??0,D=O?.height??0,F=s+(o!=="center"?"-"+o:""),te=typeof g=="number"?g:{top:0,right:0,bottom:0,left:0,...g},H=Array.isArray(h)?h:[h],Z=H.length>0,G={padding:te,boundary:H.filter(s2),altBoundary:Z},{refs:ae,floatingStyles:z,placement:L,isPositioned:W,middlewareData:ce}=ZX({strategy:"fixed",placement:F,whileElementsMounted:Yo((...le)=>$X(...le,{animationFrame:x==="always"}),"whileElementsMounted"),elements:{reference:C.anchor},middleware:[XX({mainAxis:i+D,alignmentAxis:l}),d&&JX({mainAxis:!0,crossAxis:!1,limiter:y==="partial"?QX():void 0,...G}),d&&eJ({...G}),tJ({...G,apply:Yo(({elements:le,rects:me,availableWidth:De,availableHeight:Be})=>{const{width:Ke,height:mt}=me.reference,ht=le.floating.style;ht.setProperty("--radix-popper-available-width",`${De}px`),ht.setProperty("--radix-popper-available-height",`${Be}px`),ht.setProperty("--radix-popper-anchor-width",`${Ke}px`),ht.setProperty("--radix-popper-anchor-height",`${mt}px`)},"apply")}),N&&rJ({element:N,padding:u}),dJ({arrowWidth:P,arrowHeight:D}),b&&nJ({strategy:"referenceHidden",...G,boundary:Z?G.boundary:void 0})]}),pe=C.setPlacementState;ur(()=>(pe(L),()=>{pe(void 0)}),[L,pe]);const[$,Y]=Vg(L),he=Xs(S);ur(()=>{W&&he?.()},[W,he]);const be=ce.arrow?.x,Me=ce.arrow?.y,Ce=ce.arrow?.centerOffset!==0,[He,Ee]=E.useState();return ur(()=>{A&&Ee(window.getComputedStyle(A).zIndex)},[A]),m.jsx("div",{ref:ae.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:W?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:He,"--radix-popper-transform-origin":[ce.transformOrigin?.x,ce.transformOrigin?.y].join(" "),...ce.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(cJ,{scope:r,placedSide:$,placedAlign:Y,onArrowChange:M,arrowX:be,arrowY:Me,shouldHideArrow:Ce,children:m.jsx(Mn.div,{"data-side":$,"data-align":Y,...k,ref:_,style:{...k.style,animation:W?k.style?.animation:"none"}})})})},"PopperContent"));function s2(t){return t!==null}Yo(s2,"isNotNull");var dJ=Yo(t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:s}=e,o=s.arrow?.centerOffset!==0,l=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[d,h]=Vg(n),g={start:"0%",center:"50%",end:"100%"}[h],y=(s.arrow?.x??0)+l/2,b=(s.arrow?.y??0)+u/2;let x="",S="";return d==="bottom"?(x=o?g:`${y}px`,S=`${-u}px`):d==="top"?(x=o?g:`${y}px`,S=`${r.floating.height+u}px`):d==="right"?(x=`${-u}px`,S=o?g:`${b}px`):d==="left"&&(x=`${r.floating.width+u}px`,S=o?g:`${b}px`),{data:{x,y:S}}}}),"transformOrigin");function Vg(t){const[e,n="center"]=t.split("-");return[e,n]}Yo(Vg,"getSideAndAlignFromPlacement");var fJ=oJ,hJ=lJ,pJ=uJ,mJ=Object.defineProperty,gJ=(t,e)=>mJ(t,"name",{value:e,configurable:!0}),yJ=E.forwardRef(gJ(function(e,n){const{container:r,...s}=e,[i,o]=E.useState(!1);ur(()=>o(!0),[]);const l=r||i&&globalThis?.document?.body;return l?Kc.createPortal(m.jsx(Mn.div,{...s,ref:n}),l):null},"Portal")),bJ=Object.defineProperty,Wi=(t,e)=>bJ(t,"name",{value:e,configurable:!0});function i2(t,e){return E.useReducer((n,r)=>e[n][r]??n,t)}Wi(i2,"useStateMachine");var vJ=Wi(t=>{const{present:e,children:n}=t,r=o2(e),s=typeof n=="function"?n({present:r.isPresent}):E.Children.only(n),i=a2(r.ref,l2(s));return typeof n=="function"||r.isPresent?E.cloneElement(s,{ref:i}):null},"Presence");function o2(t){const[e,n]=E.useState(),r=E.useRef(null),s=E.useRef(t),i=E.useRef("none"),o=E.useRef(void 0),l=t?"mounted":"unmounted",[u,d]=i2(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return E.useEffect(()=>{u==="mounted"?(i.current=o.current??yc(r.current),o.current=void 0):i.current="none"},[u]),ur(()=>{const h=r.current,g=s.current;if(g!==t){const b=i.current,x=yc(h);t?(o.current=x,d("MOUNT")):x==="none"||h?.display==="none"?d("UNMOUNT"):d(g&&b!==x?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,d]),ur(()=>{if(e){let h;const g=e.ownerDocument.defaultView??window,y=Wi(x=>{const k=yc(r.current).includes(CSS.escape(x.animationName));if(x.target===e&&k&&(d("ANIMATION_END"),!s.current)){const C=e.style.animationFillMode;e.style.animationFillMode="forwards",h=g.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=C)})}},"handleAnimationEnd"),b=Wi(x=>{x.target===e&&(i.current=yc(r.current))},"handleAnimationStart");return e.addEventListener("animationstart",b),e.addEventListener("animationcancel",y),e.addEventListener("animationend",y),()=>{g.clearTimeout(h),e.removeEventListener("animationstart",b),e.removeEventListener("animationcancel",y),e.removeEventListener("animationend",y)}}else d("ANIMATION_END")},[e,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:E.useCallback(h=>{if(h){const g=getComputedStyle(h);r.current=g,o.current=yc(g)}else r.current=null;n(h)},[])}}Wi(o2,"usePresence");function aw(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Wi(aw,"setRef");function a2(...t){const e=E.useRef(t);return e.current=t,E.useCallback(n=>{const r=e.current;let s=!1;const i=r.map(o=>{const l=aw(o,n);return!s&&typeof l=="function"&&(s=!0),l});if(s)return()=>{for(let o=0;o<i.length;o++){const l=i[o];typeof l=="function"?l():aw(r[o],null)}}},[])}Wi(a2,"useStableComposedRefs");function yc(t){return t?.animationName||"none"}Wi(yc,"getAnimationName");function l2(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)}Wi(l2,"getElementRef");var xJ=Object.defineProperty,wJ=(t,e)=>xJ(t,"name",{value:e,configurable:!0});function c2(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])}wJ(c2,"usePrevious");var SJ=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"}),kJ=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},oc=new WeakMap,lp=new WeakMap,cp={},m0=0,u2=function(t){return t&&(t.host||u2(t.parentNode))},CJ=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=u2(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})},EJ=function(t,e,n,r){var s=CJ(e,Array.isArray(t)?t:[t]);cp[n]||(cp[n]=new WeakMap);var i=cp[n],o=[],l=new Set,u=new Set(s),d=function(g){!g||l.has(g)||(l.add(g),d(g.parentNode))};s.forEach(d);var h=function(g){!g||u.has(g)||Array.prototype.forEach.call(g.children,function(y){if(l.has(y))h(y);else try{var b=y.getAttribute(r),x=b!==null&&b!=="false",S=(oc.get(y)||0)+1,k=(i.get(y)||0)+1;oc.set(y,S),i.set(y,k),o.push(y),S===1&&x&&lp.set(y,!0),k===1&&y.setAttribute(n,"true"),x||y.setAttribute(r,"true")}catch(C){console.error("aria-hidden: cannot operate on ",y,C)}})};return h(e),l.clear(),m0++,function(){o.forEach(function(g){var y=oc.get(g)-1,b=i.get(g)-1;oc.set(g,y),i.set(g,b),y||(lp.has(g)||g.removeAttribute(r),lp.delete(g)),b||g.removeAttribute(n)}),m0--,m0||(oc=new WeakMap,oc=new WeakMap,lp=new WeakMap,cp={})}},TJ=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),s=kJ(t);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),EJ(r,s,n,"aria-hidden")):function(){return null}},Gs=function(){return Gs=Object.assign||function(e){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Gs.apply(this,arguments)};function d2(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 s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}function _J(t,e,n){if(n||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}var zp="right-scroll-bar-position",$p="width-before-scroll-bar",AJ="with-scroll-bars-hidden",RJ="--removed-body-scroll-bar-size";function g0(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function NJ(t,e){var n=E.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=e,n.facade}var MJ=typeof window<"u"?E.useLayoutEffect:E.useEffect,fN=new WeakMap;function OJ(t,e){var n=NJ(null,function(r){return t.forEach(function(s){return g0(s,r)})});return MJ(function(){var r=fN.get(n);if(r){var s=new Set(r),i=new Set(t),o=n.current;s.forEach(function(l){i.has(l)||g0(l,null)}),i.forEach(function(l){s.has(l)||g0(l,o)})}fN.set(n,t)},[t]),n}function jJ(t){return t}function DJ(t,e){e===void 0&&(e=jJ);var n=[],r=!1,s={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(i){var o=e(i,r);return n.push(o),function(){n=n.filter(function(l){return l!==o})}},assignSyncMedium:function(i){for(r=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var o=[];if(n.length){var l=n;n=[],l.forEach(i),o=n}var u=function(){var h=o;o=[],h.forEach(i)},d=function(){return Promise.resolve().then(u)};d(),n={push:function(h){o.push(h),d()},filter:function(h){return o=o.filter(h),n}}}};return s}function IJ(t){t===void 0&&(t={});var e=DJ(null);return e.options=Gs({async:!0,ssr:!1},t),e}var f2=function(t){var e=t.sideCar,n=d2(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,Gs({},n))};f2.isSideCarExport=!0;function LJ(t,e){return t.useMedium(e),f2}var h2=IJ(),y0=function(){},Hg=E.forwardRef(function(t,e){var n=E.useRef(null),r=E.useState({onScrollCapture:y0,onWheelCapture:y0,onTouchMoveCapture:y0}),s=r[0],i=r[1],o=t.forwardProps,l=t.children,u=t.className,d=t.removeScrollBar,h=t.enabled,g=t.shards,y=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,_=d2(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=y,M=OJ([n,e]),O=Gs(Gs({},_),s);return E.createElement(E.Fragment,null,h&&E.createElement(N,{sideCar:h2,removeScrollBar:d,shards:g,noRelative:b,noIsolation:x,inert:S,setCallbacks:i,allowPinchZoom:!!k,lockRef:n,gapMode:R}),o?E.cloneElement(E.Children.only(l),Gs(Gs({},O),{ref:M})):E.createElement(A,Gs({},O,{className:u,ref:M}),l))});Hg.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Hg.classNames={fullWidth:$p,zeroRight:zp};var PJ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function zJ(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=PJ();return e&&t.setAttribute("nonce",e),t}function $J(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function BJ(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var VJ=function(){var t=0,e=null;return{add:function(n){t==0&&(e=zJ())&&($J(e,n),BJ(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},HJ=function(){var t=VJ();return function(e,n){E.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},p2=function(){var t=HJ(),e=function(n){var r=n.styles,s=n.dynamic;return t(r,s),null};return e},UJ={left:0,top:0,right:0,gap:0},b0=function(t){return parseInt(t||"",10)||0},FJ=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],s=e[t==="padding"?"paddingRight":"marginRight"];return[b0(n),b0(r),b0(s)]},qJ=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return UJ;var e=FJ(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])}},GJ=p2(),Ec="data-scroll-locked",WJ=function(t,e,n,r){var s=t.left,i=t.top,o=t.right,l=t.gap;return n===void 0&&(n="margin"),`
|
|
287
|
+
.`.concat(AJ,` {
|
|
288
|
+
overflow: hidden `).concat(r,`;
|
|
289
|
+
padding-right: `).concat(l,"px ").concat(r,`;
|
|
290
|
+
}
|
|
291
|
+
body[`).concat(Ec,`] {
|
|
292
|
+
overflow: hidden `).concat(r,`;
|
|
293
|
+
overscroll-behavior: contain;
|
|
294
|
+
`).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
295
|
+
padding-left: `.concat(s,`px;
|
|
296
|
+
padding-top: `).concat(i,`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(zp,` {
|
|
305
|
+
right: `).concat(l,"px ").concat(r,`;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.`).concat($p,` {
|
|
309
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.`).concat(zp," .").concat(zp,` {
|
|
313
|
+
right: 0 `).concat(r,`;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.`).concat($p," .").concat($p,` {
|
|
317
|
+
margin-right: 0 `).concat(r,`;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
body[`).concat(Ec,`] {
|
|
321
|
+
`).concat(RJ,": ").concat(l,`px;
|
|
322
|
+
}
|
|
323
|
+
`)},hN=function(){var t=parseInt(document.body.getAttribute(Ec)||"0",10);return isFinite(t)?t:0},KJ=function(){E.useEffect(function(){return document.body.setAttribute(Ec,(hN()+1).toString()),function(){var t=hN()-1;t<=0?document.body.removeAttribute(Ec):document.body.setAttribute(Ec,t.toString())}},[])},ZJ=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,s=r===void 0?"margin":r;KJ();var i=E.useMemo(function(){return qJ(s)},[s]);return E.createElement(GJ,{styles:WJ(i,!e,s,n?"":"!important")})},lw=!1;if(typeof window<"u")try{var up=Object.defineProperty({},"passive",{get:function(){return lw=!0,!0}});window.addEventListener("test",up,up),window.removeEventListener("test",up,up)}catch{lw=!1}var ac=lw?{passive:!1}:!1,YJ=function(t){return t.tagName==="TEXTAREA"},m2=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!YJ(t)&&n[e]==="visible")},XJ=function(t){return m2(t,"overflowY")},JJ=function(t){return m2(t,"overflowX")},pN=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=g2(t,r);if(s){var i=y2(t,r),o=i[1],l=i[2];if(o>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},QJ=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},eQ=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},g2=function(t,e){return t==="v"?XJ(e):JJ(e)},y2=function(t,e){return t==="v"?QJ(e):eQ(e)},tQ=function(t,e){return t==="h"&&e==="rtl"?-1:1},nQ=function(t,e,n,r,s){var i=tQ(t,window.getComputedStyle(e).direction),o=i*r,l=n.target,u=e.contains(l),d=!1,h=o>0,g=0,y=0;do{if(!l)break;var b=y2(t,l),x=b[0],S=b[1],k=b[2],C=S-k-i*x;(x||C)&&g2(t,l)&&(g+=C,y+=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(g)<1||!h&&Math.abs(y)<1)&&(d=!0),d},dp=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},mN=function(t){return[t.deltaX,t.deltaY]},gN=function(t){return t&&"current"in t?t.current:t},rQ=function(t,e){return t[0]===e[0]&&t[1]===e[1]},sQ=function(t){return`
|
|
324
|
+
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
325
|
+
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
326
|
+
`)},iQ=0,lc=[];function oQ(t){var e=E.useRef([]),n=E.useRef([0,0]),r=E.useRef(),s=E.useState(iQ++)[0],i=E.useState(p2)[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(s));var S=_J([t.lockRef.current],(t.shards||[]).map(gN),!0).filter(Boolean);return S.forEach(function(k){return k.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),S.forEach(function(k){return k.classList.remove("allow-interactivity-".concat(s))})}}},[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=dp(S),A=n.current,R="deltaX"in S?S.deltaX:A[0]-C[0],_="deltaY"in S?S.deltaY:A[1]-C[1],N,M=S.target,O=Math.abs(R)>Math.abs(_)?"h":"v";if("touches"in S&&O==="h"&&M.type==="range")return!1;var P=window.getSelection(),D=P&&P.anchorNode,F=D?D===M||D.contains(M):!1;if(F)return!1;var te=pN(O,M);if(!te)return!0;if(te?N=O:(N=O==="v"?"h":"v",te=pN(O,M)),!te)return!1;if(!r.current&&"changedTouches"in S&&(R||_)&&(r.current=N),!N)return!0;var H=r.current||N;return nQ(H,k,S,H==="h"?R:_)},[]),u=E.useCallback(function(S){var k=S;if(!(!lc.length||lc[lc.length-1]!==i)){var C="deltaY"in k?mN(k):dp(k),A=e.current.filter(function(N){return N.name===k.type&&(N.target===k.target||k.target===N.shadowParent)&&rQ(N.delta,C)})[0];if(A&&A.should){k.cancelable&&k.preventDefault();return}if(!A){var R=(o.current.shards||[]).map(gN).filter(Boolean).filter(function(N){return N.contains(k.target)}),_=R.length>0?l(k,R[0]):!o.current.noIsolation;_&&k.cancelable&&k.preventDefault()}}},[]),d=E.useCallback(function(S,k,C,A){var R={name:S,delta:k,target:C,should:A,shadowParent:aQ(C)};e.current.push(R),setTimeout(function(){e.current=e.current.filter(function(_){return _!==R})},1)},[]),h=E.useCallback(function(S){n.current=dp(S),r.current=void 0},[]),g=E.useCallback(function(S){d(S.type,mN(S),S.target,l(S,t.lockRef.current))},[]),y=E.useCallback(function(S){d(S.type,dp(S),S.target,l(S,t.lockRef.current))},[]);E.useEffect(function(){return lc.push(i),t.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:y}),document.addEventListener("wheel",u,ac),document.addEventListener("touchmove",u,ac),document.addEventListener("touchstart",h,ac),function(){lc=lc.filter(function(S){return S!==i}),document.removeEventListener("wheel",u,ac),document.removeEventListener("touchmove",u,ac),document.removeEventListener("touchstart",h,ac)}},[]);var b=t.removeScrollBar,x=t.inert;return E.createElement(E.Fragment,null,x?E.createElement(i,{styles:sQ(s)}):null,b?E.createElement(ZJ,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function aQ(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const lQ=LJ(h2,oQ);var b2=E.forwardRef(function(t,e){return E.createElement(Hg,Gs({},t,{ref:e,sideCar:lQ}))});b2.classNames=Hg.classNames;var cQ=Object.defineProperty,jt=(t,e)=>cQ(t,"name",{value:e,configurable:!0}),uQ=[" ","Enter","ArrowUp","ArrowDown"],dQ=[" ","Enter"],Uc="Select",[Ug,dk,fQ]=_L(Uc),[bl,sre]=Yc(Uc,[fQ,t2]),fk=t2(),[hQ,fa]=bl(Uc),[pQ,mQ]=bl(Uc);function v2(t){const{__scopeSelect:e,children:n,open:r,defaultOpen:s,onOpenChange:i,value:o,defaultValue:l,onValueChange:u,dir:d,name:h,autoComplete:g,disabled:y,required:b,form:x,internal_do_not_use_render:S}=t,k=fk(e),[C,A]=E.useState(null),[R,_]=E.useState(null),[N,M]=E.useState(!1),O=OL(d),[P,D]=sm({prop:r,defaultProp:s??!1,onChange:i,caller:Uc}),[F,te]=sm({prop:o,defaultProp:l,onChange:u,caller:Uc}),H=E.useRef(null),Z=E.useRef(F);E.useEffect(()=>{const Y=x?C?.ownerDocument.getElementById(x):C?.form;if(Y instanceof HTMLFormElement){const he=jt(()=>te(Z.current),"reset");return Y.addEventListener("reset",he),()=>Y.removeEventListener("reset",he)}},[x,C,te]);const G=C?!!x||!!C.closest("form"):!0,[ae,z]=E.useState(new Set),L=sk(),W=Array.from(ae).map(Y=>Y.props.value).join(";"),ce=E.useCallback(Y=>{z(he=>new Set(he).add(Y))},[]),pe=E.useCallback(Y=>{z(he=>{const be=new Set(he);return be.delete(Y),be})},[]),$={required:b,trigger:C,onTriggerChange:A,valueNode:R,onValueNodeChange:_,valueNodeHasChildren:N,onValueNodeHasChildrenChange:M,contentId:L,value:F,onValueChange:te,open:P,onOpenChange:D,dir:O,triggerPointerDownPosRef:H,disabled:y,name:h,autoComplete:g,form:x,nativeOptions:ae,nativeSelectKey:W,isFormControl:G};return m.jsx(fJ,{...k,children:m.jsx(hQ,{scope:e,...$,children:m.jsx(Ug.Provider,{scope:e,children:m.jsx(pQ,{scope:e,onNativeOptionAdd:ce,onNativeOptionRemove:pe,children:S2(S)?S($):n})})})})}jt(v2,"SelectProvider");var Fg=jt(t=>{const{__scopeSelect:e,children:n,...r}=t;return m.jsx(v2,{__scopeSelect:e,...r,internal_do_not_use_render:({isFormControl:s})=>m.jsxs(m.Fragment,{children:[n,s?m.jsx(MQ,{__scopeSelect:e}):null]})})},"Select"),gQ="SelectTrigger",qg=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,disabled:s=!1,...i}=e,o=fk(r),l=fa(gQ,r),u=l.disabled||s,d=dn(n,l.onTriggerChange),h=dk(r),g=E.useRef("touch"),[y,b,x]=hk(k=>{const C=h().filter(_=>!_.disabled),A=C.find(_=>_.value===l.value),R=pk(C,k,A);R!==void 0&&l.onValueChange(R.value)}),S=jt(k=>{u||(l.onOpenChange(!0),x()),k&&(l.triggerPointerDownPosRef.current={x:Math.round(k.pageX),y:Math.round(k.pageY)})},"handleOpen");return m.jsx(hJ,{asChild:!0,...o,children:m.jsx(Mn.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":Sf(l.value)?"":void 0,...i,ref:d,onClick:bn(i.onClick,k=>{k.currentTarget.focus(),g.current!=="mouse"&&S(k)}),onPointerDown:bn(i.onPointerDown,k=>{g.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:bn(i.onKeyDown,k=>{const C=y.current!=="";!(k.ctrlKey||k.altKey||k.metaKey)&&k.key.length===1&&b(k.key),!(C&&k.key===" ")&&uQ.includes(k.key)&&(S(),k.preventDefault())})})})},"SelectTrigger")),yQ="SelectValue",Gg=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,className:s,style:i,children:o,placeholder:l="",...u}=e,d=fa(yQ,r),{onValueNodeHasChildrenChange:h}=d,g=o!==void 0,y=dn(n,d.onValueNodeChange);ur(()=>{h(g)},[h,g]);const b=Sf(d.value);return m.jsx(Mn.span,{...u,asChild:b?!1:u.asChild,ref:y,style:{pointerEvents:"none"},children:m.jsx(E.Fragment,{children:b?l:o},b?"placeholder":"value")})},"SelectValue")),Wg=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,children:s,...i}=e;return m.jsx(Mn.span,{"aria-hidden":!0,...i,ref:n,children:s||"▼"})},"SelectIcon")),bQ="SelectPortal",[vQ,xQ]=bl(bQ,{forceMount:void 0}),Kg=jt(t=>{const{__scopeSelect:e,forceMount:n,...r}=t;return m.jsx(vQ,{scope:t.__scopeSelect,forceMount:n,children:m.jsx(yJ,{asChild:!0,...r})})},"SelectPortal"),ul="SelectContent",Zg=E.forwardRef(jt(function(e,n){const r=xQ(ul,e.__scopeSelect),{forceMount:s=r.forceMount,...i}=e,o=fa(ul,e.__scopeSelect),[l,u]=E.useState();return ur(()=>{u(new DocumentFragment)},[]),m.jsx(vJ,{present:s||o.open,children:({present:d})=>d?m.jsx(kQ,{...i,ref:n}):m.jsx(wQ,{...i,fragment:l})})},"SelectContent")),wQ=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,children:s,fragment:i}=e;return i?Kc.createPortal(m.jsx(x2,{scope:r,children:m.jsx(Ug.Slot,{scope:r,children:m.jsx("div",{ref:n,children:s})})}),i):null},"SelectContentFragment")),xs=10,[x2,Yg]=bl(ul),SQ=el("SelectContent.RemoveScroll"),kQ=E.forwardRef(jt(function(e,n){const{__scopeSelect:r}=e,{position:s="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:l,side:u,sideOffset:d,align:h,alignOffset:g,arrowPadding:y,collisionBoundary:b,collisionPadding:x,sticky:S,hideWhenDetached:k,avoidCollisions:C,...A}=e,R=fa(ul,r),[_,N]=E.useState(null),[M,O]=E.useState(null),P=dn(n,N),[D,F]=E.useState(null),[te,H]=E.useState(null),Z=dk(r),[G,ae]=E.useState(!1),z=E.useRef(!1);E.useEffect(()=>{if(_)return TJ(_)},[_]),nk();const L=E.useCallback(Ee=>{const[le,...me]=Z().map(Ke=>Ke.ref.current),[De]=me.slice(-1),Be=document.activeElement;for(const Ke of Ee)if(Ke===Be||(Ke?.scrollIntoView({block:"nearest"}),Ke===le&&M&&(M.scrollTop=0),Ke===De&&M&&(M.scrollTop=M.scrollHeight),Ke?.focus(),document.activeElement!==Be))return},[Z,M]),W=E.useCallback(()=>L([D,_]),[L,D,_]);E.useEffect(()=>{G&&W()},[G,W]);const{onOpenChange:ce,triggerPointerDownPosRef:pe}=R;E.useEffect(()=>{if(_){let Ee={x:0,y:0};const le=jt(De=>{Ee={x:Math.abs(Math.round(De.pageX)-(pe.current?.x??0)),y:Math.abs(Math.round(De.pageY)-(pe.current?.y??0))}},"handlePointerMove"),me=jt(De=>{Ee.x<=10&&Ee.y<=10?De.preventDefault():De.composedPath().includes(_)||ce(!1),document.removeEventListener("pointermove",le),pe.current=null},"handlePointerUp");return pe.current!==null&&(document.addEventListener("pointermove",le),document.addEventListener("pointerup",me,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",le),document.removeEventListener("pointerup",me,{capture:!0})}}},[_,ce,pe]),E.useEffect(()=>{const Ee=jt(()=>ce(!1),"close");return window.addEventListener("blur",Ee),window.addEventListener("resize",Ee),()=>{window.removeEventListener("blur",Ee),window.removeEventListener("resize",Ee)}},[ce]);const[$,Y]=hk(Ee=>{const le=Z().filter(Be=>!Be.disabled),me=le.find(Be=>Be.ref.current===document.activeElement),De=pk(le,Ee,me);De&&setTimeout(()=>De.ref.current?.focus())}),he=E.useCallback((Ee,le,me)=>{const De=!z.current&&!me;(R.value!==void 0&&R.value===le||De)&&(F(Ee),De&&(z.current=!0))},[R.value]),be=E.useCallback(()=>_?.focus(),[_]),Me=E.useCallback((Ee,le,me)=>{const De=!z.current&&!me;(R.value!==void 0&&R.value===le||De)&&H(Ee)},[R.value]),Ce=s==="popper"?yN:CQ,He=Ce===yN?{side:u,sideOffset:d,align:h,alignOffset:g,arrowPadding:y,collisionBoundary:b,collisionPadding:x,sticky:S,hideWhenDetached:k,avoidCollisions:C}:{};return m.jsx(x2,{scope:r,content:_,viewport:M,onViewportChange:O,itemRefCallback:he,selectedItem:D,onItemLeave:be,itemTextRefCallback:Me,focusSelectedItem:W,selectedItemText:te,position:s,isPositioned:G,searchRef:$,children:m.jsx(b2,{as:SQ,allowPinchZoom:!0,children:m.jsx(KY,{asChild:!0,trapped:R.open,onMountAutoFocus:Ee=>{Ee.preventDefault()},onUnmountAutoFocus:bn(i,Ee=>{R.trigger?.focus({preventScroll:!0}),Ee.preventDefault()}),children:m.jsx(HY,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Ee=>Ee.preventDefault(),onDismiss:()=>R.onOpenChange(!1),children:m.jsx(Ce,{role:"listbox",id:R.contentId,"data-state":R.open?"open":"closed",dir:R.dir,onContextMenu:Ee=>Ee.preventDefault(),...A,...He,onPlaced:()=>ae(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...A.style},onKeyDown:bn(A.onKeyDown,Ee=>{const le=Ee.ctrlKey||Ee.altKey||Ee.metaKey;if(Ee.key==="Tab"&&Ee.preventDefault(),!le&&Ee.key.length===1&&Y(Ee.key),["ArrowUp","ArrowDown","Home","End"].includes(Ee.key)){let De=Z().filter(Be=>!Be.disabled).map(Be=>Be.ref.current);if(["ArrowUp","End"].includes(Ee.key)&&(De=De.slice().reverse()),["ArrowUp","ArrowDown"].includes(Ee.key)){const Be=Ee.target,Ke=De.indexOf(Be);De=De.slice(Ke+1)}setTimeout(()=>L(De)),Ee.preventDefault()}})})})})})})},"SelectContentImpl")),CQ=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,onPlaced:s,...i}=e,o=fa(ul,r),l=Yg(ul,r),[u,d]=E.useState(null),[h,g]=E.useState(null),y=dn(n,g),b=dk(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 P=o.trigger.getBoundingClientRect(),D=h.getBoundingClientRect(),F=o.valueNode.getBoundingClientRect(),te=A.getBoundingClientRect();if(o.dir!=="rtl"){const Be=te.left-D.left,Ke=F.left-Be,mt=P.left-Ke,ht=P.width+mt,Wt=Math.max(ht,D.width),Vt=window.innerWidth-xs,Yt=Jx(Ke,[xs,Math.max(xs,Vt-Wt)]);u.style.minWidth=ht+"px",u.style.left=Yt+"px"}else{const Be=D.right-te.right,Ke=window.innerWidth-F.right-Be,mt=window.innerWidth-P.right-Ke,ht=P.width+mt,Wt=Math.max(ht,D.width),Vt=window.innerWidth-xs,Yt=Jx(Ke,[xs,Math.max(xs,Vt-Wt)]);u.style.minWidth=ht+"px",u.style.right=Yt+"px"}const H=b(),Z=window.innerHeight-xs*2,G=k.scrollHeight,ae=window.getComputedStyle(h),z=parseInt(ae.borderTopWidth,10),L=parseInt(ae.paddingTop,10),W=parseInt(ae.borderBottomWidth,10),ce=parseInt(ae.paddingBottom,10),pe=z+L+G+ce+W,$=Math.min(C.offsetHeight*5,pe),Y=window.getComputedStyle(k),he=parseInt(Y.paddingTop,10),be=parseInt(Y.paddingBottom,10),Me=P.top+P.height/2-xs,Ce=Z-Me,He=C.offsetHeight/2,Ee=C.offsetTop+He,le=z+L+Ee,me=pe-le;if(le<=Me){const Be=H.length>0&&C===H[H.length-1].ref.current;u.style.bottom="0px";const Ke=h.clientHeight-k.offsetTop-k.offsetHeight,mt=Math.max(Ce,He+(Be?be:0)+Ke+W),ht=le+mt;u.style.height=ht+"px"}else{const Be=H.length>0&&C===H[0].ref.current;u.style.top="0px";const mt=Math.max(Me,z+k.offsetTop+(Be?he:0)+He)+me;u.style.height=mt+"px",k.scrollTop=le-Me+k.offsetTop}u.style.margin=`${xs}px 0`,u.style.minHeight=$+"px",u.style.maxHeight=Z+"px",s?.(),requestAnimationFrame(()=>x.current=!0)}},[b,o.trigger,o.valueNode,u,h,k,C,A,o.dir,s]);ur(()=>_(),[_]);const[N,M]=E.useState();ur(()=>{h&&M(window.getComputedStyle(h).zIndex)},[h]);const O=E.useCallback(P=>{P&&S.current===!0&&(_(),R?.(),S.current=!1)},[_,R]);return m.jsx(EQ,{scope:r,contentWrapper:u,shouldExpandOnScrollRef:x,onScrollButtonChange:O,children:m.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:N},children:m.jsx(Mn.div,{...i,ref:y,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})},"SelectItemAlignedPosition")),yN=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,align:s="start",collisionPadding:i=xs,...o}=e,l=fk(r);return m.jsx(pJ,{...l,...o,ref:n,align:s,collisionPadding:i,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")),[EQ,TQ]=bl(ul,{}),bN="SelectViewport",Xg=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,nonce:s,...i}=e,o=Yg(bN,r),l=TQ(bN,r),u=dn(n,o.onViewportChange),d=E.useRef(0);return m.jsxs(m.Fragment,{children:[m.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:s}),m.jsx(Ug.Slot,{scope:r,children:m.jsx(Mn.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:bn(i.onScroll,h=>{const g=h.currentTarget,{contentWrapper:y,shouldExpandOnScrollRef:b}=l;if(b?.current&&y){const x=Math.abs(d.current-g.scrollTop);if(x>0){const S=window.innerHeight-xs*2,k=parseFloat(y.style.minHeight),C=parseFloat(y.style.height),A=Math.max(k,C);if(A<S){const R=A+x,_=Math.min(S,R),N=R-_;y.style.height=_+"px",y.style.bottom==="0px"&&(g.scrollTop=N>0?N:0,y.style.justifyContent="flex-end")}}}d.current=g.scrollTop})})})]})},"SelectViewport")),_Q="SelectGroup",[ire,ore]=bl(_Q),cw="SelectItem",[AQ,w2]=bl(cw),Jg=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,value:s,disabled:i=!1,textValue:o,...l}=e,u=fa(cw,r),d=Yg(cw,r),h=u.value===s,[g,y]=E.useState(o??""),[b,x]=E.useState(!1),S=Xs(_=>d.itemRefCallback?.(_,s,i)),k=dn(n,S),C=sk(),A=E.useRef("touch"),R=jt(()=>{i||(u.onValueChange(s),u.onOpenChange(!1))},"handleSelect");return m.jsx(AQ,{scope:r,value:s,disabled:i,textId:C,isSelected:h,onItemTextChange:E.useCallback(_=>{y(N=>N||(_?.textContent??"").trim())},[]),children:m.jsx(Ug.ItemSlot,{scope:r,value:s,disabled:i,textValue:g,children:m.jsx(Mn.div,{role:"option","aria-labelledby":C,"data-highlighted":b?"":void 0,"aria-selected":h&&b,"data-state":h?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...l,ref:k,onFocus:bn(l.onFocus,()=>x(!0)),onBlur:bn(l.onBlur,()=>x(!1)),onClick:bn(l.onClick,()=>{A.current!=="mouse"&&R()}),onPointerUp:bn(l.onPointerUp,()=>{A.current==="mouse"&&R()}),onPointerDown:bn(l.onPointerDown,_=>{A.current=_.pointerType}),onPointerMove:bn(l.onPointerMove,_=>{A.current=_.pointerType,i?d.onItemLeave?.():A.current==="mouse"&&_.currentTarget.focus({preventScroll:!0})}),onPointerLeave:bn(l.onPointerLeave,_=>{_.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:bn(l.onKeyDown,_=>{i||_.target!==_.currentTarget||d.searchRef?.current!==""&&_.key===" "||(dQ.includes(_.key)&&R(),_.key===" "&&_.preventDefault())})})})})},"SelectItem")),fp="SelectItemText",Qg=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,className:s,style:i,...o}=e,l=fa(fp,r),u=Yg(fp,r),d=w2(fp,r),h=mQ(fp,r),[g,y]=E.useState(null),b=Xs(R=>u.itemTextRefCallback?.(R,d.value,d.disabled)),x=dn(n,y,d.onItemTextChange,b),S=g?.textContent,k=E.useMemo(()=>m.jsx("option",{value:d.value,disabled:d.disabled,children:S},d.value),[d.disabled,d.value,S]),{onNativeOptionAdd:C,onNativeOptionRemove:A}=h;return ur(()=>(C(k),()=>A(k)),[C,A,k]),m.jsxs(m.Fragment,{children:[m.jsx(Mn.span,{id:d.textId,...o,ref:x}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!Sf(l.value)?Kc.createPortal(o.children,l.valueNode):null]})},"SelectItemText")),RQ="SelectItemIndicator",ey=E.forwardRef(jt(function(e,n){const{__scopeSelect:r,...s}=e;return w2(RQ,r).isSelected?m.jsx(Mn.span,{"aria-hidden":!0,...s,ref:n}):null},"SelectItemIndicator")),NQ="SelectBubbleInput",MQ=E.forwardRef(jt(function({__scopeSelect:e,...n},r){const s=fa(NQ,e),{value:i,onValueChange:o,required:l,disabled:u,name:d,autoComplete:h,form:g}=s,{nativeOptions:y,nativeSelectKey:b}=s,x=E.useRef(null),S=dn(r,x),k=i??"",C=c2(k),A=Array.from(y).some(R=>(R.props.value??"")==="");return E.useEffect(()=>{const R=x.current;if(!R)return;const _=window.HTMLSelectElement.prototype,M=Object.getOwnPropertyDescriptor(_,"value").set;if(C!==k&&M){const O=new Event("change",{bubbles:!0});M.call(R,k),R.dispatchEvent(O)}},[C,k]),m.jsxs(Mn.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:d,autoComplete:h,disabled:u,form:g,onChange:R=>o(R.target.value),...n,style:{...SJ,...n.style},ref:S,defaultValue:k,children:[Sf(i)&&!A?m.jsx("option",{value:""}):null,Array.from(y)]},b)},"SelectBubbleInput"));function S2(t){return typeof t=="function"}jt(S2,"isFunction");function Sf(t){return t===""||t===void 0}jt(Sf,"shouldShowPlaceholder");function hk(t){const e=Xs(t),n=E.useRef(""),r=E.useRef(0),s=E.useCallback(o=>{const l=n.current+o;e(l),jt((function u(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>u(""),1e3))}),"updateSearch")(l)},[e]),i=E.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,s,i]}jt(hk,"useTypeaheadSearch");function pk(t,e,n){const s=e.length>1&&Array.from(e).every(d=>d===e[0])?e[0]:e,i=n?t.indexOf(n):-1;let o=k2(t,Math.max(i,0));s.length===1&&(o=o.filter(d=>d!==n));const u=o.find(d=>d.textValue.toLowerCase().startsWith(s.toLowerCase()));return u!==n?u:void 0}jt(pk,"findNextItem");function k2(t,e){return t.map((n,r)=>t[(e+r)%t.length])}jt(k2,"wrapArray");function mk({id:t,value:e,field:n,readOnly:r,onChange:s}){const i=n.options?.filter(Boolean)??[],o=typeof e=="string"&&i.includes(e)?e:i[0]??"";return i.length===0?m.jsx("input",{id:t,type:"text",readOnly:r,value:o,disabled:!0}):m.jsxs(Fg,{value:o,onValueChange:s,disabled:r,children:[m.jsxs(qg,{id:t,className:"vertebr-select-trigger",children:[m.jsx("span",{className:"vertebr-select-value",children:m.jsx(Gg,{children:bd(o,n)})}),m.jsx(Wg,{className:"vertebr-select-icon",children:m.jsx(OQ,{})})]}),m.jsx(Kg,{children:m.jsx(Zg,{className:"vertebr-select-content",position:"popper",sideOffset:6,children:m.jsx(Xg,{className:"vertebr-select-viewport",children:i.map(l=>m.jsxs(Jg,{value:l,className:"vertebr-select-item",children:[m.jsx(Qg,{children:bd(l,n)}),m.jsx(ey,{className:"vertebr-select-check",children:m.jsx(jQ,{})})]},l))})})})]})}function OQ(){return m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:m.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(){return m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:m.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 DQ(t){return Array.isArray(t)?t.map(e=>String(e).trim()).filter(Boolean):[]}function IQ(t,e){const n=new Set(t),r=e.filter(i=>n.has(i)),s=t.filter(i=>!r.includes(i));return[...r.map(i=>({id:i,on:!0})),...s.map(i=>({id:i,on:!1}))]}function LQ({id:t,value:e,field:n,readOnly:r,onChange:s}){const i=n.options?.filter(Boolean)??[],o=DQ(e),l=IQ(i,o),u=d=>{s(d.filter(h=>h.on).map(h=>h.id))};return m.jsx("ul",{id:t,className:"vertebr-enum-list",children:l.map((d,h)=>m.jsxs("li",{className:"vertebr-enum-list-row","data-on":d.on,children:[m.jsxs("label",{className:"vertebr-enum-list-label",children:[m.jsx("input",{type:"checkbox",checked:d.on,disabled:r,onChange:g=>{const y=l.map(b=>b.id===d.id?{...b,on:g.target.checked}:b);u(y)}}),m.jsx("span",{children:bd(d.id,n)})]}),m.jsxs("div",{className:"vertebr-enum-list-move",children:[m.jsx("button",{type:"button","aria-label":`Move ${bd(d.id,n)} up`,disabled:r||h===0,onClick:()=>{if(h===0)return;const g=[...l],y=g[h];g[h]=g[h-1],g[h-1]=y,u(g)},children:"↑"}),m.jsx("button",{type:"button","aria-label":`Move ${bd(d.id,n)} down`,disabled:r||h===l.length-1,onClick:()=>{if(h>=l.length-1)return;const g=[...l],y=g[h];g[h]=g[h+1],g[h+1]=y,u(g)},children:"↓"})]})]},d.id))})}function PQ({id:t,name:e,value:n,asCents:r=!0,readOnly:s,onBlur:i,onChange:o,inputRef:l}){const[u,d]=E.useState(()=>Av(n,r));E.useEffect(()=>{d(Av(n,r))},[n,r]);const h=typeof n=="number"&&Number.isFinite(n)?lx(n,{asCents:r}):null;return m.jsxs("div",{className:"vertebr-field-money",children:[m.jsx("span",{className:"vertebr-field-money-prefix","aria-hidden":"true",children:"$"}),m.jsx("input",{id:t,name:e,ref:l,type:"text",inputMode:"decimal",autoComplete:"off",readOnly:s,value:u,placeholder:"0.00","aria-label":h?`Price ${h}`:"Price",onChange:g=>{const y=g.target.value;d(y),o(k4(y,r))},onBlur:()=>{d(Av(n,r)),i?.()}})]})}function zQ(t,e){const n=t[e]??t.id??t.slug??t.uid;return typeof n=="string"&&n.trim()?n:typeof n=="number"?String(n):null}function $Q(t,e,n){const r=t[e]??t.name??t.title??t.label??n;return typeof r=="string"&&r.trim()?r.trim():n}function BQ({id:t,value:e,field:n,client:r,readOnly:s,onChange:i}){const o=E.useId(),l=t??o,u=n.reference?.resource??"",d=n.reference?.valueField??"id",h=n.reference?.labelField??"name",g=typeof e=="string"?e:"",[y,b]=E.useState(""),[x,S]=E.useState(!1),[k,C]=E.useState([]),[A,R]=E.useState(!1),[_,N]=E.useState(g),M=E.useRef(null);return E.useEffect(()=>{N(g)},[g]),E.useEffect(()=>{if(!x||!u||s)return;let O=!1;const P=window.setTimeout(()=>{(async()=>{R(!0);try{const D=await r.listResource(u,{q:y.trim()||void 0,limit:20,fresh:!0});if(O)return;const F=[];for(const te of D.items){const H=zQ(te,d);H&&F.push({value:H,label:$Q(te,h,H)})}C(F)}catch{O||C([])}finally{O||R(!1)}})()},180);return()=>{O=!0,window.clearTimeout(P)}},[x,y,u,r,d,h,s]),E.useEffect(()=>{const O=P=>{M.current?.contains(P.target)||S(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]),u?m.jsxs("div",{className:"vertebr-reference",ref:M,"data-open":x||void 0,children:[m.jsx("input",{id:l,type:"text",className:"vertebr-reference-input",readOnly:s,value:x?y:_||g,placeholder:"Search…",autoComplete:"off",onFocus:()=>{s||(b(""),S(!0))},onChange:O=>{b(O.target.value),S(!0)}}),g&&!s?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-reference-clear",onClick:()=>{i(""),N(""),b("")},children:"Clear"}):null,x&&!s?m.jsx("ul",{className:"vertebr-reference-menu",role:"listbox",children:A?m.jsx("li",{className:"vertebr-reference-empty",children:"Searching…"}):k.length===0?m.jsx("li",{className:"vertebr-reference-empty",children:"No matches"}):k.map(O=>m.jsx("li",{children:m.jsxs("button",{type:"button",role:"option","aria-selected":O.value===g,className:"vertebr-reference-option",onClick:()=>{i(O.value),N(O.label),S(!1)},children:[m.jsx("span",{children:O.label}),m.jsx("code",{children:O.value})]})},O.value))}):null]}):m.jsx("input",{id:l,type:"text",readOnly:s,value:g,onChange:O=>i(O.target.value),placeholder:"Missing reference.resource"})}function ng({fieldKey:t,field:e,groupLabel:n,variant:r,schema:s,watched:i,form:o,uploads:l,onUpload:u,galleryUpload:d,onListGallery:h,onUploadGallery:g,fonts:y,fontsLoading:b,onListFonts:x,onRefreshFonts:S,hideImagePreview:k,hideUpload:C,visibilityGroup:A,settingsRow:R,client:_}){const N=wF(t,e,n),M=jF(t,s,A??n),O=!M||i?.[M]!==!1,P=!k&&e.type!=="file[]"&&Qa(t,e)&&!!rm(i?.[t]);return e.type==="boolean"?R?m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>m.jsxs("li",{className:"vertebr-settings-list-row","data-on":D.value?"true":"false",children:[m.jsxs("div",{className:"vertebr-settings-list-copy",children:[m.jsx(_v,{htmlFor:t,children:N}),e.description?m.jsx("p",{className:"vertebr-settings-list-desc",children:e.description}):null]}),m.jsx(K_,{className:"vertebr-switch",id:t,checked:!!D.value,onCheckedChange:D.onChange,children:m.jsx(Z_,{className:"vertebr-switch-thumb"})})]})}):m.jsxs("div",{className:"vertebr-switch-row",children:[m.jsxs("div",{className:"vertebr-switch-row-copy",children:[m.jsx(_v,{htmlFor:t,children:N}),e.description?m.jsx("p",{className:"vertebr-switch-row-desc",children:e.description}):null]}),m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>m.jsx(K_,{className:"vertebr-switch",id:t,checked:!!D.value,onCheckedChange:D.onChange,children:m.jsx(Z_,{className:"vertebr-switch-thumb"})})})]}):m.jsxs("div",{className:"vertebr-field","data-span":TF(t,e,r),"data-kind":Qa(t,e)?"image":void 0,"data-storefront":M?O?"on":"off":void 0,children:[m.jsxs("div",{className:"vertebr-field-head",children:[m.jsx(_v,{htmlFor:t,children:N}),M?m.jsx(WO,{name:M,label:N,form:o}):null]}),P?m.jsxs("div",{className:"vertebr-field-media",children:[m.jsx("img",{src:rm(i[t])??"",alt:""}),m.jsx("input",{id:t,type:"text",readOnly:e.readOnly,...o.register(t)})]}):e.type==="richtext"||AO(t,e)?m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>m.jsx(RY,{id:t,name:D.name,inputRef:D.ref,value:typeof D.value=="string"?D.value:"",readOnly:e.readOnly,recordImages:kF(s,i),galleryUpload:d,onListGallery:h,onUploadGallery:g,onBlur:D.onBlur,onChange:D.onChange})}):e.type==="file[]"?m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>{const F=rx(D.value);return m.jsx("div",{className:"vertebr-field-files",children:F.length>0?m.jsx("ul",{className:"vertebr-field-files-list",children:F.map(te=>m.jsxs("li",{children:[m.jsx("img",{src:te,alt:""}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>D.onChange(F.filter(H=>H!==te)),children:"Remove"})]},te))}):m.jsx("p",{className:"vertebr-field-files-empty",children:"No photos yet"})})}}):e.type==="number"&&ZO(t,e)?m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>m.jsx(PQ,{id:t,name:D.name,inputRef:D.ref,value:D.value,asCents:Jw(t,e)||/^pricing$/i.test(n),readOnly:e.readOnly,onBlur:D.onBlur,onChange:D.onChange})}):e.type==="number"?m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>m.jsx("input",{id:t,type:"number",readOnly:e.readOnly,value:typeof D.value=="number"&&Number.isFinite(D.value)?D.value:"",onBlur:D.onBlur,onChange:F=>{const te=F.target.value;D.onChange(te===""?void 0:Number(te))},name:D.name,ref:D.ref})}):e.type==="enum"?m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>m.jsx(mk,{id:t,value:D.value,field:e,readOnly:e.readOnly,onChange:D.onChange})}):e.type==="enum[]"?m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>m.jsx(LQ,{id:t,value:D.value,field:e,readOnly:e.readOnly,onChange:D.onChange})}):e.type==="font"?m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>m.jsx(C4,{id:t,value:D.value,label:e.label,description:e.description,readOnly:e.readOnly,fonts:y??[],loading:b,onChange:D.onChange,onRefreshFonts:S})}):e.type==="reference"&&_?m.jsx(Bs,{control:o.control,name:t,render:({field:D})=>m.jsx(BQ,{id:t,value:D.value,field:e,client:_,readOnly:e.readOnly,onChange:D.onChange})}):NO(t,e)?m.jsx("textarea",{id:t,rows:5,readOnly:e.readOnly,...o.register(t)}):m.jsx("input",{id:t,type:"text",readOnly:e.readOnly,...o.register(t)}),!C&&l?.[t]&&u&&!e.readOnly?m.jsx(Wc,{meta:l[t],multiple:e.type==="file[]",onUpload:async D=>{const te=(await u(t,D)).map(H=>H.url).filter(Boolean);if(te.length){if(e.type==="file[]"){o.setValue(t,[...rx(o.getValues(t)),...te],{shouldDirty:!0,shouldTouch:!0});return}o.setValue(t,te[0],{shouldDirty:!0,shouldTouch:!0})}}}):null]})}function C2({form:t,isDirty:e,status:n,tone:r,onDiscard:s,submitLabel:i="Save changes"}){return m.jsxs("div",{className:"vertebr-actions",children:[m.jsx("button",{className:"vertebr-btn vertebr-btn-primary",type:"submit",disabled:t.formState.isSubmitting||!e,children:t.formState.isSubmitting?"Saving…":i}),e?m.jsx("button",{className:"vertebr-btn",type:"button",onClick:s,children:"Discard"}):null,e?m.jsx("span",{className:"vertebr-dirty",children:"Unsaved"}):n?m.jsx("span",{className:"vertebr-status","data-tone":r,children:n}):null,m.jsx("span",{className:"vertebr-actions-spacer"}),m.jsx("span",{className:"vertebr-kbd",children:"⌘S"})]})}function VQ({schema:t,groups:e,watched:n,form:r,uploads:s,onUpload:i,galleryUpload:o,onListGallery:l,onUploadGallery:u,client:d,onSubmit:h,isDirty:g,status:y,tone:b,onDiscard:x,submitLabel:S,hideActions:k}){const C=zF(t,n),A=C?rm(n?.[C])??"":"",R=e.filter(M=>/^(Media|Display|Status)$/i.test(M.id)),_=e.filter(M=>!/^(Media|Display|Status)$/i.test(M.id)),N={variant:"record",schema:t,watched:n,form:r,uploads:s,onUpload:i,galleryUpload:o,onListGallery:l,onUploadGallery:u,client:d};return m.jsxs("form",{className:"vertebr-form","data-variant":"record",onSubmit:h,children:[m.jsx("div",{className:"vertebr-form-scroll",children:m.jsxs("div",{className:"vertebr-record-layout",children:[m.jsxs("aside",{className:"vertebr-record-aside",children:[m.jsx("div",{className:"vertebr-record-preview",children:A&&Vd(A)?m.jsx("img",{src:A,alt:""}):m.jsx("div",{className:"vertebr-record-preview-empty",children:"No image"})}),C&&s?.[C]&&i?m.jsx(Wc,{meta:s[C],label:"Drop a new image or browse",onUpload:async M=>{const[O]=await i(C,M);O?.url&&r.setValue(C,O.url,{shouldDirty:!0,shouldTouch:!0})}}):null,R.map(M=>m.jsxs("div",{className:"vertebr-record-block","data-layout":/^inventory$/i.test(M.id)?"chips":void 0,children:[m.jsx(vN,{groupId:M.id,label:M.label,schema:t,form:r}),m.jsx("div",{className:"vertebr-form-fields","data-layout":EF(M.fields[0]?.[0]??"",M.fields[0]?.[1])?"chips":void 0,children:M.fields.map(([O,P])=>m.jsx(ng,{fieldKey:O,field:P,groupLabel:M.label,visibilityGroup:M.id,hideImagePreview:!0,hideUpload:O===C,...N},O))})]},M.id))]}),m.jsx("div",{className:"vertebr-record-main",children:_.map(M=>{const O=/^inventory$/i.test(M.id),P=/^specs$/i.test(M.id),D=Gw(M.id,t),F=!D||n?.[D]!==!1;return m.jsxs("div",{className:"vertebr-record-block","data-layout":O?"chips":P?"specs":void 0,"data-storefront":D?F?"on":"off":void 0,children:[m.jsx(vN,{groupId:M.id,label:M.label,schema:t,form:r}),m.jsx("div",{className:"vertebr-form-fields","data-layout":O?"chips":P?"specs":void 0,children:M.fields.map(([te,H])=>m.jsx(ng,{fieldKey:te,field:H,groupLabel:M.label,visibilityGroup:M.id,...N},te))})]},M.id)})})]})}),k?null:m.jsx(C2,{form:r,isDirty:g,status:y,tone:b,onDiscard:x,submitLabel:S})]})}function vN({groupId:t,label:e,schema:n,form:r}){const s=Gw(t,n);return m.jsxs("div",{className:"vertebr-record-block-label",children:[m.jsx("span",{children:e}),s?m.jsx(WO,{name:s,label:e,form:r}):null]})}function HQ({schema:t,groups:e,watched:n,form:r,uploads:s,onUpload:i,galleryUpload:o,onListGallery:l,onUploadGallery:u,fonts:d,fontsLoading:h,onListFonts:g,onRefreshFonts:y,client:b,onSubmit:x,isDirty:S,status:k,tone:C,onDiscard:A,submitLabel:R,hideActions:_}){const N=e.length===1;return m.jsxs("form",{className:"vertebr-form","data-variant":"config",onSubmit:x,children:[m.jsx("div",{className:"vertebr-form-scroll",children:e.map(M=>{const O=CF(M.fields),P=!N||M.id!=="General"&&M.fields.length>0;return m.jsxs("div",{className:"vertebr-form-section","data-plain":N&&!P?"true":void 0,children:[P?m.jsxs("div",{className:"vertebr-form-section-head",children:[m.jsx("h3",{children:M.label}),m.jsx("span",{className:"vertebr-form-section-count",children:M.fields.length})]}):null,m.jsx("div",{className:"vertebr-form-fields","data-layout":O?"settings":void 0,children:O?m.jsx("ul",{className:"vertebr-settings-list",children:M.fields.map(([D,F])=>m.jsx(ng,{fieldKey:D,field:F,groupLabel:M.label,variant:"config",schema:t,watched:n,form:r,uploads:s,onUpload:i,galleryUpload:o,onListGallery:l,onUploadGallery:u,fonts:d,fontsLoading:h,onListFonts:g,onRefreshFonts:y,client:b,settingsRow:!0},D))}):M.fields.map(([D,F])=>m.jsx(ng,{fieldKey:D,field:F,groupLabel:M.label,variant:"config",schema:t,watched:n,form:r,uploads:s,onUpload:i,galleryUpload:o,onListGallery:l,onUploadGallery:u,fonts:d,fontsLoading:h,onListFonts:g,onRefreshFonts:y,client:b},D))})]},M.id)})}),_?null:m.jsx(C2,{form:r,isDirty:S,status:k,tone:C,onDiscard:A,submitLabel:R})]})}function kf({schema:t,value:e,onSave:n,submitLabel:r,variant:s="config",uploads:i,onUpload:o,galleryUpload:l,onListGallery:u,onUploadGallery:d,fonts:h,fontsLoading:g,onListFonts:y,onRefreshFonts:b,onChange:x,hideActions:S,client:k,canWrite:C=!0}){const{register:A,clear:R}=kO(),{push:_}=pg(),N=E.useMemo(()=>s==="record"?_F(t):t,[t,s]),M=E.useMemo(()=>s==="record"?AF(N,e):e,[N,e,s]),O=E.useMemo(()=>vF(N),[N]),P=E.useMemo(()=>PF(N,s),[N,s]),[D,F]=E.useState(null),[te,H]=E.useState(),Z=LU({resolver:BU(O),defaultValues:M}),G=cO({control:Z.control});E.useEffect(()=>{x?.(G??{})},[G,x]),E.useEffect(()=>{Z.reset(M)},[M,Z]);const ae=()=>{Z.reset(M),F(null),H(void 0)},z=Z.handleSubmit(async ce=>{if(C){F("Saving…"),H(void 0),A({saving:!0,isDirty:!0,visible:!0});try{await n(ce),F("Saved"),H("ok"),Z.reset(ce),_("Changes saved","ok")}catch(pe){const $=pe instanceof Error?pe.message:"Save failed";F($),H("danger"),_($,"danger")}finally{A({saving:!1})}}}),L=Z.formState.isDirty;E.useEffect(()=>{if(S){R();return}return A({visible:L,isDirty:L,saving:D==="Saving…",message:!C&&L?"Missing config.write capability":D??void 0,tone:!C&&L?"danger":te,onSave:C?()=>{z()}:void 0,onDiscard:ae}),()=>R()},[S,L,D,te,z,ae,A,R,C]),E.useEffect(()=>{const ce=pe=>{(pe.metaKey||pe.ctrlKey)&&pe.key.toLowerCase()==="s"&&(pe.preventDefault(),C&&z())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[z,C]);const W={schema:N,groups:P,watched:G,form:Z,uploads:i,onUpload:o,galleryUpload:l,onListGallery:u,onUploadGallery:d,fonts:h,fontsLoading:g,onListFonts:y,onRefreshFonts:b,client:k,onSubmit:z,isDirty:L,status:D,tone:te,onDiscard:ae,submitLabel:r,hideActions:!0};return s==="record"?m.jsx(VQ,{...W}):m.jsx(HQ,{...W})}function UQ(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function FQ({client:t,configId:e,onPublished:n}){const{push:r}=pg(),[s,i]=E.useState([]),[o,l]=E.useState(!0),[u,d]=E.useState(null),h=E.useCallback(async()=>{l(!0);try{const b=await t.listRevisions(e,{fresh:!0});i(b.items)}finally{l(!1)}},[t,e]);E.useEffect(()=>{let b=!1;return(async()=>{try{l(!0);const x=await t.listRevisions(e,{fresh:!0});b||i(x.items)}catch(x){b||r(x instanceof Error?x.message:"Failed to load revisions","danger")}finally{b||l(!1)}})(),()=>{b=!0}},[t,e,r]);const g=async b=>{d(b);try{await t.publishRevision(e,b),r("Revision published","ok"),await h(),await n?.()}catch(x){r(x instanceof Error?x.message:"Publish failed","danger")}finally{d(null)}},y=async b=>{d(b);try{await t.restoreRevision(e,b),r("Draft restored from revision","ok"),await h(),await n?.()}catch(x){r(x instanceof Error?x.message:"Restore failed","danger")}finally{d(null)}};return m.jsxs("div",{className:"vertebr-revisions",children:[m.jsxs("div",{className:"vertebr-panel-head",children:[m.jsx("h3",{children:"Revisions"}),m.jsx("span",{className:"vertebr-count",children:o?"…":`${s.length}`})]}),s.length===0&&!o?m.jsx("p",{className:"vertebr-revisions-empty",children:"No revisions yet."}):m.jsx("ul",{className:"vertebr-revisions-list",children:s.map(b=>m.jsxs("li",{className:"vertebr-revisions-item",children:[m.jsxs("div",{className:"vertebr-revisions-meta",children:[m.jsx("strong",{children:b.label?.trim()||b.id}),m.jsx("span",{"data-status":b.status,children:b.status}),m.jsxs("span",{className:"vertebr-revisions-when",children:[UQ(b.createdAt),b.createdBy?` · ${b.createdBy}`:""]})]}),m.jsxs("div",{className:"vertebr-revisions-actions",children:[b.status!=="published"?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:u!=null,onClick:()=>{g(b.id)},children:u===b.id?"…":"Publish"}):null,m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:u!=null,onClick:()=>{y(b.id)},children:"Restore"})]})]},b.id))})]})}function xN(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\bcents\b/i,"").trim()}function hp(t){return Object.fromEntries(Object.entries(t).map(([e,n])=>typeof n=="string"?[e,{type:n,label:xN(e),required:!0}]:[e,{...n,label:n.label??xN(e),required:n.required??!0}]))}function gk(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 v0({title:t,count:e=0,eyebrow:n,schema:r,submitLabel:s,onClose:i,onSubmit:o}){return E.useEffect(()=>{const l=d=>{d.key==="Escape"&&i()};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}},[i]),m.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:i,children:m.jsxs("div",{className:"vertebr-modal vertebr-modal-form",role:"dialog","aria-modal":"true","aria-label":t,onClick:l=>l.stopPropagation(),children:[m.jsxs("header",{className:"vertebr-modal-head",children:[m.jsxs("div",{className:"vertebr-modal-heading",children:[m.jsx("p",{className:"vertebr-modal-eyebrow",children:n??(e===1?"1 person":`${e} people`)}),m.jsx("h2",{children:t})]}),m.jsx("div",{className:"vertebr-modal-actions",children:m.jsx("button",{type:"button",className:"vertebr-btn",onClick:i,"aria-label":"Close",children:"Close"})})]}),m.jsx("div",{className:"vertebr-modal-body",children:m.jsx(kf,{variant:"config",schema:r,value:gk(r),submitLabel:s,onSave:async l=>{await o(l),i()}})})]})})}function cc(t){return t.trim()}function rg({options:t,value:e,loading:n,disabled:r,placeholder:s="Select…",emptyLabel:i="Nothing available",searchPlaceholder:o="Search…",onChange:l}){const u=E.useId(),d=E.useRef(null),[h,g]=E.useState(!1),[y,b]=E.useState(""),x=E.useMemo(()=>new Set(e.map(cc)),[e]),S=E.useMemo(()=>{const _=y.trim().toLowerCase();return _?t.filter(N=>`${N.label} ${N.secondary??""} ${N.id}`.toLowerCase().includes(_)):t},[t,y]);E.useEffect(()=>{if(!h)return;const _=M=>{d.current?.contains(M.target)||g(!1)},N=M=>{M.key==="Escape"&&g(!1)};return window.addEventListener("mousedown",_),window.addEventListener("keydown",N),()=>{window.removeEventListener("mousedown",_),window.removeEventListener("keydown",N)}},[h]);const k=_=>{const N=cc(_),M=new Set(x);M.has(N)?M.delete(N):M.add(N),l(t.map(O=>cc(O.id)).filter(O=>M.has(O)))},C=()=>{const _=new Set(x);for(const N of S)_.add(cc(N.id));l(t.map(N=>cc(N.id)).filter(N=>_.has(N)))},A=()=>l([]),R=e.length===0?n?"Loading…":t.length===0?i:s:e.length===1?t.find(_=>_.id===e[0])?.label??e[0]:`${e.length} selected`;return m.jsxs("div",{className:"vertebr-email-select",ref:d,"data-open":h?"true":void 0,children:[m.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:()=>g(_=>!_),children:[m.jsx("span",{className:"vertebr-select-value",children:R}),m.jsx("span",{className:"vertebr-select-icon","aria-hidden":"true",children:m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",children:m.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),h?m.jsxs("div",{className:"vertebr-email-select-panel",id:u,role:"listbox",children:[t.length>6?m.jsxs("div",{className:"vertebr-email-select-toolbar",children:[m.jsx("input",{type:"search",value:y,placeholder:o,"aria-label":"Search",onChange:_=>b(_.target.value)}),m.jsxs("div",{className:"vertebr-email-select-actions",children:[m.jsx("button",{type:"button",onClick:C,children:"All"}),m.jsx("button",{type:"button",onClick:A,disabled:e.length===0,children:"Clear"})]})]}):m.jsx("div",{className:"vertebr-email-select-toolbar vertebr-email-select-toolbar-compact",children:m.jsxs("div",{className:"vertebr-email-select-actions",children:[m.jsx("button",{type:"button",onClick:C,children:"All"}),m.jsx("button",{type:"button",onClick:A,disabled:e.length===0,children:"Clear"})]})}),m.jsx("ul",{className:"vertebr-email-select-list",children:S.length===0?m.jsx("li",{className:"vertebr-email-select-empty",children:"No matches"}):S.map(_=>{const N=x.has(cc(_.id));return m.jsx("li",{children:m.jsxs("label",{"data-on":N?"true":void 0,"data-media":_.imageUrl?"true":void 0,children:[m.jsx("input",{type:"checkbox",checked:N,onChange:()=>k(_.id)}),_.imageUrl?m.jsx("img",{className:"vertebr-email-select-thumb",src:_.imageUrl,alt:"",loading:"lazy"}):null,m.jsxs("span",{className:"vertebr-email-select-copy",children:[m.jsx("span",{className:"vertebr-email-select-primary",children:_.label}),_.secondary?m.jsx("span",{className:"vertebr-email-select-secondary",children:_.secondary}):null]})]})},_.id)})})]}):null]})}function qQ({options:t,value:e,loading:n,disabled:r,onChange:s}){const i=t.map(o=>({id:o.email.trim().toLowerCase(),label:o.email,secondary:o.label}));return m.jsx(rg,{options:i,value:e,loading:n,disabled:r,placeholder:"Select emails…",emptyLabel:"No emails on this list",searchPlaceholder:"Search emails…",onChange:s})}function wN(t){const e=Date.parse(t);return Number.isFinite(e)?new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(e):t}function GQ(t){return t.replace(/^library:/i,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim()}function WQ(t){return t==="row"?"Row":t==="campaign"?"Schedule":"Board"}function E2(t){const e=t.reference?.trim();if(e&&e.toUpperCase()!=="MM-PENDING")return e;const s=(t.subject??"").match(/(?:—|-|–)\s*((?:MM|ORD|ORDER)[-_][A-Z0-9-]+|[A-Z]{2,}[-_][A-Z0-9-]{3,})\s*$/i)?.[1]?.trim();return!s||s.toUpperCase()==="MM-PENDING"?"":s}function KQ(t){const e=E2(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 ZQ(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 YQ(t){return t.failed&&t.failed>0?`${t.sent} / ${t.failed} failed`:`${t.sent} / ${t.recipientCount}`}function SN(t){return t==="sent"?{label:"Sent",tone:"ok"}:t==="partial"?{label:"Partial"}:t==="failed"?{label:"Failed"}:{label:"Scheduled",tone:"neutral"}}function uc(){return m.jsx("span",{className:"vertebr-cell-empty",children:"—"})}function XQ({campaigns:t,history:e,canSchedule:n,canHistory:r,busy:s,onCancel:i}){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]),d=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=!!i&&o!=="history",g=async b=>{i&&window.confirm(`Cancel scheduled email to ${b.resourceLabel??b.resourceId}?`)&&await i(b.id)},y=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 m.jsxs("div",{className:"vertebr-emails-activity",children:[m.jsxs("div",{className:"vertebr-table-toolbar",children:[m.jsx("div",{className:"vertebr-table-toolbar-start",children:m.jsxs("div",{className:"vertebr-emails-segment",role:"group","aria-label":"Activity",children:[m.jsx("button",{type:"button","data-active":o==="all"?"true":void 0,onClick:()=>l("all"),children:"All"}),m.jsx("button",{type:"button","data-active":o==="scheduled"?"true":void 0,onClick:()=>l("scheduled"),children:"Scheduled"}),m.jsx("button",{type:"button","data-active":o==="history"?"true":void 0,onClick:()=>l("history"),children:"History"})]})}),m.jsx("span",{className:"vertebr-count",children:d.length})]}),d.length===0?m.jsx("div",{className:"vertebr-empty",children:y}):m.jsx("div",{className:"vertebr-table-wrap",children:m.jsxs("table",{className:"vertebr-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"When"}),m.jsx("th",{children:"Status"}),m.jsx("th",{children:"Subject"}),m.jsx("th",{children:"Confirmation"}),m.jsx("th",{children:"To"}),m.jsx("th",{children:"Audience"}),m.jsx("th",{children:"Template"}),m.jsx("th",{children:"Via"}),m.jsx("th",{children:"Delivery"}),h?m.jsx("th",{className:"vertebr-col-actions",children:"Actions"}):null]})}),m.jsx("tbody",{children:d.map(b=>{if(b.kind==="scheduled"){const A=b.campaign,R=SN("scheduled");return m.jsxs("tr",{children:[m.jsx("td",{children:m.jsx("span",{className:"vertebr-cell-datetime",children:wN(A.sendAt)})}),m.jsx("td",{children:m.jsx("span",{className:"vertebr-badge","data-tone":R.tone,children:R.label})}),m.jsx("td",{children:A.subject?.trim()||m.jsx(uc,{})}),m.jsx("td",{children:m.jsx(uc,{})}),m.jsx("td",{children:A.recipientCount??m.jsx(uc,{})}),m.jsx("td",{children:A.resourceLabel??A.resourceId}),m.jsx("td",{children:A.templateLabel??A.templateId}),m.jsx("td",{children:"Schedule"}),m.jsx("td",{children:m.jsx(uc,{})}),h?m.jsx("td",{className:"vertebr-col-actions",children:m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:s,onClick:()=>{g(A)},children:"Cancel"})}):null]},`scheduled:${b.id}`)}const x=b.entry,S=SN(x.status),k=E2(x),C=ZQ(x);return m.jsxs("tr",{children:[m.jsx("td",{children:m.jsx("span",{className:"vertebr-cell-datetime",children:wN(x.at)})}),m.jsx("td",{children:m.jsx("span",{className:"vertebr-badge","data-tone":S.tone,children:S.label})}),m.jsx("td",{children:KQ(x)}),m.jsx("td",{children:k||m.jsx(uc,{})}),m.jsx("td",{children:C||m.jsx(uc,{})}),m.jsx("td",{children:x.resourceLabel??x.resourceId}),m.jsx("td",{children:x.templateLabel??GQ(x.templateId)}),m.jsx("td",{children:WQ(x.source)}),m.jsx("td",{children:YQ(x)}),h?m.jsx("td",{className:"vertebr-col-actions"}):null]},`history:${b.id}`)})})]})})]})}function JQ({value:t,options:e,onChange:n,ariaLabel:r,size:s="md"}){const[i,o]=E.useState(!1),l=E.useRef(null),u=E.useId(),d=e.find(h=>h.id===t)??e[0];return E.useEffect(()=>{if(!i)return;const h=y=>{l.current?.contains(y.target)||o(!1)},g=y=>{y.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",g)}},[i]),m.jsxs("div",{className:"vertebr-emails-nav","data-size":s,"data-open":i||void 0,ref:l,children:[m.jsxs("button",{type:"button",className:"vertebr-emails-nav-trigger","aria-label":r,"aria-haspopup":"listbox","aria-expanded":i,"aria-controls":u,onClick:()=>o(h=>!h),children:[m.jsxs("span",{className:"vertebr-emails-nav-current",children:[m.jsx("span",{className:"vertebr-emails-nav-label",children:d?.label}),d?.count!=null?m.jsx("span",{className:"vertebr-emails-nav-count",children:d.count}):null]}),m.jsx("span",{className:"vertebr-emails-nav-chevron","aria-hidden":"true",children:"▾"})]}),i?m.jsx("ul",{id:u,className:"vertebr-emails-nav-menu",role:"listbox","aria-label":r,children:e.map(h=>{const g=h.id===t;return m.jsx("li",{role:"presentation",children:m.jsxs("button",{type:"button",role:"option","aria-selected":g,"data-active":g||void 0,className:"vertebr-emails-nav-option",onClick:()=>{n(h.id),o(!1)},children:[m.jsxs("span",{className:"vertebr-emails-nav-option-main",children:[m.jsx("span",{className:"vertebr-emails-nav-label",children:h.label}),h.count!=null?m.jsx("span",{className:"vertebr-emails-nav-count",children:h.count}):null]}),h.hint?m.jsx("span",{className:"vertebr-emails-nav-hint",children:h.hint}):null]})},h.id)})}):null]})}const QQ=new Set(["custom","promo","custom_discount"]);function eee(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim()}function tee(t){const e=new Set,n=[];for(const r of t){const s=r.input?.preset;if(!(!s||typeof s=="string")&&!(s.type!=="enum"||!s.options?.length))for(const i of s.options)!i||QQ.has(i)||i.startsWith("library:")||e.has(i)||(e.add(i),n.push({id:i,label:s.optionLabels?.[i]?.trim()||eee(i)}))}return n}function x0(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 nee(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 ree(t){return Array.isArray(t)?t.join(", "):t}function see(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 iee(t){return t.kind==="order"?!0:!t.subject.trim()||!t.body.trim()?!1:t.kind==="discount"?!!(t.discountCode.trim()&&t.discountOffer.trim()):!0}function oee({templates:t,library:e,products:n,discounts:r=[],canLibrary:s,busy:i,previewResourceId:o,previewTemplateId:l,onPreview:u,onSaveLibrary:d,onDeleteLibrary:h}){const g=E.useMemo(()=>tee(t),[t]),[y,b]=E.useState(null),[x,S]=E.useState(!1),[k,C]=E.useState(null),[A,R]=E.useState("all"),[_,N]=E.useState(null),[M,O]=E.useState(!1),P=!!(y&&e.some(L=>L.id===y.id)),D=E.useMemo(()=>n.map(L=>({id:L.id,label:L.label,secondary:L.priceLabel,imageUrl:L.imageUrl})),[n]),F=E.useCallback(async()=>{if(!y||!u||!o||!l){N(null);return}if(!iee(y)){N(null);return}O(!0);try{const L=await u({resourceId:o,templateId:l,input:see(y,P)});N(L)}catch{N(null)}finally{O(!1)}},[y,u,o,l,P]);E.useEffect(()=>{const L=window.setTimeout(()=>{F()},280);return()=>window.clearTimeout(L)},[F]);const te=L=>{C(null),b(x0({label:`${L.label} copy`,fromPreset:L.id,kind:nee(L.id)}))},H=L=>{C(null),b(x0({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}))},Z=()=>{C(null),b(x0({kind:"promo"}))},G=async()=>{if(!y||!d)return;const L=y.label.trim(),W=y.subject.trim(),ce=y.body.trim();if(!L||!W||!ce){C("Label, subject, and body are required.");return}if(y.kind==="discount"&&(!y.discountCode.trim()||!y.discountOffer.trim())){C("Discount templates need a code and offer label.");return}S(!0),C(null);try{const pe=new Date().toISOString();await d({id:y.id,label:L,subject:W,body:ce,productIds:y.productIds.length?y.productIds:void 0,discountId:y.kind==="discount"&&y.discountId||void 0,discountCode:y.kind==="discount"&&y.discountCode.trim()||void 0,discountOffer:y.kind==="discount"&&y.discountOffer.trim()||void 0,discountExpires:y.kind==="discount"&&y.discountExpires.trim()||void 0,fromPreset:y.fromPreset,kind:y.kind,eyebrow:y.kind==="order"&&y.eyebrow.trim()||void 0,headline:y.kind==="order"&&y.headline.trim()||void 0,confirmationLabel:y.kind==="order"&&y.confirmationLabel.trim()||void 0,shippingNote:y.kind==="order"&&y.shippingNote.trim()||void 0,footer:y.kind==="order"&&y.footer.trim()||void 0,signOff:y.kind==="order"&&y.signOff.trim()||void 0,createdAt:y.createdAt??pe,updatedAt:pe}),b(null)}catch(pe){C(pe instanceof Error?pe.message:"Save failed")}finally{S(!1)}},ae=async L=>{if(h&&window.confirm(`Delete template “${L.label}”?`)){S(!0),C(null);try{await h(L.id),y?.id===L.id&&b(null)}catch(W){C(W instanceof Error?W.message:"Delete failed")}finally{S(!1)}}},z=i||x||!s||!d;return m.jsx("div",{className:"vertebr-emails-library","data-editing":y?"true":void 0,children:y?m.jsxs("div",{className:"vertebr-emails-library-editor",children:[m.jsxs("header",{children:[m.jsx("h3",{children:P?"Edit template":"Save as custom"}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:x,onClick:()=>{b(null),N(null)},children:"Close"})]}),m.jsxs("div",{className:"vertebr-emails-layout",children:[m.jsxs("div",{className:"vertebr-emails-compose",children:[m.jsxs("div",{className:"vertebr-emails-fields",children:[m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Label"}),m.jsx("input",{type:"text",value:y.label,disabled:x,onChange:L=>b(W=>W&&{...W,label:L.target.value})})]}),m.jsx("div",{className:"vertebr-emails-segment",role:"group","aria-label":"Kind",children:[["account","Account"],["promo","Promo"],["discount","Discount"],["order","Order"]].map(([L,W])=>m.jsx("button",{type:"button","data-active":y.kind===L?"true":void 0,disabled:x||y.kind==="order",onClick:()=>b(ce=>ce&&{...ce,kind:L}),children:W},L))}),m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Subject"}),m.jsx("input",{type:"text",value:y.subject,disabled:x,onChange:L=>b(W=>W&&{...W,subject:L.target.value})})]}),m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:y.kind==="order"?"Intro":"Body"}),m.jsx("textarea",{rows:y.kind==="order"?4:7,value:y.body,disabled:x,onChange:L=>b(W=>W&&{...W,body:L.target.value})})]}),y.kind==="order"?m.jsxs(m.Fragment,{children:[m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Eyebrow"}),m.jsx("input",{type:"text",value:y.eyebrow,disabled:x,onChange:L=>b(W=>W&&{...W,eyebrow:L.target.value})})]}),m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Headline"}),m.jsx("input",{type:"text",value:y.headline,disabled:x,onChange:L=>b(W=>W&&{...W,headline:L.target.value})})]}),m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Confirmation label"}),m.jsx("input",{type:"text",value:y.confirmationLabel,disabled:x,onChange:L=>b(W=>W&&{...W,confirmationLabel:L.target.value})})]}),m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Shipping note"}),m.jsx("textarea",{rows:2,value:y.shippingNote,disabled:x,onChange:L=>b(W=>W&&{...W,shippingNote:L.target.value})})]}),m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Footer"}),m.jsx("textarea",{rows:2,value:y.footer,disabled:x,onChange:L=>b(W=>W&&{...W,footer:L.target.value})})]}),m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Sign-off"}),m.jsx("input",{type:"text",value:y.signOff,disabled:x,onChange:L=>b(W=>W&&{...W,signOff:L.target.value})})]}),m.jsxs("p",{className:"vertebr-mail-compose-hint",children:["Tokens: ","{{confirmationNumber}}",", ","{{email}}",","," ","{{total}}"]})]}):null,y.kind==="discount"?m.jsxs(m.Fragment,{children:[r.length>0?m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Discount"}),m.jsxs("select",{value:y.discountId??"",disabled:x,onChange:L=>{const W=L.target.value,ce=r.find(pe=>pe.id===W);b(pe=>pe&&{...pe,discountId:W||void 0,discountCode:ce?.code??pe.discountCode,discountOffer:ce?.offerLabel??ce?.label??pe.discountOffer,discountExpires:ce?.expiresLabel??pe.discountExpires})},children:[m.jsx("option",{value:"",children:"Manual code…"}),r.map(L=>m.jsxs("option",{value:L.id,children:[L.label,L.code?` (${L.code})`:""]},L.id))]})]}):null,m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Discount code"}),m.jsx("input",{type:"text",value:y.discountCode,disabled:x,placeholder:"WELCOME20",onChange:L=>b(W=>W&&{...W,discountCode:L.target.value})})]}),m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Offer label"}),m.jsx("input",{type:"text",value:y.discountOffer,disabled:x,placeholder:"20% off",onChange:L=>b(W=>W&&{...W,discountOffer:L.target.value})})]}),m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Expires (optional)"}),m.jsx("input",{type:"text",value:y.discountExpires,disabled:x,placeholder:"Expires Mar 1",onChange:L=>b(W=>W&&{...W,discountExpires:L.target.value})})]})]}):null,D.length>0?m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Products"}),m.jsx(rg,{options:D,value:y.productIds,disabled:x,placeholder:"Add products with photos…",emptyLabel:"No products",onChange:L=>b(W=>W&&{...W,productIds:L})})]}):null,y.fromPreset?m.jsxs("p",{className:"vertebr-emails-library-meta",children:["From system preset ",m.jsx("code",{children:y.fromPreset})]}):null,k?m.jsx("p",{className:"vertebr-mail-compose-error",children:k}):null]}),m.jsx("div",{className:"vertebr-mail-compose-foot",children:m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",disabled:x||!d,onClick:()=>{G()},children:x?"Saving…":"Save template"})})]}),m.jsx("div",{className:"vertebr-emails-side",children:m.jsxs("div",{className:"vertebr-mail-preview",children:[m.jsxs("div",{className:"vertebr-mail-preview-meta",children:[m.jsxs("p",{children:[m.jsx("span",{children:"To"}),m.jsx("strong",{children:_?ree(_.to):M?"Updating…":"Sample recipient"})]}),m.jsxs("p",{children:[m.jsx("span",{children:"Subject"}),m.jsx("strong",{children:_?.subject??(M?"Updating…":y.subject||"—")})]})]}),m.jsx("div",{className:"vertebr-mail-preview-stage",children:m.jsx("div",{className:"vertebr-mail-preview-frame",children:_?.html?m.jsx("iframe",{title:"Email preview",sandbox:"",srcDoc:_.html}):_?.text?m.jsx("pre",{children:_.text}):m.jsx("div",{className:"vertebr-mail-preview-empty",children:M?"Rendering host template…":!o||!l?"No sample audience to preview against.":y.kind==="discount"&&(!y.discountCode.trim()||!y.discountOffer.trim())?"Add a discount code and offer to preview.":"Write a subject and body to preview."})})})]})})]})]}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"vertebr-emails-subnav",children:[m.jsx(JQ,{size:"sm",ariaLabel:"Templates subsection",value:A,onChange:R,options:[{id:"all",label:"All templates",count:g.length+e.length,hint:"Presets and saved"},{id:"system",label:"System presets",count:g.length,hint:"Built-in starting points"},{id:"saved",label:"Saved templates",count:e.length,hint:"Owner-edited copies"}]}),s&&d&&A!=="system"?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:z,onClick:Z,children:"New"}):null]}),m.jsxs("div",{className:"vertebr-emails-library-cols","data-section":A,children:[A!=="saved"?m.jsxs("section",{className:"vertebr-emails-library-section",children:[m.jsxs("header",{children:[m.jsx("h3",{children:"System presets"}),m.jsx("span",{className:"vertebr-count",children:g.length})]}),g.length===0?m.jsx("p",{className:"vertebr-emails-campaigns-empty",children:"No system presets exposed on template inputs."}):m.jsx("ul",{children:g.map(L=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("strong",{children:L.label}),m.jsx("span",{children:L.id})]}),s&&d?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:z,onClick:()=>te(L),children:"Duplicate"}):null]},L.id))})]}):null,A!=="system"?m.jsxs("section",{className:"vertebr-emails-library-section",children:[m.jsxs("header",{children:[m.jsx("h3",{children:"Saved templates"}),m.jsx("span",{className:"vertebr-count",children:e.length})]}),s?e.length===0?m.jsx("p",{className:"vertebr-emails-campaigns-empty",children:"No saved templates yet. Duplicate a system preset or create one."}):m.jsx("ul",{children:e.map(L=>m.jsxs("li",{children:[m.jsxs("div",{children:[m.jsx("strong",{children:L.label}),m.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?m.jsx("span",{className:"vertebr-emails-campaign-subject",children:L.subject}):null]}),m.jsxs("div",{className:"vertebr-emails-library-actions",children:[m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:z,onClick:()=>H(L),children:"Edit"}),h&&L.kind!=="order"?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:z,onClick:()=>{ae(L)},children:"Delete"}):null]})]},L.id))}):m.jsx("p",{className:"vertebr-emails-campaigns-empty",children:"Host has not enabled the template library."})]}):null]})]})})}const aee=new Set(["custom","promo","custom_discount"]),lee=new Set(["discount","welcome_offer","flash_sale","custom_discount"]),cee=new Set(["discountId","discountCode","discountOffer","discountExpires"]);function Fc(t){return typeof t=="string"?t:String(t??"")}function yk(t){return t.startsWith("library:")}function uee(t){return aee.has(t)||yk(t)}function bk(t,e){if(lee.has(t))return!0;if(!yk(t))return!1;const n=t.slice(8);return e.some(r=>r.id===n&&r.kind==="discount")}function dee(t,e){const n=`${t} ${e.label??""}`;return e.type==="richtext"||/(body|message|html|notes)/i.test(n)}function T2(t,e){if(!t.preset)return!0;const n=Fc(e.preset);return!n||uee(n)}function _2(t,e,n,r=[]){if(t==="subject"||t==="body")return T2(e,n);if(cee.has(t)){const s=Fc(n.preset);return!(!bk(s,r)||t==="discountId"&&!e.discountId?.options?.length)}return!0}function kN(t,e,n=[]){return Object.entries(t).every(([r,s])=>{if(!_2(r,t,e,n))return!0;const i=(r==="subject"||r==="body")&&T2(t,e),o=(r==="discountCode"||r==="discountOffer")&&bk(Fc(e.preset),n);return s.required===!1&&!i&&!o?!0:s.type==="enum[]"?s.required===!1?!0:Array.isArray(e[r])&&e[r].length>0:s.type!=="string"&&s.type!=="richtext"&&s.type!=="enum"?!0:!!Fc(e[r]).trim()})}function fee(t){return t?Object.fromEntries(Object.entries(t).map(([e,n])=>typeof n=="string"?[e,{type:n,label:e,required:!0}]:[e,n])):{}}function hee(t,e,n,r){const s={...t};if(s.preset?.type==="enum"&&e.length>0){const i=e.map(u=>`library:${u.id}`),o=Object.fromEntries(e.map(u=>[`library:${u.id}`,u.label])),l=[...s.preset.options??[]];for(const u of i)l.includes(u)||l.push(u);s.preset={...s.preset,options:l,optionLabels:{...s.preset.optionLabels??{},...o}}}if(s.productIds&&n&&n.length>0){const i=n.map(l=>l.id),o=Object.fromEntries(n.map(l=>[l.id,l.label]));s.productIds={...s.productIds,type:"enum[]",options:i,optionLabels:{...s.productIds.optionLabels??{},...o},default:Array.isArray(s.productIds.default)?s.productIds.default:[]}}if(s.discountId&&r&&r.length>0){const i=r.map(l=>l.id),o=Object.fromEntries(r.map(l=>[l.id,l.offerLabel?`${l.label}${l.code?` (${l.code})`:""}`:l.label]));s.discountId={...s.discountId,type:"enum",options:i,optionLabels:{...s.discountId.optionLabels??{},...o},required:!1}}return s}function pee(t){const e=gk(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 mee(t,e,n,r){if(!yk(e))return t;const s=e.slice(8),i=n.find(o=>o.id===s);return i?{...t,preset:e,subject:i.subject,body:i.body,...r.productIds?{productIds:i.productIds??[]}:{},...r.discountId?{discountId:i.discountId??""}:{},...r.discountCode?{discountCode:i.discountCode??""}:{},...r.discountOffer?{discountOffer:i.discountOffer??""}:{},...r.discountExpires?{discountExpires:i.discountExpires??""}:{}}:t}function gee(t){return Array.isArray(t)?t.join(", "):t}function yee(t){const e=Date.parse(t);return Number.isFinite(e)?new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(e):t}function bee(){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 vee(t){return Array.isArray(t)?t.map(e=>String(e).trim()).filter(Boolean):[]}function xee({data:t,loading:e,tab:n,onRefresh:r,onLoadRecipients:s,onPreview:i,onSend:o,onSchedule:l,onCancel:u,onSaveLibrary:d,onDeleteLibrary:h}){const g=t.audiences,y=t.library??[],b=t.products??[],x=t.discounts??[],S=t.history??[],[k]=E.useState("compose"),C=n??k,A=E.useMemo(()=>g.map(ye=>({id:ye.id,label:ye.label})),[g]),[R,_]=E.useState(()=>g[0]?[g[0].id]:[]),N=E.useMemo(()=>g.filter(ye=>R.includes(ye.id)),[g,R]),M=E.useMemo(()=>N.length===0?[]:t.templates.filter(ye=>N.every(Ie=>Ie.templates.includes(ye.id))),[t.templates,N]),[O,P]=E.useState(M[0]?.id??""),D=M.find(ye=>ye.id===O)??M[0],F=E.useMemo(()=>hee(fee(D?.input),y,b,x),[x,y,b,D]),te=E.useMemo(()=>pee(F),[F]),[H,Z]=E.useState(te),[G,ae]=E.useState("all"),[z,L]=E.useState([]),[W,ce]=E.useState([]),[pe,$]=E.useState(!1),[Y,he]=E.useState("now"),[be,Me]=E.useState(bee),[Ce,He]=E.useState(null),[Ee,le]=E.useState(!1),[me,De]=E.useState(!1),[Be,Ke]=E.useState(null),[mt,ht]=E.useState(null);E.useEffect(()=>{_(ye=>{const Ie=ye.filter(I=>g.some(B=>B.id===I));return Ie.length>0?Ie:g[0]?[g[0].id]:[]})},[g]),E.useEffect(()=>{if(!D){P("");return}M.some(ye=>ye.id===O)||P(D.id)},[D,O,M]),E.useEffect(()=>{Z(te)},[te]),E.useEffect(()=>{L([])},[R]);const Wt=N.map(ye=>ye.id).join("|");E.useEffect(()=>{if(N.length===0){ce([]);return}let ye=!1;return $(!0),Promise.all(N.map(async Ie=>(await s(Ie.id)).map(B=>({...B,resourceId:Ie.id,label:B.label?`${B.label} · ${Ie.label}`:Ie.label})))).then(Ie=>{if(ye)return;const I=new Set,B=[];for(const U of Ie)for(const se of U){const oe=se.email.trim().toLowerCase();!oe||I.has(oe)||(I.add(oe),B.push({...se,email:oe}))}B.sort((U,se)=>U.email.localeCompare(se.email)),ce(B)}).catch(Ie=>{ye||(ce([]),Ke(Ie instanceof Error?Ie.message:"Failed to load emails"))}).finally(()=>{ye||$(!1)}),()=>{ye=!0}},[Wt,s,N]);const Vt=N[0],Yt=N.length>0&&!!D&&(!Object.keys(F).length||kN(F,H,y))&&(G==="all"||z.length>0)&&(Y==="now"||!!be)&&!me,kn=E.useMemo(()=>{if(G!=="emails"||z.length===0)return;const ye=W.find(Ie=>Ie.email.trim().toLowerCase()===z[0]?.toLowerCase());return ye?.id??ye?.email??z[0]},[W,G,z]),jn=E.useMemo(()=>{if(G==="emails"&&z[0]){const ye=W.find(Ie=>Ie.email.trim().toLowerCase()===z[0]?.toLowerCase());if(ye?.resourceId)return ye.resourceId}return Vt?.id},[Vt?.id,W,G,z]),Dn=E.useCallback(async()=>{if(C==="compose"){if(!jn||!D){He(null);return}if(Object.keys(F).length&&!kN(F,H,y)){He(null);return}le(!0),Ke(null);try{const ye=await i({resourceId:jn,templateId:D.id,rowId:kn,input:Object.keys(F).length?H:void 0});He(ye)}catch(ye){He(null),Ke(ye instanceof Error?ye.message:"Preview failed")}finally{le(!1)}}},[H,i,jn,kn,F,C,D]);E.useEffect(()=>{const ye=window.setTimeout(()=>{Dn()},280);return()=>window.clearTimeout(ye)},[Dn]);const Tr=ye=>{const Ie=W.find(I=>I.email.trim().toLowerCase()===ye.toLowerCase());return Ie?.resourceId?[Ie.resourceId]:N.map(I=>I.id)},js=async()=>{if(!(!Yt||!D||N.length===0)){De(!0),Ke(null),ht(null);try{const ye=Object.keys(F).length?H:void 0;if(Y==="later"){if(!l)throw new Error("Scheduling is not available.");const Ie=new Date(be).toISOString();if(G==="all")for(const I of N)await l({resourceId:I.id,templateId:D.id,input:ye,audience:{mode:"all"},sendAt:Ie});else{const I=new Map;for(const B of z)for(const U of Tr(B)){const se=I.get(U)??[];se.push(B),I.set(U,se)}for(const[B,U]of I)await l({resourceId:B,templateId:D.id,input:ye,audience:{mode:"emails",emails:U},sendAt:Ie})}ht(`Scheduled for ${yee(Ie)}.`)}else{let Ie=0,I=0;if(G==="all")for(const B of N){const U=await o({resourceId:B.id,templateId:D.id,input:ye,audience:{mode:"all"}});Ie+=U.sent,I+=U.failed}else{const B=new Map;for(const U of z)for(const se of Tr(U)){const oe=B.get(se)??[];oe.push(U),B.set(se,oe)}for(const[U,se]of B){const oe=await o({resourceId:U,templateId:D.id,input:ye,audience:{mode:"emails",emails:se}});Ie+=oe.sent,I+=oe.failed}}ht(I>0?`Sent ${Ie}. ${I} failed.`:`Sent ${Ie}.`)}await r()}catch(ye){Ke(ye instanceof Error?ye.message:"Request failed")}finally{De(!1)}}},Ht=async ye=>{if(u){De(!0),Ke(null);try{await u(ye),await r()}catch(Ie){Ke(Ie instanceof Error?Ie.message:"Cancel failed")}finally{De(!1)}}},pr=async ye=>{d&&(await d(ye),await r())},Gn=async ye=>{h&&(await h(ye),await r())},ds=Object.entries(F).filter(([ye])=>_2(ye,F,H,y)),rr=(ye,Ie)=>{Z(I=>{let B={...I,[ye]:Ie};if(ye==="preset"&&typeof Ie=="string"){B=mee(B,Ie,y,F);const U=Ie==="drop_live"||Ie==="restock"||Ie==="promo"||bk(Ie,y)||y.some(oe=>`library:${oe.id}`===Ie&&(oe.kind==="promo"||(oe.productIds?.length??0)>0)),se=Array.isArray(B.productIds)?B.productIds:[];U&&se.length===0&&b[0]&&F.productIds&&(B={...B,productIds:[b[0].id]})}if(ye==="discountId"&&typeof Ie=="string"){const U=x.find(se=>se.id===Ie);U&&(B={...B,discountCode:U.code??B.discountCode??"",discountOffer:U.offerLabel??U.label??B.discountOffer??"",discountExpires:U.expiresLabel??B.discountExpires??""})}return B})};return g.length===0?m.jsxs("div",{className:"vertebr-emails",children:[m.jsx("div",{className:"vertebr-panel-head",children:m.jsx("h2",{children:t.label})}),m.jsxs("div",{className:"vertebr-empty",children:["No mail-enabled resources yet. Opt a resource in with"," ",m.jsx("code",{children:'mail: ["sendEmail"]'}),"."]})]}):m.jsxs("div",{className:"vertebr-emails",children:[m.jsxs("div",{className:"vertebr-panel-head",children:[m.jsx("h2",{children:t.label}),m.jsx("div",{className:"vertebr-panel-head-actions",children:m.jsx("button",{type:"button",className:"vertebr-btn",onClick:()=>{r()},disabled:e||me,children:e?"Refreshing…":"Refresh"})})]}),C==="compose"?m.jsxs("div",{className:"vertebr-emails-layout",children:[m.jsxs("form",{className:"vertebr-emails-compose",onSubmit:ye=>{ye.preventDefault(),js()},children:[m.jsxs("div",{className:"vertebr-emails-fields",children:[m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Audience"}),m.jsx(rg,{options:A,value:R,disabled:me,placeholder:"Select audiences…",emptyLabel:"No audiences",onChange:ye=>{if(ye.length===0&&g[0]){_([g[0].id]);return}_(ye)}})]}),m.jsxs("div",{className:"vertebr-emails-segment",role:"group","aria-label":"Scope",children:[m.jsx("button",{type:"button","data-active":G==="all"?"true":void 0,onClick:()=>ae("all"),children:"Entire list"}),m.jsx("button",{type:"button","data-active":G==="emails"?"true":void 0,onClick:()=>ae("emails"),children:"Specific emails"})]}),G==="emails"?m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Emails"}),m.jsx(qQ,{options:W,value:z,loading:pe,disabled:me,onChange:L})]}):null,m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Template"}),m.jsx("select",{value:D?.id??"",onChange:ye=>P(ye.target.value),children:M.map(ye=>m.jsx("option",{value:ye.id,children:ye.label},ye.id))})]}),ds.map(([ye,Ie])=>{const I=dee(ye,Ie);return m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:Ie.label??ye}),Ie.type==="enum"?m.jsx(mk,{id:`emails-${ye}`,value:H[ye],field:Ie,onChange:B=>rr(ye,B)}):Ie.type==="enum[]"?m.jsx(rg,{options:(Ie.options??[]).map(B=>{const U=ye==="productIds"?b.find(se=>se.id===B):void 0;return{id:B,label:Ie.optionLabels?.[B]??B,secondary:U?.priceLabel,imageUrl:U?.imageUrl}}),value:vee(H[ye]),disabled:me,placeholder:ye==="productIds"?"Add products with photos…":`Select ${Ie.label??ye}…`,emptyLabel:"Nothing available",onChange:B=>rr(ye,B)}):I?m.jsx("textarea",{rows:6,value:Fc(H[ye]),onChange:B=>rr(ye,B.target.value)}):m.jsx("input",{type:"text",value:Fc(H[ye]),onChange:B=>rr(ye,B.target.value)})]},ye)}),m.jsxs("div",{className:"vertebr-emails-segment",role:"group","aria-label":"When",children:[m.jsx("button",{type:"button","data-active":Y==="now"?"true":void 0,onClick:()=>he("now"),children:"Send now"}),m.jsx("button",{type:"button","data-active":Y==="later"?"true":void 0,disabled:!t.canSchedule||!l,onClick:()=>he("later"),children:"Schedule"})]}),Y==="later"?m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:"Send at"}),m.jsx("input",{type:"datetime-local",value:be,onChange:ye=>Me(ye.target.value)})]}):null,Be?m.jsx("p",{className:"vertebr-mail-compose-error",children:Be}):null,mt?m.jsx("p",{className:"vertebr-emails-notice",children:mt}):null]}),m.jsx("div",{className:"vertebr-mail-compose-foot",children:m.jsx("button",{type:"submit",className:"vertebr-btn vertebr-btn-primary",disabled:!Yt,children:me?Y==="later"?"Scheduling…":"Sending…":Y==="later"?"Schedule email":G==="all"?"Send to list":"Send"})})]}),m.jsx("div",{className:"vertebr-emails-side",children:m.jsxs("div",{className:"vertebr-mail-preview",children:[m.jsxs("div",{className:"vertebr-mail-preview-meta",children:[m.jsxs("p",{children:[m.jsx("span",{children:"To"}),m.jsx("strong",{children:Ce?gee(Ce.to):G==="all"?N.length===0?"—":N.length===1?`Everyone on ${N[0]?.label}`:`Everyone on ${N.length} lists`:z.length>0?z.length===1?z[0]:`${z.length} selected`:"—"})]}),m.jsxs("p",{children:[m.jsx("span",{children:"Subject"}),m.jsx("strong",{children:Ce?.subject??(Ee?"Updating…":"—")})]})]}),m.jsx("div",{className:"vertebr-mail-preview-stage",children:m.jsx("div",{className:"vertebr-mail-preview-frame",children:Ce?.html?m.jsx("iframe",{title:"Email preview",sandbox:"",srcDoc:Ce.html}):Ce?.text?m.jsx("pre",{children:Ce.text}):m.jsx("div",{className:"vertebr-mail-preview-empty",children:Ee?"Rendering host template…":"Pick an audience and template to preview."})})})]})})]}):null,C==="templates"?m.jsx(oee,{templates:t.templates,library:y,products:b,discounts:x,canLibrary:t.canLibrary,busy:me,previewResourceId:t.audiences[0]?.id,previewTemplateId:t.templates.find(ye=>ye.id==="sendEmail")?.id??t.templates[0]?.id,onPreview:i,onSaveLibrary:d?pr:void 0,onDeleteLibrary:h?Gn:void 0}):null,C==="activity"?m.jsx(XQ,{campaigns:t.campaigns,history:S,canSchedule:t.canSchedule,canHistory:t.canHistory,busy:me,onCancel:u?Ht:void 0}):null]})}function wee(t){return`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@400;600;700&display=swap`}function A2({open:t,title:e,subtitle:n,family:r,files:s,googleFamily:i,bodyWeight:o,headingWeight:l,onClose:u,onConfirm:d,confirmLabel:h="Use this font"}){const g=E.useId().replace(/:/g,""),y=E.useMemo(()=>s?.length?tO({family:r,files:s}):"",[s,r,e]);if(E.useEffect(()=>{if(!t)return;let S=null;return i&&!s?.length&&(S=document.createElement("link"),S.rel="stylesheet",S.href=wee(i),document.head.appendChild(S)),()=>{S?.remove()}},[t,i,s?.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??s?.find(S=>S.weight>=400&&S.weight<600)?.weight??s?.[0]?.weight??400,x=l??s?.find(S=>S.weight>=600)?.weight??s?.[s.length-1]?.weight??700;return m.jsxs("div",{className:"vertebr-font-preview-modal-backdrop",onClick:u,children:[y?m.jsx("style",{id:g,dangerouslySetInnerHTML:{__html:y}}):null,m.jsxs("div",{className:"vertebr-font-preview-modal",role:"dialog","aria-modal":"true","aria-labelledby":`${g}-title`,onClick:S=>S.stopPropagation(),children:[m.jsxs("div",{className:"vertebr-font-preview-modal-head",children:[m.jsxs("div",{children:[m.jsx("h3",{id:`${g}-title`,children:e}),n?m.jsx("p",{children:n}):null]}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:u,children:"Close"})]}),m.jsx("div",{className:"vertebr-font-preview-modal-body",children:m.jsx(Ap,{family:r,bodyWeight:b,headingWeight:x})}),d?m.jsxs("div",{className:"vertebr-font-preview-modal-actions",children:[m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:u,children:"Cancel"}),m.jsx("button",{type:"button",className:"vertebr-btn",onClick:d,children:h})]}):null]})]})}function See({disabled:t,existingFamilies:e,onImport:n}){const[r,s]=E.useState(""),[i,o]=E.useState(null),[l,u]=E.useState(null),[d,h]=E.useState(null),g=E.useMemo(()=>{const b=r.trim().toLowerCase();return b?l_.filter(x=>x.family.toLowerCase().includes(b)||x.category.includes(b)):l_},[r]),y=async b=>{if(!(t||i)){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 m.jsxs("section",{className:"vertebr-google-fonts",children:[m.jsxs("div",{className:"vertebr-google-fonts-head",children:[m.jsxs("div",{children:[m.jsx("h3",{children:"Google Fonts"}),m.jsx("p",{children:"Browse and add open-source fonts to your library."})]}),m.jsx("input",{type:"search",className:"vertebr-google-fonts-search",placeholder:"Search fonts…",value:r,onChange:b=>s(b.target.value)})]}),l?m.jsx("div",{className:"vertebr-error-inline",children:l}):null,m.jsx("div",{className:"vertebr-google-fonts-grid-scroll",children:m.jsx("div",{className:"vertebr-google-fonts-grid",children:g.map(b=>{const x=e.includes(b.family.toLowerCase());return m.jsxs("article",{className:"vertebr-google-fonts-card",children:[m.jsxs("button",{type:"button",className:"vertebr-google-fonts-preview-btn",onClick:()=>h(b),title:`Preview ${b.family}`,children:[m.jsxs("div",{className:"vertebr-google-fonts-card-copy",children:[m.jsx("strong",{children:b.family}),m.jsx("span",{children:b.category.replace("-"," ")}),m.jsx("span",{children:b.weights.join(", ")})]}),m.jsx("span",{className:"vertebr-font-library-preview-hint",children:"Click to preview"})]}),m.jsx("button",{type:"button",className:"vertebr-btn",disabled:t||x||i===b.family,onClick:()=>{y(b)},children:x?"In library":i===b.family?"Adding…":"Add to library"})]},b.family)})})}),m.jsx(A2,{open:d!=null,title:d?.family??"Font preview",subtitle:d?`${d.category.replace("-"," ")} · weights ${d.weights.join(", ")}`:void 0,family:d?.family??"",googleFamily:d?.family,onClose:()=>h(null),onConfirm:d&&!e.includes(d.family.toLowerCase())?()=>{y(d)}:void 0,confirmLabel:d&&e.includes(d.family.toLowerCase())?"Already in library":"Add to library"})]})}function kee(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 Cee({label:t="Font Library",data:e,loading:n,onRefresh:r,onUpload:s,onImportGoogle:i,onDelete:o}){const[l,u]=E.useState(null),d={field:"fonts",accept:e.accept,maxBytes:e.maxBytes};return m.jsxs("div",{className:"vertebr-font-library",children:[m.jsx(XO,{items:e.items}),m.jsxs("div",{className:"vertebr-panel-head",children:[m.jsx("h2",{children:t}),m.jsxs("div",{className:"vertebr-font-library-head-actions",children:[m.jsx("span",{className:"vertebr-count",children:e.items.length}),r?m.jsx("button",{type:"button",className:"vertebr-btn",onClick:r,disabled:n,children:n?"Refreshing…":"Refresh"}):null]})]}),m.jsxs("div",{className:"vertebr-font-library-body",children:[e.canImportGoogle&&i?m.jsx(See,{disabled:n,onImport:i,existingFamilies:e.items.map(h=>h.family.toLowerCase())}):null,m.jsx(Wc,{meta:d,multiple:!0,label:"Drop .woff2 / .woff / .ttf files here or browse to upload",onUpload:async h=>{for(const g of h){const y=g.name.replace(/\.[^.]+$/,""),b=/(?:^|[\s_-])(100|200|300|400|500|600|700|800|900)(?:[\s_-]|$)/i.exec(y),x=y.replace(/(?:^|[\s_-])(100|200|300|400|500|600|700|800|900)(?:[\s_-]|$)/gi," ").replace(/[\s_-]+/g," ").trim();await s([g],{family:x||void 0,weight:b?Number(b[1]):400})}}}),m.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?m.jsx("div",{className:"vertebr-empty",children:"No fonts in the library yet."}):m.jsx("div",{className:"vertebr-font-library-grid",children:e.items.map(h=>m.jsxs("article",{className:"vertebr-font-library-card",children:[m.jsxs("button",{type:"button",className:"vertebr-font-library-preview-btn",onClick:()=>u(h),title:`Preview ${h.label}`,children:[m.jsxs("div",{className:"vertebr-font-library-preview",style:kee(h),children:[m.jsx("span",{className:"vertebr-font-library-ag",children:"Ag"}),m.jsx("p",{children:"The quick brown fox jumps over the lazy dog."})]}),m.jsx("span",{className:"vertebr-font-library-preview-hint",children:"Click to preview"})]}),m.jsxs("div",{className:"vertebr-font-library-meta",children:[m.jsx("strong",{title:h.label,children:h.label}),m.jsxs("span",{children:[h.source==="google"?"Google Fonts":"Upload"," ·"," ",h.files.length," file",h.files.length===1?"":"s"]}),m.jsx("code",{children:h.id})]}),e.canDelete&&o?m.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))})]}),m.jsx(A2,{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 Eee({label:t="Gallery",items:e,accept:n,maxBytes:r,canDelete:s,loading:i,onRefresh:o,onUpload:l,onDelete:u}){const d={field:"gallery",accept:n,maxBytes:r};return m.jsxs("div",{className:"vertebr-gallery",children:[m.jsxs("div",{className:"vertebr-panel-head",children:[m.jsx("h2",{children:t}),m.jsxs("div",{className:"vertebr-gallery-head-actions",children:[m.jsx("span",{className:"vertebr-count",children:e.length}),o?m.jsx("button",{type:"button",className:"vertebr-btn",onClick:o,disabled:i,children:i?"Refreshing…":"Refresh"}):null]})]}),m.jsxs("div",{className:"vertebr-gallery-body",children:[m.jsx(Wc,{meta:d,multiple:!0,label:"Drop images here or browse to add to the gallery",onUpload:l}),e.length===0?m.jsx("div",{className:"vertebr-empty",children:"No images in the gallery yet."}):m.jsx("div",{className:"vertebr-gallery-grid",children:e.map(h=>m.jsxs("article",{className:"vertebr-gallery-card",children:[m.jsx("a",{className:"vertebr-gallery-thumb",href:h.url,target:"_blank",rel:"noreferrer",title:h.name??h.url,children:m.jsx("img",{src:h.url,alt:h.name??"",loading:"lazy"})}),m.jsxs("div",{className:"vertebr-gallery-meta",children:[m.jsx("strong",{title:h.name??h.id,children:h.name??h.id}),m.jsx("a",{href:h.url,target:"_blank",rel:"noreferrer",children:h.url.replace(/^https?:\/\//i,"")})]}),s&&u?m.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 w0=3;function Tee(t){const e=Math.max(0,...t),n=Math.min(0,...t),r=e-n||1;return{min:n,max:e,span:r}}function _ee(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)),s=n/r;return(s<=1?1:s<=2?2:s<=2.5?2.5:s<=5?5:10)*r}function Aee(t,e){if(e==="usd")return[0,t/2,t];const n=t<=4||t<=10?2:t/4,r=[];for(let s=0;s<t-1e-9;s+=n)r.push(s);return r.push(t),r}function Md(t){return t[0]?t.map((n,r)=>`${r===0?"M":"L"} ${n.x} ${n.y}`).join(" "):""}function Ree({series:t,tone:e="neutral"}){if(t.length<2)return null;const n=72,r=28,{min:s,span:i}=Tee(t),o=t.map((d,h)=>({x:h/(t.length-1)*n,y:r-(d-s)/i*(r-2)-1})),l=o[o.length-1],u=l?`${Md(o)} L ${l.x} ${r} L 0 ${r} Z`:"";return m.jsxs("svg",{className:"vertebr-sparkline","data-tone":e,viewBox:`0 0 ${n} ${r}`,width:n,height:r,"aria-hidden":"true",children:[u?m.jsx("path",{d:u,fill:"currentColor",opacity:"0.16"}):null,m.jsx("path",{d:Md(o),fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round",strokeLinecap:"round"})]})}function Nee(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 Mee(){return m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:m.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function Oee(){return m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:m.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 jee({charts:t,value:e,onChange:n}){return m.jsxs(Fg,{value:e,onValueChange:n,children:[m.jsxs(qg,{className:"vertebr-select-trigger vertebr-chart-series","aria-label":"Chart series",children:[m.jsx("span",{className:"vertebr-select-value",children:m.jsx(Gg,{})}),m.jsx(Wg,{className:"vertebr-select-icon",children:m.jsx(Mee,{})})]}),m.jsx(Kg,{children:m.jsx(Zg,{className:"vertebr-select-content",position:"popper",sideOffset:6,children:m.jsx(Xg,{className:"vertebr-select-viewport",children:t.map(r=>m.jsxs(Jg,{value:r.id,className:"vertebr-select-item",children:[m.jsx(Qg,{children:r.label}),m.jsx(ey,{className:"vertebr-select-check",children:m.jsx(Oee,{})})]},r.id))})})})]})}function Dee({charts:t,chartId:e,onChartIdChange:n,compareLabel:r="Previous period"}){const s=t.find(le=>le.id===e)??t[0],i=s?.unit,o=E.useMemo(()=>t.filter(le=>le.id!==s?.id&&(le.unit??"count")===(i??"count")),[t,s?.id,i]),l=o.length>0,[u,d]=E.useState("period"),[h,g]=E.useState([]),[y,b]=E.useState(null);if(E.useEffect(()=>{b(null)},[s?.id,u,h.join("|")]),E.useEffect(()=>{!l&&u==="metrics"&&d("period")},[l,u]),E.useEffect(()=>{g(le=>le.filter(me=>o.some(De=>De.id===me)))},[o]),!s)return m.jsx("article",{className:"vertebr-chart",children:m.jsx("p",{className:"vertebr-chart-empty",children:"No activity in this window."})});const x=u==="metrics"&&l,S=o.filter(le=>h.includes(le.id)).slice(0,w0-1),k=x?[s,...S]:[s],C=s.points.map(le=>le.label),A=960,R=220,_={top:12,right:16,bottom:28,left:52},N=A-_.left-_.right,M=R-_.top-_.bottom,O=k.flatMap(le=>le.points.map(me=>me.value)),P=x?[]:(s.comparePoints??[]).map(le=>le.value),D=!x&&P.length>0,F=_ee(Math.max(0,...O,...P),s.unit),te=(le,me)=>_.left+(me<=1?N/2:le/(me-1)*N),H=k.map(le=>le.points.map((me,De)=>{const Be=te(De,C.length||le.points.length),Ke=_.top+M-Math.max(0,me.value)/F*M;return{x:Be,y:Ke,value:me.value,label:me.label}})),Z=H[0]??[],G=P.map((le,me)=>{const De=te(me,C.length||P.length),Be=_.top+M-Math.max(0,le)/F*M;return{x:De,y:Be,value:le,label:s.comparePoints?.[me]?.label??""}}),ae=Aee(F,s.unit),z=Math.max(1,Math.ceil(Z.length/7)),L=s.points.reduce((le,me)=>le+me.value,0),W=Z.length===0||k.every(le=>le.points.every(me=>me.value===0)),ce=y??(Z.length>0?Z.length-1:null),pe=`vb-chart-fill-${s.id}`,$=le=>Nee(le,s.unit),Y=D&&ce!=null?G[ce]:void 0,he=Md(Z),be=Z[0],Me=Z[Z.length-1],Ce=_.top+M,He=!x&&be&&Me?`${he} L ${Me.x} ${Ce} L ${be.x} ${Ce} Z`:"",Ee=le=>{g(me=>me.includes(le)?me.filter(De=>De!==le):me.length>=w0-1?me:[...me,le])};return m.jsxs("article",{className:"vertebr-chart","data-empty":W?"true":void 0,"data-mode":x?"metrics":"period",children:[m.jsxs("div",{className:"vertebr-chart-head",children:[m.jsxs("div",{className:"vertebr-chart-head-start",children:[t.length>1?m.jsx(jee,{charts:t,value:s.id,onChange:n}):m.jsx("p",{className:"vertebr-chart-kicker",children:s.label}),l?m.jsxs("div",{className:"vertebr-chart-mode",role:"group","aria-label":"Chart mode",children:[m.jsx("button",{type:"button",className:"vertebr-chart-mode-btn","data-active":u==="period"?"true":void 0,onClick:()=>d("period"),children:"vs previous"}),m.jsx("button",{type:"button",className:"vertebr-chart-mode-btn","data-active":u==="metrics"?"true":void 0,onClick:()=>{d("metrics"),g(le=>le.length>0?le:o.slice(0,1).map(me=>me.id))},children:"Compare metrics"})]}):null,x?m.jsx("div",{className:"vertebr-chart-metric-toggles",children:o.map(le=>{const me=h.includes(le.id),De=!me&&S.length>=w0-1;return m.jsx("button",{type:"button",className:"vertebr-chart-metric-toggle","data-on":me?"true":void 0,disabled:De,onClick:()=>Ee(le.id),children:le.label},le.id)})}):D?m.jsxs("p",{className:"vertebr-chart-legend",children:[m.jsxs("span",{children:[m.jsx("i",{"data-series":"current"}),"Current"]}),m.jsxs("span",{children:[m.jsx("i",{"data-series":"previous"}),r]})]}):null,x?m.jsx("p",{className:"vertebr-chart-legend",children:k.map((le,me)=>m.jsxs("span",{children:[m.jsx("i",{"data-series":`m${me}`}),le.label]},le.id))}):null]}),m.jsx("p",{className:"vertebr-chart-total",children:x?"—":$(L)})]}),Z.length===0?m.jsx("p",{className:"vertebr-chart-empty",children:"No activity in this window."}):m.jsxs("div",{className:"vertebr-chart-plot",children:[m.jsxs("svg",{className:"vertebr-chart-svg",viewBox:`0 0 ${A} ${R}`,role:"img","aria-label":x?k.map(le=>le.label).join(" vs "):s.label,onMouseLeave:()=>b(null),onMouseMove:le=>{const me=le.currentTarget.getBoundingClientRect(),De=(le.clientX-me.left)/me.width*A;let Be=0,Ke=1/0;Z.forEach((mt,ht)=>{const Wt=Math.abs(mt.x-De);Wt<Ke&&(Ke=Wt,Be=ht)}),b(Be)},children:[m.jsx("defs",{children:m.jsxs("linearGradient",{id:pe,x1:"0",y1:"0",x2:"0",y2:"1",children:[m.jsx("stop",{offset:"0%",stopColor:"var(--vb-accent)",stopOpacity:"0.32"}),m.jsx("stop",{offset:"100%",stopColor:"var(--vb-accent)",stopOpacity:"0"})]})}),ae.map((le,me)=>{const De=_.top+M-le/F*M;return m.jsxs("g",{children:[m.jsx("line",{className:le===0?"vertebr-chart-baseline":"vertebr-chart-grid",x1:_.left,x2:A-_.right,y1:De,y2:De}),m.jsx("text",{className:"vertebr-chart-axis",x:_.left-8,y:De+3,textAnchor:"end",children:$(le)})]},`${le}-${me}`)}),He?m.jsx("path",{className:"vertebr-chart-area",d:He,fill:`url(#${pe})`}):null,D?m.jsx("path",{className:"vertebr-chart-line-compare",d:Md(G),fill:"none"}):null,H.map((le,me)=>m.jsx("path",{className:me===0&&!x?"vertebr-chart-line":"vertebr-chart-line-metric","data-series":x||me>0?`m${me}`:void 0,d:Md(le),fill:"none"},k[me]?.id??me)),ce!=null?m.jsx("line",{className:"vertebr-chart-crosshair",x1:Z[ce]?.x,x2:Z[ce]?.x,y1:_.top,y2:_.top+M}):null,Z.map((le,me)=>me%z===0||me===Z.length-1?m.jsx("text",{className:"vertebr-chart-axis",x:le.x,y:R-8,textAnchor:me===0?"start":me===Z.length-1?"end":"middle",children:le.label},`label-${le.label}-${me}`):null),H.map((le,me)=>le.map((De,Be)=>ce===Be?m.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:De.x,cy:De.y,r:me===0?4.2:3.4},`dot-${k[me]?.id}-${Be}`):null)),Y?m.jsx("circle",{className:"vertebr-chart-dot-compare",cx:Y.x,cy:Y.y,r:3.4}):null]}),ce!=null&&Z[ce]?m.jsxs("div",{className:"vertebr-chart-tooltip",style:{left:`${Math.min(88,Math.max(12,Z[ce].x/A*100))}%`},children:[m.jsx("span",{children:Z[ce].label}),x?k.map((le,me)=>m.jsxs("strong",{className:"vertebr-chart-tooltip-row","data-series":`m${me}`,children:[le.label," ",$(le.points[ce]?.value??0)]},le.id)):m.jsxs(m.Fragment,{children:[m.jsx("strong",{children:$(Z[ce].value)}),Y?m.jsxs("span",{className:"vertebr-chart-tooltip-compare",children:["Prev ",$(Y.value),Y.label?` · ${Y.label}`:""]}):null]})]}):null]})]})}function Iee(t){const e=Math.abs(t),n=e>=10?e.toFixed(0):e.toFixed(1);return t>0?`+${n}%`:t<0?`−${n}%`:"0%"}function Lee(t){return t>0?"up":t<0?"down":"flat"}function CN({value:t}){return t==null?m.jsx("span",{className:"vertebr-metrics-table-empty",children:"—"}):m.jsx("span",{className:"vertebr-metric-delta","data-dir":Lee(t),children:Iee(t)})}function Pee(){return m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:m.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 zee(){return m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:m.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function $ee({value:t,onChange:e,disabled:n}){return m.jsxs(Fg,{value:t,onValueChange:r=>e(r),disabled:n,children:[m.jsxs(qg,{className:"vertebr-select-trigger vertebr-metrics-range","aria-label":"Metrics range",children:[m.jsx("span",{className:"vertebr-select-value",children:m.jsx(Gg,{})}),m.jsx(Wg,{className:"vertebr-select-icon",children:m.jsx(zee,{})})]}),m.jsx(Kg,{children:m.jsx(Zg,{className:"vertebr-select-content",position:"popper",sideOffset:6,children:m.jsx(Xg,{className:"vertebr-select-viewport",children:nO.map(r=>m.jsxs(Jg,{value:r.id,className:"vertebr-select-item",children:[m.jsx(Qg,{children:r.label}),m.jsx(ey,{className:"vertebr-select-check",children:m.jsx(Pee,{})})]},r.id))})})})]})}function Bee({label:t="Overview",windowLabel:e,compareLabel:n,metrics:r,charts:s=[],range:i,onRangeChange:o,onRefresh:l,loading:u}){const d=r.filter(R=>R.featured).slice(0,4),h=d.length>0?d:r.slice(0,4),g=new Set(h.map(R=>R.id)),y=r.filter(R=>!g.has(R.id)),[b,x]=E.useState(!0),S=E.useMemo(()=>new Set(s.map(R=>R.id)),[s]),[k,C]=E.useState(()=>s[0]?.id??""),A=S.has(k)?k:s[0]?.id??"";return m.jsxs("div",{className:"vertebr-metrics",children:[m.jsxs("div",{className:"vertebr-panel-head",children:[m.jsxs("div",{children:[m.jsx("h2",{children:t}),e?m.jsx("p",{className:"vertebr-metrics-window",children:e}):null]}),o||l?m.jsxs("div",{className:"vertebr-panel-head-actions",children:[o&&i?m.jsx($ee,{value:i,onChange:o,disabled:u}):null,l?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:l,disabled:u,children:u?"Refreshing…":"Refresh"}):null]}):null]}),r.length===0&&s.length===0?m.jsx("div",{className:"vertebr-empty",children:"No metrics registered yet."}):m.jsxs("div",{className:"vertebr-metrics-body",children:[h.length>0?m.jsx("section",{className:"vertebr-metrics-block",children:m.jsx("div",{className:"vertebr-metrics-kpis",children:h.map(R=>{const _=S.has(R.id);return m.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:_?N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),C(R.id))}:void 0,children:[m.jsxs("div",{className:"vertebr-kpi-top",children:[m.jsx("p",{className:"vertebr-metric-label",children:R.label}),R.series&&R.series.length>1?m.jsx(Ree,{series:R.series,tone:R.tone}):null]}),m.jsx("p",{className:"vertebr-kpi-value",children:R.value}),m.jsxs("div",{className:"vertebr-kpi-foot",children:[R.delta!=null?m.jsx(CN,{value:R.delta}):null,R.hint?m.jsx("span",{className:"vertebr-metric-hint",children:R.hint}):null]})]},R.id)})})}):null,s.length>0&&A?m.jsx("section",{className:"vertebr-metrics-block",children:m.jsx(Dee,{charts:s,chartId:A,onChartIdChange:C,compareLabel:n})}):null,y.length>0?m.jsx("section",{className:"vertebr-metrics-block",children:m.jsxs("div",{className:"vertebr-metrics-table-wrap","data-collapsed":b?void 0:"true",children:[m.jsxs("button",{type:"button",className:"vertebr-metrics-table-head","aria-expanded":b,onClick:()=>x(R=>!R),children:[m.jsx("p",{className:"vertebr-chart-kicker",children:"Breakdown"}),m.jsx("span",{className:"vertebr-metrics-chevron","aria-hidden":"true"})]}),b?m.jsxs("table",{className:"vertebr-table vertebr-metrics-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"Metric"}),m.jsx("th",{children:"Value"}),m.jsx("th",{children:"Change"}),m.jsx("th",{children:"Notes"})]})}),m.jsx("tbody",{children:y.map(R=>m.jsxs("tr",{"data-tone":R.tone??"neutral",children:[m.jsxs("td",{children:[m.jsx("span",{className:"vertebr-metrics-table-label",children:R.label}),R.section?m.jsx("span",{className:"vertebr-metrics-table-section",children:R.section}):null]}),m.jsx("td",{className:"vertebr-metrics-table-value",children:R.value}),m.jsx("td",{children:m.jsx(CN,{value:R.delta})}),m.jsx("td",{className:"vertebr-metrics-table-notes",children:R.hint??"—"})]},R.id))})]}):null]})}):null]})]})}function Vo(t,e){return typeof t=="function"?t(e):t}function Hr(t,e){return n=>{e.setState(r=>({...r,[t]:Vo(n,r[t])}))}}function ty(t){return t instanceof Function}function Vee(t){return Array.isArray(t)&&t.every(e=>typeof e=="number")}function Hee(t,e){const n=[],r=s=>{s.forEach(i=>{n.push(i);const o=e(i);o!=null&&o.length&&r(o)})};return r(t),n}function Xe(t,e,n){let r=[],s;return i=>{let o;n.key&&n.debug&&(o=Date.now());const l=t(i);if(!(l.length!==r.length||l.some((h,g)=>r[g]!==h)))return s;r=l;let d;if(n.key&&n.debug&&(d=Date.now()),s=e(...l),n==null||n.onChange==null||n.onChange(s),n.key&&n.debug&&n!=null&&n.debug()){const h=Math.round((Date.now()-o)*100)/100,g=Math.round((Date.now()-d)*100)/100,y=g/16,b=(x,S)=>{for(x=String(x);x.length<S;)x=" "+x;return x};console.info(`%c⏱ ${b(g,5)} /${b(h,5)} ms`,`
|
|
327
|
+
font-size: .6rem;
|
|
328
|
+
font-weight: bold;
|
|
329
|
+
color: hsl(${Math.max(0,Math.min(120-120*y,120))}deg 100% 31%);`,n?.key)}return s}}function Je(t,e,n,r){return{debug:()=>{var s;return(s=t?.debugAll)!=null?s:t[e]},key:!1,onChange:r}}function Uee(t,e,n,r){const s=()=>{var o;return(o=i.getValue())!=null?o:t.options.renderFallbackValue},i={id:`${e.id}_${n.id}`,row:e,column:n,getValue:()=>e.getValue(r),renderValue:s,getContext:Xe(()=>[t,n,e,i],(o,l,u,d)=>({table:o,column:l,row:u,cell:d,getValue:d.getValue,renderValue:d.renderValue}),Je(t.options,"debugCells"))};return t._features.forEach(o=>{o.createCell==null||o.createCell(i,n,e,t)},{}),i}function Fee(t,e,n,r){var s,i;const l={...t._getDefaultColumnDef(),...e},u=l.accessorKey;let d=(s=(i=l.id)!=null?i:u?typeof String.prototype.replaceAll=="function"?u.replaceAll(".","_"):u.replace(/\./g,"_"):void 0)!=null?s:typeof l.header=="string"?l.header:void 0,h;if(l.accessorFn?h=l.accessorFn:u&&(u.includes(".")?h=y=>{let b=y;for(const S of u.split(".")){var x;b=(x=b)==null?void 0:x[S]}return b}:h=y=>y[l.accessorKey]),!d)throw new Error;let g={id:`${String(d)}`,accessorFn:h,parent:r,depth:n,columnDef:l,columns:[],getFlatColumns:Xe(()=>[!0],()=>{var y;return[g,...(y=g.columns)==null?void 0:y.flatMap(b=>b.getFlatColumns())]},Je(t.options,"debugColumns")),getLeafColumns:Xe(()=>[t._getOrderColumnsFn()],y=>{var b;if((b=g.columns)!=null&&b.length){let x=g.columns.flatMap(S=>S.getLeafColumns());return y(x)}return[g]},Je(t.options,"debugColumns"))};for(const y of t._features)y.createColumn==null||y.createColumn(g,t);return g}const Xn="debugHeaders";function EN(t,e,n){var r;let i={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(i),o},getContext:()=>({table:t,header:i,column:e})};return t._features.forEach(o=>{o.createHeader==null||o.createHeader(i,t)}),i}const qee={createTable:t=>{t.getHeaderGroups=Xe(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,r,s)=>{var i,o;const l=(i=r?.map(g=>n.find(y=>y.id===g)).filter(Boolean))!=null?i:[],u=(o=s?.map(g=>n.find(y=>y.id===g)).filter(Boolean))!=null?o:[],d=n.filter(g=>!(r!=null&&r.includes(g.id))&&!(s!=null&&s.includes(g.id)));return pp(e,[...l,...d,...u],t)},Je(t.options,Xn)),t.getCenterHeaderGroups=Xe(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,r,s)=>(n=n.filter(i=>!(r!=null&&r.includes(i.id))&&!(s!=null&&s.includes(i.id))),pp(e,n,t,"center")),Je(t.options,Xn)),t.getLeftHeaderGroups=Xe(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left],(e,n,r)=>{var s;const i=(s=r?.map(o=>n.find(l=>l.id===o)).filter(Boolean))!=null?s:[];return pp(e,i,t,"left")},Je(t.options,Xn)),t.getRightHeaderGroups=Xe(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.right],(e,n,r)=>{var s;const i=(s=r?.map(o=>n.find(l=>l.id===o)).filter(Boolean))!=null?s:[];return pp(e,i,t,"right")},Je(t.options,Xn)),t.getFooterGroups=Xe(()=>[t.getHeaderGroups()],e=>[...e].reverse(),Je(t.options,Xn)),t.getLeftFooterGroups=Xe(()=>[t.getLeftHeaderGroups()],e=>[...e].reverse(),Je(t.options,Xn)),t.getCenterFooterGroups=Xe(()=>[t.getCenterHeaderGroups()],e=>[...e].reverse(),Je(t.options,Xn)),t.getRightFooterGroups=Xe(()=>[t.getRightHeaderGroups()],e=>[...e].reverse(),Je(t.options,Xn)),t.getFlatHeaders=Xe(()=>[t.getHeaderGroups()],e=>e.map(n=>n.headers).flat(),Je(t.options,Xn)),t.getLeftFlatHeaders=Xe(()=>[t.getLeftHeaderGroups()],e=>e.map(n=>n.headers).flat(),Je(t.options,Xn)),t.getCenterFlatHeaders=Xe(()=>[t.getCenterHeaderGroups()],e=>e.map(n=>n.headers).flat(),Je(t.options,Xn)),t.getRightFlatHeaders=Xe(()=>[t.getRightHeaderGroups()],e=>e.map(n=>n.headers).flat(),Je(t.options,Xn)),t.getCenterLeafHeaders=Xe(()=>[t.getCenterFlatHeaders()],e=>e.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),Je(t.options,Xn)),t.getLeftLeafHeaders=Xe(()=>[t.getLeftFlatHeaders()],e=>e.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),Je(t.options,Xn)),t.getRightLeafHeaders=Xe(()=>[t.getRightFlatHeaders()],e=>e.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),Je(t.options,Xn)),t.getLeafHeaders=Xe(()=>[t.getLeftHeaderGroups(),t.getCenterHeaderGroups(),t.getRightHeaderGroups()],(e,n,r)=>{var s,i,o,l,u,d;return[...(s=(i=e[0])==null?void 0:i.headers)!=null?s:[],...(o=(l=n[0])==null?void 0:l.headers)!=null?o:[],...(u=(d=r[0])==null?void 0:d.headers)!=null?u:[]].map(h=>h.getLeafHeaders()).flat()},Je(t.options,Xn))}};function pp(t,e,n,r){var s,i;let o=0;const l=function(y,b){b===void 0&&(b=1),o=Math.max(o,b),y.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 d=(y,b)=>{const x={depth:b,id:[r,`${b}`].filter(Boolean).join("_"),headers:[]},S=[];y.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 N=EN(n,R,{id:[r,b,R.id,k?.id].filter(Boolean).join("_"),isPlaceholder:_,placeholderId:_?`${S.filter(M=>M.column===R).length}`:void 0,depth:b,index:S.length});N.subHeaders.push(k),S.push(N)}x.headers.push(k),k.headerGroup=x}),u.push(x),b>0&&d(S,b-1)},h=e.map((y,b)=>EN(n,y,{depth:o,index:b}));d(h,o-1),u.reverse();const g=y=>y.filter(x=>x.column.getIsVisible()).map(x=>{let S=0,k=0,C=[0];x.subHeaders&&x.subHeaders.length?(C=[],g(x.subHeaders).forEach(R=>{let{colSpan:_,rowSpan:N}=R;S+=_,C.push(N)})):S=1;const A=Math.min(...C);return k=k+A,x.colSpan=S,x.rowSpan=k,{colSpan:S,rowSpan:k}});return g((s=(i=u[0])==null?void 0:i.headers)!=null?s:[]),u}const Gee=(t,e,n,r,s,i,o)=>{let l={id:e,index:r,original:n,depth:s,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:u=>{if(l._valuesCache.hasOwnProperty(u))return l._valuesCache[u];const d=t.getColumn(u);if(d!=null&&d.accessorFn)return l._valuesCache[u]=d.accessorFn(l.original,r),l._valuesCache[u]},getUniqueValues:u=>{if(l._uniqueValuesCache.hasOwnProperty(u))return l._uniqueValuesCache[u];const d=t.getColumn(u);if(d!=null&&d.accessorFn)return d.columnDef.getUniqueValues?(l._uniqueValuesCache[u]=d.columnDef.getUniqueValues(l.original,r),l._uniqueValuesCache[u]):(l._uniqueValuesCache[u]=[l.getValue(u)],l._uniqueValuesCache[u])},renderValue:u=>{var d;return(d=l.getValue(u))!=null?d:t.options.renderFallbackValue},subRows:[],getLeafRows:()=>Hee(l.subRows,u=>u.subRows),getParentRow:()=>l.parentId?t.getRow(l.parentId,!0):void 0,getParentRows:()=>{let u=[],d=l;for(;;){const h=d.getParentRow();if(!h)break;u.push(h),d=h}return u.reverse()},getAllCells:Xe(()=>[t.getAllLeafColumns()],u=>u.map(d=>Uee(t,l,d,d.id)),Je(t.options,"debugRows")),_getAllCellsByColumnId:Xe(()=>[l.getAllCells()],u=>u.reduce((d,h)=>(d[h.column.id]=h,d),{}),Je(t.options,"debugRows"))};for(let u=0;u<t._features.length;u++){const d=t._features[u];d==null||d.createRow==null||d.createRow(l,t)}return l},Wee={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()}}},R2=(t,e,n)=>{var r,s;const i=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((s=t.getValue(e))==null||(s=s.toString())==null||(s=s.toLowerCase())==null)&&s.includes(i))};R2.autoRemove=t=>Ns(t);const N2=(t,e,n)=>{var r;return!!(!((r=t.getValue(e))==null||(r=r.toString())==null)&&r.includes(n))};N2.autoRemove=t=>Ns(t);const M2=(t,e,n)=>{var r;return((r=t.getValue(e))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};M2.autoRemove=t=>Ns(t);const O2=(t,e,n)=>{var r;return(r=t.getValue(e))==null?void 0:r.includes(n)};O2.autoRemove=t=>Ns(t);const j2=(t,e,n)=>!n.some(r=>{var s;return!((s=t.getValue(e))!=null&&s.includes(r))});j2.autoRemove=t=>Ns(t)||!(t!=null&&t.length);const D2=(t,e,n)=>n.some(r=>{var s;return(s=t.getValue(e))==null?void 0:s.includes(r)});D2.autoRemove=t=>Ns(t)||!(t!=null&&t.length);const I2=(t,e,n)=>t.getValue(e)===n;I2.autoRemove=t=>Ns(t);const L2=(t,e,n)=>t.getValue(e)==n;L2.autoRemove=t=>Ns(t);const vk=(t,e,n)=>{let[r,s]=n;const i=t.getValue(e);return i>=r&&i<=s};vk.resolveFilterValue=t=>{let[e,n]=t,r=typeof e!="number"?parseFloat(e):e,s=typeof n!="number"?parseFloat(n):n,i=e===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(s)?1/0:s;if(i>o){const l=i;i=o,o=l}return[i,o]};vk.autoRemove=t=>Ns(t)||Ns(t[0])&&Ns(t[1]);const Ri={includesString:R2,includesStringSensitive:N2,equalsString:M2,arrIncludes:O2,arrIncludesAll:j2,arrIncludesSome:D2,equals:I2,weakEquals:L2,inNumberRange:vk};function Ns(t){return t==null||t===""}const Kee={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:t=>({columnFilters:[],...t}),getDefaultOptions:t=>({onColumnFiltersChange:Hr("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"?Ri.includesString:typeof r=="number"?Ri.inNumberRange:typeof r=="boolean"||r!==null&&typeof r=="object"?Ri.equals:Array.isArray(r)?Ri.arrIncludes:Ri.weakEquals},t.getFilterFn=()=>{var n,r;return ty(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:Ri[t.columnDef.filterFn]},t.getCanFilter=()=>{var n,r,s;return((n=t.columnDef.enableColumnFilter)!=null?n:!0)&&((r=e.options.enableColumnFilters)!=null?r:!0)&&((s=e.options.enableFilters)!=null?s:!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(s=>s.id===t.id))!=null?n:-1},t.setFilterValue=n=>{e.setColumnFilters(r=>{const s=t.getFilterFn(),i=r?.find(h=>h.id===t.id),o=Vo(n,i?i.value:void 0);if(TN(s,o,t)){var l;return(l=r?.filter(h=>h.id!==t.id))!=null?l:[]}const u={id:t.id,value:o};if(i){var d;return(d=r?.map(h=>h.id===t.id?u:h))!=null?d:[]}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=s=>{var i;return(i=Vo(e,s))==null?void 0:i.filter(o=>{const l=n.find(u=>u.id===o.id);if(l){const u=l.getFilterFn();if(TN(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 TN(t,e,n){return(t&&t.autoRemove?t.autoRemove(e,n):!1)||typeof e>"u"||typeof e=="string"&&!e}const Zee=(t,e,n)=>n.reduce((r,s)=>{const i=s.getValue(t);return r+(typeof i=="number"?i:0)},0),Yee=(t,e,n)=>{let r;return n.forEach(s=>{const i=s.getValue(t);i!=null&&(r>i||r===void 0&&i>=i)&&(r=i)}),r},Xee=(t,e,n)=>{let r;return n.forEach(s=>{const i=s.getValue(t);i!=null&&(r<i||r===void 0&&i>=i)&&(r=i)}),r},Jee=(t,e,n)=>{let r,s;return n.forEach(i=>{const o=i.getValue(t);o!=null&&(r===void 0?o>=o&&(r=s=o):(r>o&&(r=o),s<o&&(s=o)))}),[r,s]},Qee=(t,e)=>{let n=0,r=0;if(e.forEach(s=>{let i=s.getValue(t);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},ete=(t,e)=>{if(!e.length)return;const n=e.map(i=>i.getValue(t));if(!Vee(n))return;if(n.length===1)return n[0];const r=Math.floor(n.length/2),s=n.sort((i,o)=>i-o);return n.length%2!==0?s[r]:(s[r-1]+s[r])/2},tte=(t,e)=>Array.from(new Set(e.map(n=>n.getValue(t))).values()),nte=(t,e)=>new Set(e.map(n=>n.getValue(t))).size,rte=(t,e)=>e.length,S0={sum:Zee,min:Yee,max:Xee,extent:Jee,mean:Qee,median:ete,unique:tte,uniqueCount:nte,count:rte},ste={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:Hr("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 S0.sum;if(Object.prototype.toString.call(r)==="[object Date]")return S0.extent},t.getAggregationFn=()=>{var n,r;if(!t)throw new Error;return ty(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:S0[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 s;return!t.getIsGrouped()&&!t.getIsPlaceholder()&&!!((s=n.subRows)!=null&&s.length)}}};function ite(t,e,n){if(!(e!=null&&e.length)||!n)return t;const r=t.filter(i=>!e.includes(i.id));return n==="remove"?r:[...e.map(i=>t.find(o=>o.id===i)).filter(Boolean),...r]}const ote={getInitialState:t=>({columnOrder:[],...t}),getDefaultOptions:t=>({onColumnOrderChange:Hr("columnOrder",t)}),createColumn:(t,e)=>{t.getIndex=Xe(n=>[Od(e,n)],n=>n.findIndex(r=>r.id===t.id),Je(e.options,"debugColumns")),t.getIsFirstColumn=n=>{var r;return((r=Od(e,n)[0])==null?void 0:r.id)===t.id},t.getIsLastColumn=n=>{var r;const s=Od(e,n);return((r=s[s.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=Xe(()=>[t.getState().columnOrder,t.getState().grouping,t.options.groupedColumnMode],(e,n,r)=>s=>{let i=[];if(!(e!=null&&e.length))i=s;else{const o=[...e],l=[...s];for(;l.length&&o.length;){const u=o.shift(),d=l.findIndex(h=>h.id===u);d>-1&&i.push(l.splice(d,1)[0])}i=[...i,...l]}return ite(i,n,r)},Je(t.options,"debugTable"))}},k0=()=>({left:[],right:[]}),ate={getInitialState:t=>({columnPinning:k0(),...t}),getDefaultOptions:t=>({onColumnPinningChange:Hr("columnPinning",t)}),createColumn:(t,e)=>{t.pin=n=>{const r=t.getLeafColumns().map(s=>s.id).filter(Boolean);e.setColumnPinning(s=>{var i,o;if(n==="right"){var l,u;return{left:((l=s?.left)!=null?l:[]).filter(g=>!(r!=null&&r.includes(g))),right:[...((u=s?.right)!=null?u:[]).filter(g=>!(r!=null&&r.includes(g))),...r]}}if(n==="left"){var d,h;return{left:[...((d=s?.left)!=null?d:[]).filter(g=>!(r!=null&&r.includes(g))),...r],right:((h=s?.right)!=null?h:[]).filter(g=>!(r!=null&&r.includes(g)))}}return{left:((i=s?.left)!=null?i:[]).filter(g=>!(r!=null&&r.includes(g))),right:((o=s?.right)!=null?o:[]).filter(g=>!(r!=null&&r.includes(g)))}})},t.getCanPin=()=>t.getLeafColumns().some(r=>{var s,i,o;return((s=r.columnDef.enablePinning)!=null?s:!0)&&((i=(o=e.options.enableColumnPinning)!=null?o:e.options.enablePinning)!=null?i:!0)}),t.getIsPinned=()=>{const n=t.getLeafColumns().map(l=>l.id),{left:r,right:s}=e.getState().columnPinning,i=n.some(l=>r?.includes(l)),o=n.some(l=>s?.includes(l));return i?"left":o?"right":!1},t.getPinnedIndex=()=>{var n,r;const s=t.getIsPinned();return s?(n=(r=e.getState().columnPinning)==null||(r=r[s])==null?void 0:r.indexOf(t.id))!=null?n:-1:0}},createRow:(t,e)=>{t.getCenterVisibleCells=Xe(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,r,s)=>{const i=[...r??[],...s??[]];return n.filter(o=>!i.includes(o.column.id))},Je(e.options,"debugRows")),t.getLeftVisibleCells=Xe(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left],(n,r)=>(r??[]).map(i=>n.find(o=>o.column.id===i)).filter(Boolean).map(i=>({...i,position:"left"})),Je(e.options,"debugRows")),t.getRightVisibleCells=Xe(()=>[t._getAllVisibleCells(),e.getState().columnPinning.right],(n,r)=>(r??[]).map(i=>n.find(o=>o.column.id===i)).filter(Boolean).map(i=>({...i,position:"right"})),Je(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?k0():(n=(r=t.initialState)==null?void 0:r.columnPinning)!=null?n:k0())},t.getIsSomeColumnsPinned=e=>{var n;const r=t.getState().columnPinning;if(!e){var s,i;return!!((s=r.left)!=null&&s.length||(i=r.right)!=null&&i.length)}return!!((n=r[e])!=null&&n.length)},t.getLeftLeafColumns=Xe(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left],(e,n)=>(n??[]).map(r=>e.find(s=>s.id===r)).filter(Boolean),Je(t.options,"debugColumns")),t.getRightLeafColumns=Xe(()=>[t.getAllLeafColumns(),t.getState().columnPinning.right],(e,n)=>(n??[]).map(r=>e.find(s=>s.id===r)).filter(Boolean),Je(t.options,"debugColumns")),t.getCenterLeafColumns=Xe(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,r)=>{const s=[...n??[],...r??[]];return e.filter(i=>!s.includes(i.id))},Je(t.options,"debugColumns"))}};function lte(t){return t||(typeof document<"u"?document:null)}const mp={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},C0=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),cte={getDefaultColumnDef:()=>mp,getInitialState:t=>({columnSizing:{},columnSizingInfo:C0(),...t}),getDefaultOptions:t=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:Hr("columnSizing",t),onColumnSizingInfoChange:Hr("columnSizingInfo",t)}),createColumn:(t,e)=>{t.getSize=()=>{var n,r,s;const i=e.getState().columnSizing[t.id];return Math.min(Math.max((n=t.columnDef.minSize)!=null?n:mp.minSize,(r=i??t.columnDef.size)!=null?r:mp.size),(s=t.columnDef.maxSize)!=null?s:mp.maxSize)},t.getStart=Xe(n=>[n,Od(e,n),e.getState().columnSizing],(n,r)=>r.slice(0,t.getIndex(n)).reduce((s,i)=>s+i.getSize(),0),Je(e.options,"debugColumns")),t.getAfter=Xe(n=>[n,Od(e,n),e.getState().columnSizing],(n,r)=>r.slice(t.getIndex(n)+1).reduce((s,i)=>s+i.getSize(),0),Je(e.options,"debugColumns")),t.resetSize=()=>{e.setColumnSizing(n=>{let{[t.id]:r,...s}=n;return s})},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=s=>{if(s.subHeaders.length)s.subHeaders.forEach(r);else{var i;n+=(i=s.column.getSize())!=null?i: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),s=r?.getCanResize();return i=>{if(!r||!s||(i.persist==null||i.persist(),E0(i)&&i.touches&&i.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=E0(i)?Math.round(i.touches[0].clientX):i.clientX,d={},h=(C,A)=>{typeof A=="number"&&(e.setColumnSizingInfo(R=>{var _,N;const M=e.options.columnResizeDirection==="rtl"?-1:1,O=(A-((_=R?.startOffset)!=null?_:0))*M,P=Math.max(O/((N=R?.startSize)!=null?N:0),-.999999);return R.columnSizingStart.forEach(D=>{let[F,te]=D;d[F]=Math.round(Math.max(te+te*P,0)*100)/100}),{...R,deltaOffset:O,deltaPercentage:P}}),(e.options.columnResizeMode==="onChange"||C==="end")&&e.setColumnSizing(R=>({...R,...d})))},g=C=>h("move",C),y=C=>{h("end",C),e.setColumnSizingInfo(A=>({...A,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},b=lte(n),x={moveHandler:C=>g(C.clientX),upHandler:C=>{b?.removeEventListener("mousemove",x.moveHandler),b?.removeEventListener("mouseup",x.upHandler),y(C.clientX)}},S={moveHandler:C=>(C.cancelable&&(C.preventDefault(),C.stopPropagation()),g(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()),y((A=C.touches[0])==null?void 0:A.clientX)}},k=ute()?{passive:!1}:!1;E0(i)?(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,s)=>r+s.getSize(),0))!=null?e:0},t.getLeftTotalSize=()=>{var e,n;return(e=(n=t.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((r,s)=>r+s.getSize(),0))!=null?e:0},t.getCenterTotalSize=()=>{var e,n;return(e=(n=t.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((r,s)=>r+s.getSize(),0))!=null?e:0},t.getRightTotalSize=()=>{var e,n;return(e=(n=t.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((r,s)=>r+s.getSize(),0))!=null?e:0}}};let gp=null;function ute(){if(typeof gp=="boolean")return gp;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 gp=t,gp}function E0(t){return t.type==="touchstart"}const dte={getInitialState:t=>({columnVisibility:{},...t}),getDefaultOptions:t=>({onColumnVisibilityChange:Hr("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 s=t.columns;return(n=s.length?s.some(i=>i.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=Xe(()=>[t.getAllCells(),e.getState().columnVisibility],n=>n.filter(r=>r.column.getIsVisible()),Je(e.options,"debugRows")),t.getVisibleCells=Xe(()=>[t.getLeftVisibleCells(),t.getCenterVisibleCells(),t.getRightVisibleCells()],(n,r,s)=>[...n,...r,...s],Je(e.options,"debugRows"))},createTable:t=>{const e=(n,r)=>Xe(()=>[r(),r().filter(s=>s.getIsVisible()).map(s=>s.id).join("_")],s=>s.filter(i=>i.getIsVisible==null?void 0:i.getIsVisible()),Je(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((s,i)=>({...s,[i.id]:n||!(i.getCanHide!=null&&i.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 Od(t,e){return e?e==="center"?t.getCenterVisibleLeafColumns():e==="left"?t.getLeftVisibleLeafColumns():t.getRightVisibleLeafColumns():t.getVisibleLeafColumns()}const fte={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()}}},hte={getInitialState:t=>({globalFilter:void 0,...t}),getDefaultOptions:t=>({onGlobalFilterChange:Hr("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,s,i;return((n=t.columnDef.enableGlobalFilter)!=null?n:!0)&&((r=e.options.enableGlobalFilter)!=null?r:!0)&&((s=e.options.enableFilters)!=null?s:!0)&&((i=e.options.getColumnCanGlobalFilter==null?void 0:e.options.getColumnCanGlobalFilter(t))!=null?i:!0)&&!!t.accessorFn}},createTable:t=>{t.getGlobalAutoFilterFn=()=>Ri.includesString,t.getGlobalFilterFn=()=>{var e,n;const{globalFilterFn:r}=t.options;return ty(r)?r:r==="auto"?t.getGlobalAutoFilterFn():(e=(n=t.options.filterFns)==null?void 0:n[r])!=null?e:Ri[r]},t.setGlobalFilter=e=>{t.options.onGlobalFilterChange==null||t.options.onGlobalFilterChange(e)},t.resetGlobalFilter=e=>{t.setGlobalFilter(e?void 0:t.initialState.globalFilter)}}},pte={getInitialState:t=>({expanded:{},...t}),getDefaultOptions:t=>({onExpandedChange:Hr("expanded",t),paginateExpandedRows:!0}),createTable:t=>{let e=!1,n=!1;t._autoResetExpanded=()=>{var r,s;if(!e){t._queue(()=>{e=!0});return}if((r=(s=t.options.autoResetAll)!=null?s: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 s,i;t.setExpanded(r?{}:(s=(i=t.initialState)==null?void 0:i.expanded)!=null?s:{})},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(s=>!s.getIsExpanded()))},t.getExpandedDepth=()=>{let r=0;return(t.getState().expanded===!0?Object.keys(t.getRowModel().rowsById):Object.keys(t.getState().expanded)).forEach(i=>{const o=i.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 s;const i=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=(s=n)!=null?s:!i,!i&&n)return{...o,[t.id]:!0};if(i&&!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,s;return(n=e.options.getRowCanExpand==null?void 0:e.options.getRowCanExpand(t))!=null?n:((r=e.options.enableExpanding)!=null?r:!0)&&!!((s=t.subRows)!=null&&s.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()}}}},uw=0,dw=10,T0=()=>({pageIndex:uw,pageSize:dw}),mte={getInitialState:t=>({...t,pagination:{...T0(),...t?.pagination}}),getDefaultOptions:t=>({onPaginationChange:Hr("pagination",t)}),createTable:t=>{let e=!1,n=!1;t._autoResetPageIndex=()=>{var r,s;if(!e){t._queue(()=>{e=!0});return}if((r=(s=t.options.autoResetAll)!=null?s:t.options.autoResetPageIndex)!=null?r:!t.options.manualPagination){if(n)return;n=!0,t._queue(()=>{t.resetPageIndex(),n=!1})}},t.setPagination=r=>{const s=i=>Vo(r,i);return t.options.onPaginationChange==null?void 0:t.options.onPaginationChange(s)},t.resetPagination=r=>{var s;t.setPagination(r?T0():(s=t.initialState.pagination)!=null?s:T0())},t.setPageIndex=r=>{t.setPagination(s=>{let i=Vo(r,s.pageIndex);const o=typeof t.options.pageCount>"u"||t.options.pageCount===-1?Number.MAX_SAFE_INTEGER:t.options.pageCount-1;return i=Math.max(0,Math.min(i,o)),{...s,pageIndex:i}})},t.resetPageIndex=r=>{var s,i;t.setPageIndex(r?uw:(s=(i=t.initialState)==null||(i=i.pagination)==null?void 0:i.pageIndex)!=null?s:uw)},t.resetPageSize=r=>{var s,i;t.setPageSize(r?dw:(s=(i=t.initialState)==null||(i=i.pagination)==null?void 0:i.pageSize)!=null?s:dw)},t.setPageSize=r=>{t.setPagination(s=>{const i=Math.max(1,Vo(r,s.pageSize)),o=s.pageSize*s.pageIndex,l=Math.floor(o/i);return{...s,pageIndex:l,pageSize:i}})},t.setPageCount=r=>t.setPagination(s=>{var i;let o=Vo(r,(i=t.options.pageCount)!=null?i:-1);return typeof o=="number"&&(o=Math.max(-1,o)),{...s,pageCount:o}}),t.getPageOptions=Xe(()=>[t.getPageCount()],r=>{let s=[];return r&&r>0&&(s=[...new Array(r)].fill(null).map((i,o)=>o)),s},Je(t.options,"debugTable")),t.getCanPreviousPage=()=>t.getState().pagination.pageIndex>0,t.getCanNextPage=()=>{const{pageIndex:r}=t.getState().pagination,s=t.getPageCount();return s===-1?!0:s===0?!1:r<s-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}}},_0=()=>({top:[],bottom:[]}),gte={getInitialState:t=>({rowPinning:_0(),...t}),getDefaultOptions:t=>({onRowPinningChange:Hr("rowPinning",t)}),createRow:(t,e)=>{t.pin=(n,r,s)=>{const i=r?t.getLeafRows().map(u=>{let{id:d}=u;return d}):[],o=s?t.getParentRows().map(u=>{let{id:d}=u;return d}):[],l=new Set([...o,t.id,...i]);e.setRowPinning(u=>{var d,h;if(n==="bottom"){var g,y;return{top:((g=u?.top)!=null?g:[]).filter(S=>!(l!=null&&l.has(S))),bottom:[...((y=u?.bottom)!=null?y:[]).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:((d=u?.top)!=null?d:[]).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:s}=e.options;return typeof r=="function"?r(t):(n=r??s)!=null?n:!0},t.getIsPinned=()=>{const n=[t.id],{top:r,bottom:s}=e.getState().rowPinning,i=n.some(l=>r?.includes(l)),o=n.some(l=>s?.includes(l));return i?"top":o?"bottom":!1},t.getPinnedIndex=()=>{var n,r;const s=t.getIsPinned();if(!s)return-1;const i=(n=s==="top"?e.getTopRows():e.getBottomRows())==null?void 0:n.map(o=>{let{id:l}=o;return l});return(r=i?.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?_0():(n=(r=t.initialState)==null?void 0:r.rowPinning)!=null?n:_0())},t.getIsSomeRowsPinned=e=>{var n;const r=t.getState().rowPinning;if(!e){var s,i;return!!((s=r.top)!=null&&s.length||(i=r.bottom)!=null&&i.length)}return!!((n=r[e])!=null&&n.length)},t._getPinnedRows=(e,n,r)=>{var s;return((s=t.options.keepPinnedRows)==null||s?(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=Xe(()=>[t.getRowModel().rows,t.getState().rowPinning.top],(e,n)=>t._getPinnedRows(e,n,"top"),Je(t.options,"debugRows")),t.getBottomRows=Xe(()=>[t.getRowModel().rows,t.getState().rowPinning.bottom],(e,n)=>t._getPinnedRows(e,n,"bottom"),Je(t.options,"debugRows")),t.getCenterRows=Xe(()=>[t.getRowModel().rows,t.getState().rowPinning.top,t.getState().rowPinning.bottom],(e,n,r)=>{const s=new Set([...n??[],...r??[]]);return e.filter(i=>!s.has(i.id))},Je(t.options,"debugRows"))}},yte={getInitialState:t=>({rowSelection:{},...t}),getDefaultOptions:t=>({onRowSelectionChange:Hr("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},s=t.getPreGroupedRowModel().flatRows;return e?s.forEach(i=>{i.getCanSelect()&&(r[i.id]=!0)}):s.forEach(i=>{delete r[i.id]}),r})},t.toggleAllPageRowsSelected=e=>t.setRowSelection(n=>{const r=typeof e<"u"?e:!t.getIsAllPageRowsSelected(),s={...n};return t.getRowModel().rows.forEach(i=>{fw(s,i.id,r,!0,t)}),s}),t.getPreSelectedRowModel=()=>t.getCoreRowModel(),t.getSelectedRowModel=Xe(()=>[t.getState().rowSelection,t.getCoreRowModel()],(e,n)=>Object.keys(e).length?A0(t,n):{rows:[],flatRows:[],rowsById:{}},Je(t.options,"debugTable")),t.getFilteredSelectedRowModel=Xe(()=>[t.getState().rowSelection,t.getFilteredRowModel()],(e,n)=>Object.keys(e).length?A0(t,n):{rows:[],flatRows:[],rowsById:{}},Je(t.options,"debugTable")),t.getGroupedSelectedRowModel=Xe(()=>[t.getState().rowSelection,t.getSortedRowModel()],(e,n)=>Object.keys(e).length?A0(t,n):{rows:[],flatRows:[],rowsById:{}},Je(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(s=>s.getCanSelect()&&!n[s.id])&&(r=!1),r},t.getIsAllPageRowsSelected=()=>{const e=t.getPaginationRowModel().flatRows.filter(s=>s.getCanSelect()),{rowSelection:n}=t.getState();let r=!!e.length;return r&&e.some(s=>!n[s.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 s=t.getIsSelected();e.setRowSelection(i=>{var o;if(n=typeof n<"u"?n:!s,t.getCanSelect()&&s===n)return i;const l={...i};return fw(l,t.id,n,(o=r?.selectChildren)!=null?o:!0,e),l})},t.getIsSelected=()=>{const{rowSelection:n}=e.getState();return xk(t,n)},t.getIsSomeSelected=()=>{const{rowSelection:n}=e.getState();return hw(t,n)==="some"},t.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=e.getState();return hw(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 s;n&&t.toggleSelected((s=r.target)==null?void 0:s.checked)}}}},fw=(t,e,n,r,s)=>{var i;const o=s.getRow(e,!0);n?(o.getCanMultiSelect()||Object.keys(t).forEach(l=>delete t[l]),o.getCanSelect()&&(t[e]=!0)):delete t[e],r&&(i=o.subRows)!=null&&i.length&&o.getCanSelectSubRows()&&o.subRows.forEach(l=>fw(t,l.id,n,r,s))};function A0(t,e){const n=t.getState().rowSelection,r=[],s={},i=function(o,l){return o.map(u=>{var d;const h=xk(u,n);if(h&&(r.push(u),s[u.id]=u),(d=u.subRows)!=null&&d.length&&(u={...u,subRows:i(u.subRows)}),h)return u}).filter(Boolean)};return{rows:i(e.rows),flatRows:r,rowsById:s}}function xk(t,e){var n;return(n=e[t.id])!=null?n:!1}function hw(t,e,n){var r;if(!((r=t.subRows)!=null&&r.length))return!1;let s=!0,i=!1;return t.subRows.forEach(o=>{if(!(i&&!s)&&(o.getCanSelect()&&(xk(o,e)?i=!0:s=!1),o.subRows&&o.subRows.length)){const l=hw(o,e);l==="all"?i=!0:(l==="some"&&(i=!0),s=!1)}}),s?"all":i?"some":!1}const pw=/([0-9]+)/gm,bte=(t,e,n)=>P2(ia(t.getValue(n)).toLowerCase(),ia(e.getValue(n)).toLowerCase()),vte=(t,e,n)=>P2(ia(t.getValue(n)),ia(e.getValue(n))),xte=(t,e,n)=>wk(ia(t.getValue(n)).toLowerCase(),ia(e.getValue(n)).toLowerCase()),wte=(t,e,n)=>wk(ia(t.getValue(n)),ia(e.getValue(n))),Ste=(t,e,n)=>{const r=t.getValue(n),s=e.getValue(n);return r>s?1:r<s?-1:0},kte=(t,e,n)=>wk(t.getValue(n),e.getValue(n));function wk(t,e){return t===e?0:t>e?1:-1}function ia(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(pw).filter(Boolean),r=e.split(pw).filter(Boolean);for(;n.length&&r.length;){const s=n.shift(),i=r.shift(),o=parseInt(s,10),l=parseInt(i,10),u=[o,l].sort();if(isNaN(u[0])){if(s>i)return 1;if(i>s)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 rd={alphanumeric:bte,alphanumericCaseSensitive:vte,text:xte,textCaseSensitive:wte,datetime:Ste,basic:kte},Cte={getInitialState:t=>({sorting:[],...t}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:t=>({onSortingChange:Hr("sorting",t),isMultiSortEvent:e=>e.shiftKey}),createColumn:(t,e)=>{t.getAutoSortingFn=()=>{const n=e.getFilteredRowModel().flatRows.slice(10);let r=!1;for(const s of n){const i=s?.getValue(t.id);if(Object.prototype.toString.call(i)==="[object Date]")return rd.datetime;if(typeof i=="string"&&(r=!0,i.split(pw).length>1))return rd.alphanumeric}return r?rd.text:rd.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 ty(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:rd[t.columnDef.sortingFn]},t.toggleSorting=(n,r)=>{const s=t.getNextSortingOrder(),i=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 d=[],h,g=i?n:s==="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"&&(i||s||(h="remove")),h==="add"){var y;d=[...o,{id:t.id,desc:g}],d.splice(0,d.length-((y=e.options.maxMultiSortColCount)!=null?y:Number.MAX_SAFE_INTEGER))}else h==="toggle"?d=o.map(b=>b.id===t.id?{...b,desc:g}:b):h==="remove"?d=o.filter(b=>b.id!==t.id):d=[{id:t.id,desc:g}];return d})},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,s;const i=t.getFirstSortDir(),o=t.getIsSorted();return o?o!==i&&((r=e.options.enableSortingRemoval)==null||r)&&(!(n&&(s=e.options.enableMultiRemove)!=null)||s)?!1:o==="desc"?"asc":"desc":i},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(s=>s.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(s=>s.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())}},Ete=[qee,dte,ote,ate,Wee,Kee,fte,hte,Cte,ste,pte,mte,gte,yte,cte];function Tte(t){var e,n;const r=[...Ete,...(e=t._features)!=null?e:[]];let s={_features:r};const i=s._features.reduce((y,b)=>Object.assign(y,b.getDefaultOptions==null?void 0:b.getDefaultOptions(s)),{}),o=y=>s.options.mergeOptions?s.options.mergeOptions(i,y):{...i,...y};let u={...{},...(n=t.initialState)!=null?n:{}};s._features.forEach(y=>{var b;u=(b=y.getInitialState==null?void 0:y.getInitialState(u))!=null?b:u});const d=[];let h=!1;const g={_features:r,options:{...i,...t},initialState:u,_queue:y=>{d.push(y),h||(h=!0,Promise.resolve().then(()=>{for(;d.length;)d.shift()();h=!1}).catch(b=>setTimeout(()=>{throw b})))},reset:()=>{s.setState(s.initialState)},setOptions:y=>{const b=Vo(y,s.options);s.options=o(b)},getState:()=>s.options.state,setState:y=>{s.options.onStateChange==null||s.options.onStateChange(y)},_getRowId:(y,b,x)=>{var S;return(S=s.options.getRowId==null?void 0:s.options.getRowId(y,b,x))!=null?S:`${x?[x.id,b].join("."):b}`},getCoreRowModel:()=>(s._getCoreRowModel||(s._getCoreRowModel=s.options.getCoreRowModel(s)),s._getCoreRowModel()),getRowModel:()=>s.getPaginationRowModel(),getRow:(y,b)=>{let x=(b?s.getPrePaginationRowModel():s.getRowModel()).rowsById[y];if(!x&&(x=s.getCoreRowModel().rowsById[y],!x))throw new Error;return x},_getDefaultColumnDef:Xe(()=>[s.options.defaultColumn],y=>{var b;return y=(b=y)!=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},...s._features.reduce((x,S)=>Object.assign(x,S.getDefaultColumnDef==null?void 0:S.getDefaultColumnDef()),{}),...y}},Je(t,"debugColumns")),_getColumnDefs:()=>s.options.columns,getAllColumns:Xe(()=>[s._getColumnDefs()],y=>{const b=function(x,S,k){return k===void 0&&(k=0),x.map(C=>{const A=Fee(s,C,k,S),R=C;return A.columns=R.columns?b(R.columns,A,k+1):[],A})};return b(y)},Je(t,"debugColumns")),getAllFlatColumns:Xe(()=>[s.getAllColumns()],y=>y.flatMap(b=>b.getFlatColumns()),Je(t,"debugColumns")),_getAllFlatColumnsById:Xe(()=>[s.getAllFlatColumns()],y=>y.reduce((b,x)=>(b[x.id]=x,b),{}),Je(t,"debugColumns")),getAllLeafColumns:Xe(()=>[s.getAllColumns(),s._getOrderColumnsFn()],(y,b)=>{let x=y.flatMap(S=>S.getLeafColumns());return b(x)},Je(t,"debugColumns")),getColumn:y=>s._getAllFlatColumnsById()[y]};Object.assign(s,g);for(let y=0;y<s._features.length;y++){const b=s._features[y];b==null||b.createTable==null||b.createTable(s)}return s}function _te(){return t=>Xe(()=>[t.options.data],e=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(s,i,o){i===void 0&&(i=0);const l=[];for(let d=0;d<s.length;d++){const h=Gee(t,t._getRowId(s[d],d,o),s[d],d,i,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(s[d],d),(u=h.originalSubRows)!=null&&u.length&&(h.subRows=r(h.originalSubRows,i+1,h))}}return l};return n.rows=r(e),n},Je(t.options,"debugTable","getRowModel",()=>t._autoResetPageIndex()))}function _N(t,e){return t?Ate(t)?E.createElement(t,e):t:null}function Ate(t){return Rte(t)||typeof t=="function"||Nte(t)}function Rte(t){return typeof t=="function"&&(()=>{const e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}function Nte(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}function Mte(t){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[n]=E.useState(()=>({current:Tte(e)})),[r,s]=E.useState(()=>n.current.initialState);return n.current.setOptions(i=>({...i,...t,state:{...r,...t.state},onStateChange:o=>{s(o),t.onStateChange==null||t.onStateChange(o)}})),n.current}function Ote({uploads:t,canCreate:e,fieldLabels:n,onClose:r,onUpload:s,onCreateFromUploads:i}){const o=E.useMemo(()=>Object.keys(t),[t]),[l,u]=E.useState(o[0]??""),[d,h]=E.useState(!!e),[g,y]=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?m.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:r,children:m.jsxs("div",{className:"vertebr-modal vertebr-modal-sm",role:"dialog","aria-modal":"true","aria-label":"Bulk image upload",onClick:k=>k.stopPropagation(),children:[m.jsxs("header",{className:"vertebr-modal-head",children:[m.jsxs("div",{className:"vertebr-modal-heading",children:[m.jsx("p",{className:"vertebr-modal-eyebrow",children:"Media"}),m.jsx("h2",{children:"Bulk image upload"})]}),m.jsx("button",{type:"button",className:"vertebr-btn",onClick:r,children:"Close"})]}),m.jsxs("div",{className:"vertebr-modal-body",children:[o.length>1?m.jsxs("label",{className:"vertebr-field",children:[m.jsx("span",{children:"Target field"}),m.jsx("select",{className:"vertebr-native-select",value:l,onChange:k=>{u(k.target.value),y([]),x(null)},children:o.map(k=>m.jsx("option",{value:k,children:n[k]??k},k))})]}):null,e&&i?m.jsxs("label",{className:"vertebr-upload-check",children:[m.jsx("input",{type:"checkbox",checked:d,onChange:k=>h(k.target.checked)}),m.jsx("span",{children:"Create a record for each uploaded image"})]}):null,m.jsx(Wc,{meta:S,multiple:!0,onUpload:async k=>{x(`Uploading ${k.length} image${k.length===1?"":"s"}…`);const C=await s(l,k);y(C),d&&i?(x("Creating records…"),await i(l,C),x(`Uploaded ${C.length} and created records.`)):x(`Uploaded ${C.length} image${C.length===1?"":"s"}.`)}}),b?m.jsx("p",{className:"vertebr-upload-status",children:b}):null,g.length>0?m.jsx("ul",{className:"vertebr-upload-results",children:g.map(k=>m.jsxs("li",{children:[m.jsx("img",{src:k.url,alt:""}),m.jsxs("div",{children:[m.jsx("strong",{children:k.name??"Image"}),m.jsx("a",{href:k.url,target:"_blank",rel:"noreferrer",children:k.url})]})]},k.url))}):null]})]})}):null}function jte({columns:t,visibility:e,onChange:n}){const[r,s]=E.useState(!1),i=E.useRef(null),o=E.useId(),l=t.filter(d=>e[d.id]===!1).length;E.useEffect(()=>{if(!r)return;const d=g=>{i.current?.contains(g.target)||s(!1)},h=g=>{g.key==="Escape"&&s(!1)};return window.addEventListener("mousedown",d),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",d),window.removeEventListener("keydown",h)}},[r]);const u=t.length-l;return m.jsxs("div",{className:"vertebr-col-menu",ref:i,children:[m.jsxs("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet","aria-expanded":r,"aria-controls":o,onClick:()=>s(d=>!d),children:["Columns",l>0?m.jsx("span",{className:"vertebr-col-menu-count",children:u}):null]}),r?m.jsxs("div",{className:"vertebr-col-menu-panel",id:o,role:"menu",children:[m.jsxs("div",{className:"vertebr-col-menu-head",children:[m.jsx("span",{children:"Visible fields"}),m.jsx("button",{type:"button",className:"vertebr-link-btn",onClick:()=>{const d={};for(const h of t)d[h.id]=!0;n(d)},children:"Show all"})]}),m.jsx("ul",{className:"vertebr-col-menu-list",children:t.map(d=>{const h=e[d.id]!==!1;return m.jsx("li",{children:m.jsxs("label",{className:"vertebr-col-menu-item",children:[m.jsx("input",{type:"checkbox",checked:h,disabled:h&&u<=1,onChange:()=>{const g={...e,[d.id]:!h};n(g)}}),m.jsx("span",{children:d.label})]})},d.id)})})]}):null]})}const Dte=/(url|href|link|src)/i,Ite=/\.(png|jpe?g|gif|webp|svg|avif)(\?|#|$)/i;function z2(t){return/^https?:\/\//i.test(t)||t.startsWith("//")}function Lte(t){return z2(t)?Ite.test(t)?!0:/(image|img|media|cdn|photo)/i.test(t):!1}function AN(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 Bp({fieldKey:t,field:e,value:n,variant:r="table"}){const s=r==="detail";if(n==null||n==="")return m.jsx("span",{className:"vertebr-cell-empty",children:"—"});const i=e?.type;if(i==="boolean"||typeof n=="boolean"){const u=!!n;return m.jsx("span",{className:"vertebr-badge","data-tone":u?"ok":"neutral",children:Pte(t,e,u)})}if(i==="datetime"){const u=AN(n);if(u)return m.jsx("span",{className:"vertebr-cell-datetime",children:u})}if((i==="number"||typeof n=="number")&&typeof n=="number"&&Number.isFinite(n))return Jw(t,e)?m.jsx("span",{className:"vertebr-cell-money",children:lx(n,{asCents:!0})}):ZO(t,e)?m.jsx("span",{className:"vertebr-cell-money",children:lx(n,{asCents:!1})}):m.jsx("span",{className:"vertebr-cell-number",children:new Intl.NumberFormat().format(n)});const o=rx(n);if(o.length>0&&(i==="file[]"||Qa(t,e)||o.every(Lte)))return m.jsx(zte,{urls:o,detail:s});if(Array.isArray(n)){if(n.length===0)return m.jsx("span",{className:"vertebr-cell-empty",children:"—"});if(n.every(u=>typeof u=="string"))return m.jsx("div",{className:"vertebr-chip-row",children:n.map(u=>m.jsx("span",{className:"vertebr-chip",title:u,children:u},u))})}if(typeof n=="string")return Dte.test(t)||z2(n)?m.jsx("a",{className:"vertebr-cell-link",href:n.startsWith("//")?`https:${n}`:n,target:"_blank",rel:"noreferrer",title:n,onClick:u=>u.stopPropagation(),children:s?n:n.replace(/^https?:\/\//i,"")}):!s&&(i==="richtext"||n.length>80)?m.jsx("span",{className:"vertebr-cell-clamp",title:n,children:n}):s&&(i==="richtext"||n.length>80)?m.jsx("p",{className:"vertebr-cell-prose",children:n}):m.jsx("span",{className:"vertebr-cell-text",children:n});const l=AN(n);return l?m.jsx("span",{className:"vertebr-cell-datetime",children:l}):typeof n=="object"?m.jsx("code",{className:"vertebr-cell-json",title:JSON.stringify(n),children:JSON.stringify(n)}):m.jsx("span",{className:"vertebr-cell-text",children:String(n)})}function Pte(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 zte({urls:t,detail:e}){if(e)return m.jsx("div",{className:"vertebr-cell-thumbs vertebr-cell-thumbs-detail",children:t.map((s,i)=>m.jsxs("a",{className:"vertebr-cell-media vertebr-cell-media-detail",href:s,target:"_blank",rel:"noreferrer",title:s,onClick:o=>o.stopPropagation(),children:[m.jsx("img",{src:s,alt:"",loading:"lazy"}),m.jsx("span",{className:"vertebr-cell-link",children:s})]},`${s}:${i}`))});const n=t.slice(0,3),r=t.length-n.length;return m.jsxs("div",{className:"vertebr-cell-thumbs",title:t[0],children:[n.map((s,i)=>m.jsx("img",{src:s,alt:"",loading:"lazy"},`${s}:${i}`)),r>0?m.jsxs("span",{className:"vertebr-cell-thumbs-more",children:["+",r]}):null]})}function $te({title:t,schema:e,value:n,uploads:r,onUpload:s,galleryUpload:i,onListGallery:o,onUploadGallery:l,onClose:u,onCreate:d}){return E.useEffect(()=>{const h=y=>{y.key==="Escape"&&u()};window.addEventListener("keydown",h);const g=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",h),document.body.style.overflow=g}},[u]),m.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:u,children:m.jsxs("div",{className:"vertebr-modal vertebr-modal-form",role:"dialog","aria-modal":"true","aria-label":t,onClick:h=>h.stopPropagation(),children:[m.jsxs("header",{className:"vertebr-modal-head",children:[m.jsxs("div",{className:"vertebr-modal-heading",children:[m.jsx("p",{className:"vertebr-modal-eyebrow",children:"New record"}),m.jsx("h2",{children:t})]}),m.jsx("div",{className:"vertebr-modal-actions",children:m.jsx("button",{type:"button",className:"vertebr-btn",onClick:u,"aria-label":"Close",children:"Close"})})]}),m.jsx("div",{className:"vertebr-modal-body",children:m.jsx(kf,{variant:"record",schema:e,value:n,uploads:r,onUpload:s,galleryUpload:i,onListGallery:o,onUploadGallery:l,submitLabel:t,onSave:async h=>{await d(h),u()}})})]})})}const Bte=new Set(["custom","promo","custom_discount"]),Vte=new Set(["discount","welcome_offer","flash_sale","custom_discount"]),Hte=new Set(["discountId","discountCode","discountOffer","discountExpires"]);function Ute(t){return Array.isArray(t)?t.join(", "):t}function qc(t){return typeof t=="string"?t:String(t??"")}function Fte(t,e){const n=`${t} ${e.label??""}`;return e.type==="richtext"||/(body|message|html|notes)/i.test(n)}function sg(t,e){if(!t.preset)return!0;const n=qc(e.preset);return!n||Bte.has(n)}function $2(t){return Vte.has(t)}function B2(t,e,n){if(t==="subject"||t==="body")return sg(e,n);if(Hte.has(t)){const r=qc(n.preset);return!(!$2(r)||t==="discountId"&&!e.discountId?.options?.length)}return!0}function RN(t,e){return Object.entries(t).every(([n,r])=>{if(!B2(n,t,e))return!0;const s=(n==="subject"||n==="body")&&sg(t,e),i=(n==="discountCode"||n==="discountOffer")&&$2(qc(e.preset));return r.required===!1&&!s&&!i||r.type!=="string"&&r.type!=="richtext"&&r.type!=="enum"?!0:!!qc(e[n]).trim()})}function NN(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 qte({title:t,count:e,schema:n,submitLabel:r,onClose:s,onPreview:i,onSubmit:o}){const l=E.useMemo(()=>gk(n),[n]),u=E.useMemo(()=>Object.entries(n),[n]),d=u.length>0,[h,g]=E.useState(l),[y,b]=E.useState(null),[x,S]=E.useState(null),[k,C]=E.useState(!1),[A,R]=E.useState(!1),_=!A&&(!d||RN(n,h)),N=u.filter(([P])=>B2(P,n,h)),M=E.useCallback(async P=>{if(d&&!RN(n,P)){b(null),S(null);return}C(!0),S(null);try{const D=await i(P);b(D)}catch(D){b(null),S(NN(D))}finally{C(!1)}},[d,i,n]);E.useEffect(()=>{const P=F=>{F.key==="Escape"&&s()};window.addEventListener("keydown",P);const D=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",P),document.body.style.overflow=D}},[s]),E.useEffect(()=>{if(!d){M({});return}const P=window.setTimeout(()=>{M(h)},280);return()=>window.clearTimeout(P)},[h,d,M]);const O=async()=>{if(_){R(!0);try{await o(d?h:{}),s()}catch(P){S(NN(P))}finally{R(!1)}}};return m.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:s,children:m.jsxs("div",{className:"vertebr-modal vertebr-modal-form vertebr-mail-modal",role:"dialog","aria-modal":"true","aria-label":t,onClick:P=>P.stopPropagation(),children:[m.jsxs("header",{className:"vertebr-modal-head",children:[m.jsxs("div",{className:"vertebr-modal-heading",children:[m.jsx("p",{className:"vertebr-modal-eyebrow",children:e===1?"1 person":`${e} people`}),m.jsx("h2",{children:t})]}),m.jsx("div",{className:"vertebr-modal-actions",children:m.jsx("button",{type:"button",className:"vertebr-btn",onClick:s,"aria-label":"Close",children:"Close"})})]}),m.jsxs("div",{className:"vertebr-mail-layout",children:[m.jsxs("form",{className:"vertebr-mail-compose",onSubmit:P=>{P.preventDefault(),O()},children:[d?m.jsxs("div",{className:"vertebr-mail-fields",children:[N.map(([P,D])=>{const F=Fte(P,D);return m.jsxs("label",{className:"vertebr-mail-field",children:[m.jsx("span",{children:D.label??P}),D.type==="enum"?m.jsx(mk,{id:`mail-${P}`,value:h[P],field:D,onChange:te=>g(H=>({...H,[P]:te}))}):F?m.jsx("textarea",{rows:7,value:qc(h[P]),placeholder:"Plain text — the host template styles it.",onChange:te=>g(H=>({...H,[P]:te.target.value}))}):m.jsx("input",{type:"text",value:qc(h[P]),onChange:te=>g(H=>({...H,[P]:te.target.value}))})]},P)}),n.preset&&!sg(n,h)?m.jsx("p",{className:"vertebr-mail-compose-hint",children:"Preview updates from the selected preset. Switch to Custom to write your own copy."}):null]}):m.jsx("p",{className:"vertebr-mail-compose-note",children:"Host template — Vertebr only delivers it."}),x?m.jsx("p",{className:"vertebr-mail-compose-error",children:x}):null,m.jsx("div",{className:"vertebr-mail-compose-foot",children:m.jsx("button",{type:"submit",className:"vertebr-btn vertebr-btn-primary",disabled:!_,children:A?"Sending…":r})})]}),m.jsxs("div",{className:"vertebr-mail-preview",children:[m.jsxs("div",{className:"vertebr-mail-preview-meta",children:[m.jsxs("p",{children:[m.jsx("span",{children:"To"}),m.jsx("strong",{children:y?Ute(y.to):e===1?"—":`${e} recipients`})]}),m.jsxs("p",{children:[m.jsx("span",{children:"Subject"}),m.jsx("strong",{children:y?.subject??(k?"Updating…":"—")})]})]}),m.jsx("div",{className:"vertebr-mail-preview-stage",children:m.jsx("div",{className:"vertebr-mail-preview-frame",children:y?.html?m.jsx("iframe",{title:"Email preview",sandbox:"",srcDoc:y.html}):y?.text?m.jsx("pre",{children:y.text}):m.jsx("div",{className:"vertebr-mail-preview-empty",children:x??(k?"Rendering host template…":d?n.preset&&sg(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 Gte(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\bcents\b/i,"").trim()}function Wte(t,e){for(const[n,r]of Object.entries(e)){if(typeof r!="string"||!/^https?:\/\//i.test(r))continue;const s=t[n];if(/(image|img|photo|avatar|thumbnail|thumb|cover)/i.test(n)||/(image|img|photo)/i.test(s?.label??"")||/(image|img|media|cdn|photo)/i.test(r))return r}return null}function Kte({schema:t,row:e,title:n,canEdit:r,onClose:s,onEdit:i}){const o=Object.keys(t),l=o.length>0?o.map(d=>[d,e[d]]):Object.entries(e),u=Wte(t,e);return E.useEffect(()=>{const d=g=>{g.key==="Escape"&&s()};window.addEventListener("keydown",d);const h=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",d),document.body.style.overflow=h}},[s]),m.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:s,children:m.jsxs("div",{className:"vertebr-modal",role:"dialog","aria-modal":"true","aria-label":n,onClick:d=>d.stopPropagation(),children:[m.jsxs("header",{className:"vertebr-modal-head",children:[m.jsxs("div",{className:"vertebr-modal-heading",children:[m.jsx("p",{className:"vertebr-modal-eyebrow",children:"Record"}),m.jsx("h2",{children:n})]}),m.jsxs("div",{className:"vertebr-modal-actions",children:[r&&i?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",onClick:i,children:"Edit"}):null,m.jsx("button",{type:"button",className:"vertebr-btn",onClick:s,"aria-label":"Close",children:"Close"})]})]}),m.jsxs("div",{className:"vertebr-modal-body",children:[u?m.jsx("div",{className:"vertebr-modal-hero",children:m.jsx("img",{src:u,alt:""})}):null,m.jsx("dl",{className:"vertebr-modal-fields",children:l.map(([d,h])=>m.jsxs("div",{className:"vertebr-modal-field",children:[m.jsx("dt",{children:t[d]?.label??Gte(d)}),m.jsx("dd",{children:m.jsx(Bp,{fieldKey:d,field:t[d],value:h,variant:"detail"})})]},d))})]})]})})}function R0(t){return!!(t?.input&&Object.keys(t.input).length>0)}function MN(t){return!!t?.mail}function Zte(t,e){const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}function Dr(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 yp(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\bcents\b/i,"").trim()}function ON(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 Yte(t,e){if(!(!t||typeof localStorage>"u"))try{localStorage.setItem(`vertebr:columns:v2:${t}`,JSON.stringify(e))}catch{}}function Xte(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 jN(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 bp(t,e){return t[e]!==!1}function Jte(t){const e={};for(const[n,r]of Object.entries(t))Xte(n,r,t)&&(e[n]=!1);return e}function DN(t,e){const n=Jte(e);if(!t||typeof localStorage>"u")return n;try{const r=localStorage.getItem(`vertebr:columns:v2:${t}`);if(!r)return n;const s=JSON.parse(r);return!s||typeof s!="object"?n:{...n,...s}}catch{return n}}function Qte(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 ene(t){return t.replace(/\.[^.]+$/,"").replace(/[_-]+/g," ").replace(/\s+/g," ").trim()}function tne({schema:t,items:e,permissions:n,actions:r={},label:s,uploads:i,rowIdKeys:o=["id","slug","uid","email"],storageKey:l,onUpdate:u,onCreate:d,onDelete:h,onAction:g,onActionDone:y,onPreviewMail:b,collectionActions:x={},onCollectionAction:S,bulkActions:k={},onBulkAction:C,listQuery:A,total:R,searchQuery:_="",onSearchChange:N,onUpload:M,galleryUpload:O,onListGallery:P,onUploadGallery:D,initialEditRowId:F,onEditRowIdChange:te}){const[H,Z]=E.useState(null),[G,ae]=E.useState(!1),[z,L]=E.useState(null),[W,ce]=E.useState(!1),[pe,$]=E.useState(null),[Y,he]=E.useState(new Set),[be,Me]=E.useState(_),[Ce,He]=E.useState(null),[Ee,le]=E.useState(null),[me,De]=E.useState(null),Be=E.useRef(null),[Ke,mt]=E.useState({overflow:!1,canLeft:!1,canRight:!1}),[ht,Wt]=E.useState(()=>DN(l,t)),[Vt,Yt]=E.useState({}),[kn,jn]=E.useState(!1),Dn=!!(n?.update&&u),Tr=!!(n?.create&&d),js=!!(n?.delete&&h),Ht=Qte(s),pr=!!(i&&M&&Object.keys(i).length),Gn=Object.entries(r),ds=Object.entries(x),rr=Object.entries(k),ye=Object.keys(t),Ie=E.useMemo(()=>ye.filter(ee=>jN(ee,t[ee])),[ye,t]),I=!!(g&&Gn.length>0||C&&rr.length>0),B=!!(A&&N);E.useEffect(()=>{Me(_)},[_]),E.useEffect(()=>{if(!N)return;const ee=window.setTimeout(()=>{be!==_&&N(be)},250);return()=>window.clearTimeout(ee)},[be,_,N]);const U=E.useCallback(ee=>{Z(ee),te?.(Dr(ee,o))},[te,o]),se=E.useCallback(()=>{Z(null),te?.(null)},[te]);E.useEffect(()=>{if(!F)return;const ee=e.find(re=>Dr(re,o)===F);ee&&Z(ee)},[F,e,o]),E.useEffect(()=>{Yt({})},[e]),E.useEffect(()=>{const ee=new Set(e.map(re=>Dr(re,o)).filter(re=>!!re));he(re=>{const Te=new Set([...re].filter(qe=>ee.has(qe)));return Te.size===re.size?re:Te})},[e,o]);const oe=E.useMemo(()=>{let ee=0;for(const[re,Te]of Object.entries(Vt)){const qe=e.find(Dt=>Dr(Dt,o)===re);if(!qe){ee+=Object.keys(Te).length;continue}for(const[Dt,Kn]of Object.entries(Te))bp(qe,Dt)!==Kn&&(ee+=1)}return ee},[Vt,e,o]),xe=E.useCallback((ee,re,Te)=>{Yt(qe=>{const Dt=e.find(ma=>Dr(ma,o)===ee),Kn=Dt?bp(Dt,re):null,Ds={...qe[ee]??{}};Kn===Te?delete Ds[re]:Ds[re]=Te;const sr={...qe};return Object.keys(Ds).length===0?delete sr[ee]:sr[ee]=Ds,sr})},[e,o]),Se=E.useCallback(async()=>{if(!u||oe===0)return;jn(!0);const ee=[];try{for(const[re,Te]of Object.entries(Vt)){const qe=e.find(Dt=>Dr(Dt,o)===re);if(qe)try{await u(re,{...qe,...Te})}catch(Dt){ee.push(`${re}: ${Dt instanceof Error?Dt.message:"Failed"}`)}}Yt({}),ee.length>0&&window.alert(`Saved with ${ee.length} error(s).
|
|
330
|
+
|
|
331
|
+
${ee.slice(0,8).join(`
|
|
332
|
+
`)}`)}finally{jn(!1)}},[u,oe,Vt,e,o]),_e=E.useCallback(async(ee,re,Te)=>{if(!g||re.length===0)return;$(ee);const qe=[];try{for(const Dt of re)try{await g(Dt,ee,Te)}catch(Kn){qe.push(`${Dt}: ${Kn instanceof Error?Kn.message:"Failed"}`)}await y?.(),he(new Set),qe.length>0&&window.alert(`Finished with ${qe.length} error(s).
|
|
333
|
+
|
|
334
|
+
${qe.slice(0,8).join(`
|
|
335
|
+
`)}`)}finally{$(null)}},[g,y]),Ve=E.useCallback((ee,re)=>{const Te=r[ee];if(!Te||re.length===0||!g)return;if(MN(Te)||R0(Te)){He({actionId:ee,rowIds:re});return}const qe=re.length===1?"this person":`${re.length} people`;window.confirm(`${Te.label} for ${qe}?`)&&_e(ee,re)},[r,g,_e]),st=E.useCallback(async(ee,re)=>{if(S){$(ee);try{const Te=await S(ee,re);await y?.(),Te&&typeof Te=="object"&&"message"in Te&&typeof Te.message=="string"?window.alert(Te.message):Te&&typeof Te=="object"&&"result"in Te&&Te.result&&typeof Te.result=="object"&&"message"in Te.result&&typeof Te.result.message=="string"&&window.alert(Te.result.message)}catch(Te){window.alert(Te instanceof Error?Te.message:"Action failed")}finally{$(null)}}},[S,y]),kt=E.useCallback(ee=>{const re=x[ee];if(!re||!S)return;if(R0(re)){le(ee);return}const Te=re.confirm?`${re.label}?
|
|
336
|
+
|
|
337
|
+
${re.confirm}`:`${re.label}?`;window.confirm(Te)&&st(ee)},[x,S,st]),an=E.useCallback(async(ee,re,Te)=>{if(!(!C||re.length===0)){$(ee);try{await C(ee,re,Te),await y?.(),he(new Set)}catch(qe){window.alert(qe instanceof Error?qe.message:"Bulk action failed")}finally{$(null),De(null)}}},[C,y]),Xt=E.useCallback((ee,re)=>{const Te=k[ee];if(!Te||re.length===0||!C)return;if(R0(Te)){De(ee);return}const qe=Te.confirm?`${Te.label} on ${re.length} row(s)?
|
|
338
|
+
|
|
339
|
+
${Te.confirm}`:`${Te.label} on ${re.length} row(s)?`;window.confirm(qe)&&an(ee,re)},[k,C,an]);E.useEffect(()=>{Wt(DN(l,t))},[l]),E.useEffect(()=>{Yte(l,ht)},[l,ht]);const Wn=E.useCallback(()=>{const ee=Be.current;if(!ee){mt({overflow:!1,canLeft:!1,canRight:!1});return}const re=ee.scrollWidth>ee.clientWidth+2;mt({overflow:re,canLeft:re&&ee.scrollLeft>2,canRight:re&&ee.scrollLeft+ee.clientWidth<ee.scrollWidth-2})},[]);E.useEffect(()=>{const ee=Be.current;if(!ee)return;Wn();const re=()=>Wn();ee.addEventListener("scroll",re,{passive:!0});const Te=new ResizeObserver(Wn);Te.observe(ee);const qe=ee.querySelector("table");return qe&&Te.observe(qe),()=>{ee.removeEventListener("scroll",re),Te.disconnect()}},[Wn,e.length,ht]);const Ur=ee=>{const re=Be.current;if(!re)return;const Te=Math.max(220,Math.round(re.clientWidth*.55));re.scrollBy({left:ee==="left"?-Te:Te,behavior:"smooth"})},mr=E.useMemo(()=>ye.map(ee=>({id:ee,label:t[ee]?.label??yp(ee)})),[ye,t]),ti=E.useMemo(()=>{const ee=[];if(I){const re=e.map(qe=>Dr(qe,o)).filter(qe=>!!qe),Te=re.length>0&&re.every(qe=>Y.has(qe));ee.push({id:"_select",enableHiding:!1,header:()=>m.jsx("input",{type:"checkbox",className:"vertebr-row-check",checked:Te,"aria-label":"Select all",onChange:()=>{he(qe=>re.every(Dt=>qe.has(Dt))?new Set:new Set(re))}}),cell:({row:qe})=>{const Dt=Dr(qe.original,o);return Dt?m.jsx("input",{type:"checkbox",className:"vertebr-row-check",checked:Y.has(Dt),"aria-label":"Select row",onClick:Kn=>Kn.stopPropagation(),onChange:()=>he(Kn=>Zte(Kn,Dt))}):null},size:44})}return ee.push(...ye.length===0?[{id:"raw",header:"Item",cell:({row:re})=>m.jsx(Bp,{fieldKey:"raw",value:re.original})}]:ye.map(re=>{const Te=t[re],qe=/(image|img|photo|avatar|thumbnail|thumb|cover)/i.test(re)||/(image|img|photo)/i.test(Te?.label??""),Dt=Dn&&jN(re,Te);return{id:re,accessorKey:re,header:Te?.label??yp(re),meta:{fieldKey:re,field:Te},cell:({row:Kn,getValue:Ds})=>{if(Dt){const sr=Dr(Kn.original,o);if(!sr)return m.jsx(Bp,{fieldKey:re,field:Te,value:Ds()});const ma=Vt[sr]?.[re]??bp(Kn.original,re),ni=Vt[sr]?.[re]!==void 0&&Vt[sr]?.[re]!==bp(Kn.original,re);return m.jsx("div",{className:"vertebr-visibility-check","data-dirty":ni?"true":void 0,onClick:Is=>Is.stopPropagation(),children:m.jsx(KO,{visible:ma,dirty:ni,label:Te?.label??yp(re),disabled:kn,onChange:Is=>xe(sr,re,Is)})})}return m.jsx(Bp,{fieldKey:re,field:Te,value:Ds()})},size:Dt?88:qe?220:void 0}})),ee.push({id:"_actions",header:()=>m.jsx("span",{className:"vertebr-sr-only",children:"Actions"}),enableHiding:!1,cell:({row:re})=>{const Te=Dr(re.original,o);return m.jsxs("div",{className:"vertebr-row-actions",onClick:qe=>qe.stopPropagation(),onKeyDown:qe=>qe.stopPropagation(),children:[m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>L(re.original),children:"View"}),Dn?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>U(re.original),children:"Edit"}):null,Te?Gn.map(([qe,Dt])=>m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:pe!=null,onClick:()=>Ve(qe,[Te]),children:Dt.label},qe)):null,js&&Te?m.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?.(Te)},children:"Delete"}):null]})}}),ee},[t,ye,e,Y,I,Dn,js,Gn,pe,Ve,h,o,Vt,xe]),fs=Mte({data:e,columns:ti,state:{columnVisibility:ht},onColumnVisibilityChange:Wt,getCoreRowModel:_te()}),hs=H?Dr(H,o):null,vl=Object.fromEntries(Object.entries(t).filter(([,ee])=>!ee.readOnly||ee.required).map(([ee,re])=>[ee,re.readOnly?{...re,readOnly:!1}:re])),xl=Object.fromEntries(Object.entries(vl).map(([ee,re])=>[ee,re.default??(re.type==="boolean"?!1:re.type==="number"?void 0:re.type==="file[]"?[]:"")]));if(H&&hs&&u){const ee=Object.fromEntries(Object.entries(t).filter(([,Te])=>!Te.readOnly)),re=ON(H,o);return m.jsxs("div",{className:"vertebr-resource-edit",children:[m.jsxs("div",{className:"vertebr-resource-edit-head",children:[m.jsxs("div",{className:"vertebr-resource-edit-heading",children:[m.jsx("p",{className:"vertebr-resource-edit-eyebrow",children:"Editing record"}),m.jsx("h2",{children:re}),m.jsx("p",{className:"vertebr-resource-edit-id",children:hs})]}),m.jsx("button",{type:"button",className:"vertebr-btn",onClick:()=>se(),children:"Back"})]}),m.jsx(kf,{variant:"record",schema:ee,value:H,uploads:i,onUpload:M,galleryUpload:O,onListGallery:P,onUploadGallery:D,onSave:async Te=>{await u(hs,Te),se()}})]})}const ha=m.jsxs("div",{className:"vertebr-table-toolbar",children:[m.jsxs("div",{className:"vertebr-table-toolbar-start",children:[mr.length>0?m.jsx(jte,{columns:mr,visibility:ht,onChange:Wt}):null,pr?m.jsxs("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-icon",onClick:()=>ce(!0),children:[m.jsx(ine,{}),"Bulk upload"]}):null,Ie.length>0&&oe>0?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"vertebr-count",children:[oe," visibility change",oe===1?"":"s"]}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",disabled:kn,onClick:()=>{Se()},children:kn?"Saving…":"Save visibility"}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:kn,onClick:()=>Yt({}),children:"Discard"})]}):null,ds.map(([ee,re])=>m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:pe!=null,onClick:()=>kt(ee),children:re.label},ee)),I&&Y.size>0?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"vertebr-count",children:[Y.size," selected"]}),Gn.map(([ee,re])=>m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:pe!=null,onClick:()=>Ve(ee,[...Y]),children:re.label},ee)),rr.map(([ee,re])=>m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:pe!=null,onClick:()=>Xt(ee,[...Y]),children:re.label},`bulk:${ee}`)),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>he(new Set),children:"Clear"})]}):null]}),Ke.overflow?m.jsxs("div",{className:"vertebr-table-scroll-controls",role:"group","aria-label":"Scroll columns",children:[m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-icon vertebr-table-scroll-btn",disabled:!Ke.canLeft,onClick:()=>Ur("left"),"aria-label":"Scroll columns left",children:m.jsx(rne,{})}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-icon vertebr-table-scroll-btn",disabled:!Ke.canRight,onClick:()=>Ur("right"),"aria-label":"Scroll columns right",children:m.jsx(sne,{})})]}):null]}),pa=W&&i&&M?m.jsx(Ote,{uploads:i,canCreate:Tr,fieldLabels:Object.fromEntries(Object.keys(i).map(ee=>[ee,t[ee]?.label??yp(ee)])),onClose:()=>ce(!1),onUpload:M,onCreateFromUploads:Tr&&d?async(ee,re)=>{for(const Te of re){const qe=ene(Te.name??"Image");await d({[ee]:Te.url,name:qe,title:qe})}}:void 0}):null,Xi=G&&d?m.jsx($te,{title:Ht,schema:vl,value:xl,uploads:i,onUpload:M,galleryUpload:O,onListGallery:P,onUploadGallery:D,onClose:()=>ae(!1),onCreate:d}):null,Ji=Ce?MN(r[Ce.actionId])&&b?m.jsx(qte,{title:r[Ce.actionId]?.label??"Send email",count:Ce.rowIds.length,schema:hp(r[Ce.actionId]?.input??{}),submitLabel:pe?"Sending…":Ce.rowIds.length===1?"Send":`Send to ${Ce.rowIds.length}`,onClose:()=>He(null),onPreview:ee=>b(Ce.rowIds[0],Ce.actionId,ee),onSubmit:ee=>_e(Ce.actionId,Ce.rowIds,ee)}):r[Ce.actionId]?.input?m.jsx(v0,{title:r[Ce.actionId]?.label??"Run action",count:Ce.rowIds.length,schema:hp(r[Ce.actionId].input),submitLabel:pe?"Sending…":Ce.rowIds.length===1?r[Ce.actionId]?.label??"Send":`Send to ${Ce.rowIds.length}`,onClose:()=>He(null),onSubmit:ee=>_e(Ce.actionId,Ce.rowIds,ee)}):null:null,ge=Ee&&x[Ee]?.input?m.jsx(v0,{title:x[Ee]?.label??"Run action",eyebrow:"This resource",schema:hp(x[Ee].input),submitLabel:pe?"Working…":"Run",onClose:()=>le(null),onSubmit:ee=>st(Ee,ee)}):null,Ae=me&&k[me]?.input?m.jsx(v0,{title:k[me]?.label??"Bulk action",eyebrow:`${Y.size} selected`,schema:hp(k[me].input),submitLabel:pe?"Working…":"Run",onClose:()=>De(null),onSubmit:ee=>an(me,[...Y],ee)}):null,Ct=m.jsxs("div",{className:"vertebr-panel-head",children:[m.jsx("h2",{children:"Records"}),m.jsxs("div",{className:"vertebr-panel-head-actions",children:[B?m.jsx("input",{className:"vertebr-resource-search",type:"search",placeholder:"Search…",value:be,onChange:ee=>Me(ee.target.value),"aria-label":"Search records"}):null,Tr?m.jsxs("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-icon",onClick:()=>ae(!0),children:[m.jsx(nne,{}),Ht]}):null,m.jsx("span",{className:"vertebr-count",children:R!=null?`${e.length} of ${R}`:e.length})]})]});return e.length===0?m.jsxs("div",{className:"vertebr-resource-body",children:[Ct,pr||mr.length>0||ds.length>0?ha:null,m.jsx("div",{className:"vertebr-empty",children:"No rows yet."}),pa,Xi,Ji,ge,Ae]}):m.jsxs("div",{className:"vertebr-resource-body",children:[Ct,ha,m.jsx("div",{className:"vertebr-table-wrap",ref:Be,"data-overflow":Ke.overflow?"true":void 0,"data-overflow-left":Ke.canLeft?"true":void 0,"data-overflow-right":Ke.canRight?"true":void 0,children:m.jsxs("table",{className:"vertebr-table",children:[m.jsx("thead",{children:fs.getHeaderGroups().map(ee=>m.jsx("tr",{children:ee.headers.map(re=>m.jsx("th",{className:re.column.id==="_actions"?"vertebr-col-actions":re.column.id==="_select"?"vertebr-col-select":void 0,children:re.isPlaceholder?null:_N(re.column.columnDef.header,re.getContext())},re.id))},ee.id))}),m.jsx("tbody",{children:fs.getRowModel().rows.map(ee=>m.jsx("tr",{className:"vertebr-table-row-clickable","data-selected":I&&Dr(ee.original,o)&&Y.has(Dr(ee.original,o))?"true":void 0,tabIndex:0,onClick:()=>L(ee.original),onKeyDown:re=>{(re.key==="Enter"||re.key===" ")&&(re.preventDefault(),L(ee.original))},children:ee.getVisibleCells().map(re=>m.jsx("td",{className:re.column.id==="_actions"?"vertebr-col-actions":re.column.id==="_select"?"vertebr-col-select":void 0,children:_N(re.column.columnDef.cell,re.getContext())},re.id))},ee.id))})]})}),z?m.jsx(Kte,{schema:t,row:z,title:ON(z,o),canEdit:Dn,onClose:()=>L(null),onEdit:()=>{U(z),L(null)}}):null,Ji,ge,Ae,pa,Xi]})}function nne(){return m.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:[m.jsx("path",{d:"M12 5v14"}),m.jsx("path",{d:"M5 12h14"})]})}function rne(){return m.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:m.jsx("path",{d:"m15 18-6-6 6-6"})})}function sne(){return m.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:m.jsx("path",{d:"m9 18 6-6-6-6"})})}function ine(){return m.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:[m.jsx("path",{d:"M16 5h6"}),m.jsx("path",{d:"M19 2v6"}),m.jsx("rect",{x:"3",y:"7",width:"14",height:"14",rx:"2"}),m.jsx("circle",{cx:"8.5",cy:"12.5",r:"1.5"}),m.jsx("path",{d:"m17 21-4.5-4.5L7 21"})]})}const one={product:"Products",engagement:"Engagement",sales:"Sales"};function V2(t){return t?one[t]??"Add-on":"Add-on"}const ane={product:"Tied to products, variants, and checkout",engagement:"Brand story and feedback on the side",sales:"Promos, urgency, and cart nudges"};function lne(t){return t?ane[t]??"Optional storefront feature":"Optional storefront feature"}const cne=[{id:"desktop",label:"Desktop"},{id:"mobile",label:"Mobile"}],dc=390,fc=844;function H2({previewPath:t,controlId:e,draft:n,previewKind:r="page"}){const s=E.useRef(null),i=E.useRef(null),o=E.useRef(n),[l,u]=E.useState(!1),[d,h]=E.useState(!1),[g,y]=E.useState("desktop"),[b,x]=E.useState(1);o.current=n;const S=g==="mobile",k=E.useMemo(()=>JM(t,{controlId:e}),[t,e]),C=E.useCallback(()=>{const R=s.current?.contentWindow,_=o.current;!R||!_||QM(R,e,_)},[e]),A=E.useCallback(()=>{const R=s.current?.contentWindow;if(R)try{R.dispatchEvent(new Event("resize"))}catch{}},[]);return E.useEffect(()=>{u(!1),h(!1)},[k]),E.useEffect(()=>eO(R=>{const _=s.current?.contentWindow;!_||R!==_||(u(!0),C())}),[C,k]),E.useEffect(()=>{l&&C()},[n,l,C]),E.useEffect(()=>{if(!S){x(1);return}const R=i.current;if(!R||typeof ResizeObserver>"u")return;const _=()=>{const M=getComputedStyle(R),O=(Number.parseFloat(M.paddingLeft)||0)+(Number.parseFloat(M.paddingRight)||0),P=(Number.parseFloat(M.paddingTop)||0)+(Number.parseFloat(M.paddingBottom)||0),D=Math.max(0,R.clientWidth-O),F=Math.max(0,R.clientHeight-P),te=Math.min(1,D/dc,F/fc);x(Number.isFinite(te)&&te>0?te:1)};_();const N=new ResizeObserver(_);return N.observe(R),()=>N.disconnect()},[S]),E.useEffect(()=>{if(!l)return;const R=window.setTimeout(A,50);return()=>window.clearTimeout(R)},[g,b,l,A]),m.jsxs("div",{className:"vertebr-page-preview","data-preview-kind":r,children:[m.jsxs("div",{className:"vertebr-page-preview-meta",children:[m.jsxs("p",{children:[m.jsx("span",{children:r==="addon"?"Storefront":"Preview"}),m.jsx("strong",{children:t})]}),m.jsxs("p",{children:[m.jsx("span",{children:"Status"}),m.jsx("strong",{children:d?"Unavailable":l?"Live":"Loading…"})]}),S?m.jsxs("p",{children:[m.jsx("span",{children:"Viewport"}),m.jsxs("strong",{children:[dc,"×",fc]})]}):null,m.jsx("div",{className:"vertebr-page-preview-viewports",role:"group","aria-label":"Preview viewport",children:cne.map(R=>m.jsx("button",{type:"button","data-active":g===R.id?"true":void 0,onClick:()=>y(R.id),children:R.label},R.id))})]}),m.jsx("div",{ref:i,className:"vertebr-page-preview-stage","data-viewport":g,children:m.jsx("div",{className:"vertebr-page-preview-shell",style:S?{width:dc*b,height:fc*b}:void 0,children:m.jsx("div",{className:"vertebr-page-preview-frame",style:S?{width:dc,height:fc,transform:`scale(${b})`,transformOrigin:"top left"}:void 0,children:d?m.jsxs("div",{className:"vertebr-page-preview-empty",children:["Could not load host preview at ",t,"."]}):m.jsx("iframe",{ref:s,title:`Preview ${e}`,src:k,width:S?dc:void 0,height:S?fc:void 0,style:S?{width:dc,height:fc}:void 0,onLoad:()=>{u(!0),C(),A()},onError:()=>h(!0)})})})})]})}function une({client:t,catalog:e,addon:n,configData:r,onConfigSaved:s,galleryPicker:i,fontLibraryPicker:o}){const[l,u]=E.useState(r.value),d=E.useCallback(k=>{u(k)},[]),h=!!(l?.enabled??r.value.enabled),g=n.previewPath,y=!!g,b=Zp(e,"addon.write"),x=E.useMemo(()=>{const k=l??r.value;return y?{...k,enabled:!0}:k},[r.value,l,y]),S=m.jsx(kf,{schema:r.schema,value:r.value,client:t,canWrite:b,onChange:y?d:void 0,onSave:async k=>{const C=await t.setConfig(r.id,k);s(C)},...i,...o});return m.jsxs("div",{className:"vertebr-addon-editor",children:[m.jsxs("div",{className:"vertebr-addon-editor-head","data-category":n.category??"engagement",children:[m.jsxs("div",{className:"vertebr-addon-editor-head-start",children:[m.jsx("span",{className:"vertebr-addon-category","data-category":n.category??"engagement",children:V2(n.category)}),m.jsxs("span",{className:"vertebr-addon-status","data-enabled":h?"true":"false",children:[m.jsx("span",{className:"vertebr-addon-status-dot","aria-hidden":"true"}),h?"Enabled on storefront":"Disabled"]})]}),g?m.jsxs("div",{className:"vertebr-addon-editor-head-end",children:[m.jsx("span",{className:"vertebr-addon-preview-label",children:"Live preview"}),m.jsx("code",{className:"vertebr-addon-preview-path",children:g})]}):null]}),y&&g?m.jsxs("div",{className:"vertebr-page-editor vertebr-addon-page-editor",children:[m.jsx("div",{className:"vertebr-page-editor-form",children:S}),m.jsx(H2,{previewPath:g,controlId:r.id,draft:x,previewKind:"addon"})]}):m.jsxs("div",{className:"vertebr-addon-editor-form-only",children:[S,m.jsxs("div",{className:"vertebr-addon-preview-missing",children:[m.jsx("strong",{children:"Live preview unavailable"}),m.jsxs("p",{children:["Register a ",m.jsx("code",{children:"previewPath"})," on this add-on so Vertebr can iframe your storefront while you edit."]})]})]})]})}function dne({addonId:t,previewPath:e,draft:n,label:r}){const s=E.useRef(null),i=E.useRef(n),[o,l]=E.useState(!1),[u,d]=E.useState(!1);i.current=n;const h=E.useMemo(()=>e?JM(e,{controlId:t}):null,[t,e]),g=()=>{const y=s.current?.contentWindow,b=i.current;!y||!b||QM(y,t,b)};return E.useEffect(()=>{l(!1),d(!1)},[h]),E.useEffect(()=>{if(h)return eO(y=>{const b=s.current?.contentWindow;!b||y!==b||(l(!0),g())})},[h]),E.useEffect(()=>{!o||!n||g()},[n,o]),e?m.jsxs("div",{className:"vertebr-addon-thumb","data-ready":o?"true":void 0,"aria-label":r?`Preview ${r}`:`Preview ${t}`,children:[m.jsx("div",{className:"vertebr-addon-thumb-scale",children:u?m.jsx("div",{className:"vertebr-addon-thumb-fallback",children:"Preview unavailable"}):m.jsx("iframe",{ref:s,title:r?`Preview ${r}`:`Preview ${t}`,src:h??void 0,tabIndex:-1,loading:"lazy",onLoad:()=>{l(!0),g()},onError:()=>d(!0)})}),!o&&!u?m.jsx("div",{className:"vertebr-addon-thumb-loading",children:"Loading preview…"}):null]}):m.jsx("div",{className:"vertebr-addon-thumb vertebr-addon-thumb-empty",children:m.jsx("span",{children:"No preview route"})})}const fne=["product","engagement","sales"];function hne(t){const e=new Map;for(const s of t){const i=s.category??"other";e.has(i)||e.set(i,[]),e.get(i).push(s)}const n=[];for(const s of fne){const i=e.get(s);i?.length&&(n.push({category:s,label:V2(s),hint:lne(s),items:i}),e.delete(s))}const r=e.get("other");return r?.length&&n.push({category:"other",label:"Add-ons",hint:"Optional storefront features",items:r}),n}function pne({children:t}){const e=E.useRef(null),n=E.useRef(null);return E.useEffect(()=>{const r=n.current,s=e.current;if(!r||!s)return;const i=()=>{const l=r.scrollLeft>4,u=r.scrollLeft+r.clientWidth<r.scrollWidth-4;s.classList.toggle("can-scroll-left",l),s.classList.toggle("can-scroll-right",u)};i(),r.addEventListener("scroll",i,{passive:!0});const o=new ResizeObserver(i);return o.observe(r),()=>{r.removeEventListener("scroll",i),o.disconnect()}},[t]),m.jsx("div",{ref:e,className:"vertebr-addon-scroll-wrap",children:m.jsx("div",{ref:n,className:"vertebr-addon-scroll",tabIndex:0,children:t})})}function mne({client:t,catalog:e,onSelectAddon:n}){const r=e.addons??[],[s,i]=E.useState({}),[o,l]=E.useState(!0);E.useEffect(()=>{let h=!1;return(async()=>{l(!0);const g={};await Promise.all(r.map(async y=>{try{const b=await t.getConfig(y.id);g[y.id]={enabled:!!b.value.enabled,value:b.value}}catch{g[y.id]={enabled:!1,value:{}}}})),h||(i(g),l(!1))})(),()=>{h=!0}},[r,t]);const u=E.useMemo(()=>hne(r),[r]),d=E.useMemo(()=>{let h=0;const g={};for(const y of r){const b=y.category??"other";g[b]=(g[b]??0)+1,s[y.id]?.enabled&&(h+=1)}return{total:r.length,enabled:h,products:g.product??0,engagement:g.engagement??0,sales:g.sales??0}},[r,s]);return r.length?m.jsxs("div",{className:"vertebr-addon-overview",children:[m.jsxs("header",{className:"vertebr-addon-overview-toolbar",children:[m.jsx("div",{className:"vertebr-addon-overview-intro",children:m.jsx("p",{children:"Optional storefront features grouped by purpose. Scroll each row to browse, then configure one to edit with a live shop preview."})}),m.jsxs("div",{className:"vertebr-addon-overview-stats","aria-label":"Add-on summary",children:[m.jsxs("div",{className:"vertebr-addon-stat",children:[m.jsx("strong",{children:o?"—":d.enabled}),m.jsx("span",{children:"Enabled"})]}),m.jsxs("div",{className:"vertebr-addon-stat",children:[m.jsx("strong",{children:d.total}),m.jsx("span",{children:"Total"})]}),m.jsxs("div",{className:"vertebr-addon-stat","data-category":"product",children:[m.jsx("strong",{children:d.products}),m.jsx("span",{children:"Products"})]}),m.jsxs("div",{className:"vertebr-addon-stat","data-category":"engagement",children:[m.jsx("strong",{children:d.engagement}),m.jsx("span",{children:"Engagement"})]}),m.jsxs("div",{className:"vertebr-addon-stat","data-category":"sales",children:[m.jsx("strong",{children:d.sales}),m.jsx("span",{children:"Sales"})]})]})]}),u.map(h=>m.jsxs("section",{className:"vertebr-addon-overview-section","data-category":h.category,children:[m.jsxs("div",{className:"vertebr-addon-section-head",children:[m.jsxs("div",{className:"vertebr-addon-section-title",children:[m.jsx("h3",{children:h.label}),m.jsx("p",{children:h.hint})]}),m.jsxs("span",{className:"vertebr-addon-section-count",children:[h.items.length," add-on",h.items.length===1?"":"s"]})]}),m.jsx(pne,{children:h.items.map(g=>{const y=s[g.id],b=y?{...y.value,enabled:!0}:{enabled:!0};return m.jsxs("article",{className:"vertebr-addon-card","data-category":g.category??"engagement",children:[m.jsx(dne,{addonId:g.id,previewPath:g.previewPath,draft:b,label:g.label}),m.jsxs("div",{className:"vertebr-addon-card-body",children:[m.jsxs("div",{className:"vertebr-addon-card-head",children:[m.jsx("h4",{children:g.label}),m.jsx("span",{className:"vertebr-addon-status","data-enabled":o?void 0:y?.enabled?"true":"false",children:o?"…":y?.enabled?"On":"Off"})]}),g.description?m.jsx("p",{children:g.description}):null,m.jsxs("div",{className:"vertebr-addon-card-foot",children:[g.previewPath?m.jsx("span",{className:"vertebr-addon-route",children:g.previewPath}):null,m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",onClick:()=>n(g.id),children:"Configure"})]})]})]},g.id)})})]},h.category))]}):m.jsx("div",{className:"vertebr-addon-overview",children:m.jsx("div",{className:"vertebr-empty",children:"No add-ons registered for this host."})})}function gne(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function yne({client:t,label:e="Audit"}){const[n,r]=E.useState([]),[s,i]=E.useState(!0),[o,l]=E.useState(null);return E.useEffect(()=>{let u=!1;return(async()=>{try{i(!0),l(null);const d=await t.listAudit({limit:100,fresh:!0});u||r(d.items)}catch(d){u||l(d instanceof Error?d.message:"Failed to load audit")}finally{u||i(!1)}})(),()=>{u=!0}},[t]),m.jsxs("div",{className:"vertebr-audit",children:[m.jsxs("div",{className:"vertebr-panel-head",children:[m.jsx("h2",{children:e}),m.jsx("span",{className:"vertebr-count",children:s?"…":`${n.length} events`})]}),o?m.jsx("div",{className:"vertebr-error",children:o}):null,s&&n.length===0?m.jsx("div",{className:"vertebr-empty",children:"Loading audit log…"}):n.length===0?m.jsx("div",{className:"vertebr-empty",children:"No audit events yet."}):m.jsx("div",{className:"vertebr-table-wrap",children:m.jsxs("table",{className:"vertebr-table vertebr-audit-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"When"}),m.jsx("th",{children:"Actor"}),m.jsx("th",{children:"Action"}),m.jsx("th",{children:"Target"}),m.jsx("th",{children:"Summary"})]})}),m.jsx("tbody",{children:n.map(u=>m.jsxs("tr",{children:[m.jsx("td",{className:"vertebr-audit-when",children:gne(u.at)}),m.jsx("td",{children:u.actor??"—"}),m.jsx("td",{children:m.jsx("code",{className:"vertebr-audit-action",children:u.action})}),m.jsx("td",{children:m.jsxs("span",{className:"vertebr-audit-target",children:[u.targetType,u.targetId?` · ${u.targetId}`:""]})}),m.jsx("td",{children:u.summary})]},u.id))})]})})]})}function bne({environments:t,value:e,onChange:n,excludeId:r,ariaLabel:s="Destination environments",placeholder:i="Select destinations"}){const[o,l]=E.useState(!1),u=E.useRef(null),d=t.filter(y=>y.id!==r),h=d.filter(y=>e.includes(y.id));E.useEffect(()=>{if(!o)return;const y=b=>{u.current?.contains(b.target)||l(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[o]);const g=y=>{if(e.includes(y)){n(e.filter(b=>b!==y));return}n([...e,y])};return m.jsxs("div",{className:"vertebr-env-multi",ref:u,children:[m.jsxs("button",{type:"button",className:"vertebr-select-trigger vertebr-env-multi-trigger","aria-label":s,"aria-expanded":o,onClick:()=>l(y=>!y),children:[m.jsx("span",{className:"vertebr-env-multi-value",children:h.length===0?m.jsx("span",{className:"vertebr-env-multi-placeholder",children:i}):h.map(y=>m.jsxs("span",{className:"vertebr-env-multi-chip","data-tone":y.tone??"neutral",children:[m.jsx("span",{className:"vertebr-select-dot","data-tone":y.tone??"neutral"}),y.label]},y.id))}),m.jsx("span",{className:"vertebr-select-icon","aria-hidden":"true",children:"▾"})]}),o?m.jsx("div",{className:"vertebr-env-multi-menu",role:"listbox","aria-label":s,children:d.map(y=>{const b=e.includes(y.id);return m.jsxs("label",{className:"vertebr-env-multi-option","data-tone":y.tone??"neutral",children:[m.jsx("input",{type:"checkbox",checked:b,onChange:()=>g(y.id)}),m.jsx("span",{className:"vertebr-select-dot","data-tone":y.tone??"neutral"}),m.jsx("span",{children:y.label})]},y.id)})}):null]})}function IN({environment:t}){return m.jsxs("span",{className:"vertebr-sync-env-badge","data-tone":t.tone??"neutral",children:[m.jsx("span",{className:"vertebr-select-dot","data-tone":t.tone??"neutral"}),m.jsx("span",{children:t.label})]})}function U2({environments:t,value:e,onChange:n}){const r=t.find(s=>s.id===e);return m.jsxs(Fg,{value:e,onValueChange:n,children:[m.jsxs(qg,{className:"vertebr-select-trigger","aria-label":"Environment","data-tone":r?.tone??"neutral",children:[m.jsxs("span",{className:"vertebr-select-value",children:[m.jsx("span",{className:"vertebr-select-dot","data-tone":r?.tone??"neutral"}),m.jsx(Gg,{placeholder:"Select environment"})]}),m.jsx(Wg,{className:"vertebr-select-icon",children:m.jsx(vne,{})})]}),m.jsx(Kg,{children:m.jsx(Zg,{className:"vertebr-select-content",position:"popper",sideOffset:6,children:m.jsx(Xg,{className:"vertebr-select-viewport",children:t.map(s=>m.jsxs(Jg,{value:s.id,className:"vertebr-select-item","data-tone":s.tone??"neutral",children:[m.jsxs("span",{className:"vertebr-select-value",children:[m.jsx("span",{className:"vertebr-select-dot","data-tone":s.tone??"neutral"}),m.jsx(Qg,{children:s.label})]}),s.auth?.required?m.jsx("span",{className:"vertebr-env-lock",children:"auth"}):null,m.jsx(ey,{className:"vertebr-select-check",children:m.jsx(xne,{})})]},s.id))})})})]})}function vne(){return m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:m.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function xne(){return m.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:m.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 N0({title:t,children:e,subdued:n}){return m.jsxs("section",{className:"vertebr-card","data-subdued":n||void 0,children:[t?m.jsx("header",{className:"vertebr-card-head",children:t}):null,m.jsx("div",{className:"vertebr-card-body",children:e})]})}function vp({children:t,tone:e="neutral"}){return m.jsx("span",{className:"vertebr-badge","data-tone":e,children:t})}function LN(t,e){return t.find(n=>n.id===e)}function wne(t){const e=t.sync?.targets??[],n=new Map;for(const r of e){const s=r.group??"Content",i=n.get(s)??[];i.push(r),n.set(s,i)}return n}function Sne(t){return t==="error"?"danger":t==="changed"||t==="new"?"warn":t==="unchanged"?"ok":"neutral"}function kne(t){switch(t){case"changed":return"Changes";case"new":return"New";case"unchanged":return"Match";case"missing":return"Missing";case"skipped":return"Skipped";case"error":return"Error";default:return t}}function Cne({client:t,catalog:e}){const n=e.sync,{push:r}=pg(),s=e.environments,[i,o]=E.useState(()=>n?.defaultFrom??e.defaultEnvironment),[l,u]=E.useState(()=>{const H=n?.defaultTo??[],Z=n?.defaultFrom??e.defaultEnvironment;return H.filter(G=>G!==Z)}),[d,h]=E.useState(()=>(n?.targets??[]).filter(H=>H.defaultSelected).map(H=>H.id)),[g,y]=E.useState(null),[b,x]=E.useState(!1),[S,k]=E.useState(!1),[C,A]=E.useState(null),R=LN(s,i),_=E.useMemo(()=>l.map(H=>LN(s,H)).filter(H=>!!H),[s,l]),N=E.useMemo(()=>wne(e),[e]),M=(n?.targets.length??0)>0,O=E.useCallback(async()=>{if(!M||l.length===0){y(null);return}x(!0),A(null);try{const H=await t.getSyncPlan({from:i,to:l,targets:d});y(H)}catch(H){y(null),A(H instanceof Error?H.message:"Could not load sync preview")}finally{x(!1)}},[t,i,l,d,M]);E.useEffect(()=>{O()},[O]);const P=H=>{h(Z=>Z.includes(H)?Z.filter(G=>G!==H):[...Z,H])},D=async()=>{if(!M||l.length===0||d.length===0)return;const H=R?.label??i,Z=_.map(L=>L.label).join(", "),G=(n?.targets??[]).filter(L=>d.includes(L.id)).map(L=>L.label).join(", "),ae=_.some(L=>L.tone==="danger"),z=[`Copy from ${H} to ${Z}.`,"",`Targets: ${G}`,"","This may overwrite content in the destination environment(s)."];if(ae&&z.push("","You are writing to a production environment."),!!window.confirm(z.join(`
|
|
340
|
+
`))){k(!0),A(null);try{const L=await t.runSync({from:i,to:l,targets:d});r(L.message??(L.ok?"Sync complete":"Sync finished with errors"),L.ok?"ok":"danger"),await O()}catch(L){A(L instanceof Error?L.message:"Sync failed"),r(L instanceof Error?L.message:"Sync failed","danger")}finally{k(!1)}}},F=(H,Z)=>g?.destinations.find(G=>G.to===H)?.targets.find(G=>G.id===Z),te=_.length>0&&d.length>0?`Sync ${d.length} item${d.length===1?"":"s"} to ${_.map(H=>H.label).join(", ")}`:"Select destinations and content to sync";return M?m.jsxs("div",{className:"vertebr-sync-page",children:[m.jsxs("div",{className:"vertebr-sync-scroll",children:[m.jsx(N0,{title:"Direction",children:m.jsxs("div",{className:"vertebr-sync-direction",children:[m.jsxs("div",{className:"vertebr-sync-direction-grid",children:[m.jsxs("label",{className:"vertebr-sync-field",children:[m.jsx("span",{className:"vertebr-sync-field-label",children:"From"}),m.jsx(U2,{environments:s,value:i,onChange:H=>{o(H),u(Z=>Z.filter(G=>G!==H))}})]}),m.jsx("div",{className:"vertebr-sync-connector","aria-hidden":"true",children:_.length>0?_.map(H=>m.jsx("span",{className:"vertebr-sync-connector-arrow",children:"→"},H.id)):m.jsx("span",{className:"vertebr-sync-connector-arrow",children:"→"})}),m.jsxs("label",{className:"vertebr-sync-field",children:[m.jsx("span",{className:"vertebr-sync-field-label",children:"To"}),m.jsx(bne,{environments:s,value:l,excludeId:i,onChange:u,placeholder:"Select one or more destinations"})]})]}),R&&_.length>0?m.jsx("div",{className:"vertebr-sync-preview","aria-label":"Sync direction",children:m.jsxs("div",{className:"vertebr-sync-preview-flow","data-dest-count":_.length,children:[m.jsxs("div",{className:"vertebr-sync-preview-col vertebr-sync-preview-col-from",children:[m.jsx("span",{className:"vertebr-sync-preview-caption",children:"From"}),m.jsx(IN,{environment:R})]}),m.jsx("div",{className:"vertebr-sync-preview-col vertebr-sync-preview-col-routes",children:_.map((H,Z)=>m.jsxs("div",{className:"vertebr-sync-preview-route",children:[m.jsx("span",{className:"vertebr-sync-preview-arrow","aria-hidden":"true",children:"→"}),m.jsxs("div",{className:"vertebr-sync-preview-col vertebr-sync-preview-col-to",children:[Z===0?m.jsx("span",{className:"vertebr-sync-preview-caption",children:"To"}):m.jsx("span",{className:"vertebr-sync-preview-caption","aria-hidden":"true",children:" "}),m.jsx(IN,{environment:H})]})]},H.id))})]})}):m.jsx("p",{className:"vertebr-sync-direction-hint",children:"Pick a source environment and one or more destinations to preview changes."})]})}),m.jsxs(N0,{title:"What to sync",children:[m.jsxs("div",{className:"vertebr-sync-targets-head",children:[m.jsx("p",{className:"vertebr-sync-targets-copy",children:"Review what will change in each destination before syncing."}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-sync-refresh",disabled:b||l.length===0,onClick:()=>{O()},children:b?"Refreshing…":"Refresh preview"})]}),[...N.entries()].map(([H,Z])=>m.jsxs("div",{className:"vertebr-sync-target-group",children:[m.jsx("div",{className:"vertebr-sync-target-group-label",children:H}),m.jsx("ul",{className:"vertebr-sync-target-list",children:Z.map(G=>{const ae=d.includes(G.id);return m.jsx("li",{children:m.jsxs("button",{type:"button",className:"vertebr-sync-target-row","data-selected":ae||void 0,onClick:()=>P(G.id),children:[m.jsx("span",{className:"vertebr-sync-target-check","aria-hidden":"true",children:ae?"✓":""}),m.jsxs("span",{className:"vertebr-sync-target-main",children:[m.jsx("span",{className:"vertebr-sync-target-title",children:G.label}),G.description?m.jsx("span",{className:"vertebr-sync-target-desc",children:G.description}):null]}),m.jsx("span",{className:"vertebr-sync-target-badges",children:_.length===0?m.jsx(vp,{children:"Choose destination"}):b?m.jsx(vp,{children:"Previewing…"}):_.map(z=>{const L=F(z.id,G.id);return L?m.jsxs("span",{className:"vertebr-sync-target-dest",title:L.summary,children:[m.jsxs(vp,{tone:Sne(L.status),children:[z.label,": ",kne(L.status)]}),m.jsx("span",{className:"vertebr-sync-target-summary",children:L.summary})]},z.id):m.jsx(vp,{children:z.label},z.id)})})]})},G.id)})})]},H))]}),n?.excluded.length?m.jsx(N0,{title:"Never synced",subdued:!0,children:m.jsx("ul",{className:"vertebr-sync-excluded-list",children:n.excluded.map(H=>m.jsxs("li",{children:[m.jsx("span",{className:"vertebr-sync-excluded-name",children:H.label}),m.jsx("span",{className:"vertebr-sync-excluded-reason",children:H.reason})]},H.label))})}):null,C?m.jsx("div",{className:"vertebr-banner","data-tone":"danger",children:C}):null]}),m.jsxs("div",{className:"vertebr-savebar vertebr-sync-footer",children:[m.jsx("div",{className:"vertebr-savebar-message",children:te}),m.jsx("div",{className:"vertebr-savebar-actions",children:m.jsxs("button",{type:"button",className:"vertebr-btn vertebr-btn-primary vertebr-sync-run-btn",disabled:S||b||l.length===0||d.length===0,onClick:()=>{D()},children:[m.jsx(Pw,{}),m.jsx("span",{children:S?"Syncing…":"Sync selected"})]})})]})]}):m.jsx("div",{className:"vertebr-sync-page",children:m.jsx("div",{className:"vertebr-sync-scroll",children:m.jsxs("div",{className:"vertebr-empty-state vertebr-sync-empty",children:[m.jsx("h3",{children:"Sync not configured"}),m.jsxs("p",{children:["This admin has multiple environments but no sync targets yet. Hosts register targets with ",m.jsx("code",{children:"admin.sync()"}),"."]})]})})})}function Ene({client:t,catalog:e,configData:n,isPageSelection:r,previewPath:s,onConfigSaved:i,onRefreshConfig:o,galleryPicker:l,fontLibraryPicker:u}){const[d,h]=E.useState(n.value),g=!!s,y=Zp(e,"config.write"),b=!!e.revisionsEnabled||!!n.revisionsEnabled,x=E.useCallback(k=>{h(k)},[]),S=m.jsx(kf,{schema:n.schema,value:n.value,client:t,canWrite:y,onChange:g?x:void 0,onSave:async k=>{const C=await t.setConfig(n.id,k);i(C)},...l,...u});return m.jsxs("div",{className:"vertebr-config-editor",children:[g?m.jsxs("div",{className:"vertebr-panel-head",children:[m.jsx("h2",{children:r?"Page content":n.label}),m.jsxs("span",{className:"vertebr-count",children:[Object.keys(n.schema).length," fields"]})]}):r?m.jsxs("div",{className:"vertebr-panel-head",children:[m.jsx("h2",{children:"Page content"}),m.jsxs("span",{className:"vertebr-count",children:[Object.keys(n.schema).length," fields"]})]}):null,g&&s?m.jsxs("div",{className:"vertebr-page-editor",children:[m.jsx("div",{className:"vertebr-page-editor-form",children:S}),m.jsx(H2,{previewPath:s,controlId:n.id,draft:d??n.value})]}):S,b?m.jsx(FQ,{client:t,configId:n.id,onPublished:async()=>{await o?.()}}):null]})}function Tne({client:t,catalog:e,selection:n,onSelectionChange:r,authRequired:s,loading:i,isPageSelection:o,metricsData:l,metricsLoading:u,metricsRange:d,onMetricsRangeChange:h,onRefreshMetrics:g,galleryData:y,galleryLoading:b,onRefreshGallery:x,fontLibraryData:S,fontLibraryLoading:k,onRefreshFonts:C,emailsData:A,emailsLoading:R,onRefreshEmails:_,resourceData:N,resourceSearch:M,onResourceSearchChange:O,onRefreshResource:P,onRefreshConfig:D,configData:F,onConfigSaved:te,galleryPicker:H,fontLibraryPicker:Z}){return e?m.jsx("div",{className:"vertebr-content",children:m.jsxs("section",{className:"vertebr-panel",children:[n?.kind==="overview"?m.jsx(Bee,{label:l?.label??e.metrics?.label,windowLabel:l?.windowLabel,compareLabel:l?.compareLabel,metrics:l?.metrics??[],charts:l?.charts??[],range:d,onRangeChange:h,loading:u,onRefresh:()=>{g()}}):null,n?.kind==="audit"?m.jsx(yne,{client:t,label:e.audit?.label}):null,n?.kind==="sync"?m.jsx(Cne,{client:t,catalog:e}):null,n?.kind==="gallery"&&y?m.jsx(Eee,{label:y.label,items:y.items,accept:y.accept,maxBytes:y.maxBytes,canDelete:y.canDelete,loading:b,onRefresh:()=>{x()},onUpload:async G=>{G.length===1&&G[0]?await t.uploadGalleryFile(G[0]):await t.uploadGalleryFiles(G),await x()},onDelete:y.canDelete?async G=>{await t.deleteGalleryItem(G),await x()}:void 0}):null,n?.kind==="fontLibrary"&&S?m.jsx(Cee,{label:S.label,data:S,loading:k,onRefresh:()=>{C()},onUpload:async(G,ae)=>{for(const z of G)await t.uploadFontFile(z,ae);await C()},onImportGoogle:S.canImportGoogle?async G=>{await t.importGoogleFont(G),await C()}:void 0,onDelete:S.canDelete?async G=>{await t.deleteFontItem(G),await C()}:void 0}):null,n?.kind==="emails"&&A?m.jsx(xee,{data:A,loading:R,tab:n.tab??"compose",onRefresh:()=>{_()},onLoadRecipients:async G=>{const ae=await t.listResource(G,{fresh:!0}),z=new Set,L=[];for(const W of ae.items){const ce=String(W.email??"").trim().toLowerCase();if(!ce.includes("@")||z.has(ce))continue;z.add(ce);const pe=String(W.id??W.uid??W.slug??ce),$=String(W.displayName??W.name??"").trim();L.push({email:ce,id:pe,...$?{label:$}:{}})}return L.sort((W,ce)=>W.email.localeCompare(ce.email)),L},onPreview:G=>t.previewEmails(G),onSend:async G=>{const ae=await t.sendEmails(G);return{sent:ae.sent,failed:ae.failed}},onSchedule:A.canSchedule?async G=>{await t.scheduleEmails(G)}:void 0,onCancel:A.canSchedule?async G=>{await t.cancelEmailCampaign(G)}:void 0,onSaveLibrary:A.canLibrary?async G=>{await t.saveEmailLibraryTemplate(G)}:void 0,onDeleteLibrary:A.canLibrary?async G=>{await t.deleteEmailLibraryTemplate(G)}:void 0}):null,n?.kind==="resource"&&N?m.jsx(tne,{schema:N.schema,items:N.items,label:N.label,listQuery:N.listQuery,total:N.total,searchQuery:M,onSearchChange:O,initialEditRowId:n.rowId&&n.id===N.id?n.rowId:void 0,onEditRowIdChange:G=>{r?.({kind:"resource",id:N.id,rowId:G??void 0})},permissions:N.permissions,actions:N.actions,collectionActions:N.collectionActions,bulkActions:N.bulkActions,uploads:N.uploads,storageKey:N.id,onUpdate:N.permissions.update?async(G,ae)=>{await t.updateResource(N.id,G,ae),await P()}:void 0,onCreate:N.permissions.create?async G=>{await t.createResource(N.id,G),await P()}:void 0,onDelete:N.permissions.delete?async G=>{await t.deleteResource(N.id,G),await P()}:void 0,onAction:async(G,ae,z)=>{await t.runResourceAction(N.id,G,ae,z)},onActionDone:P,onPreviewMail:async(G,ae,z)=>t.previewResourceMail(N.id,G,ae,z),onCollectionAction:async(G,ae)=>t.runCollectionAction(N.id,G,ae),onBulkAction:N.bulkActions?async(G,ae,z)=>{await t.runBulkAction(N.id,G,{rowIds:ae,input:z})}:void 0,onUpload:N.uploads?async(G,ae)=>{if(ae.length===1&&ae[0]){const L=await t.uploadResourceFile(N.id,G,ae[0]);return[{url:L.url,name:L.name}]}return(await t.uploadResourceFiles(N.id,G,ae)).files}:void 0,...H}):null,n?.kind==="addons"?m.jsx(mne,{client:t,catalog:e,onSelectAddon:G=>r?.({kind:"addon",id:G})}):null,n?.kind==="config"&&F?m.jsx(Ene,{client:t,catalog:e,configData:F,isPageSelection:o,previewPath:e.configs.find(G=>G.id===F.id)?.previewPath,onConfigSaved:te,onRefreshConfig:D,galleryPicker:H,fontLibraryPicker:Z},F.id):null,n?.kind==="addon"&&F?(()=>{const G=e.addons?.find(ae=>ae.id===F.id);return G?m.jsx(une,{client:t,catalog:e,addon:G,configData:F,onConfigSaved:te,galleryPicker:H,fontLibraryPicker:Z},F.id):null})():null]})}):m.jsx("div",{className:"vertebr-content",children:m.jsx("section",{className:"vertebr-panel",children:m.jsx("div",{className:"vertebr-empty",children:s?"Authenticated access required for this environment.":i?"Loading…":"Unable to load catalog."})})})}function _ne({catalogLoaded:t,authRequired:e,selection:n,isPageSelection:r,hasPagePreview:s,selectionDescription:i}){return!t&&e?"Provide an access token to load this environment.":i||(n?.kind==="overview"?"Commerce, growth, and catalog for the selected environment.":n?.kind==="sync"?"Copy selected content between environments.":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"?n.rowId?"Edit this record — changes apply to the selected environment.":"Manage records scoped to the selected environment.":n?.kind==="config"?s?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 Ane({activeLabel:t,catalogLoaded:e,authRequired:n,selection:r,isPageSelection:s,hasPagePreview:i,selectionDescription:o,error:l,breadcrumbs:u}){return m.jsxs("header",{className:"vertebr-header",children:[m.jsxs("div",{children:[u.length>1?m.jsx("ol",{className:"vertebr-breadcrumbs",children:u.map((d,h)=>m.jsx("li",{children:h===u.length-1?m.jsx("strong",{children:d.label}):d.label},`${d.label}-${h}`))}):null,m.jsx("h1",{children:t}),m.jsx("p",{children:_ne({catalogLoaded:e,authRequired:n,selection:r,isPageSelection:s,hasPagePreview:i,selectionDescription:o})})]}),l?m.jsx("span",{className:"vertebr-status","data-tone":"danger",children:l}):null]})}function Rne(){const{state:t}=kO();return t.visible?m.jsxs("div",{className:"vertebr-savebar","data-tone":t.tone,children:[m.jsx("div",{className:"vertebr-savebar-message",children:t.saving?"Saving…":t.message??(t.isDirty?"Unsaved changes":"Saved")}),m.jsxs("div",{className:"vertebr-savebar-actions",children:[t.onDiscard&&t.isDirty?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:t.saving,onClick:t.onDiscard,children:"Discard"}):null,t.onSave?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",disabled:t.saving||!t.isDirty,onClick:()=>{t.onSave?.()},children:"Save"}):null]})]}):null}const PN="https://github.com/yaboijams/vertebr";function Nne({collapsed:t}){return t?m.jsx("div",{className:"vertebr-powered-by","data-collapsed":"true",children:m.jsx("a",{href:PN,target:"_blank",rel:"noopener noreferrer",title:"Powered by Vertebr","aria-label":"Powered by Vertebr",children:"V"})}):m.jsx("div",{className:"vertebr-powered-by",children:m.jsxs("a",{href:PN,target:"_blank",rel:"noopener noreferrer",children:["Powered by ",m.jsx("strong",{children:"Vertebr"})]})})}function Mne({item:t,collapsed:e}){const n=!!t.children?.length,r=t.children?.some(u=>u.active)??!1,s=t.active||r,[i,o]=E.useState(s),l=t.icon??ys(t.key);if(E.useEffect(()=>{s&&o(!0)},[s]),!n||e){const u=n?s:t.active;return m.jsxs("button",{type:"button","data-active":u||void 0,title:e?t.label:void 0,onClick:t.onSelect,children:[m.jsx(l,{className:"vertebr-nav-icon"}),m.jsx("span",{className:"vertebr-nav-label-text",children:t.label})]})}return m.jsxs("div",{className:"vertebr-nav-item","data-has-children":"true","data-open":i||void 0,children:[m.jsxs("div",{className:"vertebr-nav-parent",children:[m.jsxs("button",{type:"button",className:"vertebr-nav-parent-label","data-active":s&&!r,"data-section":s||void 0,title:e?t.label:void 0,onClick:()=>{o(!0),t.onSelect()},children:[m.jsx(l,{className:"vertebr-nav-icon"}),m.jsx("span",{className:"vertebr-nav-label-text",children:t.label})]}),e?null:m.jsx("button",{type:"button",className:"vertebr-nav-parent-toggle","aria-label":i?`Collapse ${t.label}`:`Expand ${t.label}`,"aria-expanded":i,onClick:()=>o(u=>!u),children:m.jsx("span",{className:"vertebr-nav-chevron","aria-hidden":"true",children:"▸"})})]}),m.jsx("div",{className:"vertebr-nav-sub-wrap","data-open":i?"true":void 0,children:m.jsx("div",{className:"vertebr-nav-sub-inner",children:m.jsx("div",{className:"vertebr-nav-sub",role:"group",children:t.children.map(u=>m.jsx("button",{type:"button",className:"vertebr-nav-subitem","data-active":u.active,onClick:()=>{o(!0),u.onSelect()},children:u.label},u.key))})})})]})}function One({navGroups:t,collapsed:e}){return m.jsxs("aside",{className:"vertebr-sidebar","data-collapsed":e||void 0,children:[m.jsx("div",{className:"vertebr-sidebar-top",children:m.jsx("nav",{className:"vertebr-nav",children:t.map(n=>m.jsxs("div",{className:"vertebr-nav-group",children:[m.jsx("div",{className:"vertebr-nav-label",children:n.label}),n.items.map(r=>m.jsx(Mne,{item:r,collapsed:e},r.key))]},n.label))})}),m.jsx("div",{className:"vertebr-sidebar-bottom",children:m.jsx(Nne,{collapsed:e})})]})}function jne(){const{toasts:t,dismiss:e}=pg();return t.length?m.jsx("div",{className:"vertebr-toast-stack","aria-live":"polite",children:t.map(n=>m.jsxs("div",{className:"vertebr-toast","data-tone":n.tone,role:"status",children:[m.jsx("span",{children:n.message}),m.jsx("button",{type:"button",className:"vertebr-toast-dismiss","aria-label":"Dismiss",onClick:()=>e(n.id),children:"×"})]},n.id))}):null}function Dne({theme:t,onChange:e,compact:n}){return m.jsx("div",{className:"vertebr-theme","data-compact":n?"true":void 0,children:m.jsxs("div",{className:"vertebr-theme-toggle",role:"group","aria-label":"Appearance",children:[m.jsxs("button",{type:"button",className:"vertebr-theme-option","data-active":t==="light","aria-pressed":t==="light","aria-label":"Light",title:"Light",onClick:()=>e("light"),children:[m.jsx(Ine,{}),n?null:"Light"]}),m.jsxs("button",{type:"button",className:"vertebr-theme-option","data-active":t==="dark","aria-pressed":t==="dark","aria-label":"Dark",title:"Dark",onClick:()=>e("dark"),children:[m.jsx(Lne,{}),n?null:"Dark"]})]})})}function Ine(){return m.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:[m.jsx("circle",{cx:"12",cy:"12",r:"4"}),m.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 Lne(){return m.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:m.jsx("path",{d:"M21 14.5A8.5 8.5 0 0 1 9.5 3 7 7 0 1 0 21 14.5z"})})}function Pne(t){return t==="ok"?"OK":t==="warn"?"Warn":"Error"}function zne(t){if(!t)return null;const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function $ne({checks:t,environment:e,onClose:n,onRefresh:r}){const[s,i]=E.useState(!1),[o,l]=E.useState(null);E.useEffect(()=>{const h=y=>{y.key==="Escape"&&n()};window.addEventListener("keydown",h);const g=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",h),document.body.style.overflow=g}},[n]);const u=async()=>{if(!(!r||s)){i(!0),l(null);try{await r()}catch(h){l(h instanceof Error?h.message:"Failed to refresh health")}finally{i(!1)}}},d=zne(t.map(h=>h.checkedAt).find(Boolean));return m.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:n,children:m.jsxs("div",{className:"vertebr-modal vertebr-modal-sm vertebr-health-modal",role:"dialog","aria-modal":"true","aria-label":"System health",onClick:h=>h.stopPropagation(),children:[m.jsxs("header",{className:"vertebr-modal-head",children:[m.jsxs("div",{className:"vertebr-modal-heading",children:[m.jsx("p",{className:"vertebr-modal-eyebrow",children:"Operations"}),m.jsx("h2",{children:"System health"}),e||d?m.jsx("p",{className:"vertebr-health-modal-meta",children:[e?`Env: ${e}`:null,d?`Checked ${d}`:null].filter(Boolean).join(" · ")}):null]}),m.jsxs("div",{className:"vertebr-modal-actions",children:[r?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:s,onClick:()=>{u()},children:s?"Refreshing…":"Refresh"}):null,m.jsx("button",{type:"button",className:"vertebr-btn",onClick:n,children:"Close"})]})]}),m.jsxs("div",{className:"vertebr-modal-body",children:[o?m.jsx("p",{className:"vertebr-health-modal-error",children:o}):null,t.length===0?m.jsx("p",{className:"vertebr-health-modal-empty",children:"No health checks reported."}):m.jsx("ul",{className:"vertebr-health-list",children:t.map(h=>m.jsxs("li",{className:"vertebr-health-item","data-status":h.status,children:[m.jsxs("div",{className:"vertebr-health-item-top",children:[m.jsxs("span",{className:"vertebr-health-badge","data-status":h.status,children:[m.jsx("span",{className:"vertebr-health-badge-dot","aria-hidden":!0}),Pne(h.status)]}),m.jsx("strong",{className:"vertebr-health-item-label",children:h.label})]}),h.detail?m.jsx("p",{className:"vertebr-health-item-detail",children:h.detail}):null]},h.id))})]})]})})}function Bne(t){return t?.length?t.some(e=>e.status==="error")?"error":t.some(e=>e.status==="warn")?"warn":"ok":null}function Vne(t){return t==="ok"?"Healthy":t==="warn"?"Attention":"Degraded"}function Hne({brand:t,hostName:e,hostLogoUrl:n,envList:r,environment:s,onEnvironmentChange:i,authUserLabel:o,onSignOut:l,getAccessToken:u,authViaTokenOnly:d,authRequired:h,token:g,tokenDraft:y,onTokenDraftChange:b,onSaveToken:x,onClearToken:S,theme:k,onThemeChange:C,sidebarCollapsed:A,onToggleSidebar:R,syncEnabled:_,onOpenSync:N,onOpenSearch:M,healthChecks:O,onRefreshHealth:P}){const[D,F]=E.useState(!1),te=Bne(O),H=!u&&!d&&(h||!!g);return m.jsxs(m.Fragment,{children:[m.jsxs("header",{className:"vertebr-topbar",children:[m.jsxs("div",{className:"vertebr-topbar-start",children:[m.jsx("button",{type:"button",className:"vertebr-topbar-toggle","aria-label":A?"Expand sidebar":"Collapse sidebar",onClick:R,children:m.jsx(hU,{})}),m.jsx("div",{className:"vertebr-topbar-brand-wrap",children:e?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"vertebr-topbar-host","data-primary":"true",children:[n?m.jsx("img",{className:"vertebr-topbar-host-logo",src:n,alt:""}):null,m.jsx("strong",{className:"vertebr-topbar-host-label",children:e})]}),m.jsx("span",{className:"vertebr-topbar-product",children:t})]}):m.jsx("strong",{className:"vertebr-topbar-brand",children:t})}),r.length>1?m.jsx("div",{className:"vertebr-topbar-env",children:m.jsx(U2,{environments:r,value:s,onChange:i})}):null]}),m.jsx("div",{className:"vertebr-topbar-center",children:m.jsxs("button",{type:"button",className:"vertebr-topbar-search",onClick:M,children:[m.jsx(rO,{}),m.jsx("span",{children:"Search admin"}),m.jsx("kbd",{children:"⌘K"})]})}),m.jsxs("div",{className:"vertebr-topbar-end",children:[m.jsxs("div",{className:"vertebr-topbar-cluster","aria-label":"Operations",children:[te&&O?.length?m.jsxs("button",{type:"button",className:"vertebr-topbar-health","data-tone":te,"aria-haspopup":"dialog","aria-expanded":D,onClick:()=>F(!0),children:[m.jsx("span",{className:"vertebr-topbar-health-dot","aria-hidden":!0}),m.jsx("span",{className:"vertebr-topbar-health-text",children:Vne(te)})]}):null,_&&N?m.jsxs("button",{type:"button",className:"vertebr-topbar-action",onClick:N,children:[m.jsx(Pw,{}),m.jsx("span",{children:"Sync"})]}):null]}),H?m.jsxs("div",{className:"vertebr-topbar-token",children:[m.jsx("input",{className:"vertebr-auth-input",type:"password",placeholder:"Access token",value:y,onChange:Z=>b(Z.target.value),autoComplete:"off"}),m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:x,children:"Use"}),g?m.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:S,children:"Clear"}):null]}):null,u||l?m.jsxs("div",{className:"vertebr-topbar-account",children:[u&&o?m.jsx("span",{className:"vertebr-topbar-user",title:o,children:o}):null,l?m.jsx("button",{type:"button",className:"vertebr-topbar-signout",onClick:()=>{l()},children:"Sign out"}):null]}):null,m.jsx(Dne,{theme:k,onChange:C,compact:!0})]})]}),D&&O?.length?m.jsx($ne,{checks:O,environment:s,onClose:()=>F(!1),onRefresh:P}):null]})}function Une(t,e){const n=[{label:"Home",href:"/overview"}];if(!t||!e)return n;switch(t.kind){case"overview":return[...n,{label:e.metrics?.label??"Overview"}];case"sync":return[...n,{label:"Sync environments"}];case"audit":return[...n,{label:e.audit?.label??"Audit"}];case"addons":return[...n,{label:"Add-ons"}];case"addon":{const r=e.addons?.find(s=>s.id===t.id);return[...n,{label:"Add-ons",href:"/addons"},{label:r?.label??t.id}]}case"gallery":return[...n,{label:e.gallery?.label??"Gallery"}];case"fontLibrary":return[...n,{label:e.fontLibrary?.label??"Fonts"}];case"emails":return[...n,{label:e.emails?.label??"Email"},{label:t.tab==="templates"?"Templates":t.tab==="activity"?"Activity":"Compose"}];case"resource":{const r=e.resources.find(i=>i.id===t.id),s=[...n,{label:r?.group??"Products",href:void 0},{label:r?.label??t.id}];return t.rowId&&s.push({label:t.rowId}),s}case"config":{const r=e.configs.find(i=>i.id===t.id),s=r?.group??(r?.section==="page"?"Pages":"Settings");return[...n,{label:s},{label:r?.label??t.id}]}default:return n}}const Fne=new Set(["compose","templates","activity"]);function qne(t){const e=(t||"/admin/api").replace(/\/$/,"")||"/admin/api";return e.endsWith("/api")?e.slice(0,-4)||"/":e}function F2(t){return!t||t==="/"?"":t.replace(/\/$/,"")}function Gne(t,e){if(!t)return"/overview";switch(t.kind){case"overview":return"/overview";case"sync":return"/sync";case"audit":return"/audit";case"addons":return"/addons";case"addon":return`/addons/${encodeURIComponent(t.id)}`;case"gallery":return"/gallery";case"fontLibrary":return"/fonts";case"emails":return`/emails/${t.tab??"compose"}`;case"resource":return t.rowId?`/resources/${encodeURIComponent(t.id)}/${encodeURIComponent(t.rowId)}`:`/resources/${encodeURIComponent(t.id)}`;case"config":return`/${e.configs.find(s=>s.id===t.id)?.section==="page"?"pages":"config"}/${encodeURIComponent(t.id)}`;default:return"/overview"}}function Wne(t,e,n){const r=F2(t),s=Gne(e,n);return`${r}${s}`||"/"}function Kne(t){return t&&Fne.has(t)?t:"compose"}function M0(t,e,n){const r=F2(e);let s=t||"/";if(r){if(s===r||s===`${r}/`)return null;(s.startsWith(`${r}/`)||s.startsWith(r))&&(s=s.slice(r.length))}const i=s.replace(/^\//,"").split("/").filter(Boolean);if(i.length===0)return null;const[o,...l]=i;if(o==="overview")return{kind:"overview"};if(o==="sync")return{kind:"sync"};if(o==="audit")return{kind:"audit"};if(o==="addons"){if(!l[0])return{kind:"addons"};const u=decodeURIComponent(l[0]);return n&&!n.addons?.some(d=>d.id===u)?null:{kind:"addon",id:u}}if(o==="gallery")return{kind:"gallery"};if(o==="fonts")return{kind:"fontLibrary"};if(o==="emails")return{kind:"emails",tab:Kne(l[0])};if(o==="resources"&&l[0]){const u=decodeURIComponent(l[0]);return n&&!n.resources.some(d=>d.id===u)?null:l[1]?{kind:"resource",id:u,rowId:decodeURIComponent(l[1])}:{kind:"resource",id:u}}if((o==="pages"||o==="config")&&l[0]){const u=decodeURIComponent(l[0]);if(n){const d=n.configs.find(h=>h.id===u);if(!d||o==="pages"&&d.section!=="page"||o==="config"&&d.section==="page")return null}return{kind:"config",id:u}}return null}function Sr(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 zN(t,e){return t?t.kind==="overview"?e.metrics?t:Sr(e):t.kind==="sync"?e.sync?.enabled?t:Sr(e):t.kind==="audit"?e.audit?t:Sr(e):t.kind==="addons"?e.addons?.length?t:Sr(e):t.kind==="addon"?e.addons?.some(n=>n.id===t.id)?t:Sr(e):t.kind==="gallery"?e.gallery?t:Sr(e):t.kind==="fontLibrary"?e.fontLibrary?t:Sr(e):t.kind==="emails"?e.emails?t:Sr(e):t.kind==="resource"?e.resources.some(n=>n.id===t.id)?t:Sr(e):t.kind==="config"&&e.configs.some(n=>n.id===t.id)?t:Sr(e):Sr(e)}function Zne(t,e){return t===e?!0:!t||!e?t===e:t.kind!==e.kind?!1:t.kind==="overview"||t.kind==="gallery"||t.kind==="fontLibrary"||t.kind==="sync"||t.kind==="audit"||t.kind==="addons"?!0:t.kind==="addon"&&e.kind==="addon"?t.id===e.id:t.kind==="emails"&&e.kind==="emails"?(t.tab??"compose")===(e.tab??"compose"):t.kind==="resource"&&e.kind==="resource"?t.id===e.id&&(t.rowId??"")===(e.rowId??""):t.kind==="config"&&e.kind==="config"?t.id===e.id:!1}function Yne(t){const e=[],n=new Map;for(const r of t){const s=r.group.trim()||"Resources";n.has(s)||(n.set(s,[]),e.push(s)),n.get(s).push(r)}return e.map(r=>({label:r,items:n.get(r)}))}function O0(t){try{return localStorage.getItem(t)}catch{return null}}function xp(t,e){try{localStorage.setItem(t,e)}catch{}}function $N(t){try{localStorage.removeItem(t)}catch{}}function BN({apiBase:t="/admin/api",basePath:e,title:n="Control plane",envStorageKey:r="vertebr:env",tokenStorageKey:s="vertebr:token",themeStorageKey:i="vertebr:theme",metricsRangeStorageKey:o="vertebr:metrics-range",getAccessToken:l,authUserLabel:u,onSignOut:d}){const h=e??qne(t),{theme:g,setTheme:y}=tU(i),[b,x]=E.useState(()=>O0(r)??""),[S,k]=E.useState(()=>O0(s)??""),[C,A]=E.useState(S),R=E.useCallback(()=>b,[b]),_=E.useMemo(()=>B0({apiBase:t,getEnvironment:R,getAccessToken:l??(()=>S||null)}),[t,R,l,S]),[N,M]=E.useState(null),[O,P]=E.useState(null),[D,F]=E.useState(()=>typeof window>"u"?{kind:"overview"}:M0(window.location.pathname,h,null)??{kind:"overview"}),[te,H]=E.useState(null),[Z,G]=E.useState(""),[ae,z]=E.useState(null),[L,W]=E.useState(null),[ce,pe]=E.useState(!1),[$,Y]=E.useState(()=>sU(O0(o))),[he,be]=E.useState(null),[Me,Ce]=E.useState(!1),[He,Ee]=E.useState(null),[le,me]=E.useState(!1),[De,Be]=E.useState(null),[Ke,mt]=E.useState(!1),[ht,Wt]=E.useState(null),[Vt,Yt]=E.useState(null),[kn,jn]=E.useState(!0),[Dn,Tr]=E.useState(!1),[js,Ht]=E.useState(!1),pr=E.useRef(!0),Gn=E.useCallback((ge,Ae,Ct=!1)=>{if(typeof window>"u"||!ge)return;const ee=Wne(h,ge,Ae);if(window.location.pathname===ee)return;const re=Ct?"replaceState":"pushState";window.history[re](null,"",ee)},[h]);E.useEffect(()=>{let ge=!1;return(async()=>{try{const Ae=await _.getBootstrap();if(ge)return;M(Ae);const Ct=Ae.environments.map(re=>re.id),ee=b&&Ct.includes(b)&&b||Ae.defaultEnvironment;ee!==b&&(x(ee),xp(r,ee))}catch(Ae){ge||Yt(Ae instanceof Error?Ae.message:"Failed to load bootstrap")}})(),()=>{ge=!0}},[_,b,r]),E.useEffect(()=>{if(!N||!b)return;let ge=!1;return(async()=>{try{jn(!0),Yt(null);const Ae=await _.getCatalog();if(ge)return;P(Ae);const Ct=M0(window.location.pathname,h,Ae),ee=zN(Ct??Sr(Ae),Ae);pr.current=!0,F(ee),Gn(ee,Ae,!0)}catch(Ae){ge||(P(null),Yt(Ae instanceof Error?Ae.message:"Failed to load catalog"))}finally{ge||jn(!1)}})(),()=>{ge=!0}},[_,N,b,h,Gn]),E.useEffect(()=>{if(!(!O||!D)){if(pr.current){pr.current=!1;return}Gn(D,O,!1)}},[D,O,Gn]),E.useEffect(()=>{const ge=Ae=>{(Ae.metaKey||Ae.ctrlKey)&&Ae.key.toLowerCase()==="k"&&(Ae.preventDefault(),Ht(!0))};return window.addEventListener("keydown",ge),()=>window.removeEventListener("keydown",ge)},[]),E.useEffect(()=>{const ge=()=>{if(!O)return;const Ae=M0(window.location.pathname,h,O),Ct=zN(Ae??Sr(O),O);pr.current=!0,F(ee=>Zne(ee,Ct)?ee:Ct)};return window.addEventListener("popstate",ge),()=>window.removeEventListener("popstate",ge)},[O,h]),E.useEffect(()=>{if(!D||!O)return;let ge=!1;return(async()=>{try{if(Yt(null),D.kind==="overview"){pe(!0);const Ae=await _.getMetrics({range:$});ge||(W(Ae),H(null),z(null),be(null),Ee(null),Be(null))}else if(D.kind==="gallery"){Ce(!0);const Ae=await _.getGallery();ge||(be(Ae),H(null),z(null),W(null),Ee(null),Be(null))}else if(D.kind==="fontLibrary"){me(!0);const Ae=await _.getFonts();ge||(Ee(Ae),H(null),z(null),W(null),be(null),Be(null))}else if(D.kind==="emails"){mt(!0);const Ae=await _.getEmails();ge||(Be(Ae),H(null),z(null),W(null),be(null),Ee(null))}else if(D.kind==="resource"){const Ae=await _.listResource(D.id,{...Z.trim()?{q:Z.trim()}:{},fresh:!0});ge||(H(Ae),z(null),W(null),be(null),Ee(null),Be(null))}else if(D.kind==="sync"||D.kind==="addons"||D.kind==="audit")ge||(H(null),z(null),W(null),be(null),Ee(null),Be(null));else if(D.kind==="config"||D.kind==="addon"){const Ae=await _.getConfig(D.id);if(!ge&&(z(Ae),H(null),W(null),be(null),Be(null),O.fontLibrary)){me(!0);try{const Ct=await _.getFonts();ge||Ee(Ct)}finally{ge||me(!1)}}}}catch(Ae){ge||Yt(Ae instanceof Error?Ae.message:"Failed to load panel")}finally{ge||(pe(!1),Ce(!1),me(!1),mt(!1))}})(),()=>{ge=!0}},[_,D,O,b,$,Z]);const ds=D?.kind==="resource"?D.id:null;E.useEffect(()=>{G("")},[ds]);const rr=E.useCallback(async()=>{if(!O?.health){Wt(null);return}const ge=await _.getHealth({fresh:!0});Wt(ge.checks)},[_,O]);E.useEffect(()=>{if(!O?.health){Wt(null);return}let ge=!1;return(async()=>{try{const Ae=await _.getHealth({fresh:!0});ge||Wt(Ae.checks)}catch{ge||Wt(null)}})(),()=>{ge=!0}},[_,O?.health,b]);const ye=E.useCallback(async()=>{if(D?.kind!=="resource")return;const ge=await _.listResource(D.id,{...Z.trim()?{q:Z.trim()}:{},fresh:!0});H(ge)},[_,D,Z]),Ie=E.useCallback(async()=>{if(D?.kind!=="config"&&D?.kind!=="addon")return;const ge=await _.getConfig(D.id,{fresh:!0});z(ge)},[_,D]),I=E.useCallback(async()=>{pe(!0);try{const ge=await _.getMetrics({range:$,fresh:!0});W(ge)}finally{pe(!1)}},[_,$]),B=E.useCallback(ge=>{Y(ge),xp(o,ge)},[o]),U=E.useCallback(async()=>{Ce(!0);try{const ge=await _.getGallery({fresh:!0});be(ge)}finally{Ce(!1)}},[_]),se=E.useCallback(async()=>{me(!0);try{const ge=await _.getFonts({fresh:!0});Ee(ge)}finally{me(!1)}},[_]),oe=E.useCallback(async()=>(await _.getFonts()).items,[_]),xe=E.useCallback(async()=>{mt(!0);try{const ge=await _.getEmails({fresh:!0});Be(ge)}finally{mt(!1)}},[_]),Se=E.useCallback(async()=>(await _.getGallery()).items,[_]),_e=E.useCallback(async ge=>{if(ge.length===1&&ge[0]){const{item:Ct}=await _.uploadGalleryFile(ge[0]);return[Ct]}const{items:Ae}=await _.uploadGalleryFiles(ge);return Ae},[_]),Ve=O?.gallery?{galleryUpload:{accept:O.gallery.accept,maxBytes:O.gallery.maxBytes},onListGallery:Se,onUploadGallery:_e}:{},st=O?.fontLibrary?{fonts:He?.items??[],fontsLoading:le,onListFonts:oe,onRefreshFonts:se}:{},kt=O?.environments??N?.environments??[],an=kt.find(ge=>ge.id===b),Xt=!!an?.auth?.required,Ur=an?.auth?.client?.provider==="custom"&&!!l,mr=D?.kind==="config"?O?.configs.find(ge=>ge.id===D.id):void 0,ti=mr?.section==="page",fs=!!mr?.previewPath,hs=!!O?.sync?.enabled&&Zp(O,"sync.run"),vl=ge=>{if(ge===b)return;const Ae=kt.find(Ct=>Ct.id===ge);Ae?.tone==="danger"&&!window.confirm(`Switch to ${Ae.label}? Writes will affect this environment.`)||(xp(r,ge),x(ge),H(null),G(""),z(null),be(null),Ee(null))},xl=()=>{const ge=C.trim();k(ge),ge?xp(s,ge):$N(s)},ha=()=>{k(""),A(""),$N(s)},pa=E.useMemo(()=>{if(!O)return[];const ge=[];O.metrics&&ge.push({key:"overview",group:O.metrics.group??"Analytics",label:O.metrics.label,icon:ys("overview"),active:D?.kind==="overview",onSelect:()=>F({kind:"overview"})}),O.audit&&ge.push({key:"audit",group:O.audit.group??"Analytics",label:O.audit.label,icon:ys("audit"),active:D?.kind==="audit",onSelect:()=>F({kind:"audit"})});for(const Ae of O.resources)ge.push({key:`resource:${Ae.id}`,group:Ae.group??"Resources",label:Ae.label,icon:ys(`resource:${Ae.id}`),active:D?.kind==="resource"&&D.id===Ae.id,onSelect:()=>F({kind:"resource",id:Ae.id})});if(O.gallery&&ge.push({key:"gallery",group:O.gallery.group??"Resources",label:O.gallery.label,icon:ys("gallery"),active:D?.kind==="gallery",onSelect:()=>F({kind:"gallery"})}),O.fontLibrary&&ge.push({key:"fonts",group:O.fontLibrary.group??"Resources",label:O.fontLibrary.label,icon:ys("fonts"),active:D?.kind==="fontLibrary",onSelect:()=>F({kind:"fontLibrary"})}),O.emails){const Ae=D?.kind==="emails"?D.tab??"compose":null;ge.push({key:"emails",group:O.emails.group??"Growth",label:O.emails.label,icon:ys("emails"),active:D?.kind==="emails",onSelect:()=>F({kind:"emails",tab:"compose"}),children:[{key:"emails:compose",label:"Compose",active:Ae==="compose",onSelect:()=>F({kind:"emails",tab:"compose"})},{key:"emails:templates",label:"Templates",active:Ae==="templates",onSelect:()=>F({kind:"emails",tab:"templates"})},{key:"emails:activity",label:"Activity",active:Ae==="activity",onSelect:()=>F({kind:"emails",tab:"activity"})}]})}O.addons?.length&&ge.push({key:"addons:overview",group:"Add-ons",label:"Browse add-ons",icon:ys("addons:overview"),active:D?.kind==="addons",onSelect:()=>F({kind:"addons"})});for(const Ae of O.addons??[])ge.push({key:`addon:${Ae.id}`,group:Ae.group??"Add-ons",label:Ae.label,icon:ys(`addon:${Ae.id}`),active:D?.kind==="addon"&&D.id===Ae.id,onSelect:()=>F({kind:"addon",id:Ae.id})});for(const Ae of O.configs){const Ct=Ae.section==="page"?"Pages":"Config";ge.push({key:`config:${Ae.id}`,group:Ae.group??Ct,label:Ae.label,icon:ys(`config:${Ae.id}`),active:D?.kind==="config"&&D.id===Ae.id,onSelect:()=>F({kind:"config",id:Ae.id})})}return O.sync?.enabled&&Zp(O,"sync.run")&&ge.push({key:"sync",group:"Settings",label:"Sync environments",icon:ys("sync"),active:D?.kind==="sync",onSelect:()=>F({kind:"sync"})}),Yne(ge)},[O,D]);if(!N&&kn)return m.jsx("div",{className:"vertebr-loading",children:"Loading Vertebr…"});if(Vt&&!N)return m.jsx("div",{className:"vertebr-error",children:Vt});const Xi=D?.kind==="overview"?O?.metrics?.label??"Overview":D?.kind==="sync"?"Sync environments":D?.kind==="audit"?O?.audit?.label??"Audit":D?.kind==="addons"?"Add-ons":D?.kind==="gallery"?O?.gallery?.label??"Gallery":D?.kind==="fontLibrary"?O?.fontLibrary?.label??"Font Library":D?.kind==="emails"?O?.emails?.label??"Emails":D?.kind==="resource"?O?.resources.find(ge=>ge.id===D.id)?.label:D?.kind==="config"?O?.configs.find(ge=>ge.id===D.id)?.label:D?.kind==="addon"?O?.addons?.find(ge=>ge.id===D.id)?.label:null,Ji=D?.kind==="addons"?"Preview how optional storefront features look in your shop, then configure each one.":D?.kind==="addon"?O?.addons?.find(ge=>ge.id===D.id)?.description:void 0;return m.jsx(VU,{children:m.jsx(HU,{children:m.jsxs("div",{className:"vertebr-root","data-env":b,"data-sidebar-collapsed":Dn||void 0,children:[m.jsx(Hne,{brand:N?.brand??O?.brand??"Vertebr",hostName:N?.appearance?.hostName??O?.appearance?.hostName,hostLogoUrl:N?.appearance?.hostLogoUrl??O?.appearance?.hostLogoUrl,envList:kt,environment:b,onEnvironmentChange:vl,authUserLabel:u,onSignOut:d,getAccessToken:l,authViaTokenOnly:Ur,authRequired:Xt,token:S,tokenDraft:C,onTokenDraftChange:A,onSaveToken:xl,onClearToken:ha,theme:g,onThemeChange:y,sidebarCollapsed:Dn,onToggleSidebar:()=>Tr(ge=>!ge),syncEnabled:hs,onOpenSync:()=>F({kind:"sync"}),onOpenSearch:()=>Ht(!0),healthChecks:ht,onRefreshHealth:O?.health?rr:void 0}),O&&js?m.jsx(gU,{catalog:O,onClose:()=>Ht(!1),onSelect:F}):null,m.jsx(One,{navGroups:pa,collapsed:Dn}),m.jsxs("main",{className:"vertebr-main",children:[m.jsx(Ane,{activeLabel:Xi??(O?"Dashboard":"Sign in"),catalogLoaded:!!O,authRequired:Xt,selection:D,isPageSelection:ti,hasPagePreview:fs,selectionDescription:Ji,error:Vt,breadcrumbs:Une(D,O)}),m.jsx(Tne,{client:_,catalog:O,selection:D,onSelectionChange:F,authRequired:Xt,loading:kn,isPageSelection:ti,metricsData:L,metricsLoading:ce,metricsRange:$,onMetricsRangeChange:B,onRefreshMetrics:I,galleryData:he,galleryLoading:Me,onRefreshGallery:U,fontLibraryData:He,fontLibraryLoading:le,onRefreshFonts:se,emailsData:De,emailsLoading:Ke,onRefreshEmails:xe,resourceData:te,resourceSearch:Z,onResourceSearchChange:G,onRefreshResource:ye,configData:ae,onConfigSaved:z,onRefreshConfig:Ie,galleryPicker:Ve,fontLibraryPicker:st}),m.jsx(Rne,{})]}),m.jsx(jne,{})]})})})}E.createContext(null);E.createContext(null);const wp="/admin/api";function Xne(t){const e=t.environments.map(r=>r.auth?.client).find(r=>r?.provider==="firebase");if(!e||e.provider!=="firebase")return null;const n=MB().length?tM():eM(e.config);return eH(n)}function Jne(t){return t.environments.some(e=>e.auth?.client?.provider==="custom")}function Qne(){const[t,e]=E.useState(null),[n,r]=E.useState(null),[s,i]=E.useState(null),[o,l]=E.useState(!1),[u,d]=E.useState("idle"),[h,g]=E.useState(""),[y,b]=E.useState(""),[x,S]=E.useState(null),[k,C]=E.useState(!1),A=E.useMemo(()=>B0({apiBase:wp,getEnvironment:()=>""}),[]);E.useEffect(()=>{let M=!1;return A.getBootstrap().then(O=>{if(M)return;e(O);const P=Xne(O);r(P),P||l(!0)}).catch(O=>{M||(S(O instanceof Error?O.message:"Could not load auth"),l(!0))}),()=>{M=!0}},[A]),E.useEffect(()=>{if(n)return U3(n,M=>{i(M),d(M?"checking":"idle"),l(!0)})},[n]),E.useEffect(()=>{if(!t||!s)return;let M=!1;return(async()=>{d("checking");const O=localStorage.getItem("vertebr:env"),P=[...O?[O]:[],...t.environments.map(D=>D.id)].filter((D,F,te)=>te.indexOf(D)===F);for(const D of P)try{await B0({apiBase:wp,getEnvironment:()=>D,getAccessToken:()=>s.getIdToken()}).getCatalog(),M||(localStorage.setItem("vertebr:env",D),d("allowed"));return}catch{}M||d("denied")})(),()=>{M=!0}},[t,s]);const R=t?.environments.map(M=>M.auth?.client).find(M=>M?.provider==="firebase")?.methods??["email"],_=async M=>{if(M.preventDefault(),!!n){C(!0),S(null);try{await B3(n,h.trim(),y)}catch(O){S(O instanceof Error?O.message:"Sign-in failed")}finally{C(!1)}}},N=async()=>{if(n){C(!0),S(null);try{await cV(n,new Ni)}catch(M){S(M instanceof Error?M.message:"Sign-in failed")}finally{C(!1)}}};return o?t?!n&&Jne(t)?m.jsx(BN,{apiBase:wp,title:"Owner control plane"}):n?s?u==="checking"||u==="idle"?m.jsx("div",{className:"vertebr-loading",children:"Checking admin access…"}):u==="denied"?m.jsx("main",{className:"vertebr-login",children:m.jsxs("section",{className:"vertebr-login-card",children:[m.jsxs("div",{className:"vertebr-brand",children:[m.jsx("strong",{children:t.brand}),m.jsx("span",{children:"Access denied"})]}),m.jsxs("div",{children:[m.jsx("h1",{children:"Administrator access required"}),m.jsxs("p",{children:["Signed in as ",s.email??s.uid,", but this account is not approved for any Vertebr environment."]})]}),m.jsx("button",{className:"vertebr-btn",type:"button",onClick:()=>{GT(n)},children:"Sign out"})]})}):m.jsx(BN,{apiBase:wp,title:"Owner control plane",getAccessToken:()=>s.getIdToken(),authUserLabel:s.email??s.uid,onSignOut:()=>GT(n)}):m.jsx("main",{className:"vertebr-login",children:m.jsxs("section",{className:"vertebr-login-card",children:[m.jsxs("div",{className:"vertebr-brand",children:[m.jsx("strong",{children:t.brand}),m.jsx("span",{children:"Admin access"})]}),m.jsxs("div",{children:[m.jsx("h1",{children:"Sign in"}),m.jsx("p",{children:"Use an approved administrator account. Storefront accounts do not receive dashboard access."})]}),R.includes("email")?m.jsxs("form",{className:"vertebr-login-form",onSubmit:_,children:[m.jsxs("label",{className:"vertebr-field",children:[m.jsx("span",{children:"Email"}),m.jsx("input",{type:"email",autoComplete:"username",required:!0,value:h,onChange:M=>g(M.target.value)})]}),m.jsxs("label",{className:"vertebr-field",children:[m.jsx("span",{children:"Password"}),m.jsx("input",{type:"password",autoComplete:"current-password",required:!0,value:y,onChange:M=>b(M.target.value)})]}),m.jsx("button",{className:"vertebr-btn vertebr-btn-primary",type:"submit",disabled:k,children:k?"Signing in…":"Sign in"})]}):null,R.includes("google")?m.jsx("button",{className:"vertebr-btn",type:"button",disabled:k,onClick:()=>{N()},children:"Continue with Google"}):null,x?m.jsx("p",{className:"vertebr-status","data-tone":"danger",children:x}):null]})}):m.jsx("div",{className:"vertebr-error",children:x??"No browser auth provider is configured."}):m.jsx("div",{className:"vertebr-error",children:x??"Could not load admin bootstrap."}):m.jsx("div",{className:"vertebr-loading",children:"Checking admin session…"})}c$.createRoot(document.getElementById("root")).render(m.jsx(E.StrictMode,{children:m.jsx(Qne,{})}));
|