var eEe=Object.defineProperty;var Nq=t=>{throw TypeError(t)};var tEe=(t,e,r)=>e in t?eEe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Ve=(t,e,r)=>tEe(t,typeof e!="symbol"?e+"":e,r),AD=(t,e,r)=>e.has(t)||Nq("Cannot "+r);var _=(t,e,r)=>(AD(t,e,"read from private field"),r?r.call(t):e.get(t)),le=(t,e,r)=>e.has(t)?Nq("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),te=(t,e,r,n)=>(AD(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),ce=(t,e,r)=>(AD(t,e,"access private method"),r);var Ds=(t,e,r,n)=>({set _(s){te(t,e,s,r)},get _(){return _(t,e,n)}});function rEe(t,e){for(var r=0;r<e.length;r++){const n=e[r];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in t)){const i=Object.getOwnPropertyDescriptor(n,s);i&&Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>n[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"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function r(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 n(s){if(s.ep)return;s.ep=!0;const i=r(s);fetch(s.href,i)}})();var dn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function nEe(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}var Iae={exports:{}},MI={},Rae={exports:{}},or={};/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var JN=Symbol.for("react.element"),sEe=Symbol.for("react.portal"),iEe=Symbol.for("react.fragment"),aEe=Symbol.for("react.strict_mode"),oEe=Symbol.for("react.profiler"),lEe=Symbol.for("react.provider"),cEe=Symbol.for("react.context"),uEe=Symbol.for("react.forward_ref"),dEe=Symbol.for("react.suspense"),hEe=Symbol.for("react.memo"),fEe=Symbol.for("react.lazy"),Eq=Symbol.iterator;function pEe(t){return t===null||typeof t!="object"?null:(t=Eq&&t[Eq]||t["@@iterator"],typeof t=="function"?t:null)}var Mae={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Dae=Object.assign,Lae={};function Mw(t,e,r){this.props=t,this.context=e,this.refs=Lae,this.updater=r||Mae}Mw.prototype.isReactComponent={};Mw.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Mw.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function Fae(){}Fae.prototype=Mw.prototype;function CU(t,e,r){this.props=t,this.context=e,this.refs=Lae,this.updater=r||Mae}var TU=CU.prototype=new Fae;TU.constructor=CU;Dae(TU,Mw.prototype);TU.isPureReactComponent=!0;var Aq=Array.isArray,$ae=Object.prototype.hasOwnProperty,PU={current:null},Bae={key:!0,ref:!0,__self:!0,__source:!0};function zae(t,e,r){var n,s={},i=null,a=null;if(e!=null)for(n in e.ref!==void 0&&(a=e.ref),e.key!==void 0&&(i=""+e.key),e)$ae.call(e,n)&&!Bae.hasOwnProperty(n)&&(s[n]=e[n]);var o=arguments.length-2;if(o===1)s.children=r;else if(1<o){for(var c=Array(o),u=0;u<o;u++)c[u]=arguments[u+2];s.children=c}if(t&&t.defaultProps)for(n in o=t.defaultProps,o)s[n]===void 0&&(s[n]=o[n]);return{$$typeof:JN,type:t,key:i,ref:a,props:s,_owner:PU.current}}function mEe(t,e){return{$$typeof:JN,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function OU(t){return typeof t=="object"&&t!==null&&t.$$typeof===JN}function gEe(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(r){return e[r]})}var Cq=/\/+/g;function CD(t,e){return typeof t=="object"&&t!==null&&t.key!=null?gEe(""+t.key):e.toString(36)}function qC(t,e,r,n,s){var i=typeof t;(i==="undefined"||i==="boolean")&&(t=null);var a=!1;if(t===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(t.$$typeof){case JN:case sEe:a=!0}}if(a)return a=t,s=s(a),t=n===""?"."+CD(a,0):n,Aq(s)?(r="",t!=null&&(r=t.replace(Cq,"$&/")+"/"),qC(s,e,r,"",function(u){return u})):s!=null&&(OU(s)&&(s=mEe(s,r+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(Cq,"$&/")+"/")+t)),e.push(s)),1;if(a=0,n=n===""?".":n+":",Aq(t))for(var o=0;o<t.length;o++){i=t[o];var c=n+CD(i,o);a+=qC(i,e,r,c,s)}else if(c=pEe(t),typeof c=="function")for(t=c.call(t),o=0;!(i=t.next()).done;)i=i.value,c=n+CD(i,o++),a+=qC(i,e,r,c,s);else if(i==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return a}function oA(t,e,r){if(t==null)return t;var n=[],s=0;return qC(t,n,"","",function(i){return e.call(r,i,s++)}),n}function yEe(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(r){(t._status===0||t._status===-1)&&(t._status=1,t._result=r)},function(r){(t._status===0||t._status===-1)&&(t._status=2,t._result=r)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var Sa={current:null},GC={transition:null},xEe={ReactCurrentDispatcher:Sa,ReactCurrentBatchConfig:GC,ReactCurrentOwner:PU};function Uae(){throw Error("act(...) is not supported in production builds of React.")}or.Children={map:oA,forEach:function(t,e,r){oA(t,function(){e.apply(this,arguments)},r)},count:function(t){var e=0;return oA(t,function(){e++}),e},toArray:function(t){return oA(t,function(e){return e})||[]},only:function(t){if(!OU(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};or.Component=Mw;or.Fragment=iEe;or.Profiler=oEe;or.PureComponent=CU;or.StrictMode=aEe;or.Suspense=dEe;or.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xEe;or.act=Uae;or.cloneElement=function(t,e,r){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var n=Dae({},t.props),s=t.key,i=t.ref,a=t._owner;if(e!=null){if(e.ref!==void 0&&(i=e.ref,a=PU.current),e.key!==void 0&&(s=""+e.key),t.type&&t.type.defaultProps)var o=t.type.defaultProps;for(c in e)$ae.call(e,c)&&!Bae.hasOwnProperty(c)&&(n[c]=e[c]===void 0&&o!==void 0?o[c]:e[c])}var c=arguments.length-2;if(c===1)n.children=r;else if(1<c){o=Array(c);for(var u=0;u<c;u++)o[u]=arguments[u+2];n.children=o}return{$$typeof:JN,type:t.type,key:s,ref:i,props:n,_owner:a}};or.createContext=function(t){return t={$$typeof:cEe,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:lEe,_context:t},t.Consumer=t};or.createElement=zae;or.createFactory=function(t){var e=zae.bind(null,t);return e.type=t,e};or.createRef=function(){return{current:null}};or.forwardRef=function(t){return{$$typeof:uEe,render:t}};or.isValidElement=OU;or.lazy=function(t){return{$$typeof:fEe,_payload:{_status:-1,_result:t},_init:yEe}};or.memo=function(t,e){return{$$typeof:hEe,type:t,compare:e===void 0?null:e}};or.startTransition=function(t){var e=GC.transition;GC.transition={};try{t()}finally{GC.transition=e}};or.unstable_act=Uae;or.useCallback=function(t,e){return Sa.current.useCallback(t,e)};or.useContext=function(t){return Sa.current.useContext(t)};or.useDebugValue=function(){};or.useDeferredValue=function(t){return Sa.current.useDeferredValue(t)};or.useEffect=function(t,e){return Sa.current.useEffect(t,e)};or.useId=function(){return Sa.current.useId()};or.useImperativeHandle=function(t,e,r){return Sa.current.useImperativeHandle(t,e,r)};or.useInsertionEffect=function(t,e){return Sa.current.useInsertionEffect(t,e)};or.useLayoutEffect=function(t,e){return Sa.current.useLayoutEffect(t,e)};or.useMemo=function(t,e){return Sa.current.useMemo(t,e)};or.useReducer=function(t,e,r){return Sa.current.useReducer(t,e,r)};or.useRef=function(t){return Sa.current.useRef(t)};or.useState=function(t){return Sa.current.useState(t)};or.useSyncExternalStore=function(t,e,r){return Sa.current.useSyncExternalStore(t,e,r)};or.useTransition=function(){return Sa.current.useTransition()};or.version="18.3.1";Rae.exports=or;var j=Rae.exports;const pe=cr(j),IU=rEe({__proto__:null,default:pe},[j]);/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var vEe=j,bEe=Symbol.for("react.element"),wEe=Symbol.for("react.fragment"),SEe=Object.prototype.hasOwnProperty,_Ee=vEe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,jEe={key:!0,ref:!0,__self:!0,__source:!0};function Hae(t,e,r){var n,s={},i=null,a=null;r!==void 0&&(i=""+r),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(a=e.ref);for(n in e)SEe.call(e,n)&&!jEe.hasOwnProperty(n)&&(s[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)s[n]===void 0&&(s[n]=e[n]);return{$$typeof:bEe,type:t,key:i,ref:a,props:s,_owner:_Ee.current}}MI.Fragment=wEe;MI.jsx=Hae;MI.jsxs=Hae;Iae.exports=MI;var l=Iae.exports,Vae={exports:{}},Io={},Wae={exports:{}},qae={};/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/(function(t){function e(X,H){var B=X.length;X.push(H);e:for(;0<B;){var L=B-1>>>1,F=X[L];if(0<s(F,H))X[L]=H,X[B]=F,B=L;else break e}}function r(X){return X.length===0?null:X[0]}function n(X){if(X.length===0)return null;var H=X[0],B=X.pop();if(B!==H){X[0]=B;e:for(var L=0,F=X.length,V=F>>>1;L<V;){var Y=2*(L+1)-1,ie=X[Y],Q=Y+1,D=X[Q];if(0>s(ie,B))Q<F&&0>s(D,ie)?(X[L]=D,X[Q]=B,L=Q):(X[L]=ie,X[Y]=B,L=Y);else if(Q<F&&0>s(D,B))X[L]=D,X[Q]=B,L=Q;else break e}}return H}function s(X,H){var B=X.sortIndex-H.sortIndex;return B!==0?B:X.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var c=[],u=[],d=1,h=null,f=3,p=!1,m=!1,g=!1,x=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(X){for(var H=r(u);H!==null;){if(H.callback===null)n(u);else if(H.startTime<=X)n(u),H.sortIndex=H.expirationTime,e(c,H);else break;H=r(u)}}function w(X){if(g=!1,b(X),!m)if(r(c)!==null)m=!0,K(S);else{var H=r(u);H!==null&&G(w,H.startTime-X)}}function S(X,H){m=!1,g&&(g=!1,y(C),C=-1),p=!0;var B=f;try{for(b(H),h=r(c);h!==null&&(!(h.expirationTime>H)||X&&!z());){var L=h.callback;if(typeof L=="function"){h.callback=null,f=h.priorityLevel;var F=L(h.expirationTime<=H);H=t.unstable_now(),typeof F=="function"?h.callback=F:h===r(c)&&n(c),b(H)}else n(c);h=r(c)}if(h!==null)var V=!0;else{var Y=r(u);Y!==null&&G(w,Y.startTime-H),V=!1}return V}finally{h=null,f=B,p=!1}}var k=!1,E=null,C=-1,A=5,M=-1;function z(){return!(t.unstable_now()-M<A)}function P(){if(E!==null){var X=t.unstable_now();M=X;var H=!0;try{H=E(!0,X)}finally{H?W():(k=!1,E=null)}}else k=!1}var W;if(typeof v=="function")W=function(){v(P)};else if(typeof MessageChannel<"u"){var N=new MessageChannel,U=N.port2;N.port1.onmessage=P,W=function(){U.postMessage(null)}}else W=function(){x(P,0)};function K(X){E=X,k||(k=!0,W())}function G(X,H){C=x(function(){X(t.unstable_now())},H)}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(X){X.callback=null},t.unstable_continueExecution=function(){m||p||(m=!0,K(S))},t.unstable_forceFrameRate=function(X){0>X||125<X?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<X?Math.floor(1e3/X):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_getFirstCallbackNode=function(){return r(c)},t.unstable_next=function(X){switch(f){case 1:case 2:case 3:var H=3;break;default:H=f}var B=f;f=H;try{return X()}finally{f=B}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(X,H){switch(X){case 1:case 2:case 3:case 4:case 5:break;default:X=3}var B=f;f=X;try{return H()}finally{f=B}},t.unstable_scheduleCallback=function(X,H,B){var L=t.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?L+B:L):B=L,X){case 1:var F=-1;break;case 2:F=250;break;case 5:F=1073741823;break;case 4:F=1e4;break;default:F=5e3}return F=B+F,X={id:d++,callback:H,priorityLevel:X,startTime:B,expirationTime:F,sortIndex:-1},B>L?(X.sortIndex=B,e(u,X),r(c)===null&&X===r(u)&&(g?(y(C),C=-1):g=!0,G(w,B-L))):(X.sortIndex=F,e(c,X),m||p||(m=!0,K(S))),X},t.unstable_shouldYield=z,t.unstable_wrapCallback=function(X){var H=f;return function(){var B=f;f=H;try{return X.apply(this,arguments)}finally{f=B}}}})(qae);Wae.exports=qae;var kEe=Wae.exports;/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var NEe=j,Oo=kEe;function Ye(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r<arguments.length;r++)e+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Gae=new Set,$_={};function fx(t,e){D0(t,e),D0(t+"Capture",e)}function D0(t,e){for($_[t]=e,t=0;t<e.length;t++)Gae.add(e[t])}var lh=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),SF=Object.prototype.hasOwnProperty,EEe=/^[: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]*$/,Tq={},Pq={};function AEe(t){return SF.call(Pq,t)?!0:SF.call(Tq,t)?!1:EEe.test(t)?Pq[t]=!0:(Tq[t]=!0,!1)}function CEe(t,e,r,n){if(r!==null&&r.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function TEe(t,e,r,n){if(e===null||typeof e>"u"||CEe(t,e,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function _a(t,e,r,n,s,i,a){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=s,this.mustUseProperty=r,this.propertyName=t,this.type=e,this.sanitizeURL=i,this.removeEmptyString=a}var Si={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Si[t]=new _a(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Si[e]=new _a(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Si[t]=new _a(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Si[t]=new _a(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Si[t]=new _a(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Si[t]=new _a(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Si[t]=new _a(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Si[t]=new _a(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Si[t]=new _a(t,5,!1,t.toLowerCase(),null,!1,!1)});var RU=/[\-:]([a-z])/g;function MU(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(RU,MU);Si[e]=new _a(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(RU,MU);Si[e]=new _a(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(RU,MU);Si[e]=new _a(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Si[t]=new _a(t,1,!1,t.toLowerCase(),null,!1,!1)});Si.xlinkHref=new _a("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Si[t]=new _a(t,1,!1,t.toLowerCase(),null,!0,!0)});function DU(t,e,r,n){var s=Si.hasOwnProperty(e)?Si[e]:null;(s!==null?s.type!==0:n||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(TEe(e,r,s,n)&&(r=null),n||s===null?AEe(e)&&(r===null?t.removeAttribute(e):t.setAttribute(e,""+r)):s.mustUseProperty?t[s.propertyName]=r===null?s.type===3?!1:"":r:(e=s.attributeName,n=s.attributeNamespace,r===null?t.removeAttribute(e):(s=s.type,r=s===3||s===4&&r===!0?"":""+r,n?t.setAttributeNS(n,e,r):t.setAttribute(e,r))))}var kh=NEe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,lA=Symbol.for("react.element"),bv=Symbol.for("react.portal"),wv=Symbol.for("react.fragment"),LU=Symbol.for("react.strict_mode"),_F=Symbol.for("react.profiler"),Kae=Symbol.for("react.provider"),Yae=Symbol.for("react.context"),FU=Symbol.for("react.forward_ref"),jF=Symbol.for("react.suspense"),kF=Symbol.for("react.suspense_list"),$U=Symbol.for("react.memo"),rf=Symbol.for("react.lazy"),Xae=Symbol.for("react.offscreen"),Oq=Symbol.iterator;function y1(t){return t===null||typeof t!="object"?null:(t=Oq&&t[Oq]||t["@@iterator"],typeof t=="function"?t:null)}var Cn=Object.assign,TD;function nS(t){if(TD===void 0)try{throw Error()}catch(r){var e=r.stack.trim().match(/\n( *(at )?)/);TD=e&&e[1]||""}return`
`+TD+t}var PD=!1;function OD(t,e){if(!t||PD)return"";PD=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(u){var n=u}Reflect.construct(t,[],e)}else{try{e.call()}catch(u){n=u}t.call(e.prototype)}else{try{throw Error()}catch(u){n=u}t()}}catch(u){if(u&&n&&typeof u.stack=="string"){for(var s=u.stack.split(`
`),i=n.stack.split(`
`),a=s.length-1,o=i.length-1;1<=a&&0<=o&&s[a]!==i[o];)o--;for(;1<=a&&0<=o;a--,o--)if(s[a]!==i[o]){if(a!==1||o!==1)do if(a--,o--,0>o||s[a]!==i[o]){var c=`
`+s[a].replace(" at new "," at ");return t.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",t.displayName)),c}while(1<=a&&0<=o);break}}}finally{PD=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?nS(t):""}function PEe(t){switch(t.tag){case 5:return nS(t.type);case 16:return nS("Lazy");case 13:return nS("Suspense");case 19:return nS("SuspenseList");case 0:case 2:case 15:return t=OD(t.type,!1),t;case 11:return t=OD(t.type.render,!1),t;case 1:return t=OD(t.type,!0),t;default:return""}}function NF(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case wv:return"Fragment";case bv:return"Portal";case _F:return"Profiler";case LU:return"StrictMode";case jF:return"Suspense";case kF:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Yae:return(t.displayName||"Context")+".Consumer";case Kae:return(t._context.displayName||"Context")+".Provider";case FU:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case $U:return e=t.displayName||null,e!==null?e:NF(t.type)||"Memo";case rf:e=t._payload,t=t._init;try{return NF(t(e))}catch{}}return null}function OEe(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return NF(e);case 8:return e===LU?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Dp(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Jae(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function IEe(t){var e=Jae(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var s=r.get,i=r.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(a){n=""+a,i.call(this,a)}}),Object.defineProperty(t,e,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(a){n=""+a},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function cA(t){t._valueTracker||(t._valueTracker=IEe(t))}function Qae(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=Jae(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function f2(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function EF(t,e){var r=e.checked;return Cn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function Iq(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=Dp(e.value!=null?e.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Zae(t,e){e=e.checked,e!=null&&DU(t,"checked",e,!1)}function AF(t,e){Zae(t,e);var r=Dp(e.value),n=e.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?CF(t,e.type,r):e.hasOwnProperty("defaultValue")&&CF(t,e.type,Dp(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Rq(t,e,r){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,r||e===t.value||(t.value=e),t.defaultValue=e}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function CF(t,e,r){(e!=="number"||f2(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var sS=Array.isArray;function qv(t,e,r,n){if(t=t.options,e){e={};for(var s=0;s<r.length;s++)e["$"+r[s]]=!0;for(r=0;r<t.length;r++)s=e.hasOwnProperty("$"+t[r].value),t[r].selected!==s&&(t[r].selected=s),s&&n&&(t[r].defaultSelected=!0)}else{for(r=""+Dp(r),e=null,s=0;s<t.length;s++){if(t[s].value===r){t[s].selected=!0,n&&(t[s].defaultSelected=!0);return}e!==null||t[s].disabled||(e=t[s])}e!==null&&(e.selected=!0)}}function TF(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(Ye(91));return Cn({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Mq(t,e){var r=e.value;if(r==null){if(r=e.children,e=e.defaultValue,r!=null){if(e!=null)throw Error(Ye(92));if(sS(r)){if(1<r.length)throw Error(Ye(93));r=r[0]}e=r}e==null&&(e=""),r=e}t._wrapperState={initialValue:Dp(r)}}function eoe(t,e){var r=Dp(e.value),n=Dp(e.defaultValue);r!=null&&(r=""+r,r!==t.value&&(t.value=r),e.defaultValue==null&&t.defaultValue!==r&&(t.defaultValue=r)),n!=null&&(t.defaultValue=""+n)}function Dq(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function toe(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function PF(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?toe(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var uA,roe=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,r,n,s){MSApp.execUnsafeLocalFunction(function(){return t(e,r,n,s)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(uA=uA||document.createElement("div"),uA.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=uA.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function B_(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var t_={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},REe=["Webkit","ms","Moz","O"];Object.keys(t_).forEach(function(t){REe.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),t_[e]=t_[t]})});function noe(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||t_.hasOwnProperty(t)&&t_[t]?(""+e).trim():e+"px"}function soe(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,s=noe(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,s):t[r]=s}}var MEe=Cn({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function OF(t,e){if(e){if(MEe[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Ye(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Ye(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Ye(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Ye(62))}}function IF(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){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 RF=null;function BU(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var MF=null,Gv=null,Kv=null;function Lq(t){if(t=eE(t)){if(typeof MF!="function")throw Error(Ye(280));var e=t.stateNode;e&&(e=BI(e),MF(t.stateNode,t.type,e))}}function ioe(t){Gv?Kv?Kv.push(t):Kv=[t]:Gv=t}function aoe(){if(Gv){var t=Gv,e=Kv;if(Kv=Gv=null,Lq(t),e)for(t=0;t<e.length;t++)Lq(e[t])}}function ooe(t,e){return t(e)}function loe(){}var ID=!1;function coe(t,e,r){if(ID)return t(e,r);ID=!0;try{return ooe(t,e,r)}finally{ID=!1,(Gv!==null||Kv!==null)&&(loe(),aoe())}}function z_(t,e){var r=t.stateNode;if(r===null)return null;var n=BI(r);if(n===null)return null;r=n[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(t=t.type,n=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!n;break e;default:t=!1}if(t)return null;if(r&&typeof r!="function")throw Error(Ye(231,e,typeof r));return r}var DF=!1;if(lh)try{var x1={};Object.defineProperty(x1,"passive",{get:function(){DF=!0}}),window.addEventListener("test",x1,x1),window.removeEventListener("test",x1,x1)}catch{DF=!1}function DEe(t,e,r,n,s,i,a,o,c){var u=Array.prototype.slice.call(arguments,3);try{e.apply(r,u)}catch(d){this.onError(d)}}var r_=!1,p2=null,m2=!1,LF=null,LEe={onError:function(t){r_=!0,p2=t}};function FEe(t,e,r,n,s,i,a,o,c){r_=!1,p2=null,DEe.apply(LEe,arguments)}function $Ee(t,e,r,n,s,i,a,o,c){if(FEe.apply(this,arguments),r_){if(r_){var u=p2;r_=!1,p2=null}else throw Error(Ye(198));m2||(m2=!0,LF=u)}}function px(t){var e=t,r=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(r=e.return),t=e.return;while(t)}return e.tag===3?r:null}function uoe(t){if(t.tag===13){var e=t.memoizedState;if(e===null&&(t=t.alternate,t!==null&&(e=t.memoizedState)),e!==null)return e.dehydrated}return null}function Fq(t){if(px(t)!==t)throw Error(Ye(188))}function BEe(t){var e=t.alternate;if(!e){if(e=px(t),e===null)throw Error(Ye(188));return e!==t?null:t}for(var r=t,n=e;;){var s=r.return;if(s===null)break;var i=s.alternate;if(i===null){if(n=s.return,n!==null){r=n;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===r)return Fq(s),t;if(i===n)return Fq(s),e;i=i.sibling}throw Error(Ye(188))}if(r.return!==n.return)r=s,n=i;else{for(var a=!1,o=s.child;o;){if(o===r){a=!0,r=s,n=i;break}if(o===n){a=!0,n=s,r=i;break}o=o.sibling}if(!a){for(o=i.child;o;){if(o===r){a=!0,r=i,n=s;break}if(o===n){a=!0,n=i,r=s;break}o=o.sibling}if(!a)throw Error(Ye(189))}}if(r.alternate!==n)throw Error(Ye(190))}if(r.tag!==3)throw Error(Ye(188));return r.stateNode.current===r?t:e}function doe(t){return t=BEe(t),t!==null?hoe(t):null}function hoe(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=hoe(t);if(e!==null)return e;t=t.sibling}return null}var foe=Oo.unstable_scheduleCallback,$q=Oo.unstable_cancelCallback,zEe=Oo.unstable_shouldYield,UEe=Oo.unstable_requestPaint,Jn=Oo.unstable_now,HEe=Oo.unstable_getCurrentPriorityLevel,zU=Oo.unstable_ImmediatePriority,poe=Oo.unstable_UserBlockingPriority,g2=Oo.unstable_NormalPriority,VEe=Oo.unstable_LowPriority,moe=Oo.unstable_IdlePriority,DI=null,yu=null;function WEe(t){if(yu&&typeof yu.onCommitFiberRoot=="function")try{yu.onCommitFiberRoot(DI,t,void 0,(t.current.flags&128)===128)}catch{}}var dc=Math.clz32?Math.clz32:KEe,qEe=Math.log,GEe=Math.LN2;function KEe(t){return t>>>=0,t===0?32:31-(qEe(t)/GEe|0)|0}var dA=64,hA=4194304;function iS(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function y2(t,e){var r=t.pendingLanes;if(r===0)return 0;var n=0,s=t.suspendedLanes,i=t.pingedLanes,a=r&268435455;if(a!==0){var o=a&~s;o!==0?n=iS(o):(i&=a,i!==0&&(n=iS(i)))}else a=r&~s,a!==0?n=iS(a):i!==0&&(n=iS(i));if(n===0)return 0;if(e!==0&&e!==n&&!(e&s)&&(s=n&-n,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(n&4&&(n|=r&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0<e;)r=31-dc(e),s=1<<r,n|=t[r],e&=~s;return n}function YEe(t,e){switch(t){case 1:case 2:case 4:return e+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function XEe(t,e){for(var r=t.suspendedLanes,n=t.pingedLanes,s=t.expirationTimes,i=t.pendingLanes;0<i;){var a=31-dc(i),o=1<<a,c=s[a];c===-1?(!(o&r)||o&n)&&(s[a]=YEe(o,e)):c<=e&&(t.expiredLanes|=o),i&=~o}}function FF(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function goe(){var t=dA;return dA<<=1,!(dA&4194240)&&(dA=64),t}function RD(t){for(var e=[],r=0;31>r;r++)e.push(t);return e}function QN(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-dc(e),t[e]=r}function JEe(t,e){var r=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0<r;){var s=31-dc(r),i=1<<s;e[s]=0,n[s]=-1,t[s]=-1,r&=~i}}function UU(t,e){var r=t.entangledLanes|=e;for(t=t.entanglements;r;){var n=31-dc(r),s=1<<n;s&e|t[n]&e&&(t[n]|=e),r&=~s}}var Pr=0;function yoe(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var xoe,HU,voe,boe,woe,$F=!1,fA=[],yp=null,xp=null,vp=null,U_=new Map,H_=new Map,cf=[],QEe="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Bq(t,e){switch(t){case"focusin":case"focusout":yp=null;break;case"dragenter":case"dragleave":xp=null;break;case"mouseover":case"mouseout":vp=null;break;case"pointerover":case"pointerout":U_.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":H_.delete(e.pointerId)}}function v1(t,e,r,n,s,i){return t===null||t.nativeEvent!==i?(t={blockedOn:e,domEventName:r,eventSystemFlags:n,nativeEvent:i,targetContainers:[s]},e!==null&&(e=eE(e),e!==null&&HU(e)),t):(t.eventSystemFlags|=n,e=t.targetContainers,s!==null&&e.indexOf(s)===-1&&e.push(s),t)}function ZEe(t,e,r,n,s){switch(e){case"focusin":return yp=v1(yp,t,e,r,n,s),!0;case"dragenter":return xp=v1(xp,t,e,r,n,s),!0;case"mouseover":return vp=v1(vp,t,e,r,n,s),!0;case"pointerover":var i=s.pointerId;return U_.set(i,v1(U_.get(i)||null,t,e,r,n,s)),!0;case"gotpointercapture":return i=s.pointerId,H_.set(i,v1(H_.get(i)||null,t,e,r,n,s)),!0}return!1}function Soe(t){var e=Xm(t.target);if(e!==null){var r=px(e);if(r!==null){if(e=r.tag,e===13){if(e=uoe(r),e!==null){t.blockedOn=e,woe(t.priority,function(){voe(r)});return}}else if(e===3&&r.stateNode.current.memoizedState.isDehydrated){t.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}t.blockedOn=null}function KC(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var r=BF(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(r===null){r=t.nativeEvent;var n=new r.constructor(r.type,r);RF=n,r.target.dispatchEvent(n),RF=null}else return e=eE(r),e!==null&&HU(e),t.blockedOn=r,!1;e.shift()}return!0}function zq(t,e,r){KC(t)&&r.delete(e)}function eAe(){$F=!1,yp!==null&&KC(yp)&&(yp=null),xp!==null&&KC(xp)&&(xp=null),vp!==null&&KC(vp)&&(vp=null),U_.forEach(zq),H_.forEach(zq)}function b1(t,e){t.blockedOn===e&&(t.blockedOn=null,$F||($F=!0,Oo.unstable_scheduleCallback(Oo.unstable_NormalPriority,eAe)))}function V_(t){function e(s){return b1(s,t)}if(0<fA.length){b1(fA[0],t);for(var r=1;r<fA.length;r++){var n=fA[r];n.blockedOn===t&&(n.blockedOn=null)}}for(yp!==null&&b1(yp,t),xp!==null&&b1(xp,t),vp!==null&&b1(vp,t),U_.forEach(e),H_.forEach(e),r=0;r<cf.length;r++)n=cf[r],n.blockedOn===t&&(n.blockedOn=null);for(;0<cf.length&&(r=cf[0],r.blockedOn===null);)Soe(r),r.blockedOn===null&&cf.shift()}var Yv=kh.ReactCurrentBatchConfig,x2=!0;function tAe(t,e,r,n){var s=Pr,i=Yv.transition;Yv.transition=null;try{Pr=1,VU(t,e,r,n)}finally{Pr=s,Yv.transition=i}}function rAe(t,e,r,n){var s=Pr,i=Yv.transition;Yv.transition=null;try{Pr=4,VU(t,e,r,n)}finally{Pr=s,Yv.transition=i}}function VU(t,e,r,n){if(x2){var s=BF(t,e,r,n);if(s===null)VD(t,e,n,v2,r),Bq(t,n);else if(ZEe(s,t,e,r,n))n.stopPropagation();else if(Bq(t,n),e&4&&-1<QEe.indexOf(t)){for(;s!==null;){var i=eE(s);if(i!==null&&xoe(i),i=BF(t,e,r,n),i===null&&VD(t,e,n,v2,r),i===s)break;s=i}s!==null&&n.stopPropagation()}else VD(t,e,n,null,r)}}var v2=null;function BF(t,e,r,n){if(v2=null,t=BU(n),t=Xm(t),t!==null)if(e=px(t),e===null)t=null;else if(r=e.tag,r===13){if(t=uoe(e),t!==null)return t;t=null}else if(r===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return v2=t,null}function _oe(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(HEe()){case zU:return 1;case poe:return 4;case g2:case VEe:return 16;case moe:return 536870912;default:return 16}default:return 16}}var pp=null,WU=null,YC=null;function joe(){if(YC)return YC;var t,e=WU,r=e.length,n,s="value"in pp?pp.value:pp.textContent,i=s.length;for(t=0;t<r&&e[t]===s[t];t++);var a=r-t;for(n=1;n<=a&&e[r-n]===s[i-n];n++);return YC=s.slice(t,1<n?1-n:void 0)}function XC(t){var e=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&e===13&&(t=13)):t=e,t===10&&(t=13),32<=t||t===13?t:0}function pA(){return!0}function Uq(){return!1}function Ro(t){function e(r,n,s,i,a){this._reactName=r,this._targetInst=s,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var o in t)t.hasOwnProperty(o)&&(r=t[o],this[o]=r?r(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?pA:Uq,this.isPropagationStopped=Uq,this}return Cn(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=pA)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=pA)},persist:function(){},isPersistent:pA}),e}var Dw={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qU=Ro(Dw),ZN=Cn({},Dw,{view:0,detail:0}),nAe=Ro(ZN),MD,DD,w1,LI=Cn({},ZN,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:GU,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==w1&&(w1&&t.type==="mousemove"?(MD=t.screenX-w1.screenX,DD=t.screenY-w1.screenY):DD=MD=0,w1=t),MD)},movementY:function(t){return"movementY"in t?t.movementY:DD}}),Hq=Ro(LI),sAe=Cn({},LI,{dataTransfer:0}),iAe=Ro(sAe),aAe=Cn({},ZN,{relatedTarget:0}),LD=Ro(aAe),oAe=Cn({},Dw,{animationName:0,elapsedTime:0,pseudoElement:0}),lAe=Ro(oAe),cAe=Cn({},Dw,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),uAe=Ro(cAe),dAe=Cn({},Dw,{data:0}),Vq=Ro(dAe),hAe={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fAe={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"},pAe={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mAe(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=pAe[t])?!!e[t]:!1}function GU(){return mAe}var gAe=Cn({},ZN,{key:function(t){if(t.key){var e=hAe[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=XC(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?fAe[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:GU,charCode:function(t){return t.type==="keypress"?XC(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?XC(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),yAe=Ro(gAe),xAe=Cn({},LI,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Wq=Ro(xAe),vAe=Cn({},ZN,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:GU}),bAe=Ro(vAe),wAe=Cn({},Dw,{propertyName:0,elapsedTime:0,pseudoElement:0}),SAe=Ro(wAe),_Ae=Cn({},LI,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),jAe=Ro(_Ae),kAe=[9,13,27,32],KU=lh&&"CompositionEvent"in window,n_=null;lh&&"documentMode"in document&&(n_=document.documentMode);var NAe=lh&&"TextEvent"in window&&!n_,koe=lh&&(!KU||n_&&8<n_&&11>=n_),qq=" ",Gq=!1;function Noe(t,e){switch(t){case"keyup":return kAe.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Eoe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Sv=!1;function EAe(t,e){switch(t){case"compositionend":return Eoe(e);case"keypress":return e.which!==32?null:(Gq=!0,qq);case"textInput":return t=e.data,t===qq&&Gq?null:t;default:return null}}function AAe(t,e){if(Sv)return t==="compositionend"||!KU&&Noe(t,e)?(t=joe(),YC=WU=pp=null,Sv=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return koe&&e.locale!=="ko"?null:e.data;default:return null}}var CAe={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 Kq(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!CAe[t.type]:e==="textarea"}function Aoe(t,e,r,n){ioe(n),e=b2(e,"onChange"),0<e.length&&(r=new qU("onChange","change",null,r,n),t.push({event:r,listeners:e}))}var s_=null,W_=null;function TAe(t){$oe(t,0)}function FI(t){var e=kv(t);if(Qae(e))return t}function PAe(t,e){if(t==="change")return e}var Coe=!1;if(lh){var FD;if(lh){var $D="oninput"in document;if(!$D){var Yq=document.createElement("div");Yq.setAttribute("oninput","return;"),$D=typeof Yq.oninput=="function"}FD=$D}else FD=!1;Coe=FD&&(!document.documentMode||9<document.documentMode)}function Xq(){s_&&(s_.detachEvent("onpropertychange",Toe),W_=s_=null)}function Toe(t){if(t.propertyName==="value"&&FI(W_)){var e=[];Aoe(e,W_,t,BU(t)),coe(TAe,e)}}function OAe(t,e,r){t==="focusin"?(Xq(),s_=e,W_=r,s_.attachEvent("onpropertychange",Toe)):t==="focusout"&&Xq()}function IAe(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return FI(W_)}function RAe(t,e){if(t==="click")return FI(e)}function MAe(t,e){if(t==="input"||t==="change")return FI(e)}function DAe(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var yc=typeof Object.is=="function"?Object.is:DAe;function q_(t,e){if(yc(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(n=0;n<r.length;n++){var s=r[n];if(!SF.call(e,s)||!yc(t[s],e[s]))return!1}return!0}function Jq(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Qq(t,e){var r=Jq(t);t=0;for(var n;r;){if(r.nodeType===3){if(n=t+r.textContent.length,t<=e&&n>=e)return{node:r,offset:e-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Jq(r)}}function Poe(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Poe(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Ooe(){for(var t=window,e=f2();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=f2(t.document)}return e}function YU(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function LAe(t){var e=Ooe(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&Poe(r.ownerDocument.documentElement,r)){if(n!==null&&YU(r)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in r)r.selectionStart=e,r.selectionEnd=Math.min(t,r.value.length);else if(t=(e=r.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=r.textContent.length,i=Math.min(n.start,s);n=n.end===void 0?i:Math.min(n.end,s),!t.extend&&i>n&&(s=n,n=i,i=s),s=Qq(r,i);var a=Qq(r,n);s&&a&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==a.node||t.focusOffset!==a.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),i>n?(t.addRange(e),t.extend(a.node,a.offset)):(e.setEnd(a.node,a.offset),t.addRange(e)))}}for(e=[],t=r;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r<e.length;r++)t=e[r],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var FAe=lh&&"documentMode"in document&&11>=document.documentMode,_v=null,zF=null,i_=null,UF=!1;function Zq(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;UF||_v==null||_v!==f2(n)||(n=_v,"selectionStart"in n&&YU(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),i_&&q_(i_,n)||(i_=n,n=b2(zF,"onSelect"),0<n.length&&(e=new qU("onSelect","select",null,e,r),t.push({event:e,listeners:n}),e.target=_v)))}function mA(t,e){var r={};return r[t.toLowerCase()]=e.toLowerCase(),r["Webkit"+t]="webkit"+e,r["Moz"+t]="moz"+e,r}var jv={animationend:mA("Animation","AnimationEnd"),animationiteration:mA("Animation","AnimationIteration"),animationstart:mA("Animation","AnimationStart"),transitionend:mA("Transition","TransitionEnd")},BD={},Ioe={};lh&&(Ioe=document.createElement("div").style,"AnimationEvent"in window||(delete jv.animationend.animation,delete jv.animationiteration.animation,delete jv.animationstart.animation),"TransitionEvent"in window||delete jv.transitionend.transition);function $I(t){if(BD[t])return BD[t];if(!jv[t])return t;var e=jv[t],r;for(r in e)if(e.hasOwnProperty(r)&&r in Ioe)return BD[t]=e[r];return t}var Roe=$I("animationend"),Moe=$I("animationiteration"),Doe=$I("animationstart"),Loe=$I("transitionend"),Foe=new Map,eG="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Zp(t,e){Foe.set(t,e),fx(e,[t])}for(var zD=0;zD<eG.length;zD++){var UD=eG[zD],$Ae=UD.toLowerCase(),BAe=UD[0].toUpperCase()+UD.slice(1);Zp($Ae,"on"+BAe)}Zp(Roe,"onAnimationEnd");Zp(Moe,"onAnimationIteration");Zp(Doe,"onAnimationStart");Zp("dblclick","onDoubleClick");Zp("focusin","onFocus");Zp("focusout","onBlur");Zp(Loe,"onTransitionEnd");D0("onMouseEnter",["mouseout","mouseover"]);D0("onMouseLeave",["mouseout","mouseover"]);D0("onPointerEnter",["pointerout","pointerover"]);D0("onPointerLeave",["pointerout","pointerover"]);fx("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));fx("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));fx("onBeforeInput",["compositionend","keypress","textInput","paste"]);fx("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));fx("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));fx("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var aS="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(" "),zAe=new Set("cancel close invalid load scroll toggle".split(" ").concat(aS));function tG(t,e,r){var n=t.type||"unknown-event";t.currentTarget=r,$Ee(n,e,void 0,t),t.currentTarget=null}function $oe(t,e){e=(e&4)!==0;for(var r=0;r<t.length;r++){var n=t[r],s=n.event;n=n.listeners;e:{var i=void 0;if(e)for(var a=n.length-1;0<=a;a--){var o=n[a],c=o.instance,u=o.currentTarget;if(o=o.listener,c!==i&&s.isPropagationStopped())break e;tG(s,o,u),i=c}else for(a=0;a<n.length;a++){if(o=n[a],c=o.instance,u=o.currentTarget,o=o.listener,c!==i&&s.isPropagationStopped())break e;tG(s,o,u),i=c}}}if(m2)throw t=LF,m2=!1,LF=null,t}function an(t,e){var r=e[GF];r===void 0&&(r=e[GF]=new Set);var n=t+"__bubble";r.has(n)||(Boe(e,t,2,!1),r.add(n))}function HD(t,e,r){var n=0;e&&(n|=4),Boe(r,t,n,e)}var gA="_reactListening"+Math.random().toString(36).slice(2);function G_(t){if(!t[gA]){t[gA]=!0,Gae.forEach(function(r){r!=="selectionchange"&&(zAe.has(r)||HD(r,!1,t),HD(r,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[gA]||(e[gA]=!0,HD("selectionchange",!1,e))}}function Boe(t,e,r,n){switch(_oe(e)){case 1:var s=tAe;break;case 4:s=rAe;break;default:s=VU}r=s.bind(null,e,r,t),s=void 0,!DF||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(s=!0),n?s!==void 0?t.addEventListener(e,r,{capture:!0,passive:s}):t.addEventListener(e,r,!0):s!==void 0?t.addEventListener(e,r,{passive:s}):t.addEventListener(e,r,!1)}function VD(t,e,r,n,s){var i=n;if(!(e&1)&&!(e&2)&&n!==null)e:for(;;){if(n===null)return;var a=n.tag;if(a===3||a===4){var o=n.stateNode.containerInfo;if(o===s||o.nodeType===8&&o.parentNode===s)break;if(a===4)for(a=n.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;a=a.return}for(;o!==null;){if(a=Xm(o),a===null)return;if(c=a.tag,c===5||c===6){n=i=a;continue e}o=o.parentNode}}n=n.return}coe(function(){var u=i,d=BU(r),h=[];e:{var f=Foe.get(t);if(f!==void 0){var p=qU,m=t;switch(t){case"keypress":if(XC(r)===0)break e;case"keydown":case"keyup":p=yAe;break;case"focusin":m="focus",p=LD;break;case"focusout":m="blur",p=LD;break;case"beforeblur":case"afterblur":p=LD;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=Hq;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=iAe;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=bAe;break;case Roe:case Moe:case Doe:p=lAe;break;case Loe:p=SAe;break;case"scroll":p=nAe;break;case"wheel":p=jAe;break;case"copy":case"cut":case"paste":p=uAe;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=Wq}var g=(e&4)!==0,x=!g&&t==="scroll",y=g?f!==null?f+"Capture":null:f;g=[];for(var v=u,b;v!==null;){b=v;var w=b.stateNode;if(b.tag===5&&w!==null&&(b=w,y!==null&&(w=z_(v,y),w!=null&&g.push(K_(v,w,b)))),x)break;v=v.return}0<g.length&&(f=new p(f,m,null,r,d),h.push({event:f,listeners:g}))}}if(!(e&7)){e:{if(f=t==="mouseover"||t==="pointerover",p=t==="mouseout"||t==="pointerout",f&&r!==RF&&(m=r.relatedTarget||r.fromElement)&&(Xm(m)||m[ch]))break e;if((p||f)&&(f=d.window===d?d:(f=d.ownerDocument)?f.defaultView||f.parentWindow:window,p?(m=r.relatedTarget||r.toElement,p=u,m=m?Xm(m):null,m!==null&&(x=px(m),m!==x||m.tag!==5&&m.tag!==6)&&(m=null)):(p=null,m=u),p!==m)){if(g=Hq,w="onMouseLeave",y="onMouseEnter",v="mouse",(t==="pointerout"||t==="pointerover")&&(g=Wq,w="onPointerLeave",y="onPointerEnter",v="pointer"),x=p==null?f:kv(p),b=m==null?f:kv(m),f=new g(w,v+"leave",p,r,d),f.target=x,f.relatedTarget=b,w=null,Xm(d)===u&&(g=new g(y,v+"enter",m,r,d),g.target=b,g.relatedTarget=x,w=g),x=w,p&&m)t:{for(g=p,y=m,v=0,b=g;b;b=Ix(b))v++;for(b=0,w=y;w;w=Ix(w))b++;for(;0<v-b;)g=Ix(g),v--;for(;0<b-v;)y=Ix(y),b--;for(;v--;){if(g===y||y!==null&&g===y.alternate)break t;g=Ix(g),y=Ix(y)}g=null}else g=null;p!==null&&rG(h,f,p,g,!1),m!==null&&x!==null&&rG(h,x,m,g,!0)}}e:{if(f=u?kv(u):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var S=PAe;else if(Kq(f))if(Coe)S=MAe;else{S=IAe;var k=OAe}else(p=f.nodeName)&&p.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(S=RAe);if(S&&(S=S(t,u))){Aoe(h,S,r,d);break e}k&&k(t,f,u),t==="focusout"&&(k=f._wrapperState)&&k.controlled&&f.type==="number"&&CF(f,"number",f.value)}switch(k=u?kv(u):window,t){case"focusin":(Kq(k)||k.contentEditable==="true")&&(_v=k,zF=u,i_=null);break;case"focusout":i_=zF=_v=null;break;case"mousedown":UF=!0;break;case"contextmenu":case"mouseup":case"dragend":UF=!1,Zq(h,r,d);break;case"selectionchange":if(FAe)break;case"keydown":case"keyup":Zq(h,r,d)}var E;if(KU)e:{switch(t){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else Sv?Noe(t,r)&&(C="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&(C="onCompositionStart");C&&(koe&&r.locale!=="ko"&&(Sv||C!=="onCompositionStart"?C==="onCompositionEnd"&&Sv&&(E=joe()):(pp=d,WU="value"in pp?pp.value:pp.textContent,Sv=!0)),k=b2(u,C),0<k.length&&(C=new Vq(C,t,null,r,d),h.push({event:C,listeners:k}),E?C.data=E:(E=Eoe(r),E!==null&&(C.data=E)))),(E=NAe?EAe(t,r):AAe(t,r))&&(u=b2(u,"onBeforeInput"),0<u.length&&(d=new Vq("onBeforeInput","beforeinput",null,r,d),h.push({event:d,listeners:u}),d.data=E))}$oe(h,e)})}function K_(t,e,r){return{instance:t,listener:e,currentTarget:r}}function b2(t,e){for(var r=e+"Capture",n=[];t!==null;){var s=t,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=z_(t,r),i!=null&&n.unshift(K_(t,i,s)),i=z_(t,e),i!=null&&n.push(K_(t,i,s))),t=t.return}return n}function Ix(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function rG(t,e,r,n,s){for(var i=e._reactName,a=[];r!==null&&r!==n;){var o=r,c=o.alternate,u=o.stateNode;if(c!==null&&c===n)break;o.tag===5&&u!==null&&(o=u,s?(c=z_(r,i),c!=null&&a.unshift(K_(r,c,o))):s||(c=z_(r,i),c!=null&&a.push(K_(r,c,o)))),r=r.return}a.length!==0&&t.push({event:e,listeners:a})}var UAe=/\r\n?/g,HAe=/\u0000|\uFFFD/g;function nG(t){return(typeof t=="string"?t:""+t).replace(UAe,`
`).replace(HAe,"")}function yA(t,e,r){if(e=nG(e),nG(t)!==e&&r)throw Error(Ye(425))}function w2(){}var HF=null,VF=null;function WF(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var qF=typeof setTimeout=="function"?setTimeout:void 0,VAe=typeof clearTimeout=="function"?clearTimeout:void 0,sG=typeof Promise=="function"?Promise:void 0,WAe=typeof queueMicrotask=="function"?queueMicrotask:typeof sG<"u"?function(t){return sG.resolve(null).then(t).catch(qAe)}:qF;function qAe(t){setTimeout(function(){throw t})}function WD(t,e){var r=e,n=0;do{var s=r.nextSibling;if(t.removeChild(r),s&&s.nodeType===8)if(r=s.data,r==="/$"){if(n===0){t.removeChild(s),V_(e);return}n--}else r!=="$"&&r!=="$?"&&r!=="$!"||n++;r=s}while(r);V_(e)}function bp(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function iG(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var r=t.data;if(r==="$"||r==="$!"||r==="$?"){if(e===0)return t;e--}else r==="/$"&&e++}t=t.previousSibling}return null}var Lw=Math.random().toString(36).slice(2),hu="__reactFiber$"+Lw,Y_="__reactProps$"+Lw,ch="__reactContainer$"+Lw,GF="__reactEvents$"+Lw,GAe="__reactListeners$"+Lw,KAe="__reactHandles$"+Lw;function Xm(t){var e=t[hu];if(e)return e;for(var r=t.parentNode;r;){if(e=r[ch]||r[hu]){if(r=e.alternate,e.child!==null||r!==null&&r.child!==null)for(t=iG(t);t!==null;){if(r=t[hu])return r;t=iG(t)}return e}t=r,r=t.parentNode}return null}function eE(t){return t=t[hu]||t[ch],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function kv(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(Ye(33))}function BI(t){return t[Y_]||null}var KF=[],Nv=-1;function em(t){return{current:t}}function hn(t){0>Nv||(t.current=KF[Nv],KF[Nv]=null,Nv--)}function tn(t,e){Nv++,KF[Nv]=t.current,t.current=e}var Lp={},zi=em(Lp),Va=em(!1),zy=Lp;function L0(t,e){var r=t.type.contextTypes;if(!r)return Lp;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in r)s[i]=e[i];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function Wa(t){return t=t.childContextTypes,t!=null}function S2(){hn(Va),hn(zi)}function aG(t,e,r){if(zi.current!==Lp)throw Error(Ye(168));tn(zi,e),tn(Va,r)}function zoe(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var s in n)if(!(s in e))throw Error(Ye(108,OEe(t)||"Unknown",s));return Cn({},r,n)}function _2(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Lp,zy=zi.current,tn(zi,t),tn(Va,Va.current),!0}function oG(t,e,r){var n=t.stateNode;if(!n)throw Error(Ye(169));r?(t=zoe(t,e,zy),n.__reactInternalMemoizedMergedChildContext=t,hn(Va),hn(zi),tn(zi,t)):hn(Va),tn(Va,r)}var ud=null,zI=!1,qD=!1;function Uoe(t){ud===null?ud=[t]:ud.push(t)}function YAe(t){zI=!0,Uoe(t)}function tm(){if(!qD&&ud!==null){qD=!0;var t=0,e=Pr;try{var r=ud;for(Pr=1;t<r.length;t++){var n=r[t];do n=n(!0);while(n!==null)}ud=null,zI=!1}catch(s){throw ud!==null&&(ud=ud.slice(t+1)),foe(zU,tm),s}finally{Pr=e,qD=!1}}return null}var Ev=[],Av=0,j2=null,k2=0,sl=[],il=0,Uy=null,qd=1,Gd="";function Om(t,e){Ev[Av++]=k2,Ev[Av++]=j2,j2=t,k2=e}function Hoe(t,e,r){sl[il++]=qd,sl[il++]=Gd,sl[il++]=Uy,Uy=t;var n=qd;t=Gd;var s=32-dc(n)-1;n&=~(1<<s),r+=1;var i=32-dc(e)+s;if(30<i){var a=s-s%5;i=(n&(1<<a)-1).toString(32),n>>=a,s-=a,qd=1<<32-dc(e)+s|r<<s|n,Gd=i+t}else qd=1<<i|r<<s|n,Gd=t}function XU(t){t.return!==null&&(Om(t,1),Hoe(t,1,0))}function JU(t){for(;t===j2;)j2=Ev[--Av],Ev[Av]=null,k2=Ev[--Av],Ev[Av]=null;for(;t===Uy;)Uy=sl[--il],sl[il]=null,Gd=sl[--il],sl[il]=null,qd=sl[--il],sl[il]=null}var Ao=null,Eo=null,wn=!1,sc=null;function Voe(t,e){var r=dl(5,null,null,0);r.elementType="DELETED",r.stateNode=e,r.return=t,e=t.deletions,e===null?(t.deletions=[r],t.flags|=16):e.push(r)}function lG(t,e){switch(t.tag){case 5:var r=t.type;return e=e.nodeType!==1||r.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,Ao=t,Eo=bp(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,Ao=t,Eo=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(r=Uy!==null?{id:qd,overflow:Gd}:null,t.memoizedState={dehydrated:e,treeContext:r,retryLane:1073741824},r=dl(18,null,null,0),r.stateNode=e,r.return=t,t.child=r,Ao=t,Eo=null,!0):!1;default:return!1}}function YF(t){return(t.mode&1)!==0&&(t.flags&128)===0}function XF(t){if(wn){var e=Eo;if(e){var r=e;if(!lG(t,e)){if(YF(t))throw Error(Ye(418));e=bp(r.nextSibling);var n=Ao;e&&lG(t,e)?Voe(n,r):(t.flags=t.flags&-4097|2,wn=!1,Ao=t)}}else{if(YF(t))throw Error(Ye(418));t.flags=t.flags&-4097|2,wn=!1,Ao=t}}}function cG(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Ao=t}function xA(t){if(t!==Ao)return!1;if(!wn)return cG(t),wn=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!WF(t.type,t.memoizedProps)),e&&(e=Eo)){if(YF(t))throw Woe(),Error(Ye(418));for(;e;)Voe(t,e),e=bp(e.nextSibling)}if(cG(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(Ye(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"){if(e===0){Eo=bp(t.nextSibling);break e}e--}else r!=="$"&&r!=="$!"&&r!=="$?"||e++}t=t.nextSibling}Eo=null}}else Eo=Ao?bp(t.stateNode.nextSibling):null;return!0}function Woe(){for(var t=Eo;t;)t=bp(t.nextSibling)}function F0(){Eo=Ao=null,wn=!1}function QU(t){sc===null?sc=[t]:sc.push(t)}var XAe=kh.ReactCurrentBatchConfig;function S1(t,e,r){if(t=r.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(r._owner){if(r=r._owner,r){if(r.tag!==1)throw Error(Ye(309));var n=r.stateNode}if(!n)throw Error(Ye(147,t));var s=n,i=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===i?e.ref:(e=function(a){var o=s.refs;a===null?delete o[i]:o[i]=a},e._stringRef=i,e)}if(typeof t!="string")throw Error(Ye(284));if(!r._owner)throw Error(Ye(290,t))}return t}function vA(t,e){throw t=Object.prototype.toString.call(e),Error(Ye(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function uG(t){var e=t._init;return e(t._payload)}function qoe(t){function e(y,v){if(t){var b=y.deletions;b===null?(y.deletions=[v],y.flags|=16):b.push(v)}}function r(y,v){if(!t)return null;for(;v!==null;)e(y,v),v=v.sibling;return null}function n(y,v){for(y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function s(y,v){return y=jp(y,v),y.index=0,y.sibling=null,y}function i(y,v,b){return y.index=b,t?(b=y.alternate,b!==null?(b=b.index,b<v?(y.flags|=2,v):b):(y.flags|=2,v)):(y.flags|=1048576,v)}function a(y){return t&&y.alternate===null&&(y.flags|=2),y}function o(y,v,b,w){return v===null||v.tag!==6?(v=ZD(b,y.mode,w),v.return=y,v):(v=s(v,b),v.return=y,v)}function c(y,v,b,w){var S=b.type;return S===wv?d(y,v,b.props.children,w,b.key):v!==null&&(v.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===rf&&uG(S)===v.type)?(w=s(v,b.props),w.ref=S1(y,v,b),w.return=y,w):(w=nT(b.type,b.key,b.props,null,y.mode,w),w.ref=S1(y,v,b),w.return=y,w)}function u(y,v,b,w){return v===null||v.tag!==4||v.stateNode.containerInfo!==b.containerInfo||v.stateNode.implementation!==b.implementation?(v=eL(b,y.mode,w),v.return=y,v):(v=s(v,b.children||[]),v.return=y,v)}function d(y,v,b,w,S){return v===null||v.tag!==7?(v=Ay(b,y.mode,w,S),v.return=y,v):(v=s(v,b),v.return=y,v)}function h(y,v,b){if(typeof v=="string"&&v!==""||typeof v=="number")return v=ZD(""+v,y.mode,b),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case lA:return b=nT(v.type,v.key,v.props,null,y.mode,b),b.ref=S1(y,null,v),b.return=y,b;case bv:return v=eL(v,y.mode,b),v.return=y,v;case rf:var w=v._init;return h(y,w(v._payload),b)}if(sS(v)||y1(v))return v=Ay(v,y.mode,b,null),v.return=y,v;vA(y,v)}return null}function f(y,v,b,w){var S=v!==null?v.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return S!==null?null:o(y,v,""+b,w);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case lA:return b.key===S?c(y,v,b,w):null;case bv:return b.key===S?u(y,v,b,w):null;case rf:return S=b._init,f(y,v,S(b._payload),w)}if(sS(b)||y1(b))return S!==null?null:d(y,v,b,w,null);vA(y,b)}return null}function p(y,v,b,w,S){if(typeof w=="string"&&w!==""||typeof w=="number")return y=y.get(b)||null,o(v,y,""+w,S);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case lA:return y=y.get(w.key===null?b:w.key)||null,c(v,y,w,S);case bv:return y=y.get(w.key===null?b:w.key)||null,u(v,y,w,S);case rf:var k=w._init;return p(y,v,b,k(w._payload),S)}if(sS(w)||y1(w))return y=y.get(b)||null,d(v,y,w,S,null);vA(v,w)}return null}function m(y,v,b,w){for(var S=null,k=null,E=v,C=v=0,A=null;E!==null&&C<b.length;C++){E.index>C?(A=E,E=null):A=E.sibling;var M=f(y,E,b[C],w);if(M===null){E===null&&(E=A);break}t&&E&&M.alternate===null&&e(y,E),v=i(M,v,C),k===null?S=M:k.sibling=M,k=M,E=A}if(C===b.length)return r(y,E),wn&&Om(y,C),S;if(E===null){for(;C<b.length;C++)E=h(y,b[C],w),E!==null&&(v=i(E,v,C),k===null?S=E:k.sibling=E,k=E);return wn&&Om(y,C),S}for(E=n(y,E);C<b.length;C++)A=p(E,y,C,b[C],w),A!==null&&(t&&A.alternate!==null&&E.delete(A.key===null?C:A.key),v=i(A,v,C),k===null?S=A:k.sibling=A,k=A);return t&&E.forEach(function(z){return e(y,z)}),wn&&Om(y,C),S}function g(y,v,b,w){var S=y1(b);if(typeof S!="function")throw Error(Ye(150));if(b=S.call(b),b==null)throw Error(Ye(151));for(var k=S=null,E=v,C=v=0,A=null,M=b.next();E!==null&&!M.done;C++,M=b.next()){E.index>C?(A=E,E=null):A=E.sibling;var z=f(y,E,M.value,w);if(z===null){E===null&&(E=A);break}t&&E&&z.alternate===null&&e(y,E),v=i(z,v,C),k===null?S=z:k.sibling=z,k=z,E=A}if(M.done)return r(y,E),wn&&Om(y,C),S;if(E===null){for(;!M.done;C++,M=b.next())M=h(y,M.value,w),M!==null&&(v=i(M,v,C),k===null?S=M:k.sibling=M,k=M);return wn&&Om(y,C),S}for(E=n(y,E);!M.done;C++,M=b.next())M=p(E,y,C,M.value,w),M!==null&&(t&&M.alternate!==null&&E.delete(M.key===null?C:M.key),v=i(M,v,C),k===null?S=M:k.sibling=M,k=M);return t&&E.forEach(function(P){return e(y,P)}),wn&&Om(y,C),S}function x(y,v,b,w){if(typeof b=="object"&&b!==null&&b.type===wv&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case lA:e:{for(var S=b.key,k=v;k!==null;){if(k.key===S){if(S=b.type,S===wv){if(k.tag===7){r(y,k.sibling),v=s(k,b.props.children),v.return=y,y=v;break e}}else if(k.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===rf&&uG(S)===k.type){r(y,k.sibling),v=s(k,b.props),v.ref=S1(y,k,b),v.return=y,y=v;break e}r(y,k);break}else e(y,k);k=k.sibling}b.type===wv?(v=Ay(b.props.children,y.mode,w,b.key),v.return=y,y=v):(w=nT(b.type,b.key,b.props,null,y.mode,w),w.ref=S1(y,v,b),w.return=y,y=w)}return a(y);case bv:e:{for(k=b.key;v!==null;){if(v.key===k)if(v.tag===4&&v.stateNode.containerInfo===b.containerInfo&&v.stateNode.implementation===b.implementation){r(y,v.sibling),v=s(v,b.children||[]),v.return=y,y=v;break e}else{r(y,v);break}else e(y,v);v=v.sibling}v=eL(b,y.mode,w),v.return=y,y=v}return a(y);case rf:return k=b._init,x(y,v,k(b._payload),w)}if(sS(b))return m(y,v,b,w);if(y1(b))return g(y,v,b,w);vA(y,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,v!==null&&v.tag===6?(r(y,v.sibling),v=s(v,b),v.return=y,y=v):(r(y,v),v=ZD(b,y.mode,w),v.return=y,y=v),a(y)):r(y,v)}return x}var $0=qoe(!0),Goe=qoe(!1),N2=em(null),E2=null,Cv=null,ZU=null;function eH(){ZU=Cv=E2=null}function tH(t){var e=N2.current;hn(N2),t._currentValue=e}function JF(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function Xv(t,e){E2=t,ZU=Cv=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&($a=!0),t.firstContext=null)}function jl(t){var e=t._currentValue;if(ZU!==t)if(t={context:t,memoizedValue:e,next:null},Cv===null){if(E2===null)throw Error(Ye(308));Cv=t,E2.dependencies={lanes:0,firstContext:t}}else Cv=Cv.next=t;return e}var Jm=null;function rH(t){Jm===null?Jm=[t]:Jm.push(t)}function Koe(t,e,r,n){var s=e.interleaved;return s===null?(r.next=r,rH(e)):(r.next=s.next,s.next=r),e.interleaved=r,uh(t,n)}function uh(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var nf=!1;function nH(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Yoe(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Zd(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function wp(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,yr&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,uh(t,r)}return s=n.interleaved,s===null?(e.next=e,rH(n)):(e.next=s.next,s.next=e),n.interleaved=e,uh(t,r)}function JC(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,UU(t,r)}}function dG(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var s=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var a={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?s=i=a:i=i.next=a,r=r.next}while(r!==null);i===null?s=i=e:i=i.next=e}else s=i=e;r={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function A2(t,e,r,n){var s=t.updateQueue;nf=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,u=c.next;c.next=null,a===null?i=u:a.next=u,a=c;var d=t.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==a&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var h=s.baseState;a=0,d=u=c=null,o=i;do{var f=o.lane,p=o.eventTime;if((n&f)===f){d!==null&&(d=d.next={eventTime:p,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var m=t,g=o;switch(f=e,p=r,g.tag){case 1:if(m=g.payload,typeof m=="function"){h=m.call(p,h,f);break e}h=m;break e;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m=="function"?m.call(p,h,f):m,f==null)break e;h=Cn({},h,f);break e;case 2:nf=!0}}o.callback!==null&&o.lane!==0&&(t.flags|=64,f=s.effects,f===null?s.effects=[o]:f.push(o))}else p={eventTime:p,lane:f,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=p,c=h):d=d.next=p,a|=f;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;f=o,o=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(d===null&&(c=h),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,e=s.shared.interleaved,e!==null){s=e;do a|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);Vy|=a,t.lanes=a,t.memoizedState=h}}function hG(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var n=t[e],s=n.callback;if(s!==null){if(n.callback=null,n=r,typeof s!="function")throw Error(Ye(191,s));s.call(n)}}}var tE={},xu=em(tE),X_=em(tE),J_=em(tE);function Qm(t){if(t===tE)throw Error(Ye(174));return t}function sH(t,e){switch(tn(J_,e),tn(X_,t),tn(xu,tE),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:PF(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=PF(e,t)}hn(xu),tn(xu,e)}function B0(){hn(xu),hn(X_),hn(J_)}function Xoe(t){Qm(J_.current);var e=Qm(xu.current),r=PF(e,t.type);e!==r&&(tn(X_,t),tn(xu,r))}function iH(t){X_.current===t&&(hn(xu),hn(X_))}var Nn=em(0);function C2(t){for(var e=t;e!==null;){if(e.tag===13){var r=e.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||r.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var GD=[];function aH(){for(var t=0;t<GD.length;t++)GD[t]._workInProgressVersionPrimary=null;GD.length=0}var QC=kh.ReactCurrentDispatcher,KD=kh.ReactCurrentBatchConfig,Hy=0,An=null,ks=null,qs=null,T2=!1,a_=!1,Q_=0,JAe=0;function ki(){throw Error(Ye(321))}function oH(t,e){if(e===null)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(!yc(t[r],e[r]))return!1;return!0}function lH(t,e,r,n,s,i){if(Hy=i,An=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,QC.current=t===null||t.memoizedState===null?tCe:rCe,t=r(n,s),a_){i=0;do{if(a_=!1,Q_=0,25<=i)throw Error(Ye(301));i+=1,qs=ks=null,e.updateQueue=null,QC.current=nCe,t=r(n,s)}while(a_)}if(QC.current=P2,e=ks!==null&&ks.next!==null,Hy=0,qs=ks=An=null,T2=!1,e)throw Error(Ye(300));return t}function cH(){var t=Q_!==0;return Q_=0,t}function Dc(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return qs===null?An.memoizedState=qs=t:qs=qs.next=t,qs}function kl(){if(ks===null){var t=An.alternate;t=t!==null?t.memoizedState:null}else t=ks.next;var e=qs===null?An.memoizedState:qs.next;if(e!==null)qs=e,ks=t;else{if(t===null)throw Error(Ye(310));ks=t,t={memoizedState:ks.memoizedState,baseState:ks.baseState,baseQueue:ks.baseQueue,queue:ks.queue,next:null},qs===null?An.memoizedState=qs=t:qs=qs.next=t}return qs}function Z_(t,e){return typeof e=="function"?e(t):e}function YD(t){var e=kl(),r=e.queue;if(r===null)throw Error(Ye(311));r.lastRenderedReducer=t;var n=ks,s=n.baseQueue,i=r.pending;if(i!==null){if(s!==null){var a=s.next;s.next=i.next,i.next=a}n.baseQueue=s=i,r.pending=null}if(s!==null){i=s.next,n=n.baseState;var o=a=null,c=null,u=i;do{var d=u.lane;if((Hy&d)===d)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),n=u.hasEagerState?u.eagerState:t(n,u.action);else{var h={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(o=c=h,a=n):c=c.next=h,An.lanes|=d,Vy|=d}u=u.next}while(u!==null&&u!==i);c===null?a=n:c.next=o,yc(n,e.memoizedState)||($a=!0),e.memoizedState=n,e.baseState=a,e.baseQueue=c,r.lastRenderedState=n}if(t=r.interleaved,t!==null){s=t;do i=s.lane,An.lanes|=i,Vy|=i,s=s.next;while(s!==t)}else s===null&&(r.lanes=0);return[e.memoizedState,r.dispatch]}function XD(t){var e=kl(),r=e.queue;if(r===null)throw Error(Ye(311));r.lastRenderedReducer=t;var n=r.dispatch,s=r.pending,i=e.memoizedState;if(s!==null){r.pending=null;var a=s=s.next;do i=t(i,a.action),a=a.next;while(a!==s);yc(i,e.memoizedState)||($a=!0),e.memoizedState=i,e.baseQueue===null&&(e.baseState=i),r.lastRenderedState=i}return[i,n]}function Joe(){}function Qoe(t,e){var r=An,n=kl(),s=e(),i=!yc(n.memoizedState,s);if(i&&(n.memoizedState=s,$a=!0),n=n.queue,uH(tle.bind(null,r,n,t),[t]),n.getSnapshot!==e||i||qs!==null&&qs.memoizedState.tag&1){if(r.flags|=2048,ej(9,ele.bind(null,r,n,s,e),void 0,null),Ys===null)throw Error(Ye(349));Hy&30||Zoe(r,e,s)}return s}function Zoe(t,e,r){t.flags|=16384,t={getSnapshot:e,value:r},e=An.updateQueue,e===null?(e={lastEffect:null,stores:null},An.updateQueue=e,e.stores=[t]):(r=e.stores,r===null?e.stores=[t]:r.push(t))}function ele(t,e,r,n){e.value=r,e.getSnapshot=n,rle(e)&&nle(t)}function tle(t,e,r){return r(function(){rle(e)&&nle(t)})}function rle(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!yc(t,r)}catch{return!0}}function nle(t){var e=uh(t,1);e!==null&&hc(e,t,1,-1)}function fG(t){var e=Dc();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Z_,lastRenderedState:t},e.queue=t,t=t.dispatch=eCe.bind(null,An,t),[e.memoizedState,t]}function ej(t,e,r,n){return t={tag:t,create:e,destroy:r,deps:n,next:null},e=An.updateQueue,e===null?(e={lastEffect:null,stores:null},An.updateQueue=e,e.lastEffect=t.next=t):(r=e.lastEffect,r===null?e.lastEffect=t.next=t:(n=r.next,r.next=t,t.next=n,e.lastEffect=t)),t}function sle(){return kl().memoizedState}function ZC(t,e,r,n){var s=Dc();An.flags|=t,s.memoizedState=ej(1|e,r,void 0,n===void 0?null:n)}function UI(t,e,r,n){var s=kl();n=n===void 0?null:n;var i=void 0;if(ks!==null){var a=ks.memoizedState;if(i=a.destroy,n!==null&&oH(n,a.deps)){s.memoizedState=ej(e,r,i,n);return}}An.flags|=t,s.memoizedState=ej(1|e,r,i,n)}function pG(t,e){return ZC(8390656,8,t,e)}function uH(t,e){return UI(2048,8,t,e)}function ile(t,e){return UI(4,2,t,e)}function ale(t,e){return UI(4,4,t,e)}function ole(t,e){if(typeof e=="function")return t=t(),e(t),function(){e(null)};if(e!=null)return t=t(),e.current=t,function(){e.current=null}}function lle(t,e,r){return r=r!=null?r.concat([t]):null,UI(4,4,ole.bind(null,e,t),r)}function dH(){}function cle(t,e){var r=kl();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&oH(e,n[1])?n[0]:(r.memoizedState=[t,e],t)}function ule(t,e){var r=kl();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&oH(e,n[1])?n[0]:(t=t(),r.memoizedState=[t,e],t)}function dle(t,e,r){return Hy&21?(yc(r,e)||(r=goe(),An.lanes|=r,Vy|=r,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,$a=!0),t.memoizedState=r)}function QAe(t,e){var r=Pr;Pr=r!==0&&4>r?r:4,t(!0);var n=KD.transition;KD.transition={};try{t(!1),e()}finally{Pr=r,KD.transition=n}}function hle(){return kl().memoizedState}function ZAe(t,e,r){var n=_p(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},fle(t))ple(e,r);else if(r=Koe(t,e,r,n),r!==null){var s=ya();hc(r,t,n,s),mle(r,e,n)}}function eCe(t,e,r){var n=_p(t),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(fle(t))ple(e,s);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var a=e.lastRenderedState,o=i(a,r);if(s.hasEagerState=!0,s.eagerState=o,yc(o,a)){var c=e.interleaved;c===null?(s.next=s,rH(e)):(s.next=c.next,c.next=s),e.interleaved=s;return}}catch{}finally{}r=Koe(t,e,s,n),r!==null&&(s=ya(),hc(r,t,n,s),mle(r,e,n))}}function fle(t){var e=t.alternate;return t===An||e!==null&&e===An}function ple(t,e){a_=T2=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function mle(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,UU(t,r)}}var P2={readContext:jl,useCallback:ki,useContext:ki,useEffect:ki,useImperativeHandle:ki,useInsertionEffect:ki,useLayoutEffect:ki,useMemo:ki,useReducer:ki,useRef:ki,useState:ki,useDebugValue:ki,useDeferredValue:ki,useTransition:ki,useMutableSource:ki,useSyncExternalStore:ki,useId:ki,unstable_isNewReconciler:!1},tCe={readContext:jl,useCallback:function(t,e){return Dc().memoizedState=[t,e===void 0?null:e],t},useContext:jl,useEffect:pG,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,ZC(4194308,4,ole.bind(null,e,t),r)},useLayoutEffect:function(t,e){return ZC(4194308,4,t,e)},useInsertionEffect:function(t,e){return ZC(4,2,t,e)},useMemo:function(t,e){var r=Dc();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=Dc();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=ZAe.bind(null,An,t),[n.memoizedState,t]},useRef:function(t){var e=Dc();return t={current:t},e.memoizedState=t},useState:fG,useDebugValue:dH,useDeferredValue:function(t){return Dc().memoizedState=t},useTransition:function(){var t=fG(!1),e=t[0];return t=QAe.bind(null,t[1]),Dc().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=An,s=Dc();if(wn){if(r===void 0)throw Error(Ye(407));r=r()}else{if(r=e(),Ys===null)throw Error(Ye(349));Hy&30||Zoe(n,e,r)}s.memoizedState=r;var i={value:r,getSnapshot:e};return s.queue=i,pG(tle.bind(null,n,i,t),[t]),n.flags|=2048,ej(9,ele.bind(null,n,i,r,e),void 0,null),r},useId:function(){var t=Dc(),e=Ys.identifierPrefix;if(wn){var r=Gd,n=qd;r=(n&~(1<<32-dc(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=Q_++,0<r&&(e+="H"+r.toString(32)),e+=":"}else r=JAe++,e=":"+e+"r"+r.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},rCe={readContext:jl,useCallback:cle,useContext:jl,useEffect:uH,useImperativeHandle:lle,useInsertionEffect:ile,useLayoutEffect:ale,useMemo:ule,useReducer:YD,useRef:sle,useState:function(){return YD(Z_)},useDebugValue:dH,useDeferredValue:function(t){var e=kl();return dle(e,ks.memoizedState,t)},useTransition:function(){var t=YD(Z_)[0],e=kl().memoizedState;return[t,e]},useMutableSource:Joe,useSyncExternalStore:Qoe,useId:hle,unstable_isNewReconciler:!1},nCe={readContext:jl,useCallback:cle,useContext:jl,useEffect:uH,useImperativeHandle:lle,useInsertionEffect:ile,useLayoutEffect:ale,useMemo:ule,useReducer:XD,useRef:sle,useState:function(){return XD(Z_)},useDebugValue:dH,useDeferredValue:function(t){var e=kl();return ks===null?e.memoizedState=t:dle(e,ks.memoizedState,t)},useTransition:function(){var t=XD(Z_)[0],e=kl().memoizedState;return[t,e]},useMutableSource:Joe,useSyncExternalStore:Qoe,useId:hle,unstable_isNewReconciler:!1};function Ul(t,e){if(t&&t.defaultProps){e=Cn({},e),t=t.defaultProps;for(var r in t)e[r]===void 0&&(e[r]=t[r]);return e}return e}function QF(t,e,r,n){e=t.memoizedState,r=r(n,e),r=r==null?e:Cn({},e,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var HI={isMounted:function(t){return(t=t._reactInternals)?px(t)===t:!1},enqueueSetState:function(t,e,r){t=t._reactInternals;var n=ya(),s=_p(t),i=Zd(n,s);i.payload=e,r!=null&&(i.callback=r),e=wp(t,i,s),e!==null&&(hc(e,t,s,n),JC(e,t,s))},enqueueReplaceState:function(t,e,r){t=t._reactInternals;var n=ya(),s=_p(t),i=Zd(n,s);i.tag=1,i.payload=e,r!=null&&(i.callback=r),e=wp(t,i,s),e!==null&&(hc(e,t,s,n),JC(e,t,s))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var r=ya(),n=_p(t),s=Zd(r,n);s.tag=2,e!=null&&(s.callback=e),e=wp(t,s,n),e!==null&&(hc(e,t,n,r),JC(e,t,n))}};function mG(t,e,r,n,s,i,a){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(n,i,a):e.prototype&&e.prototype.isPureReactComponent?!q_(r,n)||!q_(s,i):!0}function gle(t,e,r){var n=!1,s=Lp,i=e.contextType;return typeof i=="object"&&i!==null?i=jl(i):(s=Wa(e)?zy:zi.current,n=e.contextTypes,i=(n=n!=null)?L0(t,s):Lp),e=new e(r,i),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=HI,t.stateNode=e,e._reactInternals=t,n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=i),e}function gG(t,e,r,n){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(r,n),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(r,n),e.state!==t&&HI.enqueueReplaceState(e,e.state,null)}function ZF(t,e,r,n){var s=t.stateNode;s.props=r,s.state=t.memoizedState,s.refs={},nH(t);var i=e.contextType;typeof i=="object"&&i!==null?s.context=jl(i):(i=Wa(e)?zy:zi.current,s.context=L0(t,i)),s.state=t.memoizedState,i=e.getDerivedStateFromProps,typeof i=="function"&&(QF(t,e,i,r),s.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(e=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),e!==s.state&&HI.enqueueReplaceState(s,s.state,null),A2(t,r,s,n),s.state=t.memoizedState),typeof s.componentDidMount=="function"&&(t.flags|=4194308)}function z0(t,e){try{var r="",n=e;do r+=PEe(n),n=n.return;while(n);var s=r}catch(i){s=`
Error generating stack: `+i.message+`
`+i.stack}return{value:t,source:e,stack:s,digest:null}}function JD(t,e,r){return{value:t,source:null,stack:r??null,digest:e??null}}function e$(t,e){try{console.error(e.value)}catch(r){setTimeout(function(){throw r})}}var sCe=typeof WeakMap=="function"?WeakMap:Map;function yle(t,e,r){r=Zd(-1,r),r.tag=3,r.payload={element:null};var n=e.value;return r.callback=function(){I2||(I2=!0,u$=n),e$(t,e)},r}function xle(t,e,r){r=Zd(-1,r),r.tag=3;var n=t.type.getDerivedStateFromError;if(typeof n=="function"){var s=e.value;r.payload=function(){return n(s)},r.callback=function(){e$(t,e)}}var i=t.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){e$(t,e),typeof n!="function"&&(Sp===null?Sp=new Set([this]):Sp.add(this));var a=e.stack;this.componentDidCatch(e.value,{componentStack:a!==null?a:""})}),r}function yG(t,e,r){var n=t.pingCache;if(n===null){n=t.pingCache=new sCe;var s=new Set;n.set(e,s)}else s=n.get(e),s===void 0&&(s=new Set,n.set(e,s));s.has(r)||(s.add(r),t=xCe.bind(null,t,e,r),e.then(t,t))}function xG(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function vG(t,e,r,n,s){return t.mode&1?(t.flags|=65536,t.lanes=s,t):(t===e?t.flags|=65536:(t.flags|=128,r.flags|=131072,r.flags&=-52805,r.tag===1&&(r.alternate===null?r.tag=17:(e=Zd(-1,1),e.tag=2,wp(r,e,1))),r.lanes|=1),t)}var iCe=kh.ReactCurrentOwner,$a=!1;function ca(t,e,r,n){e.child=t===null?Goe(e,null,r,n):$0(e,t.child,r,n)}function bG(t,e,r,n,s){r=r.render;var i=e.ref;return Xv(e,s),n=lH(t,e,r,n,i,s),r=cH(),t!==null&&!$a?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,dh(t,e,s)):(wn&&r&&XU(e),e.flags|=1,ca(t,e,n,s),e.child)}function wG(t,e,r,n,s){if(t===null){var i=r.type;return typeof i=="function"&&!vH(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(e.tag=15,e.type=i,vle(t,e,i,n,s)):(t=nT(r.type,null,n,e,e.mode,s),t.ref=e.ref,t.return=e,e.child=t)}if(i=t.child,!(t.lanes&s)){var a=i.memoizedProps;if(r=r.compare,r=r!==null?r:q_,r(a,n)&&t.ref===e.ref)return dh(t,e,s)}return e.flags|=1,t=jp(i,n),t.ref=e.ref,t.return=e,e.child=t}function vle(t,e,r,n,s){if(t!==null){var i=t.memoizedProps;if(q_(i,n)&&t.ref===e.ref)if($a=!1,e.pendingProps=n=i,(t.lanes&s)!==0)t.flags&131072&&($a=!0);else return e.lanes=t.lanes,dh(t,e,s)}return t$(t,e,r,n,s)}function ble(t,e,r){var n=e.pendingProps,s=n.children,i=t!==null?t.memoizedState:null;if(n.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},tn(Pv,wo),wo|=r;else{if(!(r&1073741824))return t=i!==null?i.baseLanes|r:r,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,tn(Pv,wo),wo|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:r,tn(Pv,wo),wo|=n}else i!==null?(n=i.baseLanes|r,e.memoizedState=null):n=r,tn(Pv,wo),wo|=n;return ca(t,e,s,r),e.child}function wle(t,e){var r=e.ref;(t===null&&r!==null||t!==null&&t.ref!==r)&&(e.flags|=512,e.flags|=2097152)}function t$(t,e,r,n,s){var i=Wa(r)?zy:zi.current;return i=L0(e,i),Xv(e,s),r=lH(t,e,r,n,i,s),n=cH(),t!==null&&!$a?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,dh(t,e,s)):(wn&&n&&XU(e),e.flags|=1,ca(t,e,r,s),e.child)}function SG(t,e,r,n,s){if(Wa(r)){var i=!0;_2(e)}else i=!1;if(Xv(e,s),e.stateNode===null)eT(t,e),gle(e,r,n),ZF(e,r,n,s),n=!0;else if(t===null){var a=e.stateNode,o=e.memoizedProps;a.props=o;var c=a.context,u=r.contextType;typeof u=="object"&&u!==null?u=jl(u):(u=Wa(r)?zy:zi.current,u=L0(e,u));var d=r.getDerivedStateFromProps,h=typeof d=="function"||typeof a.getSnapshotBeforeUpdate=="function";h||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==n||c!==u)&&gG(e,a,n,u),nf=!1;var f=e.memoizedState;a.state=f,A2(e,n,a,s),c=e.memoizedState,o!==n||f!==c||Va.current||nf?(typeof d=="function"&&(QF(e,r,d,n),c=e.memoizedState),(o=nf||mG(e,r,o,n,f,c,u))?(h||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(e.flags|=4194308)):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=n,e.memoizedState=c),a.props=n,a.state=c,a.context=u,n=o):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),n=!1)}else{a=e.stateNode,Yoe(t,e),o=e.memoizedProps,u=e.type===e.elementType?o:Ul(e.type,o),a.props=u,h=e.pendingProps,f=a.context,c=r.contextType,typeof c=="object"&&c!==null?c=jl(c):(c=Wa(r)?zy:zi.current,c=L0(e,c));var p=r.getDerivedStateFromProps;(d=typeof p=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==h||f!==c)&&gG(e,a,n,c),nf=!1,f=e.memoizedState,a.state=f,A2(e,n,a,s);var m=e.memoizedState;o!==h||f!==m||Va.current||nf?(typeof p=="function"&&(QF(e,r,p,n),m=e.memoizedState),(u=nf||mG(e,r,u,n,f,m,c)||!1)?(d||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(n,m,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(n,m,c)),typeof a.componentDidUpdate=="function"&&(e.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof a.componentDidUpdate!="function"||o===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),e.memoizedProps=n,e.memoizedState=m),a.props=n,a.state=m,a.context=c,n=u):(typeof a.componentDidUpdate!="function"||o===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),n=!1)}return r$(t,e,r,n,i,s)}function r$(t,e,r,n,s,i){wle(t,e);var a=(e.flags&128)!==0;if(!n&&!a)return s&&oG(e,r,!1),dh(t,e,i);n=e.stateNode,iCe.current=e;var o=a&&typeof r.getDerivedStateFromError!="function"?null:n.render();return e.flags|=1,t!==null&&a?(e.child=$0(e,t.child,null,i),e.child=$0(e,null,o,i)):ca(t,e,o,i),e.memoizedState=n.state,s&&oG(e,r,!0),e.child}function Sle(t){var e=t.stateNode;e.pendingContext?aG(t,e.pendingContext,e.pendingContext!==e.context):e.context&&aG(t,e.context,!1),sH(t,e.containerInfo)}function _G(t,e,r,n,s){return F0(),QU(s),e.flags|=256,ca(t,e,r,n),e.child}var n$={dehydrated:null,treeContext:null,retryLane:0};function s$(t){return{baseLanes:t,cachePool:null,transitions:null}}function _le(t,e,r){var n=e.pendingProps,s=Nn.current,i=!1,a=(e.flags&128)!==0,o;if((o=a)||(o=t!==null&&t.memoizedState===null?!1:(s&2)!==0),o?(i=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(s|=1),tn(Nn,s&1),t===null)return XF(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(a=n.children,t=n.fallback,i?(n=e.mode,i=e.child,a={mode:"hidden",children:a},!(n&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=qI(a,n,0,null),t=Ay(t,n,r,null),i.return=e,t.return=e,i.sibling=t,e.child=i,e.child.memoizedState=s$(r),e.memoizedState=n$,t):hH(e,a));if(s=t.memoizedState,s!==null&&(o=s.dehydrated,o!==null))return aCe(t,e,a,n,o,s,r);if(i){i=n.fallback,a=e.mode,s=t.child,o=s.sibling;var c={mode:"hidden",children:n.children};return!(a&1)&&e.child!==s?(n=e.child,n.childLanes=0,n.pendingProps=c,e.deletions=null):(n=jp(s,c),n.subtreeFlags=s.subtreeFlags&14680064),o!==null?i=jp(o,i):(i=Ay(i,a,r,null),i.flags|=2),i.return=e,n.return=e,n.sibling=i,e.child=n,n=i,i=e.child,a=t.child.memoizedState,a=a===null?s$(r):{baseLanes:a.baseLanes|r,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=t.childLanes&~r,e.memoizedState=n$,n}return i=t.child,t=i.sibling,n=jp(i,{mode:"visible",children:n.children}),!(e.mode&1)&&(n.lanes=r),n.return=e,n.sibling=null,t!==null&&(r=e.deletions,r===null?(e.deletions=[t],e.flags|=16):r.push(t)),e.child=n,e.memoizedState=null,n}function hH(t,e){return e=qI({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function bA(t,e,r,n){return n!==null&&QU(n),$0(e,t.child,null,r),t=hH(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function aCe(t,e,r,n,s,i,a){if(r)return e.flags&256?(e.flags&=-257,n=JD(Error(Ye(422))),bA(t,e,a,n)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(i=n.fallback,s=e.mode,n=qI({mode:"visible",children:n.children},s,0,null),i=Ay(i,s,a,null),i.flags|=2,n.return=e,i.return=e,n.sibling=i,e.child=n,e.mode&1&&$0(e,t.child,null,a),e.child.memoizedState=s$(a),e.memoizedState=n$,i);if(!(e.mode&1))return bA(t,e,a,null);if(s.data==="$!"){if(n=s.nextSibling&&s.nextSibling.dataset,n)var o=n.dgst;return n=o,i=Error(Ye(419)),n=JD(i,n,void 0),bA(t,e,a,n)}if(o=(a&t.childLanes)!==0,$a||o){if(n=Ys,n!==null){switch(a&-a){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(n.suspendedLanes|a)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,uh(t,s),hc(n,t,s,-1))}return xH(),n=JD(Error(Ye(421))),bA(t,e,a,n)}return s.data==="$?"?(e.flags|=128,e.child=t.child,e=vCe.bind(null,t),s._reactRetry=e,null):(t=i.treeContext,Eo=bp(s.nextSibling),Ao=e,wn=!0,sc=null,t!==null&&(sl[il++]=qd,sl[il++]=Gd,sl[il++]=Uy,qd=t.id,Gd=t.overflow,Uy=e),e=hH(e,n.children),e.flags|=4096,e)}function jG(t,e,r){t.lanes|=e;var n=t.alternate;n!==null&&(n.lanes|=e),JF(t.return,e,r)}function QD(t,e,r,n,s){var i=t.memoizedState;i===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:s}:(i.isBackwards=e,i.rendering=null,i.renderingStartTime=0,i.last=n,i.tail=r,i.tailMode=s)}function jle(t,e,r){var n=e.pendingProps,s=n.revealOrder,i=n.tail;if(ca(t,e,n.children,r),n=Nn.current,n&2)n=n&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&jG(t,r,e);else if(t.tag===19)jG(t,r,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}n&=1}if(tn(Nn,n),!(e.mode&1))e.memoizedState=null;else switch(s){case"forwards":for(r=e.child,s=null;r!==null;)t=r.alternate,t!==null&&C2(t)===null&&(s=r),r=r.sibling;r=s,r===null?(s=e.child,e.child=null):(s=r.sibling,r.sibling=null),QD(e,!1,s,r,i);break;case"backwards":for(r=null,s=e.child,e.child=null;s!==null;){if(t=s.alternate,t!==null&&C2(t)===null){e.child=s;break}t=s.sibling,s.sibling=r,r=s,s=t}QD(e,!0,r,null,i);break;case"together":QD(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function eT(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function dh(t,e,r){if(t!==null&&(e.dependencies=t.dependencies),Vy|=e.lanes,!(r&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(Ye(153));if(e.child!==null){for(t=e.child,r=jp(t,t.pendingProps),e.child=r,r.return=e;t.sibling!==null;)t=t.sibling,r=r.sibling=jp(t,t.pendingProps),r.return=e;r.sibling=null}return e.child}function oCe(t,e,r){switch(e.tag){case 3:Sle(e),F0();break;case 5:Xoe(e);break;case 1:Wa(e.type)&&_2(e);break;case 4:sH(e,e.stateNode.containerInfo);break;case 10:var n=e.type._context,s=e.memoizedProps.value;tn(N2,n._currentValue),n._currentValue=s;break;case 13:if(n=e.memoizedState,n!==null)return n.dehydrated!==null?(tn(Nn,Nn.current&1),e.flags|=128,null):r&e.child.childLanes?_le(t,e,r):(tn(Nn,Nn.current&1),t=dh(t,e,r),t!==null?t.sibling:null);tn(Nn,Nn.current&1);break;case 19:if(n=(r&e.childLanes)!==0,t.flags&128){if(n)return jle(t,e,r);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),tn(Nn,Nn.current),n)break;return null;case 22:case 23:return e.lanes=0,ble(t,e,r)}return dh(t,e,r)}var kle,i$,Nle,Ele;kle=function(t,e){for(var r=e.child;r!==null;){if(r.tag===5||r.tag===6)t.appendChild(r.stateNode);else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};i$=function(){};Nle=function(t,e,r,n){var s=t.memoizedProps;if(s!==n){t=e.stateNode,Qm(xu.current);var i=null;switch(r){case"input":s=EF(t,s),n=EF(t,n),i=[];break;case"select":s=Cn({},s,{value:void 0}),n=Cn({},n,{value:void 0}),i=[];break;case"textarea":s=TF(t,s),n=TF(t,n),i=[];break;default:typeof s.onClick!="function"&&typeof n.onClick=="function"&&(t.onclick=w2)}OF(r,n);var a;r=null;for(u in s)if(!n.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var o=s[u];for(a in o)o.hasOwnProperty(a)&&(r||(r={}),r[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&($_.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in n){var c=n[u];if(o=s!=null?s[u]:void 0,n.hasOwnProperty(u)&&c!==o&&(c!=null||o!=null))if(u==="style")if(o){for(a in o)!o.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(r||(r={}),r[a]="");for(a in c)c.hasOwnProperty(a)&&o[a]!==c[a]&&(r||(r={}),r[a]=c[a])}else r||(i||(i=[]),i.push(u,r)),r=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,o=o?o.__html:void 0,c!=null&&o!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&($_.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&an("scroll",t),i||o===c||(i=[])):(i=i||[]).push(u,c))}r&&(i=i||[]).push("style",r);var u=i;(e.updateQueue=u)&&(e.flags|=4)}};Ele=function(t,e,r,n){r!==n&&(e.flags|=4)};function _1(t,e){if(!wn)switch(t.tailMode){case"hidden":e=t.tail;for(var r=null;e!==null;)e.alternate!==null&&(r=e),e=e.sibling;r===null?t.tail=null:r.sibling=null;break;case"collapsed":r=t.tail;for(var n=null;r!==null;)r.alternate!==null&&(n=r),r=r.sibling;n===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:n.sibling=null}}function Ni(t){var e=t.alternate!==null&&t.alternate.child===t.child,r=0,n=0;if(e)for(var s=t.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags&14680064,n|=s.flags&14680064,s.return=t,s=s.sibling;else for(s=t.child;s!==null;)r|=s.lanes|s.childLanes,n|=s.subtreeFlags,n|=s.flags,s.return=t,s=s.sibling;return t.subtreeFlags|=n,t.childLanes=r,e}function lCe(t,e,r){var n=e.pendingProps;switch(JU(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ni(e),null;case 1:return Wa(e.type)&&S2(),Ni(e),null;case 3:return n=e.stateNode,B0(),hn(Va),hn(zi),aH(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(t===null||t.child===null)&&(xA(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,sc!==null&&(f$(sc),sc=null))),i$(t,e),Ni(e),null;case 5:iH(e);var s=Qm(J_.current);if(r=e.type,t!==null&&e.stateNode!=null)Nle(t,e,r,n,s),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!n){if(e.stateNode===null)throw Error(Ye(166));return Ni(e),null}if(t=Qm(xu.current),xA(e)){n=e.stateNode,r=e.type;var i=e.memoizedProps;switch(n[hu]=e,n[Y_]=i,t=(e.mode&1)!==0,r){case"dialog":an("cancel",n),an("close",n);break;case"iframe":case"object":case"embed":an("load",n);break;case"video":case"audio":for(s=0;s<aS.length;s++)an(aS[s],n);break;case"source":an("error",n);break;case"img":case"image":case"link":an("error",n),an("load",n);break;case"details":an("toggle",n);break;case"input":Iq(n,i),an("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!i.multiple},an("invalid",n);break;case"textarea":Mq(n,i),an("invalid",n)}OF(r,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var o=i[a];a==="children"?typeof o=="string"?n.textContent!==o&&(i.suppressHydrationWarning!==!0&&yA(n.textContent,o,t),s=["children",o]):typeof o=="number"&&n.textContent!==""+o&&(i.suppressHydrationWarning!==!0&&yA(n.textContent,o,t),s=["children",""+o]):$_.hasOwnProperty(a)&&o!=null&&a==="onScroll"&&an("scroll",n)}switch(r){case"input":cA(n),Rq(n,i,!0);break;case"textarea":cA(n),Dq(n);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(n.onclick=w2)}n=s,e.updateQueue=n,n!==null&&(e.flags|=4)}else{a=s.nodeType===9?s:s.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=toe(r)),t==="http://www.w3.org/1999/xhtml"?r==="script"?(t=a.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=a.createElement(r,{is:n.is}):(t=a.createElement(r),r==="select"&&(a=t,n.multiple?a.multiple=!0:n.size&&(a.size=n.size))):t=a.createElementNS(t,r),t[hu]=e,t[Y_]=n,kle(t,e,!1,!1),e.stateNode=t;e:{switch(a=IF(r,n),r){case"dialog":an("cancel",t),an("close",t),s=n;break;case"iframe":case"object":case"embed":an("load",t),s=n;break;case"video":case"audio":for(s=0;s<aS.length;s++)an(aS[s],t);s=n;break;case"source":an("error",t),s=n;break;case"img":case"image":case"link":an("error",t),an("load",t),s=n;break;case"details":an("toggle",t),s=n;break;case"input":Iq(t,n),s=EF(t,n),an("invalid",t);break;case"option":s=n;break;case"select":t._wrapperState={wasMultiple:!!n.multiple},s=Cn({},n,{value:void 0}),an("invalid",t);break;case"textarea":Mq(t,n),s=TF(t,n),an("invalid",t);break;default:s=n}OF(r,s),o=s;for(i in o)if(o.hasOwnProperty(i)){var c=o[i];i==="style"?soe(t,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&roe(t,c)):i==="children"?typeof c=="string"?(r!=="textarea"||c!=="")&&B_(t,c):typeof c=="number"&&B_(t,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&($_.hasOwnProperty(i)?c!=null&&i==="onScroll"&&an("scroll",t):c!=null&&DU(t,i,c,a))}switch(r){case"input":cA(t),Rq(t,n,!1);break;case"textarea":cA(t),Dq(t);break;case"option":n.value!=null&&t.setAttribute("value",""+Dp(n.value));break;case"select":t.multiple=!!n.multiple,i=n.value,i!=null?qv(t,!!n.multiple,i,!1):n.defaultValue!=null&&qv(t,!!n.multiple,n.defaultValue,!0);break;default:typeof s.onClick=="function"&&(t.onclick=w2)}switch(r){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}}n&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return Ni(e),null;case 6:if(t&&e.stateNode!=null)Ele(t,e,t.memoizedProps,n);else{if(typeof n!="string"&&e.stateNode===null)throw Error(Ye(166));if(r=Qm(J_.current),Qm(xu.current),xA(e)){if(n=e.stateNode,r=e.memoizedProps,n[hu]=e,(i=n.nodeValue!==r)&&(t=Ao,t!==null))switch(t.tag){case 3:yA(n.nodeValue,r,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&yA(n.nodeValue,r,(t.mode&1)!==0)}i&&(e.flags|=4)}else n=(r.nodeType===9?r:r.ownerDocument).createTextNode(n),n[hu]=e,e.stateNode=n}return Ni(e),null;case 13:if(hn(Nn),n=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(wn&&Eo!==null&&e.mode&1&&!(e.flags&128))Woe(),F0(),e.flags|=98560,i=!1;else if(i=xA(e),n!==null&&n.dehydrated!==null){if(t===null){if(!i)throw Error(Ye(318));if(i=e.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Ye(317));i[hu]=e}else F0(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Ni(e),i=!1}else sc!==null&&(f$(sc),sc=null),i=!0;if(!i)return e.flags&65536?e:null}return e.flags&128?(e.lanes=r,e):(n=n!==null,n!==(t!==null&&t.memoizedState!==null)&&n&&(e.child.flags|=8192,e.mode&1&&(t===null||Nn.current&1?As===0&&(As=3):xH())),e.updateQueue!==null&&(e.flags|=4),Ni(e),null);case 4:return B0(),i$(t,e),t===null&&G_(e.stateNode.containerInfo),Ni(e),null;case 10:return tH(e.type._context),Ni(e),null;case 17:return Wa(e.type)&&S2(),Ni(e),null;case 19:if(hn(Nn),i=e.memoizedState,i===null)return Ni(e),null;if(n=(e.flags&128)!==0,a=i.rendering,a===null)if(n)_1(i,!1);else{if(As!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(a=C2(t),a!==null){for(e.flags|=128,_1(i,!1),n=a.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),e.subtreeFlags=0,n=r,r=e.child;r!==null;)i=r,t=n,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=t,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,t=a.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),r=r.sibling;return tn(Nn,Nn.current&1|2),e.child}t=t.sibling}i.tail!==null&&Jn()>U0&&(e.flags|=128,n=!0,_1(i,!1),e.lanes=4194304)}else{if(!n)if(t=C2(a),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),_1(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!wn)return Ni(e),null}else 2*Jn()-i.renderingStartTime>U0&&r!==1073741824&&(e.flags|=128,n=!0,_1(i,!1),e.lanes=4194304);i.isBackwards?(a.sibling=e.child,e.child=a):(r=i.last,r!==null?r.sibling=a:e.child=a,i.last=a)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Jn(),e.sibling=null,r=Nn.current,tn(Nn,n?r&1|2:r&1),e):(Ni(e),null);case 22:case 23:return yH(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?wo&1073741824&&(Ni(e),e.subtreeFlags&6&&(e.flags|=8192)):Ni(e),null;case 24:return null;case 25:return null}throw Error(Ye(156,e.tag))}function cCe(t,e){switch(JU(e),e.tag){case 1:return Wa(e.type)&&S2(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return B0(),hn(Va),hn(zi),aH(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return iH(e),null;case 13:if(hn(Nn),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Ye(340));F0()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return hn(Nn),null;case 4:return B0(),null;case 10:return tH(e.type._context),null;case 22:case 23:return yH(),null;case 24:return null;default:return null}}var wA=!1,Mi=!1,uCe=typeof WeakSet=="function"?WeakSet:Set,mt=null;function Tv(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){$n(t,e,n)}else r.current=null}function a$(t,e,r){try{r()}catch(n){$n(t,e,n)}}var kG=!1;function dCe(t,e){if(HF=x2,t=Ooe(),YU(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var s=n.anchorOffset,i=n.focusNode;n=n.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var a=0,o=-1,c=-1,u=0,d=0,h=t,f=null;t:for(;;){for(var p;h!==r||s!==0&&h.nodeType!==3||(o=a+s),h!==i||n!==0&&h.nodeType!==3||(c=a+n),h.nodeType===3&&(a+=h.nodeValue.length),(p=h.firstChild)!==null;)f=h,h=p;for(;;){if(h===t)break t;if(f===r&&++u===s&&(o=a),f===i&&++d===n&&(c=a),(p=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=p}r=o===-1||c===-1?null:{start:o,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(VF={focusedElem:t,selectionRange:r},x2=!1,mt=e;mt!==null;)if(e=mt,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,mt=t;else for(;mt!==null;){e=mt;try{var m=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(m!==null){var g=m.memoizedProps,x=m.memoizedState,y=e.stateNode,v=y.getSnapshotBeforeUpdate(e.elementType===e.type?g:Ul(e.type,g),x);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var b=e.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ye(163))}}catch(w){$n(e,e.return,w)}if(t=e.sibling,t!==null){t.return=e.return,mt=t;break}mt=e.return}return m=kG,kG=!1,m}function o_(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&t)===t){var i=s.destroy;s.destroy=void 0,i!==void 0&&a$(e,r,i)}s=s.next}while(s!==n)}}function VI(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function o$(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function Ale(t){var e=t.alternate;e!==null&&(t.alternate=null,Ale(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[hu],delete e[Y_],delete e[GF],delete e[GAe],delete e[KAe])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function Cle(t){return t.tag===5||t.tag===3||t.tag===4}function NG(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Cle(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function l$(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=w2));else if(n!==4&&(t=t.child,t!==null))for(l$(t,e,r),t=t.sibling;t!==null;)l$(t,e,r),t=t.sibling}function c$(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(c$(t,e,r),t=t.sibling;t!==null;)c$(t,e,r),t=t.sibling}var li=null,rc=!1;function Fh(t,e,r){for(r=r.child;r!==null;)Tle(t,e,r),r=r.sibling}function Tle(t,e,r){if(yu&&typeof yu.onCommitFiberUnmount=="function")try{yu.onCommitFiberUnmount(DI,r)}catch{}switch(r.tag){case 5:Mi||Tv(r,e);case 6:var n=li,s=rc;li=null,Fh(t,e,r),li=n,rc=s,li!==null&&(rc?(t=li,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):li.removeChild(r.stateNode));break;case 18:li!==null&&(rc?(t=li,r=r.stateNode,t.nodeType===8?WD(t.parentNode,r):t.nodeType===1&&WD(t,r),V_(t)):WD(li,r.stateNode));break;case 4:n=li,s=rc,li=r.stateNode.containerInfo,rc=!0,Fh(t,e,r),li=n,rc=s;break;case 0:case 11:case 14:case 15:if(!Mi&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){s=n=n.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&a$(r,e,a),s=s.next}while(s!==n)}Fh(t,e,r);break;case 1:if(!Mi&&(Tv(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(o){$n(r,e,o)}Fh(t,e,r);break;case 21:Fh(t,e,r);break;case 22:r.mode&1?(Mi=(n=Mi)||r.memoizedState!==null,Fh(t,e,r),Mi=n):Fh(t,e,r);break;default:Fh(t,e,r)}}function EG(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new uCe),e.forEach(function(n){var s=bCe.bind(null,t,n);r.has(n)||(r.add(n),n.then(s,s))})}}function Il(t,e){var r=e.deletions;if(r!==null)for(var n=0;n<r.length;n++){var s=r[n];try{var i=t,a=e,o=a;e:for(;o!==null;){switch(o.tag){case 5:li=o.stateNode,rc=!1;break e;case 3:li=o.stateNode.containerInfo,rc=!0;break e;case 4:li=o.stateNode.containerInfo,rc=!0;break e}o=o.return}if(li===null)throw Error(Ye(160));Tle(i,a,s),li=null,rc=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){$n(s,e,u)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)Ple(e,t),e=e.sibling}function Ple(t,e){var r=t.alternate,n=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Il(e,t),Pc(t),n&4){try{o_(3,t,t.return),VI(3,t)}catch(g){$n(t,t.return,g)}try{o_(5,t,t.return)}catch(g){$n(t,t.return,g)}}break;case 1:Il(e,t),Pc(t),n&512&&r!==null&&Tv(r,r.return);break;case 5:if(Il(e,t),Pc(t),n&512&&r!==null&&Tv(r,r.return),t.flags&32){var s=t.stateNode;try{B_(s,"")}catch(g){$n(t,t.return,g)}}if(n&4&&(s=t.stateNode,s!=null)){var i=t.memoizedProps,a=r!==null?r.memoizedProps:i,o=t.type,c=t.updateQueue;if(t.updateQueue=null,c!==null)try{o==="input"&&i.type==="radio"&&i.name!=null&&Zae(s,i),IF(o,a);var u=IF(o,i);for(a=0;a<c.length;a+=2){var d=c[a],h=c[a+1];d==="style"?soe(s,h):d==="dangerouslySetInnerHTML"?roe(s,h):d==="children"?B_(s,h):DU(s,d,h,u)}switch(o){case"input":AF(s,i);break;case"textarea":eoe(s,i);break;case"select":var f=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var p=i.value;p!=null?qv(s,!!i.multiple,p,!1):f!==!!i.multiple&&(i.defaultValue!=null?qv(s,!!i.multiple,i.defaultValue,!0):qv(s,!!i.multiple,i.multiple?[]:"",!1))}s[Y_]=i}catch(g){$n(t,t.return,g)}}break;case 6:if(Il(e,t),Pc(t),n&4){if(t.stateNode===null)throw Error(Ye(162));s=t.stateNode,i=t.memoizedProps;try{s.nodeValue=i}catch(g){$n(t,t.return,g)}}break;case 3:if(Il(e,t),Pc(t),n&4&&r!==null&&r.memoizedState.isDehydrated)try{V_(e.containerInfo)}catch(g){$n(t,t.return,g)}break;case 4:Il(e,t),Pc(t);break;case 13:Il(e,t),Pc(t),s=t.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(mH=Jn())),n&4&&EG(t);break;case 22:if(d=r!==null&&r.memoizedState!==null,t.mode&1?(Mi=(u=Mi)||d,Il(e,t),Mi=u):Il(e,t),Pc(t),n&8192){if(u=t.memoizedState!==null,(t.stateNode.isHidden=u)&&!d&&t.mode&1)for(mt=t,d=t.child;d!==null;){for(h=mt=d;mt!==null;){switch(f=mt,p=f.child,f.tag){case 0:case 11:case 14:case 15:o_(4,f,f.return);break;case 1:Tv(f,f.return);var m=f.stateNode;if(typeof m.componentWillUnmount=="function"){n=f,r=f.return;try{e=n,m.props=e.memoizedProps,m.state=e.memoizedState,m.componentWillUnmount()}catch(g){$n(n,r,g)}}break;case 5:Tv(f,f.return);break;case 22:if(f.memoizedState!==null){CG(h);continue}}p!==null?(p.return=f,mt=p):CG(h)}d=d.sibling}e:for(d=null,h=t;;){if(h.tag===5){if(d===null){d=h;try{s=h.stateNode,u?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(o=h.stateNode,c=h.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,o.style.display=noe("display",a))}catch(g){$n(t,t.return,g)}}}else if(h.tag===6){if(d===null)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(g){$n(t,t.return,g)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===t)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;d===h&&(d=null),h=h.return}d===h&&(d=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Il(e,t),Pc(t),n&4&&EG(t);break;case 21:break;default:Il(e,t),Pc(t)}}function Pc(t){var e=t.flags;if(e&2){try{e:{for(var r=t.return;r!==null;){if(Cle(r)){var n=r;break e}r=r.return}throw Error(Ye(160))}switch(n.tag){case 5:var s=n.stateNode;n.flags&32&&(B_(s,""),n.flags&=-33);var i=NG(t);c$(t,i,s);break;case 3:case 4:var a=n.stateNode.containerInfo,o=NG(t);l$(t,o,a);break;default:throw Error(Ye(161))}}catch(c){$n(t,t.return,c)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function hCe(t,e,r){mt=t,Ole(t)}function Ole(t,e,r){for(var n=(t.mode&1)!==0;mt!==null;){var s=mt,i=s.child;if(s.tag===22&&n){var a=s.memoizedState!==null||wA;if(!a){var o=s.alternate,c=o!==null&&o.memoizedState!==null||Mi;o=wA;var u=Mi;if(wA=a,(Mi=c)&&!u)for(mt=s;mt!==null;)a=mt,c=a.child,a.tag===22&&a.memoizedState!==null?TG(s):c!==null?(c.return=a,mt=c):TG(s);for(;i!==null;)mt=i,Ole(i),i=i.sibling;mt=s,wA=o,Mi=u}AG(t)}else s.subtreeFlags&8772&&i!==null?(i.return=s,mt=i):AG(t)}}function AG(t){for(;mt!==null;){var e=mt;if(e.flags&8772){var r=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:Mi||VI(5,e);break;case 1:var n=e.stateNode;if(e.flags&4&&!Mi)if(r===null)n.componentDidMount();else{var s=e.elementType===e.type?r.memoizedProps:Ul(e.type,r.memoizedProps);n.componentDidUpdate(s,r.memoizedState,n.__reactInternalSnapshotBeforeUpdate)}var i=e.updateQueue;i!==null&&hG(e,i,n);break;case 3:var a=e.updateQueue;if(a!==null){if(r=null,e.child!==null)switch(e.child.tag){case 5:r=e.child.stateNode;break;case 1:r=e.child.stateNode}hG(e,a,r)}break;case 5:var o=e.stateNode;if(r===null&&e.flags&4){r=o;var c=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&r.focus();break;case"img":c.src&&(r.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var u=e.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var h=d.dehydrated;h!==null&&V_(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ye(163))}Mi||e.flags&512&&o$(e)}catch(f){$n(e,e.return,f)}}if(e===t){mt=null;break}if(r=e.sibling,r!==null){r.return=e.return,mt=r;break}mt=e.return}}function CG(t){for(;mt!==null;){var e=mt;if(e===t){mt=null;break}var r=e.sibling;if(r!==null){r.return=e.return,mt=r;break}mt=e.return}}function TG(t){for(;mt!==null;){var e=mt;try{switch(e.tag){case 0:case 11:case 15:var r=e.return;try{VI(4,e)}catch(c){$n(e,r,c)}break;case 1:var n=e.stateNode;if(typeof n.componentDidMount=="function"){var s=e.return;try{n.componentDidMount()}catch(c){$n(e,s,c)}}var i=e.return;try{o$(e)}catch(c){$n(e,i,c)}break;case 5:var a=e.return;try{o$(e)}catch(c){$n(e,a,c)}}}catch(c){$n(e,e.return,c)}if(e===t){mt=null;break}var o=e.sibling;if(o!==null){o.return=e.return,mt=o;break}mt=e.return}}var fCe=Math.ceil,O2=kh.ReactCurrentDispatcher,fH=kh.ReactCurrentOwner,gl=kh.ReactCurrentBatchConfig,yr=0,Ys=null,cs=null,yi=0,wo=0,Pv=em(0),As=0,tj=null,Vy=0,WI=0,pH=0,l_=null,Da=null,mH=0,U0=1/0,rd=null,I2=!1,u$=null,Sp=null,SA=!1,mp=null,R2=0,c_=0,d$=null,tT=-1,rT=0;function ya(){return yr&6?Jn():tT!==-1?tT:tT=Jn()}function _p(t){return t.mode&1?yr&2&&yi!==0?yi&-yi:XAe.transition!==null?(rT===0&&(rT=goe()),rT):(t=Pr,t!==0||(t=window.event,t=t===void 0?16:_oe(t.type)),t):1}function hc(t,e,r,n){if(50<c_)throw c_=0,d$=null,Error(Ye(185));QN(t,r,n),(!(yr&2)||t!==Ys)&&(t===Ys&&(!(yr&2)&&(WI|=r),As===4&&uf(t,yi)),qa(t,n),r===1&&yr===0&&!(e.mode&1)&&(U0=Jn()+500,zI&&tm()))}function qa(t,e){var r=t.callbackNode;XEe(t,e);var n=y2(t,t===Ys?yi:0);if(n===0)r!==null&&$q(r),t.callbackNode=null,t.callbackPriority=0;else if(e=n&-n,t.callbackPriority!==e){if(r!=null&&$q(r),e===1)t.tag===0?YAe(PG.bind(null,t)):Uoe(PG.bind(null,t)),WAe(function(){!(yr&6)&&tm()}),r=null;else{switch(yoe(n)){case 1:r=zU;break;case 4:r=poe;break;case 16:r=g2;break;case 536870912:r=moe;break;default:r=g2}r=Ble(r,Ile.bind(null,t))}t.callbackPriority=e,t.callbackNode=r}}function Ile(t,e){if(tT=-1,rT=0,yr&6)throw Error(Ye(327));var r=t.callbackNode;if(Jv()&&t.callbackNode!==r)return null;var n=y2(t,t===Ys?yi:0);if(n===0)return null;if(n&30||n&t.expiredLanes||e)e=M2(t,n);else{e=n;var s=yr;yr|=2;var i=Mle();(Ys!==t||yi!==e)&&(rd=null,U0=Jn()+500,Ey(t,e));do try{gCe();break}catch(o){Rle(t,o)}while(!0);eH(),O2.current=i,yr=s,cs!==null?e=0:(Ys=null,yi=0,e=As)}if(e!==0){if(e===2&&(s=FF(t),s!==0&&(n=s,e=h$(t,s))),e===1)throw r=tj,Ey(t,0),uf(t,n),qa(t,Jn()),r;if(e===6)uf(t,n);else{if(s=t.current.alternate,!(n&30)&&!pCe(s)&&(e=M2(t,n),e===2&&(i=FF(t),i!==0&&(n=i,e=h$(t,i))),e===1))throw r=tj,Ey(t,0),uf(t,n),qa(t,Jn()),r;switch(t.finishedWork=s,t.finishedLanes=n,e){case 0:case 1:throw Error(Ye(345));case 2:Im(t,Da,rd);break;case 3:if(uf(t,n),(n&130023424)===n&&(e=mH+500-Jn(),10<e)){if(y2(t,0)!==0)break;if(s=t.suspendedLanes,(s&n)!==n){ya(),t.pingedLanes|=t.suspendedLanes&s;break}t.timeoutHandle=qF(Im.bind(null,t,Da,rd),e);break}Im(t,Da,rd);break;case 4:if(uf(t,n),(n&4194240)===n)break;for(e=t.eventTimes,s=-1;0<n;){var a=31-dc(n);i=1<<a,a=e[a],a>s&&(s=a),n&=~i}if(n=s,n=Jn()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*fCe(n/1960))-n,10<n){t.timeoutHandle=qF(Im.bind(null,t,Da,rd),n);break}Im(t,Da,rd);break;case 5:Im(t,Da,rd);break;default:throw Error(Ye(329))}}}return qa(t,Jn()),t.callbackNode===r?Ile.bind(null,t):null}function h$(t,e){var r=l_;return t.current.memoizedState.isDehydrated&&(Ey(t,e).flags|=256),t=M2(t,e),t!==2&&(e=Da,Da=r,e!==null&&f$(e)),t}function f$(t){Da===null?Da=t:Da.push.apply(Da,t)}function pCe(t){for(var e=t;;){if(e.flags&16384){var r=e.updateQueue;if(r!==null&&(r=r.stores,r!==null))for(var n=0;n<r.length;n++){var s=r[n],i=s.getSnapshot;s=s.value;try{if(!yc(i(),s))return!1}catch{return!1}}}if(r=e.child,e.subtreeFlags&16384&&r!==null)r.return=e,e=r;else{if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function uf(t,e){for(e&=~pH,e&=~WI,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var r=31-dc(e),n=1<<r;t[r]=-1,e&=~n}}function PG(t){if(yr&6)throw Error(Ye(327));Jv();var e=y2(t,0);if(!(e&1))return qa(t,Jn()),null;var r=M2(t,e);if(t.tag!==0&&r===2){var n=FF(t);n!==0&&(e=n,r=h$(t,n))}if(r===1)throw r=tj,Ey(t,0),uf(t,e),qa(t,Jn()),r;if(r===6)throw Error(Ye(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,Im(t,Da,rd),qa(t,Jn()),null}function gH(t,e){var r=yr;yr|=1;try{return t(e)}finally{yr=r,yr===0&&(U0=Jn()+500,zI&&tm())}}function Wy(t){mp!==null&&mp.tag===0&&!(yr&6)&&Jv();var e=yr;yr|=1;var r=gl.transition,n=Pr;try{if(gl.transition=null,Pr=1,t)return t()}finally{Pr=n,gl.transition=r,yr=e,!(yr&6)&&tm()}}function yH(){wo=Pv.current,hn(Pv)}function Ey(t,e){t.finishedWork=null,t.finishedLanes=0;var r=t.timeoutHandle;if(r!==-1&&(t.timeoutHandle=-1,VAe(r)),cs!==null)for(r=cs.return;r!==null;){var n=r;switch(JU(n),n.tag){case 1:n=n.type.childContextTypes,n!=null&&S2();break;case 3:B0(),hn(Va),hn(zi),aH();break;case 5:iH(n);break;case 4:B0();break;case 13:hn(Nn);break;case 19:hn(Nn);break;case 10:tH(n.type._context);break;case 22:case 23:yH()}r=r.return}if(Ys=t,cs=t=jp(t.current,null),yi=wo=e,As=0,tj=null,pH=WI=Vy=0,Da=l_=null,Jm!==null){for(e=0;e<Jm.length;e++)if(r=Jm[e],n=r.interleaved,n!==null){r.interleaved=null;var s=n.next,i=r.pending;if(i!==null){var a=i.next;i.next=s,n.next=a}r.pending=n}Jm=null}return t}function Rle(t,e){do{var r=cs;try{if(eH(),QC.current=P2,T2){for(var n=An.memoizedState;n!==null;){var s=n.queue;s!==null&&(s.pending=null),n=n.next}T2=!1}if(Hy=0,qs=ks=An=null,a_=!1,Q_=0,fH.current=null,r===null||r.return===null){As=1,tj=e,cs=null;break}e:{var i=t,a=r.return,o=r,c=e;if(e=yi,o.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=o,h=d.tag;if(!(d.mode&1)&&(h===0||h===11||h===15)){var f=d.alternate;f?(d.updateQueue=f.updateQueue,d.memoizedState=f.memoizedState,d.lanes=f.lanes):(d.updateQueue=null,d.memoizedState=null)}var p=xG(a);if(p!==null){p.flags&=-257,vG(p,a,o,i,e),p.mode&1&&yG(i,u,e),e=p,c=u;var m=e.updateQueue;if(m===null){var g=new Set;g.add(c),e.updateQueue=g}else m.add(c);break e}else{if(!(e&1)){yG(i,u,e),xH();break e}c=Error(Ye(426))}}else if(wn&&o.mode&1){var x=xG(a);if(x!==null){!(x.flags&65536)&&(x.flags|=256),vG(x,a,o,i,e),QU(z0(c,o));break e}}i=c=z0(c,o),As!==4&&(As=2),l_===null?l_=[i]:l_.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,e&=-e,i.lanes|=e;var y=yle(i,c,e);dG(i,y);break e;case 1:o=c;var v=i.type,b=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(Sp===null||!Sp.has(b)))){i.flags|=65536,e&=-e,i.lanes|=e;var w=xle(i,o,e);dG(i,w);break e}}i=i.return}while(i!==null)}Lle(r)}catch(S){e=S,cs===r&&r!==null&&(cs=r=r.return);continue}break}while(!0)}function Mle(){var t=O2.current;return O2.current=P2,t===null?P2:t}function xH(){(As===0||As===3||As===2)&&(As=4),Ys===null||!(Vy&268435455)&&!(WI&268435455)||uf(Ys,yi)}function M2(t,e){var r=yr;yr|=2;var n=Mle();(Ys!==t||yi!==e)&&(rd=null,Ey(t,e));do try{mCe();break}catch(s){Rle(t,s)}while(!0);if(eH(),yr=r,O2.current=n,cs!==null)throw Error(Ye(261));return Ys=null,yi=0,As}function mCe(){for(;cs!==null;)Dle(cs)}function gCe(){for(;cs!==null&&!zEe();)Dle(cs)}function Dle(t){var e=$le(t.alternate,t,wo);t.memoizedProps=t.pendingProps,e===null?Lle(t):cs=e,fH.current=null}function Lle(t){var e=t;do{var r=e.alternate;if(t=e.return,e.flags&32768){if(r=cCe(r,e),r!==null){r.flags&=32767,cs=r;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{As=6,cs=null;return}}else if(r=lCe(r,e,wo),r!==null){cs=r;return}if(e=e.sibling,e!==null){cs=e;return}cs=e=t}while(e!==null);As===0&&(As=5)}function Im(t,e,r){var n=Pr,s=gl.transition;try{gl.transition=null,Pr=1,yCe(t,e,r,n)}finally{gl.transition=s,Pr=n}return null}function yCe(t,e,r,n){do Jv();while(mp!==null);if(yr&6)throw Error(Ye(327));r=t.finishedWork;var s=t.finishedLanes;if(r===null)return null;if(t.finishedWork=null,t.finishedLanes=0,r===t.current)throw Error(Ye(177));t.callbackNode=null,t.callbackPriority=0;var i=r.lanes|r.childLanes;if(JEe(t,i),t===Ys&&(cs=Ys=null,yi=0),!(r.subtreeFlags&2064)&&!(r.flags&2064)||SA||(SA=!0,Ble(g2,function(){return Jv(),null})),i=(r.flags&15990)!==0,r.subtreeFlags&15990||i){i=gl.transition,gl.transition=null;var a=Pr;Pr=1;var o=yr;yr|=4,fH.current=null,dCe(t,r),Ple(r,t),LAe(VF),x2=!!HF,VF=HF=null,t.current=r,hCe(r),UEe(),yr=o,Pr=a,gl.transition=i}else t.current=r;if(SA&&(SA=!1,mp=t,R2=s),i=t.pendingLanes,i===0&&(Sp=null),WEe(r.stateNode),qa(t,Jn()),e!==null)for(n=t.onRecoverableError,r=0;r<e.length;r++)s=e[r],n(s.value,{componentStack:s.stack,digest:s.digest});if(I2)throw I2=!1,t=u$,u$=null,t;return R2&1&&t.tag!==0&&Jv(),i=t.pendingLanes,i&1?t===d$?c_++:(c_=0,d$=t):c_=0,tm(),null}function Jv(){if(mp!==null){var t=yoe(R2),e=gl.transition,r=Pr;try{if(gl.transition=null,Pr=16>t?16:t,mp===null)var n=!1;else{if(t=mp,mp=null,R2=0,yr&6)throw Error(Ye(331));var s=yr;for(yr|=4,mt=t.current;mt!==null;){var i=mt,a=i.child;if(mt.flags&16){var o=i.deletions;if(o!==null){for(var c=0;c<o.length;c++){var u=o[c];for(mt=u;mt!==null;){var d=mt;switch(d.tag){case 0:case 11:case 15:o_(8,d,i)}var h=d.child;if(h!==null)h.return=d,mt=h;else for(;mt!==null;){d=mt;var f=d.sibling,p=d.return;if(Ale(d),d===u){mt=null;break}if(f!==null){f.return=p,mt=f;break}mt=p}}}var m=i.alternate;if(m!==null){var g=m.child;if(g!==null){m.child=null;do{var x=g.sibling;g.sibling=null,g=x}while(g!==null)}}mt=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,mt=a;else e:for(;mt!==null;){if(i=mt,i.flags&2048)switch(i.tag){case 0:case 11:case 15:o_(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,mt=y;break e}mt=i.return}}var v=t.current;for(mt=v;mt!==null;){a=mt;var b=a.child;if(a.subtreeFlags&2064&&b!==null)b.return=a,mt=b;else e:for(a=v;mt!==null;){if(o=mt,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:VI(9,o)}}catch(S){$n(o,o.return,S)}if(o===a){mt=null;break e}var w=o.sibling;if(w!==null){w.return=o.return,mt=w;break e}mt=o.return}}if(yr=s,tm(),yu&&typeof yu.onPostCommitFiberRoot=="function")try{yu.onPostCommitFiberRoot(DI,t)}catch{}n=!0}return n}finally{Pr=r,gl.transition=e}}return!1}function OG(t,e,r){e=z0(r,e),e=yle(t,e,1),t=wp(t,e,1),e=ya(),t!==null&&(QN(t,1,e),qa(t,e))}function $n(t,e,r){if(t.tag===3)OG(t,t,r);else for(;e!==null;){if(e.tag===3){OG(e,t,r);break}else if(e.tag===1){var n=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Sp===null||!Sp.has(n))){t=z0(r,t),t=xle(e,t,1),e=wp(e,t,1),t=ya(),e!==null&&(QN(e,1,t),qa(e,t));break}}e=e.return}}function xCe(t,e,r){var n=t.pingCache;n!==null&&n.delete(e),e=ya(),t.pingedLanes|=t.suspendedLanes&r,Ys===t&&(yi&r)===r&&(As===4||As===3&&(yi&130023424)===yi&&500>Jn()-mH?Ey(t,0):pH|=r),qa(t,e)}function Fle(t,e){e===0&&(t.mode&1?(e=hA,hA<<=1,!(hA&130023424)&&(hA=4194304)):e=1);var r=ya();t=uh(t,e),t!==null&&(QN(t,e,r),qa(t,r))}function vCe(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),Fle(t,r)}function bCe(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,s=t.memoizedState;s!==null&&(r=s.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(Ye(314))}n!==null&&n.delete(e),Fle(t,r)}var $le;$le=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||Va.current)$a=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return $a=!1,oCe(t,e,r);$a=!!(t.flags&131072)}else $a=!1,wn&&e.flags&1048576&&Hoe(e,k2,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;eT(t,e),t=e.pendingProps;var s=L0(e,zi.current);Xv(e,r),s=lH(null,e,n,t,s,r);var i=cH();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Wa(n)?(i=!0,_2(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,nH(e),s.updater=HI,e.stateNode=s,s._reactInternals=e,ZF(e,n,t,r),e=r$(null,e,n,!0,i,r)):(e.tag=0,wn&&i&&XU(e),ca(null,e,s,r),e=e.child),e;case 16:n=e.elementType;e:{switch(eT(t,e),t=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=SCe(n),t=Ul(n,t),s){case 0:e=t$(null,e,n,t,r);break e;case 1:e=SG(null,e,n,t,r);break e;case 11:e=bG(null,e,n,t,r);break e;case 14:e=wG(null,e,n,Ul(n.type,t),r);break e}throw Error(Ye(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Ul(n,s),t$(t,e,n,s,r);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Ul(n,s),SG(t,e,n,s,r);case 3:e:{if(Sle(e),t===null)throw Error(Ye(387));n=e.pendingProps,i=e.memoizedState,s=i.element,Yoe(t,e),A2(e,n,null,r);var a=e.memoizedState;if(n=a.element,i.isDehydrated)if(i={element:n,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=z0(Error(Ye(423)),e),e=_G(t,e,n,r,s);break e}else if(n!==s){s=z0(Error(Ye(424)),e),e=_G(t,e,n,r,s);break e}else for(Eo=bp(e.stateNode.containerInfo.firstChild),Ao=e,wn=!0,sc=null,r=Goe(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(F0(),n===s){e=dh(t,e,r);break e}ca(t,e,n,r)}e=e.child}return e;case 5:return Xoe(e),t===null&&XF(e),n=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,a=s.children,WF(n,s)?a=null:i!==null&&WF(n,i)&&(e.flags|=32),wle(t,e),ca(t,e,a,r),e.child;case 6:return t===null&&XF(e),null;case 13:return _le(t,e,r);case 4:return sH(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=$0(e,null,n,r):ca(t,e,n,r),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Ul(n,s),bG(t,e,n,s,r);case 7:return ca(t,e,e.pendingProps,r),e.child;case 8:return ca(t,e,e.pendingProps.children,r),e.child;case 12:return ca(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,s=e.pendingProps,i=e.memoizedProps,a=s.value,tn(N2,n._currentValue),n._currentValue=a,i!==null)if(yc(i.value,a)){if(i.children===s.children&&!Va.current){e=dh(t,e,r);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var o=i.dependencies;if(o!==null){a=i.child;for(var c=o.firstContext;c!==null;){if(c.context===n){if(i.tag===1){c=Zd(-1,r&-r),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=r,c=i.alternate,c!==null&&(c.lanes|=r),JF(i.return,r,e),o.lanes|=r;break}c=c.next}}else if(i.tag===10)a=i.type===e.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(Ye(341));a.lanes|=r,o=a.alternate,o!==null&&(o.lanes|=r),JF(a,r,e),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===e){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}ca(t,e,s.children,r),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,Xv(e,r),s=jl(s),n=n(s),e.flags|=1,ca(t,e,n,r),e.child;case 14:return n=e.type,s=Ul(n,e.pendingProps),s=Ul(n.type,s),wG(t,e,n,s,r);case 15:return vle(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:Ul(n,s),eT(t,e),e.tag=1,Wa(n)?(t=!0,_2(e)):t=!1,Xv(e,r),gle(e,n,s),ZF(e,n,s,r),r$(null,e,n,!0,t,r);case 19:return jle(t,e,r);case 22:return ble(t,e,r)}throw Error(Ye(156,e.tag))};function Ble(t,e){return foe(t,e)}function wCe(t,e,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function dl(t,e,r,n){return new wCe(t,e,r,n)}function vH(t){return t=t.prototype,!(!t||!t.isReactComponent)}function SCe(t){if(typeof t=="function")return vH(t)?1:0;if(t!=null){if(t=t.$$typeof,t===FU)return 11;if(t===$U)return 14}return 2}function jp(t,e){var r=t.alternate;return r===null?(r=dl(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function nT(t,e,r,n,s,i){var a=2;if(n=t,typeof t=="function")vH(t)&&(a=1);else if(typeof t=="string")a=5;else e:switch(t){case wv:return Ay(r.children,s,i,e);case LU:a=8,s|=8;break;case _F:return t=dl(12,r,e,s|2),t.elementType=_F,t.lanes=i,t;case jF:return t=dl(13,r,e,s),t.elementType=jF,t.lanes=i,t;case kF:return t=dl(19,r,e,s),t.elementType=kF,t.lanes=i,t;case Xae:return qI(r,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Kae:a=10;break e;case Yae:a=9;break e;case FU:a=11;break e;case $U:a=14;break e;case rf:a=16,n=null;break e}throw Error(Ye(130,t==null?t:typeof t,""))}return e=dl(a,r,e,s),e.elementType=t,e.type=n,e.lanes=i,e}function Ay(t,e,r,n){return t=dl(7,t,n,e),t.lanes=r,t}function qI(t,e,r,n){return t=dl(22,t,n,e),t.elementType=Xae,t.lanes=r,t.stateNode={isHidden:!1},t}function ZD(t,e,r){return t=dl(6,t,null,e),t.lanes=r,t}function eL(t,e,r){return e=dl(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function _Ce(t,e,r,n,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=RD(0),this.expirationTimes=RD(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=RD(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function bH(t,e,r,n,s,i,a,o,c){return t=new _Ce(t,e,r,o,c),e===1?(e=1,i===!0&&(e|=8)):e=0,i=dl(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},nH(i),t}function jCe(t,e,r){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:bv,key:n==null?null:""+n,children:t,containerInfo:e,implementation:r}}function zle(t){if(!t)return Lp;t=t._reactInternals;e:{if(px(t)!==t||t.tag!==1)throw Error(Ye(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(Wa(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(Ye(171))}if(t.tag===1){var r=t.type;if(Wa(r))return zoe(t,r,e)}return e}function Ule(t,e,r,n,s,i,a,o,c){return t=bH(r,n,!0,t,s,i,a,o,c),t.context=zle(null),r=t.current,n=ya(),s=_p(r),i=Zd(n,s),i.callback=e??null,wp(r,i,s),t.current.lanes=s,QN(t,s,n),qa(t,n),t}function GI(t,e,r,n){var s=e.current,i=ya(),a=_p(s);return r=zle(r),e.context===null?e.context=r:e.pendingContext=r,e=Zd(i,a),e.payload={element:t},n=n===void 0?null:n,n!==null&&(e.callback=n),t=wp(s,e,a),t!==null&&(hc(t,s,a,i),JC(t,s,a)),a}function D2(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function IG(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<e?r:e}}function wH(t,e){IG(t,e),(t=t.alternate)&&IG(t,e)}function kCe(){return null}var Hle=typeof reportError=="function"?reportError:function(t){console.error(t)};function SH(t){this._internalRoot=t}KI.prototype.render=SH.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(Ye(409));GI(t,e,null,null)};KI.prototype.unmount=SH.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;Wy(function(){GI(null,t,null,null)}),e[ch]=null}};function KI(t){this._internalRoot=t}KI.prototype.unstable_scheduleHydration=function(t){if(t){var e=boe();t={blockedOn:null,target:t,priority:e};for(var r=0;r<cf.length&&e!==0&&e<cf[r].priority;r++);cf.splice(r,0,t),r===0&&Soe(t)}};function _H(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function YI(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function RG(){}function NCe(t,e,r,n,s){if(s){if(typeof n=="function"){var i=n;n=function(){var u=D2(a);i.call(u)}}var a=Ule(e,n,t,0,null,!1,!1,"",RG);return t._reactRootContainer=a,t[ch]=a.current,G_(t.nodeType===8?t.parentNode:t),Wy(),a}for(;s=t.lastChild;)t.removeChild(s);if(typeof n=="function"){var o=n;n=function(){var u=D2(c);o.call(u)}}var c=bH(t,0,!1,null,null,!1,!1,"",RG);return t._reactRootContainer=c,t[ch]=c.current,G_(t.nodeType===8?t.parentNode:t),Wy(function(){GI(e,c,r,n)}),c}function XI(t,e,r,n,s){var i=r._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var o=s;s=function(){var c=D2(a);o.call(c)}}GI(e,a,t,s)}else a=NCe(r,e,t,s,n);return D2(a)}xoe=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var r=iS(e.pendingLanes);r!==0&&(UU(e,r|1),qa(e,Jn()),!(yr&6)&&(U0=Jn()+500,tm()))}break;case 13:Wy(function(){var n=uh(t,1);if(n!==null){var s=ya();hc(n,t,1,s)}}),wH(t,1)}};HU=function(t){if(t.tag===13){var e=uh(t,134217728);if(e!==null){var r=ya();hc(e,t,134217728,r)}wH(t,134217728)}};voe=function(t){if(t.tag===13){var e=_p(t),r=uh(t,e);if(r!==null){var n=ya();hc(r,t,e,n)}wH(t,e)}};boe=function(){return Pr};woe=function(t,e){var r=Pr;try{return Pr=t,e()}finally{Pr=r}};MF=function(t,e,r){switch(e){case"input":if(AF(t,r),e=r.name,r.type==="radio"&&e!=null){for(r=t;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<r.length;e++){var n=r[e];if(n!==t&&n.form===t.form){var s=BI(n);if(!s)throw Error(Ye(90));Qae(n),AF(n,s)}}}break;case"textarea":eoe(t,r);break;case"select":e=r.value,e!=null&&qv(t,!!r.multiple,e,!1)}};ooe=gH;loe=Wy;var ECe={usingClientEntryPoint:!1,Events:[eE,kv,BI,ioe,aoe,gH]},j1={findFiberByHostInstance:Xm,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ACe={bundleType:j1.bundleType,version:j1.version,rendererPackageName:j1.rendererPackageName,rendererConfig:j1.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:kh.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=doe(t),t===null?null:t.stateNode},findFiberByHostInstance:j1.findFiberByHostInstance||kCe,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var _A=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_A.isDisabled&&_A.supportsFiber)try{DI=_A.inject(ACe),yu=_A}catch{}}Io.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ECe;Io.createPortal=function(t,e){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!_H(e))throw Error(Ye(200));return jCe(t,e,null,r)};Io.createRoot=function(t,e){if(!_H(t))throw Error(Ye(299));var r=!1,n="",s=Hle;return e!=null&&(e.unstable_strictMode===!0&&(r=!0),e.identifierPrefix!==void 0&&(n=e.identifierPrefix),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=bH(t,1,!1,null,null,r,!1,n,s),t[ch]=e.current,G_(t.nodeType===8?t.parentNode:t),new SH(e)};Io.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var e=t._reactInternals;if(e===void 0)throw typeof t.render=="function"?Error(Ye(188)):(t=Object.keys(t).join(","),Error(Ye(268,t)));return t=doe(e),t=t===null?null:t.stateNode,t};Io.flushSync=function(t){return Wy(t)};Io.hydrate=function(t,e,r){if(!YI(e))throw Error(Ye(200));return XI(null,t,e,!0,r)};Io.hydrateRoot=function(t,e,r){if(!_H(t))throw Error(Ye(405));var n=r!=null&&r.hydratedSources||null,s=!1,i="",a=Hle;if(r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(i=r.identifierPrefix),r.onRecoverableError!==void 0&&(a=r.onRecoverableError)),e=Ule(e,null,t,1,r??null,s,!1,i,a),t[ch]=e.current,G_(t),n)for(t=0;t<n.length;t++)r=n[t],s=r._getVersion,s=s(r._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[r,s]:e.mutableSourceEagerHydrationData.push(r,s);return new KI(e)};Io.render=function(t,e,r){if(!YI(e))throw Error(Ye(200));return XI(null,t,e,!1,r)};Io.unmountComponentAtNode=function(t){if(!YI(t))throw Error(Ye(40));return t._reactRootContainer?(Wy(function(){XI(null,null,t,!1,function(){t._reactRootContainer=null,t[ch]=null})}),!0):!1};Io.unstable_batchedUpdates=gH;Io.unstable_renderSubtreeIntoContainer=function(t,e,r,n){if(!YI(r))throw Error(Ye(200));if(t==null||t._reactInternals===void 0)throw Error(Ye(38));return XI(t,e,r,!1,n)};Io.version="18.3.1-next-f1338f8080-20240426";function Vle(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Vle)}catch(t){console.error(t)}}Vle(),Vae.exports=Io;var Iu=Vae.exports;const jH=cr(Iu);var Wle,MG=Iu;Wle=MG.createRoot,MG.hydrateRoot;var CCe=typeof Element<"u",TCe=typeof Map=="function",PCe=typeof Set=="function",OCe=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function sT(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;var r,n,s;if(Array.isArray(t)){if(r=t.length,r!=e.length)return!1;for(n=r;n--!==0;)if(!sT(t[n],e[n]))return!1;return!0}var i;if(TCe&&t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(i=t.entries();!(n=i.next()).done;)if(!e.has(n.value[0]))return!1;for(i=t.entries();!(n=i.next()).done;)if(!sT(n.value[1],e.get(n.value[0])))return!1;return!0}if(PCe&&t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(i=t.entries();!(n=i.next()).done;)if(!e.has(n.value[0]))return!1;return!0}if(OCe&&ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(r=t.length,r!=e.length)return!1;for(n=r;n--!==0;)if(t[n]!==e[n])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf&&typeof t.valueOf=="function"&&typeof e.valueOf=="function")return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString&&typeof t.toString=="function"&&typeof e.toString=="function")return t.toString()===e.toString();if(s=Object.keys(t),r=s.length,r!==Object.keys(e).length)return!1;for(n=r;n--!==0;)if(!Object.prototype.hasOwnProperty.call(e,s[n]))return!1;if(CCe&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((s[n]==="_owner"||s[n]==="__v"||s[n]==="__o")&&t.$$typeof)&&!sT(t[s[n]],e[s[n]]))return!1;return!0}return t!==t&&e!==e}var ICe=function(e,r){try{return sT(e,r)}catch(n){if((n.message||"").match(/stack|recursion/i))return console.warn("react-fast-compare cannot handle circular refs"),!1;throw n}};const RCe=cr(ICe);var MCe=function(t,e,r,n,s,i,a,o){if(!t){var c;if(e===void 0)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[r,n,s,i,a,o],d=0;c=new Error(e.replace(/%s/g,function(){return u[d++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}},DCe=MCe;const DG=cr(DCe);var LCe=function(e,r,n,s){var i=n?n.call(s,e,r):void 0;if(i!==void 0)return!!i;if(e===r)return!0;if(typeof e!="object"||!e||typeof r!="object"||!r)return!1;var a=Object.keys(e),o=Object.keys(r);if(a.length!==o.length)return!1;for(var c=Object.prototype.hasOwnProperty.bind(r),u=0;u<a.length;u++){var d=a[u];if(!c(d))return!1;var h=e[d],f=r[d];if(i=n?n.call(s,h,f,d):void 0,i===!1||i===void 0&&h!==f)return!1}return!0};const FCe=cr(LCe);var qle=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(qle||{}),tL={link:{rel:["amphtml","canonical","alternate"]},script:{type:["application/ld+json"]},meta:{charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]}},LG=Object.values(qle),kH={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},$Ce=Object.entries(kH).reduce((t,[e,r])=>(t[r]=e,t),{}),cc="data-rh",Qv={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},Zv=(t,e)=>{for(let r=t.length-1;r>=0;r-=1){const n=t[r];if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}return null},BCe=t=>{let e=Zv(t,"title");const r=Zv(t,Qv.TITLE_TEMPLATE);if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,()=>e);const n=Zv(t,Qv.DEFAULT_TITLE);return e||n||void 0},zCe=t=>Zv(t,Qv.ON_CHANGE_CLIENT_STATE)||(()=>{}),rL=(t,e)=>e.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),UCe=(t,e)=>e.filter(r=>typeof r.base<"u").map(r=>r.base).reverse().reduce((r,n)=>{if(!r.length){const s=Object.keys(n);for(let i=0;i<s.length;i+=1){const o=s[i].toLowerCase();if(t.indexOf(o)!==-1&&n[o])return r.concat(n)}}return r},[]),HCe=t=>console&&typeof console.warn=="function"&&console.warn(t),k1=(t,e,r)=>{const n={};return r.filter(s=>Array.isArray(s[t])?!0:(typeof s[t]<"u"&&HCe(`Helmet: ${t} should be of type "Array". Instead found type "${typeof s[t]}"`),!1)).map(s=>s[t]).reverse().reduce((s,i)=>{const a={};i.filter(c=>{let u;const d=Object.keys(c);for(let f=0;f<d.length;f+=1){const p=d[f],m=p.toLowerCase();e.indexOf(m)!==-1&&!(u==="rel"&&c[u].toLowerCase()==="canonical")&&!(m==="rel"&&c[m].toLowerCase()==="stylesheet")&&(u=m),e.indexOf(p)!==-1&&(p==="innerHTML"||p==="cssText"||p==="itemprop")&&(u=p)}if(!u||!c[u])return!1;const h=c[u].toLowerCase();return n[u]||(n[u]={}),a[u]||(a[u]={}),n[u][h]?!1:(a[u][h]=!0,!0)}).reverse().forEach(c=>s.push(c));const o=Object.keys(a);for(let c=0;c<o.length;c+=1){const u=o[c],d={...n[u],...a[u]};n[u]=d}return s},[]).reverse()},VCe=(t,e)=>{if(Array.isArray(t)&&t.length){for(let r=0;r<t.length;r+=1)if(t[r][e])return!0}return!1},WCe=t=>({baseTag:UCe(["href"],t),bodyAttributes:rL("bodyAttributes",t),defer:Zv(t,Qv.DEFER),encode:Zv(t,Qv.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:rL("htmlAttributes",t),linkTags:k1("link",["rel","href"],t),metaTags:k1("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:k1("noscript",["innerHTML"],t),onChangeClientState:zCe(t),scriptTags:k1("script",["src","innerHTML"],t),styleTags:k1("style",["cssText"],t),title:BCe(t),titleAttributes:rL("titleAttributes",t),prioritizeSeoTags:VCe(t,Qv.PRIORITIZE_SEO_TAGS)}),Gle=t=>Array.isArray(t)?t.join(""):t,qCe=(t,e)=>{const r=Object.keys(t);for(let n=0;n<r.length;n+=1)if(e[r[n]]&&e[r[n]].includes(t[r[n]]))return!0;return!1},nL=(t,e)=>Array.isArray(t)?t.reduce((r,n)=>(qCe(n,e)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},FG=(t,e)=>({...t,[e]:void 0}),GCe=["noscript","script","style"],p$=(t,e=!0)=>e===!1?String(t):String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),Kle=t=>Object.keys(t).reduce((e,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return e?`${e} ${n}`:n},""),KCe=(t,e,r,n)=>{const s=Kle(r),i=Gle(e);return s?`<${t} ${cc}="true" ${s}>${p$(i,n)}</${t}>`:`<${t} ${cc}="true">${p$(i,n)}</${t}>`},YCe=(t,e,r=!0)=>e.reduce((n,s)=>{const i=s,a=Object.keys(i).filter(u=>!(u==="innerHTML"||u==="cssText")).reduce((u,d)=>{const h=typeof i[d]>"u"?d:`${d}="${p$(i[d],r)}"`;return u?`${u} ${h}`:h},""),o=i.innerHTML||i.cssText||"",c=GCe.indexOf(t)===-1;return`${n}<${t} ${cc}="true" ${a}${c?"/>":`>${o}</${t}>`}`},""),Yle=(t,e={})=>Object.keys(t).reduce((r,n)=>{const s=kH[n];return r[s||n]=t[n],r},e),XCe=(t,e,r)=>{const n={key:e,[cc]:!0},s=Yle(r,n);return[pe.createElement("title",s,e)]},iT=(t,e)=>e.map((r,n)=>{const s={key:n,[cc]:!0};return Object.keys(r).forEach(i=>{const o=kH[i]||i;if(o==="innerHTML"||o==="cssText"){const c=r.innerHTML||r.cssText;s.dangerouslySetInnerHTML={__html:c}}else s[o]=r[i]}),pe.createElement(t,s)}),Wo=(t,e,r=!0)=>{switch(t){case"title":return{toComponent:()=>XCe(t,e.title,e.titleAttributes),toString:()=>KCe(t,e.title,e.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>Yle(e),toString:()=>Kle(e)};default:return{toComponent:()=>iT(t,e),toString:()=>YCe(t,e,r)}}},JCe=({metaTags:t,linkTags:e,scriptTags:r,encode:n})=>{const s=nL(t,tL.meta),i=nL(e,tL.link),a=nL(r,tL.script);return{priorityMethods:{toComponent:()=>[...iT("meta",s.priority),...iT("link",i.priority),...iT("script",a.priority)],toString:()=>`${Wo("meta",s.priority,n)} ${Wo("link",i.priority,n)} ${Wo("script",a.priority,n)}`},metaTags:s.default,linkTags:i.default,scriptTags:a.default}},QCe=t=>{const{baseTag:e,bodyAttributes:r,encode:n=!0,htmlAttributes:s,noscriptTags:i,styleTags:a,title:o="",titleAttributes:c,prioritizeSeoTags:u}=t;let{linkTags:d,metaTags:h,scriptTags:f}=t,p={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:p,linkTags:d,metaTags:h,scriptTags:f}=JCe(t)),{priority:p,base:Wo("base",e,n),bodyAttributes:Wo("bodyAttributes",r,n),htmlAttributes:Wo("htmlAttributes",s,n),link:Wo("link",d,n),meta:Wo("meta",h,n),noscript:Wo("noscript",i,n),script:Wo("script",f,n),style:Wo("style",a,n),title:Wo("title",{title:o,titleAttributes:c},n)}},m$=QCe,jA=[],Xle=!!(typeof window<"u"&&window.document&&window.document.createElement),g$=class{constructor(t,e){Ve(this,"instances",[]);Ve(this,"canUseDOM",Xle);Ve(this,"context");Ve(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?jA:this.instances,add:t=>{(this.canUseDOM?jA:this.instances).push(t)},remove:t=>{const e=(this.canUseDOM?jA:this.instances).indexOf(t);(this.canUseDOM?jA:this.instances).splice(e,1)}}});this.context=t,this.canUseDOM=e||!1,e||(t.helmet=m$({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},ZCe={},Jle=pe.createContext(ZCe),hg,Qle=(hg=class extends j.Component{constructor(r){super(r);Ve(this,"helmetData");this.helmetData=new g$(this.props.context||{},hg.canUseDOM)}render(){return pe.createElement(Jle.Provider,{value:this.helmetData.value},this.props.children)}},Ve(hg,"canUseDOM",Xle),hg),Rx=(t,e)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${cc}]`),s=[].slice.call(n),i=[];let a;return e&&e.length&&e.forEach(o=>{const c=document.createElement(t);for(const u in o)if(Object.prototype.hasOwnProperty.call(o,u))if(u==="innerHTML")c.innerHTML=o.innerHTML;else if(u==="cssText")c.styleSheet?c.styleSheet.cssText=o.cssText:c.appendChild(document.createTextNode(o.cssText));else{const d=u,h=typeof o[d]>"u"?"":o[d];c.setAttribute(u,h)}c.setAttribute(cc,"true"),s.some((u,d)=>(a=d,c.isEqualNode(u)))?s.splice(a,1):i.push(c)}),s.forEach(o=>{var c;return(c=o.parentNode)==null?void 0:c.removeChild(o)}),i.forEach(o=>r.appendChild(o)),{oldTags:s,newTags:i}},y$=(t,e)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(cc),s=n?n.split(","):[],i=[...s],a=Object.keys(e);for(const o of a){const c=e[o]||"";r.getAttribute(o)!==c&&r.setAttribute(o,c),s.indexOf(o)===-1&&s.push(o);const u=i.indexOf(o);u!==-1&&i.splice(u,1)}for(let o=i.length-1;o>=0;o-=1)r.removeAttribute(i[o]);s.length===i.length?r.removeAttribute(cc):r.getAttribute(cc)!==a.join(",")&&r.setAttribute(cc,a.join(","))},eTe=(t,e)=>{typeof t<"u"&&document.title!==t&&(document.title=Gle(t)),y$("title",e)},$G=(t,e)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:s,linkTags:i,metaTags:a,noscriptTags:o,onChangeClientState:c,scriptTags:u,styleTags:d,title:h,titleAttributes:f}=t;y$("body",n),y$("html",s),eTe(h,f);const p={baseTag:Rx("base",r),linkTags:Rx("link",i),metaTags:Rx("meta",a),noscriptTags:Rx("noscript",o),scriptTags:Rx("script",u),styleTags:Rx("style",d)},m={},g={};Object.keys(p).forEach(x=>{const{newTags:y,oldTags:v}=p[x];y.length&&(m[x]=y),v.length&&(g[x]=p[x].oldTags)}),e&&e(),c(t,m,g)},N1=null,tTe=t=>{N1&&cancelAnimationFrame(N1),t.defer?N1=requestAnimationFrame(()=>{$G(t,()=>{N1=null})}):($G(t),N1=null)},rTe=tTe,BG=class extends j.Component{constructor(){super(...arguments);Ve(this,"rendered",!1)}shouldComponentUpdate(e){return!FCe(e,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:e}=this.props.context;e.remove(this),this.emitChange()}emitChange(){const{helmetInstances:e,setHelmet:r}=this.props.context;let n=null;const s=WCe(e.get().map(i=>{const a={...i.props};return delete a.context,a}));Qle.canUseDOM?rTe(s):m$&&(n=m$(s)),r(n)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:e}=this.props.context;e.add(this),this.emitChange()}render(){return this.init(),null}},wF,Zle=(wF=class extends j.Component{shouldComponentUpdate(t){return!RCe(FG(this.props,"helmetData"),FG(t,"helmetData"))}mapNestedChildrenToProps(t,e){if(!e)return null;switch(t.type){case"script":case"noscript":return{innerHTML:e};case"style":return{cssText:e};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,e,r,n){return{...e,[t.type]:[...e[t.type]||[],{...r,...this.mapNestedChildrenToProps(t,n)}]}}mapObjectTypeChildren(t,e,r,n){switch(t.type){case"title":return{...e,[t.type]:n,titleAttributes:{...r}};case"body":return{...e,bodyAttributes:{...r}};case"html":return{...e,htmlAttributes:{...r}};default:return{...e,[t.type]:{...r}}}}mapArrayTypeChildrenToProps(t,e){let r={...e};return Object.keys(t).forEach(n=>{r={...r,[n]:t[n]}}),r}warnOnInvalidChildren(t,e){return DG(LG.some(r=>t.type===r),typeof t.type=="function"?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${LG.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),DG(!e||typeof e=="string"||Array.isArray(e)&&!e.some(r=>typeof r!="string"),`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`}</${t.type}> ) Refer to our API for more information.`),!0}mapChildrenToProps(t,e){let r={};return pe.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:s,...i}=n.props,a=Object.keys(i).reduce((c,u)=>(c[$Ce[u]||u]=i[u],c),{});let{type:o}=n;switch(typeof o=="symbol"?o=o.toString():this.warnOnInvalidChildren(n,s),o){case"Symbol(react.fragment)":e=this.mapChildrenToProps(s,e);break;case"link":case"meta":case"noscript":case"script":case"style":r=this.flattenArrayTypeChildren(n,r,a,s);break;default:e=this.mapObjectTypeChildren(n,e,a,s);break}}),this.mapArrayTypeChildrenToProps(r,e)}render(){const{children:t,...e}=this.props;let r={...e},{helmetData:n}=e;if(t&&(r=this.mapChildrenToProps(t,r)),n&&!(n instanceof g$)){const s=n;n=new g$(s.context,!0),delete r.helmetData}return n?pe.createElement(BG,{...r,context:n.value}):pe.createElement(Jle.Consumer,null,s=>pe.createElement(BG,{...r,context:s}))}},Ve(wF,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),wF);const nTe=1,sTe=1e6;let sL=0;function iTe(){return sL=(sL+1)%Number.MAX_SAFE_INTEGER,sL.toString()}const iL=new Map,zG=t=>{if(iL.has(t))return;const e=setTimeout(()=>{iL.delete(t),u_({type:"REMOVE_TOAST",toastId:t})},sTe);iL.set(t,e)},aTe=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,nTe)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(r=>r.id===e.toast.id?{...r,...e.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=e;return r?zG(r):t.toasts.forEach(n=>{zG(n.id)}),{...t,toasts:t.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(r=>r.id!==e.toastId)}}},aT=[];let oT={toasts:[]};function u_(t){oT=aTe(oT,t),aT.forEach(e=>{e(oT)})}function er({...t}){const e=iTe(),r=s=>u_({type:"UPDATE_TOAST",toast:{...s,id:e}}),n=()=>u_({type:"DISMISS_TOAST",toastId:e});return u_({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:s=>{s||n()}}}),{id:e,dismiss:n,update:r}}function qn(){const[t,e]=j.useState(oT);return j.useEffect(()=>(aT.push(e),()=>{const r=aT.indexOf(e);r>-1&&aT.splice(r,1)}),[t]),{...t,toast:er,dismiss:r=>u_({type:"DISMISS_TOAST",toastId:r})}}function Ke(t,e,{checkForDefaultPrevented:r=!0}={}){return function(s){if(t==null||t(s),r===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}function UG(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function JI(...t){return e=>{let r=!1;const n=t.map(s=>{const i=UG(s,e);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let s=0;s<n.length;s++){const i=n[s];typeof i=="function"?i():UG(t[s],null)}}}}function It(...t){return j.useCallback(JI(...t),t)}function oTe(t,e){const r=j.createContext(e),n=i=>{const{children:a,...o}=i,c=j.useMemo(()=>o,Object.values(o));return l.jsx(r.Provider,{value:c,children:a})};n.displayName=t+"Provider";function s(i){const a=j.useContext(r);if(a)return a;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[n,s]}function gs(t,e=[]){let r=[];function n(i,a){const o=j.createContext(a),c=r.length;r=[...r,a];const u=h=>{var y;const{scope:f,children:p,...m}=h,g=((y=f==null?void 0:f[t])==null?void 0:y[c])||o,x=j.useMemo(()=>m,Object.values(m));return l.jsx(g.Provider,{value:x,children:p})};u.displayName=i+"Provider";function d(h,f){var g;const p=((g=f==null?void 0:f[t])==null?void 0:g[c])||o,m=j.useContext(p);if(m)return m;if(a!==void 0)return a;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[u,d]}const s=()=>{const i=r.map(a=>j.createContext(a));return function(o){const c=(o==null?void 0:o[t])||i;return j.useMemo(()=>({[`__scope${t}`]:{...o,[t]:c}}),[o,c])}};return s.scopeName=t,[n,lTe(s,...e)]}function lTe(...t){const e=t[0];if(t.length===1)return e;const r=()=>{const n=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(i){const a=n.reduce((o,{useScope:c,scopeName:u})=>{const h=c(i)[`__scope${u}`];return{...o,...h}},{});return j.useMemo(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return r.scopeName=e.scopeName,r}function Fp(t){const e=uTe(t),r=j.forwardRef((n,s)=>{const{children:i,...a}=n,o=j.Children.toArray(i),c=o.find(dTe);if(c){const u=c.props.children,d=o.map(h=>h===c?j.Children.count(u)>1?j.Children.only(null):j.isValidElement(u)?u.props.children:null:h);return l.jsx(e,{...a,ref:s,children:j.isValidElement(u)?j.cloneElement(u,void 0,d):null})}return l.jsx(e,{...a,ref:s,children:i})});return r.displayName=`${t}.Slot`,r}var cTe=Fp("Slot");function uTe(t){const e=j.forwardRef((r,n)=>{const{children:s,...i}=r;if(j.isValidElement(s)){const a=fTe(s),o=hTe(i,s.props);return s.type!==j.Fragment&&(o.ref=n?JI(n,a):a),j.cloneElement(s,o)}return j.Children.count(s)>1?j.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var ece=Symbol("radix.slottable");function tce(t){const e=({children:r})=>l.jsx(l.Fragment,{children:r});return e.displayName=`${t}.Slottable`,e.__radixId=ece,e}function dTe(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===ece}function hTe(t,e){const r={...e};for(const n in e){const s=t[n],i=e[n];/^on[A-Z]/.test(n)?s&&i?r[n]=(...o)=>{const c=i(...o);return s(...o),c}:s&&(r[n]=s):n==="style"?r[n]={...s,...i}:n==="className"&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...t,...r}}function fTe(t){var n,s;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function rE(t){const e=t+"CollectionProvider",[r,n]=gs(e),[s,i]=r(e,{collectionRef:{current:null},itemMap:new Map}),a=g=>{const{scope:x,children:y}=g,v=pe.useRef(null),b=pe.useRef(new Map).current;return l.jsx(s,{scope:x,itemMap:b,collectionRef:v,children:y})};a.displayName=e;const o=t+"CollectionSlot",c=Fp(o),u=pe.forwardRef((g,x)=>{const{scope:y,children:v}=g,b=i(o,y),w=It(x,b.collectionRef);return l.jsx(c,{ref:w,children:v})});u.displayName=o;const d=t+"CollectionItemSlot",h="data-radix-collection-item",f=Fp(d),p=pe.forwardRef((g,x)=>{const{scope:y,children:v,...b}=g,w=pe.useRef(null),S=It(x,w),k=i(d,y);return pe.useEffect(()=>(k.itemMap.set(w,{ref:w,...b}),()=>void k.itemMap.delete(w))),l.jsx(f,{[h]:"",ref:S,children:v})});p.displayName=d;function m(g){const x=i(t+"CollectionConsumer",g);return pe.useCallback(()=>{const v=x.collectionRef.current;if(!v)return[];const b=Array.from(v.querySelectorAll(`[${h}]`));return Array.from(x.itemMap.values()).sort((k,E)=>b.indexOf(k.ref.current)-b.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:a,Slot:u,ItemSlot:p},m,n]}var pTe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ot=pTe.reduce((t,e)=>{const r=Fp(`Primitive.${e}`),n=j.forwardRef((s,i)=>{const{asChild:a,...o}=s,c=a?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...o,ref:i})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function NH(t,e){t&&Iu.flushSync(()=>t.dispatchEvent(e))}function Hn(t){const e=j.useRef(t);return j.useEffect(()=>{e.current=t}),j.useMemo(()=>(...r)=>{var n;return(n=e.current)==null?void 0:n.call(e,...r)},[])}function mTe(t,e=globalThis==null?void 0:globalThis.document){const r=Hn(t);j.useEffect(()=>{const n=s=>{s.key==="Escape"&&r(s)};return e.addEventListener("keydown",n,{capture:!0}),()=>e.removeEventListener("keydown",n,{capture:!0})},[r,e])}var gTe="DismissableLayer",x$="dismissableLayer.update",yTe="dismissableLayer.pointerDownOutside",xTe="dismissableLayer.focusOutside",HG,rce=j.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),mx=j.forwardRef((t,e)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,onDismiss:o,...c}=t,u=j.useContext(rce),[d,h]=j.useState(null),f=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=j.useState({}),m=It(e,E=>h(E)),g=Array.from(u.layers),[x]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=g.indexOf(x),v=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,w=v>=y,S=bTe(E=>{const C=E.target,A=[...u.branches].some(M=>M.contains(C));!w||A||(s==null||s(E),a==null||a(E),E.defaultPrevented||o==null||o())},f),k=wTe(E=>{const C=E.target;[...u.branches].some(M=>M.contains(C))||(i==null||i(E),a==null||a(E),E.defaultPrevented||o==null||o())},f);return mTe(E=>{v===u.layers.size-1&&(n==null||n(E),!E.defaultPrevented&&o&&(E.preventDefault(),o()))},f),j.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(HG=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),VG(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=HG)}},[d,f,r,u]),j.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),VG())},[d,u]),j.useEffect(()=>{const E=()=>p({});return document.addEventListener(x$,E),()=>document.removeEventListener(x$,E)},[]),l.jsx(ot.div,{...c,ref:m,style:{pointerEvents:b?w?"auto":"none":void 0,...t.style},onFocusCapture:Ke(t.onFocusCapture,k.onFocusCapture),onBlurCapture:Ke(t.onBlurCapture,k.onBlurCapture),onPointerDownCapture:Ke(t.onPointerDownCapture,S.onPointerDownCapture)})});mx.displayName=gTe;var vTe="DismissableLayerBranch",nce=j.forwardRef((t,e)=>{const r=j.useContext(rce),n=j.useRef(null),s=It(e,n);return j.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),l.jsx(ot.div,{...t,ref:s})});nce.displayName=vTe;function bTe(t,e=globalThis==null?void 0:globalThis.document){const r=Hn(t),n=j.useRef(!1),s=j.useRef(()=>{});return j.useEffect(()=>{const i=o=>{if(o.target&&!n.current){let c=function(){sce(yTe,r,u,{discrete:!0})};const u={originalEvent:o};o.pointerType==="touch"?(e.removeEventListener("click",s.current),s.current=c,e.addEventListener("click",s.current,{once:!0})):c()}else e.removeEventListener("click",s.current);n.current=!1},a=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),e.removeEventListener("pointerdown",i),e.removeEventListener("click",s.current)}},[e,r]),{onPointerDownCapture:()=>n.current=!0}}function wTe(t,e=globalThis==null?void 0:globalThis.document){const r=Hn(t),n=j.useRef(!1);return j.useEffect(()=>{const s=i=>{i.target&&!n.current&&sce(xTe,r,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function VG(){const t=new CustomEvent(x$);document.dispatchEvent(t)}function sce(t,e,r,{discrete:n}){const s=r.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});e&&s.addEventListener(t,e,{once:!0}),n?NH(s,i):s.dispatchEvent(i)}var STe=mx,_Te=nce,Wn=globalThis!=null&&globalThis.document?j.useLayoutEffect:()=>{},jTe="Portal",Fw=j.forwardRef((t,e)=>{var o;const{container:r,...n}=t,[s,i]=j.useState(!1);Wn(()=>i(!0),[]);const a=r||s&&((o=globalThis==null?void 0:globalThis.document)==null?void 0:o.body);return a?jH.createPortal(l.jsx(ot.div,{...n,ref:e}),a):null});Fw.displayName=jTe;function kTe(t,e){return j.useReducer((r,n)=>e[r][n]??r,t)}var Os=t=>{const{present:e,children:r}=t,n=NTe(e),s=typeof r=="function"?r({present:n.isPresent}):j.Children.only(r),i=It(n.ref,ETe(s));return typeof r=="function"||n.isPresent?j.cloneElement(s,{ref:i}):null};Os.displayName="Presence";function NTe(t){const[e,r]=j.useState(),n=j.useRef(null),s=j.useRef(t),i=j.useRef("none"),a=t?"mounted":"unmounted",[o,c]=kTe(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return j.useEffect(()=>{const u=kA(n.current);i.current=o==="mounted"?u:"none"},[o]),Wn(()=>{const u=n.current,d=s.current;if(d!==t){const f=i.current,p=kA(u);t?c("MOUNT"):p==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(d&&f!==p?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,c]),Wn(()=>{if(e){let u;const d=e.ownerDocument.defaultView??window,h=p=>{const g=kA(n.current).includes(p.animationName);if(p.target===e&&g&&(c("ANIMATION_END"),!s.current)){const x=e.style.animationFillMode;e.style.animationFillMode="forwards",u=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=x)})}},f=p=>{p.target===e&&(i.current=kA(n.current))};return e.addEventListener("animationstart",f),e.addEventListener("animationcancel",h),e.addEventListener("animationend",h),()=>{d.clearTimeout(u),e.removeEventListener("animationstart",f),e.removeEventListener("animationcancel",h),e.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(o),ref:j.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function kA(t){return(t==null?void 0:t.animationName)||"none"}function ETe(t){var n,s;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var ATe=IU[" useInsertionEffect ".trim().toString()]||Wn;function _i({prop:t,defaultProp:e,onChange:r=()=>{},caller:n}){const[s,i,a]=CTe({defaultProp:e,onChange:r}),o=t!==void 0,c=o?t:s;{const d=j.useRef(t!==void 0);j.useEffect(()=>{const h=d.current;h!==o&&console.warn(`${n} is changing from ${h?"controlled":"uncontrolled"} to ${o?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=o},[o,n])}const u=j.useCallback(d=>{var h;if(o){const f=TTe(d)?d(t):d;f!==t&&((h=a.current)==null||h.call(a,f))}else i(d)},[o,t,i,a]);return[c,u]}function CTe({defaultProp:t,onChange:e}){const[r,n]=j.useState(t),s=j.useRef(r),i=j.useRef(e);return ATe(()=>{i.current=e},[e]),j.useEffect(()=>{var a;s.current!==r&&((a=i.current)==null||a.call(i,r),s.current=r)},[r,s]),[r,n,i]}function TTe(t){return typeof t=="function"}var ice=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"}),PTe="VisuallyHidden",QI=j.forwardRef((t,e)=>l.jsx(ot.span,{...t,ref:e,style:{...ice,...t.style}}));QI.displayName=PTe;var OTe=QI,EH="ToastProvider",[AH,ITe,RTe]=rE("Toast"),[ace,q4t]=gs("Toast",[RTe]),[MTe,ZI]=ace(EH),oce=t=>{const{__scopeToast:e,label:r="Notification",duration:n=5e3,swipeDirection:s="right",swipeThreshold:i=50,children:a}=t,[o,c]=j.useState(null),[u,d]=j.useState(0),h=j.useRef(!1),f=j.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${EH}\`. Expected non-empty \`string\`.`),l.jsx(AH.Provider,{scope:e,children:l.jsx(MTe,{scope:e,label:r,duration:n,swipeDirection:s,swipeThreshold:i,toastCount:u,viewport:o,onViewportChange:c,onToastAdd:j.useCallback(()=>d(p=>p+1),[]),onToastRemove:j.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:f,children:a})})};oce.displayName=EH;var lce="ToastViewport",DTe=["F8"],v$="toast.viewportPause",b$="toast.viewportResume",cce=j.forwardRef((t,e)=>{const{__scopeToast:r,hotkey:n=DTe,label:s="Notifications ({hotkey})",...i}=t,a=ZI(lce,r),o=ITe(r),c=j.useRef(null),u=j.useRef(null),d=j.useRef(null),h=j.useRef(null),f=It(e,h,a.onViewportChange),p=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),m=a.toastCount>0;j.useEffect(()=>{const x=y=>{var b;n.length!==0&&n.every(w=>y[w]||y.code===w)&&((b=h.current)==null||b.focus())};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[n]),j.useEffect(()=>{const x=c.current,y=h.current;if(m&&x&&y){const v=()=>{if(!a.isClosePausedRef.current){const k=new CustomEvent(v$);y.dispatchEvent(k),a.isClosePausedRef.current=!0}},b=()=>{if(a.isClosePausedRef.current){const k=new CustomEvent(b$);y.dispatchEvent(k),a.isClosePausedRef.current=!1}},w=k=>{!x.contains(k.relatedTarget)&&b()},S=()=>{x.contains(document.activeElement)||b()};return x.addEventListener("focusin",v),x.addEventListener("focusout",w),x.addEventListener("pointermove",v),x.addEventListener("pointerleave",S),window.addEventListener("blur",v),window.addEventListener("focus",b),()=>{x.removeEventListener("focusin",v),x.removeEventListener("focusout",w),x.removeEventListener("pointermove",v),x.removeEventListener("pointerleave",S),window.removeEventListener("blur",v),window.removeEventListener("focus",b)}}},[m,a.isClosePausedRef]);const g=j.useCallback(({tabbingDirection:x})=>{const v=o().map(b=>{const w=b.ref.current,S=[w,...YTe(w)];return x==="forwards"?S:S.reverse()});return(x==="forwards"?v.reverse():v).flat()},[o]);return j.useEffect(()=>{const x=h.current;if(x){const y=v=>{var S,k,E;const b=v.altKey||v.ctrlKey||v.metaKey;if(v.key==="Tab"&&!b){const C=document.activeElement,A=v.shiftKey;if(v.target===x&&A){(S=u.current)==null||S.focus();return}const P=g({tabbingDirection:A?"backwards":"forwards"}),W=P.findIndex(N=>N===C);aL(P.slice(W+1))?v.preventDefault():A?(k=u.current)==null||k.focus():(E=d.current)==null||E.focus()}};return x.addEventListener("keydown",y),()=>x.removeEventListener("keydown",y)}},[o,g]),l.jsxs(_Te,{ref:c,role:"region","aria-label":s.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:m?void 0:"none"},children:[m&&l.jsx(w$,{ref:u,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"forwards"});aL(x)}}),l.jsx(AH.Slot,{scope:r,children:l.jsx(ot.ol,{tabIndex:-1,...i,ref:f})}),m&&l.jsx(w$,{ref:d,onFocusFromOutsideViewport:()=>{const x=g({tabbingDirection:"backwards"});aL(x)}})]})});cce.displayName=lce;var uce="ToastFocusProxy",w$=j.forwardRef((t,e)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...s}=t,i=ZI(uce,r);return l.jsx(QI,{"aria-hidden":!0,tabIndex:0,...s,ref:e,style:{position:"fixed"},onFocus:a=>{var u;const o=a.relatedTarget;!((u=i.viewport)!=null&&u.contains(o))&&n()}})});w$.displayName=uce;var nE="Toast",LTe="toast.swipeStart",FTe="toast.swipeMove",$Te="toast.swipeCancel",BTe="toast.swipeEnd",dce=j.forwardRef((t,e)=>{const{forceMount:r,open:n,defaultOpen:s,onOpenChange:i,...a}=t,[o,c]=_i({prop:n,defaultProp:s??!0,onChange:i,caller:nE});return l.jsx(Os,{present:r||o,children:l.jsx(HTe,{open:o,...a,ref:e,onClose:()=>c(!1),onPause:Hn(t.onPause),onResume:Hn(t.onResume),onSwipeStart:Ke(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ke(t.onSwipeMove,u=>{const{x:d,y:h}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","move"),u.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${d}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:Ke(t.onSwipeCancel,u=>{u.currentTarget.setAttribute("data-swipe","cancel"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Ke(t.onSwipeEnd,u=>{const{x:d,y:h}=u.detail.delta;u.currentTarget.setAttribute("data-swipe","end"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),u.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),u.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${d}px`),u.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),c(!1)})})})});dce.displayName=nE;var[zTe,UTe]=ace(nE,{onClose(){}}),HTe=j.forwardRef((t,e)=>{const{__scopeToast:r,type:n="foreground",duration:s,open:i,onClose:a,onEscapeKeyDown:o,onPause:c,onResume:u,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:f,onSwipeEnd:p,...m}=t,g=ZI(nE,r),[x,y]=j.useState(null),v=It(e,N=>y(N)),b=j.useRef(null),w=j.useRef(null),S=s||g.duration,k=j.useRef(0),E=j.useRef(S),C=j.useRef(0),{onToastAdd:A,onToastRemove:M}=g,z=Hn(()=>{var U;(x==null?void 0:x.contains(document.activeElement))&&((U=g.viewport)==null||U.focus()),a()}),P=j.useCallback(N=>{!N||N===1/0||(window.clearTimeout(C.current),k.current=new Date().getTime(),C.current=window.setTimeout(z,N))},[z]);j.useEffect(()=>{const N=g.viewport;if(N){const U=()=>{P(E.current),u==null||u()},K=()=>{const G=new Date().getTime()-k.current;E.current=E.current-G,window.clearTimeout(C.current),c==null||c()};return N.addEventListener(v$,K),N.addEventListener(b$,U),()=>{N.removeEventListener(v$,K),N.removeEventListener(b$,U)}}},[g.viewport,S,c,u,P]),j.useEffect(()=>{i&&!g.isClosePausedRef.current&&P(S)},[i,S,g.isClosePausedRef,P]),j.useEffect(()=>(A(),()=>M()),[A,M]);const W=j.useMemo(()=>x?xce(x):null,[x]);return g.viewport?l.jsxs(l.Fragment,{children:[W&&l.jsx(VTe,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:W}),l.jsx(zTe,{scope:r,onClose:z,children:Iu.createPortal(l.jsx(AH.ItemSlot,{scope:r,children:l.jsx(STe,{asChild:!0,onEscapeKeyDown:Ke(o,()=>{g.isFocusedToastEscapeKeyDownRef.current||z(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:l.jsx(ot.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":g.swipeDirection,...m,ref:v,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Ke(t.onKeyDown,N=>{N.key==="Escape"&&(o==null||o(N.nativeEvent),N.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,z()))}),onPointerDown:Ke(t.onPointerDown,N=>{N.button===0&&(b.current={x:N.clientX,y:N.clientY})}),onPointerMove:Ke(t.onPointerMove,N=>{if(!b.current)return;const U=N.clientX-b.current.x,K=N.clientY-b.current.y,G=!!w.current,X=["left","right"].includes(g.swipeDirection),H=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,B=X?H(0,U):0,L=X?0:H(0,K),F=N.pointerType==="touch"?10:2,V={x:B,y:L},Y={originalEvent:N,delta:V};G?(w.current=V,NA(FTe,h,Y,{discrete:!1})):WG(V,g.swipeDirection,F)?(w.current=V,NA(LTe,d,Y,{discrete:!1}),N.target.setPointerCapture(N.pointerId)):(Math.abs(U)>F||Math.abs(K)>F)&&(b.current=null)}),onPointerUp:Ke(t.onPointerUp,N=>{const U=w.current,K=N.target;if(K.hasPointerCapture(N.pointerId)&&K.releasePointerCapture(N.pointerId),w.current=null,b.current=null,U){const G=N.currentTarget,X={originalEvent:N,delta:U};WG(U,g.swipeDirection,g.swipeThreshold)?NA(BTe,p,X,{discrete:!0}):NA($Te,f,X,{discrete:!0}),G.addEventListener("click",H=>H.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),VTe=t=>{const{__scopeToast:e,children:r,...n}=t,s=ZI(nE,e),[i,a]=j.useState(!1),[o,c]=j.useState(!1);return GTe(()=>a(!0)),j.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),o?null:l.jsx(Fw,{asChild:!0,children:l.jsx(QI,{...n,children:i&&l.jsxs(l.Fragment,{children:[s.label," ",r]})})})},WTe="ToastTitle",hce=j.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return l.jsx(ot.div,{...n,ref:e})});hce.displayName=WTe;var qTe="ToastDescription",fce=j.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return l.jsx(ot.div,{...n,ref:e})});fce.displayName=qTe;var pce="ToastAction",mce=j.forwardRef((t,e)=>{const{altText:r,...n}=t;return r.trim()?l.jsx(yce,{altText:r,asChild:!0,children:l.jsx(CH,{...n,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${pce}\`. Expected non-empty \`string\`.`),null)});mce.displayName=pce;var gce="ToastClose",CH=j.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t,s=UTe(gce,r);return l.jsx(yce,{asChild:!0,children:l.jsx(ot.button,{type:"button",...n,ref:e,onClick:Ke(t.onClick,s.onClose)})})});CH.displayName=gce;var yce=j.forwardRef((t,e)=>{const{__scopeToast:r,altText:n,...s}=t;return l.jsx(ot.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...s,ref:e})});function xce(t){const e=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&e.push(n.textContent),KTe(n)){const s=n.ariaHidden||n.hidden||n.style.display==="none",i=n.dataset.radixToastAnnounceExclude==="";if(!s)if(i){const a=n.dataset.radixToastAnnounceAlt;a&&e.push(a)}else e.push(...xce(n))}}),e}function NA(t,e,r,{discrete:n}){const s=r.originalEvent.currentTarget,i=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r});e&&s.addEventListener(t,e,{once:!0}),n?NH(s,i):s.dispatchEvent(i)}var WG=(t,e,r=0)=>{const n=Math.abs(t.x),s=Math.abs(t.y),i=n>s;return e==="left"||e==="right"?i&&n>r:!i&&s>r};function GTe(t=()=>{}){const e=Hn(t);Wn(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[e])}function KTe(t){return t.nodeType===t.ELEMENT_NODE}function YTe(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||s?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function aL(t){const e=document.activeElement;return t.some(r=>r===e?!0:(r.focus(),document.activeElement!==e))}var XTe=oce,vce=cce,bce=dce,wce=hce,Sce=fce,_ce=mce,jce=CH;function kce(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(r=kce(t[e]))&&(n&&(n+=" "),n+=r)}else for(r in t)t[r]&&(n&&(n+=" "),n+=r);return n}function mr(){for(var t,e,r=0,n="",s=arguments.length;r<s;r++)(t=arguments[r])&&(e=kce(t))&&(n&&(n+=" "),n+=e);return n}const qG=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,GG=mr,Nh=(t,e)=>r=>{var n;if((e==null?void 0:e.variants)==null)return GG(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:s,defaultVariants:i}=e,a=Object.keys(s).map(u=>{const d=r==null?void 0:r[u],h=i==null?void 0:i[u];if(d===null)return null;const f=qG(d)||qG(h);return s[u][f]}),o=r&&Object.entries(r).reduce((u,d)=>{let[h,f]=d;return f===void 0||(u[h]=f),u},{}),c=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((u,d)=>{let{class:h,className:f,...p}=d;return Object.entries(p).every(m=>{let[g,x]=m;return Array.isArray(x)?x.includes({...i,...o}[g]):{...i,...o}[g]===x})?[...u,h,f]:u},[]);return GG(t,a,c,r==null?void 0:r.class,r==null?void 0:r.className)};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const JTe=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Nce=(...t)=>t.filter((e,r,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===r).join(" ").trim();/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var QTe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ZTe=j.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:i,iconNode:a,...o},c)=>j.createElement("svg",{ref:c,...QTe,width:e,height:e,stroke:t,strokeWidth:n?Number(r)*24/Number(e):r,className:Nce("lucide",s),...o},[...a.map(([u,d])=>j.createElement(u,d)),...Array.isArray(i)?i:[i]]));/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Me=(t,e)=>{const r=j.forwardRef(({className:n,...s},i)=>j.createElement(ZTe,{ref:i,iconNode:e,className:Nce(`lucide-${JTe(t)}`,n),...s}));return r.displayName=`${t}`,r};/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const KG=Me("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const e2e=Me("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const t2e=Me("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const eh=Me("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const r2e=Me("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const n2e=Me("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const s2e=Me("BookCheck",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"m9 9.5 2 2 4-4",key:"1dth82"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ps=Me("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const YG=Me("BookPlus",[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const XG=Me("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const i2e=Me("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const JG=Me("CalendarClock",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const S$=Me("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qy=Me("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Es=Me("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Eh=Me("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ece=Me("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const eR=Me("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ace=Me("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rj=Me("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _c=Me("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const vu=Me("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const a2e=Me("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const o2e=Me("CircleMinus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const l2e=Me("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const c2e=Me("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const L2=Me("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const u2e=Me("ClipboardList",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const oL=Me("ClipboardPaste",[["path",{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",key:"1pp7kr"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",key:"2ik1ml"}],["path",{d:"m17 10 4 4-4 4",key:"vp2hj1"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gx=Me("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const d2e=Me("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Cce=Me("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Tn=Me("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const h2e=Me("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const f2e=Me("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ga=Me("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const p2e=Me("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $p=Me("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const F2=Me("EyeOff",[["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",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["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",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Xa=Me("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const QG=Me("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Tce=Me("FileSearch",[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4.268 21a2 2 0 0 0 1.727 1H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"ms7g94"}],["path",{d:"m9 18-1.5-1.5",key:"1j6qii"}],["circle",{cx:"5",cy:"14",r:"3",key:"ufru5t"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Br=Me("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const m2e=Me("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const g2e=Me("FileX",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const y2e=Me("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const x2e=Me("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $2=Me("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Pce=Me("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Oce=Me("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const v2e=Me("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const b2e=Me("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const w2e=Me("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const S2e=Me("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _2e=Me("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const j2e=Me("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const k2e=Me("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sE=Me("Import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Bp=Me("Info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const N2e=Me("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const E2e=Me("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const A2e=Me("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rm=Me("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const C2e=Me("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const T2e=Me("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xt=Me("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Di=Me("Loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const TH=Me("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const P2e=Me("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ice=Me("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const O2e=Me("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const I2e=Me("Maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const PH=Me("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const R2e=Me("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const M2e=Me("MessageSquareQuote",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const D2e=Me("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Gy=Me("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const L2e=Me("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Rce=Me("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const F2e=Me("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $2e=Me("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const B2e=Me("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const z2e=Me("MousePointer",[["path",{d:"M12.586 12.586 19 19",key:"ea5xo7"}],["path",{d:"M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z",key:"277e5u"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const U2e=Me("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const H2e=Me("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const V2e=Me("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const W2e=Me("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _$=Me("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const OH=Me("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Mce=Me("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hl=Me("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const q2e=Me("Printer",[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ah=Me("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const G2e=Me("RectangleEllipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const K2e=Me("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Dce=Me("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Y2e=Me("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const j$=Me("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Lce=Me("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yl=Me("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Fce=Me("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const X2e=Me("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $ce=Me("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Qs=Me("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const J2e=Me("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const k$=Me("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Q2e=Me("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Z2e=Me("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xi=Me("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ePe=Me("TrendingDown",[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const tPe=Me("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bu=Me("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rPe=Me("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const nPe=Me("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hh=Me("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $w=Me("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Bce=Me("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const sPe=Me("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const iPe=Me("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const B2=Me("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Is=Me("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lL=Me("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zce=Me("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
* @license lucide-react v0.462.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const aPe=Me("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),IH="-",oPe=t=>{const e=cPe(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:a=>{const o=a.split(IH);return o[0]===""&&o.length!==1&&o.shift(),Uce(o,e)||lPe(a)},getConflictingClassGroupIds:(a,o)=>{const c=r[a]||[];return o&&n[a]?[...c,...n[a]]:c}}},Uce=(t,e)=>{var a;if(t.length===0)return e.classGroupId;const r=t[0],n=e.nextPart.get(r),s=n?Uce(t.slice(1),n):void 0;if(s)return s;if(e.validators.length===0)return;const i=t.join(IH);return(a=e.validators.find(({validator:o})=>o(i)))==null?void 0:a.classGroupId},ZG=/^\[(.+)\]$/,lPe=t=>{if(ZG.test(t)){const e=ZG.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},cPe=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return dPe(Object.entries(t.classGroups),r).forEach(([i,a])=>{N$(a,n,i,e)}),n},N$=(t,e,r,n)=>{t.forEach(s=>{if(typeof s=="string"){const i=s===""?e:eK(e,s);i.classGroupId=r;return}if(typeof s=="function"){if(uPe(s)){N$(s(n),e,r,n);return}e.validators.push({validator:s,classGroupId:r});return}Object.entries(s).forEach(([i,a])=>{N$(a,eK(e,i),r,n)})})},eK=(t,e)=>{let r=t;return e.split(IH).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},uPe=t=>t.isThemeGetter,dPe=(t,e)=>e?t.map(([r,n])=>{const s=n.map(i=>typeof i=="string"?e+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([a,o])=>[e+a,o])):i);return[r,s]}):t,hPe=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const s=(i,a)=>{r.set(i,a),e++,e>t&&(e=0,n=r,r=new Map)};return{get(i){let a=r.get(i);if(a!==void 0)return a;if((a=n.get(i))!==void 0)return s(i,a),a},set(i,a){r.has(i)?r.set(i,a):s(i,a)}}},Hce="!",fPe=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,s=e[0],i=e.length,a=o=>{const c=[];let u=0,d=0,h;for(let x=0;x<o.length;x++){let y=o[x];if(u===0){if(y===s&&(n||o.slice(x,x+i)===e)){c.push(o.slice(d,x)),d=x+i;continue}if(y==="/"){h=x;continue}}y==="["?u++:y==="]"&&u--}const f=c.length===0?o:o.substring(d),p=f.startsWith(Hce),m=p?f.substring(1):f,g=h&&h>d?h-d:void 0;return{modifiers:c,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:g}};return r?o=>r({className:o,parseClassName:a}):a},pPe=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},mPe=t=>({cache:hPe(t.cacheSize),parseClassName:fPe(t),...oPe(t)}),gPe=/\s+/,yPe=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s}=e,i=[],a=t.trim().split(gPe);let o="";for(let c=a.length-1;c>=0;c-=1){const u=a[c],{modifiers:d,hasImportantModifier:h,baseClassName:f,maybePostfixModifierPosition:p}=r(u);let m=!!p,g=n(m?f.substring(0,p):f);if(!g){if(!m){o=u+(o.length>0?" "+o:o);continue}if(g=n(f),!g){o=u+(o.length>0?" "+o:o);continue}m=!1}const x=pPe(d).join(":"),y=h?x+Hce:x,v=y+g;if(i.includes(v))continue;i.push(v);const b=s(g,m);for(let w=0;w<b.length;++w){const S=b[w];i.push(y+S)}o=u+(o.length>0?" "+o:o)}return o};function xPe(){let t=0,e,r,n="";for(;t<arguments.length;)(e=arguments[t++])&&(r=Vce(e))&&(n&&(n+=" "),n+=r);return n}const Vce=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=Vce(t[n]))&&(r&&(r+=" "),r+=e);return r};function vPe(t,...e){let r,n,s,i=a;function a(c){const u=e.reduce((d,h)=>h(d),t());return r=mPe(u),n=r.cache.get,s=r.cache.set,i=o,o(c)}function o(c){const u=n(c);if(u)return u;const d=yPe(c,r);return s(c,d),d}return function(){return i(xPe.apply(null,arguments))}}const sn=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},Wce=/^\[(?:([a-z-]+):)?(.+)\]$/i,bPe=/^\d+\/\d+$/,wPe=new Set(["px","full","screen"]),SPe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_Pe=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,jPe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,kPe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,NPe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Uu=t=>eb(t)||wPe.has(t)||bPe.test(t),$h=t=>Bw(t,"length",RPe),eb=t=>!!t&&!Number.isNaN(Number(t)),cL=t=>Bw(t,"number",eb),E1=t=>!!t&&Number.isInteger(Number(t)),EPe=t=>t.endsWith("%")&&eb(t.slice(0,-1)),Ht=t=>Wce.test(t),Bh=t=>SPe.test(t),APe=new Set(["length","size","percentage"]),CPe=t=>Bw(t,APe,qce),TPe=t=>Bw(t,"position",qce),PPe=new Set(["image","url"]),OPe=t=>Bw(t,PPe,DPe),IPe=t=>Bw(t,"",MPe),A1=()=>!0,Bw=(t,e,r)=>{const n=Wce.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},RPe=t=>_Pe.test(t)&&!jPe.test(t),qce=()=>!1,MPe=t=>kPe.test(t),DPe=t=>NPe.test(t),LPe=()=>{const t=sn("colors"),e=sn("spacing"),r=sn("blur"),n=sn("brightness"),s=sn("borderColor"),i=sn("borderRadius"),a=sn("borderSpacing"),o=sn("borderWidth"),c=sn("contrast"),u=sn("grayscale"),d=sn("hueRotate"),h=sn("invert"),f=sn("gap"),p=sn("gradientColorStops"),m=sn("gradientColorStopPositions"),g=sn("inset"),x=sn("margin"),y=sn("opacity"),v=sn("padding"),b=sn("saturate"),w=sn("scale"),S=sn("sepia"),k=sn("skew"),E=sn("space"),C=sn("translate"),A=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],z=()=>["auto",Ht,e],P=()=>[Ht,e],W=()=>["",Uu,$h],N=()=>["auto",eb,Ht],U=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],K=()=>["solid","dashed","dotted","double","none"],G=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],X=()=>["start","end","center","between","around","evenly","stretch"],H=()=>["","0",Ht],B=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>[eb,Ht];return{cacheSize:500,separator:":",theme:{colors:[A1],spacing:[Uu,$h],blur:["none","",Bh,Ht],brightness:L(),borderColor:[t],borderRadius:["none","","full",Bh,Ht],borderSpacing:P(),borderWidth:W(),contrast:L(),grayscale:H(),hueRotate:L(),invert:H(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[EPe,$h],inset:z(),margin:z(),opacity:L(),padding:P(),saturate:L(),scale:L(),sepia:H(),skew:L(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",Ht]}],container:["container"],columns:[{columns:[Bh]}],"break-after":[{"break-after":B()}],"break-before":[{"break-before":B()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...U(),Ht]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",E1,Ht]}],basis:[{basis:z()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Ht]}],grow:[{grow:H()}],shrink:[{shrink:H()}],order:[{order:["first","last","none",E1,Ht]}],"grid-cols":[{"grid-cols":[A1]}],"col-start-end":[{col:["auto",{span:["full",E1,Ht]},Ht]}],"col-start":[{"col-start":N()}],"col-end":[{"col-end":N()}],"grid-rows":[{"grid-rows":[A1]}],"row-start-end":[{row:["auto",{span:[E1,Ht]},Ht]}],"row-start":[{"row-start":N()}],"row-end":[{"row-end":N()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Ht]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Ht]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...X()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...X(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...X(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[E]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[E]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Ht,e]}],"min-w":[{"min-w":[Ht,e,"min","max","fit"]}],"max-w":[{"max-w":[Ht,e,"none","full","min","max","fit","prose",{screen:[Bh]},Bh]}],h:[{h:[Ht,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Ht,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Ht,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Ht,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Bh,$h]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",cL]}],"font-family":[{font:[A1]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Ht]}],"line-clamp":[{"line-clamp":["none",eb,cL]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Uu,Ht]}],"list-image":[{"list-image":["none",Ht]}],"list-style-type":[{list:["none","disc","decimal",Ht]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[y]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[y]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...K(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Uu,$h]}],"underline-offset":[{"underline-offset":["auto",Uu,Ht]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ht]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ht]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[y]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...U(),TPe]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",CPe]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},OPe]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[y]}],"border-style":[{border:[...K(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[y]}],"divide-style":[{divide:K()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-s":[{"border-s":[s]}],"border-color-e":[{"border-e":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:["",...K()]}],"outline-offset":[{"outline-offset":[Uu,Ht]}],"outline-w":[{outline:[Uu,$h]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[y]}],"ring-offset-w":[{"ring-offset":[Uu,$h]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Bh,IPe]}],"shadow-color":[{shadow:[A1]}],opacity:[{opacity:[y]}],"mix-blend":[{"mix-blend":[...G(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":G()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",Bh,Ht]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[b]}],sepia:[{sepia:[S]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[y]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[S]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[a]}],"border-spacing-x":[{"border-spacing-x":[a]}],"border-spacing-y":[{"border-spacing-y":[a]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Ht]}],duration:[{duration:L()}],ease:[{ease:["linear","in","out","in-out",Ht]}],delay:[{delay:L()}],animate:[{animate:["none","spin","ping","pulse","bounce",Ht]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[E1,Ht]}],"translate-x":[{"translate-x":[C]}],"translate-y":[{"translate-y":[C]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Ht]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ht]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ht]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Uu,$h,cL]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},FPe=vPe(LPe);function Le(...t){return FPe(mr(t))}const $Pe=XTe,Gce=j.forwardRef(({className:t,...e},r)=>l.jsx(vce,{ref:r,className:Le("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...e}));Gce.displayName=vce.displayName;const BPe=Nh("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Kce=j.forwardRef(({className:t,variant:e,...r},n)=>l.jsx(bce,{ref:n,className:Le(BPe({variant:e}),t),...r}));Kce.displayName=bce.displayName;const zPe=j.forwardRef(({className:t,...e},r)=>l.jsx(_ce,{ref:r,className:Le("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",t),...e}));zPe.displayName=_ce.displayName;const Yce=j.forwardRef(({className:t,...e},r)=>l.jsx(jce,{ref:r,className:Le("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...e,children:l.jsx(Is,{className:"h-4 w-4"})}));Yce.displayName=jce.displayName;const Xce=j.forwardRef(({className:t,...e},r)=>l.jsx(wce,{ref:r,className:Le("text-sm font-semibold",t),...e}));Xce.displayName=wce.displayName;const Jce=j.forwardRef(({className:t,...e},r)=>l.jsx(Sce,{ref:r,className:Le("text-sm opacity-90",t),...e}));Jce.displayName=Sce.displayName;function UPe(){const{toasts:t}=qn();return l.jsxs($Pe,{children:[t.map(function({id:e,title:r,description:n,action:s,...i}){return l.jsxs(Kce,{...i,children:[l.jsxs("div",{className:"grid gap-1",children:[r&&l.jsx(Xce,{children:r}),n&&l.jsx(Jce,{children:n})]}),s,l.jsx(Yce,{})]},e)}),l.jsx(Gce,{})]})}var tK=["light","dark"],HPe="(prefers-color-scheme: dark)",VPe=j.createContext(void 0),WPe={setTheme:t=>{},themes:[]},qPe=()=>{var t;return(t=j.useContext(VPe))!=null?t:WPe};j.memo(({forcedTheme:t,storageKey:e,attribute:r,enableSystem:n,enableColorScheme:s,defaultTheme:i,value:a,attrs:o,nonce:c})=>{let u=i==="system",d=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${o.map(m=>`'${m}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,h=s?tK.includes(i)&&i?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${i}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",f=(m,g=!1,x=!0)=>{let y=a?a[m]:m,v=g?m+"|| ''":`'${y}'`,b="";return s&&x&&!g&&tK.includes(m)&&(b+=`d.style.colorScheme = '${m}';`),r==="class"?g||y?b+=`c.add(${v})`:b+="null":y&&(b+=`d[s](n,${v})`),b},p=t?`!function(){${d}${f(t)}}()`:n?`!function(){try{${d}var e=localStorage.getItem('${e}');if('system'===e||(!e&&${u})){var t='${HPe}',m=window.matchMedia(t);if(m.media!==t||m.matches){${f("dark")}}else{${f("light")}}}else if(e){${a?`var x=${JSON.stringify(a)};`:""}${f(a?"x[e]":"e",!0)}}${u?"":"else{"+f(i,!1,!1)+"}"}${h}}catch(e){}}()`:`!function(){try{${d}var e=localStorage.getItem('${e}');if(e){${a?`var x=${JSON.stringify(a)};`:""}${f(a?"x[e]":"e",!0)}}else{${f(i,!1,!1)};}${h}}catch(t){}}();`;return j.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:p}})});var GPe=t=>{switch(t){case"success":return XPe;case"info":return QPe;case"warning":return JPe;case"error":return ZPe;default:return null}},KPe=Array(12).fill(0),YPe=({visible:t,className:e})=>pe.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},pe.createElement("div",{className:"sonner-spinner"},KPe.map((r,n)=>pe.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),XPe=pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},pe.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),JPe=pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},pe.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),QPe=pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},pe.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),ZPe=pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},pe.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),eOe=pe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},pe.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),pe.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),tOe=()=>{let[t,e]=pe.useState(document.hidden);return pe.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},E$=1,rOe=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...n}=t,s=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:E$++,i=this.toasts.find(o=>o.id===s),a=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),i?this.toasts=this.toasts.map(o=>o.id===s?(this.publish({...o,...t,id:s,title:r}),{...o,...t,id:s,dismissible:a,title:r}):o):this.addToast({title:r,...n,dismissible:a,id:s}),s},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let n=t instanceof Promise?t:t(),s=r!==void 0,i,a=n.then(async c=>{if(i=["resolve",c],pe.isValidElement(c))s=!1,this.create({id:r,type:"default",message:c});else if(sOe(c)&&!c.ok){s=!1;let u=typeof e.error=="function"?await e.error(`HTTP error! status: ${c.status}`):e.error,d=typeof e.description=="function"?await e.description(`HTTP error! status: ${c.status}`):e.description;this.create({id:r,type:"error",message:u,description:d})}else if(e.success!==void 0){s=!1;let u=typeof e.success=="function"?await e.success(c):e.success,d=typeof e.description=="function"?await e.description(c):e.description;this.create({id:r,type:"success",message:u,description:d})}}).catch(async c=>{if(i=["reject",c],e.error!==void 0){s=!1;let u=typeof e.error=="function"?await e.error(c):e.error,d=typeof e.description=="function"?await e.description(c):e.description;this.create({id:r,type:"error",message:u,description:d})}}).finally(()=>{var c;s&&(this.dismiss(r),r=void 0),(c=e.finally)==null||c.call(e)}),o=()=>new Promise((c,u)=>a.then(()=>i[0]==="reject"?u(i[1]):c(i[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:o}:Object.assign(r,{unwrap:o})},this.custom=(t,e)=>{let r=(e==null?void 0:e.id)||E$++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Ra=new rOe,nOe=(t,e)=>{let r=(e==null?void 0:e.id)||E$++;return Ra.addToast({title:t,...e,id:r}),r},sOe=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",iOe=nOe,aOe=()=>Ra.toasts,oOe=()=>Ra.getActiveToasts(),We=Object.assign(iOe,{success:Ra.success,info:Ra.info,warning:Ra.warning,error:Ra.error,custom:Ra.custom,message:Ra.message,promise:Ra.promise,dismiss:Ra.dismiss,loading:Ra.loading},{getHistory:aOe,getToasts:oOe});function lOe(t,{insertAt:e}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}lOe(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
`);function EA(t){return t.label!==void 0}var cOe=3,uOe="32px",dOe="16px",rK=4e3,hOe=356,fOe=14,pOe=20,mOe=200;function Rl(...t){return t.filter(Boolean).join(" ")}function gOe(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var yOe=t=>{var e,r,n,s,i,a,o,c,u,d,h;let{invert:f,toast:p,unstyled:m,interacting:g,setHeights:x,visibleToasts:y,heights:v,index:b,toasts:w,expanded:S,removeToast:k,defaultRichColors:E,closeButton:C,style:A,cancelButtonStyle:M,actionButtonStyle:z,className:P="",descriptionClassName:W="",duration:N,position:U,gap:K,loadingIcon:G,expandByDefault:X,classNames:H,icons:B,closeButtonAriaLabel:L="Close toast",pauseWhenPageIsHidden:F}=t,[V,Y]=pe.useState(null),[ie,Q]=pe.useState(null),[D,R]=pe.useState(!1),[J,Z]=pe.useState(!1),[ee,re]=pe.useState(!1),[he,O]=pe.useState(!1),[ae,q]=pe.useState(!1),[I,T]=pe.useState(0),[$,se]=pe.useState(0),ue=pe.useRef(p.duration||N||rK),ne=pe.useRef(null),me=pe.useRef(null),ve=b===0,xe=b+1<=y,oe=p.type,de=p.dismissible!==!1,ge=p.className||"",Se=p.descriptionClassName||"",ke=pe.useMemo(()=>v.findIndex(je=>je.toastId===p.id)||0,[v,p.id]),Ne=pe.useMemo(()=>{var je;return(je=p.closeButton)!=null?je:C},[p.closeButton,C]),qe=pe.useMemo(()=>p.duration||N||rK,[p.duration,N]),Ae=pe.useRef(0),fe=pe.useRef(0),Te=pe.useRef(0),Pe=pe.useRef(null),[tt,wt]=U.split("-"),Ee=pe.useMemo(()=>v.reduce((je,Re,Ue)=>Ue>=ke?je:je+Re.height,0),[v,ke]),nt=tOe(),rt=p.invert||f,Ze=oe==="loading";fe.current=pe.useMemo(()=>ke*K+Ee,[ke,Ee]),pe.useEffect(()=>{ue.current=qe},[qe]),pe.useEffect(()=>{R(!0)},[]),pe.useEffect(()=>{let je=me.current;if(je){let Re=je.getBoundingClientRect().height;return se(Re),x(Ue=>[{toastId:p.id,height:Re,position:p.position},...Ue]),()=>x(Ue=>Ue.filter(it=>it.toastId!==p.id))}},[x,p.id]),pe.useLayoutEffect(()=>{if(!D)return;let je=me.current,Re=je.style.height;je.style.height="auto";let Ue=je.getBoundingClientRect().height;je.style.height=Re,se(Ue),x(it=>it.find(Ce=>Ce.toastId===p.id)?it.map(Ce=>Ce.toastId===p.id?{...Ce,height:Ue}:Ce):[{toastId:p.id,height:Ue,position:p.position},...it])},[D,p.title,p.description,x,p.id]);let we=pe.useCallback(()=>{Z(!0),T(fe.current),x(je=>je.filter(Re=>Re.toastId!==p.id)),setTimeout(()=>{k(p)},mOe)},[p,k,x,fe]);pe.useEffect(()=>{if(p.promise&&oe==="loading"||p.duration===1/0||p.type==="loading")return;let je;return S||g||F&&nt?(()=>{if(Te.current<Ae.current){let Re=new Date().getTime()-Ae.current;ue.current=ue.current-Re}Te.current=new Date().getTime()})():ue.current!==1/0&&(Ae.current=new Date().getTime(),je=setTimeout(()=>{var Re;(Re=p.onAutoClose)==null||Re.call(p,p),we()},ue.current)),()=>clearTimeout(je)},[S,g,p,oe,F,nt,we]),pe.useEffect(()=>{p.delete&&we()},[we,p.delete]);function Oe(){var je,Re,Ue;return B!=null&&B.loading?pe.createElement("div",{className:Rl(H==null?void 0:H.loader,(je=p==null?void 0:p.classNames)==null?void 0:je.loader,"sonner-loader"),"data-visible":oe==="loading"},B.loading):G?pe.createElement("div",{className:Rl(H==null?void 0:H.loader,(Re=p==null?void 0:p.classNames)==null?void 0:Re.loader,"sonner-loader"),"data-visible":oe==="loading"},G):pe.createElement(YPe,{className:Rl(H==null?void 0:H.loader,(Ue=p==null?void 0:p.classNames)==null?void 0:Ue.loader),visible:oe==="loading"})}return pe.createElement("li",{tabIndex:0,ref:me,className:Rl(P,ge,H==null?void 0:H.toast,(e=p==null?void 0:p.classNames)==null?void 0:e.toast,H==null?void 0:H.default,H==null?void 0:H[oe],(r=p==null?void 0:p.classNames)==null?void 0:r[oe]),"data-sonner-toast":"","data-rich-colors":(n=p.richColors)!=null?n:E,"data-styled":!(p.jsx||p.unstyled||m),"data-mounted":D,"data-promise":!!p.promise,"data-swiped":ae,"data-removed":J,"data-visible":xe,"data-y-position":tt,"data-x-position":wt,"data-index":b,"data-front":ve,"data-swiping":ee,"data-dismissible":de,"data-type":oe,"data-invert":rt,"data-swipe-out":he,"data-swipe-direction":ie,"data-expanded":!!(S||X&&D),style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${J?I:fe.current}px`,"--initial-height":X?"auto":`${$}px`,...A,...p.style},onDragEnd:()=>{re(!1),Y(null),Pe.current=null},onPointerDown:je=>{Ze||!de||(ne.current=new Date,T(fe.current),je.target.setPointerCapture(je.pointerId),je.target.tagName!=="BUTTON"&&(re(!0),Pe.current={x:je.clientX,y:je.clientY}))},onPointerUp:()=>{var je,Re,Ue,it;if(he||!de)return;Pe.current=null;let Ce=Number(((je=me.current)==null?void 0:je.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),$t=Number(((Re=me.current)==null?void 0:Re.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Kt=new Date().getTime()-((Ue=ne.current)==null?void 0:Ue.getTime()),On=V==="x"?Ce:$t,Ms=Math.abs(On)/Kt;if(Math.abs(On)>=pOe||Ms>.11){T(fe.current),(it=p.onDismiss)==null||it.call(p,p),Q(V==="x"?Ce>0?"right":"left":$t>0?"down":"up"),we(),O(!0),q(!1);return}re(!1),Y(null)},onPointerMove:je=>{var Re,Ue,it,Ce;if(!Pe.current||!de||((Re=window.getSelection())==null?void 0:Re.toString().length)>0)return;let $t=je.clientY-Pe.current.y,Kt=je.clientX-Pe.current.x,On=(Ue=t.swipeDirections)!=null?Ue:gOe(U);!V&&(Math.abs(Kt)>1||Math.abs($t)>1)&&Y(Math.abs(Kt)>Math.abs($t)?"x":"y");let Ms={x:0,y:0};V==="y"?(On.includes("top")||On.includes("bottom"))&&(On.includes("top")&&$t<0||On.includes("bottom")&&$t>0)&&(Ms.y=$t):V==="x"&&(On.includes("left")||On.includes("right"))&&(On.includes("left")&&Kt<0||On.includes("right")&&Kt>0)&&(Ms.x=Kt),(Math.abs(Ms.x)>0||Math.abs(Ms.y)>0)&&q(!0),(it=me.current)==null||it.style.setProperty("--swipe-amount-x",`${Ms.x}px`),(Ce=me.current)==null||Ce.style.setProperty("--swipe-amount-y",`${Ms.y}px`)}},Ne&&!p.jsx?pe.createElement("button",{"aria-label":L,"data-disabled":Ze,"data-close-button":!0,onClick:Ze||!de?()=>{}:()=>{var je;we(),(je=p.onDismiss)==null||je.call(p,p)},className:Rl(H==null?void 0:H.closeButton,(s=p==null?void 0:p.classNames)==null?void 0:s.closeButton)},(i=B==null?void 0:B.close)!=null?i:eOe):null,p.jsx||j.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:pe.createElement(pe.Fragment,null,oe||p.icon||p.promise?pe.createElement("div",{"data-icon":"",className:Rl(H==null?void 0:H.icon,(a=p==null?void 0:p.classNames)==null?void 0:a.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||Oe():null,p.type!=="loading"?p.icon||(B==null?void 0:B[oe])||GPe(oe):null):null,pe.createElement("div",{"data-content":"",className:Rl(H==null?void 0:H.content,(o=p==null?void 0:p.classNames)==null?void 0:o.content)},pe.createElement("div",{"data-title":"",className:Rl(H==null?void 0:H.title,(c=p==null?void 0:p.classNames)==null?void 0:c.title)},typeof p.title=="function"?p.title():p.title),p.description?pe.createElement("div",{"data-description":"",className:Rl(W,Se,H==null?void 0:H.description,(u=p==null?void 0:p.classNames)==null?void 0:u.description)},typeof p.description=="function"?p.description():p.description):null),j.isValidElement(p.cancel)?p.cancel:p.cancel&&EA(p.cancel)?pe.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||M,onClick:je=>{var Re,Ue;EA(p.cancel)&&de&&((Ue=(Re=p.cancel).onClick)==null||Ue.call(Re,je),we())},className:Rl(H==null?void 0:H.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,j.isValidElement(p.action)?p.action:p.action&&EA(p.action)?pe.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||z,onClick:je=>{var Re,Ue;EA(p.action)&&((Ue=(Re=p.action).onClick)==null||Ue.call(Re,je),!je.defaultPrevented&&we())},className:Rl(H==null?void 0:H.actionButton,(h=p==null?void 0:p.classNames)==null?void 0:h.actionButton)},p.action.label):null))};function nK(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function xOe(t,e){let r={};return[t,e].forEach((n,s)=>{let i=s===1,a=i?"--mobile-offset":"--offset",o=i?dOe:uOe;function c(u){["top","right","bottom","left"].forEach(d=>{r[`${a}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof n=="number"||typeof n=="string"?c(n):typeof n=="object"?["top","right","bottom","left"].forEach(u=>{n[u]===void 0?r[`${a}-${u}`]=o:r[`${a}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):c(o)}),r}var vOe=j.forwardRef(function(t,e){let{invert:r,position:n="bottom-right",hotkey:s=["altKey","KeyT"],expand:i,closeButton:a,className:o,offset:c,mobileOffset:u,theme:d="light",richColors:h,duration:f,style:p,visibleToasts:m=cOe,toastOptions:g,dir:x=nK(),gap:y=fOe,loadingIcon:v,icons:b,containerAriaLabel:w="Notifications",pauseWhenPageIsHidden:S}=t,[k,E]=pe.useState([]),C=pe.useMemo(()=>Array.from(new Set([n].concat(k.filter(F=>F.position).map(F=>F.position)))),[k,n]),[A,M]=pe.useState([]),[z,P]=pe.useState(!1),[W,N]=pe.useState(!1),[U,K]=pe.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),G=pe.useRef(null),X=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),H=pe.useRef(null),B=pe.useRef(!1),L=pe.useCallback(F=>{E(V=>{var Y;return(Y=V.find(ie=>ie.id===F.id))!=null&&Y.delete||Ra.dismiss(F.id),V.filter(({id:ie})=>ie!==F.id)})},[]);return pe.useEffect(()=>Ra.subscribe(F=>{if(F.dismiss){E(V=>V.map(Y=>Y.id===F.id?{...Y,delete:!0}:Y));return}setTimeout(()=>{jH.flushSync(()=>{E(V=>{let Y=V.findIndex(ie=>ie.id===F.id);return Y!==-1?[...V.slice(0,Y),{...V[Y],...F},...V.slice(Y+1)]:[F,...V]})})})}),[]),pe.useEffect(()=>{if(d!=="system"){K(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;let F=window.matchMedia("(prefers-color-scheme: dark)");try{F.addEventListener("change",({matches:V})=>{K(V?"dark":"light")})}catch{F.addListener(({matches:Y})=>{try{K(Y?"dark":"light")}catch(ie){console.error(ie)}})}},[d]),pe.useEffect(()=>{k.length<=1&&P(!1)},[k]),pe.useEffect(()=>{let F=V=>{var Y,ie;s.every(Q=>V[Q]||V.code===Q)&&(P(!0),(Y=G.current)==null||Y.focus()),V.code==="Escape"&&(document.activeElement===G.current||(ie=G.current)!=null&&ie.contains(document.activeElement))&&P(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[s]),pe.useEffect(()=>{if(G.current)return()=>{H.current&&(H.current.focus({preventScroll:!0}),H.current=null,B.current=!1)}},[G.current]),pe.createElement("section",{ref:e,"aria-label":`${w} ${X}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},C.map((F,V)=>{var Y;let[ie,Q]=F.split("-");return k.length?pe.createElement("ol",{key:F,dir:x==="auto"?nK():x,tabIndex:-1,ref:G,className:o,"data-sonner-toaster":!0,"data-theme":U,"data-y-position":ie,"data-lifted":z&&k.length>1&&!i,"data-x-position":Q,style:{"--front-toast-height":`${((Y=A[0])==null?void 0:Y.height)||0}px`,"--width":`${hOe}px`,"--gap":`${y}px`,...p,...xOe(c,u)},onBlur:D=>{B.current&&!D.currentTarget.contains(D.relatedTarget)&&(B.current=!1,H.current&&(H.current.focus({preventScroll:!0}),H.current=null))},onFocus:D=>{D.target instanceof HTMLElement&&D.target.dataset.dismissible==="false"||B.current||(B.current=!0,H.current=D.relatedTarget)},onMouseEnter:()=>P(!0),onMouseMove:()=>P(!0),onMouseLeave:()=>{W||P(!1)},onDragEnd:()=>P(!1),onPointerDown:D=>{D.target instanceof HTMLElement&&D.target.dataset.dismissible==="false"||N(!0)},onPointerUp:()=>N(!1)},k.filter(D=>!D.position&&V===0||D.position===F).map((D,R)=>{var J,Z;return pe.createElement(yOe,{key:D.id,icons:b,index:R,toast:D,defaultRichColors:h,duration:(J=g==null?void 0:g.duration)!=null?J:f,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:r,visibleToasts:m,closeButton:(Z=g==null?void 0:g.closeButton)!=null?Z:a,interacting:W,position:F,style:g==null?void 0:g.style,unstyled:g==null?void 0:g.unstyled,classNames:g==null?void 0:g.classNames,cancelButtonStyle:g==null?void 0:g.cancelButtonStyle,actionButtonStyle:g==null?void 0:g.actionButtonStyle,removeToast:L,toasts:k.filter(ee=>ee.position==D.position),heights:A.filter(ee=>ee.position==D.position),setHeights:M,expandByDefault:i,gap:y,loadingIcon:v,expanded:z,pauseWhenPageIsHidden:S,swipeDirections:t.swipeDirections})})):null}))});const bOe=({...t})=>{const{theme:e="system"}=qPe();return l.jsx(vOe,{theme:e,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})};var wOe=IU[" useId ".trim().toString()]||(()=>{}),SOe=0;function Ka(t){const[e,r]=j.useState(wOe());return Wn(()=>{r(n=>n??String(SOe++))},[t]),e?`radix-${e}`:""}const _Oe=["top","right","bottom","left"],zp=Math.min,_o=Math.max,z2=Math.round,AA=Math.floor,wu=t=>({x:t,y:t}),jOe={left:"right",right:"left",bottom:"top",top:"bottom"},kOe={start:"end",end:"start"};function A$(t,e,r){return _o(t,zp(e,r))}function fh(t,e){return typeof t=="function"?t(e):t}function ph(t){return t.split("-")[0]}function zw(t){return t.split("-")[1]}function RH(t){return t==="x"?"y":"x"}function MH(t){return t==="y"?"height":"width"}const NOe=new Set(["top","bottom"]);function pu(t){return NOe.has(ph(t))?"y":"x"}function DH(t){return RH(pu(t))}function EOe(t,e,r){r===void 0&&(r=!1);const n=zw(t),s=DH(t),i=MH(s);let a=s==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(a=U2(a)),[a,U2(a)]}function AOe(t){const e=U2(t);return[C$(t),e,C$(e)]}function C$(t){return t.replace(/start|end/g,e=>kOe[e])}const sK=["left","right"],iK=["right","left"],COe=["top","bottom"],TOe=["bottom","top"];function POe(t,e,r){switch(t){case"top":case"bottom":return r?e?iK:sK:e?sK:iK;case"left":case"right":return e?COe:TOe;default:return[]}}function OOe(t,e,r,n){const s=zw(t);let i=POe(ph(t),r==="start",n);return s&&(i=i.map(a=>a+"-"+s),e&&(i=i.concat(i.map(C$)))),i}function U2(t){return t.replace(/left|right|bottom|top/g,e=>jOe[e])}function IOe(t){return{top:0,right:0,bottom:0,left:0,...t}}function Qce(t){return typeof t!="number"?IOe(t):{top:t,right:t,bottom:t,left:t}}function H2(t){const{x:e,y:r,width:n,height:s}=t;return{width:n,height:s,top:r,left:e,right:e+n,bottom:r+s,x:e,y:r}}function aK(t,e,r){let{reference:n,floating:s}=t;const i=pu(e),a=DH(e),o=MH(a),c=ph(e),u=i==="y",d=n.x+n.width/2-s.width/2,h=n.y+n.height/2-s.height/2,f=n[o]/2-s[o]/2;let p;switch(c){case"top":p={x:d,y:n.y-s.height};break;case"bottom":p={x:d,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:h};break;case"left":p={x:n.x-s.width,y:h};break;default:p={x:n.x,y:n.y}}switch(zw(e)){case"start":p[a]-=f*(r&&u?-1:1);break;case"end":p[a]+=f*(r&&u?-1:1);break}return p}const ROe=async(t,e,r)=>{const{placement:n="bottom",strategy:s="absolute",middleware:i=[],platform:a}=r,o=i.filter(Boolean),c=await(a.isRTL==null?void 0:a.isRTL(e));let u=await a.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:h}=aK(u,n,c),f=n,p={},m=0;for(let g=0;g<o.length;g++){const{name:x,fn:y}=o[g],{x:v,y:b,data:w,reset:S}=await y({x:d,y:h,initialPlacement:n,placement:f,strategy:s,middlewareData:p,rects:u,platform:a,elements:{reference:t,floating:e}});d=v??d,h=b??h,p={...p,[x]:{...p[x],...w}},S&&m<=50&&(m++,typeof S=="object"&&(S.placement&&(f=S.placement),S.rects&&(u=S.rects===!0?await a.getElementRects({reference:t,floating:e,strategy:s}):S.rects),{x:d,y:h}=aK(u,f,c)),g=-1)}return{x:d,y:h,placement:f,strategy:s,middlewareData:p}};async function nj(t,e){var r;e===void 0&&(e={});const{x:n,y:s,platform:i,rects:a,elements:o,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=fh(e,t),m=Qce(p),x=o[f?h==="floating"?"reference":"floating":h],y=H2(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(x)))==null||r?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:u,rootBoundary:d,strategy:c})),v=h==="floating"?{x:n,y:s,width:a.floating.width,height:a.floating.height}:a.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),w=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},S=H2(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:v,offsetParent:b,strategy:c}):v);return{top:(y.top-S.top+m.top)/w.y,bottom:(S.bottom-y.bottom+m.bottom)/w.y,left:(y.left-S.left+m.left)/w.x,right:(S.right-y.right+m.right)/w.x}}const MOe=t=>({name:"arrow",options:t,async fn(e){const{x:r,y:n,placement:s,rects:i,platform:a,elements:o,middlewareData:c}=e,{element:u,padding:d=0}=fh(t,e)||{};if(u==null)return{};const h=Qce(d),f={x:r,y:n},p=DH(s),m=MH(p),g=await a.getDimensions(u),x=p==="y",y=x?"top":"left",v=x?"bottom":"right",b=x?"clientHeight":"clientWidth",w=i.reference[m]+i.reference[p]-f[p]-i.floating[m],S=f[p]-i.reference[p],k=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let E=k?k[b]:0;(!E||!await(a.isElement==null?void 0:a.isElement(k)))&&(E=o.floating[b]||i.floating[m]);const C=w/2-S/2,A=E/2-g[m]/2-1,M=zp(h[y],A),z=zp(h[v],A),P=M,W=E-g[m]-z,N=E/2-g[m]/2+C,U=A$(P,N,W),K=!c.arrow&&zw(s)!=null&&N!==U&&i.reference[m]/2-(N<P?M:z)-g[m]/2<0,G=K?N<P?N-P:N-W:0;return{[p]:f[p]+G,data:{[p]:U,centerOffset:N-U-G,...K&&{alignmentOffset:G}},reset:K}}}),DOe=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var r,n;const{placement:s,middlewareData:i,rects:a,initialPlacement:o,platform:c,elements:u}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...x}=fh(t,e);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const y=ph(s),v=pu(o),b=ph(o)===o,w=await(c.isRTL==null?void 0:c.isRTL(u.floating)),S=f||(b||!g?[U2(o)]:AOe(o)),k=m!=="none";!f&&k&&S.push(...OOe(o,g,m,w));const E=[o,...S],C=await nj(e,x),A=[];let M=((n=i.flip)==null?void 0:n.overflows)||[];if(d&&A.push(C[y]),h){const N=EOe(s,a,w);A.push(C[N[0]],C[N[1]])}if(M=[...M,{placement:s,overflows:A}],!A.every(N=>N<=0)){var z,P;const N=(((z=i.flip)==null?void 0:z.index)||0)+1,U=E[N];if(U&&(!(h==="alignment"?v!==pu(U):!1)||M.every(X=>pu(X.placement)===v?X.overflows[0]>0:!0)))return{data:{index:N,overflows:M},reset:{placement:U}};let K=(P=M.filter(G=>G.overflows[0]<=0).sort((G,X)=>G.overflows[1]-X.overflows[1])[0])==null?void 0:P.placement;if(!K)switch(p){case"bestFit":{var W;const G=(W=M.filter(X=>{if(k){const H=pu(X.placement);return H===v||H==="y"}return!0}).map(X=>[X.placement,X.overflows.filter(H=>H>0).reduce((H,B)=>H+B,0)]).sort((X,H)=>X[1]-H[1])[0])==null?void 0:W[0];G&&(K=G);break}case"initialPlacement":K=o;break}if(s!==K)return{reset:{placement:K}}}return{}}}};function oK(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function lK(t){return _Oe.some(e=>t[e]>=0)}const LOe=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:r}=e,{strategy:n="referenceHidden",...s}=fh(t,e);switch(n){case"referenceHidden":{const i=await nj(e,{...s,elementContext:"reference"}),a=oK(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:lK(a)}}}case"escaped":{const i=await nj(e,{...s,altBoundary:!0}),a=oK(i,r.floating);return{data:{escapedOffsets:a,escaped:lK(a)}}}default:return{}}}}},Zce=new Set(["left","top"]);async function FOe(t,e){const{placement:r,platform:n,elements:s}=t,i=await(n.isRTL==null?void 0:n.isRTL(s.floating)),a=ph(r),o=zw(r),c=pu(r)==="y",u=Zce.has(a)?-1:1,d=i&&c?-1:1,h=fh(e,t);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return o&&typeof m=="number"&&(p=o==="end"?m*-1:m),c?{x:p*d,y:f*u}:{x:f*u,y:p*d}}const $Oe=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var r,n;const{x:s,y:i,placement:a,middlewareData:o}=e,c=await FOe(e,t);return a===((r=o.offset)==null?void 0:r.placement)&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:s+c.x,y:i+c.y,data:{...c,placement:a}}}}},BOe=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:n,placement:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:o={fn:x=>{let{x:y,y:v}=x;return{x:y,y:v}}},...c}=fh(t,e),u={x:r,y:n},d=await nj(e,c),h=pu(ph(s)),f=RH(h);let p=u[f],m=u[h];if(i){const x=f==="y"?"top":"left",y=f==="y"?"bottom":"right",v=p+d[x],b=p-d[y];p=A$(v,p,b)}if(a){const x=h==="y"?"top":"left",y=h==="y"?"bottom":"right",v=m+d[x],b=m-d[y];m=A$(v,m,b)}const g=o.fn({...e,[f]:p,[h]:m});return{...g,data:{x:g.x-r,y:g.y-n,enabled:{[f]:i,[h]:a}}}}}},zOe=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:r,y:n,placement:s,rects:i,middlewareData:a}=e,{offset:o=0,mainAxis:c=!0,crossAxis:u=!0}=fh(t,e),d={x:r,y:n},h=pu(s),f=RH(h);let p=d[f],m=d[h];const g=fh(o,e),x=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(c){const b=f==="y"?"height":"width",w=i.reference[f]-i.floating[b]+x.mainAxis,S=i.reference[f]+i.reference[b]-x.mainAxis;p<w?p=w:p>S&&(p=S)}if(u){var y,v;const b=f==="y"?"width":"height",w=Zce.has(ph(s)),S=i.reference[h]-i.floating[b]+(w&&((y=a.offset)==null?void 0:y[h])||0)+(w?0:x.crossAxis),k=i.reference[h]+i.reference[b]+(w?0:((v=a.offset)==null?void 0:v[h])||0)-(w?x.crossAxis:0);m<S?m=S:m>k&&(m=k)}return{[f]:p,[h]:m}}}},UOe=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var r,n;const{placement:s,rects:i,platform:a,elements:o}=e,{apply:c=()=>{},...u}=fh(t,e),d=await nj(e,u),h=ph(s),f=zw(s),p=pu(s)==="y",{width:m,height:g}=i.floating;let x,y;h==="top"||h==="bottom"?(x=h,y=f===(await(a.isRTL==null?void 0:a.isRTL(o.floating))?"start":"end")?"left":"right"):(y=h,x=f==="end"?"top":"bottom");const v=g-d.top-d.bottom,b=m-d.left-d.right,w=zp(g-d[x],v),S=zp(m-d[y],b),k=!e.middlewareData.shift;let E=w,C=S;if((r=e.middlewareData.shift)!=null&&r.enabled.x&&(C=b),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(E=v),k&&!f){const M=_o(d.left,0),z=_o(d.right,0),P=_o(d.top,0),W=_o(d.bottom,0);p?C=m-2*(M!==0||z!==0?M+z:_o(d.left,d.right)):E=g-2*(P!==0||W!==0?P+W:_o(d.top,d.bottom))}await c({...e,availableWidth:C,availableHeight:E});const A=await a.getDimensions(o.floating);return m!==A.width||g!==A.height?{reset:{rects:!0}}:{}}}};function tR(){return typeof window<"u"}function Uw(t){return eue(t)?(t.nodeName||"").toLowerCase():"#document"}function Co(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ru(t){var e;return(e=(eue(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function eue(t){return tR()?t instanceof Node||t instanceof Co(t).Node:!1}function xc(t){return tR()?t instanceof Element||t instanceof Co(t).Element:!1}function Eu(t){return tR()?t instanceof HTMLElement||t instanceof Co(t).HTMLElement:!1}function cK(t){return!tR()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Co(t).ShadowRoot}const HOe=new Set(["inline","contents"]);function iE(t){const{overflow:e,overflowX:r,overflowY:n,display:s}=vc(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+r)&&!HOe.has(s)}const VOe=new Set(["table","td","th"]);function WOe(t){return VOe.has(Uw(t))}const qOe=[":popover-open",":modal"];function rR(t){return qOe.some(e=>{try{return t.matches(e)}catch{return!1}})}const GOe=["transform","translate","scale","rotate","perspective"],KOe=["transform","translate","scale","rotate","perspective","filter"],YOe=["paint","layout","strict","content"];function LH(t){const e=FH(),r=xc(t)?vc(t):t;return GOe.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!e&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!e&&(r.filter?r.filter!=="none":!1)||KOe.some(n=>(r.willChange||"").includes(n))||YOe.some(n=>(r.contain||"").includes(n))}function XOe(t){let e=Up(t);for(;Eu(e)&&!H0(e);){if(LH(e))return e;if(rR(e))return null;e=Up(e)}return null}function FH(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const JOe=new Set(["html","body","#document"]);function H0(t){return JOe.has(Uw(t))}function vc(t){return Co(t).getComputedStyle(t)}function nR(t){return xc(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Up(t){if(Uw(t)==="html")return t;const e=t.assignedSlot||t.parentNode||cK(t)&&t.host||Ru(t);return cK(e)?e.host:e}function tue(t){const e=Up(t);return H0(e)?t.ownerDocument?t.ownerDocument.body:t.body:Eu(e)&&iE(e)?e:tue(e)}function sj(t,e,r){var n;e===void 0&&(e=[]),r===void 0&&(r=!0);const s=tue(t),i=s===((n=t.ownerDocument)==null?void 0:n.body),a=Co(s);if(i){const o=T$(a);return e.concat(a,a.visualViewport||[],iE(s)?s:[],o&&r?sj(o):[])}return e.concat(s,sj(s,[],r))}function T$(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function rue(t){const e=vc(t);let r=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=Eu(t),i=s?t.offsetWidth:r,a=s?t.offsetHeight:n,o=z2(r)!==i||z2(n)!==a;return o&&(r=i,n=a),{width:r,height:n,$:o}}function $H(t){return xc(t)?t:t.contextElement}function tb(t){const e=$H(t);if(!Eu(e))return wu(1);const r=e.getBoundingClientRect(),{width:n,height:s,$:i}=rue(e);let a=(i?z2(r.width):r.width)/n,o=(i?z2(r.height):r.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}const QOe=wu(0);function nue(t){const e=Co(t);return!FH()||!e.visualViewport?QOe:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ZOe(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==Co(t)?!1:e}function Ky(t,e,r,n){e===void 0&&(e=!1),r===void 0&&(r=!1);const s=t.getBoundingClientRect(),i=$H(t);let a=wu(1);e&&(n?xc(n)&&(a=tb(n)):a=tb(t));const o=ZOe(i,r,n)?nue(i):wu(0);let c=(s.left+o.x)/a.x,u=(s.top+o.y)/a.y,d=s.width/a.x,h=s.height/a.y;if(i){const f=Co(i),p=n&&xc(n)?Co(n):n;let m=f,g=T$(m);for(;g&&n&&p!==m;){const x=tb(g),y=g.getBoundingClientRect(),v=vc(g),b=y.left+(g.clientLeft+parseFloat(v.paddingLeft))*x.x,w=y.top+(g.clientTop+parseFloat(v.paddingTop))*x.y;c*=x.x,u*=x.y,d*=x.x,h*=x.y,c+=b,u+=w,m=Co(g),g=T$(m)}}return H2({width:d,height:h,x:c,y:u})}function sR(t,e){const r=nR(t).scrollLeft;return e?e.left+r:Ky(Ru(t)).left+r}function sue(t,e){const r=t.getBoundingClientRect(),n=r.left+e.scrollLeft-sR(t,r),s=r.top+e.scrollTop;return{x:n,y:s}}function eIe(t){let{elements:e,rect:r,offsetParent:n,strategy:s}=t;const i=s==="fixed",a=Ru(n),o=e?rR(e.floating):!1;if(n===a||o&&i)return r;let c={scrollLeft:0,scrollTop:0},u=wu(1);const d=wu(0),h=Eu(n);if((h||!h&&!i)&&((Uw(n)!=="body"||iE(a))&&(c=nR(n)),Eu(n))){const p=Ky(n);u=tb(n),d.x=p.x+n.clientLeft,d.y=p.y+n.clientTop}const f=a&&!h&&!i?sue(a,c):wu(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-c.scrollLeft*u.x+d.x+f.x,y:r.y*u.y-c.scrollTop*u.y+d.y+f.y}}function tIe(t){return Array.from(t.getClientRects())}function rIe(t){const e=Ru(t),r=nR(t),n=t.ownerDocument.body,s=_o(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=_o(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let a=-r.scrollLeft+sR(t);const o=-r.scrollTop;return vc(n).direction==="rtl"&&(a+=_o(e.clientWidth,n.clientWidth)-s),{width:s,height:i,x:a,y:o}}const uK=25;function nIe(t,e){const r=Co(t),n=Ru(t),s=r.visualViewport;let i=n.clientWidth,a=n.clientHeight,o=0,c=0;if(s){i=s.width,a=s.height;const d=FH();(!d||d&&e==="fixed")&&(o=s.offsetLeft,c=s.offsetTop)}const u=sR(n);if(u<=0){const d=n.ownerDocument,h=d.body,f=getComputedStyle(h),p=d.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(n.clientWidth-h.clientWidth-p);m<=uK&&(i-=m)}else u<=uK&&(i+=u);return{width:i,height:a,x:o,y:c}}const sIe=new Set(["absolute","fixed"]);function iIe(t,e){const r=Ky(t,!0,e==="fixed"),n=r.top+t.clientTop,s=r.left+t.clientLeft,i=Eu(t)?tb(t):wu(1),a=t.clientWidth*i.x,o=t.clientHeight*i.y,c=s*i.x,u=n*i.y;return{width:a,height:o,x:c,y:u}}function dK(t,e,r){let n;if(e==="viewport")n=nIe(t,r);else if(e==="document")n=rIe(Ru(t));else if(xc(e))n=iIe(e,r);else{const s=nue(t);n={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return H2(n)}function iue(t,e){const r=Up(t);return r===e||!xc(r)||H0(r)?!1:vc(r).position==="fixed"||iue(r,e)}function aIe(t,e){const r=e.get(t);if(r)return r;let n=sj(t,[],!1).filter(o=>xc(o)&&Uw(o)!=="body"),s=null;const i=vc(t).position==="fixed";let a=i?Up(t):t;for(;xc(a)&&!H0(a);){const o=vc(a),c=LH(a);!c&&o.position==="fixed"&&(s=null),(i?!c&&!s:!c&&o.position==="static"&&!!s&&sIe.has(s.position)||iE(a)&&!c&&iue(t,a))?n=n.filter(d=>d!==a):s=o,a=Up(a)}return e.set(t,n),n}function oIe(t){let{element:e,boundary:r,rootBoundary:n,strategy:s}=t;const a=[...r==="clippingAncestors"?rR(e)?[]:aIe(e,this._c):[].concat(r),n],o=a[0],c=a.reduce((u,d)=>{const h=dK(e,d,s);return u.top=_o(h.top,u.top),u.right=zp(h.right,u.right),u.bottom=zp(h.bottom,u.bottom),u.left=_o(h.left,u.left),u},dK(e,o,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function lIe(t){const{width:e,height:r}=rue(t);return{width:e,height:r}}function cIe(t,e,r){const n=Eu(e),s=Ru(e),i=r==="fixed",a=Ky(t,!0,i,e);let o={scrollLeft:0,scrollTop:0};const c=wu(0);function u(){c.x=sR(s)}if(n||!n&&!i)if((Uw(e)!=="body"||iE(s))&&(o=nR(e)),n){const p=Ky(e,!0,i,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else s&&u();i&&!n&&s&&u();const d=s&&!n&&!i?sue(s,o):wu(0),h=a.left+o.scrollLeft-c.x-d.x,f=a.top+o.scrollTop-c.y-d.y;return{x:h,y:f,width:a.width,height:a.height}}function uL(t){return vc(t).position==="static"}function hK(t,e){if(!Eu(t)||vc(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return Ru(t)===r&&(r=r.ownerDocument.body),r}function aue(t,e){const r=Co(t);if(rR(t))return r;if(!Eu(t)){let s=Up(t);for(;s&&!H0(s);){if(xc(s)&&!uL(s))return s;s=Up(s)}return r}let n=hK(t,e);for(;n&&WOe(n)&&uL(n);)n=hK(n,e);return n&&H0(n)&&uL(n)&&!LH(n)?r:n||XOe(t)||r}const uIe=async function(t){const e=this.getOffsetParent||aue,r=this.getDimensions,n=await r(t.floating);return{reference:cIe(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function dIe(t){return vc(t).direction==="rtl"}const hIe={convertOffsetParentRelativeRectToViewportRelativeRect:eIe,getDocumentElement:Ru,getClippingRect:oIe,getOffsetParent:aue,getElementRects:uIe,getClientRects:tIe,getDimensions:lIe,getScale:tb,isElement:xc,isRTL:dIe};function oue(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function fIe(t,e){let r=null,n;const s=Ru(t);function i(){var o;clearTimeout(n),(o=r)==null||o.disconnect(),r=null}function a(o,c){o===void 0&&(o=!1),c===void 0&&(c=1),i();const u=t.getBoundingClientRect(),{left:d,top:h,width:f,height:p}=u;if(o||e(),!f||!p)return;const m=AA(h),g=AA(s.clientWidth-(d+f)),x=AA(s.clientHeight-(h+p)),y=AA(d),b={rootMargin:-m+"px "+-g+"px "+-x+"px "+-y+"px",threshold:_o(0,zp(1,c))||1};let w=!0;function S(k){const E=k[0].intersectionRatio;if(E!==c){if(!w)return a();E?a(!1,E):n=setTimeout(()=>{a(!1,1e-7)},1e3)}E===1&&!oue(u,t.getBoundingClientRect())&&a(),w=!1}try{r=new IntersectionObserver(S,{...b,root:s.ownerDocument})}catch{r=new IntersectionObserver(S,b)}r.observe(t)}return a(!0),i}function pIe(t,e,r,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=$H(t),d=s||i?[...u?sj(u):[],...sj(e)]:[];d.forEach(y=>{s&&y.addEventListener("scroll",r,{passive:!0}),i&&y.addEventListener("resize",r)});const h=u&&o?fIe(u,r):null;let f=-1,p=null;a&&(p=new ResizeObserver(y=>{let[v]=y;v&&v.target===u&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(e)})),r()}),u&&!c&&p.observe(u),p.observe(e));let m,g=c?Ky(t):null;c&&x();function x(){const y=Ky(t);g&&!oue(g,y)&&r(),g=y,m=requestAnimationFrame(x)}return r(),()=>{var y;d.forEach(v=>{s&&v.removeEventListener("scroll",r),i&&v.removeEventListener("resize",r)}),h==null||h(),(y=p)==null||y.disconnect(),p=null,c&&cancelAnimationFrame(m)}}const mIe=$Oe,gIe=BOe,yIe=DOe,xIe=UOe,vIe=LOe,fK=MOe,bIe=zOe,wIe=(t,e,r)=>{const n=new Map,s={platform:hIe,...r},i={...s.platform,_c:n};return ROe(t,e,{...s,platform:i})};var SIe=typeof document<"u",_Ie=function(){},lT=SIe?j.useLayoutEffect:_Ie;function V2(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 r,n,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(r=t.length,r!==e.length)return!1;for(n=r;n--!==0;)if(!V2(t[n],e[n]))return!1;return!0}if(s=Object.keys(t),r=s.length,r!==Object.keys(e).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(e,s[n]))return!1;for(n=r;n--!==0;){const i=s[n];if(!(i==="_owner"&&t.$$typeof)&&!V2(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function lue(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function pK(t,e){const r=lue(t);return Math.round(e*r)/r}function dL(t){const e=j.useRef(t);return lT(()=>{e.current=t}),e}function jIe(t){t===void 0&&(t={});const{placement:e="bottom",strategy:r="absolute",middleware:n=[],platform:s,elements:{reference:i,floating:a}={},transform:o=!0,whileElementsMounted:c,open:u}=t,[d,h]=j.useState({x:0,y:0,strategy:r,placement:e,middlewareData:{},isPositioned:!1}),[f,p]=j.useState(n);V2(f,n)||p(n);const[m,g]=j.useState(null),[x,y]=j.useState(null),v=j.useCallback(X=>{X!==k.current&&(k.current=X,g(X))},[]),b=j.useCallback(X=>{X!==E.current&&(E.current=X,y(X))},[]),w=i||m,S=a||x,k=j.useRef(null),E=j.useRef(null),C=j.useRef(d),A=c!=null,M=dL(c),z=dL(s),P=dL(u),W=j.useCallback(()=>{if(!k.current||!E.current)return;const X={placement:e,strategy:r,middleware:f};z.current&&(X.platform=z.current),wIe(k.current,E.current,X).then(H=>{const B={...H,isPositioned:P.current!==!1};N.current&&!V2(C.current,B)&&(C.current=B,Iu.flushSync(()=>{h(B)}))})},[f,e,r,z,P]);lT(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,h(X=>({...X,isPositioned:!1})))},[u]);const N=j.useRef(!1);lT(()=>(N.current=!0,()=>{N.current=!1}),[]),lT(()=>{if(w&&(k.current=w),S&&(E.current=S),w&&S){if(M.current)return M.current(w,S,W);W()}},[w,S,W,M,A]);const U=j.useMemo(()=>({reference:k,floating:E,setReference:v,setFloating:b}),[v,b]),K=j.useMemo(()=>({reference:w,floating:S}),[w,S]),G=j.useMemo(()=>{const X={position:r,left:0,top:0};if(!K.floating)return X;const H=pK(K.floating,d.x),B=pK(K.floating,d.y);return o?{...X,transform:"translate("+H+"px, "+B+"px)",...lue(K.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:H,top:B}},[r,o,K.floating,d.x,d.y]);return j.useMemo(()=>({...d,update:W,refs:U,elements:K,floatingStyles:G}),[d,W,U,K,G])}const kIe=t=>{function e(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:t,fn(r){const{element:n,padding:s}=typeof t=="function"?t(r):t;return n&&e(n)?n.current!=null?fK({element:n.current,padding:s}).fn(r):{}:n?fK({element:n,padding:s}).fn(r):{}}}},NIe=(t,e)=>({...mIe(t),options:[t,e]}),EIe=(t,e)=>({...gIe(t),options:[t,e]}),AIe=(t,e)=>({...bIe(t),options:[t,e]}),CIe=(t,e)=>({...yIe(t),options:[t,e]}),TIe=(t,e)=>({...xIe(t),options:[t,e]}),PIe=(t,e)=>({...vIe(t),options:[t,e]}),OIe=(t,e)=>({...kIe(t),options:[t,e]});var IIe="Arrow",cue=j.forwardRef((t,e)=>{const{children:r,width:n=10,height:s=5,...i}=t;return l.jsx(ot.svg,{...i,ref:e,width:n,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});cue.displayName=IIe;var RIe=cue;function BH(t){const[e,r]=j.useState(void 0);return Wn(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const i=s[0];let a,o;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,o=u.blockSize}else a=t.offsetWidth,o=t.offsetHeight;r({width:a,height:o})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),e}var zH="Popper",[uue,nm]=gs(zH),[MIe,due]=uue(zH),hue=t=>{const{__scopePopper:e,children:r}=t,[n,s]=j.useState(null);return l.jsx(MIe,{scope:e,anchor:n,onAnchorChange:s,children:r})};hue.displayName=zH;var fue="PopperAnchor",pue=j.forwardRef((t,e)=>{const{__scopePopper:r,virtualRef:n,...s}=t,i=due(fue,r),a=j.useRef(null),o=It(e,a);return j.useEffect(()=>{i.onAnchorChange((n==null?void 0:n.current)||a.current)}),n?null:l.jsx(ot.div,{...s,ref:o})});pue.displayName=fue;var UH="PopperContent",[DIe,LIe]=uue(UH),mue=j.forwardRef((t,e)=>{var D,R,J,Z,ee,re;const{__scopePopper:r,side:n="bottom",sideOffset:s=0,align:i="center",alignOffset:a=0,arrowPadding:o=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:m,...g}=t,x=due(UH,r),[y,v]=j.useState(null),b=It(e,he=>v(he)),[w,S]=j.useState(null),k=BH(w),E=(k==null?void 0:k.width)??0,C=(k==null?void 0:k.height)??0,A=n+(i!=="center"?"-"+i:""),M=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},z=Array.isArray(u)?u:[u],P=z.length>0,W={padding:M,boundary:z.filter($Ie),altBoundary:P},{refs:N,floatingStyles:U,placement:K,isPositioned:G,middlewareData:X}=jIe({strategy:"fixed",placement:A,whileElementsMounted:(...he)=>pIe(...he,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[NIe({mainAxis:s+C,alignmentAxis:a}),c&&EIe({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?AIe():void 0,...W}),c&&CIe({...W}),TIe({...W,apply:({elements:he,rects:O,availableWidth:ae,availableHeight:q})=>{const{width:I,height:T}=O.reference,$=he.floating.style;$.setProperty("--radix-popper-available-width",`${ae}px`),$.setProperty("--radix-popper-available-height",`${q}px`),$.setProperty("--radix-popper-anchor-width",`${I}px`),$.setProperty("--radix-popper-anchor-height",`${T}px`)}}),w&&OIe({element:w,padding:o}),BIe({arrowWidth:E,arrowHeight:C}),f&&PIe({strategy:"referenceHidden",...W})]}),[H,B]=xue(K),L=Hn(m);Wn(()=>{G&&(L==null||L())},[G,L]);const F=(D=X.arrow)==null?void 0:D.x,V=(R=X.arrow)==null?void 0:R.y,Y=((J=X.arrow)==null?void 0:J.centerOffset)!==0,[ie,Q]=j.useState();return Wn(()=>{y&&Q(window.getComputedStyle(y).zIndex)},[y]),l.jsx("div",{ref:N.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:G?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ie,"--radix-popper-transform-origin":[(Z=X.transformOrigin)==null?void 0:Z.x,(ee=X.transformOrigin)==null?void 0:ee.y].join(" "),...((re=X.hide)==null?void 0:re.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:l.jsx(DIe,{scope:r,placedSide:H,onArrowChange:S,arrowX:F,arrowY:V,shouldHideArrow:Y,children:l.jsx(ot.div,{"data-side":H,"data-align":B,...g,ref:b,style:{...g.style,animation:G?void 0:"none"}})})})});mue.displayName=UH;var gue="PopperArrow",FIe={top:"bottom",right:"left",bottom:"top",left:"right"},yue=j.forwardRef(function(e,r){const{__scopePopper:n,...s}=e,i=LIe(gue,n),a=FIe[i.placedSide];return l.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:l.jsx(RIe,{...s,ref:r,style:{...s.style,display:"block"}})})});yue.displayName=gue;function $Ie(t){return t!==null}var BIe=t=>({name:"transformOrigin",options:t,fn(e){var x,y,v;const{placement:r,rects:n,middlewareData:s}=e,a=((x=s.arrow)==null?void 0:x.centerOffset)!==0,o=a?0:t.arrowWidth,c=a?0:t.arrowHeight,[u,d]=xue(r),h={start:"0%",center:"50%",end:"100%"}[d],f=(((y=s.arrow)==null?void 0:y.x)??0)+o/2,p=(((v=s.arrow)==null?void 0:v.y)??0)+c/2;let m="",g="";return u==="bottom"?(m=a?h:`${f}px`,g=`${-c}px`):u==="top"?(m=a?h:`${f}px`,g=`${n.floating.height+c}px`):u==="right"?(m=`${-c}px`,g=a?h:`${p}px`):u==="left"&&(m=`${n.floating.width+c}px`,g=a?h:`${p}px`),{data:{x:m,y:g}}}});function xue(t){const[e,r="center"]=t.split("-");return[e,r]}var iR=hue,aE=pue,aR=mue,oR=yue,[lR,G4t]=gs("Tooltip",[nm]),cR=nm(),vue="TooltipProvider",zIe=700,P$="tooltip.open",[UIe,HH]=lR(vue),bue=t=>{const{__scopeTooltip:e,delayDuration:r=zIe,skipDelayDuration:n=300,disableHoverableContent:s=!1,children:i}=t,a=j.useRef(!0),o=j.useRef(!1),c=j.useRef(0);return j.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),l.jsx(UIe,{scope:e,isOpenDelayedRef:a,delayDuration:r,onOpen:j.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:j.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,n)},[n]),isPointerInTransitRef:o,onPointerInTransitChange:j.useCallback(u=>{o.current=u},[]),disableHoverableContent:s,children:i})};bue.displayName=vue;var ij="Tooltip",[HIe,uR]=lR(ij),wue=t=>{const{__scopeTooltip:e,children:r,open:n,defaultOpen:s,onOpenChange:i,disableHoverableContent:a,delayDuration:o}=t,c=HH(ij,t.__scopeTooltip),u=cR(e),[d,h]=j.useState(null),f=Ka(),p=j.useRef(0),m=a??c.disableHoverableContent,g=o??c.delayDuration,x=j.useRef(!1),[y,v]=_i({prop:n,defaultProp:s??!1,onChange:E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(P$))):c.onClose(),i==null||i(E)},caller:ij}),b=j.useMemo(()=>y?x.current?"delayed-open":"instant-open":"closed",[y]),w=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x.current=!1,v(!0)},[v]),S=j.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),k=j.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{x.current=!0,v(!0),p.current=0},g)},[g,v]);return j.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),l.jsx(iR,{...u,children:l.jsx(HIe,{scope:e,contentId:f,open:y,stateAttribute:b,trigger:d,onTriggerChange:h,onTriggerEnter:j.useCallback(()=>{c.isOpenDelayedRef.current?k():w()},[c.isOpenDelayedRef,k,w]),onTriggerLeave:j.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:w,onClose:S,disableHoverableContent:m,children:r})})};wue.displayName=ij;var O$="TooltipTrigger",Sue=j.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=uR(O$,r),i=HH(O$,r),a=cR(r),o=j.useRef(null),c=It(e,o,s.onTriggerChange),u=j.useRef(!1),d=j.useRef(!1),h=j.useCallback(()=>u.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),l.jsx(aE,{asChild:!0,...a,children:l.jsx(ot.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:c,onPointerMove:Ke(t.onPointerMove,f=>{f.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(s.onTriggerEnter(),d.current=!0)}),onPointerLeave:Ke(t.onPointerLeave,()=>{s.onTriggerLeave(),d.current=!1}),onPointerDown:Ke(t.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ke(t.onFocus,()=>{u.current||s.onOpen()}),onBlur:Ke(t.onBlur,s.onClose),onClick:Ke(t.onClick,s.onClose)})})});Sue.displayName=O$;var VIe="TooltipPortal",[K4t,WIe]=lR(VIe,{forceMount:void 0}),V0="TooltipContent",_ue=j.forwardRef((t,e)=>{const r=WIe(V0,t.__scopeTooltip),{forceMount:n=r.forceMount,side:s="top",...i}=t,a=uR(V0,t.__scopeTooltip);return l.jsx(Os,{present:n||a.open,children:a.disableHoverableContent?l.jsx(jue,{side:s,...i,ref:e}):l.jsx(qIe,{side:s,...i,ref:e})})}),qIe=j.forwardRef((t,e)=>{const r=uR(V0,t.__scopeTooltip),n=HH(V0,t.__scopeTooltip),s=j.useRef(null),i=It(e,s),[a,o]=j.useState(null),{trigger:c,onClose:u}=r,d=s.current,{onPointerInTransitChange:h}=n,f=j.useCallback(()=>{o(null),h(!1)},[h]),p=j.useCallback((m,g)=>{const x=m.currentTarget,y={x:m.clientX,y:m.clientY},v=JIe(y,x.getBoundingClientRect()),b=QIe(y,v),w=ZIe(g.getBoundingClientRect()),S=tRe([...b,...w]);o(S),h(!0)},[h]);return j.useEffect(()=>()=>f(),[f]),j.useEffect(()=>{if(c&&d){const m=x=>p(x,d),g=x=>p(x,c);return c.addEventListener("pointerleave",m),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",m),d.removeEventListener("pointerleave",g)}}},[c,d,p,f]),j.useEffect(()=>{if(a){const m=g=>{const x=g.target,y={x:g.clientX,y:g.clientY},v=(c==null?void 0:c.contains(x))||(d==null?void 0:d.contains(x)),b=!eRe(y,a);v?f():b&&(f(),u())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[c,d,a,u,f]),l.jsx(jue,{...t,ref:i})}),[GIe,KIe]=lR(ij,{isInside:!1}),YIe=tce("TooltipContent"),jue=j.forwardRef((t,e)=>{const{__scopeTooltip:r,children:n,"aria-label":s,onEscapeKeyDown:i,onPointerDownOutside:a,...o}=t,c=uR(V0,r),u=cR(r),{onClose:d}=c;return j.useEffect(()=>(document.addEventListener(P$,d),()=>document.removeEventListener(P$,d)),[d]),j.useEffect(()=>{if(c.trigger){const h=f=>{const p=f.target;p!=null&&p.contains(c.trigger)&&d()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,d]),l.jsx(mx,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:l.jsxs(aR,{"data-state":c.stateAttribute,...u,...o,ref:e,style:{...o.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[l.jsx(YIe,{children:n}),l.jsx(GIe,{scope:r,isInside:!0,children:l.jsx(OTe,{id:c.contentId,role:"tooltip",children:s||n})})]})})});_ue.displayName=V0;var kue="TooltipArrow",XIe=j.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=cR(r);return KIe(kue,r).isInside?null:l.jsx(oR,{...s,...n,ref:e})});XIe.displayName=kue;function JIe(t,e){const r=Math.abs(e.top-t.y),n=Math.abs(e.bottom-t.y),s=Math.abs(e.right-t.x),i=Math.abs(e.left-t.x);switch(Math.min(r,n,s,i)){case i:return"left";case s:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function QIe(t,e,r=5){const n=[];switch(e){case"top":n.push({x:t.x-r,y:t.y+r},{x:t.x+r,y:t.y+r});break;case"bottom":n.push({x:t.x-r,y:t.y-r},{x:t.x+r,y:t.y-r});break;case"left":n.push({x:t.x+r,y:t.y-r},{x:t.x+r,y:t.y+r});break;case"right":n.push({x:t.x-r,y:t.y-r},{x:t.x-r,y:t.y+r});break}return n}function ZIe(t){const{top:e,right:r,bottom:n,left:s}=t;return[{x:s,y:e},{x:r,y:e},{x:r,y:n},{x:s,y:n}]}function eRe(t,e){const{x:r,y:n}=t;let s=!1;for(let i=0,a=e.length-1;i<e.length;a=i++){const o=e[i],c=e[a],u=o.x,d=o.y,h=c.x,f=c.y;d>n!=f>n&&r<(h-u)*(n-d)/(f-d)+u&&(s=!s)}return s}function tRe(t){const e=t.slice();return e.sort((r,n)=>r.x<n.x?-1:r.x>n.x?1:r.y<n.y?-1:r.y>n.y?1:0),rRe(e)}function rRe(t){if(t.length<=1)return t.slice();const e=[];for(let n=0;n<t.length;n++){const s=t[n];for(;e.length>=2;){const i=e[e.length-1],a=e[e.length-2];if((i.x-a.x)*(s.y-a.y)>=(i.y-a.y)*(s.x-a.x))e.pop();else break}e.push(s)}e.pop();const r=[];for(let n=t.length-1;n>=0;n--){const s=t[n];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(s.y-a.y)>=(i.y-a.y)*(s.x-a.x))r.pop();else break}r.push(s)}return r.pop(),e.length===1&&r.length===1&&e[0].x===r[0].x&&e[0].y===r[0].y?e:e.concat(r)}var nRe=bue,sRe=wue,iRe=Sue,Nue=_ue;const Zs=nRe,rr=sRe,nr=iRe,Qt=j.forwardRef(({className:t,sideOffset:e=4,...r},n)=>l.jsx(Nue,{ref:n,sideOffset:e,className:Le("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));Qt.displayName=Nue.displayName;var Hw=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Yy=typeof window>"u"||"Deno"in globalThis;function ua(){}function aRe(t,e){return typeof t=="function"?t(e):t}function I$(t){return typeof t=="number"&&t>=0&&t!==1/0}function Eue(t,e){return Math.max(t+(e||0)-Date.now(),0)}function kp(t,e){return typeof t=="function"?t(e):t}function rl(t,e){return typeof t=="function"?t(e):t}function mK(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:i,queryKey:a,stale:o}=t;if(a){if(n){if(e.queryHash!==VH(a,e.options))return!1}else if(!aj(e.queryKey,a))return!1}if(r!=="all"){const c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||s&&s!==e.state.fetchStatus||i&&!i(e))}function gK(t,e){const{exact:r,status:n,predicate:s,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(Xy(e.options.mutationKey)!==Xy(i))return!1}else if(!aj(e.options.mutationKey,i))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function VH(t,e){return((e==null?void 0:e.queryKeyHashFn)||Xy)(t)}function Xy(t){return JSON.stringify(t,(e,r)=>R$(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function aj(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>aj(t[r],e[r])):!1}function Aue(t,e){if(t===e)return t;const r=yK(t)&&yK(e);if(r||R$(t)&&R$(e)){const n=r?t:Object.keys(t),s=n.length,i=r?e:Object.keys(e),a=i.length,o=r?[]:{},c=new Set(n);let u=0;for(let d=0;d<a;d++){const h=r?d:i[d];(!r&&c.has(h)||r)&&t[h]===void 0&&e[h]===void 0?(o[h]=void 0,u++):(o[h]=Aue(t[h],e[h]),o[h]===t[h]&&t[h]!==void 0&&u++)}return s===a&&u===s?t:o}return e}function W2(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const r in t)if(t[r]!==e[r])return!1;return!0}function yK(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function R$(t){if(!xK(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!xK(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function xK(t){return Object.prototype.toString.call(t)==="[object Object]"}function oRe(t){return new Promise(e=>{setTimeout(e,t)})}function M$(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Aue(t,e):e}function lRe(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function cRe(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var WH=Symbol();function Cue(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===WH?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Tue(t,e){return typeof t=="function"?t(...e):!!t}var fg,gf,mb,bae,uRe=(bae=class extends Hw{constructor(){super();le(this,fg);le(this,gf);le(this,mb);te(this,mb,e=>{if(!Yy&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){_(this,gf)||this.setEventListener(_(this,mb))}onUnsubscribe(){var e;this.hasListeners()||((e=_(this,gf))==null||e.call(this),te(this,gf,void 0))}setEventListener(e){var r;te(this,mb,e),(r=_(this,gf))==null||r.call(this),te(this,gf,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){_(this,fg)!==e&&(te(this,fg,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof _(this,fg)=="boolean"?_(this,fg):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},fg=new WeakMap,gf=new WeakMap,mb=new WeakMap,bae),qH=new uRe,gb,yf,yb,wae,dRe=(wae=class extends Hw{constructor(){super();le(this,gb,!0);le(this,yf);le(this,yb);te(this,yb,e=>{if(!Yy&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){_(this,yf)||this.setEventListener(_(this,yb))}onUnsubscribe(){var e;this.hasListeners()||((e=_(this,yf))==null||e.call(this),te(this,yf,void 0))}setEventListener(e){var r;te(this,yb,e),(r=_(this,yf))==null||r.call(this),te(this,yf,e(this.setOnline.bind(this)))}setOnline(e){_(this,gb)!==e&&(te(this,gb,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return _(this,gb)}},gb=new WeakMap,yf=new WeakMap,yb=new WeakMap,wae),q2=new dRe;function D$(){let t,e;const r=new Promise((s,i)=>{t=s,e=i});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function hRe(t){return Math.min(1e3*2**t,3e4)}function Pue(t){return(t??"online")==="online"?q2.isOnline():!0}var Oue=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function hL(t){return t instanceof Oue}function Iue(t){let e=!1,r=0,n=!1,s;const i=D$(),a=g=>{var x;n||(f(new Oue(g)),(x=t.abort)==null||x.call(t))},o=()=>{e=!0},c=()=>{e=!1},u=()=>qH.isFocused()&&(t.networkMode==="always"||q2.isOnline())&&t.canRun(),d=()=>Pue(t.networkMode)&&t.canRun(),h=g=>{var x;n||(n=!0,(x=t.onSuccess)==null||x.call(t,g),s==null||s(),i.resolve(g))},f=g=>{var x;n||(n=!0,(x=t.onError)==null||x.call(t,g),s==null||s(),i.reject(g))},p=()=>new Promise(g=>{var x;s=y=>{(n||u())&&g(y)},(x=t.onPause)==null||x.call(t)}).then(()=>{var g;s=void 0,n||(g=t.onContinue)==null||g.call(t)}),m=()=>{if(n)return;let g;const x=r===0?t.initialPromise:void 0;try{g=x??t.fn()}catch(y){g=Promise.reject(y)}Promise.resolve(g).then(h).catch(y=>{var k;if(n)return;const v=t.retry??(Yy?0:3),b=t.retryDelay??hRe,w=typeof b=="function"?b(r,y):b,S=v===!0||typeof v=="number"&&r<v||typeof v=="function"&&v(r,y);if(e||!S){f(y);return}r++,(k=t.onFail)==null||k.call(t,r,y),oRe(w).then(()=>u()?void 0:p()).then(()=>{e?f(y):m()})})};return{promise:i,cancel:a,continue:()=>(s==null||s(),i),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?m():p().then(m),i)}}var fRe=t=>setTimeout(t,0);function pRe(){let t=[],e=0,r=o=>{o()},n=o=>{o()},s=fRe;const i=o=>{e?t.push(o):s(()=>{r(o)})},a=()=>{const o=t;t=[],o.length&&s(()=>{n(()=>{o.forEach(c=>{r(c)})})})};return{batch:o=>{let c;e++;try{c=o()}finally{e--,e||a()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{r=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{s=o}}}var Ns=pRe(),pg,Sae,Rue=(Sae=class{constructor(){le(this,pg)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),I$(this.gcTime)&&te(this,pg,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Yy?1/0:5*60*1e3))}clearGcTimeout(){_(this,pg)&&(clearTimeout(_(this,pg)),te(this,pg,void 0))}},pg=new WeakMap,Sae),xb,mg,qo,gg,Ti,xk,yg,Hl,Xu,_ae,mRe=(_ae=class extends Rue{constructor(e){super();le(this,Hl);le(this,xb);le(this,mg);le(this,qo);le(this,gg);le(this,Ti);le(this,xk);le(this,yg);te(this,yg,!1),te(this,xk,e.defaultOptions),this.setOptions(e.options),this.observers=[],te(this,gg,e.client),te(this,qo,_(this,gg).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,te(this,xb,gRe(this.options)),this.state=e.state??_(this,xb),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=_(this,Ti))==null?void 0:e.promise}setOptions(e){this.options={..._(this,xk),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&_(this,qo).remove(this)}setData(e,r){const n=M$(this.state.data,e,this.options);return ce(this,Hl,Xu).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){ce(this,Hl,Xu).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=_(this,Ti))==null?void 0:n.promise;return(s=_(this,Ti))==null||s.cancel(e),r?r.then(ua).catch(ua):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(_(this,xb))}isActive(){return this.observers.some(e=>rl(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===WH||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>kp(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Eue(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=_(this,Ti))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=_(this,Ti))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),_(this,qo).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(_(this,Ti)&&(_(this,yg)?_(this,Ti).cancel({revert:!0}):_(this,Ti).cancelRetry()),this.scheduleGc()),_(this,qo).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ce(this,Hl,Xu).call(this,{type:"invalidate"})}fetch(e,r){var u,d,h;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(_(this,Ti))return _(this,Ti).continueRetry(),_(this,Ti).promise}if(e&&this.setOptions(e),!this.options.queryFn){const f=this.observers.find(p=>p.options.queryFn);f&&this.setOptions(f.options)}const n=new AbortController,s=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(te(this,yg,!0),n.signal)})},i=()=>{const f=Cue(this.options,r),m=(()=>{const g={client:_(this,gg),queryKey:this.queryKey,meta:this.meta};return s(g),g})();return te(this,yg,!1),this.options.persister?this.options.persister(f,m,this):f(m)},o=(()=>{const f={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:_(this,gg),state:this.state,fetchFn:i};return s(f),f})();(u=this.options.behavior)==null||u.onFetch(o,this),te(this,mg,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&ce(this,Hl,Xu).call(this,{type:"fetch",meta:(h=o.fetchOptions)==null?void 0:h.meta});const c=f=>{var p,m,g,x;hL(f)&&f.silent||ce(this,Hl,Xu).call(this,{type:"error",error:f}),hL(f)||((m=(p=_(this,qo).config).onError)==null||m.call(p,f,this),(x=(g=_(this,qo).config).onSettled)==null||x.call(g,this.state.data,f,this)),this.scheduleGc()};return te(this,Ti,Iue({initialPromise:r==null?void 0:r.initialPromise,fn:o.fetchFn,abort:n.abort.bind(n),onSuccess:f=>{var p,m,g,x;if(f===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(y){c(y);return}(m=(p=_(this,qo).config).onSuccess)==null||m.call(p,f,this),(x=(g=_(this,qo).config).onSettled)==null||x.call(g,f,this.state.error,this),this.scheduleGc()},onError:c,onFail:(f,p)=>{ce(this,Hl,Xu).call(this,{type:"failed",failureCount:f,error:p})},onPause:()=>{ce(this,Hl,Xu).call(this,{type:"pause"})},onContinue:()=>{ce(this,Hl,Xu).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0})),_(this,Ti).start()}},xb=new WeakMap,mg=new WeakMap,qo=new WeakMap,gg=new WeakMap,Ti=new WeakMap,xk=new WeakMap,yg=new WeakMap,Hl=new WeakSet,Xu=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Mue(n.data,this.options),fetchMeta:e.meta??null};case"success":return te(this,mg,void 0),{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=e.error;return hL(s)&&s.revert&&_(this,mg)?{..._(this,mg),fetchStatus:"idle"}:{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),Ns.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),_(this,qo).notify({query:this,type:"updated",action:e})})},_ae);function Mue(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Pue(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function gRe(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Hc,jae,yRe=(jae=class extends Hw{constructor(e={}){super();le(this,Hc);this.config=e,te(this,Hc,new Map)}build(e,r,n){const s=r.queryKey,i=r.queryHash??VH(s,r);let a=this.get(i);return a||(a=new mRe({client:e,queryKey:s,queryHash:i,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(a)),a}add(e){_(this,Hc).has(e.queryHash)||(_(this,Hc).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=_(this,Hc).get(e.queryHash);r&&(e.destroy(),r===e&&_(this,Hc).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Ns.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return _(this,Hc).get(e)}getAll(){return[..._(this,Hc).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>mK(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>mK(e,n)):r}notify(e){Ns.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){Ns.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ns.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Hc=new WeakMap,jae),Vc,ra,xg,Wc,Kh,kae,xRe=(kae=class extends Rue{constructor(e){super();le(this,Wc);le(this,Vc);le(this,ra);le(this,xg);this.mutationId=e.mutationId,te(this,ra,e.mutationCache),te(this,Vc,[]),this.state=e.state||Due(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){_(this,Vc).includes(e)||(_(this,Vc).push(e),this.clearGcTimeout(),_(this,ra).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){te(this,Vc,_(this,Vc).filter(r=>r!==e)),this.scheduleGc(),_(this,ra).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){_(this,Vc).length||(this.state.status==="pending"?this.scheduleGc():_(this,ra).remove(this))}continue(){var e;return((e=_(this,xg))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var i,a,o,c,u,d,h,f,p,m,g,x,y,v,b,w,S,k,E,C;const r=()=>{ce(this,Wc,Kh).call(this,{type:"continue"})};te(this,xg,Iue({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(A,M)=>{ce(this,Wc,Kh).call(this,{type:"failed",failureCount:A,error:M})},onPause:()=>{ce(this,Wc,Kh).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>_(this,ra).canRun(this)}));const n=this.state.status==="pending",s=!_(this,xg).canStart();try{if(n)r();else{ce(this,Wc,Kh).call(this,{type:"pending",variables:e,isPaused:s}),await((a=(i=_(this,ra).config).onMutate)==null?void 0:a.call(i,e,this));const M=await((c=(o=this.options).onMutate)==null?void 0:c.call(o,e));M!==this.state.context&&ce(this,Wc,Kh).call(this,{type:"pending",context:M,variables:e,isPaused:s})}const A=await _(this,xg).start();return await((d=(u=_(this,ra).config).onSuccess)==null?void 0:d.call(u,A,e,this.state.context,this)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,A,e,this.state.context)),await((m=(p=_(this,ra).config).onSettled)==null?void 0:m.call(p,A,null,this.state.variables,this.state.context,this)),await((x=(g=this.options).onSettled)==null?void 0:x.call(g,A,null,e,this.state.context)),ce(this,Wc,Kh).call(this,{type:"success",data:A}),A}catch(A){try{throw await((v=(y=_(this,ra).config).onError)==null?void 0:v.call(y,A,e,this.state.context,this)),await((w=(b=this.options).onError)==null?void 0:w.call(b,A,e,this.state.context)),await((k=(S=_(this,ra).config).onSettled)==null?void 0:k.call(S,void 0,A,this.state.variables,this.state.context,this)),await((C=(E=this.options).onSettled)==null?void 0:C.call(E,void 0,A,e,this.state.context)),A}finally{ce(this,Wc,Kh).call(this,{type:"error",error:A})}}finally{_(this,ra).runNext(this)}}},Vc=new WeakMap,ra=new WeakMap,xg=new WeakMap,Wc=new WeakSet,Kh=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),Ns.batch(()=>{_(this,Vc).forEach(n=>{n.onMutationUpdate(e)}),_(this,ra).notify({mutation:this,type:"updated",action:e})})},kae);function Due(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var dd,Vl,vk,Nae,vRe=(Nae=class extends Hw{constructor(e={}){super();le(this,dd);le(this,Vl);le(this,vk);this.config=e,te(this,dd,new Set),te(this,Vl,new Map),te(this,vk,0)}build(e,r,n){const s=new xRe({mutationCache:this,mutationId:++Ds(this,vk)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){_(this,dd).add(e);const r=CA(e);if(typeof r=="string"){const n=_(this,Vl).get(r);n?n.push(e):_(this,Vl).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(_(this,dd).delete(e)){const r=CA(e);if(typeof r=="string"){const n=_(this,Vl).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&_(this,Vl).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=CA(e);if(typeof r=="string"){const n=_(this,Vl).get(r),s=n==null?void 0:n.find(i=>i.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=CA(e);if(typeof r=="string"){const s=(n=_(this,Vl).get(r))==null?void 0:n.find(i=>i!==e&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ns.batch(()=>{_(this,dd).forEach(e=>{this.notify({type:"removed",mutation:e})}),_(this,dd).clear(),_(this,Vl).clear()})}getAll(){return Array.from(_(this,dd))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>gK(r,n))}findAll(e={}){return this.getAll().filter(r=>gK(e,r))}notify(e){Ns.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return Ns.batch(()=>Promise.all(e.map(r=>r.continue().catch(ua))))}},dd=new WeakMap,Vl=new WeakMap,vk=new WeakMap,Nae);function CA(t){var e;return(e=t.options.scope)==null?void 0:e.id}function vK(t){return{onFetch:(e,r)=>{var d,h,f,p,m;const n=e.options,s=(f=(h=(d=e.fetchOptions)==null?void 0:d.meta)==null?void 0:h.fetchMore)==null?void 0:f.direction,i=((p=e.state.data)==null?void 0:p.pages)||[],a=((m=e.state.data)==null?void 0:m.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let g=!1;const x=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?g=!0:e.signal.addEventListener("abort",()=>{g=!0}),e.signal)})},y=Cue(e.options,e.fetchOptions),v=async(b,w,S)=>{if(g)return Promise.reject();if(w==null&&b.pages.length)return Promise.resolve(b);const E=(()=>{const z={client:e.client,queryKey:e.queryKey,pageParam:w,direction:S?"backward":"forward",meta:e.options.meta};return x(z),z})(),C=await y(E),{maxPages:A}=e.options,M=S?cRe:lRe;return{pages:M(b.pages,C,A),pageParams:M(b.pageParams,w,A)}};if(s&&i.length){const b=s==="backward",w=b?bRe:bK,S={pages:i,pageParams:a},k=w(n,S);o=await v(S,k,b)}else{const b=t??i.length;do{const w=c===0?a[0]??n.initialPageParam:bK(n,o);if(c>0&&w==null)break;o=await v(o,w),c++}while(c<b)}return o};e.options.persister?e.fetchFn=()=>{var g,x;return(x=(g=e.options).persister)==null?void 0:x.call(g,u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=u}}}function bK(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function bRe(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var Mn,xf,vf,vb,bb,bf,wb,Sb,Eae,wRe=(Eae=class{constructor(t={}){le(this,Mn);le(this,xf);le(this,vf);le(this,vb);le(this,bb);le(this,bf);le(this,wb);le(this,Sb);te(this,Mn,t.queryCache||new yRe),te(this,xf,t.mutationCache||new vRe),te(this,vf,t.defaultOptions||{}),te(this,vb,new Map),te(this,bb,new Map),te(this,bf,0)}mount(){Ds(this,bf)._++,_(this,bf)===1&&(te(this,wb,qH.subscribe(async t=>{t&&(await this.resumePausedMutations(),_(this,Mn).onFocus())})),te(this,Sb,q2.subscribe(async t=>{t&&(await this.resumePausedMutations(),_(this,Mn).onOnline())})))}unmount(){var t,e;Ds(this,bf)._--,_(this,bf)===0&&((t=_(this,wb))==null||t.call(this),te(this,wb,void 0),(e=_(this,Sb))==null||e.call(this),te(this,Sb,void 0))}isFetching(t){return _(this,Mn).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return _(this,xf).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=_(this,Mn).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=_(this,Mn).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(kp(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return _(this,Mn).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=_(this,Mn).get(n.queryHash),i=s==null?void 0:s.state.data,a=aRe(e,i);if(a!==void 0)return _(this,Mn).build(this,n).setData(a,{...r,manual:!0})}setQueriesData(t,e,r){return Ns.batch(()=>_(this,Mn).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=_(this,Mn).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=_(this,Mn);Ns.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=_(this,Mn);return Ns.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=Ns.batch(()=>_(this,Mn).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(ua).catch(ua)}invalidateQueries(t,e={}){return Ns.batch(()=>(_(this,Mn).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=Ns.batch(()=>_(this,Mn).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,r);return r.throwOnError||(i=i.catch(ua)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(ua)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=_(this,Mn).build(this,e);return r.isStaleByTime(kp(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(ua).catch(ua)}fetchInfiniteQuery(t){return t.behavior=vK(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(ua).catch(ua)}ensureInfiniteQueryData(t){return t.behavior=vK(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return q2.isOnline()?_(this,xf).resumePausedMutations():Promise.resolve()}getQueryCache(){return _(this,Mn)}getMutationCache(){return _(this,xf)}getDefaultOptions(){return _(this,vf)}setDefaultOptions(t){te(this,vf,t)}setQueryDefaults(t,e){_(this,vb).set(Xy(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[..._(this,vb).values()],r={};return e.forEach(n=>{aj(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){_(this,bb).set(Xy(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[..._(this,bb).values()],r={};return e.forEach(n=>{aj(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={..._(this,vf).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=VH(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===WH&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{..._(this,vf).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){_(this,Mn).clear(),_(this,xf).clear()}},Mn=new WeakMap,xf=new WeakMap,vf=new WeakMap,vb=new WeakMap,bb=new WeakMap,bf=new WeakMap,wb=new WeakMap,Sb=new WeakMap,Eae),Ca,ur,bk,na,vg,_b,wf,Sf,wk,jb,kb,bg,wg,_f,Nb,Er,oS,L$,F$,$$,B$,z$,U$,H$,Lue,Aae,SRe=(Aae=class extends Hw{constructor(e,r){super();le(this,Er);le(this,Ca);le(this,ur);le(this,bk);le(this,na);le(this,vg);le(this,_b);le(this,wf);le(this,Sf);le(this,wk);le(this,jb);le(this,kb);le(this,bg);le(this,wg);le(this,_f);le(this,Nb,new Set);this.options=r,te(this,Ca,e),te(this,Sf,null),te(this,wf,D$()),this.options.experimental_prefetchInRender||_(this,wf).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(_(this,ur).addObserver(this),wK(_(this,ur),this.options)?ce(this,Er,oS).call(this):this.updateResult(),ce(this,Er,B$).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return V$(_(this,ur),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return V$(_(this,ur),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ce(this,Er,z$).call(this),ce(this,Er,U$).call(this),_(this,ur).removeObserver(this)}setOptions(e){const r=this.options,n=_(this,ur);if(this.options=_(this,Ca).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof rl(this.options.enabled,_(this,ur))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ce(this,Er,H$).call(this),_(this,ur).setOptions(this.options),r._defaulted&&!W2(this.options,r)&&_(this,Ca).getQueryCache().notify({type:"observerOptionsUpdated",query:_(this,ur),observer:this});const s=this.hasListeners();s&&SK(_(this,ur),n,this.options,r)&&ce(this,Er,oS).call(this),this.updateResult(),s&&(_(this,ur)!==n||rl(this.options.enabled,_(this,ur))!==rl(r.enabled,_(this,ur))||kp(this.options.staleTime,_(this,ur))!==kp(r.staleTime,_(this,ur)))&&ce(this,Er,L$).call(this);const i=ce(this,Er,F$).call(this);s&&(_(this,ur)!==n||rl(this.options.enabled,_(this,ur))!==rl(r.enabled,_(this,ur))||i!==_(this,_f))&&ce(this,Er,$$).call(this,i)}getOptimisticResult(e){const r=_(this,Ca).getQueryCache().build(_(this,Ca),e),n=this.createResult(r,e);return jRe(this,n)&&(te(this,na,n),te(this,_b,this.options),te(this,vg,_(this,ur).state)),n}getCurrentResult(){return _(this,na)}trackResult(e,r){return new Proxy(e,{get:(n,s)=>(this.trackProp(s),r==null||r(s),Reflect.get(n,s))})}trackProp(e){_(this,Nb).add(e)}getCurrentQuery(){return _(this,ur)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=_(this,Ca).defaultQueryOptions(e),n=_(this,Ca).getQueryCache().build(_(this,Ca),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return ce(this,Er,oS).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),_(this,na)))}createResult(e,r){var A;const n=_(this,ur),s=this.options,i=_(this,na),a=_(this,vg),o=_(this,_b),u=e!==n?e.state:_(this,bk),{state:d}=e;let h={...d},f=!1,p;if(r._optimisticResults){const M=this.hasListeners(),z=!M&&wK(e,r),P=M&&SK(e,n,r,s);(z||P)&&(h={...h,...Mue(d.data,e.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:m,errorUpdatedAt:g,status:x}=h;p=h.data;let y=!1;if(r.placeholderData!==void 0&&p===void 0&&x==="pending"){let M;i!=null&&i.isPlaceholderData&&r.placeholderData===(o==null?void 0:o.placeholderData)?(M=i.data,y=!0):M=typeof r.placeholderData=="function"?r.placeholderData((A=_(this,kb))==null?void 0:A.state.data,_(this,kb)):r.placeholderData,M!==void 0&&(x="success",p=M$(i==null?void 0:i.data,M,r),f=!0)}if(r.select&&p!==void 0&&!y)if(i&&p===(a==null?void 0:a.data)&&r.select===_(this,wk))p=_(this,jb);else try{te(this,wk,r.select),p=r.select(p),p=M$(i==null?void 0:i.data,p,r),te(this,jb,p),te(this,Sf,null)}catch(M){te(this,Sf,M)}_(this,Sf)&&(m=_(this,Sf),p=_(this,jb),g=Date.now(),x="error");const v=h.fetchStatus==="fetching",b=x==="pending",w=x==="error",S=b&&v,k=p!==void 0,C={status:x,fetchStatus:h.fetchStatus,isPending:b,isSuccess:x==="success",isError:w,isInitialLoading:S,isLoading:S,data:p,dataUpdatedAt:h.dataUpdatedAt,error:m,errorUpdatedAt:g,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:v,isRefetching:v&&!b,isLoadingError:w&&!k,isPaused:h.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&k,isStale:GH(e,r),refetch:this.refetch,promise:_(this,wf),isEnabled:rl(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const M=W=>{C.status==="error"?W.reject(C.error):C.data!==void 0&&W.resolve(C.data)},z=()=>{const W=te(this,wf,C.promise=D$());M(W)},P=_(this,wf);switch(P.status){case"pending":e.queryHash===n.queryHash&&M(P);break;case"fulfilled":(C.status==="error"||C.data!==P.value)&&z();break;case"rejected":(C.status!=="error"||C.error!==P.reason)&&z();break}}return C}updateResult(){const e=_(this,na),r=this.createResult(_(this,ur),this.options);if(te(this,vg,_(this,ur).state),te(this,_b,this.options),_(this,vg).data!==void 0&&te(this,kb,_(this,ur)),W2(r,e))return;te(this,na,r);const n=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!_(this,Nb).size)return!0;const a=new Set(i??_(this,Nb));return this.options.throwOnError&&a.add("error"),Object.keys(_(this,na)).some(o=>{const c=o;return _(this,na)[c]!==e[c]&&a.has(c)})};ce(this,Er,Lue).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ce(this,Er,B$).call(this)}},Ca=new WeakMap,ur=new WeakMap,bk=new WeakMap,na=new WeakMap,vg=new WeakMap,_b=new WeakMap,wf=new WeakMap,Sf=new WeakMap,wk=new WeakMap,jb=new WeakMap,kb=new WeakMap,bg=new WeakMap,wg=new WeakMap,_f=new WeakMap,Nb=new WeakMap,Er=new WeakSet,oS=function(e){ce(this,Er,H$).call(this);let r=_(this,ur).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(ua)),r},L$=function(){ce(this,Er,z$).call(this);const e=kp(this.options.staleTime,_(this,ur));if(Yy||_(this,na).isStale||!I$(e))return;const n=Eue(_(this,na).dataUpdatedAt,e)+1;te(this,bg,setTimeout(()=>{_(this,na).isStale||this.updateResult()},n))},F$=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(_(this,ur)):this.options.refetchInterval)??!1},$$=function(e){ce(this,Er,U$).call(this),te(this,_f,e),!(Yy||rl(this.options.enabled,_(this,ur))===!1||!I$(_(this,_f))||_(this,_f)===0)&&te(this,wg,setInterval(()=>{(this.options.refetchIntervalInBackground||qH.isFocused())&&ce(this,Er,oS).call(this)},_(this,_f)))},B$=function(){ce(this,Er,L$).call(this),ce(this,Er,$$).call(this,ce(this,Er,F$).call(this))},z$=function(){_(this,bg)&&(clearTimeout(_(this,bg)),te(this,bg,void 0))},U$=function(){_(this,wg)&&(clearInterval(_(this,wg)),te(this,wg,void 0))},H$=function(){const e=_(this,Ca).getQueryCache().build(_(this,Ca),this.options);if(e===_(this,ur))return;const r=_(this,ur);te(this,ur,e),te(this,bk,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},Lue=function(e){Ns.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(_(this,na))}),_(this,Ca).getQueryCache().notify({query:_(this,ur),type:"observerResultsUpdated"})})},Aae);function _Re(t,e){return rl(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function wK(t,e){return _Re(t,e)||t.state.data!==void 0&&V$(t,e,e.refetchOnMount)}function V$(t,e,r){if(rl(e.enabled,t)!==!1&&kp(e.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&GH(t,e)}return!1}function SK(t,e,r,n){return(t!==e||rl(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&GH(t,r)}function GH(t,e){return rl(e.enabled,t)!==!1&&t.isStaleByTime(kp(e.staleTime,t))}function jRe(t,e){return!W2(t.getCurrentResult(),e)}var jf,kf,Ta,hd,ih,cT,W$,Cae,kRe=(Cae=class extends Hw{constructor(r,n){super();le(this,ih);le(this,jf);le(this,kf);le(this,Ta);le(this,hd);te(this,jf,r),this.setOptions(n),this.bindMethods(),ce(this,ih,cT).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var s;const n=this.options;this.options=_(this,jf).defaultMutationOptions(r),W2(this.options,n)||_(this,jf).getMutationCache().notify({type:"observerOptionsUpdated",mutation:_(this,Ta),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&Xy(n.mutationKey)!==Xy(this.options.mutationKey)?this.reset():((s=_(this,Ta))==null?void 0:s.state.status)==="pending"&&_(this,Ta).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=_(this,Ta))==null||r.removeObserver(this)}onMutationUpdate(r){ce(this,ih,cT).call(this),ce(this,ih,W$).call(this,r)}getCurrentResult(){return _(this,kf)}reset(){var r;(r=_(this,Ta))==null||r.removeObserver(this),te(this,Ta,void 0),ce(this,ih,cT).call(this),ce(this,ih,W$).call(this)}mutate(r,n){var s;return te(this,hd,n),(s=_(this,Ta))==null||s.removeObserver(this),te(this,Ta,_(this,jf).getMutationCache().build(_(this,jf),this.options)),_(this,Ta).addObserver(this),_(this,Ta).execute(r)}},jf=new WeakMap,kf=new WeakMap,Ta=new WeakMap,hd=new WeakMap,ih=new WeakSet,cT=function(){var n;const r=((n=_(this,Ta))==null?void 0:n.state)??Due();te(this,kf,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},W$=function(r){Ns.batch(()=>{var n,s,i,a,o,c,u,d;if(_(this,hd)&&this.hasListeners()){const h=_(this,kf).variables,f=_(this,kf).context;(r==null?void 0:r.type)==="success"?((s=(n=_(this,hd)).onSuccess)==null||s.call(n,r.data,h,f),(a=(i=_(this,hd)).onSettled)==null||a.call(i,r.data,null,h,f)):(r==null?void 0:r.type)==="error"&&((c=(o=_(this,hd)).onError)==null||c.call(o,r.error,h,f),(d=(u=_(this,hd)).onSettled)==null||d.call(u,void 0,r.error,h,f))}this.listeners.forEach(h=>{h(_(this,kf))})})},Cae),Fue=j.createContext(void 0),KH=t=>{const e=j.useContext(Fue);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},NRe=({client:t,children:e})=>(j.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),l.jsx(Fue.Provider,{value:t,children:e})),$ue=j.createContext(!1),ERe=()=>j.useContext($ue);$ue.Provider;function ARe(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var CRe=j.createContext(ARe()),TRe=()=>j.useContext(CRe),PRe=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},ORe=t=>{j.useEffect(()=>{t.clearReset()},[t])},IRe=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||Tue(r,[t.error,n])),RRe=t=>{if(t.suspense){const e=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>e(r(...n)):e(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},MRe=(t,e)=>t.isLoading&&t.isFetching&&!e,DRe=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,_K=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function LRe(t,e,r){var h,f,p,m,g;const n=ERe(),s=TRe(),i=KH(),a=i.defaultQueryOptions(t);(f=(h=i.getDefaultOptions().queries)==null?void 0:h._experimental_beforeQuery)==null||f.call(h,a),a._optimisticResults=n?"isRestoring":"optimistic",RRe(a),PRe(a,s),ORe(s);const o=!i.getQueryCache().get(a.queryHash),[c]=j.useState(()=>new e(i,a)),u=c.getOptimisticResult(a),d=!n&&t.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(x=>{const y=d?c.subscribe(Ns.batchCalls(x)):ua;return c.updateResult(),y},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),j.useEffect(()=>{c.setOptions(a)},[a,c]),DRe(a,u))throw _K(a,c,s);if(IRe({result:u,errorResetBoundary:s,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw u.error;if((m=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||m.call(p,a,u),a.experimental_prefetchInRender&&!Yy&&MRe(u,n)){const x=o?_K(a,c,s):(g=i.getQueryCache().get(a.queryHash))==null?void 0:g.promise;x==null||x.catch(ua).finally(()=>{c.updateResult()})}return a.notifyOnChangeProps?u:c.trackResult(u)}function YH(t,e){return LRe(t,SRe)}function fL(t,e){const r=KH(),[n]=j.useState(()=>new kRe(r,t));j.useEffect(()=>{n.setOptions(t)},[n,t]);const s=j.useSyncExternalStore(j.useCallback(a=>n.subscribe(Ns.batchCalls(a)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=j.useCallback((a,o)=>{n.mutate(a,o).catch(ua)},[n]);if(s.error&&Tue(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/**
* @remix-run/router v1.23.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function oj(){return oj=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},oj.apply(this,arguments)}var gp;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(gp||(gp={}));const jK="popstate";function FRe(t){t===void 0&&(t={});function e(n,s){let{pathname:i,search:a,hash:o}=n.location;return q$("",{pathname:i,search:a,hash:o},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function r(n,s){return typeof s=="string"?s:G2(s)}return BRe(e,r,null,t)}function Qn(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function Bue(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function $Re(){return Math.random().toString(36).substr(2,8)}function kK(t,e){return{usr:t.state,key:t.key,idx:e}}function q$(t,e,r,n){return r===void 0&&(r=null),oj({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Vw(e):e,{state:r,key:e&&e.key||n||$Re()})}function G2(t){let{pathname:e="/",search:r="",hash:n=""}=t;return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Vw(t){let e={};if(t){let r=t.indexOf("#");r>=0&&(e.hash=t.substr(r),t=t.substr(0,r));let n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function BRe(t,e,r,n){n===void 0&&(n={});let{window:s=document.defaultView,v5Compat:i=!1}=n,a=s.history,o=gp.Pop,c=null,u=d();u==null&&(u=0,a.replaceState(oj({},a.state,{idx:u}),""));function d(){return(a.state||{idx:null}).idx}function h(){o=gp.Pop;let x=d(),y=x==null?null:x-u;u=x,c&&c({action:o,location:g.location,delta:y})}function f(x,y){o=gp.Push;let v=q$(g.location,x,y);u=d()+1;let b=kK(v,u),w=g.createHref(v);try{a.pushState(b,"",w)}catch(S){if(S instanceof DOMException&&S.name==="DataCloneError")throw S;s.location.assign(w)}i&&c&&c({action:o,location:g.location,delta:1})}function p(x,y){o=gp.Replace;let v=q$(g.location,x,y);u=d();let b=kK(v,u),w=g.createHref(v);a.replaceState(b,"",w),i&&c&&c({action:o,location:g.location,delta:0})}function m(x){let y=s.location.origin!=="null"?s.location.origin:s.location.href,v=typeof x=="string"?x:G2(x);return v=v.replace(/ $/,"%20"),Qn(y,"No window.location.(origin|href) available to create URL for href: "+v),new URL(v,y)}let g={get action(){return o},get location(){return t(s,a)},listen(x){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(jK,h),c=x,()=>{s.removeEventListener(jK,h),c=null}},createHref(x){return e(s,x)},createURL:m,encodeLocation(x){let y=m(x);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:f,replace:p,go(x){return a.go(x)}};return g}var NK;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(NK||(NK={}));function zRe(t,e,r){return r===void 0&&(r="/"),URe(t,e,r,!1)}function URe(t,e,r,n){let s=typeof e=="string"?Vw(e):e,i=XH(s.pathname||"/",r);if(i==null)return null;let a=zue(t);HRe(a);let o=null;for(let c=0;o==null&&c<a.length;++c){let u=eMe(i);o=QRe(a[c],u,n)}return o}function zue(t,e,r,n){e===void 0&&(e=[]),r===void 0&&(r=[]),n===void 0&&(n="");let s=(i,a,o)=>{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:a,route:i};c.relativePath.startsWith("/")&&(Qn(c.relativePath.startsWith(n),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(n.length));let u=Np([n,c.relativePath]),d=r.concat(c);i.children&&i.children.length>0&&(Qn(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),zue(i.children,e,d,u)),!(i.path==null&&!i.index)&&e.push({path:u,score:XRe(u,i.index),routesMeta:d})};return t.forEach((i,a)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))s(i,a);else for(let c of Uue(i.path))s(i,a,c)}),e}function Uue(t){let e=t.split("/");if(e.length===0)return[];let[r,...n]=e,s=r.endsWith("?"),i=r.replace(/\?$/,"");if(n.length===0)return s?[i,""]:[i];let a=Uue(n.join("/")),o=[];return o.push(...a.map(c=>c===""?i:[i,c].join("/"))),s&&o.push(...a),o.map(c=>t.startsWith("/")&&c===""?"/":c)}function HRe(t){t.sort((e,r)=>e.score!==r.score?r.score-e.score:JRe(e.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const VRe=/^:[\w-]+$/,WRe=3,qRe=2,GRe=1,KRe=10,YRe=-2,EK=t=>t==="*";function XRe(t,e){let r=t.split("/"),n=r.length;return r.some(EK)&&(n+=YRe),e&&(n+=qRe),r.filter(s=>!EK(s)).reduce((s,i)=>s+(VRe.test(i)?WRe:i===""?GRe:KRe),n)}function JRe(t,e){return t.length===e.length&&t.slice(0,-1).every((n,s)=>n===e[s])?t[t.length-1]-e[e.length-1]:0}function QRe(t,e,r){let{routesMeta:n}=t,s={},i="/",a=[];for(let o=0;o<n.length;++o){let c=n[o],u=o===n.length-1,d=i==="/"?e:e.slice(i.length)||"/",h=AK({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),f=c.route;if(!h&&u&&r&&!n[n.length-1].route.index&&(h=AK({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(s,h.params),a.push({params:s,pathname:Np([i,h.pathname]),pathnameBase:sMe(Np([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=Np([i,h.pathnameBase]))}return a}function AK(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[r,n]=ZRe(t.path,t.caseSensitive,t.end),s=e.match(r);if(!s)return null;let i=s[0],a=i.replace(/(.)\/+$/,"$1"),o=s.slice(1);return{params:n.reduce((u,d,h)=>{let{paramName:f,isOptional:p}=d;if(f==="*"){let g=o[h]||"";a=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const m=o[h];return p&&!m?u[f]=void 0:u[f]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:a,pattern:t}}function ZRe(t,e,r){e===void 0&&(e=!1),r===void 0&&(r=!0),Bue(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],s="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,o,c)=>(n.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),s+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?s+="\\/*$":t!==""&&t!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),n]}function eMe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Bue(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function XH(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let r=e.endsWith("/")?e.length-1:e.length,n=t.charAt(r);return n&&n!=="/"?null:t.slice(r)||"/"}function tMe(t,e){e===void 0&&(e="/");let{pathname:r,search:n="",hash:s=""}=typeof t=="string"?Vw(t):t;return{pathname:r?r.startsWith("/")?r:rMe(r,e):e,search:iMe(n),hash:aMe(s)}}function rMe(t,e){let r=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(s=>{s===".."?r.length>1&&r.pop():s!=="."&&r.push(s)}),r.length>1?r.join("/"):"/"}function pL(t,e,r,n){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function nMe(t){return t.filter((e,r)=>r===0||e.route.path&&e.route.path.length>0)}function JH(t,e){let r=nMe(t);return e?r.map((n,s)=>s===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function QH(t,e,r,n){n===void 0&&(n=!1);let s;typeof t=="string"?s=Vw(t):(s=oj({},t),Qn(!s.pathname||!s.pathname.includes("?"),pL("?","pathname","search",s)),Qn(!s.pathname||!s.pathname.includes("#"),pL("#","pathname","hash",s)),Qn(!s.search||!s.search.includes("#"),pL("#","search","hash",s)));let i=t===""||s.pathname==="",a=i?"/":s.pathname,o;if(a==null)o=r;else{let h=e.length-1;if(!n&&a.startsWith("..")){let f=a.split("/");for(;f[0]==="..";)f.shift(),h-=1;s.pathname=f.join("/")}o=h>=0?e[h]:"/"}let c=tMe(s,o),u=a&&a!=="/"&&a.endsWith("/"),d=(i||a===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Np=t=>t.join("/").replace(/\/\/+/g,"/"),sMe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),iMe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,aMe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function oMe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Hue=["post","put","patch","delete"];new Set(Hue);const lMe=["get",...Hue];new Set(lMe);/**
* React Router v6.30.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function lj(){return lj=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},lj.apply(this,arguments)}const ZH=j.createContext(null),cMe=j.createContext(null),sm=j.createContext(null),dR=j.createContext(null),Mu=j.createContext({outlet:null,matches:[],isDataRoute:!1}),Vue=j.createContext(null);function uMe(t,e){let{relative:r}=e===void 0?{}:e;Ww()||Qn(!1);let{basename:n,navigator:s}=j.useContext(sm),{hash:i,pathname:a,search:o}=que(t,{relative:r}),c=a;return n!=="/"&&(c=a==="/"?n:Np([n,a])),s.createHref({pathname:c,search:o,hash:i})}function Ww(){return j.useContext(dR)!=null}function Ch(){return Ww()||Qn(!1),j.useContext(dR).location}function Wue(t){j.useContext(sm).static||j.useLayoutEffect(t)}function Or(){let{isDataRoute:t}=j.useContext(Mu);return t?NMe():dMe()}function dMe(){Ww()||Qn(!1);let t=j.useContext(ZH),{basename:e,future:r,navigator:n}=j.useContext(sm),{matches:s}=j.useContext(Mu),{pathname:i}=Ch(),a=JSON.stringify(JH(s,r.v7_relativeSplatPath)),o=j.useRef(!1);return Wue(()=>{o.current=!0}),j.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){n.go(u);return}let h=QH(u,JSON.parse(a),i,d.relative==="path");t==null&&e!=="/"&&(h.pathname=h.pathname==="/"?e:Np([e,h.pathname])),(d.replace?n.replace:n.push)(h,d.state,d)},[e,n,a,i,t])}const hMe=j.createContext(null);function fMe(t){let e=j.useContext(Mu).outlet;return e&&j.createElement(hMe.Provider,{value:t},e)}function pMe(){let{matches:t}=j.useContext(Mu),e=t[t.length-1];return e?e.params:{}}function que(t,e){let{relative:r}=e===void 0?{}:e,{future:n}=j.useContext(sm),{matches:s}=j.useContext(Mu),{pathname:i}=Ch(),a=JSON.stringify(JH(s,n.v7_relativeSplatPath));return j.useMemo(()=>QH(t,JSON.parse(a),i,r==="path"),[t,a,i,r])}function mMe(t,e){return gMe(t,e)}function gMe(t,e,r,n){Ww()||Qn(!1);let{navigator:s}=j.useContext(sm),{matches:i}=j.useContext(Mu),a=i[i.length-1],o=a?a.params:{};a&&a.pathname;let c=a?a.pathnameBase:"/";a&&a.route;let u=Ch(),d;if(e){var h;let x=typeof e=="string"?Vw(e):e;c==="/"||(h=x.pathname)!=null&&h.startsWith(c)||Qn(!1),d=x}else d=u;let f=d.pathname||"/",p=f;if(c!=="/"){let x=c.replace(/^\//,"").split("/");p="/"+f.replace(/^\//,"").split("/").slice(x.length).join("/")}let m=zRe(t,{pathname:p}),g=wMe(m&&m.map(x=>Object.assign({},x,{params:Object.assign({},o,x.params),pathname:Np([c,s.encodeLocation?s.encodeLocation(x.pathname).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:Np([c,s.encodeLocation?s.encodeLocation(x.pathnameBase).pathname:x.pathnameBase])})),i,r,n);return e&&g?j.createElement(dR.Provider,{value:{location:lj({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:gp.Pop}},g):g}function yMe(){let t=kMe(),e=oMe(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},e),r?j.createElement("pre",{style:s},r):null,null)}const xMe=j.createElement(yMe,null);class vMe extends j.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){console.error("React Router caught the following error during render",e,r)}render(){return this.state.error!==void 0?j.createElement(Mu.Provider,{value:this.props.routeContext},j.createElement(Vue.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function bMe(t){let{routeContext:e,match:r,children:n}=t,s=j.useContext(ZH);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),j.createElement(Mu.Provider,{value:e},n)}function wMe(t,e,r,n){var s;if(e===void 0&&(e=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var i;if(!r)return null;if(r.errors)t=r.matches;else if((i=n)!=null&&i.v7_partialHydration&&e.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let a=t,o=(s=r)==null?void 0:s.errors;if(o!=null){let d=a.findIndex(h=>h.route.id&&(o==null?void 0:o[h.route.id])!==void 0);d>=0||Qn(!1),a=a.slice(0,Math.min(a.length,d+1))}let c=!1,u=-1;if(r&&n&&n.v7_partialHydration)for(let d=0;d<a.length;d++){let h=a[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=d),h.route.id){let{loaderData:f,errors:p}=r,m=h.route.loader&&f[h.route.id]===void 0&&(!p||p[h.route.id]===void 0);if(h.route.lazy||m){c=!0,u>=0?a=a.slice(0,u+1):a=[a[0]];break}}}return a.reduceRight((d,h,f)=>{let p,m=!1,g=null,x=null;r&&(p=o&&h.route.id?o[h.route.id]:void 0,g=h.route.errorElement||xMe,c&&(u<0&&f===0?(m=!0,x=null):u===f&&(m=!0,x=h.route.hydrateFallbackElement||null)));let y=e.concat(a.slice(0,f+1)),v=()=>{let b;return p?b=g:m?b=x:h.route.Component?b=j.createElement(h.route.Component,null):h.route.element?b=h.route.element:b=d,j.createElement(bMe,{match:h,routeContext:{outlet:d,matches:y,isDataRoute:r!=null},children:b})};return r&&(h.route.ErrorBoundary||h.route.errorElement||f===0)?j.createElement(vMe,{location:r.location,revalidation:r.revalidation,component:g,error:p,children:v(),routeContext:{outlet:null,matches:y,isDataRoute:!0}}):v()},null)}var Gue=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(Gue||{}),K2=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(K2||{});function SMe(t){let e=j.useContext(ZH);return e||Qn(!1),e}function _Me(t){let e=j.useContext(cMe);return e||Qn(!1),e}function jMe(t){let e=j.useContext(Mu);return e||Qn(!1),e}function Kue(t){let e=jMe(),r=e.matches[e.matches.length-1];return r.route.id||Qn(!1),r.route.id}function kMe(){var t;let e=j.useContext(Vue),r=_Me(K2.UseRouteError),n=Kue(K2.UseRouteError);return e!==void 0?e:(t=r.errors)==null?void 0:t[n]}function NMe(){let{router:t}=SMe(Gue.UseNavigateStable),e=Kue(K2.UseNavigateStable),r=j.useRef(!1);return Wue(()=>{r.current=!0}),j.useCallback(function(s,i){i===void 0&&(i={}),r.current&&(typeof s=="number"?t.navigate(s):t.navigate(s,lj({fromRouteId:e},i)))},[t,e])}function EMe(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function uT(t){let{to:e,replace:r,state:n,relative:s}=t;Ww()||Qn(!1);let{future:i,static:a}=j.useContext(sm),{matches:o}=j.useContext(Mu),{pathname:c}=Ch(),u=Or(),d=QH(e,JH(o,i.v7_relativeSplatPath),c,s==="path"),h=JSON.stringify(d);return j.useEffect(()=>u(JSON.parse(h),{replace:r,state:n,relative:s}),[u,h,s,r,n]),null}function AMe(t){return fMe(t.context)}function Mt(t){Qn(!1)}function CMe(t){let{basename:e="/",children:r=null,location:n,navigationType:s=gp.Pop,navigator:i,static:a=!1,future:o}=t;Ww()&&Qn(!1);let c=e.replace(/^\/*/,"/"),u=j.useMemo(()=>({basename:c,navigator:i,static:a,future:lj({v7_relativeSplatPath:!1},o)}),[c,o,i,a]);typeof n=="string"&&(n=Vw(n));let{pathname:d="/",search:h="",hash:f="",state:p=null,key:m="default"}=n,g=j.useMemo(()=>{let x=XH(d,c);return x==null?null:{location:{pathname:x,search:h,hash:f,state:p,key:m},navigationType:s}},[c,d,h,f,p,m,s]);return g==null?null:j.createElement(sm.Provider,{value:u},j.createElement(dR.Provider,{children:r,value:g}))}function TMe(t){let{children:e,location:r}=t;return mMe(G$(e),r)}new Promise(()=>{});function G$(t,e){e===void 0&&(e=[]);let r=[];return j.Children.forEach(t,(n,s)=>{if(!j.isValidElement(n))return;let i=[...e,s];if(n.type===j.Fragment){r.push.apply(r,G$(n.props.children,i));return}n.type!==Mt&&Qn(!1),!n.props.index||!n.props.children||Qn(!1);let a={id:n.props.id||i.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(a.children=G$(n.props.children,i)),r.push(a)}),r}/**
* React Router DOM v6.30.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/function K$(){return K$=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},K$.apply(this,arguments)}function PMe(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,i;for(i=0;i<n.length;i++)s=n[i],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function OMe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function IMe(t,e){return t.button===0&&(!e||e==="_self")&&!OMe(t)}function Y$(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,r)=>{let n=t[r];return e.concat(Array.isArray(n)?n.map(s=>[r,s]):[[r,n]])},[]))}function RMe(t,e){let r=Y$(t);return e&&e.forEach((n,s)=>{r.has(s)||e.getAll(s).forEach(i=>{r.append(s,i)})}),r}const MMe=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],DMe="6";try{window.__reactRouterVersion=DMe}catch{}const LMe="startTransition",CK=IU[LMe];function FMe(t){let{basename:e,children:r,future:n,window:s}=t,i=j.useRef();i.current==null&&(i.current=FRe({window:s,v5Compat:!0}));let a=i.current,[o,c]=j.useState({action:a.action,location:a.location}),{v7_startTransition:u}=n||{},d=j.useCallback(h=>{u&&CK?CK(()=>c(h)):c(h)},[c,u]);return j.useLayoutEffect(()=>a.listen(d),[a,d]),j.useEffect(()=>EMe(n),[n]),j.createElement(CMe,{basename:e,children:r,location:o.location,navigationType:o.action,navigator:a,future:n})}const $Me=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",BMe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bt=j.forwardRef(function(e,r){let{onClick:n,relative:s,reloadDocument:i,replace:a,state:o,target:c,to:u,preventScrollReset:d,viewTransition:h}=e,f=PMe(e,MMe),{basename:p}=j.useContext(sm),m,g=!1;if(typeof u=="string"&&BMe.test(u)&&(m=u,$Me))try{let b=new URL(window.location.href),w=u.startsWith("//")?new URL(b.protocol+u):new URL(u),S=XH(w.pathname,p);w.origin===b.origin&&S!=null?u=S+w.search+w.hash:g=!0}catch{}let x=uMe(u,{relative:s}),y=zMe(u,{replace:a,state:o,target:c,preventScrollReset:d,relative:s,viewTransition:h});function v(b){n&&n(b),b.defaultPrevented||y(b)}return j.createElement("a",K$({},f,{href:m||x,onClick:g||i?n:v,ref:r,target:c}))});var TK;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(TK||(TK={}));var PK;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(PK||(PK={}));function zMe(t,e){let{target:r,replace:n,state:s,preventScrollReset:i,relative:a,viewTransition:o}=e===void 0?{}:e,c=Or(),u=Ch(),d=que(t,{relative:a});return j.useCallback(h=>{if(IMe(h,r)){h.preventDefault();let f=n!==void 0?n:G2(u)===G2(d);c(t,{replace:f,state:s,preventScrollReset:i,relative:a,viewTransition:o})}},[u,c,d,n,s,r,t,i,a,o])}function oE(t){let e=j.useRef(Y$(t)),r=j.useRef(!1),n=Ch(),s=j.useMemo(()=>RMe(n.search,r.current?null:e.current),[n.search]),i=Or(),a=j.useCallback((o,c)=>{const u=Y$(typeof o=="function"?o(s):o);r.current=!0,i("?"+u,c)},[i,s]);return[s,a]}const UMe="modulepreload",HMe=function(t){return"/"+t},OK={},lE=function(e,r,n){let s=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(r.map(c=>{if(c=HMe(c),c in OK)return;OK[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const h=document.createElement("link");if(h.rel=u?"stylesheet":UMe,u||(h.as="script"),h.crossOrigin="",h.href=c,o&&h.setAttribute("nonce",o),document.head.appendChild(h),u)return new Promise((f,p)=>{h.addEventListener("load",f),h.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return e().catch(i)})},VMe=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>lE(async()=>{const{default:n}=await Promise.resolve().then(()=>qw);return{default:n}},[]).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};class eV extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}}class WMe extends eV{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class IK extends eV{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class RK extends eV{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var X$;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(X$||(X$={}));var qMe=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(d){try{u(n.next(d))}catch(h){a(h)}}function c(d){try{u(n.throw(d))}catch(h){a(h)}}function u(d){d.done?i(d.value):s(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})};class GMe{constructor(e,{headers:r={},customFetch:n,region:s=X$.Any}={}){this.url=e,this.headers=r,this.region=s,this.fetch=VMe(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,r={}){var n;return qMe(this,void 0,void 0,function*(){try{const{headers:s,method:i,body:a}=r;let o={},{region:c}=r;c||(c=this.region);const u=new URL(`${this.url}/${e}`);c&&c!=="any"&&(o["x-region"]=c,u.searchParams.set("forceFunctionRegion",c));let d;a&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob<"u"&&a instanceof Blob||a instanceof ArrayBuffer?(o["Content-Type"]="application/octet-stream",d=a):typeof a=="string"?(o["Content-Type"]="text/plain",d=a):typeof FormData<"u"&&a instanceof FormData?d=a:(o["Content-Type"]="application/json",d=JSON.stringify(a)));const h=yield this.fetch(u.toString(),{method:i||"POST",headers:Object.assign(Object.assign(Object.assign({},o),this.headers),s),body:d}).catch(g=>{throw new WMe(g)}),f=h.headers.get("x-relay-error");if(f&&f==="true")throw new IK(h);if(!h.ok)throw new RK(h);let p=((n=h.headers.get("Content-Type"))!==null&&n!==void 0?n:"text/plain").split(";")[0].trim(),m;return p==="application/json"?m=yield h.json():p==="application/octet-stream"?m=yield h.blob():p==="text/event-stream"?m=h:p==="multipart/form-data"?m=yield h.formData():m=yield h.text(),{data:m,error:null,response:h}}catch(s){return{data:null,error:s,response:s instanceof RK||s instanceof IK?s.context:void 0}}})}}var La={},tV={},hR={},cE={},fR={},pR={},KMe=function(){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")},W0=KMe();const YMe=W0.fetch,Yue=W0.fetch.bind(W0),Xue=W0.Headers,XMe=W0.Request,JMe=W0.Response,qw=Object.freeze(Object.defineProperty({__proto__:null,Headers:Xue,Request:XMe,Response:JMe,default:Yue,fetch:YMe},Symbol.toStringTag,{value:"Module"})),QMe=nEe(qw);var mR={};Object.defineProperty(mR,"__esModule",{value:!0});let ZMe=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};mR.default=ZMe;var Jue=dn&&dn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(pR,"__esModule",{value:!0});const eDe=Jue(QMe),tDe=Jue(mR);let rDe=class{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.isMaybeSingle=e.isMaybeSingle,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=eDe.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,r){return this.headers=Object.assign({},this.headers),this.headers[e]=r,this}then(e,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const n=this.fetch;let s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var a,o,c;let u=null,d=null,h=null,f=i.status,p=i.statusText;if(i.ok){if(this.method!=="HEAD"){const y=await i.text();y===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?d=y:d=JSON.parse(y))}const g=(a=this.headers.Prefer)===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),x=(o=i.headers.get("content-range"))===null||o===void 0?void 0:o.split("/");g&&x&&x.length>1&&(h=parseInt(x[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(d)&&(d.length>1?(u={code:"PGRST116",details:`Results contain ${d.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},d=null,h=null,f=406,p="Not Acceptable"):d.length===1?d=d[0]:d=null)}else{const g=await i.text();try{u=JSON.parse(g),Array.isArray(u)&&i.status===404&&(d=[],u=null,f=200,p="OK")}catch{i.status===404&&g===""?(f=204,p="No Content"):u={message:g}}if(u&&this.isMaybeSingle&&(!((c=u==null?void 0:u.details)===null||c===void 0)&&c.includes("0 rows"))&&(u=null,f=200,p="OK"),u&&this.shouldThrowOnError)throw new tDe.default(u)}return{error:u,data:d,count:h,status:f,statusText:p}});return this.shouldThrowOnError||(s=s.catch(i=>{var a,o,c;return{error:{message:`${(a=i==null?void 0:i.name)!==null&&a!==void 0?a:"FetchError"}: ${i==null?void 0:i.message}`,details:`${(o=i==null?void 0:i.stack)!==null&&o!==void 0?o:""}`,hint:"",code:`${(c=i==null?void 0:i.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),s.then(e,r)}returns(){return this}overrideTypes(){return this}};pR.default=rDe;var nDe=dn&&dn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(fR,"__esModule",{value:!0});const sDe=nDe(pR);let iDe=class extends sDe.default{select(e){let r=!1;const n=(e??"*").split("").map(s=>/\s/.test(s)&&!r?"":(s==='"'&&(r=!r),s)).join("");return this.url.searchParams.set("select",n),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:r=!0,nullsFirst:n,foreignTable:s,referencedTable:i=s}={}){const a=i?`${i}.order`:"order",o=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${o?`${o},`:""}${e}.${r?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:r,referencedTable:n=r}={}){const s=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${e}`),this}range(e,r,{foreignTable:n,referencedTable:s=n}={}){const i=typeof s>"u"?"offset":`${s}.offset`,a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(i,`${e}`),this.url.searchParams.set(a,`${r-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.method==="GET"?this.headers.Accept="application/json":this.headers.Accept="application/vnd.pgrst.object+json",this.isMaybeSingle=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:r=!1,settings:n=!1,buffers:s=!1,wal:i=!1,format:a="text"}={}){var o;const c=[e?"analyze":null,r?"verbose":null,n?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),u=(o=this.headers.Accept)!==null&&o!==void 0?o:"application/json";return this.headers.Accept=`application/vnd.pgrst.plan+${a}; for="${u}"; options=${c};`,a==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}};fR.default=iDe;var aDe=dn&&dn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(cE,"__esModule",{value:!0});const oDe=aDe(fR);let lDe=class extends oDe.default{eq(e,r){return this.url.searchParams.append(e,`eq.${r}`),this}neq(e,r){return this.url.searchParams.append(e,`neq.${r}`),this}gt(e,r){return this.url.searchParams.append(e,`gt.${r}`),this}gte(e,r){return this.url.searchParams.append(e,`gte.${r}`),this}lt(e,r){return this.url.searchParams.append(e,`lt.${r}`),this}lte(e,r){return this.url.searchParams.append(e,`lte.${r}`),this}like(e,r){return this.url.searchParams.append(e,`like.${r}`),this}likeAllOf(e,r){return this.url.searchParams.append(e,`like(all).{${r.join(",")}}`),this}likeAnyOf(e,r){return this.url.searchParams.append(e,`like(any).{${r.join(",")}}`),this}ilike(e,r){return this.url.searchParams.append(e,`ilike.${r}`),this}ilikeAllOf(e,r){return this.url.searchParams.append(e,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(e,r){return this.url.searchParams.append(e,`ilike(any).{${r.join(",")}}`),this}is(e,r){return this.url.searchParams.append(e,`is.${r}`),this}in(e,r){const n=Array.from(new Set(r)).map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${n})`),this}contains(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cs.{${r.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(r)}`),this}containedBy(e,r){return typeof r=="string"?this.url.searchParams.append(e,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(e,`cd.{${r.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(r)}`),this}rangeGt(e,r){return this.url.searchParams.append(e,`sr.${r}`),this}rangeGte(e,r){return this.url.searchParams.append(e,`nxl.${r}`),this}rangeLt(e,r){return this.url.searchParams.append(e,`sl.${r}`),this}rangeLte(e,r){return this.url.searchParams.append(e,`nxr.${r}`),this}rangeAdjacent(e,r){return this.url.searchParams.append(e,`adj.${r}`),this}overlaps(e,r){return typeof r=="string"?this.url.searchParams.append(e,`ov.${r}`):this.url.searchParams.append(e,`ov.{${r.join(",")}}`),this}textSearch(e,r,{config:n,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");const a=n===void 0?"":`(${n})`;return this.url.searchParams.append(e,`${i}fts${a}.${r}`),this}match(e){return Object.entries(e).forEach(([r,n])=>{this.url.searchParams.append(r,`eq.${n}`)}),this}not(e,r,n){return this.url.searchParams.append(e,`not.${r}.${n}`),this}or(e,{foreignTable:r,referencedTable:n=r}={}){const s=n?`${n}.or`:"or";return this.url.searchParams.append(s,`(${e})`),this}filter(e,r,n){return this.url.searchParams.append(e,`${r}.${n}`),this}};cE.default=lDe;var cDe=dn&&dn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(hR,"__esModule",{value:!0});const C1=cDe(cE);let uDe=class{constructor(e,{headers:r={},schema:n,fetch:s}){this.url=e,this.headers=r,this.schema=n,this.fetch=s}select(e,{head:r=!1,count:n}={}){const s=r?"HEAD":"GET";let i=!1;const a=(e??"*").split("").map(o=>/\s/.test(o)&&!i?"":(o==='"'&&(i=!i),o)).join("");return this.url.searchParams.set("select",a),n&&(this.headers.Prefer=`count=${n}`),new C1.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:r,defaultToNull:n=!0}={}){const s="POST",i=[];if(this.headers.Prefer&&i.push(this.headers.Prefer),r&&i.push(`count=${r}`),n||i.push("missing=default"),this.headers.Prefer=i.join(","),Array.isArray(e)){const a=e.reduce((o,c)=>o.concat(Object.keys(c)),[]);if(a.length>0){const o=[...new Set(a)].map(c=>`"${c}"`);this.url.searchParams.set("columns",o.join(","))}}return new C1.default({method:s,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:r,ignoreDuplicates:n=!1,count:s,defaultToNull:i=!0}={}){const a="POST",o=[`resolution=${n?"ignore":"merge"}-duplicates`];if(r!==void 0&&this.url.searchParams.set("on_conflict",r),this.headers.Prefer&&o.push(this.headers.Prefer),s&&o.push(`count=${s}`),i||o.push("missing=default"),this.headers.Prefer=o.join(","),Array.isArray(e)){const c=e.reduce((u,d)=>u.concat(Object.keys(d)),[]);if(c.length>0){const u=[...new Set(c)].map(d=>`"${d}"`);this.url.searchParams.set("columns",u.join(","))}}return new C1.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}update(e,{count:r}={}){const n="PATCH",s=[];return this.headers.Prefer&&s.push(this.headers.Prefer),r&&s.push(`count=${r}`),this.headers.Prefer=s.join(","),new C1.default({method:n,url:this.url,headers:this.headers,schema:this.schema,body:e,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const r="DELETE",n=[];return e&&n.push(`count=${e}`),this.headers.Prefer&&n.unshift(this.headers.Prefer),this.headers.Prefer=n.join(","),new C1.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};hR.default=uDe;var gR={},yR={};Object.defineProperty(yR,"__esModule",{value:!0});yR.version=void 0;yR.version="0.0.0-automated";Object.defineProperty(gR,"__esModule",{value:!0});gR.DEFAULT_HEADERS=void 0;const dDe=yR;gR.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${dDe.version}`};var Que=dn&&dn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(tV,"__esModule",{value:!0});const hDe=Que(hR),fDe=Que(cE),pDe=gR;let mDe=class Zue{constructor(e,{headers:r={},schema:n,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},pDe.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=s}from(e){const r=new URL(`${this.url}/${e}`);return new hDe.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new Zue(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,r={},{head:n=!1,get:s=!1,count:i}={}){let a;const o=new URL(`${this.url}/rpc/${e}`);let c;n||s?(a=n?"HEAD":"GET",Object.entries(r).filter(([d,h])=>h!==void 0).map(([d,h])=>[d,Array.isArray(h)?`{${h.join(",")}}`:`${h}`]).forEach(([d,h])=>{o.searchParams.append(d,h)})):(a="POST",c=r);const u=Object.assign({},this.headers);return i&&(u.Prefer=`count=${i}`),new fDe.default({method:a,url:o,headers:u,schema:this.schemaName,body:c,fetch:this.fetch,allowEmpty:!1})}};tV.default=mDe;var Gw=dn&&dn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(La,"__esModule",{value:!0});La.PostgrestError=La.PostgrestBuilder=La.PostgrestTransformBuilder=La.PostgrestFilterBuilder=La.PostgrestQueryBuilder=La.PostgrestClient=void 0;const ede=Gw(tV);La.PostgrestClient=ede.default;const tde=Gw(hR);La.PostgrestQueryBuilder=tde.default;const rde=Gw(cE);La.PostgrestFilterBuilder=rde.default;const nde=Gw(fR);La.PostgrestTransformBuilder=nde.default;const sde=Gw(pR);La.PostgrestBuilder=sde.default;const ide=Gw(mR);La.PostgrestError=ide.default;var gDe=La.default={PostgrestClient:ede.default,PostgrestQueryBuilder:tde.default,PostgrestFilterBuilder:rde.default,PostgrestTransformBuilder:nde.default,PostgrestBuilder:sde.default,PostgrestError:ide.default};const{PostgrestClient:yDe,PostgrestQueryBuilder:t5t,PostgrestFilterBuilder:r5t,PostgrestTransformBuilder:n5t,PostgrestBuilder:s5t,PostgrestError:i5t}=gDe;class xDe{static dynamicRequire(e){try{return typeof process<"u"&&process.versions&&process.versions.node&&typeof require<"u"?require(e):null}catch{return null}}static detectEnvironment(){var e,r;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"&&process.versions&&process.versions.node){const n=parseInt(process.versions.node.split(".")[0]);if(n>=22)try{if(typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};const s=this.dynamicRequire("undici");if(s&&s.WebSocket)return{type:"native",constructor:s.WebSocket};throw new Error("undici not available")}catch{return{type:"unsupported",error:`Node.js ${n} detected but native WebSocket not found.`,workaround:'Install the "ws" package or check your Node.js installation.'}}try{const s=this.dynamicRequire("ws");if(s)return{type:"ws",constructor:(r=s.WebSocket)!==null&&r!==void 0?r:s};throw new Error("ws package not available")}catch{return{type:"unsupported",error:`Node.js ${n} detected without WebSocket support.`,workaround:'Install the "ws" package: npm install ws'}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let r=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(r+=`
Suggested solution: ${e.workaround}`),new Error(r)}static createWebSocket(e,r){const n=this.getWebSocketConstructor();return new n(e,r)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const vDe="2.15.0",bDe=`realtime-js/${vDe}`,wDe="1.0.0",J$=1e4,SDe=1e3,_De=100;var d_;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(d_||(d_={}));var vs;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(vs||(vs={}));var nc;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(nc||(nc={}));var Q$;(function(t){t.websocket="websocket"})(Q$||(Q$={}));var Hm;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Hm||(Hm={}));class jDe{constructor(){this.HEADER_LENGTH=1}decode(e,r){return e.constructor===ArrayBuffer?r(this._binaryDecode(e)):r(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const r=new DataView(e),n=new TextDecoder;return this._decodeBroadcast(e,r,n)}_decodeBroadcast(e,r,n){const s=r.getUint8(1),i=r.getUint8(2);let a=this.HEADER_LENGTH+2;const o=n.decode(e.slice(a,a+s));a=a+s;const c=n.decode(e.slice(a,a+i));a=a+i;const u=JSON.parse(n.decode(e.slice(a,e.byteLength)));return{ref:null,topic:o,event:c,payload:u}}}let ade=class{constructor(e,r){this.callback=e,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}};var Yr;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(Yr||(Yr={}));const MK=(t,e,r={})=>{var n;const s=(n=r.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(e).reduce((i,a)=>(i[a]=kDe(a,t,e,s),i),{})},kDe=(t,e,r,n)=>{const s=e.find(o=>o.name===t),i=s==null?void 0:s.type,a=r[t];return i&&!n.includes(i)?ode(i,a):Z$(a)},ode=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return CDe(e,r)}switch(t){case Yr.bool:return NDe(e);case Yr.float4:case Yr.float8:case Yr.int2:case Yr.int4:case Yr.int8:case Yr.numeric:case Yr.oid:return EDe(e);case Yr.json:case Yr.jsonb:return ADe(e);case Yr.timestamp:return TDe(e);case Yr.abstime:case Yr.date:case Yr.daterange:case Yr.int4range:case Yr.int8range:case Yr.money:case Yr.reltime:case Yr.text:case Yr.time:case Yr.timestamptz:case Yr.timetz:case Yr.tsrange:case Yr.tstzrange:return Z$(e);default:return Z$(e)}},Z$=t=>t,NDe=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},EDe=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},ADe=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},CDe=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,n=t[r];if(t[0]==="{"&&n==="}"){let i;const a=t.slice(1,r);try{i=JSON.parse("["+a+"]")}catch{i=a?a.split(","):[]}return i.map(o=>ode(e,o))}return t},TDe=t=>typeof t=="string"?t.replace(" ","T"):t,lde=t=>{let e=t;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"};class mL{constructor(e,r,n={},s=J$){this.channel=e,this.event=r,this.payload=n,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,r){var n;return this._hasReceived(e)&&r((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:e,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:r}){this.recHooks.filter(n=>n.status===e).forEach(n=>n.callback(r))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var DK;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(DK||(DK={}));class h_{constructor(e,r){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},s=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.joinRef=this.channel._joinRef(),this.state=h_.syncState(this.state,s,i,a),this.pendingDiffs.forEach(c=>{this.state=h_.syncDiff(this.state,c,i,a)}),this.pendingDiffs=[],o()}),this.channel._on(n.diff,{},s=>{const{onJoin:i,onLeave:a,onSync:o}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=h_.syncDiff(this.state,s,i,a),o())}),this.onJoin((s,i,a)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:i,newPresences:a})}),this.onLeave((s,i,a)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:i,leftPresences:a})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,r,n,s){const i=this.cloneDeep(e),a=this.transformState(r),o={},c={};return this.map(i,(u,d)=>{a[u]||(c[u]=d)}),this.map(a,(u,d)=>{const h=i[u];if(h){const f=d.map(x=>x.presence_ref),p=h.map(x=>x.presence_ref),m=d.filter(x=>p.indexOf(x.presence_ref)<0),g=h.filter(x=>f.indexOf(x.presence_ref)<0);m.length>0&&(o[u]=m),g.length>0&&(c[u]=g)}else o[u]=d}),this.syncDiff(i,{joins:o,leaves:c},n,s)}static syncDiff(e,r,n,s){const{joins:i,leaves:a}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),s||(s=()=>{}),this.map(i,(o,c)=>{var u;const d=(u=e[o])!==null&&u!==void 0?u:[];if(e[o]=this.cloneDeep(c),d.length>0){const h=e[o].map(p=>p.presence_ref),f=d.filter(p=>h.indexOf(p.presence_ref)<0);e[o].unshift(...f)}n(o,d,c)}),this.map(a,(o,c)=>{let u=e[o];if(!u)return;const d=c.map(h=>h.presence_ref);u=u.filter(h=>d.indexOf(h.presence_ref)<0),e[o]=u,s(o,u,c),u.length===0&&delete e[o]}),e}static map(e,r){return Object.getOwnPropertyNames(e).map(n=>r(n,e[n]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((r,n)=>{const s=e[n];return"metas"in s?r[n]=s.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):r[n]=s,r},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var LK;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(LK||(LK={}));var f_;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(f_||(f_={}));var nd;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(nd||(nd={}));class rV{constructor(e,r={config:{}},n){this.topic=e,this.params=r,this.socket=n,this.bindings={},this.state=vs.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new mL(this,nc.join,this.params,this.timeout),this.rejoinTimer=new ade(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=vs.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=vs.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=vs.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=vs.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=vs.errored,this.rejoinTimer.scheduleTimeout())}),this._on(nc.reply,{},(s,i)=>{this._trigger(this._replyEventName(i),s)}),this.presence=new h_(this),this.broadcastEndpointURL=lde(this.socket.endPoint),this.private=this.params.config.private||!1}subscribe(e,r=this.timeout){var n,s;if(this.socket.isConnected()||this.socket.connect(),this.state==vs.closed){const{config:{broadcast:i,presence:a,private:o}}=this.params,c=(s=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(f=>f.filter))!==null&&s!==void 0?s:[],u=!!this.bindings[f_.PRESENCE]&&this.bindings[f_.PRESENCE].length>0,d={},h={broadcast:i,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:c,private:o};this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this._onError(f=>e==null?void 0:e(nd.CHANNEL_ERROR,f)),this._onClose(()=>e==null?void 0:e(nd.CLOSED)),this.updateJoinPayload(Object.assign({config:h},d)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:f})=>{var p;if(this.socket.setAuth(),f===void 0){e==null||e(nd.SUBSCRIBED);return}else{const m=this.bindings.postgres_changes,g=(p=m==null?void 0:m.length)!==null&&p!==void 0?p:0,x=[];for(let y=0;y<g;y++){const v=m[y],{filter:{event:b,schema:w,table:S,filter:k}}=v,E=f&&f[y];if(E&&E.event===b&&E.schema===w&&E.table===S&&E.filter===k)x.push(Object.assign(Object.assign({},v),{id:E.id}));else{this.unsubscribe(),this.state=vs.errored,e==null||e(nd.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=x,e&&e(nd.SUBSCRIBED);return}}).receive("error",f=>{this.state=vs.errored,e==null||e(nd.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(f).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(nd.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,n){return this.state===vs.joined&&e===f_.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(e,r,n)}async send(e,r={}){var n,s;if(!this._canPush()&&e.type==="broadcast"){const{event:i,payload:a}=e,c={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:a,private:this.private}]})};try{const u=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((s=u.body)===null||s===void 0?void 0:s.cancel()),u.ok?"ok":"error"}catch(u){return u.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var a,o,c;const u=this._push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((c=(o=(a=this.params)===null||a===void 0?void 0:a.config)===null||o===void 0?void 0:o.broadcast)===null||c===void 0)&&c.ack)&&i("ok"),u.receive("ok",()=>i("ok")),u.receive("error",()=>i("error")),u.receive("timeout",()=>i("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=vs.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(nc.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(s=>{n=new mL(this,nc.leave,{},e),n.receive("ok",()=>{r(),s("ok")}).receive("timeout",()=>{r(),s("timed out")}).receive("error",()=>{s("error")}),n.send(),this._canPush()||n.trigger("ok",{})}).finally(()=>{n==null||n.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=vs.closed,this.bindings={}}async _fetchWithTimeout(e,r,n){const s=new AbortController,i=setTimeout(()=>s.abort(),n),a=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:s.signal}));return clearTimeout(i),a}_push(e,r,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new mL(this,e,r,n);return this._canPush()?s.send():this._addToPushBuffer(s),s}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>_De){const r=this.pushBuffer.shift();r&&(r.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${r.event}`,r.payload))}}_onMessage(e,r,n){return r}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,r,n){var s,i;const a=e.toLocaleLowerCase(),{close:o,error:c,leave:u,join:d}=nc;if(n&&[o,c,u,d].indexOf(a)>=0&&n!==this._joinRef())return;let f=this._onMessage(a,r,n);if(r&&!f)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(a)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(p=>{var m,g,x;return((m=p.filter)===null||m===void 0?void 0:m.event)==="*"||((x=(g=p.filter)===null||g===void 0?void 0:g.event)===null||x===void 0?void 0:x.toLocaleLowerCase())===a}).map(p=>p.callback(f,n)):(i=this.bindings[a])===null||i===void 0||i.filter(p=>{var m,g,x,y,v,b;if(["broadcast","presence","postgres_changes"].includes(a))if("id"in p){const w=p.id,S=(m=p.filter)===null||m===void 0?void 0:m.event;return w&&((g=r.ids)===null||g===void 0?void 0:g.includes(w))&&(S==="*"||(S==null?void 0:S.toLocaleLowerCase())===((x=r.data)===null||x===void 0?void 0:x.type.toLocaleLowerCase()))}else{const w=(v=(y=p==null?void 0:p.filter)===null||y===void 0?void 0:y.event)===null||v===void 0?void 0:v.toLocaleLowerCase();return w==="*"||w===((b=r==null?void 0:r.event)===null||b===void 0?void 0:b.toLocaleLowerCase())}else return p.type.toLocaleLowerCase()===a}).map(p=>{if(typeof f=="object"&&"ids"in f){const m=f.data,{schema:g,table:x,commit_timestamp:y,type:v,errors:b}=m;f=Object.assign(Object.assign({},{schema:g,table:x,commit_timestamp:y,eventType:v,new:{},old:{},errors:b}),this._getPayloadRecords(m))}p.callback(f,n)})}_isClosed(){return this.state===vs.closed}_isJoined(){return this.state===vs.joined}_isJoining(){return this.state===vs.joining}_isLeaving(){return this.state===vs.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,r,n){const s=e.toLocaleLowerCase(),i={type:s,filter:r,callback:n};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(e,r){const n=e.toLocaleLowerCase();return this.bindings[n]&&(this.bindings[n]=this.bindings[n].filter(s=>{var i;return!(((i=s.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===n&&rV.isEqual(s.filter,r))})),this}static isEqual(e,r){if(Object.keys(e).length!==Object.keys(r).length)return!1;for(const n in e)if(e[n]!==r[n])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(nc.close,{},e)}_onError(e){this._on(nc.error,{},r=>e(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=vs.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=MK(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=MK(e.columns,e.old_record)),r}}const FK=()=>{},TA={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},PDe=[1e3,2e3,5e3,1e4],ODe=1e4,IDe=`
addEventListener("message", (e) => {
if (e.data.event === "start") {
setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
}
});`;class RDe{constructor(e,r){var n;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=J$,this.transport=null,this.heartbeatIntervalMs=TA.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=FK,this.ref=0,this.reconnectTimer=null,this.logger=FK,this.conn=null,this.sendBuffer=[],this.serializer=new jDe,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=s=>{let i;return s?i=s:typeof fetch>"u"?i=(...a)=>lE(async()=>{const{default:o}=await Promise.resolve().then(()=>qw);return{default:o}},void 0).then(({default:o})=>o(...a)).catch(o=>{throw new Error(`Failed to load @supabase/node-fetch: ${o.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):i=fetch,(...a)=>i(...a)},!(!((n=r==null?void 0:r.params)===null||n===void 0)&&n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey,this.endPoint=`${e}/${Q$.websocket}`,this.httpEndpoint=lde(e),this._initializeOptions(r),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(r==null?void 0:r.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=xDe.createWebSocket(this.endpointURL())}catch(e){throw this._setConnectionState("disconnected"),new Error(`WebSocket not available: ${e.message}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:wDe}))}disconnect(e,r){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const n=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(n),this._setConnectionState("disconnected")},e?this.conn.close(e,r??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const e=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,r,n){this.logger(e,r,n)}connectionState(){switch(this.conn&&this.conn.readyState){case d_.connecting:return Hm.Connecting;case d_.open:return Hm.Open;case d_.closing:return Hm.Closing;default:return Hm.Closed}}isConnected(){return this.connectionState()===Hm.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,r={config:{}}){const n=`realtime:${e}`,s=this.getChannels().find(i=>i.topic===n);if(s)return s;{const i=new rV(`realtime:${e}`,r,this);return this.channels.push(i),i}}push(e){const{topic:r,event:n,payload:s,ref:i}=e,a=()=>{this.encode(e,o=>{var c;(c=this.conn)===null||c===void 0||c.send(o)})};this.log("push",`${r} ${n} (${i})`,s),this.isConnected()?a():this.sendBuffer.push(a)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var e;if(!this.isConnected()){this.heartbeatCallback("disconnected");return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.heartbeatCallback("timeout"),this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(SDe,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},TA.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatCallback("sent"),this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let r=this.channels.find(n=>n.topic===e&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${e}"`),r.unsubscribe())}_remove(e){this.channels=this.channels.filter(r=>r.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,r=>{r.topic==="phoenix"&&r.event==="phx_reply"&&this.heartbeatCallback(r.payload.status==="ok"?"ok":"error"),r.ref&&r.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:s,payload:i,ref:a}=r,o=a?`(${a})`:"",c=i.status||"";this.log("receive",`${c} ${n} ${s} ${o}`.trim(),i),this.channels.filter(u=>u._isMember(n)).forEach(u=>u._trigger(s,i,a)),this._triggerStateCallbacks("message",r)})}_clearTimer(e){var r;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((r=this.reconnectTimer)===null||r===void 0||r.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(e){var r;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(nc.error))}_appendParams(e,r){if(Object.keys(r).length===0)return e;const n=e.match(/\?/)?"&":"?",s=new URLSearchParams(r);return`${e}${n}${s}`}_workerObjectUrl(e){let r;if(e)r=e;else{const n=new Blob([IDe],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}_setConnectionState(e,r=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=r)}async _performAuth(e=null){let r;e?r=e:this.accessToken?r=await this.accessToken():r=this.accessTokenValue,this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(n=>{const s={access_token:r,version:bDe};r&&n.updateJoinPayload(s),n.joinedOnce&&n._isJoined()&&n._push(nc.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this.setAuth().catch(r=>{this.log("error",`error setting auth in ${e}`,r)})}_triggerStateCallbacks(e,r){try{this.stateChangeCallbacks[e].forEach(n=>{try{n(r)}catch(s){this.log("error",`error in ${e} callback`,s)}})}catch(n){this.log("error",`error triggering ${e} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new ade(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},TA.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var r,n,s,i,a,o,c,u;if(this.transport=(r=e==null?void 0:e.transport)!==null&&r!==void 0?r:null,this.timeout=(n=e==null?void 0:e.timeout)!==null&&n!==void 0?n:J$,this.heartbeatIntervalMs=(s=e==null?void 0:e.heartbeatIntervalMs)!==null&&s!==void 0?s:TA.HEARTBEAT_INTERVAL,this.worker=(i=e==null?void 0:e.worker)!==null&&i!==void 0?i:!1,this.accessToken=(a=e==null?void 0:e.accessToken)!==null&&a!==void 0?a:null,e!=null&&e.params&&(this.params=e.params),e!=null&&e.logger&&(this.logger=e.logger),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(o=e==null?void 0:e.reconnectAfterMs)!==null&&o!==void 0?o:d=>PDe[d-1]||ODe,this.encode=(c=e==null?void 0:e.encode)!==null&&c!==void 0?c:(d,h)=>h(JSON.stringify(d)),this.decode=(u=e==null?void 0:e.decode)!==null&&u!==void 0?u:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl}}}class nV extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function Vs(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class MDe extends nV{constructor(e,r,n){super(e),this.name="StorageApiError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class e6 extends nV{constructor(e,r){super(e),this.name="StorageUnknownError",this.originalError=r}}var DDe=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(d){try{u(n.next(d))}catch(h){a(h)}}function c(d){try{u(n.throw(d))}catch(h){a(h)}}function u(d){d.done?i(d.value):s(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})};const cde=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>lE(async()=>{const{default:n}=await Promise.resolve().then(()=>qw);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},LDe=()=>DDe(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield lE(()=>Promise.resolve().then(()=>qw),void 0)).Response:Response}),t6=t=>{if(Array.isArray(t))return t.map(r=>t6(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,n])=>{const s=r.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));e[s]=t6(n)}),e},FDe=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)};var yx=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(d){try{u(n.next(d))}catch(h){a(h)}}function c(d){try{u(n.throw(d))}catch(h){a(h)}}function u(d){d.done?i(d.value):s(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})};const gL=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),$De=(t,e,r)=>yx(void 0,void 0,void 0,function*(){const n=yield LDe();t instanceof n&&!(r!=null&&r.noResolveJson)?t.json().then(s=>{const i=t.status||500,a=(s==null?void 0:s.statusCode)||i+"";e(new MDe(gL(s),i,a))}).catch(s=>{e(new e6(gL(s),s))}):e(new e6(gL(t),t))}),BDe=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"||!n?s:(FDe(n)?(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),s.body=JSON.stringify(n)):s.body=n,Object.assign(Object.assign({},s),r))};function uE(t,e,r,n,s,i){return yx(this,void 0,void 0,function*(){return new Promise((a,o)=>{t(r,BDe(e,n,s,i)).then(c=>{if(!c.ok)throw c;return n!=null&&n.noResolveJson?c:c.json()}).then(c=>a(c)).catch(c=>$De(c,o,n))})})}function Y2(t,e,r,n){return yx(this,void 0,void 0,function*(){return uE(t,"GET",e,r,n)})}function sd(t,e,r,n,s){return yx(this,void 0,void 0,function*(){return uE(t,"POST",e,n,s,r)})}function r6(t,e,r,n,s){return yx(this,void 0,void 0,function*(){return uE(t,"PUT",e,n,s,r)})}function zDe(t,e,r,n){return yx(this,void 0,void 0,function*(){return uE(t,"HEAD",e,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function ude(t,e,r,n,s){return yx(this,void 0,void 0,function*(){return uE(t,"DELETE",e,n,s,r)})}var ka=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(d){try{u(n.next(d))}catch(h){a(h)}}function c(d){try{u(n.throw(d))}catch(h){a(h)}}function u(d){d.done?i(d.value):s(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})};const UDe={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},$K={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class HDe{constructor(e,r={},n,s){this.url=e,this.headers=r,this.bucketId=n,this.fetch=cde(s)}uploadOrUpdate(e,r,n,s){return ka(this,void 0,void 0,function*(){try{let i;const a=Object.assign(Object.assign({},$K),s);let o=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(a.upsert)});const c=a.metadata;typeof Blob<"u"&&n instanceof Blob?(i=new FormData,i.append("cacheControl",a.cacheControl),c&&i.append("metadata",this.encodeMetadata(c)),i.append("",n)):typeof FormData<"u"&&n instanceof FormData?(i=n,i.append("cacheControl",a.cacheControl),c&&i.append("metadata",this.encodeMetadata(c))):(i=n,o["cache-control"]=`max-age=${a.cacheControl}`,o["content-type"]=a.contentType,c&&(o["x-metadata"]=this.toBase64(this.encodeMetadata(c)))),s!=null&&s.headers&&(o=Object.assign(Object.assign({},o),s.headers));const u=this._removeEmptyFolders(r),d=this._getFinalPath(u),h=yield(e=="PUT"?r6:sd)(this.fetch,`${this.url}/object/${d}`,i,Object.assign({headers:o},a!=null&&a.duplex?{duplex:a.duplex}:{}));return{data:{path:u,id:h.Id,fullPath:h.Key},error:null}}catch(i){if(Vs(i))return{data:null,error:i};throw i}})}upload(e,r,n){return ka(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,r,n)})}uploadToSignedUrl(e,r,n,s){return ka(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(e),a=this._getFinalPath(i),o=new URL(this.url+`/object/upload/sign/${a}`);o.searchParams.set("token",r);try{let c;const u=Object.assign({upsert:$K.upsert},s),d=Object.assign(Object.assign({},this.headers),{"x-upsert":String(u.upsert)});typeof Blob<"u"&&n instanceof Blob?(c=new FormData,c.append("cacheControl",u.cacheControl),c.append("",n)):typeof FormData<"u"&&n instanceof FormData?(c=n,c.append("cacheControl",u.cacheControl)):(c=n,d["cache-control"]=`max-age=${u.cacheControl}`,d["content-type"]=u.contentType);const h=yield r6(this.fetch,o.toString(),c,{headers:d});return{data:{path:i,fullPath:h.Key},error:null}}catch(c){if(Vs(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(e,r){return ka(this,void 0,void 0,function*(){try{let n=this._getFinalPath(e);const s=Object.assign({},this.headers);r!=null&&r.upsert&&(s["x-upsert"]="true");const i=yield sd(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:s}),a=new URL(this.url+i.url),o=a.searchParams.get("token");if(!o)throw new nV("No token returned by API");return{data:{signedUrl:a.toString(),path:e,token:o},error:null}}catch(n){if(Vs(n))return{data:null,error:n};throw n}})}update(e,r,n){return ka(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,r,n)})}move(e,r,n){return ka(this,void 0,void 0,function*(){try{return{data:yield sd(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers}),error:null}}catch(s){if(Vs(s))return{data:null,error:s};throw s}})}copy(e,r,n){return ka(this,void 0,void 0,function*(){try{return{data:{path:(yield sd(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:r,destinationBucket:n==null?void 0:n.destinationBucket},{headers:this.headers})).Key},error:null}}catch(s){if(Vs(s))return{data:null,error:s};throw s}})}createSignedUrl(e,r,n){return ka(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield sd(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:r},n!=null&&n.transform?{transform:n.transform}:{}),{headers:this.headers});const a=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${a}`)},{data:i,error:null}}catch(s){if(Vs(s))return{data:null,error:s};throw s}})}createSignedUrls(e,r,n){return ka(this,void 0,void 0,function*(){try{const s=yield sd(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:e},{headers:this.headers}),i=n!=null&&n.download?`&download=${n.download===!0?"":n.download}`:"";return{data:s.map(a=>Object.assign(Object.assign({},a),{signedUrl:a.signedURL?encodeURI(`${this.url}${a.signedURL}${i}`):null})),error:null}}catch(s){if(Vs(s))return{data:null,error:s};throw s}})}download(e,r){return ka(this,void 0,void 0,function*(){const s=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),a=i?`?${i}`:"";try{const o=this._getFinalPath(e);return{data:yield(yield Y2(this.fetch,`${this.url}/${s}/${o}${a}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(o){if(Vs(o))return{data:null,error:o};throw o}})}info(e){return ka(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{const n=yield Y2(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:t6(n),error:null}}catch(n){if(Vs(n))return{data:null,error:n};throw n}})}exists(e){return ka(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{return yield zDe(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(Vs(n)&&n instanceof e6){const s=n.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:n}}throw n}})}getPublicUrl(e,r){const n=this._getFinalPath(e),s=[],i=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";i!==""&&s.push(i);const o=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",c=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});c!==""&&s.push(c);let u=s.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${o}/public/${n}${u}`)}}}remove(e){return ka(this,void 0,void 0,function*(){try{return{data:yield ude(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(r){if(Vs(r))return{data:null,error:r};throw r}})}list(e,r,n){return ka(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},UDe),r),{prefix:e||""});return{data:yield sd(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},n),error:null}}catch(s){if(Vs(s))return{data:null,error:s};throw s}})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return typeof Buffer<"u"?Buffer.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const r=[];return e.width&&r.push(`width=${e.width}`),e.height&&r.push(`height=${e.height}`),e.resize&&r.push(`resize=${e.resize}`),e.format&&r.push(`format=${e.format}`),e.quality&&r.push(`quality=${e.quality}`),r.join("&")}}const VDe="2.10.4",WDe={"X-Client-Info":`storage-js/${VDe}`};var Mx=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(d){try{u(n.next(d))}catch(h){a(h)}}function c(d){try{u(n.throw(d))}catch(h){a(h)}}function u(d){d.done?i(d.value):s(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})};class qDe{constructor(e,r={},n,s){const i=new URL(e);s!=null&&s.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase.")),this.url=i.href,this.headers=Object.assign(Object.assign({},WDe),r),this.fetch=cde(n)}listBuckets(){return Mx(this,void 0,void 0,function*(){try{return{data:yield Y2(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(Vs(e))return{data:null,error:e};throw e}})}getBucket(e){return Mx(this,void 0,void 0,function*(){try{return{data:yield Y2(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(r){if(Vs(r))return{data:null,error:r};throw r}})}createBucket(e,r={public:!1}){return Mx(this,void 0,void 0,function*(){try{return{data:yield sd(this.fetch,`${this.url}/bucket`,{id:e,name:e,type:r.type,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(Vs(n))return{data:null,error:n};throw n}})}updateBucket(e,r){return Mx(this,void 0,void 0,function*(){try{return{data:yield r6(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(n){if(Vs(n))return{data:null,error:n};throw n}})}emptyBucket(e){return Mx(this,void 0,void 0,function*(){try{return{data:yield sd(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(Vs(r))return{data:null,error:r};throw r}})}deleteBucket(e){return Mx(this,void 0,void 0,function*(){try{return{data:yield ude(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if(Vs(r))return{data:null,error:r};throw r}})}}class GDe extends qDe{constructor(e,r={},n,s){super(e,r,n,s)}from(e){return new HDe(this.url,this.headers,e,this.fetch)}}const KDe="2.54.0";let lS="";typeof Deno<"u"?lS="deno":typeof document<"u"?lS="web":typeof navigator<"u"&&navigator.product==="ReactNative"?lS="react-native":lS="node";const YDe={"X-Client-Info":`supabase-js-${lS}/${KDe}`},XDe={headers:YDe},JDe={schema:"public"},QDe={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},ZDe={};var eLe=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(d){try{u(n.next(d))}catch(h){a(h)}}function c(d){try{u(n.throw(d))}catch(h){a(h)}}function u(d){d.done?i(d.value):s(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})};const tLe=t=>{let e;return t?e=t:typeof fetch>"u"?e=Yue:e=fetch,(...r)=>e(...r)},rLe=()=>typeof Headers>"u"?Xue:Headers,nLe=(t,e,r)=>{const n=tLe(r),s=rLe();return(i,a)=>eLe(void 0,void 0,void 0,function*(){var o;const c=(o=yield e())!==null&&o!==void 0?o:t;let u=new s(a==null?void 0:a.headers);return u.has("apikey")||u.set("apikey",t),u.has("Authorization")||u.set("Authorization",`Bearer ${c}`),n(i,Object.assign(Object.assign({},a),{headers:u}))})};var sLe=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(d){try{u(n.next(d))}catch(h){a(h)}}function c(d){try{u(n.throw(d))}catch(h){a(h)}}function u(d){d.done?i(d.value):s(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})};function iLe(t){return t.endsWith("/")?t:t+"/"}function aLe(t,e){var r,n;const{db:s,auth:i,realtime:a,global:o}=t,{db:c,auth:u,realtime:d,global:h}=e,f={db:Object.assign(Object.assign({},c),s),auth:Object.assign(Object.assign({},u),i),realtime:Object.assign(Object.assign({},d),a),storage:{},global:Object.assign(Object.assign(Object.assign({},h),o),{headers:Object.assign(Object.assign({},(r=h==null?void 0:h.headers)!==null&&r!==void 0?r:{}),(n=o==null?void 0:o.headers)!==null&&n!==void 0?n:{})}),accessToken:()=>sLe(this,void 0,void 0,function*(){return""})};return t.accessToken?f.accessToken=t.accessToken:delete f.accessToken,f}const dde="2.71.1",Qx=30*1e3,n6=3,yL=n6*Qx,oLe="http://localhost:9999",lLe="supabase.auth.token",cLe={"X-Client-Info":`gotrue-js/${dde}`},s6="X-Supabase-Api-Version",hde={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},uLe=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,dLe=10*60*1e3;class sV extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function zt(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class hLe extends sV{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function fLe(t){return zt(t)&&t.name==="AuthApiError"}class fde extends sV{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class im extends sV{constructor(e,r,n,s){super(e,n,s),this.name=r,this.status=n}}class Yh extends im{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function pLe(t){return zt(t)&&t.name==="AuthSessionMissingError"}class PA extends im{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class OA extends im{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class IA extends im{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function mLe(t){return zt(t)&&t.name==="AuthImplicitGrantRedirectError"}class BK extends im{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class i6 extends im{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function xL(t){return zt(t)&&t.name==="AuthRetryableFetchError"}class zK extends im{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class a6 extends im{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const X2="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),UK=`
\r=`.split(""),gLe=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<UK.length;e+=1)t[UK[e].charCodeAt(0)]=-2;for(let e=0;e<X2.length;e+=1)t[X2[e].charCodeAt(0)]=e;return t})();function HK(t,e,r){if(t!==null)for(e.queue=e.queue<<8|t,e.queuedBits+=8;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;r(X2[n]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;r(X2[n]),e.queuedBits-=6}}function pde(t,e,r){const n=gLe[t];if(n>-1)for(e.queue=e.queue<<6|n,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function VK(t){const e=[],r=a=>{e.push(String.fromCodePoint(a))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=a=>{vLe(a,n,r)};for(let a=0;a<t.length;a+=1)pde(t.charCodeAt(a),s,i);return e.join("")}function yLe(t,e){if(t<=127){e(t);return}else if(t<=2047){e(192|t>>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function xLe(t,e){for(let r=0;r<t.length;r+=1){let n=t.charCodeAt(r);if(n>55295&&n<=56319){const s=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|s)+65536,r+=1}yLe(n,e)}}function vLe(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){e.utf8seq=n;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function bLe(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};for(let s=0;s<t.length;s+=1)pde(t.charCodeAt(s),r,n);return new Uint8Array(e)}function wLe(t){const e=[];return xLe(t,r=>e.push(r)),new Uint8Array(e)}function SLe(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};return t.forEach(s=>HK(s,r,n)),HK(null,r,n),e.join("")}function _Le(t){return Math.round(Date.now()/1e3)+t}function jLe(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t=="x"?e:e&3|8).toString(16)})}const Fl=()=>typeof window<"u"&&typeof document<"u",wm={tested:!1,writable:!1},mde=()=>{if(!Fl())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(wm.tested)return wm.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),wm.tested=!0,wm.writable=!0}catch{wm.tested=!0,wm.writable=!1}return wm.writable};function kLe(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((s,i)=>{e[i]=s})}catch{}return r.searchParams.forEach((n,s)=>{e[s]=n}),e}const gde=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>lE(async()=>{const{default:n}=await Promise.resolve().then(()=>qw);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},NLe=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Zx=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},Sm=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},zh=async(t,e)=>{await t.removeItem(e)};class xR{constructor(){this.promise=new xR.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}xR.promiseConstructor=Promise;function vL(t){const e=t.split(".");if(e.length!==3)throw new a6("Invalid JWT structure");for(let n=0;n<e.length;n++)if(!uLe.test(e[n]))throw new a6("JWT not in base64url format");return{header:JSON.parse(VK(e[0])),payload:JSON.parse(VK(e[1])),signature:bLe(e[2]),raw:{header:e[0],payload:e[1]}}}async function ELe(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function ALe(t,e){return new Promise((n,s)=>{(async()=>{for(let i=0;i<1/0;i++)try{const a=await t(i);if(!e(i,null,a)){n(a);return}}catch(a){if(!e(i,a)){s(a);return}}})()})}function CLe(t){return("0"+t.toString(16)).substr(-2)}function TLe(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let s="";for(let i=0;i<56;i++)s+=r.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,CLe).join("")}async function PLe(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),s=new Uint8Array(n);return Array.from(s).map(i=>String.fromCharCode(i)).join("")}async function OLe(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await PLe(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Dx(t,e,r=!1){const n=TLe();let s=n;r&&(s+="/PASSWORD_RECOVERY"),await Zx(t,`${e}-code-verifier`,s);const i=await OLe(n);return[i,n===i?"plain":"s256"]}const ILe=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function RLe(t){const e=t.headers.get(s6);if(!e||!e.match(ILe))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function MLe(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function DLe(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const LLe=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Lx(t){if(!LLe.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function bL(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function WK(t){return JSON.parse(JSON.stringify(t))}var FLe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(r[n[s]]=t[n[s]]);return r};const Rm=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),$Le=[502,503,504];async function qK(t){var e;if(!NLe(t))throw new i6(Rm(t),0);if($Le.includes(t.status))throw new i6(Rm(t),t.status);let r;try{r=await t.json()}catch(i){throw new fde(Rm(i),i)}let n;const s=RLe(t);if(s&&s.getTime()>=hde["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new zK(Rm(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new Yh}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((i,a)=>i&&typeof a=="string",!0))throw new zK(Rm(r),t.status,r.weak_password.reasons);throw new hLe(Rm(r),t.status||500,n)}const BLe=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),r))};async function sr(t,e,r,n){var s;const i=Object.assign({},n==null?void 0:n.headers);i[s6]||(i[s6]=hde["2024-01-01"].name),n!=null&&n.jwt&&(i.Authorization=`Bearer ${n.jwt}`);const a=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(a.redirect_to=n.redirectTo);const o=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",c=await zLe(t,e,r+o,{headers:i,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(c):{data:Object.assign({},c),error:null}}async function zLe(t,e,r,n,s,i){const a=BLe(e,n,s,i);let o;try{o=await t(r,Object.assign({},a))}catch(c){throw console.error(c),new i6(Rm(c),0)}if(o.ok||await qK(o),n!=null&&n.noResolveJson)return o;try{return await o.json()}catch(c){await qK(c)}}function Ju(t){var e;let r=null;WLe(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=_Le(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}function GK(t){const e=Ju(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}function df(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function ULe(t){return{data:t,error:null}}function HLe(t){const{action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i}=t,a=FLe(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),o={action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i},c=Object.assign({},a);return{data:{properties:o,user:c},error:null}}function VLe(t){return t}function WLe(t){return t.access_token&&t.refresh_token&&t.expires_in}const wL=["global","local","others"];var qLe=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(r[n[s]]=t[n[s]]);return r};class GLe{constructor({url:e="",headers:r={},fetch:n}){this.url=e,this.headers=r,this.fetch=gde(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,r=wL[0]){if(wL.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${wL.join(", ")}`);try{return await sr(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(zt(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,r={}){try{return await sr(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:df})}catch(n){if(zt(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{const{options:r}=e,n=qLe(e,["options"]),s=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(s.new_email=n==null?void 0:n.newEmail,delete s.newEmail),await sr(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:HLe,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(zt(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await sr(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:df})}catch(r){if(zt(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,n,s,i,a,o,c;try{const u={nextPage:null,lastPage:0,total:0},d=await sr(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(i=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:VLe});if(d.error)throw d.error;const h=await d.json(),f=(a=d.headers.get("x-total-count"))!==null&&a!==void 0?a:0,p=(c=(o=d.headers.get("link"))===null||o===void 0?void 0:o.split(","))!==null&&c!==void 0?c:[];return p.length>0&&(p.forEach(m=>{const g=parseInt(m.split(";")[0].split("=")[1].substring(0,1)),x=JSON.parse(m.split(";")[1].split("=")[1]);u[`${x}Page`]=g}),u.total=parseInt(f)),{data:Object.assign(Object.assign({},h),u),error:null}}catch(u){if(zt(u))return{data:{users:[]},error:u};throw u}}async getUserById(e){Lx(e);try{return await sr(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:df})}catch(r){if(zt(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){Lx(e);try{return await sr(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:df})}catch(n){if(zt(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){Lx(e);try{return await sr(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:df})}catch(n){if(zt(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){Lx(e.userId);try{const{data:r,error:n}=await sr(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:r,error:n}}catch(r){if(zt(r))return{data:null,error:r};throw r}}async _deleteFactor(e){Lx(e.userId),Lx(e.id);try{return{data:await sr(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(zt(r))return{data:null,error:r};throw r}}}function KK(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}function KLe(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}const Fx={debug:!!(globalThis&&mde()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class yde extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class YLe extends yde{}async function XLe(t,e,r){Fx.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Fx.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async s=>{if(s){Fx.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await r()}finally{Fx.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw Fx.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new YLe(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Fx.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null," "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}KLe();const JLe={url:oLe,storageKey:lLe,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:cLe,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function YK(t,e,r){return await r()}const $x={};class cj{constructor(e){var r,n;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=cj.nextInstanceID,cj.nextInstanceID+=1,this.instanceID>0&&Fl()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const s=Object.assign(Object.assign({},JLe),e);if(this.logDebugMessages=!!s.debug,typeof s.debug=="function"&&(this.logger=s.debug),this.persistSession=s.persistSession,this.storageKey=s.storageKey,this.autoRefreshToken=s.autoRefreshToken,this.admin=new GLe({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=gde(s.fetch),this.lock=s.lock||YK,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:Fl()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=XLe:this.lock=YK,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?(s.storage?this.storage=s.storage:mde()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=KK(this.memoryStorage)),s.userStorage&&(this.userStorage=s.userStorage)):(this.memoryStorage={},this.storage=KK(this.memoryStorage)),Fl()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(n=this.broadcastChannel)===null||n===void 0||n.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}get jwks(){var e,r;return(r=(e=$x[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){$x[this.storageKey]=Object.assign(Object.assign({},$x[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=$x[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){$x[this.storageKey]=Object.assign(Object.assign({},$x[this.storageKey]),{cachedAt:e})}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${dde}) ${new Date().toISOString()}`,...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{const r=kLe(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),Fl()&&this.detectSessionInUrl&&n!=="none"){const{data:s,error:i}=await this._getSessionFromURL(r,n);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),mLe(i)){const c=(e=i.details)===null||e===void 0?void 0:e.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:a,redirectType:o}=s;return this._debug("#_initialize()","detected session in URL",a,"redirect type",o),await this._saveSession(a),setTimeout(async()=>{o==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",a):await this._notifyAllSubscribers("SIGNED_IN",a)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return zt(r)?{error:r}:{error:new fde("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,s;try{const i=await sr(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:Ju}),{data:a,error:o}=i;if(o||!a)return{data:{user:null,session:null},error:o};const c=a.session,u=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(i){if(zt(i))return{data:{user:null,session:null},error:i};throw i}}async signUp(e){var r,n,s;try{let i;if("email"in e){const{email:d,password:h,options:f}=e;let p=null,m=null;this.flowType==="pkce"&&([p,m]=await Dx(this.storage,this.storageKey)),i=await sr(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:d,password:h,data:(r=f==null?void 0:f.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:p,code_challenge_method:m},xform:Ju})}else if("phone"in e){const{phone:d,password:h,options:f}=e;i=await sr(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:d,password:h,data:(n=f==null?void 0:f.data)!==null&&n!==void 0?n:{},channel:(s=f==null?void 0:f.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:Ju})}else throw new OA("You must provide either an email or phone number and a password");const{data:a,error:o}=i;if(o||!a)return{data:{user:null,session:null},error:o};const c=a.session,u=a.user;return a.session&&(await this._saveSession(a.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(i){if(zt(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithPassword(e){try{let r;if("email"in e){const{email:i,password:a,options:o}=e;r=await sr(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:GK})}else if("phone"in e){const{phone:i,password:a,options:o}=e;r=await sr(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:a,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},xform:GK})}else throw new OA("You must provide either an email or phone number and a password");const{data:n,error:s}=r;return s?{data:{user:null,session:null},error:s}:!n||!n.session||!n.user?{data:{user:null,session:null},error:new PA}:(n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),{data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(r){if(zt(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(e){var r,n,s,i;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:r}=e;if(r==="solana")return await this.signInWithSolana(e);throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}async signInWithSolana(e){var r,n,s,i,a,o,c,u,d,h,f,p;let m,g;if("message"in e)m=e.message,g=e.signature;else{const{chain:x,wallet:y,statement:v,options:b}=e;let w;if(Fl())if(typeof y=="object")w=y;else{const k=window;if("solana"in k&&typeof k.solana=="object"&&("signIn"in k.solana&&typeof k.solana.signIn=="function"||"signMessage"in k.solana&&typeof k.solana.signMessage=="function"))w=k.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof y!="object"||!(b!=null&&b.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");w=y}const S=new URL((r=b==null?void 0:b.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in w&&w.signIn){const k=await w.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},b==null?void 0:b.signInWithSolana),{version:"1",domain:S.host,uri:S.href}),v?{statement:v}:null));let E;if(Array.isArray(k)&&k[0]&&typeof k[0]=="object")E=k[0];else if(k&&typeof k=="object"&&"signedMessage"in k&&"signature"in k)E=k;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in E&&"signature"in E&&(typeof E.signedMessage=="string"||E.signedMessage instanceof Uint8Array)&&E.signature instanceof Uint8Array)m=typeof E.signedMessage=="string"?E.signedMessage:new TextDecoder().decode(E.signedMessage),g=E.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in w)||typeof w.signMessage!="function"||!("publicKey"in w)||typeof w!="object"||!w.publicKey||!("toBase58"in w.publicKey)||typeof w.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");m=[`${S.host} wants you to sign in with your Solana account:`,w.publicKey.toBase58(),...v?["",v,""]:[""],"Version: 1",`URI: ${S.href}`,`Issued At: ${(s=(n=b==null?void 0:b.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((i=b==null?void 0:b.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${b.signInWithSolana.notBefore}`]:[],...!((a=b==null?void 0:b.signInWithSolana)===null||a===void 0)&&a.expirationTime?[`Expiration Time: ${b.signInWithSolana.expirationTime}`]:[],...!((o=b==null?void 0:b.signInWithSolana)===null||o===void 0)&&o.chainId?[`Chain ID: ${b.signInWithSolana.chainId}`]:[],...!((c=b==null?void 0:b.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${b.signInWithSolana.nonce}`]:[],...!((u=b==null?void 0:b.signInWithSolana)===null||u===void 0)&&u.requestId?[`Request ID: ${b.signInWithSolana.requestId}`]:[],...!((h=(d=b==null?void 0:b.signInWithSolana)===null||d===void 0?void 0:d.resources)===null||h===void 0)&&h.length?["Resources",...b.signInWithSolana.resources.map(E=>`- ${E}`)]:[]].join(`
`);const k=await w.signMessage(new TextEncoder().encode(m),"utf8");if(!k||!(k instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");g=k}}try{const{data:x,error:y}=await sr(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:m,signature:SLe(g)},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(p=e.options)===null||p===void 0?void 0:p.captchaToken}}:null),xform:Ju});if(y)throw y;return!x||!x.session||!x.user?{data:{user:null,session:null},error:new PA}:(x.session&&(await this._saveSession(x.session),await this._notifyAllSubscribers("SIGNED_IN",x.session)),{data:Object.assign({},x),error:y})}catch(x){if(zt(x))return{data:{user:null,session:null},error:x};throw x}}async _exchangeCodeForSession(e){const r=await Sm(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(r??"").split("/");try{const{data:i,error:a}=await sr(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Ju});if(await zh(this.storage,`${this.storageKey}-code-verifier`),a)throw a;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new PA}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign(Object.assign({},i),{redirectType:s??null}),error:a})}catch(i){if(zt(i))return{data:{user:null,session:null,redirectType:null},error:i};throw i}}async signInWithIdToken(e){try{const{options:r,provider:n,token:s,access_token:i,nonce:a}=e,o=await sr(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:i,nonce:a,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Ju}),{data:c,error:u}=o;return u?{data:{user:null,session:null},error:u}:!c||!c.session||!c.user?{data:{user:null,session:null},error:new PA}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:u})}catch(r){if(zt(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(e){var r,n,s,i,a;try{if("email"in e){const{email:o,options:c}=e;let u=null,d=null;this.flowType==="pkce"&&([u,d]=await Dx(this.storage,this.storageKey));const{error:h}=await sr(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:o,data:(r=c==null?void 0:c.data)!==null&&r!==void 0?r:{},create_user:(n=c==null?void 0:c.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},code_challenge:u,code_challenge_method:d},redirectTo:c==null?void 0:c.emailRedirectTo});return{data:{user:null,session:null},error:h}}if("phone"in e){const{phone:o,options:c}=e,{data:u,error:d}=await sr(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:o,data:(s=c==null?void 0:c.data)!==null&&s!==void 0?s:{},create_user:(i=c==null?void 0:c.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(a=c==null?void 0:c.channel)!==null&&a!==void 0?a:"sms"}});return{data:{user:null,session:null,messageId:u==null?void 0:u.message_id},error:d}}throw new OA("You must provide either an email or phone number.")}catch(o){if(zt(o))return{data:{user:null,session:null},error:o};throw o}}async verifyOtp(e){var r,n;try{let s,i;"options"in e&&(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo,i=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:a,error:o}=await sr(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:Ju});if(o)throw o;if(!a)throw new Error("An error occurred on token verification.");const c=a.session,u=a.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),{data:{user:u,session:c},error:null}}catch(s){if(zt(s))return{data:{user:null,session:null},error:s};throw s}}async signInWithSSO(e){var r,n,s;try{let i=null,a=null;return this.flowType==="pkce"&&([i,a]=await Dx(this.storage,this.storageKey)),await sr(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:a}),headers:this.headers,xform:ULe})}catch(i){if(zt(i))return{data:null,error:i};throw i}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new Yh;const{error:s}=await sr(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(zt(e))return{data:{user:null,session:null},error:e};throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:n,type:s,options:i}=e,{error:a}=await sr(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:a}}else if("phone"in e){const{phone:n,type:s,options:i}=e,{data:a,error:o}=await sr(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return{data:{user:null,session:null,messageId:a==null?void 0:a.message_id},error:o}}throw new OA("You must provide either an email or phone number and a type")}catch(r){if(zt(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await Sm(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=e.expires_at?e.expires_at*1e3-Date.now()<yL:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.userStorage){const a=await Sm(this.userStorage,this.storageKey+"-user");a!=null&&a.user?e.user=a.user:e.user=bL()}if(this.storage.isServer&&e.user){let a=this.suppressGetSessionWarning;e=new Proxy(e,{get:(c,u,d)=>(!a&&u==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),a=!0,this.suppressGetSessionWarning=!0),Reflect.get(c,u,d))})}return{data:{session:e},error:null}}const{session:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{session:null},error:i}:{data:{session:s},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(e){return e?await this._getUser(e):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(e){try{return e?await sr(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:df}):await this._useSession(async r=>{var n,s,i;const{data:a,error:o}=r;if(o)throw o;return!(!((n=a.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Yh}:await sr(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(s=a.session)===null||s===void 0?void 0:s.access_token)!==null&&i!==void 0?i:void 0,xform:df})})}catch(r){if(zt(r))return pLe(r)&&(await this._removeSession(),await zh(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async n=>{const{data:s,error:i}=n;if(i)throw i;if(!s.session)throw new Yh;const a=s.session;let o=null,c=null;this.flowType==="pkce"&&e.email!=null&&([o,c]=await Dx(this.storage,this.storageKey));const{data:u,error:d}=await sr(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:o,code_challenge_method:c}),jwt:a.access_token,xform:df});if(d)throw d;return a.user=u.user,await this._saveSession(a),await this._notifyAllSubscribers("USER_UPDATED",a),{data:{user:a.user},error:null}})}catch(n){if(zt(n))return{data:{user:null},error:n};throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new Yh;const r=Date.now()/1e3;let n=r,s=!0,i=null;const{payload:a}=vL(e.access_token);if(a.exp&&(n=a.exp,s=n<=r),s){const{session:o,error:c}=await this._callRefreshToken(e.refresh_token);if(c)return{data:{user:null,session:null},error:c};if(!o)return{data:{user:null,session:null},error:null};i=o}else{const{data:o,error:c}=await this._getUser(e.access_token);if(c)throw c;i={access_token:e.access_token,refresh_token:e.refresh_token,user:o.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(r){if(zt(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){const{data:a,error:o}=r;if(o)throw o;e=(n=a.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new Yh;const{session:s,error:i}=await this._callRefreshToken(e.refresh_token);return i?{data:{user:null,session:null},error:i}:s?{data:{user:s.user,session:s},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(zt(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(e,r){try{if(!Fl())throw new IA("No browser detected.");if(e.error||e.error_description||e.error_code)throw new IA(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new BK("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new IA("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new BK("No code detected.");const{data:v,error:b}=await this._exchangeCodeForSession(e.code);if(b)throw b;const w=new URL(window.location.href);return w.searchParams.delete("code"),window.history.replaceState(window.history.state,"",w.toString()),{data:{session:v.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:s,access_token:i,refresh_token:a,expires_in:o,expires_at:c,token_type:u}=e;if(!i||!o||!a||!u)throw new IA("No session defined in URL");const d=Math.round(Date.now()/1e3),h=parseInt(o);let f=d+h;c&&(f=parseInt(c));const p=f-d;p*1e3<=Qx&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${p}s, should have been closer to ${h}s`);const m=f-h;d-m>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",m,f,d):d-m<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",m,f,d);const{data:g,error:x}=await this._getUser(i);if(x)throw x;const y={provider_token:n,provider_refresh_token:s,access_token:i,expires_in:h,expires_at:f,refresh_token:a,token_type:u,user:g.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:y,redirectType:e.type},error:null}}catch(n){if(zt(n))return{data:{session:null,redirectType:null},error:n};throw n}}_isImplicitGrantCallback(e){return!!(e.access_token||e.error_description)}async _isPKCECallback(e){const r=await Sm(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return{error:i};const a=(n=s.session)===null||n===void 0?void 0:n.access_token;if(a){const{error:o}=await this.admin.signOut(a,e);if(o&&!(fLe(o)&&(o.status===404||o.status===401||o.status===403)))return{error:o}}return e!=="others"&&(await this._removeSession(),await zh(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const r=jLe(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,s;try{const{data:{session:i},error:a}=r;if(a)throw a;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",e,"session",i)}catch(i){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",i),console.error(i)}})}async resetPasswordForEmail(e,r={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await Dx(this.storage,this.storageKey,!0));try{return await sr(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(zt(i))return{data:null,error:i};throw i}}async getUserIdentities(){var e;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return{data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null}}catch(r){if(zt(r))return{data:null,error:r};throw r}}async linkIdentity(e){var r;try{const{data:n,error:s}=await this._useSession(async i=>{var a,o,c,u,d;const{data:h,error:f}=i;if(f)throw f;const p=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(a=e.options)===null||a===void 0?void 0:a.redirectTo,scopes:(o=e.options)===null||o===void 0?void 0:o.scopes,queryParams:(c=e.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await sr(this.fetch,"GET",p,{headers:this.headers,jwt:(d=(u=h.session)===null||u===void 0?void 0:u.access_token)!==null&&d!==void 0?d:void 0})});if(s)throw s;return Fl()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),{data:{provider:e.provider,url:n==null?void 0:n.url},error:null}}catch(n){if(zt(n))return{data:{provider:e.provider,url:null},error:n};throw n}}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:a}=r;if(a)throw a;return await sr(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=i.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(r){if(zt(r))return{data:null,error:r};throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await ALe(async s=>(s>0&&await ELe(200*Math.pow(2,s-1)),this._debug(r,"refreshing attempt",s),await sr(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Ju})),(s,i)=>{const a=200*Math.pow(2,s);return i&&xL(i)&&Date.now()+a-n<Qx})}catch(n){if(this._debug(r,"error",n),zt(n))return{data:{session:null,user:null},error:n};throw n}finally{this._debug(r,"end")}}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}async _handleProviderSignIn(e,r){const n=await this._getUrlForProvider(`${this.url}/authorize`,e,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",e,"options",r,"url",n),Fl()&&!r.skipBrowserRedirect&&window.location.assign(n),{data:{provider:e,url:n},error:null}}async _recoverAndRefresh(){var e,r;const n="#_recoverAndRefresh()";this._debug(n,"begin");try{const s=await Sm(this.storage,this.storageKey);if(s&&this.userStorage){let a=await Sm(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!a&&(a={user:s.user},await Zx(this.userStorage,this.storageKey+"-user",a)),s.user=(e=a==null?void 0:a.user)!==null&&e!==void 0?e:bL()}else if(s&&!s.user&&!s.user){const a=await Sm(this.storage,this.storageKey+"-user");a&&(a!=null&&a.user)?(s.user=a.user,await zh(this.storage,this.storageKey+"-user"),await Zx(this.storage,this.storageKey,s)):s.user=bL()}if(this._debug(n,"session from storage",s),!this._isValidSession(s)){this._debug(n,"session is not valid"),s!==null&&await this._removeSession();return}const i=((r=s.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<yL;if(this._debug(n,`session has${i?"":" not"} expired with margin of ${yL}s`),i){if(this.autoRefreshToken&&s.refresh_token){const{error:a}=await this._callRefreshToken(s.refresh_token);a&&(console.error(a),xL(a)||(this._debug(n,"refresh failed with a non-retryable error, removing the session",a),await this._removeSession()))}}else if(s.user&&s.user.__isUserNotAvailableProxy===!0)try{const{data:a,error:o}=await this._getUser(s.access_token);!o&&(a!=null&&a.user)?(s.user=a.user,await this._saveSession(s),await this._notifyAllSubscribers("SIGNED_IN",s)):this._debug(n,"could not get user data, skipping SIGNED_IN notification")}catch(a){console.error("Error getting user data:",a),this._debug(n,"error getting user data, skipping SIGNED_IN notification",a)}else await this._notifyAllSubscribers("SIGNED_IN",s)}catch(s){this._debug(n,"error",s),console.error(s);return}finally{this._debug(n,"end")}}async _callRefreshToken(e){var r,n;if(!e)throw new Yh;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new xR;const{data:i,error:a}=await this._refreshAccessToken(e);if(a)throw a;if(!i.session)throw new Yh;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const o={session:i.session,error:null};return this.refreshingDeferred.resolve(o),o}catch(i){if(this._debug(s,"error",i),zt(i)){const a={session:null,error:i};return xL(i)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(a),a}throw(n=this.refreshingDeferred)===null||n===void 0||n.reject(i),i}finally{this.refreshingDeferred=null,this._debug(s,"end")}}async _notifyAllSubscribers(e,r,n=!0){const s=`#_notifyAllSubscribers(${e})`;this._debug(s,"begin",r,`broadcast = ${n}`);try{this.broadcastChannel&&n&&this.broadcastChannel.postMessage({event:e,session:r});const i=[],a=Array.from(this.stateChangeEmitters.values()).map(async o=>{try{await o.callback(e,r)}catch(c){i.push(c)}});if(await Promise.all(a),i.length>0){for(let o=0;o<i.length;o+=1)console.error(i[o]);throw i[0]}}finally{this._debug(s,"end")}}async _saveSession(e){this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0;const r=Object.assign({},e),n=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!n&&r.user&&await Zx(this.userStorage,this.storageKey+"-user",{user:r.user});const s=Object.assign({},r);delete s.user;const i=WK(s);await Zx(this.storage,this.storageKey,i)}else{const s=WK(r);await Zx(this.storage,this.storageKey,s)}}async _removeSession(){this._debug("#_removeSession()"),await zh(this.storage,this.storageKey),await zh(this.storage,this.storageKey+"-code-verifier"),await zh(this.storage,this.storageKey+"-user"),this.userStorage&&await zh(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&Fl()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const e=setInterval(()=>this._autoRefreshTokenTick(),Qx);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((n.expires_at*1e3-e)/Qx);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${Qx}ms, refresh threshold is ${n6} ticks`),s<=n6&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof yde)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Fl()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){const s=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[i,a]=await Dx(this.storage,this.storageKey),o=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(a)}`});s.push(o.toString())}if(n!=null&&n.queryParams){const i=new URLSearchParams(n.queryParams);s.push(i.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;return i?{data:null,error:i}:await sr(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(zt(r))return{data:null,error:r};throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,s;const{data:i,error:a}=r;if(a)return{data:null,error:a};const o=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:c,error:u}=await sr(this.fetch,"POST",`${this.url}/factors`,{body:o,headers:this.headers,jwt:(n=i==null?void 0:i.session)===null||n===void 0?void 0:n.access_token});return u?{data:null,error:u}:(e.factorType==="totp"&&(!((s=c==null?void 0:c.totp)===null||s===void 0)&&s.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),{data:c,error:null})})}catch(r){if(zt(r))return{data:null,error:r};throw r}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;if(i)return{data:null,error:i};const{data:a,error:o}=await sr(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return o?{data:null,error:o}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),{data:a,error:o})})}catch(r){if(zt(r))return{data:null,error:r};throw r}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:i}=r;return i?{data:null,error:i}:await sr(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:{channel:e.channel},headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(zt(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(e){const{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?{data:null,error:n}:await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){const{data:{user:e},error:r}=await this.getUser();if(r)return{data:null,error:r};const n=(e==null?void 0:e.factors)||[],s=n.filter(a=>a.factor_type==="totp"&&a.status==="verified"),i=n.filter(a=>a.factor_type==="phone"&&a.status==="verified");return{data:{all:n,totp:s,phone:i},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async e=>{var r,n;const{data:{session:s},error:i}=e;if(i)return{data:null,error:i};if(!s)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:a}=vL(s.access_token);let o=null;a.aal&&(o=a.aal);let c=o;((n=(r=s.user.factors)===null||r===void 0?void 0:r.filter(h=>h.status==="verified"))!==null&&n!==void 0?n:[]).length>0&&(c="aal2");const d=a.amr||[];return{data:{currentLevel:o,nextLevel:c,currentAuthenticationMethods:d},error:null}}))}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(o=>o.kid===e);if(n)return n;const s=Date.now();if(n=this.jwks.keys.find(o=>o.kid===e),n&&this.jwks_cached_at+dLe>s)return n;const{data:i,error:a}=await sr(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(a)throw a;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=s,n=i.keys.find(o=>o.kid===e),!n)?null:n}async getClaims(e,r={}){try{let n=e;if(!n){const{data:p,error:m}=await this.getSession();if(m||!p.session)return{data:null,error:m};n=p.session.access_token}const{header:s,payload:i,signature:a,raw:{header:o,payload:c}}=vL(n);r!=null&&r.allowExpired||MLe(i.exp);const u=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!u){const{error:p}=await this.getUser(n);if(p)throw p;return{data:{claims:i,header:s,signature:a},error:null}}const d=DLe(s.alg),h=await crypto.subtle.importKey("jwk",u,d,!0,["verify"]);if(!await crypto.subtle.verify(d,h,a,wLe(`${o}.${c}`)))throw new a6("Invalid JWT signature");return{data:{claims:i,header:s,signature:a},error:null}}catch(n){if(zt(n))return{data:null,error:n};throw n}}}cj.nextInstanceID=0;const QLe=cj;class ZLe extends QLe{constructor(e){super(e)}}var e4e=function(t,e,r,n){function s(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function o(d){try{u(n.next(d))}catch(h){a(h)}}function c(d){try{u(n.throw(d))}catch(h){a(h)}}function u(d){d.done?i(d.value):s(d.value).then(o,c)}u((n=n.apply(t,e||[])).next())})};class t4e{constructor(e,r,n){var s,i,a;if(this.supabaseUrl=e,this.supabaseKey=r,!e)throw new Error("supabaseUrl is required.");if(!r)throw new Error("supabaseKey is required.");const o=iLe(e),c=new URL(o);this.realtimeUrl=new URL("realtime/v1",c),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",c),this.storageUrl=new URL("storage/v1",c),this.functionsUrl=new URL("functions/v1",c);const u=`sb-${c.hostname.split(".")[0]}-auth-token`,d={db:JDe,realtime:ZDe,auth:Object.assign(Object.assign({},QDe),{storageKey:u}),global:XDe},h=aLe(n??{},d);this.storageKey=(s=h.auth.storageKey)!==null&&s!==void 0?s:"",this.headers=(i=h.global.headers)!==null&&i!==void 0?i:{},h.accessToken?(this.accessToken=h.accessToken,this.auth=new Proxy({},{get:(f,p)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(p)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((a=h.auth)!==null&&a!==void 0?a:{},this.headers,h.global.fetch),this.fetch=nLe(r,this._getAccessToken.bind(this),h.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},h.realtime)),this.rest=new yDe(new URL("rest/v1",c).href,{headers:this.headers,schema:h.db.schema,fetch:this.fetch}),this.storage=new GDe(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),h.accessToken||this._listenForAuthEvents()}get functions(){return new GMe(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,r={},n={}){return this.rest.rpc(e,r,n)}channel(e,r={config:{}}){return this.realtime.channel(e,r)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,r;return e4e(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:n}=yield this.auth.getSession();return(r=(e=n.session)===null||e===void 0?void 0:e.access_token)!==null&&r!==void 0?r:this.supabaseKey})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,storageKey:i,flowType:a,lock:o,debug:c},u,d){const h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new ZLe({url:this.authUrl.href,headers:Object.assign(Object.assign({},h),u),storageKey:i,autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,flowType:a,lock:o,debug:c,fetch:d,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new RDe(this.realtimeUrl.href,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,n)=>{this._handleTokenChanged(r,"CLIENT",n==null?void 0:n.access_token)})}_handleTokenChanged(e,r,n){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==n?this.changedAccessToken=n:e==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const xde=(t,e,r)=>new t4e(t,e,r);function r4e(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const e=t.match(/^v(\d+)\./);return e?parseInt(e[1],10)<=18:!1}r4e()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const n4e="https://nqibmbtqcjucktqcreob.supabase.co",s4e="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5xaWJtYnRxY2p1Y2t0cWNyZW9iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1NTk5MTAsImV4cCI6MjA3MDEzNTkxMH0.UnFk-GqYCZtlkXNlxyHUTaFAnS6Q4hIgDgWKANrxEHg",Qr=xde(n4e,s4e,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),vde=j.createContext(void 0);function i4e({children:t}){const[e,r]=j.useState(null),[n,s]=j.useState(null),[i,a]=j.useState(null),[o,c]=j.useState(null),[u,d]=j.useState(!0),h=async N=>{try{await Promise.all([f(N),p(N),m(N)])}catch(U){console.error("Error loading user data:",U)}finally{d(!1)}};j.useEffect(()=>{let N=!0;Qr.auth.getSession().then(async({data:{session:K}})=>{N&&(r((K==null?void 0:K.user)??null),K!=null&&K.user?await h(K.user.id):d(!1))});const{data:{subscription:U}}=Qr.auth.onAuthStateChange((K,G)=>{N&&(K==="SIGNED_IN"&&d(!0),r((G==null?void 0:G.user)??null),G!=null&&G.user?setTimeout(async()=>{N&&await h(G.user.id)},0):(s(null),a(null),c(null),d(!1)))});return()=>{N=!1,U.unsubscribe()}},[]);const f=async N=>{try{const{data:U,error:K}=await Qr.from("users").select("*").eq("id",N).maybeSingle();if(K){if(console.error("Error fetching user profile:",K),K.code==="PGRST116"){await v(N);return}}else U?s(U):await v(N)}catch(U){console.error("Error in fetchUserProfile:",U)}},p=async N=>{try{const{data:U,error:K}=await Qr.from("user_profiles").select("*").eq("user_id",N).maybeSingle();if(K&&K.code!=="PGRST116"){console.error("Error fetching research profile:",K);return}a(U)}catch(U){console.error("Error in fetchResearchProfile:",U)}},m=async N=>{try{const{data:U,error:K}=await Qr.from("user_student_points").select("total_purchased, used_points, remaining_points").eq("user_id",N).maybeSingle();if(K)throw K;c({total:(U==null?void 0:U.total_purchased)||60,used:(U==null?void 0:U.used_points)||0,remaining:(U==null?void 0:U.remaining_points)||60})}catch(U){console.error("Error fetching student points:",U),c({total:60,used:0,remaining:60})}},g=async N=>{await m(N)},x=async()=>{e&&(await f(e.id),await m(e.id))},y=async N=>{await p(N)},v=async(N,U)=>{var K;try{const{data:G}=await Qr.auth.getUser();if(!((K=G.user)!=null&&K.email))return;const X={id:N,email:G.user.email,plan:"starter",current_token_balance:30};if(U)X.terms_accepted_at=U.terms_accepted_at,X.privacy_accepted_at=U.privacy_accepted_at,X.terms_version=U.terms_version,X.privacy_version=U.privacy_version,X.marketing_consent=!0,X.marketing_consent_at=U.terms_accepted_at;else if(G.user.user_metadata){const L=G.user.user_metadata;L.terms_accepted_at&&(X.terms_accepted_at=L.terms_accepted_at,X.privacy_accepted_at=L.privacy_accepted_at,X.terms_version=L.terms_version,X.privacy_version=L.privacy_version,X.marketing_consent=!0,X.marketing_consent_at=L.terms_accepted_at)}const{data:H,error:B}=await Qr.from("users").insert(X).select().single();if(B)if(B.code==="23505"){console.log("User profile already exists, fetching...");const{data:L}=await Qr.from("users").select("*").eq("id",N).single();L&&s(L)}else console.error("Error creating user profile:",B);else s(H)}catch(G){console.error("Error in createUserProfile:",G)}},b=async(N,U)=>{if(!N||!N.includes("@"))return{error:{message:"Please enter a valid email address"}};if(!U||U.length<6)return{error:{message:"Password must be at least 6 characters"}};const{error:K}=await Qr.auth.signInWithPassword({email:N.trim().toLowerCase(),password:U});return K||typeof window<"u"&&window.umami&&window.umami.track("user-login"),{error:K}},w=async(N,U,K)=>{if(!N||!N.includes("@"))return{error:{message:"Please enter a valid email address"}};if(!U||U.length<6)return{error:{message:"Password must be at least 6 characters"}};const{data:G,error:X}=await Qr.auth.signUp({email:N.trim().toLowerCase(),password:U,options:{emailRedirectTo:`${window.location.origin}/dashboard`,data:K?{terms_accepted_at:K.terms_accepted_at,privacy_accepted_at:K.privacy_accepted_at,terms_version:K.terms_version,privacy_version:K.privacy_version}:void 0}});return!X&&G.user&&K&&await v(G.user.id,K),{error:X}},S=async()=>{const{error:N}=await Qr.auth.signOut();return N||(r(null),s(null),a(null),c(null)),{error:N}},k=N=>{switch(N){case"starter":return 30;case"pro":return 100;case"author":return 200;default:return 30}},E=async N=>{try{const{data:U,error:K}=await Qr.rpc("consume_tokens",{pages_to_consume:N});return K?(console.error("Token consumption error:",K),{success:!1,error:K.message}):(e&&await f(e.id),U)}catch(U){return console.error("Token consumption error:",U),{success:!1,error:U.message||"Failed to consume tokens"}}},C=-20,A=()=>o?o.remaining>C:!1,M=async N=>{if(e)try{const{error:U}=await Qr.from("user_profiles").upsert({user_id:e.id,...N,updated_at:new Date().toISOString()},{onConflict:"user_id"});if(U)throw U;await y(e.id)}catch(U){throw console.error("Error updating research profile:",U),U}},W={user:e,userProfile:n,researchProfile:i,studentPoints:o,loading:u,signIn:b,signUp:w,signOut:S,getPlanLimit:k,consumeTokens:E,fetchStudentPoints:g,refreshProfile:x,checkStudentPoints:A,updateResearchProfile:M,uploadAvatar:async N=>{if(!e)throw new Error("No user logged in");try{const U=N.name.split(".").pop(),K=`${e.id}/avatar.${U}`,{error:G}=await Qr.storage.from("avatars").upload(K,N,{upsert:!0});if(G)throw G;return await M({avatar_url:K}),K}catch(U){throw console.error("Error uploading avatar:",U),U}},selectPublicAvatar:async N=>{if(!e)throw new Error("No user logged in");await M({avatar_url:N})}};return l.jsx(vde.Provider,{value:W,children:t})}function Dt(){const t=j.useContext(vde);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const iV=Nh("inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium ring-offset-background transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 active:scale-[0.98]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90 rounded-xl shadow-md shadow-primary/20 hover:shadow-lg hover:shadow-primary/30",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 rounded-xl shadow-md",outline:"border border-border/50 bg-card/50 backdrop-blur-sm hover:bg-muted/50 hover:text-foreground rounded-xl dark:border-border/30",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 rounded-xl",ghost:"hover:bg-muted/50 hover:text-foreground rounded-xl",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-5 py-2",sm:"h-9 rounded-xl px-4",lg:"h-12 rounded-xl px-8",icon:"h-10 w-10 rounded-xl"}},defaultVariants:{variant:"default",size:"default"}}),ye=j.forwardRef(({className:t,variant:e,size:r,asChild:n=!1,...s},i)=>{const a=n?cTe:"button";return l.jsx(a,{className:Le(iV({variant:e,size:r,className:t})),ref:i,...s})});ye.displayName="Button";var a4e=j.createContext(void 0);function xx(t){const e=j.useContext(a4e);return t||e||"ltr"}var SL=0;function vR(){j.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??XK()),document.body.insertAdjacentElement("beforeend",t[1]??XK()),SL++,()=>{SL===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),SL--}},[])}function XK(){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}var _L="focusScope.autoFocusOnMount",jL="focusScope.autoFocusOnUnmount",JK={bubbles:!1,cancelable:!0},o4e="FocusScope",dE=j.forwardRef((t,e)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:i,...a}=t,[o,c]=j.useState(null),u=Hn(s),d=Hn(i),h=j.useRef(null),f=It(e,g=>c(g)),p=j.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;j.useEffect(()=>{if(n){let g=function(b){if(p.paused||!o)return;const w=b.target;o.contains(w)?h.current=w:Xh(h.current,{select:!0})},x=function(b){if(p.paused||!o)return;const w=b.relatedTarget;w!==null&&(o.contains(w)||Xh(h.current,{select:!0}))},y=function(b){if(document.activeElement===document.body)for(const S of b)S.removedNodes.length>0&&Xh(o)};document.addEventListener("focusin",g),document.addEventListener("focusout",x);const v=new MutationObserver(y);return o&&v.observe(o,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",x),v.disconnect()}}},[n,o,p.paused]),j.useEffect(()=>{if(o){ZK.add(p);const g=document.activeElement;if(!o.contains(g)){const y=new CustomEvent(_L,JK);o.addEventListener(_L,u),o.dispatchEvent(y),y.defaultPrevented||(l4e(f4e(bde(o)),{select:!0}),document.activeElement===g&&Xh(o))}return()=>{o.removeEventListener(_L,u),setTimeout(()=>{const y=new CustomEvent(jL,JK);o.addEventListener(jL,d),o.dispatchEvent(y),y.defaultPrevented||Xh(g??document.body,{select:!0}),o.removeEventListener(jL,d),ZK.remove(p)},0)}}},[o,u,d,p]);const m=j.useCallback(g=>{if(!r&&!n||p.paused)return;const x=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,y=document.activeElement;if(x&&y){const v=g.currentTarget,[b,w]=c4e(v);b&&w?!g.shiftKey&&y===w?(g.preventDefault(),r&&Xh(b,{select:!0})):g.shiftKey&&y===b&&(g.preventDefault(),r&&Xh(w,{select:!0})):y===v&&g.preventDefault()}},[r,n,p.paused]);return l.jsx(ot.div,{tabIndex:-1,...a,ref:f,onKeyDown:m})});dE.displayName=o4e;function l4e(t,{select:e=!1}={}){const r=document.activeElement;for(const n of t)if(Xh(n,{select:e}),document.activeElement!==r)return}function c4e(t){const e=bde(t),r=QK(e,t),n=QK(e.reverse(),t);return[r,n]}function bde(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||s?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function QK(t,e){for(const r of t)if(!u4e(r,{upTo:e}))return r}function u4e(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}function d4e(t){return t instanceof HTMLInputElement&&"select"in t}function Xh(t,{select:e=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&d4e(t)&&e&&t.select()}}var ZK=h4e();function h4e(){let t=[];return{add(e){const r=t[0];e!==r&&(r==null||r.pause()),t=eY(t,e),t.unshift(e)},remove(e){var r;t=eY(t,e),(r=t[0])==null||r.resume()}}}function eY(t,e){const r=[...t],n=r.indexOf(e);return n!==-1&&r.splice(n,1),r}function f4e(t){return t.filter(e=>e.tagName!=="A")}var kL="rovingFocusGroup.onEntryFocus",p4e={bubbles:!1,cancelable:!0},hE="RovingFocusGroup",[o6,wde,m4e]=rE(hE),[g4e,Kw]=gs(hE,[m4e]),[y4e,x4e]=g4e(hE),Sde=j.forwardRef((t,e)=>l.jsx(o6.Provider,{scope:t.__scopeRovingFocusGroup,children:l.jsx(o6.Slot,{scope:t.__scopeRovingFocusGroup,children:l.jsx(v4e,{...t,ref:e})})}));Sde.displayName=hE;var v4e=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:s=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:o,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...h}=t,f=j.useRef(null),p=It(e,f),m=xx(i),[g,x]=_i({prop:a,defaultProp:o??null,onChange:c,caller:hE}),[y,v]=j.useState(!1),b=Hn(u),w=wde(r),S=j.useRef(!1),[k,E]=j.useState(0);return j.useEffect(()=>{const C=f.current;if(C)return C.addEventListener(kL,b),()=>C.removeEventListener(kL,b)},[b]),l.jsx(y4e,{scope:r,orientation:n,dir:m,loop:s,currentTabStopId:g,onItemFocus:j.useCallback(C=>x(C),[x]),onItemShiftTab:j.useCallback(()=>v(!0),[]),onFocusableItemAdd:j.useCallback(()=>E(C=>C+1),[]),onFocusableItemRemove:j.useCallback(()=>E(C=>C-1),[]),children:l.jsx(ot.div,{tabIndex:y||k===0?-1:0,"data-orientation":n,...h,ref:p,style:{outline:"none",...t.style},onMouseDown:Ke(t.onMouseDown,()=>{S.current=!0}),onFocus:Ke(t.onFocus,C=>{const A=!S.current;if(C.target===C.currentTarget&&A&&!y){const M=new CustomEvent(kL,p4e);if(C.currentTarget.dispatchEvent(M),!M.defaultPrevented){const z=w().filter(K=>K.focusable),P=z.find(K=>K.active),W=z.find(K=>K.id===g),U=[P,W,...z].filter(Boolean).map(K=>K.ref.current);kde(U,d)}}S.current=!1}),onBlur:Ke(t.onBlur,()=>v(!1))})})}),_de="RovingFocusGroupItem",jde=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:s=!1,tabStopId:i,children:a,...o}=t,c=Ka(),u=i||c,d=x4e(_de,r),h=d.currentTabStopId===u,f=wde(r),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:g}=d;return j.useEffect(()=>{if(n)return p(),()=>m()},[n,p,m]),l.jsx(o6.ItemSlot,{scope:r,id:u,focusable:n,active:s,children:l.jsx(ot.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...o,ref:e,onMouseDown:Ke(t.onMouseDown,x=>{n?d.onItemFocus(u):x.preventDefault()}),onFocus:Ke(t.onFocus,()=>d.onItemFocus(u)),onKeyDown:Ke(t.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){d.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const y=S4e(x,d.orientation,d.dir);if(y!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let b=f().filter(w=>w.focusable).map(w=>w.ref.current);if(y==="last")b.reverse();else if(y==="prev"||y==="next"){y==="prev"&&b.reverse();const w=b.indexOf(x.currentTarget);b=d.loop?_4e(b,w+1):b.slice(w+1)}setTimeout(()=>kde(b))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:g!=null}):a})})});jde.displayName=_de;var b4e={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function w4e(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function S4e(t,e,r){const n=w4e(t.key,r);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return b4e[n]}function kde(t,e=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:e}),document.activeElement!==r))return}function _4e(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var aV=Sde,oV=jde,j4e=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Bx=new WeakMap,RA=new WeakMap,MA={},NL=0,Nde=function(t){return t&&(t.host||Nde(t.parentNode))},k4e=function(t,e){return e.map(function(r){if(t.contains(r))return r;var n=Nde(r);return n&&t.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",t,". Doing nothing"),null)}).filter(function(r){return!!r})},N4e=function(t,e,r,n){var s=k4e(e,Array.isArray(t)?t:[t]);MA[r]||(MA[r]=new WeakMap);var i=MA[r],a=[],o=new Set,c=new Set(s),u=function(h){!h||o.has(h)||(o.add(h),u(h.parentNode))};s.forEach(u);var d=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(f){if(o.has(f))d(f);else try{var p=f.getAttribute(n),m=p!==null&&p!=="false",g=(Bx.get(f)||0)+1,x=(i.get(f)||0)+1;Bx.set(f,g),i.set(f,x),a.push(f),g===1&&m&&RA.set(f,!0),x===1&&f.setAttribute(r,"true"),m||f.setAttribute(n,"true")}catch(y){console.error("aria-hidden: cannot operate on ",f,y)}})};return d(e),o.clear(),NL++,function(){a.forEach(function(h){var f=Bx.get(h)-1,p=i.get(h)-1;Bx.set(h,f),i.set(h,p),f||(RA.has(h)||h.removeAttribute(n),RA.delete(h)),p||h.removeAttribute(r)}),NL--,NL||(Bx=new WeakMap,Bx=new WeakMap,RA=new WeakMap,MA={})}},bR=function(t,e,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),s=j4e(t);return s?(n.push.apply(n,Array.from(s.querySelectorAll("[aria-live]"))),N4e(n,s,r,"aria-hidden")):function(){return null}},fu=function(){return fu=Object.assign||function(e){for(var r,n=1,s=arguments.length;n<s;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},fu.apply(this,arguments)};function Ede(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(r[n[s]]=t[n[s]]);return r}function E4e(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,i;n<s;n++)(i||!(n in e))&&(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}var dT="right-scroll-bar-position",hT="width-before-scroll-bar",A4e="with-scroll-bars-hidden",C4e="--removed-body-scroll-bar-size";function EL(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function T4e(t,e){var r=j.useState(function(){return{value:t,callback:e,facade:{get current(){return r.value},set current(n){var s=r.value;s!==n&&(r.value=n,r.callback(n,s))}}}})[0];return r.callback=e,r.facade}var P4e=typeof window<"u"?j.useLayoutEffect:j.useEffect,tY=new WeakMap;function O4e(t,e){var r=T4e(null,function(n){return t.forEach(function(s){return EL(s,n)})});return P4e(function(){var n=tY.get(r);if(n){var s=new Set(n),i=new Set(t),a=r.current;s.forEach(function(o){i.has(o)||EL(o,null)}),i.forEach(function(o){s.has(o)||EL(o,a)})}tY.set(r,t)},[t]),r}function I4e(t){return t}function R4e(t,e){e===void 0&&(e=I4e);var r=[],n=!1,s={read:function(){if(n)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:t},useMedium:function(i){var a=e(i,n);return r.push(a),function(){r=r.filter(function(o){return o!==a})}},assignSyncMedium:function(i){for(n=!0;r.length;){var a=r;r=[],a.forEach(i)}r={push:function(o){return i(o)},filter:function(){return r}}},assignMedium:function(i){n=!0;var a=[];if(r.length){var o=r;r=[],o.forEach(i),a=r}var c=function(){var d=a;a=[],d.forEach(i)},u=function(){return Promise.resolve().then(c)};u(),r={push:function(d){a.push(d),u()},filter:function(d){return a=a.filter(d),r}}}};return s}function M4e(t){t===void 0&&(t={});var e=R4e(null);return e.options=fu({async:!0,ssr:!1},t),e}var Ade=function(t){var e=t.sideCar,r=Ede(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var n=e.read();if(!n)throw new Error("Sidecar medium not found");return j.createElement(n,fu({},r))};Ade.isSideCarExport=!0;function D4e(t,e){return t.useMedium(e),Ade}var Cde=M4e(),AL=function(){},wR=j.forwardRef(function(t,e){var r=j.useRef(null),n=j.useState({onScrollCapture:AL,onWheelCapture:AL,onTouchMoveCapture:AL}),s=n[0],i=n[1],a=t.forwardProps,o=t.children,c=t.className,u=t.removeScrollBar,d=t.enabled,h=t.shards,f=t.sideCar,p=t.noRelative,m=t.noIsolation,g=t.inert,x=t.allowPinchZoom,y=t.as,v=y===void 0?"div":y,b=t.gapMode,w=Ede(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=f,k=O4e([r,e]),E=fu(fu({},w),s);return j.createElement(j.Fragment,null,d&&j.createElement(S,{sideCar:Cde,removeScrollBar:u,shards:h,noRelative:p,noIsolation:m,inert:g,setCallbacks:i,allowPinchZoom:!!x,lockRef:r,gapMode:b}),a?j.cloneElement(j.Children.only(o),fu(fu({},E),{ref:k})):j.createElement(v,fu({},E,{className:c,ref:k}),o))});wR.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};wR.classNames={fullWidth:hT,zeroRight:dT};var L4e=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function F4e(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=L4e();return e&&t.setAttribute("nonce",e),t}function $4e(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function B4e(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var z4e=function(){var t=0,e=null;return{add:function(r){t==0&&(e=F4e())&&($4e(e,r),B4e(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},U4e=function(){var t=z4e();return function(e,r){j.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&r])}},Tde=function(){var t=U4e(),e=function(r){var n=r.styles,s=r.dynamic;return t(n,s),null};return e},H4e={left:0,top:0,right:0,gap:0},CL=function(t){return parseInt(t||"",10)||0},V4e=function(t){var e=window.getComputedStyle(document.body),r=e[t==="padding"?"paddingLeft":"marginLeft"],n=e[t==="padding"?"paddingTop":"marginTop"],s=e[t==="padding"?"paddingRight":"marginRight"];return[CL(r),CL(n),CL(s)]},W4e=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return H4e;var e=V4e(t),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,n-r+e[2]-e[0])}},q4e=Tde(),rb="data-scroll-locked",G4e=function(t,e,r,n){var s=t.left,i=t.top,a=t.right,o=t.gap;return r===void 0&&(r="margin"),`
.`.concat(A4e,` {
overflow: hidden `).concat(n,`;
padding-right: `).concat(o,"px ").concat(n,`;
}
body[`).concat(rb,`] {
overflow: hidden `).concat(n,`;
overscroll-behavior: contain;
`).concat([e&&"position: relative ".concat(n,";"),r==="margin"&&`
padding-left: `.concat(s,`px;
padding-top: `).concat(i,`px;
padding-right: `).concat(a,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(o,"px ").concat(n,`;
`),r==="padding"&&"padding-right: ".concat(o,"px ").concat(n,";")].filter(Boolean).join(""),`
}
.`).concat(dT,` {
right: `).concat(o,"px ").concat(n,`;
}
.`).concat(hT,` {
margin-right: `).concat(o,"px ").concat(n,`;
}
.`).concat(dT," .").concat(dT,` {
right: 0 `).concat(n,`;
}
.`).concat(hT," .").concat(hT,` {
margin-right: 0 `).concat(n,`;
}
body[`).concat(rb,`] {
`).concat(C4e,": ").concat(o,`px;
}
`)},rY=function(){var t=parseInt(document.body.getAttribute(rb)||"0",10);return isFinite(t)?t:0},K4e=function(){j.useEffect(function(){return document.body.setAttribute(rb,(rY()+1).toString()),function(){var t=rY()-1;t<=0?document.body.removeAttribute(rb):document.body.setAttribute(rb,t.toString())}},[])},Y4e=function(t){var e=t.noRelative,r=t.noImportant,n=t.gapMode,s=n===void 0?"margin":n;K4e();var i=j.useMemo(function(){return W4e(s)},[s]);return j.createElement(q4e,{styles:G4e(i,!e,s,r?"":"!important")})},l6=!1;if(typeof window<"u")try{var DA=Object.defineProperty({},"passive",{get:function(){return l6=!0,!0}});window.addEventListener("test",DA,DA),window.removeEventListener("test",DA,DA)}catch{l6=!1}var zx=l6?{passive:!1}:!1,X4e=function(t){return t.tagName==="TEXTAREA"},Pde=function(t,e){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[e]!=="hidden"&&!(r.overflowY===r.overflowX&&!X4e(t)&&r[e]==="visible")},J4e=function(t){return Pde(t,"overflowY")},Q4e=function(t){return Pde(t,"overflowX")},nY=function(t,e){var r=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var s=Ode(t,n);if(s){var i=Ide(t,n),a=i[1],o=i[2];if(a>o)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},Z4e=function(t){var e=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[e,r,n]},e5e=function(t){var e=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[e,r,n]},Ode=function(t,e){return t==="v"?J4e(e):Q4e(e)},Ide=function(t,e){return t==="v"?Z4e(e):e5e(e)},t5e=function(t,e){return t==="h"&&e==="rtl"?-1:1},r5e=function(t,e,r,n,s){var i=t5e(t,window.getComputedStyle(e).direction),a=i*n,o=r.target,c=e.contains(o),u=!1,d=a>0,h=0,f=0;do{if(!o)break;var p=Ide(t,o),m=p[0],g=p[1],x=p[2],y=g-x-i*m;(m||y)&&Ode(t,o)&&(h+=y,f+=m);var v=o.parentNode;o=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&o!==document.body||c&&(e.contains(o)||e===o));return(d&&(Math.abs(h)<1||!s)||!d&&(Math.abs(f)<1||!s))&&(u=!0),u},LA=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},sY=function(t){return[t.deltaX,t.deltaY]},iY=function(t){return t&&"current"in t?t.current:t},n5e=function(t,e){return t[0]===e[0]&&t[1]===e[1]},s5e=function(t){return`
.block-interactivity-`.concat(t,` {pointer-events: none;}
.allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},i5e=0,Ux=[];function a5e(t){var e=j.useRef([]),r=j.useRef([0,0]),n=j.useRef(),s=j.useState(i5e++)[0],i=j.useState(Tde)[0],a=j.useRef(t);j.useEffect(function(){a.current=t},[t]),j.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var g=E4e([t.lockRef.current],(t.shards||[]).map(iY),!0).filter(Boolean);return g.forEach(function(x){return x.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),g.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var o=j.useCallback(function(g,x){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!a.current.allowPinchZoom;var y=LA(g),v=r.current,b="deltaX"in g?g.deltaX:v[0]-y[0],w="deltaY"in g?g.deltaY:v[1]-y[1],S,k=g.target,E=Math.abs(b)>Math.abs(w)?"h":"v";if("touches"in g&&E==="h"&&k.type==="range")return!1;var C=nY(E,k);if(!C)return!0;if(C?S=E:(S=E==="v"?"h":"v",C=nY(E,k)),!C)return!1;if(!n.current&&"changedTouches"in g&&(b||w)&&(n.current=S),!S)return!0;var A=n.current||S;return r5e(A,x,g,A==="h"?b:w,!0)},[]),c=j.useCallback(function(g){var x=g;if(!(!Ux.length||Ux[Ux.length-1]!==i)){var y="deltaY"in x?sY(x):LA(x),v=e.current.filter(function(S){return S.name===x.type&&(S.target===x.target||x.target===S.shadowParent)&&n5e(S.delta,y)})[0];if(v&&v.should){x.cancelable&&x.preventDefault();return}if(!v){var b=(a.current.shards||[]).map(iY).filter(Boolean).filter(function(S){return S.contains(x.target)}),w=b.length>0?o(x,b[0]):!a.current.noIsolation;w&&x.cancelable&&x.preventDefault()}}},[]),u=j.useCallback(function(g,x,y,v){var b={name:g,delta:x,target:y,should:v,shadowParent:o5e(y)};e.current.push(b),setTimeout(function(){e.current=e.current.filter(function(w){return w!==b})},1)},[]),d=j.useCallback(function(g){r.current=LA(g),n.current=void 0},[]),h=j.useCallback(function(g){u(g.type,sY(g),g.target,o(g,t.lockRef.current))},[]),f=j.useCallback(function(g){u(g.type,LA(g),g.target,o(g,t.lockRef.current))},[]);j.useEffect(function(){return Ux.push(i),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,zx),document.addEventListener("touchmove",c,zx),document.addEventListener("touchstart",d,zx),function(){Ux=Ux.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,zx),document.removeEventListener("touchmove",c,zx),document.removeEventListener("touchstart",d,zx)}},[]);var p=t.removeScrollBar,m=t.inert;return j.createElement(j.Fragment,null,m?j.createElement(i,{styles:s5e(s)}):null,p?j.createElement(Y4e,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function o5e(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const l5e=D4e(Cde,a5e);var fE=j.forwardRef(function(t,e){return j.createElement(wR,fu({},t,{ref:e,sideCar:l5e}))});fE.classNames=wR.classNames;var c6=["Enter"," "],c5e=["ArrowDown","PageUp","Home"],Rde=["ArrowUp","PageDown","End"],u5e=[...c5e,...Rde],d5e={ltr:[...c6,"ArrowRight"],rtl:[...c6,"ArrowLeft"]},h5e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},pE="Menu",[uj,f5e,p5e]=rE(pE),[vx,Mde]=gs(pE,[p5e,nm,Kw]),SR=nm(),Dde=Kw(),[m5e,bx]=vx(pE),[g5e,mE]=vx(pE),Lde=t=>{const{__scopeMenu:e,open:r=!1,children:n,dir:s,onOpenChange:i,modal:a=!0}=t,o=SR(e),[c,u]=j.useState(null),d=j.useRef(!1),h=Hn(i),f=xx(s);return j.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),l.jsx(iR,{...o,children:l.jsx(m5e,{scope:e,open:r,onOpenChange:h,content:c,onContentChange:u,children:l.jsx(g5e,{scope:e,onClose:j.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:f,modal:a,children:n})})})};Lde.displayName=pE;var y5e="MenuAnchor",lV=j.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=SR(r);return l.jsx(aE,{...s,...n,ref:e})});lV.displayName=y5e;var cV="MenuPortal",[x5e,Fde]=vx(cV,{forceMount:void 0}),$de=t=>{const{__scopeMenu:e,forceMount:r,children:n,container:s}=t,i=bx(cV,e);return l.jsx(x5e,{scope:e,forceMount:r,children:l.jsx(Os,{present:r||i.open,children:l.jsx(Fw,{asChild:!0,container:s,children:n})})})};$de.displayName=cV;var xl="MenuContent",[v5e,uV]=vx(xl),Bde=j.forwardRef((t,e)=>{const r=Fde(xl,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,i=bx(xl,t.__scopeMenu),a=mE(xl,t.__scopeMenu);return l.jsx(uj.Provider,{scope:t.__scopeMenu,children:l.jsx(Os,{present:n||i.open,children:l.jsx(uj.Slot,{scope:t.__scopeMenu,children:a.modal?l.jsx(b5e,{...s,ref:e}):l.jsx(w5e,{...s,ref:e})})})})}),b5e=j.forwardRef((t,e)=>{const r=bx(xl,t.__scopeMenu),n=j.useRef(null),s=It(e,n);return j.useEffect(()=>{const i=n.current;if(i)return bR(i)},[]),l.jsx(dV,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Ke(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),w5e=j.forwardRef((t,e)=>{const r=bx(xl,t.__scopeMenu);return l.jsx(dV,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),S5e=Fp("MenuContent.ScrollLock"),dV=j.forwardRef((t,e)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=t,x=bx(xl,r),y=mE(xl,r),v=SR(r),b=Dde(r),w=f5e(r),[S,k]=j.useState(null),E=j.useRef(null),C=It(e,E,x.onContentChange),A=j.useRef(0),M=j.useRef(""),z=j.useRef(0),P=j.useRef(null),W=j.useRef("right"),N=j.useRef(0),U=m?fE:j.Fragment,K=m?{as:S5e,allowPinchZoom:!0}:void 0,G=H=>{var D,R;const B=M.current+H,L=w().filter(J=>!J.disabled),F=document.activeElement,V=(D=L.find(J=>J.ref.current===F))==null?void 0:D.textValue,Y=L.map(J=>J.textValue),ie=R5e(Y,B,V),Q=(R=L.find(J=>J.textValue===ie))==null?void 0:R.ref.current;(function J(Z){M.current=Z,window.clearTimeout(A.current),Z!==""&&(A.current=window.setTimeout(()=>J(""),1e3))})(B),Q&&setTimeout(()=>Q.focus())};j.useEffect(()=>()=>window.clearTimeout(A.current),[]),vR();const X=j.useCallback(H=>{var L,F;return W.current===((L=P.current)==null?void 0:L.side)&&D5e(H,(F=P.current)==null?void 0:F.area)},[]);return l.jsx(v5e,{scope:r,searchRef:M,onItemEnter:j.useCallback(H=>{X(H)&&H.preventDefault()},[X]),onItemLeave:j.useCallback(H=>{var B;X(H)||((B=E.current)==null||B.focus(),k(null))},[X]),onTriggerLeave:j.useCallback(H=>{X(H)&&H.preventDefault()},[X]),pointerGraceTimerRef:z,onPointerGraceIntentChange:j.useCallback(H=>{P.current=H},[]),children:l.jsx(U,{...K,children:l.jsx(dE,{asChild:!0,trapped:s,onMountAutoFocus:Ke(i,H=>{var B;H.preventDefault(),(B=E.current)==null||B.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:l.jsx(mx,{asChild:!0,disableOutsidePointerEvents:o,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:f,onDismiss:p,children:l.jsx(aV,{asChild:!0,...b,dir:y.dir,orientation:"vertical",loop:n,currentTabStopId:S,onCurrentTabStopIdChange:k,onEntryFocus:Ke(c,H=>{y.isUsingKeyboardRef.current||H.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(aR,{role:"menu","aria-orientation":"vertical","data-state":rhe(x.open),"data-radix-menu-content":"",dir:y.dir,...v,...g,ref:C,style:{outline:"none",...g.style},onKeyDown:Ke(g.onKeyDown,H=>{const L=H.target.closest("[data-radix-menu-content]")===H.currentTarget,F=H.ctrlKey||H.altKey||H.metaKey,V=H.key.length===1;L&&(H.key==="Tab"&&H.preventDefault(),!F&&V&&G(H.key));const Y=E.current;if(H.target!==Y||!u5e.includes(H.key))return;H.preventDefault();const Q=w().filter(D=>!D.disabled).map(D=>D.ref.current);Rde.includes(H.key)&&Q.reverse(),O5e(Q)}),onBlur:Ke(t.onBlur,H=>{H.currentTarget.contains(H.target)||(window.clearTimeout(A.current),M.current="")}),onPointerMove:Ke(t.onPointerMove,dj(H=>{const B=H.target,L=N.current!==H.clientX;if(H.currentTarget.contains(B)&&L){const F=H.clientX>N.current?"right":"left";W.current=F,N.current=H.clientX}}))})})})})})})});Bde.displayName=xl;var _5e="MenuGroup",hV=j.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return l.jsx(ot.div,{role:"group",...n,ref:e})});hV.displayName=_5e;var j5e="MenuLabel",zde=j.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return l.jsx(ot.div,{...n,ref:e})});zde.displayName=j5e;var J2="MenuItem",aY="menu.itemSelect",_R=j.forwardRef((t,e)=>{const{disabled:r=!1,onSelect:n,...s}=t,i=j.useRef(null),a=mE(J2,t.__scopeMenu),o=uV(J2,t.__scopeMenu),c=It(e,i),u=j.useRef(!1),d=()=>{const h=i.current;if(!r&&h){const f=new CustomEvent(aY,{bubbles:!0,cancelable:!0});h.addEventListener(aY,p=>n==null?void 0:n(p),{once:!0}),NH(h,f),f.defaultPrevented?u.current=!1:a.onClose()}};return l.jsx(Ude,{...s,ref:c,disabled:r,onClick:Ke(t.onClick,d),onPointerDown:h=>{var f;(f=t.onPointerDown)==null||f.call(t,h),u.current=!0},onPointerUp:Ke(t.onPointerUp,h=>{var f;u.current||(f=h.currentTarget)==null||f.click()}),onKeyDown:Ke(t.onKeyDown,h=>{const f=o.searchRef.current!=="";r||f&&h.key===" "||c6.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});_R.displayName=J2;var Ude=j.forwardRef((t,e)=>{const{__scopeMenu:r,disabled:n=!1,textValue:s,...i}=t,a=uV(J2,r),o=Dde(r),c=j.useRef(null),u=It(e,c),[d,h]=j.useState(!1),[f,p]=j.useState("");return j.useEffect(()=>{const m=c.current;m&&p((m.textContent??"").trim())},[i.children]),l.jsx(uj.ItemSlot,{scope:r,disabled:n,textValue:s??f,children:l.jsx(oV,{asChild:!0,...o,focusable:!n,children:l.jsx(ot.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:u,onPointerMove:Ke(t.onPointerMove,dj(m=>{n?a.onItemLeave(m):(a.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ke(t.onPointerLeave,dj(m=>a.onItemLeave(m))),onFocus:Ke(t.onFocus,()=>h(!0)),onBlur:Ke(t.onBlur,()=>h(!1))})})})}),k5e="MenuCheckboxItem",Hde=j.forwardRef((t,e)=>{const{checked:r=!1,onCheckedChange:n,...s}=t;return l.jsx(Kde,{scope:t.__scopeMenu,checked:r,children:l.jsx(_R,{role:"menuitemcheckbox","aria-checked":Q2(r)?"mixed":r,...s,ref:e,"data-state":pV(r),onSelect:Ke(s.onSelect,()=>n==null?void 0:n(Q2(r)?!0:!r),{checkForDefaultPrevented:!1})})})});Hde.displayName=k5e;var Vde="MenuRadioGroup",[N5e,E5e]=vx(Vde,{value:void 0,onValueChange:()=>{}}),Wde=j.forwardRef((t,e)=>{const{value:r,onValueChange:n,...s}=t,i=Hn(n);return l.jsx(N5e,{scope:t.__scopeMenu,value:r,onValueChange:i,children:l.jsx(hV,{...s,ref:e})})});Wde.displayName=Vde;var qde="MenuRadioItem",Gde=j.forwardRef((t,e)=>{const{value:r,...n}=t,s=E5e(qde,t.__scopeMenu),i=r===s.value;return l.jsx(Kde,{scope:t.__scopeMenu,checked:i,children:l.jsx(_R,{role:"menuitemradio","aria-checked":i,...n,ref:e,"data-state":pV(i),onSelect:Ke(n.onSelect,()=>{var a;return(a=s.onValueChange)==null?void 0:a.call(s,r)},{checkForDefaultPrevented:!1})})})});Gde.displayName=qde;var fV="MenuItemIndicator",[Kde,A5e]=vx(fV,{checked:!1}),Yde=j.forwardRef((t,e)=>{const{__scopeMenu:r,forceMount:n,...s}=t,i=A5e(fV,r);return l.jsx(Os,{present:n||Q2(i.checked)||i.checked===!0,children:l.jsx(ot.span,{...s,ref:e,"data-state":pV(i.checked)})})});Yde.displayName=fV;var C5e="MenuSeparator",Xde=j.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return l.jsx(ot.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});Xde.displayName=C5e;var T5e="MenuArrow",Jde=j.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=SR(r);return l.jsx(oR,{...s,...n,ref:e})});Jde.displayName=T5e;var P5e="MenuSub",[o5t,Qde]=vx(P5e),cS="MenuSubTrigger",Zde=j.forwardRef((t,e)=>{const r=bx(cS,t.__scopeMenu),n=mE(cS,t.__scopeMenu),s=Qde(cS,t.__scopeMenu),i=uV(cS,t.__scopeMenu),a=j.useRef(null),{pointerGraceTimerRef:o,onPointerGraceIntentChange:c}=i,u={__scopeMenu:t.__scopeMenu},d=j.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return j.useEffect(()=>d,[d]),j.useEffect(()=>{const h=o.current;return()=>{window.clearTimeout(h),c(null)}},[o,c]),l.jsx(lV,{asChild:!0,...u,children:l.jsx(Ude,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":rhe(r.open),...t,ref:JI(e,s.onTriggerChange),onClick:h=>{var f;(f=t.onClick)==null||f.call(t,h),!(t.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Ke(t.onPointerMove,dj(h=>{i.onItemEnter(h),!h.defaultPrevented&&!t.disabled&&!r.open&&!a.current&&(i.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),d()},100))})),onPointerLeave:Ke(t.onPointerLeave,dj(h=>{var p,m;d();const f=(p=r.content)==null?void 0:p.getBoundingClientRect();if(f){const g=(m=r.content)==null?void 0:m.dataset.side,x=g==="right",y=x?-5:5,v=f[x?"left":"right"],b=f[x?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x:v,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:v,y:f.bottom}],side:g}),window.clearTimeout(o.current),o.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ke(t.onKeyDown,h=>{var p;const f=i.searchRef.current!=="";t.disabled||f&&h.key===" "||d5e[n.dir].includes(h.key)&&(r.onOpenChange(!0),(p=r.content)==null||p.focus(),h.preventDefault())})})})});Zde.displayName=cS;var ehe="MenuSubContent",the=j.forwardRef((t,e)=>{const r=Fde(xl,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,i=bx(xl,t.__scopeMenu),a=mE(xl,t.__scopeMenu),o=Qde(ehe,t.__scopeMenu),c=j.useRef(null),u=It(e,c);return l.jsx(uj.Provider,{scope:t.__scopeMenu,children:l.jsx(Os,{present:n||i.open,children:l.jsx(uj.Slot,{scope:t.__scopeMenu,children:l.jsx(dV,{id:o.contentId,"aria-labelledby":o.triggerId,...s,ref:u,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var h;a.isUsingKeyboardRef.current&&((h=c.current)==null||h.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:Ke(t.onFocusOutside,d=>{d.target!==o.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ke(t.onEscapeKeyDown,d=>{a.onClose(),d.preventDefault()}),onKeyDown:Ke(t.onKeyDown,d=>{var p;const h=d.currentTarget.contains(d.target),f=h5e[a.dir].includes(d.key);h&&f&&(i.onOpenChange(!1),(p=o.trigger)==null||p.focus(),d.preventDefault())})})})})})});the.displayName=ehe;function rhe(t){return t?"open":"closed"}function Q2(t){return t==="indeterminate"}function pV(t){return Q2(t)?"indeterminate":t?"checked":"unchecked"}function O5e(t){const e=document.activeElement;for(const r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function I5e(t,e){return t.map((r,n)=>t[(e+n)%t.length])}function R5e(t,e,r){const s=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,i=r?t.indexOf(r):-1;let a=I5e(t,Math.max(i,0));s.length===1&&(a=a.filter(u=>u!==r));const c=a.find(u=>u.toLowerCase().startsWith(s.toLowerCase()));return c!==r?c:void 0}function M5e(t,e){const{x:r,y:n}=t;let s=!1;for(let i=0,a=e.length-1;i<e.length;a=i++){const o=e[i],c=e[a],u=o.x,d=o.y,h=c.x,f=c.y;d>n!=f>n&&r<(h-u)*(n-d)/(f-d)+u&&(s=!s)}return s}function D5e(t,e){if(!e)return!1;const r={x:t.clientX,y:t.clientY};return M5e(r,e)}function dj(t){return e=>e.pointerType==="mouse"?t(e):void 0}var L5e=Lde,F5e=lV,$5e=$de,B5e=Bde,z5e=hV,U5e=zde,H5e=_R,V5e=Hde,W5e=Wde,q5e=Gde,G5e=Yde,K5e=Xde,Y5e=Jde,X5e=Zde,J5e=the,jR="DropdownMenu",[Q5e,l5t]=gs(jR,[Mde]),ja=Mde(),[Z5e,nhe]=Q5e(jR),she=t=>{const{__scopeDropdownMenu:e,children:r,dir:n,open:s,defaultOpen:i,onOpenChange:a,modal:o=!0}=t,c=ja(e),u=j.useRef(null),[d,h]=_i({prop:s,defaultProp:i??!1,onChange:a,caller:jR});return l.jsx(Z5e,{scope:e,triggerId:Ka(),triggerRef:u,contentId:Ka(),open:d,onOpenChange:h,onOpenToggle:j.useCallback(()=>h(f=>!f),[h]),modal:o,children:l.jsx(L5e,{...c,open:d,onOpenChange:h,dir:n,modal:o,children:r})})};she.displayName=jR;var ihe="DropdownMenuTrigger",ahe=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...s}=t,i=nhe(ihe,r),a=ja(r);return l.jsx(F5e,{asChild:!0,...a,children:l.jsx(ot.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...s,ref:JI(e,i.triggerRef),onPointerDown:Ke(t.onPointerDown,o=>{!n&&o.button===0&&o.ctrlKey===!1&&(i.onOpenToggle(),i.open||o.preventDefault())}),onKeyDown:Ke(t.onKeyDown,o=>{n||(["Enter"," "].includes(o.key)&&i.onOpenToggle(),o.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(o.key)&&o.preventDefault())})})})});ahe.displayName=ihe;var e3e="DropdownMenuPortal",ohe=t=>{const{__scopeDropdownMenu:e,...r}=t,n=ja(e);return l.jsx($5e,{...n,...r})};ohe.displayName=e3e;var lhe="DropdownMenuContent",che=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=nhe(lhe,r),i=ja(r),a=j.useRef(!1);return l.jsx(B5e,{id:s.contentId,"aria-labelledby":s.triggerId,...i,...n,ref:e,onCloseAutoFocus:Ke(t.onCloseAutoFocus,o=>{var c;a.current||(c=s.triggerRef.current)==null||c.focus(),a.current=!1,o.preventDefault()}),onInteractOutside:Ke(t.onInteractOutside,o=>{const c=o.detail.originalEvent,u=c.button===0&&c.ctrlKey===!0,d=c.button===2||u;(!s.modal||d)&&(a.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});che.displayName=lhe;var t3e="DropdownMenuGroup",r3e=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(z5e,{...s,...n,ref:e})});r3e.displayName=t3e;var n3e="DropdownMenuLabel",uhe=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(U5e,{...s,...n,ref:e})});uhe.displayName=n3e;var s3e="DropdownMenuItem",dhe=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(H5e,{...s,...n,ref:e})});dhe.displayName=s3e;var i3e="DropdownMenuCheckboxItem",hhe=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(V5e,{...s,...n,ref:e})});hhe.displayName=i3e;var a3e="DropdownMenuRadioGroup",o3e=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(W5e,{...s,...n,ref:e})});o3e.displayName=a3e;var l3e="DropdownMenuRadioItem",fhe=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(q5e,{...s,...n,ref:e})});fhe.displayName=l3e;var c3e="DropdownMenuItemIndicator",phe=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(G5e,{...s,...n,ref:e})});phe.displayName=c3e;var u3e="DropdownMenuSeparator",mhe=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(K5e,{...s,...n,ref:e})});mhe.displayName=u3e;var d3e="DropdownMenuArrow",h3e=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(Y5e,{...s,...n,ref:e})});h3e.displayName=d3e;var f3e="DropdownMenuSubTrigger",ghe=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(X5e,{...s,...n,ref:e})});ghe.displayName=f3e;var p3e="DropdownMenuSubContent",yhe=j.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=ja(r);return l.jsx(J5e,{...s,...n,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});yhe.displayName=p3e;var m3e=she,g3e=ahe,y3e=ohe,xhe=che,vhe=uhe,bhe=dhe,whe=hhe,She=fhe,_he=phe,jhe=mhe,khe=ghe,Nhe=yhe;const Ehe=m3e,Ahe=g3e,x3e=j.forwardRef(({className:t,inset:e,children:r,...n},s)=>l.jsxs(khe,{ref:s,className:Le("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",e&&"pl-8",t),...n,children:[r,l.jsx(eR,{className:"ml-auto h-4 w-4"})]}));x3e.displayName=khe.displayName;const v3e=j.forwardRef(({className:t,...e},r)=>l.jsx(Nhe,{ref:r,className:Le("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...e}));v3e.displayName=Nhe.displayName;const mV=j.forwardRef(({className:t,sideOffset:e=4,...r},n)=>l.jsx(y3e,{children:l.jsx(xhe,{ref:n,sideOffset:e,className:Le("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));mV.displayName=xhe.displayName;const nb=j.forwardRef(({className:t,inset:e,...r},n)=>l.jsx(bhe,{ref:n,className:Le("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e&&"pl-8",t),...r}));nb.displayName=bhe.displayName;const b3e=j.forwardRef(({className:t,children:e,checked:r,...n},s)=>l.jsxs(whe,{ref:s,className:Le("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:r,...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(_he,{children:l.jsx(Es,{className:"h-4 w-4"})})}),e]}));b3e.displayName=whe.displayName;const w3e=j.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(She,{ref:n,className:Le("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(_he,{children:l.jsx(L2,{className:"h-2 w-2 fill-current"})})}),e]}));w3e.displayName=She.displayName;const S3e=j.forwardRef(({className:t,inset:e,...r},n)=>l.jsx(vhe,{ref:n,className:Le("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...r}));S3e.displayName=vhe.displayName;const gV=j.forwardRef(({className:t,...e},r)=>l.jsx(jhe,{ref:r,className:Le("-mx-1 my-1 h-px bg-muted",t),...e}));gV.displayName=jhe.displayName;var Che={exports:{}},The={};/**
* @license React
* use-sync-external-store-shim.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var q0=j;function _3e(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var j3e=typeof Object.is=="function"?Object.is:_3e,k3e=q0.useState,N3e=q0.useEffect,E3e=q0.useLayoutEffect,A3e=q0.useDebugValue;function C3e(t,e){var r=e(),n=k3e({inst:{value:r,getSnapshot:e}}),s=n[0].inst,i=n[1];return E3e(function(){s.value=r,s.getSnapshot=e,TL(s)&&i({inst:s})},[t,r,e]),N3e(function(){return TL(s)&&i({inst:s}),t(function(){TL(s)&&i({inst:s})})},[t]),A3e(r),r}function TL(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!j3e(t,r)}catch{return!0}}function T3e(t,e){return e()}var P3e=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?T3e:C3e;The.useSyncExternalStore=q0.useSyncExternalStore!==void 0?q0.useSyncExternalStore:P3e;Che.exports=The;var kR=Che.exports;function O3e(){return kR.useSyncExternalStore(I3e,()=>!0,()=>!1)}function I3e(){return()=>{}}var yV="Avatar",[R3e,c5t]=gs(yV),[M3e,Phe]=R3e(yV),Ohe=j.forwardRef((t,e)=>{const{__scopeAvatar:r,...n}=t,[s,i]=j.useState("idle");return l.jsx(M3e,{scope:r,imageLoadingStatus:s,onImageLoadingStatusChange:i,children:l.jsx(ot.span,{...n,ref:e})})});Ohe.displayName=yV;var Ihe="AvatarImage",Rhe=j.forwardRef((t,e)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:s=()=>{},...i}=t,a=Phe(Ihe,r),o=D3e(n,i),c=Hn(u=>{s(u),a.onImageLoadingStatusChange(u)});return Wn(()=>{o!=="idle"&&c(o)},[o,c]),o==="loaded"?l.jsx(ot.img,{...i,ref:e,src:n}):null});Rhe.displayName=Ihe;var Mhe="AvatarFallback",Dhe=j.forwardRef((t,e)=>{const{__scopeAvatar:r,delayMs:n,...s}=t,i=Phe(Mhe,r),[a,o]=j.useState(n===void 0);return j.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>o(!0),n);return()=>window.clearTimeout(c)}},[n]),a&&i.imageLoadingStatus!=="loaded"?l.jsx(ot.span,{...s,ref:e}):null});Dhe.displayName=Mhe;function oY(t,e){return t?e?(t.src!==e&&(t.src=e),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function D3e(t,{referrerPolicy:e,crossOrigin:r}){const n=O3e(),s=j.useRef(null),i=n?(s.current||(s.current=new window.Image),s.current):null,[a,o]=j.useState(()=>oY(i,t));return Wn(()=>{o(oY(i,t))},[i,t]),Wn(()=>{const c=h=>()=>{o(h)};if(!i)return;const u=c("loaded"),d=c("error");return i.addEventListener("load",u),i.addEventListener("error",d),e&&(i.referrerPolicy=e),typeof r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",u),i.removeEventListener("error",d)}},[i,r,e]),a}var Lhe=Ohe,Fhe=Rhe,$he=Dhe;const NR=j.forwardRef(({className:t,...e},r)=>l.jsx(Lhe,{ref:r,className:Le("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...e}));NR.displayName=Lhe.displayName;const ER=j.forwardRef(({className:t,...e},r)=>l.jsx(Fhe,{ref:r,className:Le("aspect-square h-full w-full",t),...e}));ER.displayName=Fhe.displayName;const AR=j.forwardRef(({className:t,...e},r)=>l.jsx($he,{ref:r,className:Le("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...e}));AR.displayName=$he.displayName;const Bhe=j.createContext(void 0),L3e=({children:t})=>{const[e,r]=j.useState(()=>localStorage.getItem("theme")||"light");j.useEffect(()=>{e==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"),localStorage.setItem("theme",e)},[e]);const n=()=>{r(s=>s==="light"?"dark":"light")};return l.jsx(Bhe.Provider,{value:{theme:e,toggleTheme:n},children:t})},xV=()=>{const t=j.useContext(Bhe);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t};function F3e(){const{toggleTheme:t}=xV();return l.jsxs("button",{onClick:t,className:"relative flex items-center justify-center text-gray-500 transition-colors bg-white border border-gray-200 rounded-full hover:text-gray-900 h-11 w-11 hover:bg-gray-100 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-white","aria-label":"Toggle theme",children:[l.jsx(Q2e,{className:"hidden h-5 w-5 dark:block"}),l.jsx(B2e,{className:"h-5 w-5 dark:hidden"})]})}var CR="Dialog",[zhe,Uhe]=gs(CR),[$3e,jc]=zhe(CR),Hhe=t=>{const{__scopeDialog:e,children:r,open:n,defaultOpen:s,onOpenChange:i,modal:a=!0}=t,o=j.useRef(null),c=j.useRef(null),[u,d]=_i({prop:n,defaultProp:s??!1,onChange:i,caller:CR});return l.jsx($3e,{scope:e,triggerRef:o,contentRef:c,contentId:Ka(),titleId:Ka(),descriptionId:Ka(),open:u,onOpenChange:d,onOpenToggle:j.useCallback(()=>d(h=>!h),[d]),modal:a,children:r})};Hhe.displayName=CR;var Vhe="DialogTrigger",Whe=j.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=jc(Vhe,r),i=It(e,s.triggerRef);return l.jsx(ot.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":wV(s.open),...n,ref:i,onClick:Ke(t.onClick,s.onOpenToggle)})});Whe.displayName=Vhe;var vV="DialogPortal",[B3e,qhe]=zhe(vV,{forceMount:void 0}),Ghe=t=>{const{__scopeDialog:e,forceMount:r,children:n,container:s}=t,i=jc(vV,e);return l.jsx(B3e,{scope:e,forceMount:r,children:j.Children.map(n,a=>l.jsx(Os,{present:r||i.open,children:l.jsx(Fw,{asChild:!0,container:s,children:a})}))})};Ghe.displayName=vV;var Z2="DialogOverlay",Khe=j.forwardRef((t,e)=>{const r=qhe(Z2,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,i=jc(Z2,t.__scopeDialog);return i.modal?l.jsx(Os,{present:n||i.open,children:l.jsx(U3e,{...s,ref:e})}):null});Khe.displayName=Z2;var z3e=Fp("DialogOverlay.RemoveScroll"),U3e=j.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=jc(Z2,r);return l.jsx(fE,{as:z3e,allowPinchZoom:!0,shards:[s.contentRef],children:l.jsx(ot.div,{"data-state":wV(s.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),Jy="DialogContent",Yhe=j.forwardRef((t,e)=>{const r=qhe(Jy,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,i=jc(Jy,t.__scopeDialog);return l.jsx(Os,{present:n||i.open,children:i.modal?l.jsx(H3e,{...s,ref:e}):l.jsx(V3e,{...s,ref:e})})});Yhe.displayName=Jy;var H3e=j.forwardRef((t,e)=>{const r=jc(Jy,t.__scopeDialog),n=j.useRef(null),s=It(e,r.contentRef,n);return j.useEffect(()=>{const i=n.current;if(i)return bR(i)},[]),l.jsx(Xhe,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ke(t.onCloseAutoFocus,i=>{var a;i.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Ke(t.onPointerDownOutside,i=>{const a=i.detail.originalEvent,o=a.button===0&&a.ctrlKey===!0;(a.button===2||o)&&i.preventDefault()}),onFocusOutside:Ke(t.onFocusOutside,i=>i.preventDefault())})}),V3e=j.forwardRef((t,e)=>{const r=jc(Jy,t.__scopeDialog),n=j.useRef(!1),s=j.useRef(!1);return l.jsx(Xhe,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,o;(a=t.onCloseAutoFocus)==null||a.call(t,i),i.defaultPrevented||(n.current||(o=r.triggerRef.current)==null||o.focus(),i.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:i=>{var c,u;(c=t.onInteractOutside)==null||c.call(t,i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const a=i.target;((u=r.triggerRef.current)==null?void 0:u.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),Xhe=j.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:i,...a}=t,o=jc(Jy,r),c=j.useRef(null),u=It(e,c);return vR(),l.jsxs(l.Fragment,{children:[l.jsx(dE,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:i,children:l.jsx(mx,{role:"dialog",id:o.contentId,"aria-describedby":o.descriptionId,"aria-labelledby":o.titleId,"data-state":wV(o.open),...a,ref:u,onDismiss:()=>o.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(q3e,{titleId:o.titleId}),l.jsx(K3e,{contentRef:c,descriptionId:o.descriptionId})]})]})}),bV="DialogTitle",Jhe=j.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=jc(bV,r);return l.jsx(ot.h2,{id:s.titleId,...n,ref:e})});Jhe.displayName=bV;var Qhe="DialogDescription",Zhe=j.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=jc(Qhe,r);return l.jsx(ot.p,{id:s.descriptionId,...n,ref:e})});Zhe.displayName=Qhe;var efe="DialogClose",tfe=j.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=jc(efe,r);return l.jsx(ot.button,{type:"button",...n,ref:e,onClick:Ke(t.onClick,()=>s.onOpenChange(!1))})});tfe.displayName=efe;function wV(t){return t?"open":"closed"}var rfe="DialogTitleWarning",[W3e,nfe]=oTe(rfe,{contentName:Jy,titleName:bV,docsSlug:"dialog"}),q3e=({titleId:t})=>{const e=nfe(rfe),r=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return j.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},G3e="DialogDescriptionWarning",K3e=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${nfe(G3e).contentName}}.`;return j.useEffect(()=>{var i;const s=(i=t.current)==null?void 0:i.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},SV=Hhe,_V=Whe,jV=Ghe,gE=Khe,yE=Yhe,xE=Jhe,vE=Zhe,TR=tfe;const Gr=SV,bc=_V,Y3e=jV,sfe=j.forwardRef(({className:t,...e},r)=>l.jsx(gE,{ref:r,className:Le("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));sfe.displayName=gE.displayName;const zr=j.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(Y3e,{children:[l.jsx(sfe,{}),l.jsxs(yE,{ref:n,className:Le("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...r,children:[e,l.jsxs(TR,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[l.jsx(Is,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zr.displayName=yE.displayName;const Ur=({className:t,...e})=>l.jsx("div",{className:Le("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});Ur.displayName="DialogHeader";const Th=({className:t,...e})=>l.jsx("div",{className:Le("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});Th.displayName="DialogFooter";const Hr=j.forwardRef(({className:t,...e},r)=>l.jsx(xE,{ref:r,className:Le("text-lg font-semibold leading-none tracking-tight",t),...e}));Hr.displayName=xE.displayName;const wx=j.forwardRef(({className:t,...e},r)=>l.jsx(vE,{ref:r,className:Le("text-sm text-muted-foreground",t),...e}));wx.displayName=vE.displayName;const ir=j.forwardRef(({className:t,...e},r)=>l.jsx("textarea",{className:Le("flex min-h-[120px] w-full rounded-lg border border-input bg-background","px-4 py-3 text-sm text-foreground","shadow-theme-xs","placeholder:text-muted-foreground","focus:border-brand-300 focus:outline-none focus:ring-3 focus:ring-brand-500/10","disabled:cursor-not-allowed disabled:opacity-50","dark:border-gray-800 dark:bg-gray-900 dark:text-white",t),ref:r,...e}));ir.displayName="Textarea";function u6(t,[e,r]){return Math.min(r,Math.max(e,t))}function X3e(t,e){return j.useReducer((r,n)=>e[r][n]??r,t)}var kV="ScrollArea",[ife,u5t]=gs(kV),[J3e,Tl]=ife(kV),afe=j.forwardRef((t,e)=>{const{__scopeScrollArea:r,type:n="hover",dir:s,scrollHideDelay:i=600,...a}=t,[o,c]=j.useState(null),[u,d]=j.useState(null),[h,f]=j.useState(null),[p,m]=j.useState(null),[g,x]=j.useState(null),[y,v]=j.useState(0),[b,w]=j.useState(0),[S,k]=j.useState(!1),[E,C]=j.useState(!1),A=It(e,z=>c(z)),M=xx(s);return l.jsx(J3e,{scope:r,type:n,dir:M,scrollHideDelay:i,scrollArea:o,viewport:u,onViewportChange:d,content:h,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:k,scrollbarY:g,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:C,onCornerWidthChange:v,onCornerHeightChange:w,children:l.jsx(ot.div,{dir:M,...a,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":b+"px",...t.style}})})});afe.displayName=kV;var ofe="ScrollAreaViewport",lfe=j.forwardRef((t,e)=>{const{__scopeScrollArea:r,children:n,nonce:s,...i}=t,a=Tl(ofe,r),o=j.useRef(null),c=It(e,o,a.onViewportChange);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),l.jsx(ot.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...t.style},children:l.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});lfe.displayName=ofe;var Du="ScrollAreaScrollbar",NV=j.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=Tl(Du,t.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=s,o=t.orientation==="horizontal";return j.useEffect(()=>(o?i(!0):a(!0),()=>{o?i(!1):a(!1)}),[o,i,a]),s.type==="hover"?l.jsx(Q3e,{...n,ref:e,forceMount:r}):s.type==="scroll"?l.jsx(Z3e,{...n,ref:e,forceMount:r}):s.type==="auto"?l.jsx(cfe,{...n,ref:e,forceMount:r}):s.type==="always"?l.jsx(EV,{...n,ref:e}):null});NV.displayName=Du;var Q3e=j.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=Tl(Du,t.__scopeScrollArea),[i,a]=j.useState(!1);return j.useEffect(()=>{const o=s.scrollArea;let c=0;if(o){const u=()=>{window.clearTimeout(c),a(!0)},d=()=>{c=window.setTimeout(()=>a(!1),s.scrollHideDelay)};return o.addEventListener("pointerenter",u),o.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),o.removeEventListener("pointerenter",u),o.removeEventListener("pointerleave",d)}}},[s.scrollArea,s.scrollHideDelay]),l.jsx(Os,{present:r||i,children:l.jsx(cfe,{"data-state":i?"visible":"hidden",...n,ref:e})})}),Z3e=j.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=Tl(Du,t.__scopeScrollArea),i=t.orientation==="horizontal",a=OR(()=>c("SCROLL_END"),100),[o,c]=X3e("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return j.useEffect(()=>{if(o==="idle"){const u=window.setTimeout(()=>c("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[o,s.scrollHideDelay,c]),j.useEffect(()=>{const u=s.viewport,d=i?"scrollLeft":"scrollTop";if(u){let h=u[d];const f=()=>{const p=u[d];h!==p&&(c("SCROLL"),a()),h=p};return u.addEventListener("scroll",f),()=>u.removeEventListener("scroll",f)}},[s.viewport,i,c,a]),l.jsx(Os,{present:r||o!=="hidden",children:l.jsx(EV,{"data-state":o==="hidden"?"hidden":"visible",...n,ref:e,onPointerEnter:Ke(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Ke(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),cfe=j.forwardRef((t,e)=>{const r=Tl(Du,t.__scopeScrollArea),{forceMount:n,...s}=t,[i,a]=j.useState(!1),o=t.orientation==="horizontal",c=OR(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,d=r.viewport.offsetHeight<r.viewport.scrollHeight;a(o?u:d)}},10);return G0(r.viewport,c),G0(r.content,c),l.jsx(Os,{present:n||i,children:l.jsx(EV,{"data-state":i?"visible":"hidden",...s,ref:e})})}),EV=j.forwardRef((t,e)=>{const{orientation:r="vertical",...n}=t,s=Tl(Du,t.__scopeScrollArea),i=j.useRef(null),a=j.useRef(0),[o,c]=j.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=pfe(o.viewport,o.content),d={...n,sizes:o,onSizesChange:c,hasThumb:u>0&&u<1,onThumbChange:f=>i.current=f,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:f=>a.current=f};function h(f,p){return iFe(f,a.current,o,p)}return r==="horizontal"?l.jsx(eFe,{...d,ref:e,onThumbPositionChange:()=>{if(s.viewport&&i.current){const f=s.viewport.scrollLeft,p=lY(f,o,s.dir);i.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=h(f,s.dir))}}):r==="vertical"?l.jsx(tFe,{...d,ref:e,onThumbPositionChange:()=>{if(s.viewport&&i.current){const f=s.viewport.scrollTop,p=lY(f,o);i.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=h(f))}}):null}),eFe=j.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,i=Tl(Du,t.__scopeScrollArea),[a,o]=j.useState(),c=j.useRef(null),u=It(e,c,i.onScrollbarXChange);return j.useEffect(()=>{c.current&&o(getComputedStyle(c.current))},[c]),l.jsx(dfe,{"data-orientation":"horizontal",...s,ref:u,sizes:r,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":PR(r)+"px",...t.style},onThumbPointerDown:d=>t.onThumbPointerDown(d.x),onDragScroll:d=>t.onDragScroll(d.x),onWheelScroll:(d,h)=>{if(i.viewport){const f=i.viewport.scrollLeft+d.deltaX;t.onWheelScroll(f),gfe(f,h)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&n({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:tP(a.paddingLeft),paddingEnd:tP(a.paddingRight)}})}})}),tFe=j.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,i=Tl(Du,t.__scopeScrollArea),[a,o]=j.useState(),c=j.useRef(null),u=It(e,c,i.onScrollbarYChange);return j.useEffect(()=>{c.current&&o(getComputedStyle(c.current))},[c]),l.jsx(dfe,{"data-orientation":"vertical",...s,ref:u,sizes:r,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":PR(r)+"px",...t.style},onThumbPointerDown:d=>t.onThumbPointerDown(d.y),onDragScroll:d=>t.onDragScroll(d.y),onWheelScroll:(d,h)=>{if(i.viewport){const f=i.viewport.scrollTop+d.deltaY;t.onWheelScroll(f),gfe(f,h)&&d.preventDefault()}},onResize:()=>{c.current&&i.viewport&&a&&n({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:tP(a.paddingTop),paddingEnd:tP(a.paddingBottom)}})}})}),[rFe,ufe]=ife(Du),dfe=j.forwardRef((t,e)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:s,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:o,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:h,...f}=t,p=Tl(Du,r),[m,g]=j.useState(null),x=It(e,A=>g(A)),y=j.useRef(null),v=j.useRef(""),b=p.viewport,w=n.content-n.viewport,S=Hn(d),k=Hn(c),E=OR(h,10);function C(A){if(y.current){const M=A.clientX-y.current.left,z=A.clientY-y.current.top;u({x:M,y:z})}}return j.useEffect(()=>{const A=M=>{const z=M.target;(m==null?void 0:m.contains(z))&&S(M,w)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[b,m,w,S]),j.useEffect(k,[n,k]),G0(m,E),G0(p.content,E),l.jsx(rFe,{scope:r,scrollbar:m,hasThumb:s,onThumbChange:Hn(i),onThumbPointerUp:Hn(a),onThumbPositionChange:k,onThumbPointerDown:Hn(o),children:l.jsx(ot.div,{...f,ref:x,style:{position:"absolute",...f.style},onPointerDown:Ke(t.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),y.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),C(A))}),onPointerMove:Ke(t.onPointerMove,C),onPointerUp:Ke(t.onPointerUp,A=>{const M=A.target;M.hasPointerCapture(A.pointerId)&&M.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),eP="ScrollAreaThumb",hfe=j.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=ufe(eP,t.__scopeScrollArea);return l.jsx(Os,{present:r||s.hasThumb,children:l.jsx(nFe,{ref:e,...n})})}),nFe=j.forwardRef((t,e)=>{const{__scopeScrollArea:r,style:n,...s}=t,i=Tl(eP,r),a=ufe(eP,r),{onThumbPositionChange:o}=a,c=It(e,h=>a.onThumbChange(h)),u=j.useRef(void 0),d=OR(()=>{u.current&&(u.current(),u.current=void 0)},100);return j.useEffect(()=>{const h=i.viewport;if(h){const f=()=>{if(d(),!u.current){const p=aFe(h,o);u.current=p,o()}};return o(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[i.viewport,d,o]),l.jsx(ot.div,{"data-state":a.hasThumb?"visible":"hidden",...s,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Ke(t.onPointerDownCapture,h=>{const p=h.target.getBoundingClientRect(),m=h.clientX-p.left,g=h.clientY-p.top;a.onThumbPointerDown({x:m,y:g})}),onPointerUp:Ke(t.onPointerUp,a.onThumbPointerUp)})});hfe.displayName=eP;var AV="ScrollAreaCorner",ffe=j.forwardRef((t,e)=>{const r=Tl(AV,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?l.jsx(sFe,{...t,ref:e}):null});ffe.displayName=AV;var sFe=j.forwardRef((t,e)=>{const{__scopeScrollArea:r,...n}=t,s=Tl(AV,r),[i,a]=j.useState(0),[o,c]=j.useState(0),u=!!(i&&o);return G0(s.scrollbarX,()=>{var h;const d=((h=s.scrollbarX)==null?void 0:h.offsetHeight)||0;s.onCornerHeightChange(d),c(d)}),G0(s.scrollbarY,()=>{var h;const d=((h=s.scrollbarY)==null?void 0:h.offsetWidth)||0;s.onCornerWidthChange(d),a(d)}),u?l.jsx(ot.div,{...n,ref:e,style:{width:i,height:o,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function tP(t){return t?parseInt(t,10):0}function pfe(t,e){const r=t/e;return isNaN(r)?0:r}function PR(t){const e=pfe(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*e;return Math.max(n,18)}function iFe(t,e,r,n="ltr"){const s=PR(r),i=s/2,a=e||i,o=s-a,c=r.scrollbar.paddingStart+a,u=r.scrollbar.size-r.scrollbar.paddingEnd-o,d=r.content-r.viewport,h=n==="ltr"?[0,d]:[d*-1,0];return mfe([c,u],h)(t)}function lY(t,e,r="ltr"){const n=PR(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,i=e.scrollbar.size-s,a=e.content-e.viewport,o=i-n,c=r==="ltr"?[0,a]:[a*-1,0],u=u6(t,c);return mfe([0,a],[0,o])(u)}function mfe(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function gfe(t,e){return t>0&&t<e}var aFe=(t,e=()=>{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return function s(){const i={left:t.scrollLeft,top:t.scrollTop},a=r.left!==i.left,o=r.top!==i.top;(a||o)&&e(),r=i,n=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(n)};function OR(t,e){const r=Hn(t),n=j.useRef(0);return j.useEffect(()=>()=>window.clearTimeout(n.current),[]),j.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,e)},[r,e])}function G0(t,e){const r=Hn(e);Wn(()=>{let n=0;if(t){const s=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return s.observe(t),()=>{window.cancelAnimationFrame(n),s.unobserve(t)}}},[t,r])}var yfe=afe,oFe=lfe,lFe=ffe;const Yw=j.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(yfe,{ref:n,className:Le("relative overflow-hidden",t),...r,children:[l.jsx(oFe,{className:"h-full w-full rounded-[inherit]",children:e}),l.jsx(xfe,{}),l.jsx(lFe,{})]}));Yw.displayName=yfe.displayName;const xfe=j.forwardRef(({className:t,orientation:e="vertical",...r},n)=>l.jsx(NV,{ref:n,orientation:e,className:Le("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:l.jsx(hfe,{className:"relative flex-1 rounded-full bg-border"})}));xfe.displayName=NV.displayName;var cFe="Separator",cY="horizontal",uFe=["horizontal","vertical"],vfe=j.forwardRef((t,e)=>{const{decorative:r,orientation:n=cY,...s}=t,i=dFe(n)?n:cY,o=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return l.jsx(ot.div,{"data-orientation":i,...o,...s,ref:e})});vfe.displayName=cFe;function dFe(t){return uFe.includes(t)}var bfe=vfe;const vi=j.forwardRef(({className:t,orientation:e="horizontal",decorative:r=!0,...n},s)=>l.jsx(bfe,{ref:s,decorative:r,orientation:e,className:Le("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));vi.displayName=bfe.displayName;function Sr({className:t,...e}){return l.jsx("div",{className:Le("animate-pulse rounded-md bg-muted",t),...e})}const hFe="https://nqibmbtqcjucktqcreob.supabase.co",fFe="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5xaWJtYnRxY2p1Y2t0cWNyZW9iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1NTk5MTAsImV4cCI6MjA3MDEzNTkxMH0.UnFk-GqYCZtlkXNlxyHUTaFAnS6Q4hIgDgWKANrxEHg",be=xde(hFe,fFe,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}});function Nr(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function mh(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function pFe(t,e){const r=Nr(t);return isNaN(e)?mh(t,NaN):(r.setDate(r.getDate()+e),r)}const wfe=6048e5,mFe=864e5,FA=43200,uY=1440;let gFe={};function bE(){return gFe}function hj(t,e){var o,c,u,d;const r=bE(),n=(e==null?void 0:e.weekStartsOn)??((c=(o=e==null?void 0:e.locale)==null?void 0:o.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((d=(u=r.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=Nr(t),i=s.getDay(),a=(i<n?7:0)+i-n;return s.setDate(s.getDate()-a),s.setHours(0,0,0,0),s}function rP(t){return hj(t,{weekStartsOn:1})}function Sfe(t){const e=Nr(t),r=e.getFullYear(),n=mh(t,0);n.setFullYear(r+1,0,4),n.setHours(0,0,0,0);const s=rP(n),i=mh(t,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const a=rP(i);return e.getTime()>=s.getTime()?r+1:e.getTime()>=a.getTime()?r:r-1}function nP(t){const e=Nr(t);return e.setHours(0,0,0,0),e}function sP(t){const e=Nr(t),r=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return r.setUTCFullYear(e.getFullYear()),+t-+r}function _fe(t,e){const r=nP(t),n=nP(e),s=+r-sP(r),i=+n-sP(n);return Math.round((s-i)/mFe)}function yFe(t){const e=Sfe(t),r=mh(t,0);return r.setFullYear(e,0,4),r.setHours(0,0,0,0),rP(r)}function fT(t,e){const r=Nr(t),n=Nr(e),s=r.getTime()-n.getTime();return s<0?-1:s>0?1:s}function CV(t){return mh(t,Date.now())}function jfe(t,e){const r=nP(t),n=nP(e);return+r==+n}function xFe(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function vFe(t){if(!xFe(t)&&typeof t!="number")return!1;const e=Nr(t);return!isNaN(Number(e))}function bFe(t,e){const r=Nr(t),n=Nr(e),s=r.getFullYear()-n.getFullYear(),i=r.getMonth()-n.getMonth();return s*12+i}function PL(t,e){const r=Nr(t),n=Nr(e),s=dY(r,n),i=Math.abs(_fe(r,n));r.setDate(r.getDate()-s*i);const a=+(dY(r,n)===-s),o=s*(i-a);return o===0?0:o}function dY(t,e){const r=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return r<0?-1:r>0?1:r}function wFe(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return n===0?0:n}}function SFe(t,e){return+Nr(t)-+Nr(e)}function _Fe(t){const e=Nr(t);return e.setHours(23,59,59,999),e}function jFe(t){const e=Nr(t),r=e.getMonth();return e.setFullYear(e.getFullYear(),r+1,0),e.setHours(23,59,59,999),e}function kFe(t){const e=Nr(t);return+_Fe(e)==+jFe(e)}function NFe(t,e){const r=Nr(t),n=Nr(e),s=fT(r,n),i=Math.abs(bFe(r,n));let a;if(i<1)a=0;else{r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-s*i);let o=fT(r,n)===-s;kFe(Nr(t))&&i===1&&fT(t,n)===1&&(o=!1),a=s*(i-Number(o))}return a===0?0:a}function EFe(t,e,r){const n=SFe(t,e)/1e3;return wFe(r==null?void 0:r.roundingMethod)(n)}function AFe(t){const e=Nr(t),r=mh(t,0);return r.setFullYear(e.getFullYear(),0,1),r.setHours(0,0,0,0),r}const CFe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},TFe=(t,e,r)=>{let n;const s=CFe[t];return typeof s=="string"?n=s:e===1?n=s.one:n=s.other.replace("{{count}}",e.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function OL(t){return(e={})=>{const r=e.width?String(e.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const PFe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},OFe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},IFe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},RFe={date:OL({formats:PFe,defaultWidth:"full"}),time:OL({formats:OFe,defaultWidth:"full"}),dateTime:OL({formats:IFe,defaultWidth:"full"})},MFe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},DFe=(t,e,r,n)=>MFe[t];function T1(t){return(e,r)=>{const n=r!=null&&r.context?String(r.context):"standalone";let s;if(n==="formatting"&&t.formattingValues){const a=t.defaultFormattingWidth||t.defaultWidth,o=r!=null&&r.width?String(r.width):a;s=t.formattingValues[o]||t.formattingValues[a]}else{const a=t.defaultWidth,o=r!=null&&r.width?String(r.width):t.defaultWidth;s=t.values[o]||t.values[a]}const i=t.argumentCallback?t.argumentCallback(e):e;return s[i]}}const LFe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},FFe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},$Fe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},BFe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},zFe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},UFe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},HFe=(t,e)=>{const r=Number(t),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},VFe={ordinalNumber:HFe,era:T1({values:LFe,defaultWidth:"wide"}),quarter:T1({values:FFe,defaultWidth:"wide",argumentCallback:t=>t-1}),month:T1({values:$Fe,defaultWidth:"wide"}),day:T1({values:BFe,defaultWidth:"wide"}),dayPeriod:T1({values:zFe,defaultWidth:"wide",formattingValues:UFe,defaultFormattingWidth:"wide"})};function P1(t){return(e,r={})=>{const n=r.width,s=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],i=e.match(s);if(!i)return null;const a=i[0],o=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(o)?qFe(o,h=>h.test(a)):WFe(o,h=>h.test(a));let u;u=t.valueCallback?t.valueCallback(c):c,u=r.valueCallback?r.valueCallback(u):u;const d=e.slice(a.length);return{value:u,rest:d}}}function WFe(t,e){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&e(t[r]))return r}function qFe(t,e){for(let r=0;r<t.length;r++)if(e(t[r]))return r}function GFe(t){return(e,r={})=>{const n=e.match(t.matchPattern);if(!n)return null;const s=n[0],i=e.match(t.parsePattern);if(!i)return null;let a=t.valueCallback?t.valueCallback(i[0]):i[0];a=r.valueCallback?r.valueCallback(a):a;const o=e.slice(s.length);return{value:a,rest:o}}}const KFe=/^(\d+)(th|st|nd|rd)?/i,YFe=/\d+/i,XFe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},JFe={any:[/^b/i,/^(a|c)/i]},QFe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ZFe={any:[/1/i,/2/i,/3/i,/4/i]},e$e={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},t$e={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},r$e={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},n$e={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},s$e={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},i$e={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},a$e={ordinalNumber:GFe({matchPattern:KFe,parsePattern:YFe,valueCallback:t=>parseInt(t,10)}),era:P1({matchPatterns:XFe,defaultMatchWidth:"wide",parsePatterns:JFe,defaultParseWidth:"any"}),quarter:P1({matchPatterns:QFe,defaultMatchWidth:"wide",parsePatterns:ZFe,defaultParseWidth:"any",valueCallback:t=>t+1}),month:P1({matchPatterns:e$e,defaultMatchWidth:"wide",parsePatterns:t$e,defaultParseWidth:"any"}),day:P1({matchPatterns:r$e,defaultMatchWidth:"wide",parsePatterns:n$e,defaultParseWidth:"any"}),dayPeriod:P1({matchPatterns:s$e,defaultMatchWidth:"any",parsePatterns:i$e,defaultParseWidth:"any"})},TV={code:"en-US",formatDistance:TFe,formatLong:RFe,formatRelative:DFe,localize:VFe,match:a$e,options:{weekStartsOn:0,firstWeekContainsDate:1}};function o$e(t){const e=Nr(t);return _fe(e,AFe(e))+1}function l$e(t){const e=Nr(t),r=+rP(e)-+yFe(e);return Math.round(r/wfe)+1}function kfe(t,e){var d,h,f,p;const r=Nr(t),n=r.getFullYear(),s=bE(),i=(e==null?void 0:e.firstWeekContainsDate)??((h=(d=e==null?void 0:e.locale)==null?void 0:d.options)==null?void 0:h.firstWeekContainsDate)??s.firstWeekContainsDate??((p=(f=s.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,a=mh(t,0);a.setFullYear(n+1,0,i),a.setHours(0,0,0,0);const o=hj(a,e),c=mh(t,0);c.setFullYear(n,0,i),c.setHours(0,0,0,0);const u=hj(c,e);return r.getTime()>=o.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function c$e(t,e){var o,c,u,d;const r=bE(),n=(e==null?void 0:e.firstWeekContainsDate)??((c=(o=e==null?void 0:e.locale)==null?void 0:o.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((d=(u=r.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,s=kfe(t,e),i=mh(t,0);return i.setFullYear(s,0,n),i.setHours(0,0,0,0),hj(i,e)}function u$e(t,e){const r=Nr(t),n=+hj(r,e)-+c$e(r,e);return Math.round(n/wfe)+1}function Tr(t,e){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(e,"0");return r+n}const Uh={y(t,e){const r=t.getFullYear(),n=r>0?r:1-r;return Tr(e==="yy"?n%100:n,e.length)},M(t,e){const r=t.getMonth();return e==="M"?String(r+1):Tr(r+1,2)},d(t,e){return Tr(t.getDate(),e.length)},a(t,e){const r=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(t,e){return Tr(t.getHours()%12||12,e.length)},H(t,e){return Tr(t.getHours(),e.length)},m(t,e){return Tr(t.getMinutes(),e.length)},s(t,e){return Tr(t.getSeconds(),e.length)},S(t,e){const r=e.length,n=t.getMilliseconds(),s=Math.trunc(n*Math.pow(10,r-3));return Tr(s,e.length)}},Hx={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},hY={G:function(t,e,r){const n=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(t,e,r){if(e==="yo"){const n=t.getFullYear(),s=n>0?n:1-n;return r.ordinalNumber(s,{unit:"year"})}return Uh.y(t,e)},Y:function(t,e,r,n){const s=kfe(t,n),i=s>0?s:1-s;if(e==="YY"){const a=i%100;return Tr(a,2)}return e==="Yo"?r.ordinalNumber(i,{unit:"year"}):Tr(i,e.length)},R:function(t,e){const r=Sfe(t);return Tr(r,e.length)},u:function(t,e){const r=t.getFullYear();return Tr(r,e.length)},Q:function(t,e,r){const n=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(n);case"QQ":return Tr(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(t,e,r){const n=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(n);case"qq":return Tr(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(t,e,r){const n=t.getMonth();switch(e){case"M":case"MM":return Uh.M(t,e);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(t,e,r){const n=t.getMonth();switch(e){case"L":return String(n+1);case"LL":return Tr(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(t,e,r,n){const s=u$e(t,n);return e==="wo"?r.ordinalNumber(s,{unit:"week"}):Tr(s,e.length)},I:function(t,e,r){const n=l$e(t);return e==="Io"?r.ordinalNumber(n,{unit:"week"}):Tr(n,e.length)},d:function(t,e,r){return e==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Uh.d(t,e)},D:function(t,e,r){const n=o$e(t);return e==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Tr(n,e.length)},E:function(t,e,r){const n=t.getDay();switch(e){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(t,e,r,n){const s=t.getDay(),i=(s-n.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return Tr(i,2);case"eo":return r.ordinalNumber(i,{unit:"day"});case"eee":return r.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(s,{width:"short",context:"formatting"});case"eeee":default:return r.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,r,n){const s=t.getDay(),i=(s-n.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return Tr(i,e.length);case"co":return r.ordinalNumber(i,{unit:"day"});case"ccc":return r.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(s,{width:"narrow",context:"standalone"});case"cccccc":return r.day(s,{width:"short",context:"standalone"});case"cccc":default:return r.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,r){const n=t.getDay(),s=n===0?7:n;switch(e){case"i":return String(s);case"ii":return Tr(s,e.length);case"io":return r.ordinalNumber(s,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(t,e,r){const s=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(t,e,r){const n=t.getHours();let s;switch(n===12?s=Hx.noon:n===0?s=Hx.midnight:s=n/12>=1?"pm":"am",e){case"b":case"bb":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,r){const n=t.getHours();let s;switch(n>=17?s=Hx.evening:n>=12?s=Hx.afternoon:n>=4?s=Hx.morning:s=Hx.night,e){case"B":case"BB":case"BBB":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,r){if(e==="ho"){let n=t.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return Uh.h(t,e)},H:function(t,e,r){return e==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Uh.H(t,e)},K:function(t,e,r){const n=t.getHours()%12;return e==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Tr(n,e.length)},k:function(t,e,r){let n=t.getHours();return n===0&&(n=24),e==="ko"?r.ordinalNumber(n,{unit:"hour"}):Tr(n,e.length)},m:function(t,e,r){return e==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Uh.m(t,e)},s:function(t,e,r){return e==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Uh.s(t,e)},S:function(t,e){return Uh.S(t,e)},X:function(t,e,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return pY(n);case"XXXX":case"XX":return Mm(n);case"XXXXX":case"XXX":default:return Mm(n,":")}},x:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"x":return pY(n);case"xxxx":case"xx":return Mm(n);case"xxxxx":case"xxx":default:return Mm(n,":")}},O:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+fY(n,":");case"OOOO":default:return"GMT"+Mm(n,":")}},z:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+fY(n,":");case"zzzz":default:return"GMT"+Mm(n,":")}},t:function(t,e,r){const n=Math.trunc(t.getTime()/1e3);return Tr(n,e.length)},T:function(t,e,r){const n=t.getTime();return Tr(n,e.length)}};function fY(t,e=""){const r=t>0?"-":"+",n=Math.abs(t),s=Math.trunc(n/60),i=n%60;return i===0?r+String(s):r+String(s)+e+Tr(i,2)}function pY(t,e){return t%60===0?(t>0?"-":"+")+Tr(Math.abs(t)/60,2):Mm(t,e)}function Mm(t,e=""){const r=t>0?"-":"+",n=Math.abs(t),s=Tr(Math.trunc(n/60),2),i=Tr(n%60,2);return r+s+e+i}const mY=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},Nfe=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},d$e=(t,e)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],s=r[2];if(!s)return mY(t,e);let i;switch(n){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",mY(n,e)).replace("{{time}}",Nfe(s,e))},h$e={p:Nfe,P:d$e},f$e=/^D+$/,p$e=/^Y+$/,m$e=["D","DD","YY","YYYY"];function g$e(t){return f$e.test(t)}function y$e(t){return p$e.test(t)}function x$e(t,e,r){const n=v$e(t,e,r);if(console.warn(n),m$e.includes(t))throw new RangeError(n)}function v$e(t,e,r){const n=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const b$e=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,w$e=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,S$e=/^'([^]*?)'?$/,_$e=/''/g,j$e=/[a-zA-Z]/;function fj(t,e,r){var d,h,f,p,m,g,x,y;const n=bE(),s=(r==null?void 0:r.locale)??n.locale??TV,i=(r==null?void 0:r.firstWeekContainsDate)??((h=(d=r==null?void 0:r.locale)==null?void 0:d.options)==null?void 0:h.firstWeekContainsDate)??n.firstWeekContainsDate??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,a=(r==null?void 0:r.weekStartsOn)??((g=(m=r==null?void 0:r.locale)==null?void 0:m.options)==null?void 0:g.weekStartsOn)??n.weekStartsOn??((y=(x=n.locale)==null?void 0:x.options)==null?void 0:y.weekStartsOn)??0,o=Nr(t);if(!vFe(o))throw new RangeError("Invalid time value");let c=e.match(w$e).map(v=>{const b=v[0];if(b==="p"||b==="P"){const w=h$e[b];return w(v,s.formatLong)}return v}).join("").match(b$e).map(v=>{if(v==="''")return{isToken:!1,value:"'"};const b=v[0];if(b==="'")return{isToken:!1,value:k$e(v)};if(hY[b])return{isToken:!0,value:v};if(b.match(j$e))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:v}});s.localize.preprocessor&&(c=s.localize.preprocessor(o,c));const u={firstWeekContainsDate:i,weekStartsOn:a,locale:s};return c.map(v=>{if(!v.isToken)return v.value;const b=v.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&y$e(b)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&g$e(b))&&x$e(b,e,String(t));const w=hY[b[0]];return w(o,b,s.localize,u)}).join("")}function k$e(t){const e=t.match(S$e);return e?e[1].replace(_$e,"'"):t}function N$e(t,e,r){const n=bE(),s=(r==null?void 0:r.locale)??n.locale??TV,i=2520,a=fT(t,e);if(isNaN(a))throw new RangeError("Invalid time value");const o=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:a});let c,u;a>0?(c=Nr(e),u=Nr(t)):(c=Nr(t),u=Nr(e));const d=EFe(u,c),h=(sP(u)-sP(c))/1e3,f=Math.round((d-h)/60);let p;if(f<2)return r!=null&&r.includeSeconds?d<5?s.formatDistance("lessThanXSeconds",5,o):d<10?s.formatDistance("lessThanXSeconds",10,o):d<20?s.formatDistance("lessThanXSeconds",20,o):d<40?s.formatDistance("halfAMinute",0,o):d<60?s.formatDistance("lessThanXMinutes",1,o):s.formatDistance("xMinutes",1,o):f===0?s.formatDistance("lessThanXMinutes",1,o):s.formatDistance("xMinutes",f,o);if(f<45)return s.formatDistance("xMinutes",f,o);if(f<90)return s.formatDistance("aboutXHours",1,o);if(f<uY){const m=Math.round(f/60);return s.formatDistance("aboutXHours",m,o)}else{if(f<i)return s.formatDistance("xDays",1,o);if(f<FA){const m=Math.round(f/uY);return s.formatDistance("xDays",m,o)}else if(f<FA*2)return p=Math.round(f/FA),s.formatDistance("aboutXMonths",p,o)}if(p=NFe(u,c),p<12){const m=Math.round(f/FA);return s.formatDistance("xMonths",m,o)}else{const m=p%12,g=Math.trunc(p/12);return m<3?s.formatDistance("aboutXYears",g,o):m<9?s.formatDistance("overXYears",g,o):s.formatDistance("almostXYears",g+1,o)}}function gY(t,e){return N$e(t,CV(t),e)}function E$e(t){return jfe(t,CV(t))}function A$e(t,e){return pFe(t,-e)}function C$e(t){return jfe(t,A$e(CV(t),1))}function T$e(t){if(!t||t.length===0)return[];const e=new Map;return t.forEach(r=>{const n=new Date(r.created_at),s=fj(n,"yyyy-MM-dd");let i;E$e(n)?i="Today":C$e(n)?i="Yesterday":i=fj(n,"MMMM d, yyyy"),e.has(s)?e.get(s).notes.push(r):e.set(s,{date:i,dateKey:s,notes:[r]})}),Array.from(e.values()).sort((r,n)=>n.dateKey.localeCompare(r.dateKey)).map(r=>({...r,notes:r.notes.sort((n,s)=>new Date(s.created_at).getTime()-new Date(n.created_at).getTime())}))}function P$e(t){return fj(new Date(t),"HH:mm")}function O$e(){const{user:t}=Dt(),{toast:e}=qn(),r=KH(),n=["user-notes",t==null?void 0:t.id],{data:s,isLoading:i,error:a}=YH({queryKey:n,queryFn:async()=>{const{data:h,error:f}=await be.from("user_notes").select("*").order("created_at",{ascending:!1});if(f)throw f;return h},enabled:!!t}),o=fL({mutationFn:async h=>{if(!t)throw new Error("Not authenticated");const{data:f,error:p}=await be.from("user_notes").insert({user_id:t.id,content:h}).select().single();if(p)throw p;return f},onSuccess:()=>{r.invalidateQueries({queryKey:n})},onError:h=>{e({title:"Error",description:"Could not save note.",variant:"destructive"}),console.error("Create note error:",h)}}),c=fL({mutationFn:async({id:h,content:f})=>{const{data:p,error:m}=await be.from("user_notes").update({content:f,updated_at:new Date().toISOString()}).eq("id",h).select().single();if(m)throw m;return p},onSuccess:()=>{r.invalidateQueries({queryKey:n})},onError:h=>{e({title:"Error",description:"Could not update note.",variant:"destructive"}),console.error("Update note error:",h)}}),u=fL({mutationFn:async h=>{const{error:f}=await be.from("user_notes").delete().eq("id",h);if(f)throw f},onSuccess:()=>{r.invalidateQueries({queryKey:n}),e({title:"Deleted",description:"Note has been removed."})},onError:h=>{e({title:"Error",description:"Could not delete note.",variant:"destructive"}),console.error("Delete note error:",h)}}),d=j.useMemo(()=>T$e(s),[s]);return{notes:s,groupedNotes:d,isLoading:i,error:a,createNote:async h=>{await o.mutateAsync(h)},updateNote:async h=>{await c.mutateAsync(h)},deleteNote:async h=>{await u.mutateAsync(h)},isCreating:o.isPending,isUpdating:c.isPending,isDeleting:u.isPending}}function I$e({note:t,onUpdate:e,onDelete:r,isUpdating:n,isDeleting:s}){const[i,a]=j.useState(!1),[o,c]=j.useState(t.content),u=async()=>{o.trim()&&o!==t.content&&await e(t.id,o.trim()),a(!1)},d=()=>{c(t.content),a(!1)},h=async()=>{await r(t.id)};return i?l.jsxs("div",{className:"group relative p-3 rounded-lg bg-muted/50 border border-border mb-2",children:[l.jsx(ir,{value:o,onChange:f=>c(f.target.value),className:"min-h-[80px] resize-none text-sm",autoFocus:!0}),l.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[l.jsxs(ye,{size:"sm",variant:"ghost",onClick:d,disabled:n,children:[l.jsx(Is,{className:"h-4 w-4 mr-1"}),"Cancel"]}),l.jsxs(ye,{size:"sm",onClick:u,disabled:n||!o.trim(),children:[l.jsx(Es,{className:"h-4 w-4 mr-1"}),"Save"]})]})]}):l.jsxs("div",{className:"group relative p-3 rounded-lg hover:bg-muted/50 transition-colors mb-2",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:P$e(t.created_at)}),l.jsx("p",{className:"text-sm text-foreground mt-1 whitespace-pre-wrap break-words",children:t.content}),l.jsxs("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity flex gap-1",children:[l.jsx(ye,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>a(!0),disabled:s,children:l.jsx(Mce,{className:"h-3.5 w-3.5"})}),l.jsx(ye,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:h,disabled:s,children:l.jsx(xi,{className:"h-3.5 w-3.5"})})]})]})}function R$e({open:t,onOpenChange:e}){const[r,n]=j.useState(""),{groupedNotes:s,isLoading:i,createNote:a,updateNote:o,deleteNote:c,isCreating:u,isUpdating:d,isDeleting:h}=O$e(),f=async()=>{!r.trim()||u||(await a(r.trim()),n(""))},p=m=>{(m.ctrlKey||m.metaKey)&&m.key==="Enter"&&(m.preventDefault(),f())};return l.jsx(Gr,{open:t,onOpenChange:e,children:l.jsxs(zr,{className:"sm:max-w-[800px] h-[80vh] flex flex-col p-0",children:[l.jsx(Ur,{className:"px-6 py-4 border-b border-border",children:l.jsxs(Hr,{className:"flex items-center gap-2",children:[l.jsx(k$,{className:"h-5 w-5 text-primary"}),"My Notebook"]})}),l.jsx(Yw,{className:"flex-1 px-6 overflow-y-auto",children:i?l.jsx("div",{className:"py-4 space-y-4",children:[1,2,3].map(m=>l.jsxs("div",{className:"space-y-2",children:[l.jsx(Sr,{className:"h-4 w-24"}),l.jsx(Sr,{className:"h-16 w-full"})]},m))}):s.length===0?l.jsxs("div",{className:"py-12 text-center",children:[l.jsx(k$,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground text-sm",children:"No notes yet."}),l.jsx("p",{className:"text-muted-foreground text-xs mt-1",children:"Write your first note below."})]}):l.jsx("div",{className:"py-4",children:s.map(m=>l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-3 my-4 first:mt-0",children:[l.jsx(vi,{className:"flex-1"}),l.jsx("span",{className:"text-xs font-medium text-muted-foreground whitespace-nowrap",children:m.date}),l.jsx(vi,{className:"flex-1"})]}),m.notes.map(g=>l.jsx(I$e,{note:g,onUpdate:(x,y)=>o({id:x,content:y}),onDelete:c,isUpdating:d,isDeleting:h},g.id))]},m.dateKey))})}),l.jsxs("div",{className:"border-t border-border p-4 bg-background",children:[l.jsxs("div",{className:"relative",children:[l.jsx(ir,{placeholder:"Write a new note... (Ctrl+Enter to save)",value:r,onChange:m=>n(m.target.value),onKeyDown:p,className:"min-h-[80px] pr-12 resize-none",disabled:u}),l.jsx(ye,{size:"icon",className:"absolute bottom-2 right-2 h-8 w-8",onClick:f,disabled:!r.trim()||u,children:l.jsx(Fce,{className:"h-4 w-4"})})]}),l.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center",children:"Your notes are saved automatically"})]})]})})}async function Efe(t,e,r=3600){if(!e)return null;const{data:n,error:s}=await be.storage.from(t).createSignedUrl(e,r);return s?(console.error("Signed URL error:",s),null):n.signedUrl}async function M$e(t,e=3600){if(!t)return null;const{data:r,error:n}=await be.storage.from("avatars").createSignedUrl(t,e);return n?(console.error("Avatar signed URL error:",n),null):r.signedUrl}async function sb(t){return t?t.startsWith("https://")?t:M$e(t):null}async function IR(t,e){const r={};return await Promise.all(t.map(async n=>{if(n.storage_path){const s=await Efe(e,n.storage_path);s&&(r[n.id]=s)}})),r}const yY=({pageTitle:t="Dashboard",onToggleSidebar:e,onToggleMobile:r,isMobileOpen:n,showSidebarControls:s=!0})=>{const{user:i,studentPoints:a,researchProfile:o,signOut:c}=Dt(),u=Or(),{theme:d}=xV(),[h,f]=j.useState(!1),[p,m]=j.useState(null);j.useEffect(()=>{(async()=>{const b=await sb(o==null?void 0:o.avatar_url);m(b)})()},[o==null?void 0:o.avatar_url]);const g=d==="dark"?"https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/src/logo_new_light.png":"https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/src/logo_new.png",x=async()=>{await c(),u("/login")},y=()=>o!=null&&o.nickname?o.nickname.slice(0,2).toUpperCase():i!=null&&i.email?i.email.slice(0,2).toUpperCase():"U";return!i||!s?l.jsxs("header",{className:"sticky top-0 z-40 flex items-center justify-between w-full bg-card border-b border-border px-4 lg:px-6 h-14",children:[l.jsx(bt,{to:"/",className:"flex items-center",children:l.jsx("img",{src:g,alt:"Academly.ai",className:"h-8 w-auto"})}),l.jsxs("div",{className:"flex items-center space-x-4",children:[l.jsx(bt,{to:"/pricing",className:"text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:"Pricing"}),l.jsx(bt,{to:"/how-it-works",className:"text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:"How it works"}),i?l.jsx(ye,{asChild:!0,size:"sm",children:l.jsx(bt,{to:"/dashboard",children:"Dashboard"})}):l.jsx(ye,{asChild:!0,size:"sm",children:l.jsx(bt,{to:"/login",children:"Login"})})]})]}):l.jsx("header",{className:"ta-header astro-header",children:l.jsxs("div",{className:"ta-header-content",children:[l.jsxs("div",{className:"ta-header-left",children:[l.jsx("button",{onClick:r,className:"lg:hidden flex items-center justify-center w-10 h-10 text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors","aria-label":"Toggle mobile menu",children:n?l.jsx(Is,{className:"w-5 h-5"}):l.jsx(PH,{className:"w-5 h-5"})}),l.jsx("button",{onClick:e,className:"hidden lg:flex items-center justify-center w-11 h-11 text-muted-foreground hover:text-foreground border border-border rounded-lg transition-colors","aria-label":"Toggle sidebar",children:l.jsx("svg",{width:"16",height:"12",viewBox:"0 0 16 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.583252 1C0.583252 0.585788 0.919038 0.25 1.33325 0.25H14.6666C15.0808 0.25 15.4166 0.585786 15.4166 1C15.4166 1.41421 15.0808 1.75 14.6666 1.75L1.33325 1.75C0.919038 1.75 0.583252 1.41422 0.583252 1ZM0.583252 11C0.583252 10.5858 0.919038 10.25 1.33325 10.25L14.6666 10.25C15.0808 10.25 15.4166 10.5858 15.4166 11C15.4166 11.4142 15.0808 11.75 14.6666 11.75L1.33325 11.75C0.919038 11.75 0.583252 11.4142 0.583252 11ZM1.33325 5.25C0.919038 5.25 0.583252 5.58579 0.583252 6C0.583252 6.41421 0.919038 6.75 1.33325 6.75L7.99992 6.75C8.41413 6.75 8.74992 6.41421 8.74992 6C8.74992 5.58579 8.41413 5.25 7.99992 5.25L1.33325 5.25Z",fill:"currentColor"})})}),l.jsx(bt,{to:"/dashboard",className:"lg:hidden",children:l.jsx("img",{src:g,alt:"Academly.ai",className:"h-8 w-auto"})}),l.jsx("h1",{className:"ta-header-title",children:t})]}),l.jsxs("div",{className:"ta-header-right",children:[l.jsx("button",{onClick:()=>f(!0),className:"flex items-center justify-center w-10 h-10 text-muted-foreground hover:text-foreground hover:bg-muted rounded-full border border-border transition-colors","aria-label":"Open notes",children:l.jsx(k$,{className:"w-5 h-5"})}),l.jsx(F3e,{}),l.jsx(R$e,{open:h,onOpenChange:f}),a&&l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 rounded-full bg-gradient-to-r from-primary/10 to-primary/5 border border-primary/20 shadow-sm shadow-primary/10",children:[l.jsx(Qs,{className:"h-4 w-4 text-primary"}),l.jsxs("span",{className:"text-sm font-semibold text-primary",children:[Math.floor(a.remaining).toLocaleString("de-DE")," SP"]})]}),l.jsxs(Ehe,{children:[l.jsx(Ahe,{asChild:!0,children:l.jsx("button",{className:"flex items-center gap-3 hover:opacity-80 transition-opacity",children:l.jsxs(NR,{className:"h-10 w-10 border-2 border-border",children:[p?l.jsx(ER,{src:p,alt:"Avatar"}):null,l.jsx(AR,{className:"bg-brand-50 text-brand-500 font-semibold",children:y()})]})})}),l.jsxs(mV,{className:"w-60",align:"end",forceMount:!0,children:[l.jsxs("div",{className:"px-4 py-3 border-b border-border",children:[l.jsx("p",{className:"font-medium text-foreground",children:(o==null?void 0:o.nickname)||"User"}),l.jsx("p",{className:"text-sm text-muted-foreground truncate",children:i==null?void 0:i.email})]}),l.jsxs(nb,{onClick:()=>u("/account"),className:"cursor-pointer",children:[l.jsx($w,{className:"mr-2 h-4 w-4"}),l.jsx("span",{children:"Manage Account"})]}),l.jsxs(nb,{onClick:()=>u("/history"),className:"cursor-pointer",children:[l.jsx(k2e,{className:"mr-2 h-4 w-4"}),l.jsx("span",{children:"History"})]}),l.jsx(gV,{}),l.jsxs(nb,{onClick:x,className:"cursor-pointer text-destructive focus:text-destructive",children:[l.jsx(P2e,{className:"mr-2 h-4 w-4"}),l.jsx("span",{children:"Sign Out"})]})]})]})]})]})})},Wr=({children:t,className:e=""})=>l.jsx("div",{className:`max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 ${e}`,children:t}),Bi=()=>l.jsx("footer",{className:"border-t border-border bg-card",children:l.jsx(Wr,{children:l.jsxs("div",{className:"py-12 lg:py-16",children:[l.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-8 lg:gap-12",children:[l.jsxs("div",{className:"col-span-2 md:col-span-1",children:[l.jsxs(bt,{to:"/",className:"flex items-center space-x-2 mb-4",children:[l.jsx("div",{className:"h-8 w-8 rounded-lg bg-primary flex items-center justify-center",children:l.jsx("span",{className:"text-primary-foreground font-bold text-sm",children:"A"})}),l.jsx("span",{className:"font-bold text-lg text-foreground",children:"Academly.ai"})]}),l.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Thesis platform built around source-backed academic writing."})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold text-foreground mb-4",children:"Product"}),l.jsxs("ul",{className:"space-y-3",children:[l.jsx("li",{children:l.jsx(bt,{to:"/#features",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Features"})}),l.jsx("li",{children:l.jsx(bt,{to:"/#how-it-works",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"How It Works"})}),l.jsx("li",{children:l.jsx(bt,{to:"/pricing",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Pricing"})})]})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold text-foreground mb-4",children:"Free Tools"}),l.jsxs("ul",{className:"space-y-3",children:[l.jsx("li",{children:l.jsx(bt,{to:"/topic-ideas",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Topic Generator"})}),l.jsx("li",{children:l.jsx(bt,{to:"/literature-search",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Literature Search"})})]})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold text-foreground mb-4",children:"Company"}),l.jsxs("ul",{className:"space-y-3",children:[l.jsx("li",{children:l.jsx(bt,{to:"/blog",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Blog"})}),l.jsx("li",{children:l.jsx(bt,{to:"/team",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Team"})}),l.jsx("li",{children:l.jsx("a",{href:"https://docs.academly.ai/",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Docs"})}),l.jsx("li",{children:l.jsx("a",{href:"mailto:support@academly.ai",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Support"})}),l.jsx("li",{children:l.jsx(bt,{to:"/legal#privacy",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Privacy"})}),l.jsx("li",{children:l.jsx(bt,{to:"/legal#terms",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Terms"})}),l.jsx("li",{children:l.jsx(bt,{to:"/legal",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"Imprint"})})]})]})]}),l.jsxs("div",{className:"border-t border-border mt-12 pt-8 flex flex-col md:flex-row justify-between items-center gap-4",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:["© ",new Date().getFullYear()," Academly.ai. All rights reserved."]}),l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsx("a",{href:"https://youtube.com/@academly-ai?si=hAadi72xwmt5fJ3u",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-primary transition-colors","aria-label":"YouTube",children:l.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{d:"M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"})})}),l.jsx("a",{href:"https://discord.gg/YFHAZY8d9",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-primary transition-colors","aria-label":"Discord",children:l.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{d:"M20.317 4.37a19.791 19.791 0 00-4.885-1.515.074.074 0 00-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 00-5.487 0 12.64 12.64 0 00-.617-1.25.077.077 0 00-.079-.037A19.736 19.736 0 003.677 4.37a.07.07 0 00-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 00.031.057 19.9 19.9 0 005.993 3.03.078.078 0 00.084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 00-.041-.106 13.107 13.107 0 01-1.872-.892.077.077 0 01-.008-.128 10.2 10.2 0 00.372-.292.074.074 0 01.077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 01.078.01c.12.098.246.198.373.292a.077.077 0 01-.006.127 12.299 12.299 0 01-1.873.892.077.077 0 00-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 00.084.028 19.839 19.839 0 006.002-3.03.077.077 0 00.032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 00-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})})}),l.jsx("a",{href:"https://www.linkedin.com/company/academly-ai",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-primary transition-colors","aria-label":"LinkedIn",children:l.jsx("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:l.jsx("path",{fillRule:"evenodd",d:"M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.777 7 2.476v6.759z",clipRule:"evenodd"})})})]})]})]})})}),D$e=[{name:"Dashboard",path:"/dashboard",icon:l.jsx(A2e,{className:"w-5 h-5"})},{name:"My Library",path:"/documents",icon:l.jsx(Br,{className:"w-5 h-5"})},{name:"My Citations",path:"/reference-checker",icon:l.jsx(Ah,{className:"w-5 h-5"})},{name:"My Thesis",icon:l.jsx(W2e,{className:"w-5 h-5"}),subItems:[{name:"Manager",path:"/thesis-manager"},{name:"My Thesis 2",path:"/my-thesis-2"}]}],L$e=[{name:"Topic Explorer",icon:l.jsx(ps,{className:"w-5 h-5"}),subItems:[{name:"Topic Ideas",path:"/topic-explorer/ideas"},{name:"Outline",path:"/topic-explorer/outline"},{name:"Literature Keywords",path:"/topic-explorer/keywords"}]},{name:"Theory & Background",path:"/thesis-builder",icon:l.jsx(ps,{className:"w-5 h-5"})},{name:"Methods & Approach",path:"/methods-approach",icon:l.jsx(Rce,{className:"w-5 h-5"})},{name:"Discussion",path:"/discussion",icon:l.jsx(Gy,{className:"w-5 h-5"})},{name:"Conclusion",path:"/conclusion",icon:l.jsx(J2e,{className:"w-5 h-5"})}],F$e=[{name:"Qualitative",icon:l.jsx(M2e,{className:"w-5 h-5"}),subItems:[{name:"Research Setup",path:"/qualitative/research-setup"},{name:"Codebook",path:"/qualitative/kodierbogen"},{name:"Codebook (Grid)",path:"/qualitative/kodierbogen-grid"},{name:"Interviews",path:"/qualitative/interviews"},{name:"Coding",path:"/qualitative/kodieren"},{name:"Analysis",path:"/qualitative/auswertung"}]}],$$e=[{name:"Summaries",path:"/summary",icon:l.jsx(hl,{className:"w-5 h-5"})},{name:"Text Extractor",path:"/pdf-extract",icon:l.jsx(Tce,{className:"w-5 h-5"})},{name:"Page Selector",path:"/pdf-slicer",icon:l.jsx(Lce,{className:"w-5 h-5"})},{name:"Supervisor",path:"/supervisor",icon:l.jsx(Oce,{className:"w-5 h-5"})}],xY=[{label:"Workspace",items:D$e,type:"workspace"},{label:"Writing",items:L$e,type:"writing"},{label:"Qualitative",items:F$e,type:"qualitative"},{label:"Utilities",items:$$e,type:"utilities"}];function B$e({isExpanded:t,isHovered:e,isMobileOpen:r,onHoverChange:n,onMobileClose:s}){const i=Ch(),a=i.pathname,{theme:o}=xV(),[c,u]=j.useState(null),[d,h]=j.useState({}),f=j.useRef({}),p=j.useCallback(y=>a===y,[a]),m=t||e||r;j.useEffect(()=>{let y=!1;xY.forEach(v=>{v.items.forEach((b,w)=>{b.subItems&&b.subItems.forEach(S=>{p(S.path)&&(u({type:v.type,index:w}),y=!0)})})}),y||u(null)},[i,p]),j.useEffect(()=>{if(c!==null){const y=`${c.type}-${c.index}`;f.current[y]&&h(v=>{var b;return{...v,[y]:((b=f.current[y])==null?void 0:b.scrollHeight)||0}})}},[c]);const g=(y,v)=>{u(b=>b&&b.type===v&&b.index===y?null:{type:v,index:y})},x=(y,v)=>l.jsx("ul",{className:"flex flex-col gap-1.5",children:y.map((b,w)=>l.jsx("li",{children:b.subItems?l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:()=>g(w,v),className:`astro-menu-item group w-full ${(c==null?void 0:c.type)===v&&(c==null?void 0:c.index)===w?"astro-menu-item-active":"astro-menu-item-inactive"} ${m?"":"justify-center"}`,children:[l.jsx("span",{className:`w-5 h-5 flex-shrink-0 transition-colors ${(c==null?void 0:c.type)===v&&(c==null?void 0:c.index)===w?"text-primary":"text-muted-foreground group-hover:text-foreground"}`,children:b.icon}),m&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"flex-1 text-left",children:b.name}),l.jsx(Eh,{className:`w-4 h-4 transition-transform duration-300 ${(c==null?void 0:c.type)===v&&(c==null?void 0:c.index)===w?"rotate-180":""}`})]})]}),m&&l.jsx("div",{ref:S=>{f.current[`${v}-${w}`]=S},className:"overflow-hidden transition-all duration-300 ease-out",style:{height:(c==null?void 0:c.type)===v&&(c==null?void 0:c.index)===w?`${d[`${v}-${w}`]}px`:"0px"},children:l.jsx("ul",{className:"mt-2 ml-9 space-y-1",children:b.subItems.map(S=>l.jsx("li",{children:l.jsx(bt,{to:S.path,onClick:s,className:`astro-dropdown-item ${p(S.path)?"astro-dropdown-item-active":"astro-dropdown-item-inactive"}`,children:S.name})},S.name))})})]}):b.path?l.jsxs(bt,{to:b.path,onClick:s,className:`astro-menu-item group ${p(b.path)?"astro-menu-item-active":"astro-menu-item-inactive"} ${m?"":"justify-center"}`,children:[l.jsx("span",{className:`w-5 h-5 flex-shrink-0 transition-colors ${p(b.path)?"text-primary":"text-muted-foreground group-hover:text-foreground"}`,children:b.icon}),m&&l.jsx("span",{children:b.name})]}):null},b.name))});return l.jsxs(l.Fragment,{children:[r&&l.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:s}),l.jsxs("aside",{className:`ta-sidebar astro-sidebar ${m?"ta-sidebar-expanded":"ta-sidebar-collapsed"} ${r?"ta-sidebar-mobile-open":"ta-sidebar-mobile-closed"}`,onMouseEnter:()=>!t&&n(!0),onMouseLeave:()=>n(!1),children:[l.jsx("div",{className:`ta-sidebar-logo ${m?"":"justify-center"}`,children:l.jsx(bt,{to:"/dashboard",className:"flex items-center",children:m?l.jsx("img",{src:o==="dark"?"https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/src/logo_new_light.png":"https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/src/logo_new.png",alt:"Academly.ai",className:"h-10 w-auto"}):l.jsx("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:l.jsx("span",{className:"text-primary-foreground font-bold text-sm",children:"ST"})})})}),l.jsx("nav",{className:"ta-sidebar-nav no-scrollbar",children:xY.map(y=>l.jsxs("div",{className:"ta-sidebar-section",children:[l.jsx("h2",{className:`ta-sidebar-section-label ${m?"":"text-center"}`,children:m?y.label:"•••"}),x(y.items,y.type)]},y.type))})]})]})}function z$e(){return l.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"text-foreground",children:[l.jsx("circle",{cx:"4",cy:"12",r:"2",fill:"currentColor",children:l.jsx("animate",{id:"spinner_qFRN",begin:"0;spinner_OcgL.end+0.25s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),l.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",children:l.jsx("animate",{begin:"spinner_qFRN.begin+0.1s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})}),l.jsx("circle",{cx:"20",cy:"12",r:"2",fill:"currentColor",children:l.jsx("animate",{id:"spinner_OcgL",begin:"spinner_qFRN.begin+0.2s",attributeName:"cy",calcMode:"spline",dur:"0.6s",values:"12;6;12",keySplines:".33,.66,.66,1;.33,0,.66,.33"})})]})}function vY({variant:t="received",layout:e="default",className:r,children:n}){return l.jsx("div",{className:Le("flex gap-2 max-w-[80%]",t==="sent"?"ml-auto flex-row-reverse":"",e==="ai"?"items-start":"items-end",r),children:n})}function bY({variant:t="received",isLoading:e,className:r,children:n}){return l.jsx("div",{className:Le("rounded-xl px-3 py-2 text-sm",t==="sent"?"bg-primary text-primary-foreground":"bg-muted text-foreground",r),children:e?l.jsx("div",{className:"flex items-center space-x-2",children:l.jsx(z$e,{})}):n})}function wY({src:t,fallback:e="AI",className:r}){return l.jsxs(NR,{className:Le("h-8 w-8 shrink-0",r),children:[t&&l.jsx(ER,{src:t}),l.jsx(AR,{className:"text-xs",children:e})]})}const Afe=j.forwardRef(({className:t,...e},r)=>l.jsx(ir,{autoComplete:"off",ref:r,name:"message",className:Le("max-h-12 px-4 py-3 bg-background text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 w-full rounded-md flex items-center h-16 resize-none",t),...e}));Afe.displayName="ChatInput";const $A={dimensions:{sm:"sm:max-w-sm sm:h-[500px]",md:"sm:max-w-md sm:h-[min(600px,calc(100vh-120px))]",lg:"sm:max-w-lg sm:h-[min(700px,calc(100vh-120px))]",xl:"sm:max-w-xl sm:h-[min(800px,calc(100vh-120px))]",full:"sm:w-full sm:h-full"},positions:{"bottom-right":"bottom-5 right-5","bottom-left":"bottom-5 left-5"},states:{open:"pointer-events-auto opacity-100 visible scale-100 translate-y-0",closed:"pointer-events-none opacity-0 invisible scale-100 sm:translate-y-5"}},Cfe=({className:t,position:e="bottom-right",size:r="md",icon:n,children:s,...i})=>{const[a,o]=j.useState(!1),c=j.useRef(null),u=()=>o(!a);return l.jsxs("div",{className:Le(`fixed ${$A.positions[e]} z-50 flex flex-col items-end gap-3 pointer-events-none`,t),...i,children:[l.jsxs("div",{ref:c,className:Le("flex flex-col bg-background border border-border sm:rounded-2xl shadow-xl","transition-all duration-250 ease-out origin-bottom-right","w-full sm:w-auto",$A.dimensions[r],a?$A.states.open:$A.states.closed),children:[s,l.jsx(ye,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 text-muted-foreground hover:text-foreground sm:hidden",onClick:u,children:l.jsx(Is,{className:"h-4 w-4"})})]}),l.jsx(Ife,{icon:n,isOpen:a,toggleChat:u})]})};Cfe.displayName="ExpandableChat";const Tfe=({className:t,...e})=>l.jsx("div",{className:Le("flex items-center justify-between p-4 border-b border-border",t),...e});Tfe.displayName="ExpandableChatHeader";const Pfe=({className:t,...e})=>l.jsx("div",{className:Le("flex-1 overflow-y-auto",t),...e});Pfe.displayName="ExpandableChatBody";const Ofe=({className:t,...e})=>l.jsx("div",{className:Le("border-t border-border p-4",t),...e});Ofe.displayName="ExpandableChatFooter";const Ife=({className:t,icon:e,isOpen:r,toggleChat:n,...s})=>l.jsx(ye,{variant:"default",onClick:n,className:Le("w-14 h-14 rounded-full shadow-lg hover:shadow-xl transition-shadow pointer-events-auto",t),...s,children:r?l.jsx(Is,{className:"h-6 w-6"}):e||l.jsx(R2e,{className:"h-6 w-6"})});Ife.displayName="ExpandableChatToggle";function U$e(t={}){const{offset:e=20,smooth:r=!1,content:n}=t,s=j.useRef(null),i=j.useRef(0),a=j.useRef(!1),[o,c]=j.useState({isAtBottom:!0,autoScrollEnabled:!0}),u=j.useCallback(p=>{const{scrollTop:m,scrollHeight:g,clientHeight:x}=p;return Math.abs(g-m-x)<=e},[e]),d=j.useCallback(p=>{if(!s.current)return;const m=s.current.scrollHeight-s.current.clientHeight;p?s.current.scrollTop=m:s.current.scrollTo({top:m,behavior:r?"smooth":"auto"}),c({isAtBottom:!0,autoScrollEnabled:!0}),a.current=!1},[r]),h=j.useCallback(()=>{if(!s.current)return;const p=u(s.current);c(m=>({isAtBottom:p,autoScrollEnabled:p?!0:m.autoScrollEnabled}))},[u]);j.useEffect(()=>{const p=s.current;if(p)return p.addEventListener("scroll",h,{passive:!0}),()=>p.removeEventListener("scroll",h)},[h]),j.useEffect(()=>{const p=s.current;if(!p)return;const m=p.scrollHeight;m!==i.current&&(o.autoScrollEnabled&&requestAnimationFrame(()=>{d(i.current===0)}),i.current=m)},[n,o.autoScrollEnabled,d]),j.useEffect(()=>{const p=s.current;if(!p)return;const m=new ResizeObserver(()=>{o.autoScrollEnabled&&d(!0)});return m.observe(p),()=>m.disconnect()},[o.autoScrollEnabled,d]);const f=j.useCallback(()=>{(s.current?u(s.current):!1)||(a.current=!0,c(m=>({...m,autoScrollEnabled:!1})))},[u]);return{scrollRef:s,isAtBottom:o.isAtBottom,autoScrollEnabled:o.autoScrollEnabled,scrollToBottom:()=>d(!1),disableAutoScroll:f}}const Rfe=j.forwardRef(({className:t,children:e,smooth:r=!1,...n},s)=>{const{scrollRef:i,isAtBottom:a,autoScrollEnabled:o,scrollToBottom:c,disableAutoScroll:u}=U$e({smooth:r,content:e});return l.jsxs("div",{className:Le("relative w-full h-full",t),...n,children:[l.jsx("div",{className:"h-full overflow-y-auto p-4",ref:i,onWheel:u,onTouchMove:u,children:l.jsx("div",{className:"flex flex-col gap-4",children:e})}),!a&&l.jsx(ye,{onClick:()=>{c()},size:"icon",variant:"outline",className:"absolute bottom-2 left-1/2 transform -translate-x-1/2 inline-flex rounded-full shadow-md","aria-label":"Scroll to bottom",children:l.jsx(e2e,{className:"h-4 w-4"})})]})});Rfe.displayName="ChatMessageList";function H$e(t,e){const r={};return(t[t.length-1]===""?[...t,""]:t).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const V$e=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,W$e=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,q$e={};function SY(t,e){return(q$e.jsx?W$e:V$e).test(t)}const G$e=/[ \t\n\f\r]/g;function K$e(t){return typeof t=="object"?t.type==="text"?_Y(t.value):!1:_Y(t)}function _Y(t){return t.replace(G$e,"")===""}let wE=class{constructor(e,r,n){this.normal=r,this.property=e,n&&(this.space=n)}};wE.prototype.normal={};wE.prototype.property={};wE.prototype.space=void 0;function Mfe(t,e){const r={},n={};for(const s of t)Object.assign(r,s.property),Object.assign(n,s.normal);return new wE(r,n,e)}function d6(t){return t.toLowerCase()}class Za{constructor(e,r){this.attribute=r,this.property=e}}Za.prototype.attribute="";Za.prototype.booleanish=!1;Za.prototype.boolean=!1;Za.prototype.commaOrSpaceSeparated=!1;Za.prototype.commaSeparated=!1;Za.prototype.defined=!1;Za.prototype.mustUseProperty=!1;Za.prototype.number=!1;Za.prototype.overloadedBoolean=!1;Za.prototype.property="";Za.prototype.spaceSeparated=!1;Za.prototype.space=void 0;let Y$e=0;const Vt=Sx(),is=Sx(),h6=Sx(),Je=Sx(),Jr=Sx(),ib=Sx(),to=Sx();function Sx(){return 2**++Y$e}const f6=Object.freeze(Object.defineProperty({__proto__:null,boolean:Vt,booleanish:is,commaOrSpaceSeparated:to,commaSeparated:ib,number:Je,overloadedBoolean:h6,spaceSeparated:Jr},Symbol.toStringTag,{value:"Module"})),IL=Object.keys(f6);class PV extends Za{constructor(e,r,n,s){let i=-1;if(super(e,r),jY(this,"space",s),typeof n=="number")for(;++i<IL.length;){const a=IL[i];jY(this,IL[i],(n&f6[a])===f6[a])}}}PV.prototype.defined=!0;function jY(t,e,r){r&&(t[e]=r)}function Xw(t){const e={},r={};for(const[n,s]of Object.entries(t.properties)){const i=new PV(n,t.transform(t.attributes||{},n),s,t.space);t.mustUseProperty&&t.mustUseProperty.includes(n)&&(i.mustUseProperty=!0),e[n]=i,r[d6(n)]=n,r[d6(i.attribute)]=n}return new wE(e,r,t.space)}const Dfe=Xw({properties:{ariaActiveDescendant:null,ariaAtomic:is,ariaAutoComplete:null,ariaBusy:is,ariaChecked:is,ariaColCount:Je,ariaColIndex:Je,ariaColSpan:Je,ariaControls:Jr,ariaCurrent:null,ariaDescribedBy:Jr,ariaDetails:null,ariaDisabled:is,ariaDropEffect:Jr,ariaErrorMessage:null,ariaExpanded:is,ariaFlowTo:Jr,ariaGrabbed:is,ariaHasPopup:null,ariaHidden:is,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Jr,ariaLevel:Je,ariaLive:null,ariaModal:is,ariaMultiLine:is,ariaMultiSelectable:is,ariaOrientation:null,ariaOwns:Jr,ariaPlaceholder:null,ariaPosInSet:Je,ariaPressed:is,ariaReadOnly:is,ariaRelevant:null,ariaRequired:is,ariaRoleDescription:Jr,ariaRowCount:Je,ariaRowIndex:Je,ariaRowSpan:Je,ariaSelected:is,ariaSetSize:Je,ariaSort:null,ariaValueMax:Je,ariaValueMin:Je,ariaValueNow:Je,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function Lfe(t,e){return e in t?t[e]:e}function Ffe(t,e){return Lfe(t,e.toLowerCase())}const X$e=Xw({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ib,acceptCharset:Jr,accessKey:Jr,action:null,allow:null,allowFullScreen:Vt,allowPaymentRequest:Vt,allowUserMedia:Vt,alt:null,as:null,async:Vt,autoCapitalize:null,autoComplete:Jr,autoFocus:Vt,autoPlay:Vt,blocking:Jr,capture:null,charSet:null,checked:Vt,cite:null,className:Jr,cols:Je,colSpan:null,content:null,contentEditable:is,controls:Vt,controlsList:Jr,coords:Je|ib,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Vt,defer:Vt,dir:null,dirName:null,disabled:Vt,download:h6,draggable:is,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Vt,formTarget:null,headers:Jr,height:Je,hidden:h6,high:Je,href:null,hrefLang:null,htmlFor:Jr,httpEquiv:Jr,id:null,imageSizes:null,imageSrcSet:null,inert:Vt,inputMode:null,integrity:null,is:null,isMap:Vt,itemId:null,itemProp:Jr,itemRef:Jr,itemScope:Vt,itemType:Jr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Vt,low:Je,manifest:null,max:null,maxLength:Je,media:null,method:null,min:null,minLength:Je,multiple:Vt,muted:Vt,name:null,nonce:null,noModule:Vt,noValidate:Vt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Vt,optimum:Je,pattern:null,ping:Jr,placeholder:null,playsInline:Vt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Vt,referrerPolicy:null,rel:Jr,required:Vt,reversed:Vt,rows:Je,rowSpan:Je,sandbox:Jr,scope:null,scoped:Vt,seamless:Vt,selected:Vt,shadowRootClonable:Vt,shadowRootDelegatesFocus:Vt,shadowRootMode:null,shape:null,size:Je,sizes:null,slot:null,span:Je,spellCheck:is,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Je,step:null,style:null,tabIndex:Je,target:null,title:null,translate:null,type:null,typeMustMatch:Vt,useMap:null,value:is,width:Je,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Jr,axis:null,background:null,bgColor:null,border:Je,borderColor:null,bottomMargin:Je,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Vt,declare:Vt,event:null,face:null,frame:null,frameBorder:null,hSpace:Je,leftMargin:Je,link:null,longDesc:null,lowSrc:null,marginHeight:Je,marginWidth:Je,noResize:Vt,noHref:Vt,noShade:Vt,noWrap:Vt,object:null,profile:null,prompt:null,rev:null,rightMargin:Je,rules:null,scheme:null,scrolling:is,standby:null,summary:null,text:null,topMargin:Je,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Je,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Vt,disableRemotePlayback:Vt,prefix:null,property:null,results:Je,security:null,unselectable:null},space:"html",transform:Ffe}),J$e=Xw({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",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",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",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",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",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",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:to,accentHeight:Je,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Je,amplitude:Je,arabicForm:null,ascent:Je,attributeName:null,attributeType:null,azimuth:Je,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Je,by:null,calcMode:null,capHeight:Je,className:Jr,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Je,diffuseConstant:Je,direction:null,display:null,dur:null,divisor:Je,dominantBaseline:null,download:Vt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Je,enableBackground:null,end:null,event:null,exponent:Je,externalResourcesRequired:null,fill:null,fillOpacity:Je,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ib,g2:ib,glyphName:ib,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Je,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Je,horizOriginX:Je,horizOriginY:Je,id:null,ideographic:Je,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Je,k:Je,k1:Je,k2:Je,k3:Je,k4:Je,kernelMatrix:to,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Je,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Je,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Je,overlineThickness:Je,paintOrder:null,panose1:null,path:null,pathLength:Je,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Jr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Je,pointsAtY:Je,pointsAtZ:Je,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:to,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:to,rev:to,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:to,requiredFeatures:to,requiredFonts:to,requiredFormats:to,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Je,specularExponent:Je,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Je,strikethroughThickness:Je,string:null,stroke:null,strokeDashArray:to,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Je,strokeOpacity:Je,strokeWidth:null,style:null,surfaceScale:Je,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:to,tabIndex:Je,tableValues:null,target:null,targetX:Je,targetY:Je,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:to,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Je,underlineThickness:Je,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Je,values:null,vAlphabetic:Je,vMathematical:Je,vectorEffect:null,vHanging:Je,vIdeographic:Je,version:null,vertAdvY:Je,vertOriginX:Je,vertOriginY:Je,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Je,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Lfe}),$fe=Xw({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),Bfe=Xw({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ffe}),zfe=Xw({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),Q$e={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Z$e=/[A-Z]/g,kY=/-[a-z]/g,e6e=/^data[-\w.:]+$/i;function t6e(t,e){const r=d6(e);let n=e,s=Za;if(r in t.normal)return t.property[t.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&e6e.test(e)){if(e.charAt(4)==="-"){const i=e.slice(5).replace(kY,n6e);n="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=e.slice(4);if(!kY.test(i)){let a=i.replace(Z$e,r6e);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}s=PV}return new s(n,e)}function r6e(t){return"-"+t.toLowerCase()}function n6e(t){return t.charAt(1).toUpperCase()}const s6e=Mfe([Dfe,X$e,$fe,Bfe,zfe],"html"),OV=Mfe([Dfe,J$e,$fe,Bfe,zfe],"svg");function i6e(t){return t.join(" ").trim()}var IV={},NY=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,a6e=/\n/g,o6e=/^\s*/,l6e=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,c6e=/^:\s*/,u6e=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d6e=/^[;\s]*/,h6e=/^\s+|\s+$/g,f6e=`
`,EY="/",AY="*",Vm="",p6e="comment",m6e="declaration",g6e=function(t,e){if(typeof t!="string")throw new TypeError("First argument must be a string");if(!t)return[];e=e||{};var r=1,n=1;function s(m){var g=m.match(a6e);g&&(r+=g.length);var x=m.lastIndexOf(f6e);n=~x?m.length-x:n+m.length}function i(){var m={line:r,column:n};return function(g){return g.position=new a(m),u(),g}}function a(m){this.start=m,this.end={line:r,column:n},this.source=e.source}a.prototype.content=t;function o(m){var g=new Error(e.source+":"+r+":"+n+": "+m);if(g.reason=m,g.filename=e.source,g.line=r,g.column=n,g.source=t,!e.silent)throw g}function c(m){var g=m.exec(t);if(g){var x=g[0];return s(x),t=t.slice(x.length),g}}function u(){c(o6e)}function d(m){var g;for(m=m||[];g=h();)g!==!1&&m.push(g);return m}function h(){var m=i();if(!(EY!=t.charAt(0)||AY!=t.charAt(1))){for(var g=2;Vm!=t.charAt(g)&&(AY!=t.charAt(g)||EY!=t.charAt(g+1));)++g;if(g+=2,Vm===t.charAt(g-1))return o("End of comment missing");var x=t.slice(2,g-2);return n+=2,s(x),t=t.slice(g),n+=2,m({type:p6e,comment:x})}}function f(){var m=i(),g=c(l6e);if(g){if(h(),!c(c6e))return o("property missing ':'");var x=c(u6e),y=m({type:m6e,property:CY(g[0].replace(NY,Vm)),value:x?CY(x[0].replace(NY,Vm)):Vm});return c(d6e),y}}function p(){var m=[];d(m);for(var g;g=f();)g!==!1&&(m.push(g),d(m));return m}return u(),p()};function CY(t){return t?t.replace(h6e,Vm):Vm}var y6e=dn&&dn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(IV,"__esModule",{value:!0});IV.default=v6e;var x6e=y6e(g6e);function v6e(t,e){var r=null;if(!t||typeof t!="string")return r;var n=(0,x6e.default)(t),s=typeof e=="function";return n.forEach(function(i){if(i.type==="declaration"){var a=i.property,o=i.value;s?e(a,o,i):o&&(r=r||{},r[a]=o)}}),r}var RR={};Object.defineProperty(RR,"__esModule",{value:!0});RR.camelCase=void 0;var b6e=/^--[a-zA-Z0-9_-]+$/,w6e=/-([a-z])/g,S6e=/^[^-]+$/,_6e=/^-(webkit|moz|ms|o|khtml)-/,j6e=/^-(ms)-/,k6e=function(t){return!t||S6e.test(t)||b6e.test(t)},N6e=function(t,e){return e.toUpperCase()},TY=function(t,e){return"".concat(e,"-")},E6e=function(t,e){return e===void 0&&(e={}),k6e(t)?t:(t=t.toLowerCase(),e.reactCompat?t=t.replace(j6e,TY):t=t.replace(_6e,TY),t.replace(w6e,N6e))};RR.camelCase=E6e;var A6e=dn&&dn.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},C6e=A6e(IV),T6e=RR;function p6(t,e){var r={};return!t||typeof t!="string"||(0,C6e.default)(t,function(n,s){n&&s&&(r[(0,T6e.camelCase)(n,e)]=s)}),r}p6.default=p6;var P6e=p6;const O6e=cr(P6e),Ufe=Hfe("end"),RV=Hfe("start");function Hfe(t){return e;function e(r){const n=r&&r.position&&r.position[t]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function I6e(t){const e=RV(t),r=Ufe(t);if(e&&r)return{start:e,end:r}}function p_(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?PY(t.position):"start"in t||"end"in t?PY(t):"line"in t||"column"in t?m6(t):""}function m6(t){return OY(t&&t.line)+":"+OY(t&&t.column)}function PY(t){return m6(t&&t.start)+"-"+m6(t&&t.end)}function OY(t){return t&&typeof t=="number"?t:1}class Yi extends Error{constructor(e,r,n){super(),typeof r=="string"&&(n=r,r=void 0);let s="",i={},a=!1;if(r&&("line"in r&&"column"in r?i={place:r}:"start"in r&&"end"in r?i={place:r}:"type"in r?i={ancestors:[r],place:r.position}:i={...r}),typeof e=="string"?s=e:!i.cause&&e&&(a=!0,s=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n=="string"){const c=n.indexOf(":");c===-1?i.ruleId=n:(i.source=n.slice(0,c),i.ruleId=n.slice(c+1))}if(!i.place&&i.ancestors&&i.ancestors){const c=i.ancestors[i.ancestors.length-1];c&&(i.place=c.position)}const o=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=o?o.line:void 0,this.name=p_(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Yi.prototype.file="";Yi.prototype.name="";Yi.prototype.reason="";Yi.prototype.message="";Yi.prototype.stack="";Yi.prototype.column=void 0;Yi.prototype.line=void 0;Yi.prototype.ancestors=void 0;Yi.prototype.cause=void 0;Yi.prototype.fatal=void 0;Yi.prototype.place=void 0;Yi.prototype.ruleId=void 0;Yi.prototype.source=void 0;const MV={}.hasOwnProperty,R6e=new Map,M6e=/[A-Z]/g,D6e=new Set(["table","tbody","thead","tfoot","tr"]),L6e=new Set(["td","th"]),Vfe="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function F6e(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=e.filePath||void 0;let n;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");n=q6e(r,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");n=W6e(r,e.jsx,e.jsxs)}const s={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:n,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?OV:s6e,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},i=Wfe(s,t,void 0);return i&&typeof i!="string"?i:s.create(t,s.Fragment,{children:i||void 0},void 0)}function Wfe(t,e,r){if(e.type==="element")return $6e(t,e,r);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return B6e(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return U6e(t,e,r);if(e.type==="mdxjsEsm")return z6e(t,e);if(e.type==="root")return H6e(t,e,r);if(e.type==="text")return V6e(t,e)}function $6e(t,e,r){const n=t.schema;let s=n;e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(s=OV,t.schema=s),t.ancestors.push(e);const i=Gfe(t,e.tagName,!1),a=G6e(t,e);let o=LV(t,e);return D6e.has(e.tagName)&&(o=o.filter(function(c){return typeof c=="string"?!K$e(c):!0})),qfe(t,a,i,e),DV(a,o),t.ancestors.pop(),t.schema=n,t.create(e,i,a,r)}function B6e(t,e){if(e.data&&e.data.estree&&t.evaluater){const n=e.data.estree.body[0];return n.type,t.evaluater.evaluateExpression(n.expression)}pj(t,e.position)}function z6e(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);pj(t,e.position)}function U6e(t,e,r){const n=t.schema;let s=n;e.name==="svg"&&n.space==="html"&&(s=OV,t.schema=s),t.ancestors.push(e);const i=e.name===null?t.Fragment:Gfe(t,e.name,!0),a=K6e(t,e),o=LV(t,e);return qfe(t,a,i,e),DV(a,o),t.ancestors.pop(),t.schema=n,t.create(e,i,a,r)}function H6e(t,e,r){const n={};return DV(n,LV(t,e)),t.create(e,t.Fragment,n,r)}function V6e(t,e){return e.value}function qfe(t,e,r,n){typeof r!="string"&&r!==t.Fragment&&t.passNode&&(e.node=n)}function DV(t,e){if(e.length>0){const r=e.length>1?e:e[0];r&&(t.children=r)}}function W6e(t,e,r){return n;function n(s,i,a,o){const u=Array.isArray(a.children)?r:e;return o?u(i,a,o):u(i,a)}}function q6e(t,e){return r;function r(n,s,i,a){const o=Array.isArray(i.children),c=RV(n);return e(s,i,a,o,{columnNumber:c?c.column-1:void 0,fileName:t,lineNumber:c?c.line:void 0},void 0)}}function G6e(t,e){const r={};let n,s;for(s in e.properties)if(s!=="children"&&MV.call(e.properties,s)){const i=Y6e(t,s,e.properties[s]);if(i){const[a,o]=i;t.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&L6e.has(e.tagName)?n=o:r[a]=o}}if(n){const i=r.style||(r.style={});i[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return r}function K6e(t,e){const r={};for(const n of e.attributes)if(n.type==="mdxJsxExpressionAttribute")if(n.data&&n.data.estree&&t.evaluater){const i=n.data.estree.body[0];i.type;const a=i.expression;a.type;const o=a.properties[0];o.type,Object.assign(r,t.evaluater.evaluateExpression(o.argument))}else pj(t,e.position);else{const s=n.name;let i;if(n.value&&typeof n.value=="object")if(n.value.data&&n.value.data.estree&&t.evaluater){const o=n.value.data.estree.body[0];o.type,i=t.evaluater.evaluateExpression(o.expression)}else pj(t,e.position);else i=n.value===null?!0:n.value;r[s]=i}return r}function LV(t,e){const r=[];let n=-1;const s=t.passKeys?new Map:R6e;for(;++n<e.children.length;){const i=e.children[n];let a;if(t.passKeys){const c=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(c){const u=s.get(c)||0;a=c+"-"+u,s.set(c,u+1)}}const o=Wfe(t,i,a);o!==void 0&&r.push(o)}return r}function Y6e(t,e,r){const n=t6e(t.schema,e);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=n.commaSeparated?H$e(r):i6e(r)),n.property==="style"){let s=typeof r=="object"?r:X6e(t,String(r));return t.stylePropertyNameCase==="css"&&(s=J6e(s)),["style",s]}return[t.elementAttributeNameCase==="react"&&n.space?Q$e[n.property]||n.property:n.attribute,r]}}function X6e(t,e){try{return O6e(e,{reactCompat:!0})}catch(r){if(t.ignoreInvalidStyle)return{};const n=r,s=new Yi("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=t.filePath||void 0,s.url=Vfe+"#cannot-parse-style-attribute",s}}function Gfe(t,e,r){let n;if(!r)n={type:"Literal",value:e};else if(e.includes(".")){const s=e.split(".");let i=-1,a;for(;++i<s.length;){const o=SY(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(i&&o.type==="Literal"),optional:!1}:o}n=a}else n=SY(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(n.type==="Literal"){const s=n.value;return MV.call(t.components,s)?t.components[s]:s}if(t.evaluater)return t.evaluater.evaluateExpression(n);pj(t)}function pj(t,e){const r=new Yi("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=t.filePath||void 0,r.url=Vfe+"#cannot-handle-mdx-estrees-without-createevaluater",r}function J6e(t){const e={};let r;for(r in t)MV.call(t,r)&&(e[Q6e(r)]=t[r]);return e}function Q6e(t){let e=t.replace(M6e,Z6e);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function Z6e(t){return"-"+t.toLowerCase()}const RL={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},eBe={};function FV(t,e){const r=eBe,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,s=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return Kfe(t,n,s)}function Kfe(t,e,r){if(tBe(t)){if("value"in t)return t.type==="html"&&!r?"":t.value;if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return IY(t.children,e,r)}return Array.isArray(t)?IY(t,e,r):""}function IY(t,e,r){const n=[];let s=-1;for(;++s<t.length;)n[s]=Kfe(t[s],e,r);return n.join("")}function tBe(t){return!!(t&&typeof t=="object")}const RY=document.createElement("i");function $V(t){const e="&"+t+";";RY.innerHTML=e;const r=RY.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===e?!1:r}function To(t,e,r,n){const s=t.length;let i=0,a;if(e<0?e=-e>s?0:s+e:e=e>s?s:e,r=r>0?r:0,n.length<1e4)a=Array.from(n),a.unshift(e,r),t.splice(...a);else for(r&&t.splice(e,r);i<n.length;)a=n.slice(i,i+1e4),a.unshift(e,0),t.splice(...a),i+=1e4,e+=1e4}function al(t,e){return t.length>0?(To(t,t.length,0,e),t):e}const MY={}.hasOwnProperty;function Yfe(t){const e={};let r=-1;for(;++r<t.length;)rBe(e,t[r]);return e}function rBe(t,e){let r;for(r in e){const s=(MY.call(t,r)?t[r]:void 0)||(t[r]={}),i=e[r];let a;if(i)for(a in i){MY.call(s,a)||(s[a]=[]);const o=i[a];nBe(s[a],Array.isArray(o)?o:o?[o]:[])}}}function nBe(t,e){let r=-1;const n=[];for(;++r<e.length;)(e[r].add==="after"?t:n).push(e[r]);To(t,0,0,n)}function Xfe(t,e){const r=Number.parseInt(t,e);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function fc(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const da=am(/[A-Za-z]/),Li=am(/[\dA-Za-z]/),sBe=am(/[#-'*+\--9=?A-Z^-~]/);function iP(t){return t!==null&&(t<32||t===127)}const g6=am(/\d/),iBe=am(/[\dA-Fa-f]/),aBe=am(/[!-/:-@[-`{-~]/);function Nt(t){return t!==null&&t<-2}function Kr(t){return t!==null&&(t<0||t===32)}function ar(t){return t===-2||t===-1||t===32}const MR=am(new RegExp("\\p{P}|\\p{S}","u")),Qy=am(/\s/);function am(t){return e;function e(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function Jw(t){const e=[];let r=-1,n=0,s=0;for(;++r<t.length;){const i=t.charCodeAt(r);let a="";if(i===37&&Li(t.charCodeAt(r+1))&&Li(t.charCodeAt(r+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const o=t.charCodeAt(r+1);i<56320&&o>56319&&o<57344?(a=String.fromCharCode(i,o),s=1):a="�"}else a=String.fromCharCode(i);a&&(e.push(t.slice(n,r),encodeURIComponent(a)),n=r+s+1,a=""),s&&(r+=s,s=0)}return e.join("")+t.slice(n)}function pr(t,e,r,n){const s=n?n-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return ar(c)?(t.enter(r),o(c)):e(c)}function o(c){return ar(c)&&i++<s?(t.consume(c),o):(t.exit(r),e(c))}}const oBe={tokenize:lBe};function lBe(t){const e=t.attempt(this.parser.constructs.contentInitial,n,s);let r;return e;function n(o){if(o===null){t.consume(o);return}return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),pr(t,e,"linePrefix")}function s(o){return t.enter("paragraph"),i(o)}function i(o){const c=t.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=c),r=c,a(o)}function a(o){if(o===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(o);return}return Nt(o)?(t.consume(o),t.exit("chunkText"),i):(t.consume(o),a)}}const cBe={tokenize:uBe},DY={tokenize:dBe};function uBe(t){const e=this,r=[];let n=0,s,i,a;return o;function o(b){if(n<r.length){const w=r[n];return e.containerState=w[1],t.attempt(w[0].continuation,c,u)(b)}return u(b)}function c(b){if(n++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,s&&v();const w=e.events.length;let S=w,k;for(;S--;)if(e.events[S][0]==="exit"&&e.events[S][1].type==="chunkFlow"){k=e.events[S][1].end;break}y(n);let E=w;for(;E<e.events.length;)e.events[E][1].end={...k},E++;return To(e.events,S+1,0,e.events.slice(w)),e.events.length=E,u(b)}return o(b)}function u(b){if(n===r.length){if(!s)return f(b);if(s.currentConstruct&&s.currentConstruct.concrete)return m(b);e.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(DY,d,h)(b)}function d(b){return s&&v(),y(n),f(b)}function h(b){return e.parser.lazy[e.now().line]=n!==r.length,a=e.now().offset,m(b)}function f(b){return e.containerState={},t.attempt(DY,p,m)(b)}function p(b){return n++,r.push([e.currentConstruct,e.containerState]),f(b)}function m(b){if(b===null){s&&v(),y(0),t.consume(b);return}return s=s||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),g(b)}function g(b){if(b===null){x(t.exit("chunkFlow"),!0),y(0),t.consume(b);return}return Nt(b)?(t.consume(b),x(t.exit("chunkFlow")),n=0,e.interrupt=void 0,o):(t.consume(b),g)}function x(b,w){const S=e.sliceStream(b);if(w&&S.push(null),b.previous=i,i&&(i.next=b),i=b,s.defineSkip(b.start),s.write(S),e.parser.lazy[b.start.line]){let k=s.events.length;for(;k--;)if(s.events[k][1].start.offset<a&&(!s.events[k][1].end||s.events[k][1].end.offset>a))return;const E=e.events.length;let C=E,A,M;for(;C--;)if(e.events[C][0]==="exit"&&e.events[C][1].type==="chunkFlow"){if(A){M=e.events[C][1].end;break}A=!0}for(y(n),k=E;k<e.events.length;)e.events[k][1].end={...M},k++;To(e.events,C+1,0,e.events.slice(E)),e.events.length=k}}function y(b){let w=r.length;for(;w-- >b;){const S=r[w];e.containerState=S[1],S[0].exit.call(e,t)}r.length=b}function v(){s.write([null]),i=void 0,s=void 0,e.containerState._closeFlow=void 0}}function dBe(t,e,r){return pr(t,t.attempt(this.parser.constructs.document,e,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function K0(t){if(t===null||Kr(t)||Qy(t))return 1;if(MR(t))return 2}function DR(t,e,r){const n=[];let s=-1;for(;++s<t.length;){const i=t[s].resolveAll;i&&!n.includes(i)&&(e=i(e,r),n.push(i))}return e}const y6={name:"attention",resolveAll:hBe,tokenize:fBe};function hBe(t,e){let r=-1,n,s,i,a,o,c,u,d;for(;++r<t.length;)if(t[r][0]==="enter"&&t[r][1].type==="attentionSequence"&&t[r][1]._close){for(n=r;n--;)if(t[n][0]==="exit"&&t[n][1].type==="attentionSequence"&&t[n][1]._open&&e.sliceSerialize(t[n][1]).charCodeAt(0)===e.sliceSerialize(t[r][1]).charCodeAt(0)){if((t[n][1]._close||t[r][1]._open)&&(t[r][1].end.offset-t[r][1].start.offset)%3&&!((t[n][1].end.offset-t[n][1].start.offset+t[r][1].end.offset-t[r][1].start.offset)%3))continue;c=t[n][1].end.offset-t[n][1].start.offset>1&&t[r][1].end.offset-t[r][1].start.offset>1?2:1;const h={...t[n][1].end},f={...t[r][1].start};LY(h,-c),LY(f,c),a={type:c>1?"strongSequence":"emphasisSequence",start:h,end:{...t[n][1].end}},o={type:c>1?"strongSequence":"emphasisSequence",start:{...t[r][1].start},end:f},i={type:c>1?"strongText":"emphasisText",start:{...t[n][1].end},end:{...t[r][1].start}},s={type:c>1?"strong":"emphasis",start:{...a.start},end:{...o.end}},t[n][1].end={...a.start},t[r][1].start={...o.end},u=[],t[n][1].end.offset-t[n][1].start.offset&&(u=al(u,[["enter",t[n][1],e],["exit",t[n][1],e]])),u=al(u,[["enter",s,e],["enter",a,e],["exit",a,e],["enter",i,e]]),u=al(u,DR(e.parser.constructs.insideSpan.null,t.slice(n+1,r),e)),u=al(u,[["exit",i,e],["enter",o,e],["exit",o,e],["exit",s,e]]),t[r][1].end.offset-t[r][1].start.offset?(d=2,u=al(u,[["enter",t[r][1],e],["exit",t[r][1],e]])):d=0,To(t,n-1,r-n+3,u),r=n+u.length-d-2;break}}for(r=-1;++r<t.length;)t[r][1].type==="attentionSequence"&&(t[r][1].type="data");return t}function fBe(t,e){const r=this.parser.constructs.attentionMarkers.null,n=this.previous,s=K0(n);let i;return a;function a(c){return i=c,t.enter("attentionSequence"),o(c)}function o(c){if(c===i)return t.consume(c),o;const u=t.exit("attentionSequence"),d=K0(c),h=!d||d===2&&s||r.includes(c),f=!s||s===2&&d||r.includes(n);return u._open=!!(i===42?h:h&&(s||!f)),u._close=!!(i===42?f:f&&(d||!h)),e(c)}}function LY(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const pBe={name:"autolink",tokenize:mBe};function mBe(t,e,r){let n=0;return s;function s(p){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(p),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),i}function i(p){return da(p)?(t.consume(p),a):p===64?r(p):u(p)}function a(p){return p===43||p===45||p===46||Li(p)?(n=1,o(p)):u(p)}function o(p){return p===58?(t.consume(p),n=0,c):(p===43||p===45||p===46||Li(p))&&n++<32?(t.consume(p),o):(n=0,u(p))}function c(p){return p===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(p),t.exit("autolinkMarker"),t.exit("autolink"),e):p===null||p===32||p===60||iP(p)?r(p):(t.consume(p),c)}function u(p){return p===64?(t.consume(p),d):sBe(p)?(t.consume(p),u):r(p)}function d(p){return Li(p)?h(p):r(p)}function h(p){return p===46?(t.consume(p),n=0,d):p===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(p),t.exit("autolinkMarker"),t.exit("autolink"),e):f(p)}function f(p){if((p===45||Li(p))&&n++<63){const m=p===45?f:h;return t.consume(p),m}return r(p)}}const SE={partial:!0,tokenize:gBe};function gBe(t,e,r){return n;function n(i){return ar(i)?pr(t,s,"linePrefix")(i):s(i)}function s(i){return i===null||Nt(i)?e(i):r(i)}}const Jfe={continuation:{tokenize:xBe},exit:vBe,name:"blockQuote",tokenize:yBe};function yBe(t,e,r){const n=this;return s;function s(a){if(a===62){const o=n.containerState;return o.open||(t.enter("blockQuote",{_container:!0}),o.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(a),t.exit("blockQuoteMarker"),i}return r(a)}function i(a){return ar(a)?(t.enter("blockQuotePrefixWhitespace"),t.consume(a),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(a))}}function xBe(t,e,r){const n=this;return s;function s(a){return ar(a)?pr(t,i,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return t.attempt(Jfe,e,r)(a)}}function vBe(t){t.exit("blockQuote")}const Qfe={name:"characterEscape",tokenize:bBe};function bBe(t,e,r){return n;function n(i){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(i),t.exit("escapeMarker"),s}function s(i){return aBe(i)?(t.enter("characterEscapeValue"),t.consume(i),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):r(i)}}const Zfe={name:"characterReference",tokenize:wBe};function wBe(t,e,r){const n=this;let s=0,i,a;return o;function o(h){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(h),t.exit("characterReferenceMarker"),c}function c(h){return h===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(h),t.exit("characterReferenceMarkerNumeric"),u):(t.enter("characterReferenceValue"),i=31,a=Li,d(h))}function u(h){return h===88||h===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(h),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),i=6,a=iBe,d):(t.enter("characterReferenceValue"),i=7,a=g6,d(h))}function d(h){if(h===59&&s){const f=t.exit("characterReferenceValue");return a===Li&&!$V(n.sliceSerialize(f))?r(h):(t.enter("characterReferenceMarker"),t.consume(h),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return a(h)&&s++<i?(t.consume(h),d):r(h)}}const FY={partial:!0,tokenize:_Be},$Y={concrete:!0,name:"codeFenced",tokenize:SBe};function SBe(t,e,r){const n=this,s={partial:!0,tokenize:S};let i=0,a=0,o;return c;function c(k){return u(k)}function u(k){const E=n.events[n.events.length-1];return i=E&&E[1].type==="linePrefix"?E[2].sliceSerialize(E[1],!0).length:0,o=k,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),d(k)}function d(k){return k===o?(a++,t.consume(k),d):a<3?r(k):(t.exit("codeFencedFenceSequence"),ar(k)?pr(t,h,"whitespace")(k):h(k))}function h(k){return k===null||Nt(k)?(t.exit("codeFencedFence"),n.interrupt?e(k):t.check(FY,g,w)(k)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||Nt(k)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),h(k)):ar(k)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),pr(t,p,"whitespace")(k)):k===96&&k===o?r(k):(t.consume(k),f)}function p(k){return k===null||Nt(k)?h(k):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||Nt(k)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),h(k)):k===96&&k===o?r(k):(t.consume(k),m)}function g(k){return t.attempt(s,w,x)(k)}function x(k){return t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),y}function y(k){return i>0&&ar(k)?pr(t,v,"linePrefix",i+1)(k):v(k)}function v(k){return k===null||Nt(k)?t.check(FY,g,w)(k):(t.enter("codeFlowValue"),b(k))}function b(k){return k===null||Nt(k)?(t.exit("codeFlowValue"),v(k)):(t.consume(k),b)}function w(k){return t.exit("codeFenced"),e(k)}function S(k,E,C){let A=0;return M;function M(U){return k.enter("lineEnding"),k.consume(U),k.exit("lineEnding"),z}function z(U){return k.enter("codeFencedFence"),ar(U)?pr(k,P,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):P(U)}function P(U){return U===o?(k.enter("codeFencedFenceSequence"),W(U)):C(U)}function W(U){return U===o?(A++,k.consume(U),W):A>=a?(k.exit("codeFencedFenceSequence"),ar(U)?pr(k,N,"whitespace")(U):N(U)):C(U)}function N(U){return U===null||Nt(U)?(k.exit("codeFencedFence"),E(U)):C(U)}}}function _Be(t,e,r){const n=this;return s;function s(a){return a===null?r(a):(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),i)}function i(a){return n.parser.lazy[n.now().line]?r(a):e(a)}}const ML={name:"codeIndented",tokenize:kBe},jBe={partial:!0,tokenize:NBe};function kBe(t,e,r){const n=this;return s;function s(u){return t.enter("codeIndented"),pr(t,i,"linePrefix",5)(u)}function i(u){const d=n.events[n.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):r(u)}function a(u){return u===null?c(u):Nt(u)?t.attempt(jBe,a,c)(u):(t.enter("codeFlowValue"),o(u))}function o(u){return u===null||Nt(u)?(t.exit("codeFlowValue"),a(u)):(t.consume(u),o)}function c(u){return t.exit("codeIndented"),e(u)}}function NBe(t,e,r){const n=this;return s;function s(a){return n.parser.lazy[n.now().line]?r(a):Nt(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),s):pr(t,i,"linePrefix",5)(a)}function i(a){const o=n.events[n.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?e(a):Nt(a)?s(a):r(a)}}const EBe={name:"codeText",previous:CBe,resolve:ABe,tokenize:TBe};function ABe(t){let e=t.length-4,r=3,n,s;if((t[r][1].type==="lineEnding"||t[r][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(n=r;++n<e;)if(t[n][1].type==="codeTextData"){t[r][1].type="codeTextPadding",t[e][1].type="codeTextPadding",r+=2,e-=2;break}}for(n=r-1,e++;++n<=e;)s===void 0?n!==e&&t[n][1].type!=="lineEnding"&&(s=n):(n===e||t[n][1].type==="lineEnding")&&(t[s][1].type="codeTextData",n!==s+2&&(t[s][1].end=t[n-1][1].end,t.splice(s+2,n-s-2),e-=n-s-2,n=s+2),s=void 0);return t}function CBe(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function TBe(t,e,r){let n=0,s,i;return a;function a(h){return t.enter("codeText"),t.enter("codeTextSequence"),o(h)}function o(h){return h===96?(t.consume(h),n++,o):(t.exit("codeTextSequence"),c(h))}function c(h){return h===null?r(h):h===32?(t.enter("space"),t.consume(h),t.exit("space"),c):h===96?(i=t.enter("codeTextSequence"),s=0,d(h)):Nt(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),c):(t.enter("codeTextData"),u(h))}function u(h){return h===null||h===32||h===96||Nt(h)?(t.exit("codeTextData"),c(h)):(t.consume(h),u)}function d(h){return h===96?(t.consume(h),s++,d):s===n?(t.exit("codeTextSequence"),t.exit("codeText"),e(h)):(i.type="codeTextData",u(h))}}class PBe{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,r){const n=r??Number.POSITIVE_INFINITY;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,r,n){const s=r||0;this.setCursor(Math.trunc(e));const i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return n&&O1(this.left,n),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),O1(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),O1(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const r=this.left.splice(e,Number.POSITIVE_INFINITY);O1(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);O1(this.left,r.reverse())}}}function O1(t,e){let r=0;if(e.length<1e4)t.push(...e);else for(;r<e.length;)t.push(...e.slice(r,r+1e4)),r+=1e4}function epe(t){const e={};let r=-1,n,s,i,a,o,c,u;const d=new PBe(t);for(;++r<d.length;){for(;r in e;)r=e[r];if(n=d.get(r),r&&n[1].type==="chunkFlow"&&d.get(r-1)[1].type==="listItemPrefix"&&(c=n[1]._tokenizer.events,i=0,i<c.length&&c[i][1].type==="lineEndingBlank"&&(i+=2),i<c.length&&c[i][1].type==="content"))for(;++i<c.length&&c[i][1].type!=="content";)c[i][1].type==="chunkText"&&(c[i][1]._isInFirstContentOfListItem=!0,i++);if(n[0]==="enter")n[1].contentType&&(Object.assign(e,OBe(d,r)),r=e[r],u=!0);else if(n[1]._container){for(i=r,s=void 0;i--;)if(a=d.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(d.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(n[1].end={...d.get(s)[1].start},o=d.slice(s,r),o.unshift(n),d.splice(s,r-s+1,o))}}return To(t,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function OBe(t,e){const r=t.get(e)[1],n=t.get(e)[2];let s=e-1;const i=[];let a=r._tokenizer;a||(a=n.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,c=[],u={};let d,h,f=-1,p=r,m=0,g=0;const x=[g];for(;p;){for(;t.get(++s)[1]!==p;);i.push(s),p._tokenizer||(d=n.sliceStream(p),p.next||d.push(null),h&&a.defineSkip(p.start),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),p._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),h=p,p=p.next}for(p=r;++f<o.length;)o[f][0]==="exit"&&o[f-1][0]==="enter"&&o[f][1].type===o[f-1][1].type&&o[f][1].start.line!==o[f][1].end.line&&(g=f+1,x.push(g),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(a.events=[],p?(p._tokenizer=void 0,p.previous=void 0):x.pop(),f=x.length;f--;){const y=o.slice(x[f],x[f+1]),v=i.pop();c.push([v,v+y.length-1]),t.splice(v,2,y)}for(c.reverse(),f=-1;++f<c.length;)u[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return u}const IBe={resolve:MBe,tokenize:DBe},RBe={partial:!0,tokenize:LBe};function MBe(t){return epe(t),t}function DBe(t,e){let r;return n;function n(o){return t.enter("content"),r=t.enter("chunkContent",{contentType:"content"}),s(o)}function s(o){return o===null?i(o):Nt(o)?t.check(RBe,a,i)(o):(t.consume(o),s)}function i(o){return t.exit("chunkContent"),t.exit("content"),e(o)}function a(o){return t.consume(o),t.exit("chunkContent"),r.next=t.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,s}}function LBe(t,e,r){const n=this;return s;function s(a){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),pr(t,i,"linePrefix")}function i(a){if(a===null||Nt(a))return r(a);const o=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?e(a):t.interrupt(n.parser.constructs.flow,r,e)(a)}}function tpe(t,e,r,n,s,i,a,o,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return h;function h(y){return y===60?(t.enter(n),t.enter(s),t.enter(i),t.consume(y),t.exit(i),f):y===null||y===32||y===41||iP(y)?r(y):(t.enter(n),t.enter(a),t.enter(o),t.enter("chunkString",{contentType:"string"}),g(y))}function f(y){return y===62?(t.enter(i),t.consume(y),t.exit(i),t.exit(s),t.exit(n),e):(t.enter(o),t.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(t.exit("chunkString"),t.exit(o),f(y)):y===null||y===60||Nt(y)?r(y):(t.consume(y),y===92?m:p)}function m(y){return y===60||y===62||y===92?(t.consume(y),p):p(y)}function g(y){return!d&&(y===null||y===41||Kr(y))?(t.exit("chunkString"),t.exit(o),t.exit(a),t.exit(n),e(y)):d<u&&y===40?(t.consume(y),d++,g):y===41?(t.consume(y),d--,g):y===null||y===32||y===40||iP(y)?r(y):(t.consume(y),y===92?x:g)}function x(y){return y===40||y===41||y===92?(t.consume(y),g):g(y)}}function rpe(t,e,r,n,s,i){const a=this;let o=0,c;return u;function u(p){return t.enter(n),t.enter(s),t.consume(p),t.exit(s),t.enter(i),d}function d(p){return o>999||p===null||p===91||p===93&&!c||p===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?r(p):p===93?(t.exit(i),t.enter(s),t.consume(p),t.exit(s),t.exit(n),e):Nt(p)?(t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),d):(t.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||Nt(p)||o++>999?(t.exit("chunkString"),d(p)):(t.consume(p),c||(c=!ar(p)),p===92?f:h)}function f(p){return p===91||p===92||p===93?(t.consume(p),o++,h):h(p)}}function npe(t,e,r,n,s,i){let a;return o;function o(f){return f===34||f===39||f===40?(t.enter(n),t.enter(s),t.consume(f),t.exit(s),a=f===40?41:f,c):r(f)}function c(f){return f===a?(t.enter(s),t.consume(f),t.exit(s),t.exit(n),e):(t.enter(i),u(f))}function u(f){return f===a?(t.exit(i),c(a)):f===null?r(f):Nt(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),pr(t,u,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===a||f===null||Nt(f)?(t.exit("chunkString"),u(f)):(t.consume(f),f===92?h:d)}function h(f){return f===a||f===92?(t.consume(f),d):d(f)}}function m_(t,e){let r;return n;function n(s){return Nt(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),r=!0,n):ar(s)?pr(t,n,r?"linePrefix":"lineSuffix")(s):e(s)}}const FBe={name:"definition",tokenize:BBe},$Be={partial:!0,tokenize:zBe};function BBe(t,e,r){const n=this;let s;return i;function i(p){return t.enter("definition"),a(p)}function a(p){return rpe.call(n,t,o,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function o(p){return s=fc(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),p===58?(t.enter("definitionMarker"),t.consume(p),t.exit("definitionMarker"),c):r(p)}function c(p){return Kr(p)?m_(t,u)(p):u(p)}function u(p){return tpe(t,d,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return t.attempt($Be,h,h)(p)}function h(p){return ar(p)?pr(t,f,"whitespace")(p):f(p)}function f(p){return p===null||Nt(p)?(t.exit("definition"),n.parser.defined.push(s),e(p)):r(p)}}function zBe(t,e,r){return n;function n(o){return Kr(o)?m_(t,s)(o):r(o)}function s(o){return npe(t,i,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function i(o){return ar(o)?pr(t,a,"whitespace")(o):a(o)}function a(o){return o===null||Nt(o)?e(o):r(o)}}const UBe={name:"hardBreakEscape",tokenize:HBe};function HBe(t,e,r){return n;function n(i){return t.enter("hardBreakEscape"),t.consume(i),s}function s(i){return Nt(i)?(t.exit("hardBreakEscape"),e(i)):r(i)}}const VBe={name:"headingAtx",resolve:WBe,tokenize:qBe};function WBe(t,e){let r=t.length-2,n=3,s,i;return t[n][1].type==="whitespace"&&(n+=2),r-2>n&&t[r][1].type==="whitespace"&&(r-=2),t[r][1].type==="atxHeadingSequence"&&(n===r-1||r-4>n&&t[r-2][1].type==="whitespace")&&(r-=n+1===r?2:4),r>n&&(s={type:"atxHeadingText",start:t[n][1].start,end:t[r][1].end},i={type:"chunkText",start:t[n][1].start,end:t[r][1].end,contentType:"text"},To(t,n,r-n+1,[["enter",s,e],["enter",i,e],["exit",i,e],["exit",s,e]])),t}function qBe(t,e,r){let n=0;return s;function s(d){return t.enter("atxHeading"),i(d)}function i(d){return t.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&n++<6?(t.consume(d),a):d===null||Kr(d)?(t.exit("atxHeadingSequence"),o(d)):r(d)}function o(d){return d===35?(t.enter("atxHeadingSequence"),c(d)):d===null||Nt(d)?(t.exit("atxHeading"),e(d)):ar(d)?pr(t,o,"whitespace")(d):(t.enter("atxHeadingText"),u(d))}function c(d){return d===35?(t.consume(d),c):(t.exit("atxHeadingSequence"),o(d))}function u(d){return d===null||d===35||Kr(d)?(t.exit("atxHeadingText"),o(d)):(t.consume(d),u)}}const GBe=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],BY=["pre","script","style","textarea"],KBe={concrete:!0,name:"htmlFlow",resolveTo:JBe,tokenize:QBe},YBe={partial:!0,tokenize:e8e},XBe={partial:!0,tokenize:ZBe};function JBe(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function QBe(t,e,r){const n=this;let s,i,a,o,c;return u;function u(V){return d(V)}function d(V){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(V),h}function h(V){return V===33?(t.consume(V),f):V===47?(t.consume(V),i=!0,g):V===63?(t.consume(V),s=3,n.interrupt?e:B):da(V)?(t.consume(V),a=String.fromCharCode(V),x):r(V)}function f(V){return V===45?(t.consume(V),s=2,p):V===91?(t.consume(V),s=5,o=0,m):da(V)?(t.consume(V),s=4,n.interrupt?e:B):r(V)}function p(V){return V===45?(t.consume(V),n.interrupt?e:B):r(V)}function m(V){const Y="CDATA[";return V===Y.charCodeAt(o++)?(t.consume(V),o===Y.length?n.interrupt?e:P:m):r(V)}function g(V){return da(V)?(t.consume(V),a=String.fromCharCode(V),x):r(V)}function x(V){if(V===null||V===47||V===62||Kr(V)){const Y=V===47,ie=a.toLowerCase();return!Y&&!i&&BY.includes(ie)?(s=1,n.interrupt?e(V):P(V)):GBe.includes(a.toLowerCase())?(s=6,Y?(t.consume(V),y):n.interrupt?e(V):P(V)):(s=7,n.interrupt&&!n.parser.lazy[n.now().line]?r(V):i?v(V):b(V))}return V===45||Li(V)?(t.consume(V),a+=String.fromCharCode(V),x):r(V)}function y(V){return V===62?(t.consume(V),n.interrupt?e:P):r(V)}function v(V){return ar(V)?(t.consume(V),v):M(V)}function b(V){return V===47?(t.consume(V),M):V===58||V===95||da(V)?(t.consume(V),w):ar(V)?(t.consume(V),b):M(V)}function w(V){return V===45||V===46||V===58||V===95||Li(V)?(t.consume(V),w):S(V)}function S(V){return V===61?(t.consume(V),k):ar(V)?(t.consume(V),S):b(V)}function k(V){return V===null||V===60||V===61||V===62||V===96?r(V):V===34||V===39?(t.consume(V),c=V,E):ar(V)?(t.consume(V),k):C(V)}function E(V){return V===c?(t.consume(V),c=null,A):V===null||Nt(V)?r(V):(t.consume(V),E)}function C(V){return V===null||V===34||V===39||V===47||V===60||V===61||V===62||V===96||Kr(V)?S(V):(t.consume(V),C)}function A(V){return V===47||V===62||ar(V)?b(V):r(V)}function M(V){return V===62?(t.consume(V),z):r(V)}function z(V){return V===null||Nt(V)?P(V):ar(V)?(t.consume(V),z):r(V)}function P(V){return V===45&&s===2?(t.consume(V),K):V===60&&s===1?(t.consume(V),G):V===62&&s===4?(t.consume(V),L):V===63&&s===3?(t.consume(V),B):V===93&&s===5?(t.consume(V),H):Nt(V)&&(s===6||s===7)?(t.exit("htmlFlowData"),t.check(YBe,F,W)(V)):V===null||Nt(V)?(t.exit("htmlFlowData"),W(V)):(t.consume(V),P)}function W(V){return t.check(XBe,N,F)(V)}function N(V){return t.enter("lineEnding"),t.consume(V),t.exit("lineEnding"),U}function U(V){return V===null||Nt(V)?W(V):(t.enter("htmlFlowData"),P(V))}function K(V){return V===45?(t.consume(V),B):P(V)}function G(V){return V===47?(t.consume(V),a="",X):P(V)}function X(V){if(V===62){const Y=a.toLowerCase();return BY.includes(Y)?(t.consume(V),L):P(V)}return da(V)&&a.length<8?(t.consume(V),a+=String.fromCharCode(V),X):P(V)}function H(V){return V===93?(t.consume(V),B):P(V)}function B(V){return V===62?(t.consume(V),L):V===45&&s===2?(t.consume(V),B):P(V)}function L(V){return V===null||Nt(V)?(t.exit("htmlFlowData"),F(V)):(t.consume(V),L)}function F(V){return t.exit("htmlFlow"),e(V)}}function ZBe(t,e,r){const n=this;return s;function s(a){return Nt(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),i):r(a)}function i(a){return n.parser.lazy[n.now().line]?r(a):e(a)}}function e8e(t,e,r){return n;function n(s){return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),t.attempt(SE,e,r)}}const t8e={name:"htmlText",tokenize:r8e};function r8e(t,e,r){const n=this;let s,i,a;return o;function o(B){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(B),c}function c(B){return B===33?(t.consume(B),u):B===47?(t.consume(B),S):B===63?(t.consume(B),b):da(B)?(t.consume(B),C):r(B)}function u(B){return B===45?(t.consume(B),d):B===91?(t.consume(B),i=0,m):da(B)?(t.consume(B),v):r(B)}function d(B){return B===45?(t.consume(B),p):r(B)}function h(B){return B===null?r(B):B===45?(t.consume(B),f):Nt(B)?(a=h,G(B)):(t.consume(B),h)}function f(B){return B===45?(t.consume(B),p):h(B)}function p(B){return B===62?K(B):B===45?f(B):h(B)}function m(B){const L="CDATA[";return B===L.charCodeAt(i++)?(t.consume(B),i===L.length?g:m):r(B)}function g(B){return B===null?r(B):B===93?(t.consume(B),x):Nt(B)?(a=g,G(B)):(t.consume(B),g)}function x(B){return B===93?(t.consume(B),y):g(B)}function y(B){return B===62?K(B):B===93?(t.consume(B),y):g(B)}function v(B){return B===null||B===62?K(B):Nt(B)?(a=v,G(B)):(t.consume(B),v)}function b(B){return B===null?r(B):B===63?(t.consume(B),w):Nt(B)?(a=b,G(B)):(t.consume(B),b)}function w(B){return B===62?K(B):b(B)}function S(B){return da(B)?(t.consume(B),k):r(B)}function k(B){return B===45||Li(B)?(t.consume(B),k):E(B)}function E(B){return Nt(B)?(a=E,G(B)):ar(B)?(t.consume(B),E):K(B)}function C(B){return B===45||Li(B)?(t.consume(B),C):B===47||B===62||Kr(B)?A(B):r(B)}function A(B){return B===47?(t.consume(B),K):B===58||B===95||da(B)?(t.consume(B),M):Nt(B)?(a=A,G(B)):ar(B)?(t.consume(B),A):K(B)}function M(B){return B===45||B===46||B===58||B===95||Li(B)?(t.consume(B),M):z(B)}function z(B){return B===61?(t.consume(B),P):Nt(B)?(a=z,G(B)):ar(B)?(t.consume(B),z):A(B)}function P(B){return B===null||B===60||B===61||B===62||B===96?r(B):B===34||B===39?(t.consume(B),s=B,W):Nt(B)?(a=P,G(B)):ar(B)?(t.consume(B),P):(t.consume(B),N)}function W(B){return B===s?(t.consume(B),s=void 0,U):B===null?r(B):Nt(B)?(a=W,G(B)):(t.consume(B),W)}function N(B){return B===null||B===34||B===39||B===60||B===61||B===96?r(B):B===47||B===62||Kr(B)?A(B):(t.consume(B),N)}function U(B){return B===47||B===62||Kr(B)?A(B):r(B)}function K(B){return B===62?(t.consume(B),t.exit("htmlTextData"),t.exit("htmlText"),e):r(B)}function G(B){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(B),t.exit("lineEnding"),X}function X(B){return ar(B)?pr(t,H,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):H(B)}function H(B){return t.enter("htmlTextData"),a(B)}}const BV={name:"labelEnd",resolveAll:a8e,resolveTo:o8e,tokenize:l8e},n8e={tokenize:c8e},s8e={tokenize:u8e},i8e={tokenize:d8e};function a8e(t){let e=-1;const r=[];for(;++e<t.length;){const n=t[e][1];if(r.push(t[e]),n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd"){const s=n.type==="labelImage"?4:2;n.type="data",e+=s}}return t.length!==r.length&&To(t,0,t.length,r),t}function o8e(t,e){let r=t.length,n=0,s,i,a,o;for(;r--;)if(s=t[r][1],i){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;t[r][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(t[r][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(i=r,s.type!=="labelLink")){n=2;break}}else s.type==="labelEnd"&&(a=r);const c={type:t[i][1].type==="labelLink"?"link":"image",start:{...t[i][1].start},end:{...t[t.length-1][1].end}},u={type:"label",start:{...t[i][1].start},end:{...t[a][1].end}},d={type:"labelText",start:{...t[i+n+2][1].end},end:{...t[a-2][1].start}};return o=[["enter",c,e],["enter",u,e]],o=al(o,t.slice(i+1,i+n+3)),o=al(o,[["enter",d,e]]),o=al(o,DR(e.parser.constructs.insideSpan.null,t.slice(i+n+4,a-3),e)),o=al(o,[["exit",d,e],t[a-2],t[a-1],["exit",u,e]]),o=al(o,t.slice(a+1)),o=al(o,[["exit",c,e]]),To(t,i,t.length,o),t}function l8e(t,e,r){const n=this;let s=n.events.length,i,a;for(;s--;)if((n.events[s][1].type==="labelImage"||n.events[s][1].type==="labelLink")&&!n.events[s][1]._balanced){i=n.events[s][1];break}return o;function o(f){return i?i._inactive?h(f):(a=n.parser.defined.includes(fc(n.sliceSerialize({start:i.end,end:n.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(f),t.exit("labelMarker"),t.exit("labelEnd"),c):r(f)}function c(f){return f===40?t.attempt(n8e,d,a?d:h)(f):f===91?t.attempt(s8e,d,a?u:h)(f):a?d(f):h(f)}function u(f){return t.attempt(i8e,d,h)(f)}function d(f){return e(f)}function h(f){return i._balanced=!0,r(f)}}function c8e(t,e,r){return n;function n(h){return t.enter("resource"),t.enter("resourceMarker"),t.consume(h),t.exit("resourceMarker"),s}function s(h){return Kr(h)?m_(t,i)(h):i(h)}function i(h){return h===41?d(h):tpe(t,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function a(h){return Kr(h)?m_(t,c)(h):d(h)}function o(h){return r(h)}function c(h){return h===34||h===39||h===40?npe(t,u,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):d(h)}function u(h){return Kr(h)?m_(t,d)(h):d(h)}function d(h){return h===41?(t.enter("resourceMarker"),t.consume(h),t.exit("resourceMarker"),t.exit("resource"),e):r(h)}}function u8e(t,e,r){const n=this;return s;function s(o){return rpe.call(n,t,i,a,"reference","referenceMarker","referenceString")(o)}function i(o){return n.parser.defined.includes(fc(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?e(o):r(o)}function a(o){return r(o)}}function d8e(t,e,r){return n;function n(i){return t.enter("reference"),t.enter("referenceMarker"),t.consume(i),t.exit("referenceMarker"),s}function s(i){return i===93?(t.enter("referenceMarker"),t.consume(i),t.exit("referenceMarker"),t.exit("reference"),e):r(i)}}const h8e={name:"labelStartImage",resolveAll:BV.resolveAll,tokenize:f8e};function f8e(t,e,r){const n=this;return s;function s(o){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(o),t.exit("labelImageMarker"),i}function i(o){return o===91?(t.enter("labelMarker"),t.consume(o),t.exit("labelMarker"),t.exit("labelImage"),a):r(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(o):e(o)}}const p8e={name:"labelStartLink",resolveAll:BV.resolveAll,tokenize:m8e};function m8e(t,e,r){const n=this;return s;function s(a){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelLink"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(a):e(a)}}const DL={name:"lineEnding",tokenize:g8e};function g8e(t,e){return r;function r(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),pr(t,e,"linePrefix")}}const pT={name:"thematicBreak",tokenize:y8e};function y8e(t,e,r){let n=0,s;return i;function i(u){return t.enter("thematicBreak"),a(u)}function a(u){return s=u,o(u)}function o(u){return u===s?(t.enter("thematicBreakSequence"),c(u)):n>=3&&(u===null||Nt(u))?(t.exit("thematicBreak"),e(u)):r(u)}function c(u){return u===s?(t.consume(u),n++,c):(t.exit("thematicBreakSequence"),ar(u)?pr(t,o,"whitespace")(u):o(u))}}const Na={continuation:{tokenize:w8e},exit:_8e,name:"list",tokenize:b8e},x8e={partial:!0,tokenize:j8e},v8e={partial:!0,tokenize:S8e};function b8e(t,e,r){const n=this,s=n.events[n.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return o;function o(p){const m=n.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!n.containerState.marker||p===n.containerState.marker:g6(p)){if(n.containerState.type||(n.containerState.type=m,t.enter(m,{_container:!0})),m==="listUnordered")return t.enter("listItemPrefix"),p===42||p===45?t.check(pT,r,u)(p):u(p);if(!n.interrupt||p===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),c(p)}return r(p)}function c(p){return g6(p)&&++a<10?(t.consume(p),c):(!n.interrupt||a<2)&&(n.containerState.marker?p===n.containerState.marker:p===41||p===46)?(t.exit("listItemValue"),u(p)):r(p)}function u(p){return t.enter("listItemMarker"),t.consume(p),t.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||p,t.check(SE,n.interrupt?r:d,t.attempt(x8e,f,h))}function d(p){return n.containerState.initialBlankLine=!0,i++,f(p)}function h(p){return ar(p)?(t.enter("listItemPrefixWhitespace"),t.consume(p),t.exit("listItemPrefixWhitespace"),f):r(p)}function f(p){return n.containerState.size=i+n.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(p)}}function w8e(t,e,r){const n=this;return n.containerState._closeFlow=void 0,t.check(SE,s,i);function s(o){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,pr(t,e,"listItemIndent",n.containerState.size+1)(o)}function i(o){return n.containerState.furtherBlankLines||!ar(o)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,a(o)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,t.attempt(v8e,e,a)(o))}function a(o){return n.containerState._closeFlow=!0,n.interrupt=void 0,pr(t,t.attempt(Na,e,r),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function S8e(t,e,r){const n=this;return pr(t,s,"listItemIndent",n.containerState.size+1);function s(i){const a=n.events[n.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===n.containerState.size?e(i):r(i)}}function _8e(t){t.exit(this.containerState.type)}function j8e(t,e,r){const n=this;return pr(t,s,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const a=n.events[n.events.length-1];return!ar(i)&&a&&a[1].type==="listItemPrefixWhitespace"?e(i):r(i)}}const zY={name:"setextUnderline",resolveTo:k8e,tokenize:N8e};function k8e(t,e){let r=t.length,n,s,i;for(;r--;)if(t[r][0]==="enter"){if(t[r][1].type==="content"){n=r;break}t[r][1].type==="paragraph"&&(s=r)}else t[r][1].type==="content"&&t.splice(r,1),!i&&t[r][1].type==="definition"&&(i=r);const a={type:"setextHeading",start:{...t[n][1].start},end:{...t[t.length-1][1].end}};return t[s][1].type="setextHeadingText",i?(t.splice(s,0,["enter",a,e]),t.splice(i+1,0,["exit",t[n][1],e]),t[n][1].end={...t[i][1].end}):t[n][1]=a,t.push(["exit",a,e]),t}function N8e(t,e,r){const n=this;let s;return i;function i(u){let d=n.events.length,h;for(;d--;)if(n.events[d][1].type!=="lineEnding"&&n.events[d][1].type!=="linePrefix"&&n.events[d][1].type!=="content"){h=n.events[d][1].type==="paragraph";break}return!n.parser.lazy[n.now().line]&&(n.interrupt||h)?(t.enter("setextHeadingLine"),s=u,a(u)):r(u)}function a(u){return t.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===s?(t.consume(u),o):(t.exit("setextHeadingLineSequence"),ar(u)?pr(t,c,"lineSuffix")(u):c(u))}function c(u){return u===null||Nt(u)?(t.exit("setextHeadingLine"),e(u)):r(u)}}const E8e={tokenize:A8e};function A8e(t){const e=this,r=t.attempt(SE,n,t.attempt(this.parser.constructs.flowInitial,s,pr(t,t.attempt(this.parser.constructs.flow,s,t.attempt(IBe,s)),"linePrefix")));return r;function n(i){if(i===null){t.consume(i);return}return t.enter("lineEndingBlank"),t.consume(i),t.exit("lineEndingBlank"),e.currentConstruct=void 0,r}function s(i){if(i===null){t.consume(i);return}return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),e.currentConstruct=void 0,r}}const C8e={resolveAll:ipe()},T8e=spe("string"),P8e=spe("text");function spe(t){return{resolveAll:ipe(t==="text"?O8e:void 0),tokenize:e};function e(r){const n=this,s=this.parser.constructs[t],i=r.attempt(s,a,o);return a;function a(d){return u(d)?i(d):o(d)}function o(d){if(d===null){r.consume(d);return}return r.enter("data"),r.consume(d),c}function c(d){return u(d)?(r.exit("data"),i(d)):(r.consume(d),c)}function u(d){if(d===null)return!0;const h=s[d];let f=-1;if(h)for(;++f<h.length;){const p=h[f];if(!p.previous||p.previous.call(n,n.previous))return!0}return!1}}}function ipe(t){return e;function e(r,n){let s=-1,i;for(;++s<=r.length;)i===void 0?r[s]&&r[s][1].type==="data"&&(i=s,s++):(!r[s]||r[s][1].type!=="data")&&(s!==i+2&&(r[i][1].end=r[s-1][1].end,r.splice(i+2,s-i-2),s=i+2),i=void 0);return t?t(r,n):r}}function O8e(t,e){let r=0;for(;++r<=t.length;)if((r===t.length||t[r][1].type==="lineEnding")&&t[r-1][1].type==="data"){const n=t[r-1][1],s=e.sliceStream(n);let i=s.length,a=-1,o=0,c;for(;i--;){const u=s[i];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(u===-2)c=!0,o++;else if(u!==-1){i++;break}}if(e._contentTypeTextTrailing&&r===t.length&&(o=0),o){const u={type:r===t.length||c||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:n.start._bufferIndex+a,_index:n.start._index+i,line:n.end.line,column:n.end.column-o,offset:n.end.offset-o},end:{...n.end}};n.end={...u.start},n.start.offset===n.end.offset?Object.assign(n,u):(t.splice(r,0,["enter",u,e],["exit",u,e]),r+=2)}r++}return t}const I8e={42:Na,43:Na,45:Na,48:Na,49:Na,50:Na,51:Na,52:Na,53:Na,54:Na,55:Na,56:Na,57:Na,62:Jfe},R8e={91:FBe},M8e={[-2]:ML,[-1]:ML,32:ML},D8e={35:VBe,42:pT,45:[zY,pT],60:KBe,61:zY,95:pT,96:$Y,126:$Y},L8e={38:Zfe,92:Qfe},F8e={[-5]:DL,[-4]:DL,[-3]:DL,33:h8e,38:Zfe,42:y6,60:[pBe,t8e],91:p8e,92:[UBe,Qfe],93:BV,95:y6,96:EBe},$8e={null:[y6,C8e]},B8e={null:[42,95]},z8e={null:[]},U8e=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:B8e,contentInitial:R8e,disable:z8e,document:I8e,flow:D8e,flowInitial:M8e,insideSpan:$8e,string:L8e,text:F8e},Symbol.toStringTag,{value:"Module"}));function H8e(t,e,r){let n={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const s={},i=[];let a=[],o=[];const c={attempt:E(S),check:E(k),consume:v,enter:b,exit:w,interrupt:E(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:g,events:[],now:m,parser:t,previous:null,sliceSerialize:f,sliceStream:p,write:h};let d=e.tokenize.call(u,c);return e.resolveAll&&i.push(e),u;function h(z){return a=al(a,z),x(),a[a.length-1]!==null?[]:(C(e,0),u.events=DR(i,u.events,u),u.events)}function f(z,P){return W8e(p(z),P)}function p(z){return V8e(a,z)}function m(){const{_bufferIndex:z,_index:P,line:W,column:N,offset:U}=n;return{_bufferIndex:z,_index:P,line:W,column:N,offset:U}}function g(z){s[z.line]=z.column,M()}function x(){let z;for(;n._index<a.length;){const P=a[n._index];if(typeof P=="string")for(z=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===z&&n._bufferIndex<P.length;)y(P.charCodeAt(n._bufferIndex));else y(P)}}function y(z){d=d(z)}function v(z){Nt(z)?(n.line++,n.column=1,n.offset+=z===-3?2:1,M()):z!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===a[n._index].length&&(n._bufferIndex=-1,n._index++)),u.previous=z}function b(z,P){const W=P||{};return W.type=z,W.start=m(),u.events.push(["enter",W,u]),o.push(W),W}function w(z){const P=o.pop();return P.end=m(),u.events.push(["exit",P,u]),P}function S(z,P){C(z,P.from)}function k(z,P){P.restore()}function E(z,P){return W;function W(N,U,K){let G,X,H,B;return Array.isArray(N)?F(N):"tokenize"in N?F([N]):L(N);function L(Q){return D;function D(R){const J=R!==null&&Q[R],Z=R!==null&&Q.null,ee=[...Array.isArray(J)?J:J?[J]:[],...Array.isArray(Z)?Z:Z?[Z]:[]];return F(ee)(R)}}function F(Q){return G=Q,X=0,Q.length===0?K:V(Q[X])}function V(Q){return D;function D(R){return B=A(),H=Q,Q.partial||(u.currentConstruct=Q),Q.name&&u.parser.constructs.disable.null.includes(Q.name)?ie():Q.tokenize.call(P?Object.assign(Object.create(u),P):u,c,Y,ie)(R)}}function Y(Q){return z(H,B),U}function ie(Q){return B.restore(),++X<G.length?V(G[X]):K}}}function C(z,P){z.resolveAll&&!i.includes(z)&&i.push(z),z.resolve&&To(u.events,P,u.events.length-P,z.resolve(u.events.slice(P),u)),z.resolveTo&&(u.events=z.resolveTo(u.events,u))}function A(){const z=m(),P=u.previous,W=u.currentConstruct,N=u.events.length,U=Array.from(o);return{from:N,restore:K};function K(){n=z,u.previous=P,u.currentConstruct=W,u.events.length=N,o=U,M()}}function M(){n.line in s&&n.column<2&&(n.column=s[n.line],n.offset+=s[n.line]-1)}}function V8e(t,e){const r=e.start._index,n=e.start._bufferIndex,s=e.end._index,i=e.end._bufferIndex;let a;if(r===s)a=[t[r].slice(n,i)];else{if(a=t.slice(r,s),n>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(n):a.shift()}i>0&&a.push(t[s].slice(0,i))}return a}function W8e(t,e){let r=-1;const n=[];let s;for(;++r<t.length;){const i=t[r];let a;if(typeof i=="string")a=i;else switch(i){case-5:{a="\r";break}case-4:{a=`
`;break}case-3:{a=`\r
`;break}case-2:{a=e?" ":" ";break}case-1:{if(!e&&s)continue;a=" ";break}default:a=String.fromCharCode(i)}s=i===-2,n.push(a)}return n.join("")}function q8e(t){const n={constructs:Yfe([U8e,...(t||{}).extensions||[]]),content:s(oBe),defined:[],document:s(cBe),flow:s(E8e),lazy:{},string:s(T8e),text:s(P8e)};return n;function s(i){return a;function a(o){return H8e(n,i,o)}}}function G8e(t){for(;!epe(t););return t}const UY=/[\0\t\n\r]/g;function K8e(){let t=1,e="",r=!0,n;return s;function s(i,a,o){const c=[];let u,d,h,f,p;for(i=e+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),h=0,e="",r&&(i.charCodeAt(0)===65279&&h++,r=void 0);h<i.length;){if(UY.lastIndex=h,u=UY.exec(i),f=u&&u.index!==void 0?u.index:i.length,p=i.charCodeAt(f),!u){e=i.slice(h);break}if(p===10&&h===f&&n)c.push(-3),n=void 0;else switch(n&&(c.push(-5),n=void 0),h<f&&(c.push(i.slice(h,f)),t+=f-h),p){case 0:{c.push(65533),t++;break}case 9:{for(d=Math.ceil(t/4)*4,c.push(-2);t++<d;)c.push(-1);break}case 10:{c.push(-4),t=1;break}default:n=!0,t=1}h=f+1}return o&&(n&&c.push(-5),e&&c.push(e),c.push(null)),c}}const Y8e=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function X8e(t){return t.replace(Y8e,J8e)}function J8e(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){const s=r.charCodeAt(1),i=s===120||s===88;return Xfe(r.slice(i?2:1),i?16:10)}return $V(r)||t}const ape={}.hasOwnProperty;function Q8e(t,e,r){return typeof e!="string"&&(r=e,e=void 0),Z8e(r)(G8e(q8e(r).document().write(K8e()(t,e,!0))))}function Z8e(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i($),autolinkProtocol:A,autolinkEmail:A,atxHeading:i(ae),blockQuote:i(Z),characterEscape:A,characterReference:A,codeFenced:i(ee),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(ee,a),codeText:i(re,a),codeTextData:A,data:A,codeFlowValue:A,definition:i(he),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(O),hardBreakEscape:i(q),hardBreakTrailing:i(q),htmlFlow:i(I,a),htmlFlowData:A,htmlText:i(I,a),htmlTextData:A,image:i(T),label:a,link:i($),listItem:i(ue),listItemValue:f,listOrdered:i(se,h),listUnordered:i(se),paragraph:i(ne),reference:V,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(ae),strong:i(me),thematicBreak:i(xe)},exit:{atxHeading:c(),atxHeadingSequence:S,autolink:c(),autolinkEmail:J,autolinkProtocol:R,blockQuote:c(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:Q,characterReference:D,codeFenced:c(x),codeFencedFence:g,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:M,codeIndented:c(y),codeText:c(U),codeTextData:M,data:M,definition:c(),definitionDestinationString:w,definitionLabelString:v,definitionTitleString:b,emphasis:c(),hardBreakEscape:c(P),hardBreakTrailing:c(P),htmlFlow:c(W),htmlFlowData:M,htmlText:c(N),htmlTextData:M,image:c(G),label:H,labelText:X,lineEnding:z,link:c(K),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:Y,resourceDestinationString:B,resourceTitleString:L,resource:F,setextHeading:c(C),setextHeadingLineSequence:E,setextHeadingText:k,strong:c(),thematicBreak:c()}};ope(e,(t||{}).mdastExtensions||[]);const r={};return n;function n(oe){let de={type:"root",children:[]};const ge={stack:[de],tokenStack:[],config:e,enter:o,exit:u,buffer:a,resume:d,data:r},Se=[];let ke=-1;for(;++ke<oe.length;)if(oe[ke][1].type==="listOrdered"||oe[ke][1].type==="listUnordered")if(oe[ke][0]==="enter")Se.push(ke);else{const Ne=Se.pop();ke=s(oe,Ne,ke)}for(ke=-1;++ke<oe.length;){const Ne=e[oe[ke][0]];ape.call(Ne,oe[ke][1].type)&&Ne[oe[ke][1].type].call(Object.assign({sliceSerialize:oe[ke][2].sliceSerialize},ge),oe[ke][1])}if(ge.tokenStack.length>0){const Ne=ge.tokenStack[ge.tokenStack.length-1];(Ne[1]||HY).call(ge,void 0,Ne[0])}for(de.position={start:Hh(oe.length>0?oe[0][1].start:{line:1,column:1,offset:0}),end:Hh(oe.length>0?oe[oe.length-2][1].end:{line:1,column:1,offset:0})},ke=-1;++ke<e.transforms.length;)de=e.transforms[ke](de)||de;return de}function s(oe,de,ge){let Se=de-1,ke=-1,Ne=!1,qe,Ae,fe,Te;for(;++Se<=ge;){const Pe=oe[Se];switch(Pe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Pe[0]==="enter"?ke++:ke--,Te=void 0;break}case"lineEndingBlank":{Pe[0]==="enter"&&(qe&&!Te&&!ke&&!fe&&(fe=Se),Te=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Te=void 0}if(!ke&&Pe[0]==="enter"&&Pe[1].type==="listItemPrefix"||ke===-1&&Pe[0]==="exit"&&(Pe[1].type==="listUnordered"||Pe[1].type==="listOrdered")){if(qe){let tt=Se;for(Ae=void 0;tt--;){const wt=oe[tt];if(wt[1].type==="lineEnding"||wt[1].type==="lineEndingBlank"){if(wt[0]==="exit")continue;Ae&&(oe[Ae][1].type="lineEndingBlank",Ne=!0),wt[1].type="lineEnding",Ae=tt}else if(!(wt[1].type==="linePrefix"||wt[1].type==="blockQuotePrefix"||wt[1].type==="blockQuotePrefixWhitespace"||wt[1].type==="blockQuoteMarker"||wt[1].type==="listItemIndent"))break}fe&&(!Ae||fe<Ae)&&(qe._spread=!0),qe.end=Object.assign({},Ae?oe[Ae][1].start:Pe[1].end),oe.splice(Ae||Se,0,["exit",qe,Pe[2]]),Se++,ge++}if(Pe[1].type==="listItemPrefix"){const tt={type:"listItem",_spread:!1,start:Object.assign({},Pe[1].start),end:void 0};qe=tt,oe.splice(Se,0,["enter",tt,Pe[2]]),Se++,ge++,fe=void 0,Te=!0}}}return oe[de][1]._spread=Ne,ge}function i(oe,de){return ge;function ge(Se){o.call(this,oe(Se),Se),de&&de.call(this,Se)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(oe,de,ge){this.stack[this.stack.length-1].children.push(oe),this.stack.push(oe),this.tokenStack.push([de,ge||void 0]),oe.position={start:Hh(de.start),end:void 0}}function c(oe){return de;function de(ge){oe&&oe.call(this,ge),u.call(this,ge)}}function u(oe,de){const ge=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==oe.type&&(de?de.call(this,oe,Se[0]):(Se[1]||HY).call(this,oe,Se[0]));else throw new Error("Cannot close `"+oe.type+"` ("+p_({start:oe.start,end:oe.end})+"): it’s not open");ge.position.end=Hh(oe.end)}function d(){return FV(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function f(oe){if(this.data.expectingFirstListItemValue){const de=this.stack[this.stack.length-2];de.start=Number.parseInt(this.sliceSerialize(oe),10),this.data.expectingFirstListItemValue=void 0}}function p(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.lang=oe}function m(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.meta=oe}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.value=oe.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.value=oe.replace(/(\r?\n|\r)$/g,"")}function v(oe){const de=this.resume(),ge=this.stack[this.stack.length-1];ge.label=de,ge.identifier=fc(this.sliceSerialize(oe)).toLowerCase()}function b(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.title=oe}function w(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.url=oe}function S(oe){const de=this.stack[this.stack.length-1];if(!de.depth){const ge=this.sliceSerialize(oe).length;de.depth=ge}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function E(oe){const de=this.stack[this.stack.length-1];de.depth=this.sliceSerialize(oe).codePointAt(0)===61?1:2}function C(){this.data.setextHeadingSlurpLineEnding=void 0}function A(oe){const ge=this.stack[this.stack.length-1].children;let Se=ge[ge.length-1];(!Se||Se.type!=="text")&&(Se=ve(),Se.position={start:Hh(oe.start),end:void 0},ge.push(Se)),this.stack.push(Se)}function M(oe){const de=this.stack.pop();de.value+=this.sliceSerialize(oe),de.position.end=Hh(oe.end)}function z(oe){const de=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=de.children[de.children.length-1];ge.position.end=Hh(oe.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(de.type)&&(A.call(this,oe),M.call(this,oe))}function P(){this.data.atHardBreak=!0}function W(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.value=oe}function N(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.value=oe}function U(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.value=oe}function K(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=de,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function G(){const oe=this.stack[this.stack.length-1];if(this.data.inReference){const de=this.data.referenceType||"shortcut";oe.type+="Reference",oe.referenceType=de,delete oe.url,delete oe.title}else delete oe.identifier,delete oe.label;this.data.referenceType=void 0}function X(oe){const de=this.sliceSerialize(oe),ge=this.stack[this.stack.length-2];ge.label=X8e(de),ge.identifier=fc(de).toLowerCase()}function H(){const oe=this.stack[this.stack.length-1],de=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const Se=oe.children;ge.children=Se}else ge.alt=de}function B(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.url=oe}function L(){const oe=this.resume(),de=this.stack[this.stack.length-1];de.title=oe}function F(){this.data.inReference=void 0}function V(){this.data.referenceType="collapsed"}function Y(oe){const de=this.resume(),ge=this.stack[this.stack.length-1];ge.label=de,ge.identifier=fc(this.sliceSerialize(oe)).toLowerCase(),this.data.referenceType="full"}function ie(oe){this.data.characterReferenceType=oe.type}function Q(oe){const de=this.sliceSerialize(oe),ge=this.data.characterReferenceType;let Se;ge?(Se=Xfe(de,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=$V(de);const ke=this.stack[this.stack.length-1];ke.value+=Se}function D(oe){const de=this.stack.pop();de.position.end=Hh(oe.end)}function R(oe){M.call(this,oe);const de=this.stack[this.stack.length-1];de.url=this.sliceSerialize(oe)}function J(oe){M.call(this,oe);const de=this.stack[this.stack.length-1];de.url="mailto:"+this.sliceSerialize(oe)}function Z(){return{type:"blockquote",children:[]}}function ee(){return{type:"code",lang:null,meta:null,value:""}}function re(){return{type:"inlineCode",value:""}}function he(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function O(){return{type:"emphasis",children:[]}}function ae(){return{type:"heading",depth:0,children:[]}}function q(){return{type:"break"}}function I(){return{type:"html",value:""}}function T(){return{type:"image",title:null,url:"",alt:null}}function $(){return{type:"link",title:null,url:"",children:[]}}function se(oe){return{type:"list",ordered:oe.type==="listOrdered",start:null,spread:oe._spread,children:[]}}function ue(oe){return{type:"listItem",spread:oe._spread,checked:null,children:[]}}function ne(){return{type:"paragraph",children:[]}}function me(){return{type:"strong",children:[]}}function ve(){return{type:"text",value:""}}function xe(){return{type:"thematicBreak"}}}function Hh(t){return{line:t.line,column:t.column,offset:t.offset}}function ope(t,e){let r=-1;for(;++r<e.length;){const n=e[r];Array.isArray(n)?ope(t,n):eze(t,n)}}function eze(t,e){let r;for(r in e)if(ape.call(e,r))switch(r){case"canContainEols":{const n=e[r];n&&t[r].push(...n);break}case"transforms":{const n=e[r];n&&t[r].push(...n);break}case"enter":case"exit":{const n=e[r];n&&Object.assign(t[r],n);break}}}function HY(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+p_({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+p_({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+p_({start:e.start,end:e.end})+") is still open")}function tze(t){const e=this;e.parser=r;function r(n){return Q8e(n,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function rze(t,e){const r={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,r),t.applyData(e,r)}function nze(t,e){const r={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,r),[t.applyData(e,r),{type:"text",value:`
`}]}function sze(t,e){const r=e.value?e.value+`
`:"",n={};e.lang&&(n.className=["language-"+e.lang]);let s={type:"element",tagName:"code",properties:n,children:[{type:"text",value:r}]};return e.meta&&(s.data={meta:e.meta}),t.patch(e,s),s=t.applyData(e,s),s={type:"element",tagName:"pre",properties:{},children:[s]},t.patch(e,s),s}function ize(t,e){const r={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function aze(t,e){const r={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function oze(t,e){const r=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=String(e.identifier).toUpperCase(),s=Jw(n.toLowerCase()),i=t.footnoteOrder.indexOf(n);let a,o=t.footnoteCounts.get(n);o===void 0?(o=0,t.footnoteOrder.push(n),a=t.footnoteOrder.length):a=i+1,o+=1,t.footnoteCounts.set(n,o);const c={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+s,id:r+"fnref-"+s+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};t.patch(e,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return t.patch(e,u),t.applyData(e,u)}function lze(t,e){const r={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function cze(t,e){if(t.options.allowDangerousHtml){const r={type:"raw",value:e.value};return t.patch(e,r),t.applyData(e,r)}}function lpe(t,e){const r=e.referenceType;let n="]";if(r==="collapsed"?n+="[]":r==="full"&&(n+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+n}];const s=t.all(e),i=s[0];i&&i.type==="text"?i.value="["+i.value:s.unshift({type:"text",value:"["});const a=s[s.length-1];return a&&a.type==="text"?a.value+=n:s.push({type:"text",value:n}),s}function uze(t,e){const r=String(e.identifier).toUpperCase(),n=t.definitionById.get(r);if(!n)return lpe(t,e);const s={src:Jw(n.url||""),alt:e.alt};n.title!==null&&n.title!==void 0&&(s.title=n.title);const i={type:"element",tagName:"img",properties:s,children:[]};return t.patch(e,i),t.applyData(e,i)}function dze(t,e){const r={src:Jw(e.url)};e.alt!==null&&e.alt!==void 0&&(r.alt=e.alt),e.title!==null&&e.title!==void 0&&(r.title=e.title);const n={type:"element",tagName:"img",properties:r,children:[]};return t.patch(e,n),t.applyData(e,n)}function hze(t,e){const r={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,r);const n={type:"element",tagName:"code",properties:{},children:[r]};return t.patch(e,n),t.applyData(e,n)}function fze(t,e){const r=String(e.identifier).toUpperCase(),n=t.definitionById.get(r);if(!n)return lpe(t,e);const s={href:Jw(n.url||"")};n.title!==null&&n.title!==void 0&&(s.title=n.title);const i={type:"element",tagName:"a",properties:s,children:t.all(e)};return t.patch(e,i),t.applyData(e,i)}function pze(t,e){const r={href:Jw(e.url)};e.title!==null&&e.title!==void 0&&(r.title=e.title);const n={type:"element",tagName:"a",properties:r,children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function mze(t,e,r){const n=t.all(e),s=r?gze(r):cpe(e),i={},a=[];if(typeof e.checked=="boolean"){const d=n[0];let h;d&&d.type==="element"&&d.tagName==="p"?h=d:(h={type:"element",tagName:"p",properties:{},children:[]},n.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let o=-1;for(;++o<n.length;){const d=n[o];(s||o!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
`}),d.type==="element"&&d.tagName==="p"&&!s?a.push(...d.children):a.push(d)}const c=n[n.length-1];c&&(s||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
`});const u={type:"element",tagName:"li",properties:i,children:a};return t.patch(e,u),t.applyData(e,u)}function gze(t){let e=!1;if(t.type==="list"){e=t.spread||!1;const r=t.children;let n=-1;for(;!e&&++n<r.length;)e=cpe(r[n])}return e}function cpe(t){const e=t.spread;return e??t.children.length>1}function yze(t,e){const r={},n=t.all(e);let s=-1;for(typeof e.start=="number"&&e.start!==1&&(r.start=e.start);++s<n.length;){const a=n[s];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}const i={type:"element",tagName:e.ordered?"ol":"ul",properties:r,children:t.wrap(n,!0)};return t.patch(e,i),t.applyData(e,i)}function xze(t,e){const r={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function vze(t,e){const r={type:"root",children:t.wrap(t.all(e))};return t.patch(e,r),t.applyData(e,r)}function bze(t,e){const r={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function wze(t,e){const r=t.all(e),n=r.shift(),s=[];if(n){const a={type:"element",tagName:"thead",properties:{},children:t.wrap([n],!0)};t.patch(e.children[0],a),s.push(a)}if(r.length>0){const a={type:"element",tagName:"tbody",properties:{},children:t.wrap(r,!0)},o=RV(e.children[1]),c=Ufe(e.children[e.children.length-1]);o&&c&&(a.position={start:o,end:c}),s.push(a)}const i={type:"element",tagName:"table",properties:{},children:t.wrap(s,!0)};return t.patch(e,i),t.applyData(e,i)}function Sze(t,e,r){const n=r?r.children:void 0,i=(n?n.indexOf(e):1)===0?"th":"td",a=r&&r.type==="table"?r.align:void 0,o=a?a.length:e.children.length;let c=-1;const u=[];for(;++c<o;){const h=e.children[c],f={},p=a?a[c]:void 0;p&&(f.align=p);let m={type:"element",tagName:i,properties:f,children:[]};h&&(m.children=t.all(h),t.patch(h,m),m=t.applyData(h,m)),u.push(m)}const d={type:"element",tagName:"tr",properties:{},children:t.wrap(u,!0)};return t.patch(e,d),t.applyData(e,d)}function _ze(t,e){const r={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}const VY=9,WY=32;function jze(t){const e=String(t),r=/\r?\n|\r/g;let n=r.exec(e),s=0;const i=[];for(;n;)i.push(qY(e.slice(s,n.index),s>0,!0),n[0]),s=n.index+n[0].length,n=r.exec(e);return i.push(qY(e.slice(s),s>0,!1)),i.join("")}function qY(t,e,r){let n=0,s=t.length;if(e){let i=t.codePointAt(n);for(;i===VY||i===WY;)n++,i=t.codePointAt(n)}if(r){let i=t.codePointAt(s-1);for(;i===VY||i===WY;)s--,i=t.codePointAt(s-1)}return s>n?t.slice(n,s):""}function kze(t,e){const r={type:"text",value:jze(String(e.value))};return t.patch(e,r),t.applyData(e,r)}function Nze(t,e){const r={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,r),t.applyData(e,r)}const Eze={blockquote:rze,break:nze,code:sze,delete:ize,emphasis:aze,footnoteReference:oze,heading:lze,html:cze,imageReference:uze,image:dze,inlineCode:hze,linkReference:fze,link:pze,listItem:mze,list:yze,paragraph:xze,root:vze,strong:bze,table:wze,tableCell:_ze,tableRow:Sze,text:kze,thematicBreak:Nze,toml:BA,yaml:BA,definition:BA,footnoteDefinition:BA};function BA(){}const upe=-1,LR=0,g_=1,aP=2,zV=3,UV=4,HV=5,VV=6,dpe=7,hpe=8,GY=typeof self=="object"?self:globalThis,Aze=(t,e)=>{const r=(s,i)=>(t.set(i,s),s),n=s=>{if(t.has(s))return t.get(s);const[i,a]=e[s];switch(i){case LR:case upe:return r(a,s);case g_:{const o=r([],s);for(const c of a)o.push(n(c));return o}case aP:{const o=r({},s);for(const[c,u]of a)o[n(c)]=n(u);return o}case zV:return r(new Date(a),s);case UV:{const{source:o,flags:c}=a;return r(new RegExp(o,c),s)}case HV:{const o=r(new Map,s);for(const[c,u]of a)o.set(n(c),n(u));return o}case VV:{const o=r(new Set,s);for(const c of a)o.add(n(c));return o}case dpe:{const{name:o,message:c}=a;return r(new GY[o](c),s)}case hpe:return r(BigInt(a),s);case"BigInt":return r(Object(BigInt(a)),s);case"ArrayBuffer":return r(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return r(new DataView(o),a)}}return r(new GY[i](a),s)};return n},KY=t=>Aze(new Map,t)(0),Vx="",{toString:Cze}={},{keys:Tze}=Object,I1=t=>{const e=typeof t;if(e!=="object"||!t)return[LR,e];const r=Cze.call(t).slice(8,-1);switch(r){case"Array":return[g_,Vx];case"Object":return[aP,Vx];case"Date":return[zV,Vx];case"RegExp":return[UV,Vx];case"Map":return[HV,Vx];case"Set":return[VV,Vx];case"DataView":return[g_,r]}return r.includes("Array")?[g_,r]:r.includes("Error")?[dpe,r]:[aP,r]},zA=([t,e])=>t===LR&&(e==="function"||e==="symbol"),Pze=(t,e,r,n)=>{const s=(a,o)=>{const c=n.push(a)-1;return r.set(o,c),c},i=a=>{if(r.has(a))return r.get(a);let[o,c]=I1(a);switch(o){case LR:{let d=a;switch(c){case"bigint":o=hpe,d=a.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return s([upe],a)}return s([o,d],a)}case g_:{if(c){let f=a;return c==="DataView"?f=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(f=new Uint8Array(a)),s([c,[...f]],a)}const d=[],h=s([o,d],a);for(const f of a)d.push(i(f));return h}case aP:{if(c)switch(c){case"BigInt":return s([c,a.toString()],a);case"Boolean":case"Number":case"String":return s([c,a.valueOf()],a)}if(e&&"toJSON"in a)return i(a.toJSON());const d=[],h=s([o,d],a);for(const f of Tze(a))(t||!zA(I1(a[f])))&&d.push([i(f),i(a[f])]);return h}case zV:return s([o,a.toISOString()],a);case UV:{const{source:d,flags:h}=a;return s([o,{source:d,flags:h}],a)}case HV:{const d=[],h=s([o,d],a);for(const[f,p]of a)(t||!(zA(I1(f))||zA(I1(p))))&&d.push([i(f),i(p)]);return h}case VV:{const d=[],h=s([o,d],a);for(const f of a)(t||!zA(I1(f)))&&d.push(i(f));return h}}const{message:u}=a;return s([o,{name:c,message:u}],a)};return i},YY=(t,{json:e,lossy:r}={})=>{const n=[];return Pze(!(e||r),!!e,new Map,n)(t),n},oP=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?KY(YY(t,e)):structuredClone(t):(t,e)=>KY(YY(t,e));function Oze(t,e){const r=[{type:"text",value:"↩"}];return e>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),r}function Ize(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function Rze(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=t.options.footnoteBackContent||Oze,n=t.options.footnoteBackLabel||Ize,s=t.options.footnoteLabel||"Footnotes",i=t.options.footnoteLabelTagName||"h2",a=t.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let c=-1;for(;++c<t.footnoteOrder.length;){const u=t.footnoteById.get(t.footnoteOrder[c]);if(!u)continue;const d=t.all(u),h=String(u.identifier).toUpperCase(),f=Jw(h.toLowerCase());let p=0;const m=[],g=t.footnoteCounts.get(h);for(;g!==void 0&&++p<=g;){m.length>0&&m.push({type:"text",value:" "});let v=typeof r=="string"?r:r(c,p);typeof v=="string"&&(v={type:"text",value:v}),m.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+f+(p>1?"-"+p:""),dataFootnoteBackref:"",ariaLabel:typeof n=="string"?n:n(c,p),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const x=d[d.length-1];if(x&&x.type==="element"&&x.tagName==="p"){const v=x.children[x.children.length-1];v&&v.type==="text"?v.value+=" ":x.children.push({type:"text",value:" "}),x.children.push(...m)}else d.push(...m);const y={type:"element",tagName:"li",properties:{id:e+"fn-"+f},children:t.wrap(d,!0)};t.patch(u,y),o.push(y)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...oP(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
`},{type:"element",tagName:"ol",properties:{},children:t.wrap(o,!0)},{type:"text",value:`
`}]}}const FR=function(t){if(t==null)return Fze;if(typeof t=="function")return $R(t);if(typeof t=="object")return Array.isArray(t)?Mze(t):Dze(t);if(typeof t=="string")return Lze(t);throw new Error("Expected function, string, or object as test")};function Mze(t){const e=[];let r=-1;for(;++r<t.length;)e[r]=FR(t[r]);return $R(n);function n(...s){let i=-1;for(;++i<e.length;)if(e[i].apply(this,s))return!0;return!1}}function Dze(t){const e=t;return $R(r);function r(n){const s=n;let i;for(i in t)if(s[i]!==e[i])return!1;return!0}}function Lze(t){return $R(e);function e(r){return r&&r.type===t}}function $R(t){return e;function e(r,n,s){return!!($ze(r)&&t.call(this,r,typeof n=="number"?n:void 0,s||void 0))}}function Fze(){return!0}function $ze(t){return t!==null&&typeof t=="object"&&"type"in t}const fpe=[],Bze=!0,x6=!1,zze="skip";function ppe(t,e,r,n){let s;typeof e=="function"&&typeof r!="function"?(n=r,r=e):s=e;const i=FR(s),a=n?-1:1;o(t,void 0,[])();function o(c,u,d){const h=c&&typeof c=="object"?c:{};if(typeof h.type=="string"){const p=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(c.type+(p?"<"+p+">":""))+")"})}return f;function f(){let p=fpe,m,g,x;if((!e||i(c,u,d[d.length-1]||void 0))&&(p=Uze(r(c,d)),p[0]===x6))return p;if("children"in c&&c.children){const y=c;if(y.children&&p[0]!==zze)for(g=(n?y.children.length:-1)+a,x=d.concat(y);g>-1&&g<y.children.length;){const v=y.children[g];if(m=o(v,g,x)(),m[0]===x6)return m;g=typeof m[1]=="number"?m[1]:g+a}}return p}}}function Uze(t){return Array.isArray(t)?t:typeof t=="number"?[Bze,t]:t==null?fpe:[t]}function WV(t,e,r,n){let s,i,a;typeof e=="function"&&typeof r!="function"?(i=void 0,a=e,s=r):(i=e,a=r,s=n),ppe(t,i,o,s);function o(c,u){const d=u[u.length-1],h=d?d.children.indexOf(c):void 0;return a(c,h,d)}}const v6={}.hasOwnProperty,Hze={};function Vze(t,e){const r=e||Hze,n=new Map,s=new Map,i=new Map,a={...Eze,...r.handlers},o={all:u,applyData:qze,definitionById:n,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:r,patch:Wze,wrap:Kze};return WV(t,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const h=d.type==="definition"?n:s,f=String(d.identifier).toUpperCase();h.has(f)||h.set(f,d)}}),o;function c(d,h){const f=d.type,p=o.handlers[f];if(v6.call(o.handlers,f)&&p)return p(o,d,h);if(o.options.passThrough&&o.options.passThrough.includes(f)){if("children"in d){const{children:g,...x}=d,y=oP(x);return y.children=o.all(d),y}return oP(d)}return(o.options.unknownHandler||Gze)(o,d,h)}function u(d){const h=[];if("children"in d){const f=d.children;let p=-1;for(;++p<f.length;){const m=o.one(f[p],d);if(m){if(p&&f[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=XY(m.value)),!Array.isArray(m)&&m.type==="element")){const g=m.children[0];g&&g.type==="text"&&(g.value=XY(g.value))}Array.isArray(m)?h.push(...m):h.push(m)}}}return h}}function Wze(t,e){t.position&&(e.position=I6e(t))}function qze(t,e){let r=e;if(t&&t.data){const n=t.data.hName,s=t.data.hChildren,i=t.data.hProperties;if(typeof n=="string")if(r.type==="element")r.tagName=n;else{const a="children"in r?r.children:[r];r={type:"element",tagName:n,properties:{},children:a}}r.type==="element"&&i&&Object.assign(r.properties,oP(i)),"children"in r&&r.children&&s!==null&&s!==void 0&&(r.children=s)}return r}function Gze(t,e){const r=e.data||{},n="value"in e&&!(v6.call(r,"hProperties")||v6.call(r,"hChildren"))?{type:"text",value:e.value}:{type:"element",tagName:"div",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)}function Kze(t,e){const r=[];let n=-1;for(e&&r.push({type:"text",value:`
`});++n<t.length;)n&&r.push({type:"text",value:`
`}),r.push(t[n]);return e&&t.length>0&&r.push({type:"text",value:`
`}),r}function XY(t){let e=0,r=t.charCodeAt(e);for(;r===9||r===32;)e++,r=t.charCodeAt(e);return t.slice(e)}function JY(t,e){const r=Vze(t,e),n=r.one(t,void 0),s=Rze(r),i=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
`},s),i}function Yze(t,e){return t&&"run"in t?async function(r,n){const s=JY(r,{file:n,...e});await t.run(s,n)}:function(r,n){return JY(r,{file:n,...t||e})}}function QY(t){if(t)throw t}var mT=Object.prototype.hasOwnProperty,mpe=Object.prototype.toString,ZY=Object.defineProperty,eX=Object.getOwnPropertyDescriptor,tX=function(e){return typeof Array.isArray=="function"?Array.isArray(e):mpe.call(e)==="[object Array]"},rX=function(e){if(!e||mpe.call(e)!=="[object Object]")return!1;var r=mT.call(e,"constructor"),n=e.constructor&&e.constructor.prototype&&mT.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!n)return!1;var s;for(s in e);return typeof s>"u"||mT.call(e,s)},nX=function(e,r){ZY&&r.name==="__proto__"?ZY(e,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0}):e[r.name]=r.newValue},sX=function(e,r){if(r==="__proto__")if(mT.call(e,r)){if(eX)return eX(e,r).value}else return;return e[r]},Xze=function t(){var e,r,n,s,i,a,o=arguments[0],c=1,u=arguments.length,d=!1;for(typeof o=="boolean"&&(d=o,o=arguments[1]||{},c=2),(o==null||typeof o!="object"&&typeof o!="function")&&(o={});c<u;++c)if(e=arguments[c],e!=null)for(r in e)n=sX(o,r),s=sX(e,r),o!==s&&(d&&s&&(rX(s)||(i=tX(s)))?(i?(i=!1,a=n&&tX(n)?n:[]):a=n&&rX(n)?n:{},nX(o,{name:r,newValue:t(d,a,s)})):typeof s<"u"&&nX(o,{name:r,newValue:s}));return o};const LL=cr(Xze);function b6(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function Jze(){const t=[],e={run:r,use:n};return e;function r(...s){let i=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...s);function o(c,...u){const d=t[++i];let h=-1;if(c){a(c);return}for(;++h<s.length;)(u[h]===null||u[h]===void 0)&&(u[h]=s[h]);s=u,d?Qze(d,o)(...u):a(null,...u)}}function n(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return t.push(s),e}}function Qze(t,e){let r;return n;function n(...a){const o=t.length>a.length;let c;o&&a.push(s);try{c=t.apply(this,a)}catch(u){const d=u;if(o&&r)throw d;return s(d)}o||(c&&c.then&&typeof c.then=="function"?c.then(i,s):c instanceof Error?s(c):i(c))}function s(a,...o){r||(r=!0,e(a,...o))}function i(a){s(null,a)}}const Lc={basename:Zze,dirname:eUe,extname:tUe,join:rUe,sep:"/"};function Zze(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');_E(t);let r=0,n=-1,s=t.length,i;if(e===void 0||e.length===0||e.length>t.length){for(;s--;)if(t.codePointAt(s)===47){if(i){r=s+1;break}}else n<0&&(i=!0,n=s+1);return n<0?"":t.slice(r,n)}if(e===t)return"";let a=-1,o=e.length-1;for(;s--;)if(t.codePointAt(s)===47){if(i){r=s+1;break}}else a<0&&(i=!0,a=s+1),o>-1&&(t.codePointAt(s)===e.codePointAt(o--)?o<0&&(n=s):(o=-1,n=a));return r===n?n=a:n<0&&(n=t.length),t.slice(r,n)}function eUe(t){if(_E(t),t.length===0)return".";let e=-1,r=t.length,n;for(;--r;)if(t.codePointAt(r)===47){if(n){e=r;break}}else n||(n=!0);return e<0?t.codePointAt(0)===47?"/":".":e===1&&t.codePointAt(0)===47?"//":t.slice(0,e)}function tUe(t){_E(t);let e=t.length,r=-1,n=0,s=-1,i=0,a;for(;e--;){const o=t.codePointAt(e);if(o===47){if(a){n=e+1;break}continue}r<0&&(a=!0,r=e+1),o===46?s<0?s=e:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||r<0||i===0||i===1&&s===r-1&&s===n+1?"":t.slice(s,r)}function rUe(...t){let e=-1,r;for(;++e<t.length;)_E(t[e]),t[e]&&(r=r===void 0?t[e]:r+"/"+t[e]);return r===void 0?".":nUe(r)}function nUe(t){_E(t);const e=t.codePointAt(0)===47;let r=sUe(t,!e);return r.length===0&&!e&&(r="."),r.length>0&&t.codePointAt(t.length-1)===47&&(r+="/"),e?"/"+r:r}function sUe(t,e){let r="",n=0,s=-1,i=0,a=-1,o,c;for(;++a<=t.length;){if(a<t.length)o=t.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(s===a-1||i===1))if(s!==a-1&&i===2){if(r.length<2||n!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(c=r.lastIndexOf("/"),c!==r.length-1){c<0?(r="",n=0):(r=r.slice(0,c),n=r.length-1-r.lastIndexOf("/")),s=a,i=0;continue}}else if(r.length>0){r="",n=0,s=a,i=0;continue}}e&&(r=r.length>0?r+"/..":"..",n=2)}else r.length>0?r+="/"+t.slice(s+1,a):r=t.slice(s+1,a),n=a-s-1;s=a,i=0}else o===46&&i>-1?i++:i=-1}return r}function _E(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const iUe={cwd:aUe};function aUe(){return"/"}function w6(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function oUe(t){if(typeof t=="string")t=new URL(t);else if(!w6(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return lUe(t)}function lUe(t){if(t.hostname!==""){const n=new TypeError('File URL host must be "localhost" or empty on darwin');throw n.code="ERR_INVALID_FILE_URL_HOST",n}const e=t.pathname;let r=-1;for(;++r<e.length;)if(e.codePointAt(r)===37&&e.codePointAt(r+1)===50){const n=e.codePointAt(r+2);if(n===70||n===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(e)}const FL=["history","path","basename","stem","extname","dirname"];class gpe{constructor(e){let r;e?w6(e)?r={path:e}:typeof e=="string"||cUe(e)?r={value:e}:r=e:r={},this.cwd="cwd"in r?"":iUe.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<FL.length;){const i=FL[n];i in r&&r[i]!==void 0&&r[i]!==null&&(this[i]=i==="history"?[...r[i]]:r[i])}let s;for(s in r)FL.includes(s)||(this[s]=r[s])}get basename(){return typeof this.path=="string"?Lc.basename(this.path):void 0}set basename(e){BL(e,"basename"),$L(e,"basename"),this.path=Lc.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Lc.dirname(this.path):void 0}set dirname(e){iX(this.basename,"dirname"),this.path=Lc.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Lc.extname(this.path):void 0}set extname(e){if($L(e,"extname"),iX(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Lc.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){w6(e)&&(e=oUe(e)),BL(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Lc.basename(this.path,this.extname):void 0}set stem(e){BL(e,"stem"),$L(e,"stem"),this.path=Lc.join(this.dirname||"",e+(this.extname||""))}fail(e,r,n){const s=this.message(e,r,n);throw s.fatal=!0,s}info(e,r,n){const s=this.message(e,r,n);return s.fatal=void 0,s}message(e,r,n){const s=new Yi(e,r,n);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function $L(t,e){if(t&&t.includes(Lc.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Lc.sep+"`")}function BL(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function iX(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function cUe(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const uUe=function(t){const n=this.constructor.prototype,s=n[t],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,n),i},dUe={}.hasOwnProperty;class qV extends uUe{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Jze()}copy(){const e=new qV;let r=-1;for(;++r<this.attachers.length;){const n=this.attachers[r];e.use(...n)}return e.data(LL(!0,{},this.namespace)),e}data(e,r){return typeof e=="string"?arguments.length===2?(HL("data",this.frozen),this.namespace[e]=r,this):dUe.call(this.namespace,e)&&this.namespace[e]||void 0:e?(HL("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[r,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);const s=r.call(e,...n);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const r=UA(e),n=this.parser||this.Parser;return zL("parse",n),n(String(r),r)}process(e,r){const n=this;return this.freeze(),zL("process",this.parser||this.Parser),UL("process",this.compiler||this.Compiler),r?s(void 0,r):new Promise(s);function s(i,a){const o=UA(e),c=n.parse(o);n.run(c,o,function(d,h,f){if(d||!h||!f)return u(d);const p=h,m=n.stringify(p,f);pUe(m)?f.value=m:f.result=m,u(d,f)});function u(d,h){d||!h?a(d):i?i(h):r(void 0,h)}}}processSync(e){let r=!1,n;return this.freeze(),zL("processSync",this.parser||this.Parser),UL("processSync",this.compiler||this.Compiler),this.process(e,s),oX("processSync","process",r),n;function s(i,a){r=!0,QY(i),n=a}}run(e,r,n){aX(e),this.freeze();const s=this.transformers;return!n&&typeof r=="function"&&(n=r,r=void 0),n?i(void 0,n):new Promise(i);function i(a,o){const c=UA(r);s.run(e,c,u);function u(d,h,f){const p=h||e;d?o(d):a?a(p):n(void 0,p,f)}}}runSync(e,r){let n=!1,s;return this.run(e,r,i),oX("runSync","run",n),s;function i(a,o){QY(a),s=o,n=!0}}stringify(e,r){this.freeze();const n=UA(r),s=this.compiler||this.Compiler;return UL("stringify",s),aX(e),s(e,n)}use(e,...r){const n=this.attachers,s=this.namespace;if(HL("use",this.frozen),e!=null)if(typeof e=="function")c(e,r);else if(typeof e=="object")Array.isArray(e)?o(e):a(e);else throw new TypeError("Expected usable value, not `"+e+"`");return this;function i(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...h]=u;c(d,h)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(u.plugins),u.settings&&(s.settings=LL(!0,s.settings,u.settings))}function o(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const h=u[d];i(h)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,d){let h=-1,f=-1;for(;++h<n.length;)if(n[h][0]===u){f=h;break}if(f===-1)n.push([u,...d]);else if(d.length>0){let[p,...m]=d;const g=n[f][1];b6(g)&&b6(p)&&(p=LL(!0,g,p)),n[f]=[u,p,...m]}}}}const hUe=new qV().freeze();function zL(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function UL(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function HL(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function aX(t){if(!b6(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function oX(t,e,r){if(!r)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function UA(t){return fUe(t)?t:new gpe(t)}function fUe(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function pUe(t){return typeof t=="string"||mUe(t)}function mUe(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const gUe="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",lX=[],cX={allowDangerousHtml:!0},yUe=/^(https?|ircs?|mailto|xmpp)$/i,xUe=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function pc(t){const e=vUe(t),r=bUe(t);return wUe(e.runSync(e.parse(r),r),t)}function vUe(t){const e=t.rehypePlugins||lX,r=t.remarkPlugins||lX,n=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...cX}:cX;return hUe().use(tze).use(r).use(Yze,n).use(e)}function bUe(t){const e=t.children||"",r=new gpe;return typeof e=="string"&&(r.value=e),r}function wUe(t,e){const r=e.allowedElements,n=e.allowElement,s=e.components,i=e.disallowedElements,a=e.skipHtml,o=e.unwrapDisallowed,c=e.urlTransform||SUe;for(const d of xUe)Object.hasOwn(e,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+gUe+d.id,void 0);return WV(t,u),F6e(t,{Fragment:l.Fragment,components:s,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function u(d,h,f){if(d.type==="raw"&&f&&typeof h=="number")return a?f.children.splice(h,1):f.children[h]={type:"text",value:d.value},h;if(d.type==="element"){let p;for(p in RL)if(Object.hasOwn(RL,p)&&Object.hasOwn(d.properties,p)){const m=d.properties[p],g=RL[p];(g===null||g.includes(d.tagName))&&(d.properties[p]=c(String(m||""),p,d))}}if(d.type==="element"){let p=r?!r.includes(d.tagName):i?i.includes(d.tagName):!1;if(!p&&n&&typeof h=="number"&&(p=!n(d,h,f)),p&&f&&typeof h=="number")return o&&d.children?f.children.splice(h,1,...d.children):f.children.splice(h,1),h}}}function SUe(t){const e=t.indexOf(":"),r=t.indexOf("?"),n=t.indexOf("#"),s=t.indexOf("/");return e===-1||s!==-1&&e>s||r!==-1&&e>r||n!==-1&&e>n||yUe.test(t.slice(0,e))?t:""}function uX(){const[t,e]=j.useState(()=>{try{const c=sessionStorage.getItem("platform_assistant_messages");return c?JSON.parse(c):[{id:1,content:"Hi! I'm your Academly assistant. Ask me anything about the platform or your thesis! 👋",sender:"ai"}]}catch{return[{id:1,content:"Hi! I'm your Academly assistant. Ask me anything about the platform or your thesis! 👋",sender:"ai"}]}}),[r,n]=j.useState(""),[s,i]=j.useState(!1);j.useEffect(()=>{try{sessionStorage.setItem("platform_assistant_messages",JSON.stringify(t))}catch{}},[t]);const a=async c=>{if(c.preventDefault(),!r.trim()||s)return;const u=r.trim(),d=[...t,{id:t.length+1,content:u,sender:"user"}];e(d),n(""),i(!0);try{const h=t.map(m=>({role:m.sender==="ai"?"assistant":"user",content:m.content})),{data:f,error:p}=await be.functions.invoke("platform-assistant",{body:{message:u,chat_history:h}});if(p)throw p;e([...d,{id:d.length+1,content:(f==null?void 0:f.message)||"Sorry, I couldn't process that.",sender:"ai"}])}catch{e([...d,{id:d.length+1,content:"Something went wrong. Please try again.",sender:"ai"}])}finally{i(!1)}},o=c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),a(c))};return l.jsxs(Cfe,{size:"md",position:"bottom-right",icon:l.jsx(i2e,{className:"h-6 w-6"}),children:[l.jsx(Tfe,{children:l.jsxs("div",{className:"flex flex-col",children:[l.jsx("h4",{className:"text-sm font-semibold text-foreground",children:"Academly Assistant ✨"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask me anything about the platform"})]})}),l.jsx(Pfe,{children:l.jsxs(Rfe,{smooth:!0,children:[t.map(c=>l.jsxs(vY,{variant:c.sender==="ai"?"received":"sent",layout:"ai",children:[c.sender==="ai"&&l.jsx(wY,{fallback:"🎓"}),l.jsx(bY,{variant:c.sender==="ai"?"received":"sent",children:c.sender==="ai"?l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>p]:mb-2 [&>p]:leading-relaxed",children:l.jsx(pc,{children:c.content})}):c.content})]},c.id)),s&&l.jsxs(vY,{variant:"received",layout:"ai",children:[l.jsx(wY,{fallback:"🎓"}),l.jsx(bY,{isLoading:!0})]})]})}),l.jsx(Ofe,{children:l.jsxs("form",{onSubmit:a,className:"flex items-end gap-2",children:[l.jsx(Afe,{value:r,onChange:c=>n(c.target.value),onKeyDown:o,placeholder:"Type your message...",className:"min-h-12 resize-none rounded-lg bg-background border-0 p-3 shadow-none focus-visible:ring-0",disabled:s}),l.jsx("div",{className:"flex flex-col gap-1",children:l.jsxs(ye,{type:"submit",size:"sm",disabled:s||!r.trim(),className:"gap-1.5",children:["Send",l.jsx(h2e,{className:"h-3.5 w-3.5"})]})})]})})]})}const gr=({children:t,showSidebar:e=!1,pageTitle:r="Dashboard",fullWidth:n=!1,hidePlatformAssistant:s=!1})=>{const{user:i}=Dt(),[a,o]=j.useState(!0),[c,u]=j.useState(!1),[d,h]=j.useState(!1),f=a||c;return e&&i?l.jsxs("div",{className:"ta-layout astro-gradient-bg min-h-screen",children:[l.jsx(B$e,{isExpanded:a,isHovered:c,isMobileOpen:d,onHoverChange:u,onMobileClose:()=>h(!1)}),l.jsxs("div",{className:`ta-main ${f?"ta-main-expanded":"ta-main-collapsed"}`,children:[l.jsx(yY,{pageTitle:r,onToggleSidebar:()=>o(!a),onToggleMobile:()=>h(!d),isMobileOpen:d}),l.jsx("main",{className:`flex-1 animate-fade-in ${n?"p-5 md:p-6 xl:p-8":"ta-content"}`,children:l.jsx("div",{className:n?"w-full":"max-w-screen-xl mx-auto",children:t})})]}),!s&&l.jsx(uX,{})]}):l.jsxs("div",{className:"min-h-screen flex flex-col w-full bg-background",children:[l.jsx(yY,{showSidebarControls:!1}),l.jsx("main",{className:"flex-1 w-full",children:t}),l.jsx(Bi,{}),!s&&l.jsx(uX,{})]})};function _Ue(){const[t,e]=j.useState(null),[r,n]=j.useState(!0),[s,i]=j.useState(null),a=async()=>{try{n(!0),i(null);const{data:o,error:c}=await be.from("v_dashboard_stats").select("*").single();if(c)throw c;e(o)}catch(o){console.error("Error fetching dashboard stats:",o),i(o)}finally{n(!1)}};return j.useEffect(()=>{a()},[]),{stats:t,loading:r,error:s,refetch:a}}const ze=j.forwardRef(({className:t,...e},r)=>l.jsx("div",{ref:r,className:Le("rounded-2xl border border-border/50 bg-card/80 backdrop-blur-sm text-card-foreground","shadow-lg shadow-primary/5 hover:shadow-xl hover:shadow-primary/10","transition-all duration-300 ease-out","dark:bg-card/90 dark:border-border/30 dark:shadow-black/20 dark:hover:shadow-primary/20",t),...e}));ze.displayName="Card";const et=j.forwardRef(({className:t,...e},r)=>l.jsx("div",{ref:r,className:Le("flex flex-col space-y-1.5 px-5 py-4",t),...e}));et.displayName="CardHeader";const at=j.forwardRef(({className:t,...e},r)=>l.jsx("h3",{ref:r,className:Le("text-base font-semibold leading-none tracking-tight text-foreground",t),...e}));at.displayName="CardTitle";const Un=j.forwardRef(({className:t,...e},r)=>l.jsx("p",{ref:r,className:Le("text-sm text-muted-foreground",t),...e}));Un.displayName="CardDescription";const Ge=j.forwardRef(({className:t,...e},r)=>l.jsx("div",{ref:r,className:Le("px-5 pb-5 pt-0",t),...e}));Ge.displayName="CardContent";const jUe=j.forwardRef(({className:t,...e},r)=>l.jsx("div",{ref:r,className:Le("flex items-center px-5 pb-5 pt-0",t),...e}));jUe.displayName="CardFooter";var GV="Progress",KV=100,[kUe,h5t]=gs(GV),[NUe,EUe]=kUe(GV),ype=j.forwardRef((t,e)=>{const{__scopeProgress:r,value:n=null,max:s,getValueLabel:i=AUe,...a}=t;(s||s===0)&&!dX(s)&&console.error(CUe(`${s}`,"Progress"));const o=dX(s)?s:KV;n!==null&&!hX(n,o)&&console.error(TUe(`${n}`,"Progress"));const c=hX(n,o)?n:null,u=lP(c)?i(c,o):void 0;return l.jsx(NUe,{scope:r,value:c,max:o,children:l.jsx(ot.div,{"aria-valuemax":o,"aria-valuemin":0,"aria-valuenow":lP(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":bpe(c,o),"data-value":c??void 0,"data-max":o,...a,ref:e})})});ype.displayName=GV;var xpe="ProgressIndicator",vpe=j.forwardRef((t,e)=>{const{__scopeProgress:r,...n}=t,s=EUe(xpe,r);return l.jsx(ot.div,{"data-state":bpe(s.value,s.max),"data-value":s.value??void 0,"data-max":s.max,...n,ref:e})});vpe.displayName=xpe;function AUe(t,e){return`${Math.round(t/e*100)}%`}function bpe(t,e){return t==null?"indeterminate":t===e?"complete":"loading"}function lP(t){return typeof t=="number"}function dX(t){return lP(t)&&!isNaN(t)&&t>0}function hX(t,e){return lP(t)&&!isNaN(t)&&t<=e&&t>=0}function CUe(t,e){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${e}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${KV}\`.`}function TUe(t,e){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${e}\`. The \`value\` prop must be:
- a positive number
- less than the value passed to \`max\` (or ${KV} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`}var wpe=ype,PUe=vpe;const Spe=j.createContext({});function OUe(t){const e=j.useRef(null);return e.current===null&&(e.current=t()),e.current}const YV=typeof window<"u",IUe=YV?j.useLayoutEffect:j.useEffect,XV=j.createContext(null);function JV(t,e){t.indexOf(e)===-1&&t.push(e)}function QV(t,e){const r=t.indexOf(e);r>-1&&t.splice(r,1)}const gh=(t,e,r)=>r>e?e:r<t?t:r;let cP=()=>{};const yh={},_pe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function jpe(t){return typeof t=="object"&&t!==null}const kpe=t=>/^0[^.\s]+$/u.test(t);function ZV(t){let e;return()=>(e===void 0&&(e=t()),e)}const vl=t=>t,RUe=(t,e)=>r=>e(t(r)),jE=(...t)=>t.reduce(RUe),mj=(t,e,r)=>{const n=e-t;return n===0?1:(r-t)/n};class eW{constructor(){this.subscriptions=[]}add(e){return JV(this.subscriptions,e),()=>QV(this.subscriptions,e)}notify(e,r,n){const s=this.subscriptions.length;if(s)if(s===1)this.subscriptions[0](e,r,n);else for(let i=0;i<s;i++){const a=this.subscriptions[i];a&&a(e,r,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const Su=t=>t*1e3,fl=t=>t/1e3;function Npe(t,e){return e?t*(1e3/e):0}const Epe=(t,e,r)=>(((1-3*r+3*e)*t+(3*r-6*e))*t+3*e)*t,MUe=1e-7,DUe=12;function LUe(t,e,r,n,s){let i,a,o=0;do a=e+(r-e)/2,i=Epe(a,n,s)-t,i>0?r=a:e=a;while(Math.abs(i)>MUe&&++o<DUe);return a}function kE(t,e,r,n){if(t===e&&r===n)return vl;const s=i=>LUe(i,0,1,t,r);return i=>i===0||i===1?i:Epe(s(i),e,n)}const Ape=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Cpe=t=>e=>1-t(1-e),Tpe=kE(.33,1.53,.69,.99),tW=Cpe(Tpe),Ppe=Ape(tW),Ope=t=>(t*=2)<1?.5*tW(t):.5*(2-Math.pow(2,-10*(t-1))),rW=t=>1-Math.sin(Math.acos(t)),Ipe=Cpe(rW),Rpe=Ape(rW),FUe=kE(.42,0,1,1),$Ue=kE(0,0,.58,1),Mpe=kE(.42,0,.58,1),BUe=t=>Array.isArray(t)&&typeof t[0]!="number",Dpe=t=>Array.isArray(t)&&typeof t[0]=="number",fX={linear:vl,easeIn:FUe,easeInOut:Mpe,easeOut:$Ue,circIn:rW,circInOut:Rpe,circOut:Ipe,backIn:tW,backInOut:Ppe,backOut:Tpe,anticipate:Ope},zUe=t=>typeof t=="string",pX=t=>{if(Dpe(t)){cP(t.length===4);const[e,r,n,s]=t;return kE(e,r,n,s)}else if(zUe(t))return cP(fX[t]!==void 0),fX[t];return t},HA=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],mX={value:null,addProjectionMetrics:null};function UUe(t,e){let r=new Set,n=new Set,s=!1,i=!1;const a=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1},c=0;function u(h){a.has(h)&&(d.schedule(h),t()),c++,h(o)}const d={schedule:(h,f=!1,p=!1)=>{const g=p&&s?r:n;return f&&a.add(h),g.has(h)||g.add(h),h},cancel:h=>{n.delete(h),a.delete(h)},process:h=>{if(o=h,s){i=!0;return}s=!0,[r,n]=[n,r],r.forEach(u),e&&mX.value&&mX.value.frameloop[e].push(c),c=0,r.clear(),s=!1,i&&(i=!1,d.process(h))}};return d}const HUe=40;function Lpe(t,e){let r=!1,n=!0;const s={delta:0,timestamp:0,isProcessing:!1},i=()=>r=!0,a=HA.reduce((b,w)=>(b[w]=UUe(i,e?w:void 0),b),{}),{setup:o,read:c,resolveKeyframes:u,preUpdate:d,update:h,preRender:f,render:p,postRender:m}=a,g=()=>{const b=yh.useManualTiming?s.timestamp:performance.now();r=!1,yh.useManualTiming||(s.delta=n?1e3/60:Math.max(Math.min(b-s.timestamp,HUe),1)),s.timestamp=b,s.isProcessing=!0,o.process(s),c.process(s),u.process(s),d.process(s),h.process(s),f.process(s),p.process(s),m.process(s),s.isProcessing=!1,r&&e&&(n=!1,t(g))},x=()=>{r=!0,n=!0,s.isProcessing||t(g)};return{schedule:HA.reduce((b,w)=>{const S=a[w];return b[w]=(k,E=!1,C=!1)=>(r||x(),S.schedule(k,E,C)),b},{}),cancel:b=>{for(let w=0;w<HA.length;w++)a[HA[w]].cancel(b)},state:s,steps:a}}const{schedule:Sn,cancel:Hp,state:ui,steps:VL}=Lpe(typeof requestAnimationFrame<"u"?requestAnimationFrame:vl,!0);let gT;function VUe(){gT=void 0}const Ba={now:()=>(gT===void 0&&Ba.set(ui.isProcessing||yh.useManualTiming?ui.timestamp:performance.now()),gT),set:t=>{gT=t,queueMicrotask(VUe)}},Fpe=t=>e=>typeof e=="string"&&e.startsWith(t),$pe=Fpe("--"),WUe=Fpe("var(--"),nW=t=>WUe(t)?qUe.test(t.split("/*")[0].trim()):!1,qUe=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Qw={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},gj={...Qw,transform:t=>gh(0,1,t)},VA={...Qw,default:1},y_=t=>Math.round(t*1e5)/1e5,sW=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function GUe(t){return t==null}const KUe=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,iW=(t,e)=>r=>!!(typeof r=="string"&&KUe.test(r)&&r.startsWith(t)||e&&!GUe(r)&&Object.prototype.hasOwnProperty.call(r,e)),Bpe=(t,e,r)=>n=>{if(typeof n!="string")return n;const[s,i,a,o]=n.match(sW);return{[t]:parseFloat(s),[e]:parseFloat(i),[r]:parseFloat(a),alpha:o!==void 0?parseFloat(o):1}},YUe=t=>gh(0,255,t),WL={...Qw,transform:t=>Math.round(YUe(t))},Zm={test:iW("rgb","red"),parse:Bpe("red","green","blue"),transform:({red:t,green:e,blue:r,alpha:n=1})=>"rgba("+WL.transform(t)+", "+WL.transform(e)+", "+WL.transform(r)+", "+y_(gj.transform(n))+")"};function XUe(t){let e="",r="",n="",s="";return t.length>5?(e=t.substring(1,3),r=t.substring(3,5),n=t.substring(5,7),s=t.substring(7,9)):(e=t.substring(1,2),r=t.substring(2,3),n=t.substring(3,4),s=t.substring(4,5),e+=e,r+=r,n+=n,s+=s),{red:parseInt(e,16),green:parseInt(r,16),blue:parseInt(n,16),alpha:s?parseInt(s,16)/255:1}}const S6={test:iW("#"),parse:XUe,transform:Zm.transform},NE=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),Jh=NE("deg"),_u=NE("%"),Pt=NE("px"),JUe=NE("vh"),QUe=NE("vw"),gX={..._u,parse:t=>_u.parse(t)/100,transform:t=>_u.transform(t*100)},Ov={test:iW("hsl","hue"),parse:Bpe("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+_u.transform(y_(e))+", "+_u.transform(y_(r))+", "+y_(gj.transform(n))+")"},as={test:t=>Zm.test(t)||S6.test(t)||Ov.test(t),parse:t=>Zm.test(t)?Zm.parse(t):Ov.test(t)?Ov.parse(t):S6.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Zm.transform(t):Ov.transform(t),getAnimatableNone:t=>{const e=as.parse(t);return e.alpha=0,as.transform(e)}},ZUe=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function eHe(t){var e,r;return isNaN(t)&&typeof t=="string"&&(((e=t.match(sW))==null?void 0:e.length)||0)+(((r=t.match(ZUe))==null?void 0:r.length)||0)>0}const zpe="number",Upe="color",tHe="var",rHe="var(",yX="${}",nHe=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function yj(t){const e=t.toString(),r=[],n={color:[],number:[],var:[]},s=[];let i=0;const o=e.replace(nHe,c=>(as.test(c)?(n.color.push(i),s.push(Upe),r.push(as.parse(c))):c.startsWith(rHe)?(n.var.push(i),s.push(tHe),r.push(c)):(n.number.push(i),s.push(zpe),r.push(parseFloat(c))),++i,yX)).split(yX);return{values:r,split:o,indexes:n,types:s}}function Hpe(t){return yj(t).values}function Vpe(t){const{split:e,types:r}=yj(t),n=e.length;return s=>{let i="";for(let a=0;a<n;a++)if(i+=e[a],s[a]!==void 0){const o=r[a];o===zpe?i+=y_(s[a]):o===Upe?i+=as.transform(s[a]):i+=s[a]}return i}}const sHe=t=>typeof t=="number"?0:as.test(t)?as.getAnimatableNone(t):t;function iHe(t){const e=Hpe(t);return Vpe(t)(e.map(sHe))}const Vp={test:eHe,parse:Hpe,createTransformer:Vpe,getAnimatableNone:iHe};function qL(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function aHe({hue:t,saturation:e,lightness:r,alpha:n}){t/=360,e/=100,r/=100;let s=0,i=0,a=0;if(!e)s=i=a=r;else{const o=r<.5?r*(1+e):r+e-r*e,c=2*r-o;s=qL(c,o,t+1/3),i=qL(c,o,t),a=qL(c,o,t-1/3)}return{red:Math.round(s*255),green:Math.round(i*255),blue:Math.round(a*255),alpha:n}}function uP(t,e){return r=>r>0?e:t}const En=(t,e,r)=>t+(e-t)*r,GL=(t,e,r)=>{const n=t*t,s=r*(e*e-n)+n;return s<0?0:Math.sqrt(s)},oHe=[S6,Zm,Ov],lHe=t=>oHe.find(e=>e.test(t));function xX(t){const e=lHe(t);if(!e)return!1;let r=e.parse(t);return e===Ov&&(r=aHe(r)),r}const vX=(t,e)=>{const r=xX(t),n=xX(e);if(!r||!n)return uP(t,e);const s={...r};return i=>(s.red=GL(r.red,n.red,i),s.green=GL(r.green,n.green,i),s.blue=GL(r.blue,n.blue,i),s.alpha=En(r.alpha,n.alpha,i),Zm.transform(s))},_6=new Set(["none","hidden"]);function cHe(t,e){return _6.has(t)?r=>r<=0?t:e:r=>r>=1?e:t}function uHe(t,e){return r=>En(t,e,r)}function aW(t){return typeof t=="number"?uHe:typeof t=="string"?nW(t)?uP:as.test(t)?vX:fHe:Array.isArray(t)?Wpe:typeof t=="object"?as.test(t)?vX:dHe:uP}function Wpe(t,e){const r=[...t],n=r.length,s=t.map((i,a)=>aW(i)(i,e[a]));return i=>{for(let a=0;a<n;a++)r[a]=s[a](i);return r}}function dHe(t,e){const r={...t,...e},n={};for(const s in r)t[s]!==void 0&&e[s]!==void 0&&(n[s]=aW(t[s])(t[s],e[s]));return s=>{for(const i in n)r[i]=n[i](s);return r}}function hHe(t,e){const r=[],n={color:0,var:0,number:0};for(let s=0;s<e.values.length;s++){const i=e.types[s],a=t.indexes[i][n[i]],o=t.values[a]??0;r[s]=o,n[i]++}return r}const fHe=(t,e)=>{const r=Vp.createTransformer(e),n=yj(t),s=yj(e);return n.indexes.var.length===s.indexes.var.length&&n.indexes.color.length===s.indexes.color.length&&n.indexes.number.length>=s.indexes.number.length?_6.has(t)&&!s.values.length||_6.has(e)&&!n.values.length?cHe(t,e):jE(Wpe(hHe(n,s),s.values),r):uP(t,e)};function qpe(t,e,r){return typeof t=="number"&&typeof e=="number"&&typeof r=="number"?En(t,e,r):aW(t)(t,e)}const pHe=t=>{const e=({timestamp:r})=>t(r);return{start:(r=!0)=>Sn.update(e,r),stop:()=>Hp(e),now:()=>ui.isProcessing?ui.timestamp:Ba.now()}},Gpe=(t,e,r=10)=>{let n="";const s=Math.max(Math.round(e/r),2);for(let i=0;i<s;i++)n+=Math.round(t(i/(s-1))*1e4)/1e4+", ";return`linear(${n.substring(0,n.length-2)})`},dP=2e4;function oW(t){let e=0;const r=50;let n=t.next(e);for(;!n.done&&e<dP;)e+=r,n=t.next(e);return e>=dP?1/0:e}function mHe(t,e=100,r){const n=r({...t,keyframes:[0,e]}),s=Math.min(oW(n),dP);return{type:"keyframes",ease:i=>n.next(s*i).value/e,duration:fl(s)}}const gHe=5;function Kpe(t,e,r){const n=Math.max(e-gHe,0);return Npe(r-t(n),e-n)}const Fn={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},KL=.001;function yHe({duration:t=Fn.duration,bounce:e=Fn.bounce,velocity:r=Fn.velocity,mass:n=Fn.mass}){let s,i,a=1-e;a=gh(Fn.minDamping,Fn.maxDamping,a),t=gh(Fn.minDuration,Fn.maxDuration,fl(t)),a<1?(s=u=>{const d=u*a,h=d*t,f=d-r,p=j6(u,a),m=Math.exp(-h);return KL-f/p*m},i=u=>{const h=u*a*t,f=h*r+r,p=Math.pow(a,2)*Math.pow(u,2)*t,m=Math.exp(-h),g=j6(Math.pow(u,2),a);return(-s(u)+KL>0?-1:1)*((f-p)*m)/g}):(s=u=>{const d=Math.exp(-u*t),h=(u-r)*t+1;return-KL+d*h},i=u=>{const d=Math.exp(-u*t),h=(r-u)*(t*t);return d*h});const o=5/t,c=vHe(s,i,o);if(t=Su(t),isNaN(c))return{stiffness:Fn.stiffness,damping:Fn.damping,duration:t};{const u=Math.pow(c,2)*n;return{stiffness:u,damping:a*2*Math.sqrt(n*u),duration:t}}}const xHe=12;function vHe(t,e,r){let n=r;for(let s=1;s<xHe;s++)n=n-t(n)/e(n);return n}function j6(t,e){return t*Math.sqrt(1-e*e)}const bHe=["duration","bounce"],wHe=["stiffness","damping","mass"];function bX(t,e){return e.some(r=>t[r]!==void 0)}function SHe(t){let e={velocity:Fn.velocity,stiffness:Fn.stiffness,damping:Fn.damping,mass:Fn.mass,isResolvedFromDuration:!1,...t};if(!bX(t,wHe)&&bX(t,bHe))if(t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),s=n*n,i=2*gh(.05,1,1-(t.bounce||0))*Math.sqrt(s);e={...e,mass:Fn.mass,stiffness:s,damping:i}}else{const r=yHe(t);e={...e,...r,mass:Fn.mass},e.isResolvedFromDuration=!0}return e}function hP(t=Fn.visualDuration,e=Fn.bounce){const r=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:e}:t;let{restSpeed:n,restDelta:s}=r;const i=r.keyframes[0],a=r.keyframes[r.keyframes.length-1],o={done:!1,value:i},{stiffness:c,damping:u,mass:d,duration:h,velocity:f,isResolvedFromDuration:p}=SHe({...r,velocity:-fl(r.velocity||0)}),m=f||0,g=u/(2*Math.sqrt(c*d)),x=a-i,y=fl(Math.sqrt(c/d)),v=Math.abs(x)<5;n||(n=v?Fn.restSpeed.granular:Fn.restSpeed.default),s||(s=v?Fn.restDelta.granular:Fn.restDelta.default);let b;if(g<1){const S=j6(y,g);b=k=>{const E=Math.exp(-g*y*k);return a-E*((m+g*y*x)/S*Math.sin(S*k)+x*Math.cos(S*k))}}else if(g===1)b=S=>a-Math.exp(-y*S)*(x+(m+y*x)*S);else{const S=y*Math.sqrt(g*g-1);b=k=>{const E=Math.exp(-g*y*k),C=Math.min(S*k,300);return a-E*((m+g*y*x)*Math.sinh(C)+S*x*Math.cosh(C))/S}}const w={calculatedDuration:p&&h||null,next:S=>{const k=b(S);if(p)o.done=S>=h;else{let E=S===0?m:0;g<1&&(E=S===0?Su(m):Kpe(b,S,k));const C=Math.abs(E)<=n,A=Math.abs(a-k)<=s;o.done=C&&A}return o.value=o.done?a:k,o},toString:()=>{const S=Math.min(oW(w),dP),k=Gpe(E=>w.next(S*E).value,S,30);return S+"ms "+k},toTransition:()=>{}};return w}hP.applyToOptions=t=>{const e=mHe(t,100,hP);return t.ease=e.ease,t.duration=Su(e.duration),t.type="keyframes",t};function k6({keyframes:t,velocity:e=0,power:r=.8,timeConstant:n=325,bounceDamping:s=10,bounceStiffness:i=500,modifyTarget:a,min:o,max:c,restDelta:u=.5,restSpeed:d}){const h=t[0],f={done:!1,value:h},p=C=>o!==void 0&&C<o||c!==void 0&&C>c,m=C=>o===void 0?c:c===void 0||Math.abs(o-C)<Math.abs(c-C)?o:c;let g=r*e;const x=h+g,y=a===void 0?x:a(x);y!==x&&(g=y-h);const v=C=>-g*Math.exp(-C/n),b=C=>y+v(C),w=C=>{const A=v(C),M=b(C);f.done=Math.abs(A)<=u,f.value=f.done?y:M};let S,k;const E=C=>{p(f.value)&&(S=C,k=hP({keyframes:[f.value,m(f.value)],velocity:Kpe(b,C,f.value),damping:s,stiffness:i,restDelta:u,restSpeed:d}))};return E(0),{calculatedDuration:null,next:C=>{let A=!1;return!k&&S===void 0&&(A=!0,w(C),E(C)),S!==void 0&&C>=S?k.next(C-S):(!A&&w(C),f)}}}function _He(t,e,r){const n=[],s=r||yh.mix||qpe,i=t.length-1;for(let a=0;a<i;a++){let o=s(t[a],t[a+1]);if(e){const c=Array.isArray(e)?e[a]||vl:e;o=jE(c,o)}n.push(o)}return n}function jHe(t,e,{clamp:r=!0,ease:n,mixer:s}={}){const i=t.length;if(cP(i===e.length),i===1)return()=>e[0];if(i===2&&e[0]===e[1])return()=>e[1];const a=t[0]===t[1];t[0]>t[i-1]&&(t=[...t].reverse(),e=[...e].reverse());const o=_He(e,n,s),c=o.length,u=d=>{if(a&&d<t[0])return e[0];let h=0;if(c>1)for(;h<t.length-2&&!(d<t[h+1]);h++);const f=mj(t[h],t[h+1],d);return o[h](f)};return r?d=>u(gh(t[0],t[i-1],d)):u}function kHe(t,e){const r=t[t.length-1];for(let n=1;n<=e;n++){const s=mj(0,e,n);t.push(En(r,1,s))}}function NHe(t){const e=[0];return kHe(e,t.length-1),e}function EHe(t,e){return t.map(r=>r*e)}function AHe(t,e){return t.map(()=>e||Mpe).splice(0,t.length-1)}function x_({duration:t=300,keyframes:e,times:r,ease:n="easeInOut"}){const s=BUe(n)?n.map(pX):pX(n),i={done:!1,value:e[0]},a=EHe(r&&r.length===e.length?r:NHe(e),t),o=jHe(a,e,{ease:Array.isArray(s)?s:AHe(e,s)});return{calculatedDuration:t,next:c=>(i.value=o(c),i.done=c>=t,i)}}const CHe=t=>t!==null;function lW(t,{repeat:e,repeatType:r="loop"},n,s=1){const i=t.filter(CHe),o=s<0||e&&r!=="loop"&&e%2===1?0:i.length-1;return!o||n===void 0?i[o]:n}const THe={decay:k6,inertia:k6,tween:x_,keyframes:x_,spring:hP};function Ype(t){typeof t.type=="string"&&(t.type=THe[t.type])}class cW{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,r){return this.finished.then(e,r)}}const PHe=t=>t/100;class uW extends cW{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var n,s;const{motionValue:r}=this.options;r&&r.updatedAt!==Ba.now()&&this.tick(Ba.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(s=(n=this.options).onStop)==null||s.call(n))},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){const{options:e}=this;Ype(e);const{type:r=x_,repeat:n=0,repeatDelay:s=0,repeatType:i,velocity:a=0}=e;let{keyframes:o}=e;const c=r||x_;c!==x_&&typeof o[0]!="number"&&(this.mixKeyframes=jE(PHe,qpe(o[0],o[1])),o=[0,100]);const u=c({...e,keyframes:o});i==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...o].reverse(),velocity:-a})),u.calculatedDuration===null&&(u.calculatedDuration=oW(u));const{calculatedDuration:d}=u;this.calculatedDuration=d,this.resolvedDuration=d+s,this.totalDuration=this.resolvedDuration*(n+1)-s,this.generator=u}updateTime(e){const r=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=r}tick(e,r=!1){const{generator:n,totalDuration:s,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:c}=this;if(this.startTime===null)return n.next(0);const{delay:u=0,keyframes:d,repeat:h,repeatType:f,repeatDelay:p,type:m,onUpdate:g,finalKeyframe:x}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-s/this.speed,this.startTime)),r?this.currentTime=e:this.updateTime(e);const y=this.currentTime-u*(this.playbackSpeed>=0?1:-1),v=this.playbackSpeed>=0?y<0:y>s;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=s);let b=this.currentTime,w=n;if(h){const C=Math.min(this.currentTime,s)/o;let A=Math.floor(C),M=C%1;!M&&C>=1&&(M=1),M===1&&A--,A=Math.min(A,h+1),!!(A%2)&&(f==="reverse"?(M=1-M,p&&(M-=p/o)):f==="mirror"&&(w=a)),b=gh(0,1,M)*o}const S=v?{done:!1,value:d[0]}:w.next(b);i&&(S.value=i(S.value));let{done:k}=S;!v&&c!==null&&(k=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const E=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&k);return E&&m!==k6&&(S.value=lW(d,this.options,x,this.speed)),g&&g(S.value),E&&this.finish(),S}then(e,r){return this.finished.then(e,r)}get duration(){return fl(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+fl(e)}get time(){return fl(this.currentTime)}set time(e){var r;e=Su(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),(r=this.driver)==null||r.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Ba.now());const r=this.playbackSpeed!==e;this.playbackSpeed=e,r&&(this.time=fl(this.currentTime))}play(){var s,i;if(this.isStopped)return;const{driver:e=pHe,startTime:r}=this.options;this.driver||(this.driver=e(a=>this.tick(a))),(i=(s=this.options).onPlay)==null||i.call(s);const n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=r??n),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Ba.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var e,r;this.notifyFinished(),this.teardown(),this.state="finished",(r=(e=this.options).onComplete)==null||r.call(e)}cancel(){var e,r;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(r=(e=this.options).onCancel)==null||r.call(e)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){var r;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(r=this.driver)==null||r.stop(),e.observe(this)}}function OHe(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const eg=t=>t*180/Math.PI,N6=t=>{const e=eg(Math.atan2(t[1],t[0]));return E6(e)},IHe={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:N6,rotateZ:N6,skewX:t=>eg(Math.atan(t[1])),skewY:t=>eg(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},E6=t=>(t=t%360,t<0&&(t+=360),t),wX=N6,SX=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),_X=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),RHe={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:SX,scaleY:_X,scale:t=>(SX(t)+_X(t))/2,rotateX:t=>E6(eg(Math.atan2(t[6],t[5]))),rotateY:t=>E6(eg(Math.atan2(-t[2],t[0]))),rotateZ:wX,rotate:wX,skewX:t=>eg(Math.atan(t[4])),skewY:t=>eg(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function A6(t){return t.includes("scale")?1:0}function C6(t,e){if(!t||t==="none")return A6(e);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,s;if(r)n=RHe,s=r;else{const o=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=IHe,s=o}if(!s)return A6(e);const i=n[e],a=s[1].split(",").map(DHe);return typeof i=="function"?i(a):a[i]}const MHe=(t,e)=>{const{transform:r="none"}=getComputedStyle(t);return C6(r,e)};function DHe(t){return parseFloat(t.trim())}const Zw=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],e1=new Set(Zw),jX=t=>t===Qw||t===Pt,LHe=new Set(["x","y","z"]),FHe=Zw.filter(t=>!LHe.has(t));function $He(t){const e=[];return FHe.forEach(r=>{const n=t.getValue(r);n!==void 0&&(e.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),e}const Cy={width:({x:t},{paddingLeft:e="0",paddingRight:r="0"})=>t.max-t.min-parseFloat(e)-parseFloat(r),height:({y:t},{paddingTop:e="0",paddingBottom:r="0"})=>t.max-t.min-parseFloat(e)-parseFloat(r),top:(t,{top:e})=>parseFloat(e),left:(t,{left:e})=>parseFloat(e),bottom:({y:t},{top:e})=>parseFloat(e)+(t.max-t.min),right:({x:t},{left:e})=>parseFloat(e)+(t.max-t.min),x:(t,{transform:e})=>C6(e,"x"),y:(t,{transform:e})=>C6(e,"y")};Cy.translateX=Cy.x;Cy.translateY=Cy.y;const Ty=new Set;let T6=!1,P6=!1,O6=!1;function Xpe(){if(P6){const t=Array.from(Ty).filter(n=>n.needsMeasurement),e=new Set(t.map(n=>n.element)),r=new Map;e.forEach(n=>{const s=$He(n);s.length&&(r.set(n,s),n.render())}),t.forEach(n=>n.measureInitialState()),e.forEach(n=>{n.render();const s=r.get(n);s&&s.forEach(([i,a])=>{var o;(o=n.getValue(i))==null||o.set(a)})}),t.forEach(n=>n.measureEndState()),t.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}P6=!1,T6=!1,Ty.forEach(t=>t.complete(O6)),Ty.clear()}function Jpe(){Ty.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(P6=!0)})}function BHe(){O6=!0,Jpe(),Xpe(),O6=!1}class dW{constructor(e,r,n,s,i,a=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=r,this.name=n,this.motionValue=s,this.element=i,this.isAsync=a}scheduleResolve(){this.state="scheduled",this.isAsync?(Ty.add(this),T6||(T6=!0,Sn.read(Jpe),Sn.resolveKeyframes(Xpe))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:e,name:r,element:n,motionValue:s}=this;if(e[0]===null){const i=s==null?void 0:s.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&r){const o=n.readValue(r,a);o!=null&&(e[0]=o)}e[0]===void 0&&(e[0]=a),s&&i===void 0&&s.set(e[0])}OHe(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Ty.delete(this)}cancel(){this.state==="scheduled"&&(Ty.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const zHe=t=>t.startsWith("--");function UHe(t,e,r){zHe(e)?t.style.setProperty(e,r):t.style[e]=r}const HHe=ZV(()=>window.ScrollTimeline!==void 0),VHe={};function WHe(t,e){const r=ZV(t);return()=>VHe[e]??r()}const Qpe=WHe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),uS=([t,e,r,n])=>`cubic-bezier(${t}, ${e}, ${r}, ${n})`,kX={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:uS([0,.65,.55,1]),circOut:uS([.55,0,1,.45]),backIn:uS([.31,.01,.66,-.59]),backOut:uS([.33,1.53,.69,.99])};function Zpe(t,e){if(t)return typeof t=="function"?Qpe()?Gpe(t,e):"ease-out":Dpe(t)?uS(t):Array.isArray(t)?t.map(r=>Zpe(r,e)||kX.easeOut):kX[t]}function qHe(t,e,r,{delay:n=0,duration:s=300,repeat:i=0,repeatType:a="loop",ease:o="easeOut",times:c}={},u=void 0){const d={[e]:r};c&&(d.offset=c);const h=Zpe(o,s);Array.isArray(h)&&(d.easing=h);const f={delay:n,duration:s,easing:Array.isArray(h)?"linear":h,fill:"both",iterations:i+1,direction:a==="reverse"?"alternate":"normal"};return u&&(f.pseudoElement=u),t.animate(d,f)}function eme(t){return typeof t=="function"&&"applyToOptions"in t}function GHe({type:t,...e}){return eme(t)&&Qpe()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class KHe extends cW{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,!e)return;const{element:r,name:n,keyframes:s,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:c}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,cP(typeof e.type!="string");const u=GHe(e);this.animation=qHe(r,n,s,u,i),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const d=lW(s,this.options,o,this.speed);this.updateMotionValue?this.updateMotionValue(d):UHe(r,n,d),this.animation.cancel()}c==null||c(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var e,r;(r=(e=this.animation).finish)==null||r.call(e)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var e,r;this.isPseudoElement||(r=(e=this.animation).commitStyles)==null||r.call(e)}get duration(){var r,n;const e=((n=(r=this.animation.effect)==null?void 0:r.getComputedTiming)==null?void 0:n.call(r).duration)||0;return fl(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+fl(e)}get time(){return fl(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=Su(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(e){this.animation.startTime=e}attachTimeline({timeline:e,observe:r}){var n;return this.allowFlatten&&((n=this.animation.effect)==null||n.updateTiming({easing:"linear"})),this.animation.onfinish=null,e&&HHe()?(this.animation.timeline=e,vl):r(this)}}const tme={anticipate:Ope,backInOut:Ppe,circInOut:Rpe};function YHe(t){return t in tme}function XHe(t){typeof t.ease=="string"&&YHe(t.ease)&&(t.ease=tme[t.ease])}const NX=10;class JHe extends KHe{constructor(e){XHe(e),Ype(e),super(e),e.startTime&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){const{motionValue:r,onUpdate:n,onComplete:s,element:i,...a}=this.options;if(!r)return;if(e!==void 0){r.set(e);return}const o=new uW({...a,autoplay:!1}),c=Su(this.finishedTime??this.time);r.setWithVelocity(o.sample(c-NX).value,o.sample(c).value,NX),o.stop()}}const EX=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Vp.test(t)||t==="0")&&!t.startsWith("url("));function QHe(t){const e=t[0];if(t.length===1)return!0;for(let r=0;r<t.length;r++)if(t[r]!==e)return!0}function ZHe(t,e,r,n){const s=t[0];if(s===null)return!1;if(e==="display"||e==="visibility")return!0;const i=t[t.length-1],a=EX(s,e),o=EX(i,e);return!a||!o?!1:QHe(t)||(r==="spring"||eme(r))&&n}function I6(t){t.duration=0,t.type="keyframes"}const eVe=new Set(["opacity","clipPath","filter","transform"]),tVe=ZV(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function rVe(t){var d;const{motionValue:e,name:r,repeatDelay:n,repeatType:s,damping:i,type:a}=t;if(!(((d=e==null?void 0:e.owner)==null?void 0:d.current)instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=e.owner.getProps();return tVe()&&r&&eVe.has(r)&&(r!=="transform"||!u)&&!c&&!n&&s!=="mirror"&&i!==0&&a!=="inertia"}const nVe=40;class sVe extends cW{constructor({autoplay:e=!0,delay:r=0,type:n="keyframes",repeat:s=0,repeatDelay:i=0,repeatType:a="loop",keyframes:o,name:c,motionValue:u,element:d,...h}){var m;super(),this.stop=()=>{var g,x;this._animation&&(this._animation.stop(),(g=this.stopTimeline)==null||g.call(this)),(x=this.keyframeResolver)==null||x.cancel()},this.createdAt=Ba.now();const f={autoplay:e,delay:r,type:n,repeat:s,repeatDelay:i,repeatType:a,name:c,motionValue:u,element:d,...h},p=(d==null?void 0:d.KeyframeResolver)||dW;this.keyframeResolver=new p(o,(g,x,y)=>this.onKeyframesResolved(g,x,f,!y),c,u,d),(m=this.keyframeResolver)==null||m.scheduleResolve()}onKeyframesResolved(e,r,n,s){this.keyframeResolver=void 0;const{name:i,type:a,velocity:o,delay:c,isHandoff:u,onUpdate:d}=n;this.resolvedAt=Ba.now(),ZHe(e,i,a,o)||((yh.instantAnimations||!c)&&(d==null||d(lW(e,n,r))),e[0]=e[e.length-1],I6(n),n.repeat=0);const f={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>nVe?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:e},p=!u&&rVe(f)?new JHe({...f,element:f.motionValue.owner.current}):new uW(f);p.finished.then(()=>this.notifyFinished()).catch(vl),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(e,r){return this.finished.finally(e).then(()=>{})}get animation(){var e;return this._animation||((e=this.keyframeResolver)==null||e.resume(),BHe()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var e;this._animation&&this.animation.cancel(),(e=this.keyframeResolver)==null||e.cancel()}}const iVe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function aVe(t){const e=iVe.exec(t);if(!e)return[,];const[,r,n,s]=e;return[`--${r??n}`,s]}function rme(t,e,r=1){const[n,s]=aVe(t);if(!n)return;const i=window.getComputedStyle(e).getPropertyValue(n);if(i){const a=i.trim();return _pe(a)?parseFloat(a):a}return nW(s)?rme(s,e,r+1):s}function hW(t,e){return(t==null?void 0:t[e])??(t==null?void 0:t.default)??t}const nme=new Set(["width","height","top","left","right","bottom",...Zw]),oVe={test:t=>t==="auto",parse:t=>t},sme=t=>e=>e.test(t),ime=[Qw,Pt,_u,Jh,QUe,JUe,oVe],AX=t=>ime.find(sme(t));function lVe(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||kpe(t):!0}const cVe=new Set(["brightness","contrast","saturate","opacity"]);function uVe(t){const[e,r]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[n]=r.match(sW)||[];if(!n)return t;const s=r.replace(n,"");let i=cVe.has(e)?1:0;return n!==r&&(i*=100),e+"("+i+s+")"}const dVe=/\b([a-z-]*)\(.*?\)/gu,R6={...Vp,getAnimatableNone:t=>{const e=t.match(dVe);return e?e.map(uVe).join(" "):t}},CX={...Qw,transform:Math.round},hVe={rotate:Jh,rotateX:Jh,rotateY:Jh,rotateZ:Jh,scale:VA,scaleX:VA,scaleY:VA,scaleZ:VA,skew:Jh,skewX:Jh,skewY:Jh,distance:Pt,translateX:Pt,translateY:Pt,translateZ:Pt,x:Pt,y:Pt,z:Pt,perspective:Pt,transformPerspective:Pt,opacity:gj,originX:gX,originY:gX,originZ:Pt},fW={borderWidth:Pt,borderTopWidth:Pt,borderRightWidth:Pt,borderBottomWidth:Pt,borderLeftWidth:Pt,borderRadius:Pt,radius:Pt,borderTopLeftRadius:Pt,borderTopRightRadius:Pt,borderBottomRightRadius:Pt,borderBottomLeftRadius:Pt,width:Pt,maxWidth:Pt,height:Pt,maxHeight:Pt,top:Pt,right:Pt,bottom:Pt,left:Pt,padding:Pt,paddingTop:Pt,paddingRight:Pt,paddingBottom:Pt,paddingLeft:Pt,margin:Pt,marginTop:Pt,marginRight:Pt,marginBottom:Pt,marginLeft:Pt,backgroundPositionX:Pt,backgroundPositionY:Pt,...hVe,zIndex:CX,fillOpacity:gj,strokeOpacity:gj,numOctaves:CX},fVe={...fW,color:as,backgroundColor:as,outlineColor:as,fill:as,stroke:as,borderColor:as,borderTopColor:as,borderRightColor:as,borderBottomColor:as,borderLeftColor:as,filter:R6,WebkitFilter:R6},ame=t=>fVe[t];function ome(t,e){let r=ame(t);return r!==R6&&(r=Vp),r.getAnimatableNone?r.getAnimatableNone(e):void 0}const pVe=new Set(["auto","none","0"]);function mVe(t,e,r){let n=0,s;for(;n<t.length&&!s;){const i=t[n];typeof i=="string"&&!pVe.has(i)&&yj(i).values.length&&(s=t[n]),n++}if(s&&r)for(const i of e)t[i]=ome(r,s)}class gVe extends dW{constructor(e,r,n,s,i){super(e,r,n,s,i,!0)}readKeyframes(){const{unresolvedKeyframes:e,element:r,name:n}=this;if(!r||!r.current)return;super.readKeyframes();for(let c=0;c<e.length;c++){let u=e[c];if(typeof u=="string"&&(u=u.trim(),nW(u))){const d=rme(u,r.current);d!==void 0&&(e[c]=d),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!nme.has(n)||e.length!==2)return;const[s,i]=e,a=AX(s),o=AX(i);if(a!==o)if(jX(a)&&jX(o))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else Cy[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:r}=this,n=[];for(let s=0;s<e.length;s++)(e[s]===null||lVe(e[s]))&&n.push(s);n.length&&mVe(e,n,r)}measureInitialState(){const{element:e,unresolvedKeyframes:r,name:n}=this;if(!e||!e.current)return;n==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Cy[n](e.measureViewportBox(),window.getComputedStyle(e.current)),r[0]=this.measuredOrigin;const s=r[r.length-1];s!==void 0&&e.getValue(n,s).jump(s,!1)}measureEndState(){var o;const{element:e,name:r,unresolvedKeyframes:n}=this;if(!e||!e.current)return;const s=e.getValue(r);s&&s.jump(this.measuredOrigin,!1);const i=n.length-1,a=n[i];n[i]=Cy[r](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),(o=this.removedTransforms)!=null&&o.length&&this.removedTransforms.forEach(([c,u])=>{e.getValue(c).set(u)}),this.resolveNoneKeyframes()}}function lme(t,e,r){if(t instanceof EventTarget)return[t];if(typeof t=="string"){const s=document.querySelectorAll(t);return s?Array.from(s):[]}return Array.from(t)}const cme=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function yVe(t){return jpe(t)&&"offsetHeight"in t}const TX=30,xVe=t=>!isNaN(parseFloat(t));class vVe{constructor(e,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var i;const s=Ba.now();if(this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&((i=this.events.change)==null||i.notify(this.current),this.dependents))for(const a of this.dependents)a.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=r.owner}setCurrent(e){this.current=e,this.updatedAt=Ba.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=xVe(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,r){this.events[e]||(this.events[e]=new eW);const n=this.events[e].add(r);return e==="change"?()=>{n(),Sn.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(const e in this.events)this.events[e].clear()}attach(e,r){this.passiveEffect=e,this.stopPassiveEffect=r}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,r,n){this.set(r),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,r=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,r&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var e;(e=this.events.change)==null||e.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=Ba.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>TX)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,TX);return Npe(parseFloat(this.current)-parseFloat(this.prevFrameValue),r)}start(e){return this.stop(),new Promise(r=>{this.hasAnimated=!0,this.animation=e(r),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var e,r;(e=this.dependents)==null||e.clear(),(r=this.events.destroy)==null||r.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Y0(t,e){return new vVe(t,e)}const{schedule:pW,cancel:f5t}=Lpe(queueMicrotask,!1),$l={x:!1,y:!1};function ume(){return $l.x||$l.y}function bVe(t){return t==="x"||t==="y"?$l[t]?null:($l[t]=!0,()=>{$l[t]=!1}):$l.x||$l.y?null:($l.x=$l.y=!0,()=>{$l.x=$l.y=!1})}function dme(t,e){const r=lme(t),n=new AbortController,s={passive:!0,...e,signal:n.signal};return[r,s,()=>n.abort()]}function PX(t){return!(t.pointerType==="touch"||ume())}function wVe(t,e,r={}){const[n,s,i]=dme(t,r),a=o=>{if(!PX(o))return;const{target:c}=o,u=e(c,o);if(typeof u!="function"||!c)return;const d=h=>{PX(h)&&(u(h),c.removeEventListener("pointerleave",d))};c.addEventListener("pointerleave",d,s)};return n.forEach(o=>{o.addEventListener("pointerenter",a,s)}),i}const hme=(t,e)=>e?t===e?!0:hme(t,e.parentElement):!1,mW=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,SVe=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function _Ve(t){return SVe.has(t.tagName)||t.tabIndex!==-1}const yT=new WeakSet;function OX(t){return e=>{e.key==="Enter"&&t(e)}}function YL(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const jVe=(t,e)=>{const r=t.currentTarget;if(!r)return;const n=OX(()=>{if(yT.has(r))return;YL(r,"down");const s=OX(()=>{YL(r,"up")}),i=()=>YL(r,"cancel");r.addEventListener("keyup",s,e),r.addEventListener("blur",i,e)});r.addEventListener("keydown",n,e),r.addEventListener("blur",()=>r.removeEventListener("keydown",n),e)};function IX(t){return mW(t)&&!ume()}function kVe(t,e,r={}){const[n,s,i]=dme(t,r),a=o=>{const c=o.currentTarget;if(!IX(o))return;yT.add(c);const u=e(c,o),d=(p,m)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",f),yT.has(c)&&yT.delete(c),IX(p)&&typeof u=="function"&&u(p,{success:m})},h=p=>{d(p,c===window||c===document||r.useGlobalTarget||hme(c,p.target))},f=p=>{d(p,!1)};window.addEventListener("pointerup",h,s),window.addEventListener("pointercancel",f,s)};return n.forEach(o=>{(r.useGlobalTarget?window:o).addEventListener("pointerdown",a,s),yVe(o)&&(o.addEventListener("focus",u=>jVe(u,s)),!_Ve(o)&&!o.hasAttribute("tabindex")&&(o.tabIndex=0))}),i}function fme(t){return jpe(t)&&"ownerSVGElement"in t}function NVe(t){return fme(t)&&t.tagName==="svg"}const Fi=t=>!!(t&&t.getVelocity),EVe=[...ime,as,Vp],AVe=t=>EVe.find(sme(t)),pme=j.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function CVe(t=!0){const e=j.useContext(XV);if(e===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:s}=e,i=j.useId();j.useEffect(()=>{if(t)return s(i)},[t]);const a=j.useCallback(()=>t&&n&&n(i),[i,n,t]);return!r&&n?[!1,a]:[!0]}const mme=j.createContext({strict:!1}),RX={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},X0={};for(const t in RX)X0[t]={isEnabled:e=>RX[t].some(r=>!!e[r])};function TVe(t){for(const e in t)X0[e]={...X0[e],...t[e]}}const PVe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function fP(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||PVe.has(t)}let gme=t=>!fP(t);function OVe(t){typeof t=="function"&&(gme=e=>e.startsWith("on")?!fP(e):t(e))}try{OVe(require("@emotion/is-prop-valid").default)}catch{}function IVe(t,e,r){const n={};for(const s in t)s==="values"&&typeof t.values=="object"||(gme(s)||r===!0&&fP(s)||!e&&!fP(s)||t.draggable&&s.startsWith("onDrag"))&&(n[s]=t[s]);return n}const BR=j.createContext({});function zR(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function xj(t){return typeof t=="string"||Array.isArray(t)}const gW=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],yW=["initial",...gW];function UR(t){return zR(t.animate)||yW.some(e=>xj(t[e]))}function yme(t){return!!(UR(t)||t.variants)}function RVe(t,e){if(UR(t)){const{initial:r,animate:n}=t;return{initial:r===!1||xj(r)?r:void 0,animate:xj(n)?n:void 0}}return t.inherit!==!1?e:{}}function MVe(t){const{initial:e,animate:r}=RVe(t,j.useContext(BR));return j.useMemo(()=>({initial:e,animate:r}),[MX(e),MX(r)])}function MX(t){return Array.isArray(t)?t.join(" "):t}function DX(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const R1={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(Pt.test(t))t=parseFloat(t);else return t;const r=DX(t,e.target.x),n=DX(t,e.target.y);return`${r}% ${n}%`}},DVe={correct:(t,{treeScale:e,projectionDelta:r})=>{const n=t,s=Vp.parse(t);if(s.length>5)return n;const i=Vp.createTransformer(t),a=typeof s[0]!="number"?1:0,o=r.x.scale*e.x,c=r.y.scale*e.y;s[0+a]/=o,s[1+a]/=c;const u=En(o,c,.5);return typeof s[2+a]=="number"&&(s[2+a]/=u),typeof s[3+a]=="number"&&(s[3+a]/=u),i(s)}},M6={borderRadius:{...R1,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:R1,borderTopRightRadius:R1,borderBottomLeftRadius:R1,borderBottomRightRadius:R1,boxShadow:DVe};function xme(t,{layout:e,layoutId:r}){return e1.has(t)||t.startsWith("origin")||(e||r!==void 0)&&(!!M6[t]||t==="opacity")}const LVe={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},FVe=Zw.length;function $Ve(t,e,r){let n="",s=!0;for(let i=0;i<FVe;i++){const a=Zw[i],o=t[a];if(o===void 0)continue;let c=!0;if(typeof o=="number"?c=o===(a.startsWith("scale")?1:0):c=parseFloat(o)===0,!c||r){const u=cme(o,fW[a]);if(!c){s=!1;const d=LVe[a]||a;n+=`${d}(${u}) `}r&&(e[a]=u)}}return n=n.trim(),r?n=r(e,s?"":n):s&&(n="none"),n}function xW(t,e,r){const{style:n,vars:s,transformOrigin:i}=t;let a=!1,o=!1;for(const c in e){const u=e[c];if(e1.has(c)){a=!0;continue}else if($pe(c)){s[c]=u;continue}else{const d=cme(u,fW[c]);c.startsWith("origin")?(o=!0,i[c]=d):n[c]=d}}if(e.transform||(a||r?n.transform=$Ve(e,t.transform,r):n.transform&&(n.transform="none")),o){const{originX:c="50%",originY:u="50%",originZ:d=0}=i;n.transformOrigin=`${c} ${u} ${d}`}}const vW=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function vme(t,e,r){for(const n in e)!Fi(e[n])&&!xme(n,r)&&(t[n]=e[n])}function BVe({transformTemplate:t},e){return j.useMemo(()=>{const r=vW();return xW(r,e,t),Object.assign({},r.vars,r.style)},[e])}function zVe(t,e){const r=t.style||{},n={};return vme(n,r,t),Object.assign(n,BVe(t,e)),n}function UVe(t,e){const r={},n=zVe(t,e);return t.drag&&t.dragListener!==!1&&(r.draggable=!1,n.userSelect=n.WebkitUserSelect=n.WebkitTouchCallout="none",n.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(r.tabIndex=0),r.style=n,r}const HVe={offset:"stroke-dashoffset",array:"stroke-dasharray"},VVe={offset:"strokeDashoffset",array:"strokeDasharray"};function WVe(t,e,r=1,n=0,s=!0){t.pathLength=1;const i=s?HVe:VVe;t[i.offset]=Pt.transform(-n);const a=Pt.transform(e),o=Pt.transform(r);t[i.array]=`${a} ${o}`}function bme(t,{attrX:e,attrY:r,attrScale:n,pathLength:s,pathSpacing:i=1,pathOffset:a=0,...o},c,u,d){if(xW(t,o,u),c){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:h,style:f}=t;h.transform&&(f.transform=h.transform,delete h.transform),(f.transform||h.transformOrigin)&&(f.transformOrigin=h.transformOrigin??"50% 50%",delete h.transformOrigin),f.transform&&(f.transformBox=(d==null?void 0:d.transformBox)??"fill-box",delete h.transformBox),e!==void 0&&(h.x=e),r!==void 0&&(h.y=r),n!==void 0&&(h.scale=n),s!==void 0&&WVe(h,s,i,a,!1)}const wme=()=>({...vW(),attrs:{}}),Sme=t=>typeof t=="string"&&t.toLowerCase()==="svg";function qVe(t,e,r,n){const s=j.useMemo(()=>{const i=wme();return bme(i,e,Sme(n),t.transformTemplate,t.style),{...i.attrs,style:{...i.style}}},[e]);if(t.style){const i={};vme(i,t.style,t),s.style={...i,...s.style}}return s}const GVe=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function bW(t){return typeof t!="string"||t.includes("-")?!1:!!(GVe.indexOf(t)>-1||/[A-Z]/u.test(t))}function KVe(t,e,r,{latestValues:n},s,i=!1){const o=(bW(t)?qVe:UVe)(e,n,s,t),c=IVe(e,typeof t=="string",i),u=t!==j.Fragment?{...c,...o,ref:r}:{},{children:d}=e,h=j.useMemo(()=>Fi(d)?d.get():d,[d]);return j.createElement(t,{...u,children:h})}function LX(t){const e=[{},{}];return t==null||t.values.forEach((r,n)=>{e[0][n]=r.get(),e[1][n]=r.getVelocity()}),e}function wW(t,e,r,n){if(typeof e=="function"){const[s,i]=LX(n);e=e(r!==void 0?r:t.custom,s,i)}if(typeof e=="string"&&(e=t.variants&&t.variants[e]),typeof e=="function"){const[s,i]=LX(n);e=e(r!==void 0?r:t.custom,s,i)}return e}function xT(t){return Fi(t)?t.get():t}function YVe({scrapeMotionValuesFromProps:t,createRenderState:e},r,n,s){return{latestValues:XVe(r,n,s,t),renderState:e()}}function XVe(t,e,r,n){const s={},i=n(t,{});for(const f in i)s[f]=xT(i[f]);let{initial:a,animate:o}=t;const c=UR(t),u=yme(t);e&&u&&!c&&t.inherit!==!1&&(a===void 0&&(a=e.initial),o===void 0&&(o=e.animate));let d=r?r.initial===!1:!1;d=d||a===!1;const h=d?o:a;if(h&&typeof h!="boolean"&&!zR(h)){const f=Array.isArray(h)?h:[h];for(let p=0;p<f.length;p++){const m=wW(t,f[p]);if(m){const{transitionEnd:g,transition:x,...y}=m;for(const v in y){let b=y[v];if(Array.isArray(b)){const w=d?b.length-1:0;b=b[w]}b!==null&&(s[v]=b)}for(const v in g)s[v]=g[v]}}}return s}const _me=t=>(e,r)=>{const n=j.useContext(BR),s=j.useContext(XV),i=()=>YVe(t,e,n,s);return r?i():OUe(i)};function SW(t,e,r){var i;const{style:n}=t,s={};for(const a in n)(Fi(n[a])||e.style&&Fi(e.style[a])||xme(a,t)||((i=r==null?void 0:r.getValue(a))==null?void 0:i.liveStyle)!==void 0)&&(s[a]=n[a]);return s}const JVe=_me({scrapeMotionValuesFromProps:SW,createRenderState:vW});function jme(t,e,r){const n=SW(t,e,r);for(const s in t)if(Fi(t[s])||Fi(e[s])){const i=Zw.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;n[i]=t[s]}return n}const QVe=_me({scrapeMotionValuesFromProps:jme,createRenderState:wme}),ZVe=Symbol.for("motionComponentSymbol");function Iv(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function eWe(t,e,r){return j.useCallback(n=>{n&&t.onMount&&t.onMount(n),e&&(n?e.mount(n):e.unmount()),r&&(typeof r=="function"?r(n):Iv(r)&&(r.current=n))},[e])}const _W=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),tWe="framerAppearId",kme="data-"+_W(tWe),Nme=j.createContext({});function rWe(t,e,r,n,s){var g,x;const{visualElement:i}=j.useContext(BR),a=j.useContext(mme),o=j.useContext(XV),c=j.useContext(pme).reducedMotion,u=j.useRef(null);n=n||a.renderer,!u.current&&n&&(u.current=n(t,{visualState:e,parent:i,props:r,presenceContext:o,blockInitialAnimation:o?o.initial===!1:!1,reducedMotionConfig:c}));const d=u.current,h=j.useContext(Nme);d&&!d.projection&&s&&(d.type==="html"||d.type==="svg")&&nWe(u.current,r,s,h);const f=j.useRef(!1);j.useInsertionEffect(()=>{d&&f.current&&d.update(r,o)});const p=r[kme],m=j.useRef(!!p&&!((g=window.MotionHandoffIsComplete)!=null&&g.call(window,p))&&((x=window.MotionHasOptimisedAnimation)==null?void 0:x.call(window,p)));return IUe(()=>{d&&(f.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),d.scheduleRenderMicrotask(),m.current&&d.animationState&&d.animationState.animateChanges())}),j.useEffect(()=>{d&&(!m.current&&d.animationState&&d.animationState.animateChanges(),m.current&&(queueMicrotask(()=>{var y;(y=window.MotionHandoffMarkAsComplete)==null||y.call(window,p)}),m.current=!1),d.enteringChildren=void 0)}),d}function nWe(t,e,r,n){const{layoutId:s,layout:i,drag:a,dragConstraints:o,layoutScroll:c,layoutRoot:u,layoutCrossfade:d}=e;t.projection=new r(t.latestValues,e["data-framer-portal-id"]?void 0:Eme(t.parent)),t.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!a||o&&Iv(o),visualElement:t,animationType:typeof i=="string"?i:"both",initialPromotionConfig:n,crossfade:d,layoutScroll:c,layoutRoot:u})}function Eme(t){if(t)return t.options.allowProjection!==!1?t.projection:Eme(t.parent)}function XL(t,{forwardMotionProps:e=!1}={},r,n){r&&TVe(r);const s=bW(t)?QVe:JVe;function i(o,c){let u;const d={...j.useContext(pme),...o,layoutId:sWe(o)},{isStatic:h}=d,f=MVe(o),p=s(o,h);if(!h&&YV){iWe();const m=aWe(d);u=m.MeasureLayout,f.visualElement=rWe(t,p,d,n,m.ProjectionNode)}return l.jsxs(BR.Provider,{value:f,children:[u&&f.visualElement?l.jsx(u,{visualElement:f.visualElement,...d}):null,KVe(t,o,eWe(p,f.visualElement,c),p,h,e)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const a=j.forwardRef(i);return a[ZVe]=t,a}function sWe({layoutId:t}){const e=j.useContext(Spe).id;return e&&t!==void 0?e+"-"+t:t}function iWe(t,e){j.useContext(mme).strict}function aWe(t){const{drag:e,layout:r}=X0;if(!e&&!r)return{};const n={...e,...r};return{MeasureLayout:e!=null&&e.isEnabled(t)||r!=null&&r.isEnabled(t)?n.MeasureLayout:void 0,ProjectionNode:n.ProjectionNode}}function oWe(t,e){if(typeof Proxy>"u")return XL;const r=new Map,n=(i,a)=>XL(i,a,t,e),s=(i,a)=>n(i,a);return new Proxy(s,{get:(i,a)=>a==="create"?n:(r.has(a)||r.set(a,XL(a,void 0,t,e)),r.get(a))})}function Ame({top:t,left:e,right:r,bottom:n}){return{x:{min:e,max:r},y:{min:t,max:n}}}function lWe({x:t,y:e}){return{top:e.min,right:t.max,bottom:e.max,left:t.min}}function cWe(t,e){if(!e)return t;const r=e({x:t.left,y:t.top}),n=e({x:t.right,y:t.bottom});return{top:r.y,left:r.x,bottom:n.y,right:n.x}}function JL(t){return t===void 0||t===1}function D6({scale:t,scaleX:e,scaleY:r}){return!JL(t)||!JL(e)||!JL(r)}function Dm(t){return D6(t)||Cme(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Cme(t){return FX(t.x)||FX(t.y)}function FX(t){return t&&t!=="0%"}function pP(t,e,r){const n=t-r,s=e*n;return r+s}function $X(t,e,r,n,s){return s!==void 0&&(t=pP(t,s,n)),pP(t,r,n)+e}function L6(t,e=0,r=1,n,s){t.min=$X(t.min,e,r,n,s),t.max=$X(t.max,e,r,n,s)}function Tme(t,{x:e,y:r}){L6(t.x,e.translate,e.scale,e.originPoint),L6(t.y,r.translate,r.scale,r.originPoint)}const BX=.999999999999,zX=1.0000000000001;function uWe(t,e,r,n=!1){const s=r.length;if(!s)return;e.x=e.y=1;let i,a;for(let o=0;o<s;o++){i=r[o],a=i.projectionDelta;const{visualElement:c}=i.options;c&&c.props.style&&c.props.style.display==="contents"||(n&&i.options.layoutScroll&&i.scroll&&i!==i.root&&Mv(t,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),a&&(e.x*=a.x.scale,e.y*=a.y.scale,Tme(t,a)),n&&Dm(i.latestValues)&&Mv(t,i.latestValues))}e.x<zX&&e.x>BX&&(e.x=1),e.y<zX&&e.y>BX&&(e.y=1)}function Rv(t,e){t.min=t.min+e,t.max=t.max+e}function UX(t,e,r,n,s=.5){const i=En(t.min,t.max,s);L6(t,e,r,i,n)}function Mv(t,e){UX(t.x,e.x,e.scaleX,e.scale,e.originX),UX(t.y,e.y,e.scaleY,e.scale,e.originY)}function Pme(t,e){return Ame(cWe(t.getBoundingClientRect(),e))}function dWe(t,e,r){const n=Pme(t,r),{scroll:s}=e;return s&&(Rv(n.x,s.offset.x),Rv(n.y,s.offset.y)),n}const HX=()=>({translate:0,scale:1,origin:0,originPoint:0}),Dv=()=>({x:HX(),y:HX()}),VX=()=>({min:0,max:0}),js=()=>({x:VX(),y:VX()}),F6={current:null},Ome={current:!1};function hWe(){if(Ome.current=!0,!!YV)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>F6.current=t.matches;t.addEventListener("change",e),e()}else F6.current=!1}const fWe=new WeakMap;function pWe(t,e,r){for(const n in e){const s=e[n],i=r[n];if(Fi(s))t.addValue(n,s);else if(Fi(i))t.addValue(n,Y0(s,{owner:t}));else if(i!==s)if(t.hasValue(n)){const a=t.getValue(n);a.liveStyle===!0?a.jump(s):a.hasAnimated||a.set(s)}else{const a=t.getStaticValue(n);t.addValue(n,Y0(a!==void 0?a:s,{owner:t}))}}for(const n in r)e[n]===void 0&&t.removeValue(n);return e}const WX=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class mWe{scrapeMotionValuesFromProps(e,r,n){return{}}constructor({parent:e,props:r,presenceContext:n,reducedMotionConfig:s,blockInitialAnimation:i,visualState:a},o={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=dW,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const f=Ba.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,Sn.render(this.render,!1,!0))};const{latestValues:c,renderState:u}=a;this.latestValues=c,this.baseTarget={...c},this.initialValues=r.initial?{...c}:{},this.renderState=u,this.parent=e,this.props=r,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=s,this.options=o,this.blockInitialAnimation=!!i,this.isControllingVariants=UR(r),this.isVariantNode=yme(r),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);const{willChange:d,...h}=this.scrapeMotionValuesFromProps(r,{},this);for(const f in h){const p=h[f];c[f]!==void 0&&Fi(p)&&p.set(c[f])}}mount(e){var r;this.current=e,fWe.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,s)=>this.bindToMotionValue(s,n)),Ome.current||hWe(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:F6.current,(r=this.parent)==null||r.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var e;this.projection&&this.projection.unmount(),Hp(this.notifyUpdate),Hp(this.render),this.valueSubscriptions.forEach(r=>r()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(e=this.parent)==null||e.removeChild(this);for(const r in this.events)this.events[r].clear();for(const r in this.features){const n=this.features[r];n&&(n.unmount(),n.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,r){this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)();const n=e1.has(e);n&&this.onBindTransform&&this.onBindTransform();const s=r.on("change",a=>{this.latestValues[e]=a,this.props.onUpdate&&Sn.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let i;window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,r)),this.valueSubscriptions.set(e,()=>{s(),i&&i(),r.owner&&r.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in X0){const r=X0[e];if(!r)continue;const{isEnabled:n,Feature:s}=r;if(!this.features[e]&&s&&n(this.props)&&(this.features[e]=new s(this)),this.features[e]){const i=this.features[e];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):js()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,r){this.latestValues[e]=r}update(e,r){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=r;for(let n=0;n<WX.length;n++){const s=WX[n];this.propEventSubscriptions[s]&&(this.propEventSubscriptions[s](),delete this.propEventSubscriptions[s]);const i="on"+s,a=e[i];a&&(this.propEventSubscriptions[s]=this.on(s,a))}this.prevMotionValues=pWe(this,this.scrapeMotionValuesFromProps(e,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){const r=this.getClosestVariantNode();if(r)return r.variantChildren&&r.variantChildren.add(e),()=>r.variantChildren.delete(e)}addValue(e,r){const n=this.values.get(e);r!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,r),this.values.set(e,r),this.latestValues[e]=r.get())}removeValue(e){this.values.delete(e);const r=this.valueSubscriptions.get(e);r&&(r(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,r){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&r!==void 0&&(n=Y0(r===null?void 0:r,{owner:this}),this.addValue(e,n)),n}readValue(e,r){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n=="string"&&(_pe(n)||kpe(n))?n=parseFloat(n):!AVe(n)&&Vp.test(r)&&(n=ome(e,r)),this.setBaseTarget(e,Fi(n)?n.get():n)),Fi(n)?n.get():n}setBaseTarget(e,r){this.baseTarget[e]=r}getBaseTarget(e){var i;const{initial:r}=this.props;let n;if(typeof r=="string"||typeof r=="object"){const a=wW(this.props,r,(i=this.presenceContext)==null?void 0:i.custom);a&&(n=a[e])}if(r&&n!==void 0)return n;const s=this.getBaseTargetFromProps(this.props,e);return s!==void 0&&!Fi(s)?s:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,r){return this.events[e]||(this.events[e]=new eW),this.events[e].add(r)}notify(e,...r){this.events[e]&&this.events[e].notify(...r)}scheduleRenderMicrotask(){pW.render(this.render)}}class Ime extends mWe{constructor(){super(...arguments),this.KeyframeResolver=gVe}sortInstanceNodePosition(e,r){return e.compareDocumentPosition(r)&2?1:-1}getBaseTargetFromProps(e,r){return e.style?e.style[r]:void 0}removeValueFromRenderState(e,{vars:r,style:n}){delete r[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:e}=this.props;Fi(e)&&(this.childSubscription=e.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}function Rme(t,{style:e,vars:r},n,s){const i=t.style;let a;for(a in e)i[a]=e[a];s==null||s.applyProjectionStyles(i,n);for(a in r)i.setProperty(a,r[a])}function gWe(t){return window.getComputedStyle(t)}class yWe extends Ime{constructor(){super(...arguments),this.type="html",this.renderInstance=Rme}readValueFromInstance(e,r){var n;if(e1.has(r))return(n=this.projection)!=null&&n.isProjecting?A6(r):MHe(e,r);{const s=gWe(e),i=($pe(r)?s.getPropertyValue(r):s[r])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:r}){return Pme(e,r)}build(e,r,n){xW(e,r,n.transformTemplate)}scrapeMotionValuesFromProps(e,r,n){return SW(e,r,n)}}const Mme=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function xWe(t,e,r,n){Rme(t,e,void 0,n);for(const s in e.attrs)t.setAttribute(Mme.has(s)?s:_W(s),e.attrs[s])}class vWe extends Ime{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=js}getBaseTargetFromProps(e,r){return e[r]}readValueFromInstance(e,r){if(e1.has(r)){const n=ame(r);return n&&n.default||0}return r=Mme.has(r)?r:_W(r),e.getAttribute(r)}scrapeMotionValuesFromProps(e,r,n){return jme(e,r,n)}build(e,r,n){bme(e,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,r,n,s){xWe(e,r,n,s)}mount(e){this.isSVGTag=Sme(e.tagName),super.mount(e)}}const bWe=(t,e)=>bW(t)?new vWe(e):new yWe(e,{allowProjection:t!==j.Fragment});function ab(t,e,r){const n=t.getProps();return wW(n,e,r!==void 0?r:n.custom,t)}const $6=t=>Array.isArray(t);function wWe(t,e,r){t.hasValue(e)?t.getValue(e).set(r):t.addValue(e,Y0(r))}function SWe(t){return $6(t)?t[t.length-1]||0:t}function _We(t,e){const r=ab(t,e);let{transitionEnd:n={},transition:s={},...i}=r||{};i={...i,...n};for(const a in i){const o=SWe(i[a]);wWe(t,a,o)}}function jWe(t){return!!(Fi(t)&&t.add)}function B6(t,e){const r=t.getValue("willChange");if(jWe(r))return r.add(e);if(!r&&yh.WillChange){const n=new yh.WillChange("auto");t.addValue("willChange",n),n.add(e)}}function Dme(t){return t.props[kme]}const kWe=t=>t!==null;function NWe(t,{repeat:e,repeatType:r="loop"},n){const s=t.filter(kWe),i=e&&r!=="loop"&&e%2===1?0:s.length-1;return!i||n===void 0?s[i]:n}const EWe={type:"spring",stiffness:500,damping:25,restSpeed:10},AWe=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),CWe={type:"keyframes",duration:.8},TWe={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},PWe=(t,{keyframes:e})=>e.length>2?CWe:e1.has(t)?t.startsWith("scale")?AWe(e[1]):EWe:TWe;function OWe({when:t,delay:e,delayChildren:r,staggerChildren:n,staggerDirection:s,repeat:i,repeatType:a,repeatDelay:o,from:c,elapsed:u,...d}){return!!Object.keys(d).length}const jW=(t,e,r,n={},s,i)=>a=>{const o=hW(n,t)||{},c=o.delay||n.delay||0;let{elapsed:u=0}=n;u=u-Su(c);const d={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:e.getVelocity(),...o,delay:-u,onUpdate:f=>{e.set(f),o.onUpdate&&o.onUpdate(f)},onComplete:()=>{a(),o.onComplete&&o.onComplete()},name:t,motionValue:e,element:i?void 0:s};OWe(o)||Object.assign(d,PWe(t,d)),d.duration&&(d.duration=Su(d.duration)),d.repeatDelay&&(d.repeatDelay=Su(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let h=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(I6(d),d.delay===0&&(h=!0)),(yh.instantAnimations||yh.skipAnimations)&&(h=!0,I6(d),d.delay=0),d.allowFlatten=!o.type&&!o.ease,h&&!i&&e.get()!==void 0){const f=NWe(d.keyframes,o);if(f!==void 0){Sn.update(()=>{d.onUpdate(f),d.onComplete()});return}}return o.isSync?new uW(d):new sVe(d)};function IWe({protectedKeys:t,needsAnimating:e},r){const n=t.hasOwnProperty(r)&&e[r]!==!0;return e[r]=!1,n}function Lme(t,e,{delay:r=0,transitionOverride:n,type:s}={}){let{transition:i=t.getDefaultTransition(),transitionEnd:a,...o}=e;n&&(i=n);const c=[],u=s&&t.animationState&&t.animationState.getState()[s];for(const d in o){const h=t.getValue(d,t.latestValues[d]??null),f=o[d];if(f===void 0||u&&IWe(u,d))continue;const p={delay:r,...hW(i||{},d)},m=h.get();if(m!==void 0&&!h.isAnimating&&!Array.isArray(f)&&f===m&&!p.velocity)continue;let g=!1;if(window.MotionHandoffAnimation){const y=Dme(t);if(y){const v=window.MotionHandoffAnimation(y,d,Sn);v!==null&&(p.startTime=v,g=!0)}}B6(t,d),h.start(jW(d,h,f,t.shouldReduceMotion&&nme.has(d)?{type:!1}:p,t,g));const x=h.animation;x&&c.push(x)}return a&&Promise.all(c).then(()=>{Sn.update(()=>{a&&_We(t,a)})}),c}function Fme(t,e,r,n=0,s=1){const i=Array.from(t).sort((u,d)=>u.sortNodePosition(d)).indexOf(e),a=t.size,o=(a-1)*n;return typeof r=="function"?r(i,a):s===1?i*n:o-i*n}function z6(t,e,r={}){var c;const n=ab(t,e,r.type==="exit"?(c=t.presenceContext)==null?void 0:c.custom:void 0);let{transition:s=t.getDefaultTransition()||{}}=n||{};r.transitionOverride&&(s=r.transitionOverride);const i=n?()=>Promise.all(Lme(t,n,r)):()=>Promise.resolve(),a=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:d=0,staggerChildren:h,staggerDirection:f}=s;return RWe(t,e,u,d,h,f,r)}:()=>Promise.resolve(),{when:o}=s;if(o){const[u,d]=o==="beforeChildren"?[i,a]:[a,i];return u().then(()=>d())}else return Promise.all([i(),a(r.delay)])}function RWe(t,e,r=0,n=0,s=0,i=1,a){const o=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),o.push(z6(c,e,{...a,delay:r+(typeof n=="function"?0:n)+Fme(t.variantChildren,c,n,s,i)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(o)}function MWe(t,e,r={}){t.notify("AnimationStart",e);let n;if(Array.isArray(e)){const s=e.map(i=>z6(t,i,r));n=Promise.all(s)}else if(typeof e=="string")n=z6(t,e,r);else{const s=typeof e=="function"?ab(t,e,r.custom):e;n=Promise.all(Lme(t,s,r))}return n.then(()=>{t.notify("AnimationComplete",e)})}function $me(t,e){if(!Array.isArray(e))return!1;const r=e.length;if(r!==t.length)return!1;for(let n=0;n<r;n++)if(e[n]!==t[n])return!1;return!0}const DWe=yW.length;function Bme(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?Bme(t.parent)||{}:{};return t.props.initial!==void 0&&(r.initial=t.props.initial),r}const e={};for(let r=0;r<DWe;r++){const n=yW[r],s=t.props[n];(xj(s)||s===!1)&&(e[n]=s)}return e}const LWe=[...gW].reverse(),FWe=gW.length;function $We(t){return e=>Promise.all(e.map(({animation:r,options:n})=>MWe(t,r,n)))}function BWe(t){let e=$We(t),r=qX(),n=!0;const s=c=>(u,d)=>{var f;const h=ab(t,d,c==="exit"?(f=t.presenceContext)==null?void 0:f.custom:void 0);if(h){const{transition:p,transitionEnd:m,...g}=h;u={...u,...g,...m}}return u};function i(c){e=c(t)}function a(c){const{props:u}=t,d=Bme(t.parent)||{},h=[],f=new Set;let p={},m=1/0;for(let x=0;x<FWe;x++){const y=LWe[x],v=r[y],b=u[y]!==void 0?u[y]:d[y],w=xj(b),S=y===c?v.isActive:null;S===!1&&(m=x);let k=b===d[y]&&b!==u[y]&&w;if(k&&n&&t.manuallyAnimateOnMount&&(k=!1),v.protectedKeys={...p},!v.isActive&&S===null||!b&&!v.prevProp||zR(b)||typeof b=="boolean")continue;const E=zWe(v.prevProp,b);let C=E||y===c&&v.isActive&&!k&&w||x>m&&w,A=!1;const M=Array.isArray(b)?b:[b];let z=M.reduce(s(y),{});S===!1&&(z={});const{prevResolvedValues:P={}}=v,W={...P,...z},N=G=>{C=!0,f.has(G)&&(A=!0,f.delete(G)),v.needsAnimating[G]=!0;const X=t.getValue(G);X&&(X.liveStyle=!1)};for(const G in W){const X=z[G],H=P[G];if(p.hasOwnProperty(G))continue;let B=!1;$6(X)&&$6(H)?B=!$me(X,H):B=X!==H,B?X!=null?N(G):f.add(G):X!==void 0&&f.has(G)?N(G):v.protectedKeys[G]=!0}v.prevProp=b,v.prevResolvedValues=z,v.isActive&&(p={...p,...z}),n&&t.blockInitialAnimation&&(C=!1);const U=k&&E;C&&(!U||A)&&h.push(...M.map(G=>{const X={type:y};if(typeof G=="string"&&n&&!U&&t.manuallyAnimateOnMount&&t.parent){const{parent:H}=t,B=ab(H,G);if(H.enteringChildren&&B){const{delayChildren:L}=B.transition||{};X.delay=Fme(H.enteringChildren,t,L)}}return{animation:G,options:X}}))}if(f.size){const x={};if(typeof u.initial!="boolean"){const y=ab(t,Array.isArray(u.initial)?u.initial[0]:u.initial);y&&y.transition&&(x.transition=y.transition)}f.forEach(y=>{const v=t.getBaseTarget(y),b=t.getValue(y);b&&(b.liveStyle=!0),x[y]=v??null}),h.push({animation:x})}let g=!!h.length;return n&&(u.initial===!1||u.initial===u.animate)&&!t.manuallyAnimateOnMount&&(g=!1),n=!1,g?e(h):Promise.resolve()}function o(c,u){var h;if(r[c].isActive===u)return Promise.resolve();(h=t.variantChildren)==null||h.forEach(f=>{var p;return(p=f.animationState)==null?void 0:p.setActive(c,u)}),r[c].isActive=u;const d=a(c);for(const f in r)r[f].protectedKeys={};return d}return{animateChanges:a,setActive:o,setAnimateFunction:i,getState:()=>r,reset:()=>{r=qX()}}}function zWe(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!$me(e,t):!1}function _m(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function qX(){return{animate:_m(!0),whileInView:_m(),whileHover:_m(),whileTap:_m(),whileDrag:_m(),whileFocus:_m(),exit:_m()}}class om{constructor(e){this.isMounted=!1,this.node=e}update(){}}class UWe extends om{constructor(e){super(e),e.animationState||(e.animationState=BWe(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();zR(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:e}=this.node.getProps(),{animate:r}=this.node.prevProps||{};e!==r&&this.updateAnimationControlsSubscription()}unmount(){var e;this.node.animationState.reset(),(e=this.unmountControls)==null||e.call(this)}}let HWe=0;class VWe extends om{constructor(){super(...arguments),this.id=HWe++}update(){if(!this.node.presenceContext)return;const{isPresent:e,onExitComplete:r}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;const s=this.node.animationState.setActive("exit",!e);r&&!e&&s.then(()=>{r(this.id)})}mount(){const{register:e,onExitComplete:r}=this.node.presenceContext||{};r&&r(this.id),e&&(this.unmount=e(this.id))}unmount(){}}const WWe={animation:{Feature:UWe},exit:{Feature:VWe}};function vj(t,e,r,n={passive:!0}){return t.addEventListener(e,r,n),()=>t.removeEventListener(e,r)}function EE(t){return{point:{x:t.pageX,y:t.pageY}}}const qWe=t=>e=>mW(e)&&t(e,EE(e));function v_(t,e,r,n){return vj(t,e,qWe(r),n)}const zme=1e-4,GWe=1-zme,KWe=1+zme,Ume=.01,YWe=0-Ume,XWe=0+Ume;function ha(t){return t.max-t.min}function JWe(t,e,r){return Math.abs(t-e)<=r}function GX(t,e,r,n=.5){t.origin=n,t.originPoint=En(e.min,e.max,t.origin),t.scale=ha(r)/ha(e),t.translate=En(r.min,r.max,t.origin)-t.originPoint,(t.scale>=GWe&&t.scale<=KWe||isNaN(t.scale))&&(t.scale=1),(t.translate>=YWe&&t.translate<=XWe||isNaN(t.translate))&&(t.translate=0)}function b_(t,e,r,n){GX(t.x,e.x,r.x,n?n.originX:void 0),GX(t.y,e.y,r.y,n?n.originY:void 0)}function KX(t,e,r){t.min=r.min+e.min,t.max=t.min+ha(e)}function QWe(t,e,r){KX(t.x,e.x,r.x),KX(t.y,e.y,r.y)}function YX(t,e,r){t.min=e.min-r.min,t.max=t.min+ha(e)}function mP(t,e,r){YX(t.x,e.x,r.x),YX(t.y,e.y,r.y)}function Ho(t){return[t("x"),t("y")]}const Hme=({current:t})=>t?t.ownerDocument.defaultView:null,XX=(t,e)=>Math.abs(t-e);function ZWe(t,e){const r=XX(t.x,e.x),n=XX(t.y,e.y);return Math.sqrt(r**2+n**2)}class Vme{constructor(e,r,{transformPagePoint:n,contextWindow:s=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=ZL(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,m=ZWe(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!m)return;const{point:g}=f,{timestamp:x}=ui;this.history.push({...g,timestamp:x});const{onStart:y,onMove:v}=this.handlers;p||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),v&&v(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=QL(p,this.transformPagePoint),Sn.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:m,onSessionEnd:g,resumeAnimation:x}=this.handlers;if(this.dragSnapToOrigin&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=ZL(f.type==="pointercancel"?this.lastMoveEventInfo:QL(p,this.transformPagePoint),this.history);this.startEvent&&m&&m(f,y),g&&g(f,y)},!mW(e))return;this.dragSnapToOrigin=i,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=s||window;const o=EE(e),c=QL(o,this.transformPagePoint),{point:u}=c,{timestamp:d}=ui;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=r;h&&h(e,ZL(c,this.history)),this.removeListeners=jE(v_(this.contextWindow,"pointermove",this.handlePointerMove),v_(this.contextWindow,"pointerup",this.handlePointerUp),v_(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Hp(this.updatePoint)}}function QL(t,e){return e?{point:e(t.point)}:t}function JX(t,e){return{x:t.x-e.x,y:t.y-e.y}}function ZL({point:t},e){return{point:t,delta:JX(t,Wme(e)),offset:JX(t,e9e(e)),velocity:t9e(e,.1)}}function e9e(t){return t[0]}function Wme(t){return t[t.length-1]}function t9e(t,e){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const s=Wme(t);for(;r>=0&&(n=t[r],!(s.timestamp-n.timestamp>Su(e)));)r--;if(!n)return{x:0,y:0};const i=fl(s.timestamp-n.timestamp);if(i===0)return{x:0,y:0};const a={x:(s.x-n.x)/i,y:(s.y-n.y)/i};return a.x===1/0&&(a.x=0),a.y===1/0&&(a.y=0),a}function r9e(t,{min:e,max:r},n){return e!==void 0&&t<e?t=n?En(e,t,n.min):Math.max(t,e):r!==void 0&&t>r&&(t=n?En(r,t,n.max):Math.min(t,r)),t}function QX(t,e,r){return{min:e!==void 0?t.min+e:void 0,max:r!==void 0?t.max+r-(t.max-t.min):void 0}}function n9e(t,{top:e,left:r,bottom:n,right:s}){return{x:QX(t.x,r,s),y:QX(t.y,e,n)}}function ZX(t,e){let r=e.min-t.min,n=e.max-t.max;return e.max-e.min<t.max-t.min&&([r,n]=[n,r]),{min:r,max:n}}function s9e(t,e){return{x:ZX(t.x,e.x),y:ZX(t.y,e.y)}}function i9e(t,e){let r=.5;const n=ha(t),s=ha(e);return s>n?r=mj(e.min,e.max-n,t.min):n>s&&(r=mj(t.min,t.max-s,e.min)),gh(0,1,r)}function a9e(t,e){const r={};return e.min!==void 0&&(r.min=e.min-t.min),e.max!==void 0&&(r.max=e.max-t.min),r}const U6=.35;function o9e(t=U6){return t===!1?t=0:t===!0&&(t=U6),{x:eJ(t,"left","right"),y:eJ(t,"top","bottom")}}function eJ(t,e,r){return{min:tJ(t,e),max:tJ(t,r)}}function tJ(t,e){return typeof t=="number"?t:t[e]||0}const l9e=new WeakMap;class c9e{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=js(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:r=!1,distanceThreshold:n}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const i=h=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),r&&this.snapToCursor(EE(h).point)},a=(h,f)=>{const{drag:p,dragPropagation:m,onDragStart:g}=this.getProps();if(p&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=bVe(p),!this.openDragLock))return;this.latestPointerEvent=h,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ho(y=>{let v=this.getAxisMotionValue(y).get()||0;if(_u.test(v)){const{projection:b}=this.visualElement;if(b&&b.layout){const w=b.layout.layoutBox[y];w&&(v=ha(w)*(parseFloat(v)/100))}}this.originPoint[y]=v}),g&&Sn.postRender(()=>g(h,f)),B6(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},o=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:m,onDirectionLock:g,onDrag:x}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:y}=f;if(m&&this.currentDirection===null){this.currentDirection=u9e(y),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),x&&x(h,f)},c=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f,this.stop(h,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>Ho(h=>{var f;return this.getAnimationState(h)==="paused"&&((f=this.getAxisMotionValue(h).animation)==null?void 0:f.play())}),{dragSnapToOrigin:d}=this.getProps();this.panSession=new Vme(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:n,contextWindow:Hme(this.visualElement)})}stop(e,r){const n=e||this.latestPointerEvent,s=r||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!s||!n)return;const{velocity:a}=s;this.startAnimation(a);const{onDragEnd:o}=this.getProps();o&&Sn.postRender(()=>o(n,s))}cancel(){this.isDragging=!1;const{projection:e,animationState:r}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),r&&r.setActive("whileDrag",!1)}updateAxis(e,r,n){const{drag:s}=this.getProps();if(!n||!WA(e,s,this.currentDirection))return;const i=this.getAxisMotionValue(e);let a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=r9e(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){var i;const{dragConstraints:e,dragElastic:r}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(i=this.visualElement.projection)==null?void 0:i.layout,s=this.constraints;e&&Iv(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=n9e(n.layoutBox,e):this.constraints=!1,this.elastic=o9e(r),s!==this.constraints&&n&&this.constraints&&!this.hasMutatedConstraints&&Ho(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=a9e(n.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:r}=this.getProps();if(!e||!Iv(e))return!1;const n=e.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const i=dWe(n,s.root,this.visualElement.getTransformPagePoint());let a=s9e(s.layout.layoutBox,i);if(r){const o=r(lWe(a));this.hasMutatedConstraints=!!o,o&&(a=Ame(o))}return a}startAnimation(e){const{drag:r,dragMomentum:n,dragElastic:s,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),c=this.constraints||{},u=Ho(d=>{if(!WA(d,r,this.currentDirection))return;let h=c&&c[d]||{};a&&(h={min:0,max:0});const f=s?200:1e6,p=s?40:1e7,m={type:"inertia",velocity:n?e[d]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...i,...h};return this.startAxisValueAnimation(d,m)});return Promise.all(u).then(o)}startAxisValueAnimation(e,r){const n=this.getAxisMotionValue(e);return B6(this.visualElement,e),n.start(jW(e,n,0,r,this.visualElement,!1))}stopAnimation(){Ho(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){Ho(e=>{var r;return(r=this.getAxisMotionValue(e).animation)==null?void 0:r.pause()})}getAnimationState(e){var r;return(r=this.getAxisMotionValue(e).animation)==null?void 0:r.state}getAxisMotionValue(e){const r=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps(),s=n[r];return s||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){Ho(r=>{const{drag:n}=this.getProps();if(!WA(r,n,this.currentDirection))return;const{projection:s}=this.visualElement,i=this.getAxisMotionValue(r);if(s&&s.layout){const{min:a,max:o}=s.layout.layoutBox[r];i.set(e[r]-En(a,o,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!Iv(r)||!n||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};Ho(a=>{const o=this.getAxisMotionValue(a);if(o&&this.constraints!==!1){const c=o.get();s[a]=i9e({min:c,max:c},this.constraints[a])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.resolveConstraints(),Ho(a=>{if(!WA(a,e,null))return;const o=this.getAxisMotionValue(a),{min:c,max:u}=this.constraints[a];o.set(En(c,u,s[a]))})}addListeners(){if(!this.visualElement.current)return;l9e.set(this.visualElement,this);const e=this.visualElement.current,r=v_(e,"pointerdown",c=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(c)}),n=()=>{const{dragConstraints:c}=this.getProps();Iv(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,i=s.addEventListener("measure",n);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),Sn.read(n);const a=vj(window,"resize",()=>this.scalePositionWithinConstraints()),o=s.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(Ho(d=>{const h=this.getAxisMotionValue(d);h&&(this.originPoint[d]+=c[d].translate,h.set(h.get()+c[d].translate))}),this.visualElement.render())});return()=>{a(),r(),i(),o&&o()}}getProps(){const e=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:s=!1,dragConstraints:i=!1,dragElastic:a=U6,dragMomentum:o=!0}=e;return{...e,drag:r,dragDirectionLock:n,dragPropagation:s,dragConstraints:i,dragElastic:a,dragMomentum:o}}}function WA(t,e,r){return(e===!0||e===t)&&(r===null||r===t)}function u9e(t,e=10){let r=null;return Math.abs(t.y)>e?r="y":Math.abs(t.x)>e&&(r="x"),r}class d9e extends om{constructor(e){super(e),this.removeGroupControls=vl,this.removeListeners=vl,this.controls=new c9e(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||vl}unmount(){this.removeGroupControls(),this.removeListeners()}}const rJ=t=>(e,r)=>{t&&Sn.postRender(()=>t(e,r))};class h9e extends om{constructor(){super(...arguments),this.removePointerDownListener=vl}onPointerDown(e){this.session=new Vme(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:Hme(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:r,onPan:n,onPanEnd:s}=this.node.getProps();return{onSessionStart:rJ(e),onStart:rJ(r),onMove:n,onEnd:(i,a)=>{delete this.session,s&&Sn.postRender(()=>s(i,a))}}}mount(){this.removePointerDownListener=v_(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const vT={hasAnimatedSinceResize:!0,hasEverUpdated:!1};let e4=!1;class f9e extends j.Component{componentDidMount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n,layoutId:s}=this.props,{projection:i}=e;i&&(r.group&&r.group.add(i),n&&n.register&&s&&n.register(i),e4&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),vT.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:r,visualElement:n,drag:s,isPresent:i}=this.props,{projection:a}=n;return a&&(a.isPresent=i,e4=!0,s||e.layoutDependency!==r||r===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Sn.postRender(()=>{const o=a.getStack();(!o||!o.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),pW.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:s}=e;e4=!0,s&&(s.scheduleCheckAfterUnmount(),r&&r.group&&r.group.remove(s),n&&n.deregister&&n.deregister(s))}safeToRemove(){const{safeToRemove:e}=this.props;e&&e()}render(){return null}}function qme(t){const[e,r]=CVe(),n=j.useContext(Spe);return l.jsx(f9e,{...t,layoutGroup:n,switchLayoutGroup:j.useContext(Nme),isPresent:e,safeToRemove:r})}function p9e(t,e,r){const n=Fi(t)?t:Y0(t);return n.start(jW("",n,e,r)),n.animation}const m9e=(t,e)=>t.depth-e.depth;class g9e{constructor(){this.children=[],this.isDirty=!1}add(e){JV(this.children,e),this.isDirty=!0}remove(e){QV(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(m9e),this.isDirty=!1,this.children.forEach(e)}}function y9e(t,e){const r=Ba.now(),n=({timestamp:s})=>{const i=s-r;i>=e&&(Hp(n),t(i-e))};return Sn.setup(n,!0),()=>Hp(n)}const Gme=["TopLeft","TopRight","BottomLeft","BottomRight"],x9e=Gme.length,nJ=t=>typeof t=="string"?parseFloat(t):t,sJ=t=>typeof t=="number"||Pt.test(t);function v9e(t,e,r,n,s,i){s?(t.opacity=En(0,r.opacity??1,b9e(n)),t.opacityExit=En(e.opacity??1,0,w9e(n))):i&&(t.opacity=En(e.opacity??1,r.opacity??1,n));for(let a=0;a<x9e;a++){const o=`border${Gme[a]}Radius`;let c=iJ(e,o),u=iJ(r,o);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||sJ(c)===sJ(u)?(t[o]=Math.max(En(nJ(c),nJ(u),n),0),(_u.test(u)||_u.test(c))&&(t[o]+="%")):t[o]=u}(e.rotate||r.rotate)&&(t.rotate=En(e.rotate||0,r.rotate||0,n))}function iJ(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const b9e=Kme(0,.5,Ipe),w9e=Kme(.5,.95,vl);function Kme(t,e,r){return n=>n<t?0:n>e?1:r(mj(t,e,n))}function aJ(t,e){t.min=e.min,t.max=e.max}function Ml(t,e){aJ(t.x,e.x),aJ(t.y,e.y)}function oJ(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function lJ(t,e,r,n,s){return t-=e,t=pP(t,1/r,n),s!==void 0&&(t=pP(t,1/s,n)),t}function S9e(t,e=0,r=1,n=.5,s,i=t,a=t){if(_u.test(e)&&(e=parseFloat(e),e=En(a.min,a.max,e/100)-a.min),typeof e!="number")return;let o=En(i.min,i.max,n);t===i&&(o-=e),t.min=lJ(t.min,e,r,o,s),t.max=lJ(t.max,e,r,o,s)}function cJ(t,e,[r,n,s],i,a){S9e(t,e[r],e[n],e[s],e.scale,i,a)}const _9e=["x","scaleX","originX"],j9e=["y","scaleY","originY"];function uJ(t,e,r,n){cJ(t.x,e,_9e,r?r.x:void 0,n?n.x:void 0),cJ(t.y,e,j9e,r?r.y:void 0,n?n.y:void 0)}function dJ(t){return t.translate===0&&t.scale===1}function Yme(t){return dJ(t.x)&&dJ(t.y)}function hJ(t,e){return t.min===e.min&&t.max===e.max}function k9e(t,e){return hJ(t.x,e.x)&&hJ(t.y,e.y)}function fJ(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function Xme(t,e){return fJ(t.x,e.x)&&fJ(t.y,e.y)}function pJ(t){return ha(t.x)/ha(t.y)}function mJ(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class N9e{constructor(){this.members=[]}add(e){JV(this.members,e),e.scheduleRender()}remove(e){if(QV(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){const r=this.members[this.members.length-1];r&&this.promote(r)}}relegate(e){const r=this.members.findIndex(s=>e===s);if(r===0)return!1;let n;for(let s=r;s>=0;s--){const i=this.members[s];if(i.isPresent!==!1){n=i;break}}return n?(this.promote(n),!0):!1}promote(e,r){const n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender(),e.resumeFrom=n,r&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0);const{crossfade:s}=e.options;s===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{const{options:r,resumingFrom:n}=e;r.onExitComplete&&r.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function E9e(t,e,r){let n="";const s=t.x.translate/e.x,i=t.y.translate/e.y,a=(r==null?void 0:r.z)||0;if((s||i||a)&&(n=`translate3d(${s}px, ${i}px, ${a}px) `),(e.x!==1||e.y!==1)&&(n+=`scale(${1/e.x}, ${1/e.y}) `),r){const{transformPerspective:u,rotate:d,rotateX:h,rotateY:f,skewX:p,skewY:m}=r;u&&(n=`perspective(${u}px) ${n}`),d&&(n+=`rotate(${d}deg) `),h&&(n+=`rotateX(${h}deg) `),f&&(n+=`rotateY(${f}deg) `),p&&(n+=`skewX(${p}deg) `),m&&(n+=`skewY(${m}deg) `)}const o=t.x.scale*e.x,c=t.y.scale*e.y;return(o!==1||c!==1)&&(n+=`scale(${o}, ${c})`),n||"none"}const t4=["","X","Y","Z"],A9e=1e3;let C9e=0;function r4(t,e,r,n){const{latestValues:s}=e;s[t]&&(r[t]=s[t],e.setStaticValue(t,0),n&&(n[t]=0))}function Jme(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const r=Dme(e);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:s,layoutId:i}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Sn,!(s||i))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&Jme(n)}function Qme({attachResizeListener:t,defaultParent:e,measureScroll:r,checkIsScrollRoot:n,resetTransform:s}){return class{constructor(a={},o=e==null?void 0:e()){this.id=C9e++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(O9e),this.nodes.forEach(D9e),this.nodes.forEach(L9e),this.nodes.forEach(I9e)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=o?o.root||o:this,this.path=o?[...o.path,o]:[],this.parent=o,this.depth=o?o.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new g9e)}addEventListener(a,o){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new eW),this.eventHandlers.get(a).add(o)}notifyListeners(a,...o){const c=this.eventHandlers.get(a);c&&c.notify(...o)}hasListeners(a){return this.eventHandlers.has(a)}mount(a){if(this.instance)return;this.isSVG=fme(a)&&!NVe(a),this.instance=a;const{layoutId:o,layout:c,visualElement:u}=this.options;if(u&&!u.current&&u.mount(a),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(c||o)&&(this.isLayoutDirty=!0),t){let d,h=0;const f=()=>this.root.updateBlockedByResize=!1;Sn.read(()=>{h=window.innerWidth}),t(a,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=y9e(f,250),vT.hasAnimatedSinceResize&&(vT.hasAnimatedSinceResize=!1,this.nodes.forEach(xJ)))})}o&&this.root.registerSharedNode(o,this),this.options.animate!==!1&&u&&(o||c)&&this.addEventListener("didUpdate",({delta:d,hasLayoutChanged:h,hasRelativeLayoutChanged:f,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const m=this.options.transition||u.getDefaultTransition()||U9e,{onLayoutAnimationStart:g,onLayoutAnimationComplete:x}=u.getProps(),y=!this.targetLayout||!Xme(this.targetLayout,p),v=!h&&f;if(this.options.layoutRoot||this.resumeFrom||v||h&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...hW(m,"layout"),onPlay:g,onComplete:x};(u.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(d,v)}else h||xJ(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const a=this.getStack();a&&a.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Hp(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(F9e),this.animationId++)}getTransformTemplate(){const{visualElement:a}=this.options;return a&&a.getProps().transformTemplate}willUpdate(a=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Jme(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const h=this.path[d];h.shouldResetTransform=!0,h.updateScroll("snapshot"),h.options.layoutRoot&&h.willUpdate(!1)}const{layoutId:o,layout:c}=this.options;if(o===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),a&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(gJ);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(yJ);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(M9e),this.nodes.forEach(T9e),this.nodes.forEach(P9e)):this.nodes.forEach(yJ),this.clearAllSnapshots();const o=Ba.now();ui.delta=gh(0,1e3/60,o-ui.timestamp),ui.timestamp=o,ui.isProcessing=!0,VL.update.process(ui),VL.preRender.process(ui),VL.render.process(ui),ui.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,pW.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(R9e),this.sharedNodes.forEach($9e)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Sn.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Sn.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!ha(this.snapshot.measuredBox.x)&&!ha(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let c=0;c<this.path.length;c++)this.path[c].updateScroll();const a=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=js(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:o}=this.options;o&&o.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let o=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(o=!1),o&&this.instance){const c=n(this.instance);this.scroll={animationId:this.root.animationId,phase:a,isRoot:c,offset:r(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!s)return;const a=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,o=this.projectionDelta&&!Yme(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;a&&this.instance&&(o||Dm(this.latestValues)||d)&&(s(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){const o=this.measurePageBox();let c=this.removeElementScroll(o);return a&&(c=this.removeTransform(c)),H9e(c),{animationId:this.root.animationId,measuredBox:o,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var u;const{visualElement:a}=this.options;if(!a)return js();const o=a.measureViewportBox();if(!(((u=this.scroll)==null?void 0:u.wasRoot)||this.path.some(V9e))){const{scroll:d}=this.root;d&&(Rv(o.x,d.offset.x),Rv(o.y,d.offset.y))}return o}removeElementScroll(a){var c;const o=js();if(Ml(o,a),(c=this.scroll)!=null&&c.wasRoot)return o;for(let u=0;u<this.path.length;u++){const d=this.path[u],{scroll:h,options:f}=d;d!==this.root&&h&&f.layoutScroll&&(h.wasRoot&&Ml(o,a),Rv(o.x,h.offset.x),Rv(o.y,h.offset.y))}return o}applyTransform(a,o=!1){const c=js();Ml(c,a);for(let u=0;u<this.path.length;u++){const d=this.path[u];!o&&d.options.layoutScroll&&d.scroll&&d!==d.root&&Mv(c,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),Dm(d.latestValues)&&Mv(c,d.latestValues)}return Dm(this.latestValues)&&Mv(c,this.latestValues),c}removeTransform(a){const o=js();Ml(o,a);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!Dm(u.latestValues))continue;D6(u.latestValues)&&u.updateSnapshot();const d=js(),h=u.measurePageBox();Ml(d,h),uJ(o,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return Dm(this.latestValues)&&uJ(o,this.latestValues),o}setTargetDelta(a){this.targetDelta=a,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(a){this.options={...this.options,...a,crossfade:a.crossfade!==void 0?a.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==ui.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){var p;const o=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=o.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=o.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=o.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==o;if(!(a||c&&this.isSharedProjectionDirty||this.isProjectionDirty||(p=this.parent)!=null&&p.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:d,layoutId:h}=this.options;if(!this.layout||!(d||h))return;this.resolvedRelativeTargetAt=ui.timestamp;const f=this.getClosestProjectingParent();f&&this.linkedParentVersion!==f.layoutVersion&&!f.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(f&&f.layout?this.createRelativeTarget(f,this.layout.layoutBox,f.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=js(),this.targetWithTransforms=js()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),QWe(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ml(this.target,this.layout.layoutBox),Tme(this.target,this.targetDelta)):Ml(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,f&&!!f.resumingFrom==!!this.resumingFrom&&!f.options.layoutScroll&&f.target&&this.animationProgress!==1?this.createRelativeTarget(f,this.target,f.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||D6(this.parent.latestValues)||Cme(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(a,o,c){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=js(),this.relativeTargetOrigin=js(),mP(this.relativeTargetOrigin,o,c),Ml(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var m;const a=this.getLead(),o=!!this.resumingFrom||this!==a;let c=!0;if((this.isProjectionDirty||(m=this.parent)!=null&&m.isProjectionDirty)&&(c=!1),o&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===ui.timestamp&&(c=!1),c)return;const{layout:u,layoutId:d}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(u||d))return;Ml(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,f=this.treeScale.y;uWe(this.layoutCorrected,this.treeScale,this.path,o),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=js());const{target:p}=a;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(oJ(this.prevProjectionDelta.x,this.projectionDelta.x),oJ(this.prevProjectionDelta.y,this.projectionDelta.y)),b_(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==f||!mJ(this.projectionDelta.x,this.prevProjectionDelta.x)||!mJ(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(a=!0){var o;if((o=this.options.visualElement)==null||o.scheduleRender(),a){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Dv(),this.projectionDelta=Dv(),this.projectionDeltaWithTransform=Dv()}setAnimationOrigin(a,o=!1){const c=this.snapshot,u=c?c.latestValues:{},d={...this.latestValues},h=Dv();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!o;const f=js(),p=c?c.source:void 0,m=this.layout?this.layout.source:void 0,g=p!==m,x=this.getStack(),y=!x||x.members.length<=1,v=!!(g&&!y&&this.options.crossfade===!0&&!this.path.some(z9e));this.animationProgress=0;let b;this.mixTargetDelta=w=>{const S=w/1e3;vJ(h.x,a.x,S),vJ(h.y,a.y,S),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(mP(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),B9e(this.relativeTarget,this.relativeTargetOrigin,f,S),b&&k9e(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=js()),Ml(b,this.relativeTarget)),g&&(this.animationValues=d,v9e(d,u,this.latestValues,S,v,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=S},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){var o,c,u;this.notifyListeners("animationStart"),(o=this.currentAnimation)==null||o.stop(),(u=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||u.stop(),this.pendingAnimation&&(Hp(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Sn.update(()=>{vT.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Y0(0)),this.currentAnimation=p9e(this.motionValue,[0,1e3],{...a,velocity:0,isSync:!0,onUpdate:d=>{this.mixTargetDelta(d),a.onUpdate&&a.onUpdate(d)},onStop:()=>{},onComplete:()=>{a.onComplete&&a.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const a=this.getStack();a&&a.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(A9e),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:o,target:c,layout:u,latestValues:d}=a;if(!(!o||!c||!u)){if(this!==a&&this.layout&&u&&Zme(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||js();const h=ha(this.layout.layoutBox.x);c.x.min=a.target.x.min,c.x.max=c.x.min+h;const f=ha(this.layout.layoutBox.y);c.y.min=a.target.y.min,c.y.max=c.y.min+f}Ml(o,c),Mv(o,d),b_(this.projectionDeltaWithTransform,this.layoutCorrected,o,d)}}registerSharedNode(a,o){this.sharedNodes.has(a)||this.sharedNodes.set(a,new N9e),this.sharedNodes.get(a).add(o);const u=o.options.initialPromotionConfig;o.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(o):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var o;const{layoutId:a}=this.options;return a?((o=this.getStack())==null?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:a}=this.options;return a?(o=this.getStack())==null?void 0:o.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:o,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),a&&(this.projectionDelta=void 0,this.needsReset=!0),o&&this.setOptions({transition:o})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let o=!1;const{latestValues:c}=a;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(o=!0),!o)return;const u={};c.z&&r4("z",a,u,this.animationValues);for(let d=0;d<t4.length;d++)r4(`rotate${t4[d]}`,a,u,this.animationValues),r4(`skew${t4[d]}`,a,u,this.animationValues);a.render();for(const d in u)a.setStaticValue(d,u[d]),this.animationValues&&(this.animationValues[d]=u[d]);a.scheduleRender()}applyProjectionStyles(a,o){if(!this.instance||this.isSVG)return;if(!this.isVisible){a.visibility="hidden";return}const c=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,a.visibility="",a.opacity="",a.pointerEvents=xT(o==null?void 0:o.pointerEvents)||"",a.transform=c?c(this.latestValues,""):"none";return}const u=this.getLead();if(!this.projectionDelta||!this.layout||!u.target){this.options.layoutId&&(a.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,a.pointerEvents=xT(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!Dm(this.latestValues)&&(a.transform=c?c({},""):"none",this.hasProjected=!1);return}a.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=E9e(this.projectionDeltaWithTransform,this.treeScale,d);c&&(h=c(d,h)),a.transform=h;const{x:f,y:p}=this.projectionDelta;a.transformOrigin=`${f.origin*100}% ${p.origin*100}% 0`,u.animationValues?a.opacity=u===this?d.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:d.opacityExit:a.opacity=u===this?d.opacity!==void 0?d.opacity:"":d.opacityExit!==void 0?d.opacityExit:0;for(const m in M6){if(d[m]===void 0)continue;const{correct:g,applyTo:x,isCSSVariable:y}=M6[m],v=h==="none"?d[m]:g(d[m],u);if(x){const b=x.length;for(let w=0;w<b;w++)a[x[w]]=v}else y?this.options.visualElement.renderState.vars[m]=v:a[m]=v}this.options.layoutId&&(a.pointerEvents=u===this?xT(o==null?void 0:o.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>{var o;return(o=a.currentAnimation)==null?void 0:o.stop()}),this.root.nodes.forEach(gJ),this.root.sharedNodes.clear()}}}function T9e(t){t.updateLayout()}function P9e(t){var r;const e=((r=t.resumeFrom)==null?void 0:r.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&e&&t.hasListeners("didUpdate")){const{layoutBox:n,measuredBox:s}=t.layout,{animationType:i}=t.options,a=e.source!==t.layout.source;i==="size"?Ho(h=>{const f=a?e.measuredBox[h]:e.layoutBox[h],p=ha(f);f.min=n[h].min,f.max=f.min+p}):Zme(i,e.layoutBox,n)&&Ho(h=>{const f=a?e.measuredBox[h]:e.layoutBox[h],p=ha(n[h]);f.max=f.min+p,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[h].max=t.relativeTarget[h].min+p)});const o=Dv();b_(o,n,e.layoutBox);const c=Dv();a?b_(c,t.applyTransform(s,!0),e.measuredBox):b_(c,n,e.layoutBox);const u=!Yme(o);let d=!1;if(!t.resumeFrom){const h=t.getClosestProjectingParent();if(h&&!h.resumeFrom){const{snapshot:f,layout:p}=h;if(f&&p){const m=js();mP(m,e.layoutBox,f.layoutBox);const g=js();mP(g,n,p.layoutBox),Xme(m,g)||(d=!0),h.options.layoutRoot&&(t.relativeTarget=g,t.relativeTargetOrigin=m,t.relativeParent=h)}}}t.notifyListeners("didUpdate",{layout:n,snapshot:e,delta:c,layoutDelta:o,hasLayoutChanged:u,hasRelativeLayoutChanged:d})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function O9e(t){t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function I9e(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function R9e(t){t.clearSnapshot()}function gJ(t){t.clearMeasurements()}function yJ(t){t.isLayoutDirty=!1}function M9e(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function xJ(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function D9e(t){t.resolveTargetDelta()}function L9e(t){t.calcProjection()}function F9e(t){t.resetSkewAndRotation()}function $9e(t){t.removeLeadSnapshot()}function vJ(t,e,r){t.translate=En(e.translate,0,r),t.scale=En(e.scale,1,r),t.origin=e.origin,t.originPoint=e.originPoint}function bJ(t,e,r,n){t.min=En(e.min,r.min,n),t.max=En(e.max,r.max,n)}function B9e(t,e,r,n){bJ(t.x,e.x,r.x,n),bJ(t.y,e.y,r.y,n)}function z9e(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const U9e={duration:.45,ease:[.4,0,.1,1]},wJ=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),SJ=wJ("applewebkit/")&&!wJ("chrome/")?Math.round:vl;function _J(t){t.min=SJ(t.min),t.max=SJ(t.max)}function H9e(t){_J(t.x),_J(t.y)}function Zme(t,e,r){return t==="position"||t==="preserve-aspect"&&!JWe(pJ(e),pJ(r),.2)}function V9e(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const W9e=Qme({attachResizeListener:(t,e)=>vj(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),n4={current:void 0},ege=Qme({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!n4.current){const t=new W9e({});t.mount(window),t.setOptions({layoutScroll:!0}),n4.current=t}return n4.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),q9e={pan:{Feature:h9e},drag:{Feature:d9e,ProjectionNode:ege,MeasureLayout:qme}};function jJ(t,e,r){const{props:n}=t;t.animationState&&n.whileHover&&t.animationState.setActive("whileHover",r==="Start");const s="onHover"+r,i=n[s];i&&Sn.postRender(()=>i(e,EE(e)))}class G9e extends om{mount(){const{current:e}=this.node;e&&(this.unmount=wVe(e,(r,n)=>(jJ(this.node,n,"Start"),s=>jJ(this.node,s,"End"))))}unmount(){}}class K9e extends om{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=jE(vj(this.node.current,"focus",()=>this.onFocus()),vj(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function kJ(t,e,r){const{props:n}=t;if(t.current instanceof HTMLButtonElement&&t.current.disabled)return;t.animationState&&n.whileTap&&t.animationState.setActive("whileTap",r==="Start");const s="onTap"+(r==="End"?"":r),i=n[s];i&&Sn.postRender(()=>i(e,EE(e)))}class Y9e extends om{mount(){const{current:e}=this.node;e&&(this.unmount=kVe(e,(r,n)=>(kJ(this.node,n,"Start"),(s,{success:i})=>kJ(this.node,s,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const H6=new WeakMap,s4=new WeakMap,X9e=t=>{const e=H6.get(t.target);e&&e(t)},J9e=t=>{t.forEach(X9e)};function Q9e({root:t,...e}){const r=t||document;s4.has(r)||s4.set(r,{});const n=s4.get(r),s=JSON.stringify(e);return n[s]||(n[s]=new IntersectionObserver(J9e,{root:t,...e})),n[s]}function Z9e(t,e,r){const n=Q9e(e);return H6.set(t,r),n.observe(t),()=>{H6.delete(t),n.unobserve(t)}}const e7e={some:0,all:1};class t7e extends om{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:e={}}=this.node.getProps(),{root:r,margin:n,amount:s="some",once:i}=e,a={root:r?r.current:void 0,rootMargin:n,threshold:typeof s=="number"?s:e7e[s]},o=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:h}=this.node.getProps(),f=u?d:h;f&&f(c)};return Z9e(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:r}=this.node;["amount","margin","root"].some(r7e(e,r))&&this.startObserver()}unmount(){}}function r7e({viewport:t={}},{viewport:e={}}={}){return r=>t[r]!==e[r]}const n7e={inView:{Feature:t7e},tap:{Feature:Y9e},focus:{Feature:K9e},hover:{Feature:G9e}},s7e={layout:{ProjectionNode:ege,MeasureLayout:qme}},i7e={...WWe,...n7e,...q9e,...s7e},ic=oWe(i7e,bWe),a7e={some:0,all:1};function o7e(t,e,{root:r,margin:n,amount:s="some"}={}){const i=lme(t),a=new WeakMap,o=u=>{u.forEach(d=>{const h=a.get(d.target);if(d.isIntersecting!==!!h)if(d.isIntersecting){const f=e(d.target,d);typeof f=="function"?a.set(d.target,f):c.unobserve(d.target)}else typeof h=="function"&&(h(d),a.delete(d.target))})},c=new IntersectionObserver(o,{root:r,rootMargin:n,threshold:typeof s=="number"?s:a7e[s]});return i.forEach(u=>c.observe(u)),()=>c.disconnect()}function l7e(t,{root:e,margin:r,amount:n,once:s=!1,initial:i=!1}={}){const[a,o]=j.useState(i);return j.useEffect(()=>{if(!t.current||s&&a)return;const c=()=>(o(!0),s?void 0:()=>o(!1)),u={root:e&&e.current||void 0,margin:r,amount:n};return o7e(t.current,c,u)},[e,t,r,s,n]),a}const c7e=Nh("relative overflow-hidden rounded-full bg-secondary",{variants:{variant:{default:"bg-secondary",primary:"bg-primary/10",secondary:"bg-secondary",destructive:"bg-destructive/10",outline:"bg-accent border border-border",success:"bg-success/10",warning:"bg-warning/10"},size:{sm:"h-1.5",default:"h-2.5",lg:"h-3"}},defaultVariants:{variant:"default",size:"default"}}),u7e=Nh("h-full w-full flex-1 rounded-full transition-all duration-500 ease-out",{variants:{variant:{default:"bg-primary",primary:"bg-primary",secondary:"bg-foreground",destructive:"bg-destructive",outline:"bg-primary",success:"bg-success",warning:"bg-warning"}},defaultVariants:{variant:"default"}}),AE=j.forwardRef(({className:t,value:e=0,variant:r,size:n,showValue:s=!1,animated:i=!0,label:a,...o},c)=>{const u=Math.min(Math.max(e,0),100);return l.jsxs("div",{className:"space-y-2",children:[a&&l.jsx("div",{className:"text-sm text-foreground",children:a}),l.jsx(wpe,{ref:c,className:Le(c7e({variant:r,size:n}),t),...o,children:l.jsx(PUe,{className:Le(u7e({variant:r})),asChild:!0,children:l.jsx(ic.div,{initial:{transform:"translateX(-100%)"},animate:{transform:`translateX(-${100-u}%)`},transition:{duration:i?1.2:0,ease:"easeInOut"}})})}),s&&l.jsxs(ic.div,{className:"text-right text-xs font-semibold text-muted-foreground tabular-nums",initial:{opacity:0,y:-5},animate:{opacity:1,y:0},transition:{delay:i?.3:0,duration:.2},children:[Math.round(u),"%"]})]})});AE.displayName=wpe.displayName;function d7e({stats:t}){const e=Or();if(!(t!=null&&t.active_thesis_id))return l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Timeline"})}),l.jsxs(Ge,{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-muted-foreground",children:"No thesis created yet. Create one to track your deadline."}),l.jsx(ye,{size:"sm",variant:"outline",onClick:()=>e("/thesis-manager"),children:"Go to My Thesis"})]})]});if(!(t!=null&&t.active_thesis_due_date))return l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Timeline"})}),l.jsxs(Ge,{className:"space-y-3",children:[l.jsx("p",{className:"text-sm text-muted-foreground",children:"No deadline set. Add one in your thesis."}),l.jsx(ye,{size:"sm",variant:"outline",onClick:()=>e("/thesis-manager"),children:"Go to My Thesis"})]})]});const r=new Date(t.active_thesis_due_date),n=new Date,s=t.active_thesis_created_at?new Date(t.active_thesis_created_at):new Date(n.getTime()-180*24*60*60*1e3),i=PL(r,s),a=PL(n,s),o=PL(r,n),c=i>0?Math.min(100,Math.max(0,a/i*100)):100,u=t.active_thesis_target_words||15e3,d=t.total_word_count||0,h=Math.max(0,u-d),f=o>0?Math.ceil(h/o):0;let p="success";return o<7?p="destructive":o<30&&(p="warning"),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Timeline"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-muted-foreground",children:"Deadline"}),l.jsx("span",{className:"font-semibold",children:fj(r,"MMMM d, yyyy",{locale:TV})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsx("span",{className:"font-semibold",children:o>0?`${o} days remaining`:"Overdue"}),l.jsxs("span",{className:"text-muted-foreground",children:[Math.round(c),"%"]})]}),l.jsx(AE,{value:c,variant:p,size:"default",animated:!0})]})]}),h>0&&o>0&&l.jsx("div",{className:"pt-3 border-t",children:l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx("span",{className:"text-muted-foreground",children:"Recommended:"}),l.jsxs("span",{className:"font-semibold text-primary",children:["~",f," words/day"]})]})})]})]})}function h7e({stats:t}){const e=(t==null?void 0:t.total_word_count)||0,r=(t==null?void 0:t.active_thesis_target_words)||15e3,n=Math.min(100,e/r*100),s=Math.max(0,r-e);return l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{className:"flex items-center gap-2",children:"Writing Progress"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("span",{className:"text-sm text-muted-foreground",children:"Words written"}),l.jsx("span",{className:"font-semibold",children:e.toLocaleString()})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsxs("span",{className:"font-semibold",children:[Math.round(n),"%"]}),l.jsxs("span",{className:"text-muted-foreground",children:["Goal: ",r.toLocaleString()," words"]})]}),l.jsx(AE,{value:n,variant:"primary",size:"default",animated:!0})]})]}),s>0&&l.jsx("div",{className:"pt-3 border-t",children:l.jsx("div",{className:"flex items-center gap-2 text-sm",children:l.jsxs("span",{className:"text-muted-foreground",children:[s.toLocaleString()," words remaining to reach goal"]})})})]})]})}function f7e({stats:t}){const e=Or();return((t==null?void 0:t.total_codebooks)||0)>0||((t==null?void 0:t.total_interviews)||0)>0||((t==null?void 0:t.total_codings)||0)>0?l.jsxs(ze,{className:"h-full",children:[l.jsx(et,{className:"pb-3",children:l.jsx(at,{className:"flex items-center gap-2 text-base",children:"Qualitative Analysis"})}),l.jsx(Ge,{className:"space-y-3",children:l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Cce,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"Codebooks"})]}),l.jsx("span",{className:"font-semibold",children:(t==null?void 0:t.total_codebooks)||0})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Gy,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"Interviews"})]}),l.jsx("span",{className:"font-semibold",children:(t==null?void 0:t.total_interviews)||0})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx($2,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"Coded Segments"})]}),l.jsx("span",{className:"font-semibold",children:(t==null?void 0:t.total_codings)||0})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(qy,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"Analyses"})]}),l.jsx("span",{className:"font-semibold",children:(t==null?void 0:t.total_analyses)||0})]})]})})]}):l.jsxs(ze,{className:"h-full",children:[l.jsx(et,{className:"pb-3",children:l.jsxs(at,{className:"flex items-center gap-2 text-base",children:[l.jsx($2,{className:"h-5 w-5 text-primary"}),"Qualitative Analysis"]})}),l.jsxs(Ge,{children:[l.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"No qualitative data yet"}),l.jsx(ye,{variant:"outline",size:"sm",className:"w-full",onClick:()=>e("/qualitative"),children:"Start Analysis"})]})]})}var p7e=Array.isArray,eo=p7e,m7e=typeof dn=="object"&&dn&&dn.Object===Object&&dn,tge=m7e,g7e=tge,y7e=typeof self=="object"&&self&&self.Object===Object&&self,x7e=g7e||y7e||Function("return this")(),Lu=x7e,v7e=Lu,b7e=v7e.Symbol,CE=b7e,NJ=CE,rge=Object.prototype,w7e=rge.hasOwnProperty,S7e=rge.toString,M1=NJ?NJ.toStringTag:void 0;function _7e(t){var e=w7e.call(t,M1),r=t[M1];try{t[M1]=void 0;var n=!0}catch{}var s=S7e.call(t);return n&&(e?t[M1]=r:delete t[M1]),s}var j7e=_7e,k7e=Object.prototype,N7e=k7e.toString;function E7e(t){return N7e.call(t)}var A7e=E7e,EJ=CE,C7e=j7e,T7e=A7e,P7e="[object Null]",O7e="[object Undefined]",AJ=EJ?EJ.toStringTag:void 0;function I7e(t){return t==null?t===void 0?O7e:P7e:AJ&&AJ in Object(t)?C7e(t):T7e(t)}var Ph=I7e;function R7e(t){return t!=null&&typeof t=="object"}var Oh=R7e,M7e=Ph,D7e=Oh,L7e="[object Symbol]";function F7e(t){return typeof t=="symbol"||D7e(t)&&M7e(t)==L7e}var t1=F7e,$7e=eo,B7e=t1,z7e=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,U7e=/^\w*$/;function H7e(t,e){if($7e(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||B7e(t)?!0:U7e.test(t)||!z7e.test(t)||e!=null&&t in Object(e)}var kW=H7e;function V7e(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var lm=V7e;const r1=cr(lm);var W7e=Ph,q7e=lm,G7e="[object AsyncFunction]",K7e="[object Function]",Y7e="[object GeneratorFunction]",X7e="[object Proxy]";function J7e(t){if(!q7e(t))return!1;var e=W7e(t);return e==K7e||e==Y7e||e==G7e||e==X7e}var NW=J7e;const Xt=cr(NW);var Q7e=Lu,Z7e=Q7e["__core-js_shared__"],eqe=Z7e,i4=eqe,CJ=function(){var t=/[^.]+$/.exec(i4&&i4.keys&&i4.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function tqe(t){return!!CJ&&CJ in t}var rqe=tqe,nqe=Function.prototype,sqe=nqe.toString;function iqe(t){if(t!=null){try{return sqe.call(t)}catch{}try{return t+""}catch{}}return""}var nge=iqe,aqe=NW,oqe=rqe,lqe=lm,cqe=nge,uqe=/[\\^$.*+?()[\]{}|]/g,dqe=/^\[object .+?Constructor\]$/,hqe=Function.prototype,fqe=Object.prototype,pqe=hqe.toString,mqe=fqe.hasOwnProperty,gqe=RegExp("^"+pqe.call(mqe).replace(uqe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function yqe(t){if(!lqe(t)||oqe(t))return!1;var e=aqe(t)?gqe:dqe;return e.test(cqe(t))}var xqe=yqe;function vqe(t,e){return t==null?void 0:t[e]}var bqe=vqe,wqe=xqe,Sqe=bqe;function _qe(t,e){var r=Sqe(t,e);return wqe(r)?r:void 0}var _x=_qe,jqe=_x,kqe=jqe(Object,"create"),HR=kqe,TJ=HR;function Nqe(){this.__data__=TJ?TJ(null):{},this.size=0}var Eqe=Nqe;function Aqe(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Cqe=Aqe,Tqe=HR,Pqe="__lodash_hash_undefined__",Oqe=Object.prototype,Iqe=Oqe.hasOwnProperty;function Rqe(t){var e=this.__data__;if(Tqe){var r=e[t];return r===Pqe?void 0:r}return Iqe.call(e,t)?e[t]:void 0}var Mqe=Rqe,Dqe=HR,Lqe=Object.prototype,Fqe=Lqe.hasOwnProperty;function $qe(t){var e=this.__data__;return Dqe?e[t]!==void 0:Fqe.call(e,t)}var Bqe=$qe,zqe=HR,Uqe="__lodash_hash_undefined__";function Hqe(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=zqe&&e===void 0?Uqe:e,this}var Vqe=Hqe,Wqe=Eqe,qqe=Cqe,Gqe=Mqe,Kqe=Bqe,Yqe=Vqe;function n1(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}n1.prototype.clear=Wqe;n1.prototype.delete=qqe;n1.prototype.get=Gqe;n1.prototype.has=Kqe;n1.prototype.set=Yqe;var Xqe=n1;function Jqe(){this.__data__=[],this.size=0}var Qqe=Jqe;function Zqe(t,e){return t===e||t!==t&&e!==e}var EW=Zqe,eGe=EW;function tGe(t,e){for(var r=t.length;r--;)if(eGe(t[r][0],e))return r;return-1}var VR=tGe,rGe=VR,nGe=Array.prototype,sGe=nGe.splice;function iGe(t){var e=this.__data__,r=rGe(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():sGe.call(e,r,1),--this.size,!0}var aGe=iGe,oGe=VR;function lGe(t){var e=this.__data__,r=oGe(e,t);return r<0?void 0:e[r][1]}var cGe=lGe,uGe=VR;function dGe(t){return uGe(this.__data__,t)>-1}var hGe=dGe,fGe=VR;function pGe(t,e){var r=this.__data__,n=fGe(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var mGe=pGe,gGe=Qqe,yGe=aGe,xGe=cGe,vGe=hGe,bGe=mGe;function s1(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}s1.prototype.clear=gGe;s1.prototype.delete=yGe;s1.prototype.get=xGe;s1.prototype.has=vGe;s1.prototype.set=bGe;var WR=s1,wGe=_x,SGe=Lu,_Ge=wGe(SGe,"Map"),AW=_Ge,PJ=Xqe,jGe=WR,kGe=AW;function NGe(){this.size=0,this.__data__={hash:new PJ,map:new(kGe||jGe),string:new PJ}}var EGe=NGe;function AGe(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var CGe=AGe,TGe=CGe;function PGe(t,e){var r=t.__data__;return TGe(e)?r[typeof e=="string"?"string":"hash"]:r.map}var qR=PGe,OGe=qR;function IGe(t){var e=OGe(this,t).delete(t);return this.size-=e?1:0,e}var RGe=IGe,MGe=qR;function DGe(t){return MGe(this,t).get(t)}var LGe=DGe,FGe=qR;function $Ge(t){return FGe(this,t).has(t)}var BGe=$Ge,zGe=qR;function UGe(t,e){var r=zGe(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}var HGe=UGe,VGe=EGe,WGe=RGe,qGe=LGe,GGe=BGe,KGe=HGe;function i1(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}i1.prototype.clear=VGe;i1.prototype.delete=WGe;i1.prototype.get=qGe;i1.prototype.has=GGe;i1.prototype.set=KGe;var CW=i1,sge=CW,YGe="Expected a function";function TW(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(YGe);var r=function(){var n=arguments,s=e?e.apply(this,n):n[0],i=r.cache;if(i.has(s))return i.get(s);var a=t.apply(this,n);return r.cache=i.set(s,a)||i,a};return r.cache=new(TW.Cache||sge),r}TW.Cache=sge;var ige=TW;const XGe=cr(ige);var JGe=ige,QGe=500;function ZGe(t){var e=JGe(t,function(n){return r.size===QGe&&r.clear(),n}),r=e.cache;return e}var eKe=ZGe,tKe=eKe,rKe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,nKe=/\\(\\)?/g,sKe=tKe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(rKe,function(r,n,s,i){e.push(s?i.replace(nKe,"$1"):n||r)}),e}),iKe=sKe;function aKe(t,e){for(var r=-1,n=t==null?0:t.length,s=Array(n);++r<n;)s[r]=e(t[r],r,t);return s}var PW=aKe,OJ=CE,oKe=PW,lKe=eo,cKe=t1,uKe=1/0,IJ=OJ?OJ.prototype:void 0,RJ=IJ?IJ.toString:void 0;function age(t){if(typeof t=="string")return t;if(lKe(t))return oKe(t,age)+"";if(cKe(t))return RJ?RJ.call(t):"";var e=t+"";return e=="0"&&1/t==-uKe?"-0":e}var dKe=age,hKe=dKe;function fKe(t){return t==null?"":hKe(t)}var oge=fKe,pKe=eo,mKe=kW,gKe=iKe,yKe=oge;function xKe(t,e){return pKe(t)?t:mKe(t,e)?[t]:gKe(yKe(t))}var lge=xKe,vKe=t1,bKe=1/0;function wKe(t){if(typeof t=="string"||vKe(t))return t;var e=t+"";return e=="0"&&1/t==-bKe?"-0":e}var GR=wKe,SKe=lge,_Ke=GR;function jKe(t,e){e=SKe(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[_Ke(e[r++])];return r&&r==n?t:void 0}var OW=jKe,kKe=OW;function NKe(t,e,r){var n=t==null?void 0:kKe(t,e);return n===void 0?r:n}var cge=NKe;const mc=cr(cge);function EKe(t){return t==null}var AKe=EKe;const hr=cr(AKe);var CKe=Ph,TKe=eo,PKe=Oh,OKe="[object String]";function IKe(t){return typeof t=="string"||!TKe(t)&&PKe(t)&&CKe(t)==OKe}var RKe=IKe;const TE=cr(RKe);var uge={exports:{}},Ir={};/**
* @license React
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var IW=Symbol.for("react.element"),RW=Symbol.for("react.portal"),KR=Symbol.for("react.fragment"),YR=Symbol.for("react.strict_mode"),XR=Symbol.for("react.profiler"),JR=Symbol.for("react.provider"),QR=Symbol.for("react.context"),MKe=Symbol.for("react.server_context"),ZR=Symbol.for("react.forward_ref"),eM=Symbol.for("react.suspense"),tM=Symbol.for("react.suspense_list"),rM=Symbol.for("react.memo"),nM=Symbol.for("react.lazy"),DKe=Symbol.for("react.offscreen"),dge;dge=Symbol.for("react.module.reference");function Pl(t){if(typeof t=="object"&&t!==null){var e=t.$$typeof;switch(e){case IW:switch(t=t.type,t){case KR:case XR:case YR:case eM:case tM:return t;default:switch(t=t&&t.$$typeof,t){case MKe:case QR:case ZR:case nM:case rM:case JR:return t;default:return e}}case RW:return e}}}Ir.ContextConsumer=QR;Ir.ContextProvider=JR;Ir.Element=IW;Ir.ForwardRef=ZR;Ir.Fragment=KR;Ir.Lazy=nM;Ir.Memo=rM;Ir.Portal=RW;Ir.Profiler=XR;Ir.StrictMode=YR;Ir.Suspense=eM;Ir.SuspenseList=tM;Ir.isAsyncMode=function(){return!1};Ir.isConcurrentMode=function(){return!1};Ir.isContextConsumer=function(t){return Pl(t)===QR};Ir.isContextProvider=function(t){return Pl(t)===JR};Ir.isElement=function(t){return typeof t=="object"&&t!==null&&t.$$typeof===IW};Ir.isForwardRef=function(t){return Pl(t)===ZR};Ir.isFragment=function(t){return Pl(t)===KR};Ir.isLazy=function(t){return Pl(t)===nM};Ir.isMemo=function(t){return Pl(t)===rM};Ir.isPortal=function(t){return Pl(t)===RW};Ir.isProfiler=function(t){return Pl(t)===XR};Ir.isStrictMode=function(t){return Pl(t)===YR};Ir.isSuspense=function(t){return Pl(t)===eM};Ir.isSuspenseList=function(t){return Pl(t)===tM};Ir.isValidElementType=function(t){return typeof t=="string"||typeof t=="function"||t===KR||t===XR||t===YR||t===eM||t===tM||t===DKe||typeof t=="object"&&t!==null&&(t.$$typeof===nM||t.$$typeof===rM||t.$$typeof===JR||t.$$typeof===QR||t.$$typeof===ZR||t.$$typeof===dge||t.getModuleId!==void 0)};Ir.typeOf=Pl;uge.exports=Ir;var LKe=uge.exports,FKe=Ph,$Ke=Oh,BKe="[object Number]";function zKe(t){return typeof t=="number"||$Ke(t)&&FKe(t)==BKe}var hge=zKe;const UKe=cr(hge);var HKe=hge;function VKe(t){return HKe(t)&&t!=+t}var WKe=VKe;const PE=cr(WKe);var pl=function(e){return e===0?0:e>0?1:-1},tg=function(e){return TE(e)&&e.indexOf("%")===e.length-1},ut=function(e){return UKe(e)&&!PE(e)},Cs=function(e){return ut(e)||TE(e)},qKe=0,sM=function(e){var r=++qKe;return"".concat(e||"").concat(r)},za=function(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!ut(e)&&!TE(e))return n;var i;if(tg(e)){var a=e.indexOf("%");i=r*parseFloat(e.slice(0,a))/100}else i=+e;return PE(i)&&(i=n),s&&i>r&&(i=r),i},ev=function(e){if(!e)return null;var r=Object.keys(e);return r&&r.length?e[r[0]]:null},GKe=function(e){if(!Array.isArray(e))return!1;for(var r=e.length,n={},s=0;s<r;s++)if(!n[e[s]])n[e[s]]=!0;else return!0;return!1},MJ=function(e,r){return ut(e)&&ut(r)?function(n){return e+n*(r-e)}:function(){return r}};function V6(t,e,r){return!t||!t.length?null:t.find(function(n){return n&&(typeof e=="function"?e(n):mc(n,e))===r})}function W6(t,e){for(var r in t)if({}.hasOwnProperty.call(t,r)&&(!{}.hasOwnProperty.call(e,r)||t[r]!==e[r]))return!1;for(var n in e)if({}.hasOwnProperty.call(e,n)&&!{}.hasOwnProperty.call(t,n))return!1;return!0}function q6(t){"@babel/helpers - typeof";return q6=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},q6(t)}var KKe=["viewBox","children"],YKe=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRendering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],DJ=["points","pathLength"],a4={svg:KKe,polygon:DJ,polyline:DJ},MW=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDragCapture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"],gP=function(e,r){if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(j.isValidElement(e)&&(n=e.props),!r1(n))return null;var s={};return Object.keys(n).forEach(function(i){MW.includes(i)&&(s[i]=r||function(a){return n[i](n,a)})}),s},XKe=function(e,r,n){return function(s){return e(r,n,s),null}},iM=function(e,r,n){if(!r1(e)||q6(e)!=="object")return null;var s=null;return Object.keys(e).forEach(function(i){var a=e[i];MW.includes(i)&&typeof a=="function"&&(s||(s={}),s[i]=XKe(a,r,n))}),s},JKe=["children"],QKe=["children"];function LJ(t,e){if(t==null)return{};var r=ZKe(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function ZKe(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}var FJ={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},th=function(e){return typeof e=="string"?e:e?e.displayName||e.name||"Component":""},$J=null,o4=null,DW=function t(e){if(e===$J&&Array.isArray(o4))return o4;var r=[];return j.Children.forEach(e,function(n){hr(n)||(LKe.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),o4=r,$J=e,r};function ju(t,e){var r=[],n=[];return Array.isArray(e)?n=e.map(function(s){return th(s)}):n=[th(e)],DW(t).forEach(function(s){var i=mc(s,"type.displayName")||mc(s,"type.name");n.indexOf(i)!==-1&&r.push(s)}),r}function tl(t,e){var r=ju(t,e);return r&&r[0]}var BJ=function(e){if(!e||!e.props)return!1;var r=e.props,n=r.width,s=r.height;return!(!ut(n)||n<=0||!ut(s)||s<=0)},eYe=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],tYe=function(e){return e&&e.type&&TE(e.type)&&eYe.indexOf(e.type)>=0},rYe=function(e,r,n,s){var i,a=(i=a4==null?void 0:a4[s])!==null&&i!==void 0?i:[];return r.startsWith("data-")||!Xt(e)&&(s&&a.includes(r)||YKe.includes(r))||n&&MW.includes(r)},Gt=function(e,r,n){if(!e||typeof e=="function"||typeof e=="boolean")return null;var s=e;if(j.isValidElement(e)&&(s=e.props),!r1(s))return null;var i={};return Object.keys(s).forEach(function(a){var o;rYe((o=s)===null||o===void 0?void 0:o[a],a,r,n)&&(i[a]=s[a])}),i},G6=function t(e,r){if(e===r)return!0;var n=j.Children.count(e);if(n!==j.Children.count(r))return!1;if(n===0)return!0;if(n===1)return zJ(Array.isArray(e)?e[0]:e,Array.isArray(r)?r[0]:r);for(var s=0;s<n;s++){var i=e[s],a=r[s];if(Array.isArray(i)||Array.isArray(a)){if(!t(i,a))return!1}else if(!zJ(i,a))return!1}return!0},zJ=function(e,r){if(hr(e)&&hr(r))return!0;if(!hr(e)&&!hr(r)){var n=e.props||{},s=n.children,i=LJ(n,JKe),a=r.props||{},o=a.children,c=LJ(a,QKe);return s&&o?W6(i,c)&&G6(s,o):!s&&!o?W6(i,c):!1}return!1},UJ=function(e,r){var n=[],s={};return DW(e).forEach(function(i,a){if(tYe(i))n.push(i);else if(i){var o=th(i.type),c=r[o]||{},u=c.handler,d=c.once;if(u&&(!d||!s[o])){var h=u(i,o,a);n.push(h),s[o]=!0}}}),n},nYe=function(e){var r=e&&e.type;return r&&FJ[r]?FJ[r]:null},sYe=function(e,r){return DW(r).indexOf(e)},iYe=["children","width","height","viewBox","className","style","title","desc"];function K6(){return K6=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},K6.apply(this,arguments)}function aYe(t,e){if(t==null)return{};var r=oYe(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function oYe(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Y6(t){var e=t.children,r=t.width,n=t.height,s=t.viewBox,i=t.className,a=t.style,o=t.title,c=t.desc,u=aYe(t,iYe),d=s||{width:r,height:n,x:0,y:0},h=mr("recharts-surface",i);return pe.createElement("svg",K6({},Gt(u,!0,"svg"),{className:h,width:r,height:n,style:a,viewBox:"".concat(d.x," ").concat(d.y," ").concat(d.width," ").concat(d.height)}),pe.createElement("title",null,o),pe.createElement("desc",null,c),e)}var lYe=["children","className"];function X6(){return X6=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},X6.apply(this,arguments)}function cYe(t,e){if(t==null)return{};var r=uYe(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function uYe(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Vn=pe.forwardRef(function(t,e){var r=t.children,n=t.className,s=cYe(t,lYe),i=mr("recharts-layer",n);return pe.createElement("g",X6({className:i},Gt(s,!0),{ref:e}),r)}),rh=function(e,r){for(var n=arguments.length,s=new Array(n>2?n-2:0),i=2;i<n;i++)s[i-2]=arguments[i]};function dYe(t,e,r){var n=-1,s=t.length;e<0&&(e=-e>s?0:s+e),r=r>s?s:r,r<0&&(r+=s),s=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(s);++n<s;)i[n]=t[n+e];return i}var hYe=dYe,fYe=hYe;function pYe(t,e,r){var n=t.length;return r=r===void 0?n:r,!e&&r>=n?t:fYe(t,e,r)}var mYe=pYe,gYe="\\ud800-\\udfff",yYe="\\u0300-\\u036f",xYe="\\ufe20-\\ufe2f",vYe="\\u20d0-\\u20ff",bYe=yYe+xYe+vYe,wYe="\\ufe0e\\ufe0f",SYe="\\u200d",_Ye=RegExp("["+SYe+gYe+bYe+wYe+"]");function jYe(t){return _Ye.test(t)}var fge=jYe;function kYe(t){return t.split("")}var NYe=kYe,pge="\\ud800-\\udfff",EYe="\\u0300-\\u036f",AYe="\\ufe20-\\ufe2f",CYe="\\u20d0-\\u20ff",TYe=EYe+AYe+CYe,PYe="\\ufe0e\\ufe0f",OYe="["+pge+"]",J6="["+TYe+"]",Q6="\\ud83c[\\udffb-\\udfff]",IYe="(?:"+J6+"|"+Q6+")",mge="[^"+pge+"]",gge="(?:\\ud83c[\\udde6-\\uddff]){2}",yge="[\\ud800-\\udbff][\\udc00-\\udfff]",RYe="\\u200d",xge=IYe+"?",vge="["+PYe+"]?",MYe="(?:"+RYe+"(?:"+[mge,gge,yge].join("|")+")"+vge+xge+")*",DYe=vge+xge+MYe,LYe="(?:"+[mge+J6+"?",J6,gge,yge,OYe].join("|")+")",FYe=RegExp(Q6+"(?="+Q6+")|"+LYe+DYe,"g");function $Ye(t){return t.match(FYe)||[]}var BYe=$Ye,zYe=NYe,UYe=fge,HYe=BYe;function VYe(t){return UYe(t)?HYe(t):zYe(t)}var WYe=VYe,qYe=mYe,GYe=fge,KYe=WYe,YYe=oge;function XYe(t){return function(e){e=YYe(e);var r=GYe(e)?KYe(e):void 0,n=r?r[0]:e.charAt(0),s=r?qYe(r,1).join(""):e.slice(1);return n[t]()+s}}var JYe=XYe,QYe=JYe,ZYe=QYe("toUpperCase"),eXe=ZYe;const aM=cr(eXe);function en(t){return function(){return t}}const bge=Math.cos,yP=Math.sin,kc=Math.sqrt,xP=Math.PI,oM=2*xP,Z6=Math.PI,eB=2*Z6,Lm=1e-6,tXe=eB-Lm;function wge(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=arguments[e]+t[e]}function rXe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return wge;const r=10**e;return function(n){this._+=n[0];for(let s=1,i=n.length;s<i;++s)this._+=Math.round(arguments[s]*r)/r+n[s]}}class nXe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?wge:rXe(e)}moveTo(e,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+r}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,r){this._append`L${this._x1=+e},${this._y1=+r}`}quadraticCurveTo(e,r,n,s){this._append`Q${+e},${+r},${this._x1=+n},${this._y1=+s}`}bezierCurveTo(e,r,n,s,i,a){this._append`C${+e},${+r},${+n},${+s},${this._x1=+i},${this._y1=+a}`}arcTo(e,r,n,s,i){if(e=+e,r=+r,n=+n,s=+s,i=+i,i<0)throw new Error(`negative radius: ${i}`);let a=this._x1,o=this._y1,c=n-e,u=s-r,d=a-e,h=o-r,f=d*d+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=r}`;else if(f>Lm)if(!(Math.abs(h*c-u*d)>Lm)||!i)this._append`L${this._x1=e},${this._y1=r}`;else{let p=n-a,m=s-o,g=c*c+u*u,x=p*p+m*m,y=Math.sqrt(g),v=Math.sqrt(f),b=i*Math.tan((Z6-Math.acos((g+f-x)/(2*y*v)))/2),w=b/v,S=b/y;Math.abs(w-1)>Lm&&this._append`L${e+w*d},${r+w*h}`,this._append`A${i},${i},0,0,${+(h*p>d*m)},${this._x1=e+S*c},${this._y1=r+S*u}`}}arc(e,r,n,s,i,a){if(e=+e,r=+r,n=+n,a=!!a,n<0)throw new Error(`negative radius: ${n}`);let o=n*Math.cos(s),c=n*Math.sin(s),u=e+o,d=r+c,h=1^a,f=a?s-i:i-s;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Lm||Math.abs(this._y1-d)>Lm)&&this._append`L${u},${d}`,n&&(f<0&&(f=f%eB+eB),f>tXe?this._append`A${n},${n},0,1,${h},${e-o},${r-c}A${n},${n},0,1,${h},${this._x1=u},${this._y1=d}`:f>Lm&&this._append`A${n},${n},0,${+(f>=Z6)},${h},${this._x1=e+n*Math.cos(i)},${this._y1=r+n*Math.sin(i)}`)}rect(e,r,n,s){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+r}h${n=+n}v${+s}h${-n}Z`}toString(){return this._}}function LW(t){let e=3;return t.digits=function(r){if(!arguments.length)return e;if(r==null)e=null;else{const n=Math.floor(r);if(!(n>=0))throw new RangeError(`invalid digits: ${r}`);e=n}return t},()=>new nXe(e)}function FW(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Sge(t){this._context=t}Sge.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);break}}};function lM(t){return new Sge(t)}function _ge(t){return t[0]}function jge(t){return t[1]}function kge(t,e){var r=en(!0),n=null,s=lM,i=null,a=LW(o);t=typeof t=="function"?t:t===void 0?_ge:en(t),e=typeof e=="function"?e:e===void 0?jge:en(e);function o(c){var u,d=(c=FW(c)).length,h,f=!1,p;for(n==null&&(i=s(p=a())),u=0;u<=d;++u)!(u<d&&r(h=c[u],u,c))===f&&((f=!f)?i.lineStart():i.lineEnd()),f&&i.point(+t(h,u,c),+e(h,u,c));if(p)return i=null,p+""||null}return o.x=function(c){return arguments.length?(t=typeof c=="function"?c:en(+c),o):t},o.y=function(c){return arguments.length?(e=typeof c=="function"?c:en(+c),o):e},o.defined=function(c){return arguments.length?(r=typeof c=="function"?c:en(!!c),o):r},o.curve=function(c){return arguments.length?(s=c,n!=null&&(i=s(n)),o):s},o.context=function(c){return arguments.length?(c==null?n=i=null:i=s(n=c),o):n},o}function qA(t,e,r){var n=null,s=en(!0),i=null,a=lM,o=null,c=LW(u);t=typeof t=="function"?t:t===void 0?_ge:en(+t),e=typeof e=="function"?e:en(e===void 0?0:+e),r=typeof r=="function"?r:r===void 0?jge:en(+r);function u(h){var f,p,m,g=(h=FW(h)).length,x,y=!1,v,b=new Array(g),w=new Array(g);for(i==null&&(o=a(v=c())),f=0;f<=g;++f){if(!(f<g&&s(x=h[f],f,h))===y)if(y=!y)p=f,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),m=f-1;m>=p;--m)o.point(b[m],w[m]);o.lineEnd(),o.areaEnd()}y&&(b[f]=+t(x,f,h),w[f]=+e(x,f,h),o.point(n?+n(x,f,h):b[f],r?+r(x,f,h):w[f]))}if(v)return o=null,v+""||null}function d(){return kge().defined(s).curve(a).context(i)}return u.x=function(h){return arguments.length?(t=typeof h=="function"?h:en(+h),n=null,u):t},u.x0=function(h){return arguments.length?(t=typeof h=="function"?h:en(+h),u):t},u.x1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:en(+h),u):n},u.y=function(h){return arguments.length?(e=typeof h=="function"?h:en(+h),r=null,u):e},u.y0=function(h){return arguments.length?(e=typeof h=="function"?h:en(+h),u):e},u.y1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:en(+h),u):r},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(r)},u.lineX1=function(){return d().x(n).y(e)},u.defined=function(h){return arguments.length?(s=typeof h=="function"?h:en(!!h),u):s},u.curve=function(h){return arguments.length?(a=h,i!=null&&(o=a(i)),u):a},u.context=function(h){return arguments.length?(h==null?i=o=null:o=a(i=h),u):i},u}class Nge{constructor(e,r){this._context=e,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,r){switch(e=+e,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,r,e,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,e,this._y0,e,r);break}}this._x0=e,this._y0=r}}function sXe(t){return new Nge(t,!0)}function iXe(t){return new Nge(t,!1)}const $W={draw(t,e){const r=kc(e/xP);t.moveTo(r,0),t.arc(0,0,r,0,oM)}},aXe={draw(t,e){const r=kc(e/5)/2;t.moveTo(-3*r,-r),t.lineTo(-r,-r),t.lineTo(-r,-3*r),t.lineTo(r,-3*r),t.lineTo(r,-r),t.lineTo(3*r,-r),t.lineTo(3*r,r),t.lineTo(r,r),t.lineTo(r,3*r),t.lineTo(-r,3*r),t.lineTo(-r,r),t.lineTo(-3*r,r),t.closePath()}},Ege=kc(1/3),oXe=Ege*2,lXe={draw(t,e){const r=kc(e/oXe),n=r*Ege;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},cXe={draw(t,e){const r=kc(e),n=-r/2;t.rect(n,n,r,r)}},uXe=.8908130915292852,Age=yP(xP/10)/yP(7*xP/10),dXe=yP(oM/10)*Age,hXe=-bge(oM/10)*Age,fXe={draw(t,e){const r=kc(e*uXe),n=dXe*r,s=hXe*r;t.moveTo(0,-r),t.lineTo(n,s);for(let i=1;i<5;++i){const a=oM*i/5,o=bge(a),c=yP(a);t.lineTo(c*r,-o*r),t.lineTo(o*n-c*s,c*n+o*s)}t.closePath()}},l4=kc(3),pXe={draw(t,e){const r=-kc(e/(l4*3));t.moveTo(0,r*2),t.lineTo(-l4*r,-r),t.lineTo(l4*r,-r),t.closePath()}},Lo=-.5,Fo=kc(3)/2,tB=1/kc(12),mXe=(tB/2+1)*3,gXe={draw(t,e){const r=kc(e/mXe),n=r/2,s=r*tB,i=n,a=r*tB+r,o=-i,c=a;t.moveTo(n,s),t.lineTo(i,a),t.lineTo(o,c),t.lineTo(Lo*n-Fo*s,Fo*n+Lo*s),t.lineTo(Lo*i-Fo*a,Fo*i+Lo*a),t.lineTo(Lo*o-Fo*c,Fo*o+Lo*c),t.lineTo(Lo*n+Fo*s,Lo*s-Fo*n),t.lineTo(Lo*i+Fo*a,Lo*a-Fo*i),t.lineTo(Lo*o+Fo*c,Lo*c-Fo*o),t.closePath()}};function yXe(t,e){let r=null,n=LW(s);t=typeof t=="function"?t:en(t||$W),e=typeof e=="function"?e:en(e===void 0?64:+e);function s(){let i;if(r||(r=i=n()),t.apply(this,arguments).draw(r,+e.apply(this,arguments)),i)return r=null,i+""||null}return s.type=function(i){return arguments.length?(t=typeof i=="function"?i:en(i),s):t},s.size=function(i){return arguments.length?(e=typeof i=="function"?i:en(+i),s):e},s.context=function(i){return arguments.length?(r=i??null,s):r},s}function vP(){}function bP(t,e,r){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+r)/6)}function Cge(t){this._context=t}Cge.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:bP(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:bP(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function xXe(t){return new Cge(t)}function Tge(t){this._context=t}Tge.prototype={areaStart:vP,areaEnd:vP,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:bP(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function vXe(t){return new Tge(t)}function Pge(t){this._context=t}Pge.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+t)/6,n=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(r,n):this._context.moveTo(r,n);break;case 3:this._point=4;default:bP(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function bXe(t){return new Pge(t)}function Oge(t){this._context=t}Oge.prototype={areaStart:vP,areaEnd:vP,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e))}};function wXe(t){return new Oge(t)}function HJ(t){return t<0?-1:1}function VJ(t,e,r){var n=t._x1-t._x0,s=e-t._x1,i=(t._y1-t._y0)/(n||s<0&&-0),a=(r-t._y1)/(s||n<0&&-0),o=(i*s+a*n)/(n+s);return(HJ(i)+HJ(a))*Math.min(Math.abs(i),Math.abs(a),.5*Math.abs(o))||0}function WJ(t,e){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-e)/2:e}function c4(t,e,r){var n=t._x0,s=t._y0,i=t._x1,a=t._y1,o=(i-n)/3;t._context.bezierCurveTo(n+o,s+o*e,i-o,a-o*r,i,a)}function wP(t){this._context=t}wP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:c4(this,this._t0,WJ(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(t,e){var r=NaN;if(t=+t,e=+e,!(t===this._x1&&e===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,c4(this,WJ(this,r=VJ(this,t,e)),r);break;default:c4(this,this._t0,r=VJ(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=r}}};function Ige(t){this._context=new Rge(t)}(Ige.prototype=Object.create(wP.prototype)).point=function(t,e){wP.prototype.point.call(this,e,t)};function Rge(t){this._context=t}Rge.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,r,n,s,i){this._context.bezierCurveTo(e,t,n,r,i,s)}};function SXe(t){return new wP(t)}function _Xe(t){return new Ige(t)}function Mge(t){this._context=t}Mge.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var t=this._x,e=this._y,r=t.length;if(r)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),r===2)this._context.lineTo(t[1],e[1]);else for(var n=qJ(t),s=qJ(e),i=0,a=1;a<r;++i,++a)this._context.bezierCurveTo(n[0][i],s[0][i],n[1][i],s[1][i],t[a],e[a]);(this._line||this._line!==0&&r===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(t,e){this._x.push(+t),this._y.push(+e)}};function qJ(t){var e,r=t.length-1,n,s=new Array(r),i=new Array(r),a=new Array(r);for(s[0]=0,i[0]=2,a[0]=t[0]+2*t[1],e=1;e<r-1;++e)s[e]=1,i[e]=4,a[e]=4*t[e]+2*t[e+1];for(s[r-1]=2,i[r-1]=7,a[r-1]=8*t[r-1]+t[r],e=1;e<r;++e)n=s[e]/i[e-1],i[e]-=n,a[e]-=n*a[e-1];for(s[r-1]=a[r-1]/i[r-1],e=r-2;e>=0;--e)s[e]=(a[e]-s[e+1])/i[e];for(i[r-1]=(t[r]+s[r-1])/2,e=0;e<r-1;++e)i[e]=2*t[e+1]-s[e+1];return[s,i]}function jXe(t){return new Mge(t)}function cM(t,e){this._context=t,this._t=e}cM.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else{var r=this._x*(1-this._t)+t*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,e)}break}}this._x=t,this._y=e}};function kXe(t){return new cM(t,.5)}function NXe(t){return new cM(t,0)}function EXe(t){return new cM(t,1)}function J0(t,e){if((a=t.length)>1)for(var r=1,n,s,i=t[e[0]],a,o=i.length;r<a;++r)for(s=i,i=t[e[r]],n=0;n<o;++n)i[n][1]+=i[n][0]=isNaN(s[n][1])?s[n][0]:s[n][1]}function rB(t){for(var e=t.length,r=new Array(e);--e>=0;)r[e]=e;return r}function AXe(t,e){return t[e]}function CXe(t){const e=[];return e.key=t,e}function TXe(){var t=en([]),e=rB,r=J0,n=AXe;function s(i){var a=Array.from(t.apply(this,arguments),CXe),o,c=a.length,u=-1,d;for(const h of i)for(o=0,++u;o<c;++o)(a[o][u]=[0,+n(h,a[o].key,u,i)]).data=h;for(o=0,d=FW(e(a));o<c;++o)a[d[o]].index=o;return r(a,d),a}return s.keys=function(i){return arguments.length?(t=typeof i=="function"?i:en(Array.from(i)),s):t},s.value=function(i){return arguments.length?(n=typeof i=="function"?i:en(+i),s):n},s.order=function(i){return arguments.length?(e=i==null?rB:typeof i=="function"?i:en(Array.from(i)),s):e},s.offset=function(i){return arguments.length?(r=i??J0,s):r},s}function PXe(t,e){if((n=t.length)>0){for(var r,n,s=0,i=t[0].length,a;s<i;++s){for(a=r=0;r<n;++r)a+=t[r][s][1]||0;if(a)for(r=0;r<n;++r)t[r][s][1]/=a}J0(t,e)}}function OXe(t,e){if((s=t.length)>0){for(var r=0,n=t[e[0]],s,i=n.length;r<i;++r){for(var a=0,o=0;a<s;++a)o+=t[a][r][1]||0;n[r][1]+=n[r][0]=-o/2}J0(t,e)}}function IXe(t,e){if(!(!((a=t.length)>0)||!((i=(s=t[e[0]]).length)>0))){for(var r=0,n=1,s,i,a;n<i;++n){for(var o=0,c=0,u=0;o<a;++o){for(var d=t[e[o]],h=d[n][1]||0,f=d[n-1][1]||0,p=(h-f)/2,m=0;m<o;++m){var g=t[e[m]],x=g[n][1]||0,y=g[n-1][1]||0;p+=x-y}c+=h,u+=p*h}s[n-1][1]+=s[n-1][0]=r,c&&(r-=u/c)}s[n-1][1]+=s[n-1][0]=r,J0(t,e)}}function bj(t){"@babel/helpers - typeof";return bj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},bj(t)}var RXe=["type","size","sizeType"];function nB(){return nB=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},nB.apply(this,arguments)}function GJ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function KJ(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?GJ(Object(r),!0).forEach(function(n){MXe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):GJ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function MXe(t,e,r){return e=DXe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function DXe(t){var e=LXe(t,"string");return bj(e)=="symbol"?e:e+""}function LXe(t,e){if(bj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(bj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function FXe(t,e){if(t==null)return{};var r=$Xe(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function $Xe(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Dge={symbolCircle:$W,symbolCross:aXe,symbolDiamond:lXe,symbolSquare:cXe,symbolStar:fXe,symbolTriangle:pXe,symbolWye:gXe},BXe=Math.PI/180,zXe=function(e){var r="symbol".concat(aM(e));return Dge[r]||$W},UXe=function(e,r,n){if(r==="area")return e;switch(n){case"cross":return 5*e*e/9;case"diamond":return .5*e*e/Math.sqrt(3);case"square":return e*e;case"star":{var s=18*BXe;return 1.25*e*e*(Math.tan(s)-Math.tan(s*2)*Math.pow(Math.tan(s),2))}case"triangle":return Math.sqrt(3)*e*e/4;case"wye":return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},HXe=function(e,r){Dge["symbol".concat(aM(e))]=r},BW=function(e){var r=e.type,n=r===void 0?"circle":r,s=e.size,i=s===void 0?64:s,a=e.sizeType,o=a===void 0?"area":a,c=FXe(e,RXe),u=KJ(KJ({},c),{},{type:n,size:i,sizeType:o}),d=function(){var x=zXe(n),y=yXe().type(x).size(UXe(i,o,n));return y()},h=u.className,f=u.cx,p=u.cy,m=Gt(u,!0);return f===+f&&p===+p&&i===+i?pe.createElement("path",nB({},m,{className:mr("recharts-symbols",h),transform:"translate(".concat(f,", ").concat(p,")"),d:d()})):null};BW.registerSymbol=HXe;function Q0(t){"@babel/helpers - typeof";return Q0=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Q0(t)}function sB(){return sB=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},sB.apply(this,arguments)}function YJ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function VXe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?YJ(Object(r),!0).forEach(function(n){wj(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):YJ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function WXe(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function qXe(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Fge(n.key),n)}}function GXe(t,e,r){return e&&qXe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function KXe(t,e,r){return e=SP(e),YXe(t,Lge()?Reflect.construct(e,r||[],SP(t).constructor):e.apply(t,r))}function YXe(t,e){if(e&&(Q0(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return XXe(t)}function XXe(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Lge(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Lge=function(){return!!t})()}function SP(t){return SP=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},SP(t)}function JXe(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&iB(t,e)}function iB(t,e){return iB=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},iB(t,e)}function wj(t,e,r){return e=Fge(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Fge(t){var e=QXe(t,"string");return Q0(e)=="symbol"?e:e+""}function QXe(t,e){if(Q0(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Q0(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var $o=32,zW=function(t){function e(){return WXe(this,e),KXe(this,e,arguments)}return JXe(e,t),GXe(e,[{key:"renderIcon",value:function(n){var s=this.props.inactiveColor,i=$o/2,a=$o/6,o=$o/3,c=n.inactive?s:n.color;if(n.type==="plainline")return pe.createElement("line",{strokeWidth:4,fill:"none",stroke:c,strokeDasharray:n.payload.strokeDasharray,x1:0,y1:i,x2:$o,y2:i,className:"recharts-legend-icon"});if(n.type==="line")return pe.createElement("path",{strokeWidth:4,fill:"none",stroke:c,d:"M0,".concat(i,"h").concat(o,`
A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
H`).concat($o,"M").concat(2*o,",").concat(i,`
A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(n.type==="rect")return pe.createElement("path",{stroke:"none",fill:c,d:"M0,".concat($o/8,"h").concat($o,"v").concat($o*3/4,"h").concat(-$o,"z"),className:"recharts-legend-icon"});if(pe.isValidElement(n.legendIcon)){var u=VXe({},n);return delete u.legendIcon,pe.cloneElement(n.legendIcon,u)}return pe.createElement(BW,{fill:c,cx:i,cy:i,size:$o,sizeType:"diameter",type:n.type})}},{key:"renderItems",value:function(){var n=this,s=this.props,i=s.payload,a=s.iconSize,o=s.layout,c=s.formatter,u=s.inactiveColor,d={x:0,y:0,width:$o,height:$o},h={display:o==="horizontal"?"inline-block":"block",marginRight:10},f={display:"inline-block",verticalAlign:"middle",marginRight:4};return i.map(function(p,m){var g=p.formatter||c,x=mr(wj(wj({"recharts-legend-item":!0},"legend-item-".concat(m),!0),"inactive",p.inactive));if(p.type==="none")return null;var y=Xt(p.value)?null:p.value;rh(!Xt(p.value),`The name property is also required when using a function for the dataKey of a chart's cartesian components. Ex: <Bar name="Name of my Data"/>`);var v=p.inactive?u:p.color;return pe.createElement("li",sB({className:x,style:h,key:"legend-item-".concat(m)},iM(n.props,p,m)),pe.createElement(Y6,{width:a,height:a,viewBox:d,style:f},n.renderIcon(p)),pe.createElement("span",{className:"recharts-legend-item-text",style:{color:v}},g?g(y,p,m):y))})}},{key:"render",value:function(){var n=this.props,s=n.payload,i=n.layout,a=n.align;if(!s||!s.length)return null;var o={padding:0,margin:0,textAlign:i==="horizontal"?a:"left"};return pe.createElement("ul",{className:"recharts-default-legend",style:o},this.renderItems())}}])}(j.PureComponent);wj(zW,"displayName","Legend");wj(zW,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var ZXe=WR;function eJe(){this.__data__=new ZXe,this.size=0}var tJe=eJe;function rJe(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var nJe=rJe;function sJe(t){return this.__data__.get(t)}var iJe=sJe;function aJe(t){return this.__data__.has(t)}var oJe=aJe,lJe=WR,cJe=AW,uJe=CW,dJe=200;function hJe(t,e){var r=this.__data__;if(r instanceof lJe){var n=r.__data__;if(!cJe||n.length<dJe-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new uJe(n)}return r.set(t,e),this.size=r.size,this}var fJe=hJe,pJe=WR,mJe=tJe,gJe=nJe,yJe=iJe,xJe=oJe,vJe=fJe;function a1(t){var e=this.__data__=new pJe(t);this.size=e.size}a1.prototype.clear=mJe;a1.prototype.delete=gJe;a1.prototype.get=yJe;a1.prototype.has=xJe;a1.prototype.set=vJe;var $ge=a1,bJe="__lodash_hash_undefined__";function wJe(t){return this.__data__.set(t,bJe),this}var SJe=wJe;function _Je(t){return this.__data__.has(t)}var jJe=_Je,kJe=CW,NJe=SJe,EJe=jJe;function _P(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new kJe;++e<r;)this.add(t[e])}_P.prototype.add=_P.prototype.push=NJe;_P.prototype.has=EJe;var Bge=_P;function AJe(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}var zge=AJe;function CJe(t,e){return t.has(e)}var Uge=CJe,TJe=Bge,PJe=zge,OJe=Uge,IJe=1,RJe=2;function MJe(t,e,r,n,s,i){var a=r&IJe,o=t.length,c=e.length;if(o!=c&&!(a&&c>o))return!1;var u=i.get(t),d=i.get(e);if(u&&d)return u==e&&d==t;var h=-1,f=!0,p=r&RJe?new TJe:void 0;for(i.set(t,e),i.set(e,t);++h<o;){var m=t[h],g=e[h];if(n)var x=a?n(g,m,h,e,t,i):n(m,g,h,t,e,i);if(x!==void 0){if(x)continue;f=!1;break}if(p){if(!PJe(e,function(y,v){if(!OJe(p,v)&&(m===y||s(m,y,r,n,i)))return p.push(v)})){f=!1;break}}else if(!(m===g||s(m,g,r,n,i))){f=!1;break}}return i.delete(t),i.delete(e),f}var Hge=MJe,DJe=Lu,LJe=DJe.Uint8Array,FJe=LJe;function $Je(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}var BJe=$Je;function zJe(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var UW=zJe,XJ=CE,JJ=FJe,UJe=EW,HJe=Hge,VJe=BJe,WJe=UW,qJe=1,GJe=2,KJe="[object Boolean]",YJe="[object Date]",XJe="[object Error]",JJe="[object Map]",QJe="[object Number]",ZJe="[object RegExp]",eQe="[object Set]",tQe="[object String]",rQe="[object Symbol]",nQe="[object ArrayBuffer]",sQe="[object DataView]",QJ=XJ?XJ.prototype:void 0,u4=QJ?QJ.valueOf:void 0;function iQe(t,e,r,n,s,i,a){switch(r){case sQe:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case nQe:return!(t.byteLength!=e.byteLength||!i(new JJ(t),new JJ(e)));case KJe:case YJe:case QJe:return UJe(+t,+e);case XJe:return t.name==e.name&&t.message==e.message;case ZJe:case tQe:return t==e+"";case JJe:var o=VJe;case eQe:var c=n&qJe;if(o||(o=WJe),t.size!=e.size&&!c)return!1;var u=a.get(t);if(u)return u==e;n|=GJe,a.set(t,e);var d=HJe(o(t),o(e),n,s,i,a);return a.delete(t),d;case rQe:if(u4)return u4.call(t)==u4.call(e)}return!1}var aQe=iQe;function oQe(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}var Vge=oQe,lQe=Vge,cQe=eo;function uQe(t,e,r){var n=e(t);return cQe(t)?n:lQe(n,r(t))}var dQe=uQe;function hQe(t,e){for(var r=-1,n=t==null?0:t.length,s=0,i=[];++r<n;){var a=t[r];e(a,r,t)&&(i[s++]=a)}return i}var fQe=hQe;function pQe(){return[]}var mQe=pQe,gQe=fQe,yQe=mQe,xQe=Object.prototype,vQe=xQe.propertyIsEnumerable,ZJ=Object.getOwnPropertySymbols,bQe=ZJ?function(t){return t==null?[]:(t=Object(t),gQe(ZJ(t),function(e){return vQe.call(t,e)}))}:yQe,wQe=bQe;function SQe(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}var _Qe=SQe,jQe=Ph,kQe=Oh,NQe="[object Arguments]";function EQe(t){return kQe(t)&&jQe(t)==NQe}var AQe=EQe,eQ=AQe,CQe=Oh,Wge=Object.prototype,TQe=Wge.hasOwnProperty,PQe=Wge.propertyIsEnumerable,OQe=eQ(function(){return arguments}())?eQ:function(t){return CQe(t)&&TQe.call(t,"callee")&&!PQe.call(t,"callee")},HW=OQe,jP={exports:{}};function IQe(){return!1}var RQe=IQe;jP.exports;(function(t,e){var r=Lu,n=RQe,s=e&&!e.nodeType&&e,i=s&&!0&&t&&!t.nodeType&&t,a=i&&i.exports===s,o=a?r.Buffer:void 0,c=o?o.isBuffer:void 0,u=c||n;t.exports=u})(jP,jP.exports);var qge=jP.exports,MQe=9007199254740991,DQe=/^(?:0|[1-9]\d*)$/;function LQe(t,e){var r=typeof t;return e=e??MQe,!!e&&(r=="number"||r!="symbol"&&DQe.test(t))&&t>-1&&t%1==0&&t<e}var VW=LQe,FQe=9007199254740991;function $Qe(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=FQe}var WW=$Qe,BQe=Ph,zQe=WW,UQe=Oh,HQe="[object Arguments]",VQe="[object Array]",WQe="[object Boolean]",qQe="[object Date]",GQe="[object Error]",KQe="[object Function]",YQe="[object Map]",XQe="[object Number]",JQe="[object Object]",QQe="[object RegExp]",ZQe="[object Set]",eZe="[object String]",tZe="[object WeakMap]",rZe="[object ArrayBuffer]",nZe="[object DataView]",sZe="[object Float32Array]",iZe="[object Float64Array]",aZe="[object Int8Array]",oZe="[object Int16Array]",lZe="[object Int32Array]",cZe="[object Uint8Array]",uZe="[object Uint8ClampedArray]",dZe="[object Uint16Array]",hZe="[object Uint32Array]",ln={};ln[sZe]=ln[iZe]=ln[aZe]=ln[oZe]=ln[lZe]=ln[cZe]=ln[uZe]=ln[dZe]=ln[hZe]=!0;ln[HQe]=ln[VQe]=ln[rZe]=ln[WQe]=ln[nZe]=ln[qQe]=ln[GQe]=ln[KQe]=ln[YQe]=ln[XQe]=ln[JQe]=ln[QQe]=ln[ZQe]=ln[eZe]=ln[tZe]=!1;function fZe(t){return UQe(t)&&zQe(t.length)&&!!ln[BQe(t)]}var pZe=fZe;function mZe(t){return function(e){return t(e)}}var Gge=mZe,kP={exports:{}};kP.exports;(function(t,e){var r=tge,n=e&&!e.nodeType&&e,s=n&&!0&&t&&!t.nodeType&&t,i=s&&s.exports===n,a=i&&r.process,o=function(){try{var c=s&&s.require&&s.require("util").types;return c||a&&a.binding&&a.binding("util")}catch{}}();t.exports=o})(kP,kP.exports);var gZe=kP.exports,yZe=pZe,xZe=Gge,tQ=gZe,rQ=tQ&&tQ.isTypedArray,vZe=rQ?xZe(rQ):yZe,Kge=vZe,bZe=_Qe,wZe=HW,SZe=eo,_Ze=qge,jZe=VW,kZe=Kge,NZe=Object.prototype,EZe=NZe.hasOwnProperty;function AZe(t,e){var r=SZe(t),n=!r&&wZe(t),s=!r&&!n&&_Ze(t),i=!r&&!n&&!s&&kZe(t),a=r||n||s||i,o=a?bZe(t.length,String):[],c=o.length;for(var u in t)(e||EZe.call(t,u))&&!(a&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||jZe(u,c)))&&o.push(u);return o}var CZe=AZe,TZe=Object.prototype;function PZe(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||TZe;return t===r}var OZe=PZe;function IZe(t,e){return function(r){return t(e(r))}}var Yge=IZe,RZe=Yge,MZe=RZe(Object.keys,Object),DZe=MZe,LZe=OZe,FZe=DZe,$Ze=Object.prototype,BZe=$Ze.hasOwnProperty;function zZe(t){if(!LZe(t))return FZe(t);var e=[];for(var r in Object(t))BZe.call(t,r)&&r!="constructor"&&e.push(r);return e}var UZe=zZe,HZe=NW,VZe=WW;function WZe(t){return t!=null&&VZe(t.length)&&!HZe(t)}var uM=WZe,qZe=CZe,GZe=UZe,KZe=uM;function YZe(t){return KZe(t)?qZe(t):GZe(t)}var qW=YZe,XZe=dQe,JZe=wQe,QZe=qW;function ZZe(t){return XZe(t,QZe,JZe)}var eet=ZZe,nQ=eet,tet=1,ret=Object.prototype,net=ret.hasOwnProperty;function set(t,e,r,n,s,i){var a=r&tet,o=nQ(t),c=o.length,u=nQ(e),d=u.length;if(c!=d&&!a)return!1;for(var h=c;h--;){var f=o[h];if(!(a?f in e:net.call(e,f)))return!1}var p=i.get(t),m=i.get(e);if(p&&m)return p==e&&m==t;var g=!0;i.set(t,e),i.set(e,t);for(var x=a;++h<c;){f=o[h];var y=t[f],v=e[f];if(n)var b=a?n(v,y,f,e,t,i):n(y,v,f,t,e,i);if(!(b===void 0?y===v||s(y,v,r,n,i):b)){g=!1;break}x||(x=f=="constructor")}if(g&&!x){var w=t.constructor,S=e.constructor;w!=S&&"constructor"in t&&"constructor"in e&&!(typeof w=="function"&&w instanceof w&&typeof S=="function"&&S instanceof S)&&(g=!1)}return i.delete(t),i.delete(e),g}var iet=set,aet=_x,oet=Lu,cet=aet(oet,"DataView"),uet=cet,det=_x,het=Lu,fet=det(het,"Promise"),pet=fet,met=_x,get=Lu,yet=met(get,"Set"),Xge=yet,xet=_x,vet=Lu,bet=xet(vet,"WeakMap"),wet=bet,aB=uet,oB=AW,lB=pet,cB=Xge,uB=wet,Jge=Ph,o1=nge,sQ="[object Map]",_et="[object Object]",iQ="[object Promise]",aQ="[object Set]",oQ="[object WeakMap]",lQ="[object DataView]",jet=o1(aB),ket=o1(oB),Net=o1(lB),Eet=o1(cB),Aet=o1(uB),Fm=Jge;(aB&&Fm(new aB(new ArrayBuffer(1)))!=lQ||oB&&Fm(new oB)!=sQ||lB&&Fm(lB.resolve())!=iQ||cB&&Fm(new cB)!=aQ||uB&&Fm(new uB)!=oQ)&&(Fm=function(t){var e=Jge(t),r=e==_et?t.constructor:void 0,n=r?o1(r):"";if(n)switch(n){case jet:return lQ;case ket:return sQ;case Net:return iQ;case Eet:return aQ;case Aet:return oQ}return e});var Cet=Fm,d4=$ge,Tet=Hge,Pet=aQe,Oet=iet,cQ=Cet,uQ=eo,dQ=qge,Iet=Kge,Ret=1,hQ="[object Arguments]",fQ="[object Array]",GA="[object Object]",Met=Object.prototype,pQ=Met.hasOwnProperty;function Det(t,e,r,n,s,i){var a=uQ(t),o=uQ(e),c=a?fQ:cQ(t),u=o?fQ:cQ(e);c=c==hQ?GA:c,u=u==hQ?GA:u;var d=c==GA,h=u==GA,f=c==u;if(f&&dQ(t)){if(!dQ(e))return!1;a=!0,d=!1}if(f&&!d)return i||(i=new d4),a||Iet(t)?Tet(t,e,r,n,s,i):Pet(t,e,c,r,n,s,i);if(!(r&Ret)){var p=d&&pQ.call(t,"__wrapped__"),m=h&&pQ.call(e,"__wrapped__");if(p||m){var g=p?t.value():t,x=m?e.value():e;return i||(i=new d4),s(g,x,r,n,i)}}return f?(i||(i=new d4),Oet(t,e,r,n,s,i)):!1}var Let=Det,Fet=Let,mQ=Oh;function Qge(t,e,r,n,s){return t===e?!0:t==null||e==null||!mQ(t)&&!mQ(e)?t!==t&&e!==e:Fet(t,e,r,n,Qge,s)}var GW=Qge,$et=$ge,Bet=GW,zet=1,Uet=2;function Het(t,e,r,n){var s=r.length,i=s,a=!n;if(t==null)return!i;for(t=Object(t);s--;){var o=r[s];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++s<i;){o=r[s];var c=o[0],u=t[c],d=o[1];if(a&&o[2]){if(u===void 0&&!(c in t))return!1}else{var h=new $et;if(n)var f=n(u,d,c,t,e,h);if(!(f===void 0?Bet(d,u,zet|Uet,n,h):f))return!1}}return!0}var Vet=Het,Wet=lm;function qet(t){return t===t&&!Wet(t)}var Zge=qet,Get=Zge,Ket=qW;function Yet(t){for(var e=Ket(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,Get(s)]}return e}var Xet=Yet;function Jet(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}var eye=Jet,Qet=Vet,Zet=Xet,ett=eye;function ttt(t){var e=Zet(t);return e.length==1&&e[0][2]?ett(e[0][0],e[0][1]):function(r){return r===t||Qet(r,t,e)}}var rtt=ttt;function ntt(t,e){return t!=null&&e in Object(t)}var stt=ntt,itt=lge,att=HW,ott=eo,ltt=VW,ctt=WW,utt=GR;function dtt(t,e,r){e=itt(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var a=utt(e[n]);if(!(i=t!=null&&r(t,a)))break;t=t[a]}return i||++n!=s?i:(s=t==null?0:t.length,!!s&&ctt(s)&<t(a,s)&&(ott(t)||att(t)))}var htt=dtt,ftt=stt,ptt=htt;function mtt(t,e){return t!=null&&ptt(t,e,ftt)}var gtt=mtt,ytt=GW,xtt=cge,vtt=gtt,btt=kW,wtt=Zge,Stt=eye,_tt=GR,jtt=1,ktt=2;function Ntt(t,e){return btt(t)&&wtt(e)?Stt(_tt(t),e):function(r){var n=xtt(r,t);return n===void 0&&n===e?vtt(r,t):ytt(e,n,jtt|ktt)}}var Ett=Ntt;function Att(t){return t}var l1=Att;function Ctt(t){return function(e){return e==null?void 0:e[t]}}var Ttt=Ctt,Ptt=OW;function Ott(t){return function(e){return Ptt(e,t)}}var Itt=Ott,Rtt=Ttt,Mtt=Itt,Dtt=kW,Ltt=GR;function Ftt(t){return Dtt(t)?Rtt(Ltt(t)):Mtt(t)}var $tt=Ftt,Btt=rtt,ztt=Ett,Utt=l1,Htt=eo,Vtt=$tt;function Wtt(t){return typeof t=="function"?t:t==null?Utt:typeof t=="object"?Htt(t)?ztt(t[0],t[1]):Btt(t):Vtt(t)}var cm=Wtt;function qtt(t,e,r,n){for(var s=t.length,i=r+(n?1:-1);n?i--:++i<s;)if(e(t[i],i,t))return i;return-1}var Gtt=qtt;function Ktt(t){return t!==t}var Ytt=Ktt;function Xtt(t,e,r){for(var n=r-1,s=t.length;++n<s;)if(t[n]===e)return n;return-1}var Jtt=Xtt,Qtt=Gtt,Ztt=Ytt,ert=Jtt;function trt(t,e,r){return e===e?ert(t,e,r):Qtt(t,Ztt,r)}var rrt=trt,nrt=rrt;function srt(t,e){var r=t==null?0:t.length;return!!r&&nrt(t,e,0)>-1}var irt=srt;function art(t,e,r){for(var n=-1,s=t==null?0:t.length;++n<s;)if(r(e,t[n]))return!0;return!1}var ort=art;function lrt(){}var crt=lrt,h4=Xge,urt=crt,drt=UW,hrt=1/0,frt=h4&&1/drt(new h4([,-0]))[1]==hrt?function(t){return new h4(t)}:urt,prt=frt,mrt=Bge,grt=irt,yrt=ort,xrt=Uge,vrt=prt,brt=UW,wrt=200;function Srt(t,e,r){var n=-1,s=grt,i=t.length,a=!0,o=[],c=o;if(r)a=!1,s=yrt;else if(i>=wrt){var u=e?null:vrt(t);if(u)return brt(u);a=!1,s=xrt,c=new mrt}else c=e?[]:o;e:for(;++n<i;){var d=t[n],h=e?e(d):d;if(d=r||d!==0?d:0,a&&h===h){for(var f=c.length;f--;)if(c[f]===h)continue e;e&&c.push(h),o.push(d)}else s(c,h,r)||(c!==o&&c.push(h),o.push(d))}return o}var _rt=Srt,jrt=cm,krt=_rt;function Nrt(t,e){return t&&t.length?krt(t,jrt(e)):[]}var Ert=Nrt;const gQ=cr(Ert);function tye(t,e,r){return e===!0?gQ(t,r):Xt(e)?gQ(t,e):t}function Z0(t){"@babel/helpers - typeof";return Z0=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Z0(t)}var Art=["ref"];function yQ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Hu(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?yQ(Object(r),!0).forEach(function(n){dM(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):yQ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Crt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function xQ(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,nye(n.key),n)}}function Trt(t,e,r){return e&&xQ(t.prototype,e),r&&xQ(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Prt(t,e,r){return e=NP(e),Ort(t,rye()?Reflect.construct(e,r||[],NP(t).constructor):e.apply(t,r))}function Ort(t,e){if(e&&(Z0(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Irt(t)}function Irt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function rye(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(rye=function(){return!!t})()}function NP(t){return NP=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},NP(t)}function Rrt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&dB(t,e)}function dB(t,e){return dB=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},dB(t,e)}function dM(t,e,r){return e=nye(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function nye(t){var e=Mrt(t,"string");return Z0(e)=="symbol"?e:e+""}function Mrt(t,e){if(Z0(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Z0(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Drt(t,e){if(t==null)return{};var r=Lrt(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Lrt(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Frt(t){return t.value}function $rt(t,e){if(pe.isValidElement(t))return pe.cloneElement(t,e);if(typeof t=="function")return pe.createElement(t,e);e.ref;var r=Drt(e,Art);return pe.createElement(zW,r)}var vQ=1,ob=function(t){function e(){var r;Crt(this,e);for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];return r=Prt(this,e,[].concat(s)),dM(r,"lastBoundingBox",{width:-1,height:-1}),r}return Rrt(e,t),Trt(e,[{key:"componentDidMount",value:function(){this.updateBBox()}},{key:"componentDidUpdate",value:function(){this.updateBBox()}},{key:"getBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var n=this.wrapperNode.getBoundingClientRect();return n.height=this.wrapperNode.offsetHeight,n.width=this.wrapperNode.offsetWidth,n}return null}},{key:"updateBBox",value:function(){var n=this.props.onBBoxUpdate,s=this.getBBox();s?(Math.abs(s.width-this.lastBoundingBox.width)>vQ||Math.abs(s.height-this.lastBoundingBox.height)>vQ)&&(this.lastBoundingBox.width=s.width,this.lastBoundingBox.height=s.height,n&&n(s)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,n&&n(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?Hu({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var s=this.props,i=s.layout,a=s.align,o=s.verticalAlign,c=s.margin,u=s.chartWidth,d=s.chartHeight,h,f;if(!n||(n.left===void 0||n.left===null)&&(n.right===void 0||n.right===null))if(a==="center"&&i==="vertical"){var p=this.getBBoxSnapshot();h={left:((u||0)-p.width)/2}}else h=a==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!n||(n.top===void 0||n.top===null)&&(n.bottom===void 0||n.bottom===null))if(o==="middle"){var m=this.getBBoxSnapshot();f={top:((d||0)-m.height)/2}}else f=o==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return Hu(Hu({},h),f)}},{key:"render",value:function(){var n=this,s=this.props,i=s.content,a=s.width,o=s.height,c=s.wrapperStyle,u=s.payloadUniqBy,d=s.payload,h=Hu(Hu({position:"absolute",width:a||"auto",height:o||"auto"},this.getDefaultPosition(c)),c);return pe.createElement("div",{className:"recharts-legend-wrapper",style:h,ref:function(p){n.wrapperNode=p}},$rt(i,Hu(Hu({},this.props),{},{payload:tye(d,u,Frt)})))}}],[{key:"getWithHeight",value:function(n,s){var i=Hu(Hu({},this.defaultProps),n.props),a=i.layout;return a==="vertical"&&ut(n.props.height)?{height:n.props.height}:a==="horizontal"?{width:n.props.width||s}:null}}])}(j.PureComponent);dM(ob,"displayName","Legend");dM(ob,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var bQ=CE,Brt=HW,zrt=eo,wQ=bQ?bQ.isConcatSpreadable:void 0;function Urt(t){return zrt(t)||Brt(t)||!!(wQ&&t&&t[wQ])}var Hrt=Urt,Vrt=Vge,Wrt=Hrt;function sye(t,e,r,n,s){var i=-1,a=t.length;for(r||(r=Wrt),s||(s=[]);++i<a;){var o=t[i];e>0&&r(o)?e>1?sye(o,e-1,r,n,s):Vrt(s,o):n||(s[s.length]=o)}return s}var iye=sye;function qrt(t){return function(e,r,n){for(var s=-1,i=Object(e),a=n(e),o=a.length;o--;){var c=a[t?o:++s];if(r(i[c],c,i)===!1)break}return e}}var Grt=qrt,Krt=Grt,Yrt=Krt(),Xrt=Yrt,Jrt=Xrt,Qrt=qW;function Zrt(t,e){return t&&Jrt(t,e,Qrt)}var aye=Zrt,ent=uM;function tnt(t,e){return function(r,n){if(r==null)return r;if(!ent(r))return t(r,n);for(var s=r.length,i=e?s:-1,a=Object(r);(e?i--:++i<s)&&n(a[i],i,a)!==!1;);return r}}var rnt=tnt,nnt=aye,snt=rnt,int=snt(nnt),KW=int,ant=KW,ont=uM;function lnt(t,e){var r=-1,n=ont(t)?Array(t.length):[];return ant(t,function(s,i,a){n[++r]=e(s,i,a)}),n}var oye=lnt;function cnt(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}var unt=cnt,SQ=t1;function dnt(t,e){if(t!==e){var r=t!==void 0,n=t===null,s=t===t,i=SQ(t),a=e!==void 0,o=e===null,c=e===e,u=SQ(e);if(!o&&!u&&!i&&t>e||i&&a&&c&&!o&&!u||n&&a&&c||!r&&c||!s)return 1;if(!n&&!i&&!u&&t<e||u&&r&&s&&!n&&!i||o&&r&&s||!a&&s||!c)return-1}return 0}var hnt=dnt,fnt=hnt;function pnt(t,e,r){for(var n=-1,s=t.criteria,i=e.criteria,a=s.length,o=r.length;++n<a;){var c=fnt(s[n],i[n]);if(c){if(n>=o)return c;var u=r[n];return c*(u=="desc"?-1:1)}}return t.index-e.index}var mnt=pnt,f4=PW,gnt=OW,ynt=cm,xnt=oye,vnt=unt,bnt=Gge,wnt=mnt,Snt=l1,_nt=eo;function jnt(t,e,r){e.length?e=f4(e,function(i){return _nt(i)?function(a){return gnt(a,i.length===1?i[0]:i)}:i}):e=[Snt];var n=-1;e=f4(e,bnt(ynt));var s=xnt(t,function(i,a,o){var c=f4(e,function(u){return u(i)});return{criteria:c,index:++n,value:i}});return vnt(s,function(i,a){return wnt(i,a,r)})}var knt=jnt;function Nnt(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var Ent=Nnt,Ant=Ent,_Q=Math.max;function Cnt(t,e,r){return e=_Q(e===void 0?t.length-1:e,0),function(){for(var n=arguments,s=-1,i=_Q(n.length-e,0),a=Array(i);++s<i;)a[s]=n[e+s];s=-1;for(var o=Array(e+1);++s<e;)o[s]=n[s];return o[e]=r(a),Ant(t,this,o)}}var Tnt=Cnt;function Pnt(t){return function(){return t}}var Ont=Pnt,Int=_x,Rnt=function(){try{var t=Int(Object,"defineProperty");return t({},"",{}),t}catch{}}(),lye=Rnt,Mnt=Ont,jQ=lye,Dnt=l1,Lnt=jQ?function(t,e){return jQ(t,"toString",{configurable:!0,enumerable:!1,value:Mnt(e),writable:!0})}:Dnt,Fnt=Lnt,$nt=800,Bnt=16,znt=Date.now;function Unt(t){var e=0,r=0;return function(){var n=znt(),s=Bnt-(n-r);if(r=n,s>0){if(++e>=$nt)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Hnt=Unt,Vnt=Fnt,Wnt=Hnt,qnt=Wnt(Vnt),Gnt=qnt,Knt=l1,Ynt=Tnt,Xnt=Gnt;function Jnt(t,e){return Xnt(Ynt(t,e,Knt),t+"")}var Qnt=Jnt,Znt=EW,est=uM,tst=VW,rst=lm;function nst(t,e,r){if(!rst(r))return!1;var n=typeof e;return(n=="number"?est(r)&&tst(e,r.length):n=="string"&&e in r)?Znt(r[e],t):!1}var hM=nst,sst=iye,ist=knt,ast=Qnt,kQ=hM,ost=ast(function(t,e){if(t==null)return[];var r=e.length;return r>1&&kQ(t,e[0],e[1])?e=[]:r>2&&kQ(e[0],e[1],e[2])&&(e=[e[0]]),ist(t,sst(e,1),[])}),lst=ost;const YW=cr(lst);function Sj(t){"@babel/helpers - typeof";return Sj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Sj(t)}function hB(){return hB=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},hB.apply(this,arguments)}function cst(t,e){return fst(t)||hst(t,e)||dst(t,e)||ust()}function ust(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dst(t,e){if(t){if(typeof t=="string")return NQ(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return NQ(t,e)}}function NQ(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function hst(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function fst(t){if(Array.isArray(t))return t}function EQ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function p4(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?EQ(Object(r),!0).forEach(function(n){pst(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):EQ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function pst(t,e,r){return e=mst(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function mst(t){var e=gst(t,"string");return Sj(e)=="symbol"?e:e+""}function gst(t,e){if(Sj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Sj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function yst(t){return Array.isArray(t)&&Cs(t[0])&&Cs(t[1])?t.join(" ~ "):t}var xst=function(e){var r=e.separator,n=r===void 0?" : ":r,s=e.contentStyle,i=s===void 0?{}:s,a=e.itemStyle,o=a===void 0?{}:a,c=e.labelStyle,u=c===void 0?{}:c,d=e.payload,h=e.formatter,f=e.itemSorter,p=e.wrapperClassName,m=e.labelClassName,g=e.label,x=e.labelFormatter,y=e.accessibilityLayer,v=y===void 0?!1:y,b=function(){if(d&&d.length){var P={padding:0,margin:0},W=(f?YW(d,f):d).map(function(N,U){if(N.type==="none")return null;var K=p4({display:"block",paddingTop:4,paddingBottom:4,color:N.color||"#000"},o),G=N.formatter||h||yst,X=N.value,H=N.name,B=X,L=H;if(G&&B!=null&&L!=null){var F=G(X,H,N,U,d);if(Array.isArray(F)){var V=cst(F,2);B=V[0],L=V[1]}else B=F}return pe.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(U),style:K},Cs(L)?pe.createElement("span",{className:"recharts-tooltip-item-name"},L):null,Cs(L)?pe.createElement("span",{className:"recharts-tooltip-item-separator"},n):null,pe.createElement("span",{className:"recharts-tooltip-item-value"},B),pe.createElement("span",{className:"recharts-tooltip-item-unit"},N.unit||""))});return pe.createElement("ul",{className:"recharts-tooltip-item-list",style:P},W)}return null},w=p4({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},i),S=p4({margin:0},u),k=!hr(g),E=k?g:"",C=mr("recharts-default-tooltip",p),A=mr("recharts-tooltip-label",m);k&&x&&d!==void 0&&d!==null&&(E=x(g,d));var M=v?{role:"status","aria-live":"assertive"}:{};return pe.createElement("div",hB({className:C,style:w},M),pe.createElement("p",{className:A,style:S},pe.isValidElement(E)?E:"".concat(E)),b())};function _j(t){"@babel/helpers - typeof";return _j=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_j(t)}function KA(t,e,r){return e=vst(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vst(t){var e=bst(t,"string");return _j(e)=="symbol"?e:e+""}function bst(t,e){if(_j(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(_j(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var D1="recharts-tooltip-wrapper",wst={visibility:"hidden"};function Sst(t){var e=t.coordinate,r=t.translateX,n=t.translateY;return mr(D1,KA(KA(KA(KA({},"".concat(D1,"-right"),ut(r)&&e&&ut(e.x)&&r>=e.x),"".concat(D1,"-left"),ut(r)&&e&&ut(e.x)&&r<e.x),"".concat(D1,"-bottom"),ut(n)&&e&&ut(e.y)&&n>=e.y),"".concat(D1,"-top"),ut(n)&&e&&ut(e.y)&&n<e.y))}function AQ(t){var e=t.allowEscapeViewBox,r=t.coordinate,n=t.key,s=t.offsetTopLeft,i=t.position,a=t.reverseDirection,o=t.tooltipDimension,c=t.viewBox,u=t.viewBoxDimension;if(i&&ut(i[n]))return i[n];var d=r[n]-o-s,h=r[n]+s;if(e[n])return a[n]?d:h;if(a[n]){var f=d,p=c[n];return f<p?Math.max(h,c[n]):Math.max(d,c[n])}var m=h+o,g=c[n]+u;return m>g?Math.max(d,c[n]):Math.max(h,c[n])}function _st(t){var e=t.translateX,r=t.translateY,n=t.useTranslate3d;return{transform:n?"translate3d(".concat(e,"px, ").concat(r,"px, 0)"):"translate(".concat(e,"px, ").concat(r,"px)")}}function jst(t){var e=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,s=t.position,i=t.reverseDirection,a=t.tooltipBox,o=t.useTranslate3d,c=t.viewBox,u,d,h;return a.height>0&&a.width>0&&r?(d=AQ({allowEscapeViewBox:e,coordinate:r,key:"x",offsetTopLeft:n,position:s,reverseDirection:i,tooltipDimension:a.width,viewBox:c,viewBoxDimension:c.width}),h=AQ({allowEscapeViewBox:e,coordinate:r,key:"y",offsetTopLeft:n,position:s,reverseDirection:i,tooltipDimension:a.height,viewBox:c,viewBoxDimension:c.height}),u=_st({translateX:d,translateY:h,useTranslate3d:o})):u=wst,{cssProperties:u,cssClasses:Sst({translateX:d,translateY:h,coordinate:r})}}function ew(t){"@babel/helpers - typeof";return ew=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ew(t)}function CQ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function TQ(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?CQ(Object(r),!0).forEach(function(n){pB(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):CQ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function kst(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Nst(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,uye(n.key),n)}}function Est(t,e,r){return e&&Nst(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ast(t,e,r){return e=EP(e),Cst(t,cye()?Reflect.construct(e,r||[],EP(t).constructor):e.apply(t,r))}function Cst(t,e){if(e&&(ew(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Tst(t)}function Tst(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function cye(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(cye=function(){return!!t})()}function EP(t){return EP=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},EP(t)}function Pst(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&fB(t,e)}function fB(t,e){return fB=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},fB(t,e)}function pB(t,e,r){return e=uye(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function uye(t){var e=Ost(t,"string");return ew(e)=="symbol"?e:e+""}function Ost(t,e){if(ew(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(ew(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var PQ=1,Ist=function(t){function e(){var r;kst(this,e);for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];return r=Ast(this,e,[].concat(s)),pB(r,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0},lastBoundingBox:{width:-1,height:-1}}),pB(r,"handleKeyDown",function(a){if(a.key==="Escape"){var o,c,u,d;r.setState({dismissed:!0,dismissedAtCoordinate:{x:(o=(c=r.props.coordinate)===null||c===void 0?void 0:c.x)!==null&&o!==void 0?o:0,y:(u=(d=r.props.coordinate)===null||d===void 0?void 0:d.y)!==null&&u!==void 0?u:0}})}}),r}return Pst(e,t),Est(e,[{key:"updateBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var n=this.wrapperNode.getBoundingClientRect();(Math.abs(n.width-this.state.lastBoundingBox.width)>PQ||Math.abs(n.height-this.state.lastBoundingBox.height)>PQ)&&this.setState({lastBoundingBox:{width:n.width,height:n.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var n,s;this.props.active&&this.updateBBox(),this.state.dismissed&&(((n=this.props.coordinate)===null||n===void 0?void 0:n.x)!==this.state.dismissedAtCoordinate.x||((s=this.props.coordinate)===null||s===void 0?void 0:s.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var n=this,s=this.props,i=s.active,a=s.allowEscapeViewBox,o=s.animationDuration,c=s.animationEasing,u=s.children,d=s.coordinate,h=s.hasPayload,f=s.isAnimationActive,p=s.offset,m=s.position,g=s.reverseDirection,x=s.useTranslate3d,y=s.viewBox,v=s.wrapperStyle,b=jst({allowEscapeViewBox:a,coordinate:d,offsetTopLeft:p,position:m,reverseDirection:g,tooltipBox:this.state.lastBoundingBox,useTranslate3d:x,viewBox:y}),w=b.cssClasses,S=b.cssProperties,k=TQ(TQ({transition:f&&i?"transform ".concat(o,"ms ").concat(c):void 0},S),{},{pointerEvents:"none",visibility:!this.state.dismissed&&i&&h?"visible":"hidden",position:"absolute",top:0,left:0},v);return pe.createElement("div",{tabIndex:-1,className:w,style:k,ref:function(C){n.wrapperNode=C}},u)}}])}(j.PureComponent),Rst=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},Py={isSsr:Rst(),get:function(e){return Py[e]},set:function(e,r){if(typeof e=="string")Py[e]=r;else{var n=Object.keys(e);n&&n.length&&n.forEach(function(s){Py[s]=e[s]})}}};function tw(t){"@babel/helpers - typeof";return tw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},tw(t)}function OQ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function IQ(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?OQ(Object(r),!0).forEach(function(n){XW(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):OQ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Mst(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Dst(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,hye(n.key),n)}}function Lst(t,e,r){return e&&Dst(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Fst(t,e,r){return e=AP(e),$st(t,dye()?Reflect.construct(e,r||[],AP(t).constructor):e.apply(t,r))}function $st(t,e){if(e&&(tw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Bst(t)}function Bst(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function dye(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(dye=function(){return!!t})()}function AP(t){return AP=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},AP(t)}function zst(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&mB(t,e)}function mB(t,e){return mB=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},mB(t,e)}function XW(t,e,r){return e=hye(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function hye(t){var e=Ust(t,"string");return tw(e)=="symbol"?e:e+""}function Ust(t,e){if(tw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(tw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Hst(t){return t.dataKey}function Vst(t,e){return pe.isValidElement(t)?pe.cloneElement(t,e):typeof t=="function"?pe.createElement(t,e):pe.createElement(xst,e)}var id=function(t){function e(){return Mst(this,e),Fst(this,e,arguments)}return zst(e,t),Lst(e,[{key:"render",value:function(){var n=this,s=this.props,i=s.active,a=s.allowEscapeViewBox,o=s.animationDuration,c=s.animationEasing,u=s.content,d=s.coordinate,h=s.filterNull,f=s.isAnimationActive,p=s.offset,m=s.payload,g=s.payloadUniqBy,x=s.position,y=s.reverseDirection,v=s.useTranslate3d,b=s.viewBox,w=s.wrapperStyle,S=m??[];h&&S.length&&(S=tye(m.filter(function(E){return E.value!=null&&(E.hide!==!0||n.props.includeHidden)}),g,Hst));var k=S.length>0;return pe.createElement(Ist,{allowEscapeViewBox:a,animationDuration:o,animationEasing:c,isAnimationActive:f,active:i,coordinate:d,hasPayload:k,offset:p,position:x,reverseDirection:y,useTranslate3d:v,viewBox:b,wrapperStyle:w},Vst(u,IQ(IQ({},this.props),{},{payload:S})))}}])}(j.PureComponent);XW(id,"displayName","Tooltip");XW(id,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!Py.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var Wst=Lu,qst=function(){return Wst.Date.now()},Gst=qst,Kst=/\s/;function Yst(t){for(var e=t.length;e--&&Kst.test(t.charAt(e)););return e}var Xst=Yst,Jst=Xst,Qst=/^\s+/;function Zst(t){return t&&t.slice(0,Jst(t)+1).replace(Qst,"")}var eit=Zst,tit=eit,RQ=lm,rit=t1,MQ=NaN,nit=/^[-+]0x[0-9a-f]+$/i,sit=/^0b[01]+$/i,iit=/^0o[0-7]+$/i,ait=parseInt;function oit(t){if(typeof t=="number")return t;if(rit(t))return MQ;if(RQ(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=RQ(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=tit(t);var r=sit.test(t);return r||iit.test(t)?ait(t.slice(2),r?2:8):nit.test(t)?MQ:+t}var fye=oit,lit=lm,m4=Gst,DQ=fye,cit="Expected a function",uit=Math.max,dit=Math.min;function hit(t,e,r){var n,s,i,a,o,c,u=0,d=!1,h=!1,f=!0;if(typeof t!="function")throw new TypeError(cit);e=DQ(e)||0,lit(r)&&(d=!!r.leading,h="maxWait"in r,i=h?uit(DQ(r.maxWait)||0,e):i,f="trailing"in r?!!r.trailing:f);function p(k){var E=n,C=s;return n=s=void 0,u=k,a=t.apply(C,E),a}function m(k){return u=k,o=setTimeout(y,e),d?p(k):a}function g(k){var E=k-c,C=k-u,A=e-E;return h?dit(A,i-C):A}function x(k){var E=k-c,C=k-u;return c===void 0||E>=e||E<0||h&&C>=i}function y(){var k=m4();if(x(k))return v(k);o=setTimeout(y,g(k))}function v(k){return o=void 0,f&&n?p(k):(n=s=void 0,a)}function b(){o!==void 0&&clearTimeout(o),u=0,n=c=s=o=void 0}function w(){return o===void 0?a:v(m4())}function S(){var k=m4(),E=x(k);if(n=arguments,s=this,c=k,E){if(o===void 0)return m(c);if(h)return clearTimeout(o),o=setTimeout(y,e),p(c)}return o===void 0&&(o=setTimeout(y,e)),a}return S.cancel=b,S.flush=w,S}var fit=hit,pit=fit,mit=lm,git="Expected a function";function yit(t,e,r){var n=!0,s=!0;if(typeof t!="function")throw new TypeError(git);return mit(r)&&(n="leading"in r?!!r.leading:n,s="trailing"in r?!!r.trailing:s),pit(t,e,{leading:n,maxWait:e,trailing:s})}var xit=yit;const pye=cr(xit);function jj(t){"@babel/helpers - typeof";return jj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},jj(t)}function LQ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function YA(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?LQ(Object(r),!0).forEach(function(n){vit(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):LQ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function vit(t,e,r){return e=bit(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function bit(t){var e=wit(t,"string");return jj(e)=="symbol"?e:e+""}function wit(t,e){if(jj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(jj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Sit(t,e){return Nit(t)||kit(t,e)||jit(t,e)||_it()}function _it(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jit(t,e){if(t){if(typeof t=="string")return FQ(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return FQ(t,e)}}function FQ(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function kit(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function Nit(t){if(Array.isArray(t))return t}var mye=j.forwardRef(function(t,e){var r=t.aspect,n=t.initialDimension,s=n===void 0?{width:-1,height:-1}:n,i=t.width,a=i===void 0?"100%":i,o=t.height,c=o===void 0?"100%":o,u=t.minWidth,d=u===void 0?0:u,h=t.minHeight,f=t.maxHeight,p=t.children,m=t.debounce,g=m===void 0?0:m,x=t.id,y=t.className,v=t.onResize,b=t.style,w=b===void 0?{}:b,S=j.useRef(null),k=j.useRef();k.current=v,j.useImperativeHandle(e,function(){return Object.defineProperty(S.current,"current",{get:function(){return console.warn("The usage of ref.current.current is deprecated and will no longer be supported."),S.current},configurable:!0})});var E=j.useState({containerWidth:s.width,containerHeight:s.height}),C=Sit(E,2),A=C[0],M=C[1],z=j.useCallback(function(W,N){M(function(U){var K=Math.round(W),G=Math.round(N);return U.containerWidth===K&&U.containerHeight===G?U:{containerWidth:K,containerHeight:G}})},[]);j.useEffect(function(){var W=function(H){var B,L=H[0].contentRect,F=L.width,V=L.height;z(F,V),(B=k.current)===null||B===void 0||B.call(k,F,V)};g>0&&(W=pye(W,g,{trailing:!0,leading:!1}));var N=new ResizeObserver(W),U=S.current.getBoundingClientRect(),K=U.width,G=U.height;return z(K,G),N.observe(S.current),function(){N.disconnect()}},[z,g]);var P=j.useMemo(function(){var W=A.containerWidth,N=A.containerHeight;if(W<0||N<0)return null;rh(tg(a)||tg(c),`The width(%s) and height(%s) are both fixed numbers,
maybe you don't need to use a ResponsiveContainer.`,a,c),rh(!r||r>0,"The aspect(%s) must be greater than zero.",r);var U=tg(a)?W:a,K=tg(c)?N:c;r&&r>0&&(U?K=U/r:K&&(U=K*r),f&&K>f&&(K=f)),rh(U>0||K>0,`The width(%s) and height(%s) of chart should be greater than 0,
please check the style of container, or the props width(%s) and height(%s),
or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
height and width.`,U,K,a,c,d,h,r);var G=!Array.isArray(p)&&th(p.type).endsWith("Chart");return pe.Children.map(p,function(X){return pe.isValidElement(X)?j.cloneElement(X,YA({width:U,height:K},G?{style:YA({height:"100%",width:"100%",maxHeight:K,maxWidth:U},X.props.style)}:{})):X})},[r,p,c,f,h,d,A,a]);return pe.createElement("div",{id:x?"".concat(x):void 0,className:mr("recharts-responsive-container",y),style:YA(YA({},w),{},{width:a,height:c,minWidth:d,minHeight:h,maxHeight:f}),ref:S},P)}),rw=function(e){return null};rw.displayName="Cell";function kj(t){"@babel/helpers - typeof";return kj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},kj(t)}function $Q(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function gB(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?$Q(Object(r),!0).forEach(function(n){Eit(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$Q(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Eit(t,e,r){return e=Ait(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ait(t){var e=Cit(t,"string");return kj(e)=="symbol"?e:e+""}function Cit(t,e){if(kj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(kj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Wx={widthCache:{},cacheCount:0},Tit=2e3,Pit={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},BQ="recharts_measurement_span";function Oit(t){var e=gB({},t);return Object.keys(e).forEach(function(r){e[r]||delete e[r]}),e}var zQ=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Py.isSsr)return{width:0,height:0};var n=Oit(r),s=JSON.stringify({text:e,copyStyle:n});if(Wx.widthCache[s])return Wx.widthCache[s];try{var i=document.getElementById(BQ);i||(i=document.createElement("span"),i.setAttribute("id",BQ),i.setAttribute("aria-hidden","true"),document.body.appendChild(i));var a=gB(gB({},Pit),n);Object.assign(i.style,a),i.textContent="".concat(e);var o=i.getBoundingClientRect(),c={width:o.width,height:o.height};return Wx.widthCache[s]=c,++Wx.cacheCount>Tit&&(Wx.cacheCount=0,Wx.widthCache={}),c}catch{return{width:0,height:0}}},Iit=function(e){return{top:e.top+window.scrollY-document.documentElement.clientTop,left:e.left+window.scrollX-document.documentElement.clientLeft}};function Nj(t){"@babel/helpers - typeof";return Nj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Nj(t)}function CP(t,e){return Lit(t)||Dit(t,e)||Mit(t,e)||Rit()}function Rit(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mit(t,e){if(t){if(typeof t=="string")return UQ(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return UQ(t,e)}}function UQ(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Dit(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function Lit(t){if(Array.isArray(t))return t}function Fit(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function HQ(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Bit(n.key),n)}}function $it(t,e,r){return e&&HQ(t.prototype,e),r&&HQ(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Bit(t){var e=zit(t,"string");return Nj(e)=="symbol"?e:e+""}function zit(t,e){if(Nj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(Nj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var VQ=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,WQ=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Uit=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,Hit=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,gye={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},Vit=Object.keys(gye),Lv="NaN";function Wit(t,e){return t*gye[e]}var XA=function(){function t(e,r){Fit(this,t),this.num=e,this.unit=r,this.num=e,this.unit=r,Number.isNaN(e)&&(this.unit=""),r!==""&&!Uit.test(r)&&(this.num=NaN,this.unit=""),Vit.includes(r)&&(this.num=Wit(e,r),this.unit="px")}return $it(t,[{key:"add",value:function(r){return this.unit!==r.unit?new t(NaN,""):new t(this.num+r.num,this.unit)}},{key:"subtract",value:function(r){return this.unit!==r.unit?new t(NaN,""):new t(this.num-r.num,this.unit)}},{key:"multiply",value:function(r){return this.unit!==""&&r.unit!==""&&this.unit!==r.unit?new t(NaN,""):new t(this.num*r.num,this.unit||r.unit)}},{key:"divide",value:function(r){return this.unit!==""&&r.unit!==""&&this.unit!==r.unit?new t(NaN,""):new t(this.num/r.num,this.unit||r.unit)}},{key:"toString",value:function(){return"".concat(this.num).concat(this.unit)}},{key:"isNaN",value:function(){return Number.isNaN(this.num)}}],[{key:"parse",value:function(r){var n,s=(n=Hit.exec(r))!==null&&n!==void 0?n:[],i=CP(s,3),a=i[1],o=i[2];return new t(parseFloat(a),o??"")}}])}();function yye(t){if(t.includes(Lv))return Lv;for(var e=t;e.includes("*")||e.includes("/");){var r,n=(r=VQ.exec(e))!==null&&r!==void 0?r:[],s=CP(n,4),i=s[1],a=s[2],o=s[3],c=XA.parse(i??""),u=XA.parse(o??""),d=a==="*"?c.multiply(u):c.divide(u);if(d.isNaN())return Lv;e=e.replace(VQ,d.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var h,f=(h=WQ.exec(e))!==null&&h!==void 0?h:[],p=CP(f,4),m=p[1],g=p[2],x=p[3],y=XA.parse(m??""),v=XA.parse(x??""),b=g==="+"?y.add(v):y.subtract(v);if(b.isNaN())return Lv;e=e.replace(WQ,b.toString())}return e}var qQ=/\(([^()]*)\)/;function qit(t){for(var e=t;e.includes("(");){var r=qQ.exec(e),n=CP(r,2),s=n[1];e=e.replace(qQ,yye(s))}return e}function Git(t){var e=t.replace(/\s+/g,"");return e=qit(e),e=yye(e),e}function Kit(t){try{return Git(t)}catch{return Lv}}function g4(t){var e=Kit(t.slice(5,-1));return e===Lv?"":e}var Yit=["x","y","lineHeight","capHeight","scaleToFit","textAnchor","verticalAnchor","fill"],Xit=["dx","dy","angle","className","breakAll"];function yB(){return yB=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},yB.apply(this,arguments)}function GQ(t,e){if(t==null)return{};var r=Jit(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Jit(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function KQ(t,e){return tat(t)||eat(t,e)||Zit(t,e)||Qit()}function Qit(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zit(t,e){if(t){if(typeof t=="string")return YQ(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return YQ(t,e)}}function YQ(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function eat(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function tat(t){if(Array.isArray(t))return t}var xye=/[ \f\n\r\t\v\u2028\u2029]+/,vye=function(e){var r=e.children,n=e.breakAll,s=e.style;try{var i=[];hr(r)||(n?i=r.toString().split(""):i=r.toString().split(xye));var a=i.map(function(c){return{word:c,width:zQ(c,s).width}}),o=n?0:zQ(" ",s).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}},rat=function(e,r,n,s,i){var a=e.maxLines,o=e.children,c=e.style,u=e.breakAll,d=ut(a),h=o,f=function(){var U=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return U.reduce(function(K,G){var X=G.word,H=G.width,B=K[K.length-1];if(B&&(s==null||i||B.width+H+n<Number(s)))B.words.push(X),B.width+=H+n;else{var L={words:[X],width:H};K.push(L)}return K},[])},p=f(r),m=function(U){return U.reduce(function(K,G){return K.width>G.width?K:G})};if(!d)return p;for(var g="…",x=function(U){var K=h.slice(0,U),G=vye({breakAll:u,style:c,children:K+g}).wordsWithComputedWidth,X=f(G),H=X.length>a||m(X).width>Number(s);return[H,X]},y=0,v=h.length-1,b=0,w;y<=v&&b<=h.length-1;){var S=Math.floor((y+v)/2),k=S-1,E=x(k),C=KQ(E,2),A=C[0],M=C[1],z=x(S),P=KQ(z,1),W=P[0];if(!A&&!W&&(y=S+1),A&&W&&(v=S-1),!A&&W){w=M;break}b++}return w||p},XQ=function(e){var r=hr(e)?[]:e.toString().split(xye);return[{words:r}]},nat=function(e){var r=e.width,n=e.scaleToFit,s=e.children,i=e.style,a=e.breakAll,o=e.maxLines;if((r||n)&&!Py.isSsr){var c,u,d=vye({breakAll:a,children:s,style:i});if(d){var h=d.wordsWithComputedWidth,f=d.spaceWidth;c=h,u=f}else return XQ(s);return rat({breakAll:a,children:s,maxLines:o,style:i},c,u,r,n)}return XQ(s)},JQ="#808080",nw=function(e){var r=e.x,n=r===void 0?0:r,s=e.y,i=s===void 0?0:s,a=e.lineHeight,o=a===void 0?"1em":a,c=e.capHeight,u=c===void 0?"0.71em":c,d=e.scaleToFit,h=d===void 0?!1:d,f=e.textAnchor,p=f===void 0?"start":f,m=e.verticalAnchor,g=m===void 0?"end":m,x=e.fill,y=x===void 0?JQ:x,v=GQ(e,Yit),b=j.useMemo(function(){return nat({breakAll:v.breakAll,children:v.children,maxLines:v.maxLines,scaleToFit:h,style:v.style,width:v.width})},[v.breakAll,v.children,v.maxLines,h,v.style,v.width]),w=v.dx,S=v.dy,k=v.angle,E=v.className,C=v.breakAll,A=GQ(v,Xit);if(!Cs(n)||!Cs(i))return null;var M=n+(ut(w)?w:0),z=i+(ut(S)?S:0),P;switch(g){case"start":P=g4("calc(".concat(u,")"));break;case"middle":P=g4("calc(".concat((b.length-1)/2," * -").concat(o," + (").concat(u," / 2))"));break;default:P=g4("calc(".concat(b.length-1," * -").concat(o,")"));break}var W=[];if(h){var N=b[0].width,U=v.width;W.push("scale(".concat((ut(U)?U/N:1)/N,")"))}return k&&W.push("rotate(".concat(k,", ").concat(M,", ").concat(z,")")),W.length&&(A.transform=W.join(" ")),pe.createElement("text",yB({},Gt(A,!0),{x:M,y:z,className:mr("recharts-text",E),textAnchor:p,fill:y.includes("url")?JQ:y}),b.map(function(K,G){var X=K.words.join(C?"":" ");return pe.createElement("tspan",{x:M,dy:G===0?P:o,key:"".concat(X,"-").concat(G)},X)}))};function Ep(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function sat(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function JW(t){let e,r,n;t.length!==2?(e=Ep,r=(o,c)=>Ep(t(o),c),n=(o,c)=>t(o)-c):(e=t===Ep||t===sat?t:iat,r=t,n=t);function s(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const h=u+d>>>1;r(o[h],c)<0?u=h+1:d=h}while(u<d)}return u}function i(o,c,u=0,d=o.length){if(u<d){if(e(c,c)!==0)return d;do{const h=u+d>>>1;r(o[h],c)<=0?u=h+1:d=h}while(u<d)}return u}function a(o,c,u=0,d=o.length){const h=s(o,c,u,d-1);return h>u&&n(o[h-1],c)>-n(o[h],c)?h-1:h}return{left:s,center:a,right:i}}function iat(){return 0}function bye(t){return t===null?NaN:+t}function*aat(t,e){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const oat=JW(Ep),OE=oat.right;JW(bye).center;class QQ extends Map{constructor(e,r=uat){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),e!=null)for(const[n,s]of e)this.set(n,s)}get(e){return super.get(ZQ(this,e))}has(e){return super.has(ZQ(this,e))}set(e,r){return super.set(lat(this,e),r)}delete(e){return super.delete(cat(this,e))}}function ZQ({_intern:t,_key:e},r){const n=e(r);return t.has(n)?t.get(n):r}function lat({_intern:t,_key:e},r){const n=e(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function cat({_intern:t,_key:e},r){const n=e(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function uat(t){return t!==null&&typeof t=="object"?t.valueOf():t}function dat(t=Ep){if(t===Ep)return wye;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,r)=>{const n=t(e,r);return n||n===0?n:(t(r,r)===0)-(t(e,e)===0)}}function wye(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const hat=Math.sqrt(50),fat=Math.sqrt(10),pat=Math.sqrt(2);function TP(t,e,r){const n=(e-t)/Math.max(0,r),s=Math.floor(Math.log10(n)),i=n/Math.pow(10,s),a=i>=hat?10:i>=fat?5:i>=pat?2:1;let o,c,u;return s<0?(u=Math.pow(10,-s)/a,o=Math.round(t*u),c=Math.round(e*u),o/u<t&&++o,c/u>e&&--c,u=-u):(u=Math.pow(10,s)*a,o=Math.round(t/u),c=Math.round(e/u),o*u<t&&++o,c*u>e&&--c),c<o&&.5<=r&&r<2?TP(t,e,r*2):[o,c,u]}function xB(t,e,r){if(e=+e,t=+t,r=+r,!(r>0))return[];if(t===e)return[t];const n=e<t,[s,i,a]=n?TP(e,t,r):TP(t,e,r);if(!(i>=s))return[];const o=i-s+1,c=new Array(o);if(n)if(a<0)for(let u=0;u<o;++u)c[u]=(i-u)/-a;else for(let u=0;u<o;++u)c[u]=(i-u)*a;else if(a<0)for(let u=0;u<o;++u)c[u]=(s+u)/-a;else for(let u=0;u<o;++u)c[u]=(s+u)*a;return c}function vB(t,e,r){return e=+e,t=+t,r=+r,TP(t,e,r)[2]}function bB(t,e,r){e=+e,t=+t,r=+r;const n=e<t,s=n?vB(e,t,r):vB(t,e,r);return(n?-1:1)*(s<0?1/-s:s)}function eZ(t,e){let r;for(const n of t)n!=null&&(r<n||r===void 0&&n>=n)&&(r=n);return r}function tZ(t,e){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function Sye(t,e,r=0,n=1/0,s){if(e=Math.floor(e),r=Math.floor(Math.max(0,r)),n=Math.floor(Math.min(t.length-1,n)),!(r<=e&&e<=n))return t;for(s=s===void 0?wye:dat(s);n>r;){if(n-r>600){const c=n-r+1,u=e-r+1,d=Math.log(c),h=.5*Math.exp(2*d/3),f=.5*Math.sqrt(d*h*(c-h)/c)*(u-c/2<0?-1:1),p=Math.max(r,Math.floor(e-u*h/c+f)),m=Math.min(n,Math.floor(e+(c-u)*h/c+f));Sye(t,e,p,m,s)}const i=t[e];let a=r,o=n;for(L1(t,r,e),s(t[n],i)>0&&L1(t,r,n);a<o;){for(L1(t,a,o),++a,--o;s(t[a],i)<0;)++a;for(;s(t[o],i)>0;)--o}s(t[r],i)===0?L1(t,r,o):(++o,L1(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1)}return t}function L1(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function mat(t,e,r){if(t=Float64Array.from(aat(t)),!(!(n=t.length)||isNaN(e=+e))){if(e<=0||n<2)return tZ(t);if(e>=1)return eZ(t);var n,s=(n-1)*e,i=Math.floor(s),a=eZ(Sye(t,i).subarray(0,i+1)),o=tZ(t.subarray(i+1));return a+(o-a)*(s-i)}}function gat(t,e,r=bye){if(!(!(n=t.length)||isNaN(e=+e))){if(e<=0||n<2)return+r(t[0],0,t);if(e>=1)return+r(t[n-1],n-1,t);var n,s=(n-1)*e,i=Math.floor(s),a=+r(t[i],i,t),o=+r(t[i+1],i+1,t);return a+(o-a)*(s-i)}}function yat(t,e,r){t=+t,e=+e,r=(s=arguments.length)<2?(e=t,t=0,1):s<3?1:+r;for(var n=-1,s=Math.max(0,Math.ceil((e-t)/r))|0,i=new Array(s);++n<s;)i[n]=t+n*r;return i}function Ol(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Ih(t,e){switch(arguments.length){case 0:break;case 1:{typeof t=="function"?this.interpolator(t):this.range(t);break}default:{this.domain(t),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const wB=Symbol("implicit");function QW(){var t=new QQ,e=[],r=[],n=wB;function s(i){let a=t.get(i);if(a===void 0){if(n!==wB)return n;t.set(i,a=e.push(i)-1)}return r[a%r.length]}return s.domain=function(i){if(!arguments.length)return e.slice();e=[],t=new QQ;for(const a of i)t.has(a)||t.set(a,e.push(a)-1);return s},s.range=function(i){return arguments.length?(r=Array.from(i),s):r.slice()},s.unknown=function(i){return arguments.length?(n=i,s):n},s.copy=function(){return QW(e,r).unknown(n)},Ol.apply(s,arguments),s}function Ej(){var t=QW().unknown(void 0),e=t.domain,r=t.range,n=0,s=1,i,a,o=!1,c=0,u=0,d=.5;delete t.unknown;function h(){var f=e().length,p=s<n,m=p?s:n,g=p?n:s;i=(g-m)/Math.max(1,f-c+u*2),o&&(i=Math.floor(i)),m+=(g-m-i*(f-c))*d,a=i*(1-c),o&&(m=Math.round(m),a=Math.round(a));var x=yat(f).map(function(y){return m+i*y});return r(p?x.reverse():x)}return t.domain=function(f){return arguments.length?(e(f),h()):e()},t.range=function(f){return arguments.length?([n,s]=f,n=+n,s=+s,h()):[n,s]},t.rangeRound=function(f){return[n,s]=f,n=+n,s=+s,o=!0,h()},t.bandwidth=function(){return a},t.step=function(){return i},t.round=function(f){return arguments.length?(o=!!f,h()):o},t.padding=function(f){return arguments.length?(c=Math.min(1,u=+f),h()):c},t.paddingInner=function(f){return arguments.length?(c=Math.min(1,f),h()):c},t.paddingOuter=function(f){return arguments.length?(u=+f,h()):u},t.align=function(f){return arguments.length?(d=Math.max(0,Math.min(1,f)),h()):d},t.copy=function(){return Ej(e(),[n,s]).round(o).paddingInner(c).paddingOuter(u).align(d)},Ol.apply(h(),arguments)}function _ye(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return _ye(e())},t}function w_(){return _ye(Ej.apply(null,arguments).paddingInner(1))}function ZW(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function jye(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function IE(){}var Aj=.7,PP=1/Aj,lb="\\s*([+-]?\\d+)\\s*",Cj="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ku="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xat=/^#([0-9a-f]{3,8})$/,vat=new RegExp(`^rgb\\(${lb},${lb},${lb}\\)$`),bat=new RegExp(`^rgb\\(${ku},${ku},${ku}\\)$`),wat=new RegExp(`^rgba\\(${lb},${lb},${lb},${Cj}\\)$`),Sat=new RegExp(`^rgba\\(${ku},${ku},${ku},${Cj}\\)$`),_at=new RegExp(`^hsl\\(${Cj},${ku},${ku}\\)$`),jat=new RegExp(`^hsla\\(${Cj},${ku},${ku},${Cj}\\)$`),rZ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};ZW(IE,Tj,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:nZ,formatHex:nZ,formatHex8:kat,formatHsl:Nat,formatRgb:sZ,toString:sZ});function nZ(){return this.rgb().formatHex()}function kat(){return this.rgb().formatHex8()}function Nat(){return kye(this).formatHsl()}function sZ(){return this.rgb().formatRgb()}function Tj(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=xat.exec(t))?(r=e[1].length,e=parseInt(e[1],16),r===6?iZ(e):r===3?new Ua(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):r===8?JA(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):r===4?JA(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=vat.exec(t))?new Ua(e[1],e[2],e[3],1):(e=bat.exec(t))?new Ua(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=wat.exec(t))?JA(e[1],e[2],e[3],e[4]):(e=Sat.exec(t))?JA(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=_at.exec(t))?lZ(e[1],e[2]/100,e[3]/100,1):(e=jat.exec(t))?lZ(e[1],e[2]/100,e[3]/100,e[4]):rZ.hasOwnProperty(t)?iZ(rZ[t]):t==="transparent"?new Ua(NaN,NaN,NaN,0):null}function iZ(t){return new Ua(t>>16&255,t>>8&255,t&255,1)}function JA(t,e,r,n){return n<=0&&(t=e=r=NaN),new Ua(t,e,r,n)}function Eat(t){return t instanceof IE||(t=Tj(t)),t?(t=t.rgb(),new Ua(t.r,t.g,t.b,t.opacity)):new Ua}function SB(t,e,r,n){return arguments.length===1?Eat(t):new Ua(t,e,r,n??1)}function Ua(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}ZW(Ua,SB,jye(IE,{brighter(t){return t=t==null?PP:Math.pow(PP,t),new Ua(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?Aj:Math.pow(Aj,t),new Ua(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ua(Oy(this.r),Oy(this.g),Oy(this.b),OP(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:aZ,formatHex:aZ,formatHex8:Aat,formatRgb:oZ,toString:oZ}));function aZ(){return`#${rg(this.r)}${rg(this.g)}${rg(this.b)}`}function Aat(){return`#${rg(this.r)}${rg(this.g)}${rg(this.b)}${rg((isNaN(this.opacity)?1:this.opacity)*255)}`}function oZ(){const t=OP(this.opacity);return`${t===1?"rgb(":"rgba("}${Oy(this.r)}, ${Oy(this.g)}, ${Oy(this.b)}${t===1?")":`, ${t})`}`}function OP(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Oy(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function rg(t){return t=Oy(t),(t<16?"0":"")+t.toString(16)}function lZ(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new ac(t,e,r,n)}function kye(t){if(t instanceof ac)return new ac(t.h,t.s,t.l,t.opacity);if(t instanceof IE||(t=Tj(t)),!t)return new ac;if(t instanceof ac)return t;t=t.rgb();var e=t.r/255,r=t.g/255,n=t.b/255,s=Math.min(e,r,n),i=Math.max(e,r,n),a=NaN,o=i-s,c=(i+s)/2;return o?(e===i?a=(r-n)/o+(r<n)*6:r===i?a=(n-e)/o+2:a=(e-r)/o+4,o/=c<.5?i+s:2-i-s,a*=60):o=c>0&&c<1?0:a,new ac(a,o,c,t.opacity)}function Cat(t,e,r,n){return arguments.length===1?kye(t):new ac(t,e,r,n??1)}function ac(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}ZW(ac,Cat,jye(IE,{brighter(t){return t=t==null?PP:Math.pow(PP,t),new ac(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?Aj:Math.pow(Aj,t),new ac(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,s=2*r-n;return new Ua(y4(t>=240?t-240:t+120,s,n),y4(t,s,n),y4(t<120?t+240:t-120,s,n),this.opacity)},clamp(){return new ac(cZ(this.h),QA(this.s),QA(this.l),OP(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=OP(this.opacity);return`${t===1?"hsl(":"hsla("}${cZ(this.h)}, ${QA(this.s)*100}%, ${QA(this.l)*100}%${t===1?")":`, ${t})`}`}}));function cZ(t){return t=(t||0)%360,t<0?t+360:t}function QA(t){return Math.max(0,Math.min(1,t||0))}function y4(t,e,r){return(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)*255}const e9=t=>()=>t;function Tat(t,e){return function(r){return t+r*e}}function Pat(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}function Oat(t){return(t=+t)==1?Nye:function(e,r){return r-e?Pat(e,r,t):e9(isNaN(e)?r:e)}}function Nye(t,e){var r=e-t;return r?Tat(t,r):e9(isNaN(t)?e:t)}const uZ=function t(e){var r=Oat(e);function n(s,i){var a=r((s=SB(s)).r,(i=SB(i)).r),o=r(s.g,i.g),c=r(s.b,i.b),u=Nye(s.opacity,i.opacity);return function(d){return s.r=a(d),s.g=o(d),s.b=c(d),s.opacity=u(d),s+""}}return n.gamma=t,n}(1);function Iat(t,e){e||(e=[]);var r=t?Math.min(e.length,t.length):0,n=e.slice(),s;return function(i){for(s=0;s<r;++s)n[s]=t[s]*(1-i)+e[s]*i;return n}}function Rat(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Mat(t,e){var r=e?e.length:0,n=t?Math.min(r,t.length):0,s=new Array(n),i=new Array(r),a;for(a=0;a<n;++a)s[a]=c1(t[a],e[a]);for(;a<r;++a)i[a]=e[a];return function(o){for(a=0;a<n;++a)i[a]=s[a](o);return i}}function Dat(t,e){var r=new Date;return t=+t,e=+e,function(n){return r.setTime(t*(1-n)+e*n),r}}function IP(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function Lat(t,e){var r={},n={},s;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(s in e)s in t?r[s]=c1(t[s],e[s]):n[s]=e[s];return function(i){for(s in r)n[s]=r[s](i);return n}}var _B=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,x4=new RegExp(_B.source,"g");function Fat(t){return function(){return t}}function $at(t){return function(e){return t(e)+""}}function Bat(t,e){var r=_B.lastIndex=x4.lastIndex=0,n,s,i,a=-1,o=[],c=[];for(t=t+"",e=e+"";(n=_B.exec(t))&&(s=x4.exec(e));)(i=s.index)>r&&(i=e.slice(r,i),o[a]?o[a]+=i:o[++a]=i),(n=n[0])===(s=s[0])?o[a]?o[a]+=s:o[++a]=s:(o[++a]=null,c.push({i:a,x:IP(n,s)})),r=x4.lastIndex;return r<e.length&&(i=e.slice(r),o[a]?o[a]+=i:o[++a]=i),o.length<2?c[0]?$at(c[0].x):Fat(e):(e=c.length,function(u){for(var d=0,h;d<e;++d)o[(h=c[d]).i]=h.x(u);return o.join("")})}function c1(t,e){var r=typeof e,n;return e==null||r==="boolean"?e9(e):(r==="number"?IP:r==="string"?(n=Tj(e))?(e=n,uZ):Bat:e instanceof Tj?uZ:e instanceof Date?Dat:Rat(e)?Iat:Array.isArray(e)?Mat:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Lat:IP)(t,e)}function t9(t,e){return t=+t,e=+e,function(r){return Math.round(t*(1-r)+e*r)}}function zat(t,e){e===void 0&&(e=t,t=c1);for(var r=0,n=e.length-1,s=e[0],i=new Array(n<0?0:n);r<n;)i[r]=t(s,s=e[++r]);return function(a){var o=Math.max(0,Math.min(n-1,Math.floor(a*=n)));return i[o](a-o)}}function Uat(t){return function(){return t}}function RP(t){return+t}var dZ=[0,1];function fa(t){return t}function jB(t,e){return(e-=t=+t)?function(r){return(r-t)/e}:Uat(isNaN(e)?NaN:.5)}function Hat(t,e){var r;return t>e&&(r=t,t=e,e=r),function(n){return Math.max(t,Math.min(e,n))}}function Vat(t,e,r){var n=t[0],s=t[1],i=e[0],a=e[1];return s<n?(n=jB(s,n),i=r(a,i)):(n=jB(n,s),i=r(i,a)),function(o){return i(n(o))}}function Wat(t,e,r){var n=Math.min(t.length,e.length)-1,s=new Array(n),i=new Array(n),a=-1;for(t[n]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++a<n;)s[a]=jB(t[a],t[a+1]),i[a]=r(e[a],e[a+1]);return function(o){var c=OE(t,o,1,n)-1;return i[c](s[c](o))}}function RE(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function fM(){var t=dZ,e=dZ,r=c1,n,s,i,a=fa,o,c,u;function d(){var f=Math.min(t.length,e.length);return a!==fa&&(a=Hat(t[0],t[f-1])),o=f>2?Wat:Vat,c=u=null,h}function h(f){return f==null||isNaN(f=+f)?i:(c||(c=o(t.map(n),e,r)))(n(a(f)))}return h.invert=function(f){return a(s((u||(u=o(e,t.map(n),IP)))(f)))},h.domain=function(f){return arguments.length?(t=Array.from(f,RP),d()):t.slice()},h.range=function(f){return arguments.length?(e=Array.from(f),d()):e.slice()},h.rangeRound=function(f){return e=Array.from(f),r=t9,d()},h.clamp=function(f){return arguments.length?(a=f?!0:fa,d()):a!==fa},h.interpolate=function(f){return arguments.length?(r=f,d()):r},h.unknown=function(f){return arguments.length?(i=f,h):i},function(f,p){return n=f,s=p,d()}}function r9(){return fM()(fa,fa)}function qat(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function MP(t,e){if((r=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var r,n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function sw(t){return t=MP(Math.abs(t)),t?t[1]:NaN}function Gat(t,e){return function(r,n){for(var s=r.length,i=[],a=0,o=t[0],c=0;s>0&&o>0&&(c+o+1>n&&(o=Math.max(1,n-c)),i.push(r.substring(s-=o,s+o)),!((c+=o+1)>n));)o=t[a=(a+1)%t.length];return i.reverse().join(e)}}function Kat(t){return function(e){return e.replace(/[0-9]/g,function(r){return t[+r]})}}var Yat=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Pj(t){if(!(e=Yat.exec(t)))throw new Error("invalid format: "+t);var e;return new n9({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}Pj.prototype=n9.prototype;function n9(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}n9.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Xat(t){e:for(var e=t.length,r=1,n=-1,s;r<e;++r)switch(t[r]){case".":n=s=r;break;case"0":n===0&&(n=r),s=r;break;default:if(!+t[r])break e;n>0&&(n=0);break}return n>0?t.slice(0,n)+t.slice(s+1):t}var Eye;function Jat(t,e){var r=MP(t,e);if(!r)return t+"";var n=r[0],s=r[1],i=s-(Eye=Math.max(-8,Math.min(8,Math.floor(s/3)))*3)+1,a=n.length;return i===a?n:i>a?n+new Array(i-a+1).join("0"):i>0?n.slice(0,i)+"."+n.slice(i):"0."+new Array(1-i).join("0")+MP(t,Math.max(0,e+i-1))[0]}function hZ(t,e){var r=MP(t,e);if(!r)return t+"";var n=r[0],s=r[1];return s<0?"0."+new Array(-s).join("0")+n:n.length>s+1?n.slice(0,s+1)+"."+n.slice(s+1):n+new Array(s-n.length+2).join("0")}const fZ={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:qat,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>hZ(t*100,e),r:hZ,s:Jat,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function pZ(t){return t}var mZ=Array.prototype.map,gZ=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Qat(t){var e=t.grouping===void 0||t.thousands===void 0?pZ:Gat(mZ.call(t.grouping,Number),t.thousands+""),r=t.currency===void 0?"":t.currency[0]+"",n=t.currency===void 0?"":t.currency[1]+"",s=t.decimal===void 0?".":t.decimal+"",i=t.numerals===void 0?pZ:Kat(mZ.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",o=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(h){h=Pj(h);var f=h.fill,p=h.align,m=h.sign,g=h.symbol,x=h.zero,y=h.width,v=h.comma,b=h.precision,w=h.trim,S=h.type;S==="n"?(v=!0,S="g"):fZ[S]||(b===void 0&&(b=12),w=!0,S="g"),(x||f==="0"&&p==="=")&&(x=!0,f="0",p="=");var k=g==="$"?r:g==="#"&&/[boxX]/.test(S)?"0"+S.toLowerCase():"",E=g==="$"?n:/[%p]/.test(S)?a:"",C=fZ[S],A=/[defgprs%]/.test(S);b=b===void 0?6:/[gprs]/.test(S)?Math.max(1,Math.min(21,b)):Math.max(0,Math.min(20,b));function M(z){var P=k,W=E,N,U,K;if(S==="c")W=C(z)+W,z="";else{z=+z;var G=z<0||1/z<0;if(z=isNaN(z)?c:C(Math.abs(z),b),w&&(z=Xat(z)),G&&+z==0&&m!=="+"&&(G=!1),P=(G?m==="("?m:o:m==="-"||m==="("?"":m)+P,W=(S==="s"?gZ[8+Eye/3]:"")+W+(G&&m==="("?")":""),A){for(N=-1,U=z.length;++N<U;)if(K=z.charCodeAt(N),48>K||K>57){W=(K===46?s+z.slice(N+1):z.slice(N))+W,z=z.slice(0,N);break}}}v&&!x&&(z=e(z,1/0));var X=P.length+z.length+W.length,H=X<y?new Array(y-X+1).join(f):"";switch(v&&x&&(z=e(H+z,H.length?y-W.length:1/0),H=""),p){case"<":z=P+z+W+H;break;case"=":z=P+H+z+W;break;case"^":z=H.slice(0,X=H.length>>1)+P+z+W+H.slice(X);break;default:z=H+P+z+W;break}return i(z)}return M.toString=function(){return h+""},M}function d(h,f){var p=u((h=Pj(h),h.type="f",h)),m=Math.max(-8,Math.min(8,Math.floor(sw(f)/3)))*3,g=Math.pow(10,-m),x=gZ[8+m/3];return function(y){return p(g*y)+x}}return{format:u,formatPrefix:d}}var ZA,s9,Aye;Zat({thousands:",",grouping:[3],currency:["$",""]});function Zat(t){return ZA=Qat(t),s9=ZA.format,Aye=ZA.formatPrefix,ZA}function eot(t){return Math.max(0,-sw(Math.abs(t)))}function tot(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(sw(e)/3)))*3-sw(Math.abs(t)))}function rot(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,sw(e)-sw(t))+1}function Cye(t,e,r,n){var s=bB(t,e,r),i;switch(n=Pj(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return n.precision==null&&!isNaN(i=tot(s,a))&&(n.precision=i),Aye(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(i=rot(s,Math.max(Math.abs(t),Math.abs(e))))&&(n.precision=i-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(i=eot(s))&&(n.precision=i-(n.type==="%")*2);break}}return s9(n)}function um(t){var e=t.domain;return t.ticks=function(r){var n=e();return xB(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var s=e();return Cye(s[0],s[s.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=e(),s=0,i=n.length-1,a=n[s],o=n[i],c,u,d=10;for(o<a&&(u=a,a=o,o=u,u=s,s=i,i=u);d-- >0;){if(u=vB(a,o,r),u===c)return n[s]=a,n[i]=o,e(n);if(u>0)a=Math.floor(a/u)*u,o=Math.ceil(o/u)*u;else if(u<0)a=Math.ceil(a*u)/u,o=Math.floor(o*u)/u;else break;c=u}return t},t}function DP(){var t=r9();return t.copy=function(){return RE(t,DP())},Ol.apply(t,arguments),um(t)}function Tye(t){var e;function r(n){return n==null||isNaN(n=+n)?e:n}return r.invert=r,r.domain=r.range=function(n){return arguments.length?(t=Array.from(n,RP),r):t.slice()},r.unknown=function(n){return arguments.length?(e=n,r):e},r.copy=function(){return Tye(t).unknown(e)},t=arguments.length?Array.from(t,RP):[0,1],um(r)}function Pye(t,e){t=t.slice();var r=0,n=t.length-1,s=t[r],i=t[n],a;return i<s&&(a=r,r=n,n=a,a=s,s=i,i=a),t[r]=e.floor(s),t[n]=e.ceil(i),t}function yZ(t){return Math.log(t)}function xZ(t){return Math.exp(t)}function not(t){return-Math.log(-t)}function sot(t){return-Math.exp(-t)}function iot(t){return isFinite(t)?+("1e"+t):t<0?0:t}function aot(t){return t===10?iot:t===Math.E?Math.exp:e=>Math.pow(t,e)}function oot(t){return t===Math.E?Math.log:t===10&&Math.log10||t===2&&Math.log2||(t=Math.log(t),e=>Math.log(e)/t)}function vZ(t){return(e,r)=>-t(-e,r)}function i9(t){const e=t(yZ,xZ),r=e.domain;let n=10,s,i;function a(){return s=oot(n),i=aot(n),r()[0]<0?(s=vZ(s),i=vZ(i),t(not,sot)):t(yZ,xZ),e}return e.base=function(o){return arguments.length?(n=+o,a()):n},e.domain=function(o){return arguments.length?(r(o),a()):r()},e.ticks=o=>{const c=r();let u=c[0],d=c[c.length-1];const h=d<u;h&&([u,d]=[d,u]);let f=s(u),p=s(d),m,g;const x=o==null?10:+o;let y=[];if(!(n%1)&&p-f<x){if(f=Math.floor(f),p=Math.ceil(p),u>0){for(;f<=p;++f)for(m=1;m<n;++m)if(g=f<0?m/i(-f):m*i(f),!(g<u)){if(g>d)break;y.push(g)}}else for(;f<=p;++f)for(m=n-1;m>=1;--m)if(g=f>0?m/i(-f):m*i(f),!(g<u)){if(g>d)break;y.push(g)}y.length*2<x&&(y=xB(u,d,x))}else y=xB(f,p,Math.min(p-f,x)).map(i);return h?y.reverse():y},e.tickFormat=(o,c)=>{if(o==null&&(o=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=Pj(c)).precision==null&&(c.trim=!0),c=s9(c)),o===1/0)return c;const u=Math.max(1,n*o/e.ticks().length);return d=>{let h=d/i(Math.round(s(d)));return h*n<n-.5&&(h*=n),h<=u?c(d):""}},e.nice=()=>r(Pye(r(),{floor:o=>i(Math.floor(s(o))),ceil:o=>i(Math.ceil(s(o)))})),e}function Oye(){const t=i9(fM()).domain([1,10]);return t.copy=()=>RE(t,Oye()).base(t.base()),Ol.apply(t,arguments),t}function bZ(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function wZ(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function a9(t){var e=1,r=t(bZ(e),wZ(e));return r.constant=function(n){return arguments.length?t(bZ(e=+n),wZ(e)):e},um(r)}function Iye(){var t=a9(fM());return t.copy=function(){return RE(t,Iye()).constant(t.constant())},Ol.apply(t,arguments)}function SZ(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function lot(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function cot(t){return t<0?-t*t:t*t}function o9(t){var e=t(fa,fa),r=1;function n(){return r===1?t(fa,fa):r===.5?t(lot,cot):t(SZ(r),SZ(1/r))}return e.exponent=function(s){return arguments.length?(r=+s,n()):r},um(e)}function l9(){var t=o9(fM());return t.copy=function(){return RE(t,l9()).exponent(t.exponent())},Ol.apply(t,arguments),t}function uot(){return l9.apply(null,arguments).exponent(.5)}function _Z(t){return Math.sign(t)*t*t}function dot(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function Rye(){var t=r9(),e=[0,1],r=!1,n;function s(i){var a=dot(t(i));return isNaN(a)?n:r?Math.round(a):a}return s.invert=function(i){return t.invert(_Z(i))},s.domain=function(i){return arguments.length?(t.domain(i),s):t.domain()},s.range=function(i){return arguments.length?(t.range((e=Array.from(i,RP)).map(_Z)),s):e.slice()},s.rangeRound=function(i){return s.range(i).round(!0)},s.round=function(i){return arguments.length?(r=!!i,s):r},s.clamp=function(i){return arguments.length?(t.clamp(i),s):t.clamp()},s.unknown=function(i){return arguments.length?(n=i,s):n},s.copy=function(){return Rye(t.domain(),e).round(r).clamp(t.clamp()).unknown(n)},Ol.apply(s,arguments),um(s)}function Mye(){var t=[],e=[],r=[],n;function s(){var a=0,o=Math.max(1,e.length);for(r=new Array(o-1);++a<o;)r[a-1]=gat(t,a/o);return i}function i(a){return a==null||isNaN(a=+a)?n:e[OE(r,a)]}return i.invertExtent=function(a){var o=e.indexOf(a);return o<0?[NaN,NaN]:[o>0?r[o-1]:t[0],o<r.length?r[o]:t[t.length-1]]},i.domain=function(a){if(!arguments.length)return t.slice();t=[];for(let o of a)o!=null&&!isNaN(o=+o)&&t.push(o);return t.sort(Ep),s()},i.range=function(a){return arguments.length?(e=Array.from(a),s()):e.slice()},i.unknown=function(a){return arguments.length?(n=a,i):n},i.quantiles=function(){return r.slice()},i.copy=function(){return Mye().domain(t).range(e).unknown(n)},Ol.apply(i,arguments)}function Dye(){var t=0,e=1,r=1,n=[.5],s=[0,1],i;function a(c){return c!=null&&c<=c?s[OE(n,c,0,r)]:i}function o(){var c=-1;for(n=new Array(r);++c<r;)n[c]=((c+1)*e-(c-r)*t)/(r+1);return a}return a.domain=function(c){return arguments.length?([t,e]=c,t=+t,e=+e,o()):[t,e]},a.range=function(c){return arguments.length?(r=(s=Array.from(c)).length-1,o()):s.slice()},a.invertExtent=function(c){var u=s.indexOf(c);return u<0?[NaN,NaN]:u<1?[t,n[0]]:u>=r?[n[r-1],e]:[n[u-1],n[u]]},a.unknown=function(c){return arguments.length&&(i=c),a},a.thresholds=function(){return n.slice()},a.copy=function(){return Dye().domain([t,e]).range(s).unknown(i)},Ol.apply(um(a),arguments)}function Lye(){var t=[.5],e=[0,1],r,n=1;function s(i){return i!=null&&i<=i?e[OE(t,i,0,n)]:r}return s.domain=function(i){return arguments.length?(t=Array.from(i),n=Math.min(t.length,e.length-1),s):t.slice()},s.range=function(i){return arguments.length?(e=Array.from(i),n=Math.min(t.length,e.length-1),s):e.slice()},s.invertExtent=function(i){var a=e.indexOf(i);return[t[a-1],t[a]]},s.unknown=function(i){return arguments.length?(r=i,s):r},s.copy=function(){return Lye().domain(t).range(e).unknown(r)},Ol.apply(s,arguments)}const v4=new Date,b4=new Date;function Rs(t,e,r,n){function s(i){return t(i=arguments.length===0?new Date:new Date(+i)),i}return s.floor=i=>(t(i=new Date(+i)),i),s.ceil=i=>(t(i=new Date(i-1)),e(i,1),t(i),i),s.round=i=>{const a=s(i),o=s.ceil(i);return i-a<o-i?a:o},s.offset=(i,a)=>(e(i=new Date(+i),a==null?1:Math.floor(a)),i),s.range=(i,a,o)=>{const c=[];if(i=s.ceil(i),o=o==null?1:Math.floor(o),!(i<a)||!(o>0))return c;let u;do c.push(u=new Date(+i)),e(i,o),t(i);while(u<i&&i<a);return c},s.filter=i=>Rs(a=>{if(a>=a)for(;t(a),!i(a);)a.setTime(a-1)},(a,o)=>{if(a>=a)if(o<0)for(;++o<=0;)for(;e(a,-1),!i(a););else for(;--o>=0;)for(;e(a,1),!i(a););}),r&&(s.count=(i,a)=>(v4.setTime(+i),b4.setTime(+a),t(v4),t(b4),Math.floor(r(v4,b4))),s.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?s.filter(n?a=>n(a)%i===0:a=>s.count(0,a)%i===0):s)),s}const LP=Rs(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);LP.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Rs(e=>{e.setTime(Math.floor(e/t)*t)},(e,r)=>{e.setTime(+e+r*t)},(e,r)=>(r-e)/t):LP);LP.range;const Kd=1e3,ml=Kd*60,Yd=ml*60,xh=Yd*24,c9=xh*7,jZ=xh*30,w4=xh*365,ng=Rs(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Kd)},(t,e)=>(e-t)/Kd,t=>t.getUTCSeconds());ng.range;const u9=Rs(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Kd)},(t,e)=>{t.setTime(+t+e*ml)},(t,e)=>(e-t)/ml,t=>t.getMinutes());u9.range;const d9=Rs(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*ml)},(t,e)=>(e-t)/ml,t=>t.getUTCMinutes());d9.range;const h9=Rs(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Kd-t.getMinutes()*ml)},(t,e)=>{t.setTime(+t+e*Yd)},(t,e)=>(e-t)/Yd,t=>t.getHours());h9.range;const f9=Rs(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Yd)},(t,e)=>(e-t)/Yd,t=>t.getUTCHours());f9.range;const ME=Rs(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*ml)/xh,t=>t.getDate()-1);ME.range;const pM=Rs(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/xh,t=>t.getUTCDate()-1);pM.range;const Fye=Rs(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/xh,t=>Math.floor(t/xh));Fye.range;function jx(t){return Rs(e=>{e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0)},(e,r)=>{e.setDate(e.getDate()+r*7)},(e,r)=>(r-e-(r.getTimezoneOffset()-e.getTimezoneOffset())*ml)/c9)}const mM=jx(0),FP=jx(1),hot=jx(2),fot=jx(3),iw=jx(4),pot=jx(5),mot=jx(6);mM.range;FP.range;hot.range;fot.range;iw.range;pot.range;mot.range;function kx(t){return Rs(e=>{e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0)},(e,r)=>{e.setUTCDate(e.getUTCDate()+r*7)},(e,r)=>(r-e)/c9)}const gM=kx(0),$P=kx(1),got=kx(2),yot=kx(3),aw=kx(4),xot=kx(5),vot=kx(6);gM.range;$P.range;got.range;yot.range;aw.range;xot.range;vot.range;const p9=Rs(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());p9.range;const m9=Rs(t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCMonth(t.getUTCMonth()+e)},(t,e)=>e.getUTCMonth()-t.getUTCMonth()+(e.getUTCFullYear()-t.getUTCFullYear())*12,t=>t.getUTCMonth());m9.range;const vh=Rs(t=>{t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e)},(t,e)=>e.getFullYear()-t.getFullYear(),t=>t.getFullYear());vh.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Rs(e=>{e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0)},(e,r)=>{e.setFullYear(e.getFullYear()+r*t)});vh.range;const bh=Rs(t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e)},(t,e)=>e.getUTCFullYear()-t.getUTCFullYear(),t=>t.getUTCFullYear());bh.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Rs(e=>{e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,r)=>{e.setUTCFullYear(e.getUTCFullYear()+r*t)});bh.range;function $ye(t,e,r,n,s,i){const a=[[ng,1,Kd],[ng,5,5*Kd],[ng,15,15*Kd],[ng,30,30*Kd],[i,1,ml],[i,5,5*ml],[i,15,15*ml],[i,30,30*ml],[s,1,Yd],[s,3,3*Yd],[s,6,6*Yd],[s,12,12*Yd],[n,1,xh],[n,2,2*xh],[r,1,c9],[e,1,jZ],[e,3,3*jZ],[t,1,w4]];function o(u,d,h){const f=d<u;f&&([u,d]=[d,u]);const p=h&&typeof h.range=="function"?h:c(u,d,h),m=p?p.range(u,+d+1):[];return f?m.reverse():m}function c(u,d,h){const f=Math.abs(d-u)/h,p=JW(([,,x])=>x).right(a,f);if(p===a.length)return t.every(bB(u/w4,d/w4,h));if(p===0)return LP.every(Math.max(bB(u,d,h),1));const[m,g]=a[f/a[p-1][2]<a[p][2]/f?p-1:p];return m.every(g)}return[o,c]}const[bot,wot]=$ye(bh,m9,gM,Fye,f9,d9),[Sot,_ot]=$ye(vh,p9,mM,ME,h9,u9);function S4(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function _4(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function F1(t,e,r){return{y:t,m:e,d:r,H:0,M:0,S:0,L:0}}function jot(t){var e=t.dateTime,r=t.date,n=t.time,s=t.periods,i=t.days,a=t.shortDays,o=t.months,c=t.shortMonths,u=$1(s),d=B1(s),h=$1(i),f=B1(i),p=$1(a),m=B1(a),g=$1(o),x=B1(o),y=$1(c),v=B1(c),b={a:G,A:X,b:H,B,c:null,d:TZ,e:TZ,f:Got,g:nlt,G:ilt,H:Vot,I:Wot,j:qot,L:Bye,m:Kot,M:Yot,p:L,q:F,Q:IZ,s:RZ,S:Xot,u:Jot,U:Qot,V:Zot,w:elt,W:tlt,x:null,X:null,y:rlt,Y:slt,Z:alt,"%":OZ},w={a:V,A:Y,b:ie,B:Q,c:null,d:PZ,e:PZ,f:ult,g:blt,G:Slt,H:olt,I:llt,j:clt,L:Uye,m:dlt,M:hlt,p:D,q:R,Q:IZ,s:RZ,S:flt,u:plt,U:mlt,V:glt,w:ylt,W:xlt,x:null,X:null,y:vlt,Y:wlt,Z:_lt,"%":OZ},S={a:M,A:z,b:P,B:W,c:N,d:AZ,e:AZ,f:Bot,g:EZ,G:NZ,H:CZ,I:CZ,j:Dot,L:$ot,m:Mot,M:Lot,p:A,q:Rot,Q:Uot,s:Hot,S:Fot,u:Cot,U:Tot,V:Pot,w:Aot,W:Oot,x:U,X:K,y:EZ,Y:NZ,Z:Iot,"%":zot};b.x=k(r,b),b.X=k(n,b),b.c=k(e,b),w.x=k(r,w),w.X=k(n,w),w.c=k(e,w);function k(J,Z){return function(ee){var re=[],he=-1,O=0,ae=J.length,q,I,T;for(ee instanceof Date||(ee=new Date(+ee));++he<ae;)J.charCodeAt(he)===37&&(re.push(J.slice(O,he)),(I=kZ[q=J.charAt(++he)])!=null?q=J.charAt(++he):I=q==="e"?" ":"0",(T=Z[q])&&(q=T(ee,I)),re.push(q),O=he+1);return re.push(J.slice(O,he)),re.join("")}}function E(J,Z){return function(ee){var re=F1(1900,void 0,1),he=C(re,J,ee+="",0),O,ae;if(he!=ee.length)return null;if("Q"in re)return new Date(re.Q);if("s"in re)return new Date(re.s*1e3+("L"in re?re.L:0));if(Z&&!("Z"in re)&&(re.Z=0),"p"in re&&(re.H=re.H%12+re.p*12),re.m===void 0&&(re.m="q"in re?re.q:0),"V"in re){if(re.V<1||re.V>53)return null;"w"in re||(re.w=1),"Z"in re?(O=_4(F1(re.y,0,1)),ae=O.getUTCDay(),O=ae>4||ae===0?$P.ceil(O):$P(O),O=pM.offset(O,(re.V-1)*7),re.y=O.getUTCFullYear(),re.m=O.getUTCMonth(),re.d=O.getUTCDate()+(re.w+6)%7):(O=S4(F1(re.y,0,1)),ae=O.getDay(),O=ae>4||ae===0?FP.ceil(O):FP(O),O=ME.offset(O,(re.V-1)*7),re.y=O.getFullYear(),re.m=O.getMonth(),re.d=O.getDate()+(re.w+6)%7)}else("W"in re||"U"in re)&&("w"in re||(re.w="u"in re?re.u%7:"W"in re?1:0),ae="Z"in re?_4(F1(re.y,0,1)).getUTCDay():S4(F1(re.y,0,1)).getDay(),re.m=0,re.d="W"in re?(re.w+6)%7+re.W*7-(ae+5)%7:re.w+re.U*7-(ae+6)%7);return"Z"in re?(re.H+=re.Z/100|0,re.M+=re.Z%100,_4(re)):S4(re)}}function C(J,Z,ee,re){for(var he=0,O=Z.length,ae=ee.length,q,I;he<O;){if(re>=ae)return-1;if(q=Z.charCodeAt(he++),q===37){if(q=Z.charAt(he++),I=S[q in kZ?Z.charAt(he++):q],!I||(re=I(J,ee,re))<0)return-1}else if(q!=ee.charCodeAt(re++))return-1}return re}function A(J,Z,ee){var re=u.exec(Z.slice(ee));return re?(J.p=d.get(re[0].toLowerCase()),ee+re[0].length):-1}function M(J,Z,ee){var re=p.exec(Z.slice(ee));return re?(J.w=m.get(re[0].toLowerCase()),ee+re[0].length):-1}function z(J,Z,ee){var re=h.exec(Z.slice(ee));return re?(J.w=f.get(re[0].toLowerCase()),ee+re[0].length):-1}function P(J,Z,ee){var re=y.exec(Z.slice(ee));return re?(J.m=v.get(re[0].toLowerCase()),ee+re[0].length):-1}function W(J,Z,ee){var re=g.exec(Z.slice(ee));return re?(J.m=x.get(re[0].toLowerCase()),ee+re[0].length):-1}function N(J,Z,ee){return C(J,e,Z,ee)}function U(J,Z,ee){return C(J,r,Z,ee)}function K(J,Z,ee){return C(J,n,Z,ee)}function G(J){return a[J.getDay()]}function X(J){return i[J.getDay()]}function H(J){return c[J.getMonth()]}function B(J){return o[J.getMonth()]}function L(J){return s[+(J.getHours()>=12)]}function F(J){return 1+~~(J.getMonth()/3)}function V(J){return a[J.getUTCDay()]}function Y(J){return i[J.getUTCDay()]}function ie(J){return c[J.getUTCMonth()]}function Q(J){return o[J.getUTCMonth()]}function D(J){return s[+(J.getUTCHours()>=12)]}function R(J){return 1+~~(J.getUTCMonth()/3)}return{format:function(J){var Z=k(J+="",b);return Z.toString=function(){return J},Z},parse:function(J){var Z=E(J+="",!1);return Z.toString=function(){return J},Z},utcFormat:function(J){var Z=k(J+="",w);return Z.toString=function(){return J},Z},utcParse:function(J){var Z=E(J+="",!0);return Z.toString=function(){return J},Z}}}var kZ={"-":"",_:" ",0:"0"},ei=/^\s*\d+/,kot=/^%/,Not=/[\\^$*+?|[\]().{}]/g;function wr(t,e,r){var n=t<0?"-":"",s=(n?-t:t)+"",i=s.length;return n+(i<r?new Array(r-i+1).join(e)+s:s)}function Eot(t){return t.replace(Not,"\\$&")}function $1(t){return new RegExp("^(?:"+t.map(Eot).join("|")+")","i")}function B1(t){return new Map(t.map((e,r)=>[e.toLowerCase(),r]))}function Aot(t,e,r){var n=ei.exec(e.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function Cot(t,e,r){var n=ei.exec(e.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function Tot(t,e,r){var n=ei.exec(e.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function Pot(t,e,r){var n=ei.exec(e.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function Oot(t,e,r){var n=ei.exec(e.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function NZ(t,e,r){var n=ei.exec(e.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function EZ(t,e,r){var n=ei.exec(e.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function Iot(t,e,r){var n=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(r,r+6));return n?(t.Z=n[1]?0:-(n[2]+(n[3]||"00")),r+n[0].length):-1}function Rot(t,e,r){var n=ei.exec(e.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Mot(t,e,r){var n=ei.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function AZ(t,e,r){var n=ei.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Dot(t,e,r){var n=ei.exec(e.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function CZ(t,e,r){var n=ei.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Lot(t,e,r){var n=ei.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Fot(t,e,r){var n=ei.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function $ot(t,e,r){var n=ei.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Bot(t,e,r){var n=ei.exec(e.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function zot(t,e,r){var n=kot.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function Uot(t,e,r){var n=ei.exec(e.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function Hot(t,e,r){var n=ei.exec(e.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function TZ(t,e){return wr(t.getDate(),e,2)}function Vot(t,e){return wr(t.getHours(),e,2)}function Wot(t,e){return wr(t.getHours()%12||12,e,2)}function qot(t,e){return wr(1+ME.count(vh(t),t),e,3)}function Bye(t,e){return wr(t.getMilliseconds(),e,3)}function Got(t,e){return Bye(t,e)+"000"}function Kot(t,e){return wr(t.getMonth()+1,e,2)}function Yot(t,e){return wr(t.getMinutes(),e,2)}function Xot(t,e){return wr(t.getSeconds(),e,2)}function Jot(t){var e=t.getDay();return e===0?7:e}function Qot(t,e){return wr(mM.count(vh(t)-1,t),e,2)}function zye(t){var e=t.getDay();return e>=4||e===0?iw(t):iw.ceil(t)}function Zot(t,e){return t=zye(t),wr(iw.count(vh(t),t)+(vh(t).getDay()===4),e,2)}function elt(t){return t.getDay()}function tlt(t,e){return wr(FP.count(vh(t)-1,t),e,2)}function rlt(t,e){return wr(t.getFullYear()%100,e,2)}function nlt(t,e){return t=zye(t),wr(t.getFullYear()%100,e,2)}function slt(t,e){return wr(t.getFullYear()%1e4,e,4)}function ilt(t,e){var r=t.getDay();return t=r>=4||r===0?iw(t):iw.ceil(t),wr(t.getFullYear()%1e4,e,4)}function alt(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+wr(e/60|0,"0",2)+wr(e%60,"0",2)}function PZ(t,e){return wr(t.getUTCDate(),e,2)}function olt(t,e){return wr(t.getUTCHours(),e,2)}function llt(t,e){return wr(t.getUTCHours()%12||12,e,2)}function clt(t,e){return wr(1+pM.count(bh(t),t),e,3)}function Uye(t,e){return wr(t.getUTCMilliseconds(),e,3)}function ult(t,e){return Uye(t,e)+"000"}function dlt(t,e){return wr(t.getUTCMonth()+1,e,2)}function hlt(t,e){return wr(t.getUTCMinutes(),e,2)}function flt(t,e){return wr(t.getUTCSeconds(),e,2)}function plt(t){var e=t.getUTCDay();return e===0?7:e}function mlt(t,e){return wr(gM.count(bh(t)-1,t),e,2)}function Hye(t){var e=t.getUTCDay();return e>=4||e===0?aw(t):aw.ceil(t)}function glt(t,e){return t=Hye(t),wr(aw.count(bh(t),t)+(bh(t).getUTCDay()===4),e,2)}function ylt(t){return t.getUTCDay()}function xlt(t,e){return wr($P.count(bh(t)-1,t),e,2)}function vlt(t,e){return wr(t.getUTCFullYear()%100,e,2)}function blt(t,e){return t=Hye(t),wr(t.getUTCFullYear()%100,e,2)}function wlt(t,e){return wr(t.getUTCFullYear()%1e4,e,4)}function Slt(t,e){var r=t.getUTCDay();return t=r>=4||r===0?aw(t):aw.ceil(t),wr(t.getUTCFullYear()%1e4,e,4)}function _lt(){return"+0000"}function OZ(){return"%"}function IZ(t){return+t}function RZ(t){return Math.floor(+t/1e3)}var qx,Vye,Wye;jlt({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function jlt(t){return qx=jot(t),Vye=qx.format,qx.parse,Wye=qx.utcFormat,qx.utcParse,qx}function klt(t){return new Date(t)}function Nlt(t){return t instanceof Date?+t:+new Date(+t)}function g9(t,e,r,n,s,i,a,o,c,u){var d=r9(),h=d.invert,f=d.domain,p=u(".%L"),m=u(":%S"),g=u("%I:%M"),x=u("%I %p"),y=u("%a %d"),v=u("%b %d"),b=u("%B"),w=u("%Y");function S(k){return(c(k)<k?p:o(k)<k?m:a(k)<k?g:i(k)<k?x:n(k)<k?s(k)<k?y:v:r(k)<k?b:w)(k)}return d.invert=function(k){return new Date(h(k))},d.domain=function(k){return arguments.length?f(Array.from(k,Nlt)):f().map(klt)},d.ticks=function(k){var E=f();return t(E[0],E[E.length-1],k??10)},d.tickFormat=function(k,E){return E==null?S:u(E)},d.nice=function(k){var E=f();return(!k||typeof k.range!="function")&&(k=e(E[0],E[E.length-1],k??10)),k?f(Pye(E,k)):d},d.copy=function(){return RE(d,g9(t,e,r,n,s,i,a,o,c,u))},d}function Elt(){return Ol.apply(g9(Sot,_ot,vh,p9,mM,ME,h9,u9,ng,Vye).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Alt(){return Ol.apply(g9(bot,wot,bh,m9,gM,pM,f9,d9,ng,Wye).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function yM(){var t=0,e=1,r,n,s,i,a=fa,o=!1,c;function u(h){return h==null||isNaN(h=+h)?c:a(s===0?.5:(h=(i(h)-r)*s,o?Math.max(0,Math.min(1,h)):h))}u.domain=function(h){return arguments.length?([t,e]=h,r=i(t=+t),n=i(e=+e),s=r===n?0:1/(n-r),u):[t,e]},u.clamp=function(h){return arguments.length?(o=!!h,u):o},u.interpolator=function(h){return arguments.length?(a=h,u):a};function d(h){return function(f){var p,m;return arguments.length?([p,m]=f,a=h(p,m),u):[a(0),a(1)]}}return u.range=d(c1),u.rangeRound=d(t9),u.unknown=function(h){return arguments.length?(c=h,u):c},function(h){return i=h,r=h(t),n=h(e),s=r===n?0:1/(n-r),u}}function dm(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function qye(){var t=um(yM()(fa));return t.copy=function(){return dm(t,qye())},Ih.apply(t,arguments)}function Gye(){var t=i9(yM()).domain([1,10]);return t.copy=function(){return dm(t,Gye()).base(t.base())},Ih.apply(t,arguments)}function Kye(){var t=a9(yM());return t.copy=function(){return dm(t,Kye()).constant(t.constant())},Ih.apply(t,arguments)}function y9(){var t=o9(yM());return t.copy=function(){return dm(t,y9()).exponent(t.exponent())},Ih.apply(t,arguments)}function Clt(){return y9.apply(null,arguments).exponent(.5)}function Yye(){var t=[],e=fa;function r(n){if(n!=null&&!isNaN(n=+n))return e((OE(t,n,1)-1)/(t.length-1))}return r.domain=function(n){if(!arguments.length)return t.slice();t=[];for(let s of n)s!=null&&!isNaN(s=+s)&&t.push(s);return t.sort(Ep),r},r.interpolator=function(n){return arguments.length?(e=n,r):e},r.range=function(){return t.map((n,s)=>e(s/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(s,i)=>mat(t,i/n))},r.copy=function(){return Yye(e).domain(t)},Ih.apply(r,arguments)}function xM(){var t=0,e=.5,r=1,n=1,s,i,a,o,c,u=fa,d,h=!1,f;function p(g){return isNaN(g=+g)?f:(g=.5+((g=+d(g))-i)*(n*g<n*i?o:c),u(h?Math.max(0,Math.min(1,g)):g))}p.domain=function(g){return arguments.length?([t,e,r]=g,s=d(t=+t),i=d(e=+e),a=d(r=+r),o=s===i?0:.5/(i-s),c=i===a?0:.5/(a-i),n=i<s?-1:1,p):[t,e,r]},p.clamp=function(g){return arguments.length?(h=!!g,p):h},p.interpolator=function(g){return arguments.length?(u=g,p):u};function m(g){return function(x){var y,v,b;return arguments.length?([y,v,b]=x,u=zat(g,[y,v,b]),p):[u(0),u(.5),u(1)]}}return p.range=m(c1),p.rangeRound=m(t9),p.unknown=function(g){return arguments.length?(f=g,p):f},function(g){return d=g,s=g(t),i=g(e),a=g(r),o=s===i?0:.5/(i-s),c=i===a?0:.5/(a-i),n=i<s?-1:1,p}}function Xye(){var t=um(xM()(fa));return t.copy=function(){return dm(t,Xye())},Ih.apply(t,arguments)}function Jye(){var t=i9(xM()).domain([.1,1,10]);return t.copy=function(){return dm(t,Jye()).base(t.base())},Ih.apply(t,arguments)}function Qye(){var t=a9(xM());return t.copy=function(){return dm(t,Qye()).constant(t.constant())},Ih.apply(t,arguments)}function x9(){var t=o9(xM());return t.copy=function(){return dm(t,x9()).exponent(t.exponent())},Ih.apply(t,arguments)}function Tlt(){return x9.apply(null,arguments).exponent(.5)}const MZ=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:Ej,scaleDiverging:Xye,scaleDivergingLog:Jye,scaleDivergingPow:x9,scaleDivergingSqrt:Tlt,scaleDivergingSymlog:Qye,scaleIdentity:Tye,scaleImplicit:wB,scaleLinear:DP,scaleLog:Oye,scaleOrdinal:QW,scalePoint:w_,scalePow:l9,scaleQuantile:Mye,scaleQuantize:Dye,scaleRadial:Rye,scaleSequential:qye,scaleSequentialLog:Gye,scaleSequentialPow:y9,scaleSequentialQuantile:Yye,scaleSequentialSqrt:Clt,scaleSequentialSymlog:Kye,scaleSqrt:uot,scaleSymlog:Iye,scaleThreshold:Lye,scaleTime:Elt,scaleUtc:Alt,tickFormat:Cye},Symbol.toStringTag,{value:"Module"}));var Plt=t1;function Olt(t,e,r){for(var n=-1,s=t.length;++n<s;){var i=t[n],a=e(i);if(a!=null&&(o===void 0?a===a&&!Plt(a):r(a,o)))var o=a,c=i}return c}var vM=Olt;function Ilt(t,e){return t>e}var Zye=Ilt,Rlt=vM,Mlt=Zye,Dlt=l1;function Llt(t){return t&&t.length?Rlt(t,Dlt,Mlt):void 0}var Flt=Llt;const bM=cr(Flt);function $lt(t,e){return t<e}var exe=$lt,Blt=vM,zlt=exe,Ult=l1;function Hlt(t){return t&&t.length?Blt(t,Ult,zlt):void 0}var Vlt=Hlt;const wM=cr(Vlt);var Wlt=PW,qlt=cm,Glt=oye,Klt=eo;function Ylt(t,e){var r=Klt(t)?Wlt:Glt;return r(t,qlt(e))}var Xlt=Ylt,Jlt=iye,Qlt=Xlt;function Zlt(t,e){return Jlt(Qlt(t,e),1)}var ect=Zlt;const tct=cr(ect);var rct=GW;function nct(t,e){return rct(t,e)}var sct=nct;const v9=cr(sct);var u1=1e9,ict={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},w9,_n=!0,Nl="[DecimalError] ",Iy=Nl+"Invalid argument: ",b9=Nl+"Exponent out of range: ",d1=Math.floor,$m=Math.pow,act=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ko,Ws=1e7,un=7,txe=9007199254740991,BP=d1(txe/un),gt={};gt.absoluteValue=gt.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};gt.comparedTo=gt.cmp=function(t){var e,r,n,s,i=this;if(t=new i.constructor(t),i.s!==t.s)return i.s||-t.s;if(i.e!==t.e)return i.e>t.e^i.s<0?1:-1;for(n=i.d.length,s=t.d.length,e=0,r=n<s?n:s;e<r;++e)if(i.d[e]!==t.d[e])return i.d[e]>t.d[e]^i.s<0?1:-1;return n===s?0:n>s^i.s<0?1:-1};gt.decimalPlaces=gt.dp=function(){var t=this,e=t.d.length-1,r=(e-t.e)*un;if(e=t.d[e],e)for(;e%10==0;e/=10)r--;return r<0?0:r};gt.dividedBy=gt.div=function(t){return nh(this,new this.constructor(t))};gt.dividedToIntegerBy=gt.idiv=function(t){var e=this,r=e.constructor;return qr(nh(e,new r(t),0,1),r.precision)};gt.equals=gt.eq=function(t){return!this.cmp(t)};gt.exponent=function(){return hs(this)};gt.greaterThan=gt.gt=function(t){return this.cmp(t)>0};gt.greaterThanOrEqualTo=gt.gte=function(t){return this.cmp(t)>=0};gt.isInteger=gt.isint=function(){return this.e>this.d.length-2};gt.isNegative=gt.isneg=function(){return this.s<0};gt.isPositive=gt.ispos=function(){return this.s>0};gt.isZero=function(){return this.s===0};gt.lessThan=gt.lt=function(t){return this.cmp(t)<0};gt.lessThanOrEqualTo=gt.lte=function(t){return this.cmp(t)<1};gt.logarithm=gt.log=function(t){var e,r=this,n=r.constructor,s=n.precision,i=s+5;if(t===void 0)t=new n(10);else if(t=new n(t),t.s<1||t.eq(ko))throw Error(Nl+"NaN");if(r.s<1)throw Error(Nl+(r.s?"NaN":"-Infinity"));return r.eq(ko)?new n(0):(_n=!1,e=nh(Oj(r,i),Oj(t,i),i),_n=!0,qr(e,s))};gt.minus=gt.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?sxe(e,t):rxe(e,(t.s=-t.s,t))};gt.modulo=gt.mod=function(t){var e,r=this,n=r.constructor,s=n.precision;if(t=new n(t),!t.s)throw Error(Nl+"NaN");return r.s?(_n=!1,e=nh(r,t,0,1).times(t),_n=!0,r.minus(e)):qr(new n(r),s)};gt.naturalExponential=gt.exp=function(){return nxe(this)};gt.naturalLogarithm=gt.ln=function(){return Oj(this)};gt.negated=gt.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};gt.plus=gt.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?rxe(e,t):sxe(e,(t.s=-t.s,t))};gt.precision=gt.sd=function(t){var e,r,n,s=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Iy+t);if(e=hs(s)+1,n=s.d.length-1,r=n*un+1,n=s.d[n],n){for(;n%10==0;n/=10)r--;for(n=s.d[0];n>=10;n/=10)r++}return t&&e>r?e:r};gt.squareRoot=gt.sqrt=function(){var t,e,r,n,s,i,a,o=this,c=o.constructor;if(o.s<1){if(!o.s)return new c(0);throw Error(Nl+"NaN")}for(t=hs(o),_n=!1,s=Math.sqrt(+o),s==0||s==1/0?(e=mu(o.d),(e.length+t)%2==0&&(e+="0"),s=Math.sqrt(e),t=d1((t+1)/2)-(t<0||t%2),s==1/0?e="5e"+t:(e=s.toExponential(),e=e.slice(0,e.indexOf("e")+1)+t),n=new c(e)):n=new c(s.toString()),r=c.precision,s=a=r+3;;)if(i=n,n=i.plus(nh(o,i,a+2)).times(.5),mu(i.d).slice(0,a)===(e=mu(n.d)).slice(0,a)){if(e=e.slice(a-3,a+1),s==a&&e=="4999"){if(qr(i,r+1,0),i.times(i).eq(o)){n=i;break}}else if(e!="9999")break;a+=4}return _n=!0,qr(n,r)};gt.times=gt.mul=function(t){var e,r,n,s,i,a,o,c,u,d=this,h=d.constructor,f=d.d,p=(t=new h(t)).d;if(!d.s||!t.s)return new h(0);for(t.s*=d.s,r=d.e+t.e,c=f.length,u=p.length,c<u&&(i=f,f=p,p=i,a=c,c=u,u=a),i=[],a=c+u,n=a;n--;)i.push(0);for(n=u;--n>=0;){for(e=0,s=c+n;s>n;)o=i[s]+p[n]*f[s-n-1]+e,i[s--]=o%Ws|0,e=o/Ws|0;i[s]=(i[s]+e)%Ws|0}for(;!i[--a];)i.pop();return e?++r:i.shift(),t.d=i,t.e=r,_n?qr(t,h.precision):t};gt.toDecimalPlaces=gt.todp=function(t,e){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(Au(t,0,u1),e===void 0?e=n.rounding:Au(e,0,8),qr(r,t+hs(r)+1,e))};gt.toExponential=function(t,e){var r,n=this,s=n.constructor;return t===void 0?r=Zy(n,!0):(Au(t,0,u1),e===void 0?e=s.rounding:Au(e,0,8),n=qr(new s(n),t+1,e),r=Zy(n,!0,t+1)),r};gt.toFixed=function(t,e){var r,n,s=this,i=s.constructor;return t===void 0?Zy(s):(Au(t,0,u1),e===void 0?e=i.rounding:Au(e,0,8),n=qr(new i(s),t+hs(s)+1,e),r=Zy(n.abs(),!1,t+hs(n)+1),s.isneg()&&!s.isZero()?"-"+r:r)};gt.toInteger=gt.toint=function(){var t=this,e=t.constructor;return qr(new e(t),hs(t)+1,e.rounding)};gt.toNumber=function(){return+this};gt.toPower=gt.pow=function(t){var e,r,n,s,i,a,o=this,c=o.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(ko);if(o=new c(o),!o.s){if(t.s<1)throw Error(Nl+"Infinity");return o}if(o.eq(ko))return o;if(n=c.precision,t.eq(ko))return qr(o,n);if(e=t.e,r=t.d.length-1,a=e>=r,i=o.s,a){if((r=d<0?-d:d)<=txe){for(s=new c(ko),e=Math.ceil(n/un+4),_n=!1;r%2&&(s=s.times(o),LZ(s.d,e)),r=d1(r/2),r!==0;)o=o.times(o),LZ(o.d,e);return _n=!0,t.s<0?new c(ko).div(s):qr(s,n)}}else if(i<0)throw Error(Nl+"NaN");return i=i<0&&t.d[Math.max(e,r)]&1?-1:1,o.s=1,_n=!1,s=t.times(Oj(o,n+u)),_n=!0,s=nxe(s),s.s=i,s};gt.toPrecision=function(t,e){var r,n,s=this,i=s.constructor;return t===void 0?(r=hs(s),n=Zy(s,r<=i.toExpNeg||r>=i.toExpPos)):(Au(t,1,u1),e===void 0?e=i.rounding:Au(e,0,8),s=qr(new i(s),t,e),r=hs(s),n=Zy(s,t<=r||r<=i.toExpNeg,t)),n};gt.toSignificantDigits=gt.tosd=function(t,e){var r=this,n=r.constructor;return t===void 0?(t=n.precision,e=n.rounding):(Au(t,1,u1),e===void 0?e=n.rounding:Au(e,0,8)),qr(new n(r),t,e)};gt.toString=gt.valueOf=gt.val=gt.toJSON=gt[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=hs(t),r=t.constructor;return Zy(t,e<=r.toExpNeg||e>=r.toExpPos)};function rxe(t,e){var r,n,s,i,a,o,c,u,d=t.constructor,h=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),_n?qr(e,h):e;if(c=t.d,u=e.d,a=t.e,s=e.e,c=c.slice(),i=a-s,i){for(i<0?(n=c,i=-i,o=u.length):(n=u,s=a,o=c.length),a=Math.ceil(h/un),o=a>o?a+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=c.length,i=u.length,o-i<0&&(i=o,n=u,u=c,c=n),r=0;i;)r=(c[--i]=c[i]+u[i]+r)/Ws|0,c[i]%=Ws;for(r&&(c.unshift(r),++s),o=c.length;c[--o]==0;)c.pop();return e.d=c,e.e=s,_n?qr(e,h):e}function Au(t,e,r){if(t!==~~t||t<e||t>r)throw Error(Iy+t)}function mu(t){var e,r,n,s=t.length-1,i="",a=t[0];if(s>0){for(i+=a,e=1;e<s;e++)n=t[e]+"",r=un-n.length,r&&(i+=sf(r)),i+=n;a=t[e],n=a+"",r=un-n.length,r&&(i+=sf(r))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}var nh=function(){function t(n,s){var i,a=0,o=n.length;for(n=n.slice();o--;)i=n[o]*s+a,n[o]=i%Ws|0,a=i/Ws|0;return a&&n.unshift(a),n}function e(n,s,i,a){var o,c;if(i!=a)c=i>a?1:-1;else for(o=c=0;o<i;o++)if(n[o]!=s[o]){c=n[o]>s[o]?1:-1;break}return c}function r(n,s,i){for(var a=0;i--;)n[i]-=a,a=n[i]<s[i]?1:0,n[i]=a*Ws+n[i]-s[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,s,i,a){var o,c,u,d,h,f,p,m,g,x,y,v,b,w,S,k,E,C,A=n.constructor,M=n.s==s.s?1:-1,z=n.d,P=s.d;if(!n.s)return new A(n);if(!s.s)throw Error(Nl+"Division by zero");for(c=n.e-s.e,E=P.length,S=z.length,p=new A(M),m=p.d=[],u=0;P[u]==(z[u]||0);)++u;if(P[u]>(z[u]||0)&&--c,i==null?v=i=A.precision:a?v=i+(hs(n)-hs(s))+1:v=i,v<0)return new A(0);if(v=v/un+2|0,u=0,E==1)for(d=0,P=P[0],v++;(u<S||d)&&v--;u++)b=d*Ws+(z[u]||0),m[u]=b/P|0,d=b%P|0;else{for(d=Ws/(P[0]+1)|0,d>1&&(P=t(P,d),z=t(z,d),E=P.length,S=z.length),w=E,g=z.slice(0,E),x=g.length;x<E;)g[x++]=0;C=P.slice(),C.unshift(0),k=P[0],P[1]>=Ws/2&&++k;do d=0,o=e(P,g,E,x),o<0?(y=g[0],E!=x&&(y=y*Ws+(g[1]||0)),d=y/k|0,d>1?(d>=Ws&&(d=Ws-1),h=t(P,d),f=h.length,x=g.length,o=e(h,g,f,x),o==1&&(d--,r(h,E<f?C:P,f))):(d==0&&(o=d=1),h=P.slice()),f=h.length,f<x&&h.unshift(0),r(g,h,x),o==-1&&(x=g.length,o=e(P,g,E,x),o<1&&(d++,r(g,E<x?C:P,x))),x=g.length):o===0&&(d++,g=[0]),m[u++]=d,o&&g[0]?g[x++]=z[w]||0:(g=[z[w]],x=1);while((w++<S||g[0]!==void 0)&&v--)}return m[0]||m.shift(),p.e=c,qr(p,a?i+hs(p)+1:i)}}();function nxe(t,e){var r,n,s,i,a,o,c=0,u=0,d=t.constructor,h=d.precision;if(hs(t)>16)throw Error(b9+hs(t));if(!t.s)return new d(ko);for(e==null?(_n=!1,o=h):o=e,a=new d(.03125);t.abs().gte(.1);)t=t.times(a),u+=5;for(n=Math.log($m(2,u))/Math.LN10*2+5|0,o+=n,r=s=i=new d(ko),d.precision=o;;){if(s=qr(s.times(t),o),r=r.times(++c),a=i.plus(nh(s,r,o)),mu(a.d).slice(0,o)===mu(i.d).slice(0,o)){for(;u--;)i=qr(i.times(i),o);return d.precision=h,e==null?(_n=!0,qr(i,h)):i}i=a}}function hs(t){for(var e=t.e*un,r=t.d[0];r>=10;r/=10)e++;return e}function j4(t,e,r){if(e>t.LN10.sd())throw _n=!0,r&&(t.precision=r),Error(Nl+"LN10 precision limit exceeded");return qr(new t(t.LN10),e)}function sf(t){for(var e="";t--;)e+="0";return e}function Oj(t,e){var r,n,s,i,a,o,c,u,d,h=1,f=10,p=t,m=p.d,g=p.constructor,x=g.precision;if(p.s<1)throw Error(Nl+(p.s?"NaN":"-Infinity"));if(p.eq(ko))return new g(0);if(e==null?(_n=!1,u=x):u=e,p.eq(10))return e==null&&(_n=!0),j4(g,u);if(u+=f,g.precision=u,r=mu(m),n=r.charAt(0),i=hs(p),Math.abs(i)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)p=p.times(t),r=mu(p.d),n=r.charAt(0),h++;i=hs(p),n>1?(p=new g("0."+r),i++):p=new g(n+"."+r.slice(1))}else return c=j4(g,u+2,x).times(i+""),p=Oj(new g(n+"."+r.slice(1)),u-f).plus(c),g.precision=x,e==null?(_n=!0,qr(p,x)):p;for(o=a=p=nh(p.minus(ko),p.plus(ko),u),d=qr(p.times(p),u),s=3;;){if(a=qr(a.times(d),u),c=o.plus(nh(a,new g(s),u)),mu(c.d).slice(0,u)===mu(o.d).slice(0,u))return o=o.times(2),i!==0&&(o=o.plus(j4(g,u+2,x).times(i+""))),o=nh(o,new g(h),u),g.precision=x,e==null?(_n=!0,qr(o,x)):o;o=c,s+=2}}function DZ(t,e){var r,n,s;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),n=0;e.charCodeAt(n)===48;)++n;for(s=e.length;e.charCodeAt(s-1)===48;)--s;if(e=e.slice(n,s),e){if(s-=n,r=r-n-1,t.e=d1(r/un),t.d=[],n=(r+1)%un,r<0&&(n+=un),n<s){for(n&&t.d.push(+e.slice(0,n)),s-=un;n<s;)t.d.push(+e.slice(n,n+=un));e=e.slice(n),n=un-e.length}else n-=s;for(;n--;)e+="0";if(t.d.push(+e),_n&&(t.e>BP||t.e<-BP))throw Error(b9+r)}else t.s=0,t.e=0,t.d=[0];return t}function qr(t,e,r){var n,s,i,a,o,c,u,d,h=t.d;for(a=1,i=h[0];i>=10;i/=10)a++;if(n=e-a,n<0)n+=un,s=e,u=h[d=0];else{if(d=Math.ceil((n+1)/un),i=h.length,d>=i)return t;for(u=i=h[d],a=1;i>=10;i/=10)a++;n%=un,s=n-un+a}if(r!==void 0&&(i=$m(10,a-s-1),o=u/i%10|0,c=e<0||h[d+1]!==void 0||u%i,c=r<4?(o||c)&&(r==0||r==(t.s<0?3:2)):o>5||o==5&&(r==4||c||r==6&&(n>0?s>0?u/$m(10,a-s):0:h[d-1])%10&1||r==(t.s<0?8:7))),e<1||!h[0])return c?(i=hs(t),h.length=1,e=e-i-1,h[0]=$m(10,(un-e%un)%un),t.e=d1(-e/un)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(n==0?(h.length=d,i=1,d--):(h.length=d+1,i=$m(10,un-n),h[d]=s>0?(u/$m(10,a-s)%$m(10,s)|0)*i:0),c)for(;;)if(d==0){(h[0]+=i)==Ws&&(h[0]=1,++t.e);break}else{if(h[d]+=i,h[d]!=Ws)break;h[d--]=0,i=1}for(n=h.length;h[--n]===0;)h.pop();if(_n&&(t.e>BP||t.e<-BP))throw Error(b9+hs(t));return t}function sxe(t,e){var r,n,s,i,a,o,c,u,d,h,f=t.constructor,p=f.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new f(t),_n?qr(e,p):e;if(c=t.d,h=e.d,n=e.e,u=t.e,c=c.slice(),a=u-n,a){for(d=a<0,d?(r=c,a=-a,o=h.length):(r=h,n=u,o=c.length),s=Math.max(Math.ceil(p/un),o)+2,a>s&&(a=s,r.length=1),r.reverse(),s=a;s--;)r.push(0);r.reverse()}else{for(s=c.length,o=h.length,d=s<o,d&&(o=s),s=0;s<o;s++)if(c[s]!=h[s]){d=c[s]<h[s];break}a=0}for(d&&(r=c,c=h,h=r,e.s=-e.s),o=c.length,s=h.length-o;s>0;--s)c[o++]=0;for(s=h.length;s>a;){if(c[--s]<h[s]){for(i=s;i&&c[--i]===0;)c[i]=Ws-1;--c[i],c[s]+=Ws}c[s]-=h[s]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--n;return c[0]?(e.d=c,e.e=n,_n?qr(e,p):e):new f(0)}function Zy(t,e,r){var n,s=hs(t),i=mu(t.d),a=i.length;return e?(r&&(n=r-a)>0?i=i.charAt(0)+"."+i.slice(1)+sf(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(s<0?"e":"e+")+s):s<0?(i="0."+sf(-s-1)+i,r&&(n=r-a)>0&&(i+=sf(n))):s>=a?(i+=sf(s+1-a),r&&(n=r-s-1)>0&&(i=i+"."+sf(n))):((n=s+1)<a&&(i=i.slice(0,n)+"."+i.slice(n)),r&&(n=r-a)>0&&(s+1===a&&(i+="."),i+=sf(n))),t.s<0?"-"+i:i}function LZ(t,e){if(t.length>e)return t.length=e,!0}function ixe(t){var e,r,n;function s(i){var a=this;if(!(a instanceof s))return new s(i);if(a.constructor=s,i instanceof s){a.s=i.s,a.e=i.e,a.d=(i=i.d)?i.slice():i;return}if(typeof i=="number"){if(i*0!==0)throw Error(Iy+i);if(i>0)a.s=1;else if(i<0)i=-i,a.s=-1;else{a.s=0,a.e=0,a.d=[0];return}if(i===~~i&&i<1e7){a.e=0,a.d=[i];return}return DZ(a,i.toString())}else if(typeof i!="string")throw Error(Iy+i);if(i.charCodeAt(0)===45?(i=i.slice(1),a.s=-1):a.s=1,act.test(i))DZ(a,i);else throw Error(Iy+i)}if(s.prototype=gt,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.clone=ixe,s.config=s.set=oct,t===void 0&&(t={}),t)for(n=["precision","rounding","toExpNeg","toExpPos","LN10"],e=0;e<n.length;)t.hasOwnProperty(r=n[e++])||(t[r]=this[r]);return s.config(t),s}function oct(t){if(!t||typeof t!="object")throw Error(Nl+"Object expected");var e,r,n,s=["precision",1,u1,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(e=0;e<s.length;e+=3)if((n=t[r=s[e]])!==void 0)if(d1(n)===n&&n>=s[e+1]&&n<=s[e+2])this[r]=n;else throw Error(Iy+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(Iy+r+": "+n);return this}var w9=ixe(ict);ko=new w9(1);const Lr=w9;function lct(t){return hct(t)||dct(t)||uct(t)||cct()}function cct(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uct(t,e){if(t){if(typeof t=="string")return kB(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return kB(t,e)}}function dct(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function hct(t){if(Array.isArray(t))return kB(t)}function kB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var fct=function(e){return e},axe={"@@functional/placeholder":!0},oxe=function(e){return e===axe},FZ=function(e){return function r(){return arguments.length===0||arguments.length===1&&oxe(arguments.length<=0?void 0:arguments[0])?r:e.apply(void 0,arguments)}},pct=function t(e,r){return e===1?r:FZ(function(){for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];var a=s.filter(function(o){return o!==axe}).length;return a>=e?r.apply(void 0,s):t(e-a,FZ(function(){for(var o=arguments.length,c=new Array(o),u=0;u<o;u++)c[u]=arguments[u];var d=s.map(function(h){return oxe(h)?c.shift():h});return r.apply(void 0,lct(d).concat(c))}))})},SM=function(e){return pct(e.length,e)},NB=function(e,r){for(var n=[],s=e;s<r;++s)n[s-e]=s;return n},mct=SM(function(t,e){return Array.isArray(e)?e.map(t):Object.keys(e).map(function(r){return e[r]}).map(t)}),gct=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];if(!r.length)return fct;var s=r.reverse(),i=s[0],a=s.slice(1);return function(){return a.reduce(function(o,c){return c(o)},i.apply(void 0,arguments))}},EB=function(e){return Array.isArray(e)?e.reverse():e.split("").reverse.join("")},lxe=function(e){var r=null,n=null;return function(){for(var s=arguments.length,i=new Array(s),a=0;a<s;a++)i[a]=arguments[a];return r&&i.every(function(o,c){return o===r[c]})||(r=i,n=e.apply(void 0,i)),n}};function yct(t){var e;return t===0?e=1:e=Math.floor(new Lr(t).abs().log(10).toNumber())+1,e}function xct(t,e,r){for(var n=new Lr(t),s=0,i=[];n.lt(e)&&s<1e5;)i.push(n.toNumber()),n=n.add(r),s++;return i}var vct=SM(function(t,e,r){var n=+t,s=+e;return n+r*(s-n)}),bct=SM(function(t,e,r){var n=e-+t;return n=n||1/0,(r-t)/n}),wct=SM(function(t,e,r){var n=e-+t;return n=n||1/0,Math.max(0,Math.min(1,(r-t)/n))});const _M={rangeStep:xct,getDigitCount:yct,interpolateNumber:vct,uninterpolateNumber:bct,uninterpolateTruncation:wct};function AB(t){return jct(t)||_ct(t)||cxe(t)||Sct()}function Sct(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _ct(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function jct(t){if(Array.isArray(t))return CB(t)}function Ij(t,e){return Ect(t)||Nct(t,e)||cxe(t,e)||kct()}function kct(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cxe(t,e){if(t){if(typeof t=="string")return CB(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return CB(t,e)}}function CB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Nct(t,e){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(t)))){var r=[],n=!0,s=!1,i=void 0;try{for(var a=t[Symbol.iterator](),o;!(n=(o=a.next()).done)&&(r.push(o.value),!(e&&r.length===e));n=!0);}catch(c){s=!0,i=c}finally{try{!n&&a.return!=null&&a.return()}finally{if(s)throw i}}return r}}function Ect(t){if(Array.isArray(t))return t}function uxe(t){var e=Ij(t,2),r=e[0],n=e[1],s=r,i=n;return r>n&&(s=n,i=r),[s,i]}function dxe(t,e,r){if(t.lte(0))return new Lr(0);var n=_M.getDigitCount(t.toNumber()),s=new Lr(10).pow(n),i=t.div(s),a=n!==1?.05:.1,o=new Lr(Math.ceil(i.div(a).toNumber())).add(r).mul(a),c=o.mul(s);return e?c:new Lr(Math.ceil(c))}function Act(t,e,r){var n=1,s=new Lr(t);if(!s.isint()&&r){var i=Math.abs(t);i<1?(n=new Lr(10).pow(_M.getDigitCount(t)-1),s=new Lr(Math.floor(s.div(n).toNumber())).mul(n)):i>1&&(s=new Lr(Math.floor(t)))}else t===0?s=new Lr(Math.floor((e-1)/2)):r||(s=new Lr(Math.floor(t)));var a=Math.floor((e-1)/2),o=gct(mct(function(c){return s.add(new Lr(c-a).mul(n)).toNumber()}),NB);return o(0,e)}function hxe(t,e,r,n){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((e-t)/(r-1)))return{step:new Lr(0),tickMin:new Lr(0),tickMax:new Lr(0)};var i=dxe(new Lr(e).sub(t).div(r-1),n,s),a;t<=0&&e>=0?a=new Lr(0):(a=new Lr(t).add(e).div(2),a=a.sub(new Lr(a).mod(i)));var o=Math.ceil(a.sub(t).div(i).toNumber()),c=Math.ceil(new Lr(e).sub(a).div(i).toNumber()),u=o+c+1;return u>r?hxe(t,e,r,n,s+1):(u<r&&(c=e>0?c+(r-u):c,o=e>0?o:o+(r-u)),{step:i,tickMin:a.sub(new Lr(o).mul(i)),tickMax:a.add(new Lr(c).mul(i))})}function Cct(t){var e=Ij(t,2),r=e[0],n=e[1],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=Math.max(s,2),o=uxe([r,n]),c=Ij(o,2),u=c[0],d=c[1];if(u===-1/0||d===1/0){var h=d===1/0?[u].concat(AB(NB(0,s-1).map(function(){return 1/0}))):[].concat(AB(NB(0,s-1).map(function(){return-1/0})),[d]);return r>n?EB(h):h}if(u===d)return Act(u,s,i);var f=hxe(u,d,a,i),p=f.step,m=f.tickMin,g=f.tickMax,x=_M.rangeStep(m,g.add(new Lr(.1).mul(p)),p);return r>n?EB(x):x}function Tct(t,e){var r=Ij(t,2),n=r[0],s=r[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=uxe([n,s]),o=Ij(a,2),c=o[0],u=o[1];if(c===-1/0||u===1/0)return[n,s];if(c===u)return[c];var d=Math.max(e,2),h=dxe(new Lr(u).sub(c).div(d-1),i,0),f=[].concat(AB(_M.rangeStep(new Lr(c),new Lr(u).sub(new Lr(.99).mul(h)),h)),[u]);return n>s?EB(f):f}var Pct=lxe(Cct),Oct=lxe(Tct),Ict="Invariant failed";function ow(t,e){throw new Error(Ict)}var Rct=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function lw(t){"@babel/helpers - typeof";return lw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},lw(t)}function zP(){return zP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},zP.apply(this,arguments)}function Mct(t,e){return $ct(t)||Fct(t,e)||Lct(t,e)||Dct()}function Dct(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lct(t,e){if(t){if(typeof t=="string")return $Z(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $Z(t,e)}}function $Z(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Fct(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function $ct(t){if(Array.isArray(t))return t}function Bct(t,e){if(t==null)return{};var r=zct(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function zct(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Uct(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Hct(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,mxe(n.key),n)}}function Vct(t,e,r){return e&&Hct(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Wct(t,e,r){return e=UP(e),qct(t,fxe()?Reflect.construct(e,r||[],UP(t).constructor):e.apply(t,r))}function qct(t,e){if(e&&(lw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Gct(t)}function Gct(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function fxe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(fxe=function(){return!!t})()}function UP(t){return UP=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},UP(t)}function Kct(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&TB(t,e)}function TB(t,e){return TB=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},TB(t,e)}function pxe(t,e,r){return e=mxe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function mxe(t){var e=Yct(t,"string");return lw(e)=="symbol"?e:e+""}function Yct(t,e){if(lw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(lw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var S9=function(t){function e(){return Uct(this,e),Wct(this,e,arguments)}return Kct(e,t),Vct(e,[{key:"render",value:function(){var n=this.props,s=n.offset,i=n.layout,a=n.width,o=n.dataKey,c=n.data,u=n.dataPointFormatter,d=n.xAxis,h=n.yAxis,f=Bct(n,Rct),p=Gt(f,!1);this.props.direction==="x"&&d.type!=="number"&&ow();var m=c.map(function(g){var x=u(g,o),y=x.x,v=x.y,b=x.value,w=x.errorVal;if(!w)return null;var S=[],k,E;if(Array.isArray(w)){var C=Mct(w,2);k=C[0],E=C[1]}else k=E=w;if(i==="vertical"){var A=d.scale,M=v+s,z=M+a,P=M-a,W=A(b-k),N=A(b+E);S.push({x1:N,y1:z,x2:N,y2:P}),S.push({x1:W,y1:M,x2:N,y2:M}),S.push({x1:W,y1:z,x2:W,y2:P})}else if(i==="horizontal"){var U=h.scale,K=y+s,G=K-a,X=K+a,H=U(b-k),B=U(b+E);S.push({x1:G,y1:B,x2:X,y2:B}),S.push({x1:K,y1:H,x2:K,y2:B}),S.push({x1:G,y1:H,x2:X,y2:H})}return pe.createElement(Vn,zP({className:"recharts-errorBar",key:"bar-".concat(S.map(function(L){return"".concat(L.x1,"-").concat(L.x2,"-").concat(L.y1,"-").concat(L.y2)}))},p),S.map(function(L){return pe.createElement("line",zP({},L,{key:"line-".concat(L.x1,"-").concat(L.x2,"-").concat(L.y1,"-").concat(L.y2)}))}))});return pe.createElement(Vn,{className:"recharts-errorBars"},m)}}])}(pe.Component);pxe(S9,"defaultProps",{stroke:"black",strokeWidth:1.5,width:5,offset:0,layout:"horizontal"});pxe(S9,"displayName","ErrorBar");function Rj(t){"@babel/helpers - typeof";return Rj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Rj(t)}function BZ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function jm(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?BZ(Object(r),!0).forEach(function(n){Xct(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):BZ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Xct(t,e,r){return e=Jct(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Jct(t){var e=Qct(t,"string");return Rj(e)=="symbol"?e:e+""}function Qct(t,e){if(Rj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Rj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var gxe=function(e){var r=e.children,n=e.formattedGraphicalItems,s=e.legendWidth,i=e.legendContent,a=tl(r,ob);if(!a)return null;var o=ob.defaultProps,c=o!==void 0?jm(jm({},o),a.props):{},u;return a.props&&a.props.payload?u=a.props&&a.props.payload:i==="children"?u=(n||[]).reduce(function(d,h){var f=h.item,p=h.props,m=p.sectors||p.data||[];return d.concat(m.map(function(g){return{type:a.props.iconType||f.props.legendType,value:g.name,color:g.fill,payload:g}}))},[]):u=(n||[]).map(function(d){var h=d.item,f=h.type.defaultProps,p=f!==void 0?jm(jm({},f),h.props):{},m=p.dataKey,g=p.name,x=p.legendType,y=p.hide;return{inactive:y,dataKey:m,type:c.iconType||x||"square",color:_9(h),value:g||m,payload:p}}),jm(jm(jm({},c),ob.getWithHeight(a,s)),{},{payload:u,item:a})};function Mj(t){"@babel/helpers - typeof";return Mj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Mj(t)}function zZ(t){return rut(t)||tut(t)||eut(t)||Zct()}function Zct(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function eut(t,e){if(t){if(typeof t=="string")return PB(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return PB(t,e)}}function tut(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function rut(t){if(Array.isArray(t))return PB(t)}function PB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function UZ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Bn(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?UZ(Object(r),!0).forEach(function(n){cb(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):UZ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function cb(t,e,r){return e=nut(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function nut(t){var e=sut(t,"string");return Mj(e)=="symbol"?e:e+""}function sut(t,e){if(Mj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Mj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function No(t,e,r){return hr(t)||hr(e)?r:Cs(e)?mc(t,e,r):Xt(e)?e(t):r}function S_(t,e,r,n){var s=tct(t,function(o){return No(o,e)});if(r==="number"){var i=s.filter(function(o){return ut(o)||parseFloat(o)});return i.length?[wM(i),bM(i)]:[1/0,-1/0]}var a=n?s.filter(function(o){return!hr(o)}):s;return a.map(function(o){return Cs(o)||o instanceof Date?o:""})}var iut=function(e){var r,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,a=-1,o=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0;if(o<=1)return 0;if(i&&i.axisType==="angleAxis"&&Math.abs(Math.abs(i.range[1]-i.range[0])-360)<=1e-6)for(var c=i.range,u=0;u<o;u++){var d=u>0?s[u-1].coordinate:s[o-1].coordinate,h=s[u].coordinate,f=u>=o-1?s[0].coordinate:s[u+1].coordinate,p=void 0;if(pl(h-d)!==pl(f-h)){var m=[];if(pl(f-h)===pl(c[1]-c[0])){p=f;var g=h+c[1]-c[0];m[0]=Math.min(g,(g+d)/2),m[1]=Math.max(g,(g+d)/2)}else{p=d;var x=f+c[1]-c[0];m[0]=Math.min(h,(x+h)/2),m[1]=Math.max(h,(x+h)/2)}var y=[Math.min(h,(p+h)/2),Math.max(h,(p+h)/2)];if(e>y[0]&&e<=y[1]||e>=m[0]&&e<=m[1]){a=s[u].index;break}}else{var v=Math.min(d,f),b=Math.max(d,f);if(e>(v+h)/2&&e<=(b+h)/2){a=s[u].index;break}}}else for(var w=0;w<o;w++)if(w===0&&e<=(n[w].coordinate+n[w+1].coordinate)/2||w>0&&w<o-1&&e>(n[w].coordinate+n[w-1].coordinate)/2&&e<=(n[w].coordinate+n[w+1].coordinate)/2||w===o-1&&e>(n[w].coordinate+n[w-1].coordinate)/2){a=n[w].index;break}return a},_9=function(e){var r,n=e,s=n.type.displayName,i=(r=e.type)!==null&&r!==void 0&&r.defaultProps?Bn(Bn({},e.type.defaultProps),e.props):e.props,a=i.stroke,o=i.fill,c;switch(s){case"Line":c=a;break;case"Area":case"Radar":c=a&&a!=="none"?a:o;break;default:c=o;break}return c},aut=function(e){var r=e.barSize,n=e.totalSize,s=e.stackGroups,i=s===void 0?{}:s;if(!i)return{};for(var a={},o=Object.keys(i),c=0,u=o.length;c<u;c++)for(var d=i[o[c]].stackGroups,h=Object.keys(d),f=0,p=h.length;f<p;f++){var m=d[h[f]],g=m.items,x=m.cateAxisId,y=g.filter(function(E){return th(E.type).indexOf("Bar")>=0});if(y&&y.length){var v=y[0].type.defaultProps,b=v!==void 0?Bn(Bn({},v),y[0].props):y[0].props,w=b.barSize,S=b[x];a[S]||(a[S]=[]);var k=hr(w)?r:w;a[S].push({item:y[0],stackList:y.slice(1),barSize:hr(k)?void 0:za(k,n,0)})}}return a},out=function(e){var r=e.barGap,n=e.barCategoryGap,s=e.bandSize,i=e.sizeList,a=i===void 0?[]:i,o=e.maxBarSize,c=a.length;if(c<1)return null;var u=za(r,s,0,!0),d,h=[];if(a[0].barSize===+a[0].barSize){var f=!1,p=s/c,m=a.reduce(function(w,S){return w+S.barSize||0},0);m+=(c-1)*u,m>=s&&(m-=(c-1)*u,u=0),m>=s&&p>0&&(f=!0,p*=.9,m=c*p);var g=(s-m)/2>>0,x={offset:g-u,size:0};d=a.reduce(function(w,S){var k={item:S.item,position:{offset:x.offset+x.size+u,size:f?p:S.barSize}},E=[].concat(zZ(w),[k]);return x=E[E.length-1].position,S.stackList&&S.stackList.length&&S.stackList.forEach(function(C){E.push({item:C,position:x})}),E},h)}else{var y=za(n,s,0,!0);s-2*y-(c-1)*u<=0&&(u=0);var v=(s-2*y-(c-1)*u)/c;v>1&&(v>>=0);var b=o===+o?Math.min(v,o):v;d=a.reduce(function(w,S,k){var E=[].concat(zZ(w),[{item:S.item,position:{offset:y+(v+u)*k+(v-b)/2,size:b}}]);return S.stackList&&S.stackList.length&&S.stackList.forEach(function(C){E.push({item:C,position:E[E.length-1].position})}),E},h)}return d},lut=function(e,r,n,s){var i=n.children,a=n.width,o=n.margin,c=a-(o.left||0)-(o.right||0),u=gxe({children:i,legendWidth:c});if(u){var d=s||{},h=d.width,f=d.height,p=u.align,m=u.verticalAlign,g=u.layout;if((g==="vertical"||g==="horizontal"&&m==="middle")&&p!=="center"&&ut(e[p]))return Bn(Bn({},e),{},cb({},p,e[p]+(h||0)));if((g==="horizontal"||g==="vertical"&&p==="center")&&m!=="middle"&&ut(e[m]))return Bn(Bn({},e),{},cb({},m,e[m]+(f||0)))}return e},cut=function(e,r,n){return hr(r)?!0:e==="horizontal"?r==="yAxis":e==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},yxe=function(e,r,n,s,i){var a=r.props.children,o=ju(a,S9).filter(function(u){return cut(s,i,u.props.direction)});if(o&&o.length){var c=o.map(function(u){return u.props.dataKey});return e.reduce(function(u,d){var h=No(d,n);if(hr(h))return u;var f=Array.isArray(h)?[wM(h),bM(h)]:[h,h],p=c.reduce(function(m,g){var x=No(d,g,0),y=f[0]-Math.abs(Array.isArray(x)?x[0]:x),v=f[1]+Math.abs(Array.isArray(x)?x[1]:x);return[Math.min(y,m[0]),Math.max(v,m[1])]},[1/0,-1/0]);return[Math.min(p[0],u[0]),Math.max(p[1],u[1])]},[1/0,-1/0])}return null},uut=function(e,r,n,s,i){var a=r.map(function(o){return yxe(e,o,n,i,s)}).filter(function(o){return!hr(o)});return a&&a.length?a.reduce(function(o,c){return[Math.min(o[0],c[0]),Math.max(o[1],c[1])]},[1/0,-1/0]):null},xxe=function(e,r,n,s,i){var a=r.map(function(c){var u=c.props.dataKey;return n==="number"&&u&&yxe(e,c,u,s)||S_(e,u,n,i)});if(n==="number")return a.reduce(function(c,u){return[Math.min(c[0],u[0]),Math.max(c[1],u[1])]},[1/0,-1/0]);var o={};return a.reduce(function(c,u){for(var d=0,h=u.length;d<h;d++)o[u[d]]||(o[u[d]]=!0,c.push(u[d]));return c},[])},vxe=function(e,r){return e==="horizontal"&&r==="xAxis"||e==="vertical"&&r==="yAxis"||e==="centric"&&r==="angleAxis"||e==="radial"&&r==="radiusAxis"},dS=function(e,r,n){if(!e)return null;var s=e.scale,i=e.duplicateDomain,a=e.type,o=e.range,c=e.realScaleType==="scaleBand"?s.bandwidth()/2:2,u=(r||n)&&a==="category"&&s.bandwidth?s.bandwidth()/c:0;if(u=e.axisType==="angleAxis"&&(o==null?void 0:o.length)>=2?pl(o[0]-o[1])*2*u:u,r&&(e.ticks||e.niceTicks)){var d=(e.ticks||e.niceTicks).map(function(h){var f=i?i.indexOf(h):h;return{coordinate:s(f)+u,value:h,offset:u}});return d.filter(function(h){return!PE(h.coordinate)})}return e.isCategorical&&e.categoricalDomain?e.categoricalDomain.map(function(h,f){return{coordinate:s(h)+u,value:h,index:f,offset:u}}):s.ticks&&!n?s.ticks(e.tickCount).map(function(h){return{coordinate:s(h)+u,value:h,offset:u}}):s.domain().map(function(h,f){return{coordinate:s(h)+u,value:i?i[h]:h,index:f,offset:u}})},k4=new WeakMap,eC=function(e,r){if(typeof r!="function")return e;k4.has(e)||k4.set(e,new WeakMap);var n=k4.get(e);if(n.has(r))return n.get(r);var s=function(){e.apply(void 0,arguments),r.apply(void 0,arguments)};return n.set(r,s),s},dut=function(e,r,n){var s=e.scale,i=e.type,a=e.layout,o=e.axisType;if(s==="auto")return a==="radial"&&o==="radiusAxis"?{scale:Ej(),realScaleType:"band"}:a==="radial"&&o==="angleAxis"?{scale:DP(),realScaleType:"linear"}:i==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:w_(),realScaleType:"point"}:i==="category"?{scale:Ej(),realScaleType:"band"}:{scale:DP(),realScaleType:"linear"};if(TE(s)){var c="scale".concat(aM(s));return{scale:(MZ[c]||w_)(),realScaleType:MZ[c]?c:"point"}}return Xt(s)?{scale:s}:{scale:w_(),realScaleType:"point"}},HZ=1e-4,hut=function(e){var r=e.domain();if(!(!r||r.length<=2)){var n=r.length,s=e.range(),i=Math.min(s[0],s[1])-HZ,a=Math.max(s[0],s[1])+HZ,o=e(r[0]),c=e(r[n-1]);(o<i||o>a||c<i||c>a)&&e.domain([r[0],r[n-1]])}},fut=function(e){var r=e.length;if(!(r<=0))for(var n=0,s=e[0].length;n<s;++n)for(var i=0,a=0,o=0;o<r;++o){var c=PE(e[o][n][1])?e[o][n][0]:e[o][n][1];c>=0?(e[o][n][0]=i,e[o][n][1]=i+c,i=e[o][n][1]):(e[o][n][0]=a,e[o][n][1]=a+c,a=e[o][n][1])}},put=function(e){var r=e.length;if(!(r<=0))for(var n=0,s=e[0].length;n<s;++n)for(var i=0,a=0;a<r;++a){var o=PE(e[a][n][1])?e[a][n][0]:e[a][n][1];o>=0?(e[a][n][0]=i,e[a][n][1]=i+o,i=e[a][n][1]):(e[a][n][0]=0,e[a][n][1]=0)}},mut={sign:fut,expand:PXe,none:J0,silhouette:OXe,wiggle:IXe,positive:put},gut=function(e,r,n){var s=r.map(function(o){return o.props.dataKey}),i=mut[n],a=TXe().keys(s).value(function(o,c){return+No(o,c,0)}).order(rB).offset(i);return a(e)},yut=function(e,r,n,s,i,a){if(!e)return null;var o=a?r.reverse():r,c={},u=o.reduce(function(h,f){var p,m=(p=f.type)!==null&&p!==void 0&&p.defaultProps?Bn(Bn({},f.type.defaultProps),f.props):f.props,g=m.stackId,x=m.hide;if(x)return h;var y=m[n],v=h[y]||{hasStack:!1,stackGroups:{}};if(Cs(g)){var b=v.stackGroups[g]||{numericAxisId:n,cateAxisId:s,items:[]};b.items.push(f),v.hasStack=!0,v.stackGroups[g]=b}else v.stackGroups[sM("_stackId_")]={numericAxisId:n,cateAxisId:s,items:[f]};return Bn(Bn({},h),{},cb({},y,v))},c),d={};return Object.keys(u).reduce(function(h,f){var p=u[f];if(p.hasStack){var m={};p.stackGroups=Object.keys(p.stackGroups).reduce(function(g,x){var y=p.stackGroups[x];return Bn(Bn({},g),{},cb({},x,{numericAxisId:n,cateAxisId:s,items:y.items,stackedData:gut(e,y.items,i)}))},m)}return Bn(Bn({},h),{},cb({},f,p))},d)},xut=function(e,r){var n=r.realScaleType,s=r.type,i=r.tickCount,a=r.originalDomain,o=r.allowDecimals,c=n||r.scale;if(c!=="auto"&&c!=="linear")return null;if(i&&s==="number"&&a&&(a[0]==="auto"||a[1]==="auto")){var u=e.domain();if(!u.length)return null;var d=Pct(u,i,o);return e.domain([wM(d),bM(d)]),{niceTicks:d}}if(i&&s==="number"){var h=e.domain(),f=Oct(h,i,o);return{niceTicks:f}}return null},vut=function(e,r){var n,s=(n=e.type)!==null&&n!==void 0&&n.defaultProps?Bn(Bn({},e.type.defaultProps),e.props):e.props,i=s.stackId;if(Cs(i)){var a=r[i];if(a){var o=a.items.indexOf(e);return o>=0?a.stackedData[o]:null}}return null},but=function(e){return e.reduce(function(r,n){return[wM(n.concat([r[0]]).filter(ut)),bM(n.concat([r[1]]).filter(ut))]},[1/0,-1/0])},bxe=function(e,r,n){return Object.keys(e).reduce(function(s,i){var a=e[i],o=a.stackedData,c=o.reduce(function(u,d){var h=but(d.slice(r,n+1));return[Math.min(u[0],h[0]),Math.max(u[1],h[1])]},[1/0,-1/0]);return[Math.min(c[0],s[0]),Math.max(c[1],s[1])]},[1/0,-1/0]).map(function(s){return s===1/0||s===-1/0?0:s})},VZ=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,WZ=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,OB=function(e,r,n){if(Xt(e))return e(r,n);if(!Array.isArray(e))return r;var s=[];if(ut(e[0]))s[0]=n?e[0]:Math.min(e[0],r[0]);else if(VZ.test(e[0])){var i=+VZ.exec(e[0])[1];s[0]=r[0]-i}else Xt(e[0])?s[0]=e[0](r[0]):s[0]=r[0];if(ut(e[1]))s[1]=n?e[1]:Math.max(e[1],r[1]);else if(WZ.test(e[1])){var a=+WZ.exec(e[1])[1];s[1]=r[1]+a}else Xt(e[1])?s[1]=e[1](r[1]):s[1]=r[1];return s},IB=function(e,r,n){if(e&&e.scale&&e.scale.bandwidth){var s=e.scale.bandwidth();if(!n||s>0)return s}if(e&&r&&r.length>=2){for(var i=YW(r,function(h){return h.coordinate}),a=1/0,o=1,c=i.length;o<c;o++){var u=i[o],d=i[o-1];a=Math.min((u.coordinate||0)-(d.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0},qZ=function(e,r,n){return!e||!e.length||v9(e,mc(n,"type.defaultProps.domain"))?r:e},wut=function(e,r){var n=e.type.defaultProps?Bn(Bn({},e.type.defaultProps),e.props):e.props,s=n.dataKey,i=n.name,a=n.unit,o=n.formatter,c=n.tooltipType,u=n.chartType,d=n.hide;return Bn(Bn({},Gt(e,!1)),{},{dataKey:s,unit:a,formatter:o,name:i||s,color:_9(e),value:No(r,s),type:c,payload:r,chartType:u,hide:d})};function Dj(t){"@babel/helpers - typeof";return Dj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dj(t)}function GZ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function ad(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?GZ(Object(r),!0).forEach(function(n){wxe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):GZ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function wxe(t,e,r){return e=Sut(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sut(t){var e=_ut(t,"string");return Dj(e)=="symbol"?e:e+""}function _ut(t,e){if(Dj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Dj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function jut(t,e){return Aut(t)||Eut(t,e)||Nut(t,e)||kut()}function kut(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nut(t,e){if(t){if(typeof t=="string")return KZ(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return KZ(t,e)}}function KZ(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Eut(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function Aut(t){if(Array.isArray(t))return t}var HP=Math.PI/180,Cut=function(e){return e*180/Math.PI},nn=function(e,r,n,s){return{x:e+Math.cos(-HP*s)*n,y:r+Math.sin(-HP*s)*n}},Sxe=function(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0};return Math.min(Math.abs(e-(n.left||0)-(n.right||0)),Math.abs(r-(n.top||0)-(n.bottom||0)))/2},Tut=function(e,r,n,s,i){var a=e.width,o=e.height,c=e.startAngle,u=e.endAngle,d=za(e.cx,a,a/2),h=za(e.cy,o,o/2),f=Sxe(a,o,n),p=za(e.innerRadius,f,0),m=za(e.outerRadius,f,f*.8),g=Object.keys(r);return g.reduce(function(x,y){var v=r[y],b=v.domain,w=v.reversed,S;if(hr(v.range))s==="angleAxis"?S=[c,u]:s==="radiusAxis"&&(S=[p,m]),w&&(S=[S[1],S[0]]);else{S=v.range;var k=S,E=jut(k,2);c=E[0],u=E[1]}var C=dut(v,i),A=C.realScaleType,M=C.scale;M.domain(b).range(S),hut(M);var z=xut(M,ad(ad({},v),{},{realScaleType:A})),P=ad(ad(ad({},v),z),{},{range:S,radius:m,realScaleType:A,scale:M,cx:d,cy:h,innerRadius:p,outerRadius:m,startAngle:c,endAngle:u});return ad(ad({},x),{},wxe({},y,P))},{})},Put=function(e,r){var n=e.x,s=e.y,i=r.x,a=r.y;return Math.sqrt(Math.pow(n-i,2)+Math.pow(s-a,2))},Out=function(e,r){var n=e.x,s=e.y,i=r.cx,a=r.cy,o=Put({x:n,y:s},{x:i,y:a});if(o<=0)return{radius:o};var c=(n-i)/o,u=Math.acos(c);return s>a&&(u=2*Math.PI-u),{radius:o,angle:Cut(u),angleInRadian:u}},Iut=function(e){var r=e.startAngle,n=e.endAngle,s=Math.floor(r/360),i=Math.floor(n/360),a=Math.min(s,i);return{startAngle:r-a*360,endAngle:n-a*360}},Rut=function(e,r){var n=r.startAngle,s=r.endAngle,i=Math.floor(n/360),a=Math.floor(s/360),o=Math.min(i,a);return e+o*360},YZ=function(e,r){var n=e.x,s=e.y,i=Out({x:n,y:s},r),a=i.radius,o=i.angle,c=r.innerRadius,u=r.outerRadius;if(a<c||a>u)return!1;if(a===0)return!0;var d=Iut(r),h=d.startAngle,f=d.endAngle,p=o,m;if(h<=f){for(;p>f;)p-=360;for(;p<h;)p+=360;m=p>=h&&p<=f}else{for(;p>h;)p-=360;for(;p<f;)p+=360;m=p>=f&&p<=h}return m?ad(ad({},r),{},{radius:a,angle:Rut(p,r)}):null},_xe=function(e){return!j.isValidElement(e)&&!Xt(e)&&typeof e!="boolean"?e.className:""};function Lj(t){"@babel/helpers - typeof";return Lj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Lj(t)}var Mut=["offset"];function Dut(t){return But(t)||$ut(t)||Fut(t)||Lut()}function Lut(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fut(t,e){if(t){if(typeof t=="string")return RB(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return RB(t,e)}}function $ut(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function But(t){if(Array.isArray(t))return RB(t)}function RB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function zut(t,e){if(t==null)return{};var r=Uut(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Uut(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function XZ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function xs(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?XZ(Object(r),!0).forEach(function(n){Hut(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):XZ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Hut(t,e,r){return e=Vut(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Vut(t){var e=Wut(t,"string");return Lj(e)=="symbol"?e:e+""}function Wut(t,e){if(Lj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Lj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Fj(){return Fj=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Fj.apply(this,arguments)}var qut=function(e){var r=e.value,n=e.formatter,s=hr(e.children)?r:e.children;return Xt(n)?n(s):s},Gut=function(e,r){var n=pl(r-e),s=Math.min(Math.abs(r-e),360);return n*s},Kut=function(e,r,n){var s=e.position,i=e.viewBox,a=e.offset,o=e.className,c=i,u=c.cx,d=c.cy,h=c.innerRadius,f=c.outerRadius,p=c.startAngle,m=c.endAngle,g=c.clockWise,x=(h+f)/2,y=Gut(p,m),v=y>=0?1:-1,b,w;s==="insideStart"?(b=p+v*a,w=g):s==="insideEnd"?(b=m-v*a,w=!g):s==="end"&&(b=m+v*a,w=g),w=y<=0?w:!w;var S=nn(u,d,x,b),k=nn(u,d,x,b+(w?1:-1)*359),E="M".concat(S.x,",").concat(S.y,`
A`).concat(x,",").concat(x,",0,1,").concat(w?0:1,`,
`).concat(k.x,",").concat(k.y),C=hr(e.id)?sM("recharts-radial-line-"):e.id;return pe.createElement("text",Fj({},n,{dominantBaseline:"central",className:mr("recharts-radial-bar-label",o)}),pe.createElement("defs",null,pe.createElement("path",{id:C,d:E})),pe.createElement("textPath",{xlinkHref:"#".concat(C)},r))},Yut=function(e){var r=e.viewBox,n=e.offset,s=e.position,i=r,a=i.cx,o=i.cy,c=i.innerRadius,u=i.outerRadius,d=i.startAngle,h=i.endAngle,f=(d+h)/2;if(s==="outside"){var p=nn(a,o,u+n,f),m=p.x,g=p.y;return{x:m,y:g,textAnchor:m>=a?"start":"end",verticalAnchor:"middle"}}if(s==="center")return{x:a,y:o,textAnchor:"middle",verticalAnchor:"middle"};if(s==="centerTop")return{x:a,y:o,textAnchor:"middle",verticalAnchor:"start"};if(s==="centerBottom")return{x:a,y:o,textAnchor:"middle",verticalAnchor:"end"};var x=(c+u)/2,y=nn(a,o,x,f),v=y.x,b=y.y;return{x:v,y:b,textAnchor:"middle",verticalAnchor:"middle"}},Xut=function(e){var r=e.viewBox,n=e.parentViewBox,s=e.offset,i=e.position,a=r,o=a.x,c=a.y,u=a.width,d=a.height,h=d>=0?1:-1,f=h*s,p=h>0?"end":"start",m=h>0?"start":"end",g=u>=0?1:-1,x=g*s,y=g>0?"end":"start",v=g>0?"start":"end";if(i==="top"){var b={x:o+u/2,y:c-h*s,textAnchor:"middle",verticalAnchor:p};return xs(xs({},b),n?{height:Math.max(c-n.y,0),width:u}:{})}if(i==="bottom"){var w={x:o+u/2,y:c+d+f,textAnchor:"middle",verticalAnchor:m};return xs(xs({},w),n?{height:Math.max(n.y+n.height-(c+d),0),width:u}:{})}if(i==="left"){var S={x:o-x,y:c+d/2,textAnchor:y,verticalAnchor:"middle"};return xs(xs({},S),n?{width:Math.max(S.x-n.x,0),height:d}:{})}if(i==="right"){var k={x:o+u+x,y:c+d/2,textAnchor:v,verticalAnchor:"middle"};return xs(xs({},k),n?{width:Math.max(n.x+n.width-k.x,0),height:d}:{})}var E=n?{width:u,height:d}:{};return i==="insideLeft"?xs({x:o+x,y:c+d/2,textAnchor:v,verticalAnchor:"middle"},E):i==="insideRight"?xs({x:o+u-x,y:c+d/2,textAnchor:y,verticalAnchor:"middle"},E):i==="insideTop"?xs({x:o+u/2,y:c+f,textAnchor:"middle",verticalAnchor:m},E):i==="insideBottom"?xs({x:o+u/2,y:c+d-f,textAnchor:"middle",verticalAnchor:p},E):i==="insideTopLeft"?xs({x:o+x,y:c+f,textAnchor:v,verticalAnchor:m},E):i==="insideTopRight"?xs({x:o+u-x,y:c+f,textAnchor:y,verticalAnchor:m},E):i==="insideBottomLeft"?xs({x:o+x,y:c+d-f,textAnchor:v,verticalAnchor:p},E):i==="insideBottomRight"?xs({x:o+u-x,y:c+d-f,textAnchor:y,verticalAnchor:p},E):r1(i)&&(ut(i.x)||tg(i.x))&&(ut(i.y)||tg(i.y))?xs({x:o+za(i.x,u),y:c+za(i.y,d),textAnchor:"end",verticalAnchor:"end"},E):xs({x:o+u/2,y:c+d/2,textAnchor:"middle",verticalAnchor:"middle"},E)},Jut=function(e){return"cx"in e&&ut(e.cx)};function fi(t){var e=t.offset,r=e===void 0?5:e,n=zut(t,Mut),s=xs({offset:r},n),i=s.viewBox,a=s.position,o=s.value,c=s.children,u=s.content,d=s.className,h=d===void 0?"":d,f=s.textBreakAll;if(!i||hr(o)&&hr(c)&&!j.isValidElement(u)&&!Xt(u))return null;if(j.isValidElement(u))return j.cloneElement(u,s);var p;if(Xt(u)){if(p=j.createElement(u,s),j.isValidElement(p))return p}else p=qut(s);var m=Jut(i),g=Gt(s,!0);if(m&&(a==="insideStart"||a==="insideEnd"||a==="end"))return Kut(s,p,g);var x=m?Yut(s):Xut(s);return pe.createElement(nw,Fj({className:mr("recharts-label",h)},g,x,{breakAll:f}),p)}fi.displayName="Label";var jxe=function(e){var r=e.cx,n=e.cy,s=e.angle,i=e.startAngle,a=e.endAngle,o=e.r,c=e.radius,u=e.innerRadius,d=e.outerRadius,h=e.x,f=e.y,p=e.top,m=e.left,g=e.width,x=e.height,y=e.clockWise,v=e.labelViewBox;if(v)return v;if(ut(g)&&ut(x)){if(ut(h)&&ut(f))return{x:h,y:f,width:g,height:x};if(ut(p)&&ut(m))return{x:p,y:m,width:g,height:x}}return ut(h)&&ut(f)?{x:h,y:f,width:0,height:0}:ut(r)&&ut(n)?{cx:r,cy:n,startAngle:i||s||0,endAngle:a||s||0,innerRadius:u||0,outerRadius:d||c||o||0,clockWise:y}:e.viewBox?e.viewBox:{}},Qut=function(e,r){return e?e===!0?pe.createElement(fi,{key:"label-implicit",viewBox:r}):Cs(e)?pe.createElement(fi,{key:"label-implicit",viewBox:r,value:e}):j.isValidElement(e)?e.type===fi?j.cloneElement(e,{key:"label-implicit",viewBox:r}):pe.createElement(fi,{key:"label-implicit",content:e,viewBox:r}):Xt(e)?pe.createElement(fi,{key:"label-implicit",content:e,viewBox:r}):r1(e)?pe.createElement(fi,Fj({viewBox:r},e,{key:"label-implicit"})):null:null},Zut=function(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&n&&!e.label)return null;var s=e.children,i=jxe(e),a=ju(s,fi).map(function(c,u){return j.cloneElement(c,{viewBox:r||i,key:"label-".concat(u)})});if(!n)return a;var o=Qut(e.label,r||i);return[o].concat(Dut(a))};fi.parseViewBox=jxe;fi.renderCallByParent=Zut;function edt(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}var tdt=edt;const rdt=cr(tdt);function $j(t){"@babel/helpers - typeof";return $j=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$j(t)}var ndt=["valueAccessor"],sdt=["data","dataKey","clockWise","id","textBreakAll"];function idt(t){return cdt(t)||ldt(t)||odt(t)||adt()}function adt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function odt(t,e){if(t){if(typeof t=="string")return MB(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return MB(t,e)}}function ldt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function cdt(t){if(Array.isArray(t))return MB(t)}function MB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function VP(){return VP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},VP.apply(this,arguments)}function JZ(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function QZ(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?JZ(Object(r),!0).forEach(function(n){udt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):JZ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function udt(t,e,r){return e=ddt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ddt(t){var e=hdt(t,"string");return $j(e)=="symbol"?e:e+""}function hdt(t,e){if($j(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if($j(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ZZ(t,e){if(t==null)return{};var r=fdt(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function fdt(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}var pdt=function(e){return Array.isArray(e.value)?rdt(e.value):e.value};function Ry(t){var e=t.valueAccessor,r=e===void 0?pdt:e,n=ZZ(t,ndt),s=n.data,i=n.dataKey,a=n.clockWise,o=n.id,c=n.textBreakAll,u=ZZ(n,sdt);return!s||!s.length?null:pe.createElement(Vn,{className:"recharts-label-list"},s.map(function(d,h){var f=hr(i)?r(d,h):No(d&&d.payload,i),p=hr(o)?{}:{id:"".concat(o,"-").concat(h)};return pe.createElement(fi,VP({},Gt(d,!0),u,p,{parentViewBox:d.parentViewBox,value:f,textBreakAll:c,viewBox:fi.parseViewBox(hr(a)?d:QZ(QZ({},d),{},{clockWise:a})),key:"label-".concat(h),index:h}))}))}Ry.displayName="LabelList";function mdt(t,e){return t?t===!0?pe.createElement(Ry,{key:"labelList-implicit",data:e}):pe.isValidElement(t)||Xt(t)?pe.createElement(Ry,{key:"labelList-implicit",data:e,content:t}):r1(t)?pe.createElement(Ry,VP({data:e},t,{key:"labelList-implicit"})):null:null}function gdt(t,e){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&r&&!t.label)return null;var n=t.children,s=ju(n,Ry).map(function(a,o){return j.cloneElement(a,{data:e,key:"labelList-".concat(o)})});if(!r)return s;var i=mdt(t.label,e);return[i].concat(idt(s))}Ry.renderCallByParent=gdt;function Bj(t){"@babel/helpers - typeof";return Bj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Bj(t)}function DB(){return DB=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},DB.apply(this,arguments)}function eee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function tee(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?eee(Object(r),!0).forEach(function(n){ydt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):eee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ydt(t,e,r){return e=xdt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function xdt(t){var e=vdt(t,"string");return Bj(e)=="symbol"?e:e+""}function vdt(t,e){if(Bj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Bj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var bdt=function(e,r){var n=pl(r-e),s=Math.min(Math.abs(r-e),359.999);return n*s},tC=function(e){var r=e.cx,n=e.cy,s=e.radius,i=e.angle,a=e.sign,o=e.isExternal,c=e.cornerRadius,u=e.cornerIsExternal,d=c*(o?1:-1)+s,h=Math.asin(c/d)/HP,f=u?i:i+a*h,p=nn(r,n,d,f),m=nn(r,n,s,f),g=u?i-a*h:i,x=nn(r,n,d*Math.cos(h*HP),g);return{center:p,circleTangency:m,lineTangency:x,theta:h}},kxe=function(e){var r=e.cx,n=e.cy,s=e.innerRadius,i=e.outerRadius,a=e.startAngle,o=e.endAngle,c=bdt(a,o),u=a+c,d=nn(r,n,i,a),h=nn(r,n,i,u),f="M ".concat(d.x,",").concat(d.y,`
A `).concat(i,",").concat(i,`,0,
`).concat(+(Math.abs(c)>180),",").concat(+(a>u),`,
`).concat(h.x,",").concat(h.y,`
`);if(s>0){var p=nn(r,n,s,a),m=nn(r,n,s,u);f+="L ".concat(m.x,",").concat(m.y,`
A `).concat(s,",").concat(s,`,0,
`).concat(+(Math.abs(c)>180),",").concat(+(a<=u),`,
`).concat(p.x,",").concat(p.y," Z")}else f+="L ".concat(r,",").concat(n," Z");return f},wdt=function(e){var r=e.cx,n=e.cy,s=e.innerRadius,i=e.outerRadius,a=e.cornerRadius,o=e.forceCornerRadius,c=e.cornerIsExternal,u=e.startAngle,d=e.endAngle,h=pl(d-u),f=tC({cx:r,cy:n,radius:i,angle:u,sign:h,cornerRadius:a,cornerIsExternal:c}),p=f.circleTangency,m=f.lineTangency,g=f.theta,x=tC({cx:r,cy:n,radius:i,angle:d,sign:-h,cornerRadius:a,cornerIsExternal:c}),y=x.circleTangency,v=x.lineTangency,b=x.theta,w=c?Math.abs(u-d):Math.abs(u-d)-g-b;if(w<0)return o?"M ".concat(m.x,",").concat(m.y,`
a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
`):kxe({cx:r,cy:n,innerRadius:s,outerRadius:i,startAngle:u,endAngle:d});var S="M ".concat(m.x,",").concat(m.y,`
A`).concat(a,",").concat(a,",0,0,").concat(+(h<0),",").concat(p.x,",").concat(p.y,`
A`).concat(i,",").concat(i,",0,").concat(+(w>180),",").concat(+(h<0),",").concat(y.x,",").concat(y.y,`
A`).concat(a,",").concat(a,",0,0,").concat(+(h<0),",").concat(v.x,",").concat(v.y,`
`);if(s>0){var k=tC({cx:r,cy:n,radius:s,angle:u,sign:h,isExternal:!0,cornerRadius:a,cornerIsExternal:c}),E=k.circleTangency,C=k.lineTangency,A=k.theta,M=tC({cx:r,cy:n,radius:s,angle:d,sign:-h,isExternal:!0,cornerRadius:a,cornerIsExternal:c}),z=M.circleTangency,P=M.lineTangency,W=M.theta,N=c?Math.abs(u-d):Math.abs(u-d)-A-W;if(N<0&&a===0)return"".concat(S,"L").concat(r,",").concat(n,"Z");S+="L".concat(P.x,",").concat(P.y,`
A`).concat(a,",").concat(a,",0,0,").concat(+(h<0),",").concat(z.x,",").concat(z.y,`
A`).concat(s,",").concat(s,",0,").concat(+(N>180),",").concat(+(h>0),",").concat(E.x,",").concat(E.y,`
A`).concat(a,",").concat(a,",0,0,").concat(+(h<0),",").concat(C.x,",").concat(C.y,"Z")}else S+="L".concat(r,",").concat(n,"Z");return S},Sdt={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Nxe=function(e){var r=tee(tee({},Sdt),e),n=r.cx,s=r.cy,i=r.innerRadius,a=r.outerRadius,o=r.cornerRadius,c=r.forceCornerRadius,u=r.cornerIsExternal,d=r.startAngle,h=r.endAngle,f=r.className;if(a<i||d===h)return null;var p=mr("recharts-sector",f),m=a-i,g=za(o,m,0,!0),x;return g>0&&Math.abs(d-h)<360?x=wdt({cx:n,cy:s,innerRadius:i,outerRadius:a,cornerRadius:Math.min(g,m/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:d,endAngle:h}):x=kxe({cx:n,cy:s,innerRadius:i,outerRadius:a,startAngle:d,endAngle:h}),pe.createElement("path",DB({},Gt(r,!0),{className:p,d:x,role:"img"}))};function zj(t){"@babel/helpers - typeof";return zj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},zj(t)}function LB(){return LB=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},LB.apply(this,arguments)}function ree(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function nee(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ree(Object(r),!0).forEach(function(n){_dt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ree(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function _dt(t,e,r){return e=jdt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jdt(t){var e=kdt(t,"string");return zj(e)=="symbol"?e:e+""}function kdt(t,e){if(zj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(zj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var see={curveBasisClosed:vXe,curveBasisOpen:bXe,curveBasis:xXe,curveBumpX:sXe,curveBumpY:iXe,curveLinearClosed:wXe,curveLinear:lM,curveMonotoneX:SXe,curveMonotoneY:_Xe,curveNatural:jXe,curveStep:kXe,curveStepAfter:EXe,curveStepBefore:NXe},rC=function(e){return e.x===+e.x&&e.y===+e.y},z1=function(e){return e.x},U1=function(e){return e.y},Ndt=function(e,r){if(Xt(e))return e;var n="curve".concat(aM(e));return(n==="curveMonotone"||n==="curveBump")&&r?see["".concat(n).concat(r==="vertical"?"Y":"X")]:see[n]||lM},Edt=function(e){var r=e.type,n=r===void 0?"linear":r,s=e.points,i=s===void 0?[]:s,a=e.baseLine,o=e.layout,c=e.connectNulls,u=c===void 0?!1:c,d=Ndt(n,o),h=u?i.filter(function(g){return rC(g)}):i,f;if(Array.isArray(a)){var p=u?a.filter(function(g){return rC(g)}):a,m=h.map(function(g,x){return nee(nee({},g),{},{base:p[x]})});return o==="vertical"?f=qA().y(U1).x1(z1).x0(function(g){return g.base.x}):f=qA().x(z1).y1(U1).y0(function(g){return g.base.y}),f.defined(rC).curve(d),f(m)}return o==="vertical"&&ut(a)?f=qA().y(U1).x1(z1).x0(a):ut(a)?f=qA().x(z1).y1(U1).y0(a):f=kge().x(z1).y(U1),f.defined(rC).curve(d),f(h)},FB=function(e){var r=e.className,n=e.points,s=e.path,i=e.pathRef;if((!n||!n.length)&&!s)return null;var a=n&&n.length?Edt(e):s;return j.createElement("path",LB({},Gt(e,!1),gP(e),{className:mr("recharts-curve",r),d:a,ref:i}))},Exe={exports:{}},Adt="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",Cdt=Adt,Tdt=Cdt;function Axe(){}function Cxe(){}Cxe.resetWarningCache=Axe;var Pdt=function(){function t(n,s,i,a,o,c){if(c!==Tdt){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}t.isRequired=t;function e(){return t}var r={array:t,bigint:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:Cxe,resetWarningCache:Axe};return r.PropTypes=r,r};Exe.exports=Pdt();var Odt=Exe.exports;const jr=cr(Odt),{getOwnPropertyNames:Idt,getOwnPropertySymbols:Rdt}=Object,{hasOwnProperty:Mdt}=Object.prototype;function N4(t,e){return function(n,s,i){return t(n,s,i)&&e(n,s,i)}}function nC(t){return function(r,n,s){if(!r||!n||typeof r!="object"||typeof n!="object")return t(r,n,s);const{cache:i}=s,a=i.get(r),o=i.get(n);if(a&&o)return a===n&&o===r;i.set(r,n),i.set(n,r);const c=t(r,n,s);return i.delete(r),i.delete(n),c}}function Ddt(t){return t!=null?t[Symbol.toStringTag]:void 0}function iee(t){return Idt(t).concat(Rdt(t))}const Ldt=Object.hasOwn||((t,e)=>Mdt.call(t,e));function Nx(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const Fdt="__v",$dt="__o",Bdt="_owner",{getOwnPropertyDescriptor:aee,keys:oee}=Object;function zdt(t,e){return t.byteLength===e.byteLength&&WP(new Uint8Array(t),new Uint8Array(e))}function Udt(t,e,r){let n=t.length;if(e.length!==n)return!1;for(;n-- >0;)if(!r.equals(t[n],e[n],n,n,t,e,r))return!1;return!0}function Hdt(t,e){return t.byteLength===e.byteLength&&WP(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Vdt(t,e){return Nx(t.getTime(),e.getTime())}function Wdt(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function qdt(t,e){return t===e}function lee(t,e,r){const n=t.size;if(n!==e.size)return!1;if(!n)return!0;const s=new Array(n),i=t.entries();let a,o,c=0;for(;(a=i.next())&&!a.done;){const u=e.entries();let d=!1,h=0;for(;(o=u.next())&&!o.done;){if(s[h]){h++;continue}const f=a.value,p=o.value;if(r.equals(f[0],p[0],c,h,t,e,r)&&r.equals(f[1],p[1],f[0],p[0],t,e,r)){d=s[h]=!0;break}h++}if(!d)return!1;c++}return!0}const Gdt=Nx;function Kdt(t,e,r){const n=oee(t);let s=n.length;if(oee(e).length!==s)return!1;for(;s-- >0;)if(!Txe(t,e,r,n[s]))return!1;return!0}function H1(t,e,r){const n=iee(t);let s=n.length;if(iee(e).length!==s)return!1;let i,a,o;for(;s-- >0;)if(i=n[s],!Txe(t,e,r,i)||(a=aee(t,i),o=aee(e,i),(a||o)&&(!a||!o||a.configurable!==o.configurable||a.enumerable!==o.enumerable||a.writable!==o.writable)))return!1;return!0}function Ydt(t,e){return Nx(t.valueOf(),e.valueOf())}function Xdt(t,e){return t.source===e.source&&t.flags===e.flags}function cee(t,e,r){const n=t.size;if(n!==e.size)return!1;if(!n)return!0;const s=new Array(n),i=t.values();let a,o;for(;(a=i.next())&&!a.done;){const c=e.values();let u=!1,d=0;for(;(o=c.next())&&!o.done;){if(!s[d]&&r.equals(a.value,o.value,a.value,o.value,t,e,r)){u=s[d]=!0;break}d++}if(!u)return!1}return!0}function WP(t,e){let r=t.byteLength;if(e.byteLength!==r||t.byteOffset!==e.byteOffset)return!1;for(;r-- >0;)if(t[r]!==e[r])return!1;return!0}function Jdt(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 Txe(t,e,r,n){return(n===Bdt||n===$dt||n===Fdt)&&(t.$$typeof||e.$$typeof)?!0:Ldt(e,n)&&r.equals(t[n],e[n],n,n,t,e,r)}const Qdt="[object ArrayBuffer]",Zdt="[object Arguments]",eht="[object Boolean]",tht="[object DataView]",rht="[object Date]",nht="[object Error]",sht="[object Map]",iht="[object Number]",aht="[object Object]",oht="[object RegExp]",lht="[object Set]",cht="[object String]",uht={"[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},dht="[object URL]",hht=Object.prototype.toString;function fht({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:a,areNumbersEqual:o,areObjectsEqual:c,arePrimitiveWrappersEqual:u,areRegExpsEqual:d,areSetsEqual:h,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(x,y,v){if(x===y)return!0;if(x==null||y==null)return!1;const b=typeof x;if(b!==typeof y)return!1;if(b!=="object")return b==="number"?o(x,y,v):b==="function"?i(x,y,v):!1;const w=x.constructor;if(w!==y.constructor)return!1;if(w===Object)return c(x,y,v);if(Array.isArray(x))return e(x,y,v);if(w===Date)return n(x,y,v);if(w===RegExp)return d(x,y,v);if(w===Map)return a(x,y,v);if(w===Set)return h(x,y,v);const S=hht.call(x);if(S===rht)return n(x,y,v);if(S===oht)return d(x,y,v);if(S===sht)return a(x,y,v);if(S===lht)return h(x,y,v);if(S===aht)return typeof x.then!="function"&&typeof y.then!="function"&&c(x,y,v);if(S===dht)return p(x,y,v);if(S===nht)return s(x,y,v);if(S===Zdt)return c(x,y,v);if(uht[S])return f(x,y,v);if(S===Qdt)return t(x,y,v);if(S===tht)return r(x,y,v);if(S===eht||S===iht||S===cht)return u(x,y,v);if(m){let k=m[S];if(!k){const E=Ddt(x);E&&(k=m[E])}if(k)return k(x,y,v)}return!1}}function pht({circular:t,createCustomConfig:e,strict:r}){let n={areArrayBuffersEqual:zdt,areArraysEqual:r?H1:Udt,areDataViewsEqual:Hdt,areDatesEqual:Vdt,areErrorsEqual:Wdt,areFunctionsEqual:qdt,areMapsEqual:r?N4(lee,H1):lee,areNumbersEqual:Gdt,areObjectsEqual:r?H1:Kdt,arePrimitiveWrappersEqual:Ydt,areRegExpsEqual:Xdt,areSetsEqual:r?N4(cee,H1):cee,areTypedArraysEqual:r?N4(WP,H1):WP,areUrlsEqual:Jdt,unknownTagComparators:void 0};if(e&&(n=Object.assign({},n,e(n))),t){const s=nC(n.areArraysEqual),i=nC(n.areMapsEqual),a=nC(n.areObjectsEqual),o=nC(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:a,areSetsEqual:o})}return n}function mht(t){return function(e,r,n,s,i,a,o){return t(e,r,o)}}function ght({circular:t,comparator:e,createState:r,equals:n,strict:s}){if(r)return function(o,c){const{cache:u=t?new WeakMap:void 0,meta:d}=r();return e(o,c,{cache:u,equals:n,meta:d,strict:s})};if(t)return function(o,c){return e(o,c,{cache:new WeakMap,equals:n,meta:void 0,strict:s})};const i={cache:void 0,equals:n,meta:void 0,strict:s};return function(o,c){return e(o,c,i)}}const Pxe=hm();hm({strict:!0});hm({circular:!0});hm({circular:!0,strict:!0});hm({createInternalComparator:()=>Nx});hm({strict:!0,createInternalComparator:()=>Nx});hm({circular:!0,createInternalComparator:()=>Nx});hm({circular:!0,createInternalComparator:()=>Nx,strict:!0});function hm(t={}){const{circular:e=!1,createInternalComparator:r,createState:n,strict:s=!1}=t,i=pht(t),a=fht(i),o=r?r(a):mht(a);return ght({circular:e,comparator:a,createState:n,equals:o,strict:s})}function yht(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function uee(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,n=function s(i){r<0&&(r=i),i-r>e?(t(i),r=-1):yht(s)};requestAnimationFrame(n)}function $B(t){"@babel/helpers - typeof";return $B=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$B(t)}function xht(t){return Sht(t)||wht(t)||bht(t)||vht()}function vht(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function bht(t,e){if(t){if(typeof t=="string")return dee(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return dee(t,e)}}function dee(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function wht(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Sht(t){if(Array.isArray(t))return t}function _ht(){var t={},e=function(){return null},r=!1,n=function s(i){if(!r){if(Array.isArray(i)){if(!i.length)return;var a=i,o=xht(a),c=o[0],u=o.slice(1);if(typeof c=="number"){uee(s.bind(null,u),c);return}s(c),uee(s.bind(null,u));return}$B(i)==="object"&&(t=i,e(t)),typeof i=="function"&&i()}};return{stop:function(){r=!0},start:function(i){r=!1,n(i)},subscribe:function(i){return e=i,function(){e=function(){return null}}}}}function Uj(t){"@babel/helpers - typeof";return Uj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Uj(t)}function hee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function fee(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?hee(Object(r),!0).forEach(function(n){Oxe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):hee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Oxe(t,e,r){return e=jht(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jht(t){var e=kht(t,"string");return Uj(e)==="symbol"?e:String(e)}function kht(t,e){if(Uj(t)!=="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Uj(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Nht=function(e,r){return[Object.keys(e),Object.keys(r)].reduce(function(n,s){return n.filter(function(i){return s.includes(i)})})},Eht=function(e){return e},Aht=function(e){return e.replace(/([A-Z])/g,function(r){return"-".concat(r.toLowerCase())})},__=function(e,r){return Object.keys(r).reduce(function(n,s){return fee(fee({},n),{},Oxe({},s,e(s,r[s])))},{})},pee=function(e,r,n){return e.map(function(s){return"".concat(Aht(s)," ").concat(r,"ms ").concat(n)}).join(",")};function Cht(t,e){return Oht(t)||Pht(t,e)||Ixe(t,e)||Tht()}function Tht(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pht(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function Oht(t){if(Array.isArray(t))return t}function Iht(t){return Dht(t)||Mht(t)||Ixe(t)||Rht()}function Rht(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ixe(t,e){if(t){if(typeof t=="string")return BB(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return BB(t,e)}}function Mht(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Dht(t){if(Array.isArray(t))return BB(t)}function BB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var qP=1e-4,Rxe=function(e,r){return[0,3*e,3*r-6*e,3*e-3*r+1]},Mxe=function(e,r){return e.map(function(n,s){return n*Math.pow(r,s)}).reduce(function(n,s){return n+s})},mee=function(e,r){return function(n){var s=Rxe(e,r);return Mxe(s,n)}},Lht=function(e,r){return function(n){var s=Rxe(e,r),i=[].concat(Iht(s.map(function(a,o){return a*o}).slice(1)),[0]);return Mxe(i,n)}},gee=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var s=r[0],i=r[1],a=r[2],o=r[3];if(r.length===1)switch(r[0]){case"linear":s=0,i=0,a=1,o=1;break;case"ease":s=.25,i=.1,a=.25,o=1;break;case"ease-in":s=.42,i=0,a=1,o=1;break;case"ease-out":s=.42,i=0,a=.58,o=1;break;case"ease-in-out":s=0,i=0,a=.58,o=1;break;default:{var c=r[0].split("(");if(c[0]==="cubic-bezier"&&c[1].split(")")[0].split(",").length===4){var u=c[1].split(")")[0].split(",").map(function(x){return parseFloat(x)}),d=Cht(u,4);s=d[0],i=d[1],a=d[2],o=d[3]}}}var h=mee(s,a),f=mee(i,o),p=Lht(s,a),m=function(y){return y>1?1:y<0?0:y},g=function(y){for(var v=y>1?1:y,b=v,w=0;w<8;++w){var S=h(b)-v,k=p(b);if(Math.abs(S-v)<qP||k<qP)return f(b);b=m(b-S/k)}return f(b)};return g.isStepper=!1,g},Fht=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=e.stiff,n=r===void 0?100:r,s=e.damping,i=s===void 0?8:s,a=e.dt,o=a===void 0?17:a,c=function(d,h,f){var p=-(d-h)*n,m=f*i,g=f+(p-m)*o/1e3,x=f*o/1e3+d;return Math.abs(x-h)<qP&&Math.abs(g)<qP?[h,0]:[x,g]};return c.isStepper=!0,c.dt=o,c},$ht=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];var s=r[0];if(typeof s=="string")switch(s){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return gee(s);case"spring":return Fht();default:if(s.split("(")[0]==="cubic-bezier")return gee(s)}return typeof s=="function"?s:null};function Hj(t){"@babel/helpers - typeof";return Hj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Hj(t)}function yee(t){return Uht(t)||zht(t)||Dxe(t)||Bht()}function Bht(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zht(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Uht(t){if(Array.isArray(t))return UB(t)}function xee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function oi(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?xee(Object(r),!0).forEach(function(n){zB(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):xee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function zB(t,e,r){return e=Hht(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Hht(t){var e=Vht(t,"string");return Hj(e)==="symbol"?e:String(e)}function Vht(t,e){if(Hj(t)!=="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Hj(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Wht(t,e){return Kht(t)||Ght(t,e)||Dxe(t,e)||qht()}function qht(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Dxe(t,e){if(t){if(typeof t=="string")return UB(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return UB(t,e)}}function UB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Ght(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function Kht(t){if(Array.isArray(t))return t}var GP=function(e,r,n){return e+(r-e)*n},HB=function(e){var r=e.from,n=e.to;return r!==n},Yht=function t(e,r,n){var s=__(function(i,a){if(HB(a)){var o=e(a.from,a.to,a.velocity),c=Wht(o,2),u=c[0],d=c[1];return oi(oi({},a),{},{from:u,velocity:d})}return a},r);return n<1?__(function(i,a){return HB(a)?oi(oi({},a),{},{velocity:GP(a.velocity,s[i].velocity,n),from:GP(a.from,s[i].from,n)}):a},r):t(e,s,n-1)};const Xht=function(t,e,r,n,s){var i=Nht(t,e),a=i.reduce(function(x,y){return oi(oi({},x),{},zB({},y,[t[y],e[y]]))},{}),o=i.reduce(function(x,y){return oi(oi({},x),{},zB({},y,{from:t[y],velocity:0,to:e[y]}))},{}),c=-1,u,d,h=function(){return null},f=function(){return __(function(y,v){return v.from},o)},p=function(){return!Object.values(o).filter(HB).length},m=function(y){u||(u=y);var v=y-u,b=v/r.dt;o=Yht(r,o,b),s(oi(oi(oi({},t),e),f())),u=y,p()||(c=requestAnimationFrame(h))},g=function(y){d||(d=y);var v=(y-d)/n,b=__(function(S,k){return GP.apply(void 0,yee(k).concat([r(v)]))},a);if(s(oi(oi(oi({},t),e),b)),v<1)c=requestAnimationFrame(h);else{var w=__(function(S,k){return GP.apply(void 0,yee(k).concat([r(1)]))},a);s(oi(oi(oi({},t),e),w))}};return h=r.isStepper?m:g,function(){return requestAnimationFrame(h),function(){cancelAnimationFrame(c)}}};function cw(t){"@babel/helpers - typeof";return cw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},cw(t)}var Jht=["children","begin","duration","attributeName","easing","isActive","steps","from","to","canBegin","onAnimationEnd","shouldReAnimate","onAnimationReStart"];function Qht(t,e){if(t==null)return{};var r=Zht(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Zht(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,i;for(i=0;i<n.length;i++)s=n[i],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function E4(t){return nft(t)||rft(t)||tft(t)||eft()}function eft(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tft(t,e){if(t){if(typeof t=="string")return VB(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return VB(t,e)}}function rft(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function nft(t){if(Array.isArray(t))return VB(t)}function VB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function vee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Dl(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?vee(Object(r),!0).forEach(function(n){hS(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):vee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function hS(t,e,r){return e=Lxe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function sft(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ift(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Lxe(n.key),n)}}function aft(t,e,r){return e&&ift(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Lxe(t){var e=oft(t,"string");return cw(e)==="symbol"?e:String(e)}function oft(t,e){if(cw(t)!=="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(cw(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function lft(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&WB(t,e)}function WB(t,e){return WB=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},WB(t,e)}function cft(t){var e=uft();return function(){var n=KP(t),s;if(e){var i=KP(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return qB(this,s)}}function qB(t,e){if(e&&(cw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return GB(t)}function GB(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function uft(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function KP(t){return KP=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},KP(t)}var Wp=function(t){lft(r,t);var e=cft(r);function r(n,s){var i;sft(this,r),i=e.call(this,n,s);var a=i.props,o=a.isActive,c=a.attributeName,u=a.from,d=a.to,h=a.steps,f=a.children,p=a.duration;if(i.handleStyleChange=i.handleStyleChange.bind(GB(i)),i.changeStyle=i.changeStyle.bind(GB(i)),!o||p<=0)return i.state={style:{}},typeof f=="function"&&(i.state={style:d}),qB(i);if(h&&h.length)i.state={style:h[0].style};else if(u){if(typeof f=="function")return i.state={style:u},qB(i);i.state={style:c?hS({},c,u):u}}else i.state={style:{}};return i}return aft(r,[{key:"componentDidMount",value:function(){var s=this.props,i=s.isActive,a=s.canBegin;this.mounted=!0,!(!i||!a)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(s){var i=this.props,a=i.isActive,o=i.canBegin,c=i.attributeName,u=i.shouldReAnimate,d=i.to,h=i.from,f=this.state.style;if(o){if(!a){var p={style:c?hS({},c,d):d};this.state&&f&&(c&&f[c]!==d||!c&&f!==d)&&this.setState(p);return}if(!(Pxe(s.to,d)&&s.canBegin&&s.isActive)){var m=!s.canBegin||!s.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var g=m||u?h:s.to;if(this.state&&f){var x={style:c?hS({},c,g):g};(c&&f[c]!==g||!c&&f!==g)&&this.setState(x)}this.runAnimation(Dl(Dl({},this.props),{},{from:g,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var s=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),s&&s()}},{key:"handleStyleChange",value:function(s){this.changeStyle(s)}},{key:"changeStyle",value:function(s){this.mounted&&this.setState({style:s})}},{key:"runJSAnimation",value:function(s){var i=this,a=s.from,o=s.to,c=s.duration,u=s.easing,d=s.begin,h=s.onAnimationEnd,f=s.onAnimationStart,p=Xht(a,o,$ht(u),c,this.changeStyle),m=function(){i.stopJSAnimation=p()};this.manager.start([f,d,m,c,h])}},{key:"runStepAnimation",value:function(s){var i=this,a=s.steps,o=s.begin,c=s.onAnimationStart,u=a[0],d=u.style,h=u.duration,f=h===void 0?0:h,p=function(g,x,y){if(y===0)return g;var v=x.duration,b=x.easing,w=b===void 0?"ease":b,S=x.style,k=x.properties,E=x.onAnimationEnd,C=y>0?a[y-1]:x,A=k||Object.keys(S);if(typeof w=="function"||w==="spring")return[].concat(E4(g),[i.runJSAnimation.bind(i,{from:C.style,to:S,duration:v,easing:w}),v]);var M=pee(A,v,w),z=Dl(Dl(Dl({},C.style),S),{},{transition:M});return[].concat(E4(g),[z,v,E]).filter(Eht)};return this.manager.start([c].concat(E4(a.reduce(p,[d,Math.max(f,o)])),[s.onAnimationEnd]))}},{key:"runAnimation",value:function(s){this.manager||(this.manager=_ht());var i=s.begin,a=s.duration,o=s.attributeName,c=s.to,u=s.easing,d=s.onAnimationStart,h=s.onAnimationEnd,f=s.steps,p=s.children,m=this.manager;if(this.unSubscribe=m.subscribe(this.handleStyleChange),typeof u=="function"||typeof p=="function"||u==="spring"){this.runJSAnimation(s);return}if(f.length>1){this.runStepAnimation(s);return}var g=o?hS({},o,c):c,x=pee(Object.keys(g),a,u);m.start([d,i,Dl(Dl({},g),{},{transition:x}),a,h])}},{key:"render",value:function(){var s=this.props,i=s.children;s.begin;var a=s.duration;s.attributeName,s.easing;var o=s.isActive;s.steps,s.from,s.to,s.canBegin,s.onAnimationEnd,s.shouldReAnimate,s.onAnimationReStart;var c=Qht(s,Jht),u=j.Children.count(i),d=this.state.style;if(typeof i=="function")return i(d);if(!o||u===0||a<=0)return i;var h=function(p){var m=p.props,g=m.style,x=g===void 0?{}:g,y=m.className,v=j.cloneElement(p,Dl(Dl({},c),{},{style:Dl(Dl({},x),d),className:y}));return v};return u===1?h(j.Children.only(i)):pe.createElement("div",null,j.Children.map(i,function(f){return h(f)}))}}]),r}(j.PureComponent);Wp.displayName="Animate";Wp.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};Wp.propTypes={from:jr.oneOfType([jr.object,jr.string]),to:jr.oneOfType([jr.object,jr.string]),attributeName:jr.string,duration:jr.number,begin:jr.number,easing:jr.oneOfType([jr.string,jr.func]),steps:jr.arrayOf(jr.shape({duration:jr.number.isRequired,style:jr.object.isRequired,easing:jr.oneOfType([jr.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),jr.func]),properties:jr.arrayOf("string"),onAnimationEnd:jr.func})),children:jr.oneOfType([jr.node,jr.func]),isActive:jr.bool,canBegin:jr.bool,onAnimationEnd:jr.func,shouldReAnimate:jr.bool,onAnimationStart:jr.func,onAnimationReStart:jr.func};function Vj(t){"@babel/helpers - typeof";return Vj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vj(t)}function YP(){return YP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},YP.apply(this,arguments)}function dft(t,e){return mft(t)||pft(t,e)||fft(t,e)||hft()}function hft(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fft(t,e){if(t){if(typeof t=="string")return bee(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return bee(t,e)}}function bee(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function pft(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function mft(t){if(Array.isArray(t))return t}function wee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function See(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?wee(Object(r),!0).forEach(function(n){gft(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):wee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function gft(t,e,r){return e=yft(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function yft(t){var e=xft(t,"string");return Vj(e)=="symbol"?e:e+""}function xft(t,e){if(Vj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Vj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var _ee=function(e,r,n,s,i){var a=Math.min(Math.abs(n)/2,Math.abs(s)/2),o=s>=0?1:-1,c=n>=0?1:-1,u=s>=0&&n>=0||s<0&&n<0?1:0,d;if(a>0&&i instanceof Array){for(var h=[0,0,0,0],f=0,p=4;f<p;f++)h[f]=i[f]>a?a:i[f];d="M".concat(e,",").concat(r+o*h[0]),h[0]>0&&(d+="A ".concat(h[0],",").concat(h[0],",0,0,").concat(u,",").concat(e+c*h[0],",").concat(r)),d+="L ".concat(e+n-c*h[1],",").concat(r),h[1]>0&&(d+="A ".concat(h[1],",").concat(h[1],",0,0,").concat(u,`,
`).concat(e+n,",").concat(r+o*h[1])),d+="L ".concat(e+n,",").concat(r+s-o*h[2]),h[2]>0&&(d+="A ".concat(h[2],",").concat(h[2],",0,0,").concat(u,`,
`).concat(e+n-c*h[2],",").concat(r+s)),d+="L ".concat(e+c*h[3],",").concat(r+s),h[3]>0&&(d+="A ".concat(h[3],",").concat(h[3],",0,0,").concat(u,`,
`).concat(e,",").concat(r+s-o*h[3])),d+="Z"}else if(a>0&&i===+i&&i>0){var m=Math.min(a,i);d="M ".concat(e,",").concat(r+o*m,`
A `).concat(m,",").concat(m,",0,0,").concat(u,",").concat(e+c*m,",").concat(r,`
L `).concat(e+n-c*m,",").concat(r,`
A `).concat(m,",").concat(m,",0,0,").concat(u,",").concat(e+n,",").concat(r+o*m,`
L `).concat(e+n,",").concat(r+s-o*m,`
A `).concat(m,",").concat(m,",0,0,").concat(u,",").concat(e+n-c*m,",").concat(r+s,`
L `).concat(e+c*m,",").concat(r+s,`
A `).concat(m,",").concat(m,",0,0,").concat(u,",").concat(e,",").concat(r+s-o*m," Z")}else d="M ".concat(e,",").concat(r," h ").concat(n," v ").concat(s," h ").concat(-n," Z");return d},vft=function(e,r){if(!e||!r)return!1;var n=e.x,s=e.y,i=r.x,a=r.y,o=r.width,c=r.height;if(Math.abs(o)>0&&Math.abs(c)>0){var u=Math.min(i,i+o),d=Math.max(i,i+o),h=Math.min(a,a+c),f=Math.max(a,a+c);return n>=u&&n<=d&&s>=h&&s<=f}return!1},bft={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},j9=function(e){var r=See(See({},bft),e),n=j.useRef(),s=j.useState(-1),i=dft(s,2),a=i[0],o=i[1];j.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var w=n.current.getTotalLength();w&&o(w)}catch{}},[]);var c=r.x,u=r.y,d=r.width,h=r.height,f=r.radius,p=r.className,m=r.animationEasing,g=r.animationDuration,x=r.animationBegin,y=r.isAnimationActive,v=r.isUpdateAnimationActive;if(c!==+c||u!==+u||d!==+d||h!==+h||d===0||h===0)return null;var b=mr("recharts-rectangle",p);return v?pe.createElement(Wp,{canBegin:a>0,from:{width:d,height:h,x:c,y:u},to:{width:d,height:h,x:c,y:u},duration:g,animationEasing:m,isActive:v},function(w){var S=w.width,k=w.height,E=w.x,C=w.y;return pe.createElement(Wp,{canBegin:a>0,from:"0px ".concat(a===-1?1:a,"px"),to:"".concat(a,"px 0px"),attributeName:"strokeDasharray",begin:x,duration:g,isActive:y,easing:m},pe.createElement("path",YP({},Gt(r,!0),{className:b,d:_ee(E,C,S,k,f),ref:n})))}):pe.createElement("path",YP({},Gt(r,!0),{className:b,d:_ee(c,u,d,h,f)}))},wft=["points","className","baseLinePoints","connectNulls"];function Fv(){return Fv=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Fv.apply(this,arguments)}function Sft(t,e){if(t==null)return{};var r=_ft(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _ft(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function jee(t){return Eft(t)||Nft(t)||kft(t)||jft()}function jft(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kft(t,e){if(t){if(typeof t=="string")return KB(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return KB(t,e)}}function Nft(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Eft(t){if(Array.isArray(t))return KB(t)}function KB(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var kee=function(e){return e&&e.x===+e.x&&e.y===+e.y},Aft=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return e.forEach(function(n){kee(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),kee(e[0])&&r[r.length-1].push(e[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},j_=function(e,r){var n=Aft(e);r&&(n=[n.reduce(function(i,a){return[].concat(jee(i),jee(a))},[])]);var s=n.map(function(i){return i.reduce(function(a,o,c){return"".concat(a).concat(c===0?"M":"L").concat(o.x,",").concat(o.y)},"")}).join("");return n.length===1?"".concat(s,"Z"):s},Cft=function(e,r,n){var s=j_(e,n);return"".concat(s.slice(-1)==="Z"?s.slice(0,-1):s,"L").concat(j_(r.reverse(),n).slice(1))},Tft=function(e){var r=e.points,n=e.className,s=e.baseLinePoints,i=e.connectNulls,a=Sft(e,wft);if(!r||!r.length)return null;var o=mr("recharts-polygon",n);if(s&&s.length){var c=a.stroke&&a.stroke!=="none",u=Cft(r,s,i);return pe.createElement("g",{className:o},pe.createElement("path",Fv({},Gt(a,!0),{fill:u.slice(-1)==="Z"?a.fill:"none",stroke:"none",d:u})),c?pe.createElement("path",Fv({},Gt(a,!0),{fill:"none",d:j_(r,i)})):null,c?pe.createElement("path",Fv({},Gt(a,!0),{fill:"none",d:j_(s,i)})):null)}var d=j_(r,i);return pe.createElement("path",Fv({},Gt(a,!0),{fill:d.slice(-1)==="Z"?a.fill:"none",className:o,d}))};function YB(){return YB=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},YB.apply(this,arguments)}var k9=function(e){var r=e.cx,n=e.cy,s=e.r,i=e.className,a=mr("recharts-dot",i);return r===+r&&n===+n&&s===+s?j.createElement("circle",YB({},Gt(e,!1),gP(e),{className:a,cx:r,cy:n,r:s})):null};function Wj(t){"@babel/helpers - typeof";return Wj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Wj(t)}var Pft=["x","y","top","left","width","height","className"];function XB(){return XB=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},XB.apply(this,arguments)}function Nee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Oft(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Nee(Object(r),!0).forEach(function(n){Ift(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Nee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ift(t,e,r){return e=Rft(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Rft(t){var e=Mft(t,"string");return Wj(e)=="symbol"?e:e+""}function Mft(t,e){if(Wj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Wj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Dft(t,e){if(t==null)return{};var r=Lft(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Lft(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}var Fft=function(e,r,n,s,i,a){return"M".concat(e,",").concat(i,"v").concat(s,"M").concat(a,",").concat(r,"h").concat(n)},$ft=function(e){var r=e.x,n=r===void 0?0:r,s=e.y,i=s===void 0?0:s,a=e.top,o=a===void 0?0:a,c=e.left,u=c===void 0?0:c,d=e.width,h=d===void 0?0:d,f=e.height,p=f===void 0?0:f,m=e.className,g=Dft(e,Pft),x=Oft({x:n,y:i,top:o,left:u,width:h,height:p},g);return!ut(n)||!ut(i)||!ut(h)||!ut(p)||!ut(o)||!ut(u)?null:pe.createElement("path",XB({},Gt(x,!0),{className:mr("recharts-cross",m),d:Fft(n,i,h,p,o,u)}))},Bft=vM,zft=Zye,Uft=cm;function Hft(t,e){return t&&t.length?Bft(t,Uft(e),zft):void 0}var Vft=Hft;const Wft=cr(Vft);var qft=vM,Gft=cm,Kft=exe;function Yft(t,e){return t&&t.length?qft(t,Gft(e),Kft):void 0}var Xft=Yft;const Jft=cr(Xft);var Qft=["cx","cy","angle","ticks","axisLine"],Zft=["ticks","tick","angle","tickFormatter","stroke"];function uw(t){"@babel/helpers - typeof";return uw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},uw(t)}function k_(){return k_=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},k_.apply(this,arguments)}function Eee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function km(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Eee(Object(r),!0).forEach(function(n){jM(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Eee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Aee(t,e){if(t==null)return{};var r=ept(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function ept(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function tpt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Cee(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,$xe(n.key),n)}}function rpt(t,e,r){return e&&Cee(t.prototype,e),r&&Cee(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function npt(t,e,r){return e=XP(e),spt(t,Fxe()?Reflect.construct(e,r||[],XP(t).constructor):e.apply(t,r))}function spt(t,e){if(e&&(uw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ipt(t)}function ipt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Fxe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Fxe=function(){return!!t})()}function XP(t){return XP=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},XP(t)}function apt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&JB(t,e)}function JB(t,e){return JB=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},JB(t,e)}function jM(t,e,r){return e=$xe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $xe(t){var e=opt(t,"string");return uw(e)=="symbol"?e:e+""}function opt(t,e){if(uw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(uw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var kM=function(t){function e(){return tpt(this,e),npt(this,e,arguments)}return apt(e,t),rpt(e,[{key:"getTickValueCoord",value:function(n){var s=n.coordinate,i=this.props,a=i.angle,o=i.cx,c=i.cy;return nn(o,c,s,a)}},{key:"getTickTextAnchor",value:function(){var n=this.props.orientation,s;switch(n){case"left":s="end";break;case"right":s="start";break;default:s="middle";break}return s}},{key:"getViewBox",value:function(){var n=this.props,s=n.cx,i=n.cy,a=n.angle,o=n.ticks,c=Wft(o,function(d){return d.coordinate||0}),u=Jft(o,function(d){return d.coordinate||0});return{cx:s,cy:i,startAngle:a,endAngle:a,innerRadius:u.coordinate||0,outerRadius:c.coordinate||0}}},{key:"renderAxisLine",value:function(){var n=this.props,s=n.cx,i=n.cy,a=n.angle,o=n.ticks,c=n.axisLine,u=Aee(n,Qft),d=o.reduce(function(m,g){return[Math.min(m[0],g.coordinate),Math.max(m[1],g.coordinate)]},[1/0,-1/0]),h=nn(s,i,d[0],a),f=nn(s,i,d[1],a),p=km(km(km({},Gt(u,!1)),{},{fill:"none"},Gt(c,!1)),{},{x1:h.x,y1:h.y,x2:f.x,y2:f.y});return pe.createElement("line",k_({className:"recharts-polar-radius-axis-line"},p))}},{key:"renderTicks",value:function(){var n=this,s=this.props,i=s.ticks,a=s.tick,o=s.angle,c=s.tickFormatter,u=s.stroke,d=Aee(s,Zft),h=this.getTickTextAnchor(),f=Gt(d,!1),p=Gt(a,!1),m=i.map(function(g,x){var y=n.getTickValueCoord(g),v=km(km(km(km({textAnchor:h,transform:"rotate(".concat(90-o,", ").concat(y.x,", ").concat(y.y,")")},f),{},{stroke:"none",fill:u},p),{},{index:x},y),{},{payload:g});return pe.createElement(Vn,k_({className:mr("recharts-polar-radius-axis-tick",_xe(a)),key:"tick-".concat(g.coordinate)},iM(n.props,g,x)),e.renderTickItem(a,v,c?c(g.value,x):g.value))});return pe.createElement(Vn,{className:"recharts-polar-radius-axis-ticks"},m)}},{key:"render",value:function(){var n=this.props,s=n.ticks,i=n.axisLine,a=n.tick;return!s||!s.length?null:pe.createElement(Vn,{className:mr("recharts-polar-radius-axis",this.props.className)},i&&this.renderAxisLine(),a&&this.renderTicks(),fi.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(n,s,i){var a;return pe.isValidElement(n)?a=pe.cloneElement(n,s):Xt(n)?a=n(s):a=pe.createElement(nw,k_({},s,{className:"recharts-polar-radius-axis-tick-value"}),i),a}}])}(j.PureComponent);jM(kM,"displayName","PolarRadiusAxis");jM(kM,"axisType","radiusAxis");jM(kM,"defaultProps",{type:"number",radiusAxisId:0,cx:0,cy:0,angle:0,orientation:"right",stroke:"#ccc",axisLine:!0,tick:!0,tickCount:5,allowDataOverflow:!1,scale:"auto",allowDuplicatedCategory:!0});function dw(t){"@babel/helpers - typeof";return dw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},dw(t)}function Wm(){return Wm=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Wm.apply(this,arguments)}function Tee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Nm(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Tee(Object(r),!0).forEach(function(n){NM(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Tee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function lpt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Pee(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,zxe(n.key),n)}}function cpt(t,e,r){return e&&Pee(t.prototype,e),r&&Pee(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function upt(t,e,r){return e=JP(e),dpt(t,Bxe()?Reflect.construct(e,r||[],JP(t).constructor):e.apply(t,r))}function dpt(t,e){if(e&&(dw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return hpt(t)}function hpt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Bxe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Bxe=function(){return!!t})()}function JP(t){return JP=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},JP(t)}function fpt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&QB(t,e)}function QB(t,e){return QB=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},QB(t,e)}function NM(t,e,r){return e=zxe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function zxe(t){var e=ppt(t,"string");return dw(e)=="symbol"?e:e+""}function ppt(t,e){if(dw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(dw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var mpt=Math.PI/180,Oee=1e-5,EM=function(t){function e(){return lpt(this,e),upt(this,e,arguments)}return fpt(e,t),cpt(e,[{key:"getTickLineCoord",value:function(n){var s=this.props,i=s.cx,a=s.cy,o=s.radius,c=s.orientation,u=s.tickSize,d=u||8,h=nn(i,a,o,n.coordinate),f=nn(i,a,o+(c==="inner"?-1:1)*d,n.coordinate);return{x1:h.x,y1:h.y,x2:f.x,y2:f.y}}},{key:"getTickTextAnchor",value:function(n){var s=this.props.orientation,i=Math.cos(-n.coordinate*mpt),a;return i>Oee?a=s==="outer"?"start":"end":i<-Oee?a=s==="outer"?"end":"start":a="middle",a}},{key:"renderAxisLine",value:function(){var n=this.props,s=n.cx,i=n.cy,a=n.radius,o=n.axisLine,c=n.axisLineType,u=Nm(Nm({},Gt(this.props,!1)),{},{fill:"none"},Gt(o,!1));if(c==="circle")return pe.createElement(k9,Wm({className:"recharts-polar-angle-axis-line"},u,{cx:s,cy:i,r:a}));var d=this.props.ticks,h=d.map(function(f){return nn(s,i,a,f.coordinate)});return pe.createElement(Tft,Wm({className:"recharts-polar-angle-axis-line"},u,{points:h}))}},{key:"renderTicks",value:function(){var n=this,s=this.props,i=s.ticks,a=s.tick,o=s.tickLine,c=s.tickFormatter,u=s.stroke,d=Gt(this.props,!1),h=Gt(a,!1),f=Nm(Nm({},d),{},{fill:"none"},Gt(o,!1)),p=i.map(function(m,g){var x=n.getTickLineCoord(m),y=n.getTickTextAnchor(m),v=Nm(Nm(Nm({textAnchor:y},d),{},{stroke:"none",fill:u},h),{},{index:g,payload:m,x:x.x2,y:x.y2});return pe.createElement(Vn,Wm({className:mr("recharts-polar-angle-axis-tick",_xe(a)),key:"tick-".concat(m.coordinate)},iM(n.props,m,g)),o&&pe.createElement("line",Wm({className:"recharts-polar-angle-axis-tick-line"},f,x)),a&&e.renderTickItem(a,v,c?c(m.value,g):m.value))});return pe.createElement(Vn,{className:"recharts-polar-angle-axis-ticks"},p)}},{key:"render",value:function(){var n=this.props,s=n.ticks,i=n.radius,a=n.axisLine;return i<=0||!s||!s.length?null:pe.createElement(Vn,{className:mr("recharts-polar-angle-axis",this.props.className)},a&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,s,i){var a;return pe.isValidElement(n)?a=pe.cloneElement(n,s):Xt(n)?a=n(s):a=pe.createElement(nw,Wm({},s,{className:"recharts-polar-angle-axis-tick-value"}),i),a}}])}(j.PureComponent);NM(EM,"displayName","PolarAngleAxis");NM(EM,"axisType","angleAxis");NM(EM,"defaultProps",{type:"category",angleAxisId:0,scale:"auto",cx:0,cy:0,orientation:"outer",axisLine:!0,tickLine:!0,tickSize:8,tick:!0,hide:!1,allowDuplicatedCategory:!0});var gpt=Yge,ypt=gpt(Object.getPrototypeOf,Object),xpt=ypt,vpt=Ph,bpt=xpt,wpt=Oh,Spt="[object Object]",_pt=Function.prototype,jpt=Object.prototype,Uxe=_pt.toString,kpt=jpt.hasOwnProperty,Npt=Uxe.call(Object);function Ept(t){if(!wpt(t)||vpt(t)!=Spt)return!1;var e=bpt(t);if(e===null)return!0;var r=kpt.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Uxe.call(r)==Npt}var Apt=Ept;const Cpt=cr(Apt);var Tpt=Ph,Ppt=Oh,Opt="[object Boolean]";function Ipt(t){return t===!0||t===!1||Ppt(t)&&Tpt(t)==Opt}var Rpt=Ipt;const Mpt=cr(Rpt);function qj(t){"@babel/helpers - typeof";return qj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qj(t)}function QP(){return QP=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},QP.apply(this,arguments)}function Dpt(t,e){return Bpt(t)||$pt(t,e)||Fpt(t,e)||Lpt()}function Lpt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fpt(t,e){if(t){if(typeof t=="string")return Iee(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Iee(t,e)}}function Iee(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function $pt(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function Bpt(t){if(Array.isArray(t))return t}function Ree(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Mee(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ree(Object(r),!0).forEach(function(n){zpt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ree(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function zpt(t,e,r){return e=Upt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Upt(t){var e=Hpt(t,"string");return qj(e)=="symbol"?e:e+""}function Hpt(t,e){if(qj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(qj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Dee=function(e,r,n,s,i){var a=n-s,o;return o="M ".concat(e,",").concat(r),o+="L ".concat(e+n,",").concat(r),o+="L ".concat(e+n-a/2,",").concat(r+i),o+="L ".concat(e+n-a/2-s,",").concat(r+i),o+="L ".concat(e,",").concat(r," Z"),o},Vpt={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Wpt=function(e){var r=Mee(Mee({},Vpt),e),n=j.useRef(),s=j.useState(-1),i=Dpt(s,2),a=i[0],o=i[1];j.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var b=n.current.getTotalLength();b&&o(b)}catch{}},[]);var c=r.x,u=r.y,d=r.upperWidth,h=r.lowerWidth,f=r.height,p=r.className,m=r.animationEasing,g=r.animationDuration,x=r.animationBegin,y=r.isUpdateAnimationActive;if(c!==+c||u!==+u||d!==+d||h!==+h||f!==+f||d===0&&h===0||f===0)return null;var v=mr("recharts-trapezoid",p);return y?pe.createElement(Wp,{canBegin:a>0,from:{upperWidth:0,lowerWidth:0,height:f,x:c,y:u},to:{upperWidth:d,lowerWidth:h,height:f,x:c,y:u},duration:g,animationEasing:m,isActive:y},function(b){var w=b.upperWidth,S=b.lowerWidth,k=b.height,E=b.x,C=b.y;return pe.createElement(Wp,{canBegin:a>0,from:"0px ".concat(a===-1?1:a,"px"),to:"".concat(a,"px 0px"),attributeName:"strokeDasharray",begin:x,duration:g,easing:m},pe.createElement("path",QP({},Gt(r,!0),{className:v,d:Dee(E,C,w,S,k),ref:n})))}):pe.createElement("g",null,pe.createElement("path",QP({},Gt(r,!0),{className:v,d:Dee(c,u,d,h,f)})))},qpt=["option","shapeType","propTransformer","activeClassName","isActive"];function Gj(t){"@babel/helpers - typeof";return Gj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gj(t)}function Gpt(t,e){if(t==null)return{};var r=Kpt(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Kpt(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Lee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function ZP(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Lee(Object(r),!0).forEach(function(n){Ypt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Lee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ypt(t,e,r){return e=Xpt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Xpt(t){var e=Jpt(t,"string");return Gj(e)=="symbol"?e:e+""}function Jpt(t,e){if(Gj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Gj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Qpt(t,e){return ZP(ZP({},e),t)}function Zpt(t,e){return t==="symbols"}function Fee(t){var e=t.shapeType,r=t.elementProps;switch(e){case"rectangle":return pe.createElement(j9,r);case"trapezoid":return pe.createElement(Wpt,r);case"sector":return pe.createElement(Nxe,r);case"symbols":if(Zpt(e))return pe.createElement(BW,r);break;default:return null}}function emt(t){return j.isValidElement(t)?t.props:t}function tmt(t){var e=t.option,r=t.shapeType,n=t.propTransformer,s=n===void 0?Qpt:n,i=t.activeClassName,a=i===void 0?"recharts-active-shape":i,o=t.isActive,c=Gpt(t,qpt),u;if(j.isValidElement(e))u=j.cloneElement(e,ZP(ZP({},c),emt(e)));else if(Xt(e))u=e(c);else if(Cpt(e)&&!Mpt(e)){var d=s(e,c);u=pe.createElement(Fee,{shapeType:r,elementProps:d})}else{var h=c;u=pe.createElement(Fee,{shapeType:r,elementProps:h})}return o?pe.createElement(Vn,{className:a},u):u}function AM(t,e){return e!=null&&"trapezoids"in t.props}function CM(t,e){return e!=null&&"sectors"in t.props}function Kj(t,e){return e!=null&&"points"in t.props}function rmt(t,e){var r,n,s=t.x===(e==null||(r=e.labelViewBox)===null||r===void 0?void 0:r.x)||t.x===e.x,i=t.y===(e==null||(n=e.labelViewBox)===null||n===void 0?void 0:n.y)||t.y===e.y;return s&&i}function nmt(t,e){var r=t.endAngle===e.endAngle,n=t.startAngle===e.startAngle;return r&&n}function smt(t,e){var r=t.x===e.x,n=t.y===e.y,s=t.z===e.z;return r&&n&&s}function imt(t,e){var r;return AM(t,e)?r=rmt:CM(t,e)?r=nmt:Kj(t,e)&&(r=smt),r}function amt(t,e){var r;return AM(t,e)?r="trapezoids":CM(t,e)?r="sectors":Kj(t,e)&&(r="points"),r}function omt(t,e){if(AM(t,e)){var r;return(r=e.tooltipPayload)===null||r===void 0||(r=r[0])===null||r===void 0||(r=r.payload)===null||r===void 0?void 0:r.payload}if(CM(t,e)){var n;return(n=e.tooltipPayload)===null||n===void 0||(n=n[0])===null||n===void 0||(n=n.payload)===null||n===void 0?void 0:n.payload}return Kj(t,e)?e.payload:{}}function lmt(t){var e=t.activeTooltipItem,r=t.graphicalItem,n=t.itemData,s=amt(r,e),i=omt(r,e),a=n.filter(function(c,u){var d=v9(i,c),h=r.props[s].filter(function(m){var g=imt(r,e);return g(m,e)}),f=r.props[s].indexOf(h[h.length-1]),p=u===f;return d&&p}),o=n.indexOf(a[a.length-1]);return o}var bT;function hw(t){"@babel/helpers - typeof";return hw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},hw(t)}function $v(){return $v=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},$v.apply(this,arguments)}function $ee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Zr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?$ee(Object(r),!0).forEach(function(n){ol(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$ee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function cmt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Bee(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Vxe(n.key),n)}}function umt(t,e,r){return e&&Bee(t.prototype,e),r&&Bee(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function dmt(t,e,r){return e=eO(e),hmt(t,Hxe()?Reflect.construct(e,r||[],eO(t).constructor):e.apply(t,r))}function hmt(t,e){if(e&&(hw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return fmt(t)}function fmt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Hxe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Hxe=function(){return!!t})()}function eO(t){return eO=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},eO(t)}function pmt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ZB(t,e)}function ZB(t,e){return ZB=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},ZB(t,e)}function ol(t,e,r){return e=Vxe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Vxe(t){var e=mmt(t,"string");return hw(e)=="symbol"?e:e+""}function mmt(t,e){if(hw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(hw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Fu=function(t){function e(r){var n;return cmt(this,e),n=dmt(this,e,[r]),ol(n,"pieRef",null),ol(n,"sectorRefs",[]),ol(n,"id",sM("recharts-pie-")),ol(n,"handleAnimationEnd",function(){var s=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),Xt(s)&&s()}),ol(n,"handleAnimationStart",function(){var s=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),Xt(s)&&s()}),n.state={isAnimationFinished:!r.isAnimationActive,prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,sectorToFocus:0},n}return pmt(e,t),umt(e,[{key:"isActiveIndex",value:function(n){var s=this.props.activeIndex;return Array.isArray(s)?s.indexOf(n)!==-1:n===s}},{key:"hasActiveIndex",value:function(){var n=this.props.activeIndex;return Array.isArray(n)?n.length!==0:n||n===0}},{key:"renderLabels",value:function(n){var s=this.props.isAnimationActive;if(s&&!this.state.isAnimationFinished)return null;var i=this.props,a=i.label,o=i.labelLine,c=i.dataKey,u=i.valueKey,d=Gt(this.props,!1),h=Gt(a,!1),f=Gt(o,!1),p=a&&a.offsetRadius||20,m=n.map(function(g,x){var y=(g.startAngle+g.endAngle)/2,v=nn(g.cx,g.cy,g.outerRadius+p,y),b=Zr(Zr(Zr(Zr({},d),g),{},{stroke:"none"},h),{},{index:x,textAnchor:e.getTextAnchor(v.x,g.cx)},v),w=Zr(Zr(Zr(Zr({},d),g),{},{fill:"none",stroke:g.fill},f),{},{index:x,points:[nn(g.cx,g.cy,g.outerRadius,y),v]}),S=c;return hr(c)&&hr(u)?S="value":hr(c)&&(S=u),pe.createElement(Vn,{key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(x)},o&&e.renderLabelLineItem(o,w,"line"),e.renderLabelItem(a,b,No(g,S)))});return pe.createElement(Vn,{className:"recharts-pie-labels"},m)}},{key:"renderSectorsStatically",value:function(n){var s=this,i=this.props,a=i.activeShape,o=i.blendStroke,c=i.inactiveShape;return n.map(function(u,d){if((u==null?void 0:u.startAngle)===0&&(u==null?void 0:u.endAngle)===0&&n.length!==1)return null;var h=s.isActiveIndex(d),f=c&&s.hasActiveIndex()?c:null,p=h?a:f,m=Zr(Zr({},u),{},{stroke:o?u.fill:u.stroke,tabIndex:-1});return pe.createElement(Vn,$v({ref:function(x){x&&!s.sectorRefs.includes(x)&&s.sectorRefs.push(x)},tabIndex:-1,className:"recharts-pie-sector"},iM(s.props,u,d),{key:"sector-".concat(u==null?void 0:u.startAngle,"-").concat(u==null?void 0:u.endAngle,"-").concat(u.midAngle,"-").concat(d)}),pe.createElement(tmt,$v({option:p,isActive:h,shapeType:"sector"},m)))})}},{key:"renderSectorsWithAnimation",value:function(){var n=this,s=this.props,i=s.sectors,a=s.isAnimationActive,o=s.animationBegin,c=s.animationDuration,u=s.animationEasing,d=s.animationId,h=this.state,f=h.prevSectors,p=h.prevIsAnimationActive;return pe.createElement(Wp,{begin:o,duration:c,isActive:a,easing:u,from:{t:0},to:{t:1},key:"pie-".concat(d,"-").concat(p),onAnimationStart:this.handleAnimationStart,onAnimationEnd:this.handleAnimationEnd},function(m){var g=m.t,x=[],y=i&&i[0],v=y.startAngle;return i.forEach(function(b,w){var S=f&&f[w],k=w>0?mc(b,"paddingAngle",0):0;if(S){var E=MJ(S.endAngle-S.startAngle,b.endAngle-b.startAngle),C=Zr(Zr({},b),{},{startAngle:v+k,endAngle:v+E(g)+k});x.push(C),v=C.endAngle}else{var A=b.endAngle,M=b.startAngle,z=MJ(0,A-M),P=z(g),W=Zr(Zr({},b),{},{startAngle:v+k,endAngle:v+P+k});x.push(W),v=W.endAngle}}),pe.createElement(Vn,null,n.renderSectorsStatically(x))})}},{key:"attachKeyboardHandlers",value:function(n){var s=this;n.onkeydown=function(i){if(!i.altKey)switch(i.key){case"ArrowLeft":{var a=++s.state.sectorToFocus%s.sectorRefs.length;s.sectorRefs[a].focus(),s.setState({sectorToFocus:a});break}case"ArrowRight":{var o=--s.state.sectorToFocus<0?s.sectorRefs.length-1:s.state.sectorToFocus%s.sectorRefs.length;s.sectorRefs[o].focus(),s.setState({sectorToFocus:o});break}case"Escape":{s.sectorRefs[s.state.sectorToFocus].blur(),s.setState({sectorToFocus:0});break}}}}},{key:"renderSectors",value:function(){var n=this.props,s=n.sectors,i=n.isAnimationActive,a=this.state.prevSectors;return i&&s&&s.length&&(!a||!v9(a,s))?this.renderSectorsWithAnimation():this.renderSectorsStatically(s)}},{key:"componentDidMount",value:function(){this.pieRef&&this.attachKeyboardHandlers(this.pieRef)}},{key:"render",value:function(){var n=this,s=this.props,i=s.hide,a=s.sectors,o=s.className,c=s.label,u=s.cx,d=s.cy,h=s.innerRadius,f=s.outerRadius,p=s.isAnimationActive,m=this.state.isAnimationFinished;if(i||!a||!a.length||!ut(u)||!ut(d)||!ut(h)||!ut(f))return null;var g=mr("recharts-pie",o);return pe.createElement(Vn,{tabIndex:this.props.rootTabIndex,className:g,ref:function(y){n.pieRef=y}},this.renderSectors(),c&&this.renderLabels(a),fi.renderCallByParent(this.props,null,!1),(!p||m)&&Ry.renderCallByParent(this.props,a,!1))}}],[{key:"getDerivedStateFromProps",value:function(n,s){return s.prevIsAnimationActive!==n.isAnimationActive?{prevIsAnimationActive:n.isAnimationActive,prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:[],isAnimationFinished:!0}:n.isAnimationActive&&n.animationId!==s.prevAnimationId?{prevAnimationId:n.animationId,curSectors:n.sectors,prevSectors:s.curSectors,isAnimationFinished:!0}:n.sectors!==s.curSectors?{curSectors:n.sectors,isAnimationFinished:!0}:null}},{key:"getTextAnchor",value:function(n,s){return n>s?"start":n<s?"end":"middle"}},{key:"renderLabelLineItem",value:function(n,s,i){if(pe.isValidElement(n))return pe.cloneElement(n,s);if(Xt(n))return n(s);var a=mr("recharts-pie-label-line",typeof n!="boolean"?n.className:"");return pe.createElement(FB,$v({},s,{key:i,type:"linear",className:a}))}},{key:"renderLabelItem",value:function(n,s,i){if(pe.isValidElement(n))return pe.cloneElement(n,s);var a=i;if(Xt(n)&&(a=n(s),pe.isValidElement(a)))return a;var o=mr("recharts-pie-label-text",typeof n!="boolean"&&!Xt(n)?n.className:"");return pe.createElement(nw,$v({},s,{alignmentBaseline:"middle",className:o}),a)}}])}(j.PureComponent);bT=Fu;ol(Fu,"displayName","Pie");ol(Fu,"defaultProps",{stroke:"#fff",fill:"#808080",legendType:"rect",cx:"50%",cy:"50%",startAngle:0,endAngle:360,innerRadius:0,outerRadius:"80%",paddingAngle:0,labelLine:!0,hide:!1,minAngle:0,isAnimationActive:!Py.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});ol(Fu,"parseDeltaAngle",function(t,e){var r=pl(e-t),n=Math.min(Math.abs(e-t),360);return r*n});ol(Fu,"getRealPieData",function(t){var e=t.data,r=t.children,n=Gt(t,!1),s=ju(r,rw);return e&&e.length?e.map(function(i,a){return Zr(Zr(Zr({payload:i},n),i),s&&s[a]&&s[a].props)}):s&&s.length?s.map(function(i){return Zr(Zr({},n),i.props)}):[]});ol(Fu,"parseCoordinateOfPie",function(t,e){var r=e.top,n=e.left,s=e.width,i=e.height,a=Sxe(s,i),o=n+za(t.cx,s,s/2),c=r+za(t.cy,i,i/2),u=za(t.innerRadius,a,0),d=za(t.outerRadius,a,a*.8),h=t.maxRadius||Math.sqrt(s*s+i*i)/2;return{cx:o,cy:c,innerRadius:u,outerRadius:d,maxRadius:h}});ol(Fu,"getComposedData",function(t){var e=t.item,r=t.offset,n=e.type.defaultProps!==void 0?Zr(Zr({},e.type.defaultProps),e.props):e.props,s=bT.getRealPieData(n);if(!s||!s.length)return null;var i=n.cornerRadius,a=n.startAngle,o=n.endAngle,c=n.paddingAngle,u=n.dataKey,d=n.nameKey,h=n.valueKey,f=n.tooltipType,p=Math.abs(n.minAngle),m=bT.parseCoordinateOfPie(n,r),g=bT.parseDeltaAngle(a,o),x=Math.abs(g),y=u;hr(u)&&hr(h)?(rh(!1,`Use "dataKey" to specify the value of pie,
the props "valueKey" will be deprecated in 1.1.0`),y="value"):hr(u)&&(rh(!1,`Use "dataKey" to specify the value of pie,
the props "valueKey" will be deprecated in 1.1.0`),y=h);var v=s.filter(function(C){return No(C,y,0)!==0}).length,b=(x>=360?v:v-1)*c,w=x-v*p-b,S=s.reduce(function(C,A){var M=No(A,y,0);return C+(ut(M)?M:0)},0),k;if(S>0){var E;k=s.map(function(C,A){var M=No(C,y,0),z=No(C,d,A),P=(ut(M)?M:0)/S,W;A?W=E.endAngle+pl(g)*c*(M!==0?1:0):W=a;var N=W+pl(g)*((M!==0?p:0)+P*w),U=(W+N)/2,K=(m.innerRadius+m.outerRadius)/2,G=[{name:z,value:M,payload:C,dataKey:y,type:f}],X=nn(m.cx,m.cy,K,U);return E=Zr(Zr(Zr({percent:P,cornerRadius:i,name:z,tooltipPayload:G,midAngle:U,middleRadius:K,tooltipPosition:X},C),m),{},{value:No(C,y),startAngle:W,endAngle:N,payload:C,paddingAngle:pl(g)*c}),E})}return Zr(Zr({},m),{},{sectors:k,data:s})});var gmt=Math.ceil,ymt=Math.max;function xmt(t,e,r,n){for(var s=-1,i=ymt(gmt((e-t)/(r||1)),0),a=Array(i);i--;)a[n?i:++s]=t,t+=r;return a}var vmt=xmt,bmt=fye,zee=1/0,wmt=17976931348623157e292;function Smt(t){if(!t)return t===0?t:0;if(t=bmt(t),t===zee||t===-zee){var e=t<0?-1:1;return e*wmt}return t===t?t:0}var _mt=Smt,jmt=vmt,kmt=hM,A4=_mt;function Nmt(t){return function(e,r,n){return n&&typeof n!="number"&&kmt(e,r,n)&&(r=n=void 0),e=A4(e),r===void 0?(r=e,e=0):r=A4(r),n=n===void 0?e<r?1:-1:A4(n),jmt(e,r,n,t)}}var Emt=Nmt,Amt=Emt,Cmt=Amt(),Tmt=Cmt;const tO=cr(Tmt);function Yj(t){"@babel/helpers - typeof";return Yj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yj(t)}function Uee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Hee(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Uee(Object(r),!0).forEach(function(n){Wxe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Uee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Wxe(t,e,r){return e=Pmt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pmt(t){var e=Omt(t,"string");return Yj(e)=="symbol"?e:e+""}function Omt(t,e){if(Yj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Yj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Imt=["Webkit","Moz","O","ms"],Rmt=function(e,r){var n=e.replace(/(\w)/,function(i){return i.toUpperCase()}),s=Imt.reduce(function(i,a){return Hee(Hee({},i),{},Wxe({},a+n,r))},{});return s[e]=r,s};function fw(t){"@babel/helpers - typeof";return fw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fw(t)}function rO(){return rO=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},rO.apply(this,arguments)}function Vee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function C4(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Vee(Object(r),!0).forEach(function(n){no(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Vee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Mmt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Wee(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Gxe(n.key),n)}}function Dmt(t,e,r){return e&&Wee(t.prototype,e),r&&Wee(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Lmt(t,e,r){return e=nO(e),Fmt(t,qxe()?Reflect.construct(e,r||[],nO(t).constructor):e.apply(t,r))}function Fmt(t,e){if(e&&(fw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return $mt(t)}function $mt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function qxe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(qxe=function(){return!!t})()}function nO(t){return nO=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},nO(t)}function Bmt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&e8(t,e)}function e8(t,e){return e8=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},e8(t,e)}function no(t,e,r){return e=Gxe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Gxe(t){var e=zmt(t,"string");return fw(e)=="symbol"?e:e+""}function zmt(t,e){if(fw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(fw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Umt=function(e){var r=e.data,n=e.startIndex,s=e.endIndex,i=e.x,a=e.width,o=e.travellerWidth;if(!r||!r.length)return{};var c=r.length,u=w_().domain(tO(0,c)).range([i,i+a-o]),d=u.domain().map(function(h){return u(h)});return{isTextActive:!1,isSlideMoving:!1,isTravellerMoving:!1,isTravellerFocused:!1,startX:u(n),endX:u(s),scale:u,scaleValues:d}},qee=function(e){return e.changedTouches&&!!e.changedTouches.length},pw=function(t){function e(r){var n;return Mmt(this,e),n=Lmt(this,e,[r]),no(n,"handleDrag",function(s){n.leaveTimer&&(clearTimeout(n.leaveTimer),n.leaveTimer=null),n.state.isTravellerMoving?n.handleTravellerMove(s):n.state.isSlideMoving&&n.handleSlideDrag(s)}),no(n,"handleTouchMove",function(s){s.changedTouches!=null&&s.changedTouches.length>0&&n.handleDrag(s.changedTouches[0])}),no(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var s=n.props,i=s.endIndex,a=s.onDragEnd,o=s.startIndex;a==null||a({endIndex:i,startIndex:o})}),n.detachDragEndListener()}),no(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),no(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),no(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),no(n,"handleSlideDragStart",function(s){var i=qee(s)?s.changedTouches[0]:s;n.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:i.pageX}),n.attachDragEndListener()}),n.travellerDragStartHandlers={startX:n.handleTravellerDragStart.bind(n,"startX"),endX:n.handleTravellerDragStart.bind(n,"endX")},n.state={},n}return Bmt(e,t),Dmt(e,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(n){var s=n.startX,i=n.endX,a=this.state.scaleValues,o=this.props,c=o.gap,u=o.data,d=u.length-1,h=Math.min(s,i),f=Math.max(s,i),p=e.getIndexInRange(a,h),m=e.getIndexInRange(a,f);return{startIndex:p-p%c,endIndex:m===d?d:m-m%c}}},{key:"getTextOfTick",value:function(n){var s=this.props,i=s.data,a=s.tickFormatter,o=s.dataKey,c=No(i[n],o,n);return Xt(a)?a(c,n):c}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(n){var s=this.state,i=s.slideMoveStartX,a=s.startX,o=s.endX,c=this.props,u=c.x,d=c.width,h=c.travellerWidth,f=c.startIndex,p=c.endIndex,m=c.onChange,g=n.pageX-i;g>0?g=Math.min(g,u+d-h-o,u+d-h-a):g<0&&(g=Math.max(g,u-a,u-o));var x=this.getIndex({startX:a+g,endX:o+g});(x.startIndex!==f||x.endIndex!==p)&&m&&m(x),this.setState({startX:a+g,endX:o+g,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,s){var i=qee(s)?s.changedTouches[0]:s;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:n,brushMoveStartX:i.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(n){var s=this.state,i=s.brushMoveStartX,a=s.movingTravellerId,o=s.endX,c=s.startX,u=this.state[a],d=this.props,h=d.x,f=d.width,p=d.travellerWidth,m=d.onChange,g=d.gap,x=d.data,y={startX:this.state.startX,endX:this.state.endX},v=n.pageX-i;v>0?v=Math.min(v,h+f-p-u):v<0&&(v=Math.max(v,h-u)),y[a]=u+v;var b=this.getIndex(y),w=b.startIndex,S=b.endIndex,k=function(){var C=x.length-1;return a==="startX"&&(o>c?w%g===0:S%g===0)||o<c&&S===C||a==="endX"&&(o>c?S%g===0:w%g===0)||o>c&&S===C};this.setState(no(no({},a,u+v),"brushMoveStartX",n.pageX),function(){m&&k()&&m(b)})}},{key:"handleTravellerMoveKeyboard",value:function(n,s){var i=this,a=this.state,o=a.scaleValues,c=a.startX,u=a.endX,d=this.state[s],h=o.indexOf(d);if(h!==-1){var f=h+n;if(!(f===-1||f>=o.length)){var p=o[f];s==="startX"&&p>=u||s==="endX"&&p<=c||this.setState(no({},s,p),function(){i.props.onChange(i.getIndex({startX:i.state.startX,endX:i.state.endX}))})}}}},{key:"renderBackground",value:function(){var n=this.props,s=n.x,i=n.y,a=n.width,o=n.height,c=n.fill,u=n.stroke;return pe.createElement("rect",{stroke:u,fill:c,x:s,y:i,width:a,height:o})}},{key:"renderPanorama",value:function(){var n=this.props,s=n.x,i=n.y,a=n.width,o=n.height,c=n.data,u=n.children,d=n.padding,h=j.Children.only(u);return h?pe.cloneElement(h,{x:s,y:i,width:a,height:o,margin:d,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(n,s){var i,a,o=this,c=this.props,u=c.y,d=c.travellerWidth,h=c.height,f=c.traveller,p=c.ariaLabel,m=c.data,g=c.startIndex,x=c.endIndex,y=Math.max(n,this.props.x),v=C4(C4({},Gt(this.props,!1)),{},{x:y,y:u,width:d,height:h}),b=p||"Min value: ".concat((i=m[g])===null||i===void 0?void 0:i.name,", Max value: ").concat((a=m[x])===null||a===void 0?void 0:a.name);return pe.createElement(Vn,{tabIndex:0,role:"slider","aria-label":b,"aria-valuenow":n,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[s],onTouchStart:this.travellerDragStartHandlers[s],onKeyDown:function(S){["ArrowLeft","ArrowRight"].includes(S.key)&&(S.preventDefault(),S.stopPropagation(),o.handleTravellerMoveKeyboard(S.key==="ArrowRight"?1:-1,s))},onFocus:function(){o.setState({isTravellerFocused:!0})},onBlur:function(){o.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},e.renderTraveller(f,v))}},{key:"renderSlide",value:function(n,s){var i=this.props,a=i.y,o=i.height,c=i.stroke,u=i.travellerWidth,d=Math.min(n,s)+u,h=Math.max(Math.abs(s-n)-u,0);return pe.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:d,y:a,width:h,height:o})}},{key:"renderText",value:function(){var n=this.props,s=n.startIndex,i=n.endIndex,a=n.y,o=n.height,c=n.travellerWidth,u=n.stroke,d=this.state,h=d.startX,f=d.endX,p=5,m={pointerEvents:"none",fill:u};return pe.createElement(Vn,{className:"recharts-brush-texts"},pe.createElement(nw,rO({textAnchor:"end",verticalAnchor:"middle",x:Math.min(h,f)-p,y:a+o/2},m),this.getTextOfTick(s)),pe.createElement(nw,rO({textAnchor:"start",verticalAnchor:"middle",x:Math.max(h,f)+c+p,y:a+o/2},m),this.getTextOfTick(i)))}},{key:"render",value:function(){var n=this.props,s=n.data,i=n.className,a=n.children,o=n.x,c=n.y,u=n.width,d=n.height,h=n.alwaysShowText,f=this.state,p=f.startX,m=f.endX,g=f.isTextActive,x=f.isSlideMoving,y=f.isTravellerMoving,v=f.isTravellerFocused;if(!s||!s.length||!ut(o)||!ut(c)||!ut(u)||!ut(d)||u<=0||d<=0)return null;var b=mr("recharts-brush",i),w=pe.Children.count(a)===1,S=Rmt("userSelect","none");return pe.createElement(Vn,{className:b,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:S},this.renderBackground(),w&&this.renderPanorama(),this.renderSlide(p,m),this.renderTravellerLayer(p,"startX"),this.renderTravellerLayer(m,"endX"),(g||x||y||v||h)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var s=n.x,i=n.y,a=n.width,o=n.height,c=n.stroke,u=Math.floor(i+o/2)-1;return pe.createElement(pe.Fragment,null,pe.createElement("rect",{x:s,y:i,width:a,height:o,fill:c,stroke:"none"}),pe.createElement("line",{x1:s+1,y1:u,x2:s+a-1,y2:u,fill:"none",stroke:"#fff"}),pe.createElement("line",{x1:s+1,y1:u+2,x2:s+a-1,y2:u+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(n,s){var i;return pe.isValidElement(n)?i=pe.cloneElement(n,s):Xt(n)?i=n(s):i=e.renderDefaultTraveller(s),i}},{key:"getDerivedStateFromProps",value:function(n,s){var i=n.data,a=n.width,o=n.x,c=n.travellerWidth,u=n.updateId,d=n.startIndex,h=n.endIndex;if(i!==s.prevData||u!==s.prevUpdateId)return C4({prevData:i,prevTravellerWidth:c,prevUpdateId:u,prevX:o,prevWidth:a},i&&i.length?Umt({data:i,width:a,x:o,travellerWidth:c,startIndex:d,endIndex:h}):{scale:null,scaleValues:null});if(s.scale&&(a!==s.prevWidth||o!==s.prevX||c!==s.prevTravellerWidth)){s.scale.range([o,o+a-c]);var f=s.scale.domain().map(function(p){return s.scale(p)});return{prevData:i,prevTravellerWidth:c,prevUpdateId:u,prevX:o,prevWidth:a,startX:s.scale(n.startIndex),endX:s.scale(n.endIndex),scaleValues:f}}return null}},{key:"getIndexInRange",value:function(n,s){for(var i=n.length,a=0,o=i-1;o-a>1;){var c=Math.floor((a+o)/2);n[c]>s?o=c:a=c}return s>=n[o]?o:a}}])}(j.PureComponent);no(pw,"displayName","Brush");no(pw,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var Hmt=KW;function Vmt(t,e){var r;return Hmt(t,function(n,s,i){return r=e(n,s,i),!r}),!!r}var Wmt=Vmt,qmt=zge,Gmt=cm,Kmt=Wmt,Ymt=eo,Xmt=hM;function Jmt(t,e,r){var n=Ymt(t)?qmt:Kmt;return r&&Xmt(t,e,r)&&(e=void 0),n(t,Gmt(e))}var Qmt=Jmt;const Zmt=cr(Qmt);var Nu=function(e,r){var n=e.alwaysShow,s=e.ifOverflow;return n&&(s="extendDomain"),s===r},Gee=lye;function egt(t,e,r){e=="__proto__"&&Gee?Gee(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var tgt=egt,rgt=tgt,ngt=aye,sgt=cm;function igt(t,e){var r={};return e=sgt(e),ngt(t,function(n,s,i){rgt(r,s,e(n,s,i))}),r}var agt=igt;const ogt=cr(agt);function lgt(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(!e(t[r],r,t))return!1;return!0}var cgt=lgt,ugt=KW;function dgt(t,e){var r=!0;return ugt(t,function(n,s,i){return r=!!e(n,s,i),r}),r}var hgt=dgt,fgt=cgt,pgt=hgt,mgt=cm,ggt=eo,ygt=hM;function xgt(t,e,r){var n=ggt(t)?fgt:pgt;return r&&ygt(t,e,r)&&(e=void 0),n(t,mgt(e))}var vgt=xgt;const bgt=cr(vgt);function Xj(t){"@babel/helpers - typeof";return Xj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xj(t)}function wgt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Kee(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Kxe(n.key),n)}}function Sgt(t,e,r){return e&&Kee(t.prototype,e),r&&Kee(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Yee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function sC(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Yee(Object(r),!0).forEach(function(n){N9(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Yee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function N9(t,e,r){return e=Kxe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Kxe(t){var e=_gt(t,"string");return Xj(e)=="symbol"?e:e+""}function _gt(t,e){if(Xj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Xj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Yxe=function(e,r){var n=e.x,s=e.y,i=r.x,a=r.y;return{x:Math.min(n,i),y:Math.min(s,a),width:Math.abs(i-n),height:Math.abs(a-s)}},jgt=function(e){var r=e.x1,n=e.y1,s=e.x2,i=e.y2;return Yxe({x:r,y:n},{x:s,y:i})},Xxe=function(){function t(e){wgt(this,t),this.scale=e}return Sgt(t,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=n.bandAware,i=n.position;if(r!==void 0){if(i)switch(i){case"start":return this.scale(r);case"middle":{var a=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+a}case"end":{var o=this.bandwidth?this.bandwidth():0;return this.scale(r)+o}default:return this.scale(r)}if(s){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+c}return this.scale(r)}}},{key:"isInRange",value:function(r){var n=this.range(),s=n[0],i=n[n.length-1];return s<=i?r>=s&&r<=i:r>=i&&r<=s}}],[{key:"create",value:function(r){return new t(r)}}])}();N9(Xxe,"EPS",1e-4);var E9=function(e){var r=Object.keys(e).reduce(function(n,s){return sC(sC({},n),{},N9({},s,Xxe.create(e[s])))},{});return sC(sC({},r),{},{apply:function(s){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=i.bandAware,o=i.position;return ogt(s,function(c,u){return r[u].apply(c,{bandAware:a,position:o})})},isInRange:function(s){return bgt(s,function(i,a){return r[a].isInRange(i)})}})},kgt=XGe(function(t){return{x:t.left,y:t.top,width:t.width,height:t.height}},function(t){return["l",t.left,"t",t.top,"w",t.width,"h",t.height].join("")}),Jxe=j.createContext(void 0),Qxe=j.createContext(void 0),Zxe=j.createContext(void 0),Ngt=j.createContext({}),eve=j.createContext(void 0),Egt=j.createContext(0),Agt=j.createContext(0),Xee=function(e){var r=e.state,n=r.xAxisMap,s=r.yAxisMap,i=r.offset,a=e.clipPathId,o=e.children,c=e.width,u=e.height,d=kgt(i);return pe.createElement(Jxe.Provider,{value:n},pe.createElement(Qxe.Provider,{value:s},pe.createElement(Ngt.Provider,{value:i},pe.createElement(Zxe.Provider,{value:d},pe.createElement(eve.Provider,{value:a},pe.createElement(Egt.Provider,{value:u},pe.createElement(Agt.Provider,{value:c},o)))))))},Cgt=function(){return j.useContext(eve)},Tgt=function(e){var r=j.useContext(Jxe);r==null&&ow();var n=r[e];return n==null&&ow(),n},Pgt=function(e){var r=j.useContext(Qxe);r==null&&ow();var n=r[e];return n==null&&ow(),n},Ogt=function(){var e=j.useContext(Zxe);return e};function mw(t){"@babel/helpers - typeof";return mw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},mw(t)}function Igt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Rgt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,rve(n.key),n)}}function Mgt(t,e,r){return e&&Rgt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Dgt(t,e,r){return e=sO(e),Lgt(t,tve()?Reflect.construct(e,r||[],sO(t).constructor):e.apply(t,r))}function Lgt(t,e){if(e&&(mw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Fgt(t)}function Fgt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function tve(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(tve=function(){return!!t})()}function sO(t){return sO=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},sO(t)}function $gt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&t8(t,e)}function t8(t,e){return t8=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},t8(t,e)}function Jee(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Qee(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Jee(Object(r),!0).forEach(function(n){A9(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Jee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function A9(t,e,r){return e=rve(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function rve(t){var e=Bgt(t,"string");return mw(e)=="symbol"?e:e+""}function Bgt(t,e){if(mw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(mw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function zgt(t,e){return Wgt(t)||Vgt(t,e)||Hgt(t,e)||Ugt()}function Ugt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hgt(t,e){if(t){if(typeof t=="string")return Zee(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Zee(t,e)}}function Zee(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Vgt(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function Wgt(t){if(Array.isArray(t))return t}function r8(){return r8=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},r8.apply(this,arguments)}var qgt=function(e,r){var n;return pe.isValidElement(e)?n=pe.cloneElement(e,r):Xt(e)?n=e(r):n=pe.createElement("line",r8({},r,{className:"recharts-reference-line-line"})),n},Ggt=function(e,r,n,s,i,a,o,c,u){var d=i.x,h=i.y,f=i.width,p=i.height;if(n){var m=u.y,g=e.y.apply(m,{position:a});if(Nu(u,"discard")&&!e.y.isInRange(g))return null;var x=[{x:d+f,y:g},{x:d,y:g}];return c==="left"?x.reverse():x}if(r){var y=u.x,v=e.x.apply(y,{position:a});if(Nu(u,"discard")&&!e.x.isInRange(v))return null;var b=[{x:v,y:h+p},{x:v,y:h}];return o==="top"?b.reverse():b}if(s){var w=u.segment,S=w.map(function(k){return e.apply(k,{position:a})});return Nu(u,"discard")&&Zmt(S,function(k){return!e.isInRange(k)})?null:S}return null};function Kgt(t){var e=t.x,r=t.y,n=t.segment,s=t.xAxisId,i=t.yAxisId,a=t.shape,o=t.className,c=t.alwaysShow,u=Cgt(),d=Tgt(s),h=Pgt(i),f=Ogt();if(!u||!f)return null;rh(c===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var p=E9({x:d.scale,y:h.scale}),m=Cs(e),g=Cs(r),x=n&&n.length===2,y=Ggt(p,m,g,x,f,t.position,d.orientation,h.orientation,t);if(!y)return null;var v=zgt(y,2),b=v[0],w=b.x,S=b.y,k=v[1],E=k.x,C=k.y,A=Nu(t,"hidden")?"url(#".concat(u,")"):void 0,M=Qee(Qee({clipPath:A},Gt(t,!0)),{},{x1:w,y1:S,x2:E,y2:C});return pe.createElement(Vn,{className:mr("recharts-reference-line",o)},qgt(a,M),fi.renderCallByParent(t,jgt({x1:w,y1:S,x2:E,y2:C})))}var C9=function(t){function e(){return Igt(this,e),Dgt(this,e,arguments)}return $gt(e,t),Mgt(e,[{key:"render",value:function(){return pe.createElement(Kgt,this.props)}}])}(pe.Component);A9(C9,"displayName","ReferenceLine");A9(C9,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle"});function n8(){return n8=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},n8.apply(this,arguments)}function gw(t){"@babel/helpers - typeof";return gw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gw(t)}function ete(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function tte(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ete(Object(r),!0).forEach(function(n){TM(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ete(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ygt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Xgt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,sve(n.key),n)}}function Jgt(t,e,r){return e&&Xgt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Qgt(t,e,r){return e=iO(e),Zgt(t,nve()?Reflect.construct(e,r||[],iO(t).constructor):e.apply(t,r))}function Zgt(t,e){if(e&&(gw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return eyt(t)}function eyt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function nve(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(nve=function(){return!!t})()}function iO(t){return iO=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},iO(t)}function tyt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&s8(t,e)}function s8(t,e){return s8=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},s8(t,e)}function TM(t,e,r){return e=sve(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function sve(t){var e=ryt(t,"string");return gw(e)=="symbol"?e:e+""}function ryt(t,e){if(gw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(gw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var nyt=function(e){var r=e.x,n=e.y,s=e.xAxis,i=e.yAxis,a=E9({x:s.scale,y:i.scale}),o=a.apply({x:r,y:n},{bandAware:!0});return Nu(e,"discard")&&!a.isInRange(o)?null:o},PM=function(t){function e(){return Ygt(this,e),Qgt(this,e,arguments)}return tyt(e,t),Jgt(e,[{key:"render",value:function(){var n=this.props,s=n.x,i=n.y,a=n.r,o=n.alwaysShow,c=n.clipPathId,u=Cs(s),d=Cs(i);if(rh(o===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.'),!u||!d)return null;var h=nyt(this.props);if(!h)return null;var f=h.x,p=h.y,m=this.props,g=m.shape,x=m.className,y=Nu(this.props,"hidden")?"url(#".concat(c,")"):void 0,v=tte(tte({clipPath:y},Gt(this.props,!0)),{},{cx:f,cy:p});return pe.createElement(Vn,{className:mr("recharts-reference-dot",x)},e.renderDot(g,v),fi.renderCallByParent(this.props,{x:f-a,y:p-a,width:2*a,height:2*a}))}}])}(pe.Component);TM(PM,"displayName","ReferenceDot");TM(PM,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#fff",stroke:"#ccc",fillOpacity:1,strokeWidth:1});TM(PM,"renderDot",function(t,e){var r;return pe.isValidElement(t)?r=pe.cloneElement(t,e):Xt(t)?r=t(e):r=pe.createElement(k9,n8({},e,{cx:e.cx,cy:e.cy,className:"recharts-reference-dot-dot"})),r});function i8(){return i8=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i8.apply(this,arguments)}function yw(t){"@babel/helpers - typeof";return yw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yw(t)}function rte(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function nte(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?rte(Object(r),!0).forEach(function(n){OM(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):rte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function syt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function iyt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ave(n.key),n)}}function ayt(t,e,r){return e&&iyt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function oyt(t,e,r){return e=aO(e),lyt(t,ive()?Reflect.construct(e,r||[],aO(t).constructor):e.apply(t,r))}function lyt(t,e){if(e&&(yw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return cyt(t)}function cyt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ive(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ive=function(){return!!t})()}function aO(t){return aO=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},aO(t)}function uyt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a8(t,e)}function a8(t,e){return a8=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},a8(t,e)}function OM(t,e,r){return e=ave(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ave(t){var e=dyt(t,"string");return yw(e)=="symbol"?e:e+""}function dyt(t,e){if(yw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(yw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var hyt=function(e,r,n,s,i){var a=i.x1,o=i.x2,c=i.y1,u=i.y2,d=i.xAxis,h=i.yAxis;if(!d||!h)return null;var f=E9({x:d.scale,y:h.scale}),p={x:e?f.x.apply(a,{position:"start"}):f.x.rangeMin,y:n?f.y.apply(c,{position:"start"}):f.y.rangeMin},m={x:r?f.x.apply(o,{position:"end"}):f.x.rangeMax,y:s?f.y.apply(u,{position:"end"}):f.y.rangeMax};return Nu(i,"discard")&&(!f.isInRange(p)||!f.isInRange(m))?null:Yxe(p,m)},IM=function(t){function e(){return syt(this,e),oyt(this,e,arguments)}return uyt(e,t),ayt(e,[{key:"render",value:function(){var n=this.props,s=n.x1,i=n.x2,a=n.y1,o=n.y2,c=n.className,u=n.alwaysShow,d=n.clipPathId;rh(u===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var h=Cs(s),f=Cs(i),p=Cs(a),m=Cs(o),g=this.props.shape;if(!h&&!f&&!p&&!m&&!g)return null;var x=hyt(h,f,p,m,this.props);if(!x&&!g)return null;var y=Nu(this.props,"hidden")?"url(#".concat(d,")"):void 0;return pe.createElement(Vn,{className:mr("recharts-reference-area",c)},e.renderRect(g,nte(nte({clipPath:y},Gt(this.props,!0)),x)),fi.renderCallByParent(this.props,x))}}])}(pe.Component);OM(IM,"displayName","ReferenceArea");OM(IM,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#ccc",fillOpacity:.5,stroke:"none",strokeWidth:1});OM(IM,"renderRect",function(t,e){var r;return pe.isValidElement(t)?r=pe.cloneElement(t,e):Xt(t)?r=t(e):r=pe.createElement(j9,i8({},e,{className:"recharts-reference-area-rect"})),r});function ste(t){return gyt(t)||myt(t)||pyt(t)||fyt()}function fyt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pyt(t,e){if(t){if(typeof t=="string")return o8(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o8(t,e)}}function myt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function gyt(t){if(Array.isArray(t))return o8(t)}function o8(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var l8=function(e,r,n,s,i){var a=ju(e,C9),o=ju(e,PM),c=[].concat(ste(a),ste(o)),u=ju(e,IM),d="".concat(s,"Id"),h=s[0],f=r;if(c.length&&(f=c.reduce(function(g,x){if(x.props[d]===n&&Nu(x.props,"extendDomain")&&ut(x.props[h])){var y=x.props[h];return[Math.min(g[0],y),Math.max(g[1],y)]}return g},f)),u.length){var p="".concat(h,"1"),m="".concat(h,"2");f=u.reduce(function(g,x){if(x.props[d]===n&&Nu(x.props,"extendDomain")&&ut(x.props[p])&&ut(x.props[m])){var y=x.props[p],v=x.props[m];return[Math.min(g[0],y,v),Math.max(g[1],y,v)]}return g},f)}return i&&i.length&&(f=i.reduce(function(g,x){return ut(x)?[Math.min(g[0],x),Math.max(g[1],x)]:g},f)),f},ove={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}Object.create&&(n.prototype=Object.create(null),new n().__proto__||(r=!1));function s(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function i(c,u,d,h,f){if(typeof d!="function")throw new TypeError("The listener must be a function");var p=new s(d,h||c,f),m=r?r+u:u;return c._events[m]?c._events[m].fn?c._events[m]=[c._events[m],p]:c._events[m].push(p):(c._events[m]=p,c._eventsCount++),c}function a(c,u){--c._eventsCount===0?c._events=new n:delete c._events[u]}function o(){this._events=new n,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],d,h;if(this._eventsCount===0)return u;for(h in d=this._events)e.call(d,h)&&u.push(r?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},o.prototype.listeners=function(u){var d=r?r+u:u,h=this._events[d];if(!h)return[];if(h.fn)return[h.fn];for(var f=0,p=h.length,m=new Array(p);f<p;f++)m[f]=h[f].fn;return m},o.prototype.listenerCount=function(u){var d=r?r+u:u,h=this._events[d];return h?h.fn?1:h.length:0},o.prototype.emit=function(u,d,h,f,p,m){var g=r?r+u:u;if(!this._events[g])return!1;var x=this._events[g],y=arguments.length,v,b;if(x.fn){switch(x.once&&this.removeListener(u,x.fn,void 0,!0),y){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,d),!0;case 3:return x.fn.call(x.context,d,h),!0;case 4:return x.fn.call(x.context,d,h,f),!0;case 5:return x.fn.call(x.context,d,h,f,p),!0;case 6:return x.fn.call(x.context,d,h,f,p,m),!0}for(b=1,v=new Array(y-1);b<y;b++)v[b-1]=arguments[b];x.fn.apply(x.context,v)}else{var w=x.length,S;for(b=0;b<w;b++)switch(x[b].once&&this.removeListener(u,x[b].fn,void 0,!0),y){case 1:x[b].fn.call(x[b].context);break;case 2:x[b].fn.call(x[b].context,d);break;case 3:x[b].fn.call(x[b].context,d,h);break;case 4:x[b].fn.call(x[b].context,d,h,f);break;default:if(!v)for(S=1,v=new Array(y-1);S<y;S++)v[S-1]=arguments[S];x[b].fn.apply(x[b].context,v)}}return!0},o.prototype.on=function(u,d,h){return i(this,u,d,h,!1)},o.prototype.once=function(u,d,h){return i(this,u,d,h,!0)},o.prototype.removeListener=function(u,d,h,f){var p=r?r+u:u;if(!this._events[p])return this;if(!d)return a(this,p),this;var m=this._events[p];if(m.fn)m.fn===d&&(!f||m.once)&&(!h||m.context===h)&&a(this,p);else{for(var g=0,x=[],y=m.length;g<y;g++)(m[g].fn!==d||f&&!m[g].once||h&&m[g].context!==h)&&x.push(m[g]);x.length?this._events[p]=x.length===1?x[0]:x:a(this,p)}return this},o.prototype.removeAllListeners=function(u){var d;return u?(d=r?r+u:u,this._events[d]&&a(this,d)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,t.exports=o})(ove);var yyt=ove.exports;const xyt=cr(yyt);var T4=new xyt,P4="recharts.syncMouseEvents";function Jj(t){"@babel/helpers - typeof";return Jj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Jj(t)}function vyt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function byt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,lve(n.key),n)}}function wyt(t,e,r){return e&&byt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function O4(t,e,r){return e=lve(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function lve(t){var e=Syt(t,"string");return Jj(e)=="symbol"?e:e+""}function Syt(t,e){if(Jj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(Jj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var _yt=function(){function t(){vyt(this,t),O4(this,"activeIndex",0),O4(this,"coordinateList",[]),O4(this,"layout","horizontal")}return wyt(t,[{key:"setDetails",value:function(r){var n,s=r.coordinateList,i=s===void 0?null:s,a=r.container,o=a===void 0?null:a,c=r.layout,u=c===void 0?null:c,d=r.offset,h=d===void 0?null:d,f=r.mouseHandlerCallback,p=f===void 0?null:f;this.coordinateList=(n=i??this.coordinateList)!==null&&n!==void 0?n:[],this.container=o??this.container,this.layout=u??this.layout,this.offset=h??this.offset,this.mouseHandlerCallback=p??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:"focus",value:function(){this.spoofMouse()}},{key:"keyboardEvent",value:function(r){if(this.coordinateList.length!==0)switch(r.key){case"ArrowRight":{if(this.layout!=="horizontal")return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break}case"ArrowLeft":{if(this.layout!=="horizontal")return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break}}}},{key:"setIndex",value:function(r){this.activeIndex=r}},{key:"spoofMouse",value:function(){var r,n;if(this.layout==="horizontal"&&this.coordinateList.length!==0){var s=this.container.getBoundingClientRect(),i=s.x,a=s.y,o=s.height,c=this.coordinateList[this.activeIndex].coordinate,u=((r=window)===null||r===void 0?void 0:r.scrollX)||0,d=((n=window)===null||n===void 0?void 0:n.scrollY)||0,h=i+c+u,f=a+this.offset.top+o/2+d;this.mouseHandlerCallback({pageX:h,pageY:f})}}}])}();function jyt(t,e,r){if(r==="number"&&e===!0&&Array.isArray(t)){var n=t==null?void 0:t[0],s=t==null?void 0:t[1];if(n&&s&&ut(n)&&ut(s))return!0}return!1}function kyt(t,e,r,n){var s=n/2;return{stroke:"none",fill:"#ccc",x:t==="horizontal"?e.x-s:r.left+.5,y:t==="horizontal"?r.top+.5:e.y-s,width:t==="horizontal"?n:r.width-1,height:t==="horizontal"?r.height-1:n}}function cve(t){var e=t.cx,r=t.cy,n=t.radius,s=t.startAngle,i=t.endAngle,a=nn(e,r,n,s),o=nn(e,r,n,i);return{points:[a,o],cx:e,cy:r,radius:n,startAngle:s,endAngle:i}}function Nyt(t,e,r){var n,s,i,a;if(t==="horizontal")n=e.x,i=n,s=r.top,a=r.top+r.height;else if(t==="vertical")s=e.y,a=s,n=r.left,i=r.left+r.width;else if(e.cx!=null&&e.cy!=null)if(t==="centric"){var o=e.cx,c=e.cy,u=e.innerRadius,d=e.outerRadius,h=e.angle,f=nn(o,c,u,h),p=nn(o,c,d,h);n=f.x,s=f.y,i=p.x,a=p.y}else return cve(e);return[{x:n,y:s},{x:i,y:a}]}function Qj(t){"@babel/helpers - typeof";return Qj=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Qj(t)}function ite(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function iC(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ite(Object(r),!0).forEach(function(n){Eyt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ite(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Eyt(t,e,r){return e=Ayt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ayt(t){var e=Cyt(t,"string");return Qj(e)=="symbol"?e:e+""}function Cyt(t,e){if(Qj(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Qj(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Tyt(t){var e,r,n=t.element,s=t.tooltipEventType,i=t.isActive,a=t.activeCoordinate,o=t.activePayload,c=t.offset,u=t.activeTooltipIndex,d=t.tooltipAxisBandSize,h=t.layout,f=t.chartName,p=(e=n.props.cursor)!==null&&e!==void 0?e:(r=n.type.defaultProps)===null||r===void 0?void 0:r.cursor;if(!n||!p||!i||!a||f!=="ScatterChart"&&s!=="axis")return null;var m,g=FB;if(f==="ScatterChart")m=a,g=$ft;else if(f==="BarChart")m=kyt(h,a,c,d),g=j9;else if(h==="radial"){var x=cve(a),y=x.cx,v=x.cy,b=x.radius,w=x.startAngle,S=x.endAngle;m={cx:y,cy:v,startAngle:w,endAngle:S,innerRadius:b,outerRadius:b},g=Nxe}else m={points:Nyt(h,a,c)},g=FB;var k=iC(iC(iC(iC({stroke:"#ccc",pointerEvents:"none"},c),m),Gt(p,!1)),{},{payload:o,payloadIndex:u,className:mr("recharts-tooltip-cursor",p.className)});return j.isValidElement(p)?j.cloneElement(p,k):j.createElement(g,k)}var Pyt=["item"],Oyt=["children","className","width","height","style","compact","title","desc"];function xw(t){"@babel/helpers - typeof";return xw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xw(t)}function Bv(){return Bv=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Bv.apply(this,arguments)}function ate(t,e){return Myt(t)||Ryt(t,e)||dve(t,e)||Iyt()}function Iyt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ryt(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,o=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(o.push(n.value),o.length!==e);c=!0);}catch(d){u=!0,s=d}finally{try{if(!c&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw s}}return o}}function Myt(t){if(Array.isArray(t))return t}function ote(t,e){if(t==null)return{};var r=Dyt(t,e),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(s=0;s<i.length;s++)n=i[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Dyt(t,e){if(t==null)return{};var r={};for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(e.indexOf(n)>=0)continue;r[n]=t[n]}return r}function Lyt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Fyt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,hve(n.key),n)}}function $yt(t,e,r){return e&&Fyt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Byt(t,e,r){return e=oO(e),zyt(t,uve()?Reflect.construct(e,r||[],oO(t).constructor):e.apply(t,r))}function zyt(t,e){if(e&&(xw(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Uyt(t)}function Uyt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function uve(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(uve=function(){return!!t})()}function oO(t){return oO=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},oO(t)}function Hyt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c8(t,e)}function c8(t,e){return c8=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},c8(t,e)}function vw(t){return qyt(t)||Wyt(t)||dve(t)||Vyt()}function Vyt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dve(t,e){if(t){if(typeof t=="string")return u8(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u8(t,e)}}function Wyt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function qyt(t){if(Array.isArray(t))return u8(t)}function u8(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function lte(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function Ie(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?lte(Object(r),!0).forEach(function(n){Tt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):lte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Tt(t,e,r){return e=hve(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function hve(t){var e=Gyt(t,"string");return xw(e)=="symbol"?e:e+""}function Gyt(t,e){if(xw(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(xw(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Kyt={xAxis:["bottom","top"],yAxis:["left","right"]},Yyt={width:"100%",height:"100%"},fve={x:0,y:0};function aC(t){return t}var Xyt=function(e,r){return r==="horizontal"?e.x:r==="vertical"?e.y:r==="centric"?e.angle:e.radius},Jyt=function(e,r,n,s){var i=r.find(function(d){return d&&d.index===n});if(i){if(e==="horizontal")return{x:i.coordinate,y:s.y};if(e==="vertical")return{x:s.x,y:i.coordinate};if(e==="centric"){var a=i.coordinate,o=s.radius;return Ie(Ie(Ie({},s),nn(s.cx,s.cy,o,a)),{},{angle:a,radius:o})}var c=i.coordinate,u=s.angle;return Ie(Ie(Ie({},s),nn(s.cx,s.cy,c,u)),{},{angle:u,radius:c})}return fve},RM=function(e,r){var n=r.graphicalItems,s=r.dataStartIndex,i=r.dataEndIndex,a=(n??[]).reduce(function(o,c){var u=c.props.data;return u&&u.length?[].concat(vw(o),vw(u)):o},[]);return a.length>0?a:e&&e.length&&ut(s)&&ut(i)?e.slice(s,i+1):[]};function pve(t){return t==="number"?[0,"auto"]:void 0}var d8=function(e,r,n,s){var i=e.graphicalItems,a=e.tooltipAxis,o=RM(r,e);return n<0||!i||!i.length||n>=o.length?null:i.reduce(function(c,u){var d,h=(d=u.props.data)!==null&&d!==void 0?d:r;h&&e.dataStartIndex+e.dataEndIndex!==0&&e.dataEndIndex-e.dataStartIndex>=n&&(h=h.slice(e.dataStartIndex,e.dataEndIndex+1));var f;if(a.dataKey&&!a.allowDuplicatedCategory){var p=h===void 0?o:h;f=V6(p,a.dataKey,s)}else f=h&&h[n]||o[n];return f?[].concat(vw(c),[wut(u,f)]):c},[])},cte=function(e,r,n,s){var i=s||{x:e.chartX,y:e.chartY},a=Xyt(i,n),o=e.orderedTooltipTicks,c=e.tooltipAxis,u=e.tooltipTicks,d=iut(a,o,u,c);if(d>=0&&u){var h=u[d]&&u[d].value,f=d8(e,r,d,h),p=Jyt(n,o,d,i);return{activeTooltipIndex:d,activeLabel:h,activePayload:f,activeCoordinate:p}}return null},Qyt=function(e,r){var n=r.axes,s=r.graphicalItems,i=r.axisType,a=r.axisIdKey,o=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,d=e.layout,h=e.children,f=e.stackOffset,p=vxe(d,i);return n.reduce(function(m,g){var x,y=g.type.defaultProps!==void 0?Ie(Ie({},g.type.defaultProps),g.props):g.props,v=y.type,b=y.dataKey,w=y.allowDataOverflow,S=y.allowDuplicatedCategory,k=y.scale,E=y.ticks,C=y.includeHidden,A=y[a];if(m[A])return m;var M=RM(e.data,{graphicalItems:s.filter(function(F){var V,Y=a in F.props?F.props[a]:(V=F.type.defaultProps)===null||V===void 0?void 0:V[a];return Y===A}),dataStartIndex:c,dataEndIndex:u}),z=M.length,P,W,N;jyt(y.domain,w,v)&&(P=OB(y.domain,null,w),p&&(v==="number"||k!=="auto")&&(N=S_(M,b,"category")));var U=pve(v);if(!P||P.length===0){var K,G=(K=y.domain)!==null&&K!==void 0?K:U;if(b){if(P=S_(M,b,v),v==="category"&&p){var X=GKe(P);S&&X?(W=P,P=tO(0,z)):S||(P=qZ(G,P,g).reduce(function(F,V){return F.indexOf(V)>=0?F:[].concat(vw(F),[V])},[]))}else if(v==="category")S?P=P.filter(function(F){return F!==""&&!hr(F)}):P=qZ(G,P,g).reduce(function(F,V){return F.indexOf(V)>=0||V===""||hr(V)?F:[].concat(vw(F),[V])},[]);else if(v==="number"){var H=uut(M,s.filter(function(F){var V,Y,ie=a in F.props?F.props[a]:(V=F.type.defaultProps)===null||V===void 0?void 0:V[a],Q="hide"in F.props?F.props.hide:(Y=F.type.defaultProps)===null||Y===void 0?void 0:Y.hide;return ie===A&&(C||!Q)}),b,i,d);H&&(P=H)}p&&(v==="number"||k!=="auto")&&(N=S_(M,b,"category"))}else p?P=tO(0,z):o&&o[A]&&o[A].hasStack&&v==="number"?P=f==="expand"?[0,1]:bxe(o[A].stackGroups,c,u):P=xxe(M,s.filter(function(F){var V=a in F.props?F.props[a]:F.type.defaultProps[a],Y="hide"in F.props?F.props.hide:F.type.defaultProps.hide;return V===A&&(C||!Y)}),v,d,!0);if(v==="number")P=l8(h,P,A,i,E),G&&(P=OB(G,P,w));else if(v==="category"&&G){var B=G,L=P.every(function(F){return B.indexOf(F)>=0});L&&(P=B)}}return Ie(Ie({},m),{},Tt({},A,Ie(Ie({},y),{},{axisType:i,domain:P,categoricalDomain:N,duplicateDomain:W,originalDomain:(x=y.domain)!==null&&x!==void 0?x:U,isCategorical:p,layout:d})))},{})},Zyt=function(e,r){var n=r.graphicalItems,s=r.Axis,i=r.axisType,a=r.axisIdKey,o=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,d=e.layout,h=e.children,f=RM(e.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:u}),p=f.length,m=vxe(d,i),g=-1;return n.reduce(function(x,y){var v=y.type.defaultProps!==void 0?Ie(Ie({},y.type.defaultProps),y.props):y.props,b=v[a],w=pve("number");if(!x[b]){g++;var S;return m?S=tO(0,p):o&&o[b]&&o[b].hasStack?(S=bxe(o[b].stackGroups,c,u),S=l8(h,S,b,i)):(S=OB(w,xxe(f,n.filter(function(k){var E,C,A=a in k.props?k.props[a]:(E=k.type.defaultProps)===null||E===void 0?void 0:E[a],M="hide"in k.props?k.props.hide:(C=k.type.defaultProps)===null||C===void 0?void 0:C.hide;return A===b&&!M}),"number",d),s.defaultProps.allowDataOverflow),S=l8(h,S,b,i)),Ie(Ie({},x),{},Tt({},b,Ie(Ie({axisType:i},s.defaultProps),{},{hide:!0,orientation:mc(Kyt,"".concat(i,".").concat(g%2),null),domain:S,originalDomain:w,isCategorical:m,layout:d})))}return x},{})},ext=function(e,r){var n=r.axisType,s=n===void 0?"xAxis":n,i=r.AxisComp,a=r.graphicalItems,o=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,d=e.children,h="".concat(s,"Id"),f=ju(d,i),p={};return f&&f.length?p=Qyt(e,{axes:f,graphicalItems:a,axisType:s,axisIdKey:h,stackGroups:o,dataStartIndex:c,dataEndIndex:u}):a&&a.length&&(p=Zyt(e,{Axis:i,graphicalItems:a,axisType:s,axisIdKey:h,stackGroups:o,dataStartIndex:c,dataEndIndex:u})),p},txt=function(e){var r=ev(e),n=dS(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:YW(n,function(s){return s.coordinate}),tooltipAxis:r,tooltipAxisBandSize:IB(r,n)}},ute=function(e){var r=e.children,n=e.defaultShowTooltip,s=tl(r,pw),i=0,a=0;return e.data&&e.data.length!==0&&(a=e.data.length-1),s&&s.props&&(s.props.startIndex>=0&&(i=s.props.startIndex),s.props.endIndex>=0&&(a=s.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:a,activeTooltipIndex:-1,isTooltipActive:!!n}},rxt=function(e){return!e||!e.length?!1:e.some(function(r){var n=th(r&&r.type);return n&&n.indexOf("Bar")>=0})},dte=function(e){return e==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:e==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:e==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},nxt=function(e,r){var n=e.props,s=e.graphicalItems,i=e.xAxisMap,a=i===void 0?{}:i,o=e.yAxisMap,c=o===void 0?{}:o,u=n.width,d=n.height,h=n.children,f=n.margin||{},p=tl(h,pw),m=tl(h,ob),g=Object.keys(c).reduce(function(S,k){var E=c[k],C=E.orientation;return!E.mirror&&!E.hide?Ie(Ie({},S),{},Tt({},C,S[C]+E.width)):S},{left:f.left||0,right:f.right||0}),x=Object.keys(a).reduce(function(S,k){var E=a[k],C=E.orientation;return!E.mirror&&!E.hide?Ie(Ie({},S),{},Tt({},C,mc(S,"".concat(C))+E.height)):S},{top:f.top||0,bottom:f.bottom||0}),y=Ie(Ie({},x),g),v=y.bottom;p&&(y.bottom+=p.props.height||pw.defaultProps.height),m&&r&&(y=lut(y,s,n,r));var b=u-y.left-y.right,w=d-y.top-y.bottom;return Ie(Ie({brushBottom:v},y),{},{width:Math.max(b,0),height:Math.max(w,0)})},sxt=function(e,r){if(r==="xAxis")return e[r].width;if(r==="yAxis")return e[r].height},ixt=function(e){var r=e.chartName,n=e.GraphicalChild,s=e.defaultTooltipEventType,i=s===void 0?"axis":s,a=e.validateTooltipEventTypes,o=a===void 0?["axis"]:a,c=e.axisComponents,u=e.legendContent,d=e.formatAxisMap,h=e.defaultProps,f=function(y,v){var b=v.graphicalItems,w=v.stackGroups,S=v.offset,k=v.updateId,E=v.dataStartIndex,C=v.dataEndIndex,A=y.barSize,M=y.layout,z=y.barGap,P=y.barCategoryGap,W=y.maxBarSize,N=dte(M),U=N.numericAxisName,K=N.cateAxisName,G=rxt(b),X=[];return b.forEach(function(H,B){var L=RM(y.data,{graphicalItems:[H],dataStartIndex:E,dataEndIndex:C}),F=H.type.defaultProps!==void 0?Ie(Ie({},H.type.defaultProps),H.props):H.props,V=F.dataKey,Y=F.maxBarSize,ie=F["".concat(U,"Id")],Q=F["".concat(K,"Id")],D={},R=c.reduce(function(ue,ne){var me=v["".concat(ne.axisType,"Map")],ve=F["".concat(ne.axisType,"Id")];me&&me[ve]||ne.axisType==="zAxis"||ow();var xe=me[ve];return Ie(Ie({},ue),{},Tt(Tt({},ne.axisType,xe),"".concat(ne.axisType,"Ticks"),dS(xe)))},D),J=R[K],Z=R["".concat(K,"Ticks")],ee=w&&w[ie]&&w[ie].hasStack&&vut(H,w[ie].stackGroups),re=th(H.type).indexOf("Bar")>=0,he=IB(J,Z),O=[],ae=G&&aut({barSize:A,stackGroups:w,totalSize:sxt(R,K)});if(re){var q,I,T=hr(Y)?W:Y,$=(q=(I=IB(J,Z,!0))!==null&&I!==void 0?I:T)!==null&&q!==void 0?q:0;O=out({barGap:z,barCategoryGap:P,bandSize:$!==he?$:he,sizeList:ae[Q],maxBarSize:T}),$!==he&&(O=O.map(function(ue){return Ie(Ie({},ue),{},{position:Ie(Ie({},ue.position),{},{offset:ue.position.offset-$/2})})}))}var se=H&&H.type&&H.type.getComposedData;se&&X.push({props:Ie(Ie({},se(Ie(Ie({},R),{},{displayedData:L,props:y,dataKey:V,item:H,bandSize:he,barPosition:O,offset:S,stackedData:ee,layout:M,dataStartIndex:E,dataEndIndex:C}))),{},Tt(Tt(Tt({key:H.key||"item-".concat(B)},U,R[U]),K,R[K]),"animationId",k)),childIndex:sYe(H,y.children),item:H})}),X},p=function(y,v){var b=y.props,w=y.dataStartIndex,S=y.dataEndIndex,k=y.updateId;if(!BJ({props:b}))return null;var E=b.children,C=b.layout,A=b.stackOffset,M=b.data,z=b.reverseStackOrder,P=dte(C),W=P.numericAxisName,N=P.cateAxisName,U=ju(E,n),K=yut(M,U,"".concat(W,"Id"),"".concat(N,"Id"),A,z),G=c.reduce(function(F,V){var Y="".concat(V.axisType,"Map");return Ie(Ie({},F),{},Tt({},Y,ext(b,Ie(Ie({},V),{},{graphicalItems:U,stackGroups:V.axisType===W&&K,dataStartIndex:w,dataEndIndex:S}))))},{}),X=nxt(Ie(Ie({},G),{},{props:b,graphicalItems:U}),v==null?void 0:v.legendBBox);Object.keys(G).forEach(function(F){G[F]=d(b,G[F],X,F.replace("Map",""),r)});var H=G["".concat(N,"Map")],B=txt(H),L=f(b,Ie(Ie({},G),{},{dataStartIndex:w,dataEndIndex:S,updateId:k,graphicalItems:U,stackGroups:K,offset:X}));return Ie(Ie({formattedGraphicalItems:L,graphicalItems:U,offset:X,stackGroups:K},B),G)},m=function(x){function y(v){var b,w,S;return Lyt(this,y),S=Byt(this,y,[v]),Tt(S,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Tt(S,"accessibilityManager",new _yt),Tt(S,"handleLegendBBoxUpdate",function(k){if(k){var E=S.state,C=E.dataStartIndex,A=E.dataEndIndex,M=E.updateId;S.setState(Ie({legendBBox:k},p({props:S.props,dataStartIndex:C,dataEndIndex:A,updateId:M},Ie(Ie({},S.state),{},{legendBBox:k}))))}}),Tt(S,"handleReceiveSyncEvent",function(k,E,C){if(S.props.syncId===k){if(C===S.eventEmitterSymbol&&typeof S.props.syncMethod!="function")return;S.applySyncEvent(E)}}),Tt(S,"handleBrushChange",function(k){var E=k.startIndex,C=k.endIndex;if(E!==S.state.dataStartIndex||C!==S.state.dataEndIndex){var A=S.state.updateId;S.setState(function(){return Ie({dataStartIndex:E,dataEndIndex:C},p({props:S.props,dataStartIndex:E,dataEndIndex:C,updateId:A},S.state))}),S.triggerSyncEvent({dataStartIndex:E,dataEndIndex:C})}}),Tt(S,"handleMouseEnter",function(k){var E=S.getMouseInfo(k);if(E){var C=Ie(Ie({},E),{},{isTooltipActive:!0});S.setState(C),S.triggerSyncEvent(C);var A=S.props.onMouseEnter;Xt(A)&&A(C,k)}}),Tt(S,"triggeredAfterMouseMove",function(k){var E=S.getMouseInfo(k),C=E?Ie(Ie({},E),{},{isTooltipActive:!0}):{isTooltipActive:!1};S.setState(C),S.triggerSyncEvent(C);var A=S.props.onMouseMove;Xt(A)&&A(C,k)}),Tt(S,"handleItemMouseEnter",function(k){S.setState(function(){return{isTooltipActive:!0,activeItem:k,activePayload:k.tooltipPayload,activeCoordinate:k.tooltipPosition||{x:k.cx,y:k.cy}}})}),Tt(S,"handleItemMouseLeave",function(){S.setState(function(){return{isTooltipActive:!1}})}),Tt(S,"handleMouseMove",function(k){k.persist(),S.throttleTriggeredAfterMouseMove(k)}),Tt(S,"handleMouseLeave",function(k){S.throttleTriggeredAfterMouseMove.cancel();var E={isTooltipActive:!1};S.setState(E),S.triggerSyncEvent(E);var C=S.props.onMouseLeave;Xt(C)&&C(E,k)}),Tt(S,"handleOuterEvent",function(k){var E=nYe(k),C=mc(S.props,"".concat(E));if(E&&Xt(C)){var A,M;/.*touch.*/i.test(E)?M=S.getMouseInfo(k.changedTouches[0]):M=S.getMouseInfo(k),C((A=M)!==null&&A!==void 0?A:{},k)}}),Tt(S,"handleClick",function(k){var E=S.getMouseInfo(k);if(E){var C=Ie(Ie({},E),{},{isTooltipActive:!0});S.setState(C),S.triggerSyncEvent(C);var A=S.props.onClick;Xt(A)&&A(C,k)}}),Tt(S,"handleMouseDown",function(k){var E=S.props.onMouseDown;if(Xt(E)){var C=S.getMouseInfo(k);E(C,k)}}),Tt(S,"handleMouseUp",function(k){var E=S.props.onMouseUp;if(Xt(E)){var C=S.getMouseInfo(k);E(C,k)}}),Tt(S,"handleTouchMove",function(k){k.changedTouches!=null&&k.changedTouches.length>0&&S.throttleTriggeredAfterMouseMove(k.changedTouches[0])}),Tt(S,"handleTouchStart",function(k){k.changedTouches!=null&&k.changedTouches.length>0&&S.handleMouseDown(k.changedTouches[0])}),Tt(S,"handleTouchEnd",function(k){k.changedTouches!=null&&k.changedTouches.length>0&&S.handleMouseUp(k.changedTouches[0])}),Tt(S,"handleDoubleClick",function(k){var E=S.props.onDoubleClick;if(Xt(E)){var C=S.getMouseInfo(k);E(C,k)}}),Tt(S,"handleContextMenu",function(k){var E=S.props.onContextMenu;if(Xt(E)){var C=S.getMouseInfo(k);E(C,k)}}),Tt(S,"triggerSyncEvent",function(k){S.props.syncId!==void 0&&T4.emit(P4,S.props.syncId,k,S.eventEmitterSymbol)}),Tt(S,"applySyncEvent",function(k){var E=S.props,C=E.layout,A=E.syncMethod,M=S.state.updateId,z=k.dataStartIndex,P=k.dataEndIndex;if(k.dataStartIndex!==void 0||k.dataEndIndex!==void 0)S.setState(Ie({dataStartIndex:z,dataEndIndex:P},p({props:S.props,dataStartIndex:z,dataEndIndex:P,updateId:M},S.state)));else if(k.activeTooltipIndex!==void 0){var W=k.chartX,N=k.chartY,U=k.activeTooltipIndex,K=S.state,G=K.offset,X=K.tooltipTicks;if(!G)return;if(typeof A=="function")U=A(X,k);else if(A==="value"){U=-1;for(var H=0;H<X.length;H++)if(X[H].value===k.activeLabel){U=H;break}}var B=Ie(Ie({},G),{},{x:G.left,y:G.top}),L=Math.min(W,B.x+B.width),F=Math.min(N,B.y+B.height),V=X[U]&&X[U].value,Y=d8(S.state,S.props.data,U),ie=X[U]?{x:C==="horizontal"?X[U].coordinate:L,y:C==="horizontal"?F:X[U].coordinate}:fve;S.setState(Ie(Ie({},k),{},{activeLabel:V,activeCoordinate:ie,activePayload:Y,activeTooltipIndex:U}))}else S.setState(k)}),Tt(S,"renderCursor",function(k){var E,C=S.state,A=C.isTooltipActive,M=C.activeCoordinate,z=C.activePayload,P=C.offset,W=C.activeTooltipIndex,N=C.tooltipAxisBandSize,U=S.getTooltipEventType(),K=(E=k.props.active)!==null&&E!==void 0?E:A,G=S.props.layout,X=k.key||"_recharts-cursor";return pe.createElement(Tyt,{key:X,activeCoordinate:M,activePayload:z,activeTooltipIndex:W,chartName:r,element:k,isActive:K,layout:G,offset:P,tooltipAxisBandSize:N,tooltipEventType:U})}),Tt(S,"renderPolarAxis",function(k,E,C){var A=mc(k,"type.axisType"),M=mc(S.state,"".concat(A,"Map")),z=k.type.defaultProps,P=z!==void 0?Ie(Ie({},z),k.props):k.props,W=M&&M[P["".concat(A,"Id")]];return j.cloneElement(k,Ie(Ie({},W),{},{className:mr(A,W.className),key:k.key||"".concat(E,"-").concat(C),ticks:dS(W,!0)}))}),Tt(S,"renderPolarGrid",function(k){var E=k.props,C=E.radialLines,A=E.polarAngles,M=E.polarRadius,z=S.state,P=z.radiusAxisMap,W=z.angleAxisMap,N=ev(P),U=ev(W),K=U.cx,G=U.cy,X=U.innerRadius,H=U.outerRadius;return j.cloneElement(k,{polarAngles:Array.isArray(A)?A:dS(U,!0).map(function(B){return B.coordinate}),polarRadius:Array.isArray(M)?M:dS(N,!0).map(function(B){return B.coordinate}),cx:K,cy:G,innerRadius:X,outerRadius:H,key:k.key||"polar-grid",radialLines:C})}),Tt(S,"renderLegend",function(){var k=S.state.formattedGraphicalItems,E=S.props,C=E.children,A=E.width,M=E.height,z=S.props.margin||{},P=A-(z.left||0)-(z.right||0),W=gxe({children:C,formattedGraphicalItems:k,legendWidth:P,legendContent:u});if(!W)return null;var N=W.item,U=ote(W,Pyt);return j.cloneElement(N,Ie(Ie({},U),{},{chartWidth:A,chartHeight:M,margin:z,onBBoxUpdate:S.handleLegendBBoxUpdate}))}),Tt(S,"renderTooltip",function(){var k,E=S.props,C=E.children,A=E.accessibilityLayer,M=tl(C,id);if(!M)return null;var z=S.state,P=z.isTooltipActive,W=z.activeCoordinate,N=z.activePayload,U=z.activeLabel,K=z.offset,G=(k=M.props.active)!==null&&k!==void 0?k:P;return j.cloneElement(M,{viewBox:Ie(Ie({},K),{},{x:K.left,y:K.top}),active:G,label:U,payload:G?N:[],coordinate:W,accessibilityLayer:A})}),Tt(S,"renderBrush",function(k){var E=S.props,C=E.margin,A=E.data,M=S.state,z=M.offset,P=M.dataStartIndex,W=M.dataEndIndex,N=M.updateId;return j.cloneElement(k,{key:k.key||"_recharts-brush",onChange:eC(S.handleBrushChange,k.props.onChange),data:A,x:ut(k.props.x)?k.props.x:z.left,y:ut(k.props.y)?k.props.y:z.top+z.height+z.brushBottom-(C.bottom||0),width:ut(k.props.width)?k.props.width:z.width,startIndex:P,endIndex:W,updateId:"brush-".concat(N)})}),Tt(S,"renderReferenceElement",function(k,E,C){if(!k)return null;var A=S,M=A.clipPathId,z=S.state,P=z.xAxisMap,W=z.yAxisMap,N=z.offset,U=k.type.defaultProps||{},K=k.props,G=K.xAxisId,X=G===void 0?U.xAxisId:G,H=K.yAxisId,B=H===void 0?U.yAxisId:H;return j.cloneElement(k,{key:k.key||"".concat(E,"-").concat(C),xAxis:P[X],yAxis:W[B],viewBox:{x:N.left,y:N.top,width:N.width,height:N.height},clipPathId:M})}),Tt(S,"renderActivePoints",function(k){var E=k.item,C=k.activePoint,A=k.basePoint,M=k.childIndex,z=k.isRange,P=[],W=E.props.key,N=E.item.type.defaultProps!==void 0?Ie(Ie({},E.item.type.defaultProps),E.item.props):E.item.props,U=N.activeDot,K=N.dataKey,G=Ie(Ie({index:M,dataKey:K,cx:C.x,cy:C.y,r:4,fill:_9(E.item),strokeWidth:2,stroke:"#fff",payload:C.payload,value:C.value},Gt(U,!1)),gP(U));return P.push(y.renderActiveDot(U,G,"".concat(W,"-activePoint-").concat(M))),A?P.push(y.renderActiveDot(U,Ie(Ie({},G),{},{cx:A.x,cy:A.y}),"".concat(W,"-basePoint-").concat(M))):z&&P.push(null),P}),Tt(S,"renderGraphicChild",function(k,E,C){var A=S.filterFormatItem(k,E,C);if(!A)return null;var M=S.getTooltipEventType(),z=S.state,P=z.isTooltipActive,W=z.tooltipAxis,N=z.activeTooltipIndex,U=z.activeLabel,K=S.props.children,G=tl(K,id),X=A.props,H=X.points,B=X.isRange,L=X.baseLine,F=A.item.type.defaultProps!==void 0?Ie(Ie({},A.item.type.defaultProps),A.item.props):A.item.props,V=F.activeDot,Y=F.hide,ie=F.activeBar,Q=F.activeShape,D=!!(!Y&&P&&G&&(V||ie||Q)),R={};M!=="axis"&&G&&G.props.trigger==="click"?R={onClick:eC(S.handleItemMouseEnter,k.props.onClick)}:M!=="axis"&&(R={onMouseLeave:eC(S.handleItemMouseLeave,k.props.onMouseLeave),onMouseEnter:eC(S.handleItemMouseEnter,k.props.onMouseEnter)});var J=j.cloneElement(k,Ie(Ie({},A.props),R));function Z(ne){return typeof W.dataKey=="function"?W.dataKey(ne.payload):null}if(D)if(N>=0){var ee,re;if(W.dataKey&&!W.allowDuplicatedCategory){var he=typeof W.dataKey=="function"?Z:"payload.".concat(W.dataKey.toString());ee=V6(H,he,U),re=B&&L&&V6(L,he,U)}else ee=H==null?void 0:H[N],re=B&&L&&L[N];if(Q||ie){var O=k.props.activeIndex!==void 0?k.props.activeIndex:N;return[j.cloneElement(k,Ie(Ie(Ie({},A.props),R),{},{activeIndex:O})),null,null]}if(!hr(ee))return[J].concat(vw(S.renderActivePoints({item:A,activePoint:ee,basePoint:re,childIndex:N,isRange:B})))}else{var ae,q=(ae=S.getItemByXY(S.state.activeCoordinate))!==null&&ae!==void 0?ae:{graphicalItem:J},I=q.graphicalItem,T=I.item,$=T===void 0?k:T,se=I.childIndex,ue=Ie(Ie(Ie({},A.props),R),{},{activeIndex:se});return[j.cloneElement($,ue),null,null]}return B?[J,null,null]:[J,null]}),Tt(S,"renderCustomized",function(k,E,C){return j.cloneElement(k,Ie(Ie({key:"recharts-customized-".concat(C)},S.props),S.state))}),Tt(S,"renderMap",{CartesianGrid:{handler:aC,once:!0},ReferenceArea:{handler:S.renderReferenceElement},ReferenceLine:{handler:aC},ReferenceDot:{handler:S.renderReferenceElement},XAxis:{handler:aC},YAxis:{handler:aC},Brush:{handler:S.renderBrush,once:!0},Bar:{handler:S.renderGraphicChild},Line:{handler:S.renderGraphicChild},Area:{handler:S.renderGraphicChild},Radar:{handler:S.renderGraphicChild},RadialBar:{handler:S.renderGraphicChild},Scatter:{handler:S.renderGraphicChild},Pie:{handler:S.renderGraphicChild},Funnel:{handler:S.renderGraphicChild},Tooltip:{handler:S.renderCursor,once:!0},PolarGrid:{handler:S.renderPolarGrid,once:!0},PolarAngleAxis:{handler:S.renderPolarAxis},PolarRadiusAxis:{handler:S.renderPolarAxis},Customized:{handler:S.renderCustomized}}),S.clipPathId="".concat((b=v.id)!==null&&b!==void 0?b:sM("recharts"),"-clip"),S.throttleTriggeredAfterMouseMove=pye(S.triggeredAfterMouseMove,(w=v.throttleDelay)!==null&&w!==void 0?w:1e3/60),S.state={},S}return Hyt(y,x),$yt(y,[{key:"componentDidMount",value:function(){var b,w;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(b=this.props.margin.left)!==null&&b!==void 0?b:0,top:(w=this.props.margin.top)!==null&&w!==void 0?w:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var b=this.props,w=b.children,S=b.data,k=b.height,E=b.layout,C=tl(w,id);if(C){var A=C.props.defaultIndex;if(!(typeof A!="number"||A<0||A>this.state.tooltipTicks.length-1)){var M=this.state.tooltipTicks[A]&&this.state.tooltipTicks[A].value,z=d8(this.state,S,A,M),P=this.state.tooltipTicks[A].coordinate,W=(this.state.offset.top+k)/2,N=E==="horizontal",U=N?{x:P,y:W}:{y:P,x:W},K=this.state.formattedGraphicalItems.find(function(X){var H=X.item;return H.type.name==="Scatter"});K&&(U=Ie(Ie({},U),K.props.points[A].tooltipPosition),z=K.props.points[A].tooltipPayload);var G={activeTooltipIndex:A,isTooltipActive:!0,activeLabel:M,activePayload:z,activeCoordinate:U};this.setState(G),this.renderCursor(C),this.accessibilityManager.setIndex(A)}}}},{key:"getSnapshotBeforeUpdate",value:function(b,w){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==w.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==b.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==b.margin){var S,k;this.accessibilityManager.setDetails({offset:{left:(S=this.props.margin.left)!==null&&S!==void 0?S:0,top:(k=this.props.margin.top)!==null&&k!==void 0?k:0}})}return null}},{key:"componentDidUpdate",value:function(b){G6([tl(b.children,id)],[tl(this.props.children,id)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var b=tl(this.props.children,id);if(b&&typeof b.props.shared=="boolean"){var w=b.props.shared?"axis":"item";return o.indexOf(w)>=0?w:i}return i}},{key:"getMouseInfo",value:function(b){if(!this.container)return null;var w=this.container,S=w.getBoundingClientRect(),k=Iit(S),E={chartX:Math.round(b.pageX-k.left),chartY:Math.round(b.pageY-k.top)},C=S.width/w.offsetWidth||1,A=this.inRange(E.chartX,E.chartY,C);if(!A)return null;var M=this.state,z=M.xAxisMap,P=M.yAxisMap,W=this.getTooltipEventType(),N=cte(this.state,this.props.data,this.props.layout,A);if(W!=="axis"&&z&&P){var U=ev(z).scale,K=ev(P).scale,G=U&&U.invert?U.invert(E.chartX):null,X=K&&K.invert?K.invert(E.chartY):null;return Ie(Ie({},E),{},{xValue:G,yValue:X},N)}return N?Ie(Ie({},E),N):null}},{key:"inRange",value:function(b,w){var S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,k=this.props.layout,E=b/S,C=w/S;if(k==="horizontal"||k==="vertical"){var A=this.state.offset,M=E>=A.left&&E<=A.left+A.width&&C>=A.top&&C<=A.top+A.height;return M?{x:E,y:C}:null}var z=this.state,P=z.angleAxisMap,W=z.radiusAxisMap;if(P&&W){var N=ev(P);return YZ({x:E,y:C},N)}return null}},{key:"parseEventsOfWrapper",value:function(){var b=this.props.children,w=this.getTooltipEventType(),S=tl(b,id),k={};S&&w==="axis"&&(S.props.trigger==="click"?k={onClick:this.handleClick}:k={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var E=gP(this.props,this.handleOuterEvent);return Ie(Ie({},E),k)}},{key:"addListener",value:function(){T4.on(P4,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){T4.removeListener(P4,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(b,w,S){for(var k=this.state.formattedGraphicalItems,E=0,C=k.length;E<C;E++){var A=k[E];if(A.item===b||A.props.key===b.key||w===th(A.item.type)&&S===A.childIndex)return A}return null}},{key:"renderClipPath",value:function(){var b=this.clipPathId,w=this.state.offset,S=w.left,k=w.top,E=w.height,C=w.width;return pe.createElement("defs",null,pe.createElement("clipPath",{id:b},pe.createElement("rect",{x:S,y:k,height:E,width:C})))}},{key:"getXScales",value:function(){var b=this.state.xAxisMap;return b?Object.entries(b).reduce(function(w,S){var k=ate(S,2),E=k[0],C=k[1];return Ie(Ie({},w),{},Tt({},E,C.scale))},{}):null}},{key:"getYScales",value:function(){var b=this.state.yAxisMap;return b?Object.entries(b).reduce(function(w,S){var k=ate(S,2),E=k[0],C=k[1];return Ie(Ie({},w),{},Tt({},E,C.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(b){var w;return(w=this.state.xAxisMap)===null||w===void 0||(w=w[b])===null||w===void 0?void 0:w.scale}},{key:"getYScaleByAxisId",value:function(b){var w;return(w=this.state.yAxisMap)===null||w===void 0||(w=w[b])===null||w===void 0?void 0:w.scale}},{key:"getItemByXY",value:function(b){var w=this.state,S=w.formattedGraphicalItems,k=w.activeItem;if(S&&S.length)for(var E=0,C=S.length;E<C;E++){var A=S[E],M=A.props,z=A.item,P=z.type.defaultProps!==void 0?Ie(Ie({},z.type.defaultProps),z.props):z.props,W=th(z.type);if(W==="Bar"){var N=(M.data||[]).find(function(X){return vft(b,X)});if(N)return{graphicalItem:A,payload:N}}else if(W==="RadialBar"){var U=(M.data||[]).find(function(X){return YZ(b,X)});if(U)return{graphicalItem:A,payload:U}}else if(AM(A,k)||CM(A,k)||Kj(A,k)){var K=lmt({graphicalItem:A,activeTooltipItem:k,itemData:P.data}),G=P.activeIndex===void 0?K:P.activeIndex;return{graphicalItem:Ie(Ie({},A),{},{childIndex:G}),payload:Kj(A,k)?P.data[K]:A.props.data[K]}}}return null}},{key:"render",value:function(){var b=this;if(!BJ(this))return null;var w=this.props,S=w.children,k=w.className,E=w.width,C=w.height,A=w.style,M=w.compact,z=w.title,P=w.desc,W=ote(w,Oyt),N=Gt(W,!1);if(M)return pe.createElement(Xee,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},pe.createElement(Y6,Bv({},N,{width:E,height:C,title:z,desc:P}),this.renderClipPath(),UJ(S,this.renderMap)));if(this.props.accessibilityLayer){var U,K;N.tabIndex=(U=this.props.tabIndex)!==null&&U!==void 0?U:0,N.role=(K=this.props.role)!==null&&K!==void 0?K:"application",N.onKeyDown=function(X){b.accessibilityManager.keyboardEvent(X)},N.onFocus=function(){b.accessibilityManager.focus()}}var G=this.parseEventsOfWrapper();return pe.createElement(Xee,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},pe.createElement("div",Bv({className:mr("recharts-wrapper",k),style:Ie({position:"relative",cursor:"default",width:E,height:C},A)},G,{ref:function(H){b.container=H}}),pe.createElement(Y6,Bv({},N,{width:E,height:C,title:z,desc:P,style:Yyt}),this.renderClipPath(),UJ(S,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(j.Component);Tt(m,"displayName",r),Tt(m,"defaultProps",Ie({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},h)),Tt(m,"getDerivedStateFromProps",function(x,y){var v=x.dataKey,b=x.data,w=x.children,S=x.width,k=x.height,E=x.layout,C=x.stackOffset,A=x.margin,M=y.dataStartIndex,z=y.dataEndIndex;if(y.updateId===void 0){var P=ute(x);return Ie(Ie(Ie({},P),{},{updateId:0},p(Ie(Ie({props:x},P),{},{updateId:0}),y)),{},{prevDataKey:v,prevData:b,prevWidth:S,prevHeight:k,prevLayout:E,prevStackOffset:C,prevMargin:A,prevChildren:w})}if(v!==y.prevDataKey||b!==y.prevData||S!==y.prevWidth||k!==y.prevHeight||E!==y.prevLayout||C!==y.prevStackOffset||!W6(A,y.prevMargin)){var W=ute(x),N={chartX:y.chartX,chartY:y.chartY,isTooltipActive:y.isTooltipActive},U=Ie(Ie({},cte(y,b,E)),{},{updateId:y.updateId+1}),K=Ie(Ie(Ie({},W),N),U);return Ie(Ie(Ie({},K),p(Ie({props:x},K),y)),{},{prevDataKey:v,prevData:b,prevWidth:S,prevHeight:k,prevLayout:E,prevStackOffset:C,prevMargin:A,prevChildren:w})}if(!G6(w,y.prevChildren)){var G,X,H,B,L=tl(w,pw),F=L&&(G=(X=L.props)===null||X===void 0?void 0:X.startIndex)!==null&&G!==void 0?G:M,V=L&&(H=(B=L.props)===null||B===void 0?void 0:B.endIndex)!==null&&H!==void 0?H:z,Y=F!==M||V!==z,ie=!hr(b),Q=ie&&!Y?y.updateId:y.updateId+1;return Ie(Ie({updateId:Q},p(Ie(Ie({props:x},y),{},{updateId:Q,dataStartIndex:F,dataEndIndex:V}),y)),{},{prevChildren:w,dataStartIndex:F,dataEndIndex:V})}return null}),Tt(m,"renderActiveDot",function(x,y,v){var b;return j.isValidElement(x)?b=j.cloneElement(x,y):Xt(x)?b=x(y):b=pe.createElement(k9,y),pe.createElement(Vn,{className:"recharts-active-dot",key:v},b)});var g=j.forwardRef(function(y,v){return pe.createElement(m,Bv({},y,{ref:v}))});return g.displayName=m.displayName,g},mve=ixt({chartName:"PieChart",GraphicalChild:Fu,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:EM},{axisType:"radiusAxis",AxisComp:kM}],formatAxisMap:Tut,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});function axt(){const{studentPoints:t}=Dt(),e=(t==null?void 0:t.remaining)||0,r=(t==null?void 0:t.total)||0,n=r>0?e/r*100:0,s=[{name:"remaining",value:n},{name:"used",value:Math.max(0,100-n)}],a=(o=>o>=50?"hsl(var(--success))":o>=25?"hsl(var(--warning))":"hsl(var(--destructive))")(n);return l.jsx(ze,{className:"astro-card h-full overflow-hidden",children:l.jsxs(Ge,{className:"py-4 px-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Student Points"}),n<25&&l.jsxs("div",{className:"flex items-center gap-1 text-destructive",children:[l.jsx(ePe,{className:"w-3 h-3"}),l.jsx("span",{className:"text-xs font-medium",children:"Low"})]})]}),l.jsxs("div",{className:"relative h-[140px]",children:[l.jsx(mye,{width:"100%",height:"100%",children:l.jsxs(mve,{children:[l.jsx("defs",{children:l.jsxs("filter",{id:"glow-sp",children:[l.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),l.jsxs("feMerge",{children:[l.jsx("feMergeNode",{in:"coloredBlur"}),l.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),l.jsxs(Fu,{data:s,cx:"50%",cy:"50%",innerRadius:45,outerRadius:60,startAngle:90,endAngle:-270,paddingAngle:2,dataKey:"value",strokeWidth:0,filter:n>=50?"url(#glow-sp)":void 0,children:[l.jsx(rw,{fill:a}),l.jsx(rw,{fill:"hsl(var(--muted))"})]})]})}),l.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:l.jsxs("span",{className:"text-3xl font-bold text-foreground",children:[Math.round(n),"%"]})})]}),l.jsx("div",{className:"text-center mt-1",children:l.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(n),"% of ",r.toLocaleString()," SP remaining"]})})]})})}function oxt({stats:t}){const e=Or(),r=[{label:"Create Coding",icon:Cce,onClick:()=>e("/qualitative/kodieren"),variant:"outline"},{label:"Create Analysis",icon:qy,onClick:()=>e("/qualitative/auswertung"),variant:"outline"},{label:"Show Codebook Grid",icon:v2e,onClick:()=>e("/qualitative/kodierbogen-grid"),variant:"outline"}],n=[];((t==null?void 0:t.total_documents)||0)===0&&n.push({label:"Upload Literature",icon:hh,onClick:()=>e("/my-documents"),variant:"default"}),((t==null?void 0:t.total_documents)||0)>0&&((t==null?void 0:t.total_theories)||0)===0&&n.push({label:"Generate Theory",icon:ps,onClick:()=>e("/theory-builder"),variant:"default"}),((t==null?void 0:t.total_documents)||0)>0&&((t==null?void 0:t.total_summaries)||0)===0&&n.push({label:"Create Summary",icon:Br,onClick:()=>e("/new-summary"),variant:"outline"}),!(t!=null&&t.active_thesis_id)&&((t==null?void 0:t.total_theses)||0)===0&&n.push({label:"Create Thesis",icon:ps,onClick:()=>e("/thesis-manager"),variant:"default"}),((t==null?void 0:t.total_documents)||0)>0&&((t==null?void 0:t.total_methods)||0)===0&&n.push({label:"Create Methodology",icon:$2,onClick:()=>e("/methods-approach"),variant:"outline"});const s=n.slice(0,3);return l.jsxs(ze,{className:"h-full",children:[l.jsx(et,{className:"pb-3",children:l.jsx(at,{className:"flex items-center gap-2 text-base",children:"Quick Actions"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsx("div",{className:"space-y-2",children:l.jsx("div",{className:"space-y-2",children:r.map((i,a)=>l.jsxs(ye,{variant:i.variant,size:"sm",className:"w-full justify-start",onClick:i.onClick,children:[l.jsx(i.icon,{className:"h-4 w-4 mr-2"}),i.label]},a))})}),s.length>0&&l.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Suggested"}),l.jsx("div",{className:"space-y-2",children:s.map((i,a)=>l.jsxs(ye,{variant:i.variant,size:"sm",className:"w-full justify-start",onClick:i.onClick,children:[l.jsx(i.icon,{className:"h-4 w-4 mr-2"}),i.label]},a))})]})]})]})}function gve(){return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsx(ze,{className:"lg:col-span-2 astro-card",children:l.jsxs("div",{className:"flex items-center gap-6 p-6",children:[l.jsx(Sr,{className:"h-20 w-20 rounded-full"}),l.jsxs("div",{className:"space-y-3",children:[l.jsx(Sr,{className:"h-4 w-24"}),l.jsx(Sr,{className:"h-8 w-48"}),l.jsx(Sr,{className:"h-6 w-64"})]})]})}),l.jsx(ze,{className:"astro-card",children:l.jsxs(Ge,{className:"py-4 px-4",children:[l.jsx(Sr,{className:"h-4 w-24 mb-2"}),l.jsx("div",{className:"flex items-center justify-center h-[140px]",children:l.jsx(Sr,{className:"h-[120px] w-[120px] rounded-full"})}),l.jsx(Sr,{className:"h-4 w-32 mx-auto mt-1"})]})})]}),l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[1,2,3].map(t=>l.jsx(ze,{className:"astro-card",children:l.jsxs(Ge,{className:"py-3 px-4",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsx(Sr,{className:"h-7 w-7 rounded-lg"}),l.jsx(Sr,{className:"h-4 w-20"})]}),l.jsx("div",{className:"flex items-center justify-center h-[70px]",children:l.jsx(Sr,{className:"h-16 w-32 rounded-t-full"})})]})},t))}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsxs(ze,{className:"astro-card",children:[l.jsx(et,{children:l.jsx(Sr,{className:"h-6 w-32"})}),l.jsxs(Ge,{className:"space-y-3",children:[l.jsx(Sr,{className:"h-12 w-full"}),l.jsx(Sr,{className:"h-4 w-3/4"})]})]}),l.jsxs(ze,{className:"astro-card",children:[l.jsx(et,{children:l.jsx(Sr,{className:"h-6 w-40"})}),l.jsxs(Ge,{className:"space-y-3",children:[l.jsx(Sr,{className:"h-12 w-full"}),l.jsx(Sr,{className:"h-4 w-3/4"})]})]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsxs(ze,{className:"astro-card",children:[l.jsx(et,{children:l.jsx(Sr,{className:"h-6 w-36"})}),l.jsx(Ge,{className:"space-y-3",children:l.jsxs("div",{className:"flex justify-between",children:[l.jsx(Sr,{className:"h-10 w-16"}),l.jsx(Sr,{className:"h-10 w-16"}),l.jsx(Sr,{className:"h-10 w-16"})]})})]}),l.jsxs(ze,{className:"astro-card",children:[l.jsx(et,{children:l.jsx(Sr,{className:"h-6 w-44"})}),l.jsx(Ge,{className:"space-y-3",children:l.jsxs("div",{className:"flex justify-between",children:[l.jsx(Sr,{className:"h-10 w-16"}),l.jsx(Sr,{className:"h-10 w-16"}),l.jsx(Sr,{className:"h-10 w-16"})]})})]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[l.jsxs(ze,{className:"astro-card",children:[l.jsx(et,{children:l.jsx(Sr,{className:"h-6 w-32"})}),l.jsx(Ge,{children:l.jsx(Sr,{className:"h-16 w-full"})})]}),l.jsxs(ze,{className:"astro-card",children:[l.jsx(et,{children:l.jsx(Sr,{className:"h-6 w-28"})}),l.jsxs(Ge,{className:"space-y-2",children:[l.jsx(Sr,{className:"h-10 w-full"}),l.jsx(Sr,{className:"h-10 w-full"})]})]})]})]})}const hte=["Focus is key.","Let's make some progress.","Action time.","You've got this.","Great to see you working.","Keep the momentum.","Power through.","Another productive day.","Let's dive in.","Good work day ahead.","Onward and upward."];function lxt({stats:t}){const{researchProfile:e}=Dt(),[r,n]=j.useState(null),s=(e==null?void 0:e.nickname)||"Researcher",i=t==null?void 0:t.active_thesis_title;j.useEffect(()=>{(async()=>{const u=await sb(e==null?void 0:e.avatar_url);n(u)})()},[e==null?void 0:e.avatar_url]);const a=j.useMemo(()=>hte[Math.floor(Math.random()*hte.length)],[]),o=s.split(" ").map(c=>c[0]).join("").toUpperCase().slice(0,2);return l.jsxs("div",{className:"flex items-center gap-6 p-6",children:[l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"absolute -inset-1 bg-gradient-to-r from-primary via-primary/60 to-primary/30 rounded-full blur-sm opacity-60"}),l.jsxs(NR,{className:"relative h-20 w-20 ring-4 ring-primary/20 ring-offset-2 ring-offset-background",children:[l.jsx(ER,{src:r||void 0,alt:s,className:"object-cover"}),l.jsx(AR,{className:"bg-gradient-to-br from-primary/20 to-primary/5 text-primary text-2xl font-bold",children:o||"R"})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Qs,{className:"w-5 h-5 text-primary/70"}),l.jsx("span",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide",children:"Welcome back"})]}),l.jsx("h2",{className:"text-3xl font-bold text-foreground",children:s}),i?l.jsxs("div",{className:"mt-1 space-y-1",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[l.jsx("span",{children:"Working on "}),l.jsx("span",{className:"font-medium text-foreground",children:i})]}),l.jsx("p",{className:"text-muted-foreground/70 italic mt-2 my-[22px] text-sm",children:a})]}):l.jsx("p",{className:"text-sm text-muted-foreground",children:"Ready to start your research journey?"})]})]})}function cxt({stats:t}){const e=(t==null?void 0:t.active_thesis_progress)??0,r=t==null?void 0:t.active_thesis_title,n=o=>o<=25?"The start is made.":o<=50?"Well on your way! Keep the pace.":o<=75?"Halfway done and you're great!":"The final stretch is on. Almost there!",s=[{name:"completed",value:e},{name:"remaining",value:Math.max(0,100-e)}],i=o=>o>=75?"hsl(var(--success))":o>=50?"hsl(var(--warning))":o>=25?"hsl(var(--primary))":"hsl(var(--muted-foreground))";if(!r)return l.jsx(ze,{className:"astro-card h-full",children:l.jsxs(Ge,{className:"flex flex-col items-center justify-center h-full py-8",children:[l.jsx("div",{className:"w-16 h-16 rounded-full bg-muted/50 flex items-center justify-center mb-4",children:l.jsx(Oce,{className:"w-8 h-8 text-muted-foreground"})}),l.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No active thesis yet"}),l.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1",children:"Create one to track progress"})]})});const a=i(e);return l.jsx(ze,{className:"astro-card h-full overflow-hidden",children:l.jsxs(Ge,{className:"py-4 px-4",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Thesis Progress"}),e>=50&&l.jsxs("div",{className:"flex items-center gap-1 text-success",children:[l.jsx(tPe,{className:"w-3 h-3"}),l.jsx("span",{className:"text-xs font-medium",children:"On track"})]})]}),l.jsxs("div",{className:"relative h-[140px]",children:[l.jsx(mye,{width:"100%",height:"100%",children:l.jsxs(mve,{children:[l.jsx("defs",{children:l.jsxs("filter",{id:"glow",children:[l.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),l.jsxs("feMerge",{children:[l.jsx("feMergeNode",{in:"coloredBlur"}),l.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),l.jsxs(Fu,{data:s,cx:"50%",cy:"50%",innerRadius:45,outerRadius:60,startAngle:90,endAngle:-270,paddingAngle:2,dataKey:"value",strokeWidth:0,filter:e>=50?"url(#glow)":void 0,children:[l.jsx(rw,{fill:a}),l.jsx(rw,{fill:"hsl(var(--muted))"})]})]})}),l.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:l.jsxs("span",{className:"text-4xl font-bold text-foreground",children:[Math.round(e),"%"]})})]}),l.jsx("p",{className:"text-muted-foreground text-center mt-2 italic text-sm",children:n(e)})]})})}const oC=({title:t,currentValue:e,targetValue:r,excellentThreshold:n,icon:s,progressColor:i="hsl(var(--primary))",className:a})=>{const o=j.useRef(null),c=l7e(o,{once:!0,margin:"-20%"}),{progressPercentage:u,circumference:d,strokeDashoffset:h}=j.useMemo(()=>{const m=2*Math.PI*45,g=Math.min(Math.max(e/r*100,0),100),x=m*(1-g/100);return{progressPercentage:Math.round(g),circumference:m,strokeDashoffset:x}},[e,r]),f=n&&e>=n;return l.jsx(ze,{ref:o,className:Le("astro-card",a),children:l.jsx(Ge,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("div",{className:"relative h-20 w-20 flex-shrink-0",children:[l.jsx("svg",{width:"100%",height:"100%",viewBox:"0 0 100 100",role:"img","aria-label":`Progress: ${u}%`,children:l.jsxs("g",{transform:"rotate(-90, 50, 50)",children:[l.jsx("circle",{cx:"50",cy:"50",r:"45",fill:"transparent",stroke:"hsl(var(--muted))",strokeWidth:"8"}),l.jsx(ic.circle,{cx:"50",cy:"50",r:"45",fill:"transparent",stroke:i,strokeWidth:"8",strokeLinecap:"round",strokeDasharray:d,initial:{strokeDashoffset:d},animate:c?{strokeDashoffset:h}:{},transition:{duration:1.2,ease:"easeOut"}})]})}),l.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:l.jsx(s,{className:"h-6 w-6",style:{color:i}})})]}),l.jsxs("div",{className:"flex flex-col min-w-0",children:[l.jsxs("span",{className:"text-2xl font-bold text-foreground",children:[e,l.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-1",children:["/ ",r]})]}),l.jsx("span",{className:"text-sm text-muted-foreground truncate",children:t}),f&&l.jsx("span",{className:"text-xs font-medium mt-1",style:{color:i},children:"✓ Excellent"})]})]})})})};function uxt(){const{stats:t,loading:e}=_Ue(),{userProfile:r}=Dt();return e?l.jsx(gve,{}):l.jsxs("div",{className:"space-y-4 animate-fade-in",children:[(r==null?void 0:r.plan)==="free"&&l.jsxs("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-xl p-4 mb-6 flex items-start gap-3",children:[l.jsx(Qs,{className:"h-5 w-5 text-amber-600 mt-0.5 shrink-0"}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold text-amber-900 dark:text-amber-200",children:"Welcome to Academly Beta! 🎉"}),l.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-300 mt-1",children:"As a beta tester, we've credited your account with 2,000 Student Points — enough to explore all features. Your honest feedback helps us build something great."}),l.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2",children:"Beta period · Free access · No credit card needed"})]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3 lg:gap-4",children:[l.jsx(ze,{className:"astro-card animate-slide-up",style:{animationDelay:"0ms"},children:l.jsx(lxt,{stats:t})}),l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"50ms"},children:l.jsx(axt,{})}),l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"100ms"},children:l.jsx(cxt,{stats:t})})]}),l.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 lg:gap-4",children:[l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"100ms"},children:l.jsx(oC,{currentValue:(t==null?void 0:t.total_documents)??0,targetValue:5,excellentThreshold:7,title:"Documents",icon:Br,progressColor:"hsl(var(--primary))"})}),l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"150ms"},children:l.jsx(oC,{currentValue:(t==null?void 0:t.total_theories)??0,targetValue:4,excellentThreshold:7,title:"Theory Blocks",icon:ps,progressColor:"hsl(142, 76%, 41%)"})}),l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"200ms"},children:l.jsx(oC,{currentValue:(t==null?void 0:t.total_methods)??0,targetValue:4,excellentThreshold:7,title:"Methodologies",icon:Rce,progressColor:"hsl(270, 70%, 60%)"})}),l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"250ms"},children:l.jsx(oC,{currentValue:(t==null?void 0:t.total_interviews)??0,targetValue:5,excellentThreshold:8,title:"Interviews",icon:Bce,progressColor:"hsl(38, 92%, 50%)"})})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 lg:gap-4",children:[l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"250ms"},children:l.jsx(d7e,{stats:t})}),l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"300ms"},children:l.jsx(h7e,{stats:t})})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 lg:gap-4",children:[l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"350ms"},children:l.jsx(oxt,{stats:t})}),l.jsx("div",{className:"animate-slide-up",style:{animationDelay:"400ms"},children:l.jsx(f7e,{stats:t})})]})]})}const Be=j.forwardRef(({className:t,type:e,...r},n)=>l.jsx("input",{type:e,className:Le("flex h-11 w-full rounded-lg border border-input bg-background","px-4 py-2.5 text-sm text-foreground","shadow-theme-xs","placeholder:text-muted-foreground","focus:border-brand-300 focus:outline-none focus:ring-3 focus:ring-brand-500/10","disabled:cursor-not-allowed disabled:opacity-50","dark:border-gray-800 dark:bg-gray-900 dark:text-white",t),ref:n,...r}));Be.displayName="Input";var dxt="Label",yve=j.forwardRef((t,e)=>l.jsx(ot.label,{...t,ref:e,onMouseDown:r=>{var s;r.target.closest("button, input, select, textarea")||((s=t.onMouseDown)==null||s.call(t,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));yve.displayName=dxt;var xve=yve;const hxt=Nh("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),_e=j.forwardRef(({className:t,...e},r)=>l.jsx(xve,{ref:r,className:Le(hxt(),t),...e}));_e.displayName=xve.displayName;function T9(t){const e=j.useRef({value:t,previous:t});return j.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var fxt=[" ","Enter","ArrowUp","ArrowDown"],pxt=[" ","Enter"],ex="Select",[MM,DM,mxt]=rE(ex),[h1,m5t]=gs(ex,[mxt,nm]),LM=nm(),[gxt,fm]=h1(ex),[yxt,xxt]=h1(ex),vve=t=>{const{__scopeSelect:e,children:r,open:n,defaultOpen:s,onOpenChange:i,value:a,defaultValue:o,onValueChange:c,dir:u,name:d,autoComplete:h,disabled:f,required:p,form:m}=t,g=LM(e),[x,y]=j.useState(null),[v,b]=j.useState(null),[w,S]=j.useState(!1),k=xx(u),[E,C]=_i({prop:n,defaultProp:s??!1,onChange:i,caller:ex}),[A,M]=_i({prop:a,defaultProp:o,onChange:c,caller:ex}),z=j.useRef(null),P=x?m||!!x.closest("form"):!0,[W,N]=j.useState(new Set),U=Array.from(W).map(K=>K.props.value).join(";");return l.jsx(iR,{...g,children:l.jsxs(gxt,{required:p,scope:e,trigger:x,onTriggerChange:y,valueNode:v,onValueNodeChange:b,valueNodeHasChildren:w,onValueNodeHasChildrenChange:S,contentId:Ka(),value:A,onValueChange:M,open:E,onOpenChange:C,dir:k,triggerPointerDownPosRef:z,disabled:f,children:[l.jsx(MM.Provider,{scope:e,children:l.jsx(yxt,{scope:t.__scopeSelect,onNativeOptionAdd:j.useCallback(K=>{N(G=>new Set(G).add(K))},[]),onNativeOptionRemove:j.useCallback(K=>{N(G=>{const X=new Set(G);return X.delete(K),X})},[]),children:r})}),P?l.jsxs(Hve,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:h,value:A,onChange:K=>M(K.target.value),disabled:f,form:m,children:[A===void 0?l.jsx("option",{value:""}):null,Array.from(W)]},U):null]})})};vve.displayName=ex;var bve="SelectTrigger",wve=j.forwardRef((t,e)=>{const{__scopeSelect:r,disabled:n=!1,...s}=t,i=LM(r),a=fm(bve,r),o=a.disabled||n,c=It(e,a.onTriggerChange),u=DM(r),d=j.useRef("touch"),[h,f,p]=Wve(g=>{const x=u().filter(b=>!b.disabled),y=x.find(b=>b.value===a.value),v=qve(x,g,y);v!==void 0&&a.onValueChange(v.value)}),m=g=>{o||(a.onOpenChange(!0),p()),g&&(a.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return l.jsx(aE,{asChild:!0,...i,children:l.jsx(ot.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:o,"data-disabled":o?"":void 0,"data-placeholder":Vve(a.value)?"":void 0,...s,ref:c,onClick:Ke(s.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&m(g)}),onPointerDown:Ke(s.onPointerDown,g=>{d.current=g.pointerType;const x=g.target;x.hasPointerCapture(g.pointerId)&&x.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(m(g),g.preventDefault())}),onKeyDown:Ke(s.onKeyDown,g=>{const x=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&f(g.key),!(x&&g.key===" ")&&fxt.includes(g.key)&&(m(),g.preventDefault())})})})});wve.displayName=bve;var Sve="SelectValue",_ve=j.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,children:i,placeholder:a="",...o}=t,c=fm(Sve,r),{onValueNodeHasChildrenChange:u}=c,d=i!==void 0,h=It(e,c.onValueNodeChange);return Wn(()=>{u(d)},[u,d]),l.jsx(ot.span,{...o,ref:h,style:{pointerEvents:"none"},children:Vve(c.value)?l.jsx(l.Fragment,{children:a}):i})});_ve.displayName=Sve;var vxt="SelectIcon",jve=j.forwardRef((t,e)=>{const{__scopeSelect:r,children:n,...s}=t;return l.jsx(ot.span,{"aria-hidden":!0,...s,ref:e,children:n||"▼"})});jve.displayName=vxt;var bxt="SelectPortal",kve=t=>l.jsx(Fw,{asChild:!0,...t});kve.displayName=bxt;var tx="SelectContent",Nve=j.forwardRef((t,e)=>{const r=fm(tx,t.__scopeSelect),[n,s]=j.useState();if(Wn(()=>{s(new DocumentFragment)},[]),!r.open){const i=n;return i?Iu.createPortal(l.jsx(Eve,{scope:t.__scopeSelect,children:l.jsx(MM.Slot,{scope:t.__scopeSelect,children:l.jsx("div",{children:t.children})})}),i):null}return l.jsx(Ave,{...t,ref:e})});Nve.displayName=tx;var Bl=10,[Eve,pm]=h1(tx),wxt="SelectContentImpl",Sxt=Fp("SelectContent.RemoveScroll"),Ave=j.forwardRef((t,e)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:i,onPointerDownOutside:a,side:o,sideOffset:c,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x,...y}=t,v=fm(tx,r),[b,w]=j.useState(null),[S,k]=j.useState(null),E=It(e,D=>w(D)),[C,A]=j.useState(null),[M,z]=j.useState(null),P=DM(r),[W,N]=j.useState(!1),U=j.useRef(!1);j.useEffect(()=>{if(b)return bR(b)},[b]),vR();const K=j.useCallback(D=>{const[R,...J]=P().map(re=>re.ref.current),[Z]=J.slice(-1),ee=document.activeElement;for(const re of D)if(re===ee||(re==null||re.scrollIntoView({block:"nearest"}),re===R&&S&&(S.scrollTop=0),re===Z&&S&&(S.scrollTop=S.scrollHeight),re==null||re.focus(),document.activeElement!==ee))return},[P,S]),G=j.useCallback(()=>K([C,b]),[K,C,b]);j.useEffect(()=>{W&&G()},[W,G]);const{onOpenChange:X,triggerPointerDownPosRef:H}=v;j.useEffect(()=>{if(b){let D={x:0,y:0};const R=Z=>{var ee,re;D={x:Math.abs(Math.round(Z.pageX)-(((ee=H.current)==null?void 0:ee.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((re=H.current)==null?void 0:re.y)??0))}},J=Z=>{D.x<=10&&D.y<=10?Z.preventDefault():b.contains(Z.target)||X(!1),document.removeEventListener("pointermove",R),H.current=null};return H.current!==null&&(document.addEventListener("pointermove",R),document.addEventListener("pointerup",J,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",R),document.removeEventListener("pointerup",J,{capture:!0})}}},[b,X,H]),j.useEffect(()=>{const D=()=>X(!1);return window.addEventListener("blur",D),window.addEventListener("resize",D),()=>{window.removeEventListener("blur",D),window.removeEventListener("resize",D)}},[X]);const[B,L]=Wve(D=>{const R=P().filter(ee=>!ee.disabled),J=R.find(ee=>ee.ref.current===document.activeElement),Z=qve(R,D,J);Z&&setTimeout(()=>Z.ref.current.focus())}),F=j.useCallback((D,R,J)=>{const Z=!U.current&&!J;(v.value!==void 0&&v.value===R||Z)&&(A(D),Z&&(U.current=!0))},[v.value]),V=j.useCallback(()=>b==null?void 0:b.focus(),[b]),Y=j.useCallback((D,R,J)=>{const Z=!U.current&&!J;(v.value!==void 0&&v.value===R||Z)&&z(D)},[v.value]),ie=n==="popper"?h8:Cve,Q=ie===h8?{side:o,sideOffset:c,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:x}:{};return l.jsx(Eve,{scope:r,content:b,viewport:S,onViewportChange:k,itemRefCallback:F,selectedItem:C,onItemLeave:V,itemTextRefCallback:Y,focusSelectedItem:G,selectedItemText:M,position:n,isPositioned:W,searchRef:B,children:l.jsx(fE,{as:Sxt,allowPinchZoom:!0,children:l.jsx(dE,{asChild:!0,trapped:v.open,onMountAutoFocus:D=>{D.preventDefault()},onUnmountAutoFocus:Ke(s,D=>{var R;(R=v.trigger)==null||R.focus({preventScroll:!0}),D.preventDefault()}),children:l.jsx(mx,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:D=>D.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:l.jsx(ie,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:D=>D.preventDefault(),...y,...Q,onPlaced:()=>N(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:Ke(y.onKeyDown,D=>{const R=D.ctrlKey||D.altKey||D.metaKey;if(D.key==="Tab"&&D.preventDefault(),!R&&D.key.length===1&&L(D.key),["ArrowUp","ArrowDown","Home","End"].includes(D.key)){let Z=P().filter(ee=>!ee.disabled).map(ee=>ee.ref.current);if(["ArrowUp","End"].includes(D.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(D.key)){const ee=D.target,re=Z.indexOf(ee);Z=Z.slice(re+1)}setTimeout(()=>K(Z)),D.preventDefault()}})})})})})})});Ave.displayName=wxt;var _xt="SelectItemAlignedPosition",Cve=j.forwardRef((t,e)=>{const{__scopeSelect:r,onPlaced:n,...s}=t,i=fm(tx,r),a=pm(tx,r),[o,c]=j.useState(null),[u,d]=j.useState(null),h=It(e,E=>d(E)),f=DM(r),p=j.useRef(!1),m=j.useRef(!0),{viewport:g,selectedItem:x,selectedItemText:y,focusSelectedItem:v}=a,b=j.useCallback(()=>{if(i.trigger&&i.valueNode&&o&&u&&g&&x&&y){const E=i.trigger.getBoundingClientRect(),C=u.getBoundingClientRect(),A=i.valueNode.getBoundingClientRect(),M=y.getBoundingClientRect();if(i.dir!=="rtl"){const ee=M.left-C.left,re=A.left-ee,he=E.left-re,O=E.width+he,ae=Math.max(O,C.width),q=window.innerWidth-Bl,I=u6(re,[Bl,Math.max(Bl,q-ae)]);o.style.minWidth=O+"px",o.style.left=I+"px"}else{const ee=C.right-M.right,re=window.innerWidth-A.right-ee,he=window.innerWidth-E.right-re,O=E.width+he,ae=Math.max(O,C.width),q=window.innerWidth-Bl,I=u6(re,[Bl,Math.max(Bl,q-ae)]);o.style.minWidth=O+"px",o.style.right=I+"px"}const z=f(),P=window.innerHeight-Bl*2,W=g.scrollHeight,N=window.getComputedStyle(u),U=parseInt(N.borderTopWidth,10),K=parseInt(N.paddingTop,10),G=parseInt(N.borderBottomWidth,10),X=parseInt(N.paddingBottom,10),H=U+K+W+X+G,B=Math.min(x.offsetHeight*5,H),L=window.getComputedStyle(g),F=parseInt(L.paddingTop,10),V=parseInt(L.paddingBottom,10),Y=E.top+E.height/2-Bl,ie=P-Y,Q=x.offsetHeight/2,D=x.offsetTop+Q,R=U+K+D,J=H-R;if(R<=Y){const ee=z.length>0&&x===z[z.length-1].ref.current;o.style.bottom="0px";const re=u.clientHeight-g.offsetTop-g.offsetHeight,he=Math.max(ie,Q+(ee?V:0)+re+G),O=R+he;o.style.height=O+"px"}else{const ee=z.length>0&&x===z[0].ref.current;o.style.top="0px";const he=Math.max(Y,U+g.offsetTop+(ee?F:0)+Q)+J;o.style.height=he+"px",g.scrollTop=R-Y+g.offsetTop}o.style.margin=`${Bl}px 0`,o.style.minHeight=B+"px",o.style.maxHeight=P+"px",n==null||n(),requestAnimationFrame(()=>p.current=!0)}},[f,i.trigger,i.valueNode,o,u,g,x,y,i.dir,n]);Wn(()=>b(),[b]);const[w,S]=j.useState();Wn(()=>{u&&S(window.getComputedStyle(u).zIndex)},[u]);const k=j.useCallback(E=>{E&&m.current===!0&&(b(),v==null||v(),m.current=!1)},[b,v]);return l.jsx(kxt,{scope:r,contentWrapper:o,shouldExpandOnScrollRef:p,onScrollButtonChange:k,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:l.jsx(ot.div,{...s,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});Cve.displayName=_xt;var jxt="SelectPopperPosition",h8=j.forwardRef((t,e)=>{const{__scopeSelect:r,align:n="start",collisionPadding:s=Bl,...i}=t,a=LM(r);return l.jsx(aR,{...a,...i,ref:e,align:n,collisionPadding:s,style:{boxSizing:"border-box",...i.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)"}})});h8.displayName=jxt;var[kxt,P9]=h1(tx,{}),f8="SelectViewport",Tve=j.forwardRef((t,e)=>{const{__scopeSelect:r,nonce:n,...s}=t,i=pm(f8,r),a=P9(f8,r),o=It(e,i.onViewportChange),c=j.useRef(0);return l.jsxs(l.Fragment,{children:[l.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:n}),l.jsx(MM.Slot,{scope:r,children:l.jsx(ot.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:o,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Ke(s.onScroll,u=>{const d=u.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:f}=a;if(f!=null&&f.current&&h){const p=Math.abs(c.current-d.scrollTop);if(p>0){const m=window.innerHeight-Bl*2,g=parseFloat(h.style.minHeight),x=parseFloat(h.style.height),y=Math.max(g,x);if(y<m){const v=y+p,b=Math.min(m,v),w=v-b;h.style.height=b+"px",h.style.bottom==="0px"&&(d.scrollTop=w>0?w:0,h.style.justifyContent="flex-end")}}}c.current=d.scrollTop})})})]})});Tve.displayName=f8;var Pve="SelectGroup",[Nxt,Ext]=h1(Pve),Axt=j.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=Ka();return l.jsx(Nxt,{scope:r,id:s,children:l.jsx(ot.div,{role:"group","aria-labelledby":s,...n,ref:e})})});Axt.displayName=Pve;var Ove="SelectLabel",Ive=j.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=Ext(Ove,r);return l.jsx(ot.div,{id:s.id,...n,ref:e})});Ive.displayName=Ove;var lO="SelectItem",[Cxt,Rve]=h1(lO),Mve=j.forwardRef((t,e)=>{const{__scopeSelect:r,value:n,disabled:s=!1,textValue:i,...a}=t,o=fm(lO,r),c=pm(lO,r),u=o.value===n,[d,h]=j.useState(i??""),[f,p]=j.useState(!1),m=It(e,v=>{var b;return(b=c.itemRefCallback)==null?void 0:b.call(c,v,n,s)}),g=Ka(),x=j.useRef("touch"),y=()=>{s||(o.onValueChange(n),o.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return l.jsx(Cxt,{scope:r,value:n,disabled:s,textId:g,isSelected:u,onItemTextChange:j.useCallback(v=>{h(b=>b||((v==null?void 0:v.textContent)??"").trim())},[]),children:l.jsx(MM.ItemSlot,{scope:r,value:n,disabled:s,textValue:d,children:l.jsx(ot.div,{role:"option","aria-labelledby":g,"data-highlighted":f?"":void 0,"aria-selected":u&&f,"data-state":u?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...a,ref:m,onFocus:Ke(a.onFocus,()=>p(!0)),onBlur:Ke(a.onBlur,()=>p(!1)),onClick:Ke(a.onClick,()=>{x.current!=="mouse"&&y()}),onPointerUp:Ke(a.onPointerUp,()=>{x.current==="mouse"&&y()}),onPointerDown:Ke(a.onPointerDown,v=>{x.current=v.pointerType}),onPointerMove:Ke(a.onPointerMove,v=>{var b;x.current=v.pointerType,s?(b=c.onItemLeave)==null||b.call(c):x.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ke(a.onPointerLeave,v=>{var b;v.currentTarget===document.activeElement&&((b=c.onItemLeave)==null||b.call(c))}),onKeyDown:Ke(a.onKeyDown,v=>{var w;((w=c.searchRef)==null?void 0:w.current)!==""&&v.key===" "||(pxt.includes(v.key)&&y(),v.key===" "&&v.preventDefault())})})})})});Mve.displayName=lO;var fS="SelectItemText",Dve=j.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,...i}=t,a=fm(fS,r),o=pm(fS,r),c=Rve(fS,r),u=xxt(fS,r),[d,h]=j.useState(null),f=It(e,y=>h(y),c.onItemTextChange,y=>{var v;return(v=o.itemTextRefCallback)==null?void 0:v.call(o,y,c.value,c.disabled)}),p=d==null?void 0:d.textContent,m=j.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:x}=u;return Wn(()=>(g(m),()=>x(m)),[g,x,m]),l.jsxs(l.Fragment,{children:[l.jsx(ot.span,{id:c.textId,...i,ref:f}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?Iu.createPortal(i.children,a.valueNode):null]})});Dve.displayName=fS;var Lve="SelectItemIndicator",Fve=j.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return Rve(Lve,r).isSelected?l.jsx(ot.span,{"aria-hidden":!0,...n,ref:e}):null});Fve.displayName=Lve;var p8="SelectScrollUpButton",$ve=j.forwardRef((t,e)=>{const r=pm(p8,t.__scopeSelect),n=P9(p8,t.__scopeSelect),[s,i]=j.useState(!1),a=It(e,n.onScrollButtonChange);return Wn(()=>{if(r.viewport&&r.isPositioned){let o=function(){const u=c.scrollTop>0;i(u)};const c=r.viewport;return o(),c.addEventListener("scroll",o),()=>c.removeEventListener("scroll",o)}},[r.viewport,r.isPositioned]),s?l.jsx(zve,{...t,ref:a,onAutoScroll:()=>{const{viewport:o,selectedItem:c}=r;o&&c&&(o.scrollTop=o.scrollTop-c.offsetHeight)}}):null});$ve.displayName=p8;var m8="SelectScrollDownButton",Bve=j.forwardRef((t,e)=>{const r=pm(m8,t.__scopeSelect),n=P9(m8,t.__scopeSelect),[s,i]=j.useState(!1),a=It(e,n.onScrollButtonChange);return Wn(()=>{if(r.viewport&&r.isPositioned){let o=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;i(d)};const c=r.viewport;return o(),c.addEventListener("scroll",o),()=>c.removeEventListener("scroll",o)}},[r.viewport,r.isPositioned]),s?l.jsx(zve,{...t,ref:a,onAutoScroll:()=>{const{viewport:o,selectedItem:c}=r;o&&c&&(o.scrollTop=o.scrollTop+c.offsetHeight)}}):null});Bve.displayName=m8;var zve=j.forwardRef((t,e)=>{const{__scopeSelect:r,onAutoScroll:n,...s}=t,i=pm("SelectScrollButton",r),a=j.useRef(null),o=DM(r),c=j.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return j.useEffect(()=>()=>c(),[c]),Wn(()=>{var d;const u=o().find(h=>h.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[o]),l.jsx(ot.div,{"aria-hidden":!0,...s,ref:e,style:{flexShrink:0,...s.style},onPointerDown:Ke(s.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(n,50))}),onPointerMove:Ke(s.onPointerMove,()=>{var u;(u=i.onItemLeave)==null||u.call(i),a.current===null&&(a.current=window.setInterval(n,50))}),onPointerLeave:Ke(s.onPointerLeave,()=>{c()})})}),Txt="SelectSeparator",Uve=j.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return l.jsx(ot.div,{"aria-hidden":!0,...n,ref:e})});Uve.displayName=Txt;var g8="SelectArrow",Pxt=j.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=LM(r),i=fm(g8,r),a=pm(g8,r);return i.open&&a.position==="popper"?l.jsx(oR,{...s,...n,ref:e}):null});Pxt.displayName=g8;var Oxt="SelectBubbleInput",Hve=j.forwardRef(({__scopeSelect:t,value:e,...r},n)=>{const s=j.useRef(null),i=It(n,s),a=T9(e);return j.useEffect(()=>{const o=s.current;if(!o)return;const c=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(a!==e&&d){const h=new Event("change",{bubbles:!0});d.call(o,e),o.dispatchEvent(h)}},[a,e]),l.jsx(ot.select,{...r,style:{...ice,...r.style},ref:i,defaultValue:e})});Hve.displayName=Oxt;function Vve(t){return t===""||t===void 0}function Wve(t){const e=Hn(t),r=j.useRef(""),n=j.useRef(0),s=j.useCallback(a=>{const o=r.current+a;e(o),function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))}(o)},[e]),i=j.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,s,i]}function qve(t,e,r){const s=e.length>1&&Array.from(e).every(u=>u===e[0])?e[0]:e,i=r?t.indexOf(r):-1;let a=Ixt(t,Math.max(i,0));s.length===1&&(a=a.filter(u=>u!==r));const c=a.find(u=>u.textValue.toLowerCase().startsWith(s.toLowerCase()));return c!==r?c:void 0}function Ixt(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var Rxt=vve,Gve=wve,Mxt=_ve,Dxt=jve,Lxt=kve,Kve=Nve,Fxt=Tve,Yve=Ive,Xve=Mve,$xt=Dve,Bxt=Fve,Jve=$ve,Qve=Bve,Zve=Uve;const dt=Rxt,ht=Mxt,lt=j.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(Gve,{ref:n,className:Le("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[e,l.jsx(Dxt,{asChild:!0,children:l.jsx(Eh,{className:"h-4 w-4 opacity-50"})})]}));lt.displayName=Gve.displayName;const ebe=j.forwardRef(({className:t,...e},r)=>l.jsx(Jve,{ref:r,className:Le("flex cursor-default items-center justify-center py-1",t),...e,children:l.jsx(Ace,{className:"h-4 w-4"})}));ebe.displayName=Jve.displayName;const tbe=j.forwardRef(({className:t,...e},r)=>l.jsx(Qve,{ref:r,className:Le("flex cursor-default items-center justify-center py-1",t),...e,children:l.jsx(Eh,{className:"h-4 w-4"})}));tbe.displayName=Qve.displayName;const ct=j.forwardRef(({className:t,children:e,position:r="popper",...n},s)=>l.jsx(Lxt,{children:l.jsxs(Kve,{ref:s,className:Le("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[l.jsx(ebe,{}),l.jsx(Fxt,{className:Le("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),l.jsx(tbe,{})]})}));ct.displayName=Kve.displayName;const zxt=j.forwardRef(({className:t,...e},r)=>l.jsx(Yve,{ref:r,className:Le("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...e}));zxt.displayName=Yve.displayName;const De=j.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(Xve,{ref:n,className:Le("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(Bxt,{children:l.jsx(Es,{className:"h-4 w-4"})})}),l.jsx($xt,{children:e})]}));De.displayName=Xve.displayName;const Uxt=j.forwardRef(({className:t,...e},r)=>l.jsx(Zve,{ref:r,className:Le("-mx-1 my-1 h-px bg-muted",t),...e}));Uxt.displayName=Zve.displayName;const rbe=({currentAvatarUrl:t,onSelectPublic:e,onUploadCustom:r,disabled:n})=>{const[s,i]=j.useState(!1),[a,o]=j.useState(!1),[c,u]=j.useState(null),[d,h]=j.useState([]),[f,p]=j.useState(!0),m=j.useRef(null),{toast:g}=qn();j.useEffect(()=>{(async()=>{const w=await sb(t);u(w)})()},[t]),j.useEffect(()=>{(async()=>{p(!0);try{const{data:w,error:S}=await be.storage.from("avatars-public").list("",{limit:20});if(S){console.error("Error loading public avatars:",S);return}if(w){const k=w.filter(E=>E.name.match(/\.(png|jpg|jpeg|webp|svg)$/i)).map(E=>({name:E.name,url:`https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/avatars-public/${E.name}`}));h(k)}}catch(w){console.error("Error loading public avatars:",w)}finally{p(!1)}})()},[]);const x=async b=>{var k;const w=(k=b.target.files)==null?void 0:k[0];if(!w)return;if(!w.type.startsWith("image/")){g({title:"Error",description:"Please select an image file",variant:"destructive"});return}if(w.size>2*1024*1024){g({title:"Error",description:"File is too large. Maximum 2MB allowed.",variant:"destructive"});return}const S=new FileReader;S.onloadend=()=>{u(S.result)},S.readAsDataURL(w),i(!0);try{await r(w),g({title:"Success",description:"Avatar uploaded successfully"})}catch(E){console.error("Avatar upload error:",E),g({title:"Error",description:"Failed to upload avatar",variant:"destructive"});const C=await sb(t);u(C)}finally{i(!1)}},y=async b=>{if(!(n||a)){o(!0),u(b.url);try{await e(b.url),g({title:"Success",description:"Avatar selected successfully"})}catch(w){console.error("Avatar selection error:",w),g({title:"Error",description:"Failed to select avatar",variant:"destructive"});const S=await sb(t);u(S)}finally{o(!1)}}},v=b=>t===b||c===b;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center gap-6",children:[l.jsxs("div",{className:"relative w-40 h-40 rounded-full overflow-hidden bg-muted cursor-pointer group flex-shrink-0",onClick:()=>{var b;return!n&&((b=m.current)==null?void 0:b.click())},children:[c?l.jsx("img",{src:c,alt:"Avatar",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center",children:l.jsx($w,{className:"w-20 h-20 text-muted-foreground"})}),!n&&l.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:s?l.jsx(xt,{className:"w-8 h-8 text-white animate-spin"}):l.jsx(hh,{className:"w-8 h-8 text-white"})})]}),l.jsx("input",{ref:m,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:x,className:"hidden",disabled:n||s}),l.jsxs("div",{className:"flex-1",children:[l.jsx("p",{className:"text-sm font-medium",children:"Profile Picture"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose a default avatar or upload your own (max 2MB)"})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Or choose a default avatar"}),f?l.jsx("div",{className:"flex items-center justify-center py-8",children:l.jsx(xt,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):d.length>0?l.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-5",children:d.map(b=>l.jsxs("button",{onClick:()=>y(b),disabled:n||a||s,className:Le("relative w-24 h-24 rounded-full overflow-hidden border-2 transition-all","hover:scale-105 hover:border-primary focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2","disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100",v(b.url)?"border-primary ring-2 ring-primary ring-offset-2":"border-border hover:border-primary/50"),children:[l.jsx("img",{src:b.url,alt:b.name,className:"w-full h-full object-cover"}),v(b.url)&&l.jsx("div",{className:"absolute inset-0 bg-primary/20 flex items-center justify-center",children:l.jsx(Es,{className:"w-8 h-8 text-primary"})})]},b.name))}):l.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No default avatars available"})]})]})},Hxt=["Germany","Austria","Switzerland","United States","United Kingdom","France","Spain","Italy","Netherlands","Belgium","Poland","Sweden","Norway","Denmark","Finland","Australia","Canada","Other"],Vxt=[{value:"bachelor",label:"Bachelor"},{value:"master",label:"Master"},{value:"phd",label:"PhD / Doctorate"},{value:"postdoc",label:"Postdoc"},{value:"other",label:"Other"}],Wxt=["Business & Economics","Computer Science","Education","Engineering","Health Sciences","Humanities","Law","Natural Sciences","Psychology","Social Sciences","Other"],qxt=[{value:"quantitative",label:"Quantitative"},{value:"qualitative",label:"Qualitative"},{value:"mixed",label:"Mixed Methods"}],Gxt=[{value:"de",label:"Deutsch"},{value:"en",label:"English"},{value:"fr",label:"Français"},{value:"es",label:"Español"},{value:"it",label:"Italiano"}];function lC({label:t,tooltip:e,required:r}){return l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs(_e,{className:"text-foreground font-medium",children:[t,r&&l.jsx("span",{className:"text-destructive ml-0.5",children:"*"})]}),l.jsx(Zs,{children:l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(Bp,{className:"w-3.5 h-3.5 text-muted-foreground cursor-help"})}),l.jsx(Qt,{side:"top",className:"max-w-[250px] text-xs",children:e})]})})]})}function Kxt({open:t,onComplete:e}){const{user:r,updateResearchProfile:n,uploadAvatar:s,selectPublicAvatar:i,researchProfile:a}=Dt(),[o,c]=j.useState(!1),[u,d]=j.useState((a==null?void 0:a.nickname)||""),[h,f]=j.useState((a==null?void 0:a.study_country)||""),[p,m]=j.useState((a==null?void 0:a.degree_type)||null),[g,x]=j.useState((a==null?void 0:a.discipline)||""),[y,v]=j.useState((a==null?void 0:a.university)||""),[b,w]=j.useState((a==null?void 0:a.methodology)||null),[S,k]=j.useState((a==null?void 0:a.preferred_language)||"de"),E=async z=>{await i(z)},C=async z=>await s(z),A=async()=>{if(!u.trim()){We.error("Please enter a nickname");return}c(!0);try{await n({nickname:u.trim(),study_country:h||null,degree_type:p,discipline:g||null,university:y||null,methodology:b,preferred_language:S}),We.success("Profile saved! Welcome to Academly."),e()}catch(z){console.error("Error saving profile:",z),We.error("Failed to save profile. Please try again.")}finally{c(!1)}},M=async()=>{c(!0);try{await n({preferred_language:"de"}),e()}catch(z){console.error("Error creating minimal profile:",z),e()}finally{c(!1)}};return l.jsx(Gr,{open:t,onOpenChange:()=>{},children:l.jsxs(zr,{className:"sm:max-w-[500px] max-h-[90vh] overflow-y-auto",onPointerDownOutside:z=>z.preventDefault(),onEscapeKeyDown:z=>z.preventDefault(),children:[l.jsxs(Ur,{className:"text-center pb-2",children:[l.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:l.jsx(Qs,{className:"w-6 h-6 text-primary"})}),l.jsx(Hr,{className:"text-xl",children:"Welcome to Academly!"}),l.jsx(wx,{children:"Tell us a bit about yourself to personalize your experience."})]}),l.jsxs("div",{className:"space-y-5 py-4",children:[l.jsx(rbe,{currentAvatarUrl:(a==null?void 0:a.avatar_url)||null,onSelectPublic:E,onUploadCustom:C}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(_e,{className:"text-foreground font-medium",children:["Nickname ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsx(Be,{value:u,onChange:z=>d(z.target.value),placeholder:"How should we call you?",className:"h-10"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(lC,{label:"Study Country",tooltip:"Helps us tailor language support and citation styles for your region in future updates."}),l.jsxs(dt,{value:h,onValueChange:f,children:[l.jsx(lt,{className:"h-10",children:l.jsx(ht,{placeholder:"Select your country"})}),l.jsx(ct,{children:Hxt.map(z=>l.jsx(De,{value:z,children:z},z))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(lC,{label:"Degree Type",tooltip:"Helps us customize academic requirements and formatting options."}),l.jsxs(dt,{value:p||"",onValueChange:z=>m(z),children:[l.jsx(lt,{className:"h-10",children:l.jsx(ht,{placeholder:"Select your degree"})}),l.jsx(ct,{children:Vxt.map(z=>l.jsx(De,{value:z.value||"",children:z.label},z.value))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(lC,{label:"Discipline",tooltip:"Enables discipline-specific citation styles and terminology suggestions."}),l.jsxs(dt,{value:g,onValueChange:x,children:[l.jsx(lt,{className:"h-10",children:l.jsx(ht,{placeholder:"Select your field"})}),l.jsx(ct,{children:Wxt.map(z=>l.jsx(De,{value:z,children:z},z))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{className:"text-foreground font-medium",children:"University"}),l.jsx(Be,{value:y,onChange:z=>v(z.target.value),placeholder:"Your university name",className:"h-10"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{className:"text-foreground font-medium",children:"Research Methodology"}),l.jsxs(dt,{value:b||"",onValueChange:z=>w(z),children:[l.jsx(lt,{className:"h-10",children:l.jsx(ht,{placeholder:"Select methodology"})}),l.jsx(ct,{children:qxt.map(z=>l.jsx(De,{value:z.value||"",children:z.label},z.value))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(lC,{label:"Preferred Language",tooltip:"We'll prioritize adding features and translations in your preferred language."}),l.jsxs(dt,{value:S,onValueChange:z=>k(z),children:[l.jsx(lt,{className:"h-10",children:l.jsx(ht,{placeholder:"Select language"})}),l.jsx(ct,{children:Gxt.map(z=>l.jsx(De,{value:z.value,children:z.label},z.value))})]})]})]}),l.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[l.jsx(ye,{onClick:A,disabled:o||!u.trim(),className:"w-full h-11 rounded-full",children:o?"Saving...":"Save & Continue"}),l.jsx("button",{type:"button",onClick:M,disabled:o,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:"Skip for now"})]})]})})}const Yxt=()=>{const{user:t,loading:e,researchProfile:r}=Dt(),n=Or(),[s,i]=j.useState(!1);j.useEffect(()=>{!t&&!e&&n("/login")},[t,e,n]),j.useEffect(()=>{if(t&&!e){const o=!r||!r.nickname;i(o)}else i(!1)},[t,e,r]);const a=()=>{i(!1)};return e?l.jsx(gr,{showSidebar:!0,children:l.jsx(gve,{})}):t?l.jsxs(gr,{showSidebar:!0,children:[l.jsx(uxt,{}),l.jsx(Kxt,{open:s,onComplete:a})]}):null},Xs=()=>{const{user:t}=Dt(),[e,r]=j.useState(!1),n="https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/src/logo_new.png",s=[{label:"Topic Generator",subtitle:"Free thesis topic ideas",href:"/topic-ideas",icon:rm},{label:"Literature Keywords",subtitle:"Discover relevant sources",href:"/literature-search",icon:yl}];return l.jsxs("header",{className:"absolute inset-x-0 top-0 z-50",children:[l.jsxs("nav",{className:"mx-auto flex max-w-7xl items-center justify-between px-6 py-5 lg:px-12",children:[l.jsx(bt,{to:"/",className:"flex items-center gap-2",children:l.jsx("img",{src:n,alt:"Academly.ai",className:"h-9 w-auto"})}),l.jsxs("div",{className:"hidden lg:flex lg:items-center lg:gap-8",children:[l.jsx(bt,{to:"/#features",className:"text-sm font-medium text-foreground/80 transition-colors hover:text-foreground",children:"Features"}),l.jsx(bt,{to:"/topic-ideas",className:"text-sm font-medium text-foreground/80 transition-colors hover:text-foreground",children:"Topic Generator"}),l.jsx(bt,{to:"/pricing",className:"text-sm font-medium text-foreground/80 transition-colors hover:text-foreground",children:"Pricing"}),l.jsx(bt,{to:"/blog",className:"text-sm font-medium text-foreground/80 transition-colors hover:text-foreground",children:"Blog"}),l.jsxs("div",{className:"relative group",children:[l.jsxs("button",{type:"button",className:"flex items-center gap-1 text-sm font-medium text-foreground/80 transition-colors hover:text-foreground",children:["Demo",l.jsx(Eh,{className:"h-3.5 w-3.5 transition-transform group-hover:rotate-180"})]}),l.jsx("div",{className:"invisible absolute left-1/2 top-full z-50 w-72 -translate-x-1/2 pt-3 opacity-0 transition-all duration-150 group-hover:visible group-hover:opacity-100",children:l.jsx("div",{className:"rounded-xl border border-border bg-background p-2 shadow-lg",children:s.map(i=>{const a=i.icon;return l.jsxs(bt,{to:i.href,className:"flex items-start gap-3 rounded-lg p-3 transition-colors hover:bg-muted",children:[l.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:l.jsx(a,{className:"h-4 w-4"})}),l.jsxs("div",{children:[l.jsx("div",{className:"text-sm font-semibold text-foreground",children:i.label}),l.jsx("div",{className:"text-xs text-muted-foreground",children:i.subtitle})]})]},i.href)})})})]})]}),l.jsx("div",{className:"hidden lg:flex lg:items-center lg:gap-4",children:t?l.jsx(ye,{asChild:!0,className:"rounded-full px-6",children:l.jsx(bt,{to:"/dashboard",children:"Dashboard"})}):l.jsxs(l.Fragment,{children:[l.jsx(bt,{to:"/login",className:"text-sm font-medium text-foreground/80 transition-colors hover:text-foreground",children:"Login"}),l.jsx(ye,{asChild:!0,className:"rounded-full px-6","data-umami-event":"cta-signup-click","data-umami-event-location":"header-desktop",children:l.jsx(bt,{to:"/login?mode=signup",children:"Start Writing Free"})})]})}),l.jsx("div",{className:"flex items-center gap-3 lg:hidden",children:l.jsx("button",{onClick:()=>r(!e),className:"flex h-10 w-10 items-center justify-center rounded-lg text-foreground/80 hover:bg-muted",children:e?l.jsx(Is,{className:"h-5 w-5"}):l.jsx(PH,{className:"h-5 w-5"})})})]}),e&&l.jsx("div",{className:"lg:hidden",children:l.jsxs("div",{className:"border-t border-border bg-background/95 backdrop-blur-lg px-6 py-4 space-y-4",children:[l.jsx(bt,{to:"/#features",className:"block text-sm font-medium text-foreground/80",onClick:()=>r(!1),children:"Features"}),l.jsx(bt,{to:"/topic-ideas",className:"block text-sm font-medium text-foreground/80",onClick:()=>r(!1),children:"Topic Generator"}),l.jsx(bt,{to:"/pricing",className:"block text-sm font-medium text-foreground/80",onClick:()=>r(!1),children:"Pricing"}),l.jsx(bt,{to:"/blog",className:"block text-sm font-medium text-foreground/80",onClick:()=>r(!1),children:"Blog"}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Demo"}),s.map(i=>l.jsx(bt,{to:i.href,className:"block text-sm text-foreground/80 pl-2",onClick:()=>r(!1),children:i.label},i.href))]}),l.jsx("div",{className:"pt-4 border-t border-border",children:t?l.jsx(ye,{asChild:!0,className:"w-full rounded-full",children:l.jsx(bt,{to:"/dashboard",children:"Dashboard"})}):l.jsxs("div",{className:"space-y-3",children:[l.jsx(bt,{to:"/login",className:"block text-sm font-medium text-foreground/80",onClick:()=>r(!1),children:"Login"}),l.jsx(ye,{asChild:!0,className:"w-full rounded-full","data-umami-event":"cta-signup-click","data-umami-event-location":"header-mobile",children:l.jsx(bt,{to:"/login?mode=signup",children:"Start Writing Free"})})]})})]})})]})},Xxt="/assets/logo-icon-FLGou0Tt.png",Jxt=["Citations only from uploaded PDFs","Verified page references","No hallucinated references","GDPR compliant","EU hosted"],Qxt=()=>l.jsxs("div",{className:"relative",id:"home",children:[l.jsxs("div",{"aria-hidden":"true",className:"absolute inset-0 grid grid-cols-2 -space-x-52 opacity-40 dark:opacity-20",children:[l.jsx("div",{className:"blur-[106px] h-56 bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),l.jsx("div",{className:"blur-[106px] h-32 bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),l.jsx(Wr,{children:l.jsx("div",{className:"relative pt-36 ml-auto",children:l.jsxs("div",{className:"max-w-3xl text-center mx-auto",children:[l.jsxs("h1",{className:"text-foreground text-balance font-bold text-5xl md:text-6xl xl:text-7xl",children:["Write your thesis with ",l.jsx("span",{className:"text-primary",children:"real citations"})," from your own sources."]}),l.jsx("div",{className:"flex justify-center my-10",children:l.jsxs("div",{className:"relative",children:[l.jsx("div",{className:"absolute inset-0 blur-3xl bg-primary/30 rounded-full scale-150"}),l.jsx("img",{src:Xxt,alt:"Academly.ai Logo",className:"relative w-36 h-36 md:w-48 md:h-48 object-contain drop-shadow-2xl animate-fade-in"})]})}),l.jsx("p",{className:"mt-8 text-muted-foreground text-lg",children:"Upload academic PDFs, generate structured thesis chapters, and keep every citation connected to real research with verified page references."}),l.jsxs("div",{className:"mt-12 flex flex-wrap justify-center gap-y-4 gap-x-6",children:[l.jsx(bt,{to:"/login?mode=signup",className:"relative flex h-12 w-full items-center justify-center px-8 before:absolute before:inset-0 before:rounded-full before:bg-primary before:transition before:duration-300 hover:before:scale-105 active:duration-75 active:before:scale-95 sm:w-max","data-umami-event":"cta-signup-click","data-umami-event-location":"hero",children:l.jsx("span",{className:"relative text-base font-semibold text-primary-foreground",children:"Start Writing Free"})}),l.jsx("a",{href:"#how-it-works",className:"relative flex h-12 w-full items-center justify-center px-8 before:absolute before:inset-0 before:rounded-full before:border before:border-transparent before:bg-primary/10 before:transition before:duration-300 hover:before:scale-105 active:duration-75 active:before:scale-95 dark:before:border-gray-700 dark:before:bg-gray-800 sm:w-max",children:l.jsx("span",{className:"relative text-base font-semibold text-primary dark:text-white",children:"See How It Works"})})]}),l.jsx("ul",{className:"mt-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-2 text-sm text-muted-foreground",children:Jxt.map(t=>l.jsxs("li",{className:"flex items-center gap-1.5",children:[l.jsx(Es,{className:"h-4 w-4 text-primary shrink-0"}),l.jsx("span",{children:t})]},t))})]})})})]}),fte="Burnout in Remote Work Environments",I4="Burnout in remote work environments has emerged as a critical concern in contemporary organizational research (Maslach & Jackson, 1981, p. 99). The Maslach Burnout Inventory (MBI) identifies three core dimensions: emotional exhaustion, depersonalization, and reduced personal accomplishment. Remote work conditions have been shown to significantly amplify emotional exhaustion due to the blurring of work-life boundaries (Meyer et al., 2022, p. 45). Furthermore, the absence of social interaction in remote settings contributes to increased depersonalization among employees (Meyer et al., 2022, p. 47).",Zxt=80,evt=18,tvt=1500,pte=500,rvt=1e3,mte=500,nvt=4e3,svt=600,ivt=[{text:"The Maslach Burnout Inventory (MBI) has become the leading measure of burnout, encompassing emotional exhaustion, depersonalization, and personal accomplishment.",cite:"(Maslach & Jackson, 1981, p. 99)"},{text:"Remote work environments create unique stressors that significantly contribute to emotional exhaustion, particularly through the erosion of work-life boundaries.",cite:"(Meyer et al., 2022, p. 45)"}],avt=()=>{const[t,e]=j.useState(""),[r,n]=j.useState(""),[s,i]=j.useState(!1),[a,o]=j.useState(0),[c,u]=j.useState(!1),d=j.useRef([]);j.useEffect(()=>{let f=!1;const p=(g,x)=>{const y=setTimeout(()=>{f||g()},x);d.current.push(y)},m=()=>{f||(u(!1),e(""),n(""),i(!1),o(0),p(()=>{let g=0;const x=()=>{f||(g+=1,e(fte.slice(0,g)),g<fte.length?p(x,Zxt):(i(!0),p(()=>i(!1),pte),p(()=>{let y=0;const v=()=>{f||(y+=1,n(I4.slice(0,y)),y<I4.length?p(v,evt):p(()=>{o(1),p(()=>o(2),mte),p(()=>{u(!0),p(m,svt)},mte+nvt)},rvt))};v()},pte)))};x()},tvt))};return m(),()=>{f=!0,d.current.forEach(clearTimeout),d.current=[]}},[]);const h=[{name:"leseprobe_burnout_2021.pdf",pages:24,selected:!1},{name:"maslach_burnout_inventory.pdf",pages:18,selected:!0},{name:"meyer_remote_work_2022.pdf",pages:12,selected:!0}];return l.jsx("section",{className:"py-8",children:l.jsx(Wr,{children:l.jsxs("div",{className:"max-w-5xl mx-auto rounded-2xl border border-border bg-card shadow-lg overflow-hidden",children:[l.jsxs("div",{className:`grid grid-cols-1 md:grid-cols-5 transition-opacity duration-500 ${c?"opacity-0":"opacity-100"}`,children:[l.jsxs("div",{className:"md:col-span-2 bg-muted/30 p-6 md:border-r border-border space-y-5",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:"Paragraph Configuration"}),l.jsxs("div",{children:[l.jsxs("p",{className:"text-xs font-medium text-foreground mb-2",children:["Select Documents ",l.jsx("span",{className:"text-primary",children:"*"})]}),l.jsx("div",{className:"space-y-1.5",children:h.map(f=>l.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-background px-3 py-2",children:[l.jsx("span",{className:`flex-shrink-0 h-4 w-4 rounded-full border-2 ${f.selected?"bg-primary border-primary":"border-muted-foreground/40"}`}),l.jsx(Br,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),l.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:f.name}),l.jsxs("span",{className:"text-[11px] text-muted-foreground flex-shrink-0",children:["(",f.pages," pages)"]})]},f.name))}),l.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:"2 of 3 selected"})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-medium text-foreground mb-2",children:"Page Selection"}),l.jsx("div",{className:"space-y-1.5",children:[{name:"maslach_burnout_inventory...",from:95,to:105,total:18,count:"10p"},{name:"meyer_remote_work_2022...",from:40,to:48,total:12,count:"8p"}].map(f=>l.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-foreground",children:[l.jsx("span",{className:"flex-1 truncate",children:f.name}),l.jsx("span",{className:"text-muted-foreground",children:"p."}),l.jsx("span",{className:"rounded border border-border bg-background px-2 py-0.5 w-10 text-center",children:f.from}),l.jsx("span",{className:"text-muted-foreground",children:"-"}),l.jsx("span",{className:"rounded border border-border bg-background px-2 py-0.5 w-10 text-center",children:f.to}),l.jsxs("span",{className:"text-muted-foreground",children:["/ ",f.total]}),l.jsx("span",{className:"text-primary font-medium ml-1",children:f.count})]},f.name))})]}),l.jsxs("div",{children:[l.jsxs("p",{className:"text-xs font-medium text-foreground mb-2",children:["Topic / Research Question ",l.jsx("span",{className:"text-primary",children:"*"})]}),l.jsxs("div",{className:"rounded-lg border border-border bg-background px-3 py-2 min-h-[48px] text-sm text-foreground",children:[t,l.jsx("span",{className:"inline-block w-[2px] h-4 bg-primary align-middle ml-0.5 animate-pulse"})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-[11px] font-medium text-foreground mb-1",children:"Mode"}),l.jsxs("div",{className:"rounded-lg border border-border bg-background px-3 py-2 text-xs text-foreground flex items-center justify-between",children:["Short (300 Tokens)",l.jsx("span",{className:"text-muted-foreground",children:"▾"})]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-[11px] font-medium text-foreground mb-1",children:"Citation Style"}),l.jsxs("div",{className:"rounded-lg border border-border bg-background px-3 py-2 text-xs text-foreground flex items-center justify-between",children:["APA7",l.jsx("span",{className:"text-muted-foreground",children:"▾"})]})]})]}),l.jsx("div",{className:`w-full rounded-lg bg-primary text-primary-foreground text-sm font-medium py-2.5 text-center transition-transform ${s?"scale-105 shadow-lg shadow-primary/30":"scale-100"}`,children:"Generate Paragraph"})]}),l.jsxs("div",{className:"md:col-span-3 bg-card p-6 space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:"Result"}),l.jsx("span",{className:"text-xs rounded-full bg-muted border border-border px-3 py-1 text-muted-foreground",children:"Live Preview"})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-bold text-foreground text-lg",children:"Theory & Background"}),l.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[l.jsx("span",{className:"text-[11px] rounded-md bg-primary/10 text-primary px-2 py-0.5",children:"maslach_burnout_inventory.pdf"}),l.jsx("span",{className:"text-[11px] rounded-md bg-primary/10 text-primary px-2 py-0.5",children:"meyer_remote_work_2022.pdf"})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:"Short | APA7 | 9/5/2026"})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2 uppercase tracking-wide",children:"Generated Text"}),l.jsx("div",{className:"rounded-xl border border-border bg-background p-4 min-h-[180px]",children:l.jsxs("p",{className:"text-sm leading-relaxed text-foreground",children:[r,r.length>0&&r.length<I4.length&&l.jsx("span",{className:"inline-block w-[2px] h-4 bg-primary align-middle ml-0.5 animate-pulse"})]})})]}),a>0&&l.jsxs("div",{className:"animate-fade-in",children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Original Quotes"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Original Language"}),l.jsx("div",{className:"w-8 h-4 rounded-full bg-primary/30 relative",children:l.jsx("div",{className:"absolute right-0.5 top-0.5 w-3 h-3 rounded-full bg-primary"})})]})]}),l.jsx("div",{className:"space-y-2",children:ivt.slice(0,a).map((f,p)=>l.jsxs("div",{className:"border-l-4 border-primary bg-muted/40 rounded-r-lg p-3 animate-fade-in",children:[l.jsxs("p",{className:"text-xs italic text-foreground leading-relaxed",children:['"',f.text,'"']}),l.jsx("p",{className:"text-[11px] text-muted-foreground mt-1.5",children:f.cite})]},p))})]})]})]}),l.jsxs("div",{className:"border-t border-border px-6 py-5 text-center bg-muted/30",children:[l.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"This is what Academly generates from your PDFs"}),l.jsx(ye,{asChild:!0,className:"rounded-full px-6",children:l.jsxs(bt,{to:"/login",children:["Try it with your own sources",l.jsx(eh,{className:"h-4 w-4 ml-2"})]})})]})]})})})},gte="AI in Education",ovt=80,lvt=1e3,cvt=500,uvt=400,dvt=5e3,hvt=600,fvt=[{title:"Burnout in Remote Work Environments",questions:["How does remote work contribute to emotional exhaustion among employees?","What role does work-life balance play in preventing burnout?"],method:"Mixed-methods approach combining quantitative surveys with qualitative interviews to assess burnout levels in remote settings.",relevance:"Understanding burnout in remote settings is critical for organizational health and employee wellbeing in the post-pandemic era.",sources:[{text:"Maslach, C. & Jackson, S.E. (1981). The measurement of experienced burnout.",doi:"10.1002/job.4030020205"},{text:"Meyer, B. et al. (2022). Remote work and stress.",doi:"10.1007/s11528-022-00731-4"}]},{title:"AI-Driven Personalized Learning in Higher Education",questions:["How can AI algorithms adapt learning paths to individual student needs?","What impact does personalized learning have on academic performance?"],method:"Comparative analysis of traditional teaching versus AI-driven personalization using case studies from three universities.",relevance:"AI personalization has the potential to revolutionize higher education by addressing diverse learning styles and improving outcomes.",sources:[{text:"Holmes, W. et al. (2019). Artificial Intelligence in Education.",doi:"10.1007/s11528-019-00422-5"},{text:"Baker, R.S. (2016). Big data and education.",doi:"10.1007/s11528-016-0104-0"}]}],pvt=()=>{const[t,e]=j.useState(""),[r,n]=j.useState(!1),[s,i]=j.useState(0),[a,o]=j.useState(!1);return j.useEffect(()=>{let c=[],u=[],d=!1;const h=()=>{d||(e(""),n(!1),i(0),o(!1),c.push(setTimeout(()=>{let f=0;const p=setInterval(()=>{f++,e(gte.slice(0,f)),f>=gte.length&&(clearInterval(p),c.push(setTimeout(()=>{n(!0),c.push(setTimeout(()=>n(!1),cvt)),c.push(setTimeout(()=>{i(1),c.push(setTimeout(()=>i(2),uvt)),c.push(setTimeout(()=>{o(!0),c.push(setTimeout(h,hvt))},dvt))},500))},200)))},ovt);u.push(p)},lvt)))};return h(),()=>{d=!0,c.forEach(clearTimeout),u.forEach(clearInterval)}},[]),l.jsx("section",{className:"py-8",children:l.jsx("div",{className:"max-w-5xl mx-auto px-6",children:l.jsxs("div",{className:`transition-opacity duration-500 ${a?"opacity-0":"opacity-100"}`,children:[l.jsxs("div",{className:"rounded-2xl border border-border bg-card shadow-sm p-6 mb-8",children:[l.jsxs("div",{className:"flex items-start gap-3 mb-5",children:[l.jsx("div",{className:"rounded-lg bg-primary/10 p-2 text-primary",children:l.jsx(rm,{className:"h-5 w-5"})}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-foreground",children:"Generate Topic Suggestions"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter your basic idea and receive structured suggestions"})]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-10 gap-4 mb-4",children:[l.jsxs("div",{className:"md:col-span-7",children:[l.jsx("p",{className:"text-xs font-medium text-foreground mb-1.5",children:"Working Title / Topic Idea"}),l.jsxs("div",{className:"rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground min-h-[40px] flex items-center",children:[t,l.jsx("span",{className:"inline-block w-[2px] h-4 bg-primary ml-0.5 animate-pulse"})]})]}),l.jsxs("div",{className:"md:col-span-3",children:[l.jsx("p",{className:"text-xs font-medium text-foreground mb-1.5",children:"Output Language"}),l.jsxs("div",{className:"rounded-lg border border-border bg-background p-1 flex text-xs",children:[l.jsx("div",{className:"flex-1 text-center py-1.5 rounded text-muted-foreground",children:"DE"}),l.jsx("div",{className:"flex-1 text-center py-1.5 rounded bg-primary text-primary-foreground font-medium",children:"EN"})]})]})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("p",{className:"text-xs font-medium text-foreground mb-1.5",children:"Description / Context"}),l.jsx("div",{className:"rounded-lg border border-border bg-background px-3 py-2 text-sm text-muted-foreground min-h-[72px]",children:"Describe program, scope, methodology, context..."})]}),l.jsx("div",{className:`w-full rounded-lg bg-primary text-primary-foreground text-sm font-medium py-2.5 text-center transition-transform ${r?"scale-[1.02] shadow-lg shadow-primary/30":"scale-100"}`,children:"Generate Suggestions"})]}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:fvt.map((c,u)=>l.jsxs("div",{className:`rounded-xl border border-border bg-card shadow-sm p-5 transition-opacity duration-500 ${s>u?"opacity-100":"opacity-0"}`,children:[l.jsx("h4",{className:"font-bold text-lg text-foreground mb-4",children:c.title}),l.jsxs("div",{className:"mb-3",children:[l.jsx("p",{className:"font-semibold text-sm text-primary mb-1",children:"Research Questions"}),l.jsx("ul",{className:"text-sm text-foreground space-y-1 list-disc list-inside",children:c.questions.map(d=>l.jsx("li",{children:d},d))})]}),l.jsxs("div",{className:"mb-3",children:[l.jsx("p",{className:"font-semibold text-sm text-primary mb-1",children:"Method"}),l.jsx("p",{className:"text-sm text-foreground",children:c.method})]}),l.jsxs("div",{className:"mb-3",children:[l.jsx("p",{className:"font-semibold text-sm text-primary mb-1",children:"Relevance"}),l.jsx("p",{className:"text-sm text-foreground",children:c.relevance})]}),l.jsxs("div",{className:"mb-4",children:[l.jsx("p",{className:"font-semibold text-sm text-primary mb-1",children:"Initial Sources"}),l.jsx("ul",{className:"space-y-1",children:c.sources.map(d=>l.jsxs("li",{className:"text-xs text-muted-foreground",children:[d.text,l.jsx("br",{}),l.jsxs("span",{className:"text-[11px]",children:["DOI: ",d.doi]})]},d.doi))})]}),l.jsx(ye,{variant:"outline",className:"w-full opacity-50 cursor-not-allowed",disabled:!0,children:"Select"})]},c.title))})]})})})},mvt=[{icon:s2e,title:"Real Sources Only",text:"Academly only works with your uploaded academic PDFs."},{icon:Tce,title:"Verified Page References",text:"Every citation can be traced back to specific pages."},{icon:X2e,title:"No Hallucinated References",text:"No invented books, papers or authors."},{icon:TH,title:"GDPR & EU Hosted",text:"Built for privacy-conscious students and universities."}],gvt=()=>l.jsx("section",{className:"py-16 lg:py-24",children:l.jsxs(Wr,{children:[l.jsxs("div",{className:"max-w-2xl mx-auto text-center mb-12",children:[l.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary mb-3",children:"Academic trust"}),l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4",children:"Built for academic trust."}),l.jsx("p",{className:"text-muted-foreground text-lg",children:"Unlike generic AI tools, Academly is designed around verifiable academic work."})]}),l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-5",children:mvt.map(t=>{const e=t.icon;return l.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6 transition hover:shadow-xl hover:shadow-primary/5",children:[l.jsx("div",{className:"w-11 h-11 rounded-xl bg-primary/10 text-primary flex items-center justify-center mb-4",children:l.jsx(e,{className:"w-5 h-5"})}),l.jsx("h3",{className:"font-semibold text-foreground mb-2",children:t.title}),l.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.text})]},t.title)})})]})}),yte=[{icon:hh,title:"Upload Interviews"},{icon:E2e,title:"Create Categories"},{icon:qy,title:"Analyze Findings"},{icon:Br,title:"Generate Discussion"}],yvt=()=>l.jsx("section",{className:"py-16 lg:py-24 bg-muted/30",children:l.jsxs(Wr,{children:[l.jsxs("div",{className:"max-w-2xl mx-auto text-center mb-12",children:[l.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary mb-3",children:"Qualitative Analysis"}),l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4",children:"The only thesis platform with integrated Mayring analysis."}),l.jsx("p",{className:"text-muted-foreground text-lg",children:"From interview coding to discussion chapter, all in one workflow."})]}),l.jsx("div",{className:"flex flex-col md:flex-row items-stretch md:items-center justify-center gap-4 md:gap-3 max-w-5xl mx-auto mb-10",children:yte.map((t,e)=>{const r=t.icon;return l.jsxs("div",{className:"flex items-center gap-4 md:gap-3 md:flex-col md:flex-1",children:[l.jsxs("div",{className:"flex-1 md:flex-none w-full rounded-2xl border border-border bg-card p-5 text-center shadow-sm",children:[l.jsx("div",{className:"w-11 h-11 rounded-xl bg-primary/10 text-primary mx-auto flex items-center justify-center mb-3",children:l.jsx(r,{className:"w-5 h-5"})}),l.jsx("p",{className:"text-sm font-semibold text-foreground",children:t.title}),l.jsxs("p",{className:"text-[11px] uppercase tracking-widest text-muted-foreground mt-1",children:["Step ",e+1]})]}),e<yte.length-1&&l.jsx(eh,{className:"hidden md:block w-5 h-5 text-muted-foreground shrink-0 md:-mx-1"})]},t.title)})}),l.jsx("div",{className:"text-center",children:l.jsx(ye,{asChild:!0,className:"rounded-full px-8",children:l.jsx(bt,{to:"/login?mode=signup",children:"Explore Qualitative Analysis"})})})]})}),xvt=[{icon:_$,title:"Turn research into thesis chapters",description:"Generate structured theory, methods, discussion and conclusion chapters directly from your sources."},{icon:qy,title:"Complete Mayring workflow in one place",description:"Code interviews, create categories and generate findings without switching tools."},{icon:Gy,title:"Get feedback before your supervisor sees it",description:"Identify weak arguments, missing sections and unclear writing before submission."},{icon:Ah,title:"Never lose track of a source again",description:"Every citation stays connected to real PDFs and verified page references."}],vvt=()=>l.jsx("div",{id:"features",className:"py-16 lg:py-24",children:l.jsxs(Wr,{children:[l.jsxs("div",{className:"md:w-2/3 lg:w-1/2",children:[l.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary mb-3",children:"Why Academly"}),l.jsx("h2",{className:"my-4 text-2xl font-bold text-foreground md:text-4xl",children:"Built for thesis writing, not generic chatting."}),l.jsx("p",{className:"text-muted-foreground",children:"Outcomes you can't get from ChatGPT, Claude or Gemini: source-backed chapters, verifiable citations and a complete academic workflow."})]}),l.jsx("div",{className:"mt-12 grid divide-x divide-y divide-border overflow-hidden rounded-3xl border border-border text-muted-foreground sm:grid-cols-2 lg:grid-cols-4 lg:divide-y-0",children:xvt.map((t,e)=>l.jsx("div",{className:"group relative bg-card transition hover:z-[1] hover:shadow-2xl hover:shadow-gray-600/10",children:l.jsxs("div",{className:"relative space-y-6 py-10 p-7",children:[l.jsx(t.icon,{className:"w-10 h-10 text-primary"}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("h3",{className:"text-lg font-semibold text-foreground transition group-hover:text-primary",children:t.title}),l.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.description})]})]})},e))}),l.jsxs("div",{className:"mt-24 max-w-3xl mx-auto",children:[l.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-primary mb-3",children:"ChatGPT vs Academly"}),l.jsx("h3",{className:"text-center text-2xl md:text-3xl font-bold text-foreground mb-3",children:"Why students switch from ChatGPT to Academly"}),l.jsxs("p",{className:"text-center text-muted-foreground mb-10",children:["ChatGPT helps you write. Academly helps you write ",l.jsx("em",{children:"academically"}),"."]}),l.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[l.jsxs("div",{className:"rounded-2xl bg-primary p-7 text-primary-foreground",children:[l.jsx("p",{className:"font-bold text-lg mb-6",children:"Academly"}),l.jsx("ul",{className:"space-y-3",children:["Source-backed citations from your PDFs","Verified page numbers","Thesis-specific structure","AI Thesis Supervisor for feedback","Full Mayring qualitative workflow"].map(t=>l.jsxs("li",{className:"flex items-start gap-3 text-sm",children:[l.jsx(Es,{className:"w-4 h-4 mt-0.5 shrink-0 opacity-90"}),l.jsx("span",{children:t})]},t))})]}),l.jsxs("div",{className:"rounded-2xl border border-border bg-card p-7",children:[l.jsx("p",{className:"font-bold text-lg text-muted-foreground mb-6",children:"ChatGPT"}),l.jsx("ul",{className:"space-y-3",children:["Can invent citations","No source traceability","No thesis workflow","No qualitative analysis workflow","Generic chat without academic structure"].map(t=>l.jsxs("li",{className:"flex items-start gap-3 text-sm",children:[l.jsx(Is,{className:"w-4 h-4 mt-0.5 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"text-muted-foreground",children:t})]},t))})]})]})]})]})}),bvt=[{icon:hh,title:"Upload academic sources",text:"Add the PDFs, papers and interviews you want your thesis to be built on."},{icon:z2e,title:"Select relevant pages",text:"Pick the exact pages and passages Academly should write from."},{icon:Qs,title:"Generate source-based drafts",text:"Produce theory, methods, discussion and conclusion text grounded in those sources."},{icon:r2e,title:"Verify citations",text:"Every quote and reference links back to the original PDF and page number."},{icon:ps,title:"Build your thesis",text:"Assemble verified chapters into a structured Bachelor or Master thesis."}],wvt=()=>l.jsx("section",{id:"how-it-works",className:"py-16 lg:py-24",children:l.jsxs(Wr,{children:[l.jsxs("div",{className:"max-w-2xl mx-auto text-center mb-12",children:[l.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary mb-3",children:"Workflow"}),l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground",children:"How Academly works"})]}),l.jsx("ol",{className:"grid gap-4 md:grid-cols-5 max-w-6xl mx-auto",children:bvt.map((t,e)=>{const r=t.icon;return l.jsxs("li",{className:"relative rounded-2xl border border-border bg-card p-5 shadow-sm",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg bg-primary/10 text-primary flex items-center justify-center",children:l.jsx(r,{className:"w-4 h-4"})}),l.jsxs("span",{className:"text-[11px] font-bold uppercase tracking-widest text-primary/60",children:["Step ",e+1]})]}),l.jsx("h3",{className:"font-semibold text-foreground mb-1.5 text-sm",children:t.title}),l.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:t.text})]},t.title)})})]})}),Svt=Nh("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-success-50 text-success-600 dark:bg-success-500/20 dark:text-success-400",warning:"border-transparent bg-warning-50 text-warning-600 dark:bg-warning-500/20 dark:text-warning-400",error:"border-transparent bg-error-50 text-error-600 dark:bg-error-500/20 dark:text-error-400"}},defaultVariants:{variant:"default"}});function kt({className:t,variant:e,...r}){return l.jsx("div",{className:Le(Svt({variant:e}),t),...r})}const xte=[{quarter:"Q3 2025",title:"Core Platform",description:"Dashboard, Document Library, PDF Upload, Text Extractor, Page Selector",icon:l.jsx(vu,{className:"h-4 w-4"})},{quarter:"Q4 2025",title:"Writing Suite",description:"Topic Explorer (Ideas, Outline, Keywords), Theory & Background, Methods & Approach, Discussion Generator",icon:l.jsx(vu,{className:"h-4 w-4"})},{quarter:"Q1 2026",title:"Analysis & Completion",description:"Qualitative Analysis (Full Mayring workflow), Citation Manager, Conclusion Generator, AI Thesis Supervisor",icon:l.jsx(vu,{className:"h-4 w-4"})}],R4=[{key:"student-hub",label:"Student Hub",icon:l.jsx(Bce,{className:"h-4 w-4"}),timeline:[{quarter:"Q1 2026",title:"Development",description:"Building user exchange and community chat features."},{quarter:"Q1 2026",title:"Beta Testing",description:"Early adopters test collaboration and resource sharing."},{quarter:"Q2 2026",title:"Fully Integrated",description:"Student Hub launches with matching and community tools."}],items:[{title:"Community Chat & Exchange",description:"Connect with fellow students, share experiences and get peer feedback on your research.",status:"planned",why:"Collaboration accelerates learning."},{title:"Resource Sharing",description:"Share and discover literature, templates, and research resources within your discipline.",status:"planned",why:"Great research builds on shared knowledge."},{title:"Project Matching",description:"Find study partners and collaborators matched by discipline and research interests.",status:"exploring",why:"The right team makes all the difference."}]},{key:"transcription",label:"Transcription",icon:l.jsx(L2e,{className:"h-4 w-4"}),timeline:[{quarter:"Q2 2026",title:"Development",description:"Core audio/video transcription engine for interviews."},{quarter:"Q2 2026",title:"Beta Multilanguage",description:"Testing German, English and additional language support."},{quarter:"Q3 2026",title:"Fully Integrated",description:"Seamless transcription pipeline for all users."}],items:[{title:"Audio/Video Transcription",description:"Automatically transcribe interview recordings into structured text for analysis.",status:"planned",why:"Saves hours of manual transcription work."},{title:"Multilanguage Support",description:"Full platform support for German, English and additional languages.",status:"planned",why:"Research is global — your tools should be too."}]},{key:"quantitative-module",label:"Quantitative Module",icon:l.jsx(qy,{className:"h-4 w-4"}),timeline:[{quarter:"Q2 2026",title:"Exploring Modular Design",description:"Defining the architecture for pluggable analysis modules."},{quarter:"Q2 2026",title:"Data Visualization",description:"Developing charts, boxplots and visual analysis tools."},{quarter:"Q3 2026",title:"Beta Testing",description:"Validating statistical workflows with early testers."},{quarter:"Q3 2026",title:"Going Live",description:"Full quantitative analysis module available to all users."}],items:[{title:"Quantitative Analysis",description:"Statistical analysis tools for survey data, experiments, and quantitative research methods.",status:"exploring",why:"Complete your methodology toolkit."},{title:"Data Visualization",description:"Generate charts, boxplots, and graphs directly from your research data.",status:"exploring",why:"Visual evidence strengthens your thesis."},{title:"Automated Insights",description:"AI-assisted pattern detection and key findings from your datasets.",status:"exploring",why:"Discover what your data is telling you."}]},{key:"citations",label:"Citation Styles",icon:l.jsx(Ah,{className:"h-4 w-4"}),timeline:[{quarter:"Q2 2026",title:"Development",description:"Implementing MLA, Chicago, Harvard and Vancouver parsers."},{quarter:"Q2 2026",title:"Beta Testing",description:"Testing citation accuracy across multiple style guides."},{quarter:"Q3 2026",title:"Shipping",description:"All new citation styles available for every user."}],items:[{title:"MLA & Chicago",description:"Support for MLA 9th edition and Chicago (Notes & Bibliography + Author-Date).",status:"planned",why:"Essential for humanities and social sciences."},{title:"Harvard & Vancouver",description:"Harvard referencing and Vancouver (numbered) citation styles.",status:"planned",why:"Required by many European and medical universities."},{title:"IEEE",description:"IEEE citation format for engineering and computer science papers.",status:"planned",why:"Standard in technical disciplines."}]}],_vt={done:{label:"Done",variant:"success"},planned:{label:"Planned",variant:"default"},exploring:{label:"Exploring",variant:"warning"}},jvt=({milestones:t})=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"hidden md:block relative mb-10",children:[l.jsx("div",{className:"absolute top-4 left-0 right-0 h-0.5 bg-border"}),l.jsx("div",{className:"grid gap-8 relative",style:{gridTemplateColumns:`repeat(${t.length}, minmax(0, 1fr))`},children:t.map((e,r)=>l.jsxs(ic.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3,delay:r*.1},className:"flex flex-col items-center text-center",children:[l.jsx("div",{className:"relative z-10 mb-3 flex h-8 w-8 items-center justify-center rounded-full bg-muted border border-border text-muted-foreground shadow-sm",children:l.jsx(JG,{className:"h-3.5 w-3.5"})}),l.jsx(kt,{variant:"default",className:"mb-1 text-[10px]",children:e.quarter}),l.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),e.description&&l.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 max-w-[180px] leading-relaxed",children:e.description})]},r))})]}),l.jsxs("div",{className:"md:hidden space-y-4 relative pl-7 mb-8",children:[l.jsx("div",{className:"absolute left-[13px] top-0 bottom-0 w-0.5 bg-border"}),t.map((e,r)=>l.jsxs(ic.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{duration:.3,delay:r*.08},className:"relative",children:[l.jsx("div",{className:"absolute -left-7 top-0.5 z-10 flex h-6 w-6 items-center justify-center rounded-full bg-muted border border-border text-muted-foreground",children:l.jsx(JG,{className:"h-3 w-3"})}),l.jsx(kt,{variant:"default",className:"mb-0.5 text-[10px]",children:e.quarter}),l.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),e.description&&l.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:e.description})]},r))]})]}),kvt=()=>{const[t,e]=j.useState(R4[0].key),r=R4.find(n=>n.key===t);return l.jsx("section",{id:"roadmap",className:"py-20 sm:py-28 bg-muted/30",children:l.jsxs(Wr,{children:[l.jsxs(ic.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5},className:"text-center mb-16",children:[l.jsx(kt,{variant:"secondary",className:"mb-4",children:"Roadmap"}),l.jsx("h2",{className:"text-3xl sm:text-4xl font-bold tracking-tight text-foreground mb-4",children:"Building the Future of Academic Writing"}),l.jsx("p",{className:"text-muted-foreground max-w-2xl mx-auto text-lg",children:"Academly assists your research process. You remain the author. This roadmap shows planned features and may evolve based on community feedback."})]}),l.jsxs("div",{className:"mb-20",children:[l.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-muted-foreground mb-8 text-center",children:"What we've shipped"}),l.jsxs("div",{className:"hidden md:block relative",children:[l.jsx("div",{className:"absolute top-5 left-0 right-0 h-0.5 bg-border"}),l.jsx("div",{className:"grid grid-cols-3 gap-8 relative",children:xte.map((n,s)=>l.jsxs(ic.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:s*.15},className:"flex flex-col items-center text-center",children:[l.jsx("div",{className:"relative z-10 mb-4 flex h-10 w-10 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-md shadow-primary/20",children:n.icon}),l.jsx(kt,{variant:"success",className:"mb-2",children:n.quarter}),l.jsx("p",{className:"font-semibold text-foreground mb-1",children:n.title}),l.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:n.description})]},n.quarter))})]}),l.jsxs("div",{className:"md:hidden space-y-6 relative pl-8",children:[l.jsx("div",{className:"absolute left-[15px] top-0 bottom-0 w-0.5 bg-border"}),xte.map((n,s)=>l.jsxs(ic.div,{initial:{opacity:0,x:-10},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.4,delay:s*.1},className:"relative",children:[l.jsx("div",{className:"absolute -left-8 top-1 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-md shadow-primary/20",children:n.icon}),l.jsx(kt,{variant:"success",className:"mb-1",children:n.quarter}),l.jsx("p",{className:"font-semibold text-foreground",children:n.title}),l.jsx("p",{className:"text-sm text-muted-foreground",children:n.description})]},n.quarter))]})]}),l.jsxs("div",{children:[l.jsxs(ic.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4},className:"text-center mb-8",children:[l.jsx("h3",{className:"text-2xl sm:text-3xl font-bold tracking-tight text-foreground mb-2",children:"What's Next"}),l.jsx("p",{className:"text-muted-foreground max-w-xl mx-auto",children:"Explore the development tracks we're working on. Select a track to see details and timelines."})]}),l.jsx("div",{className:"flex flex-wrap items-center justify-center gap-2 mb-10",children:R4.map(n=>l.jsxs("button",{onClick:()=>e(n.key),className:`inline-flex items-center gap-2 rounded-full px-4 py-2 text-sm font-medium transition-all duration-200 ${t===n.key?"bg-primary text-primary-foreground shadow-md shadow-primary/20":"bg-card border border-border/50 text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[n.icon,n.label]},n.key))}),l.jsxs(ic.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3},children:[r.timeline&&l.jsx(jvt,{milestones:r.timeline}),l.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:r.items.map((n,s)=>{const i=_vt[n.status];return l.jsx(ze,{className:"flex flex-col",children:l.jsxs(Ge,{className:"pt-6 flex flex-col flex-1",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[l.jsx("h4",{className:"font-semibold text-foreground leading-snug",children:n.title}),l.jsx(kt,{variant:i.variant,className:"shrink-0",children:i.label})]}),l.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed mb-3 flex-1",children:n.description}),l.jsxs("p",{className:"text-xs text-muted-foreground/70 flex items-start gap-1.5",children:[l.jsx(rm,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),n.why]})]})},s)})})]},t)]})]})})},Nvt=()=>l.jsxs("div",{className:"relative py-16 lg:py-24",children:[l.jsxs("div",{"aria-hidden":"true",className:"absolute inset-0 h-max w-full m-auto grid grid-cols-2 -space-x-52 opacity-40 dark:opacity-20",children:[l.jsx("div",{className:"blur-[106px] h-56 bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),l.jsx("div",{className:"blur-[106px] h-32 bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),l.jsx(Wr,{children:l.jsxs("div",{className:"relative m-auto space-y-6 md:w-9/12 lg:w-8/12",children:[l.jsx("h2",{className:"text-center text-4xl font-bold text-foreground md:text-5xl",children:"Stop wasting weeks organizing sources."}),l.jsx("p",{className:"text-center text-xl text-muted-foreground",children:"Write faster, stay academically safe and keep every citation connected to real research."}),l.jsxs("div",{className:"flex flex-wrap justify-center gap-6 pt-2",children:[l.jsx(bt,{to:"/login?mode=signup",className:"relative flex h-12 w-full items-center justify-center px-8 before:absolute before:inset-0 before:rounded-full before:bg-primary before:transition before:duration-300 hover:before:scale-105 active:duration-75 active:before:scale-95 sm:w-max","data-umami-event":"cta-signup-click","data-umami-event-location":"final-cta",children:l.jsx("span",{className:"relative text-base font-semibold text-primary-foreground",children:"Start Free"})}),l.jsx("a",{href:"#source-demo",className:"relative flex h-12 w-full items-center justify-center px-8 before:absolute before:inset-0 before:rounded-full before:border before:border-transparent before:bg-primary/10 before:transition before:duration-300 hover:before:scale-105 active:duration-75 active:before:scale-95 dark:before:border-gray-700 dark:before:bg-gray-800 sm:w-max",children:l.jsx("span",{className:"relative text-base font-semibold text-primary dark:text-white",children:"See Source Demo"})})]})]})})]}),Ui=({title:t,description:e,canonical:r,ogImage:n="https://academly.ai/og-image.png",jsonLd:s,noIndex:i=!1})=>l.jsxs(Zle,{children:[l.jsx("title",{children:t}),l.jsx("meta",{name:"description",content:e}),l.jsx("link",{rel:"canonical",href:r}),i?l.jsx("meta",{name:"robots",content:"noindex, nofollow"}):l.jsx("meta",{name:"robots",content:"index, follow"}),l.jsx("meta",{property:"og:title",content:t}),l.jsx("meta",{property:"og:description",content:e}),l.jsx("meta",{property:"og:url",content:r}),l.jsx("meta",{property:"og:type",content:"website"}),l.jsx("meta",{property:"og:image",content:n}),l.jsx("meta",{property:"og:site_name",content:"Academly.ai"}),l.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),l.jsx("meta",{name:"twitter:title",content:t}),l.jsx("meta",{name:"twitter:description",content:e}),l.jsx("meta",{name:"twitter:image",content:n}),s&&l.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})]}),Evt=[{"@context":"https://schema.org","@type":"Organization",name:"Academly.ai",url:"https://academly.ai",logo:"https://academly.ai/og-image.png",sameAs:[]},{"@context":"https://schema.org","@type":"SoftwareApplication",name:"Academly.ai",applicationCategory:"EducationalApplication",operatingSystem:"Web",description:"Thesis platform for source-backed academic writing. Upload PDFs and generate structured thesis chapters with verified citations.",url:"https://academly.ai",offers:{"@type":"Offer",price:"0",priceCurrency:"USD"}}],Avt=()=>{const[t,e]=j.useState(!0);return l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:"Academly - AI thesis writing with real citations",description:"Upload academic PDFs, generate structured thesis chapters and keep every citation connected to real research with verified page references. APA7, Harvard, MLA.",canonical:"https://academly.ai/",jsonLd:Evt}),l.jsx(Xs,{}),l.jsxs("main",{children:[l.jsx(Qxt,{}),l.jsx("section",{id:"source-demo",className:"pt-8 pb-4",children:l.jsxs("div",{className:"max-w-5xl mx-auto px-6 text-center mb-6",children:[l.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary mb-3",children:"Source-backed writing"}),l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground mb-3",children:"See exactly how Academly writes from your research."}),l.jsx("p",{className:"text-muted-foreground text-lg",children:"Upload PDFs, select source pages, generate academic text and verify every citation."})]})}),l.jsx(avt,{}),l.jsxs("div",{className:"max-w-5xl mx-auto px-6 -mt-4 mb-12 text-center",children:[l.jsx("p",{className:"text-foreground font-medium mb-4",children:"Every statement stays connected to real academic sources."}),l.jsx(ye,{asChild:!0,className:"rounded-full px-8",children:l.jsx(bt,{to:"/login?mode=signup",children:"Try it with your own sources"})})]}),l.jsx(gvt,{}),l.jsx("section",{className:"pt-8 pb-4",children:l.jsxs("div",{className:"max-w-5xl mx-auto px-6 text-center mb-2",children:[l.jsx("span",{className:"inline-block text-[11px] font-bold uppercase tracking-widest text-primary bg-primary/10 rounded-full px-3 py-1 mb-4",children:"Free tool"}),l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground mb-3",children:"Free Bachelor & Master Thesis Topic Generator"}),l.jsx("p",{className:"text-muted-foreground text-lg mb-2",children:"Generate thesis ideas, research questions and methodology suggestions in seconds."}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Perfect for students who don't know what to write about."})]})}),l.jsx(pvt,{}),l.jsx("div",{className:"max-w-5xl mx-auto px-6 -mt-6 mb-16 text-center",children:l.jsx(ye,{asChild:!0,className:"rounded-full px-8",children:l.jsx(bt,{to:"/topic-ideas",children:"Generate Thesis Topics Free"})})}),l.jsx("section",{className:"py-12",children:l.jsxs("div",{className:"max-w-5xl mx-auto px-6",children:[l.jsx("p",{className:"text-center text-muted-foreground text-sm uppercase tracking-wider mb-6",children:"See Academly in action"}),l.jsxs("div",{className:"relative rounded-2xl overflow-hidden shadow-2xl group",children:[l.jsx("video",{src:"/hero.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,"aria-label":"Academly platform demo",className:"w-full"}),l.jsxs("div",{className:"absolute inset-0 flex items-end justify-between p-4 opacity-0 group-hover:opacity-100 transition-opacity",children:[l.jsx("button",{onClick:()=>{const r=document.querySelector("video");r&&(r.muted=!r.muted,e(r.muted))},className:"bg-black/50 text-white rounded-full p-2","aria-label":t?"Unmute":"Mute",children:t?l.jsx(iPe,{size:20}):l.jsx(sPe,{size:20})}),l.jsx("button",{onClick:()=>{const r=document.querySelector("video");r&&r.requestFullscreen()},className:"bg-black/50 text-white rounded-full p-2","aria-label":"Fullscreen",children:l.jsx(I2e,{size:20})})]})]})]})}),l.jsx(vvt,{}),l.jsx(yvt,{}),l.jsx(wvt,{}),l.jsx("section",{className:"py-16",children:l.jsx("div",{className:"max-w-3xl mx-auto px-6",children:l.jsx("div",{className:"relative overflow-hidden rounded-3xl p-[1.5px] bg-gradient-to-r from-amber-300 via-orange-400 to-amber-300 shadow-2xl shadow-amber-500/20",children:l.jsxs("div",{className:"relative rounded-3xl bg-gradient-to-br from-amber-50 via-white to-orange-50 dark:from-amber-950/60 dark:via-background dark:to-orange-950/40 px-8 py-8 md:px-12 md:py-10",children:[l.jsx("div",{"aria-hidden":"true",className:"absolute -top-24 -right-24 w-64 h-64 rounded-full bg-amber-400/20 blur-3xl"}),l.jsx("div",{"aria-hidden":"true",className:"absolute -bottom-24 -left-24 w-64 h-64 rounded-full bg-orange-400/20 blur-3xl"}),l.jsxs("div",{className:"relative flex flex-col md:flex-row items-center gap-6 text-center md:text-left",children:[l.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-full bg-amber-500/15 border border-amber-500/30 shrink-0",children:[l.jsxs("span",{className:"relative flex h-2 w-2",children:[l.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-amber-500 opacity-75 animate-ping"}),l.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),l.jsx("span",{className:"text-xs font-bold uppercase tracking-widest text-amber-700 dark:text-amber-300",children:"Beta Live"})]}),l.jsxs("div",{className:"flex-1",children:[l.jsxs("h3",{className:"text-xl md:text-2xl font-bold text-foreground mb-1",children:["Completely free : get ",l.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"2,000 credits"})," on signup"]}),l.jsx("p",{className:"text-sm md:text-base text-muted-foreground",children:"Help shape Academly during our beta. No credit card required."})]}),l.jsx("a",{href:"https://discord.gg/YFHAZY8d9",target:"_blank",rel:"noreferrer",className:"shrink-0 inline-flex items-center gap-2 px-5 py-2.5 rounded-full bg-foreground text-background text-sm font-semibold hover:scale-105 transition-transform shadow-lg",children:"Join Discord →"})]})]})})})}),l.jsx(kvt,{}),l.jsx(Nvt,{})]}),l.jsx(Bi,{})]})};function nbe(){const{user:t,userProfile:e}=Dt(),[r,n]=j.useState(!1);return{loading:r,createCheckoutSession:async o=>{if(!t){We.error("Please log in to subscribe");return}n(!0);try{const{data:c,error:u}=await Qr.functions.invoke("create-checkout-session",{body:{plan:o}});if(u)throw u;if(c!=null&&c.url)window.location.href=c.url;else throw new Error("No checkout URL received")}catch(c){console.error("Checkout error:",c),We.error(c.message||"Failed to create checkout session")}finally{n(!1)}},openCustomerPortal:async o=>{if(!t){We.error("Please log in to manage subscription");return}n(!0);try{const{data:c,error:u}=await Qr.functions.invoke("create-customer-portal",{body:{targetPlan:o}});if(u)throw u;if(c!=null&&c.url)window.location.href=c.url;else throw new Error("No portal URL received")}catch(c){console.error("Portal error:",c),We.error(c.message||"Failed to open customer portal")}finally{n(!1)}},getSubscriptionStatus:()=>e?{plan:e.plan,status:e.subscription_status,endsAt:e.subscription_ends_at,isActive:e.subscription_status==="active",hasSubscription:!!e.stripe_subscription_id}:null}}const Cvt=!1,Tvt=250,Pvt=[{id:"free",name:"Free",originalPrice:null,price:"0",discount:null,points:"60",description:"Perfect for getting started",features:["60 Student Points on signup","PDF upload up to 5 MB","Basic summaries","Automatic citations"],popular:!1,launchOffer:!1,enabled:!0},{id:"pro",name:"Pro",originalPrice:"24.99",price:"15.99",discount:36,points:"2,000",description:"Ideal for active researchers",features:["2,000 Student Points per month","PDF upload up to 50 MB","Advanced summaries","Methodology Builder","Theory Builder","Discussion Builder","Qualitative Analysis","Export to multiple formats"],popular:!0,launchOffer:!0,enabled:!0},{id:"author",name:"Author",originalPrice:"39.99",price:"24.99",discount:37,points:"4,000",description:"For students & professionals",features:["4,000 Student Points per month","PDF upload up to 50 MB","All Pro features","AI-powered text blocks","Collaboration features","Custom citation styles"],popular:!1,launchOffer:!0,enabled:!0},{id:"lifetime",name:"Lifetime",originalPrice:null,price:"199",discount:null,points:"4,000",description:"One-time payment, lifetime access",features:["4,000 Student Points (renew monthly)","Lifetime access to all features","All Author features included","No monthly payments ever","Future feature updates included"],popular:!1,launchOffer:!1,isLifetime:!0,enabled:Cvt}],Ovt=Pvt.filter(t=>t.enabled!==!1),Ivt={"@context":"https://schema.org","@type":"WebPage",name:"Pricing - AI Academic Writing Plans",description:"Simple, transparent pricing for AI thesis writing. Free tier available.",url:"https://academly.ai/pricing"},Rvt=()=>{const t=Or(),{user:e,userProfile:r,loading:n}=Dt(),{createCheckoutSession:s,openCustomerPortal:i,loading:a}=nbe(),[o,c]=j.useState(null),u=(r==null?void 0:r.plan)||"free",d=(r==null?void 0:r.subscription_status)==="active";j.useEffect(()=>{(async()=>{const{data:g,error:x}=await Qr.rpc("get_lifetime_sold_count");!x&&g!==null&&c(g)})()},[]),j.useEffect(()=>{typeof window<"u"&&window.umami&&window.umami.track("pricing-page-view")},[]);const h=async m=>{if(m==="free"){t(e?"/dashboard":"/login");return}if(!e){t("/login");return}if(m==="lifetime"){await s(m);return}if(u===m&&d){await i();return}if(d){await i(m);return}await s(m)},f=m=>m==="free"?e?"Current Plan":"Get Started":m==="lifetime"?u==="lifetime"?"Current Plan":"Buy Lifetime Access":e?u===m&&d?"Manage Plan":d?"Change Plan":"Subscribe Now":"Start Trial",p=m=>m==="lifetime"&&u==="lifetime"||m==="free"&&(u==="free"||u==="starter")&&!d?!0:u===m&&d;return l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:"Pricing - AI Academic Writing Plans | Academly",description:"Simple, transparent pricing for AI thesis writing. Free tier available. Generate theory sections, methodology chapters, and more with real citations.",canonical:"https://academly.ai/pricing",jsonLd:Ivt}),l.jsx(Xs,{}),l.jsxs("section",{className:"relative pt-32 pb-20 overflow-visible",children:[l.jsxs("div",{"aria-hidden":"true",className:"absolute inset-0 -bottom-[600px] grid grid-cols-2 -space-x-52 opacity-40 dark:opacity-20 pointer-events-none overflow-visible",children:[l.jsx("div",{className:"blur-[106px] h-[400px] bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),l.jsx("div",{className:"blur-[106px] h-[300px] bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),l.jsx(Wr,{className:"relative",children:l.jsxs("div",{className:"text-center max-w-3xl mx-auto",children:[l.jsxs("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-foreground mb-6",children:["Simple, Transparent",l.jsx("span",{className:"text-primary",children:" Pricing"})]}),l.jsx("p",{className:"text-xl text-muted-foreground",children:"Choose the plan that fits your research needs. No hidden fees, cancel anytime."})]})})]}),l.jsx("section",{className:"relative py-20 overflow-visible",children:l.jsxs(Wr,{className:"max-w-screen-xl",children:[l.jsx("div",{className:"grid md:grid-cols-2 xl:grid-cols-4 gap-8",children:Ovt.map(m=>l.jsxs("div",{className:`relative rounded-3xl p-8 transition-all duration-300 hover:shadow-2xl ${m.popular?"bg-primary text-primary-foreground scale-105 shadow-2xl":m.isLifetime?"bg-card border-2 border-purple-500 ring-2 ring-purple-500/20 hover:ring-purple-500/40 shadow-lg shadow-purple-500/10":"bg-card border border-border hover:border-primary/50"}`,children:[l.jsxs("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 flex gap-2",children:[m.popular&&l.jsx("span",{className:"bg-orange-500 text-white text-sm font-medium px-4 py-1 rounded-full whitespace-nowrap",children:"Most Popular"}),m.isLifetime&&l.jsxs("span",{className:"bg-gradient-to-r from-purple-600 to-violet-500 text-white text-sm font-medium px-4 py-1 rounded-full whitespace-nowrap flex items-center gap-1.5",children:[l.jsx(gx,{className:"h-3.5 w-3.5"}),"Limited Offer"]})]}),m.launchOffer&&l.jsx("div",{className:"absolute -top-3 right-4",children:l.jsxs("span",{className:"bg-gradient-to-r from-amber-500 to-orange-500 text-white text-xs font-bold px-3 py-1 rounded-full flex items-center gap-1",children:[l.jsx(Qs,{className:"h-3 w-3"}),"-",m.discount,"%"]})}),m.isLifetime&&o!==null&&l.jsx("div",{className:"absolute -top-3 right-4",children:l.jsxs("span",{className:"bg-purple-100 dark:bg-purple-900/50 text-purple-700 dark:text-purple-300 text-xs font-bold px-3 py-1 rounded-full",children:[o,"/",Tvt," sold"]})}),l.jsxs("div",{className:"text-center mb-8 mt-2",children:[l.jsx("h3",{className:`text-2xl font-bold mb-2 ${m.popular?"":"text-foreground"}`,children:m.name}),l.jsx("p",{className:`text-sm mb-4 ${m.popular?"text-primary-foreground/80":"text-muted-foreground"}`,children:m.description}),l.jsxs("div",{className:"mb-2",children:[m.originalPrice&&l.jsxs("span",{className:`text-lg line-through ${m.popular?"text-primary-foreground/50":"text-muted-foreground"}`,children:["$",m.originalPrice]}),l.jsxs("div",{children:[l.jsxs("span",{className:"text-4xl font-bold",children:["$",m.price]}),m.id!=="free"&&!m.isLifetime&&l.jsx("span",{className:m.popular?"text-primary-foreground/80":"text-muted-foreground",children:"/month"})]})]}),l.jsx("p",{className:`text-sm ${m.popular?"text-primary-foreground/80":"text-muted-foreground"}`,children:m.isLifetime?"4,000 Student Points (renew monthly)":m.id!=="free"?`${m.points} Student Points per month`:`${m.points} Student Points`})]}),l.jsx("ul",{className:"space-y-4 mb-8",children:m.features.map((g,x)=>l.jsxs("li",{className:"flex items-start gap-3",children:[l.jsx(_c,{className:`h-5 w-5 flex-shrink-0 mt-0.5 ${m.popular?"text-primary-foreground":"text-primary"}`}),l.jsx("span",{className:`text-sm ${m.popular?"":"text-muted-foreground"}`,children:g})]},x))}),l.jsx(ye,{onClick:()=>h(m.id),disabled:a||n||p(m.id),className:`w-full rounded-full h-12 text-base font-semibold ${m.popular?"bg-white text-primary hover:bg-white/90":""}`,variant:m.popular?"secondary":"default","data-umami-event":"pricing-plan-click","data-umami-event-plan":m.id,children:a?l.jsx(xt,{className:"h-4 w-4 animate-spin"}):p(m.id)?"Current Plan":f(m.id)})]},m.name))}),l.jsxs("div",{className:"text-center mt-16",children:[l.jsx("p",{className:"text-muted-foreground mb-4"}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Need a custom plan?"," ",l.jsx("a",{href:"mailto:contact@academly.ai",className:"text-primary hover:underline",children:"Contact us"})]})]})]})}),l.jsx(Bi,{})]})};var O9={};(function t(e,r,n,s){var i=!!(e.Worker&&e.Blob&&e.Promise&&e.OffscreenCanvas&&e.OffscreenCanvasRenderingContext2D&&e.HTMLCanvasElement&&e.HTMLCanvasElement.prototype.transferControlToOffscreen&&e.URL&&e.URL.createObjectURL),a=typeof Path2D=="function"&&typeof DOMMatrix=="function",o=function(){if(!e.OffscreenCanvas)return!1;try{var B=new OffscreenCanvas(1,1),L=B.getContext("2d");L.fillRect(0,0,1,1);var F=B.transferToImageBitmap();L.createPattern(F,"no-repeat")}catch{return!1}return!0}();function c(){}function u(B){var L=r.exports.Promise,F=L!==void 0?L:e.Promise;return typeof F=="function"?new F(B):(B(c,c),null)}var d=function(B,L){return{transform:function(F){if(B)return F;if(L.has(F))return L.get(F);var V=new OffscreenCanvas(F.width,F.height),Y=V.getContext("2d");return Y.drawImage(F,0,0),L.set(F,V),V},clear:function(){L.clear()}}}(o,new Map),h=function(){var B=Math.floor(16.666666666666668),L,F,V={},Y=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(L=function(ie){var Q=Math.random();return V[Q]=requestAnimationFrame(function D(R){Y===R||Y+B-1<R?(Y=R,delete V[Q],ie()):V[Q]=requestAnimationFrame(D)}),Q},F=function(ie){V[ie]&&cancelAnimationFrame(V[ie])}):(L=function(ie){return setTimeout(ie,B)},F=function(ie){return clearTimeout(ie)}),{frame:L,cancel:F}}(),f=function(){var B,L,F={};function V(Y){function ie(Q,D){Y.postMessage({options:Q||{},callback:D})}Y.init=function(D){var R=D.transferControlToOffscreen();Y.postMessage({canvas:R},[R])},Y.fire=function(D,R,J){if(L)return ie(D,null),L;var Z=Math.random().toString(36).slice(2);return L=u(function(ee){function re(he){he.data.callback===Z&&(delete F[Z],Y.removeEventListener("message",re),L=null,d.clear(),J(),ee())}Y.addEventListener("message",re),ie(D,Z),F[Z]=re.bind(null,{data:{callback:Z}})}),L},Y.reset=function(){Y.postMessage({reset:!0});for(var D in F)F[D](),delete F[D]}}return function(){if(B)return B;if(!n&&i){var Y=["var CONFETTI, SIZE = {}, module = {};","("+t.toString()+")(this, module, true, SIZE);","onmessage = function(msg) {"," if (msg.data.options) {"," CONFETTI(msg.data.options).then(function () {"," if (msg.data.callback) {"," postMessage({ callback: msg.data.callback });"," }"," });"," } else if (msg.data.reset) {"," CONFETTI && CONFETTI.reset();"," } else if (msg.data.resize) {"," SIZE.width = msg.data.resize.width;"," SIZE.height = msg.data.resize.height;"," } else if (msg.data.canvas) {"," SIZE.width = msg.data.canvas.width;"," SIZE.height = msg.data.canvas.height;"," CONFETTI = module.exports.create(msg.data.canvas);"," }","}"].join(`
`);try{B=new Worker(URL.createObjectURL(new Blob([Y])))}catch(ie){return typeof console<"u"&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",ie),null}V(B)}return B}}(),p={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:["square","circle"],zIndex:100,colors:["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"],disableForReducedMotion:!1,scalar:1};function m(B,L){return L?L(B):B}function g(B){return B!=null}function x(B,L,F){return m(B&&g(B[L])?B[L]:p[L],F)}function y(B){return B<0?0:Math.floor(B)}function v(B,L){return Math.floor(Math.random()*(L-B))+B}function b(B){return parseInt(B,16)}function w(B){return B.map(S)}function S(B){var L=String(B).replace(/[^0-9a-f]/gi,"");return L.length<6&&(L=L[0]+L[0]+L[1]+L[1]+L[2]+L[2]),{r:b(L.substring(0,2)),g:b(L.substring(2,4)),b:b(L.substring(4,6))}}function k(B){var L=x(B,"origin",Object);return L.x=x(L,"x",Number),L.y=x(L,"y",Number),L}function E(B){B.width=document.documentElement.clientWidth,B.height=document.documentElement.clientHeight}function C(B){var L=B.getBoundingClientRect();B.width=L.width,B.height=L.height}function A(B){var L=document.createElement("canvas");return L.style.position="fixed",L.style.top="0px",L.style.left="0px",L.style.pointerEvents="none",L.style.zIndex=B,L}function M(B,L,F,V,Y,ie,Q,D,R){B.save(),B.translate(L,F),B.rotate(ie),B.scale(V,Y),B.arc(0,0,1,Q,D,R),B.restore()}function z(B){var L=B.angle*(Math.PI/180),F=B.spread*(Math.PI/180);return{x:B.x,y:B.y,wobble:Math.random()*10,wobbleSpeed:Math.min(.11,Math.random()*.1+.05),velocity:B.startVelocity*.5+Math.random()*B.startVelocity,angle2D:-L+(.5*F-Math.random()*F),tiltAngle:(Math.random()*(.75-.25)+.25)*Math.PI,color:B.color,shape:B.shape,tick:0,totalTicks:B.ticks,decay:B.decay,drift:B.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:B.gravity*3,ovalScalar:.6,scalar:B.scalar,flat:B.flat}}function P(B,L){L.x+=Math.cos(L.angle2D)*L.velocity+L.drift,L.y+=Math.sin(L.angle2D)*L.velocity+L.gravity,L.velocity*=L.decay,L.flat?(L.wobble=0,L.wobbleX=L.x+10*L.scalar,L.wobbleY=L.y+10*L.scalar,L.tiltSin=0,L.tiltCos=0,L.random=1):(L.wobble+=L.wobbleSpeed,L.wobbleX=L.x+10*L.scalar*Math.cos(L.wobble),L.wobbleY=L.y+10*L.scalar*Math.sin(L.wobble),L.tiltAngle+=.1,L.tiltSin=Math.sin(L.tiltAngle),L.tiltCos=Math.cos(L.tiltAngle),L.random=Math.random()+2);var F=L.tick++/L.totalTicks,V=L.x+L.random*L.tiltCos,Y=L.y+L.random*L.tiltSin,ie=L.wobbleX+L.random*L.tiltCos,Q=L.wobbleY+L.random*L.tiltSin;if(B.fillStyle="rgba("+L.color.r+", "+L.color.g+", "+L.color.b+", "+(1-F)+")",B.beginPath(),a&&L.shape.type==="path"&&typeof L.shape.path=="string"&&Array.isArray(L.shape.matrix))B.fill(G(L.shape.path,L.shape.matrix,L.x,L.y,Math.abs(ie-V)*.1,Math.abs(Q-Y)*.1,Math.PI/10*L.wobble));else if(L.shape.type==="bitmap"){var D=Math.PI/10*L.wobble,R=Math.abs(ie-V)*.1,J=Math.abs(Q-Y)*.1,Z=L.shape.bitmap.width*L.scalar,ee=L.shape.bitmap.height*L.scalar,re=new DOMMatrix([Math.cos(D)*R,Math.sin(D)*R,-Math.sin(D)*J,Math.cos(D)*J,L.x,L.y]);re.multiplySelf(new DOMMatrix(L.shape.matrix));var he=B.createPattern(d.transform(L.shape.bitmap),"no-repeat");he.setTransform(re),B.globalAlpha=1-F,B.fillStyle=he,B.fillRect(L.x-Z/2,L.y-ee/2,Z,ee),B.globalAlpha=1}else if(L.shape==="circle")B.ellipse?B.ellipse(L.x,L.y,Math.abs(ie-V)*L.ovalScalar,Math.abs(Q-Y)*L.ovalScalar,Math.PI/10*L.wobble,0,2*Math.PI):M(B,L.x,L.y,Math.abs(ie-V)*L.ovalScalar,Math.abs(Q-Y)*L.ovalScalar,Math.PI/10*L.wobble,0,2*Math.PI);else if(L.shape==="star")for(var O=Math.PI/2*3,ae=4*L.scalar,q=8*L.scalar,I=L.x,T=L.y,$=5,se=Math.PI/$;$--;)I=L.x+Math.cos(O)*q,T=L.y+Math.sin(O)*q,B.lineTo(I,T),O+=se,I=L.x+Math.cos(O)*ae,T=L.y+Math.sin(O)*ae,B.lineTo(I,T),O+=se;else B.moveTo(Math.floor(L.x),Math.floor(L.y)),B.lineTo(Math.floor(L.wobbleX),Math.floor(Y)),B.lineTo(Math.floor(ie),Math.floor(Q)),B.lineTo(Math.floor(V),Math.floor(L.wobbleY));return B.closePath(),B.fill(),L.tick<L.totalTicks}function W(B,L,F,V,Y){var ie=L.slice(),Q=B.getContext("2d"),D,R,J=u(function(Z){function ee(){D=R=null,Q.clearRect(0,0,V.width,V.height),d.clear(),Y(),Z()}function re(){n&&!(V.width===s.width&&V.height===s.height)&&(V.width=B.width=s.width,V.height=B.height=s.height),!V.width&&!V.height&&(F(B),V.width=B.width,V.height=B.height),Q.clearRect(0,0,V.width,V.height),ie=ie.filter(function(he){return P(Q,he)}),ie.length?D=h.frame(re):ee()}D=h.frame(re),R=ee});return{addFettis:function(Z){return ie=ie.concat(Z),J},canvas:B,promise:J,reset:function(){D&&h.cancel(D),R&&R()}}}function N(B,L){var F=!B,V=!!x(L||{},"resize"),Y=!1,ie=x(L,"disableForReducedMotion",Boolean),Q=i&&!!x(L||{},"useWorker"),D=Q?f():null,R=F?E:C,J=B&&D?!!B.__confetti_initialized:!1,Z=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion)").matches,ee;function re(O,ae,q){for(var I=x(O,"particleCount",y),T=x(O,"angle",Number),$=x(O,"spread",Number),se=x(O,"startVelocity",Number),ue=x(O,"decay",Number),ne=x(O,"gravity",Number),me=x(O,"drift",Number),ve=x(O,"colors",w),xe=x(O,"ticks",Number),oe=x(O,"shapes"),de=x(O,"scalar"),ge=!!x(O,"flat"),Se=k(O),ke=I,Ne=[],qe=B.width*Se.x,Ae=B.height*Se.y;ke--;)Ne.push(z({x:qe,y:Ae,angle:T,spread:$,startVelocity:se,color:ve[ke%ve.length],shape:oe[v(0,oe.length)],ticks:xe,decay:ue,gravity:ne,drift:me,scalar:de,flat:ge}));return ee?ee.addFettis(Ne):(ee=W(B,Ne,R,ae,q),ee.promise)}function he(O){var ae=ie||x(O,"disableForReducedMotion",Boolean),q=x(O,"zIndex",Number);if(ae&&Z)return u(function(se){se()});F&&ee?B=ee.canvas:F&&!B&&(B=A(q),document.body.appendChild(B)),V&&!J&&R(B);var I={width:B.width,height:B.height};D&&!J&&D.init(B),J=!0,D&&(B.__confetti_initialized=!0);function T(){if(D){var se={getBoundingClientRect:function(){if(!F)return B.getBoundingClientRect()}};R(se),D.postMessage({resize:{width:se.width,height:se.height}});return}I.width=I.height=null}function $(){ee=null,V&&(Y=!1,e.removeEventListener("resize",T)),F&&B&&(document.body.contains(B)&&document.body.removeChild(B),B=null,J=!1)}return V&&!Y&&(Y=!0,e.addEventListener("resize",T,!1)),D?D.fire(O,I,$):re(O,I,$)}return he.reset=function(){D&&D.reset(),ee&&ee.reset()},he}var U;function K(){return U||(U=N(null,{useWorker:!0,resize:!0})),U}function G(B,L,F,V,Y,ie,Q){var D=new Path2D(B),R=new Path2D;R.addPath(D,new DOMMatrix(L));var J=new Path2D;return J.addPath(R,new DOMMatrix([Math.cos(Q)*Y,Math.sin(Q)*Y,-Math.sin(Q)*ie,Math.cos(Q)*ie,F,V])),J}function X(B){if(!a)throw new Error("path confetti are not supported in this browser");var L,F;typeof B=="string"?L=B:(L=B.path,F=B.matrix);var V=new Path2D(L),Y=document.createElement("canvas"),ie=Y.getContext("2d");if(!F){for(var Q=1e3,D=Q,R=Q,J=0,Z=0,ee,re,he=0;he<Q;he+=2)for(var O=0;O<Q;O+=2)ie.isPointInPath(V,he,O,"nonzero")&&(D=Math.min(D,he),R=Math.min(R,O),J=Math.max(J,he),Z=Math.max(Z,O));ee=J-D,re=Z-R;var ae=10,q=Math.min(ae/ee,ae/re);F=[q,0,0,q,-Math.round(ee/2+D)*q,-Math.round(re/2+R)*q]}return{type:"path",path:L,matrix:F}}function H(B){var L,F=1,V="#000000",Y='"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "EmojiOne Color", "Android Emoji", "Twemoji Mozilla", "system emoji", sans-serif';typeof B=="string"?L=B:(L=B.text,F="scalar"in B?B.scalar:F,Y="fontFamily"in B?B.fontFamily:Y,V="color"in B?B.color:V);var ie=10*F,Q=""+ie+"px "+Y,D=new OffscreenCanvas(ie,ie),R=D.getContext("2d");R.font=Q;var J=R.measureText(L),Z=Math.ceil(J.actualBoundingBoxRight+J.actualBoundingBoxLeft),ee=Math.ceil(J.actualBoundingBoxAscent+J.actualBoundingBoxDescent),re=2,he=J.actualBoundingBoxLeft+re,O=J.actualBoundingBoxAscent+re;Z+=re+re,ee+=re+re,D=new OffscreenCanvas(Z,ee),R=D.getContext("2d"),R.font=Q,R.fillStyle=V,R.fillText(L,he,O);var ae=1/F;return{type:"bitmap",bitmap:D.transferToImageBitmap(),matrix:[ae,0,0,ae,-Z*ae/2,-ee*ae/2]}}r.exports=function(){return K().apply(this,arguments)},r.exports.reset=function(){K().reset()},r.exports.create=N,r.exports.shapeFromPath=X,r.exports.shapeFromText=H})(function(){return typeof window<"u"?window:typeof self<"u"?self:this||{}}(),O9,!1);const Mvt=O9.exports;O9.exports.create;const vte={pro:"Pro",author:"Author",lifetime:"Lifetime"},Dvt=()=>{const{userProfile:t,refreshProfile:e}=Dt(),[r]=oE(),n=r.get("upgraded")==="true",[s,i]=j.useState(n),[a,o]=j.useState(0),c=j.useMemo(()=>{const d=t==null?void 0:t.plan;return d&&vte[d]?vte[d]:"Premium"},[t==null?void 0:t.plan]);j.useEffect(()=>{if(!n||!s)return;if(a>=10){i(!1);return}const d=setTimeout(async()=>{await(e==null?void 0:e()),o(h=>h+1)},1500);return()=>clearTimeout(d)},[n,s,a,e]),j.useEffect(()=>{s||Mvt({particleCount:100,spread:70,origin:{y:.6}})},[s]),j.useEffect(()=>{n&&(t!=null&&t.plan)&&t.plan!=="pro"&&i(!1)},[t==null?void 0:t.plan,n]);const u=l.jsx(Ui,{title:"Subscription Confirmed | Academly.ai",description:"Private page on Academly.ai.",canonical:"https://academly.ai/subscription/success",noIndex:!0});return s?l.jsxs("div",{className:"min-h-screen bg-background",children:[u,l.jsx(Xs,{}),l.jsx("section",{className:"relative pt-32 pb-20",children:l.jsx(Wr,{className:"relative",children:l.jsxs("div",{className:"text-center max-w-2xl mx-auto",children:[l.jsx("div",{className:"w-20 h-20 bg-primary/10 rounded-full flex items-center justify-center mx-auto mb-6",children:l.jsx(xt,{className:"h-10 w-10 text-primary animate-spin"})}),l.jsx("h1",{className:"text-3xl font-bold text-foreground mb-4",children:"Finalizing your upgrade..."}),l.jsx("p",{className:"text-muted-foreground",children:"Just a moment while we activate your new plan."})]})})}),l.jsx(Bi,{})]}):l.jsxs("div",{className:"min-h-screen bg-background",children:[u,l.jsx(Xs,{}),l.jsxs("section",{className:"relative pt-32 pb-20",children:[l.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-transparent to-transparent"}),l.jsx(Wr,{className:"relative",children:l.jsxs("div",{className:"text-center max-w-2xl mx-auto",children:[l.jsx("div",{className:"w-20 h-20 bg-primary/10 rounded-full flex items-center justify-center mx-auto mb-6",children:l.jsx(_c,{className:"h-10 w-10 text-primary"})}),l.jsxs("h1",{className:"text-4xl md:text-5xl font-bold text-foreground mb-4",children:["Welcome to ",l.jsx("span",{className:"text-primary",children:c}),"!"]}),l.jsx("p",{className:"text-xl text-muted-foreground mb-8",children:"Your subscription is now active. You have full access to all premium features."}),l.jsxs("div",{className:"bg-card border border-border rounded-2xl p-6 mb-8",children:[l.jsxs("div",{className:"flex items-center justify-center gap-2 mb-4",children:[l.jsx(Qs,{className:"h-5 w-5 text-primary"}),l.jsx("span",{className:"font-semibold",children:"Your Student Points have been credited"})]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Check your dashboard to see your updated balance."})]}),l.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[l.jsx(ye,{asChild:!0,size:"lg",className:"rounded-full",children:l.jsx(bt,{to:"/dashboard",children:"Go to Dashboard"})}),l.jsx(ye,{asChild:!0,variant:"outline",size:"lg",className:"rounded-full",children:l.jsx(bt,{to:"/summary",children:"Create Your First Summary"})})]})]})})]}),l.jsx(Bi,{})]})},Lvt=()=>l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:"Checkout Cancelled | Academly.ai",description:"Private page on Academly.ai.",canonical:"https://academly.ai/subscription/cancel",noIndex:!0}),l.jsx(Xs,{}),l.jsxs("section",{className:"relative pt-32 pb-20",children:[l.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-muted/50 via-transparent to-transparent"}),l.jsx(Wr,{className:"relative",children:l.jsxs("div",{className:"text-center max-w-2xl mx-auto",children:[l.jsx("div",{className:"w-20 h-20 bg-muted rounded-full flex items-center justify-center mx-auto mb-6",children:l.jsx(c2e,{className:"h-10 w-10 text-muted-foreground"})}),l.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-foreground mb-4",children:"Checkout Cancelled"}),l.jsx("p",{className:"text-xl text-muted-foreground mb-8",children:"No worries! Your checkout was cancelled and you haven't been charged."}),l.jsx("div",{className:"bg-card border border-border rounded-2xl p-6 mb-8",children:l.jsx("p",{className:"text-muted-foreground",children:"If you have any questions or need help choosing the right plan, feel free to reach out to our support team."})}),l.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[l.jsx(ye,{asChild:!0,size:"lg",className:"rounded-full",children:l.jsxs(bt,{to:"/pricing",children:[l.jsx(t2e,{className:"mr-2 h-4 w-4"}),"Back to Pricing"]})}),l.jsx(ye,{asChild:!0,variant:"outline",size:"lg",className:"rounded-full",children:l.jsx(bt,{to:"/dashboard",children:"Go to Dashboard"})})]})]})})]}),l.jsx(Bi,{})]}),Fvt=[{icon:Br,title:"Thesis Builder",description:"Generate structured thesis sections with AI assistance. Create introduction, theory, methodology, and conclusion chapters with proper academic citations.",highlights:["Auto-generate chapter structures","Proper citation formatting (APA, Harvard, etc.)","Word count tracking & deadlines","Export to Word/PDF"],color:"bg-blue-500/10 text-blue-500 dark:bg-blue-500/20"},{icon:$2,title:"Methodology Builder",description:"Design your research methodology with AI-powered suggestions. Get guidance on research design, data collection, and analysis methods.",highlights:["Research design templates","Method justification assistance","Sample size recommendations","Validity & reliability checks"],color:"bg-purple-500/10 text-purple-500 dark:bg-purple-500/20"},{icon:ps,title:"Theory Builder",description:"Build your theoretical framework systematically. Extract and organize key concepts from your literature sources.",highlights:["Concept extraction from PDFs","Framework visualization","Literature synthesis","Gap analysis"],color:"bg-emerald-500/10 text-emerald-500 dark:bg-emerald-500/20"},{icon:D2e,title:"Qualitative Analysis",description:"Powerful tools for qualitative research. Code interviews, build codebooks, and analyze themes across your data.",highlights:["Interview transcription","Codebook management","Theme extraction","Cross-case analysis"],color:"bg-orange-500/10 text-orange-500 dark:bg-orange-500/20"}],$vt=[{step:"01",icon:hh,title:"Upload Your Documents",description:"Simply drag and drop your PDFs. We support academic papers, textbooks, and research documents up to 100MB."},{step:"02",icon:Qs,title:"AI Analysis",description:"Our AI analyzes your documents, extracting key information, citations, and relevant content for your research."},{step:"03",icon:Ga,title:"Export & Integrate",description:"Download your summaries, citations, and generated content in various formats ready for your thesis."}],Bvt={"@context":"https://schema.org","@type":"WebPage",name:"How It Works - AI Thesis Writing Assistant",description:"Learn how Academly helps you structure academic papers with AI assistance. Upload PDFs, organize sources, and create properly cited drafts.",url:"https://academly.ai/how-it-works"},zvt=()=>l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:"How It Works - AI Thesis Writing Assistant | Academly",description:"Upload academic PDFs, let AI help you identify key information with page numbers, structure theory and methodology sections with proper citations. Simple 3-step workflow.",canonical:"https://academly.ai/how-it-works",jsonLd:Bvt}),l.jsx(Xs,{}),l.jsxs("section",{className:"relative pt-32 pb-32 overflow-visible",children:[l.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-primary/3 to-transparent pointer-events-none"}),l.jsx("div",{className:"absolute -bottom-32 left-0 right-0 h-64 bg-gradient-to-b from-primary/3 to-transparent pointer-events-none"}),l.jsx("div",{className:"absolute top-20 left-1/4 w-72 h-72 bg-primary/20 rounded-full blur-3xl pointer-events-none"}),l.jsx("div",{className:"absolute top-40 right-1/4 w-96 h-96 bg-purple-500/10 rounded-full blur-3xl pointer-events-none"}),l.jsx(Wr,{className:"relative",children:l.jsxs("div",{className:"text-center max-w-4xl mx-auto",children:[l.jsxs("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-foreground mb-6",children:["Your Complete",l.jsx("span",{className:"text-primary",children:" Research Toolkit"})]}),l.jsx("p",{className:"text-xl text-muted-foreground max-w-2xl mx-auto",children:"From literature review to final thesis, Academly provides all the tools you need to succeed in academic research."})]})})]}),l.jsx("section",{className:"py-20",children:l.jsxs(Wr,{children:[l.jsxs("div",{className:"text-center mb-16",children:[l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4",children:"Powerful Features"}),l.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Everything you need to write better academic papers, faster."})]}),l.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:Fvt.map((t,e)=>{const r=t.icon;return l.jsxs(ic.div,{className:"group relative overflow-hidden rounded-3xl border border-border bg-card p-8 transition-all duration-300 hover:shadow-2xl hover:border-primary/50 hover:-translate-y-1",initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5,delay:e*.1},children:[l.jsx("div",{className:"absolute left-1/2 top-0 -z-10 h-1/2 w-1/2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary/10 blur-3xl opacity-0 group-hover:opacity-100 transition-opacity duration-500"}),l.jsx("div",{className:`w-16 h-16 rounded-2xl ${t.color} flex items-center justify-center mb-6`,children:l.jsx(r,{className:"w-8 h-8"})}),l.jsx("h3",{className:"text-2xl font-bold text-foreground mb-3",children:t.title}),l.jsx("p",{className:"text-muted-foreground mb-6",children:t.description}),l.jsx("ul",{className:"space-y-3",children:t.highlights.map((n,s)=>l.jsxs("li",{className:"flex items-center gap-3",children:[l.jsx(_c,{className:"w-5 h-5 text-primary flex-shrink-0"}),l.jsx("span",{className:"text-sm text-muted-foreground",children:n})]},s))})]},e)})})]})}),l.jsx("section",{className:"py-20 bg-muted/30",children:l.jsxs(Wr,{children:[l.jsxs("div",{className:"text-center mb-16",children:[l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4",children:"Simple 3-Step Workflow"}),l.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Get started in minutes. No complex setup required."})]}),l.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:$vt.map((t,e)=>{const r=t.icon;return l.jsxs("div",{className:"text-center",children:[l.jsxs("div",{className:"relative mb-6",children:[l.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center mx-auto",children:l.jsx(r,{className:"w-10 h-10 text-primary"})}),l.jsx("span",{className:"absolute -top-2 -right-2 w-8 h-8 rounded-full bg-primary text-primary-foreground text-sm font-bold flex items-center justify-center",children:t.step})]}),l.jsx("h3",{className:"text-xl font-bold text-foreground mb-3",children:t.title}),l.jsx("p",{className:"text-muted-foreground",children:t.description})]},e)})})]})}),l.jsx("section",{className:"py-20",children:l.jsx(Wr,{children:l.jsxs("div",{className:"relative rounded-3xl bg-gradient-to-br from-primary to-primary/80 p-12 md:p-16 text-center overflow-hidden",children:[l.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzLTItMi00LTJsLTIgMnYyaDJ2Mmw0LTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),l.jsxs("div",{className:"relative",children:[l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-primary-foreground mb-4",children:"Ready to Transform Your Research?"}),l.jsx("p",{className:"text-xl text-primary-foreground/80 mb-8 max-w-2xl mx-auto",children:"Join thousands of students and researchers who are writing better papers with Academly."}),l.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[l.jsx(ye,{asChild:!0,size:"lg",className:"rounded-full h-14 px-8 text-base font-semibold bg-white text-primary hover:bg-white/90",children:l.jsx(bt,{to:"/login",children:"Get Started Free"})}),l.jsx(ye,{asChild:!0,size:"lg",variant:"outline",className:"rounded-full h-14 px-8 text-base font-semibold border-white/30 text-white hover:bg-white/10",children:l.jsx(bt,{to:"/pricing",children:"View Pricing"})})]})]})]})})}),l.jsx(Bi,{})]});var sbe="Toggle",I9=j.forwardRef((t,e)=>{const{pressed:r,defaultPressed:n,onPressedChange:s,...i}=t,[a,o]=_i({prop:r,onChange:s,defaultProp:n??!1,caller:sbe});return l.jsx(ot.button,{type:"button","aria-pressed":a,"data-state":a?"on":"off","data-disabled":t.disabled?"":void 0,...i,ref:e,onClick:Ke(t.onClick,()=>{t.disabled||o(!a)})})});I9.displayName=sbe;var ibe=I9,mm="ToggleGroup",[abe,g5t]=gs(mm,[Kw]),obe=Kw(),R9=pe.forwardRef((t,e)=>{const{type:r,...n}=t;if(r==="single"){const s=n;return l.jsx(Uvt,{...s,ref:e})}if(r==="multiple"){const s=n;return l.jsx(Hvt,{...s,ref:e})}throw new Error(`Missing prop \`type\` expected on \`${mm}\``)});R9.displayName=mm;var[lbe,cbe]=abe(mm),Uvt=pe.forwardRef((t,e)=>{const{value:r,defaultValue:n,onValueChange:s=()=>{},...i}=t,[a,o]=_i({prop:r,defaultProp:n??"",onChange:s,caller:mm});return l.jsx(lbe,{scope:t.__scopeToggleGroup,type:"single",value:pe.useMemo(()=>a?[a]:[],[a]),onItemActivate:o,onItemDeactivate:pe.useCallback(()=>o(""),[o]),children:l.jsx(ube,{...i,ref:e})})}),Hvt=pe.forwardRef((t,e)=>{const{value:r,defaultValue:n,onValueChange:s=()=>{},...i}=t,[a,o]=_i({prop:r,defaultProp:n??[],onChange:s,caller:mm}),c=pe.useCallback(d=>o((h=[])=>[...h,d]),[o]),u=pe.useCallback(d=>o((h=[])=>h.filter(f=>f!==d)),[o]);return l.jsx(lbe,{scope:t.__scopeToggleGroup,type:"multiple",value:a,onItemActivate:c,onItemDeactivate:u,children:l.jsx(ube,{...i,ref:e})})});R9.displayName=mm;var[Vvt,Wvt]=abe(mm),ube=pe.forwardRef((t,e)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:s=!0,orientation:i,dir:a,loop:o=!0,...c}=t,u=obe(r),d=xx(a),h={role:"group",dir:d,...c};return l.jsx(Vvt,{scope:r,rovingFocus:s,disabled:n,children:s?l.jsx(aV,{asChild:!0,...u,orientation:i,dir:d,loop:o,children:l.jsx(ot.div,{...h,ref:e})}):l.jsx(ot.div,{...h,ref:e})})}),cO="ToggleGroupItem",dbe=pe.forwardRef((t,e)=>{const r=cbe(cO,t.__scopeToggleGroup),n=Wvt(cO,t.__scopeToggleGroup),s=obe(t.__scopeToggleGroup),i=r.value.includes(t.value),a=n.disabled||t.disabled,o={...t,pressed:i,disabled:a},c=pe.useRef(null);return n.rovingFocus?l.jsx(oV,{asChild:!0,...s,focusable:!a,active:i,ref:c,children:l.jsx(bte,{...o,ref:e})}):l.jsx(bte,{...o,ref:e})});dbe.displayName=cO;var bte=pe.forwardRef((t,e)=>{const{__scopeToggleGroup:r,value:n,...s}=t,i=cbe(cO,r),a={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},o=i.type==="single"?a:void 0;return l.jsx(I9,{...o,...s,ref:e,onPressedChange:c=>{c?i.onItemActivate(n):i.onItemDeactivate(n)}})}),hbe=R9,fbe=dbe;const pbe=Nh("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),qvt=j.forwardRef(({className:t,variant:e,size:r,...n},s)=>l.jsx(ibe,{ref:s,className:Le(pbe({variant:e,size:r,className:t})),...n}));qvt.displayName=ibe.displayName;const mbe=j.createContext({size:"default",variant:"default"}),f1=j.forwardRef(({className:t,variant:e,size:r,children:n,...s},i)=>l.jsx(hbe,{ref:i,className:Le("flex items-center justify-center gap-1",t),...s,children:l.jsx(mbe.Provider,{value:{variant:e,size:r},children:n})}));f1.displayName=hbe.displayName;const wc=j.forwardRef(({className:t,children:e,variant:r,size:n,...s},i)=>{const a=j.useContext(mbe);return l.jsx(fbe,{ref:i,className:Le(pbe({variant:a.variant||r,size:a.size||n}),t),...s,children:e})});wc.displayName=fbe.displayName;const Gvt="https://nqibmbtqcjucktqcreob.supabase.co",Kvt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5xaWJtYnRxY2p1Y2t0cWNyZW9iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1NTk5MTAsImV4cCI6MjA3MDEzNTkxMH0.UnFk-GqYCZtlkXNlxyHUTaFAnS6Q4hIgDgWKANrxEHg";function Yvt(){const{toast:t}=qn(),[e,r]=j.useState("EN"),[n,s]=j.useState(""),[i,a]=j.useState(""),[o,c]=j.useState(!1),[u,d]=j.useState([]),[h,f]=j.useState(null),[p,m]=j.useState(!1),g=b=>{navigator.clipboard.writeText(b).then(()=>{t({title:"Copied!",description:"Copied to clipboard."})})},x=async()=>{if(n.trim()){c(!0),m(!1),f(null);try{const b=await fetch(`${Gvt}/functions/v1/demo-topic-ideas`,{method:"POST",headers:{"Content-Type":"application/json",apikey:Kvt},body:JSON.stringify({topic:n,context:i,language:e})});if(b.status===429){m(!0),d([]);return}const w=await b.json();if(!b.ok||w.error)throw new Error(w.error||"Request failed");const S=(w.suggestions||[]).map((k,E)=>{var C;return{id:((C=crypto.randomUUID)==null?void 0:C.call(crypto))||String(E),title:k.title,research_questions:k.research_questions??k.researchQuestions??[],method:k.method,relevance:k.relevance,sources:Array.isArray(k.sources)?k.sources:[]}});d(S)}catch(b){console.error(b),t({title:"Error",description:"Generation failed. Please try again.",variant:"destructive"})}finally{c(!1)}}},y=b=>{f(b),setTimeout(()=>{var w;(w=document.getElementById("selected-topic"))==null||w.scrollIntoView({behavior:"smooth",block:"start"})},50)},v=b=>{var S;let w=`${b.title}
Research Questions:
${b.research_questions.map((k,E)=>`${E+1}. ${k}`).join(`
`)}
Method:
${b.method}
Relevance:
${b.relevance}`;return(S=b.sources)!=null&&S.length&&(w+=`
Initial Sources:
${b.sources.map((k,E)=>`${E+1}. ${k.title}${k.doi?` (DOI: ${k.doi})`:""}${k.isbn?` (ISBN: ${k.isbn})`:""}`).join(`
`)}`),w};return l.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[l.jsx(Ui,{title:"Bachelorarbeit-Themen finden mit KI | Academly",description:"Themenideen für Bachelor- und Masterarbeit per KI generieren: strukturierte Forschungsfragen mit Begründung. Kostenlos ausprobieren.",canonical:"https://academly.ai/topic-ideas"}),l.jsx(Xs,{}),l.jsxs("section",{className:"relative pt-32 pb-16 overflow-hidden",children:[l.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-transparent to-transparent"}),l.jsxs("div",{className:"relative max-w-4xl mx-auto px-6 text-center",children:[l.jsx("p",{className:"text-sm uppercase tracking-wider text-primary mb-4 font-medium",children:"Free Demo"}),l.jsx("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-foreground mb-6",children:"Find Your Perfect Research Topic"}),l.jsxs("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto leading-relaxed",children:["Try our Topic Ideas generator, no account needed.",l.jsx("br",{}),"3 free generations per day."]})]})]}),l.jsxs("main",{className:"flex-1 w-full",children:[l.jsx("section",{className:"py-16",children:l.jsx("div",{className:"max-w-3xl mx-auto px-6",children:l.jsxs("div",{className:"rounded-3xl border border-border bg-card shadow-sm p-8 md:p-10",children:[l.jsxs("div",{className:"flex items-start gap-3 mb-6",children:[l.jsx("div",{className:"rounded-xl bg-primary/10 p-2.5 text-primary",children:l.jsx(rm,{className:"h-5 w-5"})}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-foreground",children:"Generate Topic Suggestions"}),l.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter your basic idea and receive structured suggestions"})]})]}),l.jsxs("div",{className:"space-y-5",children:[l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-5",children:[l.jsxs("div",{className:"space-y-2 lg:col-span-7",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Working Title / Topic Idea"}),l.jsx(Be,{placeholder:"e.g., AI in Education",value:n,onChange:b=>s(b.target.value),className:"h-12 rounded-xl text-base"})]}),l.jsxs("div",{className:"space-y-2 lg:col-span-3",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Language"}),l.jsxs(f1,{type:"single",value:e,onValueChange:b=>b&&r(b),className:"justify-start h-12",children:[l.jsx(wc,{value:"DE",className:"h-10 px-5",children:"DE"}),l.jsx(wc,{value:"EN",className:"h-10 px-5",children:"EN"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Description / Context (optional)"}),l.jsx(ir,{placeholder:"Describe program, scope, methodology, context...",value:i,onChange:b=>a(b.target.value),rows:4,className:"rounded-xl text-base resize-none"})]}),l.jsx(ye,{onClick:x,disabled:!n.trim()||o,className:"w-full rounded-full h-12 text-base font-semibold",children:o?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):"Generate Suggestions"})]})]})})}),p&&l.jsx("section",{className:"py-16",children:l.jsx("div",{className:"max-w-3xl mx-auto px-6",children:l.jsxs("div",{className:"rounded-3xl border border-amber-500/30 bg-amber-50/50 dark:bg-amber-950/20 p-8 md:p-10",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(gx,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"}),l.jsx("h3",{className:"text-lg font-bold text-amber-900 dark:text-amber-200",children:"Daily limit reached"})]}),l.jsx("p",{className:"text-sm text-amber-900/80 dark:text-amber-200/80 mb-6 leading-relaxed",children:"You've used your 3 free demo generations today. Come back tomorrow, or sign up free for unlimited access."}),l.jsx(ye,{asChild:!0,className:"rounded-full h-12 px-8",children:l.jsxs(bt,{to:"/login",children:["Get started free ",l.jsx(eh,{className:"h-4 w-4 ml-2"})]})})]})})}),u.length>0&&!p&&l.jsx("section",{className:"py-16",children:l.jsxs("div",{className:"max-w-6xl mx-auto px-6",children:[l.jsxs("div",{className:"text-center mb-12",children:[l.jsx("p",{className:"text-sm uppercase tracking-wider text-muted-foreground mb-3",children:"Generated for you"}),l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground",children:"Topic Suggestions"})]}),l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:u.map(b=>l.jsxs("div",{className:"rounded-2xl border border-border bg-card shadow-sm p-6 hover:border-primary/30 transition-colors flex flex-col",children:[l.jsx("h3",{className:"text-xl font-bold text-foreground mb-5",children:b.title}),l.jsxs("div",{className:"space-y-4 flex-1",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-sm text-primary mb-2",children:"Research Questions"}),l.jsx("ul",{className:"text-sm text-muted-foreground space-y-1.5",children:b.research_questions.map((w,S)=>l.jsxs("li",{className:"flex gap-2",children:[l.jsx("span",{className:"text-primary mt-0.5",children:"•"}),l.jsx("span",{children:w})]},S))})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-sm text-primary mb-2",children:"Method"}),l.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:b.method})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-sm text-primary mb-2",children:"Relevance"}),l.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:b.relevance})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold text-sm text-primary mb-2",children:"Initial Sources"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:b.sources.map((w,S)=>l.jsx("span",{className:"inline-flex items-center rounded-full bg-muted px-3 py-1.5 text-xs text-muted-foreground",children:w.title},S))})]})]}),l.jsxs("div",{className:"flex gap-3 pt-5 mt-5 border-t border-border",children:[l.jsxs(ye,{size:"sm",onClick:()=>y(b),className:"flex-1 rounded-full h-10",children:["Select ",l.jsx(eh,{className:"h-4 w-4 ml-1"})]}),l.jsx(ye,{size:"sm",variant:"outline",onClick:()=>g(v(b)),className:"rounded-full h-10 w-10 p-0",children:l.jsx(Tn,{className:"h-4 w-4"})})]})]},b.id))})]})}),h&&l.jsx("section",{className:"py-16",children:l.jsx("div",{className:"max-w-3xl mx-auto px-6",children:l.jsx("div",{id:"selected-topic",className:"rounded-3xl border border-border bg-card shadow-sm overflow-hidden",children:l.jsxs("div",{className:"p-8 md:p-10",children:[l.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[l.jsx("div",{className:"rounded-xl bg-primary/10 p-2.5 text-primary",children:l.jsx(ps,{className:"h-5 w-5"})}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-foreground",children:"Your Topic Structure"}),l.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Based on your selected topic idea"})]})]}),l.jsxs("div",{className:"bg-muted/30 p-6 md:p-8 rounded-2xl space-y-6 text-foreground",children:[l.jsx("h3",{className:"text-2xl font-bold",children:h.title}),h.research_questions.length>0&&l.jsxs("div",{children:[l.jsx("h4",{className:"text-base font-semibold text-primary mb-3",children:"Research Questions"}),l.jsx("ul",{className:"space-y-2",children:h.research_questions.map((b,w)=>l.jsxs("li",{className:"flex gap-2 text-sm",children:[l.jsx("span",{className:"text-primary mt-0.5",children:"•"}),l.jsx("span",{className:"leading-relaxed",children:b})]},w))})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"text-base font-semibold text-primary mb-3",children:"Method"}),l.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:h.method})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"text-base font-semibold text-primary mb-3",children:"Relevance"}),l.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:h.relevance})]}),h.sources.length>0&&l.jsxs("div",{children:[l.jsx("h4",{className:"text-base font-semibold text-primary mb-3",children:"Sources"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:h.sources.map((b,w)=>l.jsx("span",{className:"inline-flex items-center rounded-full bg-background border border-border px-3 py-1.5 text-xs text-foreground",children:b.title},w))})]})]}),l.jsx("div",{className:"rounded-2xl border border-primary/20 bg-primary/5 p-6 mt-6",children:l.jsxs("p",{className:"text-sm text-foreground leading-relaxed",children:[l.jsx("span",{className:"font-semibold",children:"Want to continue with this topic?"}),l.jsx("br",{}),"Sign up free to generate a full outline, theory chapter, and methodology."]})}),l.jsxs("div",{className:"flex flex-wrap gap-3 mt-6",children:[l.jsx(ye,{asChild:!0,className:"rounded-full h-12 px-8",children:l.jsxs(bt,{to:"/login",children:["Continue in Academly"," ",l.jsx(eh,{className:"h-4 w-4 ml-2"})]})}),l.jsxs(ye,{variant:"outline",onClick:()=>g(v(h)),className:"rounded-full h-12 px-6",children:[l.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Copy"]})]})]})})})})]}),l.jsx(Bi,{})]})}const Xvt="https://nqibmbtqcjucktqcreob.supabase.co",wte="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5xaWJtYnRxY2p1Y2t0cWNyZW9iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1NTk5MTAsImV4cCI6MjA3MDEzNTkxMH0.UnFk-GqYCZtlkXNlxyHUTaFAnS6Q4hIgDgWKANrxEHg";function Jvt(){var M,z,P,W;const{toast:t}=qn(),[e,r]=j.useState("EN"),[n,s]=j.useState(""),[i,a]=j.useState(""),[o,c]=j.useState(!1),[u,d]=j.useState(null),[h,f]=j.useState(!1),[p,m]=j.useState(!1),[g,x]=j.useState(""),[y,v]=j.useState([]),[b,w]=j.useState(1),S=N=>{navigator.clipboard.writeText(N).then(()=>{t({title:"Copied!",description:"Copied to clipboard."})})},k=async N=>fetch(`${Xvt}/functions/v1/demo-keywords`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${wte}`,apikey:wte},body:JSON.stringify(N)}),E=async N=>{if(N.trim()){m(!0);try{const U=await k({action:"search_literature",keywords:N,language:e});if(U.status===429){f(!0);return}const K=await U.json();if(!U.ok||K.error)throw new Error(K.error||"Search failed");v(K.results||[]),w(1)}catch(U){console.error(U),t({title:"Error",description:"Literature search failed.",variant:"destructive"})}finally{m(!1)}}},C=async()=>{var N,U;if(n.trim()){c(!0),f(!1),v([]);try{const K=await k({action:"keywords",title:n,research_questions:i.split(`
`).map(B=>B.trim()).filter(B=>B),language:e});if(K.status===429){f(!0),d(null);return}const G=await K.json();if(!K.ok||G.error)throw new Error(G.error||"Request failed");const X=G.keywords||G;d(X);const H=((U=(N=X==null?void 0:X.keyword_combinations)==null?void 0:N[0])==null?void 0:U.combination)||n;x(H),await E(H)}catch(K){console.error(K),t({title:"Error",description:"Generation failed. Please try again.",variant:"destructive"})}finally{c(!1)}}},A=()=>{var U,K,G,X;if(!u)return;const N=[];(U=u.keyword_combinations)!=null&&U.length&&(N.push("Search Combinations:"),u.keyword_combinations.forEach(H=>N.push(`- ${H.combination} — ${H.purpose}`))),(K=u.known_authors)!=null&&K.length&&(N.push(`
Known Authors:`),u.known_authors.forEach(H=>N.push(`- ${H.name} (${H.relevance})`))),(G=u.known_works)!=null&&G.length&&(N.push(`
Known Works:`),u.known_works.forEach(H=>N.push(`- ${H.title} — ${H.author} (${H.year}): ${H.relevance}`))),(X=u.database_suggestions)!=null&&X.length&&(N.push(`
Recommended Databases:`),N.push(u.database_suggestions.join(", "))),u.search_tips&&(N.push(`
Search Tips:`),N.push(u.search_tips)),S(N.join(`
`))};return l.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[l.jsx(Ui,{title:"Literaturrecherche mit KI: CrossRef & OpenAlex | Academly",description:"Wissenschaftliche Literatur über CrossRef und OpenAlex finden: mit Open-Access-Badges, DOI und Relevanz-Score. Kostenlos testen.",canonical:"https://academly.ai/literature-search"}),l.jsx(Xs,{}),l.jsxs("section",{className:"relative pt-32 pb-16 overflow-hidden",children:[l.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-transparent to-transparent"}),l.jsxs("div",{className:"relative max-w-4xl mx-auto px-6 text-center",children:[l.jsx("p",{className:"text-sm uppercase tracking-wider text-primary mb-4 font-medium",children:"Free Demo"}),l.jsx("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-foreground mb-6",children:"Find the Right Literature Keywords"}),l.jsxs("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto leading-relaxed",children:["Generate search terms for your thesis, no account needed.",l.jsx("br",{}),"3 free generations per day."]})]})]}),l.jsxs("main",{className:"flex-1 w-full",children:[l.jsx("section",{className:"py-12",children:l.jsx("div",{className:"max-w-3xl mx-auto px-6",children:l.jsxs("div",{className:"rounded-3xl border border-border bg-card shadow-sm p-8 md:p-10",children:[l.jsxs("div",{className:"flex items-start gap-3 mb-6",children:[l.jsx("div",{className:"rounded-xl bg-primary/10 p-2.5 text-primary",children:l.jsx(yl,{className:"h-5 w-5"})}),l.jsxs("div",{children:[l.jsx("h2",{className:"text-xl font-bold text-foreground",children:"Find Literature Keywords"}),l.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Generate search terms and find relevant literature for your topic"})]})]}),l.jsxs("div",{className:"space-y-5",children:[l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-10 gap-5",children:[l.jsxs("div",{className:"space-y-2 lg:col-span-7",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Title / Topic *"}),l.jsx(Be,{placeholder:"e.g., AI in Education",value:n,onChange:N=>s(N.target.value),className:"h-12 rounded-xl text-base"})]}),l.jsxs("div",{className:"space-y-2 lg:col-span-3",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Language"}),l.jsxs(f1,{type:"single",value:e,onValueChange:N=>N&&r(N),className:"justify-start h-12",children:[l.jsx(wc,{value:"DE",className:"h-10 px-5",children:"DE"}),l.jsx(wc,{value:"EN",className:"h-10 px-5",children:"EN"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Research Questions (optional)"}),l.jsx(ir,{placeholder:"One question per line...",value:i,onChange:N=>a(N.target.value),rows:3,className:"rounded-xl text-base resize-none"})]}),l.jsx(ye,{onClick:C,disabled:!n.trim()||o||p,className:"w-full rounded-full h-12 text-base font-semibold",children:o||p?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating & Searching..."]}):"Generate Keywords"})]})]})})}),h&&l.jsx("section",{className:"py-12",children:l.jsx("div",{className:"max-w-3xl mx-auto px-6",children:l.jsxs("div",{className:"rounded-3xl border border-amber-500/30 bg-amber-50/50 dark:bg-amber-950/20 p-8 md:p-10",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(gx,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"}),l.jsx("h3",{className:"text-lg font-bold text-amber-900 dark:text-amber-200",children:"Daily limit reached"})]}),l.jsx("p",{className:"text-sm text-amber-900/80 dark:text-amber-200/80 mb-6 leading-relaxed",children:"You've used your 3 free demo generations today. Come back tomorrow, or sign up free for unlimited access."}),l.jsx(ye,{asChild:!0,className:"rounded-full h-12 px-8",children:l.jsxs(bt,{to:"/login",children:["Get started free ",l.jsx(eh,{className:"h-4 w-4 ml-2"})]})})]})})}),u&&!h&&l.jsx("section",{className:"py-12",children:l.jsxs("div",{className:"max-w-5xl mx-auto px-6",children:[l.jsxs("div",{className:"flex items-center justify-between mb-8 flex-wrap gap-4",children:[l.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground",children:"Keywords & Search Terms"}),l.jsxs(ye,{variant:"outline",onClick:A,className:"rounded-full",children:[l.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Copy All"]})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs("div",{className:"rounded-2xl border border-border bg-card shadow-sm p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(rm,{className:"h-5 w-5 text-primary"}),l.jsx("h3",{className:"text-xl font-bold text-foreground",children:"Search Combinations"})]}),l.jsx("ul",{className:"space-y-2",children:(M=u.keyword_combinations)==null?void 0:M.map((N,U)=>l.jsxs("li",{onClick:()=>S(N.combination),className:"cursor-pointer bg-muted/50 hover:bg-muted rounded-md p-2 transition-colors",children:[l.jsx("code",{className:"font-mono text-sm text-foreground block",children:N.combination}),l.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:N.purpose})]},U))})]}),l.jsxs("div",{className:"rounded-2xl border border-border bg-card shadow-sm p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx($w,{className:"h-5 w-5 text-primary"}),l.jsx("h3",{className:"text-xl font-bold text-foreground",children:"Known Authors"})]}),l.jsx("ul",{className:"space-y-2",children:(z=u.known_authors)==null?void 0:z.map((N,U)=>l.jsxs("li",{onClick:()=>S(N.name),className:"cursor-pointer bg-muted/50 hover:bg-muted rounded-md p-2 transition-colors",children:[l.jsx("p",{className:"font-medium text-sm text-foreground",children:N.name}),l.jsx("p",{className:"text-xs text-muted-foreground",children:N.relevance})]},U))})]}),l.jsxs("div",{className:"rounded-2xl border border-border bg-card shadow-sm p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(ps,{className:"h-5 w-5 text-primary"}),l.jsx("h3",{className:"text-xl font-bold text-foreground",children:"Known Works"})]}),l.jsx("ul",{className:"space-y-2",children:(P=u.known_works)==null?void 0:P.map((N,U)=>l.jsxs("li",{onClick:()=>S(N.title),className:"cursor-pointer bg-muted/50 hover:bg-muted rounded-md p-2 transition-colors",children:[l.jsx("p",{className:"font-medium text-sm text-foreground",children:N.title}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.author," (",N.year,")"]}),l.jsx("p",{className:"text-xs italic text-muted-foreground mt-0.5",children:N.relevance})]},U))})]}),l.jsxs("div",{className:"rounded-2xl border border-border bg-card shadow-sm p-6",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(yl,{className:"h-5 w-5 text-primary"}),l.jsx("h3",{className:"text-xl font-bold text-foreground",children:"Recommended Databases"})]}),l.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:(W=u.database_suggestions)==null?void 0:W.map((N,U)=>l.jsx(kt,{variant:"secondary",children:N},U))}),u.search_tips&&l.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap leading-relaxed",children:u.search_tips})]})]}),l.jsxs("div",{className:"rounded-3xl border border-border bg-card shadow-sm p-6 md:p-8 mt-10",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx(ps,{className:"h-5 w-5 text-primary"}),l.jsx("h3",{className:"text-xl font-bold text-foreground",children:"Literature Search"})]}),l.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mb-6",children:[l.jsx(Be,{value:g,onChange:N=>x(N.target.value),placeholder:"Search query...",className:"h-12 rounded-xl text-base flex-1"}),l.jsx(ye,{onClick:()=>E(g),disabled:!g.trim()||p,className:"rounded-full h-12 px-6",children:p?l.jsx(xt,{className:"h-4 w-4 animate-spin"}):l.jsxs(l.Fragment,{children:[l.jsx(yl,{className:"h-4 w-4 mr-2"})," Search"]})})]}),y.length>0?l.jsx("ul",{className:"space-y-3",children:y.slice((b-1)*10,b*10).map((N,U)=>l.jsxs("li",{className:"rounded-xl border border-border bg-muted/30 p-4",children:[l.jsx("p",{className:"font-medium text-foreground",children:N.title||"Untitled"}),l.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[Array.isArray(N.authors)?N.authors.join(", "):N.authors,N.year?` (${N.year})`:"",N.journal?` — ${N.journal}`:""]}),N.abstract&&l.jsx("p",{className:"text-sm text-muted-foreground mt-2 line-clamp-3",children:N.abstract}),(N.url||N.doi)&&l.jsx("a",{href:N.url||`https://doi.org/${N.doi}`,target:"_blank",rel:"noreferrer",className:"text-xs text-primary mt-2 inline-block hover:underline",children:"View source →"})]},U))}):!p&&l.jsx("p",{className:"text-sm text-muted-foreground",children:"No results yet."}),y.length>10&&l.jsxs("div",{className:"flex items-center justify-between mt-6",children:[l.jsx(ye,{variant:"outline",size:"sm",disabled:b===1,onClick:()=>w(N=>N-1),children:"Previous"}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["Page ",b," of"," ",Math.ceil(y.length/10)]}),l.jsx(ye,{variant:"outline",size:"sm",disabled:b*10>=y.length,onClick:()=>w(N=>N+1),children:"Next"})]})]}),l.jsx("div",{className:"rounded-3xl border border-primary/20 bg-primary/5 p-8 md:p-10 mt-10",children:l.jsxs("div",{className:"flex items-start gap-4",children:[l.jsx("div",{className:"rounded-xl bg-primary/10 p-2.5 text-primary shrink-0",children:l.jsx(Qs,{className:"h-5 w-5"})}),l.jsxs("div",{className:"flex-1",children:[l.jsx("h3",{className:"text-xl font-bold text-foreground mb-2",children:"Want to search real academic papers?"}),l.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed mb-5",children:"Sign up free to access our full Literature Search, powered by CrossRef and OpenAlex. Find and cite real papers directly in your thesis."}),l.jsx(ye,{asChild:!0,className:"rounded-full h-12 px-8",children:l.jsxs(bt,{to:"/login",children:["Get started free ",l.jsx(eh,{className:"h-4 w-4 ml-2"})]})})]})]})})]})})]}),l.jsx(Bi,{})]})}const Qvt=[{name:"Dom",role:"Founder",description:"Cloud technologist with a strong focus on privacy-first infrastructure. Passionate about AI applications in academic work. Bachelor of Science."},{name:"Rebecca",role:"Marketing & IT Security",description:"IT security specialist and penetration tester with a background in secure systems and communication. Bachelor of Science."},{name:"Nicole",role:"Platform Design & IT Security",description:"IT security specialist focused on platform architecture and usability. Bachelor of Science, Master of Science."}],Zvt=[{icon:$ce,title:"GDPR Compliant",description:"Fully compliant with European data protection regulations."},{icon:TH,title:"Security-First",description:"Built by IT security specialists with penetration testing expertise."},{icon:g2e,title:"No Training on User Documents",description:"Your academic work stays yours. We never train AI models on your data."}];function ebt(){return l.jsxs(l.Fragment,{children:[l.jsx(Ui,{title:"Meet the Team - Academly | Security & AI Experts",description:"Built by professionals with a background in technology, IT security, and academic research. Meet the team behind Academly.",canonical:"https://academly.ai/team"}),l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Xs,{}),l.jsxs("div",{className:"relative pt-32 pb-16",children:[l.jsxs("div",{"aria-hidden":"true",className:"absolute inset-0 grid grid-cols-2 -space-x-52 opacity-40 dark:opacity-20",children:[l.jsx("div",{className:"blur-[106px] h-56 bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),l.jsx("div",{className:"blur-[106px] h-32 bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),l.jsx(Wr,{children:l.jsx("div",{className:"relative",children:l.jsxs("div",{className:"mx-auto max-w-3xl text-center",children:[l.jsxs("h1",{className:"text-4xl font-bold tracking-tight text-foreground sm:text-5xl md:text-6xl",children:["The team behind"," ",l.jsx("span",{className:"text-primary",children:"Academly"})]}),l.jsx("p",{className:"mt-6 text-lg leading-8 text-muted-foreground",children:"Built by professionals with a background in technology, security, and academic research."})]})})})]}),l.jsx("section",{className:"pb-16",children:l.jsx(Wr,{children:l.jsx("div",{className:"mx-auto max-w-3xl space-y-6",children:Qvt.map((t,e)=>l.jsxs("div",{className:"group flex items-start gap-6 rounded-3xl border border-border bg-card p-6 sm:p-8 shadow-lg shadow-primary/5 transition-all duration-300 hover:shadow-xl hover:shadow-primary/10 animate-fade-in",style:{animationDelay:`${e*100}ms`},children:[l.jsx("div",{className:"flex h-20 w-20 sm:h-24 sm:w-24 flex-shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-primary/20 to-primary/5 ring-2 ring-primary/10 group-hover:ring-primary/20 transition-all duration-300 overflow-hidden",children:l.jsx("span",{className:"text-2xl sm:text-3xl font-bold text-primary",children:t.name.slice(0,2).toUpperCase()})}),l.jsxs("div",{className:"flex-1",children:[l.jsx("h3",{className:"text-xl sm:text-2xl font-semibold text-foreground group-hover:text-primary transition-colors",children:t.name}),l.jsx("p",{className:"text-sm font-medium text-primary mt-1",children:t.role}),l.jsx("p",{className:"mt-3 text-muted-foreground leading-relaxed",children:t.description})]})]},t.name))})})}),l.jsxs("section",{className:"relative py-20",children:[l.jsxs("div",{"aria-hidden":"true",className:"absolute inset-0 h-max w-full m-auto grid grid-cols-2 -space-x-52 opacity-20 dark:opacity-10",children:[l.jsx("div",{className:"blur-[106px] h-40 bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),l.jsx("div",{className:"blur-[106px] h-24 bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),l.jsx(Wr,{children:l.jsxs("div",{className:"relative",children:[l.jsx("h2",{className:"text-center text-2xl sm:text-3xl font-bold text-foreground mb-12",children:"Your data is safe with us"}),l.jsx("div",{className:"grid gap-8 sm:grid-cols-3",children:Zvt.map((t,e)=>l.jsxs("div",{className:"text-center group animate-fade-in",style:{animationDelay:`${e*100}ms`},children:[l.jsx("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-gradient-to-br from-primary/20 to-primary/5 shadow-lg shadow-primary/10 group-hover:shadow-xl group-hover:shadow-primary/20 transition-all duration-300",children:l.jsx(t.icon,{className:"h-8 w-8 text-primary"})}),l.jsx("h3",{className:"font-semibold text-foreground text-lg",children:t.title}),l.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:t.description})]},t.title))})]})})]}),l.jsx(Bi,{})]})]})}var FM="Checkbox",[tbt,y5t]=gs(FM),[rbt,M9]=tbt(FM);function nbt(t){const{__scopeCheckbox:e,checked:r,children:n,defaultChecked:s,disabled:i,form:a,name:o,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:h}=t,[f,p]=_i({prop:r,defaultProp:s??!1,onChange:c,caller:FM}),[m,g]=j.useState(null),[x,y]=j.useState(null),v=j.useRef(!1),b=m?!!a||!!m.closest("form"):!0,w={checked:f,disabled:i,setChecked:p,control:m,setControl:g,name:o,form:a,value:d,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:Ap(s)?!1:s,isFormControl:b,bubbleInput:x,setBubbleInput:y};return l.jsx(rbt,{scope:e,...w,children:sbt(h)?h(w):n})}var gbe="CheckboxTrigger",ybe=j.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:r,...n},s)=>{const{control:i,value:a,disabled:o,checked:c,required:u,setControl:d,setChecked:h,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=M9(gbe,t),g=It(s,d),x=j.useRef(c);return j.useEffect(()=>{const y=i==null?void 0:i.form;if(y){const v=()=>h(x.current);return y.addEventListener("reset",v),()=>y.removeEventListener("reset",v)}},[i,h]),l.jsx(ot.button,{type:"button",role:"checkbox","aria-checked":Ap(c)?"mixed":c,"aria-required":u,"data-state":Sbe(c),"data-disabled":o?"":void 0,disabled:o,value:a,...n,ref:g,onKeyDown:Ke(e,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:Ke(r,y=>{h(v=>Ap(v)?!0:!v),m&&p&&(f.current=y.isPropagationStopped(),f.current||y.stopPropagation())})})});ybe.displayName=gbe;var D9=j.forwardRef((t,e)=>{const{__scopeCheckbox:r,name:n,checked:s,defaultChecked:i,required:a,disabled:o,value:c,onCheckedChange:u,form:d,...h}=t;return l.jsx(nbt,{__scopeCheckbox:r,checked:s,defaultChecked:i,disabled:o,required:a,onCheckedChange:u,name:n,form:d,value:c,internal_do_not_use_render:({isFormControl:f})=>l.jsxs(l.Fragment,{children:[l.jsx(ybe,{...h,ref:e,__scopeCheckbox:r}),f&&l.jsx(wbe,{__scopeCheckbox:r})]})})});D9.displayName=FM;var xbe="CheckboxIndicator",vbe=j.forwardRef((t,e)=>{const{__scopeCheckbox:r,forceMount:n,...s}=t,i=M9(xbe,r);return l.jsx(Os,{present:n||Ap(i.checked)||i.checked===!0,children:l.jsx(ot.span,{"data-state":Sbe(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:e,style:{pointerEvents:"none",...t.style}})})});vbe.displayName=xbe;var bbe="CheckboxBubbleInput",wbe=j.forwardRef(({__scopeCheckbox:t,...e},r)=>{const{control:n,hasConsumerStoppedPropagationRef:s,checked:i,defaultChecked:a,required:o,disabled:c,name:u,value:d,form:h,bubbleInput:f,setBubbleInput:p}=M9(bbe,t),m=It(r,p),g=T9(i),x=BH(n);j.useEffect(()=>{const v=f;if(!v)return;const b=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(b,"checked").set,k=!s.current;if(g!==i&&S){const E=new Event("click",{bubbles:k});v.indeterminate=Ap(i),S.call(v,Ap(i)?!1:i),v.dispatchEvent(E)}},[f,g,i,s]);const y=j.useRef(Ap(i)?!1:i);return l.jsx(ot.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??y.current,required:o,disabled:c,name:u,value:d,form:h,...e,tabIndex:-1,ref:m,style:{...e.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});wbe.displayName=bbe;function sbt(t){return typeof t=="function"}function Ap(t){return t==="indeterminate"}function Sbe(t){return Ap(t)?"indeterminate":t?"checked":"unchecked"}const bl=j.forwardRef(({className:t,...e},r)=>l.jsx(D9,{ref:r,className:Le("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...e,children:l.jsx(vbe,{className:Le("flex items-center justify-center text-current"),children:l.jsx(Es,{className:"h-4 w-4"})})}));bl.displayName=D9.displayName;function _be({id:t,checked:e,onCheckedChange:r,required:n=!1,className:s,children:i}){return l.jsxs("div",{className:Le("flex items-start gap-3",s),children:[l.jsx(bl,{id:t,checked:e,onCheckedChange:a=>r(a===!0),required:n,className:"mt-0.5 flex-shrink-0"}),l.jsx("label",{htmlFor:t,className:"text-sm text-muted-foreground leading-relaxed cursor-pointer select-none",children:i})]})}var ibt=Object.defineProperty,jbe=t=>{throw TypeError(t)},abt=(t,e,r)=>e in t?ibt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vh=(t,e,r)=>abt(t,typeof e!="symbol"?e+"":e,r),obt=(t,e,r)=>e.has(t)||jbe("Cannot "+r),Ste=(t,e,r)=>(obt(t,e,"read from private field"),e.get(t)),lbt=(t,e,r)=>e.has(t)?jbe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r);function cbt(t){return t==null?[]:Array.isArray(t)?t:[t]}var _te=t=>(t==null?void 0:t.constructor.name)==="Array",ubt=(t,e)=>{if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!L9(t[r],e[r]))return!1;return!0},L9=(t,e)=>{if(Object.is(t,e))return!0;if(t==null&&e!=null||t!=null&&e==null)return!1;if(typeof(t==null?void 0:t.isEqual)=="function"&&typeof(e==null?void 0:e.isEqual)=="function")return t.isEqual(e);if(typeof t=="function"&&typeof e=="function")return t.toString()===e.toString();if(_te(t)&&_te(e))return ubt(Array.from(t),Array.from(e));if(typeof t!="object"||typeof e!="object")return!1;const r=Object.keys(e??Object.create(null)),n=r.length;for(let s=0;s<n;s++)if(!Reflect.has(t,r[s]))return!1;for(let s=0;s<n;s++){const i=r[s];if(!L9(t[i],e[i]))return!1}return!0},dbt=t=>t!=null&&typeof t=="object",wT=t=>typeof t=="string",sg=t=>typeof t=="function",kbe=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),hbt=t=>Object.prototype.toString.call(t),Nbe=Function.prototype.toString,fbt=Nbe.call(Object),pbt=t=>{if(!dbt(t)||hbt(t)!="[object Object]"||ybt(t))return!1;const e=Object.getPrototypeOf(t);if(e===null)return!0;const r=kbe(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Nbe.call(r)==fbt},mbt=t=>typeof t=="object"&&t!==null&&"$$typeof"in t&&"props"in t,gbt=t=>typeof t=="object"&&t!==null&&"__v_isVNode"in t,ybt=t=>mbt(t)||gbt(t),xbt=t=>t(),vbt=(...t)=>(...e)=>{t.forEach(function(r){r==null||r(...e)})};function Ebe(t,e,...r){var s;if(t in e){const i=e[t];return sg(i)?i(...r):i}const n=new Error(`No matching key: ${JSON.stringify(t)} in ${JSON.stringify(Object.keys(e))}`);throw(s=Error.captureStackTrace)==null||s.call(Error,n,Ebe),n}var{floor:x5t,abs:v5t,round:b5t,min:bbt,max:wbt,pow:w5t,sign:S5t}=Math,Sbt=t=>Number.isNaN(t),_bt=t=>Sbt(t)?0:t,jbt=(t,e,r)=>bbt(wbt(_bt(t),e),r);function Abe(t){if(!pbt(t)||t===void 0)return t;const e=Reflect.ownKeys(t).filter(n=>typeof n=="string"),r={};for(const n of e){const s=t[n];s!==void 0&&(r[n]=Abe(s))}return r}var cC=()=>performance.now(),ST,Cbe=class{constructor(t){this.onTick=t,Vh(this,"frameId",null),Vh(this,"pausedAtMs",null),Vh(this,"context"),Vh(this,"cancelFrame",()=>{this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}),Vh(this,"setStartMs",e=>{this.context.startMs=e}),Vh(this,"start",()=>{if(this.frameId!==null)return;const e=cC();this.pausedAtMs!==null?(this.context.startMs+=e-this.pausedAtMs,this.pausedAtMs=null):this.context.startMs=e,this.frameId=requestAnimationFrame(Ste(this,ST))}),Vh(this,"pause",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=cC())}),Vh(this,"stop",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=null)}),lbt(this,ST,e=>{if(this.context.now=e,this.context.deltaMs=e-this.context.startMs,this.onTick(this.context)===!1){this.stop();return}this.frameId=requestAnimationFrame(Ste(this,ST))}),this.context={now:0,startMs:cC(),deltaMs:0}}get elapsedMs(){return this.pausedAtMs!==null?this.pausedAtMs-this.context.startMs:cC()-this.context.startMs}};ST=new WeakMap;function kbt(t,e){const r=new Cbe(({now:n,deltaMs:s})=>{if(s>=e){const i=e>0?n-s%e:n;r.setStartMs(i),t({startMs:i,deltaMs:s})}});return r.start(),()=>r.stop()}function Nbt(t,e){const r=new Cbe(({deltaMs:n})=>{if(n>=e)return t(),!1});return r.start(),()=>r.stop()}function jte(...t){const e=t.length===1?t[0]:t[1],r=t.length===2?t[0]:!0}function Ebt(t,e){if(t==null)throw new Error(e())}var Tbe=t=>typeof t=="object"&&t!==null,Abt=9,Cbt=t=>Tbe(t)&&t.nodeType===Abt,Tbt=t=>Tbe(t)&&t===t.window;function Pbt(t){if(!t)return!1;const e=t.getRootNode();return Pbe(e)===t}function Obt(t){return Cbt(t)?t:Tbt(t)?t.document:(t==null?void 0:t.ownerDocument)??document}function Pbe(t){let e=t.activeElement;for(;e!=null&&e.shadowRoot;){const r=e.shadowRoot.activeElement;if(!r||r===e)break;e=r}return e}var Ibt=(...t)=>t.map(e=>{var r;return(r=e==null?void 0:e.trim)==null?void 0:r.call(e)}).filter(Boolean).join(" "),Rbt=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,kte=t=>{const e={};let r;for(;r=Rbt.exec(t);)e[r[1]]=r[2];return e},Mbt=(t,e)=>{if(wT(t)){if(wT(e))return`${t};${e}`;t=kte(t)}else wT(e)&&(e=kte(e));return Object.assign({},t??{},e??{})};function $M(...t){let e={};for(let r of t){if(!r)continue;for(let s in e){if(s.startsWith("on")&&typeof e[s]=="function"&&typeof r[s]=="function"){e[s]=vbt(r[s],e[s]);continue}if(s==="className"||s==="class"){e[s]=Ibt(e[s],r[s]);continue}if(s==="style"){e[s]=Mbt(e[s],r[s]);continue}e[s]=r[s]!==void 0?r[s]:e[s]}for(let s in r)e[s]===void 0&&(e[s]=r[s]);const n=Object.getOwnPropertySymbols(r);for(let s of n)e[s]=r[s]}return e}function Dbt(t,e,r){let n=[],s;return i=>{const a=t(i);return(a.length!==n.length||a.some((c,u)=>!L9(n[u],c)))&&(n=a,s=e(a,i)),s}}var tv=(t=>(t.NotStarted="Not Started",t.Started="Started",t.Stopped="Stopped",t))(tv||{}),M4="__init__";function Lbt(t){const e=()=>{var a;return((a=t.getRootNode)==null?void 0:a.call(t))??document},r=()=>Obt(e());return{...t,getRootNode:e,getDoc:r,getWin:()=>r().defaultView??window,getActiveElement:()=>Pbe(e()),isActiveElement:Pbt,getById:a=>e().getElementById(a)}}function Fbt(t){return new Proxy({},{get(e,r){return r==="style"?n=>t({style:n}).style:t}})}var $bt=()=>t=>Array.from(new Set(t)),Obe=typeof globalThis.document<"u"?j.useLayoutEffect:j.useEffect;function uO(t){const e=t().value??t().defaultValue,r=t().isEqual??Object.is,[n]=j.useState(e),[s,i]=j.useState(n),a=t().value!==void 0,o=j.useRef(s);o.current=a?t().value:s;const c=j.useRef(o.current);Obe(()=>{c.current=o.current},[s,t().value]);const u=h=>{var m,g;const f=c.current,p=sg(h)?h(f):h;t().debug&&console.log(`[bindable > ${t().debug}] setValue`,{next:p,prev:f}),a||i(p),r(p,f)||(g=(m=t()).onChange)==null||g.call(m,p,f)};function d(){return a?t().value:s}return{initial:n,ref:o,get:d,set(h){(t().sync?Iu.flushSync:xbt)(()=>u(h))},invoke(h,f){var p,m;(m=(p=t()).onChange)==null||m.call(p,h,f)},hash(h){var f,p;return((p=(f=t()).hash)==null?void 0:p.call(f,h))??String(h)}}}uO.cleanup=t=>{j.useEffect(()=>t,[])};uO.ref=t=>{const e=j.useRef(t);return{get:()=>e.current,set:r=>{e.current=r}}};function Bbt(t){const e=j.useRef(t);return{get(r){return e.current[r]},set(r,n){e.current[r]=n}}}var zbt=(t,e)=>{const r=j.useRef(!1),n=j.useRef(!1);j.useEffect(()=>{if(r.current&&n.current)return e();n.current=!0},[...(t??[]).map(s=>typeof s=="function"?s():s)]),j.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[])};function Ubt(t,e={}){var z,P,W,N;const r=j.useMemo(()=>{const{id:U,ids:K,getRootNode:G}=e;return Lbt({id:U,ids:K,getRootNode:G})},[e]),n=(...U)=>{t.debug&&console.log(...U)},s=((z=t.props)==null?void 0:z.call(t,{props:Abe(e),scope:r}))??e,i=Hbt(s),a=(P=t.context)==null?void 0:P.call(t,{prop:i,bindable:uO,scope:r,flush:Nte,getContext(){return c},getComputed(){return S},getRefs(){return g},getEvent(){return p()}}),o=Ibe(a),c={get(U){var K;return(K=o.current)==null?void 0:K[U].ref.current},set(U,K){var G;(G=o.current)==null||G[U].set(K)},initial(U){var K;return(K=o.current)==null?void 0:K[U].initial},hash(U){var G,X;const K=(G=o.current)==null?void 0:G[U].get();return(X=o.current)==null?void 0:X[U].hash(K)}},u=j.useRef(new Map),d=j.useRef(null),h=j.useRef(null),f=j.useRef({type:""}),p=()=>({...f.current,current(){return f.current},previous(){return h.current}}),m=()=>({...k,matches(...U){return U.includes(k.ref.current)},hasTag(U){var K,G;return!!((G=(K=t.states[k.ref.current])==null?void 0:K.tags)!=null&&G.includes(U))}}),g=Bbt(((W=t.refs)==null?void 0:W.call(t,{prop:i,context:c}))??{}),x=()=>({state:m(),context:c,event:p(),prop:i,send:M,action:y,guard:v,track:zbt,refs:g,computed:S,flush:Nte,scope:r,choose:w}),y=U=>{const K=sg(U)?U(x()):U;if(!K)return;const G=K.map(X=>{var B,L;const H=(L=(B=t.implementations)==null?void 0:B.actions)==null?void 0:L[X];return H||jte(`[zag-js] No implementation found for action "${JSON.stringify(X)}"`),H});for(const X of G)X==null||X(x())},v=U=>{var K,G;return sg(U)?U(x()):(G=(K=t.implementations)==null?void 0:K.guards)==null?void 0:G[U](x())},b=U=>{const K=sg(U)?U(x()):U;if(!K)return;const G=K.map(H=>{var L,F;const B=(F=(L=t.implementations)==null?void 0:L.effects)==null?void 0:F[H];return B||jte(`[zag-js] No implementation found for effect "${JSON.stringify(H)}"`),B}),X=[];for(const H of G){const B=H==null?void 0:H(x());B&&X.push(B)}return()=>X.forEach(H=>H==null?void 0:H())},w=U=>cbt(U).find(K=>{let G=!K.guard;return wT(K.guard)?G=!!v(K.guard):sg(K.guard)&&(G=K.guard(x())),G}),S=U=>{Ebt(t.computed,()=>"[zag-js] No computed object found on machine");const K=t.computed[U];return K({context:c,event:p(),prop:i,refs:g,scope:r,computed:S})},k=uO(()=>({defaultValue:t.initialState({prop:i}),onChange(U,K){var X,H,B,L;if(K){const F=u.current.get(K);F==null||F(),u.current.delete(K)}K&&y((X=t.states[K])==null?void 0:X.exit),y((H=d.current)==null?void 0:H.actions);const G=b((B=t.states[U])==null?void 0:B.effects);if(G&&u.current.set(U,G),K===M4){y(t.entry);const F=b(t.effects);F&&u.current.set(M4,F)}y((L=t.states[U])==null?void 0:L.entry)}})),E=j.useRef(void 0),C=j.useRef(tv.NotStarted);Obe(()=>{queueMicrotask(()=>{const G=C.current===tv.Started;C.current=tv.Started,n(G?"rehydrating...":"initializing...");const X=E.current??k.initial;k.invoke(X,G?k.get():M4)});const U=u.current,K=k.ref.current;return()=>{n("unmounting..."),E.current=K,C.current=tv.Stopped,U.forEach(G=>G==null?void 0:G()),u.current=new Map,d.current=null,queueMicrotask(()=>{y(t.exit)})}},[]);const A=()=>"ref"in k?k.ref.current:k.get(),M=U=>{queueMicrotask(()=>{var L,F;if(C.current!==tv.Started)return;h.current=f.current,f.current=U;let K=A();const G=((L=t.states[K].on)==null?void 0:L[U.type])??((F=t.on)==null?void 0:F[U.type]),X=w(G);if(!X)return;d.current=X;const H=X.target??K;n("transition",U.type,X.target||K,`(${X.actions})`);const B=H!==K;B?Iu.flushSync(()=>k.set(H)):X.reenter&&!B?k.invoke(K,K):y(X.actions??[])})};return(N=t.watch)==null||N.call(t,x()),{state:m(),send:M,context:c,prop:i,scope:r,refs:g,computed:S,event:p(),getStatus:()=>C.current}}function Ibe(t){const e=j.useRef(t);return e.current=t,e}function Hbt(t){const e=Ibe(t);return function(n){return e.current[n]}}function Nte(t){queueMicrotask(()=>{Iu.flushSync(()=>t())})}var Vbt=Fbt(t=>t);const Rbe=()=>(t,e)=>e.reduce((r,n)=>{const[s,i]=r,a=n;return i[a]!==void 0&&(s[a]=i[a]),delete i[a],[s,i]},[{},{...t}]);function Wbt(...t){return e=>{const r=[];for(const n of t)if(typeof n=="function"){const s=n(e);typeof s=="function"&&r.push(s)}else n&&(n.current=e);if(r.length)return()=>{for(const n of r)n()}}}function qbt(t){var n,s;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}const D4=t=>{const e=j.memo(j.forwardRef((r,n)=>{const{asChild:s,children:i,...a}=r;if(!s)return j.createElement(t,{...a,ref:n},i);if(!j.isValidElement(i))return null;const o=j.Children.only(i),c=qbt(o);return j.cloneElement(o,{...$M(a,o.props),ref:n?Wbt(n,c):c})}));return e.displayName=t.displayName||t.name,e},Gbt=()=>{const t=new Map;return new Proxy(D4,{apply(e,r,n){return D4(n[0])},get(e,r){const n=r;return t.has(n)||t.set(n,D4(n)),t.get(n)}})},F9=Gbt();function Kbt(t,e){return`${t} returned \`undefined\`. Seems you forgot to wrap component within ${e}`}function Mbe(t={}){const{name:e,strict:r=!0,hookName:n="useContext",providerName:s="Provider",errorMessage:i,defaultValue:a}=t,o=j.createContext(a);o.displayName=e;function c(){const u=j.useContext(o);if(!u&&r){const d=new Error(i??Kbt(n,s));throw d.name="ContextError",kbe(Error,"captureStackTrace")&&sg(Error.captureStackTrace)&&Error.captureStackTrace(d,c),d}return u}return[o.Provider,c,o]}const[Ybt,Dbe]=Mbe({name:"TimerContext",hookName:"useTimerContext",providerName:"<TimerProvider />"}),Lbe=j.forwardRef((t,e)=>{const r=Dbe(),n=$M(r.getAreaProps(),t);return l.jsx(F9.div,{...n,ref:e})});Lbe.displayName="TimerArea";const Xbt=Rbe(),pS=j.forwardRef((t,e)=>{const[r,n]=Xbt(t,["type"]),s=Dbe(),i=$M(s.getItemProps(r),n);return l.jsx(F9.div,{...i,ref:e,children:s.formattedTime[r.type]})});pS.displayName="TimerItem";var mS=(t,e=[])=>({parts:(...r)=>{if(Jbt(e))return mS(t,r);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...r)=>mS(t,[...e,...r]),omit:(...r)=>mS(t,e.filter(n=>!r.includes(n))),rename:r=>mS(r,e),keys:()=>e,build:()=>[...new Set(e)].reduce((r,n)=>Object.assign(r,{[n]:{selector:[`&[data-scope="${Gx(t)}"][data-part="${Gx(n)}"]`,`& [data-scope="${Gx(t)}"][data-part="${Gx(n)}"]`].join(", "),attrs:{"data-scope":Gx(t),"data-part":Gx(n)}}}),{})}),Gx=t=>t.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),Jbt=t=>t.length===0,Qbt=mS("timer").parts("root","area","control","item","itemValue","itemLabel","actionTrigger","separator"),Wh=Qbt.build(),Zbt=t=>{var e;return((e=t.ids)==null?void 0:e.root)??`timer:${t.id}:root`},e0t=t=>{var e;return((e=t.ids)==null?void 0:e.area)??`timer:${t.id}:area`},Ete=new Set(["start","pause","resume","reset","restart"]);function t0t(t,e){const{state:r,send:n,computed:s,scope:i}=t,a=r.matches("running"),o=r.matches("paused"),c=s("time"),u=s("formattedTime"),d=s("progressPercent");return{running:a,paused:o,time:c,formattedTime:u,progressPercent:d,start(){n({type:"START"})},pause(){n({type:"PAUSE"})},resume(){n({type:"RESUME"})},reset(){n({type:"RESET"})},restart(){n({type:"RESTART"})},getRootProps(){return e.element({id:Zbt(i),...Wh.root.attrs})},getAreaProps(){return e.element({role:"timer",id:e0t(i),"aria-label":`${c.days} days ${u.hours}:${u.minutes}:${u.seconds}`,"aria-atomic":!0,...Wh.area.attrs})},getControlProps(){return e.element({...Wh.control.attrs})},getItemProps(h){const f=c[h.type];return e.element({...Wh.item.attrs,"data-type":h.type,style:{"--value":f}})},getItemLabelProps(h){return e.element({...Wh.itemLabel.attrs,"data-type":h.type})},getItemValueProps(h){return e.element({...Wh.itemValue.attrs,"data-type":h.type})},getSeparatorProps(){return e.element({"aria-hidden":!0,...Wh.separator.attrs})},getActionTriggerProps(h){if(!Ete.has(h.action))throw new Error(`[zag-js] Invalid action: ${h.action}. Must be one of: ${Array.from(Ete).join(", ")}`);return e.button({...Wh.actionTrigger.attrs,hidden:Ebe(h.action,{start:()=>a||o,pause:()=>!a,reset:()=>!a&&!o,resume:()=>!o,restart:()=>!1}),type:"button",onClick(f){f.defaultPrevented||n({type:h.action.toUpperCase()})}})}}}var r0t={props({props:t}){return a0t(t),{interval:1e3,startMs:0,...t}},initialState({prop:t}){return t("autoStart")?"running":"idle"},context({prop:t,bindable:e}){return{currentMs:e(()=>({defaultValue:t("startMs")}))}},watch({track:t,send:e,prop:r}){t([()=>r("startMs")],()=>{e({type:"RESTART"})})},on:{RESTART:{target:"running:temp",actions:["resetTime"]}},computed:{time:({context:t})=>n0t(t.get("currentMs")),formattedTime:({computed:t})=>i0t(t("time")),progressPercent:Dbt(({context:t,prop:e})=>[t.get("currentMs"),e("targetMs"),e("startMs"),e("countdown")],([t,e=0,r,n])=>{const s=n?Ate(t,e,r):Ate(t,r,e);return jbt(s,0,1)})},states:{idle:{on:{START:{target:"running"},RESET:{actions:["resetTime"]}}},"running:temp":{effects:["waitForNextTick"],on:{CONTINUE:{target:"running"}}},running:{effects:["keepTicking"],on:{PAUSE:{target:"paused"},TICK:[{target:"idle",guard:"hasReachedTarget",actions:["invokeOnComplete"]},{actions:["updateTime","invokeOnTick"]}],RESET:{actions:["resetTime"]}}},paused:{on:{RESUME:{target:"running"},RESET:{target:"idle",actions:["resetTime"]}}}},implementations:{effects:{keepTicking({prop:t,send:e}){return kbt(({deltaMs:r})=>{e({type:"TICK",deltaMs:r})},t("interval"))},waitForNextTick({send:t}){return Nbt(()=>{t({type:"CONTINUE"})},0)}},actions:{updateTime({context:t,prop:e,event:r}){const n=e("countdown")?-1:1,s=s0t(r.deltaMs,e("interval"));t.set("currentMs",i=>{const a=i+n*s;let o=e("targetMs");return o==null&&e("countdown")&&(o=0),e("countdown")&&o!=null?Math.max(a,o):!e("countdown")&&o!=null?Math.min(a,o):a})},resetTime({context:t,prop:e}){let r=e("targetMs");r==null&&e("countdown")&&(r=0),t.set("currentMs",e("startMs")??0)},invokeOnTick({context:t,prop:e,computed:r}){var n;(n=e("onTick"))==null||n({value:t.get("currentMs"),time:r("time"),formattedTime:r("formattedTime")})},invokeOnComplete({prop:t}){var e;(e=t("onComplete"))==null||e()}},guards:{hasReachedTarget:({context:t,prop:e})=>{let r=e("targetMs");if(r==null&&e("countdown")&&(r=0),r==null)return!1;const n=t.get("currentMs");return e("countdown")?n<=r:n>=r}}}};function n0t(t){const e=Math.max(0,t),r=e%1e3,n=Math.floor(e/1e3)%60,s=Math.floor(e/(1e3*60))%60,i=Math.floor(e/(1e3*60*60))%24;return{days:Math.floor(e/(1e3*60*60*24)),hours:i,minutes:s,seconds:n,milliseconds:r}}function Ate(t,e,r){const n=r-e;return n===0?0:(t-e)/n}function V1(t,e=2){return t.toString().padStart(e,"0")}function s0t(t,e){return Math.floor(t/e)*e}function i0t(t){const{days:e,hours:r,minutes:n,seconds:s}=t;return{days:V1(e),hours:V1(r),minutes:V1(n),seconds:V1(s),milliseconds:V1(t.milliseconds,3)}}function a0t(t){const{startMs:e,targetMs:r,countdown:n,interval:s}=t;if(s!=null&&(typeof s!="number"||s<=0))throw new Error(`[timer] Invalid interval: ${s}. Must be a positive number.`);if(e!=null&&(typeof e!="number"||e<0))throw new Error(`[timer] Invalid startMs: ${e}. Must be a non-negative number.`);if(r!=null&&(typeof r!="number"||r<0))throw new Error(`[timer] Invalid targetMs: ${r}. Must be a non-negative number.`);if(n&&e!=null&&r!=null&&e<=r)throw new Error(`[timer] Invalid countdown configuration: startMs (${e}) must be greater than targetMs (${r}).`);if(!n&&e!=null&&r!=null&&e>=r)throw new Error(`[timer] Invalid stopwatch configuration: startMs (${e}) must be less than targetMs (${r}).`);if(n&&r==null&&e!=null&&e<=0)throw new Error(`[timer] Invalid countdown configuration: startMs (${e}) must be greater than 0 when no targetMs is provided.`)}$bt()(["autoStart","countdown","getRootNode","id","ids","interval","onComplete","onTick","startMs","targetMs"]);const[_5t,o0t]=Mbe({name:"EnvironmentContext",hookName:"useEnvironmentContext",providerName:"<EnvironmentProvider />",strict:!1,defaultValue:{getRootNode:()=>document,getDocument:()=>document,getWindow:()=>window}}),l0t=t=>{const e=j.useId(),{getRootNode:r}=o0t(),n={id:e,getRootNode:r,...t},s=Ubt(r0t,n);return t0t(s,Vbt)},c0t=Rbe(),Fbe=j.forwardRef((t,e)=>{const[r,n]=c0t(t,["id","ids","autoStart","interval","countdown","startMs","targetMs","onComplete","onTick"]),s=l0t(r),i=$M(s.getRootProps(),n);return l.jsx(Ybt,{value:s,children:l.jsx(F9.div,{...i,ref:e})})});Fbe.displayName="TimerRoot";const u0t="2026-05-04",d0t=[{value:"may_2026",label:"May 2026"},{value:"June_2026",label:"June 2026"},{value:"July_2026",label:"July 2026"},{value:"later",label:"Later / not sure yet"}],h0t=[{value:"qualitative",label:"Qualitative"},{value:"quantitative",label:"Quantitative"},{value:"mixed",label:"Mixed methods"},{value:"not_sure",label:"Not sure yet"}];function f0t(){const[t,e]=j.useState(""),[r,n]=j.useState(""),[s,i]=j.useState(""),[a,o]=j.useState(!1),[c,u]=j.useState(!1),[d,h]=j.useState(!1),f=async g=>{if(g.preventDefault(),!t){We.error("Please enter your email address");return}if(!a){We.error("Please accept the privacy terms to join the waitlist");return}u(!0);try{const x=new Date().toISOString(),{error:y}=await be.from("waitlist_signups").insert({email:t.toLowerCase().trim(),planned_start:r||null,research_method:s||null,source:"landingpage",privacy_accepted_at:x,privacy_version:u0t,marketing_consent:!0,marketing_consent_at:x});if(y)if(y.code==="23505")We.error("This email is already on the waitlist!");else throw y;else h(!0),We.success("You're on the list!")}catch(x){console.error("Waitlist signup error:",x),We.error("Something went wrong. Please try again.")}finally{u(!1)}},m=(()=>{const g=new Date("2026-05-30T23:59:59"),x=new Date;return Math.max(0,g.getTime()-x.getTime())})();return l.jsxs(l.Fragment,{children:[l.jsx(Ui,{title:"Join the Waitlist - Early Access to Academly",description:"Join the Academly beta: AI thesis writing tool for Bachelor and Master students. Real citations from your own PDFs. Free to try.",canonical:"https://academly.ai/waitlist"}),l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Xs,{}),l.jsxs("div",{className:"relative pt-32 pb-20",children:[l.jsxs("div",{"aria-hidden":"true",className:"absolute inset-0 grid grid-cols-2 -space-x-52 opacity-40 dark:opacity-20",children:[l.jsx("div",{className:"blur-[106px] h-56 bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),l.jsx("div",{className:"blur-[106px] h-32 bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),l.jsx(Wr,{children:l.jsx("div",{className:"relative",children:l.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[l.jsxs("h1",{className:"text-4xl font-bold tracking-tight text-foreground sm:text-5xl md:text-6xl",children:["Get early access to ",l.jsx("span",{className:"text-primary",children:"Academly"})]}),l.jsx("p",{className:"mt-6 text-lg leading-8 text-muted-foreground",children:"Join the waitlist to be among the first students and researchers using AI for structured academic work."}),l.jsx("div",{className:"mt-12",children:m>0?l.jsx(Fbe,{autoStart:!0,countdown:!0,startMs:m,children:l.jsxs(Lbe,{className:"flex flex-col items-center",children:[l.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-4 uppercase tracking-wider",children:"Public Beta Launches In"}),l.jsxs("div",{className:"flex items-center gap-2 sm:gap-4",children:[l.jsxs("div",{className:"flex flex-col items-center rounded-2xl bg-card border border-border px-4 py-3 sm:px-6 sm:py-4 shadow-lg shadow-primary/5",children:[l.jsx(pS,{type:"days",className:"text-3xl sm:text-5xl font-bold text-foreground tabular-nums"}),l.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"days"})]}),l.jsx("span",{className:"text-2xl sm:text-4xl font-light text-muted-foreground/50",children:":"}),l.jsxs("div",{className:"flex flex-col items-center rounded-2xl bg-card border border-border px-4 py-3 sm:px-6 sm:py-4 shadow-lg shadow-primary/5",children:[l.jsx(pS,{type:"hours",className:"text-3xl sm:text-5xl font-bold text-foreground tabular-nums"}),l.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"hrs"})]}),l.jsx("span",{className:"text-2xl sm:text-4xl font-light text-muted-foreground/50",children:":"}),l.jsxs("div",{className:"flex flex-col items-center rounded-2xl bg-card border border-border px-4 py-3 sm:px-6 sm:py-4 shadow-lg shadow-primary/5",children:[l.jsx(pS,{type:"minutes",className:"text-3xl sm:text-5xl font-bold text-foreground tabular-nums"}),l.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"min"})]}),l.jsx("span",{className:"text-2xl sm:text-4xl font-light text-muted-foreground/50",children:":"}),l.jsxs("div",{className:"flex flex-col items-center rounded-2xl bg-card border border-border px-4 py-3 sm:px-6 sm:py-4 shadow-lg shadow-primary/5",children:[l.jsx(pS,{type:"seconds",className:"text-3xl sm:text-5xl font-bold text-foreground tabular-nums"}),l.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"sec"})]})]})]})}):l.jsxs("div",{className:"flex flex-col items-center",children:[l.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-4 uppercase tracking-wider",children:"Public Beta"}),l.jsx("p",{className:"text-3xl sm:text-5xl font-bold text-primary",children:"Launching soon!"})]})})]})})})]}),l.jsx("section",{className:"pb-20 px-6 lg:px-12",children:l.jsx(Wr,{children:l.jsx("div",{className:"mx-auto max-w-md",children:d?l.jsxs("div",{className:"rounded-3xl border border-border bg-card p-8 shadow-xl shadow-primary/5 text-center animate-fade-in",children:[l.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-full bg-success/10",children:l.jsx(_c,{className:"h-8 w-8 text-success"})}),l.jsx("h3",{className:"text-2xl font-semibold text-foreground",children:"You're on the list!"}),l.jsx("p",{className:"mt-3 text-muted-foreground",children:"We'll notify you when we launch. Check your inbox for updates."})]}):l.jsx("form",{onSubmit:f,className:"rounded-3xl border border-border bg-card p-8 shadow-xl shadow-primary/5",children:l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs(_e,{htmlFor:"email",className:"flex items-center gap-2",children:[l.jsx(Ice,{className:"h-4 w-4 text-muted-foreground"}),"Email address ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsx(Be,{id:"email",type:"email",placeholder:"you@university.edu",value:t,onChange:g=>e(g.target.value),required:!0,className:"h-12"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"planned-start",children:"Planned start (optional)"}),l.jsxs(dt,{value:r,onValueChange:n,children:[l.jsx(lt,{id:"planned-start",className:"h-12",children:l.jsx(ht,{placeholder:"Select..."})}),l.jsx(ct,{children:d0t.map(g=>l.jsx(De,{value:g.value,children:g.label},g.value))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"research-method",children:"Research method (optional)"}),l.jsxs(dt,{value:s,onValueChange:i,children:[l.jsx(lt,{id:"research-method",className:"h-12",children:l.jsx(ht,{placeholder:"Select..."})}),l.jsx(ct,{children:h0t.map(g=>l.jsx(De,{value:g.value,children:g.label},g.value))})]})]}),l.jsxs(_be,{id:"marketing-consent",checked:a,onCheckedChange:o,required:!0,children:["I agree that Academly may contact me about early access and product updates. I have read the"," ",l.jsx(bt,{to:"/legal?tab=privacy",className:"text-primary hover:underline font-medium",target:"_blank",children:"Privacy Policy"}),"."]}),l.jsx(ye,{type:"submit",size:"lg",className:"w-full h-12 text-base font-semibold rounded-full",disabled:c||!a,children:c?"Joining...":"Join the Waitlist"}),l.jsxs("p",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[l.jsx(TH,{className:"h-3 w-3"}),"No spam. No data sharing. Unsubscribe anytime."]})]})})})})}),l.jsx(Bi,{})]})]})}var BM="Tabs",[p0t,j5t]=gs(BM,[Kw]),$be=Kw(),[m0t,$9]=p0t(BM),Bbe=j.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,onValueChange:s,defaultValue:i,orientation:a="horizontal",dir:o,activationMode:c="automatic",...u}=t,d=xx(o),[h,f]=_i({prop:n,onChange:s,defaultProp:i??"",caller:BM});return l.jsx(m0t,{scope:r,baseId:Ka(),value:h,onValueChange:f,orientation:a,dir:d,activationMode:c,children:l.jsx(ot.div,{dir:d,"data-orientation":a,...u,ref:e})})});Bbe.displayName=BM;var zbe="TabsList",Ube=j.forwardRef((t,e)=>{const{__scopeTabs:r,loop:n=!0,...s}=t,i=$9(zbe,r),a=$be(r);return l.jsx(aV,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:n,children:l.jsx(ot.div,{role:"tablist","aria-orientation":i.orientation,...s,ref:e})})});Ube.displayName=zbe;var Hbe="TabsTrigger",Vbe=j.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,disabled:s=!1,...i}=t,a=$9(Hbe,r),o=$be(r),c=Gbe(a.baseId,n),u=Kbe(a.baseId,n),d=n===a.value;return l.jsx(oV,{asChild:!0,...o,focusable:!s,active:d,children:l.jsx(ot.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":u,"data-state":d?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:c,...i,ref:e,onMouseDown:Ke(t.onMouseDown,h=>{!s&&h.button===0&&h.ctrlKey===!1?a.onValueChange(n):h.preventDefault()}),onKeyDown:Ke(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&a.onValueChange(n)}),onFocus:Ke(t.onFocus,()=>{const h=a.activationMode!=="manual";!d&&!s&&h&&a.onValueChange(n)})})})});Vbe.displayName=Hbe;var Wbe="TabsContent",qbe=j.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,forceMount:s,children:i,...a}=t,o=$9(Wbe,r),c=Gbe(o.baseId,n),u=Kbe(o.baseId,n),d=n===o.value,h=j.useRef(d);return j.useEffect(()=>{const f=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(f)},[]),l.jsx(Os,{present:s||d,children:({present:f})=>l.jsx(ot.div,{"data-state":d?"active":"inactive","data-orientation":o.orientation,role:"tabpanel","aria-labelledby":c,hidden:!f,id:u,tabIndex:0,...a,ref:e,style:{...t.style,animationDuration:h.current?"0s":void 0},children:f&&i})})});qbe.displayName=Wbe;function Gbe(t,e){return`${t}-trigger-${e}`}function Kbe(t,e){return`${t}-content-${e}`}var g0t=Bbe,Ybe=Ube,Xbe=Vbe,Jbe=qbe;const y8=g0t,dO=j.forwardRef(({className:t,...e},r)=>l.jsx(Ybe,{ref:r,className:Le("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));dO.displayName=Ybe.displayName;const hf=j.forwardRef(({className:t,...e},r)=>l.jsx(Xbe,{ref:r,className:Le("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...e}));hf.displayName=Xbe.displayName;const ff=j.forwardRef(({className:t,...e},r)=>l.jsx(Jbe,{ref:r,className:Le("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));ff.displayName=Jbe.displayName;const y0t=()=>{const[t]=oE(),e=t.get("tab"),[r,n]=j.useState(e==="privacy"?"privacy":"terms");return j.useEffect(()=>{(e==="privacy"||e==="terms")&&n(e)},[e]),l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:"Terms of Service & Privacy Policy | Academly.ai",description:"Terms of Service and Privacy Policy for Academly.ai — GDPR compliant AI thesis writing platform.",canonical:"https://academly.ai/legal"}),l.jsx(Xs,{}),l.jsxs("section",{className:"relative pt-32 pb-12",children:[l.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-transparent to-transparent"}),l.jsx(Wr,{className:"relative",children:l.jsxs("div",{className:"text-center max-w-3xl mx-auto",children:[l.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-foreground mb-6",children:"Legal Information"}),l.jsx("p",{className:"text-xl text-muted-foreground",children:"Transparency and trust are important to us"})]})})]}),l.jsx("section",{className:"py-12 pb-20",children:l.jsx(Wr,{children:l.jsx("div",{className:"max-w-4xl mx-auto",children:l.jsxs(y8,{value:r,onValueChange:n,className:"w-full",children:[l.jsxs(dO,{className:"grid w-full grid-cols-2 rounded-full p-1 h-14 bg-muted",children:[l.jsx(hf,{value:"terms",className:"rounded-full data-[state=active]:bg-background data-[state=active]:shadow-sm h-12 text-base font-medium",children:"Terms of Service"}),l.jsx(hf,{value:"privacy",className:"rounded-full data-[state=active]:bg-background data-[state=active]:shadow-sm h-12 text-base font-medium",children:"Privacy Policy"})]}),l.jsx(ff,{value:"terms",className:"mt-8",children:l.jsxs("div",{className:"rounded-3xl border border-border bg-card p-8 md:p-12",children:[l.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"TERMS OF SERVICE"}),l.jsxs("p",{className:"text-muted-foreground mb-8",children:["for the use of the SaaS platform Academly.ai",l.jsx("br",{}),"Effective: 15 January 2026, last amended May 2026"]}),l.jsxs("div",{className:"space-y-8 text-muted-foreground leading-relaxed",children:[l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"1. Scope and Contracting Parties"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.1 Provider"}),l.jsx("p",{children:'The provider of the platform available under the domain academly.ai (hereinafter the "Platform" or "Service") is:'}),l.jsxs("p",{className:"mt-2",children:["Academly (Dominik Dunst)",l.jsx("br",{}),"Contact: contact@academly.ai"]}),l.jsx("p",{className:"mt-2",children:"Academly.ai is currently intended exclusively for consumers (B2C). Use for commercial or business purposes is only permitted if the Provider expressly agrees to this on a case-by-case basis."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.2 Scope of these Terms"}),l.jsx("p",{children:'These Terms of Service govern the contractual relationship between the Provider and users of the Platform ("Users"). They apply to all functions offered via the Platform, in particular AI-assisted processing, document processing, quota/credit models ("Student Points"), as well as export and storage functions.'}),l.jsx("p",{className:"mt-2",children:"Any deviating, conflicting, or additional terms of the User shall not become part of the contract unless the Provider expressly agrees to them in writing."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.3 Changes to these Terms"}),l.jsx("p",{children:"The Provider may amend these Terms with effect for the future if there are objective reasons for doing so (e.g., changes in law, technical developments, adjustments to the Service). Changes that are not merely insignificant for Users will be announced at least four (4) weeks before they take effect by email to the address stored in the User account. If the User does not object within that period, the changes will be deemed accepted. The User will be explicitly informed of this consequence in the change notice."}),l.jsx("p",{className:"mt-2",children:"If the User objects in due time, the Provider may terminate the contract as of the date the new Terms would take effect."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"2. Service Description"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.1 Description of the Platform"}),l.jsx("p",{children:"The Platform is an AI-supported, web-based software-as-a-service (SaaS) solution designed to support academic workflows. In particular, it enables the uploading and processing of documents, the generation of summaries, outlines and text drafts, as well as additional functions for structuring academic content."}),l.jsx("p",{className:"mt-2",children:"Which features are available in detail depends on the plan selected by the User and may change as the product evolves."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.2 AI-assisted Functions"}),l.jsx("p",{children:"Academly.ai provides AI-assisted features that may vary depending on the selected plan. These include in particular:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"AI-generated summaries of uploaded content, structured and condensed;"}),l.jsx("li",{children:"outline/structure and drafting functions (e.g., theory, methodology, or structural building blocks);"}),l.jsx("li",{children:"document analysis (e.g., identification of relevant passages, structural suggestions, extraction)."})]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Important:"})," All AI outputs are working drafts. They do not replace the User's own academic work. Outputs may contain errors, omissions, or outdated information and must be reviewed independently by the User."]}),l.jsx("p",{className:"mt-2",children:"To provide AI features, the Provider may use technical subcontractors (e.g., AI models via API providers). Details on service providers, data categories, and any transfers to third countries (if applicable) are set out in the Privacy Policy."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.3 Document Processing"}),l.jsx("p",{children:"Users may upload documents (e.g., PDF and other supported formats) to the Platform. Supported formats and any upload limits (e.g., file size, number of uploads, quotas) depend on the selected plan and are displayed within the Platform and/or on the pricing page. The Provider may adjust such limits for technical or security reasons."}),l.jsx("p",{className:"mt-2",children:"The User represents that they are entitled to use and upload the respective documents and that no third-party rights are infringed."}),l.jsx("p",{className:"mt-2",children:"Uploaded documents are stored and processed in order to provide Platform functionality. Details on data processing and service providers are governed by the Privacy Policy."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.4 Export and Backup Features"}),l.jsx("p",{children:"Users may export generated content—especially summaries, outlines, and drafts—in common formats (e.g., DOCX, TXT) and store it locally."}),l.jsx("p",{className:"mt-2",children:"The Platform may provide features for exporting/transferring User-related content. The Provider recommends regularly creating exports of your content. The Provider does not guarantee permanent storage of all User data beyond the term of the contract."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.5 Use in Different Countries"}),l.jsx("p",{children:"The Services are not intended for use in jurisdictions where providing or using the Services would violate applicable laws or regulations or would subject the Provider to special registration, licensing, or supervisory requirements. Users accessing the Platform from outside Austria do so on their own initiative and are solely responsible for complying with local legal requirements to the extent applicable."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.6 Changes, Corrections and Further Development"}),l.jsx("p",{children:"The Provider is entitled to develop, change, supplement, or restrict the Platform and individual functions, insofar as (i) this is necessary to improve the Service, maintain security, or ensure legal compliance, or (ii) it is reasonable for the User and does not materially impair the purpose of the contract. Obvious errors (e.g., in displays, descriptions, or calculations) may be corrected at any time."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.7 Third-party Offers and Links"}),l.jsx("p",{children:"To the extent the Platform contains links to websites or content of third parties, these are provided for informational purposes only. The respective third party is solely responsible for the content, availability, and data protection practices. The Provider only reviews such content to the extent required by law."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"3. Registration and User Account"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.1 Registration Requirements"}),l.jsx("p",{children:"Use of the Platform is only permitted for persons who have reached the age of 18. By registering, the User confirms that they are of legal age."}),l.jsx("p",{className:"mt-2",children:"The User must provide truthful and complete information during registration. As a rule, only one account per User is permitted. Access credentials must not be shared."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.2 Account Security"}),l.jsx("p",{children:"The User must keep their password confidential and take appropriate measures to prevent unauthorized access. Activities carried out using the account will generally be attributed to the User to the extent the User is responsible for the misuse."}),l.jsx("p",{className:"mt-2",children:"If misuse or security incidents are suspected, the Provider must be informed without undue delay at contact@academly.ai."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.3 Account Termination and Deletion"}),l.jsx("p",{children:"The User may terminate their account at any time—either via available account functions or by notifying contact@academly.ai. Personal data will be deleted in accordance with the GDPR unless statutory retention obligations or legitimate interests (e.g., legal enforcement) require further storage."}),l.jsx("p",{className:"mt-2",children:"The Provider may block or delete accounts in the event of violations of these Terms. As a rule, the User will receive a prior warning. In the case of serious violations, immediate suspension may be carried out."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"4. Subscriptions and Payments"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.1 Available Plans"}),l.jsx("p",{children:"The Platform offers plans that differ in particular with respect to quotas (e.g., Student Points), feature scope, support level, and usage limits. Current plans and details are displayed within the Platform and on the pricing page and form part of the service description."}),l.jsx("p",{className:"mt-2",children:"Prices are stated inclusive of VAT where applicable, or plus any taxes that may apply depending on the User's country of residence/billing location."}),l.jsx("p",{className:"mt-2",children:"The Provider may adjust prices and plan details for future billing periods. Changes will be announced before becoming effective; ongoing subscriptions are only affected from the next renewal."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.2 Payments via Stripe"}),l.jsx("p",{children:"Payments are processed via Stripe. For processing, necessary payment data is transmitted to Stripe. The Provider does not store full payment details (e.g., credit card numbers). In the event of payment default or failed charges, the Provider may suspend access to paid features until outstanding amounts are settled."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.3 Right of Withdrawal (Consumers) – Austria"}),l.jsx("p",{children:"Consumers generally have a statutory right of withdrawal. The withdrawal period is fourteen (14) days from the conclusion of the contract unless otherwise provided by law."}),l.jsx("p",{className:"mt-2",children:"To exercise the right of withdrawal, the User must inform the Provider of the decision to withdraw by an unequivocal statement (e.g., by email or post). Withdrawal notices should be sent to: Email: contact@academly.ai"}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Consequences of withdrawal:"})," In the event of an effective withdrawal, services received shall be returned/refunded in accordance with statutory provisions."]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Early expiry of the right of withdrawal:"})," For digital content and digital services, the right of withdrawal may expire early if the User expressly requests that the Provider begin performance before the withdrawal period ends and the User confirms that they thereby lose the right of withdrawal once the service has been provided or made available."]})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"5. Usage Rights and Restrictions"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.1 Granted Usage Rights"}),l.jsx("p",{children:"The Provider grants the User a non-exclusive, non-transferable, non-sublicensable right to use the Platform during the term of the contract within the scope of the booked plan. Use is limited to personal, academic purposes. Any commercial use requires prior written consent of the Provider."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.2 Prohibited Use"}),l.jsx("p",{children:"In particular, it is prohibited to use the Platform to create unlawful content or to infringe third-party rights. It is also prohibited to bypass security mechanisms, conduct automated mass access without permission, share accounts, or distribute malware or spam."}),l.jsx("p",{className:"mt-2",children:"The Platform must not be used to present AI outputs as the User's own academic work without appropriate own contribution and without proper labeling/citation work."}),l.jsx("p",{className:"mt-2",children:"In particular, the following is also prohibited:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"systematically reading or extracting data (scraping) without permission;"}),l.jsx("li",{children:"bypassing or manipulating technical protection measures;"}),l.jsx("li",{children:"reverse engineering, decompilation, or other analysis of the Platform unless mandatory law permits it;"}),l.jsx("li",{children:"using automated systems or scripts that place excessive load on the Platform;"}),l.jsx("li",{children:"using the Platform to deceive third parties (e.g., phishing, identity misuse);"}),l.jsx("li",{children:"uploading content that infringes third-party rights;"}),l.jsx("li",{children:"introducing malware or other disruptions;"}),l.jsx("li",{children:"account sharing or allowing multiple persons to use one account."})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.3 Fair Use and Abuse Prevention"}),l.jsx("p",{children:"The Provider may restrict use if abusive or excessive usage is identified, in particular in cases of systematic mass processing, circumvention of plan limits, or usage by multiple persons via one account. Where possible, the User will be informed in advance, unless immediate action is necessary to prevent harm."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"6. Intellectual Property"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.1 Rights in the Platform"}),l.jsx("p",{children:"All rights in the Platform (software, design, logos, texts, trademarks) remain with the Provider or its licensors. The User receives no rights beyond the granted usage right."}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Trademark notice:"}),` "Academly.ai" is currently used as a product/project name. To the best of the Provider's knowledge, no registered trademark exists at this time.`]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.2 Rights in User Content"}),l.jsx("p",{children:'The User retains all rights in content uploaded to the Platform ("User Content"). By uploading, the User grants the Provider the right to store and process such content insofar as necessary to provide the Services.'})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.3 Rights in AI-generated Content"}),l.jsx("p",{children:"AI-generated content may be used by the User within the scope of Platform usage. The User acknowledges that AI outputs may not constitute works protected by copyright and that third-party rights cannot be excluded in individual cases. The User is responsible for review, use, and proper citation."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.4 Feedback"}),l.jsx("p",{children:"If the User voluntarily submits feedback, ideas, or improvement suggestions to the Provider, the Provider may use them free of charge, worldwide and without time limitation, to improve the Platform. Personal data will only be processed in accordance with the Privacy Policy."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"7. Academic Integrity and Notices"}),l.jsx("p",{children:"Academly.ai is a tool. The Provider does not guarantee academic success. Users are required to independently review content, cite sources correctly, and comply with the rules of their university/institution. The Provider assumes no liability for consequences arising from plagiarism, violations of academic rules, or improper use of the content."})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"8. Limitation of Liability"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:'8.1 Platform Availability ("Best Effort")'}),l.jsx("p",{children:'The Provider uses reasonable efforts to ensure high availability of the Platform within technical and operational possibilities ("best effort"). There is no entitlement to uninterrupted availability at all times. In particular, maintenance, further development, security measures, technical issues, or force majeure events may lead to temporary restrictions.'}),l.jsx("p",{className:"mt-2",children:"Planned maintenance will be announced in advance where possible and, where feasible, carried out during times of lower usage. The Provider is not liable for outages or restrictions caused by circumstances outside its control, in particular issues with third-party providers and subcontractors (e.g., hosting, database, payment, or AI providers) or general network failures."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.2 Data Loss"}),l.jsx("p",{children:"The Provider takes reasonable measures for data backup but does not guarantee full recoverability in all cases. Users should regularly create exports/backups of their content."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.3 Liability Cap"}),l.jsx("p",{children:"In cases of slight negligence, the Provider is only liable if essential contractual obligations (cardinal obligations) are breached, and then only for foreseeable, typical damage. To the extent legally permissible, the Provider's total liability is limited in amount to the fees actually paid by the User to the Provider during the last twelve (12) months before the damaging event occurred."}),l.jsx("p",{className:"mt-2",children:"These limitations do not apply in cases of intent or gross negligence, injury to life, body or health, or mandatory statutory liability provisions."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"9. Final Provisions"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.1 Governing Law"}),l.jsx("p",{children:"Austrian law applies, excluding the UN Convention on Contracts for the International Sale of Goods (CISG). Mandatory consumer protection provisions of the User's country of residence remain unaffected."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.2 Jurisdiction and Dispute Resolution"}),l.jsxs("p",{children:["For consumers, the statutory places of jurisdiction apply. The Provider is neither obliged nor willing to participate in dispute resolution proceedings before a consumer arbitration board. The EU Online Dispute Resolution platform is available at:"," ",l.jsx("a",{href:"https://ec.europa.eu/consumers/odr",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://ec.europa.eu/consumers/odr"})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.3 Severability"}),l.jsx("p",{children:"If any provision of these Terms is or becomes invalid, the remainder of the agreement remains effective. An effective provision that most closely reflects the economic purpose of the invalid provision shall be deemed agreed."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.4 Contact"}),l.jsx("p",{children:"Questions or complaints may be sent to contact@academly.ai."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.5 Electronic Communication"}),l.jsx("p",{children:"The User agrees that contractual notices and declarations by the Provider may generally be made electronically (e.g., by email or within the Platform), to the extent legally permissible."})]})]})]})]})]})}),l.jsx(ff,{value:"privacy",className:"mt-8",children:l.jsxs("div",{className:"rounded-3xl border border-border bg-card p-8 md:p-12",children:[l.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"PRIVACY POLICY"}),l.jsxs("p",{className:"text-muted-foreground mb-8",children:["for the use of the SaaS platform Academly.ai",l.jsx("br",{}),"Last updated: May 2026"]}),l.jsxs("div",{className:"space-y-8 text-muted-foreground leading-relaxed",children:[l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"1. Introduction and Controller"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.1 Controller name and contact details"}),l.jsx("p",{children:"The controller within the meaning of the General Data Protection Regulation (GDPR) and other applicable data protection laws is:"}),l.jsxs("p",{className:"mt-2",children:["Academly (Dominik Dunst)",l.jsx("br",{}),"Email: contact@academly.ai"]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.2 Data Protection Officer"}),l.jsx("p",{children:"The appointment of a Data Protection Officer is currently not required under Art. 37 GDPR, as the statutory requirements are not met."}),l.jsx("p",{className:"mt-2",children:"For any data protection inquiries, please contact us using the contact details above."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.3 Scope of this Privacy Policy"}),l.jsx("p",{children:"This Privacy Policy applies to the platform accessible under the domain academly.ai and all related services, including mobile access and linked subdomains. It informs you about the nature, scope and purposes of the collection and use of personal data by the controller."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"2. Principles of Data Processing"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.1 Legal bases for processing"}),l.jsx("p",{children:"We process personal data only on the basis of one of the following legal bases under Art. 6(1) GDPR:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-2",children:[l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"(a) Consent (Art. 6(1)(a) GDPR)"}),l.jsx("br",{}),"Where we obtain your consent for specific processing activities, your consent forms the legal basis. You may withdraw your consent at any time with effect for the future."]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"(b) Performance of a contract (Art. 6(1)(b) GDPR)"}),l.jsx("br",{}),"Where processing is necessary for the performance of a contract to which you are a party, or in order to take steps at your request prior to entering into a contract, Art. 6(1)(b) GDPR is the legal basis."]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"(c) Legal obligation (Art. 6(1)(c) GDPR)"}),l.jsx("br",{}),"Where processing is necessary for compliance with a legal obligation to which we are subject, Art. 6(1)(c) GDPR is the legal basis."]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"(d) Legitimate interests (Art. 6(1)(f) GDPR)"}),l.jsx("br",{}),"Where processing is necessary for the purposes of our legitimate interests or those of a third party, and your interests or fundamental rights and freedoms do not override those interests, Art. 6(1)(f) GDPR is the legal basis. Our legitimate interests include, in particular, providing and improving our services, ensuring IT security, and preventing fraud."]})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.2 Categories of data processed"}),l.jsx("p",{children:"When you use our platform, we may process the following categories of personal data:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Account data:"})," email address, nickname, profile information (university, degree program), account-related information"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Usage data:"})," IP address, access time, pages accessed, browser type, operating system, referrer URL, device information"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Content data:"})," uploaded documents, AI-generated content (summaries, thesis drafts, analyses), stored projects and notes"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Payment-related data:"})," billing address, payment history, subscription status (full payment details are processed exclusively by Stripe)"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Meta and communication data:"})," token usage, student points, activity history, communication with support"]})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.3 Purposes of processing"}),l.jsx("p",{children:"We process personal data for the following purposes:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Providing the platform and its features"}),l.jsx("li",{children:"User account administration and authentication"}),l.jsx("li",{children:"Processing documents for AI-assisted analysis"}),l.jsx("li",{children:"Generating summaries, thesis drafts and other AI-generated outputs"}),l.jsx("li",{children:"Payment processing and subscription management"}),l.jsx("li",{children:"Ensuring IT security and fraud prevention"}),l.jsx("li",{children:"Analytics and service improvement"}),l.jsx("li",{children:"Compliance with statutory retention obligations"}),l.jsx("li",{children:"Communication with users (support and service messages)"})]})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"3. Data Collection When Using the Platform"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.1 Registration and user account"}),l.jsx("p",{children:"When you register for a user account, we collect:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Email address:"})," required to create an account, authenticate you and communicate with you"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Password:"})," stored only in hashed form; plaintext passwords are never stored or transmitted"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Profile information (optional):"})," nickname, university, degree program, research interests"]})]}),l.jsx("p",{className:"mt-2",children:"Authentication is provided via Supabase Auth, a specialized authentication service. Processing is necessary for the performance of the contract (Art. 6(1)(b) GDPR)."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.2 Document upload and processing"}),l.jsx("p",{children:"Users may upload documents (in particular PDF files) to the platform. These documents are:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Stored securely in Supabase Storage"}),l.jsx("li",{children:"Processed to provide AI-assisted analysis features"}),l.jsx("li",{children:"Retained for the duration of the account use or until deleted by the user"})]}),l.jsx("p",{className:"mt-2",children:"This processing is necessary for the performance of the contract, as it constitutes a core function of the platform (Art. 6(1)(b) GDPR)."}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Note:"})," Users are responsible for ensuring that they are authorized to use and upload the relevant documents and that no third-party rights are infringed."]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.3 AI-generated content"}),l.jsx("p",{children:"In the course of using the platform, AI-generated content is created, including:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Thesis drafts and outlines"}),l.jsx("li",{children:"Summaries of uploaded documents"}),l.jsx("li",{children:"Theory building blocks and methodology suggestions"}),l.jsx("li",{children:"Document analyses and structure suggestions"})]}),l.jsx("p",{className:"mt-2",children:"This content is stored in the user account and can be exported or deleted by the user. The legal basis is performance of the contract (Art. 6(1)(b) GDPR)."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.4 Usage data and statistics"}),l.jsx("p",{children:"To provide and improve our services, we collect:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Token usage:"})," for billing and quota monitoring"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Student points:"})," to manage the credit system"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Activity history:"})," to track usage history"]})]}),l.jsx("p",{className:"mt-2",children:"Processing is based on our legitimate interests in service improvement and fraud prevention (Art. 6(1)(f) GDPR)."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"4. Hosting and Infrastructure"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.1 Vercel (frontend hosting)"}),l.jsx("p",{children:"Our frontend is hosted by Vercel Inc. Each time you access the platform, the following data may be processed automatically:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"IP address of the accessing device"}),l.jsx("li",{children:"Date and time of access"}),l.jsx("li",{children:"Browser type and version"}),l.jsx("li",{children:"Operating system"}),l.jsx("li",{children:"Referrer URL"})]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Provider:"})," Vercel Inc., 340 S Lemon Ave #4133, Walnut, CA 91789, USA"]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Server locations:"})," Vercel operates a global edge network. Data may be processed in various data centers worldwide, including in the USA and the EU."]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," legitimate interest in the technical provision of the platform (Art. 6(1)(f) GDPR)."]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"International transfers:"})," where data is transferred to the USA, we rely on Standard Contractual Clauses pursuant to Art. 46(2)(c) GDPR and, where applicable, on the EU–US Data Privacy Framework for appropriately certified companies, as well as supplementary technical and organizational measures."]}),l.jsxs("p",{className:"mt-2",children:["Further information:"," ",l.jsx("a",{href:"https://vercel.com/legal/privacy-policy",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://vercel.com/legal/privacy-policy"})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.2 Supabase (backend infrastructure)"}),l.jsx("p",{children:"We use Supabase for backend services, including:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Database:"})," storage of account data, projects and generated content"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Authentication:"})," user account and login management"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"File storage:"})," secure storage of uploaded documents"]})]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Provider:"})," Supabase Inc., 970 Toa Payoh North #07-04, Singapore 318992"]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Server location:"})," our Supabase instance is hosted in the EU region (Frankfurt, Germany)."]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," performance of the contract (Art. 6(1)(b) GDPR) and legitimate interests (Art. 6(1)(f) GDPR)."]}),l.jsx("p",{className:"mt-2",children:"Supabase acts as a processor pursuant to Art. 28 GDPR. We enter into data processing agreements (Art. 28 GDPR) with processors where applicable or otherwise ensure that appropriate agreements are in place."}),l.jsxs("p",{className:"mt-2",children:["Further information:"," ",l.jsx("a",{href:"https://supabase.com/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://supabase.com/privacy"})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.3 Edge Functions (serverless)"}),l.jsx("p",{children:"To process AI requests, we use serverless functions (edge functions) executed on Supabase infrastructure. These functions:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Process requests to AI APIs in real time"}),l.jsx("li",{children:"Are executed in the EU region"}),l.jsx("li",{children:"Do not store persistent data outside the database"})]}),l.jsx("p",{className:"mt-2",children:"Processing is necessary for performance of the contract (Art. 6(1)(b) GDPR)."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"5. Payment Processing"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.1 Stripe as payment service provider"}),l.jsx("p",{children:"Payments are processed via Stripe, an external payment service provider. Stripe processes:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Credit card or other payment information"}),l.jsx("li",{children:"Billing address"}),l.jsx("li",{children:"Email address"}),l.jsx("li",{children:"Transaction data"})]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Provider:"})," Stripe Payments Europe Ltd., 1 Grand Canal Street Lower, Grand Canal Dock, Dublin, D02 H210, Ireland"]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Important note:"})," We do not store full payment details (e.g., credit card numbers) on our servers. These are processed and stored exclusively by Stripe."]}),l.jsx("p",{className:"mt-2",children:"With respect to payment data, Stripe acts as an independent controller and is subject to its own data protection obligations."}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," performance of the contract (Art. 6(1)(b) GDPR)."]}),l.jsxs("p",{className:"mt-2",children:["Further information:"," ",l.jsx("a",{href:"https://stripe.com/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://stripe.com/privacy"})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.2 Invoice data"}),l.jsx("p",{children:"Invoice data (billing address, invoice amounts, invoice date) is stored for tax and accounting purposes."}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," compliance with legal obligations (Art. 6(1)(c) GDPR) in conjunction with Austrian tax and commercial retention obligations."]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Retention period:"})," 7 years under Austrian tax law."]})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"6. Analytics and Tracking"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.1 Plausible Analytics"}),l.jsx("p",{children:"We use Plausible Analytics, a privacy-friendly web analytics service."}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Provider:"})," Plausible Insights OÜ, Västriku tn 2, 50403, Tartu, Estonia"]}),l.jsx("p",{className:"mt-2",children:l.jsx("strong",{className:"text-foreground",children:"Key characteristics:"})}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"No cookies"}),l.jsx("li",{children:"No collection of directly identifying personal data"}),l.jsx("li",{children:"No cross-device tracking"}),l.jsx("li",{children:"GDPR-compliant without consent"}),l.jsx("li",{children:"Servers located in the EU"})]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Data processed:"})," aggregated, anonymized usage statistics (page views, time on page, device type, country based on anonymized IP)."]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," legitimate interest in analytics and optimization of our platform (Art. 6(1)(f) GDPR)."]}),l.jsxs("p",{className:"mt-2",children:["Further information:"," ",l.jsx("a",{href:"https://plausible.io/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://plausible.io/privacy"})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.2 Cookie policy"}),l.jsx("p",{children:"Our platform uses only technically necessary cookies required for operating the platform, such as:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Authentication cookies (session management)"}),l.jsx("li",{children:"Security cookies (CSRF protection)"})]}),l.jsx("p",{className:"mt-2",children:"These cookies are essential for the operation of the platform and do not require consent under applicable ePrivacy rules."}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Analytics cookies:"})," currently not used. Plausible Analytics works without cookies."]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.3 Notice regarding possible future use of Google Analytics"}),l.jsx("p",{children:"We do not currently use Google Analytics. If we implement Google Analytics or comparable tools requiring consent in the future, this will only occur after you have given prior consent via a cookie/consent banner (Art. 6(1)(a) GDPR in conjunction with applicable ePrivacy rules). In that case, we will update this Privacy Policy in advance and provide transparent information, in particular on the provider, data categories, retention periods and any international transfers."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"7. Email Communication"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"7.1 Transactional emails"}),l.jsx("p",{children:"We send transactional emails that are necessary for performing the contract, such as:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Account confirmation upon registration"}),l.jsx("li",{children:"Password reset"}),l.jsx("li",{children:"Payment confirmations and invoices"}),l.jsx("li",{children:"Important service messages (e.g., changes to the Terms of Service)"})]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," performance of the contract (Art. 6(1)(b) GDPR)."]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"7.2 Marketing and product updates"}),l.jsx("p",{children:"By creating an account or joining our waitlist, you consent to receive occasional product updates, feature announcements, tips for using the platform, and promotional offers from Academly by email. Legal basis: consent (Art. 6(1)(a) GDPR). Frequency: We typically send 1-4 emails per month. We do not share your email address with third parties for their marketing purposes. Opt-out: Every marketing email contains an unsubscribe link. You can withdraw your consent at any time by clicking 'Unsubscribe' in any email or by contacting us at contact@academly.ai. Withdrawal of consent does not affect the lawfulness of processing based on consent before its withdrawal. Unsubscribing from marketing emails does not affect transactional emails necessary for providing the service."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"8. Disclosure to Third Parties"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.1 Service providers"}),l.jsx("p",{children:"To provide the platform, we use service providers. Where these providers process personal data on our behalf, they act as processors within the meaning of Art. 28 GDPR. Where service providers process data for their own purposes (e.g., payment processing), they act as independent controllers and are subject to their own data protection obligations."}),l.jsx("div",{className:"mt-4 overflow-x-auto",children:l.jsxs("table",{className:"w-full border-collapse border border-border text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"bg-muted",children:[l.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Provider"}),l.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Role"}),l.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Purpose"}),l.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Location"})]})}),l.jsxs("tbody",{children:[l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"Supabase Inc."}),l.jsx("td",{className:"border border-border p-2",children:"Processor"}),l.jsx("td",{className:"border border-border p-2",children:"Database, authentication, storage"}),l.jsx("td",{className:"border border-border p-2",children:"EU (Frankfurt)"})]}),l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"Vercel Inc."}),l.jsx("td",{className:"border border-border p-2",children:"Processor"}),l.jsx("td",{className:"border border-border p-2",children:"Frontend hosting/delivery"}),l.jsx("td",{className:"border border-border p-2",children:"Global (including EU/USA)"})]}),l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"Plausible Insights OÜ"}),l.jsx("td",{className:"border border-border p-2",children:"Processor"}),l.jsx("td",{className:"border border-border p-2",children:"Web analytics (aggregated, cookie-free)"}),l.jsx("td",{className:"border border-border p-2",children:"EU (Estonia)"})]}),l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"OpenAI, LLC"}),l.jsx("td",{className:"border border-border p-2",children:"Processor"}),l.jsx("td",{className:"border border-border p-2",children:"AI processing via API"}),l.jsx("td",{className:"border border-border p-2",children:"USA"})]}),l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"Stripe Payments Europe Ltd."}),l.jsx("td",{className:"border border-border p-2",children:"Independent controller"}),l.jsx("td",{className:"border border-border p-2",children:"Payment processing"}),l.jsx("td",{className:"border border-border p-2",children:"Ireland/EU"})]})]})]})}),l.jsx("p",{className:"mt-2",children:"Where providers act as processors, we enter into data processing agreements (Art. 28 GDPR) and/or otherwise ensure that appropriate agreements are in place."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.2 International transfers"}),l.jsx("p",{children:"Where personal data is transferred to third countries outside the EU/EEA, this is done on the basis of appropriate safeguards, in particular:"}),l.jsx("p",{className:"mt-2",children:l.jsx("strong",{className:"text-foreground",children:"USA:"})}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Standard Contractual Clauses pursuant to Art. 46(2)(c) GDPR (SCCs)"}),l.jsx("li",{children:"Where applicable: EU–US Data Privacy Framework for appropriately certified companies"}),l.jsx("li",{children:"Supplementary technical and organizational measures"})]}),l.jsx("p",{className:"mt-2",children:l.jsx("strong",{className:"text-foreground",children:"Affected services:"})}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Vercel Inc. (hosting) – SCCs; where applicable EU–US DPF"}),l.jsx("li",{children:"OpenAI, LLC (AI processing) – SCCs"})]}),l.jsx("p",{className:"mt-2",children:"Users may request copies of the Standard Contractual Clauses by contacting contact@academly.ai."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.3 AI Provider — Important Notice"}),l.jsxs("p",{children:[l.jsx("strong",{className:"text-foreground",children:"OpenAI, LLC"}),l.jsx("br",{}),"3180 18th Street, San Francisco, CA 94110, USA"]}),l.jsx("p",{className:"mt-2",children:"When you use the following features, content from your uploaded documents and interactions is transmitted to OpenAI for processing:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Theory & Background Builder"}),l.jsx("li",{children:"Methods & Approach Builder"}),l.jsx("li",{children:"Supervisor Chat"}),l.jsx("li",{children:"Qualitative Analysis (interview evaluation, codebooks)"}),l.jsx("li",{children:"Document Summaries"}),l.jsx("li",{children:"Topic Explorer"})]}),l.jsxs("p",{className:"mt-2",children:["This means: interview transcripts, research documents, and chat messages you enter are sent to OpenAI's API for analysis. According to OpenAI's API data usage policy, data transmitted via the API is ",l.jsx("strong",{className:"text-foreground",children:"not used to train their models"}),"."]}),l.jsx("p",{className:"mt-2",children:l.jsx("strong",{className:"text-foreground",children:"Important notes:"})}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Transmission is encrypted"}),l.jsx("li",{children:"Standard Contractual Clauses apply for international transfers"}),l.jsx("li",{children:"Data transmitted via the API is not used by OpenAI to train its models, according to OpenAI's API data usage policy"})]}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," performance of the contract (Art. 6(1)(b) GDPR), as AI processing is a core feature of the platform."]}),l.jsxs("p",{className:"mt-2",children:["Further information:"," ",l.jsx("a",{href:"https://openai.com/policies/privacy-policy",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://openai.com/policies/privacy-policy"})]})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"9. Retention and Deletion"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.1 Retention periods by data category"}),l.jsx("div",{className:"mt-4 overflow-x-auto",children:l.jsxs("table",{className:"w-full border-collapse border border-border text-sm",children:[l.jsx("thead",{children:l.jsxs("tr",{className:"bg-muted",children:[l.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Data category"}),l.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Retention period"}),l.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Reason"})]})}),l.jsxs("tbody",{children:[l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"Account data"}),l.jsx("td",{className:"border border-border p-2",children:"Until account deletion"}),l.jsx("td",{className:"border border-border p-2",children:"Performance of contract"})]}),l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"Documents"}),l.jsx("td",{className:"border border-border p-2",children:"Per user settings or upon account deletion"}),l.jsx("td",{className:"border border-border p-2",children:"Performance of contract"})]}),l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"AI-generated content"}),l.jsx("td",{className:"border border-border p-2",children:"Until deleted by user or account deletion"}),l.jsx("td",{className:"border border-border p-2",children:"Performance of contract"})]}),l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"Usage statistics"}),l.jsx("td",{className:"border border-border p-2",children:"12 months"}),l.jsx("td",{className:"border border-border p-2",children:"Legitimate interests"})]}),l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"Payment/invoice data"}),l.jsx("td",{className:"border border-border p-2",children:"7 years"}),l.jsx("td",{className:"border border-border p-2",children:"Statutory retention obligation"})]}),l.jsxs("tr",{children:[l.jsx("td",{className:"border border-border p-2",children:"Server logs"}),l.jsx("td",{className:"border border-border p-2",children:"30 days"}),l.jsx("td",{className:"border border-border p-2",children:"IT security"})]})]})]})})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.2 Automatic deletion of inactive accounts"}),l.jsx("p",{children:"Inactive accounts are automatically deleted after 24 months without login and/or without active use, unless statutory retention obligations or legitimate interests (e.g., legal enforcement) prevent deletion. Before deletion, we will inform users by email where possible and provide an opportunity to export data."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.3 Backup retention"}),l.jsx("p",{children:"To ensure data integrity, daily full backups are created. Backups are retained on a rolling basis for 7 days; the oldest backup is overwritten thereafter. Backup retention is intended solely for disaster recovery and is not an archiving service."})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"10. Data Security"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"10.1 Technical measures"}),l.jsx("p",{children:"We implement technical measures to protect personal data, including:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Encryption:"})," all data transmissions via TLS/HTTPS (at least TLS 1.2)"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Password hashing:"})," passwords stored using secure, up-to-date hashing algorithms"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Row Level Security (RLS):"})," database access restricted via row-level policies"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Access controls:"})," restricting access to authorized systems"]}),l.jsxs("li",{children:[l.jsx("strong",{className:"text-foreground",children:"Regular updates:"})," applying security patches and updates"]})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"10.2 Organizational measures"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Access to personal data is limited to what is necessary"}),l.jsx("li",{children:"Security-relevant accesses are logged where appropriate"}),l.jsx("li",{children:"Security measures are reviewed regularly"})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"10.3 Incident response"}),l.jsx("p",{children:"In the event of a personal data breach, we will:"}),l.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[l.jsx("li",{children:"Notify the competent supervisory authority within 72 hours where required under Art. 33 GDPR"}),l.jsx("li",{children:"Notify affected individuals without undue delay where required under Art. 34 GDPR"}),l.jsx("li",{children:"Document the incident and take remedial measures"})]})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"11. Data Subject Rights"}),l.jsx("p",{className:"mb-4",children:"You have the following rights regarding your personal data:"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.1 Right of access (Art. 15 GDPR)"}),l.jsx("p",{children:"You have the right to obtain information about personal data processed by us. The platform provides a data export function allowing you to download your data."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.2 Right to rectification (Art. 16 GDPR)"}),l.jsx("p",{children:"You have the right to request correction of inaccurate personal data. Many data fields can be edited directly in your account."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.3 Right to erasure (Art. 17 GDPR)"}),l.jsx("p",{children:"You have the right to request deletion of your personal data, unless statutory retention obligations apply. Full deletion can be performed via the account deletion function or by contacting contact@academly.ai."}),l.jsxs("div",{className:"mt-4 p-4 bg-muted/50 rounded-lg border border-border",children:[l.jsx("h5",{className:"font-medium text-foreground mb-3",children:"What happens when you delete your account:"}),l.jsx("p",{className:"text-sm mb-2",children:l.jsx("strong",{className:"text-foreground",children:"Immediately and permanently deleted:"})}),l.jsxs("ul",{className:"list-disc list-inside text-sm space-y-1 mb-4",children:[l.jsx("li",{children:"Your email address and profile information (nickname, university, research interests)"}),l.jsx("li",{children:"All uploaded documents and PDFs"}),l.jsx("li",{children:"All generated summaries and analyses"}),l.jsx("li",{children:"All thesis drafts, chapters, and sections"}),l.jsx("li",{children:"All research setups and topic explorations"}),l.jsx("li",{children:"All qualitative coding data (interviews, codebooks, coded segments)"}),l.jsx("li",{children:"All files stored in our cloud storage"})]}),l.jsx("p",{className:"text-sm mb-2",children:l.jsx("strong",{className:"text-foreground",children:"Anonymized (retained without personal reference):"})}),l.jsxs("ul",{className:"list-disc list-inside text-sm space-y-1 mb-4",children:[l.jsx("li",{children:"Transaction records required for tax/accounting compliance (§ 132 BAO Austria: 7 years)"}),l.jsx("li",{children:"Usage statistics (aggregated, with no possibility of personal identification)"})]}),l.jsx("p",{className:"text-sm mb-2",children:l.jsx("strong",{className:"text-foreground",children:"Third-party data:"})}),l.jsx("p",{className:"text-sm mb-4",children:"We will cancel any active subscription with Stripe. Stripe retains payment records according to their own retention policy (typically 7 years for tax/legal compliance). For deletion of data held by Stripe, please contact Stripe directly or visit their privacy portal."}),l.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/50 p-3 rounded-md border border-amber-200 dark:border-amber-800",children:l.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[l.jsx("strong",{children:"Important:"}),' Before deleting your account, we recommend downloading a complete backup of your data using the "Download Backup" function in your account settings. This backup includes all your documents, summaries, thesis drafts, and qualitative coding data in standard formats.']})})]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.4 Right to restriction of processing (Art. 18 GDPR)"}),l.jsx("p",{children:"Under certain conditions, you have the right to request restriction of processing."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.5 Right to data portability (Art. 20 GDPR)"}),l.jsx("p",{children:"You have the right to receive your personal data in a structured, commonly used and machine-readable format. The platform offers export functions (DOCX, TXT, backup ZIP) for your content."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.6 Right to object (Art. 21 GDPR)"}),l.jsx("p",{children:"You have the right to object, on grounds relating to your particular situation, at any time to processing based on Art. 6(1)(f) GDPR."}),l.jsx("p",{className:"mt-2",children:"You may object to direct marketing at any time without giving reasons."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.7 Withdrawal of consent (Art. 7(3) GDPR)"}),l.jsx("p",{children:"Where processing is based on consent, you may withdraw your consent at any time with effect for the future. The lawfulness of processing prior to withdrawal remains unaffected."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.8 Right to lodge a complaint with a supervisory authority"}),l.jsx("p",{children:"You have the right to lodge a complaint with a data protection supervisory authority. The competent authority for us is:"}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Austrian Data Protection Authority (Österreichische Datenschutzbehörde)"}),l.jsx("br",{}),"Barichgasse 40-42",l.jsx("br",{}),"1030 Vienna, Austria",l.jsx("br",{}),"Email: dsb@dsb.gv.at"]}),l.jsxs("p",{className:"mt-2",children:["Website:"," ",l.jsx("a",{href:"https://www.dsb.gv.at",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://www.dsb.gv.at"})]})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"12. Special Notes on AI Processing"}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"12.1 Automated decision-making"}),l.jsx("p",{children:"We do not carry out automated decision-making, including profiling, that produces legal effects concerning users or similarly significantly affects them (Art. 22 GDPR)."}),l.jsx("p",{className:"mt-2",children:"AI-generated content is provided as working drafts only and has no legal or academic binding effect."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"12.2 Use of data for AI training"}),l.jsxs("p",{children:[l.jsx("strong",{className:"text-foreground",children:"Important note:"})," User data is not used to train external AI models."]}),l.jsx("p",{className:"mt-2",children:"Data transmitted to OpenAI via our API integration is not used to train models according to OpenAI's API data usage policy."})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"12.3 AI-generated content"}),l.jsx("p",{children:"AI-generated content may be labeled as such, in particular where this is required for transparency or to meet regulatory requirements. This is intended to be in line with applicable transparency requirements, including those arising under the EU AI Act (Regulation (EU) 2024/1689)."}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Note:"})," AI-generated content may contain errors, inaccuracies, or outdated information. Users are responsible for reviewing and deciding how to use such content."]})]})]})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"13. Changes to this Privacy Policy"}),l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"13.1 Updates"}),l.jsx("p",{children:"We reserve the right to update this Privacy Policy to reflect changes in legal requirements or changes to our services."}),l.jsx("p",{className:"mt-2",children:"In the event of material changes, registered users will be informed by email. The current version is available on our platform at academly.ai/legal."}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Date of last update:"})," May 2026"]})]})})]}),l.jsxs("section",{children:[l.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"14. Contact"}),l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-foreground mb-2",children:"14.1 Data protection inquiries"}),l.jsx("p",{children:"For questions about data protection, exercising your rights, or complaints, please contact:"}),l.jsxs("p",{className:"mt-2",children:[l.jsx("strong",{className:"text-foreground",children:"Email:"})," contact@academly.ai"]}),l.jsx("p",{className:"mt-2",children:"We aim to respond to requests within one month."})]})})]})]})]})})]})})})}),l.jsx(Bi,{})]})},x0t=Nh("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),wh=j.forwardRef(({className:t,variant:e,...r},n)=>l.jsx("div",{ref:n,role:"alert",className:Le(x0t({variant:e}),t),...r}));wh.displayName="Alert";const B9=j.forwardRef(({className:t,...e},r)=>l.jsx("h5",{ref:r,className:Le("mb-1 font-medium leading-none tracking-tight",t),...e}));B9.displayName="AlertTitle";const Sh=j.forwardRef(({className:t,...e},r)=>l.jsx("div",{ref:r,className:Le("text-sm [&_p]:leading-relaxed",t),...e}));Sh.displayName="AlertDescription";const Cte="2026-01-15",v0t="ACAD58EMY",b0t=!0;function w0t({defaultIsLogin:t=!1}){const[e,r]=j.useState(t),[n,s]=j.useState(""),[i,a]=j.useState(""),[o,c]=j.useState(""),[u,d]=j.useState(!1),[h,f]=j.useState(!1),[p,m]=j.useState(""),[g,x]=j.useState(!1),[y,v]=j.useState(!1),[b,w]=j.useState(""),[S,k]=j.useState(!1),[E,C]=j.useState(!1),[A,M]=j.useState(""),[z,P]=j.useState(!1),[W,N]=j.useState(!1),{signIn:U,signUp:K}=Dt(),G=async B=>{if(B.preventDefault(),v(!0),w(""),e){const{error:L}=await U(n,i);L&&w(L.message)}else{if(i!==o){w("Passwords do not match"),v(!1);return}if(p.toUpperCase()!==v0t){w("Invalid invite code. Contact us for beta access."),v(!1);return}if(!g){w("Please accept the Terms of Service and Privacy Policy"),v(!1);return}const L={terms_accepted_at:new Date().toISOString(),privacy_accepted_at:new Date().toISOString(),terms_version:Cte,privacy_version:Cte},{error:F}=await K(n,i,L);F?w(F.message):k(!0)}v(!1)},X=async B=>{B.preventDefault(),N(!0),w("");try{const{error:L}=await be.auth.resetPasswordForEmail(A,{redirectTo:"https://academly.ai/reset-password"});if(L)throw L;P(!0)}catch(L){w(L.message||"Failed to send reset email")}finally{N(!1)}},H=()=>{r(!e),C(!1),c(""),d(!1),f(!1),m(""),x(!1),w(""),k(!1),P(!1)};return S?l.jsxs("div",{className:"w-full max-w-5xl mx-auto grid lg:grid-cols-2 gap-12 lg:gap-16 items-center",children:[l.jsxs("div",{className:"text-center lg:text-left space-y-8",children:[l.jsxs("div",{className:"space-y-4",children:[l.jsxs("h1",{className:"text-4xl md:text-5xl font-bold text-foreground",children:["Welcome to",l.jsx("span",{className:"text-primary",children:" Academly"})]}),l.jsx("p",{className:"text-xl text-muted-foreground",children:"Your AI-powered research assistant. Structure your thesis, manage sources, and create properly cited drafts."})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-start gap-3.5",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg bg-primary/8 flex items-center justify-center flex-shrink-0 mt-0.5",children:l.jsx(_$,{className:"w-4.5 h-4.5 text-primary"})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-sm font-medium text-foreground",children:"AI Writing Suite"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Theory, Methods, Discussion & Conclusion"})]})]}),l.jsxs("div",{className:"flex items-start gap-3.5",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg bg-emerald-500/8 flex items-center justify-center flex-shrink-0 mt-0.5",children:l.jsx(qy,{className:"w-4.5 h-4.5 text-emerald-500"})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-sm font-medium text-foreground",children:"Qualitative Analysis"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Full Mayring workflow — codebook, coding & findings"})]})]}),l.jsxs("div",{className:"flex items-start gap-3.5",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg bg-orange-500/8 flex items-center justify-center flex-shrink-0 mt-0.5",children:l.jsx(Gy,{className:"w-4.5 h-4.5 text-orange-500"})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-sm font-medium text-foreground",children:"AI Supervisor"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Your personal thesis coach, available 24/7"})]})]})]})]}),l.jsx("div",{className:"w-full max-w-md mx-auto lg:mx-0",children:l.jsxs("div",{className:"rounded-3xl border border-border bg-card p-8 shadow-xl text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-500/10 flex items-center justify-center mx-auto mb-6",children:l.jsx(vu,{className:"w-8 h-8 text-emerald-500"})}),l.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Check your inbox!"}),l.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground mb-6",children:[l.jsx(Ice,{className:"w-4 h-4"}),l.jsx("span",{className:"text-sm",children:n})]}),l.jsx("p",{className:"text-muted-foreground mb-8",children:"We've sent a confirmation email to your address. Please click the link in the email to activate your account."}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-xs text-muted-foreground",children:"Didn't receive the email? Check your spam folder or try again."}),l.jsx(ye,{variant:"outline",onClick:H,className:"w-full h-12 rounded-full",children:"Back to Login"})]})]})})]}):l.jsxs("div",{className:"w-full max-w-5xl mx-auto grid lg:grid-cols-2 gap-12 lg:gap-16 items-center",children:[l.jsxs("div",{className:"text-center lg:text-left space-y-8",children:[l.jsxs("div",{className:"space-y-4",children:[l.jsxs("h1",{className:"text-4xl md:text-5xl font-bold text-foreground",children:["Welcome to",l.jsx("span",{className:"text-primary",children:" Academly"})]}),l.jsx("p",{className:"text-xl text-muted-foreground",children:"Your AI-powered research assistant. Structure your thesis, manage sources, and create properly cited drafts."})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-start gap-3.5 group",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg bg-primary/8 flex items-center justify-center flex-shrink-0 mt-0.5",children:l.jsx(_$,{className:"w-4.5 h-4.5 text-primary"})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-sm font-medium text-foreground",children:"AI Writing Suite"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Theory, Methods, Discussion & Conclusion"})]})]}),l.jsxs("div",{className:"flex items-start gap-3.5 group",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg bg-emerald-500/8 flex items-center justify-center flex-shrink-0 mt-0.5",children:l.jsx(qy,{className:"w-4.5 h-4.5 text-emerald-500"})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-sm font-medium text-foreground",children:"Qualitative Analysis"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Full Mayring workflow — codebook, coding & findings"})]})]}),l.jsxs("div",{className:"flex items-start gap-3.5 group",children:[l.jsx("div",{className:"w-9 h-9 rounded-lg bg-orange-500/8 flex items-center justify-center flex-shrink-0 mt-0.5",children:l.jsx(Gy,{className:"w-4.5 h-4.5 text-orange-500"})}),l.jsxs("div",{className:"text-left",children:[l.jsx("p",{className:"text-sm font-medium text-foreground",children:"AI Supervisor"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Your personal thesis coach, available 24/7"})]})]})]})]}),l.jsx("div",{className:"w-full max-w-md mx-auto lg:mx-0",children:l.jsx("div",{className:"rounded-3xl border border-border bg-card p-8 shadow-xl",children:E?l.jsx("div",{children:z?l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"w-16 h-16 rounded-full bg-emerald-500/10 flex items-center justify-center mx-auto mb-6",children:l.jsx(vu,{className:"w-8 h-8 text-emerald-500"})}),l.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Reset email sent!"}),l.jsx("p",{className:"text-muted-foreground mb-8",children:"Check your inbox for the reset link."}),l.jsx(ye,{variant:"outline",onClick:()=>{C(!1),P(!1)},className:"w-full h-12 rounded-full",children:"Back to Login"})]}):l.jsxs("form",{onSubmit:X,className:"space-y-5",children:[l.jsxs("div",{className:"text-center mb-8",children:[l.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Reset Password"}),l.jsx("p",{className:"text-muted-foreground",children:"Enter your email to receive a reset link."})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"forgotEmail",className:"text-foreground font-medium",children:"Email"}),l.jsx(Be,{id:"forgotEmail",type:"email",value:A,onChange:B=>M(B.target.value),required:!0,className:"h-12 rounded-xl",placeholder:"your@email.com"})]}),b&&l.jsx(wh,{className:"border-destructive/50 bg-destructive/10",children:l.jsx(Sh,{className:"text-destructive",children:b})}),l.jsx(ye,{type:"submit",disabled:W,className:"w-full h-12 rounded-full text-base font-semibold",children:W?"Sending...":"Send Reset Link"}),l.jsx("div",{className:"text-center pt-2",children:l.jsx("button",{type:"button",onClick:()=>{C(!1),w("")},className:"text-sm text-primary hover:underline font-medium",children:"Back to Login"})})]})}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"text-center mb-8",children:[l.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:e?"Sign In":"Create Account"}),l.jsx("p",{className:"text-muted-foreground",children:e?"Welcome back! Sign in to continue.":"Get started with Academly"})]}),l.jsxs("form",{onSubmit:G,className:"space-y-5",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"email",className:"text-foreground font-medium",children:"Email"}),l.jsx(Be,{id:"email",type:"email",value:n,onChange:B=>s(B.target.value),required:!0,className:"h-12 rounded-xl",placeholder:"your@email.com"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"password",className:"text-foreground font-medium",children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(Be,{id:"password",type:u?"text":"password",value:i,onChange:B=>a(B.target.value),required:!0,className:"h-12 rounded-xl pr-12",placeholder:"At least 6 characters"}),l.jsx("button",{type:"button",onClick:()=>d(!u),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",tabIndex:-1,children:u?l.jsx(F2,{className:"h-5 w-5"}):l.jsx(Xa,{className:"h-5 w-5"})})]})]}),e&&l.jsx("div",{className:"text-right",children:l.jsx("button",{type:"button",onClick:()=>{C(!0),M(n),w("")},className:"text-sm text-primary hover:underline",children:"Forgot password?"})}),!e&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"confirmPassword",className:"text-foreground font-medium",children:"Confirm Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(Be,{id:"confirmPassword",type:h?"text":"password",value:o,onChange:B=>c(B.target.value),required:!0,className:"h-12 rounded-xl pr-12",placeholder:"Repeat your password"}),l.jsx("button",{type:"button",onClick:()=>f(!h),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",tabIndex:-1,children:h?l.jsx(F2,{className:"h-5 w-5"}):l.jsx(Xa,{className:"h-5 w-5"})})]})]}),!e&&b0t&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"inviteCode",className:"text-foreground font-medium",children:"Invite Code"}),l.jsx(Be,{id:"inviteCode",type:"text",value:p,onChange:B=>m(B.target.value),required:!0,className:"h-12 rounded-xl",placeholder:"Enter your beta invite code"})]}),!e&&l.jsxs(_be,{id:"terms-consent",checked:g,onCheckedChange:x,required:!0,children:["I agree to the"," ",l.jsx(bt,{to:"/legal?tab=terms",className:"text-primary hover:underline font-medium",target:"_blank",children:"Terms of Service"})," ","and acknowledge the"," ",l.jsx(bt,{to:"/legal?tab=privacy",className:"text-primary hover:underline font-medium",target:"_blank",children:"Privacy Policy"}),"."]}),b&&l.jsx(wh,{className:"border-destructive/50 bg-destructive/10",children:l.jsx(Sh,{className:"text-destructive",children:b})}),l.jsx(ye,{type:"submit",disabled:y||!e&&!g,className:"w-full h-12 rounded-full text-base font-semibold",children:y?"Loading...":e?"Sign In":"Create Account"}),!e&&l.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"We'll send you account-related emails and occasional product updates. You can unsubscribe anytime."}),l.jsx("div",{className:"text-center pt-2",children:l.jsx("button",{type:"button",onClick:H,className:"text-sm text-primary hover:underline font-medium",children:e?"Don't have an account? Sign up":"Already have an account? Sign in"})})]})]})})})]})}const S0t=()=>{const{user:t,loading:e}=Dt(),r=Or(),[n]=oE(),i=n.get("mode")!=="signup";return j.useEffect(()=>{t&&!e&&r("/dashboard")},[t,e,r]),e?l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Xs,{}),l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})]}):t?null:l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:"Sign In | Academly.ai",description:"Private page on Academly.ai.",canonical:"https://academly.ai/login",noIndex:!0}),l.jsx(Xs,{}),l.jsxs("div",{className:"fixed inset-0 -z-10",children:[l.jsx("div",{className:"absolute top-20 left-1/4 w-72 h-72 bg-primary/20 rounded-full blur-3xl"}),l.jsx("div",{className:"absolute top-40 right-1/4 w-96 h-96 bg-purple-500/10 rounded-full blur-3xl"})]}),l.jsx("section",{className:"pt-32 pb-20",children:l.jsx(Wr,{children:l.jsx(w0t,{defaultIsLogin:i})})})]})},_0t=()=>{const t=Or(),[e,r]=j.useState(""),[n,s]=j.useState(""),[i,a]=j.useState(!1),[o,c]=j.useState(!1),[u,d]=j.useState(!1),[h,f]=j.useState(""),[p,m]=j.useState(!1);j.useEffect(()=>{const{data:{subscription:x}}=be.auth.onAuthStateChange((y,v)=>{y==="PASSWORD_RECOVERY"||(y==="SIGNED_OUT"||!v&&!window.location.hash.includes("access_token"))&&t("/login")});return()=>x.unsubscribe()},[t]);const g=async()=>{if(f(""),e!==n){f("Passwords do not match");return}if(e.length<6){f("Password must be at least 6 characters");return}d(!0);try{const{error:x}=await be.auth.updateUser({password:e});if(x)throw x;m(!0),setTimeout(()=>t("/login"),3e3)}catch(x){f(x.message||"Failed to update password")}finally{d(!1)}};return l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:"Reset Password | Academly.ai",description:"Private page on Academly.ai.",canonical:"https://academly.ai/reset-password",noIndex:!0}),l.jsx(Xs,{}),l.jsxs("div",{className:"fixed inset-0 -z-10",children:[l.jsx("div",{className:"absolute top-20 left-1/4 w-72 h-72 bg-primary/20 rounded-full blur-3xl"}),l.jsx("div",{className:"absolute top-40 right-1/4 w-96 h-96 bg-purple-500/10 rounded-full blur-3xl"})]}),l.jsx("section",{className:"pt-32 pb-20",children:l.jsx(Wr,{children:l.jsx("div",{className:"max-w-md mx-auto",children:l.jsxs(ze,{children:[l.jsxs(et,{className:"text-center",children:[l.jsx(at,{className:"text-2xl",children:"Set new password"}),l.jsx(Un,{children:"Enter your new password below."})]}),l.jsx(Ge,{children:p?l.jsxs("div",{className:"flex flex-col items-center gap-3 py-6 text-center",children:[l.jsx(_c,{className:"w-12 h-12 text-green-500"}),l.jsx("p",{className:"text-lg font-medium",children:"Password updated successfully!"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Redirecting to login…"})]}):l.jsxs("form",{onSubmit:x=>{x.preventDefault(),g()},className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"password",children:"New Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(Be,{id:"password",type:i?"text":"password",value:e,onChange:x=>r(x.target.value),placeholder:"Min. 6 characters",required:!0}),l.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>a(!i),children:i?l.jsx(F2,{className:"w-4 h-4"}):l.jsx(Xa,{className:"w-4 h-4"})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"confirm",children:"Confirm Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(Be,{id:"confirm",type:o?"text":"password",value:n,onChange:x=>s(x.target.value),placeholder:"Repeat password",required:!0}),l.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>c(!o),children:o?l.jsx(F2,{className:"w-4 h-4"}):l.jsx(Xa,{className:"w-4 h-4"})})]})]}),h&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[l.jsx(rj,{className:"w-4 h-4 shrink-0"}),h]}),l.jsx(ye,{type:"submit",className:"w-full",disabled:u,children:u?"Updating…":"Update Password"})]})})]})})})})]})},x8="id,slug,language,title,excerpt,category,tags,author_name,reading_time,cover_image,featured,published_at";function j0t(t){return YH({queryKey:["articles","list","all"],queryFn:async()=>{let e=be.from("articles").select(x8).eq("status","published").order("featured",{ascending:!1}).order("published_at",{ascending:!1,nullsFirst:!1});const{data:r,error:n}=await e;if(n)throw n;return r??[]}})}function k0t(t){return YH({queryKey:["article",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await be.from("articles").select("*").eq("slug",t).eq("status","published").order("language",{ascending:!0}).limit(1).maybeSingle();if(r)throw r;if(!e)return{article:null,faqs:[],related:[]};const[{data:n},s]=await Promise.all([be.from("article_faq").select("*").eq("article_id",e.id).order("order_index",{ascending:!0}),N0t(e)]);return{article:e,faqs:n??[],related:s}}})}async function N0t(t){var s;let e=be.from("articles").select(x8).eq("status","published").eq("language",t.language).neq("id",t.id).limit(3);t.category&&(e=e.eq("category",t.category));const{data:r}=await e;let n=r??[];if(n.length<3&&((s=t.tags)!=null&&s.length)){const{data:i}=await be.from("articles").select(x8).eq("status","published").eq("language",t.language).neq("id",t.id).overlaps("tags",t.tags).limit(3),a=new Set(n.map(o=>o.id));for(const o of i??[])!a.has(o.id)&&n.length<3&&n.push(o)}return n}const Qbe=({article:t})=>l.jsxs(bt,{to:`/blog/${t.slug}`,className:"group rounded-3xl border border-border bg-card shadow-sm p-8 hover:shadow-md hover:border-primary/30 transition-all flex flex-col",children:[t.category&&l.jsx("span",{className:"inline-flex items-center self-start rounded-full bg-primary/10 text-primary text-xs font-semibold uppercase tracking-wider px-3 py-1 mb-4",children:t.category}),l.jsx("h2",{className:"text-xl md:text-2xl font-bold text-foreground mb-3 group-hover:text-primary transition-colors",children:t.title}),t.excerpt&&l.jsx("p",{className:"text-muted-foreground leading-relaxed line-clamp-2 mb-6",children:t.excerpt}),l.jsxs("div",{className:"mt-auto flex items-center justify-between text-sm",children:[l.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[l.jsx(gx,{className:"h-4 w-4"}),t.reading_time??5," min"]}),l.jsxs("span",{className:"inline-flex items-center gap-1 font-semibold text-primary",children:["Read more",l.jsx(eh,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]});function Zbe(t,e){j.useEffect(()=>{if(!t)return;const r=document.documentElement;r.dataset.prerenderReady="true";let n=null;return e&&e!==200&&(n=document.createElement("meta"),n.name="prerender-status-code",n.content=String(e),document.head.appendChild(n)),()=>{delete r.dataset.prerenderReady,n&&n.remove()}},[t,e])}const E0t=()=>{const{data:t=[],isLoading:e}=j0t();return Zbe(!e),l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:"Blog: Thesis Writing Guides & Academic Tips | Academly",description:"Step-by-step guides for Bachelor and Master thesis students. Mayring analysis, APA7 citations, research methodology and more.",canonical:"https://academly.ai/blog"}),l.jsx(Xs,{}),l.jsxs("main",{children:[l.jsxs("section",{className:"relative pt-32 pb-16 overflow-hidden",children:[l.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-transparent to-transparent"}),l.jsxs("div",{className:"relative max-w-4xl mx-auto px-6 text-center",children:[l.jsx("p",{className:"text-sm uppercase tracking-wider text-primary mb-4 font-medium",children:"Blog"}),l.jsx("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-foreground mb-6",children:"Thesis Writing Guides"}),l.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto leading-relaxed",children:"Practical guides for Bachelor and Master students, from research methods to citations."})]})]}),l.jsx("section",{className:"pb-24",children:l.jsx("div",{className:"max-w-5xl mx-auto px-6 space-y-10",children:t.length>0&&l.jsx("div",{className:"grid md:grid-cols-2 gap-6",children:t.map(r=>l.jsx(Qbe,{article:r},r.id))})})})]}),l.jsx(Bi,{})]})};function Tte(t,e){const r=String(t);if(typeof e!="string")throw new TypeError("Expected character");let n=0,s=r.indexOf(e);for(;s!==-1;)n++,s=r.indexOf(e,s+e.length);return n}function A0t(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function C0t(t,e,r){const s=FR((r||{}).ignore||[]),i=T0t(e);let a=-1;for(;++a<i.length;)ppe(t,"text",o);function o(u,d){let h=-1,f;for(;++h<d.length;){const p=d[h],m=f?f.children:void 0;if(s(p,m?m.indexOf(p):void 0,f))return;f=p}if(f)return c(u,d)}function c(u,d){const h=d[d.length-1],f=i[a][0],p=i[a][1];let m=0;const x=h.children.indexOf(u);let y=!1,v=[];f.lastIndex=0;let b=f.exec(u.value);for(;b;){const w=b.index,S={index:b.index,input:b.input,stack:[...d,u]};let k=p(...b,S);if(typeof k=="string"&&(k=k.length>0?{type:"text",value:k}:void 0),k===!1?f.lastIndex=w+1:(m!==w&&v.push({type:"text",value:u.value.slice(m,w)}),Array.isArray(k)?v.push(...k):k&&v.push(k),m=w+b[0].length,y=!0),!f.global)break;b=f.exec(u.value)}return y?(m<u.value.length&&v.push({type:"text",value:u.value.slice(m)}),h.children.splice(x,1,...v)):v=[u],x+v.length}}function T0t(t){const e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const r=!t[0]||Array.isArray(t[0])?t:[t];let n=-1;for(;++n<r.length;){const s=r[n];e.push([P0t(s[0]),O0t(s[1])])}return e}function P0t(t){return typeof t=="string"?new RegExp(A0t(t),"g"):t}function O0t(t){return typeof t=="function"?t:function(){return t}}const L4="phrasing",F4=["autolink","link","image","label"];function I0t(){return{transforms:[B0t],enter:{literalAutolink:M0t,literalAutolinkEmail:$4,literalAutolinkHttp:$4,literalAutolinkWww:$4},exit:{literalAutolink:$0t,literalAutolinkEmail:F0t,literalAutolinkHttp:D0t,literalAutolinkWww:L0t}}}function R0t(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:L4,notInConstruct:F4},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:L4,notInConstruct:F4},{character:":",before:"[ps]",after:"\\/",inConstruct:L4,notInConstruct:F4}]}}function M0t(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function $4(t){this.config.enter.autolinkProtocol.call(this,t)}function D0t(t){this.config.exit.autolinkProtocol.call(this,t)}function L0t(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function F0t(t){this.config.exit.autolinkEmail.call(this,t)}function $0t(t){this.exit(t)}function B0t(t){C0t(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,z0t],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),U0t]],{ignore:["link","linkReference"]})}function z0t(t,e,r,n,s){let i="";if(!e0e(s)||(/^w/i.test(e)&&(r=e+r,e="",i="http://"),!H0t(r)))return!1;const a=V0t(r+n);if(!a[0])return!1;const o={type:"link",title:null,url:i+e+a[0],children:[{type:"text",value:e+a[0]}]};return a[1]?[o,{type:"text",value:a[1]}]:o}function U0t(t,e,r,n){return!e0e(n,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function H0t(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function V0t(t){const e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let r=e[0],n=r.indexOf(")");const s=Tte(t,"(");let i=Tte(t,")");for(;n!==-1&&s>i;)t+=r.slice(0,n+1),r=r.slice(n+1),n=r.indexOf(")"),i++;return[t,r]}function e0e(t,e){const r=t.input.charCodeAt(t.index-1);return(t.index===0||Qy(r)||MR(r))&&(!e||r!==47)}t0e.peek=Z0t;function W0t(){this.buffer()}function q0t(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function G0t(){this.buffer()}function K0t(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function Y0t(t){const e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=fc(this.sliceSerialize(t)).toLowerCase(),r.label=e}function X0t(t){this.exit(t)}function J0t(t){const e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=fc(this.sliceSerialize(t)).toLowerCase(),r.label=e}function Q0t(t){this.exit(t)}function Z0t(){return"["}function t0e(t,e,r,n){const s=r.createTracker(n);let i=s.move("[^");const a=r.enter("footnoteReference"),o=r.enter("reference");return i+=s.move(r.safe(r.associationId(t),{after:"]",before:i})),o(),a(),i+=s.move("]"),i}function ewt(){return{enter:{gfmFootnoteCallString:W0t,gfmFootnoteCall:q0t,gfmFootnoteDefinitionLabelString:G0t,gfmFootnoteDefinition:K0t},exit:{gfmFootnoteCallString:Y0t,gfmFootnoteCall:X0t,gfmFootnoteDefinitionLabelString:J0t,gfmFootnoteDefinition:Q0t}}}function twt(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:r,footnoteReference:t0e},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(n,s,i,a){const o=i.createTracker(a);let c=o.move("[^");const u=i.enter("footnoteDefinition"),d=i.enter("label");return c+=o.move(i.safe(i.associationId(n),{before:c,after:"]"})),d(),c+=o.move("]:"),n.children&&n.children.length>0&&(o.shift(4),c+=o.move((e?`
`:" ")+i.indentLines(i.containerFlow(n,o.current()),e?r0e:rwt))),u(),c}}function rwt(t,e,r){return e===0?t:r0e(t,e,r)}function r0e(t,e,r){return(r?"":" ")+t}const nwt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];n0e.peek=lwt;function swt(){return{canContainEols:["delete"],enter:{strikethrough:awt},exit:{strikethrough:owt}}}function iwt(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:nwt}],handlers:{delete:n0e}}}function awt(t){this.enter({type:"delete",children:[]},t)}function owt(t){this.exit(t)}function n0e(t,e,r,n){const s=r.createTracker(n),i=r.enter("strikethrough");let a=s.move("~~");return a+=r.containerPhrasing(t,{...s.current(),before:a,after:"~"}),a+=s.move("~~"),i(),a}function lwt(){return"~"}function cwt(t){return t.length}function uwt(t,e){const r=e||{},n=(r.align||[]).concat(),s=r.stringLength||cwt,i=[],a=[],o=[],c=[];let u=0,d=-1;for(;++d<t.length;){const g=[],x=[];let y=-1;for(t[d].length>u&&(u=t[d].length);++y<t[d].length;){const v=dwt(t[d][y]);if(r.alignDelimiters!==!1){const b=s(v);x[y]=b,(c[y]===void 0||b>c[y])&&(c[y]=b)}g.push(v)}a[d]=g,o[d]=x}let h=-1;if(typeof n=="object"&&"length"in n)for(;++h<u;)i[h]=Pte(n[h]);else{const g=Pte(n);for(;++h<u;)i[h]=g}h=-1;const f=[],p=[];for(;++h<u;){const g=i[h];let x="",y="";g===99?(x=":",y=":"):g===108?x=":":g===114&&(y=":");let v=r.alignDelimiters===!1?1:Math.max(1,c[h]-x.length-y.length);const b=x+"-".repeat(v)+y;r.alignDelimiters!==!1&&(v=x.length+v+y.length,v>c[h]&&(c[h]=v),p[h]=v),f[h]=b}a.splice(1,0,f),o.splice(1,0,p),d=-1;const m=[];for(;++d<a.length;){const g=a[d],x=o[d];h=-1;const y=[];for(;++h<u;){const v=g[h]||"";let b="",w="";if(r.alignDelimiters!==!1){const S=c[h]-(x[h]||0),k=i[h];k===114?b=" ".repeat(S):k===99?S%2?(b=" ".repeat(S/2+.5),w=" ".repeat(S/2-.5)):(b=" ".repeat(S/2),w=b):w=" ".repeat(S)}r.delimiterStart!==!1&&!h&&y.push("|"),r.padding!==!1&&!(r.alignDelimiters===!1&&v==="")&&(r.delimiterStart!==!1||h)&&y.push(" "),r.alignDelimiters!==!1&&y.push(b),y.push(v),r.alignDelimiters!==!1&&y.push(w),r.padding!==!1&&y.push(" "),(r.delimiterEnd!==!1||h!==u-1)&&y.push("|")}m.push(r.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return m.join(`
`)}function dwt(t){return t==null?"":String(t)}function Pte(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function hwt(t,e,r,n){const s=r.enter("blockquote"),i=r.createTracker(n);i.move("> "),i.shift(2);const a=r.indentLines(r.containerFlow(t,i.current()),fwt);return s(),a}function fwt(t,e,r){return">"+(r?"":" ")+t}function pwt(t,e){return Ote(t,e.inConstruct,!0)&&!Ote(t,e.notInConstruct,!1)}function Ote(t,e,r){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return r;let n=-1;for(;++n<e.length;)if(t.includes(e[n]))return!0;return!1}function Ite(t,e,r,n){let s=-1;for(;++s<r.unsafe.length;)if(r.unsafe[s].character===`
`&&pwt(r.stack,r.unsafe[s]))return/[ \t]/.test(n.before)?"":" ";return`\\
`}function mwt(t,e){const r=String(t);let n=r.indexOf(e),s=n,i=0,a=0;if(typeof e!="string")throw new TypeError("Expected substring");for(;n!==-1;)n===s?++i>a&&(a=i):i=1,s=n+e.length,n=r.indexOf(e,s);return a}function gwt(t,e){return!!(e.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function ywt(t){const e=t.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function xwt(t,e,r,n){const s=ywt(r),i=t.value||"",a=s==="`"?"GraveAccent":"Tilde";if(gwt(t,r)){const h=r.enter("codeIndented"),f=r.indentLines(i,vwt);return h(),f}const o=r.createTracker(n),c=s.repeat(Math.max(mwt(i,s)+1,3)),u=r.enter("codeFenced");let d=o.move(c);if(t.lang){const h=r.enter(`codeFencedLang${a}`);d+=o.move(r.safe(t.lang,{before:d,after:" ",encode:["`"],...o.current()})),h()}if(t.lang&&t.meta){const h=r.enter(`codeFencedMeta${a}`);d+=o.move(" "),d+=o.move(r.safe(t.meta,{before:d,after:`
`,encode:["`"],...o.current()})),h()}return d+=o.move(`
`),i&&(d+=o.move(i+`
`)),d+=o.move(c),u(),d}function vwt(t,e,r){return(r?"":" ")+t}function z9(t){const e=t.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function bwt(t,e,r,n){const s=z9(r),i=s==='"'?"Quote":"Apostrophe",a=r.enter("definition");let o=r.enter("label");const c=r.createTracker(n);let u=c.move("[");return u+=c.move(r.safe(r.associationId(t),{before:u,after:"]",...c.current()})),u+=c.move("]: "),o(),!t.url||/[\0- \u007F]/.test(t.url)?(o=r.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(r.safe(t.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=r.enter("destinationRaw"),u+=c.move(r.safe(t.url,{before:u,after:t.title?" ":`
`,...c.current()}))),o(),t.title&&(o=r.enter(`title${i}`),u+=c.move(" "+s),u+=c.move(r.safe(t.title,{before:u,after:s,...c.current()})),u+=c.move(s),o()),a(),u}function wwt(t){const e=t.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Zj(t){return"&#x"+t.toString(16).toUpperCase()+";"}function hO(t,e,r){const n=K0(t),s=K0(e);return n===void 0?s===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:n===1?s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}s0e.peek=Swt;function s0e(t,e,r,n){const s=wwt(r),i=r.enter("emphasis"),a=r.createTracker(n),o=a.move(s);let c=a.move(r.containerPhrasing(t,{after:s,before:o,...a.current()}));const u=c.charCodeAt(0),d=hO(n.before.charCodeAt(n.before.length-1),u,s);d.inside&&(c=Zj(u)+c.slice(1));const h=c.charCodeAt(c.length-1),f=hO(n.after.charCodeAt(0),h,s);f.inside&&(c=c.slice(0,-1)+Zj(h));const p=a.move(s);return i(),r.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},o+c+p}function Swt(t,e,r){return r.options.emphasis||"*"}function _wt(t,e){let r=!1;return WV(t,function(n){if("value"in n&&/\r?\n|\r/.test(n.value)||n.type==="break")return r=!0,x6}),!!((!t.depth||t.depth<3)&&FV(t)&&(e.options.setext||r))}function jwt(t,e,r,n){const s=Math.max(Math.min(6,t.depth||1),1),i=r.createTracker(n);if(_wt(t,r)){const d=r.enter("headingSetext"),h=r.enter("phrasing"),f=r.containerPhrasing(t,{...i.current(),before:`
`,after:`
`});return h(),d(),f+`
`+(s===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.lastIndexOf(`
`))+1))}const a="#".repeat(s),o=r.enter("headingAtx"),c=r.enter("phrasing");i.move(a+" ");let u=r.containerPhrasing(t,{before:"# ",after:`
`,...i.current()});return/^[\t ]/.test(u)&&(u=Zj(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,r.options.closeAtx&&(u+=" "+a),c(),o(),u}i0e.peek=kwt;function i0e(t){return t.value||""}function kwt(){return"<"}a0e.peek=Nwt;function a0e(t,e,r,n){const s=z9(r),i=s==='"'?"Quote":"Apostrophe",a=r.enter("image");let o=r.enter("label");const c=r.createTracker(n);let u=c.move("![");return u+=c.move(r.safe(t.alt,{before:u,after:"]",...c.current()})),u+=c.move("]("),o(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(o=r.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(r.safe(t.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(o=r.enter("destinationRaw"),u+=c.move(r.safe(t.url,{before:u,after:t.title?" ":")",...c.current()}))),o(),t.title&&(o=r.enter(`title${i}`),u+=c.move(" "+s),u+=c.move(r.safe(t.title,{before:u,after:s,...c.current()})),u+=c.move(s),o()),u+=c.move(")"),a(),u}function Nwt(){return"!"}o0e.peek=Ewt;function o0e(t,e,r,n){const s=t.referenceType,i=r.enter("imageReference");let a=r.enter("label");const o=r.createTracker(n);let c=o.move("![");const u=r.safe(t.alt,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const d=r.stack;r.stack=[],a=r.enter("reference");const h=r.safe(r.associationId(t),{before:c,after:"]",...o.current()});return a(),r.stack=d,i(),s==="full"||!u||u!==h?c+=o.move(h+"]"):s==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function Ewt(){return"!"}l0e.peek=Awt;function l0e(t,e,r){let n=t.value||"",s="`",i=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(n);)s+="`";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^`|`$/.test(n))&&(n=" "+n+" ");++i<r.unsafe.length;){const a=r.unsafe[i],o=r.compilePattern(a);let c;if(a.atBreak)for(;c=o.exec(n);){let u=c.index;n.charCodeAt(u)===10&&n.charCodeAt(u-1)===13&&u--,n=n.slice(0,u)+" "+n.slice(c.index+1)}}return s+n+s}function Awt(){return"`"}function c0e(t,e){const r=FV(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(r===t.url||"mailto:"+r===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}u0e.peek=Cwt;function u0e(t,e,r,n){const s=z9(r),i=s==='"'?"Quote":"Apostrophe",a=r.createTracker(n);let o,c;if(c0e(t,r)){const d=r.stack;r.stack=[],o=r.enter("autolink");let h=a.move("<");return h+=a.move(r.containerPhrasing(t,{before:h,after:">",...a.current()})),h+=a.move(">"),o(),r.stack=d,h}o=r.enter("link"),c=r.enter("label");let u=a.move("[");return u+=a.move(r.containerPhrasing(t,{before:u,after:"](",...a.current()})),u+=a.move("]("),c(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(c=r.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(r.safe(t.url,{before:u,after:">",...a.current()})),u+=a.move(">")):(c=r.enter("destinationRaw"),u+=a.move(r.safe(t.url,{before:u,after:t.title?" ":")",...a.current()}))),c(),t.title&&(c=r.enter(`title${i}`),u+=a.move(" "+s),u+=a.move(r.safe(t.title,{before:u,after:s,...a.current()})),u+=a.move(s),c()),u+=a.move(")"),o(),u}function Cwt(t,e,r){return c0e(t,r)?"<":"["}d0e.peek=Twt;function d0e(t,e,r,n){const s=t.referenceType,i=r.enter("linkReference");let a=r.enter("label");const o=r.createTracker(n);let c=o.move("[");const u=r.containerPhrasing(t,{before:c,after:"]",...o.current()});c+=o.move(u+"]["),a();const d=r.stack;r.stack=[],a=r.enter("reference");const h=r.safe(r.associationId(t),{before:c,after:"]",...o.current()});return a(),r.stack=d,i(),s==="full"||!u||u!==h?c+=o.move(h+"]"):s==="shortcut"?c=c.slice(0,-1):c+=o.move("]"),c}function Twt(){return"["}function U9(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Pwt(t){const e=U9(t),r=t.options.bulletOther;if(!r)return e==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+r+"`) to be different");return r}function Owt(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function h0e(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function Iwt(t,e,r,n){const s=r.enter("list"),i=r.bulletCurrent;let a=t.ordered?Owt(r):U9(r);const o=t.ordered?a==="."?")":".":Pwt(r);let c=e&&r.bulletLastUsed?a===r.bulletLastUsed:!1;if(!t.ordered){const d=t.children?t.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(c=!0),h0e(r)===a&&d){let h=-1;for(;++h<t.children.length;){const f=t.children[h];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(a=o),r.bulletCurrent=a;const u=r.containerFlow(t,n);return r.bulletLastUsed=a,r.bulletCurrent=i,s(),u}function Rwt(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function Mwt(t,e,r,n){const s=Rwt(r);let i=r.bulletCurrent||U9(r);e&&e.type==="list"&&e.ordered&&(i=(typeof e.start=="number"&&e.start>-1?e.start:1)+(r.options.incrementListMarker===!1?0:e.children.indexOf(t))+i);let a=i.length+1;(s==="tab"||s==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(a=Math.ceil(a/4)*4);const o=r.createTracker(n);o.move(i+" ".repeat(a-i.length)),o.shift(a);const c=r.enter("listItem"),u=r.indentLines(r.containerFlow(t,o.current()),d);return c(),u;function d(h,f,p){return f?(p?"":" ".repeat(a))+h:(p?i:i+" ".repeat(a-i.length))+h}}function Dwt(t,e,r,n){const s=r.enter("paragraph"),i=r.enter("phrasing"),a=r.containerPhrasing(t,n);return i(),s(),a}const Lwt=FR(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Fwt(t,e,r,n){return(t.children.some(function(a){return Lwt(a)})?r.containerPhrasing:r.containerFlow).call(r,t,n)}function $wt(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}f0e.peek=Bwt;function f0e(t,e,r,n){const s=$wt(r),i=r.enter("strong"),a=r.createTracker(n),o=a.move(s+s);let c=a.move(r.containerPhrasing(t,{after:s,before:o,...a.current()}));const u=c.charCodeAt(0),d=hO(n.before.charCodeAt(n.before.length-1),u,s);d.inside&&(c=Zj(u)+c.slice(1));const h=c.charCodeAt(c.length-1),f=hO(n.after.charCodeAt(0),h,s);f.inside&&(c=c.slice(0,-1)+Zj(h));const p=a.move(s+s);return i(),r.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},o+c+p}function Bwt(t,e,r){return r.options.strong||"*"}function zwt(t,e,r,n){return r.safe(t.value,n)}function Uwt(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function Hwt(t,e,r){const n=(h0e(r)+(r.options.ruleSpaces?" ":"")).repeat(Uwt(r));return r.options.ruleSpaces?n.slice(0,-1):n}const p0e={blockquote:hwt,break:Ite,code:xwt,definition:bwt,emphasis:s0e,hardBreak:Ite,heading:jwt,html:i0e,image:a0e,imageReference:o0e,inlineCode:l0e,link:u0e,linkReference:d0e,list:Iwt,listItem:Mwt,paragraph:Dwt,root:Fwt,strong:f0e,text:zwt,thematicBreak:Hwt};function Vwt(){return{enter:{table:Wwt,tableData:Rte,tableHeader:Rte,tableRow:Gwt},exit:{codeText:Kwt,table:qwt,tableData:B4,tableHeader:B4,tableRow:B4}}}function Wwt(t){const e=t._align;this.enter({type:"table",align:e.map(function(r){return r==="none"?null:r}),children:[]},t),this.data.inTable=!0}function qwt(t){this.exit(t),this.data.inTable=void 0}function Gwt(t){this.enter({type:"tableRow",children:[]},t)}function B4(t){this.exit(t)}function Rte(t){this.enter({type:"tableCell",children:[]},t)}function Kwt(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,Ywt));const r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function Ywt(t,e){return e==="|"?e:t}function Xwt(t){const e=t||{},r=e.tableCellPadding,n=e.tablePipeAlign,s=e.stringLength,i=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:a,tableCell:c,tableRow:o}};function a(p,m,g,x){return u(d(p,g,x),p.align)}function o(p,m,g,x){const y=h(p,g,x),v=u([y]);return v.slice(0,v.indexOf(`
`))}function c(p,m,g,x){const y=g.enter("tableCell"),v=g.enter("phrasing"),b=g.containerPhrasing(p,{...x,before:i,after:i});return v(),y(),b}function u(p,m){return uwt(p,{align:m,alignDelimiters:n,padding:r,stringLength:s})}function d(p,m,g){const x=p.children;let y=-1;const v=[],b=m.enter("table");for(;++y<x.length;)v[y]=h(x[y],m,g);return b(),v}function h(p,m,g){const x=p.children;let y=-1;const v=[],b=m.enter("tableRow");for(;++y<x.length;)v[y]=c(x[y],p,m,g);return b(),v}function f(p,m,g){let x=p0e.inlineCode(p,m,g);return g.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function Jwt(){return{exit:{taskListCheckValueChecked:Mte,taskListCheckValueUnchecked:Mte,paragraph:Zwt}}}function Qwt(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:e1t}}}function Mte(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function Zwt(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const n=r.children[0];if(n&&n.type==="text"){const s=e.children;let i=-1,a;for(;++i<s.length;){const o=s[i];if(o.type==="paragraph"){a=o;break}}a===r&&(n.value=n.value.slice(1),n.value.length===0?r.children.shift():r.position&&n.position&&typeof n.position.start.offset=="number"&&(n.position.start.column++,n.position.start.offset++,r.position.start=Object.assign({},n.position.start)))}}this.exit(t)}function e1t(t,e,r,n){const s=t.children[0],i=typeof t.checked=="boolean"&&s&&s.type==="paragraph",a="["+(t.checked?"x":" ")+"] ",o=r.createTracker(n);i&&o.move(a);let c=p0e.listItem(t,e,r,{...n,...o.current()});return i&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(d){return d+a}}function t1t(){return[I0t(),ewt(),swt(),Vwt(),Jwt()]}function r1t(t){return{extensions:[R0t(),twt(t),iwt(),Xwt(t),Qwt()]}}const n1t={tokenize:c1t,partial:!0},m0e={tokenize:u1t,partial:!0},g0e={tokenize:d1t,partial:!0},y0e={tokenize:h1t,partial:!0},s1t={tokenize:f1t,partial:!0},x0e={name:"wwwAutolink",tokenize:o1t,previous:b0e},v0e={name:"protocolAutolink",tokenize:l1t,previous:w0e},Rh={name:"emailAutolink",tokenize:a1t,previous:S0e},$u={};function i1t(){return{text:$u}}let Em=48;for(;Em<123;)$u[Em]=Rh,Em++,Em===58?Em=65:Em===91&&(Em=97);$u[43]=Rh;$u[45]=Rh;$u[46]=Rh;$u[95]=Rh;$u[72]=[Rh,v0e];$u[104]=[Rh,v0e];$u[87]=[Rh,x0e];$u[119]=[Rh,x0e];function a1t(t,e,r){const n=this;let s,i;return a;function a(h){return!v8(h)||!S0e.call(n,n.previous)||H9(n.events)?r(h):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),o(h))}function o(h){return v8(h)?(t.consume(h),o):h===64?(t.consume(h),c):r(h)}function c(h){return h===46?t.check(s1t,d,u)(h):h===45||h===95||Li(h)?(i=!0,t.consume(h),c):d(h)}function u(h){return t.consume(h),s=!0,c}function d(h){return i&&s&&da(n.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(h)):r(h)}}function o1t(t,e,r){const n=this;return s;function s(a){return a!==87&&a!==119||!b0e.call(n,n.previous)||H9(n.events)?r(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(n1t,t.attempt(m0e,t.attempt(g0e,i),r),r)(a))}function i(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function l1t(t,e,r){const n=this;let s="",i=!1;return a;function a(h){return(h===72||h===104)&&w0e.call(n,n.previous)&&!H9(n.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),s+=String.fromCodePoint(h),t.consume(h),o):r(h)}function o(h){if(da(h)&&s.length<5)return s+=String.fromCodePoint(h),t.consume(h),o;if(h===58){const f=s.toLowerCase();if(f==="http"||f==="https")return t.consume(h),c}return r(h)}function c(h){return h===47?(t.consume(h),i?u:(i=!0,c)):r(h)}function u(h){return h===null||iP(h)||Kr(h)||Qy(h)||MR(h)?r(h):t.attempt(m0e,t.attempt(g0e,d),r)(h)}function d(h){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(h)}}function c1t(t,e,r){let n=0;return s;function s(a){return(a===87||a===119)&&n<3?(n++,t.consume(a),s):a===46&&n===3?(t.consume(a),i):r(a)}function i(a){return a===null?r(a):e(a)}}function u1t(t,e,r){let n,s,i;return a;function a(u){return u===46||u===95?t.check(y0e,c,o)(u):u===null||Kr(u)||Qy(u)||u!==45&&MR(u)?c(u):(i=!0,t.consume(u),a)}function o(u){return u===95?n=!0:(s=n,n=void 0),t.consume(u),a}function c(u){return s||n||!i?r(u):e(u)}}function d1t(t,e){let r=0,n=0;return s;function s(a){return a===40?(r++,t.consume(a),s):a===41&&n<r?i(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?t.check(y0e,e,i)(a):a===null||Kr(a)||Qy(a)?e(a):(t.consume(a),s)}function i(a){return a===41&&n++,t.consume(a),s}}function h1t(t,e,r){return n;function n(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(t.consume(o),n):o===38?(t.consume(o),i):o===93?(t.consume(o),s):o===60||o===null||Kr(o)||Qy(o)?e(o):r(o)}function s(o){return o===null||o===40||o===91||Kr(o)||Qy(o)?e(o):n(o)}function i(o){return da(o)?a(o):r(o)}function a(o){return o===59?(t.consume(o),n):da(o)?(t.consume(o),a):r(o)}}function f1t(t,e,r){return n;function n(i){return t.consume(i),s}function s(i){return Li(i)?r(i):e(i)}}function b0e(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Kr(t)}function w0e(t){return!da(t)}function S0e(t){return!(t===47||v8(t))}function v8(t){return t===43||t===45||t===46||t===95||Li(t)}function H9(t){let e=t.length,r=!1;for(;e--;){const n=t[e][1];if((n.type==="labelLink"||n.type==="labelImage")&&!n._balanced){r=!0;break}if(n._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const p1t={tokenize:S1t,partial:!0};function m1t(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:v1t,continuation:{tokenize:b1t},exit:w1t}},text:{91:{name:"gfmFootnoteCall",tokenize:x1t},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:g1t,resolveTo:y1t}}}}function g1t(t,e,r){const n=this;let s=n.events.length;const i=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let a;for(;s--;){const c=n.events[s][1];if(c.type==="labelImage"){a=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return o;function o(c){if(!a||!a._balanced)return r(c);const u=fc(n.sliceSerialize({start:a.end,end:n.now()}));return u.codePointAt(0)!==94||!i.includes(u.slice(1))?r(c):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(c),t.exit("gfmFootnoteCallLabelMarker"),e(c))}}function y1t(t,e){let r=t.length;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";const n={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const i={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},i.start),end:Object.assign({},i.end)},o=[t[r+1],t[r+2],["enter",n,e],t[r+3],t[r+4],["enter",s,e],["exit",s,e],["enter",i,e],["enter",a,e],["exit",a,e],["exit",i,e],t[t.length-2],t[t.length-1],["exit",n,e]];return t.splice(r,t.length-r+1,...o),t}function x1t(t,e,r){const n=this,s=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let i=0,a;return o;function o(h){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),c}function c(h){return h!==94?r(h):(t.enter("gfmFootnoteCallMarker"),t.consume(h),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",u)}function u(h){if(i>999||h===93&&!a||h===null||h===91||Kr(h))return r(h);if(h===93){t.exit("chunkString");const f=t.exit("gfmFootnoteCallString");return s.includes(fc(n.sliceSerialize(f)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(h)}return Kr(h)||(a=!0),i++,t.consume(h),h===92?d:u}function d(h){return h===91||h===92||h===93?(t.consume(h),i++,u):u(h)}}function v1t(t,e,r){const n=this,s=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let i,a=0,o;return c;function c(m){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(m){return m===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",d):r(m)}function d(m){if(a>999||m===93&&!o||m===null||m===91||Kr(m))return r(m);if(m===93){t.exit("chunkString");const g=t.exit("gfmFootnoteDefinitionLabelString");return i=fc(n.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),f}return Kr(m)||(o=!0),a++,t.consume(m),m===92?h:d}function h(m){return m===91||m===92||m===93?(t.consume(m),a++,d):d(m)}function f(m){return m===58?(t.enter("definitionMarker"),t.consume(m),t.exit("definitionMarker"),s.includes(i)||s.push(i),pr(t,p,"gfmFootnoteDefinitionWhitespace")):r(m)}function p(m){return e(m)}}function b1t(t,e,r){return t.check(SE,e,t.attempt(p1t,e,r))}function w1t(t){t.exit("gfmFootnoteDefinition")}function S1t(t,e,r){const n=this;return pr(t,s,"gfmFootnoteDefinitionIndent",5);function s(i){const a=n.events[n.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(i):r(i)}}function _1t(t){let r=(t||{}).singleTilde;const n={name:"strikethrough",tokenize:i,resolveAll:s};return r==null&&(r=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function s(a,o){let c=-1;for(;++c<a.length;)if(a[c][0]==="enter"&&a[c][1].type==="strikethroughSequenceTemporary"&&a[c][1]._close){let u=c;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[c][1].end.offset-a[c][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[c][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[c][1].end)},h={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[c][1].start)},f=[["enter",d,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",h,o]],p=o.parser.constructs.insideSpan.null;p&&To(f,f.length,0,DR(p,a.slice(u+1,c),o)),To(f,f.length,0,[["exit",h,o],["enter",a[c][1],o],["exit",a[c][1],o],["exit",d,o]]),To(a,u-1,c-u+3,f),c=u+f.length-2;break}}for(c=-1;++c<a.length;)a[c][1].type==="strikethroughSequenceTemporary"&&(a[c][1].type="data");return a}function i(a,o,c){const u=this.previous,d=this.events;let h=0;return f;function f(m){return u===126&&d[d.length-1][1].type!=="characterEscape"?c(m):(a.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const g=K0(u);if(m===126)return h>1?c(m):(a.consume(m),h++,p);if(h<2&&!r)return c(m);const x=a.exit("strikethroughSequenceTemporary"),y=K0(m);return x._open=!y||y===2&&!!g,x._close=!g||g===2&&!!y,o(m)}}}class j1t{constructor(){this.map=[]}add(e,r,n){k1t(this,e,r,n)}consume(e){if(this.map.sort(function(i,a){return i[0]-a[0]}),this.map.length===0)return;let r=this.map.length;const n=[];for(;r>0;)r-=1,n.push(e.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),e.length=this.map[r][0];n.push(e.slice()),e.length=0;let s=n.pop();for(;s;){for(const i of s)e.push(i);s=n.pop()}this.map.length=0}}function k1t(t,e,r,n){let s=0;if(!(r===0&&n.length===0)){for(;s<t.map.length;){if(t.map[s][0]===e){t.map[s][1]+=r,t.map[s][2].push(...n);return}s+=1}t.map.push([e,r,n])}}function N1t(t,e){let r=!1;const n=[];for(;e<t.length;){const s=t[e];if(r){if(s[0]==="enter")s[1].type==="tableContent"&&n.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const i=n.length-1;n[i]=n[i]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(r=!0);e+=1}return n}function E1t(){return{flow:{null:{name:"table",tokenize:A1t,resolveAll:C1t}}}}function A1t(t,e,r){const n=this;let s=0,i=0,a;return o;function o(M){let z=n.events.length-1;for(;z>-1;){const N=n.events[z][1].type;if(N==="lineEnding"||N==="linePrefix")z--;else break}const P=z>-1?n.events[z][1].type:null,W=P==="tableHead"||P==="tableRow"?k:c;return W===k&&n.parser.lazy[n.now().line]?r(M):W(M)}function c(M){return t.enter("tableHead"),t.enter("tableRow"),u(M)}function u(M){return M===124||(a=!0,i+=1),d(M)}function d(M){return M===null?r(M):Nt(M)?i>1?(i=0,n.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(M),t.exit("lineEnding"),p):r(M):ar(M)?pr(t,d,"whitespace")(M):(i+=1,a&&(a=!1,s+=1),M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),a=!0,d):(t.enter("data"),h(M)))}function h(M){return M===null||M===124||Kr(M)?(t.exit("data"),d(M)):(t.consume(M),M===92?f:h)}function f(M){return M===92||M===124?(t.consume(M),h):h(M)}function p(M){return n.interrupt=!1,n.parser.lazy[n.now().line]?r(M):(t.enter("tableDelimiterRow"),a=!1,ar(M)?pr(t,m,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):m(M))}function m(M){return M===45||M===58?x(M):M===124?(a=!0,t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),g):S(M)}function g(M){return ar(M)?pr(t,x,"whitespace")(M):x(M)}function x(M){return M===58?(i+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(M),t.exit("tableDelimiterMarker"),y):M===45?(i+=1,y(M)):M===null||Nt(M)?w(M):S(M)}function y(M){return M===45?(t.enter("tableDelimiterFiller"),v(M)):S(M)}function v(M){return M===45?(t.consume(M),v):M===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(M),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(M))}function b(M){return ar(M)?pr(t,w,"whitespace")(M):w(M)}function w(M){return M===124?m(M):M===null||Nt(M)?!a||s!==i?S(M):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(M)):S(M)}function S(M){return r(M)}function k(M){return t.enter("tableRow"),E(M)}function E(M){return M===124?(t.enter("tableCellDivider"),t.consume(M),t.exit("tableCellDivider"),E):M===null||Nt(M)?(t.exit("tableRow"),e(M)):ar(M)?pr(t,E,"whitespace")(M):(t.enter("data"),C(M))}function C(M){return M===null||M===124||Kr(M)?(t.exit("data"),E(M)):(t.consume(M),M===92?A:C)}function A(M){return M===92||M===124?(t.consume(M),C):C(M)}}function C1t(t,e){let r=-1,n=!0,s=0,i=[0,0,0,0],a=[0,0,0,0],o=!1,c=0,u,d,h;const f=new j1t;for(;++r<t.length;){const p=t[r],m=p[1];p[0]==="enter"?m.type==="tableHead"?(o=!1,c!==0&&(Dte(f,e,c,u,d),d=void 0,c=0),u={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(r,0,[["enter",u,e]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(n=!0,h=void 0,i=[0,0,0,0],a=[0,r+1,0,0],o&&(o=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(r,0,[["enter",d,e]])),s=m.type==="tableDelimiterRow"?2:d?3:1):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(n=!1,a[2]===0&&(i[1]!==0&&(a[0]=a[1],h=uC(f,e,i,s,void 0,h),i=[0,0,0,0]),a[2]=r)):m.type==="tableCellDivider"&&(n?n=!1:(i[1]!==0&&(a[0]=a[1],h=uC(f,e,i,s,void 0,h)),i=a,a=[i[1],r,0,0])):m.type==="tableHead"?(o=!0,c=r):m.type==="tableRow"||m.type==="tableDelimiterRow"?(c=r,i[1]!==0?(a[0]=a[1],h=uC(f,e,i,s,r,h)):a[1]!==0&&(h=uC(f,e,a,s,r,h)),s=0):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=r)}for(c!==0&&Dte(f,e,c,u,d),f.consume(e.events),r=-1;++r<e.events.length;){const p=e.events[r];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=N1t(e.events,r))}return t}function uC(t,e,r,n,s,i){const a=n===1?"tableHeader":n===2?"tableDelimiter":"tableData",o="tableContent";r[0]!==0&&(i.end=Object.assign({},rv(e.events,r[0])),t.add(r[0],0,[["exit",i,e]]));const c=rv(e.events,r[1]);if(i={type:a,start:Object.assign({},c),end:Object.assign({},c)},t.add(r[1],0,[["enter",i,e]]),r[2]!==0){const u=rv(e.events,r[2]),d=rv(e.events,r[3]),h={type:o,start:Object.assign({},u),end:Object.assign({},d)};if(t.add(r[2],0,[["enter",h,e]]),n!==2){const f=e.events[r[2]],p=e.events[r[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",r[3]>r[2]+1){const m=r[2]+1,g=r[3]-r[2]-1;t.add(m,g,[])}}t.add(r[3]+1,0,[["exit",h,e]])}return s!==void 0&&(i.end=Object.assign({},rv(e.events,s)),t.add(s,0,[["exit",i,e]]),i=void 0),i}function Dte(t,e,r,n,s){const i=[],a=rv(e.events,r);s&&(s.end=Object.assign({},a),i.push(["exit",s,e])),n.end=Object.assign({},a),i.push(["exit",n,e]),t.add(r+1,0,i)}function rv(t,e){const r=t[e],n=r[0]==="enter"?"start":"end";return r[1][n]}const T1t={name:"tasklistCheck",tokenize:O1t};function P1t(){return{text:{91:T1t}}}function O1t(t,e,r){const n=this;return s;function s(c){return n.previous!==null||!n._gfmTasklistFirstContentOfListItem?r(c):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(c),t.exit("taskListCheckMarker"),i)}function i(c){return Kr(c)?(t.enter("taskListCheckValueUnchecked"),t.consume(c),t.exit("taskListCheckValueUnchecked"),a):c===88||c===120?(t.enter("taskListCheckValueChecked"),t.consume(c),t.exit("taskListCheckValueChecked"),a):r(c)}function a(c){return c===93?(t.enter("taskListCheckMarker"),t.consume(c),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),o):r(c)}function o(c){return Nt(c)?e(c):ar(c)?t.check({tokenize:I1t},e,r)(c):r(c)}}function I1t(t,e,r){return pr(t,n,"whitespace");function n(s){return s===null?r(s):e(s)}}function R1t(t){return Yfe([i1t(),m1t(),_1t(t),E1t(),P1t()])}const M1t={};function D1t(t){const e=this,r=t||M1t,n=e.data(),s=n.micromarkExtensions||(n.micromarkExtensions=[]),i=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),a=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);s.push(R1t(r)),i.push(t1t()),a.push(r1t(r))}function L1t(t){const e=t.trim();if(/^[a-zA-Z0-9_-]{6,20}$/.test(e))return e;try{const r=new URL(e);if(r.hostname.includes("youtu.be"))return r.pathname.replace(/^\//,"")||null;if(r.hostname.includes("youtube.com")){if(r.pathname.startsWith("/embed/"))return r.pathname.replace("/embed/","")||null;if(r.pathname.startsWith("/shorts/"))return r.pathname.replace("/shorts/","")||null;const n=r.searchParams.get("v");if(n)return n}}catch{}return null}function F1t(t){const e=t.trim();if(/^\d{4,}$/.test(e))return e;try{const r=new URL(e);if(r.hostname.includes("vimeo.com")){const n=r.pathname.match(/(\d{4,})/);if(n)return n[1]}}catch{}return null}const $1t=/\{\{(youtube|vimeo):([^}]+)\}\}/g;function B1t(t){return t.replace($1t,(e,r,n)=>{if(r==="youtube"){const s=L1t(n);if(s)return`
[[EMBED:youtube:${s}]]
`}else if(r==="vimeo"){const s=F1t(n);if(s)return`
[[EMBED:vimeo:${s}]]
`}return""})}const Lte=/^\[\[EMBED:(youtube|vimeo):([a-zA-Z0-9_-]+)\]\]$/;function Fte({kind:t,id:e}){const r=t==="youtube"?`https://www.youtube-nocookie.com/embed/${e}`:`https://player.vimeo.com/video/${e}`;return l.jsx("div",{className:"my-8 relative w-full overflow-hidden rounded-xl border border-border bg-muted aspect-video",children:l.jsx("iframe",{src:r,title:t==="youtube"?"YouTube video":"Vimeo video",loading:"lazy",allow:"accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin",className:"absolute inset-0 h-full w-full border-0"})})}const z4=({content:t})=>{const e=j.useMemo(()=>B1t(t??""),[t]),[r,n]=j.useState(null);return j.useEffect(()=>{if(!r)return;const s=i=>{i.key==="Escape"&&n(null)};return window.addEventListener("keydown",s),document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",s),document.body.style.overflow=""}},[r]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`prose prose-slate dark:prose-invert max-w-none prose-headings:font-bold prose-headings:text-foreground prose-p:text-foreground/90 prose-a:text-primary prose-strong:text-foreground prose-img:rounded-xl prose-img:border prose-img:border-border
prose-code:text-primary prose-code:bg-primary/10 prose-code:px-1.5 prose-code:py-0.5 prose-code:rounded-md prose-code:font-medium prose-code:before:content-none prose-code:after:content-none
prose-pre:bg-gray-50 dark:prose-pre:bg-gray-900/60 prose-pre:border prose-pre:border-border prose-pre:rounded-xl prose-pre:p-4 prose-pre:text-foreground prose-pre:shadow-theme-xs
[&_pre_code]:!bg-transparent [&_pre_code]:!text-foreground [&_pre_code]:!p-0 [&_pre_code]:!text-sm [&_pre_code]:font-mono
prose-blockquote:not-italic prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:bg-primary/5 prose-blockquote:rounded-r-lg prose-blockquote:py-3 prose-blockquote:px-5 prose-blockquote:my-6 prose-blockquote:text-foreground prose-blockquote:font-normal [&_blockquote_p]:before:content-none [&_blockquote_p]:after:content-none`,children:l.jsx(pc,{remarkPlugins:[D1t],components:{a:({href:s,children:i,...a})=>{if(!s)return l.jsx("a",{...a,children:i});if((s.startsWith("/")||s.startsWith("#"))&&!s.startsWith("#"))return l.jsx(bt,{to:s,children:i});const c=/^https?:\/\//i.test(s);return l.jsx("a",{href:s,target:c?"_blank":void 0,rel:c?"noopener noreferrer":void 0,children:i})},img:({src:s,alt:i,title:a})=>s?l.jsxs("button",{type:"button",onClick:()=>n({src:s,alt:i??""}),className:"group relative block w-full my-6 cursor-zoom-in overflow-hidden rounded-xl border border-border","aria-label":"Bild vergrößern",children:[l.jsx("img",{src:s,alt:i??"",title:a,loading:"lazy",decoding:"async",className:"w-full h-auto transition-transform duration-300 group-hover:scale-[1.02]"}),l.jsx("span",{className:"absolute top-3 right-3 inline-flex items-center justify-center h-9 w-9 rounded-full bg-background/80 backdrop-blur border border-border opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx(zce,{className:"h-4 w-4 text-foreground"})})]}):null,p:({children:s,...i})=>{if(Array.isArray(s)&&s.length===1&&typeof s[0]=="string"){const a=s[0].match(Lte);if(a)return l.jsx(Fte,{kind:a[1],id:a[2]})}if(typeof s=="string"){const a=s.match(Lte);if(a)return l.jsx(Fte,{kind:a[1],id:a[2]})}return l.jsx("p",{...i,children:s})}},children:e})}),r&&l.jsxs("div",{role:"dialog","aria-modal":"true",onClick:()=>n(null),className:"fixed inset-0 z-[100] bg-black/85 backdrop-blur-sm flex items-center justify-center p-4 md:p-8 animate-fade-in cursor-zoom-out",children:[l.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),n(null)},className:"absolute top-4 right-4 inline-flex items-center justify-center h-10 w-10 rounded-full bg-white/10 hover:bg-white/20 text-white border border-white/20 transition","aria-label":"Schließen",children:l.jsx(Is,{className:"h-5 w-5"})}),l.jsx("img",{src:r.src,alt:r.alt,onClick:s=>s.stopPropagation(),className:"max-h-[90vh] max-w-[95vw] w-auto h-auto rounded-lg shadow-2xl object-contain"})]})]})};var zM="Collapsible",[z1t,_0e]=gs(zM),[U1t,V9]=z1t(zM),j0e=j.forwardRef((t,e)=>{const{__scopeCollapsible:r,open:n,defaultOpen:s,disabled:i,onOpenChange:a,...o}=t,[c,u]=_i({prop:n,defaultProp:s??!1,onChange:a,caller:zM});return l.jsx(U1t,{scope:r,disabled:i,contentId:Ka(),open:c,onOpenToggle:j.useCallback(()=>u(d=>!d),[u]),children:l.jsx(ot.div,{"data-state":K9(c),"data-disabled":i?"":void 0,...o,ref:e})})});j0e.displayName=zM;var k0e="CollapsibleTrigger",W9=j.forwardRef((t,e)=>{const{__scopeCollapsible:r,...n}=t,s=V9(k0e,r);return l.jsx(ot.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":K9(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...n,ref:e,onClick:Ke(t.onClick,s.onOpenToggle)})});W9.displayName=k0e;var q9="CollapsibleContent",G9=j.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=V9(q9,t.__scopeCollapsible);return l.jsx(Os,{present:r||s.open,children:({present:i})=>l.jsx(H1t,{...n,ref:e,present:i})})});G9.displayName=q9;var H1t=j.forwardRef((t,e)=>{const{__scopeCollapsible:r,present:n,children:s,...i}=t,a=V9(q9,r),[o,c]=j.useState(n),u=j.useRef(null),d=It(e,u),h=j.useRef(0),f=h.current,p=j.useRef(0),m=p.current,g=a.open||o,x=j.useRef(g),y=j.useRef(void 0);return j.useEffect(()=>{const v=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(v)},[]),Wn(()=>{const v=u.current;if(v){y.current=y.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const b=v.getBoundingClientRect();h.current=b.height,p.current=b.width,x.current||(v.style.transitionDuration=y.current.transitionDuration,v.style.animationName=y.current.animationName),c(n)}},[a.open,n]),l.jsx(ot.div,{"data-state":K9(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!g,...i,ref:d,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":m?`${m}px`:void 0,...t.style},children:g&&s})});function K9(t){return t?"open":"closed"}var N0e=j0e,V1t=W9,W1t=G9,Nc="Accordion",q1t=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Y9,G1t,K1t]=rE(Nc),[UM,k5t]=gs(Nc,[K1t,_0e]),X9=_0e(),E0e=pe.forwardRef((t,e)=>{const{type:r,...n}=t,s=n,i=n;return l.jsx(Y9.Provider,{scope:t.__scopeAccordion,children:r==="multiple"?l.jsx(Q1t,{...i,ref:e}):l.jsx(J1t,{...s,ref:e})})});E0e.displayName=Nc;var[A0e,Y1t]=UM(Nc),[C0e,X1t]=UM(Nc,{collapsible:!1}),J1t=pe.forwardRef((t,e)=>{const{value:r,defaultValue:n,onValueChange:s=()=>{},collapsible:i=!1,...a}=t,[o,c]=_i({prop:r,defaultProp:n??"",onChange:s,caller:Nc});return l.jsx(A0e,{scope:t.__scopeAccordion,value:pe.useMemo(()=>o?[o]:[],[o]),onItemOpen:c,onItemClose:pe.useCallback(()=>i&&c(""),[i,c]),children:l.jsx(C0e,{scope:t.__scopeAccordion,collapsible:i,children:l.jsx(T0e,{...a,ref:e})})})}),Q1t=pe.forwardRef((t,e)=>{const{value:r,defaultValue:n,onValueChange:s=()=>{},...i}=t,[a,o]=_i({prop:r,defaultProp:n??[],onChange:s,caller:Nc}),c=pe.useCallback(d=>o((h=[])=>[...h,d]),[o]),u=pe.useCallback(d=>o((h=[])=>h.filter(f=>f!==d)),[o]);return l.jsx(A0e,{scope:t.__scopeAccordion,value:a,onItemOpen:c,onItemClose:u,children:l.jsx(C0e,{scope:t.__scopeAccordion,collapsible:!0,children:l.jsx(T0e,{...i,ref:e})})})}),[Z1t,HM]=UM(Nc),T0e=pe.forwardRef((t,e)=>{const{__scopeAccordion:r,disabled:n,dir:s,orientation:i="vertical",...a}=t,o=pe.useRef(null),c=It(o,e),u=G1t(r),h=xx(s)==="ltr",f=Ke(t.onKeyDown,p=>{var C;if(!q1t.includes(p.key))return;const m=p.target,g=u().filter(A=>{var M;return!((M=A.ref.current)!=null&&M.disabled)}),x=g.findIndex(A=>A.ref.current===m),y=g.length;if(x===-1)return;p.preventDefault();let v=x;const b=0,w=y-1,S=()=>{v=x+1,v>w&&(v=b)},k=()=>{v=x-1,v<b&&(v=w)};switch(p.key){case"Home":v=b;break;case"End":v=w;break;case"ArrowRight":i==="horizontal"&&(h?S():k());break;case"ArrowDown":i==="vertical"&&S();break;case"ArrowLeft":i==="horizontal"&&(h?k():S());break;case"ArrowUp":i==="vertical"&&k();break}const E=v%y;(C=g[E].ref.current)==null||C.focus()});return l.jsx(Z1t,{scope:r,disabled:n,direction:s,orientation:i,children:l.jsx(Y9.Slot,{scope:r,children:l.jsx(ot.div,{...a,"data-orientation":i,ref:c,onKeyDown:n?void 0:f})})})}),fO="AccordionItem",[eSt,J9]=UM(fO),P0e=pe.forwardRef((t,e)=>{const{__scopeAccordion:r,value:n,...s}=t,i=HM(fO,r),a=Y1t(fO,r),o=X9(r),c=Ka(),u=n&&a.value.includes(n)||!1,d=i.disabled||t.disabled;return l.jsx(eSt,{scope:r,open:u,disabled:d,triggerId:c,children:l.jsx(N0e,{"data-orientation":i.orientation,"data-state":L0e(u),...o,...s,ref:e,disabled:d,open:u,onOpenChange:h=>{h?a.onItemOpen(n):a.onItemClose(n)}})})});P0e.displayName=fO;var O0e="AccordionHeader",I0e=pe.forwardRef((t,e)=>{const{__scopeAccordion:r,...n}=t,s=HM(Nc,r),i=J9(O0e,r);return l.jsx(ot.h3,{"data-orientation":s.orientation,"data-state":L0e(i.open),"data-disabled":i.disabled?"":void 0,...n,ref:e})});I0e.displayName=O0e;var b8="AccordionTrigger",R0e=pe.forwardRef((t,e)=>{const{__scopeAccordion:r,...n}=t,s=HM(Nc,r),i=J9(b8,r),a=X1t(b8,r),o=X9(r);return l.jsx(Y9.ItemSlot,{scope:r,children:l.jsx(V1t,{"aria-disabled":i.open&&!a.collapsible||void 0,"data-orientation":s.orientation,id:i.triggerId,...o,...n,ref:e})})});R0e.displayName=b8;var M0e="AccordionContent",D0e=pe.forwardRef((t,e)=>{const{__scopeAccordion:r,...n}=t,s=HM(Nc,r),i=J9(M0e,r),a=X9(r);return l.jsx(W1t,{role:"region","aria-labelledby":i.triggerId,"data-orientation":s.orientation,...a,...n,ref:e,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})});D0e.displayName=M0e;function L0e(t){return t?"open":"closed"}var tSt=E0e,rSt=P0e,nSt=I0e,F0e=R0e,$0e=D0e;const Q9=tSt,VM=j.forwardRef(({className:t,...e},r)=>l.jsx(rSt,{ref:r,className:Le("border-b",t),...e}));VM.displayName="AccordionItem";const WM=j.forwardRef(({className:t,children:e,...r},n)=>l.jsx(nSt,{className:"flex",children:l.jsxs(F0e,{ref:n,className:Le("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",t),...r,children:[e,l.jsx(Eh,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));WM.displayName=F0e.displayName;const qM=j.forwardRef(({className:t,children:e,...r},n)=>l.jsx($0e,{ref:n,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:l.jsx("div",{className:Le("pb-4 pt-0",t),children:e})}));qM.displayName=$0e.displayName;const sSt=({faqs:t})=>t.length?l.jsxs("section",{className:"mt-16 border-t border-border pt-12",children:[l.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-foreground mb-6",children:"Frequently asked questions"}),l.jsx(Q9,{type:"single",collapsible:!0,className:"w-full",children:t.map(e=>l.jsxs(VM,{value:e.id,children:[l.jsx(WM,{className:"text-left text-base font-semibold",children:e.question}),l.jsx(qM,{className:"text-muted-foreground leading-relaxed whitespace-pre-line",children:e.answer})]},e.id))})]}):null,iSt=({items:t})=>l.jsx("nav",{"aria-label":"Breadcrumb",className:"text-sm text-muted-foreground",children:l.jsx("ol",{className:"flex flex-wrap items-center gap-1.5",children:t.map((e,r)=>{const n=r===t.length-1;return l.jsxs("li",{className:"flex items-center gap-1.5",children:[e.href&&!n?l.jsx(bt,{to:e.href,className:"hover:text-primary transition-colors",children:e.label}):l.jsx("span",{className:n?"text-foreground font-medium":"",children:e.label}),!n&&l.jsx(eR,{className:"h-3.5 w-3.5"})]},r)})})});function aSt(t,e){return{"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:t.map((r,n)=>({"@type":"ListItem",position:n+1,name:r.label,...r.href?{item:`${e}${r.href}`}:{}}))}}const U4="https://academly.ai",oSt=()=>{var m,g;const{slug:t}=pMe(),{data:e,isLoading:r,isError:n}=k0t(t),s=!r&&(!e||!e.article);if(Zbe(!r,s?404:200),r)return l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Xs,{}),l.jsxs("div",{className:"max-w-[760px] mx-auto px-6 pt-32 pb-24 animate-pulse",children:[l.jsx("div",{className:"h-4 w-32 bg-muted rounded mb-6"}),l.jsx("div",{className:"h-10 w-3/4 bg-muted rounded mb-4"}),l.jsx("div",{className:"h-4 w-full bg-muted rounded mb-2"}),l.jsx("div",{className:"h-4 w-5/6 bg-muted rounded"})]}),l.jsx(Bi,{})]});if(s||n)return l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:"Article not found | Academly",description:"The article you are looking for does not exist.",canonical:`${U4}/blog/${t??""}`,noIndex:!0}),l.jsx(Xs,{}),l.jsxs("main",{className:"max-w-[760px] mx-auto px-6 pt-32 pb-24 text-center",children:[l.jsx("h1",{className:"text-3xl font-bold text-foreground mb-4",children:"Article not found"}),l.jsx("p",{className:"text-muted-foreground mb-8",children:"This article doesn't exist or hasn't been published yet."}),l.jsx(bt,{to:"/blog",className:"inline-flex items-center rounded-full bg-primary text-primary-foreground px-5 py-2.5 font-semibold hover:opacity-90",children:"Back to blog"})]}),l.jsx(Bi,{})]});const{article:i,faqs:a,related:o}=e,c=i.canonical_url||`${U4}/blog/${i.slug}`,u=i.seo_title||`${i.title} | Academly`,d=i.seo_description||i.excerpt||"",h=i.published_at||i.created_at,f=[{label:"Home",href:"/"},{label:"Blog",href:"/blog"},{label:i.title}],p=[{"@context":"https://schema.org","@type":"Article",headline:i.title,description:d,datePublished:h,dateModified:i.updated_at,author:{"@type":"Person",name:i.author_name},...i.cover_image?{image:[i.cover_image]}:{},mainEntityOfPage:{"@type":"WebPage","@id":c},...(m=i.tags)!=null&&m.length?{keywords:i.tags.join(", ")}:{},...i.category?{articleSection:i.category}:{},inLanguage:i.language},aSt(f,U4)];return a.length&&p.push({"@context":"https://schema.org","@type":"FAQPage",mainEntity:a.map(x=>({"@type":"Question",name:x.question,acceptedAnswer:{"@type":"Answer",text:x.answer}}))}),i.schema_json&&p.push(i.schema_json),l.jsxs("div",{className:"min-h-screen bg-background",children:[l.jsx(Ui,{title:u,description:d,canonical:c,ogImage:i.og_image||i.cover_image||void 0,jsonLd:p}),l.jsx(Zle,{children:l.jsx("html",{lang:i.language})}),l.jsx(Xs,{}),l.jsxs("main",{children:[l.jsx("article",{className:"pt-28 pb-16",children:l.jsxs("div",{className:"max-w-[760px] mx-auto px-6",children:[l.jsx(iSt,{items:f}),l.jsxs("header",{className:"mt-6 mb-10",children:[i.category&&l.jsx("span",{className:"inline-flex items-center rounded-full bg-primary/10 text-primary text-xs font-semibold uppercase tracking-wider px-3 py-1 mb-4",children:i.category}),l.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground leading-tight mb-4",children:i.title}),l.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-x-5 gap-y-2 text-sm text-muted-foreground",children:[l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx($w,{className:"h-4 w-4"}),i.author_name]}),l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx(S$,{className:"h-4 w-4"}),new Date(h).toLocaleDateString(i.language==="de"?"de-DE":"en-US",{year:"numeric",month:"long",day:"numeric"})]}),i.reading_time&&l.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[l.jsx(gx,{className:"h-4 w-4"}),i.reading_time," min read"]})]})]}),i.cover_image&&l.jsx("img",{src:i.cover_image,alt:i.cover_image_alt||i.title,className:"w-full rounded-2xl mb-10 border border-border",loading:"eager"}),(()=>{const x=i.content_md??"";if(!!!i.cta_headline)return l.jsx(z4,{content:x});const v=x.split(`
`);let b=!1,w=0,S=-1;for(let C=0;C<v.length;C++){const A=v[C];if(/^\s*```/.test(A)&&(b=!b),!b&&/^##\s+/.test(A)&&(w+=1,w===2)){S=C;break}}const k=S===-1?x:v.slice(0,S).join(`
`),E=S===-1?"":v.slice(S).join(`
`);return l.jsxs(l.Fragment,{children:[l.jsx(z4,{content:k}),l.jsxs("aside",{className:"my-10 rounded-2xl bg-primary text-primary-foreground p-8 text-center shadow-theme-md not-prose",children:[l.jsx("h3",{className:"text-2xl font-bold text-white mb-3",children:i.cta_headline}),i.cta_text&&l.jsx("p",{className:"text-base text-white/90 mx-auto max-w-[500px] mb-6 leading-relaxed",children:i.cta_text}),l.jsx(bt,{to:"/login?mode=signup",className:"inline-flex items-center justify-center rounded-full bg-white text-primary font-semibold px-6 py-3 hover:bg-white/90 transition",children:"Try Academly Free"})]}),E&&l.jsx(z4,{content:E})]})})(),!!((g=i.tags)!=null&&g.length)&&l.jsx("div",{className:"mt-12 flex flex-wrap gap-2",children:i.tags.map(x=>l.jsxs("span",{className:"inline-flex rounded-full bg-muted text-muted-foreground text-xs px-3 py-1",children:["#",x]},x))}),l.jsx(sSt,{faqs:a})]})}),!!o.length&&l.jsx("section",{className:"pb-24",children:l.jsxs("div",{className:"max-w-5xl mx-auto px-6",children:[l.jsx("h2",{className:"text-2xl font-bold text-foreground mb-6",children:"Related articles"}),l.jsx("div",{className:"grid md:grid-cols-3 gap-6",children:o.map(x=>l.jsx(Qbe,{article:x},x.id))})]})})]}),l.jsx(Bi,{})]})},Ec=j.forwardRef(({className:t,...e},r)=>l.jsx("div",{className:"relative w-full overflow-auto",children:l.jsx("table",{ref:r,className:Le("w-full caption-bottom text-sm",t),...e})}));Ec.displayName="Table";const Ac=j.forwardRef(({className:t,...e},r)=>l.jsx("thead",{ref:r,className:Le("[&_tr]:border-b",t),...e}));Ac.displayName="TableHeader";const Cc=j.forwardRef(({className:t,...e},r)=>l.jsx("tbody",{ref:r,className:Le("[&_tr:last-child]:border-0",t),...e}));Cc.displayName="TableBody";const lSt=j.forwardRef(({className:t,...e},r)=>l.jsx("tfoot",{ref:r,className:Le("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...e}));lSt.displayName="TableFooter";const Zn=j.forwardRef(({className:t,...e},r)=>l.jsx("tr",{ref:r,className:Le("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));Zn.displayName="TableRow";const Et=j.forwardRef(({className:t,...e},r)=>l.jsx("th",{ref:r,className:Le("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));Et.displayName="TableHead";const At=j.forwardRef(({className:t,...e},r)=>l.jsx("td",{ref:r,className:Le("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));At.displayName="TableCell";const cSt=j.forwardRef(({className:t,...e},r)=>l.jsx("caption",{ref:r,className:Le("mt-4 text-sm text-muted-foreground",t),...e}));cSt.displayName="TableCaption";var B0e="AlertDialog",[uSt,N5t]=gs(B0e,[Uhe]),Mh=Uhe(),z0e=t=>{const{__scopeAlertDialog:e,...r}=t,n=Mh(e);return l.jsx(SV,{...n,...r,modal:!0})};z0e.displayName=B0e;var dSt="AlertDialogTrigger",U0e=j.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Mh(r);return l.jsx(_V,{...s,...n,ref:e})});U0e.displayName=dSt;var hSt="AlertDialogPortal",H0e=t=>{const{__scopeAlertDialog:e,...r}=t,n=Mh(e);return l.jsx(jV,{...n,...r})};H0e.displayName=hSt;var fSt="AlertDialogOverlay",V0e=j.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Mh(r);return l.jsx(gE,{...s,...n,ref:e})});V0e.displayName=fSt;var ub="AlertDialogContent",[pSt,mSt]=uSt(ub),gSt=tce("AlertDialogContent"),W0e=j.forwardRef((t,e)=>{const{__scopeAlertDialog:r,children:n,...s}=t,i=Mh(r),a=j.useRef(null),o=It(e,a),c=j.useRef(null);return l.jsx(W3e,{contentName:ub,titleName:q0e,docsSlug:"alert-dialog",children:l.jsx(pSt,{scope:r,cancelRef:c,children:l.jsxs(yE,{role:"alertdialog",...i,...s,ref:o,onOpenAutoFocus:Ke(s.onOpenAutoFocus,u=>{var d;u.preventDefault(),(d=c.current)==null||d.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[l.jsx(gSt,{children:n}),l.jsx(xSt,{contentRef:a})]})})})});W0e.displayName=ub;var q0e="AlertDialogTitle",G0e=j.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Mh(r);return l.jsx(xE,{...s,...n,ref:e})});G0e.displayName=q0e;var K0e="AlertDialogDescription",Y0e=j.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Mh(r);return l.jsx(vE,{...s,...n,ref:e})});Y0e.displayName=K0e;var ySt="AlertDialogAction",X0e=j.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Mh(r);return l.jsx(TR,{...s,...n,ref:e})});X0e.displayName=ySt;var J0e="AlertDialogCancel",Q0e=j.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:s}=mSt(J0e,r),i=Mh(r),a=It(e,s);return l.jsx(TR,{...i,...n,ref:a})});Q0e.displayName=J0e;var xSt=({contentRef:t})=>{const e=`\`${ub}\` requires a description for the component to be accessible for screen reader users.
You can add a description to the \`${ub}\` by passing a \`${K0e}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${ub}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return j.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},vSt=z0e,bSt=U0e,wSt=H0e,Z0e=V0e,ewe=W0e,twe=X0e,rwe=Q0e,nwe=G0e,swe=Y0e;const va=vSt,El=bSt,SSt=wSt,iwe=j.forwardRef(({className:t,...e},r)=>l.jsx(Z0e,{className:Le("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));iwe.displayName=Z0e.displayName;const Hi=j.forwardRef(({className:t,...e},r)=>l.jsxs(SSt,{children:[l.jsx(iwe,{}),l.jsx(ewe,{ref:r,className:Le("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...e})]}));Hi.displayName=ewe.displayName;const Vi=({className:t,...e})=>l.jsx("div",{className:Le("flex flex-col space-y-2 text-center sm:text-left",t),...e});Vi.displayName="AlertDialogHeader";const Wi=({className:t,...e})=>l.jsx("div",{className:Le("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});Wi.displayName="AlertDialogFooter";const qi=j.forwardRef(({className:t,...e},r)=>l.jsx(nwe,{ref:r,className:Le("text-lg font-semibold",t),...e}));qi.displayName=nwe.displayName;const Gi=j.forwardRef(({className:t,...e},r)=>l.jsx(swe,{ref:r,className:Le("text-sm text-muted-foreground",t),...e}));Gi.displayName=swe.displayName;const bi=j.forwardRef(({className:t,...e},r)=>l.jsx(twe,{ref:r,className:Le(iV(),t),...e}));bi.displayName=twe.displayName;const ji=j.forwardRef(({className:t,...e},r)=>l.jsx(rwe,{ref:r,className:Le(iV({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));ji.displayName=rwe.displayName;const oa=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),w8=[.001,0,0,.001,0,0],H4=1.35,bo={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},pf={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},awe="pdfjs_internal_editor_",Lt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101,COMMENT:102},dr={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},_St={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ei={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},_T={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},ss={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},nv={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},GM={ERRORS:0,WARNINGS:1,INFOS:5},pO={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},dC={moveTo:0,lineTo:1,curveTo:2,closePath:3},jSt={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let KM=GM.WARNINGS;function kSt(t){Number.isInteger(t)&&(KM=t)}function NSt(){return KM}function YM(t){KM>=GM.INFOS&&console.log(`Info: ${t}`)}function Ft(t){KM>=GM.WARNINGS&&console.log(`Warning: ${t}`)}function $r(t){throw new Error(t)}function us(t,e){t||$r(e)}function ESt(t){switch(t==null?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function owe(t,e=null,r=null){if(!t)return null;if(r&&typeof t=="string"){if(r.addDefaultProtocol&&t.startsWith("www.")){const s=t.match(/\./g);(s==null?void 0:s.length)>=2&&(t=`http://${t}`)}if(r.tryConvertEncoding)try{t=OSt(t)}catch{}}const n=e?URL.parse(t,e):URL.parse(t);return ESt(n)?n:null}function lwe(t,e,r=!1){const n=URL.parse(t);return n?(n.hash=e,n.href):r&&owe(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function tr(t,e,r,n=!1){return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!0,writable:!1}),r}const Ex=function(){function e(r,n){this.message=r,this.name=n}return e.prototype=new Error,e.constructor=e,e}();class $te extends Ex{constructor(e,r){super(e,"PasswordException"),this.code=r}}class V4 extends Ex{constructor(e,r){super(e,"UnknownErrorException"),this.details=r}}class S8 extends Ex{constructor(e){super(e,"InvalidPDFException")}}class mO extends Ex{constructor(e,r,n){super(e,"ResponseException"),this.status=r,this.missing=n}}class ASt extends Ex{constructor(e){super(e,"FormatError")}}class qp extends Ex{constructor(e){super(e,"AbortException")}}function cwe(t){(typeof t!="object"||(t==null?void 0:t.length)===void 0)&&$r("Invalid argument for bytesToString");const e=t.length,r=8192;if(e<r)return String.fromCharCode.apply(null,t);const n=[];for(let s=0;s<e;s+=r){const i=Math.min(s+r,e),a=t.subarray(s,i);n.push(String.fromCharCode.apply(null,a))}return n.join("")}function DE(t){typeof t!="string"&&$r("Invalid argument for stringToBytes");const e=t.length,r=new Uint8Array(e);for(let n=0;n<e;++n)r[n]=t.charCodeAt(n)&255;return r}function CSt(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255)}function TSt(){const t=new Uint8Array(4);return t[0]=1,new Uint32Array(t.buffer,0,1)[0]===1}function PSt(){try{return new Function(""),!0}catch{return!1}}class wi{static get isLittleEndian(){return tr(this,"isLittleEndian",TSt())}static get isEvalSupported(){return tr(this,"isEvalSupported",PSt())}static get isOffscreenCanvasSupported(){return tr(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return tr(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:e,userAgent:r}=navigator;return tr(this,"platform",{isAndroid:r.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:r.includes("Firefox")})}static get isCSSRoundSupported(){var e,r;return tr(this,"isCSSRoundSupported",(r=(e=globalThis.CSS)==null?void 0:e.supports)==null?void 0:r.call(e,"width: round(1.5px, 1px)"))}}const W4=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));var ah,jT,_8;class jt{static makeHexColor(e,r,n){return`#${W4[e]}${W4[r]}${W4[n]}`}static scaleMinMax(e,r){let n;e[0]?(e[0]<0&&(n=r[0],r[0]=r[2],r[2]=n),r[0]*=e[0],r[2]*=e[0],e[3]<0&&(n=r[1],r[1]=r[3],r[3]=n),r[1]*=e[3],r[3]*=e[3]):(n=r[0],r[0]=r[1],r[1]=n,n=r[2],r[2]=r[3],r[3]=n,e[1]<0&&(n=r[1],r[1]=r[3],r[3]=n),r[1]*=e[1],r[3]*=e[1],e[2]<0&&(n=r[0],r[0]=r[2],r[2]=n),r[0]*=e[2],r[2]*=e[2]),r[0]+=e[4],r[1]+=e[5],r[2]+=e[4],r[3]+=e[5]}static transform(e,r){return[e[0]*r[0]+e[2]*r[1],e[1]*r[0]+e[3]*r[1],e[0]*r[2]+e[2]*r[3],e[1]*r[2]+e[3]*r[3],e[0]*r[4]+e[2]*r[5]+e[4],e[1]*r[4]+e[3]*r[5]+e[5]]}static applyTransform(e,r,n=0){const s=e[n],i=e[n+1];e[n]=s*r[0]+i*r[2]+r[4],e[n+1]=s*r[1]+i*r[3]+r[5]}static applyTransformToBezier(e,r,n=0){const s=r[0],i=r[1],a=r[2],o=r[3],c=r[4],u=r[5];for(let d=0;d<6;d+=2){const h=e[n+d],f=e[n+d+1];e[n+d]=h*s+f*a+c,e[n+d+1]=h*i+f*o+u}}static applyInverseTransform(e,r){const n=e[0],s=e[1],i=r[0]*r[3]-r[1]*r[2];e[0]=(n*r[3]-s*r[2]+r[2]*r[5]-r[4]*r[3])/i,e[1]=(-n*r[1]+s*r[0]+r[4]*r[1]-r[5]*r[0])/i}static axialAlignedBoundingBox(e,r,n){const s=r[0],i=r[1],a=r[2],o=r[3],c=r[4],u=r[5],d=e[0],h=e[1],f=e[2],p=e[3];let m=s*d+c,g=m,x=s*f+c,y=x,v=o*h+u,b=v,w=o*p+u,S=w;if(i!==0||a!==0){const k=i*d,E=i*f,C=a*h,A=a*p;m+=C,y+=C,x+=A,g+=A,v+=k,S+=k,w+=E,b+=E}n[0]=Math.min(n[0],m,x,g,y),n[1]=Math.min(n[1],v,w,b,S),n[2]=Math.max(n[2],m,x,g,y),n[3]=Math.max(n[3],v,w,b,S)}static inverseTransform(e){const r=e[0]*e[3]-e[1]*e[2];return[e[3]/r,-e[1]/r,-e[2]/r,e[0]/r,(e[2]*e[5]-e[4]*e[3])/r,(e[4]*e[1]-e[5]*e[0])/r]}static singularValueDecompose2dScale(e,r){const n=e[0],s=e[1],i=e[2],a=e[3],o=n**2+s**2,c=n*i+s*a,u=i**2+a**2,d=(o+u)/2,h=Math.sqrt(d**2-(o*u-c**2));r[0]=Math.sqrt(d+h||1),r[1]=Math.sqrt(d-h||1)}static normalizeRect(e){const r=e.slice(0);return e[0]>e[2]&&(r[0]=e[2],r[2]=e[0]),e[1]>e[3]&&(r[1]=e[3],r[3]=e[1]),r}static intersect(e,r){const n=Math.max(Math.min(e[0],e[2]),Math.min(r[0],r[2])),s=Math.min(Math.max(e[0],e[2]),Math.max(r[0],r[2]));if(n>s)return null;const i=Math.max(Math.min(e[1],e[3]),Math.min(r[1],r[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(r[1],r[3]));return i>a?null:[n,i,s,a]}static pointBoundingBox(e,r,n){n[0]=Math.min(n[0],e),n[1]=Math.min(n[1],r),n[2]=Math.max(n[2],e),n[3]=Math.max(n[3],r)}static rectBoundingBox(e,r,n,s,i){i[0]=Math.min(i[0],e,n),i[1]=Math.min(i[1],r,s),i[2]=Math.max(i[2],e,n),i[3]=Math.max(i[3],r,s)}static bezierBoundingBox(e,r,n,s,i,a,o,c,u){u[0]=Math.min(u[0],e,o),u[1]=Math.min(u[1],r,c),u[2]=Math.max(u[2],e,o),u[3]=Math.max(u[3],r,c),ce(this,ah,_8).call(this,e,n,i,o,r,s,a,c,3*(-e+3*(n-i)+o),6*(e-2*n+i),3*(n-e),u),ce(this,ah,_8).call(this,e,n,i,o,r,s,a,c,3*(-r+3*(s-a)+c),6*(r-2*s+a),3*(s-r),u)}}ah=new WeakSet,jT=function(e,r,n,s,i,a,o,c,u,d){if(u<=0||u>=1)return;const h=1-u,f=u*u,p=f*u,m=h*(h*(h*e+3*u*r)+3*f*n)+p*s,g=h*(h*(h*i+3*u*a)+3*f*o)+p*c;d[0]=Math.min(d[0],m),d[1]=Math.min(d[1],g),d[2]=Math.max(d[2],m),d[3]=Math.max(d[3],g)},_8=function(e,r,n,s,i,a,o,c,u,d,h,f){if(Math.abs(u)<1e-12){Math.abs(d)>=1e-12&&ce(this,ah,jT).call(this,e,r,n,s,i,a,o,c,-h/d,f);return}const p=d**2-4*h*u;if(p<0)return;const m=Math.sqrt(p),g=2*u;ce(this,ah,jT).call(this,e,r,n,s,i,a,o,c,(-d+m)/g,f),ce(this,ah,jT).call(this,e,r,n,s,i,a,o,c,(-d-m)/g,f)},le(jt,ah);function OSt(t){return decodeURIComponent(escape(t))}let q4=null,Bte=null;function ISt(t){return q4||(q4=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Bte=new Map([["ſt","ſt"]])),t.replaceAll(q4,(e,r,n)=>r?r.normalize("NFKC"):Bte.get(n))}function uwe(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),cwe(t)}const Z9="pdfjs_internal_id_";function RSt(t,e,r){if(!Array.isArray(r)||r.length<2)return!1;const[n,s,...i]=r;if(!t(n)&&!Number.isInteger(n)||!e(s))return!1;const a=i.length;let o=!0;switch(s.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const c of i)if(!(typeof c=="number"||o&&c===null))return!1;return!0}function la(t,e,r){return Math.min(Math.max(t,e),r)}function dwe(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(cwe(t))}function MSt(t){return Uint8Array.fromBase64?Uint8Array.fromBase64(t):DE(atob(t))}typeof Promise.try!="function"&&(Promise.try=function(t,...e){return new Promise(r=>{r(t(...e))})});typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(t){return t.reduce((e,r)=>e+r,0)});const Qu="http://www.w3.org/2000/svg",Gm=class Gm{};Ve(Gm,"CSS",96),Ve(Gm,"PDF",72),Ve(Gm,"PDF_TO_CSS_UNITS",Gm.CSS/Gm.PDF);let Gp=Gm;async function LE(t,e="text"){if(gS(t,document.baseURI)){const r=await fetch(t);if(!r.ok)throw new Error(r.statusText);switch(e){case"arraybuffer":return r.arrayBuffer();case"blob":return r.blob();case"json":return r.json()}return r.text()}return new Promise((r,n)=>{const s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType=e,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE){if(s.status===200||s.status===0){switch(e){case"arraybuffer":case"blob":case"json":r(s.response);return}r(s.responseText);return}n(new Error(s.statusText))}},s.send(null)})}class FE{constructor({viewBox:e,userUnit:r,scale:n,rotation:s,offsetX:i=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=r,this.scale=n,this.rotation=s,this.offsetX=i,this.offsetY=a,n*=r;const c=(e[2]+e[0])/2,u=(e[3]+e[1])/2;let d,h,f,p;switch(s%=360,s<0&&(s+=360),s){case 180:d=-1,h=0,f=0,p=1;break;case 90:d=0,h=1,f=1,p=0;break;case 270:d=0,h=-1,f=-1,p=0;break;case 0:d=1,h=0,f=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(f=-f,p=-p);let m,g,x,y;d===0?(m=Math.abs(u-e[1])*n+i,g=Math.abs(c-e[0])*n+a,x=(e[3]-e[1])*n,y=(e[2]-e[0])*n):(m=Math.abs(c-e[0])*n+i,g=Math.abs(u-e[1])*n+a,x=(e[2]-e[0])*n,y=(e[3]-e[1])*n),this.transform=[d*n,h*n,f*n,p*n,m-d*n*c-f*n*u,g-h*n*c-p*n*u],this.width=x,this.height=y}get rawDims(){const e=this.viewBox;return tr(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:r=this.rotation,offsetX:n=this.offsetX,offsetY:s=this.offsetY,dontFlip:i=!1}={}){return new FE({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:r,offsetX:n,offsetY:s,dontFlip:i})}convertToViewportPoint(e,r){const n=[e,r];return jt.applyTransform(n,this.transform),n}convertToViewportRectangle(e){const r=[e[0],e[1]];jt.applyTransform(r,this.transform);const n=[e[2],e[3]];return jt.applyTransform(n,this.transform),[r[0],r[1],n[0],n[1]]}convertToPdfPoint(e,r){const n=[e,r];return jt.applyInverseTransform(n,this.transform),n}}class e7 extends Ex{constructor(e,r=0){super(e,"RenderingCancelledException"),this.extraDelay=r}}function XM(t){const e=t.length;let r=0;for(;r<e&&t[r].trim()==="";)r++;return t.substring(r,r+5).toLowerCase()==="data:"}function t7(t){return typeof t=="string"&&/\.pdf$/i.test(t)}function DSt(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function LSt(t,e="document.pdf"){if(typeof t!="string")return e;if(XM(t))return Ft('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const n=(o=>{try{return new URL(o)}catch{try{return new URL(decodeURIComponent(o))}catch{try{return new URL(o,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{return null}}}}})(t);if(!n)return e;const s=o=>{try{let c=decodeURIComponent(o);return c.includes("/")?(c=c.split("/").at(-1),c.test(/^\.pdf$/i)?c:o):c}catch{return o}},i=/\.pdf$/i,a=n.pathname.split("/").at(-1);if(i.test(a))return s(a);if(n.searchParams.size>0){const o=Array.from(n.searchParams.values()).reverse();for(const u of o)if(i.test(u))return s(u);const c=Array.from(n.searchParams.keys()).reverse();for(const u of c)if(i.test(u))return s(u)}if(n.hash){const c=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(n.hash);if(c)return s(c[0])}return e}class zte{constructor(){Ve(this,"started",Object.create(null));Ve(this,"times",[])}time(e){e in this.started&&Ft(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||Ft(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let r=0;for(const{name:n}of this.times)r=Math.max(n.length,r);for(const{name:n,start:s,end:i}of this.times)e.push(`${n.padEnd(r)} ${i-s}ms
`);return e.join("")}}function gS(t,e){const r=e?URL.parse(t,e):URL.parse(t);return(r==null?void 0:r.protocol)==="http:"||(r==null?void 0:r.protocol)==="https:"}function Al(t){t.preventDefault()}function ls(t){t.preventDefault(),t.stopPropagation()}function FSt(t){console.log("Deprecated API usage: "+t)}var Sk;class gO{static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!="string")return null;_(this,Sk)||te(this,Sk,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const r=_(this,Sk).exec(e);if(!r)return null;const n=parseInt(r[1],10);let s=parseInt(r[2],10);s=s>=1&&s<=12?s-1:0;let i=parseInt(r[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(r[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(r[5],10);o=o>=0&&o<=59?o:0;let c=parseInt(r[6],10);c=c>=0&&c<=59?c:0;const u=r[7]||"Z";let d=parseInt(r[8],10);d=d>=0&&d<=23?d:0;let h=parseInt(r[9],10)||0;return h=h>=0&&h<=59?h:0,u==="-"?(a+=d,o+=h):u==="+"&&(a-=d,o-=h),new Date(Date.UTC(n,s,i,a,o,c))}}Sk=new WeakMap,le(gO,Sk);function $St(t,{scale:e=1,rotation:r=0}){const{width:n,height:s}=t.attributes.style,i=[0,0,parseInt(n),parseInt(s)];return new FE({viewBox:i,userUnit:1,scale:e,rotation:r})}function JM(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(e=>parseInt(e)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(Ft(`Not a valid color format: "${t}"`),[0,0,0])}function BSt(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const r of t.keys()){e.style.color=r;const n=window.getComputedStyle(e).color;t.set(r,JM(n))}e.remove()}function kn(t){const{a:e,b:r,c:n,d:s,e:i,f:a}=t.getTransform();return[e,r,n,s,i,a]}function Oc(t){const{a:e,b:r,c:n,d:s,e:i,f:a}=t.getTransform().invertSelf();return[e,r,n,s,i,a]}function rx(t,e,r=!1,n=!0){if(e instanceof FE){const{pageWidth:s,pageHeight:i}=e.rawDims,{style:a}=t,o=wi.isCSSRoundSupported,c=`var(--total-scale-factor) * ${s}px`,u=`var(--total-scale-factor) * ${i}px`,d=o?`round(down, ${c}, var(--scale-round-x))`:`calc(${c})`,h=o?`round(down, ${u}, var(--scale-round-y))`:`calc(${u})`;!r||e.rotation%180===0?(a.width=d,a.height=h):(a.width=h,a.height=d)}n&&t.setAttribute("data-main-rotation",e.rotation)}class Cu{constructor(){const{pixelRatio:e}=Cu;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(e,r,n,s,i=-1){let a=1/0,o=1/0,c=1/0;n=Cu.capPixels(n,i),n>0&&(a=Math.sqrt(n/(e*r))),s!==-1&&(o=s/e,c=s/r);const u=Math.min(a,o,c);return this.sx>u||this.sy>u?(this.sx=u,this.sy=u,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,r){if(r>=0){const n=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+r/100));return e>0?Math.min(e,n):n}return e}}const j8=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];var Nf,Ef,Go,fd,_k,Eb,Ab,jk,gI,hwe,gi,fwe,pwe,sv,yS;const ld=class ld{constructor(e){le(this,gi);le(this,Nf,null);le(this,Ef,null);le(this,Go);le(this,fd,null);le(this,_k,null);le(this,Eb,null);le(this,Ab,null);te(this,Go,e),_(ld,jk)||te(ld,jk,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=te(this,Nf,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const r=_(this,Go)._uiManager._signal;e.addEventListener("contextmenu",Al,{signal:r}),e.addEventListener("pointerdown",ce(ld,gI,hwe),{signal:r});const n=te(this,fd,document.createElement("div"));n.className="buttons",e.append(n);const s=_(this,Go).toolbarPosition;if(s){const{style:i}=e,a=_(this,Go)._uiManager.direction==="ltr"?1-s[0]:s[0];i.insetInlineEnd=`${100*a}%`,i.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return _(this,Nf)}hide(){var e;_(this,Nf).classList.add("hidden"),(e=_(this,Ef))==null||e.hideDropdown()}show(){var e,r;_(this,Nf).classList.remove("hidden"),(e=_(this,_k))==null||e.shown(),(r=_(this,Eb))==null||r.shown()}addDeleteButton(){const{editorType:e,_uiManager:r}=_(this,Go),n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",_(ld,jk)[e]),ce(this,gi,sv).call(this,n),n.addEventListener("click",s=>{r.delete()},{signal:r._signal}),_(this,fd).append(n)}async addAltText(e){const r=await e.render();ce(this,gi,sv).call(this,r),_(this,fd).append(r,_(this,gi,yS)),te(this,_k,e)}addComment(e){if(_(this,Eb))return;const r=e.render();r&&(ce(this,gi,sv).call(this,r),_(this,fd).prepend(r,_(this,gi,yS)),te(this,Eb,e),e.toolbar=this)}addColorPicker(e){if(_(this,Ef))return;te(this,Ef,e);const r=e.renderButton();ce(this,gi,sv).call(this,r),_(this,fd).append(r,_(this,gi,yS))}async addEditSignatureButton(e){const r=te(this,Ab,await e.renderEditButton(_(this,Go)));ce(this,gi,sv).call(this,r),_(this,fd).append(r,_(this,gi,yS))}async addButton(e,r){switch(e){case"colorPicker":this.addColorPicker(r);break;case"altText":await this.addAltText(r);break;case"editSignature":await this.addEditSignatureButton(r);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(r);break}}updateEditSignatureButton(e){_(this,Ab)&&(_(this,Ab).title=e)}remove(){var e;_(this,Nf).remove(),(e=_(this,Ef))==null||e.destroy(),te(this,Ef,null)}};Nf=new WeakMap,Ef=new WeakMap,Go=new WeakMap,fd=new WeakMap,_k=new WeakMap,Eb=new WeakMap,Ab=new WeakMap,jk=new WeakMap,gI=new WeakSet,hwe=function(e){e.stopPropagation()},gi=new WeakSet,fwe=function(e){_(this,Go)._focusEventsAllowed=!1,ls(e)},pwe=function(e){_(this,Go)._focusEventsAllowed=!0,ls(e)},sv=function(e){const r=_(this,Go)._uiManager._signal;e.addEventListener("focusin",ce(this,gi,fwe).bind(this),{capture:!0,signal:r}),e.addEventListener("focusout",ce(this,gi,pwe).bind(this),{capture:!0,signal:r}),e.addEventListener("contextmenu",Al,{signal:r})},yS=function(){const e=document.createElement("div");return e.className="divider",e},le(ld,gI),le(ld,jk,null);let k8=ld;var kk,Sg,_g,Xp,mwe,gwe,ywe;class zSt{constructor(e){le(this,Xp);le(this,kk,null);le(this,Sg,null);le(this,_g);te(this,_g,e)}show(e,r,n){const[s,i]=ce(this,Xp,gwe).call(this,r,n),{style:a}=_(this,Sg)||te(this,Sg,ce(this,Xp,mwe).call(this));e.append(_(this,Sg)),a.insetInlineEnd=`${100*s}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){_(this,Sg).remove()}}kk=new WeakMap,Sg=new WeakMap,_g=new WeakMap,Xp=new WeakSet,mwe=function(){const e=te(this,Sg,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",Al,{signal:_(this,_g)._signal});const r=te(this,kk,document.createElement("div"));return r.className="buttons",e.append(r),ce(this,Xp,ywe).call(this),e},gwe=function(e,r){let n=0,s=0;for(const i of e){const a=i.y+i.height;if(a<n)continue;const o=i.x+(r?i.width:0);if(a>n){s=o,n=a;continue}r?o>s&&(s=o):o<s&&(s=o)}return[r?1-s:s,n]},ywe=function(){const e=document.createElement("button");e.className="highlightButton",e.tabIndex=0,e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const r=document.createElement("span");e.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=_(this,_g)._signal;e.addEventListener("contextmenu",Al,{signal:n}),e.addEventListener("click",()=>{_(this,_g).highlightSelection("floating_button")},{signal:n}),_(this,kk).append(e)};function xwe(t,e,r){for(const n of r)e.addEventListener(n,t[n].bind(t))}var yI;class USt{constructor(){le(this,yI,0)}get id(){return`${awe}${Ds(this,yI)._++}`}}yI=new WeakMap;var Cb,Nk,Pi,Tb,kT;const bq=class bq{constructor(){le(this,Tb);le(this,Cb,uwe());le(this,Nk,0);le(this,Pi,null)}static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',n=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),s=new Image;s.src=e;const i=s.decode().then(()=>(n.drawImage(s,0,0,1,1,0,0,1,3),new Uint32Array(n.getImageData(0,0,1,1).data.buffer)[0]===0));return tr(this,"_isSVGFittingCanvas",i)}async getFromFile(e){const{lastModified:r,name:n,size:s,type:i}=e;return ce(this,Tb,kT).call(this,`${r}_${n}_${s}_${i}`,e)}async getFromUrl(e){return ce(this,Tb,kT).call(this,e,e)}async getFromBlob(e,r){const n=await r;return ce(this,Tb,kT).call(this,e,n)}async getFromId(e){_(this,Pi)||te(this,Pi,new Map);const r=_(this,Pi).get(e);if(!r)return null;if(r.bitmap)return r.refCounter+=1,r;if(r.file)return this.getFromFile(r.file);if(r.blobPromise){const{blobPromise:n}=r;return delete r.blobPromise,this.getFromBlob(r.id,n)}return this.getFromUrl(r.url)}getFromCanvas(e,r){_(this,Pi)||te(this,Pi,new Map);let n=_(this,Pi).get(e);if(n!=null&&n.bitmap)return n.refCounter+=1,n;const s=new OffscreenCanvas(r.width,r.height);return s.getContext("2d").drawImage(r,0,0),n={bitmap:s.transferToImageBitmap(),id:`image_${_(this,Cb)}_${Ds(this,Nk)._++}`,refCounter:1,isSvg:!1},_(this,Pi).set(e,n),_(this,Pi).set(n.id,n),n}getSvgUrl(e){const r=_(this,Pi).get(e);return r!=null&&r.isSvg?r.svgUrl:null}deleteId(e){var s;_(this,Pi)||te(this,Pi,new Map);const r=_(this,Pi).get(e);if(!r||(r.refCounter-=1,r.refCounter!==0))return;const{bitmap:n}=r;if(!r.url&&!r.file){const i=new OffscreenCanvas(n.width,n.height);i.getContext("bitmaprenderer").transferFromImageBitmap(n),r.blobPromise=i.convertToBlob()}(s=n.close)==null||s.call(n),r.bitmap=null}isValidId(e){return e.startsWith(`image_${_(this,Cb)}_`)}};Cb=new WeakMap,Nk=new WeakMap,Pi=new WeakMap,Tb=new WeakSet,kT=async function(e,r){_(this,Pi)||te(this,Pi,new Map);let n=_(this,Pi).get(e);if(n===null)return null;if(n!=null&&n.bitmap)return n.refCounter+=1,n;try{n||(n={bitmap:null,id:`image_${_(this,Cb)}_${Ds(this,Nk)._++}`,refCounter:0,isSvg:!1});let s;if(typeof r=="string"?(n.url=r,s=await LE(r,"blob")):r instanceof File?s=n.file=r:r instanceof Blob&&(s=r),s.type==="image/svg+xml"){const i=bq._isSVGFittingCanvas,a=new FileReader,o=new Image,c=new Promise((u,d)=>{o.onload=()=>{n.bitmap=o,n.isSvg=!0,u()},a.onload=async()=>{const h=n.svgUrl=a.result;o.src=await i?`${h}#svgView(preserveAspectRatio(none))`:h},o.onerror=a.onerror=d});a.readAsDataURL(s),await c}else n.bitmap=await createImageBitmap(s);n.refCounter=1}catch(s){Ft(s),n=null}return _(this,Pi).set(e,n),n&&_(this,Pi).set(n.id,n),n};let N8=bq;var Kn,Af,Ek,jn,Tae;let HSt=(Tae=class{constructor(e=128){le(this,Kn,[]);le(this,Af,!1);le(this,Ek);le(this,jn,-1);te(this,Ek,e)}add({cmd:e,undo:r,post:n,mustExec:s,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(s&&e(),_(this,Af))return;const c={cmd:e,undo:r,post:n,type:i};if(_(this,jn)===-1){_(this,Kn).length>0&&(_(this,Kn).length=0),te(this,jn,0),_(this,Kn).push(c);return}if(a&&_(this,Kn)[_(this,jn)].type===i){o&&(c.undo=_(this,Kn)[_(this,jn)].undo),_(this,Kn)[_(this,jn)]=c;return}const u=_(this,jn)+1;u===_(this,Ek)?_(this,Kn).splice(0,1):(te(this,jn,u),u<_(this,Kn).length&&_(this,Kn).splice(u)),_(this,Kn).push(c)}undo(){if(_(this,jn)===-1)return;te(this,Af,!0);const{undo:e,post:r}=_(this,Kn)[_(this,jn)];e(),r==null||r(),te(this,Af,!1),te(this,jn,_(this,jn)-1)}redo(){if(_(this,jn)<_(this,Kn).length-1){te(this,jn,_(this,jn)+1),te(this,Af,!0);const{cmd:e,post:r}=_(this,Kn)[_(this,jn)];e(),r==null||r(),te(this,Af,!1)}}hasSomethingToUndo(){return _(this,jn)!==-1}hasSomethingToRedo(){return _(this,jn)<_(this,Kn).length-1}cleanType(e){if(_(this,jn)!==-1){for(let r=_(this,jn);r>=0;r--)if(_(this,Kn)[r].type!==e){_(this,Kn).splice(r+1,_(this,jn)-r),te(this,jn,r);return}_(this,Kn).length=0,te(this,jn,-1)}}destroy(){te(this,Kn,null)}},Kn=new WeakMap,Af=new WeakMap,Ek=new WeakMap,jn=new WeakMap,Tae);var xI,vwe;class $E{constructor(e){le(this,xI);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:r}=wi.platform;for(const[n,s,i={}]of e)for(const a of n){const o=a.startsWith("mac+");r&&o?(this.callbacks.set(a.slice(4),{callback:s,options:i}),this.allKeys.add(a.split("+").at(-1))):!r&&!o&&(this.callbacks.set(a,{callback:s,options:i}),this.allKeys.add(a.split("+").at(-1)))}}exec(e,r){if(!this.allKeys.has(r.key))return;const n=this.callbacks.get(ce(this,xI,vwe).call(this,r));if(!n)return;const{callback:s,options:{bubbles:i=!1,args:a=[],checker:o=null}}=n;o&&!o(e,r)||(s.bind(e,...a,r)(),i||ls(r))}}xI=new WeakSet,vwe=function(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const r=this.buffer.join("+");return this.buffer.length=0,r};const vI=class vI{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return BSt(e),tr(this,"_colors",e)}convert(e){const r=JM(e);if(!window.matchMedia("(forced-colors: active)").matches)return r;for(const[n,s]of this._colors)if(s.every((i,a)=>i===r[a]))return vI._colorsMapping.get(n);return r}getHexCode(e){const r=this._colors.get(e);return r?jt.makeHexColor(...r):e}};Ve(vI,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let E8=vI;var Pb,so,Ss,ti,Ob,pd,Ib,Ko,jg,Cf,Tf,Rb,kg,qc,Wl,Ng,Ak,Ck,Mb,Tk,Gc,Pf,Db,Of,Kc,bI,If,Pk,Rf,Eg,Lb,Mf,Ok,Ls,Cr,md,Df,Lf,Ik,Rk,Ff,Yc,gd,Mk,Dk,Yo,st,NT,A8,bwe,wwe,ET,Swe,_we,jwe,C8,kwe,T8,P8,Nwe,Qi,Zu,Ewe,Awe,O8,Cwe,xS,I8;const Vv=class Vv{constructor(e,r,n,s,i,a,o,c,u,d,h,f,p,m,g,x){le(this,st);le(this,Pb,new AbortController);le(this,so,null);le(this,Ss,new Map);le(this,ti,new Map);le(this,Ob,null);le(this,pd,null);le(this,Ib,null);le(this,Ko,new HSt);le(this,jg,null);le(this,Cf,null);le(this,Tf,null);le(this,Rb,0);le(this,kg,new Set);le(this,qc,null);le(this,Wl,null);le(this,Ng,new Set);Ve(this,"_editorUndoBar",null);le(this,Ak,!1);le(this,Ck,!1);le(this,Mb,!1);le(this,Tk,null);le(this,Gc,null);le(this,Pf,null);le(this,Db,null);le(this,Of,!1);le(this,Kc,null);le(this,bI,new USt);le(this,If,!1);le(this,Pk,!1);le(this,Rf,null);le(this,Eg,null);le(this,Lb,null);le(this,Mf,null);le(this,Ok,null);le(this,Ls,Lt.NONE);le(this,Cr,new Set);le(this,md,null);le(this,Df,null);le(this,Lf,null);le(this,Ik,null);le(this,Rk,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});le(this,Ff,[0,0]);le(this,Yc,null);le(this,gd,null);le(this,Mk,null);le(this,Dk,null);le(this,Yo,null);const y=this._signal=_(this,Pb).signal;te(this,gd,e),te(this,Mk,r),te(this,Dk,n),te(this,Ob,s),te(this,jg,i),te(this,Df,a),this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:y}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:y}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:y}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:y}),o._on("setpreference",this.onSetPreference.bind(this),{signal:y}),o._on("switchannotationeditorparams",v=>this.updateParams(v.type,v.value),{signal:y}),ce(this,st,Swe).call(this),ce(this,st,Nwe).call(this),ce(this,st,C8).call(this),te(this,pd,c.annotationStorage),te(this,Tk,c.filterFactory),te(this,Lf,u),te(this,Db,d||null),te(this,Ak,h),te(this,Ck,f),te(this,Mb,p),te(this,Ok,m||null),this.viewParameters={realScale:Gp.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=x!==!1}static get _keyboardManager(){const e=Vv.prototype,r=a=>_(a,gd).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),n=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:c}=o;return c!=="text"&&c!=="number"}return!0},s=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return tr(this,"_keyboardManager",new $E([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],e.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:n}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:n}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&_(a,gd).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&_(a,gd).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-s,0],checker:r}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:r}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[s,0],checker:r}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:r}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-s],checker:r}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:r}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,s],checker:r}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:r}]]))}destroy(){var e,r,n,s,i,a,o,c,u;(e=_(this,Yo))==null||e.resolve(),te(this,Yo,null),(r=_(this,Pb))==null||r.abort(),te(this,Pb,null),this._signal=null;for(const d of _(this,ti).values())d.destroy();_(this,ti).clear(),_(this,Ss).clear(),_(this,Ng).clear(),(n=_(this,Mf))==null||n.clear(),te(this,so,null),_(this,Cr).clear(),_(this,Ko).destroy(),(s=_(this,Ob))==null||s.destroy(),(i=_(this,jg))==null||i.destroy(),(a=_(this,Df))==null||a.destroy(),(o=_(this,Kc))==null||o.hide(),te(this,Kc,null),(c=_(this,Lb))==null||c.destroy(),te(this,Lb,null),_(this,Gc)&&(clearTimeout(_(this,Gc)),te(this,Gc,null)),_(this,Yc)&&(clearTimeout(_(this,Yc)),te(this,Yc,null)),(u=this._editorUndoBar)==null||u.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return _(this,Ok)}get useNewAltTextFlow(){return _(this,Ck)}get useNewAltTextWhenAddingImage(){return _(this,Mb)}get hcmFilter(){return tr(this,"hcmFilter",_(this,Lf)?_(this,Tk).addHCMFilter(_(this,Lf).foreground,_(this,Lf).background):"none")}get direction(){return tr(this,"direction",getComputedStyle(_(this,gd)).direction)}get _highlightColors(){return tr(this,"_highlightColors",_(this,Db)?new Map(_(this,Db).split(",").map(e=>(e=e.split("=").map(r=>r.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){const{_highlightColors:e}=this;if(!e)return tr(this,"highlightColors",null);const r=new Map,n=!!_(this,Lf);for(const[s,i]of e){const a=s.endsWith("_HCM");if(n&&a){r.set(s.replace("_HCM",""),i);continue}!n&&!a&&r.set(s,i)}return tr(this,"highlightColors",r)}get highlightColorNames(){return tr(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const r=this.highlightColorNames.get(e);return this._highlightColors.get(r)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),te(this,Tf,e)}setMainHighlightColorPicker(e){te(this,Lb,e)}editAltText(e,r=!1){var n;(n=_(this,Ob))==null||n.editAltText(this,e,r)}hasCommentManager(){return!!_(this,jg)}editComment(e,r){var n;(n=_(this,jg))==null||n.open(this,e,r)}getSignature(e){var r;(r=_(this,Df))==null||r.getSignature({uiManager:this,editor:e})}get signatureManager(){return _(this,Df)}switchToMode(e,r){this._eventBus.on("annotationeditormodechanged",r,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,r){this._eventBus.dispatch("setpreference",{source:this,name:e,value:r})}onSetPreference({name:e,value:r}){switch(e){case"enableNewAltTextWhenAddingImage":te(this,Mb,r);break}}onPageChanging({pageNumber:e}){te(this,Rb,e-1)}focusMainContainer(){_(this,gd).focus()}findParent(e,r){for(const n of _(this,ti).values()){const{x:s,y:i,width:a,height:o}=n.div.getBoundingClientRect();if(e>=s&&e<=s+a&&r>=i&&r<=i+o)return n}return null}disableUserSelect(e=!1){_(this,Mk).classList.toggle("noUserSelect",e)}addShouldRescale(e){_(this,Ng).add(e)}removeShouldRescale(e){_(this,Ng).delete(e)}onScaleChanging({scale:e}){var r;this.commitOrRemove(),this.viewParameters.realScale=e*Gp.PDF_TO_CSS_UNITS;for(const n of _(this,Ng))n.onScaleChanging();(r=_(this,Tf))==null||r.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e=""){const r=document.getSelection();if(!r||r.isCollapsed)return;const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:a}=r,o=r.toString(),u=ce(this,st,NT).call(this,r).closest(".textLayer"),d=this.getSelectionBoxes(u);if(!d)return;r.empty();const h=ce(this,st,A8).call(this,u),f=_(this,Ls)===Lt.NONE,p=()=>{h==null||h.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:d,anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:a,text:o}),f&&this.showAllEditors("highlight",!0,!0)};if(f){this.switchToMode(Lt.HIGHLIGHT,p);return}p()}addToAnnotationStorage(e){!e.isEmpty()&&_(this,pd)&&!_(this,pd).has(e.id)&&_(this,pd).setValue(e.id,e)}a11yAlert(e,r=null){const n=_(this,Dk);n&&(n.setAttribute("data-l10n-id",e),r?n.setAttribute("data-l10n-args",JSON.stringify(r)):n.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,_(this,Of)&&(te(this,Of,!1),ce(this,st,ET).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const r of _(this,Cr))if(r.div.contains(e)){te(this,Eg,[r,e]),r._focusEventsAllowed=!1;break}}focus(){if(!_(this,Eg))return;const[e,r]=_(this,Eg);te(this,Eg,null),r.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),r.focus()}addEditListeners(){ce(this,st,C8).call(this),ce(this,st,T8).call(this)}removeEditListeners(){ce(this,st,kwe).call(this),ce(this,st,P8).call(this)}dragOver(e){for(const{type:r}of e.dataTransfer.items)for(const n of _(this,Wl))if(n.isHandlingMimeForPasting(r)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const r of e.dataTransfer.items)for(const n of _(this,Wl))if(n.isHandlingMimeForPasting(r.type)){n.paste(r,this.currentLayer),e.preventDefault();return}}copy(e){var n;if(e.preventDefault(),(n=_(this,so))==null||n.commitOrRemove(),!this.hasSelection)return;const r=[];for(const s of _(this,Cr)){const i=s.serialize(!0);i&&r.push(i)}r.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(r))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:r}=e;for(const i of r.items)for(const a of _(this,Wl))if(a.isHandlingMimeForPasting(i.type)){a.paste(i,this.currentLayer);return}let n=r.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(i){Ft(`paste: "${i.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();const s=this.currentLayer;try{const i=[];for(const c of n){const u=await s.deserialize(c);if(!u)return;i.push(u)}const a=()=>{for(const c of i)ce(this,st,O8).call(this,c);ce(this,st,I8).call(this,i)},o=()=>{for(const c of i)c.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(i){Ft(`paste: "${i.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),_(this,Ls)!==Lt.NONE&&!this.isEditorHandlingKeyboard&&Vv._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,_(this,Of)&&(te(this,Of,!1),ce(this,st,ET).call(this,"main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break}}setEditingState(e){e?(ce(this,st,_we).call(this),ce(this,st,T8).call(this),ce(this,st,Qi).call(this,{isEditing:_(this,Ls)!==Lt.NONE,isEmpty:ce(this,st,xS).call(this),hasSomethingToUndo:_(this,Ko).hasSomethingToUndo(),hasSomethingToRedo:_(this,Ko).hasSomethingToRedo(),hasSelectedEditor:!1})):(ce(this,st,jwe).call(this),ce(this,st,P8).call(this),ce(this,st,Qi).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!_(this,Wl)){te(this,Wl,e);for(const r of _(this,Wl))ce(this,st,Zu).call(this,r.defaultPropertiesToUpdate)}}getId(){return _(this,bI).id}get currentLayer(){return _(this,ti).get(_(this,Rb))}getLayer(e){return _(this,ti).get(e)}get currentPageIndex(){return _(this,Rb)}addLayer(e){_(this,ti).set(e.pageIndex,e),_(this,If)?e.enable():e.disable()}removeLayer(e){_(this,ti).delete(e.pageIndex)}async updateMode(e,r=null,n=!1,s=!1,i=!1){var a,o,c;if(_(this,Ls)!==e&&!(_(this,Yo)&&(await _(this,Yo).promise,!_(this,Yo)))){if(te(this,Yo,Promise.withResolvers()),(a=_(this,Tf))==null||a.commitOrRemove(),te(this,Ls,e),e===Lt.NONE){this.setEditingState(!1),ce(this,st,Awe).call(this),(o=this._editorUndoBar)==null||o.hide(),_(this,Yo).resolve();return}e===Lt.SIGNATURE&&await((c=_(this,Df))==null?void 0:c.loadSignatures()),this.setEditingState(!0),await ce(this,st,Ewe).call(this),this.unselectAll();for(const u of _(this,ti).values())u.updateMode(e);if(!r){n&&this.addNewEditorFromKeyboard(),_(this,Yo).resolve();return}for(const u of _(this,Ss).values())u.annotationElementId===r||u.id===r?(this.setSelected(u),i?u.editComment():s&&u.enterInEditMode()):u.unselect();_(this,Yo).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==_(this,Ls)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,r){if(_(this,Wl)){switch(e){case dr.CREATE:this.currentLayer.addNewEditor(r);return;case dr.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(_(this,Ik)||te(this,Ik,new Map)).set(e,r),this.showAllEditors("highlight",r);break}if(this.hasSelection)for(const n of _(this,Cr))n.updateParams(e,r);else for(const n of _(this,Wl))n.updateDefaultParams(e,r)}}showAllEditors(e,r,n=!1){var i;for(const a of _(this,Ss).values())a.editorType===e&&a.show(r);(((i=_(this,Ik))==null?void 0:i.get(dr.HIGHLIGHT_SHOW_ALL))??!0)!==r&&ce(this,st,Zu).call(this,[[dr.HIGHLIGHT_SHOW_ALL,r]])}enableWaiting(e=!1){if(_(this,Pk)!==e){te(this,Pk,e);for(const r of _(this,ti).values())e?r.disableClick():r.enableClick(),r.div.classList.toggle("waiting",e)}}getEditors(e){const r=[];for(const n of _(this,Ss).values())n.pageIndex===e&&r.push(n);return r}getEditor(e){return _(this,Ss).get(e)}addEditor(e){_(this,Ss).set(e.id,e)}removeEditor(e){var r,n;e.div.contains(document.activeElement)&&(_(this,Gc)&&clearTimeout(_(this,Gc)),te(this,Gc,setTimeout(()=>{this.focusMainContainer(),te(this,Gc,null)},0))),_(this,Ss).delete(e.id),e.annotationElementId&&((r=_(this,Mf))==null||r.delete(e.annotationElementId)),this.unselect(e),(!e.annotationElementId||!_(this,kg).has(e.annotationElementId))&&((n=_(this,pd))==null||n.remove(e.id))}addDeletedAnnotationElement(e){_(this,kg).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return _(this,kg).has(e)}removeDeletedAnnotationElement(e){_(this,kg).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){_(this,so)!==e&&(te(this,so,e),e&&ce(this,st,Zu).call(this,e.propertiesToUpdate))}updateUI(e){_(this,st,Cwe)===e&&ce(this,st,Zu).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){ce(this,st,Zu).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(_(this,Cr).has(e)){_(this,Cr).delete(e),e.unselect(),ce(this,st,Qi).call(this,{hasSelectedEditor:this.hasSelection});return}_(this,Cr).add(e),e.select(),ce(this,st,Zu).call(this,e.propertiesToUpdate),ce(this,st,Qi).call(this,{hasSelectedEditor:!0})}setSelected(e){var r;this.updateToolbar({mode:e.mode,editId:e.id}),(r=_(this,Tf))==null||r.commitOrRemove();for(const n of _(this,Cr))n!==e&&n.unselect();_(this,Cr).clear(),_(this,Cr).add(e),e.select(),ce(this,st,Zu).call(this,e.propertiesToUpdate),ce(this,st,Qi).call(this,{hasSelectedEditor:!0})}isSelected(e){return _(this,Cr).has(e)}get firstSelectedEditor(){return _(this,Cr).values().next().value}unselect(e){e.unselect(),_(this,Cr).delete(e),ce(this,st,Qi).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return _(this,Cr).size!==0}get isEnterHandled(){return _(this,Cr).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var e;_(this,Ko).undo(),ce(this,st,Qi).call(this,{hasSomethingToUndo:_(this,Ko).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:ce(this,st,xS).call(this)}),(e=this._editorUndoBar)==null||e.hide()}redo(){_(this,Ko).redo(),ce(this,st,Qi).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:_(this,Ko).hasSomethingToRedo(),isEmpty:ce(this,st,xS).call(this)})}addCommands(e){_(this,Ko).add(e),ce(this,st,Qi).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:ce(this,st,xS).call(this)})}cleanUndoStack(e){_(this,Ko).cleanType(e)}delete(){var i;this.commitOrRemove();const e=(i=this.currentLayer)==null?void 0:i.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const r=e?[e]:[..._(this,Cr)],n=()=>{var a;(a=this._editorUndoBar)==null||a.show(s,r.length===1?r[0].editorType:r.length);for(const o of r)o.remove()},s=()=>{for(const a of r)ce(this,st,O8).call(this,a)};this.addCommands({cmd:n,undo:s,mustExec:!0})}commitOrRemove(){var e;(e=_(this,so))==null||e.commitOrRemove()}hasSomethingToControl(){return _(this,so)||this.hasSelection}selectAll(){for(const e of _(this,Cr))e.commit();ce(this,st,I8).call(this,_(this,Ss).values())}unselectAll(){var e;if(!(_(this,so)&&(_(this,so).commitOrRemove(),_(this,Ls)!==Lt.NONE))&&!((e=_(this,Tf))!=null&&e.commitOrRemove())&&this.hasSelection){for(const r of _(this,Cr))r.unselect();_(this,Cr).clear(),ce(this,st,Qi).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,r,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;_(this,Ff)[0]+=e,_(this,Ff)[1]+=r;const[s,i]=_(this,Ff),a=[..._(this,Cr)],o=1e3;_(this,Yc)&&clearTimeout(_(this,Yc)),te(this,Yc,setTimeout(()=>{te(this,Yc,null),_(this,Ff)[0]=_(this,Ff)[1]=0,this.addCommands({cmd:()=>{for(const c of a)_(this,Ss).has(c.id)&&(c.translateInPage(s,i),c.translationDone())},undo:()=>{for(const c of a)_(this,Ss).has(c.id)&&(c.translateInPage(-s,-i),c.translationDone())},mustExec:!1})},o));for(const c of a)c.translateInPage(e,r),c.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),te(this,qc,new Map);for(const e of _(this,Cr))_(this,qc).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!_(this,qc))return!1;this.disableUserSelect(!1);const e=_(this,qc);te(this,qc,null);let r=!1;for(const[{x:s,y:i,pageIndex:a},o]of e)o.newX=s,o.newY=i,o.newPageIndex=a,r||(r=s!==o.savedX||i!==o.savedY||a!==o.savedPageIndex);if(!r)return!1;const n=(s,i,a,o)=>{if(_(this,Ss).has(s.id)){const c=_(this,ti).get(o);c?s._setParentAndPosition(c,i,a):(s.pageIndex=o,s.x=i,s.y=a)}};return this.addCommands({cmd:()=>{for(const[s,{newX:i,newY:a,newPageIndex:o}]of e)n(s,i,a,o)},undo:()=>{for(const[s,{savedX:i,savedY:a,savedPageIndex:o}]of e)n(s,i,a,o)},mustExec:!0}),!0}dragSelectedEditors(e,r){if(_(this,qc))for(const n of _(this,qc).keys())n.drag(e,r)}rebuild(e){if(e.parent===null){const r=this.getLayer(e.pageIndex);r?(r.changeParent(e),r.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||_(this,Cr).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return _(this,so)===e}getActive(){return _(this,so)}getMode(){return _(this,Ls)}get imageManager(){return tr(this,"imageManager",new N8)}getSelectionBoxes(e){if(!e)return null;const r=document.getSelection();for(let u=0,d=r.rangeCount;u<d;u++)if(!e.contains(r.getRangeAt(u).commonAncestorContainer))return null;const{x:n,y:s,width:i,height:a}=e.getBoundingClientRect();let o;switch(e.getAttribute("data-main-rotation")){case"90":o=(u,d,h,f)=>({x:(d-s)/a,y:1-(u+h-n)/i,width:f/a,height:h/i});break;case"180":o=(u,d,h,f)=>({x:1-(u+h-n)/i,y:1-(d+f-s)/a,width:h/i,height:f/a});break;case"270":o=(u,d,h,f)=>({x:1-(d+f-s)/a,y:(u-n)/i,width:f/a,height:h/i});break;default:o=(u,d,h,f)=>({x:(u-n)/i,y:(d-s)/a,width:h/i,height:f/a});break}const c=[];for(let u=0,d=r.rangeCount;u<d;u++){const h=r.getRangeAt(u);if(!h.collapsed)for(const{x:f,y:p,width:m,height:g}of h.getClientRects())m===0||g===0||c.push(o(f,p,m,g))}return c.length===0?null:c}addChangedExistingAnnotation({annotationElementId:e,id:r}){(_(this,Ib)||te(this,Ib,new Map)).set(e,r)}removeChangedExistingAnnotation({annotationElementId:e}){var r;(r=_(this,Ib))==null||r.delete(e)}renderAnnotationElement(e){var s;const r=(s=_(this,Ib))==null?void 0:s.get(e.data.id);if(!r)return;const n=_(this,pd).getRawValue(r);n&&(_(this,Ls)===Lt.NONE&&!n.hasBeenModified||n.renderAnnotationElement(e))}setMissingCanvas(e,r,n){var i;const s=(i=_(this,Mf))==null?void 0:i.get(e);s&&(s.setCanvas(r,n),_(this,Mf).delete(e))}addMissingCanvas(e,r){(_(this,Mf)||te(this,Mf,new Map)).set(e,r)}};Pb=new WeakMap,so=new WeakMap,Ss=new WeakMap,ti=new WeakMap,Ob=new WeakMap,pd=new WeakMap,Ib=new WeakMap,Ko=new WeakMap,jg=new WeakMap,Cf=new WeakMap,Tf=new WeakMap,Rb=new WeakMap,kg=new WeakMap,qc=new WeakMap,Wl=new WeakMap,Ng=new WeakMap,Ak=new WeakMap,Ck=new WeakMap,Mb=new WeakMap,Tk=new WeakMap,Gc=new WeakMap,Pf=new WeakMap,Db=new WeakMap,Of=new WeakMap,Kc=new WeakMap,bI=new WeakMap,If=new WeakMap,Pk=new WeakMap,Rf=new WeakMap,Eg=new WeakMap,Lb=new WeakMap,Mf=new WeakMap,Ok=new WeakMap,Ls=new WeakMap,Cr=new WeakMap,md=new WeakMap,Df=new WeakMap,Lf=new WeakMap,Ik=new WeakMap,Rk=new WeakMap,Ff=new WeakMap,Yc=new WeakMap,gd=new WeakMap,Mk=new WeakMap,Dk=new WeakMap,Yo=new WeakMap,st=new WeakSet,NT=function({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e},A8=function(e){const{currentLayer:r}=this;if(r.hasTextLayer(e))return r;for(const n of _(this,ti).values())if(n.hasTextLayer(e))return n;return null},bwe=function(){const e=document.getSelection();if(!e||e.isCollapsed)return;const n=ce(this,st,NT).call(this,e).closest(".textLayer"),s=this.getSelectionBoxes(n);s&&(_(this,Kc)||te(this,Kc,new zSt(this)),_(this,Kc).show(n,s,this.direction==="ltr"))},wwe=function(){var i,a,o;const e=document.getSelection();if(!e||e.isCollapsed){_(this,md)&&((i=_(this,Kc))==null||i.hide(),te(this,md,null),ce(this,st,Qi).call(this,{hasSelectedText:!1}));return}const{anchorNode:r}=e;if(r===_(this,md))return;const s=ce(this,st,NT).call(this,e).closest(".textLayer");if(!s){_(this,md)&&((a=_(this,Kc))==null||a.hide(),te(this,md,null),ce(this,st,Qi).call(this,{hasSelectedText:!1}));return}if((o=_(this,Kc))==null||o.hide(),te(this,md,r),ce(this,st,Qi).call(this,{hasSelectedText:!0}),!(_(this,Ls)!==Lt.HIGHLIGHT&&_(this,Ls)!==Lt.NONE)&&(_(this,Ls)===Lt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),te(this,Of,this.isShiftKeyDown),!this.isShiftKeyDown)){const c=_(this,Ls)===Lt.HIGHLIGHT?ce(this,st,A8).call(this,s):null;c==null||c.toggleDrawing();const u=new AbortController,d=this.combinedSignal(u),h=f=>{f.type==="pointerup"&&f.button!==0||(u.abort(),c==null||c.toggleDrawing(!0),f.type==="pointerup"&&ce(this,st,ET).call(this,"main_toolbar"))};window.addEventListener("pointerup",h,{signal:d}),window.addEventListener("blur",h,{signal:d})}},ET=function(e=""){_(this,Ls)===Lt.HIGHLIGHT?this.highlightSelection(e):_(this,Ak)&&ce(this,st,bwe).call(this)},Swe=function(){document.addEventListener("selectionchange",ce(this,st,wwe).bind(this),{signal:this._signal})},_we=function(){if(_(this,Pf))return;te(this,Pf,new AbortController);const e=this.combinedSignal(_(this,Pf));window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})},jwe=function(){var e;(e=_(this,Pf))==null||e.abort(),te(this,Pf,null)},C8=function(){if(_(this,Rf))return;te(this,Rf,new AbortController);const e=this.combinedSignal(_(this,Rf));window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})},kwe=function(){var e;(e=_(this,Rf))==null||e.abort(),te(this,Rf,null)},T8=function(){if(_(this,Cf))return;te(this,Cf,new AbortController);const e=this.combinedSignal(_(this,Cf));document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})},P8=function(){var e;(e=_(this,Cf))==null||e.abort(),te(this,Cf,null)},Nwe=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},Qi=function(e){Object.entries(e).some(([n,s])=>_(this,Rk)[n]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(_(this,Rk),e)}),_(this,Ls)===Lt.HIGHLIGHT&&e.hasSelectedEditor===!1&&ce(this,st,Zu).call(this,[[dr.HIGHLIGHT_FREE,!0]]))},Zu=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},Ewe=async function(){if(!_(this,If)){te(this,If,!0);const e=[];for(const r of _(this,ti).values())e.push(r.enable());await Promise.all(e);for(const r of _(this,Ss).values())r.enable()}},Awe=function(){if(this.unselectAll(),_(this,If)){te(this,If,!1);for(const e of _(this,ti).values())e.disable();for(const e of _(this,Ss).values())e.disable()}},O8=function(e){const r=_(this,ti).get(e.pageIndex);r?r.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},Cwe=function(){let e=null;for(e of _(this,Cr));return e},xS=function(){if(_(this,Ss).size===0)return!0;if(_(this,Ss).size===1)for(const e of _(this,Ss).values())return e.isEmpty();return!1},I8=function(e){for(const r of _(this,Cr))r.unselect();_(this,Cr).clear();for(const r of e)r.isEmpty()||(_(this,Cr).add(r),r.select());ce(this,st,Qi).call(this,{hasSelectedEditor:this.hasSelection})},Ve(Vv,"TRANSLATE_SMALL",1),Ve(Vv,"TRANSLATE_BIG",10);let nx=Vv;var Fs,Xc,ql,Fb,Jc,io,$b,Qc,Pa,yd,Ag,Zc,$f,uc,vS,AT;const ta=class ta{constructor(e){le(this,uc);le(this,Fs,null);le(this,Xc,!1);le(this,ql,null);le(this,Fb,null);le(this,Jc,null);le(this,io,null);le(this,$b,!1);le(this,Qc,null);le(this,Pa,null);le(this,yd,null);le(this,Ag,null);le(this,Zc,!1);te(this,Pa,e),te(this,Zc,e._uiManager.useNewAltTextFlow),_(ta,$f)||te(ta,$f,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){ta._l10n??(ta._l10n=e)}async render(){const e=te(this,ql,document.createElement("button"));e.className="altText",e.tabIndex="0";const r=te(this,Fb,document.createElement("span"));e.append(r),_(this,Zc)?(e.classList.add("new"),e.setAttribute("data-l10n-id",_(ta,$f).missing),r.setAttribute("data-l10n-id",_(ta,$f)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const n=_(this,Pa)._uiManager._signal;e.addEventListener("contextmenu",Al,{signal:n}),e.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:n});const s=i=>{i.preventDefault(),_(this,Pa)._uiManager.editAltText(_(this,Pa)),_(this,Zc)&&_(this,Pa)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:_(this,uc,vS)}})};return e.addEventListener("click",s,{capture:!0,signal:n}),e.addEventListener("keydown",i=>{i.target===e&&i.key==="Enter"&&(te(this,$b,!0),s(i))},{signal:n}),await ce(this,uc,AT).call(this),e}finish(){_(this,ql)&&(_(this,ql).focus({focusVisible:_(this,$b)}),te(this,$b,!1))}isEmpty(){return _(this,Zc)?_(this,Fs)===null:!_(this,Fs)&&!_(this,Xc)}hasData(){return _(this,Zc)?_(this,Fs)!==null||!!_(this,yd):this.isEmpty()}get guessedText(){return _(this,yd)}async setGuessedText(e){_(this,Fs)===null&&(te(this,yd,e),te(this,Ag,await ta._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),ce(this,uc,AT).call(this))}toggleAltTextBadge(e=!1){var r;if(!_(this,Zc)||_(this,Fs)){(r=_(this,Qc))==null||r.remove(),te(this,Qc,null);return}if(!_(this,Qc)){const n=te(this,Qc,document.createElement("div"));n.className="noAltTextBadge",_(this,Pa).div.append(n)}_(this,Qc).classList.toggle("hidden",!e)}serialize(e){let r=_(this,Fs);return!e&&_(this,yd)===r&&(r=_(this,Ag)),{altText:r,decorative:_(this,Xc),guessedText:_(this,yd),textWithDisclaimer:_(this,Ag)}}get data(){return{altText:_(this,Fs),decorative:_(this,Xc)}}set data({altText:e,decorative:r,guessedText:n,textWithDisclaimer:s,cancel:i=!1}){n&&(te(this,yd,n),te(this,Ag,s)),!(_(this,Fs)===e&&_(this,Xc)===r)&&(i||(te(this,Fs,e),te(this,Xc,r)),ce(this,uc,AT).call(this))}toggle(e=!1){_(this,ql)&&(!e&&_(this,io)&&(clearTimeout(_(this,io)),te(this,io,null)),_(this,ql).disabled=!e)}shown(){_(this,Pa)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:_(this,uc,vS)}})}destroy(){var e,r;(e=_(this,ql))==null||e.remove(),te(this,ql,null),te(this,Fb,null),te(this,Jc,null),(r=_(this,Qc))==null||r.remove(),te(this,Qc,null)}};Fs=new WeakMap,Xc=new WeakMap,ql=new WeakMap,Fb=new WeakMap,Jc=new WeakMap,io=new WeakMap,$b=new WeakMap,Qc=new WeakMap,Pa=new WeakMap,yd=new WeakMap,Ag=new WeakMap,Zc=new WeakMap,$f=new WeakMap,uc=new WeakSet,vS=function(){return _(this,Fs)&&"added"||_(this,Fs)===null&&this.guessedText&&"review"||"missing"},AT=async function(){var s,i,a;const e=_(this,ql);if(!e)return;if(_(this,Zc)){if(e.classList.toggle("done",!!_(this,Fs)),e.setAttribute("data-l10n-id",_(ta,$f)[_(this,uc,vS)]),(s=_(this,Fb))==null||s.setAttribute("data-l10n-id",_(ta,$f)[`${_(this,uc,vS)}-label`]),!_(this,Fs)){(i=_(this,Jc))==null||i.remove();return}}else{if(!_(this,Fs)&&!_(this,Xc)){e.classList.remove("done"),(a=_(this,Jc))==null||a.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let r=_(this,Jc);if(!r){te(this,Jc,r=document.createElement("span")),r.className="tooltip",r.setAttribute("role","tooltip"),r.id=`alt-text-tooltip-${_(this,Pa).id}`;const o=100,c=_(this,Pa)._uiManager._signal;c.addEventListener("abort",()=>{clearTimeout(_(this,io)),te(this,io,null)},{once:!0}),e.addEventListener("mouseenter",()=>{te(this,io,setTimeout(()=>{te(this,io,null),_(this,Jc).classList.add("show"),_(this,Pa)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:c}),e.addEventListener("mouseleave",()=>{var u;_(this,io)&&(clearTimeout(_(this,io)),te(this,io,null)),(u=_(this,Jc))==null||u.classList.remove("show")},{signal:c})}_(this,Xc)?r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(r.removeAttribute("data-l10n-id"),r.textContent=_(this,Fs)),r.parentNode||e.append(r);const n=_(this,Pa).getElementForAltText();n==null||n.setAttribute("aria-describedby",r.id)},le(ta,$f,null),Ve(ta,"_l10n",null);let yO=ta;var eu,Cg,Gl,Lk,xd,Bb,Bf,Pae;let hC=(Pae=class{constructor(e){le(this,eu,null);le(this,Cg,!1);le(this,Gl,null);le(this,Lk,null);le(this,xd,null);le(this,Bb,null);le(this,Bf,!1);te(this,Gl,e),this.toolbar=null}render(){if(!_(this,Gl)._uiManager.hasCommentManager())return null;const e=te(this,eu,document.createElement("button"));e.className="comment",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button");const r=_(this,Gl)._uiManager._signal;e.addEventListener("contextmenu",Al,{signal:r}),e.addEventListener("pointerdown",s=>s.stopPropagation(),{signal:r});const n=s=>{s.preventDefault(),this.edit()};return e.addEventListener("click",n,{capture:!0,signal:r}),e.addEventListener("keydown",s=>{s.target===e&&s.key==="Enter"&&(te(this,Cg,!0),n(s))},{signal:r}),e}edit(){const{bottom:e,left:r,right:n}=_(this,Gl).getClientDimensions(),s={top:e};_(this,Gl)._uiManager.direction==="ltr"?s.right=n:s.left=r,_(this,Gl)._uiManager.editComment(_(this,Gl),s)}finish(){_(this,eu)&&(_(this,eu).focus({focusVisible:_(this,Cg)}),te(this,Cg,!1))}isDeleted(){return _(this,Bf)||_(this,xd)===""}hasBeenEdited(){return this.isDeleted()||_(this,xd)!==_(this,Lk)}serialize(){return this.data}get data(){return{text:_(this,xd),date:_(this,Bb),deleted:_(this,Bf)}}set data(e){if(e===null){te(this,xd,""),te(this,Bf,!0);return}te(this,xd,e),te(this,Bb,new Date),te(this,Bf,!1)}setInitialText(e){te(this,Lk,e),this.data=e}toggle(e=!1){_(this,eu)&&(_(this,eu).disabled=!e)}shown(){}destroy(){var e;(e=_(this,eu))==null||e.remove(),te(this,eu,null),te(this,xd,""),te(this,Bb,null),te(this,Gl,null),te(this,Cg,!1),te(this,Bf,!1)}},eu=new WeakMap,Cg=new WeakMap,Gl=new WeakMap,Lk=new WeakMap,xd=new WeakMap,Bb=new WeakMap,Bf=new WeakMap,Pae);var zb,Tg,Fk,$k,Bk,zk,Uk,vd,Pg,bd,Og,wd,Jp,Twe,Pwe,Owe;const wq=class wq{constructor({container:e,isPinchingDisabled:r=null,isPinchingStopped:n=null,onPinchStart:s=null,onPinching:i=null,onPinchEnd:a=null,signal:o}){le(this,Jp);le(this,zb);le(this,Tg,!1);le(this,Fk,null);le(this,$k);le(this,Bk);le(this,zk);le(this,Uk);le(this,vd,null);le(this,Pg);le(this,bd,null);le(this,Og);le(this,wd,null);te(this,zb,e),te(this,Fk,n),te(this,$k,r),te(this,Bk,s),te(this,zk,i),te(this,Uk,a),te(this,Og,new AbortController),te(this,Pg,AbortSignal.any([o,_(this,Og).signal])),e.addEventListener("touchstart",ce(this,Jp,Twe).bind(this),{passive:!1,signal:_(this,Pg)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Cu.pixelRatio}destroy(){var e,r;(e=_(this,Og))==null||e.abort(),te(this,Og,null),(r=_(this,vd))==null||r.abort(),te(this,vd,null)}};zb=new WeakMap,Tg=new WeakMap,Fk=new WeakMap,$k=new WeakMap,Bk=new WeakMap,zk=new WeakMap,Uk=new WeakMap,vd=new WeakMap,Pg=new WeakMap,bd=new WeakMap,Og=new WeakMap,wd=new WeakMap,Jp=new WeakSet,Twe=function(e){var s,i,a;if((s=_(this,$k))!=null&&s.call(this))return;if(e.touches.length===1){if(_(this,vd))return;const o=te(this,vd,new AbortController),c=AbortSignal.any([_(this,Pg),o.signal]),u=_(this,zb),d={capture:!0,signal:c,passive:!1},h=f=>{var p;f.pointerType==="touch"&&((p=_(this,vd))==null||p.abort(),te(this,vd,null))};u.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(ls(f),h(f))},d),u.addEventListener("pointerup",h,d),u.addEventListener("pointercancel",h,d);return}if(!_(this,wd)){te(this,wd,new AbortController);const o=AbortSignal.any([_(this,Pg),_(this,wd).signal]),c=_(this,zb),u={signal:o,capture:!1,passive:!1};c.addEventListener("touchmove",ce(this,Jp,Pwe).bind(this),u);const d=ce(this,Jp,Owe).bind(this);c.addEventListener("touchend",d,u),c.addEventListener("touchcancel",d,u),u.capture=!0,c.addEventListener("pointerdown",ls,u),c.addEventListener("pointermove",ls,u),c.addEventListener("pointercancel",ls,u),c.addEventListener("pointerup",ls,u),(i=_(this,Bk))==null||i.call(this)}if(ls(e),e.touches.length!==2||(a=_(this,Fk))!=null&&a.call(this)){te(this,bd,null);return}let[r,n]=e.touches;r.identifier>n.identifier&&([r,n]=[n,r]),te(this,bd,{touch0X:r.screenX,touch0Y:r.screenY,touch1X:n.screenX,touch1Y:n.screenY})},Pwe=function(e){var w;if(!_(this,bd)||e.touches.length!==2)return;ls(e);let[r,n]=e.touches;r.identifier>n.identifier&&([r,n]=[n,r]);const{screenX:s,screenY:i}=r,{screenX:a,screenY:o}=n,c=_(this,bd),{touch0X:u,touch0Y:d,touch1X:h,touch1Y:f}=c,p=h-u,m=f-d,g=a-s,x=o-i,y=Math.hypot(g,x)||1,v=Math.hypot(p,m)||1;if(!_(this,Tg)&&Math.abs(v-y)<=wq.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=s,c.touch0Y=i,c.touch1X=a,c.touch1Y=o,!_(this,Tg)){te(this,Tg,!0);return}const b=[(s+a)/2,(i+o)/2];(w=_(this,zk))==null||w.call(this,b,v,y)},Owe=function(e){var r;e.touches.length>=2||(_(this,wd)&&(_(this,wd).abort(),te(this,wd,null),(r=_(this,Uk))==null||r.call(this)),_(this,bd)&&(ls(e),te(this,bd,null),te(this,Tg,!1)))};let xO=wq;var Ig,Kl,yn,ri,Ub,zf,Hk,Rg,ni,Mg,Sd,Uf,Vk,Dg,ao,Wk,Lg,_d,tu,Hb,Vb,Xo,Fg,qk,wI,Ct,R8,Gk,M8,CT,Iwe,Rwe,D8,TT,L8,Mwe,Dwe,Lwe,F8,Fwe,$8,$we,Bwe,zwe,B8,bS;const Wt=class Wt{constructor(e){le(this,Ct);le(this,Ig,null);le(this,Kl,null);le(this,yn,null);le(this,ri,null);le(this,Ub,!1);le(this,zf,null);le(this,Hk,"");le(this,Rg,!1);le(this,ni,null);le(this,Mg,null);le(this,Sd,null);le(this,Uf,null);le(this,Vk,"");le(this,Dg,!1);le(this,ao,null);le(this,Wk,!1);le(this,Lg,!1);le(this,_d,!1);le(this,tu,null);le(this,Hb,0);le(this,Vb,0);le(this,Xo,null);le(this,Fg,null);Ve(this,"isSelected",!1);Ve(this,"_isCopy",!1);Ve(this,"_editToolbar",null);Ve(this,"_initialOptions",Object.create(null));Ve(this,"_initialData",null);Ve(this,"_isVisible",!0);Ve(this,"_uiManager",null);Ve(this,"_focusEventsAllowed",!0);le(this,qk,!1);le(this,wI,Wt._zIndex++);this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null;const{rotation:r,rawDims:{pageWidth:n,pageHeight:s,pageX:i,pageY:a}}=this.parent.viewport;this.rotation=r,this.pageRotation=(360+r-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,s],this.pageTranslation=[i,a];const[o,c]=this.parentDimensions;this.x=e.x/o,this.y=e.y/c,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=Wt.prototype._resizeWithKeyboard,r=nx.TRANSLATE_SMALL,n=nx.TRANSLATE_BIG;return tr(this,"_resizerKeyboardManager",new $E([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-r,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[r,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-r]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,r]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,n]}],[["Escape","mac+Escape"],Wt.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return tr(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const r=new VSt({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});r.annotationElementId=e.annotationElementId,r.deleted=!0,r._uiManager.addToAnnotationStorage(r)}static initialize(e,r){if(Wt._l10n??(Wt._l10n=e),Wt._l10nResizer||(Wt._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),Wt._borderLineWidth!==-1)return;const n=getComputedStyle(document.documentElement);Wt._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,r){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,r){$r("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return _(this,qk)}set _isDraggable(e){var r;te(this,qk,e),(r=this.div)==null||r.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){const[e,r]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*r/(e*2),this.y+=this.width*e/(r*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*r/(e*2),this.y-=this.width*e/(r*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=_(this,wI)}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):ce(this,Ct,bS).call(this),this.parent=e}focusin(e){this._focusEventsAllowed&&(_(this,Dg)?te(this,Dg,!1):this.parent.setSelected(this))}focusout(e){var n;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const r=e.relatedTarget;r!=null&&r.closest(`#${this.id}`)||(e.preventDefault(),(n=this.parent)!=null&&n.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,r,n,s){const[i,a]=this.parentDimensions;[n,s]=this.screenToPageTranslation(n,s),this.x=(e+n)/i,this.y=(r+s)/a,this.fixAndSetPosition()}_moveAfterPaste(e,r){const[n,s]=this.parentDimensions;this.setAt(e*n,r*s,this.width*n,this.height*s),this._onTranslated()}translate(e,r){ce(this,Ct,R8).call(this,this.parentDimensions,e,r)}translateInPage(e,r){_(this,ao)||te(this,ao,[this.x,this.y,this.width,this.height]),ce(this,Ct,R8).call(this,this.pageDimensions,e,r),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,r){_(this,ao)||te(this,ao,[this.x,this.y,this.width,this.height]);const{div:n,parentDimensions:[s,i]}=this;if(this.x+=e/s,this.y+=r/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:h,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,h,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[c,u]=this.getBaseTranslation();a+=c,o+=u;const{style:d}=n;d.left=`${(100*a).toFixed(2)}%`,d.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),n.scrollIntoView({block:"nearest"})}_onTranslating(e,r){}_onTranslated(e,r){}get _hasBeenMoved(){return!!_(this,ao)&&(_(this,ao)[0]!==this.x||_(this,ao)[1]!==this.y)}get _hasBeenResized(){return!!_(this,ao)&&(_(this,ao)[2]!==this.width||_(this,ao)[3]!==this.height)}getBaseTranslation(){const[e,r]=this.parentDimensions,{_borderLineWidth:n}=Wt,s=n/e,i=n/r;switch(this.rotation){case 90:return[-s,i];case 180:return[s,i];case 270:return[s,-i];default:return[-s,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:r},pageDimensions:[n,s]}=this;let{x:i,y:a,width:o,height:c}=this;if(o*=n,c*=s,i*=n,a*=s,this._mustFixPosition)switch(e){case 0:i=la(i,0,n-o),a=la(a,0,s-c);break;case 90:i=la(i,0,n-c),a=la(a,o,s);break;case 180:i=la(i,o,n),a=la(a,c,s);break;case 270:i=la(i,c,n),a=la(a,0,s-o);break}this.x=i/=n,this.y=a/=s;const[u,d]=this.getBaseTranslation();i+=u,a+=d,r.left=`${(100*i).toFixed(2)}%`,r.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,r){var n;return ce(n=Wt,Gk,M8).call(n,e,r,this.parentRotation)}pageTranslationToScreen(e,r){var n;return ce(n=Wt,Gk,M8).call(n,e,r,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[r,n]}=this;return[r*e,n*e]}setDims(e,r){const[n,s]=this.parentDimensions,{style:i}=this.div;i.width=`${(100*e/n).toFixed(2)}%`,_(this,Rg)||(i.height=`${(100*r/s).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:r,width:n}=e,s=n.endsWith("%"),i=!_(this,Rg)&&r.endsWith("%");if(s&&i)return;const[a,o]=this.parentDimensions;s||(e.width=`${(100*parseFloat(n)/a).toFixed(2)}%`),!_(this,Rg)&&!i&&(e.height=`${(100*parseFloat(r)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(e*1e4)/1e4}_onResizing(){}altTextFinish(){var e;(e=_(this,yn))==null||e.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||_(this,Lg))return this._editToolbar;this._editToolbar=new k8(this),this.div.append(this._editToolbar.render()),this._editToolbar.addButton("comment",this.addCommentButton());const{toolbarButtons:e}=this;if(e)for(const[r,n]of e)await this._editToolbar.addButton(r,n);return this._editToolbar.addButton("delete"),this._editToolbar}removeEditToolbar(){var e;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(e=_(this,yn))==null||e.destroy())}addContainer(e){var n;const r=(n=this._editToolbar)==null?void 0:n.div;r?r.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return _(this,yn)||(yO.initialize(Wt._l10n),te(this,yn,new yO(this)),_(this,Ig)&&(_(this,yn).data=_(this,Ig),te(this,Ig,null))),_(this,yn)}get altTextData(){var e;return(e=_(this,yn))==null?void 0:e.data}set altTextData(e){_(this,yn)&&(_(this,yn).data=e)}get guessedAltText(){var e;return(e=_(this,yn))==null?void 0:e.guessedText}async setGuessedAltText(e){var r;await((r=_(this,yn))==null?void 0:r.setGuessedText(e))}serializeAltText(e){var r;return(r=_(this,yn))==null?void 0:r.serialize(e)}hasAltText(){return!!_(this,yn)&&!_(this,yn).isEmpty()}hasAltTextData(){var e;return((e=_(this,yn))==null?void 0:e.hasData())??!1}addCommentButton(){return _(this,ri)?_(this,ri):te(this,ri,new hC(this))}get commentColor(){return null}get comment(){const e=_(this,ri);return{text:e.data.text,date:e.data.date,deleted:e.isDeleted(),color:this.commentColor}}set comment(e){_(this,ri)||te(this,ri,new hC(this)),_(this,ri).data=e}setCommentData(e){_(this,ri)||te(this,ri,new hC(this)),_(this,ri).setInitialText(e)}get hasEditedComment(){var e;return(e=_(this,ri))==null?void 0:e.hasBeenEdited()}async editComment(){_(this,ri)||te(this,ri,new hC(this)),_(this,ri).edit()}addComment(e){this.hasEditedComment&&(e.popup={contents:this.comment.text,deleted:this.comment.deleted})}render(){var a;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=_(this,Ub)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),ce(this,Ct,$8).call(this);const[r,n]=this.parentDimensions;this.parentRotation%180!==0&&(e.style.maxWidth=`${(100*n/r).toFixed(2)}%`,e.style.maxHeight=`${(100*r/n).toFixed(2)}%`);const[s,i]=this.getInitialTranslation();return this.translate(s,i),xwe(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(_(this,Fg)||te(this,Fg,new xO({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:ce(this,Ct,Mwe).bind(this),onPinching:ce(this,Ct,Dwe).bind(this),onPinchEnd:ce(this,Ct,Lwe).bind(this),signal:this._uiManager._signal}))),(a=this._uiManager._editorUndoBar)==null||a.hide(),e}pointerdown(e){const{isMac:r}=wi.platform;if(e.button!==0||e.ctrlKey&&r){e.preventDefault();return}if(te(this,Dg,!0),this._isDraggable){ce(this,Ct,Fwe).call(this,e);return}ce(this,Ct,F8).call(this,e)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){_(this,tu)&&clearTimeout(_(this,tu)),te(this,tu,setTimeout(()=>{var e;te(this,tu,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,r,n){e.changeParent(this),this.x=r,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,r,n=this.rotation){const s=this.parentScale,[i,a]=this.pageDimensions,[o,c]=this.pageTranslation,u=e/s,d=r/s,h=this.x*i,f=this.y*a,p=this.width*i,m=this.height*a;switch(n){case 0:return[h+u+o,a-f-d-m+c,h+u+p+o,a-f-d+c];case 90:return[h+d+o,a-f+u+c,h+d+m+o,a-f+u+p+c];case 180:return[h-u-p+o,a-f+d+c,h-u+o,a-f+d+m+c];case 270:return[h-d-m+o,a-f-u-p+c,h-d+o,a-f-u+c];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,r){const[n,s,i,a]=e,o=i-n,c=a-s;switch(this.rotation){case 0:return[n,r-a,o,c];case 90:return[n,r-s,c,o];case 180:return[i,r-s,o,c];case 270:return[i,r-a,c,o];default:throw new Error("Invalid rotation")}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),te(this,Lg,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),te(this,Lg,!1),!0):!1}isInEditMode(){return _(this,Lg)}shouldGetKeyboardEvents(){return _(this,_d)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:r,bottom:n,right:s}=this.getClientDimensions(),{innerHeight:i,innerWidth:a}=window;return r<a&&s>0&&e<i&&n>0}rebuild(){ce(this,Ct,$8).call(this)}rotate(e){}resize(){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||""}}serialize(e=!1,r=null){$r("An editor must be serializable")}static async deserialize(e,r,n){const s=new this.prototype.constructor({parent:r,id:r.getNextId(),uiManager:n,annotationElementId:e.annotationElementId});s.rotation=e.rotation,te(s,Ig,e.accessibilityData),s._isCopy=e.isCopy||!1;const[i,a]=s.pageDimensions,[o,c,u,d]=s.getRectInCurrentCoords(e.rect,a);return s.x=o/i,s.y=c/a,s.width=u/i,s.height=d/a,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e,r;if((e=_(this,Uf))==null||e.abort(),te(this,Uf,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),_(this,tu)&&(clearTimeout(_(this,tu)),te(this,tu,null)),ce(this,Ct,bS).call(this),this.removeEditToolbar(),_(this,Xo)){for(const n of _(this,Xo).values())clearTimeout(n);te(this,Xo,null)}this.parent=null,(r=_(this,Fg))==null||r.destroy(),te(this,Fg,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(ce(this,Ct,Iwe).call(this),_(this,ni).classList.remove("hidden"))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),te(this,Sd,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const r=_(this,ni).children;if(!_(this,Kl)){te(this,Kl,Array.from(r));const a=ce(this,Ct,$we).bind(this),o=ce(this,Ct,Bwe).bind(this),c=this._uiManager._signal;for(const u of _(this,Kl)){const d=u.getAttribute("data-resizer-name");u.setAttribute("role","spinbutton"),u.addEventListener("keydown",a,{signal:c}),u.addEventListener("blur",o,{signal:c}),u.addEventListener("focus",ce(this,Ct,zwe).bind(this,d),{signal:c}),u.setAttribute("data-l10n-id",Wt._l10nResizer[d])}}const n=_(this,Kl)[0];let s=0;for(const a of r){if(a===n)break;s++}const i=(360-this.rotation+this.parentRotation)%360/90*(_(this,Kl).length/4);if(i!==s){if(i<s)for(let o=0;o<s-i;o++)_(this,ni).append(_(this,ni).firstChild);else if(i>s)for(let o=0;o<i-s;o++)_(this,ni).firstChild.before(_(this,ni).lastChild);let a=0;for(const o of r){const u=_(this,Kl)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",Wt._l10nResizer[u])}}ce(this,Ct,B8).call(this,0),te(this,_d,!0),_(this,ni).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(e,r){_(this,_d)&&ce(this,Ct,L8).call(this,_(this,Vk),{deltaX:e,deltaY:r,fromKeyboard:!0})}_stopResizingWithKeyboard(){ce(this,Ct,bS).call(this),this.div.focus()}select(){var e,r,n;if(!(this.isSelected&&this._editToolbar)){if(this.isSelected=!0,this.makeResizable(),(e=this.div)==null||e.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var s,i;(s=this.div)!=null&&s.classList.contains("selectedEditor")&&((i=this._editToolbar)==null||i.show())});return}(r=this._editToolbar)==null||r.show(),(n=_(this,yn))==null||n.toggleAltTextBadge(!1)}}unselect(){var e,r,n,s,i;this.isSelected&&(this.isSelected=!1,(e=_(this,ni))==null||e.classList.add("hidden"),(r=this.div)==null||r.classList.remove("selectedEditor"),(n=this.div)!=null&&n.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(s=this._editToolbar)==null||s.hide(),(i=_(this,yn))==null||i.toggleAltTextBadge(!0))}updateParams(e,r){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return _(this,Wk)}set isEditing(e){te(this,Wk,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,r){te(this,Rg,!0);const n=e/r,{style:s}=this.div;s.aspectRatio=n,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,r=!1){if(r){_(this,Xo)||te(this,Xo,new Map);const{action:n}=e;let s=_(this,Xo).get(n);s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(e),_(this,Xo).delete(n),_(this,Xo).size===0&&te(this,Xo,null)},Wt._telemetryTimeout),_(this,Xo).set(n,s);return}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),te(this,Ub,!1)}disable(){this.div&&(this.div.tabIndex=-1),te(this,Ub,!0)}renderAnnotationElement(e){let r=e.container.querySelector(".annotationContent");if(!r)r=document.createElement("div"),r.classList.add("annotationContent",this.editorType),e.container.prepend(r);else if(r.nodeName==="CANVAS"){const n=r;r=document.createElement("div"),r.classList.add("annotationContent",this.editorType),n.before(r)}return r}resetAnnotationElement(e){const{firstChild:r}=e.container;(r==null?void 0:r.nodeName)==="DIV"&&r.classList.contains("annotationContent")&&r.remove()}};Ig=new WeakMap,Kl=new WeakMap,yn=new WeakMap,ri=new WeakMap,Ub=new WeakMap,zf=new WeakMap,Hk=new WeakMap,Rg=new WeakMap,ni=new WeakMap,Mg=new WeakMap,Sd=new WeakMap,Uf=new WeakMap,Vk=new WeakMap,Dg=new WeakMap,ao=new WeakMap,Wk=new WeakMap,Lg=new WeakMap,_d=new WeakMap,tu=new WeakMap,Hb=new WeakMap,Vb=new WeakMap,Xo=new WeakMap,Fg=new WeakMap,qk=new WeakMap,wI=new WeakMap,Ct=new WeakSet,R8=function([e,r],n,s){[n,s]=this.screenToPageTranslation(n,s),this.x+=n/e,this.y+=s/r,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Gk=new WeakSet,M8=function(e,r,n){switch(n){case 90:return[r,-e];case 180:return[-e,-r];case 270:return[-r,e];default:return[e,r]}},CT=function(e){switch(e){case 90:{const[r,n]=this.pageDimensions;return[0,-r/n,n/r,0]}case 180:return[-1,0,0,-1];case 270:{const[r,n]=this.pageDimensions;return[0,r/n,-n/r,0]}default:return[1,0,0,1]}},Iwe=function(){if(_(this,ni))return;te(this,ni,document.createElement("div")),_(this,ni).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],r=this._uiManager._signal;for(const n of e){const s=document.createElement("div");_(this,ni).append(s),s.classList.add("resizer",n),s.setAttribute("data-resizer-name",n),s.addEventListener("pointerdown",ce(this,Ct,Rwe).bind(this,n),{signal:r}),s.addEventListener("contextmenu",Al,{signal:r}),s.tabIndex=-1}this.div.prepend(_(this,ni))},Rwe=function(e,r){var d;r.preventDefault();const{isMac:n}=wi.platform;if(r.button!==0||r.ctrlKey&&n)return;(d=_(this,yn))==null||d.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,te(this,Mg,[r.screenX,r.screenY]);const i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",ce(this,Ct,L8).bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",ls,{passive:!1,signal:a}),window.addEventListener("contextmenu",Al,{signal:a}),te(this,Sd,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,c=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(r.target).cursor;const u=()=>{var h;i.abort(),this.parent.togglePointerEvents(!0),(h=_(this,yn))==null||h.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=o,this.div.style.cursor=c,ce(this,Ct,TT).call(this)};window.addEventListener("pointerup",u,{signal:a}),window.addEventListener("blur",u,{signal:a})},D8=function(e,r,n,s){this.width=n,this.height=s,this.x=e,this.y=r;const[i,a]=this.parentDimensions;this.setDims(i*n,a*s),this.fixAndSetPosition(),this._onResized()},TT=function(){if(!_(this,Sd))return;const{savedX:e,savedY:r,savedWidth:n,savedHeight:s}=_(this,Sd);te(this,Sd,null);const i=this.x,a=this.y,o=this.width,c=this.height;i===e&&a===r&&o===n&&c===s||this.addCommands({cmd:ce(this,Ct,D8).bind(this,i,a,o,c),undo:ce(this,Ct,D8).bind(this,e,r,n,s),mustExec:!0})},L8=function(e,r){const[n,s]=this.parentDimensions,i=this.x,a=this.y,o=this.width,c=this.height,u=Wt.MIN_SIZE/n,d=Wt.MIN_SIZE/s,h=ce(this,Ct,CT).call(this,this.rotation),f=(K,G)=>[h[0]*K+h[2]*G,h[1]*K+h[3]*G],p=ce(this,Ct,CT).call(this,360-this.rotation),m=(K,G)=>[p[0]*K+p[2]*G,p[1]*K+p[3]*G];let g,x,y=!1,v=!1;switch(e){case"topLeft":y=!0,g=(K,G)=>[0,0],x=(K,G)=>[K,G];break;case"topMiddle":g=(K,G)=>[K/2,0],x=(K,G)=>[K/2,G];break;case"topRight":y=!0,g=(K,G)=>[K,0],x=(K,G)=>[0,G];break;case"middleRight":v=!0,g=(K,G)=>[K,G/2],x=(K,G)=>[0,G/2];break;case"bottomRight":y=!0,g=(K,G)=>[K,G],x=(K,G)=>[0,0];break;case"bottomMiddle":g=(K,G)=>[K/2,G],x=(K,G)=>[K/2,0];break;case"bottomLeft":y=!0,g=(K,G)=>[0,G],x=(K,G)=>[K,0];break;case"middleLeft":v=!0,g=(K,G)=>[0,G/2],x=(K,G)=>[K,G/2];break}const b=g(o,c),w=x(o,c);let S=f(...w);const k=Wt._round(i+S[0]),E=Wt._round(a+S[1]);let C=1,A=1,M,z;if(r.fromKeyboard)({deltaX:M,deltaY:z}=r);else{const{screenX:K,screenY:G}=r,[X,H]=_(this,Mg);[M,z]=this.screenToPageTranslation(K-X,G-H),_(this,Mg)[0]=K,_(this,Mg)[1]=G}if([M,z]=m(M/n,z/s),y){const K=Math.hypot(o,c);C=A=Math.max(Math.min(Math.hypot(w[0]-b[0]-M,w[1]-b[1]-z)/K,1/o,1/c),u/o,d/c)}else v?C=la(Math.abs(w[0]-b[0]-M),u,1)/o:A=la(Math.abs(w[1]-b[1]-z),d,1)/c;const P=Wt._round(o*C),W=Wt._round(c*A);S=f(...x(P,W));const N=k-S[0],U=E-S[1];_(this,ao)||te(this,ao,[this.x,this.y,this.width,this.height]),this.width=P,this.height=W,this.x=N,this.y=U,this.setDims(n*P,s*W),this.fixAndSetPosition(),this._onResizing()},Mwe=function(){var e;te(this,Sd,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(e=_(this,yn))==null||e.toggle(!1),this.parent.togglePointerEvents(!1)},Dwe=function(e,r,n){let i=.7*(n/r)+1-.7;if(i===1)return;const a=ce(this,Ct,CT).call(this,this.rotation),o=(k,E)=>[a[0]*k+a[2]*E,a[1]*k+a[3]*E],[c,u]=this.parentDimensions,d=this.x,h=this.y,f=this.width,p=this.height,m=Wt.MIN_SIZE/c,g=Wt.MIN_SIZE/u;i=Math.max(Math.min(i,1/f,1/p),m/f,g/p);const x=Wt._round(f*i),y=Wt._round(p*i);if(x===f&&y===p)return;_(this,ao)||te(this,ao,[d,h,f,p]);const v=o(f/2,p/2),b=Wt._round(d+v[0]),w=Wt._round(h+v[1]),S=o(x/2,y/2);this.x=b-S[0],this.y=w-S[1],this.width=x,this.height=y,this.setDims(c*x,u*y),this.fixAndSetPosition(),this._onResizing()},Lwe=function(){var e;(e=_(this,yn))==null||e.toggle(!0),this.parent.togglePointerEvents(!0),ce(this,Ct,TT).call(this)},F8=function(e){const{isMac:r}=wi.platform;e.ctrlKey&&!r||e.shiftKey||e.metaKey&&r?this.parent.toggleSelected(this):this.parent.setSelected(this)},Fwe=function(e){const{isSelected:r}=this;this._uiManager.setUpDragSession();let n=!1;const s=new AbortController,i=this._uiManager.combinedSignal(s),a={capture:!0,passive:!1,signal:i},o=u=>{s.abort(),te(this,zf,null),te(this,Dg,!1),this._uiManager.endDragSession()||ce(this,Ct,F8).call(this,u),n&&this._onStopDragging()};r&&(te(this,Hb,e.clientX),te(this,Vb,e.clientY),te(this,zf,e.pointerId),te(this,Hk,e.pointerType),window.addEventListener("pointermove",u=>{n||(n=!0,this._onStartDragging());const{clientX:d,clientY:h,pointerId:f}=u;if(f!==_(this,zf)){ls(u);return}const[p,m]=this.screenToPageTranslation(d-_(this,Hb),h-_(this,Vb));te(this,Hb,d),te(this,Vb,h),this._uiManager.dragSelectedEditors(p,m)},a),window.addEventListener("touchmove",ls,a),window.addEventListener("pointerdown",u=>{u.pointerType===_(this,Hk)&&(_(this,Fg)||u.isPrimary)&&o(u),ls(u)},a));const c=u=>{if(!_(this,zf)||_(this,zf)===u.pointerId){o(u);return}ls(u)};window.addEventListener("pointerup",c,{signal:i}),window.addEventListener("blur",c,{signal:i})},$8=function(){if(_(this,Uf)||!this.div)return;te(this,Uf,new AbortController);const e=this._uiManager.combinedSignal(_(this,Uf));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})},$we=function(e){Wt._resizerKeyboardManager.exec(this,e)},Bwe=function(e){var r;_(this,_d)&&((r=e.relatedTarget)==null?void 0:r.parentNode)!==_(this,ni)&&ce(this,Ct,bS).call(this)},zwe=function(e){te(this,Vk,_(this,_d)?e:"")},B8=function(e){if(_(this,Kl))for(const r of _(this,Kl))r.tabIndex=e},bS=function(){te(this,_d,!1),ce(this,Ct,B8).call(this,-1),ce(this,Ct,TT).call(this)},le(Wt,Gk),Ve(Wt,"_l10n",null),Ve(Wt,"_l10nResizer",null),Ve(Wt,"_borderLineWidth",-1),Ve(Wt,"_colorManager",new E8),Ve(Wt,"_zIndex",1),Ve(Wt,"_telemetryTimeout",1e3);let rn=Wt;class VSt extends rn{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ute=3285377520,Bo=4294901760,Ic=65535;class Uwe{constructor(e){this.h1=e?e&4294967295:Ute,this.h2=e?e&4294967295:Ute}update(e){let r,n;if(typeof e=="string"){r=new Uint8Array(e.length*2),n=0;for(let g=0,x=e.length;g<x;g++){const y=e.charCodeAt(g);y<=255?r[n++]=y:(r[n++]=y>>>8,r[n++]=y&255)}}else if(ArrayBuffer.isView(e))r=e.slice(),n=r.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const s=n>>2,i=n-s*4,a=new Uint32Array(r.buffer,0,s);let o=0,c=0,u=this.h1,d=this.h2;const h=3432918353,f=461845907,p=h&Ic,m=f&Ic;for(let g=0;g<s;g++)g&1?(o=a[g],o=o*h&Bo|o*p&Ic,o=o<<15|o>>>17,o=o*f&Bo|o*m&Ic,u^=o,u=u<<13|u>>>19,u=u*5+3864292196):(c=a[g],c=c*h&Bo|c*p&Ic,c=c<<15|c>>>17,c=c*f&Bo|c*m&Ic,d^=c,d=d<<13|d>>>19,d=d*5+3864292196);switch(o=0,i){case 3:o^=r[s*4+2]<<16;case 2:o^=r[s*4+1]<<8;case 1:o^=r[s*4],o=o*h&Bo|o*p&Ic,o=o<<15|o>>>17,o=o*f&Bo|o*m&Ic,s&1?u^=o:d^=o}this.h1=u,this.h2=d}hexdigest(){let e=this.h1,r=this.h2;return e^=r>>>1,e=e*3981806797&Bo|e*36045&Ic,r=r*4283543511&Bo|((r<<16|e>>>16)*2950163797&Bo)>>>16,e^=r>>>1,e=e*444984403&Bo|e*60499&Ic,r=r*3301882366&Bo|((r<<16|e>>>16)*3120437893&Bo)>>>16,e^=r>>>1,(e>>>0).toString(16).padStart(8,"0")+(r>>>0).toString(16).padStart(8,"0")}}const z8=Object.freeze({map:null,hash:"",transfer:void 0});var $g,Bg,si,SI,Hwe;class r7{constructor(){le(this,SI);le(this,$g,!1);le(this,Bg,null);le(this,si,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,r){const n=_(this,si).get(e);return n===void 0?r:Object.assign(r,n)}getRawValue(e){return _(this,si).get(e)}remove(e){if(_(this,si).delete(e),_(this,si).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const r of _(this,si).values())if(r instanceof rn)return;this.onAnnotationEditor(null)}}setValue(e,r){const n=_(this,si).get(e);let s=!1;if(n!==void 0)for(const[i,a]of Object.entries(r))n[i]!==a&&(s=!0,n[i]=a);else s=!0,_(this,si).set(e,r);s&&ce(this,SI,Hwe).call(this),r instanceof rn&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(r.constructor._type)}has(e){return _(this,si).has(e)}get size(){return _(this,si).size}resetModified(){_(this,$g)&&(te(this,$g,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Vwe(this)}get serializable(){if(_(this,si).size===0)return z8;const e=new Map,r=new Uwe,n=[],s=Object.create(null);let i=!1;for(const[a,o]of _(this,si)){const c=o instanceof rn?o.serialize(!1,s):o;c&&(e.set(a,c),r.update(`${a}:${JSON.stringify(c)}`),i||(i=!!c.bitmap))}if(i)for(const a of e.values())a.bitmap&&n.push(a.bitmap);return e.size>0?{map:e,hash:r.hexdigest(),transfer:n}:z8}get editorStats(){let e=null;const r=new Map;for(const n of _(this,si).values()){if(!(n instanceof rn))continue;const s=n.telemetryFinalData;if(!s)continue;const{type:i}=s;r.has(i)||r.set(i,Object.getPrototypeOf(n).constructor),e||(e=Object.create(null));const a=e[i]||(e[i]=new Map);for(const[o,c]of Object.entries(s)){if(o==="type")continue;let u=a.get(o);u||(u=new Map,a.set(o,u));const d=u.get(c)??0;u.set(c,d+1)}}for(const[n,s]of r)e[n]=s.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){te(this,Bg,null)}get modifiedIds(){if(_(this,Bg))return _(this,Bg);const e=[];for(const r of _(this,si).values())!(r instanceof rn)||!r.annotationElementId||!r.serialize()||e.push(r.annotationElementId);return te(this,Bg,{ids:new Set(e),hash:e.join(",")})}[Symbol.iterator](){return _(this,si).entries()}}$g=new WeakMap,Bg=new WeakMap,si=new WeakMap,SI=new WeakSet,Hwe=function(){_(this,$g)||(te(this,$g,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Kk;class Vwe extends r7{constructor(r){super();le(this,Kk);const{map:n,hash:s,transfer:i}=r.serializable,a=structuredClone(n,i?{transfer:i}:null);te(this,Kk,{map:a,hash:s,transfer:i})}get print(){$r("Should not call PrintAnnotationStorage.print")}get serializable(){return _(this,Kk)}get modifiedIds(){return tr(this,"modifiedIds",{ids:new Set,hash:""})}}Kk=new WeakMap;var Wb;class WSt{constructor({ownerDocument:e=globalThis.document,styleElement:r=null}){le(this,Wb,new Set);this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const r=this.styleElement.sheet;r.insertRule(e,r.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),_(this,Wb).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,disableFontFace:r,_inspectFont:n}){if(!(!e||_(this,Wb).has(e.loadedName))){if(us(!r,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:a}=e,o=new FontFace(s,i,a);this.addNativeFontFace(o);try{await o.load(),_(this,Wb).add(s),n==null||n(e)}catch{Ft(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}$r("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const n=e.createNativeFontFace();if(n){this.addNativeFontFace(n);try{await n.loaded}catch(s){throw Ft(`Failed to load font '${n.family}': '${s}'.`),e.disableFontFace=!0,s}}return}const r=e.createFontFaceRule();if(r){if(this.insertRule(r),this.isSyncFontLoadingSupported)return;await new Promise(n=>{const s=this._queueLoadingCallback(n);this._prepareFontLoadEvent(e,s)})}}get isFontLoadingAPISupported(){var r;const e=!!((r=this._document)!=null&&r.fonts);return tr(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return tr(this,"isSyncFontLoadingSupported",oa||wi.platform.isFirefox)}_queueLoadingCallback(e){function r(){for(us(!s.done,"completeRequest() cannot be called twice."),s.done=!0;n.length>0&&n[0].done;){const i=n.shift();setTimeout(i.callback,0)}}const{loadingRequests:n}=this,s={done:!1,complete:r,callback:e};return n.push(s),s}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return tr(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,r){function n(w,S){return w.charCodeAt(S)<<24|w.charCodeAt(S+1)<<16|w.charCodeAt(S+2)<<8|w.charCodeAt(S+3)&255}function s(w,S,k,E){const C=w.substring(0,S),A=w.substring(S+k);return C+E+A}let i,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const c=o.getContext("2d");let u=0;function d(w,S){if(++u>30){Ft("Load test font never loaded."),S();return}if(c.font="30px "+w,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){S();return}setTimeout(d.bind(null,w,S))}const h=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=s(f,976,h.length,h);const m=16,g=1482184792;let x=n(f,m);for(i=0,a=h.length-3;i<a;i+=4)x=x-g+n(h,i)|0;i<h.length&&(x=x-g+n(h+"XXX",i)|0),f=s(f,m,4,CSt(x));const y=`url(data:font/opentype;base64,${btoa(f)});`,v=`@font-face {font-family:"${h}";src:${y}}`;this.insertRule(v);const b=this._document.createElement("div");b.style.visibility="hidden",b.style.width=b.style.height="10px",b.style.position="absolute",b.style.top=b.style.left="0px";for(const w of[e.loadedName,h]){const S=this._document.createElement("span");S.textContent="Hi",S.style.fontFamily=w,b.append(S)}this._document.body.append(b),d(h,()=>{b.remove(),r.complete()})}}Wb=new WeakMap;class qSt{constructor(e,r=null){this.compiledGlyphs=Object.create(null);for(const n in e)this[n]=e[n];this._inspectFont=r}createNativeFontFace(){var r;if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const n={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(n.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,n)}return(r=this._inspectFont)==null||r.call(this,this),e}createFontFaceRule(){var n;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${dwe(this.data)});`;let r;if(!this.cssFontInfo)r=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let s=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(s+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),r=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${s}src:${e}}`}return(n=this._inspectFont)==null||n.call(this,this,e),r}getPathGenerator(e,r){if(this.compiledGlyphs[r]!==void 0)return this.compiledGlyphs[r];const n=this.loadedName+"_path_"+r;let s;try{s=e.get(n)}catch(a){Ft(`getPathGenerator - ignoring character: "${a}".`)}const i=new Path2D(s||"");return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[r]=i}}function GSt(t){if(t instanceof URL)return t.href;if(typeof t=="string"){if(oa)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function KSt(t){if(oa&&typeof Buffer<"u"&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if(typeof t=="string")return DE(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t=="object"&&!isNaN(t==null?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function fC(t){if(typeof t!="string")return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const U8=t=>typeof t=="object"&&Number.isInteger(t==null?void 0:t.num)&&t.num>=0&&Number.isInteger(t==null?void 0:t.gen)&&t.gen>=0,YSt=t=>typeof t=="object"&&typeof(t==null?void 0:t.name)=="string",XSt=RSt.bind(null,U8,YSt);var jd,_I;class JSt{constructor(){le(this,jd,new Map);le(this,_I,Promise.resolve())}postMessage(e,r){const n={data:structuredClone(e,r?{transfer:r}:null)};_(this,_I).then(()=>{for(const[s]of _(this,jd))s.call(this,n)})}addEventListener(e,r,n=null){let s=null;if((n==null?void 0:n.signal)instanceof AbortSignal){const{signal:i}=n;if(i.aborted){Ft("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(e,r);s=()=>i.removeEventListener("abort",a),i.addEventListener("abort",a)}_(this,jd).set(r,s)}removeEventListener(e,r){const n=_(this,jd).get(r);n==null||n(),_(this,jd).delete(r)}terminate(){for(const[,e]of _(this,jd))e==null||e();_(this,jd).clear()}}jd=new WeakMap,_I=new WeakMap;const pC={DATA:1,ERROR:2},ns={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Hte(){}function Ea(t){if(t instanceof qp||t instanceof S8||t instanceof $te||t instanceof mO||t instanceof V4)return t;switch(t instanceof Error||typeof t=="object"&&t!==null||$r('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new qp(t.message);case"InvalidPDFException":return new S8(t.message);case"PasswordException":return new $te(t.message,t.code);case"ResponseException":return new mO(t.message,t.status,t.missing);case"UnknownErrorException":return new V4(t.message,t.details)}return new V4(t.message,t.toString())}var qb,_l,Wwe,qwe,Gwe,PT;class wS{constructor(e,r,n){le(this,_l);le(this,qb,new AbortController);this.sourceName=e,this.targetName=r,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener("message",ce(this,_l,Wwe).bind(this),{signal:_(this,qb).signal})}on(e,r){const n=this.actionHandler;if(n[e])throw new Error(`There is already an actionName called "${e}"`);n[e]=r}send(e,r,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:r},n)}sendWithPromise(e,r,n){const s=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[s]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:s,data:r},n)}catch(a){i.reject(a)}return i.promise}sendWithStream(e,r,n,s){const i=this.streamId++,a=this.sourceName,o=this.targetName,c=this.comObj;return new ReadableStream({start:u=>{const d=Promise.withResolvers();return this.streamControllers[i]={controller:u,startCall:d,pullCall:null,cancelCall:null,isClosed:!1},c.postMessage({sourceName:a,targetName:o,action:e,streamId:i,data:r,desiredSize:u.desiredSize},s),d.promise},pull:u=>{const d=Promise.withResolvers();return this.streamControllers[i].pullCall=d,c.postMessage({sourceName:a,targetName:o,stream:ns.PULL,streamId:i,desiredSize:u.desiredSize}),d.promise},cancel:u=>{us(u instanceof Error,"cancel must have a valid reason");const d=Promise.withResolvers();return this.streamControllers[i].cancelCall=d,this.streamControllers[i].isClosed=!0,c.postMessage({sourceName:a,targetName:o,stream:ns.CANCEL,streamId:i,reason:Ea(u)}),d.promise}},n)}destroy(){var e;(e=_(this,qb))==null||e.abort(),te(this,qb,null)}}qb=new WeakMap,_l=new WeakSet,Wwe=function({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){ce(this,_l,Gwe).call(this,e);return}if(e.callback){const n=e.callbackId,s=this.callbackCapabilities[n];if(!s)throw new Error(`Cannot resolve callback ${n}`);if(delete this.callbackCapabilities[n],e.callback===pC.DATA)s.resolve(e.data);else if(e.callback===pC.ERROR)s.reject(Ea(e.reason));else throw new Error("Unexpected callback case");return}const r=this.actionHandler[e.action];if(!r)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const n=this.sourceName,s=e.sourceName,i=this.comObj;Promise.try(r,e.data).then(function(a){i.postMessage({sourceName:n,targetName:s,callback:pC.DATA,callbackId:e.callbackId,data:a})},function(a){i.postMessage({sourceName:n,targetName:s,callback:pC.ERROR,callbackId:e.callbackId,reason:Ea(a)})});return}if(e.streamId){ce(this,_l,qwe).call(this,e);return}r(e.data)},qwe=function(e){const r=e.streamId,n=this.sourceName,s=e.sourceName,i=this.comObj,a=this,o=this.actionHandler[e.action],c={enqueue(u,d=1,h){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=d,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:n,targetName:s,stream:ns.ENQUEUE,streamId:r,chunk:u},h)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:s,stream:ns.CLOSE,streamId:r}),delete a.streamSinks[r])},error(u){us(u instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:s,stream:ns.ERROR,streamId:r,reason:Ea(u)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};c.sinkCapability.resolve(),c.ready=c.sinkCapability.promise,this.streamSinks[r]=c,Promise.try(o,e.data,c).then(function(){i.postMessage({sourceName:n,targetName:s,stream:ns.START_COMPLETE,streamId:r,success:!0})},function(u){i.postMessage({sourceName:n,targetName:s,stream:ns.START_COMPLETE,streamId:r,reason:Ea(u)})})},Gwe=function(e){const r=e.streamId,n=this.sourceName,s=e.sourceName,i=this.comObj,a=this.streamControllers[r],o=this.streamSinks[r];switch(e.stream){case ns.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(Ea(e.reason));break;case ns.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(Ea(e.reason));break;case ns.PULL:if(!o){i.postMessage({sourceName:n,targetName:s,stream:ns.PULL_COMPLETE,streamId:r,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Hte).then(function(){i.postMessage({sourceName:n,targetName:s,stream:ns.PULL_COMPLETE,streamId:r,success:!0})},function(u){i.postMessage({sourceName:n,targetName:s,stream:ns.PULL_COMPLETE,streamId:r,reason:Ea(u)})});break;case ns.ENQUEUE:if(us(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(e.chunk);break;case ns.CLOSE:if(us(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),ce(this,_l,PT).call(this,a,r);break;case ns.ERROR:us(a,"error should have stream controller"),a.controller.error(Ea(e.reason)),ce(this,_l,PT).call(this,a,r);break;case ns.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(Ea(e.reason)),ce(this,_l,PT).call(this,a,r);break;case ns.CANCEL:if(!o)break;const c=Ea(e.reason);Promise.try(o.onCancel||Hte,c).then(function(){i.postMessage({sourceName:n,targetName:s,stream:ns.CANCEL_COMPLETE,streamId:r,success:!0})},function(u){i.postMessage({sourceName:n,targetName:s,stream:ns.CANCEL_COMPLETE,streamId:r,reason:Ea(u)})}),o.sinkCapability.reject(c),o.isCancelled=!0,delete this.streamSinks[r];break;default:throw new Error("Unexpected stream case")}},PT=async function(e,r){var n,s,i;await Promise.allSettled([(n=e.startCall)==null?void 0:n.promise,(s=e.pullCall)==null?void 0:s.promise,(i=e.cancelCall)==null?void 0:i.promise]),delete this.streamControllers[r]};var Yk;class Kwe{constructor({enableHWA:e=!1}){le(this,Yk,!1);te(this,Yk,e)}create(e,r){if(e<=0||r<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(e,r);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!_(this,Yk)})}}reset(e,r,n){if(!e.canvas)throw new Error("Canvas is not specified");if(r<=0||n<=0)throw new Error("Invalid canvas size");e.canvas.width=r,e.canvas.height=n}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,r){$r("Abstract method `_createCanvas` called.")}}Yk=new WeakMap;class QSt extends Kwe{constructor({ownerDocument:e=globalThis.document,enableHWA:r=!1}){super({enableHWA:r}),this._document=e}_createCanvas(e,r){const n=this._document.createElement("canvas");return n.width=e,n.height=r,n}}class Ywe{constructor({baseUrl:e=null,isCompressed:r=!0}){this.baseUrl=e,this.isCompressed=r}async fetch({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const r=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(r).then(n=>({cMapData:n,isCompressed:this.isCompressed})).catch(n=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${r}`)})}async _fetch(e){$r("Abstract method `_fetch` called.")}}class Vte extends Ywe{async _fetch(e){const r=await LE(e,this.isCompressed?"arraybuffer":"text");return r instanceof ArrayBuffer?new Uint8Array(r):DE(r)}}class Xwe{addFilter(e){return"none"}addHCMFilter(e,r){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,r,n,s,i){return"none"}destroy(e=!1){}}var zg,Gb,kd,Nd,Oi,Ug,Hg,ft,Ai,SS,iv,OT,av,Jwe,H8,ov,_S,jS,V8,kS;class ZSt extends Xwe{constructor({docId:r,ownerDocument:n=globalThis.document}){super();le(this,ft);le(this,zg);le(this,Gb);le(this,kd);le(this,Nd);le(this,Oi);le(this,Ug);le(this,Hg,0);te(this,Nd,r),te(this,Oi,n)}addFilter(r){if(!r)return"none";let n=_(this,ft,Ai).get(r);if(n)return n;const[s,i,a]=ce(this,ft,OT).call(this,r),o=r.length===1?s:`${s}${i}${a}`;if(n=_(this,ft,Ai).get(o),n)return _(this,ft,Ai).set(r,n),n;const c=`g_${_(this,Nd)}_transfer_map_${Ds(this,Hg)._++}`,u=ce(this,ft,av).call(this,c);_(this,ft,Ai).set(r,u),_(this,ft,Ai).set(o,u);const d=ce(this,ft,ov).call(this,c);return ce(this,ft,jS).call(this,s,i,a,d),u}addHCMFilter(r,n){var m;const s=`${r}-${n}`,i="base";let a=_(this,ft,SS).get(i);if((a==null?void 0:a.key)===s||(a?((m=a.filter)==null||m.remove(),a.key=s,a.url="none",a.filter=null):(a={key:s,url:"none",filter:null},_(this,ft,SS).set(i,a)),!r||!n))return a.url;const o=ce(this,ft,kS).call(this,r);r=jt.makeHexColor(...o);const c=ce(this,ft,kS).call(this,n);if(n=jt.makeHexColor(...c),_(this,ft,iv).style.color="",r==="#000000"&&n==="#ffffff"||r===n)return a.url;const u=new Array(256);for(let g=0;g<=255;g++){const x=g/255;u[g]=x<=.03928?x/12.92:((x+.055)/1.055)**2.4}const d=u.join(","),h=`g_${_(this,Nd)}_hcm_filter`,f=a.filter=ce(this,ft,ov).call(this,h);ce(this,ft,jS).call(this,d,d,d,f),ce(this,ft,H8).call(this,f);const p=(g,x)=>{const y=o[g]/255,v=c[g]/255,b=new Array(x+1);for(let w=0;w<=x;w++)b[w]=y+w/x*(v-y);return b.join(",")};return ce(this,ft,jS).call(this,p(0,5),p(1,5),p(2,5),f),a.url=ce(this,ft,av).call(this,h),a.url}addAlphaFilter(r){let n=_(this,ft,Ai).get(r);if(n)return n;const[s]=ce(this,ft,OT).call(this,[r]),i=`alpha_${s}`;if(n=_(this,ft,Ai).get(i),n)return _(this,ft,Ai).set(r,n),n;const a=`g_${_(this,Nd)}_alpha_map_${Ds(this,Hg)._++}`,o=ce(this,ft,av).call(this,a);_(this,ft,Ai).set(r,o),_(this,ft,Ai).set(i,o);const c=ce(this,ft,ov).call(this,a);return ce(this,ft,V8).call(this,s,c),o}addLuminosityFilter(r){let n=_(this,ft,Ai).get(r||"luminosity");if(n)return n;let s,i;if(r?([s]=ce(this,ft,OT).call(this,[r]),i=`luminosity_${s}`):i="luminosity",n=_(this,ft,Ai).get(i),n)return _(this,ft,Ai).set(r,n),n;const a=`g_${_(this,Nd)}_luminosity_map_${Ds(this,Hg)._++}`,o=ce(this,ft,av).call(this,a);_(this,ft,Ai).set(r,o),_(this,ft,Ai).set(i,o);const c=ce(this,ft,ov).call(this,a);return ce(this,ft,Jwe).call(this,c),r&&ce(this,ft,V8).call(this,s,c),o}addHighlightHCMFilter(r,n,s,i,a){var v;const o=`${n}-${s}-${i}-${a}`;let c=_(this,ft,SS).get(r);if((c==null?void 0:c.key)===o||(c?((v=c.filter)==null||v.remove(),c.key=o,c.url="none",c.filter=null):(c={key:o,url:"none",filter:null},_(this,ft,SS).set(r,c)),!n||!s))return c.url;const[u,d]=[n,s].map(ce(this,ft,kS).bind(this));let h=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),f=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[p,m]=[i,a].map(ce(this,ft,kS).bind(this));f<h&&([h,f,p,m]=[f,h,m,p]),_(this,ft,iv).style.color="";const g=(b,w,S)=>{const k=new Array(256),E=(f-h)/S,C=b/255,A=(w-b)/(255*S);let M=0;for(let z=0;z<=S;z++){const P=Math.round(h+z*E),W=C+z*A;for(let N=M;N<=P;N++)k[N]=W;M=P+1}for(let z=M;z<256;z++)k[z]=k[M-1];return k.join(",")},x=`g_${_(this,Nd)}_hcm_${r}_filter`,y=c.filter=ce(this,ft,ov).call(this,x);return ce(this,ft,H8).call(this,y),ce(this,ft,jS).call(this,g(p[0],m[0],5),g(p[1],m[1],5),g(p[2],m[2],5),y),c.url=ce(this,ft,av).call(this,x),c.url}destroy(r=!1){var n,s,i,a;r&&((n=_(this,Ug))!=null&&n.size)||((s=_(this,kd))==null||s.parentNode.parentNode.remove(),te(this,kd,null),(i=_(this,Gb))==null||i.clear(),te(this,Gb,null),(a=_(this,Ug))==null||a.clear(),te(this,Ug,null),te(this,Hg,0))}}zg=new WeakMap,Gb=new WeakMap,kd=new WeakMap,Nd=new WeakMap,Oi=new WeakMap,Ug=new WeakMap,Hg=new WeakMap,ft=new WeakSet,Ai=function(){return _(this,Gb)||te(this,Gb,new Map)},SS=function(){return _(this,Ug)||te(this,Ug,new Map)},iv=function(){if(!_(this,kd)){const r=_(this,Oi).createElement("div"),{style:n}=r;n.visibility="hidden",n.contain="strict",n.width=n.height=0,n.position="absolute",n.top=n.left=0,n.zIndex=-1;const s=_(this,Oi).createElementNS(Qu,"svg");s.setAttribute("width",0),s.setAttribute("height",0),te(this,kd,_(this,Oi).createElementNS(Qu,"defs")),r.append(s),s.append(_(this,kd)),_(this,Oi).body.append(r)}return _(this,kd)},OT=function(r){if(r.length===1){const u=r[0],d=new Array(256);for(let f=0;f<256;f++)d[f]=u[f]/255;const h=d.join(",");return[h,h,h]}const[n,s,i]=r,a=new Array(256),o=new Array(256),c=new Array(256);for(let u=0;u<256;u++)a[u]=n[u]/255,o[u]=s[u]/255,c[u]=i[u]/255;return[a.join(","),o.join(","),c.join(",")]},av=function(r){if(_(this,zg)===void 0){te(this,zg,"");const n=_(this,Oi).URL;n!==_(this,Oi).baseURI&&(XM(n)?Ft('#createUrl: ignore "data:"-URL for performance reasons.'):te(this,zg,lwe(n,"")))}return`url(${_(this,zg)}#${r})`},Jwe=function(r){const n=_(this,Oi).createElementNS(Qu,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),r.append(n)},H8=function(r){const n=_(this,Oi).createElementNS(Qu,"feColorMatrix");n.setAttribute("type","matrix"),n.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),r.append(n)},ov=function(r){const n=_(this,Oi).createElementNS(Qu,"filter");return n.setAttribute("color-interpolation-filters","sRGB"),n.setAttribute("id",r),_(this,ft,iv).append(n),n},_S=function(r,n,s){const i=_(this,Oi).createElementNS(Qu,n);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),r.append(i)},jS=function(r,n,s,i){const a=_(this,Oi).createElementNS(Qu,"feComponentTransfer");i.append(a),ce(this,ft,_S).call(this,a,"feFuncR",r),ce(this,ft,_S).call(this,a,"feFuncG",n),ce(this,ft,_S).call(this,a,"feFuncB",s)},V8=function(r,n){const s=_(this,Oi).createElementNS(Qu,"feComponentTransfer");n.append(s),ce(this,ft,_S).call(this,s,"feFuncA",r)},kS=function(r){return _(this,ft,iv).style.color=r,JM(getComputedStyle(_(this,ft,iv)).getPropertyValue("color"))};class Qwe{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const r=`${this.baseUrl}${e}`;return this._fetch(r).catch(n=>{throw new Error(`Unable to load font data at: ${r}`)})}async _fetch(e){$r("Abstract method `_fetch` called.")}}class Wte extends Qwe{async _fetch(e){const r=await LE(e,"arraybuffer");return new Uint8Array(r)}}class Zwe{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!e)throw new Error("Wasm filename must be specified.");const r=`${this.baseUrl}${e}`;return this._fetch(r).catch(n=>{throw new Error(`Unable to load wasm data at: ${r}`)})}async _fetch(e){$r("Abstract method `_fetch` called.")}}class qte extends Zwe{async _fetch(e){const r=await LE(e,"arraybuffer");return new Uint8Array(r)}}oa&&Ft("Please use the `legacy` build in Node.js environments.");async function n7(t){const r=await process.getBuiltinModule("fs").promises.readFile(t);return new Uint8Array(r)}class e_t extends Xwe{}class t_t extends Kwe{_createCanvas(e,r){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,r)}}class r_t extends Ywe{async _fetch(e){return n7(e)}}class n_t extends Qwe{async _fetch(e){return n7(e)}}class s_t extends Zwe{async _fetch(e){return n7(e)}}const di={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function W8(t,e){if(!e)return;const r=e[2]-e[0],n=e[3]-e[1],s=new Path2D;s.rect(e[0],e[1],r,n),t.clip(s)}class s7{isModifyingCurrentTransform(){return!1}getPattern(){$r("Abstract method `getPattern` called.")}}class i_t extends s7{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let r;this._type==="axial"?r=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(r=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const n of this._colorStops)r.addColorStop(n[0],n[1]);return r}getPattern(e,r,n,s){let i;if(s===di.STROKE||s===di.FILL){const a=r.current.getClippedPathBoundingBox(s,kn(e))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,c=Math.ceil(a[3]-a[1])||1,u=r.cachedCanvases.getCanvas("pattern",o,c),d=u.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-a[0],-a[1]),n=jt.transform(n,[1,0,0,1,a[0],a[1]]),d.transform(...r.baseTransform),this.matrix&&d.transform(...this.matrix),W8(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),i=e.createPattern(u.canvas,"no-repeat");const h=new DOMMatrix(n);i.setTransform(h)}else W8(e,this._bbox),i=this._createGradient(e);return i}}function G4(t,e,r,n,s,i,a,o){const c=e.coords,u=e.colors,d=t.data,h=t.width*4;let f;c[r+1]>c[n+1]&&(f=r,r=n,n=f,f=i,i=a,a=f),c[n+1]>c[s+1]&&(f=n,n=s,s=f,f=a,a=o,o=f),c[r+1]>c[n+1]&&(f=r,r=n,n=f,f=i,i=a,a=f);const p=(c[r]+e.offsetX)*e.scaleX,m=(c[r+1]+e.offsetY)*e.scaleY,g=(c[n]+e.offsetX)*e.scaleX,x=(c[n+1]+e.offsetY)*e.scaleY,y=(c[s]+e.offsetX)*e.scaleX,v=(c[s+1]+e.offsetY)*e.scaleY;if(m>=v)return;const b=u[i],w=u[i+1],S=u[i+2],k=u[a],E=u[a+1],C=u[a+2],A=u[o],M=u[o+1],z=u[o+2],P=Math.round(m),W=Math.round(v);let N,U,K,G,X,H,B,L;for(let F=P;F<=W;F++){if(F<x){const D=F<m?0:(m-F)/(m-x);N=p-(p-g)*D,U=b-(b-k)*D,K=w-(w-E)*D,G=S-(S-C)*D}else{let D;F>v?D=1:x===v?D=0:D=(x-F)/(x-v),N=g-(g-y)*D,U=k-(k-A)*D,K=E-(E-M)*D,G=C-(C-z)*D}let V;F<m?V=0:F>v?V=1:V=(m-F)/(m-v),X=p-(p-y)*V,H=b-(b-A)*V,B=w-(w-M)*V,L=S-(S-z)*V;const Y=Math.round(Math.min(N,X)),ie=Math.round(Math.max(N,X));let Q=h*F+Y*4;for(let D=Y;D<=ie;D++)V=(N-D)/(N-X),V<0?V=0:V>1&&(V=1),d[Q++]=U-(U-H)*V|0,d[Q++]=K-(K-B)*V|0,d[Q++]=G-(G-L)*V|0,d[Q++]=255}}function a_t(t,e,r){const n=e.coords,s=e.colors;let i,a;switch(e.type){case"lattice":const o=e.verticesPerRow,c=Math.floor(n.length/o)-1,u=o-1;for(i=0;i<c;i++){let d=i*o;for(let h=0;h<u;h++,d++)G4(t,r,n[d],n[d+1],n[d+o],s[d],s[d+1],s[d+o]),G4(t,r,n[d+o+1],n[d+1],n[d+o],s[d+o+1],s[d+1],s[d+o])}break;case"triangles":for(i=0,a=n.length;i<a;i+=3)G4(t,r,n[i],n[i+1],n[i+2],s[i],s[i+1],s[i+2]);break;default:throw new Error("illegal figure")}}class o_t extends s7{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[6],this._background=e[7],this.matrix=null}_createMeshCanvas(e,r,n){const o=Math.floor(this._bounds[0]),c=Math.floor(this._bounds[1]),u=Math.ceil(this._bounds[2])-o,d=Math.ceil(this._bounds[3])-c,h=Math.min(Math.ceil(Math.abs(u*e[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(d*e[1]*1.1)),3e3),p=u/h,m=d/f,g={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-c,scaleX:1/p,scaleY:1/m},x=h+2*2,y=f+2*2,v=n.getCanvas("mesh",x,y),b=v.context,w=b.createImageData(h,f);if(r){const k=w.data;for(let E=0,C=k.length;E<C;E+=4)k[E]=r[0],k[E+1]=r[1],k[E+2]=r[2],k[E+3]=255}for(const k of this._figures)a_t(w,k,g);return b.putImageData(w,2,2),{canvas:v.canvas,offsetX:o-2*p,offsetY:c-2*m,scaleX:p,scaleY:m}}isModifyingCurrentTransform(){return!0}getPattern(e,r,n,s){W8(e,this._bbox);const i=new Float32Array(2);if(s===di.SHADING)jt.singularValueDecompose2dScale(kn(e),i);else if(this.matrix){jt.singularValueDecompose2dScale(this.matrix,i);const[o,c]=i;jt.singularValueDecompose2dScale(r.baseTransform,i),i[0]*=o,i[1]*=c}else jt.singularValueDecompose2dScale(r.baseTransform,i);const a=this._createMeshCanvas(i,s===di.SHADING?null:this._background,r.cachedCanvases);return s!==di.SHADING&&(e.setTransform(...r.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(a.offsetX,a.offsetY),e.scale(a.scaleX,a.scaleY),e.createPattern(a.canvas,"no-repeat")}}class l_t extends s7{getPattern(){return"hotpink"}}function c_t(t){switch(t[0]){case"RadialAxial":return new i_t(t);case"Mesh":return new o_t(t);case"Dummy":return new l_t}throw new Error(`Unknown IR type: ${t[0]}`)}const Gte={COLORED:1,UNCOLORED:2},jI=class jI{constructor(e,r,n,s){this.color=e[1],this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.ctx=r,this.canvasGraphicsFactory=n,this.baseTransform=s}createPatternCanvas(e){const{bbox:r,operatorList:n,paintType:s,tilingType:i,color:a,canvasGraphicsFactory:o}=this;let{xstep:c,ystep:u}=this;c=Math.abs(c),u=Math.abs(u),YM("TilingType: "+i);const d=r[0],h=r[1],f=r[2],p=r[3],m=f-d,g=p-h,x=new Float32Array(2);jt.singularValueDecompose2dScale(this.matrix,x);const[y,v]=x;jt.singularValueDecompose2dScale(this.baseTransform,x);const b=y*x[0],w=v*x[1];let S=m,k=g,E=!1,C=!1;const A=Math.ceil(c*b),M=Math.ceil(u*w),z=Math.ceil(m*b),P=Math.ceil(g*w);A>=z?S=c:E=!0,M>=P?k=u:C=!0;const W=this.getSizeAndScale(S,this.ctx.canvas.width,b),N=this.getSizeAndScale(k,this.ctx.canvas.height,w),U=e.cachedCanvases.getCanvas("pattern",W.size,N.size),K=U.context,G=o.createCanvasGraphics(K);if(G.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(G,s,a),K.translate(-W.scale*d,-N.scale*h),G.transform(W.scale,0,0,N.scale,0,0),K.save(),this.clipBbox(G,d,h,f,p),G.baseTransform=kn(G.ctx),G.executeOperatorList(n),G.endDrawing(),K.restore(),E||C){const X=U.canvas;E&&(S=c),C&&(k=u);const H=this.getSizeAndScale(S,this.ctx.canvas.width,b),B=this.getSizeAndScale(k,this.ctx.canvas.height,w),L=H.size,F=B.size,V=e.cachedCanvases.getCanvas("pattern-workaround",L,F),Y=V.context,ie=E?Math.floor(m/c):0,Q=C?Math.floor(g/u):0;for(let D=0;D<=ie;D++)for(let R=0;R<=Q;R++)Y.drawImage(X,L*D,F*R,L,F,0,0,L,F);return{canvas:V.canvas,scaleX:H.scale,scaleY:B.scale,offsetX:d,offsetY:h}}return{canvas:U.canvas,scaleX:W.scale,scaleY:N.scale,offsetX:d,offsetY:h}}getSizeAndScale(e,r,n){const s=Math.max(jI.MAX_PATTERN_SIZE,r);let i=Math.ceil(e*n);return i>=s?i=s:n=i/e,{scale:n,size:i}}clipBbox(e,r,n,s,i){const a=s-r,o=i-n;e.ctx.rect(r,n,a,o),jt.axialAlignedBoundingBox([r,n,s,i],kn(e.ctx),e.current.minMax),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,r,n){const s=e.ctx,i=e.current;switch(r){case Gte.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;s.fillStyle=i.fillColor=a,s.strokeStyle=i.strokeColor=o;break;case Gte.UNCOLORED:s.fillStyle=s.strokeStyle=n,i.fillColor=i.strokeColor=n;break;default:throw new ASt(`Unsupported paint type: ${r}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,r,n,s){let i=n;s!==di.SHADING&&(i=jt.transform(i,r.baseTransform),this.matrix&&(i=jt.transform(i,this.matrix)));const a=this.createPatternCanvas(r);let o=new DOMMatrix(i);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const c=e.createPattern(a.canvas,"repeat");return c.setTransform(o),c}};Ve(jI,"MAX_PATTERN_SIZE",3e3);let q8=jI;function u_t({src:t,srcPos:e=0,dest:r,width:n,height:s,nonBlackColor:i=4294967295,inverseDecode:a=!1}){const o=wi.isLittleEndian?4278190080:255,[c,u]=a?[i,o]:[o,i],d=n>>3,h=n&7,f=t.length;r=new Uint32Array(r.buffer);let p=0;for(let m=0;m<s;m++){for(const x=e+d;e<x;e++){const y=e<f?t[e]:255;r[p++]=y&128?u:c,r[p++]=y&64?u:c,r[p++]=y&32?u:c,r[p++]=y&16?u:c,r[p++]=y&8?u:c,r[p++]=y&4?u:c,r[p++]=y&2?u:c,r[p++]=y&1?u:c}if(h===0)continue;const g=e<f?t[e++]:255;for(let x=0;x<h;x++)r[p++]=g&1<<7-x?u:c}return{srcPos:e,destPos:p}}const Kte=16,Yte=100,d_t=15,Xte=10,Ma=16,K4=new DOMMatrix,So=new Float32Array(2),zv=new Float32Array([1/0,1/0,-1/0,-1/0]);function h_t(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(r,n){e.translate(r,n),this.__originalTranslate(r,n)},t.scale=function(r,n){e.scale(r,n),this.__originalScale(r,n)},t.transform=function(r,n,s,i,a,o){e.transform(r,n,s,i,a,o),this.__originalTransform(r,n,s,i,a,o)},t.setTransform=function(r,n,s,i,a,o){e.setTransform(r,n,s,i,a,o),this.__originalSetTransform(r,n,s,i,a,o)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(r){e.rotate(r),this.__originalRotate(r)},t.clip=function(r){e.clip(r),this.__originalClip(r)},t.moveTo=function(r,n){e.moveTo(r,n),this.__originalMoveTo(r,n)},t.lineTo=function(r,n){e.lineTo(r,n),this.__originalLineTo(r,n)},t.bezierCurveTo=function(r,n,s,i,a,o){e.bezierCurveTo(r,n,s,i,a,o),this.__originalBezierCurveTo(r,n,s,i,a,o)},t.rect=function(r,n,s,i){e.rect(r,n,s,i),this.__originalRect(r,n,s,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}class f_t{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,r,n){let s;return this.cache[e]!==void 0?(s=this.cache[e],this.canvasFactory.reset(s,r,n)):(s=this.canvasFactory.create(r,n),this.cache[e]=s),s}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const r=this.cache[e];this.canvasFactory.destroy(r),delete this.cache[e]}}}function mC(t,e,r,n,s,i,a,o,c,u){const[d,h,f,p,m,g]=kn(t);if(h===0&&f===0){const v=a*d+m,b=Math.round(v),w=o*p+g,S=Math.round(w),k=(a+c)*d+m,E=Math.abs(Math.round(k)-b)||1,C=(o+u)*p+g,A=Math.abs(Math.round(C)-S)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),b,S),t.drawImage(e,r,n,s,i,0,0,E,A),t.setTransform(d,h,f,p,m,g),[E,A]}if(d===0&&p===0){const v=o*f+m,b=Math.round(v),w=a*h+g,S=Math.round(w),k=(o+u)*f+m,E=Math.abs(Math.round(k)-b)||1,C=(a+c)*h+g,A=Math.abs(Math.round(C)-S)||1;return t.setTransform(0,Math.sign(h),Math.sign(f),0,b,S),t.drawImage(e,r,n,s,i,0,0,A,E),t.setTransform(d,h,f,p,m,g),[A,E]}t.drawImage(e,r,n,s,i,a,o,c,u);const x=Math.hypot(d,h),y=Math.hypot(f,p);return[x*c,y*u]}class Jte{constructor(e,r){Ve(this,"alphaIsShape",!1);Ve(this,"fontSize",0);Ve(this,"fontSizeScale",1);Ve(this,"textMatrix",null);Ve(this,"textMatrixScale",1);Ve(this,"fontMatrix",w8);Ve(this,"leading",0);Ve(this,"x",0);Ve(this,"y",0);Ve(this,"lineX",0);Ve(this,"lineY",0);Ve(this,"charSpacing",0);Ve(this,"wordSpacing",0);Ve(this,"textHScale",1);Ve(this,"textRenderingMode",Ei.FILL);Ve(this,"textRise",0);Ve(this,"fillColor","#000000");Ve(this,"strokeColor","#000000");Ve(this,"patternFill",!1);Ve(this,"patternStroke",!1);Ve(this,"fillAlpha",1);Ve(this,"strokeAlpha",1);Ve(this,"lineWidth",1);Ve(this,"activeSMask",null);Ve(this,"transferMaps","none");this.clipBox=new Float32Array([0,0,e,r]),this.minMax=zv.slice()}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e.minMax=this.minMax.slice(),e}getPathBoundingBox(e=di.FILL,r=null){const n=this.minMax.slice();if(e===di.STROKE){r||$r("Stroke bounding box must include transform."),jt.singularValueDecompose2dScale(r,So);const s=So[0]*this.lineWidth/2,i=So[1]*this.lineWidth/2;n[0]-=s,n[1]-=i,n[2]+=s,n[3]+=i}return n}updateClipFromPath(){const e=jt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0),this.minMax.set(zv,0)}getClippedPathBoundingBox(e=di.FILL,r=null){return jt.intersect(this.clipBox,this.getPathBoundingBox(e,r))}}function Qte(t,e){if(e instanceof ImageData){t.putImageData(e,0,0);return}const r=e.height,n=e.width,s=r%Ma,i=(r-s)/Ma,a=s===0?i:i+1,o=t.createImageData(n,Ma);let c=0,u;const d=e.data,h=o.data;let f,p,m,g;if(e.kind===_T.GRAYSCALE_1BPP){const x=d.byteLength,y=new Uint32Array(h.buffer,0,h.byteLength>>2),v=y.length,b=n+7>>3,w=4294967295,S=wi.isLittleEndian?4278190080:255;for(f=0;f<a;f++){for(m=f<i?Ma:s,u=0,p=0;p<m;p++){const k=x-c;let E=0;const C=k>b?n:k*8-7,A=C&-8;let M=0,z=0;for(;E<A;E+=8)z=d[c++],y[u++]=z&128?w:S,y[u++]=z&64?w:S,y[u++]=z&32?w:S,y[u++]=z&16?w:S,y[u++]=z&8?w:S,y[u++]=z&4?w:S,y[u++]=z&2?w:S,y[u++]=z&1?w:S;for(;E<C;E++)M===0&&(z=d[c++],M=128),y[u++]=z&M?w:S,M>>=1}for(;u<v;)y[u++]=0;t.putImageData(o,0,f*Ma)}}else if(e.kind===_T.RGBA_32BPP){for(p=0,g=n*Ma*4,f=0;f<i;f++)h.set(d.subarray(c,c+g)),c+=g,t.putImageData(o,0,p),p+=Ma;f<a&&(g=n*s*4,h.set(d.subarray(c,c+g)),t.putImageData(o,0,p))}else if(e.kind===_T.RGB_24BPP)for(m=Ma,g=n*m,f=0;f<a;f++){for(f>=i&&(m=s,g=n*m),u=0,p=g;p--;)h[u++]=d[c++],h[u++]=d[c++],h[u++]=d[c++],h[u++]=255;t.putImageData(o,0,f*Ma)}else throw new Error(`bad image kind: ${e.kind}`)}function Zte(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}const r=e.height,n=e.width,s=r%Ma,i=(r-s)/Ma,a=s===0?i:i+1,o=t.createImageData(n,Ma);let c=0;const u=e.data,d=o.data;for(let h=0;h<a;h++){const f=h<i?Ma:s;({srcPos:c}=u_t({src:u,srcPos:c,dest:d,width:n,height:f,nonBlackColor:0})),t.putImageData(o,0,h*Ma)}}function W1(t,e){const r=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const n of r)t[n]!==void 0&&(e[n]=t[n]);t.setLineDash!==void 0&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function gC(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",t.setLineDash!==void 0&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;e!=="none"&&e!==""&&(t.filter="none")}function ere(t,e){if(e)return!0;jt.singularValueDecompose2dScale(t,So);const r=Math.fround(Cu.pixelRatio*Gp.PDF_TO_CSS_UNITS);return So[0]<=r&&So[1]<=r}const p_t=["butt","round","square"],m_t=["miter","round","bevel"],g_t={},tre={};var Sc,G8,K8,Y8;const Sq=class Sq{constructor(e,r,n,s,i,{optionalContentConfig:a,markedContentStack:o=null},c,u){le(this,Sc);this.ctx=e,this.current=new Jte(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=r,this.objs=n,this.canvasFactory=s,this.filterFactory=i,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedCanvases=new f_t(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=c,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=u,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,r=null){return typeof e=="string"?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):r}beginDrawing({transform:e,viewport:r,transparency:n=!1,background:s=null}){const i=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,i,a),this.ctx.fillStyle=o,n){const c=this.cachedCanvases.getCanvas("transparent",i,a);this.compositeCtx=this.ctx,this.transparentCanvas=c.canvas,this.ctx=c.context,this.ctx.save(),this.ctx.transform(...kn(this.compositeCtx))}this.ctx.save(),gC(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...r.transform),this.viewportScale=r.scale,this.baseTransform=kn(this.ctx)}executeOperatorList(e,r,n,s){const i=e.argsArray,a=e.fnArray;let o=r||0;const c=i.length;if(c===o)return o;const u=c-o>Xte&&typeof n=="function",d=u?Date.now()+d_t:0;let h=0;const f=this.commonObjs,p=this.objs;let m;for(;;){if(s!==void 0&&o===s.nextBreakPoint)return s.breakIt(o,n),o;if(m=a[o],m!==pO.dependency)this[m].apply(this,i[o]);else for(const g of i[o]){const x=g.startsWith("g_")?f:p;if(!x.has(g))return x.get(g,n),o}if(o++,o===c)return o;if(u&&++h>Xte){if(Date.now()>d)return n(),o;h=0}}}endDrawing(){ce(this,Sc,G8).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const r of e.values())typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement&&(r.width=r.height=0);e.clear()}this._cachedBitmapsMap.clear(),ce(this,Sc,K8).call(this)}_scaleImage(e,r){const n=e.width??e.displayWidth,s=e.height??e.displayHeight;let i=Math.max(Math.hypot(r[0],r[1]),1),a=Math.max(Math.hypot(r[2],r[3]),1),o=n,c=s,u="prescale1",d,h;for(;i>2&&o>1||a>2&&c>1;){let f=o,p=c;i>2&&o>1&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),i/=o/f),a>2&&c>1&&(p=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,a/=c/p),d=this.cachedCanvases.getCanvas(u,f,p),h=d.context,h.clearRect(0,0,f,p),h.drawImage(e,0,0,o,c,0,0,f,p),e=d.canvas,o=f,c=p,u=u==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:o,paintHeight:c}}_createMaskCanvas(e){const r=this.ctx,{width:n,height:s}=e,i=this.current.fillColor,a=this.current.patternFill,o=kn(r);let c,u,d,h;if((e.bitmap||e.data)&&e.count>1){const A=e.bitmap||e.data.buffer;u=JSON.stringify(a?o:[o.slice(0,4),i]),c=this._cachedBitmapsMap.get(A),c||(c=new Map,this._cachedBitmapsMap.set(A,c));const M=c.get(u);if(M&&!a){const z=Math.round(Math.min(o[0],o[2])+o[4]),P=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:M,offsetX:z,offsetY:P}}d=M}d||(h=this.cachedCanvases.getCanvas("maskCanvas",n,s),Zte(h.context,e));let f=jt.transform(o,[1/n,0,0,-1/s,0,0]);f=jt.transform(f,[1,0,0,1,0,-s]);const p=zv.slice();jt.axialAlignedBoundingBox([0,0,n,s],f,p);const[m,g,x,y]=p,v=Math.round(x-m)||1,b=Math.round(y-g)||1,w=this.cachedCanvases.getCanvas("fillCanvas",v,b),S=w.context,k=m,E=g;S.translate(-k,-E),S.transform(...f),d||(d=this._scaleImage(h.canvas,Oc(S)),d=d.img,c&&a&&c.set(u,d)),S.imageSmoothingEnabled=ere(kn(S),e.interpolate),mC(S,d,0,0,d.width,d.height,0,0,n,s),S.globalCompositeOperation="source-in";const C=jt.transform(Oc(S),[1,0,0,1,-k,-E]);return S.fillStyle=a?i.getPattern(r,this,C,di.FILL):i,S.fillRect(0,0,n,s),c&&!a&&(this.cachedCanvases.delete("fillCanvas"),c.set(u,w.canvas)),{canvas:w.canvas,offsetX:Math.round(k),offsetY:Math.round(E)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=p_t[e]}setLineJoin(e){this.ctx.lineJoin=m_t[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,r){const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=r)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[r,n]of e)switch(r){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.ctx.globalAlpha=this.current.fillAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,r=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(n,e,r);this.suspendedCtx=this.ctx;const i=this.ctx=s.context;i.setTransform(this.suspendedCtx.getTransform()),W1(this.suspendedCtx,i),h_t(i,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),W1(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const r=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,r,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,r,n,s){const i=s[0],a=s[1],o=s[2]-i,c=s[3]-a;o===0||c===0||(this.genericComposeSMask(r.context,n,o,c,r.subtype,r.backdrop,r.transferMap,i,a,r.offsetX,r.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore())}genericComposeSMask(e,r,n,s,i,a,o,c,u,d,h){let f=e.canvas,p=c-d,m=u-h;if(a)if(p<0||m<0||p+n>f.width||m+s>f.height){const x=this.cachedCanvases.getCanvas("maskExtension",n,s),y=x.context;y.drawImage(f,-p,-m),y.globalCompositeOperation="destination-atop",y.fillStyle=a,y.fillRect(0,0,n,s),y.globalCompositeOperation="source-over",f=x.canvas,p=m=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const x=new Path2D;x.rect(p,m,n,s),e.clip(x),e.globalCompositeOperation="destination-atop",e.fillStyle=a,e.fillRect(p,m,n,s),e.restore()}r.save(),r.globalAlpha=1,r.setTransform(1,0,0,1,0,0),i==="Alpha"&&o?r.filter=this.filterFactory.addAlphaFilter(o):i==="Luminosity"&&(r.filter=this.filterFactory.addLuminosityFilter(o));const g=new Path2D;g.rect(c,u,n,s),r.clip(g),r.globalCompositeOperation="destination-in",r.drawImage(f,p,m,n,s,c,u,n,s),r.restore()}save(){this.inSMaskMode&&W1(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){if(this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&W1(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(e,r,n,s,i,a){this.ctx.transform(e,r,n,s,i,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,r,n){let[s]=r;if(!n){s||(s=r[0]=new Path2D),this[e](s);return}if(!(s instanceof Path2D)){const i=r[0]=new Path2D;for(let a=0,o=s.length;a<o;)switch(s[a++]){case dC.moveTo:i.moveTo(s[a++],s[a++]);break;case dC.lineTo:i.lineTo(s[a++],s[a++]);break;case dC.curveTo:i.bezierCurveTo(s[a++],s[a++],s[a++],s[a++],s[a++],s[a++]);break;case dC.closePath:i.closePath();break;default:Ft(`Unrecognized drawing path operator: ${s[a-1]}`);break}s=i}jt.axialAlignedBoundingBox(n,kn(this.ctx),this.current.minMax),this[e](s)}closePath(){this.ctx.closePath()}stroke(e,r=!0){const n=this.ctx,s=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof s=="object"&&(s!=null&&s.getPattern)){const i=s.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=s.getPattern(n,this,Oc(n),di.STROKE),i){const a=new Path2D;a.addPath(e,n.getTransform().invertSelf().multiplySelf(i)),e=a}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);r&&this.consumePath(e,this.current.getClippedPathBoundingBox(di.STROKE,kn(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(e){this.stroke(e)}fill(e,r=!0){const n=this.ctx,s=this.current.fillColor,i=this.current.patternFill;let a=!1;if(i){const c=s.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.fillStyle=s.getPattern(n,this,Oc(n),di.FILL),c){const u=new Path2D;u.addPath(e,n.getTransform().invertSelf().multiplySelf(c)),e=u}a=!0}const o=this.current.getClippedPathBoundingBox();this.contentVisible&&o!==null&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),a&&n.restore(),r&&this.consumePath(e,o)}eoFill(e){this.pendingEOFill=!0,this.fill(e)}fillStroke(e){this.fill(e,!1),this.stroke(e,!1),this.consumePath(e)}eoFillStroke(e){this.pendingEOFill=!0,this.fillStroke(e)}closeFillStroke(e){this.fillStroke(e)}closeEOFillStroke(e){this.pendingEOFill=!0,this.fillStroke(e)}endPath(e){this.consumePath(e)}rawFillPath(e){this.ctx.fill(e)}clip(){this.pendingClip=g_t}eoClip(){this.pendingClip=tre}beginText(){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const e=this.pendingTextPaths,r=this.ctx;if(e===void 0)return;const n=new Path2D,s=r.getTransform().invertSelf();for(const{transform:i,x:a,y:o,fontSize:c,path:u}of e)u&&n.addPath(u,new DOMMatrix(i).preMultiplySelf(s).translate(a,o).scale(c,-c));r.clip(n),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,r){var d;const n=this.commonObjs.get(e),s=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(s.fontMatrix=n.fontMatrix||w8,(s.fontMatrix[0]===0||s.fontMatrix[3]===0)&&Ft("Invalid font matrix for font "+e),r<0?(r=-r,s.fontDirection=-1):s.fontDirection=1,this.current.font=n,this.current.fontSize=r,n.isType3Font)return;const i=n.loadedName||"sans-serif",a=((d=n.systemFontInfo)==null?void 0:d.css)||`"${i}", ${n.fallbackName}`;let o="normal";n.black?o="900":n.bold&&(o="bold");const c=n.italic?"italic":"normal";let u=r;r<Kte?u=Kte:r>Yte&&(u=Yte),this.current.fontSizeScale=r/u,this.ctx.font=`${c} ${o} ${u}px ${a}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,r){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=r}setLeadingMoveText(e,r){this.setLeading(-r),this.moveText(e,r)}setTextMatrix(e){const{current:r}=this;r.textMatrix=e,r.textMatrixScale=Math.hypot(e[0],e[1]),r.x=r.lineX=0,r.y=r.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,r,n,s,i){const a=this.ctx,o=this.current,c=o.font,u=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,h=u&Ei.FILL_STROKE_MASK,f=!!(u&Ei.ADD_TO_PATH_FLAG),p=o.patternFill&&!c.missingFile,m=o.patternStroke&&!c.missingFile;let g;if((c.disableFontFace||f||p||m)&&!c.missingFile&&(g=c.getPathGenerator(this.commonObjs,e)),g&&(c.disableFontFace||p||m)){a.save(),a.translate(r,n),a.scale(d,-d);let x;if((h===Ei.FILL||h===Ei.FILL_STROKE)&&(s?(x=a.getTransform(),a.setTransform(...s),a.fill(ce(this,Sc,Y8).call(this,g,x,s))):a.fill(g)),h===Ei.STROKE||h===Ei.FILL_STROKE)if(i){x||(x=a.getTransform()),a.setTransform(...i);const{a:y,b:v,c:b,d:w}=x,S=jt.inverseTransform(i),k=jt.transform([y,v,b,w,0,0],S);jt.singularValueDecompose2dScale(k,So),a.lineWidth*=Math.max(So[0],So[1])/d,a.stroke(ce(this,Sc,Y8).call(this,g,x,i))}else a.lineWidth/=d,a.stroke(g);a.restore()}else(h===Ei.FILL||h===Ei.FILL_STROKE)&&a.fillText(e,r,n),(h===Ei.STROKE||h===Ei.FILL_STROKE)&&a.strokeText(e,r,n);f&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:kn(a),x:r,y:n,fontSize:d,path:g})}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const r=e.getImageData(0,0,10,10).data;let n=!1;for(let s=3;s<r.length;s+=4)if(r[s]>0&&r[s]<255){n=!0;break}return tr(this,"isFontSubpixelAAEnabled",n)}showText(e){const r=this.current,n=r.font;if(n.isType3Font)return this.showType3Text(e);const s=r.fontSize;if(s===0)return;const i=this.ctx,a=r.fontSizeScale,o=r.charSpacing,c=r.wordSpacing,u=r.fontDirection,d=r.textHScale*u,h=e.length,f=n.vertical,p=f?1:-1,m=n.defaultVMetrics,g=s*r.fontMatrix[0],x=r.textRenderingMode===Ei.FILL&&!n.disableFontFace&&!r.patternFill;i.save(),r.textMatrix&&i.transform(...r.textMatrix),i.translate(r.x,r.y+r.textRise),u>0?i.scale(d,-1):i.scale(d,1);let y,v;if(r.patternFill){i.save();const E=r.fillColor.getPattern(i,this,Oc(i),di.FILL);y=kn(i),i.restore(),i.fillStyle=E}if(r.patternStroke){i.save();const E=r.strokeColor.getPattern(i,this,Oc(i),di.STROKE);v=kn(i),i.restore(),i.strokeStyle=E}let b=r.lineWidth;const w=r.textMatrixScale;if(w===0||b===0){const E=r.textRenderingMode&Ei.FILL_STROKE_MASK;(E===Ei.STROKE||E===Ei.FILL_STROKE)&&(b=this.getSinglePixelWidth())}else b/=w;if(a!==1&&(i.scale(a,a),b/=a),i.lineWidth=b,n.isInvalidPDFjsFont){const E=[];let C=0;for(const A of e)E.push(A.unicode),C+=A.width;i.fillText(E.join(""),0,0),r.x+=C*g*d,i.restore(),this.compose();return}let S=0,k;for(k=0;k<h;++k){const E=e[k];if(typeof E=="number"){S+=p*E*s/1e3;continue}let C=!1;const A=(E.isSpace?c:0)+o,M=E.fontChar,z=E.accent;let P,W,N=E.width;if(f){const K=E.vmetric||m,G=-(E.vmetric?K[1]:N*.5)*g,X=K[2]*g;N=K?-K[0]:N,P=G/a,W=(S+X)/a}else P=S/a,W=0;if(n.remeasure&&N>0){const K=i.measureText(M).width*1e3/s*a;if(N<K&&this.isFontSubpixelAAEnabled){const G=N/K;C=!0,i.save(),i.scale(G,1),P/=G}else N!==K&&(P+=(N-K)/2e3*s/a)}if(this.contentVisible&&(E.isInFont||n.missingFile)){if(x&&!z)i.fillText(M,P,W);else if(this.paintChar(M,P,W,y,v),z){const K=P+s*z.offset.x/a,G=W-s*z.offset.y/a;this.paintChar(z.fontChar,K,G,y,v)}}const U=f?N*g-A*u:N*g+A*u;S+=U,C&&i.restore()}f?r.y-=S:r.x+=S*d,i.restore(),this.compose()}showType3Text(e){const r=this.ctx,n=this.current,s=n.font,i=n.fontSize,a=n.fontDirection,o=s.vertical?1:-1,c=n.charSpacing,u=n.wordSpacing,d=n.textHScale*a,h=n.fontMatrix||w8,f=e.length,p=n.textRenderingMode===Ei.INVISIBLE;let m,g,x,y;if(!(p||i===0)){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,r.save(),n.textMatrix&&r.transform(...n.textMatrix),r.translate(n.x,n.y+n.textRise),r.scale(d,a),m=0;m<f;++m){if(g=e[m],typeof g=="number"){y=o*g*i/1e3,this.ctx.translate(y,0),n.x+=y*d;continue}const v=(g.isSpace?u:0)+c,b=s.charProcOperatorList[g.operatorListId];b?this.contentVisible&&(this.save(),r.scale(i,i),r.transform(...h),this.executeOperatorList(b),this.restore()):Ft(`Type3 character "${g.operatorListId}" is not available.`);const w=[g.width,0];jt.applyTransform(w,h),x=w[0]*i+v,r.translate(x,0),n.x+=x*d}r.restore()}}setCharWidth(e,r){}setCharWidthAndBounds(e,r,n,s,i,a){const o=new Path2D;o.rect(n,s,i-n,a-s),this.ctx.clip(o),this.endPath()}getColorN_Pattern(e){let r;if(e[0]==="TilingPattern"){const n=this.baseTransform||kn(this.ctx),s={createCanvasGraphics:i=>new Sq(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};r=new q8(e,this.ctx,s,n)}else r=this._getPattern(e[1],e[2]);return r}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e){this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e){this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,r=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=c_t(this.getObject(e)),this.cachedPatterns.set(e,n)),r&&(n.matrix=r),n}shadingFill(e){if(!this.contentVisible)return;const r=this.ctx;this.save();const n=this._getPattern(e);r.fillStyle=n.getPattern(r,this,Oc(r),di.SHADING);const s=Oc(r);if(s){const{width:i,height:a}=r.canvas,o=zv.slice();jt.axialAlignedBoundingBox([0,0,i,a],s,o);const[c,u,d,h]=o;this.ctx.fillRect(c,u,d-c,h-u)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){$r("Should not call beginInlineImage")}beginImageData(){$r("Should not call beginImageData")}paintFormXObjectBegin(e,r){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=kn(this.ctx),r)){jt.axialAlignedBoundingBox(r,this.baseTransform,this.current.minMax);const[n,s,i,a]=r,o=new Path2D;o.rect(n,s,i-n,a-s),this.ctx.clip(o),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const r=this.ctx;e.isolated||YM("TODO: Support non-isolated groups."),e.knockout&&Ft("Knockout groups not supported.");const n=kn(r);if(e.matrix&&r.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let s=zv.slice();jt.axialAlignedBoundingBox(e.bbox,kn(r),s);const i=[0,0,r.canvas.width,r.canvas.height];s=jt.intersect(s,i)||[0,0,0,0];const a=Math.floor(s[0]),o=Math.floor(s[1]),c=Math.max(Math.ceil(s[2])-a,1),u=Math.max(Math.ceil(s[3])-o,1);this.current.startNewPathAndClipBox([0,0,c,u]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);const h=this.cachedCanvases.getCanvas(d,c,u),f=h.context;f.translate(-a,-o),f.transform(...n);let p=new Path2D;const[m,g,x,y]=e.bbox;if(p.rect(m,g,x-m,y-g),e.matrix){const v=new Path2D;v.addPath(p,new DOMMatrix(e.matrix)),p=v}f.clip(p),e.smask?this.smaskStack.push({canvas:h.canvas,context:f,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(r.setTransform(1,0,0,1,0,0),r.translate(a,o),r.save()),W1(r,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(r),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const r=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const s=kn(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...s);const i=zv.slice();jt.axialAlignedBoundingBox([0,0,r.canvas.width,r.canvas.height],s,i),this.ctx.drawImage(r.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(e,r,n,s,i){if(ce(this,Sc,G8).call(this),gC(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),r){const a=r[2]-r[0],o=r[3]-r[1];if(i&&this.annotationCanvasMap){n=n.slice(),n[4]-=r[0],n[5]-=r[1],r=r.slice(),r[0]=r[1]=0,r[2]=a,r[3]=o,jt.singularValueDecompose2dScale(kn(this.ctx),So);const{viewportScale:c}=this,u=Math.ceil(a*this.outputScaleX*c),d=Math.ceil(o*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(u,d);const{canvas:h,context:f}=this.annotationCanvas;this.annotationCanvasMap.set(e,h),this.annotationCanvas.savedCtx=this.ctx,this.ctx=f,this.ctx.save(),this.ctx.setTransform(So[0],0,0,-So[1],0,o*So[1]),gC(this.ctx)}else{gC(this.ctx),this.endPath();const c=new Path2D;c.rect(r[0],r[1],a,o),this.ctx.clip(c)}}this.current=new Jte(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),ce(this,Sc,K8).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;const r=e.count;e=this.getObject(e.data,e),e.count=r;const n=this.ctx,s=this._createMaskCanvas(e),i=s.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(i,s.offsetX,s.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,r,n=0,s=0,i,a){if(!this.contentVisible)return;e=this.getObject(e.data,e);const o=this.ctx;o.save();const c=kn(o);o.transform(r,n,s,i,0,0);const u=this._createMaskCanvas(e);o.setTransform(1,0,0,1,u.offsetX-c[4],u.offsetY-c[5]);for(let d=0,h=a.length;d<h;d+=2){const f=jt.transform(c,[r,n,s,i,a[d],a[d+1]]);o.drawImage(u.canvas,f[4],f[5])}o.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;const r=this.ctx,n=this.current.fillColor,s=this.current.patternFill;for(const i of e){const{data:a,width:o,height:c,transform:u}=i,d=this.cachedCanvases.getCanvas("maskCanvas",o,c),h=d.context;h.save();const f=this.getObject(a,i);Zte(h,f),h.globalCompositeOperation="source-in",h.fillStyle=s?n.getPattern(h,this,Oc(r),di.FILL):n,h.fillRect(0,0,o,c),h.restore(),r.save(),r.transform(...u),r.scale(1,-1),mC(r,d.canvas,0,0,o,c,0,-1,1,1),r.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;const r=this.getObject(e);if(!r){Ft("Dependent image isn't ready yet");return}this.paintInlineImageXObject(r)}paintImageXObjectRepeat(e,r,n,s){if(!this.contentVisible)return;const i=this.getObject(e);if(!i){Ft("Dependent image isn't ready yet");return}const a=i.width,o=i.height,c=[];for(let u=0,d=s.length;u<d;u+=2)c.push({transform:[r,0,0,n,s[u],s[u+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(i,c)}applyTransferMapsToCanvas(e){return this.current.transferMaps!=="none"&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps==="none")return e.bitmap;const{bitmap:r,width:n,height:s}=e,i=this.cachedCanvases.getCanvas("inlineImage",n,s),a=i.context;return a.filter=this.current.transferMaps,a.drawImage(r,0,0),a.filter="none",i.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;const r=e.width,n=e.height,s=this.ctx;this.save();const{filter:i}=s;i!=="none"&&i!==""&&(s.filter="none"),s.scale(1/r,-1/n);let a;if(e.bitmap)a=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)a=e;else{const u=this.cachedCanvases.getCanvas("inlineImage",r,n).context;Qte(u,e),a=this.applyTransferMapsToCanvas(u)}const o=this._scaleImage(a,Oc(s));s.imageSmoothingEnabled=ere(kn(s),e.interpolate),mC(s,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,r,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,r){if(!this.contentVisible)return;const n=this.ctx;let s;if(e.bitmap)s=e.bitmap;else{const i=e.width,a=e.height,c=this.cachedCanvases.getCanvas("inlineImage",i,a).context;Qte(c,e),s=this.applyTransferMapsToCanvas(c)}for(const i of r)n.save(),n.transform(...i.transform),n.scale(1,-1),mC(n,s,i.x,i.y,i.w,i.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,r){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,r){e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(r)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e,r){const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(r);const s=this.ctx;this.pendingClip&&(n||(this.pendingClip===tre?s.clip(e,"evenodd"):s.clip(e)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=kn(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const r=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),s=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,s)/r}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:e}=this.current,{a:r,b:n,c:s,d:i}=this.ctx.getTransform();let a,o;if(n===0&&s===0){const c=Math.abs(r),u=Math.abs(i);if(c===u)if(e===0)a=o=1/c;else{const d=c*e;a=o=d<1?1/d:1}else if(e===0)a=1/c,o=1/u;else{const d=c*e,h=u*e;a=d<1?1/d:1,o=h<1?1/h:1}}else{const c=Math.abs(r*i-n*s),u=Math.hypot(r,n),d=Math.hypot(s,i);if(e===0)a=d/c,o=u/c;else{const h=e*c;a=d>h?d/h:1,o=u>h?u/h:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e,r){const{ctx:n,current:{lineWidth:s}}=this,[i,a]=this.getScaleForStroking();if(i===a){n.lineWidth=(s||1)*i,n.stroke(e);return}const o=n.getLineDash();r&&n.save(),n.scale(i,a),K4.a=1/i,K4.d=1/a;const c=new Path2D;if(c.addPath(e,K4),o.length>0){const u=Math.max(i,a);n.setLineDash(o.map(d=>d/u)),n.lineDashOffset/=u}n.lineWidth=s||1,n.stroke(c),r&&n.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};Sc=new WeakSet,G8=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},K8=function(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){const r=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=r}}},Y8=function(e,r,n){const s=new Path2D;return s.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(r)),s};let db=Sq;for(const t in pO)db.prototype[t]!==void 0&&(db.prototype[pO[t]]=db.prototype[t]);var Xk,Jk;class ll{static get workerPort(){return _(this,Xk)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");te(this,Xk,e)}static get workerSrc(){return _(this,Jk)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");te(this,Jk,e)}}Xk=new WeakMap,Jk=new WeakMap,le(ll,Xk,null),le(ll,Jk,"");var Kb,Qk;class y_t{constructor({parsedData:e,rawData:r}){le(this,Kb);le(this,Qk);te(this,Kb,e),te(this,Qk,r)}getRaw(){return _(this,Qk)}get(e){return _(this,Kb).get(e)??null}[Symbol.iterator](){return _(this,Kb).entries()}}Kb=new WeakMap,Qk=new WeakMap;const lv=Symbol("INTERNAL");var Zk,eN,tN,Yb;class x_t{constructor(e,{name:r,intent:n,usage:s,rbGroups:i}){le(this,Zk,!1);le(this,eN,!1);le(this,tN,!1);le(this,Yb,!0);te(this,Zk,!!(e&bo.DISPLAY)),te(this,eN,!!(e&bo.PRINT)),this.name=r,this.intent=n,this.usage=s,this.rbGroups=i}get visible(){if(_(this,tN))return _(this,Yb);if(!_(this,Yb))return!1;const{print:e,view:r}=this.usage;return _(this,Zk)?(r==null?void 0:r.viewState)!=="OFF":_(this,eN)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,r,n=!1){e!==lv&&$r("Internal method `_setVisible` called."),te(this,tN,n),te(this,Yb,r)}}Zk=new WeakMap,eN=new WeakMap,tN=new WeakMap,Yb=new WeakMap;var Hf,Dr,Xb,Jb,rN,X8;class v_t{constructor(e,r=bo.DISPLAY){le(this,rN);le(this,Hf,null);le(this,Dr,new Map);le(this,Xb,null);le(this,Jb,null);if(this.renderingIntent=r,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,te(this,Jb,e.order);for(const n of e.groups)_(this,Dr).set(n.id,new x_t(r,n));if(e.baseState==="OFF")for(const n of _(this,Dr).values())n._setVisible(lv,!1);for(const n of e.on)_(this,Dr).get(n)._setVisible(lv,!0);for(const n of e.off)_(this,Dr).get(n)._setVisible(lv,!1);te(this,Xb,this.getHash())}}isVisible(e){if(_(this,Dr).size===0)return!0;if(!e)return YM("Optional content group not defined."),!0;if(e.type==="OCG")return _(this,Dr).has(e.id)?_(this,Dr).get(e.id).visible:(Ft(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return ce(this,rN,X8).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const r of e.ids){if(!_(this,Dr).has(r))return Ft(`Optional content group not found: ${r}`),!0;if(_(this,Dr).get(r).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const r of e.ids){if(!_(this,Dr).has(r))return Ft(`Optional content group not found: ${r}`),!0;if(!_(this,Dr).get(r).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const r of e.ids){if(!_(this,Dr).has(r))return Ft(`Optional content group not found: ${r}`),!0;if(!_(this,Dr).get(r).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const r of e.ids){if(!_(this,Dr).has(r))return Ft(`Optional content group not found: ${r}`),!0;if(_(this,Dr).get(r).visible)return!1}return!0}return Ft(`Unknown optional content policy ${e.policy}.`),!0}return Ft(`Unknown group type ${e.type}.`),!0}setVisibility(e,r=!0,n=!0){var i;const s=_(this,Dr).get(e);if(!s){Ft(`Optional content group not found: ${e}`);return}if(n&&r&&s.rbGroups.length)for(const a of s.rbGroups)for(const o of a)o!==e&&((i=_(this,Dr).get(o))==null||i._setVisible(lv,!1,!0));s._setVisible(lv,!!r,!0),te(this,Hf,null)}setOCGState({state:e,preserveRB:r}){let n;for(const s of e){switch(s){case"ON":case"OFF":case"Toggle":n=s;continue}const i=_(this,Dr).get(s);if(i)switch(n){case"ON":this.setVisibility(s,!0,r);break;case"OFF":this.setVisibility(s,!1,r);break;case"Toggle":this.setVisibility(s,!i.visible,r);break}}te(this,Hf,null)}get hasInitialVisibility(){return _(this,Xb)===null||this.getHash()===_(this,Xb)}getOrder(){return _(this,Dr).size?_(this,Jb)?_(this,Jb).slice():[..._(this,Dr).keys()]:null}getGroup(e){return _(this,Dr).get(e)||null}getHash(){if(_(this,Hf)!==null)return _(this,Hf);const e=new Uwe;for(const[r,n]of _(this,Dr))e.update(`${r}:${n.visible}`);return te(this,Hf,e.hexdigest())}[Symbol.iterator](){return _(this,Dr).entries()}}Hf=new WeakMap,Dr=new WeakMap,Xb=new WeakMap,Jb=new WeakMap,rN=new WeakSet,X8=function(e){const r=e.length;if(r<2)return!0;const n=e[0];for(let s=1;s<r;s++){const i=e[s];let a;if(Array.isArray(i))a=ce(this,rN,X8).call(this,i);else if(_(this,Dr).has(i))a=_(this,Dr).get(i).visible;else return Ft(`Optional content group not found: ${i}`),!0;switch(n){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return n==="And"};class b_t{constructor(e,{disableRange:r=!1,disableStream:n=!1}){us(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:i,progressiveDone:a,contentDispositionFilename:o}=e;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,(i==null?void 0:i.length)>0){const c=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(c)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!r,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((c,u)=>{this._onReceiveData({begin:c,chunk:u})}),e.addProgressListener((c,u)=>{this._onProgress({loaded:c,total:u})}),e.addProgressiveReadListener(c=>{this._onReceiveData({chunk:c})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:r}){const n=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{const s=this._rangeReaders.some(function(i){return i._begin!==e?!1:(i._enqueue(n),!0)});us(s,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}_onProgress(e){var r,n,s,i;e.total===void 0?(n=(r=this._rangeReaders[0])==null?void 0:r.onProgress)==null||n.call(r,{loaded:e.loaded}):(i=(s=this._fullRequestReader)==null?void 0:s.onProgress)==null||i.call(s,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;(e=this._fullRequestReader)==null||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const r=this._rangeReaders.indexOf(e);r>=0&&this._rangeReaders.splice(r,1)}getFullReader(){us(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new w_t(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,r){if(r<=this._progressiveDataLength)return null;const n=new S_t(this,e,r);return this._pdfDataRangeTransport.requestDataRange(e,r),this._rangeReaders.push(n),n}cancelAllRequests(e){var r;(r=this._fullRequestReader)==null||r.cancel(e);for(const n of this._rangeReaders.slice(0))n.cancel(e);this._pdfDataRangeTransport.abort()}}class w_t{constructor(e,r,n=!1,s=null){this._stream=e,this._done=n||!1,this._filename=t7(s)?s:null,this._queuedChunks=r||[],this._loaded=0;for(const i of this._queuedChunks)this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class S_t{constructor(e,r,n){this._stream=e,this._begin=r,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function __t(t){let e=!0,r=n("filename\\*","i").exec(t);if(r){r=r[1];let d=o(r);return d=unescape(d),d=c(d),d=u(d),i(d)}if(r=a(t),r){const d=u(r);return i(d)}if(r=n("filename","i").exec(t),r){r=r[1];let d=o(r);return d=u(d),i(d)}function n(d,h){return new RegExp("(?:^|;)\\s*"+d+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',h)}function s(d,h){if(d){if(!/^[\x00-\xFF]+$/.test(h))return h;try{const f=new TextDecoder(d,{fatal:!0}),p=DE(h);h=f.decode(p),e=!1}catch{}}return h}function i(d){return e&&/[\x80-\xff]/.test(d)&&(d=s("utf-8",d),e&&(d=s("iso-8859-1",d))),d}function a(d){const h=[];let f;const p=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=p.exec(d))!==null;){let[,g,x,y]=f;if(g=parseInt(g,10),g in h){if(g===0)break;continue}h[g]=[x,y]}const m=[];for(let g=0;g<h.length&&g in h;++g){let[x,y]=h[g];y=o(y),x&&(y=unescape(y),g===0&&(y=c(y))),m.push(y)}return m.join("")}function o(d){if(d.startsWith('"')){const h=d.slice(1).split('\\"');for(let f=0;f<h.length;++f){const p=h[f].indexOf('"');p!==-1&&(h[f]=h[f].slice(0,p),h.length=f+1),h[f]=h[f].replaceAll(/\\(.)/g,"$1")}d=h.join('"')}return d}function c(d){const h=d.indexOf("'");if(h===-1)return d;const f=d.slice(0,h),m=d.slice(h+1).replace(/^[^']*'/,"");return s(f,m)}function u(d){return!d.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(d)?d:d.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(h,f,p,m){if(p==="q"||p==="Q")return m=m.replaceAll("_"," "),m=m.replaceAll(/=([0-9a-fA-F]{2})/g,function(g,x){return String.fromCharCode(parseInt(x,16))}),s(f,m);try{m=atob(m)}catch{}return s(f,m)})}return""}function e1e(t,e){const r=new Headers;if(!t||!e||typeof e!="object")return r;for(const n in e){const s=e[n];s!==void 0&&r.append(n,s)}return r}function QM(t){var e;return((e=URL.parse(t))==null?void 0:e.origin)??null}function t1e({responseHeaders:t,isHttp:e,rangeChunkSize:r,disableRange:n}){const s={allowRangeRequests:!1,suggestedLength:void 0},i=parseInt(t.get("Content-Length"),10);return!Number.isInteger(i)||(s.suggestedLength=i,i<=2*r)||n||!e||t.get("Accept-Ranges")!=="bytes"||(t.get("Content-Encoding")||"identity")!=="identity"||(s.allowRangeRequests=!0),s}function r1e(t){const e=t.get("Content-Disposition");if(e){let r=__t(e);if(r.includes("%"))try{r=decodeURIComponent(r)}catch{}if(t7(r))return r}return null}function BE(t,e){return new mO(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,t===404||t===0&&e.startsWith("file:"))}function n1e(t){return t===200||t===206}function s1e(t,e,r){return{method:"GET",headers:t,signal:r.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function i1e(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Ft(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class j_t{constructor(e){Ve(this,"_responseOrigin",null);this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=e1e(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return us(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new k_t(this),this._fullRequestReader}getRangeReader(e,r){if(r<=this._progressiveDataLength)return null;const n=new N_t(this,e,r);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var r;(r=this._fullRequestReader)==null||r.cancel(e);for(const n of this._rangeRequestReaders.slice(0))n.cancel(e)}}class k_t{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const r=e.source;this._withCredentials=r.withCredentials||!1,this._contentLength=r.length,this._headersCapability=Promise.withResolvers(),this._disableRange=r.disableRange||!1,this._rangeChunkSize=r.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!r.disableStream,this._isRangeSupported=!r.disableRange;const n=new Headers(e.headers),s=r.url;fetch(s,s1e(n,this._withCredentials,this._abortController)).then(i=>{if(e._responseOrigin=QM(i.url),!n1e(i.status))throw BE(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const a=i.headers,{allowRangeRequests:o,suggestedLength:c}=t1e({responseHeaders:a,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=c||this._contentLength,this._filename=r1e(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new qp("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;await this._headersCapability.promise;const{value:e,done:r}=await this._reader.read();return r?{value:e,done:r}:(this._loaded+=e.byteLength,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded,total:this._contentLength}),{value:i1e(e),done:!1})}cancel(e){var r;(r=this._reader)==null||r.cancel(e),this._abortController.abort()}}class N_t{constructor(e,r,n){this._stream=e,this._reader=null,this._loaded=0;const s=e.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const i=new Headers(e.headers);i.append("Range",`bytes=${r}-${n-1}`);const a=s.url;fetch(a,s1e(i,this._withCredentials,this._abortController)).then(o=>{const c=QM(o.url);if(c!==e._responseOrigin)throw new Error(`Expected range response-origin "${c}" to match "${e._responseOrigin}".`);if(!n1e(o.status))throw BE(o.status,a);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;await this._readCapability.promise;const{value:e,done:r}=await this._reader.read();return r?{value:e,done:r}:(this._loaded+=e.byteLength,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded}),{value:i1e(e),done:!1})}cancel(e){var r;(r=this._reader)==null||r.cancel(e),this._abortController.abort()}}const Y4=200,X4=206;function E_t(t){const e=t.response;return typeof e!="string"?e:DE(e).buffer}class A_t{constructor({url:e,httpHeaders:r,withCredentials:n}){Ve(this,"_responseOrigin",null);this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=e1e(this.isHttp,r),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){const r=new XMLHttpRequest,n=this.currXhrId++,s=this.pendingRequests[n]={xhr:r};r.open("GET",this.url),r.withCredentials=this.withCredentials;for(const[i,a]of this.headers)r.setRequestHeader(i,a);return this.isHttp&&"begin"in e&&"end"in e?(r.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),s.expectedStatus=X4):s.expectedStatus=Y4,r.responseType="arraybuffer",us(e.onError,"Expected `onError` callback to be provided."),r.onerror=()=>{e.onError(r.status)},r.onreadystatechange=this.onStateChange.bind(this,n),r.onprogress=this.onProgress.bind(this,n),s.onHeadersReceived=e.onHeadersReceived,s.onDone=e.onDone,s.onError=e.onError,s.onProgress=e.onProgress,r.send(null),n}onProgress(e,r){var s;const n=this.pendingRequests[e];n&&((s=n.onProgress)==null||s.call(n,r))}onStateChange(e,r){const n=this.pendingRequests[e];if(!n)return;const s=n.xhr;if(s.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),s.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],s.status===0&&this.isHttp){n.onError(s.status);return}const i=s.status||Y4;if(!(i===Y4&&n.expectedStatus===X4)&&i!==n.expectedStatus){n.onError(s.status);return}const o=E_t(s);if(i===X4){const c=s.getResponseHeader("Content-Range"),u=/bytes (\d+)-(\d+)\/(\d+)/.exec(c);u?n.onDone({begin:parseInt(u[1],10),chunk:o}):(Ft('Missing or invalid "Content-Range" header.'),n.onError(0))}else o?n.onDone({begin:0,chunk:o}):n.onError(s.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const r=this.pendingRequests[e].xhr;delete this.pendingRequests[e],r.abort()}}class C_t{constructor(e){this._source=e,this._manager=new A_t(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const r=this._rangeRequestReaders.indexOf(e);r>=0&&this._rangeRequestReaders.splice(r,1)}getFullReader(){return us(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new T_t(this._manager,this._source),this._fullRequestReader}getRangeReader(e,r){const n=new P_t(this._manager,e,r);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var r;(r=this._fullRequestReader)==null||r.cancel(e);for(const n of this._rangeRequestReaders.slice(0))n.cancel(e)}}class T_t{constructor(e,r){this._manager=e,this._url=r.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=r.disableRange||!1,this._contentLength=r.length,this._rangeChunkSize=r.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,r=this._manager.getRequestXhr(e);this._manager._responseOrigin=QM(r.responseURL);const n=r.getAllResponseHeaders(),s=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(o=>{const[c,...u]=o.split(": ");return[c,u.join(": ")]}):[]),{allowRangeRequests:i,suggestedLength:a}=t1e({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=r1e(s),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=BE(e,this._url),this._headersCapability.reject(this._storedError);for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var r;(r=this.onProgress)==null||r.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class P_t{constructor(e,r,n){this._manager=e,this._url=e.url,this._requestId=e.request({begin:r,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var r;const e=QM((r=this._manager.getRequestXhr(this._requestId))==null?void 0:r.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var e;(e=this.onClosed)==null||e.call(this,this)}_onDone(e){const r=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:r,done:!1}):this._queuedChunk=r,this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??(this._storedError=BE(e,this._url));for(const r of this._requests)r.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var r;this.isStreamingSupported||(r=this.onProgress)==null||r.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const r=this._queuedChunk;return this._queuedChunk=null,{value:r,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const O_t=/^[a-z][a-z0-9\-+.]+:/i;function I_t(t){if(O_t.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}class R_t{constructor(e){this.source=e,this.url=I_t(e.url),us(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return us(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new M_t(this),this._fullRequestReader}getRangeReader(e,r){if(r<=this._progressiveDataLength)return null;const n=new D_t(this,e,r);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var r;(r=this._fullRequestReader)==null||r.cancel(e);for(const n of this._rangeRequestReaders.slice(0))n.cancel(e)}}class M_t{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const r=e.source;this._contentLength=r.length,this._loaded=0,this._filename=null,this._disableRange=r.disableRange||!1,this._rangeChunkSize=r.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!r.disableStream,this._isRangeSupported=!r.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const n=process.getBuiltinModule("fs");n.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=BE(0,this._url.href)),this._storedError=s,this._headersCapability.reject(s)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",r=>{this._error(r)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new qp("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class D_t{constructor(e,r,n){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=e.source;this._isStreamingSupported=!s.disableStream;const i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:r,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var n;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(n=this.onProgress)==null||n.call(this,{loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",r=>{this._error(r)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const q1=Symbol("INITIAL_DATA");var oo,nN,J8;class a1e{constructor(){le(this,nN);le(this,oo,Object.create(null))}get(e,r=null){if(r){const s=ce(this,nN,J8).call(this,e);return s.promise.then(()=>r(s.data)),null}const n=_(this,oo)[e];if(!n||n.data===q1)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){const r=_(this,oo)[e];return!!r&&r.data!==q1}delete(e){const r=_(this,oo)[e];return!r||r.data===q1?!1:(delete _(this,oo)[e],!0)}resolve(e,r=null){const n=ce(this,nN,J8).call(this,e);n.data=r,n.resolve()}clear(){var e;for(const r in _(this,oo)){const{data:n}=_(this,oo)[r];(e=n==null?void 0:n.bitmap)==null||e.close()}te(this,oo,Object.create(null))}*[Symbol.iterator](){for(const e in _(this,oo)){const{data:r}=_(this,oo)[e];r!==q1&&(yield[e,r])}}}oo=new WeakMap,nN=new WeakSet,J8=function(e){var r;return(r=_(this,oo))[e]||(r[e]={...Promise.withResolvers(),data:q1})};const L_t=1e5,rre=30;var Oae,Vf,Oa,sN,iN,Vg,Ed,aN,oN,Wg,Qb,Zb,Wf,e0,lN,t0,qg,cN,uN,r0,Gg,dN,qf,n0,jh,o1e,l1e,Q8,Po,IT,Z8,c1e,u1e;const bs=class bs{constructor({textContentSource:e,container:r,viewport:n}){le(this,jh);le(this,Vf,Promise.withResolvers());le(this,Oa,null);le(this,sN,!1);le(this,iN,!!((Oae=globalThis.FontInspector)!=null&&Oae.enabled));le(this,Vg,null);le(this,Ed,null);le(this,aN,0);le(this,oN,0);le(this,Wg,null);le(this,Qb,null);le(this,Zb,0);le(this,Wf,0);le(this,e0,Object.create(null));le(this,lN,[]);le(this,t0,null);le(this,qg,[]);le(this,cN,new WeakMap);le(this,uN,null);var c;if(e instanceof ReadableStream)te(this,t0,e);else if(typeof e=="object")te(this,t0,new ReadableStream({start(u){u.enqueue(e),u.close()}}));else throw new Error('No "textContentSource" parameter specified.');te(this,Oa,te(this,Qb,r)),te(this,Wf,n.scale*Cu.pixelRatio),te(this,Zb,n.rotation),te(this,Ed,{div:null,properties:null,ctx:null});const{pageWidth:s,pageHeight:i,pageX:a,pageY:o}=n.rawDims;te(this,uN,[1,0,0,-1,-a,o+i]),te(this,oN,s),te(this,aN,i),ce(c=bs,Po,c1e).call(c),rx(r,n),_(this,Vf).promise.finally(()=>{_(bs,n0).delete(this),te(this,Ed,null),te(this,e0,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:r}=wi.platform;return tr(this,"fontFamilyMap",new Map([["sans-serif",`${e&&r?"Calibri, ":""}sans-serif`],["monospace",`${e&&r?"Lucida Console, ":""}monospace`]]))}render(){const e=()=>{_(this,Wg).read().then(({value:r,done:n})=>{if(n){_(this,Vf).resolve();return}_(this,Vg)??te(this,Vg,r.lang),Object.assign(_(this,e0),r.styles),ce(this,jh,o1e).call(this,r.items),e()},_(this,Vf).reject)};return te(this,Wg,_(this,t0).getReader()),_(bs,n0).add(this),e(),_(this,Vf).promise}update({viewport:e,onBefore:r=null}){var i;const n=e.scale*Cu.pixelRatio,s=e.rotation;if(s!==_(this,Zb)&&(r==null||r(),te(this,Zb,s),rx(_(this,Qb),{rotation:s})),n!==_(this,Wf)){r==null||r(),te(this,Wf,n);const a={div:null,properties:null,ctx:ce(i=bs,Po,IT).call(i,_(this,Vg))};for(const o of _(this,qg))a.properties=_(this,cN).get(o),a.div=o,ce(this,jh,Q8).call(this,a)}}cancel(){var r;const e=new qp("TextLayer task cancelled.");(r=_(this,Wg))==null||r.cancel(e).catch(()=>{}),te(this,Wg,null),_(this,Vf).reject(e)}get textDivs(){return _(this,qg)}get textContentItemsStr(){return _(this,lN)}static cleanup(){if(!(_(this,n0).size>0)){_(this,r0).clear();for(const{canvas:e}of _(this,Gg).values())e.remove();_(this,Gg).clear()}}};Vf=new WeakMap,Oa=new WeakMap,sN=new WeakMap,iN=new WeakMap,Vg=new WeakMap,Ed=new WeakMap,aN=new WeakMap,oN=new WeakMap,Wg=new WeakMap,Qb=new WeakMap,Zb=new WeakMap,Wf=new WeakMap,e0=new WeakMap,lN=new WeakMap,t0=new WeakMap,qg=new WeakMap,cN=new WeakMap,uN=new WeakMap,r0=new WeakMap,Gg=new WeakMap,dN=new WeakMap,qf=new WeakMap,n0=new WeakMap,jh=new WeakSet,o1e=function(e){var s,i;if(_(this,sN))return;(i=_(this,Ed)).ctx??(i.ctx=ce(s=bs,Po,IT).call(s,_(this,Vg)));const r=_(this,qg),n=_(this,lN);for(const a of e){if(r.length>L_t){Ft("Ignoring additional textDivs for performance reasons."),te(this,sN,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=_(this,Oa);te(this,Oa,document.createElement("span")),_(this,Oa).classList.add("markedContent"),a.id&&_(this,Oa).setAttribute("id",`${a.id}`),o.append(_(this,Oa))}else a.type==="endMarkedContent"&&te(this,Oa,_(this,Oa).parentNode);continue}n.push(a.str),ce(this,jh,l1e).call(this,a)}},l1e=function(e){var g;const r=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};_(this,qg).push(r);const s=jt.transform(_(this,uN),e.transform);let i=Math.atan2(s[1],s[0]);const a=_(this,e0)[e.fontName];a.vertical&&(i+=Math.PI/2);let o=_(this,iN)&&a.fontSubstitution||a.fontFamily;o=bs.fontFamilyMap.get(o)||o;const c=Math.hypot(s[2],s[3]),u=c*ce(g=bs,Po,u1e).call(g,o,a,_(this,Vg));let d,h;i===0?(d=s[4],h=s[5]-u):(d=s[4]+u*Math.sin(i),h=s[5]-u*Math.cos(i));const f="calc(var(--total-scale-factor) *",p=r.style;_(this,Oa)===_(this,Qb)?(p.left=`${(100*d/_(this,oN)).toFixed(2)}%`,p.top=`${(100*h/_(this,aN)).toFixed(2)}%`):(p.left=`${f}${d.toFixed(2)}px)`,p.top=`${f}${h.toFixed(2)}px)`),p.fontSize=`${f}${(_(bs,qf)*c).toFixed(2)}px)`,p.fontFamily=o,n.fontSize=c,r.setAttribute("role","presentation"),r.textContent=e.str,r.dir=e.dir,_(this,iN)&&(r.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),i!==0&&(n.angle=i*(180/Math.PI));let m=!1;if(e.str.length>1)m=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){const x=Math.abs(e.transform[0]),y=Math.abs(e.transform[3]);x!==y&&Math.max(x,y)/Math.min(x,y)>1.5&&(m=!0)}if(m&&(n.canvasWidth=a.vertical?e.height:e.width),_(this,cN).set(r,n),_(this,Ed).div=r,_(this,Ed).properties=n,ce(this,jh,Q8).call(this,_(this,Ed)),n.hasText&&_(this,Oa).append(r),n.hasEOL){const x=document.createElement("br");x.setAttribute("role","presentation"),_(this,Oa).append(x)}},Q8=function(e){var o;const{div:r,properties:n,ctx:s}=e,{style:i}=r;let a="";if(_(bs,qf)>1&&(a=`scale(${1/_(bs,qf)})`),n.canvasWidth!==0&&n.hasText){const{fontFamily:c}=i,{canvasWidth:u,fontSize:d}=n;ce(o=bs,Po,Z8).call(o,s,d*_(this,Wf),c);const{width:h}=s.measureText(r.textContent);h>0&&(a=`scaleX(${u*_(this,Wf)/h}) ${a}`)}n.angle!==0&&(a=`rotate(${n.angle}deg) ${a}`),a.length>0&&(i.transform=a)},Po=new WeakSet,IT=function(e=null){let r=_(this,Gg).get(e||(e=""));if(!r){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=e,document.body.append(n),r=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),_(this,Gg).set(e,r),_(this,dN).set(r,{size:0,family:""})}return r},Z8=function(e,r,n){const s=_(this,dN).get(e);r===s.size&&n===s.family||(e.font=`${r}px ${n}`,s.size=r,s.family=n)},c1e=function(){if(_(this,qf)!==null)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),te(this,qf,e.getBoundingClientRect().height),e.remove()},u1e=function(e,r,n){const s=_(this,r0).get(e);if(s)return s;const i=ce(this,Po,IT).call(this,n);i.canvas.width=i.canvas.height=rre,ce(this,Po,Z8).call(this,i,rre,e);const a=i.measureText(""),o=a.fontBoundingBoxAscent,c=Math.abs(a.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let u=.8;return o?u=o/(o+c):(wi.platform.isFirefox&&Ft("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),r.ascent?u=r.ascent:r.descent&&(u=1+r.descent)),_(this,r0).set(e,u),u},le(bs,Po),le(bs,r0,new Map),le(bs,Gg,new Map),le(bs,dN,new WeakMap),le(bs,qf,null),le(bs,n0,new Set);let bw=bs;class ek{static textContent(e){const r=[],n={items:r,styles:Object.create(null)};function s(i){var c;if(!i)return;let a=null;const o=i.name;if(o==="#text")a=i.value;else if(ek.shouldBuildText(o))(c=i==null?void 0:i.attributes)!=null&&c.textContent?a=i.attributes.textContent:i.value&&(a=i.value);else return;if(a!==null&&r.push({str:a}),!!i.children)for(const u of i.children)s(u)}return s(e),n}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}const F_t=100;function ZM(t={}){typeof t=="string"||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new ez,{docId:r}=e,n=t.url?GSt(t.url):null,s=t.data?KSt(t.data):null,i=t.httpHeaders||null,a=t.withCredentials===!0,o=t.password??null,c=t.range instanceof d1e?t.range:null,u=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:2**16;let d=t.worker instanceof tk?t.worker:null;const h=t.verbosity,f=typeof t.docBaseUrl=="string"&&!XM(t.docBaseUrl)?t.docBaseUrl:null,p=fC(t.cMapUrl),m=t.cMapPacked!==!1,g=t.CMapReaderFactory||(oa?r_t:Vte),x=fC(t.iccUrl),y=fC(t.standardFontDataUrl),v=t.StandardFontDataFactory||(oa?n_t:Wte),b=fC(t.wasmUrl),w=t.WasmFactory||(oa?s_t:qte),S=t.stopAtErrors!==!0,k=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,E=t.isEvalSupported!==!1,C=typeof t.isOffscreenCanvasSupported=="boolean"?t.isOffscreenCanvasSupported:!oa,A=typeof t.isImageDecoderSupported=="boolean"?t.isImageDecoderSupported:!oa&&(wi.platform.isFirefox||!globalThis.chrome),M=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,z=typeof t.disableFontFace=="boolean"?t.disableFontFace:oa,P=t.fontExtraProperties===!0,W=t.enableXfa===!0,N=t.ownerDocument||globalThis.document,U=t.disableRange===!0,K=t.disableStream===!0,G=t.disableAutoFetch===!0,X=t.pdfBug===!0,H=t.CanvasFactory||(oa?t_t:QSt),B=t.FilterFactory||(oa?e_t:ZSt),L=t.enableHWA===!0,F=t.useWasm!==!1,V=c?c.length:t.length??NaN,Y=typeof t.useSystemFonts=="boolean"?t.useSystemFonts:!oa&&!z,ie=typeof t.useWorkerFetch=="boolean"?t.useWorkerFetch:!!(g===Vte&&v===Wte&&w===qte&&p&&y&&b&&gS(p,document.baseURI)&&gS(y,document.baseURI)&&gS(b,document.baseURI)),Q=null;kSt(h);const D={canvasFactory:new H({ownerDocument:N,enableHWA:L}),filterFactory:new B({docId:r,ownerDocument:N}),cMapReaderFactory:ie?null:new g({baseUrl:p,isCompressed:m}),standardFontDataFactory:ie?null:new v({baseUrl:y}),wasmFactory:ie?null:new w({baseUrl:b})};d||(d=tk.create({verbosity:h,port:ll.workerPort}),e._worker=d);const R={docId:r,apiVersion:"5.4.54",data:s,password:o,disableAutoFetch:G,rangeChunkSize:u,length:V,docBaseUrl:f,enableXfa:W,evaluatorOptions:{maxImageSize:k,disableFontFace:z,ignoreErrors:S,isEvalSupported:E,isOffscreenCanvasSupported:C,isImageDecoderSupported:A,canvasMaxAreaInBytes:M,fontExtraProperties:P,useSystemFonts:Y,useWasm:F,useWorkerFetch:ie,cMapUrl:p,iccUrl:x,standardFontDataUrl:y,wasmUrl:b}},J={ownerDocument:N,pdfBug:X,styleElement:Q,loadingParams:{disableAutoFetch:G,enableXfa:W}};return d.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const Z=d.messageHandler.sendWithPromise("GetDocRequest",R,s?[s.buffer]:null);let ee;if(c)ee=new b_t(c,{disableRange:U,disableStream:K});else if(!s){if(!n)throw new Error("getDocument - no `url` parameter provided.");const re=gS(n)?j_t:oa?R_t:C_t;ee=new re({url:n,length:V,httpHeaders:i,withCredentials:a,rangeChunkSize:u,disableRange:U,disableStream:K})}return Z.then(re=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const he=new wS(r,re,d.port),O=new z_t(he,e,ee,J,D,L);e._transport=O,he.send("Ready",null)})}).catch(e._capability.reject),e}var kI;const NI=class NI{constructor(){Ve(this,"_capability",Promise.withResolvers());Ve(this,"_transport",null);Ve(this,"_worker",null);Ve(this,"docId",`d${Ds(NI,kI)._++}`);Ve(this,"destroyed",!1);Ve(this,"onPassword",null);Ve(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var e,r,n,s;this.destroyed=!0;try{(e=this._worker)!=null&&e.port&&(this._worker._pendingDestroy=!0),await((r=this._transport)==null?void 0:r.destroy())}catch(i){throw(n=this._worker)!=null&&n.port&&delete this._worker._pendingDestroy,i}this._transport=null,(s=this._worker)==null||s.destroy(),this._worker=null}async getData(){return this._transport.getData()}};kI=new WeakMap,le(NI,kI,0);let ez=NI;var Kg,hN,fN,pN,mN;class d1e{constructor(e,r,n=!1,s=null){le(this,Kg,Promise.withResolvers());le(this,hN,[]);le(this,fN,[]);le(this,pN,[]);le(this,mN,[]);this.length=e,this.initialData=r,this.progressiveDone=n,this.contentDispositionFilename=s}addRangeListener(e){_(this,mN).push(e)}addProgressListener(e){_(this,pN).push(e)}addProgressiveReadListener(e){_(this,fN).push(e)}addProgressiveDoneListener(e){_(this,hN).push(e)}onDataRange(e,r){for(const n of _(this,mN))n(e,r)}onDataProgress(e,r){_(this,Kg).promise.then(()=>{for(const n of _(this,pN))n(e,r)})}onDataProgressiveRead(e){_(this,Kg).promise.then(()=>{for(const r of _(this,fN))r(e)})}onDataProgressiveDone(){_(this,Kg).promise.then(()=>{for(const e of _(this,hN))e()})}transportReady(){_(this,Kg).resolve()}requestDataRange(e,r){$r("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Kg=new WeakMap,hN=new WeakMap,fN=new WeakMap,pN=new WeakMap,mN=new WeakMap;class $_t{constructor(e,r){this._pdfInfo=e,this._transport=r}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return tr(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:r}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(r)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Ad,Yg,NS;class B_t{constructor(e,r,n,s=!1){le(this,Yg);le(this,Ad,!1);this._pageIndex=e,this._pageInfo=r,this._transport=n,this._stats=s?new zte:null,this._pdfBug=s,this.commonObjs=n.commonObjs,this.objs=new a1e,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:r=this.rotate,offsetX:n=0,offsetY:s=0,dontFlip:i=!1}={}){return new FE({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:r,offsetX:n,offsetY:s,dontFlip:i})}getAnnotations({intent:e="display"}={}){const{renderingIntent:r}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,r)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return tr(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var e;return((e=this._transport._htmlForXfa)==null?void 0:e.children[this._pageIndex])||null}render({canvasContext:e,canvas:r=e.canvas,viewport:n,intent:s="display",annotationMode:i=pf.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:c=null,annotationCanvasMap:u=null,pageColors:d=null,printAnnotationStorage:h=null,isEditing:f=!1}){var S,k;(S=this._stats)==null||S.time("Overall");const p=this._transport.getRenderingIntent(s,i,h,f),{renderingIntent:m,cacheKey:g}=p;te(this,Ad,!1),c||(c=this._transport.getOptionalContentConfig(m));let x=this._intentStates.get(g);x||(x=Object.create(null),this._intentStates.set(g,x)),x.streamReaderCancelTimeout&&(clearTimeout(x.streamReaderCancelTimeout),x.streamReaderCancelTimeout=null);const y=!!(m&bo.PRINT);x.displayReadyCapability||(x.displayReadyCapability=Promise.withResolvers(),x.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(k=this._stats)==null||k.time("Page Request"),this._pumpOperatorList(p));const v=E=>{var C;x.renderTasks.delete(b),y&&te(this,Ad,!0),ce(this,Yg,NS).call(this),E?(b.capability.reject(E),this._abortOperatorList({intentState:x,reason:E instanceof Error?E:new Error(E)})):b.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(C=globalThis.Stats)!=null&&C.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},b=new tz({callback:v,params:{canvas:r,canvasContext:e,viewport:n,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:u,operatorList:x.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!y,pdfBug:this._pdfBug,pageColors:d,enableHWA:this._transport.enableHWA});(x.renderTasks||(x.renderTasks=new Set)).add(b);const w=b.task;return Promise.all([x.displayReadyCapability.promise,c]).then(([E,C])=>{var A;if(this.destroyed){v();return}if((A=this._stats)==null||A.time("Rendering"),!(C.renderingIntent&m))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");b.initializeGraphics({transparency:E,optionalContentConfig:C}),b.operatorListChanged()}).catch(v),w}getOperatorList({intent:e="display",annotationMode:r=pf.ENABLE,printAnnotationStorage:n=null,isEditing:s=!1}={}){var u;function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(c))}const a=this._transport.getRenderingIntent(e,r,n,s,!0);let o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let c;return o.opListReadCapability||(c=Object.create(null),c.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(c),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(u=this._stats)==null||u.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:r=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:r===!0},{highWaterMark:100,size(s){return s.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(n=>ek.textContent(n));const r=this.streamTextContent(e);return new Promise(function(n,s){function i(){a.read().then(function({value:c,done:u}){if(u){n(o);return}o.lang??(o.lang=c.lang),Object.assign(o.styles,c.styles),o.items.push(...c.items),i()},s)}const a=r.getReader(),o={items:[],styles:Object.create(null),lang:null};i()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const r of this._intentStates.values())if(this._abortOperatorList({intentState:r,reason:new Error("Page was destroyed."),force:!0}),!r.opListReadCapability)for(const n of r.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),te(this,Ad,!1),Promise.all(e)}cleanup(e=!1){te(this,Ad,!0);const r=ce(this,Yg,NS).call(this);return e&&r&&this._stats&&(this._stats=new zte),r}_startRenderPage(e,r){var s,i;const n=this._intentStates.get(r);n&&((s=this._stats)==null||s.timeEnd("Page Request"),(i=n.displayReadyCapability)==null||i.resolve(e))}_renderPageChunk(e,r){for(let n=0,s=e.length;n<s;n++)r.operatorList.fnArray.push(e.fnArray[n]),r.operatorList.argsArray.push(e.argsArray[n]);r.operatorList.lastChunk=e.lastChunk,r.operatorList.separateAnnots=e.separateAnnots;for(const n of r.renderTasks)n.operatorListChanged();e.lastChunk&&ce(this,Yg,NS).call(this)}_pumpOperatorList({renderingIntent:e,cacheKey:r,annotationStorageSerializable:n,modifiedIds:s}){const{map:i,transfer:a}=n,c=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:r,annotationStorage:i,modifiedIds:s},a).getReader(),u=this._intentStates.get(r);u.streamReader=c;const d=()=>{c.read().then(({value:h,done:f})=>{if(f){u.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(h,u),d())},h=>{if(u.streamReader=null,!this._transport.destroyed){if(u.operatorList){u.operatorList.lastChunk=!0;for(const f of u.renderTasks)f.operatorListChanged();ce(this,Yg,NS).call(this)}if(u.displayReadyCapability)u.displayReadyCapability.reject(h);else if(u.opListReadCapability)u.opListReadCapability.reject(h);else throw h}})};d()}_abortOperatorList({intentState:e,reason:r,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(r instanceof e7){let s=F_t;r.extraDelay>0&&r.extraDelay<1e3&&(s+=r.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:r,force:!0})},s);return}}if(e.streamReader.cancel(new qp(r.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(const[s,i]of this._intentStates)if(i===e){this._intentStates.delete(s);break}this.cleanup()}}}get stats(){return this._stats}}Ad=new WeakMap,Yg=new WeakSet,NS=function(){if(!_(this,Ad)||this.destroyed)return!1;for(const{renderTasks:e,operatorList:r}of this._intentStates.values())if(e.size>0||!r.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),te(this,Ad,!1),!0};var Gf,Yl,Cd,Xg,EI,Jg,Qg,ga,RT,h1e,f1e,ES,s0,MT;const gn=class gn{constructor({name:e=null,port:r=null,verbosity:n=NSt()}={}){le(this,ga);le(this,Gf,Promise.withResolvers());le(this,Yl,null);le(this,Cd,null);le(this,Xg,null);if(this.name=e,this.destroyed=!1,this.verbosity=n,r){if(_(gn,Qg).has(r))throw new Error("Cannot use more than one PDFWorker per port.");_(gn,Qg).set(r,this),ce(this,ga,h1e).call(this,r)}else ce(this,ga,f1e).call(this)}get promise(){return _(this,Gf).promise}get port(){return _(this,Cd)}get messageHandler(){return _(this,Yl)}destroy(){var e,r;this.destroyed=!0,(e=_(this,Xg))==null||e.terminate(),te(this,Xg,null),_(gn,Qg).delete(_(this,Cd)),te(this,Cd,null),(r=_(this,Yl))==null||r.destroy(),te(this,Yl,null)}static create(e){const r=_(this,Qg).get(e==null?void 0:e.port);if(r){if(r._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return r}return new gn(e)}static get workerSrc(){if(ll.workerSrc)return ll.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return tr(this,"_setupFakeWorkerGlobal",(async()=>_(this,s0,MT)?_(this,s0,MT):(await import(this.workerSrc)).WorkerMessageHandler)())}};Gf=new WeakMap,Yl=new WeakMap,Cd=new WeakMap,Xg=new WeakMap,EI=new WeakMap,Jg=new WeakMap,Qg=new WeakMap,ga=new WeakSet,RT=function(){_(this,Gf).resolve(),_(this,Yl).send("configure",{verbosity:this.verbosity})},h1e=function(e){te(this,Cd,e),te(this,Yl,new wS("main","worker",e)),_(this,Yl).on("ready",()=>{}),ce(this,ga,RT).call(this)},f1e=function(){if(_(gn,Jg)||_(gn,s0,MT)){ce(this,ga,ES).call(this);return}let{workerSrc:e}=gn;try{gn._isSameOrigin(window.location,e)||(e=gn._createCDNWrapper(new URL(e,window.location).href));const r=new Worker(e,{type:"module"}),n=new wS("main","worker",r),s=()=>{i.abort(),n.destroy(),r.terminate(),this.destroyed?_(this,Gf).reject(new Error("Worker was destroyed")):ce(this,ga,ES).call(this)},i=new AbortController;r.addEventListener("error",()=>{_(this,Xg)||s()},{signal:i.signal}),n.on("test",o=>{if(i.abort(),this.destroyed||!o){s();return}te(this,Yl,n),te(this,Cd,r),te(this,Xg,r),ce(this,ga,RT).call(this)}),n.on("ready",o=>{if(i.abort(),this.destroyed){s();return}try{a()}catch{ce(this,ga,ES).call(this)}});const a=()=>{const o=new Uint8Array;n.send("test",o,[o.buffer])};a();return}catch{YM("The worker has been disabled.")}ce(this,ga,ES).call(this)},ES=function(){_(gn,Jg)||(Ft("Setting up fake worker."),te(gn,Jg,!0)),gn._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){_(this,Gf).reject(new Error("Worker was destroyed"));return}const r=new JSt;te(this,Cd,r);const n=`fake${Ds(gn,EI)._++}`,s=new wS(n+"_worker",n,r);e.setup(s,r),te(this,Yl,new wS(n,n+"_worker",r)),ce(this,ga,RT).call(this)}).catch(e=>{_(this,Gf).reject(new Error(`Setting up fake worker failed: "${e.message}".`))})},s0=new WeakSet,MT=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},le(gn,s0),le(gn,EI,0),le(gn,Jg,!1),le(gn,Qg,new WeakMap),oa&&(te(gn,Jg,!0),ll.workerSrc||(ll.workerSrc="./pdf.worker.mjs")),gn._isSameOrigin=(e,r)=>{const n=URL.parse(e);if(!(n!=null&&n.origin)||n.origin==="null")return!1;const s=new URL(r,n);return n.origin===s.origin},gn._createCDNWrapper=e=>{const r=`await import("${e}");`;return URL.createObjectURL(new Blob([r],{type:"text/javascript"}))},gn.fromPort=e=>{if(FSt("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(e!=null&&e.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return gn.create(e)};let tk=gn;var Td,ru,i0,a0,Pd,Zg,AS;class z_t{constructor(e,r,n,s,i,a){le(this,Zg);le(this,Td,new Map);le(this,ru,new Map);le(this,i0,new Map);le(this,a0,new Map);le(this,Pd,null);this.messageHandler=e,this.loadingTask=r,this.commonObjs=new a1e,this.fontLoader=new WSt({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.wasmFactory=i.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=a,this.setupMessageHandler()}get annotationStorage(){return tr(this,"annotationStorage",new r7)}getRenderingIntent(e,r=pf.ENABLE,n=null,s=!1,i=!1){let a=bo.DISPLAY,o=z8;switch(e){case"any":a=bo.ANY;break;case"display":break;case"print":a=bo.PRINT;break;default:Ft(`getRenderingIntent - invalid intent: ${e}`)}const c=a&bo.PRINT&&n instanceof Vwe?n:this.annotationStorage;switch(r){case pf.DISABLE:a+=bo.ANNOTATIONS_DISABLE;break;case pf.ENABLE:break;case pf.ENABLE_FORMS:a+=bo.ANNOTATIONS_FORMS;break;case pf.ENABLE_STORAGE:a+=bo.ANNOTATIONS_STORAGE,o=c.serializable;break;default:Ft(`getRenderingIntent - invalid annotationMode: ${r}`)}s&&(a+=bo.IS_EDITING),i&&(a+=bo.OPLIST);const{ids:u,hash:d}=c.modifiedIds,h=[a,o.hash,d];return{renderingIntent:a,cacheKey:h.join("_"),annotationStorageSerializable:o,modifiedIds:u}}destroy(){var n;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(n=_(this,Pd))==null||n.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const s of _(this,ru).values())e.push(s._destroy());_(this,ru).clear(),_(this,i0).clear(),_(this,a0).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const r=this.messageHandler.sendWithPromise("Terminate",null);return e.push(r),Promise.all(e).then(()=>{var s,i;this.commonObjs.clear(),this.fontLoader.clear(),_(this,Td).clear(),this.filterFactory.destroy(),bw.cleanup(),(s=this._networkStream)==null||s.cancelAllRequests(new qp("Worker was terminated.")),(i=this.messageHandler)==null||i.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:r}=this;e.on("GetReader",(n,s)=>{us(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=i=>{this._lastProgress={loaded:i.loaded,total:i.total}},s.onPull=()=>{this._fullReader.read().then(function({value:i,done:a}){if(a){s.close();return}us(i instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(i),1,[i])}).catch(i=>{s.error(i)})},s.onCancel=i=>{this._fullReader.cancel(i),s.ready.catch(a=>{if(!this.destroyed)throw a})}}),e.on("ReaderHeadersReady",async n=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:s,isRangeSupported:i,contentLength:a}=this._fullReader;return(!s||!i)&&(this._lastProgress&&((o=r.onProgress)==null||o.call(r,this._lastProgress)),this._fullReader.onProgress=c=>{var u;(u=r.onProgress)==null||u.call(r,{loaded:c.loaded,total:c.total})}),{isStreamingSupported:s,isRangeSupported:i,contentLength:a}}),e.on("GetRangeReader",(n,s)=>{us(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(n.begin,n.end);if(!i){s.close();return}s.onPull=()=>{i.read().then(function({value:a,done:o}){if(o){s.close();return}us(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),s.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{s.error(a)})},s.onCancel=a=>{i.cancel(a),s.ready.catch(o=>{if(!this.destroyed)throw o})}}),e.on("GetDoc",({pdfInfo:n})=>{this._numPages=n.numPages,this._htmlForXfa=n.htmlForXfa,delete n.htmlForXfa,r._capability.resolve(new $_t(n,this))}),e.on("DocException",n=>{r._capability.reject(Ea(n))}),e.on("PasswordRequest",n=>{te(this,Pd,Promise.withResolvers());try{if(!r.onPassword)throw Ea(n);const s=i=>{i instanceof Error?_(this,Pd).reject(i):_(this,Pd).resolve({password:i})};r.onPassword(s,n.code)}catch(s){_(this,Pd).reject(s)}return _(this,Pd).promise}),e.on("DataLoaded",n=>{var s;(s=r.onProgress)==null||s.call(r,{loaded:n.length,total:n.length}),this.downloadInfoCapability.resolve(n)}),e.on("StartRenderPage",n=>{if(this.destroyed)return;_(this,ru).get(n.pageIndex)._startRenderPage(n.transparency,n.cacheKey)}),e.on("commonobj",([n,s,i])=>{var a;if(this.destroyed||this.commonObjs.has(n))return null;switch(s){case"Font":if("error"in i){const d=i.error;Ft(`Error during font loading: ${d}`),this.commonObjs.resolve(n,d);break}const o=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(d,h)=>globalThis.FontInspector.fontAdded(d,h):null,c=new qSt(i,o);this.fontLoader.bind(c).catch(()=>e.sendWithPromise("FontFallback",{id:n})).finally(()=>{!c.fontExtraProperties&&c.data&&(c.data=null),this.commonObjs.resolve(n,c)});break;case"CopyLocalImage":const{imageRef:u}=i;us(u,"The imageRef must be defined.");for(const d of _(this,ru).values())for(const[,h]of d.objs)if((h==null?void 0:h.ref)===u)return h.dataLen?(this.commonObjs.resolve(n,structuredClone(h)),h.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(n,i);break;default:throw new Error(`Got unknown common object type ${s}`)}return null}),e.on("obj",([n,s,i,a])=>{var c;if(this.destroyed)return;const o=_(this,ru).get(s);if(!o.objs.has(n)){if(o._intentStates.size===0){(c=a==null?void 0:a.bitmap)==null||c.close();return}switch(i){case"Image":case"Pattern":o.objs.resolve(n,a);break;default:throw new Error(`Got unknown object type ${i}`)}}}),e.on("DocProgress",n=>{var s;this.destroyed||(s=r.onProgress)==null||s.call(r,{loaded:n.loaded,total:n.total})}),e.on("FetchBinaryData",async n=>{if(this.destroyed)throw new Error("Worker was destroyed.");const s=this[n.type];if(!s)throw new Error(`${n.type} not initialized, see the \`useWorkerFetch\` parameter.`);return s.fetch(n)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var n;this.annotationStorage.size<=0&&Ft("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:r}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:((n=this._fullReader)==null?void 0:n.filename)??null},r).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const r=e-1,n=_(this,i0).get(r);if(n)return n;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:r}).then(i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&_(this,a0).set(i.refStr,e);const a=new B_t(r,i,this,this._params.pdfBug);return _(this,ru).set(r,a),a});return _(this,i0).set(r,s),s}getPageIndex(e){return U8(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,r){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:r})}getFieldObjects(){return ce(this,Zg,AS).call(this,"GetFieldObjects")}hasJSActions(){return ce(this,Zg,AS).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return ce(this,Zg,AS).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return ce(this,Zg,AS).call(this,"GetOptionalContentConfig").then(r=>new v_t(r,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",r=_(this,Td).get(e);if(r)return r;const n=this.messageHandler.sendWithPromise(e,null).then(s=>{var i,a;return{info:s[0],metadata:s[1]?new y_t(s[1]):null,contentDispositionFilename:((i=this._fullReader)==null?void 0:i.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return _(this,Td).set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const r of _(this,ru).values())if(!r.cleanup())throw new Error(`startCleanup: Page ${r.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),_(this,Td).clear(),this.filterFactory.destroy(!0),bw.cleanup()}}cachedPageNumber(e){if(!U8(e))return null;const r=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return _(this,a0).get(r)??null}}Td=new WeakMap,ru=new WeakMap,i0=new WeakMap,a0=new WeakMap,Pd=new WeakMap,Zg=new WeakSet,AS=function(e,r=null){const n=_(this,Td).get(e);if(n)return n;const s=this.messageHandler.sendWithPromise(e,r);return _(this,Td).set(e,s),s};var Kf;class U_t{constructor(e){le(this,Kf,null);Ve(this,"onContinue",null);Ve(this,"onError",null);te(this,Kf,e)}get promise(){return _(this,Kf).capability.promise}cancel(e=0){_(this,Kf).cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=_(this,Kf).operatorList;if(!e)return!1;const{annotationCanvasMap:r}=_(this,Kf);return e.form||e.canvas&&(r==null?void 0:r.size)>0}}Kf=new WeakMap;var Yf,ey;const Km=class Km{constructor({callback:e,params:r,objs:n,commonObjs:s,annotationCanvasMap:i,operatorList:a,pageIndex:o,canvasFactory:c,filterFactory:u,useRequestAnimationFrame:d=!1,pdfBug:h=!1,pageColors:f=null,enableHWA:p=!1}){le(this,Yf,null);this.callback=e,this.params=r,this.objs=n,this.commonObjs=s,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=c,this.filterFactory=u,this._pdfBug=h,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new U_t(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=r.canvas,this._canvasContext=r.canvas?null:r.canvasContext,this._enableHWA=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:r}){var o,c;if(this.cancelled)return;if(this._canvas){if(_(Km,ey).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");_(Km,ey).add(this._canvas)}this._pdfBug&&((o=globalThis.StepperManager)!=null&&o.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:n,transform:s,background:i}=this.params,a=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new db(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:r},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:s,viewport:n,transparency:e,background:i}),this.operatorListIdx=0,this.graphicsReady=!0,(c=this.graphicsReadyCallback)==null||c.call(this)}cancel(e=null,r=0){var n,s,i;this.running=!1,this.cancelled=!0,(n=this.gfx)==null||n.endDrawing(),_(this,Yf)&&(window.cancelAnimationFrame(_(this,Yf)),te(this,Yf,null)),_(Km,ey).delete(this._canvas),e||(e=new e7(`Rendering cancelled, page ${this._pageIndex+1}`,r)),this.callback(e),(i=(s=this.task).onError)==null||i.call(s,e)}operatorListChanged(){var e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?te(this,Yf,window.requestAnimationFrame(()=>{te(this,Yf,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),_(Km,ey).delete(this._canvas),this.callback())))}};Yf=new WeakMap,ey=new WeakMap,le(Km,ey,new WeakSet);let tz=Km;const eD="5.4.54",H_t="295fb3ec4";var lo,ty,o0,_s,gN,l0,Od,yN,Xf,Xl,xN,Fr,rz,nz,sz,Bm,p1e,Qh;const Aa=class Aa{constructor({editor:e=null,uiManager:r=null}){le(this,Fr);le(this,lo,null);le(this,ty,null);le(this,o0);le(this,_s,null);le(this,gN,!1);le(this,l0,!1);le(this,Od,null);le(this,yN);le(this,Xf,null);le(this,Xl,null);var n,s;e?(te(this,l0,!1),te(this,Od,e)):te(this,l0,!0),te(this,Xl,(e==null?void 0:e._uiManager)||r),te(this,yN,_(this,Xl)._eventBus),te(this,o0,((n=e==null?void 0:e.color)==null?void 0:n.toUpperCase())||((s=_(this,Xl))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),_(Aa,xN)||te(Aa,xN,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return tr(this,"_keyboardManager",new $E([[["Escape","mac+Escape"],Aa.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Aa.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Aa.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Aa.prototype._moveToPrevious],[["Home","mac+Home"],Aa.prototype._moveToBeginning],[["End","mac+End"],Aa.prototype._moveToEnd]]))}renderButton(){const e=te(this,lo,document.createElement("button"));e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.ariaHasPopup="true",_(this,Od)&&(e.ariaControls=`${_(this,Od).id}_colorpicker_dropdown`);const r=_(this,Xl)._signal;e.addEventListener("click",ce(this,Fr,Bm).bind(this),{signal:r}),e.addEventListener("keydown",ce(this,Fr,sz).bind(this),{signal:r});const n=te(this,ty,document.createElement("span"));return n.className="swatch",n.ariaHidden="true",n.style.backgroundColor=_(this,o0),e.append(n),e}renderMainDropdown(){const e=te(this,_s,ce(this,Fr,rz).call(this));return e.ariaOrientation="horizontal",e.ariaLabelledBy="highlightColorPickerLabel",e}_colorSelectFromKeyboard(e){if(e.target===_(this,lo)){ce(this,Fr,Bm).call(this,e);return}const r=e.target.getAttribute("data-color");r&&ce(this,Fr,nz).call(this,r,e)}_moveToNext(e){var r,n;if(!_(this,Fr,Qh)){ce(this,Fr,Bm).call(this,e);return}if(e.target===_(this,lo)){(r=_(this,_s).firstChild)==null||r.focus();return}(n=e.target.nextSibling)==null||n.focus()}_moveToPrevious(e){var r,n;if(e.target===((r=_(this,_s))==null?void 0:r.firstChild)||e.target===_(this,lo)){_(this,Fr,Qh)&&this._hideDropdownFromKeyboard();return}_(this,Fr,Qh)||ce(this,Fr,Bm).call(this,e),(n=e.target.previousSibling)==null||n.focus()}_moveToBeginning(e){var r;if(!_(this,Fr,Qh)){ce(this,Fr,Bm).call(this,e);return}(r=_(this,_s).firstChild)==null||r.focus()}_moveToEnd(e){var r;if(!_(this,Fr,Qh)){ce(this,Fr,Bm).call(this,e);return}(r=_(this,_s).lastChild)==null||r.focus()}hideDropdown(){var e,r;(e=_(this,_s))==null||e.classList.add("hidden"),_(this,lo).ariaExpanded="false",(r=_(this,Xf))==null||r.abort(),te(this,Xf,null)}_hideDropdownFromKeyboard(){var e;if(!_(this,l0)){if(!_(this,Fr,Qh)){(e=_(this,Od))==null||e.unselect();return}this.hideDropdown(),_(this,lo).focus({preventScroll:!0,focusVisible:_(this,gN)})}}updateColor(e){if(_(this,ty)&&(_(this,ty).style.backgroundColor=e),!_(this,_s))return;const r=_(this,Xl).highlightColors.values();for(const n of _(this,_s).children)n.ariaSelected=r.next().value===e.toUpperCase()}destroy(){var e,r;(e=_(this,lo))==null||e.remove(),te(this,lo,null),te(this,ty,null),(r=_(this,_s))==null||r.remove(),te(this,_s,null)}};lo=new WeakMap,ty=new WeakMap,o0=new WeakMap,_s=new WeakMap,gN=new WeakMap,l0=new WeakMap,Od=new WeakMap,yN=new WeakMap,Xf=new WeakMap,Xl=new WeakMap,xN=new WeakMap,Fr=new WeakSet,rz=function(){const e=document.createElement("div"),r=_(this,Xl)._signal;e.addEventListener("contextmenu",Al,{signal:r}),e.className="dropdown",e.role="listbox",e.ariaMultiSelectable="false",e.ariaOrientation="vertical",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),_(this,Od)&&(e.id=`${_(this,Od).id}_colorpicker_dropdown`);for(const[n,s]of _(this,Xl).highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",s),i.title=n,i.setAttribute("data-l10n-id",_(Aa,xN)[n]);const a=document.createElement("span");i.append(a),a.className="swatch",a.style.backgroundColor=s,i.ariaSelected=s===_(this,o0),i.addEventListener("click",ce(this,Fr,nz).bind(this,s),{signal:r}),e.append(i)}return e.addEventListener("keydown",ce(this,Fr,sz).bind(this),{signal:r}),e},nz=function(e,r){r.stopPropagation(),_(this,yN).dispatch("switchannotationeditorparams",{source:this,type:dr.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)},sz=function(e){Aa._keyboardManager.exec(this,e)},Bm=function(e){if(_(this,Fr,Qh)){this.hideDropdown();return}if(te(this,gN,e.detail===0),_(this,Xf)||(te(this,Xf,new AbortController),window.addEventListener("pointerdown",ce(this,Fr,p1e).bind(this),{signal:_(this,Xl).combinedSignal(_(this,Xf))})),_(this,lo).ariaExpanded="true",_(this,_s)){_(this,_s).classList.remove("hidden");return}const r=te(this,_s,ce(this,Fr,rz).call(this));_(this,lo).append(r)},p1e=function(e){var r;(r=_(this,_s))!=null&&r.contains(e.target)||this.hideDropdown()},Qh=function(){return _(this,_s)&&!_(this,_s).classList.contains("hidden")},le(Aa,xN,null);let vO=Aa;var nu,vN,c0,bN;const Ym=class Ym{constructor(e){le(this,nu,null);le(this,vN,null);le(this,c0,null);te(this,vN,e),te(this,c0,e._uiManager),_(Ym,bN)||te(Ym,bN,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(_(this,nu))return _(this,nu);const{editorType:e,colorType:r,colorValue:n}=_(this,vN),s=te(this,nu,document.createElement("input"));return s.type="color",s.value=n||"#000000",s.className="basicColorPicker",s.tabIndex=0,s.setAttribute("data-l10n-id",_(Ym,bN)[e]),s.addEventListener("input",()=>{_(this,c0).updateParams(r,s.value)},{signal:_(this,c0)._signal}),s}update(e){_(this,nu)&&(_(this,nu).value=e)}destroy(){var e;(e=_(this,nu))==null||e.remove(),te(this,nu,null)}hideDropdown(){}};nu=new WeakMap,vN=new WeakMap,c0=new WeakMap,bN=new WeakMap,le(Ym,bN,null);let bO=Ym;function nre(t){return Math.floor(Math.max(0,Math.min(1,t))*255).toString(16).padStart(2,"0")}function G1(t){return Math.max(0,Math.min(255,255*t))}class sre{static CMYK_G([e,r,n,s]){return["G",1-Math.min(1,.3*e+.59*n+.11*r+s)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=G1(e),[e,e,e]}static G_HTML([e]){const r=nre(e);return`#${r}${r}${r}`}static RGB_G([e,r,n]){return["G",.3*e+.59*r+.11*n]}static RGB_rgb(e){return e.map(G1)}static RGB_HTML(e){return`#${e.map(nre).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,r,n,s]){return["RGB",1-Math.min(1,e+s),1-Math.min(1,n+s),1-Math.min(1,r+s)]}static CMYK_rgb([e,r,n,s]){return[G1(1-Math.min(1,e+s)),G1(1-Math.min(1,n+s)),G1(1-Math.min(1,r+s))]}static CMYK_HTML(e){const r=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(r)}static RGB_CMYK([e,r,n]){const s=1-e,i=1-r,a=1-n,o=Math.min(s,i,a);return["CMYK",s,i,a,o]}}class V_t{create(e,r,n=!1){if(e<=0||r<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),n||(s.setAttribute("width",`${e}px`),s.setAttribute("height",`${r}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${e} ${r}`),s}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){$r("Abstract method `_createSVG` called.")}}class wO extends V_t{_createSVG(e){return document.createElementNS(Qu,e)}}class m1e{static setupStorage(e,r,n,s,i){const a=s.getValue(r,{value:null});switch(n.name){case"textarea":if(a.value!==null&&(e.textContent=a.value),i==="print")break;e.addEventListener("input",o=>{s.setValue(r,{value:o.target.value})});break;case"input":if(n.attributes.type==="radio"||n.attributes.type==="checkbox"){if(a.value===n.attributes.xfaOn?e.setAttribute("checked",!0):a.value===n.attributes.xfaOff&&e.removeAttribute("checked"),i==="print")break;e.addEventListener("change",o=>{s.setValue(r,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&e.setAttribute("value",a.value),i==="print")break;e.addEventListener("input",o=>{s.setValue(r,{value:o.target.value})})}break;case"select":if(a.value!==null){e.setAttribute("value",a.value);for(const o of n.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}e.addEventListener("input",o=>{const c=o.target.options,u=c.selectedIndex===-1?"":c[c.selectedIndex].value;s.setValue(r,{value:u})});break}}static setAttributes({html:e,element:r,storage:n=null,intent:s,linkService:i}){const{attributes:a}=r,o=e instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${s}`);for(const[c,u]of Object.entries(a))if(u!=null)switch(c){case"class":u.length&&e.setAttribute(c,u.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",u);break;case"style":Object.assign(e.style,u);break;case"textContent":e.textContent=u;break;default:(!o||c!=="href"&&c!=="newWindow")&&e.setAttribute(c,u)}o&&i.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,r,n)}static render(e){var h,f;const r=e.annotationStorage,n=e.linkService,s=e.xfaHtml,i=e.intent||"display",a=document.createElement(s.name);s.attributes&&this.setAttributes({html:a,element:s,intent:i,linkService:n});const o=i!=="richText",c=e.div;if(c.append(a),e.viewport){const p=`matrix(${e.viewport.transform.join(",")})`;c.style.transform=p}o&&c.setAttribute("class","xfaLayer xfaFont");const u=[];if(s.children.length===0){if(s.value){const p=document.createTextNode(s.value);a.append(p),o&&ek.shouldBuildText(s.name)&&u.push(p)}return{textDivs:u}}const d=[[s,-1,a]];for(;d.length>0;){const[p,m,g]=d.at(-1);if(m+1===p.children.length){d.pop();continue}const x=p.children[++d.at(-1)[1]];if(x===null)continue;const{name:y}=x;if(y==="#text"){const b=document.createTextNode(x.value);u.push(b),g.append(b);continue}const v=(h=x==null?void 0:x.attributes)!=null&&h.xmlns?document.createElementNS(x.attributes.xmlns,y):document.createElement(y);if(g.append(v),x.attributes&&this.setAttributes({html:v,element:x,storage:r,intent:i,linkService:n}),((f=x.children)==null?void 0:f.length)>0)d.push([x,-1,v]);else if(x.value){const b=document.createTextNode(x.value);o&&ek.shouldBuildText(y)&&u.push(b),v.append(b)}}for(const p of c.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))p.setAttribute("readOnly",!0);return{textDivs:u}}static update(e){const r=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=r,e.div.hidden=!1}}const W_t=9,sx=new WeakSet,q_t=new Date().getTimezoneOffset()*60*1e3;class ire{static create(e){switch(e.data.annotationType){case ss.LINK:return new i7(e);case ss.TEXT:return new G_t(e);case ss.WIDGET:switch(e.data.fieldType){case"Tx":return new K_t(e);case"Btn":return e.data.radioButton?new x1e(e):e.data.checkBox?new X_t(e):new J_t(e);case"Ch":return new Q_t(e);case"Sig":return new Y_t(e)}return new Ax(e);case ss.POPUP:return new az(e);case ss.FREETEXT:return new _1e(e);case ss.LINE:return new ejt(e);case ss.SQUARE:return new tjt(e);case ss.CIRCLE:return new rjt(e);case ss.POLYLINE:return new j1e(e);case ss.CARET:return new sjt(e);case ss.INK:return new a7(e);case ss.POLYGON:return new njt(e);case ss.HIGHLIGHT:return new k1e(e);case ss.UNDERLINE:return new ijt(e);case ss.SQUIGGLY:return new ajt(e);case ss.STRIKEOUT:return new ojt(e);case ss.STAMP:return new N1e(e);case ss.FILEATTACHMENT:return new ljt(e);default:return new es(e)}}}var ry,u0,Id,wN,iz;const _q=class _q{constructor(e,{isRenderable:r=!1,ignoreBorder:n=!1,createQuadrilaterals:s=!1}={}){le(this,wN);le(this,ry,null);le(this,u0,!1);le(this,Id,null);this.isRenderable=r,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,r&&(this.container=this._createContainer(n)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:r}){return!!(e!=null&&e.str||r!=null&&r.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return _q._hasPopupData(this.data)}updateEdited(e){var i;if(!this.container)return;e.rect&&(_(this,ry)||te(this,ry,{rect:this.data.rect.slice(0)}));const{rect:r,popup:n}=e;r&&ce(this,wN,iz).call(this,r);let s=((i=_(this,Id))==null?void 0:i.popup)||this.popup;!s&&(n!=null&&n.text)&&(this._createPopup(n),s=_(this,Id).popup),s&&(s.updateEdited(e),n!=null&&n.deleted&&(s.remove(),te(this,Id,null),this.popup=null))}resetEdited(){var e;_(this,ry)&&(ce(this,wN,iz).call(this,_(this,ry).rect),(e=_(this,Id))==null||e.popup.resetEdited(),te(this,ry,null))}_createContainer(e){const{data:r,parent:{page:n,viewport:s}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",r.id),!(this instanceof Ax)&&!(this instanceof i7)&&(i.tabIndex=0);const{style:a}=i;if(a.zIndex=this.parent.zIndex++,r.alternativeText&&(i.title=r.alternativeText),r.noRotate&&i.classList.add("norotate"),!r.rect||this instanceof az){const{rotation:g}=r;return!r.hasOwnCanvas&&g!==0&&this.setRotation(g,i),i}const{width:o,height:c}=this;if(!e&&r.borderStyle.width>0){a.borderWidth=`${r.borderStyle.width}px`;const g=r.borderStyle.horizontalCornerRadius,x=r.borderStyle.verticalCornerRadius;if(g>0||x>0){const v=`calc(${g}px * var(--total-scale-factor)) / calc(${x}px * var(--total-scale-factor))`;a.borderRadius=v}else if(this instanceof x1e){const v=`calc(${o}px * var(--total-scale-factor)) / calc(${c}px * var(--total-scale-factor))`;a.borderRadius=v}switch(r.borderStyle.style){case nv.SOLID:a.borderStyle="solid";break;case nv.DASHED:a.borderStyle="dashed";break;case nv.BEVELED:Ft("Unimplemented border style: beveled");break;case nv.INSET:Ft("Unimplemented border style: inset");break;case nv.UNDERLINE:a.borderBottomStyle="solid";break}const y=r.borderColor||null;y?(te(this,u0,!0),a.borderColor=jt.makeHexColor(y[0]|0,y[1]|0,y[2]|0)):a.borderWidth=0}const u=jt.normalizeRect([r.rect[0],n.view[3]-r.rect[1]+n.view[1],r.rect[2],n.view[3]-r.rect[3]+n.view[1]]),{pageWidth:d,pageHeight:h,pageX:f,pageY:p}=s.rawDims;a.left=`${100*(u[0]-f)/d}%`,a.top=`${100*(u[1]-p)/h}%`;const{rotation:m}=r;return r.hasOwnCanvas||m===0?(a.width=`${100*o/d}%`,a.height=`${100*c/h}%`):this.setRotation(m,i),i}setRotation(e,r=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:s}=this.parent.viewport.rawDims;let{width:i,height:a}=this;e%180!==0&&([i,a]=[a,i]),r.style.width=`${100*i/n}%`,r.style.height=`${100*a/s}%`,r.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(r,n,s)=>{const i=s.detail[r],a=i[0],o=i.slice(1);s.target.style[n]=sre[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[n]:sre[`${a}_rgb`](o)})};return tr(this,"_commonActions",{display:r=>{const{display:n}=r.detail,s=n%2===1;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:n===1||n===2})},print:r=>{this.annotationStorage.setValue(this.data.id,{noPrint:!r.detail.print})},hidden:r=>{const{hidden:n}=r.detail;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:n,noView:n})},focus:r=>{setTimeout(()=>r.target.focus({preventScroll:!1}),0)},userName:r=>{r.target.title=r.detail.userName},readonly:r=>{r.target.disabled=r.detail.readonly},required:r=>{this._setRequired(r.target,r.detail.required)},bgColor:r=>{e("bgColor","backgroundColor",r)},fillColor:r=>{e("fillColor","backgroundColor",r)},fgColor:r=>{e("fgColor","color",r)},textColor:r=>{e("textColor","color",r)},borderColor:r=>{e("borderColor","borderColor",r)},strokeColor:r=>{e("strokeColor","borderColor",r)},rotation:r=>{const n=r.detail.rotation;this.setRotation(n),this.annotationStorage.setValue(this.data.id,{rotation:n})}})}_dispatchEventFromSandbox(e,r){const n=this._commonActions;for(const s of Object.keys(r.detail)){const i=e[s]||n[s];i==null||i(r)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const r=this.annotationStorage.getRawValue(this.data.id);if(!r)return;const n=this._commonActions;for(const[s,i]of Object.entries(r)){const a=n[s];if(a){const o={detail:{[s]:i},target:e};a(o),delete r[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[r,n,s,i]=this.data.rect.map(g=>Math.fround(g));if(e.length===8){const[g,x,y,v]=e.subarray(2,6);if(s===g&&i===x&&r===y&&n===v)return}const{style:a}=this.container;let o;if(_(this,u0)){const{borderColor:g,borderWidth:x}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${g}" stroke-width="${x}">`],this.container.classList.add("hasBorder")}const c=s-r,u=i-n,{svgFactory:d}=this,h=d.createElement("svg");h.classList.add("quadrilateralsContainer"),h.setAttribute("width",0),h.setAttribute("height",0),h.role="none";const f=d.createElement("defs");h.append(f);const p=d.createElement("clipPath"),m=`clippath_${this.data.id}`;p.setAttribute("id",m),p.setAttribute("clipPathUnits","objectBoundingBox"),f.append(p);for(let g=2,x=e.length;g<x;g+=8){const y=e[g],v=e[g+1],b=e[g+2],w=e[g+3],S=d.createElement("rect"),k=(b-r)/c,E=(i-v)/u,C=(y-b)/c,A=(v-w)/u;S.setAttribute("x",k),S.setAttribute("y",E),S.setAttribute("width",C),S.setAttribute("height",A),p.append(S),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${k}" y="${E}" width="${C}" height="${A}"/>`)}_(this,u0)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(h),this.container.style.clipPath=`url(#${m})`}_createPopup(e=null){const{data:r}=this;let n,s;e?(n={str:e.text},s=e.date):(n=r.contentsObj,s=r.modificationDate);const i=te(this,Id,new az({data:{color:r.color,titleObj:r.titleObj,modificationDate:s,contentsObj:n,richText:r.richText,parentRect:r.rect,borderStyle:0,id:`popup_${r.id}`,rotation:r.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent.div.append(i.render())}get hasPopupElement(){return!!(_(this,Id)||this.popup||this.data.popupRef)}render(){$r("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,r=null){const n=[];if(this._fieldObjects){const s=this._fieldObjects[e];if(s)for(const{page:i,id:a,exportValues:o}of s){if(i===-1||a===r)continue;const c=typeof o=="string"?o:null,u=document.querySelector(`[data-element-id="${a}"]`);if(u&&!sx.has(u)){Ft(`_getElementsByName - element not allowed: ${a}`);continue}n.push({id:a,exportValue:c,domElement:u})}return n}for(const s of document.getElementsByName(e)){const{exportValue:i}=s,a=s.getAttribute("data-element-id");a!==r&&sx.has(s)&&n.push({id:a,exportValue:i,domElement:s})}return n}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const r of e)r.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:r}}=this;this.container.addEventListener("dblclick",()=>{var n;(n=this.linkService.eventBus)==null||n.dispatch("switchannotationeditormode",{source:this,mode:e,editId:r,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};ry=new WeakMap,u0=new WeakMap,Id=new WeakMap,wN=new WeakSet,iz=function(e){const{container:{style:r},data:{rect:n,rotation:s},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:c}}}}=this;n==null||n.splice(0,4,...e),r.left=`${100*(e[0]-o)/i}%`,r.top=`${100*(a-e[3]+c)/a}%`,s===0?(r.width=`${100*(e[2]-e[0])/i}%`,r.height=`${100*(e[3]-e[1])/a}%`):this.setRotation(s)};let es=_q;var jo,zm,g1e,y1e;class i7 extends es{constructor(r,n=null){super(r,{isRenderable:!0,ignoreBorder:!!(n!=null&&n.ignoreBorder),createQuadrilaterals:!0});le(this,jo);this.isTooltipOnly=r.data.isTooltipOnly}render(){const{data:r,linkService:n}=this,s=document.createElement("a");s.setAttribute("data-element-id",r.id);let i=!1;return r.url?(n.addLinkAttributes(s,r.url,r.newWindow),i=!0):r.action?(this._bindNamedAction(s,r.action,r.overlaidText),i=!0):r.attachment?(ce(this,jo,g1e).call(this,s,r.attachment,r.overlaidText,r.attachmentDest),i=!0):r.setOCGState?(ce(this,jo,y1e).call(this,s,r.setOCGState,r.overlaidText),i=!0):r.dest?(this._bindLink(s,r.dest,r.overlaidText),i=!0):(r.actions&&(r.actions.Action||r.actions["Mouse Up"]||r.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,r),i=!0),r.resetForm?(this._bindResetFormAction(s,r.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(s),this.container}_bindLink(r,n,s=""){r.href=this.linkService.getDestinationHash(n),r.onclick=()=>(n&&this.linkService.goToDestination(n),!1),(n||n==="")&&ce(this,jo,zm).call(this),s&&(r.title=s)}_bindNamedAction(r,n,s=""){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeNamedAction(n),!1),s&&(r.title=s),ce(this,jo,zm).call(this)}_bindJSAction(r,n){r.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(n.actions)){const a=s.get(i);a&&(r[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n.id,name:i}}),!1})}n.overlaidText&&(r.title=n.overlaidText),r.onclick||(r.onclick=()=>!1),ce(this,jo,zm).call(this)}_bindResetFormAction(r,n){const s=r.onclick;if(s||(r.href=this.linkService.getAnchorUrl("")),ce(this,jo,zm).call(this),!this._fieldObjects){Ft('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(r.onclick=()=>!1);return}r.onclick=()=>{var h;s==null||s();const{fields:i,refs:a,include:o}=n,c=[];if(i.length!==0||a.length!==0){const f=new Set(a);for(const p of i){const m=this._fieldObjects[p]||[];for(const{id:g}of m)f.add(g)}for(const p of Object.values(this._fieldObjects))for(const m of p)f.has(m.id)===o&&c.push(m)}else for(const f of Object.values(this._fieldObjects))c.push(...f);const u=this.annotationStorage,d=[];for(const f of c){const{id:p}=f;switch(d.push(p),f.type){case"text":{const g=f.defaultValue||"";u.setValue(p,{value:g});break}case"checkbox":case"radiobutton":{const g=f.defaultValue===f.exportValues;u.setValue(p,{value:g});break}case"combobox":case"listbox":{const g=f.defaultValue||"";u.setValue(p,{value:g});break}default:continue}const m=document.querySelector(`[data-element-id="${p}"]`);if(m){if(!sx.has(m)){Ft(`_bindResetFormAction - element not allowed: ${p}`);continue}}else continue;m.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((h=this.linkService.eventBus)==null||h.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:d,name:"ResetForm"}})),!1}}}jo=new WeakSet,zm=function(){this.container.setAttribute("data-internal-link","")},g1e=function(r,n,s="",i=null){r.href=this.linkService.getAnchorUrl(""),n.description?r.title=n.description:s&&(r.title=s),r.onclick=()=>{var a;return(a=this.downloadManager)==null||a.openOrDownloadData(n.content,n.filename,i),!1},ce(this,jo,zm).call(this)},y1e=function(r,n,s=""){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeSetOCGState(n),!1),s&&(r.title=s),ce(this,jo,zm).call(this)};class G_t extends es{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class Ax extends es{render(){return this.container}showElementAndHideCanvas(e){var r;this.data.hasOwnCanvas&&(((r=e.previousSibling)==null?void 0:r.nodeName)==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return wi.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,r,n,s,i){n.includes("mouse")?e.addEventListener(n,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:i(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):e.addEventListener(n,a=>{var o;if(n==="blur"){if(!r.focused||!a.relatedTarget)return;r.focused=!1}else if(n==="focus"){if(r.focused)return;r.focused=!0}i&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:i(a)}}))})}_setEventListeners(e,r,n,s){var i,a,o;for(const[c,u]of n)(u==="Action"||(i=this.data.actions)!=null&&i[u])&&((u==="Focus"||u==="Blur")&&(r||(r={focused:!1})),this._setEventListener(e,r,c,u,s),u==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(e,r,"blur","Blur",null):u==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(e,r,"focus","Focus",null))}_setBackgroundColor(e){const r=this.data.backgroundColor||null;e.style.backgroundColor=r===null?"transparent":jt.makeHexColor(r[0],r[1],r[2])}_setTextStyle(e){const r=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||W_t,i=e.style;let a;const o=2,c=u=>Math.round(10*u)/10;if(this.data.multiLine){const u=Math.abs(this.data.rect[3]-this.data.rect[1]-o),d=Math.round(u/(H4*s))||1,h=u/d;a=Math.min(s,c(h/H4))}else{const u=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(s,c(u/H4))}i.fontSize=`calc(${a}px * var(--total-scale-factor))`,i.color=jt.makeHexColor(n[0],n[1],n[2]),this.data.textAlignment!==null&&(i.textAlign=r[this.data.textAlignment])}_setRequired(e,r){r?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",r)}}class K_t extends Ax{constructor(e){const r=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:r})}setPropertyOnSiblings(e,r,n,s){const i=this.annotationStorage;for(const a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[r]=n),i.setValue(a.id,{[s]:n})}render(){var s,i;const e=this.annotationStorage,r=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const a=e.getValue(r,{value:this.data.fieldValue});let o=a.value||"";const c=e.getValue(r,{charLimit:this.data.maxLen}).charLimit;c&&o.length>c&&(o=o.slice(0,c));let u=a.formattedValue||((s=this.data.textContent)==null?void 0:s.join(`
`))||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,""));const d={userValue:o,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=u??o,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type=this.data.password?"password":"text",n.setAttribute("value",u??o),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),sx.add(n),n.setAttribute("data-element-id",r),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=0;const{datetimeFormat:h,datetimeType:f,timeStep:p}=this.data,m=!!f&&this.enableScripting;h&&(n.title=h),this._setRequired(n,this.data.required),c&&(n.maxLength=c),n.addEventListener("input",x=>{e.setValue(r,{value:x.target.value}),this.setPropertyOnSiblings(n,"value",x.target.value,"value"),d.formattedValue=null}),n.addEventListener("resetform",x=>{const y=this.data.defaultFieldValue??"";n.value=d.userValue=y,d.formattedValue=null});let g=x=>{const{formattedValue:y}=d;y!=null&&(x.target.value=y),x.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",y=>{var b;if(d.focused)return;const{target:v}=y;if(m&&(v.type=f,p&&(v.step=p)),d.userValue){const w=d.userValue;if(m)if(f==="time"){const S=new Date(w),k=[S.getHours(),S.getMinutes(),S.getSeconds()];v.value=k.map(E=>E.toString().padStart(2,"0")).join(":")}else v.value=new Date(w-q_t).toISOString().split(f==="date"?"T":".",1)[0];else v.value=w}d.lastCommittedValue=v.value,d.commitKey=1,(b=this.data.actions)!=null&&b.Focus||(d.focused=!0)}),n.addEventListener("updatefromsandbox",y=>{this.showElementAndHideCanvas(y.target);const v={value(b){d.userValue=b.detail.value??"",m||e.setValue(r,{value:d.userValue.toString()}),b.target.value=d.userValue},formattedValue(b){const{formattedValue:w}=b.detail;d.formattedValue=w,w!=null&&b.target!==document.activeElement&&(b.target.value=w);const S={formattedValue:w};m&&(S.value=w),e.setValue(r,S)},selRange(b){b.target.setSelectionRange(...b.detail.selRange)},charLimit:b=>{var E;const{charLimit:w}=b.detail,{target:S}=b;if(w===0){S.removeAttribute("maxLength");return}S.setAttribute("maxLength",w);let k=d.userValue;!k||k.length<=w||(k=k.slice(0,w),S.value=d.userValue=k,e.setValue(r,{value:k}),(E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:k,willCommit:!0,commitKey:1,selStart:S.selectionStart,selEnd:S.selectionEnd}}))}};this._dispatchEventFromSandbox(v,y)}),n.addEventListener("keydown",y=>{var w;d.commitKey=1;let v=-1;if(y.key==="Escape"?v=0:y.key==="Enter"&&!this.data.multiLine?v=2:y.key==="Tab"&&(d.commitKey=3),v===-1)return;const{value:b}=y.target;d.lastCommittedValue!==b&&(d.lastCommittedValue=b,d.userValue=b,(w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:b,willCommit:!0,commitKey:v,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}))});const x=g;g=null,n.addEventListener("blur",y=>{var w,S;if(!d.focused||!y.relatedTarget)return;(w=this.data.actions)!=null&&w.Blur||(d.focused=!1);const{target:v}=y;let{value:b}=v;if(m){if(b&&f==="time"){const k=b.split(":").map(E=>parseInt(E,10));b=new Date(2e3,0,1,k[0],k[1],k[2]||0).valueOf(),v.step=""}else b=new Date(b).valueOf();v.type="text"}d.userValue=b,d.lastCommittedValue!==b&&((S=this.linkService.eventBus)==null||S.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:b,willCommit:!0,commitKey:d.commitKey,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}})),x(y)}),(i=this.data.actions)!=null&&i.Keystroke&&n.addEventListener("beforeinput",y=>{var A;d.lastCommittedValue=null;const{data:v,target:b}=y,{value:w,selectionStart:S,selectionEnd:k}=b;let E=S,C=k;switch(y.inputType){case"deleteWordBackward":{const M=w.substring(0,S).match(/\w*[^\w]*$/);M&&(E-=M[0].length);break}case"deleteWordForward":{const M=w.substring(S).match(/^[^\w]*\w*/);M&&(C+=M[0].length);break}case"deleteContentBackward":S===k&&(E-=1);break;case"deleteContentForward":S===k&&(C+=1);break}y.preventDefault(),(A=this.linkService.eventBus)==null||A.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:w,change:v||"",willCommit:!1,selStart:E,selEnd:C}})}),this._setEventListeners(n,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],y=>y.target.value)}if(g&&n.addEventListener("blur",g),this.data.comb){const y=(this.data.rect[2]-this.data.rect[0])/c;n.classList.add("comb"),n.style.letterSpacing=`calc(${y}px * var(--total-scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Y_t extends Ax{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class X_t extends Ax{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,r=this.data,n=r.id;let s=e.getValue(n,{value:r.exportValue===r.fieldValue}).value;typeof s=="string"&&(s=s!=="Off",e.setValue(n,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const i=document.createElement("input");return sx.add(i),i.setAttribute("data-element-id",n),i.disabled=r.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=r.fieldName,s&&i.setAttribute("checked",!0),i.setAttribute("exportValue",r.exportValue),i.tabIndex=0,i.addEventListener("change",a=>{const{name:o,checked:c}=a.target;for(const u of this._getElementsByName(o,n)){const d=c&&u.exportValue===r.exportValue;u.domElement&&(u.domElement.checked=d),e.setValue(u.id,{value:d})}e.setValue(n,{value:c})}),i.addEventListener("resetform",a=>{const o=r.defaultFieldValue||"Off";a.target.checked=o===r.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",a=>{const o={value(c){c.target.checked=c.detail.value!=="Off",e.setValue(n,{value:c.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class x1e extends Ax{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,r=this.data,n=r.id;let s=e.getValue(n,{value:r.fieldValue===r.buttonValue}).value;if(typeof s=="string"&&(s=s!==r.buttonValue,e.setValue(n,{value:s})),s)for(const a of this._getElementsByName(r.fieldName,n))e.setValue(a.id,{value:!1});const i=document.createElement("input");if(sx.add(i),i.setAttribute("data-element-id",n),i.disabled=r.readOnly,this._setRequired(i,this.data.required),i.type="radio",i.name=r.fieldName,s&&i.setAttribute("checked",!0),i.tabIndex=0,i.addEventListener("change",a=>{const{name:o,checked:c}=a.target;for(const u of this._getElementsByName(o,n))e.setValue(u.id,{value:!1});e.setValue(n,{value:c})}),i.addEventListener("resetform",a=>{const o=r.defaultFieldValue;a.target.checked=o!=null&&o===r.buttonValue}),this.enableScripting&&this.hasJSActions){const a=r.buttonValue;i.addEventListener("updatefromsandbox",o=>{const c={value:u=>{const d=a===u.detail.value;for(const h of this._getElementsByName(u.target.name)){const f=d&&h.id===n;h.domElement&&(h.domElement.checked=f),e.setValue(h.id,{value:f})}}};this._dispatchEventFromSandbox(c,o)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class J_t extends i7{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const r=e.lastChild;return this.enableScripting&&this.hasJSActions&&r&&(this._setDefaultPropertiesFromJS(r),r.addEventListener("updatefromsandbox",n=>{this._dispatchEventFromSandbox({},n)})),e}}class Q_t extends Ax{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,r=this.data.id,n=e.getValue(r,{value:this.data.fieldValue}),s=document.createElement("select");sx.add(s),s.setAttribute("data-element-id",r),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=0;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",d=>{const h=this.data.defaultFieldValue;for(const f of s.options)f.selected=f.value===h});for(const d of this.data.options){const h=document.createElement("option");h.textContent=d.displayValue,h.value=d.exportValue,n.value.includes(d.exportValue)&&(h.setAttribute("selected",!0),i=!1),s.append(h)}let a=null;if(i){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),s.prepend(d),a=()=>{d.remove(),s.removeEventListener("input",a),a=null},s.addEventListener("input",a)}const o=d=>{const h=d?"value":"textContent",{options:f,multiple:p}=s;return p?Array.prototype.filter.call(f,m=>m.selected).map(m=>m[h]):f.selectedIndex===-1?null:f[f.selectedIndex][h]};let c=o(!1);const u=d=>{const h=d.target.options;return Array.prototype.map.call(h,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",d=>{const h={value(f){a==null||a();const p=f.detail.value,m=new Set(Array.isArray(p)?p:[p]);for(const g of s.options)g.selected=m.has(g.value);e.setValue(r,{value:o(!0)}),c=o(!1)},multipleSelection(f){s.multiple=!0},remove(f){const p=s.options,m=f.detail.remove;p[m].selected=!1,s.remove(m),p.length>0&&Array.prototype.findIndex.call(p,x=>x.selected)===-1&&(p[0].selected=!0),e.setValue(r,{value:o(!0),items:u(f)}),c=o(!1)},clear(f){for(;s.length!==0;)s.remove(0);e.setValue(r,{value:null,items:[]}),c=o(!1)},insert(f){const{index:p,displayValue:m,exportValue:g}=f.detail.insert,x=s.children[p],y=document.createElement("option");y.textContent=m,y.value=g,x?x.before(y):s.append(y),e.setValue(r,{value:o(!0),items:u(f)}),c=o(!1)},items(f){const{items:p}=f.detail;for(;s.length!==0;)s.remove(0);for(const m of p){const{displayValue:g,exportValue:x}=m,y=document.createElement("option");y.textContent=g,y.value=x,s.append(y)}s.options.length>0&&(s.options[0].selected=!0),e.setValue(r,{value:o(!0),items:u(f)}),c=o(!1)},indices(f){const p=new Set(f.detail.indices);for(const m of f.target.options)m.selected=p.has(m.index);e.setValue(r,{value:o(!0)}),c=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(h,d)}),s.addEventListener("input",d=>{var p;const h=o(!0),f=o(!1);e.setValue(r,{value:h}),d.preventDefault(),(p=this.linkService.eventBus)==null||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:c,change:f,changeEx:h,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):s.addEventListener("input",function(d){e.setValue(r,{value:o(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class az extends es{constructor(e){const{data:r,elements:n}=e;super(e,{isRenderable:es._hasPopupData(r)}),this.elements=n,this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";const r=this.popup=new Z_t({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),n=[];for(const s of this.elements)s.popup=r,s.container.ariaHasPopup="dialog",n.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",n.map(s=>`${Z9}${s}`).join(",")),this.container}}var d0,AI,CI,h0,f0,Dn,Rd,Jf,p0,SN,m0,su,co,Qf,Md,_N,Dd,g0,ny,Zf,br,DT,LT,oz,v1e,b1e,w1e,S1e,FT,$T,lz;class Z_t{constructor({container:e,color:r,elements:n,titleObj:s,modificationDate:i,contentsObj:a,richText:o,parent:c,rect:u,parentRect:d,open:h}){le(this,br);le(this,d0,ce(this,br,w1e).bind(this));le(this,AI,ce(this,br,lz).bind(this));le(this,CI,ce(this,br,$T).bind(this));le(this,h0,ce(this,br,FT).bind(this));le(this,f0,null);le(this,Dn,null);le(this,Rd,null);le(this,Jf,null);le(this,p0,null);le(this,SN,null);le(this,m0,null);le(this,su,!1);le(this,co,null);le(this,Qf,null);le(this,Md,null);le(this,_N,null);le(this,Dd,null);le(this,g0,null);le(this,ny,null);le(this,Zf,!1);te(this,Dn,e),te(this,g0,s),te(this,Rd,a),te(this,Dd,o),te(this,SN,c),te(this,f0,r),te(this,_N,u),te(this,m0,d),te(this,p0,n),te(this,Jf,gO.toDateObject(i)),this.trigger=n.flatMap(f=>f.getElementsToTriggerPopup()),ce(this,br,DT).call(this),_(this,Dn).hidden=!0,h&&ce(this,br,FT).call(this)}render(){var s;if(_(this,co))return;const e=te(this,co,document.createElement("div"));if(e.className="popup",_(this,f0)){const i=e.style.outlineColor=jt.makeHexColor(..._(this,f0));e.style.backgroundColor=`color-mix(in srgb, ${i} 30%, white)`}const r=document.createElement("span");if(r.className="header",(s=_(this,g0))!=null&&s.str){const i=document.createElement("span");i.className="title",r.append(i),{dir:i.dir,str:i.textContent}=_(this,g0)}if(e.append(r),_(this,Jf)){const i=document.createElement("time");i.className="popupDate",i.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),i.setAttribute("data-l10n-args",JSON.stringify({dateObj:_(this,Jf).valueOf()})),i.dateTime=_(this,Jf).toISOString(),r.append(i)}const n=_(this,br,LT);if(n)m1e.render({xfaHtml:n,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const i=this._formatContents(_(this,Rd));e.append(i)}_(this,Dn).append(e)}_formatContents({str:e,dir:r}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=r;const s=e.split(/(?:\r\n?|\n)/);for(let i=0,a=s.length;i<a;++i){const o=s[i];n.append(document.createTextNode(o)),i<a-1&&n.append(document.createElement("br"))}return n}updateEdited({rect:e,popup:r,deleted:n}){var s;if(n||r!=null&&r.deleted){this.remove();return}ce(this,br,DT).call(this),_(this,ny)||te(this,ny,{contentsObj:_(this,Rd),richText:_(this,Dd)}),e&&te(this,Md,null),r&&(te(this,Dd,ce(this,br,b1e).call(this,r.text)),te(this,Jf,gO.toDateObject(r.date)),te(this,Rd,null)),(s=_(this,co))==null||s.remove(),te(this,co,null)}resetEdited(){var e;_(this,ny)&&({contentsObj:Ds(this,Rd)._,richText:Ds(this,Dd)._}=_(this,ny),te(this,ny,null),(e=_(this,co))==null||e.remove(),te(this,co,null),te(this,Md,null))}remove(){var e,r;(e=_(this,Qf))==null||e.abort(),te(this,Qf,null),(r=_(this,co))==null||r.remove(),te(this,co,null),te(this,Zf,!1),te(this,su,!1);for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){te(this,Zf,this.isVisible),_(this,Zf)&&(_(this,Dn).hidden=!0)}maybeShow(){ce(this,br,DT).call(this),_(this,Zf)&&(_(this,co)||ce(this,br,$T).call(this),te(this,Zf,!1),_(this,Dn).hidden=!1)}get isVisible(){return _(this,Dn).hidden===!1}}d0=new WeakMap,AI=new WeakMap,CI=new WeakMap,h0=new WeakMap,f0=new WeakMap,Dn=new WeakMap,Rd=new WeakMap,Jf=new WeakMap,p0=new WeakMap,SN=new WeakMap,m0=new WeakMap,su=new WeakMap,co=new WeakMap,Qf=new WeakMap,Md=new WeakMap,_N=new WeakMap,Dd=new WeakMap,g0=new WeakMap,ny=new WeakMap,Zf=new WeakMap,br=new WeakSet,DT=function(){var r;if(_(this,Qf))return;te(this,Qf,new AbortController);const{signal:e}=_(this,Qf);for(const n of this.trigger)n.addEventListener("click",_(this,h0),{signal:e}),n.addEventListener("mouseenter",_(this,CI),{signal:e}),n.addEventListener("mouseleave",_(this,AI),{signal:e}),n.classList.add("popupTriggerArea");for(const n of _(this,p0))(r=n.container)==null||r.addEventListener("keydown",_(this,d0),{signal:e})},LT=function(){const e=_(this,Dd),r=_(this,Rd);return e!=null&&e.str&&(!(r!=null&&r.str)||r.str===e.str)&&_(this,Dd).html||null},oz=function(){var e,r,n;return((n=(r=(e=_(this,br,LT))==null?void 0:e.attributes)==null?void 0:r.style)==null?void 0:n.fontSize)||0},v1e=function(){var e,r,n;return((n=(r=(e=_(this,br,LT))==null?void 0:e.attributes)==null?void 0:r.style)==null?void 0:n.color)||null},b1e=function(e){const r=[],n={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:r}]}},s={style:{color:_(this,br,v1e),fontSize:_(this,br,oz)?`calc(${_(this,br,oz)}px * var(--total-scale-factor))`:""}};for(const i of e.split(`
`))r.push({name:"span",value:i,attributes:s});return n},w1e=function(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key==="Enter"||e.key==="Escape"&&_(this,su))&&ce(this,br,FT).call(this)},S1e=function(){if(_(this,Md)!==null)return;const{page:{view:e},viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:s,pageY:i}}}=_(this,SN);let a=!!_(this,m0),o=a?_(this,m0):_(this,_N);for(const m of _(this,p0))if(!o||jt.intersect(m.data.rect,o)!==null){o=m.data.rect,a=!0;break}const c=jt.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),d=a?o[2]-o[0]+5:0,h=c[0]+d,f=c[1];te(this,Md,[100*(h-s)/r,100*(f-i)/n]);const{style:p}=_(this,Dn);p.left=`${_(this,Md)[0]}%`,p.top=`${_(this,Md)[1]}%`},FT=function(){te(this,su,!_(this,su)),_(this,su)?(ce(this,br,$T).call(this),_(this,Dn).addEventListener("click",_(this,h0)),_(this,Dn).addEventListener("keydown",_(this,d0))):(ce(this,br,lz).call(this),_(this,Dn).removeEventListener("click",_(this,h0)),_(this,Dn).removeEventListener("keydown",_(this,d0)))},$T=function(){_(this,co)||this.render(),this.isVisible?_(this,su)&&_(this,Dn).classList.add("focused"):(ce(this,br,S1e).call(this),_(this,Dn).hidden=!1,_(this,Dn).style.zIndex=parseInt(_(this,Dn).style.zIndex)+1e3)},lz=function(){_(this,Dn).classList.remove("focused"),!(_(this,su)||!this.isVisible)&&(_(this,Dn).hidden=!0,_(this,Dn).style.zIndex=parseInt(_(this,Dn).style.zIndex)-1e3)};class _1e extends es{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=Lt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(const r of this.textContent){const n=document.createElement("span");n.textContent=r,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var jN;class ejt extends es{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,jN,null)}render(){this.container.classList.add("lineAnnotation");const{data:r,width:n,height:s}=this,i=this.svgFactory.create(n,s,!0),a=te(this,jN,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",r.rect[2]-r.lineCoordinates[0]),a.setAttribute("y1",r.rect[3]-r.lineCoordinates[1]),a.setAttribute("x2",r.rect[2]-r.lineCoordinates[2]),a.setAttribute("y2",r.rect[3]-r.lineCoordinates[3]),a.setAttribute("stroke-width",r.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,jN)}addHighlightArea(){this.container.classList.add("highlightArea")}}jN=new WeakMap;var kN;class tjt extends es{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,kN,null)}render(){this.container.classList.add("squareAnnotation");const{data:r,width:n,height:s}=this,i=this.svgFactory.create(n,s,!0),a=r.borderStyle.width,o=te(this,kN,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",n-a),o.setAttribute("height",s-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,kN)}addHighlightArea(){this.container.classList.add("highlightArea")}}kN=new WeakMap;var NN;class rjt extends es{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,NN,null)}render(){this.container.classList.add("circleAnnotation");const{data:r,width:n,height:s}=this,i=this.svgFactory.create(n,s,!0),a=r.borderStyle.width,o=te(this,NN,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",n/2),o.setAttribute("cy",s/2),o.setAttribute("rx",n/2-a/2),o.setAttribute("ry",s/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,NN)}addHighlightArea(){this.container.classList.add("highlightArea")}}NN=new WeakMap;var EN;class j1e extends es{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,EN,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,vertices:n,borderStyle:s,popupRef:i},width:a,height:o}=this;if(!n)return this.container;const c=this.svgFactory.create(a,o,!0);let u=[];for(let h=0,f=n.length;h<f;h+=2){const p=n[h]-r[0],m=r[3]-n[h+1];u.push(`${p},${m}`)}u=u.join(" ");const d=te(this,EN,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",u),d.setAttribute("stroke-width",s.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),c.append(d),this.container.append(c),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,EN)}addHighlightArea(){this.container.classList.add("highlightArea")}}EN=new WeakMap;class njt extends j1e{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class sjt extends es{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var AN,sy,CN,cz;class a7 extends es{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,CN);le(this,AN,null);le(this,sy,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Lt.HIGHLIGHT:Lt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,rotation:n,inkLists:s,borderStyle:i,popupRef:a}}=this,{transform:o,width:c,height:u}=ce(this,CN,cz).call(this,n,r),d=this.svgFactory.create(c,u,!0),h=te(this,AN,this.svgFactory.createElement("svg:g"));d.append(h),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",o);for(let f=0,p=s.length;f<p;f++){const m=this.svgFactory.createElement(this.svgElementName);_(this,sy).push(m),m.setAttribute("points",s[f].join(",")),h.append(m)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(d),this._editOnDoubleClick(),this.container}updateEdited(r){super.updateEdited(r);const{thickness:n,points:s,rect:i}=r,a=_(this,AN);if(n>=0&&a.setAttribute("stroke-width",n||1),s)for(let o=0,c=_(this,sy).length;o<c;o++)_(this,sy)[o].setAttribute("points",s[o].join(","));if(i){const{transform:o,width:c,height:u}=ce(this,CN,cz).call(this,this.data.rotation,i);a.parentElement.setAttribute("viewBox",`0 0 ${c} ${u}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return _(this,sy)}addHighlightArea(){this.container.classList.add("highlightArea")}}AN=new WeakMap,sy=new WeakMap,CN=new WeakSet,cz=function(r,n){switch(r){case 90:return{transform:`rotate(90) translate(${-n[0]},${n[1]}) scale(1,-1)`,width:n[3]-n[1],height:n[2]-n[0]};case 180:return{transform:`rotate(180) translate(${-n[2]},${n[1]}) scale(1,-1)`,width:n[2]-n[0],height:n[3]-n[1]};case 270:return{transform:`rotate(270) translate(${-n[2]},${n[3]}) scale(1,-1)`,width:n[3]-n[1],height:n[2]-n[0]};default:return{transform:`translate(${-n[0]},${n[3]}) scale(1,-1)`,width:n[2]-n[0],height:n[3]-n[1]}}};class k1e extends es{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Lt.HIGHLIGHT}render(){const{data:{overlaidText:e,popupRef:r}}=this;if(!r&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),e){const n=document.createElement("mark");n.classList.add("overlaidText"),n.textContent=e,this.container.append(n)}return this.container}}class ijt extends es{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:r}}=this;if(!r&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),e){const n=document.createElement("u");n.classList.add("overlaidText"),n.textContent=e,this.container.append(n)}return this.container}}class ajt extends es{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:r}}=this;if(!r&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),e){const n=document.createElement("u");n.classList.add("overlaidText"),n.textContent=e,this.container.append(n)}return this.container}}class ojt extends es{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:r}}=this;if(!r&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),e){const n=document.createElement("s");n.classList.add("overlaidText"),n.textContent=e,this.container.append(n)}return this.container}}class N1e extends es{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Lt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var TN,PN,uz;class ljt extends es{constructor(r){var s;super(r,{isRenderable:!0});le(this,PN);le(this,TN,null);const{file:n}=this.data;this.filename=n.filename,this.content=n.content,(s=this.linkService.eventBus)==null||s.dispatch("fileattachmentannotation",{source:this,...n})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:r,data:n}=this;let s;n.hasAppearance||n.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(n.name)?"paperclip":"pushpin"}.svg`,n.fillAlpha&&n.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(n.fillAlpha*100)}%);`)),s.addEventListener("dblclick",ce(this,PN,uz).bind(this)),te(this,TN,s);const{isMac:i}=wi.platform;return r.addEventListener("keydown",a=>{a.key==="Enter"&&(i?a.metaKey:a.ctrlKey)&&ce(this,PN,uz).call(this)}),!n.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),r.append(s),r}getElementsToTriggerPopup(){return _(this,TN)}addHighlightArea(){this.container.classList.add("highlightArea")}}TN=new WeakMap,PN=new WeakSet,uz=function(){var r;(r=this.downloadManager)==null||r.openOrDownloadData(this.content,this.filename)};var ON,iy,ep,IN,Qp,hz,fz;const jq=class jq{constructor({div:e,accessibilityManager:r,annotationCanvasMap:n,annotationEditorUIManager:s,page:i,viewport:a,structTreeLayer:o}){le(this,Qp);le(this,ON,null);le(this,iy,null);le(this,ep,new Map);le(this,IN,null);this.div=e,te(this,ON,r),te(this,iy,n),te(this,IN,o||null),this.page=i,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return _(this,ep).size>0}async render(e){var a;const{annotations:r}=e,n=this.div;rx(n,this.viewport);const s=new Map,i={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new wO,annotationStorage:e.annotationStorage||new r7,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const o of r){if(o.noHTML)continue;const c=o.annotationType===ss.POPUP;if(c){const h=s.get(o.id);if(!h)continue;i.elements=h}else if(o.rect[2]===o.rect[0]||o.rect[3]===o.rect[1])continue;i.data=o;const u=ire.create(i);if(!u.isRenderable)continue;if(!c&&o.popupRef){const h=s.get(o.popupRef);h?h.push(u):s.set(o.popupRef,[u])}const d=u.render();o.hidden&&(d.style.visibility="hidden"),await ce(this,Qp,hz).call(this,d,o.id,i.elements),u._isEditable&&(_(this,ep).set(u.data.id,u),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(u))}ce(this,Qp,fz).call(this)}async addLinkAnnotations(e,r){const n={data:null,layer:this.div,linkService:r,svgFactory:new wO,parent:this};for(const s of e){s.borderStyle||(s.borderStyle=jq._defaultBorderStyle),n.data=s;const i=ire.create(n);if(!i.isRenderable)continue;const a=i.render();await ce(this,Qp,hz).call(this,a,s.id,null)}}update({viewport:e}){const r=this.div;this.viewport=e,rx(r,{rotation:e.rotation}),ce(this,Qp,fz).call(this),r.hidden=!1}getEditableAnnotations(){return Array.from(_(this,ep).values())}getEditableAnnotation(e){return _(this,ep).get(e)}static get _defaultBorderStyle(){return tr(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:nv.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};ON=new WeakMap,iy=new WeakMap,ep=new WeakMap,IN=new WeakMap,Qp=new WeakSet,hz=async function(e,r,n){var o,c;const s=e.firstChild||e,i=s.id=`${Z9}${r}`,a=await((o=_(this,IN))==null?void 0:o.getAriaAttributes(i));if(a)for(const[u,d]of a)s.setAttribute(u,d);n?n.at(-1).container.after(e):(this.div.append(e),(c=_(this,ON))==null||c.moveElementInDOM(this.div,e,s,!1))},fz=function(){var r;if(!_(this,iy))return;const e=this.div;for(const[n,s]of _(this,iy)){const i=e.querySelector(`[data-annotation-id="${n}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:a}=i;a?a.nodeName==="CANVAS"?a.replaceWith(s):a.classList.contains("annotationContent")?a.after(s):a.before(s):i.append(s);const o=_(this,ep).get(n);o&&(o._hasNoCanvas?((r=this._annotationEditorUIManager)==null||r.setMissingCanvas(n,i.id,s),o._hasNoCanvas=!1):o.canvas=s)}_(this,iy).clear()};let dz=jq;const yC=/\r\n?|\n/g;var Jo,uo,RN,ay,ho,fs,E1e,A1e,C1e,BT,oh,zT,UT,T1e,mz,P1e;const Xr=class Xr extends rn{constructor(r){super({...r,name:"freeTextEditor"});le(this,fs);le(this,Jo);le(this,uo,"");le(this,RN,`${this.id}-editor`);le(this,ay,null);le(this,ho);Ve(this,"_colorPicker",null);te(this,Jo,r.color||Xr._defaultColor||rn._defaultLineColor),te(this,ho,r.fontSize||Xr._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const r=Xr.prototype,n=a=>a.isEmpty(),s=nx.TRANSLATE_SMALL,i=nx.TRANSLATE_BIG;return tr(this,"_keyboardManager",new $E([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],r.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],r.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],r._translateEmpty,{args:[-s,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],r._translateEmpty,{args:[-i,0],checker:n}],[["ArrowRight","mac+ArrowRight"],r._translateEmpty,{args:[s,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],r._translateEmpty,{args:[i,0],checker:n}],[["ArrowUp","mac+ArrowUp"],r._translateEmpty,{args:[0,-s],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],r._translateEmpty,{args:[0,-i],checker:n}],[["ArrowDown","mac+ArrowDown"],r._translateEmpty,{args:[0,s],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],r._translateEmpty,{args:[0,i],checker:n}]]))}static initialize(r,n){rn.initialize(r,n);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(r,n){switch(r){case dr.FREETEXT_SIZE:Xr._defaultFontSize=n;break;case dr.FREETEXT_COLOR:Xr._defaultColor=n;break}}updateParams(r,n){switch(r){case dr.FREETEXT_SIZE:ce(this,fs,E1e).call(this,n);break;case dr.FREETEXT_COLOR:ce(this,fs,A1e).call(this,n);break}}static get defaultPropertiesToUpdate(){return[[dr.FREETEXT_SIZE,Xr._defaultFontSize],[dr.FREETEXT_COLOR,Xr._defaultColor||rn._defaultLineColor]]}get propertiesToUpdate(){return[[dr.FREETEXT_SIZE,_(this,ho)],[dr.FREETEXT_COLOR,_(this,Jo)]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new bO(this)),[["colorPicker",this._colorPicker]]}get colorType(){return dr.FREETEXT_COLOR}get colorValue(){return _(this,Jo)}_translateEmpty(r,n){this._uiManager.translateSelectedEditors(r,n,!0)}getInitialTranslation(){const r=this.parentScale;return[-Xr._internalPadding*r,-(Xr._internalPadding+_(this,ho))*r]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),te(this,ay,new AbortController);const r=this._uiManager.combinedSignal(_(this,ay));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:r}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:r}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:r}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:r}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:r}),!0}disableEditMode(){var r;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",_(this,RN)),this._isDraggable=!0,(r=_(this,ay))==null||r.abort(),te(this,ay,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(r){this._focusEventsAllowed&&(super.focusin(r),r.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(r){var n;this.width||(this.enableEditMode(),r&&this.editorDiv.focus(),(n=this._initialOptions)!=null&&n.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const r=_(this,uo),n=te(this,uo,ce(this,fs,C1e).call(this).trimEnd());if(r===n)return;const s=i=>{if(te(this,uo,i),!i){this.remove();return}ce(this,fs,UT).call(this),this._uiManager.rebuild(this),ce(this,fs,BT).call(this)};this.addCommands({cmd:()=>{s(n)},undo:()=>{s(r)},mustExec:!1}),ce(this,fs,BT).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(r){r.target===this.div&&r.key==="Enter"&&(this.enterInEditMode(),r.preventDefault())}editorDivKeydown(r){Xr._keyboardManager.exec(this,r)}editorDivFocus(r){this.isEditing=!0}editorDivBlur(r){this.isEditing=!1}editorDivInput(r){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let r,n;(this._isCopy||this.annotationElementId)&&(r=this.x,n=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",_(this,RN)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${_(this,ho)}px * var(--total-scale-factor))`,s.color=_(this,Jo),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[c,u]=this.getInitialTranslation();[c,u]=this.pageTranslationToScreen(c,u);const[d,h]=this.pageDimensions,[f,p]=this.pageTranslation;let m,g;switch(this.rotation){case 0:m=r+(o[0]-f)/d,g=n+this.height-(o[1]-p)/h;break;case 90:m=r+(o[0]-f)/d,g=n-(o[1]-p)/h,[c,u]=[u,-c];break;case 180:m=r-this.width+(o[0]-f)/d,g=n-(o[1]-p)/h,[c,u]=[-c,-u];break;case 270:m=r+(o[0]-f-this.height*h)/d,g=n+(o[1]-p-this.width*d)/h,[c,u]=[-u,c];break}this.setAt(m*i,g*a,c,u)}else this._moveAfterPaste(r,n);ce(this,fs,UT).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(r){var m,g,x;const n=r.clipboardData||window.clipboardData,{types:s}=n;if(s.length===1&&s[0]==="text/plain")return;r.preventDefault();const i=ce(m=Xr,oh,mz).call(m,n.getData("text")||"").replaceAll(yC,`
`);if(!i)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!i.includes(`
`)){o.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:c,startOffset:u}=o,d=[],h=[];if(c.nodeType===Node.TEXT_NODE){const y=c.parentElement;if(h.push(c.nodeValue.slice(u).replaceAll(yC,"")),y!==this.editorDiv){let v=d;for(const b of this.editorDiv.childNodes){if(b===y){v=h;continue}v.push(ce(g=Xr,oh,zT).call(g,b))}}d.push(c.nodeValue.slice(0,u).replaceAll(yC,""))}else if(c===this.editorDiv){let y=d,v=0;for(const b of this.editorDiv.childNodes)v++===u&&(y=h),y.push(ce(x=Xr,oh,zT).call(x,b))}te(this,uo,`${d.join(`
`)}${i}${h.join(`
`)}`),ce(this,fs,UT).call(this);const f=new Range;let p=Math.sumPrecise(d.map(y=>y.length));for(const{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){const v=y.nodeValue.length;if(p<=v){f.setStart(y,p),f.setEnd(y,p);break}p-=v}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}static async deserialize(r,n,s){var o;let i=null;if(r instanceof _1e){const{data:{defaultAppearanceData:{fontSize:c,fontColor:u},rect:d,rotation:h,id:f,popupRef:p,contentsObj:m},textContent:g,textPosition:x,parent:{page:{pageNumber:y}}}=r;if(!g||g.length===0)return null;i=r={annotationType:Lt.FREETEXT,color:Array.from(u),fontSize:c,value:g.join(`
`),position:x,pageIndex:y-1,rect:d.slice(0),rotation:h,annotationElementId:f,id:f,deleted:!1,popupRef:p,comment:(m==null?void 0:m.str)||null}}const a=await super.deserialize(r,n,s);return te(a,ho,r.fontSize),te(a,Jo,jt.makeHexColor(...r.color)),te(a,uo,ce(o=Xr,oh,mz).call(o,r.value)),a._initialData=i,r.comment&&a.setCommentData(r.comment),a}serialize(r=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n=Xr._internalPadding*this.parentScale,s=this.getRect(n,n),i=rn._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:_(this,Jo)),a={annotationType:Lt.FREETEXT,color:i,fontSize:_(this,ho),value:ce(this,fs,T1e).call(this),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(a),r?(a.isCopy=!0,a):this.annotationElementId&&!ce(this,fs,P1e).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(r){const n=super.renderAnnotationElement(r),{style:s}=n;s.fontSize=`calc(${_(this,ho)}px * var(--total-scale-factor))`,s.color=_(this,Jo),n.replaceChildren();for(const o of _(this,uo).split(`
`)){const c=document.createElement("div");c.append(o?document.createTextNode(o):document.createElement("br")),n.append(c)}const i=Xr._internalPadding*this.parentScale,a={rect:this.getRect(i,i)};return a.popup=this.hasEditedComment?this.comment:{text:_(this,uo)},r.updateEdited(a),n}resetAnnotationElement(r){super.resetAnnotationElement(r),r.resetEdited()}};Jo=new WeakMap,uo=new WeakMap,RN=new WeakMap,ay=new WeakMap,ho=new WeakMap,fs=new WeakSet,E1e=function(r){const n=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-_(this,ho))*this.parentScale),te(this,ho,i),ce(this,fs,BT).call(this)},s=_(this,ho);this.addCommands({cmd:n.bind(this,r),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dr.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},A1e=function(r){const n=i=>{var a;te(this,Jo,this.editorDiv.style.color=i),(a=this._colorPicker)==null||a.update(i)},s=_(this,Jo);this.addCommands({cmd:n.bind(this,r),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dr.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},C1e=function(){var s;const r=[];this.editorDiv.normalize();let n=null;for(const i of this.editorDiv.childNodes)(n==null?void 0:n.nodeType)===Node.TEXT_NODE&&i.nodeName==="BR"||(r.push(ce(s=Xr,oh,zT).call(s,i)),n=i);return r.join(`
`)},BT=function(){const[r,n]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:i,div:a}=this,o=a.style.display,c=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",i.div.append(this.div),s=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",c)}this.rotation%180===this.parentRotation%180?(this.width=s.width/r,this.height=s.height/n):(this.width=s.height/r,this.height=s.width/n),this.fixAndSetPosition()},oh=new WeakSet,zT=function(r){return(r.nodeType===Node.TEXT_NODE?r.nodeValue:r.innerText).replaceAll(yC,"")},UT=function(){if(this.editorDiv.replaceChildren(),!!_(this,uo))for(const r of _(this,uo).split(`
`)){const n=document.createElement("div");n.append(r?document.createTextNode(r):document.createElement("br")),this.editorDiv.append(n)}},T1e=function(){return _(this,uo).replaceAll(" "," ")},mz=function(r){return r.replaceAll(" "," ")},P1e=function(r){const{value:n,fontSize:s,color:i,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||r.value!==n||r.fontSize!==s||r.color.some((o,c)=>o!==i[c])||r.pageIndex!==a},le(Xr,oh),Ve(Xr,"_freeTextDefaultContent",""),Ve(Xr,"_internalPadding",0),Ve(Xr,"_defaultColor",null),Ve(Xr,"_defaultFontSize",10),Ve(Xr,"_type","freetext"),Ve(Xr,"_editorType",Lt.FREETEXT);let pz=Xr;class pt{toSVGPath(){$r("Abstract method `toSVGPath` must be implemented.")}get box(){$r("Abstract getter `box` must be implemented.")}serialize(e,r){$r("Abstract method `serialize` must be implemented.")}static _rescale(e,r,n,s,i,a){a||(a=new Float32Array(e.length));for(let o=0,c=e.length;o<c;o+=2)a[o]=r+e[o]*s,a[o+1]=n+e[o+1]*i;return a}static _rescaleAndSwap(e,r,n,s,i,a){a||(a=new Float32Array(e.length));for(let o=0,c=e.length;o<c;o+=2)a[o]=r+e[o+1]*s,a[o+1]=n+e[o]*i;return a}static _translate(e,r,n,s){s||(s=new Float32Array(e.length));for(let i=0,a=e.length;i<a;i+=2)s[i]=r+e[i],s[i+1]=n+e[i+1];return s}static svgRound(e){return Math.round(e*1e4)}static _normalizePoint(e,r,n,s,i){switch(i){case 90:return[1-r/n,e/s];case 180:return[1-e/n,1-r/s];case 270:return[r/n,1-e/s];default:return[e/n,r/s]}}static _normalizePagePoint(e,r,n){switch(n){case 90:return[1-r,e];case 180:return[1-e,1-r];case 270:return[r,1-e];default:return[e,r]}}static createBezierPoints(e,r,n,s,i,a){return[(e+5*n)/6,(r+5*s)/6,(5*n+i)/6,(5*s+a)/6,(n+i)/2,(s+a)/2]}}Ve(pt,"PRECISION",1e-4);var fo,Jl,y0,x0,iu,Zt,oy,ly,MN,DN,v0,b0,tp,LN,TI,PI,Ts,CS,O1e,I1e,R1e,M1e,D1e,L1e;const cd=class cd{constructor({x:e,y:r},n,s,i,a,o=0){le(this,Ts);le(this,fo);le(this,Jl,[]);le(this,y0);le(this,x0);le(this,iu,[]);le(this,Zt,new Float32Array(18));le(this,oy);le(this,ly);le(this,MN);le(this,DN);le(this,v0);le(this,b0);le(this,tp,[]);te(this,fo,n),te(this,b0,i*s),te(this,x0,a),_(this,Zt).set([NaN,NaN,NaN,NaN,e,r],6),te(this,y0,o),te(this,DN,_(cd,LN)*s),te(this,MN,_(cd,PI)*s),te(this,v0,s),_(this,tp).push(e,r)}isEmpty(){return isNaN(_(this,Zt)[8])}add({x:e,y:r}){var A;te(this,oy,e),te(this,ly,r);const[n,s,i,a]=_(this,fo);let[o,c,u,d]=_(this,Zt).subarray(8,12);const h=e-u,f=r-d,p=Math.hypot(h,f);if(p<_(this,MN))return!1;const m=p-_(this,DN),g=m/p,x=g*h,y=g*f;let v=o,b=c;o=u,c=d,u+=x,d+=y,(A=_(this,tp))==null||A.push(e,r);const w=-y/m,S=x/m,k=w*_(this,b0),E=S*_(this,b0);return _(this,Zt).set(_(this,Zt).subarray(2,8),0),_(this,Zt).set([u+k,d+E],4),_(this,Zt).set(_(this,Zt).subarray(14,18),12),_(this,Zt).set([u-k,d-E],16),isNaN(_(this,Zt)[6])?(_(this,iu).length===0&&(_(this,Zt).set([o+k,c+E],2),_(this,iu).push(NaN,NaN,NaN,NaN,(o+k-n)/i,(c+E-s)/a),_(this,Zt).set([o-k,c-E],14),_(this,Jl).push(NaN,NaN,NaN,NaN,(o-k-n)/i,(c-E-s)/a)),_(this,Zt).set([v,b,o,c,u,d],6),!this.isEmpty()):(_(this,Zt).set([v,b,o,c,u,d],6),Math.abs(Math.atan2(b-c,v-o)-Math.atan2(y,x))<Math.PI/2?([o,c,u,d]=_(this,Zt).subarray(2,6),_(this,iu).push(NaN,NaN,NaN,NaN,((o+u)/2-n)/i,((c+d)/2-s)/a),[o,c,v,b]=_(this,Zt).subarray(14,18),_(this,Jl).push(NaN,NaN,NaN,NaN,((v+o)/2-n)/i,((b+c)/2-s)/a),!0):([v,b,o,c,u,d]=_(this,Zt).subarray(0,6),_(this,iu).push(((v+5*o)/6-n)/i,((b+5*c)/6-s)/a,((5*o+u)/6-n)/i,((5*c+d)/6-s)/a,((o+u)/2-n)/i,((c+d)/2-s)/a),[u,d,o,c,v,b]=_(this,Zt).subarray(12,18),_(this,Jl).push(((v+5*o)/6-n)/i,((b+5*c)/6-s)/a,((5*o+u)/6-n)/i,((5*c+d)/6-s)/a,((o+u)/2-n)/i,((c+d)/2-s)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const e=_(this,iu),r=_(this,Jl);if(isNaN(_(this,Zt)[6])&&!this.isEmpty())return ce(this,Ts,O1e).call(this);const n=[];n.push(`M${e[4]} ${e[5]}`);for(let s=6;s<e.length;s+=6)isNaN(e[s])?n.push(`L${e[s+4]} ${e[s+5]}`):n.push(`C${e[s]} ${e[s+1]} ${e[s+2]} ${e[s+3]} ${e[s+4]} ${e[s+5]}`);ce(this,Ts,R1e).call(this,n);for(let s=r.length-6;s>=6;s-=6)isNaN(r[s])?n.push(`L${r[s+4]} ${r[s+5]}`):n.push(`C${r[s]} ${r[s+1]} ${r[s+2]} ${r[s+3]} ${r[s+4]} ${r[s+5]}`);return ce(this,Ts,I1e).call(this,n),n.join(" ")}newFreeDrawOutline(e,r,n,s,i,a){return new F1e(e,r,n,s,i,a)}getOutlines(){var h;const e=_(this,iu),r=_(this,Jl),n=_(this,Zt),[s,i,a,o]=_(this,fo),c=new Float32Array((((h=_(this,tp))==null?void 0:h.length)??0)+2);for(let f=0,p=c.length-2;f<p;f+=2)c[f]=(_(this,tp)[f]-s)/a,c[f+1]=(_(this,tp)[f+1]-i)/o;if(c[c.length-2]=(_(this,oy)-s)/a,c[c.length-1]=(_(this,ly)-i)/o,isNaN(n[6])&&!this.isEmpty())return ce(this,Ts,M1e).call(this,c);const u=new Float32Array(_(this,iu).length+24+_(this,Jl).length);let d=e.length;for(let f=0;f<d;f+=2){if(isNaN(e[f])){u[f]=u[f+1]=NaN;continue}u[f]=e[f],u[f+1]=e[f+1]}d=ce(this,Ts,L1e).call(this,u,d);for(let f=r.length-6;f>=6;f-=6)for(let p=0;p<6;p+=2){if(isNaN(r[f+p])){u[d]=u[d+1]=NaN,d+=2;continue}u[d]=r[f+p],u[d+1]=r[f+p+1],d+=2}return ce(this,Ts,D1e).call(this,u,d),this.newFreeDrawOutline(u,c,_(this,fo),_(this,v0),_(this,y0),_(this,x0))}};fo=new WeakMap,Jl=new WeakMap,y0=new WeakMap,x0=new WeakMap,iu=new WeakMap,Zt=new WeakMap,oy=new WeakMap,ly=new WeakMap,MN=new WeakMap,DN=new WeakMap,v0=new WeakMap,b0=new WeakMap,tp=new WeakMap,LN=new WeakMap,TI=new WeakMap,PI=new WeakMap,Ts=new WeakSet,CS=function(){const e=_(this,Zt).subarray(4,6),r=_(this,Zt).subarray(16,18),[n,s,i,a]=_(this,fo);return[(_(this,oy)+(e[0]-r[0])/2-n)/i,(_(this,ly)+(e[1]-r[1])/2-s)/a,(_(this,oy)+(r[0]-e[0])/2-n)/i,(_(this,ly)+(r[1]-e[1])/2-s)/a]},O1e=function(){const[e,r,n,s]=_(this,fo),[i,a,o,c]=ce(this,Ts,CS).call(this);return`M${(_(this,Zt)[2]-e)/n} ${(_(this,Zt)[3]-r)/s} L${(_(this,Zt)[4]-e)/n} ${(_(this,Zt)[5]-r)/s} L${i} ${a} L${o} ${c} L${(_(this,Zt)[16]-e)/n} ${(_(this,Zt)[17]-r)/s} L${(_(this,Zt)[14]-e)/n} ${(_(this,Zt)[15]-r)/s} Z`},I1e=function(e){const r=_(this,Jl);e.push(`L${r[4]} ${r[5]} Z`)},R1e=function(e){const[r,n,s,i]=_(this,fo),a=_(this,Zt).subarray(4,6),o=_(this,Zt).subarray(16,18),[c,u,d,h]=ce(this,Ts,CS).call(this);e.push(`L${(a[0]-r)/s} ${(a[1]-n)/i} L${c} ${u} L${d} ${h} L${(o[0]-r)/s} ${(o[1]-n)/i}`)},M1e=function(e){const r=_(this,Zt),[n,s,i,a]=_(this,fo),[o,c,u,d]=ce(this,Ts,CS).call(this),h=new Float32Array(36);return h.set([NaN,NaN,NaN,NaN,(r[2]-n)/i,(r[3]-s)/a,NaN,NaN,NaN,NaN,(r[4]-n)/i,(r[5]-s)/a,NaN,NaN,NaN,NaN,o,c,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,(r[16]-n)/i,(r[17]-s)/a,NaN,NaN,NaN,NaN,(r[14]-n)/i,(r[15]-s)/a],0),this.newFreeDrawOutline(h,e,_(this,fo),_(this,v0),_(this,y0),_(this,x0))},D1e=function(e,r){const n=_(this,Jl);return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],r),r+=6},L1e=function(e,r){const n=_(this,Zt).subarray(4,6),s=_(this,Zt).subarray(16,18),[i,a,o,c]=_(this,fo),[u,d,h,f]=ce(this,Ts,CS).call(this);return e.set([NaN,NaN,NaN,NaN,(n[0]-i)/o,(n[1]-a)/c,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,h,f,NaN,NaN,NaN,NaN,(s[0]-i)/o,(s[1]-a)/c],r),r+=24},le(cd,LN,8),le(cd,TI,2),le(cd,PI,_(cd,LN)+_(cd,TI));let SO=cd;var w0,cy,Ld,FN,po,$N,Yn,OI,$1e;class F1e extends pt{constructor(r,n,s,i,a,o){super();le(this,OI);le(this,w0);le(this,cy,new Float32Array(4));le(this,Ld);le(this,FN);le(this,po);le(this,$N);le(this,Yn);te(this,Yn,r),te(this,po,n),te(this,w0,s),te(this,$N,i),te(this,Ld,a),te(this,FN,o),this.lastPoint=[NaN,NaN],ce(this,OI,$1e).call(this,o);const[c,u,d,h]=_(this,cy);for(let f=0,p=r.length;f<p;f+=2)r[f]=(r[f]-c)/d,r[f+1]=(r[f+1]-u)/h;for(let f=0,p=n.length;f<p;f+=2)n[f]=(n[f]-c)/d,n[f+1]=(n[f+1]-u)/h}toSVGPath(){const r=[`M${_(this,Yn)[4]} ${_(this,Yn)[5]}`];for(let n=6,s=_(this,Yn).length;n<s;n+=6){if(isNaN(_(this,Yn)[n])){r.push(`L${_(this,Yn)[n+4]} ${_(this,Yn)[n+5]}`);continue}r.push(`C${_(this,Yn)[n]} ${_(this,Yn)[n+1]} ${_(this,Yn)[n+2]} ${_(this,Yn)[n+3]} ${_(this,Yn)[n+4]} ${_(this,Yn)[n+5]}`)}return r.push("Z"),r.join(" ")}serialize([r,n,s,i],a){const o=s-r,c=i-n;let u,d;switch(a){case 0:u=pt._rescale(_(this,Yn),r,i,o,-c),d=pt._rescale(_(this,po),r,i,o,-c);break;case 90:u=pt._rescaleAndSwap(_(this,Yn),r,n,o,c),d=pt._rescaleAndSwap(_(this,po),r,n,o,c);break;case 180:u=pt._rescale(_(this,Yn),s,n,-o,c),d=pt._rescale(_(this,po),s,n,-o,c);break;case 270:u=pt._rescaleAndSwap(_(this,Yn),s,i,-o,-c),d=pt._rescaleAndSwap(_(this,po),s,i,-o,-c);break}return{outline:Array.from(u),points:[Array.from(d)]}}get box(){return _(this,cy)}newOutliner(r,n,s,i,a,o=0){return new SO(r,n,s,i,a,o)}getNewOutline(r,n){const[s,i,a,o]=_(this,cy),[c,u,d,h]=_(this,w0),f=a*d,p=o*h,m=s*d+c,g=i*h+u,x=this.newOutliner({x:_(this,po)[0]*f+m,y:_(this,po)[1]*p+g},_(this,w0),_(this,$N),r,_(this,FN),n??_(this,Ld));for(let y=2;y<_(this,po).length;y+=2)x.add({x:_(this,po)[y]*f+m,y:_(this,po)[y+1]*p+g});return x.getOutlines()}}w0=new WeakMap,cy=new WeakMap,Ld=new WeakMap,FN=new WeakMap,po=new WeakMap,$N=new WeakMap,Yn=new WeakMap,OI=new WeakSet,$1e=function(r){const n=_(this,Yn);let s=n[4],i=n[5];const a=[s,i,s,i];let o=s,c=i;const u=r?Math.max:Math.min;for(let h=6,f=n.length;h<f;h+=6){const p=n[h+4],m=n[h+5];if(isNaN(n[h]))jt.pointBoundingBox(p,m,a),c<m?(o=p,c=m):c===m&&(o=u(o,p));else{const g=[1/0,1/0,-1/0,-1/0];jt.bezierBoundingBox(s,i,...n.slice(h,h+6),g),jt.rectBoundingBox(...g,a),c<g[3]?(o=g[2],c=g[3]):c===g[3]&&(o=u(o,g[2]))}s=p,i=m}const d=_(this,cy);d[0]=a[0]-_(this,Ld),d[1]=a[1]-_(this,Ld),d[2]=a[2]-a[0]+2*_(this,Ld),d[3]=a[3]-a[1]+2*_(this,Ld),this.lastPoint=[o,c]};var BN,zN,rp,Ql,xa,B1e,HT,z1e,U1e,yz;class gz{constructor(e,r=0,n=0,s=!0){le(this,xa);le(this,BN);le(this,zN);le(this,rp,[]);le(this,Ql,[]);const i=[1/0,1/0,-1/0,-1/0],o=10**-4;for(const{x:m,y:g,width:x,height:y}of e){const v=Math.floor((m-r)/o)*o,b=Math.ceil((m+x+r)/o)*o,w=Math.floor((g-r)/o)*o,S=Math.ceil((g+y+r)/o)*o,k=[v,w,S,!0],E=[b,w,S,!1];_(this,rp).push(k,E),jt.rectBoundingBox(v,w,b,S,i)}const c=i[2]-i[0]+2*n,u=i[3]-i[1]+2*n,d=i[0]-n,h=i[1]-n,f=_(this,rp).at(s?-1:-2),p=[f[0],f[2]];for(const m of _(this,rp)){const[g,x,y]=m;m[0]=(g-d)/c,m[1]=(x-h)/u,m[2]=(y-h)/u}te(this,BN,new Float32Array([d,h,c,u])),te(this,zN,p)}getOutlines(){_(this,rp).sort((r,n)=>r[0]-n[0]||r[1]-n[1]||r[2]-n[2]);const e=[];for(const r of _(this,rp))r[3]?(e.push(...ce(this,xa,yz).call(this,r)),ce(this,xa,z1e).call(this,r)):(ce(this,xa,U1e).call(this,r),e.push(...ce(this,xa,yz).call(this,r)));return ce(this,xa,B1e).call(this,e)}}BN=new WeakMap,zN=new WeakMap,rp=new WeakMap,Ql=new WeakMap,xa=new WeakSet,B1e=function(e){const r=[],n=new Set;for(const a of e){const[o,c,u]=a;r.push([o,c,a],[o,u,a])}r.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=r.length;a<o;a+=2){const c=r[a][2],u=r[a+1][2];c.push(u),u.push(c),n.add(c),n.add(u)}const s=[];let i;for(;n.size>0;){const a=n.values().next().value;let[o,c,u,d,h]=a;n.delete(a);let f=o,p=c;for(i=[o,u],s.push(i);;){let m;if(n.has(d))m=d;else if(n.has(h))m=h;else break;n.delete(m),[o,c,u,d,h]=m,f!==o&&(i.push(f,p,o,p===c?c:u),f=o),p=p===c?u:c}i.push(f,p)}return new cjt(s,_(this,BN),_(this,zN))},HT=function(e){const r=_(this,Ql);let n=0,s=r.length-1;for(;n<=s;){const i=n+s>>1,a=r[i][0];if(a===e)return i;a<e?n=i+1:s=i-1}return s+1},z1e=function([,e,r]){const n=ce(this,xa,HT).call(this,e);_(this,Ql).splice(n,0,[e,r])},U1e=function([,e,r]){const n=ce(this,xa,HT).call(this,e);for(let s=n;s<_(this,Ql).length;s++){const[i,a]=_(this,Ql)[s];if(i!==e)break;if(i===e&&a===r){_(this,Ql).splice(s,1);return}}for(let s=n-1;s>=0;s--){const[i,a]=_(this,Ql)[s];if(i!==e)break;if(i===e&&a===r){_(this,Ql).splice(s,1);return}}},yz=function(e){const[r,n,s]=e,i=[[r,n,s]],a=ce(this,xa,HT).call(this,s);for(let o=0;o<a;o++){const[c,u]=_(this,Ql)[o];for(let d=0,h=i.length;d<h;d++){const[,f,p]=i[d];if(!(u<=f||p<=c)){if(f>=c){if(p>u)i[d][1]=u;else{if(h===1)return[];i.splice(d,1),d--,h--}continue}i[d][2]=c,p>u&&i.push([r,u,p])}}}return i};var UN,S0;class cjt extends pt{constructor(r,n,s){super();le(this,UN);le(this,S0);te(this,S0,r),te(this,UN,n),this.lastPoint=s}toSVGPath(){const r=[];for(const n of _(this,S0)){let[s,i]=n;r.push(`M${s} ${i}`);for(let a=2;a<n.length;a+=2){const o=n[a],c=n[a+1];o===s?(r.push(`V${c}`),i=c):c===i&&(r.push(`H${o}`),s=o)}r.push("Z")}return r.join(" ")}serialize([r,n,s,i],a){const o=[],c=s-r,u=i-n;for(const d of _(this,S0)){const h=new Array(d.length);for(let f=0;f<d.length;f+=2)h[f]=r+d[f]*c,h[f+1]=i-d[f+1]*u;o.push(h)}return o}get box(){return _(this,UN)}get classNamesForOutlining(){return["highlightOutline"]}}UN=new WeakMap,S0=new WeakMap;class xz extends SO{newFreeDrawOutline(e,r,n,s,i,a){return new ujt(e,r,n,s,i,a)}}class ujt extends F1e{newOutliner(e,r,n,s,i,a=0){return new xz(e,r,n,s,i,a)}}var _0,HN,Fd,uy,VN,Ia,WN,qN,dy,Qo,mo,ii,j0,$d,Ii,k0,Zo,GN,Ut,vz,VT,H1e,V1e,W1e,bz,Um,ul,cv,q1e,WT,TS,G1e,K1e,Y1e,X1e,J1e;const _r=class _r extends rn{constructor(r){super({...r,name:"highlightEditor"});le(this,Ut);le(this,_0,null);le(this,HN,0);le(this,Fd);le(this,uy,null);le(this,VN,null);le(this,Ia,null);le(this,WN,null);le(this,qN,0);le(this,dy,null);le(this,Qo,null);le(this,mo,null);le(this,ii,!1);le(this,j0,null);le(this,$d);le(this,Ii,null);le(this,k0,"");le(this,Zo);le(this,GN,"");this.color=r.color||_r._defaultColor,te(this,Zo,r.thickness||_r._defaultThickness),te(this,$d,r.opacity||_r._defaultOpacity),te(this,Fd,r.boxes||null),te(this,GN,r.methodOfCreation||""),te(this,k0,r.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",r.highlightId>-1?(te(this,ii,!0),ce(this,Ut,VT).call(this,r),ce(this,Ut,Um).call(this)):_(this,Fd)&&(te(this,_0,r.anchorNode),te(this,HN,r.anchorOffset),te(this,WN,r.focusNode),te(this,qN,r.focusOffset),ce(this,Ut,vz).call(this),ce(this,Ut,Um).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const r=_r.prototype;return tr(this,"_keyboardManager",new $E([[["ArrowLeft","mac+ArrowLeft"],r._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],r._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],r._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],r._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:_(this,ii)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:_(this,Zo),methodOfCreation:_(this,GN)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}get commentColor(){return this.color}static computeTelemetryFinalData(r){return{numberOfColors:r.get("color").size}}static initialize(r,n){var s;rn.initialize(r,n),_r._defaultColor||(_r._defaultColor=((s=n.highlightColors)==null?void 0:s.values().next().value)||"#fff066")}static updateDefaultParams(r,n){switch(r){case dr.HIGHLIGHT_COLOR:_r._defaultColor=n;break;case dr.HIGHLIGHT_THICKNESS:_r._defaultThickness=n;break}}translateInPage(r,n){}get toolbarPosition(){return _(this,j0)}updateParams(r,n){switch(r){case dr.HIGHLIGHT_COLOR:ce(this,Ut,H1e).call(this,n);break;case dr.HIGHLIGHT_THICKNESS:ce(this,Ut,V1e).call(this,n);break}}static get defaultPropertiesToUpdate(){return[[dr.HIGHLIGHT_COLOR,_r._defaultColor],[dr.HIGHLIGHT_THICKNESS,_r._defaultThickness]]}get propertiesToUpdate(){return[[dr.HIGHLIGHT_COLOR,this.color||_r._defaultColor],[dr.HIGHLIGHT_THICKNESS,_(this,Zo)||_r._defaultThickness],[dr.HIGHLIGHT_FREE,_(this,ii)]]}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",te(this,VN,new vO({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(ce(this,Ut,TS).call(this))}getBaseTranslation(){return[0,0]}getRect(r,n){return super.getRect(r,n,ce(this,Ut,TS).call(this))}onceAdded(r){this.annotationElementId||this.parent.addUndoableEditor(this),r&&this.div.focus()}remove(){ce(this,Ut,bz).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(ce(this,Ut,Um).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(r){var s;let n=!1;this.parent&&!r?ce(this,Ut,bz).call(this):r&&(ce(this,Ut,Um).call(this,r),n=!this.parent&&((s=this.div)==null?void 0:s.classList.contains("selectedEditor"))),super.setParent(r),this.show(this._isVisible),n&&this.select()}rotate(r){var i,a,o;const{drawLayer:n}=this.parent;let s;_(this,ii)?(r=(r-this.rotation+360)%360,s=ce(i=_r,ul,cv).call(i,_(this,Qo).box,r)):s=ce(a=_r,ul,cv).call(a,[this.x,this.y,this.width,this.height],r),n.updateProperties(_(this,mo),{bbox:s,root:{"data-main-rotation":r}}),n.updateProperties(_(this,Ii),{bbox:ce(o=_r,ul,cv).call(o,_(this,Ia).box,r),root:{"data-main-rotation":r}})}render(){if(this.div)return this.div;const r=super.render();_(this,k0)&&(r.setAttribute("aria-label",_(this,k0)),r.setAttribute("role","mark")),_(this,ii)?r.classList.add("free"):this.div.addEventListener("keydown",ce(this,Ut,q1e).bind(this),{signal:this._uiManager._signal});const n=te(this,dy,document.createElement("div"));r.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",n.style.clipPath=_(this,uy);const[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),xwe(this,_(this,dy),["pointerover","pointerleave"]),this.enableEditing(),r}pointerover(){var r;this.isSelected||(r=this.parent)==null||r.drawLayer.updateProperties(_(this,Ii),{rootClass:{hovered:!0}})}pointerleave(){var r;this.isSelected||(r=this.parent)==null||r.drawLayer.updateProperties(_(this,Ii),{rootClass:{hovered:!1}})}_moveCaret(r){switch(this.parent.unselect(this),r){case 0:case 2:ce(this,Ut,WT).call(this,!0);break;case 1:case 3:ce(this,Ut,WT).call(this,!1);break}}select(){var r;super.select(),_(this,Ii)&&((r=this.parent)==null||r.drawLayer.updateProperties(_(this,Ii),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var r;super.unselect(),_(this,Ii)&&((r=this.parent)==null||r.drawLayer.updateProperties(_(this,Ii),{rootClass:{selected:!1}}),_(this,ii)||ce(this,Ut,WT).call(this,!1))}get _mustFixPosition(){return!_(this,ii)}show(r=this._isVisible){super.show(r),this.parent&&(this.parent.drawLayer.updateProperties(_(this,mo),{rootClass:{hidden:!r}}),this.parent.drawLayer.updateProperties(_(this,Ii),{rootClass:{hidden:!r}}))}static startHighlighting(r,n,{target:s,x:i,y:a}){const{x:o,y:c,width:u,height:d}=s.getBoundingClientRect(),h=new AbortController,f=r.combinedSignal(h),p=m=>{h.abort(),ce(this,ul,X1e).call(this,r,m)};window.addEventListener("blur",p,{signal:f}),window.addEventListener("pointerup",p,{signal:f}),window.addEventListener("pointerdown",ls,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Al,{signal:f}),s.addEventListener("pointermove",ce(this,ul,Y1e).bind(this,r),{signal:f}),this._freeHighlight=new xz({x:i,y:a},[o,c,u,d],r.scale,this._defaultThickness/2,n,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=r.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(r,n,s){var g,x,y,v;let i=null;if(r instanceof k1e){const{data:{quadPoints:b,rect:w,rotation:S,id:k,color:E,opacity:C,popupRef:A,contentsObj:M},parent:{page:{pageNumber:z}}}=r;i=r={annotationType:Lt.HIGHLIGHT,color:Array.from(E),opacity:C,quadPoints:b,boxes:null,pageIndex:z-1,rect:w.slice(0),rotation:S,annotationElementId:k,id:k,deleted:!1,popupRef:A,comment:(M==null?void 0:M.str)||null}}else if(r instanceof a7){const{data:{inkLists:b,rect:w,rotation:S,id:k,color:E,borderStyle:{rawWidth:C},popupRef:A,contentsObj:M},parent:{page:{pageNumber:z}}}=r;i=r={annotationType:Lt.HIGHLIGHT,color:Array.from(E),thickness:C,inkLists:b,boxes:null,pageIndex:z-1,rect:w.slice(0),rotation:S,annotationElementId:k,id:k,deleted:!1,popupRef:A,comment:(M==null?void 0:M.str)||null}}const{color:a,quadPoints:o,inkLists:c,opacity:u}=r,d=await super.deserialize(r,n,s);d.color=jt.makeHexColor(...a),te(d,$d,u||1),c&&te(d,Zo,r.thickness),d._initialData=i,r.comment&&d.setCommentData(r.comment);const[h,f]=d.pageDimensions,[p,m]=d.pageTranslation;if(o){const b=te(d,Fd,[]);for(let w=0;w<o.length;w+=8)b.push({x:(o[w]-p)/h,y:1-(o[w+1]-m)/f,width:(o[w+2]-o[w])/h,height:(o[w+1]-o[w+5])/f});ce(g=d,Ut,vz).call(g),ce(x=d,Ut,Um).call(x),d.rotate(d.rotation)}else if(c){te(d,ii,!0);const b=c[0],w={x:b[0]-p,y:f-(b[1]-m)},S=new xz(w,[0,0,h,f],1,_(d,Zo)/2,!0,.001);for(let C=0,A=b.length;C<A;C+=2)w.x=b[C]-p,w.y=f-(b[C+1]-m),S.add(w);const{id:k,clipPathId:E}=n.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:S.toSVGPath()}},!0,!0);ce(y=d,Ut,VT).call(y,{highlightOutlines:S.getOutlines(),highlightId:k,clipPathId:E}),ce(v=d,Ut,Um).call(v),d.rotate(d.parentRotation)}return d}serialize(r=!1){if(this.isEmpty()||r)return null;if(this.deleted)return this.serializeDeleted();const n=this.getRect(0,0),s=rn._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i={annotationType:Lt.HIGHLIGHT,color:s,opacity:_(this,$d),thickness:_(this,Zo),quadPoints:ce(this,Ut,G1e).call(this),outlines:ce(this,Ut,K1e).call(this,n),pageIndex:this.pageIndex,rect:n,rotation:ce(this,Ut,TS).call(this),structTreeParentId:this._structTreeParentId};return this.addComment(i),this.annotationElementId&&!ce(this,Ut,J1e).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(r){const n={rect:this.getRect(0,0)};return this.hasEditedComment&&(n.popup=this.comment),r.updateEdited(n),null}static canCreateNewEmptyEditor(){return!1}};_0=new WeakMap,HN=new WeakMap,Fd=new WeakMap,uy=new WeakMap,VN=new WeakMap,Ia=new WeakMap,WN=new WeakMap,qN=new WeakMap,dy=new WeakMap,Qo=new WeakMap,mo=new WeakMap,ii=new WeakMap,j0=new WeakMap,$d=new WeakMap,Ii=new WeakMap,k0=new WeakMap,Zo=new WeakMap,GN=new WeakMap,Ut=new WeakSet,vz=function(){const r=new gz(_(this,Fd),.001);te(this,Qo,r.getOutlines()),[this.x,this.y,this.width,this.height]=_(this,Qo).box;const n=new gz(_(this,Fd),.0025,.001,this._uiManager.direction==="ltr");te(this,Ia,n.getOutlines());const{lastPoint:s}=_(this,Ia);te(this,j0,[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height])},VT=function({highlightOutlines:r,highlightId:n,clipPathId:s}){var h,f;if(te(this,Qo,r),te(this,Ia,r.getNewOutline(_(this,Zo)/2+1.5,.0025)),n>=0)te(this,mo,n),te(this,uy,s),this.parent.drawLayer.finalizeDraw(n,{bbox:r.box,path:{d:r.toSVGPath()}}),te(this,Ii,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:_(this,Ia).box,path:{d:_(this,Ia).toSVGPath()}},!0));else if(this.parent){const p=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(_(this,mo),{bbox:ce(h=_r,ul,cv).call(h,_(this,Qo).box,(p-this.rotation+360)%360),path:{d:r.toSVGPath()}}),this.parent.drawLayer.updateProperties(_(this,Ii),{bbox:ce(f=_r,ul,cv).call(f,_(this,Ia).box,p),path:{d:_(this,Ia).toSVGPath()}})}const[a,o,c,u]=r.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=c,this.height=u;break;case 90:{const[p,m]=this.parentDimensions;this.x=o,this.y=1-a,this.width=c*m/p,this.height=u*p/m;break}case 180:this.x=1-a,this.y=1-o,this.width=c,this.height=u;break;case 270:{const[p,m]=this.parentDimensions;this.x=1-o,this.y=a,this.width=c*m/p,this.height=u*p/m;break}}const{lastPoint:d}=_(this,Ia);te(this,j0,[(d[0]-a)/c,(d[1]-o)/u])},H1e=function(r){const n=(a,o)=>{var c,u;this.color=a,te(this,$d,o),(c=this.parent)==null||c.drawLayer.updateProperties(_(this,mo),{root:{fill:a,"fill-opacity":o}}),(u=_(this,VN))==null||u.updateColor(a)},s=this.color,i=_(this,$d);this.addCommands({cmd:n.bind(this,r,_r._defaultOpacity),undo:n.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dr.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(r)},!0)},V1e=function(r){const n=_(this,Zo),s=i=>{te(this,Zo,i),ce(this,Ut,W1e).call(this,i)};this.addCommands({cmd:s.bind(this,r),undo:s.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:dr.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:r},!0)},W1e=function(r){if(!_(this,ii))return;ce(this,Ut,VT).call(this,{highlightOutlines:_(this,Qo).getNewOutline(r/2)}),this.fixAndSetPosition();const[n,s]=this.parentDimensions;this.setDims(this.width*n,this.height*s)},bz=function(){_(this,mo)===null||!this.parent||(this.parent.drawLayer.remove(_(this,mo)),te(this,mo,null),this.parent.drawLayer.remove(_(this,Ii)),te(this,Ii,null))},Um=function(r=this.parent){_(this,mo)===null&&({id:Ds(this,mo)._,clipPathId:Ds(this,uy)._}=r.drawLayer.draw({bbox:_(this,Qo).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":_(this,$d)},rootClass:{highlight:!0,free:_(this,ii)},path:{d:_(this,Qo).toSVGPath()}},!1,!0),te(this,Ii,r.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:_(this,ii)},bbox:_(this,Ia).box,path:{d:_(this,Ia).toSVGPath()}},_(this,ii))),_(this,dy)&&(_(this,dy).style.clipPath=_(this,uy)))},ul=new WeakSet,cv=function([r,n,s,i],a){switch(a){case 90:return[1-n-i,r,i,s];case 180:return[1-r-s,1-n-i,s,i];case 270:return[n,1-r-s,i,s]}return[r,n,s,i]},q1e=function(r){_r._keyboardManager.exec(this,r)},WT=function(r){if(!_(this,_0))return;const n=window.getSelection();r?n.setPosition(_(this,_0),_(this,HN)):n.setPosition(_(this,WN),_(this,qN))},TS=function(){return _(this,ii)?this.rotation:0},G1e=function(){if(_(this,ii))return null;const[r,n]=this.pageDimensions,[s,i]=this.pageTranslation,a=_(this,Fd),o=new Float32Array(a.length*8);let c=0;for(const{x:u,y:d,width:h,height:f}of a){const p=u*r+s,m=(1-d)*n+i;o[c]=o[c+4]=p,o[c+1]=o[c+3]=m,o[c+2]=o[c+6]=p+h*r,o[c+5]=o[c+7]=m-f*n,c+=8}return o},K1e=function(r){return _(this,Qo).serialize(r,ce(this,Ut,TS).call(this))},Y1e=function(r,n){this._freeHighlight.add(n)&&r.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},X1e=function(r,n){this._freeHighlight.isEmpty()?r.drawLayer.remove(this._freeHighlightId):r.createAndAddNewEditor(n,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},J1e=function(r){const{color:n}=this._initialData;return this.hasEditedComment||r.color.some((s,i)=>s!==n[i])},le(_r,ul),Ve(_r,"_defaultColor",null),Ve(_r,"_defaultOpacity",1),Ve(_r,"_defaultThickness",12),Ve(_r,"_type","highlight"),Ve(_r,"_editorType",Lt.HIGHLIGHT),Ve(_r,"_freeHighlightId",-1),Ve(_r,"_freeHighlight",null),Ve(_r,"_freeHighlightClipId","");let _O=_r;var hy;class Q1e{constructor(){le(this,hy,Object.create(null))}updateProperty(e,r){this[e]=r,this.updateSVGProperty(e,r)}updateProperties(e){if(e)for(const[r,n]of Object.entries(e))r.startsWith("_")||this.updateProperty(r,n)}updateSVGProperty(e,r){_(this,hy)[e]=r}toSVGProperties(){const e=_(this,hy);return te(this,hy,Object.create(null)),{root:e}}reset(){te(this,hy,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){$r("Not implemented")}}hy=new WeakMap;var go,N0,$s,fy,py,np,sp,ip,my,xr,wz,Sz,_z,PS,Z1e,qT,OS,uv;const yt=class yt extends rn{constructor(r){super(r);le(this,xr);le(this,go,null);le(this,N0);Ve(this,"_colorPicker",null);Ve(this,"_drawId",null);te(this,N0,r.mustBeCommitted||!1),this._addOutlines(r)}_addOutlines(r){r.drawOutlines&&(ce(this,xr,wz).call(this,r),ce(this,xr,PS).call(this))}static _mergeSVGProperties(r,n){const s=new Set(Object.keys(r));for(const[i,a]of Object.entries(n))s.has(i)?Object.assign(r[i],a):r[i]=a;return r}static getDefaultDrawingOptions(r){$r("Not implemented")}static get typesMap(){$r("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(r,n){const s=this.typesMap.get(r);s&&this._defaultDrawingOptions.updateProperty(s,n),this._currentParent&&(_(yt,$s).updateProperty(s,n),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(r,n){const s=this.constructor.typesMap.get(r);s&&this._updateProperty(r,s,n)}static get defaultPropertiesToUpdate(){const r=[],n=this._defaultDrawingOptions;for(const[s,i]of this.typesMap)r.push([s,n[i]]);return r}get propertiesToUpdate(){const r=[],{_drawingOptions:n}=this;for(const[s,i]of this.constructor.typesMap)r.push([s,n[i]]);return r}_updateProperty(r,n,s){const i=this._drawingOptions,a=i[n],o=c=>{var d,h;i.updateProperty(n,c);const u=_(this,go).updateProperty(n,c);u&&ce(this,xr,OS).call(this,u),(d=this.parent)==null||d.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),r===this.colorType&&((h=this._colorPicker)==null||h.update(c))};this.addCommands({cmd:o.bind(this,s),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:r,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,yt._mergeSVGProperties(_(this,go).getPathResizingSVGProperties(ce(this,xr,qT).call(this)),{bbox:ce(this,xr,uv).call(this)}))}_onResized(){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,yt._mergeSVGProperties(_(this,go).getPathResizedSVGProperties(ce(this,xr,qT).call(this)),{bbox:ce(this,xr,uv).call(this)}))}_onTranslating(r,n){var s;(s=this.parent)==null||s.drawLayer.updateProperties(this._drawId,{bbox:ce(this,xr,uv).call(this)})}_onTranslated(){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,yt._mergeSVGProperties(_(this,go).getPathTranslatedSVGProperties(ce(this,xr,qT).call(this),this.parentDimensions),{bbox:ce(this,xr,uv).call(this)}))}_onStartDragging(){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(r){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,_(this,N0)&&(te(this,N0,!1),this.commit(),this.parent.setSelected(this),r&&this.isOnScreen&&this.div.focus())}remove(){ce(this,xr,_z).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(ce(this,xr,PS).call(this),ce(this,xr,OS).call(this,_(this,go).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(r){var s;let n=!1;this.parent&&!r?(this._uiManager.removeShouldRescale(this),ce(this,xr,_z).call(this)):r&&(this._uiManager.addShouldRescale(this),ce(this,xr,PS).call(this,r),n=!this.parent&&((s=this.div)==null?void 0:s.classList.contains("selectedEditor"))),super.setParent(r),n&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,yt._mergeSVGProperties({bbox:ce(this,xr,uv).call(this)},_(this,go).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&ce(this,xr,OS).call(this,_(this,go).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let r,n;this._isCopy&&(r=this.x,n=this.y);const s=super.render();s.classList.add("draw");const i=document.createElement("div");s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal";const[a,o]=this.parentDimensions;return this.setDims(this.width*a,this.height*o),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(r,n),s}static createDrawerInstance(r,n,s,i,a){$r("Not implemented")}static startDrawing(r,n,s,i){var x;const{target:a,offsetX:o,offsetY:c,pointerId:u,pointerType:d}=i;if(_(yt,sp)&&_(yt,sp)!==d)return;const{viewport:{rotation:h}}=r,{width:f,height:p}=a.getBoundingClientRect(),m=te(yt,fy,new AbortController),g=r.combinedSignal(m);if(_(yt,np)||te(yt,np,u),_(yt,sp)??te(yt,sp,d),window.addEventListener("pointerup",y=>{var v;_(yt,np)===y.pointerId?this._endDraw(y):(v=_(yt,ip))==null||v.delete(y.pointerId)},{signal:g}),window.addEventListener("pointercancel",y=>{var v;_(yt,np)===y.pointerId?this._currentParent.endDrawingSession():(v=_(yt,ip))==null||v.delete(y.pointerId)},{signal:g}),window.addEventListener("pointerdown",y=>{_(yt,sp)===y.pointerType&&((_(yt,ip)||te(yt,ip,new Set)).add(y.pointerId),_(yt,$s).isCancellable()&&(_(yt,$s).removeLastElement(),_(yt,$s).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",Al,{signal:g}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),a.addEventListener("touchmove",y=>{y.timeStamp===_(yt,my)&&ls(y)},{signal:g}),r.toggleDrawing(),(x=n._editorUndoBar)==null||x.hide(),_(yt,$s)){r.drawLayer.updateProperties(this._currentDrawId,_(yt,$s).startNew(o,c,f,p,h));return}n.updateUIForDefaultProperties(this),te(yt,$s,this.createDrawerInstance(o,c,f,p,h)),te(yt,py,this.getDefaultDrawingOptions()),this._currentParent=r,{id:this._currentDrawId}=r.drawLayer.draw(this._mergeSVGProperties(_(yt,py).toSVGProperties(),_(yt,$s).defaultSVGProperties),!0,!1)}static _drawMove(r){var a;if(te(yt,my,-1),!_(yt,$s))return;const{offsetX:n,offsetY:s,pointerId:i}=r;if(_(yt,np)===i){if(((a=_(yt,ip))==null?void 0:a.size)>=1){this._endDraw(r);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,_(yt,$s).add(n,s)),te(yt,my,r.timeStamp),ls(r)}}static _cleanup(r){r&&(this._currentDrawId=-1,this._currentParent=null,te(yt,$s,null),te(yt,py,null),te(yt,sp,null),te(yt,my,NaN)),_(yt,fy)&&(_(yt,fy).abort(),te(yt,fy,null),te(yt,np,NaN),te(yt,ip,null))}static _endDraw(r){const n=this._currentParent;if(n){if(n.toggleDrawing(!0),this._cleanup(!1),(r==null?void 0:r.target)===n.div&&n.drawLayer.updateProperties(this._currentDrawId,_(yt,$s).end(r.offsetX,r.offsetY)),this.supportMultipleDrawings){const s=_(yt,$s),i=this._currentDrawId,a=s.getLastElement();n.addCommands({cmd:()=>{n.drawLayer.updateProperties(i,s.setLastElement(a))},undo:()=>{n.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:dr.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(r){const n=this._currentParent;if(!n)return null;if(n.toggleDrawing(!0),n.cleanUndoStack(dr.DRAW_STEP),!_(yt,$s).isEmpty()){const{pageDimensions:[s,i],scale:a}=n,o=n.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:_(yt,$s).getOutlines(s*a,i*a,a,this._INNER_MARGIN),drawingOptions:_(yt,py),mustBeCommitted:!r});return this._cleanup(!0),o}return n.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(r){}static deserializeDraw(r,n,s,i,a,o){$r("Not implemented")}static async deserialize(r,n,s){var h,f;const{rawDims:{pageWidth:i,pageHeight:a,pageX:o,pageY:c}}=n.viewport,u=this.deserializeDraw(o,c,i,a,this._INNER_MARGIN,r),d=await super.deserialize(r,n,s);return d.createDrawingOptions(r),ce(h=d,xr,wz).call(h,{drawOutlines:u}),ce(f=d,xr,PS).call(f),d.onScaleChanging(),d.rotate(),d}serializeDraw(r){const[n,s]=this.pageTranslation,[i,a]=this.pageDimensions;return _(this,go).serialize([n,s,i,a],r)}renderAnnotationElement(r){return r.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};go=new WeakMap,N0=new WeakMap,$s=new WeakMap,fy=new WeakMap,py=new WeakMap,np=new WeakMap,sp=new WeakMap,ip=new WeakMap,my=new WeakMap,xr=new WeakSet,wz=function({drawOutlines:r,drawId:n,drawingOptions:s}){te(this,go,r),this._drawingOptions||(this._drawingOptions=s),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),n>=0?(this._drawId=n,this.parent.drawLayer.finalizeDraw(n,r.defaultProperties)):this._drawId=ce(this,xr,Sz).call(this,r,this.parent),ce(this,xr,OS).call(this,r.box)},Sz=function(r,n){const{id:s}=n.drawLayer.draw(yt._mergeSVGProperties(this._drawingOptions.toSVGProperties(),r.defaultSVGProperties),!1,!1);return s},_z=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},PS=function(r=this.parent){if(!(this._drawId!==null&&this.parent===r)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,r.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=ce(this,xr,Sz).call(this,_(this,go),r)}},Z1e=function([r,n,s,i]){const{parentDimensions:[a,o],rotation:c}=this;switch(c){case 90:return[n,1-r,s*(o/a),i*(a/o)];case 180:return[1-r,1-n,s,i];case 270:return[1-n,r,s*(o/a),i*(a/o)];default:return[r,n,s,i]}},qT=function(){const{x:r,y:n,width:s,height:i,parentDimensions:[a,o],rotation:c}=this;switch(c){case 90:return[1-n,r,s*(a/o),i*(o/a)];case 180:return[1-r,1-n,s,i];case 270:return[n,1-r,s*(a/o),i*(o/a)];default:return[r,n,s,i]}},OS=function(r){if([this.x,this.y,this.width,this.height]=ce(this,xr,Z1e).call(this,r),this.div){this.fixAndSetPosition();const[n,s]=this.parentDimensions;this.setDims(this.width*n,this.height*s)}this._onResized()},uv=function(){const{x:r,y:n,width:s,height:i,rotation:a,parentRotation:o,parentDimensions:[c,u]}=this;switch((a*4+o)/90){case 1:return[1-n-i,r,i,s];case 2:return[1-r-s,1-n-i,s,i];case 3:return[n,1-r-s,i,s];case 4:return[r,n-s*(c/u),i*(u/c),s*(c/u)];case 5:return[1-n,r,s*(c/u),i*(u/c)];case 6:return[1-r-i*(u/c),1-n,i*(u/c),s*(c/u)];case 7:return[n-s*(c/u),1-r-i*(u/c),s*(c/u),i*(u/c)];case 8:return[r-s,n-i,s,i];case 9:return[1-n,r-s,i,s];case 10:return[1-r,1-n,s,i];case 11:return[n-i,1-r,i,s];case 12:return[r-i*(u/c),n,i*(u/c),s*(c/u)];case 13:return[1-n-s*(c/u),r-i*(u/c),s*(c/u),i*(u/c)];case 14:return[1-r,1-n-s*(c/u),i*(u/c),s*(c/u)];case 15:return[n,1-r,s*(c/u),i*(u/c)];default:return[r,n,s,i]}},Ve(yt,"_currentDrawId",-1),Ve(yt,"_currentParent",null),le(yt,$s,null),le(yt,fy,null),le(yt,py,null),le(yt,np,NaN),le(yt,sp,null),le(yt,ip,null),le(yt,my,NaN),Ve(yt,"_INNER_MARGIN",3);let jO=yt;var au,Bs,zs,gy,E0,sa,ai,el,yy,xy,vy,A0,GT;class djt{constructor(e,r,n,s,i,a){le(this,A0);le(this,au,new Float64Array(6));le(this,Bs);le(this,zs);le(this,gy);le(this,E0);le(this,sa);le(this,ai,"");le(this,el,0);le(this,yy,new zE);le(this,xy);le(this,vy);te(this,xy,n),te(this,vy,s),te(this,gy,i),te(this,E0,a),[e,r]=ce(this,A0,GT).call(this,e,r);const o=te(this,Bs,[NaN,NaN,NaN,NaN,e,r]);te(this,sa,[e,r]),te(this,zs,[{line:o,points:_(this,sa)}]),_(this,au).set(o,0)}updateProperty(e,r){e==="stroke-width"&&te(this,E0,r)}isEmpty(){return!_(this,zs)||_(this,zs).length===0}isCancellable(){return _(this,sa).length<=10}add(e,r){[e,r]=ce(this,A0,GT).call(this,e,r);const[n,s,i,a]=_(this,au).subarray(2,6),o=e-i,c=r-a;return Math.hypot(_(this,xy)*o,_(this,vy)*c)<=2?null:(_(this,sa).push(e,r),isNaN(n)?(_(this,au).set([i,a,e,r],2),_(this,Bs).push(NaN,NaN,NaN,NaN,e,r),{path:{d:this.toSVGPath()}}):(isNaN(_(this,au)[0])&&_(this,Bs).splice(6,6),_(this,au).set([n,s,i,a,e,r],0),_(this,Bs).push(...pt.createBezierPoints(n,s,i,a,e,r)),{path:{d:this.toSVGPath()}}))}end(e,r){const n=this.add(e,r);return n||(_(this,sa).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,r,n,s,i){te(this,xy,n),te(this,vy,s),te(this,gy,i),[e,r]=ce(this,A0,GT).call(this,e,r);const a=te(this,Bs,[NaN,NaN,NaN,NaN,e,r]);te(this,sa,[e,r]);const o=_(this,zs).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),_(this,zs).push({line:a,points:_(this,sa)}),_(this,au).set(a,0),te(this,el,0),this.toSVGPath(),null}getLastElement(){return _(this,zs).at(-1)}setLastElement(e){return _(this,zs)?(_(this,zs).push(e),te(this,Bs,e.line),te(this,sa,e.points),te(this,el,0),{path:{d:this.toSVGPath()}}):_(this,yy).setLastElement(e)}removeLastElement(){if(!_(this,zs))return _(this,yy).removeLastElement();_(this,zs).pop(),te(this,ai,"");for(let e=0,r=_(this,zs).length;e<r;e++){const{line:n,points:s}=_(this,zs)[e];te(this,Bs,n),te(this,sa,s),te(this,el,0),this.toSVGPath()}return{path:{d:_(this,ai)}}}toSVGPath(){const e=pt.svgRound(_(this,Bs)[4]),r=pt.svgRound(_(this,Bs)[5]);if(_(this,sa).length===2)return te(this,ai,`${_(this,ai)} M ${e} ${r} Z`),_(this,ai);if(_(this,sa).length<=6){const s=_(this,ai).lastIndexOf("M");te(this,ai,`${_(this,ai).slice(0,s)} M ${e} ${r}`),te(this,el,6)}if(_(this,sa).length===4){const s=pt.svgRound(_(this,Bs)[10]),i=pt.svgRound(_(this,Bs)[11]);return te(this,ai,`${_(this,ai)} L ${s} ${i}`),te(this,el,12),_(this,ai)}const n=[];_(this,el)===0&&(n.push(`M ${e} ${r}`),te(this,el,6));for(let s=_(this,el),i=_(this,Bs).length;s<i;s+=6){const[a,o,c,u,d,h]=_(this,Bs).slice(s,s+6).map(pt.svgRound);n.push(`C${a} ${o} ${c} ${u} ${d} ${h}`)}return te(this,ai,_(this,ai)+n.join(" ")),te(this,el,_(this,Bs).length),_(this,ai)}getOutlines(e,r,n,s){const i=_(this,zs).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),_(this,yy).build(_(this,zs),e,r,n,_(this,gy),_(this,E0),s),te(this,au,null),te(this,Bs,null),te(this,zs,null),te(this,ai,null),_(this,yy)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}au=new WeakMap,Bs=new WeakMap,zs=new WeakMap,gy=new WeakMap,E0=new WeakMap,sa=new WeakMap,ai=new WeakMap,el=new WeakMap,yy=new WeakMap,xy=new WeakMap,vy=new WeakMap,A0=new WeakSet,GT=function(e,r){return pt._normalizePoint(e,r,_(this,xy),_(this,vy),_(this,gy))};var ia,KN,YN,yo,ou,lu,C0,T0,by,hi,ed,eSe,tSe,rSe;class zE extends pt{constructor(){super(...arguments);le(this,hi);le(this,ia);le(this,KN,0);le(this,YN);le(this,yo);le(this,ou);le(this,lu);le(this,C0);le(this,T0);le(this,by)}build(r,n,s,i,a,o,c){te(this,ou,n),te(this,lu,s),te(this,C0,i),te(this,T0,a),te(this,by,o),te(this,YN,c??0),te(this,yo,r),ce(this,hi,tSe).call(this)}get thickness(){return _(this,by)}setLastElement(r){return _(this,yo).push(r),{path:{d:this.toSVGPath()}}}removeLastElement(){return _(this,yo).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const r=[];for(const{line:n}of _(this,yo)){if(r.push(`M${pt.svgRound(n[4])} ${pt.svgRound(n[5])}`),n.length===6){r.push("Z");continue}if(n.length===12&&isNaN(n[6])){r.push(`L${pt.svgRound(n[10])} ${pt.svgRound(n[11])}`);continue}for(let s=6,i=n.length;s<i;s+=6){const[a,o,c,u,d,h]=n.subarray(s,s+6).map(pt.svgRound);r.push(`C${a} ${o} ${c} ${u} ${d} ${h}`)}}return r.join("")}serialize([r,n,s,i],a){const o=[],c=[],[u,d,h,f]=ce(this,hi,eSe).call(this);let p,m,g,x,y,v,b,w,S;switch(_(this,T0)){case 0:S=pt._rescale,p=r,m=n+i,g=s,x=-i,y=r+u*s,v=n+(1-d-f)*i,b=r+(u+h)*s,w=n+(1-d)*i;break;case 90:S=pt._rescaleAndSwap,p=r,m=n,g=s,x=i,y=r+d*s,v=n+u*i,b=r+(d+f)*s,w=n+(u+h)*i;break;case 180:S=pt._rescale,p=r+s,m=n,g=-s,x=i,y=r+(1-u-h)*s,v=n+d*i,b=r+(1-u)*s,w=n+(d+f)*i;break;case 270:S=pt._rescaleAndSwap,p=r+s,m=n+i,g=-s,x=-i,y=r+(1-d-f)*s,v=n+(1-u-h)*i,b=r+(1-d)*s,w=n+(1-u)*i;break}for(const{line:k,points:E}of _(this,yo))o.push(S(k,p,m,g,x,a?new Array(k.length):null)),c.push(S(E,p,m,g,x,a?new Array(E.length):null));return{lines:o,points:c,rect:[y,v,b,w]}}static deserialize(r,n,s,i,a,{paths:{lines:o,points:c},rotation:u,thickness:d}){const h=[];let f,p,m,g,x;switch(u){case 0:x=pt._rescale,f=-r/s,p=n/i+1,m=1/s,g=-1/i;break;case 90:x=pt._rescaleAndSwap,f=-n/i,p=-r/s,m=1/i,g=1/s;break;case 180:x=pt._rescale,f=r/s+1,p=-n/i,m=-1/s,g=1/i;break;case 270:x=pt._rescaleAndSwap,f=n/i+1,p=r/s+1,m=-1/i,g=-1/s;break}if(!o){o=[];for(const v of c){const b=v.length;if(b===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]));continue}if(b===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));continue}const w=new Float32Array(3*(b-2));o.push(w);let[S,k,E,C]=v.subarray(0,4);w.set([NaN,NaN,NaN,NaN,S,k],0);for(let A=4;A<b;A+=2){const M=v[A],z=v[A+1];w.set(pt.createBezierPoints(S,k,E,C,M,z),(A-2)*3),[S,k,E,C]=[E,C,M,z]}}}for(let v=0,b=o.length;v<b;v++)h.push({line:x(o[v].map(w=>w??NaN),f,p,m,g),points:x(c[v].map(w=>w??NaN),f,p,m,g)});const y=new this.prototype.constructor;return y.build(h,s,i,1,u,d,a),y}get box(){return _(this,ia)}updateProperty(r,n){return r==="stroke-width"?ce(this,hi,rSe).call(this,n):null}updateParentDimensions([r,n],s){const[i,a]=ce(this,hi,ed).call(this);te(this,ou,r),te(this,lu,n),te(this,C0,s);const[o,c]=ce(this,hi,ed).call(this),u=o-i,d=c-a,h=_(this,ia);return h[0]-=u,h[1]-=d,h[2]+=2*u,h[3]+=2*d,h}updateRotation(r){return te(this,KN,r),{path:{transform:this.rotationTransform}}}get viewBox(){return _(this,ia).map(pt.svgRound).join(" ")}get defaultProperties(){const[r,n]=_(this,ia);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${pt.svgRound(r)} ${pt.svgRound(n)}`}}}get rotationTransform(){const[,,r,n]=_(this,ia);let s=0,i=0,a=0,o=0,c=0,u=0;switch(_(this,KN)){case 90:i=n/r,a=-r/n,c=r;break;case 180:s=-1,o=-1,c=r,u=n;break;case 270:i=-n/r,a=r/n,u=n;break;default:return""}return`matrix(${s} ${i} ${a} ${o} ${pt.svgRound(c)} ${pt.svgRound(u)})`}getPathResizingSVGProperties([r,n,s,i]){const[a,o]=ce(this,hi,ed).call(this),[c,u,d,h]=_(this,ia);if(Math.abs(d-a)<=pt.PRECISION||Math.abs(h-o)<=pt.PRECISION){const x=r+s/2-(c+d/2),y=n+i/2-(u+h/2);return{path:{"transform-origin":`${pt.svgRound(r)} ${pt.svgRound(n)}`,transform:`${this.rotationTransform} translate(${x} ${y})`}}}const f=(s-2*a)/(d-2*a),p=(i-2*o)/(h-2*o),m=d/s,g=h/i;return{path:{"transform-origin":`${pt.svgRound(c)} ${pt.svgRound(u)}`,transform:`${this.rotationTransform} scale(${m} ${g}) translate(${pt.svgRound(a)} ${pt.svgRound(o)}) scale(${f} ${p}) translate(${pt.svgRound(-a)} ${pt.svgRound(-o)})`}}}getPathResizedSVGProperties([r,n,s,i]){const[a,o]=ce(this,hi,ed).call(this),c=_(this,ia),[u,d,h,f]=c;if(c[0]=r,c[1]=n,c[2]=s,c[3]=i,Math.abs(h-a)<=pt.PRECISION||Math.abs(f-o)<=pt.PRECISION){const y=r+s/2-(u+h/2),v=n+i/2-(d+f/2);for(const{line:b,points:w}of _(this,yo))pt._translate(b,y,v,b),pt._translate(w,y,v,w);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${pt.svgRound(r)} ${pt.svgRound(n)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const p=(s-2*a)/(h-2*a),m=(i-2*o)/(f-2*o),g=-p*(u+a)+r+a,x=-m*(d+o)+n+o;if(p!==1||m!==1||g!==0||x!==0)for(const{line:y,points:v}of _(this,yo))pt._rescale(y,g,x,p,m,y),pt._rescale(v,g,x,p,m,v);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${pt.svgRound(r)} ${pt.svgRound(n)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([r,n],s){const[i,a]=s,o=_(this,ia),c=r-o[0],u=n-o[1];if(_(this,ou)===i&&_(this,lu)===a)for(const{line:d,points:h}of _(this,yo))pt._translate(d,c,u,d),pt._translate(h,c,u,h);else{const d=_(this,ou)/i,h=_(this,lu)/a;te(this,ou,i),te(this,lu,a);for(const{line:f,points:p}of _(this,yo))pt._rescale(f,c,u,d,h,f),pt._rescale(p,c,u,d,h,p);o[2]*=d,o[3]*=h}return o[0]=r,o[1]=n,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${pt.svgRound(r)} ${pt.svgRound(n)}`}}}get defaultSVGProperties(){const r=_(this,ia);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${pt.svgRound(r[0])} ${pt.svgRound(r[1])}`,transform:this.rotationTransform||null},bbox:r}}}ia=new WeakMap,KN=new WeakMap,YN=new WeakMap,yo=new WeakMap,ou=new WeakMap,lu=new WeakMap,C0=new WeakMap,T0=new WeakMap,by=new WeakMap,hi=new WeakSet,ed=function(r=_(this,by)){const n=_(this,YN)+r/2*_(this,C0);return _(this,T0)%180===0?[n/_(this,ou),n/_(this,lu)]:[n/_(this,lu),n/_(this,ou)]},eSe=function(){const[r,n,s,i]=_(this,ia),[a,o]=ce(this,hi,ed).call(this,0);return[r+a,n+o,s-2*a,i-2*o]},tSe=function(){const r=te(this,ia,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:i}of _(this,yo)){if(i.length<=12){for(let c=4,u=i.length;c<u;c+=6)jt.pointBoundingBox(i[c],i[c+1],r);continue}let a=i[4],o=i[5];for(let c=6,u=i.length;c<u;c+=6){const[d,h,f,p,m,g]=i.subarray(c,c+6);jt.bezierBoundingBox(a,o,d,h,f,p,m,g,r),a=m,o=g}}const[n,s]=ce(this,hi,ed).call(this);r[0]=la(r[0]-n,0,1),r[1]=la(r[1]-s,0,1),r[2]=la(r[2]+n,0,1),r[3]=la(r[3]+s,0,1),r[2]-=r[0],r[3]-=r[1]},rSe=function(r){const[n,s]=ce(this,hi,ed).call(this);te(this,by,r);const[i,a]=ce(this,hi,ed).call(this),[o,c]=[i-n,a-s],u=_(this,ia);return u[0]-=o,u[1]-=c,u[2]+=2*o,u[3]+=2*c,u};class tD extends Q1e{constructor(e){super(),this._viewParameters=e,super.updateProperties({fill:"none",stroke:rn._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,r){e==="stroke-width"&&(r??(r=this["stroke-width"]),r*=this._viewParameters.realScale),super.updateSVGProperty(e,r)}clone(){const e=new tD(this._viewParameters);return e.updateAll(this),e}}var II,nSe;const Wv=class Wv extends jO{constructor(r){super({...r,name:"inkEditor"});le(this,II);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(r,n){rn.initialize(r,n),this._defaultDrawingOptions=new tD(n.viewParameters)}static getDefaultDrawingOptions(r){const n=this._defaultDrawingOptions.clone();return n.updateProperties(r),n}static get supportMultipleDrawings(){return!0}static get typesMap(){return tr(this,"typesMap",new Map([[dr.INK_THICKNESS,"stroke-width"],[dr.INK_COLOR,"stroke"],[dr.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(r,n,s,i,a){return new djt(r,n,s,i,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(r,n,s,i,a,o){return zE.deserialize(r,n,s,i,a,o)}static async deserialize(r,n,s){let i=null;if(r instanceof a7){const{data:{inkLists:o,rect:c,rotation:u,id:d,color:h,opacity:f,borderStyle:{rawWidth:p},popupRef:m,contentsObj:g},parent:{page:{pageNumber:x}}}=r;i=r={annotationType:Lt.INK,color:Array.from(h),thickness:p,opacity:f,paths:{points:o},boxes:null,pageIndex:x-1,rect:c.slice(0),rotation:u,annotationElementId:d,id:d,deleted:!1,popupRef:m,comment:(g==null?void 0:g.str)||null}}const a=await super.deserialize(r,n,s);return a._initialData=i,r.comment&&a.setCommentData(r.comment),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new bO(this)),[["colorPicker",this._colorPicker]]}get colorType(){return dr.INK_COLOR}get colorValue(){return this._drawingOptions.stroke}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:r,_drawingOptions:n,parent:s}=this;n.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(r,n.toSVGProperties())}static onScaleChangingWhenDrawing(){const r=this._currentParent;r&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),r.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:r,thickness:n,opacity:s}){this._drawingOptions=Wv.getDefaultDrawingOptions({stroke:jt.makeHexColor(...r),"stroke-width":n,"stroke-opacity":s})}serialize(r=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:n,points:s,rect:i}=this.serializeDraw(r),{_drawingOptions:{stroke:a,"stroke-opacity":o,"stroke-width":c}}=this,u={annotationType:Lt.INK,color:rn._colorManager.convert(a),opacity:o,thickness:c,paths:{lines:n,points:s},pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(u),r?(u.isCopy=!0,u):this.annotationElementId&&!ce(this,II,nSe).call(this,u)?null:(u.id=this.annotationElementId,u)}renderAnnotationElement(r){const{points:n,rect:s}=this.serializeDraw(!1),i={rect:s,thickness:this._drawingOptions["stroke-width"],points:n};return this.hasEditedComment&&(i.popup=this.comment),r.updateEdited(i),null}};II=new WeakSet,nSe=function(r){const{color:n,thickness:s,opacity:i,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||r.color.some((o,c)=>o!==n[c])||r.thickness!==s||r.opacity!==i||r.pageIndex!==a},Ve(Wv,"_type","ink"),Ve(Wv,"_editorType",Lt.INK),Ve(Wv,"_defaultDrawingOptions",null);let jz=Wv;class kz extends zE{toSVGPath(){let e=super.toSVGPath();return e.endsWith("Z")||(e+="Z"),e}}const xC=8,K1=3;var wy,Ar,Nz,Zl,sSe,iSe,Ez,KT,aSe,oSe,lSe,Az,Cz,cSe;class Wd{static extractContoursFromText(e,{fontFamily:r,fontStyle:n,fontWeight:s},i,a,o,c){let u=new OffscreenCanvas(1,1),d=u.getContext("2d",{alpha:!1});const h=200,f=d.font=`${n} ${s} ${h}px ${r}`,{actualBoundingBoxLeft:p,actualBoundingBoxRight:m,actualBoundingBoxAscent:g,actualBoundingBoxDescent:x,fontBoundingBoxAscent:y,fontBoundingBoxDescent:v,width:b}=d.measureText(e),w=1.5,S=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||0,b)*w),k=Math.ceil(Math.max(Math.abs(g)+Math.abs(x)||h,Math.abs(y)+Math.abs(v)||h)*w);u=new OffscreenCanvas(S,k),d=u.getContext("2d",{alpha:!0,willReadFrequently:!0}),d.font=f,d.filter="grayscale(1)",d.fillStyle="white",d.fillRect(0,0,S,k),d.fillStyle="black",d.fillText(e,S*(w-1)/2,k*(3-w)/2);const E=ce(this,Ar,Az).call(this,d.getImageData(0,0,S,k).data),C=ce(this,Ar,lSe).call(this,E),A=ce(this,Ar,Cz).call(this,C),M=ce(this,Ar,Ez).call(this,E,S,k,A);return this.processDrawnLines({lines:{curves:M,width:S,height:k},pageWidth:i,pageHeight:a,rotation:o,innerMargin:c,mustSmooth:!0,areContours:!0})}static process(e,r,n,s,i){const[a,o,c]=ce(this,Ar,cSe).call(this,e),[u,d]=ce(this,Ar,oSe).call(this,a,o,c,Math.hypot(o,c)*_(this,wy).sigmaSFactor,_(this,wy).sigmaR,_(this,wy).kernelSize),h=ce(this,Ar,Cz).call(this,d),f=ce(this,Ar,Ez).call(this,u,o,c,h);return this.processDrawnLines({lines:{curves:f,width:o,height:c},pageWidth:r,pageHeight:n,rotation:s,innerMargin:i,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:r,pageHeight:n,rotation:s,innerMargin:i,mustSmooth:a,areContours:o}){s%180!==0&&([r,n]=[n,r]);const{curves:c,width:u,height:d}=e,h=e.thickness??0,f=[],p=Math.min(r/u,n/d),m=p/r,g=p/n,x=[];for(const{points:v}of c){const b=a?ce(this,Ar,aSe).call(this,v):v;if(!b)continue;x.push(b);const w=b.length,S=new Float32Array(w),k=new Float32Array(3*(w===2?2:w-2));if(f.push({line:k,points:S}),w===2){S[0]=b[0]*m,S[1]=b[1]*g,k.set([NaN,NaN,NaN,NaN,S[0],S[1]],0);continue}let[E,C,A,M]=b;E*=m,C*=g,A*=m,M*=g,S.set([E,C,A,M],0),k.set([NaN,NaN,NaN,NaN,E,C],0);for(let z=4;z<w;z+=2){const P=S[z]=b[z]*m,W=S[z+1]=b[z+1]*g;k.set(pt.createBezierPoints(E,C,A,M,P,W),(z-2)*3),[E,C,A,M]=[A,M,P,W]}}if(f.length===0)return null;const y=o?new kz:new zE;return y.build(f,r,n,1,s,o?0:h,i),{outline:y,newCurves:x,areContours:o,thickness:h,width:u,height:d}}static async compressSignature({outlines:e,areContours:r,thickness:n,width:s,height:i}){let a=1/0,o=-1/0,c=0;for(const b of e){c+=b.length;for(let w=2,S=b.length;w<S;w++){const k=b[w]-b[w-2];a=Math.min(a,k),o=Math.max(o,k)}}let u;a>=-128&&o<=127?u=Int8Array:a>=-32768&&o<=32767?u=Int16Array:u=Int32Array;const d=e.length,h=xC+K1*d,f=new Uint32Array(h);let p=0;f[p++]=h*Uint32Array.BYTES_PER_ELEMENT+(c-2*d)*u.BYTES_PER_ELEMENT,f[p++]=0,f[p++]=s,f[p++]=i,f[p++]=r?0:1,f[p++]=Math.max(0,Math.floor(n??0)),f[p++]=d,f[p++]=u.BYTES_PER_ELEMENT;for(const b of e)f[p++]=b.length-2,f[p++]=b[0],f[p++]=b[1];const m=new CompressionStream("deflate-raw"),g=m.writable.getWriter();await g.ready,g.write(f);const x=u.prototype.constructor;for(const b of e){const w=new x(b.length-2);for(let S=2,k=b.length;S<k;S++)w[S-2]=b[S]-b[S-2];g.write(w)}g.close();const y=await new Response(m.readable).arrayBuffer(),v=new Uint8Array(y);return dwe(v)}static async decompressSignature(e){try{const r=MSt(e),{readable:n,writable:s}=new DecompressionStream("deflate-raw"),i=s.getWriter();await i.ready,i.write(r).then(async()=>{await i.ready,await i.close()}).catch(()=>{});let a=null,o=0;for await(const b of n)a||(a=new Uint8Array(new Uint32Array(b.buffer,0,4)[0])),a.set(b,o),o+=b.length;const c=new Uint32Array(a.buffer,0,a.length>>2),u=c[1];if(u!==0)throw new Error(`Invalid version: ${u}`);const d=c[2],h=c[3],f=c[4]===0,p=c[5],m=c[6],g=c[7],x=[],y=(xC+K1*m)*Uint32Array.BYTES_PER_ELEMENT;let v;switch(g){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(a.buffer,y);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(a.buffer,y);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(a.buffer,y);break}o=0;for(let b=0;b<m;b++){const w=c[K1*b+xC],S=new Float32Array(w+2);x.push(S);for(let k=0;k<K1-1;k++)S[k]=c[K1*b+xC+k+1];for(let k=0;k<w;k++)S[k+2]=S[k]+v[o++]}return{areContours:f,thickness:p,outlines:x,width:d,height:h}}catch(r){return Ft(`decompressSignature: ${r}`),null}}}wy=new WeakMap,Ar=new WeakSet,Nz=function(e,r,n,s){return n-=e,s-=r,n===0?s>0?0:4:n===1?s+6:2-s},Zl=new WeakMap,sSe=function(e,r,n,s,i,a,o){const c=ce(this,Ar,Nz).call(this,n,s,i,a);for(let u=0;u<8;u++){const d=(-u+c-o+16)%8,h=_(this,Zl)[2*d],f=_(this,Zl)[2*d+1];if(e[(n+h)*r+(s+f)]!==0)return d}return-1},iSe=function(e,r,n,s,i,a,o){const c=ce(this,Ar,Nz).call(this,n,s,i,a);for(let u=0;u<8;u++){const d=(u+c+o+16)%8,h=_(this,Zl)[2*d],f=_(this,Zl)[2*d+1];if(e[(n+h)*r+(s+f)]!==0)return d}return-1},Ez=function(e,r,n,s){const i=e.length,a=new Int32Array(i);for(let d=0;d<i;d++)a[d]=e[d]<=s?1:0;for(let d=1;d<n-1;d++)a[d*r]=a[d*r+r-1]=0;for(let d=0;d<r;d++)a[d]=a[r*n-1-d]=0;let o=1,c;const u=[];for(let d=1;d<n-1;d++){c=1;for(let h=1;h<r-1;h++){const f=d*r+h,p=a[f];if(p===0)continue;let m=d,g=h;if(p===1&&a[f-1]===0)o+=1,g-=1;else if(p>=1&&a[f+1]===0)o+=1,g+=1,p>1&&(c=p);else{p!==1&&(c=Math.abs(p));continue}const x=[h,d],y=g===h+1,v={isHole:y,points:x,id:o,parent:0};u.push(v);let b;for(const z of u)if(z.id===c){b=z;break}b?b.isHole?v.parent=y?b.parent:c:v.parent=y?c:b.parent:v.parent=y?c:0;const w=ce(this,Ar,sSe).call(this,a,r,d,h,m,g,0);if(w===-1){a[f]=-o,a[f]!==1&&(c=Math.abs(a[f]));continue}let S=_(this,Zl)[2*w],k=_(this,Zl)[2*w+1];const E=d+S,C=h+k;m=E,g=C;let A=d,M=h;for(;;){const z=ce(this,Ar,iSe).call(this,a,r,A,M,m,g,1);S=_(this,Zl)[2*z],k=_(this,Zl)[2*z+1];const P=A+S,W=M+k;x.push(W,P);const N=A*r+M;if(a[N+1]===0?a[N]=-o:a[N]===1&&(a[N]=o),P===d&&W===h&&A===E&&M===C){a[f]!==1&&(c=Math.abs(a[f]));break}else m=A,g=M,A=P,M=W}}}return u},KT=function(e,r,n,s){if(n-r<=4){for(let E=r;E<n-2;E+=2)s.push(e[E],e[E+1]);return}const i=e[r],a=e[r+1],o=e[n-4]-i,c=e[n-3]-a,u=Math.hypot(o,c),d=o/u,h=c/u,f=d*a-h*i,p=c/o,m=1/u,g=Math.atan(p),x=Math.cos(g),y=Math.sin(g),v=m*(Math.abs(x)+Math.abs(y)),b=m*(1-v+v**2),w=Math.max(Math.atan(Math.abs(y+x)*b),Math.atan(Math.abs(y-x)*b));let S=0,k=r;for(let E=r+2;E<n-2;E+=2){const C=Math.abs(f-d*e[E+1]+h*e[E]);C>S&&(k=E,S=C)}S>(u*w)**2?(ce(this,Ar,KT).call(this,e,r,k+2,s),ce(this,Ar,KT).call(this,e,k,n,s)):s.push(i,a)},aSe=function(e){const r=[],n=e.length;return ce(this,Ar,KT).call(this,e,0,n,r),r.push(e[n-2],e[n-1]),r.length<=4?null:r},oSe=function(e,r,n,s,i,a){const o=new Float32Array(a**2),c=-2*s**2,u=a>>1;for(let g=0;g<a;g++){const x=(g-u)**2;for(let y=0;y<a;y++)o[g*a+y]=Math.exp((x+(y-u)**2)/c)}const d=new Float32Array(256),h=-2*i**2;for(let g=0;g<256;g++)d[g]=Math.exp(g**2/h);const f=e.length,p=new Uint8Array(f),m=new Uint32Array(256);for(let g=0;g<n;g++)for(let x=0;x<r;x++){const y=g*r+x,v=e[y];let b=0,w=0;for(let k=0;k<a;k++){const E=g+k-u;if(!(E<0||E>=n))for(let C=0;C<a;C++){const A=x+C-u;if(A<0||A>=r)continue;const M=e[E*r+A],z=o[k*a+C]*d[Math.abs(M-v)];b+=M*z,w+=z}}const S=p[y]=Math.round(b/w);m[S]++}return[p,m]},lSe=function(e){const r=new Uint32Array(256);for(const n of e)r[n]++;return r},Az=function(e){const r=e.length,n=new Uint8ClampedArray(r>>2);let s=-1/0,i=1/0;for(let o=0,c=n.length;o<c;o++){const u=n[o]=e[o<<2];s=Math.max(s,u),i=Math.min(i,u)}const a=255/(s-i);for(let o=0,c=n.length;o<c;o++)n[o]=(n[o]-i)*a;return n},Cz=function(e){let r,n=-1/0,s=-1/0;const i=e.findIndex(c=>c!==0);let a=i,o=i;for(r=i;r<256;r++){const c=e[r];c>n&&(r-a>s&&(s=r-a,o=r-1),n=c,a=r)}for(r=o-1;r>=0&&!(e[r]>e[r+1]);r--);return r},cSe=function(e){const r=e,{width:n,height:s}=e,{maxDim:i}=_(this,wy);let a=n,o=s;if(n>i||s>i){let f=n,p=s,m=Math.log2(Math.max(n,s)/i);const g=Math.floor(m);m=m===g?g-1:g;for(let y=0;y<m;y++){a=Math.ceil(f/2),o=Math.ceil(p/2);const v=new OffscreenCanvas(a,o);v.getContext("2d").drawImage(e,0,0,f,p,0,0,a,o),f=a,p=o,e!==r&&e.close(),e=v.transferToImageBitmap()}const x=Math.min(i/a,i/o);a=Math.round(a*x),o=Math.round(o*x)}const u=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});u.fillStyle="white",u.fillRect(0,0,a,o),u.filter="grayscale(1)",u.drawImage(e,0,0,e.width,e.height,0,0,a,o);const d=u.getImageData(0,0,a,o).data;return[ce(this,Ar,Az).call(this,d),a,o]},le(Wd,Ar),le(Wd,wy,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),le(Wd,Zl,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class o7 extends Q1e{constructor(){super(),super.updateProperties({fill:rn._defaultLineColor,"stroke-width":0})}clone(){const e=new o7;return e.updateAll(this),e}}class l7 extends tD{constructor(e){super(e),super.updateProperties({stroke:rn._defaultLineColor,"stroke-width":1})}clone(){const e=new l7(this._viewParameters);return e.updateAll(this),e}}var ap,cu,op,Sy;const ro=class ro extends jO{constructor(r){super({...r,mustBeCommitted:!0,name:"signatureEditor"});le(this,ap,!1);le(this,cu,null);le(this,op,null);le(this,Sy,null);this._willKeepAspectRatio=!0,te(this,op,r.signatureData||null),te(this,cu,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(r,n){rn.initialize(r,n),this._defaultDrawingOptions=new o7,this._defaultDrawnSignatureOptions=new l7(n.viewParameters)}static getDefaultDrawingOptions(r){const n=this._defaultDrawingOptions.clone();return n.updateProperties(r),n}static get supportMultipleDrawings(){return!1}static get typesMap(){return tr(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!_(this,cu)}}static computeTelemetryFinalData(r){const n=r.get("hasDescription");return{hasAltText:n.get(!0)??0,hasNoAltText:n.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let r,n;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,r=this.x,n=this.y),super.render(),this._drawId===null)if(_(this,op)){const{lines:i,mustSmooth:a,areContours:o,description:c,uuid:u,heightInPage:d}=_(this,op),{rawDims:{pageWidth:h,pageHeight:f},rotation:p}=this.parent.viewport,m=Wd.processDrawnLines({lines:i,pageWidth:h,pageHeight:f,rotation:p,innerMargin:ro._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(m,d,c,u)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:_(this,cu)||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(r,n)),this.div}setUuid(r){te(this,Sy,r),this.addEditToolbar()}getUuid(){return _(this,Sy)}get description(){return _(this,cu)}set description(r){te(this,cu,r),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:r})),super.addEditToolbar().then(n=>{n==null||n.updateEditSignatureButton(r)}))}getSignaturePreview(){const{newCurves:r,areContours:n,thickness:s,width:i,height:a}=_(this,op),o=Math.max(i,a),c=Wd.processDrawnLines({lines:{curves:r.map(u=>({points:u})),thickness:s,width:i,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:n});return{areContours:n,outline:c.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(r,n,s,i){const{x:a,y:o}=this,{outline:c}=te(this,op,r);te(this,ap,c instanceof kz),this.description=s;let u;_(this,ap)?u=ro.getDefaultDrawingOptions():(u=ro._defaultDrawnSignatureOptions.clone(),u.updateProperties({"stroke-width":c.thickness})),this._addOutlines({drawOutlines:c,drawingOptions:u});const[d,h]=this.parentDimensions,[,f]=this.pageDimensions;let p=n/f;p=p>=1?.5:p,this.width*=p/this.height,this.width>=1&&(p*=.9/this.width,this.width=.9),this.height=p,this.setDims(d*this.width,h*this.height),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!s}}),this.div.hidden=!1}getFromImage(r){const{rawDims:{pageWidth:n,pageHeight:s},rotation:i}=this.parent.viewport;return Wd.process(r,n,s,i,ro._INNER_MARGIN)}getFromText(r,n){const{rawDims:{pageWidth:s,pageHeight:i},rotation:a}=this.parent.viewport;return Wd.extractContoursFromText(r,n,s,i,a,ro._INNER_MARGIN)}getDrawnSignature(r){const{rawDims:{pageWidth:n,pageHeight:s},rotation:i}=this.parent.viewport;return Wd.processDrawnLines({lines:r,pageWidth:n,pageHeight:s,rotation:i,innerMargin:ro._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:r,thickness:n}){r?this._drawingOptions=ro.getDefaultDrawingOptions():(this._drawingOptions=ro._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":n}))}serialize(r=!1){if(this.isEmpty())return null;const{lines:n,points:s,rect:i}=this.serializeDraw(r),{_drawingOptions:{"stroke-width":a}}=this,o={annotationType:Lt.SIGNATURE,isSignature:!0,areContours:_(this,ap),color:[0,0,0],thickness:_(this,ap)?0:a,pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(o),r?(o.paths={lines:n,points:s},o.uuid=_(this,Sy),o.isCopy=!0):o.lines=n,_(this,cu)&&(o.accessibilityData={type:"Figure",alt:_(this,cu)}),o}static deserializeDraw(r,n,s,i,a,o){return o.areContours?kz.deserialize(r,n,s,i,a,o):zE.deserialize(r,n,s,i,a,o)}static async deserialize(r,n,s){var a;const i=await super.deserialize(r,n,s);return te(i,ap,r.areContours),i.description=((a=r.accessibilityData)==null?void 0:a.alt)||"",te(i,Sy,r.uuid),i}};ap=new WeakMap,cu=new WeakMap,op=new WeakMap,Sy=new WeakMap,Ve(ro,"_type","signature"),Ve(ro,"_editorType",Lt.SIGNATURE),Ve(ro,"_defaultDrawingOptions",null);let Tz=ro;var xn,Us,lp,Bd,cp,P0,zd,_y,uu,xo,O0,vr,IS,RS,YT,XT,JT,Oz,QT,uSe;class Pz extends rn{constructor(r){super({...r,name:"stampEditor"});le(this,vr);le(this,xn,null);le(this,Us,null);le(this,lp,null);le(this,Bd,null);le(this,cp,null);le(this,P0,"");le(this,zd,null);le(this,_y,!1);le(this,uu,null);le(this,xo,!1);le(this,O0,!1);te(this,Bd,r.bitmapUrl),te(this,cp,r.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(r,n){rn.initialize(r,n)}static isHandlingMimeForPasting(r){return j8.includes(r)}static paste(r,n){n.pasteEditor({mode:Lt.STAMP},{bitmapFile:r.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var r;return{type:"stamp",hasAltText:!!((r=this.altTextData)!=null&&r.altText)}}static computeTelemetryFinalData(r){const n=r.get("hasAltText");return{hasAltText:n.get(!0)??0,hasNoAltText:n.get(!1)??0}}async mlGuessAltText(r=null,n=!0){if(this.hasAltTextData())return null;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:a,height:o}=r||this.copyCanvas(null,null,!0).imageData,c=await s.guess({name:"altText",request:{data:i,width:a,height:o,channels:i.length/(a*o)}});if(!c)throw new Error("No response from the AI service.");if(c.error)throw new Error("Error from the AI service.");if(c.cancel)return null;if(!c.output)throw new Error("No valid response from the AI service.");const u=c.output;return await this.setGuessedAltText(u),n&&!this.hasAltTextData()&&(this.altTextData={alt:u,decorative:!1}),u}remove(){var r;_(this,Us)&&(te(this,xn,null),this._uiManager.imageManager.deleteId(_(this,Us)),(r=_(this,zd))==null||r.remove(),te(this,zd,null),_(this,uu)&&(clearTimeout(_(this,uu)),te(this,uu,null))),super.remove()}rebuild(){if(!this.parent){_(this,Us)&&ce(this,vr,YT).call(this);return}super.rebuild(),this.div!==null&&(_(this,Us)&&_(this,zd)===null&&ce(this,vr,YT).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(r){this._isDraggable=!0,r&&this.div.focus()}isEmpty(){return!(_(this,lp)||_(this,xn)||_(this,Bd)||_(this,cp)||_(this,Us)||_(this,_y))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let r,n;return this._isCopy&&(r=this.x,n=this.y),super.render(),this.div.hidden=!0,this.createAltText(),_(this,_y)||(_(this,xn)?ce(this,vr,XT).call(this):ce(this,vr,YT).call(this)),this._isCopy&&this._moveAfterPaste(r,n),this._uiManager.addShouldRescale(this),this.div}setCanvas(r,n){const{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(r,n);n.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(te(this,Us,s),i&&te(this,xn,i),te(this,_y,!1),ce(this,vr,XT).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;_(this,uu)!==null&&clearTimeout(_(this,uu)),te(this,uu,setTimeout(()=>{te(this,uu,null),ce(this,vr,Oz).call(this)},200))}copyCanvas(r,n,s=!1){var p;r||(r=224);const{width:i,height:a}=_(this,xn),o=new Cu;let c=_(this,xn),u=i,d=a,h=null;if(n){if(i>n||a>n){const C=Math.min(n/i,n/a);u=Math.floor(i*C),d=Math.floor(a*C)}h=document.createElement("canvas");const m=h.width=Math.ceil(u*o.sx),g=h.height=Math.ceil(d*o.sy);_(this,xo)||(c=ce(this,vr,JT).call(this,m,g));const x=h.getContext("2d");x.filter=this._uiManager.hcmFilter;let y="white",v="#cfcfd8";this._uiManager.hcmFilter!=="none"?v="black":(p=window.matchMedia)!=null&&p.call(window,"(prefers-color-scheme: dark)").matches&&(y="#8f8f9d",v="#42414d");const b=15,w=b*o.sx,S=b*o.sy,k=new OffscreenCanvas(w*2,S*2),E=k.getContext("2d");E.fillStyle=y,E.fillRect(0,0,w*2,S*2),E.fillStyle=v,E.fillRect(0,0,w,S),E.fillRect(w,S,w,S),x.fillStyle=x.createPattern(k,"repeat"),x.fillRect(0,0,m,g),x.drawImage(c,0,0,c.width,c.height,0,0,m,g)}let f=null;if(s){let m,g;if(o.symmetric&&c.width<r&&c.height<r)m=c.width,g=c.height;else if(c=_(this,xn),i>r||a>r){const v=Math.min(r/i,r/a);m=Math.floor(i*v),g=Math.floor(a*v),_(this,xo)||(c=ce(this,vr,JT).call(this,m,g))}const y=new OffscreenCanvas(m,g).getContext("2d",{willReadFrequently:!0});y.drawImage(c,0,0,c.width,c.height,0,0,m,g),f={width:m,height:g,data:y.getImageData(0,0,m,g).data}}return{canvas:h,width:u,height:d,imageData:f}}static async deserialize(r,n,s){var x;let i=null,a=!1;if(r instanceof N1e){const{data:{rect:y,rotation:v,id:b,structParent:w,popupRef:S,contentsObj:k},container:E,parent:{page:{pageNumber:C}},canvas:A}=r;let M,z;A?(delete r.canvas,{id:M,bitmap:z}=s.imageManager.getFromCanvas(E.id,A),A.remove()):(a=!0,r._hasNoCanvas=!0);const P=((x=await n._structTree.getAriaAttributes(`${Z9}${b}`))==null?void 0:x.get("aria-label"))||"";i=r={annotationType:Lt.STAMP,bitmapId:M,bitmap:z,pageIndex:C-1,rect:y.slice(0),rotation:v,annotationElementId:b,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:P},isSvg:!1,structParent:w,popupRef:S,comment:(k==null?void 0:k.str)||null}}const o=await super.deserialize(r,n,s),{rect:c,bitmap:u,bitmapUrl:d,bitmapId:h,isSvg:f,accessibilityData:p}=r;a?(s.addMissingCanvas(r.id,o),te(o,_y,!0)):h&&s.imageManager.isValidId(h)?(te(o,Us,h),u&&te(o,xn,u)):te(o,Bd,d),te(o,xo,f);const[m,g]=o.pageDimensions;return o.width=(c[2]-c[0])/m,o.height=(c[3]-c[1])/g,p&&(o.altTextData=p),o._initialData=i,r.comment&&o.setCommentData(r.comment),te(o,O0,!!i),o}serialize(r=!1,n=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s={annotationType:Lt.STAMP,bitmapId:_(this,Us),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:_(this,xo),structTreeParentId:this._structTreeParentId};if(this.addComment(s),r)return s.bitmapUrl=ce(this,vr,QT).call(this,!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;const{decorative:i,altText:a}=this.serializeAltText(!1);if(!i&&a&&(s.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const c=ce(this,vr,uSe).call(this,s);if(c.isSame)return null;c.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1}if(s.id=this.annotationElementId,n===null)return s;n.stamps||(n.stamps=new Map);const o=_(this,xo)?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!n.stamps.has(_(this,Us)))n.stamps.set(_(this,Us),{area:o,serialized:s}),s.bitmap=ce(this,vr,QT).call(this,!1);else if(_(this,xo)){const c=n.stamps.get(_(this,Us));o>c.area&&(c.area=o,c.serialized.bitmap.close(),c.serialized.bitmap=ce(this,vr,QT).call(this,!1))}return s}renderAnnotationElement(r){const n={rect:this.getRect(0,0)};return this.hasEditedComment&&(n.popup=this.comment),r.updateEdited(n),null}}xn=new WeakMap,Us=new WeakMap,lp=new WeakMap,Bd=new WeakMap,cp=new WeakMap,P0=new WeakMap,zd=new WeakMap,_y=new WeakMap,uu=new WeakMap,xo=new WeakMap,O0=new WeakMap,vr=new WeakSet,IS=function(r,n=!1){if(!r){this.remove();return}te(this,xn,r.bitmap),n||(te(this,Us,r.id),te(this,xo,r.isSvg)),r.file&&te(this,P0,r.file.name),ce(this,vr,XT).call(this)},RS=function(){if(te(this,lp,null),this._uiManager.enableWaiting(!1),!!_(this,zd)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_(this,xn)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_(this,xn)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},YT=function(){if(_(this,Us)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(_(this,Us)).then(s=>ce(this,vr,IS).call(this,s,!0)).finally(()=>ce(this,vr,RS).call(this));return}if(_(this,Bd)){const s=_(this,Bd);te(this,Bd,null),this._uiManager.enableWaiting(!0),te(this,lp,this._uiManager.imageManager.getFromUrl(s).then(i=>ce(this,vr,IS).call(this,i)).finally(()=>ce(this,vr,RS).call(this)));return}if(_(this,cp)){const s=_(this,cp);te(this,cp,null),this._uiManager.enableWaiting(!0),te(this,lp,this._uiManager.imageManager.getFromFile(s).then(i=>ce(this,vr,IS).call(this,i)).finally(()=>ce(this,vr,RS).call(this)));return}const r=document.createElement("input");r.type="file",r.accept=j8.join(",");const n=this._uiManager._signal;te(this,lp,new Promise(s=>{r.addEventListener("change",async()=>{if(!r.files||r.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(r.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),ce(this,vr,IS).call(this,i)}s()},{signal:n}),r.addEventListener("cancel",()=>{this.remove(),s()},{signal:n})}).finally(()=>ce(this,vr,RS).call(this))),r.click()},XT=function(){var h;const{div:r}=this;let{width:n,height:s}=_(this,xn);const[i,a]=this.pageDimensions,o=.75;if(this.width)n=this.width*i,s=this.height*a;else if(n>o*i||s>o*a){const f=Math.min(o*i/n,o*a/s);n*=f,s*=f}const[c,u]=this.parentDimensions;this.setDims(n*c/i,s*u/a),this._uiManager.enableWaiting(!1);const d=te(this,zd,document.createElement("canvas"));d.setAttribute("role","img"),this.addContainer(d),this.width=n/i,this.height=s/a,(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(r.hidden=!1),ce(this,vr,Oz).call(this),_(this,O0)||(this.parent.addUndoableEditor(this),te(this,O0,!0)),this._reportTelemetry({action:"inserted_image"}),_(this,P0)&&this.div.setAttribute("aria-description",_(this,P0)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},JT=function(r,n){const{width:s,height:i}=_(this,xn);let a=s,o=i,c=_(this,xn);for(;a>2*r||o>2*n;){const u=a,d=o;a>2*r&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*n&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const h=new OffscreenCanvas(a,o);h.getContext("2d").drawImage(c,0,0,u,d,0,0,a,o),c=h.transferToImageBitmap()}return c},Oz=function(){const[r,n]=this.parentDimensions,{width:s,height:i}=this,a=new Cu,o=Math.ceil(s*r*a.sx),c=Math.ceil(i*n*a.sy),u=_(this,zd);if(!u||u.width===o&&u.height===c)return;u.width=o,u.height=c;const d=_(this,xo)?_(this,xn):ce(this,vr,JT).call(this,o,c),h=u.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(d,0,0,d.width,d.height,0,0,o,c)},QT=function(r){if(r){if(_(this,xo)){const i=this._uiManager.imageManager.getSvgUrl(_(this,Us));if(i)return i}const n=document.createElement("canvas");return{width:n.width,height:n.height}=_(this,xn),n.getContext("2d").drawImage(_(this,xn),0,0),n.toDataURL()}if(_(this,xo)){const[n,s]=this.pageDimensions,i=Math.round(this.width*n*Gp.PDF_TO_CSS_UNITS),a=Math.round(this.height*s*Gp.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(i,a);return o.getContext("2d").drawImage(_(this,xn),0,0,_(this,xn).width,_(this,xn).height,0,0,i,a),o.transferToImageBitmap()}return structuredClone(_(this,xn))},uSe=function(r){var o;const{pageIndex:n,accessibilityData:{altText:s}}=this._initialData,i=r.pageIndex===n,a=(((o=r.accessibilityData)==null?void 0:o.alt)||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&a,isSameAltText:a}},Ve(Pz,"_type","stamp"),Ve(Pz,"_editorType",Lt.STAMP);var jy,I0,du,up,Ud,vo,dp,R0,ky,ec,Hd,Hs,Vd,hp,M0,St,fp,vn,dSe,Mc,Rz,Mz,ZT;const zl=class zl{constructor({uiManager:e,pageIndex:r,div:n,structTreeLayer:s,accessibilityManager:i,annotationLayer:a,drawLayer:o,textLayer:c,viewport:u,l10n:d}){le(this,vn);le(this,jy);le(this,I0,!1);le(this,du,null);le(this,up,null);le(this,Ud,null);le(this,vo,new Map);le(this,dp,!1);le(this,R0,!1);le(this,ky,!1);le(this,ec,null);le(this,Hd,null);le(this,Hs,null);le(this,Vd,null);le(this,hp,null);le(this,M0,-1);le(this,St);const h=[..._(zl,fp).values()];if(!zl._initialized){zl._initialized=!0;for(const f of h)f.initialize(d,e)}e.registerEditorTypes(h),te(this,St,e),this.pageIndex=r,this.div=n,te(this,jy,i),te(this,du,a),this.viewport=u,te(this,Hs,c),this.drawLayer=o,this._structTree=s,_(this,St).addLayer(this)}get isEmpty(){return _(this,vo).size===0}get isInvisible(){return this.isEmpty&&_(this,St).getMode()===Lt.NONE}updateToolbar(e){_(this,St).updateToolbar(e)}updateMode(e=_(this,St).getMode()){switch(ce(this,vn,ZT).call(this),e){case Lt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Lt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Lt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:r}=this.div;for(const n of _(zl,fp).values())r.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){var r;return e===((r=_(this,Hs))==null?void 0:r.div)}setEditingState(e){_(this,St).setEditingState(e)}addCommands(e){_(this,St).addCommands(e)}cleanUndoStack(e){_(this,St).cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){var r;(r=_(this,du))==null||r.div.classList.toggle("disabled",!e)}async enable(){var n;te(this,ky,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),(n=_(this,hp))==null||n.abort(),te(this,hp,null);const e=new Set;for(const s of _(this,vo).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(_(this,St).removeChangedExistingAnnotation(s),e.add(s.annotationElementId));if(!_(this,du)){te(this,ky,!1);return}const r=_(this,du).getEditableAnnotations();for(const s of r){if(s.hide(),_(this,St).isDeletedAnnotationElement(s.data.id)||e.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}te(this,ky,!1)}disable(){var s;if(te(this,R0,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),_(this,Hs)&&!_(this,hp)){te(this,hp,new AbortController);const i=_(this,St).combinedSignal(_(this,hp));_(this,Hs).div.addEventListener("pointerdown",a=>{const{clientX:c,clientY:u,timeStamp:d}=a,h=_(this,M0);if(d-h>500){te(this,M0,d);return}te(this,M0,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const p=document.elementsFromPoint(c,u);if(f.toggle("getElements",!1),!this.div.contains(p[0]))return;let m;const g=new RegExp(`^${awe}[0-9]+$`);for(const y of p)if(g.test(y.id)){m=y.id;break}if(!m)return;const x=_(this,vo).get(m);(x==null?void 0:x.annotationElementId)===null&&(a.stopPropagation(),a.preventDefault(),x.dblclick())},{signal:i,capture:!0})}const e=new Map,r=new Map;for(const i of _(this,vo).values())if(i.disableEditing(),!!i.annotationElementId){if(i.serialize()!==null){e.set(i.annotationElementId,i);continue}else r.set(i.annotationElementId,i);(s=this.getEditableAnnotation(i.annotationElementId))==null||s.show(),i.remove()}if(_(this,du)){const i=_(this,du).getEditableAnnotations();for(const a of i){const{id:o}=a.data;if(_(this,St).isDeletedAnnotationElement(o)){a.updateEdited({deleted:!0});continue}let c=r.get(o);if(c){c.resetAnnotationElement(a),c.show(!1),a.show();continue}c=e.get(o),c&&(_(this,St).addChangedExistingAnnotation(c),c.renderAnnotationElement(a)&&c.show(!1)),a.show()}}ce(this,vn,ZT).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const i of _(zl,fp).values())n.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),te(this,R0,!1)}getEditableAnnotation(e){var r;return((r=_(this,du))==null?void 0:r.getEditableAnnotation(e))||null}setActiveEditor(e){_(this,St).getActive()!==e&&_(this,St).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=_(this,Hs))!=null&&e.div&&!_(this,Vd)){te(this,Vd,new AbortController);const r=_(this,St).combinedSignal(_(this,Vd));_(this,Hs).div.addEventListener("pointerdown",ce(this,vn,dSe).bind(this),{signal:r}),_(this,Hs).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=_(this,Hs))!=null&&e.div&&_(this,Vd)&&(_(this,Vd).abort(),te(this,Vd,null),_(this,Hs).div.classList.remove("highlighting"))}enableClick(){if(_(this,up))return;te(this,up,new AbortController);const e=_(this,St).combinedSignal(_(this,up));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const r=this.pointerup.bind(this);this.div.addEventListener("pointerup",r,{signal:e}),this.div.addEventListener("pointercancel",r,{signal:e})}disableClick(){var e;(e=_(this,up))==null||e.abort(),te(this,up,null)}attach(e){_(this,vo).set(e.id,e);const{annotationElementId:r}=e;r&&_(this,St).isDeletedAnnotationElement(r)&&_(this,St).removeDeletedAnnotationElement(e)}detach(e){var r;_(this,vo).delete(e.id),(r=_(this,jy))==null||r.removePointerInTextLayer(e.contentDiv),!_(this,R0)&&e.annotationElementId&&_(this,St).addDeletedAnnotationElement(e)}remove(e){this.detach(e),_(this,St).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){var r;e.parent!==this&&(e.parent&&e.annotationElementId&&(_(this,St).addDeletedAnnotationElement(e.annotationElementId),rn.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(r=e.parent)==null||r.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),_(this,St).addEditor(e),this.attach(e),!e.isAttachedToDOM){const r=e.render();this.div.append(r),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!_(this,ky)),_(this,St).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var n;if(!e.isAttachedToDOM)return;const{activeElement:r}=document;e.div.contains(r)&&!_(this,Ud)&&(e._focusEventsAllowed=!1,te(this,Ud,setTimeout(()=>{te(this,Ud,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:_(this,St)._signal}),r.focus())},0))),e._structTreeParentId=(n=_(this,jy))==null?void 0:n.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||(e.parent=this),e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){const r=()=>e._uiManager.rebuild(e),n=()=>{e.remove()};this.addCommands({cmd:r,undo:n,mustExec:!1})}getNextId(){return _(this,St).getId()}combinedSignal(e){return _(this,St).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=_(this,vn,Mc))==null?void 0:e.canCreateNewEmptyEditor()}async pasteEditor(e,r){this.updateToolbar(e),await _(this,St).updateMode(e.mode);const{offsetX:n,offsetY:s}=ce(this,vn,Mz).call(this),i=this.getNextId(),a=ce(this,vn,Rz).call(this,{parent:this,id:i,x:n,y:s,uiManager:_(this,St),isCentered:!0,...r});a&&this.add(a)}async deserialize(e){var r;return await((r=_(zl,fp).get(e.annotationType??e.annotationEditorType))==null?void 0:r.deserialize(e,this,_(this,St)))||null}createAndAddNewEditor(e,r,n={}){const s=this.getNextId(),i=ce(this,vn,Rz).call(this,{parent:this,id:s,x:e.offsetX,y:e.offsetY,uiManager:_(this,St),isCentered:r,...n});return i&&this.add(i),i}addNewEditor(e={}){this.createAndAddNewEditor(ce(this,vn,Mz).call(this),!0,e)}setSelected(e){_(this,St).setSelected(e)}toggleSelected(e){_(this,St).toggleSelected(e)}unselect(e){_(this,St).unselect(e)}pointerup(e){var s;const{isMac:r}=wi.platform;if(e.button!==0||e.ctrlKey&&r||e.target!==this.div||!_(this,dp)||(te(this,dp,!1),(s=_(this,vn,Mc))!=null&&s.isDrawer&&_(this,vn,Mc).supportMultipleDrawings))return;if(!_(this,I0)){te(this,I0,!0);return}const n=_(this,St).getMode();if(n===Lt.STAMP||n===Lt.SIGNATURE){_(this,St).unselectAll();return}this.createAndAddNewEditor(e,!1)}pointerdown(e){var s;if(_(this,St).getMode()===Lt.HIGHLIGHT&&this.enableTextSelection(),_(this,dp)){te(this,dp,!1);return}const{isMac:r}=wi.platform;if(e.button!==0||e.ctrlKey&&r||e.target!==this.div)return;if(te(this,dp,!0),(s=_(this,vn,Mc))!=null&&s.isDrawer){this.startDrawingSession(e);return}const n=_(this,St).getActive();te(this,I0,!n||n.isEmpty())}startDrawingSession(e){if(this.div.focus({preventScroll:!0}),_(this,ec)){_(this,vn,Mc).startDrawing(this,_(this,St),!1,e);return}_(this,St).setCurrentDrawingSession(this),te(this,ec,new AbortController);const r=_(this,St).combinedSignal(_(this,ec));this.div.addEventListener("blur",({relatedTarget:n})=>{n&&!this.div.contains(n)&&(te(this,Hd,null),this.commitOrRemove())},{signal:r}),_(this,vn,Mc).startDrawing(this,_(this,St),!1,e)}pause(e){if(e){const{activeElement:r}=document;this.div.contains(r)&&te(this,Hd,r);return}_(this,Hd)&&setTimeout(()=>{var r;(r=_(this,Hd))==null||r.focus(),te(this,Hd,null)},0)}endDrawingSession(e=!1){return _(this,ec)?(_(this,St).setCurrentDrawingSession(null),_(this,ec).abort(),te(this,ec,null),te(this,Hd,null),_(this,vn,Mc).endDrawing(e)):null}findNewParent(e,r,n){const s=_(this,St).findParent(r,n);return s===null||s===this?!1:(s.changeParent(e),!0)}commitOrRemove(){return _(this,ec)?(this.endDrawingSession(),!0):!1}onScaleChanging(){_(this,ec)&&_(this,vn,Mc).onScaleChangingWhenDrawing(this)}destroy(){var e,r;this.commitOrRemove(),((e=_(this,St).getActive())==null?void 0:e.parent)===this&&(_(this,St).commitOrRemove(),_(this,St).setActiveEditor(null)),_(this,Ud)&&(clearTimeout(_(this,Ud)),te(this,Ud,null));for(const n of _(this,vo).values())(r=_(this,jy))==null||r.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,_(this,vo).clear(),_(this,St).removeLayer(this)}render({viewport:e}){this.viewport=e,rx(this.div,e);for(const r of _(this,St).getEditors(this.pageIndex))this.add(r),r.rebuild();this.updateMode()}update({viewport:e}){_(this,St).commitOrRemove(),ce(this,vn,ZT).call(this);const r=this.viewport.rotation,n=e.rotation;if(this.viewport=e,rx(this.div,{rotation:n}),r!==n)for(const s of _(this,vo).values())s.rotate(n)}get pageDimensions(){const{pageWidth:e,pageHeight:r}=this.viewport.rawDims;return[e,r]}get scale(){return _(this,St).viewParameters.realScale}};jy=new WeakMap,I0=new WeakMap,du=new WeakMap,up=new WeakMap,Ud=new WeakMap,vo=new WeakMap,dp=new WeakMap,R0=new WeakMap,ky=new WeakMap,ec=new WeakMap,Hd=new WeakMap,Hs=new WeakMap,Vd=new WeakMap,hp=new WeakMap,M0=new WeakMap,St=new WeakMap,fp=new WeakMap,vn=new WeakSet,dSe=function(e){_(this,St).unselectAll();const{target:r}=e;if(r===_(this,Hs).div||(r.getAttribute("role")==="img"||r.classList.contains("endOfContent"))&&_(this,Hs).div.contains(r)){const{isMac:n}=wi.platform;if(e.button!==0||e.ctrlKey&&n)return;_(this,St).showAllEditors("highlight",!0,!0),_(this,Hs).div.classList.add("free"),this.toggleDrawing(),_O.startHighlighting(this,_(this,St).direction==="ltr",{target:_(this,Hs).div,x:e.x,y:e.y}),_(this,Hs).div.addEventListener("pointerup",()=>{_(this,Hs).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:_(this,St)._signal}),e.preventDefault()}},Mc=function(){return _(zl,fp).get(_(this,St).getMode())},Rz=function(e){const r=_(this,vn,Mc);return r?new r.prototype.constructor(e):null},Mz=function(){const{x:e,y:r,width:n,height:s}=this.div.getBoundingClientRect(),i=Math.max(0,e),a=Math.max(0,r),o=Math.min(window.innerWidth,e+n),c=Math.min(window.innerHeight,r+s),u=(i+o)/2-e,d=(a+c)/2-r,[h,f]=this.viewport.rotation%180===0?[u,d]:[d,u];return{offsetX:h,offsetY:f}},ZT=function(){for(const e of _(this,vo).values())e.isEmpty()&&e.remove()},Ve(zl,"_initialized",!1),le(zl,fp,new Map([pz,jz,Pz,_O,Tz].map(e=>[e._editorType,e])));let Iz=zl;var tc,aa,Ny,XN,RI,hSe,Ou,Lz,fSe,Fz;const ws=class ws{constructor({pageIndex:e}){le(this,Ou);le(this,tc,null);le(this,aa,new Map);le(this,Ny,new Map);this.pageIndex=e}setParent(e){if(!_(this,tc)){te(this,tc,e);return}if(_(this,tc)!==e){if(_(this,aa).size>0)for(const r of _(this,aa).values())r.remove(),e.append(r);te(this,tc,e)}}static get _svgFactory(){return tr(this,"_svgFactory",new wO)}draw(e,r=!1,n=!1){const s=Ds(ws,XN)._++,i=ce(this,Ou,Lz).call(this),a=ws._svgFactory.createElement("defs");i.append(a);const o=ws._svgFactory.createElement("path");a.append(o);const c=`path_p${this.pageIndex}_${s}`;o.setAttribute("id",c),o.setAttribute("vector-effect","non-scaling-stroke"),r&&_(this,Ny).set(s,o);const u=n?ce(this,Ou,fSe).call(this,a,c):null,d=ws._svgFactory.createElement("use");return i.append(d),d.setAttribute("href",`#${c}`),this.updateProperties(i,e),_(this,aa).set(s,i),{id:s,clipPathId:`url(#${u})`}}drawOutline(e,r){const n=Ds(ws,XN)._++,s=ce(this,Ou,Lz).call(this),i=ws._svgFactory.createElement("defs");s.append(i);const a=ws._svgFactory.createElement("path");i.append(a);const o=`path_p${this.pageIndex}_${n}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let c;if(r){const h=ws._svgFactory.createElement("mask");i.append(h),c=`mask_p${this.pageIndex}_${n}`,h.setAttribute("id",c),h.setAttribute("maskUnits","objectBoundingBox");const f=ws._svgFactory.createElement("rect");h.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const p=ws._svgFactory.createElement("use");h.append(p),p.setAttribute("href",`#${o}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const u=ws._svgFactory.createElement("use");s.append(u),u.setAttribute("href",`#${o}`),c&&u.setAttribute("mask",`url(#${c})`);const d=u.cloneNode();return s.append(d),u.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(s,e),_(this,aa).set(n,s),n}finalizeDraw(e,r){_(this,Ny).delete(e),this.updateProperties(e,r)}updateProperties(e,r){var c;if(!r)return;const{root:n,bbox:s,rootClass:i,path:a}=r,o=typeof e=="number"?_(this,aa).get(e):e;if(o){if(n&&ce(this,Ou,Fz).call(this,o,n),s&&ce(c=ws,RI,hSe).call(c,o,s),i){const{classList:u}=o;for(const[d,h]of Object.entries(i))u.toggle(d,h)}if(a){const d=o.firstChild.firstChild;ce(this,Ou,Fz).call(this,d,a)}}}updateParent(e,r){if(r===this)return;const n=_(this,aa).get(e);n&&(_(r,tc).append(n),_(this,aa).delete(e),_(r,aa).set(e,n))}remove(e){_(this,Ny).delete(e),_(this,tc)!==null&&(_(this,aa).get(e).remove(),_(this,aa).delete(e))}destroy(){te(this,tc,null);for(const e of _(this,aa).values())e.remove();_(this,aa).clear(),_(this,Ny).clear()}};tc=new WeakMap,aa=new WeakMap,Ny=new WeakMap,XN=new WeakMap,RI=new WeakSet,hSe=function(e,[r,n,s,i]){const{style:a}=e;a.top=`${100*n}%`,a.left=`${100*r}%`,a.width=`${100*s}%`,a.height=`${100*i}%`},Ou=new WeakSet,Lz=function(){const e=ws._svgFactory.create(1,1,!0);return _(this,tc).append(e),e.setAttribute("aria-hidden",!0),e},fSe=function(e,r){const n=ws._svgFactory.createElement("clipPath");e.append(n);const s=`clip_${r}`;n.setAttribute("id",s),n.setAttribute("clipPathUnits","objectBoundingBox");const i=ws._svgFactory.createElement("use");return n.append(i),i.setAttribute("href",`#${r}`),i.classList.add("clip"),s},Fz=function(e,r){for(const[n,s]of Object.entries(r))s===null?e.removeAttribute(n):e.setAttribute(n,s)},le(ws,RI),le(ws,XN,0);let Dz=ws;globalThis._pdfjsTestingUtils={HighlightOutliner:gz};globalThis.pdfjsLib={AbortException:qp,AnnotationEditorLayer:Iz,AnnotationEditorParamsType:dr,AnnotationEditorType:Lt,AnnotationEditorUIManager:nx,AnnotationLayer:dz,AnnotationMode:pf,AnnotationType:ss,build:H_t,ColorPicker:vO,createValidAbsoluteUrl:owe,DOMSVGFactory:wO,DrawLayer:Dz,FeatureTest:wi,fetchData:LE,getDocument:ZM,getFilenameFromUrl:DSt,getPdfFilenameFromUrl:LSt,getRGB:JM,getUuid:uwe,getXfaPageViewport:$St,GlobalWorkerOptions:ll,ImageKind:_T,InvalidPDFException:S8,isDataScheme:XM,isPdfFile:t7,isValidExplicitDest:XSt,MathClamp:la,noContextMenu:Al,normalizeUnicode:ISt,OPS:pO,OutputScale:Cu,PasswordResponses:jSt,PDFDataRangeTransport:d1e,PDFDateString:gO,PDFWorker:tk,PermissionFlag:_St,PixelsPerInch:Gp,RenderingCancelledException:e7,ResponseException:mO,setLayerDimensions:rx,shadow:tr,SignatureExtractor:Wd,stopEvent:ls,SupportedImageMimeTypes:j8,TextLayer:bw,TouchManager:xO,updateUrlHash:lwe,Util:jt,VerbosityLevel:GM,version:eD,XfaLayer:m1e};ll.workerSrc=`https://unpkg.com/pdfjs-dist@${eD}/build/pdf.worker.min.mjs`;function hjt({open:t,onOpenChange:e,pdfUrl:r,title:n}){const[s,i]=j.useState(null),[a,o]=j.useState(1),[c,u]=j.useState(0),[d,h]=j.useState(1),[f,p]=j.useState(!0),[m,g]=j.useState(null),[x,y]=j.useState(!0),[v,b]=j.useState(!1),[w,S]=j.useState([]),[k,E]=j.useState([]),C=j.useRef(null),A=j.useRef([]),M=j.useRef(null);j.useEffect(()=>{if(!t||!r)return;p(!0),g(null),i(null),S([]),E([]),o(1),(async()=>{try{const F=await ZM(r).promise;i(F),u(F.numPages),p(!1)}catch(L){console.error("Error loading PDF:",L),g("Failed to load PDF. Please try again."),p(!1)}})()},[t,r]),j.useEffect(()=>{if(!s||k.length>0)return;(async()=>{const L=[];for(let F=1;F<=s.numPages;F++)try{const V=await s.getPage(F),Y=V.getViewport({scale:d}),ie=document.createElement("canvas"),Q=ie.getContext("2d");if(!Q)continue;ie.height=Y.height,ie.width=Y.width,await V.render({canvasContext:Q,viewport:Y,canvas:ie}).promise,L.push(ie.toDataURL("image/png",.9))}catch(V){console.error(`Error rendering page ${F}:`,V)}E(L)})()},[s,d]),j.useEffect(()=>{!s||!t||E([])},[d]),j.useEffect(()=>{if(!s||w.length>0)return;(async()=>{const L=[];for(let F=1;F<=Math.min(s.numPages,50);F++)try{const V=await s.getPage(F),Y=V.getViewport({scale:.2}),ie=document.createElement("canvas"),Q=ie.getContext("2d");if(!Q)continue;ie.height=Y.height,ie.width=Y.width,await V.render({canvasContext:Q,viewport:Y,canvas:ie}).promise,L.push(ie.toDataURL())}catch(V){console.error(`Error generating thumbnail for page ${F}:`,V)}S(L)})()},[s,w.length]),j.useEffect(()=>{const B=M.current;if(!B||k.length===0)return;const L=()=>{const F=B.scrollTop,V=B.clientHeight;for(let Y=0;Y<A.current.length;Y++){const ie=A.current[Y];if(!ie)continue;const Q=ie.offsetTop,D=ie.offsetHeight,R=Q+D/2;if(R>F&&R<F+V){o(Y+1);break}}};return B.addEventListener("scroll",L),()=>B.removeEventListener("scroll",L)},[k]);const z=j.useCallback(B=>{const L=A.current[B-1];L&&M.current&&(L.scrollIntoView({behavior:"smooth",block:"start"}),o(B))},[]),P=()=>{a>1&&z(a-1)},W=()=>{a<c&&z(a+1)},N=B=>{const L=parseInt(B.target.value);L>=1&&L<=c&&z(L)},U=B=>{if(B.key==="Enter"){const L=parseInt(B.target.value);L>=1&&L<=c&&z(L)}},K=()=>h(B=>Math.min(B+.25,3)),G=()=>h(B=>Math.max(B-.25,.5)),X=()=>{if(C.current&&s){const B=C.current.clientWidth-48;s.getPage(1).then(L=>{const F=L.getViewport({scale:1});h(B/F.width)})}},H=()=>{const B=document.createElement("a");B.href=r,B.download=n||"document.pdf",B.click()};return j.useEffect(()=>{if(!t)return;const B=L=>{L.key==="ArrowLeft"&&P(),L.key==="ArrowRight"&&W(),(L.key==="+"||L.key==="=")&&K(),L.key==="-"&&G()};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[t,a,c]),l.jsx(Gr,{open:t,onOpenChange:e,children:l.jsxs(zr,{className:Le("p-0 gap-0 overflow-hidden",v?"max-w-[100vw] h-[100vh] rounded-none":"max-w-6xl h-[90vh]"),children:[l.jsx(Ur,{className:"px-4 py-3 border-b bg-muted/30",children:l.jsx(Hr,{className:"text-base font-medium truncate pr-8",children:n||"PDF Document"})}),l.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b bg-muted/20 backdrop-blur-sm",children:[l.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>y(!x),className:"h-8 w-8 p-0",children:x?l.jsx(U2e,{className:"h-4 w-4"}):l.jsx(H2e,{className:"h-4 w-4"})}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ye,{variant:"ghost",size:"sm",onClick:P,disabled:a<=1,className:"h-8 w-8 p-0",children:l.jsx(Ece,{className:"h-4 w-4"})}),l.jsxs("div",{className:"flex items-center gap-1.5 text-sm",children:[l.jsx(Be,{type:"number",min:1,max:c,value:a,onChange:N,onKeyDown:U,className:"w-14 h-7 text-center text-sm [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),l.jsxs("span",{className:"text-muted-foreground",children:["of ",c]})]}),l.jsx(ye,{variant:"ghost",size:"sm",onClick:W,disabled:a>=c,className:"h-8 w-8 p-0",children:l.jsx(eR,{className:"h-4 w-4"})})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(ye,{variant:"ghost",size:"sm",onClick:G,disabled:d<=.5,className:"h-8 w-8 p-0",children:l.jsx(aPe,{className:"h-4 w-4"})}),l.jsxs(ye,{variant:"ghost",size:"sm",onClick:X,className:"h-8 px-2 text-xs",children:[Math.round(d*100),"%"]}),l.jsx(ye,{variant:"ghost",size:"sm",onClick:K,disabled:d>=3,className:"h-8 w-8 p-0",children:l.jsx(zce,{className:"h-4 w-4"})}),l.jsx("div",{className:"w-px h-5 bg-border mx-1"}),l.jsx(ye,{variant:"ghost",size:"sm",onClick:H,className:"h-8 w-8 p-0",children:l.jsx(Ga,{className:"h-4 w-4"})}),l.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>b(!v),className:"h-8 w-8 p-0",children:v?l.jsx(F2e,{className:"h-4 w-4"}):l.jsx(O2e,{className:"h-4 w-4"})})]})]}),l.jsxs("div",{className:"flex flex-1 overflow-hidden",ref:C,children:[x&&l.jsx("div",{className:"w-32 border-r bg-muted/10 flex-shrink-0",children:l.jsx(Yw,{className:"h-full",children:l.jsxs("div",{className:"p-2 space-y-2",children:[w.map((B,L)=>l.jsxs("button",{onClick:()=>z(L+1),className:Le("w-full rounded-lg border-2 overflow-hidden transition-all",a===L+1?"border-primary shadow-md":"border-transparent hover:border-muted-foreground/30"),children:[l.jsx("img",{src:B,alt:`Page ${L+1}`,className:"w-full"}),l.jsx("div",{className:"text-xs text-muted-foreground py-1",children:L+1})]},L)),w.length===0&&!f&&l.jsx("div",{className:"text-xs text-muted-foreground text-center py-4",children:"Loading thumbnails..."})]})})}),l.jsx("div",{ref:M,className:"flex-1 overflow-auto bg-muted/5",children:f?l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"flex flex-col items-center gap-3",children:[l.jsx(xt,{className:"h-8 w-8 animate-spin text-primary"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading PDF..."})]})}):m?l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-destructive mb-2",children:m}),l.jsx(ye,{variant:"outline",onClick:()=>e(!1),children:"Close"})]})}):k.length===0?l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsxs("div",{className:"flex flex-col items-center gap-3",children:[l.jsx(xt,{className:"h-8 w-8 animate-spin text-primary"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Rendering pages..."})]})}):l.jsx("div",{className:"flex flex-col items-center gap-4 p-6",children:k.map((B,L)=>l.jsxs("div",{ref:F=>A.current[L]=F,className:"relative",children:[l.jsx("img",{src:B,alt:`Page ${L+1}`,className:"shadow-lg rounded-sm max-w-full"}),l.jsxs("div",{className:"absolute -bottom-3 left-1/2 -translate-x-1/2 bg-muted/80 backdrop-blur-sm px-2 py-0.5 rounded text-xs text-muted-foreground",children:["Page ",L+1]})]},L))})})]})]})})}function fjt({documentId:t}){const[e,r]=j.useState(null),[n,s]=j.useState(0),[i,a]=j.useState(""),[o,c]=j.useState(!1),[u,d]=j.useState(!0),[h,f]=j.useState(!1);j.useEffect(()=>{p()},[t]);const p=async()=>{var E;d(!0);const[w,S]=await Promise.all([be.from("pages").select("page_number").eq("document_id",t).order("page_number",{ascending:!0}).limit(1).maybeSingle(),be.from("pages").select("id",{count:"exact",head:!0}).eq("document_id",t)]),k=((E=w.data)==null?void 0:E.page_number)??null;r(k),s(S.count??0),a(k!=null?String(k):""),d(!1)},m=parseInt(i,10),g=!isNaN(m)&&i.trim()!=="",x=g&&e!=null?m-e:0,y=e!=null&&e!==1,v=()=>{if(x===0){We.info("No correction needed — the start page is already correct.");return}f(!0)},b=async()=>{f(!1),c(!0);try{const{data:w,error:S}=await be.from("pages").select("id, page_number").eq("document_id",t);if(S)throw S;if(!w||w.length===0){We.error("No pages found for this document.");return}const k=w.map(M=>be.from("pages").update({page_number:(M.page_number??0)+x}).eq("id",M.id)),C=(await Promise.all(k)).filter(M=>M.error);if(C.length>0){console.error("Some page updates failed:",C),We.error(`${C.length} page(s) could not be updated.`);return}const A=x>0?"+":"";We.success(`Page numbers corrected (Offset: ${A}${x})`),await p()}catch(w){console.error("Page correction error:",w),We.error("Error correcting page numbers.")}finally{c(!1)}};return u?l.jsxs(l.Fragment,{children:[l.jsx(vi,{}),l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-2",children:[l.jsx(Di,{className:"w-4 h-4 animate-spin"}),"Loading page data..."]})]}):n===0?null:l.jsxs(l.Fragment,{children:[l.jsx(vi,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"text-sm font-semibold",children:"Correct Original Page Numbers"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"If this PDF is an excerpt (e.g. from a journal), enter the real page number of the first PDF page."})]}),y&&l.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-950/30 p-2 rounded-md",children:[l.jsx(bu,{className:"w-3.5 h-3.5 shrink-0 text-destructive"}),"Pages already shifted — first page is currently ",e,"."]}),l.jsxs("div",{className:"flex items-end gap-3",children:[l.jsxs("div",{className:"flex-1 space-y-1.5",children:[l.jsx(_e,{htmlFor:"page-start",className:"text-xs",children:"PDF page 1 corresponds to original page:"}),l.jsx(Be,{id:"page-start",type:"number",value:i,onChange:w=>a(w.target.value),placeholder:"e.g. 413",className:"h-9"})]}),l.jsx(ye,{size:"sm",onClick:v,disabled:!g||x===0||o,className:"h-9",children:o?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):"Correct Pages"})]}),g&&x!==0&&l.jsxs("p",{className:"text-xs text-muted-foreground",children:[n," page(s) will be shifted by ",x>0?"+":"",x,". Page ",e," → ",m,", Page ",(e??0)+n-1," → ",m+n-1,"."]})]}),l.jsx(va,{open:h,onOpenChange:f,children:l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Correct Page Numbers?"}),l.jsxs(Gi,{children:["All ",n," page(s) will be shifted by ",x>0?"+":"",x,". Page ",e," becomes ",m,", Page ",(e??0)+n-1," becomes ",m+n-1,". This cannot be easily undone."]})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:b,children:"Correct Pages"})]})]})})]})}function pjt({documents:t,documentPages:e,onDocumentDeleted:r,currentPage:n,itemsPerPage:s,totalItems:i,onPageChange:a}){const o=Or(),{userProfile:c}=Dt(),[u,d]=j.useState(new Set),[h,f]=j.useState({}),[p,m]=j.useState(new Set),[g,x]=j.useState(new Set),[y,v]=j.useState(""),[b,w]=j.useState(!1),[S,k]=j.useState(null);j.useEffect(()=>{IR(t,"documents").then(f)},[t]);const E=H=>{var F,V,Y,ie;const B=H.book_title;if(B)return B;const L=H.bib_meta;if(!L)return null;if(L.title&&typeof L.title=="string")return L.title;if((F=L.google_books_data)!=null&&F.title)return L.google_books_data.title;if((Y=(V=L.crossref_data)==null?void 0:V.crossref_metadata)!=null&&Y.title){const Q=L.crossref_data.crossref_metadata.title;return Array.isArray(Q)?Q[0]:Q}if((ie=L.crossref_payload)!=null&&ie.title){const Q=L.crossref_payload.title;return Array.isArray(Q)?Q[0]:Q}return null},C=async H=>{const B=t.find(L=>L.id===H);if(B){d(L=>new Set(L).add(H));try{const{error:L}=await be.from("summaries").delete().eq("document_id",H).eq("user_id",c==null?void 0:c.id);if(L)throw L;const{error:F}=await be.from("documents").delete().eq("id",H).eq("user_id",c==null?void 0:c.id);if(F)throw F;try{B.storage_path&&await be.storage.from("documents").remove([B.storage_path])}catch(V){console.warn("Could not delete file from storage:",V)}We.success("Document deleted successfully"),r()}catch(L){console.error("Delete error:",L),We.error("Error deleting. Please try again.")}finally{d(L=>{const F=new Set(L);return F.delete(H),F})}}},A=async(H,B)=>{try{await navigator.clipboard.writeText(H),m(L=>new Set(L).add(B)),We.success("Citation copied to clipboard"),setTimeout(()=>{m(L=>{const F=new Set(L);return F.delete(B),F})},2e3)}catch{We.error("Error copying to clipboard")}},M=(H,B)=>{x(L=>new Set(L).add(H)),v(B)},z=async H=>{try{const{error:B}=await be.from("documents").update({citation_apa:y}).eq("id",H).eq("user_id",c==null?void 0:c.id);if(B)throw B;We.success("Citation updated successfully"),r(),x(L=>{const F=new Set(L);return F.delete(H),F})}catch(B){console.error("Save citation error:",B),We.error("Error saving citation")}},P=H=>{x(B=>{const L=new Set(B);return L.delete(H),L}),v("")},W=H=>h[H.id]||null,N=H=>e[H]||!1?l.jsx(kt,{className:"bg-green-100 text-green-800 hover:bg-green-200",children:"Completed"}):l.jsx(kt,{variant:"secondary",children:"open"}),U=H=>new Date(H).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),K=Math.ceil(i/s),G=(n-1)*s+1,X=Math.min(n*s,i);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{children:"Name"}),l.jsx(Et,{children:"Pages"}),l.jsx(Et,{children:"ISBN/DOI"}),l.jsx(Et,{children:"Index Status"}),l.jsx(Et,{children:"Date"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:t.map(H=>{const B=u.has(H.id),L=p.has(H.id),F=g.has(H.id);return l.jsxs(Zn,{children:[l.jsx(At,{children:l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:l.jsx(Br,{className:"w-4 h-4 text-primary"})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-medium text-sm",children:H.original_filename||H.title}),(()=>{const V=E(H),Y=H.original_filename||H.title||"";if(V&&V!==Y){const ie=V.length>70?V.substring(0,70)+"...":V;return l.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[l.jsx(XG,{className:"w-3 h-3"}),ie]})}return null})()]})]})}),l.jsxs(At,{className:"text-muted-foreground",children:[H.page_count||"?"," Pages"]}),l.jsx(At,{className:"text-muted-foreground",children:H.isbn?`ISBN: ${H.isbn}`:H.doi?`DOI: ${H.doi}`:"–"}),l.jsx(At,{children:N(H.id)}),l.jsx(At,{className:"text-muted-foreground",children:U(H.created_at)}),l.jsx(At,{className:"text-right",children:l.jsx(Zs,{children:l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",onClick:()=>{W(H)?(k(H),w(!0)):We.error("PDF URL not available")},children:l.jsx(Xa,{className:"w-4 h-4"})})}),l.jsx(Qt,{children:l.jsx("p",{children:"View PDF"})})]}),l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx("a",{href:W(H)||"#",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center w-8 h-8 p-0 rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground",onClick:V=>{W(H)||(V.preventDefault(),We.error("PDF URL not available"))},children:l.jsx($p,{className:"w-4 h-4"})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Open in New Tab"})})]}),l.jsxs(Gr,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bc,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",disabled:!H.citation_apa,children:l.jsx(Ah,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:H.citation_apa?"View APA Citation":"No citation available"})})]}),l.jsxs(zr,{className:"max-w-lg",children:[l.jsxs(Ur,{children:[l.jsxs(Hr,{className:"flex items-center gap-2",children:[l.jsx(XG,{className:"w-5 h-5"}),"Book Information"]}),l.jsx(wx,{children:"Automatically detected data for this document"})]}),H.bib_meta&&(()=>{var xe,oe,de,ge,Se,ke,Ne,qe,Ae,fe,Te,Pe,tt;const V=H.bib_meta,Y=V==null?void 0:V.google_books_data,ie=V==null?void 0:V.crossref_payload,Q=V==null?void 0:V.crossref_data,D=ie||Q,R=(V==null?void 0:V.method)==="manual_entry"||(V==null?void 0:V.method)==="parsed_paste",J=((xe=D==null?void 0:D.author)==null?void 0:xe.map(wt=>`${wt.given||""} ${wt.family||""}`.trim()).join(", "))||((oe=Q==null?void 0:Q.authors)==null?void 0:oe.join(", ")),Z=((Se=(ge=(de=D==null?void 0:D.issued)==null?void 0:de["date-parts"])==null?void 0:ge[0])==null?void 0:Se.join("-"))||((qe=(Ne=(ke=D==null?void 0:D.published)==null?void 0:ke["date-parts"])==null?void 0:Ne[0])==null?void 0:qe.join("-"))||(Q==null?void 0:Q.year),ee=Array.isArray(D==null?void 0:D.title)?D.title[0]:D==null?void 0:D.title,re=Array.isArray(D==null?void 0:D["container-title"])?D["container-title"][0]:(D==null?void 0:D["container-title"])||(Q==null?void 0:Q.journal),he=(D==null?void 0:D.page)||(Q==null?void 0:Q.pages),O=((Ae=D==null?void 0:D.ISBN)==null?void 0:Ae[0])||((Te=(fe=Q==null?void 0:Q.crossref_metadata)==null?void 0:fe.ISBN)==null?void 0:Te[0]),ae=(D==null?void 0:D.type)||((Pe=Q==null?void 0:Q.crossref_metadata)==null?void 0:Pe.type),q=R?V.title:(Y==null?void 0:Y.title)||ee,I=R?Array.isArray(V.authors)?V.authors.join(", "):V.authors:((tt=Y==null?void 0:Y.authors)==null?void 0:tt.join(", "))||J,T=R?V.publisher:(Y==null?void 0:Y.publisher)||(D==null?void 0:D.publisher),$=R?V.published_year:(Y==null?void 0:Y.publishedDate)||Z,se=R?V.pages:he||(Y==null?void 0:Y.pageCount),ue=R?V.edition:null,ne=R?V.language:null,me=R?V.series:null,ve=R?V.type:ae;return l.jsxs("div",{className:"space-y-2 p-4 bg-muted/50 rounded-lg border",children:[q&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Title:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:q})]}),ve&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Type:"}),l.jsx("span",{className:"text-sm font-medium text-right capitalize",children:String(ve).replace("-"," ")})]}),I&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Author(s):"}),l.jsx("span",{className:"text-sm font-medium text-right",children:I})]}),re&&!R&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Journal:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:re})]}),T&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Publisher:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:T})]}),$&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Published:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:$})]}),ue&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Edition:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:ue})]}),((D==null?void 0:D.volume)||(D==null?void 0:D.issue))&&!R&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Volume/Issue:"}),l.jsxs("span",{className:"text-sm font-medium text-right",children:[(D==null?void 0:D.volume)&&`Vol. ${D.volume}`,(D==null?void 0:D.volume)&&(D==null?void 0:D.issue)&&", ",(D==null?void 0:D.issue)&&`Issue ${D.issue}`]})]}),se&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Pages:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:se})]}),ne&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Language:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:ne})]}),me&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Series:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:me})]}),(O||(Y==null?void 0:Y.isbn)||H.isbn)&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"ISBN:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:O||(Y==null?void 0:Y.isbn)||H.isbn})]}),(H.doi||(D==null?void 0:D.DOI)||(D==null?void 0:D.doi))&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"DOI:"}),l.jsx("a",{href:`https://doi.org/${(H.doi||(D==null?void 0:D.DOI)||(D==null?void 0:D.doi)).replace("https://doi.org/","")}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-primary hover:underline text-right break-all",children:(H.doi||(D==null?void 0:D.DOI)||(D==null?void 0:D.doi)).replace("https://doi.org/","")})]}),(D==null?void 0:D.ISSN)&&!R&&l.jsxs("div",{className:"flex justify-between gap-4",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"ISSN:"}),l.jsx("span",{className:"text-sm font-medium text-right",children:Array.isArray(D.ISSN)?D.ISSN[0]:D.ISSN})]}),(V==null?void 0:V.method)&&l.jsxs("div",{className:"flex justify-between gap-4 pt-2 border-t border-border/50 mt-2",children:[l.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Source:"}),l.jsx(kt,{variant:"secondary",className:"text-xs",children:V.method==="manual_entry"?"Manual Entry":V.method==="parsed_paste"?"Parsed Paste":V.method==="crossref"?"CrossRef":V.method==="google_books"?"Google Books":V.method})]})]})})(),!H.bib_meta&&l.jsx("div",{className:"p-4 bg-muted/50 rounded-lg border text-center text-sm text-muted-foreground",children:'No metadata available. Click "Detect APA" to fetch data.'}),l.jsx(fjt,{documentId:H.id}),l.jsx(vi,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"text-sm font-semibold",children:"APA-7 Citation"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically detected citation for this document"})]}),F?l.jsxs("div",{className:"space-y-3",children:[l.jsx(ir,{value:y,onChange:V=>v(V.target.value),className:"min-h-[100px] text-sm",placeholder:"Edit APA citation..."}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(ye,{onClick:()=>z(H.id),size:"sm",className:"flex items-center gap-2",children:[l.jsx(j$,{className:"w-4 h-4"}),"Save"]}),l.jsxs(ye,{onClick:()=>P(H.id),size:"sm",variant:"outline",className:"flex items-center gap-2",children:[l.jsx(Is,{className:"w-4 h-4"}),"Cancel"]})]})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"p-4 bg-muted rounded-lg",children:l.jsx("p",{className:"text-sm leading-relaxed",children:H.citation_apa||"No citation available"})}),H.citation_apa&&l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ye,{onClick:()=>A(H.citation_apa,H.id),variant:L?"default":"outline",className:"flex items-center gap-2",children:L?"Copied!":"Copy"}),l.jsxs(ye,{onClick:()=>M(H.id,H.citation_apa),variant:"outline",className:"flex items-center gap-2",children:[l.jsx(OH,{className:"w-4 h-4"}),"Edit"]})]})]})]})]})]}),l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",onClick:()=>o(`/reference-checker?document=${H.id}`),children:l.jsx(_c,{className:"w-4 h-4"})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Check with Reference Checker"})})]}),l.jsxs(va,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:B,children:B?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):l.jsx(xi,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Delete"})})]}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Document"}),l.jsxs(Gi,{children:['Are you sure you want to delete "',H.original_filename||H.title,'"? This action cannot be undone.']})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>C(H.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},H.id)})})]}),K>1&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[G,"-",X," of ",i," Documents"]}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>a(n-1),disabled:n===1,children:"Back"}),l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>a(n+1),disabled:n===K,children:"Next"})]})]}),l.jsx(hjt,{open:b,onOpenChange:w,pdfUrl:S&&h[S.id]||"",title:(S==null?void 0:S.title)||(S==null?void 0:S.original_filename)||"PDF Document"})]})}function are(t){return!t||!t.length?"- –":t.map(e=>`- ${e}`).join(`
`)}function ore(t){if(!t)return"";const e=t.intro?`${t.intro}
`:"",r=(t.questions??[]).map((n,s)=>{const i=(n.probes??[]).map(o=>` - ${o}`).join(`
`),a=n.maps_to_rq?` *(zu ${n.maps_to_rq})*`:"";return`${s+1}. **${n.question}**${a}
${i?`
${i}
`:""}`}).join(`
`);return`${e}${r}`}function mjt(t){const e=(t==null?void 0:t.meta)??{},r=(t==null?void 0:t.participant_interview)??{},n=(t==null?void 0:t.expert_interview)??{},s=(t==null?void 0:t.notes)??{},i=e.title||"Research Setup",a=(e.derived_research_questions??[]).map(o=>`- ${o}`).join(`
`);return[`# ${i}`,"",`**Objective:** ${e.aim??"–"}`,`**Degree:** ${e.degree??"–"} | **Discipline:** ${e.discipline??"–"} | **Language:** ${e.language??"–"}`,"","## Research Questions",a||"- –","","## Guidelines: Participant Interviews",ore(r)||"- –","","## Guidelines: Expert Interviews",ore(n)||"- –","","## Sampling & Criteria",`**Sampling-Strategy**
${s.sampling??"–"}`,"",`**Inclusion Criteria**
${are(s.inclusion)}`,"",`**Exclusion Criteria**
${are(s.exclusion)}`,"","## Ethics",s.ethics??"–","","## Piloting",s.pilot??"–"].join(`
`)}function gjt(t){let e=`# ${t.title}
`;return e+=`${t.content}
`,t.literature&&t.literature.length>0&&(e+=`## Literaturverzeichnis
`,t.literature.forEach(r=>{e+=`- ${r}
`}),e+=`
`),t.proof_of_material&&t.proof_of_material.length>0&&(e+=`## Quellennachweis
`,t.proof_of_material.forEach((r,n)=>{e+=`**[${n+1}] ${r.citation}**
`,e+=`> ${r.original_text}
`,r.page_number&&(e+=`*Seite ${r.page_number}*`),r.document_title&&(e+=` - ${r.document_title}`),e+=`
`})),e.trim()}function kO(t,e){var r,n,s,i,a;if(e==="research_setup")try{if(t.trim().startsWith("#"))return t;const o=JSON.parse(t);return mjt(o)}catch(o){return console.error("Failed to parse research setup data:",o),t||"Error displaying research setup data"}if(e==="topic_explorer")try{if(t.trim().startsWith("#"))return t;const o=JSON.parse(t);let c=`# ${o.title}
`;return o.introduction&&(c+=`## Introduction
${o.introduction}
`),o.problem&&(c+=`## Problem Statement
${o.problem}
`),o.objectives&&(c+=`## Objectives
${o.objectives}
`),(n=(r=o.original_selection)==null?void 0:r.researchQuestions)!=null&&n.length&&(c+=`## Research Questions?
`,o.original_selection.researchQuestions.forEach((u,d)=>{c+=`${d+1}. ${u}
`}),c+=`
`),(s=o.original_selection)!=null&&s.method&&(c+=`## Methodology
${o.original_selection.method}
`),(a=(i=o.original_selection)==null?void 0:i.sources)!=null&&a.length&&(c+=`## Literature Recommendations
`,o.original_selection.sources.forEach((u,d)=>{c+=`${d+1}. ${u.title}`,u.doi&&(c+=` (DOI: ${u.doi})`),u.isbn&&(c+=` (ISBN: ${u.isbn})`),c+=`
`}),c+=`
`),c.trim()}catch(o){return console.error("Failed to parse topic explorer data:",o),t||"Error displaying topic explorer data"}if(e==="thesis_builder"||e==="theory"||e==="paragraph"||e==="outline")try{if(t.trim().startsWith("#"))return t;const o=JSON.parse(t);return gjt(o)}catch(o){return console.warn("Could not parse thesis builder data:",o),t||"No content available"}return t||"No text available"}function lre(t){var e,r,n,s,i;if(t.summary_mode==="research_setup")try{return(e=t.summary_text)!=null&&e.trim().startsWith("#")?t.summary_text.split(`
`)[0].replace(/^#+\s*/,""):((r=JSON.parse(t.summary_text||"{}").meta)==null?void 0:r.title)||"Research Setup"}catch{return"Research Setup"}if(t.summary_mode==="topic_explorer")try{return(n=t.summary_text)!=null&&n.trim().startsWith("#")?t.summary_text.split(`
`)[0].replace(/^#+\s*/,""):(JSON.parse(t.summary_text||"{}").title||"Topic Explorer Struktur").replace(/^#+\s*/,"")}catch{return"Topic Explorer Struktur"}return((s=t.documents)==null?void 0:s.original_filename)||((i=t.documents)==null?void 0:i.title)||"Unbekanntes Dokument"}function cre(t){return t==="research_setup"?"Research Setup":t==="topic_explorer"?"Topic Explorer":{small:"Kurz",medium:"Mittel",large:"Lang",detailed:"Detailliert",big:"Ausführlich",deep15:"Detailliert"}[t||""]||t||""}function yjt({summaries:t,onSummaryDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){const{userProfile:a}=Dt(),[o,c]=j.useState(new Set),[u,d]=j.useState({});j.useEffect(()=>{IR(t,"summaries").then(d)},[t]);const h=async v=>{c(b=>new Set(b).add(v));try{const{error:b}=await be.from("summaries").delete().eq("id",v).eq("user_id",a==null?void 0:a.id);if(b)throw b;We.success("Summary deleted successfully"),e()}catch(b){console.error("Delete error:",b),We.error("Error deleting. Please try again.")}finally{c(b=>{const w=new Set(b);return w.delete(v),w})}},f=async v=>{try{await navigator.clipboard.writeText(v),We.success("Copied to clipboard")}catch{We.error("Error copying")}},p=v=>new Date(v).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),m=v=>u[v.id]||null,g=Math.ceil(s/n),x=(r-1)*n+1,y=Math.min(r*n,s);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{children:"Name"}),l.jsx(Et,{children:"Mode"}),l.jsx(Et,{children:"Date"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:t.map(v=>{const b=o.has(v.id),w=m(v);return l.jsxs(Zn,{children:[l.jsx(At,{children:l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:l.jsx(Br,{className:"w-4 h-4 text-primary"})}),l.jsx("div",{children:l.jsx("p",{className:"font-medium text-sm",children:lre(v)})})]})}),l.jsx(At,{children:l.jsx(kt,{variant:"outline",children:cre(v.summary_mode||"")})}),l.jsx(At,{className:"text-muted-foreground",children:p(v.created_at)}),l.jsx(At,{className:"text-right",children:l.jsx(Zs,{children:l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsxs(Gr,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bc,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:l.jsx(Xa,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"View Text"})})]}),l.jsxs(zr,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Summary"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[l.jsx("h3",{className:"font-semibold mb-2",children:lre(v)}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Mode: ",cre(v.summary_mode||"")," | Created: ",p(v.created_at)]})]}),l.jsx("div",{className:"prose max-w-none",children:l.jsx("div",{className:"whitespace-pre-wrap",children:kO(v.summary_text||"",v.summary_mode||"")})}),l.jsx("div",{className:"flex justify-end",children:l.jsxs(ye,{onClick:()=>f(kO(v.summary_text||"",v.summary_mode||"")),className:"flex items-center space-x-2",children:[l.jsx(Tn,{className:"w-4 h-4"}),l.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),w&&l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",onClick:()=>window.open(w,"_blank"),children:l.jsx($p,{className:"w-4 h-4"})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Open PDF"})})]}),l.jsxs(va,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:b,children:b?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):l.jsx(xi,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Delete"})})]}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Summary"}),l.jsx(Gi,{children:"Are you sure you want to delete this summary? This action cannot be undone."})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>h(v.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},v.id)})})]}),g>1&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[x,"-",y," of ",s," Summaries"]}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===g,children:"Next"})]})]})]})}function xjt({methods:t,onMethodDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){const{userProfile:a}=Dt(),[o,c]=j.useState(new Set),[u,d]=j.useState({});j.useEffect(()=>{IR(t,"summaries").then(d)},[t]);const h=async w=>{c(S=>new Set(S).add(w));try{const{error:S}=await be.from("methods").delete().eq("id",w).eq("user_id",a==null?void 0:a.id);if(S)throw S;We.success("Methodology deleted successfully"),e()}catch(S){console.error("Delete error:",S),We.error("Error deleting. Please try again.")}finally{c(S=>{const k=new Set(S);return k.delete(w),k})}},f=async w=>{try{await navigator.clipboard.writeText(w),We.success("Copied to clipboard")}catch{We.error("Error copying")}},p=w=>new Date(w).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),m=w=>u[w.id]||null,g=w=>{var S,k;return((S=w.documents)==null?void 0:S.title)||((k=w.documents)==null?void 0:k.original_filename)||w.title||"Unknown Document"},x=w=>{switch(w){case"small":return"Short";case"medium":return"Medium";case"big":return"Long";default:return"Methods"}},y=Math.ceil(s/n),v=(r-1)*n+1,b=Math.min(r*n,s);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{children:"Title"}),l.jsx(Et,{children:"Document Sources"}),l.jsx(Et,{children:"Mode"}),l.jsx(Et,{children:"Date"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:t.map(w=>{var E,C,A;const S=o.has(w.id),k=m(w);return l.jsxs(Zn,{children:[l.jsx(At,{children:l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:l.jsx(Br,{className:"w-4 h-4 text-primary"})}),l.jsx("div",{children:l.jsx("p",{className:"font-medium text-sm",children:((C=(E=w.method_text)==null?void 0:E.split(`
`)[0])==null?void 0:C.trim())||w.title||"Methods & Approach"})})]})}),l.jsx(At,{className:"text-muted-foreground",children:l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-sm font-medium",children:g(w)}),l.jsxs("span",{className:"text-xs",children:[((A=w.documents)==null?void 0:A.page_count)||"?"," Pages"]})]})}),l.jsx(At,{children:l.jsx(kt,{variant:"outline",children:x(w.mode||"")})}),l.jsx(At,{className:"text-muted-foreground",children:p(w.created_at)}),l.jsx(At,{className:"text-right",children:l.jsx(Zs,{children:l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsxs(Gr,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bc,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:l.jsx(Xa,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"View Text"})})]}),l.jsxs(zr,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Methodology"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[l.jsx("h3",{className:"font-semibold mb-2",children:w.title||"Methods & Approach"}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Document: ",g(w)," | Mode: ",x(w.mode||"")," | Created: ",p(w.created_at)]})]}),l.jsx("div",{className:"prose max-w-none",children:l.jsx("div",{className:"whitespace-pre-wrap",children:w.method_text||""})}),l.jsx("div",{className:"flex justify-end",children:l.jsxs(ye,{onClick:()=>f(w.method_text||""),className:"flex items-center space-x-2",children:[l.jsx(Tn,{className:"w-4 h-4"}),l.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),k&&l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",onClick:()=>window.open(k,"_blank"),children:l.jsx($p,{className:"w-4 h-4"})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Open PDF"})})]}),l.jsxs(va,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:S,children:S?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):l.jsx(xi,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Delete"})})]}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Methodology"}),l.jsx(Gi,{children:"Are you sure you want to delete this methodology? This action cannot be undone."})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>h(w.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},w.id)})})]}),y>1&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[v,"-",b," of ",s," Methodology Entries"]}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===y,children:"Next"})]})]})]})}const vjt=({theories:t,onTheoryDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i})=>{const{userProfile:a}=Dt(),[o,c]=j.useState(new Set),[u,d]=j.useState({});j.useEffect(()=>{IR(t,"summaries").then(d)},[t]);const h=async w=>{c(S=>new Set(S).add(w));try{const{error:S}=await be.from("theory_backgrounds").delete().eq("id",w).eq("user_id",a==null?void 0:a.id);if(S)throw S;We.success("Theory/Background deleted successfully"),e()}catch(S){console.error("Delete error:",S),We.error("Error deleting. Please try again.")}finally{c(S=>{const k=new Set(S);return k.delete(w),k})}},f=async w=>{try{await navigator.clipboard.writeText(w),We.success("Copied to clipboard")}catch{We.error("Error copying")}},p=w=>new Date(w).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),m=w=>u[w.id]||null,g=w=>{var S,k;return((S=w.documents)==null?void 0:S.title)||((k=w.documents)==null?void 0:k.original_filename)||"Unknown Document"},x=w=>{if(!w||w==="theory")return"Theory & Background";switch(w){case"paragraph":return"Paragraph";case"outline":return"Outline";default:return w}},y=Math.ceil(s/n),v=(r-1)*n+1,b=Math.min(r*n,s);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{children:"Name"}),l.jsx(Et,{children:"Document Sources"}),l.jsx(Et,{children:"Mode"}),l.jsx(Et,{children:"Date"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:t.map(w=>{var E,C,A;const S=o.has(w.id),k=m(w);return l.jsxs(Zn,{children:[l.jsx(At,{children:l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:l.jsx(Br,{className:"w-4 h-4 text-primary"})}),l.jsx("div",{children:l.jsx("p",{className:"font-medium text-sm",children:((C=(E=w.theory_text)==null?void 0:E.split(`
`)[0])==null?void 0:C.trim())||w.title||"Theory & Background"})})]})}),l.jsx(At,{className:"text-muted-foreground",children:l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-sm font-medium",children:g(w)}),l.jsxs("span",{className:"text-xs",children:[((A=w.documents)==null?void 0:A.page_count)||"?"," Pages"]})]})}),l.jsx(At,{children:l.jsx(kt,{variant:"outline",children:x(w.mode)})}),l.jsx(At,{className:"text-muted-foreground",children:p(w.created_at)}),l.jsx(At,{className:"text-right",children:l.jsx(Zs,{children:l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsxs(Gr,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bc,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:l.jsx(Xa,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"View Text"})})]}),l.jsxs(zr,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Theory & Background"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[l.jsx("h3",{className:"font-semibold mb-2",children:w.title||"Theory & Background"}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Document: ",g(w)," | Mode: ",x(w.mode)," | Created: ",p(w.created_at)]})]}),l.jsx("div",{className:"prose max-w-none",children:l.jsx("div",{className:"whitespace-pre-wrap",children:kO(w.theory_text||"",w.mode||"theory")})}),l.jsx("div",{className:"flex justify-end",children:l.jsxs(ye,{onClick:()=>f(w.theory_text||""),className:"flex items-center space-x-2",children:[l.jsx(Tn,{className:"w-4 h-4"}),l.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),k&&l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",onClick:()=>window.open(k,"_blank"),children:l.jsx($p,{className:"w-4 h-4"})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Open PDF"})})]}),l.jsxs(va,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:S,children:S?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):l.jsx(xi,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Delete"})})]}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Theory/Background"}),l.jsx(Gi,{children:"Are you sure you want to delete this Theory/Background? This action cannot be undone."})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>h(w.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},w.id)})})]}),y>1&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[v,"-",b," of ",s," Theory & Background"]}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===y,children:"Next"})]})]})]})},bjt=({analyses:t,onAnalysisDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i})=>{const{userProfile:a}=Dt(),[o,c]=j.useState(new Set),u=async y=>{c(v=>new Set(v).add(y));try{const{error:v}=await be.from("analysis_results").delete().eq("id",y).eq("user_id",a==null?void 0:a.id);if(v)throw v;We.success("Analysis deleted successfully"),e()}catch(v){console.error("Delete error:",v),We.error("Error deleting. Please try again.")}finally{c(v=>{const b=new Set(v);return b.delete(y),b})}},d=y=>new Date(y).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),h=y=>{switch(y){case"small":return"Short";case"medium":return"Medium";case"big":return"Long";default:return y||"–"}},f=y=>{var v;return((v=y.categories)==null?void 0:v.category_title)||"No Category"},p=y=>{var v;return((v=y.codebooks)==null?void 0:v.title)||"No Codebook"},m=Math.ceil(s/n),g=(r-1)*n+1,x=Math.min(r*n,s);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{children:"Name"}),l.jsx(Et,{children:"Codebook"}),l.jsx(Et,{children:"Mode"}),l.jsx(Et,{children:"Date"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:t.map(y=>{var b;const v=o.has(y.id);return l.jsxs(Zn,{children:[l.jsx(At,{children:l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:l.jsx(Br,{className:"w-4 h-4 text-primary"})}),l.jsx("div",{children:l.jsx("p",{className:"font-medium text-sm",children:f(y)})})]})}),l.jsx(At,{className:"text-muted-foreground text-sm",children:p(y)}),l.jsx(At,{children:l.jsx(kt,{variant:"outline",children:h(y.mode)})}),l.jsx(At,{className:"text-muted-foreground",children:d(y.created_at)}),l.jsx(At,{className:"text-right",children:l.jsx(Zs,{children:l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsxs(Gr,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bc,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:l.jsx(Xa,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"View Analysis"})})]}),l.jsxs(zr,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Qualitative Analysis"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[l.jsx("h3",{className:"font-semibold mb-2",children:f(y)}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Codebook: ",p(y)," | Mode: ",h(y.mode)," | Created: ",d(y.created_at)]})]}),l.jsx("div",{className:"prose max-w-none",children:l.jsx("div",{className:"whitespace-pre-wrap",children:y.result_text||"No content available"})}),((b=y.categories)==null?void 0:b.category_conclusion)&&l.jsxs(l.Fragment,{children:[l.jsx("hr",{className:"my-6 border-border"}),l.jsxs("div",{className:"prose max-w-none",children:[l.jsxs("p",{className:"font-bold underline mb-2",children:["Fazit Kategorie: ",y.categories.category_title]}),l.jsx("p",{className:"whitespace-pre-wrap",children:y.categories.category_conclusion})]})]})]})]})]}),l.jsxs(va,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:v,children:v?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):l.jsx(xi,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Delete"})})]}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Analysis"}),l.jsx(Gi,{children:"Are you sure you want to delete this analysis? This action cannot be undone."})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>u(y.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},y.id)})})]}),m>1&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[g,"-",x," of ",s," Analyses"]}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===m,children:"Next"})]})]})]})};function wjt({topics:t,onTopicDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){Dt();const[a,o]=j.useState(new Set),c=async m=>{o(g=>new Set(g).add(m));try{const{error:g}=await be.from("topic_explorations").delete().eq("id",m);if(g)throw g;We.success("Topic exploration deleted successfully"),e()}catch(g){console.error("Delete error:",g),We.error("Error deleting. Please try again.")}finally{o(g=>{const x=new Set(g);return x.delete(m),x})}},u=async m=>{var x,y,v,b,w,S,k,E;let g=`# ${m.title}
`;m.introduction&&(g+=`## Introduction
${m.introduction}
`),m.problem_statement&&(g+=`## Problem Statement
${m.problem_statement}
`),m.objectives&&(g+=`## Objectives
${m.objectives}
`),Array.isArray(m.research_questions)&&m.research_questions.length>0&&(g+=`## Research Questions
${m.research_questions.join(`
`)}
`),m.method&&(g+=`## Methodology
${m.method}
`),(x=m.outline_json)!=null&&x.chapters&&(g+=`## Outline
`,m.outline_json.chapters.forEach(C=>{g+=`${C.number}. ${C.title}
`,C.subchapters&&C.subchapters.forEach(A=>{g+=` ${A.number} ${A.title}
`})}),g+=`
`),(y=m.keywords_json)!=null&&y.primary_keywords&&(g+=`## Primary Keywords
${m.keywords_json.primary_keywords.join(", ")}
`),(v=m.keywords_json)!=null&&v.german_equivalents&&(g+=`## German Keywords
${m.keywords_json.german_equivalents.join(", ")}
`),(b=m.keywords_json)!=null&&b.english_equivalents&&(g+=`## English Keywords
${m.keywords_json.english_equivalents.join(", ")}
`),(w=m.keywords_json)!=null&&w.keyword_combinations&&(g+=`## Search Combinations
`,m.keywords_json.keyword_combinations.forEach(C=>{g+=`- ${C.combination} (${C.purpose})
`}),g+=`
`),(S=m.keywords_json)!=null&&S.database_suggestions&&(g+=`## Recommended Databases
${m.keywords_json.database_suggestions.join(", ")}
`),(k=m.keywords_json)!=null&&k.known_authors&&(g+=`## Known Authors
`,m.keywords_json.known_authors.forEach(C=>{g+=`- ${C.name}: ${C.relevance}
`}),g+=`
`),(E=m.keywords_json)!=null&&E.known_works&&(g+=`## Known Works
`,m.keywords_json.known_works.forEach(C=>{g+=`- ${C.title} (${C.author}${C.year?`, ${C.year}`:""})
`}),g+=`
`);try{await navigator.clipboard.writeText(g.trim()),We.success("Copied to clipboard")}catch{We.error("Error copying")}},d=m=>new Date(m).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),h=Math.ceil(s/n),f=(r-1)*n+1,p=Math.min(r*n,s);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{children:"Name"}),l.jsx(Et,{children:"Source"}),l.jsx(Et,{children:"Language"}),l.jsx(Et,{children:"Date"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:t.map(m=>{var x,y,v,b,w,S,k,E,C,A;const g=a.has(m.id);return l.jsxs(Zn,{children:[l.jsx(At,{children:l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:l.jsx(rm,{className:"w-4 h-4 text-primary"})}),l.jsx("div",{children:l.jsx("p",{className:"font-medium text-sm",children:m.title||"Untitled Topic"})})]})}),l.jsx(At,{children:l.jsx(kt,{variant:"secondary",children:m.feature_type==="outline"?"Outline":m.feature_type==="keywords"?"Literature Keywords":"Topic Ideas"})}),l.jsx(At,{children:l.jsx(kt,{variant:"outline",children:m.language||"DE"})}),l.jsx(At,{className:"text-muted-foreground",children:d(m.created_at)}),l.jsx(At,{className:"text-right",children:l.jsx(Zs,{children:l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsxs(Gr,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bc,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:l.jsx(Xa,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"View"})})]}),l.jsxs(zr,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[l.jsx(Ur,{children:l.jsx(Hr,{children:m.title})}),l.jsxs("div",{className:"space-y-6",children:[m.feature_type&&l.jsx(kt,{variant:"secondary",className:"mb-2",children:m.feature_type==="outline"?"Thesis Outline":m.feature_type==="keywords"?"Literature Keywords":"Topic Ideas"}),m.introduction&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Introduction"}),l.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:m.introduction})]}),m.problem_statement&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Problem Statement"}),l.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:m.problem_statement})]}),m.objectives&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Objectives"}),l.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:m.objectives})]}),m.research_questions&&Array.isArray(m.research_questions)&&m.research_questions.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Research Questions"}),l.jsx("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground",children:m.research_questions.map((M,z)=>l.jsx("li",{children:M},z))})]}),m.method&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Methodology"}),l.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:m.method})]}),((x=m.outline_json)==null?void 0:x.chapters)&&m.outline_json.chapters.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Thesis Outline"}),m.outline_json.estimated_pages&&l.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Estimated pages: ",m.outline_json.estimated_pages]}),l.jsx("div",{className:"space-y-3",children:m.outline_json.chapters.map((M,z)=>l.jsxs("div",{className:"border rounded-lg p-3",children:[l.jsxs("span",{className:"font-medium",children:[M.number,". ",M.title]}),M.subchapters&&M.subchapters.length>0&&l.jsx("div",{className:"ml-4 mt-2 space-y-1 border-l-2 pl-3",children:M.subchapters.map((P,W)=>l.jsxs("div",{className:"text-sm text-muted-foreground",children:[P.number," ",P.title]},W))})]},z))}),m.outline_json.notes&&l.jsx("p",{className:"text-sm text-muted-foreground mt-3 italic",children:m.outline_json.notes})]}),((y=m.keywords_json)==null?void 0:y.primary_keywords)&&m.keywords_json.primary_keywords.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Primary Keywords"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.primary_keywords.map((M,z)=>l.jsx(kt,{variant:"secondary",children:M},z))})]}),((v=m.keywords_json)==null?void 0:v.german_equivalents)&&m.keywords_json.german_equivalents.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"German Keywords"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.german_equivalents.map((M,z)=>l.jsx(kt,{variant:"outline",children:M},z))})]}),((b=m.keywords_json)==null?void 0:b.english_equivalents)&&m.keywords_json.english_equivalents.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"English Keywords"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.english_equivalents.map((M,z)=>l.jsx(kt,{variant:"outline",children:M},z))})]}),((w=m.keywords_json)==null?void 0:w.alternative_terms)&&m.keywords_json.alternative_terms.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Alternative Terms"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.alternative_terms.map((M,z)=>l.jsx(kt,{variant:"outline",children:M},z))})]}),((S=m.keywords_json)==null?void 0:S.keyword_combinations)&&m.keywords_json.keyword_combinations.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Search Combinations"}),l.jsx("div",{className:"space-y-2",children:m.keywords_json.keyword_combinations.map((M,z)=>l.jsxs("div",{className:"border rounded p-2",children:[l.jsx("code",{className:"text-sm font-mono bg-muted px-1 rounded",children:M.combination}),l.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:M.purpose})]},z))})]}),((k=m.keywords_json)==null?void 0:k.database_suggestions)&&m.keywords_json.database_suggestions.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Recommended Databases"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.database_suggestions.map((M,z)=>l.jsx(kt,{variant:"outline",children:M},z))})]}),((E=m.keywords_json)==null?void 0:E.known_authors)&&m.keywords_json.known_authors.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Known Authors"}),l.jsx("div",{className:"space-y-2",children:m.keywords_json.known_authors.map((M,z)=>l.jsxs("div",{className:"text-sm",children:[l.jsx("span",{className:"font-medium",children:M.name}),l.jsxs("span",{className:"text-muted-foreground",children:[" - ",M.relevance]})]},z))})]}),((C=m.keywords_json)==null?void 0:C.known_works)&&m.keywords_json.known_works.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Known Works"}),l.jsx("div",{className:"space-y-2",children:m.keywords_json.known_works.map((M,z)=>l.jsxs("div",{className:"text-sm border rounded p-2",children:[l.jsx("span",{className:"font-medium",children:M.title}),M.year&&l.jsxs("span",{className:"text-muted-foreground",children:[" (",M.year,")"]}),l.jsx("p",{className:"text-xs text-muted-foreground",children:M.author}),l.jsx("p",{className:"text-xs text-muted-foreground italic mt-1",children:M.relevance})]},z))})]}),((A=m.keywords_json)==null?void 0:A.search_tips)&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Search Tips"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:m.keywords_json.search_tips})]}),m.known_sources_json&&Array.isArray(m.known_sources_json)&&m.known_sources_json.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Known Sources"}),l.jsx("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground",children:m.known_sources_json.map((M,z)=>l.jsx("li",{children:M.citation||M.title||JSON.stringify(M)},z))})]}),m.sources&&Array.isArray(m.sources)&&m.sources.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Sources"}),l.jsx("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground",children:m.sources.map((M,z)=>l.jsxs("li",{children:[M.title,M.doi&&l.jsxs("span",{className:"text-xs ml-2",children:["DOI: ",M.doi]}),M.isbn&&l.jsxs("span",{className:"text-xs ml-2",children:["ISBN: ",M.isbn]})]},z))})]}),l.jsx("div",{className:"flex justify-end",children:l.jsxs(ye,{onClick:()=>u(m),className:"flex items-center space-x-2",children:[l.jsx(Tn,{className:"w-4 h-4"}),l.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),l.jsxs(va,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:g,children:g?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):l.jsx(xi,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Delete"})})]}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Topic Exploration"}),l.jsx(Gi,{children:"Are you sure you want to delete this topic exploration? This action cannot be undone."})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>c(m.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},m.id)})})]}),h>1&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[f,"-",p," of ",s," Topics"]}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===h,children:"Next"})]})]})]})}function Sjt({setups:t,onSetupDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){Dt();const[a,o]=j.useState(new Set),c=async g=>{o(x=>new Set(x).add(g));try{const{error:x}=await be.from("research_setups").delete().eq("id",g);if(x)throw x;We.success("Research setup deleted successfully"),e()}catch(x){console.error("Delete error:",x),We.error("Error deleting. Please try again.")}finally{o(x=>{const y=new Set(x);return y.delete(g),y})}},u=async g=>{const x=g.markdown_text||g.title;try{await navigator.clipboard.writeText(x),We.success("Copied to clipboard")}catch{We.error("Error copying")}},d=g=>new Date(g).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),h=g=>{switch(g){case"bachelor":return"Bachelor";case"master":return"Master";default:return g||"N/A"}},f=Math.ceil(s/n),p=(r-1)*n+1,m=Math.min(r*n,s);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{children:"Name"}),l.jsx(Et,{children:"Language"}),l.jsx(Et,{children:"Discipline"}),l.jsx(Et,{children:"Date"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:t.map(g=>{var y;const x=a.has(g.id);return l.jsxs(Zn,{children:[l.jsx(At,{children:l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:l.jsx(u2e,{className:"w-4 h-4 text-primary"})}),l.jsx("div",{children:l.jsx("p",{className:"font-medium text-sm",children:g.title||"Untitled Setup"})})]})}),l.jsx(At,{children:l.jsx(kt,{variant:"outline",children:((y=g.language)==null?void 0:y.toUpperCase())||"N/A"})}),l.jsx(At,{className:"text-muted-foreground",children:g.discipline||"N/A"}),l.jsx(At,{className:"text-muted-foreground",children:d(g.created_at)}),l.jsx(At,{className:"text-right",children:l.jsx(Zs,{children:l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsxs(Gr,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bc,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:l.jsx(Xa,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"View"})})]}),l.jsxs(zr,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[l.jsx(Ur,{children:l.jsx(Hr,{children:g.title})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsx(kt,{variant:"secondary",children:h(g.degree)}),g.discipline&&l.jsx(kt,{variant:"outline",children:g.discipline}),g.language&&l.jsx(kt,{variant:"outline",children:g.language.toUpperCase()})]}),g.markdown_text?l.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:l.jsx(pc,{children:g.markdown_text})}):l.jsxs("div",{className:"space-y-4",children:[g.aim&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Research Aim"}),l.jsx("p",{className:"text-muted-foreground",children:g.aim})]}),g.derived_research_questions&&Array.isArray(g.derived_research_questions)&&l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold mb-2",children:"Research Questions"}),l.jsx("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground",children:g.derived_research_questions.map((v,b)=>l.jsx("li",{children:v},b))})]})]}),l.jsx("div",{className:"flex justify-end",children:l.jsxs(ye,{onClick:()=>u(g),className:"flex items-center space-x-2",children:[l.jsx(Tn,{className:"w-4 h-4"}),l.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),l.jsxs(va,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:x,children:x?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):l.jsx(xi,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Delete"})})]}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Research Setup"}),l.jsx(Gi,{children:"Are you sure you want to delete this research setup? This action cannot be undone."})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>c(g.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},g.id)})})]}),f>1&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[p,"-",m," of ",s," Setups"]}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===f,children:"Next"})]})]})]})}function _jt({discussions:t,onDiscussionDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){const{user:a}=Dt(),[o,c]=j.useState(new Set),u=async x=>{c(y=>new Set(y).add(x));try{const{error:y}=await be.from("results_discussions").delete().eq("id",x).eq("user_id",a==null?void 0:a.id);if(y)throw y;We.success("Discussion deleted successfully"),e()}catch(y){console.error("Delete error:",y),We.error("Error deleting. Please try again.")}finally{c(y=>{const v=new Set(y);return v.delete(x),v})}},d=async x=>{try{await navigator.clipboard.writeText(x),We.success("Copied to clipboard")}catch{We.error("Error copying")}},h=x=>new Date(x).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),f=x=>{switch(x){case"de":return"DE";case"en":return"EN";default:return(x==null?void 0:x.toUpperCase())||"N/A"}},p=Math.ceil(s/n),m=(r-1)*n+1,g=Math.min(r*n,s);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{children:"Name"}),l.jsx(Et,{children:"Language"}),l.jsx(Et,{children:"Date"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:t.map(x=>{const y=o.has(x.id);return l.jsxs(Zn,{children:[l.jsx(At,{children:l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:l.jsx(Gy,{className:"w-4 h-4 text-primary"})}),l.jsx("div",{children:l.jsx("p",{className:"font-medium text-sm",children:x.title||"Discussion"})})]})}),l.jsx(At,{children:l.jsx(kt,{variant:"outline",children:f(x.language)})}),l.jsx(At,{className:"text-muted-foreground",children:h(x.created_at)}),l.jsx(At,{className:"text-right",children:l.jsx(Zs,{children:l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsxs(Gr,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bc,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:l.jsx(Xa,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"View Text"})})]}),l.jsxs(zr,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Discussion"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[l.jsx("h3",{className:"font-semibold mb-2",children:x.title||"Discussion"}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Language: ",f(x.language)," | Created: ",h(x.created_at)]})]}),l.jsx("div",{className:"prose max-w-none",children:l.jsx(pc,{children:x.discussion_text||""})}),l.jsx("div",{className:"flex justify-end",children:l.jsxs(ye,{onClick:()=>d(x.discussion_text||""),className:"flex items-center space-x-2",children:[l.jsx(Tn,{className:"w-4 h-4"}),l.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),l.jsxs(va,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:y,children:y?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):l.jsx(xi,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Delete"})})]}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Discussion"}),l.jsx(Gi,{children:"Are you sure you want to delete this discussion? This action cannot be undone."})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>u(x.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},x.id)})})]}),p>1&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[m,"-",g," of ",s," Discussions"]}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===p,children:"Next"})]})]})]})}function jjt({codings:t,onCodingDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){const[a,o]=j.useState(new Set),c=async m=>{o(g=>new Set(g).add(m));try{const{error:g}=await be.from("coding_results").delete().eq("id",m);if(g)throw g;We.success("Coding deleted successfully"),e()}catch(g){console.error("Delete error:",g),We.error("Error deleting. Please try again.")}finally{o(g=>{const x=new Set(g);return x.delete(m),x})}},u=async m=>{const g=m.result_text||m.title||"";try{await navigator.clipboard.writeText(g),We.success("Copied to clipboard")}catch{We.error("Error copying")}},d=m=>new Date(m).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),h=Math.ceil(s/n),f=(r-1)*n+1,p=Math.min(r*n,s);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{children:"Name"}),l.jsx(Et,{children:"Interviews"}),l.jsx(Et,{children:"Date"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:t.map(m=>{var x,y,v;const g=a.has(m.id);return l.jsxs(Zn,{children:[l.jsx(At,{children:l.jsxs("div",{className:"flex items-center space-x-3",children:[l.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:l.jsx(d2e,{className:"w-4 h-4 text-primary"})}),l.jsx("p",{className:"font-medium text-sm",children:m.title||"Untitled Coding"})]})}),l.jsx(At,{className:"text-muted-foreground text-sm",children:((x=m.interviews)==null?void 0:x.title)||"–"}),l.jsx(At,{className:"text-muted-foreground",children:d(m.created_at)}),l.jsx(At,{className:"text-right",children:l.jsx(Zs,{children:l.jsxs("div",{className:"flex justify-end space-x-2",children:[l.jsxs(Gr,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bc,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:l.jsx(Xa,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"View"})})]}),l.jsxs(zr,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[l.jsx(Ur,{children:l.jsx(Hr,{children:m.title||"Coding Result"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[((y=m.codebooks)==null?void 0:y.title)&&l.jsx(kt,{variant:"secondary",children:m.codebooks.title}),((v=m.interviews)==null?void 0:v.title)&&l.jsx(kt,{variant:"outline",children:m.interviews.title}),m.language&&l.jsx(kt,{variant:"outline",children:m.language.toUpperCase()}),l.jsxs(kt,{variant:"outline",children:[m.created_segments??0," Segments"]})]}),m.result_text?l.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:l.jsx(pc,{children:m.result_text})}):l.jsx("p",{className:"text-muted-foreground",children:"No content available."}),l.jsx("div",{className:"flex justify-end",children:l.jsxs(ye,{onClick:()=>u(m),className:"flex items-center space-x-2",children:[l.jsx(Tn,{className:"w-4 h-4"}),l.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),l.jsxs(va,{children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:g,children:g?l.jsx(Di,{className:"w-4 h-4 animate-spin"}):l.jsx(xi,{className:"w-4 h-4"})})})}),l.jsx(Qt,{children:l.jsx("p",{children:"Delete"})})]}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Coding"}),l.jsx(Gi,{children:"Are you sure you want to delete this coding result? This action cannot be undone."})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>c(m.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},m.id)})})]}),h>1&&l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[f,"-",p," of ",s," Codings"]}),l.jsxs("div",{className:"flex space-x-2",children:[l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===h,children:"Next"})]})]})]})}function kjt({onDocumentUploaded:t}){const{userProfile:e}=Dt(),[r,n]=j.useState(!1),[s,i]=j.useState("idle"),[a,o]=j.useState(null),[c,u]=j.useState(!1),d=j.useRef(null);function h(S){return S.replace(/\.pdf$/i,"").replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/Ä/g,"Ae").replace(/Ö/g,"Oe").replace(/Ü/g,"Ue").replace(/ß/g,"ss").normalize("NFKD").replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-").toLowerCase().slice(0,90)}const f=S=>{if(S.type!=="application/pdf")return"Only PDF files are allowed.";const k=50*1024*1024;return S.size>k?"The file is too large. The maximum allowed size is 50MB.":S.size<1024?"The file is too small. At least 1KB is required.":null},p=j.useCallback(S=>{const k=f(S);if(k){We.error(k);return}o(S)},[]),m=j.useCallback(S=>{S.preventDefault(),S.stopPropagation()},[]),g=j.useCallback(S=>{S.preventDefault(),S.stopPropagation(),u(!0)},[]),x=j.useCallback(S=>{S.preventDefault(),S.stopPropagation(),u(!1)},[]),y=j.useCallback(S=>{S.preventDefault(),S.stopPropagation(),u(!1);const k=S.dataTransfer.files;k&&k[0]&&p(k[0])},[p]),v=S=>{var E;const k=(E=S.target.files)==null?void 0:E[0];k&&p(k)},b=()=>{o(null),d.current&&(d.current.value="")},w=async()=>{if(!(!a||!e||r)){n(!0),i("uploading");try{const S=a.name,k=h(S)||"dokument",E=`${Date.now()}-${k}.pdf`,C=`${e.id}/${E}`,{error:A}=await Qr.storage.from("documents").upload(C,a,{cacheControl:"3600",upsert:!1});if(A)throw A;const{data:M,error:z}=await Qr.from("documents").insert({user_id:e.id,title:k,original_filename:S,storage_path:C,page_count:null}).select().single();if(z)throw await Qr.storage.from("documents").remove([C]),z;i("extracting");const P=Qr.functions.invoke("ingest_document",{body:{document_id:M.id}}).catch(U=>console.error("ingest_document call failed",U)),W=Qr.functions.invoke("pdf_extract",{body:{document_id:M.id,overwrite:!0,also_block:!1}}).catch(U=>console.error("pdf_extract call failed",U)),N=Qr.functions.invoke("detect_bibliography",{body:{document_id:M.id}}).catch(U=>console.error("detect_bibliography call failed",U));await Promise.all([P,W,N]),We.success("PDF successfully uploaded and extracted!"),o(null),d.current&&(d.current.value=""),t()}catch(S){console.error("Upload error:",S),We.error("Error uploading. Please try again.")}finally{n(!1),i("idle")}}};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:`
relative border-2 border-dashed rounded-lg p-6 text-center
transition-all duration-200 h-[200px] flex flex-col items-center justify-center
${c?"border-primary bg-primary/5":a?"border-green-500 bg-green-50/50":"border-muted-foreground/25 hover:border-primary/50"}
${r?"pointer-events-none opacity-50":"cursor-pointer"}
`,onDragEnter:g,onDragLeave:x,onDragOver:m,onDrop:y,onClick:()=>{var S;return!a&&((S=d.current)==null?void 0:S.click())},children:[a?l.jsxs("div",{className:"space-y-3",children:[l.jsx(_c,{className:"w-8 h-8 text-green-600 mx-auto"}),l.jsxs("div",{className:"flex items-center justify-center gap-2",children:[l.jsx(y2e,{className:"w-4 h-4"}),l.jsx("span",{className:"text-sm font-medium truncate max-w-[200px]",children:a.name}),l.jsx("button",{onClick:S=>{S.stopPropagation(),b()},className:"p-1 hover:bg-red-100 rounded-full",children:l.jsx(Is,{className:"w-4 h-4 text-red-500"})})]}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(a.size/1024)," KB"]})]}):l.jsxs("div",{className:"space-y-3",children:[l.jsx(hh,{className:"w-8 h-8 text-muted-foreground mx-auto"}),l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium",children:"Drag PDF or click here"}),l.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Max 50MB, PDFs Only"})]})]}),l.jsx(Be,{ref:d,type:"file",accept:".pdf",onChange:v,className:"hidden"})]}),a&&l.jsx(ye,{onClick:w,disabled:r,className:"w-full",children:r?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),s==="extracting"?"Extract text...":"Uploading..."]}):l.jsxs(l.Fragment,{children:[l.jsx(hh,{className:"w-4 h-4 mr-2"}),"Upload PDF"]})})]})}const Njt=t=>t.title||t.original_filename||t.book_title||"",Ejt=t=>{var e,r;return((e=t.documents)==null?void 0:e.title)||((r=t.documents)==null?void 0:r.original_filename)||t.summary_mode||""},Ajt=t=>{var e,r,n,s;return((r=(e=t.method_text)==null?void 0:e.split(`
`)[0])==null?void 0:r.trim())||t.title||((n=t.documents)==null?void 0:n.title)||((s=t.documents)==null?void 0:s.original_filename)||""},Cjt=t=>{var e,r,n;return((r=(e=t.theory_text)==null?void 0:e.split(`
`)[0])==null?void 0:r.trim())||t.title||((n=t.documents)==null?void 0:n.title)||""},Tjt=t=>{var e;return((e=t.codebooks)==null?void 0:e.title)||""},Pjt=t=>t.title||"",Ojt=t=>t.title||"",Ijt=t=>t.title||"",Rjt=t=>t.title||"";function Vu(t,e,r,n){let s=t;if(e){const i=e.toLowerCase();s=t.filter(a=>n(a).toLowerCase().includes(i))}return[...s].sort((i,a)=>r==="alphabetical"?n(i).localeCompare(n(a)):new Date(a.created_at).getTime()-new Date(i.created_at).getTime())}const Mjt=()=>{const{user:t,loading:e}=Dt(),r=Or(),[n,s]=j.useState([]),[i,a]=j.useState(!0),[o,c]=j.useState([]),[u,d]=j.useState([]),[h,f]=j.useState([]),[p,m]=j.useState([]),[g,x]=j.useState([]),[y,v]=j.useState([]),[b,w]=j.useState([]),[S,k]=j.useState([]),[E,C]=j.useState({}),[A,M]=j.useState(""),[z,P]=j.useState("all"),[W,N]=j.useState("newest"),[U,K]=j.useState(1),[G,X]=j.useState(1),[H,B]=j.useState(1),[L,F]=j.useState(1),[V,Y]=j.useState(1),[ie,Q]=j.useState(1),[D,R]=j.useState(1),[J,Z]=j.useState(1),[ee,re]=j.useState(1),[he,O]=j.useState(0),[ae,q]=j.useState(0),[I,T]=j.useState(0),[$,se]=j.useState(0),[ue,ne]=j.useState(0),[me,ve]=j.useState(0),[xe,oe]=j.useState(0),[de,ge]=j.useState(0),[Se,ke]=j.useState(0),Ne=20;j.useEffect(()=>{!t&&!e&&r("/login")},[t,e,r]),j.useEffect(()=>{t&&qe()},[t,U,G,H,L,V,ie,D,J,ee]);const qe=async()=>{if(t){a(!0);try{const{count:Oe}=await be.from("v_documents_with_status").select("*",{count:"exact",head:!0}).eq("user_id",t.id);O(Oe||0);const{data:je,error:Re}=await be.from("v_documents_with_status").select("*").eq("user_id",t.id).order("created_at",{ascending:!1}).range((U-1)*Ne,U*Ne-1);if(Re){console.error("Error loading documents:",Re);return}s(je||[]);const{data:Ue,error:it}=await be.from("pages").select("document_id").in("document_id",(je||[]).map(aA=>aA.id));if(!it&&Ue){const aA={};je==null||je.forEach(kq=>{aA[kq.id]=Ue.some(ZNe=>ZNe.document_id===kq.id)}),C(aA)}const{count:Ce}=await be.from("summaries").select("*",{count:"exact",head:!0}).eq("user_id",t.id);q(Ce||0);const{data:$t,error:Kt}=await be.from("summaries").select("*, documents(title, page_count, original_filename)").eq("user_id",t.id).order("created_at",{ascending:!1}).range((G-1)*Ne,G*Ne-1);Kt||c($t||[]);const{count:On}=await be.from("methods").select("*",{count:"exact",head:!0}).eq("user_id",t.id);T(On||0);const{data:Ms,error:Do}=await be.from("methods").select("*, documents(title, page_count, original_filename)").eq("user_id",t.id).order("created_at",{ascending:!1}).range((H-1)*Ne,H*Ne-1);Do||d(Ms||[]);const{count:rs}=await be.from("theory_backgrounds").select("*",{count:"exact",head:!0}).eq("user_id",t.id);se(rs||0);const{data:Rr,error:pn}=await be.from("theory_backgrounds").select("*, documents(title, page_count, original_filename)").eq("user_id",t.id).order("created_at",{ascending:!1}).range((L-1)*Ne,L*Ne-1);pn||f(Rr||[]);const{count:lr}=await be.from("analysis_results").select("*",{count:"exact",head:!0}).eq("user_id",t.id);ne(lr||0);const{data:mn,error:ZE}=await be.from("analysis_results").select("*, codebooks(title)").eq("user_id",t.id).order("created_at",{ascending:!1}).range((V-1)*Ne,V*Ne-1);ZE||m(mn||[]);const{count:eA}=await be.from("topic_explorations").select("*",{count:"exact",head:!0}).eq("user_id",t.id);ve(eA||0);const{data:tA,error:rA}=await be.from("topic_explorations").select("*").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ie-1)*Ne,ie*Ne-1);rA||x(tA||[]);const{count:nA}=await be.from("research_setups").select("*",{count:"exact",head:!0}).eq("user_id",t.id);oe(nA||0);const{data:sA,error:iA}=await be.from("research_setups").select("*").eq("user_id",t.id).order("created_at",{ascending:!1}).range((D-1)*Ne,D*Ne-1);iA||v(sA||[]);const{count:Tc}=await be.from("results_discussions").select("*",{count:"exact",head:!0}).eq("user_id",t.id);ge(Tc||0);const{data:KNe,error:YNe}=await be.from("results_discussions").select("*").eq("user_id",t.id).order("created_at",{ascending:!1}).range((J-1)*Ne,J*Ne-1);YNe||w(KNe||[]);const{count:XNe}=await be.from("coding_results").select("*",{count:"exact",head:!0}).eq("user_id",t.id);ke(XNe||0);const{data:JNe,error:QNe}=await be.from("coding_results").select("*, codebooks(title), interviews(title)").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ee-1)*Ne,ee*Ne-1);QNe||k(JNe||[])}catch(Oe){console.error("Error in loadDocuments:",Oe)}finally{a(!1)}}},Ae=()=>{qe()},fe=j.useMemo(()=>Vu(n,A,W,Njt),[n,A,W]),Te=j.useMemo(()=>Vu(o,A,W,Ejt),[o,A,W]),Pe=j.useMemo(()=>Vu(u,A,W,Ajt),[u,A,W]),tt=j.useMemo(()=>Vu(h,A,W,Cjt),[h,A,W]),wt=j.useMemo(()=>Vu(p,A,W,Tjt),[p,A,W]),Ee=j.useMemo(()=>Vu(g,A,W,Pjt),[g,A,W]),nt=j.useMemo(()=>Vu(y,A,W,Ojt),[y,A,W]),rt=j.useMemo(()=>Vu(b,A,W,Ijt),[b,A,W]),Ze=j.useMemo(()=>Vu(S,A,W,Rjt),[S,A,W]),we=Oe=>z==="all"||z===Oe;return e||i?l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?l.jsx(gr,{showSidebar:!0,children:l.jsxs("div",{className:"space-y-8",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"My Library"}),l.jsx("p",{className:"text-muted-foreground",children:"Overview of all uploaded PDFs and generated content"})]}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(hh,{className:"h-5 w-5"}),"Upload PDF"]}),l.jsx(Un,{children:"Add new documents to your library"})]}),l.jsx(Ge,{children:l.jsx(kjt,{onDocumentUploaded:Ae})})]}),l.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(yl,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),l.jsx(Be,{placeholder:"Search by name...",value:A,onChange:Oe=>M(Oe.target.value),className:"pl-9"})]}),l.jsxs(dt,{value:z,onValueChange:P,children:[l.jsx(lt,{className:"w-full sm:w-[240px]",children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"all",children:"All types"}),l.jsxs(De,{value:"documents",children:["Documents (",he,")"]}),l.jsxs(De,{value:"summaries",children:["Summaries (",ae,")"]}),l.jsxs(De,{value:"methods",children:["Methods (",I,")"]}),l.jsxs(De,{value:"theories",children:["Theory & Background (",$,")"]}),l.jsxs(De,{value:"analyses",children:["Analysis (",ue,")"]}),l.jsxs(De,{value:"topics",children:["Topic Explorations (",me,")"]}),l.jsxs(De,{value:"setups",children:["Research Setups (",xe,")"]}),l.jsxs(De,{value:"discussions",children:["Discussions (",de,")"]}),l.jsxs(De,{value:"codings",children:["Codings (",Se,")"]})]})]}),l.jsxs(dt,{value:W,onValueChange:Oe=>N(Oe),children:[l.jsx(lt,{className:"w-full sm:w-[180px]",children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"newest",children:"Newest first"}),l.jsx(De,{value:"alphabetical",children:"A → Z"})]})]})]}),we("documents")&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"My Documents"})}),l.jsx(Ge,{children:fe.length===0?l.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No documents found"}):l.jsx(pjt,{documents:fe,documentPages:E,onDocumentDeleted:Ae,currentPage:U,itemsPerPage:Ne,totalItems:he,onPageChange:K})})]}),we("summaries")&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"My Summaries"})}),l.jsx(Ge,{children:Te.length===0?l.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No summaries found"}):l.jsx(yjt,{summaries:Te,onSummaryDeleted:Ae,currentPage:G,itemsPerPage:Ne,totalItems:ae,onPageChange:X})})]}),we("methods")&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"My Methods"})}),l.jsx(Ge,{children:Pe.length===0?l.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No methods found"}):l.jsx(xjt,{methods:Pe,onMethodDeleted:Ae,currentPage:H,itemsPerPage:Ne,totalItems:I,onPageChange:B})})]}),we("theories")&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"My Theory & Background"})}),l.jsx(Ge,{children:tt.length===0?l.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No theories found"}):l.jsx(vjt,{theories:tt,onTheoryDeleted:Ae,currentPage:L,itemsPerPage:Ne,totalItems:$,onPageChange:F})})]}),we("analyses")&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"My Analysis"})}),l.jsx(Ge,{children:wt.length===0?l.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No analyses found"}):l.jsx(bjt,{analyses:wt,onAnalysisDeleted:Ae,currentPage:V,itemsPerPage:Ne,totalItems:ue,onPageChange:Y})})]}),we("topics")&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"My Topic Explorations"})}),l.jsx(Ge,{children:Ee.length===0?l.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No topic explorations found"}):l.jsx(wjt,{topics:Ee,onTopicDeleted:Ae,currentPage:ie,itemsPerPage:Ne,totalItems:me,onPageChange:Q})})]}),we("setups")&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"My Research Setups"})}),l.jsx(Ge,{children:nt.length===0?l.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No research setups found"}):l.jsx(Sjt,{setups:nt,onSetupDeleted:Ae,currentPage:D,itemsPerPage:Ne,totalItems:xe,onPageChange:R})})]}),we("discussions")&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"My Discussions"})}),l.jsx(Ge,{children:rt.length===0?l.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No discussions found"}):l.jsx(_jt,{discussions:rt,onDiscussionDeleted:Ae,currentPage:J,itemsPerPage:Ne,totalItems:de,onPageChange:Z})})]}),we("codings")&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"My Codings"})}),l.jsx(Ge,{children:Ze.length===0?l.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No codings found"}):l.jsx(jjt,{codings:Ze,onCodingDeleted:Ae,currentPage:ee,itemsPerPage:Ne,totalItems:Se,onPageChange:re})})]})]})}):null};function Bu({open:t,onClose:e,remainingPoints:r}){const n=Or();return l.jsx(Gr,{open:t,onOpenChange:e,children:l.jsxs(zr,{className:"sm:max-w-md",children:[l.jsxs(Ur,{className:"items-center text-center",children:[l.jsx("div",{className:"mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10",children:l.jsx(bu,{className:"h-6 w-6 text-destructive"})}),l.jsx(Hr,{children:"Student Points exhausted"}),l.jsxs(wx,{children:["You currently have ",l.jsx("span",{className:"font-semibold text-foreground",children:Math.round(r)})," ","Student Points. You need more points to use this feature."]})]}),l.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[l.jsx(ye,{onClick:()=>{e(),n("/pricing")},children:"View Plans"}),l.jsx(ye,{variant:"outline",onClick:e,children:"Close"})]})]})})}const ure={small:{label:"Small - Brief Overview",description:"2-3 sentences, approx. 200-300 tokens"},medium:{label:"Medium - Detailed Summary",description:"1 paragraph, approx. 400-600 tokens"},big:{label:"Big - Comprehensive Analysis",description:"2-3 paragraphs, approx. 800-1200 tokens"},deep15:{label:"Deep - In-depth Analysis",description:"~15% of input, structured with introduction, key points, conclusion"}},Djt={small:1,medium:1,big:1.25,deep15:1.5};function Ljt({documents:t,onSummaryCreated:e}){const{userProfile:r,user:n,checkStudentPoints:s,studentPoints:i}=Dt(),[a,o]=j.useState(!1),[c,u]=j.useState(""),[d,h]=j.useState(""),[f,p]=j.useState(""),[m,g]=j.useState(!1),[x,y]=j.useState(null),[v,b]=j.useState(null),[w,S]=j.useState(null),[k,E]=j.useState(null),C=F=>F.replace(/[^\d,\-–\s]/g,"").trim(),A=F=>{const V=C(F);if(!V)return[];const Y=[],ie=V.split(",").map(Q=>Q.trim());for(const Q of ie)if(Q.includes("–")||Q.includes("-")){const[D,R]=Q.split(/[–-]/).map(J=>parseInt(J.trim()));if(!isNaN(D)&&!isNaN(R)&&D>0&&R>0&&D<=R&&R<=1e3)for(let J=D;J<=R;J++)Y.includes(J)||Y.push(J)}else{const D=parseInt(Q);!isNaN(D)&&D>0&&D<=1e3&&!Y.includes(D)&&Y.push(D)}return Y.sort((Q,D)=>Q-D)},M=F=>{if(!F.trim())return"Please select at least one page.";const V=A(F);if(V.length===0)return"Invalid format. Use e.g. 1-5, 8, 12";const Y=t.find(ie=>ie.id===c);if(Y&&Y.page_count){const ie=V.filter(Q=>Q>Y.page_count);if(ie.length>0)return`Document only has ${Y.page_count} pages. Invalid pages: ${ie.join(", ")}`}return V.length>50?"Maximum 50 pages per summary.":null},z=F=>{h(F);const V=M(F);b(V)},P=t.find(F=>F.id===c),W=A(d),N=W.length,U=f?Djt[f]:1,K=Math.ceil(N*U),G=P&&N>0&&f&&r&&!v,X=r?r.current_token_balance>=K:!1,H=async()=>{if(!s()){o(!0);return}if(!(!G||!r||!n)){g(!0),y(null),S(null),E(null);try{const{data:{session:F}}=await Qr.auth.getSession();if(!(F!=null&&F.access_token))throw new Error("No valid login found");const V=crypto.randomUUID(),{data:Y,error:ie}=await Qr.functions.invoke("summarize",{body:{client_request_id:V,document_id:c,selected_pages:W,mode:f}});if(console.log("summarize response",{data:Y,error:ie}),ie){E({text:ie.message||"Invoke error",isError:!0});return}if(Y!=null&&Y.error){const D=Y.message||"Error";E({text:D,isError:!0}),We.error(D);return}const Q=Y==null?void 0:Y.summary_text;if(!Q){We.error("No summary returned");return}E({text:Q,isError:!1}),y(Q),S({mode:(Y==null?void 0:Y.summary_mode)||f,pagesCharged:(Y==null?void 0:Y.pages_selected)||K,remainingAfter:r.current_token_balance}),console.log("summary_id",Y==null?void 0:Y.summary_id),We.success(`Summary created successfully! ${(Y==null?void 0:Y.pages_selected)||K} pages processed.`),u(""),h(""),p(""),b(null),e()}catch(F){console.error("Summary generation error:",F),E({text:F.message||"Error creating summary. Please try again.",isError:!0}),F.message.includes("Plan upgraden")?We.error("Page limit reached – please upgrade plan.",{action:{label:"View Pricing",onClick:()=>window.open("/pricing","_blank")}}):We.error(F.message||"Error creating summary. Please try again.")}finally{g(!1)}}},B=async()=>{if(x)try{await navigator.clipboard.writeText(x),We.success("Copied to clipboard")}catch{We.error("Copy failed")}},L=f?ure[f]:null;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-4",children:[t.length===0?l.jsxs(wh,{children:[l.jsx(bu,{className:"h-4 w-4"}),l.jsx(Sh,{children:"No documents available. Upload a PDF in Step 1 first."})]}):l.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"document-select",children:"Select Document"}),l.jsxs(dt,{value:c,onValueChange:u,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Choose document..."})}),l.jsx(ct,{children:t.map(F=>l.jsxs(De,{value:F.id,children:[F.title," (",F.page_count||"?"," pages)"]},F.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"summary-mode",children:"Summary Mode"}),l.jsxs(dt,{value:f,onValueChange:p,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Choose mode..."})}),l.jsx(ct,{children:Object.entries(ure).map(([F,V])=>l.jsx(De,{value:F,children:V.label},F))})]}),L&&l.jsx("p",{className:"text-xs text-muted-foreground",children:L.description})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"page-selection",children:"Page Selection"}),l.jsx(Be,{id:"page-selection",value:d,onChange:F=>z(F.target.value),placeholder:"e.g. 2-5, 7, 12",maxLength:100,className:v?"border-destructive":""}),v?l.jsx("p",{className:"text-sm text-destructive",children:v}):l.jsx("p",{className:"text-xs text-muted-foreground",children:"Format: Individual pages (7) or ranges (2-5), separated by comma. Max. 50 pages per summary."}),W.length>0&&!v&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("p",{className:"text-sm text-primary",children:["Selected pages: ",W.join(", ")," (",N," pages)"]}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:["This selection will use approximately ",K," pages from your monthly limit (pages ×"," ",U," multiplier = ",K,")."]})]})]}),!X&&N>0&&l.jsxs(wh,{className:"border-destructive/50 bg-destructive/5",children:[l.jsx(bu,{className:"h-4 w-4 text-destructive"}),l.jsxs(Sh,{children:["Not enough pages available! You need ",K," pages, but only have"," ",r==null?void 0:r.current_token_balance," remaining."]})]}),l.jsx(ye,{onClick:H,disabled:!G||m,className:"w-full",children:m?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Creating summary..."]}):"➤ Summarize Now"}),(k==null?void 0:k.isError)&&l.jsx("div",{className:"border rounded-lg p-4 border-destructive/50 bg-destructive/5",children:l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(bu,{className:"w-5 h-5 text-destructive mt-0.5 flex-shrink-0"}),l.jsxs("div",{className:"space-y-2 flex-1",children:[l.jsx("h4",{className:"font-medium text-destructive",children:"Summary Error"}),l.jsx("p",{className:"text-sm text-destructive/80",children:k.text})]})]})})]}),x&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-lg font-semibold",children:"Summary"}),l.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[l.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[l.jsx(_c,{className:"w-4 h-4"}),l.jsx("span",{children:"Saved"})]}),w&&l.jsxs("div",{className:"text-muted-foreground",children:[w.pagesCharged," pages used • ",w.remainingAfter," remaining"]})]})]}),l.jsx("div",{className:"border rounded-lg p-4 bg-muted/20",children:l.jsx(ir,{value:x,readOnly:!0,className:"border-none bg-transparent resize-none focus:ring-0 p-0 w-full",style:{height:"auto",minHeight:"200px",overflow:"hidden"},rows:x?x.split(`
`).length+5:10})}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.jsxs(ye,{onClick:B,variant:"outline",size:"sm",children:[l.jsx(Tn,{className:"w-4 h-4 mr-2"}),"Copy to Clipboard"]}),l.jsxs(ye,{variant:"outline",size:"sm",disabled:!0,children:[l.jsx(QG,{className:"w-4 h-4 mr-2"}),"Export as PDF"]}),l.jsxs(ye,{variant:"outline",size:"sm",disabled:!0,children:[l.jsx(QG,{className:"w-4 h-4 mr-2"}),"Export as DOCX"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>window.location.href="/documents",children:[l.jsx($p,{className:"w-4 h-4 mr-2"}),"Open in Library"]})]})]}),l.jsx(Bu,{open:a,onClose:()=>o(!1),remainingPoints:(i==null?void 0:i.remaining)??0})]})}const Fjt=()=>{const{user:t,loading:e}=Dt(),r=Or(),[n,s]=j.useState([]),[i,a]=j.useState(!1);j.useEffect(()=>{!t&&!e&&r("/login")},[t,e,r]);const o=async()=>{if(t){a(!0);try{const{data:u,error:d}=await Qr.from("documents").select("id, user_id, title, original_file_url, page_count, created_at").eq("user_id",t.id).order("created_at",{ascending:!1});d?console.error("Error fetching documents:",d):s(u||[])}catch(u){console.error("Error fetching documents:",u)}finally{a(!1)}}};j.useEffect(()=>{t&&o()},[t]);const c=()=>{o()};return e?l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?l.jsx(gr,{showSidebar:!0,children:l.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"Summaries"}),l.jsx("p",{className:"text-muted-foreground",children:"Create summaries based on your uploaded documents"})]}),l.jsxs(ze,{className:"panze-content-card",children:[l.jsxs(et,{children:[l.jsx(at,{className:"flex items-center gap-3",children:"Create Summary"}),l.jsx(Un,{children:"Select a document and configure your summary options"})]}),l.jsx(Ge,{children:l.jsx(Ljt,{documents:n,onSummaryCreated:c})})]})]})}):null},dre=(t,e,r,n)=>{switch(n){case"theory":return 60;case"theory-fox40":return 60;case"methods":return 60;case"methods-fox40":return 40;case"discussion":return 30;case"conclusion":return 30;case"summary":return 20;case"supervisor":return 5;case"topic_exp":return 5;case"platform_assistant":return 2;case"analysis_r":return 10;case"codeapply":return 15;case"r_setup":return 5;default:return 0}},$jt=()=>{const{user:t,loading:e}=Dt(),r=Or(),[n,s]=j.useState([]),[i,a]=j.useState([]),[o,c]=j.useState(!0),[u,d]=j.useState("all");j.useEffect(()=>{!t&&!e?r("/login"):t&&h()},[t,e,r]);const h=async()=>{try{const[v,b,w,S,k,E,C,A]=await Promise.all([be.from("summaries").select("id, summary_text, citation_style, created_at, summary_mode, documents(title)").order("created_at",{ascending:!1}),be.from("theory_backgrounds").select("id, title, theory_text, citation_style, created_at, mode").order("created_at",{ascending:!1}),be.from("methods").select("id, title, method_text, citation_style, created_at, mode").order("created_at",{ascending:!1}),be.from("analysis_results").select("id, result_text, citation_style, created_at, mode").order("created_at",{ascending:!1}),be.from("qualitative_summaries").select("id, title, summary_text, created_at").order("created_at",{ascending:!1}),be.from("topic_explorations").select("id, title, introduction, created_at, language").order("created_at",{ascending:!1}),be.from("research_setups").select("id, title, aim, degree, discipline, created_at").order("created_at",{ascending:!1}),be.from("usage_log").select("id, tokens_used, prompt_tokens, completion_tokens, model, source, timestamp").order("timestamp",{ascending:!1}).limit(100)]),M=[];v.data&&v.data.forEach(z=>{var P;M.push({id:z.id,type:"summary",title:((P=z.documents)==null?void 0:P.title)||"Summary",content:z.summary_text||"",created_at:z.created_at||"",citation_style:z.citation_style||void 0,mode:z.summary_mode||void 0})}),b.data&&b.data.forEach(z=>{M.push({id:z.id,type:"theory",title:z.title||"Theory Background",content:z.theory_text||"",created_at:z.created_at,citation_style:z.citation_style||void 0,mode:z.mode||void 0})}),w.data&&w.data.forEach(z=>{M.push({id:z.id,type:"method",title:z.title||"Methodology",content:z.method_text||"",created_at:z.created_at,citation_style:z.citation_style||void 0,mode:z.mode||void 0})}),S.data&&S.data.forEach(z=>{M.push({id:z.id,type:"analysis",title:"Analysis Result",content:z.result_text||"",created_at:z.created_at,citation_style:z.citation_style||void 0,mode:z.mode||void 0})}),k.data&&k.data.forEach(z=>{M.push({id:z.id,type:"qualitative",title:z.title||"Qualitative Summary",content:z.summary_text||"",created_at:z.created_at})}),E.data&&E.data.forEach(z=>{M.push({id:z.id,type:"topic_explorer",title:z.title||"Topic Exploration",content:z.introduction||"",created_at:z.created_at,mode:z.language||void 0})}),C.data&&C.data.forEach(z=>{M.push({id:z.id,type:"research_setup",title:z.title||"Research Setup",content:z.aim||"",created_at:z.created_at,mode:z.degree||void 0})}),M.sort((z,P)=>new Date(P.created_at).getTime()-new Date(z.created_at).getTime()),s(M),a(A.data||[])}catch(v){console.error("Error fetching history:",v),We.error("Error loading history")}finally{c(!1)}},f=async(v,b)=>{We.info(`Preparing ${b.toUpperCase()} export...`)},p=v=>{switch(v){case"summary":return"default";case"theory":return"secondary";case"method":return"outline";case"analysis":return"default";case"qualitative":return"secondary";case"topic_explorer":return"default";case"research_setup":return"secondary";default:return"outline"}},m=v=>{switch(v){case"summary":return"Summary";case"theory":return"Theory";case"method":return"Method";case"analysis":return"Analysis";case"qualitative":return"Qualitative";case"topic_explorer":return"Topic Explorer";case"research_setup":return"Research Setup";default:return v}},g=v=>new Date(v).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0});if(e||o)return l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})});if(!t)return null;const x=i.reduce((v,b)=>v+dre(b.prompt_tokens,b.completion_tokens,b.model,b.source),0),y=i.filter(v=>new Date(v.timestamp).toDateString()===new Date().toDateString()).length;return l.jsx(gr,{showSidebar:!0,children:l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"History & Exports"}),l.jsx("p",{className:"text-muted-foreground",children:"Overview of all your activities and download options"})]}),l.jsx("div",{className:"flex items-center gap-4",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(x2e,{className:"h-4 w-4"}),l.jsxs(dt,{value:u,onValueChange:v=>d(v),children:[l.jsx(lt,{className:"w-44",children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"all",children:"All Activities"}),l.jsx(De,{value:"generations",children:"AI Generations"}),l.jsx(De,{value:"usage",children:"Usage History"})]})]})]})})]}),l.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[l.jsxs(ze,{children:[l.jsx(et,{className:"pb-3",children:l.jsxs(at,{className:"text-sm font-medium flex items-center gap-2",children:[l.jsx(Qs,{className:"h-4 w-4 text-primary"}),"Total AI Generations"]})}),l.jsx(Ge,{children:l.jsx("div",{className:"text-3xl font-bold",children:n.length})})]}),l.jsxs(ze,{children:[l.jsx(et,{className:"pb-3",children:l.jsxs(at,{className:"text-sm font-medium flex items-center gap-2",children:[l.jsx(KG,{className:"h-4 w-4 text-primary"}),"Student Points Used"]})}),l.jsx(Ge,{children:l.jsxs("div",{className:"text-3xl font-bold",children:[x.toFixed(2)," SP"]})})]}),l.jsxs(ze,{children:[l.jsx(et,{className:"pb-3",children:l.jsxs(at,{className:"text-sm font-medium flex items-center gap-2",children:[l.jsx(S$,{className:"h-4 w-4 text-primary"}),"Activities Today"]})}),l.jsx(Ge,{children:l.jsx("div",{className:"text-3xl font-bold",children:y})})]})]}),(u==="all"||u==="generations")&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-xl font-semibold",children:"AI Generations"}),n.length===0?l.jsx(ze,{children:l.jsxs(Ge,{className:"text-center py-12",children:[l.jsx(Br,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-medium mb-2",children:"No AI generations yet"}),l.jsx("p",{className:"text-muted-foreground",children:"Start creating summaries, theories, or methodologies to see them here"})]})}):l.jsx("div",{className:"grid gap-4",children:n.map(v=>l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx("div",{className:"flex items-start justify-between",children:l.jsxs("div",{children:[l.jsx(at,{className:"text-lg",children:v.title}),l.jsxs(Un,{className:"flex items-center gap-3 mt-2 flex-wrap",children:[l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx(S$,{className:"h-4 w-4"}),g(v.created_at)]}),l.jsx(kt,{variant:p(v.type),children:m(v.type)}),v.citation_style&&l.jsx(kt,{variant:"outline",children:v.citation_style})]})]})})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsx("div",{className:"bg-muted/30 rounded-lg p-4",children:l.jsx("p",{className:"text-sm leading-relaxed line-clamp-3",children:v.content?kO(v.content,v.mode):"No content available"})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>f(v,"pdf"),children:[l.jsx(Ga,{className:"h-4 w-4 mr-2"}),"PDF"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>f(v,"docx"),children:[l.jsx(Ga,{className:"h-4 w-4 mr-2"}),"DOCX"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>f(v,"txt"),children:[l.jsx(Ga,{className:"h-4 w-4 mr-2"}),"TXT"]})]})]})]},`${v.type}-${v.id}`))})]}),(u==="all"||u==="usage")&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-xl font-semibold",children:"Usage History"}),i.length===0?l.jsx(ze,{children:l.jsxs(Ge,{className:"text-center py-12",children:[l.jsx(KG,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),l.jsx("h3",{className:"text-lg font-medium mb-2",children:"No activity recorded yet"}),l.jsx("p",{className:"text-muted-foreground",children:"Your usage history will appear here"})]})}):l.jsx(ze,{children:l.jsx(Ge,{className:"p-0",children:l.jsx("div",{className:"max-h-96 overflow-y-auto",children:i.map(v=>{const b=dre(v.prompt_tokens,v.completion_tokens,v.model,v.source);return l.jsxs("div",{className:"flex items-center justify-between p-4 border-b last:border-b-0",children:[l.jsxs("div",{children:[l.jsx("div",{className:"font-medium",children:v.source||"Unknown"}),l.jsx("div",{className:"text-sm text-muted-foreground",children:g(v.timestamp)})]}),l.jsxs(kt,{variant:"secondary",className:"font-mono",children:[b.toFixed(3)," SP"]})]},v.id)})})})})]})]})})};function vC(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var pSe={exports:{}};/*!
JSZip v3.10.1 - A JavaScript class for generating and reading zip files
<http://stuartk.com/jszip>
(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
JSZip uses the library pako released under the MIT license :
https://github.com/nodeca/pako/blob/main/LICENSE
*/(function(t,e){(function(r){t.exports=r()})(function(){return function r(n,s,i){function a(u,d){if(!s[u]){if(!n[u]){var h=typeof vC=="function"&&vC;if(!d&&h)return h(u,!0);if(o)return o(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var p=s[u]={exports:{}};n[u][0].call(p.exports,function(m){var g=n[u][1][m];return a(g||m)},p,p.exports,r,n,s,i)}return s[u].exports}for(var o=typeof vC=="function"&&vC,c=0;c<i.length;c++)a(i[c]);return a}({1:[function(r,n,s){var i=r("./utils"),a=r("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(c){for(var u,d,h,f,p,m,g,x=[],y=0,v=c.length,b=v,w=i.getTypeOf(c)!=="string";y<c.length;)b=v-y,h=w?(u=c[y++],d=y<v?c[y++]:0,y<v?c[y++]:0):(u=c.charCodeAt(y++),d=y<v?c.charCodeAt(y++):0,y<v?c.charCodeAt(y++):0),f=u>>2,p=(3&u)<<4|d>>4,m=1<b?(15&d)<<2|h>>6:64,g=2<b?63&h:64,x.push(o.charAt(f)+o.charAt(p)+o.charAt(m)+o.charAt(g));return x.join("")},s.decode=function(c){var u,d,h,f,p,m,g=0,x=0,y="data:";if(c.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var v,b=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===o.charAt(64)&&b--,c.charAt(c.length-2)===o.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=a.uint8array?new Uint8Array(0|b):new Array(0|b);g<c.length;)u=o.indexOf(c.charAt(g++))<<2|(f=o.indexOf(c.charAt(g++)))>>4,d=(15&f)<<4|(p=o.indexOf(c.charAt(g++)))>>2,h=(3&p)<<6|(m=o.indexOf(c.charAt(g++))),v[x++]=u,p!==64&&(v[x++]=d),m!==64&&(v[x++]=h);return v}},{"./support":30,"./utils":32}],2:[function(r,n,s){var i=r("./external"),a=r("./stream/DataWorker"),o=r("./stream/Crc32Probe"),c=r("./stream/DataLengthProbe");function u(d,h,f,p,m){this.compressedSize=d,this.uncompressedSize=h,this.crc32=f,this.compression=p,this.compressedContent=m}u.prototype={getContentWorker:function(){var d=new a(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,h,f){return d.pipe(new o).pipe(new c("uncompressedSize")).pipe(h.compressWorker(f)).pipe(new c("compressedSize")).withStreamInfo("compression",h)},n.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,s){var i=r("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},s.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,s){var i=r("./utils"),a=function(){for(var o,c=[],u=0;u<256;u++){o=u;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;c[u]=o}return c}();n.exports=function(o,c){return o!==void 0&&o.length?i.getTypeOf(o)!=="string"?function(u,d,h,f){var p=a,m=f+h;u^=-1;for(var g=f;g<m;g++)u=u>>>8^p[255&(u^d[g])];return-1^u}(0|c,o,o.length,0):function(u,d,h,f){var p=a,m=f+h;u^=-1;for(var g=f;g<m;g++)u=u>>>8^p[255&(u^d.charCodeAt(g))];return-1^u}(0|c,o,o.length,0):0}},{"./utils":32}],5:[function(r,n,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(r,n,s){var i=null;i=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:i}},{lie:37}],7:[function(r,n,s){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=r("pako"),o=r("./utils"),c=r("./stream/GenericWorker"),u=i?"uint8array":"array";function d(h,f){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=f,this.meta={}}s.magic="\b\0",o.inherits(d,c),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(u,h.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(f){h.push({data:f,meta:h.meta})}},s.compressWorker=function(h){return new d("Deflate",h)},s.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,s){function i(p,m){var g,x="";for(g=0;g<m;g++)x+=String.fromCharCode(255&p),p>>>=8;return x}function a(p,m,g,x,y,v){var b,w,S=p.file,k=p.compression,E=v!==u.utf8encode,C=o.transformTo("string",v(S.name)),A=o.transformTo("string",u.utf8encode(S.name)),M=S.comment,z=o.transformTo("string",v(M)),P=o.transformTo("string",u.utf8encode(M)),W=A.length!==S.name.length,N=P.length!==M.length,U="",K="",G="",X=S.dir,H=S.date,B={crc32:0,compressedSize:0,uncompressedSize:0};m&&!g||(B.crc32=p.crc32,B.compressedSize=p.compressedSize,B.uncompressedSize=p.uncompressedSize);var L=0;m&&(L|=8),E||!W&&!N||(L|=2048);var F=0,V=0;X&&(F|=16),y==="UNIX"?(V=798,F|=function(ie,Q){var D=ie;return ie||(D=Q?16893:33204),(65535&D)<<16}(S.unixPermissions,X)):(V=20,F|=function(ie){return 63&(ie||0)}(S.dosPermissions)),b=H.getUTCHours(),b<<=6,b|=H.getUTCMinutes(),b<<=5,b|=H.getUTCSeconds()/2,w=H.getUTCFullYear()-1980,w<<=4,w|=H.getUTCMonth()+1,w<<=5,w|=H.getUTCDate(),W&&(K=i(1,1)+i(d(C),4)+A,U+="up"+i(K.length,2)+K),N&&(G=i(1,1)+i(d(z),4)+P,U+="uc"+i(G.length,2)+G);var Y="";return Y+=`
\0`,Y+=i(L,2),Y+=k.magic,Y+=i(b,2),Y+=i(w,2),Y+=i(B.crc32,4),Y+=i(B.compressedSize,4),Y+=i(B.uncompressedSize,4),Y+=i(C.length,2),Y+=i(U.length,2),{fileRecord:h.LOCAL_FILE_HEADER+Y+C+U,dirRecord:h.CENTRAL_FILE_HEADER+i(V,2)+Y+i(z.length,2)+"\0\0\0\0"+i(F,4)+i(x,4)+C+U+z}}var o=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),d=r("../crc32"),h=r("../signature");function f(p,m,g,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=g,this.encodeFileName=x,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(f,c),f.prototype.push=function(p){var m=p.meta.percent||0,g=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:g?(m+100*(g-x-1))/g:100}}))},f.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var m=this.streamFiles&&!p.file.dir;if(m){var g=a(p,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(p){this.accumulate=!1;var m=this.streamFiles&&!p.file.dir,g=a(p,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),m)this.push({data:function(x){return h.DATA_DESCRIPTOR+i(x.crc32,4)+i(x.compressedSize,4)+i(x.uncompressedSize,4)}(p),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var p=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var g=this.bytesWritten-p,x=function(y,v,b,w,S){var k=o.transformTo("string",S(w));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(y,2)+i(y,2)+i(v,4)+i(b,4)+i(k.length,2)+k}(this.dirRecords.length,g,p,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(p){this._sources.push(p);var m=this;return p.on("data",function(g){m.processChunk(g)}),p.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),p.on("error",function(g){m.error(g)}),this},f.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(p){var m=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var g=0;g<m.length;g++)try{m[g].error(p)}catch{}return!0},f.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,m=0;m<p.length;m++)p[m].lock()},n.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(r,n,s){var i=r("../compressions"),a=r("./ZipFileWorker");s.generateWorker=function(o,c,u){var d=new a(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{o.forEach(function(f,p){h++;var m=function(v,b){var w=v||b,S=i[w];if(!S)throw new Error(w+" is not a valid compression method !");return S}(p.options.compression,c.compression),g=p.options.compressionOptions||c.compressionOptions||{},x=p.dir,y=p.date;p._compressWorker(m,g).withStreamInfo("file",{name:f,dir:x,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(f){d.error(f)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(r,n,s){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new i;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(i.prototype=r("./object")).loadAsync=r("./load"),i.support=r("./support"),i.defaults=r("./defaults"),i.version="3.10.1",i.loadAsync=function(a,o){return new i().loadAsync(a,o)},i.external=r("./external"),n.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(r,n,s){var i=r("./utils"),a=r("./external"),o=r("./utf8"),c=r("./zipEntries"),u=r("./stream/Crc32Probe"),d=r("./nodejsUtils");function h(f){return new a.Promise(function(p,m){var g=f.decompressed.getContentWorker().pipe(new u);g.on("error",function(x){m(x)}).on("end",function(){g.streamInfo.crc32!==f.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(f,p){var m=this;return p=i.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),d.isNode&&d.isStream(f)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",f,!0,p.optimizedBinaryString,p.base64).then(function(g){var x=new c(p);return x.load(g),x}).then(function(g){var x=[a.Promise.resolve(g)],y=g.files;if(p.checkCRC32)for(var v=0;v<y.length;v++)x.push(h(y[v]));return a.Promise.all(x)}).then(function(g){for(var x=g.shift(),y=x.files,v=0;v<y.length;v++){var b=y[v],w=b.fileNameStr,S=i.resolve(b.fileNameStr);m.file(S,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:p.createFolders}),b.dir||(m.file(S).unsafeOriginalName=w)}return x.zipComment.length&&(m.comment=x.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(r,n,s){var i=r("../utils"),a=r("../stream/GenericWorker");function o(c,u){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}i.inherits(o,a),o.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(r,n,s){var i=r("readable-stream").Readable;function a(o,c,u){i.call(this,c),this._helper=o;var d=this;o.on("data",function(h,f){d.push(h)||d._helper.pause(),u&&u(f)}).on("error",function(h){d.emit("error",h)}).on("end",function(){d.push(null)})}r("../utils").inherits(a,i),a.prototype._read=function(){this._helper.resume()},n.exports=a},{"../utils":32,"readable-stream":16}],14:[function(r,n,s){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,a);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,a)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var a=new Buffer(i);return a.fill(0),a},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(r,n,s){function i(S,k,E){var C,A=o.getTypeOf(k),M=o.extend(E||{},d);M.date=M.date||new Date,M.compression!==null&&(M.compression=M.compression.toUpperCase()),typeof M.unixPermissions=="string"&&(M.unixPermissions=parseInt(M.unixPermissions,8)),M.unixPermissions&&16384&M.unixPermissions&&(M.dir=!0),M.dosPermissions&&16&M.dosPermissions&&(M.dir=!0),M.dir&&(S=y(S)),M.createFolders&&(C=x(S))&&v.call(this,C,!0);var z=A==="string"&&M.binary===!1&&M.base64===!1;E&&E.binary!==void 0||(M.binary=!z),(k instanceof h&&k.uncompressedSize===0||M.dir||!k||k.length===0)&&(M.base64=!1,M.binary=!0,k="",M.compression="STORE",A="string");var P=null;P=k instanceof h||k instanceof c?k:m.isNode&&m.isStream(k)?new g(S,k):o.prepareContent(S,k,M.binary,M.optimizedBinaryString,M.base64);var W=new f(S,P,M);this.files[S]=W}var a=r("./utf8"),o=r("./utils"),c=r("./stream/GenericWorker"),u=r("./stream/StreamHelper"),d=r("./defaults"),h=r("./compressedObject"),f=r("./zipObject"),p=r("./generate"),m=r("./nodejsUtils"),g=r("./nodejs/NodejsStreamInputAdapter"),x=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var k=S.lastIndexOf("/");return 0<k?S.substring(0,k):""},y=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},v=function(S,k){return k=k!==void 0?k:d.createFolders,S=y(S),this.files[S]||i.call(this,S,null,{dir:!0,createFolders:k}),this.files[S]};function b(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var w={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var k,E,C;for(k in this.files)C=this.files[k],(E=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&S(E,C)},filter:function(S){var k=[];return this.forEach(function(E,C){S(E,C)&&k.push(C)}),k},file:function(S,k,E){if(arguments.length!==1)return S=this.root+S,i.call(this,S,k,E),this;if(b(S)){var C=S;return this.filter(function(M,z){return!z.dir&&C.test(M)})}var A=this.files[this.root+S];return A&&!A.dir?A:null},folder:function(S){if(!S)return this;if(b(S))return this.filter(function(A,M){return M.dir&&S.test(A)});var k=this.root+S,E=v.call(this,k),C=this.clone();return C.root=E.name,C},remove:function(S){S=this.root+S;var k=this.files[S];if(k||(S.slice(-1)!=="/"&&(S+="/"),k=this.files[S]),k&&!k.dir)delete this.files[S];else for(var E=this.filter(function(A,M){return M.name.slice(0,S.length)===S}),C=0;C<E.length;C++)delete this.files[E[C].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var k,E={};try{if((E=o.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=E.type.toLowerCase(),E.compression=E.compression.toUpperCase(),E.type==="binarystring"&&(E.type="string"),!E.type)throw new Error("No output type specified.");o.checkSupport(E.type),E.platform!=="darwin"&&E.platform!=="freebsd"&&E.platform!=="linux"&&E.platform!=="sunos"||(E.platform="UNIX"),E.platform==="win32"&&(E.platform="DOS");var C=E.comment||this.comment||"";k=p.generateWorker(this,E,C)}catch(A){(k=new c("error")).error(A)}return new u(k,E.type||"string",E.mimeType)},generateAsync:function(S,k){return this.generateInternalStream(S).accumulate(k)},generateNodeStream:function(S,k){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(k)}};n.exports=w},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(r,n,s){n.exports=r("stream")},{stream:void 0}],17:[function(r,n,s){var i=r("./DataReader");function a(o){i.call(this,o);for(var c=0;c<this.data.length;c++)o[c]=255&o[c]}r("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),h=o.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===c&&this.data[f+1]===u&&this.data[f+2]===d&&this.data[f+3]===h)return f-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),h=o.charCodeAt(3),f=this.readData(4);return c===f[0]&&u===f[1]&&d===f[2]&&h===f[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},n.exports=a},{"../utils":32,"./DataReader":18}],18:[function(r,n,s){var i=r("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var c,u=0;for(this.checkOffset(o),c=this.index+o-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=o,u},readString:function(o){return i.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},n.exports=a},{"../utils":32}],19:[function(r,n,s){var i=r("./Uint8ArrayReader");function a(o){i.call(this,o)}r("../utils").inherits(a,i),a.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},n.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,s){var i=r("./DataReader");function a(o){i.call(this,o)}r("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},n.exports=a},{"../utils":32,"./DataReader":18}],21:[function(r,n,s){var i=r("./ArrayReader");function a(o){i.call(this,o)}r("../utils").inherits(a,i),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},n.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,s){var i=r("../utils"),a=r("../support"),o=r("./ArrayReader"),c=r("./StringReader"),u=r("./NodeBufferReader"),d=r("./Uint8ArrayReader");n.exports=function(h){var f=i.getTypeOf(h);return i.checkSupport(f),f!=="string"||a.uint8array?f==="nodebuffer"?new u(h):a.uint8array?new d(i.transformTo("uint8array",h)):new o(i.transformTo("array",h)):new c(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,s){s.LOCAL_FILE_HEADER="PK",s.CENTRAL_FILE_HEADER="PK",s.CENTRAL_DIRECTORY_END="PK",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,s){var i=r("./GenericWorker"),a=r("../utils");function o(c){i.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(o,i),o.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},n.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,s){var i=r("./GenericWorker"),a=r("../crc32");function o(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(o,i),o.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},n.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,s){var i=r("../utils"),a=r("./GenericWorker");function o(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}i.inherits(o,a),o.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}a.prototype.processChunk.call(this,c)},n.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,s){var i=r("../utils"),a=r("./GenericWorker");function o(c){a.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=i.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}i.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,s){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(c){o.processChunk(c)}),a.on("end",function(){o.end()}),a.on("error",function(c){o.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},n.exports=i},{}],29:[function(r,n,s){var i=r("../utils"),a=r("./ConvertWorker"),o=r("./GenericWorker"),c=r("../base64"),u=r("../support"),d=r("../external"),h=null;if(u.nodestream)try{h=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(m,g){return new d.Promise(function(x,y){var v=[],b=m._internalType,w=m._outputType,S=m._mimeType;m.on("data",function(k,E){v.push(k),g&&g(E)}).on("error",function(k){v=[],y(k)}).on("end",function(){try{var k=function(E,C,A){switch(E){case"blob":return i.newBlob(i.transformTo("arraybuffer",C),A);case"base64":return c.encode(C);default:return i.transformTo(E,C)}}(w,function(E,C){var A,M=0,z=null,P=0;for(A=0;A<C.length;A++)P+=C[A].length;switch(E){case"string":return C.join("");case"array":return Array.prototype.concat.apply([],C);case"uint8array":for(z=new Uint8Array(P),A=0;A<C.length;A++)z.set(C[A],M),M+=C[A].length;return z;case"nodebuffer":return Buffer.concat(C);default:throw new Error("concat : unsupported type '"+E+"'")}}(b,v),S);x(k)}catch(E){y(E)}v=[]}).resume()})}function p(m,g,x){var y=g;switch(g){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=g,this._mimeType=x,i.checkSupport(y),this._worker=m.pipe(new a(y)),m.lock()}catch(v){this._worker=new o("error"),this._worker.error(v)}}p.prototype={accumulate:function(m){return f(this,m)},on:function(m,g){var x=this;return m==="data"?this._worker.on(m,function(y){g.call(x,y.data,y.meta)}):this._worker.on(m,function(){i.delay(g,arguments,x)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},m)}},n.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(r,n,s){if(s.base64=!0,s.array=!0,s.string=!0,s.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",s.nodebuffer=typeof Buffer<"u",s.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")s.blob=!1;else{var i=new ArrayBuffer(0);try{s.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),s.blob=a.getBlob("application/zip").size===0}catch{s.blob=!1}}}try{s.nodestream=!!r("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,s){for(var i=r("./utils"),a=r("./support"),o=r("./nodejsUtils"),c=r("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function h(){c.call(this,"utf-8 decode"),this.leftOver=null}function f(){c.call(this,"utf-8 encode")}s.utf8encode=function(p){return a.nodebuffer?o.newBufferFrom(p,"utf-8"):function(m){var g,x,y,v,b,w=m.length,S=0;for(v=0;v<w;v++)(64512&(x=m.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=m.charCodeAt(v+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),v++),S+=x<128?1:x<2048?2:x<65536?3:4;for(g=a.uint8array?new Uint8Array(S):new Array(S),v=b=0;b<S;v++)(64512&(x=m.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=m.charCodeAt(v+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),v++),x<128?g[b++]=x:(x<2048?g[b++]=192|x>>>6:(x<65536?g[b++]=224|x>>>12:(g[b++]=240|x>>>18,g[b++]=128|x>>>12&63),g[b++]=128|x>>>6&63),g[b++]=128|63&x);return g}(p)},s.utf8decode=function(p){return a.nodebuffer?i.transformTo("nodebuffer",p).toString("utf-8"):function(m){var g,x,y,v,b=m.length,w=new Array(2*b);for(g=x=0;g<b;)if((y=m[g++])<128)w[x++]=y;else if(4<(v=u[y]))w[x++]=65533,g+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&g<b;)y=y<<6|63&m[g++],v--;1<v?w[x++]=65533:y<65536?w[x++]=y:(y-=65536,w[x++]=55296|y>>10&1023,w[x++]=56320|1023&y)}return w.length!==x&&(w.subarray?w=w.subarray(0,x):w.length=x),i.applyFromCharCode(w)}(p=i.transformTo(a.uint8array?"uint8array":"array",p))},i.inherits(h,c),h.prototype.processChunk=function(p){var m=i.transformTo(a.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var g=m;(m=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),m.set(g,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var x=function(v,b){var w;for((b=b||v.length)>v.length&&(b=v.length),w=b-1;0<=w&&(192&v[w])==128;)w--;return w<0||w===0?b:w+u[v[w]]>b?w:b}(m),y=m;x!==m.length&&(a.uint8array?(y=m.subarray(0,x),this.leftOver=m.subarray(x,m.length)):(y=m.slice(0,x),this.leftOver=m.slice(x,m.length))),this.push({data:s.utf8decode(y),meta:p.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=h,i.inherits(f,c),f.prototype.processChunk=function(p){this.push({data:s.utf8encode(p.data),meta:p.meta})},s.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,s){var i=r("./support"),a=r("./base64"),o=r("./nodejsUtils"),c=r("./external");function u(g){return g}function d(g,x){for(var y=0;y<g.length;++y)x[y]=255&g.charCodeAt(y);return x}r("setimmediate"),s.newBlob=function(g,x){s.checkSupport("blob");try{return new Blob([g],{type:x})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(g),y.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,x,y){var v=[],b=0,w=g.length;if(w<=y)return String.fromCharCode.apply(null,g);for(;b<w;)x==="array"||x==="nodebuffer"?v.push(String.fromCharCode.apply(null,g.slice(b,Math.min(b+y,w)))):v.push(String.fromCharCode.apply(null,g.subarray(b,Math.min(b+y,w)))),b+=y;return v.join("")},stringifyByChar:function(g){for(var x="",y=0;y<g.length;y++)x+=String.fromCharCode(g[y]);return x},applyCanBeUsed:{uint8array:function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}}()}};function f(g){var x=65536,y=s.getTypeOf(g),v=!0;if(y==="uint8array"?v=h.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=h.applyCanBeUsed.nodebuffer),v)for(;1<x;)try{return h.stringifyByChunk(g,y,x)}catch{x=Math.floor(x/2)}return h.stringifyByChar(g)}function p(g,x){for(var y=0;y<g.length;y++)x[y]=g[y];return x}s.applyFromCharCode=f;var m={};m.string={string:u,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return m.string.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:function(g){return d(g,o.allocBuffer(g.length))}},m.array={string:f,array:u,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return o.newBufferFrom(g)}},m.arraybuffer={string:function(g){return f(new Uint8Array(g))},array:function(g){return p(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:u,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return o.newBufferFrom(new Uint8Array(g))}},m.uint8array={string:f,array:function(g){return p(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return o.newBufferFrom(g)}},m.nodebuffer={string:f,array:function(g){return p(g,new Array(g.length))},arraybuffer:function(g){return m.nodebuffer.uint8array(g).buffer},uint8array:function(g){return p(g,new Uint8Array(g.length))},nodebuffer:u},s.transformTo=function(g,x){if(x=x||"",!g)return x;s.checkSupport(g);var y=s.getTypeOf(x);return m[y][g](x)},s.resolve=function(g){for(var x=g.split("/"),y=[],v=0;v<x.length;v++){var b=x[v];b==="."||b===""&&v!==0&&v!==x.length-1||(b===".."?y.pop():y.push(b))}return y.join("/")},s.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":i.nodebuffer&&o.isBuffer(g)?"nodebuffer":i.uint8array&&g instanceof Uint8Array?"uint8array":i.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(g){if(!i[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(g){var x,y,v="";for(y=0;y<(g||"").length;y++)v+="\\x"+((x=g.charCodeAt(y))<16?"0":"")+x.toString(16).toUpperCase();return v},s.delay=function(g,x,y){setImmediate(function(){g.apply(y||null,x||[])})},s.inherits=function(g,x){function y(){}y.prototype=x.prototype,g.prototype=new y},s.extend=function(){var g,x,y={};for(g=0;g<arguments.length;g++)for(x in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],x)&&y[x]===void 0&&(y[x]=arguments[g][x]);return y},s.prepareContent=function(g,x,y,v,b){return c.Promise.resolve(x).then(function(w){return i.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)&&typeof FileReader<"u"?new c.Promise(function(S,k){var E=new FileReader;E.onload=function(C){S(C.target.result)},E.onerror=function(C){k(C.target.error)},E.readAsArrayBuffer(w)}):w}).then(function(w){var S=s.getTypeOf(w);return S?(S==="arraybuffer"?w=s.transformTo("uint8array",w):S==="string"&&(b?w=a.decode(w):y&&v!==!0&&(w=function(k){return d(k,i.uint8array?new Uint8Array(k.length):new Array(k.length))}(w))),w):c.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(r,n,s){var i=r("./reader/readerFor"),a=r("./utils"),o=r("./signature"),c=r("./zipEntry"),u=r("./support");function d(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(f)+", expected "+a.pretty(h)+")")}},isSignature:function(h,f){var p=this.reader.index;this.reader.setIndex(h);var m=this.reader.readString(4)===f;return this.reader.setIndex(p),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),f=u.uint8array?"uint8array":"array",p=a.transformTo(f,h);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h,f,p,m=this.zip64EndOfCentralSize-44;0<m;)h=this.reader.readInt(2),f=this.reader.readInt(4),p=this.reader.readData(f),this.zip64ExtensibleData[h]={id:h,length:f,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,f;for(h=0;h<this.files.length;h++)f=this.files[h],this.reader.setIndex(f.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(h=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var h=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(h);var f=h;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var m=f-p;if(0<m)this.isSignature(f,o.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(h){this.reader=i(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(r,n,s){var i=r("./reader/readerFor"),a=r("./utils"),o=r("./compressedObject"),c=r("./crc32"),u=r("./utf8"),d=r("./compressions"),h=r("./support");function f(p,m){this.options=p,this.loadOptions=m}f.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var m,g;if(p.skip(22),this.fileNameLength=p.readInt(2),g=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((m=function(x){for(var y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===x)return d[y];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,m,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var m=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(m),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var m,g,x,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)m=p.readInt(2),g=p.readInt(2),x=p.readData(g),this.extraFields[m]={id:m,length:g,value:x};p.setIndex(y)},handleUTF8:function(){var p=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var g=a.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var y=a.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var m=i(p.value);return m.readInt(1)!==1||c(this.fileName)!==m.readInt(4)?null:u.utf8decode(m.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var m=i(p.value);return m.readInt(1)!==1||c(this.fileComment)!==m.readInt(4)?null:u.utf8decode(m.readData(p.length-5))}return null}},n.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(r,n,s){function i(m,g,x){this.name=m,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=g,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var a=r("./stream/StreamHelper"),o=r("./stream/DataWorker"),c=r("./utf8"),u=r("./compressedObject"),d=r("./stream/GenericWorker");i.prototype={internalStream:function(m){var g=null,x="string";try{if(!m)throw new Error("No output type specified.");var y=(x=m.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),g=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(g=g.pipe(new c.Utf8EncodeWorker)),!v&&y&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(b){(g=new d("error")).error(b)}return new a(g,x,"")},async:function(m,g){return this.internalStream(m).accumulate(g)},nodeStream:function(m,g){return this.internalStream(m||"nodebuffer").toNodejsStream(g)},_compressWorker:function(m,g){if(this._data instanceof u&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,m,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new o(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<h.length;p++)i.prototype[h[p]]=f;n.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(r,n,s){(function(i){var a,o,c=i.MutationObserver||i.WebKitMutationObserver;if(c){var u=0,d=new c(m),h=i.document.createTextNode("");d.observe(h,{characterData:!0}),a=function(){h.data=u=++u%2}}else if(i.setImmediate||i.MessageChannel===void 0)a="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var g=i.document.createElement("script");g.onreadystatechange=function(){m(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},i.document.documentElement.appendChild(g)}:function(){setTimeout(m,0)};else{var f=new i.MessageChannel;f.port1.onmessage=m,a=function(){f.port2.postMessage(0)}}var p=[];function m(){var g,x;o=!0;for(var y=p.length;y;){for(x=p,p=[],g=-1;++g<y;)x[g]();y=p.length}o=!1}n.exports=function(g){p.push(g)!==1||o||a()}}).call(this,typeof dn<"u"?dn:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(r,n,s){var i=r("immediate");function a(){}var o={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==a&&g(this,y)}function f(y,v,b){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function p(y,v,b){i(function(){var w;try{w=v(b)}catch(S){return o.reject(y,S)}w===y?o.reject(y,new TypeError("Cannot resolve promise with itself")):o.resolve(y,w)})}function m(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function g(y,v){var b=!1;function w(E){b||(b=!0,o.reject(y,E))}function S(E){b||(b=!0,o.resolve(y,E))}var k=x(function(){v(S,w)});k.status==="error"&&w(k.value)}function x(y,v){var b={};try{b.value=y(v),b.status="success"}catch(w){b.status="error",b.value=w}return b}(n.exports=h).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(y()).then(function(){return b})},function(b){return v.resolve(y()).then(function(){throw b})})},h.prototype.catch=function(y){return this.then(null,y)},h.prototype.then=function(y,v){if(typeof y!="function"&&this.state===u||typeof v!="function"&&this.state===c)return this;var b=new this.constructor(a);return this.state!==d?p(b,this.state===u?y:v,this.outcome):this.queue.push(new f(b,y,v)),b},f.prototype.callFulfilled=function(y){o.resolve(this.promise,y)},f.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},f.prototype.callRejected=function(y){o.reject(this.promise,y)},f.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},o.resolve=function(y,v){var b=x(m,v);if(b.status==="error")return o.reject(y,b.value);var w=b.value;if(w)g(y,w);else{y.state=u,y.outcome=v;for(var S=-1,k=y.queue.length;++S<k;)y.queue[S].callFulfilled(v)}return y},o.reject=function(y,v){y.state=c,y.outcome=v;for(var b=-1,w=y.queue.length;++b<w;)y.queue[b].callRejected(v);return y},h.resolve=function(y){return y instanceof this?y:o.resolve(new this(a),y)},h.reject=function(y){var v=new this(a);return o.reject(v,y)},h.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var S=new Array(b),k=0,E=-1,C=new this(a);++E<b;)A(y[E],E);return C;function A(M,z){v.resolve(M).then(function(P){S[z]=P,++k!==b||w||(w=!0,o.resolve(C,S))},function(P){w||(w=!0,o.reject(C,P))})}},h.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var S=-1,k=new this(a);++S<b;)E=y[S],v.resolve(E).then(function(C){w||(w=!0,o.resolve(k,C))},function(C){w||(w=!0,o.reject(k,C))});var E;return k}},{immediate:36}],38:[function(r,n,s){var i={};(0,r("./lib/utils/common").assign)(i,r("./lib/deflate"),r("./lib/inflate"),r("./lib/zlib/constants")),n.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(r,n,s){var i=r("./zlib/deflate"),a=r("./utils/common"),o=r("./utils/strings"),c=r("./zlib/messages"),u=r("./zlib/zstream"),d=Object.prototype.toString,h=0,f=-1,p=0,m=8;function g(y){if(!(this instanceof g))return new g(y);this.options=a.assign({level:f,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var b=i.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(b!==h)throw new Error(c[b]);if(v.header&&i.deflateSetHeader(this.strm,v.header),v.dictionary){var w;if(w=typeof v.dictionary=="string"?o.string2buf(v.dictionary):d.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(b=i.deflateSetDictionary(this.strm,w))!==h)throw new Error(c[b]);this._dict_set=!0}}function x(y,v){var b=new g(v);if(b.push(y,!0),b.err)throw b.msg||c[b.err];return b.result}g.prototype.push=function(y,v){var b,w,S=this.strm,k=this.options.chunkSize;if(this.ended)return!1;w=v===~~v?v:v===!0?4:0,typeof y=="string"?S.input=o.string2buf(y):d.call(y)==="[object ArrayBuffer]"?S.input=new Uint8Array(y):S.input=y,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new a.Buf8(k),S.next_out=0,S.avail_out=k),(b=i.deflate(S,w))!==1&&b!==h)return this.onEnd(b),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(S.output,S.next_out))):this.onData(a.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&b!==1);return w===4?(b=i.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===h):w!==2||(this.onEnd(h),!(S.avail_out=0))},g.prototype.onData=function(y){this.chunks.push(y)},g.prototype.onEnd=function(y){y===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},s.Deflate=g,s.deflate=x,s.deflateRaw=function(y,v){return(v=v||{}).raw=!0,x(y,v)},s.gzip=function(y,v){return(v=v||{}).gzip=!0,x(y,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(r,n,s){var i=r("./zlib/inflate"),a=r("./utils/common"),o=r("./utils/strings"),c=r("./zlib/constants"),u=r("./zlib/messages"),d=r("./zlib/zstream"),h=r("./zlib/gzheader"),f=Object.prototype.toString;function p(g){if(!(this instanceof p))return new p(g);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},g||{});var x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||g&&g.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&!(15&x.windowBits)&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var y=i.inflateInit2(this.strm,x.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new h,i.inflateGetHeader(this.strm,this.header)}function m(g,x){var y=new p(x);if(y.push(g,!0),y.err)throw y.msg||u[y.err];return y.result}p.prototype.push=function(g,x){var y,v,b,w,S,k,E=this.strm,C=this.options.chunkSize,A=this.options.dictionary,M=!1;if(this.ended)return!1;v=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?E.input=o.binstring2buf(g):f.call(g)==="[object ArrayBuffer]"?E.input=new Uint8Array(g):E.input=g,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new a.Buf8(C),E.next_out=0,E.avail_out=C),(y=i.inflate(E,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(k=typeof A=="string"?o.string2buf(A):f.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,y=i.inflateSetDictionary(this.strm,k)),y===c.Z_BUF_ERROR&&M===!0&&(y=c.Z_OK,M=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);E.next_out&&(E.avail_out!==0&&y!==c.Z_STREAM_END&&(E.avail_in!==0||v!==c.Z_FINISH&&v!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=o.utf8border(E.output,E.next_out),w=E.next_out-b,S=o.buf2string(E.output,b),E.next_out=w,E.avail_out=C-w,w&&a.arraySet(E.output,E.output,b,w,0),this.onData(S)):this.onData(a.shrinkBuf(E.output,E.next_out)))),E.avail_in===0&&E.avail_out===0&&(M=!0)}while((0<E.avail_in||E.avail_out===0)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(v=c.Z_FINISH),v===c.Z_FINISH?(y=i.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c.Z_OK):v!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(E.avail_out=0))},p.prototype.onData=function(g){this.chunks.push(g)},p.prototype.onEnd=function(g){g===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},s.Inflate=p,s.inflate=m,s.inflateRaw=function(g,x){return(x=x||{}).raw=!0,m(g,x)},s.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(r,n,s){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";s.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var h in d)d.hasOwnProperty(h)&&(c[h]=d[h])}}return c},s.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var a={arraySet:function(c,u,d,h,f){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+h),f);else for(var p=0;p<h;p++)c[f+p]=u[d+p]},flattenChunks:function(c){var u,d,h,f,p,m;for(u=h=0,d=c.length;u<d;u++)h+=c[u].length;for(m=new Uint8Array(h),u=f=0,d=c.length;u<d;u++)p=c[u],m.set(p,f),f+=p.length;return m}},o={arraySet:function(c,u,d,h,f){for(var p=0;p<h;p++)c[f+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};s.setTyped=function(c){c?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,a)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,o))},s.setTyped(i)},{}],42:[function(r,n,s){var i=r("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var c=new i.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(h,f){if(f<65537&&(h.subarray&&o||!h.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(h,f));for(var p="",m=0;m<f;m++)p+=String.fromCharCode(h[m]);return p}c[254]=c[254]=1,s.string2buf=function(h){var f,p,m,g,x,y=h.length,v=0;for(g=0;g<y;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<y&&(64512&(m=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),g++),v+=p<128?1:p<2048?2:p<65536?3:4;for(f=new i.Buf8(v),g=x=0;x<v;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<y&&(64512&(m=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),g++),p<128?f[x++]=p:(p<2048?f[x++]=192|p>>>6:(p<65536?f[x++]=224|p>>>12:(f[x++]=240|p>>>18,f[x++]=128|p>>>12&63),f[x++]=128|p>>>6&63),f[x++]=128|63&p);return f},s.buf2binstring=function(h){return d(h,h.length)},s.binstring2buf=function(h){for(var f=new i.Buf8(h.length),p=0,m=f.length;p<m;p++)f[p]=h.charCodeAt(p);return f},s.buf2string=function(h,f){var p,m,g,x,y=f||h.length,v=new Array(2*y);for(p=m=0;p<y;)if((g=h[p++])<128)v[m++]=g;else if(4<(x=c[g]))v[m++]=65533,p+=x-1;else{for(g&=x===2?31:x===3?15:7;1<x&&p<y;)g=g<<6|63&h[p++],x--;1<x?v[m++]=65533:g<65536?v[m++]=g:(g-=65536,v[m++]=55296|g>>10&1023,v[m++]=56320|1023&g)}return d(v,m)},s.utf8border=function(h,f){var p;for((f=f||h.length)>h.length&&(f=h.length),p=f-1;0<=p&&(192&h[p])==128;)p--;return p<0||p===0?f:p+c[h[p]]>f?p:f}},{"./common":41}],43:[function(r,n,s){n.exports=function(i,a,o,c){for(var u=65535&i|0,d=i>>>16&65535|0,h=0;o!==0;){for(o-=h=2e3<o?2e3:o;d=d+(u=u+a[c++]|0)|0,--h;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(r,n,s){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(r,n,s){var i=function(){for(var a,o=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;o[c]=a}return o}();n.exports=function(a,o,c,u){var d=i,h=u+c;a^=-1;for(var f=u;f<h;f++)a=a>>>8^d[255&(a^o[f])];return-1^a}},{}],46:[function(r,n,s){var i,a=r("../utils/common"),o=r("./trees"),c=r("./adler32"),u=r("./crc32"),d=r("./messages"),h=0,f=4,p=0,m=-2,g=-1,x=4,y=2,v=8,b=9,w=286,S=30,k=19,E=2*w+1,C=15,A=3,M=258,z=M+A+1,P=42,W=113,N=1,U=2,K=3,G=4;function X(O,ae){return O.msg=d[ae],ae}function H(O){return(O<<1)-(4<O?9:0)}function B(O){for(var ae=O.length;0<=--ae;)O[ae]=0}function L(O){var ae=O.state,q=ae.pending;q>O.avail_out&&(q=O.avail_out),q!==0&&(a.arraySet(O.output,ae.pending_buf,ae.pending_out,q,O.next_out),O.next_out+=q,ae.pending_out+=q,O.total_out+=q,O.avail_out-=q,ae.pending-=q,ae.pending===0&&(ae.pending_out=0))}function F(O,ae){o._tr_flush_block(O,0<=O.block_start?O.block_start:-1,O.strstart-O.block_start,ae),O.block_start=O.strstart,L(O.strm)}function V(O,ae){O.pending_buf[O.pending++]=ae}function Y(O,ae){O.pending_buf[O.pending++]=ae>>>8&255,O.pending_buf[O.pending++]=255&ae}function ie(O,ae){var q,I,T=O.max_chain_length,$=O.strstart,se=O.prev_length,ue=O.nice_match,ne=O.strstart>O.w_size-z?O.strstart-(O.w_size-z):0,me=O.window,ve=O.w_mask,xe=O.prev,oe=O.strstart+M,de=me[$+se-1],ge=me[$+se];O.prev_length>=O.good_match&&(T>>=2),ue>O.lookahead&&(ue=O.lookahead);do if(me[(q=ae)+se]===ge&&me[q+se-1]===de&&me[q]===me[$]&&me[++q]===me[$+1]){$+=2,q++;do;while(me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&$<oe);if(I=M-(oe-$),$=oe-M,se<I){if(O.match_start=ae,ue<=(se=I))break;de=me[$+se-1],ge=me[$+se]}}while((ae=xe[ae&ve])>ne&&--T!=0);return se<=O.lookahead?se:O.lookahead}function Q(O){var ae,q,I,T,$,se,ue,ne,me,ve,xe=O.w_size;do{if(T=O.window_size-O.lookahead-O.strstart,O.strstart>=xe+(xe-z)){for(a.arraySet(O.window,O.window,xe,xe,0),O.match_start-=xe,O.strstart-=xe,O.block_start-=xe,ae=q=O.hash_size;I=O.head[--ae],O.head[ae]=xe<=I?I-xe:0,--q;);for(ae=q=xe;I=O.prev[--ae],O.prev[ae]=xe<=I?I-xe:0,--q;);T+=xe}if(O.strm.avail_in===0)break;if(se=O.strm,ue=O.window,ne=O.strstart+O.lookahead,me=T,ve=void 0,ve=se.avail_in,me<ve&&(ve=me),q=ve===0?0:(se.avail_in-=ve,a.arraySet(ue,se.input,se.next_in,ve,ne),se.state.wrap===1?se.adler=c(se.adler,ue,ve,ne):se.state.wrap===2&&(se.adler=u(se.adler,ue,ve,ne)),se.next_in+=ve,se.total_in+=ve,ve),O.lookahead+=q,O.lookahead+O.insert>=A)for($=O.strstart-O.insert,O.ins_h=O.window[$],O.ins_h=(O.ins_h<<O.hash_shift^O.window[$+1])&O.hash_mask;O.insert&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[$+A-1])&O.hash_mask,O.prev[$&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=$,$++,O.insert--,!(O.lookahead+O.insert<A)););}while(O.lookahead<z&&O.strm.avail_in!==0)}function D(O,ae){for(var q,I;;){if(O.lookahead<z){if(Q(O),O.lookahead<z&&ae===h)return N;if(O.lookahead===0)break}if(q=0,O.lookahead>=A&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+A-1])&O.hash_mask,q=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart),q!==0&&O.strstart-q<=O.w_size-z&&(O.match_length=ie(O,q)),O.match_length>=A)if(I=o._tr_tally(O,O.strstart-O.match_start,O.match_length-A),O.lookahead-=O.match_length,O.match_length<=O.max_lazy_match&&O.lookahead>=A){for(O.match_length--;O.strstart++,O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+A-1])&O.hash_mask,q=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart,--O.match_length!=0;);O.strstart++}else O.strstart+=O.match_length,O.match_length=0,O.ins_h=O.window[O.strstart],O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+1])&O.hash_mask;else I=o._tr_tally(O,0,O.window[O.strstart]),O.lookahead--,O.strstart++;if(I&&(F(O,!1),O.strm.avail_out===0))return N}return O.insert=O.strstart<A-1?O.strstart:A-1,ae===f?(F(O,!0),O.strm.avail_out===0?K:G):O.last_lit&&(F(O,!1),O.strm.avail_out===0)?N:U}function R(O,ae){for(var q,I,T;;){if(O.lookahead<z){if(Q(O),O.lookahead<z&&ae===h)return N;if(O.lookahead===0)break}if(q=0,O.lookahead>=A&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+A-1])&O.hash_mask,q=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart),O.prev_length=O.match_length,O.prev_match=O.match_start,O.match_length=A-1,q!==0&&O.prev_length<O.max_lazy_match&&O.strstart-q<=O.w_size-z&&(O.match_length=ie(O,q),O.match_length<=5&&(O.strategy===1||O.match_length===A&&4096<O.strstart-O.match_start)&&(O.match_length=A-1)),O.prev_length>=A&&O.match_length<=O.prev_length){for(T=O.strstart+O.lookahead-A,I=o._tr_tally(O,O.strstart-1-O.prev_match,O.prev_length-A),O.lookahead-=O.prev_length-1,O.prev_length-=2;++O.strstart<=T&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+A-1])&O.hash_mask,q=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart),--O.prev_length!=0;);if(O.match_available=0,O.match_length=A-1,O.strstart++,I&&(F(O,!1),O.strm.avail_out===0))return N}else if(O.match_available){if((I=o._tr_tally(O,0,O.window[O.strstart-1]))&&F(O,!1),O.strstart++,O.lookahead--,O.strm.avail_out===0)return N}else O.match_available=1,O.strstart++,O.lookahead--}return O.match_available&&(I=o._tr_tally(O,0,O.window[O.strstart-1]),O.match_available=0),O.insert=O.strstart<A-1?O.strstart:A-1,ae===f?(F(O,!0),O.strm.avail_out===0?K:G):O.last_lit&&(F(O,!1),O.strm.avail_out===0)?N:U}function J(O,ae,q,I,T){this.good_length=O,this.max_lazy=ae,this.nice_length=q,this.max_chain=I,this.func=T}function Z(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*E),this.dyn_dtree=new a.Buf16(2*(2*S+1)),this.bl_tree=new a.Buf16(2*(2*k+1)),B(this.dyn_ltree),B(this.dyn_dtree),B(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(C+1),this.heap=new a.Buf16(2*w+1),B(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*w+1),B(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ee(O){var ae;return O&&O.state?(O.total_in=O.total_out=0,O.data_type=y,(ae=O.state).pending=0,ae.pending_out=0,ae.wrap<0&&(ae.wrap=-ae.wrap),ae.status=ae.wrap?P:W,O.adler=ae.wrap===2?0:1,ae.last_flush=h,o._tr_init(ae),p):X(O,m)}function re(O){var ae=ee(O);return ae===p&&function(q){q.window_size=2*q.w_size,B(q.head),q.max_lazy_match=i[q.level].max_lazy,q.good_match=i[q.level].good_length,q.nice_match=i[q.level].nice_length,q.max_chain_length=i[q.level].max_chain,q.strstart=0,q.block_start=0,q.lookahead=0,q.insert=0,q.match_length=q.prev_length=A-1,q.match_available=0,q.ins_h=0}(O.state),ae}function he(O,ae,q,I,T,$){if(!O)return m;var se=1;if(ae===g&&(ae=6),I<0?(se=0,I=-I):15<I&&(se=2,I-=16),T<1||b<T||q!==v||I<8||15<I||ae<0||9<ae||$<0||x<$)return X(O,m);I===8&&(I=9);var ue=new Z;return(O.state=ue).strm=O,ue.wrap=se,ue.gzhead=null,ue.w_bits=I,ue.w_size=1<<ue.w_bits,ue.w_mask=ue.w_size-1,ue.hash_bits=T+7,ue.hash_size=1<<ue.hash_bits,ue.hash_mask=ue.hash_size-1,ue.hash_shift=~~((ue.hash_bits+A-1)/A),ue.window=new a.Buf8(2*ue.w_size),ue.head=new a.Buf16(ue.hash_size),ue.prev=new a.Buf16(ue.w_size),ue.lit_bufsize=1<<T+6,ue.pending_buf_size=4*ue.lit_bufsize,ue.pending_buf=new a.Buf8(ue.pending_buf_size),ue.d_buf=1*ue.lit_bufsize,ue.l_buf=3*ue.lit_bufsize,ue.level=ae,ue.strategy=$,ue.method=q,re(O)}i=[new J(0,0,0,0,function(O,ae){var q=65535;for(q>O.pending_buf_size-5&&(q=O.pending_buf_size-5);;){if(O.lookahead<=1){if(Q(O),O.lookahead===0&&ae===h)return N;if(O.lookahead===0)break}O.strstart+=O.lookahead,O.lookahead=0;var I=O.block_start+q;if((O.strstart===0||O.strstart>=I)&&(O.lookahead=O.strstart-I,O.strstart=I,F(O,!1),O.strm.avail_out===0)||O.strstart-O.block_start>=O.w_size-z&&(F(O,!1),O.strm.avail_out===0))return N}return O.insert=0,ae===f?(F(O,!0),O.strm.avail_out===0?K:G):(O.strstart>O.block_start&&(F(O,!1),O.strm.avail_out),N)}),new J(4,4,8,4,D),new J(4,5,16,8,D),new J(4,6,32,32,D),new J(4,4,16,16,R),new J(8,16,32,32,R),new J(8,16,128,128,R),new J(8,32,128,256,R),new J(32,128,258,1024,R),new J(32,258,258,4096,R)],s.deflateInit=function(O,ae){return he(O,ae,v,15,8,0)},s.deflateInit2=he,s.deflateReset=re,s.deflateResetKeep=ee,s.deflateSetHeader=function(O,ae){return O&&O.state?O.state.wrap!==2?m:(O.state.gzhead=ae,p):m},s.deflate=function(O,ae){var q,I,T,$;if(!O||!O.state||5<ae||ae<0)return O?X(O,m):m;if(I=O.state,!O.output||!O.input&&O.avail_in!==0||I.status===666&&ae!==f)return X(O,O.avail_out===0?-5:m);if(I.strm=O,q=I.last_flush,I.last_flush=ae,I.status===P)if(I.wrap===2)O.adler=0,V(I,31),V(I,139),V(I,8),I.gzhead?(V(I,(I.gzhead.text?1:0)+(I.gzhead.hcrc?2:0)+(I.gzhead.extra?4:0)+(I.gzhead.name?8:0)+(I.gzhead.comment?16:0)),V(I,255&I.gzhead.time),V(I,I.gzhead.time>>8&255),V(I,I.gzhead.time>>16&255),V(I,I.gzhead.time>>24&255),V(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),V(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(V(I,255&I.gzhead.extra.length),V(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(O.adler=u(O.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(V(I,0),V(I,0),V(I,0),V(I,0),V(I,0),V(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),V(I,3),I.status=W);else{var se=v+(I.w_bits-8<<4)<<8;se|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(se|=32),se+=31-se%31,I.status=W,Y(I,se),I.strstart!==0&&(Y(I,O.adler>>>16),Y(I,65535&O.adler)),O.adler=1}if(I.status===69)if(I.gzhead.extra){for(T=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),L(O),T=I.pending,I.pending!==I.pending_buf_size));)V(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){T=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),L(O),T=I.pending,I.pending===I.pending_buf_size)){$=1;break}$=I.gzindex<I.gzhead.name.length?255&I.gzhead.name.charCodeAt(I.gzindex++):0,V(I,$)}while($!==0);I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),$===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){T=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),L(O),T=I.pending,I.pending===I.pending_buf_size)){$=1;break}$=I.gzindex<I.gzhead.comment.length?255&I.gzhead.comment.charCodeAt(I.gzindex++):0,V(I,$)}while($!==0);I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),$===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&L(O),I.pending+2<=I.pending_buf_size&&(V(I,255&O.adler),V(I,O.adler>>8&255),O.adler=0,I.status=W)):I.status=W),I.pending!==0){if(L(O),O.avail_out===0)return I.last_flush=-1,p}else if(O.avail_in===0&&H(ae)<=H(q)&&ae!==f)return X(O,-5);if(I.status===666&&O.avail_in!==0)return X(O,-5);if(O.avail_in!==0||I.lookahead!==0||ae!==h&&I.status!==666){var ue=I.strategy===2?function(ne,me){for(var ve;;){if(ne.lookahead===0&&(Q(ne),ne.lookahead===0)){if(me===h)return N;break}if(ne.match_length=0,ve=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++,ve&&(F(ne,!1),ne.strm.avail_out===0))return N}return ne.insert=0,me===f?(F(ne,!0),ne.strm.avail_out===0?K:G):ne.last_lit&&(F(ne,!1),ne.strm.avail_out===0)?N:U}(I,ae):I.strategy===3?function(ne,me){for(var ve,xe,oe,de,ge=ne.window;;){if(ne.lookahead<=M){if(Q(ne),ne.lookahead<=M&&me===h)return N;if(ne.lookahead===0)break}if(ne.match_length=0,ne.lookahead>=A&&0<ne.strstart&&(xe=ge[oe=ne.strstart-1])===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]){de=ne.strstart+M;do;while(xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&oe<de);ne.match_length=M-(de-oe),ne.match_length>ne.lookahead&&(ne.match_length=ne.lookahead)}if(ne.match_length>=A?(ve=o._tr_tally(ne,1,ne.match_length-A),ne.lookahead-=ne.match_length,ne.strstart+=ne.match_length,ne.match_length=0):(ve=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++),ve&&(F(ne,!1),ne.strm.avail_out===0))return N}return ne.insert=0,me===f?(F(ne,!0),ne.strm.avail_out===0?K:G):ne.last_lit&&(F(ne,!1),ne.strm.avail_out===0)?N:U}(I,ae):i[I.level].func(I,ae);if(ue!==K&&ue!==G||(I.status=666),ue===N||ue===K)return O.avail_out===0&&(I.last_flush=-1),p;if(ue===U&&(ae===1?o._tr_align(I):ae!==5&&(o._tr_stored_block(I,0,0,!1),ae===3&&(B(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),L(O),O.avail_out===0))return I.last_flush=-1,p}return ae!==f?p:I.wrap<=0?1:(I.wrap===2?(V(I,255&O.adler),V(I,O.adler>>8&255),V(I,O.adler>>16&255),V(I,O.adler>>24&255),V(I,255&O.total_in),V(I,O.total_in>>8&255),V(I,O.total_in>>16&255),V(I,O.total_in>>24&255)):(Y(I,O.adler>>>16),Y(I,65535&O.adler)),L(O),0<I.wrap&&(I.wrap=-I.wrap),I.pending!==0?p:1)},s.deflateEnd=function(O){var ae;return O&&O.state?(ae=O.state.status)!==P&&ae!==69&&ae!==73&&ae!==91&&ae!==103&&ae!==W&&ae!==666?X(O,m):(O.state=null,ae===W?X(O,-3):p):m},s.deflateSetDictionary=function(O,ae){var q,I,T,$,se,ue,ne,me,ve=ae.length;if(!O||!O.state||($=(q=O.state).wrap)===2||$===1&&q.status!==P||q.lookahead)return m;for($===1&&(O.adler=c(O.adler,ae,ve,0)),q.wrap=0,ve>=q.w_size&&($===0&&(B(q.head),q.strstart=0,q.block_start=0,q.insert=0),me=new a.Buf8(q.w_size),a.arraySet(me,ae,ve-q.w_size,q.w_size,0),ae=me,ve=q.w_size),se=O.avail_in,ue=O.next_in,ne=O.input,O.avail_in=ve,O.next_in=0,O.input=ae,Q(q);q.lookahead>=A;){for(I=q.strstart,T=q.lookahead-(A-1);q.ins_h=(q.ins_h<<q.hash_shift^q.window[I+A-1])&q.hash_mask,q.prev[I&q.w_mask]=q.head[q.ins_h],q.head[q.ins_h]=I,I++,--T;);q.strstart=I,q.lookahead=A-1,Q(q)}return q.strstart+=q.lookahead,q.block_start=q.strstart,q.insert=q.lookahead,q.lookahead=0,q.match_length=q.prev_length=A-1,q.match_available=0,O.next_in=ue,O.input=ne,O.avail_in=se,q.wrap=$,p},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(r,n,s){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(r,n,s){n.exports=function(i,a){var o,c,u,d,h,f,p,m,g,x,y,v,b,w,S,k,E,C,A,M,z,P,W,N,U;o=i.state,c=i.next_in,N=i.input,u=c+(i.avail_in-5),d=i.next_out,U=i.output,h=d-(a-i.avail_out),f=d+(i.avail_out-257),p=o.dmax,m=o.wsize,g=o.whave,x=o.wnext,y=o.window,v=o.hold,b=o.bits,w=o.lencode,S=o.distcode,k=(1<<o.lenbits)-1,E=(1<<o.distbits)-1;e:do{b<15&&(v+=N[c++]<<b,b+=8,v+=N[c++]<<b,b+=8),C=w[v&k];t:for(;;){if(v>>>=A=C>>>24,b-=A,(A=C>>>16&255)===0)U[d++]=65535&C;else{if(!(16&A)){if(!(64&A)){C=w[(65535&C)+(v&(1<<A)-1)];continue t}if(32&A){o.mode=12;break e}i.msg="invalid literal/length code",o.mode=30;break e}M=65535&C,(A&=15)&&(b<A&&(v+=N[c++]<<b,b+=8),M+=v&(1<<A)-1,v>>>=A,b-=A),b<15&&(v+=N[c++]<<b,b+=8,v+=N[c++]<<b,b+=8),C=S[v&E];r:for(;;){if(v>>>=A=C>>>24,b-=A,!(16&(A=C>>>16&255))){if(!(64&A)){C=S[(65535&C)+(v&(1<<A)-1)];continue r}i.msg="invalid distance code",o.mode=30;break e}if(z=65535&C,b<(A&=15)&&(v+=N[c++]<<b,(b+=8)<A&&(v+=N[c++]<<b,b+=8)),p<(z+=v&(1<<A)-1)){i.msg="invalid distance too far back",o.mode=30;break e}if(v>>>=A,b-=A,(A=d-h)<z){if(g<(A=z-A)&&o.sane){i.msg="invalid distance too far back",o.mode=30;break e}if(W=y,(P=0)===x){if(P+=m-A,A<M){for(M-=A;U[d++]=y[P++],--A;);P=d-z,W=U}}else if(x<A){if(P+=m+x-A,(A-=x)<M){for(M-=A;U[d++]=y[P++],--A;);if(P=0,x<M){for(M-=A=x;U[d++]=y[P++],--A;);P=d-z,W=U}}}else if(P+=x-A,A<M){for(M-=A;U[d++]=y[P++],--A;);P=d-z,W=U}for(;2<M;)U[d++]=W[P++],U[d++]=W[P++],U[d++]=W[P++],M-=3;M&&(U[d++]=W[P++],1<M&&(U[d++]=W[P++]))}else{for(P=d-z;U[d++]=U[P++],U[d++]=U[P++],U[d++]=U[P++],2<(M-=3););M&&(U[d++]=U[P++],1<M&&(U[d++]=U[P++]))}break}}break}}while(c<u&&d<f);c-=M=b>>3,v&=(1<<(b-=M<<3))-1,i.next_in=c,i.next_out=d,i.avail_in=c<u?u-c+5:5-(c-u),i.avail_out=d<f?f-d+257:257-(d-f),o.hold=v,o.bits=b}},{}],49:[function(r,n,s){var i=r("../utils/common"),a=r("./adler32"),o=r("./crc32"),c=r("./inffast"),u=r("./inftrees"),d=1,h=2,f=0,p=-2,m=1,g=852,x=592;function y(P){return(P>>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(P){var W;return P&&P.state?(W=P.state,P.total_in=P.total_out=W.total=0,P.msg="",W.wrap&&(P.adler=1&W.wrap),W.mode=m,W.last=0,W.havedict=0,W.dmax=32768,W.head=null,W.hold=0,W.bits=0,W.lencode=W.lendyn=new i.Buf32(g),W.distcode=W.distdyn=new i.Buf32(x),W.sane=1,W.back=-1,f):p}function w(P){var W;return P&&P.state?((W=P.state).wsize=0,W.whave=0,W.wnext=0,b(P)):p}function S(P,W){var N,U;return P&&P.state?(U=P.state,W<0?(N=0,W=-W):(N=1+(W>>4),W<48&&(W&=15)),W&&(W<8||15<W)?p:(U.window!==null&&U.wbits!==W&&(U.window=null),U.wrap=N,U.wbits=W,w(P))):p}function k(P,W){var N,U;return P?(U=new v,(P.state=U).window=null,(N=S(P,W))!==f&&(P.state=null),N):p}var E,C,A=!0;function M(P){if(A){var W;for(E=new i.Buf32(512),C=new i.Buf32(32),W=0;W<144;)P.lens[W++]=8;for(;W<256;)P.lens[W++]=9;for(;W<280;)P.lens[W++]=7;for(;W<288;)P.lens[W++]=8;for(u(d,P.lens,0,288,E,0,P.work,{bits:9}),W=0;W<32;)P.lens[W++]=5;u(h,P.lens,0,32,C,0,P.work,{bits:5}),A=!1}P.lencode=E,P.lenbits=9,P.distcode=C,P.distbits=5}function z(P,W,N,U){var K,G=P.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new i.Buf8(G.wsize)),U>=G.wsize?(i.arraySet(G.window,W,N-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(U<(K=G.wsize-G.wnext)&&(K=U),i.arraySet(G.window,W,N-U,K,G.wnext),(U-=K)?(i.arraySet(G.window,W,N-U,U,0),G.wnext=U,G.whave=G.wsize):(G.wnext+=K,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=K))),0}s.inflateReset=w,s.inflateReset2=S,s.inflateResetKeep=b,s.inflateInit=function(P){return k(P,15)},s.inflateInit2=k,s.inflate=function(P,W){var N,U,K,G,X,H,B,L,F,V,Y,ie,Q,D,R,J,Z,ee,re,he,O,ae,q,I,T=0,$=new i.Buf8(4),se=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!P||!P.state||!P.output||!P.input&&P.avail_in!==0)return p;(N=P.state).mode===12&&(N.mode=13),X=P.next_out,K=P.output,B=P.avail_out,G=P.next_in,U=P.input,H=P.avail_in,L=N.hold,F=N.bits,V=H,Y=B,ae=f;e:for(;;)switch(N.mode){case m:if(N.wrap===0){N.mode=13;break}for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(2&N.wrap&&L===35615){$[N.check=0]=255&L,$[1]=L>>>8&255,N.check=o(N.check,$,2,0),F=L=0,N.mode=2;break}if(N.flags=0,N.head&&(N.head.done=!1),!(1&N.wrap)||(((255&L)<<8)+(L>>8))%31){P.msg="incorrect header check",N.mode=30;break}if((15&L)!=8){P.msg="unknown compression method",N.mode=30;break}if(F-=4,O=8+(15&(L>>>=4)),N.wbits===0)N.wbits=O;else if(O>N.wbits){P.msg="invalid window size",N.mode=30;break}N.dmax=1<<O,P.adler=N.check=1,N.mode=512&L?10:12,F=L=0;break;case 2:for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(N.flags=L,(255&N.flags)!=8){P.msg="unknown compression method",N.mode=30;break}if(57344&N.flags){P.msg="unknown header flags set",N.mode=30;break}N.head&&(N.head.text=L>>8&1),512&N.flags&&($[0]=255&L,$[1]=L>>>8&255,N.check=o(N.check,$,2,0)),F=L=0,N.mode=3;case 3:for(;F<32;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.head&&(N.head.time=L),512&N.flags&&($[0]=255&L,$[1]=L>>>8&255,$[2]=L>>>16&255,$[3]=L>>>24&255,N.check=o(N.check,$,4,0)),F=L=0,N.mode=4;case 4:for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.head&&(N.head.xflags=255&L,N.head.os=L>>8),512&N.flags&&($[0]=255&L,$[1]=L>>>8&255,N.check=o(N.check,$,2,0)),F=L=0,N.mode=5;case 5:if(1024&N.flags){for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.length=L,N.head&&(N.head.extra_len=L),512&N.flags&&($[0]=255&L,$[1]=L>>>8&255,N.check=o(N.check,$,2,0)),F=L=0}else N.head&&(N.head.extra=null);N.mode=6;case 6:if(1024&N.flags&&(H<(ie=N.length)&&(ie=H),ie&&(N.head&&(O=N.head.extra_len-N.length,N.head.extra||(N.head.extra=new Array(N.head.extra_len)),i.arraySet(N.head.extra,U,G,ie,O)),512&N.flags&&(N.check=o(N.check,U,ie,G)),H-=ie,G+=ie,N.length-=ie),N.length))break e;N.length=0,N.mode=7;case 7:if(2048&N.flags){if(H===0)break e;for(ie=0;O=U[G+ie++],N.head&&O&&N.length<65536&&(N.head.name+=String.fromCharCode(O)),O&&ie<H;);if(512&N.flags&&(N.check=o(N.check,U,ie,G)),H-=ie,G+=ie,O)break e}else N.head&&(N.head.name=null);N.length=0,N.mode=8;case 8:if(4096&N.flags){if(H===0)break e;for(ie=0;O=U[G+ie++],N.head&&O&&N.length<65536&&(N.head.comment+=String.fromCharCode(O)),O&&ie<H;);if(512&N.flags&&(N.check=o(N.check,U,ie,G)),H-=ie,G+=ie,O)break e}else N.head&&(N.head.comment=null);N.mode=9;case 9:if(512&N.flags){for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(L!==(65535&N.check)){P.msg="header crc mismatch",N.mode=30;break}F=L=0}N.head&&(N.head.hcrc=N.flags>>9&1,N.head.done=!0),P.adler=N.check=0,N.mode=12;break;case 10:for(;F<32;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}P.adler=N.check=y(L),F=L=0,N.mode=11;case 11:if(N.havedict===0)return P.next_out=X,P.avail_out=B,P.next_in=G,P.avail_in=H,N.hold=L,N.bits=F,2;P.adler=N.check=1,N.mode=12;case 12:if(W===5||W===6)break e;case 13:if(N.last){L>>>=7&F,F-=7&F,N.mode=27;break}for(;F<3;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}switch(N.last=1&L,F-=1,3&(L>>>=1)){case 0:N.mode=14;break;case 1:if(M(N),N.mode=20,W!==6)break;L>>>=2,F-=2;break e;case 2:N.mode=17;break;case 3:P.msg="invalid block type",N.mode=30}L>>>=2,F-=2;break;case 14:for(L>>>=7&F,F-=7&F;F<32;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if((65535&L)!=(L>>>16^65535)){P.msg="invalid stored block lengths",N.mode=30;break}if(N.length=65535&L,F=L=0,N.mode=15,W===6)break e;case 15:N.mode=16;case 16:if(ie=N.length){if(H<ie&&(ie=H),B<ie&&(ie=B),ie===0)break e;i.arraySet(K,U,G,ie,X),H-=ie,G+=ie,B-=ie,X+=ie,N.length-=ie;break}N.mode=12;break;case 17:for(;F<14;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(N.nlen=257+(31&L),L>>>=5,F-=5,N.ndist=1+(31&L),L>>>=5,F-=5,N.ncode=4+(15&L),L>>>=4,F-=4,286<N.nlen||30<N.ndist){P.msg="too many length or distance symbols",N.mode=30;break}N.have=0,N.mode=18;case 18:for(;N.have<N.ncode;){for(;F<3;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.lens[se[N.have++]]=7&L,L>>>=3,F-=3}for(;N.have<19;)N.lens[se[N.have++]]=0;if(N.lencode=N.lendyn,N.lenbits=7,q={bits:N.lenbits},ae=u(0,N.lens,0,19,N.lencode,0,N.work,q),N.lenbits=q.bits,ae){P.msg="invalid code lengths set",N.mode=30;break}N.have=0,N.mode=19;case 19:for(;N.have<N.nlen+N.ndist;){for(;J=(T=N.lencode[L&(1<<N.lenbits)-1])>>>16&255,Z=65535&T,!((R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(Z<16)L>>>=R,F-=R,N.lens[N.have++]=Z;else{if(Z===16){for(I=R+2;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(L>>>=R,F-=R,N.have===0){P.msg="invalid bit length repeat",N.mode=30;break}O=N.lens[N.have-1],ie=3+(3&L),L>>>=2,F-=2}else if(Z===17){for(I=R+3;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}F-=R,O=0,ie=3+(7&(L>>>=R)),L>>>=3,F-=3}else{for(I=R+7;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}F-=R,O=0,ie=11+(127&(L>>>=R)),L>>>=7,F-=7}if(N.have+ie>N.nlen+N.ndist){P.msg="invalid bit length repeat",N.mode=30;break}for(;ie--;)N.lens[N.have++]=O}}if(N.mode===30)break;if(N.lens[256]===0){P.msg="invalid code -- missing end-of-block",N.mode=30;break}if(N.lenbits=9,q={bits:N.lenbits},ae=u(d,N.lens,0,N.nlen,N.lencode,0,N.work,q),N.lenbits=q.bits,ae){P.msg="invalid literal/lengths set",N.mode=30;break}if(N.distbits=6,N.distcode=N.distdyn,q={bits:N.distbits},ae=u(h,N.lens,N.nlen,N.ndist,N.distcode,0,N.work,q),N.distbits=q.bits,ae){P.msg="invalid distances set",N.mode=30;break}if(N.mode=20,W===6)break e;case 20:N.mode=21;case 21:if(6<=H&&258<=B){P.next_out=X,P.avail_out=B,P.next_in=G,P.avail_in=H,N.hold=L,N.bits=F,c(P,Y),X=P.next_out,K=P.output,B=P.avail_out,G=P.next_in,U=P.input,H=P.avail_in,L=N.hold,F=N.bits,N.mode===12&&(N.back=-1);break}for(N.back=0;J=(T=N.lencode[L&(1<<N.lenbits)-1])>>>16&255,Z=65535&T,!((R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(J&&!(240&J)){for(ee=R,re=J,he=Z;J=(T=N.lencode[he+((L&(1<<ee+re)-1)>>ee)])>>>16&255,Z=65535&T,!(ee+(R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}L>>>=ee,F-=ee,N.back+=ee}if(L>>>=R,F-=R,N.back+=R,N.length=Z,J===0){N.mode=26;break}if(32&J){N.back=-1,N.mode=12;break}if(64&J){P.msg="invalid literal/length code",N.mode=30;break}N.extra=15&J,N.mode=22;case 22:if(N.extra){for(I=N.extra;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.length+=L&(1<<N.extra)-1,L>>>=N.extra,F-=N.extra,N.back+=N.extra}N.was=N.length,N.mode=23;case 23:for(;J=(T=N.distcode[L&(1<<N.distbits)-1])>>>16&255,Z=65535&T,!((R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(!(240&J)){for(ee=R,re=J,he=Z;J=(T=N.distcode[he+((L&(1<<ee+re)-1)>>ee)])>>>16&255,Z=65535&T,!(ee+(R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}L>>>=ee,F-=ee,N.back+=ee}if(L>>>=R,F-=R,N.back+=R,64&J){P.msg="invalid distance code",N.mode=30;break}N.offset=Z,N.extra=15&J,N.mode=24;case 24:if(N.extra){for(I=N.extra;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.offset+=L&(1<<N.extra)-1,L>>>=N.extra,F-=N.extra,N.back+=N.extra}if(N.offset>N.dmax){P.msg="invalid distance too far back",N.mode=30;break}N.mode=25;case 25:if(B===0)break e;if(ie=Y-B,N.offset>ie){if((ie=N.offset-ie)>N.whave&&N.sane){P.msg="invalid distance too far back",N.mode=30;break}Q=ie>N.wnext?(ie-=N.wnext,N.wsize-ie):N.wnext-ie,ie>N.length&&(ie=N.length),D=N.window}else D=K,Q=X-N.offset,ie=N.length;for(B<ie&&(ie=B),B-=ie,N.length-=ie;K[X++]=D[Q++],--ie;);N.length===0&&(N.mode=21);break;case 26:if(B===0)break e;K[X++]=N.length,B--,N.mode=21;break;case 27:if(N.wrap){for(;F<32;){if(H===0)break e;H--,L|=U[G++]<<F,F+=8}if(Y-=B,P.total_out+=Y,N.total+=Y,Y&&(P.adler=N.check=N.flags?o(N.check,K,Y,X-Y):a(N.check,K,Y,X-Y)),Y=B,(N.flags?L:y(L))!==N.check){P.msg="incorrect data check",N.mode=30;break}F=L=0}N.mode=28;case 28:if(N.wrap&&N.flags){for(;F<32;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(L!==(4294967295&N.total)){P.msg="incorrect length check",N.mode=30;break}F=L=0}N.mode=29;case 29:ae=1;break e;case 30:ae=-3;break e;case 31:return-4;case 32:default:return p}return P.next_out=X,P.avail_out=B,P.next_in=G,P.avail_in=H,N.hold=L,N.bits=F,(N.wsize||Y!==P.avail_out&&N.mode<30&&(N.mode<27||W!==4))&&z(P,P.output,P.next_out,Y-P.avail_out)?(N.mode=31,-4):(V-=P.avail_in,Y-=P.avail_out,P.total_in+=V,P.total_out+=Y,N.total+=Y,N.wrap&&Y&&(P.adler=N.check=N.flags?o(N.check,K,Y,P.next_out-Y):a(N.check,K,Y,P.next_out-Y)),P.data_type=N.bits+(N.last?64:0)+(N.mode===12?128:0)+(N.mode===20||N.mode===15?256:0),(V==0&&Y===0||W===4)&&ae===f&&(ae=-5),ae)},s.inflateEnd=function(P){if(!P||!P.state)return p;var W=P.state;return W.window&&(W.window=null),P.state=null,f},s.inflateGetHeader=function(P,W){var N;return P&&P.state&&2&(N=P.state).wrap?((N.head=W).done=!1,f):p},s.inflateSetDictionary=function(P,W){var N,U=W.length;return P&&P.state?(N=P.state).wrap!==0&&N.mode!==11?p:N.mode===11&&a(1,W,U,0)!==N.check?-3:z(P,W,U,U)?(N.mode=31,-4):(N.havedict=1,f):p},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(r,n,s){var i=r("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(d,h,f,p,m,g,x,y){var v,b,w,S,k,E,C,A,M,z=y.bits,P=0,W=0,N=0,U=0,K=0,G=0,X=0,H=0,B=0,L=0,F=null,V=0,Y=new i.Buf16(16),ie=new i.Buf16(16),Q=null,D=0;for(P=0;P<=15;P++)Y[P]=0;for(W=0;W<p;W++)Y[h[f+W]]++;for(K=z,U=15;1<=U&&Y[U]===0;U--);if(U<K&&(K=U),U===0)return m[g++]=20971520,m[g++]=20971520,y.bits=1,0;for(N=1;N<U&&Y[N]===0;N++);for(K<N&&(K=N),P=H=1;P<=15;P++)if(H<<=1,(H-=Y[P])<0)return-1;if(0<H&&(d===0||U!==1))return-1;for(ie[1]=0,P=1;P<15;P++)ie[P+1]=ie[P]+Y[P];for(W=0;W<p;W++)h[f+W]!==0&&(x[ie[h[f+W]]++]=W);if(E=d===0?(F=Q=x,19):d===1?(F=a,V-=257,Q=o,D-=257,256):(F=c,Q=u,-1),P=N,k=g,X=W=L=0,w=-1,S=(B=1<<(G=K))-1,d===1&&852<B||d===2&&592<B)return 1;for(;;){for(C=P-X,M=x[W]<E?(A=0,x[W]):x[W]>E?(A=Q[D+x[W]],F[V+x[W]]):(A=96,0),v=1<<P-X,N=b=1<<G;m[k+(L>>X)+(b-=v)]=C<<24|A<<16|M|0,b!==0;);for(v=1<<P-1;L&v;)v>>=1;if(v!==0?(L&=v-1,L+=v):L=0,W++,--Y[P]==0){if(P===U)break;P=h[f+x[W]]}if(K<P&&(L&S)!==w){for(X===0&&(X=K),k+=N,H=1<<(G=P-X);G+X<U&&!((H-=Y[G+X])<=0);)G++,H<<=1;if(B+=1<<G,d===1&&852<B||d===2&&592<B)return 1;m[w=L&S]=K<<24|G<<16|k-g|0}}return L!==0&&(m[k+L]=P-X<<24|64<<16|0),y.bits=K,0}},{"../utils/common":41}],51:[function(r,n,s){n.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(r,n,s){var i=r("../utils/common"),a=0,o=1;function c(T){for(var $=T.length;0<=--$;)T[$]=0}var u=0,d=29,h=256,f=h+1+d,p=30,m=19,g=2*f+1,x=15,y=16,v=7,b=256,w=16,S=17,k=18,E=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],C=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],z=new Array(2*(f+2));c(z);var P=new Array(2*p);c(P);var W=new Array(512);c(W);var N=new Array(256);c(N);var U=new Array(d);c(U);var K,G,X,H=new Array(p);function B(T,$,se,ue,ne){this.static_tree=T,this.extra_bits=$,this.extra_base=se,this.elems=ue,this.max_length=ne,this.has_stree=T&&T.length}function L(T,$){this.dyn_tree=T,this.max_code=0,this.stat_desc=$}function F(T){return T<256?W[T]:W[256+(T>>>7)]}function V(T,$){T.pending_buf[T.pending++]=255&$,T.pending_buf[T.pending++]=$>>>8&255}function Y(T,$,se){T.bi_valid>y-se?(T.bi_buf|=$<<T.bi_valid&65535,V(T,T.bi_buf),T.bi_buf=$>>y-T.bi_valid,T.bi_valid+=se-y):(T.bi_buf|=$<<T.bi_valid&65535,T.bi_valid+=se)}function ie(T,$,se){Y(T,se[2*$],se[2*$+1])}function Q(T,$){for(var se=0;se|=1&T,T>>>=1,se<<=1,0<--$;);return se>>>1}function D(T,$,se){var ue,ne,me=new Array(x+1),ve=0;for(ue=1;ue<=x;ue++)me[ue]=ve=ve+se[ue-1]<<1;for(ne=0;ne<=$;ne++){var xe=T[2*ne+1];xe!==0&&(T[2*ne]=Q(me[xe]++,xe))}}function R(T){var $;for($=0;$<f;$++)T.dyn_ltree[2*$]=0;for($=0;$<p;$++)T.dyn_dtree[2*$]=0;for($=0;$<m;$++)T.bl_tree[2*$]=0;T.dyn_ltree[2*b]=1,T.opt_len=T.static_len=0,T.last_lit=T.matches=0}function J(T){8<T.bi_valid?V(T,T.bi_buf):0<T.bi_valid&&(T.pending_buf[T.pending++]=T.bi_buf),T.bi_buf=0,T.bi_valid=0}function Z(T,$,se,ue){var ne=2*$,me=2*se;return T[ne]<T[me]||T[ne]===T[me]&&ue[$]<=ue[se]}function ee(T,$,se){for(var ue=T.heap[se],ne=se<<1;ne<=T.heap_len&&(ne<T.heap_len&&Z($,T.heap[ne+1],T.heap[ne],T.depth)&&ne++,!Z($,ue,T.heap[ne],T.depth));)T.heap[se]=T.heap[ne],se=ne,ne<<=1;T.heap[se]=ue}function re(T,$,se){var ue,ne,me,ve,xe=0;if(T.last_lit!==0)for(;ue=T.pending_buf[T.d_buf+2*xe]<<8|T.pending_buf[T.d_buf+2*xe+1],ne=T.pending_buf[T.l_buf+xe],xe++,ue===0?ie(T,ne,$):(ie(T,(me=N[ne])+h+1,$),(ve=E[me])!==0&&Y(T,ne-=U[me],ve),ie(T,me=F(--ue),se),(ve=C[me])!==0&&Y(T,ue-=H[me],ve)),xe<T.last_lit;);ie(T,b,$)}function he(T,$){var se,ue,ne,me=$.dyn_tree,ve=$.stat_desc.static_tree,xe=$.stat_desc.has_stree,oe=$.stat_desc.elems,de=-1;for(T.heap_len=0,T.heap_max=g,se=0;se<oe;se++)me[2*se]!==0?(T.heap[++T.heap_len]=de=se,T.depth[se]=0):me[2*se+1]=0;for(;T.heap_len<2;)me[2*(ne=T.heap[++T.heap_len]=de<2?++de:0)]=1,T.depth[ne]=0,T.opt_len--,xe&&(T.static_len-=ve[2*ne+1]);for($.max_code=de,se=T.heap_len>>1;1<=se;se--)ee(T,me,se);for(ne=oe;se=T.heap[1],T.heap[1]=T.heap[T.heap_len--],ee(T,me,1),ue=T.heap[1],T.heap[--T.heap_max]=se,T.heap[--T.heap_max]=ue,me[2*ne]=me[2*se]+me[2*ue],T.depth[ne]=(T.depth[se]>=T.depth[ue]?T.depth[se]:T.depth[ue])+1,me[2*se+1]=me[2*ue+1]=ne,T.heap[1]=ne++,ee(T,me,1),2<=T.heap_len;);T.heap[--T.heap_max]=T.heap[1],function(ge,Se){var ke,Ne,qe,Ae,fe,Te,Pe=Se.dyn_tree,tt=Se.max_code,wt=Se.stat_desc.static_tree,Ee=Se.stat_desc.has_stree,nt=Se.stat_desc.extra_bits,rt=Se.stat_desc.extra_base,Ze=Se.stat_desc.max_length,we=0;for(Ae=0;Ae<=x;Ae++)ge.bl_count[Ae]=0;for(Pe[2*ge.heap[ge.heap_max]+1]=0,ke=ge.heap_max+1;ke<g;ke++)Ze<(Ae=Pe[2*Pe[2*(Ne=ge.heap[ke])+1]+1]+1)&&(Ae=Ze,we++),Pe[2*Ne+1]=Ae,tt<Ne||(ge.bl_count[Ae]++,fe=0,rt<=Ne&&(fe=nt[Ne-rt]),Te=Pe[2*Ne],ge.opt_len+=Te*(Ae+fe),Ee&&(ge.static_len+=Te*(wt[2*Ne+1]+fe)));if(we!==0){do{for(Ae=Ze-1;ge.bl_count[Ae]===0;)Ae--;ge.bl_count[Ae]--,ge.bl_count[Ae+1]+=2,ge.bl_count[Ze]--,we-=2}while(0<we);for(Ae=Ze;Ae!==0;Ae--)for(Ne=ge.bl_count[Ae];Ne!==0;)tt<(qe=ge.heap[--ke])||(Pe[2*qe+1]!==Ae&&(ge.opt_len+=(Ae-Pe[2*qe+1])*Pe[2*qe],Pe[2*qe+1]=Ae),Ne--)}}(T,$),D(me,de,T.bl_count)}function O(T,$,se){var ue,ne,me=-1,ve=$[1],xe=0,oe=7,de=4;for(ve===0&&(oe=138,de=3),$[2*(se+1)+1]=65535,ue=0;ue<=se;ue++)ne=ve,ve=$[2*(ue+1)+1],++xe<oe&&ne===ve||(xe<de?T.bl_tree[2*ne]+=xe:ne!==0?(ne!==me&&T.bl_tree[2*ne]++,T.bl_tree[2*w]++):xe<=10?T.bl_tree[2*S]++:T.bl_tree[2*k]++,me=ne,de=(xe=0)===ve?(oe=138,3):ne===ve?(oe=6,3):(oe=7,4))}function ae(T,$,se){var ue,ne,me=-1,ve=$[1],xe=0,oe=7,de=4;for(ve===0&&(oe=138,de=3),ue=0;ue<=se;ue++)if(ne=ve,ve=$[2*(ue+1)+1],!(++xe<oe&&ne===ve)){if(xe<de)for(;ie(T,ne,T.bl_tree),--xe!=0;);else ne!==0?(ne!==me&&(ie(T,ne,T.bl_tree),xe--),ie(T,w,T.bl_tree),Y(T,xe-3,2)):xe<=10?(ie(T,S,T.bl_tree),Y(T,xe-3,3)):(ie(T,k,T.bl_tree),Y(T,xe-11,7));me=ne,de=(xe=0)===ve?(oe=138,3):ne===ve?(oe=6,3):(oe=7,4)}}c(H);var q=!1;function I(T,$,se,ue){Y(T,(u<<1)+(ue?1:0),3),function(ne,me,ve,xe){J(ne),V(ne,ve),V(ne,~ve),i.arraySet(ne.pending_buf,ne.window,me,ve,ne.pending),ne.pending+=ve}(T,$,se)}s._tr_init=function(T){q||(function(){var $,se,ue,ne,me,ve=new Array(x+1);for(ne=ue=0;ne<d-1;ne++)for(U[ne]=ue,$=0;$<1<<E[ne];$++)N[ue++]=ne;for(N[ue-1]=ne,ne=me=0;ne<16;ne++)for(H[ne]=me,$=0;$<1<<C[ne];$++)W[me++]=ne;for(me>>=7;ne<p;ne++)for(H[ne]=me<<7,$=0;$<1<<C[ne]-7;$++)W[256+me++]=ne;for(se=0;se<=x;se++)ve[se]=0;for($=0;$<=143;)z[2*$+1]=8,$++,ve[8]++;for(;$<=255;)z[2*$+1]=9,$++,ve[9]++;for(;$<=279;)z[2*$+1]=7,$++,ve[7]++;for(;$<=287;)z[2*$+1]=8,$++,ve[8]++;for(D(z,f+1,ve),$=0;$<p;$++)P[2*$+1]=5,P[2*$]=Q($,5);K=new B(z,E,h+1,f,x),G=new B(P,C,0,p,x),X=new B(new Array(0),A,0,m,v)}(),q=!0),T.l_desc=new L(T.dyn_ltree,K),T.d_desc=new L(T.dyn_dtree,G),T.bl_desc=new L(T.bl_tree,X),T.bi_buf=0,T.bi_valid=0,R(T)},s._tr_stored_block=I,s._tr_flush_block=function(T,$,se,ue){var ne,me,ve=0;0<T.level?(T.strm.data_type===2&&(T.strm.data_type=function(xe){var oe,de=4093624447;for(oe=0;oe<=31;oe++,de>>>=1)if(1&de&&xe.dyn_ltree[2*oe]!==0)return a;if(xe.dyn_ltree[18]!==0||xe.dyn_ltree[20]!==0||xe.dyn_ltree[26]!==0)return o;for(oe=32;oe<h;oe++)if(xe.dyn_ltree[2*oe]!==0)return o;return a}(T)),he(T,T.l_desc),he(T,T.d_desc),ve=function(xe){var oe;for(O(xe,xe.dyn_ltree,xe.l_desc.max_code),O(xe,xe.dyn_dtree,xe.d_desc.max_code),he(xe,xe.bl_desc),oe=m-1;3<=oe&&xe.bl_tree[2*M[oe]+1]===0;oe--);return xe.opt_len+=3*(oe+1)+5+5+4,oe}(T),ne=T.opt_len+3+7>>>3,(me=T.static_len+3+7>>>3)<=ne&&(ne=me)):ne=me=se+5,se+4<=ne&&$!==-1?I(T,$,se,ue):T.strategy===4||me===ne?(Y(T,2+(ue?1:0),3),re(T,z,P)):(Y(T,4+(ue?1:0),3),function(xe,oe,de,ge){var Se;for(Y(xe,oe-257,5),Y(xe,de-1,5),Y(xe,ge-4,4),Se=0;Se<ge;Se++)Y(xe,xe.bl_tree[2*M[Se]+1],3);ae(xe,xe.dyn_ltree,oe-1),ae(xe,xe.dyn_dtree,de-1)}(T,T.l_desc.max_code+1,T.d_desc.max_code+1,ve+1),re(T,T.dyn_ltree,T.dyn_dtree)),R(T),ue&&J(T)},s._tr_tally=function(T,$,se){return T.pending_buf[T.d_buf+2*T.last_lit]=$>>>8&255,T.pending_buf[T.d_buf+2*T.last_lit+1]=255&$,T.pending_buf[T.l_buf+T.last_lit]=255&se,T.last_lit++,$===0?T.dyn_ltree[2*se]++:(T.matches++,$--,T.dyn_ltree[2*(N[se]+h+1)]++,T.dyn_dtree[2*F($)]++),T.last_lit===T.lit_bufsize-1},s._tr_align=function(T){Y(T,2,3),ie(T,b,z),function($){$.bi_valid===16?(V($,$.bi_buf),$.bi_buf=0,$.bi_valid=0):8<=$.bi_valid&&($.pending_buf[$.pending++]=255&$.bi_buf,$.bi_buf>>=8,$.bi_valid-=8)}(T)}},{"../utils/common":41}],53:[function(r,n,s){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,s){(function(i){(function(a,o){if(!a.setImmediate){var c,u,d,h,f=1,p={},m=!1,g=a.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(a);x=x&&x.setTimeout?x:a,c={}.toString.call(a.process)==="[object process]"?function(w){process.nextTick(function(){v(w)})}:function(){if(a.postMessage&&!a.importScripts){var w=!0,S=a.onmessage;return a.onmessage=function(){w=!1},a.postMessage("","*"),a.onmessage=S,w}}()?(h="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",b,!1):a.attachEvent("onmessage",b),function(w){a.postMessage(h+w,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(w){v(w.data)},function(w){d.port2.postMessage(w)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(w){var S=g.createElement("script");S.onreadystatechange=function(){v(w),S.onreadystatechange=null,u.removeChild(S),S=null},u.appendChild(S)}):function(w){setTimeout(v,0,w)},x.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var S=new Array(arguments.length-1),k=0;k<S.length;k++)S[k]=arguments[k+1];var E={callback:w,args:S};return p[f]=E,c(f),f++},x.clearImmediate=y}function y(w){delete p[w]}function v(w){if(m)setTimeout(v,0,w);else{var S=p[w];if(S){m=!0;try{(function(k){var E=k.callback,C=k.args;switch(C.length){case 0:E();break;case 1:E(C[0]);break;case 2:E(C[0],C[1]);break;case 3:E(C[0],C[1],C[2]);break;default:E.apply(o,C)}})(S)}finally{y(w),m=!1}}}}function b(w){w.source===a&&typeof w.data=="string"&&w.data.indexOf(h)===0&&v(+w.data.slice(h.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof dn<"u"?dn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(pSe);var Bjt=pSe.exports;const zjt=cr(Bjt);var mSe={exports:{}};/* @license
Papa Parse
v5.5.3
https://github.com/mholt/PapaParse
License: MIT
*/(function(t,e){((r,n)=>{t.exports=n()})(dn,function r(){var n=typeof self<"u"?self:typeof window<"u"?window:n!==void 0?n:{},s,i=!n.document&&!!n.postMessage,a=n.IS_PAPA_WORKER||!1,o={},c=0,u={};function d(C){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(A){var M=S(A);M.chunkSize=parseInt(M.chunkSize),A.step||A.chunk||(M.chunkSize=null),this._handle=new g(M),(this._handle.streamer=this)._config=M}).call(this,C),this.parseChunk=function(A,M){var z=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<z){let W=this._config.newline;W||(P=this._config.quoteChar||'"',W=this._handle.guessLineEndings(A,P)),A=[...A.split(W).slice(z)].join(W)}this.isFirstChunk&&E(this._config.beforeFirstChunk)&&(P=this._config.beforeFirstChunk(A))!==void 0&&(A=P),this.isFirstChunk=!1,this._halted=!1;var z=this._partialLine+A,P=(this._partialLine="",this._handle.parse(z,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(A=P.meta.cursor,z=(this._finished||(this._partialLine=z.substring(A-this._baseIndex),this._baseIndex=A),P&&P.data&&(this._rowCount+=P.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),a)n.postMessage({results:P,workerId:u.WORKER_ID,finished:z});else if(E(this._config.chunk)&&!M){if(this._config.chunk(P,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=P=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(P.data),this._completeResults.errors=this._completeResults.errors.concat(P.errors),this._completeResults.meta=P.meta),this._completed||!z||!E(this._config.complete)||P&&P.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),z||P&&P.meta.paused||this._nextChunk(),P}this._halted=!0},this._sendError=function(A){E(this._config.error)?this._config.error(A):a&&this._config.error&&n.postMessage({workerId:u.WORKER_ID,error:A,finished:!1})}}function h(C){var A;(C=C||{}).chunkSize||(C.chunkSize=u.RemoteChunkSize),d.call(this,C),this._nextChunk=i?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(M){this._input=M,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(A=new XMLHttpRequest,this._config.withCredentials&&(A.withCredentials=this._config.withCredentials),i||(A.onload=k(this._chunkLoaded,this),A.onerror=k(this._chunkError,this)),A.open(this._config.downloadRequestBody?"POST":"GET",this._input,!i),this._config.downloadRequestHeaders){var M,z=this._config.downloadRequestHeaders;for(M in z)A.setRequestHeader(M,z[M])}var P;this._config.chunkSize&&(P=this._start+this._config.chunkSize-1,A.setRequestHeader("Range","bytes="+this._start+"-"+P));try{A.send(this._config.downloadRequestBody)}catch(W){this._chunkError(W.message)}i&&A.status===0&&this._chunkError()}},this._chunkLoaded=function(){A.readyState===4&&(A.status<200||400<=A.status?this._chunkError():(this._start+=this._config.chunkSize||A.responseText.length,this._finished=!this._config.chunkSize||this._start>=(M=>(M=M.getResponseHeader("Content-Range"))!==null?parseInt(M.substring(M.lastIndexOf("/")+1)):-1)(A),this.parseChunk(A.responseText)))},this._chunkError=function(M){M=A.statusText||M,this._sendError(new Error(M))}}function f(C){(C=C||{}).chunkSize||(C.chunkSize=u.LocalChunkSize),d.call(this,C);var A,M,z=typeof FileReader<"u";this.stream=function(P){this._input=P,M=P.slice||P.webkitSlice||P.mozSlice,z?((A=new FileReader).onload=k(this._chunkLoaded,this),A.onerror=k(this._chunkError,this)):A=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var P=this._input,W=(this._config.chunkSize&&(W=Math.min(this._start+this._config.chunkSize,this._input.size),P=M.call(P,this._start,W)),A.readAsText(P,this._config.encoding));z||this._chunkLoaded({target:{result:W}})},this._chunkLoaded=function(P){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(P.target.result)},this._chunkError=function(){this._sendError(A.error)}}function p(C){var A;d.call(this,C=C||{}),this.stream=function(M){return A=M,this._nextChunk()},this._nextChunk=function(){var M,z;if(!this._finished)return M=this._config.chunkSize,A=M?(z=A.substring(0,M),A.substring(M)):(z=A,""),this._finished=!A,this.parseChunk(z)}}function m(C){d.call(this,C=C||{});var A=[],M=!0,z=!1;this.pause=function(){d.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){d.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(P){this._input=P,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){z&&A.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),A.length?this.parseChunk(A.shift()):M=!0},this._streamData=k(function(P){try{A.push(typeof P=="string"?P:P.toString(this._config.encoding)),M&&(M=!1,this._checkIsFinished(),this.parseChunk(A.shift()))}catch(W){this._streamError(W)}},this),this._streamError=k(function(P){this._streamCleanUp(),this._sendError(P)},this),this._streamEnd=k(function(){this._streamCleanUp(),z=!0,this._streamData("")},this),this._streamCleanUp=k(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function g(C){var A,M,z,P,W=Math.pow(2,53),N=-W,U=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,K=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,G=this,X=0,H=0,B=!1,L=!1,F=[],V={data:[],errors:[],meta:{}};function Y(R){return C.skipEmptyLines==="greedy"?R.join("").trim()==="":R.length===1&&R[0].length===0}function ie(){if(V&&z&&(D("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+u.DefaultDelimiter+"'"),z=!1),C.skipEmptyLines&&(V.data=V.data.filter(function(ee){return!Y(ee)})),Q()){let ee=function(re,he){E(C.transformHeader)&&(re=C.transformHeader(re,he)),F.push(re)};if(V)if(Array.isArray(V.data[0])){for(var R=0;Q()&&R<V.data.length;R++)V.data[R].forEach(ee);V.data.splice(0,1)}else V.data.forEach(ee)}function J(ee,re){for(var he=C.header?{}:[],O=0;O<ee.length;O++){var ae=O,q=ee[O],q=((I,T)=>($=>(C.dynamicTypingFunction&&C.dynamicTyping[$]===void 0&&(C.dynamicTyping[$]=C.dynamicTypingFunction($)),(C.dynamicTyping[$]||C.dynamicTyping)===!0))(I)?T==="true"||T==="TRUE"||T!=="false"&&T!=="FALSE"&&(($=>{if(U.test($)&&($=parseFloat($),N<$&&$<W))return 1})(T)?parseFloat(T):K.test(T)?new Date(T):T===""?null:T):T)(ae=C.header?O>=F.length?"__parsed_extra":F[O]:ae,q=C.transform?C.transform(q,ae):q);ae==="__parsed_extra"?(he[ae]=he[ae]||[],he[ae].push(q)):he[ae]=q}return C.header&&(O>F.length?D("FieldMismatch","TooManyFields","Too many fields: expected "+F.length+" fields but parsed "+O,H+re):O<F.length&&D("FieldMismatch","TooFewFields","Too few fields: expected "+F.length+" fields but parsed "+O,H+re)),he}var Z;V&&(C.header||C.dynamicTyping||C.transform)&&(Z=1,!V.data.length||Array.isArray(V.data[0])?(V.data=V.data.map(J),Z=V.data.length):V.data=J(V.data,0),C.header&&V.meta&&(V.meta.fields=F),H+=Z)}function Q(){return C.header&&F.length===0}function D(R,J,Z,ee){R={type:R,code:J,message:Z},ee!==void 0&&(R.row=ee),V.errors.push(R)}E(C.step)&&(P=C.step,C.step=function(R){V=R,Q()?ie():(ie(),V.data.length!==0&&(X+=R.data.length,C.preview&&X>C.preview?M.abort():(V.data=V.data[0],P(V,G))))}),this.parse=function(R,J,Z){var ee=C.quoteChar||'"',ee=(C.newline||(C.newline=this.guessLineEndings(R,ee)),z=!1,C.delimiter?E(C.delimiter)&&(C.delimiter=C.delimiter(R),V.meta.delimiter=C.delimiter):((ee=((re,he,O,ae,q)=>{var I,T,$,se;q=q||[","," ","|",";",u.RECORD_SEP,u.UNIT_SEP];for(var ue=0;ue<q.length;ue++){for(var ne,me=q[ue],ve=0,xe=0,oe=0,de=($=void 0,new y({comments:ae,delimiter:me,newline:he,preview:10}).parse(re)),ge=0;ge<de.data.length;ge++)O&&Y(de.data[ge])?oe++:(ne=de.data[ge].length,xe+=ne,$===void 0?$=ne:0<ne&&(ve+=Math.abs(ne-$),$=ne));0<de.data.length&&(xe/=de.data.length-oe),(T===void 0||ve<=T)&&(se===void 0||se<xe)&&1.99<xe&&(T=ve,I=me,se=xe)}return{successful:!!(C.delimiter=I),bestDelimiter:I}})(R,C.newline,C.skipEmptyLines,C.comments,C.delimitersToGuess)).successful?C.delimiter=ee.bestDelimiter:(z=!0,C.delimiter=u.DefaultDelimiter),V.meta.delimiter=C.delimiter),S(C));return C.preview&&C.header&&ee.preview++,A=R,M=new y(ee),V=M.parse(A,J,Z),ie(),B?{meta:{paused:!0}}:V||{meta:{paused:!1}}},this.paused=function(){return B},this.pause=function(){B=!0,M.abort(),A=E(C.chunk)?"":A.substring(M.getCharIndex())},this.resume=function(){G.streamer._halted?(B=!1,G.streamer.parseChunk(A,!0)):setTimeout(G.resume,3)},this.aborted=function(){return L},this.abort=function(){L=!0,M.abort(),V.meta.aborted=!0,E(C.complete)&&C.complete(V),A=""},this.guessLineEndings=function(re,ee){re=re.substring(0,1048576);var ee=new RegExp(x(ee)+"([^]*?)"+x(ee),"gm"),Z=(re=re.replace(ee,"")).split("\r"),ee=re.split(`
`),re=1<ee.length&&ee[0].length<Z[0].length;if(Z.length===1||re)return`
`;for(var he=0,O=0;O<Z.length;O++)Z[O][0]===`
`&&he++;return he>=Z.length/2?`\r
`:"\r"}}function x(C){return C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function y(C){var A=(C=C||{}).delimiter,M=C.newline,z=C.comments,P=C.step,W=C.preview,N=C.fastMode,U=null,K=!1,G=C.quoteChar==null?'"':C.quoteChar,X=G;if(C.escapeChar!==void 0&&(X=C.escapeChar),(typeof A!="string"||-1<u.BAD_DELIMITERS.indexOf(A))&&(A=","),z===A)throw new Error("Comment character same as delimiter");z===!0?z="#":(typeof z!="string"||-1<u.BAD_DELIMITERS.indexOf(z))&&(z=!1),M!==`
`&&M!=="\r"&&M!==`\r
`&&(M=`
`);var H=0,B=!1;this.parse=function(L,F,V){if(typeof L!="string")throw new Error("Input must be a string");var Y=L.length,ie=A.length,Q=M.length,D=z.length,R=E(P),J=[],Z=[],ee=[],re=H=0;if(!L)return ve();if(N||N!==!1&&L.indexOf(G)===-1){for(var he=L.split(M),O=0;O<he.length;O++){if(ee=he[O],H+=ee.length,O!==he.length-1)H+=M.length;else if(V)return ve();if(!z||ee.substring(0,D)!==z){if(R){if(J=[],se(ee.split(A)),xe(),B)return ve()}else se(ee.split(A));if(W&&W<=O)return J=J.slice(0,W),ve(!0)}}return ve()}for(var ae=L.indexOf(A,H),q=L.indexOf(M,H),I=new RegExp(x(X)+x(G),"g"),T=L.indexOf(G,H);;)if(L[H]===G)for(T=H,H++;;){if((T=L.indexOf(G,T+1))===-1)return V||Z.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:J.length,index:H}),ne();if(T===Y-1)return ne(L.substring(H,T).replace(I,G));if(G===X&&L[T+1]===X)T++;else if(G===X||T===0||L[T-1]!==X){ae!==-1&&ae<T+1&&(ae=L.indexOf(A,T+1));var $=ue((q=q!==-1&&q<T+1?L.indexOf(M,T+1):q)===-1?ae:Math.min(ae,q));if(L.substr(T+1+$,ie)===A){ee.push(L.substring(H,T).replace(I,G)),L[H=T+1+$+ie]!==G&&(T=L.indexOf(G,H)),ae=L.indexOf(A,H),q=L.indexOf(M,H);break}if($=ue(q),L.substring(T+1+$,T+1+$+Q)===M){if(ee.push(L.substring(H,T).replace(I,G)),me(T+1+$+Q),ae=L.indexOf(A,H),T=L.indexOf(G,H),R&&(xe(),B))return ve();if(W&&J.length>=W)return ve(!0);break}Z.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:J.length,index:H}),T++}}else if(z&&ee.length===0&&L.substring(H,H+D)===z){if(q===-1)return ve();H=q+Q,q=L.indexOf(M,H),ae=L.indexOf(A,H)}else if(ae!==-1&&(ae<q||q===-1))ee.push(L.substring(H,ae)),H=ae+ie,ae=L.indexOf(A,H);else{if(q===-1)break;if(ee.push(L.substring(H,q)),me(q+Q),R&&(xe(),B))return ve();if(W&&J.length>=W)return ve(!0)}return ne();function se(oe){J.push(oe),re=H}function ue(oe){var de=0;return de=oe!==-1&&(oe=L.substring(T+1,oe))&&oe.trim()===""?oe.length:de}function ne(oe){return V||(oe===void 0&&(oe=L.substring(H)),ee.push(oe),H=Y,se(ee),R&&xe()),ve()}function me(oe){H=oe,se(ee),ee=[],q=L.indexOf(M,H)}function ve(oe){if(C.header&&!F&&J.length&&!K){var de=J[0],ge=Object.create(null),Se=new Set(de);let ke=!1;for(let Ne=0;Ne<de.length;Ne++){let qe=de[Ne];if(ge[qe=E(C.transformHeader)?C.transformHeader(qe,Ne):qe]){let Ae,fe=ge[qe];for(;Ae=qe+"_"+fe,fe++,Se.has(Ae););Se.add(Ae),de[Ne]=Ae,ge[qe]++,ke=!0,(U=U===null?{}:U)[Ae]=qe}else ge[qe]=1,de[Ne]=qe;Se.add(qe)}ke&&console.warn("Duplicate headers found and renamed."),K=!0}return{data:J,errors:Z,meta:{delimiter:A,linebreak:M,aborted:B,truncated:!!oe,cursor:re+(F||0),renamedHeaders:U}}}function xe(){P(ve()),J=[],Z=[]}},this.abort=function(){B=!0},this.getCharIndex=function(){return H}}function v(C){var A=C.data,M=o[A.workerId],z=!1;if(A.error)M.userError(A.error,A.file);else if(A.results&&A.results.data){var P={abort:function(){z=!0,b(A.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:w,resume:w};if(E(M.userStep)){for(var W=0;W<A.results.data.length&&(M.userStep({data:A.results.data[W],errors:A.results.errors,meta:A.results.meta},P),!z);W++);delete A.results}else E(M.userChunk)&&(M.userChunk(A.results,P,A.file),delete A.results)}A.finished&&!z&&b(A.workerId,A.results)}function b(C,A){var M=o[C];E(M.userComplete)&&M.userComplete(A),M.terminate(),delete o[C]}function w(){throw new Error("Not implemented.")}function S(C){if(typeof C!="object"||C===null)return C;var A,M=Array.isArray(C)?[]:{};for(A in C)M[A]=S(C[A]);return M}function k(C,A){return function(){C.apply(A,arguments)}}function E(C){return typeof C=="function"}return u.parse=function(C,A){var M=(A=A||{}).dynamicTyping||!1;if(E(M)&&(A.dynamicTypingFunction=M,M={}),A.dynamicTyping=M,A.transform=!!E(A.transform)&&A.transform,!A.worker||!u.WORKERS_SUPPORTED)return M=null,u.NODE_STREAM_INPUT,typeof C=="string"?(C=(z=>z.charCodeAt(0)!==65279?z:z.slice(1))(C),M=new(A.download?h:p)(A)):C.readable===!0&&E(C.read)&&E(C.on)?M=new m(A):(n.File&&C instanceof File||C instanceof Object)&&(M=new f(A)),M.stream(C);(M=(()=>{var z;return!!u.WORKERS_SUPPORTED&&(z=(()=>{var P=n.URL||n.webkitURL||null,W=r.toString();return u.BLOB_URL||(u.BLOB_URL=P.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",W,")();"],{type:"text/javascript"})))})(),(z=new n.Worker(z)).onmessage=v,z.id=c++,o[z.id]=z)})()).userStep=A.step,M.userChunk=A.chunk,M.userComplete=A.complete,M.userError=A.error,A.step=E(A.step),A.chunk=E(A.chunk),A.complete=E(A.complete),A.error=E(A.error),delete A.worker,M.postMessage({input:C,config:A,workerId:M.id})},u.unparse=function(C,A){var M=!1,z=!0,P=",",W=`\r
`,N='"',U=N+N,K=!1,G=null,X=!1,H=((()=>{if(typeof A=="object"){if(typeof A.delimiter!="string"||u.BAD_DELIMITERS.filter(function(F){return A.delimiter.indexOf(F)!==-1}).length||(P=A.delimiter),typeof A.quotes!="boolean"&&typeof A.quotes!="function"&&!Array.isArray(A.quotes)||(M=A.quotes),typeof A.skipEmptyLines!="boolean"&&typeof A.skipEmptyLines!="string"||(K=A.skipEmptyLines),typeof A.newline=="string"&&(W=A.newline),typeof A.quoteChar=="string"&&(N=A.quoteChar),typeof A.header=="boolean"&&(z=A.header),Array.isArray(A.columns)){if(A.columns.length===0)throw new Error("Option columns is empty");G=A.columns}A.escapeChar!==void 0&&(U=A.escapeChar+N),A.escapeFormulae instanceof RegExp?X=A.escapeFormulae:typeof A.escapeFormulae=="boolean"&&A.escapeFormulae&&(X=/^[=+\-@\t\r].*$/)}})(),new RegExp(x(N),"g"));if(typeof C=="string"&&(C=JSON.parse(C)),Array.isArray(C)){if(!C.length||Array.isArray(C[0]))return B(null,C,K);if(typeof C[0]=="object")return B(G||Object.keys(C[0]),C,K)}else if(typeof C=="object")return typeof C.data=="string"&&(C.data=JSON.parse(C.data)),Array.isArray(C.data)&&(C.fields||(C.fields=C.meta&&C.meta.fields||G),C.fields||(C.fields=Array.isArray(C.data[0])?C.fields:typeof C.data[0]=="object"?Object.keys(C.data[0]):[]),Array.isArray(C.data[0])||typeof C.data[0]=="object"||(C.data=[C.data])),B(C.fields||[],C.data||[],K);throw new Error("Unable to serialize unrecognized input");function B(F,V,Y){var ie="",Q=(typeof F=="string"&&(F=JSON.parse(F)),typeof V=="string"&&(V=JSON.parse(V)),Array.isArray(F)&&0<F.length),D=!Array.isArray(V[0]);if(Q&&z){for(var R=0;R<F.length;R++)0<R&&(ie+=P),ie+=L(F[R],R);0<V.length&&(ie+=W)}for(var J=0;J<V.length;J++){var Z=(Q?F:V[J]).length,ee=!1,re=Q?Object.keys(V[J]).length===0:V[J].length===0;if(Y&&!Q&&(ee=Y==="greedy"?V[J].join("").trim()==="":V[J].length===1&&V[J][0].length===0),Y==="greedy"&&Q){for(var he=[],O=0;O<Z;O++){var ae=D?F[O]:O;he.push(V[J][ae])}ee=he.join("").trim()===""}if(!ee){for(var q=0;q<Z;q++){0<q&&!re&&(ie+=P);var I=Q&&D?F[q]:q;ie+=L(V[J][I],q)}J<V.length-1&&(!Y||0<Z&&!re)&&(ie+=W)}}return ie}function L(F,V){var Y,ie;return F==null?"":F.constructor===Date?JSON.stringify(F).slice(1,25):(ie=!1,X&&typeof F=="string"&&X.test(F)&&(F="'"+F,ie=!0),Y=F.toString().replace(H,U),(ie=ie||M===!0||typeof M=="function"&&M(F,V)||Array.isArray(M)&&M[V]||((Q,D)=>{for(var R=0;R<D.length;R++)if(-1<Q.indexOf(D[R]))return!0;return!1})(Y,u.BAD_DELIMITERS)||-1<Y.indexOf(P)||Y.charAt(0)===" "||Y.charAt(Y.length-1)===" ")?N+Y+N:Y)}},u.RECORD_SEP="",u.UNIT_SEP="",u.BYTE_ORDER_MARK="\uFEFF",u.BAD_DELIMITERS=["\r",`
`,'"',u.BYTE_ORDER_MARK],u.WORKERS_SUPPORTED=!i&&!!n.Worker,u.NODE_STREAM_INPUT=1,u.LocalChunkSize=10485760,u.RemoteChunkSize=5242880,u.DefaultDelimiter=",",u.Parser=y,u.ParserHandle=g,u.NetworkStreamer=h,u.FileStreamer=f,u.StringStreamer=p,u.ReadableStreamStreamer=m,n.jQuery&&((s=n.jQuery).fn.parse=function(C){var A=C.config||{},M=[];return this.each(function(W){if(!(s(this).prop("tagName").toUpperCase()==="INPUT"&&s(this).attr("type").toLowerCase()==="file"&&n.FileReader)||!this.files||this.files.length===0)return!0;for(var N=0;N<this.files.length;N++)M.push({file:this.files[N],inputElem:this,instanceConfig:s.extend({},A)})}),z(),this;function z(){if(M.length===0)E(C.complete)&&C.complete();else{var W,N,U,K,G=M[0];if(E(C.before)){var X=C.before(G.file,G.inputElem);if(typeof X=="object"){if(X.action==="abort")return W="AbortError",N=G.file,U=G.inputElem,K=X.reason,void(E(C.error)&&C.error({name:W},N,U,K));if(X.action==="skip")return void P();typeof X.config=="object"&&(G.instanceConfig=s.extend(G.instanceConfig,X.config))}else if(X==="skip")return void P()}var H=G.instanceConfig.complete;G.instanceConfig.complete=function(B){E(H)&&H(B,G.file,G.inputElem),P()},u.parse(G.file,G.instanceConfig)}}function P(){M.splice(0,1),z()}}),a&&(n.onmessage=function(C){C=C.data,u.WORKER_ID===void 0&&C&&(u.WORKER_ID=C.workerId),typeof C.input=="string"?n.postMessage({workerId:u.WORKER_ID,results:u.parse(C.input,C.config),finished:!0}):(n.File&&C.input instanceof File||C.input instanceof Object)&&(C=u.parse(C.input,C.config))&&n.postMessage({workerId:u.WORKER_ID,results:C,finished:!0})}),(h.prototype=Object.create(d.prototype)).constructor=h,(f.prototype=Object.create(d.prototype)).constructor=f,(p.prototype=Object.create(p.prototype)).constructor=p,(m.prototype=Object.create(d.prototype)).constructor=m,u})})(mSe);var Ujt=mSe.exports;const rk=cr(Ujt);function Ha(t){return t?t.replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/__([^_]+)__/g,"$1").replace(/_([^_]+)_/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/^>\s+/gm,"").replace(/^[\*\+]\s+/gm,"- ").replace(/`([^`]+)`/g,"$1").replace(/```[\s\S]*?```/g,"").replace(/\n{3,}/g,`
`).trim():""}async function Hjt(t,e,r){var E,C,A,M,z;const[n,s,i,a,o,c,u,d,h,f,p,m,g,x]=await Promise.all([be.from("theses").select("*").eq("user_id",t),be.from("chapters").select("*"),be.from("sections").select("*"),be.from("documents").select("id, title, original_filename, doi, isbn, citation_apa, page_count, created_at").eq("user_id",t),be.from("summaries").select("id, document_id, summary_text, summary_mode, citation_style, created_at").eq("user_id",t),be.from("theory_backgrounds").select("id, document_id, title, theory_text, mode, citation_style, created_at").eq("user_id",t),be.from("methods").select("id, document_id, title, method_text, mode, citation_style, created_at").eq("user_id",t),be.from("research_setups").select("*").eq("user_id",t),be.from("topic_explorations").select("*").eq("user_id",t),be.from("codebooks").select("*").eq("user_id",t),be.from("codebook_categories").select("*"),be.from("interviews").select("*").eq("user_id",t),be.from("coded_segments").select("*").eq("user_id",t),be.from("qualitative_summaries").select("*").eq("user_id",t)]),y=((E=n.data)==null?void 0:E.map(P=>P.id))||[],v=((C=s.data)==null?void 0:C.filter(P=>y.includes(P.thesis_id)))||[],b=v.map(P=>P.id),w=((A=i.data)==null?void 0:A.filter(P=>b.includes(P.chapter_id)))||[],S=((M=f.data)==null?void 0:M.map(P=>P.id))||[],k=((z=p.data)==null?void 0:z.filter(P=>S.includes(P.codebook_id)))||[];return{exportDate:new Date().toISOString(),version:"1.0",user:{id:t,email:e,nickname:r},thesis:{theses:n.data||[],chapters:v,sections:w},library:{documents:a.data||[],summaries:o.data||[],theoryBackgrounds:c.data||[],methods:u.data||[]},research:{researchSetups:d.data||[],topicExplorations:h.data||[]},qualitative:{codebooks:f.data||[],codebookCategories:k,interviews:m.data||[],codedSegments:g.data||[],qualitativeSummaries:x.data||[]}}}function Vjt(t){const e=[`THESIS BACKUP
`];for(const r of t.thesis.theses){e.push(`${r.title}`),e.push(`Degree: ${r.degree==="bachelor"?"Bachelor":"Master"}`),r.due_date&&e.push(`Due Date: ${new Date(r.due_date).toLocaleDateString()}`),r.description&&e.push(`
${Ha(r.description)}`),e.push(`
---
`);const n=t.thesis.chapters.filter(s=>s.thesis_id===r.id).sort((s,i)=>s.order_index-i.order_index);for(let s=0;s<n.length;s++){const i=n[s];e.push(`${s+1}. ${i.title}
`);const a=t.thesis.sections.filter(o=>o.chapter_id===i.id).sort((o,c)=>o.order_index-c.order_index);for(let o=0;o<a.length;o++){const c=a[o],u=c.title||c.type;e.push(`${s+1}.${o+1} ${u}
`),e.push(Ha(c.content)||"[No content]"),e.push(`
`)}}e.push(`
---
`)}return e.join(`
`)}function Wjt(t){const e=[`SUMMARIES
`];for(const r of t.library.summaries){const n=t.library.documents.find(i=>i.id===r.document_id),s=(n==null?void 0:n.title)||(n==null?void 0:n.original_filename)||"Unknown Document";e.push(`${s}`),e.push(`Mode: ${r.summary_mode||"Standard"}`),e.push(`Created: ${new Date(r.created_at).toLocaleDateString()}`),e.push(""),e.push(Ha(r.summary_text)||"[No summary text]"),e.push(`
---
`)}return e.join(`
`)}function qjt(t){const e=[`THEORY BACKGROUNDS
`];for(const r of t.library.theoryBackgrounds)e.push(`${r.title||"Untitled"}`),e.push(`Mode: ${r.mode||"Standard"}`),e.push(`Created: ${new Date(r.created_at).toLocaleDateString()}`),e.push(""),e.push(Ha(r.theory_text)||"[No text]"),e.push(`
---
`);return e.join(`
`)}function Gjt(t){const e=[`METHODS
`];for(const r of t.library.methods)e.push(`${r.title||"Untitled"}`),e.push(`Mode: ${r.mode||"Standard"}`),e.push(`Created: ${new Date(r.created_at).toLocaleDateString()}`),e.push(""),e.push(Ha(r.method_text)||"[No text]"),e.push(`
---
`);return e.join(`
`)}function Kjt(t){const e=[`INTERVIEWS
`];for(const r of t.qualitative.interviews)e.push(`${r.title}`),r.source&&e.push(`Source: ${r.source}`),e.push(`Created: ${new Date(r.created_at).toLocaleDateString()}`),e.push(""),e.push(Ha(r.raw_text)||"[No text]"),e.push(`
---
`);return e.join(`
`)}function Yjt(t){const e=[`RESEARCH SETUPS
`];for(const r of t.research.researchSetups)e.push(`${r.title}`),r.aim&&e.push(`Aim: ${Ha(r.aim)}`),r.degree&&e.push(`Degree: ${r.degree}`),r.discipline&&e.push(`Discipline: ${r.discipline}`),e.push(`Created: ${new Date(r.created_at).toLocaleDateString()}`),e.push(""),r.derived_research_questions&&(e.push("Research Questions"),(Array.isArray(r.derived_research_questions)?r.derived_research_questions:[]).forEach((s,i)=>{e.push(`${i+1}. ${Ha(s)}`)}),e.push("")),r.markdown_text&&(e.push("Full Content"),e.push(Ha(r.markdown_text))),e.push(`
---
`);return e.join(`
`)}function Xjt(t){const e=[`TOPIC EXPLORATIONS
`];for(const r of t.research.topicExplorations)e.push(`${r.title}`),r.degree_type&&e.push(`Degree: ${r.degree_type}`),e.push(`Created: ${new Date(r.created_at).toLocaleDateString()}`),e.push(""),r.problem_statement&&(e.push("Problem Statement"),e.push(Ha(r.problem_statement)),e.push("")),r.objectives&&(e.push("Objectives"),e.push(Ha(r.objectives)),e.push("")),r.introduction&&(e.push("Introduction"),e.push(Ha(r.introduction)),e.push("")),r.research_questions&&(e.push("Research Questions"),(Array.isArray(r.research_questions)?r.research_questions:[]).forEach((s,i)=>{e.push(`${i+1}. ${Ha(s)}`)}),e.push("")),e.push(`
---
`);return e.join(`
`)}function Jjt(t){const e=[`QUALITATIVE SUMMARIES
`];for(const r of t.qualitative.qualitativeSummaries){const n=t.qualitative.codebooks.find(s=>s.id===r.codebook_id);e.push(`${r.title||"Untitled"}`),n&&e.push(`Codebook: ${n.title}`),e.push(`Created: ${new Date(r.created_at).toLocaleDateString()}`),e.push(""),e.push(Ha(r.summary_text)||"[No text]"),e.push(`
---
`)}return e.join(`
`)}async function Qjt(t,e,r){const n=r.qualitative.codebookCategories.filter(h=>h.codebook_id===t).sort((h,f)=>(h.order_index||0)-(f.order_index||0)),s=r.qualitative.codedSegments.filter(h=>h.codebook_id===t),i=[...new Set(s.map(h=>h.interview_id))],a=r.qualitative.interviews.filter(h=>i.includes(h.id)),c=[["Category","Definition","Coding Rule","Anchor Example",...a.map(h=>h.title)]];for(const h of n){const f=[(h.name||"").replace(/\r?\n/g," ").replace(/"/g,'""').trim(),(h.definition||"").replace(/\r?\n/g," ").replace(/"/g,'""').trim(),(h.coding_rule||"").replace(/\r?\n/g," ").replace(/"/g,'""').trim(),(h.anchor_example||"").replace(/\r?\n/g," ").replace(/"/g,'""').trim()];for(const p of a){const g=s.filter(x=>x.category_id===h.id&&x.interview_id===p.id).map(x=>x.snippet).join(" | ").replace(/"/g,'""').replace(/\r?\n/g," ").trim();f.push(g)}c.push(f)}const u=rk.unparse(c,{delimiter:";",quotes:!0,escapeFormulae:!0,newline:`\r
`});return{filename:`codebook_${e.replace(/[^a-zA-Z0-9_\-]/g,"_").substring(0,50)}.csv`,content:"\uFEFF"+u}}function Zjt(t){const e=new Date,r=e.toISOString().split("T")[0],n=e.toTimeString().split(":").slice(0,2).join(":");return`# Academly AI Backup
This backup contains all your data from Academly AI.
## Structure
- thesis/
- thesis_content.txt - Your thesis drafts in readable format
- library/
- summaries.txt - All document summaries
- theory_backgrounds.txt - Theory background texts
- methods.txt - Methodology texts
- research/
- research_setups.txt - Research setup documents
- topic_explorations.txt - Topic exploration notes
- qualitative/
- interviews.txt - All interview transcripts
- coding_summaries.txt - Qualitative analysis summaries
- codebook_*.csv - Codebook grids (Excel compatible)
## Notes
- CSV files use semicolon (;) as delimiter for Excel compatibility
- All text files are UTF-8 encoded with BOM
- Dates are in ISO format (YYYY-MM-DD)
## Data Ownership
${t.user.nickname?`Dear ${t.user.nickname}, your`:"Your"} data belongs to you! This backup ensures you always have access to your work.
---
Generated by Academly AI
${r} ${n}
`}async function ekt(t){const e=new zjt;e.file("README.txt","\uFEFF"+Zjt(t));const r=e.folder("thesis");t.thesis.theses.length>0&&(r==null||r.file("thesis_content.txt","\uFEFF"+Vjt(t)));const n=e.folder("library");t.library.summaries.length>0&&(n==null||n.file("summaries.txt","\uFEFF"+Wjt(t))),t.library.theoryBackgrounds.length>0&&(n==null||n.file("theory_backgrounds.txt","\uFEFF"+qjt(t))),t.library.methods.length>0&&(n==null||n.file("methods.txt","\uFEFF"+Gjt(t)));const s=e.folder("research");t.research.researchSetups.length>0&&(s==null||s.file("research_setups.txt","\uFEFF"+Yjt(t))),t.research.topicExplorations.length>0&&(s==null||s.file("topic_explorations.txt","\uFEFF"+Xjt(t)));const i=e.folder("qualitative");t.qualitative.interviews.length>0&&(i==null||i.file("interviews.txt","\uFEFF"+Kjt(t))),t.qualitative.qualitativeSummaries.length>0&&(i==null||i.file("coding_summaries.txt","\uFEFF"+Jjt(t)));for(const a of t.qualitative.codebooks){const o=await Qjt(a.id,a.title,t);i==null||i.file(o.filename,o.content)}return await e.generateAsync({type:"blob",compression:"DEFLATE"})}const tkt=[{value:"education",label:{de:"Bildungswissenschaften",en:"Education"}},{value:"arts_humanities",label:{de:"Kunst & Geisteswissenschaften",en:"Arts & Humanities"}},{value:"social_sciences",label:{de:"Sozialwissenschaften",en:"Social Sciences"}},{value:"business",label:{de:"Wirtschaftswissenschaften",en:"Business & Economics"}},{value:"law",label:{de:"Rechtswissenschaften",en:"Law"}},{value:"natural_sciences",label:{de:"Naturwissenschaften",en:"Natural Sciences"}},{value:"ict",label:{de:"Informatik & IT",en:"ICT"}},{value:"engineering",label:{de:"Ingenieurwissenschaften",en:"Engineering"}},{value:"health",label:{de:"Gesundheitswissenschaften",en:"Health Sciences"}},{value:"agriculture",label:{de:"Agrarwissenschaften",en:"Agriculture"}},{value:"services",label:{de:"Dienstleistungen",en:"Services"}}],rkt=[{value:"DE",label:"🇩🇪 Deutschland"},{value:"AT",label:"🇦🇹 Österreich"},{value:"CH",label:"🇨🇭 Schweiz"},{value:"US",label:"🇺🇸 USA"},{value:"GB",label:"🇬🇧 UK"},{value:"FR",label:"🇫🇷 Frankreich"},{value:"ES",label:"🇪🇸 Spanien"},{value:"IT",label:"🇮🇹 Italien"},{value:"NL",label:"🇳🇱 Niederlande"},{value:"BE",label:"🇧🇪 Belgien"},{value:"SE",label:"🇸🇪 Schweden"},{value:"NO",label:"🇳🇴 Norwegen"},{value:"DK",label:"🇩🇰 Dänemark"},{value:"FI",label:"🇫🇮 Finnland"},{value:"PL",label:"🇵🇱 Polen"},{value:"CZ",label:"🇨🇿 Tschechien"},{value:"OTHER",label:"🌍 Andere"}],nkt=[{value:"bachelor",label:{de:"Bachelor",en:"Bachelor"}},{value:"master",label:{de:"Master",en:"Master"}},{value:"phd",label:{de:"Promotion/PhD",en:"PhD"}},{value:"postdoc",label:{de:"Postdoc",en:"Postdoc"}},{value:"other",label:{de:"Sonstiges",en:"Other"}}],skt=[{value:"qualitative",label:{de:"Qualitativ",en:"Qualitative"}},{value:"quantitative",label:{de:"Quantitativ",en:"Quantitative"}},{value:"mixed",label:{de:"Mixed Methods",en:"Mixed Methods"}}],ikt=[{value:"de",label:"🇩🇪 Deutsch"},{value:"en",label:"🇬🇧 English"},{value:"fr",label:"🇫🇷 Français"},{value:"es",label:"🇪🇸 Español"},{value:"it",label:"🇮🇹 Italiano"}],akt=({initialData:t,onUpdate:e,disabled:r})=>{var f;const[n,s]=j.useState(t),[i,a]=j.useState(""),o=(p,m)=>{const g={...n,[p]:m};s(g),e({[p]:m})},c=()=>{if(!i.trim())return;const p=[...n.research_interests||[],i.trim()];o("research_interests",p),a("")},u=p=>{const m=[...n.research_interests||[]];m.splice(p,1),o("research_interests",m)},d=n.preferred_language||"de",h=p=>p[d]||p.de;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Country of Study"}),l.jsxs(dt,{value:n.study_country||"",onValueChange:p=>o("study_country",p),disabled:r,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select country"})}),l.jsx(ct,{children:rkt.map(p=>l.jsx(De,{value:p.value,children:p.label},p.value))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Degree Type"}),l.jsxs(dt,{value:n.degree_type||"",onValueChange:p=>o("degree_type",p),disabled:r,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select degree"})}),l.jsx(ct,{children:nkt.map(p=>l.jsx(De,{value:p.value,children:h(p.label)},p.value))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Discipline"}),l.jsxs(dt,{value:n.discipline||"",onValueChange:p=>o("discipline",p),disabled:r,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Discipline auswählen"})}),l.jsx(ct,{children:tkt.map(p=>l.jsx(De,{value:p.value,children:h(p.label)},p.value))})]})]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"University (optional)"}),l.jsx(Be,{value:n.university||"",onChange:p=>o("university",p.target.value),placeholder:"z.B. University Stanford",disabled:r})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Primary Methodology"}),l.jsxs(dt,{value:n.methodology||"",onValueChange:p=>o("methodology",p),disabled:r,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select methodology"})}),l.jsx(ct,{children:skt.map(p=>l.jsx(De,{value:p.value,children:h(p.label)},p.value))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Preferred Language"}),l.jsxs(dt,{value:n.preferred_language||"en",onValueChange:p=>o("preferred_language",p),disabled:r,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select language"})}),l.jsx(ct,{children:ikt.map(p=>l.jsx(De,{value:p.value,children:p.label},p.value))})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Research Interests"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Be,{value:i,onChange:p=>a(p.target.value),onKeyDown:p=>p.key==="Enter"&&(p.preventDefault(),c()),placeholder:"z.B. Künstliche Intelligenz",disabled:r}),l.jsx("button",{onClick:c,disabled:r||!i.trim(),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50",children:"+"})]}),l.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:(f=n.research_interests)==null?void 0:f.map((p,m)=>l.jsxs(kt,{variant:"secondary",className:"gap-1",children:[p,!r&&l.jsx(Is,{className:"w-3 h-3 cursor-pointer",onClick:()=>u(m)})]},m))})]})]})},okt=()=>{const{user:t,userProfile:e,researchProfile:r,studentPoints:n,loading:s,signOut:i,updateResearchProfile:a,uploadAvatar:o,selectPublicAvatar:c}=Dt(),{openCustomerPortal:u,loading:d}=nbe(),h=Or(),[f,p]=j.useState(""),[m,g]=j.useState(""),[x,y]=j.useState(!1),[v,b]=j.useState(""),[w,S]=j.useState(""),[k,E]=j.useState(""),[C,A]=j.useState(!1),[M,z]=j.useState(null),[P,W]=j.useState(!1),[N,U]=j.useState(""),[K,G]=j.useState(!1),[X,H]=j.useState(""),[B,L]=j.useState(!1),[F,V]=j.useState(!1),[Y,ie]=j.useState(null);j.useEffect(()=>{const $=localStorage.getItem("lastBackupDate");$&&z($)},[]),j.useEffect(()=>{(async()=>{if(!(r!=null&&r.avatar_url)){ie(null);return}const se=await sb(r.avatar_url);ie(se)})()},[r==null?void 0:r.avatar_url]),j.useEffect(()=>{!t&&!s?h("/login"):t&&p(t.email||""),r!=null&&r.nickname&&g(r.nickname)},[t,r,s,h]);const Q=async()=>{if(w!==k){We.error("Passwords do not match");return}if(w.length<6){We.error("Password must be at least 6 characters");return}We.success("Password updated successfully"),b(""),S(""),E("")},D=async()=>{if(!t||X!==t.email){We.error("Please enter your email address correctly to confirm deletion");return}W(!0);try{U("Canceling subscription...");const{data:$,error:se}=await be.functions.invoke("delete-account");if(se)throw console.error("Delete account error:",se),new Error(se.message||"Failed to delete account");if($!=null&&$.error)throw new Error($.error);We.success("Account successfully deleted. Goodbye!"),await i(),h("/")}catch($){console.error("Delete account error:",$),We.error("Failed to delete account: "+($.message||"Unknown error")),W(!1),U("")}},R=()=>{G(!1),H(""),L(!1)},J=async()=>{if(m.trim()){y(!0);try{await a({nickname:m.trim()}),We.success("Nickname updated")}catch{We.error("Failed to update nickname")}finally{y(!1)}}},Z=async $=>await o($),ee=async $=>{await c($)},re=async $=>{try{await a($)}catch{We.error("Failed to update profile")}},he=async()=>{if(t){A(!0);try{const $=await Hjt(t.id,t.email||"",(r==null?void 0:r.nickname)||void 0),se=await ekt($),ue=new Date().toISOString().split("T")[0],ne=r!=null&&r.nickname?`${r.nickname}_Backup_${ue}.zip`:`User_Backup_${ue}.zip`,me=URL.createObjectURL(se),ve=document.createElement("a");ve.href=me,ve.download=ne,document.body.appendChild(ve),ve.click(),document.body.removeChild(ve),URL.revokeObjectURL(me);const xe=new Date().toISOString();localStorage.setItem("lastBackupDate",xe),z(xe),We.success("Backup created successfully!")}catch($){console.error("Backup error:",$),We.error("Failed to create backup.")}finally{A(!1)}}};if(s)return l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})});if(!t||!e)return null;const O=(n==null?void 0:n.total)||0,ae=(n==null?void 0:n.used)||0,q=(n==null?void 0:n.remaining)||0,I=O>0?Math.round(ae/O*100):0,T=new Date(e.created_at).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});return l.jsx(gr,{showSidebar:!0,children:l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"Manage Account"}),l.jsx("p",{className:"text-muted-foreground",children:"Manage your account settings and profile"})]}),l.jsx(ze,{children:l.jsx(Ge,{className:"pt-6",children:l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex flex-col items-center gap-4",children:[l.jsxs("div",{onClick:()=>V(!0),className:"cursor-pointer group",children:[l.jsx("div",{className:"relative w-24 h-24 rounded-full overflow-hidden bg-muted border-2 border-transparent group-hover:border-primary transition-all",children:Y?l.jsx("img",{src:Y,alt:"Profile",className:"w-full h-full object-cover"}):l.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:l.jsx($w,{className:"w-12 h-12 text-muted-foreground"})})}),l.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center group-hover:text-primary transition-colors",children:"Click to change"})]}),l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm font-medium",children:"Profile Picture"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose a default avatar or upload your own (max 2MB)"})]})]}),l.jsx(Gr,{open:F,onOpenChange:V,children:l.jsxs(zr,{className:"sm:max-w-[840px]",children:[l.jsxs(Ur,{children:[l.jsx(Hr,{children:"Choose Your Avatar"}),l.jsx(wx,{children:"Select a default avatar or upload your own"})]}),l.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:l.jsx(rbe,{currentAvatarUrl:(r==null?void 0:r.avatar_url)||null,onSelectPublic:ee,onUploadCustom:Z})})]})}),l.jsx(vi,{}),l.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-4",children:[l.jsxs("div",{className:"flex gap-2 flex-1",children:[l.jsx(Be,{placeholder:"Nickname (optional)",value:m,onChange:$=>g($.target.value),className:"max-w-xs"}),l.jsx(ye,{onClick:J,disabled:x||!m.trim(),children:"Save"})]}),l.jsxs("div",{className:"text-sm text-muted-foreground",children:[f," • Member since ",T]})]})]})})}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsx(at,{children:"Research Profile"}),l.jsx(Un,{children:"Optional information for personalization and analytics (GDPR compliant)"})]}),l.jsx(Ge,{children:l.jsx(akt,{initialData:{study_country:(r==null?void 0:r.study_country)||null,degree_type:(r==null?void 0:r.degree_type)||null,discipline:(r==null?void 0:r.discipline)||null,research_interests:(r==null?void 0:r.research_interests)||null,university:(r==null?void 0:r.university)||null,methodology:(r==null?void 0:r.methodology)||null,preferred_language:(r==null?void 0:r.preferred_language)||null},onUpdate:re})})]}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(f2e,{className:"h-5 w-5"}),"Subscription & Credits"]}),l.jsx(Un,{children:"Your plan and Student Points"})]}),l.jsx(Ge,{children:l.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[l.jsx("div",{className:"space-y-4",children:l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium mb-2",children:"Current Plan"}),l.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[l.jsx("span",{className:"text-2xl font-bold capitalize",children:e.plan==="starter"?"Free":e.plan||"Free"}),e.subscription_status==="active"&&l.jsx(kt,{variant:"default",className:"bg-green-500/10 text-green-600 border-green-500/20",children:"Active"}),e.subscription_status==="canceled"&&l.jsx(kt,{variant:"secondary",className:"bg-amber-500/10 text-amber-600 border-amber-500/20",children:"Canceled"}),e.subscription_status==="past_due"&&l.jsx(kt,{variant:"destructive",children:"Past Due"})]}),e.subscription_ends_at&&l.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:e.subscription_status==="canceled"?`Access until ${new Date(e.subscription_ends_at).toLocaleDateString("en-US")}`:`Next billing: ${new Date(e.subscription_ends_at).toLocaleDateString("en-US")}`}),l.jsx("div",{className:"flex gap-2",children:e.stripe_subscription_id?l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>u(),disabled:d,children:[d?l.jsx(xt,{className:"h-4 w-4 animate-spin mr-2"}):null,"Manage Subscription"]}):l.jsx(ye,{variant:"outline",size:"sm",onClick:()=>h("/pricing"),children:"Upgrade Plan"})})]})}),l.jsxs("div",{className:"space-y-4",children:[l.jsx("p",{className:"text-sm font-medium",children:"Student Points"}),l.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-muted-foreground",children:"Purchased"}),l.jsxs("p",{className:"text-lg font-bold",children:[O.toLocaleString("en-US")," SP"]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-muted-foreground",children:"Used"}),l.jsxs("p",{className:"text-lg font-bold",children:[ae.toLocaleString("en-US",{maximumFractionDigits:1})," SP"]})]}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-muted-foreground",children:"Remaining"}),l.jsxs("p",{className:"text-lg font-bold text-primary",children:[q.toLocaleString("en-US",{maximumFractionDigits:1})," SP"]})]})]}),l.jsxs("div",{className:"space-y-1",children:[l.jsx(AE,{value:I}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[I,"% used • 1 SP = $0.001"]})]})]})]})})]}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx($ce,{className:"h-5 w-5"}),"Change Password"]}),l.jsx(Un,{children:"Update your password for security"})]}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"current-password",children:"Current Password"}),l.jsx(Be,{id:"current-password",type:"password",value:v,onChange:$=>b($.target.value)})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"new-password",children:"New Password"}),l.jsx(Be,{id:"new-password",type:"password",value:w,onChange:$=>S($.target.value)})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"confirm-password",children:"Confirm Password"}),l.jsx(Be,{id:"confirm-password",type:"password",value:k,onChange:$=>E($.target.value)})]})]}),l.jsx(ye,{onClick:Q,children:"Update Password"})]})]}),e.stripe_subscription_id&&l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsx(at,{children:"Billing & Invoices"}),l.jsx(Un,{children:"Manage your payment methods and view invoices"})]}),l.jsx(Ge,{className:"space-y-4",children:l.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[l.jsx("div",{className:"text-sm text-muted-foreground",children:l.jsx("p",{children:"Access your complete billing history and manage payment methods through the Stripe Customer Portal."})}),l.jsxs(ye,{variant:"outline",onClick:()=>u(),disabled:d,children:[d?l.jsx(xt,{className:"h-4 w-4 animate-spin mr-2"}):null,"Open Billing Portal"]})]})})]}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(w2e,{className:"h-5 w-5"}),"Data Backup"]}),l.jsx(Un,{children:"Download a complete backup of all your data. Your data belongs to you."})]}),l.jsx(Ge,{className:"space-y-4",children:l.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx("p",{className:"text-sm text-muted-foreground",children:"Includes: Thesis drafts, library documents, summaries, research setups, qualitative coding data (as CSV), and all notes."}),M&&l.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[l.jsx(gx,{className:"h-3 w-3"}),"Last backup:"," ",new Date(M).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),l.jsx(ye,{onClick:he,disabled:C,children:C?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"h-4 w-4 animate-spin mr-2"}),"Creating Backup..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Ga,{className:"h-4 w-4 mr-2"}),"Download Backup"]})})]})})]}),l.jsxs(ze,{className:"border-destructive",children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2 text-destructive",children:[l.jsx(xi,{className:"h-5 w-5"}),"Danger Zone"]}),l.jsx(Un,{children:"These actions are irreversible. Please be careful."})]}),l.jsx(Ge,{children:l.jsxs(va,{open:B,onOpenChange:$=>{P||(L($),$||R())},children:[l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"destructive",children:"Delete Account"})}),l.jsxs(Hi,{className:"max-w-lg",children:[l.jsxs(Vi,{children:[l.jsxs(qi,{className:"flex items-center gap-2 text-destructive",children:[l.jsx(bu,{className:"h-5 w-5"}),"Delete Account Permanently"]}),l.jsx(Gi,{asChild:!0,children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("p",{children:["This action is ",l.jsx("strong",{className:"text-foreground",children:"irreversible"}),". The following will be permanently deleted:"]}),l.jsxs("ul",{className:"list-disc list-inside text-sm space-y-1",children:[l.jsx("li",{children:"All documents and PDFs"}),l.jsx("li",{children:"All summaries and analyses"}),l.jsx("li",{children:"All thesis drafts and chapters"}),l.jsx("li",{children:"Research setups and topic explorations"}),l.jsx("li",{children:"Qualitative coding data (interviews, codebooks)"}),l.jsx("li",{children:"Your profile and account data"})]}),l.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/50 p-3 rounded-md border border-amber-200 dark:border-amber-800",children:l.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[l.jsx("strong",{children:"Tip:"})," Download a backup of your data before deleting your account."]})}),l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(bl,{id:"confirm-delete",checked:K,onCheckedChange:$=>G($===!0),disabled:P}),l.jsx(_e,{htmlFor:"confirm-delete",className:"text-sm leading-tight cursor-pointer",children:"I understand that all my data will be permanently deleted and this action cannot be undone"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"confirm-email",children:"Type your email to confirm:"}),l.jsx(Be,{id:"confirm-email",placeholder:(t==null?void 0:t.email)||"",value:X,onChange:$=>H($.target.value),disabled:P,className:"font-mono text-sm"})]})]})})]}),l.jsxs(Wi,{children:[l.jsx(ji,{disabled:P,children:"Cancel"}),l.jsx(ye,{variant:"destructive",onClick:D,disabled:!K||X!==(t==null?void 0:t.email)||P,children:P?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"h-4 w-4 animate-spin mr-2"}),N||"Deleting..."]}):"Delete Account Permanently"})]})]})]})})]})]})})};async function gSe(t){const e={kind:"generic"};try{if((t==null?void 0:t.name)==="FunctionsHttpError"&&(t==null?void 0:t.context)instanceof Response){const n=t.context,s=n.status,i=await n.clone().text(),a=i.toLowerCase();if(s===429||a.includes("429")||a.includes("tpm")||a.includes("too large")||a.includes("tokens per min")||a.includes("request too large")||a.includes("rate_limit")||a.includes("context_length_exceeded")||a.includes("maximum context length"))return{kind:"page_limit",status:s,serverMessage:i};if(s===401||s===403)return{kind:"unauthorized",status:s,serverMessage:i};try{const o=JSON.parse(i),c=o.error||o.details||o.message||"",u=c.toLowerCase();if(u.includes("429")||u.includes("tpm")||u.includes("too large")||u.includes("tokens per min")||u.includes("rate_limit"))return{kind:"page_limit",status:s,serverMessage:c}}catch{}return{kind:"generic",status:s,serverMessage:i}}const r=((t==null?void 0:t.message)||"").toLowerCase();if(r.includes("429")||r.includes("tpm")||r.includes("too large")||r.includes("tokens per min")||r.includes("request too large"))return{kind:"page_limit",serverMessage:t==null?void 0:t.message}}catch(r){console.error("Error parsing edge function error:",r)}return e}const hre=t=>t.is_extracted===!0?!0:t.page_count==null||t.extracted_pages==null?!1:t.page_count-t.extracted_pages<3;function ySe({documents:t,selectedDocuments:e,onToggle:r,onUploadClick:n,emptyMessage:s="No documents available.",uploadLabel:i="Upload Document",className:a}){const o=Or(),[c,u]=j.useState(null),d=()=>{t.forEach(m=>{e.includes(m.id)||r(m.id)})},h=()=>{e.forEach(m=>r(m))},f=m=>{!hre(m)&&!e.includes(m.id)?u(m):r(m.id)},p=()=>{c&&o(`/pdf-extract?document=${c.id}`),u(null)};return t.length===0?l.jsx("div",{className:Le("rounded-xl border border-border/50 bg-muted/30 p-6",a),children:l.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[l.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center",children:l.jsx(Br,{className:"h-6 w-6 text-muted-foreground"})}),l.jsx("p",{className:"text-sm text-muted-foreground",children:s}),n&&l.jsx(ye,{variant:"outline",size:"sm",onClick:n,children:i})]})}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Le("space-y-3",a),children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.length," of ",t.length," selected"]}),l.jsxs("div",{className:"flex gap-1",children:[l.jsxs(ye,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:d,disabled:e.length===t.length,children:[l.jsx(Es,{className:"h-3 w-3 mr-1"}),"All"]}),l.jsxs(ye,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:h,disabled:e.length===0,children:[l.jsx(Is,{className:"h-3 w-3 mr-1"}),"None"]})]})]}),l.jsx(Yw,{className:"h-[280px] rounded-xl border border-border/50 bg-gradient-to-b from-background to-muted/20",children:l.jsx("div",{className:"p-2 space-y-0.5",children:t.map(m=>{const g=e.includes(m.id),x=hre(m);return l.jsxs("label",{htmlFor:`doc-${m.id}`,className:Le("flex items-center gap-2 px-2 py-1.5 rounded-md cursor-pointer transition-all duration-200","hover:bg-primary/5 group",g&&"bg-primary/10 border border-primary/20"),onClick:y=>{y.preventDefault(),f(m)},children:[l.jsx(bl,{id:`doc-${m.id}`,checked:g,onCheckedChange:()=>f(m),className:"h-3.5 w-3.5 data-[state=checked]:bg-primary data-[state=checked]:border-primary",onClick:y=>y.stopPropagation()}),l.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5",children:[l.jsx(Br,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx("p",{className:Le("text-xs font-medium truncate transition-colors",g?"text-foreground":"text-muted-foreground group-hover:text-foreground"),children:m.title||m.original_filename}),l.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:["(",m.page_count||"?"," pages)"]}),!x&&l.jsx(Zs,{children:l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(bu,{className:"w-3 h-3 text-destructive shrink-0"})}),l.jsx(Qt,{children:l.jsxs("p",{children:["Document needs extraction (",m.extracted_pages||0,"/",m.page_count||"?",")"]})})]})})]})]},m.id)})})})]}),l.jsx(va,{open:!!c,onOpenChange:m=>!m&&u(null),children:l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsxs(qi,{className:"flex items-center gap-2",children:[l.jsx(bu,{className:"h-5 w-5 text-destructive"}),"Document Not Extracted"]}),l.jsxs(Gi,{className:"space-y-2",children:[l.jsxs("p",{children:["The document ",l.jsxs("strong",{children:['"',(c==null?void 0:c.title)||(c==null?void 0:c.original_filename),'"']})," has not been fully extracted yet."]}),l.jsxs("p",{children:["Only ",(c==null?void 0:c.extracted_pages)||0," of ",(c==null?void 0:c.page_count)||"?"," pages have been processed. Text content from unextracted pages will not be available for AI processing."]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Please extract the document first to ensure all pages are available."})]})]}),l.jsxs(Wi,{className:"flex-col sm:flex-row gap-2",children:[l.jsx(ji,{children:"Cancel"}),l.jsx(ye,{variant:"outline",onClick:()=>{c&&r(c.id),u(null)},children:"Use Anyway"}),l.jsx(bi,{onClick:p,children:"Extract Now"})]})]})})]})}const lkt=()=>{const{user:t,loading:e,checkStudentPoints:r,studentPoints:n,fetchStudentPoints:s}=Dt(),[i,a]=j.useState(!1),o=Or(),{toast:c}=qn(),[u,d]=j.useState([]),[h,f]=j.useState([]),[p,m]=j.useState({}),[g,x]=j.useState({}),[y,v]=j.useState(""),[b,w]=j.useState("small"),[S,k]=j.useState("en"),[E,C]=j.useState("fox41"),[A,M]=j.useState(null),[z,P]=j.useState("APA7"),[W,N]=j.useState(!1),[U,K]=j.useState(null),[G,X]=j.useState(null),[H,B]=j.useState(!1),[L,F]=j.useState([]),[V,Y]=j.useState(""),[ie,Q]=j.useState([]),[D,R]=j.useState(!1),[J,Z]=j.useState(""),[ee,re]=j.useState(""),[he,O]=j.useState(!1);j.useEffect(()=>{!t&&!e&&o("/login")},[t,e,o]),j.useEffect(()=>{t&&(T(),ae())},[t]),j.useEffect(()=>{V?q():(Q([]),Z(""))},[V]);const ae=async()=>{const{data:de}=await be.from("theses").select("id, title").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});F(de||[])},q=async()=>{const{data:de}=await be.from("chapters").select("id, title, order_index").eq("thesis_id",V).order("order_index");Q(de||[])},I=async()=>{if(!(!J||!U)){O(!0);try{const{data:de}=await be.from("sections").select("order_index").eq("chapter_id",J).order("order_index",{ascending:!1}).limit(1),ge=de!=null&&de.length?de[0].order_index+1:0;await be.from("sections").insert({chapter_id:J,content:U.content,title:ee.trim()||null,type:"other",order_index:ge,status:"open"}),c({title:"Successfully imported",description:"Saved as section in chapter."}),R(!1),re(""),Z("")}catch{c({title:"Error with Import",variant:"destructive"})}finally{O(!1)}}},T=async()=>{try{const{data:de,error:ge}=await be.from("v_documents_with_status").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(ge)throw ge;d(de||[])}catch(de){console.error("Error loading documents:",de),c({title:"Error",description:"Could not load documents.",variant:"destructive"})}},$=async de=>{var ke,Ne;const{data:ge}=await be.from("pages").select("page_number").eq("document_id",de).order("page_number",{ascending:!0}).limit(1),{data:Se}=await be.from("pages").select("page_number").eq("document_id",de).order("page_number",{ascending:!1}).limit(1);return{min:((ke=ge==null?void 0:ge[0])==null?void 0:ke.page_number)??1,max:((Ne=Se==null?void 0:Se[0])==null?void 0:Ne.page_number)??1}},se=async de=>{if(h.includes(de))f(Se=>Se.filter(ke=>ke!==de)),m(Se=>{const ke={...Se};return delete ke[de],ke}),x(Se=>{const ke={...Se};return delete ke[de],ke});else{const Se=await $(de);x(ke=>({...ke,[de]:Se})),f(ke=>[...ke,de]),m(ke=>({...ke,[de]:{from:Se.min,to:Math.min(Se.max,Se.min+14)}}))}},ue=()=>h.reduce((de,ge)=>{const Se=p[ge];return Se?de+(Se.to-Se.from+1):de},0),ne=(de,ge=40)=>de.length>ge?de.substring(0,ge)+"...":de,me=(de,ge,Se)=>{const ke=g[de]||{min:1,max:999},Ne=p[de]||{from:ke.min,to:Math.min(ke.max,ke.min+14)};let qe=ge==="from"?Se:Ne.from,Ae=ge==="to"?Se:Ne.to;qe=Math.max(ke.min,Math.min(qe,ke.max)),Ae=Math.max(ke.min,Math.min(Ae,ke.max)),ge==="from"&&qe>Ae&&(Ae=qe),ge==="to"&&Ae<qe&&(qe=Ae),m(fe=>({...fe,[de]:{from:qe,to:Ae}}))},ve=async()=>{var de,ge,Se;if(!r()){a(!0);return}if(h.length===0){c({title:"Error",description:"Please select at least one document.",variant:"destructive"});return}if(y.length<5){c({title:"Error",description:"Topic must be at least 5 characters.",variant:"destructive"});return}N(!0);try{const ke=E==="fox40"?"thesis_builder_fox40":"thesis_builder",{data:Ne,error:qe}=await be.functions.invoke(ke,{body:{document_ids:h,page_ranges:p,topic:y,mode:b,language:S,citation_style:z,save_pdf:!1}});if(qe)throw qe;if((Ne==null?void 0:Ne.error)==="rate_limit"){const Ae=Ne.retry_after||10;M(Ae);let fe=Ae;const Te=setInterval(()=>{fe-=1,M(fe),fe<=0&&(clearInterval(Te),M(null),N(!1),ve())},1e3);return}K(Ne),B(!0),c({title:"Success",description:"Theory & Background generated!"}),t&&(await new Promise(Ae=>setTimeout(Ae,4e3)),await s(t.id)),X({prompt:((de=Ne==null?void 0:Ne.usage)==null?void 0:de.prompt_tokens)??void 0,completion:((ge=Ne==null?void 0:Ne.usage)==null?void 0:ge.completion_tokens)??void 0,total:((Se=Ne==null?void 0:Ne.usage)==null?void 0:Se.total_tokens)??void 0}),B(!0),c({title:"Success",description:"Theory & Background generated!"})}catch(ke){console.error("Error generating thesis:",ke);const Ne=await gSe(ke);Ne.kind==="page_limit"?c({title:"Processing Limit Reached",description:"The document could not be processed due to page limits. Please try using fewer pages by adjusting the page selector or selecting fewer documents.",variant:"destructive"}):Ne.kind==="unauthorized"?c({title:"Session Expired",description:"Your session has expired. Please log in again.",variant:"destructive"}):c({title:"Error",description:"Something went wrong while generating the text. Please try again in a moment.",variant:"destructive"})}finally{N(!1)}},xe=async de=>{try{await navigator.clipboard.writeText(de),c({title:"Copied",description:"Text copied to clipboard."})}catch{c({title:"Error",description:"Could not copy text.",variant:"destructive"})}},oe=()=>{o("/documents")};return e?l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?l.jsxs(gr,{showSidebar:!0,children:[l.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"Theory & Background"}),l.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate academic paragraphs from your documents with automatic citations."})]})}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Paragraph Configuration"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Select Documents *"}),l.jsx(ySe,{documents:u,selectedDocuments:h,onToggle:se,onUploadClick:()=>o("/summary"),emptyMessage:"No documents available.",uploadLabel:"Upload Document"})]}),h.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(_e,{className:"text-sm font-medium",children:"Page Selection"}),l.jsxs("span",{className:`text-xs ${ue()>15?"text-red-500 font-medium":"text-muted-foreground"}`,children:[ue()," / 15 pages selected"]})]}),l.jsx("div",{className:"space-y-2",children:h.map(de=>{const ge=u.find(Ae=>Ae.id===de);if(!ge)return null;const Se=p[de]||{from:1,to:Math.min(ge.page_count||1,15)},ke=g[de]||{min:1,max:ge.page_count||1},Ne=ne(ge.title||ge.original_filename||"Document"),qe=Se.to-Se.from+1;return l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md",children:[l.jsx("span",{className:"text-xs text-muted-foreground flex-1 truncate",title:ge.title||ge.original_filename,children:Ne}),l.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:"p."}),l.jsx(Be,{type:"number",min:ke.min,max:ke.max,value:Se.from,onChange:Ae=>{const fe=parseInt(Ae.target.value);isNaN(fe)||m(Te=>({...Te,[de]:{...Te[de],from:fe}}))},onBlur:Ae=>me(de,"from",parseInt(Ae.target.value)||ke.min),className:"w-14 h-7 text-xs text-center px-1"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"–"}),l.jsx(Be,{type:"number",min:ke.min,max:ke.max,value:Se.to,onChange:Ae=>{const fe=parseInt(Ae.target.value);isNaN(fe)||m(Te=>({...Te,[de]:{...Te[de],to:fe}}))},onBlur:Ae=>me(de,"to",parseInt(Ae.target.value)||ke.min),className:"w-14 h-7 text-xs text-center px-1"}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["/ ",ke.max]}),l.jsxs(kt,{variant:qe>15?"destructive":"secondary",className:"text-xs ml-1",children:[qe,"p"]})]})]},de)})}),ue()>15&&l.jsxs(wh,{className:"border-red-500/50 bg-red-500/10",children:[l.jsx(bu,{className:"h-4 w-4 text-red-600"}),l.jsx(Sh,{className:"text-red-700 dark:text-red-400 text-xs",children:"Maximum 15 pages total across all documents. Please reduce your selection."})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"topic",children:"Topic / Research Question *"}),l.jsx(ir,{id:"topic",value:y,onChange:de=>v(de.target.value),className:"min-h-[100px]",placeholder:"Describe your topic or research question..."}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[y.length,"/5 characters (minimum 5 required)"]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Mode"}),l.jsxs(dt,{value:b,onValueChange:w,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"small",children:"Short (300 Tokens)"}),l.jsx(De,{value:"medium",children:"Medium (600 Tokens)"}),l.jsx(De,{value:"big",children:"Long (1200 Tokens)"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Language"}),l.jsxs(dt,{value:S,onValueChange:k,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"de",children:"Deutsch"}),l.jsx(De,{value:"en",children:"English"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Citation Style"}),l.jsxs(dt,{value:z,onValueChange:P,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"APA7",children:"APA7"}),l.jsx(De,{value:"Harvard",children:"Harvard"}),l.jsx(De,{value:"Chicago",children:"Chicago"}),l.jsx(De,{value:"MLA",children:"MLA"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(_e,{children:"AI Model"}),l.jsx(Zs,{children:l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(Bp,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"})}),l.jsxs(Qt,{side:"top",className:"max-w-xs text-xs space-y-1",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Fox 4.0:"})," Faster, lower SP consumption"]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Fox 4.1:"})," Higher quality, more SP consumption"]})]})]})})]}),l.jsxs(dt,{value:E,onValueChange:C,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"fox41",children:"Fox 4.1 — Advanced"}),l.jsx(De,{value:"fox40",children:"Fox 4.0 — Fast"})]})]})]}),l.jsx(ye,{onClick:ve,disabled:W||h.length===0||y.length<5||ue()>15,className:"w-full",children:A!==null?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Retrying in ",A,"s..."]}):W?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate Paragraph"})]})]}),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Result"})}),l.jsx(Ge,{children:U?l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold text-lg mb-2",children:U.title}),l.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:h.map(de=>{const ge=u.find(Se=>Se.id===de);return ge?l.jsx(kt,{variant:"secondary",className:"text-xs",children:ge.title||ge.original_filename},de):null})}),l.jsxs(kt,{variant:"outline",className:"text-xs",children:[b.charAt(0).toUpperCase()+b.slice(1)," | ",z," |"," ",new Date().toLocaleDateString("en-US")]})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold mb-2",children:"Generated Text"}),l.jsx("div",{className:"prose prose-sm max-w-none whitespace-pre-wrap",children:U.content.split(/Originaltextstellen:|Proof of Material:|Original quotes:/)[0].split("---")[0].trim()})]}),(U.content.includes("Originaltextstellen")||U.content.includes("Proof of Material")||U.content.includes("Original quotes"))&&l.jsxs(l.Fragment,{children:[l.jsx(vi,{}),l.jsxs("div",{children:[l.jsxs("h4",{className:"font-semibold mb-3 flex items-center gap-2",children:[l.jsx(Ah,{className:"h-4 w-4"}),"Original Quotes",l.jsx(kt,{variant:"outline",className:"text-xs font-normal",children:"Original Language"})]}),l.jsx("div",{className:"space-y-2",children:(()=>{var ke,Ne,qe,Ae;let de=U.content.split("Originaltextstellen:")[1];de||(de=U.content.split("Original quotes:")[1]),de||(de=U.content.split("Proof of Material:")[1]);const ge=(Ae=(qe=(Ne=(ke=de==null?void 0:de.split("---")[0])==null?void 0:ke.split("=== APA7 Literatur ===")[0])==null?void 0:Ne.split("## Literaturverzeichnis")[0])==null?void 0:qe.split("## References")[0])==null?void 0:Ae.trim();if(!ge)return l.jsx("p",{className:"text-sm text-muted-foreground",children:"No original quotes available"});const Se=ge.split(/\n(?=["„]|[A-Z][a-zäöü]+,?\s+\d{4})/).filter(fe=>fe.trim());return Se.length>0?Se.map((fe,Te)=>l.jsx("div",{className:"bg-muted/50 border-l-4 border-primary/30 p-3 rounded-r-md",children:l.jsx("p",{className:"text-sm italic whitespace-pre-wrap",children:fe.trim()})},Te)):l.jsx("div",{className:"bg-muted/50 border-l-4 border-primary/30 p-3 rounded-r-md",children:l.jsx("p",{className:"text-sm italic whitespace-pre-wrap",children:ge})})})()})]})]}),(U.content.includes("Literaturverzeichnis")||U.content.includes("=== APA7 Literatur ===")||U.content.includes("References"))&&l.jsxs(l.Fragment,{children:[l.jsx(vi,{}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold mb-2",children:"References"}),l.jsx("div",{className:"prose prose-sm max-w-none whitespace-pre-wrap bg-muted p-3 rounded-md text-sm",children:(()=>{let de=U.content.split("=== APA7 Literatur ===")[1];return de||(de=U.content.split("## Literaturverzeichnis")[1]),de||(de=U.content.split("## References")[1]),(de==null?void 0:de.trim())||(Array.isArray(U.literature)?U.literature.join(`
`):U.literature)})()})]})]}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>xe(U.content),children:[l.jsx(Tn,{className:"mr-2 h-4 w-4"}),"Copy"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>R(!0),disabled:!U,children:[l.jsx(sE,{className:"mr-2 h-4 w-4"}),"Import to Chapter"]}),l.jsxs(ye,{variant:"outline",size:"sm",disabled:!0,className:"opacity-50 cursor-not-allowed",children:[l.jsx(Br,{className:"mr-2 h-4 w-4"}),"Create PDF (disabled)"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:oe,children:[l.jsx(Br,{className:"mr-2 h-4 w-4"}),"View in Library"]})]})]}):l.jsxs("div",{className:"text-center py-12",children:[l.jsx(Br,{className:"mx-auto h-12 w-12 text-muted-foreground mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:'Configure the parameters on the left and click "Generate Paragraph".'})]})})]})]})]}),l.jsx(Gr,{open:D,onOpenChange:R,children:l.jsxs(zr,{children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Als Section importieren"})}),l.jsxs("div",{className:"space-y-4 py-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Thesis"}),l.jsxs(dt,{value:V,onValueChange:Y,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select thesis..."})}),l.jsx(ct,{children:L.map(de=>l.jsx(De,{value:de.id,children:de.title},de.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Target Chapter"}),l.jsxs(dt,{value:J,onValueChange:Z,disabled:!V,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:V?"Select chapter...":"Select thesis first"})}),l.jsx(ct,{children:ie.map(de=>l.jsx(De,{value:de.id,children:de.title},de.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Section-Titel (optional)"}),l.jsx(Be,{value:ee,onChange:de=>re(de.target.value),placeholder:"z.B. Theoretischer Hintergrund"})]})]}),l.jsxs(Th,{children:[l.jsx(ye,{variant:"outline",onClick:()=>R(!1),children:"Abbrechen"}),l.jsx(ye,{onClick:I,disabled:!J||he,children:he?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Importiere..."]}):l.jsxs(l.Fragment,{children:[l.jsx(vu,{className:"mr-2 h-4 w-4"}),"Importieren"]})})]})]})}),l.jsx(Bu,{open:i,onClose:()=>a(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]}):null},ckt=()=>{const{user:t,loading:e,checkStudentPoints:r,studentPoints:n,fetchStudentPoints:s}=Dt(),[i,a]=j.useState(!1),o=Or(),{toast:c}=qn(),[u,d]=j.useState([]),[h,f]=j.useState([]),[p,m]=j.useState({}),[g,x]=j.useState({}),[y,v]=j.useState("fox41"),[b,w]=j.useState(null),[S,k]=j.useState(""),[E,C]=j.useState("de"),[A,M]=j.useState("APA7"),[z,P]=j.useState(""),[W,N]=j.useState("small"),[U,K]=j.useState(0),[G,X]=j.useState(null),[H,B]=j.useState(!1),[L,F]=j.useState(!1),[V,Y]=j.useState(null),[ie,Q]=j.useState([]),[D,R]=j.useState(""),[J,Z]=j.useState([]),[ee,re]=j.useState(!1),[he,O]=j.useState(""),[ae,q]=j.useState(""),[I,T]=j.useState(!1);j.useEffect(()=>{!t&&!e&&o("/login")},[t,e,o]),j.useEffect(()=>{t&&(Se(),$())},[t]),j.useEffect(()=>{D?se():(Z([]),O(""))},[D]);const $=async()=>{const{data:Ee}=await be.from("theses").select("id, title").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});Q(Ee||[])},se=async()=>{const{data:Ee}=await be.from("chapters").select("id, title, order_index").eq("thesis_id",D).order("order_index");Z(Ee||[])},ue=async()=>{if(!(!he||!V)){T(!0);try{const{data:Ee}=await be.from("sections").select("order_index").eq("chapter_id",he).order("order_index",{ascending:!1}).limit(1),nt=Ee!=null&&Ee.length?Ee[0].order_index+1:0;await be.from("sections").insert({chapter_id:he,content:V.content,title:ae.trim()||null,type:"other",order_index:nt,status:"open"}),c({title:"Successfully imported",description:"Saved as section in chapter."}),re(!1),q(""),O("")}catch{c({title:"Fehler beim Import",variant:"destructive"})}finally{T(!1)}}},ne={small:{wordMin:200,wordMax:380,proofSnippets:1,overheadTokens:400},medium:{wordMin:350,wordMax:700,proofSnippets:2,overheadTokens:500},big:{wordMin:650,wordMax:1e3,proofSnippets:3,overheadTokens:650}},me=Ee=>Math.round(Ee*1.4),ve=Ee=>Math.round(Ee/4),xe=1e3;function oe(Ee,nt,rt){const Ze=ne[Ee]??ne.small,we=me((Ze.wordMin+Ze.wordMax)/2),je=Math.max(1,nt*Math.max(1,rt))*xe,Re=ve(je),Ue=Ze.overheadTokens+Re;return{prompt:Ue,completion:we,total:Ue+we}}const de=()=>{if(h.length===0)return{tokens:{prompt:0,completion:0,total:0}};const Ee=h.map(Ze=>{var we;return((we=u.find(Oe=>Oe.id===Ze))==null?void 0:we.page_count)||0}),nt=Math.max(1,Math.round(Ee.reduce((Ze,we)=>Ze+we,0)/(Ee.length||1))||5);return{tokens:oe(W,h.length,nt)}},ge=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,Ee=>{const nt=(crypto.getRandomValues(new Uint8Array(1))[0]&15)>>0;return(Ee==="x"?nt:nt&3|8).toString(16)});j.useEffect(()=>{const Ee=de();K(Ee.tokens.total)},[W,h,u]);const Se=async()=>{try{const{data:Ee,error:nt}=await be.from("v_documents_with_status").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(nt)throw nt;d(Ee||[])}catch(Ee){console.error("Error loading documents:",Ee),c({title:"Error",description:"Documents could not be loaded.",variant:"destructive"})}},ke=async Ee=>{var Ze,we;const{data:nt}=await be.from("pages").select("page_number").eq("document_id",Ee).order("page_number",{ascending:!0}).limit(1),{data:rt}=await be.from("pages").select("page_number").eq("document_id",Ee).order("page_number",{ascending:!1}).limit(1);return{min:((Ze=nt==null?void 0:nt[0])==null?void 0:Ze.page_number)??1,max:((we=rt==null?void 0:rt[0])==null?void 0:we.page_number)??1}},Ne=async Ee=>{if(h.includes(Ee))f(rt=>rt.filter(Ze=>Ze!==Ee)),m(rt=>{const Ze={...rt};return delete Ze[Ee],Ze}),x(rt=>{const Ze={...rt};return delete Ze[Ee],Ze});else{const rt=await ke(Ee);x(Ze=>({...Ze,[Ee]:rt})),f(Ze=>[...Ze,Ee]),m(Ze=>({...Ze,[Ee]:{from:rt.min,to:Math.min(rt.max,rt.min+14)}}))}},qe=()=>h.reduce((Ee,nt)=>{const rt=p[nt];return rt?Ee+(rt.to-rt.from+1):Ee},0),Ae=(Ee,nt=40)=>Ee.length>nt?Ee.substring(0,nt)+"...":Ee,fe=(Ee,nt,rt)=>{const Ze=g[Ee]||{min:1,max:999},we=p[Ee]||{from:Ze.min,to:Math.min(Ze.max,Ze.min+14)};let Oe=nt==="from"?rt:we.from,je=nt==="to"?rt:we.to;Oe=Math.max(Ze.min,Math.min(Oe,Ze.max)),je=Math.max(Ze.min,Math.min(je,Ze.max)),nt==="from"&&Oe>je&&(je=Oe),nt==="to"&&je<Oe&&(Oe=je),m(Re=>({...Re,[Ee]:{from:Oe,to:je}}))},Te=async()=>{var Ee,nt,rt;if(!r()){a(!0);return}if(!S.trim()){c({title:"Error",description:"Please enter a topic.",variant:"destructive"});return}B(!0);try{const Ze=y==="fox40"?"methodology_builder_fox40":"methodology_builder",{data:we,error:Oe}=await be.functions.invoke(Ze,{body:{document_ids:h,page_ranges:p,topic:S.trim(),language:E,citation_style:A,own_words:z.trim(),mode:W,client_request_id:ge()}});if(Oe)throw Oe;if((we==null?void 0:we.error)==="rate_limit"){const je=we.retry_after||10;w(je);let Re=je;const Ue=setInterval(()=>{Re-=1,w(Re),Re<=0&&(clearInterval(Ue),w(null),B(!1),Te())},1e3);return}Y(we),X({prompt:((Ee=we==null?void 0:we.usage)==null?void 0:Ee.prompt_tokens)??void 0,completion:((nt=we==null?void 0:we.usage)==null?void 0:nt.completion_tokens)??void 0,total:((rt=we==null?void 0:we.usage)==null?void 0:rt.total_tokens)??void 0}),t&&(await new Promise(je=>setTimeout(je,4e3)),await s(t.id)),c({title:"Success",description:we.saved_to_library?"Methods & Approach generated and saved to library!":"Methods & Approach was generated!"})}catch(Ze){console.error("Error generating methodology:",Ze);const we=await gSe(Ze);we.kind==="page_limit"?c({title:"Processing Limit Reached",description:"The document could not be processed due to page limits. Please try using fewer pages by adjusting the page selector or selecting fewer documents.",variant:"destructive"}):we.kind==="unauthorized"?c({title:"Session Expired",description:"Your session has expired. Please log in again.",variant:"destructive"}):c({title:"Error",description:"Something went wrong while generating the text. Please try again in a moment.",variant:"destructive"})}finally{B(!1)}},Pe=async()=>{if(!(!V||!z.trim())){F(!0);try{const{data:Ee,error:nt}=await be.functions.invoke("methodology_builder",{body:{action:"refine",draft:V,own_words:z.trim(),language:E}});if(nt)throw nt;Y(Ee),c({title:"Success",description:"Draft has been refined and merged!"})}catch(Ee){console.error("Error refining methodology:",Ee),c({title:"Error",description:Ee.message||"Error refining the draft.",variant:"destructive"})}finally{F(!1)}}},tt=async Ee=>{try{await navigator.clipboard.writeText(Ee),c({title:"Copied",description:"Text has been copied to clipboard."})}catch{c({title:"Error",description:"Text could not be copied.",variant:"destructive"})}},wt=()=>{o("/documents")};return e?l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?l.jsxs(gr,{showSidebar:!0,children:[l.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"Methods & Approach"}),l.jsx("p",{className:"text-muted-foreground mt-2",children:"Develop a structured methodology based on your literature and your own approach."})]})}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Paragraph Configuration"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Sources (optional)"}),l.jsx(ySe,{documents:u,selectedDocuments:h,onToggle:Ne,onUploadClick:()=>o("/summary"),emptyMessage:"No documents available.",uploadLabel:"Upload Document"})]}),h.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(_e,{className:"text-sm font-medium",children:"Page Selection"}),l.jsxs("span",{className:`text-xs ${qe()>15?"text-red-500 font-medium":"text-muted-foreground"}`,children:[qe()," / 15 pages selected"]})]}),l.jsx("div",{className:"space-y-2",children:h.map(Ee=>{const nt=u.find(je=>je.id===Ee);if(!nt)return null;const rt=g[Ee]||{min:1,max:nt.page_count||1},Ze=p[Ee]||{from:rt.min,to:Math.min(rt.max,rt.min+14)},we=Ae(nt.title||nt.original_filename||"Document"),Oe=Ze.to-Ze.from+1;return l.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md",children:[l.jsx("span",{className:"text-xs text-muted-foreground flex-1 truncate",children:we}),l.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:"p."}),l.jsx(Be,{type:"number",min:rt.min,max:rt.max,value:Ze.from,onChange:je=>{const Re=parseInt(je.target.value);isNaN(Re)||m(Ue=>({...Ue,[Ee]:{...Ue[Ee],from:Re}}))},onBlur:je=>fe(Ee,"from",parseInt(je.target.value)||rt.min),className:"w-14 h-7 text-xs text-center px-1"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"–"}),l.jsx(Be,{type:"number",min:rt.min,max:rt.max,value:Ze.to,onChange:je=>{const Re=parseInt(je.target.value);isNaN(Re)||m(Ue=>({...Ue,[Ee]:{...Ue[Ee],to:Re}}))},onBlur:je=>fe(Ee,"to",parseInt(je.target.value)||rt.min),className:"w-14 h-7 text-xs text-center px-1"}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["/ ",rt.max]}),l.jsxs(kt,{variant:Oe>15?"destructive":"secondary",className:"text-xs ml-1",children:[Oe,"p"]})]})]},Ee)})}),qe()>15&&l.jsxs(wh,{className:"border-red-500/50 bg-red-500/10",children:[l.jsx(bu,{className:"h-4 w-4 text-red-600"}),l.jsx(Sh,{className:"text-red-700 dark:text-red-400 text-xs",children:"Maximum 15 pages total across all documents."})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"topic",children:"Topic / Focus *"}),l.jsx(Be,{id:"topic",placeholder:"e.g. Mixed-methods evaluation of burnout prevention in nursing",value:S,onChange:Ee=>k(Ee.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Language"}),l.jsxs(dt,{value:E,onValueChange:C,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"de",children:"DE"}),l.jsx(De,{value:"en",children:"EN"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Citation Style"}),l.jsxs(dt,{value:A,onValueChange:M,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsx(ct,{children:l.jsx(De,{value:"APA7",children:"APA7"})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Mode"}),l.jsxs(dt,{value:W,onValueChange:N,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"small",children:"Short"}),l.jsx(De,{value:"medium",children:"Medium"}),l.jsx(De,{value:"big",children:"Long"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"ownProcedure",children:"Your Approach (optional)"}),l.jsx(ir,{id:"ownProcedure",value:z,onChange:Ee=>P(Ee.target.value),className:"min-h-[120px]",placeholder:"Describe your own steps (sampling, tools, timeline, limitations, etc.)"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(_e,{children:"AI Model"}),l.jsx(Zs,{children:l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(Bp,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"})}),l.jsxs(Qt,{side:"top",className:"max-w-xs text-xs space-y-1",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Fox 4.0:"})," Faster, lower SP consumption"]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Fox 4.1:"})," Higher quality, more SP consumption"]})]})]})})]}),l.jsxs(dt,{value:y,onValueChange:v,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"fox41",children:"Fox 4.1 — Advanced"}),l.jsx(De,{value:"fox40",children:"Fox 4.0 — Fast"})]})]})]}),l.jsx(ye,{onClick:Te,disabled:H||!S.trim()||qe()>15,className:"w-full",children:b!==null?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Retrying in ",b,"s..."]}):H?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating Draft..."]}):"Generate Draft"})]})]}),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Results"})}),l.jsx(Ge,{children:V?l.jsxs("div",{className:"space-y-4",children:[l.jsx("div",{children:l.jsx("h3",{className:"font-semibold text-lg mb-2",children:V.title})}),l.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:l.jsx(pc,{components:{h1:({children:Ee})=>l.jsx("h1",{className:"text-lg font-semibold mt-6 mb-3 first:mt-0",children:Ee}),h2:({children:Ee})=>l.jsx("h2",{className:"text-base font-semibold mt-5 mb-2",children:Ee}),p:({children:Ee})=>l.jsx("p",{className:"mb-3 leading-relaxed",children:Ee}),ul:({children:Ee})=>l.jsx("ul",{className:"mb-3 ml-4 list-disc",children:Ee}),ol:({children:Ee})=>l.jsx("ol",{className:"mb-3 ml-4 list-decimal",children:Ee}),li:({children:Ee})=>l.jsx("li",{className:"mb-1",children:Ee})},children:V.content.split(/Originaltextstellen:|Proof of Material:|Original quotes:/)[0].split("---")[0].trim()})}),(V.content.includes("Originaltextstellen")||V.content.includes("Proof of Material")||V.content.includes("Original quotes"))&&l.jsxs(l.Fragment,{children:[l.jsx(vi,{}),l.jsxs("div",{children:[l.jsxs("h4",{className:"font-semibold mb-3 flex items-center gap-2",children:[l.jsx(Ah,{className:"h-4 w-4"}),"Original Quotes",l.jsx(kt,{variant:"outline",className:"text-xs font-normal",children:"Original Language"})]}),l.jsx("div",{className:"space-y-2",children:(()=>{var Ze,we,Oe,je;let Ee=V.content.split("Originaltextstellen:")[1];Ee||(Ee=V.content.split("Original quotes:")[1]),Ee||(Ee=V.content.split("Proof of Material:")[1]);const nt=(je=(Oe=(we=(Ze=Ee==null?void 0:Ee.split("---")[0])==null?void 0:Ze.split("=== APA7 Literatur ===")[0])==null?void 0:we.split("## Literaturverzeichnis")[0])==null?void 0:Oe.split("## References")[0])==null?void 0:je.trim();if(!nt)return l.jsx("p",{className:"text-sm text-muted-foreground",children:"No original quotes available"});const rt=nt.split(/\n(?=["„]|[A-Z][a-zäöü]+,?\s+\d{4})/).filter(Re=>Re.trim());return rt.length>0?rt.map((Re,Ue)=>l.jsx("div",{className:"bg-muted/50 border-l-4 border-primary/30 p-3 rounded-r-md",children:l.jsx("p",{className:"text-sm italic whitespace-pre-wrap",children:Re.trim()})},Ue)):l.jsx("div",{className:"bg-muted/50 border-l-4 border-primary/30 p-3 rounded-r-md",children:l.jsx("p",{className:"text-sm italic whitespace-pre-wrap",children:nt})})})()})]})]}),l.jsx(vi,{}),V.literature&&V.literature.length>0&&l.jsxs("div",{children:[l.jsx("h4",{className:"font-semibold mb-2",children:"References"}),l.jsx("div",{className:"text-sm space-y-1",children:V.literature.map((Ee,nt)=>l.jsx("div",{className:"text-sm text-muted-foreground",children:Ee},nt))})]}),l.jsxs("div",{className:"flex flex-wrap gap-2",children:[z.trim()&&l.jsxs(ye,{variant:"outline",size:"sm",onClick:Pe,disabled:L,children:[L?l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}):l.jsx(Dce,{className:"mr-2 h-4 w-4"}),"Refine & Merge"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>{var Ee;return tt(`${V.title}
${V.content}
References:
${((Ee=V.literature)==null?void 0:Ee.join(`
`))||""}`)},children:[l.jsx(Tn,{className:"mr-2 h-4 w-4"}),"Copy All"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>re(!0),disabled:!V,children:[l.jsx(sE,{className:"mr-2 h-4 w-4"}),"Import to Chapter"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:wt,children:[l.jsx(Br,{className:"mr-2 h-4 w-4"}),"Go to Library"]})]})]}):l.jsxs("div",{className:"text-center py-12",children:[l.jsx(Br,{className:"mx-auto h-12 w-12 text-muted-foreground mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:'Fill in the parameters on the left and click "Generate Draft".'})]})})]})]})]}),l.jsx(Gr,{open:ee,onOpenChange:re,children:l.jsxs(zr,{children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Als Section importieren"})}),l.jsxs("div",{className:"space-y-4 py-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Thesis"}),l.jsxs(dt,{value:D,onValueChange:R,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select thesis..."})}),l.jsx(ct,{children:ie.map(Ee=>l.jsx(De,{value:Ee.id,children:Ee.title},Ee.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Target Chapter"}),l.jsxs(dt,{value:he,onValueChange:O,disabled:!D,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:D?"Select Chapter...":"Select thesis first"})}),l.jsx(ct,{children:J.map(Ee=>l.jsx(De,{value:Ee.id,children:Ee.title},Ee.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Section Title (optional)"}),l.jsx(Be,{value:ae,onChange:Ee=>q(Ee.target.value),placeholder:"e.g. Methodology & Approach"})]})]}),l.jsxs(Th,{children:[l.jsx(ye,{variant:"outline",onClick:()=>re(!1),children:"Abbrechen"}),l.jsx(ye,{onClick:ue,disabled:!he||I,children:I?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Importiere..."]}):l.jsxs(l.Fragment,{children:[l.jsx(vu,{className:"mr-2 h-4 w-4"}),"Importieren"]})})]})]})}),l.jsx(Bu,{open:i,onClose:()=>a(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]}):null},ukt=["introduction","einleitung","methodology","methodik","methods","methoden","findings","ergebnisse","results","auswertung","analyse","analysis","interviews","discussion","diskussion","stand des wissens","theoretischer hintergrund","literature","literatur","theory","theorie"],dkt=()=>{const{user:t,loading:e,checkStudentPoints:r,studentPoints:n}=Dt(),[s,i]=j.useState(!1),a=Or(),{toast:o}=qn(),[c,u]=j.useState([]),[d,h]=j.useState([]),[f,p]=j.useState(""),[m,g]=j.useState([]),[x,y]=j.useState("en"),[v,b]=j.useState("medium"),[w,S]=j.useState(!1),[k,E]=j.useState(null),[C,A]=j.useState(!1),[M,z]=j.useState(""),[P,W]=j.useState(""),[N,U]=j.useState(!1);j.useEffect(()=>{!t&&!e&&a("/login")},[t,e,a]),j.useEffect(()=>{t&&K()},[t]),j.useEffect(()=>{f&&(G(f),g([]),E(null))},[f]);const K=async()=>{try{const{data:Y,error:ie}=await be.from("theses").select("id, title, degree").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(ie)throw ie;u(Y||[]),Y&&Y.length>0&&!f&&p(Y[0].id)}catch(Y){console.error("Error loading theses:",Y),o({title:"Error",description:"Could not load theses.",variant:"destructive"})}},G=async Y=>{try{const{data:ie,error:Q}=await be.from("chapters").select("id, title, order_index").eq("thesis_id",Y).is("parent_id",null).order("order_index",{ascending:!0});if(Q)throw Q;const{data:D,error:R}=await be.from("sections").select("chapter_id, word_count").in("chapter_id",(ie||[]).map(ee=>ee.id));if(R)throw R;const J={};(D||[]).forEach(ee=>{J[ee.chapter_id]=(J[ee.chapter_id]||0)+ee.word_count});const Z=(ie||[]).map(ee=>({...ee,word_count:J[ee.id]||0,isRecommended:ukt.some(re=>ee.title.toLowerCase().includes(re))}));h(Z)}catch(ie){console.error("Error loading chapters:",ie),o({title:"Error",description:"Could not load chapters.",variant:"destructive"})}},X=Y=>{g(ie=>ie.includes(Y)?ie.filter(Q=>Q!==Y):[...ie,Y])},H=j.useMemo(()=>d.filter(Y=>Y.word_count>0),[d]),B=async()=>{var Y;if(!r()){i(!0);return}if(m.length===0){o({title:"Error",description:"Please select at least one chapter.",variant:"destructive"});return}S(!0);try{const{data:ie,error:Q}=await be.functions.invoke("discussion_builder",{body:{thesis_id:f,chapter_ids:m,language:x,mode:v}});if(Q)throw Q;const D=(ie==null?void 0:ie.content)||(ie==null?void 0:ie.discussion_text)||((Y=ie==null?void 0:ie.data)==null?void 0:Y.content);if(console.log("Discussion response:",ie),typeof D=="string")E(D);else if(D!=null&&D.discussion_text)E(D.discussion_text);else throw new Error("Invalid response format");o({title:"Success",description:"Discussion generated successfully!"})}catch(ie){console.error("Error generating discussion:",ie),o({title:"Error",description:ie.message||"Error generating discussion.",variant:"destructive"})}finally{S(!1)}},L=async()=>{if(k)try{await navigator.clipboard.writeText(k),o({title:"Copied",description:"Text copied to clipboard."})}catch{o({title:"Error",description:"Could not copy text.",variant:"destructive"})}},F=async()=>{if(!(!k||!M)){U(!0);try{const{data:Y,error:ie}=await be.from("sections").select("order_index").eq("chapter_id",M).order("order_index",{ascending:!1}).limit(1);if(ie)throw ie;const Q=Y&&Y.length>0?Y[0].order_index+1:0,{error:D}=await be.from("sections").insert({chapter_id:M,content:k,title:P.trim()||null,type:"other",order_index:Q,status:"open"});if(D)throw D;o({title:"Imported",description:"Discussion imported as section."}),A(!1),W(""),z("")}catch(Y){console.error("Error importing section:",Y),o({title:"Error",description:Y.message||"Error importing.",variant:"destructive"})}finally{U(!1)}}},V={small:"Short (~500 words)",medium:"Medium (~1000 words)",big:"Long (~2000 words)"};return e?l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?l.jsxs(gr,{showSidebar:!0,children:[l.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"Discussion Generator"}),l.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate a discussion based on your thesis chapters."})]})}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Settings"})}),l.jsxs(Ge,{className:"space-y-5",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Select Thesis"}),l.jsxs(dt,{value:f,onValueChange:p,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select thesis..."})}),l.jsx(ct,{children:c.map(Y=>l.jsx(De,{value:Y.id,children:Y.title},Y.id))})]})]}),f&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Select Chapters"}),d.length===0?l.jsx("p",{className:"text-sm text-muted-foreground",children:"No chapters available."}):H.length===0?l.jsx("p",{className:"text-sm text-muted-foreground",children:"No chapters with content available."}):l.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto border rounded-lg p-3",children:d.map(Y=>{const ie=Y.word_count>0;return l.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg transition-colors ${ie?"hover:bg-muted/50":"opacity-50"}`,children:[l.jsx(bl,{id:Y.id,checked:m.includes(Y.id),onCheckedChange:()=>X(Y.id),disabled:!ie}),l.jsx("label",{htmlFor:Y.id,className:`flex-1 text-sm ${ie?"cursor-pointer":"cursor-not-allowed"}`,children:Y.title}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:[Y.word_count," words"]}),Y.isRecommended&&ie&&l.jsx(kt,{variant:"secondary",className:"text-xs",children:"Recommended"})]},Y.id)})}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[m.length," chapter(s) selected"]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Language"}),l.jsxs(dt,{value:x,onValueChange:Y=>y(Y),children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"de",children:"Deutsch"}),l.jsx(De,{value:"en",children:"English"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Length"}),l.jsxs(dt,{value:v,onValueChange:Y=>b(Y),children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"small",children:V.small}),l.jsx(De,{value:"medium",children:V.medium}),l.jsx(De,{value:"big",children:V.big})]})]})]}),l.jsx(ye,{onClick:B,disabled:w||m.length===0,className:"w-full",children:w?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating Discussion..."]}):"Generate Discussion"})]})]}),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Result"})}),l.jsx(Ge,{children:k?l.jsxs("div",{className:"space-y-4",children:[l.jsx("div",{className:"prose prose-sm max-w-none text-sm max-h-[500px] overflow-y-auto",children:l.jsx(pc,{components:{h1:({children:Y})=>l.jsx("h1",{className:"text-lg font-semibold mt-6 mb-3 first:mt-0",children:Y}),h2:({children:Y})=>l.jsx("h2",{className:"text-base font-semibold mt-5 mb-2",children:Y}),h3:({children:Y})=>l.jsx("h3",{className:"text-sm font-semibold mt-4 mb-2",children:Y}),p:({children:Y})=>l.jsx("p",{className:"mb-3 leading-relaxed",children:Y}),ul:({children:Y})=>l.jsx("ul",{className:"mb-3 ml-4 list-disc",children:Y}),ol:({children:Y})=>l.jsx("ol",{className:"mb-3 ml-4 list-decimal",children:Y}),li:({children:Y})=>l.jsx("li",{className:"mb-1",children:Y})},children:k})}),l.jsxs("div",{className:"flex flex-wrap gap-2 pt-4 border-t",children:[l.jsxs(ye,{variant:"outline",size:"sm",onClick:L,children:[l.jsx(Tn,{className:"mr-2 h-4 w-4"}),"Copy"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>A(!0),children:[l.jsx(sE,{className:"mr-2 h-4 w-4"}),"Import to Chapter"]})]})]}):l.jsxs("div",{className:"text-center py-12",children:[l.jsx(Br,{className:"mx-auto h-12 w-12 text-muted-foreground mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:'Select a thesis and chapters, then click "Generate Discussion".'})]})})]})]})]}),l.jsx(Gr,{open:C,onOpenChange:A,children:l.jsxs(zr,{children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Import as Section"})}),l.jsxs("div",{className:"space-y-4 py-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Target Chapter"}),l.jsxs(dt,{value:M,onValueChange:z,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select chapter..."})}),l.jsx(ct,{children:d.map(Y=>l.jsx(De,{value:Y.id,children:Y.title},Y.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Section Title (optional)"}),l.jsx(Be,{value:P,onChange:Y=>W(Y.target.value),placeholder:"e.g. Discussion of Results"})]})]}),l.jsxs(Th,{children:[l.jsx(ye,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),l.jsx(ye,{onClick:F,disabled:!M||N,children:N?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):l.jsxs(l.Fragment,{children:[l.jsx(vu,{className:"mr-2 h-4 w-4"}),"Import"]})})]})]})}),l.jsx(Bu,{open:s,onClose:()=>i(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]}):null},hkt=["introduction","einleitung","methodology","methodik","methods","methoden","findings","ergebnisse","results","auswertung","analyse","analysis","interviews","discussion","diskussion","stand des wissens","theoretischer hintergrund","literature","literatur","theory","theorie","zusammenfassung","summary","conclusion"],fkt=()=>{const{user:t,loading:e,checkStudentPoints:r,studentPoints:n}=Dt(),[s,i]=j.useState(!1),a=Or(),{toast:o}=qn(),[c,u]=j.useState([]),[d,h]=j.useState([]),[f,p]=j.useState(""),[m,g]=j.useState([]),[x,y]=j.useState("en"),[v,b]=j.useState("medium"),[w,S]=j.useState(!0),[k,E]=j.useState(!0),[C,A]=j.useState(!1),[M,z]=j.useState(null),[P,W]=j.useState(!1),[N,U]=j.useState(""),[K,G]=j.useState(""),[X,H]=j.useState(!1);j.useEffect(()=>{!t&&!e&&a("/login")},[t,e,a]),j.useEffect(()=>{t&&B()},[t]),j.useEffect(()=>{f&&(L(f),g([]),z(null))},[f]);const B=async()=>{try{const{data:R,error:J}=await be.from("theses").select("id, title, degree").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(J)throw J;u(R||[]),R&&R.length>0&&!f&&p(R[0].id)}catch(R){console.error("Error loading theses:",R),o({title:"Error",description:"Could not load theses.",variant:"destructive"})}},L=async R=>{try{const{data:J,error:Z}=await be.from("chapters").select("id, title, order_index").eq("thesis_id",R).is("parent_id",null).order("order_index",{ascending:!0});if(Z)throw Z;const{data:ee,error:re}=await be.from("sections").select("chapter_id, word_count").in("chapter_id",(J||[]).map(ae=>ae.id));if(re)throw re;const he={};(ee||[]).forEach(ae=>{he[ae.chapter_id]=(he[ae.chapter_id]||0)+ae.word_count});const O=(J||[]).map(ae=>({...ae,word_count:he[ae.id]||0,isRecommended:hkt.some(q=>ae.title.toLowerCase().includes(q))}));h(O)}catch(J){console.error("Error loading chapters:",J),o({title:"Error",description:"Could not load chapters.",variant:"destructive"})}},F=R=>{g(J=>J.includes(R)?J.filter(Z=>Z!==R):[...J,R])},V=j.useMemo(()=>d.filter(R=>R.word_count>0),[d]),Y=async()=>{if(!r()){i(!0);return}if(m.length===0){o({title:"Error",description:"Please select at least one chapter.",variant:"destructive"});return}A(!0);try{const{data:R,error:J}=await be.functions.invoke("conclusion_builder",{body:{thesis_id:f,chapter_ids:m,language:x,mode:v,include_limitations:w,include_outlook:k}});if(J)throw J;const Z=(R==null?void 0:R.conclusion_text)||(R==null?void 0:R.content);if(console.log("Conclusion response:",R),typeof Z=="string")z(Z);else throw new Error("Invalid response format");o({title:"Success",description:"Conclusion generated successfully!"})}catch(R){console.error("Error generating conclusion:",R),o({title:"Error",description:R.message||"Error generating conclusion.",variant:"destructive"})}finally{A(!1)}},ie=async()=>{if(M)try{await navigator.clipboard.writeText(M),o({title:"Copied",description:"Text copied to clipboard."})}catch{o({title:"Error",description:"Could not copy text.",variant:"destructive"})}},Q=async()=>{if(!(!M||!N)){H(!0);try{const{data:R,error:J}=await be.from("sections").select("order_index").eq("chapter_id",N).order("order_index",{ascending:!1}).limit(1);if(J)throw J;const Z=R&&R.length>0?R[0].order_index+1:0,{error:ee}=await be.from("sections").insert({chapter_id:N,content:M,title:K.trim()||null,type:"other",order_index:Z,status:"open"});if(ee)throw ee;o({title:"Imported",description:"Conclusion imported as section."}),W(!1),G(""),U("")}catch(R){console.error("Error importing section:",R),o({title:"Error",description:R.message||"Error importing.",variant:"destructive"})}finally{H(!1)}}},D={small:"Short (~500 words)",medium:"Medium (~1000 words)",big:"Long (~2000 words)"};return e?l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?l.jsxs(gr,{showSidebar:!0,children:[l.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"Conclusion Generator"}),l.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate a conclusion based on your thesis chapters including limitations and outlook."})]})}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Settings"})}),l.jsxs(Ge,{className:"space-y-5",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Select Thesis"}),l.jsxs(dt,{value:f,onValueChange:p,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select thesis..."})}),l.jsx(ct,{children:c.map(R=>l.jsx(De,{value:R.id,children:R.title},R.id))})]})]}),f&&l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Select Chapters"}),d.length===0?l.jsx("p",{className:"text-sm text-muted-foreground",children:"No chapters available."}):V.length===0?l.jsx("p",{className:"text-sm text-muted-foreground",children:"No chapters with content available."}):l.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto border rounded-lg p-3",children:d.map(R=>{const J=R.word_count>0;return l.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg transition-colors ${J?"hover:bg-muted/50":"opacity-50"}`,children:[l.jsx(bl,{id:R.id,checked:m.includes(R.id),onCheckedChange:()=>F(R.id),disabled:!J}),l.jsx("label",{htmlFor:R.id,className:`flex-1 text-sm ${J?"cursor-pointer":"cursor-not-allowed"}`,children:R.title}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:[R.word_count," words"]}),R.isRecommended&&J&&l.jsx(kt,{variant:"secondary",className:"text-xs",children:"Recommended"})]},R.id)})}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[m.length," chapter(s) selected"]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Language"}),l.jsxs(dt,{value:x,onValueChange:R=>y(R),children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"de",children:"Deutsch"}),l.jsx(De,{value:"en",children:"English"})]})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx(_e,{children:"Include Sections"}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(bl,{id:"include-limitations",checked:w,onCheckedChange:R=>S(!!R)}),l.jsx("label",{htmlFor:"include-limitations",className:"text-sm cursor-pointer",children:"Limitations (Einschränkungen der Studie)"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(bl,{id:"include-outlook",checked:k,onCheckedChange:R=>E(!!R)}),l.jsx("label",{htmlFor:"include-outlook",className:"text-sm cursor-pointer",children:"Ausblick / Future Research"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Length"}),l.jsxs(dt,{value:v,onValueChange:R=>b(R),children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"small",children:D.small}),l.jsx(De,{value:"medium",children:D.medium}),l.jsx(De,{value:"big",children:D.big})]})]})]}),l.jsx(ye,{onClick:Y,disabled:C||m.length===0,className:"w-full",children:C?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating Conclusion..."]}):"Generate Conclusion"})]})]}),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Result"})}),l.jsx(Ge,{children:M?l.jsxs("div",{className:"space-y-4",children:[l.jsx("div",{className:"prose prose-sm max-w-none text-sm max-h-[500px] overflow-y-auto",children:l.jsx(pc,{components:{h1:({children:R})=>l.jsx("h1",{className:"text-lg font-semibold mt-6 mb-3 first:mt-0",children:R}),h2:({children:R})=>l.jsx("h2",{className:"text-base font-semibold mt-5 mb-2",children:R}),h3:({children:R})=>l.jsx("h3",{className:"text-sm font-semibold mt-4 mb-2",children:R}),p:({children:R})=>l.jsx("p",{className:"mb-3 leading-relaxed",children:R}),ul:({children:R})=>l.jsx("ul",{className:"mb-3 ml-4 list-disc",children:R}),ol:({children:R})=>l.jsx("ol",{className:"mb-3 ml-4 list-decimal",children:R}),li:({children:R})=>l.jsx("li",{className:"mb-1",children:R})},children:M})}),l.jsxs("div",{className:"flex flex-wrap gap-2 pt-4 border-t",children:[l.jsxs(ye,{variant:"outline",size:"sm",onClick:ie,children:[l.jsx(Tn,{className:"mr-2 h-4 w-4"}),"Copy"]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:()=>W(!0),children:[l.jsx(sE,{className:"mr-2 h-4 w-4"}),"Import to Chapter"]})]})]}):l.jsxs("div",{className:"text-center py-12",children:[l.jsx(Br,{className:"mx-auto h-12 w-12 text-muted-foreground mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:'Select a thesis and chapters, then click "Generate Conclusion".'})]})})]})]})]}),l.jsx(Gr,{open:P,onOpenChange:W,children:l.jsxs(zr,{children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Import Conclusion as Section"})}),l.jsxs("div",{className:"space-y-4 py-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Target Chapter"}),l.jsxs(dt,{value:N,onValueChange:U,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select chapter..."})}),l.jsx(ct,{children:d.map(R=>l.jsx(De,{value:R.id,children:R.title},R.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Section Title (optional)"}),l.jsx(Be,{value:K,onChange:R=>G(R.target.value),placeholder:"e.g. Conclusion"})]})]}),l.jsxs(Th,{children:[l.jsx(ye,{variant:"outline",onClick:()=>W(!1),children:"Cancel"}),l.jsx(ye,{onClick:Q,disabled:!N||X,children:X?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):l.jsxs(l.Fragment,{children:[l.jsx(vu,{className:"mr-2 h-4 w-4"}),"Import"]})})]})]})}),l.jsx(Bu,{open:s,onClose:()=>i(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]}):null};var pkt=Object.defineProperty,mkt=Object.defineProperties,gkt=Object.getOwnPropertyDescriptors,fre=Object.getOwnPropertySymbols,ykt=Object.prototype.hasOwnProperty,xkt=Object.prototype.propertyIsEnumerable,$z=(t,e,r)=>e in t?pkt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fr=(t,e)=>{for(var r in e||(e={}))ykt.call(e,r)&&$z(t,r,e[r]);if(fre)for(var r of fre(e))xkt.call(e,r)&&$z(t,r,e[r]);return t},ww=(t,e)=>mkt(t,gkt(e)),Fe=(t,e,r)=>$z(t,typeof e!="symbol"?e+"":e,r),vkt=(t,e,r)=>new Promise((n,s)=>{var i=c=>{try{o(r.next(c))}catch(u){s(u)}},a=c=>{try{o(r.throw(c))}catch(u){s(u)}},o=c=>c.done?n(c.value):Promise.resolve(c.value).then(i,a);o((r=r.apply(t,e)).next())});class NO{constructor(e){Fe(this,"rootKey"),this.rootKey=e}}const bkt=Object.seal({});class $e extends NO{constructor(e){super(e),Fe(this,"root"),this.root=new Array}prepForXml(e){var r;e.stack.push(this);const n=this.root.map(s=>s instanceof NO?s.prepForXml(e):s).filter(s=>s!==void 0);return e.stack.pop(),{[this.rootKey]:n.length?n.length===1&&((r=n[0])!=null&&r._attr)?n[0]:n:bkt}}addChildElement(e){return this.root.push(e),this}}class rD extends $e{prepForXml(e){const r=super.prepForXml(e);if(r&&(typeof r[this.rootKey]!="object"||Object.keys(r[this.rootKey]).length))return r}}class Rt extends NO{constructor(e){super("_attr"),Fe(this,"xmlKeys"),this.root=e}prepForXml(e){const r={};return Object.entries(this.root).forEach(([n,s])=>{if(s!==void 0){const i=this.xmlKeys&&this.xmlKeys[n]||n;r[i]=s}}),{_attr:r}}}class nD extends NO{constructor(e){super("_attr"),this.root=e}prepForXml(e){return{_attr:Object.values(this.root).filter(({value:n})=>n!==void 0).reduce((n,{key:s,value:i})=>ww(fr({},n),{[s]:i}),{})}}}class Gn extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{val:"w:val",color:"w:color",fill:"w:fill",space:"w:space",sz:"w:sz",type:"w:type",rsidR:"w:rsidR",rsidRPr:"w:rsidRPr",rsidSect:"w:rsidSect",w:"w:w",h:"w:h",top:"w:top",right:"w:right",bottom:"w:bottom",left:"w:left",header:"w:header",footer:"w:footer",gutter:"w:gutter",linePitch:"w:linePitch",pos:"w:pos"})}}var gu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xSe(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var J4={},bC={exports:{}},pre;function c7(){if(pre)return bC.exports;pre=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(S,k,E){return Function.prototype.apply.call(S,k,E)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(S){return Object.getOwnPropertyNames(S).concat(Object.getOwnPropertySymbols(S))}:r=function(S){return Object.getOwnPropertyNames(S)};function n(w){console&&console.warn&&console.warn(w)}var s=Number.isNaN||function(S){return S!==S};function i(){i.init.call(this)}bC.exports=i,bC.exports.once=y,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function o(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(w){if(typeof w!="number"||w<0||s(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");a=w}}),i.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(S){if(typeof S!="number"||S<0||s(S))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+S+".");return this._maxListeners=S,this};function c(w){return w._maxListeners===void 0?i.defaultMaxListeners:w._maxListeners}i.prototype.getMaxListeners=function(){return c(this)},i.prototype.emit=function(S){for(var k=[],E=1;E<arguments.length;E++)k.push(arguments[E]);var C=S==="error",A=this._events;if(A!==void 0)C=C&&A.error===void 0;else if(!C)return!1;if(C){var M;if(k.length>0&&(M=k[0]),M instanceof Error)throw M;var z=new Error("Unhandled error."+(M?" ("+M.message+")":""));throw z.context=M,z}var P=A[S];if(P===void 0)return!1;if(typeof P=="function")e(P,this,k);else for(var W=P.length,N=m(P,W),E=0;E<W;++E)e(N[E],this,k);return!0};function u(w,S,k,E){var C,A,M;if(o(k),A=w._events,A===void 0?(A=w._events=Object.create(null),w._eventsCount=0):(A.newListener!==void 0&&(w.emit("newListener",S,k.listener?k.listener:k),A=w._events),M=A[S]),M===void 0)M=A[S]=k,++w._eventsCount;else if(typeof M=="function"?M=A[S]=E?[k,M]:[M,k]:E?M.unshift(k):M.push(k),C=c(w),C>0&&M.length>C&&!M.warned){M.warned=!0;var z=new Error("Possible EventEmitter memory leak detected. "+M.length+" "+String(S)+" listeners added. Use emitter.setMaxListeners() to increase limit");z.name="MaxListenersExceededWarning",z.emitter=w,z.type=S,z.count=M.length,n(z)}return w}i.prototype.addListener=function(S,k){return u(this,S,k,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(S,k){return u(this,S,k,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(w,S,k){var E={fired:!1,wrapFn:void 0,target:w,type:S,listener:k},C=d.bind(E);return C.listener=k,E.wrapFn=C,C}i.prototype.once=function(S,k){return o(k),this.on(S,h(this,S,k)),this},i.prototype.prependOnceListener=function(S,k){return o(k),this.prependListener(S,h(this,S,k)),this},i.prototype.removeListener=function(S,k){var E,C,A,M,z;if(o(k),C=this._events,C===void 0)return this;if(E=C[S],E===void 0)return this;if(E===k||E.listener===k)--this._eventsCount===0?this._events=Object.create(null):(delete C[S],C.removeListener&&this.emit("removeListener",S,E.listener||k));else if(typeof E!="function"){for(A=-1,M=E.length-1;M>=0;M--)if(E[M]===k||E[M].listener===k){z=E[M].listener,A=M;break}if(A<0)return this;A===0?E.shift():g(E,A),E.length===1&&(C[S]=E[0]),C.removeListener!==void 0&&this.emit("removeListener",S,z||k)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(S){var k,E,C;if(E=this._events,E===void 0)return this;if(E.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):E[S]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete E[S]),this;if(arguments.length===0){var A=Object.keys(E),M;for(C=0;C<A.length;++C)M=A[C],M!=="removeListener"&&this.removeAllListeners(M);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(k=E[S],typeof k=="function")this.removeListener(S,k);else if(k!==void 0)for(C=k.length-1;C>=0;C--)this.removeListener(S,k[C]);return this};function f(w,S,k){var E=w._events;if(E===void 0)return[];var C=E[S];return C===void 0?[]:typeof C=="function"?k?[C.listener||C]:[C]:k?x(C):m(C,C.length)}i.prototype.listeners=function(S){return f(this,S,!0)},i.prototype.rawListeners=function(S){return f(this,S,!1)},i.listenerCount=function(w,S){return typeof w.listenerCount=="function"?w.listenerCount(S):p.call(w,S)},i.prototype.listenerCount=p;function p(w){var S=this._events;if(S!==void 0){var k=S[w];if(typeof k=="function")return 1;if(k!==void 0)return k.length}return 0}i.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function m(w,S){for(var k=new Array(S),E=0;E<S;++E)k[E]=w[E];return k}function g(w,S){for(;S+1<w.length;S++)w[S]=w[S+1];w.pop()}function x(w){for(var S=new Array(w.length),k=0;k<S.length;++k)S[k]=w[k].listener||w[k];return S}function y(w,S){return new Promise(function(k,E){function C(M){w.removeListener(S,A),E(M)}function A(){typeof w.removeListener=="function"&&w.removeListener("error",C),k([].slice.call(arguments))}b(w,S,A,{once:!0}),S!=="error"&&v(w,C,{once:!0})})}function v(w,S,k){typeof w.on=="function"&&b(w,"error",S,k)}function b(w,S,k,E){if(typeof w.on=="function")E.once?w.once(S,k):w.on(S,k);else if(typeof w.addEventListener=="function")w.addEventListener(S,function C(A){E.once&&w.removeEventListener(S,C),k(A)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return bC.exports}var wC={exports:{}},mre;function gm(){return mre||(mre=1,typeof Object.create=="function"?wC.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:wC.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}),wC.exports}function wkt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var vSe={exports:{}},ts=vSe.exports={},zc,Uc;function Bz(){throw new Error("setTimeout has not been defined")}function zz(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?zc=setTimeout:zc=Bz}catch{zc=Bz}try{typeof clearTimeout=="function"?Uc=clearTimeout:Uc=zz}catch{Uc=zz}})();function bSe(t){if(zc===setTimeout)return setTimeout(t,0);if((zc===Bz||!zc)&&setTimeout)return zc=setTimeout,setTimeout(t,0);try{return zc(t,0)}catch{try{return zc.call(null,t,0)}catch{return zc.call(this,t,0)}}}function Skt(t){if(Uc===clearTimeout)return clearTimeout(t);if((Uc===zz||!Uc)&&clearTimeout)return Uc=clearTimeout,clearTimeout(t);try{return Uc(t)}catch{try{return Uc.call(null,t)}catch{return Uc.call(this,t)}}}var Xd=[],hb=!1,ig,e2=-1;function _kt(){!hb||!ig||(hb=!1,ig.length?Xd=ig.concat(Xd):e2=-1,Xd.length&&wSe())}function wSe(){if(!hb){var t=bSe(_kt);hb=!0;for(var e=Xd.length;e;){for(ig=Xd,Xd=[];++e2<e;)ig&&ig[e2].run();e2=-1,e=Xd.length}ig=null,hb=!1,Skt(t)}}ts.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];Xd.push(new SSe(t,e)),Xd.length===1&&!hb&&bSe(wSe)};function SSe(t,e){this.fun=t,this.array=e}SSe.prototype.run=function(){this.fun.apply(null,this.array)};ts.title="browser";ts.browser=!0;ts.env={};ts.argv=[];ts.version="";ts.versions={};function Dh(){}ts.on=Dh;ts.addListener=Dh;ts.once=Dh;ts.off=Dh;ts.removeListener=Dh;ts.removeAllListeners=Dh;ts.emit=Dh;ts.prependListener=Dh;ts.prependOnceListener=Dh;ts.listeners=function(t){return[]};ts.binding=function(t){throw new Error("process.binding is not supported")};ts.cwd=function(){return"/"};ts.chdir=function(t){throw new Error("process.chdir is not supported")};ts.umask=function(){return 0};var jkt=vSe.exports;const Jt=wkt(jkt);var Q4,gre;function _Se(){return gre||(gre=1,Q4=c7().EventEmitter),Q4}var Z4={},Y1={},yre;function kkt(){if(yre)return Y1;yre=1,Y1.byteLength=o,Y1.toByteArray=u,Y1.fromByteArray=f;for(var t=[],e=[],r=typeof Uint8Array<"u"?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=n.length;s<i;++s)t[s]=n[s],e[n.charCodeAt(s)]=s;e[45]=62,e[95]=63;function a(p){var m=p.length;if(m%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var g=p.indexOf("=");g===-1&&(g=m);var x=g===m?0:4-g%4;return[g,x]}function o(p){var m=a(p),g=m[0],x=m[1];return(g+x)*3/4-x}function c(p,m,g){return(m+g)*3/4-g}function u(p){var m,g=a(p),x=g[0],y=g[1],v=new r(c(p,x,y)),b=0,w=y>0?x-4:x,S;for(S=0;S<w;S+=4)m=e[p.charCodeAt(S)]<<18|e[p.charCodeAt(S+1)]<<12|e[p.charCodeAt(S+2)]<<6|e[p.charCodeAt(S+3)],v[b++]=m>>16&255,v[b++]=m>>8&255,v[b++]=m&255;return y===2&&(m=e[p.charCodeAt(S)]<<2|e[p.charCodeAt(S+1)]>>4,v[b++]=m&255),y===1&&(m=e[p.charCodeAt(S)]<<10|e[p.charCodeAt(S+1)]<<4|e[p.charCodeAt(S+2)]>>2,v[b++]=m>>8&255,v[b++]=m&255),v}function d(p){return t[p>>18&63]+t[p>>12&63]+t[p>>6&63]+t[p&63]}function h(p,m,g){for(var x,y=[],v=m;v<g;v+=3)x=(p[v]<<16&16711680)+(p[v+1]<<8&65280)+(p[v+2]&255),y.push(d(x));return y.join("")}function f(p){for(var m,g=p.length,x=g%3,y=[],v=16383,b=0,w=g-x;b<w;b+=v)y.push(h(p,b,b+v>w?w:b+v));return x===1?(m=p[g-1],y.push(t[m>>2]+t[m<<4&63]+"==")):x===2&&(m=(p[g-2]<<8)+p[g-1],y.push(t[m>>10]+t[m>>4&63]+t[m<<2&63]+"=")),y.join("")}return Y1}var SC={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var xre;function Nkt(){return xre||(xre=1,SC.read=function(t,e,r,n,s){var i,a,o=s*8-n-1,c=(1<<o)-1,u=c>>1,d=-7,h=r?s-1:0,f=r?-1:1,p=t[e+h];for(h+=f,i=p&(1<<-d)-1,p>>=-d,d+=o;d>0;i=i*256+t[e+h],h+=f,d-=8);for(a=i&(1<<-d)-1,i>>=-d,d+=n;d>0;a=a*256+t[e+h],h+=f,d-=8);if(i===0)i=1-u;else{if(i===c)return a?NaN:(p?-1:1)*(1/0);a=a+Math.pow(2,n),i=i-u}return(p?-1:1)*a*Math.pow(2,i-n)},SC.write=function(t,e,r,n,s,i){var a,o,c,u=i*8-s-1,d=(1<<u)-1,h=d>>1,f=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,m=n?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=d):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),a+h>=1?e+=f/c:e+=f*Math.pow(2,1-h),e*c>=2&&(a++,c/=2),a+h>=d?(o=0,a=d):a+h>=1?(o=(e*c-1)*Math.pow(2,s),a=a+h):(o=e*Math.pow(2,h-1)*Math.pow(2,s),a=0));s>=8;t[r+p]=o&255,p+=m,o/=256,s-=8);for(a=a<<s|o,u+=s;u>0;t[r+p]=a&255,p+=m,a/=256,u-=8);t[r+p-m]|=g*128}),SC}/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/var vre;function sD(){return vre||(vre=1,function(t){var e=kkt(),r=Nkt(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=o,t.SlowBuffer=v,t.INSPECT_MAX_BYTES=50;var s=2147483647;t.kMaxLength=s,o.TYPED_ARRAY_SUPPORT=i(),!o.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{var q=new Uint8Array(1),I={foo:function(){return 42}};return Object.setPrototypeOf(I,Uint8Array.prototype),Object.setPrototypeOf(q,I),q.foo()===42}catch{return!1}}Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}});function a(q){if(q>s)throw new RangeError('The value "'+q+'" is invalid for option "size"');var I=new Uint8Array(q);return Object.setPrototypeOf(I,o.prototype),I}function o(q,I,T){if(typeof q=="number"){if(typeof I=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return h(q)}return c(q,I,T)}o.poolSize=8192;function c(q,I,T){if(typeof q=="string")return f(q,I);if(ArrayBuffer.isView(q))return m(q);if(q==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q);if(he(q,ArrayBuffer)||q&&he(q.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(he(q,SharedArrayBuffer)||q&&he(q.buffer,SharedArrayBuffer)))return g(q,I,T);if(typeof q=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var $=q.valueOf&&q.valueOf();if($!=null&&$!==q)return o.from($,I,T);var se=x(q);if(se)return se;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof q[Symbol.toPrimitive]=="function")return o.from(q[Symbol.toPrimitive]("string"),I,T);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof q)}o.from=function(q,I,T){return c(q,I,T)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array);function u(q){if(typeof q!="number")throw new TypeError('"size" argument must be of type number');if(q<0)throw new RangeError('The value "'+q+'" is invalid for option "size"')}function d(q,I,T){return u(q),q<=0?a(q):I!==void 0?typeof T=="string"?a(q).fill(I,T):a(q).fill(I):a(q)}o.alloc=function(q,I,T){return d(q,I,T)};function h(q){return u(q),a(q<0?0:y(q)|0)}o.allocUnsafe=function(q){return h(q)},o.allocUnsafeSlow=function(q){return h(q)};function f(q,I){if((typeof I!="string"||I==="")&&(I="utf8"),!o.isEncoding(I))throw new TypeError("Unknown encoding: "+I);var T=b(q,I)|0,$=a(T),se=$.write(q,I);return se!==T&&($=$.slice(0,se)),$}function p(q){for(var I=q.length<0?0:y(q.length)|0,T=a(I),$=0;$<I;$+=1)T[$]=q[$]&255;return T}function m(q){if(he(q,Uint8Array)){var I=new Uint8Array(q);return g(I.buffer,I.byteOffset,I.byteLength)}return p(q)}function g(q,I,T){if(I<0||q.byteLength<I)throw new RangeError('"offset" is outside of buffer bounds');if(q.byteLength<I+(T||0))throw new RangeError('"length" is outside of buffer bounds');var $;return I===void 0&&T===void 0?$=new Uint8Array(q):T===void 0?$=new Uint8Array(q,I):$=new Uint8Array(q,I,T),Object.setPrototypeOf($,o.prototype),$}function x(q){if(o.isBuffer(q)){var I=y(q.length)|0,T=a(I);return T.length===0||q.copy(T,0,0,I),T}if(q.length!==void 0)return typeof q.length!="number"||O(q.length)?a(0):p(q);if(q.type==="Buffer"&&Array.isArray(q.data))return p(q.data)}function y(q){if(q>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return q|0}function v(q){return+q!=q&&(q=0),o.alloc(+q)}o.isBuffer=function(I){return I!=null&&I._isBuffer===!0&&I!==o.prototype},o.compare=function(I,T){if(he(I,Uint8Array)&&(I=o.from(I,I.offset,I.byteLength)),he(T,Uint8Array)&&(T=o.from(T,T.offset,T.byteLength)),!o.isBuffer(I)||!o.isBuffer(T))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(I===T)return 0;for(var $=I.length,se=T.length,ue=0,ne=Math.min($,se);ue<ne;++ue)if(I[ue]!==T[ue]){$=I[ue],se=T[ue];break}return $<se?-1:se<$?1:0},o.isEncoding=function(I){switch(String(I).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(I,T){if(!Array.isArray(I))throw new TypeError('"list" argument must be an Array of Buffers');if(I.length===0)return o.alloc(0);var $;if(T===void 0)for(T=0,$=0;$<I.length;++$)T+=I[$].length;var se=o.allocUnsafe(T),ue=0;for($=0;$<I.length;++$){var ne=I[$];if(he(ne,Uint8Array))ue+ne.length>se.length?o.from(ne).copy(se,ue):Uint8Array.prototype.set.call(se,ne,ue);else if(o.isBuffer(ne))ne.copy(se,ue);else throw new TypeError('"list" argument must be an Array of Buffers');ue+=ne.length}return se};function b(q,I){if(o.isBuffer(q))return q.length;if(ArrayBuffer.isView(q)||he(q,ArrayBuffer))return q.byteLength;if(typeof q!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof q);var T=q.length,$=arguments.length>2&&arguments[2]===!0;if(!$&&T===0)return 0;for(var se=!1;;)switch(I){case"ascii":case"latin1":case"binary":return T;case"utf8":case"utf-8":return R(q).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T*2;case"hex":return T>>>1;case"base64":return ee(q).length;default:if(se)return $?-1:R(q).length;I=(""+I).toLowerCase(),se=!0}}o.byteLength=b;function w(q,I,T){var $=!1;if((I===void 0||I<0)&&(I=0),I>this.length||((T===void 0||T>this.length)&&(T=this.length),T<=0)||(T>>>=0,I>>>=0,T<=I))return"";for(q||(q="utf8");;)switch(q){case"hex":return H(this,I,T);case"utf8":case"utf-8":return N(this,I,T);case"ascii":return G(this,I,T);case"latin1":case"binary":return X(this,I,T);case"base64":return W(this,I,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,I,T);default:if($)throw new TypeError("Unknown encoding: "+q);q=(q+"").toLowerCase(),$=!0}}o.prototype._isBuffer=!0;function S(q,I,T){var $=q[I];q[I]=q[T],q[T]=$}o.prototype.swap16=function(){var I=this.length;if(I%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var T=0;T<I;T+=2)S(this,T,T+1);return this},o.prototype.swap32=function(){var I=this.length;if(I%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var T=0;T<I;T+=4)S(this,T,T+3),S(this,T+1,T+2);return this},o.prototype.swap64=function(){var I=this.length;if(I%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var T=0;T<I;T+=8)S(this,T,T+7),S(this,T+1,T+6),S(this,T+2,T+5),S(this,T+3,T+4);return this},o.prototype.toString=function(){var I=this.length;return I===0?"":arguments.length===0?N(this,0,I):w.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(I){if(!o.isBuffer(I))throw new TypeError("Argument must be a Buffer");return this===I?!0:o.compare(this,I)===0},o.prototype.inspect=function(){var I="",T=t.INSPECT_MAX_BYTES;return I=this.toString("hex",0,T).replace(/(.{2})/g,"$1 ").trim(),this.length>T&&(I+=" ... "),"<Buffer "+I+">"},n&&(o.prototype[n]=o.prototype.inspect),o.prototype.compare=function(I,T,$,se,ue){if(he(I,Uint8Array)&&(I=o.from(I,I.offset,I.byteLength)),!o.isBuffer(I))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof I);if(T===void 0&&(T=0),$===void 0&&($=I?I.length:0),se===void 0&&(se=0),ue===void 0&&(ue=this.length),T<0||$>I.length||se<0||ue>this.length)throw new RangeError("out of range index");if(se>=ue&&T>=$)return 0;if(se>=ue)return-1;if(T>=$)return 1;if(T>>>=0,$>>>=0,se>>>=0,ue>>>=0,this===I)return 0;for(var ne=ue-se,me=$-T,ve=Math.min(ne,me),xe=this.slice(se,ue),oe=I.slice(T,$),de=0;de<ve;++de)if(xe[de]!==oe[de]){ne=xe[de],me=oe[de];break}return ne<me?-1:me<ne?1:0};function k(q,I,T,$,se){if(q.length===0)return-1;if(typeof T=="string"?($=T,T=0):T>2147483647?T=2147483647:T<-2147483648&&(T=-2147483648),T=+T,O(T)&&(T=se?0:q.length-1),T<0&&(T=q.length+T),T>=q.length){if(se)return-1;T=q.length-1}else if(T<0)if(se)T=0;else return-1;if(typeof I=="string"&&(I=o.from(I,$)),o.isBuffer(I))return I.length===0?-1:E(q,I,T,$,se);if(typeof I=="number")return I=I&255,typeof Uint8Array.prototype.indexOf=="function"?se?Uint8Array.prototype.indexOf.call(q,I,T):Uint8Array.prototype.lastIndexOf.call(q,I,T):E(q,[I],T,$,se);throw new TypeError("val must be string, number or Buffer")}function E(q,I,T,$,se){var ue=1,ne=q.length,me=I.length;if($!==void 0&&($=String($).toLowerCase(),$==="ucs2"||$==="ucs-2"||$==="utf16le"||$==="utf-16le")){if(q.length<2||I.length<2)return-1;ue=2,ne/=2,me/=2,T/=2}function ve(Se,ke){return ue===1?Se[ke]:Se.readUInt16BE(ke*ue)}var xe;if(se){var oe=-1;for(xe=T;xe<ne;xe++)if(ve(q,xe)===ve(I,oe===-1?0:xe-oe)){if(oe===-1&&(oe=xe),xe-oe+1===me)return oe*ue}else oe!==-1&&(xe-=xe-oe),oe=-1}else for(T+me>ne&&(T=ne-me),xe=T;xe>=0;xe--){for(var de=!0,ge=0;ge<me;ge++)if(ve(q,xe+ge)!==ve(I,ge)){de=!1;break}if(de)return xe}return-1}o.prototype.includes=function(I,T,$){return this.indexOf(I,T,$)!==-1},o.prototype.indexOf=function(I,T,$){return k(this,I,T,$,!0)},o.prototype.lastIndexOf=function(I,T,$){return k(this,I,T,$,!1)};function C(q,I,T,$){T=Number(T)||0;var se=q.length-T;$?($=Number($),$>se&&($=se)):$=se;var ue=I.length;$>ue/2&&($=ue/2);for(var ne=0;ne<$;++ne){var me=parseInt(I.substr(ne*2,2),16);if(O(me))return ne;q[T+ne]=me}return ne}function A(q,I,T,$){return re(R(I,q.length-T),q,T,$)}function M(q,I,T,$){return re(J(I),q,T,$)}function z(q,I,T,$){return re(ee(I),q,T,$)}function P(q,I,T,$){return re(Z(I,q.length-T),q,T,$)}o.prototype.write=function(I,T,$,se){if(T===void 0)se="utf8",$=this.length,T=0;else if($===void 0&&typeof T=="string")se=T,$=this.length,T=0;else if(isFinite(T))T=T>>>0,isFinite($)?($=$>>>0,se===void 0&&(se="utf8")):(se=$,$=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var ue=this.length-T;if(($===void 0||$>ue)&&($=ue),I.length>0&&($<0||T<0)||T>this.length)throw new RangeError("Attempt to write outside buffer bounds");se||(se="utf8");for(var ne=!1;;)switch(se){case"hex":return C(this,I,T,$);case"utf8":case"utf-8":return A(this,I,T,$);case"ascii":case"latin1":case"binary":return M(this,I,T,$);case"base64":return z(this,I,T,$);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,I,T,$);default:if(ne)throw new TypeError("Unknown encoding: "+se);se=(""+se).toLowerCase(),ne=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function W(q,I,T){return I===0&&T===q.length?e.fromByteArray(q):e.fromByteArray(q.slice(I,T))}function N(q,I,T){T=Math.min(q.length,T);for(var $=[],se=I;se<T;){var ue=q[se],ne=null,me=ue>239?4:ue>223?3:ue>191?2:1;if(se+me<=T){var ve,xe,oe,de;switch(me){case 1:ue<128&&(ne=ue);break;case 2:ve=q[se+1],(ve&192)===128&&(de=(ue&31)<<6|ve&63,de>127&&(ne=de));break;case 3:ve=q[se+1],xe=q[se+2],(ve&192)===128&&(xe&192)===128&&(de=(ue&15)<<12|(ve&63)<<6|xe&63,de>2047&&(de<55296||de>57343)&&(ne=de));break;case 4:ve=q[se+1],xe=q[se+2],oe=q[se+3],(ve&192)===128&&(xe&192)===128&&(oe&192)===128&&(de=(ue&15)<<18|(ve&63)<<12|(xe&63)<<6|oe&63,de>65535&&de<1114112&&(ne=de))}}ne===null?(ne=65533,me=1):ne>65535&&(ne-=65536,$.push(ne>>>10&1023|55296),ne=56320|ne&1023),$.push(ne),se+=me}return K($)}var U=4096;function K(q){var I=q.length;if(I<=U)return String.fromCharCode.apply(String,q);for(var T="",$=0;$<I;)T+=String.fromCharCode.apply(String,q.slice($,$+=U));return T}function G(q,I,T){var $="";T=Math.min(q.length,T);for(var se=I;se<T;++se)$+=String.fromCharCode(q[se]&127);return $}function X(q,I,T){var $="";T=Math.min(q.length,T);for(var se=I;se<T;++se)$+=String.fromCharCode(q[se]);return $}function H(q,I,T){var $=q.length;(!I||I<0)&&(I=0),(!T||T<0||T>$)&&(T=$);for(var se="",ue=I;ue<T;++ue)se+=ae[q[ue]];return se}function B(q,I,T){for(var $=q.slice(I,T),se="",ue=0;ue<$.length-1;ue+=2)se+=String.fromCharCode($[ue]+$[ue+1]*256);return se}o.prototype.slice=function(I,T){var $=this.length;I=~~I,T=T===void 0?$:~~T,I<0?(I+=$,I<0&&(I=0)):I>$&&(I=$),T<0?(T+=$,T<0&&(T=0)):T>$&&(T=$),T<I&&(T=I);var se=this.subarray(I,T);return Object.setPrototypeOf(se,o.prototype),se};function L(q,I,T){if(q%1!==0||q<0)throw new RangeError("offset is not uint");if(q+I>T)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUintLE=o.prototype.readUIntLE=function(I,T,$){I=I>>>0,T=T>>>0,$||L(I,T,this.length);for(var se=this[I],ue=1,ne=0;++ne<T&&(ue*=256);)se+=this[I+ne]*ue;return se},o.prototype.readUintBE=o.prototype.readUIntBE=function(I,T,$){I=I>>>0,T=T>>>0,$||L(I,T,this.length);for(var se=this[I+--T],ue=1;T>0&&(ue*=256);)se+=this[I+--T]*ue;return se},o.prototype.readUint8=o.prototype.readUInt8=function(I,T){return I=I>>>0,T||L(I,1,this.length),this[I]},o.prototype.readUint16LE=o.prototype.readUInt16LE=function(I,T){return I=I>>>0,T||L(I,2,this.length),this[I]|this[I+1]<<8},o.prototype.readUint16BE=o.prototype.readUInt16BE=function(I,T){return I=I>>>0,T||L(I,2,this.length),this[I]<<8|this[I+1]},o.prototype.readUint32LE=o.prototype.readUInt32LE=function(I,T){return I=I>>>0,T||L(I,4,this.length),(this[I]|this[I+1]<<8|this[I+2]<<16)+this[I+3]*16777216},o.prototype.readUint32BE=o.prototype.readUInt32BE=function(I,T){return I=I>>>0,T||L(I,4,this.length),this[I]*16777216+(this[I+1]<<16|this[I+2]<<8|this[I+3])},o.prototype.readIntLE=function(I,T,$){I=I>>>0,T=T>>>0,$||L(I,T,this.length);for(var se=this[I],ue=1,ne=0;++ne<T&&(ue*=256);)se+=this[I+ne]*ue;return ue*=128,se>=ue&&(se-=Math.pow(2,8*T)),se},o.prototype.readIntBE=function(I,T,$){I=I>>>0,T=T>>>0,$||L(I,T,this.length);for(var se=T,ue=1,ne=this[I+--se];se>0&&(ue*=256);)ne+=this[I+--se]*ue;return ue*=128,ne>=ue&&(ne-=Math.pow(2,8*T)),ne},o.prototype.readInt8=function(I,T){return I=I>>>0,T||L(I,1,this.length),this[I]&128?(255-this[I]+1)*-1:this[I]},o.prototype.readInt16LE=function(I,T){I=I>>>0,T||L(I,2,this.length);var $=this[I]|this[I+1]<<8;return $&32768?$|4294901760:$},o.prototype.readInt16BE=function(I,T){I=I>>>0,T||L(I,2,this.length);var $=this[I+1]|this[I]<<8;return $&32768?$|4294901760:$},o.prototype.readInt32LE=function(I,T){return I=I>>>0,T||L(I,4,this.length),this[I]|this[I+1]<<8|this[I+2]<<16|this[I+3]<<24},o.prototype.readInt32BE=function(I,T){return I=I>>>0,T||L(I,4,this.length),this[I]<<24|this[I+1]<<16|this[I+2]<<8|this[I+3]},o.prototype.readFloatLE=function(I,T){return I=I>>>0,T||L(I,4,this.length),r.read(this,I,!0,23,4)},o.prototype.readFloatBE=function(I,T){return I=I>>>0,T||L(I,4,this.length),r.read(this,I,!1,23,4)},o.prototype.readDoubleLE=function(I,T){return I=I>>>0,T||L(I,8,this.length),r.read(this,I,!0,52,8)},o.prototype.readDoubleBE=function(I,T){return I=I>>>0,T||L(I,8,this.length),r.read(this,I,!1,52,8)};function F(q,I,T,$,se,ue){if(!o.isBuffer(q))throw new TypeError('"buffer" argument must be a Buffer instance');if(I>se||I<ue)throw new RangeError('"value" argument is out of bounds');if(T+$>q.length)throw new RangeError("Index out of range")}o.prototype.writeUintLE=o.prototype.writeUIntLE=function(I,T,$,se){if(I=+I,T=T>>>0,$=$>>>0,!se){var ue=Math.pow(2,8*$)-1;F(this,I,T,$,ue,0)}var ne=1,me=0;for(this[T]=I&255;++me<$&&(ne*=256);)this[T+me]=I/ne&255;return T+$},o.prototype.writeUintBE=o.prototype.writeUIntBE=function(I,T,$,se){if(I=+I,T=T>>>0,$=$>>>0,!se){var ue=Math.pow(2,8*$)-1;F(this,I,T,$,ue,0)}var ne=$-1,me=1;for(this[T+ne]=I&255;--ne>=0&&(me*=256);)this[T+ne]=I/me&255;return T+$},o.prototype.writeUint8=o.prototype.writeUInt8=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,1,255,0),this[T]=I&255,T+1},o.prototype.writeUint16LE=o.prototype.writeUInt16LE=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,2,65535,0),this[T]=I&255,this[T+1]=I>>>8,T+2},o.prototype.writeUint16BE=o.prototype.writeUInt16BE=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,2,65535,0),this[T]=I>>>8,this[T+1]=I&255,T+2},o.prototype.writeUint32LE=o.prototype.writeUInt32LE=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,4,4294967295,0),this[T+3]=I>>>24,this[T+2]=I>>>16,this[T+1]=I>>>8,this[T]=I&255,T+4},o.prototype.writeUint32BE=o.prototype.writeUInt32BE=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,4,4294967295,0),this[T]=I>>>24,this[T+1]=I>>>16,this[T+2]=I>>>8,this[T+3]=I&255,T+4},o.prototype.writeIntLE=function(I,T,$,se){if(I=+I,T=T>>>0,!se){var ue=Math.pow(2,8*$-1);F(this,I,T,$,ue-1,-ue)}var ne=0,me=1,ve=0;for(this[T]=I&255;++ne<$&&(me*=256);)I<0&&ve===0&&this[T+ne-1]!==0&&(ve=1),this[T+ne]=(I/me>>0)-ve&255;return T+$},o.prototype.writeIntBE=function(I,T,$,se){if(I=+I,T=T>>>0,!se){var ue=Math.pow(2,8*$-1);F(this,I,T,$,ue-1,-ue)}var ne=$-1,me=1,ve=0;for(this[T+ne]=I&255;--ne>=0&&(me*=256);)I<0&&ve===0&&this[T+ne+1]!==0&&(ve=1),this[T+ne]=(I/me>>0)-ve&255;return T+$},o.prototype.writeInt8=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,1,127,-128),I<0&&(I=255+I+1),this[T]=I&255,T+1},o.prototype.writeInt16LE=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,2,32767,-32768),this[T]=I&255,this[T+1]=I>>>8,T+2},o.prototype.writeInt16BE=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,2,32767,-32768),this[T]=I>>>8,this[T+1]=I&255,T+2},o.prototype.writeInt32LE=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,4,2147483647,-2147483648),this[T]=I&255,this[T+1]=I>>>8,this[T+2]=I>>>16,this[T+3]=I>>>24,T+4},o.prototype.writeInt32BE=function(I,T,$){return I=+I,T=T>>>0,$||F(this,I,T,4,2147483647,-2147483648),I<0&&(I=4294967295+I+1),this[T]=I>>>24,this[T+1]=I>>>16,this[T+2]=I>>>8,this[T+3]=I&255,T+4};function V(q,I,T,$,se,ue){if(T+$>q.length)throw new RangeError("Index out of range");if(T<0)throw new RangeError("Index out of range")}function Y(q,I,T,$,se){return I=+I,T=T>>>0,se||V(q,I,T,4),r.write(q,I,T,$,23,4),T+4}o.prototype.writeFloatLE=function(I,T,$){return Y(this,I,T,!0,$)},o.prototype.writeFloatBE=function(I,T,$){return Y(this,I,T,!1,$)};function ie(q,I,T,$,se){return I=+I,T=T>>>0,se||V(q,I,T,8),r.write(q,I,T,$,52,8),T+8}o.prototype.writeDoubleLE=function(I,T,$){return ie(this,I,T,!0,$)},o.prototype.writeDoubleBE=function(I,T,$){return ie(this,I,T,!1,$)},o.prototype.copy=function(I,T,$,se){if(!o.isBuffer(I))throw new TypeError("argument should be a Buffer");if($||($=0),!se&&se!==0&&(se=this.length),T>=I.length&&(T=I.length),T||(T=0),se>0&&se<$&&(se=$),se===$||I.length===0||this.length===0)return 0;if(T<0)throw new RangeError("targetStart out of bounds");if($<0||$>=this.length)throw new RangeError("Index out of range");if(se<0)throw new RangeError("sourceEnd out of bounds");se>this.length&&(se=this.length),I.length-T<se-$&&(se=I.length-T+$);var ue=se-$;return this===I&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(T,$,se):Uint8Array.prototype.set.call(I,this.subarray($,se),T),ue},o.prototype.fill=function(I,T,$,se){if(typeof I=="string"){if(typeof T=="string"?(se=T,T=0,$=this.length):typeof $=="string"&&(se=$,$=this.length),se!==void 0&&typeof se!="string")throw new TypeError("encoding must be a string");if(typeof se=="string"&&!o.isEncoding(se))throw new TypeError("Unknown encoding: "+se);if(I.length===1){var ue=I.charCodeAt(0);(se==="utf8"&&ue<128||se==="latin1")&&(I=ue)}}else typeof I=="number"?I=I&255:typeof I=="boolean"&&(I=Number(I));if(T<0||this.length<T||this.length<$)throw new RangeError("Out of range index");if($<=T)return this;T=T>>>0,$=$===void 0?this.length:$>>>0,I||(I=0);var ne;if(typeof I=="number")for(ne=T;ne<$;++ne)this[ne]=I;else{var me=o.isBuffer(I)?I:o.from(I,se),ve=me.length;if(ve===0)throw new TypeError('The value "'+I+'" is invalid for argument "value"');for(ne=0;ne<$-T;++ne)this[ne+T]=me[ne%ve]}return this};var Q=/[^+/0-9A-Za-z-_]/g;function D(q){if(q=q.split("=")[0],q=q.trim().replace(Q,""),q.length<2)return"";for(;q.length%4!==0;)q=q+"=";return q}function R(q,I){I=I||1/0;for(var T,$=q.length,se=null,ue=[],ne=0;ne<$;++ne){if(T=q.charCodeAt(ne),T>55295&&T<57344){if(!se){if(T>56319){(I-=3)>-1&&ue.push(239,191,189);continue}else if(ne+1===$){(I-=3)>-1&&ue.push(239,191,189);continue}se=T;continue}if(T<56320){(I-=3)>-1&&ue.push(239,191,189),se=T;continue}T=(se-55296<<10|T-56320)+65536}else se&&(I-=3)>-1&&ue.push(239,191,189);if(se=null,T<128){if((I-=1)<0)break;ue.push(T)}else if(T<2048){if((I-=2)<0)break;ue.push(T>>6|192,T&63|128)}else if(T<65536){if((I-=3)<0)break;ue.push(T>>12|224,T>>6&63|128,T&63|128)}else if(T<1114112){if((I-=4)<0)break;ue.push(T>>18|240,T>>12&63|128,T>>6&63|128,T&63|128)}else throw new Error("Invalid code point")}return ue}function J(q){for(var I=[],T=0;T<q.length;++T)I.push(q.charCodeAt(T)&255);return I}function Z(q,I){for(var T,$,se,ue=[],ne=0;ne<q.length&&!((I-=2)<0);++ne)T=q.charCodeAt(ne),$=T>>8,se=T%256,ue.push(se),ue.push($);return ue}function ee(q){return e.toByteArray(D(q))}function re(q,I,T,$){for(var se=0;se<$&&!(se+T>=I.length||se>=q.length);++se)I[se+T]=q[se];return se}function he(q,I){return q instanceof I||q!=null&&q.constructor!=null&&q.constructor.name!=null&&q.constructor.name===I.name}function O(q){return q!==q}var ae=function(){for(var q="0123456789abcdef",I=new Array(256),T=0;T<16;++T)for(var $=T*16,se=0;se<16;++se)I[$+se]=q[T]+q[se];return I}()}(Z4)),Z4}var e5={},t5={},r5,bre;function jSe(){return bre||(bre=1,r5=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var s=42;e[r]=s;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var o=Object.getOwnPropertyDescriptor(e,r);if(o.value!==s||o.enumerable!==!0)return!1}return!0}),r5}var n5,wre;function u7(){if(wre)return n5;wre=1;var t=jSe();return n5=function(){return t()&&!!Symbol.toStringTag},n5}var s5,Sre;function kSe(){return Sre||(Sre=1,s5=Object),s5}var i5,_re;function Ekt(){return _re||(_re=1,i5=Error),i5}var a5,jre;function Akt(){return jre||(jre=1,a5=EvalError),a5}var o5,kre;function Ckt(){return kre||(kre=1,o5=RangeError),o5}var l5,Nre;function Tkt(){return Nre||(Nre=1,l5=ReferenceError),l5}var c5,Ere;function NSe(){return Ere||(Ere=1,c5=SyntaxError),c5}var u5,Are;function UE(){return Are||(Are=1,u5=TypeError),u5}var d5,Cre;function Pkt(){return Cre||(Cre=1,d5=URIError),d5}var h5,Tre;function Okt(){return Tre||(Tre=1,h5=Math.abs),h5}var f5,Pre;function Ikt(){return Pre||(Pre=1,f5=Math.floor),f5}var p5,Ore;function Rkt(){return Ore||(Ore=1,p5=Math.max),p5}var m5,Ire;function Mkt(){return Ire||(Ire=1,m5=Math.min),m5}var g5,Rre;function Dkt(){return Rre||(Rre=1,g5=Math.pow),g5}var y5,Mre;function Lkt(){return Mre||(Mre=1,y5=Math.round),y5}var x5,Dre;function Fkt(){return Dre||(Dre=1,x5=Number.isNaN||function(e){return e!==e}),x5}var v5,Lre;function $kt(){if(Lre)return v5;Lre=1;var t=Fkt();return v5=function(r){return t(r)||r===0?r:r<0?-1:1},v5}var b5,Fre;function Bkt(){return Fre||(Fre=1,b5=Object.getOwnPropertyDescriptor),b5}var w5,$re;function HE(){if($re)return w5;$re=1;var t=Bkt();if(t)try{t([],"length")}catch{t=null}return w5=t,w5}var S5,Bre;function iD(){if(Bre)return S5;Bre=1;var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return S5=t,S5}var _5,zre;function zkt(){if(zre)return _5;zre=1;var t=typeof Symbol<"u"&&Symbol,e=jSe();return _5=function(){return typeof t!="function"||typeof Symbol!="function"||typeof t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},_5}var j5,Ure;function ESe(){return Ure||(Ure=1,j5=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),j5}var k5,Hre;function ASe(){if(Hre)return k5;Hre=1;var t=kSe();return k5=t.getPrototypeOf||null,k5}var N5,Vre;function Ukt(){if(Vre)return N5;Vre=1;var t="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,r=Math.max,n="[object Function]",s=function(c,u){for(var d=[],h=0;h<c.length;h+=1)d[h]=c[h];for(var f=0;f<u.length;f+=1)d[f+c.length]=u[f];return d},i=function(c,u){for(var d=[],h=u,f=0;h<c.length;h+=1,f+=1)d[f]=c[h];return d},a=function(o,c){for(var u="",d=0;d<o.length;d+=1)u+=o[d],d+1<o.length&&(u+=c);return u};return N5=function(c){var u=this;if(typeof u!="function"||e.apply(u)!==n)throw new TypeError(t+u);for(var d=i(arguments,1),h,f=function(){if(this instanceof h){var y=u.apply(this,s(d,arguments));return Object(y)===y?y:this}return u.apply(c,s(d,arguments))},p=r(0,u.length-d.length),m=[],g=0;g<p;g++)m[g]="$"+g;if(h=Function("binder","return function ("+a(m,",")+"){ return binder.apply(this,arguments); }")(f),u.prototype){var x=function(){};x.prototype=u.prototype,h.prototype=new x,x.prototype=null}return h},N5}var E5,Wre;function VE(){if(Wre)return E5;Wre=1;var t=Ukt();return E5=Function.prototype.bind||t,E5}var A5,qre;function d7(){return qre||(qre=1,A5=Function.prototype.call),A5}var C5,Gre;function CSe(){return Gre||(Gre=1,C5=Function.prototype.apply),C5}var T5,Kre;function Hkt(){return Kre||(Kre=1,T5=typeof Reflect<"u"&&Reflect&&Reflect.apply),T5}var P5,Yre;function Vkt(){if(Yre)return P5;Yre=1;var t=VE(),e=CSe(),r=d7(),n=Hkt();return P5=n||t.call(r,e),P5}var O5,Xre;function Wkt(){if(Xre)return O5;Xre=1;var t=VE(),e=UE(),r=d7(),n=Vkt();return O5=function(i){if(i.length<1||typeof i[0]!="function")throw new e("a function is required");return n(t,r,i)},O5}var I5,Jre;function qkt(){if(Jre)return I5;Jre=1;var t=Wkt(),e=HE(),r;try{r=[].__proto__===Array.prototype}catch(a){if(!a||typeof a!="object"||!("code"in a)||a.code!=="ERR_PROTO_ACCESS")throw a}var n=!!r&&e&&e(Object.prototype,"__proto__"),s=Object,i=s.getPrototypeOf;return I5=n&&typeof n.get=="function"?t([n.get]):typeof i=="function"?function(o){return i(o==null?o:s(o))}:!1,I5}var R5,Qre;function Gkt(){if(Qre)return R5;Qre=1;var t=ESe(),e=ASe(),r=qkt();return R5=t?function(s){return t(s)}:e?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return e(s)}:r?function(s){return r(s)}:null,R5}var M5,Zre;function Kkt(){if(Zre)return M5;Zre=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,r=VE();return M5=r.call(t,e),M5}var D5,ene;function h7(){if(ene)return D5;ene=1;var t,e=kSe(),r=Ekt(),n=Akt(),s=Ckt(),i=Tkt(),a=NSe(),o=UE(),c=Pkt(),u=Okt(),d=Ikt(),h=Rkt(),f=Mkt(),p=Dkt(),m=Lkt(),g=$kt(),x=Function,y=function(J){try{return x('"use strict"; return ('+J+").constructor;")()}catch{}},v=HE(),b=iD(),w=function(){throw new o},S=v?function(){try{return arguments.callee,w}catch{try{return v(arguments,"callee").get}catch{return w}}}():w,k=zkt()(),E=Gkt(),C=ASe(),A=ESe(),M=CSe(),z=d7(),P={},W=typeof Uint8Array>"u"||!E?t:E(Uint8Array),N={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?t:ArrayBuffer,"%ArrayIteratorPrototype%":k&&E?E([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":P,"%AsyncGenerator%":P,"%AsyncGeneratorFunction%":P,"%AsyncIteratorPrototype%":P,"%Atomics%":typeof Atomics>"u"?t:Atomics,"%BigInt%":typeof BigInt>"u"?t:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?t:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":typeof Float16Array>"u"?t:Float16Array,"%Float32Array%":typeof Float32Array>"u"?t:Float32Array,"%Float64Array%":typeof Float64Array>"u"?t:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?t:FinalizationRegistry,"%Function%":x,"%GeneratorFunction%":P,"%Int8Array%":typeof Int8Array>"u"?t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":k&&E?E(E([][Symbol.iterator]())):t,"%JSON%":typeof JSON=="object"?JSON:t,"%Map%":typeof Map>"u"?t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!k||!E?t:E(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":v,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?t:Promise,"%Proxy%":typeof Proxy>"u"?t:Proxy,"%RangeError%":s,"%ReferenceError%":i,"%Reflect%":typeof Reflect>"u"?t:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?t:Set,"%SetIteratorPrototype%":typeof Set>"u"||!k||!E?t:E(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":k&&E?E(""[Symbol.iterator]()):t,"%Symbol%":k?Symbol:t,"%SyntaxError%":a,"%ThrowTypeError%":S,"%TypedArray%":W,"%TypeError%":o,"%Uint8Array%":typeof Uint8Array>"u"?t:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?t:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?t:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?t:Uint32Array,"%URIError%":c,"%WeakMap%":typeof WeakMap>"u"?t:WeakMap,"%WeakRef%":typeof WeakRef>"u"?t:WeakRef,"%WeakSet%":typeof WeakSet>"u"?t:WeakSet,"%Function.prototype.call%":z,"%Function.prototype.apply%":M,"%Object.defineProperty%":b,"%Object.getPrototypeOf%":C,"%Math.abs%":u,"%Math.floor%":d,"%Math.max%":h,"%Math.min%":f,"%Math.pow%":p,"%Math.round%":m,"%Math.sign%":g,"%Reflect.getPrototypeOf%":A};if(E)try{null.error}catch(J){var U=E(E(J));N["%Error.prototype%"]=U}var K=function J(Z){var ee;if(Z==="%AsyncFunction%")ee=y("async function () {}");else if(Z==="%GeneratorFunction%")ee=y("function* () {}");else if(Z==="%AsyncGeneratorFunction%")ee=y("async function* () {}");else if(Z==="%AsyncGenerator%"){var re=J("%AsyncGeneratorFunction%");re&&(ee=re.prototype)}else if(Z==="%AsyncIteratorPrototype%"){var he=J("%AsyncGenerator%");he&&E&&(ee=E(he.prototype))}return N[Z]=ee,ee},G={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},X=VE(),H=Kkt(),B=X.call(z,Array.prototype.concat),L=X.call(M,Array.prototype.splice),F=X.call(z,String.prototype.replace),V=X.call(z,String.prototype.slice),Y=X.call(z,RegExp.prototype.exec),ie=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Q=/\\(\\)?/g,D=function(Z){var ee=V(Z,0,1),re=V(Z,-1);if(ee==="%"&&re!=="%")throw new a("invalid intrinsic syntax, expected closing `%`");if(re==="%"&&ee!=="%")throw new a("invalid intrinsic syntax, expected opening `%`");var he=[];return F(Z,ie,function(O,ae,q,I){he[he.length]=q?F(I,Q,"$1"):ae||O}),he},R=function(Z,ee){var re=Z,he;if(H(G,re)&&(he=G[re],re="%"+he[0]+"%"),H(N,re)){var O=N[re];if(O===P&&(O=K(re)),typeof O>"u"&&!ee)throw new o("intrinsic "+Z+" exists, but is not available. Please file an issue!");return{alias:he,name:re,value:O}}throw new a("intrinsic "+Z+" does not exist!")};return D5=function(Z,ee){if(typeof Z!="string"||Z.length===0)throw new o("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof ee!="boolean")throw new o('"allowMissing" argument must be a boolean');if(Y(/^%?[^%]*%?$/,Z)===null)throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var re=D(Z),he=re.length>0?re[0]:"",O=R("%"+he+"%",ee),ae=O.name,q=O.value,I=!1,T=O.alias;T&&(he=T[0],L(re,B([0,1],T)));for(var $=1,se=!0;$<re.length;$+=1){var ue=re[$],ne=V(ue,0,1),me=V(ue,-1);if((ne==='"'||ne==="'"||ne==="`"||me==='"'||me==="'"||me==="`")&&ne!==me)throw new a("property names with quotes must have matching quotes");if((ue==="constructor"||!se)&&(I=!0),he+="."+ue,ae="%"+he+"%",H(N,ae))q=N[ae];else if(q!=null){if(!(ue in q)){if(!ee)throw new o("base intrinsic for "+Z+" exists, but the property is not available.");return}if(v&&$+1>=re.length){var ve=v(q,ue);se=!!ve,se&&"get"in ve&&!("originalValue"in ve.get)?q=ve.get:q=q[ue]}else se=H(q,ue),q=q[ue];se&&!I&&(N[ae]=q)}}return q},D5}var L5={exports:{}},F5,tne;function Ykt(){if(tne)return F5;tne=1;var t=iD(),e=NSe(),r=UE(),n=HE();return F5=function(i,a,o){if(!i||typeof i!="object"&&typeof i!="function")throw new r("`obj` must be an object or a function`");if(typeof a!="string"&&typeof a!="symbol")throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new r("`loose`, if provided, must be a boolean");var c=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,d=arguments.length>5?arguments[5]:null,h=arguments.length>6?arguments[6]:!1,f=!!n&&n(i,a);if(t)t(i,a,{configurable:d===null&&f?f.configurable:!d,enumerable:c===null&&f?f.enumerable:!c,value:o,writable:u===null&&f?f.writable:!u});else if(h||!c&&!u&&!d)i[a]=o;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},F5}var $5,rne;function Xkt(){if(rne)return $5;rne=1;var t=iD(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return t([],"length",{value:1}).length!==1}catch{return!0}},$5=e,$5}var B5,nne;function Jkt(){if(nne)return B5;nne=1;var t=h7(),e=Ykt(),r=Xkt()(),n=HE(),s=UE(),i=t("%Math.floor%");return B5=function(o,c){if(typeof o!="function")throw new s("`fn` is not a function");if(typeof c!="number"||c<0||c>4294967295||i(c)!==c)throw new s("`length` must be a positive 32-bit integer");var u=arguments.length>2&&!!arguments[2],d=!0,h=!0;if("length"in o&&n){var f=n(o,"length");f&&!f.configurable&&(d=!1),f&&!f.writable&&(h=!1)}return(d||h||!u)&&(r?e(o,"length",c,!0,!0):e(o,"length",c)),o},B5}var sne;function TSe(){return sne||(sne=1,function(t){var e=VE(),r=h7(),n=Jkt(),s=UE(),i=r("%Function.prototype.apply%"),a=r("%Function.prototype.call%"),o=r("%Reflect.apply%",!0)||e.call(a,i),c=iD(),u=r("%Math.max%");t.exports=function(f){if(typeof f!="function")throw new s("a function is required");var p=o(e,a,arguments);return n(p,1+u(0,f.length-(arguments.length-1)),!0)};var d=function(){return o(e,i,arguments)};c?c(t.exports,"apply",{value:d}):t.exports.apply=d}(L5)),L5.exports}var z5,ine;function PSe(){if(ine)return z5;ine=1;var t=h7(),e=TSe(),r=e(t("String.prototype.indexOf"));return z5=function(s,i){var a=t(s,!!i);return typeof a=="function"&&r(s,".prototype.")>-1?e(a):a},z5}var U5,ane;function Qkt(){if(ane)return U5;ane=1;var t=u7()(),e=PSe(),r=e("Object.prototype.toString"),n=function(o){return t&&o&&typeof o=="object"&&Symbol.toStringTag in o?!1:r(o)==="[object Arguments]"},s=function(o){return n(o)?!0:o!==null&&typeof o=="object"&&typeof o.length=="number"&&o.length>=0&&r(o)!=="[object Array]"&&r(o.callee)==="[object Function]"},i=function(){return n(arguments)}();return n.isLegacyArguments=s,U5=i?n:s,U5}var H5,one;function Zkt(){if(one)return H5;one=1;var t=Object.prototype.toString,e=Function.prototype.toString,r=/^\s*(?:function)?\*/,n=u7()(),s=Object.getPrototypeOf,i=function(){if(!n)return!1;try{return Function("return function*() {}")()}catch{}},a;return H5=function(c){if(typeof c!="function")return!1;if(r.test(e.call(c)))return!0;if(!n){var u=t.call(c);return u==="[object GeneratorFunction]"}if(!s)return!1;if(typeof a>"u"){var d=i();a=d?s(d):!1}return s(c)===a},H5}var V5,lne;function eNt(){if(lne)return V5;lne=1;var t=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,r,n;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{r=Object.defineProperty({},"length",{get:function(){throw n}}),n={},e(function(){throw 42},null,r)}catch(v){v!==n&&(e=null)}else e=null;var s=/^\s*class\b/,i=function(b){try{var w=t.call(b);return s.test(w)}catch{return!1}},a=function(b){try{return i(b)?!1:(t.call(b),!0)}catch{return!1}},o=Object.prototype.toString,c="[object Object]",u="[object Function]",d="[object GeneratorFunction]",h="[object HTMLAllCollection]",f="[object HTML document.all class]",p="[object HTMLCollection]",m=typeof Symbol=="function"&&!!Symbol.toStringTag,g=!(0 in[,]),x=function(){return!1};if(typeof document=="object"){var y=document.all;o.call(y)===o.call(document.all)&&(x=function(b){if((g||!b)&&(typeof b>"u"||typeof b=="object"))try{var w=o.call(b);return(w===h||w===f||w===p||w===c)&&b("")==null}catch{}return!1})}return V5=e?function(b){if(x(b))return!0;if(!b||typeof b!="function"&&typeof b!="object")return!1;try{e(b,null,r)}catch(w){if(w!==n)return!1}return!i(b)&&a(b)}:function(b){if(x(b))return!0;if(!b||typeof b!="function"&&typeof b!="object")return!1;if(m)return a(b);if(i(b))return!1;var w=o.call(b);return w!==u&&w!==d&&!/^\[object HTML/.test(w)?!1:a(b)},V5}var W5,cne;function tNt(){if(cne)return W5;cne=1;var t=eNt(),e=Object.prototype.toString,r=Object.prototype.hasOwnProperty,n=function(c,u,d){for(var h=0,f=c.length;h<f;h++)r.call(c,h)&&(d==null?u(c[h],h,c):u.call(d,c[h],h,c))},s=function(c,u,d){for(var h=0,f=c.length;h<f;h++)d==null?u(c.charAt(h),h,c):u.call(d,c.charAt(h),h,c)},i=function(c,u,d){for(var h in c)r.call(c,h)&&(d==null?u(c[h],h,c):u.call(d,c[h],h,c))},a=function(c,u,d){if(!t(u))throw new TypeError("iterator must be a function");var h;arguments.length>=3&&(h=d),e.call(c)==="[object Array]"?n(c,u,h):typeof c=="string"?s(c,u,h):i(c,u,h)};return W5=a,W5}var q5,une;function rNt(){return une||(une=1,q5=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),q5}var G5,dne;function nNt(){if(dne)return G5;dne=1;var t=rNt(),e=typeof globalThis>"u"?gu:globalThis;return G5=function(){for(var n=[],s=0;s<t.length;s++)typeof e[t[s]]=="function"&&(n[n.length]=t[s]);return n},G5}var K5,hne;function OSe(){if(hne)return K5;hne=1;var t=tNt(),e=nNt(),r=TSe(),n=PSe(),s=HE(),i=n("Object.prototype.toString"),a=u7()(),o=typeof globalThis>"u"?gu:globalThis,c=e(),u=n("String.prototype.slice"),d=Object.getPrototypeOf,h=n("Array.prototype.indexOf",!0)||function(x,y){for(var v=0;v<x.length;v+=1)if(x[v]===y)return v;return-1},f={__proto__:null};a&&s&&d?t(c,function(g){var x=new o[g];if(Symbol.toStringTag in x){var y=d(x),v=s(y,Symbol.toStringTag);if(!v){var b=d(y);v=s(b,Symbol.toStringTag)}f["$"+g]=r(v.get)}}):t(c,function(g){var x=new o[g],y=x.slice||x.set;y&&(f["$"+g]=r(y))});var p=function(x){var y=!1;return t(f,function(v,b){if(!y)try{"$"+v(x)===b&&(y=u(b,1))}catch{}}),y},m=function(x){var y=!1;return t(f,function(v,b){if(!y)try{v(x),y=u(b,1)}catch{}}),y};return K5=function(x){if(!x||typeof x!="object")return!1;if(!a){var y=u(i(x),8,-1);return h(c,y)>-1?y:y!=="Object"?!1:m(x)}return s?p(x):null},K5}var Y5,fne;function sNt(){if(fne)return Y5;fne=1;var t=OSe();return Y5=function(r){return!!t(r)},Y5}var pne;function iNt(){return pne||(pne=1,function(t){var e=Qkt(),r=Zkt(),n=OSe(),s=sNt();function i($){return $.call.bind($)}var a=typeof BigInt<"u",o=typeof Symbol<"u",c=i(Object.prototype.toString),u=i(Number.prototype.valueOf),d=i(String.prototype.valueOf),h=i(Boolean.prototype.valueOf);if(a)var f=i(BigInt.prototype.valueOf);if(o)var p=i(Symbol.prototype.valueOf);function m($,se){if(typeof $!="object")return!1;try{return se($),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=s;function g($){return typeof Promise<"u"&&$ instanceof Promise||$!==null&&typeof $=="object"&&typeof $.then=="function"&&typeof $.catch=="function"}t.isPromise=g;function x($){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView($):s($)||V($)}t.isArrayBufferView=x;function y($){return n($)==="Uint8Array"}t.isUint8Array=y;function v($){return n($)==="Uint8ClampedArray"}t.isUint8ClampedArray=v;function b($){return n($)==="Uint16Array"}t.isUint16Array=b;function w($){return n($)==="Uint32Array"}t.isUint32Array=w;function S($){return n($)==="Int8Array"}t.isInt8Array=S;function k($){return n($)==="Int16Array"}t.isInt16Array=k;function E($){return n($)==="Int32Array"}t.isInt32Array=E;function C($){return n($)==="Float32Array"}t.isFloat32Array=C;function A($){return n($)==="Float64Array"}t.isFloat64Array=A;function M($){return n($)==="BigInt64Array"}t.isBigInt64Array=M;function z($){return n($)==="BigUint64Array"}t.isBigUint64Array=z;function P($){return c($)==="[object Map]"}P.working=typeof Map<"u"&&P(new Map);function W($){return typeof Map>"u"?!1:P.working?P($):$ instanceof Map}t.isMap=W;function N($){return c($)==="[object Set]"}N.working=typeof Set<"u"&&N(new Set);function U($){return typeof Set>"u"?!1:N.working?N($):$ instanceof Set}t.isSet=U;function K($){return c($)==="[object WeakMap]"}K.working=typeof WeakMap<"u"&&K(new WeakMap);function G($){return typeof WeakMap>"u"?!1:K.working?K($):$ instanceof WeakMap}t.isWeakMap=G;function X($){return c($)==="[object WeakSet]"}X.working=typeof WeakSet<"u"&&X(new WeakSet);function H($){return X($)}t.isWeakSet=H;function B($){return c($)==="[object ArrayBuffer]"}B.working=typeof ArrayBuffer<"u"&&B(new ArrayBuffer);function L($){return typeof ArrayBuffer>"u"?!1:B.working?B($):$ instanceof ArrayBuffer}t.isArrayBuffer=L;function F($){return c($)==="[object DataView]"}F.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&F(new DataView(new ArrayBuffer(1),0,1));function V($){return typeof DataView>"u"?!1:F.working?F($):$ instanceof DataView}t.isDataView=V;var Y=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function ie($){return c($)==="[object SharedArrayBuffer]"}function Q($){return typeof Y>"u"?!1:(typeof ie.working>"u"&&(ie.working=ie(new Y)),ie.working?ie($):$ instanceof Y)}t.isSharedArrayBuffer=Q;function D($){return c($)==="[object AsyncFunction]"}t.isAsyncFunction=D;function R($){return c($)==="[object Map Iterator]"}t.isMapIterator=R;function J($){return c($)==="[object Set Iterator]"}t.isSetIterator=J;function Z($){return c($)==="[object Generator]"}t.isGeneratorObject=Z;function ee($){return c($)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=ee;function re($){return m($,u)}t.isNumberObject=re;function he($){return m($,d)}t.isStringObject=he;function O($){return m($,h)}t.isBooleanObject=O;function ae($){return a&&m($,f)}t.isBigIntObject=ae;function q($){return o&&m($,p)}t.isSymbolObject=q;function I($){return re($)||he($)||O($)||ae($)||q($)}t.isBoxedPrimitive=I;function T($){return typeof Uint8Array<"u"&&(L($)||Q($))}t.isAnyArrayBuffer=T,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function($){Object.defineProperty(t,$,{enumerable:!1,value:function(){throw new Error($+" is not supported in userland")}})})}(t5)),t5}var X5,mne;function aNt(){return mne||(mne=1,X5=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),X5}var gne;function ISe(){return gne||(gne=1,function(t){var e=Object.getOwnPropertyDescriptors||function(V){for(var Y=Object.keys(V),ie={},Q=0;Q<Y.length;Q++)ie[Y[Q]]=Object.getOwnPropertyDescriptor(V,Y[Q]);return ie},r=/%[sdj%]/g;t.format=function(F){if(!S(F)){for(var V=[],Y=0;Y<arguments.length;Y++)V.push(a(arguments[Y]));return V.join(" ")}for(var Y=1,ie=arguments,Q=ie.length,D=String(F).replace(r,function(J){if(J==="%%")return"%";if(Y>=Q)return J;switch(J){case"%s":return String(ie[Y++]);case"%d":return Number(ie[Y++]);case"%j":try{return JSON.stringify(ie[Y++])}catch{return"[Circular]"}default:return J}}),R=ie[Y];Y<Q;R=ie[++Y])v(R)||!A(R)?D+=" "+R:D+=" "+a(R);return D},t.deprecate=function(F,V){if(typeof Jt<"u"&&Jt.noDeprecation===!0)return F;if(typeof Jt>"u")return function(){return t.deprecate(F,V).apply(this,arguments)};var Y=!1;function ie(){if(!Y){if(Jt.throwDeprecation)throw new Error(V);Jt.traceDeprecation?console.trace(V):console.error(V),Y=!0}return F.apply(this,arguments)}return ie};var n={},s=/^$/;if(Jt.env.NODE_DEBUG){var i=Jt.env.NODE_DEBUG;i=i.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+i+"$","i")}t.debuglog=function(F){if(F=F.toUpperCase(),!n[F])if(s.test(F)){var V=Jt.pid;n[F]=function(){var Y=t.format.apply(t,arguments);console.error("%s %d: %s",F,V,Y)}}else n[F]=function(){};return n[F]};function a(F,V){var Y={seen:[],stylize:c};return arguments.length>=3&&(Y.depth=arguments[2]),arguments.length>=4&&(Y.colors=arguments[3]),y(V)?Y.showHidden=V:V&&t._extend(Y,V),E(Y.showHidden)&&(Y.showHidden=!1),E(Y.depth)&&(Y.depth=2),E(Y.colors)&&(Y.colors=!1),E(Y.customInspect)&&(Y.customInspect=!0),Y.colors&&(Y.stylize=o),d(Y,F,Y.depth)}t.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function o(F,V){var Y=a.styles[V];return Y?"\x1B["+a.colors[Y][0]+"m"+F+"\x1B["+a.colors[Y][1]+"m":F}function c(F,V){return F}function u(F){var V={};return F.forEach(function(Y,ie){V[Y]=!0}),V}function d(F,V,Y){if(F.customInspect&&V&&P(V.inspect)&&V.inspect!==t.inspect&&!(V.constructor&&V.constructor.prototype===V)){var ie=V.inspect(Y,F);return S(ie)||(ie=d(F,ie,Y)),ie}var Q=h(F,V);if(Q)return Q;var D=Object.keys(V),R=u(D);if(F.showHidden&&(D=Object.getOwnPropertyNames(V)),z(V)&&(D.indexOf("message")>=0||D.indexOf("description")>=0))return f(V);if(D.length===0){if(P(V)){var J=V.name?": "+V.name:"";return F.stylize("[Function"+J+"]","special")}if(C(V))return F.stylize(RegExp.prototype.toString.call(V),"regexp");if(M(V))return F.stylize(Date.prototype.toString.call(V),"date");if(z(V))return f(V)}var Z="",ee=!1,re=["{","}"];if(x(V)&&(ee=!0,re=["[","]"]),P(V)){var he=V.name?": "+V.name:"";Z=" [Function"+he+"]"}if(C(V)&&(Z=" "+RegExp.prototype.toString.call(V)),M(V)&&(Z=" "+Date.prototype.toUTCString.call(V)),z(V)&&(Z=" "+f(V)),D.length===0&&(!ee||V.length==0))return re[0]+Z+re[1];if(Y<0)return C(V)?F.stylize(RegExp.prototype.toString.call(V),"regexp"):F.stylize("[Object]","special");F.seen.push(V);var O;return ee?O=p(F,V,Y,R,D):O=D.map(function(ae){return m(F,V,Y,R,ae,ee)}),F.seen.pop(),g(O,Z,re)}function h(F,V){if(E(V))return F.stylize("undefined","undefined");if(S(V)){var Y="'"+JSON.stringify(V).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return F.stylize(Y,"string")}if(w(V))return F.stylize(""+V,"number");if(y(V))return F.stylize(""+V,"boolean");if(v(V))return F.stylize("null","null")}function f(F){return"["+Error.prototype.toString.call(F)+"]"}function p(F,V,Y,ie,Q){for(var D=[],R=0,J=V.length;R<J;++R)X(V,String(R))?D.push(m(F,V,Y,ie,String(R),!0)):D.push("");return Q.forEach(function(Z){Z.match(/^\d+$/)||D.push(m(F,V,Y,ie,Z,!0))}),D}function m(F,V,Y,ie,Q,D){var R,J,Z;if(Z=Object.getOwnPropertyDescriptor(V,Q)||{value:V[Q]},Z.get?Z.set?J=F.stylize("[Getter/Setter]","special"):J=F.stylize("[Getter]","special"):Z.set&&(J=F.stylize("[Setter]","special")),X(ie,Q)||(R="["+Q+"]"),J||(F.seen.indexOf(Z.value)<0?(v(Y)?J=d(F,Z.value,null):J=d(F,Z.value,Y-1),J.indexOf(`
`)>-1&&(D?J=J.split(`
`).map(function(ee){return" "+ee}).join(`
`).slice(2):J=`
`+J.split(`
`).map(function(ee){return" "+ee}).join(`
`))):J=F.stylize("[Circular]","special")),E(R)){if(D&&Q.match(/^\d+$/))return J;R=JSON.stringify(""+Q),R.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(R=R.slice(1,-1),R=F.stylize(R,"name")):(R=R.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),R=F.stylize(R,"string"))}return R+": "+J}function g(F,V,Y){var ie=F.reduce(function(Q,D){return D.indexOf(`
`)>=0,Q+D.replace(/\u001b\[\d\d?m/g,"").length+1},0);return ie>60?Y[0]+(V===""?"":V+`
`)+" "+F.join(`,
`)+" "+Y[1]:Y[0]+V+" "+F.join(", ")+" "+Y[1]}t.types=iNt();function x(F){return Array.isArray(F)}t.isArray=x;function y(F){return typeof F=="boolean"}t.isBoolean=y;function v(F){return F===null}t.isNull=v;function b(F){return F==null}t.isNullOrUndefined=b;function w(F){return typeof F=="number"}t.isNumber=w;function S(F){return typeof F=="string"}t.isString=S;function k(F){return typeof F=="symbol"}t.isSymbol=k;function E(F){return F===void 0}t.isUndefined=E;function C(F){return A(F)&&N(F)==="[object RegExp]"}t.isRegExp=C,t.types.isRegExp=C;function A(F){return typeof F=="object"&&F!==null}t.isObject=A;function M(F){return A(F)&&N(F)==="[object Date]"}t.isDate=M,t.types.isDate=M;function z(F){return A(F)&&(N(F)==="[object Error]"||F instanceof Error)}t.isError=z,t.types.isNativeError=z;function P(F){return typeof F=="function"}t.isFunction=P;function W(F){return F===null||typeof F=="boolean"||typeof F=="number"||typeof F=="string"||typeof F=="symbol"||typeof F>"u"}t.isPrimitive=W,t.isBuffer=aNt();function N(F){return Object.prototype.toString.call(F)}function U(F){return F<10?"0"+F.toString(10):F.toString(10)}var K=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function G(){var F=new Date,V=[U(F.getHours()),U(F.getMinutes()),U(F.getSeconds())].join(":");return[F.getDate(),K[F.getMonth()],V].join(" ")}t.log=function(){console.log("%s - %s",G(),t.format.apply(t,arguments))},t.inherits=gm(),t._extend=function(F,V){if(!V||!A(V))return F;for(var Y=Object.keys(V),ie=Y.length;ie--;)F[Y[ie]]=V[Y[ie]];return F};function X(F,V){return Object.prototype.hasOwnProperty.call(F,V)}var H=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(V){if(typeof V!="function")throw new TypeError('The "original" argument must be of type Function');if(H&&V[H]){var Y=V[H];if(typeof Y!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(Y,H,{value:Y,enumerable:!1,writable:!1,configurable:!0}),Y}function Y(){for(var ie,Q,D=new Promise(function(Z,ee){ie=Z,Q=ee}),R=[],J=0;J<arguments.length;J++)R.push(arguments[J]);R.push(function(Z,ee){Z?Q(Z):ie(ee)});try{V.apply(this,R)}catch(Z){Q(Z)}return D}return Object.setPrototypeOf(Y,Object.getPrototypeOf(V)),H&&Object.defineProperty(Y,H,{value:Y,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(Y,e(V))},t.promisify.custom=H;function B(F,V){if(!F){var Y=new Error("Promise was rejected with a falsy value");Y.reason=F,F=Y}return V(F)}function L(F){if(typeof F!="function")throw new TypeError('The "original" argument must be of type Function');function V(){for(var Y=[],ie=0;ie<arguments.length;ie++)Y.push(arguments[ie]);var Q=Y.pop();if(typeof Q!="function")throw new TypeError("The last argument must be of type Function");var D=this,R=function(){return Q.apply(D,arguments)};F.apply(this,Y).then(function(J){Jt.nextTick(R.bind(null,null,J))},function(J){Jt.nextTick(B.bind(null,J,R))})}return Object.setPrototypeOf(V,Object.getPrototypeOf(F)),Object.defineProperties(V,e(F)),V}t.callbackify=L}(e5)),e5}var J5,yne;function oNt(){if(yne)return J5;yne=1;function t(f,p){var m=Object.keys(f);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(f);p&&(g=g.filter(function(x){return Object.getOwnPropertyDescriptor(f,x).enumerable})),m.push.apply(m,g)}return m}function e(f){for(var p=1;p<arguments.length;p++){var m=arguments[p]!=null?arguments[p]:{};p%2?t(Object(m),!0).forEach(function(g){r(f,g,m[g])}):Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(m)):t(Object(m)).forEach(function(g){Object.defineProperty(f,g,Object.getOwnPropertyDescriptor(m,g))})}return f}function r(f,p,m){return p in f?Object.defineProperty(f,p,{value:m,enumerable:!0,configurable:!0,writable:!0}):f[p]=m,f}function n(f,p){if(!(f instanceof p))throw new TypeError("Cannot call a class as a function")}function s(f,p){for(var m=0;m<p.length;m++){var g=p[m];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(f,g.key,g)}}function i(f,p,m){return p&&s(f.prototype,p),f}var a=sD(),o=a.Buffer,c=ISe(),u=c.inspect,d=u&&u.custom||"inspect";function h(f,p,m){o.prototype.copy.call(f,p,m)}return J5=function(){function f(){n(this,f),this.head=null,this.tail=null,this.length=0}return i(f,[{key:"push",value:function(m){var g={data:m,next:null};this.length>0?this.tail.next=g:this.head=g,this.tail=g,++this.length}},{key:"unshift",value:function(m){var g={data:m,next:this.head};this.length===0&&(this.tail=g),this.head=g,++this.length}},{key:"shift",value:function(){if(this.length!==0){var m=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,m}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(m){if(this.length===0)return"";for(var g=this.head,x=""+g.data;g=g.next;)x+=m+g.data;return x}},{key:"concat",value:function(m){if(this.length===0)return o.alloc(0);for(var g=o.allocUnsafe(m>>>0),x=this.head,y=0;x;)h(x.data,g,y),y+=x.data.length,x=x.next;return g}},{key:"consume",value:function(m,g){var x;return m<this.head.data.length?(x=this.head.data.slice(0,m),this.head.data=this.head.data.slice(m)):m===this.head.data.length?x=this.shift():x=g?this._getString(m):this._getBuffer(m),x}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(m){var g=this.head,x=1,y=g.data;for(m-=y.length;g=g.next;){var v=g.data,b=m>v.length?v.length:m;if(b===v.length?y+=v:y+=v.slice(0,m),m-=b,m===0){b===v.length?(++x,g.next?this.head=g.next:this.head=this.tail=null):(this.head=g,g.data=v.slice(b));break}++x}return this.length-=x,y}},{key:"_getBuffer",value:function(m){var g=o.allocUnsafe(m),x=this.head,y=1;for(x.data.copy(g),m-=x.data.length;x=x.next;){var v=x.data,b=m>v.length?v.length:m;if(v.copy(g,g.length-m,0,b),m-=b,m===0){b===v.length?(++y,x.next?this.head=x.next:this.head=this.tail=null):(this.head=x,x.data=v.slice(b));break}++y}return this.length-=y,g}},{key:d,value:function(m,g){return u(this,e({},g,{depth:0,customInspect:!1}))}}]),f}(),J5}var Q5,xne;function RSe(){if(xne)return Q5;xne=1;function t(a,o){var c=this,u=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return u||d?(o?o(a):a&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Jt.nextTick(s,this,a)):Jt.nextTick(s,this,a)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(a||null,function(h){!o&&h?c._writableState?c._writableState.errorEmitted?Jt.nextTick(r,c):(c._writableState.errorEmitted=!0,Jt.nextTick(e,c,h)):Jt.nextTick(e,c,h):o?(Jt.nextTick(r,c),o(h)):Jt.nextTick(r,c)}),this)}function e(a,o){s(a,o),r(a)}function r(a){a._writableState&&!a._writableState.emitClose||a._readableState&&!a._readableState.emitClose||a.emit("close")}function n(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function s(a,o){a.emit("error",o)}function i(a,o){var c=a._readableState,u=a._writableState;c&&c.autoDestroy||u&&u.autoDestroy?a.destroy(o):a.emit("error",o)}return Q5={destroy:t,undestroy:n,errorOrDestroy:i},Q5}var Z5={},vne;function p1(){if(vne)return Z5;vne=1;function t(o,c){o.prototype=Object.create(c.prototype),o.prototype.constructor=o,o.__proto__=c}var e={};function r(o,c,u){u||(u=Error);function d(f,p,m){return typeof c=="string"?c:c(f,p,m)}var h=function(f){t(p,f);function p(m,g,x){return f.call(this,d(m,g,x))||this}return p}(u);h.prototype.name=u.name,h.prototype.code=o,e[o]=h}function n(o,c){if(Array.isArray(o)){var u=o.length;return o=o.map(function(d){return String(d)}),u>2?"one of ".concat(c," ").concat(o.slice(0,u-1).join(", "),", or ")+o[u-1]:u===2?"one of ".concat(c," ").concat(o[0]," or ").concat(o[1]):"of ".concat(c," ").concat(o[0])}else return"of ".concat(c," ").concat(String(o))}function s(o,c,u){return o.substr(0,c.length)===c}function i(o,c,u){return(u===void 0||u>o.length)&&(u=o.length),o.substring(u-c.length,u)===c}function a(o,c,u){return typeof u!="number"&&(u=0),u+c.length>o.length?!1:o.indexOf(c,u)!==-1}return r("ERR_INVALID_OPT_VALUE",function(o,c){return'The value "'+c+'" is invalid for option "'+o+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(o,c,u){var d;typeof c=="string"&&s(c,"not ")?(d="must not be",c=c.replace(/^not /,"")):d="must be";var h;if(i(o," argument"))h="The ".concat(o," ").concat(d," ").concat(n(c,"type"));else{var f=a(o,".")?"property":"argument";h='The "'.concat(o,'" ').concat(f," ").concat(d," ").concat(n(c,"type"))}return h+=". Received type ".concat(typeof u),h},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(o){return"The "+o+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(o){return"Cannot call "+o+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(o){return"Unknown encoding: "+o},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Z5.codes=e,Z5}var e3,bne;function MSe(){if(bne)return e3;bne=1;var t=p1().codes.ERR_INVALID_OPT_VALUE;function e(n,s,i){return n.highWaterMark!=null?n.highWaterMark:s?n[i]:null}function r(n,s,i,a){var o=e(s,a,i);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0){var c=a?i:"highWaterMark";throw new t(c,o)}return Math.floor(o)}return n.objectMode?16:16*1024}return e3={getHighWaterMark:r},e3}var t3,wne;function lNt(){if(wne)return t3;wne=1,t3=t;function t(r,n){if(e("noDeprecation"))return r;var s=!1;function i(){if(!s){if(e("throwDeprecation"))throw new Error(n);e("traceDeprecation")?console.trace(n):console.warn(n),s=!0}return r.apply(this,arguments)}return i}function e(r){try{if(!gu.localStorage)return!1}catch{return!1}var n=gu.localStorage[r];return n==null?!1:String(n).toLowerCase()==="true"}return t3}var r3,Sne;function DSe(){if(Sne)return r3;Sne=1,r3=C;function t(Q){var D=this;this.next=null,this.entry=null,this.finish=function(){ie(D,Q)}}var e;C.WritableState=k;var r={deprecate:lNt()},n=_Se(),s=sD().Buffer,i=gu.Uint8Array||function(){};function a(Q){return s.from(Q)}function o(Q){return s.isBuffer(Q)||Q instanceof i}var c=RSe(),u=MSe(),d=u.getHighWaterMark,h=p1().codes,f=h.ERR_INVALID_ARG_TYPE,p=h.ERR_METHOD_NOT_IMPLEMENTED,m=h.ERR_MULTIPLE_CALLBACK,g=h.ERR_STREAM_CANNOT_PIPE,x=h.ERR_STREAM_DESTROYED,y=h.ERR_STREAM_NULL_VALUES,v=h.ERR_STREAM_WRITE_AFTER_END,b=h.ERR_UNKNOWN_ENCODING,w=c.errorOrDestroy;gm()(C,n);function S(){}function k(Q,D,R){e=e||Sw(),Q=Q||{},typeof R!="boolean"&&(R=D instanceof e),this.objectMode=!!Q.objectMode,R&&(this.objectMode=this.objectMode||!!Q.writableObjectMode),this.highWaterMark=d(this,Q,"writableHighWaterMark",R),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var J=Q.decodeStrings===!1;this.decodeStrings=!J,this.defaultEncoding=Q.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(Z){K(D,Z)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=Q.emitClose!==!1,this.autoDestroy=!!Q.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}k.prototype.getBuffer=function(){for(var D=this.bufferedRequest,R=[];D;)R.push(D),D=D.next;return R},function(){try{Object.defineProperty(k.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var E;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(E=Function.prototype[Symbol.hasInstance],Object.defineProperty(C,Symbol.hasInstance,{value:function(D){return E.call(this,D)?!0:this!==C?!1:D&&D._writableState instanceof k}})):E=function(D){return D instanceof this};function C(Q){e=e||Sw();var D=this instanceof e;if(!D&&!E.call(C,this))return new C(Q);this._writableState=new k(Q,this,D),this.writable=!0,Q&&(typeof Q.write=="function"&&(this._write=Q.write),typeof Q.writev=="function"&&(this._writev=Q.writev),typeof Q.destroy=="function"&&(this._destroy=Q.destroy),typeof Q.final=="function"&&(this._final=Q.final)),n.call(this)}C.prototype.pipe=function(){w(this,new g)};function A(Q,D){var R=new v;w(Q,R),Jt.nextTick(D,R)}function M(Q,D,R,J){var Z;return R===null?Z=new y:typeof R!="string"&&!D.objectMode&&(Z=new f("chunk",["string","Buffer"],R)),Z?(w(Q,Z),Jt.nextTick(J,Z),!1):!0}C.prototype.write=function(Q,D,R){var J=this._writableState,Z=!1,ee=!J.objectMode&&o(Q);return ee&&!s.isBuffer(Q)&&(Q=a(Q)),typeof D=="function"&&(R=D,D=null),ee?D="buffer":D||(D=J.defaultEncoding),typeof R!="function"&&(R=S),J.ending?A(this,R):(ee||M(this,J,Q,R))&&(J.pendingcb++,Z=P(this,J,ee,Q,D,R)),Z},C.prototype.cork=function(){this._writableState.corked++},C.prototype.uncork=function(){var Q=this._writableState;Q.corked&&(Q.corked--,!Q.writing&&!Q.corked&&!Q.bufferProcessing&&Q.bufferedRequest&&H(this,Q))},C.prototype.setDefaultEncoding=function(D){if(typeof D=="string"&&(D=D.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((D+"").toLowerCase())>-1))throw new b(D);return this._writableState.defaultEncoding=D,this},Object.defineProperty(C.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function z(Q,D,R){return!Q.objectMode&&Q.decodeStrings!==!1&&typeof D=="string"&&(D=s.from(D,R)),D}Object.defineProperty(C.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function P(Q,D,R,J,Z,ee){if(!R){var re=z(D,J,Z);J!==re&&(R=!0,Z="buffer",J=re)}var he=D.objectMode?1:J.length;D.length+=he;var O=D.length<D.highWaterMark;if(O||(D.needDrain=!0),D.writing||D.corked){var ae=D.lastBufferedRequest;D.lastBufferedRequest={chunk:J,encoding:Z,isBuf:R,callback:ee,next:null},ae?ae.next=D.lastBufferedRequest:D.bufferedRequest=D.lastBufferedRequest,D.bufferedRequestCount+=1}else W(Q,D,!1,he,J,Z,ee);return O}function W(Q,D,R,J,Z,ee,re){D.writelen=J,D.writecb=re,D.writing=!0,D.sync=!0,D.destroyed?D.onwrite(new x("write")):R?Q._writev(Z,D.onwrite):Q._write(Z,ee,D.onwrite),D.sync=!1}function N(Q,D,R,J,Z){--D.pendingcb,R?(Jt.nextTick(Z,J),Jt.nextTick(V,Q,D),Q._writableState.errorEmitted=!0,w(Q,J)):(Z(J),Q._writableState.errorEmitted=!0,w(Q,J),V(Q,D))}function U(Q){Q.writing=!1,Q.writecb=null,Q.length-=Q.writelen,Q.writelen=0}function K(Q,D){var R=Q._writableState,J=R.sync,Z=R.writecb;if(typeof Z!="function")throw new m;if(U(R),D)N(Q,R,J,D,Z);else{var ee=B(R)||Q.destroyed;!ee&&!R.corked&&!R.bufferProcessing&&R.bufferedRequest&&H(Q,R),J?Jt.nextTick(G,Q,R,ee,Z):G(Q,R,ee,Z)}}function G(Q,D,R,J){R||X(Q,D),D.pendingcb--,J(),V(Q,D)}function X(Q,D){D.length===0&&D.needDrain&&(D.needDrain=!1,Q.emit("drain"))}function H(Q,D){D.bufferProcessing=!0;var R=D.bufferedRequest;if(Q._writev&&R&&R.next){var J=D.bufferedRequestCount,Z=new Array(J),ee=D.corkedRequestsFree;ee.entry=R;for(var re=0,he=!0;R;)Z[re]=R,R.isBuf||(he=!1),R=R.next,re+=1;Z.allBuffers=he,W(Q,D,!0,D.length,Z,"",ee.finish),D.pendingcb++,D.lastBufferedRequest=null,ee.next?(D.corkedRequestsFree=ee.next,ee.next=null):D.corkedRequestsFree=new t(D),D.bufferedRequestCount=0}else{for(;R;){var O=R.chunk,ae=R.encoding,q=R.callback,I=D.objectMode?1:O.length;if(W(Q,D,!1,I,O,ae,q),R=R.next,D.bufferedRequestCount--,D.writing)break}R===null&&(D.lastBufferedRequest=null)}D.bufferedRequest=R,D.bufferProcessing=!1}C.prototype._write=function(Q,D,R){R(new p("_write()"))},C.prototype._writev=null,C.prototype.end=function(Q,D,R){var J=this._writableState;return typeof Q=="function"?(R=Q,Q=null,D=null):typeof D=="function"&&(R=D,D=null),Q!=null&&this.write(Q,D),J.corked&&(J.corked=1,this.uncork()),J.ending||Y(this,J,R),this},Object.defineProperty(C.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function B(Q){return Q.ending&&Q.length===0&&Q.bufferedRequest===null&&!Q.finished&&!Q.writing}function L(Q,D){Q._final(function(R){D.pendingcb--,R&&w(Q,R),D.prefinished=!0,Q.emit("prefinish"),V(Q,D)})}function F(Q,D){!D.prefinished&&!D.finalCalled&&(typeof Q._final=="function"&&!D.destroyed?(D.pendingcb++,D.finalCalled=!0,Jt.nextTick(L,Q,D)):(D.prefinished=!0,Q.emit("prefinish")))}function V(Q,D){var R=B(D);if(R&&(F(Q,D),D.pendingcb===0&&(D.finished=!0,Q.emit("finish"),D.autoDestroy))){var J=Q._readableState;(!J||J.autoDestroy&&J.endEmitted)&&Q.destroy()}return R}function Y(Q,D,R){D.ending=!0,V(Q,D),R&&(D.finished?Jt.nextTick(R):Q.once("finish",R)),D.ended=!0,Q.writable=!1}function ie(Q,D,R){var J=Q.entry;for(Q.entry=null;J;){var Z=J.callback;D.pendingcb--,Z(R),J=J.next}D.corkedRequestsFree.next=Q}return Object.defineProperty(C.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(D){this._writableState&&(this._writableState.destroyed=D)}}),C.prototype.destroy=c.destroy,C.prototype._undestroy=c.undestroy,C.prototype._destroy=function(Q,D){D(Q)},r3}var n3,_ne;function Sw(){if(_ne)return n3;_ne=1;var t=Object.keys||function(u){var d=[];for(var h in u)d.push(h);return d};n3=a;var e=LSe(),r=DSe();gm()(a,e);for(var n=t(r.prototype),s=0;s<n.length;s++){var i=n[s];a.prototype[i]||(a.prototype[i]=r.prototype[i])}function a(u){if(!(this instanceof a))return new a(u);e.call(this,u),r.call(this,u),this.allowHalfOpen=!0,u&&(u.readable===!1&&(this.readable=!1),u.writable===!1&&(this.writable=!1),u.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",o)))}Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(a.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(a.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function o(){this._writableState.ended||Jt.nextTick(c,this)}function c(u){u.end()}return Object.defineProperty(a.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(d){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=d,this._writableState.destroyed=d)}}),n3}var s3={},_C={exports:{}},jne;function cNt(){return jne||(jne=1,function(t,e){var r=sD(),n=r.Buffer;function s(a,o){for(var c in a)o[c]=a[c]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(s(r,e),e.Buffer=i);function i(a,o,c){return n(a,o,c)}s(n,i),i.from=function(a,o,c){if(typeof a=="number")throw new TypeError("Argument must not be a number");return n(a,o,c)},i.alloc=function(a,o,c){if(typeof a!="number")throw new TypeError("Argument must be a number");var u=n(a);return o!==void 0?typeof c=="string"?u.fill(o,c):u.fill(o):u.fill(0),u},i.allocUnsafe=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return n(a)},i.allocUnsafeSlow=function(a){if(typeof a!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(a)}}(_C,_C.exports)),_C.exports}var kne;function Uz(){if(kne)return s3;kne=1;var t=cNt().Buffer,e=t.isEncoding||function(y){switch(y=""+y,y&&y.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(y){if(!y)return"utf8";for(var v;;)switch(y){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return y;default:if(v)return;y=(""+y).toLowerCase(),v=!0}}function n(y){var v=r(y);if(typeof v!="string"&&(t.isEncoding===e||!e(y)))throw new Error("Unknown encoding: "+y);return v||y}s3.StringDecoder=s;function s(y){this.encoding=n(y);var v;switch(this.encoding){case"utf16le":this.text=h,this.end=f,v=4;break;case"utf8":this.fillLast=c,v=4;break;case"base64":this.text=p,this.end=m,v=3;break;default:this.write=g,this.end=x;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(v)}s.prototype.write=function(y){if(y.length===0)return"";var v,b;if(this.lastNeed){if(v=this.fillLast(y),v===void 0)return"";b=this.lastNeed,this.lastNeed=0}else b=0;return b<y.length?v?v+this.text(y,b):this.text(y,b):v||""},s.prototype.end=d,s.prototype.text=u,s.prototype.fillLast=function(y){if(this.lastNeed<=y.length)return y.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);y.copy(this.lastChar,this.lastTotal-this.lastNeed,0,y.length),this.lastNeed-=y.length};function i(y){return y<=127?0:y>>5===6?2:y>>4===14?3:y>>3===30?4:y>>6===2?-1:-2}function a(y,v,b){var w=v.length-1;if(w<b)return 0;var S=i(v[w]);return S>=0?(S>0&&(y.lastNeed=S-1),S):--w<b||S===-2?0:(S=i(v[w]),S>=0?(S>0&&(y.lastNeed=S-2),S):--w<b||S===-2?0:(S=i(v[w]),S>=0?(S>0&&(S===2?S=0:y.lastNeed=S-3),S):0))}function o(y,v,b){if((v[0]&192)!==128)return y.lastNeed=0,"�";if(y.lastNeed>1&&v.length>1){if((v[1]&192)!==128)return y.lastNeed=1,"�";if(y.lastNeed>2&&v.length>2&&(v[2]&192)!==128)return y.lastNeed=2,"�"}}function c(y){var v=this.lastTotal-this.lastNeed,b=o(this,y);if(b!==void 0)return b;if(this.lastNeed<=y.length)return y.copy(this.lastChar,v,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);y.copy(this.lastChar,v,0,y.length),this.lastNeed-=y.length}function u(y,v){var b=a(this,y,v);if(!this.lastNeed)return y.toString("utf8",v);this.lastTotal=b;var w=y.length-(b-this.lastNeed);return y.copy(this.lastChar,0,w),y.toString("utf8",v,w)}function d(y){var v=y&&y.length?this.write(y):"";return this.lastNeed?v+"�":v}function h(y,v){if((y.length-v)%2===0){var b=y.toString("utf16le",v);if(b){var w=b.charCodeAt(b.length-1);if(w>=55296&&w<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=y[y.length-2],this.lastChar[1]=y[y.length-1],b.slice(0,-1)}return b}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=y[y.length-1],y.toString("utf16le",v,y.length-1)}function f(y){var v=y&&y.length?this.write(y):"";if(this.lastNeed){var b=this.lastTotal-this.lastNeed;return v+this.lastChar.toString("utf16le",0,b)}return v}function p(y,v){var b=(y.length-v)%3;return b===0?y.toString("base64",v):(this.lastNeed=3-b,this.lastTotal=3,b===1?this.lastChar[0]=y[y.length-1]:(this.lastChar[0]=y[y.length-2],this.lastChar[1]=y[y.length-1]),y.toString("base64",v,y.length-b))}function m(y){var v=y&&y.length?this.write(y):"";return this.lastNeed?v+this.lastChar.toString("base64",0,3-this.lastNeed):v}function g(y){return y.toString(this.encoding)}function x(y){return y&&y.length?this.write(y):""}return s3}var i3,Nne;function f7(){if(Nne)return i3;Nne=1;var t=p1().codes.ERR_STREAM_PREMATURE_CLOSE;function e(i){var a=!1;return function(){if(!a){a=!0;for(var o=arguments.length,c=new Array(o),u=0;u<o;u++)c[u]=arguments[u];i.apply(this,c)}}}function r(){}function n(i){return i.setHeader&&typeof i.abort=="function"}function s(i,a,o){if(typeof a=="function")return s(i,null,a);a||(a={}),o=e(o||r);var c=a.readable||a.readable!==!1&&i.readable,u=a.writable||a.writable!==!1&&i.writable,d=function(){i.writable||f()},h=i._writableState&&i._writableState.finished,f=function(){u=!1,h=!0,c||o.call(i)},p=i._readableState&&i._readableState.endEmitted,m=function(){c=!1,p=!0,u||o.call(i)},g=function(b){o.call(i,b)},x=function(){var b;if(c&&!p)return(!i._readableState||!i._readableState.ended)&&(b=new t),o.call(i,b);if(u&&!h)return(!i._writableState||!i._writableState.ended)&&(b=new t),o.call(i,b)},y=function(){i.req.on("finish",f)};return n(i)?(i.on("complete",f),i.on("abort",x),i.req?y():i.on("request",y)):u&&!i._writableState&&(i.on("end",d),i.on("close",d)),i.on("end",m),i.on("finish",f),a.error!==!1&&i.on("error",g),i.on("close",x),function(){i.removeListener("complete",f),i.removeListener("abort",x),i.removeListener("request",y),i.req&&i.req.removeListener("finish",f),i.removeListener("end",d),i.removeListener("close",d),i.removeListener("finish",f),i.removeListener("end",m),i.removeListener("error",g),i.removeListener("close",x)}}return i3=s,i3}var a3,Ene;function uNt(){if(Ene)return a3;Ene=1;var t;function e(y,v,b){return v in y?Object.defineProperty(y,v,{value:b,enumerable:!0,configurable:!0,writable:!0}):y[v]=b,y}var r=f7(),n=Symbol("lastResolve"),s=Symbol("lastReject"),i=Symbol("error"),a=Symbol("ended"),o=Symbol("lastPromise"),c=Symbol("handlePromise"),u=Symbol("stream");function d(y,v){return{value:y,done:v}}function h(y){var v=y[n];if(v!==null){var b=y[u].read();b!==null&&(y[o]=null,y[n]=null,y[s]=null,v(d(b,!1)))}}function f(y){Jt.nextTick(h,y)}function p(y,v){return function(b,w){y.then(function(){if(v[a]){b(d(void 0,!0));return}v[c](b,w)},w)}}var m=Object.getPrototypeOf(function(){}),g=Object.setPrototypeOf((t={get stream(){return this[u]},next:function(){var v=this,b=this[i];if(b!==null)return Promise.reject(b);if(this[a])return Promise.resolve(d(void 0,!0));if(this[u].destroyed)return new Promise(function(E,C){Jt.nextTick(function(){v[i]?C(v[i]):E(d(void 0,!0))})});var w=this[o],S;if(w)S=new Promise(p(w,this));else{var k=this[u].read();if(k!==null)return Promise.resolve(d(k,!1));S=new Promise(this[c])}return this[o]=S,S}},e(t,Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var v=this;return new Promise(function(b,w){v[u].destroy(null,function(S){if(S){w(S);return}b(d(void 0,!0))})})}),t),m),x=function(v){var b,w=Object.create(g,(b={},e(b,u,{value:v,writable:!0}),e(b,n,{value:null,writable:!0}),e(b,s,{value:null,writable:!0}),e(b,i,{value:null,writable:!0}),e(b,a,{value:v._readableState.endEmitted,writable:!0}),e(b,c,{value:function(k,E){var C=w[u].read();C?(w[o]=null,w[n]=null,w[s]=null,k(d(C,!1))):(w[n]=k,w[s]=E)},writable:!0}),b));return w[o]=null,r(v,function(S){if(S&&S.code!=="ERR_STREAM_PREMATURE_CLOSE"){var k=w[s];k!==null&&(w[o]=null,w[n]=null,w[s]=null,k(S)),w[i]=S;return}var E=w[n];E!==null&&(w[o]=null,w[n]=null,w[s]=null,E(d(void 0,!0))),w[a]=!0}),v.on("readable",f.bind(null,w)),w};return a3=x,a3}var o3,Ane;function dNt(){return Ane||(Ane=1,o3=function(){throw new Error("Readable.from is not available in the browser")}),o3}var l3,Cne;function LSe(){if(Cne)return l3;Cne=1,l3=A;var t;A.ReadableState=C,c7().EventEmitter;var e=function(re,he){return re.listeners(he).length},r=_Se(),n=sD().Buffer,s=gu.Uint8Array||function(){};function i(ee){return n.from(ee)}function a(ee){return n.isBuffer(ee)||ee instanceof s}var o=ISe(),c;o&&o.debuglog?c=o.debuglog("stream"):c=function(){};var u=oNt(),d=RSe(),h=MSe(),f=h.getHighWaterMark,p=p1().codes,m=p.ERR_INVALID_ARG_TYPE,g=p.ERR_STREAM_PUSH_AFTER_EOF,x=p.ERR_METHOD_NOT_IMPLEMENTED,y=p.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,v,b,w;gm()(A,r);var S=d.errorOrDestroy,k=["error","close","destroy","pause","resume"];function E(ee,re,he){if(typeof ee.prependListener=="function")return ee.prependListener(re,he);!ee._events||!ee._events[re]?ee.on(re,he):Array.isArray(ee._events[re])?ee._events[re].unshift(he):ee._events[re]=[he,ee._events[re]]}function C(ee,re,he){t=t||Sw(),ee=ee||{},typeof he!="boolean"&&(he=re instanceof t),this.objectMode=!!ee.objectMode,he&&(this.objectMode=this.objectMode||!!ee.readableObjectMode),this.highWaterMark=f(this,ee,"readableHighWaterMark",he),this.buffer=new u,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=ee.emitClose!==!1,this.autoDestroy=!!ee.autoDestroy,this.destroyed=!1,this.defaultEncoding=ee.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,ee.encoding&&(v||(v=Uz().StringDecoder),this.decoder=new v(ee.encoding),this.encoding=ee.encoding)}function A(ee){if(t=t||Sw(),!(this instanceof A))return new A(ee);var re=this instanceof t;this._readableState=new C(ee,this,re),this.readable=!0,ee&&(typeof ee.read=="function"&&(this._read=ee.read),typeof ee.destroy=="function"&&(this._destroy=ee.destroy)),r.call(this)}Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(re){this._readableState&&(this._readableState.destroyed=re)}}),A.prototype.destroy=d.destroy,A.prototype._undestroy=d.undestroy,A.prototype._destroy=function(ee,re){re(ee)},A.prototype.push=function(ee,re){var he=this._readableState,O;return he.objectMode?O=!0:typeof ee=="string"&&(re=re||he.defaultEncoding,re!==he.encoding&&(ee=n.from(ee,re),re=""),O=!0),M(this,ee,re,!1,O)},A.prototype.unshift=function(ee){return M(this,ee,null,!0,!1)};function M(ee,re,he,O,ae){c("readableAddChunk",re);var q=ee._readableState;if(re===null)q.reading=!1,K(ee,q);else{var I;if(ae||(I=P(q,re)),I)S(ee,I);else if(q.objectMode||re&&re.length>0)if(typeof re!="string"&&!q.objectMode&&Object.getPrototypeOf(re)!==n.prototype&&(re=i(re)),O)q.endEmitted?S(ee,new y):z(ee,q,re,!0);else if(q.ended)S(ee,new g);else{if(q.destroyed)return!1;q.reading=!1,q.decoder&&!he?(re=q.decoder.write(re),q.objectMode||re.length!==0?z(ee,q,re,!1):H(ee,q)):z(ee,q,re,!1)}else O||(q.reading=!1,H(ee,q))}return!q.ended&&(q.length<q.highWaterMark||q.length===0)}function z(ee,re,he,O){re.flowing&&re.length===0&&!re.sync?(re.awaitDrain=0,ee.emit("data",he)):(re.length+=re.objectMode?1:he.length,O?re.buffer.unshift(he):re.buffer.push(he),re.needReadable&&G(ee)),H(ee,re)}function P(ee,re){var he;return!a(re)&&typeof re!="string"&&re!==void 0&&!ee.objectMode&&(he=new m("chunk",["string","Buffer","Uint8Array"],re)),he}A.prototype.isPaused=function(){return this._readableState.flowing===!1},A.prototype.setEncoding=function(ee){v||(v=Uz().StringDecoder);var re=new v(ee);this._readableState.decoder=re,this._readableState.encoding=this._readableState.decoder.encoding;for(var he=this._readableState.buffer.head,O="";he!==null;)O+=re.write(he.data),he=he.next;return this._readableState.buffer.clear(),O!==""&&this._readableState.buffer.push(O),this._readableState.length=O.length,this};var W=1073741824;function N(ee){return ee>=W?ee=W:(ee--,ee|=ee>>>1,ee|=ee>>>2,ee|=ee>>>4,ee|=ee>>>8,ee|=ee>>>16,ee++),ee}function U(ee,re){return ee<=0||re.length===0&&re.ended?0:re.objectMode?1:ee!==ee?re.flowing&&re.length?re.buffer.head.data.length:re.length:(ee>re.highWaterMark&&(re.highWaterMark=N(ee)),ee<=re.length?ee:re.ended?re.length:(re.needReadable=!0,0))}A.prototype.read=function(ee){c("read",ee),ee=parseInt(ee,10);var re=this._readableState,he=ee;if(ee!==0&&(re.emittedReadable=!1),ee===0&&re.needReadable&&((re.highWaterMark!==0?re.length>=re.highWaterMark:re.length>0)||re.ended))return c("read: emitReadable",re.length,re.ended),re.length===0&&re.ended?R(this):G(this),null;if(ee=U(ee,re),ee===0&&re.ended)return re.length===0&&R(this),null;var O=re.needReadable;c("need readable",O),(re.length===0||re.length-ee<re.highWaterMark)&&(O=!0,c("length less than watermark",O)),re.ended||re.reading?(O=!1,c("reading or ended",O)):O&&(c("do read"),re.reading=!0,re.sync=!0,re.length===0&&(re.needReadable=!0),this._read(re.highWaterMark),re.sync=!1,re.reading||(ee=U(he,re)));var ae;return ee>0?ae=D(ee,re):ae=null,ae===null?(re.needReadable=re.length<=re.highWaterMark,ee=0):(re.length-=ee,re.awaitDrain=0),re.length===0&&(re.ended||(re.needReadable=!0),he!==ee&&re.ended&&R(this)),ae!==null&&this.emit("data",ae),ae};function K(ee,re){if(c("onEofChunk"),!re.ended){if(re.decoder){var he=re.decoder.end();he&&he.length&&(re.buffer.push(he),re.length+=re.objectMode?1:he.length)}re.ended=!0,re.sync?G(ee):(re.needReadable=!1,re.emittedReadable||(re.emittedReadable=!0,X(ee)))}}function G(ee){var re=ee._readableState;c("emitReadable",re.needReadable,re.emittedReadable),re.needReadable=!1,re.emittedReadable||(c("emitReadable",re.flowing),re.emittedReadable=!0,Jt.nextTick(X,ee))}function X(ee){var re=ee._readableState;c("emitReadable_",re.destroyed,re.length,re.ended),!re.destroyed&&(re.length||re.ended)&&(ee.emit("readable"),re.emittedReadable=!1),re.needReadable=!re.flowing&&!re.ended&&re.length<=re.highWaterMark,Q(ee)}function H(ee,re){re.readingMore||(re.readingMore=!0,Jt.nextTick(B,ee,re))}function B(ee,re){for(;!re.reading&&!re.ended&&(re.length<re.highWaterMark||re.flowing&&re.length===0);){var he=re.length;if(c("maybeReadMore read 0"),ee.read(0),he===re.length)break}re.readingMore=!1}A.prototype._read=function(ee){S(this,new x("_read()"))},A.prototype.pipe=function(ee,re){var he=this,O=this._readableState;switch(O.pipesCount){case 0:O.pipes=ee;break;case 1:O.pipes=[O.pipes,ee];break;default:O.pipes.push(ee);break}O.pipesCount+=1,c("pipe count=%d opts=%j",O.pipesCount,re);var ae=(!re||re.end!==!1)&&ee!==Jt.stdout&&ee!==Jt.stderr,q=ae?T:oe;O.endEmitted?Jt.nextTick(q):he.once("end",q),ee.on("unpipe",I);function I(de,ge){c("onunpipe"),de===he&&ge&&ge.hasUnpiped===!1&&(ge.hasUnpiped=!0,ue())}function T(){c("onend"),ee.end()}var $=L(he);ee.on("drain",$);var se=!1;function ue(){c("cleanup"),ee.removeListener("close",ve),ee.removeListener("finish",xe),ee.removeListener("drain",$),ee.removeListener("error",me),ee.removeListener("unpipe",I),he.removeListener("end",T),he.removeListener("end",oe),he.removeListener("data",ne),se=!0,O.awaitDrain&&(!ee._writableState||ee._writableState.needDrain)&&$()}he.on("data",ne);function ne(de){c("ondata");var ge=ee.write(de);c("dest.write",ge),ge===!1&&((O.pipesCount===1&&O.pipes===ee||O.pipesCount>1&&Z(O.pipes,ee)!==-1)&&!se&&(c("false write response, pause",O.awaitDrain),O.awaitDrain++),he.pause())}function me(de){c("onerror",de),oe(),ee.removeListener("error",me),e(ee,"error")===0&&S(ee,de)}E(ee,"error",me);function ve(){ee.removeListener("finish",xe),oe()}ee.once("close",ve);function xe(){c("onfinish"),ee.removeListener("close",ve),oe()}ee.once("finish",xe);function oe(){c("unpipe"),he.unpipe(ee)}return ee.emit("pipe",he),O.flowing||(c("pipe resume"),he.resume()),ee};function L(ee){return function(){var he=ee._readableState;c("pipeOnDrain",he.awaitDrain),he.awaitDrain&&he.awaitDrain--,he.awaitDrain===0&&e(ee,"data")&&(he.flowing=!0,Q(ee))}}A.prototype.unpipe=function(ee){var re=this._readableState,he={hasUnpiped:!1};if(re.pipesCount===0)return this;if(re.pipesCount===1)return ee&&ee!==re.pipes?this:(ee||(ee=re.pipes),re.pipes=null,re.pipesCount=0,re.flowing=!1,ee&&ee.emit("unpipe",this,he),this);if(!ee){var O=re.pipes,ae=re.pipesCount;re.pipes=null,re.pipesCount=0,re.flowing=!1;for(var q=0;q<ae;q++)O[q].emit("unpipe",this,{hasUnpiped:!1});return this}var I=Z(re.pipes,ee);return I===-1?this:(re.pipes.splice(I,1),re.pipesCount-=1,re.pipesCount===1&&(re.pipes=re.pipes[0]),ee.emit("unpipe",this,he),this)},A.prototype.on=function(ee,re){var he=r.prototype.on.call(this,ee,re),O=this._readableState;return ee==="data"?(O.readableListening=this.listenerCount("readable")>0,O.flowing!==!1&&this.resume()):ee==="readable"&&!O.endEmitted&&!O.readableListening&&(O.readableListening=O.needReadable=!0,O.flowing=!1,O.emittedReadable=!1,c("on readable",O.length,O.reading),O.length?G(this):O.reading||Jt.nextTick(V,this)),he},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(ee,re){var he=r.prototype.removeListener.call(this,ee,re);return ee==="readable"&&Jt.nextTick(F,this),he},A.prototype.removeAllListeners=function(ee){var re=r.prototype.removeAllListeners.apply(this,arguments);return(ee==="readable"||ee===void 0)&&Jt.nextTick(F,this),re};function F(ee){var re=ee._readableState;re.readableListening=ee.listenerCount("readable")>0,re.resumeScheduled&&!re.paused?re.flowing=!0:ee.listenerCount("data")>0&&ee.resume()}function V(ee){c("readable nexttick read 0"),ee.read(0)}A.prototype.resume=function(){var ee=this._readableState;return ee.flowing||(c("resume"),ee.flowing=!ee.readableListening,Y(this,ee)),ee.paused=!1,this};function Y(ee,re){re.resumeScheduled||(re.resumeScheduled=!0,Jt.nextTick(ie,ee,re))}function ie(ee,re){c("resume",re.reading),re.reading||ee.read(0),re.resumeScheduled=!1,ee.emit("resume"),Q(ee),re.flowing&&!re.reading&&ee.read(0)}A.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function Q(ee){var re=ee._readableState;for(c("flow",re.flowing);re.flowing&&ee.read()!==null;);}A.prototype.wrap=function(ee){var re=this,he=this._readableState,O=!1;ee.on("end",function(){if(c("wrapped end"),he.decoder&&!he.ended){var I=he.decoder.end();I&&I.length&&re.push(I)}re.push(null)}),ee.on("data",function(I){if(c("wrapped data"),he.decoder&&(I=he.decoder.write(I)),!(he.objectMode&&I==null)&&!(!he.objectMode&&(!I||!I.length))){var T=re.push(I);T||(O=!0,ee.pause())}});for(var ae in ee)this[ae]===void 0&&typeof ee[ae]=="function"&&(this[ae]=function(T){return function(){return ee[T].apply(ee,arguments)}}(ae));for(var q=0;q<k.length;q++)ee.on(k[q],this.emit.bind(this,k[q]));return this._read=function(I){c("wrapped _read",I),O&&(O=!1,ee.resume())},this},typeof Symbol=="function"&&(A.prototype[Symbol.asyncIterator]=function(){return b===void 0&&(b=uNt()),b(this)}),Object.defineProperty(A.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(A.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(A.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(re){this._readableState&&(this._readableState.flowing=re)}}),A._fromList=D,Object.defineProperty(A.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function D(ee,re){if(re.length===0)return null;var he;return re.objectMode?he=re.buffer.shift():!ee||ee>=re.length?(re.decoder?he=re.buffer.join(""):re.buffer.length===1?he=re.buffer.first():he=re.buffer.concat(re.length),re.buffer.clear()):he=re.buffer.consume(ee,re.decoder),he}function R(ee){var re=ee._readableState;c("endReadable",re.endEmitted),re.endEmitted||(re.ended=!0,Jt.nextTick(J,re,ee))}function J(ee,re){if(c("endReadableNT",ee.endEmitted,ee.length),!ee.endEmitted&&ee.length===0&&(ee.endEmitted=!0,re.readable=!1,re.emit("end"),ee.autoDestroy)){var he=re._writableState;(!he||he.autoDestroy&&he.finished)&&re.destroy()}}typeof Symbol=="function"&&(A.from=function(ee,re){return w===void 0&&(w=dNt()),w(A,ee,re)});function Z(ee,re){for(var he=0,O=ee.length;he<O;he++)if(ee[he]===re)return he;return-1}return l3}var c3,Tne;function FSe(){if(Tne)return c3;Tne=1,c3=o;var t=p1().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,r=t.ERR_MULTIPLE_CALLBACK,n=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=t.ERR_TRANSFORM_WITH_LENGTH_0,i=Sw();gm()(o,i);function a(d,h){var f=this._transformState;f.transforming=!1;var p=f.writecb;if(p===null)return this.emit("error",new r);f.writechunk=null,f.writecb=null,h!=null&&this.push(h),p(d);var m=this._readableState;m.reading=!1,(m.needReadable||m.length<m.highWaterMark)&&this._read(m.highWaterMark)}function o(d){if(!(this instanceof o))return new o(d);i.call(this,d),this._transformState={afterTransform:a.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",c)}function c(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(h,f){u(d,h,f)}):u(this,null,null)}o.prototype.push=function(d,h){return this._transformState.needTransform=!1,i.prototype.push.call(this,d,h)},o.prototype._transform=function(d,h,f){f(new e("_transform()"))},o.prototype._write=function(d,h,f){var p=this._transformState;if(p.writecb=f,p.writechunk=d,p.writeencoding=h,!p.transforming){var m=this._readableState;(p.needTransform||m.needReadable||m.length<m.highWaterMark)&&this._read(m.highWaterMark)}},o.prototype._read=function(d){var h=this._transformState;h.writechunk!==null&&!h.transforming?(h.transforming=!0,this._transform(h.writechunk,h.writeencoding,h.afterTransform)):h.needTransform=!0},o.prototype._destroy=function(d,h){i.prototype._destroy.call(this,d,function(f){h(f)})};function u(d,h,f){if(h)return d.emit("error",h);if(f!=null&&d.push(f),d._writableState.length)throw new s;if(d._transformState.transforming)throw new n;return d.push(null)}return c3}var u3,Pne;function hNt(){if(Pne)return u3;Pne=1,u3=e;var t=FSe();gm()(e,t);function e(r){if(!(this instanceof e))return new e(r);t.call(this,r)}return e.prototype._transform=function(r,n,s){s(null,r)},u3}var d3,One;function fNt(){if(One)return d3;One=1;var t;function e(f){var p=!1;return function(){p||(p=!0,f.apply(void 0,arguments))}}var r=p1().codes,n=r.ERR_MISSING_ARGS,s=r.ERR_STREAM_DESTROYED;function i(f){if(f)throw f}function a(f){return f.setHeader&&typeof f.abort=="function"}function o(f,p,m,g){g=e(g);var x=!1;f.on("close",function(){x=!0}),t===void 0&&(t=f7()),t(f,{readable:p,writable:m},function(v){if(v)return g(v);x=!0,g()});var y=!1;return function(v){if(!x&&!y){if(y=!0,a(f))return f.abort();if(typeof f.destroy=="function")return f.destroy();g(v||new s("pipe"))}}}function c(f){f()}function u(f,p){return f.pipe(p)}function d(f){return!f.length||typeof f[f.length-1]!="function"?i:f.pop()}function h(){for(var f=arguments.length,p=new Array(f),m=0;m<f;m++)p[m]=arguments[m];var g=d(p);if(Array.isArray(p[0])&&(p=p[0]),p.length<2)throw new n("streams");var x,y=p.map(function(v,b){var w=b<p.length-1,S=b>0;return o(v,w,S,function(k){x||(x=k),k&&y.forEach(c),!w&&(y.forEach(c),g(x))})});return p.reduce(u)}return d3=h,d3}var h3,Ine;function p7(){if(Ine)return h3;Ine=1,h3=r;var t=c7().EventEmitter,e=gm();e(r,t),r.Readable=LSe(),r.Writable=DSe(),r.Duplex=Sw(),r.Transform=FSe(),r.PassThrough=hNt(),r.finished=f7(),r.pipeline=fNt(),r.Stream=r;function r(){t.call(this)}return r.prototype.pipe=function(n,s){var i=this;function a(p){n.writable&&n.write(p)===!1&&i.pause&&i.pause()}i.on("data",a);function o(){i.readable&&i.resume&&i.resume()}n.on("drain",o),!n._isStdio&&(!s||s.end!==!1)&&(i.on("end",u),i.on("close",d));var c=!1;function u(){c||(c=!0,n.end())}function d(){c||(c=!0,typeof n.destroy=="function"&&n.destroy())}function h(p){if(f(),t.listenerCount(this,"error")===0)throw p}i.on("error",h),n.on("error",h);function f(){i.removeListener("data",a),n.removeListener("drain",o),i.removeListener("end",u),i.removeListener("close",d),i.removeListener("error",h),n.removeListener("error",h),i.removeListener("end",f),i.removeListener("close",f),n.removeListener("close",f)}return i.on("end",f),i.on("close",f),n.on("close",f),n.emit("pipe",i),n},h3}var Rne;function pNt(){return Rne||(Rne=1,function(t){(function(e){e.parser=function(D,R){return new n(D,R)},e.SAXParser=n,e.SAXStream=d,e.createStream=u,e.MAX_BUFFER_LENGTH=64*1024;var r=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"];function n(D,R){if(!(this instanceof n))return new n(D,R);var J=this;i(J),J.q=J.c="",J.bufferCheckPosition=e.MAX_BUFFER_LENGTH,J.opt=R||{},J.opt.lowercase=J.opt.lowercase||J.opt.lowercasetags,J.looseCase=J.opt.lowercase?"toLowerCase":"toUpperCase",J.tags=[],J.closed=J.closedRoot=J.sawRoot=!1,J.tag=J.error=null,J.strict=!!D,J.noscript=!!(D||J.opt.noscript),J.state=A.BEGIN,J.strictEntities=J.opt.strictEntities,J.ENTITIES=J.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),J.attribList=[],J.opt.xmlns&&(J.ns=Object.create(g)),J.trackPosition=J.opt.position!==!1,J.trackPosition&&(J.position=J.line=J.column=0),z(J,"onready")}Object.create||(Object.create=function(D){function R(){}R.prototype=D;var J=new R;return J}),Object.keys||(Object.keys=function(D){var R=[];for(var J in D)D.hasOwnProperty(J)&&R.push(J);return R});function s(D){for(var R=Math.max(e.MAX_BUFFER_LENGTH,10),J=0,Z=0,ee=r.length;Z<ee;Z++){var re=D[r[Z]].length;if(re>R)switch(r[Z]){case"textNode":W(D);break;case"cdata":P(D,"oncdata",D.cdata),D.cdata="";break;case"script":P(D,"onscript",D.script),D.script="";break;default:U(D,"Max buffer length exceeded: "+r[Z])}J=Math.max(J,re)}var he=e.MAX_BUFFER_LENGTH-J;D.bufferCheckPosition=he+D.position}function i(D){for(var R=0,J=r.length;R<J;R++)D[r[R]]=""}function a(D){W(D),D.cdata!==""&&(P(D,"oncdata",D.cdata),D.cdata=""),D.script!==""&&(P(D,"onscript",D.script),D.script="")}n.prototype={end:function(){K(this)},write:Q,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var o;try{o=p7().Stream}catch{o=function(){}}var c=e.EVENTS.filter(function(D){return D!=="error"&&D!=="end"});function u(D,R){return new d(D,R)}function d(D,R){if(!(this instanceof d))return new d(D,R);o.apply(this),this._parser=new n(D,R),this.writable=!0,this.readable=!0;var J=this;this._parser.onend=function(){J.emit("end")},this._parser.onerror=function(Z){J.emit("error",Z),J._parser.error=null},this._decoder=null,c.forEach(function(Z){Object.defineProperty(J,"on"+Z,{get:function(){return J._parser["on"+Z]},set:function(ee){if(!ee)return J.removeAllListeners(Z),J._parser["on"+Z]=ee,ee;J.on(Z,ee)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(o.prototype,{constructor:{value:d}}),d.prototype.write=function(D){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(D)){if(!this._decoder){var R=Uz().StringDecoder;this._decoder=new R("utf8")}D=this._decoder.write(D)}return this._parser.write(D.toString()),this.emit("data",D),!0},d.prototype.end=function(D){return D&&D.length&&this.write(D),this._parser.end(),!0},d.prototype.on=function(D,R){var J=this;return!J._parser["on"+D]&&c.indexOf(D)!==-1&&(J._parser["on"+D]=function(){var Z=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);Z.splice(0,0,D),J.emit.apply(J,Z)}),o.prototype.on.call(J,D,R)};var h="[CDATA[",f="DOCTYPE",p="http://www.w3.org/XML/1998/namespace",m="http://www.w3.org/2000/xmlns/",g={xml:p,xmlns:m},x=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,y=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,v=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,b=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function w(D){return D===" "||D===`
`||D==="\r"||D===" "}function S(D){return D==='"'||D==="'"}function k(D){return D===">"||w(D)}function E(D,R){return D.test(R)}function C(D,R){return!E(D,R)}var A=0;e.STATE={BEGIN:A++,BEGIN_WHITESPACE:A++,TEXT:A++,TEXT_ENTITY:A++,OPEN_WAKA:A++,SGML_DECL:A++,SGML_DECL_QUOTED:A++,DOCTYPE:A++,DOCTYPE_QUOTED:A++,DOCTYPE_DTD:A++,DOCTYPE_DTD_QUOTED:A++,COMMENT_STARTING:A++,COMMENT:A++,COMMENT_ENDING:A++,COMMENT_ENDED:A++,CDATA:A++,CDATA_ENDING:A++,CDATA_ENDING_2:A++,PROC_INST:A++,PROC_INST_BODY:A++,PROC_INST_ENDING:A++,OPEN_TAG:A++,OPEN_TAG_SLASH:A++,ATTRIB:A++,ATTRIB_NAME:A++,ATTRIB_NAME_SAW_WHITE:A++,ATTRIB_VALUE:A++,ATTRIB_VALUE_QUOTED:A++,ATTRIB_VALUE_CLOSED:A++,ATTRIB_VALUE_UNQUOTED:A++,ATTRIB_VALUE_ENTITY_Q:A++,ATTRIB_VALUE_ENTITY_U:A++,CLOSE_TAG:A++,CLOSE_TAG_SAW_WHITE:A++,SCRIPT:A++,SCRIPT_ENDING:A++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach(function(D){var R=e.ENTITIES[D],J=typeof R=="number"?String.fromCharCode(R):R;e.ENTITIES[D]=J});for(var M in e.STATE)e.STATE[e.STATE[M]]=M;A=e.STATE;function z(D,R,J){D[R]&&D[R](J)}function P(D,R,J){D.textNode&&W(D),z(D,R,J)}function W(D){D.textNode=N(D.opt,D.textNode),D.textNode&&z(D,"ontext",D.textNode),D.textNode=""}function N(D,R){return D.trim&&(R=R.trim()),D.normalize&&(R=R.replace(/\s+/g," ")),R}function U(D,R){return W(D),D.trackPosition&&(R+=`
Line: `+D.line+`
Column: `+D.column+`
Char: `+D.c),R=new Error(R),D.error=R,z(D,"onerror",R),D}function K(D){return D.sawRoot&&!D.closedRoot&&G(D,"Unclosed root tag"),D.state!==A.BEGIN&&D.state!==A.BEGIN_WHITESPACE&&D.state!==A.TEXT&&U(D,"Unexpected end"),W(D),D.c="",D.closed=!0,z(D,"onend"),n.call(D,D.strict,D.opt),D}function G(D,R){if(typeof D!="object"||!(D instanceof n))throw new Error("bad call to strictFail");D.strict&&U(D,R)}function X(D){D.strict||(D.tagName=D.tagName[D.looseCase]());var R=D.tags[D.tags.length-1]||D,J=D.tag={name:D.tagName,attributes:{}};D.opt.xmlns&&(J.ns=R.ns),D.attribList.length=0,P(D,"onopentagstart",J)}function H(D,R){var J=D.indexOf(":"),Z=J<0?["",D]:D.split(":"),ee=Z[0],re=Z[1];return R&&D==="xmlns"&&(ee="xmlns",re=""),{prefix:ee,local:re}}function B(D){if(D.strict||(D.attribName=D.attribName[D.looseCase]()),D.attribList.indexOf(D.attribName)!==-1||D.tag.attributes.hasOwnProperty(D.attribName)){D.attribName=D.attribValue="";return}if(D.opt.xmlns){var R=H(D.attribName,!0),J=R.prefix,Z=R.local;if(J==="xmlns")if(Z==="xml"&&D.attribValue!==p)G(D,"xml: prefix must be bound to "+p+`
Actual: `+D.attribValue);else if(Z==="xmlns"&&D.attribValue!==m)G(D,"xmlns: prefix must be bound to "+m+`
Actual: `+D.attribValue);else{var ee=D.tag,re=D.tags[D.tags.length-1]||D;ee.ns===re.ns&&(ee.ns=Object.create(re.ns)),ee.ns[Z]=D.attribValue}D.attribList.push([D.attribName,D.attribValue])}else D.tag.attributes[D.attribName]=D.attribValue,P(D,"onattribute",{name:D.attribName,value:D.attribValue});D.attribName=D.attribValue=""}function L(D,R){if(D.opt.xmlns){var J=D.tag,Z=H(D.tagName);J.prefix=Z.prefix,J.local=Z.local,J.uri=J.ns[Z.prefix]||"",J.prefix&&!J.uri&&(G(D,"Unbound namespace prefix: "+JSON.stringify(D.tagName)),J.uri=Z.prefix);var ee=D.tags[D.tags.length-1]||D;J.ns&&ee.ns!==J.ns&&Object.keys(J.ns).forEach(function(ne){P(D,"onopennamespace",{prefix:ne,uri:J.ns[ne]})});for(var re=0,he=D.attribList.length;re<he;re++){var O=D.attribList[re],ae=O[0],q=O[1],I=H(ae,!0),T=I.prefix,$=I.local,se=T===""?"":J.ns[T]||"",ue={name:ae,value:q,prefix:T,local:$,uri:se};T&&T!=="xmlns"&&!se&&(G(D,"Unbound namespace prefix: "+JSON.stringify(T)),ue.uri=T),D.tag.attributes[ae]=ue,P(D,"onattribute",ue)}D.attribList.length=0}D.tag.isSelfClosing=!!R,D.sawRoot=!0,D.tags.push(D.tag),P(D,"onopentag",D.tag),R||(!D.noscript&&D.tagName.toLowerCase()==="script"?D.state=A.SCRIPT:D.state=A.TEXT,D.tag=null,D.tagName=""),D.attribName=D.attribValue="",D.attribList.length=0}function F(D){if(!D.tagName){G(D,"Weird empty close tag."),D.textNode+="</>",D.state=A.TEXT;return}if(D.script){if(D.tagName!=="script"){D.script+="</"+D.tagName+">",D.tagName="",D.state=A.SCRIPT;return}P(D,"onscript",D.script),D.script=""}var R=D.tags.length,J=D.tagName;D.strict||(J=J[D.looseCase]());for(var Z=J;R--;){var ee=D.tags[R];if(ee.name!==Z)G(D,"Unexpected close tag");else break}if(R<0){G(D,"Unmatched closing tag: "+D.tagName),D.textNode+="</"+D.tagName+">",D.state=A.TEXT;return}D.tagName=J;for(var re=D.tags.length;re-- >R;){var he=D.tag=D.tags.pop();D.tagName=D.tag.name,P(D,"onclosetag",D.tagName);var O={};for(var ae in he.ns)O[ae]=he.ns[ae];var q=D.tags[D.tags.length-1]||D;D.opt.xmlns&&he.ns!==q.ns&&Object.keys(he.ns).forEach(function(I){var T=he.ns[I];P(D,"onclosenamespace",{prefix:I,uri:T})})}R===0&&(D.closedRoot=!0),D.tagName=D.attribValue=D.attribName="",D.attribList.length=0,D.state=A.TEXT}function V(D){var R=D.entity,J=R.toLowerCase(),Z,ee="";return D.ENTITIES[R]?D.ENTITIES[R]:D.ENTITIES[J]?D.ENTITIES[J]:(R=J,R.charAt(0)==="#"&&(R.charAt(1)==="x"?(R=R.slice(2),Z=parseInt(R,16),ee=Z.toString(16)):(R=R.slice(1),Z=parseInt(R,10),ee=Z.toString(10))),R=R.replace(/^0+/,""),isNaN(Z)||ee.toLowerCase()!==R?(G(D,"Invalid character entity"),"&"+D.entity+";"):String.fromCodePoint(Z))}function Y(D,R){R==="<"?(D.state=A.OPEN_WAKA,D.startTagPosition=D.position):w(R)||(G(D,"Non-whitespace before first tag."),D.textNode=R,D.state=A.TEXT)}function ie(D,R){var J="";return R<D.length&&(J=D.charAt(R)),J}function Q(D){var R=this;if(this.error)throw this.error;if(R.closed)return U(R,"Cannot write after close. Assign an onready handler.");if(D===null)return K(R);typeof D=="object"&&(D=D.toString());for(var J=0,Z="";Z=ie(D,J++),R.c=Z,!!Z;)switch(R.trackPosition&&(R.position++,Z===`
`?(R.line++,R.column=0):R.column++),R.state){case A.BEGIN:if(R.state=A.BEGIN_WHITESPACE,Z==="\uFEFF")continue;Y(R,Z);continue;case A.BEGIN_WHITESPACE:Y(R,Z);continue;case A.TEXT:if(R.sawRoot&&!R.closedRoot){for(var ee=J-1;Z&&Z!=="<"&&Z!=="&";)Z=ie(D,J++),Z&&R.trackPosition&&(R.position++,Z===`
`?(R.line++,R.column=0):R.column++);R.textNode+=D.substring(ee,J-1)}Z==="<"&&!(R.sawRoot&&R.closedRoot&&!R.strict)?(R.state=A.OPEN_WAKA,R.startTagPosition=R.position):(!w(Z)&&(!R.sawRoot||R.closedRoot)&&G(R,"Text data outside of root node."),Z==="&"?R.state=A.TEXT_ENTITY:R.textNode+=Z);continue;case A.SCRIPT:Z==="<"?R.state=A.SCRIPT_ENDING:R.script+=Z;continue;case A.SCRIPT_ENDING:Z==="/"?R.state=A.CLOSE_TAG:(R.script+="<"+Z,R.state=A.SCRIPT);continue;case A.OPEN_WAKA:if(Z==="!")R.state=A.SGML_DECL,R.sgmlDecl="";else if(!w(Z))if(E(x,Z))R.state=A.OPEN_TAG,R.tagName=Z;else if(Z==="/")R.state=A.CLOSE_TAG,R.tagName="";else if(Z==="?")R.state=A.PROC_INST,R.procInstName=R.procInstBody="";else{if(G(R,"Unencoded <"),R.startTagPosition+1<R.position){var re=R.position-R.startTagPosition;Z=new Array(re).join(" ")+Z}R.textNode+="<"+Z,R.state=A.TEXT}continue;case A.SGML_DECL:(R.sgmlDecl+Z).toUpperCase()===h?(P(R,"onopencdata"),R.state=A.CDATA,R.sgmlDecl="",R.cdata=""):R.sgmlDecl+Z==="--"?(R.state=A.COMMENT,R.comment="",R.sgmlDecl=""):(R.sgmlDecl+Z).toUpperCase()===f?(R.state=A.DOCTYPE,(R.doctype||R.sawRoot)&&G(R,"Inappropriately located doctype declaration"),R.doctype="",R.sgmlDecl=""):Z===">"?(P(R,"onsgmldeclaration",R.sgmlDecl),R.sgmlDecl="",R.state=A.TEXT):(S(Z)&&(R.state=A.SGML_DECL_QUOTED),R.sgmlDecl+=Z);continue;case A.SGML_DECL_QUOTED:Z===R.q&&(R.state=A.SGML_DECL,R.q=""),R.sgmlDecl+=Z;continue;case A.DOCTYPE:Z===">"?(R.state=A.TEXT,P(R,"ondoctype",R.doctype),R.doctype=!0):(R.doctype+=Z,Z==="["?R.state=A.DOCTYPE_DTD:S(Z)&&(R.state=A.DOCTYPE_QUOTED,R.q=Z));continue;case A.DOCTYPE_QUOTED:R.doctype+=Z,Z===R.q&&(R.q="",R.state=A.DOCTYPE);continue;case A.DOCTYPE_DTD:R.doctype+=Z,Z==="]"?R.state=A.DOCTYPE:S(Z)&&(R.state=A.DOCTYPE_DTD_QUOTED,R.q=Z);continue;case A.DOCTYPE_DTD_QUOTED:R.doctype+=Z,Z===R.q&&(R.state=A.DOCTYPE_DTD,R.q="");continue;case A.COMMENT:Z==="-"?R.state=A.COMMENT_ENDING:R.comment+=Z;continue;case A.COMMENT_ENDING:Z==="-"?(R.state=A.COMMENT_ENDED,R.comment=N(R.opt,R.comment),R.comment&&P(R,"oncomment",R.comment),R.comment=""):(R.comment+="-"+Z,R.state=A.COMMENT);continue;case A.COMMENT_ENDED:Z!==">"?(G(R,"Malformed comment"),R.comment+="--"+Z,R.state=A.COMMENT):R.state=A.TEXT;continue;case A.CDATA:Z==="]"?R.state=A.CDATA_ENDING:R.cdata+=Z;continue;case A.CDATA_ENDING:Z==="]"?R.state=A.CDATA_ENDING_2:(R.cdata+="]"+Z,R.state=A.CDATA);continue;case A.CDATA_ENDING_2:Z===">"?(R.cdata&&P(R,"oncdata",R.cdata),P(R,"onclosecdata"),R.cdata="",R.state=A.TEXT):Z==="]"?R.cdata+="]":(R.cdata+="]]"+Z,R.state=A.CDATA);continue;case A.PROC_INST:Z==="?"?R.state=A.PROC_INST_ENDING:w(Z)?R.state=A.PROC_INST_BODY:R.procInstName+=Z;continue;case A.PROC_INST_BODY:if(!R.procInstBody&&w(Z))continue;Z==="?"?R.state=A.PROC_INST_ENDING:R.procInstBody+=Z;continue;case A.PROC_INST_ENDING:Z===">"?(P(R,"onprocessinginstruction",{name:R.procInstName,body:R.procInstBody}),R.procInstName=R.procInstBody="",R.state=A.TEXT):(R.procInstBody+="?"+Z,R.state=A.PROC_INST_BODY);continue;case A.OPEN_TAG:E(y,Z)?R.tagName+=Z:(X(R),Z===">"?L(R):Z==="/"?R.state=A.OPEN_TAG_SLASH:(w(Z)||G(R,"Invalid character in tag name"),R.state=A.ATTRIB));continue;case A.OPEN_TAG_SLASH:Z===">"?(L(R,!0),F(R)):(G(R,"Forward-slash in opening tag not followed by >"),R.state=A.ATTRIB);continue;case A.ATTRIB:if(w(Z))continue;Z===">"?L(R):Z==="/"?R.state=A.OPEN_TAG_SLASH:E(x,Z)?(R.attribName=Z,R.attribValue="",R.state=A.ATTRIB_NAME):G(R,"Invalid attribute name");continue;case A.ATTRIB_NAME:Z==="="?R.state=A.ATTRIB_VALUE:Z===">"?(G(R,"Attribute without value"),R.attribValue=R.attribName,B(R),L(R)):w(Z)?R.state=A.ATTRIB_NAME_SAW_WHITE:E(y,Z)?R.attribName+=Z:G(R,"Invalid attribute name");continue;case A.ATTRIB_NAME_SAW_WHITE:if(Z==="=")R.state=A.ATTRIB_VALUE;else{if(w(Z))continue;G(R,"Attribute without value"),R.tag.attributes[R.attribName]="",R.attribValue="",P(R,"onattribute",{name:R.attribName,value:""}),R.attribName="",Z===">"?L(R):E(x,Z)?(R.attribName=Z,R.state=A.ATTRIB_NAME):(G(R,"Invalid attribute name"),R.state=A.ATTRIB)}continue;case A.ATTRIB_VALUE:if(w(Z))continue;S(Z)?(R.q=Z,R.state=A.ATTRIB_VALUE_QUOTED):(G(R,"Unquoted attribute value"),R.state=A.ATTRIB_VALUE_UNQUOTED,R.attribValue=Z);continue;case A.ATTRIB_VALUE_QUOTED:if(Z!==R.q){Z==="&"?R.state=A.ATTRIB_VALUE_ENTITY_Q:R.attribValue+=Z;continue}B(R),R.q="",R.state=A.ATTRIB_VALUE_CLOSED;continue;case A.ATTRIB_VALUE_CLOSED:w(Z)?R.state=A.ATTRIB:Z===">"?L(R):Z==="/"?R.state=A.OPEN_TAG_SLASH:E(x,Z)?(G(R,"No whitespace between attributes"),R.attribName=Z,R.attribValue="",R.state=A.ATTRIB_NAME):G(R,"Invalid attribute name");continue;case A.ATTRIB_VALUE_UNQUOTED:if(!k(Z)){Z==="&"?R.state=A.ATTRIB_VALUE_ENTITY_U:R.attribValue+=Z;continue}B(R),Z===">"?L(R):R.state=A.ATTRIB;continue;case A.CLOSE_TAG:if(R.tagName)Z===">"?F(R):E(y,Z)?R.tagName+=Z:R.script?(R.script+="</"+R.tagName,R.tagName="",R.state=A.SCRIPT):(w(Z)||G(R,"Invalid tagname in closing tag"),R.state=A.CLOSE_TAG_SAW_WHITE);else{if(w(Z))continue;C(x,Z)?R.script?(R.script+="</"+Z,R.state=A.SCRIPT):G(R,"Invalid tagname in closing tag."):R.tagName=Z}continue;case A.CLOSE_TAG_SAW_WHITE:if(w(Z))continue;Z===">"?F(R):G(R,"Invalid characters in closing tag");continue;case A.TEXT_ENTITY:case A.ATTRIB_VALUE_ENTITY_Q:case A.ATTRIB_VALUE_ENTITY_U:var he,O;switch(R.state){case A.TEXT_ENTITY:he=A.TEXT,O="textNode";break;case A.ATTRIB_VALUE_ENTITY_Q:he=A.ATTRIB_VALUE_QUOTED,O="attribValue";break;case A.ATTRIB_VALUE_ENTITY_U:he=A.ATTRIB_VALUE_UNQUOTED,O="attribValue";break}Z===";"?(R[O]+=V(R),R.entity="",R.state=he):E(R.entity.length?b:v,Z)?R.entity+=Z:(G(R,"Invalid character in entity name"),R[O]+="&"+R.entity+Z,R.entity="",R.state=he);continue;default:throw new Error(R,"Unknown state: "+R.state)}return R.position>=R.bufferCheckPosition&&s(R),R}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var D=String.fromCharCode,R=Math.floor,J=function(){var Z=16384,ee=[],re,he,O=-1,ae=arguments.length;if(!ae)return"";for(var q="";++O<ae;){var I=Number(arguments[O]);if(!isFinite(I)||I<0||I>1114111||R(I)!==I)throw RangeError("Invalid code point: "+I);I<=65535?ee.push(I):(I-=65536,re=(I>>10)+55296,he=I%1024+56320,ee.push(re,he)),(O+1===ae||ee.length>Z)&&(q+=D.apply(null,ee),ee.length=0)}return q};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:J,configurable:!0,writable:!0}):String.fromCodePoint=J}()})(t)}(J4)),J4}var f3,Mne;function m7(){return Mne||(Mne=1,f3={isArray:function(t){return Array.isArray?Array.isArray(t):Object.prototype.toString.call(t)==="[object Array]"}}),f3}var p3,Dne;function g7(){if(Dne)return p3;Dne=1;var t=m7().isArray;return p3={copyOptions:function(e){var r,n={};for(r in e)e.hasOwnProperty(r)&&(n[r]=e[r]);return n},ensureFlagExists:function(e,r){(!(e in r)||typeof r[e]!="boolean")&&(r[e]=!1)},ensureSpacesExists:function(e){(!("spaces"in e)||typeof e.spaces!="number"&&typeof e.spaces!="string")&&(e.spaces=0)},ensureAlwaysArrayExists:function(e){(!("alwaysArray"in e)||typeof e.alwaysArray!="boolean"&&!t(e.alwaysArray))&&(e.alwaysArray=!1)},ensureKeyExists:function(e,r){(!(e+"Key"in r)||typeof r[e+"Key"]!="string")&&(r[e+"Key"]=r.compact?"_"+e:e)},checkFnExists:function(e,r){return e+"Fn"in r}},p3}var m3,Lne;function $Se(){if(Lne)return m3;Lne=1;var t=pNt(),e=g7(),r=m7().isArray,n,s;function i(y){return n=e.copyOptions(y),e.ensureFlagExists("ignoreDeclaration",n),e.ensureFlagExists("ignoreInstruction",n),e.ensureFlagExists("ignoreAttributes",n),e.ensureFlagExists("ignoreText",n),e.ensureFlagExists("ignoreComment",n),e.ensureFlagExists("ignoreCdata",n),e.ensureFlagExists("ignoreDoctype",n),e.ensureFlagExists("compact",n),e.ensureFlagExists("alwaysChildren",n),e.ensureFlagExists("addParent",n),e.ensureFlagExists("trim",n),e.ensureFlagExists("nativeType",n),e.ensureFlagExists("nativeTypeAttributes",n),e.ensureFlagExists("sanitize",n),e.ensureFlagExists("instructionHasAttributes",n),e.ensureFlagExists("captureSpacesBetweenElements",n),e.ensureAlwaysArrayExists(n),e.ensureKeyExists("declaration",n),e.ensureKeyExists("instruction",n),e.ensureKeyExists("attributes",n),e.ensureKeyExists("text",n),e.ensureKeyExists("comment",n),e.ensureKeyExists("cdata",n),e.ensureKeyExists("doctype",n),e.ensureKeyExists("type",n),e.ensureKeyExists("name",n),e.ensureKeyExists("elements",n),e.ensureKeyExists("parent",n),e.checkFnExists("doctype",n),e.checkFnExists("instruction",n),e.checkFnExists("cdata",n),e.checkFnExists("comment",n),e.checkFnExists("text",n),e.checkFnExists("instructionName",n),e.checkFnExists("elementName",n),e.checkFnExists("attributeName",n),e.checkFnExists("attributeValue",n),e.checkFnExists("attributes",n),n}function a(y){var v=Number(y);if(!isNaN(v))return v;var b=y.toLowerCase();return b==="true"?!0:b==="false"?!1:y}function o(y,v){var b;if(n.compact){if(!s[n[y+"Key"]]&&(r(n.alwaysArray)?n.alwaysArray.indexOf(n[y+"Key"])!==-1:n.alwaysArray)&&(s[n[y+"Key"]]=[]),s[n[y+"Key"]]&&!r(s[n[y+"Key"]])&&(s[n[y+"Key"]]=[s[n[y+"Key"]]]),y+"Fn"in n&&typeof v=="string"&&(v=n[y+"Fn"](v,s)),y==="instruction"&&("instructionFn"in n||"instructionNameFn"in n)){for(b in v)if(v.hasOwnProperty(b))if("instructionFn"in n)v[b]=n.instructionFn(v[b],b,s);else{var w=v[b];delete v[b],v[n.instructionNameFn(b,w,s)]=w}}r(s[n[y+"Key"]])?s[n[y+"Key"]].push(v):s[n[y+"Key"]]=v}else{s[n.elementsKey]||(s[n.elementsKey]=[]);var S={};if(S[n.typeKey]=y,y==="instruction"){for(b in v)if(v.hasOwnProperty(b))break;S[n.nameKey]="instructionNameFn"in n?n.instructionNameFn(b,v,s):b,n.instructionHasAttributes?(S[n.attributesKey]=v[b][n.attributesKey],"instructionFn"in n&&(S[n.attributesKey]=n.instructionFn(S[n.attributesKey],b,s))):("instructionFn"in n&&(v[b]=n.instructionFn(v[b],b,s)),S[n.instructionKey]=v[b])}else y+"Fn"in n&&(v=n[y+"Fn"](v,s)),S[n[y+"Key"]]=v;n.addParent&&(S[n.parentKey]=s),s[n.elementsKey].push(S)}}function c(y){if("attributesFn"in n&&y&&(y=n.attributesFn(y,s)),(n.trim||"attributeValueFn"in n||"attributeNameFn"in n||n.nativeTypeAttributes)&&y){var v;for(v in y)if(y.hasOwnProperty(v)&&(n.trim&&(y[v]=y[v].trim()),n.nativeTypeAttributes&&(y[v]=a(y[v])),"attributeValueFn"in n&&(y[v]=n.attributeValueFn(y[v],v,s)),"attributeNameFn"in n)){var b=y[v];delete y[v],y[n.attributeNameFn(v,y[v],s)]=b}}return y}function u(y){var v={};if(y.body&&(y.name.toLowerCase()==="xml"||n.instructionHasAttributes)){for(var b=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,w;(w=b.exec(y.body))!==null;)v[w[1]]=w[2]||w[3]||w[4];v=c(v)}if(y.name.toLowerCase()==="xml"){if(n.ignoreDeclaration)return;s[n.declarationKey]={},Object.keys(v).length&&(s[n.declarationKey][n.attributesKey]=v),n.addParent&&(s[n.declarationKey][n.parentKey]=s)}else{if(n.ignoreInstruction)return;n.trim&&(y.body=y.body.trim());var S={};n.instructionHasAttributes&&Object.keys(v).length?(S[y.name]={},S[y.name][n.attributesKey]=v):S[y.name]=y.body,o("instruction",S)}}function d(y,v){var b;if(typeof y=="object"&&(v=y.attributes,y=y.name),v=c(v),"elementNameFn"in n&&(y=n.elementNameFn(y,s)),n.compact){if(b={},!n.ignoreAttributes&&v&&Object.keys(v).length){b[n.attributesKey]={};var w;for(w in v)v.hasOwnProperty(w)&&(b[n.attributesKey][w]=v[w])}!(y in s)&&(r(n.alwaysArray)?n.alwaysArray.indexOf(y)!==-1:n.alwaysArray)&&(s[y]=[]),s[y]&&!r(s[y])&&(s[y]=[s[y]]),r(s[y])?s[y].push(b):s[y]=b}else s[n.elementsKey]||(s[n.elementsKey]=[]),b={},b[n.typeKey]="element",b[n.nameKey]=y,!n.ignoreAttributes&&v&&Object.keys(v).length&&(b[n.attributesKey]=v),n.alwaysChildren&&(b[n.elementsKey]=[]),s[n.elementsKey].push(b);b[n.parentKey]=s,s=b}function h(y){n.ignoreText||!y.trim()&&!n.captureSpacesBetweenElements||(n.trim&&(y=y.trim()),n.nativeType&&(y=a(y)),n.sanitize&&(y=y.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),o("text",y))}function f(y){n.ignoreComment||(n.trim&&(y=y.trim()),o("comment",y))}function p(y){var v=s[n.parentKey];n.addParent||delete s[n.parentKey],s=v}function m(y){n.ignoreCdata||(n.trim&&(y=y.trim()),o("cdata",y))}function g(y){n.ignoreDoctype||(y=y.replace(/^ /,""),n.trim&&(y=y.trim()),o("doctype",y))}function x(y){y.note=y}return m3=function(y,v){var b=t.parser(!0,{}),w={};if(s=w,n=i(v),b.opt={strictEntities:!0},b.onopentag=d,b.ontext=h,b.oncomment=f,b.onclosetag=p,b.onerror=x,b.oncdata=m,b.ondoctype=g,b.onprocessinginstruction=u,b.write(y).close(),w[n.elementsKey]){var S=w[n.elementsKey];delete w[n.elementsKey],w[n.elementsKey]=S,delete w.text}return w},m3}var g3,Fne;function mNt(){if(Fne)return g3;Fne=1;var t=g7(),e=$Se();function r(n){var s=t.copyOptions(n);return t.ensureSpacesExists(s),s}return g3=function(n,s){var i,a,o,c;return i=r(s),a=e(n,i),c="compact"in i&&i.compact?"_parent":"parent","addParent"in i&&i.addParent?o=JSON.stringify(a,function(u,d){return u===c?"_":d},i.spaces):o=JSON.stringify(a,null,i.spaces),o.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},g3}var y3,$ne;function BSe(){if($ne)return y3;$ne=1;var t=g7(),e=m7().isArray,r,n;function s(b){var w=t.copyOptions(b);return t.ensureFlagExists("ignoreDeclaration",w),t.ensureFlagExists("ignoreInstruction",w),t.ensureFlagExists("ignoreAttributes",w),t.ensureFlagExists("ignoreText",w),t.ensureFlagExists("ignoreComment",w),t.ensureFlagExists("ignoreCdata",w),t.ensureFlagExists("ignoreDoctype",w),t.ensureFlagExists("compact",w),t.ensureFlagExists("indentText",w),t.ensureFlagExists("indentCdata",w),t.ensureFlagExists("indentAttributes",w),t.ensureFlagExists("indentInstruction",w),t.ensureFlagExists("fullTagEmptyElement",w),t.ensureFlagExists("noQuotesForNativeAttributes",w),t.ensureSpacesExists(w),typeof w.spaces=="number"&&(w.spaces=Array(w.spaces+1).join(" ")),t.ensureKeyExists("declaration",w),t.ensureKeyExists("instruction",w),t.ensureKeyExists("attributes",w),t.ensureKeyExists("text",w),t.ensureKeyExists("comment",w),t.ensureKeyExists("cdata",w),t.ensureKeyExists("doctype",w),t.ensureKeyExists("type",w),t.ensureKeyExists("name",w),t.ensureKeyExists("elements",w),t.checkFnExists("doctype",w),t.checkFnExists("instruction",w),t.checkFnExists("cdata",w),t.checkFnExists("comment",w),t.checkFnExists("text",w),t.checkFnExists("instructionName",w),t.checkFnExists("elementName",w),t.checkFnExists("attributeName",w),t.checkFnExists("attributeValue",w),t.checkFnExists("attributes",w),t.checkFnExists("fullTagEmptyElement",w),w}function i(b,w,S){return(!S&&b.spaces?`
`:"")+Array(w+1).join(b.spaces)}function a(b,w,S){if(w.ignoreAttributes)return"";"attributesFn"in w&&(b=w.attributesFn(b,n,r));var k,E,C,A,M=[];for(k in b)b.hasOwnProperty(k)&&b[k]!==null&&b[k]!==void 0&&(A=w.noQuotesForNativeAttributes&&typeof b[k]!="string"?"":'"',E=""+b[k],E=E.replace(/"/g,"""),C="attributeNameFn"in w?w.attributeNameFn(k,E,n,r):k,M.push(w.spaces&&w.indentAttributes?i(w,S+1,!1):" "),M.push(C+"="+A+("attributeValueFn"in w?w.attributeValueFn(E,k,n,r):E)+A));return b&&Object.keys(b).length&&w.spaces&&w.indentAttributes&&M.push(i(w,S,!1)),M.join("")}function o(b,w,S){return r=b,n="xml",w.ignoreDeclaration?"":"<?xml"+a(b[w.attributesKey],w,S)+"?>"}function c(b,w,S){if(w.ignoreInstruction)return"";var k;for(k in b)if(b.hasOwnProperty(k))break;var E="instructionNameFn"in w?w.instructionNameFn(k,b[k],n,r):k;if(typeof b[k]=="object")return r=b,n=E,"<?"+E+a(b[k][w.attributesKey],w,S)+"?>";var C=b[k]?b[k]:"";return"instructionFn"in w&&(C=w.instructionFn(C,k,n,r)),"<?"+E+(C?" "+C:"")+"?>"}function u(b,w){return w.ignoreComment?"":"<!--"+("commentFn"in w?w.commentFn(b,n,r):b)+"-->"}function d(b,w){return w.ignoreCdata?"":"<![CDATA["+("cdataFn"in w?w.cdataFn(b,n,r):b.replace("]]>","]]]]><![CDATA[>"))+"]]>"}function h(b,w){return w.ignoreDoctype?"":"<!DOCTYPE "+("doctypeFn"in w?w.doctypeFn(b,n,r):b)+">"}function f(b,w){return w.ignoreText?"":(b=""+b,b=b.replace(/&/g,"&"),b=b.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),"textFn"in w?w.textFn(b,n,r):b)}function p(b,w){var S;if(b.elements&&b.elements.length)for(S=0;S<b.elements.length;++S)switch(b.elements[S][w.typeKey]){case"text":if(w.indentText)return!0;break;case"cdata":if(w.indentCdata)return!0;break;case"instruction":if(w.indentInstruction)return!0;break;case"doctype":case"comment":case"element":return!0;default:return!0}return!1}function m(b,w,S){r=b,n=b.name;var k=[],E="elementNameFn"in w?w.elementNameFn(b.name,b):b.name;k.push("<"+E),b[w.attributesKey]&&k.push(a(b[w.attributesKey],w,S));var C=b[w.elementsKey]&&b[w.elementsKey].length||b[w.attributesKey]&&b[w.attributesKey]["xml:space"]==="preserve";return C||("fullTagEmptyElementFn"in w?C=w.fullTagEmptyElementFn(b.name,b):C=w.fullTagEmptyElement),C?(k.push(">"),b[w.elementsKey]&&b[w.elementsKey].length&&(k.push(g(b[w.elementsKey],w,S+1)),r=b,n=b.name),k.push(w.spaces&&p(b,w)?`
`+Array(S+1).join(w.spaces):""),k.push("</"+E+">")):k.push("/>"),k.join("")}function g(b,w,S,k){return b.reduce(function(E,C){var A=i(w,S,k&&!E);switch(C.type){case"element":return E+A+m(C,w,S);case"comment":return E+A+u(C[w.commentKey],w);case"doctype":return E+A+h(C[w.doctypeKey],w);case"cdata":return E+(w.indentCdata?A:"")+d(C[w.cdataKey],w);case"text":return E+(w.indentText?A:"")+f(C[w.textKey],w);case"instruction":var M={};return M[C[w.nameKey]]=C[w.attributesKey]?C:C[w.instructionKey],E+(w.indentInstruction?A:"")+c(M,w,S)}},"")}function x(b,w,S){var k;for(k in b)if(b.hasOwnProperty(k))switch(k){case w.parentKey:case w.attributesKey:break;case w.textKey:if(w.indentText||S)return!0;break;case w.cdataKey:if(w.indentCdata||S)return!0;break;case w.instructionKey:if(w.indentInstruction||S)return!0;break;case w.doctypeKey:case w.commentKey:return!0;default:return!0}return!1}function y(b,w,S,k,E){r=b,n=w;var C="elementNameFn"in S?S.elementNameFn(w,b):w;if(typeof b>"u"||b===null||b==="")return"fullTagEmptyElementFn"in S&&S.fullTagEmptyElementFn(w,b)||S.fullTagEmptyElement?"<"+C+"></"+C+">":"<"+C+"/>";var A=[];if(w){if(A.push("<"+C),typeof b!="object")return A.push(">"+f(b,S)+"</"+C+">"),A.join("");b[S.attributesKey]&&A.push(a(b[S.attributesKey],S,k));var M=x(b,S,!0)||b[S.attributesKey]&&b[S.attributesKey]["xml:space"]==="preserve";if(M||("fullTagEmptyElementFn"in S?M=S.fullTagEmptyElementFn(w,b):M=S.fullTagEmptyElement),M)A.push(">");else return A.push("/>"),A.join("")}return A.push(v(b,S,k+1,!1)),r=b,n=w,w&&A.push((E?i(S,k,!1):"")+"</"+C+">"),A.join("")}function v(b,w,S,k){var E,C,A,M=[];for(C in b)if(b.hasOwnProperty(C))for(A=e(b[C])?b[C]:[b[C]],E=0;E<A.length;++E){switch(C){case w.declarationKey:M.push(o(A[E],w,S));break;case w.instructionKey:M.push((w.indentInstruction?i(w,S,k):"")+c(A[E],w,S));break;case w.attributesKey:case w.parentKey:break;case w.textKey:M.push((w.indentText?i(w,S,k):"")+f(A[E],w));break;case w.cdataKey:M.push((w.indentCdata?i(w,S,k):"")+d(A[E],w));break;case w.doctypeKey:M.push(i(w,S,k)+h(A[E],w));break;case w.commentKey:M.push(i(w,S,k)+u(A[E],w));break;default:M.push(i(w,S,k)+y(A[E],C,w,S,x(A[E],w)))}k=k&&!M.length}return M.join("")}return y3=function(b,w){w=s(w);var S=[];return r=b,n="_root_",w.compact?S.push(v(b,w,0,!0)):(b[w.declarationKey]&&S.push(o(b[w.declarationKey],w,0)),b[w.elementsKey]&&b[w.elementsKey].length&&S.push(g(b[w.elementsKey],w,0,!S.length))),S.join("")},y3}var x3,Bne;function gNt(){if(Bne)return x3;Bne=1;var t=BSe();return x3=function(e,r){e instanceof Buffer&&(e=e.toString());var n=null;if(typeof e=="string")try{n=JSON.parse(e)}catch{throw new Error("The JSON structure is invalid")}else n=e;return t(n,r)},x3}var v3,zne;function yNt(){if(zne)return v3;zne=1;var t=$Se(),e=mNt(),r=BSe(),n=gNt();return v3={xml2js:t,xml2json:e,js2xml:r,json2xml:n},v3}var zSe=yNt();const y7=t=>{switch(t.type){case void 0:case"element":const e=new vNt(t.name,t.attributes),r=t.elements||[];for(const n of r){const s=y7(n);s!==void 0&&e.push(s)}return e;case"text":return t.text;default:return}};class xNt extends Rt{}class vNt extends $e{static fromXmlString(e){const r=zSe.xml2js(e,{compact:!1});return y7(r)}constructor(e,r){super(e),r&&this.root.push(new xNt(r))}push(e){this.root.push(e)}}class bNt extends $e{constructor(e){super(""),this._attr=e}prepForXml(e){return{_attr:this._attr}}}class USe extends $e{constructor(e,r){super(e),r&&(this.root=r.root)}}const Ja=t=>{if(isNaN(t))throw new Error(`Invalid value '${t}' specified. Must be an integer.`);return Math.floor(t)},aD=t=>{const e=Ja(t);if(e<0)throw new Error(`Invalid value '${t}' specified. Must be a positive integer.`);return e},HSe=(t,e)=>{const r=e*2;if(t.length!==r||isNaN(+`0x${t}`))throw new Error(`Invalid hex value '${t}'. Expected ${r} digit hex value`);return t},Une=t=>HSe(t,1),VSe=t=>{const e=t.slice(-2),r=t.substring(0,t.length-2);return`${Number(r)}${e}`},WSe=t=>{const e=VSe(t);if(parseFloat(e)<0)throw new Error(`Invalid value '${e}' specified. Expected a positive number.`);return e},_w=t=>{if(t==="auto")return t;const e=t.charAt(0)==="#"?t.substring(1):t;return HSe(e,3)},ag=t=>typeof t=="string"?VSe(t):Ja(t),wNt=t=>typeof t=="string"?WSe(t):aD(t),oc=t=>typeof t=="string"?WSe(t):aD(t),SNt=aD,_Nt=aD,jNt=t=>t.toISOString();class He extends $e{constructor(e,r=!0){super(e),r!==!0&&this.root.push(new Gn({val:r}))}}class b3 extends $e{constructor(e,r){super(e),this.root.push(new Gn({val:wNt(r)}))}}class My extends $e{constructor(e,r){super(e),this.root.push(new Gn({val:r}))}}const X1=(t,e)=>new Tu({name:t,attributes:{value:{key:"w:val",value:e}}});class N_ extends $e{constructor(e,r){super(e),this.root.push(new Gn({val:r}))}}class Am extends $e{constructor(e,r){super(e),this.root.push(r)}}class Tu extends $e{constructor({name:e,attributes:r,children:n}){super(e),r&&this.root.push(new nD(r)),n&&this.root.push(...n)}}const Xn={START:"start",CENTER:"center",END:"end",BOTH:"both",MEDIUM_KASHIDA:"mediumKashida",DISTRIBUTE:"distribute",NUM_TAB:"numTab",HIGH_KASHIDA:"highKashida",LOW_KASHIDA:"lowKashida",THAI_DISTRIBUTE:"thaiDistribute",LEFT:"left",RIGHT:"right",JUSTIFIED:"both"};class kNt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{val:"w:val"})}}class NNt extends $e{constructor(e){super("w:jc"),this.root.push(new kNt({val:e}))}}class Ln extends $e{constructor(e,{color:r,size:n,space:s,style:i}){super(e),this.root.push(new ENt({style:i,color:r===void 0?void 0:_w(r),size:n===void 0?void 0:SNt(n),space:s===void 0?void 0:_Nt(s)}))}}class ENt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{style:"w:val",color:"w:color",size:"w:sz",space:"w:space"})}}const x7={SINGLE:"single",DASH_DOT_STROKED:"dashDotStroked",DASHED:"dashed",DASH_SMALL_GAP:"dashSmallGap",DOT_DASH:"dotDash",DOT_DOT_DASH:"dotDotDash",DOTTED:"dotted",DOUBLE:"double",DOUBLE_WAVE:"doubleWave",INSET:"inset",NIL:"nil",NONE:"none",OUTSET:"outset",THICK:"thick",THICK_THIN_LARGE_GAP:"thickThinLargeGap",THICK_THIN_MEDIUM_GAP:"thickThinMediumGap",THICK_THIN_SMALL_GAP:"thickThinSmallGap",THIN_THICK_LARGE_GAP:"thinThickLargeGap",THIN_THICK_MEDIUM_GAP:"thinThickMediumGap",THIN_THICK_SMALL_GAP:"thinThickSmallGap",THIN_THICK_THIN_LARGE_GAP:"thinThickThinLargeGap",THIN_THICK_THIN_MEDIUM_GAP:"thinThickThinMediumGap",THIN_THICK_THIN_SMALL_GAP:"thinThickThinSmallGap",THREE_D_EMBOSS:"threeDEmboss",THREE_D_ENGRAVE:"threeDEngrave",TRIPLE:"triple",WAVE:"wave"};class ANt extends rD{constructor(e){super("w:pBdr"),e.top&&this.root.push(new Ln("w:top",e.top)),e.bottom&&this.root.push(new Ln("w:bottom",e.bottom)),e.left&&this.root.push(new Ln("w:left",e.left)),e.right&&this.root.push(new Ln("w:right",e.right))}}class CNt extends $e{constructor(){super("w:pBdr");const e=new Ln("w:bottom",{color:"auto",space:1,style:x7.SINGLE,size:6});this.root.push(e)}}class TNt extends $e{constructor({start:e,end:r,left:n,right:s,hanging:i,firstLine:a}){super("w:ind"),this.root.push(new nD({start:{key:"w:start",value:e===void 0?void 0:ag(e)},end:{key:"w:end",value:r===void 0?void 0:ag(r)},left:{key:"w:left",value:n===void 0?void 0:ag(n)},right:{key:"w:right",value:s===void 0?void 0:ag(s)},hanging:{key:"w:hanging",value:i===void 0?void 0:oc(i)},firstLine:{key:"w:firstLine",value:a===void 0?void 0:oc(a)}}))}}let PNt=class extends $e{constructor(){super("w:br")}};const v7={BEGIN:"begin",END:"end",SEPARATE:"separate"};class b7 extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{type:"w:fldCharType",dirty:"w:dirty"})}}class MS extends $e{constructor(e){super("w:fldChar"),this.root.push(new b7({type:v7.BEGIN,dirty:e}))}}class DS extends $e{constructor(e){super("w:fldChar"),this.root.push(new b7({type:v7.SEPARATE,dirty:e}))}}class LS extends $e{constructor(e){super("w:fldChar"),this.root.push(new b7({type:v7.END,dirty:e}))}}const ONt={DECIMAL:"decimal",UPPER_ROMAN:"upperRoman",LOWER_ROMAN:"lowerRoman",UPPER_LETTER:"upperLetter",LOWER_LETTER:"lowerLetter",ORDINAL:"ordinal",CARDINAL_TEXT:"cardinalText",ORDINAL_TEXT:"ordinalText",HEX:"hex",CHICAGO:"chicago",IDEOGRAPH_DIGITAL:"ideographDigital",JAPANESE_COUNTING:"japaneseCounting",AIUEO:"aiueo",IROHA:"iroha",DECIMAL_FULL_WIDTH:"decimalFullWidth",DECIMAL_HALF_WIDTH:"decimalHalfWidth",JAPANESE_LEGAL:"japaneseLegal",JAPANESE_DIGITAL_TEN_THOUSAND:"japaneseDigitalTenThousand",DECIMAL_ENCLOSED_CIRCLE:"decimalEnclosedCircle",DECIMAL_FULL_WIDTH_2:"decimalFullWidth2",AIUEO_FULL_WIDTH:"aiueoFullWidth",IROHA_FULL_WIDTH:"irohaFullWidth",DECIMAL_ZERO:"decimalZero",BULLET:"bullet",GANADA:"ganada",CHOSUNG:"chosung",DECIMAL_ENCLOSED_FULL_STOP:"decimalEnclosedFullstop",DECIMAL_ENCLOSED_PAREN:"decimalEnclosedParen",DECIMAL_ENCLOSED_CIRCLE_CHINESE:"decimalEnclosedCircleChinese",IDEOGRAPH_ENCLOSED_CIRCLE:"ideographEnclosedCircle",IDEOGRAPH_TRADITIONAL:"ideographTraditional",IDEOGRAPH_ZODIAC:"ideographZodiac",IDEOGRAPH_ZODIAC_TRADITIONAL:"ideographZodiacTraditional",TAIWANESE_COUNTING:"taiwaneseCounting",IDEOGRAPH_LEGAL_TRADITIONAL:"ideographLegalTraditional",TAIWANESE_COUNTING_THOUSAND:"taiwaneseCountingThousand",TAIWANESE_DIGITAL:"taiwaneseDigital",CHINESE_COUNTING:"chineseCounting",CHINESE_LEGAL_SIMPLIFIED:"chineseLegalSimplified",CHINESE_COUNTING_TEN_THOUSAND:"chineseCountingThousand",KOREAN_DIGITAL:"koreanDigital",KOREAN_COUNTING:"koreanCounting",KOREAN_LEGAL:"koreanLegal",KOREAN_DIGITAL_2:"koreanDigital2",VIETNAMESE_COUNTING:"vietnameseCounting",RUSSIAN_LOWER:"russianLower",RUSSIAN_UPPER:"russianUpper",NONE:"none",NUMBER_IN_DASH:"numberInDash",HEBREW_1:"hebrew1",HEBREW_2:"hebrew2",ARABIC_ALPHA:"arabicAlpha",ARABIC_ABJAD:"arabicAbjad",HINDI_VOWELS:"hindiVowels",HINDI_CONSONANTS:"hindiConsonants",HINDI_NUMBERS:"hindiNumbers",HINDI_COUNTING:"hindiCounting",THAI_LETTERS:"thaiLetters",THAI_NUMBERS:"thaiNumbers",THAI_COUNTING:"thaiCounting",BAHT_TEXT:"bahtText",DOLLAR_TEXT:"dollarText"},ix={DEFAULT:"default",PRESERVE:"preserve"};class ax extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{space:"xml:space"})}}class INt extends $e{constructor(){super("w:instrText"),this.root.push(new ax({space:ix.PRESERVE})),this.root.push("PAGE")}}class RNt extends $e{constructor(){super("w:instrText"),this.root.push(new ax({space:ix.PRESERVE})),this.root.push("NUMPAGES")}}class MNt extends $e{constructor(){super("w:instrText"),this.root.push(new ax({space:ix.PRESERVE})),this.root.push("SECTIONPAGES")}}class DNt extends $e{constructor(){super("w:instrText"),this.root.push(new ax({space:ix.PRESERVE})),this.root.push("SECTION")}}class LNt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{fill:"w:fill",color:"w:color",type:"w:val"})}}class qSe extends $e{constructor({fill:e,color:r,type:n}){super("w:shd"),this.root.push(new LNt({fill:e===void 0?void 0:_w(e),color:r===void 0?void 0:_w(r),type:n}))}}class FNt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{id:"w:id",author:"w:author",date:"w:date"})}}const $Nt={DOT:"dot"};class BNt extends $e{constructor(e){super("w:em"),this.root.push(new Gn({val:e}))}}class zNt extends BNt{constructor(e=$Nt.DOT){super(e)}}class UNt extends $e{constructor(e){super("w:spacing"),this.root.push(new Gn({val:ag(e)}))}}class HNt extends $e{constructor(e){super("w:color"),this.root.push(new Gn({val:_w(e)}))}}class VNt extends $e{constructor(e){super("w:highlight"),this.root.push(new Gn({val:e}))}}class WNt extends $e{constructor(e){super("w:highlightCs"),this.root.push(new Gn({val:e}))}}const qNt=t=>new Tu({name:"w:lang",attributes:{value:{key:"w:val",value:t.value},eastAsia:{key:"w:eastAsia",value:t.eastAsia},bidirectional:{key:"w:bidi",value:t.bidirectional}}});class Hne extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{ascii:"w:ascii",cs:"w:cs",eastAsia:"w:eastAsia",hAnsi:"w:hAnsi",hint:"w:hint"})}}class w3 extends $e{constructor(e,r){if(super("w:rFonts"),typeof e=="string"){const n=e;this.root.push(new Hne({ascii:n,cs:n,eastAsia:n,hAnsi:n,hint:r}))}else{const n=e;this.root.push(new Hne(n))}}}let GSe=class extends $e{constructor(e){super("w:vertAlign"),this.root.push(new Gn({val:e}))}};class GNt extends GSe{constructor(){super("superscript")}}class KNt extends GSe{constructor(){super("subscript")}}const KSe={SINGLE:"single",WORDS:"words",DOUBLE:"double",THICK:"thick",DOTTED:"dotted",DOTTEDHEAVY:"dottedHeavy",DASH:"dash",DASHEDHEAVY:"dashedHeavy",DASHLONG:"dashLong",DASHLONGHEAVY:"dashLongHeavy",DOTDASH:"dotDash",DASHDOTHEAVY:"dashDotHeavy",DOTDOTDASH:"dotDotDash",DASHDOTDOTHEAVY:"dashDotDotHeavy",WAVE:"wave",WAVYHEAVY:"wavyHeavy",WAVYDOUBLE:"wavyDouble",NONE:"none"};let YNt=class extends $e{constructor(e=KSe.SINGLE,r){super("w:u"),this.root.push(new Gn({val:e,color:r===void 0?void 0:_w(r)}))}};class Cx extends rD{constructor(e){var r,n;if(super("w:rPr"),!e)return;e.style&&this.push(new My("w:rStyle",e.style)),e.font&&(typeof e.font=="string"?this.push(new w3(e.font)):"name"in e.font?this.push(new w3(e.font.name,e.font.hint)):this.push(new w3(e.font))),e.bold!==void 0&&this.push(new He("w:b",e.bold)),(e.boldComplexScript===void 0&&e.bold!==void 0||e.boldComplexScript)&&this.push(new He("w:bCs",(r=e.boldComplexScript)!=null?r:e.bold)),e.italics!==void 0&&this.push(new He("w:i",e.italics)),(e.italicsComplexScript===void 0&&e.italics!==void 0||e.italicsComplexScript)&&this.push(new He("w:iCs",(n=e.italicsComplexScript)!=null?n:e.italics)),e.smallCaps!==void 0?this.push(new He("w:smallCaps",e.smallCaps)):e.allCaps!==void 0&&this.push(new He("w:caps",e.allCaps)),e.strike!==void 0&&this.push(new He("w:strike",e.strike)),e.doubleStrike!==void 0&&this.push(new He("w:dstrike",e.doubleStrike)),e.emboss!==void 0&&this.push(new He("w:emboss",e.emboss)),e.imprint!==void 0&&this.push(new He("w:imprint",e.imprint)),e.noProof!==void 0&&this.push(new He("w:noProof",e.noProof)),e.snapToGrid!==void 0&&this.push(new He("w:snapToGrid",e.snapToGrid)),e.vanish&&this.push(new He("w:vanish",e.vanish)),e.color&&this.push(new HNt(e.color)),e.characterSpacing&&this.push(new UNt(e.characterSpacing)),e.scale!==void 0&&this.push(new N_("w:w",e.scale)),e.kern&&this.push(new b3("w:kern",e.kern)),e.position&&this.push(new My("w:position",e.position)),e.size!==void 0&&this.push(new b3("w:sz",e.size));const s=e.sizeComplexScript===void 0||e.sizeComplexScript===!0?e.size:e.sizeComplexScript;s&&this.push(new b3("w:szCs",s)),e.highlight&&this.push(new VNt(e.highlight));const i=e.highlightComplexScript===void 0||e.highlightComplexScript===!0?e.highlight:e.highlightComplexScript;i&&this.push(new WNt(i)),e.underline&&this.push(new YNt(e.underline.type,e.underline.color)),e.effect&&this.push(new My("w:effect",e.effect)),e.border&&this.push(new Ln("w:bdr",e.border)),e.shading&&this.push(new qSe(e.shading)),e.subScript&&this.push(new KNt),e.superScript&&this.push(new GNt),e.rightToLeft!==void 0&&this.push(new He("w:rtl",e.rightToLeft)),e.emphasisMark&&this.push(new zNt(e.emphasisMark.type)),e.language&&this.push(qNt(e.language)),e.specVanish&&this.push(new He("w:specVanish",e.vanish)),e.math&&this.push(new He("w:oMath",e.math)),e.revision&&this.push(new XNt(e.revision))}push(e){this.root.push(e)}}class XNt extends $e{constructor(e){super("w:rPrChange"),this.root.push(new FNt({id:e.id,author:e.author,date:e.date})),this.addChildElement(new Cx(e))}}let Vne=class extends $e{constructor(e){var r;super("w:t"),typeof e=="string"?(this.root.push(new ax({space:ix.PRESERVE})),this.root.push(e)):(this.root.push(new ax({space:(r=e.space)!=null?r:ix.DEFAULT})),this.root.push(e.text))}};const Uv={CURRENT:"CURRENT",TOTAL_PAGES:"TOTAL_PAGES",TOTAL_PAGES_IN_SECTION:"TOTAL_PAGES_IN_SECTION",CURRENT_SECTION:"SECTION"};class ox extends $e{constructor(e){if(super("w:r"),Fe(this,"properties"),this.properties=new Cx(e),this.root.push(this.properties),e.break)for(let r=0;r<e.break;r++)this.root.push(new PNt);if(e.children)for(const r of e.children){if(typeof r=="string"){switch(r){case Uv.CURRENT:this.root.push(new MS),this.root.push(new INt),this.root.push(new DS),this.root.push(new LS);break;case Uv.TOTAL_PAGES:this.root.push(new MS),this.root.push(new RNt),this.root.push(new DS),this.root.push(new LS);break;case Uv.TOTAL_PAGES_IN_SECTION:this.root.push(new MS),this.root.push(new MNt),this.root.push(new DS),this.root.push(new LS);break;case Uv.CURRENT_SECTION:this.root.push(new MS),this.root.push(new DNt),this.root.push(new DS),this.root.push(new LS);break;default:this.root.push(new Vne(r));break}continue}this.root.push(r)}else e.text!==void 0&&this.root.push(new Vne(e.text))}}class Ci extends ox{constructor(e){super(typeof e=="string"?{text:e}:e)}}var S3={},Mr={},_3,Wne;function WE(){if(Wne)return _3;Wne=1,_3=t;function t(e,r){if(!e)throw new Error(r||"Assertion failed")}return t.equal=function(r,n,s){if(r!=n)throw new Error(s||"Assertion failed: "+r+" != "+n)},_3}var qne;function zu(){if(qne)return Mr;qne=1;var t=WE(),e=gm();Mr.inherits=e;function r(P,W){return(P.charCodeAt(W)&64512)!==55296||W<0||W+1>=P.length?!1:(P.charCodeAt(W+1)&64512)===56320}function n(P,W){if(Array.isArray(P))return P.slice();if(!P)return[];var N=[];if(typeof P=="string")if(W){if(W==="hex")for(P=P.replace(/[^a-z0-9]+/ig,""),P.length%2!==0&&(P="0"+P),K=0;K<P.length;K+=2)N.push(parseInt(P[K]+P[K+1],16))}else for(var U=0,K=0;K<P.length;K++){var G=P.charCodeAt(K);G<128?N[U++]=G:G<2048?(N[U++]=G>>6|192,N[U++]=G&63|128):r(P,K)?(G=65536+((G&1023)<<10)+(P.charCodeAt(++K)&1023),N[U++]=G>>18|240,N[U++]=G>>12&63|128,N[U++]=G>>6&63|128,N[U++]=G&63|128):(N[U++]=G>>12|224,N[U++]=G>>6&63|128,N[U++]=G&63|128)}else for(K=0;K<P.length;K++)N[K]=P[K]|0;return N}Mr.toArray=n;function s(P){for(var W="",N=0;N<P.length;N++)W+=o(P[N].toString(16));return W}Mr.toHex=s;function i(P){var W=P>>>24|P>>>8&65280|P<<8&16711680|(P&255)<<24;return W>>>0}Mr.htonl=i;function a(P,W){for(var N="",U=0;U<P.length;U++){var K=P[U];W==="little"&&(K=i(K)),N+=c(K.toString(16))}return N}Mr.toHex32=a;function o(P){return P.length===1?"0"+P:P}Mr.zero2=o;function c(P){return P.length===7?"0"+P:P.length===6?"00"+P:P.length===5?"000"+P:P.length===4?"0000"+P:P.length===3?"00000"+P:P.length===2?"000000"+P:P.length===1?"0000000"+P:P}Mr.zero8=c;function u(P,W,N,U){var K=N-W;t(K%4===0);for(var G=new Array(K/4),X=0,H=W;X<G.length;X++,H+=4){var B;U==="big"?B=P[H]<<24|P[H+1]<<16|P[H+2]<<8|P[H+3]:B=P[H+3]<<24|P[H+2]<<16|P[H+1]<<8|P[H],G[X]=B>>>0}return G}Mr.join32=u;function d(P,W){for(var N=new Array(P.length*4),U=0,K=0;U<P.length;U++,K+=4){var G=P[U];W==="big"?(N[K]=G>>>24,N[K+1]=G>>>16&255,N[K+2]=G>>>8&255,N[K+3]=G&255):(N[K+3]=G>>>24,N[K+2]=G>>>16&255,N[K+1]=G>>>8&255,N[K]=G&255)}return N}Mr.split32=d;function h(P,W){return P>>>W|P<<32-W}Mr.rotr32=h;function f(P,W){return P<<W|P>>>32-W}Mr.rotl32=f;function p(P,W){return P+W>>>0}Mr.sum32=p;function m(P,W,N){return P+W+N>>>0}Mr.sum32_3=m;function g(P,W,N,U){return P+W+N+U>>>0}Mr.sum32_4=g;function x(P,W,N,U,K){return P+W+N+U+K>>>0}Mr.sum32_5=x;function y(P,W,N,U){var K=P[W],G=P[W+1],X=U+G>>>0,H=(X<U?1:0)+N+K;P[W]=H>>>0,P[W+1]=X}Mr.sum64=y;function v(P,W,N,U){var K=W+U>>>0,G=(K<W?1:0)+P+N;return G>>>0}Mr.sum64_hi=v;function b(P,W,N,U){var K=W+U;return K>>>0}Mr.sum64_lo=b;function w(P,W,N,U,K,G,X,H){var B=0,L=W;L=L+U>>>0,B+=L<W?1:0,L=L+G>>>0,B+=L<G?1:0,L=L+H>>>0,B+=L<H?1:0;var F=P+N+K+X+B;return F>>>0}Mr.sum64_4_hi=w;function S(P,W,N,U,K,G,X,H){var B=W+U+G+H;return B>>>0}Mr.sum64_4_lo=S;function k(P,W,N,U,K,G,X,H,B,L){var F=0,V=W;V=V+U>>>0,F+=V<W?1:0,V=V+G>>>0,F+=V<G?1:0,V=V+H>>>0,F+=V<H?1:0,V=V+L>>>0,F+=V<L?1:0;var Y=P+N+K+X+B+F;return Y>>>0}Mr.sum64_5_hi=k;function E(P,W,N,U,K,G,X,H,B,L){var F=W+U+G+H+L;return F>>>0}Mr.sum64_5_lo=E;function C(P,W,N){var U=W<<32-N|P>>>N;return U>>>0}Mr.rotr64_hi=C;function A(P,W,N){var U=P<<32-N|W>>>N;return U>>>0}Mr.rotr64_lo=A;function M(P,W,N){return P>>>N}Mr.shr64_hi=M;function z(P,W,N){var U=P<<32-N|W>>>N;return U>>>0}return Mr.shr64_lo=z,Mr}var j3={},Gne;function qE(){if(Gne)return j3;Gne=1;var t=zu(),e=WE();function r(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}return j3.BlockHash=r,r.prototype.update=function(s,i){if(s=t.toArray(s,i),this.pending?this.pending=this.pending.concat(s):this.pending=s,this.pendingTotal+=s.length,this.pending.length>=this._delta8){s=this.pending;var a=s.length%this._delta8;this.pending=s.slice(s.length-a,s.length),this.pending.length===0&&(this.pending=null),s=t.join32(s,0,s.length-a,this.endian);for(var o=0;o<s.length;o+=this._delta32)this._update(s,o,o+this._delta32)}return this},r.prototype.digest=function(s){return this.update(this._pad()),e(this.pending===null),this._digest(s)},r.prototype._pad=function(){var s=this.pendingTotal,i=this._delta8,a=i-(s+this.padLength)%i,o=new Array(a+this.padLength);o[0]=128;for(var c=1;c<a;c++)o[c]=0;if(s<<=3,this.endian==="big"){for(var u=8;u<this.padLength;u++)o[c++]=0;o[c++]=0,o[c++]=0,o[c++]=0,o[c++]=0,o[c++]=s>>>24&255,o[c++]=s>>>16&255,o[c++]=s>>>8&255,o[c++]=s&255}else for(o[c++]=s&255,o[c++]=s>>>8&255,o[c++]=s>>>16&255,o[c++]=s>>>24&255,o[c++]=0,o[c++]=0,o[c++]=0,o[c++]=0,u=8;u<this.padLength;u++)o[c++]=0;return o},j3}var Cm={},Rc={},Kne;function YSe(){if(Kne)return Rc;Kne=1;var t=zu(),e=t.rotr32;function r(d,h,f,p){if(d===0)return n(h,f,p);if(d===1||d===3)return i(h,f,p);if(d===2)return s(h,f,p)}Rc.ft_1=r;function n(d,h,f){return d&h^~d&f}Rc.ch32=n;function s(d,h,f){return d&h^d&f^h&f}Rc.maj32=s;function i(d,h,f){return d^h^f}Rc.p32=i;function a(d){return e(d,2)^e(d,13)^e(d,22)}Rc.s0_256=a;function o(d){return e(d,6)^e(d,11)^e(d,25)}Rc.s1_256=o;function c(d){return e(d,7)^e(d,18)^d>>>3}Rc.g0_256=c;function u(d){return e(d,17)^e(d,19)^d>>>10}return Rc.g1_256=u,Rc}var k3,Yne;function JNt(){if(Yne)return k3;Yne=1;var t=zu(),e=qE(),r=YSe(),n=t.rotl32,s=t.sum32,i=t.sum32_5,a=r.ft_1,o=e.BlockHash,c=[1518500249,1859775393,2400959708,3395469782];function u(){if(!(this instanceof u))return new u;o.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}return t.inherits(u,o),k3=u,u.blockSize=512,u.outSize=160,u.hmacStrength=80,u.padLength=64,u.prototype._update=function(h,f){for(var p=this.W,m=0;m<16;m++)p[m]=h[f+m];for(;m<p.length;m++)p[m]=n(p[m-3]^p[m-8]^p[m-14]^p[m-16],1);var g=this.h[0],x=this.h[1],y=this.h[2],v=this.h[3],b=this.h[4];for(m=0;m<p.length;m++){var w=~~(m/20),S=i(n(g,5),a(w,x,y,v),b,p[m],c[w]);b=v,v=y,y=n(x,30),x=g,g=S}this.h[0]=s(this.h[0],g),this.h[1]=s(this.h[1],x),this.h[2]=s(this.h[2],y),this.h[3]=s(this.h[3],v),this.h[4]=s(this.h[4],b)},u.prototype._digest=function(h){return h==="hex"?t.toHex32(this.h,"big"):t.split32(this.h,"big")},k3}var N3,Xne;function XSe(){if(Xne)return N3;Xne=1;var t=zu(),e=qE(),r=YSe(),n=WE(),s=t.sum32,i=t.sum32_4,a=t.sum32_5,o=r.ch32,c=r.maj32,u=r.s0_256,d=r.s1_256,h=r.g0_256,f=r.g1_256,p=e.BlockHash,m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function g(){if(!(this instanceof g))return new g;p.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m,this.W=new Array(64)}return t.inherits(g,p),N3=g,g.blockSize=512,g.outSize=256,g.hmacStrength=192,g.padLength=64,g.prototype._update=function(y,v){for(var b=this.W,w=0;w<16;w++)b[w]=y[v+w];for(;w<b.length;w++)b[w]=i(f(b[w-2]),b[w-7],h(b[w-15]),b[w-16]);var S=this.h[0],k=this.h[1],E=this.h[2],C=this.h[3],A=this.h[4],M=this.h[5],z=this.h[6],P=this.h[7];for(n(this.k.length===b.length),w=0;w<b.length;w++){var W=a(P,d(A),o(A,M,z),this.k[w],b[w]),N=s(u(S),c(S,k,E));P=z,z=M,M=A,A=s(C,W),C=E,E=k,k=S,S=s(W,N)}this.h[0]=s(this.h[0],S),this.h[1]=s(this.h[1],k),this.h[2]=s(this.h[2],E),this.h[3]=s(this.h[3],C),this.h[4]=s(this.h[4],A),this.h[5]=s(this.h[5],M),this.h[6]=s(this.h[6],z),this.h[7]=s(this.h[7],P)},g.prototype._digest=function(y){return y==="hex"?t.toHex32(this.h,"big"):t.split32(this.h,"big")},N3}var E3,Jne;function QNt(){if(Jne)return E3;Jne=1;var t=zu(),e=XSe();function r(){if(!(this instanceof r))return new r;e.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}return t.inherits(r,e),E3=r,r.blockSize=512,r.outSize=224,r.hmacStrength=192,r.padLength=64,r.prototype._digest=function(s){return s==="hex"?t.toHex32(this.h.slice(0,7),"big"):t.split32(this.h.slice(0,7),"big")},E3}var A3,Qne;function JSe(){if(Qne)return A3;Qne=1;var t=zu(),e=qE(),r=WE(),n=t.rotr64_hi,s=t.rotr64_lo,i=t.shr64_hi,a=t.shr64_lo,o=t.sum64,c=t.sum64_hi,u=t.sum64_lo,d=t.sum64_4_hi,h=t.sum64_4_lo,f=t.sum64_5_hi,p=t.sum64_5_lo,m=e.BlockHash,g=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function x(){if(!(this instanceof x))return new x;m.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=g,this.W=new Array(160)}t.inherits(x,m),A3=x,x.blockSize=1024,x.outSize=512,x.hmacStrength=192,x.padLength=128,x.prototype._prepareBlock=function(N,U){for(var K=this.W,G=0;G<32;G++)K[G]=N[U+G];for(;G<K.length;G+=2){var X=z(K[G-4],K[G-3]),H=P(K[G-4],K[G-3]),B=K[G-14],L=K[G-13],F=A(K[G-30],K[G-29]),V=M(K[G-30],K[G-29]),Y=K[G-32],ie=K[G-31];K[G]=d(X,H,B,L,F,V,Y,ie),K[G+1]=h(X,H,B,L,F,V,Y,ie)}},x.prototype._update=function(N,U){this._prepareBlock(N,U);var K=this.W,G=this.h[0],X=this.h[1],H=this.h[2],B=this.h[3],L=this.h[4],F=this.h[5],V=this.h[6],Y=this.h[7],ie=this.h[8],Q=this.h[9],D=this.h[10],R=this.h[11],J=this.h[12],Z=this.h[13],ee=this.h[14],re=this.h[15];r(this.k.length===K.length);for(var he=0;he<K.length;he+=2){var O=ee,ae=re,q=E(ie,Q),I=C(ie,Q),T=y(ie,Q,D,R,J),$=v(ie,Q,D,R,J,Z),se=this.k[he],ue=this.k[he+1],ne=K[he],me=K[he+1],ve=f(O,ae,q,I,T,$,se,ue,ne,me),xe=p(O,ae,q,I,T,$,se,ue,ne,me);O=S(G,X),ae=k(G,X),q=b(G,X,H,B,L),I=w(G,X,H,B,L,F);var oe=c(O,ae,q,I),de=u(O,ae,q,I);ee=J,re=Z,J=D,Z=R,D=ie,R=Q,ie=c(V,Y,ve,xe),Q=u(Y,Y,ve,xe),V=L,Y=F,L=H,F=B,H=G,B=X,G=c(ve,xe,oe,de),X=u(ve,xe,oe,de)}o(this.h,0,G,X),o(this.h,2,H,B),o(this.h,4,L,F),o(this.h,6,V,Y),o(this.h,8,ie,Q),o(this.h,10,D,R),o(this.h,12,J,Z),o(this.h,14,ee,re)},x.prototype._digest=function(N){return N==="hex"?t.toHex32(this.h,"big"):t.split32(this.h,"big")};function y(W,N,U,K,G){var X=W&U^~W&G;return X<0&&(X+=4294967296),X}function v(W,N,U,K,G,X){var H=N&K^~N&X;return H<0&&(H+=4294967296),H}function b(W,N,U,K,G){var X=W&U^W&G^U&G;return X<0&&(X+=4294967296),X}function w(W,N,U,K,G,X){var H=N&K^N&X^K&X;return H<0&&(H+=4294967296),H}function S(W,N){var U=n(W,N,28),K=n(N,W,2),G=n(N,W,7),X=U^K^G;return X<0&&(X+=4294967296),X}function k(W,N){var U=s(W,N,28),K=s(N,W,2),G=s(N,W,7),X=U^K^G;return X<0&&(X+=4294967296),X}function E(W,N){var U=n(W,N,14),K=n(W,N,18),G=n(N,W,9),X=U^K^G;return X<0&&(X+=4294967296),X}function C(W,N){var U=s(W,N,14),K=s(W,N,18),G=s(N,W,9),X=U^K^G;return X<0&&(X+=4294967296),X}function A(W,N){var U=n(W,N,1),K=n(W,N,8),G=i(W,N,7),X=U^K^G;return X<0&&(X+=4294967296),X}function M(W,N){var U=s(W,N,1),K=s(W,N,8),G=a(W,N,7),X=U^K^G;return X<0&&(X+=4294967296),X}function z(W,N){var U=n(W,N,19),K=n(N,W,29),G=i(W,N,6),X=U^K^G;return X<0&&(X+=4294967296),X}function P(W,N){var U=s(W,N,19),K=s(N,W,29),G=a(W,N,6),X=U^K^G;return X<0&&(X+=4294967296),X}return A3}var C3,Zne;function ZNt(){if(Zne)return C3;Zne=1;var t=zu(),e=JSe();function r(){if(!(this instanceof r))return new r;e.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}return t.inherits(r,e),C3=r,r.blockSize=1024,r.outSize=384,r.hmacStrength=192,r.padLength=128,r.prototype._digest=function(s){return s==="hex"?t.toHex32(this.h.slice(0,12),"big"):t.split32(this.h.slice(0,12),"big")},C3}var ese;function eEt(){return ese||(ese=1,Cm.sha1=JNt(),Cm.sha224=QNt(),Cm.sha256=XSe(),Cm.sha384=ZNt(),Cm.sha512=JSe()),Cm}var T3={},tse;function tEt(){if(tse)return T3;tse=1;var t=zu(),e=qE(),r=t.rotl32,n=t.sum32,s=t.sum32_3,i=t.sum32_4,a=e.BlockHash;function o(){if(!(this instanceof o))return new o;a.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}t.inherits(o,a),T3.ripemd160=o,o.blockSize=512,o.outSize=160,o.hmacStrength=192,o.padLength=64,o.prototype._update=function(x,y){for(var v=this.h[0],b=this.h[1],w=this.h[2],S=this.h[3],k=this.h[4],E=v,C=b,A=w,M=S,z=k,P=0;P<80;P++){var W=n(r(i(v,c(P,b,w,S),x[h[P]+y],u(P)),p[P]),k);v=k,k=S,S=r(w,10),w=b,b=W,W=n(r(i(E,c(79-P,C,A,M),x[f[P]+y],d(P)),m[P]),z),E=z,z=M,M=r(A,10),A=C,C=W}W=s(this.h[1],w,M),this.h[1]=s(this.h[2],S,z),this.h[2]=s(this.h[3],k,E),this.h[3]=s(this.h[4],v,C),this.h[4]=s(this.h[0],b,A),this.h[0]=W},o.prototype._digest=function(x){return x==="hex"?t.toHex32(this.h,"little"):t.split32(this.h,"little")};function c(g,x,y,v){return g<=15?x^y^v:g<=31?x&y|~x&v:g<=47?(x|~y)^v:g<=63?x&v|y&~v:x^(y|~v)}function u(g){return g<=15?0:g<=31?1518500249:g<=47?1859775393:g<=63?2400959708:2840853838}function d(g){return g<=15?1352829926:g<=31?1548603684:g<=47?1836072691:g<=63?2053994217:0}var h=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],f=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],p=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],m=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11];return T3}var P3,rse;function rEt(){if(rse)return P3;rse=1;var t=zu(),e=WE();function r(n,s,i){if(!(this instanceof r))return new r(n,s,i);this.Hash=n,this.blockSize=n.blockSize/8,this.outSize=n.outSize/8,this.inner=null,this.outer=null,this._init(t.toArray(s,i))}return P3=r,r.prototype._init=function(s){s.length>this.blockSize&&(s=new this.Hash().update(s).digest()),e(s.length<=this.blockSize);for(var i=s.length;i<this.blockSize;i++)s.push(0);for(i=0;i<s.length;i++)s[i]^=54;for(this.inner=new this.Hash().update(s),i=0;i<s.length;i++)s[i]^=106;this.outer=new this.Hash().update(s)},r.prototype.update=function(s,i){return this.inner.update(s,i),this},r.prototype.digest=function(s){return this.outer.update(this.inner.digest()),this.outer.digest(s)},P3}var nse;function nEt(){return nse||(nse=1,function(t){var e=t;e.utils=zu(),e.common=qE(),e.sha=eEt(),e.ripemd=tEt(),e.hmac=rEt(),e.sha1=e.sha.sha1,e.sha256=e.sha.sha256,e.sha224=e.sha.sha224,e.sha384=e.sha.sha384,e.sha512=e.sha.sha512,e.ripemd160=e.ripemd.ripemd160}(S3)),S3}nEt();let sEt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",iEt=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n},aEt=(t=21)=>{let e="",r=t|0;for(;r--;)e+=sEt[Math.random()*64|0];return e};const Ll=t=>Math.floor(t*72*20),w7=(t=0)=>{let e=t;return()=>++e},oEt=()=>w7(),lEt=()=>w7(1),cEt=()=>w7(),uEt=()=>aEt().toLowerCase(),J1=t=>iEt("1234567890abcdef",t)(),dEt=()=>`${J1(8)}-${J1(4)}-${J1(4)}-${J1(4)}-${J1(12)}`;class hEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{xmlns:"xmlns"})}}class fEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{id:"Id",type:"Type",target:"Target",targetMode:"TargetMode"})}}const pEt={EXTERNAL:"External"};class mEt extends $e{constructor(e,r,n,s){super("Relationship"),this.root.push(new fEt({id:e,type:r,target:n,targetMode:s}))}}class Tx extends $e{constructor(){super("Relationships"),this.root.push(new hEt({xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"}))}createRelationship(e,r,n,s){const i=new mEt(`rId${e}`,r,n,s);return this.root.push(i),i}get RelationshipCount(){return this.root.length-1}}class gEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{id:"w:id",initials:"w:initials",author:"w:author",date:"w:date"})}}class yEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{"xmlns:cx":"xmlns:cx","xmlns:cx1":"xmlns:cx1","xmlns:cx2":"xmlns:cx2","xmlns:cx3":"xmlns:cx3","xmlns:cx4":"xmlns:cx4","xmlns:cx5":"xmlns:cx5","xmlns:cx6":"xmlns:cx6","xmlns:cx7":"xmlns:cx7","xmlns:cx8":"xmlns:cx8","xmlns:mc":"xmlns:mc","xmlns:aink":"xmlns:aink","xmlns:am3d":"xmlns:am3d","xmlns:o":"xmlns:o","xmlns:r":"xmlns:r","xmlns:m":"xmlns:m","xmlns:v":"xmlns:v","xmlns:wp14":"xmlns:wp14","xmlns:wp":"xmlns:wp","xmlns:w10":"xmlns:w10","xmlns:w":"xmlns:w","xmlns:w14":"xmlns:w14","xmlns:w15":"xmlns:w15","xmlns:w16cex":"xmlns:w16cex","xmlns:w16cid":"xmlns:w16cid","xmlns:w16":"xmlns:w16","xmlns:w16sdtdh":"xmlns:w16sdtdh","xmlns:w16se":"xmlns:w16se","xmlns:wpg":"xmlns:wpg","xmlns:wpi":"xmlns:wpi","xmlns:wne":"xmlns:wne","xmlns:wps":"xmlns:wps"})}}class xEt extends $e{constructor({id:e,initials:r,author:n,date:s=new Date,children:i}){super("w:comment"),this.root.push(new gEt({id:e,initials:r,author:n,date:s.toISOString()}));for(const a of i)this.root.push(a)}}class vEt extends $e{constructor({children:e}){super("w:comments"),Fe(this,"relationships"),this.root.push(new yEt({"xmlns:cx":"http://schemas.microsoft.com/office/drawing/2014/chartex","xmlns:cx1":"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex","xmlns:cx2":"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex","xmlns:cx3":"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex","xmlns:cx4":"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex","xmlns:cx5":"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex","xmlns:cx6":"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex","xmlns:cx7":"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex","xmlns:cx8":"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","xmlns:aink":"http://schemas.microsoft.com/office/drawing/2016/ink","xmlns:am3d":"http://schemas.microsoft.com/office/drawing/2017/model3d","xmlns:o":"urn:schemas-microsoft-com:office:office","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:m":"http://schemas.openxmlformats.org/officeDocument/2006/math","xmlns:v":"urn:schemas-microsoft-com:vml","xmlns:wp14":"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing","xmlns:wp":"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing","xmlns:w10":"urn:schemas-microsoft-com:office:word","xmlns:w":"http://schemas.openxmlformats.org/wordprocessingml/2006/main","xmlns:w14":"http://schemas.microsoft.com/office/word/2010/wordml","xmlns:w15":"http://schemas.microsoft.com/office/word/2012/wordml","xmlns:w16cex":"http://schemas.microsoft.com/office/word/2018/wordml/cex","xmlns:w16cid":"http://schemas.microsoft.com/office/word/2016/wordml/cid","xmlns:w16":"http://schemas.microsoft.com/office/word/2018/wordml","xmlns:w16sdtdh":"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash","xmlns:w16se":"http://schemas.microsoft.com/office/word/2015/wordml/symex","xmlns:wpg":"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup","xmlns:wpi":"http://schemas.microsoft.com/office/word/2010/wordprocessingInk","xmlns:wne":"http://schemas.microsoft.com/office/word/2006/wordml","xmlns:wps":"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"}));for(const r of e)this.root.push(new xEt(r));this.relationships=new Tx}get Relationships(){return this.relationships}}const bEt={COLUMN:"column",PAGE:"page"};class wEt extends $e{constructor(e){super("w:br"),this.root.push(new Gn({type:e}))}}class sse extends ox{constructor(){super({}),this.root.push(new wEt(bEt.PAGE))}}class SEt extends $e{constructor(){super("w:pageBreakBefore")}}const Hz={AT_LEAST:"atLeast",EXACTLY:"exactly",EXACT:"exact",AUTO:"auto"};class _Et extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{after:"w:after",before:"w:before",line:"w:line",lineRule:"w:lineRule",beforeAutoSpacing:"w:beforeAutospacing",afterAutoSpacing:"w:afterAutospacing"})}}class jEt extends $e{constructor(e){super("w:spacing"),this.root.push(new _Et(e))}}const O3={HEADING_1:"Heading1",HEADING_2:"Heading2",HEADING_3:"Heading3",HEADING_4:"Heading4",HEADING_5:"Heading5",HEADING_6:"Heading6",TITLE:"Title"};let jC=class extends $e{constructor(e){super("w:pStyle"),this.root.push(new Gn({val:e}))}};class kEt extends $e{constructor(e){super("w:tabs");for(const r of e)this.root.push(new EEt(r))}}const ise={LEFT:"left",RIGHT:"right",CENTER:"center",BAR:"bar",CLEAR:"clear",DECIMAL:"decimal",END:"end",NUM:"num",START:"start"};class NEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{val:"w:val",pos:"w:pos",leader:"w:leader"})}}class EEt extends $e{constructor({type:e,position:r,leader:n}){super("w:tab"),this.root.push(new NEt({val:e,pos:r,leader:n}))}}class I3 extends $e{constructor(e,r){super("w:numPr"),this.root.push(new AEt(r)),this.root.push(new CEt(e))}}class AEt extends $e{constructor(e){if(super("w:ilvl"),e>9)throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");this.root.push(new Gn({val:e}))}}class CEt extends $e{constructor(e){super("w:numId"),this.root.push(new Gn({val:typeof e=="string"?`{${e}}`:e}))}}class QSe extends $e{constructor(){super(...arguments),Fe(this,"fileChild",Symbol())}}class TEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{id:"r:id",history:"w:history",anchor:"w:anchor"})}}class PEt extends $e{constructor(e,r,n){super("w:hyperlink"),Fe(this,"linkId"),this.linkId=r;const s={history:1,anchor:n||void 0,id:n?void 0:`rId${this.linkId}`},i=new TEt(s);this.root.push(i),e.forEach(a=>{this.root.push(a)})}}class OEt extends $e{constructor(e){super("w:externalHyperlink"),this.options=e}}class IEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{id:"w:id",name:"w:name"})}}class REt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{id:"w:id"})}}class MEt{constructor(e){Fe(this,"bookmarkUniqueNumericId",cEt()),Fe(this,"start"),Fe(this,"children"),Fe(this,"end");const r=this.bookmarkUniqueNumericId();this.start=new DEt(e.id,r),this.children=e.children,this.end=new LEt(r)}}class DEt extends $e{constructor(e,r){super("w:bookmarkStart");const n=new IEt({name:e,id:r});this.root.push(n)}}class LEt extends $e{constructor(e){super("w:bookmarkEnd");const r=new REt({id:e});this.root.push(r)}}class FEt extends $e{constructor(e){super("w:outlineLvl"),this.level=e,this.root.push(new Gn({val:e}))}}const $Et={TOP:"top",CENTER:"center",BOTTOM:"bottom"};ww(fr({},$Et),{BOTH:"both"});class BEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{verticalAlign:"w:val"})}}class zEt extends $e{constructor(e){super("w:vAlign"),this.root.push(new BEt({verticalAlign:e}))}}class UEt extends $e{constructor({space:e,count:r,separate:n,equalWidth:s,children:i}){super("w:cols"),this.root.push(new nD({space:{key:"w:space",value:e===void 0?void 0:oc(e)},count:{key:"w:num",value:r===void 0?void 0:Ja(r)},separate:{key:"w:sep",value:n},equalWidth:{key:"w:equalWidth",value:s}})),!s&&i&&i.forEach(a=>this.addChildElement(a))}}const HEt=({type:t,linePitch:e,charSpace:r})=>new Tu({name:"w:docGrid",attributes:{type:{key:"w:type",value:t},linePitch:{key:"w:linePitch",value:Ja(e)},charSpace:{key:"w:charSpace",value:r?Ja(r):void 0}}}),fb={DEFAULT:"default",FIRST:"first",EVEN:"even"};class VEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{type:"w:type",id:"r:id"})}}const ase={HEADER:"w:headerReference",FOOTER:"w:footerReference"};class R3 extends $e{constructor(e,r){super(e),this.root.push(new VEt({type:r.type||fb.DEFAULT,id:`rId${r.id}`}))}}const WEt=({countBy:t,start:e,restart:r,distance:n})=>new Tu({name:"w:lnNumType",attributes:{countBy:{key:"w:countBy",value:t===void 0?void 0:Ja(t)},start:{key:"w:start",value:e===void 0?void 0:Ja(e)},restart:{key:"w:restart",value:r},distance:{key:"w:distance",value:n===void 0?void 0:oc(n)}}});class ose extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{display:"w:display",offsetFrom:"w:offsetFrom",zOrder:"w:zOrder"})}}class qEt extends rD{constructor(e){if(super("w:pgBorders"),!e)return this;e.pageBorders?this.root.push(new ose({display:e.pageBorders.display,offsetFrom:e.pageBorders.offsetFrom,zOrder:e.pageBorders.zOrder})):this.root.push(new ose({})),e.pageBorderTop&&this.root.push(new Ln("w:top",e.pageBorderTop)),e.pageBorderLeft&&this.root.push(new Ln("w:left",e.pageBorderLeft)),e.pageBorderBottom&&this.root.push(new Ln("w:bottom",e.pageBorderBottom)),e.pageBorderRight&&this.root.push(new Ln("w:right",e.pageBorderRight))}}class GEt extends $e{constructor(e,r,n,s,i,a,o){super("w:pgMar"),this.root.push(new nD({top:{key:"w:top",value:ag(e)},right:{key:"w:right",value:oc(r)},bottom:{key:"w:bottom",value:ag(n)},left:{key:"w:left",value:oc(s)},header:{key:"w:header",value:oc(i)},footer:{key:"w:footer",value:oc(a)},gutter:{key:"w:gutter",value:oc(o)}}))}}class KEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{start:"w:start",formatType:"w:fmt",separator:"w:chapSep"})}}class YEt extends $e{constructor({start:e,formatType:r,separator:n}){super("w:pgNumType"),this.root.push(new KEt({start:e===void 0?void 0:Ja(e),formatType:r,separator:n}))}}const Vz={PORTRAIT:"portrait",LANDSCAPE:"landscape"},XEt=({width:t,height:e,orientation:r,code:n})=>{const s=oc(t),i=oc(e);return new Tu({name:"w:pgSz",attributes:{width:{key:"w:w",value:r===Vz.LANDSCAPE?i:s},height:{key:"w:h",value:r===Vz.LANDSCAPE?s:i},orientation:{key:"w:orient",value:r},code:{key:"w:code",value:n}}})};class JEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{val:"w:val"})}}class QEt extends $e{constructor(e){super("w:textDirection"),this.root.push(new JEt({val:e}))}}class ZEt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{val:"w:val"})}}class eAt extends $e{constructor(e){super("w:type"),this.root.push(new ZEt({val:e}))}}const Tm={TOP:1440,RIGHT:1440,BOTTOM:1440,LEFT:1440,HEADER:708,FOOTER:708,GUTTER:0},M3={WIDTH:11906,HEIGHT:16838,ORIENTATION:Vz.PORTRAIT};class tAt extends $e{constructor({page:{size:{width:e=M3.WIDTH,height:r=M3.HEIGHT,orientation:n=M3.ORIENTATION}={},margin:{top:s=Tm.TOP,right:i=Tm.RIGHT,bottom:a=Tm.BOTTOM,left:o=Tm.LEFT,header:c=Tm.HEADER,footer:u=Tm.FOOTER,gutter:d=Tm.GUTTER}={},pageNumbers:h={},borders:f,textDirection:p}={},grid:{linePitch:m=360,charSpace:g,type:x}={},headerWrapperGroup:y={},footerWrapperGroup:v={},lineNumbers:b,titlePage:w,verticalAlign:S,column:k,type:E}={}){super("w:sectPr"),this.addHeaderFooterGroup(ase.HEADER,y),this.addHeaderFooterGroup(ase.FOOTER,v),E&&this.root.push(new eAt(E)),this.root.push(XEt({width:e,height:r,orientation:n})),this.root.push(new GEt(s,i,a,o,c,u,d)),f&&this.root.push(new qEt(f)),b&&this.root.push(WEt(b)),this.root.push(new YEt(h)),k&&this.root.push(new UEt(k)),S&&this.root.push(new zEt(S)),w!==void 0&&this.root.push(new He("w:titlePg",w)),p&&this.root.push(new QEt(p)),this.root.push(HEt({linePitch:m,charSpace:g,type:x}))}addHeaderFooterGroup(e,r){r.default&&this.root.push(new R3(e,{type:fb.DEFAULT,id:r.default.View.ReferenceId})),r.first&&this.root.push(new R3(e,{type:fb.FIRST,id:r.first.View.ReferenceId})),r.even&&this.root.push(new R3(e,{type:fb.EVEN,id:r.even.View.ReferenceId}))}}class rAt extends $e{constructor(){super("w:body"),Fe(this,"sections",[])}addSection(e){const r=this.sections.pop();this.root.push(this.createSectionParagraph(r)),this.sections.push(new tAt(e))}prepForXml(e){return this.sections.length===1&&(this.root.splice(0,1),this.root.push(this.sections.pop())),super.prepForXml(e)}push(e){this.root.push(e)}createSectionParagraph(e){const r=new on({}),n=new jw({});return n.push(e),r.addChildElement(n),r}}const lse={wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",cp:"http://schemas.openxmlformats.org/package/2006/metadata/core-properties",dc:"http://purl.org/dc/elements/1.1/",dcterms:"http://purl.org/dc/terms/",dcmitype:"http://purl.org/dc/dcmitype/",xsi:"http://www.w3.org/2001/XMLSchema-instance",cx:"http://schemas.microsoft.com/office/drawing/2014/chartex",cx1:"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex",cx2:"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex",cx3:"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex",cx4:"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex",cx5:"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex",cx6:"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex",cx7:"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex",cx8:"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex",aink:"http://schemas.microsoft.com/office/drawing/2016/ink",am3d:"http://schemas.microsoft.com/office/drawing/2017/model3d",w16cex:"http://schemas.microsoft.com/office/word/2018/wordml/cex",w16cid:"http://schemas.microsoft.com/office/word/2016/wordml/cid",w16:"http://schemas.microsoft.com/office/word/2018/wordml",w16sdtdh:"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash",w16se:"http://schemas.microsoft.com/office/word/2015/wordml/symex"};class oD extends Rt{constructor(e,r){super(fr({Ignorable:r},Object.fromEntries(e.map(n=>[n,lse[n]])))),Fe(this,"xmlKeys",fr({Ignorable:"mc:Ignorable"},Object.fromEntries(Object.keys(lse).map(n=>[n,`xmlns:${n}`]))))}}class nAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{color:"w:color",themeColor:"w:themeColor",themeShade:"w:themeShade",themeTint:"w:themeTint"})}}class sAt extends $e{constructor(e){super("w:background"),this.root.push(new nAt({color:e.color===void 0?void 0:_w(e.color),themeColor:e.themeColor,themeShade:e.themeShade===void 0?void 0:Une(e.themeShade),themeTint:e.themeTint===void 0?void 0:Une(e.themeTint)}))}}let iAt=class extends $e{constructor(e){super("w:document"),Fe(this,"body"),this.root.push(new oD(["wpc","mc","o","r","m","v","wp14","wp","w10","w","w14","w15","wpg","wpi","wne","wps","cx","cx1","cx2","cx3","cx4","cx5","cx6","cx7","cx8","aink","am3d","w16cex","w16cid","w16","w16sdtdh","w16se"],"w14 w15 wp14")),this.body=new rAt,e.background&&this.root.push(new sAt(e.background)),this.root.push(this.body)}add(e){return this.body.push(e),this}get Body(){return this.body}};class ZSe{constructor(e){Fe(this,"document"),Fe(this,"relationships"),this.document=new iAt(e),this.relationships=new Tx}get View(){return this.document}get Relationships(){return this.relationships}}class aAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{val:"w:val"})}}class oAt extends $e{constructor(){super("w:wordWrap"),this.root.push(new aAt({val:0}))}}const lAt=t=>{var e,r;return new Tu({name:"w:framePr",attributes:{anchorLock:{key:"w:anchorLock",value:t.anchorLock},dropCap:{key:"w:dropCap",value:t.dropCap},width:{key:"w:w",value:t.width},height:{key:"w:h",value:t.height},x:{key:"w:x",value:t.position?t.position.x:void 0},y:{key:"w:y",value:t.position?t.position.y:void 0},anchorHorizontal:{key:"w:hAnchor",value:t.anchor.horizontal},anchorVertical:{key:"w:vAnchor",value:t.anchor.vertical},spaceHorizontal:{key:"w:hSpace",value:(e=t.space)==null?void 0:e.horizontal},spaceVertical:{key:"w:vSpace",value:(r=t.space)==null?void 0:r.vertical},rule:{key:"w:hRule",value:t.rule},alignmentX:{key:"w:xAlign",value:t.alignment?t.alignment.x:void 0},alignmentY:{key:"w:yAlign",value:t.alignment?t.alignment.y:void 0},lines:{key:"w:lines",value:t.lines},wrap:{key:"w:wrap",value:t.wrap}}})};class jw extends rD{constructor(e){var r,n;if(super("w:pPr"),Fe(this,"numberingReferences",[]),!e)return this;e.heading&&this.push(new jC(e.heading)),e.bullet&&this.push(new jC("ListParagraph")),e.numbering&&!e.style&&!e.heading&&(e.numbering.custom||this.push(new jC("ListParagraph"))),e.style&&this.push(new jC(e.style)),e.keepNext!==void 0&&this.push(new He("w:keepNext",e.keepNext)),e.keepLines!==void 0&&this.push(new He("w:keepLines",e.keepLines)),e.pageBreakBefore&&this.push(new SEt),e.frame&&this.push(lAt(e.frame)),e.widowControl!==void 0&&this.push(new He("w:widowControl",e.widowControl)),e.bullet&&this.push(new I3(1,e.bullet.level)),e.numbering?(this.numberingReferences.push({reference:e.numbering.reference,instance:(r=e.numbering.instance)!=null?r:0}),this.push(new I3(`${e.numbering.reference}-${(n=e.numbering.instance)!=null?n:0}`,e.numbering.level))):e.numbering===!1&&this.push(new I3(0,0)),e.border&&this.push(new ANt(e.border)),e.thematicBreak&&this.push(new CNt),e.shading&&this.push(new qSe(e.shading)),e.wordWrap&&this.push(new oAt),e.overflowPunctuation&&this.push(new He("w:overflowPunct",e.overflowPunctuation));const s=[...e.rightTabStop!==void 0?[{type:ise.RIGHT,position:e.rightTabStop}]:[],...e.tabStops?e.tabStops:[],...e.leftTabStop!==void 0?[{type:ise.LEFT,position:e.leftTabStop}]:[]];s.length>0&&this.push(new kEt(s)),e.bidirectional!==void 0&&this.push(new He("w:bidi",e.bidirectional)),e.spacing&&this.push(new jEt(e.spacing)),e.indent&&this.push(new TNt(e.indent)),e.contextualSpacing!==void 0&&this.push(new He("w:contextualSpacing",e.contextualSpacing)),e.alignment&&this.push(new NNt(e.alignment)),e.outlineLevel!==void 0&&this.push(new FEt(e.outlineLevel)),e.suppressLineNumbers!==void 0&&this.push(new He("w:suppressLineNumbers",e.suppressLineNumbers)),e.autoSpaceEastAsianText!==void 0&&this.push(new He("w:autoSpaceDN",e.autoSpaceEastAsianText)),e.run&&this.push(new Cx(e.run))}push(e){this.root.push(e)}prepForXml(e){if(e.viewWrapper instanceof ZSe)for(const r of this.numberingReferences)e.file.Numbering.createConcreteNumberingInstance(r.reference,r.instance);return super.prepForXml(e)}}let on=class extends QSe{constructor(e){if(super("w:p"),Fe(this,"properties"),typeof e=="string")return this.properties=new jw({}),this.root.push(this.properties),this.root.push(new Ci(e)),this;if(this.properties=new jw(e),this.root.push(this.properties),e.text&&this.root.push(new Ci(e.text)),e.children)for(const r of e.children){if(r instanceof MEt){this.root.push(r.start);for(const n of r.children)this.root.push(n);this.root.push(r.end);continue}this.root.push(r)}}prepForXml(e){for(const r of this.root)if(r instanceof OEt){const n=this.root.indexOf(r),s=new PEt(r.options.children,uEt());e.viewWrapper.Relationships.createRelationship(s.linkId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",r.options.link,pEt.EXTERNAL),this.root[n]=s}return super.prepForXml(e)}addRunToFront(e){return this.root.splice(1,0,e),this}};const Kx={style:x7.NONE,size:0,color:"auto"},Yx={style:x7.SINGLE,size:4,color:"auto"};class cAt extends $e{constructor(e){super("w:tblBorders"),e.top?this.root.push(new Ln("w:top",e.top)):this.root.push(new Ln("w:top",Yx)),e.left?this.root.push(new Ln("w:left",e.left)):this.root.push(new Ln("w:left",Yx)),e.bottom?this.root.push(new Ln("w:bottom",e.bottom)):this.root.push(new Ln("w:bottom",Yx)),e.right?this.root.push(new Ln("w:right",e.right)):this.root.push(new Ln("w:right",Yx)),e.insideHorizontal?this.root.push(new Ln("w:insideH",e.insideHorizontal)):this.root.push(new Ln("w:insideH",Yx)),e.insideVertical?this.root.push(new Ln("w:insideV",e.insideVertical)):this.root.push(new Ln("w:insideV",Yx))}}Fe(cAt,"NONE",{top:Kx,bottom:Kx,left:Kx,right:Kx,insideHorizontal:Kx,insideVertical:Kx});class uAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{xmlns:"xmlns",vt:"xmlns:vt"})}}class dAt extends $e{constructor(){super("Properties"),this.root.push(new uAt({xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"}))}}class hAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{xmlns:"xmlns"})}}class fAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{contentType:"ContentType",extension:"Extension"})}}class Wu extends $e{constructor(e,r){super("Default"),this.root.push(new fAt({contentType:e,extension:r}))}}class pAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{contentType:"ContentType",partName:"PartName"})}}class zo extends $e{constructor(e,r){super("Override"),this.root.push(new pAt({contentType:e,partName:r}))}}class mAt extends $e{constructor(){super("Types"),this.root.push(new hAt({xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"})),this.root.push(new Wu("image/png","png")),this.root.push(new Wu("image/jpeg","jpeg")),this.root.push(new Wu("image/jpeg","jpg")),this.root.push(new Wu("image/bmp","bmp")),this.root.push(new Wu("image/gif","gif")),this.root.push(new Wu("image/svg+xml","svg")),this.root.push(new Wu("application/vnd.openxmlformats-package.relationships+xml","rels")),this.root.push(new Wu("application/xml","xml")),this.root.push(new Wu("application/vnd.openxmlformats-officedocument.obfuscatedFont","odttf")),this.root.push(new zo("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml","/word/document.xml")),this.root.push(new zo("application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml","/word/styles.xml")),this.root.push(new zo("application/vnd.openxmlformats-package.core-properties+xml","/docProps/core.xml")),this.root.push(new zo("application/vnd.openxmlformats-officedocument.custom-properties+xml","/docProps/custom.xml")),this.root.push(new zo("application/vnd.openxmlformats-officedocument.extended-properties+xml","/docProps/app.xml")),this.root.push(new zo("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml","/word/numbering.xml")),this.root.push(new zo("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml","/word/footnotes.xml")),this.root.push(new zo("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml","/word/settings.xml")),this.root.push(new zo("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml","/word/comments.xml")),this.root.push(new zo("application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml","/word/fontTable.xml"))}addFooter(e){this.root.push(new zo("application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",`/word/footer${e}.xml`))}addHeader(e){this.root.push(new zo("application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml",`/word/header${e}.xml`))}}class gAt extends $e{constructor(e){super("cp:coreProperties"),this.root.push(new oD(["cp","dc","dcterms","dcmitype","xsi"])),e.title&&this.root.push(new Am("dc:title",e.title)),e.subject&&this.root.push(new Am("dc:subject",e.subject)),e.creator&&this.root.push(new Am("dc:creator",e.creator)),e.keywords&&this.root.push(new Am("cp:keywords",e.keywords)),e.description&&this.root.push(new Am("dc:description",e.description)),e.lastModifiedBy&&this.root.push(new Am("cp:lastModifiedBy",e.lastModifiedBy)),e.revision&&this.root.push(new Am("cp:revision",String(e.revision))),this.root.push(new cse("dcterms:created")),this.root.push(new cse("dcterms:modified"))}}class yAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{type:"xsi:type"})}}class cse extends $e{constructor(e){super(e),this.root.push(new yAt({type:"dcterms:W3CDTF"})),this.root.push(jNt(new Date))}}class xAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{xmlns:"xmlns",vt:"xmlns:vt"})}}class vAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{fmtid:"fmtid",pid:"pid",name:"name"})}}class bAt extends $e{constructor(e,r){super("property"),this.root.push(new vAt({fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:e.toString(),name:r.name})),this.root.push(new wAt(r.value))}}class wAt extends $e{constructor(e){super("vt:lpwstr"),this.root.push(e)}}class SAt extends $e{constructor(e){super("Properties"),Fe(this,"nextId"),Fe(this,"properties",[]),this.root.push(new xAt({xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"})),this.nextId=2;for(const r of e)this.addCustomProperty(r)}prepForXml(e){return this.properties.forEach(r=>this.root.push(r)),super.prepForXml(e)}addCustomProperty(e){this.properties.push(new bAt(this.nextId++,e))}}const kC=({id:t,fontKey:e,subsetted:r},n)=>new Tu({name:n,attributes:fr({id:{key:"r:id",value:t}},e?{fontKey:{key:"w:fontKey",value:`{${e}}`}}:{}),children:[...r?[new He("w:subsetted",r)]:[]]}),_At=({name:t,altName:e,panose1:r,charset:n,family:s,notTrueType:i,pitch:a,sig:o,embedRegular:c,embedBold:u,embedItalic:d,embedBoldItalic:h})=>new Tu({name:"w:font",attributes:{name:{key:"w:name",value:t}},children:[...e?[X1("w:altName",e)]:[],...r?[X1("w:panose1",r)]:[],...n?[X1("w:charset",n)]:[],X1("w:family",s),...i?[new He("w:notTrueType",i)]:[],X1("w:pitch",a),...o?[new Tu({name:"w:sig",attributes:{usb0:{key:"w:usb0",value:o.usb0},usb1:{key:"w:usb1",value:o.usb1},usb2:{key:"w:usb2",value:o.usb2},usb3:{key:"w:usb3",value:o.usb3},csb0:{key:"w:csb0",value:o.csb0},csb1:{key:"w:csb1",value:o.csb1}}})]:[],...c?[kC(c,"w:embedRegular")]:[],...u?[kC(u,"w:embedBold")]:[],...d?[kC(d,"w:embedItalic")]:[],...h?[kC(h,"w:embedBoldItalic")]:[]]}),jAt=({name:t,index:e,fontKey:r,characterSet:n})=>_At({name:t,sig:{usb0:"E0002AFF",usb1:"C000247B",usb2:"00000009",usb3:"00000000",csb0:"000001FF",csb1:"00000000"},charset:n,family:"auto",pitch:"variable",embedRegular:{fontKey:r,id:`rId${e}`}}),kAt=t=>new Tu({name:"w:fonts",attributes:{mc:{key:"xmlns:mc",value:"http://schemas.openxmlformats.org/markup-compatibility/2006"},r:{key:"xmlns:r",value:"http://schemas.openxmlformats.org/officeDocument/2006/relationships"},w:{key:"xmlns:w",value:"http://schemas.openxmlformats.org/wordprocessingml/2006/main"},w14:{key:"xmlns:w14",value:"http://schemas.microsoft.com/office/word/2010/wordml"},w15:{key:"xmlns:w15",value:"http://schemas.microsoft.com/office/word/2012/wordml"},w16cex:{key:"xmlns:w16cex",value:"http://schemas.microsoft.com/office/word/2018/wordml/cex"},w16cid:{key:"xmlns:w16cid",value:"http://schemas.microsoft.com/office/word/2016/wordml/cid"},w16:{key:"xmlns:w16",value:"http://schemas.microsoft.com/office/word/2018/wordml"},w16sdtdh:{key:"xmlns:w16sdtdh",value:"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash"},w16se:{key:"xmlns:w16se",value:"http://schemas.microsoft.com/office/word/2015/wordml/symex"},Ignorable:{key:"mc:Ignorable",value:"w14 w15 w16se w16cid w16 w16cex w16sdtdh"}},children:t.map((e,r)=>jAt({name:e.name,index:r+1,fontKey:e.fontKey}))});class NAt{constructor(e){Fe(this,"fontTable"),Fe(this,"relationships"),Fe(this,"fontOptionsWithKey",[]),this.options=e,this.fontOptionsWithKey=e.map(r=>ww(fr({},r),{fontKey:dEt()})),this.fontTable=kAt(this.fontOptionsWithKey),this.relationships=new Tx;for(let r=0;r<e.length;r++)this.relationships.createRelationship(r+1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/font",`fonts/${e[r].name}.odttf`)}get View(){return this.fontTable}get Relationships(){return this.relationships}}class EAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",cp:"xmlns:cp",dc:"xmlns:dc",dcterms:"xmlns:dcterms",dcmitype:"xmlns:dcmitype",xsi:"xmlns:xsi",type:"xsi:type"})}}let AAt=class extends USe{constructor(e,r){super("w:ftr",r),Fe(this,"refId"),this.refId=e,r||this.root.push(new EAt({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape"}))}get ReferenceId(){return this.refId}add(e){this.root.push(e)}};class CAt{constructor(e,r,n){Fe(this,"footer"),Fe(this,"relationships"),this.media=e,this.footer=new AAt(r,n),this.relationships=new Tx}add(e){this.footer.add(e)}addChildElement(e){this.footer.addChildElement(e)}get View(){return this.footer}get Relationships(){return this.relationships}get Media(){return this.media}}class TAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{type:"w:type",id:"w:id"})}}class PAt extends $e{constructor(){super("w:footnoteRef")}}class OAt extends ox{constructor(){super({style:"FootnoteReference"}),this.root.push(new PAt)}}const use={SEPERATOR:"separator",CONTINUATION_SEPERATOR:"continuationSeparator"};class D3 extends $e{constructor(e){super("w:footnote"),this.root.push(new TAt({type:e.type,id:e.id}));for(let r=0;r<e.children.length;r++){const n=e.children[r];r===0&&n.addRunToFront(new OAt),this.root.push(n)}}}class IAt extends $e{constructor(){super("w:continuationSeparator")}}class RAt extends ox{constructor(){super({}),this.root.push(new IAt)}}class MAt extends $e{constructor(){super("w:separator")}}class DAt extends ox{constructor(){super({}),this.root.push(new MAt)}}class LAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",Ignorable:"mc:Ignorable"})}}class FAt extends $e{constructor(){super("w:footnotes"),this.root.push(new LAt({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",Ignorable:"w14 w15 wp14"}));const e=new D3({id:-1,type:use.SEPERATOR,children:[new on({spacing:{after:0,line:240,lineRule:Hz.AUTO},children:[new DAt]})]});this.root.push(e);const r=new D3({id:0,type:use.CONTINUATION_SEPERATOR,children:[new on({spacing:{after:0,line:240,lineRule:Hz.AUTO},children:[new RAt]})]});this.root.push(r)}createFootNote(e,r){const n=new D3({id:e,children:r});this.root.push(n)}}class $At{constructor(){Fe(this,"footnotess"),Fe(this,"relationships"),this.footnotess=new FAt,this.relationships=new Tx}get View(){return this.footnotess}get Relationships(){return this.relationships}}class BAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",cp:"xmlns:cp",dc:"xmlns:dc",dcterms:"xmlns:dcterms",dcmitype:"xmlns:dcmitype",xsi:"xmlns:xsi",type:"xsi:type",cx:"xmlns:cx",cx1:"xmlns:cx1",cx2:"xmlns:cx2",cx3:"xmlns:cx3",cx4:"xmlns:cx4",cx5:"xmlns:cx5",cx6:"xmlns:cx6",cx7:"xmlns:cx7",cx8:"xmlns:cx8",w16cid:"xmlns:w16cid",w16se:"xmlns:w16se"})}}let zAt=class extends USe{constructor(e,r){super("w:hdr",r),Fe(this,"refId"),this.refId=e,r||this.root.push(new BAt({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",cx:"http://schemas.microsoft.com/office/drawing/2014/chartex",cx1:"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex",cx2:"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex",cx3:"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex",cx4:"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex",cx5:"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex",cx6:"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex",cx7:"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex",cx8:"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex",w16cid:"http://schemas.microsoft.com/office/word/2016/wordml/cid",w16se:"http://schemas.microsoft.com/office/word/2015/wordml/symex"}))}get ReferenceId(){return this.refId}add(e){this.root.push(e)}};class UAt{constructor(e,r,n){Fe(this,"header"),Fe(this,"relationships"),this.media=e,this.header=new zAt(r,n),this.relationships=new Tx}add(e){return this.header.add(e),this}addChildElement(e){this.header.addChildElement(e)}get View(){return this.header}get Relationships(){return this.relationships}get Media(){return this.media}}class HAt{constructor(){Fe(this,"map"),this.map=new Map}addImage(e,r){this.map.set(e,r)}get Array(){return Array.from(this.map.values())}}const qu={DECIMAL:"decimal",UPPER_ROMAN:"upperRoman",LOWER_ROMAN:"lowerRoman",UPPER_LETTER:"upperLetter",LOWER_LETTER:"lowerLetter",ORDINAL:"ordinal",CARDINAL_TEXT:"cardinalText",ORDINAL_TEXT:"ordinalText",HEX:"hex",CHICAGO:"chicago",IDEOGRAPH__DIGITAL:"ideographDigital",JAPANESE_COUNTING:"japaneseCounting",AIUEO:"aiueo",IROHA:"iroha",DECIMAL_FULL_WIDTH:"decimalFullWidth",DECIMAL_HALF_WIDTH:"decimalHalfWidth",JAPANESE_LEGAL:"japaneseLegal",JAPANESE_DIGITAL_TEN_THOUSAND:"japaneseDigitalTenThousand",DECIMAL_ENCLOSED_CIRCLE:"decimalEnclosedCircle",DECIMAL_FULL_WIDTH2:"decimalFullWidth2",AIUEO_FULL_WIDTH:"aiueoFullWidth",IROHA_FULL_WIDTH:"irohaFullWidth",DECIMAL_ZERO:"decimalZero",BULLET:"bullet",GANADA:"ganada",CHOSUNG:"chosung",DECIMAL_ENCLOSED_FULLSTOP:"decimalEnclosedFullstop",DECIMAL_ENCLOSED_PARENTHESES:"decimalEnclosedParen",DECIMAL_ENCLOSED_CIRCLE_CHINESE:"decimalEnclosedCircleChinese",IDEOGRAPH_ENCLOSED_CIRCLE:"ideographEnclosedCircle",IDEOGRAPH_TRADITIONAL:"ideographTraditional",IDEOGRAPH_ZODIAC:"ideographZodiac",IDEOGRAPH_ZODIAC_TRADITIONAL:"ideographZodiacTraditional",TAIWANESE_COUNTING:"taiwaneseCounting",IDEOGRAPH_LEGAL_TRADITIONAL:"ideographLegalTraditional",TAIWANESE_COUNTING_THOUSAND:"taiwaneseCountingThousand",TAIWANESE_DIGITAL:"taiwaneseDigital",CHINESE_COUNTING:"chineseCounting",CHINESE_LEGAL_SIMPLIFIED:"chineseLegalSimplified",CHINESE_COUNTING_THOUSAND:"chineseCountingThousand",KOREAN_DIGITAL:"koreanDigital",KOREAN_COUNTING:"koreanCounting",KOREAN_LEGAL:"koreanLegal",KOREAN_DIGITAL2:"koreanDigital2",VIETNAMESE_COUNTING:"vietnameseCounting",RUSSIAN_LOWER:"russianLower",RUSSIAN_UPPER:"russianUpper",NONE:"none",NUMBER_IN_DASH:"numberInDash",HEBREW1:"hebrew1",HEBREW2:"hebrew2",ARABIC_ALPHA:"arabicAlpha",ARABIC_ABJAD:"arabicAbjad",HINDI_VOWELS:"hindiVowels",HINDI_CONSONANTS:"hindiConsonants",HINDI_NUMBERS:"hindiNumbers",HINDI_COUNTING:"hindiCounting",THAI_LETTERS:"thaiLetters",THAI_NUMBERS:"thaiNumbers",THAI_COUNTING:"thaiCounting",BAHT_TEXT:"bahtText",DOLLAR_TEXT:"dollarText",CUSTOM:"custom"};class VAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{ilvl:"w:ilvl",tentative:"w15:tentative"})}}class WAt extends $e{constructor(e){super("w:numFmt"),this.root.push(new Gn({val:e}))}}class qAt extends $e{constructor(e){super("w:lvlText"),this.root.push(new Gn({val:e}))}}class GAt extends $e{constructor(e){super("w:lvlJc"),this.root.push(new Gn({val:e}))}}class KAt extends $e{constructor(e){super("w:suff"),this.root.push(new Gn({val:e}))}}class YAt extends $e{constructor(){super("w:isLgl")}}class XAt extends $e{constructor({level:e,format:r,text:n,alignment:s=Xn.START,start:i=1,style:a,suffix:o,isLegalNumberingStyle:c}){if(super("w:lvl"),Fe(this,"paragraphProperties"),Fe(this,"runProperties"),this.root.push(new N_("w:start",Ja(i))),r&&this.root.push(new WAt(r)),o&&this.root.push(new KAt(o)),c&&this.root.push(new YAt),n&&this.root.push(new qAt(n)),this.root.push(new GAt(s)),this.paragraphProperties=new jw(a&&a.paragraph),this.runProperties=new Cx(a&&a.run),this.root.push(this.paragraphProperties),this.root.push(this.runProperties),e>9)throw new Error("Level cannot be greater than 9. Read more here: https://answers.microsoft.com/en-us/msoffice/forum/all/does-word-support-more-than-9-list-levels/d130fdcd-1781-446d-8c84-c6c79124e4d7");this.root.push(new VAt({ilvl:Ja(e),tentative:1}))}}class JAt extends XAt{}class QAt extends $e{constructor(e){super("w:multiLevelType"),this.root.push(new Gn({val:e}))}}class ZAt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{abstractNumId:"w:abstractNumId",restartNumberingAfterBreak:"w15:restartNumberingAfterBreak"})}}class dse extends $e{constructor(e,r){super("w:abstractNum"),Fe(this,"id"),this.root.push(new ZAt({abstractNumId:Ja(e),restartNumberingAfterBreak:0})),this.root.push(new QAt("hybridMultilevel")),this.id=e;for(const n of r)this.root.push(new JAt(n))}}class eCt extends $e{constructor(e){super("w:abstractNumId"),this.root.push(new Gn({val:e}))}}class tCt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{numId:"w:numId"})}}class hse extends $e{constructor(e){if(super("w:num"),Fe(this,"numId"),Fe(this,"reference"),Fe(this,"instance"),this.numId=e.numId,this.reference=e.reference,this.instance=e.instance,this.root.push(new tCt({numId:Ja(e.numId)})),this.root.push(new eCt(Ja(e.abstractNumId))),e.overrideLevels&&e.overrideLevels.length)for(const r of e.overrideLevels)this.root.push(new nCt(r.num,r.start))}}class rCt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{ilvl:"w:ilvl"})}}class nCt extends $e{constructor(e,r){super("w:lvlOverride"),this.root.push(new rCt({ilvl:e})),r!==void 0&&this.root.push(new iCt(r))}}class sCt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{val:"w:val"})}}class iCt extends $e{constructor(e){super("w:startOverride"),this.root.push(new sCt({val:e}))}}class aCt extends $e{constructor(e){super("w:numbering"),Fe(this,"abstractNumberingMap",new Map),Fe(this,"concreteNumberingMap",new Map),Fe(this,"referenceConfigMap",new Map),Fe(this,"abstractNumUniqueNumericId",oEt()),Fe(this,"concreteNumUniqueNumericId",lEt()),this.root.push(new oD(["wpc","mc","o","r","m","v","wp14","wp","w10","w","w14","w15","wpg","wpi","wne","wps"],"w14 w15 wp14"));const r=new dse(this.abstractNumUniqueNumericId(),[{level:0,format:qu.BULLET,text:"●",alignment:Xn.LEFT,style:{paragraph:{indent:{left:Ll(.5),hanging:Ll(.25)}}}},{level:1,format:qu.BULLET,text:"○",alignment:Xn.LEFT,style:{paragraph:{indent:{left:Ll(1),hanging:Ll(.25)}}}},{level:2,format:qu.BULLET,text:"■",alignment:Xn.LEFT,style:{paragraph:{indent:{left:2160,hanging:Ll(.25)}}}},{level:3,format:qu.BULLET,text:"●",alignment:Xn.LEFT,style:{paragraph:{indent:{left:2880,hanging:Ll(.25)}}}},{level:4,format:qu.BULLET,text:"○",alignment:Xn.LEFT,style:{paragraph:{indent:{left:3600,hanging:Ll(.25)}}}},{level:5,format:qu.BULLET,text:"■",alignment:Xn.LEFT,style:{paragraph:{indent:{left:4320,hanging:Ll(.25)}}}},{level:6,format:qu.BULLET,text:"●",alignment:Xn.LEFT,style:{paragraph:{indent:{left:5040,hanging:Ll(.25)}}}},{level:7,format:qu.BULLET,text:"●",alignment:Xn.LEFT,style:{paragraph:{indent:{left:5760,hanging:Ll(.25)}}}},{level:8,format:qu.BULLET,text:"●",alignment:Xn.LEFT,style:{paragraph:{indent:{left:6480,hanging:Ll(.25)}}}}]);this.concreteNumberingMap.set("default-bullet-numbering",new hse({numId:1,abstractNumId:r.id,reference:"default-bullet-numbering",instance:0,overrideLevels:[{num:0,start:1}]})),this.abstractNumberingMap.set("default-bullet-numbering",r);for(const n of e.config)this.abstractNumberingMap.set(n.reference,new dse(this.abstractNumUniqueNumericId(),n.levels)),this.referenceConfigMap.set(n.reference,n.levels)}prepForXml(e){for(const r of this.abstractNumberingMap.values())this.root.push(r);for(const r of this.concreteNumberingMap.values())this.root.push(r);return super.prepForXml(e)}createConcreteNumberingInstance(e,r){const n=this.abstractNumberingMap.get(e);if(!n)return;const s=`${e}-${r}`;if(this.concreteNumberingMap.has(s))return;const i=this.referenceConfigMap.get(e),a=i&&i[0].start,o={numId:this.concreteNumUniqueNumericId(),abstractNumId:n.id,reference:e,instance:r,overrideLevels:[a&&Number.isInteger(a)?{num:0,start:a}:{num:0,start:1}]};this.concreteNumberingMap.set(s,new hse(o))}get ConcreteNumbering(){return Array.from(this.concreteNumberingMap.values())}get ReferenceConfig(){return Array.from(this.referenceConfigMap.values())}}class oCt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{version:"w:val",name:"w:name",uri:"w:uri"})}}class lCt extends $e{constructor(e){super("w:compatSetting"),this.root.push(new oCt({version:e,uri:"http://schemas.microsoft.com/office/word",name:"compatibilityMode"}))}}class cCt extends $e{constructor(e){super("w:compat"),e.version&&this.root.push(new lCt(e.version)),e.useSingleBorderforContiguousCells&&this.root.push(new He("w:useSingleBorderforContiguousCells",e.useSingleBorderforContiguousCells)),e.wordPerfectJustification&&this.root.push(new He("w:wpJustification",e.wordPerfectJustification)),e.noTabStopForHangingIndent&&this.root.push(new He("w:noTabHangInd",e.noTabStopForHangingIndent)),e.noLeading&&this.root.push(new He("w:noLeading",e.noLeading)),e.spaceForUnderline&&this.root.push(new He("w:spaceForUL",e.spaceForUnderline)),e.noColumnBalance&&this.root.push(new He("w:noColumnBalance",e.noColumnBalance)),e.balanceSingleByteDoubleByteWidth&&this.root.push(new He("w:balanceSingleByteDoubleByteWidth",e.balanceSingleByteDoubleByteWidth)),e.noExtraLineSpacing&&this.root.push(new He("w:noExtraLineSpacing",e.noExtraLineSpacing)),e.doNotLeaveBackslashAlone&&this.root.push(new He("w:doNotLeaveBackslashAlone",e.doNotLeaveBackslashAlone)),e.underlineTrailingSpaces&&this.root.push(new He("w:ulTrailSpace",e.underlineTrailingSpaces)),e.doNotExpandShiftReturn&&this.root.push(new He("w:doNotExpandShiftReturn",e.doNotExpandShiftReturn)),e.spacingInWholePoints&&this.root.push(new He("w:spacingInWholePoints",e.spacingInWholePoints)),e.lineWrapLikeWord6&&this.root.push(new He("w:lineWrapLikeWord6",e.lineWrapLikeWord6)),e.printBodyTextBeforeHeader&&this.root.push(new He("w:printBodyTextBeforeHeader",e.printBodyTextBeforeHeader)),e.printColorsBlack&&this.root.push(new He("w:printColBlack",e.printColorsBlack)),e.spaceWidth&&this.root.push(new He("w:wpSpaceWidth",e.spaceWidth)),e.showBreaksInFrames&&this.root.push(new He("w:showBreaksInFrames",e.showBreaksInFrames)),e.subFontBySize&&this.root.push(new He("w:subFontBySize",e.subFontBySize)),e.suppressBottomSpacing&&this.root.push(new He("w:suppressBottomSpacing",e.suppressBottomSpacing)),e.suppressTopSpacing&&this.root.push(new He("w:suppressTopSpacing",e.suppressTopSpacing)),e.suppressSpacingAtTopOfPage&&this.root.push(new He("w:suppressSpacingAtTopOfPage",e.suppressSpacingAtTopOfPage)),e.suppressTopSpacingWP&&this.root.push(new He("w:suppressTopSpacingWP",e.suppressTopSpacingWP)),e.suppressSpBfAfterPgBrk&&this.root.push(new He("w:suppressSpBfAfterPgBrk",e.suppressSpBfAfterPgBrk)),e.swapBordersFacingPages&&this.root.push(new He("w:swapBordersFacingPages",e.swapBordersFacingPages)),e.convertMailMergeEsc&&this.root.push(new He("w:convMailMergeEsc",e.convertMailMergeEsc)),e.truncateFontHeightsLikeWP6&&this.root.push(new He("w:truncateFontHeightsLikeWP6",e.truncateFontHeightsLikeWP6)),e.macWordSmallCaps&&this.root.push(new He("w:mwSmallCaps",e.macWordSmallCaps)),e.usePrinterMetrics&&this.root.push(new He("w:usePrinterMetrics",e.usePrinterMetrics)),e.doNotSuppressParagraphBorders&&this.root.push(new He("w:doNotSuppressParagraphBorders",e.doNotSuppressParagraphBorders)),e.wrapTrailSpaces&&this.root.push(new He("w:wrapTrailSpaces",e.wrapTrailSpaces)),e.footnoteLayoutLikeWW8&&this.root.push(new He("w:footnoteLayoutLikeWW8",e.footnoteLayoutLikeWW8)),e.shapeLayoutLikeWW8&&this.root.push(new He("w:shapeLayoutLikeWW8",e.shapeLayoutLikeWW8)),e.alignTablesRowByRow&&this.root.push(new He("w:alignTablesRowByRow",e.alignTablesRowByRow)),e.forgetLastTabAlignment&&this.root.push(new He("w:forgetLastTabAlignment",e.forgetLastTabAlignment)),e.adjustLineHeightInTable&&this.root.push(new He("w:adjustLineHeightInTable",e.adjustLineHeightInTable)),e.autoSpaceLikeWord95&&this.root.push(new He("w:autoSpaceLikeWord95",e.autoSpaceLikeWord95)),e.noSpaceRaiseLower&&this.root.push(new He("w:noSpaceRaiseLower",e.noSpaceRaiseLower)),e.doNotUseHTMLParagraphAutoSpacing&&this.root.push(new He("w:doNotUseHTMLParagraphAutoSpacing",e.doNotUseHTMLParagraphAutoSpacing)),e.layoutRawTableWidth&&this.root.push(new He("w:layoutRawTableWidth",e.layoutRawTableWidth)),e.layoutTableRowsApart&&this.root.push(new He("w:layoutTableRowsApart",e.layoutTableRowsApart)),e.useWord97LineBreakRules&&this.root.push(new He("w:useWord97LineBreakRules",e.useWord97LineBreakRules)),e.doNotBreakWrappedTables&&this.root.push(new He("w:doNotBreakWrappedTables",e.doNotBreakWrappedTables)),e.doNotSnapToGridInCell&&this.root.push(new He("w:doNotSnapToGridInCell",e.doNotSnapToGridInCell)),e.selectFieldWithFirstOrLastCharacter&&this.root.push(new He("w:selectFldWithFirstOrLastChar",e.selectFieldWithFirstOrLastCharacter)),e.applyBreakingRules&&this.root.push(new He("w:applyBreakingRules",e.applyBreakingRules)),e.doNotWrapTextWithPunctuation&&this.root.push(new He("w:doNotWrapTextWithPunct",e.doNotWrapTextWithPunctuation)),e.doNotUseEastAsianBreakRules&&this.root.push(new He("w:doNotUseEastAsianBreakRules",e.doNotUseEastAsianBreakRules)),e.useWord2002TableStyleRules&&this.root.push(new He("w:useWord2002TableStyleRules",e.useWord2002TableStyleRules)),e.growAutofit&&this.root.push(new He("w:growAutofit",e.growAutofit)),e.useFELayout&&this.root.push(new He("w:useFELayout",e.useFELayout)),e.useNormalStyleForList&&this.root.push(new He("w:useNormalStyleForList",e.useNormalStyleForList)),e.doNotUseIndentAsNumberingTabStop&&this.root.push(new He("w:doNotUseIndentAsNumberingTabStop",e.doNotUseIndentAsNumberingTabStop)),e.useAlternateEastAsianLineBreakRules&&this.root.push(new He("w:useAltKinsokuLineBreakRules",e.useAlternateEastAsianLineBreakRules)),e.allowSpaceOfSameStyleInTable&&this.root.push(new He("w:allowSpaceOfSameStyleInTable",e.allowSpaceOfSameStyleInTable)),e.doNotSuppressIndentation&&this.root.push(new He("w:doNotSuppressIndentation",e.doNotSuppressIndentation)),e.doNotAutofitConstrainedTables&&this.root.push(new He("w:doNotAutofitConstrainedTables",e.doNotAutofitConstrainedTables)),e.autofitToFirstFixedWidthCell&&this.root.push(new He("w:autofitToFirstFixedWidthCell",e.autofitToFirstFixedWidthCell)),e.underlineTabInNumberingList&&this.root.push(new He("w:underlineTabInNumList",e.underlineTabInNumberingList)),e.displayHangulFixedWidth&&this.root.push(new He("w:displayHangulFixedWidth",e.displayHangulFixedWidth)),e.splitPgBreakAndParaMark&&this.root.push(new He("w:splitPgBreakAndParaMark",e.splitPgBreakAndParaMark)),e.doNotVerticallyAlignCellWithSp&&this.root.push(new He("w:doNotVertAlignCellWithSp",e.doNotVerticallyAlignCellWithSp)),e.doNotBreakConstrainedForcedTable&&this.root.push(new He("w:doNotBreakConstrainedForcedTable",e.doNotBreakConstrainedForcedTable)),e.ignoreVerticalAlignmentInTextboxes&&this.root.push(new He("w:doNotVertAlignInTxbx",e.ignoreVerticalAlignmentInTextboxes)),e.useAnsiKerningPairs&&this.root.push(new He("w:useAnsiKerningPairs",e.useAnsiKerningPairs)),e.cachedColumnBalance&&this.root.push(new He("w:cachedColBalance",e.cachedColumnBalance))}}class uCt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{wpc:"xmlns:wpc",mc:"xmlns:mc",o:"xmlns:o",r:"xmlns:r",m:"xmlns:m",v:"xmlns:v",wp14:"xmlns:wp14",wp:"xmlns:wp",w10:"xmlns:w10",w:"xmlns:w",w14:"xmlns:w14",w15:"xmlns:w15",wpg:"xmlns:wpg",wpi:"xmlns:wpi",wne:"xmlns:wne",wps:"xmlns:wps",Ignorable:"mc:Ignorable"})}}class dCt extends $e{constructor(e){var r,n,s,i,a,o,c,u;super("w:settings"),this.root.push(new uCt({wpc:"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",mc:"http://schemas.openxmlformats.org/markup-compatibility/2006",o:"urn:schemas-microsoft-com:office:office",r:"http://schemas.openxmlformats.org/officeDocument/2006/relationships",m:"http://schemas.openxmlformats.org/officeDocument/2006/math",v:"urn:schemas-microsoft-com:vml",wp14:"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",wp:"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",w10:"urn:schemas-microsoft-com:office:word",w:"http://schemas.openxmlformats.org/wordprocessingml/2006/main",w14:"http://schemas.microsoft.com/office/word/2010/wordml",w15:"http://schemas.microsoft.com/office/word/2012/wordml",wpg:"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",wpi:"http://schemas.microsoft.com/office/word/2010/wordprocessingInk",wne:"http://schemas.microsoft.com/office/word/2006/wordml",wps:"http://schemas.microsoft.com/office/word/2010/wordprocessingShape",Ignorable:"w14 w15 wp14"})),this.root.push(new He("w:displayBackgroundShape",!0)),e.trackRevisions!==void 0&&this.root.push(new He("w:trackRevisions",e.trackRevisions)),e.evenAndOddHeaders!==void 0&&this.root.push(new He("w:evenAndOddHeaders",e.evenAndOddHeaders)),e.updateFields!==void 0&&this.root.push(new He("w:updateFields",e.updateFields)),e.defaultTabStop!==void 0&&this.root.push(new N_("w:defaultTabStop",e.defaultTabStop)),((r=e.hyphenation)==null?void 0:r.autoHyphenation)!==void 0&&this.root.push(new He("w:autoHyphenation",e.hyphenation.autoHyphenation)),((n=e.hyphenation)==null?void 0:n.hyphenationZone)!==void 0&&this.root.push(new N_("w:hyphenationZone",e.hyphenation.hyphenationZone)),((s=e.hyphenation)==null?void 0:s.consecutiveHyphenLimit)!==void 0&&this.root.push(new N_("w:consecutiveHyphenLimit",e.hyphenation.consecutiveHyphenLimit)),((i=e.hyphenation)==null?void 0:i.doNotHyphenateCaps)!==void 0&&this.root.push(new He("w:doNotHyphenateCaps",e.hyphenation.doNotHyphenateCaps)),this.root.push(new cCt(ww(fr({},(a=e.compatibility)!=null?a:{}),{version:(u=(c=(o=e.compatibility)==null?void 0:o.version)!=null?c:e.compatibilityModeVersion)!=null?u:15})))}}class e_e extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{val:"w:val"})}}class hCt extends $e{constructor(e){super("w:name"),this.root.push(new e_e({val:e}))}}class fCt extends $e{constructor(e){super("w:uiPriority"),this.root.push(new e_e({val:Ja(e)}))}}class pCt extends Rt{constructor(){super(...arguments),Fe(this,"xmlKeys",{type:"w:type",styleId:"w:styleId",default:"w:default",customStyle:"w:customStyle"})}}class t_e extends $e{constructor(e,r){super("w:style"),this.root.push(new pCt(e)),r.name&&this.root.push(new hCt(r.name)),r.basedOn&&this.root.push(new My("w:basedOn",r.basedOn)),r.next&&this.root.push(new My("w:next",r.next)),r.link&&this.root.push(new My("w:link",r.link)),r.uiPriority!==void 0&&this.root.push(new fCt(r.uiPriority)),r.semiHidden!==void 0&&this.root.push(new He("w:semiHidden",r.semiHidden)),r.unhideWhenUsed!==void 0&&this.root.push(new He("w:unhideWhenUsed",r.unhideWhenUsed)),r.quickFormat!==void 0&&this.root.push(new He("w:qFormat",r.quickFormat))}}class lD extends t_e{constructor(e){super({type:"paragraph",styleId:e.id},e),Fe(this,"paragraphProperties"),Fe(this,"runProperties"),this.paragraphProperties=new jw(e.paragraph),this.runProperties=new Cx(e.run),this.root.push(this.paragraphProperties),this.root.push(this.runProperties)}}class cD extends t_e{constructor(e){super({type:"character",styleId:e.id},fr({uiPriority:99,unhideWhenUsed:!0},e)),Fe(this,"runProperties"),this.runProperties=new Cx(e.run),this.root.push(this.runProperties)}}class ym extends lD{constructor(e){super(fr({basedOn:"Normal",next:"Normal",quickFormat:!0},e))}}class mCt extends ym{constructor(e){super(fr({id:"Title",name:"Title"},e))}}class gCt extends ym{constructor(e){super(fr({id:"Heading1",name:"Heading 1"},e))}}class yCt extends ym{constructor(e){super(fr({id:"Heading2",name:"Heading 2"},e))}}class xCt extends ym{constructor(e){super(fr({id:"Heading3",name:"Heading 3"},e))}}class vCt extends ym{constructor(e){super(fr({id:"Heading4",name:"Heading 4"},e))}}class bCt extends ym{constructor(e){super(fr({id:"Heading5",name:"Heading 5"},e))}}class wCt extends ym{constructor(e){super(fr({id:"Heading6",name:"Heading 6"},e))}}class SCt extends ym{constructor(e){super(fr({id:"Strong",name:"Strong"},e))}}class _Ct extends lD{constructor(e){super(fr({id:"ListParagraph",name:"List Paragraph",basedOn:"Normal",quickFormat:!0},e))}}class jCt extends lD{constructor(e){super(fr({id:"FootnoteText",name:"footnote text",link:"FootnoteTextChar",basedOn:"Normal",uiPriority:99,semiHidden:!0,unhideWhenUsed:!0,paragraph:{spacing:{after:0,line:240,lineRule:Hz.AUTO}},run:{size:20}},e))}}class kCt extends cD{constructor(e){super(fr({id:"FootnoteReference",name:"footnote reference",basedOn:"DefaultParagraphFont",semiHidden:!0,run:{superScript:!0}},e))}}class NCt extends cD{constructor(e){super(fr({id:"FootnoteTextChar",name:"Footnote Text Char",basedOn:"DefaultParagraphFont",link:"FootnoteText",semiHidden:!0,run:{size:20}},e))}}class ECt extends cD{constructor(e){super(fr({id:"Hyperlink",name:"Hyperlink",basedOn:"DefaultParagraphFont",run:{color:"0563C1",underline:{type:KSe.SINGLE}}},e))}}class Wz extends $e{constructor(e){if(super("w:styles"),e.initialStyles&&this.root.push(e.initialStyles),e.importedStyles)for(const r of e.importedStyles)this.root.push(r);if(e.paragraphStyles)for(const r of e.paragraphStyles)this.root.push(new lD(r));if(e.characterStyles)for(const r of e.characterStyles)this.root.push(new cD(r))}}class ACt extends $e{constructor(e){super("w:pPrDefault"),this.root.push(new jw(e))}}class CCt extends $e{constructor(e){super("w:rPrDefault"),this.root.push(new Cx(e))}}class TCt extends $e{constructor(e){super("w:docDefaults"),Fe(this,"runPropertiesDefaults"),Fe(this,"paragraphPropertiesDefaults"),this.runPropertiesDefaults=new CCt(e.run),this.paragraphPropertiesDefaults=new ACt(e.paragraph),this.root.push(this.runPropertiesDefaults),this.root.push(this.paragraphPropertiesDefaults)}}class PCt{newInstance(e){const r=zSe.xml2js(e,{compact:!1});let n;for(const a of r.elements||[])a.name==="w:styles"&&(n=a);if(n===void 0)throw new Error("can not find styles element");const s=n.elements||[];return new Wz({initialStyles:new bNt(n.attributes),importedStyles:s.map(a=>y7(a))})}}class fse{newInstance(e={}){var r;return{initialStyles:new oD(["mc","r","w","w14","w15"],"w14 w15"),importedStyles:[new TCt((r=e.document)!=null?r:{}),new mCt(fr({run:{size:56}},e.title)),new gCt(fr({run:{color:"2E74B5",size:32}},e.heading1)),new yCt(fr({run:{color:"2E74B5",size:26}},e.heading2)),new xCt(fr({run:{color:"1F4D78",size:24}},e.heading3)),new vCt(fr({run:{color:"2E74B5",italics:!0}},e.heading4)),new bCt(fr({run:{color:"2E74B5"}},e.heading5)),new wCt(fr({run:{color:"1F4D78"}},e.heading6)),new SCt(fr({run:{bold:!0}},e.strong)),new _Ct(e.listParagraph||{}),new ECt(e.hyperlink||{}),new kCt(e.footnoteReference||{}),new jCt(e.footnoteText||{}),new NCt(e.footnoteTextChar||{})]}}}let OCt=class{constructor(e){Fe(this,"currentRelationshipId",1),Fe(this,"documentWrapper"),Fe(this,"headers",[]),Fe(this,"footers",[]),Fe(this,"coreProperties"),Fe(this,"numbering"),Fe(this,"media"),Fe(this,"fileRelationships"),Fe(this,"footnotesWrapper"),Fe(this,"settings"),Fe(this,"contentTypes"),Fe(this,"customProperties"),Fe(this,"appProperties"),Fe(this,"styles"),Fe(this,"comments"),Fe(this,"fontWrapper");var r,n,s,i,a,o,c,u,d,h,f,p;if(this.coreProperties=new gAt(ww(fr({},e),{creator:(r=e.creator)!=null?r:"Un-named",revision:(n=e.revision)!=null?n:1,lastModifiedBy:(s=e.lastModifiedBy)!=null?s:"Un-named"})),this.numbering=new aCt(e.numbering?e.numbering:{config:[]}),this.comments=new vEt((i=e.comments)!=null?i:{children:[]}),this.fileRelationships=new Tx,this.customProperties=new SAt((a=e.customProperties)!=null?a:[]),this.appProperties=new dAt,this.footnotesWrapper=new $At,this.contentTypes=new mAt,this.documentWrapper=new ZSe({background:e.background}),this.settings=new dCt({compatibilityModeVersion:e.compatabilityModeVersion,compatibility:e.compatibility,evenAndOddHeaders:!!e.evenAndOddHeaderAndFooters,trackRevisions:(o=e.features)==null?void 0:o.trackRevisions,updateFields:(c=e.features)==null?void 0:c.updateFields,defaultTabStop:e.defaultTabStop,hyphenation:{autoHyphenation:(u=e.hyphenation)==null?void 0:u.autoHyphenation,hyphenationZone:(d=e.hyphenation)==null?void 0:d.hyphenationZone,consecutiveHyphenLimit:(h=e.hyphenation)==null?void 0:h.consecutiveHyphenLimit,doNotHyphenateCaps:(f=e.hyphenation)==null?void 0:f.doNotHyphenateCaps}}),this.media=new HAt,e.externalStyles!==void 0){const m=new PCt;this.styles=m.newInstance(e.externalStyles)}else if(e.styles){const g=new fse().newInstance(e.styles.default);this.styles=new Wz(fr(fr({},g),e.styles))}else{const m=new fse;this.styles=new Wz(m.newInstance())}this.addDefaultRelationships();for(const m of e.sections)this.addSection(m);if(e.footnotes)for(const m in e.footnotes)this.footnotesWrapper.View.createFootNote(parseFloat(m),e.footnotes[m].children);this.fontWrapper=new NAt((p=e.fonts)!=null?p:[])}addSection({headers:e={},footers:r={},children:n,properties:s}){this.documentWrapper.View.Body.addSection(ww(fr({},s),{headerWrapperGroup:{default:e.default?this.createHeader(e.default):void 0,first:e.first?this.createHeader(e.first):void 0,even:e.even?this.createHeader(e.even):void 0},footerWrapperGroup:{default:r.default?this.createFooter(r.default):void 0,first:r.first?this.createFooter(r.first):void 0,even:r.even?this.createFooter(r.even):void 0}}));for(const i of n)this.documentWrapper.View.add(i)}createHeader(e){const r=new UAt(this.media,this.currentRelationshipId++);for(const n of e.options.children)r.add(n);return this.addHeaderToDocument(r),r}createFooter(e){const r=new CAt(this.media,this.currentRelationshipId++);for(const n of e.options.children)r.add(n);return this.addFooterToDocument(r),r}addHeaderToDocument(e,r=fb.DEFAULT){this.headers.push({header:e,type:r}),this.documentWrapper.Relationships.createRelationship(e.View.ReferenceId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",`header${this.headers.length}.xml`),this.contentTypes.addHeader(this.headers.length)}addFooterToDocument(e,r=fb.DEFAULT){this.footers.push({footer:e,type:r}),this.documentWrapper.Relationships.createRelationship(e.View.ReferenceId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",`footer${this.footers.length}.xml`),this.contentTypes.addFooter(this.footers.length)}addDefaultRelationships(){this.fileRelationships.createRelationship(1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument","word/document.xml"),this.fileRelationships.createRelationship(2,"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties","docProps/core.xml"),this.fileRelationships.createRelationship(3,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties","docProps/app.xml"),this.fileRelationships.createRelationship(4,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties","docProps/custom.xml"),this.documentWrapper.Relationships.createRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles","styles.xml"),this.documentWrapper.Relationships.createRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering","numbering.xml"),this.documentWrapper.Relationships.createRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes","footnotes.xml"),this.documentWrapper.Relationships.createRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings","settings.xml"),this.documentWrapper.Relationships.createRelationship(this.currentRelationshipId++,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments","comments.xml")}get Document(){return this.documentWrapper}get Styles(){return this.styles}get CoreProperties(){return this.coreProperties}get Numbering(){return this.numbering}get Media(){return this.media}get FileRelationships(){return this.fileRelationships}get Headers(){return this.headers.map(e=>e.header)}get Footers(){return this.footers.map(e=>e.footer)}get ContentTypes(){return this.contentTypes}get CustomProperties(){return this.customProperties}get AppProperties(){return this.appProperties}get FootNotes(){return this.footnotesWrapper}get Settings(){return this.settings}get Comments(){return this.comments}get FontTable(){return this.fontWrapper}};class ICt extends $e{constructor(e={}){super("w:instrText"),Fe(this,"properties"),this.properties=e,this.root.push(new ax({space:ix.PRESERVE}));let r="TOC";if(this.properties.captionLabel&&(r=`${r} \\a "${this.properties.captionLabel}"`),this.properties.entriesFromBookmark&&(r=`${r} \\b "${this.properties.entriesFromBookmark}"`),this.properties.captionLabelIncludingNumbers&&(r=`${r} \\c "${this.properties.captionLabelIncludingNumbers}"`),this.properties.sequenceAndPageNumbersSeparator&&(r=`${r} \\d "${this.properties.sequenceAndPageNumbersSeparator}"`),this.properties.tcFieldIdentifier&&(r=`${r} \\f "${this.properties.tcFieldIdentifier}"`),this.properties.hyperlink&&(r=`${r} \\h`),this.properties.tcFieldLevelRange&&(r=`${r} \\l "${this.properties.tcFieldLevelRange}"`),this.properties.pageNumbersEntryLevelsRange&&(r=`${r} \\n "${this.properties.pageNumbersEntryLevelsRange}"`),this.properties.headingStyleRange&&(r=`${r} \\o "${this.properties.headingStyleRange}"`),this.properties.entryAndPageNumberSeparator&&(r=`${r} \\p "${this.properties.entryAndPageNumberSeparator}"`),this.properties.seqFieldIdentifierForPrefix&&(r=`${r} \\s "${this.properties.seqFieldIdentifierForPrefix}"`),this.properties.stylesWithLevels&&this.properties.stylesWithLevels.length){const n=this.properties.stylesWithLevels.map(s=>`${s.styleName},${s.level}`).join(",");r=`${r} \\t "${n}"`}this.properties.useAppliedParagraphOutlineLevel&&(r=`${r} \\u`),this.properties.preserveTabInEntries&&(r=`${r} \\w`),this.properties.preserveNewLineInEntries&&(r=`${r} \\x`),this.properties.hideTabAndPageNumbersInWebView&&(r=`${r} \\z`),this.root.push(r)}}class RCt extends $e{constructor(){super("w:sdtContent")}}class MCt extends $e{constructor(e){super("w:sdtPr"),e&&this.root.push(new My("w:alias",e))}}class DCt extends QSe{constructor(e="Table of Contents",r){super("w:sdt"),this.root.push(new MCt(e));const n=new RCt,s=new on({children:[new ox({children:[new MS(!0),new ICt(r),new DS]})]});n.addChildElement(s);const i=new on({children:[new ox({children:[new LS]})]});n.addChildElement(i),this.root.push(n)}}class LCt{constructor(e={children:[]}){Fe(this,"options"),this.options=e}}class FCt{constructor(e={children:[]}){Fe(this,"options"),this.options=e}}var $Ct=p7();function NC(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var L3={exports:{}},pse;function BCt(){return pse||(pse=1,function(t,e){(function(r){t.exports=r()})(function(){return function r(n,s,i){function a(u,d){if(!s[u]){if(!n[u]){var h=typeof NC=="function"&&NC;if(!d&&h)return h(u,!0);if(o)return o(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var p=s[u]={exports:{}};n[u][0].call(p.exports,function(m){var g=n[u][1][m];return a(g||m)},p,p.exports,r,n,s,i)}return s[u].exports}for(var o=typeof NC=="function"&&NC,c=0;c<i.length;c++)a(i[c]);return a}({1:[function(r,n,s){var i=r("./utils"),a=r("./support"),o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(c){for(var u,d,h,f,p,m,g,x=[],y=0,v=c.length,b=v,w=i.getTypeOf(c)!=="string";y<c.length;)b=v-y,h=w?(u=c[y++],d=y<v?c[y++]:0,y<v?c[y++]:0):(u=c.charCodeAt(y++),d=y<v?c.charCodeAt(y++):0,y<v?c.charCodeAt(y++):0),f=u>>2,p=(3&u)<<4|d>>4,m=1<b?(15&d)<<2|h>>6:64,g=2<b?63&h:64,x.push(o.charAt(f)+o.charAt(p)+o.charAt(m)+o.charAt(g));return x.join("")},s.decode=function(c){var u,d,h,f,p,m,g=0,x=0,y="data:";if(c.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var v,b=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===o.charAt(64)&&b--,c.charAt(c.length-2)===o.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=a.uint8array?new Uint8Array(0|b):new Array(0|b);g<c.length;)u=o.indexOf(c.charAt(g++))<<2|(f=o.indexOf(c.charAt(g++)))>>4,d=(15&f)<<4|(p=o.indexOf(c.charAt(g++)))>>2,h=(3&p)<<6|(m=o.indexOf(c.charAt(g++))),v[x++]=u,p!==64&&(v[x++]=d),m!==64&&(v[x++]=h);return v}},{"./support":30,"./utils":32}],2:[function(r,n,s){var i=r("./external"),a=r("./stream/DataWorker"),o=r("./stream/Crc32Probe"),c=r("./stream/DataLengthProbe");function u(d,h,f,p,m){this.compressedSize=d,this.uncompressedSize=h,this.crc32=f,this.compression=p,this.compressedContent=m}u.prototype={getContentWorker:function(){var d=new a(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new a(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,h,f){return d.pipe(new o).pipe(new c("uncompressedSize")).pipe(h.compressWorker(f)).pipe(new c("compressedSize")).withStreamInfo("compression",h)},n.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,n,s){var i=r("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},s.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,n,s){var i=r("./utils"),a=function(){for(var o,c=[],u=0;u<256;u++){o=u;for(var d=0;d<8;d++)o=1&o?3988292384^o>>>1:o>>>1;c[u]=o}return c}();n.exports=function(o,c){return o!==void 0&&o.length?i.getTypeOf(o)!=="string"?function(u,d,h,f){var p=a,m=f+h;u^=-1;for(var g=f;g<m;g++)u=u>>>8^p[255&(u^d[g])];return-1^u}(0|c,o,o.length,0):function(u,d,h,f){var p=a,m=f+h;u^=-1;for(var g=f;g<m;g++)u=u>>>8^p[255&(u^d.charCodeAt(g))];return-1^u}(0|c,o,o.length,0):0}},{"./utils":32}],5:[function(r,n,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(r,n,s){var i=null;i=typeof Promise<"u"?Promise:r("lie"),n.exports={Promise:i}},{lie:37}],7:[function(r,n,s){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",a=r("pako"),o=r("./utils"),c=r("./stream/GenericWorker"),u=i?"uint8array":"array";function d(h,f){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=f,this.meta={}}s.magic="\b\0",o.inherits(d,c),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(o.transformTo(u,h.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new a[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(f){h.push({data:f,meta:h.meta})}},s.compressWorker=function(h){return new d("Deflate",h)},s.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,n,s){function i(p,m){var g,x="";for(g=0;g<m;g++)x+=String.fromCharCode(255&p),p>>>=8;return x}function a(p,m,g,x,y,v){var b,w,S=p.file,k=p.compression,E=v!==u.utf8encode,C=o.transformTo("string",v(S.name)),A=o.transformTo("string",u.utf8encode(S.name)),M=S.comment,z=o.transformTo("string",v(M)),P=o.transformTo("string",u.utf8encode(M)),W=A.length!==S.name.length,N=P.length!==M.length,U="",K="",G="",X=S.dir,H=S.date,B={crc32:0,compressedSize:0,uncompressedSize:0};m&&!g||(B.crc32=p.crc32,B.compressedSize=p.compressedSize,B.uncompressedSize=p.uncompressedSize);var L=0;m&&(L|=8),E||!W&&!N||(L|=2048);var F=0,V=0;X&&(F|=16),y==="UNIX"?(V=798,F|=function(ie,Q){var D=ie;return ie||(D=Q?16893:33204),(65535&D)<<16}(S.unixPermissions,X)):(V=20,F|=function(ie){return 63&(ie||0)}(S.dosPermissions)),b=H.getUTCHours(),b<<=6,b|=H.getUTCMinutes(),b<<=5,b|=H.getUTCSeconds()/2,w=H.getUTCFullYear()-1980,w<<=4,w|=H.getUTCMonth()+1,w<<=5,w|=H.getUTCDate(),W&&(K=i(1,1)+i(d(C),4)+A,U+="up"+i(K.length,2)+K),N&&(G=i(1,1)+i(d(z),4)+P,U+="uc"+i(G.length,2)+G);var Y="";return Y+=`
\0`,Y+=i(L,2),Y+=k.magic,Y+=i(b,2),Y+=i(w,2),Y+=i(B.crc32,4),Y+=i(B.compressedSize,4),Y+=i(B.uncompressedSize,4),Y+=i(C.length,2),Y+=i(U.length,2),{fileRecord:h.LOCAL_FILE_HEADER+Y+C+U,dirRecord:h.CENTRAL_FILE_HEADER+i(V,2)+Y+i(z.length,2)+"\0\0\0\0"+i(F,4)+i(x,4)+C+U+z}}var o=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),d=r("../crc32"),h=r("../signature");function f(p,m,g,x){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=g,this.encodeFileName=x,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}o.inherits(f,c),f.prototype.push=function(p){var m=p.meta.percent||0,g=this.entriesCount,x=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,c.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:g?(m+100*(g-x-1))/g:100}}))},f.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var m=this.streamFiles&&!p.file.dir;if(m){var g=a(p,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(p){this.accumulate=!1;var m=this.streamFiles&&!p.file.dir,g=a(p,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),m)this.push({data:function(x){return h.DATA_DESCRIPTOR+i(x.crc32,4)+i(x.compressedSize,4)+i(x.uncompressedSize,4)}(p),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var p=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var g=this.bytesWritten-p,x=function(y,v,b,w,S){var k=o.transformTo("string",S(w));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(y,2)+i(y,2)+i(v,4)+i(b,4)+i(k.length,2)+k}(this.dirRecords.length,g,p,this.zipComment,this.encodeFileName);this.push({data:x,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(p){this._sources.push(p);var m=this;return p.on("data",function(g){m.processChunk(g)}),p.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),p.on("error",function(g){m.error(g)}),this},f.prototype.resume=function(){return!!c.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(p){var m=this._sources;if(!c.prototype.error.call(this,p))return!1;for(var g=0;g<m.length;g++)try{m[g].error(p)}catch{}return!0},f.prototype.lock=function(){c.prototype.lock.call(this);for(var p=this._sources,m=0;m<p.length;m++)p[m].lock()},n.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(r,n,s){var i=r("../compressions"),a=r("./ZipFileWorker");s.generateWorker=function(o,c,u){var d=new a(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{o.forEach(function(f,p){h++;var m=function(v,b){var w=v||b,S=i[w];if(!S)throw new Error(w+" is not a valid compression method !");return S}(p.options.compression,c.compression),g=p.options.compressionOptions||c.compressionOptions||{},x=p.dir,y=p.date;p._compressWorker(m,g).withStreamInfo("file",{name:f,dir:x,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(f){d.error(f)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(r,n,s){function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var a=new i;for(var o in this)typeof this[o]!="function"&&(a[o]=this[o]);return a}}(i.prototype=r("./object")).loadAsync=r("./load"),i.support=r("./support"),i.defaults=r("./defaults"),i.version="3.10.1",i.loadAsync=function(a,o){return new i().loadAsync(a,o)},i.external=r("./external"),n.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(r,n,s){var i=r("./utils"),a=r("./external"),o=r("./utf8"),c=r("./zipEntries"),u=r("./stream/Crc32Probe"),d=r("./nodejsUtils");function h(f){return new a.Promise(function(p,m){var g=f.decompressed.getContentWorker().pipe(new u);g.on("error",function(x){m(x)}).on("end",function(){g.streamInfo.crc32!==f.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(f,p){var m=this;return p=i.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:o.utf8decode}),d.isNode&&d.isStream(f)?a.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",f,!0,p.optimizedBinaryString,p.base64).then(function(g){var x=new c(p);return x.load(g),x}).then(function(g){var x=[a.Promise.resolve(g)],y=g.files;if(p.checkCRC32)for(var v=0;v<y.length;v++)x.push(h(y[v]));return a.Promise.all(x)}).then(function(g){for(var x=g.shift(),y=x.files,v=0;v<y.length;v++){var b=y[v],w=b.fileNameStr,S=i.resolve(b.fileNameStr);m.file(S,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:p.createFolders}),b.dir||(m.file(S).unsafeOriginalName=w)}return x.zipComment.length&&(m.comment=x.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(r,n,s){var i=r("../utils"),a=r("../stream/GenericWorker");function o(c,u){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}i.inherits(o,a),o.prototype._bindStream=function(c){var u=this;(this._stream=c).pause(),c.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},o.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=o},{"../stream/GenericWorker":28,"../utils":32}],13:[function(r,n,s){var i=r("readable-stream").Readable;function a(o,c,u){i.call(this,c),this._helper=o;var d=this;o.on("data",function(h,f){d.push(h)||d._helper.pause(),u&&u(f)}).on("error",function(h){d.emit("error",h)}).on("end",function(){d.push(null)})}r("../utils").inherits(a,i),a.prototype._read=function(){this._helper.resume()},n.exports=a},{"../utils":32,"readable-stream":16}],14:[function(r,n,s){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,a){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,a);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,a)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var a=new Buffer(i);return a.fill(0),a},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(r,n,s){function i(S,k,E){var C,A=o.getTypeOf(k),M=o.extend(E||{},d);M.date=M.date||new Date,M.compression!==null&&(M.compression=M.compression.toUpperCase()),typeof M.unixPermissions=="string"&&(M.unixPermissions=parseInt(M.unixPermissions,8)),M.unixPermissions&&16384&M.unixPermissions&&(M.dir=!0),M.dosPermissions&&16&M.dosPermissions&&(M.dir=!0),M.dir&&(S=y(S)),M.createFolders&&(C=x(S))&&v.call(this,C,!0);var z=A==="string"&&M.binary===!1&&M.base64===!1;E&&E.binary!==void 0||(M.binary=!z),(k instanceof h&&k.uncompressedSize===0||M.dir||!k||k.length===0)&&(M.base64=!1,M.binary=!0,k="",M.compression="STORE",A="string");var P=null;P=k instanceof h||k instanceof c?k:m.isNode&&m.isStream(k)?new g(S,k):o.prepareContent(S,k,M.binary,M.optimizedBinaryString,M.base64);var W=new f(S,P,M);this.files[S]=W}var a=r("./utf8"),o=r("./utils"),c=r("./stream/GenericWorker"),u=r("./stream/StreamHelper"),d=r("./defaults"),h=r("./compressedObject"),f=r("./zipObject"),p=r("./generate"),m=r("./nodejsUtils"),g=r("./nodejs/NodejsStreamInputAdapter"),x=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var k=S.lastIndexOf("/");return 0<k?S.substring(0,k):""},y=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},v=function(S,k){return k=k!==void 0?k:d.createFolders,S=y(S),this.files[S]||i.call(this,S,null,{dir:!0,createFolders:k}),this.files[S]};function b(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var w={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var k,E,C;for(k in this.files)C=this.files[k],(E=k.slice(this.root.length,k.length))&&k.slice(0,this.root.length)===this.root&&S(E,C)},filter:function(S){var k=[];return this.forEach(function(E,C){S(E,C)&&k.push(C)}),k},file:function(S,k,E){if(arguments.length!==1)return S=this.root+S,i.call(this,S,k,E),this;if(b(S)){var C=S;return this.filter(function(M,z){return!z.dir&&C.test(M)})}var A=this.files[this.root+S];return A&&!A.dir?A:null},folder:function(S){if(!S)return this;if(b(S))return this.filter(function(A,M){return M.dir&&S.test(A)});var k=this.root+S,E=v.call(this,k),C=this.clone();return C.root=E.name,C},remove:function(S){S=this.root+S;var k=this.files[S];if(k||(S.slice(-1)!=="/"&&(S+="/"),k=this.files[S]),k&&!k.dir)delete this.files[S];else for(var E=this.filter(function(A,M){return M.name.slice(0,S.length)===S}),C=0;C<E.length;C++)delete this.files[E[C].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var k,E={};try{if((E=o.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=E.type.toLowerCase(),E.compression=E.compression.toUpperCase(),E.type==="binarystring"&&(E.type="string"),!E.type)throw new Error("No output type specified.");o.checkSupport(E.type),E.platform!=="darwin"&&E.platform!=="freebsd"&&E.platform!=="linux"&&E.platform!=="sunos"||(E.platform="UNIX"),E.platform==="win32"&&(E.platform="DOS");var C=E.comment||this.comment||"";k=p.generateWorker(this,E,C)}catch(A){(k=new c("error")).error(A)}return new u(k,E.type||"string",E.mimeType)},generateAsync:function(S,k){return this.generateInternalStream(S).accumulate(k)},generateNodeStream:function(S,k){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(k)}};n.exports=w},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(r,n,s){n.exports=r("stream")},{stream:void 0}],17:[function(r,n,s){var i=r("./DataReader");function a(o){i.call(this,o);for(var c=0;c<this.data.length;c++)o[c]=255&o[c]}r("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data[this.zero+o]},a.prototype.lastIndexOfSignature=function(o){for(var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),h=o.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===c&&this.data[f+1]===u&&this.data[f+2]===d&&this.data[f+3]===h)return f-this.zero;return-1},a.prototype.readAndCheckSignature=function(o){var c=o.charCodeAt(0),u=o.charCodeAt(1),d=o.charCodeAt(2),h=o.charCodeAt(3),f=this.readData(4);return c===f[0]&&u===f[1]&&d===f[2]&&h===f[3]},a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},n.exports=a},{"../utils":32,"./DataReader":18}],18:[function(r,n,s){var i=r("../utils");function a(o){this.data=o,this.length=o.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(o){this.checkIndex(this.index+o)},checkIndex:function(o){if(this.length<this.zero+o||o<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+o+"). Corrupted zip ?")},setIndex:function(o){this.checkIndex(o),this.index=o},skip:function(o){this.setIndex(this.index+o)},byteAt:function(){},readInt:function(o){var c,u=0;for(this.checkOffset(o),c=this.index+o-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=o,u},readString:function(o){return i.transformTo("string",this.readData(o))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var o=this.readInt(4);return new Date(Date.UTC(1980+(o>>25&127),(o>>21&15)-1,o>>16&31,o>>11&31,o>>5&63,(31&o)<<1))}},n.exports=a},{"../utils":32}],19:[function(r,n,s){var i=r("./Uint8ArrayReader");function a(o){i.call(this,o)}r("../utils").inherits(a,i),a.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},n.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,s){var i=r("./DataReader");function a(o){i.call(this,o)}r("../utils").inherits(a,i),a.prototype.byteAt=function(o){return this.data.charCodeAt(this.zero+o)},a.prototype.lastIndexOfSignature=function(o){return this.data.lastIndexOf(o)-this.zero},a.prototype.readAndCheckSignature=function(o){return o===this.readData(4)},a.prototype.readData=function(o){this.checkOffset(o);var c=this.data.slice(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},n.exports=a},{"../utils":32,"./DataReader":18}],21:[function(r,n,s){var i=r("./ArrayReader");function a(o){i.call(this,o)}r("../utils").inherits(a,i),a.prototype.readData=function(o){if(this.checkOffset(o),o===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+o);return this.index+=o,c},n.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,s){var i=r("../utils"),a=r("../support"),o=r("./ArrayReader"),c=r("./StringReader"),u=r("./NodeBufferReader"),d=r("./Uint8ArrayReader");n.exports=function(h){var f=i.getTypeOf(h);return i.checkSupport(f),f!=="string"||a.uint8array?f==="nodebuffer"?new u(h):a.uint8array?new d(i.transformTo("uint8array",h)):new o(i.transformTo("array",h)):new c(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,n,s){s.LOCAL_FILE_HEADER="PK",s.CENTRAL_FILE_HEADER="PK",s.CENTRAL_DIRECTORY_END="PK",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,n,s){var i=r("./GenericWorker"),a=r("../utils");function o(c){i.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(o,i),o.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},n.exports=o},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,s){var i=r("./GenericWorker"),a=r("../crc32");function o(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(o,i),o.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},n.exports=o},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,s){var i=r("../utils"),a=r("./GenericWorker");function o(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}i.inherits(o,a),o.prototype.processChunk=function(c){if(c){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+c.data.length}a.prototype.processChunk.call(this,c)},n.exports=o},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,s){var i=r("../utils"),a=r("./GenericWorker");function o(c){a.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,c.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=i.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}i.inherits(o,a),o.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},o.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},o.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},o.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=o},{"../utils":32,"./GenericWorker":28}],28:[function(r,n,s){function i(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,o){return this._listeners[a].push(o),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,o){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,o)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var o=this;return a.on("data",function(c){o.processChunk(c)}),a.on("end",function(){o.end()}),a.on("error",function(c){o.error(c)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var a=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,o){return this.extraStreamInfo[a]=o,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},n.exports=i},{}],29:[function(r,n,s){var i=r("../utils"),a=r("./ConvertWorker"),o=r("./GenericWorker"),c=r("../base64"),u=r("../support"),d=r("../external"),h=null;if(u.nodestream)try{h=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function f(m,g){return new d.Promise(function(x,y){var v=[],b=m._internalType,w=m._outputType,S=m._mimeType;m.on("data",function(k,E){v.push(k),g&&g(E)}).on("error",function(k){v=[],y(k)}).on("end",function(){try{var k=function(E,C,A){switch(E){case"blob":return i.newBlob(i.transformTo("arraybuffer",C),A);case"base64":return c.encode(C);default:return i.transformTo(E,C)}}(w,function(E,C){var A,M=0,z=null,P=0;for(A=0;A<C.length;A++)P+=C[A].length;switch(E){case"string":return C.join("");case"array":return Array.prototype.concat.apply([],C);case"uint8array":for(z=new Uint8Array(P),A=0;A<C.length;A++)z.set(C[A],M),M+=C[A].length;return z;case"nodebuffer":return Buffer.concat(C);default:throw new Error("concat : unsupported type '"+E+"'")}}(b,v),S);x(k)}catch(E){y(E)}v=[]}).resume()})}function p(m,g,x){var y=g;switch(g){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=g,this._mimeType=x,i.checkSupport(y),this._worker=m.pipe(new a(y)),m.lock()}catch(v){this._worker=new o("error"),this._worker.error(v)}}p.prototype={accumulate:function(m){return f(this,m)},on:function(m,g){var x=this;return m==="data"?this._worker.on(m,function(y){g.call(x,y.data,y.meta)}):this._worker.on(m,function(){i.delay(g,arguments,x)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:this._outputType!=="nodebuffer"},m)}},n.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(r,n,s){if(s.base64=!0,s.array=!0,s.string=!0,s.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",s.nodebuffer=typeof Buffer<"u",s.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")s.blob=!1;else{var i=new ArrayBuffer(0);try{s.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);a.append(i),s.blob=a.getBlob("application/zip").size===0}catch{s.blob=!1}}}try{s.nodestream=!!r("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(r,n,s){for(var i=r("./utils"),a=r("./support"),o=r("./nodejsUtils"),c=r("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function h(){c.call(this,"utf-8 decode"),this.leftOver=null}function f(){c.call(this,"utf-8 encode")}s.utf8encode=function(p){return a.nodebuffer?o.newBufferFrom(p,"utf-8"):function(m){var g,x,y,v,b,w=m.length,S=0;for(v=0;v<w;v++)(64512&(x=m.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=m.charCodeAt(v+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),v++),S+=x<128?1:x<2048?2:x<65536?3:4;for(g=a.uint8array?new Uint8Array(S):new Array(S),v=b=0;b<S;v++)(64512&(x=m.charCodeAt(v)))==55296&&v+1<w&&(64512&(y=m.charCodeAt(v+1)))==56320&&(x=65536+(x-55296<<10)+(y-56320),v++),x<128?g[b++]=x:(x<2048?g[b++]=192|x>>>6:(x<65536?g[b++]=224|x>>>12:(g[b++]=240|x>>>18,g[b++]=128|x>>>12&63),g[b++]=128|x>>>6&63),g[b++]=128|63&x);return g}(p)},s.utf8decode=function(p){return a.nodebuffer?i.transformTo("nodebuffer",p).toString("utf-8"):function(m){var g,x,y,v,b=m.length,w=new Array(2*b);for(g=x=0;g<b;)if((y=m[g++])<128)w[x++]=y;else if(4<(v=u[y]))w[x++]=65533,g+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&g<b;)y=y<<6|63&m[g++],v--;1<v?w[x++]=65533:y<65536?w[x++]=y:(y-=65536,w[x++]=55296|y>>10&1023,w[x++]=56320|1023&y)}return w.length!==x&&(w.subarray?w=w.subarray(0,x):w.length=x),i.applyFromCharCode(w)}(p=i.transformTo(a.uint8array?"uint8array":"array",p))},i.inherits(h,c),h.prototype.processChunk=function(p){var m=i.transformTo(a.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(a.uint8array){var g=m;(m=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),m.set(g,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var x=function(v,b){var w;for((b=b||v.length)>v.length&&(b=v.length),w=b-1;0<=w&&(192&v[w])==128;)w--;return w<0||w===0?b:w+u[v[w]]>b?w:b}(m),y=m;x!==m.length&&(a.uint8array?(y=m.subarray(0,x),this.leftOver=m.subarray(x,m.length)):(y=m.slice(0,x),this.leftOver=m.slice(x,m.length))),this.push({data:s.utf8decode(y),meta:p.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=h,i.inherits(f,c),f.prototype.processChunk=function(p){this.push({data:s.utf8encode(p.data),meta:p.meta})},s.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,n,s){var i=r("./support"),a=r("./base64"),o=r("./nodejsUtils"),c=r("./external");function u(g){return g}function d(g,x){for(var y=0;y<g.length;++y)x[y]=255&g.charCodeAt(y);return x}r("setimmediate"),s.newBlob=function(g,x){s.checkSupport("blob");try{return new Blob([g],{type:x})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(g),y.getBlob(x)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,x,y){var v=[],b=0,w=g.length;if(w<=y)return String.fromCharCode.apply(null,g);for(;b<w;)x==="array"||x==="nodebuffer"?v.push(String.fromCharCode.apply(null,g.slice(b,Math.min(b+y,w)))):v.push(String.fromCharCode.apply(null,g.subarray(b,Math.min(b+y,w)))),b+=y;return v.join("")},stringifyByChar:function(g){for(var x="",y=0;y<g.length;y++)x+=String.fromCharCode(g[y]);return x},applyCanBeUsed:{uint8array:function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,o.allocBuffer(1)).length===1}catch{return!1}}()}};function f(g){var x=65536,y=s.getTypeOf(g),v=!0;if(y==="uint8array"?v=h.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=h.applyCanBeUsed.nodebuffer),v)for(;1<x;)try{return h.stringifyByChunk(g,y,x)}catch{x=Math.floor(x/2)}return h.stringifyByChar(g)}function p(g,x){for(var y=0;y<g.length;y++)x[y]=g[y];return x}s.applyFromCharCode=f;var m={};m.string={string:u,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return m.string.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:function(g){return d(g,o.allocBuffer(g.length))}},m.array={string:f,array:u,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return o.newBufferFrom(g)}},m.arraybuffer={string:function(g){return f(new Uint8Array(g))},array:function(g){return p(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:u,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return o.newBufferFrom(new Uint8Array(g))}},m.uint8array={string:f,array:function(g){return p(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:u,nodebuffer:function(g){return o.newBufferFrom(g)}},m.nodebuffer={string:f,array:function(g){return p(g,new Array(g.length))},arraybuffer:function(g){return m.nodebuffer.uint8array(g).buffer},uint8array:function(g){return p(g,new Uint8Array(g.length))},nodebuffer:u},s.transformTo=function(g,x){if(x=x||"",!g)return x;s.checkSupport(g);var y=s.getTypeOf(x);return m[y][g](x)},s.resolve=function(g){for(var x=g.split("/"),y=[],v=0;v<x.length;v++){var b=x[v];b==="."||b===""&&v!==0&&v!==x.length-1||(b===".."?y.pop():y.push(b))}return y.join("/")},s.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":i.nodebuffer&&o.isBuffer(g)?"nodebuffer":i.uint8array&&g instanceof Uint8Array?"uint8array":i.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(g){if(!i[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(g){var x,y,v="";for(y=0;y<(g||"").length;y++)v+="\\x"+((x=g.charCodeAt(y))<16?"0":"")+x.toString(16).toUpperCase();return v},s.delay=function(g,x,y){setImmediate(function(){g.apply(y||null,x||[])})},s.inherits=function(g,x){function y(){}y.prototype=x.prototype,g.prototype=new y},s.extend=function(){var g,x,y={};for(g=0;g<arguments.length;g++)for(x in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],x)&&y[x]===void 0&&(y[x]=arguments[g][x]);return y},s.prepareContent=function(g,x,y,v,b){return c.Promise.resolve(x).then(function(w){return i.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)&&typeof FileReader<"u"?new c.Promise(function(S,k){var E=new FileReader;E.onload=function(C){S(C.target.result)},E.onerror=function(C){k(C.target.error)},E.readAsArrayBuffer(w)}):w}).then(function(w){var S=s.getTypeOf(w);return S?(S==="arraybuffer"?w=s.transformTo("uint8array",w):S==="string"&&(b?w=a.decode(w):y&&v!==!0&&(w=function(k){return d(k,i.uint8array?new Uint8Array(k.length):new Array(k.length))}(w))),w):c.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(r,n,s){var i=r("./reader/readerFor"),a=r("./utils"),o=r("./signature"),c=r("./zipEntry"),u=r("./support");function d(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+a.pretty(f)+", expected "+a.pretty(h)+")")}},isSignature:function(h,f){var p=this.reader.index;this.reader.setIndex(h);var m=this.reader.readString(4)===f;return this.reader.setIndex(p),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var h=this.reader.readData(this.zipCommentLength),f=u.uint8array?"uint8array":"array",p=a.transformTo(f,h);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h,f,p,m=this.zip64EndOfCentralSize-44;0<m;)h=this.reader.readInt(2),f=this.reader.readInt(4),p=this.reader.readData(f),this.zip64ExtensibleData[h]={id:h,length:f,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,f;for(h=0;h<this.files.length;h++)f=this.files[h],this.reader.setIndex(f.localHeaderOffset),this.checkSignature(o.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(o.CENTRAL_FILE_HEADER);)(h=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var h=this.reader.lastIndexOfSignature(o.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,o.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(h);var f=h;if(this.checkSignature(o.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===a.MAX_VALUE_16BITS||this.diskWithCentralDirStart===a.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===a.MAX_VALUE_16BITS||this.centralDirRecords===a.MAX_VALUE_16BITS||this.centralDirSize===a.MAX_VALUE_32BITS||this.centralDirOffset===a.MAX_VALUE_32BITS){if(this.zip64=!0,(h=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(h),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,o.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(o.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var m=f-p;if(0<m)this.isSignature(f,o.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(h){this.reader=i(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(r,n,s){var i=r("./reader/readerFor"),a=r("./utils"),o=r("./compressedObject"),c=r("./crc32"),u=r("./utf8"),d=r("./compressions"),h=r("./support");function f(p,m){this.options=p,this.loadOptions=m}f.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var m,g;if(p.skip(22),this.fileNameLength=p.readInt(2),g=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((m=function(x){for(var y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===x)return d[y];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+a.pretty(this.compressionMethod)+" unknown (inner file : "+a.transformTo("string",this.fileName)+")");this.decompressed=new o(this.compressedSize,this.uncompressedSize,this.crc32,m,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var m=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(m),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=i(this.extraFields[1].value);this.uncompressedSize===a.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===a.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===a.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===a.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var m,g,x,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)m=p.readInt(2),g=p.readInt(2),x=p.readData(g),this.extraFields[m]={id:m,length:g,value:x};p.setIndex(y)},handleUTF8:function(){var p=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var g=a.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var x=this.findExtraFieldUnicodeComment();if(x!==null)this.fileCommentStr=x;else{var y=a.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var m=i(p.value);return m.readInt(1)!==1||c(this.fileName)!==m.readInt(4)?null:u.utf8decode(m.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var m=i(p.value);return m.readInt(1)!==1||c(this.fileComment)!==m.readInt(4)?null:u.utf8decode(m.readData(p.length-5))}return null}},n.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(r,n,s){function i(m,g,x){this.name=m,this.dir=x.dir,this.date=x.date,this.comment=x.comment,this.unixPermissions=x.unixPermissions,this.dosPermissions=x.dosPermissions,this._data=g,this._dataBinary=x.binary,this.options={compression:x.compression,compressionOptions:x.compressionOptions}}var a=r("./stream/StreamHelper"),o=r("./stream/DataWorker"),c=r("./utf8"),u=r("./compressedObject"),d=r("./stream/GenericWorker");i.prototype={internalStream:function(m){var g=null,x="string";try{if(!m)throw new Error("No output type specified.");var y=(x=m.toLowerCase())==="string"||x==="text";x!=="binarystring"&&x!=="text"||(x="string"),g=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(g=g.pipe(new c.Utf8EncodeWorker)),!v&&y&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(b){(g=new d("error")).error(b)}return new a(g,x,"")},async:function(m,g){return this.internalStream(m).accumulate(g)},nodeStream:function(m,g){return this.internalStream(m||"nodebuffer").toNodejsStream(g)},_compressWorker:function(m,g){if(this._data instanceof u&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var x=this._decompressWorker();return this._dataBinary||(x=x.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(x,m,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new o(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<h.length;p++)i.prototype[h[p]]=f;n.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(r,n,s){(function(i){var a,o,c=i.MutationObserver||i.WebKitMutationObserver;if(c){var u=0,d=new c(m),h=i.document.createTextNode("");d.observe(h,{characterData:!0}),a=function(){h.data=u=++u%2}}else if(i.setImmediate||i.MessageChannel===void 0)a="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var g=i.document.createElement("script");g.onreadystatechange=function(){m(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},i.document.documentElement.appendChild(g)}:function(){setTimeout(m,0)};else{var f=new i.MessageChannel;f.port1.onmessage=m,a=function(){f.port2.postMessage(0)}}var p=[];function m(){var g,x;o=!0;for(var y=p.length;y;){for(x=p,p=[],g=-1;++g<y;)x[g]();y=p.length}o=!1}n.exports=function(g){p.push(g)!==1||o||a()}}).call(this,typeof gu<"u"?gu:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(r,n,s){var i=r("immediate");function a(){}var o={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==a&&g(this,y)}function f(y,v,b){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function p(y,v,b){i(function(){var w;try{w=v(b)}catch(S){return o.reject(y,S)}w===y?o.reject(y,new TypeError("Cannot resolve promise with itself")):o.resolve(y,w)})}function m(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function g(y,v){var b=!1;function w(E){b||(b=!0,o.reject(y,E))}function S(E){b||(b=!0,o.resolve(y,E))}var k=x(function(){v(S,w)});k.status==="error"&&w(k.value)}function x(y,v){var b={};try{b.value=y(v),b.status="success"}catch(w){b.status="error",b.value=w}return b}(n.exports=h).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(y()).then(function(){return b})},function(b){return v.resolve(y()).then(function(){throw b})})},h.prototype.catch=function(y){return this.then(null,y)},h.prototype.then=function(y,v){if(typeof y!="function"&&this.state===u||typeof v!="function"&&this.state===c)return this;var b=new this.constructor(a);return this.state!==d?p(b,this.state===u?y:v,this.outcome):this.queue.push(new f(b,y,v)),b},f.prototype.callFulfilled=function(y){o.resolve(this.promise,y)},f.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},f.prototype.callRejected=function(y){o.reject(this.promise,y)},f.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},o.resolve=function(y,v){var b=x(m,v);if(b.status==="error")return o.reject(y,b.value);var w=b.value;if(w)g(y,w);else{y.state=u,y.outcome=v;for(var S=-1,k=y.queue.length;++S<k;)y.queue[S].callFulfilled(v)}return y},o.reject=function(y,v){y.state=c,y.outcome=v;for(var b=-1,w=y.queue.length;++b<w;)y.queue[b].callRejected(v);return y},h.resolve=function(y){return y instanceof this?y:o.resolve(new this(a),y)},h.reject=function(y){var v=new this(a);return o.reject(v,y)},h.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var S=new Array(b),k=0,E=-1,C=new this(a);++E<b;)A(y[E],E);return C;function A(M,z){v.resolve(M).then(function(P){S[z]=P,++k!==b||w||(w=!0,o.resolve(C,S))},function(P){w||(w=!0,o.reject(C,P))})}},h.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=y.length,w=!1;if(!b)return this.resolve([]);for(var S=-1,k=new this(a);++S<b;)E=y[S],v.resolve(E).then(function(C){w||(w=!0,o.resolve(k,C))},function(C){w||(w=!0,o.reject(k,C))});var E;return k}},{immediate:36}],38:[function(r,n,s){var i={};(0,r("./lib/utils/common").assign)(i,r("./lib/deflate"),r("./lib/inflate"),r("./lib/zlib/constants")),n.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(r,n,s){var i=r("./zlib/deflate"),a=r("./utils/common"),o=r("./utils/strings"),c=r("./zlib/messages"),u=r("./zlib/zstream"),d=Object.prototype.toString,h=0,f=-1,p=0,m=8;function g(y){if(!(this instanceof g))return new g(y);this.options=a.assign({level:f,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var b=i.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(b!==h)throw new Error(c[b]);if(v.header&&i.deflateSetHeader(this.strm,v.header),v.dictionary){var w;if(w=typeof v.dictionary=="string"?o.string2buf(v.dictionary):d.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(b=i.deflateSetDictionary(this.strm,w))!==h)throw new Error(c[b]);this._dict_set=!0}}function x(y,v){var b=new g(v);if(b.push(y,!0),b.err)throw b.msg||c[b.err];return b.result}g.prototype.push=function(y,v){var b,w,S=this.strm,k=this.options.chunkSize;if(this.ended)return!1;w=v===~~v?v:v===!0?4:0,typeof y=="string"?S.input=o.string2buf(y):d.call(y)==="[object ArrayBuffer]"?S.input=new Uint8Array(y):S.input=y,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new a.Buf8(k),S.next_out=0,S.avail_out=k),(b=i.deflate(S,w))!==1&&b!==h)return this.onEnd(b),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(o.buf2binstring(a.shrinkBuf(S.output,S.next_out))):this.onData(a.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&b!==1);return w===4?(b=i.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===h):w!==2||(this.onEnd(h),!(S.avail_out=0))},g.prototype.onData=function(y){this.chunks.push(y)},g.prototype.onEnd=function(y){y===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},s.Deflate=g,s.deflate=x,s.deflateRaw=function(y,v){return(v=v||{}).raw=!0,x(y,v)},s.gzip=function(y,v){return(v=v||{}).gzip=!0,x(y,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(r,n,s){var i=r("./zlib/inflate"),a=r("./utils/common"),o=r("./utils/strings"),c=r("./zlib/constants"),u=r("./zlib/messages"),d=r("./zlib/zstream"),h=r("./zlib/gzheader"),f=Object.prototype.toString;function p(g){if(!(this instanceof p))return new p(g);this.options=a.assign({chunkSize:16384,windowBits:0,to:""},g||{});var x=this.options;x.raw&&0<=x.windowBits&&x.windowBits<16&&(x.windowBits=-x.windowBits,x.windowBits===0&&(x.windowBits=-15)),!(0<=x.windowBits&&x.windowBits<16)||g&&g.windowBits||(x.windowBits+=32),15<x.windowBits&&x.windowBits<48&&!(15&x.windowBits)&&(x.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var y=i.inflateInit2(this.strm,x.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new h,i.inflateGetHeader(this.strm,this.header)}function m(g,x){var y=new p(x);if(y.push(g,!0),y.err)throw y.msg||u[y.err];return y.result}p.prototype.push=function(g,x){var y,v,b,w,S,k,E=this.strm,C=this.options.chunkSize,A=this.options.dictionary,M=!1;if(this.ended)return!1;v=x===~~x?x:x===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?E.input=o.binstring2buf(g):f.call(g)==="[object ArrayBuffer]"?E.input=new Uint8Array(g):E.input=g,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new a.Buf8(C),E.next_out=0,E.avail_out=C),(y=i.inflate(E,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(k=typeof A=="string"?o.string2buf(A):f.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,y=i.inflateSetDictionary(this.strm,k)),y===c.Z_BUF_ERROR&&M===!0&&(y=c.Z_OK,M=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);E.next_out&&(E.avail_out!==0&&y!==c.Z_STREAM_END&&(E.avail_in!==0||v!==c.Z_FINISH&&v!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=o.utf8border(E.output,E.next_out),w=E.next_out-b,S=o.buf2string(E.output,b),E.next_out=w,E.avail_out=C-w,w&&a.arraySet(E.output,E.output,b,w,0),this.onData(S)):this.onData(a.shrinkBuf(E.output,E.next_out)))),E.avail_in===0&&E.avail_out===0&&(M=!0)}while((0<E.avail_in||E.avail_out===0)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(v=c.Z_FINISH),v===c.Z_FINISH?(y=i.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c.Z_OK):v!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(E.avail_out=0))},p.prototype.onData=function(g){this.chunks.push(g)},p.prototype.onEnd=function(g){g===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},s.Inflate=p,s.inflate=m,s.inflateRaw=function(g,x){return(x=x||{}).raw=!0,m(g,x)},s.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(r,n,s){var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";s.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var h in d)d.hasOwnProperty(h)&&(c[h]=d[h])}}return c},s.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var a={arraySet:function(c,u,d,h,f){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+h),f);else for(var p=0;p<h;p++)c[f+p]=u[d+p]},flattenChunks:function(c){var u,d,h,f,p,m;for(u=h=0,d=c.length;u<d;u++)h+=c[u].length;for(m=new Uint8Array(h),u=f=0,d=c.length;u<d;u++)p=c[u],m.set(p,f),f+=p.length;return m}},o={arraySet:function(c,u,d,h,f){for(var p=0;p<h;p++)c[f+p]=u[d+p]},flattenChunks:function(c){return[].concat.apply([],c)}};s.setTyped=function(c){c?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,a)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,o))},s.setTyped(i)},{}],42:[function(r,n,s){var i=r("./common"),a=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{o=!1}for(var c=new i.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(h,f){if(f<65537&&(h.subarray&&o||!h.subarray&&a))return String.fromCharCode.apply(null,i.shrinkBuf(h,f));for(var p="",m=0;m<f;m++)p+=String.fromCharCode(h[m]);return p}c[254]=c[254]=1,s.string2buf=function(h){var f,p,m,g,x,y=h.length,v=0;for(g=0;g<y;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<y&&(64512&(m=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),g++),v+=p<128?1:p<2048?2:p<65536?3:4;for(f=new i.Buf8(v),g=x=0;x<v;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<y&&(64512&(m=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),g++),p<128?f[x++]=p:(p<2048?f[x++]=192|p>>>6:(p<65536?f[x++]=224|p>>>12:(f[x++]=240|p>>>18,f[x++]=128|p>>>12&63),f[x++]=128|p>>>6&63),f[x++]=128|63&p);return f},s.buf2binstring=function(h){return d(h,h.length)},s.binstring2buf=function(h){for(var f=new i.Buf8(h.length),p=0,m=f.length;p<m;p++)f[p]=h.charCodeAt(p);return f},s.buf2string=function(h,f){var p,m,g,x,y=f||h.length,v=new Array(2*y);for(p=m=0;p<y;)if((g=h[p++])<128)v[m++]=g;else if(4<(x=c[g]))v[m++]=65533,p+=x-1;else{for(g&=x===2?31:x===3?15:7;1<x&&p<y;)g=g<<6|63&h[p++],x--;1<x?v[m++]=65533:g<65536?v[m++]=g:(g-=65536,v[m++]=55296|g>>10&1023,v[m++]=56320|1023&g)}return d(v,m)},s.utf8border=function(h,f){var p;for((f=f||h.length)>h.length&&(f=h.length),p=f-1;0<=p&&(192&h[p])==128;)p--;return p<0||p===0?f:p+c[h[p]]>f?p:f}},{"./common":41}],43:[function(r,n,s){n.exports=function(i,a,o,c){for(var u=65535&i|0,d=i>>>16&65535|0,h=0;o!==0;){for(o-=h=2e3<o?2e3:o;d=d+(u=u+a[c++]|0)|0,--h;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(r,n,s){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(r,n,s){var i=function(){for(var a,o=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;o[c]=a}return o}();n.exports=function(a,o,c,u){var d=i,h=u+c;a^=-1;for(var f=u;f<h;f++)a=a>>>8^d[255&(a^o[f])];return-1^a}},{}],46:[function(r,n,s){var i,a=r("../utils/common"),o=r("./trees"),c=r("./adler32"),u=r("./crc32"),d=r("./messages"),h=0,f=4,p=0,m=-2,g=-1,x=4,y=2,v=8,b=9,w=286,S=30,k=19,E=2*w+1,C=15,A=3,M=258,z=M+A+1,P=42,W=113,N=1,U=2,K=3,G=4;function X(O,ae){return O.msg=d[ae],ae}function H(O){return(O<<1)-(4<O?9:0)}function B(O){for(var ae=O.length;0<=--ae;)O[ae]=0}function L(O){var ae=O.state,q=ae.pending;q>O.avail_out&&(q=O.avail_out),q!==0&&(a.arraySet(O.output,ae.pending_buf,ae.pending_out,q,O.next_out),O.next_out+=q,ae.pending_out+=q,O.total_out+=q,O.avail_out-=q,ae.pending-=q,ae.pending===0&&(ae.pending_out=0))}function F(O,ae){o._tr_flush_block(O,0<=O.block_start?O.block_start:-1,O.strstart-O.block_start,ae),O.block_start=O.strstart,L(O.strm)}function V(O,ae){O.pending_buf[O.pending++]=ae}function Y(O,ae){O.pending_buf[O.pending++]=ae>>>8&255,O.pending_buf[O.pending++]=255&ae}function ie(O,ae){var q,I,T=O.max_chain_length,$=O.strstart,se=O.prev_length,ue=O.nice_match,ne=O.strstart>O.w_size-z?O.strstart-(O.w_size-z):0,me=O.window,ve=O.w_mask,xe=O.prev,oe=O.strstart+M,de=me[$+se-1],ge=me[$+se];O.prev_length>=O.good_match&&(T>>=2),ue>O.lookahead&&(ue=O.lookahead);do if(me[(q=ae)+se]===ge&&me[q+se-1]===de&&me[q]===me[$]&&me[++q]===me[$+1]){$+=2,q++;do;while(me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&me[++$]===me[++q]&&$<oe);if(I=M-(oe-$),$=oe-M,se<I){if(O.match_start=ae,ue<=(se=I))break;de=me[$+se-1],ge=me[$+se]}}while((ae=xe[ae&ve])>ne&&--T!=0);return se<=O.lookahead?se:O.lookahead}function Q(O){var ae,q,I,T,$,se,ue,ne,me,ve,xe=O.w_size;do{if(T=O.window_size-O.lookahead-O.strstart,O.strstart>=xe+(xe-z)){for(a.arraySet(O.window,O.window,xe,xe,0),O.match_start-=xe,O.strstart-=xe,O.block_start-=xe,ae=q=O.hash_size;I=O.head[--ae],O.head[ae]=xe<=I?I-xe:0,--q;);for(ae=q=xe;I=O.prev[--ae],O.prev[ae]=xe<=I?I-xe:0,--q;);T+=xe}if(O.strm.avail_in===0)break;if(se=O.strm,ue=O.window,ne=O.strstart+O.lookahead,me=T,ve=void 0,ve=se.avail_in,me<ve&&(ve=me),q=ve===0?0:(se.avail_in-=ve,a.arraySet(ue,se.input,se.next_in,ve,ne),se.state.wrap===1?se.adler=c(se.adler,ue,ve,ne):se.state.wrap===2&&(se.adler=u(se.adler,ue,ve,ne)),se.next_in+=ve,se.total_in+=ve,ve),O.lookahead+=q,O.lookahead+O.insert>=A)for($=O.strstart-O.insert,O.ins_h=O.window[$],O.ins_h=(O.ins_h<<O.hash_shift^O.window[$+1])&O.hash_mask;O.insert&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[$+A-1])&O.hash_mask,O.prev[$&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=$,$++,O.insert--,!(O.lookahead+O.insert<A)););}while(O.lookahead<z&&O.strm.avail_in!==0)}function D(O,ae){for(var q,I;;){if(O.lookahead<z){if(Q(O),O.lookahead<z&&ae===h)return N;if(O.lookahead===0)break}if(q=0,O.lookahead>=A&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+A-1])&O.hash_mask,q=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart),q!==0&&O.strstart-q<=O.w_size-z&&(O.match_length=ie(O,q)),O.match_length>=A)if(I=o._tr_tally(O,O.strstart-O.match_start,O.match_length-A),O.lookahead-=O.match_length,O.match_length<=O.max_lazy_match&&O.lookahead>=A){for(O.match_length--;O.strstart++,O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+A-1])&O.hash_mask,q=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart,--O.match_length!=0;);O.strstart++}else O.strstart+=O.match_length,O.match_length=0,O.ins_h=O.window[O.strstart],O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+1])&O.hash_mask;else I=o._tr_tally(O,0,O.window[O.strstart]),O.lookahead--,O.strstart++;if(I&&(F(O,!1),O.strm.avail_out===0))return N}return O.insert=O.strstart<A-1?O.strstart:A-1,ae===f?(F(O,!0),O.strm.avail_out===0?K:G):O.last_lit&&(F(O,!1),O.strm.avail_out===0)?N:U}function R(O,ae){for(var q,I,T;;){if(O.lookahead<z){if(Q(O),O.lookahead<z&&ae===h)return N;if(O.lookahead===0)break}if(q=0,O.lookahead>=A&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+A-1])&O.hash_mask,q=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart),O.prev_length=O.match_length,O.prev_match=O.match_start,O.match_length=A-1,q!==0&&O.prev_length<O.max_lazy_match&&O.strstart-q<=O.w_size-z&&(O.match_length=ie(O,q),O.match_length<=5&&(O.strategy===1||O.match_length===A&&4096<O.strstart-O.match_start)&&(O.match_length=A-1)),O.prev_length>=A&&O.match_length<=O.prev_length){for(T=O.strstart+O.lookahead-A,I=o._tr_tally(O,O.strstart-1-O.prev_match,O.prev_length-A),O.lookahead-=O.prev_length-1,O.prev_length-=2;++O.strstart<=T&&(O.ins_h=(O.ins_h<<O.hash_shift^O.window[O.strstart+A-1])&O.hash_mask,q=O.prev[O.strstart&O.w_mask]=O.head[O.ins_h],O.head[O.ins_h]=O.strstart),--O.prev_length!=0;);if(O.match_available=0,O.match_length=A-1,O.strstart++,I&&(F(O,!1),O.strm.avail_out===0))return N}else if(O.match_available){if((I=o._tr_tally(O,0,O.window[O.strstart-1]))&&F(O,!1),O.strstart++,O.lookahead--,O.strm.avail_out===0)return N}else O.match_available=1,O.strstart++,O.lookahead--}return O.match_available&&(I=o._tr_tally(O,0,O.window[O.strstart-1]),O.match_available=0),O.insert=O.strstart<A-1?O.strstart:A-1,ae===f?(F(O,!0),O.strm.avail_out===0?K:G):O.last_lit&&(F(O,!1),O.strm.avail_out===0)?N:U}function J(O,ae,q,I,T){this.good_length=O,this.max_lazy=ae,this.nice_length=q,this.max_chain=I,this.func=T}function Z(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new a.Buf16(2*E),this.dyn_dtree=new a.Buf16(2*(2*S+1)),this.bl_tree=new a.Buf16(2*(2*k+1)),B(this.dyn_ltree),B(this.dyn_dtree),B(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new a.Buf16(C+1),this.heap=new a.Buf16(2*w+1),B(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new a.Buf16(2*w+1),B(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ee(O){var ae;return O&&O.state?(O.total_in=O.total_out=0,O.data_type=y,(ae=O.state).pending=0,ae.pending_out=0,ae.wrap<0&&(ae.wrap=-ae.wrap),ae.status=ae.wrap?P:W,O.adler=ae.wrap===2?0:1,ae.last_flush=h,o._tr_init(ae),p):X(O,m)}function re(O){var ae=ee(O);return ae===p&&function(q){q.window_size=2*q.w_size,B(q.head),q.max_lazy_match=i[q.level].max_lazy,q.good_match=i[q.level].good_length,q.nice_match=i[q.level].nice_length,q.max_chain_length=i[q.level].max_chain,q.strstart=0,q.block_start=0,q.lookahead=0,q.insert=0,q.match_length=q.prev_length=A-1,q.match_available=0,q.ins_h=0}(O.state),ae}function he(O,ae,q,I,T,$){if(!O)return m;var se=1;if(ae===g&&(ae=6),I<0?(se=0,I=-I):15<I&&(se=2,I-=16),T<1||b<T||q!==v||I<8||15<I||ae<0||9<ae||$<0||x<$)return X(O,m);I===8&&(I=9);var ue=new Z;return(O.state=ue).strm=O,ue.wrap=se,ue.gzhead=null,ue.w_bits=I,ue.w_size=1<<ue.w_bits,ue.w_mask=ue.w_size-1,ue.hash_bits=T+7,ue.hash_size=1<<ue.hash_bits,ue.hash_mask=ue.hash_size-1,ue.hash_shift=~~((ue.hash_bits+A-1)/A),ue.window=new a.Buf8(2*ue.w_size),ue.head=new a.Buf16(ue.hash_size),ue.prev=new a.Buf16(ue.w_size),ue.lit_bufsize=1<<T+6,ue.pending_buf_size=4*ue.lit_bufsize,ue.pending_buf=new a.Buf8(ue.pending_buf_size),ue.d_buf=1*ue.lit_bufsize,ue.l_buf=3*ue.lit_bufsize,ue.level=ae,ue.strategy=$,ue.method=q,re(O)}i=[new J(0,0,0,0,function(O,ae){var q=65535;for(q>O.pending_buf_size-5&&(q=O.pending_buf_size-5);;){if(O.lookahead<=1){if(Q(O),O.lookahead===0&&ae===h)return N;if(O.lookahead===0)break}O.strstart+=O.lookahead,O.lookahead=0;var I=O.block_start+q;if((O.strstart===0||O.strstart>=I)&&(O.lookahead=O.strstart-I,O.strstart=I,F(O,!1),O.strm.avail_out===0)||O.strstart-O.block_start>=O.w_size-z&&(F(O,!1),O.strm.avail_out===0))return N}return O.insert=0,ae===f?(F(O,!0),O.strm.avail_out===0?K:G):(O.strstart>O.block_start&&(F(O,!1),O.strm.avail_out),N)}),new J(4,4,8,4,D),new J(4,5,16,8,D),new J(4,6,32,32,D),new J(4,4,16,16,R),new J(8,16,32,32,R),new J(8,16,128,128,R),new J(8,32,128,256,R),new J(32,128,258,1024,R),new J(32,258,258,4096,R)],s.deflateInit=function(O,ae){return he(O,ae,v,15,8,0)},s.deflateInit2=he,s.deflateReset=re,s.deflateResetKeep=ee,s.deflateSetHeader=function(O,ae){return O&&O.state?O.state.wrap!==2?m:(O.state.gzhead=ae,p):m},s.deflate=function(O,ae){var q,I,T,$;if(!O||!O.state||5<ae||ae<0)return O?X(O,m):m;if(I=O.state,!O.output||!O.input&&O.avail_in!==0||I.status===666&&ae!==f)return X(O,O.avail_out===0?-5:m);if(I.strm=O,q=I.last_flush,I.last_flush=ae,I.status===P)if(I.wrap===2)O.adler=0,V(I,31),V(I,139),V(I,8),I.gzhead?(V(I,(I.gzhead.text?1:0)+(I.gzhead.hcrc?2:0)+(I.gzhead.extra?4:0)+(I.gzhead.name?8:0)+(I.gzhead.comment?16:0)),V(I,255&I.gzhead.time),V(I,I.gzhead.time>>8&255),V(I,I.gzhead.time>>16&255),V(I,I.gzhead.time>>24&255),V(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),V(I,255&I.gzhead.os),I.gzhead.extra&&I.gzhead.extra.length&&(V(I,255&I.gzhead.extra.length),V(I,I.gzhead.extra.length>>8&255)),I.gzhead.hcrc&&(O.adler=u(O.adler,I.pending_buf,I.pending,0)),I.gzindex=0,I.status=69):(V(I,0),V(I,0),V(I,0),V(I,0),V(I,0),V(I,I.level===9?2:2<=I.strategy||I.level<2?4:0),V(I,3),I.status=W);else{var se=v+(I.w_bits-8<<4)<<8;se|=(2<=I.strategy||I.level<2?0:I.level<6?1:I.level===6?2:3)<<6,I.strstart!==0&&(se|=32),se+=31-se%31,I.status=W,Y(I,se),I.strstart!==0&&(Y(I,O.adler>>>16),Y(I,65535&O.adler)),O.adler=1}if(I.status===69)if(I.gzhead.extra){for(T=I.pending;I.gzindex<(65535&I.gzhead.extra.length)&&(I.pending!==I.pending_buf_size||(I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),L(O),T=I.pending,I.pending!==I.pending_buf_size));)V(I,255&I.gzhead.extra[I.gzindex]),I.gzindex++;I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),I.gzindex===I.gzhead.extra.length&&(I.gzindex=0,I.status=73)}else I.status=73;if(I.status===73)if(I.gzhead.name){T=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),L(O),T=I.pending,I.pending===I.pending_buf_size)){$=1;break}$=I.gzindex<I.gzhead.name.length?255&I.gzhead.name.charCodeAt(I.gzindex++):0,V(I,$)}while($!==0);I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),$===0&&(I.gzindex=0,I.status=91)}else I.status=91;if(I.status===91)if(I.gzhead.comment){T=I.pending;do{if(I.pending===I.pending_buf_size&&(I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),L(O),T=I.pending,I.pending===I.pending_buf_size)){$=1;break}$=I.gzindex<I.gzhead.comment.length?255&I.gzhead.comment.charCodeAt(I.gzindex++):0,V(I,$)}while($!==0);I.gzhead.hcrc&&I.pending>T&&(O.adler=u(O.adler,I.pending_buf,I.pending-T,T)),$===0&&(I.status=103)}else I.status=103;if(I.status===103&&(I.gzhead.hcrc?(I.pending+2>I.pending_buf_size&&L(O),I.pending+2<=I.pending_buf_size&&(V(I,255&O.adler),V(I,O.adler>>8&255),O.adler=0,I.status=W)):I.status=W),I.pending!==0){if(L(O),O.avail_out===0)return I.last_flush=-1,p}else if(O.avail_in===0&&H(ae)<=H(q)&&ae!==f)return X(O,-5);if(I.status===666&&O.avail_in!==0)return X(O,-5);if(O.avail_in!==0||I.lookahead!==0||ae!==h&&I.status!==666){var ue=I.strategy===2?function(ne,me){for(var ve;;){if(ne.lookahead===0&&(Q(ne),ne.lookahead===0)){if(me===h)return N;break}if(ne.match_length=0,ve=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++,ve&&(F(ne,!1),ne.strm.avail_out===0))return N}return ne.insert=0,me===f?(F(ne,!0),ne.strm.avail_out===0?K:G):ne.last_lit&&(F(ne,!1),ne.strm.avail_out===0)?N:U}(I,ae):I.strategy===3?function(ne,me){for(var ve,xe,oe,de,ge=ne.window;;){if(ne.lookahead<=M){if(Q(ne),ne.lookahead<=M&&me===h)return N;if(ne.lookahead===0)break}if(ne.match_length=0,ne.lookahead>=A&&0<ne.strstart&&(xe=ge[oe=ne.strstart-1])===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]){de=ne.strstart+M;do;while(xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&xe===ge[++oe]&&oe<de);ne.match_length=M-(de-oe),ne.match_length>ne.lookahead&&(ne.match_length=ne.lookahead)}if(ne.match_length>=A?(ve=o._tr_tally(ne,1,ne.match_length-A),ne.lookahead-=ne.match_length,ne.strstart+=ne.match_length,ne.match_length=0):(ve=o._tr_tally(ne,0,ne.window[ne.strstart]),ne.lookahead--,ne.strstart++),ve&&(F(ne,!1),ne.strm.avail_out===0))return N}return ne.insert=0,me===f?(F(ne,!0),ne.strm.avail_out===0?K:G):ne.last_lit&&(F(ne,!1),ne.strm.avail_out===0)?N:U}(I,ae):i[I.level].func(I,ae);if(ue!==K&&ue!==G||(I.status=666),ue===N||ue===K)return O.avail_out===0&&(I.last_flush=-1),p;if(ue===U&&(ae===1?o._tr_align(I):ae!==5&&(o._tr_stored_block(I,0,0,!1),ae===3&&(B(I.head),I.lookahead===0&&(I.strstart=0,I.block_start=0,I.insert=0))),L(O),O.avail_out===0))return I.last_flush=-1,p}return ae!==f?p:I.wrap<=0?1:(I.wrap===2?(V(I,255&O.adler),V(I,O.adler>>8&255),V(I,O.adler>>16&255),V(I,O.adler>>24&255),V(I,255&O.total_in),V(I,O.total_in>>8&255),V(I,O.total_in>>16&255),V(I,O.total_in>>24&255)):(Y(I,O.adler>>>16),Y(I,65535&O.adler)),L(O),0<I.wrap&&(I.wrap=-I.wrap),I.pending!==0?p:1)},s.deflateEnd=function(O){var ae;return O&&O.state?(ae=O.state.status)!==P&&ae!==69&&ae!==73&&ae!==91&&ae!==103&&ae!==W&&ae!==666?X(O,m):(O.state=null,ae===W?X(O,-3):p):m},s.deflateSetDictionary=function(O,ae){var q,I,T,$,se,ue,ne,me,ve=ae.length;if(!O||!O.state||($=(q=O.state).wrap)===2||$===1&&q.status!==P||q.lookahead)return m;for($===1&&(O.adler=c(O.adler,ae,ve,0)),q.wrap=0,ve>=q.w_size&&($===0&&(B(q.head),q.strstart=0,q.block_start=0,q.insert=0),me=new a.Buf8(q.w_size),a.arraySet(me,ae,ve-q.w_size,q.w_size,0),ae=me,ve=q.w_size),se=O.avail_in,ue=O.next_in,ne=O.input,O.avail_in=ve,O.next_in=0,O.input=ae,Q(q);q.lookahead>=A;){for(I=q.strstart,T=q.lookahead-(A-1);q.ins_h=(q.ins_h<<q.hash_shift^q.window[I+A-1])&q.hash_mask,q.prev[I&q.w_mask]=q.head[q.ins_h],q.head[q.ins_h]=I,I++,--T;);q.strstart=I,q.lookahead=A-1,Q(q)}return q.strstart+=q.lookahead,q.block_start=q.strstart,q.insert=q.lookahead,q.lookahead=0,q.match_length=q.prev_length=A-1,q.match_available=0,O.next_in=ue,O.input=ne,O.avail_in=se,q.wrap=$,p},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(r,n,s){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(r,n,s){n.exports=function(i,a){var o,c,u,d,h,f,p,m,g,x,y,v,b,w,S,k,E,C,A,M,z,P,W,N,U;o=i.state,c=i.next_in,N=i.input,u=c+(i.avail_in-5),d=i.next_out,U=i.output,h=d-(a-i.avail_out),f=d+(i.avail_out-257),p=o.dmax,m=o.wsize,g=o.whave,x=o.wnext,y=o.window,v=o.hold,b=o.bits,w=o.lencode,S=o.distcode,k=(1<<o.lenbits)-1,E=(1<<o.distbits)-1;e:do{b<15&&(v+=N[c++]<<b,b+=8,v+=N[c++]<<b,b+=8),C=w[v&k];t:for(;;){if(v>>>=A=C>>>24,b-=A,(A=C>>>16&255)===0)U[d++]=65535&C;else{if(!(16&A)){if(!(64&A)){C=w[(65535&C)+(v&(1<<A)-1)];continue t}if(32&A){o.mode=12;break e}i.msg="invalid literal/length code",o.mode=30;break e}M=65535&C,(A&=15)&&(b<A&&(v+=N[c++]<<b,b+=8),M+=v&(1<<A)-1,v>>>=A,b-=A),b<15&&(v+=N[c++]<<b,b+=8,v+=N[c++]<<b,b+=8),C=S[v&E];r:for(;;){if(v>>>=A=C>>>24,b-=A,!(16&(A=C>>>16&255))){if(!(64&A)){C=S[(65535&C)+(v&(1<<A)-1)];continue r}i.msg="invalid distance code",o.mode=30;break e}if(z=65535&C,b<(A&=15)&&(v+=N[c++]<<b,(b+=8)<A&&(v+=N[c++]<<b,b+=8)),p<(z+=v&(1<<A)-1)){i.msg="invalid distance too far back",o.mode=30;break e}if(v>>>=A,b-=A,(A=d-h)<z){if(g<(A=z-A)&&o.sane){i.msg="invalid distance too far back",o.mode=30;break e}if(W=y,(P=0)===x){if(P+=m-A,A<M){for(M-=A;U[d++]=y[P++],--A;);P=d-z,W=U}}else if(x<A){if(P+=m+x-A,(A-=x)<M){for(M-=A;U[d++]=y[P++],--A;);if(P=0,x<M){for(M-=A=x;U[d++]=y[P++],--A;);P=d-z,W=U}}}else if(P+=x-A,A<M){for(M-=A;U[d++]=y[P++],--A;);P=d-z,W=U}for(;2<M;)U[d++]=W[P++],U[d++]=W[P++],U[d++]=W[P++],M-=3;M&&(U[d++]=W[P++],1<M&&(U[d++]=W[P++]))}else{for(P=d-z;U[d++]=U[P++],U[d++]=U[P++],U[d++]=U[P++],2<(M-=3););M&&(U[d++]=U[P++],1<M&&(U[d++]=U[P++]))}break}}break}}while(c<u&&d<f);c-=M=b>>3,v&=(1<<(b-=M<<3))-1,i.next_in=c,i.next_out=d,i.avail_in=c<u?u-c+5:5-(c-u),i.avail_out=d<f?f-d+257:257-(d-f),o.hold=v,o.bits=b}},{}],49:[function(r,n,s){var i=r("../utils/common"),a=r("./adler32"),o=r("./crc32"),c=r("./inffast"),u=r("./inftrees"),d=1,h=2,f=0,p=-2,m=1,g=852,x=592;function y(P){return(P>>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(P){var W;return P&&P.state?(W=P.state,P.total_in=P.total_out=W.total=0,P.msg="",W.wrap&&(P.adler=1&W.wrap),W.mode=m,W.last=0,W.havedict=0,W.dmax=32768,W.head=null,W.hold=0,W.bits=0,W.lencode=W.lendyn=new i.Buf32(g),W.distcode=W.distdyn=new i.Buf32(x),W.sane=1,W.back=-1,f):p}function w(P){var W;return P&&P.state?((W=P.state).wsize=0,W.whave=0,W.wnext=0,b(P)):p}function S(P,W){var N,U;return P&&P.state?(U=P.state,W<0?(N=0,W=-W):(N=1+(W>>4),W<48&&(W&=15)),W&&(W<8||15<W)?p:(U.window!==null&&U.wbits!==W&&(U.window=null),U.wrap=N,U.wbits=W,w(P))):p}function k(P,W){var N,U;return P?(U=new v,(P.state=U).window=null,(N=S(P,W))!==f&&(P.state=null),N):p}var E,C,A=!0;function M(P){if(A){var W;for(E=new i.Buf32(512),C=new i.Buf32(32),W=0;W<144;)P.lens[W++]=8;for(;W<256;)P.lens[W++]=9;for(;W<280;)P.lens[W++]=7;for(;W<288;)P.lens[W++]=8;for(u(d,P.lens,0,288,E,0,P.work,{bits:9}),W=0;W<32;)P.lens[W++]=5;u(h,P.lens,0,32,C,0,P.work,{bits:5}),A=!1}P.lencode=E,P.lenbits=9,P.distcode=C,P.distbits=5}function z(P,W,N,U){var K,G=P.state;return G.window===null&&(G.wsize=1<<G.wbits,G.wnext=0,G.whave=0,G.window=new i.Buf8(G.wsize)),U>=G.wsize?(i.arraySet(G.window,W,N-G.wsize,G.wsize,0),G.wnext=0,G.whave=G.wsize):(U<(K=G.wsize-G.wnext)&&(K=U),i.arraySet(G.window,W,N-U,K,G.wnext),(U-=K)?(i.arraySet(G.window,W,N-U,U,0),G.wnext=U,G.whave=G.wsize):(G.wnext+=K,G.wnext===G.wsize&&(G.wnext=0),G.whave<G.wsize&&(G.whave+=K))),0}s.inflateReset=w,s.inflateReset2=S,s.inflateResetKeep=b,s.inflateInit=function(P){return k(P,15)},s.inflateInit2=k,s.inflate=function(P,W){var N,U,K,G,X,H,B,L,F,V,Y,ie,Q,D,R,J,Z,ee,re,he,O,ae,q,I,T=0,$=new i.Buf8(4),se=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!P||!P.state||!P.output||!P.input&&P.avail_in!==0)return p;(N=P.state).mode===12&&(N.mode=13),X=P.next_out,K=P.output,B=P.avail_out,G=P.next_in,U=P.input,H=P.avail_in,L=N.hold,F=N.bits,V=H,Y=B,ae=f;e:for(;;)switch(N.mode){case m:if(N.wrap===0){N.mode=13;break}for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(2&N.wrap&&L===35615){$[N.check=0]=255&L,$[1]=L>>>8&255,N.check=o(N.check,$,2,0),F=L=0,N.mode=2;break}if(N.flags=0,N.head&&(N.head.done=!1),!(1&N.wrap)||(((255&L)<<8)+(L>>8))%31){P.msg="incorrect header check",N.mode=30;break}if((15&L)!=8){P.msg="unknown compression method",N.mode=30;break}if(F-=4,O=8+(15&(L>>>=4)),N.wbits===0)N.wbits=O;else if(O>N.wbits){P.msg="invalid window size",N.mode=30;break}N.dmax=1<<O,P.adler=N.check=1,N.mode=512&L?10:12,F=L=0;break;case 2:for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(N.flags=L,(255&N.flags)!=8){P.msg="unknown compression method",N.mode=30;break}if(57344&N.flags){P.msg="unknown header flags set",N.mode=30;break}N.head&&(N.head.text=L>>8&1),512&N.flags&&($[0]=255&L,$[1]=L>>>8&255,N.check=o(N.check,$,2,0)),F=L=0,N.mode=3;case 3:for(;F<32;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.head&&(N.head.time=L),512&N.flags&&($[0]=255&L,$[1]=L>>>8&255,$[2]=L>>>16&255,$[3]=L>>>24&255,N.check=o(N.check,$,4,0)),F=L=0,N.mode=4;case 4:for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.head&&(N.head.xflags=255&L,N.head.os=L>>8),512&N.flags&&($[0]=255&L,$[1]=L>>>8&255,N.check=o(N.check,$,2,0)),F=L=0,N.mode=5;case 5:if(1024&N.flags){for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.length=L,N.head&&(N.head.extra_len=L),512&N.flags&&($[0]=255&L,$[1]=L>>>8&255,N.check=o(N.check,$,2,0)),F=L=0}else N.head&&(N.head.extra=null);N.mode=6;case 6:if(1024&N.flags&&(H<(ie=N.length)&&(ie=H),ie&&(N.head&&(O=N.head.extra_len-N.length,N.head.extra||(N.head.extra=new Array(N.head.extra_len)),i.arraySet(N.head.extra,U,G,ie,O)),512&N.flags&&(N.check=o(N.check,U,ie,G)),H-=ie,G+=ie,N.length-=ie),N.length))break e;N.length=0,N.mode=7;case 7:if(2048&N.flags){if(H===0)break e;for(ie=0;O=U[G+ie++],N.head&&O&&N.length<65536&&(N.head.name+=String.fromCharCode(O)),O&&ie<H;);if(512&N.flags&&(N.check=o(N.check,U,ie,G)),H-=ie,G+=ie,O)break e}else N.head&&(N.head.name=null);N.length=0,N.mode=8;case 8:if(4096&N.flags){if(H===0)break e;for(ie=0;O=U[G+ie++],N.head&&O&&N.length<65536&&(N.head.comment+=String.fromCharCode(O)),O&&ie<H;);if(512&N.flags&&(N.check=o(N.check,U,ie,G)),H-=ie,G+=ie,O)break e}else N.head&&(N.head.comment=null);N.mode=9;case 9:if(512&N.flags){for(;F<16;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(L!==(65535&N.check)){P.msg="header crc mismatch",N.mode=30;break}F=L=0}N.head&&(N.head.hcrc=N.flags>>9&1,N.head.done=!0),P.adler=N.check=0,N.mode=12;break;case 10:for(;F<32;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}P.adler=N.check=y(L),F=L=0,N.mode=11;case 11:if(N.havedict===0)return P.next_out=X,P.avail_out=B,P.next_in=G,P.avail_in=H,N.hold=L,N.bits=F,2;P.adler=N.check=1,N.mode=12;case 12:if(W===5||W===6)break e;case 13:if(N.last){L>>>=7&F,F-=7&F,N.mode=27;break}for(;F<3;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}switch(N.last=1&L,F-=1,3&(L>>>=1)){case 0:N.mode=14;break;case 1:if(M(N),N.mode=20,W!==6)break;L>>>=2,F-=2;break e;case 2:N.mode=17;break;case 3:P.msg="invalid block type",N.mode=30}L>>>=2,F-=2;break;case 14:for(L>>>=7&F,F-=7&F;F<32;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if((65535&L)!=(L>>>16^65535)){P.msg="invalid stored block lengths",N.mode=30;break}if(N.length=65535&L,F=L=0,N.mode=15,W===6)break e;case 15:N.mode=16;case 16:if(ie=N.length){if(H<ie&&(ie=H),B<ie&&(ie=B),ie===0)break e;i.arraySet(K,U,G,ie,X),H-=ie,G+=ie,B-=ie,X+=ie,N.length-=ie;break}N.mode=12;break;case 17:for(;F<14;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(N.nlen=257+(31&L),L>>>=5,F-=5,N.ndist=1+(31&L),L>>>=5,F-=5,N.ncode=4+(15&L),L>>>=4,F-=4,286<N.nlen||30<N.ndist){P.msg="too many length or distance symbols",N.mode=30;break}N.have=0,N.mode=18;case 18:for(;N.have<N.ncode;){for(;F<3;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.lens[se[N.have++]]=7&L,L>>>=3,F-=3}for(;N.have<19;)N.lens[se[N.have++]]=0;if(N.lencode=N.lendyn,N.lenbits=7,q={bits:N.lenbits},ae=u(0,N.lens,0,19,N.lencode,0,N.work,q),N.lenbits=q.bits,ae){P.msg="invalid code lengths set",N.mode=30;break}N.have=0,N.mode=19;case 19:for(;N.have<N.nlen+N.ndist;){for(;J=(T=N.lencode[L&(1<<N.lenbits)-1])>>>16&255,Z=65535&T,!((R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(Z<16)L>>>=R,F-=R,N.lens[N.have++]=Z;else{if(Z===16){for(I=R+2;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(L>>>=R,F-=R,N.have===0){P.msg="invalid bit length repeat",N.mode=30;break}O=N.lens[N.have-1],ie=3+(3&L),L>>>=2,F-=2}else if(Z===17){for(I=R+3;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}F-=R,O=0,ie=3+(7&(L>>>=R)),L>>>=3,F-=3}else{for(I=R+7;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}F-=R,O=0,ie=11+(127&(L>>>=R)),L>>>=7,F-=7}if(N.have+ie>N.nlen+N.ndist){P.msg="invalid bit length repeat",N.mode=30;break}for(;ie--;)N.lens[N.have++]=O}}if(N.mode===30)break;if(N.lens[256]===0){P.msg="invalid code -- missing end-of-block",N.mode=30;break}if(N.lenbits=9,q={bits:N.lenbits},ae=u(d,N.lens,0,N.nlen,N.lencode,0,N.work,q),N.lenbits=q.bits,ae){P.msg="invalid literal/lengths set",N.mode=30;break}if(N.distbits=6,N.distcode=N.distdyn,q={bits:N.distbits},ae=u(h,N.lens,N.nlen,N.ndist,N.distcode,0,N.work,q),N.distbits=q.bits,ae){P.msg="invalid distances set",N.mode=30;break}if(N.mode=20,W===6)break e;case 20:N.mode=21;case 21:if(6<=H&&258<=B){P.next_out=X,P.avail_out=B,P.next_in=G,P.avail_in=H,N.hold=L,N.bits=F,c(P,Y),X=P.next_out,K=P.output,B=P.avail_out,G=P.next_in,U=P.input,H=P.avail_in,L=N.hold,F=N.bits,N.mode===12&&(N.back=-1);break}for(N.back=0;J=(T=N.lencode[L&(1<<N.lenbits)-1])>>>16&255,Z=65535&T,!((R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(J&&!(240&J)){for(ee=R,re=J,he=Z;J=(T=N.lencode[he+((L&(1<<ee+re)-1)>>ee)])>>>16&255,Z=65535&T,!(ee+(R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}L>>>=ee,F-=ee,N.back+=ee}if(L>>>=R,F-=R,N.back+=R,N.length=Z,J===0){N.mode=26;break}if(32&J){N.back=-1,N.mode=12;break}if(64&J){P.msg="invalid literal/length code",N.mode=30;break}N.extra=15&J,N.mode=22;case 22:if(N.extra){for(I=N.extra;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.length+=L&(1<<N.extra)-1,L>>>=N.extra,F-=N.extra,N.back+=N.extra}N.was=N.length,N.mode=23;case 23:for(;J=(T=N.distcode[L&(1<<N.distbits)-1])>>>16&255,Z=65535&T,!((R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(!(240&J)){for(ee=R,re=J,he=Z;J=(T=N.distcode[he+((L&(1<<ee+re)-1)>>ee)])>>>16&255,Z=65535&T,!(ee+(R=T>>>24)<=F);){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}L>>>=ee,F-=ee,N.back+=ee}if(L>>>=R,F-=R,N.back+=R,64&J){P.msg="invalid distance code",N.mode=30;break}N.offset=Z,N.extra=15&J,N.mode=24;case 24:if(N.extra){for(I=N.extra;F<I;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}N.offset+=L&(1<<N.extra)-1,L>>>=N.extra,F-=N.extra,N.back+=N.extra}if(N.offset>N.dmax){P.msg="invalid distance too far back",N.mode=30;break}N.mode=25;case 25:if(B===0)break e;if(ie=Y-B,N.offset>ie){if((ie=N.offset-ie)>N.whave&&N.sane){P.msg="invalid distance too far back",N.mode=30;break}Q=ie>N.wnext?(ie-=N.wnext,N.wsize-ie):N.wnext-ie,ie>N.length&&(ie=N.length),D=N.window}else D=K,Q=X-N.offset,ie=N.length;for(B<ie&&(ie=B),B-=ie,N.length-=ie;K[X++]=D[Q++],--ie;);N.length===0&&(N.mode=21);break;case 26:if(B===0)break e;K[X++]=N.length,B--,N.mode=21;break;case 27:if(N.wrap){for(;F<32;){if(H===0)break e;H--,L|=U[G++]<<F,F+=8}if(Y-=B,P.total_out+=Y,N.total+=Y,Y&&(P.adler=N.check=N.flags?o(N.check,K,Y,X-Y):a(N.check,K,Y,X-Y)),Y=B,(N.flags?L:y(L))!==N.check){P.msg="incorrect data check",N.mode=30;break}F=L=0}N.mode=28;case 28:if(N.wrap&&N.flags){for(;F<32;){if(H===0)break e;H--,L+=U[G++]<<F,F+=8}if(L!==(4294967295&N.total)){P.msg="incorrect length check",N.mode=30;break}F=L=0}N.mode=29;case 29:ae=1;break e;case 30:ae=-3;break e;case 31:return-4;case 32:default:return p}return P.next_out=X,P.avail_out=B,P.next_in=G,P.avail_in=H,N.hold=L,N.bits=F,(N.wsize||Y!==P.avail_out&&N.mode<30&&(N.mode<27||W!==4))&&z(P,P.output,P.next_out,Y-P.avail_out)?(N.mode=31,-4):(V-=P.avail_in,Y-=P.avail_out,P.total_in+=V,P.total_out+=Y,N.total+=Y,N.wrap&&Y&&(P.adler=N.check=N.flags?o(N.check,K,Y,P.next_out-Y):a(N.check,K,Y,P.next_out-Y)),P.data_type=N.bits+(N.last?64:0)+(N.mode===12?128:0)+(N.mode===20||N.mode===15?256:0),(V==0&&Y===0||W===4)&&ae===f&&(ae=-5),ae)},s.inflateEnd=function(P){if(!P||!P.state)return p;var W=P.state;return W.window&&(W.window=null),P.state=null,f},s.inflateGetHeader=function(P,W){var N;return P&&P.state&&2&(N=P.state).wrap?((N.head=W).done=!1,f):p},s.inflateSetDictionary=function(P,W){var N,U=W.length;return P&&P.state?(N=P.state).wrap!==0&&N.mode!==11?p:N.mode===11&&a(1,W,U,0)!==N.check?-3:z(P,W,U,U)?(N.mode=31,-4):(N.havedict=1,f):p},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(r,n,s){var i=r("../utils/common"),a=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(d,h,f,p,m,g,x,y){var v,b,w,S,k,E,C,A,M,z=y.bits,P=0,W=0,N=0,U=0,K=0,G=0,X=0,H=0,B=0,L=0,F=null,V=0,Y=new i.Buf16(16),ie=new i.Buf16(16),Q=null,D=0;for(P=0;P<=15;P++)Y[P]=0;for(W=0;W<p;W++)Y[h[f+W]]++;for(K=z,U=15;1<=U&&Y[U]===0;U--);if(U<K&&(K=U),U===0)return m[g++]=20971520,m[g++]=20971520,y.bits=1,0;for(N=1;N<U&&Y[N]===0;N++);for(K<N&&(K=N),P=H=1;P<=15;P++)if(H<<=1,(H-=Y[P])<0)return-1;if(0<H&&(d===0||U!==1))return-1;for(ie[1]=0,P=1;P<15;P++)ie[P+1]=ie[P]+Y[P];for(W=0;W<p;W++)h[f+W]!==0&&(x[ie[h[f+W]]++]=W);if(E=d===0?(F=Q=x,19):d===1?(F=a,V-=257,Q=o,D-=257,256):(F=c,Q=u,-1),P=N,k=g,X=W=L=0,w=-1,S=(B=1<<(G=K))-1,d===1&&852<B||d===2&&592<B)return 1;for(;;){for(C=P-X,M=x[W]<E?(A=0,x[W]):x[W]>E?(A=Q[D+x[W]],F[V+x[W]]):(A=96,0),v=1<<P-X,N=b=1<<G;m[k+(L>>X)+(b-=v)]=C<<24|A<<16|M|0,b!==0;);for(v=1<<P-1;L&v;)v>>=1;if(v!==0?(L&=v-1,L+=v):L=0,W++,--Y[P]==0){if(P===U)break;P=h[f+x[W]]}if(K<P&&(L&S)!==w){for(X===0&&(X=K),k+=N,H=1<<(G=P-X);G+X<U&&!((H-=Y[G+X])<=0);)G++,H<<=1;if(B+=1<<G,d===1&&852<B||d===2&&592<B)return 1;m[w=L&S]=K<<24|G<<16|k-g|0}}return L!==0&&(m[k+L]=P-X<<24|64<<16|0),y.bits=K,0}},{"../utils/common":41}],51:[function(r,n,s){n.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(r,n,s){var i=r("../utils/common"),a=0,o=1;function c(T){for(var $=T.length;0<=--$;)T[$]=0}var u=0,d=29,h=256,f=h+1+d,p=30,m=19,g=2*f+1,x=15,y=16,v=7,b=256,w=16,S=17,k=18,E=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],C=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],z=new Array(2*(f+2));c(z);var P=new Array(2*p);c(P);var W=new Array(512);c(W);var N=new Array(256);c(N);var U=new Array(d);c(U);var K,G,X,H=new Array(p);function B(T,$,se,ue,ne){this.static_tree=T,this.extra_bits=$,this.extra_base=se,this.elems=ue,this.max_length=ne,this.has_stree=T&&T.length}function L(T,$){this.dyn_tree=T,this.max_code=0,this.stat_desc=$}function F(T){return T<256?W[T]:W[256+(T>>>7)]}function V(T,$){T.pending_buf[T.pending++]=255&$,T.pending_buf[T.pending++]=$>>>8&255}function Y(T,$,se){T.bi_valid>y-se?(T.bi_buf|=$<<T.bi_valid&65535,V(T,T.bi_buf),T.bi_buf=$>>y-T.bi_valid,T.bi_valid+=se-y):(T.bi_buf|=$<<T.bi_valid&65535,T.bi_valid+=se)}function ie(T,$,se){Y(T,se[2*$],se[2*$+1])}function Q(T,$){for(var se=0;se|=1&T,T>>>=1,se<<=1,0<--$;);return se>>>1}function D(T,$,se){var ue,ne,me=new Array(x+1),ve=0;for(ue=1;ue<=x;ue++)me[ue]=ve=ve+se[ue-1]<<1;for(ne=0;ne<=$;ne++){var xe=T[2*ne+1];xe!==0&&(T[2*ne]=Q(me[xe]++,xe))}}function R(T){var $;for($=0;$<f;$++)T.dyn_ltree[2*$]=0;for($=0;$<p;$++)T.dyn_dtree[2*$]=0;for($=0;$<m;$++)T.bl_tree[2*$]=0;T.dyn_ltree[2*b]=1,T.opt_len=T.static_len=0,T.last_lit=T.matches=0}function J(T){8<T.bi_valid?V(T,T.bi_buf):0<T.bi_valid&&(T.pending_buf[T.pending++]=T.bi_buf),T.bi_buf=0,T.bi_valid=0}function Z(T,$,se,ue){var ne=2*$,me=2*se;return T[ne]<T[me]||T[ne]===T[me]&&ue[$]<=ue[se]}function ee(T,$,se){for(var ue=T.heap[se],ne=se<<1;ne<=T.heap_len&&(ne<T.heap_len&&Z($,T.heap[ne+1],T.heap[ne],T.depth)&&ne++,!Z($,ue,T.heap[ne],T.depth));)T.heap[se]=T.heap[ne],se=ne,ne<<=1;T.heap[se]=ue}function re(T,$,se){var ue,ne,me,ve,xe=0;if(T.last_lit!==0)for(;ue=T.pending_buf[T.d_buf+2*xe]<<8|T.pending_buf[T.d_buf+2*xe+1],ne=T.pending_buf[T.l_buf+xe],xe++,ue===0?ie(T,ne,$):(ie(T,(me=N[ne])+h+1,$),(ve=E[me])!==0&&Y(T,ne-=U[me],ve),ie(T,me=F(--ue),se),(ve=C[me])!==0&&Y(T,ue-=H[me],ve)),xe<T.last_lit;);ie(T,b,$)}function he(T,$){var se,ue,ne,me=$.dyn_tree,ve=$.stat_desc.static_tree,xe=$.stat_desc.has_stree,oe=$.stat_desc.elems,de=-1;for(T.heap_len=0,T.heap_max=g,se=0;se<oe;se++)me[2*se]!==0?(T.heap[++T.heap_len]=de=se,T.depth[se]=0):me[2*se+1]=0;for(;T.heap_len<2;)me[2*(ne=T.heap[++T.heap_len]=de<2?++de:0)]=1,T.depth[ne]=0,T.opt_len--,xe&&(T.static_len-=ve[2*ne+1]);for($.max_code=de,se=T.heap_len>>1;1<=se;se--)ee(T,me,se);for(ne=oe;se=T.heap[1],T.heap[1]=T.heap[T.heap_len--],ee(T,me,1),ue=T.heap[1],T.heap[--T.heap_max]=se,T.heap[--T.heap_max]=ue,me[2*ne]=me[2*se]+me[2*ue],T.depth[ne]=(T.depth[se]>=T.depth[ue]?T.depth[se]:T.depth[ue])+1,me[2*se+1]=me[2*ue+1]=ne,T.heap[1]=ne++,ee(T,me,1),2<=T.heap_len;);T.heap[--T.heap_max]=T.heap[1],function(ge,Se){var ke,Ne,qe,Ae,fe,Te,Pe=Se.dyn_tree,tt=Se.max_code,wt=Se.stat_desc.static_tree,Ee=Se.stat_desc.has_stree,nt=Se.stat_desc.extra_bits,rt=Se.stat_desc.extra_base,Ze=Se.stat_desc.max_length,we=0;for(Ae=0;Ae<=x;Ae++)ge.bl_count[Ae]=0;for(Pe[2*ge.heap[ge.heap_max]+1]=0,ke=ge.heap_max+1;ke<g;ke++)Ze<(Ae=Pe[2*Pe[2*(Ne=ge.heap[ke])+1]+1]+1)&&(Ae=Ze,we++),Pe[2*Ne+1]=Ae,tt<Ne||(ge.bl_count[Ae]++,fe=0,rt<=Ne&&(fe=nt[Ne-rt]),Te=Pe[2*Ne],ge.opt_len+=Te*(Ae+fe),Ee&&(ge.static_len+=Te*(wt[2*Ne+1]+fe)));if(we!==0){do{for(Ae=Ze-1;ge.bl_count[Ae]===0;)Ae--;ge.bl_count[Ae]--,ge.bl_count[Ae+1]+=2,ge.bl_count[Ze]--,we-=2}while(0<we);for(Ae=Ze;Ae!==0;Ae--)for(Ne=ge.bl_count[Ae];Ne!==0;)tt<(qe=ge.heap[--ke])||(Pe[2*qe+1]!==Ae&&(ge.opt_len+=(Ae-Pe[2*qe+1])*Pe[2*qe],Pe[2*qe+1]=Ae),Ne--)}}(T,$),D(me,de,T.bl_count)}function O(T,$,se){var ue,ne,me=-1,ve=$[1],xe=0,oe=7,de=4;for(ve===0&&(oe=138,de=3),$[2*(se+1)+1]=65535,ue=0;ue<=se;ue++)ne=ve,ve=$[2*(ue+1)+1],++xe<oe&&ne===ve||(xe<de?T.bl_tree[2*ne]+=xe:ne!==0?(ne!==me&&T.bl_tree[2*ne]++,T.bl_tree[2*w]++):xe<=10?T.bl_tree[2*S]++:T.bl_tree[2*k]++,me=ne,de=(xe=0)===ve?(oe=138,3):ne===ve?(oe=6,3):(oe=7,4))}function ae(T,$,se){var ue,ne,me=-1,ve=$[1],xe=0,oe=7,de=4;for(ve===0&&(oe=138,de=3),ue=0;ue<=se;ue++)if(ne=ve,ve=$[2*(ue+1)+1],!(++xe<oe&&ne===ve)){if(xe<de)for(;ie(T,ne,T.bl_tree),--xe!=0;);else ne!==0?(ne!==me&&(ie(T,ne,T.bl_tree),xe--),ie(T,w,T.bl_tree),Y(T,xe-3,2)):xe<=10?(ie(T,S,T.bl_tree),Y(T,xe-3,3)):(ie(T,k,T.bl_tree),Y(T,xe-11,7));me=ne,de=(xe=0)===ve?(oe=138,3):ne===ve?(oe=6,3):(oe=7,4)}}c(H);var q=!1;function I(T,$,se,ue){Y(T,(u<<1)+(ue?1:0),3),function(ne,me,ve,xe){J(ne),V(ne,ve),V(ne,~ve),i.arraySet(ne.pending_buf,ne.window,me,ve,ne.pending),ne.pending+=ve}(T,$,se)}s._tr_init=function(T){q||(function(){var $,se,ue,ne,me,ve=new Array(x+1);for(ne=ue=0;ne<d-1;ne++)for(U[ne]=ue,$=0;$<1<<E[ne];$++)N[ue++]=ne;for(N[ue-1]=ne,ne=me=0;ne<16;ne++)for(H[ne]=me,$=0;$<1<<C[ne];$++)W[me++]=ne;for(me>>=7;ne<p;ne++)for(H[ne]=me<<7,$=0;$<1<<C[ne]-7;$++)W[256+me++]=ne;for(se=0;se<=x;se++)ve[se]=0;for($=0;$<=143;)z[2*$+1]=8,$++,ve[8]++;for(;$<=255;)z[2*$+1]=9,$++,ve[9]++;for(;$<=279;)z[2*$+1]=7,$++,ve[7]++;for(;$<=287;)z[2*$+1]=8,$++,ve[8]++;for(D(z,f+1,ve),$=0;$<p;$++)P[2*$+1]=5,P[2*$]=Q($,5);K=new B(z,E,h+1,f,x),G=new B(P,C,0,p,x),X=new B(new Array(0),A,0,m,v)}(),q=!0),T.l_desc=new L(T.dyn_ltree,K),T.d_desc=new L(T.dyn_dtree,G),T.bl_desc=new L(T.bl_tree,X),T.bi_buf=0,T.bi_valid=0,R(T)},s._tr_stored_block=I,s._tr_flush_block=function(T,$,se,ue){var ne,me,ve=0;0<T.level?(T.strm.data_type===2&&(T.strm.data_type=function(xe){var oe,de=4093624447;for(oe=0;oe<=31;oe++,de>>>=1)if(1&de&&xe.dyn_ltree[2*oe]!==0)return a;if(xe.dyn_ltree[18]!==0||xe.dyn_ltree[20]!==0||xe.dyn_ltree[26]!==0)return o;for(oe=32;oe<h;oe++)if(xe.dyn_ltree[2*oe]!==0)return o;return a}(T)),he(T,T.l_desc),he(T,T.d_desc),ve=function(xe){var oe;for(O(xe,xe.dyn_ltree,xe.l_desc.max_code),O(xe,xe.dyn_dtree,xe.d_desc.max_code),he(xe,xe.bl_desc),oe=m-1;3<=oe&&xe.bl_tree[2*M[oe]+1]===0;oe--);return xe.opt_len+=3*(oe+1)+5+5+4,oe}(T),ne=T.opt_len+3+7>>>3,(me=T.static_len+3+7>>>3)<=ne&&(ne=me)):ne=me=se+5,se+4<=ne&&$!==-1?I(T,$,se,ue):T.strategy===4||me===ne?(Y(T,2+(ue?1:0),3),re(T,z,P)):(Y(T,4+(ue?1:0),3),function(xe,oe,de,ge){var Se;for(Y(xe,oe-257,5),Y(xe,de-1,5),Y(xe,ge-4,4),Se=0;Se<ge;Se++)Y(xe,xe.bl_tree[2*M[Se]+1],3);ae(xe,xe.dyn_ltree,oe-1),ae(xe,xe.dyn_dtree,de-1)}(T,T.l_desc.max_code+1,T.d_desc.max_code+1,ve+1),re(T,T.dyn_ltree,T.dyn_dtree)),R(T),ue&&J(T)},s._tr_tally=function(T,$,se){return T.pending_buf[T.d_buf+2*T.last_lit]=$>>>8&255,T.pending_buf[T.d_buf+2*T.last_lit+1]=255&$,T.pending_buf[T.l_buf+T.last_lit]=255&se,T.last_lit++,$===0?T.dyn_ltree[2*se]++:(T.matches++,$--,T.dyn_ltree[2*(N[se]+h+1)]++,T.dyn_dtree[2*F($)]++),T.last_lit===T.lit_bufsize-1},s._tr_align=function(T){Y(T,2,3),ie(T,b,z),function($){$.bi_valid===16?(V($,$.bi_buf),$.bi_buf=0,$.bi_valid=0):8<=$.bi_valid&&($.pending_buf[$.pending++]=255&$.bi_buf,$.bi_buf>>=8,$.bi_valid-=8)}(T)}},{"../utils/common":41}],53:[function(r,n,s){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,n,s){(function(i){(function(a,o){if(!a.setImmediate){var c,u,d,h,f=1,p={},m=!1,g=a.document,x=Object.getPrototypeOf&&Object.getPrototypeOf(a);x=x&&x.setTimeout?x:a,c={}.toString.call(a.process)==="[object process]"?function(w){Jt.nextTick(function(){v(w)})}:function(){if(a.postMessage&&!a.importScripts){var w=!0,S=a.onmessage;return a.onmessage=function(){w=!1},a.postMessage("","*"),a.onmessage=S,w}}()?(h="setImmediate$"+Math.random()+"$",a.addEventListener?a.addEventListener("message",b,!1):a.attachEvent("onmessage",b),function(w){a.postMessage(h+w,"*")}):a.MessageChannel?((d=new MessageChannel).port1.onmessage=function(w){v(w.data)},function(w){d.port2.postMessage(w)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(w){var S=g.createElement("script");S.onreadystatechange=function(){v(w),S.onreadystatechange=null,u.removeChild(S),S=null},u.appendChild(S)}):function(w){setTimeout(v,0,w)},x.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var S=new Array(arguments.length-1),k=0;k<S.length;k++)S[k]=arguments[k+1];var E={callback:w,args:S};return p[f]=E,c(f),f++},x.clearImmediate=y}function y(w){delete p[w]}function v(w){if(m)setTimeout(v,0,w);else{var S=p[w];if(S){m=!0;try{(function(k){var E=k.callback,C=k.args;switch(C.length){case 0:E();break;case 1:E(C[0]);break;case 2:E(C[0],C[1]);break;case 3:E(C[0],C[1],C[2]);break;default:E.apply(o,C)}})(S)}finally{y(w),m=!1}}}}function b(w){w.source===a&&typeof w.data=="string"&&w.data.indexOf(h)===0&&v(+w.data.slice(h.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof gu<"u"?gu:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}(L3)),L3.exports}var zCt=BCt();const UCt=xSe(zCt);var Q1={exports:{}},F3,mse;function HCt(){if(mse)return F3;mse=1;var t={"&":"&",'"':""","'":"'","<":"<",">":">"};function e(r){return r&&r.replace?r.replace(/([&"<>'])/g,function(n,s){return t[s]}):r}return F3=e,F3}var gse;function VCt(){if(gse)return Q1.exports;gse=1;var t=HCt(),e=p7().Stream,r=" ";function n(u,d){typeof d!="object"&&(d={indent:d});var h=d.stream?new e:null,f="",p=!1,m=d.indent?d.indent===!0?r:d.indent:"",g=!0;function x(S){g?Jt.nextTick(S):S()}function y(S,k){if(k!==void 0&&(f+=k),S&&!p&&(h=h||new e,p=!0),S&&p){var E=f;x(function(){h.emit("data",E)}),f=""}}function v(S,k){o(y,a(S,m,m?1:0),k)}function b(){if(h){var S=f;x(function(){h.emit("data",S),h.emit("end"),h.readable=!1,h.emit("close")})}}function w(S){var k=S.encoding||"UTF-8",E={version:"1.0",encoding:k};S.standalone&&(E.standalone=S.standalone),v({"?xml":{_attr:E}}),f=f.replace("/>","?>")}return x(function(){g=!1}),d.declaration&&w(d.declaration),u&&u.forEach?u.forEach(function(S,k){var E;k+1===u.length&&(E=b),v(S,E)}):v(u,b),h?(h.readable=!0,h):f}function s(){var u=Array.prototype.slice.call(arguments),d={_elem:a(u)};return d.push=function(h){if(!this.append)throw new Error("not assigned to a parent!");var f=this,p=this._elem.indent;o(this.append,a(h,p,this._elem.icount+(p?1:0)),function(){f.append(!0)})},d.close=function(h){h!==void 0&&this.push(h),this.end&&this.end()},d}function i(u,d){return new Array(d||0).join(u||"")}function a(u,d,h){h=h||0;var f=i(d,h),p,m=u,g=!1;if(typeof u=="object"){var x=Object.keys(u);if(p=x[0],m=u[p],m&&m._elem)return m._elem.name=p,m._elem.icount=h,m._elem.indent=d,m._elem.indents=f,m._elem.interrupt=m,m._elem}var y=[],v=[],b;function w(S){var k=Object.keys(S);k.forEach(function(E){y.push(c(E,S[E]))})}switch(typeof m){case"object":if(m===null)break;m._attr&&w(m._attr),m._cdata&&v.push(("<![CDATA["+m._cdata).replace(/\]\]>/g,"]]]]><![CDATA[>")+"]]>"),m.forEach&&(b=!1,v.push(""),m.forEach(function(S){if(typeof S=="object"){var k=Object.keys(S)[0];k=="_attr"?w(S._attr):v.push(a(S,d,h+1))}else v.pop(),b=!0,v.push(t(S))}),b||v.push(""));break;default:v.push(t(m))}return{name:p,interrupt:g,attributes:y,content:v,icount:h,indents:f,indent:d}}function o(u,d,h){if(typeof d!="object")return u(!1,d);var f=d.interrupt?1:d.content.length;function p(){for(;d.content.length;){var g=d.content.shift();if(g!==void 0){if(m(g))return;o(u,g)}}u(!1,(f>1?d.indents:"")+(d.name?"</"+d.name+">":"")+(d.indent&&!h?`
`:"")),h&&h()}function m(g){return g.interrupt?(g.interrupt.append=u,g.interrupt.end=p,g.interrupt=!1,u(!0),!0):!1}if(u(!1,d.indents+(d.name?"<"+d.name:"")+(d.attributes.length?" "+d.attributes.join(" "):"")+(f?d.name?">":"":d.name?"/>":"")+(d.indent&&f>1?`
`:"")),!f)return u(!1,d.indent?`
`:"");m(d)||p()}function c(u,d){return u+'="'+t(d)+'"'}return Q1.exports=n,Q1.exports.element=Q1.exports.Element=s,Q1.exports}var WCt=VCt();const In=xSe(WCt),Z1=0,$3=32,qCt=32,GCt=(t,e)=>{const r=e.replace(/-/g,"");if(r.length!==qCt)throw new Error(`Error: Cannot extract GUID from font filename: ${e}`);const s=r.replace(/(..)/g,"$1 ").trim().split(" ").map(c=>parseInt(c,16));s.reverse();const a=t.slice(Z1,$3).map((c,u)=>c^s[u%s.length]),o=new Uint8Array(Z1+a.length+Math.max(0,t.length-$3));return o.set(t.slice(0,Z1)),o.set(a,Z1),o.set(t.slice($3),Z1+a.length),o};class KCt{format(e,r={stack:[]}){const n=e.prepForXml(r);if(n)return n;throw Error("XMLComponent did not format correctly")}}class YCt{replace(e,r,n){let s=e;return r.forEach((i,a)=>{s=s.replace(new RegExp(`{${i.fileName}}`,"g"),(n+a).toString())}),s}getMediaData(e,r){return r.Array.filter(n=>e.search(`{${n.fileName}}`)>0)}}class XCt{replace(e,r){let n=e;for(const s of r)n=n.replace(new RegExp(`{${s.reference}-${s.instance}}`,"g"),s.numId.toString());return n}}class JCt{constructor(){Fe(this,"formatter"),Fe(this,"imageReplacer"),Fe(this,"numberingReplacer"),this.formatter=new KCt,this.imageReplacer=new YCt,this.numberingReplacer=new XCt}compile(e,r,n=[]){const s=new UCt,i=this.xmlifyFile(e,r),a=new Map(Object.entries(i));for(const[,o]of a)if(Array.isArray(o))for(const c of o)s.file(c.path,c.data);else s.file(o.path,o.data);for(const o of n)s.file(o.path,o.data);for(const o of e.Media.Array)o.type!=="svg"?s.file(`word/media/${o.fileName}`,o.data):(s.file(`word/media/${o.fileName}`,o.data),s.file(`word/media/${o.fallback.fileName}`,o.fallback.data));for(const{data:o,name:c,fontKey:u}of e.FontTable.fontOptionsWithKey){const[d]=c.split(".");s.file(`word/fonts/${d}.odttf`,GCt(o,u))}return s}xmlifyFile(e,r){const n=e.Document.Relationships.RelationshipCount+1,s=In(this.formatter.format(e.Document.View,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}}),i=e.Comments.Relationships.RelationshipCount+1,a=In(this.formatter.format(e.Comments,{viewWrapper:{View:e.Comments,Relationships:e.Comments.Relationships},file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}}),o=this.imageReplacer.getMediaData(s,e.Media),c=this.imageReplacer.getMediaData(a,e.Media);return{Relationships:{data:(o.forEach((u,d)=>{e.Document.Relationships.createRelationship(n+d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${u.fileName}`)}),e.Document.Relationships.createRelationship(e.Document.Relationships.RelationshipCount+1,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable","fontTable.xml"),In(this.formatter.format(e.Document.Relationships,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}})),path:"word/_rels/document.xml.rels"},Document:{data:(()=>{const u=this.imageReplacer.replace(s,o,n);return this.numberingReplacer.replace(u,e.Numbering.ConcreteNumbering)})(),path:"word/document.xml"},Styles:{data:(()=>{const u=In(this.formatter.format(e.Styles,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}});return this.numberingReplacer.replace(u,e.Numbering.ConcreteNumbering)})(),path:"word/styles.xml"},Properties:{data:In(this.formatter.format(e.CoreProperties,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"docProps/core.xml"},Numbering:{data:In(this.formatter.format(e.Numbering,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/numbering.xml"},FileRelationships:{data:In(this.formatter.format(e.FileRelationships,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),path:"_rels/.rels"},HeaderRelationships:e.Headers.map((u,d)=>{const h=In(this.formatter.format(u.View,{viewWrapper:u,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}});return this.imageReplacer.getMediaData(h,e.Media).forEach((p,m)=>{u.Relationships.createRelationship(m,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${p.fileName}`)}),{data:In(this.formatter.format(u.Relationships,{viewWrapper:u,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),path:`word/_rels/header${d+1}.xml.rels`}}),FooterRelationships:e.Footers.map((u,d)=>{const h=In(this.formatter.format(u.View,{viewWrapper:u,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}});return this.imageReplacer.getMediaData(h,e.Media).forEach((p,m)=>{u.Relationships.createRelationship(m,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${p.fileName}`)}),{data:In(this.formatter.format(u.Relationships,{viewWrapper:u,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),path:`word/_rels/footer${d+1}.xml.rels`}}),Headers:e.Headers.map((u,d)=>{const h=In(this.formatter.format(u.View,{viewWrapper:u,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),f=this.imageReplacer.getMediaData(h,e.Media),p=this.imageReplacer.replace(h,f,0);return{data:this.numberingReplacer.replace(p,e.Numbering.ConcreteNumbering),path:`word/header${d+1}.xml`}}),Footers:e.Footers.map((u,d)=>{const h=In(this.formatter.format(u.View,{viewWrapper:u,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),f=this.imageReplacer.getMediaData(h,e.Media),p=this.imageReplacer.replace(h,f,0);return{data:this.numberingReplacer.replace(p,e.Numbering.ConcreteNumbering),path:`word/footer${d+1}.xml`}}),ContentTypes:{data:In(this.formatter.format(e.ContentTypes,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),path:"[Content_Types].xml"},CustomProperties:{data:In(this.formatter.format(e.CustomProperties,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"docProps/custom.xml"},AppProperties:{data:In(this.formatter.format(e.AppProperties,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"docProps/app.xml"},FootNotes:{data:In(this.formatter.format(e.FootNotes.View,{viewWrapper:e.FootNotes,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),path:"word/footnotes.xml"},FootNotesRelationships:{data:In(this.formatter.format(e.FootNotes.Relationships,{viewWrapper:e.FootNotes,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),path:"word/_rels/footnotes.xml.rels"},Settings:{data:In(this.formatter.format(e.Settings,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/settings.xml"},Comments:{data:(()=>{const u=this.imageReplacer.replace(a,c,i);return this.numberingReplacer.replace(u,e.Numbering.ConcreteNumbering)})(),path:"word/comments.xml"},CommentsRelationships:{data:(c.forEach((u,d)=>{e.Comments.Relationships.createRelationship(i+d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`media/${u.fileName}`)}),In(this.formatter.format(e.Comments.Relationships,{viewWrapper:{View:e.Comments,Relationships:e.Comments.Relationships},file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}})),path:"word/_rels/comments.xml.rels"},FontTable:{data:In(this.formatter.format(e.FontTable.View,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}}),path:"word/fontTable.xml"},FontTableRelationships:{data:In(this.formatter.format(e.FontTable.Relationships,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),path:"word/_rels/fontTable.xml.rels"}}}}const QCt={NONE:"",WITH_2_BLANKS:" ",WITH_4_BLANKS:" ",WITH_TAB:" "},yse=t=>t===!0?QCt.WITH_2_BLANKS:t===!1?void 0:t,r_e=class dv{static pack(e,r,n){return vkt(this,arguments,function*(s,i,a,o=[]){return this.compiler.compile(s,yse(a),o).generateAsync({type:i,mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",compression:"DEFLATE"})})}static toString(e,r,n=[]){return dv.pack(e,"string",r,n)}static toBuffer(e,r,n=[]){return dv.pack(e,"nodebuffer",r,n)}static toBase64String(e,r,n=[]){return dv.pack(e,"base64",r,n)}static toBlob(e,r,n=[]){return dv.pack(e,"blob",r,n)}static toArrayBuffer(e,r,n=[]){return dv.pack(e,"arraybuffer",r,n)}static toStream(e,r,n=[]){const s=new $Ct.Stream;return this.compiler.compile(e,yse(r),n).generateAsync({type:"nodebuffer",mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",compression:"DEFLATE"}).then(a=>{s.emit("data",a),s.emit("end")}),s}};Fe(r_e,"compiler",new JCt);let ZCt=r_e;function n_e(t){if(!t)return[];const e=/\(([A-ZÀ-ÖØ-Þa-zà-öø-ÿ][A-Za-zÀ-ÖØ-Þà-öø-ÿ''-]+(?:\s(?:et\s+al\.|&\s+[A-ZÀ-ÖØ-Þ][A-Za-zÀ-ÖØ-Þà-öø-ÿ''-]+))?(?:,?\s*[A-ZÀ-ÖØ-Þ][A-Za-zÀ-ÖØ-Þà-öø-ÿ''-]+)*(?:\s*&\s*[A-ZÀ-ÖØ-Þ][A-Za-zÀ-ÖØ-Þà-öø-ÿ''-]+)?),\s*(\d{4})(?:,\s*(?:p\.|pp\.|S\.)\s*[\d–\-]+)?\)/g,r=[],n=new Set;let s;for(;(s=e.exec(t))!==null;){const a=s[1].trim(),o=parseInt(s[2]),c=`${a.toLowerCase()}|${o}`;n.has(c)||(n.add(c),r.push({authors:a,year:o,raw:s[0]}))}const i=new RegExp("(?<![(\\w])([A-ZÀ-ÖØ-Þ][A-Za-zÀ-ÖØ-Þà-öø-ÿ''-]+(?:\\s(?:et\\s+al\\.|&\\s+[A-ZÀ-ÖØ-Þ][A-Za-zÀ-ÖØ-Þà-öø-ÿ''-]+))?)\\s+\\((\\d{4})(?:,\\s*(?:p\\.|pp\\.|S\\.)\\s*[\\d\\u2013-]+\\.?)?\\)","g");for(;(s=i.exec(t))!==null;){const a=s[1].trim(),o=parseInt(s[2]),c=`${a.toLowerCase()}|${o}`;n.has(c)||(n.add(c),r.push({authors:a,year:o,raw:s[0]}))}return r}function eTt(t){return t.replace(/\s+et\s+al\.?/i,"").replace(/\s*&\s*.+$/,"").trim().split(/[\s,]/)[0].toLowerCase()}function tTt(t,e){if(!e||!Array.isArray(e)||e.length===0)return!1;const r=eTt(t);return r?e.some(n=>{var s,i,a;if(typeof n=="string"){if(((s=n.split(/,\s*/)[0])==null?void 0:s.trim().toLowerCase())===r)return!0;const u=n.trim().split(/\s+/);if(((i=u[u.length-1])==null?void 0:i.toLowerCase())===r)return!0}return typeof n=="object"&&n!==null&&((a=n.family)==null?void 0:a.toLowerCase())===r}):!1}function s_e(t,e){var s,i,a,o,c,u,d,h,f,p,m,g;const r=[],n=[];for(const x of t){let y=!1;for(const v of e){const b=v.bib_meta;if(!b)continue;const w=b.published_year||b.year||((s=b.crossref_data)==null?void 0:s.year)||((u=(c=(o=(a=(i=b.crossref_data)==null?void 0:i.crossref_metadata)==null?void 0:a.issued)==null?void 0:o["date-parts"])==null?void 0:c[0])==null?void 0:u[0])||((d=b.google_books_data)!=null&&d.publishedDate?parseInt(String(b.google_books_data.publishedDate).substring(0,4)):null);if(!w||parseInt(String(w))!==x.year)continue;const S=b.authors||((h=b.crossref_data)==null?void 0:h.authors)||((f=b.crossref_payload)==null?void 0:f.author)||((m=(p=b.crossref_data)==null?void 0:p.crossref_metadata)==null?void 0:m.author)||((g=b.google_books_data)==null?void 0:g.authors);if(tTt(x.authors,S)){r.push({citation:x,documentId:v.id,citationApa:v.citation_apa||`${x.authors} (${x.year}). ${v.title||"Untitled"}.`,title:v.title||void 0}),y=!0;break}}y||n.push(x)}return{matched:r,unmatched:n}}function i_e(t){const e=new Set,r=[];for(const n of t.matched)e.has(n.citationApa)||(e.add(n.citationApa),r.push(n.citationApa));for(const n of t.unmatched){const s=`${n.authors} (${n.year}). [Source not found in library]`;e.has(s)||(e.add(s),r.push(s))}return r.sort((n,s)=>n.localeCompare(s))}function S7(t,e){const r=t.flatMap(s=>s.sections.map(i=>i.content)).join(`
`),n=n_e(r);return s_e(n,e)}function rTt(t,e){const r=n_e(t);return s_e(r,e)}const a_e={intro:"Introduction",problem:"Problem Statement",goal:"Objectives",theory:"Theory",method:"Methodology",results:"Results",findings:"Findings",discussion:"Discussion",conclusion:"Conclusion",literature:"Literature Review",references:"References",other:"Other"};function o_e(t){return t?t.replace(/^#{1,6}\s+/gm,"").replace(/\*\*(.+?)\*\*/g,"$1").replace(/\*(.+?)\*/g,"$1").replace(/__(.+?)__/g,"$1").replace(/_(.+?)_/g,"$1").replace(/`(.+?)`/g,"$1").replace(/```[\s\S]*?```/g,"").replace(/\[(.+?)\]\((.+?)\)/g,"$1").replace(/!\[.*?\]\((.+?)\)/g,"").replace(/^>\s+/gm,"").replace(/^[-*_]{3,}$/gm,"").replace(/^\s*[-*+]\s+/gm,"• ").replace(/^\s*\d+\.\s+/gm,"").replace(/\n{3,}/g,`
`).trim():""}function nTt(t,e){const r=[];if(r.push("=".repeat(60)),r.push(""),r.push(e.thesisTitle.toUpperCase()),r.push(""),r.push("=".repeat(60)),r.push(""),e.authorName&&r.push(`Author: ${e.authorName}`),e.institution&&r.push(`Institution: ${e.institution}`),e.degreeProgram&&r.push(`Degree: ${e.degreeProgram}`),e.supervisor&&r.push(`Supervisor: ${e.supervisor}`),e.submissionDate){const a=new Date(e.submissionDate).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});r.push(`Submission Date: ${a}`)}r.push(""),r.push("-".repeat(60)),r.push("");let n=0;const s=[...t.chapters].sort((a,o)=>a.order_index-o.order_index);if(s.forEach((a,o)=>{r.push(`${o+1}. ${a.title.toUpperCase()}`),r.push(""),a.sections&&a.sections.length>0?[...a.sections].sort((u,d)=>u.order_index-d.order_index).forEach((u,d)=>{const h=u.title||a_e[u.type]||u.type;if(r.push(` ${o+1}.${d+1} ${h}`),r.push(""),u.content&&u.content.trim()){const p=o_e(u.content).split(`
`).map(m=>` ${m}`).join(`
`);r.push(p),n+=u.word_count||0}else r.push(" [No content yet]");r.push("")}):(r.push(" [No sections yet]"),r.push("")),r.push("-".repeat(60)),r.push("")}),e.includeLiterature&&t.documents&&t.documents.length>0){const a=S7(t.chapters,t.documents),o=i_e(a);if(o.length>0){const c=s.length+1;r.push(`${c}. REFERENCES`),r.push(""),o.forEach(u=>{r.push(` ${u}`),r.push("")}),r.push("-".repeat(60)),r.push("")}}const i=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"});return r.push(`Exported on: ${i}`),r.push(`Total words: ${n.toLocaleString()}`),r.join(`
`)}async function sTt(t,e){const r=[];if(r.push(new on({children:[],spacing:{after:2400}})),r.push(new on({children:[new Ci({text:e.thesisTitle,bold:!0,size:56})],alignment:Xn.CENTER,spacing:{after:400}})),e.degreeProgram&&r.push(new on({children:[new Ci({text:e.degreeProgram,size:28,italics:!0})],alignment:Xn.CENTER,spacing:{after:800}})),e.authorName&&(r.push(new on({children:[new Ci({text:"Submitted by",size:24})],alignment:Xn.CENTER,spacing:{after:100}})),r.push(new on({children:[new Ci({text:e.authorName,bold:!0,size:28})],alignment:Xn.CENTER,spacing:{after:400}}))),e.institution&&r.push(new on({children:[new Ci({text:e.institution,size:24})],alignment:Xn.CENTER,spacing:{after:200}})),e.supervisor&&r.push(new on({children:[new Ci({text:`Supervisor: ${e.supervisor}`,size:24})],alignment:Xn.CENTER,spacing:{after:200}})),e.submissionDate){const i=new Date(e.submissionDate).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});r.push(new on({children:[new Ci({text:i,size:24})],alignment:Xn.CENTER,spacing:{after:400}}))}r.push(new on({children:[new sse]})),e.includeTableOfContents&&(r.push(new on({children:[new Ci({text:"TABLE OF CONTENTS",bold:!0,size:28})],alignment:Xn.CENTER,spacing:{after:400}})),r.push(new on({children:[new Ci({text:"[Update this Table of Contents in Word: Right-click → Update Field]",italics:!0,size:20,color:"888888"})],alignment:Xn.CENTER,spacing:{after:200}})),r.push(new DCt("Table of Contents",{hyperlink:!0,headingStyleRange:"1-3"})),r.push(new on({children:[new sse]})));const n=[...t.chapters].sort((i,a)=>i.order_index-a.order_index);if(n.forEach((i,a)=>{r.push(new on({text:`${a+1}. ${i.title}`,heading:O3.HEADING_1,spacing:{before:400,after:200}})),i.sections&&i.sections.length>0&&[...i.sections].sort((c,u)=>c.order_index-u.order_index).forEach((c,u)=>{const d=c.title||a_e[c.type]||c.type;r.push(new on({text:`${a+1}.${u+1} ${d}`,heading:O3.HEADING_2,spacing:{before:300,after:150}})),c.content&&c.content.trim()?o_e(c.content).split(`
`).forEach(p=>{p.trim()&&r.push(new on({children:[new Ci({text:p.trim(),size:24})],spacing:{after:200}}))}):r.push(new on({children:[new Ci({text:"[No content yet]",italics:!0,color:"888888",size:24})],spacing:{after:200}}))})}),e.includeLiterature&&t.documents&&t.documents.length>0){const i=S7(t.chapters,t.documents),a=i_e(i);a.length>0&&(r.push(new on({text:`${n.length+1}. References`,heading:O3.HEADING_1,spacing:{before:400,after:200}})),a.forEach(o=>{r.push(new on({children:[new Ci({text:o,size:24})],spacing:{after:120},indent:{left:720,hanging:720}}))}))}const s=new OCt({features:{updateFields:!0},styles:{paragraphStyles:[{id:"Heading1",name:"Heading 1",basedOn:"Normal",next:"Normal",quickFormat:!0,run:{size:32,bold:!0},paragraph:{spacing:{before:400,after:200}}},{id:"Heading2",name:"Heading 2",basedOn:"Normal",next:"Normal",quickFormat:!0,run:{size:28,bold:!0},paragraph:{spacing:{before:300,after:150}}}]},sections:[{properties:{page:{pageNumbers:e.includePageNumbers?{start:1,formatType:ONt.DECIMAL}:void 0}},headers:{default:new LCt({children:[new on({alignment:Xn.LEFT,children:[new Ci({text:"Academly.ai",size:18,color:"666666",italics:!0})]})]})},footers:e.includePageNumbers?{default:new FCt({children:[new on({alignment:Xn.CENTER,children:[new Ci({children:["Page ",Uv.CURRENT," of ",Uv.TOTAL_PAGES],size:20})]})]})}:void 0,children:r}]});return await ZCt.toBlob(s)}function l_e(t,e){const r=URL.createObjectURL(t),n=document.createElement("a");n.href=r,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}function iTt(t,e){const r="\uFEFF",n=new Blob([r+t],{type:"text/plain;charset=utf-8"});l_e(n,e)}function c_e({open:t,onOpenChange:e,thesisData:r,defaultAuthorName:n="",defaultInstitution:s="",defaultDegreeProgram:i="",documents:a=[]}){const[o,c]=j.useState("docx"),[u,d]=j.useState(!1),[h,f]=j.useState(""),[p,m]=j.useState(""),[g,x]=j.useState(""),[y,v]=j.useState(""),[b,w]=j.useState(""),[S,k]=j.useState(""),[E,C]=j.useState(!0),[A,M]=j.useState(!0),[z,P]=j.useState(!0);j.useEffect(()=>{if(t&&r){f(r.thesis.title||""),m(n),x(s);const K=r.thesis.degree==="bachelor"?"Bachelor":"Master";v(i||`${K} Thesis`),r.thesis.due_date?k(r.thesis.due_date.split("T")[0]):k(new Date().toISOString().split("T")[0])}},[t,r,n,s,i]);const W=async()=>{if(r){d(!0);try{const K={format:o,thesisTitle:h,authorName:p||void 0,institution:g||void 0,degreeProgram:y||void 0,supervisor:b||void 0,submissionDate:S||void 0,includePageNumbers:E,includeTableOfContents:A,includeLiterature:z},G=z&&a.length>0?{...r,documents:a}:r,X=h.replace(/[^a-zA-Z0-9äöüÄÖÜß\s-]/g,"_").trim(),H=new Date().toISOString().split("T")[0];switch(o){case"txt":{const B=nTt(G,K);iTt(B,`${X}_${H}.txt`);break}case"docx":{const B=await sTt(G,K);l_e(B,`${X}_${H}.docx`);break}case"pdf":{console.warn("PDF export not yet implemented");break}}e(!1)}catch(K){console.error("Export error:",K)}finally{d(!1)}}},N=[{value:"txt",label:"TXT",icon:l.jsx(Br,{className:"h-5 w-5"}),description:"Plain text, no formatting",disabled:!1},{value:"docx",label:"DOCX",icon:l.jsx(m2e,{className:"h-5 w-5"}),description:"Word document with styles",disabled:!1},{value:"pdf",label:"PDF",icon:l.jsx(q2e,{className:"h-5 w-5"}),description:"Coming soon",disabled:!0}],U=o==="docx"||o==="pdf";return l.jsx(Gr,{open:t,onOpenChange:e,children:l.jsxs(zr,{className:"sm:max-w-[500px] max-h-[90vh] overflow-y-auto",children:[l.jsxs(Ur,{children:[l.jsx(Hr,{children:"Export Thesis"}),l.jsx(wx,{children:"Choose export format and customize the template"})]}),l.jsxs("div",{className:"space-y-6 py-4",children:[l.jsxs("div",{className:"space-y-3",children:[l.jsx(_e,{className:"text-sm font-medium",children:"Format"}),l.jsx("div",{className:"grid grid-cols-3 gap-2",children:N.map(K=>l.jsxs("button",{type:"button",onClick:()=>!K.disabled&&c(K.value),disabled:K.disabled,className:Le("flex flex-col items-center gap-2 p-4 rounded-lg border-2 transition-all",K.disabled&&"opacity-50 cursor-not-allowed",!K.disabled&&o===K.value?"border-primary bg-primary/5":K.disabled?"border-border":"border-border hover:border-primary/50"),children:[l.jsx("div",{className:Le("p-2 rounded-full",!K.disabled&&o===K.value?"bg-primary text-primary-foreground":"bg-muted"),children:K.icon}),l.jsx("span",{className:"font-medium text-sm",children:K.label}),l.jsx("span",{className:"text-xs text-muted-foreground text-center",children:K.description})]},K.value))})]}),U&&l.jsxs(l.Fragment,{children:[l.jsx(vi,{}),l.jsxs("div",{className:"space-y-4",children:[l.jsx(_e,{className:"text-sm font-medium",children:"Template Settings"}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"thesis-title",className:"text-xs text-muted-foreground",children:"Thesis Title"}),l.jsx(Be,{id:"thesis-title",value:h,onChange:K=>f(K.target.value),placeholder:"Enter thesis title"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"author-name",className:"text-xs text-muted-foreground",children:"Author Name"}),l.jsx(Be,{id:"author-name",value:p,onChange:K=>m(K.target.value),placeholder:"Your name"})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"institution",className:"text-xs text-muted-foreground",children:"Institution"}),l.jsx(Be,{id:"institution",value:g,onChange:K=>x(K.target.value),placeholder:"University name"})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"degree-program",className:"text-xs text-muted-foreground",children:"Degree / Program"}),l.jsx(Be,{id:"degree-program",value:y,onChange:K=>v(K.target.value),placeholder:"e.g., Master of Science"})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"supervisor",className:"text-xs text-muted-foreground",children:"Supervisor"}),l.jsx(Be,{id:"supervisor",value:b,onChange:K=>w(K.target.value),placeholder:"Prof. Dr. Name"})]})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"submission-date",className:"text-xs text-muted-foreground",children:"Submission Date"}),l.jsx(Be,{id:"submission-date",type:"date",value:S,onChange:K=>k(K.target.value)})]})]})]}),l.jsx(vi,{}),l.jsxs("div",{className:"space-y-4",children:[l.jsx(_e,{className:"text-sm font-medium",children:"Layout Options"}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(bl,{id:"page-numbers",checked:E,onCheckedChange:K=>C(K===!0)}),l.jsx(_e,{htmlFor:"page-numbers",className:"text-sm font-normal cursor-pointer",children:"Include page numbers"})]}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(bl,{id:"toc",checked:A,onCheckedChange:K=>M(K===!0)}),l.jsx(_e,{htmlFor:"toc",className:"text-sm font-normal cursor-pointer",children:"Include table of contents"})]})]})]})]}),l.jsx(vi,{}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(bl,{id:"literature",checked:z,onCheckedChange:K=>P(K===!0)}),l.jsx(_e,{htmlFor:"literature",className:"text-sm font-normal cursor-pointer",children:"Auto-generate Literature from citations"})]})]}),l.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[l.jsx(ye,{variant:"outline",onClick:()=>e(!1),children:"Cancel"}),l.jsx(ye,{onClick:W,disabled:u||!r,children:u?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"h-4 w-4 mr-2 animate-spin"}),"Exporting..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Ga,{className:"h-4 w-4 mr-2"}),"Download"]})})]})]})})}var uD="Popover",[u_e,$5t]=gs(uD,[nm]),GE=nm(),[aTt,xm]=u_e(uD),d_e=t=>{const{__scopePopover:e,children:r,open:n,defaultOpen:s,onOpenChange:i,modal:a=!1}=t,o=GE(e),c=j.useRef(null),[u,d]=j.useState(!1),[h,f]=_i({prop:n,defaultProp:s??!1,onChange:i,caller:uD});return l.jsx(iR,{...o,children:l.jsx(aTt,{scope:e,contentId:Ka(),triggerRef:c,open:h,onOpenChange:f,onOpenToggle:j.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:u,onCustomAnchorAdd:j.useCallback(()=>d(!0),[]),onCustomAnchorRemove:j.useCallback(()=>d(!1),[]),modal:a,children:r})})};d_e.displayName=uD;var h_e="PopoverAnchor",oTt=j.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,s=xm(h_e,r),i=GE(r),{onCustomAnchorAdd:a,onCustomAnchorRemove:o}=s;return j.useEffect(()=>(a(),()=>o()),[a,o]),l.jsx(aE,{...i,...n,ref:e})});oTt.displayName=h_e;var f_e="PopoverTrigger",p_e=j.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,s=xm(f_e,r),i=GE(r),a=It(e,s.triggerRef),o=l.jsx(ot.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":v_e(s.open),...n,ref:a,onClick:Ke(t.onClick,s.onOpenToggle)});return s.hasCustomAnchor?o:l.jsx(aE,{asChild:!0,...i,children:o})});p_e.displayName=f_e;var _7="PopoverPortal",[lTt,cTt]=u_e(_7,{forceMount:void 0}),m_e=t=>{const{__scopePopover:e,forceMount:r,children:n,container:s}=t,i=xm(_7,e);return l.jsx(lTt,{scope:e,forceMount:r,children:l.jsx(Os,{present:r||i.open,children:l.jsx(Fw,{asChild:!0,container:s,children:n})})})};m_e.displayName=_7;var kw="PopoverContent",g_e=j.forwardRef((t,e)=>{const r=cTt(kw,t.__scopePopover),{forceMount:n=r.forceMount,...s}=t,i=xm(kw,t.__scopePopover);return l.jsx(Os,{present:n||i.open,children:i.modal?l.jsx(dTt,{...s,ref:e}):l.jsx(hTt,{...s,ref:e})})});g_e.displayName=kw;var uTt=Fp("PopoverContent.RemoveScroll"),dTt=j.forwardRef((t,e)=>{const r=xm(kw,t.__scopePopover),n=j.useRef(null),s=It(e,n),i=j.useRef(!1);return j.useEffect(()=>{const a=n.current;if(a)return bR(a)},[]),l.jsx(fE,{as:uTt,allowPinchZoom:!0,children:l.jsx(y_e,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ke(t.onCloseAutoFocus,a=>{var o;a.preventDefault(),i.current||(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Ke(t.onPointerDownOutside,a=>{const o=a.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0,u=o.button===2||c;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Ke(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),hTt=j.forwardRef((t,e)=>{const r=xm(kw,t.__scopePopover),n=j.useRef(!1),s=j.useRef(!1);return l.jsx(y_e,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,o;(a=t.onCloseAutoFocus)==null||a.call(t,i),i.defaultPrevented||(n.current||(o=r.triggerRef.current)==null||o.focus(),i.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:i=>{var c,u;(c=t.onInteractOutside)==null||c.call(t,i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const a=i.target;((u=r.triggerRef.current)==null?void 0:u.contains(a))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}})}),y_e=j.forwardRef((t,e)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:d,...h}=t,f=xm(kw,r),p=GE(r);return vR(),l.jsx(dE,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:i,children:l.jsx(mx,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:d,onEscapeKeyDown:o,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),children:l.jsx(aR,{"data-state":v_e(f.open),role:"dialog",id:f.contentId,...p,...h,ref:e,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),x_e="PopoverClose",fTt=j.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,s=xm(x_e,r);return l.jsx(ot.button,{type:"button",...n,ref:e,onClick:Ke(t.onClick,()=>s.onOpenChange(!1))})});fTt.displayName=x_e;var pTt="PopoverArrow",mTt=j.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,s=GE(r);return l.jsx(oR,{...s,...n,ref:e})});mTt.displayName=pTt;function v_e(t){return t?"open":"closed"}var gTt=d_e,yTt=p_e,xTt=m_e,b_e=g_e;const w_e=gTt,S_e=yTt,j7=j.forwardRef(({className:t,align:e="center",sideOffset:r=4,...n},s)=>l.jsx(xTt,{children:l.jsx(b_e,{ref:s,align:e,sideOffset:r,className:Le("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n})}));j7.displayName=b_e.displayName;function vTt({content:t,documents:e}){const r=j.useMemo(()=>!t||e.length===0?{matched:[],unmatched:[]}:rTt(t,e),[t,e]),n=r.matched.length+r.unmatched.length;if(n===0)return null;const i=r.unmatched.length===0?"bg-green-500":"bg-yellow-500";return l.jsxs(w_e,{children:[l.jsx(S_e,{asChild:!0,children:l.jsxs("button",{type:"button",onClick:a=>a.stopPropagation(),className:"flex items-center gap-1 shrink-0",title:`${r.matched.length}/${n} citations matched`,children:[l.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${i}`}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.matched.length,"/",n]})]})}),l.jsx(j7,{className:"w-80 p-3",align:"start",onClick:a=>a.stopPropagation(),children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-sm font-medium",children:"Citations in this section"}),r.matched.length>0&&l.jsx("div",{className:"space-y-1",children:r.matched.map((a,o)=>l.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[l.jsx(Es,{className:"h-3.5 w-3.5 text-green-500 shrink-0 mt-0.5"}),l.jsxs("div",{children:[l.jsx("span",{className:"font-medium",children:a.citation.raw}),a.title&&l.jsx("p",{className:"text-muted-foreground truncate",children:a.title})]})]},o))}),r.unmatched.length>0&&l.jsx("div",{className:"space-y-1",children:r.unmatched.map((a,o)=>l.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[l.jsx(Is,{className:"h-3.5 w-3.5 text-red-500 shrink-0 mt-0.5"}),l.jsxs("div",{children:[l.jsx("span",{className:"font-medium",children:a.raw}),l.jsx("p",{className:"text-muted-foreground",children:"Not found — add via Citation Manager"})]})]},o))})]})})]})}const xse={intro:"Introduction",problem:"Problem Statement",goal:"Objectives",theory:"Theory",method:"Methodology",results:"Results",findings:"Findings",discussion:"Discussion",conclusion:"Conclusion",literature:"Literature Review",references:"References",other:"Other"},vse={open:"secondary",in_progress:"warning",done:"success"},bse={open:"Open",in_progress:"In Progress",done:"Done"},bTt=["Introduction","Literature Review","Methodology","Findings","Discussion","Conclusion","References"],wTt=()=>{const{user:t,loading:e,researchProfile:r}=Dt(),n=Or(),{toast:s}=qn(),[i,a]=j.useState([]),[o,c]=j.useState(""),[u,d]=j.useState(null),[h,f]=j.useState(0),[p,m]=j.useState([]),[g,x]=j.useState({}),[y,v]=j.useState([]),[b,w]=j.useState(!1),[S,k]=j.useState(!1),[E,C]=j.useState(!1),[A,M]=j.useState(!1),[z,P]=j.useState(!1),[W,N]=j.useState([]),[U,K]=j.useState({title:"",degree:"bachelor",description:"",due_date:"",target_word_count:15e3}),[G,X]=j.useState({title:"",degree:"bachelor",description:"",due_date:"",target_word_count:15e3}),[H,B]=j.useState(""),[L,F]=j.useState(!1),[V,Y]=j.useState(null),[ie,Q]=j.useState([]);j.useEffect(()=>{!t&&!e&&n("/login")},[t,e,n]),j.useEffect(()=>{t&&(D(),R())},[t]),j.useEffect(()=>{if(o){J();const oe=i.find(de=>de.id===o);d(oe||null),oe&&X({title:oe.title,degree:oe.degree,description:oe.description||"",due_date:oe.due_date||"",target_word_count:oe.target_word_count||15e3})}},[o,i]);const D=async()=>{w(!0);try{const{data:oe,error:de}=await be.from("theses").select("id, title, degree, description, due_date, target_word_count, created_at").order("created_at",{ascending:!1});if(de)throw de;a(oe||[])}catch(oe){console.error("Error loading theses:",oe),s({title:"Error",description:"Failed to load theses.",variant:"destructive"})}finally{w(!1)}},R=async()=>{try{const{data:oe,error:de}=await be.from("documents").select("id, title, citation_apa, bib_meta").eq("user_id",t==null?void 0:t.id);if(de)throw de;Q(oe||[])}catch(oe){console.error("Error loading documents for citation matching:",oe)}},J=async()=>{if(o){k(!0);try{const{data:oe,error:de}=await be.from("v_thesis_progress").select("thesis_progress").eq("thesis_id",o).single();de&&de.code!=="PGRST116"?console.error("Error loading thesis progress:",de):f((oe==null?void 0:oe.thesis_progress)||0);const{data:ge,error:Se}=await be.from("chapters").select("*").eq("thesis_id",o).is("parent_id",null).order("order_index",{ascending:!0}).order("created_at",{ascending:!0});if(Se)throw Se;const ke=(ge==null?void 0:ge.map(Ae=>Ae.id))||[];if(ke.length>0){const{data:Ae,error:fe}=await be.from("v_chapter_progress").select("chapter_id, computed_progress").in("chapter_id",ke);fe&&console.error("Error loading chapter progress:",fe);const Te=(ge==null?void 0:ge.map(Pe=>{var tt;return{...Pe,computed_progress:((tt=Ae==null?void 0:Ae.find(wt=>wt.chapter_id===Pe.id))==null?void 0:tt.computed_progress)||0}}))||[];m(Te)}else m([]);const{data:Ne,error:qe}=await be.from("progress_log").select("*").eq("thesis_id",o).order("timestamp",{ascending:!1}).limit(10);qe?console.error("Error loading progress log:",qe):v(Ne||[])}catch(oe){console.error("Error loading thesis data:",oe),s({title:"Error",description:"Failed to load data.",variant:"destructive"})}finally{k(!1)}}},Z=async oe=>{try{const{data:de,error:ge}=await be.from("sections").select("*").eq("chapter_id",oe).order("order_index",{ascending:!0}).order("created_at",{ascending:!0});if(ge)throw ge;x(Se=>({...Se,[oe]:de||[]}))}catch(de){console.error("Error loading sections:",de),s({title:"Error",description:"Failed to load sections.",variant:"destructive"})}},ee=async oe=>{const{data:de,error:ge}=await be.from("v_chapter_progress").select("chapter_id, computed_progress").eq("chapter_id",oe).single();!ge&&de&&m(Se=>Se.map(ke=>ke.id===oe?{...ke,computed_progress:de.computed_progress}:ke))},re=async()=>{if(!U.title.trim()){s({title:"Error",description:"Title is required.",variant:"destructive"});return}try{const{data:oe,error:de}=await be.from("theses").insert({user_id:t==null?void 0:t.id,title:U.title,degree:U.degree,description:U.description||null,due_date:U.due_date||null,target_word_count:U.target_word_count}).select("id").single();if(de)throw de;const{error:ge}=await be.rpc("seed_default_chapters",{p_thesis:oe.id});if(ge)throw ge;s({title:"Success",description:"Thesis created with default chapters."}),K({title:"",degree:"bachelor",description:"",due_date:"",target_word_count:15e3}),C(!1),await D(),c(oe.id)}catch(oe){console.error("Error creating thesis:",oe),s({title:"Error",description:oe.message||"Failed to create thesis.",variant:"destructive"})}},he=async()=>{if(!G.title.trim()){s({title:"Error",description:"Title is required.",variant:"destructive"});return}try{const{error:oe}=await be.from("theses").update({title:G.title,degree:G.degree,description:G.description||null,due_date:G.due_date||null,target_word_count:G.target_word_count}).eq("id",o);if(oe)throw oe;s({title:"Success",description:"Thesis updated successfully."}),M(!1),await D()}catch(oe){console.error("Error updating thesis:",oe),s({title:"Error",description:oe.message||"Failed to update thesis.",variant:"destructive"})}},O=async()=>{try{const{error:oe}=await be.from("theses").delete().eq("id",o);if(oe)throw oe;s({title:"Success",description:"Thesis deleted successfully."}),c(""),d(null),await D()}catch(oe){console.error("Error deleting thesis:",oe),s({title:"Error",description:oe.message||"Failed to delete thesis.",variant:"destructive"})}},ae=async(oe,de,ge)=>{if(o)try{const Se=de?p.find(qe=>qe.id===de):null,ke=ge??((Se==null?void 0:Se.computed_progress)||0);await be.from("progress_log").insert({thesis_id:o,chapter_id:de||null,completed:ke,note:oe});const{data:Ne}=await be.from("progress_log").select("*").eq("thesis_id",o).order("timestamp",{ascending:!1}).limit(10);Ne&&v(Ne)}catch(Se){console.error("Error logging activity:",Se)}},q=async oe=>{try{const de=p.length>0?Math.max(...p.map(Se=>Se.order_index)):0,{error:ge}=await be.from("chapters").insert({thesis_id:o,title:oe,order_index:de+10,status:"open"});if(ge)throw ge;s({title:"Success",description:"Chapter added successfully."}),await ae(`Chapter "${oe}" added`,void 0,0),B(""),P(!1),await J()}catch(de){console.error("Error adding chapter:",de),s({title:"Error",description:de.message||"Failed to add chapter.",variant:"destructive"})}},I=async oe=>{const de=p.find(Se=>Se.id===oe),ge=(de==null?void 0:de.title)||"Chapter";try{const{error:Se}=await be.from("chapters").delete().eq("id",oe);if(Se)throw Se;s({title:"Success",description:"Chapter deleted successfully."}),await ae(`Chapter "${ge}" removed`),await J()}catch(Se){console.error("Error deleting chapter:",Se),s({title:"Error",description:Se.message||"Failed to delete chapter.",variant:"destructive"})}},T=async(oe,de)=>{try{const{error:ge}=await be.from("chapters").update({title:de}).eq("id",oe);if(ge)throw ge;m(Se=>Se.map(ke=>ke.id===oe?{...ke,title:de}:ke))}catch(ge){console.error("Error updating chapter title:",ge),s({title:"Error",description:"Failed to update chapter title.",variant:"destructive"})}},$=async(oe,de="other")=>{const ge=p.find(ke=>ke.id===oe),Se=(ge==null?void 0:ge.title)||"Chapter";try{const ke=g[oe]||[],Ne=ke.length>0?Math.max(...ke.map(Ae=>Ae.order_index)):0,{error:qe}=await be.from("sections").insert({chapter_id:oe,type:de,status:"open",content:"",order_index:Ne+1});if(qe)throw qe;s({title:"Success",description:"Section added."}),await Z(oe),await ee(oe),await ae(`Section added to "${Se}"`,oe)}catch(ke){console.error("Error creating section:",ke),s({title:"Error",description:"Failed to create section.",variant:"destructive"})}},se=async(oe,de)=>{const ge=Object.values(g).flat().find(qe=>qe.id===oe),Se=ge?p.find(qe=>qe.id===ge.chapter_id):null,ke=(ge==null?void 0:ge.title)||xse[(ge==null?void 0:ge.type)||"other"],Ne=(Se==null?void 0:Se.title)||"Chapter";try{const{error:qe}=await be.from("sections").update(de).eq("id",oe);if(qe)throw qe;if(ge&&(await Z(ge.chapter_id),await ee(ge.chapter_id),de.status&&de.status!==ge.status)){const Ae=de.status==="done"?"completed":de.status==="in_progress"?"in progress":"reopened";await ae(`"${ke}" ${Ae} in "${Ne}"`,ge.chapter_id)}}catch(qe){console.error("Error updating section:",qe),s({title:"Error",description:"Failed to update section.",variant:"destructive"})}},ue=async oe=>{const de=Object.values(g).flat().find(Ne=>Ne.id===oe);if(!de)return;const ge=p.find(Ne=>Ne.id===de.chapter_id),Se=de.title||xse[de.type],ke=(ge==null?void 0:ge.title)||"Chapter";try{const{error:Ne}=await be.from("sections").delete().eq("id",oe);if(Ne)throw Ne;s({title:"Success",description:"Section deleted."}),await Z(de.chapter_id),await ee(de.chapter_id),await ae(`"${Se}" removed from "${ke}"`,de.chapter_id)}catch(Ne){console.error("Error deleting section:",Ne),s({title:"Error",description:"Failed to delete section.",variant:"destructive"})}},ne=oe=>oe+1,me=(oe,de)=>`${oe+1}.${de+1}`,ve=()=>{const oe=p.map(de=>de.title.toLowerCase());return bTt.filter(de=>!oe.includes(de.toLowerCase()))},xe=oe=>oe?oe.includes("completed")?l.jsx(_c,{className:"h-4 w-4 text-green-500"}):oe.includes("in progress")?l.jsx(gx,{className:"h-4 w-4 text-yellow-500"}):oe.includes("added")?l.jsx(l2e,{className:"h-4 w-4 text-blue-500"}):oe.includes("removed")||oe.includes("reopened")?l.jsx(o2e,{className:"h-4 w-4 text-red-500"}):l.jsx(L2,{className:"h-4 w-4 text-muted-foreground"}):l.jsx(L2,{className:"h-4 w-4 text-muted-foreground"});return e||b?l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?l.jsx(gr,{showSidebar:!0,children:l.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[l.jsx("div",{className:"flex items-center justify-between",children:l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"Thesis Builder"}),l.jsx("p",{className:"text-muted-foreground mt-2",children:"Manage your thesis with structured chapters and sections."})]})}),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Select or Create Thesis"})}),l.jsx(Ge,{children:l.jsxs("div",{className:"flex gap-4 flex-wrap",children:[l.jsxs("div",{className:"flex-1 min-w-[200px]",children:[l.jsx(_e,{htmlFor:"thesis-select",children:"Existing Thesis"}),l.jsxs(dt,{value:o,onValueChange:c,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select thesis..."})}),l.jsx(ct,{children:i.map(oe=>l.jsxs(De,{value:oe.id,children:[oe.title," (",oe.degree,")"]},oe.id))})]})]}),l.jsxs("div",{className:"flex items-end gap-2",children:[l.jsxs(Gr,{open:E,onOpenChange:C,children:[l.jsx(bc,{asChild:!0,children:l.jsxs(ye,{children:[l.jsx(hl,{className:"mr-2 h-4 w-4"}),"New Thesis"]})}),l.jsxs(zr,{children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Create New Thesis"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"title",children:"Title *"}),l.jsx(Be,{id:"title",value:U.title,onChange:oe=>K(de=>({...de,title:oe.target.value})),placeholder:"Thesis title"})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"degree",children:"Degree"}),l.jsxs(dt,{value:U.degree,onValueChange:oe=>K(de=>({...de,degree:oe})),children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"bachelor",children:"Bachelor"}),l.jsx(De,{value:"master",children:"Master"})]})]})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"description",children:"Description (optional)"}),l.jsx(ir,{id:"description",value:U.description,onChange:oe=>K(de=>({...de,description:oe.target.value})),placeholder:"Brief description of the thesis"})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"due_date",children:"Due Date (optional)"}),l.jsx(Be,{id:"due_date",type:"date",value:U.due_date,onChange:oe=>K(de=>({...de,due_date:oe.target.value}))})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(_e,{htmlFor:"target_word_count",children:"Target Word Count"}),l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(Bp,{className:"h-4 w-4 text-muted-foreground cursor-help"})}),l.jsxs(Qt,{side:"right",className:"max-w-[260px] text-xs leading-relaxed",children:[l.jsx("p",{className:"font-medium mb-1",children:"Approximate page count (A4, 12pt, 1.5 spacing):"}),l.jsxs("ul",{className:"space-y-0.5",children:[l.jsx("li",{children:"~3,000 words ≈ 10–12 pages"}),l.jsx("li",{children:"~5,000 words ≈ 18–20 pages"}),l.jsx("li",{children:"~10,000 words ≈ 35–40 pages"}),l.jsx("li",{children:"~15,000 words ≈ 55–60 pages"})]})]})]})]}),l.jsx(Be,{id:"target_word_count",type:"number",min:"1000",step:"500",value:U.target_word_count,onChange:oe=>K(de=>({...de,target_word_count:parseInt(oe.target.value)||15e3})),placeholder:"15000"})]}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(ye,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),l.jsx(ye,{onClick:re,children:"Create"})]})]})]})]}),o&&l.jsxs(l.Fragment,{children:[l.jsx(ye,{variant:"outline",size:"icon",onClick:async()=>{if(!u)return;const oe={...g};for(const ge of p)if(!oe[ge.id]){const{data:Se}=await be.from("sections").select("*").eq("chapter_id",ge.id).order("order_index");oe[ge.id]=Se||[]}const de={thesis:u,chapters:p.map(ge=>({title:ge.title,order_index:ge.order_index,status:ge.status,sections:(oe[ge.id]||[]).map(Se=>({title:Se.title,type:Se.type,content:Se.content,status:Se.status,word_count:Se.word_count,order_index:Se.order_index}))}))};Y(de),F(!0)},title:"Export Thesis",children:l.jsx(Ga,{className:"h-4 w-4"})}),l.jsxs(Gr,{open:A,onOpenChange:M,children:[l.jsx(bc,{asChild:!0,children:l.jsx(ye,{variant:"outline",size:"icon",children:l.jsx(OH,{className:"h-4 w-4"})})}),l.jsxs(zr,{children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Edit Thesis"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"edit-title",children:"Title *"}),l.jsx(Be,{id:"edit-title",value:G.title,onChange:oe=>X(de=>({...de,title:oe.target.value})),placeholder:"Thesis title"})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"edit-degree",children:"Degree"}),l.jsxs(dt,{value:G.degree,onValueChange:oe=>X(de=>({...de,degree:oe})),children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"bachelor",children:"Bachelor"}),l.jsx(De,{value:"master",children:"Master"})]})]})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"edit-description",children:"Description (optional)"}),l.jsx(ir,{id:"edit-description",value:G.description,onChange:oe=>X(de=>({...de,description:oe.target.value})),placeholder:"Brief description of the thesis"})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"edit-due_date",children:"Due Date (optional)"}),l.jsx(Be,{id:"edit-due_date",type:"date",value:G.due_date,onChange:oe=>X(de=>({...de,due_date:oe.target.value}))})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(_e,{htmlFor:"edit-target_word_count",children:"Target Word Count"}),l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(Bp,{className:"h-4 w-4 text-muted-foreground cursor-help"})}),l.jsxs(Qt,{side:"right",className:"max-w-[260px] text-xs leading-relaxed",children:[l.jsx("p",{className:"font-medium mb-1",children:"Approximate page count (A4, 12pt, 1.5 spacing):"}),l.jsxs("ul",{className:"space-y-0.5",children:[l.jsx("li",{children:"~3,000 words ≈ 10–12 pages"}),l.jsx("li",{children:"~5,000 words ≈ 18–20 pages"}),l.jsx("li",{children:"~10,000 words ≈ 35–40 pages"}),l.jsx("li",{children:"~15,000 words ≈ 55–60 pages"})]})]})]})]}),l.jsx(Be,{id:"edit-target_word_count",type:"number",min:"1000",step:"500",value:G.target_word_count,onChange:oe=>X(de=>({...de,target_word_count:parseInt(oe.target.value)||15e3})),placeholder:"15000"})]}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(ye,{variant:"outline",onClick:()=>M(!1),children:"Cancel"}),l.jsx(ye,{onClick:he,children:"Save Changes"})]})]})]})]}),l.jsxs(va,{children:[l.jsx(El,{asChild:!0,children:l.jsx(ye,{variant:"destructive",size:"icon",children:l.jsx(xi,{className:"h-4 w-4"})})}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Thesis?"}),l.jsxs(Gi,{children:['This will permanently delete the thesis "',u==null?void 0:u.title,'" and all its chapters and sections. This action cannot be undone.']})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:O,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})]})})]}),o&&l.jsxs(l.Fragment,{children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(Z2e,{className:"h-5 w-5"}),"Overall Progress"]})}),l.jsx(Ge,{children:l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex justify-between text-sm",children:[l.jsx("span",{children:"Progress"}),l.jsxs("span",{children:[Math.round(h),"%"]})]}),l.jsx(AE,{value:h,className:"h-2"})]})})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[l.jsx("div",{className:"lg:col-span-2",children:l.jsxs(ze,{children:[l.jsxs(et,{className:"flex flex-row items-center justify-between",children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(ps,{className:"h-5 w-5"}),"Chapters"]}),l.jsxs(Ehe,{children:[l.jsx(Ahe,{asChild:!0,children:l.jsxs(ye,{variant:"outline",size:"sm",children:[l.jsx(hl,{className:"mr-2 h-4 w-4"}),"Add Chapter"]})}),l.jsxs(mV,{align:"end",children:[ve().map(oe=>l.jsx(nb,{onClick:()=>q(oe),children:oe},oe)),ve().length>0&&l.jsx(gV,{}),l.jsxs(nb,{onClick:()=>P(!0),children:[l.jsx(hl,{className:"mr-2 h-4 w-4"}),"Custom Chapter..."]})]})]})]}),l.jsx(Ge,{children:S?l.jsx("div",{className:"flex items-center justify-center py-8",children:l.jsx(xt,{className:"h-6 w-6 animate-spin"})}):p.length===0?l.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No chapters yet. Add your first chapter above."}):l.jsx(Q9,{type:"multiple",value:W,onValueChange:N,className:"space-y-2",children:p.map((oe,de)=>{var ge;return l.jsxs(VM,{value:oe.id,className:"border rounded-lg px-4",children:[l.jsx(WM,{className:"hover:no-underline",onClick:()=>{g[oe.id]||Z(oe.id)},children:l.jsxs("div",{className:"flex items-center justify-between w-full mr-4",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsxs("span",{className:"text-muted-foreground font-mono text-sm",children:[ne(de),"."]}),l.jsx(Be,{value:oe.title,onChange:Se=>{m(ke=>ke.map(Ne=>Ne.id===oe.id?{...Ne,title:Se.target.value}:Ne))},onBlur:Se=>T(oe.id,Se.target.value),onClick:Se=>Se.stopPropagation(),className:"h-8 w-auto min-w-[150px] font-medium"}),l.jsx(kt,{variant:vse[oe.status],children:bse[oe.status]})]}),l.jsxs("div",{className:"flex items-center gap-2",onClick:Se=>Se.stopPropagation(),children:[l.jsxs("span",{className:"text-sm text-muted-foreground",children:[Math.round(oe.computed_progress||0),"%"]}),l.jsxs(va,{children:[l.jsx(El,{asChild:!0,children:l.jsx(ye,{size:"sm",variant:"ghost",children:l.jsx(xi,{className:"h-4 w-4"})})}),l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsx(qi,{children:"Delete Chapter?"}),l.jsxs(Gi,{children:['This will delete "',oe.title,'" and all its sections. This action cannot be undone.']})]}),l.jsxs(Wi,{children:[l.jsx(ji,{children:"Cancel"}),l.jsx(bi,{onClick:()=>I(oe.id),className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})]})]})]})}),l.jsx(qM,{children:l.jsxs("div",{className:"space-y-4 pt-4",children:[l.jsx("div",{className:"space-y-3",children:(ge=g[oe.id])==null?void 0:ge.map((Se,ke)=>l.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[l.jsx("span",{className:"text-muted-foreground font-mono text-sm min-w-[40px]",children:me(de,ke)}),l.jsx(Be,{value:Se.title||"",onChange:Ne=>{x(qe=>{var Ae;return{...qe,[oe.id]:((Ae=qe[oe.id])==null?void 0:Ae.map(fe=>fe.id===Se.id?{...fe,title:Ne.target.value}:fe))||[]}})},onBlur:Ne=>se(Se.id,{title:Ne.target.value||null}),placeholder:"Section title (optional)",className:"h-8 flex-1"}),l.jsx(vTt,{content:Se.content,documents:ie})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(kt,{variant:vse[Se.status],children:bse[Se.status]}),l.jsxs("span",{className:"text-sm text-muted-foreground",children:[Se.word_count," words"]}),l.jsx("div",{onClick:Ne=>Ne.stopPropagation(),children:l.jsxs(dt,{value:Se.status,onValueChange:Ne=>se(Se.id,{status:Ne}),children:[l.jsx(lt,{className:"w-32 h-8",children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"open",children:"Open"}),l.jsx(De,{value:"in_progress",children:"In Progress"}),l.jsx(De,{value:"done",children:"Done"})]})]})}),l.jsx(ye,{size:"sm",variant:"ghost",onClick:Ne=>{Ne.stopPropagation(),ue(Se.id)},children:l.jsx(xi,{className:"h-4 w-4"})})]})]}),l.jsx(ir,{value:Se.content,onChange:Ne=>{const qe=Ne.target.value;x(Ae=>{var fe;return{...Ae,[oe.id]:((fe=Ae[oe.id])==null?void 0:fe.map(Te=>Te.id===Se.id?{...Te,content:qe}:Te))||[]}})},onBlur:Ne=>se(Se.id,{content:Ne.currentTarget.value}),placeholder:"Section content...",className:"min-h-[120px]"})]},Se.id))}),l.jsxs(ye,{variant:"outline",onClick:()=>$(oe.id),className:"w-full",children:[l.jsx(hl,{className:"mr-2 h-4 w-4"}),"Add Section"]})]})})]},oe.id)})})})]})}),l.jsx("div",{children:l.jsxs(ze,{children:[l.jsx(et,{children:l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(Br,{className:"h-5 w-5"}),"Recent Activities"]})}),l.jsx(Ge,{children:l.jsx("div",{className:"space-y-3",children:y.length===0?l.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activities yet"}):y.map(oe=>l.jsxs("div",{className:"flex items-start gap-3 py-2",children:[xe(oe.note),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium truncate",children:oe.note||`${Math.round(oe.completed)}% completed`}),l.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(oe.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]})]},oe.id))})})]})})]})]}),l.jsx(Gr,{open:z,onOpenChange:P,children:l.jsxs(zr,{children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Add Custom Chapter"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"chapter-title",children:"Chapter Title *"}),l.jsx(Be,{id:"chapter-title",value:H,onChange:oe=>B(oe.target.value),placeholder:"e.g., Appendix, Acknowledgements"})]}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(ye,{variant:"outline",onClick:()=>{B(""),P(!1)},children:"Cancel"}),l.jsx(ye,{onClick:()=>{H.trim()&&q(H.trim())},disabled:!H.trim(),children:"Add Chapter"})]})]})]})}),l.jsx(c_e,{open:L,onOpenChange:F,thesisData:V,defaultAuthorName:(r==null?void 0:r.nickname)||"",defaultInstitution:(r==null?void 0:r.university)||"",defaultDegreeProgram:r!=null&&r.degree_type?`${r.degree_type==="bachelor"?"Bachelor":"Master"} Thesis`:"",documents:ie})]})}):null};function B3({value:t,onSave:e,className:r,placeholder:n="Untitled",as:s="h2"}){const[i,a]=j.useState(!1),[o,c]=j.useState(t),u=j.useRef(null);j.useEffect(()=>{c(t)},[t]),j.useEffect(()=>{var g,x;i&&((g=u.current)==null||g.focus(),(x=u.current)==null||x.select())},[i]);const d=()=>{const g=o.trim();a(!1),g&&g!==t?e(g):c(t)},h=()=>{c(t),a(!1)},f=g=>{g.key==="Enter"?(g.preventDefault(),d()):g.key==="Escape"&&(g.preventDefault(),h())},p=g=>d(),m=s;return i?l.jsx("input",{ref:u,value:o,onChange:g=>c(g.target.value),onBlur:p,onKeyDown:f,placeholder:n,className:Le("w-full bg-transparent outline-none border-b border-primary/40 focus:border-primary",r)}):l.jsx(m,{onClick:()=>a(!0),title:"Click to rename",className:Le("cursor-text rounded-sm hover:bg-muted/40 transition-colors",r),children:t||l.jsx("span",{className:"text-muted-foreground/60",children:n})})}function ci(t){this.content=t}ci.prototype={constructor:ci,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,r){var n=r&&r!=t?this.remove(r):this,s=n.find(t),i=n.content.slice();return s==-1?i.push(r||t,e):(i[s+1]=e,r&&(i[s]=r)),new ci(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var r=this.content.slice();return r.splice(e,2),new ci(r)},addToStart:function(t,e){return new ci([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();return r.push(t,e),new ci(r)},addBefore:function(t,e,r){var n=this.remove(e),s=n.content.slice(),i=n.find(t);return s.splice(i==-1?s.length:i,0,e,r),new ci(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=ci.from(t),t.size?new ci(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ci.from(t),t.size?new ci(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ci.from(t);for(var r=0;r<t.content.length;r+=2)e=e.remove(t.content[r]);return e},toObject:function(){var t={};return this.forEach(function(e,r){t[e]=r}),t},get size(){return this.content.length>>1}};ci.from=function(t){if(t instanceof ci)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new ci(e)};function __e(t,e,r){for(let n=0;;n++){if(n==t.childCount||n==e.childCount)return t.childCount==e.childCount?null:r;let s=t.child(n),i=e.child(n);if(s==i){r+=s.nodeSize;continue}if(!s.sameMarkup(i))return r;if(s.isText&&s.text!=i.text){let a=s.text,o=i.text,c=0;for(;a[c]==o[c];c++)r++;return c&&c<a.length&&c<o.length&&N_e(a.charCodeAt(c-1))&&k_e(a.charCodeAt(c))&&r--,r}if(s.content.size||i.content.size){let a=__e(s.content,i.content,r+1);if(a!=null)return a}r+=s.nodeSize}}function j_e(t,e,r,n){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:r,b:n};let a=t.child(--s),o=e.child(--i),c=a.nodeSize;if(a==o){r-=c,n-=c;continue}if(!a.sameMarkup(o))return{a:r,b:n};if(a.isText&&a.text!=o.text){let u=a.text,d=o.text,h=u.length,f=d.length;for(;h>0&&f>0&&u[h-1]==d[f-1];)h--,f--,r--,n--;return h&&f&&h<u.length&&N_e(u.charCodeAt(h-1))&&k_e(u.charCodeAt(h))&&(r++,n++),{a:r,b:n}}if(a.content.size||o.content.size){let u=j_e(a.content,o.content,r-1,n-1);if(u)return u}r-=c,n-=c}}function k_e(t){return t>=56320&&t<57344}function N_e(t){return t>=55296&&t<56320}let Qe=class Zi{constructor(e,r){if(this.content=e,this.size=r||0,r==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,r,n,s=0,i){for(let a=0,o=0;o<r;a++){let c=this.content[a],u=o+c.nodeSize;if(u>e&&n(c,s+o,i||null,a)!==!1&&c.content.size){let d=o+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,r-d),n,s+d)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,r,n,s){let i="",a=!0;return this.nodesBetween(e,r,(o,c)=>{let u=o.isText?o.text.slice(Math.max(e,c)-c,r-c):o.isLeaf?s?typeof s=="function"?s(o):s:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=u},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let r=this.lastChild,n=e.firstChild,s=this.content.slice(),i=0;for(r.isText&&r.sameMarkup(n)&&(s[s.length-1]=r.withText(r.text+n.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new Zi(s,this.size+e.size)}cut(e,r=this.size){if(e==0&&r==this.size)return this;let n=[],s=0;if(r>e)for(let i=0,a=0;a<r;i++){let o=this.content[i],c=a+o.nodeSize;c>e&&((a<e||c>r)&&(o.isText?o=o.cut(Math.max(0,e-a),Math.min(o.text.length,r-a)):o=o.cut(Math.max(0,e-a-1),Math.min(o.content.size,r-a-1))),n.push(o),s+=o.nodeSize),a=c}return new Zi(n,s)}cutByIndex(e,r){return e==r?Zi.empty:e==0&&r==this.content.length?this:new Zi(this.content.slice(e,r))}replaceChild(e,r){let n=this.content[e];if(n==r)return this;let s=this.content.slice(),i=this.size+r.nodeSize-n.nodeSize;return s[e]=r,new Zi(s,i)}addToStart(e){return new Zi([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Zi(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let r=0;r<this.content.length;r++)if(!this.content[r].eq(e.content[r]))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 r=this.content[e];if(!r)throw new RangeError("Index "+e+" out of range for "+this);return r}maybeChild(e){return this.content[e]||null}forEach(e){for(let r=0,n=0;r<this.content.length;r++){let s=this.content[r];e(s,n,r),n+=s.nodeSize}}findDiffStart(e,r=0){return __e(this,e,r)}findDiffEnd(e,r=this.size,n=e.size){return j_e(this,e,r,n)}findIndex(e){if(e==0)return EC(0,e);if(e==this.size)return EC(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,n=0;;r++){let s=this.child(r),i=n+s.nodeSize;if(i>=e)return i==e?EC(r+1,i):EC(r,n);n=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,r){if(!r)return Zi.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return Zi.fromArray(r.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Zi.empty;let r,n=0;for(let s=0;s<e.length;s++){let i=e[s];n+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(r||(r=e.slice(0,s)),r[r.length-1]=i.withText(r[r.length-1].text+i.text)):r&&r.push(i)}return new Zi(r||e,n)}static from(e){if(!e)return Zi.empty;if(e instanceof Zi)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Zi([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};Qe.empty=new Qe([],0);const z3={index:0,offset:0};function EC(t,e){return z3.index=t,z3.offset=e,z3}function EO(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let r=Array.isArray(t);if(Array.isArray(e)!=r)return!1;if(r){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!EO(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!EO(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}let Vr=class qz{constructor(e,r){this.type=e,this.attrs=r}addToSet(e){let r,n=!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))r||(r=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!n&&i.type.rank>this.type.rank&&(r||(r=e.slice(0,s)),r.push(this),n=!0),r&&r.push(i)}}return r||(r=e.slice()),n||r.push(this),r}removeFromSet(e){for(let r=0;r<e.length;r++)if(this.eq(e[r]))return e.slice(0,r).concat(e.slice(r+1));return e}isInSet(e){for(let r=0;r<e.length;r++)if(this.eq(e[r]))return!0;return!1}eq(e){return this==e||this.type==e.type&&EO(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let r in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,r){if(!r)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[r.type];if(!n)throw new RangeError(`There is no mark type ${r.type} in this schema`);let s=n.create(r.attrs);return n.checkAttrs(s.attrs),s}static sameSet(e,r){if(e==r)return!0;if(e.length!=r.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(r[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return qz.none;if(e instanceof qz)return[e];let r=e.slice();return r.sort((n,s)=>n.type.rank-s.type.rank),r}};Vr.none=[];let nk=class extends Error{},vt=class hv{constructor(e,r,n){this.content=e,this.openStart=r,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,r){let n=A_e(this.content,e+this.openStart,r,this.openStart+1,this.openEnd+1);return n&&new hv(n,this.openStart,this.openEnd)}removeBetween(e,r){return new hv(E_e(this.content,e+this.openStart,r+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,r){if(!r)return hv.empty;let n=r.openStart||0,s=r.openEnd||0;if(typeof n!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new hv(Qe.fromJSON(e,r.content),n,s)}static maxOpen(e,r=!0){let n=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(r||!i.type.spec.isolating);i=i.firstChild)n++;for(let i=e.lastChild;i&&!i.isLeaf&&(r||!i.type.spec.isolating);i=i.lastChild)s++;return new hv(e,n,s)}};vt.empty=new vt(Qe.empty,0,0);function E_e(t,e,r){let{index:n,offset:s}=t.findIndex(e),i=t.maybeChild(n),{index:a,offset:o}=t.findIndex(r);if(s==e||i.isText){if(o!=r&&!t.child(a).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(n!=a)throw new RangeError("Removing non-flat range");return t.replaceChild(n,i.copy(E_e(i.content,e-s-1,r-s-1)))}function A_e(t,e,r,n,s,i){let{index:a,offset:o}=t.findIndex(e),c=t.maybeChild(a);if(o==e||c.isText)return i&&n<=0&&s<=0&&!i.canReplace(a,a,r)?null:t.cut(0,e).append(r).append(t.cut(e));let u=A_e(c.content,e-o-1,r,a==0?n-1:0,a==t.childCount-1?s-1:0,c);return u&&t.replaceChild(a,c.copy(u))}function STt(t,e,r){if(r.openStart>t.depth)throw new nk("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new nk("Inconsistent open depths");return C_e(t,e,r,0)}function C_e(t,e,r,n){let s=t.index(n),i=t.node(n);if(s==e.index(n)&&n<t.depth-r.openStart){let a=C_e(t,e,r,n+1);return i.copy(i.content.replaceChild(s,a))}else if(r.content.size)if(!r.openStart&&!r.openEnd&&t.depth==n&&e.depth==n){let a=t.parent,o=a.content;return Ly(a,o.cut(0,t.parentOffset).append(r.content).append(o.cut(e.parentOffset)))}else{let{start:a,end:o}=_Tt(r,t);return Ly(i,P_e(t,a,o,e,n))}else return Ly(i,AO(t,e,n))}function T_e(t,e){if(!e.type.compatibleContent(t.type))throw new nk("Cannot join "+e.type.name+" onto "+t.type.name)}function Gz(t,e,r){let n=t.node(r);return T_e(n,e.node(r)),n}function Dy(t,e){let r=e.length-1;r>=0&&t.isText&&t.sameMarkup(e[r])?e[r]=t.withText(e[r].text+t.text):e.push(t)}function E_(t,e,r,n){let s=(e||t).node(r),i=0,a=e?e.index(r):s.childCount;t&&(i=t.index(r),t.depth>r?i++:t.textOffset&&(Dy(t.nodeAfter,n),i++));for(let o=i;o<a;o++)Dy(s.child(o),n);e&&e.depth==r&&e.textOffset&&Dy(e.nodeBefore,n)}function Ly(t,e){if(!t.type.validContent(e))throw new nk("Invalid content for node "+t.type.name);return t.copy(e)}function P_e(t,e,r,n,s){let i=t.depth>s&&Gz(t,e,s+1),a=n.depth>s&&Gz(r,n,s+1),o=[];return E_(null,t,s,o),i&&a&&e.index(s)==r.index(s)?(T_e(i,a),Dy(Ly(i,P_e(t,e,r,n,s+1)),o)):(i&&Dy(Ly(i,AO(t,e,s+1)),o),E_(e,r,s,o),a&&Dy(Ly(a,AO(r,n,s+1)),o)),E_(n,null,s,o),new Qe(o)}function AO(t,e,r){let n=[];if(E_(null,t,r,n),t.depth>r){let s=Gz(t,e,r+1);Dy(Ly(s,AO(t,e,r+1)),n)}return E_(e,null,r,n),new Qe(n)}function _Tt(t,e){let r=e.depth-t.openStart,s=e.node(r).copy(t.content);for(let i=r-1;i>=0;i--)s=e.node(i).copy(Qe.from(s));return{start:s.resolveNoCache(t.openStart+r),end:s.resolveNoCache(s.content.size-t.openEnd-r)}}class sk{constructor(e,r,n){this.pos=e,this.path=r,this.parentOffset=n,this.depth=r.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,r=this.index(this.depth);if(r==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],s=e.child(r);return n?e.child(r).cut(n):s}get nodeBefore(){let e=this.index(this.depth),r=this.pos-this.path[this.path.length-1];return r?this.parent.child(e).cut(0,r):e==0?null:this.parent.child(e-1)}posAtIndex(e,r){r=this.resolveDepth(r);let n=this.path[r*3],s=r==0?0:this.path[r*3-1]+1;for(let i=0;i<e;i++)s+=n.child(i).nodeSize;return s}marks(){let e=this.parent,r=this.index();if(e.content.size==0)return Vr.none;if(this.textOffset)return e.child(r).marks;let n=e.maybeChild(r-1),s=e.maybeChild(r);if(!n){let o=n;n=s,s=o}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!s||!i[a].isInSet(s.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let r=this.parent.maybeChild(this.index());if(!r||!r.isInline)return null;let n=r.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!s||!n[i].isInSet(s.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let r=this.depth;r>0;r--)if(this.start(r)<=e&&this.end(r)>=e)return r;return 0}blockRange(e=this,r){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!r||r(this.node(n))))return new CO(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let r=1;r<=this.depth;r++)e+=(e?"/":"")+this.node(r).type.name+"_"+this.index(r-1);return e+":"+this.parentOffset}static resolve(e,r){if(!(r>=0&&r<=e.content.size))throw new RangeError("Position "+r+" out of range");let n=[],s=0,i=r;for(let a=e;;){let{index:o,offset:c}=a.content.findIndex(i),u=i-c;if(n.push(a,o,s+c),!u||(a=a.child(o),a.isText))break;i=u-1,s+=c+1}return new sk(r,n,i)}static resolveCached(e,r){let n=wse.get(e);if(n)for(let i=0;i<n.elts.length;i++){let a=n.elts[i];if(a.pos==r)return a}else wse.set(e,n=new jTt);let s=n.elts[n.i]=sk.resolve(e,r);return n.i=(n.i+1)%kTt,s}}class jTt{constructor(){this.elts=[],this.i=0}}const kTt=12,wse=new WeakMap;class CO{constructor(e,r,n){this.$from=e,this.$to=r,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const NTt=Object.create(null);let Cp=class Kz{constructor(e,r,n,s=Vr.none){this.type=e,this.attrs=r,this.marks=s,this.content=n||Qe.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,r,n,s=0){this.content.nodesBetween(e,r,n,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,r,n,s){return this.content.textBetween(e,r,n,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,r,n){return this.type==e&&EO(this.attrs,r||e.defaultAttrs||NTt)&&Vr.sameSet(this.marks,n||Vr.none)}copy(e=null){return e==this.content?this:new Kz(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Kz(this.type,this.attrs,this.content,e)}cut(e,r=this.content.size){return e==0&&r==this.content.size?this:this.copy(this.content.cut(e,r))}slice(e,r=this.content.size,n=!1){if(e==r)return vt.empty;let s=this.resolve(e),i=this.resolve(r),a=n?0:s.sharedDepth(r),o=s.start(a),u=s.node(a).content.cut(s.pos-o,i.pos-o);return new vt(u,s.depth-a,i.depth-a)}replace(e,r,n){return STt(this.resolve(e),this.resolve(r),n)}nodeAt(e){for(let r=this;;){let{index:n,offset:s}=r.content.findIndex(e);if(r=r.maybeChild(n),!r)return null;if(s==e||r.isText)return r;e-=s+1}}childAfter(e){let{index:r,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(r),index:r,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:r,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(r),index:r,offset:n};let s=this.content.child(r-1);return{node:s,index:r-1,offset:n-s.nodeSize}}resolve(e){return sk.resolveCached(this,e)}resolveNoCache(e){return sk.resolve(this,e)}rangeHasMark(e,r,n){let s=!1;return r>e&&this.nodesBetween(e,r,i=>(n.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()+")"),O_e(this.marks,e)}contentMatchAt(e){let r=this.type.contentMatch.matchFragment(this.content,0,e);if(!r)throw new Error("Called contentMatchAt on a node with invalid content");return r}canReplace(e,r,n=Qe.empty,s=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,s,i),o=a&&a.matchFragment(this.content,r);if(!o||!o.validEnd)return!1;for(let c=s;c<i;c++)if(!this.type.allowsMarks(n.child(c).marks))return!1;return!0}canReplaceWith(e,r,n,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,r);return a?a.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=Vr.none;for(let r=0;r<this.marks.length;r++){let n=this.marks[r];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!Vr.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(r=>r.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let e={type:this.type.name};for(let r 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(r=>r.toJSON())),e}static fromJSON(e,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(e.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(r.text,n)}let s=Qe.fromJSON(e,r.content),i=e.nodeType(r.type).create(r.attrs,s,n);return i.type.checkAttrs(i.attrs),i}};Cp.prototype.text=void 0;class TO extends Cp{constructor(e,r,n,s){if(super(e,r,null,s),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):O_e(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,r){return this.text.slice(e,r)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new TO(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new TO(this.type,this.attrs,e,this.marks)}cut(e=0,r=this.text.length){return e==0&&r==this.text.length?this:this.withText(this.text.slice(e,r))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function O_e(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class lx{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,r){let n=new ETt(e,r);if(n.next==null)return lx.empty;let s=I_e(n);n.next&&n.err("Unexpected trailing text");let i=RTt(ITt(s));return MTt(i,n),i}matchType(e){for(let r=0;r<this.next.length;r++)if(this.next[r].type==e)return this.next[r].next;return null}matchFragment(e,r=0,n=e.childCount){let s=this;for(let i=r;s&&i<n;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:r}=this.next[e];if(!(r.isText||r.hasRequiredAttrs()))return r}return null}compatible(e){for(let r=0;r<this.next.length;r++)for(let n=0;n<e.next.length;n++)if(this.next[r].type==e.next[n].type)return!0;return!1}fillBefore(e,r=!1,n=0){let s=[this];function i(a,o){let c=a.matchFragment(e,n);if(c&&(!r||c.validEnd))return Qe.from(o.map(u=>u.createAndFill()));for(let u=0;u<a.next.length;u++){let{type:d,next:h}=a.next[u];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(h)==-1){s.push(h);let f=i(h,o.concat(d));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let r=this.computeWrapping(e);return this.wrapCache.push(e,r),r}computeWrapping(e){let r=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let s=n.shift(),i=s.match;if(i.matchType(e)){let a=[];for(let o=s;o.type;o=o.via)a.push(o.type);return a.reverse()}for(let a=0;a<i.next.length;a++){let{type:o,next:c}=i.next[a];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in r)&&(!s.type||c.validEnd)&&(n.push({match:o.contentMatch,type:o,via:s}),r[o.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 r(n){e.push(n);for(let s=0;s<n.next.length;s++)e.indexOf(n.next[s].next)==-1&&r(n.next[s].next)}return r(this),e.map((n,s)=>{let i=s+(n.validEnd?"*":" ")+" ";for(let a=0;a<n.next.length;a++)i+=(a?", ":"")+n.next[a].type.name+"->"+e.indexOf(n.next[a].next);return i}).join(`
`)}}lx.empty=new lx(!0);class ETt{constructor(e,r){this.string=e,this.nodeTypes=r,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 I_e(t){let e=[];do e.push(ATt(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ATt(t){let e=[];do e.push(CTt(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function CTt(t){let e=OTt(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=TTt(t,e);else break;return e}function Sse(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function TTt(t,e){let r=Sse(t),n=r;return t.eat(",")&&(t.next!="}"?n=Sse(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:e}}function PTt(t,e){let r=t.nodeTypes,n=r[e];if(n)return[n];let s=[];for(let i in r){let a=r[i];a.isInGroup(e)&&s.push(a)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function OTt(t){if(t.eat("(")){let e=I_e(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=PTt(t,t.next).map(r=>(t.inline==null?t.inline=r.isInline:t.inline!=r.isInline&&t.err("Mixing inline and block content"),{type:"name",value:r}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ITt(t){let e=[[]];return s(i(t,0),r()),e;function r(){return e.push([])-1}function n(a,o,c){let u={term:c,to:o};return e[a].push(u),u}function s(a,o){a.forEach(c=>c.to=o)}function i(a,o){if(a.type=="choice")return a.exprs.reduce((c,u)=>c.concat(i(u,o)),[]);if(a.type=="seq")for(let c=0;;c++){let u=i(a.exprs[c],o);if(c==a.exprs.length-1)return u;s(u,o=r())}else if(a.type=="star"){let c=r();return n(o,c),s(i(a.expr,c),c),[n(c)]}else if(a.type=="plus"){let c=r();return s(i(a.expr,o),c),s(i(a.expr,c),c),[n(c)]}else{if(a.type=="opt")return[n(o)].concat(i(a.expr,o));if(a.type=="range"){let c=o;for(let u=0;u<a.min;u++){let d=r();s(i(a.expr,c),d),c=d}if(a.max==-1)s(i(a.expr,c),c);else for(let u=a.min;u<a.max;u++){let d=r();n(c,d),s(i(a.expr,c),d),c=d}return[n(c)]}else{if(a.type=="name")return[n(o,void 0,a.value)];throw new Error("Unknown expr type")}}}}function R_e(t,e){return e-t}function _se(t,e){let r=[];return n(e),r.sort(R_e);function n(s){let i=t[s];if(i.length==1&&!i[0].term)return n(i[0].to);r.push(s);for(let a=0;a<i.length;a++){let{term:o,to:c}=i[a];!o&&r.indexOf(c)==-1&&n(c)}}}function RTt(t){let e=Object.create(null);return r(_se(t,0));function r(n){let s=[];n.forEach(a=>{t[a].forEach(({term:o,to:c})=>{if(!o)return;let u;for(let d=0;d<s.length;d++)s[d][0]==o&&(u=s[d][1]);_se(t,c).forEach(d=>{u||s.push([o,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let i=e[n.join(",")]=new lx(n.indexOf(t.length-1)>-1);for(let a=0;a<s.length;a++){let o=s[a][1].sort(R_e);i.next.push({type:s[a][0],next:e[o.join(",")]||r(o)})}return i}}function MTt(t,e){for(let r=0,n=[t];r<n.length;r++){let s=n[r],i=!s.validEnd,a=[];for(let o=0;o<s.next.length;o++){let{type:c,next:u}=s.next[o];a.push(c.name),i&&!(c.isText||c.hasRequiredAttrs())&&(i=!1),n.indexOf(u)==-1&&n.push(u)}i&&e.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function M_e(t){let e=Object.create(null);for(let r in t){let n=t[r];if(!n.hasDefault)return null;e[r]=n.default}return e}function D_e(t,e){let r=Object.create(null);for(let n in t){let s=e&&e[n];if(s===void 0){let i=t[n];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+n)}r[n]=s}return r}function L_e(t,e,r,n){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${r} of type ${n}`);for(let s in t)t[s].validate&&t[s].validate(e[s])}function F_e(t,e){let r=Object.create(null);if(e)for(let n in e)r[n]=new LTt(t,n,e[n]);return r}let jse=class $_e{constructor(e,r,n){this.name=e,this.schema=r,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=F_e(e,n.attrs),this.defaultAttrs=M_e(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==lx.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:D_e(this.attrs,e)}create(e=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Cp(this,this.computeAttrs(e),Qe.from(r),Vr.setFrom(n))}createChecked(e=null,r,n){return r=Qe.from(r),this.checkContent(r),new Cp(this,this.computeAttrs(e),r,Vr.setFrom(n))}createAndFill(e=null,r,n){if(e=this.computeAttrs(e),r=Qe.from(r),r.size){let a=this.contentMatch.fillBefore(r);if(!a)return null;r=a.append(r)}let s=this.contentMatch.matchFragment(r),i=s&&s.fillBefore(Qe.empty,!0);return i?new Cp(this,e,r.append(i),Vr.setFrom(n)):null}validContent(e){let r=this.contentMatch.matchFragment(e);if(!r||!r.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){L_e(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 r=0;r<e.length;r++)if(!this.allowsMarkType(e[r].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let r;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?r&&r.push(e[n]):r||(r=e.slice(0,n));return r?r.length?r:Vr.none:e}static compile(e,r){let n=Object.create(null);e.forEach((i,a)=>n[i]=new $_e(i,r,a));let s=r.spec.topNode||"doc";if(!n[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let i in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function DTt(t,e,r){let n=r.split("|");return s=>{let i=s===null?"null":typeof s;if(n.indexOf(i)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${t}, got ${i}`)}}class LTt{constructor(e,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?DTt(e,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class dD{constructor(e,r,n,s){this.name=e,this.rank=r,this.schema=n,this.spec=s,this.attrs=F_e(e,s.attrs),this.excluded=null;let i=M_e(this.attrs);this.instance=i?new Vr(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Vr(this,D_e(this.attrs,e))}static compile(e,r){let n=Object.create(null),s=0;return e.forEach((i,a)=>n[i]=new dD(i,s++,r,a)),n}removeFromSet(e){for(var r=0;r<e.length;r++)e[r].type==this&&(e=e.slice(0,r).concat(e.slice(r+1)),r--);return e}isInSet(e){for(let r=0;r<e.length;r++)if(e[r].type==this)return e[r]}checkAttrs(e){L_e(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class B_e{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let r=this.spec={};for(let s in e)r[s]=e[s];r.nodes=ci.from(e.nodes),r.marks=ci.from(e.marks||{}),this.nodes=jse.compile(this.spec.nodes,this),this.marks=dD.compile(this.spec.marks,this);let n=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],a=i.spec.content||"",o=i.spec.marks;if(i.contentMatch=n[a]||(n[a]=lx.parse(a,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=o=="_"?null:o?kse(this,o.split(" ")):o==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],a=i.spec.excludes;i.excluded=a==null?[i]:a==""?[]:kse(this,a.split(" "))}this.nodeFromJSON=s=>Cp.fromJSON(this,s),this.markFromJSON=s=>Vr.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,r=null,n,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof jse){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(r,n,s)}text(e,r){let n=this.nodes.text;return new TO(n,n.defaultAttrs,e,Vr.setFrom(r))}mark(e,r){return typeof e=="string"&&(e=this.marks[e]),e.create(r)}nodeType(e){let r=this.nodes[e];if(!r)throw new RangeError("Unknown node type: "+e);return r}}function kse(t,e){let r=[];for(let n=0;n<e.length;n++){let s=e[n],i=t.marks[s],a=i;if(i)r.push(i);else for(let o in t.marks){let c=t.marks[o];(s=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(s)>-1)&&r.push(a=c)}if(!a)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return r}function FTt(t){return t.tag!=null}function $Tt(t){return t.style!=null}class Tp{constructor(e,r){this.schema=e,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(s=>{if(FTt(s))this.tags.push(s);else if($Tt(s)){let i=/[^=]*/.exec(s.style)[0];n.indexOf(i)<0&&n.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,r={}){let n=new Ese(this,r,!1);return n.addAll(e,Vr.none,r.from,r.to),n.finish()}parseSlice(e,r={}){let n=new Ese(this,r,!0);return n.addAll(e,Vr.none,r.from,r.to),vt.maxOpen(n.finish())}matchTag(e,r,n){for(let s=n?this.tags.indexOf(n)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(UTt(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||r.matchesContext(i.context))){if(i.getAttrs){let a=i.getAttrs(e);if(a===!1)continue;i.attrs=a||void 0}return i}}}matchStyle(e,r,n,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let a=this.styles[i],o=a.style;if(!(o.indexOf(e)!=0||a.context&&!n.matchesContext(a.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=r))){if(a.getAttrs){let c=a.getAttrs(r);if(c===!1)continue;a.attrs=c||void 0}return a}}}static schemaRules(e){let r=[];function n(s){let i=s.priority==null?50:s.priority,a=0;for(;a<r.length;a++){let o=r[a];if((o.priority==null?50:o.priority)<i)break}r.splice(a,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(a=>{n(a=Ase(a)),a.mark||a.ignore||a.clearMark||(a.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(a=>{n(a=Ase(a)),a.node||a.ignore||a.mark||(a.node=s)})}return r}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Tp(e,Tp.schemaRules(e)))}}const z_e={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},BTt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},U_e={ol:!0,ul:!0},ik=1,Yz=2,A_=4;function Nse(t,e,r){return e!=null?(e?ik:0)|(e==="full"?Yz:0):t&&t.whitespace=="pre"?ik|Yz:r&~A_}class AC{constructor(e,r,n,s,i,a){this.type=e,this.attrs=r,this.marks=n,this.solid=s,this.options=a,this.content=[],this.activeMarks=Vr.none,this.match=i||(a&A_?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Qe.from(e));if(r)this.match=this.type.contentMatch.matchFragment(r);else{let n=this.type.contentMatch,s;return(s=n.findWrapping(e.type))?(this.match=n,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ik)){let n=this.content[this.content.length-1],s;if(n&&n.isText&&(s=/[ \t\r\n\u000c]+$/.exec(n.text))){let i=n;n.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 r=Qe.from(this.content);return!e&&this.match&&(r=r.append(this.match.fillBefore(Qe.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!z_e.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ese{constructor(e,r,n){this.parser=e,this.options=r,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let s=r.topNode,i,a=Nse(null,r.preserveWhitespace,0)|(n?A_:0);s?i=new AC(s.type,s.attrs,Vr.none,!0,r.topMatch||s.type.contentMatch,a):n?i=new AC(null,null,Vr.none,!0,null,a):i=new AC(e.schema.topNodeType,null,Vr.none,!0,null,a),this.nodes=[i],this.find=r.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,r){e.nodeType==3?this.addTextNode(e,r):e.nodeType==1&&this.addElement(e,r)}addTextNode(e,r){let n=e.nodeValue,s=this.top,i=s.options&Yz?"full":this.localPreserveWS||(s.options&ik)>0,{schema:a}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(i)if(i==="full")n=n.replace(/\r\n?/g,`
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let o=n.split(/\r?\n|\r/);for(let c=0;c<o.length;c++)c&&this.insertNode(a.linebreakReplacement.create(),r,!0),o[c]&&this.insertNode(a.text(o[c]),r,!/\S/.test(o[c]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let o=s.content[s.content.length-1],c=e.previousSibling;(!o||c&&c.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(n=n.slice(1))}n&&this.insertNode(a.text(n),r,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,r,n){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;U_e.hasOwnProperty(a)&&this.parser.normalizeLists&&zTt(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(c?c.ignore:BTt.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,r);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(z_e.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),u=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,r);break e}let h=c&&c.skip?r:this.readStyles(e,r);h&&this.addAll(e,h),u&&this.sync(i),this.needsBlock=d}else{let u=this.readStyles(e,r);u&&this.addElementByRule(e,c,u,c.consuming===!1?o:void 0)}this.localPreserveWS=s}leafFallback(e,r){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),r)}ignoreFallback(e,r){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),r,!0)}readStyles(e,r){let n=e.style;if(n&&n.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],a=n.getPropertyValue(i);if(a)for(let o=void 0;;){let c=this.parser.matchStyle(i,a,this,o);if(!c)break;if(c.ignore)return null;if(c.clearMark?r=r.filter(u=>!c.clearMark(u)):r=r.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)o=c;else break}}return r}addElementByRule(e,r,n,s){let i,a;if(r.node)if(a=this.parser.schema.nodes[r.node],a.isLeaf)this.insertNode(a.create(r.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let c=this.enter(a,r.attrs||null,n,r.preserveWhitespace);c&&(i=!0,n=c)}else{let c=this.parser.schema.marks[r.mark];n=n.concat(c.create(r.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(s)this.addElement(e,n,s);else if(r.getContent)this.findInside(e),r.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,n,!1));else{let c=e;typeof r.contentElement=="string"?c=e.querySelector(r.contentElement):typeof r.contentElement=="function"?c=r.contentElement(e):r.contentElement&&(c=r.contentElement),this.findAround(e,c,!0),this.addAll(c,n),this.findAround(e,c,!1)}i&&this.sync(o)&&this.open--}addAll(e,r,n,s){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=s==null?null:e.childNodes[s];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,r);this.findAtPoint(e,i)}findPlace(e,r,n){let s,i;for(let a=this.open,o=0;a>=0;a--){let c=this.nodes[a],u=c.findWrapping(e);if(u&&(!s||s.length>u.length+o)&&(s=u,i=c,!u.length))break;if(c.solid){if(n)break;o+=2}}if(!s)return null;this.sync(i);for(let a=0;a<s.length;a++)r=this.enterInner(s[a],null,r,!1);return r}insertNode(e,r,n){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(r=this.enterInner(i,null,r))}let s=this.findPlace(e,r,n);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let a=Vr.none;for(let o of s.concat(e.marks))(i.type?i.type.allowsMarkType(o.type):Cse(o.type,e.type))&&(a=o.addToSet(a));return i.content.push(e.mark(a)),!0}return!1}enter(e,r,n,s){let i=this.findPlace(e.create(r),n,!1);return i&&(i=this.enterInner(e,r,n,!0,s)),i}enterInner(e,r,n,s=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=Nse(e,i,a.options);a.options&A_&&a.content.length==0&&(o|=A_);let c=Vr.none;return n=n.filter(u=>(a.type?a.type.allowsMarkType(u.type):Cse(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new AC(e,r,c,s,null,o)),this.open++,n}closeExtra(e=!1){let r=this.nodes.length-1;if(r>this.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].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 r=this.open;r>=0;r--){if(this.nodes[r]==e)return this.open=r,!0;this.localPreserveWS&&(this.nodes[r].options|=ik)}return!1}get currentPos(){this.closeExtra();let e=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let s=n.length-1;s>=0;s--)e+=n[s].nodeSize;r&&e++}return e}findAtPoint(e,r){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==r&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&(this.find[r].pos=this.currentPos)}findAround(e,r,n){if(e!=r&&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)&&r.compareDocumentPosition(this.find[s].node)&(n?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&(this.find[r].pos=this.currentPos-(e.nodeValue.length-this.find[r].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let r=e.split("/"),n=this.options.context,s=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(s?0:1),a=(o,c)=>{for(;o>=0;o--){let u=r[o];if(u==""){if(o==r.length-1||o==0)continue;for(;c>=i;c--)if(a(o-1,c))return!0;return!1}else{let d=c>0||c==0&&s?this.nodes[c].type:n&&c>=i?n.node(c-i).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return a(r.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let r=e.depth;r>=0;r--){let n=e.node(r).contentMatchAt(e.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}}function zTt(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&U_e.hasOwnProperty(n)&&r?(r.appendChild(e),e=r):n=="li"?r=e:n&&(r=null)}}function UTt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ase(t){let e={};for(let r in t)e[r]=t[r];return e}function Cse(t,e){let r=e.schema.nodes;for(let n in r){let s=r[n];if(!s.allowsMarkType(t))continue;let i=[],a=o=>{i.push(o);for(let c=0;c<o.edgeCount;c++){let{type:u,next:d}=o.edge(c);if(u==e||i.indexOf(d)<0&&a(d))return!0}};if(a(s.contentMatch))return!0}}class Px{constructor(e,r){this.nodes=e,this.marks=r}serializeFragment(e,r={},n){n||(n=CC(r).createDocumentFragment());let s=n,i=[];return e.forEach(a=>{if(i.length||a.marks.length){let o=0,c=0;for(;o<i.length&&c<a.marks.length;){let u=a.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(i[o][0])||u.type.spec.spanning===!1)break;o++,c++}for(;o<i.length;)s=i.pop()[1];for(;c<a.marks.length;){let u=a.marks[c++],d=this.serializeMark(u,a.isInline,r);d&&(i.push([u,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(a,r))}),n}serializeNodeInner(e,r){if(e.isText)return CC(r).createTextNode(e.text);let{dom:n,contentDOM:s}=t2(CC(r),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,r,s)}return n}serializeNode(e,r={}){let n=this.serializeNodeInner(e,r);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,r);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,r,n={}){let s=this.marks[e.type.name];return s&&t2(CC(n),s(e,r),null,e.attrs)}static renderSpec(e,r,n=null,s){return typeof r=="string"?{dom:e.createTextNode(r)}:t2(e,r,n,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Px(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let r=Tse(e.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(e){return Tse(e.marks)}}function Tse(t){let e={};for(let r in t){let n=t[r].spec.toDOM;n&&(e[r]=n)}return e}function CC(t){return t.document||window.document}const Pse=new WeakMap;function HTt(t){let e=Pse.get(t);return e===void 0&&Pse.set(t,e=VTt(t)),e}function VTt(t){let e=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let s=0;s<n.length;s++)r(n[s]);else for(let s in n)r(n[s])}return r(t),e}function t2(t,e,r,n){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(n&&(i=HTt(n))&&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 a=s.indexOf(" ");a>0&&(r=s.slice(0,a),s=s.slice(a+1));let o,c=r?t.createElementNS(r,s):t.createElement(s),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let h in u)if(u[h]!=null){let f=h.indexOf(" ");f>0?c.setAttributeNS(h.slice(0,f),h.slice(f+1),u[h]):h=="style"&&c.style?c.style.cssText=u[h]:c.setAttribute(h,u[h])}}for(let h=d;h<e.length;h++){let f=e[h];if(f===0){if(h<e.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else if(typeof f=="string")c.appendChild(t.createTextNode(f));else{let{dom:p,contentDOM:m}=t2(t,f,r,n);if(c.appendChild(p),m){if(o)throw new RangeError("Multiple content holes");o=m}}}return{dom:c,contentDOM:o}}const H_e=65535,V_e=Math.pow(2,16);function WTt(t,e){return t+e*V_e}function Ose(t){return t&H_e}function qTt(t){return(t-(t&H_e))/V_e}const W_e=1,q_e=2,r2=4,G_e=8;let Xz=class{constructor(e,r,n){this.pos=e,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&G_e)>0}get deletedBefore(){return(this.delInfo&(W_e|r2))>0}get deletedAfter(){return(this.delInfo&(q_e|r2))>0}get deletedAcross(){return(this.delInfo&r2)>0}},cx=class fv{constructor(e,r=!1){if(this.ranges=e,this.inverted=r,!e.length&&fv.empty)return fv.empty}recover(e){let r=0,n=Ose(e);if(!this.inverted)for(let s=0;s<n;s++)r+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[n*3]+r+qTt(e)}mapResult(e,r=1){return this._map(e,r,!1)}map(e,r=1){return this._map(e,r,!0)}_map(e,r,n){let s=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?s:0);if(c>e)break;let u=this.ranges[o+i],d=this.ranges[o+a],h=c+u;if(e<=h){let f=u?e==c?-1:e==h?1:r:r,p=c+s+(f<0?0:d);if(n)return p;let m=e==(r<0?c:h)?null:WTt(o/3,e-c),g=e==c?q_e:e==h?W_e:r2;return(r<0?e!=c:e!=h)&&(g|=G_e),new Xz(p,g,m)}s+=d-u}return n?e+s:new Xz(e+s,0,null)}touches(e,r){let n=0,s=Ose(r),i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?n:0);if(c>e)break;let u=this.ranges[o+i],d=c+u;if(e<=d&&o==s*3)return!0;n+=this.ranges[o+a]-u}return!1}forEach(e){let r=this.inverted?2:1,n=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let a=this.ranges[s],o=a-(this.inverted?i:0),c=a+(this.inverted?0:i),u=this.ranges[s+r],d=this.ranges[s+n];e(o,o+u,c,c+d),i+=d-u}}invert(){return new fv(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?fv.empty:new fv(e<0?[0,-e,0]:[0,0,e])}};cx.empty=new cx([]);class ak{constructor(e,r,n=0,s=e?e.length:0){this.mirror=r,this.from=n,this.to=s,this._maps=e||[],this.ownData=!(e||r)}get maps(){return this._maps}slice(e=0,r=this.maps.length){return new ak(this._maps,this.mirror,e,r)}appendMap(e,r){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),r!=null&&this.setMirror(this._maps.length-1,r)}appendMapping(e){for(let r=0,n=this._maps.length;r<e._maps.length;r++){let s=e.getMirror(r);this.appendMap(e._maps[r],s!=null&&s<r?n+s:void 0)}}getMirror(e){if(this.mirror){for(let r=0;r<this.mirror.length;r++)if(this.mirror[r]==e)return this.mirror[r+(r%2?-1:1)]}}setMirror(e,r){this.mirror||(this.mirror=[]),this.mirror.push(e,r)}appendMappingInverted(e){for(let r=e.maps.length-1,n=this._maps.length+e._maps.length;r>=0;r--){let s=e.getMirror(r);this.appendMap(e._maps[r].invert(),s!=null&&s>r?n-s-1:void 0)}}invert(){let e=new ak;return e.appendMappingInverted(this),e}map(e,r=1){if(this.mirror)return this._map(e,r,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,r);return e}mapResult(e,r=1){return this._map(e,r,!1)}_map(e,r,n){let s=0;for(let i=this.from;i<this.to;i++){let a=this._maps[i],o=a.mapResult(e,r);if(o.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,e=this._maps[c].recover(o.recover);continue}}s|=o.delInfo,e=o.pos}return n?e:new Xz(e,s,null)}}const U3=Object.create(null);let Xi=class{getMap(){return cx.empty}merge(e){return null}static fromJSON(e,r){if(!r||!r.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=U3[r.stepType];if(!n)throw new RangeError(`No step type ${r.stepType} defined`);return n.fromJSON(e,r)}static jsonID(e,r){if(e in U3)throw new RangeError("Duplicate use of step JSON ID "+e);return U3[e]=r,r.prototype.jsonID=e,r}},pa=class FS{constructor(e,r){this.doc=e,this.failed=r}static ok(e){return new FS(e,null)}static fail(e){return new FS(null,e)}static fromReplace(e,r,n,s){try{return FS.ok(e.replace(r,n,s))}catch(i){if(i instanceof nk)return FS.fail(i.message);throw i}}};function k7(t,e,r){let n=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(k7(i.content,e,i))),i.isInline&&(i=e(i,r,s)),n.push(i)}return Qe.fromArray(n)}let N7=class $S extends Xi{constructor(e,r,n){super(),this.from=e,this.to=r,this.mark=n}apply(e){let r=e.slice(this.from,this.to),n=e.resolve(this.from),s=n.node(n.sharedDepth(this.to)),i=new vt(k7(r.content,(a,o)=>!a.isAtom||!o.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),s),r.openStart,r.openEnd);return pa.fromReplace(e,this.from,this.to,i)}invert(){return new m1(this.from,this.to,this.mark)}map(e){let r=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new $S(r.pos,n.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:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new $S(r.from,r.to,e.markFromJSON(r.mark))}};Xi.jsonID("addMark",N7);let m1=class BS extends Xi{constructor(e,r,n){super(),this.from=e,this.to=r,this.mark=n}apply(e){let r=e.slice(this.from,this.to),n=new vt(k7(r.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),r.openStart,r.openEnd);return pa.fromReplace(e,this.from,this.to,n)}invert(){return new N7(this.from,this.to,this.mark)}map(e){let r=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new BS(r.pos,n.pos,this.mark)}merge(e){return e instanceof BS&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new BS(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,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new BS(r.from,r.to,e.markFromJSON(r.mark))}};Xi.jsonID("removeMark",m1);let E7=class zS extends Xi{constructor(e,r){super(),this.pos=e,this.mark=r}apply(e){let r=e.nodeAt(this.pos);if(!r)return pa.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return pa.fromReplace(e,this.pos,this.pos+1,new vt(Qe.from(n),0,r.isLeaf?0:1))}invert(e){let r=e.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let s=0;s<r.marks.length;s++)if(!r.marks[s].isInSet(n))return new zS(this.pos,r.marks[s]);return new zS(this.pos,this.mark)}}return new PO(this.pos,this.mark)}map(e){let r=e.mapResult(this.pos,1);return r.deletedAfter?null:new zS(r.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,r){if(typeof r.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new zS(r.pos,e.markFromJSON(r.mark))}};Xi.jsonID("addNodeMark",E7);let PO=class Jz extends Xi{constructor(e,r){super(),this.pos=e,this.mark=r}apply(e){let r=e.nodeAt(this.pos);if(!r)return pa.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.removeFromSet(r.marks));return pa.fromReplace(e,this.pos,this.pos+1,new vt(Qe.from(n),0,r.isLeaf?0:1))}invert(e){let r=e.nodeAt(this.pos);return!r||!this.mark.isInSet(r.marks)?this:new E7(this.pos,this.mark)}map(e){let r=e.mapResult(this.pos,1);return r.deletedAfter?null:new Jz(r.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,r){if(typeof r.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Jz(r.pos,e.markFromJSON(r.mark))}};Xi.jsonID("removeNodeMark",PO);let Cl=class Zh extends Xi{constructor(e,r,n,s=!1){super(),this.from=e,this.to=r,this.slice=n,this.structure=s}apply(e){return this.structure&&Qz(e,this.from,this.to)?pa.fail("Structure replace would overwrite content"):pa.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new cx([this.from,this.to-this.from,this.slice.size])}invert(e){return new Zh(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let r=e.mapResult(this.to,-1),n=this.from==this.to&&Zh.MAP_BIAS<0?r:e.mapResult(this.from,1);return n.deletedAcross&&r.deletedAcross?null:new Zh(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Zh)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let r=this.slice.size+e.slice.size==0?vt.empty:new vt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Zh(this.from,this.to+(e.to-e.from),r,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let r=this.slice.size+e.slice.size==0?vt.empty:new vt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Zh(e.from,this.to,r,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,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Zh(r.from,r.to,vt.fromJSON(e,r.slice),!!r.structure)}};Cl.MAP_BIAS=1;Xi.jsonID("replace",Cl);let Qa=class n2 extends Xi{constructor(e,r,n,s,i,a,o=!1){super(),this.from=e,this.to=r,this.gapFrom=n,this.gapTo=s,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Qz(e,this.from,this.gapFrom)||Qz(e,this.gapTo,this.to)))return pa.fail("Structure gap-replace would overwrite content");let r=e.slice(this.gapFrom,this.gapTo);if(r.openStart||r.openEnd)return pa.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,r.content);return n?pa.fromReplace(e,this.from,this.to,n):pa.fail("Content does not fit in gap")}getMap(){return new cx([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let r=this.gapTo-this.gapFrom;return new n2(this.from,this.from+this.slice.size+r,this.from+this.insert,this.from+this.insert+r,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let r=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),s=this.from==this.gapFrom?r.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return r.deletedAcross&&n.deletedAcross||s<r.pos||i>n.pos?null:new n2(r.pos,n.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,r){if(typeof r.from!="number"||typeof r.to!="number"||typeof r.gapFrom!="number"||typeof r.gapTo!="number"||typeof r.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n2(r.from,r.to,r.gapFrom,r.gapTo,vt.fromJSON(e,r.slice),r.insert,!!r.structure)}};Xi.jsonID("replaceAround",Qa);function Qz(t,e,r){let n=t.resolve(e),s=r-e,i=n.depth;for(;s>0&&i>0&&n.indexAfter(i)==n.node(i).childCount;)i--,s--;if(s>0){let a=n.node(i).maybeChild(n.indexAfter(i));for(;s>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,s--}}return!1}function GTt(t,e,r,n){let s=[],i=[],a,o;t.doc.nodesBetween(e,r,(c,u,d)=>{if(!c.isInline)return;let h=c.marks;if(!n.isInSet(h)&&d.type.allowsMarkType(n.type)){let f=Math.max(u,e),p=Math.min(u+c.nodeSize,r),m=n.addToSet(h);for(let g=0;g<h.length;g++)h[g].isInSet(m)||(a&&a.to==f&&a.mark.eq(h[g])?a.to=p:s.push(a=new m1(f,p,h[g])));o&&o.to==f?o.to=p:i.push(o=new N7(f,p,n))}}),s.forEach(c=>t.step(c)),i.forEach(c=>t.step(c))}function KTt(t,e,r,n){let s=[],i=0;t.doc.nodesBetween(e,r,(a,o)=>{if(!a.isInline)return;i++;let c=null;if(n instanceof dD){let u=a.marks,d;for(;d=n.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else n?n.isInSet(a.marks)&&(c=[n]):c=a.marks;if(c&&c.length){let u=Math.min(o+a.nodeSize,r);for(let d=0;d<c.length;d++){let h=c[d],f;for(let p=0;p<s.length;p++){let m=s[p];m.step==i-1&&h.eq(s[p].style)&&(f=m)}f?(f.to=u,f.step=i):s.push({style:h,from:Math.max(o,e),to:u,step:i})}}}),s.forEach(a=>t.step(new m1(a.from,a.to,a.style)))}function A7(t,e,r,n=r.contentMatch,s=!0){let i=t.doc.nodeAt(e),a=[],o=e+1;for(let c=0;c<i.childCount;c++){let u=i.child(c),d=o+u.nodeSize,h=n.matchType(u.type);if(!h)a.push(new Cl(o,d,vt.empty));else{n=h;for(let f=0;f<u.marks.length;f++)r.allowsMarkType(u.marks[f].type)||t.step(new m1(o,d,u.marks[f]));if(s&&u.isText&&r.whitespace!="pre"){let f,p=/\r?\n|\r/g,m;for(;f=p.exec(u.text);)m||(m=new vt(Qe.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0)),a.push(new Cl(o+f.index,o+f.index+f[0].length,m))}}o=d}if(!n.validEnd){let c=n.fillBefore(Qe.empty,!0);t.replace(o,o,new vt(c,0,0))}for(let c=a.length-1;c>=0;c--)t.step(a[c])}function YTt(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function g1(t){let r=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,s=0,i=0;;--n){let a=t.$from.node(n),o=t.$from.index(n)+s,c=t.$to.indexAfter(n)-i;if(n<t.depth&&a.canReplace(o,c,r))return n;if(n==0||a.type.spec.isolating||!YTt(a,o,c))break;o&&(s=1),c<a.childCount&&(i=1)}return null}function XTt(t,e,r){let{$from:n,$to:s,depth:i}=e,a=n.before(i+1),o=s.after(i+1),c=a,u=o,d=Qe.empty,h=0;for(let m=i,g=!1;m>r;m--)g||n.index(m)>0?(g=!0,d=Qe.from(n.node(m).copy(d)),h++):c--;let f=Qe.empty,p=0;for(let m=i,g=!1;m>r;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=Qe.from(s.node(m).copy(f)),p++):u++;t.step(new Qa(c,u,a,o,new vt(d.append(f),h,p),d.size-h,!0))}function C7(t,e,r=null,n=t){let s=JTt(t,e),i=s&&QTt(n,e);return i?s.map(Ise).concat({type:e,attrs:r}).concat(i.map(Ise)):null}function Ise(t){return{type:t,attrs:null}}function JTt(t,e){let{parent:r,startIndex:n,endIndex:s}=t,i=r.contentMatchAt(n).findWrapping(e);if(!i)return null;let a=i.length?i[0]:e;return r.canReplaceWith(n,s,a)?i:null}function QTt(t,e){let{parent:r,startIndex:n,endIndex:s}=t,i=r.child(n),a=e.contentMatch.findWrapping(i.type);if(!a)return null;let c=(a.length?a[a.length-1]:e).contentMatch;for(let u=n;c&&u<s;u++)c=c.matchType(r.child(u).type);return!c||!c.validEnd?null:a}function ZTt(t,e,r){let n=Qe.empty;for(let a=r.length-1;a>=0;a--){if(n.size){let o=r[a].type.contentMatch.matchFragment(n);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=Qe.from(r[a].type.create(r[a].attrs,n))}let s=e.start,i=e.end;t.step(new Qa(s,i,s,i,new vt(n,0,0),r.length,!0))}function e2t(t,e,r,n,s){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,r,(a,o)=>{let c=typeof s=="function"?s(a):s;if(a.isTextblock&&!a.hasMarkup(n,c)&&t2t(t.doc,t.mapping.slice(i).map(o),n)){let u=null;if(n.schema.linebreakReplacement){let p=n.whitespace=="pre",m=!!n.contentMatch.matchType(n.schema.linebreakReplacement);p&&!m?u=!1:!p&&m&&(u=!0)}u===!1&&Y_e(t,a,o,i),A7(t,t.mapping.slice(i).map(o,1),n,void 0,u===null);let d=t.mapping.slice(i),h=d.map(o,1),f=d.map(o+a.nodeSize,1);return t.step(new Qa(h,f,h+1,f-1,new vt(Qe.from(n.create(c,null,a.marks)),0,0),1,!0)),u===!0&&K_e(t,a,o,i),!1}})}function K_e(t,e,r,n){e.forEach((s,i)=>{if(s.isText){let a,o=/\r?\n|\r/g;for(;a=o.exec(s.text);){let c=t.mapping.slice(n).map(r+1+i+a.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Y_e(t,e,r,n){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let a=t.mapping.slice(n).map(r+1+i);t.replaceWith(a,a+1,e.type.schema.text(`
`))}})}function t2t(t,e,r){let n=t.resolve(e),s=n.index();return n.parent.canReplaceWith(s,s+1,r)}function r2t(t,e,r,n,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");r||(r=i.type);let a=r.create(n,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,a);if(!r.validContent(i.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new Qa(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new vt(Qe.from(a),0,0),1,!0))}function pb(t,e,r=1,n){let s=t.resolve(e),i=s.depth-r,a=n&&n[n.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!a.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let u=s.depth-1,d=r-2;u>i;u--,d--){let h=s.node(u),f=s.index(u);if(h.type.spec.isolating)return!1;let p=h.content.cutByIndex(f,h.childCount),m=n&&n[d+1];m&&(p=p.replaceChild(0,m.type.create(m.attrs)));let g=n&&n[d]||h;if(!h.canReplace(f+1,h.childCount)||!g.type.validContent(p))return!1}let o=s.indexAfter(i),c=n&&n[0];return s.node(i).canReplaceWith(o,o,c?c.type:s.node(i+1).type)}function n2t(t,e,r=1,n){let s=t.doc.resolve(e),i=Qe.empty,a=Qe.empty;for(let o=s.depth,c=s.depth-r,u=r-1;o>c;o--,u--){i=Qe.from(s.node(o).copy(i));let d=n&&n[u];a=Qe.from(d?d.type.create(d.attrs,a):s.node(o).copy(a))}t.step(new Cl(e,e,new vt(i.append(a),r,r),!0))}function vm(t,e){let r=t.resolve(e),n=r.index();return X_e(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function s2t(t,e){e.content.size||t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:n}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),a=i.type==n?t.type.schema.nodes.text:i.type;if(r=r.matchType(a),!r||!t.type.allowsMarks(i.marks))return!1}return r.validEnd}function X_e(t,e){return!!(t&&e&&!t.isLeaf&&s2t(t,e))}function hD(t,e,r=-1){let n=t.resolve(e);for(let s=n.depth;;s--){let i,a,o=n.index(s);if(s==n.depth?(i=n.nodeBefore,a=n.nodeAfter):r>0?(i=n.node(s+1),o++,a=n.node(s).maybeChild(o)):(i=n.node(s).maybeChild(o-1),a=n.node(s+1)),i&&!i.isTextblock&&X_e(i,a)&&n.node(s).canReplace(o,o+1))return e;if(s==0)break;e=r<0?n.before(s):n.after(s)}}function i2t(t,e,r){let n=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-r),a=i.node().type;if(s&&a.inlineContent){let d=a.whitespace=="pre",h=!!a.contentMatch.matchType(s);d&&!h?n=!1:!d&&h&&(n=!0)}let o=t.steps.length;if(n===!1){let d=t.doc.resolve(e+r);Y_e(t,d.node(),d.before(),o)}a.inlineContent&&A7(t,e+r-1,a,i.node().contentMatchAt(i.index()),n==null);let c=t.mapping.slice(o),u=c.map(e-r);if(t.step(new Cl(u,c.map(e+r,-1),vt.empty,!0)),n===!0){let d=t.doc.resolve(u);K_e(t,d.node(),d.before(),t.steps.length)}return t}function a2t(t,e,r){let n=t.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),r))return e;if(n.parentOffset==0)for(let s=n.depth-1;s>=0;s--){let i=n.index(s);if(n.node(s).canReplaceWith(i,i,r))return n.before(s+1);if(i>0)return null}if(n.parentOffset==n.parent.content.size)for(let s=n.depth-1;s>=0;s--){let i=n.indexAfter(s);if(n.node(s).canReplaceWith(i,i,r))return n.after(s+1);if(i<n.node(s).childCount)return null}return null}function J_e(t,e,r){let n=t.resolve(e);if(!r.content.size)return e;let s=r.content;for(let i=0;i<r.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(r.openStart==0&&r.size?2:1);i++)for(let a=n.depth;a>=0;a--){let o=a==n.depth?0:n.pos<=(n.start(a+1)+n.end(a+1))/2?-1:1,c=n.index(a)+(o>0?1:0),u=n.node(a),d=!1;if(i==1)d=u.canReplace(c,c,s);else{let h=u.contentMatchAt(c).findWrapping(s.firstChild.type);d=h&&u.canReplaceWith(c,c,h[0])}if(d)return o==0?n.pos:o<0?n.before(a+1):n.after(a+1)}return null}function fD(t,e,r=e,n=vt.empty){if(e==r&&!n.size)return null;let s=t.resolve(e),i=t.resolve(r);return Q_e(s,i,n)?new Cl(e,r,n):new o2t(s,i,n).fit()}function Q_e(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class o2t{constructor(e,r,n){this.$from=e,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Qe.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=Qe.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,s=this.close(e<0?this.$to:n.doc.resolve(e));if(!s)return null;let i=this.placed,a=n.depth,o=s.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let c=new vt(i,a,o);return e>-1?new Qa(n.pos,e,this.$to.pos,this.$to.end(),c,r):c.size||n.pos!=this.$to.pos?new Cl(n.pos,s.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,s=this.unplaced.openEnd;n<e;n++){let i=r.firstChild;if(r.childCount>1&&(s=0),i.type.spec.isolating&&s<=n){e=n;break}r=i.content}for(let r=1;r<=2;r++)for(let n=r==1?e:this.unplaced.openStart;n>=0;n--){let s,i=null;n?(i=H3(this.unplaced.content,n-1).firstChild,s=i.content):s=this.unplaced.content;let a=s.firstChild;for(let o=this.depth;o>=0;o--){let{type:c,match:u}=this.frontier[o],d,h=null;if(r==1&&(a?u.matchType(a.type)||(h=u.fillBefore(Qe.from(a),!1)):i&&c.compatibleContent(i.type)))return{sliceDepth:n,frontierDepth:o,parent:i,inject:h};if(r==2&&a&&(d=u.findWrapping(a.type)))return{sliceDepth:n,frontierDepth:o,parent:i,wrap:d};if(i&&u.matchType(i.type))break}}}openMore(){let{content:e,openStart:r,openEnd:n}=this.unplaced,s=H3(e,r);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new vt(e,r+1,Math.max(n,s.size+r>=e.size-n?r+1:0)),!0)}dropNode(){let{content:e,openStart:r,openEnd:n}=this.unplaced,s=H3(e,r);if(s.childCount<=1&&r>0){let i=e.size-r<=r+s.size;this.unplaced=new vt(US(e,r-1,1),r-1,i?r-1:n)}else this.unplaced=new vt(US(e,r,1),r,n)}placeNodes({sliceDepth:e,frontierDepth:r,parent:n,inject:s,wrap:i}){for(;this.depth>r;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let a=this.unplaced,o=n?n.content:a.content,c=a.openStart-e,u=0,d=[],{match:h,type:f}=this.frontier[r];if(s){for(let g=0;g<s.childCount;g++)d.push(s.child(g));h=h.matchFragment(s)}let p=o.size+e-(a.content.size-a.openEnd);for(;u<o.childCount;){let g=o.child(u),x=h.matchType(g.type);if(!x)break;u++,(u>1||c==0||g.content.size)&&(h=x,d.push(Z_e(g.mark(f.allowedMarks(g.marks)),u==1?c:0,u==o.childCount?p:-1)))}let m=u==o.childCount;m||(p=-1),this.placed=HS(this.placed,r,Qe.from(d)),this.frontier[r].match=h,m&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,x=o;g<p;g++){let y=x.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),x=y.content}this.unplaced=m?e==0?vt.empty:new vt(US(a.content,e-1,1),e-1,p<0?a.openEnd:e-1):new vt(US(a.content,e,u),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],r;if(!e.type.isTextblock||!V3(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(r=this.findCloseLevel(this.$to))&&r.depth==this.depth)return-1;let{depth:n}=this.$to,s=this.$to.after(n);for(;n>1&&s==this.$to.end(--n);)++s;return s}findCloseLevel(e){e:for(let r=Math.min(this.depth,e.depth);r>=0;r--){let{match:n,type:s}=this.frontier[r],i=r<e.depth&&e.end(r+1)==e.pos+(e.depth-(r+1)),a=V3(e,r,s,n,i);if(a){for(let o=r-1;o>=0;o--){let{match:c,type:u}=this.frontier[o],d=V3(e,o,u,c,!0);if(!d||d.childCount)continue e}return{depth:r,fit:a,move:i?e.doc.resolve(e.after(r+1)):e}}}}close(e){let r=this.findCloseLevel(e);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=HS(this.placed,r.depth,r.fit)),e=r.move;for(let n=r.depth+1;n<=e.depth;n++){let s=e.node(n),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(n));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,r=null,n){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=HS(this.placed,this.depth,Qe.from(e.create(r,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Qe.empty,!0);r.childCount&&(this.placed=HS(this.placed,this.frontier.length,r))}}function US(t,e,r){return e==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(US(t.firstChild.content,e-1,r)))}function HS(t,e,r){return e==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(HS(t.lastChild.content,e-1,r)))}function H3(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function Z_e(t,e,r){if(e<=0)return t;let n=t.content;return e>1&&(n=n.replaceChild(0,Z_e(n.firstChild,e-1,n.childCount==1?r-1:0))),e>0&&(n=t.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(Qe.empty,!0)))),t.copy(n)}function V3(t,e,r,n,s){let i=t.node(e),a=s?t.indexAfter(e):t.index(e);if(a==i.childCount&&!r.compatibleContent(i.type))return null;let o=n.fillBefore(i.content,!0,a);return o&&!l2t(r,i.content,a)?o:null}function l2t(t,e,r){for(let n=r;n<e.childCount;n++)if(!t.allowsMarks(e.child(n).marks))return!0;return!1}function c2t(t){return t.spec.defining||t.spec.definingForContent}function u2t(t,e,r,n){if(!n.size)return t.deleteRange(e,r);let s=t.doc.resolve(e),i=t.doc.resolve(r);if(Q_e(s,i,n))return t.step(new Cl(e,r,n));let a=tje(s,i);a[a.length-1]==0&&a.pop();let o=-(s.depth+1);a.unshift(o);for(let f=s.depth,p=s.pos-1;f>0;f--,p--){let m=s.node(f).type.spec;if(m.defining||m.definingAsContext||m.isolating)break;a.indexOf(f)>-1?o=f:s.before(f)==p&&a.splice(1,0,-f)}let c=a.indexOf(o),u=[],d=n.openStart;for(let f=n.content,p=0;;p++){let m=f.firstChild;if(u.push(m),p==n.openStart)break;f=m.content}for(let f=d-1;f>=0;f--){let p=u[f],m=c2t(p.type);if(m&&!p.sameMarkup(s.node(Math.abs(o)-1)))d=f;else if(m||!p.type.isTextblock)break}for(let f=n.openStart;f>=0;f--){let p=(f+d+1)%(n.openStart+1),m=u[p];if(m)for(let g=0;g<a.length;g++){let x=a[(g+c)%a.length],y=!0;x<0&&(y=!1,x=-x);let v=s.node(x-1),b=s.index(x-1);if(v.canReplaceWith(b,b,m.type,m.marks))return t.replace(s.before(x),y?i.after(x):r,new vt(eje(n.content,0,n.openStart,p),p,n.openEnd))}}let h=t.steps.length;for(let f=a.length-1;f>=0&&(t.replace(e,r,n),!(t.steps.length>h));f--){let p=a[f];p<0||(e=s.before(p),r=i.after(p))}}function eje(t,e,r,n,s){if(e<r){let i=t.firstChild;t=t.replaceChild(0,i.copy(eje(i.content,e+1,r,n,i)))}if(e>n){let i=s.contentMatchAt(0),a=i.fillBefore(t).append(t);t=a.append(i.matchFragment(a).fillBefore(Qe.empty,!0))}return t}function d2t(t,e,r,n){if(!n.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let s=a2t(t.doc,e,n.type);s!=null&&(e=r=s)}t.replaceRange(e,r,new vt(Qe.from(n),0,0))}function h2t(t,e,r){let n=t.doc.resolve(e),s=t.doc.resolve(r);if(n.parent.isTextblock&&s.parent.isTextblock&&n.start()!=s.start()&&n.parentOffset==0&&s.parentOffset==0){let a=n.sharedDepth(r),o=!1;for(let c=n.depth;c>a;c--)n.node(c).type.spec.isolating&&(o=!0);for(let c=s.depth;c>a;c--)s.node(c).type.spec.isolating&&(o=!0);if(!o){for(let c=n.depth;c>0&&e==n.start(c);c--)e=n.before(c);for(let c=s.depth;c>0&&r==s.start(c);c--)r=s.before(c);n=t.doc.resolve(e),s=t.doc.resolve(r)}}let i=tje(n,s);for(let a=0;a<i.length;a++){let o=i[a],c=a==i.length-1;if(c&&o==0||n.node(o).type.contentMatch.validEnd)return t.delete(n.start(o),s.end(o));if(o>0&&(c||n.node(o-1).canReplace(n.index(o-1),s.indexAfter(o-1))))return t.delete(n.before(o),s.after(o))}for(let a=1;a<=n.depth&&a<=s.depth;a++)if(e-n.start(a)==n.depth-a&&r>n.end(a)&&s.end(a)-r!=s.depth-a&&n.start(a-1)==s.start(a-1)&&n.node(a-1).canReplace(n.index(a-1),s.index(a-1)))return t.delete(n.before(a),r);t.delete(e,r)}function tje(t,e){let r=[],n=Math.min(t.depth,e.depth);for(let s=n;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)&&r.push(s)}return r}let rje=class s2 extends Xi{constructor(e,r,n){super(),this.pos=e,this.attr=r,this.value=n}apply(e){let r=e.nodeAt(this.pos);if(!r)return pa.fail("No node at attribute step's position");let n=Object.create(null);for(let i in r.attrs)n[i]=r.attrs[i];n[this.attr]=this.value;let s=r.type.create(n,null,r.marks);return pa.fromReplace(e,this.pos,this.pos+1,new vt(Qe.from(s),0,r.isLeaf?0:1))}getMap(){return cx.empty}invert(e){return new s2(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let r=e.mapResult(this.pos,1);return r.deletedAfter?null:new s2(r.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,r){if(typeof r.pos!="number"||typeof r.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new s2(r.pos,r.attr,r.value)}};Xi.jsonID("attr",rje);let nje=class Zz extends Xi{constructor(e,r){super(),this.attr=e,this.value=r}apply(e){let r=Object.create(null);for(let s in e.attrs)r[s]=e.attrs[s];r[this.attr]=this.value;let n=e.type.create(r,e.content,e.marks);return pa.ok(n)}getMap(){return cx.empty}invert(e){return new Zz(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,r){if(typeof r.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Zz(r.attr,r.value)}};Xi.jsonID("docAttr",nje);let Nw=class extends Error{};Nw=function t(e){let r=Error.call(this,e);return r.__proto__=t.prototype,r};Nw.prototype=Object.create(Error.prototype);Nw.prototype.constructor=Nw;Nw.prototype.name="TransformError";class sje{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ak}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let r=this.maybeStep(e);if(r.failed)throw new Nw(r.failed);return this}maybeStep(e){let r=e.apply(this.doc);return r.failed||this.addStep(e,r.doc),r}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,r=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let s=this.mapping.maps[n];n&&(e=s.map(e,1),r=s.map(r,-1)),s.forEach((i,a,o,c)=>{e=Math.min(e,o),r=Math.max(r,c)})}return e==1e9?null:{from:e,to:r}}addStep(e,r){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=r}replace(e,r=e,n=vt.empty){let s=fD(this.doc,e,r,n);return s&&this.step(s),this}replaceWith(e,r,n){return this.replace(e,r,new vt(Qe.from(n),0,0))}delete(e,r){return this.replace(e,r,vt.empty)}insert(e,r){return this.replaceWith(e,e,r)}replaceRange(e,r,n){return u2t(this,e,r,n),this}replaceRangeWith(e,r,n){return d2t(this,e,r,n),this}deleteRange(e,r){return h2t(this,e,r),this}lift(e,r){return XTt(this,e,r),this}join(e,r=1){return i2t(this,e,r),this}wrap(e,r){return ZTt(this,e,r),this}setBlockType(e,r=e,n,s=null){return e2t(this,e,r,n,s),this}setNodeMarkup(e,r,n=null,s){return r2t(this,e,r,n,s),this}setNodeAttribute(e,r,n){return this.step(new rje(e,r,n)),this}setDocAttribute(e,r){return this.step(new nje(e,r)),this}addNodeMark(e,r){return this.step(new E7(e,r)),this}removeNodeMark(e,r){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(r instanceof Vr)r.isInSet(n.marks)&&this.step(new PO(e,r));else{let s=n.marks,i,a=[];for(;i=r.isInSet(s);)a.push(new PO(e,i)),s=i.removeFromSet(s);for(let o=a.length-1;o>=0;o--)this.step(a[o])}return this}split(e,r=1,n){return n2t(this,e,r,n),this}addMark(e,r,n){return GTt(this,e,r,n),this}removeMark(e,r,n){return KTt(this,e,r,n),this}clearIncompatible(e,r,n){return A7(this,e,r,n),this}}const W3=Object.create(null);let qt=class{constructor(e,r,n){this.$anchor=e,this.$head=r,this.ranges=n||[new f2t(e.min(r),e.max(r))]}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 r=0;r<e.length;r++)if(e[r].$from.pos!=e[r].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,r=vt.empty){let n=r.content.lastChild,s=null;for(let o=0;o<r.openEnd;o++)s=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:c,$to:u}=a[o],d=e.mapping.slice(i);e.replaceRange(d.map(c.pos),d.map(u.pos),o?vt.empty:r),o==0&&Dse(e,i,(n?n.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,r){let n=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:a,$to:o}=s[i],c=e.mapping.slice(n),u=c.map(a.pos),d=c.map(o.pos);i?e.deleteRange(u,d):(e.replaceRangeWith(u,d,r),Dse(e,n,r.isInline?-1:1))}}static findFrom(e,r,n=!1){let s=e.parent.inlineContent?new Bt(e):pv(e.node(0),e.parent,e.pos,e.index(),r,n);if(s)return s;for(let i=e.depth-1;i>=0;i--){let a=r<0?pv(e.node(0),e.node(i),e.before(i+1),e.index(i),r,n):pv(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,r,n);if(a)return a}return null}static near(e,r=1){return this.findFrom(e,r)||this.findFrom(e,-r)||new Pp(e.node(0))}static atStart(e){return pv(e,e,0,0,1)||new Pp(e)}static atEnd(e){return pv(e,e,e.content.size,e.childCount,-1)||new Pp(e)}static fromJSON(e,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=W3[r.type];if(!n)throw new RangeError(`No selection type ${r.type} defined`);return n.fromJSON(e,r)}static jsonID(e,r){if(e in W3)throw new RangeError("Duplicate use of selection JSON ID "+e);return W3[e]=r,r.prototype.jsonID=e,r}getBookmark(){return Bt.between(this.$anchor,this.$head).getBookmark()}};qt.prototype.visible=!0;let f2t=class{constructor(e,r){this.$from=e,this.$to=r}},Rse=!1;function Mse(t){!Rse&&!t.parent.inlineContent&&(Rse=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}let Bt=class VS extends qt{constructor(e,r=e){Mse(e),Mse(r),super(e,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,r){let n=e.resolve(r.map(this.head));if(!n.parent.inlineContent)return qt.near(n);let s=e.resolve(r.map(this.anchor));return new VS(s.parent.inlineContent?s:n,n)}replace(e,r=vt.empty){if(super.replace(e,r),r==vt.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof VS&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ije(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new VS(e.resolve(r.anchor),e.resolve(r.head))}static create(e,r,n=r){let s=e.resolve(r);return new this(s,n==r?s:e.resolve(n))}static between(e,r,n){let s=e.pos-r.pos;if((!n||s)&&(n=s>=0?1:-1),!r.parent.inlineContent){let i=qt.findFrom(r,n,!0)||qt.findFrom(r,-n,!0);if(i)r=i.$head;else return qt.near(r,n)}return e.parent.inlineContent||(s==0?e=r:(e=(qt.findFrom(e,-n,!0)||qt.findFrom(e,n,!0)).$anchor,e.pos<r.pos!=s<0&&(e=r))),new VS(e,r)}};qt.jsonID("text",Bt);let ije=class aje{constructor(e,r){this.anchor=e,this.head=r}map(e){return new aje(e.map(this.anchor),e.map(this.head))}resolve(e){return Bt.between(e.resolve(this.anchor),e.resolve(this.head))}},Ot=class WS extends qt{constructor(e){let r=e.nodeAfter,n=e.node(0).resolve(e.pos+r.nodeSize);super(e,n),this.node=r}map(e,r){let{deleted:n,pos:s}=r.mapResult(this.anchor),i=e.resolve(s);return n?qt.near(i):new WS(i)}content(){return new vt(Qe.from(this.node),0,0)}eq(e){return e instanceof WS&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new p2t(this.anchor)}static fromJSON(e,r){if(typeof r.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new WS(e.resolve(r.anchor))}static create(e,r){return new WS(e.resolve(r))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Ot.prototype.visible=!1;qt.jsonID("node",Ot);let p2t=class oje{constructor(e){this.anchor=e}map(e){let{deleted:r,pos:n}=e.mapResult(this.anchor);return r?new ije(n,n):new oje(n)}resolve(e){let r=e.resolve(this.anchor),n=r.nodeAfter;return n&&Ot.isSelectable(n)?new Ot(r):qt.near(r)}},Pp=class i2 extends qt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,r=vt.empty){if(r==vt.empty){e.delete(0,e.doc.content.size);let n=qt.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,r)}toJSON(){return{type:"all"}}static fromJSON(e){return new i2(e)}map(e){return new i2(e)}eq(e){return e instanceof i2}getBookmark(){return m2t}};qt.jsonID("all",Pp);const m2t={map(){return this},resolve(t){return new Pp(t)}};function pv(t,e,r,n,s,i=!1){if(e.inlineContent)return Bt.create(t,r);for(let a=n-(s>0?0:1);s>0?a<e.childCount:a>=0;a+=s){let o=e.child(a);if(o.isAtom){if(!i&&Ot.isSelectable(o))return Ot.create(t,r-(s<0?o.nodeSize:0))}else{let c=pv(t,o,r+s,s<0?o.childCount:0,s,i);if(c)return c}r+=o.nodeSize*s}return null}function Dse(t,e,r){let n=t.steps.length-1;if(n<e)return;let s=t.steps[n];if(!(s instanceof Cl||s instanceof Qa))return;let i=t.mapping.maps[n],a;i.forEach((o,c,u,d)=>{a==null&&(a=d)}),t.setSelection(qt.near(t.doc.resolve(a),r))}const Lse=1,TC=2,Fse=4;class g2t extends sje{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|Lse)&~TC,this.storedMarks=null,this}get selectionSet(){return(this.updated&Lse)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=TC,this}ensureMarks(e){return Vr.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&TC)>0}addStep(e,r){super.addStep(e,r),this.updated=this.updated&~TC,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,r=!0){let n=this.selection;return r&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Vr.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,r,n){let s=this.doc.type.schema;if(r==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(n==null&&(n=r),!e)return this.deleteRange(r,n);let i=this.storedMarks;if(!i){let a=this.doc.resolve(r);i=n==r?a.marks():a.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(r,n,s.text(e,i)),!this.selection.empty&&this.selection.to==r+e.length&&this.setSelection(qt.near(this.selection.$to)),this}}setMeta(e,r){return this.meta[typeof e=="string"?e:e.key]=r,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|=Fse,this}get scrolledIntoView(){return(this.updated&Fse)>0}}function $se(t,e){return!e||!t?t:t.bind(e)}let qS=class{constructor(e,r,n){this.name=e,this.init=$se(r.init,n),this.apply=$se(r.apply,n)}};const y2t=[new qS("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new qS("selection",{init(t,e){return t.selection||qt.atStart(e.doc)},apply(t){return t.selection}}),new qS("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,n){return n.selection.$cursor?t.storedMarks:null}}),new qS("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class q3{constructor(e,r){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=y2t.slice(),r&&r.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new qS(n.key,n.spec.state,n))})}}class Hv{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,r=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=r){let s=this.config.plugins[n];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 r=[e],n=this.applyInner(e),s=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let c=s?s[a].n:0,u=s?s[a].state:this,d=c<r.length&&o.spec.appendTransaction.call(o,c?r.slice(c):r,u,n);if(d&&n.filterTransaction(d,a)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let h=0;h<this.config.plugins.length;h++)s.push(h<a?{state:n,n:r.length}:{state:this,n:0})}r.push(d),n=n.applyInner(d),i=!0}s&&(s[a]={state:n,n:r.length})}}if(!i)return{state:n,transactions:r}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let r=new Hv(this.config),n=this.config.fields;for(let s=0;s<n.length;s++){let i=n[s];r[i.name]=i.apply(e,this[i.name],this,r)}return r}get tr(){return new g2t(this)}static create(e){let r=new q3(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Hv(r);for(let s=0;s<r.fields.length;s++)n[r.fields[s].name]=r.fields[s].init(e,n);return n}reconfigure(e){let r=new q3(this.schema,e.plugins),n=r.fields,s=new Hv(r);for(let i=0;i<n.length;i++){let a=n[i].name;s[a]=this.hasOwnProperty(a)?this[a]:n[i].init(e,s)}return s}toJSON(e){let r={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(r.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[n],i=s.spec.state;i&&i.toJSON&&(r[n]=i.toJSON.call(s,this[s.key]))}return r}static fromJSON(e,r,n){if(!r)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new q3(e.schema,e.plugins),i=new Hv(s);return s.fields.forEach(a=>{if(a.name=="doc")i.doc=Cp.fromJSON(e.schema,r.doc);else if(a.name=="selection")i.selection=qt.fromJSON(i.doc,r.selection);else if(a.name=="storedMarks")r.storedMarks&&(i.storedMarks=r.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let o in n){let c=n[o],u=c.spec.state;if(c.key==a.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(r,o)){i[a.name]=u.fromJSON.call(c,e,r[o],i);return}}i[a.name]=a.init(e,i)}}),i}}function lje(t,e,r){for(let n in t){let s=t[n];s instanceof Function?s=s.bind(e):n=="handleDOMEvents"&&(s=lje(s,e,{})),r[n]=s}return r}class fn{constructor(e){this.spec=e,this.props={},e.props&&lje(e.props,this,this.props),this.key=e.key?e.key.key:cje("plugin")}getState(e){return e[this.key]}}const G3=Object.create(null);function cje(t){return t in G3?t+"$"+ ++G3[t]:(G3[t]=0,t+"$")}class ys{constructor(e="key"){this.key=cje(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}function uje(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const x2t=(t,e,r)=>{let n=uje(t,r);if(!n)return!1;let s=T7(n);if(!s){let a=n.blockRange(),o=a&&g1(a);return o==null?!1:(e&&e(t.tr.lift(a,o).scrollIntoView()),!0)}let i=s.nodeBefore;if(pje(t,s,e,-1))return!0;if(n.parent.content.size==0&&(Ew(i,"end")||Ot.isSelectable(i)))for(let a=n.depth;;a--){let o=fD(t.doc,n.before(a),n.after(a),vt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(Ew(i,"end")?qt.findFrom(c.doc.resolve(c.mapping.map(s.pos,-1)),-1):Ot.create(c.doc,s.pos-i.nodeSize)),e(c.scrollIntoView())}return!0}if(a==1||n.node(a-1).childCount>1)break}return i.isAtom&&s.depth==n.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},v2t=(t,e,r)=>{let n=uje(t,r);if(!n)return!1;let s=T7(n);return s?dje(t,s,e):!1},b2t=(t,e,r)=>{let n=hje(t,r);if(!n)return!1;let s=P7(n);return s?dje(t,s,e):!1};function dje(t,e,r){let n=e.nodeBefore,s=n,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let a=e.nodeAfter,o=a,c=e.pos+1;for(;!o.isTextblock;c++){if(o.type.spec.isolating)return!1;let d=o.firstChild;if(!d)return!1;o=d}let u=fD(t.doc,i,c,vt.empty);if(!u||u.from!=i||u instanceof Cl&&u.slice.size>=c-i)return!1;if(r){let d=t.tr.step(u);d.setSelection(Bt.create(d.doc,i)),r(d.scrollIntoView())}return!0}function Ew(t,e,r=!1){for(let n=t;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(r&&n.childCount!=1)return!1}return!1}const w2t=(t,e,r)=>{let{$head:n,empty:s}=t.selection,i=n;if(!s)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):n.parentOffset>0)return!1;i=T7(n)}let a=i&&i.nodeBefore;return!a||!Ot.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Ot.create(t.doc,i.pos-a.nodeSize)).scrollIntoView()),!0)};function T7(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 hje(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)?null:r}const S2t=(t,e,r)=>{let n=hje(t,r);if(!n)return!1;let s=P7(n);if(!s)return!1;let i=s.nodeAfter;if(pje(t,s,e,1))return!0;if(n.parent.content.size==0&&(Ew(i,"start")||Ot.isSelectable(i))){let a=fD(t.doc,n.before(),n.after(),vt.empty);if(a&&a.slice.size<a.to-a.from){if(e){let o=t.tr.step(a);o.setSelection(Ew(i,"start")?qt.findFrom(o.doc.resolve(o.mapping.map(s.pos)),1):Ot.create(o.doc,o.mapping.map(s.pos))),e(o.scrollIntoView())}return!0}}return i.isAtom&&s.depth==n.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},_2t=(t,e,r)=>{let{$head:n,empty:s}=t.selection,i=n;if(!s)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)return!1;i=P7(n)}let a=i&&i.nodeAfter;return!a||!Ot.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Ot.create(t.doc,i.pos)).scrollIntoView()),!0)};function P7(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let r=t.node(e);if(t.index(e)+1<r.childCount)return t.doc.resolve(t.after(e+1));if(r.type.spec.isolating)break}return null}const j2t=(t,e)=>{let r=t.selection,n=r instanceof Ot,s;if(n){if(r.node.isTextblock||!vm(t.doc,r.from))return!1;s=r.from}else if(s=hD(t.doc,r.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);n&&i.setSelection(Ot.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},k2t=(t,e)=>{let r=t.selection,n;if(r instanceof Ot){if(r.node.isTextblock||!vm(t.doc,r.to))return!1;n=r.to}else if(n=hD(t.doc,r.to,1),n==null)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0},N2t=(t,e)=>{let{$from:r,$to:n}=t.selection,s=r.blockRange(n),i=s&&g1(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},E2t=(t,e)=>{let{$head:r,$anchor:n}=t.selection;return!r.parent.type.spec.code||!r.sameParent(n)?!1:(e&&e(t.tr.insertText(`
`).scrollIntoView()),!0)};function fje(t){for(let e=0;e<t.edgeCount;e++){let{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs())return r}return null}const A2t=(t,e)=>{let{$head:r,$anchor:n}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(n))return!1;let s=r.node(-1),i=r.indexAfter(-1),a=fje(s.contentMatchAt(i));if(!a||!s.canReplaceWith(i,i,a))return!1;if(e){let o=r.after(),c=t.tr.replaceWith(o,o,a.createAndFill());c.setSelection(qt.near(c.doc.resolve(o),1)),e(c.scrollIntoView())}return!0},C2t=(t,e)=>{let r=t.selection,{$from:n,$to:s}=r;if(r instanceof Pp||n.parent.inlineContent||s.parent.inlineContent)return!1;let i=fje(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let a=(!n.parentOffset&&s.index()<s.parent.childCount?n:s).pos,o=t.tr.insert(a,i.createAndFill());o.setSelection(Bt.create(o.doc,a+1)),e(o.scrollIntoView())}return!0},T2t=(t,e)=>{let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){let i=r.before();if(pb(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let n=r.blockRange(),s=n&&g1(n);return s==null?!1:(e&&e(t.tr.lift(n,s).scrollIntoView()),!0)},P2t=(t,e)=>{let{$from:r,to:n}=t.selection,s,i=r.sharedDepth(n);return i==0?!1:(s=r.before(i),e&&e(t.tr.setSelection(Ot.create(t.doc,s))),!0)};function O2t(t,e,r){let n=e.nodeBefore,s=e.nodeAfter,i=e.index();return!n||!s||!n.type.compatibleContent(s.type)?!1:!n.content.size&&e.parent.canReplace(i-1,i)?(r&&r(t.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||vm(t.doc,e.pos))?!1:(r&&r(t.tr.join(e.pos).scrollIntoView()),!0)}function pje(t,e,r,n){let s=e.nodeBefore,i=e.nodeAfter,a,o,c=s.type.spec.isolating||i.type.spec.isolating;if(!c&&O2t(t,e,r))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(a=(o=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&o.matchType(a[0]||i.type).validEnd){if(r){let p=e.pos+i.nodeSize,m=Qe.empty;for(let y=a.length-1;y>=0;y--)m=Qe.from(a[y].create(null,m));m=Qe.from(s.copy(m));let g=t.tr.step(new Qa(e.pos-1,p,e.pos,p,new vt(m,1,0),a.length,!0)),x=g.doc.resolve(p+2*a.length);x.nodeAfter&&x.nodeAfter.type==s.type&&vm(g.doc,x.pos)&&g.join(x.pos),r(g.scrollIntoView())}return!0}let d=i.type.spec.isolating||n>0&&c?null:qt.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),f=h&&g1(h);if(f!=null&&f>=e.depth)return r&&r(t.tr.lift(h,f).scrollIntoView()),!0;if(u&&Ew(i,"start",!0)&&Ew(s,"end")){let p=s,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let g=i,x=1;for(;!g.isTextblock;g=g.firstChild)x++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(r){let y=Qe.empty;for(let b=m.length-1;b>=0;b--)y=Qe.from(m[b].copy(y));let v=t.tr.step(new Qa(e.pos-m.length,e.pos+i.nodeSize,e.pos+x,e.pos+i.nodeSize-x,new vt(y,m.length,0),0,!0));r(v.scrollIntoView())}return!0}}return!1}function mje(t){return function(e,r){let n=e.selection,s=t<0?n.$from:n.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(r&&r(e.tr.setSelection(Bt.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const I2t=mje(-1),R2t=mje(1);function M2t(t,e=null){return function(r,n){let{$from:s,$to:i}=r.selection,a=s.blockRange(i),o=a&&C7(a,t,e);return o?(n&&n(r.tr.wrap(a,o).scrollIntoView()),!0):!1}}function Bse(t,e=null){return function(r,n){let s=!1;for(let i=0;i<r.selection.ranges.length&&!s;i++){let{$from:{pos:a},$to:{pos:o}}=r.selection.ranges[i];r.doc.nodesBetween(a,o,(c,u)=>{if(s)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)s=!0;else{let d=r.doc.resolve(u),h=d.index();s=d.parent.canReplaceWith(h,h+1,t)}})}if(!s)return!1;if(n){let i=r.tr;for(let a=0;a<r.selection.ranges.length;a++){let{$from:{pos:o},$to:{pos:c}}=r.selection.ranges[a];i.setBlockType(o,c,t,e)}n(i.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function D2t(t,e=null){return function(r,n){let{$from:s,$to:i}=r.selection,a=s.blockRange(i);if(!a)return!1;let o=n?r.tr:null;return L2t(o,a,t,e)?(n&&n(o.scrollIntoView()),!0):!1}}function L2t(t,e,r,n=null){let s=!1,i=e,a=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(r)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=a.resolve(e.start-2);i=new CO(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new CO(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let o=C7(i,r,n,e);return o?(t&&F2t(t,e,o,s,r),!0):!1}function F2t(t,e,r,n,s){let i=Qe.empty;for(let d=r.length-1;d>=0;d--)i=Qe.from(r[d].type.create(r[d].attrs,i));t.step(new Qa(e.start-(n?2:0),e.end,e.start,e.end,new vt(i,0,0),r.length,!0));let a=0;for(let d=0;d<r.length;d++)r[d].type==s&&(a=d+1);let o=r.length-a,c=e.start+r.length-(n?2:0),u=e.parent;for(let d=e.startIndex,h=e.endIndex,f=!0;d<h;d++,f=!1)!f&&pb(t.doc,c,o)&&(t.split(c,o),c+=2*o),c+=u.child(d).nodeSize;return t}function $2t(t){return function(e,r){let{$from:n,$to:s}=e.selection,i=n.blockRange(s,a=>a.childCount>0&&a.firstChild.type==t);return i?r?n.node(i.depth-1).type==t?B2t(e,r,t,i):z2t(e,r,i):!0:!1}}function B2t(t,e,r,n){let s=t.tr,i=n.end,a=n.$to.end(n.depth);i<a&&(s.step(new Qa(i-1,a,i,a,new vt(Qe.from(r.create(null,n.parent.copy())),1,0),1,!0)),n=new CO(s.doc.resolve(n.$from.pos),s.doc.resolve(a),n.depth));const o=g1(n);if(o==null)return!1;s.lift(n,o);let c=s.doc.resolve(s.mapping.map(i,-1)-1);return vm(s.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&s.join(c.pos),e(s.scrollIntoView()),!0}function z2t(t,e,r){let n=t.tr,s=r.parent;for(let p=r.end,m=r.endIndex-1,g=r.startIndex;m>g;m--)p-=s.child(m).nodeSize,n.delete(p-1,p+1);let i=n.doc.resolve(r.start),a=i.nodeAfter;if(n.mapping.map(r.end)!=r.start+i.nodeAfter.nodeSize)return!1;let o=r.startIndex==0,c=r.endIndex==s.childCount,u=i.node(-1),d=i.index(-1);if(!u.canReplace(d+(o?0:1),d+1,a.content.append(c?Qe.empty:Qe.from(s))))return!1;let h=i.pos,f=h+a.nodeSize;return n.step(new Qa(h-(o?1:0),f+(c?1:0),h+1,f-1,new vt((o?Qe.empty:Qe.from(s.copy(Qe.empty))).append(c?Qe.empty:Qe.from(s.copy(Qe.empty))),o?0:1,c?0:1),o?0:1)),e(n.scrollIntoView()),!0}function U2t(t){return function(e,r){let{$from:n,$to:s}=e.selection,i=n.blockRange(s,u=>u.childCount>0&&u.firstChild.type==t);if(!i)return!1;let a=i.startIndex;if(a==0)return!1;let o=i.parent,c=o.child(a-1);if(c.type!=t)return!1;if(r){let u=c.lastChild&&c.lastChild.type==o.type,d=Qe.from(u?t.create():null),h=new vt(Qe.from(t.create(null,Qe.from(o.type.create(null,d)))),u?3:1,0),f=i.start,p=i.end;r(e.tr.step(new Qa(f-(u?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0}}const pi=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Aw=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let eU=null;const od=function(t,e,r){let n=eU||(eU=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,e||0),n},H2t=function(){eU=null},ux=function(t,e,r,n){return r&&(zse(t,e,r,n,-1)||zse(t,e,r,n,1))},V2t=/^(img|br|input|textarea|hr)$/i;function zse(t,e,r,n,s){for(var i;;){if(t==r&&e==n)return!0;if(e==(s<0?0:cl(t))){let a=t.parentNode;if(!a||a.nodeType!=1||KE(t)||V2t.test(t.nodeName)||t.contentEditable=="false")return!1;e=pi(t)+(s<0?0:1),t=a}else if(t.nodeType==1){let a=t.childNodes[e+(s<0?-1:0)];if(a.nodeType==1&&a.contentEditable=="false")if(!((i=a.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=a,e=s<0?cl(t):0}else return!1}}function cl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function W2t(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=cl(t)}else if(t.parentNode&&!KE(t))e=pi(t),t=t.parentNode;else return null}}function q2t(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&&!KE(t))e=pi(t)+1,t=t.parentNode;else return null}}function G2t(t,e,r){for(let n=e==0,s=e==cl(t);n||s;){if(t==r)return!0;let i=pi(t);if(t=t.parentNode,!t)return!1;n=n&&i==0,s=s&&i==cl(t)}}function KE(t){let e;for(let r=t;r&&!(e=r.pmViewDesc);r=r.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const pD=function(t){return t.focusNode&&ux(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function qm(t,e){let r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=t,r.key=r.code=e,r}function K2t(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Y2t(t,e,r){if(t.caretPositionFromPoint)try{let n=t.caretPositionFromPoint(e,r);if(n)return{node:n.offsetNode,offset:Math.min(cl(n.offsetNode),n.offset)}}catch{}if(t.caretRangeFromPoint){let n=t.caretRangeFromPoint(e,r);if(n)return{node:n.startContainer,offset:Math.min(cl(n.startContainer),n.startOffset)}}}const Pu=typeof navigator<"u"?navigator:null,Use=typeof document<"u"?document:null,bm=Pu&&Pu.userAgent||"",tU=/Edge\/(\d+)/.exec(bm),gje=/MSIE \d/.exec(bm),rU=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bm),Ya=!!(gje||rU||tU),Op=gje?document.documentMode:rU?+rU[1]:tU?+tU[1]:0,wl=!Ya&&/gecko\/(\d+)/i.test(bm);wl&&+(/Firefox\/(\d+)/.exec(bm)||[0,0])[1];const nU=!Ya&&/Chrome\/(\d+)/.exec(bm),Ks=!!nU,yje=nU?+nU[1]:0,Ki=!Ya&&!!Pu&&/Apple Computer/.test(Pu.vendor),Cw=Ki&&(/Mobile\/\w+/.test(bm)||!!Pu&&Pu.maxTouchPoints>2),nl=Cw||(Pu?/Mac/.test(Pu.platform):!1),xje=Pu?/Win/.test(Pu.platform):!1,Jd=/Android \d/.test(bm),YE=!!Use&&"webkitFontSmoothing"in Use.documentElement.style,X2t=YE?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function J2t(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 Gu(t,e){return typeof t=="number"?t:t[e]}function Q2t(t){let e=t.getBoundingClientRect(),r=e.width/t.offsetWidth||1,n=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*r,top:e.top,bottom:e.top+t.clientHeight*n}}function Hse(t,e,r){let n=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let a=r||t.dom;a;){if(a.nodeType!=1){a=Aw(a);continue}let o=a,c=o==i.body,u=c?J2t(i):Q2t(o),d=0,h=0;if(e.top<u.top+Gu(n,"top")?h=-(u.top-e.top+Gu(s,"top")):e.bottom>u.bottom-Gu(n,"bottom")&&(h=e.bottom-e.top>u.bottom-u.top?e.top+Gu(s,"top")-u.top:e.bottom-u.bottom+Gu(s,"bottom")),e.left<u.left+Gu(n,"left")?d=-(u.left-e.left+Gu(s,"left")):e.right>u.right-Gu(n,"right")&&(d=e.right-u.right+Gu(s,"right")),d||h)if(c)i.defaultView.scrollBy(d,h);else{let p=o.scrollLeft,m=o.scrollTop;h&&(o.scrollTop+=h),d&&(o.scrollLeft+=d);let g=o.scrollLeft-p,x=o.scrollTop-m;e={left:e.left-g,top:e.top-x,right:e.right-g,bottom:e.bottom-x}}let f=c?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(f))break;a=f=="absolute"?a.offsetParent:Aw(a)}}function Z2t(t){let e=t.dom.getBoundingClientRect(),r=Math.max(0,e.top),n,s;for(let i=(e.left+e.right)/2,a=r+1;a<Math.min(innerHeight,e.bottom);a+=5){let o=t.root.elementFromPoint(i,a);if(!o||o==t.dom||!t.dom.contains(o))continue;let c=o.getBoundingClientRect();if(c.top>=r-20){n=o,s=c.top;break}}return{refDOM:n,refTop:s,stack:vje(t.dom)}}function vje(t){let e=[],r=t.ownerDocument;for(let n=t;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=Aw(n));return e}function ePt({refDOM:t,refTop:e,stack:r}){let n=t?t.getBoundingClientRect().top:0;bje(r,n==0?0:n-e)}function bje(t,e){for(let r=0;r<t.length;r++){let{dom:n,top:s,left:i}=t[r];n.scrollTop!=s+e&&(n.scrollTop=s+e),n.scrollLeft!=i&&(n.scrollLeft=i)}}let Xx=null;function tPt(t){if(t.setActive)return t.setActive();if(Xx)return t.focus(Xx);let e=vje(t);t.focus(Xx==null?{get preventScroll(){return Xx={preventScroll:!0},!0}}:void 0),Xx||(Xx=!1,bje(e,0))}function wje(t,e){let r,n=2e8,s,i=0,a=e.top,o=e.top,c,u;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=od(d).getClientRects();else continue;for(let p=0;p<f.length;p++){let m=f[p];if(m.top<=a&&m.bottom>=o){a=Math.max(m.bottom,a),o=Math.min(m.top,o);let g=m.left>e.left?m.left-e.left:m.right<e.left?e.left-m.right:0;if(g<n){r=d,n=g,s=g&&r.nodeType==3?{left:m.right<e.left?m.right:m.left,top:e.top}:e,d.nodeType==1&&g&&(i=h+(e.left>=(m.left+m.right)/2?1:0));continue}}else m.top>e.top&&!c&&m.left<=e.left&&m.right>=e.left&&(c=d,u={left:Math.max(m.left,Math.min(m.right,e.left)),top:m.top});!r&&(e.left>=m.right&&e.top>=m.top||e.left>=m.left&&e.top>=m.bottom)&&(i=h+1)}}return!r&&c&&(r=c,s=u,n=0),r&&r.nodeType==3?rPt(r,s):!r||n&&r.nodeType==1?{node:t,offset:i}:wje(r,s)}function rPt(t,e){let r=t.nodeValue.length,n=document.createRange(),s;for(let i=0;i<r;i++){n.setEnd(t,i+1),n.setStart(t,i);let a=ef(n,1);if(a.top!=a.bottom&&O7(e,a)){s={node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)};break}}return n.detach(),s||{node:t,offset:0}}function O7(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function nPt(t,e){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left?r:t}function sPt(t,e,r){let{node:n,offset:s}=wje(e,r),i=-1;if(n.nodeType==1&&!n.firstChild){let a=n.getBoundingClientRect();i=a.left!=a.right&&r.left>(a.left+a.right)/2?1:-1}return t.docView.posFromDOM(n,s,i)}function iPt(t,e,r,n){let s=-1;for(let i=e,a=!1;i!=t.dom;){let o=t.docView.nearestDesc(i,!0),c;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((c=o.dom.getBoundingClientRect()).width||c.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!a&&c.left>n.left||c.top>n.top?s=o.posBefore:(!a&&c.right<n.left||c.bottom<n.top)&&(s=o.posAfter),a=!0),!o.contentDOM&&s<0&&!o.node.isText))return(o.node.isBlock?n.top<(c.top+c.bottom)/2:n.left<(c.left+c.right)/2)?o.posBefore:o.posAfter;i=o.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,r,-1)}function Sje(t,e,r){let n=t.childNodes.length;if(n&&r.top<r.bottom)for(let s=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-r.top)/(r.bottom-r.top))-2)),i=s;;){let a=t.childNodes[i];if(a.nodeType==1){let o=a.getClientRects();for(let c=0;c<o.length;c++){let u=o[c];if(O7(e,u))return Sje(a,e,u)}}if((i=(i+1)%n)==s)break}return t}function aPt(t,e){let r=t.dom.ownerDocument,n,s=0,i=Y2t(r,e.left,e.top);i&&({node:n,offset:s}=i);let a=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top),o;if(!a||!t.dom.contains(a.nodeType!=1?a.parentNode:a)){let u=t.dom.getBoundingClientRect();if(!O7(e,u)||(a=Sje(t.dom,e,u),!a))return null}if(Ki)for(let u=a;n&&u;u=Aw(u))u.draggable&&(n=void 0);if(a=nPt(a,e),n){if(wl&&n.nodeType==1&&(s=Math.min(s,n.childNodes.length),s<n.childNodes.length)){let d=n.childNodes[s],h;d.nodeName=="IMG"&&(h=d.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&s++}let u;YE&&s&&n.nodeType==1&&(u=n.childNodes[s-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&s--,n==t.dom&&s==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(s==0||n.nodeType!=1||n.childNodes[s-1].nodeName!="BR")&&(o=iPt(t,n,s,e))}o==null&&(o=sPt(t,a,e));let c=t.docView.nearestDesc(a,!0);return{pos:o,inside:c?c.posAtStart-c.border:-1}}function Vse(t){return t.top<t.bottom||t.left<t.right}function ef(t,e){let r=t.getClientRects();if(r.length){let n=r[e<0?0:r.length-1];if(Vse(n))return n}return Array.prototype.find.call(r,Vse)||t.getBoundingClientRect()}const oPt=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function _je(t,e,r){let{node:n,offset:s,atom:i}=t.docView.domFromPos(e,r<0?-1:1),a=YE||wl;if(n.nodeType==3)if(a&&(oPt.test(n.nodeValue)||(r<0?!s:s==n.nodeValue.length))){let c=ef(od(n,s,s),r);if(wl&&s&&/\s/.test(n.nodeValue[s-1])&&s<n.nodeValue.length){let u=ef(od(n,s-1,s-1),-1);if(u.top==c.top){let d=ef(od(n,s,s+1),-1);if(d.top!=c.top)return eS(d,d.left<u.left)}}return c}else{let c=s,u=s,d=r<0?1:-1;return r<0&&!s?(u++,d=-1):r>=0&&s==n.nodeValue.length?(c--,d=1):r<0?c--:u++,eS(ef(od(n,c,u),d),d<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(r<0||s==cl(n))){let c=n.childNodes[s-1];if(c.nodeType==1)return K3(c.getBoundingClientRect(),!1)}if(i==null&&s<cl(n)){let c=n.childNodes[s];if(c.nodeType==1)return K3(c.getBoundingClientRect(),!0)}return K3(n.getBoundingClientRect(),r>=0)}if(i==null&&s&&(r<0||s==cl(n))){let c=n.childNodes[s-1],u=c.nodeType==3?od(c,cl(c)-(a?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return eS(ef(u,1),!1)}if(i==null&&s<cl(n)){let c=n.childNodes[s];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?od(c,0,a?0:1):c.nodeType==1?c:null:null;if(u)return eS(ef(u,-1),!0)}return eS(ef(n.nodeType==3?od(n):n,-r),r>=0)}function eS(t,e){if(t.width==0)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function K3(t,e){if(t.height==0)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function jje(t,e,r){let n=t.state,s=t.root.activeElement;n!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return r()}finally{n!=e&&t.updateState(n),s!=t.dom&&s&&s.focus()}}function lPt(t,e,r){let n=e.selection,s=r=="up"?n.$from:n.$to;return jje(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,r=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(i,!0);if(!o)break;if(o.node.isBlock){i=o.contentDOM||o.dom;break}i=o.dom.parentNode}let a=_je(t,s.pos,1);for(let o=i.firstChild;o;o=o.nextSibling){let c;if(o.nodeType==1)c=o.getClientRects();else if(o.nodeType==3)c=od(o,0,o.nodeValue.length).getClientRects();else continue;for(let u=0;u<c.length;u++){let d=c[u];if(d.bottom>d.top+1&&(r=="up"?a.top-d.top>(d.bottom-a.top)*2:d.bottom-a.bottom>(a.bottom-d.top)*2))return!1}}return!0})}const cPt=/[\u0590-\u08ac]/;function uPt(t,e,r){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let s=n.parentOffset,i=!s,a=s==n.parent.content.size,o=t.domSelection();return o?!cPt.test(n.parent.textContent)||!o.modify?r=="left"||r=="backward"?i:a:jje(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:h}=t.domSelectionRange(),f=o.caretBidiLevel;o.modify("move",r,"character");let p=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:m,focusOffset:g}=t.domSelectionRange(),x=m&&!p.contains(m.nodeType==1?m:m.parentNode)||c==m&&u==g;try{o.collapse(d,h),c&&(c!=d||u!=h)&&o.extend&&o.extend(c,u)}catch{}return f!=null&&(o.caretBidiLevel=f),x}):n.pos==n.start()||n.pos==n.end()}let Wse=null,qse=null,Gse=!1;function dPt(t,e,r){return Wse==e&&qse==r?Gse:(Wse=e,qse=r,Gse=r=="up"||r=="down"?lPt(t,e,r):uPt(t,e,r))}const Sl=0,Kse=1,og=2,gc=3;class XE{constructor(e,r,n,s){this.parent=e,this.children=r,this.dom=n,this.contentDOM=s,this.dirty=Sl,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,r,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let r=0;r<this.children.length;r++)e+=this.children[r].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 r=0,n=this.posAtStart;;r++){let s=this.children[r];if(s==e)return n;n+=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,r,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let i,a;if(e==this.contentDOM)i=e.childNodes[r-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((a=i.pmViewDesc)&&a.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(a)+a.size:this.posAtStart}else{let i,a;if(e==this.contentDOM)i=e.childNodes[r];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((a=i.pmViewDesc)&&a.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(a):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=r>pi(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(r==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&r==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,r=!1){for(let n=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),a;if(i&&(!r||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let r=e.pmViewDesc;for(let n=r;n;n=n.parent)if(n==this)return r}posFromDOM(e,r,n){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,r,n)}return-1}descAt(e){for(let r=0,n=0;r<this.children.length;r++){let s=this.children[r],i=n+s.size;if(n==e&&i!=n){for(;!s.border&&s.children.length;)for(let a=0;a<s.children.length;a++){let o=s.children[a];if(o.size){s=o;break}}return s}if(e<i)return s.descAt(e-n-s.border);n=i}}domFromPos(e,r){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,s=0;for(let i=0;n<this.children.length;n++){let a=this.children[n],o=i+a.size;if(o>e||a instanceof Nje){s=e-i;break}i=o}if(s)return this.children[n].domFromPos(s-this.children[n].border,r);for(let i;n&&!(i=this.children[n-1]).size&&i instanceof kje&&i.side>=0;n--);if(r<=0){let i,a=!0;for(;i=n?this.children[n-1]:null,!(!i||i.dom.parentNode==this.contentDOM);n--,a=!1);return i&&r&&a&&!i.border&&!i.domAtom?i.domFromPos(i.size,r):{node:this.contentDOM,offset:i?pi(i.dom)+1:0}}else{let i,a=!0;for(;i=n<this.children.length?this.children[n]:null,!(!i||i.dom.parentNode==this.contentDOM);n++,a=!1);return i&&a&&!i.border&&!i.domAtom?i.domFromPos(0,r):{node:this.contentDOM,offset:i?pi(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,r,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:r,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let a=n,o=0;;o++){let c=this.children[o],u=a+c.size;if(s==-1&&e<=u){let d=a+c.border;if(e>=d&&r<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,r,d);e=a;for(let h=o;h>0;h--){let f=this.children[h-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=pi(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(u>r||o==this.children.length-1)){r=u;for(let d=o+1;d<this.children.length;d++){let h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){i=pi(h.dom);break}r+=h.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=u}return{node:this.contentDOM,from:e,to:r,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let r=this.children[e<0?0:this.children.length-1];return r.size==0||r.emptyChildAt(e)}domAfterPos(e){let{node:r,offset:n}=this.domFromPos(e,0);if(r.nodeType!=1||n==r.childNodes.length)throw new RangeError("No node after pos "+e);return r.childNodes[n]}setSelection(e,r,n,s=!1){let i=Math.min(e,r),a=Math.max(e,r);for(let p=0,m=0;p<this.children.length;p++){let g=this.children[p],x=m+g.size;if(i>m&&a<x)return g.setSelection(e-m-g.border,r-m-g.border,n,s);m=x}let o=this.domFromPos(e,e?-1:1),c=r==e?o:this.domFromPos(r,r?-1:1),u=n.root.getSelection(),d=n.domSelectionRange(),h=!1;if((wl||Ki)&&e==r){let{node:p,offset:m}=o;if(p.nodeType==3){if(h=!!(m&&p.nodeValue[m-1]==`
`),h&&m==p.nodeValue.length)for(let g=p,x;g;g=g.parentNode){if(x=g.nextSibling){x.nodeName=="BR"&&(o=c={node:x.parentNode,offset:pi(x)+1});break}let y=g.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let g=p.childNodes[m-1];h=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(wl&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(s=!0)}if(!(s||h&&Ki)&&ux(o.node,o.offset,d.anchorNode,d.anchorOffset)&&ux(c.node,c.offset,d.focusNode,d.focusOffset))return;let f=!1;if((u.extend||e==r)&&!(h&&wl)){u.collapse(o.node,o.offset);try{e!=r&&u.extend(c.node,c.offset),f=!0}catch{}}if(!f){if(e>r){let m=o;o=c,c=m}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(o.node,o.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,r){for(let n=0,s=0;s<this.children.length;s++){let i=this.children[s],a=n+i.size;if(n==a?e<=a&&r>=n:e<a&&r>n){let o=n+i.border,c=a-i.border;if(e>=o&&r<=c){this.dirty=e==n||r==a?og:Kse,e==o&&r==c&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=gc:i.markDirty(e-o,r-o);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?og:gc}n=a}this.dirty=og}markParentsDirty(){let e=1;for(let r=this.parent;r;r=r.parent,e++){let n=e==1?og:Kse;r.dirty<n&&(r.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class kje extends XE{constructor(e,r,n,s){let i,a=r.type.toDOM;if(typeof a=="function"&&(a=a(n,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!r.type.spec.raw){if(a.nodeType!=1){let o=document.createElement("span");o.appendChild(a),a=o}a.contentEditable="false",a.classList.add("ProseMirror-widget")}super(e,[],a,null),this.widget=r,this.widget=r,i=this}matchesWidget(e){return this.dirty==Sl&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let r=this.widget.spec.stopEvent;return r?r(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 hPt extends XE{constructor(e,r,n,s){super(e,[],r,null),this.textDOM=n,this.text=s}get size(){return this.text.length}localPosFromDOM(e,r){return e!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Ip extends XE{constructor(e,r,n,s,i){super(e,[],n,s),this.mark=r,this.spec=i}static create(e,r,n,s){let i=s.nodeViews[r.type.name],a=i&&i(r,s,n);return(!a||!a.dom)&&(a=Px.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new Ip(e,r,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&gc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=gc&&this.mark.eq(e)}markDirty(e,r){if(super.markDirty(e,r),this.dirty!=Sl){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=Sl}}slice(e,r,n){let s=Ip.create(this.parent,this.mark,!0,n),i=this.children,a=this.size;r<a&&(i=iU(i,r,a,n)),e>0&&(i=iU(i,0,e,n));for(let o=0;o<i.length;o++)i[o].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 Rp extends XE{constructor(e,r,n,s,i,a,o){super(e,[],i,a),this.node=r,this.outerDeco=n,this.innerDeco=s,this.nodeDOM=o}static create(e,r,n,s,i,a){let o=i.nodeViews[r.type.name],c,u=o&&o(r,i,()=>{if(!c)return a;if(c.parent)return c.parent.posBeforeChild(c)},n,s),d=u&&u.dom,h=u&&u.contentDOM;if(r.isText){if(!d)d=document.createTextNode(r.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:h}=Px.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!h&&!r.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),r.type.spec.draggable&&(d.draggable=!0));let f=d;return d=Cje(d,n,r),u?c=new fPt(e,r,n,s,d,h||null,f,u):r.isText?new mD(e,r,n,s,d,f):new Rp(e,r,n,s,d,h||null,f)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Qe.empty)}return e}matchesNode(e,r,n){return this.dirty==Sl&&e.eq(this.node)&&OO(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,r){let n=this.node.inlineContent,s=r,i=e.composing?this.localCompositionInfo(e,r):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,c=new mPt(this,a&&a.node,e);xPt(this.node,this.innerDeco,(u,d,h)=>{u.spec.marks?c.syncToMarks(u.spec.marks,n,e,d):u.type.side>=0&&!h&&c.syncToMarks(d==this.node.childCount?Vr.none:this.node.child(d).marks,n,e,d),c.placeWidget(u,e,s)},(u,d,h,f)=>{c.syncToMarks(u.marks,n,e,f);let p;c.findNodeMatch(u,d,h,f)||o&&e.state.selection.from>s&&e.state.selection.to<s+u.nodeSize&&(p=c.findIndexWithChild(i.node))>-1&&c.updateNodeAt(u,d,h,p,e)||c.updateNextNode(u,d,h,e,f,s)||c.addNode(u,d,h,e,s),s+=u.nodeSize}),c.syncToMarks([],n,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==og)&&(a&&this.protectLocalComposition(e,a),Eje(this.contentDOM,this.children,e),Cw&&vPt(this.dom))}localCompositionInfo(e,r){let{from:n,to:s}=e.state.selection;if(!(e.state.selection instanceof Bt)||n<r||s>r+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 a=i.nodeValue,o=bPt(this.node.content,a,n-r,s-r);return o<0?null:{node:i,pos:o,text:a}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:r,pos:n,text:s}){if(this.getDesc(r))return;let i=r;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 a=new hPt(this,i,r,s);e.input.compositionNodes.push(a),this.children=iU(this.children,n,n+s.length,e,a)}update(e,r,n,s){return this.dirty==gc||!e.sameMarkup(this.node)?!1:(this.updateInner(e,r,n,s),!0)}updateInner(e,r,n,s){this.updateOuterDeco(r),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Sl}updateOuterDeco(e){if(OO(e,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Aje(this.dom,this.nodeDOM,sU(this.outerDeco,this.node,r),sU(e,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Yse(t,e,r,n,s){Cje(n,e,t);let i=new Rp(void 0,t,e,r,n,n,n);return i.contentDOM&&i.updateChildren(s,0),i}class mD extends Rp{constructor(e,r,n,s,i,a){super(e,r,n,s,i,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,r,n,s){return this.dirty==gc||this.dirty!=Sl&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Sl||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=Sl,!0)}inParent(){let e=this.parent.contentDOM;for(let r=this.nodeDOM;r;r=r.parentNode)if(r==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,r,n){return e==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):super.localPosFromDOM(e,r,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,r,n){let s=this.node.cut(e,r),i=document.createTextNode(s.text);return new mD(this.parent,s,this.outerDeco,this.innerDeco,i,i)}markDirty(e,r){super.markDirty(e,r),this.dom!=this.nodeDOM&&(e==0||r==this.nodeDOM.nodeValue.length)&&(this.dirty=gc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Nje extends XE{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Sl&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class fPt extends Rp{constructor(e,r,n,s,i,a,o,c){super(e,r,n,s,i,a,o),this.spec=c}update(e,r,n,s){if(this.dirty==gc)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,r,n);return i&&this.updateInner(e,r,n,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,r,n,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,r,n,s){this.spec.setSelection?this.spec.setSelection(e,r,n.root):super.setSelection(e,r,n,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 Eje(t,e,r){let n=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let a=e[i],o=a.dom;if(o.parentNode==t){for(;o!=n;)n=Xse(n),s=!0;n=n.nextSibling}else s=!0,t.insertBefore(o,n);if(a instanceof Ip){let c=n?n.previousSibling:t.lastChild;Eje(a.contentDOM,a.children,r),n=c?c.nextSibling:t.firstChild}}for(;n;)n=Xse(n),s=!0;s&&r.trackWrites==t&&(r.trackWrites=null)}const C_=function(t){t&&(this.nodeName=t)};C_.prototype=Object.create(null);const lg=[new C_];function sU(t,e,r){if(t.length==0)return lg;let n=r?lg[0]:new C_,s=[n];for(let i=0;i<t.length;i++){let a=t[i].type.attrs;if(a){a.nodeName&&s.push(n=new C_(a.nodeName));for(let o in a){let c=a[o];c!=null&&(r&&s.length==1&&s.push(n=new C_(e.isInline?"span":"div")),o=="class"?n.class=(n.class?n.class+" ":"")+c:o=="style"?n.style=(n.style?n.style+";":"")+c:o!="nodeName"&&(n[o]=c))}}}return s}function Aje(t,e,r,n){if(r==lg&&n==lg)return e;let s=e;for(let i=0;i<n.length;i++){let a=n[i],o=r[i];if(i){let c;o&&o.nodeName==a.nodeName&&s!=t&&(c=s.parentNode)&&c.nodeName.toLowerCase()==a.nodeName||(c=document.createElement(a.nodeName),c.pmIsDeco=!0,c.appendChild(s),o=lg[0]),s=c}pPt(s,o||lg[0],a)}return s}function pPt(t,e,r){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in r)&&t.removeAttribute(n);for(let n in r)n!="class"&&n!="style"&&n!="nodeName"&&r[n]!=e[n]&&t.setAttribute(n,r[n]);if(e.class!=r.class){let n=e.class?e.class.split(" ").filter(Boolean):[],s=r.class?r.class.split(" ").filter(Boolean):[];for(let i=0;i<n.length;i++)s.indexOf(n[i])==-1&&t.classList.remove(n[i]);for(let i=0;i<s.length;i++)n.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=r.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=n.exec(e.style);)t.style.removeProperty(s[1])}r.style&&(t.style.cssText+=r.style)}}function Cje(t,e,r){return Aje(t,t,lg,sU(e,r,t.nodeType!=1))}function OO(t,e){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].type.eq(e[r].type))return!1;return!0}function Xse(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class mPt{constructor(e,r,n){this.lock=r,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=gPt(e.node.content,e)}destroyBetween(e,r){if(e!=r){for(let n=e;n<r;n++)this.top.children[n].destroy();this.top.children.splice(e,r-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,r,n,s){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=Sl,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let c=-1,u=this.top.children.length;s<this.preMatch.index&&(u=Math.min(this.index+3,u));for(let d=this.index;d<u;d++){let h=this.top.children[d];if(h.matchesMark(e[a])&&!this.isLocked(h.dom)){c=d;break}}if(c<0&&this.index<this.top.children.length){let d=this.top.children[this.index];d instanceof Ip&&d.dirty!=gc&&d.mark.type==e[a].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[a])&&(d.mark=e[a],c=this.index,this.changed=!0)}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let d=Ip.create(this.top,e[a],r,n);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,a++}}findNodeMatch(e,r,n,s){let i=-1,a;if(s>=this.preMatch.index&&(a=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&a.matchesNode(e,r,n))i=this.top.children.indexOf(a,this.index);else for(let o=this.index,c=Math.min(this.top.children.length,o+5);o<c;o++){let u=this.top.children[o];if(u.matchesNode(e,r,n)&&!this.preMatch.matched.has(u)){i=o;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,r,n,s,i){let a=this.top.children[s];return a.dirty==gc&&a.dom==a.contentDOM&&(a.dirty=og),a.update(e,r,n,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let r=e.parentNode;if(!r)return-1;if(r==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==n)return s}return-1}e=r}}updateNextNode(e,r,n,s,i,a){for(let o=this.index;o<this.top.children.length;o++){let c=this.top.children[o];if(c instanceof Rp){let u=this.preMatch.matched.get(c);if(u!=null&&u!=i)return!1;let d=c.dom,h,f=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=gc&&OO(r,c.outerDeco));if(!f&&c.update(e,r,n,s))return this.destroyBetween(this.index,o),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(h=this.recreateWrapper(c,e,r,n,s,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=og,h.updateChildren(s,a+1),h.dirty=Sl),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,r,n,s,i,a){if(e.dirty||r.isAtom||!e.children.length||!e.node.content.eq(r.content)||!OO(n,e.outerDeco)||!s.eq(e.innerDeco))return null;let o=Rp.create(this.top,r,n,s,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let c of o.children)c.parent=o}return e.destroy(),o}addNode(e,r,n,s,i){let a=Rp.create(this.top,e,r,n,s,i);a.contentDOM&&a.updateChildren(s,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,r,n){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 kje(this.top,e,r,n);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],r=this.top;for(;e instanceof Ip;)r=e,e=r.children[r.children.length-1];(!e||!(e instanceof mD)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ki||Ks)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",r),this.addHackNode("BR",this.top))}addHackNode(e,r){if(r==this.top&&this.index<r.children.length&&r.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let s=new Nje(this.top,[],n,null);r!=this.top?r.children.push(s):r.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 gPt(t,e){let r=e,n=r.children.length,s=t.childCount,i=new Map,a=[];e:for(;s>0;){let o;for(;;)if(n){let u=r.children[n-1];if(u instanceof Ip)r=u,n=u.children.length;else{o=u,n--;break}}else{if(r==e)break e;n=r.parent.children.indexOf(r),r=r.parent}let c=o.node;if(c){if(c!=t.child(s-1))break;--s,i.set(o,s),a.push(o)}}return{index:s,matched:i,matches:a.reverse()}}function yPt(t,e){return t.type.side-e.type.side}function xPt(t,e,r,n){let s=e.locals(t),i=0;if(s.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);n(d,s,e.forChild(i,d),u),i+=d.nodeSize}return}let a=0,o=[],c=null;for(let u=0;;){let d,h;for(;a<s.length&&s[a].to==i;){let x=s[a++];x.widget&&(d?(h||(h=[d])).push(x):d=x)}if(d)if(h){h.sort(yPt);for(let x=0;x<h.length;x++)r(h[x],u,!!c)}else r(d,u,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(u<t.childCount)p=u,f=t.child(u++);else break;for(let x=0;x<o.length;x++)o[x].to<=i&&o.splice(x--,1);for(;a<s.length&&s[a].from<=i&&s[a].to>i;)o.push(s[a++]);let m=i+f.nodeSize;if(f.isText){let x=m;a<s.length&&s[a].from<x&&(x=s[a].from);for(let y=0;y<o.length;y++)o[y].to<x&&(x=o[y].to);x<m&&(c=f.cut(x-i),f=f.cut(0,x-i),m=x,p=-1)}else for(;a<s.length&&s[a].to<m;)a++;let g=f.isInline&&!f.isLeaf?o.filter(x=>!x.inline):o.slice();n(f,g,e.forChild(i,f),p),i=m}}function vPt(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 bPt(t,e,r,n){for(let s=0,i=0;s<t.childCount&&i<=n;){let a=t.child(s++),o=i;if(i+=a.nodeSize,!a.isText)continue;let c=a.text;for(;s<t.childCount;){let u=t.child(s++);if(i+=u.nodeSize,!u.isText)break;c+=u.text}if(i>=r){if(i>=n&&c.slice(n-e.length-o,n-o)==e)return n-e.length;let u=o<n?c.lastIndexOf(e,n-o-1):-1;if(u>=0&&u+e.length+o>=r)return o+u;if(r==n&&c.length>=n+e.length-o&&c.slice(n-o,n-o+e.length)==e)return n}}return-1}function iU(t,e,r,n,s){let i=[];for(let a=0,o=0;a<t.length;a++){let c=t[a],u=o,d=o+=c.size;u>=r||d<=e?i.push(c):(u<e&&i.push(c.slice(0,e-u,n)),s&&(i.push(s),s=void 0),d>r&&i.push(c.slice(r-u,c.size,n)))}return i}function I7(t,e=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let s=t.docView.nearestDesc(r.focusNode),i=s&&s.size==0,a=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(a<0)return null;let o=n.resolve(a),c,u;if(pD(r)){for(c=a;s&&!s.node;)s=s.parent;let h=s.node;if(s&&h.isAtom&&Ot.isSelectable(h)&&s.parent&&!(h.isInline&&G2t(r.focusNode,r.focusOffset,s.dom))){let f=s.posBefore;u=new Ot(a==f?o:n.resolve(f))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let h=a,f=a;for(let p=0;p<r.rangeCount;p++){let m=r.getRangeAt(p);h=Math.min(h,t.docView.posFromDOM(m.startContainer,m.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(m.endContainer,m.endOffset,-1))}if(h<0)return null;[c,a]=f==t.state.selection.anchor?[f,h]:[h,f],o=n.resolve(a)}else c=t.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(c<0)return null}let d=n.resolve(c);if(!u){let h=e=="pointer"||t.state.selection.head<o.pos&&!i?1:-1;u=R7(t,d,o,h)}return u}function Tje(t){return t.editable?t.hasFocus():Oje(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function sh(t,e=!1){let r=t.state.selection;if(Pje(t,r),!Tje(t))return;let n=t.input.mouseDown;if(!e&&Ks&&n){let s=t.domSelectionRange(),i=t.domObserver.currentSelection;if(s.anchorNode&&i.anchorNode&&ux(s.anchorNode,s.anchorOffset,i.anchorNode,i.anchorOffset)&&n.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)SPt(t);else{let{anchor:s,head:i}=r,a,o;Jse&&!(r instanceof Bt)&&(r.$from.parent.inlineContent||(a=Qse(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(o=Qse(t,r.to))),t.docView.setSelection(s,i,t,e),Jse&&(a&&Zse(a),o&&Zse(o)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wPt(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const Jse=Ki||Ks&&yje<63;function Qse(t,e){let{node:r,offset:n}=t.docView.domFromPos(e,0),s=n<r.childNodes.length?r.childNodes[n]:null,i=n?r.childNodes[n-1]:null;if(Ki&&s&&s.contentEditable=="false")return Y3(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Y3(s);if(i)return Y3(i)}}function Y3(t){return t.contentEditable="true",Ki&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Zse(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function wPt(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let r=t.domSelectionRange(),n=r.anchorNode,s=r.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(r.anchorNode!=n||r.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Tje(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function SPt(t){let e=t.domSelection();if(!e)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?e.collapse(r.parentNode,pi(r)+1):e.collapse(r,0),!n&&!t.state.selection.visible&&Ya&&Op<=11&&(r.disabled=!0,r.disabled=!1)}function Pje(t,e){if(e instanceof Ot){let r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(eie(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else eie(t)}function eie(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function R7(t,e,r,n){return t.someProp("createSelectionBetween",s=>s(t,e,r))||Bt.between(e,r,n)}function tie(t){return t.editable&&!t.hasFocus()?!1:Oje(t)}function Oje(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 _Pt(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return ux(e.node,e.offset,r.anchorNode,r.anchorOffset)}function aU(t,e){let{$anchor:r,$head:n}=t.selection,s=e>0?r.max(n):r.min(n),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&qt.findFrom(i,e)}function af(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function rie(t,e,r){let n=t.state.selection;if(n instanceof Bt)if(r.indexOf("s")>-1){let{$head:s}=n,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return af(t,new Bt(n.$anchor,a))}else if(n.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=aU(t.state,e);return s&&s instanceof Ot?af(t,s):!1}else if(!(nl&&r.indexOf("m")>-1)){let s=n.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,a;if(!i||i.isText)return!1;let o=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(a=t.docView.descAt(o))&&!a.contentDOM?Ot.isSelectable(i)?af(t,new Ot(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):YE?af(t,new Bt(t.state.doc.resolve(e<0?o:o+i.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Ot&&n.node.isInline)return af(t,new Bt(e>0?n.$to:n.$from));{let s=aU(t.state,e);return s?af(t,s):!1}}}function IO(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function T_(t,e){let r=t.pmViewDesc;return r&&r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Jx(t,e){return e<0?jPt(t):kPt(t)}function jPt(t){let e=t.domSelectionRange(),r=e.focusNode,n=e.focusOffset;if(!r)return;let s,i,a=!1;for(wl&&r.nodeType==1&&n<IO(r)&&T_(r.childNodes[n],-1)&&(a=!0);;)if(n>0){if(r.nodeType!=1)break;{let o=r.childNodes[n-1];if(T_(o,-1))s=r,i=--n;else if(o.nodeType==3)r=o,n=r.nodeValue.length;else break}}else{if(Ije(r))break;{let o=r.previousSibling;for(;o&&T_(o,-1);)s=r.parentNode,i=pi(o),o=o.previousSibling;if(o)r=o,n=IO(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}a?oU(t,r,n):s&&oU(t,s,i)}function kPt(t){let e=t.domSelectionRange(),r=e.focusNode,n=e.focusOffset;if(!r)return;let s=IO(r),i,a;for(;;)if(n<s){if(r.nodeType!=1)break;let o=r.childNodes[n];if(T_(o,1))i=r,a=++n;else break}else{if(Ije(r))break;{let o=r.nextSibling;for(;o&&T_(o,1);)i=o.parentNode,a=pi(o)+1,o=o.nextSibling;if(o)r=o,n=0,s=IO(r);else{if(r=r.parentNode,r==t.dom)break;n=s=0}}}i&&oU(t,i,a)}function Ije(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function NPt(t,e){for(;t&&e==t.childNodes.length&&!KE(t);)e=pi(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let r=t.childNodes[e];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r,e=0}}function EPt(t,e){for(;t&&!e&&!KE(t);)e=pi(t),t=t.parentNode;for(;t&&e;){let r=t.childNodes[e-1];if(r.nodeType==3)return r;if(r.nodeType==1&&r.contentEditable=="false")break;t=r,e=t.childNodes.length}}function oU(t,e,r){if(e.nodeType!=3){let i,a;(a=NPt(e,r))?(e=a,r=0):(i=EPt(e,r))&&(e=i,r=i.nodeValue.length)}let n=t.domSelection();if(!n)return;if(pD(n)){let i=document.createRange();i.setEnd(e,r),i.setStart(e,r),n.removeAllRanges(),n.addRange(i)}else n.extend&&n.extend(e,r);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&sh(t)},50)}function nie(t,e){let r=t.state.doc.resolve(e);if(!(Ks||xje)&&r.parent.inlineContent){let s=t.coordsAtPos(e);if(e>r.start()){let i=t.coordsAtPos(e-1),a=(i.top+i.bottom)/2;if(a>s.top&&a<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<r.end()){let i=t.coordsAtPos(e+1),a=(i.top+i.bottom)/2;if(a>s.top&&a<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 sie(t,e,r){let n=t.state.selection;if(n instanceof Bt&&!n.empty||r.indexOf("s")>-1||nl&&r.indexOf("m")>-1)return!1;let{$from:s,$to:i}=n;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let a=aU(t.state,e);if(a&&a instanceof Ot)return af(t,a)}if(!s.parent.inlineContent){let a=e<0?s:i,o=n instanceof Pp?qt.near(a,e):qt.findFrom(a,e);return o?af(t,o):!1}return!1}function iie(t,e){if(!(t.state.selection instanceof Bt))return!0;let{$head:r,$anchor:n,empty:s}=t.state.selection;if(!r.sameParent(n))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(i&&!i.isText){let a=t.state.tr;return e<0?a.delete(r.pos-i.nodeSize,r.pos):a.delete(r.pos,r.pos+i.nodeSize),t.dispatch(a),!0}return!1}function aie(t,e,r){t.domObserver.stop(),e.contentEditable=r,t.domObserver.start()}function APt(t){if(!Ki||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&e.nodeType==1&&r==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;aie(t,n,"true"),setTimeout(()=>aie(t,n,"false"),20)}return!1}function CPt(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function TPt(t,e){let r=e.keyCode,n=CPt(e);if(r==8||nl&&r==72&&n=="c")return iie(t,-1)||Jx(t,-1);if(r==46&&!e.shiftKey||nl&&r==68&&n=="c")return iie(t,1)||Jx(t,1);if(r==13||r==27)return!0;if(r==37||nl&&r==66&&n=="c"){let s=r==37?nie(t,t.state.selection.from)=="ltr"?-1:1:-1;return rie(t,s,n)||Jx(t,s)}else if(r==39||nl&&r==70&&n=="c"){let s=r==39?nie(t,t.state.selection.from)=="ltr"?1:-1:1;return rie(t,s,n)||Jx(t,s)}else{if(r==38||nl&&r==80&&n=="c")return sie(t,-1,n)||Jx(t,-1);if(r==40||nl&&r==78&&n=="c")return APt(t)||sie(t,1,n)||Jx(t,1);if(n==(nl?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function M7(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let r=[],{content:n,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&n.childCount==1&&n.firstChild.childCount==1;){s--,i--;let p=n.firstChild;r.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),n=p.content}let a=t.someProp("clipboardSerializer")||Px.fromSchema(t.state.schema),o=$je(),c=o.createElement("div");c.appendChild(a.serializeFragment(n,{document:o}));let u=c.firstChild,d,h=0;for(;u&&u.nodeType==1&&(d=Fje[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let m=o.createElement(d[p]);for(;c.firstChild;)m.appendChild(c.firstChild);c.appendChild(m),h++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${s} ${i}${h?` -${h}`:""} ${JSON.stringify(r)}`);let f=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,`
`);return{dom:c,text:f,slice:e}}function Rje(t,e,r,n,s){let i=s.parent.type.spec.code,a,o;if(!r&&!e)return null;let c=!!e&&(n||i||!r);if(c){if(t.someProp("transformPastedText",f=>{e=f(e,i||n,t)}),i)return o=new vt(Qe.from(t.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),t.someProp("transformPasted",f=>{o=f(o,t,!0)}),o;let h=t.someProp("clipboardTextParser",f=>f(e,s,n,t));if(h)o=h;else{let f=s.marks(),{schema:p}=t.state,m=Px.fromSchema(p);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let x=a.appendChild(document.createElement("p"));g&&x.appendChild(m.serializeNode(p.text(g,f)))})}}else t.someProp("transformPastedHTML",h=>{r=h(r,t)}),a=RPt(r),YE&&MPt(a);let u=a&&a.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let h=+d[3];h>0;h--){let f=a.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;a=f}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||Tp.fromSchema(t.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!PPt.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)o=DPt(oie(o,+d[1],+d[2]),d[4]);else if(o=vt.maxOpen(OPt(o.content,s),!0),o.openStart||o.openEnd){let h=0,f=0;for(let p=o.content.firstChild;h<o.openStart&&!p.type.spec.isolating;h++,p=p.firstChild);for(let p=o.content.lastChild;f<o.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);o=oie(o,h,f)}return t.someProp("transformPasted",h=>{o=h(o,t,c)}),o}const PPt=/^(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 OPt(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let s=e.node(r).contentMatchAt(e.index(r)),i,a=[];if(t.forEach(o=>{if(!a)return;let c=s.findWrapping(o.type),u;if(!c)return a=null;if(u=a.length&&i.length&&Dje(c,i,o,a[a.length-1],0))a[a.length-1]=u;else{a.length&&(a[a.length-1]=Lje(a[a.length-1],i.length));let d=Mje(o,c);a.push(d),s=s.matchType(d.type),i=c}}),a)return Qe.from(a)}return t}function Mje(t,e,r=0){for(let n=e.length-1;n>=r;n--)t=e[n].create(null,Qe.from(t));return t}function Dje(t,e,r,n,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=Dje(t,e,r,n.lastChild,s+1);if(i)return n.copy(n.content.replaceChild(n.childCount-1,i));if(n.contentMatchAt(n.childCount).matchType(s==t.length-1?r.type:t[s+1]))return n.copy(n.content.append(Qe.from(Mje(r,t,s+1))))}}function Lje(t,e){if(e==0)return t;let r=t.content.replaceChild(t.childCount-1,Lje(t.lastChild,e-1)),n=t.contentMatchAt(t.childCount).fillBefore(Qe.empty,!0);return t.copy(r.append(n))}function lU(t,e,r,n,s,i){let a=e<0?t.firstChild:t.lastChild,o=a.content;return t.childCount>1&&(i=0),s<n-1&&(o=lU(o,e,r,n,s+1,i)),s>=r&&(o=e<0?a.contentMatchAt(0).fillBefore(o,i<=s).append(o):o.append(a.contentMatchAt(a.childCount).fillBefore(Qe.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(o))}function oie(t,e,r){return e<t.openStart&&(t=new vt(lU(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),r<t.openEnd&&(t=new vt(lU(t.content,1,r,t.openEnd,0,0),t.openStart,r)),t}const Fje={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 $je(){return document.implementation.createHTMLDocument("title")}let X3=null;function IPt(t){let e=window.trustedTypes;return e?(X3||(X3=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:r=>r})),X3.createHTML(t)):t}function RPt(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let r=$je(),n=r.body,s=/<([a-z][^>\s]+)/i.exec(t),i;if((i=s&&Fje[s[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=IPt(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;for(let a=0;a<r.styleSheets.length;a++){let o=r.styleSheets[a];for(let c=0;c<o.rules.length;c++){let u=o.rules[c];if(u instanceof CSSStyleRule){let d=n.querySelectorAll(u.selectorText);for(let h=0;h<d.length;h++)d[h].style.cssText+=u.style.cssText}}}return n}function MPt(t){let e=t.querySelectorAll(Ks?"span:not([class]):not([style])":"span.Apple-converted-space");for(let r=0;r<e.length;r++){let n=e[r];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),n)}}function DPt(t,e){if(!t.size)return t;let r=t.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:a}=t;for(let o=n.length-2;o>=0;o-=2){let c=r.nodes[n[o]];if(!c||c.hasRequiredAttrs())break;s=Qe.from(c.create(n[o+1],s)),i++,a++}return new vt(s,i,a)}const ba={},wa={},LPt={touchstart:!0,touchmove:!0};class FPt{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 $Pt(t){for(let e in ba){let r=ba[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=n=>{zPt(t,n)&&!D7(t,n)&&(t.editable||!(n.type in wa))&&r(t,n)},LPt[e]?{passive:!0}:void 0)}Ki&&t.dom.addEventListener("input",()=>null),cU(t)}function Qd(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function BPt(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 cU(t){t.someProp("handleDOMEvents",e=>{for(let r in e)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>D7(t,n))})}function D7(t,e){return t.someProp("handleDOMEvents",r=>{let n=r[e.type];return n?n(t,e)||e.defaultPrevented:!1})}function zPt(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return!1;return!0}function UPt(t,e){!D7(t,e)&&ba[e.type]&&(t.editable||!(e.type in wa))&&ba[e.type](t,e)}wa.keydown=(t,e)=>{let r=e;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!Hje(t)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Jd&&Ks&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),Cw&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let n=Date.now();t.input.lastIOSEnter=n,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==n&&(t.someProp("handleKeyDown",s=>s(t,qm(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||TPt(t,r)?r.preventDefault():Qd(t,"key")};wa.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};wa.keypress=(t,e)=>{let r=e;if(Hje(t)||!r.charCode||r.ctrlKey&&!r.altKey||nl&&r.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Bt)||!n.$from.sameParent(n.$to)){let s=String.fromCharCode(r.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",a=>a(t,n.$from.pos,n.$to.pos,s,i))&&t.dispatch(i()),r.preventDefault()}};function JE(t){return{left:t.clientX,top:t.clientY}}function HPt(t,e){let r=e.x-t.clientX,n=e.y-t.clientY;return r*r+n*n<100}function L7(t,e,r,n,s){if(n==-1)return!1;let i=t.state.doc.resolve(n);for(let a=i.depth+1;a>0;a--)if(t.someProp(e,o=>a>i.depth?o(t,r,i.nodeAfter,i.before(a),s,!0):o(t,r,i.node(a),i.before(a),s,!1)))return!0;return!1}function QE(t,e,r){if(t.focused||t.focus(),t.state.selection.eq(e))return;let n=t.state.tr.setSelection(e);n.setMeta("pointer",!0),t.dispatch(n)}function VPt(t,e){if(e==-1)return!1;let r=t.state.doc.resolve(e),n=r.nodeAfter;return n&&n.isAtom&&Ot.isSelectable(n)?(QE(t,new Ot(r)),!0):!1}function WPt(t,e){if(e==-1)return!1;let r=t.state.selection,n,s;r instanceof Ot&&(n=r.node);let i=t.state.doc.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a);if(Ot.isSelectable(o)){n&&r.$from.depth>0&&a>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?s=i.before(r.$from.depth):s=i.before(a);break}}return s!=null?(QE(t,Ot.create(t.state.doc,s)),!0):!1}function qPt(t,e,r,n,s){return L7(t,"handleClickOn",e,r,n)||t.someProp("handleClick",i=>i(t,e,n))||(s?WPt(t,r):VPt(t,r))}function GPt(t,e,r,n){return L7(t,"handleDoubleClickOn",e,r,n)||t.someProp("handleDoubleClick",s=>s(t,e,n))}function KPt(t,e,r,n){return L7(t,"handleTripleClickOn",e,r,n)||t.someProp("handleTripleClick",s=>s(t,e,n))||YPt(t,r,n)}function YPt(t,e,r){if(r.button!=0)return!1;let n=Bje(t,e,!0),s=t.state.doc;return n?(QE(t,n),n instanceof Bt&&s.eq(t.state.doc)&&(t.input.mouseDown=new JPt(t,n)),!0):!1}function Bje(t,e,r){let n=t.state.doc;if(e==-1)return n.inlineContent?Bt.create(n,0,n.content.size):null;let s=n.resolve(e);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i),o=s.before(i);if(a.inlineContent)return Bt.create(n,o+1,o+1+a.content.size);if(r&&Ot.isSelectable(a))return Ot.create(n,o)}return null}function F7(t){return RO(t)}const zje=nl?"metaKey":"ctrlKey";ba.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let n=F7(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&HPt(r,t.input.lastClick)&&!r[zje]&&t.input.lastClick.button==r.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:r.clientX,y:r.clientY,type:i,button:r.button},t.input.mouseDown&&t.input.mouseDown.done();let a=t.posAtCoords(JE(r));a&&(i=="singleClick"?t.input.mouseDown=new XPt(t,a,r,!!n):(i=="doubleClick"?GPt:KPt)(t,a.pos,a.inside,r)?r.preventDefault():Qd(t,"pointer"))};class Uje{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 XPt extends Uje{constructor(e,r,n,s){super(e),this.pos=r,this.event=n,this.flushed=s,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[zje],this.allowDefault=n.shiftKey;let i,a;if(r.inside>-1)i=e.state.doc.nodeAt(r.inside),a=r.inside;else{let d=e.state.doc.resolve(r.pos);i=d.parent,a=d.depth?d.before():0}const o=s?null:n.target,c=o?e.docView.nearestDesc(o,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:u}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof Ot&&u.from<=a&&u.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&wl&&!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()),Qd(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||sh(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let r=this.pos;this.view.state.doc!=this.startDoc&&(r=this.view.posAtCoords(JE(e))),this.updateAllowDefault(e),this.allowDefault||!r?Qd(this.view,"pointer"):qPt(this.view,r.pos,r.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ki&&this.mightDrag&&!this.mightDrag.node.isAtom||Ks&&!this.view.state.selection.visible&&Math.min(Math.abs(r.pos-this.view.state.selection.from),Math.abs(r.pos-this.view.state.selection.to))<=2)?(QE(this.view,qt.near(this.view.state.doc.resolve(r.pos))),e.preventDefault()):Qd(this.view,"pointer")}move(e){this.updateAllowDefault(e),Qd(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 JPt extends Uje{constructor(e,r){super(e),this.startSelection=r,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(),Qd(this.view,"pointer");let r=this.view.posAtCoords(JE(e)),n=r&&Bje(this.view,r.inside,!1);if(!n)return;let{doc:s}=this.view.state,i=this.startSelection,[a,o]=n.from<i.from?[i.to,n.from]:[i.from,n.to];QE(this.view,Bt.create(s,a,o))}}ba.touchstart=t=>{t.input.lastTouch=Date.now(),F7(t),Qd(t,"pointer")};ba.touchmove=t=>{t.input.lastTouch=Date.now(),Qd(t,"pointer")};ba.contextmenu=t=>F7(t);function Hje(t,e){return t.composing?!0:Ki&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const QPt=Jd?5e3:-1;wa.compositionstart=wa.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof Bt&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Ks&&xje&&ZPt(t)))t.markCursor=t.state.storedMarks||r.marks(),RO(t,!0),t.markCursor=null;else if(RO(t,!e.selection.empty),wl&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let n=t.domSelectionRange();for(let s=n.focusNode,i=n.focusOffset;s&&s.nodeType==1&&i!=0;){let a=i<0?s.lastChild:s.childNodes[i-1];if(!a)break;if(a.nodeType==3){let o=t.domSelection();o&&o.collapse(a,a.nodeValue.length);break}else s=a,i=-1}}t.input.composing=!0}Vje(t,QPt)};function ZPt(t){let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(!e||e.nodeType!=1||r>=e.childNodes.length)return!1;let n=e.childNodes[r];return n.nodeType==1&&n.contentEditable=="false"}wa.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++,Vje(t,20))};function Vje(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>RO(t),e))}function Wje(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function eOt(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=W2t(e.focusNode,e.focusOffset),n=q2t(e.focusNode,e.focusOffset);if(r&&n&&r!=n){let s=n.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(r==i||n==i)return i;if(!s||!s.isText(n.nodeValue))return n;if(t.input.compositionNode==n){let a=r.pmViewDesc;if(!(!a||!a.isText(r.nodeValue)))return n}}return r||n}function RO(t,e=!1){if(!(Jd&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Wje(t),e||t.docView&&t.docView.dirty){let r=I7(t),n=t.state.selection;return r&&!r.eq(n)?t.dispatch(t.state.tr.setSelection(r)):(t.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function tOt(t,e){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(e),r.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),n.removeAllRanges(),n.addRange(s),setTimeout(()=>{r.parentNode&&r.parentNode.removeChild(r),t.focus()},50)}const ok=Ya&&Op<15||Cw&&X2t<604;ba.copy=wa.cut=(t,e)=>{let r=e,n=t.state.selection,s=r.type=="cut";if(n.empty)return;let i=ok?null:r.clipboardData,a=n.content(),{dom:o,text:c}=M7(t,a);i?(r.preventDefault(),i.clearData(),i.setData("text/html",o.innerHTML),i.setData("text/plain",c)):tOt(t,o),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function rOt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function nOt(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,n=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),n.parentNode&&n.parentNode.removeChild(n),r?lk(t,n.value,null,s,e):lk(t,n.textContent,n.innerHTML,s,e)},50)}function lk(t,e,r,n,s){let i=Rje(t,e,r,n,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,s,i||vt.empty)))return!0;if(!i)return!1;let a=rOt(i),o=a?t.state.tr.replaceSelectionWith(a,n):t.state.tr.replaceSelection(i);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function qje(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}wa.paste=(t,e)=>{let r=e;if(t.composing&&!Jd)return;let n=ok?null:r.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&lk(t,qje(n),n.getData("text/html"),s,r)?r.preventDefault():nOt(t,r)};class Gje{constructor(e,r,n){this.slice=e,this.move=r,this.node=n}}const sOt=nl?"altKey":"ctrlKey";function Kje(t,e){let r;return t.someProp("dragCopies",n=>{r=r||n(e)}),r!=null?!r:!e[sOt]}ba.dragstart=(t,e)=>{let r=e,n=t.input.mouseDown;if(n&&n.done(),!r.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(JE(r)),a;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Ot?s.to-1:s.to))){if(n&&n.mightDrag)a=Ot.create(t.state.doc,n.mightDrag.pos);else if(r.target&&r.target.nodeType==1){let h=t.docView.nearestDesc(r.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(a=Ot.create(t.state.doc,h.posBefore))}}let o=(a||t.state.selection).content(),{dom:c,text:u,slice:d}=M7(t,o);(!r.dataTransfer.files.length||!Ks||yje>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(ok?"Text":"text/html",c.innerHTML),r.dataTransfer.effectAllowed="copyMove",ok||r.dataTransfer.setData("text/plain",u),t.dragging=new Gje(d,Kje(t,r),a)};ba.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};wa.dragover=wa.dragenter=(t,e)=>e.preventDefault();wa.drop=(t,e)=>{try{iOt(t,e,t.dragging)}finally{t.dragging=null}};function iOt(t,e,r){if(!e.dataTransfer)return;let n=t.posAtCoords(JE(e));if(!n)return;let s=t.state.doc.resolve(n.pos),i=r&&r.slice;i?t.someProp("transformPasted",p=>{i=p(i,t,!1)}):i=Rje(t,qje(e.dataTransfer),ok?null:e.dataTransfer.getData("text/html"),!1,s);let a=!!(r&&Kje(t,e));if(t.someProp("handleDrop",p=>p(t,e,i||vt.empty,a))){e.preventDefault();return}if(!i)return;e.preventDefault();let o=i?J_e(t.state.doc,s.pos,i):s.pos;o==null&&(o=s.pos);let c=t.state.tr;if(a){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(o),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,h=c.doc;if(d?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(h))return;let f=c.doc.resolve(u);if(d&&Ot.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new Ot(f));else{let p=c.mapping.map(o);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,x,y)=>p=y),c.setSelection(R7(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}ba.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())&&sh(t)},20))};ba.blur=(t,e)=>{let r=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),r.relatedTarget&&t.dom.contains(r.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};ba.beforeinput=(t,e)=>{if(Ks&&Jd&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:n}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=n||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,qm(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 wa)ba[t]=wa[t];function ck(t,e){if(t==e)return!0;for(let r in t)if(t[r]!==e[r])return!1;for(let r in e)if(!(r in t))return!1;return!0}class MO{constructor(e,r){this.toDOM=e,this.spec=r||Fy,this.side=this.spec.side||0}map(e,r,n,s){let{pos:i,deleted:a}=e.mapResult(r.from+s,this.side<0?-1:1);return a?null:new $i(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof MO&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ck(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Mp{constructor(e,r){this.attrs=e,this.spec=r||Fy}map(e,r,n,s){let i=e.map(r.from+s,this.spec.inclusiveStart?-1:1)-n,a=e.map(r.to+s,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new $i(i,a,this)}valid(e,r){return r.from<r.to}eq(e){return this==e||e instanceof Mp&&ck(this.attrs,e.attrs)&&ck(this.spec,e.spec)}static is(e){return e.type instanceof Mp}destroy(){}}class $7{constructor(e,r){this.attrs=e,this.spec=r||Fy}map(e,r,n,s){let i=e.mapResult(r.from+s,1);if(i.deleted)return null;let a=e.mapResult(r.to+s,-1);return a.deleted||a.pos<=i.pos?null:new $i(i.pos-n,a.pos-n,this)}valid(e,r){let{index:n,offset:s}=e.content.findIndex(r.from),i;return s==r.from&&!(i=e.child(n)).isText&&s+i.nodeSize==r.to}eq(e){return this==e||e instanceof $7&&ck(this.attrs,e.attrs)&&ck(this.spec,e.spec)}destroy(){}}class $i{constructor(e,r,n){this.from=e,this.to=r,this.type=n}copy(e,r){return new $i(e,r,this.type)}eq(e,r=0){return this.type.eq(e.type)&&this.from+r==e.from&&this.to+r==e.to}map(e,r,n){return this.type.map(e,this,r,n)}static widget(e,r,n){return new $i(e,e,new MO(r,n))}static inline(e,r,n,s){return new $i(e,r,new Mp(n,s))}static node(e,r,n,s){return new $i(e,r,new $7(n,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Mp}get widget(){return this.type instanceof MO}}const mv=[],Fy={};class bn{constructor(e,r){this.local=e.length?e:mv,this.children=r.length?r:mv}static create(e,r){return r.length?DO(r,e,0,Fy):Ri}find(e,r,n){let s=[];return this.findInner(e??0,r??1e9,s,0,n),s}findInner(e,r,n,s,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=r&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+s,o.to+s))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<r&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,r-o,n,s+o,i)}}map(e,r,n){return this==Ri||e.maps.length==0?this:this.mapInner(e,r,0,0,n||Fy)}mapInner(e,r,n,s,i){let a;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(e,n,s);c&&c.type.valid(r,c)?(a||(a=[])).push(c):i.onRemove&&i.onRemove(this.local[o].spec)}return this.children.length?aOt(this.children,a||[],e,r,n,s,i):a?new bn(a.sort($y),mv):Ri}add(e,r){return r.length?this==Ri?bn.create(e,r):this.addInner(e,r,0):this}addInner(e,r,n){let s,i=0;e.forEach((o,c)=>{let u=c+n,d;if(d=Xje(r,o,u)){for(s||(s=this.children.slice());i<s.length&&s[i]<c;)i+=3;s[i]==c?s[i+2]=s[i+2].addInner(o,d,u+1):s.splice(i,0,c,c+o.nodeSize,DO(d,o,u+1,Fy)),i+=3}});let a=Yje(i?Jje(r):r,-n);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||a.splice(o--,1);return new bn(a.length?this.local.concat(a).sort($y):this.local,s||this.children)}remove(e){return e.length==0||this==Ri?this:this.removeInner(e,0)}removeInner(e,r){let n=this.children,s=this.local;for(let i=0;i<n.length;i+=3){let a,o=n[i]+r,c=n[i+1]+r;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>o&&h.to<c&&(e[d]=null,(a||(a=[])).push(h));if(!a)continue;n==this.children&&(n=this.children.slice());let u=n[i+2].removeInner(a,o+1);u!=Ri?n[i+2]=u:(n.splice(i,3),i-=3)}if(s.length){for(let i=0,a;i<e.length;i++)if(a=e[i])for(let o=0;o<s.length;o++)s[o].eq(a,r)&&(s==this.local&&(s=this.local.slice()),s.splice(o--,1))}return n==this.children&&s==this.local?this:s.length||n.length?new bn(s,n):Ri}forChild(e,r){if(this==Ri)return this;if(r.isLeaf)return bn.empty;let n,s;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(n=this.children[o+2]);break}let i=e+1,a=i+r.content.size;for(let o=0;o<this.local.length;o++){let c=this.local[o];if(c.from<a&&c.to>i&&c.type instanceof Mp){let u=Math.max(i,c.from)-i,d=Math.min(a,c.to)-i;u<d&&(s||(s=[])).push(c.copy(u,d))}}if(s){let o=new bn(s.sort($y),mv);return n?new mf([o,n]):o}return n||Ri}eq(e){if(this==e)return!0;if(!(e instanceof bn)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let r=0;r<this.local.length;r++)if(!this.local[r].eq(e.local[r]))return!1;for(let r=0;r<this.children.length;r+=3)if(this.children[r]!=e.children[r]||this.children[r+1]!=e.children[r+1]||!this.children[r+2].eq(e.children[r+2]))return!1;return!0}locals(e){return B7(this.localsInner(e))}localsInner(e){if(this==Ri)return mv;if(e.inlineContent||!this.local.some(Mp.is))return this.local;let r=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Mp||r.push(this.local[n]);return r}forEachSet(e){e(this)}}bn.empty=new bn([],[]);bn.removeOverlap=B7;const Ri=bn.empty;class mf{constructor(e){this.members=e}map(e,r){const n=this.members.map(s=>s.map(e,r,Fy));return mf.from(n)}forChild(e,r){if(r.isLeaf)return bn.empty;let n=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,r);i!=Ri&&(i instanceof mf?n=n.concat(i.members):n.push(i))}return mf.from(n)}eq(e){if(!(e instanceof mf)||e.members.length!=this.members.length)return!1;for(let r=0;r<this.members.length;r++)if(!this.members[r].eq(e.members[r]))return!1;return!0}locals(e){let r,n=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!r)r=i;else{n&&(r=r.slice(),n=!1);for(let a=0;a<i.length;a++)r.push(i[a])}}return r?B7(n?r:r.sort($y)):mv}static from(e){switch(e.length){case 0:return Ri;case 1:return e[0];default:return new mf(e.every(r=>r instanceof bn)?e:e.reduce((r,n)=>r.concat(n instanceof bn?n:n.members),[]))}}forEachSet(e){for(let r=0;r<this.members.length;r++)this.members[r].forEachSet(e)}}function aOt(t,e,r,n,s,i,a){let o=t.slice();for(let u=0,d=i;u<r.maps.length;u++){let h=0;r.maps[u].forEach((f,p,m,g)=>{let x=g-m-(p-f);for(let y=0;y<o.length;y+=3){let v=o[y+1];if(v<0||f>v+d-h)continue;let b=o[y]+d-h;p>=b?o[y+1]=f<=b?-2:-1:f>=d&&x&&(o[y]+=x,o[y+1]+=x)}h+=x}),d=r.maps[u].map(d,-1)}let c=!1;for(let u=0;u<o.length;u+=3)if(o[u+1]<0){if(o[u+1]==-2){c=!0,o[u+1]=-1;continue}let d=r.map(t[u]+i),h=d-s;if(h<0||h>=n.content.size){c=!0;continue}let f=r.map(t[u+1]+i,-1),p=f-s,{index:m,offset:g}=n.content.findIndex(h),x=n.maybeChild(m);if(x&&g==h&&g+x.nodeSize==p){let y=o[u+2].mapInner(r,x,d+1,t[u]+i+1,a);y!=Ri?(o[u]=h,o[u+1]=p,o[u+2]=y):(o[u+1]=-2,c=!0)}else c=!0}if(c){let u=oOt(o,t,e,r,s,i,a),d=DO(u,n,0,a);e=d.local;for(let h=0;h<o.length;h+=3)o[h+1]<0&&(o.splice(h,3),h-=3);for(let h=0,f=0;h<d.children.length;h+=3){let p=d.children[h];for(;f<o.length&&o[f]<p;)f+=3;o.splice(f,0,d.children[h],d.children[h+1],d.children[h+2])}}return new bn(e.sort($y),o)}function Yje(t,e){if(!e||!t.length)return t;let r=[];for(let n=0;n<t.length;n++){let s=t[n];r.push(new $i(s.from+e,s.to+e,s.type))}return r}function oOt(t,e,r,n,s,i,a){function o(c,u){for(let d=0;d<c.local.length;d++){let h=c.local[d].map(n,s,u);h?r.push(h):a.onRemove&&a.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)o(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&o(t[c+2],e[c]+i+1);return r}function Xje(t,e,r){if(e.isLeaf)return null;let n=r+e.nodeSize,s=null;for(let i=0,a;i<t.length;i++)(a=t[i])&&a.from>r&&a.to<n&&((s||(s=[])).push(a),t[i]=null);return s}function Jje(t){let e=[];for(let r=0;r<t.length;r++)t[r]!=null&&e.push(t[r]);return e}function DO(t,e,r,n){let s=[],i=!1;e.forEach((o,c)=>{let u=Xje(t,o,c+r);if(u){i=!0;let d=DO(u,o,r+c+1,n);d!=Ri&&s.push(c,c+o.nodeSize,d)}});let a=Yje(i?Jje(t):t,-r).sort($y);for(let o=0;o<a.length;o++)a[o].type.valid(e,a[o])||(n.onRemove&&n.onRemove(a[o].spec),a.splice(o--,1));return a.length||s.length?new bn(a,s):Ri}function $y(t,e){return t.from-e.from||t.to-e.to}function B7(t){let e=t;for(let r=0;r<e.length-1;r++){let n=e[r];if(n.from!=n.to)for(let s=r+1;s<e.length;s++){let i=e[s];if(i.from==n.from){i.to!=n.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,n.to),lie(e,s+1,i.copy(n.to,i.to)));continue}else{i.from<n.to&&(e==t&&(e=t.slice()),e[r]=n.copy(n.from,i.from),lie(e,s,n.copy(i.from,n.to)));break}}}return e}function lie(t,e,r){for(;e<t.length&&$y(r,t[e])>0;)e++;t.splice(e,0,r)}function J3(t){let e=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=Ri&&e.push(n)}),t.cursorWrapper&&e.push(bn.create(t.state.doc,[t.cursorWrapper.deco])),mf.from(e)}const lOt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},cOt=Ya&&Op<=11;class uOt{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 dOt{constructor(e,r){this.view=e,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new uOt,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let s=0;s<n.length;s++)this.queue.push(n[s]);Ya&&Op<=11&&n.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Ki&&e.composing&&n.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),cOt&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,lOt)),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 r=0;r<e.length;r++)this.queue.push(e[r]);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(tie(this.view)){if(this.suppressingSelectionUpdates)return sh(this.view);if(Ya&&Op<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ux(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 r=new Set,n;for(let i=e.focusNode;i;i=Aw(i))r.add(i);for(let i=e.anchorNode;i;i=Aw(i))if(r.has(i)){n=i;break}let s=n&&this.view.docView.nearestDesc(n);if(s&&s.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]);let n=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&tie(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,c=[];if(e.editable)for(let d=0;d<r.length;d++){let h=this.registerMutation(r[d],c);h&&(i=i<0?h.from:Math.min(h.from,i),a=a<0?h.to:Math.max(h.to,a),h.typeOver&&(o=!0))}if(c.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Ks&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&r.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of c)if(d.nodeName=="BR"&&d.parentNode){let h=d.nextSibling;for(;h&&h.nodeType==1;){if(h.contentEditable=="false"){d.parentNode.removeChild(d);break}h=h.firstChild}}}else if(wl&&c.length){let d=c.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,f]=d;h.parentNode&&h.parentNode.parentNode==f.parentNode?f.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let f of d){let p=f.parentNode;p&&p.nodeName=="LI"&&(!h||pOt(e,h)!=p)&&f.remove()}}}let u=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&pD(n)&&(u=I7(e))&&u.eq(qt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,sh(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,a),hOt(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,mOt(e,c)),this.handleDOMChange(i,a,o,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||sh(e),this.currentSelection.set(n))}registerMutation(e,r){if(r.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let h=e.addedNodes[d];r.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Ya&&Op<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:f}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(s=h),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f)}let a=s&&s.parentNode==e.target?pi(s)+1:0,o=n.localPosFromDOM(e.target,a,-1),c=i&&i.parentNode==e.target?pi(i):e.target.childNodes.length,u=n.localPosFromDOM(e.target,c,1);return{from:o,to:u}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let cie=new WeakMap,uie=!1;function hOt(t){if(!cie.has(t)&&(cie.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=wl,uie)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."),uie=!0}}function die(t,e){let r=e.startContainer,n=e.startOffset,s=e.endContainer,i=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return ux(a.node,a.offset,s,i)&&([r,n,s,i]=[s,i,r,n]),{anchorNode:r,anchorOffset:n,focusNode:s,focusOffset:i}}function fOt(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return die(t,s)}let r;function n(s){s.preventDefault(),s.stopImmediatePropagation(),r=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",n,!0),r?die(t,r):null}function pOt(t,e){for(let r=e.parentNode;r&&r!=t.dom;r=r.parentNode){let n=t.docView.nearestDesc(r,!0);if(n&&n.node.isBlock)return r}return null}function mOt(t,e){var r;let{focusNode:n,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((r=i.parentNode)===null||r===void 0?void 0:r.nodeName)=="TR"){let a=i.nextSibling;for(;a&&a.nodeName!="TD"&&a.nodeName!="TH";)a=a.nextSibling;if(a){let o=a;for(;;){let c=o.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;o=c}o.insertBefore(i,o.firstChild),n==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function gOt(t,e,r){let{node:n,fromOffset:s,toOffset:i,from:a,to:o}=t.docView.parseRange(e,r),c=t.domSelectionRange(),u,d=c.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(u=[{node:d,offset:c.anchorOffset}],pD(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ks&&t.input.lastKeyCode===8)for(let x=i;x>s;x--){let y=n.childNodes[x-1],v=y.pmViewDesc;if(y.nodeName=="BR"&&!v){i=x;break}if(!v||v.size)break}let h=t.state.doc,f=t.someProp("domParser")||Tp.fromSchema(t.state.schema),p=h.resolve(a),m=null,g=f.parse(n,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:yOt,context:p});if(u&&u[0].pos!=null){let x=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=x),m={anchor:x+a,head:y+a}}return{doc:g,sel:m,from:a,to:o}}function yOt(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ki&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||Ki&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const xOt=/^(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 vOt(t,e,r,n,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let E=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,C=I7(t,E);if(C&&!t.state.selection.eq(C)){if(Ks&&Jd&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",M=>M(t,qm(13,"Enter"))))return;let A=t.state.tr.setSelection(C);E=="pointer"?A.setMeta("pointer",!0):E=="key"&&A.scrollIntoView(),i&&A.setMeta("composition",i),t.dispatch(A)}return}let a=t.state.doc.resolve(e),o=a.sharedDepth(r);e=a.before(o+1),r=t.state.doc.resolve(r).after(o+1);let c=t.state.selection,u=gOt(t,e,r),d=t.state.doc,h=d.slice(u.from,u.to),f,p;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,p="end"):(f=t.state.selection.from,p="start"),t.input.lastKeyCode=null;let m=SOt(h.content,u.doc.content,u.from,f,p);if(m&&t.input.domChangeCount++,(Cw&&t.input.lastIOSEnter>Date.now()-225||Jd)&&s.some(E=>E.nodeType==1&&!xOt.test(E.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",E=>E(t,qm(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(n&&c instanceof Bt&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let E=hie(t,t.state.doc,u.sel);if(E&&!E.eq(t.state.selection)){let C=t.state.tr.setSelection(E);i&&C.setMeta("composition",i),t.dispatch(C)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof Bt&&(m.start>t.state.selection.from&&m.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?m.start=t.state.selection.from:m.endA<t.state.selection.to&&m.endA>=t.state.selection.to-2&&t.state.selection.to<=u.to&&(m.endB+=t.state.selection.to-m.endA,m.endA=t.state.selection.to)),Ya&&Op<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>u.from&&u.doc.textBetween(m.start-u.from-1,m.start-u.from+1)==" "&&(m.start--,m.endA--,m.endB--);let g=u.doc.resolveNoCache(m.start-u.from),x=u.doc.resolveNoCache(m.endB-u.from),y=d.resolve(m.start),v=g.sameParent(x)&&g.parent.inlineContent&&y.end()>=m.endA;if((Cw&&t.input.lastIOSEnter>Date.now()-225&&(!v||s.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!v&&g.pos<u.doc.content.size&&(!g.sameParent(x)||!g.parent.inlineContent)&&g.pos<x.pos&&!/\S/.test(u.doc.textBetween(g.pos,x.pos,"","")))&&t.someProp("handleKeyDown",E=>E(t,qm(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&wOt(d,m.start,m.endA,g,x)&&t.someProp("handleKeyDown",E=>E(t,qm(8,"Backspace")))){Jd&&Ks&&t.domObserver.suppressSelectionUpdates();return}Ks&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),Jd&&!v&&g.start()!=x.start()&&x.parentOffset==0&&g.depth==x.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,x=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(E){return E(t,qm(13,"Enter"))})},20));let b=m.start,w=m.endA,S=E=>{let C=E||t.state.tr.replace(b,w,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let A=hie(t,C.doc,u.sel);A&&!(Ks&&t.composing&&A.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(A.head==b||A.head==C.mapping.map(w)-1)||Ya&&A.empty&&A.head==b)&&C.setSelection(A)}return i&&C.setMeta("composition",i),C.scrollIntoView()},k;if(v)if(g.pos==x.pos){Ya&&Op<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>sh(t),20));let E=S(t.state.tr.delete(b,w)),C=d.resolve(m.start).marksAcross(d.resolve(m.endA));C&&E.ensureMarks(C),t.dispatch(E)}else if(m.endA==m.endB&&(k=bOt(g.parent.content.cut(g.parentOffset,x.parentOffset),y.parent.content.cut(y.parentOffset,m.endA-y.start())))){let E=S(t.state.tr);k.type=="add"?E.addMark(b,w,k.mark):E.removeMark(b,w,k.mark),t.dispatch(E)}else if(g.parent.child(g.index()).isText&&g.index()==x.index()-(x.textOffset?0:1)){let E=g.parent.textBetween(g.parentOffset,x.parentOffset),C=()=>S(t.state.tr.insertText(E,b,w));t.someProp("handleTextInput",A=>A(t,b,w,E,C))||t.dispatch(C())}else t.dispatch(S());else t.dispatch(S())}function hie(t,e,r){return Math.max(r.anchor,r.head)>e.content.size?null:R7(t,e.resolve(r.anchor),e.resolve(r.head))}function bOt(t,e){let r=t.firstChild.marks,n=e.firstChild.marks,s=r,i=n,a,o,c;for(let d=0;d<n.length;d++)s=n[d].removeFromSet(s);for(let d=0;d<r.length;d++)i=r[d].removeFromSet(i);if(s.length==1&&i.length==0)o=s[0],a="add",c=d=>d.mark(o.addToSet(d.marks));else if(s.length==0&&i.length==1)o=i[0],a="remove",c=d=>d.mark(o.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(Qe.from(u).eq(t))return{mark:o,type:a}}function wOt(t,e,r,n,s){if(r-e<=s.pos-n.pos||Q3(n,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!n.parent.isTextblock){let o=i.nodeAfter;return o!=null&&r==e+o.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let a=t.resolve(Q3(i,!0,!0));return!a.parent.isTextblock||a.pos>r||Q3(a,!0,!1)<r?!1:n.parent.content.cut(n.parentOffset).eq(a.parent.content)}function Q3(t,e,r){let n=t.depth,s=e?t.end():t.pos;for(;n>0&&(e||t.indexAfter(n)==t.node(n).childCount);)n--,s++,e=!1;if(r){let i=t.node(n).maybeChild(t.indexAfter(n));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function SOt(t,e,r,n,s){let i=t.findDiffStart(e,r),a=r+t.size,o=r+e.size;if(i==null)return null;let{a:c,b:u}=t.findDiffEnd(e,a,o);if(s=="end"){let d=Math.max(0,i-Math.min(c,u));n-=c+d-i}if(c<i&&a<o){let d=n<=i&&n>=c?i-n:0;i-=d,u=i+(u-c),c=i}else if(u<i){let d=n<=i&&n>=u?i-n:0;i-=d,c=i+(c-u),u=i}return{start:i,endA:c,endB:u}}class Qje{constructor(e,r){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 FPt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(yie),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=mie(this),pie(this),this.nodeViews=gie(this),this.docView=Yse(this.state.doc,fie(this),J3(this),this.dom,this),this.domObserver=new dOt(this,(n,s,i,a)=>vOt(this,n,s,i,a)),this.domObserver.start(),$Pt(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 r in e)this._props[r]=e[r];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&cU(this);let r=this._props;this._props=e,e.plugins&&(e.plugins.forEach(yie),this.directPlugins=e.plugins),this.updateStateInner(e.state,r)}setProps(e){let r={};for(let n in this._props)r[n]=this._props[n];r.state=this.state;for(let n in e)r[n]=e[n];this.update(r)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,r){var n;let s=this.state,i=!1,a=!1;e.storedMarks&&this.composing&&(Wje(this),a=!0),this.state=e;let o=s.plugins!=e.plugins||this._props.plugins!=r.plugins;if(o||this._props.plugins!=r.plugins||this._props.nodeViews!=r.nodeViews){let p=gie(this);jOt(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(o||r.handleDOMEvents!=this._props.handleDOMEvents)&&cU(this),this.editable=mie(this),pie(this);let c=J3(this),u=fie(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",h=i||!this.docView.matchesNode(e.doc,u,c);(h||!e.selection.eq(s.selection))&&(a=!0);let f=d=="preserve"&&a&&this.dom.style.overflowAnchor==null&&Z2t(this);if(a){this.domObserver.stop();let p=h&&(Ya||Ks)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&_Ot(s.selection,e.selection);if(h){let g=Ks?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=eOt(this)),(i||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Yse(e.doc,u,c,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}let m=this.input.mouseDown;p||!(m&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&_Pt(this)&&m.delaySelUpdate())?sh(this,p):(Pje(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((n=this.dragging)===null||n===void 0)&&n.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&ePt(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",r=>r(this)))if(this.state.selection instanceof Ot){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&Hse(this,r.getBoundingClientRect(),e)}else Hse(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 r=0;r<this.directPlugins.length;r++){let n=this.directPlugins[r];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let r=0;r<this.state.plugins.length;r++){let n=this.state.plugins[r];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let r=0;r<this.pluginViews.length;r++){let n=this.pluginViews[r];n.update&&n.update(this,e)}}updateDraggedNode(e,r){let n=e.node,s=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)s=n.from;else{let i=n.from+(this.state.doc.content.size-r.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==n.node&&(s=i)}this.dragging=new Gje(e.slice,e.move,s<0?void 0:Ot.create(this.state.doc,s))}someProp(e,r){let n=this._props&&this._props[e],s;if(n!=null&&(s=r?r(n):n))return s;for(let a=0;a<this.directPlugins.length;a++){let o=this.directPlugins[a].props[e];if(o!=null&&(s=r?r(o):o))return s}let i=this.state.plugins;if(i)for(let a=0;a<i.length;a++){let o=i[a].props[e];if(o!=null&&(s=r?r(o):o))return s}}hasFocus(){if(Ya){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&&tPt(this.dom),sh(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let r=this.dom.parentNode;r;r=r.parentNode)if(r.nodeType==9||r.nodeType==11&&r.host)return r.getSelection||(Object.getPrototypeOf(r).getSelection=()=>r.ownerDocument.getSelection()),this._root=r}return e||document}updateRoot(){this._root=null}posAtCoords(e){return aPt(this,e)}coordsAtPos(e,r=1){return _je(this,e,r)}domAtPos(e,r=0){return this.docView.domFromPos(e,r)}nodeDOM(e){let r=this.docView.descAt(e);return r?r.nodeDOM:null}posAtDOM(e,r,n=-1){let s=this.docView.posFromDOM(e,r,n);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,r){return dPt(this,r||this.state,e)}pasteHTML(e,r){return lk(this,"",e,!1,r||new ClipboardEvent("paste"))}pasteText(e,r){return lk(this,e,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(e){return M7(this,e)}destroy(){this.docView&&(BPt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],J3(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,H2t())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return UPt(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ki&&this.root.nodeType===11&&K2t(this.dom.ownerDocument)==this.dom&&fOt(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Qje.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function fie(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",r=>{if(typeof r=="function"&&(r=r(t.state)),r)for(let n in r)n=="class"?e.class+=" "+r[n]:n=="style"?e.style=(e.style?e.style+";":"")+r[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(r[n]))}),e.translate||(e.translate="no"),[$i.node(0,t.state.doc.content.size,e)]}function pie(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:$i.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function mie(t){return!t.someProp("editable",e=>e(t.state)===!1)}function _Ot(t,e){let r=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(r)!=e.$anchor.start(r)}function gie(t){let e=Object.create(null);function r(n){for(let s in n)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=n[s])}return t.someProp("nodeViews",r),t.someProp("markViews",r),e}function jOt(t,e){let r=0,n=0;for(let s in t){if(t[s]!=e[s])return!0;r++}for(let s in e)n++;return r!=n}function yie(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 Kp={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:"'"},LO={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},kOt=typeof navigator<"u"&&/Mac/.test(navigator.platform),NOt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var mi=0;mi<10;mi++)Kp[48+mi]=Kp[96+mi]=String(mi);for(var mi=1;mi<=24;mi++)Kp[mi+111]="F"+mi;for(var mi=65;mi<=90;mi++)Kp[mi]=String.fromCharCode(mi+32),LO[mi]=String.fromCharCode(mi);for(var Z3 in Kp)LO.hasOwnProperty(Z3)||(LO[Z3]=Kp[Z3]);function EOt(t){var e=kOt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||NOt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!e&&t.key||(t.shiftKey?LO:Kp)[t.keyCode]||t.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}const AOt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),COt=typeof navigator<"u"&&/Win/.test(navigator.platform);function TOt(t){let e=t.split(/-(?!$)/),r=e[e.length-1];r=="Space"&&(r=" ");let n,s,i,a;for(let o=0;o<e.length-1;o++){let c=e[o];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))n=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))AOt?a=!0:s=!0;else throw new Error("Unrecognized modifier name: "+c)}return n&&(r="Alt-"+r),s&&(r="Ctrl-"+r),a&&(r="Meta-"+r),i&&(r="Shift-"+r),r}function POt(t){let e=Object.create(null);for(let r in t)e[TOt(r)]=t[r];return e}function eF(t,e,r=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),r&&e.shiftKey&&(t="Shift-"+t),t}function OOt(t){return new fn({props:{handleKeyDown:Zje(t)}})}function Zje(t){let e=POt(t);return function(r,n){let s=EOt(n),i,a=e[eF(s,n)];if(a&&a(r.state,r.dispatch,r))return!0;if(s.length==1&&s!=" "){if(n.shiftKey){let o=e[eF(s,n,!1)];if(o&&o(r.state,r.dispatch,r))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(COt&&n.ctrlKey&&n.altKey)&&(i=Kp[n.keyCode])&&i!=s){let o=e[eF(i,n)];if(o&&o(r.state,r.dispatch,r))return!0}}return!1}}var IOt=Object.defineProperty,z7=(t,e)=>{for(var r in e)IOt(t,r,{get:e[r],enumerable:!0})};function gD(t){const{state:e,transaction:r}=t;let{selection:n}=r,{doc:s}=r,{storedMarks:i}=r;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 n},get doc(){return s},get tr(){return n=r.selection,s=r.doc,i=r.storedMarks,r}}}var yD=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:r}=this,{view:n}=e,{tr:s}=r,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([a,o])=>[a,(...u)=>{const d=o(...u)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&n.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:r,editor:n,state:s}=this,{view:i}=n,a=[],o=!!t,c=t||s.tr,u=()=>(!o&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(c),a.every(h=>h===!0)),d={...Object.fromEntries(Object.entries(r).map(([h,f])=>[h,(...m)=>{const g=this.buildProps(c,e),x=f(...m)(g);return a.push(x),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:r}=this,n=!1,s=t||r.tr,i=this.buildProps(s,n);return{...Object.fromEntries(Object.entries(e).map(([o,c])=>[o,(...u)=>c(...u)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,n)}}buildProps(t,e=!0){const{rawCommands:r,editor:n,state:s}=this,{view:i}=n,a={tr:t,editor:n,view:i,state:gD({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([o,c])=>[o,(...u)=>c(...u)(a)]))}};return a}},eke={};z7(eke,{blur:()=>ROt,clearContent:()=>MOt,clearNodes:()=>DOt,command:()=>LOt,createParagraphNear:()=>FOt,cut:()=>$Ot,deleteCurrentNode:()=>BOt,deleteNode:()=>zOt,deleteRange:()=>UOt,deleteSelection:()=>WOt,enter:()=>qOt,exitCode:()=>GOt,extendMarkRange:()=>KOt,first:()=>YOt,focus:()=>JOt,forEach:()=>QOt,insertContent:()=>ZOt,insertContentAt:()=>rIt,joinBackward:()=>iIt,joinDown:()=>sIt,joinForward:()=>aIt,joinItemBackward:()=>oIt,joinItemForward:()=>lIt,joinTextblockBackward:()=>cIt,joinTextblockForward:()=>uIt,joinUp:()=>nIt,keyboardShortcut:()=>hIt,lift:()=>fIt,liftEmptyBlock:()=>pIt,liftListItem:()=>mIt,newlineInCode:()=>gIt,resetAttributes:()=>yIt,scrollIntoView:()=>xIt,selectAll:()=>vIt,selectNodeBackward:()=>bIt,selectNodeForward:()=>wIt,selectParentNode:()=>SIt,selectTextblockEnd:()=>_It,selectTextblockStart:()=>jIt,setContent:()=>kIt,setMark:()=>qIt,setMeta:()=>GIt,setNode:()=>KIt,setNodeSelection:()=>YIt,setTextDirection:()=>XIt,setTextSelection:()=>JIt,sinkListItem:()=>QIt,splitBlock:()=>ZIt,splitListItem:()=>eRt,toggleList:()=>rRt,toggleMark:()=>nRt,toggleNode:()=>sRt,toggleWrap:()=>iRt,undoInputRule:()=>aRt,unsetAllMarks:()=>oRt,unsetMark:()=>lRt,unsetTextDirection:()=>cRt,updateAttributes:()=>uRt,wrapIn:()=>dRt,wrapInList:()=>hRt});var ROt=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var r;t.isDestroyed||(e.dom.blur(),(r=window==null?void 0:window.getSelection())==null||r.removeAllRanges())}),!0),MOt=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),DOt=()=>({state:t,tr:e,dispatch:r})=>{const{selection:n}=e,{ranges:s}=n;return r&&s.forEach(({$from:i,$to:a})=>{t.doc.nodesBetween(i.pos,a.pos,(o,c)=>{if(o.type.isText)return;const{doc:u,mapping:d}=e,h=u.resolve(d.map(c)),f=u.resolve(d.map(c+o.nodeSize)),p=h.blockRange(f);if(!p)return;const m=g1(p);if(o.type.isTextblock){const{defaultType:g}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(p.start,g)}(m||m===0)&&e.lift(p,m)})}),!0},LOt=t=>e=>t(e),FOt=()=>({state:t,dispatch:e})=>C2t(t,e),$Ot=(t,e)=>({editor:r,tr:n})=>{const{state:s}=r,i=s.doc.slice(t.from,t.to);n.deleteRange(t.from,t.to);const a=n.mapping.map(e);return n.insert(a,i.content),n.setSelection(new Bt(n.doc.resolve(Math.max(a-1,0)))),!0},BOt=()=>({tr:t,dispatch:e})=>{const{selection:r}=t,n=r.$anchor.node();if(n.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===n.type){if(e){const o=s.before(i),c=s.after(i);t.delete(o,c).scrollIntoView()}return!0}return!1};function ms(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 zOt=t=>({tr:e,state:r,dispatch:n})=>{const s=ms(t,r.schema),i=e.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===s){if(n){const c=i.before(a),u=i.after(a);e.delete(c,u).scrollIntoView()}return!0}return!1},UOt=t=>({tr:e,dispatch:r})=>{const{from:n,to:s}=t;return r&&e.delete(n,s),!0},HOt=t=>t.content?/^text(\*|\+)/.test(t.content):!1,xie=(t,e,r)=>{if(!t.parent.isInline||r==="left"&&t.pos>t.start()||r==="right"&&t.pos<t.end())return t.pos;const n=e.nodes[t.parent.type.name].spec;return HOt(n)?r==="left"?t.start()-1:t.end()+1:t.pos},VOt=(t,e,r)=>{const n=xie(t,r,"left"),s=xie(e,r,"right");return{from:n,to:s}},WOt=()=>({state:t,dispatch:e})=>{const{$from:r,$to:n}=t.selection;if(t.selection.empty)return!1;const{from:s,to:i}=VOt(r,n,t.schema);return e&&(t.tr.deleteRange(s,i).scrollIntoView(),e(t.tr)),!0},qOt=()=>({commands:t})=>t.keyboardShortcut("Enter"),GOt=()=>({state:t,dispatch:e})=>A2t(t,e);function U7(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function FO(t,e,r={strict:!0}){const n=Object.keys(e);return n.length?n.every(s=>r.strict?e[s]===t[s]:U7(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function tke(t,e,r={}){return t.find(n=>n.type===e&&FO(Object.fromEntries(Object.keys(r).map(s=>[s,n.attrs[s]])),r))}function vie(t,e,r={}){return!!tke(t,e,r)}function H7(t,e,r){if(!t||!e)return;let n=t.parent.childAfter(t.parentOffset);if((!n.node||!n.node.marks.some(u=>u.type===e))&&(n=t.parent.childBefore(t.parentOffset)),!n.node||!n.node.marks.some(u=>u.type===e))return;if(!r){const u=n.node.marks.find(d=>d.type===e);u&&(r=u.attrs)}if(!tke([...n.node.marks],e,r))return;let i=n.index,a=t.start()+n.offset,o=i+1,c=a+n.node.nodeSize;for(;i>0&&vie([...t.parent.child(i-1).marks],e,r);)i-=1,a-=t.parent.child(i).nodeSize;for(;o<t.parent.childCount&&vie([...t.parent.child(o).marks],e,r);)c+=t.parent.child(o).nodeSize,o+=1;return{from:a,to:c}}function Lh(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 KOt=(t,e)=>({tr:r,state:n,dispatch:s})=>{const i=Lh(t,n.schema),{doc:a,selection:o}=r,{$from:c,from:u,to:d}=o;if(s){const h=H7(c,i,e);if(h&&h.from<=u&&h.to>=d){const f=Bt.create(a,h.from,h.to);r.setSelection(f)}}return!0},YOt=t=>e=>{const r=typeof t=="function"?t(e):t;for(let n=0;n<r.length;n+=1)if(r[n](e))return!0;return!1};function rke(t){return t instanceof Bt}function cg(t=0,e=0,r=0){return Math.min(Math.max(t,e),r)}function nke(t,e=null){if(!e)return null;const r=qt.atStart(t),n=qt.atEnd(t);if(e==="start"||e===!0)return r;if(e==="end")return n;const s=r.from,i=n.to;return e==="all"?Bt.create(t,cg(0,s,i),cg(t.content.size,s,i)):Bt.create(t,cg(e,s,i),cg(e,s,i))}function bie(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function $O(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function XOt(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var JOt=(t=null,e={})=>({editor:r,view:n,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const a=()=>{($O()||bie())&&n.dom.focus(),XOt()&&!$O()&&!bie()&&n.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{r.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&r.commands.scrollIntoView())})};try{if(n.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!rke(r.state.selection))return a(),!0;const o=nke(s.doc,t)||r.state.selection,c=r.state.selection.eq(o);return i&&(c||s.setSelection(o),c&&s.storedMarks&&s.setStoredMarks(s.storedMarks),a()),!0},QOt=(t,e)=>r=>t.every((n,s)=>e(n,{...r,index:s})),ZOt=(t,e)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,e),ske=t=>{const e=t.childNodes;for(let r=e.length-1;r>=0;r-=1){const n=e[r];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?t.removeChild(n):n.nodeType===1&&ske(n)}return t};function PC(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>`,r=new window.DOMParser().parseFromString(e,"text/html").body;return ske(r)}function uk(t,e,r){if(t instanceof Cp||t instanceof Qe)return t;r={slice:!0,parseOptions:{},...r};const n=typeof t=="object"&&t!==null,s=typeof t=="string";if(n)try{if(Array.isArray(t)&&t.length>0)return Qe.fromArray(t.map(o=>e.nodeFromJSON(o)));const a=e.nodeFromJSON(t);return r.errorOnInvalidContent&&a.check(),a}catch(i){if(r.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),uk("",e,r)}if(s){if(r.errorOnInvalidContent){let a=!1,o="";const c=new B_e({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:u=>(a=!0,o=typeof u=="string"?u:u.outerHTML,null)}]}})});if(r.slice?Tp.fromSchema(c).parseSlice(PC(t),r.parseOptions):Tp.fromSchema(c).parse(PC(t),r.parseOptions),r.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const i=Tp.fromSchema(e);return r.slice?i.parseSlice(PC(t),r.parseOptions).content:i.parse(PC(t),r.parseOptions)}return uk("",e,r)}function eIt(t,e,r){const n=t.steps.length-1;if(n<e)return;const s=t.steps[n];if(!(s instanceof Cl||s instanceof Qa))return;const i=t.mapping.maps[n];let a=0;i.forEach((o,c,u,d)=>{a===0&&(a=d)}),t.setSelection(qt.near(t.doc.resolve(a),r))}var tIt=t=>!("type"in t),rIt=(t,e,r)=>({tr:n,dispatch:s,editor:i})=>{var a;if(s){r={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let o;const c=x=>{i.emit("contentError",{editor:i,error:x,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{uk(e,i.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(x){c(x)}try{o=uk(e,i.schema,{parseOptions:u,errorOnInvalidContent:(a=r.errorOnInvalidContent)!=null?a:i.options.enableContentCheck})}catch(x){return c(x),!1}let{from:d,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,p=!0;if((tIt(o)?o:[o]).forEach(x=>{x.check(),f=f?x.isText&&x.marks.length===0:!1,p=p?x.isBlock:!1}),d===h&&p){const{parent:x}=n.doc.resolve(d);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(d-=1,h+=1)}let g;if(f){if(Array.isArray(e))g=e.map(x=>x.text||"").join("");else if(e instanceof Qe){let x="";e.forEach(y=>{y.text&&(x+=y.text)}),g=x}else typeof e=="object"&&e&&e.text?g=e.text:g=e;n.insertText(g,d,h)}else{g=o;const x=n.doc.resolve(d),y=x.node(),v=x.parentOffset===0,b=y.isText||y.isTextblock,w=y.content.size>0;v&&b&&w&&p&&(d=Math.max(0,d-1)),n.replaceWith(d,h,g)}r.updateSelection&&eIt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:d,text:g}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:d,text:g})}return!0},nIt=()=>({state:t,dispatch:e})=>j2t(t,e),sIt=()=>({state:t,dispatch:e})=>k2t(t,e),iIt=()=>({state:t,dispatch:e})=>x2t(t,e),aIt=()=>({state:t,dispatch:e})=>S2t(t,e),oIt=()=>({state:t,dispatch:e,tr:r})=>{try{const n=hD(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),e&&e(r),!0)}catch{return!1}},lIt=()=>({state:t,dispatch:e,tr:r})=>{try{const n=hD(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),e&&e(r),!0)}catch{return!1}},cIt=()=>({state:t,dispatch:e})=>v2t(t,e),uIt=()=>({state:t,dispatch:e})=>b2t(t,e);function ike(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function dIt(t){const e=t.split(/-(?!$)/);let r=e[e.length-1];r==="Space"&&(r=" ");let n,s,i,a;for(let o=0;o<e.length-1;o+=1){const c=e[o];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))n=!0;else if(/^(c|ctrl|control)$/i.test(c))s=!0;else if(/^s(hift)?$/i.test(c))i=!0;else if(/^mod$/i.test(c))$O()||ike()?a=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return n&&(r=`Alt-${r}`),s&&(r=`Ctrl-${r}`),a&&(r=`Meta-${r}`),i&&(r=`Shift-${r}`),r}var hIt=t=>({editor:e,view:r,tr:n,dispatch:s})=>{const i=dIt(t).split(/-(?!$)/),a=i.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),o=new KeyboardEvent("keydown",{key:a==="Space"?" ":a,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{r.someProp("handleKeyDown",u=>u(r,o))});return c==null||c.steps.forEach(u=>{const d=u.map(n.mapping);d&&s&&n.maybeStep(d)}),!0};function Yp(t,e,r={}){const{from:n,to:s,empty:i}=t.selection,a=e?ms(e,t.schema):null,o=[];t.doc.nodesBetween(n,s,(h,f)=>{if(h.isText)return;const p=Math.max(n,f),m=Math.min(s,f+h.nodeSize);o.push({node:h,from:p,to:m})});const c=s-n,u=o.filter(h=>a?a.name===h.node.type.name:!0).filter(h=>FO(h.node.attrs,r,{strict:!1}));return i?!!u.length:u.reduce((h,f)=>h+f.to-f.from,0)>=c}var fIt=(t,e={})=>({state:r,dispatch:n})=>{const s=ms(t,r.schema);return Yp(r,s,e)?N2t(r,n):!1},pIt=()=>({state:t,dispatch:e})=>T2t(t,e),mIt=t=>({state:e,dispatch:r})=>{const n=ms(t,e.schema);return $2t(n)(e,r)},gIt=()=>({state:t,dispatch:e})=>E2t(t,e);function xD(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function wie(t,e){const r=typeof e=="string"?[e]:e;return Object.keys(t).reduce((n,s)=>(r.includes(s)||(n[s]=t[s]),n),{})}var yIt=(t,e)=>({tr:r,state:n,dispatch:s})=>{let i=null,a=null;const o=xD(typeof t=="string"?t:t.name,n.schema);if(!o)return!1;o==="node"&&(i=ms(t,n.schema)),o==="mark"&&(a=Lh(t,n.schema));let c=!1;return r.selection.ranges.forEach(u=>{n.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,h)=>{i&&i===d.type&&(c=!0,s&&r.setNodeMarkup(h,void 0,wie(d.attrs,e))),a&&d.marks.length&&d.marks.forEach(f=>{a===f.type&&(c=!0,s&&r.addMark(h,h+d.nodeSize,a.create(wie(f.attrs,e))))})})}),c},xIt=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),vIt=()=>({tr:t,dispatch:e})=>{if(e){const r=new Pp(t.doc);t.setSelection(r)}return!0},bIt=()=>({state:t,dispatch:e})=>w2t(t,e),wIt=()=>({state:t,dispatch:e})=>_2t(t,e),SIt=()=>({state:t,dispatch:e})=>P2t(t,e),_It=()=>({state:t,dispatch:e})=>R2t(t,e),jIt=()=>({state:t,dispatch:e})=>I2t(t,e);function uU(t,e,r={},n={}){return uk(t,e,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}var kIt=(t,{errorOnInvalidContent:e,emitUpdate:r=!0,parseOptions:n={}}={})=>({editor:s,tr:i,dispatch:a,commands:o})=>{const{doc:c}=i;if(n.preserveWhitespace!=="full"){const u=uU(t,s.schema,n,{errorOnInvalidContent:e??s.options.enableContentCheck});return a&&i.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!r),!0}return a&&i.setMeta("preventUpdate",!r),o.insertContentAt({from:0,to:c.content.size},t,{parseOptions:n,errorOnInvalidContent:e??s.options.enableContentCheck})};function ake(t,e){const r=Lh(e,t.schema),{from:n,to:s,empty:i}=t.selection,a=[];i?(t.storedMarks&&a.push(...t.storedMarks),a.push(...t.selection.$head.marks())):t.doc.nodesBetween(n,s,c=>{a.push(...c.marks)});const o=a.find(c=>c.type.name===r.name);return o?{...o.attrs}:{}}function oke(t,e){const r=new sje(t);return e.forEach(n=>{n.steps.forEach(s=>{r.step(s)})}),r}function NIt(t){for(let e=0;e<t.edgeCount;e+=1){const{type:r}=t.edge(e);if(r.isTextblock&&!r.hasRequiredAttrs())return r}return null}function EIt(t,e,r){const n=[];return t.nodesBetween(e.from,e.to,(s,i)=>{r(s)&&n.push({node:s,pos:i})}),n}function AIt(t,e){for(let r=t.depth;r>0;r-=1){const n=t.node(r);if(e(n))return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:n}}}function vD(t){return e=>AIt(e.$from,t)}function _t(t,e,r){return t.config[e]===void 0&&t.parent?_t(t.parent,e,r):typeof t.config[e]=="function"?t.config[e].bind({...r,parent:t.parent?_t(t.parent,e,r):null}):t.config[e]}function V7(t){return t.map(e=>{const r={name:e.name,options:e.options,storage:e.storage},n=_t(e,"addExtensions",r);return n?[e,...V7(n())]:e}).flat(10)}function W7(t,e){const r=Px.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(r),s.innerHTML}function lke(t){return typeof t=="function"}function kr(t,e=void 0,...r){return lke(t)?e?t.bind(e)(...r):t(...r):t}function CIt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Tw(t){const e=t.filter(s=>s.type==="extension"),r=t.filter(s=>s.type==="node"),n=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:r,markExtensions:n}}function cke(t){const e=[],{nodeExtensions:r,markExtensions:n}=Tw(t),s=[...r,...n],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},a=r.filter(u=>u.name!=="text").map(u=>u.name),o=n.map(u=>u.name),c=[...a,...o];return t.forEach(u=>{const d={name:u.name,options:u.options,storage:u.storage,extensions:s},h=_t(u,"addGlobalAttributes",d);if(!h)return;h().forEach(p=>{let m;Array.isArray(p.types)?m=p.types:p.types==="*"?m=c:p.types==="nodes"?m=a:p.types==="marks"?m=o:m=[],m.forEach(g=>{Object.entries(p.attributes).forEach(([x,y])=>{e.push({type:g,name:x,attribute:{...i,...y}})})})})}),s.forEach(u=>{const d={name:u.name,options:u.options,storage:u.storage},h=_t(u,"addAttributes",d);if(!h)return;const f=h();Object.entries(f).forEach(([p,m])=>{const g={...i,...m};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:u.name,name:p,attribute:g})})}),e}function TIt(t){const e=[];let r="",n=!1,s=!1,i=0;const a=t.length;for(let o=0;o<a;o+=1){const c=t[o];if(c==="'"&&!s){n=!n,r+=c;continue}if(c==='"'&&!n){s=!s,r+=c;continue}if(!n&&!s){if(c==="("){i+=1,r+=c;continue}if(c===")"&&i>0){i-=1,r+=c;continue}if(c===";"&&i===0){e.push(r),r="";continue}}r+=c}return r&&e.push(r),e}function Sie(t){const e=[],r=TIt(t||""),n=r.length;for(let s=0;s<n;s+=1){const i=r[s],a=i.indexOf(":");if(a===-1)continue;const o=i.slice(0,a).trim(),c=i.slice(a+1).trim();o&&c&&e.push([o,c])}return e}function Ps(...t){return t.filter(e=>!!e).reduce((e,r)=>{const n={...e};return Object.entries(r).forEach(([s,i])=>{if(!n[s]){n[s]=i;return}if(s==="class"){const o=i?String(i).split(" "):[],c=n[s]?n[s].split(" "):[],u=o.filter(d=>!c.includes(d));n[s]=[...c,...u].join(" ")}else if(s==="style"){const o=new Map([...Sie(n[s]),...Sie(i)]);n[s]=Array.from(o.entries()).map(([c,u])=>`${c}: ${u}`).join("; ")}else n[s]=i}),n},{})}function dk(t,e){return e.filter(r=>r.type===t.type.name).filter(r=>r.attribute.rendered).map(r=>r.attribute.renderHTML?r.attribute.renderHTML(t.attrs)||{}:{[r.name]:t.attrs[r.name]}).reduce((r,n)=>Ps(r,n),{})}function PIt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function _ie(t,e){return"style"in t?t:{...t,getAttrs:r=>{const n=t.getAttrs?t.getAttrs(r):t.attrs;if(n===!1)return!1;const s=e.reduce((i,a)=>{const o=a.attribute.parseHTML?a.attribute.parseHTML(r):PIt(r.getAttribute(a.name));return o==null?i:{...i,[a.name]:o}},{});return{...n,...s}}}}function jie(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>e==="attrs"&&CIt(r)?!1:r!=null))}function kie(t){var e,r;const n={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(n.default=t.attribute.default),((r=t==null?void 0:t.attribute)==null?void 0:r.validate)!==void 0&&(n.validate=t.attribute.validate),[t.name,n]}function OIt(t,e){var r;const n=cke(t),{nodeExtensions:s,markExtensions:i}=Tw(t),a=(r=s.find(u=>_t(u,"topNode")))==null?void 0:r.name,o=Object.fromEntries(s.map(u=>{const d=n.filter(y=>y.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},f=t.reduce((y,v)=>{const b=_t(v,"extendNodeSchema",h);return{...y,...b?b(u):{}}},{}),p=jie({...f,content:kr(_t(u,"content",h)),marks:kr(_t(u,"marks",h)),group:kr(_t(u,"group",h)),inline:kr(_t(u,"inline",h)),atom:kr(_t(u,"atom",h)),selectable:kr(_t(u,"selectable",h)),draggable:kr(_t(u,"draggable",h)),code:kr(_t(u,"code",h)),whitespace:kr(_t(u,"whitespace",h)),linebreakReplacement:kr(_t(u,"linebreakReplacement",h)),defining:kr(_t(u,"defining",h)),isolating:kr(_t(u,"isolating",h)),attrs:Object.fromEntries(d.map(kie))}),m=kr(_t(u,"parseHTML",h));m&&(p.parseDOM=m.map(y=>_ie(y,d)));const g=_t(u,"renderHTML",h);g&&(p.toDOM=y=>g({node:y,HTMLAttributes:dk(y,d)}));const x=_t(u,"renderText",h);return x&&(p.toText=x),[u.name,p]})),c=Object.fromEntries(i.map(u=>{const d=n.filter(x=>x.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},f=t.reduce((x,y)=>{const v=_t(y,"extendMarkSchema",h);return{...x,...v?v(u):{}}},{}),p=jie({...f,inclusive:kr(_t(u,"inclusive",h)),excludes:kr(_t(u,"excludes",h)),group:kr(_t(u,"group",h)),spanning:kr(_t(u,"spanning",h)),code:kr(_t(u,"code",h)),attrs:Object.fromEntries(d.map(kie))}),m=kr(_t(u,"parseHTML",h));m&&(p.parseDOM=m.map(x=>_ie(x,d)));const g=_t(u,"renderHTML",h);return g&&(p.toDOM=x=>g({mark:x,HTMLAttributes:dk(x,d)})),[u.name,p]}));return new B_e({topNode:a,nodes:o,marks:c})}function IIt(t){const e=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(e))}function P_(t){return t.sort((r,n)=>{const s=_t(r,"priority")||100,i=_t(n,"priority")||100;return s>i?-1:s<i?1:0})}function uke(t){const e=P_(V7(t)),r=IIt(e.map(n=>n.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(n=>`'${n}'`).join(", ")}]. This can lead to issues.`),e}function dke(t,e,r){const{from:n,to:s}=e,{blockSeparator:i=`
`,textSerializers:a={}}=r||{};let o="";return t.nodesBetween(n,s,(c,u,d,h)=>{var f;c.isBlock&&u>n&&(o+=i);const p=a==null?void 0:a[c.type.name];if(p)return d&&(o+=p({node:c,pos:u,parent:d,index:h,range:e})),!1;c.isText&&(o+=(f=c==null?void 0:c.text)==null?void 0:f.slice(Math.max(n,u)-u,s-u))}),o}function RIt(t,e){const r={from:0,to:t.content.size};return dke(t,r,e)}function hke(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,r])=>[e,r.spec.toText]))}function MIt(t,e){const r=ms(e,t.schema),{from:n,to:s}=t.selection,i=[];t.doc.nodesBetween(n,s,o=>{i.push(o)});const a=i.reverse().find(o=>o.type.name===r.name);return a?{...a.attrs}:{}}function fke(t,e){const r=xD(typeof e=="string"?e:e.name,t.schema);return r==="node"?MIt(t,e):r==="mark"?ake(t,e):{}}function DIt(t,e=JSON.stringify){const r={};return t.filter(n=>{const s=e(n);return Object.prototype.hasOwnProperty.call(r,s)?!1:r[s]=!0})}function LIt(t){const e=DIt(t);return e.length===1?e:e.filter((r,n)=>!e.filter((i,a)=>a!==n).some(i=>r.oldRange.from>=i.oldRange.from&&r.oldRange.to<=i.oldRange.to&&r.newRange.from>=i.newRange.from&&r.newRange.to<=i.newRange.to))}function pke(t){const{mapping:e,steps:r}=t,n=[];return e.maps.forEach((s,i)=>{const a=[];if(s.ranges.length)s.forEach((o,c)=>{a.push({from:o,to:c})});else{const{from:o,to:c}=r[i];if(o===void 0||c===void 0)return;a.push({from:o,to:c})}a.forEach(({from:o,to:c})=>{const u=e.slice(i).map(o,-1),d=e.slice(i).map(c),h=e.invert().map(u,-1),f=e.invert().map(d);n.push({oldRange:{from:h,to:f},newRange:{from:u,to:d}})})}),LIt(n)}function q7(t,e,r){const n=[];return t===e?r.resolve(t).marks().forEach(s=>{const i=r.resolve(t),a=H7(i,s.type);a&&n.push({mark:s,...a})}):r.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||n.push(...s.marks.map(a=>({from:i,to:i+s.nodeSize,mark:a})))}),n}var FIt=(t,e,r,n=20)=>{const s=t.doc.resolve(r);let i=n,a=null;for(;i>0&&a===null;){const o=s.node(i);(o==null?void 0:o.type.name)===e?a=o:i-=1}return[a,i]};function tS(t,e){return e.nodes[t]||e.marks[t]||null}function a2(t,e,r){return Object.fromEntries(Object.entries(r).filter(([n])=>{const s=t.find(i=>i.type===e&&i.name===n);return s?s.attribute.keepOnSplit:!1}))}var $It=(t,e=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-e),n,(s,i,a,o)=>{var c,u;const d=((u=(c=s.type.spec).toText)==null?void 0:u.call(c,{node:s,pos:i,parent:a,index:o}))||s.textContent||"%leaf%";r+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,n-i))}),r};function dU(t,e,r={}){const{empty:n,ranges:s}=t.selection,i=e?Lh(e,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>i?i.name===h.type.name:!0).find(h=>FO(h.attrs,r,{strict:!1}));let a=0;const o=[];if(s.forEach(({$from:h,$to:f})=>{const p=h.pos,m=f.pos;t.doc.nodesBetween(p,m,(g,x)=>{if(i&&g.inlineContent&&!g.type.allowsMarkType(i))return!1;if(!g.isText&&!g.marks.length)return;const y=Math.max(p,x),v=Math.min(m,x+g.nodeSize),b=v-y;a+=b,o.push(...g.marks.map(w=>({mark:w,from:y,to:v})))})}),a===0)return!1;const c=o.filter(h=>i?i.name===h.mark.type.name:!0).filter(h=>FO(h.mark.attrs,r,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),u=o.filter(h=>i?h.mark.type!==i&&h.mark.type.excludes(i):!0).reduce((h,f)=>h+f.to-f.from,0);return(c>0?c+u:c)>=a}function BIt(t,e,r={}){if(!e)return Yp(t,null,r)||dU(t,null,r);const n=xD(e,t.schema);return n==="node"?Yp(t,e,r):n==="mark"?dU(t,e,r):!1}var zIt=(t,e)=>{const{$from:r,$to:n,$anchor:s}=t.selection;if(e){const i=vD(o=>o.type.name===e)(t.selection);if(!i)return!1;const a=t.doc.resolve(i.pos+1);return s.pos+1===a.end()}return!(n.parentOffset<n.parent.nodeSize-2||r.pos!==n.pos)},UIt=t=>{const{$from:e,$to:r}=t.selection;return!(e.parentOffset>0||e.pos!==r.pos)};function Nie(t,e){return Array.isArray(e)?e.some(r=>(typeof r=="string"?r:r.name)===t.name):e}function tF(t,e){const{nodeExtensions:r}=Tw(e),n=r.find(a=>a.name===t);if(!n)return!1;const s={name:n.name,options:n.options,storage:n.storage},i=kr(_t(n,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function hk(t,{checkChildren:e=!0,ignoreWhitespace:r=!1}={}){var n;if(r){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((n=t.text)!=null?n:"")}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&&(hk(i,{ignoreWhitespace:r,checkChildren:e})||(s=!1))}),s}return!1}function mke(t){return t instanceof Ot}var gke=class yke{constructor(e){this.position=e}static fromJSON(e){return new yke(e.position)}toJSON(){return{position:this.position}}};function HIt(t,e){const r=e.mapping.mapResult(t.position);return{position:new gke(r.pos),mapResult:r}}function VIt(t){return new gke(t)}function WIt(t,e,r){var n;const{selection:s}=e;let i=null;if(rke(s)&&(i=s.$cursor),i){const o=(n=t.storedMarks)!=null?n:i.marks();return i.parent.type.allowsMarkType(r)&&(!!r.isInSet(o)||!o.some(u=>u.type.excludes(r)))}const{ranges:a}=s;return a.some(({$from:o,$to:c})=>{let u=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(o.pos,c.pos,(d,h,f)=>{if(u)return!1;if(d.isInline){const p=!f||f.type.allowsMarkType(r),m=!!r.isInSet(d.marks)||!d.marks.some(g=>g.type.excludes(r));u=p&&m}return!u}),u})}var qIt=(t,e={})=>({tr:r,state:n,dispatch:s})=>{const{selection:i}=r,{empty:a,ranges:o}=i,c=Lh(t,n.schema);if(s)if(a){const u=ake(n,c);r.addStoredMark(c.create({...u,...e}))}else o.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;n.doc.nodesBetween(d,h,(f,p)=>{const m=Math.max(p,d),g=Math.min(p+f.nodeSize,h);f.marks.find(y=>y.type===c)?f.marks.forEach(y=>{c===y.type&&r.addMark(m,g,c.create({...y.attrs,...e}))}):r.addMark(m,g,c.create(e))})});return WIt(n,r,c)},GIt=(t,e)=>({tr:r})=>(r.setMeta(t,e),!0),KIt=(t,e={})=>({state:r,dispatch:n,chain:s})=>{const i=ms(t,r.schema);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:o})=>Bse(i,{...a,...e})(r)?!0:o.clearNodes()).command(({state:o})=>Bse(i,{...a,...e})(o,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},YIt=t=>({tr:e,dispatch:r})=>{if(r){const{doc:n}=e,s=cg(t,0,n.content.size),i=Ot.create(n,s);e.setSelection(i)}return!0},XIt=(t,e)=>({tr:r,state:n,dispatch:s})=>{const{selection:i}=n;let a,o;return typeof e=="number"?(a=e,o=e):e&&"from"in e&&"to"in e?(a=e.from,o=e.to):(a=i.from,o=i.to),s&&r.doc.nodesBetween(a,o,(c,u)=>{c.isText||r.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},JIt=t=>({tr:e,dispatch:r})=>{if(r){const{doc:n}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,a=Bt.atStart(n).from,o=Bt.atEnd(n).to,c=cg(s,a,o),u=cg(i,a,o),d=Bt.create(n,c,u);e.setSelection(d)}return!0},QIt=t=>({state:e,dispatch:r})=>{const n=ms(t,e.schema);return U2t(n)(e,r)};function Eie(t,e){const r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(r){const n=r.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(n)}}var ZIt=({keepMarks:t=!0}={})=>({tr:e,state:r,dispatch:n,editor:s})=>{const{selection:i,doc:a}=e,{$from:o,$to:c}=i,u=s.extensionManager.attributes,d=a2(u,o.node().type.name,o.node().attrs);if(i instanceof Ot&&i.node.isBlock)return!o.parentOffset||!pb(a,o.pos)?!1:(n&&(t&&Eie(r,s.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,f=o.depth===0?void 0:NIt(o.node(-1).contentMatchAt(o.indexAfter(-1)));let p=h&&f?[{type:f,attrs:d}]:void 0,m=pb(e.doc,e.mapping.map(o.pos),1,p);if(!p&&!m&&pb(e.doc,e.mapping.map(o.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:d}]:void 0),n){if(m&&(i instanceof Bt&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,p),f&&!h&&!o.parentOffset&&o.parent.type!==f)){const g=e.mapping.map(o.before()),x=e.doc.resolve(g);o.node(-1).canReplaceWith(x.index(),x.index()+1,f)&&e.setNodeMarkup(e.mapping.map(o.before()),f)}t&&Eie(r,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},eRt=(t,e={})=>({tr:r,state:n,dispatch:s,editor:i})=>{var a;const o=ms(t,n.schema),{$from:c,$to:u}=n.selection,d=n.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const h=c.node(-1);if(h.type!==o)return!1;const f=i.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==o||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let y=Qe.empty;const v=c.index(-1)?1:c.index(-2)?2:3;for(let C=c.depth-v;C>=c.depth-3;C-=1)y=Qe.from(c.node(C).copy(y));const b=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,w={...a2(f,c.node().type.name,c.node().attrs),...e},S=((a=o.contentMatch.defaultType)==null?void 0:a.createAndFill(w))||void 0;y=y.append(Qe.from(o.createAndFill(null,S)||void 0));const k=c.before(c.depth-(v-1));r.replace(k,c.after(-b),new vt(y,4-v,0));let E=-1;r.doc.nodesBetween(k,r.doc.content.size,(C,A)=>{if(E>-1)return!1;C.isTextblock&&C.content.size===0&&(E=A+1)}),E>-1&&r.setSelection(Bt.near(r.doc.resolve(E))),r.scrollIntoView()}return!0}const p=u.pos===c.end()?h.contentMatchAt(0).defaultType:null,m={...a2(f,h.type.name,h.attrs),...e},g={...a2(f,c.node().type.name,c.node().attrs),...e};r.delete(c.pos,u.pos);const x=p?[{type:o,attrs:m},{type:p,attrs:g}]:[{type:o,attrs:m}];if(!pb(r.doc,c.pos,2))return!1;if(s){const{selection:y,storedMarks:v}=n,{splittableMarks:b}=i.extensionManager,w=v||y.$to.parentOffset&&y.$from.marks();if(r.split(c.pos,2,x).scrollIntoView(),!w||!s)return!0;const S=w.filter(k=>b.includes(k.type.name));r.ensureMarks(S)}return!0};function Aie(t){return!t||t==="1"?null:t}function xke(t,e){return Aie(t)===Aie(e)}var rF=(t,e)=>{const r=vD(a=>a.type===e)(t.selection);if(!r)return!0;const n=t.doc.resolve(Math.max(0,r.pos-1)).before(r.depth);if(n===void 0)return!0;const s=t.doc.nodeAt(n);return!(r.node.type===(s==null?void 0:s.type)&&vm(t.doc,r.pos))||!xke(r.node.attrs.type,s==null?void 0:s.attrs.type)||t.join(r.pos),!0},nF=(t,e)=>{const r=vD(a=>a.type===e)(t.selection);if(!r)return!0;const n=t.doc.resolve(r.start).after(r.depth);if(n===void 0)return!0;const s=t.doc.nodeAt(n);return!(r.node.type===(s==null?void 0:s.type)&&vm(t.doc,n))||!xke(r.node.attrs.type,s==null?void 0:s.attrs.type)||t.join(n),!0};function tRt(t){const e=t.doc,r=e.firstChild;if(!r)return null;const n=e.resolve(1),s=e.resolve(r.nodeSize-1);return Bt.between(n,s)}var rRt=(t,e,r,n={})=>({editor:s,tr:i,state:a,dispatch:o,chain:c,commands:u,can:d})=>{const{extensions:h,splittableMarks:f}=s.extensionManager,p=ms(t,a.schema),m=ms(e,a.schema),{selection:g,storedMarks:x}=a,{$from:y,$to:v}=g,b=y.blockRange(v),w=x||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;const S=vD(W=>tF(W.type.name,h))(g),k=g.from===0&&g.to===a.doc.content.size,E=a.doc.content.content,C=E.length===1?E[0]:null,A=k&&C&&tF(C.type.name,h)?{node:C,pos:0,depth:0}:null,M=S??A,z=!!S&&b.depth>=1&&b.depth-S.depth<=1,P=!!A;if((z||P)&&M){if(M.node.type===p)return k&&P?c().command(({tr:W,dispatch:N})=>{const U=tRt(W);return U?(W.setSelection(U),N&&N(W),!0):!1}).liftListItem(m).run():u.liftListItem(m);if(tF(M.node.type.name,h)&&p.validContent(M.node.content))return c().command(()=>(i.setNodeMarkup(M.pos,p),!0)).command(()=>rF(i,p)).command(()=>nF(i,p)).run()}return!r||!w||!o?c().command(()=>d().wrapInList(p,n)?!0:u.clearNodes()).wrapInList(p,n).command(()=>rF(i,p)).command(()=>nF(i,p)).run():c().command(()=>{const W=d().wrapInList(p,n),N=w.filter(U=>f.includes(U.type.name));return i.ensureMarks(N),W?!0:u.clearNodes()}).wrapInList(p,n).command(()=>rF(i,p)).command(()=>nF(i,p)).run()},nRt=(t,e={},r={})=>({state:n,commands:s})=>{const{extendEmptyMarkRange:i=!1}=r,a=Lh(t,n.schema);return dU(n,a,e)?s.unsetMark(a,{extendEmptyMarkRange:i}):s.setMark(a,e)},sRt=(t,e,r={})=>({state:n,commands:s})=>{const i=ms(t,n.schema),a=ms(e,n.schema),o=Yp(n,i,r);let c;return n.selection.$anchor.sameParent(n.selection.$head)&&(c=n.selection.$anchor.parent.attrs),o?s.setNode(a,c):s.setNode(i,{...c,...r})},iRt=(t,e={})=>({state:r,commands:n})=>{const s=ms(t,r.schema);return Yp(r,s,e)?n.lift(s):n.wrapIn(s,e)},aRt=()=>({state:t,dispatch:e})=>{const r=t.plugins;for(let n=0;n<r.length;n+=1){const s=r[n];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const a=t.tr,o=i.transform;for(let c=o.steps.length-1;c>=0;c-=1)a.step(o.steps[c].invert(o.docs[c]));if(i.text){const c=a.doc.resolve(i.from).marks();a.replaceWith(i.from,i.to,t.schema.text(i.text,c))}else a.delete(i.from,i.to)}return!0}}return!1},oRt=(t={})=>({tr:e,dispatch:r,editor:n})=>{const{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:a,ranges:o}=i;if(a)return!0;const{nonClearableMarks:c}=n.extensionManager;if(r){const u=Object.values(n.schema.marks).filter(d=>s||!c.includes(d.name));o.forEach(d=>{for(const h of u)e.removeMark(d.$from.pos,d.$to.pos,h)})}return!0},lRt=(t,e={})=>({tr:r,state:n,dispatch:s})=>{var i;const{extendEmptyMarkRange:a=!1}=e,{selection:o}=r,c=Lh(t,n.schema),{$from:u,empty:d,ranges:h}=o;if(!s)return!0;if(d&&a){let{from:f,to:p}=o;const m=(i=u.marks().find(x=>x.type===c))==null?void 0:i.attrs,g=H7(u,c,m);g&&(f=g.from,p=g.to),r.removeMark(f,p,c)}else h.forEach(f=>{r.removeMark(f.$from.pos,f.$to.pos,c)});return r.removeStoredMark(c),!0},cRt=t=>({tr:e,state:r,dispatch:n})=>{const{selection:s}=r;let i,a;return typeof t=="number"?(i=t,a=t):t&&"from"in t&&"to"in t?(i=t.from,a=t.to):(i=s.from,a=s.to),n&&e.doc.nodesBetween(i,a,(o,c)=>{if(o.isText)return;const u={...o.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},uRt=(t,e={})=>({tr:r,state:n,dispatch:s})=>{let i=null,a=null;const o=xD(typeof t=="string"?t:t.name,n.schema);if(!o)return!1;o==="node"&&(i=ms(t,n.schema)),o==="mark"&&(a=Lh(t,n.schema));let c=!1;return r.selection.ranges.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;let f,p,m,g;r.selection.empty?n.doc.nodesBetween(d,h,(x,y)=>{i&&i===x.type&&(c=!0,m=Math.max(y,d),g=Math.min(y+x.nodeSize,h),f=y,p=x)}):n.doc.nodesBetween(d,h,(x,y)=>{y<d&&i&&i===x.type&&(c=!0,m=Math.max(y,d),g=Math.min(y+x.nodeSize,h),f=y,p=x),y>=d&&y<=h&&(i&&i===x.type&&(c=!0,s&&r.setNodeMarkup(y,void 0,{...x.attrs,...e})),a&&x.marks.length&&x.marks.forEach(v=>{if(a===v.type&&(c=!0,s)){const b=Math.max(y,d),w=Math.min(y+x.nodeSize,h);r.addMark(b,w,a.create({...v.attrs,...e}))}}))}),p&&(f!==void 0&&s&&r.setNodeMarkup(f,void 0,{...p.attrs,...e}),a&&p.marks.length&&p.marks.forEach(x=>{a===x.type&&s&&r.addMark(m,g,a.create({...x.attrs,...e}))}))}),c},dRt=(t,e={})=>({state:r,dispatch:n})=>{const s=ms(t,r.schema);return M2t(s,e)(r,n)},hRt=(t,e={})=>({state:r,dispatch:n})=>{const s=ms(t,r.schema);return D2t(s,e)(r,n)},fRt=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const r=this.callbacks[t];return r&&r.forEach(n=>n.apply(this,e)),this}off(t,e){const r=this.callbacks[t];return r&&(e?this.callbacks[t]=r.filter(n=>n!==e):delete this.callbacks[t]),this}once(t,e){const r=(...n)=>{this.off(t,r),e.apply(this,n)};return this.on(t,r)}removeAllListeners(){this.callbacks={}}};function pRt(t,e){const{selection:r}=t,{$from:n}=r;if(r instanceof Ot){const i=n.index();return n.parent.canReplaceWith(i,i+1,e)}let s=n.depth;for(;s>=0;){const i=n.index(s);if(n.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function vke(t,e,r){const n=document.querySelector(`style[data-tiptap-style${r?`-${r}`:""}]`);if(n!==null)return n;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute(`data-tiptap-style${r?`-${r}`:""}`,""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}function mRt(t){return typeof t=="number"}function gRt(t){return Object.prototype.toString.call(t).slice(8,-1)}function OC(t){return gRt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}var yRt={};z7(yRt,{createAtomBlockMarkdownSpec:()=>xRt,createBlockMarkdownSpec:()=>vRt,createInlineMarkdownSpec:()=>SRt,parseAttributes:()=>G7,parseIndentedBlocks:()=>hU,renderNestedMarkdownContent:()=>Y7,serializeAttributes:()=>K7});function G7(t){if(!(t!=null&&t.trim()))return{};const e={},r=[],n=t.replace(/["']([^"']*)["']/g,u=>(r.push(u),`__QUOTED_${r.length-1}__`)),s=n.match(/(?:^|\s)\.([\w-]+)/g);if(s){const u=s.map(d=>d.trim().slice(1));e.class=u.join(" ")}const i=n.match(/(?:^|\s)#([\w-]+)/);i&&(e.id=i[1]);const a=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(n.matchAll(a)).forEach(([,u,d])=>{var h;const f=parseInt(((h=d.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),p=r[f];p&&(e[u]=p.slice(1,-1))});const c=n.replace(/(?:^|\s)\.([\w-]+)/g,"").replace(/(?:^|\s)#([\w-]+)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function K7(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(n=>e.push(`.${n}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([r,n])=>{r==="class"||r==="id"||(n===!0?e.push(r):n!==!1&&n!=null&&e.push(`${r}="${String(n)}"`))}),e.join(" ")}function xRt(t){const{nodeName:e,name:r,parseAttributes:n=G7,serializeAttributes:s=K7,defaultAttributes:i={},requiredAttributes:a=[],allowedAttributes:o}=t,c=r||e,u=d=>{if(!o)return d;const h={};return o.forEach(f=>{f in d&&(h[f]=d[f])}),h};return{parseMarkdown:(d,h)=>{const f={...i,...d.attributes};return h.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(d){var h;const f=new RegExp(`^:::${c}(?:\\s|$)`,"m"),p=(h=d.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(d,h,f){const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),m=d.match(p);if(!m)return;const g=m[1]||"",x=n(g);if(!a.find(v=>!(v in x)))return{type:e,raw:m[0],attributes:x}}},renderMarkdown:d=>{const h=u(d.attrs||{}),f=s(h),p=f?` {${f}}`:"";return`:::${c}${p} :::`}}}function vRt(t){const{nodeName:e,name:r,getContent:n,parseAttributes:s=G7,serializeAttributes:i=K7,defaultAttributes:a={},content:o="block",allowedAttributes:c}=t,u=r||e,d=h=>{if(!c)return h;const f={};return c.forEach(p=>{p in h&&(f[p]=h[p])}),f};return{parseMarkdown:(h,f)=>{let p;if(n){const g=n(h);p=typeof g=="string"?[{type:"text",text:g}]:g}else o==="block"?p=f.parseChildren(h.tokens||[]):p=f.parseInline(h.tokens||[]);const m={...a,...h.attributes};return f.createNode(e,m,p)},markdownTokenizer:{name:e,level:"block",start(h){var f;const p=new RegExp(`^:::${u}`,"m"),m=(f=h.match(p))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(h,f,p){var m;const g=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=h.match(g);if(!x)return;const[y,v=""]=x,b=s(v);let w=1;const S=y.length;let k="";const E=/^:::([\w-]*)(\s.*)?/gm,C=h.slice(S);for(E.lastIndex=0;;){const A=E.exec(C);if(A===null)break;const M=A.index,z=A[1];if(!((m=A[2])!=null&&m.endsWith(":::"))){if(z)w+=1;else if(w-=1,w===0){const P=C.slice(0,M);k=P.trim();const W=h.slice(0,S+M+A[0].length);let N=[];if(k)if(o==="block")for(N=p.blockTokens(P),N.forEach(U=>{U.text&&(!U.tokens||U.tokens.length===0)&&(U.tokens=p.inlineTokens(U.text))});N.length>0;){const U=N[N.length-1];if(U.type==="paragraph"&&(!U.text||U.text.trim()===""))N.pop();else break}else N=p.inlineTokens(k);return{type:e,raw:W,attributes:b,content:k,tokens:N}}}}}},renderMarkdown:(h,f)=>{const p=d(h.attrs||{}),m=i(p),g=m?` {${m}}`:"",x=f.renderChildren(h.content||[],`
`);return`:::${u}${g}
${x}
:::`}}}function bRt(t){if(!t.trim())return{};const e={},r=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let n=r.exec(t);for(;n!==null;){const[,s,i,a]=n;e[s]=i||a,n=r.exec(t)}return e}function wRt(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,r])=>`${e}="${r}"`).join(" ")}function SRt(t){const{nodeName:e,name:r,getContent:n,parseAttributes:s=bRt,serializeAttributes:i=wRt,defaultAttributes:a={},selfClosing:o=!1,allowedAttributes:c}=t,u=r||e,d=f=>{if(!c)return f;const p={};return c.forEach(m=>{const g=typeof m=="string"?m:m.name,x=typeof m=="string"?void 0:m.skipIfDefault;if(g in f){const y=f[g];if(x!==void 0&&y===x)return;p[g]=y}}),p},h=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,p)=>{const m={...a,...f.attributes};if(o)return p.createNode(e,m);const g=n?n(f):f.content||"";return g?p.createNode(e,m,[p.createTextNode(g)]):p.createNode(e,m,[])},markdownTokenizer:{name:e,level:"inline",start(f){const p=o?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),m=f.match(p),g=m==null?void 0:m.index;return g!==void 0?g:-1},tokenize(f,p,m){const g=o?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),x=f.match(g);if(!x)return;let y="",v="";if(o){const[,w]=x;v=w}else{const[,w,S]=x;v=w,y=S||""}const b=s(v.trim());return{type:e,raw:x[0],content:y.trim(),attributes:b}}},renderMarkdown:f=>{let p="";n?p=n(f):f.content&&f.content.length>0&&(p=f.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const m=d(f.attrs||{}),g=i(m),x=g?` ${g}`:"";return o?`[${u}${x}]`:`[${u}${x}]${p}[/${u}]`}}}function hU(t,e,r){var n,s,i,a;const o=t.split(`
`),c=[];let u="",d=0;const h=e.baseIndentSize||2;for(;d<o.length;){const f=o[d],p=f.match(e.itemPattern);if(!p){if(c.length>0)break;if(f.trim()===""){d+=1,u=`${u}${f}
`;continue}else return}const m=e.extractItemData(p),{indentLevel:g,mainContent:x}=m;u=`${u}${f}
`;const y=[x];for(d+=1;d<o.length;){const S=o[d];if(S.trim()===""){const E=o.slice(d+1).findIndex(M=>M.trim()!=="");if(E===-1)break;if((((s=(n=o[d+1+E].match(/^(\s*)/))==null?void 0:n[1])==null?void 0:s.length)||0)>g){y.push(S),u=`${u}${S}
`,d+=1;continue}else break}if((((a=(i=S.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:a.length)||0)>g)y.push(S),u=`${u}${S}
`,d+=1;else break}let v;const b=y.slice(1);if(b.length>0){const S=b.map(k=>k.slice(g+h)).join(`
`);S.trim()&&(e.customNestedParser?v=e.customNestedParser(S):v=r.blockTokens(S))}const w=e.createToken(m,v);c.push(w)}if(c.length!==0)return{items:c,raw:u}}function Y7(t,e,r,n){if(!t||!Array.isArray(t.content))return"";const s=typeof r=="function"?r(n):r,[i,...a]=t.content,o=e.renderChildren([i]);let c=`${s}${o}`;return a&&a.length>0&&a.forEach((u,d)=>{var h,f;const p=(f=(h=e.renderChild)==null?void 0:h.call(e,u,d+1))!=null?f:e.renderChildren([u]);if(p!=null){const m=p.split(`
`).map(g=>g?e.indent(g):e.indent("")).join(`
`);c+=u.type==="paragraph"?`
${m}`:`
${m}`}}),c}function bke(t,e){const r={...t};return OC(t)&&OC(e)&&Object.keys(e).forEach(n=>{OC(e[n])&&OC(t[n])?r[n]=bke(t[n],e[n]):r[n]=e[n]}),r}function _Rt(t,e,r={}){const{state:n}=e,{doc:s,tr:i}=n,a=t;s.descendants((o,c)=>{const u=i.mapping.map(c),d=i.mapping.map(c)+o.nodeSize;let h=null;if(o.marks.forEach(p=>{if(p!==a)return!1;h=p}),!h)return;let f=!1;if(Object.keys(r).forEach(p=>{r[p]!==h.attrs[p]&&(f=!0)}),f){const p=t.type.create({...t.attrs,...r});i.removeMark(u,d,t.type),i.addMark(u,d,p)}}),i.docChanged&&e.view.dispatch(i)}var bD=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},jRt=(t,e)=>{if(U7(e))return e.exec(t);const r=e(t);if(!r)return null;const n=[r.text];return n.index=r.index,n.input=t,n.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(r.replaceWith)),n};function IC(t){var e;const{editor:r,from:n,to:s,text:i,rules:a,plugin:o}=t,{view:c}=r;if(c.composing)return!1;const u=c.state.doc.resolve(n);if(u.parent.type.spec.code||(e=u.nodeBefore||u.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1;const h=$It(u)+i;return a.forEach(f=>{if(d)return;const p=jRt(h,f.find);if(!p)return;const m=c.state.tr,g=gD({state:c.state,transaction:m}),x={from:n-(p[0].length-i.length),to:s},{commands:y,chain:v,can:b}=new yD({editor:r,state:g});f.handler({state:g,range:x,match:p,commands:y,chain:v,can:b})===null||!m.steps.length||(f.undoable&&m.setMeta(o,{transform:m,from:n,to:s,text:i}),c.dispatch(m),d=!0)}),d}function kRt(t){const{editor:e,rules:r}=t,n=new fn({state:{init(){return null},apply(s,i,a){const o=s.getMeta(n);if(o)return o;const c=s.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=W7(Qe.from(d),a.schema);const{from:h}=c,f=h+d.length;IC({editor:e,from:h,to:f,text:d,rules:r,plugin:n})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,a,o){return IC({editor:e,from:i,to:a,text:o,rules:r,plugin:n})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&IC({editor:e,from:i.pos,to:i.pos,text:"",rules:r,plugin:n})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:a}=s.state.selection;return a?IC({editor:e,from:a.pos,to:a.pos,text:`
`,rules:r,plugin:n}):!1}},isInputRules:!0});return n}var X7=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{...kr(_t(this,"addOptions",{name:this.name}))}}get storage(){return{...kr(_t(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>bke(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}},Ox=class wke extends X7{constructor(){super(...arguments),this.type="mark"}static create(e={}){const r=typeof e=="function"?e():e;return new wke(r)}static handleExit({editor:e,mark:r}){const{tr:n}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const a=s.marks();if(!!!a.find(u=>(u==null?void 0:u.type.name)===r.name))return!1;const c=a.find(u=>(u==null?void 0:u.type.name)===r.name);return c&&n.removeStoredMark(c),n.insertText(" ",s.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){const r=typeof e=="function"?e():e;return super.extend(r)}},NRt=class{constructor(t){this.find=t.find,this.handler=t.handler}},ERt=(t,e,r)=>{if(U7(e))return[...t.matchAll(e)];const n=e(t,r);return n?n.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 ARt(t){const{editor:e,state:r,from:n,to:s,rule:i,pasteEvent:a,dropEvent:o}=t,{commands:c,chain:u,can:d}=new yD({editor:e,state:r}),h=[];return r.doc.nodesBetween(n,s,(p,m)=>{var g,x,y,v,b;if((x=(g=p.type)==null?void 0:g.spec)!=null&&x.code||!(p.isText||p.isTextblock||p.isInline))return;const w=(b=(v=(y=p.content)==null?void 0:y.size)!=null?v:p.nodeSize)!=null?b:0,S=Math.max(n,m),k=Math.min(s,m+w);if(S>=k)return;const E=p.isText?p.text||"":p.textBetween(S-m,k-m,void 0,"");ERt(E,i.find,a).forEach(A=>{if(A.index===void 0)return;const M=S+A.index+1,z=M+A[0].length,P={from:r.tr.mapping.map(M),to:r.tr.mapping.map(z)},W=i.handler({state:r,range:P,match:A,commands:c,chain:u,can:d,pasteEvent:a,dropEvent:o});h.push(W)})}),h.every(p=>p!==null)}var RC=null,CRt=t=>{var e;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=r.clipboardData)==null||e.setData("text/html",t),r};function TRt(t){const{editor:e,rules:r}=t;let n=null,s=!1,i=!1,a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const c=({state:d,from:h,to:f,rule:p,pasteEvt:m})=>{const g=d.tr,x=gD({state:d,transaction:g});if(!(!ARt({editor:e,state:x,from:Math.max(h-1,0),to:f.b-1,rule:p,pasteEvent:m,dropEvent:o})||!g.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return r.map(d=>new fn({view(h){const f=m=>{var g;n=(g=h.dom.parentElement)!=null&&g.contains(m.target)?h.dom.parentElement:null,n&&(RC=e)},p=()=>{RC&&(RC=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(h,f)=>{if(i=n===h.dom.parentElement,o=f,!i){const p=RC;p!=null&&p.isEditable&&setTimeout(()=>{const m=p.state.selection;m&&p.commands.deleteRange({from:m.from,to:m.to})},10)}return!1},paste:(h,f)=>{var p;const m=(p=f.clipboardData)==null?void 0:p.getData("text/html");return a=f,s=!!(m!=null&&m.includes("data-pm-slice")),!1}}},appendTransaction:(h,f,p)=>{const m=h[0],g=m.getMeta("uiEvent")==="paste"&&!s,x=m.getMeta("uiEvent")==="drop"&&!i,y=m.getMeta("applyPasteRules"),v=!!y;if(!g&&!x&&!v)return;if(v){let{text:S}=y;typeof S=="string"?S=S:S=W7(Qe.from(S),p.schema);const{from:k}=y,E=k+S.length,C=CRt(S);return c({rule:d,state:p,from:k,to:{b:E},pasteEvt:C})}const b=f.doc.content.findDiffStart(p.doc.content),w=f.doc.content.findDiffEnd(p.doc.content);if(!(!mRt(b)||!w||b===w.b))return c({rule:d,state:p,from:b,to:w,pasteEvt:a})}}))}var wD=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=uke(t),this.schema=OIt(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:tS(e.name,this.schema)},n=_t(e,"addCommands",r);return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this;return P_([...this.extensions].reverse()).flatMap(n=>{const s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:tS(n.name,this.schema)},i=[],a=_t(n,"addKeyboardShortcuts",s);let o={};if(n.type==="mark"&&_t(n,"exitable",s)&&(o.ArrowRight=()=>Ox.handleExit({editor:t,mark:n})),a){const f=Object.fromEntries(Object.entries(a()).map(([p,m])=>[p,()=>m({editor:t})]));o={...o,...f}}const c=OOt(o);i.push(c);const u=_t(n,"addInputRules",s);if(Nie(n,t.options.enableInputRules)&&u){const f=u();if(f&&f.length){const p=kRt({editor:t,rules:f}),m=Array.isArray(p)?p:[p];i.push(...m)}}const d=_t(n,"addPasteRules",s);if(Nie(n,t.options.enablePasteRules)&&d){const f=d();if(f&&f.length){const p=TRt({editor:t,rules:f});i.push(...p)}}const h=_t(n,"addProseMirrorPlugins",s);if(h){const f=h();i.push(...f)}return i})}get attributes(){return cke(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Tw(this.extensions);return Object.fromEntries(e.filter(r=>!!_t(r,"addNodeView")).map(r=>{const n=this.attributes.filter(c=>c.type===r.name),s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ms(r.name,this.schema)},i=_t(r,"addNodeView",s);if(!i)return[];const a=i();if(!a)return[];const o=(c,u,d,h,f)=>{const p=dk(c,n);return a({node:c,view:u,getPos:d,decorations:h,innerDecorations:f,editor:t,extension:r,HTMLAttributes:p})};return[r.name,o]}))}dispatchTransaction(t){const{editor:e}=this;return P_([...this.extensions].reverse()).reduceRight((n,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:tS(s.name,this.schema)},a=_t(s,"dispatchTransaction",i);return a?o=>{a.call(i,{transaction:o,next:n})}:n},t)}transformPastedHTML(t){const{editor:e}=this;return P_([...this.extensions]).reduce((n,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:tS(s.name,this.schema)},a=_t(s,"transformPastedHTML",i);return a?(o,c)=>{const u=n(o,c);return a.call(i,u)}:n},t||(n=>n))}get markViews(){const{editor:t}=this,{markExtensions:e}=Tw(this.extensions);return Object.fromEntries(e.filter(r=>!!_t(r,"addMarkView")).map(r=>{const n=this.attributes.filter(o=>o.type===r.name),s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Lh(r.name,this.schema)},i=_t(r,"addMarkView",s);if(!i)return[];const a=(o,c,u)=>{const d=dk(o,n);return i()({mark:o,view:c,inline:u,editor:t,extension:r,HTMLAttributes:d,updateAttributes:h=>{_Rt(o,t,h)}})};return[r.name,a]}))}destroy(){this.extensions.forEach(t=>{let e=t;for(;e.parent;){const r=e.parent;r.child===e&&(r.child=null),e=r}}),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 r,n;const s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:tS(e.name,this.schema)};e.type==="mark"&&(((r=kr(_t(e,"keepOnSplit",s)))==null||r)&&this.splittableMarks.push(e.name),(n=kr(_t(e,"clearable",s)))==null||n||this.nonClearableMarks.push(e.name));const i=_t(e,"onBeforeCreate",s),a=_t(e,"onCreate",s),o=_t(e,"onUpdate",s),c=_t(e,"onSelectionUpdate",s),u=_t(e,"onTransaction",s),d=_t(e,"onFocus",s),h=_t(e,"onBlur",s),f=_t(e,"onDestroy",s);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),o&&this.editor.on("update",o),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),d&&this.editor.on("focus",d),h&&this.editor.on("blur",h),f&&this.editor.on("destroy",f)})}};wD.resolve=uke;wD.sort=P_;wD.flatten=V7;var PRt={};z7(PRt,{ClipboardTextSerializer:()=>_ke,Commands:()=>jke,Delete:()=>kke,Drop:()=>Nke,Editable:()=>Eke,FocusEvents:()=>Cke,Keymap:()=>Tke,Paste:()=>Pke,Tabindex:()=>Oke,TextDirection:()=>Ike,focusEventsPluginKey:()=>Ake});var Pn=class Ske extends X7{constructor(){super(...arguments),this.type="extension"}static create(e={}){const r=typeof e=="function"?e():e;return new Ske(r)}configure(e){return super.configure(e)}extend(e){const r=typeof e=="function"?e():e;return super.extend(r)}},_ke=Pn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new fn({key:new ys("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:r}=t,{doc:n,selection:s}=e,i=hke(r),{blockSeparator:a}=this.options,o={...a!==void 0?{blockSeparator:a}:{},textSerializers:i};return[...s.ranges].sort((u,d)=>u.$from.pos-d.$from.pos).map(({$from:u,$to:d})=>dke(n,{from:u.pos,to:d.pos},o)).join(a??`
`)}}})]}}),jke=Pn.create({name:"commands",addCommands(){return{...eke}}}),kke=Pn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var r,n,s;const i=()=>{var a,o,c,u;if((u=(c=(o=(a=this.editor.options.coreExtensionOptions)==null?void 0:a.delete)==null?void 0:o.filterTransaction)==null?void 0:c.call(o,t))!=null?u:t.getMeta("y-sync$"))return;const d=oke(t.before,[t,...e]);pke(d).forEach(p=>{d.mapping.mapResult(p.oldRange.from).deletedAfter&&d.mapping.mapResult(p.oldRange.to).deletedBefore&&d.before.nodesBetween(p.oldRange.from,p.oldRange.to,(m,g)=>{const x=g+m.nodeSize-2,y=p.oldRange.from<=g&&x<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:x,newFrom:d.mapping.map(g),newTo:d.mapping.map(x),deletedRange:p.oldRange,newRange:p.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});const f=d.mapping;d.steps.forEach((p,m)=>{var g,x;if(p instanceof m1){const y=f.slice(m).map(p.from,-1),v=f.slice(m).map(p.to),b=f.invert().map(y,-1),w=f.invert().map(v),S=y>0?(g=d.doc.nodeAt(y-1))==null?void 0:g.marks.some(E=>E.eq(p.mark)):!1,k=(x=d.doc.nodeAt(v))==null?void 0:x.marks.some(E=>E.eq(p.mark));this.editor.emit("delete",{type:"mark",mark:p.mark,from:p.from,to:p.to,deletedRange:{from:b,to:w},newRange:{from:y,to:v},partial:!!(k||S),editor:this.editor,transaction:t,combinedTransform:d})}})};(s=(n=(r=this.editor.options.coreExtensionOptions)==null?void 0:r.delete)==null?void 0:n.async)==null||s?setTimeout(i,0):i()}}),Nke=Pn.create({name:"drop",addProseMirrorPlugins(){return[new fn({key:new ys("tiptapDrop"),props:{handleDrop:(t,e,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:r,moved:n})}}})]}}),Eke=Pn.create({name:"editable",addProseMirrorPlugins(){return[new fn({key:new ys("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Ake=new ys("focusEvents"),Cke=Pn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new fn({key:Ake,props:{handleDOMEvents:{focus:(e,r)=>{t.isFocused=!0;const n=t.state.tr.setMeta("focus",{event:r}).setMeta("addToHistory",!1);return e.dispatch(n),!1},blur:(e,r)=>{t.isFocused=!1;const n=t.state.tr.setMeta("blur",{event:r}).setMeta("addToHistory",!1);return e.dispatch(n),!1}}}})]}}),Tke=Pn.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:o})=>{const{selection:c,doc:u}=o,{empty:d,$anchor:h}=c,{pos:f,parent:p}=h,m=h.parent.isTextblock&&f>0?o.doc.resolve(f-1):h,g=m.parent.type.spec.isolating,x=h.pos-h.parentOffset,y=g&&m.parent.childCount===1?x===h.pos:qt.atStart(u).from===f;return!d||!p.type.isTextblock||p.textContent.length||!y||y&&h.parent.type.name==="paragraph"?!1:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.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={...n},i={...n,"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 $O()||ike()?i:s},addProseMirrorPlugins(){return[new fn({key:new ys("clearDocument"),appendTransaction:(t,e,r)=>{if(t.some(g=>g.getMeta("composition")))return;const n=t.some(g=>g.docChanged)&&!e.doc.eq(r.doc),s=t.some(g=>g.getMeta("preventClearDocument"));if(!n||s)return;const{empty:i,from:a,to:o}=e.selection,c=qt.atStart(e.doc).from,u=qt.atEnd(e.doc).to;if(i||!(a===c&&o===u)||!hk(r.doc))return;const f=r.tr,p=gD({state:r,transaction:f}),{commands:m}=new yD({editor:this.editor,state:p});if(m.clearNodes(),!!f.steps.length)return f}})]}}),Pke=Pn.create({name:"paste",addProseMirrorPlugins(){return[new fn({key:new ys("tiptapPaste"),props:{handlePaste:(t,e,r)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:r})}}})]}}),Oke=Pn.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new fn({key:new ys("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),Ike=Pn.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Tw(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const r=e.getAttribute("dir");return r&&(r==="ltr"||r==="rtl"||r==="auto")?r:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new fn({key:new ys("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),ORt=class GS{constructor(e,r,n=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=r,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 r=this.from,n=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}r=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:r,to:n},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),r=this.resolvedPos.doc.resolve(e);return new GS(r,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 GS(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 GS(e,this.editor)}get children(){const e=[];return this.node.content.forEach((r,n)=>{const s=r.isBlock&&!r.isTextblock,i=r.isAtom&&!r.isText,a=r.isInline,o=this.pos+n+(i?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(o);if(!s&&!a&&c.depth<=this.depth)return;const u=new GS(c,this.editor,s,s||a?r:null);s&&(u.actualDepth=this.depth+1),e.push(u)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,r={}){let n=null,s=this.parent;for(;s&&!n;){if(s.node.type.name===e)if(Object.keys(r).length>0){const i=s.node.attrs,a=Object.keys(r);for(let o=0;o<a.length;o+=1){const c=a[o];if(i[c]!==r[c])break}}else n=s;s=s.parent}return n}querySelector(e,r={}){return this.querySelectorAll(e,r,!0)[0]||null}querySelectorAll(e,r={},n=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(r);return this.children.forEach(a=>{n&&s.length>0||(a.node.type.name===e&&i.every(c=>r[c]===a.node.attrs[c])&&s.push(a),!(n&&s.length>0)&&(s=s.concat(a.querySelectorAll(e,r,n))))}),s}setAttribute(e){const{tr:r}=this.editor.state;r.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(r)}},IRt=`.ProseMirror {
position: relative;
}
.ProseMirror {
word-wrap: break-word;
white-space: pre-wrap;
white-space: break-spaces;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}
.ProseMirror [contenteditable="false"] {
white-space: normal;
}
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
white-space: pre-wrap;
}
.ProseMirror pre {
white-space: pre-wrap;
}
img.ProseMirror-separator {
display: inline !important;
border: none !important;
margin: 0 !important;
width: 0 !important;
height: 0 !important;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
margin: 0;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-hideselection *::selection {
background: transparent;
}
.ProseMirror-hideselection *::-moz-selection {
background: transparent;
}
.ProseMirror-hideselection * {
caret-color: transparent;
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}`,RRt=class extends fRt{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:HIt,createMappablePosition:VIt},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:s,moved:i})=>this.options.onDrop(n,s,i)),this.on("paste",({event:n,slice:s})=>this.options.onPaste(n,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),r=nke(e,this.options.autofocus);this.editorState=Hv.create({doc:e,schema:this.schema,selection:r||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=vke(IRt,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 r=lke(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],n=this.state.reconfigure({plugins:r});return this.view.updateState(n),n}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let r=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;r=r.filter(a=>!a.key.startsWith(i))}),e.length===r.length)return;const n=this.state.reconfigure({plugins:r});return this.view.updateState(n),n}createExtensionManager(){var t,e,r,n;const i=[...this.options.enableCoreExtensions?[Eke,_ke.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),jke,Cke,Tke,Oke.configure({value:(n=(r=this.options.coreExtensionOptions)==null?void 0:r.tabindex)==null?void 0:n.value}),Nke,Pke,kke,Ike.configure({direction:this.options.textDirection})].filter(a=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[a.name]!==!1:!0):[],...this.options.extensions].filter(a=>["extension","node","mark"].includes(a==null?void 0:a.type));this.extensionManager=new wD(i,this)}createCommandManager(){this.commandManager=new yD({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=uU(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),t=uU(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:r}=this.options,n=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=r?this.extensionManager.dispatchTransaction(n):n,i=e.transformPastedHTML,a=this.extensionManager.transformPastedHTML(i);this.editorView=new Qje(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:s,transformPastedHTML:a,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.prependClass(),this.injectCSS();const c=this.view.dom;c.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(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:r}=this.state.applyTransaction(t),n=!this.state.selection.eq(e.selection),s=r.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:r.slice(1)}),n&&this.emit("selectionUpdate",{editor:this,transaction:t});const a=r.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),o=a==null?void 0:a.getMeta("focus"),c=a==null?void 0:a.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:a}),c&&this.emit("blur",{editor:this,event:c.event,transaction:a}),!(t.getMeta("preventUpdate")||!r.some(u=>u.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:r.slice(1)})}getAttributes(t){return fke(this.state,t)}isActive(t,e){const r=typeof t=="string"?t:null,n=typeof t=="string"?e:t;return BIt(this.state,r,n)}getJSON(){return this.state.doc.toJSON()}getHTML(){return W7(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
`,textSerializers:r={}}=t||{};return RIt(this.state.doc,{blockSeparator:e,textSerializers:{...hke(this.schema),...r}})}get isEmpty(){return hk(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 r;return((r=this.$doc)==null?void 0:r.querySelector(t,e))||null}$nodes(t,e){var r;return((r=this.$doc)==null?void 0:r.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t),r=t>0&&e.nodeAfter&&!e.nodeAfter.isText?e.nodeAfter:null;return new ORt(e,this,!1,r)}get $doc(){return this.$pos(0)}};function Pw(t){return new bD({find:t.find,handler:({state:e,range:r,match:n})=>{const s=kr(t.getAttributes,void 0,n);if(s===!1||s===null)return null;const{tr:i}=e,a=n[n.length-1],o=n[0];if(a){const c=o.search(/\S/),u=r.from+o.indexOf(a),d=u+a.length;if(q7(r.from,r.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===t.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;d<r.to&&i.delete(d,r.to),u>r.from&&i.delete(r.from+c,u);const f=r.from+c+a.length;i.addMark(r.from+c,f,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function MRt(t){return new bD({find:t.find,handler:({state:e,range:r,match:n})=>{const s=kr(t.getAttributes,void 0,n)||{},{tr:i}=e,a=r.from;let o=r.to;const c=t.type.create(s);if(n[1]){const u=n[0].lastIndexOf(n[1]);let d=a+u;d>o?d=o:o=d+n[1].length;const h=n[0][n[0].length-1];i.insertText(h,a+n[0].length-1),i.replaceWith(d,o,c)}else if(n[0]){const u=t.type.isInline?a:a-1;i.insert(u,t.type.create(s)).delete(i.mapping.map(a),i.mapping.map(o))}i.scrollIntoView()},undoable:t.undoable})}function fU(t){return new bD({find:t.find,handler:({state:e,range:r,match:n})=>{const s=e.doc.resolve(r.from),i=kr(t.getAttributes,void 0,n)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,i)},undoable:t.undoable})}function Ow(t){return new bD({find:t.find,handler:({state:e,range:r,match:n,chain:s})=>{const i=kr(t.getAttributes,void 0,n)||{},a=e.tr.delete(r.from,r.to),c=a.doc.resolve(r.from).blockRange(),u=c&&C7(c,t.type,i);if(!u)return null;if(a.wrap(c,u),t.keepMarks&&t.editor){const{selection:h,storedMarks:f}=e,{splittableMarks:p}=t.editor.extensionManager,m=f||h.$to.parentOffset&&h.$from.marks();if(m){const g=m.filter(x=>p.includes(x.type.name));a.ensureMarks(g)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(h,i).run()}const d=a.doc.resolve(r.from-1).nodeBefore;d&&d.type===t.type&&vm(a.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,d))&&a.join(r.from-1)},undoable:t.undoable})}var Mo=class Rke extends X7{constructor(){super(...arguments),this.type="node"}static create(e={}){const r=typeof e=="function"?e():e;return new Rke(r)}configure(e){return super.configure(e)}extend(e){const r=typeof e=="function"?e():e;return super.extend(r)}};function dx(t){return new NRt({find:t.find,handler:({state:e,range:r,match:n,pasteEvent:s})=>{const i=kr(t.getAttributes,void 0,n,s);if(i===!1||i===null)return null;const{tr:a}=e,o=n[n.length-1],c=n[0];let u=r.to;if(o){const d=c.search(/\S/),h=r.from+c.indexOf(o),f=h+o.length;if(q7(r.from,r.to,e.doc).filter(g=>g.mark.type.excluded.find(y=>y===t.type&&y!==g.mark.type)).filter(g=>g.to>h).length)return null;f<r.to&&a.delete(f,r.to),h>r.from&&a.delete(r.from+d,h),u=r.from+d+o.length,a.addMark(r.from+d,u,t.type.create(i||{})),n.index!==void 0&&n.input!==void 0&&n.index+n[0].length>=n.input.length||a.removeStoredMark(t.type)}}})}var Mke={exports:{}},Dke={};/**
* @license React
* use-sync-external-store-shim/with-selector.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var SD=j,DRt=kR;function LRt(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var FRt=typeof Object.is=="function"?Object.is:LRt,$Rt=DRt.useSyncExternalStore,BRt=SD.useRef,zRt=SD.useEffect,URt=SD.useMemo,HRt=SD.useDebugValue;Dke.useSyncExternalStoreWithSelector=function(t,e,r,n,s){var i=BRt(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=URt(function(){function c(p){if(!u){if(u=!0,d=p,p=n(p),s!==void 0&&a.hasValue){var m=a.value;if(s(m,p))return h=m}return h=p}if(m=h,FRt(d,p))return m;var g=n(p);return s!==void 0&&s(m,g)?(d=p,m):(d=p,h=g)}var u=!1,d,h,f=r===void 0?null:r;return[function(){return c(e())},f===null?void 0:function(){return c(f())}]},[e,r,n,s]);var o=$Rt(t,i[0],i[1]);return zRt(function(){a.hasValue=!0,a.value=o},[o]),HRt(o),o};Mke.exports=Dke;var VRt=Mke.exports,WRt=(...t)=>e=>{t.forEach(r=>{typeof r=="function"?r(e):r&&(r.current=e)})},qRt=({contentComponent:t})=>{const e=kR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return l.jsx(l.Fragment,{children:Object.values(e)})};function GRt(){const t=new Set;let e={};return{subscribe(r){return t.add(r),()=>{t.delete(r)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(r,n){e={...e,[r]:jH.createPortal(n.reactElement,n.element,r)},t.forEach(s=>s())},removeRenderer(r){const n={...e};delete n[r],e=n,t.forEach(s=>s())}}}var KRt=class extends pe.Component{constructor(t){super(t),this.editorContentRef=pe.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 r=this.editorContentRef.current;r.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:r}),e.contentComponent=GRt(),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 r=document.createElement("div");r.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:r})}catch{}}}render(){const{editor:t,innerRef:e,...r}=this.props;return l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:WRt(e,this.editorContentRef),...r}),(t==null?void 0:t.contentComponent)&&l.jsx(qRt,{contentComponent:t.contentComponent})]})}},YRt=j.forwardRef((t,e)=>{const r=pe.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return pe.createElement(KRt,{key:r,innerRef:e,...t})}),Lke=pe.memo(YRt),XRt=typeof window<"u"?j.useLayoutEffect:j.useEffect,JRt=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(n=>n())},r=this.editor;return r.on("transaction",e),()=>{r.off("transaction",e)}}}};function QRt(t){var e;const[r]=j.useState(()=>new JRt(t.editor)),n=VRt.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:Pxe);return XRt(()=>r.watch(t.editor),[t.editor,r]),j.useDebugValue(n),n}var ZRt=!1,Fke=typeof window>"u",eMt=Fke||!!(typeof window<"u"&&window.next),tMt=class $ke{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(r=>r())}getInitialEditor(){const e=this.options.current.immediatelyRender;let r=e??!0;return Fke?(r&&ZRt&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),r=!1):eMt&&e===void 0&&(r=!1),r?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...n)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...n)},onBlur:(...n)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...n)},onCreate:(...n)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...n)},onDestroy:(...n)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...n)},onFocus:(...n)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...n)},onSelectionUpdate:(...n)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...n)},onTransaction:(...n)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...n)},onUpdate:(...n)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...n)},onContentError:(...n)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...n)},onDrop:(...n)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...n)},onPaste:(...n)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...n)},onDelete:(...n)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...n)}};return new RRt(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,r){return Object.keys(e).every(n=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)?!0:n==="extensions"&&e.extensions&&r.extensions?e.extensions.length!==r.extensions.length?!1:e.extensions.every((s,i)=>{var a;return s===((a=r.extensions)==null?void 0:a[i])}):e[n]===r[n])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?$ke.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((n,s)=>n===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,r=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){r&&r.setOptions(this.options.current);return}r&&!r.isDestroyed&&(r.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function rMt(t={},e=[]){const r=j.useRef(t);r.current=t;const[n]=j.useState(()=>new tMt(r)),s=kR.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return j.useDebugValue(s),j.useEffect(n.onRender(e)),QRt({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var Bke=j.createContext({editor:null});Bke.Consumer;var nMt=j.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),sMt=()=>j.useContext(nMt);pe.forwardRef((t,e)=>{const{onDragStart:r}=sMt(),n=t.as||"div";return l.jsx(n,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});pe.createContext({markViewContentRef:()=>{}});var J7=j.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});J7.displayName="TiptapContext";var iMt=()=>j.useContext(J7);function zke({editor:t,instance:e,children:r}){const n=t??e;if(!n)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=j.useMemo(()=>({editor:n}),[n]),i=j.useMemo(()=>({editor:n}),[n]);return l.jsx(Bke.Provider,{value:i,children:l.jsx(J7.Provider,{value:s,children:r})})}zke.displayName="Tiptap";function Uke({...t}){const{editor:e}=iMt();return l.jsx(Lke,{editor:e,...t})}Uke.displayName="Tiptap.Content";Object.assign(zke,{Content:Uke});var BO=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:r,...n}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,n,r]};function Hke(t,e,r){for(let n=0;;n++){if(n==t.childCount||n==e.childCount)return t.childCount==e.childCount?null:r;let s=t.child(n),i=e.child(n);if(s==i){r+=s.nodeSize;continue}if(!s.sameMarkup(i))return r;if(s.isText&&s.text!=i.text){for(let a=0;s.text[a]==i.text[a];a++)r++;return r}if(s.content.size||i.content.size){let a=Hke(s.content,i.content,r+1);if(a!=null)return a}r+=s.nodeSize}}function Vke(t,e,r,n){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:r,b:n};let a=t.child(--s),o=e.child(--i),c=a.nodeSize;if(a==o){r-=c,n-=c;continue}if(!a.sameMarkup(o))return{a:r,b:n};if(a.isText&&a.text!=o.text){let u=0,d=Math.min(a.text.length,o.text.length);for(;u<d&&a.text[a.text.length-u-1]==o.text[o.text.length-u-1];)u++,r--,n--;return{a:r,b:n}}if(a.content.size||o.content.size){let u=Vke(a.content,o.content,r-1,n-1);if(u)return u}r-=c,n-=c}}var _h=class ea{constructor(e,r){if(this.content=e,this.size=r||0,r==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,r,n,s=0,i){for(let a=0,o=0;o<r;a++){let c=this.content[a],u=o+c.nodeSize;if(u>e&&n(c,s+o,i||null,a)!==!1&&c.content.size){let d=o+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,r-d),n,s+d)}o=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,r,n,s){let i="",a=!0;return this.nodesBetween(e,r,(o,c)=>{let u=o.isText?o.text.slice(Math.max(e,c)-c,r-c):o.isLeaf?s?typeof s=="function"?s(o):s:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&u||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=u},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let r=this.lastChild,n=e.firstChild,s=this.content.slice(),i=0;for(r.isText&&r.sameMarkup(n)&&(s[s.length-1]=r.withText(r.text+n.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new ea(s,this.size+e.size)}cut(e,r=this.size){if(e==0&&r==this.size)return this;let n=[],s=0;if(r>e)for(let i=0,a=0;a<r;i++){let o=this.content[i],c=a+o.nodeSize;c>e&&((a<e||c>r)&&(o.isText?o=o.cut(Math.max(0,e-a),Math.min(o.text.length,r-a)):o=o.cut(Math.max(0,e-a-1),Math.min(o.content.size,r-a-1))),n.push(o),s+=o.nodeSize),a=c}return new ea(n,s)}cutByIndex(e,r){return e==r?ea.empty:e==0&&r==this.content.length?this:new ea(this.content.slice(e,r))}replaceChild(e,r){let n=this.content[e];if(n==r)return this;let s=this.content.slice(),i=this.size+r.nodeSize-n.nodeSize;return s[e]=r,new ea(s,i)}addToStart(e){return new ea([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ea(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let r=0;r<this.content.length;r++)if(!this.content[r].eq(e.content[r]))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 r=this.content[e];if(!r)throw new RangeError("Index "+e+" out of range for "+this);return r}maybeChild(e){return this.content[e]||null}forEach(e){for(let r=0,n=0;r<this.content.length;r++){let s=this.content[r];e(s,n,r),n+=s.nodeSize}}findDiffStart(e,r=0){return Hke(this,e,r)}findDiffEnd(e,r=this.size,n=e.size){return Vke(this,e,r,n)}findIndex(e){if(e==0)return MC(0,e);if(e==this.size)return MC(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,n=0;;r++){let s=this.child(r),i=n+s.nodeSize;if(i>=e)return i==e?MC(r+1,i):MC(r,n);n=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,r){if(!r)return ea.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return ea.fromArray(r.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ea.empty;let r,n=0;for(let s=0;s<e.length;s++){let i=e[s];n+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(r||(r=e.slice(0,s)),r[r.length-1]=i.withText(r[r.length-1].text+i.text)):r&&r.push(i)}return new ea(r||e,n)}static from(e){if(!e)return ea.empty;if(e instanceof ea)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ea([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};_h.empty=new _h([],0);var sF={index:0,offset:0};function MC(t,e){return sF.index=t,sF.offset=e,sF}var aMt=class extends Error{},ds=class gv{constructor(e,r,n){this.content=e,this.openStart=r,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,r){let n=qke(this.content,e+this.openStart,r,this.openStart+1,this.openEnd+1);return n&&new gv(n,this.openStart,this.openEnd)}removeBetween(e,r){return new gv(Wke(this.content,e+this.openStart,r+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,r){if(!r)return gv.empty;let n=r.openStart||0,s=r.openEnd||0;if(typeof n!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new gv(_h.fromJSON(e,r.content),n,s)}static maxOpen(e,r=!0){let n=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(r||!i.type.spec.isolating);i=i.firstChild)n++;for(let i=e.lastChild;i&&!i.isLeaf&&(r||!i.type.spec.isolating);i=i.lastChild)s++;return new gv(e,n,s)}};ds.empty=new ds(_h.empty,0,0);function Wke(t,e,r){let{index:n,offset:s}=t.findIndex(e),i=t.maybeChild(n),{index:a,offset:o}=t.findIndex(r);if(s==e||i.isText){if(o!=r&&!t.child(a).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(n!=a)throw new RangeError("Removing non-flat range");return t.replaceChild(n,i.copy(Wke(i.content,e-s-1,r-s-1)))}function qke(t,e,r,n,s,i){let{index:a,offset:o}=t.findIndex(e),c=t.maybeChild(a);if(o==e||c.isText)return i&&n<=0&&s<=0&&!i.canReplace(a,a,r)?null:t.cut(0,e).append(r).append(t.cut(e));let u=qke(c.content,e-o-1,r,a==0?n-1:0,a==t.childCount-1?s-1:0,c);return u&&t.replaceChild(a,c.copy(u))}var Gke=65535,Kke=Math.pow(2,16);function oMt(t,e){return t+e*Kke}function Cie(t){return t&Gke}function lMt(t){return(t-(t&Gke))/Kke}var Yke=1,Xke=2,o2=4,Jke=8,Tie=class{constructor(t,e,r){this.pos=t,this.delInfo=e,this.recover=r}get deleted(){return(this.delInfo&Jke)>0}get deletedBefore(){return(this.delInfo&(Yke|o2))>0}get deletedAfter(){return(this.delInfo&(Xke|o2))>0}get deletedAcross(){return(this.delInfo&o2)>0}},hx=class yv{constructor(e,r=!1){if(this.ranges=e,this.inverted=r,!e.length&&yv.empty)return yv.empty}recover(e){let r=0,n=Cie(e);if(!this.inverted)for(let s=0;s<n;s++)r+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[n*3]+r+lMt(e)}mapResult(e,r=1){return this._map(e,r,!1)}map(e,r=1){return this._map(e,r,!0)}_map(e,r,n){let s=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?s:0);if(c>e)break;let u=this.ranges[o+i],d=this.ranges[o+a],h=c+u;if(e<=h){let f=u?e==c?-1:e==h?1:r:r,p=c+s+(f<0?0:d);if(n)return p;let m=e==(r<0?c:h)?null:oMt(o/3,e-c),g=e==c?Xke:e==h?Yke:o2;return(r<0?e!=c:e!=h)&&(g|=Jke),new Tie(p,g,m)}s+=d-u}return n?e+s:new Tie(e+s,0,null)}touches(e,r){let n=0,s=Cie(r),i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?n:0);if(c>e)break;let u=this.ranges[o+i],d=c+u;if(e<=d&&o==s*3)return!0;n+=this.ranges[o+a]-u}return!1}forEach(e){let r=this.inverted?2:1,n=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let a=this.ranges[s],o=a-(this.inverted?i:0),c=a+(this.inverted?0:i),u=this.ranges[s+r],d=this.ranges[s+n];e(o,o+u,c,c+d),i+=d-u}}invert(){return new yv(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?yv.empty:new yv(e<0?[0,-e,0]:[0,0,e])}};hx.empty=new hx([]);var iF=Object.create(null),Ji=class{getMap(){return hx.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=iF[e.stepType];if(!r)throw new RangeError(`No step type ${e.stepType} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in iF)throw new RangeError("Duplicate use of step JSON ID "+t);return iF[t]=e,e.prototype.jsonID=t,e}},ma=class KS{constructor(e,r){this.doc=e,this.failed=r}static ok(e){return new KS(e,null)}static fail(e){return new KS(null,e)}static fromReplace(e,r,n,s){try{return KS.ok(e.replace(r,n,s))}catch(i){if(i instanceof aMt)return KS.fail(i.message);throw i}}};function Q7(t,e,r){let n=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Q7(i.content,e,i))),i.isInline&&(i=e(i,r,s)),n.push(i)}return _h.fromArray(n)}var Qke=class YS extends Ji{constructor(e,r,n){super(),this.from=e,this.to=r,this.mark=n}apply(e){let r=e.slice(this.from,this.to),n=e.resolve(this.from),s=n.node(n.sharedDepth(this.to)),i=new ds(Q7(r.content,(a,o)=>!a.isAtom||!o.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),s),r.openStart,r.openEnd);return ma.fromReplace(e,this.from,this.to,i)}invert(){return new Zke(this.from,this.to,this.mark)}map(e){let r=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new YS(r.pos,n.pos,this.mark)}merge(e){return e instanceof YS&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new YS(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,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new YS(r.from,r.to,e.markFromJSON(r.mark))}};Ji.jsonID("addMark",Qke);var Zke=class XS extends Ji{constructor(e,r,n){super(),this.from=e,this.to=r,this.mark=n}apply(e){let r=e.slice(this.from,this.to),n=new ds(Q7(r.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),r.openStart,r.openEnd);return ma.fromReplace(e,this.from,this.to,n)}invert(){return new Qke(this.from,this.to,this.mark)}map(e){let r=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new XS(r.pos,n.pos,this.mark)}merge(e){return e instanceof XS&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new XS(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,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new XS(r.from,r.to,e.markFromJSON(r.mark))}};Ji.jsonID("removeMark",Zke);var eNe=class JS extends Ji{constructor(e,r){super(),this.pos=e,this.mark=r}apply(e){let r=e.nodeAt(this.pos);if(!r)return ma.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return ma.fromReplace(e,this.pos,this.pos+1,new ds(_h.from(n),0,r.isLeaf?0:1))}invert(e){let r=e.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let s=0;s<r.marks.length;s++)if(!r.marks[s].isInSet(n))return new JS(this.pos,r.marks[s]);return new JS(this.pos,this.mark)}}return new tNe(this.pos,this.mark)}map(e){let r=e.mapResult(this.pos,1);return r.deletedAfter?null:new JS(r.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,r){if(typeof r.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new JS(r.pos,e.markFromJSON(r.mark))}};Ji.jsonID("addNodeMark",eNe);var tNe=class pU extends Ji{constructor(e,r){super(),this.pos=e,this.mark=r}apply(e){let r=e.nodeAt(this.pos);if(!r)return ma.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.removeFromSet(r.marks));return ma.fromReplace(e,this.pos,this.pos+1,new ds(_h.from(n),0,r.isLeaf?0:1))}invert(e){let r=e.nodeAt(this.pos);return!r||!this.mark.isInSet(r.marks)?this:new eNe(this.pos,this.mark)}map(e){let r=e.mapResult(this.pos,1);return r.deletedAfter?null:new pU(r.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,r){if(typeof r.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new pU(r.pos,e.markFromJSON(r.mark))}};Ji.jsonID("removeNodeMark",tNe);var Z7=class tf extends Ji{constructor(e,r,n,s=!1){super(),this.from=e,this.to=r,this.slice=n,this.structure=s}apply(e){return this.structure&&mU(e,this.from,this.to)?ma.fail("Structure replace would overwrite content"):ma.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new hx([this.from,this.to-this.from,this.slice.size])}invert(e){return new tf(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let r=e.mapResult(this.to,-1),n=this.from==this.to&&tf.MAP_BIAS<0?r:e.mapResult(this.from,1);return n.deletedAcross&&r.deletedAcross?null:new tf(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof tf)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let r=this.slice.size+e.slice.size==0?ds.empty:new ds(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new tf(this.from,this.to+(e.to-e.from),r,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let r=this.slice.size+e.slice.size==0?ds.empty:new ds(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new tf(e.from,this.to,r,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,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new tf(r.from,r.to,ds.fromJSON(e,r.slice),!!r.structure)}};Z7.MAP_BIAS=1;Ji.jsonID("replace",Z7);var rNe=class l2 extends Ji{constructor(e,r,n,s,i,a,o=!1){super(),this.from=e,this.to=r,this.gapFrom=n,this.gapTo=s,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(mU(e,this.from,this.gapFrom)||mU(e,this.gapTo,this.to)))return ma.fail("Structure gap-replace would overwrite content");let r=e.slice(this.gapFrom,this.gapTo);if(r.openStart||r.openEnd)return ma.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,r.content);return n?ma.fromReplace(e,this.from,this.to,n):ma.fail("Content does not fit in gap")}getMap(){return new hx([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let r=this.gapTo-this.gapFrom;return new l2(this.from,this.from+this.slice.size+r,this.from+this.insert,this.from+this.insert+r,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let r=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),s=this.from==this.gapFrom?r.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return r.deletedAcross&&n.deletedAcross||s<r.pos||i>n.pos?null:new l2(r.pos,n.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,r){if(typeof r.from!="number"||typeof r.to!="number"||typeof r.gapFrom!="number"||typeof r.gapTo!="number"||typeof r.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new l2(r.from,r.to,r.gapFrom,r.gapTo,ds.fromJSON(e,r.slice),r.insert,!!r.structure)}};Ji.jsonID("replaceAround",rNe);function mU(t,e,r){let n=t.resolve(e),s=r-e,i=n.depth;for(;s>0&&i>0&&n.indexAfter(i)==n.node(i).childCount;)i--,s--;if(s>0){let a=n.node(i).maybeChild(n.indexAfter(i));for(;s>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,s--}}return!1}var cMt=class c2 extends Ji{constructor(e,r,n){super(),this.pos=e,this.attr=r,this.value=n}apply(e){let r=e.nodeAt(this.pos);if(!r)return ma.fail("No node at attribute step's position");let n=Object.create(null);for(let i in r.attrs)n[i]=r.attrs[i];n[this.attr]=this.value;let s=r.type.create(n,null,r.marks);return ma.fromReplace(e,this.pos,this.pos+1,new ds(_h.from(s),0,r.isLeaf?0:1))}getMap(){return hx.empty}invert(e){return new c2(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let r=e.mapResult(this.pos,1);return r.deletedAfter?null:new c2(r.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,r){if(typeof r.pos!="number"||typeof r.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new c2(r.pos,r.attr,r.value)}};Ji.jsonID("attr",cMt);var uMt=class gU extends Ji{constructor(e,r){super(),this.attr=e,this.value=r}apply(e){let r=Object.create(null);for(let s in e.attrs)r[s]=e.attrs[s];r[this.attr]=this.value;let n=e.type.create(r,e.content,e.marks);return ma.ok(n)}getMap(){return hx.empty}invert(e){return new gU(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,r){if(typeof r.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new gU(r.attr,r.value)}};Ji.jsonID("docAttr",uMt);var fk=class extends Error{};fk=function t(e){let r=Error.call(this,e);return r.__proto__=t.prototype,r};fk.prototype=Object.create(Error.prototype);fk.prototype.constructor=fk;fk.prototype.name="TransformError";var aF=Object.create(null),Gs=class{constructor(t,e,r){this.$anchor=t,this.$head=e,this.ranges=r||[new dMt(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=ds.empty){let r=e.content.lastChild,n=null;for(let a=0;a<e.openEnd;a++)n=r,r=r.lastChild;let s=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:c}=i[a],u=t.mapping.slice(s);t.replaceRange(u.map(o.pos),u.map(c.pos),a?ds.empty:e),a==0&&Iie(t,s,(r?r.isInline:n&&n.isTextblock)?-1:1)}}replaceWith(t,e){let r=t.steps.length,n=this.ranges;for(let s=0;s<n.length;s++){let{$from:i,$to:a}=n[s],o=t.mapping.slice(r),c=o.map(i.pos),u=o.map(a.pos);s?t.deleteRange(c,u):(t.replaceRangeWith(c,u,e),Iie(t,r,e.isInline?-1:1))}}static findFrom(t,e,r=!1){let n=t.parent.inlineContent?new Iw(t):xv(t.node(0),t.parent,t.pos,t.index(),e,r);if(n)return n;for(let s=t.depth-1;s>=0;s--){let i=e<0?xv(t.node(0),t.node(s),t.before(s+1),t.index(s),e,r):xv(t.node(0),t.node(s),t.after(s+1),t.index(s)+1,e,r);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new O_(t.node(0))}static atStart(t){return xv(t,t,0,0,1)||new O_(t)}static atEnd(t){return xv(t,t,t.content.size,t.childCount,-1)||new O_(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=aF[e.type];if(!r)throw new RangeError(`No selection type ${e.type} defined`);return r.fromJSON(t,e)}static jsonID(t,e){if(t in aF)throw new RangeError("Duplicate use of selection JSON ID "+t);return aF[t]=e,e.prototype.jsonID=t,e}getBookmark(){return Iw.between(this.$anchor,this.$head).getBookmark()}};Gs.prototype.visible=!0;var dMt=class{constructor(t,e){this.$from=t,this.$to=e}},Pie=!1;function Oie(t){!Pie&&!t.parent.inlineContent&&(Pie=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var Iw=class QS extends Gs{constructor(e,r=e){Oie(e),Oie(r),super(e,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,r){let n=e.resolve(r.map(this.head));if(!n.parent.inlineContent)return Gs.near(n);let s=e.resolve(r.map(this.anchor));return new QS(s.parent.inlineContent?s:n,n)}replace(e,r=ds.empty){if(super.replace(e,r),r==ds.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof QS&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new nNe(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new QS(e.resolve(r.anchor),e.resolve(r.head))}static create(e,r,n=r){let s=e.resolve(r);return new this(s,n==r?s:e.resolve(n))}static between(e,r,n){let s=e.pos-r.pos;if((!n||s)&&(n=s>=0?1:-1),!r.parent.inlineContent){let i=Gs.findFrom(r,n,!0)||Gs.findFrom(r,-n,!0);if(i)r=i.$head;else return Gs.near(r,n)}return e.parent.inlineContent||(s==0?e=r:(e=(Gs.findFrom(e,-n,!0)||Gs.findFrom(e,n,!0)).$anchor,e.pos<r.pos!=s<0&&(e=r))),new QS(e,r)}};Gs.jsonID("text",Iw);var nNe=class sNe{constructor(e,r){this.anchor=e,this.head=r}map(e){return new sNe(e.map(this.anchor),e.map(this.head))}resolve(e){return Iw.between(e.resolve(this.anchor),e.resolve(this.head))}},Rw=class ZS extends Gs{constructor(e){let r=e.nodeAfter,n=e.node(0).resolve(e.pos+r.nodeSize);super(e,n),this.node=r}map(e,r){let{deleted:n,pos:s}=r.mapResult(this.anchor),i=e.resolve(s);return n?Gs.near(i):new ZS(i)}content(){return new ds(_h.from(this.node),0,0)}eq(e){return e instanceof ZS&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new hMt(this.anchor)}static fromJSON(e,r){if(typeof r.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ZS(e.resolve(r.anchor))}static create(e,r){return new ZS(e.resolve(r))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Rw.prototype.visible=!1;Gs.jsonID("node",Rw);var hMt=class iNe{constructor(e){this.anchor=e}map(e){let{deleted:r,pos:n}=e.mapResult(this.anchor);return r?new nNe(n,n):new iNe(n)}resolve(e){let r=e.resolve(this.anchor),n=r.nodeAfter;return n&&Rw.isSelectable(n)?new Rw(r):Gs.near(r)}},O_=class u2 extends Gs{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,r=ds.empty){if(r==ds.empty){e.delete(0,e.doc.content.size);let n=Gs.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,r)}toJSON(){return{type:"all"}}static fromJSON(e){return new u2(e)}map(e){return new u2(e)}eq(e){return e instanceof u2}getBookmark(){return fMt}};Gs.jsonID("all",O_);var fMt={map(){return this},resolve(t){return new O_(t)}};function xv(t,e,r,n,s,i=!1){if(e.inlineContent)return Iw.create(t,r);for(let a=n-(s>0?0:1);s>0?a<e.childCount:a>=0;a+=s){let o=e.child(a);if(o.isAtom){if(!i&&Rw.isSelectable(o))return Rw.create(t,r-(s<0?o.nodeSize:0))}else{let c=xv(t,o,r+s,s<0?o.childCount:0,s,i);if(c)return c}r+=o.nodeSize*s}return null}function Iie(t,e,r){let n=t.steps.length-1;if(n<e)return;let s=t.steps[n];if(!(s instanceof Z7||s instanceof rNe))return;let i=t.mapping.maps[n],a;i.forEach((o,c,u,d)=>{a==null&&(a=d)}),t.setSelection(Gs.near(t.doc.resolve(a),r))}function Rie(t,e){return!e||!t?t:t.bind(e)}var DC=class{constructor(t,e,r){this.name=t,this.init=Rie(e.init,r),this.apply=Rie(e.apply,r)}};new DC("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new DC("selection",{init(t,e){return t.selection||Gs.atStart(e.doc)},apply(t){return t.selection}}),new DC("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,n){return n.selection.$cursor?t.storedMarks:null}}),new DC("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});var pMt=(t,e)=>{var r;const{state:n,view:s}=t,{selection:i}=n;if(!i.empty)return!1;const{$from:a}=i;if(a.parentOffset!==0)return!1;const o=a.depth-1,c=a.node(o),u=a.index(o);if(u===0)return!1;if(c.type===e)return t.commands.lift(e.name);const d=c.child(u-1);if(d.type!==e||!((r=d.lastChild)!=null&&r.isTextblock))return!1;const h=a.before(),p=h-1-1,{tr:m}=n;return m.delete(h,a.after()).insert(p,a.parent.content),m.setSelection(Iw.create(m.doc,p)),s.dispatch(m.scrollIntoView()),!0},mMt=/^\s*>\s$/,gMt=Mo.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return BO("blockquote",{...Ps(this.options.HTMLAttributes,t),children:BO("slot",{})})},parseMarkdown:(t,e)=>{var r;const n=(r=e.parseBlockChildren)!=null?r:e.parseChildren;return e.createNode("blockquote",void 0,n(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const r=">",n=[];return t.content.forEach((s,i)=>{var a,o;const d=((o=(a=e.renderChild)==null?void 0:a.call(e,s,i))!=null?o:e.renderChildren([s])).split(`
`).map(h=>h.trim()===""?r:`${r} ${h}`);n.push(d.join(`
`))}),n.join(`
${r}
`)},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:()=>pMt(this.editor,this.type)}},addInputRules(){return[Ow({find:mMt,type:this.type})]}}),yMt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,xMt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,vMt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,bMt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,wMt=Ox.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 BO("strong",{...Ps(this.options.HTMLAttributes,t),children:BO("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[Pw({find:yMt,type:this.type}),Pw({find:vMt,type:this.type})]},addPasteRules(){return[dx({find:xMt,type:this.type}),dx({find:bMt,type:this.type})]}}),SMt=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},_Mt=t=>{const e=/`([^`]+)`(?!`)/g,r=[];let n;for(;(n=e.exec(t))!==null;)n.index>0&&t[n.index-1]==="`"||r.push({index:n.index,text:n[0],replaceWith:n[1]});return r},jMt=Ox.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Ps(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[Pw({find:SMt,type:this.type})]},addPasteRules(){return[dx({find:_Mt,type:this.type})]}}),oF=4,kMt=/^```([a-z]+)?[\s\n]$/,NMt=/^~~~([a-z]+)?[\s\n]$/,EMt=Mo.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:oF,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:r}=this.options;if(!r)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(a=>a.startsWith(r)).map(a=>a.replace(r,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Ps(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var r,n;return((r=t.raw)==null?void 0:r.startsWith("```"))===!1&&((n=t.raw)==null?void 0:n.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var r;let n="";const s=((r=t.attrs)==null?void 0:r.language)||"";return t.content?n=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
`):n=`\`\`\`${s}
\`\`\``,n},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,r=e.pos===1;return!t||e.parent.type.name!==this.name?!1:r||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const r=(e=this.options.tabSize)!=null?e:oF,{state:n}=t,{selection:s}=n,{$from:i,empty:a}=s;if(i.parent.type!==this.type)return!1;const o=" ".repeat(r);return a?t.commands.insertContent(o):t.commands.command(({tr:c})=>{const{from:u,to:d}=s,p=n.doc.textBetween(u,d,`
`,`
`).split(`
`).map(m=>o+m).join(`
`);return c.replaceWith(u,d,n.schema.text(p)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const r=(e=this.options.tabSize)!=null?e:oF,{state:n}=t,{selection:s}=n,{$from:i,empty:a}=s;return i.parent.type!==this.type?!1:a?t.commands.command(({tr:o})=>{var c;const{pos:u}=i,d=i.start(),h=i.end(),p=n.doc.textBetween(d,h,`
`,`
`).split(`
`);let m=0,g=0;const x=u-d;for(let k=0;k<p.length;k+=1){if(g+p[k].length>=x){m=k;break}g+=p[k].length+1}const v=((c=p[m].match(/^ */))==null?void 0:c[0])||"",b=Math.min(v.length,r);if(b===0)return!0;let w=d;for(let k=0;k<m;k+=1)w+=p[k].length+1;return o.delete(w,w+b),u-w<=b&&o.setSelection(Bt.create(o.doc,w)),!0}):t.commands.command(({tr:o})=>{const{from:c,to:u}=s,f=n.doc.textBetween(c,u,`
`,`
`).split(`
`).map(p=>{var m;const g=((m=p.match(/^ */))==null?void 0:m[0])||"",x=Math.min(g.length,r);return p.slice(x)}).join(`
`);return o.replaceWith(c,u,n.schema.text(f)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:r}=e,{$from:n,empty:s}=r;if(!s||n.parent.type!==this.type)return!1;const i=n.parentOffset===n.parent.nodeSize-2,a=n.parent.textContent.endsWith(`
`);return!i||!a?!1:t.chain().command(({tr:o})=>(o.delete(n.pos-2,n.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:r,doc:n}=e,{$from:s,empty:i}=r;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const o=s.after();return o===void 0?!1:n.nodeAt(o)?t.commands.command(({tr:u})=>(u.setSelection(qt.near(n.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[fU({find:kMt,type:this.type,getAttributes:t=>({language:t[1]})}),fU({find:NMt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new fn({key:new ys("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const r=e.clipboardData.getData("text/plain"),n=e.clipboardData.getData("vscode-editor-data"),s=n?JSON.parse(n):void 0,i=s==null?void 0:s.mode;if(!r||!i)return!1;const{tr:a,schema:o}=t.state,c=o.text(r.replace(/\r\n?/g,`
`));return a.replaceSelectionWith(this.type.create({language:i},c)),a.selection.$from.parent.type!==this.type&&a.setSelection(Bt.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),AMt=Mo.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):""}),CMt=Mo.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",Ps(this.options.HTMLAttributes,t)]},renderText(){return`
`},renderMarkdown:()=>`
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=r;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:o}=n.extensionManager,c=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&a){const h=c.filter(f=>o.includes(f.type.name));u.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),TMt=Mo.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]}`,Ps(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var r;const n=(r=t.attrs)!=null&&r.level?parseInt(t.attrs.level,10):1,s="#".repeat(n);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=>fU({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),PMt=Mo.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Ps(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!pRt(e,e.schema.nodes[this.name]))return!1;const{selection:r}=e,{$to:n}=r,s=t();return mke(r)?s.insertContentAt(n.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:a,dispatch:o})=>{if(o){const{$to:c}=a.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?a.setSelection(Bt.create(a.doc,c.pos+1)):c.nodeAfter.isBlock?a.setSelection(Ot.create(a.doc,c.pos)):a.setSelection(Bt.create(a.doc,c.pos));else{const d=i.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,h=d==null?void 0:d.create();h&&(a.insert(u,h),a.setSelection(Bt.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[MRt({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),OMt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,IMt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,RMt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,MMt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,DMt=Ox.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",Ps(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[Pw({find:OMt,type:this.type}),Pw({find:RMt,type:this.type})]},addPasteRules(){return[dx({find:IMt,type:this.type}),dx({find:MMt,type:this.type})]}});const LMt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",FMt="ελ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",yU="numeric",xU="ascii",vU="alpha",I_="asciinumeric",e_="alphanumeric",bU="domain",aNe="emoji",$Mt="scheme",BMt="slashscheme",lF="whitespace";function zMt(t,e){return t in e||(e[t]=[]),e[t]}function ug(t,e,r){e[yU]&&(e[I_]=!0,e[e_]=!0),e[xU]&&(e[I_]=!0,e[vU]=!0),e[I_]&&(e[e_]=!0),e[vU]&&(e[e_]=!0),e[e_]&&(e[bU]=!0),e[aNe]&&(e[bU]=!0);for(const n in e){const s=zMt(n,r);s.indexOf(t)<0&&s.push(t)}}function UMt(t,e){const r={};for(const n in e)e[n].indexOf(t)>=0&&(r[n]=!0);return r}function Fa(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Fa.groups={};Fa.prototype={accepts(){return!!this.t},go(t){const e=this,r=e.j[t];if(r)return r;for(let n=0;n<e.jr.length;n++){const s=e.jr[n][0],i=e.jr[n][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,r,n){for(let s=0;s<t.length;s++)this.tt(t[s],e,r,n)},tr(t,e,r,n){n=n||Fa.groups;let s;return e&&e.j?s=e:(s=new Fa(e),r&&n&&ug(e,r,n)),this.jr.push([t,s]),s},ts(t,e,r,n){let s=this;const i=t.length;if(!i)return s;for(let a=0;a<i-1;a++)s=s.tt(t[a]);return s.tt(t[i-1],e,r,n)},tt(t,e,r,n){n=n||Fa.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let a,o=s.go(t);if(o?(a=new Fa,Object.assign(a.j,o.j),a.jr.push.apply(a.jr,o.jr),a.jd=o.jd,a.t=o.t):a=new Fa,i){if(n)if(a.t&&typeof a.t=="string"){const c=Object.assign(UMt(a.t,n),r);ug(i,c,n)}else r&&ug(i,r,n);a.t=i}return s.j[t]=a,a}};const Yt=(t,e,r,n,s)=>t.ta(e,r,n,s),Rn=(t,e,r,n,s)=>t.tr(e,r,n,s),Mie=(t,e,r,n,s)=>t.ts(e,r,n,s),Xe=(t,e,r,n,s)=>t.tt(e,r,n,s),td="WORD",wU="UWORD",oNe="ASCIINUMERICAL",lNe="ALPHANUMERICAL",pk="LOCALHOST",SU="TLD",_U="UTLD",d2="SCHEME",vv="SLASH_SCHEME",eq="NUM",jU="WS",tq="NL",R_="OPENBRACE",M_="CLOSEBRACE",zO="OPENBRACKET",UO="CLOSEBRACKET",HO="OPENPAREN",VO="CLOSEPAREN",WO="OPENANGLEBRACKET",qO="CLOSEANGLEBRACKET",GO="FULLWIDTHLEFTPAREN",KO="FULLWIDTHRIGHTPAREN",YO="LEFTCORNERBRACKET",XO="RIGHTCORNERBRACKET",JO="LEFTWHITECORNERBRACKET",QO="RIGHTWHITECORNERBRACKET",ZO="FULLWIDTHLESSTHAN",eI="FULLWIDTHGREATERTHAN",tI="AMPERSAND",rI="APOSTROPHE",nI="ASTERISK",of="AT",sI="BACKSLASH",iI="BACKTICK",aI="CARET",dg="COLON",rq="COMMA",oI="DOLLAR",Fc="DOT",lI="EQUALS",nq="EXCLAMATION",Vo="HYPHEN",D_="PERCENT",cI="PIPE",uI="PLUS",dI="POUND",L_="QUERY",sq="QUOTE",cNe="FULLWIDTHMIDDLEDOT",iq="SEMI",$c="SLASH",F_="TILDE",hI="UNDERSCORE",uNe="EMOJI",fI="SYM";var dNe=Object.freeze({__proto__:null,ALPHANUMERICAL:lNe,AMPERSAND:tI,APOSTROPHE:rI,ASCIINUMERICAL:oNe,ASTERISK:nI,AT:of,BACKSLASH:sI,BACKTICK:iI,CARET:aI,CLOSEANGLEBRACKET:qO,CLOSEBRACE:M_,CLOSEBRACKET:UO,CLOSEPAREN:VO,COLON:dg,COMMA:rq,DOLLAR:oI,DOT:Fc,EMOJI:uNe,EQUALS:lI,EXCLAMATION:nq,FULLWIDTHGREATERTHAN:eI,FULLWIDTHLEFTPAREN:GO,FULLWIDTHLESSTHAN:ZO,FULLWIDTHMIDDLEDOT:cNe,FULLWIDTHRIGHTPAREN:KO,HYPHEN:Vo,LEFTCORNERBRACKET:YO,LEFTWHITECORNERBRACKET:JO,LOCALHOST:pk,NL:tq,NUM:eq,OPENANGLEBRACKET:WO,OPENBRACE:R_,OPENBRACKET:zO,OPENPAREN:HO,PERCENT:D_,PIPE:cI,PLUS:uI,POUND:dI,QUERY:L_,QUOTE:sq,RIGHTCORNERBRACKET:XO,RIGHTWHITECORNERBRACKET:QO,SCHEME:d2,SEMI:iq,SLASH:$c,SLASH_SCHEME:vv,SYM:fI,TILDE:F_,TLD:SU,UNDERSCORE:hI,UTLD:_U,UWORD:wU,WORD:td,WS:jU});const Ku=/[a-z]/,rS=new RegExp("\\p{L}","u"),cF=new RegExp("\\p{Emoji}","u"),Yu=/\d/,uF=/\s/,Die="\r",dF=`
`,HMt="️",VMt="",hF="";let LC=null,FC=null;function WMt(t=[]){const e={};Fa.groups=e;const r=new Fa;LC==null&&(LC=Lie(LMt)),FC==null&&(FC=Lie(FMt)),Xe(r,"'",rI),Xe(r,"{",R_),Xe(r,"}",M_),Xe(r,"[",zO),Xe(r,"]",UO),Xe(r,"(",HO),Xe(r,")",VO),Xe(r,"<",WO),Xe(r,">",qO),Xe(r,"(",GO),Xe(r,")",KO),Xe(r,"「",YO),Xe(r,"」",XO),Xe(r,"『",JO),Xe(r,"』",QO),Xe(r,"<",ZO),Xe(r,">",eI),Xe(r,"&",tI),Xe(r,"*",nI),Xe(r,"@",of),Xe(r,"`",iI),Xe(r,"^",aI),Xe(r,":",dg),Xe(r,",",rq),Xe(r,"$",oI),Xe(r,".",Fc),Xe(r,"=",lI),Xe(r,"!",nq),Xe(r,"-",Vo),Xe(r,"%",D_),Xe(r,"|",cI),Xe(r,"+",uI),Xe(r,"#",dI),Xe(r,"?",L_),Xe(r,'"',sq),Xe(r,"/",$c),Xe(r,";",iq),Xe(r,"~",F_),Xe(r,"_",hI),Xe(r,"\\",sI),Xe(r,"・",cNe);const n=Rn(r,Yu,eq,{[yU]:!0});Rn(n,Yu,n);const s=Rn(n,Ku,oNe,{[I_]:!0}),i=Rn(n,rS,lNe,{[e_]:!0}),a=Rn(r,Ku,td,{[xU]:!0});Rn(a,Yu,s),Rn(a,Ku,a),Rn(s,Yu,s),Rn(s,Ku,s);const o=Rn(r,rS,wU,{[vU]:!0});Rn(o,Ku),Rn(o,Yu,i),Rn(o,rS,o),Rn(i,Yu,i),Rn(i,Ku),Rn(i,rS,i);const c=Xe(r,dF,tq,{[lF]:!0}),u=Xe(r,Die,jU,{[lF]:!0}),d=Rn(r,uF,jU,{[lF]:!0});Xe(r,hF,d),Xe(u,dF,c),Xe(u,hF,d),Rn(u,uF,d),Xe(d,Die),Xe(d,dF),Rn(d,uF,d),Xe(d,hF,d);const h=Rn(r,cF,uNe,{[aNe]:!0});Xe(h,"#"),Rn(h,cF,h),Xe(h,HMt,h);const f=Xe(h,VMt);Xe(f,"#"),Rn(f,cF,h);const p=[[Ku,a],[Yu,s]],m=[[Ku,null],[rS,o],[Yu,i]];for(let g=0;g<LC.length;g++)qh(r,LC[g],SU,td,p);for(let g=0;g<FC.length;g++)qh(r,FC[g],_U,wU,m);ug(SU,{tld:!0,ascii:!0},e),ug(_U,{utld:!0,alpha:!0},e),qh(r,"file",d2,td,p),qh(r,"mailto",d2,td,p),qh(r,"http",vv,td,p),qh(r,"https",vv,td,p),qh(r,"ftp",vv,td,p),qh(r,"ftps",vv,td,p),ug(d2,{scheme:!0,ascii:!0},e),ug(vv,{slashscheme:!0,ascii:!0},e),t=t.sort((g,x)=>g[0]>x[0]?1:-1);for(let g=0;g<t.length;g++){const x=t[g][0],v=t[g][1]?{[$Mt]:!0}:{[BMt]:!0};x.indexOf("-")>=0?v[bU]=!0:Ku.test(x)?Yu.test(x)?v[I_]=!0:v[xU]=!0:v[yU]=!0,Mie(r,x,x,v)}return Mie(r,"localhost",pk,{ascii:!0}),r.jd=new Fa(fI),{start:r,tokens:Object.assign({groups:e},dNe)}}function hNe(t,e){const r=qMt(e.replace(/[A-Z]/g,o=>o.toLowerCase())),n=r.length,s=[];let i=0,a=0;for(;a<n;){let o=t,c=null,u=0,d=null,h=-1,f=-1;for(;a<n&&(c=o.go(r[a]));)o=c,o.accepts()?(h=0,f=0,d=o):h>=0&&(h+=r[a].length,f++),u+=r[a].length,i+=r[a].length,a++;i-=h,a-=f,u-=h,s.push({t:d.t,v:e.slice(i-u,i),s:i-u,e:i})}return s}function qMt(t){const e=[],r=t.length;let n=0;for(;n<r;){let s=t.charCodeAt(n),i,a=s<55296||s>56319||n+1===r||(i=t.charCodeAt(n+1))<56320||i>57343?t[n]:t.slice(n,n+2);e.push(a),n+=a.length}return e}function qh(t,e,r,n,s){let i;const a=e.length;for(let o=0;o<a-1;o++){const c=e[o];t.j[c]?i=t.j[c]:(i=new Fa(n),i.jr=s.slice(),t.j[c]=i),t=i}return i=new Fa(r),i.jr=s.slice(),t.j[e[a-1]]=i,i}function Lie(t){const e=[],r=[];let n=0,s="0123456789";for(;n<t.length;){let i=0;for(;s.indexOf(t[n+i])>=0;)i++;if(i>0){e.push(r.join(""));for(let a=parseInt(t.substring(n,n+i),10);a>0;a--)r.pop();n+=i}else r.push(t[n]),n++}return e}const mk={defaultProtocol:"http",events:null,format:Fie,formatHref:Fie,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function aq(t,e=null){let r=Object.assign({},mk);t&&(r=Object.assign(r,t instanceof aq?t.o:t));const n=r.ignoreTags,s=[];for(let i=0;i<n.length;i++)s.push(n[i].toUpperCase());this.o=r,e&&(this.defaultRender=e),this.ignoreTags=s}aq.prototype={o:mk,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,r){const n=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=r.t in s?s[r.t]:mk[t],typeof s=="function"&&n&&(s=s(e,r))):typeof s=="function"&&n&&(s=s(e,r.t,r)),s)},getObj(t,e,r){let n=this.o[t];return typeof n=="function"&&e!=null&&(n=n(e,r.t,r)),n},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Fie(t){return t}function fNe(t,e){this.t="token",this.v=t,this.tk=e}fNe.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),r=t.get("truncate",e,this),n=t.get("format",e,this);return r&&n.length>r?n.substring(0,r)+"…":n},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=mk.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,r=this.toHref(t.get("defaultProtocol")),n=t.get("formatHref",r,this),s=t.get("tagName",r,e),i=this.toFormattedString(t),a={},o=t.get("className",r,e),c=t.get("target",r,e),u=t.get("rel",r,e),d=t.getObj("attributes",r,e),h=t.getObj("events",r,e);return a.href=n,o&&(a.class=o),c&&(a.target=c),u&&(a.rel=u),d&&Object.assign(a,d),{tagName:s,attributes:a,content:i,eventListeners:h}}};function _D(t,e){class r extends fNe{constructor(s,i){super(s,i),this.t=t}}for(const n in e)r.prototype[n]=e[n];return r.t=t,r}const GMt=_D("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),$ie=_D("text"),KMt=_D("nl"),$C=_D("url",{isLink:!0,toHref(t=mk.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==pk&&t[1].t===dg}}),Uo=t=>new Fa(t);function YMt({groups:t}){const e=t.domain.concat([tI,nI,of,sI,iI,aI,oI,lI,Vo,eq,D_,cI,uI,dI,$c,fI,F_,hI]),r=[rI,dg,rq,Fc,nq,D_,L_,sq,iq,WO,qO,R_,M_,UO,zO,HO,VO,GO,KO,YO,XO,JO,QO,ZO,eI],n=[tI,rI,nI,sI,iI,aI,oI,lI,Vo,R_,M_,D_,cI,uI,dI,L_,$c,fI,F_,hI],s=Uo(),i=Xe(s,F_);Yt(i,n,i),Yt(i,t.domain,i);const a=Uo(),o=Uo(),c=Uo();Yt(s,t.domain,a),Yt(s,t.scheme,o),Yt(s,t.slashscheme,c),Yt(a,n,i),Yt(a,t.domain,a);const u=Xe(a,of);Xe(i,of,u),Xe(o,of,u),Xe(c,of,u);const d=Xe(i,Fc);Yt(d,n,i),Yt(d,t.domain,i);const h=Uo();Yt(u,t.domain,h),Yt(h,t.domain,h);const f=Xe(h,Fc);Yt(f,t.domain,h);const p=Uo(GMt);Yt(f,t.tld,p),Yt(f,t.utld,p),Xe(u,pk,p);const m=Xe(h,Vo);Xe(m,Vo,m),Yt(m,t.domain,h),Yt(p,t.domain,h),Xe(p,Fc,f),Xe(p,Vo,m);const g=Xe(a,Vo),x=Xe(a,Fc);Xe(g,Vo,g),Yt(g,t.domain,a),Yt(x,n,i),Yt(x,t.domain,a);const y=Uo($C);Yt(x,t.tld,y),Yt(x,t.utld,y),Yt(y,t.domain,a),Yt(y,n,i),Xe(y,Fc,x),Xe(y,Vo,g),Xe(y,of,u);const v=Xe(y,dg),b=Uo($C);Yt(v,t.numeric,b);const w=Uo($C),S=Uo();Yt(w,e,w),Yt(w,r,S),Yt(S,e,w),Yt(S,r,S),Xe(y,$c,w),Xe(b,$c,w);const k=Xe(o,dg),E=Xe(c,dg),C=Xe(E,$c),A=Xe(C,$c);Yt(o,t.domain,a),Xe(o,Fc,x),Xe(o,Vo,g),Yt(c,t.domain,a),Xe(c,Fc,x),Xe(c,Vo,g),Yt(k,t.domain,w),Xe(k,$c,w),Xe(k,L_,w),Yt(A,t.domain,w),Yt(A,e,w),Xe(A,$c,w);const M=[[R_,M_],[zO,UO],[HO,VO],[WO,qO],[GO,KO],[YO,XO],[JO,QO],[ZO,eI]];for(let z=0;z<M.length;z++){const[P,W]=M[z],N=Xe(w,P);Xe(S,P,N);const U=Uo($C);Yt(N,e,U);const K=Uo();Yt(N,r,K),Xe(N,W,w),Yt(U,e,U),Yt(U,r,K),Yt(K,e,U),Yt(K,r,K),Xe(U,W,w),Xe(K,W,w)}return Xe(s,pk,y),Xe(s,tq,KMt),{start:s,tokens:dNe}}function XMt(t,e,r){let n=r.length,s=0,i=[],a=[];for(;s<n;){let o=t,c=null,u=null,d=0,h=null,f=-1;for(;s<n&&!(c=o.go(r[s].t));)a.push(r[s++]);for(;s<n&&(u=c||o.go(r[s].t));)c=null,o=u,o.accepts()?(f=0,h=o):f>=0&&f++,s++,d++;if(f<0)s-=d,s<n&&(a.push(r[s]),s++);else{a.length>0&&(i.push(fF($ie,e,a)),a=[]),s-=f,d-=f;const p=h.t,m=r.slice(s-d,s);i.push(fF(p,e,m))}}return a.length>0&&i.push(fF($ie,e,a)),i}function fF(t,e,r){const n=r[0].s,s=r[r.length-1].e,i=e.slice(n,s);return new t(i,r)}const JMt=typeof console<"u"&&console&&console.warn||(()=>{}),QMt="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",cn={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ZMt(){return Fa.groups={},cn.scanner=null,cn.parser=null,cn.tokenQueue=[],cn.pluginQueue=[],cn.customSchemes=[],cn.initialized=!1,cn}function Bie(t,e=!1){if(cn.initialized&&JMt(`linkifyjs: already initialized - will not register custom scheme "${t}" ${QMt}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
1. Must only contain digits, lowercase ASCII letters or "-"
2. Cannot start or end with "-"
3. "-" cannot repeat`);cn.customSchemes.push([t,e])}function eDt(){cn.scanner=WMt(cn.customSchemes);for(let t=0;t<cn.tokenQueue.length;t++)cn.tokenQueue[t][1]({scanner:cn.scanner});cn.parser=YMt(cn.scanner.tokens);for(let t=0;t<cn.pluginQueue.length;t++)cn.pluginQueue[t][1]({scanner:cn.scanner,parser:cn.parser});return cn.initialized=!0,cn}function oq(t){return cn.initialized||eDt(),XMt(cn.parser.start,t,hNe(cn.scanner.start,t))}oq.scan=hNe;function pNe(t,e=null,r=null){if(e&&typeof e=="object"){if(r)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);r=e,e=null}const n=new aq(r),s=oq(t),i=[];for(let a=0;a<s.length;a++){const o=s[a];o.isLink&&(!e||o.t===e)&&n.check(o)&&i.push(o.toFormattedObject(n))}return i}var lq="[\0- -\u2029 ]",tDt=new RegExp(lq),rDt=new RegExp(`${lq}$`),nDt=new RegExp(lq,"g");function sDt(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function iDt(t){return new fn({key:new ys("autolink"),appendTransaction:(e,r,n)=>{const s=e.some(u=>u.docChanged)&&!r.doc.eq(n.doc),i=e.some(u=>u.getMeta("preventAutolink"));if(!s||i)return;const{tr:a}=n,o=oke(r.doc,[...e]);if(pke(o).forEach(({newRange:u})=>{const d=EIt(n.doc,u,p=>p.isTextblock);let h,f;if(d.length>1)h=d[0],f=n.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(d.length){const p=n.doc.textBetween(u.from,u.to," "," ");if(!rDt.test(p))return;h=d[0],f=n.doc.textBetween(h.pos,u.to,void 0," ")}if(h&&f){const p=f.split(tDt).filter(Boolean);if(p.length<=0)return!1;const m=p[p.length-1],g=h.pos+f.lastIndexOf(m);if(!m)return!1;const x=oq(m).map(y=>y.toObject(t.defaultProtocol));if(!sDt(x))return!1;x.filter(y=>y.isLink).map(y=>({...y,from:g+y.start+1,to:g+y.end+1})).filter(y=>n.schema.marks.code?!n.doc.rangeHasMark(y.from,y.to,n.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{q7(y.from,y.to,n.doc).some(v=>v.mark.type===t.type)||a.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!a.steps.length)return a}})}function aDt(t){return new fn({key:new ys("handleClickLink"),props:{handleClick:(e,r,n)=>{var s,i;if(n.button!==0||!e.editable)return!1;let a=null;if(n.target instanceof HTMLAnchorElement)a=n.target;else{const c=n.target;if(!c)return!1;const u=t.editor.view.dom;a=c.closest("a"),a&&!u.contains(a)&&(a=null)}if(!a)return!1;let o=!1;if(t.enableClickSelection&&(o=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const c=fke(e.state,t.type.name),u=(s=a.href)!=null?s:c.href,d=(i=a.target)!=null?i:c.target;u&&(window.open(u,d),o=!0)}return o}}})}function oDt(t){return new fn({key:new ys("handlePasteLink"),props:{handlePaste:(e,r,n)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:a}=i,{empty:o}=a;if(o)return!1;let c="";n.content.forEach(d=>{c+=d.textContent});const u=pNe(c,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===c);return!c||!u||s!==void 0&&!s(u.value)?!1:t.editor.commands.setMark(t.type,{href:u.href})}}})}function Pm(t,e){const r=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(n=>{const s=typeof n=="string"?n:n.scheme;s&&r.push(s)}),!t||t.replace(nDt,"").match(new RegExp(`^(?:(?:${r.map(n=>n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var mNe=Ox.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"){Bie(t);return}Bie(t.scheme,t.optionalSlashes)})},onDestroy(){ZMt()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Pm(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),r=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||r&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:r=>!!Pm(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Pm(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Ps(this.options.HTMLAttributes,t),0]:["a",Ps(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 r,n,s,i;const a=(n=(r=t.attrs)==null?void 0:r.href)!=null?n:"",o=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",c=e.renderChildren(t);return o?`[${c}](${a} "${o}")`:`[${c}](${a})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!Pm(n,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:r}=t||{};return r&&!this.options.isAllowedUri(r,{defaultValidate:n=>!!Pm(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[dx({find:t=>{const e=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,s=pNe(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:a=>!!Pm(a,r),protocols:r,defaultProtocol:n}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:r}=this.options;return this.options.autolink&&t.push(iDt({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:s=>!!Pm(s,e),protocols:e,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),t.push(aDt({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(oDt({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),lDt=mNe,cDt=Object.defineProperty,uDt=(t,e)=>{for(var r in e)cDt(t,r,{get:e[r],enumerable:!0})},dDt="listItem",zie="textStyle",Uie=/^\s*([-+*])\s$/,gNe=Mo.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",Ps(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,`
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(dDt,this.editor.getAttributes(zie)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ow({find:Uie,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ow({find:Uie,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(zie),editor:this.editor})),[t]}}),hDt=(t,e,r)=>{const{selection:n}=t;if(!n.empty)return null;const{$from:s}=n;if(!s.parent.isTextblock||s.parentOffset!==s.parent.content.size)return null;let i=-1;for(let p=s.depth;p>0;p-=1)if(s.node(p).type.name===e){i=p;break}if(i<0)return null;const a=s.node(i),o=s.index(i);if(o+1>=a.childCount)return null;const c=a.child(o+1);if(!r.includes(c.type.name))return null;const u=t.schema.nodes[e];let d=!1;if(c.forEach(p=>{p.type===u&&p.childCount>1&&(d=!0)}),!d)return null;const h=t.doc.resolve(s.after()).nodeAfter;if(!h||!r.includes(h.type.name))return null;const f=[];return h.forEach(p=>{f.push(p)}),f.length===0?null:{listItemDepth:i,nestedList:h,nestedListPos:s.after(),insertPos:s.after(i),items:f}},fDt=(t,e,r,n)=>{const s=hDt(t,r,n);if(!s)return!1;const{selection:i}=t,{nestedList:a,nestedListPos:o,insertPos:c,items:u}=s,d=t.tr;d.delete(o,o+a.nodeSize);const h=d.mapping.map(c);return d.insert(h,Qe.from(u)),d.setSelection(i.map(d.doc,d.mapping)),e&&e(d),!0},pDt=(t,e,r)=>fDt(t.state,t.view.dispatch,e,r),yNe=(t,e)=>Pn.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const r=()=>pDt(this.editor,t,e);return{Delete:r,"Mod-Delete":r}}}),xNe=[[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"]],BC="abcdefghijklmnopqrstuvwxyz",mDt="[a-zA-Z]{1,2}",cq=String.raw`\d+|[ivxlcdmIVXLCDM]+|${mDt}`;function jD(t){let e=t,r="";for(const[n,s]of xNe)for(;e>=n;)r+=s,e-=n;return r}function uq(t){return jD(t).toUpperCase()}function vNe(t){const e=t.toLowerCase();let r=0,n=0;for(;r<e.length;){let s=!1;for(const[i,a]of xNe)if(e.startsWith(a,r)){n+=i,r+=a.length,s=!0;break}if(!s)return 0}return n}function gDt(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=vNe(t);return e<=0?!1:(t===t.toLowerCase()?jD(e):uq(e))===t}function yDt(t){const e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){const r=e.charCodeAt(0)-97,n=e.charCodeAt(1)-97;return(r+1)*26+n+1}return 0}function pI(t){if(t<=26)return BC[t-1];const e=Math.floor((t-1)/26)-1,r=(t-1)%26;return e<0?BC[r]:BC[e]+BC[r]}function kD(t){if(!(!t||/^\d+$/.test(t))){if(gDt(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 dq(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=kD(t);if(e==="i"||e==="I")return vNe(t);if(e==="a"||e==="A"){const n=yDt(t);return n>0?n:1}const r=parseInt(t,10);return Number.isNaN(r)?1:r}function xDt(t,e){if(t==="numeric")return String(e);switch(t){case"a":return pI(e);case"A":return pI(e).toUpperCase();case"i":return jD(e);case"I":return uq(e);default:return String(e)}}function vDt(t){var e;if(t.length===0)return!1;const r=(e=kD(t[0]))!=null?e:"numeric",n=dq(t[0]);if(n<1)return!1;for(let s=0;s<t.length;s++){const i=xDt(r,n+s);if(t[s]!==i)return!1}return!0}function bDt(t){return{type:kD(t),start:dq(t)}}function wDt(t){const{type:e,start:r}=bDt(t),n={};return e&&(n.type=e),r!==1&&(n.start=r),n}function SDt(t,e,r=". "){const n=e+1;if(!t||t==="1")return`${n}${r}`;switch(t){case"a":return`${pI(n)}${r}`;case"A":return`${pI(n).toUpperCase()}${r}`;case"i":return`${jD(n)}${r}`;case"I":return`${uq(n)}${r}`;default:return`${n}${r}`}}function _Dt(t){var e,r;const n=(e=t.tokens)==null?void 0:e[0];return!!(t.text&&((r=t.tokens)==null?void 0:r.length)===1&&(n==null?void 0:n.type)==="list"&&n.ordered&&n.raw===t.text)}function jDt(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var bNe=Mo.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ps(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var r;if(t.type!=="list_item")return[];const n=(r=e.parseBlockChildren)!=null?r:e.parseChildren;let s=[];if(t.tokens&&t.tokens.length>0){if(_Dt(t))return{type:"listItem",content:[{type:"paragraph",content:jDt(t.text||"",e)}]};if(t.tokens.some(a=>a.type==="paragraph"))s=n(t.tokens);else{const a=t.tokens[0];if(a&&a.type==="text"&&a.tokens&&a.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(a.tokens)}],t.tokens.length>1){const c=t.tokens.slice(1),u=n(c);s.push(...u)}}else s=n(t.tokens)}}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(t,e,r)=>Y7(t,e,n=>{var s,i,a,o;if(n.parentType==="bulletList")return"- ";if(n.parentType==="orderedList"){const c=((i=(s=n.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1,u=(o=(a=n.meta)==null?void 0:a.parentAttrs)==null?void 0:o.type,d=c-1+(n.index||0);return SDt(u,d,". ")}return"- "},r),addExtensions(){return[yNe(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)}}}),kDt={};uDt(kDt,{findListItemPos:()=>ND,getNextListDepth:()=>hq,handleBackspace:()=>kU,handleDelete:()=>NU,hasListBefore:()=>wNe,hasListItemAfter:()=>NDt,hasListItemBefore:()=>EDt,listItemHasSubList:()=>ADt,nextListIsDeeper:()=>SNe,nextListIsHigher:()=>_Ne});var ND=(t,e)=>{const{$from:r}=e.selection,n=ms(t,e.schema);let s=null,i=r.depth,a=r.pos,o=null;for(;i>0&&o===null;)s=r.node(i),s.type===n?o=i:(i-=1,a-=1);return o===null?null:{$pos:e.doc.resolve(a),depth:o}},hq=(t,e)=>{const r=ND(t,e);if(!r)return!1;const[,n]=FIt(e,t,r.$pos.pos+4);return n},wNe=(t,e,r)=>{const{$anchor:n}=t.selection,s=Math.max(0,n.pos-2),i=t.doc.resolve(s).node();return!(!i||!r.includes(i.type.name))},kU=(t,e,r)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Yp(t.state,e)&&wNe(t.state,e,r)){const{$anchor:n}=t.state.selection,s=t.state.doc.resolve(n.before()-1),i=[];s.node().descendants((c,u)=>{c.type.name===e&&i.push({node:c,pos:u})});const a=i.at(-1);if(!a)return!1;const o=t.state.doc.resolve(s.start()+a.pos+1);return t.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}return!Yp(t.state,e)||!UIt(t.state)?!1:t.chain().liftListItem(e).run()},SNe=(t,e)=>{const r=hq(t,e),n=ND(t,e);return!n||!r?!1:r>n.depth},_Ne=(t,e)=>{const r=hq(t,e),n=ND(t,e);return!n||!r?!1:r<n.depth},NU=(t,e)=>{if(!Yp(t.state,e)||!zIt(t.state,e))return!1;const{selection:r}=t.state,{$from:n,$to:s}=r;return!r.empty&&n.sameParent(s)?!1:SNe(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():_Ne(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},NDt=(t,e)=>{var r;const{$anchor:n}=e.selection,s=e.doc.resolve(n.pos-n.parentOffset-2);return!(s.index()===s.parent.childCount-1||((r=s.nodeAfter)==null?void 0:r.type.name)!==t)},EDt=(t,e)=>{var r;const{$anchor:n}=e.selection,s=e.doc.resolve(n.pos-2);return!(s.index()===0||((r=s.nodeBefore)==null?void 0:r.type.name)!==t)},ADt=(t,e,r)=>{if(!r)return!1;const n=ms(t,e.schema);let s=!1;return r.descendants(i=>{i.type===n&&(s=!0)}),s},jNe=Pn.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:r})=>{t.state.schema.nodes[r]!==void 0&&NU(t,r)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:r})=>{t.state.schema.nodes[r]!==void 0&&NU(t,r)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:r,wrapperNames:n})=>{t.state.schema.nodes[r]!==void 0&&kU(t,r,n)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:r,wrapperNames:n})=>{t.state.schema.nodes[r]!==void 0&&kU(t,r,n)&&(e=!0)}),e}}}}),EU=new RegExp(`^(\\s*)(${cq})([.)])\\s+(.*)$`),CDt=new RegExp(`^(\\s*)(${cq})([.)])\\s+`),TDt=/^\s/;function PDt(t){return EU.test(t.trimStart())}function ODt(t){const e=t.trimStart();return/^[-+*]\s+/.test(e)||PDt(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function IDt(t){const e=[],r=[];let n=!1;return t.forEach(s=>{if(n){r.push(s);return}if(s.trim()===""){n=!0,r.push(s);return}if(e.length>0&&ODt(s)){n=!0,r.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:r}}function RDt(t){const e=[];let r=0,n=0;for(;r<t.length;){const s=t[r],i=s.match(EU);if(!i)break;const[,a,o,c,u]=i,d=a.length,h=parseInt(o,10),f=isNaN(h)?kD(o):void 0,p=isNaN(h)?dq(o):h,m=[u];let g=r+1;const x=[s];let y=!1;for(;g<t.length;){const v=t[g];if(v.match(EU))break;if(v.trim()==="")x.push(v),m.push(""),y=!0,g+=1;else if(v.match(TDt)){const w=v.length-v.trimStart().length,S=d+o.length+1;x.push(v),m.push(v.slice(Math.min(w,S))),g+=1}else{if(y)break;x.push(v),m.push(v),g+=1}}e.push({indent:d,number:p,type:f,content:m.join(`
`).trim(),contentLines:m,raw:x.join(`
`)}),n=g,r=g}return[e,n]}var MDt=new RegExp(`^(${cq})([.)])\\s+(.+)$`);function DDt(t){const e=t.split(`
`).filter(i=>i.trim().length>0);if(e.length===0)return null;const r=[];for(const i of e){const a=i.trim().match(MDt);if(!a)return null;r.push({marker:a[1],content:a[3]})}const n=r.map(i=>i.marker);return vDt(n)?{type:"orderedList",attrs:wDt(r[0].marker),content:r.map(i=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:i.content}]}]}))}:null}function kNe(t,e,r){const n=[];let s=0;for(;s<t.length;){const i=t[s];if(i.indent===e){const{paragraphLines:a,blockLines:o}=IDt(i.contentLines),c=a.join(`
`).trim(),u=[];c&&u.push({type:"paragraph",raw:c,tokens:r.inlineTokens(c)});const d=o.join(`
`).trim();if(d){const p=r.blockTokens(d);u.push(...p)}let h=s+1;const f=[];for(;h<t.length&&t[h].indent>e;)f.push(t[h]),h+=1;if(f.length>0){const p=Math.min(...f.map(g=>g.indent)),m=kNe(f,p,r);u.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:m,raw:f.map(g=>g.raw).join(`
`)})}n.push({type:"list_item",raw:i.raw,tokens:u}),s=h}else s+=1}return n}function LDt(t,e){return t.map(r=>{if(r.type!=="list_item")return e.parseChildren([r])[0];const n=[];return r.tokens&&r.tokens.length>0&&r.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")n.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);n.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&n.push(...i)}}),{type:"listItem",content:n}})}var FDt="listItem",Hie="textStyle",Vie=/^(\d+)\.\s$/;function Wie(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 NNe=Mo.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 r=t.getAttribute("style");if(r){const s=Wie(r);if(s)return s}const n=t.querySelector("li");if(n){const s=n.getAttribute("style");if(s){const i=Wie(s);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,type:r,...n}=t,s=Ps(this.options.HTMLAttributes,n);return e!==1&&(s.start=e),r&&r!=="1"&&(s.type=r),["ol",s,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const r=t.start||1,n=t.typeMarker,s=t.items?LDt(t.items,e):[],i={};return r!==1&&(i.start=r),n&&(i.type=n),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:s}:{type:"orderedList",content:s}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(CDt),r=e==null?void 0:e.index;return r!==void 0?r:-1},tokenize:(t,e,r)=>{var n,s;const i=t.split(`
`),[a,o]=RDt(i);if(a.length===0)return;const c=kNe(a,0,r);if(c.length===0)return;const u=((n=a[0])==null?void 0:n.number)||1,d=(s=a[0])==null?void 0:s.type;return{type:"list",ordered:!0,start:u,typeMarker:d,items:c,raw:i.slice(0,o).join(`
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(FDt,this.editor.getAttributes(Hie)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new fn({props:{handlePaste:(t,e)=>{var r,n;const s=(r=e.clipboardData)==null?void 0:r.getData("text/html");if(s!=null&&s.trim())return!1;const i=(n=e.clipboardData)==null?void 0:n.getData("text/plain");if(!i)return!1;const a=DDt(i);if(!a)return!1;try{const o=t.state.schema.nodeFromJSON(a),c=t.state.tr.replaceSelectionWith(o);return t.dispatch(c),!0}catch{return!1}}}})]},addInputRules(){const t=(r,n)=>(!n.attrs.type||n.attrs.type==="1")&&n.childCount+n.attrs.start===+r[1];let e=Ow({find:Vie,type:this.type,getAttributes:r=>({start:+r[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Ow({find:Vie,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:r=>({start:+r[1],...this.editor.getAttributes(Hie)}),joinPredicate:t,editor:this.editor})),[e]}}),$Dt=/^\s*(\[([( |x])?\])\s$/,BDt=Mo.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",Ps(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 r=[];if(t.tokens&&t.tokens.length>0?r.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?r.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):r.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const n=e.parseChildren(t.nestedTokens);r.push(...n)}return e.createNode("taskItem",{checked:t.checked||!1},r)},renderMarkdown:(t,e)=>{var r;const s=`- [${(r=t.attrs)!=null&&r.checked?"x":" "}] `;return Y7(t,e,s)},addExtensions(){return this.options.nested?[yNe(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:r,editor:n})=>{const s=document.createElement("li"),i=document.createElement("label"),a=document.createElement("span"),o=document.createElement("input"),c=document.createElement("div"),u=h=>{var f,p;o.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,h,o.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};u(t),i.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",h=>h.preventDefault()),o.addEventListener("change",h=>{if(!n.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:f}=h.target;n.isEditable&&typeof r=="function"&&n.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const m=r();if(typeof m!="number")return!1;const g=p.doc.nodeAt(m);return p.setNodeMarkup(m,void 0,{...g==null?void 0:g.attrs,checked:f}),!0}).run(),!n.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,f])=>{s.setAttribute(h,f)}),s.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,i.append(o,a),s.append(i,c),Object.entries(e).forEach(([h,f])=>{s.setAttribute(h,f)});let d=new Set(Object.keys(e));return{dom:s,contentDOM:c,update:h=>{if(h.type!==this.type)return!1;s.dataset.checked=h.attrs.checked,o.checked=h.attrs.checked,u(h);const f=n.extensionManager.attributes,p=dk(h,f),m=new Set(Object.keys(p)),g=this.options.HTMLAttributes;return d.forEach(x=>{m.has(x)||(x in g?s.setAttribute(x,g[x]):s.removeAttribute(x))}),Object.entries(p).forEach(([x,y])=>{y==null?x in g?s.setAttribute(x,g[x]):s.removeAttribute(x):s.setAttribute(x,y)}),d=m,!0}}}},addInputRules(){return[Ow({find:$Dt,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),zDt=Mo.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",Ps(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,`
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const r=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return r!==void 0?r:-1},tokenize(t,e,r){const n=i=>{const a=hU(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,c)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:r.inlineTokens(o.mainContent),nestedTokens:c}),customNestedParser:n},r);return a?[{type:"taskList",raw:a.raw,items:a.items}]:r.blockTokens(i)},s=hU(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,a)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:r.inlineTokens(i.mainContent),nestedTokens:a}),customNestedParser:n},r);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()}}});Pn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(gNe.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(bNe.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(jNe.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(NNe.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(BDt.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(zDt.configure(this.options.taskList)),t}});var zC=" ",pF=" ",UDt=Mo.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Ps(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const r=t.tokens||[];if(r.length===1&&r[0].type==="image")return e.parseChildren([r[0]]);const n=e.parseInline(r);return r.length===1&&r[0].type==="text"&&(r[0].raw===zC||r[0].text===zC||r[0].raw===pF||r[0].text===pF)&&n.length===1&&n[0].type==="text"&&(n[0].text===zC||n[0].text===pF)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,n)},renderMarkdown:(t,e,r)=>{var n,s;if(!t)return"";const i=Array.isArray(t.content)?t.content:[];if(i.length===0){const a=Array.isArray((n=r==null?void 0:r.previousNode)==null?void 0:n.content)?r.previousNode.content:[];return((s=r==null?void 0:r.previousNode)==null?void 0:s.type)==="paragraph"&&a.length===0?zC:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),HDt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,VDt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,WDt=Ox.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",Ps(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[Pw({find:HDt,type:this.type})]},addPasteRules(){return[dx({find:VDt,type:this.type})]}}),qDt=Mo.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),ENe=Ox.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",Ps(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,r){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:r.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()}}}),GDt=ENe;function KDt(t={}){return new fn({view(e){return new YDt(e,t)}})}class YDt{constructor(e,r){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=r.width)!==null&&n!==void 0?n:1,this.color=r.color===!1?void 0:r.color||"black",this.class=r.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=a=>{this[s](a)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:r})=>this.editorView.dom.removeEventListener(e,r))}update(e,r){this.cursorPos!=null&&r.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),r=!e.parent.inlineContent,n,s=this.editorView.dom,i=s.getBoundingClientRect(),a=i.width/s.offsetWidth,o=i.height/s.offsetHeight;if(r){let h=e.nodeBefore,f=e.nodeAfter;if(h||f){let p=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(p){let m=p.getBoundingClientRect(),g=h?m.bottom:m.top;h&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*o;n={left:m.left,right:m.right,top:g-x,bottom:g+x}}}}if(!n){let h=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*a;n={left:h.left-f,right:h.left+f,top:h.top,bottom:h.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.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",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let h=c.getBoundingClientRect(),f=h.width/c.offsetWidth,p=h.height/c.offsetHeight;u=h.left-c.scrollLeft*f,d=h.top-c.scrollTop*p}this.element.style.left=(n.left-u)/a+"px",this.element.style.top=(n.top-d)/o+"px",this.element.style.width=(n.right-n.left)/a+"px",this.element.style.height=(n.bottom-n.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),s=n&&n.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,r,e):s;if(r&&!i){let a=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=J_e(this.editorView.state.doc,a,this.editorView.dragging.slice);o!=null&&(a=o)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class zn extends qt{constructor(e){super(e,e)}map(e,r){let n=e.resolve(r.map(this.head));return zn.valid(n)?new zn(n):qt.near(n)}content(){return vt.empty}eq(e){return e instanceof zn&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,r){if(typeof r.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new zn(e.resolve(r.pos))}getBookmark(){return new fq(this.anchor)}static valid(e){let r=e.parent;if(r.inlineContent||!XDt(e)||!JDt(e))return!1;let n=r.type.spec.allowGapCursor;if(n!=null)return n;let s=r.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,r,n=!1){e:for(;;){if(!n&&zn.valid(e))return e;let s=e.pos,i=null;for(let a=e.depth;;a--){let o=e.node(a);if(r>0?e.indexAfter(a)<o.childCount:e.index(a)>0){i=o.child(r>0?e.indexAfter(a):e.index(a)-1);break}else if(a==0)return null;s+=r;let c=e.doc.resolve(s);if(zn.valid(c))return c}for(;;){let a=r>0?i.firstChild:i.lastChild;if(!a){if(i.isAtom&&!i.isText&&!Ot.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*r),n=!1;continue e}break}i=a,s+=r;let o=e.doc.resolve(s);if(zn.valid(o))return o}return null}}}zn.prototype.visible=!1;zn.findFrom=zn.findGapCursorFrom;qt.jsonID("gapcursor",zn);class fq{constructor(e){this.pos=e}map(e){return new fq(e.map(this.pos))}resolve(e){let r=e.resolve(this.pos);return zn.valid(r)?new zn(r):qt.near(r)}}function ANe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function XDt(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),n=t.node(e);if(r==0){if(n.type.spec.isolating)return!0;continue}for(let s=n.child(r-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||ANe(s.type))return!0;if(s.inlineContent)return!1}}return!0}function JDt(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),n=t.node(e);if(r==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let s=n.child(r);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||ANe(s.type))return!0;if(s.inlineContent)return!1}}return!0}function QDt(){return new fn({props:{decorations:rLt,createSelectionBetween(t,e,r){return e.pos==r.pos&&zn.valid(r)?new zn(r):null},handleClick:eLt,handleKeyDown:ZDt,handleDOMEvents:{beforeinput:tLt}}})}const ZDt=Zje({ArrowLeft:UC("horiz",-1),ArrowRight:UC("horiz",1),ArrowUp:UC("vert",-1),ArrowDown:UC("vert",1)});function UC(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,s,i){let a=n.selection,o=e>0?a.$to:a.$from,c=a.empty;if(a instanceof Bt){if(!i.endOfTextblock(r)||o.depth==0)return!1;c=!1,o=n.doc.resolve(e>0?o.after():o.before())}let u=zn.findGapCursorFrom(o,e,c);return u?(s&&s(n.tr.setSelection(new zn(u))),!0):!1}}function eLt(t,e,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(e);if(!zn.valid(n))return!1;let s=t.posAtCoords({left:r.clientX,top:r.clientY});return s&&s.inside>-1&&Ot.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new zn(n))),!0)}function tLt(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof zn))return!1;let{$from:r}=t.state.selection,n=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!n)return!1;let s=Qe.empty;for(let a=n.length-1;a>=0;a--)s=Qe.from(n[a].createAndFill(null,s));let i=t.state.tr.replace(r.pos,r.pos,new vt(s,0,0));return i.setSelection(Bt.near(i.doc.resolve(r.pos+1))),t.dispatch(i),!1}function rLt(t){if(!(t.selection instanceof zn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",bn.create(t.doc,[$i.widget(t.selection.head,e,{key:"gapcursor"})])}var mI=200,Js=function(){};Js.prototype.append=function(e){return e.length?(e=Js.from(e),!this.length&&e||e.length<mI&&this.leafAppend(e)||this.length<mI&&e.leafPrepend(this)||this.appendInner(e)):this};Js.prototype.prepend=function(e){return e.length?Js.from(e).append(this):this};Js.prototype.appendInner=function(e){return new nLt(this,e)};Js.prototype.slice=function(e,r){return e===void 0&&(e=0),r===void 0&&(r=this.length),e>=r?Js.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,r))};Js.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Js.prototype.forEach=function(e,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length),r<=n?this.forEachInner(e,r,n,0):this.forEachInvertedInner(e,r,n,0)};Js.prototype.map=function(e,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length);var s=[];return this.forEach(function(i,a){return s.push(e(i,a))},r,n),s};Js.from=function(e){return e instanceof Js?e:e&&e.length?new CNe(e):Js.empty};var CNe=function(t){function e(n){t.call(this),this.values=n}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={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,a,o){for(var c=i;c<a;c++)if(s(this.values[c],o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,a,o){for(var c=i-1;c>=a;c--)if(s(this.values[c],o+c)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=mI)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=mI)return new e(s.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(e.prototype,r),e}(Js);Js.empty=new CNe([]);var nLt=function(t){function e(r,n){t.call(this),this.left=r,this.right=n,this.length=r.length+n.length,this.depth=Math.max(r.depth,n.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(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,s,i,a){var o=this.left.length;if(s<o&&this.left.forEachInner(n,s,Math.min(i,o),a)===!1||i>o&&this.right.forEachInner(n,Math.max(s-o,0),Math.min(this.length,i)-o,a+o)===!1)return!1},e.prototype.forEachInvertedInner=function(n,s,i,a){var o=this.left.length;if(s>o&&this.right.forEachInvertedInner(n,s-o,Math.max(i,o)-o,a+o)===!1||i<o&&this.left.forEachInvertedInner(n,Math.min(s,o),i,a)===!1)return!1},e.prototype.sliceInner=function(n,s){if(n==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(n,s):n>=i?this.right.slice(n-i,s-i):this.left.slice(n,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(n){var s=this.right.leafAppend(n);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(n){var s=this.left.leafPrepend(n);if(s)return new e(s,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(Js);const sLt=500;class lc{constructor(e,r){this.items=e,this.eventCount=r}popEvent(e,r){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let s,i;r&&(s=this.remapping(n,this.items.length),i=s.maps.length);let a=e.tr,o,c,u=[],d=[];return this.items.forEach((h,f)=>{if(!h.step){s||(s=this.remapping(n,f+1),i=s.maps.length),i--,d.push(h);return}if(s){d.push(new Bc(h.map));let p=h.step.map(s.slice(i)),m;p&&a.maybeStep(p).doc&&(m=a.mapping.maps[a.mapping.maps.length-1],u.push(new Bc(m,void 0,void 0,u.length+d.length))),i--,m&&s.appendMap(m,i)}else a.maybeStep(h.step);if(h.selection)return o=s?h.selection.map(s.slice(i)):h.selection,c=new lc(this.items.slice(0,n).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:a,selection:o}}addTransform(e,r,n,s){let i=[],a=this.eventCount,o=this.items,c=!s&&o.length?o.get(o.length-1):null;for(let d=0;d<e.steps.length;d++){let h=e.steps[d].invert(e.docs[d]),f=new Bc(e.mapping.maps[d],h,r),p;(p=c&&c.merge(f))&&(f=p,d?i.pop():o=o.slice(0,o.length-1)),i.push(f),r&&(a++,r=void 0),s||(c=f)}let u=a-n.depth;return u>aLt&&(o=iLt(o,u),a-=u),new lc(o.append(i),a)}remapping(e,r){let n=new ak;return this.items.forEach((s,i)=>{let a=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?n.maps.length-s.mirrorOffset:void 0;n.appendMap(s.map,a)},e,r),n}addMaps(e){return this.eventCount==0?this:new lc(this.items.append(e.map(r=>new Bc(r))),this.eventCount)}rebased(e,r){if(!this.eventCount)return this;let n=[],s=Math.max(0,this.items.length-r),i=e.mapping,a=e.steps.length,o=this.eventCount;this.items.forEach(f=>{f.selection&&o--},s);let c=r;this.items.forEach(f=>{let p=i.getMirror(--c);if(p==null)return;a=Math.min(a,p);let m=i.maps[p];if(f.step){let g=e.steps[p].invert(e.docs[p]),x=f.selection&&f.selection.map(i.slice(c+1,p));x&&o++,n.push(new Bc(m,g,x))}else n.push(new Bc(m))},s);let u=[];for(let f=r;f<a;f++)u.push(new Bc(i.maps[f]));let d=this.items.slice(0,s).append(u).append(n),h=new lc(d,o);return h.emptyItemCount()>sLt&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach(r=>{r.step||e++}),e}compress(e=this.items.length){let r=this.remapping(0,e),n=r.maps.length,s=[],i=0;return this.items.forEach((a,o)=>{if(o>=e)s.push(a),a.selection&&i++;else if(a.step){let c=a.step.map(r.slice(n)),u=c&&c.getMap();if(n--,u&&r.appendMap(u,n),c){let d=a.selection&&a.selection.map(r.slice(n));d&&i++;let h=new Bc(u.invert(),c,d),f,p=s.length-1;(f=s.length&&s[p].merge(h))?s[p]=f:s.push(h)}}else a.map&&n--},this.items.length,0),new lc(Js.from(s.reverse()),i)}}lc.empty=new lc(Js.empty,0);function iLt(t,e){let r;return t.forEach((n,s)=>{if(n.selection&&e--==0)return r=s,!1}),t.slice(r)}class Bc{constructor(e,r,n,s){this.map=e,this.step=r,this.selection=n,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let r=e.step.merge(this.step);if(r)return new Bc(r.getMap().invert(),r,this.selection)}}}class lf{constructor(e,r,n,s,i){this.done=e,this.undone=r,this.prevRanges=n,this.prevTime=s,this.prevComposition=i}}const aLt=20;function oLt(t,e,r,n){let s=r.getMeta(By),i;if(s)return s.historyState;r.getMeta(uLt)&&(t=new lf(t.done,t.undone,null,0,-1));let a=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(a&&a.getMeta(By))return a.getMeta(By).redo?new lf(t.done.addTransform(r,void 0,n,h2(e)),t.undone,qie(r.mapping.maps),t.prevTime,t.prevComposition):new lf(t.done,t.undone.addTransform(r,void 0,n,h2(e)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let o=r.getMeta("composition"),c=t.prevTime==0||!a&&t.prevComposition!=o&&(t.prevTime<(r.time||0)-n.newGroupDelay||!lLt(r,t.prevRanges)),u=a?mF(t.prevRanges,r.mapping):qie(r.mapping.maps);return new lf(t.done.addTransform(r,c?e.selection.getBookmark():void 0,n,h2(e)),lc.empty,u,r.time,o??t.prevComposition)}else return(i=r.getMeta("rebased"))?new lf(t.done.rebased(r,i),t.undone.rebased(r,i),mF(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new lf(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),mF(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function lLt(t,e){if(!e)return!1;if(!t.docChanged)return!0;let r=!1;return t.mapping.maps[0].forEach((n,s)=>{for(let i=0;i<e.length;i+=2)n<=e[i+1]&&s>=e[i]&&(r=!0)}),r}function qie(t){let e=[];for(let r=t.length-1;r>=0&&e.length==0;r--)t[r].forEach((n,s,i,a)=>e.push(i,a));return e}function mF(t,e){if(!t)return null;let r=[];for(let n=0;n<t.length;n+=2){let s=e.map(t[n],1),i=e.map(t[n+1],-1);s<=i&&r.push(s,i)}return r}function cLt(t,e,r){let n=h2(e),s=By.get(e).spec.config,i=(r?t.undone:t.done).popEvent(e,n);if(!i)return null;let a=i.selection.resolve(i.transform.doc),o=(r?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,n),c=new lf(r?o:i.remaining,r?i.remaining:o,null,0,-1);return i.transform.setSelection(a).setMeta(By,{redo:r,historyState:c})}let gF=!1,Gie=null;function h2(t){let e=t.plugins;if(Gie!=e){gF=!1,Gie=e;for(let r=0;r<e.length;r++)if(e[r].spec.historyPreserveItems){gF=!0;break}}return gF}const By=new ys("history"),uLt=new ys("closeHistory");function dLt(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new fn({key:By,state:{init(){return new lf(lc.empty,lc.empty,null,0,-1)},apply(e,r,n){return oLt(r,n,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,r){let n=r.inputType,s=n=="historyUndo"?PNe:n=="historyRedo"?ONe:null;return!s||!e.editable?!1:(r.preventDefault(),s(e.state,e.dispatch))}}}})}function TNe(t,e){return(r,n)=>{let s=By.getState(r);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(n){let i=cLt(s,r,t);i&&n(e?i.scrollIntoView():i)}return!0}}const PNe=TNe(!1,!0),ONe=TNe(!0,!0);Pn.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==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,r=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(r)}},addProseMirrorPlugins(){let t=!1;return[new fn({key:new ys("characterCount"),appendTransaction:(e,r,n)=>{if(t)return;const s=this.options.limit,i=this.options.autoTrim;if(s==null||s===0||i===!1){t=!0;return}const a=this.storage.characters({node:n.doc});if(a>s){const o=a-s,c=0,u=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const d=n.tr.deleteRange(c,u);return t=!0,d}t=!0},filterTransaction:(e,r)=>{const n=this.options.limit;if(!e.docChanged||n===0||n===null||n===void 0)return!0;const s=this.storage.characters({node:r.doc}),i=this.storage.characters({node:e.doc});if(i<=n||s>n&&i>n&&i<=s)return!0;if(s>n&&i>n&&i>s||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,c=i-n,u=o-c,d=o;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>n)}})]}});var hLt=Pn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[KDt(this.options)]}});Pn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new fn({key:new ys("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:r,isFocused:n}=this.editor,{anchor:s}=e,i=[];if(!r||!n)return bn.create(t,[]);let a=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(c.isText)return;if(!(s>=u&&s<=u+c.nodeSize-1))return!1;a+=1});let o=0;return t.descendants((c,u)=>{if(c.isText||!(s>=u&&s<=u+c.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&a-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";i.push($i.node(u,u+c.nodeSize,{class:this.options.className}))}),bn.create(t,i)}}})]}});var fLt=Pn.create({name:"gapCursor",addProseMirrorPlugins(){return[QDt()]},extendNodeSchema(t){var e;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=kr(_t(t,"allowGapCursor",r)))!=null?e:null}}}),INe="placeholder",gk=new ys("tiptap__placeholder"),Kie=200;function Yie(t){const{editor:e,placeholder:r,dataAttribute:n,pos:s,node:i,isEmptyDoc:a,hasAnchor:o,classes:{emptyNode:c,emptyEditor:u}}=t,d=[c];return a&&d.push(u),$i.node(s,s+i.nodeSize,{class:d.join(" "),[n]:typeof r=="function"?r({editor:e,node:i,pos:s,hasAnchor:o}):r})}function Xie(t,e){return typeof t=="function"?t(e):t}function pLt({editor:t,options:e,dataAttribute:r,doc:n,selection:s}){var i,a;if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:c}=s,u=[],d=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const f=n.resolve(c),p=f.depth>0?f.node(1):f.nodeAfter,m=f.depth>0?f.before(1):c;if(p&&p.type.isTextblock&&hk(p)){const g=c>=m&&c<=m+p.nodeSize;u.push(Yie({editor:t,isEmptyDoc:d,dataAttribute:r,hasAnchor:g,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Xie(e.emptyNodeClass,{editor:t,node:p,pos:m,hasAnchor:g})},node:p,pos:m}))}}else{const f=gk.getState(t.state),p=(i=f==null?void 0:f.topPos)!=null?i:0,m=(a=f==null?void 0:f.bottomPos)!=null?a:n.content.size;n.nodesBetween(p,m,(g,x)=>{const y=c>=x&&c<=x+g.nodeSize,v=!g.isLeaf&&hk(g);return g.type.isTextblock&&(y||!e.showOnlyCurrent)&&v&&u.push(Yie({editor:t,isEmptyDoc:d,dataAttribute:r,hasAnchor:y,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Xie(e.emptyNodeClass,{editor:t,node:g,pos:x,hasAnchor:y})},node:g,pos:x})),e.includeChildren})}return bn.create(n,u)}function mLt(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function gLt(t){const e=getComputedStyle(t),r=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(r)}function yLt(t){let e=t;for(;e;){if(gLt(e))return e;const r=e.parentElement;if(!r){const n=e.getRootNode();if(n instanceof ShadowRoot){e=n.host;continue}return window}e=r}return window}function xLt(t){return t===window?{top:0,bottom:window.innerHeight}:t.getBoundingClientRect()}function vLt({view:t,scrollContainer:e}){const r=t.dom.getBoundingClientRect();if(r.width<=0||r.height<=0)return null;const n=e?xLt(e):{top:0,bottom:window.innerHeight},s=Math.max(r.top,n.top)-Kie,i=Math.min(r.bottom,n.bottom)+Kie;if(s>=i)return null;const a=r.left+1,o=r.right-1;if(a>o)return null;const u=getComputedStyle(t.dom).direction==="rtl"?r.right-2:r.left+2,d=Math.min(Math.max(u,a),o),h=Math.max(s+2,r.top+1),f=Math.min(i-2,r.bottom-1);if(h>f)return null;const p=t.posAtCoords({left:d,top:h}),m=t.posAtCoords({left:d,top:f});return!p||!m?null:{top:p.pos,bottom:m.pos}}var bLt={init(){return{topPos:null,bottomPos:null}},apply(t,e){const r=t.getMeta(gk);return r!=null&&r.positions?{topPos:r.positions.top,bottomPos:r.positions.bottom}:t.docChanged?{topPos:e.topPos!==null?t.mapping.map(e.topPos):null,bottomPos:e.bottomPos!==null?t.mapping.map(e.bottomPos):null}:e}};function wLt(t){const e=yLt(t.dom),r=()=>{const u=vLt({view:t,scrollContainer:e});if(u===null)return;const d=gk.getState(t.state);if((d==null?void 0:d.topPos)===u.top&&(d==null?void 0:d.bottomPos)===u.bottom)return;const h=t.state.tr.setMeta(gk,{positions:u});t.dispatch(h)};let n=null,s=0;const i=150,a=()=>{n===null&&(n=requestAnimationFrame(()=>{n=null;const u=performance.now();u-s>=i?(s=u,r()):a()}))};e.addEventListener("scroll",a,{passive:!0});const o=typeof ResizeObserver<"u"?new ResizeObserver(a):null;o==null||o.observe(t.dom);const c=typeof IntersectionObserver<"u"?new IntersectionObserver(a):null;return c==null||c.observe(t.dom),t.dom.addEventListener("focus",a),r(),{update(u,d){t.state.doc.content.size!==d.doc.content.size&&a()},destroy:()=>{n!==null&&cancelAnimationFrame(n),e.removeEventListener("scroll",a),o==null||o.disconnect(),c==null||c.disconnect(),t.dom.removeEventListener("focus",a)}}}function SLt({editor:t,options:e}){const r=e.dataAttribute?`data-${mLt(e.dataAttribute)}`:`data-${INe}`;return new fn({key:gk,state:bLt,view:wLt,props:{decorations:({doc:n,selection:s})=>pLt({editor:t,options:e,dataAttribute:r,doc:n,selection:s})}})}Pn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:INe,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[SLt({editor:this.editor,options:this.options})]}});var _Lt=`.ProseMirror:not(.ProseMirror-focused) *::selection {
background: transparent;
}
.ProseMirror:not(.ProseMirror-focused) *::-moz-selection {
background: transparent;
}`;Pn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return t.options.injectCSS&&typeof document<"u"&&vke(_Lt,t.options.injectNonce,"selection"),[new fn({key:new ys("selection"),props:{decorations(r){return r.selection.empty||t.isFocused||!t.isEditable||mke(r.selection)||t.view.dragging?null:bn.create(r.doc,[$i.inline(r.selection.from,r.selection.to,{class:e.className})])}}})]}});var jLt="skipTrailingNode";function Jie({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var kLt=Pn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ys(this.name),r=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",n=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(r).includes(s.name));return[new fn({key:e,appendTransaction:(s,i,a)=>{const{doc:o,tr:c,schema:u}=a,d=e.getState(a),h=o.content.size,f=u.nodes[r];if(!s.some(p=>p.getMeta(jLt))&&d)return c.insert(h,f.create())},state:{init:(s,i)=>{const a=i.tr.doc.lastChild;return!Jie({node:a,types:n})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const a=s.doc.lastChild;return!Jie({node:a,types:n})}}})]}}),NLt=Pn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>PNe(t,e),redo:()=>({state:t,dispatch:e})=>ONe(t,e)}},addProseMirrorPlugins(){return[dLt(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()}}}),ELt=Pn.create({name:"starterKit",addExtensions(){var t,e,r,n;const s=[];return this.options.bold!==!1&&s.push(wMt.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(gMt.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(gNe.configure(this.options.bulletList)),this.options.code!==!1&&s.push(jMt.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(EMt.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(AMt.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(hLt.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(fLt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(CMt.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(TMt.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(NLt.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(PMt.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(DMt.configure(this.options.italic)),this.options.listItem!==!1&&s.push(bNe.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(jNe.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(mNe.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(NNe.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(UDt.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(WDt.configure(this.options.strike)),this.options.text!==!1&&s.push(qDt.configure(this.options.text)),this.options.underline!==!1&&s.push(ENe.configure((r=this.options)==null?void 0:r.underline)),this.options.trailingNode!==!1&&s.push(kLt.configure((n=this.options)==null?void 0:n.trailingNode)),s}}),ALt=ELt;const RNe=j.createContext(null);function CLt({children:t}){const e=j.useRef(new Map),[r,n]=j.useState(null),[s,i]=j.useState(null),[a,o]=j.useState(0),c=j.useCallback(f=>{i(f?e.current.get(f)??null:null)},[]),u=j.useCallback(f=>{n(f),c(f)},[c]),d=j.useCallback((f,p)=>{e.current.set(f,p),n(m=>(m===f&&i(p),m===null?(i(p),f):m))},[]),h=j.useCallback(f=>{e.current.delete(f),n(p=>p===f?(i(null),null):p)},[]);return j.useEffect(()=>{if(!s)return;const f=()=>o(p=>p+1);return s.on("transaction",f),s.on("selectionUpdate",f),()=>{s.off("transaction",f),s.off("selectionUpdate",f)}},[s]),l.jsx(RNe.Provider,{value:{register:d,unregister:h,setActiveId:u,activeId:r,activeEditor:s,tick:a},children:t})}function MNe(){const t=j.useContext(RNe);if(!t)throw new Error("useEditorRegistry must be used inside EditorRegistryProvider");return t}const DNe=String.raw`[\p{L}][\p{L}'\-\.]*(?:\s+(?:&|und|and)\s+[\p{L}][\p{L}'\-\.]*|\s+et\s+al\.?(?:\s+[\p{L}][\p{L}'\-\.]*)?)*`,Qie=new RegExp(String.raw`\((`+DNe+String.raw`)\s*,\s*(\d{4})(?:[a-z])?(?:\s*,\s*pp?\.?\s*(\d+)(?:[-–]\d+)?)?\)`,"gu"),Zie=new RegExp(String.raw`\b(`+DNe+String.raw`)\s*\((\d{4})(?:[a-z])?\)`,"gu"),eae=/\(([^()]{1,120}?),\s*(\d{4})(?:[a-z])?(?:\s*,\s*pp?\.?\s*(\d+)(?:[-–]\d+)?)?\)/gu,tae=/\(([^()]{1,120}?),\s*pp?\.?\s*(\d+)(?:[-–]\d+)?\)/gu;function TLt(t){return t.split(/\s+(?:&|und|and|et\s+al\.?)\s*/i)[0].split(/\s+/)[0].replace(/[.,]+$/,"").trim().toLowerCase()}function PLt(t){return t.replace(/\s+/g," ").replace(/[.,]+$/,"").trim().toLowerCase()}function OLt(t,e,r){return`${t.toLowerCase()}|${e??""}|${r??""}`}function ILt(t,e,r){return t.some(n=>!(r<=n.start||e>=n.end))}function RLt(t){if(!t)return[];const e=[],r=[],n=new Set,s=(a,o,c,u)=>{if(ILt(r,a.index,a.index+a[0].length))return;const d=TLt(o);if(!d)return;const h=`${a.index}|${a[0]}`;n.has(h)||(n.add(h),r.push({start:a.index,end:a.index+a[0].length}),e.push({raw:a[0],surname:d,authorPhrase:PLt(o),year:c,page:u,key:OLt(d,c,u),start:a.index,end:a.index+a[0].length}))};let i;for(Qie.lastIndex=0;(i=Qie.exec(t))!==null;)s(i,i[1],parseInt(i[2],10),i[3]?parseInt(i[3],10):null);for(Zie.lastIndex=0;(i=Zie.exec(t))!==null;)s(i,i[1],parseInt(i[2],10),null);for(eae.lastIndex=0;(i=eae.exec(t))!==null;)s(i,i[1],parseInt(i[2],10),i[3]?parseInt(i[3],10):null);for(tae.lastIndex=0;(i=tae.exec(t))!==null;)s(i,i[1],null,parseInt(i[2],10));return e.sort((a,o)=>a.start-o.start)}const rae=new ys("citation-decorations");function nae(t){const e=[];return t.descendants((r,n)=>{if(!r.isText||!r.text)return;const s=RLt(r.text);for(const i of s)e.push($i.inline(n+i.start,n+i.end,{class:"cite-link","data-citation-key":i.key,"data-citation-raw":i.raw,"data-citation-surname":i.surname,"data-citation-author-phrase":i.authorPhrase,"data-citation-year":i.year==null?"":String(i.year),"data-citation-page":i.page==null?"":String(i.page),role:"button",tabindex:"0"}))}),bn.create(t,e)}const MLt=Pn.create({name:"citationDecorations",addProseMirrorPlugins(){return[new fn({key:rae,state:{init:(t,{doc:e})=>nae(e),apply(t,e){return t.docChanged?nae(t.doc):e}},props:{decorations(t){return rae.getState(t)}}})]}}),LNe=j.createContext(null);function DLt({children:t}){const[e,r]=j.useState(null),n=j.useCallback(a=>r(a),[]),s=j.useCallback(()=>r(null),[]),i=j.useMemo(()=>({current:e,open:n,close:s}),[e,n,s]);return l.jsx(LNe.Provider,{value:i,children:t})}function pq(){const t=j.useContext(LNe);if(!t)throw new Error("useEvidence must be used inside <EvidenceProvider>");return t}function LLt(t){const[e,r]=j.useState(null),[n,s]=j.useState(null),[i,a]=j.useState(null),[o,c]=j.useState(!1),u=j.useRef(null),d=j.useRef(0),h=j.useRef(null),f=()=>{r(null),s(null),a(null),h.current=null};return j.useEffect(()=>{const{paragraphText:p,chapterKind:m,chapterTitle:g,enabled:x}=t;if(u.current&&(clearTimeout(u.current),u.current=null),!x||p.length<=80){c(!1);return}return h.current!==null&&Math.abs(p.length-h.current.length)>20&&f(),c(!0),u.current=setTimeout(async()=>{if(Date.now()-d.current<3e3){c(!1);return}try{d.current=Date.now();const{data:v,error:b}=await be.functions.invoke("ghost_suggestion",{body:{paragraph_text:p,chapter_kind:m,chapter_title:g}});if(b)throw b;v!=null&&v.suggestion&&(r(v.suggestion),s(v.citation??null),a(v.evidence??null),h.current=p)}catch(v){console.error("Ghost suggestion failed:",v),r(null)}finally{c(!1)}},1500),()=>{u.current&&clearTimeout(u.current)}},[t.paragraphText,t.chapterKind,t.chapterTitle,t.enabled]),{suggestion:e,citation:n,evidence:i,isLoading:o,clearSuggestion:f}}function sae(t){return t?t.split(/\n{2,}/).map(e=>`<p>${e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/\n/g,"<br/>")}</p>`).join(""):""}function iae({sectionId:t,html:e,plainText:r,onChange:n,placeholder:s,chapterKind:i="theory",chapterTitle:a=""}){const{register:o,unregister:c,setActiveId:u}=MNe(),{open:d}=pq(),{user:h}=Dt(),f=e!=null&&e.trim()?e:r?sae(r):"",p=j.useRef(f),m=j.useRef({suggestion:null,citation:null,evidence:null,clearSuggestion:()=>{}}),g=rMt({extensions:[ALt.configure({heading:{levels:[1,2,3]}}),GDt,lDt.configure({openOnClick:!1,autolink:!0,HTMLAttributes:{class:"underline text-primary"}}),MLt],content:f,editorProps:{attributes:{class:"prose prose-sm dark:prose-invert max-w-none focus:outline-none min-h-[80px] text-[15px] leading-relaxed"},handleClickOn(k,E,C,A,M){const z=M.target,P=z==null?void 0:z.closest("[data-citation-key]");if(!P)return!1;M.preventDefault();const W=P.getAttribute("data-citation-key")??"",N=P.getAttribute("data-citation-raw")??"",U=P.getAttribute("data-citation-surname")??"",K=P.getAttribute("data-citation-author-phrase")??"",G=P.getAttribute("data-citation-year")??"",X=P.getAttribute("data-citation-page")??"";return d({sectionId:t,citationKey:W,raw:N,surname:U,authorPhrase:K,year:G?parseInt(G,10):null,page:X?parseInt(X,10):null}),!0},handleKeyDown(k,E){const{suggestion:C,citation:A,evidence:M,clearSuggestion:z}=m.current;return E.key==="Tab"&&C?(E.preventDefault(),k.dispatch(k.state.tr.insertText(C+" "+A)),M&&t&&h&&be.from("section_evidence").insert({user_id:h.id,section_id:t,document_id:M.document_id,page_id:M.page_id,page_number:M.page_number,quote_text:M.quote_text,citation_text:M.citation_text}).then(()=>{window.dispatchEvent(new CustomEvent("ghost-evidence-accepted",{detail:{section_id:t}}))}),z(),!0):E.key==="Escape"?(z(),!0):!1}},onFocus(){u(t)},onUpdate({editor:k}){const E=k.getHTML();E!==p.current&&(p.current=E,n({html:E,text:k.getText()}))}}),x=g!=null&&g.state?g.state.doc.textBetween(g.state.selection.$from.start(),g.state.selection.$from.end()):"",{suggestion:y,citation:v,evidence:b,isLoading:w,clearSuggestion:S}=LLt({paragraphText:x,chapterKind:i??"theory",chapterTitle:a??"",enabled:!!h&&!!(g!=null&&g.isFocused)});return j.useEffect(()=>{m.current={suggestion:y,citation:v,evidence:b,clearSuggestion:S}},[y,v,b,S]),j.useEffect(()=>{if(g)return o(t,g),()=>c(t)},[g,t,o,c]),j.useEffect(()=>{if(!g)return;const k=e!=null&&e.trim()?e:r?sae(r):"";k&&k!==p.current&&(p.current=k,g.commands.setContent(k,{emitUpdate:!1}))},[e,r]),g?l.jsxs(l.Fragment,{children:[l.jsx(Lke,{editor:g,placeholder:s}),w&&l.jsx("div",{className:"ghost-loading",children:l.jsxs("span",{className:"ghost-fox-badge",children:[l.jsx("span",{className:"ghost-pulse"}),"Fox AI"]})}),!w&&y&&l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"ghost-inline-text",children:[y,v?` ${v}`:""]}),l.jsxs("div",{className:"ghost-action-bar",children:[l.jsxs("button",{className:"ghost-accept-btn",onClick:()=>{g.commands.insertContent(y+(v?" "+v:"")),b&&t&&h&&be.from("section_evidence").insert({user_id:h.id,section_id:t,document_id:b.document_id,page_id:b.page_id,page_number:b.page_number,quote_text:b.quote_text,citation_text:b.citation_text}).then(()=>{window.dispatchEvent(new CustomEvent("ghost-evidence-accepted",{detail:{section_id:t}}))}),S()},children:["Akzeptieren ",l.jsx("span",{"aria-hidden":!0,children:"→"})]}),l.jsx("button",{className:"ghost-dismiss-btn",onClick:()=>S(),children:"Verwerfen"})]})]})]}):null}const aae={introduction:"Introduction",theory:"Theory",methodology:"Methodology",results:"Results",discussion:"Discussion",conclusion:"Conclusion",references:"References",custom:"Custom"};function FLt({kind:t,isActive:e,hasDraft:r,onImport:n,onChangeKind:s,aiAvailability:i="hidden",aiTooltip:a,onCreateWithAI:o,onAddSection:c}){const u=t==="theory"?"Theory":t==="methodology"?"Methodology":null,d="w-10 h-10 inline-flex items-center justify-center rounded-md transition-colors";return l.jsxs("div",{className:Le("absolute -left-12 top-0 flex flex-col items-center gap-0.5 transition-opacity duration-150",e?"opacity-100":"opacity-0 group-hover/chapter:opacity-100 focus-within:opacity-100"),children:[c&&l.jsx(Zs,{delayDuration:150,children:l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx("button",{type:"button",onClick:c,className:Le(d,"text-muted-foreground hover:text-primary hover:bg-primary/10"),"aria-label":"Add section",children:l.jsx(hl,{className:"w-6 h-6"})})}),l.jsx(Qt,{side:"right",className:"text-xs",children:"Add section"})]})}),i!=="hidden"&&l.jsx(Zs,{delayDuration:150,children:l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx("button",{type:"button",onClick:i==="ready"?o:void 0,disabled:i==="soon",className:Le(d,i==="ready"?"text-muted-foreground hover:text-primary hover:bg-primary/10":"text-muted-foreground/40 cursor-not-allowed"),"aria-label":"Create with AI",children:l.jsx(Qs,{className:"w-6 h-6"})})}),l.jsx(Qt,{side:"right",className:"text-xs",children:a??(i==="ready"?"Create with AI":"Coming soon")})]})}),l.jsx("button",{type:"button",title:"Drag to reorder (coming soon)",className:Le(d,"text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted cursor-grab"),tabIndex:-1,children:l.jsx(b2e,{className:"w-6 h-6"})}),l.jsxs(w_e,{children:[l.jsx(S_e,{asChild:!0,children:l.jsx("button",{type:"button",title:"Chapter actions",className:Le(d,"text-muted-foreground hover:text-foreground hover:bg-muted"),children:l.jsx(p2e,{className:"w-6 h-6"})})}),l.jsxs(j7,{side:"right",align:"start",className:"w-60 p-1.5",children:[u&&r&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",onClick:n,className:"w-full text-left px-2.5 py-1.5 rounded text-sm hover:bg-muted",children:["Import ",u," Draft"]}),l.jsx("div",{className:"h-px bg-border my-1"})]}),l.jsx("div",{className:"px-2.5 py-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:"Chapter kind"}),Object.keys(aae).map(h=>l.jsx("button",{type:"button",onClick:()=>s(h),className:Le("w-full text-left px-2.5 py-1 rounded text-sm hover:bg-muted",h===t&&"text-primary font-medium"),children:aae[h]},h))]})]})]})}function $Lt({onEditThesis:t,onExport:e,exportLoading:r}){const{activeEditor:n}=MNe(),s=n,i=!s,a=u=>Le("p-1 rounded hover:bg-muted text-muted-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed",u&&"bg-muted text-foreground"),o=u=>u.preventDefault(),c=u=>()=>{s&&u()};return l.jsxs("div",{className:"sticky top-[var(--app-header-height)] z-30 -mx-3 md:-mx-4 xl:-mx-6 mb-4 px-3 lg:px-6 flex items-center gap-0.5 bg-card/95 text-card-foreground backdrop-blur border-b border-border overflow-x-auto",style:{height:"var(--thesis-toolbar-height)"},children:[l.jsx("button",{type:"button",onMouseDown:o,className:a(!1),onClick:c(()=>s.chain().focus().undo().run()),disabled:i||!(s!=null&&s.can().undo()),title:"Undo",children:l.jsx(nPe,{className:"w-3.5 h-3.5"})}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!1),onClick:c(()=>s.chain().focus().redo().run()),disabled:i||!(s!=null&&s.can().redo()),title:"Redo",children:l.jsx(K2e,{className:"w-3.5 h-3.5"})}),l.jsx("span",{className:"w-px h-5 bg-border mx-1.5"}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!!(s!=null&&s.isActive("heading",{level:1}))),onClick:c(()=>s.chain().focus().toggleHeading({level:1}).run()),disabled:i,title:"Heading 1",children:l.jsx(S2e,{className:"w-3.5 h-3.5"})}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!!(s!=null&&s.isActive("heading",{level:2}))),onClick:c(()=>s.chain().focus().toggleHeading({level:2}).run()),disabled:i,title:"Heading 2",children:l.jsx(_2e,{className:"w-3.5 h-3.5"})}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!!(s!=null&&s.isActive("heading",{level:3}))),onClick:c(()=>s.chain().focus().toggleHeading({level:3}).run()),disabled:i,title:"Heading 3",children:l.jsx(j2e,{className:"w-3.5 h-3.5"})}),l.jsx("span",{className:"w-px h-5 bg-border mx-1.5"}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!!(s!=null&&s.isActive("bold"))),onClick:c(()=>s.chain().focus().toggleBold().run()),disabled:i,title:"Bold",children:l.jsx(n2e,{className:"w-3.5 h-3.5"})}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!!(s!=null&&s.isActive("italic"))),onClick:c(()=>s.chain().focus().toggleItalic().run()),disabled:i,title:"Italic",children:l.jsx(N2e,{className:"w-3.5 h-3.5"})}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!!(s!=null&&s.isActive("underline"))),onClick:c(()=>s.chain().focus().toggleUnderline().run()),disabled:i,title:"Underline",children:l.jsx(rPe,{className:"w-3.5 h-3.5"})}),l.jsx("span",{className:"w-px h-5 bg-border mx-1.5"}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!!(s!=null&&s.isActive("bulletList"))),onClick:c(()=>s.chain().focus().toggleBulletList().run()),disabled:i,title:"Bullet list",children:l.jsx(T2e,{className:"w-3.5 h-3.5"})}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!!(s!=null&&s.isActive("orderedList"))),onClick:c(()=>s.chain().focus().toggleOrderedList().run()),disabled:i,title:"Numbered list",children:l.jsx(C2e,{className:"w-3.5 h-3.5"})}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!!(s!=null&&s.isActive("blockquote"))),onClick:c(()=>s.chain().focus().toggleBlockquote().run()),disabled:i,title:"Quote",children:l.jsx(Ah,{className:"w-3.5 h-3.5"})}),l.jsx("div",{className:"flex-1"}),l.jsx("span",{className:"w-px h-5 bg-border mx-1.5"}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!1),onClick:t,disabled:!t,title:"Edit Thesis",children:l.jsx(OH,{className:"w-3.5 h-3.5"})}),l.jsx("button",{type:"button",onMouseDown:o,className:a(!1),onClick:e,disabled:r||!e,title:"Export",children:r?l.jsx(xt,{className:"w-3.5 h-3.5 animate-spin"}):l.jsx(Ga,{className:"w-3.5 h-3.5"})})]})}function BLt({thesisId:t,chapterId:e,chapterTitle:r,defaultLanguage:n="en",isGenerating:s,onGenerate:i,onCancel:a,variant:o="inline"}){const[c,u]=j.useState(""),[d,h]=j.useState("auto"),[f,p]=j.useState(!1),[m,g]=j.useState(null),[x,y]=j.useState([]),[v,b]=j.useState({}),[w,S]=j.useState(""),[k,E]=j.useState(!1),[C,A]=j.useState(null),[M,z]=j.useState({}),P=Q=>Q.doi?`doi:${Q.doi.toLowerCase()}`:Q.id?`oa:${Q.id}`:`title:${(Q.title||Q.display_name||"").toLowerCase().replace(/\s+/g," ").trim()}`,W=Q=>Q.pdf_verified===!0&&!!Q.verified_pdf_url,N=async()=>{const Q=(w||c).trim();if(!Q){er({title:"Enter a search query or topic",variant:"destructive"});return}E(!0),A(null);try{const{data:D,error:R}=await be.functions.invoke("literature_discovery",{body:{action:"search",query:Q}});if(R)throw R;const J=(D==null?void 0:D.results)??(D==null?void 0:D.works)??(D==null?void 0:D.items)??[];A(J),J.length===0&&er({title:"No results",description:"Try a different query."})}catch(D){er({title:"OpenAlex search failed",description:(D==null?void 0:D.message)??"Unknown error",variant:"destructive"})}finally{E(!1)}},U=async Q=>{const D=P(Q);z(R=>({...R,[D]:{status:"loading"}}));try{const{data:R,error:J}=await be.functions.invoke("literature_discovery",{body:{action:"claim",work:Q}});if(J)throw J;const Z=R==null?void 0:R.import_status;z(ee=>({...ee,[D]:{status:"done",import_status:Z}})),er({title:"Added to My Library"})}catch(R){z(J=>{const Z={...J};return delete Z[D],Z}),er({title:"Could not add to library",description:(R==null?void 0:R.message)??"Unknown error",variant:"destructive"})}},K=Q=>{const D=Q.authors;return!D||Array.isArray(D)&&D.length===0?"":typeof D[0]=="string"?D.join(", "):D.map(R=>R.display_name||R.name||"").filter(Boolean).join(", ")},G=Q=>typeof Q.is_oa=="boolean"?Q.is_oa:typeof Q.open_access=="boolean"?Q.open_access:Q.open_access&&typeof Q.open_access=="object"?!!Q.open_access.is_oa:!1,X=async()=>{var Q;p(!0);try{const D={thesis_id:t,chapter_id:e,topic:c};console.log("[suggest_sources_for_chapter] REQUEST →",D);const{data:R,error:J}=await be.functions.invoke("suggest_sources_for_chapter",{body:D});if(console.log("[suggest_sources_for_chapter] RESPONSE ←",{data:R,error:J}),console.log("[suggest_sources_for_chapter] query field:",R==null?void 0:R.query),console.log("[suggest_sources_for_chapter] sources count:",((Q=R==null?void 0:R.sources)==null?void 0:Q.length)??0),console.log("[suggest_sources_for_chapter] sources:",R==null?void 0:R.sources),J)throw J;const Z=(R==null?void 0:R.sources)??[];g(Z),Z.length===0&&er({title:"No matching sources",description:"Add more documents to your library or refine the topic, or switch to manual selection."})}catch(D){er({title:"Could not suggest sources",description:(D==null?void 0:D.message)??"Unknown error",variant:"destructive"})}finally{p(!1)}},H=async()=>{const{data:Q}=await be.from("documents").select("id,title,original_filename,page_count").order("created_at",{ascending:!1}).limit(100);y((Q??[]).map(D=>({id:D.id,title:D.title||D.original_filename||"Untitled",page_count:D.page_count})))},B=async Q=>{h(Q),g(null),Q==="manual"&&x.length===0&&await H()},L=Q=>{g(D=>D&&D.filter(R=>R.document_id!==Q))},F=(Q,D)=>{b(R=>{const J={...R};return J[Q]?delete J[Q]:J[Q]={from:1,to:Math.min(D??15,15)},J})},V=async()=>{if(d==="auto"){if(!m||m.length===0){er({title:"Find sources first",description:'Click "Find relevant sources" to auto-select pages.',variant:"destructive"});return}const Q={};for(const D of m){const R=D.page_ranges[0];R&&(Q[D.document_id]=R)}await i({text:c,selected:m,pageRanges:Q})}else{const Q=Object.keys(v);if(Q.length===0){er({title:"Select at least one source",variant:"destructive"});return}const D=Q.map(R=>{const J=x.find(Z=>Z.id===R);return{document_id:R,document_title:J.title,score:0,page_ranges:[v[R]],pages:[]}});await i({text:c,selected:D,pageRanges:v})}},Y=o==="sheet",ie=Y?"":"mt-4 rounded-xl border border-border bg-muted/30 p-5";return l.jsxs("div",{className:ie,children:[!Y&&l.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[l.jsx(Qs,{className:"w-4 h-4 text-primary"}),"Generate Theory for “",r,"”"]}),l.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Academly drafts theoretical foundations from your own uploaded sources. APA7,"," ",n.toUpperCase(),"."]})]}),a&&l.jsx(ye,{variant:"ghost",size:"sm",onClick:a,disabled:s,className:"text-muted-foreground",children:"Close"})]}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"theory-topic",className:"text-xs",children:"Topic / focus"}),l.jsx(Be,{id:"theory-topic",value:c,onChange:Q=>u(Q.target.value),placeholder:`e.g. "${r}: key concepts and recent research"`,className:"mt-1.5 bg-background",disabled:s})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Sources"}),l.jsxs("div",{className:"mt-1.5 inline-flex rounded-lg border border-border bg-background p-0.5",children:[l.jsx("button",{type:"button",onClick:()=>B("auto"),disabled:s,className:`px-3 py-1.5 text-xs rounded-md transition ${d==="auto"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Auto-select relevant"}),l.jsx("button",{type:"button",onClick:()=>B("manual"),disabled:s,className:`px-3 py-1.5 text-xs rounded-md transition ${d==="manual"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Choose manually"}),l.jsx("button",{type:"button",onClick:()=>B("openalex"),disabled:s,className:`px-3 py-1.5 text-xs rounded-md transition ${d==="openalex"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:"OpenAlex"})]})]}),d==="auto"&&l.jsxs("div",{className:"space-y-2",children:[!m&&l.jsxs(ye,{variant:"outline",size:"sm",onClick:X,disabled:f||s,className:"gap-2",children:[f?l.jsx(xt,{className:"w-3.5 h-3.5 animate-spin"}):l.jsx(B2,{className:"w-3.5 h-3.5"}),"Find relevant sources"]}),m&&m.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-xs text-muted-foreground",children:"Suggested from your library — remove any you don't want to use."}),l.jsx("ul",{className:"space-y-2",children:m.map(Q=>{var D;return l.jsx("li",{className:"rounded-lg border border-border bg-background px-3 py-2",children:l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(ps,{className:"w-3.5 h-3.5 mt-1 text-muted-foreground shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-sm font-medium truncate",children:Q.document_title}),l.jsxs("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:["Pages"," ",Q.page_ranges.map(R=>R.from===R.to?`${R.from}`:`${R.from}–${R.to}`).join(", ")]}),((D=Q.pages[0])==null?void 0:D.snippet)&&l.jsxs("div",{className:"text-[11px] text-muted-foreground/80 mt-1 line-clamp-2 italic",children:['"',Q.pages[0].snippet,'"']})]}),l.jsx("button",{type:"button",onClick:()=>L(Q.document_id),disabled:s,className:"text-muted-foreground hover:text-foreground","aria-label":"Remove source",children:l.jsx(Is,{className:"w-3.5 h-3.5"})})]})},Q.document_id)})}),l.jsxs(ye,{variant:"ghost",size:"sm",onClick:X,disabled:f||s,className:"text-xs gap-1.5",children:[f?l.jsx(xt,{className:"w-3 h-3 animate-spin"}):l.jsx(B2,{className:"w-3 h-3"}),"Re-run suggestion"]})]})]}),d==="manual"&&l.jsx("div",{className:"max-h-56 overflow-y-auto rounded-lg border border-border bg-background divide-y divide-border",children:x.length===0?l.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"No documents found."}):x.map(Q=>{const D=!!v[Q.id];return l.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:bg-muted/40",children:[l.jsx("input",{type:"checkbox",checked:D,onChange:()=>F(Q.id,Q.page_count),disabled:s}),l.jsx("span",{className:"truncate flex-1",children:Q.title}),l.jsxs("span",{className:"text-[11px] text-muted-foreground tabular-nums",children:[Q.page_count??"—","p"]})]},Q.id)})}),d==="openalex"&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(yl,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),l.jsx(Be,{value:w,onChange:Q=>S(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&(Q.preventDefault(),N())},placeholder:"Search literature...",className:"pl-8 bg-background",disabled:k})]}),l.jsxs(ye,{size:"sm",onClick:N,disabled:k,className:"gap-1.5 whitespace-nowrap",children:[k?l.jsx(xt,{className:"w-3.5 h-3.5 animate-spin"}):l.jsx(Pce,{className:"w-3.5 h-3.5"}),"Search OpenAlex"]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Falls leer, wird Topic / focus verwendet. Results are not added to your thesis — only to your library."}),C&&C.length>0&&l.jsx("ul",{className:"space-y-2 max-h-[420px] overflow-y-auto pr-1",children:C.map(Q=>{const D=Q.title||Q.display_name||"Untitled",R=K(Q),J=Q.year??Q.publication_year??"",Z=Q.journal||Q.host_venue||Q.venue||"",ee=G(Q),re=M[P(Q)],he=W(Q),O=(re==null?void 0:re.status)==="loading",ae=(re==null?void 0:re.status)==="done",q=(re==null?void 0:re.status)==="done"?re.import_status==="fulltext_imported"?"Added · Fulltext":re.import_status==="pdf_stored"?"Added · PDF stored":re.import_status==="pdf_extract_failed"?"Added · Extract failed":"Added · Metadata":null;return l.jsx("li",{className:"rounded-lg border border-border bg-background px-3 py-2",children:l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(ps,{className:"w-3.5 h-3.5 mt-1 text-muted-foreground shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-sm font-medium leading-snug",children:D}),R&&l.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5 truncate",children:R}),l.jsxs("div",{className:"text-[11px] text-muted-foreground mt-0.5 flex flex-wrap items-center gap-x-2",children:[J&&l.jsx("span",{children:J}),Z&&l.jsx("span",{className:"italic truncate",children:Z}),ee&&l.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-sm bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 text-[10px] font-semibold uppercase tracking-wide",children:"Open Access"}),he?l.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-sm bg-sky-500/10 text-sky-600 dark:text-sky-400 text-[10px] font-semibold uppercase tracking-wide",children:"PDF available"}):l.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-sm bg-muted text-muted-foreground text-[10px] font-semibold uppercase tracking-wide",children:"Metadata only"})]})]}),l.jsxs(ye,{size:"sm",variant:ae?"secondary":"outline",onClick:()=>U(Q),disabled:!!re,className:"gap-1.5 shrink-0",children:[O?l.jsx(xt,{className:"w-3.5 h-3.5 animate-spin"}):ae?l.jsx(Es,{className:"w-3.5 h-3.5"}):null,ae?q:"Add to Library"]})]})},Q.id)})})]}),d!=="openalex"&&l.jsx("div",{className:"flex items-center justify-end gap-2 pt-1",children:l.jsxs(ye,{onClick:V,disabled:s,className:"gap-2",children:[s?l.jsx(xt,{className:"w-4 h-4 animate-spin"}):l.jsx(Qs,{className:"w-4 h-4"}),"Generate Theory"]})})]})]})}function zLt({thesisId:t,chapterId:e,chapterTitle:r,defaultLanguage:n="en",isGenerating:s,onGenerate:i,onCancel:a,variant:o="inline"}){const[c,u]=j.useState(""),[d,h]=j.useState(""),[f,p]=j.useState("auto"),[m,g]=j.useState(!1),[x,y]=j.useState(null),[v,b]=j.useState([]),[w,S]=j.useState({}),[k,E]=j.useState(""),[C,A]=j.useState(!1),[M,z]=j.useState(null),[P,W]=j.useState({}),N=R=>R.doi?`doi:${R.doi.toLowerCase()}`:R.id?`oa:${R.id}`:`title:${(R.title||R.display_name||"").toLowerCase().replace(/\s+/g," ").trim()}`,U=R=>R.pdf_verified===!0&&!!R.verified_pdf_url,K=async()=>{const R=(k||c).trim();if(!R){er({title:"Enter a search query or topic",variant:"destructive"});return}A(!0),z(null);try{const{data:J,error:Z}=await be.functions.invoke("literature_discovery",{body:{action:"search",query:R}});if(Z)throw Z;const ee=(J==null?void 0:J.results)??(J==null?void 0:J.works)??(J==null?void 0:J.items)??[];z(ee),ee.length===0&&er({title:"No results",description:"Try a different query."})}catch(J){er({title:"OpenAlex search failed",description:(J==null?void 0:J.message)??"Unknown error",variant:"destructive"})}finally{A(!1)}},G=async R=>{const J=N(R);W(Z=>({...Z,[J]:{status:"loading"}}));try{const{data:Z,error:ee}=await be.functions.invoke("literature_discovery",{body:{action:"claim",work:R}});if(ee)throw ee;const re=Z==null?void 0:Z.import_status;W(he=>({...he,[J]:{status:"done",import_status:re}})),er({title:"Added to My Library"})}catch(Z){W(ee=>{const re={...ee};return delete re[J],re}),er({title:"Could not add to library",description:(Z==null?void 0:Z.message)??"Unknown error",variant:"destructive"})}},X=R=>{const J=R.authors;return!J||Array.isArray(J)&&J.length===0?"":typeof J[0]=="string"?J.join(", "):J.map(Z=>Z.display_name||Z.name||"").filter(Boolean).join(", ")},H=R=>typeof R.is_oa=="boolean"?R.is_oa:typeof R.open_access=="boolean"?R.open_access:R.open_access&&typeof R.open_access=="object"?!!R.open_access.is_oa:!1,B=async()=>{var R;g(!0);try{const J={thesis_id:t,chapter_id:e,topic:c};console.log("[suggest_sources_for_chapter] REQUEST →",J);const{data:Z,error:ee}=await be.functions.invoke("suggest_sources_for_chapter",{body:J});if(console.log("[suggest_sources_for_chapter] RESPONSE ←",{data:Z,error:ee}),console.log("[suggest_sources_for_chapter] query field:",Z==null?void 0:Z.query),console.log("[suggest_sources_for_chapter] sources count:",((R=Z==null?void 0:Z.sources)==null?void 0:R.length)??0),console.log("[suggest_sources_for_chapter] sources:",Z==null?void 0:Z.sources),ee)throw ee;const re=(Z==null?void 0:Z.sources)??[];y(re),re.length===0&&er({title:"No matching sources",description:"Add more documents to your library or refine the topic, or switch to manual selection."})}catch(J){er({title:"Could not suggest sources",description:(J==null?void 0:J.message)??"Unknown error",variant:"destructive"})}finally{g(!1)}},L=async()=>{const{data:R}=await be.from("documents").select("id,title,original_filename,page_count").order("created_at",{ascending:!1}).limit(100);b((R??[]).map(J=>({id:J.id,title:J.title||J.original_filename||"Untitled",page_count:J.page_count})))},F=async R=>{p(R),y(null),R==="manual"&&v.length===0&&await L()},V=R=>{y(J=>J&&J.filter(Z=>Z.document_id!==R))},Y=(R,J)=>{S(Z=>{const ee={...Z};return ee[R]?delete ee[R]:ee[R]={from:1,to:Math.min(J??15,15)},ee})},ie=async()=>{if(f==="auto"){if(!x||x.length===0){er({title:"Find sources first",description:'Click "Find relevant sources" to auto-select pages.',variant:"destructive"});return}const R={};for(const J of x){const Z=J.page_ranges[0];Z&&(R[J.document_id]=Z)}await i({text:c,selected:x,pageRanges:R,ownWords:d})}else{const R=Object.keys(w);if(R.length===0){er({title:"Select at least one source",variant:"destructive"});return}const J=R.map(Z=>{const ee=v.find(re=>re.id===Z);return{document_id:Z,document_title:ee.title,score:0,page_ranges:[w[Z]],pages:[]}});await i({text:c,selected:J,pageRanges:w,ownWords:d})}},Q=o==="sheet",D=Q?"":"mt-4 rounded-xl border border-border bg-muted/30 p-5";return l.jsxs("div",{className:D,children:[!Q&&l.jsxs("div",{className:"flex items-start justify-between gap-3 mb-4",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[l.jsx(Qs,{className:"w-4 h-4 text-primary"}),"Draft Methodology for “",r,"”"]}),l.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Generate a methodology section based on your literature and your own research approach. APA7,"," ",n.toUpperCase(),"."]})]}),a&&l.jsx(ye,{variant:"ghost",size:"sm",onClick:a,disabled:s,className:"text-muted-foreground",children:"Close"})]}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"methodology-topic",className:"text-xs",children:"Topic / focus"}),l.jsx(Be,{id:"methodology-topic",value:c,onChange:R=>u(R.target.value),placeholder:`e.g. "${r}: research design and procedure"`,className:"mt-1.5 bg-background",disabled:s})]}),l.jsxs("div",{children:[l.jsxs(_e,{htmlFor:"methodology-own-words",className:"text-xs",children:["Your Approach ",l.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),l.jsx("textarea",{id:"methodology-own-words",value:d,onChange:R=>h(R.target.value),placeholder:"Describe your own steps (sampling, tools, timeline, limitations, etc.)",className:"mt-1.5 w-full min-h-[90px] rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",disabled:s})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Sources"}),l.jsxs("div",{className:"mt-1.5 inline-flex rounded-lg border border-border bg-background p-0.5",children:[l.jsx("button",{type:"button",onClick:()=>F("auto"),disabled:s,className:`px-3 py-1.5 text-xs rounded-md transition ${f==="auto"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Auto-select relevant"}),l.jsx("button",{type:"button",onClick:()=>F("manual"),disabled:s,className:`px-3 py-1.5 text-xs rounded-md transition ${f==="manual"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Choose manually"}),l.jsx("button",{type:"button",onClick:()=>F("openalex"),disabled:s,className:`px-3 py-1.5 text-xs rounded-md transition ${f==="openalex"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:"OpenAlex"})]})]}),f==="auto"&&l.jsxs("div",{className:"space-y-2",children:[!x&&l.jsxs(ye,{variant:"outline",size:"sm",onClick:B,disabled:m||s,className:"gap-2",children:[m?l.jsx(xt,{className:"w-3.5 h-3.5 animate-spin"}):l.jsx(B2,{className:"w-3.5 h-3.5"}),"Find relevant sources"]}),x&&x.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{className:"text-xs text-muted-foreground",children:"Suggested from your library — remove any you don't want to use."}),l.jsx("ul",{className:"space-y-2",children:x.map(R=>{var J;return l.jsx("li",{className:"rounded-lg border border-border bg-background px-3 py-2",children:l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(ps,{className:"w-3.5 h-3.5 mt-1 text-muted-foreground shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-sm font-medium truncate",children:R.document_title}),l.jsxs("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:["Pages"," ",R.page_ranges.map(Z=>Z.from===Z.to?`${Z.from}`:`${Z.from}–${Z.to}`).join(", ")]}),((J=R.pages[0])==null?void 0:J.snippet)&&l.jsxs("div",{className:"text-[11px] text-muted-foreground/80 mt-1 line-clamp-2 italic",children:['"',R.pages[0].snippet,'"']})]}),l.jsx("button",{type:"button",onClick:()=>V(R.document_id),disabled:s,className:"text-muted-foreground hover:text-foreground","aria-label":"Remove source",children:l.jsx(Is,{className:"w-3.5 h-3.5"})})]})},R.document_id)})}),l.jsxs(ye,{variant:"ghost",size:"sm",onClick:B,disabled:m||s,className:"text-xs gap-1.5",children:[m?l.jsx(xt,{className:"w-3 h-3 animate-spin"}):l.jsx(B2,{className:"w-3 h-3"}),"Re-run suggestion"]})]})]}),f==="manual"&&l.jsx("div",{className:"max-h-56 overflow-y-auto rounded-lg border border-border bg-background divide-y divide-border",children:v.length===0?l.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"No documents found."}):v.map(R=>{const J=!!w[R.id];return l.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:bg-muted/40",children:[l.jsx("input",{type:"checkbox",checked:J,onChange:()=>Y(R.id,R.page_count),disabled:s}),l.jsx("span",{className:"truncate flex-1",children:R.title}),l.jsxs("span",{className:"text-[11px] text-muted-foreground tabular-nums",children:[R.page_count??"—","p"]})]},R.id)})}),f==="openalex"&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("div",{className:"relative flex-1",children:[l.jsx(yl,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),l.jsx(Be,{value:k,onChange:R=>E(R.target.value),onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),K())},placeholder:"Search literature...",className:"pl-8 bg-background",disabled:C})]}),l.jsxs(ye,{size:"sm",onClick:K,disabled:C,className:"gap-1.5 whitespace-nowrap",children:[C?l.jsx(xt,{className:"w-3.5 h-3.5 animate-spin"}):l.jsx(Pce,{className:"w-3.5 h-3.5"}),"Search OpenAlex"]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Falls leer, wird Topic / focus verwendet. Results are not added to your thesis — only to your library."}),M&&M.length>0&&l.jsx("ul",{className:"space-y-2 max-h-[420px] overflow-y-auto pr-1",children:M.map(R=>{const J=R.title||R.display_name||"Untitled",Z=X(R),ee=R.year??R.publication_year??"",re=R.journal||R.host_venue||R.venue||"",he=H(R),O=P[N(R)],ae=U(R),q=(O==null?void 0:O.status)==="loading",I=(O==null?void 0:O.status)==="done",T=(O==null?void 0:O.status)==="done"?O.import_status==="fulltext_imported"?"Added · Fulltext":O.import_status==="pdf_stored"?"Added · PDF stored":O.import_status==="pdf_extract_failed"?"Added · Extract failed":"Added · Metadata":null;return l.jsx("li",{className:"rounded-lg border border-border bg-background px-3 py-2",children:l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(ps,{className:"w-3.5 h-3.5 mt-1 text-muted-foreground shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-sm font-medium leading-snug",children:J}),Z&&l.jsx("div",{className:"text-[11px] text-muted-foreground mt-0.5 truncate",children:Z}),l.jsxs("div",{className:"text-[11px] text-muted-foreground mt-0.5 flex flex-wrap items-center gap-x-2",children:[ee&&l.jsx("span",{children:ee}),re&&l.jsx("span",{className:"italic truncate",children:re}),he&&l.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-sm bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 text-[10px] font-semibold uppercase tracking-wide",children:"Open Access"}),ae?l.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-sm bg-sky-500/10 text-sky-600 dark:text-sky-400 text-[10px] font-semibold uppercase tracking-wide",children:"PDF available"}):l.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-sm bg-muted text-muted-foreground text-[10px] font-semibold uppercase tracking-wide",children:"Metadata only"})]})]}),l.jsxs(ye,{size:"sm",variant:I?"secondary":"outline",onClick:()=>G(R),disabled:!!O,className:"gap-1.5 shrink-0",children:[q?l.jsx(xt,{className:"w-3.5 h-3.5 animate-spin"}):I?l.jsx(Es,{className:"w-3.5 h-3.5"}):null,I?T:"Add to Library"]})]})},R.id)})})]}),f!=="openalex"&&l.jsx("div",{className:"flex items-center justify-end gap-2 pt-1",children:l.jsxs(ye,{onClick:ie,disabled:s,className:"gap-2",children:[s?l.jsx(xt,{className:"w-4 h-4 animate-spin"}):l.jsx(Qs,{className:"w-4 h-4"}),"Generate Methodology"]})})]})]})}const ULt={introduction:"Introduction",theory:"Theory",methodology:"Methodology",results:"Results",discussion:"Discussion",conclusion:"Conclusion",references:"References",custom:"Custom"};function HLt({open:t,onOpenChange:e,thesisId:r,chapterId:n,chapterTitle:s,chapterKind:i,isGenerating:a,onGenerate:o}){return j.useEffect(()=>{if(!t)return;const c=u=>{u.key==="Escape"&&e(!1)};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[t,e]),l.jsx("aside",{role:"complementary","aria-label":"Create with AI","aria-hidden":!t,className:Le("fixed inset-y-0 right-0 z-40 h-full w-full sm:max-w-md","bg-card border-l border-border shadow-xl overflow-y-auto","transition-transform duration-300 ease-out",t?"translate-x-0 pointer-events-auto":"translate-x-full pointer-events-none"),children:l.jsxs("div",{className:"p-6",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"inline-flex items-center justify-center w-7 h-7 rounded-md bg-primary/10 text-primary",children:l.jsx(Qs,{className:"w-4 h-4"})}),l.jsx("h2",{className:"text-base font-semibold text-foreground",children:"Create with AI"}),l.jsx("span",{className:"ml-auto text-[10px] uppercase tracking-wider px-2 py-0.5 rounded-full bg-muted text-muted-foreground",children:ULt[i]}),l.jsx("button",{type:"button",onClick:()=>e(!1),className:"ml-1 rounded-sm opacity-70 hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 p-1","aria-label":"Close",children:l.jsx(Is,{className:"h-4 w-4"})})]}),l.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Draft a theoretical background for"," ",l.jsx("span",{className:"text-foreground font-medium",children:s})," using your own uploaded sources."]}),l.jsxs("div",{className:"mt-5",children:[n&&i==="methodology"&&l.jsx(zLt,{variant:"sheet",thesisId:r,chapterId:n,chapterTitle:s,isGenerating:a,onGenerate:o,onCancel:()=>e(!1)}),n&&i!=="methodology"&&l.jsx(BLt,{variant:"sheet",thesisId:r,chapterId:n,chapterTitle:s,isGenerating:a,onGenerate:o,onCancel:()=>e(!1)})]})]})})}const FNe=SV,VLt=_V,WLt=jV,$Ne=j.forwardRef(({className:t,...e},r)=>l.jsx(gE,{className:Le("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));$Ne.displayName=gE.displayName;const qLt=Nh("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),mq=j.forwardRef(({side:t="right",className:e,children:r,...n},s)=>l.jsxs(WLt,{children:[l.jsx($Ne,{}),l.jsxs(yE,{ref:s,className:Le(qLt({side:t}),e),...n,children:[r,l.jsxs(TR,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[l.jsx(Is,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));mq.displayName=yE.displayName;const BNe=({className:t,...e})=>l.jsx("div",{className:Le("flex flex-col space-y-2 text-center sm:text-left",t),...e});BNe.displayName="SheetHeader";const gq=j.forwardRef(({className:t,...e},r)=>l.jsx(xE,{ref:r,className:Le("text-lg font-semibold text-foreground",t),...e}));gq.displayName=xE.displayName;const GLt=j.forwardRef(({className:t,...e},r)=>l.jsx(vE,{ref:r,className:Le("text-sm text-muted-foreground",t),...e}));GLt.displayName=vE.displayName;const oae=new Map,lae=3600,KLt=6e4;async function cae(t){if(!t)return null;const e=Date.now(),r=oae.get(t);if(r&&r.expiresAt-KLt>e)return r.url;const n=await Efe("documents",t,lae);return n&&oae.set(t,{url:n,expiresAt:e+lae*1e3}),n}function uae(t){return t.toLowerCase().replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/-\s+/g,"").replace(/\s+/g," ").trim()}async function zNe(t,e,r,n){if(!n||!n.trim())return[];const i=(await t.getTextContent()).items,a=[];let o="";i.forEach((g,x)=>{const y=uae(g.str);if(!y){a.push({itemIdx:x,normStart:o.length,normEnd:o.length});return}o.length>0&&!o.endsWith(" ")&&(o+=" ");const v=o.length;o+=y,a.push({itemIdx:x,normStart:v,normEnd:o.length})});const c=uae(n),u=[c],d=c.split(" ");d.length>8&&u.push(d.slice(0,Math.floor(d.length*.8)).join(" ")),d.length>12&&u.push(d.slice(0,10).join(" "));let h=-1,f=-1;for(const g of u){const x=o.indexOf(g);if(x>=0){h=x,f=x+g.length;break}}if(h<0)return[];const p=a.filter(g=>g.normEnd>h&&g.normStart<f).map(g=>g.itemIdx),m=[];for(const g of p){const x=i[g];if(!x||!x.str)continue;const y=jt.transform(e.transform,x.transform),v=Math.hypot(y[2],y[3]),b=x.width*r,w=y[4],S=y[5]-v;m.push({left:w,top:S,width:b,height:v})}return m}ll.workerSrc=`https://unpkg.com/pdfjs-dist@${eD}/build/pdf.worker.min.mjs`;function YLt({pdfUrl:t,pageNumber:e,quote:r,width:n=720}){const s=j.useRef(null),i=j.useRef(null),[a,o]=j.useState(!0),[c,u]=j.useState(null),[d,h]=j.useState([]),[f,p]=j.useState(null),[m,g]=j.useState(!1);return j.useEffect(()=>{let x=!1;return o(!0),u(null),h([]),g(!1),(async()=>{try{const y=await ZM(t).promise;if(x)return;const v=Math.min(Math.max(1,e),y.numPages),b=await y.getPage(v);if(x)return;const w=b.getViewport({scale:1}),S=n/w.width,k=b.getViewport({scale:S}),E=s.current;if(!E)return;const C=E.getContext("2d");if(!C||(E.width=k.width,E.height=k.height,p({w:k.width,h:k.height}),await b.render({canvasContext:C,viewport:k,canvas:E}).promise,x))return;if(r&&r.trim().length>0)try{const A=await zNe(b,k,S,r);x||(h(A),g(A.length>0))}catch(A){console.warn("Quote highlight failed:",A)}o(!1)}catch(y){console.error("PDF page render failed:",y),x||(u("Could not load PDF page."),o(!1))}})(),()=>{x=!0}},[t,e,r,n]),l.jsxs("div",{className:"space-y-2",children:[!a&&r&&!m&&l.jsxs("div",{className:"text-xs text-muted-foreground bg-muted/40 border border-border rounded px-2 py-1.5",children:["Exact highlight unavailable — showing cited page ",e,"."]}),l.jsxs("div",{ref:i,className:"relative inline-block rounded-md border border-border shadow-sm bg-white overflow-hidden",style:f?{width:f.w,height:f.h}:void 0,children:[l.jsx("canvas",{ref:s,className:"block"}),d.map((x,y)=>l.jsx("span",{className:"pdf-evidence-highlight",style:{left:x.left,top:x.top,width:x.width,height:x.height}},y)),a&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/60",children:l.jsx(xt,{className:"w-5 h-5 animate-spin text-muted-foreground"})}),c&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-destructive",children:c})]})]})}function XLt({pdf:t,pageNumber:e,width:r,quote:n,estimatedHeight:s,active:i}){const a=j.useRef(null),o=j.useRef(null),[c,u]=j.useState(s?{w:r,h:s}:null),[d,h]=j.useState([]),[f,p]=j.useState(!1);return j.useEffect(()=>{if(!i)return;let m=!1,g=null;return(async()=>{try{const x=await t.getPage(e);if(m)return;const y=x.getViewport({scale:1}),v=r/y.width,b=x.getViewport({scale:v});u({w:b.width,h:b.height});const w=a.current;if(!w)return;const S=w.getContext("2d");if(!S||(w.width=b.width,w.height=b.height,g=x.render({canvasContext:S,viewport:b,canvas:w}),await g.promise,m))return;const k=o.current;if(k){k.innerHTML="",k.style.width=`${b.width}px`,k.style.height=`${b.height}px`;try{const E=bw;typeof E=="function"&&await new E({textContentSource:x.streamTextContent(),container:k,viewport:b}).render()}catch(E){console.warn("Text layer render failed:",E)}}if(n&&n.trim())try{const E=await zNe(x,b,v,n);m||h(E)}catch(E){console.warn("Highlight failed:",E)}else h([]);m||p(!0)}catch(x){console.error("Page render failed:",x)}})(),()=>{m=!0;try{g==null||g.cancel()}catch{}}},[t,e,r,n,i]),l.jsx("div",{className:"relative mx-auto rounded-md border border-border shadow-sm bg-white overflow-hidden",style:c?{width:c.w,height:c.h}:{width:r,height:400},"data-page-number":e,children:i?l.jsxs(l.Fragment,{children:[l.jsx("canvas",{ref:a,className:"block"}),l.jsx("div",{ref:o,className:"evidence-pdf-textlayer","aria-hidden":!1}),d.map((m,g)=>l.jsx("span",{className:"pdf-evidence-highlight",style:{left:m.left,top:m.top,width:m.width,height:m.height}},g)),!f&&l.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/60",children:l.jsx(xt,{className:"w-5 h-5 animate-spin text-muted-foreground"})})]}):l.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-xs text-muted-foreground",children:["Page ",e]})})}ll.workerSrc=`https://unpkg.com/pdfjs-dist@${eD}/build/pdf.worker.min.mjs`;const dae=.5,hae=2,fae=.1,JLt=j.forwardRef(function({pdfUrl:e,highlights:r=[],initialPage:n=1,width:s,renderWindow:i=6},a){const o=j.useRef(null),c=j.useRef(new Map),[u,d]=j.useState(null),[h,f]=j.useState(!0),[p,m]=j.useState(null),[g,x]=j.useState({}),[y,v]=j.useState(new Set),[b,w]=j.useState(n),[S,k]=j.useState(String(n)),[E,C]=j.useState(1),[A,M]=j.useState(s??680),z=Math.max(200,Math.round(A*E)),P=j.useMemo(()=>{const Y=new Map;for(const ie of r)ie.page!=null&&ie.quote&&Y.set(ie.page,ie.quote);return Y},[r]);j.useEffect(()=>{if(s){M(s);return}const Y=o.current;if(!Y)return;const ie=()=>{const D=Y.clientWidth;D>0&&M(Math.max(320,D-24))};ie();const Q=new ResizeObserver(ie);return Q.observe(Y),()=>Q.disconnect()},[s]),j.useEffect(()=>{let Y=!1;return f(!0),m(null),d(null),x({}),(async()=>{try{const ie=await ZM(e).promise;if(Y){ie.destroy();return}d(ie),f(!1)}catch(ie){console.error("PDF load failed:",ie),Y||(m("Could not load PDF."),f(!1))}})(),()=>{Y=!0}},[e]),j.useEffect(()=>{if(!u)return;let Y=!1;return(async()=>{const ie=u.numPages,Q=8;for(let D=1;D<=ie;D+=Q){const R=[];for(let Z=D;Z<D+Q&&Z<=ie;Z++)R.push(Z);const J=await Promise.all(R.map(async Z=>{const re=(await u.getPage(Z)).getViewport({scale:1});return[Z,z/re.width*re.height]}));if(Y)return;x(Z=>{const ee={...Z};for(const[re,he]of J)ee[re]=he;return ee})}})(),()=>{Y=!0}},[u,z]),j.useEffect(()=>{if(!u)return;const Y=o.current;if(!Y)return;const ie=new IntersectionObserver(Q=>{v(D=>{const R=new Set(D);for(const J of Q){const Z=Number(J.target.dataset.page);Z&&(J.isIntersecting?R.add(Z):R.delete(Z))}return R})},{root:Y,rootMargin:"200px 0px",threshold:.01});return c.current.forEach(Q=>ie.observe(Q)),()=>ie.disconnect()},[u]),j.useEffect(()=>{if(y.size===0)return;const Y=Math.min(...Array.from(y));w(Y),k(String(Y))},[y]);const W=j.useMemo(()=>{if(!u)return new Set;const Y=new Set,ie=Array.from(y).sort((R,J)=>R-J),Q=ie[0]??n,D=Math.floor(i/2);for(let R=Q-D;R<=Q+D;R++)R>=1&&R<=u.numPages&&Y.add(R);for(const R of ie)Y.add(R);return Y},[y,u,i,n]),N=j.useCallback(Y=>{const ie=c.current.get(Y);ie&&ie.scrollIntoView({behavior:"smooth",block:"start"})},[]),U=j.useRef(!1);j.useEffect(()=>{if(!(!u||U.current))if(n>1){const Y=c.current.get(n);Y&&(Y.scrollIntoView({block:"start"}),U.current=!0)}else U.current=!0},[u,n,g]);const K=j.useRef(E);if(j.useEffect(()=>{if(K.current===E)return;K.current=E;const Y=b;requestAnimationFrame(()=>{const ie=c.current.get(Y);ie&&ie.scrollIntoView({block:"start"})})},[E,b]),j.useImperativeHandle(a,()=>({scrollToPage:N}),[N]),h)return l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8",children:[l.jsx(xt,{className:"w-4 h-4 animate-spin"})," Loading PDF…"]});if(p||!u)return l.jsx("div",{className:"text-sm text-destructive border border-destructive/30 rounded p-3",children:p??"PDF unavailable."});const G=u.numPages,X=Array.from({length:G},(Y,ie)=>ie+1),H=()=>N(Math.max(1,b-1)),B=()=>N(Math.min(G,b+1)),L=()=>C(Y=>Math.max(dae,Math.round((Y-fae)*100)/100)),F=()=>C(Y=>Math.min(hae,Math.round((Y+fae)*100)/100)),V=()=>{const Y=parseInt(S,10);Number.isFinite(Y)&&Y>=1&&Y<=G?N(Y):k(String(b))};return l.jsxs("div",{className:"relative min-w-0",children:[l.jsx("div",{ref:o,className:"relative max-h-[70vh] overflow-y-auto overflow-x-hidden bg-muted/30 rounded-md border border-border min-w-0",children:l.jsx("div",{className:"py-3 space-y-3",children:X.map(Y=>{const ie=W.has(Y);return l.jsxs("div",{"data-page":Y,ref:Q=>{Q?c.current.set(Y,Q):c.current.delete(Y)},children:[l.jsx(XLt,{pdf:u,pageNumber:Y,width:z,active:ie,quote:P.get(Y)??null,estimatedHeight:g[Y]}),l.jsxs("div",{className:"text-center text-[10px] text-muted-foreground mt-1",children:["Page ",Y," / ",G]})]},Y)})})}),l.jsx("div",{className:"pointer-events-none absolute bottom-3 left-0 right-0 flex justify-center z-10",children:l.jsxs("div",{className:"pointer-events-auto flex items-center gap-1 rounded-full border border-border bg-card/95 backdrop-blur px-2 py-1 shadow-theme-lg",children:[l.jsx("button",{type:"button",onClick:H,disabled:b<=1,className:"p-1.5 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Previous page",children:l.jsx(Ece,{className:"w-4 h-4"})}),l.jsxs("div",{className:"flex items-center gap-1 text-xs px-1",children:[l.jsx("input",{value:S,onChange:Y=>k(Y.target.value.replace(/[^\d]/g,"")),onBlur:V,onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),V())},className:"w-10 text-center bg-transparent border border-border rounded px-1 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary","aria-label":"Current page"}),l.jsxs("span",{className:"text-muted-foreground",children:["/ ",G]})]}),l.jsx("button",{type:"button",onClick:B,disabled:b>=G,className:"p-1.5 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Next page",children:l.jsx(eR,{className:"w-4 h-4"})}),l.jsx("div",{className:"w-px h-5 bg-border mx-1"}),l.jsx("button",{type:"button",onClick:L,disabled:E<=dae+.001,className:"p-1.5 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Zoom out",children:l.jsx($2e,{className:"w-4 h-4"})}),l.jsxs("span",{className:"text-xs tabular-nums w-10 text-center",children:[Math.round(E*100),"%"]}),l.jsx("button",{type:"button",onClick:F,disabled:E>=hae-.001,className:"p-1.5 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Zoom in",children:l.jsx(hl,{className:"w-4 h-4"})})]})})]})}),yF=3;function Gh(t){return t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function QLt(t,e){if(!t)return null;const r=t.authors_display||t.author_surname,n=t.published_year;if(!r||!n)return null;const s=e!=null?`, p. ${e}`:"";return`(${r}, ${n}${s})`}function ZLt(t,e){var h,f,p,m,g,x,y,v,b,w,S,k;let r=0;const n=Gh(e.surname??""),s=Gh(e.authorPhrase??e.surname??""),i=s.length>20||/\s/.test(s),a=Gh(((h=t.documents)==null?void 0:h.title)??""),o=Gh(((f=t.documents)==null?void 0:f.original_filename)??""),c=Gh(((p=t.documents)==null?void 0:p.author_surname)??"");Gh(((m=t.documents)==null?void 0:m.authors_display)??"");const u=Gh(((g=t.documents)==null?void 0:g.citation_apa)??""),d=[t.citation_text??"",((x=t.documents)==null?void 0:x.title)??"",((y=t.documents)==null?void 0:y.original_filename)??"",((v=t.documents)==null?void 0:v.author_surname)??"",((b=t.documents)==null?void 0:b.authors_display)??"",JSON.stringify(((w=t.documents)==null?void 0:w.bib_meta)??{})].map(E=>Gh(E)).join(" ");return e.raw&&t.citation_text&&t.citation_text.trim()===e.raw.trim()&&(r+=10),e.year!=null&&((S=t.documents)==null?void 0:S.published_year)===e.year&&(r+=3),n.length>=yF&&c&&(c.includes(n)||n.includes(c))&&(r+=6),i&&s.length>=8&&(a&&(a.includes(s)||s.includes(a))?r+=8:u&&u.includes(s.slice(0,30))?r+=5:o&&o.includes(s.slice(0,20))&&(r+=3)),!i&&n.length>=yF&&new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(d)&&(r+=4),n.length>0&&n.length<yF&&(a===n||o.includes(n))&&(r+=4),e.year&&d.includes(String(e.year))&&(r+=1),e.page!=null&&t.page_number===e.page&&(r+=5),e.year!=null&&((k=t.documents)==null?void 0:k.published_year)!=null&&Math.abs(t.documents.published_year-e.year)>1&&(r-=1),r}const pae="evidence-panel-width",e4t=520,mae=760;function gae(t){const e=typeof window<"u"?window.innerWidth*.9:1600;return Math.max(e4t,Math.min(e,t))}function t4t(){var X,H,B,L,F,V,Y,ie;const{current:t,close:e}=pq(),[r,n]=j.useState([]),[s,i]=j.useState(!1),[a,o]=j.useState(null),[c,u]=j.useState("quotes"),[d,h]=j.useState(null),[f,p]=j.useState(!1),[m,g]=j.useState(null),[x,y]=j.useState(null),[v,b]=j.useState(!1),w=j.useRef(null),[S,k]=j.useState(()=>{if(typeof window>"u")return mae;const Q=Number(localStorage.getItem(pae));return gae(Number.isFinite(Q)&&Q>0?Q:mae)}),E=j.useRef(!1),C=Q=>{Q.preventDefault(),E.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const D=J=>{if(!E.current)return;const Z=gae(window.innerWidth-J.clientX);k(Z)},R=()=>{E.current=!1,document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(pae,String(A.current))}catch{}window.removeEventListener("mousemove",D),window.removeEventListener("mouseup",R)};window.addEventListener("mousemove",D),window.addEventListener("mouseup",R)},A=j.useRef(S);j.useEffect(()=>{A.current=S},[S]);const M=j.useCallback(async Q=>{i(!0);const{data:D,error:R}=await be.from("section_evidence").select("id, section_id, document_id, page_number, quote_text, citation_text, created_at, documents(id, title, original_filename, storage_path, bib_meta, author_surname, authors_display, published_year, citation_apa)").eq("section_id",Q).order("created_at",{ascending:!0});R?(console.error("Load section_evidence failed:",R),n([])):n(D??[]),i(!1)},[]);j.useEffect(()=>{if(!t){n([]),o(null),h(null),u("quotes");return}M(t.sectionId)},[t==null?void 0:t.sectionId,M]),j.useEffect(()=>{const Q=D=>{t!=null&&t.sectionId&&M(t.sectionId)};return window.addEventListener("ghost-evidence-accepted",Q),()=>window.removeEventListener("ghost-evidence-accepted",Q)},[t==null?void 0:t.sectionId,M]);const z=j.useMemo(()=>t?r.map((Q,D)=>({row:Q,score:ZLt(Q,t),idx:D})).sort((Q,D)=>D.score-Q.score||Q.idx-D.idx).map(({row:Q,score:D})=>({row:Q,score:D})):[],[r,t]);j.useEffect(()=>{if(!t||z.length===0){o(null);return}const Q=!!t.citationKey,D=z[0],R=z[1],J=!R||D.score-R.score>=3||z.length===1;Q&&D.score>0&&J?o(D.row.id):o(null)},[t==null?void 0:t.citationKey,t==null?void 0:t.raw,z]);const P=((X=z.find(Q=>Q.row.id===a))==null?void 0:X.row)??null,W=j.useMemo(()=>{const Q=new Map;for(const D of r){const R=D.document_id;Q.has(R)||Q.set(R,[]),Q.get(R).push(D)}return Array.from(Q.entries()).map(([D,R])=>({documentId:D,rows:R.sort((J,Z)=>(J.page_number??0)-(Z.page_number??0)),doc:R[0].documents}))},[r]);j.useEffect(()=>{var D;if(!((D=P==null?void 0:P.documents)!=null&&D.storage_path)){h(null);return}let Q=!1;return p(!0),h(null),(async()=>{const R=await cae(P.documents.storage_path);Q||(h(R),p(!1))})(),()=>{Q=!0}},[P==null?void 0:P.id,(H=P==null?void 0:P.documents)==null?void 0:H.storage_path]),j.useEffect(()=>{if(W.length===0){g(null);return}(!m||!W.some(Q=>Q.documentId===m))&&g(W[0].documentId)},[W,m]);const N=j.useMemo(()=>W.find(Q=>Q.documentId===m)??null,[W,m]);j.useEffect(()=>{var R;const Q=(R=N==null?void 0:N.doc)==null?void 0:R.storage_path;if(!Q){y(null);return}let D=!1;return b(!0),y(null),(async()=>{const J=await cae(Q);D||(y(J),b(!1))})(),()=>{D=!0}},[(B=N==null?void 0:N.doc)==null?void 0:B.storage_path]);const U=((L=P==null?void 0:P.documents)==null?void 0:L.title)||((F=P==null?void 0:P.documents)==null?void 0:F.original_filename)||"Untitled source",K=r.length,G=W.length;return l.jsx(FNe,{open:!!t,onOpenChange:Q=>!Q&&e(),children:l.jsxs(mq,{side:"right",className:"w-full p-0 flex flex-col sm:!max-w-none",style:{width:typeof window<"u"&&window.innerWidth>=640?S:void 0},children:[l.jsx("div",{role:"separator","aria-orientation":"vertical",onMouseDown:C,className:"hidden sm:block absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-primary/30 active:bg-primary/50 transition-colors z-20",title:"Drag to resize"}),l.jsxs(BNe,{className:"px-5 py-4 border-b space-y-2",children:[l.jsxs(gq,{className:"text-base flex items-center gap-2",children:[l.jsx(Br,{className:"w-4 h-4 text-primary"}),"Citation evidence"]}),t&&(t.raw||t.surname)&&l.jsx("div",{className:"text-xs text-muted-foreground truncate",children:t.raw||`${t.surname} (${t.year??"?"}${t.page?`, p. ${t.page}`:""})`}),l.jsxs("div",{className:"flex items-center gap-1 pt-1",children:[l.jsxs("button",{onClick:()=>u("quotes"),className:`text-xs px-2.5 py-1 rounded-md inline-flex items-center gap-1.5 transition ${c==="quotes"?"bg-primary text-primary-foreground":"bg-muted/40 text-foreground hover:bg-muted"}`,children:[l.jsx(Ah,{className:"w-3 h-3"})," Quotes (",K,")"]}),l.jsxs("button",{onClick:()=>u("pdfs"),className:`text-xs px-2.5 py-1 rounded-md inline-flex items-center gap-1.5 transition ${c==="pdfs"?"bg-primary text-primary-foreground":"bg-muted/40 text-foreground hover:bg-muted"}`,children:[l.jsx(ps,{className:"w-3 h-3"})," PDFs (",G,")"]})]})]}),l.jsx(Yw,{className:"flex-1",children:l.jsxs("div",{className:"p-5 space-y-5",children:[s&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(xt,{className:"w-4 h-4 animate-spin"})," Loading evidence…"]}),!s&&r.length===0&&l.jsx("div",{className:"text-sm text-muted-foreground",children:"No stored evidence for this section yet. Re-generate the section with AI to capture original quotes."}),!s&&c==="quotes"&&r.length>0&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:["All evidence (",r.length,")"]}),z.map(({row:Q,score:D})=>{var Z,ee;const R=Q.id===a,J=((Z=Q.documents)==null?void 0:Z.title)||((ee=Q.documents)==null?void 0:ee.original_filename)||"Untitled source";return l.jsxs("button",{onClick:()=>o(Q.id),"aria-selected":R,className:`w-full text-left rounded-lg border p-3 transition min-w-0 overflow-hidden ${R?"border-primary bg-primary/5 ring-1 ring-primary/40":"border-border bg-card hover:bg-muted/30"}`,children:[l.jsxs("div",{className:"flex items-start justify-between gap-3 min-w-0",children:[l.jsx("div",{className:"text-xs font-medium break-words min-w-0 flex-1",children:J}),l.jsxs("div",{className:"text-[10px] text-muted-foreground shrink-0 flex items-center gap-2",children:[Q.citation_text&&l.jsx("span",{className:"break-words max-w-[180px]",children:Q.citation_text}),Q.page_number!=null&&l.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-muted/60 whitespace-nowrap",children:["p. ",Q.page_number]})]})]}),l.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2 break-words",children:["“",Q.quote_text,"”"]}),D>0&&(t==null?void 0:t.citationKey)&&l.jsxs("div",{className:"text-[9px] uppercase tracking-wider text-primary/70 mt-1",children:["match score ",D]})]},Q.id)})]}),P?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"rounded-lg border border-border bg-card p-4 min-w-0 overflow-hidden",children:[l.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground mb-1",children:"Source"}),l.jsx("div",{className:"text-sm font-medium leading-snug break-words",children:U}),l.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground min-w-0",children:[P.citation_text&&l.jsx("span",{className:"break-words min-w-0",children:P.citation_text}),P.page_number!=null&&l.jsxs("span",{className:"shrink-0",children:["Page ",P.page_number]}),d&&l.jsxs("a",{href:d,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-primary hover:underline ml-auto shrink-0",children:["Open full PDF ",l.jsx($p,{className:"w-3 h-3"})]})]})]}),(()=>{const Q=QLt(P.documents,P.page_number);if(!Q)return null;const D=!!P.citation_text&&P.citation_text.trim()!==Q;return l.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-3 flex items-center gap-3",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-0.5",children:"Canonical in-text citation"}),l.jsx("code",{className:"text-xs font-mono text-foreground block break-all",children:Q}),D&&l.jsx("div",{className:"text-[10px] text-amber-700 dark:text-amber-400 mt-0.5",children:"Differs from the citation in your draft — copy & paste to replace."})]}),l.jsx(ye,{size:"sm",variant:"ghost",className:"shrink-0 h-7 px-2",onClick:()=>{navigator.clipboard.writeText(Q).then(()=>{er({title:"Citation copied"})})},children:l.jsx(Tn,{className:"w-3.5 h-3.5"})})]})})(),l.jsxs("div",{className:"rounded-lg border border-yellow-200 bg-yellow-50 dark:bg-yellow-950/30 dark:border-yellow-900/60 p-4 min-w-0 overflow-hidden",children:[l.jsx("div",{className:"text-xs uppercase tracking-wider text-yellow-700 dark:text-yellow-400 mb-1",children:"Original quote"}),l.jsxs("blockquote",{className:"text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words",children:["“",P.quote_text,"”"]})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-2",children:"Cited page"}),f&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8",children:[l.jsx(xt,{className:"w-4 h-4 animate-spin"})," Loading PDF…"]}),!f&&!d&&l.jsxs("div",{className:"text-sm text-muted-foreground border border-dashed border-border rounded p-4",children:["PDF not available for this source. Copy the citation:"," ",l.jsx("code",{className:"text-xs",children:P.citation_text||(t==null?void 0:t.raw)})]}),d&&P.page_number!=null&&l.jsx(YLt,{pdfUrl:d,pageNumber:P.page_number,quote:P.quote_text})]})]}):l.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border rounded p-4",children:"Select an evidence row above to preview the source PDF and original quote."})]}),!s&&c==="pdfs"&&r.length>0&&l.jsxs("div",{className:"space-y-3",children:[W.length>1&&l.jsx("div",{className:"flex flex-wrap gap-1.5",children:W.map(Q=>{var J,Z;const D=((J=Q.doc)==null?void 0:J.title)||((Z=Q.doc)==null?void 0:Z.original_filename)||"Untitled",R=Q.documentId===m;return l.jsx("button",{onClick:()=>g(Q.documentId),className:`text-xs px-2.5 py-1 rounded-md border transition truncate max-w-[260px] ${R?"border-primary bg-primary/10 text-foreground":"border-border bg-card hover:bg-muted"}`,title:D,children:D},Q.documentId)})}),N?l.jsxs("div",{className:"rounded-lg border border-border bg-card p-3 space-y-3 min-w-0 overflow-hidden",children:[l.jsxs("div",{className:"flex items-start justify-between gap-3 min-w-0",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-sm font-medium break-words line-clamp-2",children:((V=N.doc)==null?void 0:V.title)||((Y=N.doc)==null?void 0:Y.original_filename)||"Untitled source"}),l.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[N.rows.length," quote",N.rows.length===1?"":"s"," ·"," ",new Set(N.rows.map(Q=>Q.page_number)).size," cited page",new Set(N.rows.map(Q=>Q.page_number)).size===1?"":"s"]})]}),x&&l.jsxs("a",{href:x,target:"_blank",rel:"noreferrer",className:"shrink-0 inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Open full PDF ",l.jsx($p,{className:"w-3 h-3"})]})]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:Array.from(new Set(N.rows.map(Q=>Q.page_number).filter(Q=>Q!=null))).sort((Q,D)=>Q-D).map(Q=>l.jsxs("button",{onClick:()=>{var D;return(D=w.current)==null?void 0:D.scrollToPage(Q)},className:"text-xs px-2 py-0.5 rounded border border-border bg-muted/30 hover:bg-muted transition",children:["p. ",Q]},Q))}),v&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6",children:[l.jsx(xt,{className:"w-4 h-4 animate-spin"})," Loading PDF…"]}),!v&&!x&&l.jsx("div",{className:"text-sm text-muted-foreground border border-dashed border-border rounded p-4",children:"PDF not available for this source."}),!v&&x&&l.jsx(JLt,{ref:w,pdfUrl:x,highlights:N.rows.filter(Q=>Q.page_number!=null).map(Q=>({page:Q.page_number,quote:Q.quote_text})),initialPage:((ie=N.rows[0])==null?void 0:ie.page_number)??1})]}):l.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border rounded p-4",children:"No source selected."})]})]})}),l.jsx("div",{className:"border-t px-5 py-3 flex justify-end",children:l.jsx(ye,{variant:"ghost",size:"sm",onClick:e,children:"Close"})})]})})}function yae({sectionId:t}){const{open:e}=pq(),[r,n]=j.useState(null);return j.useEffect(()=>{let s=!1;return(async()=>{const{count:i}=await be.from("section_evidence").select("id",{count:"exact",head:!0}).eq("section_id",t);s||n(typeof i=="number"?i:0)})(),()=>{s=!0}},[t]),!r||r<=0?null:l.jsxs("button",{type:"button",onClick:()=>e({sectionId:t,citationKey:"",raw:"",surname:"",year:null,page:null}),className:"inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-yellow-100 text-yellow-800 hover:bg-yellow-200 dark:bg-yellow-900/40 dark:text-yellow-300 border border-yellow-200 dark:border-yellow-900/60 transition",title:"Show citation evidence for this section",children:[l.jsx(Ah,{className:"w-3 h-3"}),"Evidence (",r,")"]})}function r4t({open:t,onOpenChange:e,thesis:r,onUpdated:n}){const[s,i]=j.useState({title:"",degree:"bachelor",description:"",due_date:"",target_word_count:15e3}),[a,o]=j.useState(!1);j.useEffect(()=>{t&&r&&i({title:r.title||"",degree:r.degree||"bachelor",description:r.description||"",due_date:r.due_date?r.due_date.split("T")[0]:"",target_word_count:r.target_word_count||15e3})},[t,r]);const c=async()=>{if(r){if(!s.title.trim()){er({title:"Error",description:"Title is required.",variant:"destructive"});return}o(!0);try{const u={title:s.title,degree:s.degree,description:s.description||null,due_date:s.due_date||null,target_word_count:s.target_word_count},{error:d}=await be.from("theses").update(u).eq("id",r.id);if(d)throw d;er({title:"Success",description:"Thesis updated successfully."}),n==null||n({...r,...u}),e(!1)}catch(u){console.error("Error updating thesis:",u),er({title:"Error",description:(u==null?void 0:u.message)||"Failed to update thesis.",variant:"destructive"})}finally{o(!1)}}};return l.jsx(Gr,{open:t,onOpenChange:e,children:l.jsxs(zr,{children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Edit Thesis"})}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"edit-title",children:"Title *"}),l.jsx(Be,{id:"edit-title",value:s.title,onChange:u=>i(d=>({...d,title:u.target.value})),placeholder:"Thesis title"})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"edit-degree",children:"Degree"}),l.jsxs(dt,{value:s.degree,onValueChange:u=>i(d=>({...d,degree:u})),children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"bachelor",children:"Bachelor"}),l.jsx(De,{value:"master",children:"Master"})]})]})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"edit-description",children:"Description (optional)"}),l.jsx(ir,{id:"edit-description",value:s.description,onChange:u=>i(d=>({...d,description:u.target.value})),placeholder:"Brief description of the thesis"})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"edit-due_date",children:"Due Date (optional)"}),l.jsx(Be,{id:"edit-due_date",type:"date",value:s.due_date,onChange:u=>i(d=>({...d,due_date:u.target.value}))})]}),l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(_e,{htmlFor:"edit-target_word_count",children:"Target Word Count"}),l.jsx(Zs,{children:l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(Bp,{className:"h-4 w-4 text-muted-foreground cursor-help"})}),l.jsxs(Qt,{side:"right",className:"max-w-[260px] text-xs leading-relaxed",children:[l.jsx("p",{className:"font-medium mb-1",children:"Approximate page count (A4, 12pt, 1.5 spacing):"}),l.jsxs("ul",{className:"space-y-0.5",children:[l.jsx("li",{children:"~3,000 words ≈ 10–12 pages"}),l.jsx("li",{children:"~5,000 words ≈ 18–20 pages"}),l.jsx("li",{children:"~10,000 words ≈ 35–40 pages"}),l.jsx("li",{children:"~15,000 words ≈ 55–60 pages"})]})]})]})})]}),l.jsx(Be,{id:"edit-target_word_count",type:"number",min:"1000",step:"500",value:s.target_word_count,onChange:u=>i(d=>({...d,target_word_count:parseInt(u.target.value)||15e3})),placeholder:"15000"})]}),l.jsxs("div",{className:"flex justify-end gap-2",children:[l.jsx(ye,{variant:"outline",onClick:()=>e(!1),disabled:a,children:"Cancel"}),l.jsx(ye,{onClick:c,disabled:a,children:a?"Saving…":"Save Changes"})]})]})]})})}const xae={theory:["theor","background","hinterg","literatur","literature review","stand des wissens","allgemeine definition","grundlag"],methodology:["method","methodik","vorgeh","approach"]};function n4t(t){if(!t)return"custom";const e=t.toLowerCase();return xae.theory.some(r=>e.includes(r))?"theory":xae.methodology.some(r=>e.includes(r))?"methodology":/(introd|einleit)/i.test(e)?"introduction":/(result|finding|befund|ergebn)/i.test(e)?"results":/(discuss|diskus)/i.test(e)?"discussion":/(conclus|fazit|schluss)/i.test(e)?"conclusion":/(referenc|bibliograp|literaturverz)/i.test(e)?"references":"custom"}function xF(t){if(!t)return"";if(typeof window>"u")return t;const e=document.createElement("div");return e.innerHTML=t,(e.textContent||e.innerText||"").trim()}function HC(t){return(t.trim().match(/\S+/g)||[]).length}function s4t(){const{user:t,loading:e,researchProfile:r}=Dt(),n=Or(),[s,i]=j.useState(!0),[a,o]=j.useState(null),[c,u]=j.useState([]),[d,h]=j.useState({}),[f,p]=j.useState(null),[m,g]=j.useState(null),[x,y]=j.useState(0),[v,b]=j.useState(null),[w,S]=j.useState([]),[k,E]=j.useState(new Set),[C,A]=j.useState(!1),[M,z]=j.useState(!1),[P,W]=j.useState(null),[N,U]=j.useState(!1),[K,G]=j.useState(null),[X,H]=j.useState(null),[B,L]=j.useState(null),[F,V]=j.useState(!1),[Y,ie]=j.useState(null),[Q,D]=j.useState(null),R=j.useRef({}),J=j.useRef({}),Z=j.useRef({}),ee=j.useRef({});j.useEffect(()=>{!e&&!t&&n("/login")},[e,t,n]);const re=async we=>{var it,Ce;i(!0);const{data:Oe}=await be.from("theses").select("id,title,due_date,target_word_count,updated_at,degree,description").eq("user_id",we).order("updated_at",{ascending:!1}).limit(1),je=(Oe==null?void 0:Oe[0])??null;if(o(je),je){const{data:$t}=await be.from("chapters").select("id,title,order_index,progress,updated_at,kind").eq("thesis_id",je.id).is("parent_id",null).order("order_index"),Kt=$t??[];if(u(Kt),Kt.length&&p(Kt[0].id),Kt.length){const{data:Do}=await be.from("sections").select("id,chapter_id,title,order_index,content,content_rich,word_count,updated_at").in("chapter_id",Kt.map(Rr=>Rr.id)).order("order_index"),rs={};Do==null||Do.forEach(Rr=>{var pn;(rs[pn=Rr.chapter_id]||(rs[pn]=[])).push(Rr)}),h(rs)}const{count:On}=await be.from("documents").select("id",{count:"exact",head:!0}).eq("user_id",we);y(On??0);const{data:Ms}=await be.from("documents").select("id, title, citation_apa, bib_meta, author_surname, published_year, authors_display").eq("user_id",we);if(S(Ms||[]),Kt.length){const{data:Do}=await be.from("sections").select("id").in("chapter_id",Kt.map(Rr=>Rr.id)),rs=(Do||[]).map(Rr=>Rr.id);if(rs.length){const{data:Rr}=await be.from("section_evidence").select("document_id").in("section_id",rs).not("document_id","is",null);E(new Set((Rr||[]).map(pn=>pn.document_id).filter(Boolean)))}else E(new Set)}}const[Re,Ue]=await Promise.all([be.from("theory_backgrounds").select("title,theory_text,created_at").eq("user_id",we).not("theory_text","is",null).order("created_at",{ascending:!1}).limit(1).maybeSingle(),be.from("methods").select("title,method_text,created_at").eq("user_id",we).not("method_text","is",null).order("created_at",{ascending:!1}).limit(1).maybeSingle()]);(it=Re.data)!=null&&it.theory_text&&G({title:Re.data.title||"Theory Draft",text:Re.data.theory_text,created_at:Re.data.created_at}),(Ce=Ue.data)!=null&&Ce.method_text&&H({title:Ue.data.title||"Methodology Draft",text:Ue.data.method_text,created_at:Ue.data.created_at}),i(!1)};j.useEffect(()=>{t&&re(t.id)},[t]),j.useEffect(()=>{if(!c.length)return;const we=new IntersectionObserver(Oe=>{var Re;const je=Oe.filter(Ue=>Ue.isIntersecting).map(Ue=>({id:Ue.target.dataset.chapterId,top:Ue.boundingClientRect.top})).filter(Ue=>!!Ue.id).sort((Ue,it)=>Ue.top-it.top);(Re=je[0])!=null&&Re.id&&p(je[0].id)},{rootMargin:"-25% 0px -65% 0px",threshold:[0,.1,.5]});return c.forEach(Oe=>{const je=R.current[Oe.id];je&&we.observe(je)}),()=>we.disconnect()},[c]),j.useEffect(()=>{const we=Object.values(d).flat();if(!we.length)return;const Oe=new IntersectionObserver(je=>{var Ue;const Re=je.filter(it=>it.isIntersecting).map(it=>({id:it.target.dataset.sectionId,top:it.boundingClientRect.top})).filter(it=>!!it.id).sort((it,Ce)=>it.top-Ce.top);(Ue=Re[0])!=null&&Ue.id&&g(Re[0].id)},{rootMargin:"-30% 0px -60% 0px",threshold:[0,.1,.5]});return we.forEach(je=>{const Re=J.current[je.id];Re&&Oe.observe(Re)}),()=>Oe.disconnect()},[d]),j.useEffect(()=>{if(!f)return;const we=Z.current[f];we==null||we.scrollIntoView({block:"nearest",behavior:"smooth"})},[f]);const he=we=>we.kind||n4t(we.title),O=j.useMemo(()=>c.find(we=>he(we)==="theory"),[c]),ae=j.useMemo(()=>c.find(we=>he(we)==="methodology"),[c]),q=j.useMemo(()=>{const we=c.map(Ce=>({sections:(d[Ce.id]??[]).map($t=>({content:`${$t.content||""}
${xF($t.content_rich||"")}`}))})),Oe=S7(we,w),je=new Set(k);Oe.matched.forEach(Ce=>je.add(Ce.documentId));const Re=new Map(w.map(Ce=>[Ce.id,Ce])),Ue=Array.from(je).map(Ce=>Re.get(Ce)).filter(Boolean),it=Ce=>{var $t;return(Ce.author_surname||Ce.authors_display||(($t=Ce.citation_apa)==null?void 0:$t.split(/[,(]/)[0])||Ce.title||"").toString().trim().toLowerCase()};return Ue.sort((Ce,$t)=>it(Ce).localeCompare(it($t))),Ue},[c,d,w,k]),I=we=>(O==null?void 0:O.id)===we&&K?{kind:"theory",title:K.title,text:K.text,createdAt:K.created_at,chapterId:we}:(ae==null?void 0:ae.id)===we&&X?{kind:"methodology",title:X.title,text:X.text,createdAt:X.created_at,chapterId:we}:null,T=we=>we.content_rich?HC(xF(we.content_rich)):we.word_count??HC(we.content||""),$=j.useMemo(()=>Object.values(d).flat().reduce((we,Oe)=>we+T(Oe),0),[d]),se=j.useMemo(()=>Object.values(d).flat().length,[d]),ue=Number(a==null?void 0:a.target_word_count)||0,ne=j.useMemo(()=>ue>0?Math.min(100,Math.round($/ue*100)):c.length?Math.round(c.reduce((we,Oe)=>we+(Number(Oe.progress)||0),0)/c.length):0,[ue,$,c]),me=j.useMemo(()=>{const we={},Oe=ue>0&&se>0?ue/se:0;return c.forEach(je=>{const Re=d[je.id]??[];if(!Re.length){we[je.id]=0;return}if(Oe>0){const Ue=Re.reduce((it,Ce)=>it+Math.min(100,Math.round(T(Ce)/Oe*100)),0)/Re.length;we[je.id]=Math.round(Ue)}else we[je.id]=Number(je.progress)||0}),we},[c,d,ue,se]),ve=ne,xe=j.useMemo(()=>c.filter(we=>(me[we.id]??0)>=100).length,[c,me]),oe=(we,Oe,je)=>{h(Re=>({...Re,[we]:(Re[we]??[]).map(Ue=>Ue.id===Oe?{...Ue,content_rich:je.html,content:je.text,word_count:HC(je.text)}:Ue)})),ee.current[Oe]&&clearTimeout(ee.current[Oe]),ee.current[Oe]=setTimeout(async()=>{b(Oe),await be.from("sections").update({content:je.text,content_rich:je.html}).eq("id",Oe),b(null)},700)},de=async(we,Oe)=>{u(je=>je.map(Re=>Re.id===we?{...Re,title:Oe}:Re)),await be.from("chapters").update({title:Oe}).eq("id",we)},ge=async(we,Oe,je)=>{h(Re=>({...Re,[we]:(Re[we]??[]).map(Ue=>Ue.id===Oe?{...Ue,title:je}:Ue)})),await be.from("sections").update({title:je}).eq("id",Oe)},Se=async we=>{if(!t)return;const je=((d[we]??[]).reduce((Ce,$t)=>Math.max(Ce,$t.order_index??0),0)||0)+10,{data:Re,error:Ue}=await be.from("sections").insert({chapter_id:we,title:"",content:"",order_index:je}).select("id,chapter_id,title,order_index,content,content_rich,word_count,updated_at").single();if(Ue){er({title:"Could not add section",description:Ue.message,variant:"destructive"});return}const it=Re;h(Ce=>({...Ce,[we]:[...Ce[we]??[],it]})),setTimeout(()=>{const Ce=J.current[it.id];Ce==null||Ce.scrollIntoView({behavior:"smooth",block:"center"});const $t=Ce==null?void 0:Ce.querySelector('.ProseMirror[contenteditable="true"]');$t==null||$t.focus()},150)},ke=async(we,Oe)=>{u(je=>je.map(Re=>Re.id===we?{...Re,kind:Oe}:Re)),await be.from("chapters").update({kind:Oe}).eq("id",we)},Ne=we=>{var Oe;(Oe=R.current[we])==null||Oe.scrollIntoView({behavior:"smooth",block:"start"})},qe=we=>{var Oe;(Oe=J.current[we])==null||Oe.scrollIntoView({behavior:"smooth",block:"start"})},Ae=async()=>{if(a){U(!0);try{const we={thesis:{title:a.title,degree:a.degree||"bachelor",description:a.description||void 0,due_date:a.due_date,target_word_count:a.target_word_count},chapters:c.map(Oe=>({title:Oe.title,order_index:Oe.order_index,status:"open",sections:(d[Oe.id]??[]).map(je=>({title:je.title||"",type:"text",content:je.content_rich?xF(je.content_rich):je.content||"",status:"open",word_count:je.word_count??HC(je.content||""),order_index:je.order_index}))}))};W(we),z(!0)}finally{U(!1)}}},fe=async()=>{if(!(!B||!t)){V(!0);try{const we=d[B.chapterId]??[],Oe=B.kind==="theory"?"Theory Draft":"Methodology Draft",je=we.find(Re=>Re.title===Oe)??we[0];if(je){const Re=je.content?`${je.content}
${B.text}`:B.text,{error:Ue}=await be.from("sections").update({content:Re,content_rich:null}).eq("id",je.id);if(Ue)throw Ue;h(it=>({...it,[B.chapterId]:it[B.chapterId].map(Ce=>Ce.id===je.id?{...Ce,content:Re,content_rich:null}:Ce)}))}else{const{data:Re,error:Ue}=await be.from("sections").insert({chapter_id:B.chapterId,title:Oe,content:B.text,order_index:10}).select("id,chapter_id,title,order_index,content,content_rich,word_count,updated_at").single();if(Ue)throw Ue;h(it=>({...it,[B.chapterId]:[...it[B.chapterId]??[],Re]}))}er({title:"Draft imported",description:`${B.title} added to chapter.`}),L(null),setTimeout(()=>Ne(B.chapterId),50)}catch(we){er({title:"Import failed",description:we.message??"Could not import draft.",variant:"destructive"})}finally{V(!1)}}},Te=we=>{if(!we)return we;const Oe=/^[ \t]*(?:#{1,6}[ \t]*)?(?:\*\*)?(?:Original\s+Quotes|Proof\s+of\s+Material|Wörtliche\s+Zitate|Originalzitate)\b.*$/im;let je=we.replace(new RegExp(Oe.source+"[\\s\\S]*$","im"),"");return je=je.replace(/(?:\n[ \t]*>.*)+\s*$/m,""),je.trimEnd()},Pe=(we,Oe,je)=>{const Re=(we||"").trim();if(Re)return Re.slice(0,80);const Ue=(Oe||"").trim();return Ue.length>=3?Ue.slice(0,80):(je||"Section").slice(0,80)},tt=async(we,Oe)=>{if(!(!a||!t)){D(we);try{const je=c.find(pn=>pn.id===we),Re=Oe.selected.map(pn=>pn.document_id),Ue=(Oe.text||"").trim().length>=5?Oe.text.trim():`${(je==null?void 0:je.title)??"Theory"} — ${a.title}`,{data:it,error:Ce}=await be.functions.invoke("thesis_builder",{body:{document_ids:Re,page_ranges:Oe.pageRanges,topic:Ue,mode:"academic",language:"en",citation_style:"APA7",save_pdf:!1,thesis_id:a.id,chapter_id:we}});if(Ce)throw Ce;if((it==null?void 0:it.error)==="rate_limit"){er({title:"Please retry",description:`Rate limited. Retry in ~${it.retry_after??10}s.`,variant:"destructive"});return}const $t=(it==null?void 0:it.content)??(it==null?void 0:it.theory_text)??(it==null?void 0:it.text)??(it==null?void 0:it.result)??"";if(!$t)throw new Error("Empty response from generator.");const Kt=Te($t),On=Pe(it==null?void 0:it.title,Oe.text,je==null?void 0:je.title),Do=((d[we]??[]).reduce((pn,lr)=>Math.max(pn,lr.order_index??0),0)||0)+10,{data:rs,error:Rr}=await be.from("sections").insert({chapter_id:we,title:On,content:Kt,order_index:Do}).select("id,chapter_id,title,order_index,content,content_rich,word_count,updated_at").single();if(Rr)throw Rr;if(rs!=null&&rs.id&&Array.isArray(it==null?void 0:it.evidence)&&it.evidence.length>0){const pn=it.evidence.filter(lr=>(lr==null?void 0:lr.document_id)&&(lr==null?void 0:lr.quote_text)).map(lr=>({user_id:t.id,section_id:rs.id,document_id:lr.document_id,page_number:lr.page_number??null,quote_text:lr.quote_text,citation_text:lr.citation_text??null}));if(pn.length>0){const{error:lr}=await be.from("section_evidence").insert(pn);lr&&(console.error("[MyThesis2] Evidence insert failed:",lr),er({title:"Evidence not saved",description:lr.message,variant:"destructive"}))}}h(pn=>({...pn,[we]:[...pn[we]??[],rs]})),er({title:"Draft created",description:"Inserted into your chapter."}),ie(null),setTimeout(()=>Ne(we),80)}catch(je){console.error("runTheoryGeneration error",je),er({title:"Generation failed",description:(je==null?void 0:je.message)??"Unknown error",variant:"destructive"})}finally{D(null)}}},wt=async(we,Oe)=>{var je;if(!(!a||!t)){D(we);try{const Re=c.find(lr=>lr.id===we),Ue=Oe.selected.map(lr=>lr.document_id),it=(Oe.text||"").trim().length>=5?Oe.text.trim():`${(Re==null?void 0:Re.title)??"Methodology"} — ${a.title}`,{data:Ce,error:$t}=await be.functions.invoke("methodology_builder",{body:{document_ids:Ue,page_ranges:Oe.pageRanges,topic:it,language:"en",citation_style:"APA7",mode:"academic",own_words:Oe.ownWords??"",client_request_id:crypto.randomUUID()}});if($t)throw $t;if(console.log("[methodology-evidence] data received:",{hasEvidence:Array.isArray(Ce==null?void 0:Ce.evidence),evidenceCount:((je=Ce==null?void 0:Ce.evidence)==null?void 0:je.length)??0,hasContent:!!(Ce!=null&&Ce.content)}),(Ce==null?void 0:Ce.error)==="rate_limit"){er({title:"Please retry",description:`Rate limited. Retry in ~${Ce.retry_after??10}s.`,variant:"destructive"});return}const Kt=(Ce==null?void 0:Ce.content)??(Ce==null?void 0:Ce.methodology_text)??(Ce==null?void 0:Ce.text)??(Ce==null?void 0:Ce.result)??"";if(!Kt)throw new Error("Empty response from generator.");const On=Te(Kt),Ms=Pe(Ce==null?void 0:Ce.title,Oe.text,Re==null?void 0:Re.title),rs=((d[we]??[]).reduce((lr,mn)=>Math.max(lr,mn.order_index??0),0)||0)+10,{data:Rr,error:pn}=await be.from("sections").insert({chapter_id:we,title:Ms,content:On,order_index:rs}).select("id,chapter_id,title,order_index,content,content_rich,word_count,updated_at").single();if(pn)throw pn;if(Rr!=null&&Rr.id&&Array.isArray(Ce==null?void 0:Ce.evidence)&&Ce.evidence.length>0){const lr=Ce.evidence.filter(mn=>(mn==null?void 0:mn.document_id)&&(mn==null?void 0:mn.quote_text)).map(mn=>({user_id:t.id,section_id:Rr.id,document_id:mn.document_id,page_id:mn.page_id??null,page_number:mn.page_number??null,quote_text:mn.quote_text,citation_text:mn.citation_text??null}));if(lr.length>0){console.log("[methodology-evidence] about to upsert payload:",{payload:lr,insertedSectionId:(Rr==null?void 0:Rr.id)??null});const{error:mn}=await be.from("section_evidence").insert(lr);console.log("[methodology-evidence] upsert result:",{evidenceError:mn}),mn?(console.error("[methodology-evidence] save failed:",mn,lr),er({title:"Evidence not saved",description:mn.message,variant:"destructive"})):window.dispatchEvent(new CustomEvent("ghost-evidence-accepted",{detail:{section_id:Rr.id}}))}}h(lr=>({...lr,[we]:[...lr[we]??[],Rr]})),er({title:"Draft created",description:"Inserted into your chapter."}),ie(null),setTimeout(()=>Ne(we),80)}catch(Re){console.error("runMethodologyGeneration error",Re),er({title:"Generation failed",description:(Re==null?void 0:Re.message)??"Unknown error",variant:"destructive"})}finally{D(null)}}},Ee=(we,Oe,je)=>je&&we<100?l.jsx(lL,{className:"w-3.5 h-3.5 text-primary fill-primary/30"}):we>=100?l.jsx(Es,{className:"w-3.5 h-3.5 text-emerald-500",strokeWidth:3}):we>0?l.jsx(a2e,{className:"w-3.5 h-3.5 text-amber-500"}):l.jsx(L2,{className:`w-3.5 h-3.5 ${Oe?"text-primary":"text-muted-foreground/40"}`});if(e||s)return l.jsx(gr,{showSidebar:!0,pageTitle:"My Thesis 2",fullWidth:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsx(xt,{className:"w-6 h-6 animate-spin text-muted-foreground"})})});if(!a)return l.jsx(gr,{showSidebar:!0,pageTitle:"My Thesis 2",fullWidth:!0,children:l.jsxs("div",{className:"min-h-[60vh] flex flex-col items-center justify-center gap-4",children:[l.jsx("p",{className:"text-muted-foreground",children:"No thesis yet."}),l.jsx(ye,{onClick:()=>n("/thesis-manager"),children:"Create your first thesis"})]})});c.find(we=>we.id===f);const nt=we=>{switch(we){case"theory":case"methodology":return"ready";case"results":case"discussion":case"conclusion":return"soon";default:return"hidden"}},rt=(we,Oe)=>{(Oe==="theory"||Oe==="methodology")&&ie(we)},Ze=c.find(we=>we.id===Y)??null;return l.jsx(DLt,{children:l.jsx(CLt,{children:l.jsxs(gr,{showSidebar:!0,pageTitle:"My Thesis 2",fullWidth:!0,children:[l.jsx($Lt,{onEditThesis:()=>A(!0),onExport:Ae,exportLoading:N}),l.jsx(t4t,{}),l.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_240px] gap-5 px-2 lg:px-4 py-2",children:[l.jsx("main",{className:"min-w-0",children:l.jsxs("article",{className:"bg-card text-card-foreground p-6 lg:p-8 pl-8 lg:pl-12 max-w-[78ch] mx-auto",children:[c.map((we,Oe)=>{const je=d[we.id]??[],Re=I(we.id),Ue=he(we),it=f===we.id;return l.jsxs("section",{"data-chapter-id":we.id,ref:Ce=>{R.current[we.id]=Ce},className:`group/chapter relative ${Oe>0?"mt-16 pt-10 border-t border-border":""}`,children:[l.jsx(FLt,{kind:Ue,isActive:it,hasDraft:!!Re,onImport:Re?()=>L(Re):void 0,onChangeKind:Ce=>ke(we.id,Ce),aiAvailability:nt(Ue),aiTooltip:Ue==="theory"?"Create with AI — draft theoretical background":Ue==="methodology"?"Create with AI — draft methodology":"Coming soon",onCreateWithAI:()=>rt(we.id,Ue),onAddSection:()=>Se(we.id)}),l.jsxs("header",{className:"mb-6",children:[l.jsxs("div",{className:"text-xs text-muted-foreground mb-1",children:[Oe+1,".0"]}),l.jsx(B3,{as:"h2",value:we.title,onSave:Ce=>de(we.id,Ce),className:"text-2xl font-semibold tracking-tight"}),Re&&l.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[l.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-primary/10 text-primary",children:[l.jsx(lL,{className:"w-3 h-3"}),"Draft available"]}),l.jsxs("span",{children:["Generated ",gY(new Date(Re.createdAt))," ago"]})]})]}),Ue==="references"?l.jsxs("div",{className:"space-y-4",children:[q.length===0?l.jsx("div",{className:"text-sm text-muted-foreground py-8",children:"Cite sources in your chapters — they will appear here automatically as an APA7 reference list."}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"text-xs text-muted-foreground",children:[q.length," source",q.length===1?"":"s"," cited"]}),l.jsx("ol",{className:"space-y-3",children:q.map(Ce=>{const $t=Ce.citation_apa||`${Ce.authors_display||Ce.author_surname||"Unknown"}${Ce.published_year?` (${Ce.published_year})`:""}. ${Ce.title||"Untitled"}.`;return l.jsx("li",{className:"text-sm leading-relaxed text-foreground pl-6 -indent-6",children:$t},Ce.id)})})]}),je.length>0&&l.jsx("div",{className:"mt-8 space-y-10 border-t border-border pt-6",children:je.map((Ce,$t)=>l.jsxs("div",{"data-section-id":Ce.id,ref:Kt=>{J.current[Ce.id]=Kt},className:"scroll-mt-6",children:[Ce.title!==null&&Ce.title!==void 0&&l.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[l.jsxs("span",{className:"text-lg font-semibold text-muted-foreground/70",children:[Oe+1,".",$t+1]}),l.jsx(B3,{as:"h3",value:Ce.title||"",placeholder:"Untitled section",onSave:Kt=>ge(we.id,Ce.id,Kt),className:"text-lg font-semibold flex-1"}),l.jsx(yae,{sectionId:Ce.id})]}),l.jsx(iae,{sectionId:Ce.id,html:Ce.content_rich,plainText:Ce.content,onChange:Kt=>oe(we.id,Ce.id,Kt),placeholder:"Start writing this section...",chapterKind:we.kind??void 0,chapterTitle:we.title??void 0})]},Ce.id))})]}):je.length===0?l.jsx("div",{className:"text-sm text-muted-foreground py-8",children:"No sections yet for this chapter."}):l.jsx("div",{className:"space-y-10",children:je.map((Ce,$t)=>l.jsxs("div",{"data-section-id":Ce.id,ref:Kt=>{J.current[Ce.id]=Kt},className:"scroll-mt-6",children:[Ce.title!==null&&Ce.title!==void 0&&l.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[l.jsxs("span",{className:"text-lg font-semibold text-muted-foreground/70",children:[Oe+1,".",$t+1]}),l.jsx(B3,{as:"h3",value:Ce.title||"",placeholder:"Untitled section",onSave:Kt=>ge(we.id,Ce.id,Kt),className:"text-lg font-semibold flex-1"}),l.jsx(yae,{sectionId:Ce.id})]}),l.jsx(iae,{sectionId:Ce.id,html:Ce.content_rich,plainText:Ce.content,onChange:Kt=>oe(we.id,Ce.id,Kt),placeholder:"Start writing this section...",chapterKind:we.kind??void 0,chapterTitle:we.title??void 0})]},Ce.id))})]},we.id)}),l.jsxs("footer",{className:"mt-12 pt-5 border-t border-border flex items-center justify-between text-xs text-muted-foreground",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("span",{className:"tabular-nums",children:[$," words"]}),l.jsx("span",{className:"flex items-center gap-1.5",children:v?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"w-3 h-3 animate-spin"})," Saving…"]}):l.jsxs(l.Fragment,{children:[l.jsx(Es,{className:"w-3 h-3 text-emerald-500"})," All changes saved"]})})]}),l.jsxs("span",{className:"tabular-nums",children:[x," sources"]})]})]})}),l.jsx("aside",{className:"hidden xl:block",children:l.jsxs("div",{className:"sticky top-[calc(var(--app-header-height)+var(--thesis-toolbar-height)+var(--thesis-sticky-gap))] max-h-[calc(100vh-var(--app-header-height)-var(--thesis-toolbar-height)-var(--thesis-sticky-gap)-20px)] flex flex-col bg-card text-card-foreground rounded-xl border border-border p-3 text-sm",children:[l.jsxs("div",{className:"shrink-0 space-y-4 pr-1 pb-3 border-b border-border",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground mb-3",children:"Thesis Navigator"}),l.jsx("div",{className:"text-sm font-medium leading-snug",children:a.title}),a.due_date&&l.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Due ",new Date(a.due_date).toLocaleDateString()]}),l.jsxs("div",{className:"mt-4",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs mb-1.5",children:[l.jsx("span",{className:"text-muted-foreground",children:"Progress"}),l.jsxs("span",{className:"tabular-nums font-medium",children:[ve,"%"]})]}),l.jsx("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden",children:l.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${ve}%`}})})]})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[l.jsxs("div",{children:[l.jsx("div",{className:"text-muted-foreground",children:"Words"}),l.jsx("div",{className:"mt-0.5 text-sm font-semibold tabular-nums",children:$.toLocaleString()})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-muted-foreground",children:"Sources"}),l.jsx("div",{className:"mt-0.5 text-sm font-semibold tabular-nums",children:x})]}),l.jsxs("div",{children:[l.jsx("div",{className:"text-muted-foreground",children:"Chapters"}),l.jsxs("div",{className:"mt-0.5 text-sm font-semibold tabular-nums",children:[xe," / ",c.length]})]})]})]}),l.jsx("nav",{className:"flex-1 min-h-0 overflow-y-auto pr-1 pt-4 space-y-0.5",children:c.map((we,Oe)=>{const je=we.id===f,Re=d[we.id]??[],Ue=me[we.id]??0,it=I(we.id);return l.jsxs("div",{children:[l.jsxs("button",{ref:Ce=>{Z.current[we.id]=Ce},onClick:()=>Ne(we.id),className:`w-full text-left flex items-center gap-2.5 px-1.5 py-1.5 rounded text-sm transition ${je?"text-primary font-medium bg-primary/5":"text-foreground/80 hover:text-foreground"}`,children:[l.jsx("span",{className:"text-xs tabular-nums w-4 shrink-0 text-muted-foreground/70",children:Oe+1}),l.jsxs("span",{className:"truncate flex-1",children:[we.title,it&&l.jsx("span",{className:"ml-1.5 text-[10px] text-primary font-medium",children:"• Draft"})]}),l.jsx("span",{className:"shrink-0",children:Ee(Ue,je,!!it)})]}),je&&Re.length>0&&l.jsx("div",{className:"ml-7 mt-0.5 mb-1 space-y-0.5 border-l border-border pl-3 animate-in fade-in slide-in-from-top-1 duration-150",children:Re.map((Ce,$t)=>{if(!Ce.title)return null;const Kt=Ce.id===m;return l.jsxs("button",{onClick:()=>qe(Ce.id),className:`w-full text-left text-[13px] py-1 px-1.5 rounded transition truncate ${Kt?"text-primary font-medium":"text-muted-foreground hover:text-foreground"}`,children:[Oe+1,".",$t+1," ",Ce.title]},Ce.id)})})]},we.id)})})]})})]}),l.jsx(HLt,{open:!!Y,onOpenChange:we=>!we&&ie(null),thesisId:a.id,chapterId:Y,chapterTitle:(Ze==null?void 0:Ze.title)??"",chapterKind:Ze?he(Ze):"custom",isGenerating:!!Y&&Q===Y,onGenerate:we=>!Y||!Ze?void 0:he(Ze)==="methodology"?wt(Y,we):tt(Y,we)}),l.jsx(Gr,{open:!!B,onOpenChange:we=>!we&&L(null),children:l.jsxs(zr,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[l.jsxs(Ur,{children:[l.jsxs(Hr,{className:"flex items-center gap-2",children:[l.jsx(lL,{className:"w-4 h-4 text-primary"}),(B==null?void 0:B.kind)==="theory"?"Import Theory Draft":"Import Methodology Draft"]}),l.jsxs(wx,{children:[B==null?void 0:B.title,B&&l.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["· Generated ",gY(new Date(B.createdAt))," ago"]})]})]}),l.jsx("div",{className:"flex-1 overflow-y-auto rounded-md border border-border bg-muted/30 p-4 text-sm leading-relaxed whitespace-pre-wrap",children:B==null?void 0:B.text}),l.jsxs(Th,{className:"gap-2",children:[l.jsx(ye,{variant:"outline",onClick:()=>L(null),disabled:F,children:"Cancel"}),l.jsxs(ye,{onClick:fe,disabled:F,className:"gap-2",children:[F?l.jsx(xt,{className:"w-4 h-4 animate-spin"}):l.jsx(Ga,{className:"w-4 h-4"}),"Import into chapter"]})]})]})}),l.jsx(r4t,{open:C,onOpenChange:A,thesis:a,onUpdated:we=>o(Oe=>Oe&&{...Oe,...we})}),l.jsx(c_e,{open:M,onOpenChange:z,thesisData:P,defaultAuthorName:(r==null?void 0:r.nickname)||"",defaultInstitution:(r==null?void 0:r.university)||"",defaultDegreeProgram:r!=null&&r.degree_type?`${r.degree_type==="bachelor"?"Bachelor":"Master"} Thesis`:"",documents:w})]})})})}function i4t(){return l.jsx(uT,{to:"/topic-explorer/ideas",replace:!0})}function a4t(){const{toast:t}=qn(),e=Or(),{checkStudentPoints:r,studentPoints:n}=Dt(),[s,i]=j.useState(!1),[a,o]=j.useState("EN"),[c,u]=j.useState(""),[d,h]=j.useState(""),[f,p]=j.useState(!1),[m,g]=j.useState([]),[x,y]=j.useState(null),[v,b]=j.useState({title:"",introduction:"",problemStatement:"",objectives:""}),w=async()=>{if(!r()){i(!0);return}p(!0);try{const{data:{session:E}}=await be.auth.getSession();if(!(E!=null&&E.access_token))throw new Error("No authentication token found");const A=await(await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/topic_explorer",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.access_token}`},body:JSON.stringify({action:"suggest",topic:c,context:d,language:a})})).json();if(A.error)throw new Error(A.error);const M=(A.suggestions||[]).map((z,P)=>{var W;return{id:((W=crypto.randomUUID)==null?void 0:W.call(crypto))||String(P),title:z.title,researchQuestions:z.research_questions??z.researchQuestions??[],method:z.method,relevance:z.relevance,sources:Array.isArray(z.sources)?z.sources:[]}});g(M)}catch(E){console.error("Error generating suggestions:",E),t({title:"Generation Error",description:"The suggestions could not be generated.",variant:"destructive"})}finally{p(!1)}},S=async E=>{y(E);try{const{data:{session:C}}=await be.auth.getSession();if(!(C!=null&&C.access_token))throw new Error("No authentication token found");const A={action:"structure",selection:E,language:a,original_topic:c,original_context:d,save:!0},z=await(await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/topic_explorer",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${C.access_token}`},body:JSON.stringify(A)})).json();if(z.error)throw new Error(z.error);const P=z.structure||z;b({title:P.title||E.title,introduction:P.introduction||"",problemStatement:P.problem||"",objectives:P.objectives||""}),z.summary_id&&t({title:"Saved",description:"Saved to My Library under My Topic Explorations."})}catch(C){console.error("Error generating structure:",C),t({title:"Structure Error",description:"The structure could not be generated.",variant:"destructive"})}},k=E=>{navigator.clipboard.writeText(E).then(()=>{t({title:"Copied!",description:"Text has been copied to clipboard."})})};return l.jsxs(gr,{showSidebar:!0,pageTitle:"Topic Ideas",children:[l.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Topic Ideas"}),l.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate structured topic suggestions for your research"})]}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(rm,{className:"h-5 w-5 text-primary"}),"Generate Topic Suggestions"]}),l.jsx(Un,{children:"Enter your basic idea and receive structured suggestions"})]}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Working Title / Topic Idea"}),l.jsx(Be,{placeholder:"e.g., AI in Education",value:c,onChange:E=>u(E.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Language"}),l.jsxs(f1,{type:"single",value:a,onValueChange:E=>E&&o(E),children:[l.jsx(wc,{value:"DE",children:"DE"}),l.jsx(wc,{value:"EN",children:"EN"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Description / Context"}),l.jsx(ir,{placeholder:"Describe program, scope, methodology, context...",value:d,onChange:E=>h(E.target.value),rows:3})]}),l.jsx(ye,{onClick:w,disabled:!c.trim()||f,className:"w-full",children:f?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating Suggestions..."]}):"Generate Suggestions"})]})]}),m.length>0&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Topic Suggestions"}),l.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:m.map(E=>l.jsxs(ze,{className:"hover:border-primary/50 transition-colors",children:[l.jsx(et,{children:l.jsx(at,{className:"text-lg",children:E.title})}),l.jsxs(Ge,{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-sm text-foreground mb-1",children:"Research Questions:"}),l.jsx("ul",{className:"text-sm text-muted-foreground space-y-1",children:(E.researchQuestions||[]).map((C,A)=>l.jsxs("li",{children:["• ",C]},A))})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-sm text-foreground mb-1",children:"Method:"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:E.method})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-sm text-foreground mb-1",children:"Relevance:"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:E.relevance})]}),l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium text-sm text-foreground mb-1",children:"Initial Sources:"}),l.jsx("div",{className:"space-y-1",children:(E.sources||[]).map((C,A)=>l.jsxs("div",{className:"text-xs text-muted-foreground",children:[l.jsx("span",{className:"font-medium",children:C.title}),C.doi&&l.jsxs("span",{className:"block",children:["DOI: ",C.doi]}),C.isbn&&l.jsxs("span",{className:"block",children:["ISBN: ",C.isbn]})]},A))})]}),l.jsxs("div",{className:"flex gap-2 pt-2",children:[l.jsx(ye,{size:"sm",onClick:()=>S(E),className:"flex-1",children:"Select"}),l.jsx(ye,{size:"sm",variant:"outline",onClick:()=>k(JSON.stringify(E,null,2)),children:l.jsx(Tn,{className:"h-4 w-4"})})]})]})]},E.id))})]}),x&&l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(ps,{className:"h-5 w-5 text-primary"}),"Basic Structure"]}),l.jsx(Un,{children:"Your topic idea has been saved to My Library under My Topic Explorations."})]}),l.jsx(Ge,{children:l.jsxs("div",{className:"space-y-6",children:[l.jsxs(wh,{children:[l.jsx(_c,{className:"h-4 w-4"}),l.jsx(B9,{children:"Saved successfully"}),l.jsxs(Sh,{className:"flex items-center justify-between",children:[l.jsx("span",{children:"Your topic idea is available in My Library. You can continue by creating an outline."}),l.jsxs(ye,{size:"sm",variant:"outline",className:"ml-4 shrink-0",onClick:()=>e("/topic-explorer/outline"),children:["Go to Outline Generator",l.jsx(eh,{className:"h-4 w-4 ml-1"})]})]})]}),l.jsx("div",{className:"bg-muted/30 p-6 rounded-lg",children:l.jsxs("div",{className:"space-y-4 text-foreground",children:[l.jsx("div",{children:l.jsx("h2",{className:"text-xl font-bold mb-2",children:v.title})}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Introduction:"}),l.jsx("p",{className:"whitespace-pre-wrap mb-4",children:v.introduction})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Problem Statement:"}),l.jsx("p",{className:"whitespace-pre-wrap mb-4",children:v.problemStatement})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Objectives:"}),l.jsx("p",{className:"whitespace-pre-wrap",children:v.objectives})]}),(x==null?void 0:x.researchQuestions)&&x.researchQuestions.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Research Questions:"}),l.jsx("ul",{className:"space-y-1",children:x.researchQuestions.map((E,C)=>l.jsxs("li",{className:"whitespace-pre-wrap",children:["• ",E]},C))})]}),(x==null?void 0:x.method)&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Methodology:"}),l.jsx("p",{className:"whitespace-pre-wrap",children:x.method})]}),(x==null?void 0:x.sources)&&x.sources.length>0&&l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Literature Tips:"}),l.jsx("ol",{className:"list-decimal list-inside space-y-2",children:x.sources.map((E,C)=>l.jsxs("li",{className:"text-sm",children:[l.jsx("span",{children:E.title}),E.doi&&l.jsxs("span",{className:"block text-muted-foreground ml-5",children:["DOI: ",E.doi]}),E.isbn&&l.jsxs("span",{className:"block text-muted-foreground ml-5",children:["ISBN: ",E.isbn]})]},C))})]})]})}),l.jsx("div",{className:"flex justify-end",children:l.jsxs(ye,{variant:"outline",onClick:()=>{let E=`${v.title}
Introduction:
${v.introduction}
Problem Statement:
${v.problemStatement}
Objectives:
${v.objectives}`;x!=null&&x.researchQuestions&&x.researchQuestions.length>0&&(E+=`
Research Questions:
${x.researchQuestions.map((C,A)=>`${A+1}. ${C}`).join(`
`)}`),x!=null&&x.method&&(E+=`
Methodology:
${x.method}`),x!=null&&x.sources&&x.sources.length>0&&(E+=`
Literature Tips:
${x.sources.map((C,A)=>`${A+1}. ${C.title}${C.doi?` (DOI: ${C.doi})`:""}${C.isbn?` (ISBN: ${C.isbn})`:""}`).join(`
`)}`),k(E)},children:[l.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Copy"]})})]})})]})]}),l.jsx(Bu,{open:s,onClose:()=>i(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]})}const yq=N0e,xq=W9,vq=G9;function o4t(){const{toast:t}=qn(),[e,r]=j.useState("EN"),[n,s]=j.useState(""),[i,a]=j.useState(""),[o,c]=j.useState("bachelor"),[u,d]=j.useState(""),[h,f]=j.useState(!1),[p,m]=j.useState(null),[g,x]=j.useState(""),[y,v]=j.useState(""),[b,w]=j.useState(""),[S,k]=j.useState(""),[E,C]=j.useState(!1),[A,M]=j.useState([]),[z,P]=j.useState(""),[W,N]=j.useState(!0);j.useEffect(()=>{U()},[]);const U=async()=>{try{const{data:{session:H}}=await be.auth.getSession();if(!H)return;const{data:B,error:L}=await be.from("topic_explorations").select("id, title, research_questions, introduction, problem_statement, objectives, method, created_at").eq("user_id",H.user.id).eq("feature_type","topic_ideas").order("created_at",{ascending:!1});if(L)throw L;M(B||[])}catch(H){console.error("Error loading explorations:",H)}finally{N(!1)}},K=()=>{if(!z)return;const H=A.find(B=>B.id===z);if(H){if(s(H.title||""),H.research_questions){const B=Array.isArray(H.research_questions)?H.research_questions:[];a(B.join(`
`))}H.introduction&&x(H.introduction),H.problem_statement&&v(H.problem_statement),H.objectives&&w(H.objectives),H.method&&k(H.method),(H.introduction||H.problem_statement||H.objectives||H.method)&&C(!0),t({title:"Imported",description:"Data has been imported"})}},G=async()=>{if(n.trim()){f(!0);try{const{data:{session:H}}=await be.auth.getSession();if(!(H!=null&&H.access_token))throw new Error("No authentication token found");const L=await(await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/topic_research_tools",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${H.access_token}`},body:JSON.stringify({action:"outline",title:n.trim(),research_questions:i.split(`
`).filter(F=>F.trim()),language:e,degree_type:o,target_word_count:u?parseInt(u):void 0,topic_context:{introduction:g.trim()||void 0,problem_statement:y.trim()||void 0,objectives:b.trim()||void 0,methodology:S.trim()||void 0}})})).json();if(L.error)throw new Error(L.error);m(L.outline),t({title:"Outline Generated",description:"Your outline has been saved to My Library under My Topic Explorations."})}catch(H){console.error("Error generating outline:",H),t({title:"Error",description:"The outline could not be generated.",variant:"destructive"})}finally{f(!1)}}},X=()=>{if(!p)return;let H=`${p.title}
`;H+=`TABLE OF CONTENTS
`,p.chapters.forEach(B=>{H+=`${B.number} ${B.title}`,B.estimated_pages&&(H+=` (~${B.estimated_pages} pages)`),H+=`
`,B.subchapters&&B.subchapters.forEach(L=>{H+=` ${L.number} ${L.title}`,L.estimated_pages&&(H+=` (~${L.estimated_pages} pages)`),H+=`
`})}),H+=`
Estimated Total Pages: ~${p.total_estimated_pages}`,p.notes&&(H+=`
Notes:
${p.notes}`),navigator.clipboard.writeText(H),t({title:"Copied!",description:"Outline has been copied to clipboard."})};return l.jsx(gr,{showSidebar:!0,pageTitle:"Outline Generator",children:l.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Outline Generator"}),l.jsx("p",{className:"text-muted-foreground mt-2",children:"Create a detailed outline for your scientific work"})]}),l.jsx(ze,{children:l.jsx(Ge,{className:"pt-6",children:l.jsxs("div",{className:"space-y-3",children:[l.jsx(_e,{className:"text-sm font-semibold",children:"Take from Topic Explorer"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(dt,{value:z,onValueChange:P,children:[l.jsx(lt,{className:"flex-1",children:l.jsx(ht,{placeholder:W?"Loading...":"Select a topic..."})}),l.jsx(ct,{children:A.map(H=>l.jsx(De,{value:H.id,children:H.title},H.id))})]}),l.jsx(ye,{onClick:K,disabled:!z,variant:"secondary",children:"Import Topic"})]})]})})}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(Br,{className:"h-5 w-5 text-primary"}),"Generate Outline"]}),l.jsx(Un,{children:"Create a detailed outline for your scientific work"})]}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Title / Topic *"}),l.jsx(Be,{placeholder:"e.g., AI in Education",value:n,onChange:H=>s(H.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Language"}),l.jsxs(f1,{type:"single",value:e,onValueChange:H=>H&&r(H),children:[l.jsx(wc,{value:"DE",children:"DE"}),l.jsx(wc,{value:"EN",children:"EN"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Research Questions (optional)"}),l.jsx(ir,{placeholder:"One question per line...",value:i,onChange:H=>a(H.target.value),rows:3})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Degree Type"}),l.jsxs(dt,{value:o,onValueChange:c,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"bachelor",children:"Bachelor"}),l.jsx(De,{value:"master",children:"Master"}),l.jsx(De,{value:"phd",children:"PhD / Dissertation"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Target Word Count (optional)"}),l.jsx(Zs,{children:l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(Bp,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"})}),l.jsxs(Qt,{side:"top",className:"max-w-xs text-xs space-y-1",children:[l.jsx("p",{className:"font-semibold",children:"Approximate page equivalents:"}),l.jsx("p",{children:"~3,000 words ≈ 10–12 pages"}),l.jsx("p",{children:"~5,000 words ≈ 18–20 pages"}),l.jsx("p",{children:"~10,000 words ≈ 35–40 pages"}),l.jsx("p",{children:"~15,000 words ≈ 55–60 pages"}),l.jsx("p",{className:"text-muted-foreground pt-1",children:"Based on ~275 words/page (A4, 12pt, 1.5 spacing)"})]})]})})]}),l.jsx(Be,{type:"number",placeholder:"e.g., 15000",value:u,onChange:H=>d(H.target.value)})]})]}),l.jsxs(yq,{open:E,onOpenChange:C,children:[l.jsx(xq,{asChild:!0,children:l.jsxs(ye,{variant:"ghost",className:"w-full justify-between p-3 h-auto border border-dashed border-border hover:bg-muted/50",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Qs,{className:"h-4 w-4 text-primary"}),l.jsx("span",{className:"text-sm font-medium",children:e==="DE"?"Erweiterter Kontext (optional)":"Advanced Context (optional)"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:e==="DE"?"Für bessere Ergebnisse":"For better results"}),l.jsx(Eh,{className:`h-4 w-4 transition-transform ${E?"rotate-180":""}`})]})]})}),l.jsxs(vq,{className:"pt-4 space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Einleitung":"Introduction"}),l.jsx(ir,{placeholder:e==="DE"?"Kurze Einführung in das Thema...":"Brief introduction to the topic...",value:g,onChange:H=>x(H.target.value),rows:3})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Problemstellung":"Problem Statement"}),l.jsx(ir,{placeholder:e==="DE"?"Das Forschungsproblem...":"The research problem...",value:y,onChange:H=>v(H.target.value),rows:3})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Ziele (ein Ziel pro Zeile)":"Objectives (one per line)"}),l.jsx(ir,{placeholder:e==="DE"?`Ziel 1
Ziel 2
Ziel 3`:`Objective 1
Objective 2
Objective 3`,value:b,onChange:H=>w(H.target.value),rows:3})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Methodischer Ansatz":"Methodology"}),l.jsx(ir,{placeholder:e==="DE"?"z.B. RCT, Qualitative Interviews, Systematic Review...":"e.g., RCT, Qualitative Interviews, Systematic Review...",value:S,onChange:H=>k(H.target.value),rows:2})]})]})]}),l.jsx(ye,{onClick:G,disabled:!n.trim()||h,className:"w-full",children:h?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating Outline..."]}):"Generate Outline"})]})]}),p&&l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(at,{children:p.title}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:X,children:[l.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Copy"]})]}),l.jsxs(Un,{children:["Estimated pages: ~",p.total_estimated_pages]})]}),l.jsxs(Ge,{children:[l.jsx(Q9,{type:"multiple",className:"w-full",children:p.chapters.map((H,B)=>l.jsxs(VM,{value:`chapter-${B}`,children:[l.jsx(WM,{className:"hover:no-underline",children:l.jsxs("div",{className:"flex items-center gap-3 text-left",children:[l.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:H.number}),l.jsx("span",{className:"font-medium",children:H.title}),H.estimated_pages&&l.jsxs("span",{className:"text-xs text-muted-foreground",children:["(~",H.estimated_pages," p.)"]})]})}),l.jsx(qM,{children:l.jsxs("div",{className:"pl-8 space-y-3",children:[H.description&&l.jsx("p",{className:"text-sm text-muted-foreground",children:H.description}),H.subchapters&&H.subchapters.length>0&&l.jsx("div",{className:"space-y-2",children:H.subchapters.map((L,F)=>l.jsxs("div",{className:"flex items-start gap-3 py-1",children:[l.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:L.number}),l.jsxs("div",{children:[l.jsx("span",{className:"text-sm font-medium",children:L.title}),L.estimated_pages&&l.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:["(~",L.estimated_pages," p.)"]}),L.description&&l.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:L.description})]})]},F))})]})})]},B))}),p.notes&&l.jsxs("div",{className:"mt-4 p-4 bg-muted/50 rounded-lg",children:[l.jsx("h4",{className:"font-medium text-sm mb-2",children:"Notes"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:p.notes})]})]})]})]})})}function l4t(){const{toast:t}=qn(),[e,r]=j.useState("EN"),[n,s]=j.useState(""),[i,a]=j.useState(""),[o,c]=j.useState(""),[u,d]=j.useState(!1),[h,f]=j.useState(null),[p,m]=j.useState(""),[g,x]=j.useState(""),[y,v]=j.useState(""),[b,w]=j.useState(""),[S,k]=j.useState(!1),[E,C]=j.useState(""),[A,M]=j.useState(!1),[z,P]=j.useState([]),[W,N]=j.useState(new Set),[U,K]=j.useState([]),[G,X]=j.useState(""),[H,B]=j.useState(!0);j.useEffect(()=>{L()},[]);const L=async()=>{try{const{data:{session:R}}=await be.auth.getSession();if(!R)return;const{data:J,error:Z}=await be.from("topic_explorations").select("id, title, research_questions, outline_json, introduction, problem_statement, objectives, method, created_at").eq("user_id",R.user.id).eq("feature_type","topic_ideas").order("created_at",{ascending:!1});if(Z)throw Z;K(J||[])}catch(R){console.error("Error loading explorations:",R)}finally{B(!1)}},F=()=>{if(!G)return;const R=U.find(J=>J.id===G);if(R){if(s(R.title||""),R.research_questions){const J=Array.isArray(R.research_questions)?R.research_questions:[];a(J.join(`
`))}if(R.outline_json){const J=R.outline_json;if(J.chapters){const Z=J.chapters.map(ee=>`${ee.number} ${ee.title}`).join(`
`);c(Z)}}R.introduction&&m(R.introduction),R.problem_statement&&x(R.problem_statement),R.objectives&&v(R.objectives),R.method&&w(R.method),(R.introduction||R.problem_statement||R.objectives||R.method)&&k(!0),t({title:"Imported",description:"Data has been imported"})}},V=async()=>{var R,J;if(n.trim()){d(!0);try{const{data:{session:Z}}=await be.auth.getSession();if(!(Z!=null&&Z.access_token))throw new Error("No authentication token found");const re=await(await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/topic_research_tools",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Z.access_token}`},body:JSON.stringify({action:"keywords",title:n.trim(),research_questions:i.split(`
`).filter(he=>he.trim()),outline:o.trim()||void 0,language:e,topic_context:{introduction:p.trim()||void 0,problem_statement:g.trim()||void 0,objectives:y.trim()||void 0,methodology:b.trim()||void 0}})})).json();if(re.error)throw new Error(re.error);f(re.keywords),((J=(R=re.keywords)==null?void 0:R.keyword_combinations)==null?void 0:J.length)>0&&C(re.keywords.keyword_combinations[0].combination),t({title:"Keywords Generated",description:"The literature keywords have been successfully generated."})}catch(Z){console.error("Error generating keywords:",Z),t({title:"Error",description:"The keywords could not be generated.",variant:"destructive"})}finally{d(!1)}}},Y=R=>{navigator.clipboard.writeText(R),t({title:"Copied!",description:"Text has been copied to clipboard."})},ie=()=>{if(!h)return;const R=h.keyword_combinations||[],J=h.known_authors||[],Z=h.known_works||[],ee=h.database_suggestions||[];let re=`LITERATURE KEYWORDS
`;re+=`Search Combinations:
`,R.forEach(he=>{re+=`- ${he.combination} (${he.purpose})
`}),re+=`
Known Authors:
`,J.forEach(he=>{re+=`- ${he.name}: ${he.relevance}
`}),re+=`
Known Works:
`,Z.forEach(he=>{re+=`- ${he.title}`,he.author&&(re+=` (${he.author}`),he.year&&(re+=`, ${he.year}`),he.author&&(re+=")"),re+=`
`}),re+=`
Database Suggestions:
`,re+=ee.join(", ")+`
`,re+=`Search Tips:
`,re+=h.search_tips||"",Y(re)},Q=async()=>{if(E.trim()){M(!0),P([]);try{const{data:{session:R}}=await be.auth.getSession();if(!(R!=null&&R.access_token))throw new Error("No authentication token found");const Z=await(await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/topic_research_tools",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${R.access_token}`},body:JSON.stringify({action:"search_literature",keywords:E.trim()})})).json();if(Z.error)throw new Error(Z.error);P(Z.results||[]),(Z.results||[]).length===0&&t({title:"No results found",description:"Try different keywords."})}catch(R){console.error("Error searching literature:",R),t({title:"Error",description:"Literature search failed.",variant:"destructive"})}finally{M(!1)}}},D=R=>{N(J=>{const Z=new Set(J);return Z.has(R)?Z.delete(R):Z.add(R),Z})};return l.jsx(gr,{showSidebar:!0,pageTitle:"Literature Keywords",children:l.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Literature Keywords"}),l.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate search terms and find relevant literature for your topic"})]}),l.jsx(ze,{children:l.jsx(Ge,{className:"pt-6",children:l.jsxs("div",{className:"space-y-3",children:[l.jsx(_e,{className:"text-sm font-semibold",children:"Take from Topic Explorer"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(dt,{value:G,onValueChange:X,children:[l.jsx(lt,{className:"flex-1",children:l.jsx(ht,{placeholder:H?"Loading...":"Select a topic..."})}),l.jsx(ct,{children:U.map(R=>l.jsx(De,{value:R.id,children:R.title},R.id))})]}),l.jsx(ye,{onClick:F,disabled:!G,variant:"secondary",children:"Import Topic"})]})]})})}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(yl,{className:"h-5 w-5 text-primary"}),"Find Literature Keywords"]}),l.jsx(Un,{children:"Generate search terms and find relevant literature for your topic"})]}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Title / Topic *"}),l.jsx(Be,{placeholder:"e.g., AI in Education",value:n,onChange:R=>s(R.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Language"}),l.jsxs(f1,{type:"single",value:e,onValueChange:R=>R&&r(R),children:[l.jsx(wc,{value:"DE",children:"DE"}),l.jsx(wc,{value:"EN",children:"EN"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Research Questions (optional)"}),l.jsx(ir,{placeholder:"One question per line...",value:i,onChange:R=>a(R.target.value),rows:3})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:"Outline (optional)"}),l.jsx(ir,{placeholder:"Chapter structure or topic overview...",value:o,onChange:R=>c(R.target.value),rows:4})]}),l.jsxs(yq,{open:S,onOpenChange:k,children:[l.jsx(xq,{asChild:!0,children:l.jsxs(ye,{variant:"ghost",className:"w-full justify-between p-3 h-auto border border-dashed border-border hover:bg-muted/50",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Qs,{className:"h-4 w-4 text-primary"}),l.jsx("span",{className:"text-sm font-medium",children:e==="DE"?"Erweiterter Kontext (optional)":"Advanced Context (optional)"})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:e==="DE"?"Für bessere Ergebnisse":"For better results"}),l.jsx(Eh,{className:`h-4 w-4 transition-transform ${S?"rotate-180":""}`})]})]})}),l.jsxs(vq,{className:"pt-4 space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Einleitung":"Introduction"}),l.jsx(ir,{placeholder:e==="DE"?"Kurze Einführung in das Thema...":"Brief introduction to the topic...",value:p,onChange:R=>m(R.target.value),rows:3})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Problemstellung":"Problem Statement"}),l.jsx(ir,{placeholder:e==="DE"?"Das Forschungsproblem...":"The research problem...",value:g,onChange:R=>x(R.target.value),rows:3})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Ziele (ein Ziel pro Zeile)":"Objectives (one per line)"}),l.jsx(ir,{placeholder:e==="DE"?`Ziel 1
Ziel 2
Ziel 3`:`Objective 1
Objective 2
Objective 3`,value:y,onChange:R=>v(R.target.value),rows:3})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Methodischer Ansatz":"Methodology"}),l.jsx(ir,{placeholder:e==="DE"?"z.B. RCT, Qualitative Interviews, Systematic Review...":"e.g., RCT, Qualitative Interviews, Systematic Review...",value:b,onChange:R=>w(R.target.value),rows:2})]})]})]}),l.jsx(ye,{onClick:V,disabled:!n.trim()||u,className:"w-full",children:u?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating Keywords..."]}):"Generate Keywords"})]})]}),h&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-lg font-semibold",children:"Results"}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:ie,children:[l.jsx(Tn,{className:"h-4 w-4 mr-2"}),"Copy All"]})]}),l.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[l.jsxs(ze,{children:[l.jsx(et,{className:"pb-3",children:l.jsxs(at,{className:"text-base flex items-center gap-2",children:[l.jsx(rm,{className:"h-4 w-4"}),"Search Combinations"]})}),l.jsx(Ge,{children:l.jsx("div",{className:"space-y-2",children:(h.keyword_combinations||[]).map((R,J)=>l.jsxs("div",{className:"flex items-start justify-between gap-2 p-2 bg-muted/50 rounded-md cursor-pointer hover:bg-muted",onClick:()=>Y(R.combination),children:[l.jsxs("div",{children:[l.jsx("code",{className:"text-sm font-medium",children:R.combination}),l.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:R.purpose})]}),l.jsx(kt,{variant:"outline",className:"text-xs shrink-0",children:R.language})]},J))})})]}),l.jsxs(ze,{children:[l.jsx(et,{className:"pb-3",children:l.jsxs(at,{className:"text-base flex items-center gap-2",children:[l.jsx($w,{className:"h-4 w-4"}),"Known Authors"]})}),l.jsx(Ge,{children:l.jsx("div",{className:"space-y-2",children:(h.known_authors||[]).map((R,J)=>l.jsxs("div",{className:"p-2 bg-muted/50 rounded-md cursor-pointer hover:bg-muted",onClick:()=>Y(R.name),children:[l.jsx("span",{className:"font-medium text-sm",children:R.name}),l.jsx("p",{className:"text-xs text-muted-foreground",children:R.relevance})]},J))})})]}),l.jsxs(ze,{children:[l.jsx(et,{className:"pb-3",children:l.jsxs(at,{className:"text-base flex items-center gap-2",children:[l.jsx(ps,{className:"h-4 w-4"}),"Known Works"]})}),l.jsx(Ge,{children:l.jsx("div",{className:"space-y-2",children:(h.known_works||[]).map((R,J)=>l.jsxs("div",{className:"p-2 bg-muted/50 rounded-md cursor-pointer hover:bg-muted",onClick:()=>Y(R.title),children:[l.jsx("span",{className:"font-medium text-sm",children:R.title}),(R.author||R.year)&&l.jsxs("p",{className:"text-xs text-muted-foreground",children:[R.author,R.year&&` (${R.year})`]}),R.relevance&&l.jsx("p",{className:"text-xs text-muted-foreground italic mt-1",children:R.relevance})]},J))})})]}),l.jsxs(ze,{children:[l.jsx(et,{className:"pb-3",children:l.jsx(at,{className:"text-base",children:"Recommended Databases"})}),l.jsx(Ge,{children:l.jsx("div",{className:"flex flex-wrap gap-2",children:(h.database_suggestions||[]).map((R,J)=>l.jsx(kt,{variant:"secondary",children:R},J))})})]})]}),h.search_tips&&l.jsxs(ze,{children:[l.jsx(et,{className:"pb-3",children:l.jsx(at,{className:"text-base",children:"Search Tips"})}),l.jsx(Ge,{children:l.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:h.search_tips})})]})]}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(ps,{className:"h-5 w-5 text-primary"}),"Search Real Literature"]}),l.jsx(Un,{children:"Search CrossRef and OpenAlex for real academic papers"})]}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Be,{placeholder:"e.g., ITIL service transition challenges",value:E,onChange:R=>C(R.target.value),onKeyDown:R=>R.key==="Enter"&&Q(),className:"flex-1"}),l.jsx(ye,{onClick:Q,disabled:!E.trim()||A,children:A?l.jsx(xt,{className:"h-4 w-4 animate-spin"}):l.jsx(yl,{className:"h-4 w-4"})})]}),z.length>0&&l.jsxs("div",{className:"space-y-3",children:[l.jsxs("p",{className:"text-sm text-muted-foreground",children:[z.length," results found"]}),z.map((R,J)=>{var Z;return l.jsxs("div",{className:"border border-border rounded-lg p-4 space-y-2 hover:bg-muted/30 transition-colors",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsx("h4",{className:"font-medium text-sm leading-snug flex-1",children:R.title}),l.jsxs("div",{className:"flex gap-1 shrink-0 flex-wrap justify-end",children:[R.is_open_access&&l.jsx(kt,{className:"text-xs bg-green-100 text-green-800 border-green-200",children:"Open Access"}),l.jsx(kt,{variant:"outline",className:"text-xs",children:R.source==="crossref"?"CrossRef":"OpenAlex"})]})]}),l.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[((Z=R.authors)==null?void 0:Z.length)>0&&l.jsxs("span",{children:[R.authors.slice(0,3).join(", "),R.authors.length>3?" et al.":""]}),R.year&&l.jsx("span",{children:R.year}),R.journal&&l.jsx("span",{className:"italic",children:R.journal})]}),R.abstract&&l.jsxs("div",{children:[l.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:W.has(J)?R.abstract:R.abstract.substring(0,150)+"..."}),l.jsx("button",{onClick:()=>D(J),className:"text-xs text-primary hover:underline mt-1",children:W.has(J)?"Show less":"Show more"})]}),l.jsxs("div",{className:"flex gap-2 pt-1 flex-wrap",children:[R.doi&&l.jsxs(ye,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>Y(R.doi),children:[l.jsx(Tn,{className:"h-3 w-3 mr-1"}),"Copy DOI"]}),R.url&&l.jsx(ye,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>window.open(R.url,"_blank"),children:"View"})]})]},J)})]})]})]})]})})}var ED="Switch",[c4t,G5t]=gs(ED),[u4t,d4t]=c4t(ED),UNe=j.forwardRef((t,e)=>{const{__scopeSwitch:r,name:n,checked:s,defaultChecked:i,required:a,disabled:o,value:c="on",onCheckedChange:u,form:d,...h}=t,[f,p]=j.useState(null),m=It(e,b=>p(b)),g=j.useRef(!1),x=f?d||!!f.closest("form"):!0,[y,v]=_i({prop:s,defaultProp:i??!1,onChange:u,caller:ED});return l.jsxs(u4t,{scope:r,checked:y,disabled:o,children:[l.jsx(ot.button,{type:"button",role:"switch","aria-checked":y,"aria-required":a,"data-state":qNe(y),"data-disabled":o?"":void 0,disabled:o,value:c,...h,ref:m,onClick:Ke(t.onClick,b=>{v(w=>!w),x&&(g.current=b.isPropagationStopped(),g.current||b.stopPropagation())})}),x&&l.jsx(WNe,{control:f,bubbles:!g.current,name:n,value:c,checked:y,required:a,disabled:o,form:d,style:{transform:"translateX(-100%)"}})]})});UNe.displayName=ED;var HNe="SwitchThumb",VNe=j.forwardRef((t,e)=>{const{__scopeSwitch:r,...n}=t,s=d4t(HNe,r);return l.jsx(ot.span,{"data-state":qNe(s.checked),"data-disabled":s.disabled?"":void 0,...n,ref:e})});VNe.displayName=HNe;var h4t="SwitchBubbleInput",WNe=j.forwardRef(({__scopeSwitch:t,control:e,checked:r,bubbles:n=!0,...s},i)=>{const a=j.useRef(null),o=It(a,i),c=T9(r),u=BH(e);return j.useEffect(()=>{const d=a.current;if(!d)return;const h=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(h,"checked").set;if(c!==r&&p){const m=new Event("click",{bubbles:n});p.call(d,r),d.dispatchEvent(m)}},[c,r,n]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:o,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});WNe.displayName=h4t;function qNe(t){return t?"checked":"unchecked"}var GNe=UNe,f4t=VNe;const yk=j.forwardRef(({className:t,...e},r)=>l.jsx(GNe,{className:Le("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...e,ref:r,children:l.jsx(f4t,{className:Le("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));yk.displayName=GNe.displayName;function p4t(t,e){if(!t.trim())return{pages:[],error:"Please enter page numbers"};const r=new Set,n=t.split(",").map(s=>s.trim()).filter(s=>s.length>0);try{for(const s of n)if(s.includes("-")){const[i,a]=s.split("-").map(o=>parseInt(o.trim()));if(isNaN(i)||isNaN(a)||i<1||a>e||i>a)return{pages:[],error:`Invalid range: ${s}`};for(let o=i;o<=a;o++)r.add(o)}else{const i=parseInt(s);if(isNaN(i)||i<1||i>e)return{pages:[],error:`Invalid page: ${s}`};r.add(i)}return{pages:Array.from(r).sort((s,i)=>s-i)}}catch{return{pages:[],error:"Invalid page format"}}}function m4t(){const{user:t,loading:e,checkStudentPoints:r,studentPoints:n}=Dt(),[s,i]=j.useState(!1),a=Or(),[o,c]=j.useState([]),[u,d]=j.useState(!0),[h,f]=j.useState(null),[p,m]=j.useState(""),[g,x]=j.useState([]),[y,v]=j.useState(""),[b,w]=j.useState(""),[S,k]=j.useState(!0),[E,C]=j.useState(!0),[A,M]=j.useState(!1),[z,P]=j.useState(null);j.useEffect(()=>{!t&&!e&&a("/login")},[t,e,a]),j.useEffect(()=>{t&&W()},[t]),j.useEffect(()=>{if(h){const X=p4t(p,h.page_count||0);if(x(X.pages||[]),v(X.error||""),X.pages&&X.pages.length>0){const H=N(X.pages);w(`${h.title} – Excerpt (${H})`)}}},[p,h]);const W=async()=>{if(t){d(!0);try{const{data:X,error:H}=await be.from("documents").select("id, title, page_count, storage_path").eq("user_id",t.id).not("page_count","is",null).order("created_at",{ascending:!1});if(H){console.error("Error loading documents:",H),er({title:"Error",description:"Documents could not be loaded",variant:"destructive"});return}c(X||[])}catch(X){console.error("Error in loadDocuments:",X)}finally{d(!1)}}},N=X=>{if(X.length===0)return"";const H=[];let B=X[0],L=X[0];for(let F=1;F<X.length;F++)X[F]===L+1?L=X[F]:(B===L?H.push(B.toString()):H.push(`${B}-${L}`),B=L=X[F]);return B===L?H.push(B.toString()):H.push(`${B}-${L}`),H.join(", ")},U=async()=>{if(!r()){i(!0);return}if(!(!h||g.length===0||y)){M(!0),er({title:"Extract is being generated...",description:"Please wait a moment"});try{const{data:X,error:H}=await be.functions.invoke("pdf_slicer",{body:{document_id:h.id,pages:g,new_title:b,keep_citation:S,copy_metadata:E}});if(H)throw H;if(X.success)er({title:"Successfully created",description:"Your PDF extract has been successfully created"}),P(X.document),await W();else throw new Error(X.error||"Uknown Error")}catch(X){console.error("Error creating excerpt:",X),er({title:"Fehler",description:X.message||"Excerpt could not be created",variant:"destructive"})}finally{M(!1)}}},K=()=>{f(null),m(""),x([]),v(""),w(""),k(!0),C(!0),P(null)},G=()=>{m(""),x([]),v(""),w(""),P(null)};return e||u?l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?l.jsxs(gr,{showSidebar:!0,children:[l.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(Lce,{className:"h-8 w-8 text-primary"}),l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"Page Selector"}),l.jsx("p",{className:"text-muted-foreground",children:"Create extracts from your PDF documents"})]})]}),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Source"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"source-document",children:"Quelldokument"}),l.jsxs(dt,{value:(h==null?void 0:h.id)||"",onValueChange:X=>{const H=o.find(B=>B.id===X)||null;f(H),m(""),x([]),v("")},disabled:u||o.length===0,children:[l.jsx(lt,{id:"source-document",children:l.jsx(ht,{placeholder:"Select document..."})}),l.jsx(ct,{children:o.map(X=>l.jsxs(De,{value:X.id,children:[X.title," (",X.page_count||0," pages)"]},X.id))})]})]}),h&&l.jsxs("div",{className:"text-sm text-muted-foreground",children:["pages: ",h.page_count||0," | Title: ",h.title]}),h&&l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"pages",children:"pages"}),l.jsx(Be,{id:"pages",value:p,onChange:X=>m(X.target.value),placeholder:"e.G. 1-3, 5, 9-11"}),l.jsxs("div",{className:"mt-2 text-sm text-muted-foreground",children:["Examples: 3-6, 8, 10-12 → ",g.length>0&&`${g.length} pages selected`]}),y&&l.jsx("div",{className:"mt-2 text-sm text-destructive",children:y})]})]})]}),h&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Goal & Optionsn"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"new-title",children:"New Title"}),l.jsx(Be,{id:"new-title",value:b,onChange:X=>w(X.target.value)})]}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(yk,{id:"keep-citation",checked:S,onCheckedChange:k}),l.jsx(_e,{htmlFor:"keep-citation",children:"Retain APA citation"})]}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(yk,{id:"copy-metadata",checked:E,onCheckedChange:C}),l.jsx(_e,{htmlFor:"copy-metadata",children:"Copy DOI/ISBN"})]})]})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx(ye,{onClick:U,disabled:!h||g.length===0||!!y||A,className:"flex-1",children:A?"Being created...":"Create extract"}),l.jsxs(ye,{variant:"outline",onClick:K,children:[l.jsx(Y2e,{className:"h-4 w-4 mr-2"}),"Reset"]})]}),z&&l.jsxs(ze,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/50",children:[l.jsx(et,{children:l.jsxs(at,{className:"text-green-800 dark:text-green-200",children:[l.jsx(Br,{className:"h-5 w-5 inline mr-2"}),"Auszug erfolgreich erstellt"]})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("div",{className:"font-medium",children:z.title}),l.jsxs("div",{className:"text-sm text-muted-foreground",children:[z.page_count||0," pages"]}),l.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Saved at: ",z.storage_path]})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsxs(ye,{onClick:()=>a("/documents"),children:[l.jsx($p,{className:"h-4 w-4 mr-2"}),"Go to the library"]}),l.jsx(ye,{variant:"outline",onClick:G,children:"Create more"})]})]})]})]}),l.jsx(Bu,{open:s,onClose:()=>i(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]}):null}function g4t(){const t=Or(),[e]=oE(),{toast:r}=qn(),{user:n,loading:s}=Dt(),[i,a]=j.useState([]),[o,c]=j.useState(!1),[u,d]=j.useState(""),[h,f]=j.useState(!0),[p,m]=j.useState(!1),[g,x]=j.useState(!1),[y,v]=j.useState(null),[b,w]=j.useState(""),S=e.get("document");j.useEffect(()=>{if(!s&&!n){t("/login");return}n&&k()},[n,s,t]),j.useEffect(()=>{S&&i.length>0&&!u&&i.some(M=>M.id===S)&&d(S)},[S,i,u]);const k=async()=>{c(!0);try{const{data:A,error:M}=await be.from("documents").select("id, title, page_count, storage_path, created_at").order("created_at",{ascending:!1});if(M)throw M;a(A||[])}catch(A){console.error("Error loading documents:",A),r({title:"Error",description:"Failed to load documents.",variant:"destructive"})}finally{c(!1)}},E=async()=>{if(u){x(!0),w(""),v(null);try{const{data:{session:A}}=await be.auth.getSession();if(!A)throw new Error("AUTH");const M=await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/pdf_extract",{method:"POST",headers:{Authorization:`Bearer ${A.access_token}`,"Content-Type":"application/json"},body:JSON.stringify({document_id:u,overwrite:h,also_block:p})}),z=await M.json();if(!M.ok||z.error)throw new Error(z.error||"UNKNOWN");console.log("Extract result:",z),v(z),r({title:"Sucessfully extracted",description:`${z.inserted_pages} Seiten extrahiert. page_count = ${z.page_count}.`}),await k()}catch(A){console.error("Extract error:",A);const M=A.message||"UNKNOWN";w(M);let z="Uknown Error.";switch(M){case"AUTH":z="Please Login.";break;case"DOC_NOT_FOUND":z="Document not found or permission denied.";break;case"STORAGE":z="Error accessing the file.";break;case"PDF_PARSE":z="PDF could not be processed.";break;case"DB_WRITE":z="Error saving to the database.";break}r({title:"Error",description:z,variant:"destructive"})}finally{x(!1)}}},C=i.find(A=>A.id===u);return s?l.jsx(gr,{showSidebar:!0,children:l.jsx("div",{className:"flex items-center justify-center h-64",children:l.jsx(xt,{className:"h-8 w-8 animate-spin"})})}):l.jsx(gr,{showSidebar:!0,children:l.jsxs("div",{className:"container mx-auto py-8 space-y-6",children:[l.jsxs("div",{className:"mb-6",children:[l.jsx("h1",{className:"text-3xl font-bold",children:"PDF-Extract"}),l.jsx("p",{className:"text-muted-foreground",children:"Extract page-by-page text from previously uploaded documents"})]}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsx(at,{children:"Choose Document"}),l.jsx(Un,{children:"Extract page-by-page text from previously uploaded documents"})]}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs(dt,{value:u,onValueChange:d,disabled:o||g,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Choose document..."})}),l.jsx(ct,{children:i.map(A=>l.jsxs(De,{value:A.id,children:[A.title," (",A.page_count?`${A.page_count} Pages`:"unbekannt",")"]},A.id))})]}),C&&l.jsx("div",{className:"text-sm text-muted-foreground",children:C.page_count?"Extracted pages already exist.":"No page text has been extracted yet."}),o&&l.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[l.jsx(xt,{className:"h-4 w-4 animate-spin"}),"Loading Document..."]})]})]}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsx(at,{children:"Optionen"}),l.jsx(Un,{children:"Configure the extraction settings"})]}),l.jsxs(Ge,{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(yk,{id:"overwrite",checked:h,onCheckedChange:f,disabled:g}),l.jsx(_e,{htmlFor:"overwrite",children:"Overwrite existing page text"})]}),l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(yk,{id:"alsoBlock",checked:p,onCheckedChange:m,disabled:g}),l.jsx(_e,{htmlFor:"alsoBlock",children:"Additionally, save the entire Markdown block"})]}),l.jsx("div",{className:"text-sm text-muted-foreground",children:p?"Additionally, a block containing all pages is stored as Markdown.":"Only pages are stored in the `pages` directory, and `page_count` is updated."})]})]}),l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsx(at,{children:"Execution and result"}),l.jsx(Un,{children:"Start the text extraction and view the results."})]}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs(ye,{onClick:E,disabled:!u||g,className:"w-full",size:"lg",children:[g&&l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),g?"Extract...":"Extract"]}),y&&l.jsxs("div",{className:"p-4 bg-green-50 dark:bg-green-950 rounded-lg border border-green-200 dark:border-green-800",children:[l.jsx("h4",{className:"font-semibold text-green-800 dark:text-green-200 mb-2",children:"Extraction successful"}),l.jsxs("div",{className:"space-y-1 text-sm text-green-700 dark:text-green-300",children:[l.jsxs("div",{children:["New page_count: ",l.jsx("strong",{children:y.page_count})]}),l.jsxs("div",{children:["Overwritten: ",l.jsx("strong",{children:y.overwrote?"Yes":"No"})]}),y.block_id&&l.jsxs("div",{children:["Block-ID: ",l.jsx("strong",{children:y.block_id})]})]})]}),b&&l.jsxs("div",{className:"p-4 bg-red-50 dark:bg-red-950 rounded-lg border border-red-200 dark:border-red-800",children:[l.jsx("h4",{className:"font-semibold text-red-800 dark:text-red-200 mb-2",children:"Fehler aufgetreten"}),l.jsxs("div",{className:"text-sm text-red-700 dark:text-red-300",children:["Error Code: ",b]})]}),l.jsxs(ye,{variant:"outline",onClick:k,disabled:o||g,className:"w-full",children:[o&&l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),l.jsx(Dce,{className:"mr-2 h-4 w-4"}),"Update document list"]})]})]})]})})}function y4t(t){var r,n;if(!t)return"GEN";const e=(t.type||((r=t.crossref_data)==null?void 0:r.type)||((n=t.crossref_payload)==null?void 0:n.type)||"").toLowerCase();return e.includes("journal")||e.includes("article")?"JOUR":e.includes("book")?"BOOK":e.includes("conference")||e.includes("proceeding")?"CONF":e.includes("thesis")||e.includes("dissertation")?"THES":"GEN"}function x4t(t){var r,n,s,i,a;const e=(t==null?void 0:t.authors)||((r=t==null?void 0:t.crossref_data)==null?void 0:r.authors)||((n=t==null?void 0:t.crossref_payload)==null?void 0:n.author)||((i=(s=t==null?void 0:t.crossref_data)==null?void 0:s.crossref_metadata)==null?void 0:i.author)||((a=t==null?void 0:t.google_books_data)==null?void 0:a.authors)||[];return Array.isArray(e)?e.map(o=>typeof o=="string"?o:o!=null&&o.family?`${o.family}, ${o.given||""}`.trim():"").filter(Boolean):[]}function v4t(t){var n,s,i,a,o,c,u,d,h,f,p,m,g,x,y;if(!t)return null;const e=t.published_year||t.year||((n=t.crossref_data)==null?void 0:n.year)||((c=(o=(a=(i=(s=t.crossref_data)==null?void 0:s.crossref_metadata)==null?void 0:i.issued)==null?void 0:a["date-parts"])==null?void 0:o[0])==null?void 0:c[0])||((f=(h=(d=(u=t.crossref_payload)==null?void 0:u.issued)==null?void 0:d["date-parts"])==null?void 0:h[0])==null?void 0:f[0])||((x=(g=(m=(p=t.crossref_payload)==null?void 0:p.published)==null?void 0:m["date-parts"])==null?void 0:g[0])==null?void 0:x[0]);if(e)return String(e);const r=(y=t.google_books_data)==null?void 0:y.publishedDate;return r?String(r).substring(0,4):null}function b4t(t){var r,n,s,i,a,o;const e=t.bib_meta;return(e==null?void 0:e.title)||((r=e==null?void 0:e.google_books_data)==null?void 0:r.title)||((s=(n=e==null?void 0:e.crossref_payload)==null?void 0:n.title)==null?void 0:s[0])||((o=(a=(i=e==null?void 0:e.crossref_data)==null?void 0:i.crossref_metadata)==null?void 0:a.title)==null?void 0:o[0])||t.title||"Untitled"}function w4t(t){var o,c,u,d,h,f;const e=t.bib_meta,r=e==null?void 0:e.crossref_payload,n=(o=e==null?void 0:e.crossref_data)==null?void 0:o.crossref_metadata,s=[],i=(p,m)=>{m&&s.push(`${p} - ${m}`)};i("TY",y4t(e)),i("TI",b4t(t));for(const p of x4t(e))i("AU",p);i("PY",v4t(e)),i("DO",t.doi||(e==null?void 0:e.doi)||(r==null?void 0:r.DOI)||null),i("SN",t.isbn||(e==null?void 0:e.isbn)||((c=r==null?void 0:r.ISSN)==null?void 0:c[0])||((u=n==null?void 0:n.ISSN)==null?void 0:u[0])||null),i("PB",(e==null?void 0:e.publisher)||((d=e==null?void 0:e.google_books_data)==null?void 0:d.publisher)||(r==null?void 0:r.publisher)||(n==null?void 0:n.publisher)||null),i("JO",(e==null?void 0:e.journal)||((h=r==null?void 0:r["container-title"])==null?void 0:h[0])||((f=n==null?void 0:n["container-title"])==null?void 0:f[0])||null),i("VL",(e==null?void 0:e.volume)||(r==null?void 0:r.volume)||(n==null?void 0:n.volume)||null),i("IS",(e==null?void 0:e.issue)||(r==null?void 0:r.issue)||(n==null?void 0:n.issue)||null);const a=(e==null?void 0:e.pages)||(r==null?void 0:r.page)||(n==null?void 0:n.page);if(a&&typeof a=="string"){const p=a.split(/[-–]/);p[0]&&i("SP",p[0].trim()),p[1]&&i("EP",p[1].trim())}return i("AB",(e==null?void 0:e.abstract)||(r==null?void 0:r.abstract)||null),i("UR",(e==null?void 0:e.url)||(r==null?void 0:r.URL)||null),i("LA",(r==null?void 0:r.language)||null),s.push("ER -"),s.join(`
`)}function AU(t,e="citations.ris"){const r=t.map(w4t).join(`
`),n=new Blob([r],{type:"application/x-research-info-systems"}),s=URL.createObjectURL(n),i=document.createElement("a");i.href=s,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(s)}function S4t(t){var n,s,i,a,o;if(!t)return null;const e=t.authors||((n=t.crossref_data)==null?void 0:n.authors)||((s=t.crossref_payload)==null?void 0:s.author)||((a=(i=t.crossref_data)==null?void 0:i.crossref_metadata)==null?void 0:a.author)||((o=t.google_books_data)==null?void 0:o.authors);if(!Array.isArray(e)||e.length===0)return null;const r=c=>typeof c=="string"?c.split(/,\s*/)[0]||c.split(/\s+/).pop()||c:c!=null&&c.family?c.family:String(c);return e.length===1?r(e[0]):e.length===2?`${r(e[0])} & ${r(e[1])}`:`${r(e[0])} et al.`}function _4t(t){var n,s,i,a,o,c,u,d,h,f,p;if(!t)return null;const e=t.published_year||t.year||((n=t.crossref_data)==null?void 0:n.year)||((c=(o=(a=(i=(s=t.crossref_data)==null?void 0:s.crossref_metadata)==null?void 0:i.issued)==null?void 0:a["date-parts"])==null?void 0:o[0])==null?void 0:c[0])||((f=(h=(d=(u=t.crossref_payload)==null?void 0:u.issued)==null?void 0:d["date-parts"])==null?void 0:h[0])==null?void 0:f[0]);if(e)return String(e);const r=(p=t.google_books_data)==null?void 0:p.publishedDate;return r?String(r).substring(0,4):null}function vF(t){return t?!!(/\.\w{2,4}$/.test(t)||/^[\w-]+$/.test(t)&&t.length<40&&(/\d{3,}/.test(t)||/^[a-z]-\d/i.test(t))):!1}function j4t(t){var n,s,i,a,o,c,u;const e=t.bib_meta,r=[e==null?void 0:e.title,(n=e==null?void 0:e.crossref_data)==null?void 0:n.title,(i=(s=e==null?void 0:e.crossref_data)==null?void 0:s.crossref_metadata)==null?void 0:i.title,(a=e==null?void 0:e.google_books_data)==null?void 0:a.title,(c=(o=e==null?void 0:e.crossref_payload)==null?void 0:o.title)==null?void 0:c[0]];for(const d of r){if(d&&typeof d=="string"&&d.trim()&&!vF(d.trim()))return d.trim();if(Array.isArray(d)&&((u=d[0])!=null&&u.trim()))return d[0].trim()}return t.title&&!vF(t.title)?t.title:t.original_filename&&!vF(t.original_filename)?t.original_filename:t.title||t.original_filename||"Untitled"}function k4t(t){var e,r,n;return t&&(t.pages||((r=(e=t.crossref_data)==null?void 0:e.crossref_metadata)==null?void 0:r.page)||((n=t.crossref_payload)==null?void 0:n.page))||null}function N4t({doc:t,selected:e,onSelectionChange:r}){const[n,s]=j.useState(!1),i=Or(),a=t.bib_meta,o=j4t(t),c=S4t(a),u=_4t(a),d=k4t(a),h=t.doi||t.isbn||null,f=t.doi?"DOI":t.isbn?"ISBN":null,p=t.original_filename||null,m=p&&p!==o,g=async()=>{if(!t.citation_apa){We.error("No APA citation available");return}await navigator.clipboard.writeText(t.citation_apa),s(!0),We.success("APA citation copied"),setTimeout(()=>s(!1),2e3)},x=()=>{AU([t],`${o.replace(/[^a-zA-Z0-9]/g,"_").substring(0,40)}.ris`),We.success("RIS file downloaded")};return l.jsxs(Zn,{children:[l.jsx(At,{className:"w-8",children:l.jsx(bl,{checked:e,onCheckedChange:y=>r(t.id,!!y)})}),l.jsx(At,{children:l.jsxs("div",{className:"min-w-0",children:[l.jsx("p",{className:"font-medium text-sm line-clamp-2",children:o}),m&&l.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1 mt-0.5",children:[l.jsx(Br,{className:"w-3 h-3 flex-shrink-0"}),l.jsx("span",{className:"truncate",children:p})]})]})}),l.jsx(At,{className:"text-muted-foreground text-sm",children:c||"–"}),l.jsx(At,{className:"text-muted-foreground text-sm",children:u||"–"}),l.jsx(At,{className:"text-muted-foreground text-sm",children:d||"–"}),l.jsx(At,{className:"text-muted-foreground text-sm max-w-[180px]",children:h?l.jsxs("span",{className:"truncate block",title:h,children:[f,": ",h]}):"–"}),l.jsx(At,{className:"text-right",children:l.jsxs("div",{className:"flex justify-end gap-1",children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0",onClick:g,disabled:!t.citation_apa,children:n?l.jsx(Es,{className:"w-4 h-4"}):l.jsx(Tn,{className:"w-4 h-4"})})}),l.jsx(Qt,{children:"Copy APA citation"})]}),l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0",onClick:x,children:l.jsx(Ga,{className:"w-4 h-4"})})}),l.jsx(Qt,{children:"Export RIS"})]}),l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0",onClick:()=>i("/reference-checker"),children:l.jsx(_c,{className:"w-4 h-4"})})}),l.jsx(Qt,{children:"Check with Citation Manager"})]})]})})]})}const VC={title:"",authors:"",publisher:"",published_year:"",isbn:"",doi:"",edition:"",pages:"",language:"",series:"",type:"book"},E4t=()=>{const{user:t,userProfile:e,loading:r}=Dt(),n=Or(),[s]=oE(),i=s.get("document"),[a,o]=j.useState([]),[c,u]=j.useState(!0),[d,h]=j.useState(""),[f,p]=j.useState("all"),[m,g]=j.useState("newest"),[x,y]=j.useState(new Set),[v,b]=j.useState([]),[w,S]=j.useState(""),[k,E]=j.useState(""),[C,A]=j.useState(""),[M,z]=j.useState(!1),[P,W]=j.useState(null),[N,U]=j.useState(""),[K,G]=j.useState(!1),[X,H]=j.useState(""),[B,L]=j.useState(!1),[F,V]=j.useState(""),[Y,ie]=j.useState(VC),[Q,D]=j.useState("manual_entry"),[R,J]=j.useState(!1),[Z,ee]=j.useState(VC),[re,he]=j.useState(!1);j.useEffect(()=>{!t&&!r&&n("/login")},[t,r,n]),j.useEffect(()=>{t&&O()},[t]),j.useEffect(()=>{e!=null&&e.id&&ae()},[e==null?void 0:e.id]),j.useEffect(()=>{if(i&&v.length>0){const fe=v.find(Te=>Te.id===i);fe&&(S(i),E(fe.doi||""),A(fe.isbn||""))}},[i,v]);const O=async()=>{if(t){u(!0);try{const{data:fe,error:Te}=await be.from("v_documents_with_status").select("*").eq("user_id",t.id).or("bib_meta.not.is.null,citation_apa.not.is.null,doi.not.is.null,isbn.not.is.null").order("created_at",{ascending:!1});if(Te){console.error("Error fetching citations:",Te);return}o(fe||[])}finally{u(!1)}}},ae=async()=>{try{const{data:fe,error:Te}=await be.from("documents").select("*").eq("user_id",e==null?void 0:e.id).order("created_at",{ascending:!1});if(Te)throw Te;b(fe||[])}catch(fe){console.error("Error loading documents:",fe),We.error("Error loading documents")}},q=async()=>{var fe;if(!w){U("Please select a document");return}z(!0),U(""),W(null);try{const{data:Te,error:Pe}=await be.functions.invoke("detect_bibliography",{body:{document_id:w,force:!0,manual_doi:k.trim()||null,manual_isbn:C.trim()||null}});if(Pe)throw Pe;if(Te!=null&&Te.error)throw new Error(Te.error);const{data:tt,error:wt}=await be.from("documents").select("*").eq("id",w).single();if(wt)throw wt;const Ee=tt;W({citation_apa:Ee.citation_apa,doi:Ee.doi,isbn:Ee.isbn,bib_meta:Ee.bib_meta,source:((fe=Ee.bib_meta)==null?void 0:fe.method)||"unknown"}),We.success("Citation updated successfully"),b(nt=>nt.map(rt=>rt.id===w?Ee:rt)),O()}catch(Te){console.error("Reference check error:",Te);const Pe=Te.message||"Unknown error";Pe.includes("ISBN")||Pe.includes("isbn")?U("Invalid ISBN or no match found"):Pe.includes("DOI")||Pe.includes("doi")?U("Invalid DOI or no match found"):U(`Error: ${Pe}`)}finally{z(!1)}},I=async()=>{var fe,Te;if(!X.trim()){V("Please paste some text first");return}L(!0),V("");try{const{data:Pe,error:tt}=await be.functions.invoke("parse_bibliography_text",{body:{rawText:X.trim()}});if(tt)throw tt;if(Pe!=null&&Pe.error)throw new Error(Pe.error);const wt=Pe==null?void 0:Pe.data;wt&&(ie({title:wt.title||"",authors:((fe=wt.authors)==null?void 0:fe.join(", "))||"",publisher:wt.publisher||"",published_year:((Te=wt.published_year)==null?void 0:Te.toString())||"",isbn:wt.isbn||"",doi:wt.doi||"",edition:wt.edition||"",pages:wt.pages||"",language:wt.language||"",series:wt.series||"",type:wt.type||"book"}),D("parsed_paste"),We.success("Text successfully parsed!"))}catch(Pe){console.error("Parse error:",Pe),V(Pe.message||"Failed to parse text")}finally{L(!1)}},T=async()=>{if(!w){We.error("Please select a document first");return}if(!Y.title.trim()){We.error("Title is required");return}J(!0);try{const fe=Y.authors.split(",").map(Ze=>Ze.trim()).filter(Boolean),Te={title:Y.title,authors:fe,publisher:Y.publisher||null,published_year:parseInt(Y.published_year)||null,edition:Y.edition||null,pages:Y.pages||null,language:Y.language||null,series:Y.series||null,type:Y.type||"book",method:Q},Pe=fe.length?fe.join(", "):"Unknown Author",tt=Y.published_year?`(${Y.published_year})`:"(n.d.)",wt=Y.publisher?`. ${Y.publisher}`:"",Ee=`${Pe} ${tt}. ${Y.title}${wt}.`,{error:nt}=await be.from("documents").update({bib_meta:Te,citation_apa:Ee,isbn:Y.isbn||null,doi:Y.doi||null,title:Y.title}).eq("id",w);if(nt)throw nt;const{data:rt}=await be.from("documents").select("*").eq("id",w).single();rt&&(b(Ze=>Ze.map(we=>we.id===w?rt:we)),W({citation_apa:Ee,doi:Y.doi,isbn:Y.isbn,bib_meta:Te,source:Q})),We.success("Metadata applied successfully!"),ie(VC),H(""),O()}catch(fe){console.error("Apply error:",fe),We.error("Failed to apply metadata")}finally{J(!1)}},$=(fe,Te)=>{ie(Pe=>({...Pe,[fe]:Te})),D("manual_entry")},se=(fe,Te)=>{ee(Pe=>({...Pe,[fe]:Te}))},ue=async()=>{if(!Z.title.trim()){We.error("Title is required");return}if(t){he(!0);try{const fe=Z.authors.split(",").map(rt=>rt.trim()).filter(Boolean),Te={title:Z.title,authors:fe,publisher:Z.publisher||null,published_year:parseInt(Z.published_year)||null,edition:Z.edition||null,pages:Z.pages||null,language:Z.language||null,series:Z.series||null,type:Z.type||"book",method:"manual_citation"},Pe=fe.length?fe.join(", "):"Unknown Author",tt=Z.published_year?`(${Z.published_year})`:"(n.d.)",wt=Z.publisher?`. ${Z.publisher}`:"",Ee=`${Pe} ${tt}. ${Z.title}${wt}.`,{error:nt}=await be.from("documents").insert({user_id:t.id,title:Z.title,bib_meta:Te,citation_apa:Ee,isbn:Z.isbn||null,doi:Z.doi||null,page_count:0});if(nt)throw nt;We.success("Citation source created successfully!"),ee(VC),await ae(),O()}catch(fe){console.error("Error creating citation-only entry:",fe),We.error("Failed to create citation source")}finally{he(!1)}}},ne=async()=>{if(P!=null&&P.citation_apa)try{await navigator.clipboard.writeText(P.citation_apa),G(!0),We.success("Citation copied to clipboard"),setTimeout(()=>G(!1),2e3)}catch{We.error("Failed to copy")}},me=v.find(fe=>fe.id===w),ve=fe=>{var Pe,tt,wt,Ee,nt;const Te=(fe==null?void 0:fe.authors)||((Pe=fe==null?void 0:fe.crossref_data)==null?void 0:Pe.authors)||((tt=fe==null?void 0:fe.crossref_payload)==null?void 0:tt.author)||((Ee=(wt=fe==null?void 0:fe.crossref_data)==null?void 0:wt.crossref_metadata)==null?void 0:Ee.author)||((nt=fe==null?void 0:fe.google_books_data)==null?void 0:nt.authors)||[];return Array.isArray(Te)?Te.map(rt=>typeof rt=="string"?rt:`${(rt==null?void 0:rt.family)||""} ${(rt==null?void 0:rt.given)||""}`.trim()).join(" "):""},xe=fe=>{var tt,wt,Ee,nt,rt,Ze,we;const Te=fe.bib_meta,Pe=[Te==null?void 0:Te.title,(tt=Te==null?void 0:Te.crossref_data)==null?void 0:tt.title,(Ee=(wt=Te==null?void 0:Te.crossref_data)==null?void 0:wt.crossref_metadata)==null?void 0:Ee.title,(nt=Te==null?void 0:Te.google_books_data)==null?void 0:nt.title,(Ze=(rt=Te==null?void 0:Te.crossref_payload)==null?void 0:rt.title)==null?void 0:Ze[0]];for(const Oe of Pe){if(Oe&&typeof Oe=="string"&&Oe.trim())return Oe.trim().toLowerCase();if(Array.isArray(Oe)&&((we=Oe[0])!=null&&we.trim()))return Oe[0].trim().toLowerCase()}return(fe.title||fe.original_filename||"").toLowerCase()},oe=fe=>{var tt,wt,Ee,nt,rt,Ze,we,Oe,je,Re,Ue;if(!fe)return null;const Te=fe.published_year||fe.year||((tt=fe.crossref_data)==null?void 0:tt.year)||((Ze=(rt=(nt=(Ee=(wt=fe.crossref_data)==null?void 0:wt.crossref_metadata)==null?void 0:Ee.issued)==null?void 0:nt["date-parts"])==null?void 0:rt[0])==null?void 0:Ze[0])||((Re=(je=(Oe=(we=fe.crossref_payload)==null?void 0:we.issued)==null?void 0:Oe["date-parts"])==null?void 0:je[0])==null?void 0:Re[0]);if(Te)return Number(Te);const Pe=(Ue=fe.google_books_data)==null?void 0:Ue.publishedDate;return Pe?parseInt(String(Pe).substring(0,4)):null},de=fe=>{var Te,Pe;return((fe==null?void 0:fe.type)||((Te=fe==null?void 0:fe.crossref_data)==null?void 0:Te.type)||((Pe=fe==null?void 0:fe.crossref_payload)==null?void 0:Pe.type)||"").toLowerCase().replace(/-/g," ")},ge=j.useMemo(()=>{const fe=new Set;return a.forEach(Te=>{const Pe=de(Te.bib_meta);Pe&&fe.add(Pe)}),Array.from(fe).sort()},[a]),Se=j.useMemo(()=>{let fe=a;if(d){const Te=d.toLowerCase();fe=fe.filter(Pe=>{const tt=xe(Pe),wt=ve(Pe.bib_meta).toLowerCase(),Ee=(Pe.doi||"").toLowerCase(),nt=(Pe.isbn||"").toLowerCase();return tt.includes(Te)||wt.includes(Te)||Ee.includes(Te)||nt.includes(Te)})}return f!=="all"&&(fe=fe.filter(Te=>de(Te.bib_meta)===f)),fe=[...fe].sort((Te,Pe)=>{if(m==="newest")return new Date(Pe.created_at).getTime()-new Date(Te.created_at).getTime();if(m==="alphabetical")return xe(Te).localeCompare(xe(Pe));const tt=oe(Te.bib_meta)||0;return(oe(Pe.bib_meta)||0)-tt}),fe},[a,d,f,m]),ke=(fe,Te)=>{y(Pe=>{const tt=new Set(Pe);return Te?tt.add(fe):tt.delete(fe),tt})},Ne=()=>{Se.length!==0&&(AU(Se,"all-citations.ris"),We.success(`Exported ${Se.length} citations`))},qe=()=>{const fe=Se.filter(Te=>x.has(Te.id));if(fe.length===0){We.error("No citations selected");return}AU(fe,"selected-citations.ris"),We.success(`Exported ${fe.length} citations`)};if(r||c)return l.jsx(gr,{showSidebar:!0,pageTitle:"My Citations",children:l.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),l.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})});if(!t)return null;const Ae=(fe,Te)=>l.jsxs(dt,{value:fe,onValueChange:Te,children:[l.jsx(lt,{className:"mt-1",children:l.jsx(ht,{placeholder:"Select language..."})}),l.jsxs(ct,{children:[l.jsx(De,{value:"German",children:"German"}),l.jsx(De,{value:"English",children:"English"}),l.jsx(De,{value:"French",children:"French"}),l.jsx(De,{value:"Spanish",children:"Spanish"}),l.jsx(De,{value:"Italian",children:"Italian"}),l.jsx(De,{value:"Other",children:"Other"})]})]});return l.jsx(gr,{showSidebar:!0,pageTitle:"My Citations",children:l.jsxs("div",{className:"space-y-6",children:[l.jsxs(ze,{children:[l.jsxs(et,{className:"pb-3",children:[l.jsx(at,{children:"Citation Manager"}),l.jsx(Un,{children:"Verify, enter, or create citation entries for your documents"})]}),l.jsx(Ge,{children:l.jsxs(y8,{defaultValue:"check",className:"w-full",children:[l.jsxs(dO,{className:"grid w-full grid-cols-3",children:[l.jsxs(hf,{value:"check",className:"flex items-center gap-2",children:[l.jsx(ps,{className:"w-4 h-4"}),"Document Check"]}),l.jsxs(hf,{value:"manual",className:"flex items-center gap-2",children:[l.jsx(oL,{className:"w-4 h-4"}),"Manual Entry"]}),l.jsxs(hf,{value:"physical",className:"flex items-center gap-2",children:[l.jsx(YG,{className:"w-4 h-4"}),"Add Source"]})]}),l.jsxs(ff,{value:"check",className:"space-y-6 mt-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"document-select",children:"Document"}),l.jsxs(dt,{value:w,onValueChange:S,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select a document..."})}),l.jsx(ct,{children:v.map(fe=>l.jsx(De,{value:fe.id,children:l.jsx("span",{className:"font-medium",children:fe.title||fe.original_filename||"Untitled"})},fe.id))})]})]}),me&&(()=>{var rs,Rr,pn,lr,mn,ZE,eA,tA,rA,nA,sA,iA;const fe=me.bib_meta,Te=fe==null?void 0:fe.google_books_data,Pe=(fe==null?void 0:fe.crossref_payload)||((rs=fe==null?void 0:fe.crossref_data)==null?void 0:rs.crossref_metadata),tt=fe==null?void 0:fe.crossref_data,wt=(fe==null?void 0:fe.title)||(tt==null?void 0:tt.title)||me.title||me.original_filename||"No title",Ee=(fe==null?void 0:fe.type)||(Pe==null?void 0:Pe.type),nt=((Rr=fe==null?void 0:fe.authors)==null?void 0:Rr.join(", "))||((pn=tt==null?void 0:tt.authors)==null?void 0:pn.join(", "))||((lr=Te==null?void 0:Te.authors)==null?void 0:lr.join(", "))||((mn=Pe==null?void 0:Pe.author)==null?void 0:mn.map(Tc=>`${Tc.family}, ${Tc.given}`).join("; ")),rt=(fe==null?void 0:fe.publisher)||(tt==null?void 0:tt.publisher)||(Te==null?void 0:Te.publisher)||(Pe==null?void 0:Pe.publisher),Ze=(fe==null?void 0:fe.published_year)||(tt==null?void 0:tt.year)||((ZE=Te==null?void 0:Te.publishedDate)==null?void 0:ZE.substring(0,4))||((rA=(tA=(eA=Pe==null?void 0:Pe.issued)==null?void 0:eA["date-parts"])==null?void 0:tA[0])==null?void 0:rA[0]),we=fe==null?void 0:fe.edition,Oe=(fe==null?void 0:fe.pages)||(tt==null?void 0:tt.pages)||(Te==null?void 0:Te.pageCount)||(Pe==null?void 0:Pe.page),je=(fe==null?void 0:fe.language)||(Te==null?void 0:Te.language),Re=fe==null?void 0:fe.series,Ue=me.isbn||(fe==null?void 0:fe.isbn)||((sA=(nA=Te==null?void 0:Te.industryIdentifiers)==null?void 0:nA.find(Tc=>Tc.type==="ISBN_13"))==null?void 0:sA.identifier),it=me.doi||(fe==null?void 0:fe.doi)||(tt==null?void 0:tt.doi),Ce=fe==null?void 0:fe.method,$t=Ce==="manual_entry"?"Manual Entry":Ce==="parsed_paste"?"Parsed Paste":Ce==="manual_input"?"Manual Input":Ce||null,Kt=(tt==null?void 0:tt.journal)||((iA=Pe==null?void 0:Pe["container-title"])==null?void 0:iA[0]),On=(tt==null?void 0:tt.volume)||(Pe==null?void 0:Pe.volume),Ms=(tt==null?void 0:tt.issue)||(Pe==null?void 0:Pe.issue),Do=[{label:"Title",value:wt},Ee&&{label:"Type",value:Ee.charAt(0).toUpperCase()+Ee.slice(1)},nt&&{label:"Author(s)",value:nt},rt&&{label:"Publisher",value:rt},Ze&&{label:"Published",value:String(Ze)},we&&{label:"Edition",value:we},Kt&&{label:"Journal",value:Kt},On&&{label:"Volume",value:`${On}${Ms?` (${Ms})`:""}`},Oe&&{label:"Pages",value:String(Oe)},je&&{label:"Language",value:je.charAt(0).toUpperCase()+je.slice(1)},Re&&{label:"Series",value:Re},Ue&&{label:"ISBN",value:Ue},it&&{label:"DOI",value:it},$t&&{label:"Source",value:$t}].filter(Boolean);return l.jsxs("div",{className:"p-4 bg-muted/50 rounded-xl border border-border/50",children:[l.jsxs("div",{className:"flex items-center justify-between mb-3",children:[l.jsx("span",{className:"text-sm font-semibold",children:"Current Status"}),l.jsx("div",{children:me.citation_apa?l.jsxs(kt,{className:"bg-success/20 text-success hover:bg-success/30",children:[l.jsx(Es,{className:"w-3 h-3 mr-1"}),"Citation Available"]}):l.jsxs(kt,{variant:"destructive",className:"bg-destructive/20 text-destructive hover:bg-destructive/30",children:[l.jsx(Is,{className:"w-3 h-3 mr-1"}),"Citation Missing"]})})]}),l.jsx("div",{className:"grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5",children:Do.map(Tc=>l.jsxs("div",{className:"contents",children:[l.jsxs("span",{className:"text-xs text-muted-foreground py-0.5",children:[Tc.label,":"]}),l.jsx("span",{className:"text-sm font-medium py-0.5 break-words",children:Tc.value})]},Tc.label))})]})})(),l.jsxs("div",{className:"pt-4 border-t border-border/50",children:[l.jsx(_e,{className:"text-sm font-medium mb-3 block",children:"Manual Override (Optional)"}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"doi",className:"text-xs text-muted-foreground",children:"DOI"}),l.jsx(Be,{id:"doi",value:k,onChange:fe=>E(fe.target.value),placeholder:"10.1000/example",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"isbn",className:"text-xs text-muted-foreground",children:"ISBN"}),l.jsx(Be,{id:"isbn",value:C,onChange:fe=>A(fe.target.value),placeholder:"978-3-16-148410-0",className:"mt-1"})]})]})]}),l.jsx(ye,{onClick:q,disabled:M||!w,className:"w-full",size:"lg",children:M?l.jsxs(l.Fragment,{children:[l.jsx(Di,{className:"w-4 h-4 mr-2 animate-spin"}),"Checking document..."]}):l.jsxs(l.Fragment,{children:[l.jsx(yl,{className:"w-4 h-4 mr-2"}),"Check Document"]})}),N&&l.jsxs("div",{className:"flex items-center gap-2 p-4 bg-destructive/10 border border-destructive/20 rounded-lg",children:[l.jsx(rj,{className:"w-4 h-4 text-destructive shrink-0"}),l.jsx("span",{className:"text-sm text-destructive",children:N})]})]}),l.jsxs(ff,{value:"manual",className:"space-y-4 mt-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"manual-document-select",children:"Target Document"}),l.jsxs(dt,{value:w,onValueChange:S,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select a document to apply data..."})}),l.jsx(ct,{children:v.map(fe=>l.jsx(De,{value:fe.id,children:l.jsx("span",{className:"font-medium",children:fe.title||fe.original_filename||"Untitled"})},fe.id))})]}),!w&&l.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Select a document to apply bibliographic data"})]}),l.jsxs(y8,{defaultValue:"quick-paste",className:"w-full",children:[l.jsxs(dO,{className:"grid w-full grid-cols-2",children:[l.jsxs(hf,{value:"quick-paste",className:"flex items-center gap-2",children:[l.jsx(oL,{className:"w-4 h-4"}),"Quick Paste"]}),l.jsxs(hf,{value:"manual-fields",className:"flex items-center gap-2",children:[l.jsx(G2e,{className:"w-4 h-4"}),"Manual Fields"]})]}),l.jsxs(ff,{value:"quick-paste",className:"space-y-4 mt-4",children:[l.jsxs("div",{children:[l.jsx(_e,{children:"Paste Raw Text"}),l.jsx(ir,{value:X,onChange:fe=>H(fe.target.value),placeholder:"Paste bibliographic data from Amazon, Google Books, library catalogs, etc...",className:"min-h-[120px] mt-1"}),l.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Example: ISBN978-3-411-87151-3VerlagDuden..."})]}),l.jsx(ye,{onClick:I,disabled:B||!X.trim(),className:"w-full",children:B?l.jsxs(l.Fragment,{children:[l.jsx(Di,{className:"w-4 h-4 mr-2 animate-spin"}),"Parsing..."]}):l.jsxs(l.Fragment,{children:[l.jsx(oL,{className:"w-4 h-4 mr-2"}),"Parse Text"]})}),F&&l.jsxs("div",{className:"flex items-center gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-lg",children:[l.jsx(rj,{className:"w-4 h-4 text-destructive shrink-0"}),l.jsx("span",{className:"text-sm text-destructive",children:F})]}),(Y.title||Y.authors||Y.publisher)&&l.jsxs("div",{className:"p-4 bg-muted/50 rounded-xl border border-border/50 space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx(Es,{className:"w-4 h-4 text-success"}),l.jsx("span",{className:"text-sm font-medium",children:"Parsed Result (editable)"})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Title *"}),l.jsx(Be,{value:Y.title,onChange:fe=>$("title",fe.target.value),placeholder:"Enter title...",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Authors (comma-separated)"}),l.jsx(Be,{value:Y.authors,onChange:fe=>$("authors",fe.target.value),placeholder:"Author 1, Author 2...",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Publisher"}),l.jsx(Be,{value:Y.publisher,onChange:fe=>$("publisher",fe.target.value),className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Year"}),l.jsx(Be,{value:Y.published_year,onChange:fe=>$("published_year",fe.target.value),placeholder:"2023",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"ISBN"}),l.jsx(Be,{value:Y.isbn,onChange:fe=>$("isbn",fe.target.value),className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"DOI"}),l.jsx(Be,{value:Y.doi,onChange:fe=>$("doi",fe.target.value),className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Edition"}),l.jsx(Be,{value:Y.edition,onChange:fe=>$("edition",fe.target.value),className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Pages"}),l.jsx(Be,{value:Y.pages,onChange:fe=>$("pages",fe.target.value),className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Language"}),Ae(Y.language,fe=>$("language",fe))]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Series"}),l.jsx(Be,{value:Y.series,onChange:fe=>$("series",fe.target.value),className:"mt-1"})]})]}),l.jsx(ye,{onClick:T,disabled:R||!w||!Y.title.trim(),className:"w-full mt-4",children:R?l.jsxs(l.Fragment,{children:[l.jsx(Di,{className:"w-4 h-4 mr-2 animate-spin"}),"Applying..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Es,{className:"w-4 h-4 mr-2"}),"Apply to Document"]})})]})]}),l.jsxs(ff,{value:"manual-fields",className:"space-y-4 mt-4",children:[l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsxs("div",{className:"md:col-span-2",children:[l.jsx(_e,{children:"Title *"}),l.jsx(Be,{value:Y.title,onChange:fe=>$("title",fe.target.value),placeholder:"Book or article title...",className:"mt-1"})]}),l.jsxs("div",{className:"md:col-span-2",children:[l.jsx(_e,{children:"Authors (comma-separated)"}),l.jsx(Be,{value:Y.authors,onChange:fe=>$("authors",fe.target.value),placeholder:"Last, First; Last, First...",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Publisher"}),l.jsx(Be,{value:Y.publisher,onChange:fe=>$("publisher",fe.target.value),placeholder:"Publisher name...",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Year"}),l.jsx(Be,{value:Y.published_year,onChange:fe=>$("published_year",fe.target.value),placeholder:"2023",type:"number",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"ISBN"}),l.jsx(Be,{value:Y.isbn,onChange:fe=>$("isbn",fe.target.value),placeholder:"978-3-16-148410-0",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"DOI"}),l.jsx(Be,{value:Y.doi,onChange:fe=>$("doi",fe.target.value),placeholder:"10.1000/example",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Edition"}),l.jsx(Be,{value:Y.edition,onChange:fe=>$("edition",fe.target.value),placeholder:"4th edition",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Pages"}),l.jsx(Be,{value:Y.pages,onChange:fe=>$("pages",fe.target.value),placeholder:"136",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Language"}),Ae(Y.language,fe=>$("language",fe))]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Series"}),l.jsx(Be,{value:Y.series,onChange:fe=>$("series",fe.target.value),placeholder:"Book series name...",className:"mt-1"})]})]}),l.jsx(ye,{onClick:T,disabled:R||!w||!Y.title.trim(),className:"w-full",size:"lg",children:R?l.jsxs(l.Fragment,{children:[l.jsx(Di,{className:"w-4 h-4 mr-2 animate-spin"}),"Applying..."]}):l.jsxs(l.Fragment,{children:[l.jsx(Es,{className:"w-4 h-4 mr-2"}),"Apply to Document"]})})]})]})]}),l.jsxs(ff,{value:"physical",className:"space-y-4 mt-4",children:[l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[l.jsxs("div",{className:"md:col-span-2",children:[l.jsx(_e,{children:"Title *"}),l.jsx(Be,{value:Z.title,onChange:fe=>se("title",fe.target.value),placeholder:"Book or article title...",className:"mt-1"})]}),l.jsxs("div",{className:"md:col-span-2",children:[l.jsx(_e,{children:"Authors (comma-separated)"}),l.jsx(Be,{value:Z.authors,onChange:fe=>se("authors",fe.target.value),placeholder:"Last, First; Last, First...",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Publisher"}),l.jsx(Be,{value:Z.publisher,onChange:fe=>se("publisher",fe.target.value),placeholder:"Publisher name...",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Year"}),l.jsx(Be,{value:Z.published_year,onChange:fe=>se("published_year",fe.target.value),placeholder:"2023",type:"number",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"ISBN"}),l.jsx(Be,{value:Z.isbn,onChange:fe=>se("isbn",fe.target.value),placeholder:"978-3-16-148410-0",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"DOI"}),l.jsx(Be,{value:Z.doi,onChange:fe=>se("doi",fe.target.value),placeholder:"10.1000/example",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Edition"}),l.jsx(Be,{value:Z.edition,onChange:fe=>se("edition",fe.target.value),placeholder:"4th edition",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Pages"}),l.jsx(Be,{value:Z.pages,onChange:fe=>se("pages",fe.target.value),placeholder:"136",className:"mt-1"})]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Language"}),Ae(Z.language,fe=>se("language",fe))]}),l.jsxs("div",{children:[l.jsx(_e,{children:"Series"}),l.jsx(Be,{value:Z.series,onChange:fe=>se("series",fe.target.value),placeholder:"Book series name...",className:"mt-1"})]})]}),l.jsx(ye,{onClick:ue,disabled:re||!Z.title.trim(),className:"w-full",size:"lg",children:re?l.jsxs(l.Fragment,{children:[l.jsx(Di,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):l.jsxs(l.Fragment,{children:[l.jsx(YG,{className:"w-4 h-4 mr-2"}),"Create Source Entry"]})})]})]})})]}),P&&l.jsxs(ze,{children:[l.jsxs(et,{children:[l.jsxs(at,{className:"flex items-center gap-2",children:[l.jsx(Es,{className:"w-5 h-5 text-success"}),"Result"]}),l.jsx(Un,{children:"Citation has been successfully updated"})]}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center justify-between mb-2",children:[l.jsx(_e,{className:"text-base font-semibold",children:"APA Citation"}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:ne,disabled:!P.citation_apa,children:[l.jsx(Tn,{className:"w-4 h-4 mr-2"}),K?"Copied!":"Copy"]})]}),l.jsx("div",{className:"p-4 bg-muted rounded-lg",children:l.jsx("p",{className:"text-sm leading-relaxed font-medium",children:P.citation_apa||"No citation available"})})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[l.jsxs("div",{children:[l.jsx(_e,{className:"text-sm",children:"Source"}),l.jsx("div",{className:"mt-1",children:l.jsx(kt,{variant:"secondary",children:P.source==="pdf_metadata_and_text_analysis"?"PDF Analysis":P.source==="google_books"?"Google Books":P.source==="open_library"?"Open Library":P.source==="crossref"?"CrossRef":P.source==="parsed_paste"?"Parsed Paste":P.source==="manual_entry"?"Manual Entry":P.source||"Unknown"})})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-sm",children:"DOI"}),l.jsx("p",{className:"text-sm mt-1",children:P.doi||"–"})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-sm",children:"ISBN"}),l.jsx("p",{className:"text-sm mt-1",children:P.isbn||"–"})]})]}),P.bib_meta&&l.jsxs(yq,{children:[l.jsx(xq,{asChild:!0,children:l.jsxs(ye,{variant:"ghost",size:"sm",className:"w-full justify-between",children:[l.jsx("span",{children:"Show Raw JSON Metadata"}),l.jsx(Eh,{className:"w-4 h-4"})]})}),l.jsx(vq,{children:l.jsx("div",{className:"mt-2 p-4 bg-muted rounded-lg",children:l.jsx("pre",{className:"text-xs overflow-auto max-h-64",children:JSON.stringify(P.bib_meta,null,2)})})})]})]})]}),l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold",children:"My Citations"}),l.jsx("p",{className:"text-muted-foreground",children:"Manage bibliographic data from your library documents"})]}),l.jsxs("div",{className:"flex flex-col sm:flex-row flex-wrap gap-3",children:[l.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[l.jsx(yl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),l.jsx(Be,{placeholder:"Search title, author, DOI, ISBN…",value:d,onChange:fe=>h(fe.target.value),className:"pl-9"})]}),l.jsxs(dt,{value:f,onValueChange:p,children:[l.jsx(lt,{className:"w-[160px]",children:l.jsx(ht,{placeholder:"All types"})}),l.jsxs(ct,{children:[l.jsx(De,{value:"all",children:"All types"}),ge.map(fe=>l.jsx(De,{value:fe,className:"capitalize",children:fe},fe))]})]}),l.jsxs(dt,{value:m,onValueChange:fe=>g(fe),children:[l.jsx(lt,{className:"w-[150px]",children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"newest",children:"Newest first"}),l.jsx(De,{value:"alphabetical",children:"A → Z"}),l.jsx(De,{value:"year",children:"Year (desc)"})]})]}),l.jsxs("div",{className:"flex gap-2 ml-auto",children:[l.jsxs(rr,{children:[l.jsx(nr,{asChild:!0,children:l.jsxs(ye,{variant:"outline",size:"sm",onClick:Ne,disabled:Se.length===0,children:[l.jsx(Ga,{className:"w-4 h-4 mr-1"}),"Export all"]})}),l.jsxs(Qt,{className:"flex items-start gap-1.5 max-w-[220px]",children:[l.jsx(Bp,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),l.jsx("span",{children:"In Zotero: File → Import → select the .ris file"})]})]}),l.jsxs(ye,{variant:"outline",size:"sm",onClick:qe,disabled:x.size===0,children:[l.jsx(Ga,{className:"w-4 h-4 mr-1"}),"Export selected (",x.size,")"]})]})]}),Se.length===0?l.jsxs("div",{className:"min-h-[40vh] flex flex-col items-center justify-center text-center",children:[l.jsx(Br,{className:"w-12 h-12 text-muted-foreground/40 mb-4"}),l.jsx("h3",{className:"text-lg font-medium text-foreground mb-1",children:"No citations yet"}),l.jsx("p",{className:"text-muted-foreground text-sm max-w-md",children:"Upload documents to your library first. Bibliographic metadata will be extracted automatically."})]}):l.jsxs(Ec,{children:[l.jsx(Ac,{children:l.jsxs(Zn,{children:[l.jsx(Et,{className:"w-8"}),l.jsx(Et,{children:"Title"}),l.jsx(Et,{children:"Author(s)"}),l.jsx(Et,{children:"Year"}),l.jsx(Et,{children:"Pages"}),l.jsx(Et,{children:"DOI / ISBN"}),l.jsx(Et,{className:"text-right",children:"Actions"})]})}),l.jsx(Cc,{children:Se.map(fe=>l.jsx(N4t,{doc:fe,selected:x.has(fe.id),onSelectionChange:ke},fe.id))})]})]})})};function WC({isLoading:t=!1,size:e=40}){return l.jsxs("div",{className:"relative flex-shrink-0",style:{width:e,height:e},children:[t&&l.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-purple-500 animate-spin",style:{width:e,height:e}}),l.jsx("img",{src:"https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/src/Logo_ST_small_supervisor.png",alt:"Thesis Supervisor",className:"rounded-full object-cover",style:{width:e,height:e}})]})}const bF=768;function A4t(){const[t,e]=j.useState(void 0);return j.useEffect(()=>{const r=window.matchMedia(`(max-width: ${bF-1}px)`),n=()=>{e(window.innerWidth<bF)};return r.addEventListener("change",n),e(window.innerWidth<bF),()=>r.removeEventListener("change",n)},[]),!!t}const C4t=["How well am I answering my research questions?","What is still missing in my thesis?","Can you review my discussion?"];function T4t(){var W;const{user:t}=Dt(),e=A4t(),[r,n]=j.useState([]),[s,i]=j.useState(""),[a,o]=j.useState([]),[c,u]=j.useState(null),[d,h]=j.useState([]),[f,p]=j.useState(""),[m,g]=j.useState(!1),[x,y]=j.useState(!1),v=j.useRef(null),[b,w]=j.useState(null),S=j.useRef(null);j.useEffect(()=>{if(!t)return;(async()=>{const{data:U}=await be.from("theses").select("id, title").order("created_at",{ascending:!1});U&&U.length>0&&(n(U),i(U[0].id))})()},[t]),j.useEffect(()=>{if(!s)return;(async()=>{const{data:U}=await be.from("supervisor_chats").select("id, title, messages, created_at, updated_at").eq("thesis_id",s).order("updated_at",{ascending:!1});o(U||[]),u(null),h([])})()},[s]),j.useEffect(()=>{var N;(N=v.current)==null||N.scrollIntoView({behavior:"smooth"})},[d]);const k=N=>{u(N.id),h(N.messages||[]),y(!1)},E=()=>{u(null),h([]),p(""),y(!1)},C=j.useCallback(async N=>{if(!N.trim()||!s||!t||m)return;const U={role:"user",content:N.trim(),timestamp:new Date().toISOString()},K=[...d,U];h(K),p(""),g(!0);try{const{data:G,error:X}=await be.functions.invoke("supervisor_chat",{body:{thesis_id:s,message:U.content,chat_history:d.map(L=>({role:L.role,content:L.content})),language:"en",attachment:b??null}});if(X)throw X;w(null);const H={role:"assistant",content:(G==null?void 0:G.message)||"Keine Antwort erhalten.",timestamp:new Date().toISOString()},B=[...K,H];if(h(B),c)await be.from("supervisor_chats").update({messages:B,updated_at:new Date().toISOString()}).eq("id",c),o(L=>L.map(F=>F.id===c?{...F,messages:B,updated_at:new Date().toISOString()}:F));else{const L=U.content.substring(0,50),{data:F}=await be.from("supervisor_chats").insert({user_id:t.id,thesis_id:s,title:L,messages:B}).select("id").single();F&&(u(F.id),o(V=>[{id:F.id,title:L,messages:B,created_at:new Date().toISOString(),updated_at:new Date().toISOString()},...V]))}}catch(G){We.error("Fehler: "+(G.message||"Unbekannter Fehler"))}finally{g(!1)}},[d,s,t,m,c]),A=N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),C(f))},M=async N=>{var G;const U=(G=N.target.files)==null?void 0:G[0];if(!U)return;if(U.size>10*1024*1024){We.error("Datei zu groß – maximum 10MB");return}const K=new FileReader;K.onload=()=>{const X=K.result.split(",")[1];w({name:U.name,base64:X,type:U.type}),We.success(`${U.name} attached`)},K.readAsDataURL(U)},z=l.jsxs(l.Fragment,{children:[l.jsxs("div",{children:[l.jsx("label",{className:"text-sm font-medium text-muted-foreground mb-1.5 block",children:"Thesis"}),l.jsxs(dt,{value:s,onValueChange:i,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select thesis…"})}),l.jsx(ct,{children:r.map(N=>l.jsx(De,{value:N.id,children:N.title},N.id))})]})]}),l.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[l.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Vergangene Chats"}),l.jsx(Yw,{className:"flex-1",children:l.jsxs("div",{className:"space-y-1",children:[a.map(N=>l.jsxs("button",{onClick:()=>k(N),className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors flex items-center gap-2 ${c===N.id?"bg-primary/10 text-primary":"hover:bg-muted text-foreground"}`,children:[l.jsx(Gy,{className:"w-3.5 h-3.5 flex-shrink-0 opacity-50"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-xs font-medium leading-tight",children:N.title||"Untitled"}),l.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:fj(new Date(N.updated_at),"dd.MM. HH:mm")})]})]},N.id)),a.length===0&&s&&l.jsx("p",{className:"text-sm text-muted-foreground px-3 py-4",children:"Noch keine Chats."})]})})]}),l.jsxs(ye,{variant:"outline",className:"w-full",onClick:E,children:[l.jsx(hl,{className:"w-4 h-4 mr-2"})," New Chat"]})]}),P=N=>{if(!(N.includes("✓")||N.includes("✗")||N.includes("→")))return l.jsx("div",{className:`prose prose-sm dark:prose-invert max-w-none
[&>*:first-child]:mt-0 [&>*:last-child]:mb-0
[&>p]:mb-3 [&>p]:leading-relaxed
[&>p>strong]:block [&>p>strong]:mt-4 [&>p>strong]:mb-1 [&>p>strong]:text-sm
[&>ul]:mt-1 [&>ul]:mb-3 [&>ul]:space-y-1.5
[&>li]:leading-relaxed`,children:l.jsx(pc,{components:{p:({children:F,...V})=>{var Q;const Y=Array.isArray(F)?F:[F];return Y.length===1&&typeof Y[0]=="object"&&((Q=Y[0])==null?void 0:Q.type)==="strong"?l.jsx("p",{className:"font-semibold text-sm mt-5 mb-1.5",...V,children:F}):l.jsx("p",{className:"mb-2.5 leading-relaxed",...V,children:F})},a:({href:F,children:V})=>l.jsx("a",{target:"_blank",rel:"noopener noreferrer",className:"text-primary underline underline-offset-2 hover:opacity-80 transition-opacity",children:V}),hr:()=>null},children:N})});const K=[],G=N.split(`
`);let X={type:"",lines:[]};const H=[];let B=!1;for(const F of G)F.startsWith("✓")||F.includes("Was gut ist")?(X.lines.length&&K.push(X),X={type:"good",lines:[F.replace(/^✓\s*\*?\*?Was gut ist\*?\*?:?\s*/i,"").replace(/^✓\s*/,"")]},B=!0):F.startsWith("✗")||F.includes("Was verbessert")?(X.lines.length&&K.push(X),X={type:"improve",lines:[F.replace(/^✗\s*\*?\*?Was verbessert werden muss\*?\*?:?\s*/i,"").replace(/^✗\s*/,"")]},B=!0):F.startsWith("→")||F.includes("Nächster")?(X.lines.length&&K.push(X),X={type:"next",lines:[F.replace(/^→\s*\*?\*?Nächster konkreter Schritt\*?\*?:?\s*/i,"").replace(/^→\s*/,"")]},B=!0):B?X.lines.push(F):H.push(F);X.lines.length&&K.push(X);const L={good:{label:"What is good",icon:"✓",bg:"bg-emerald-50 dark:bg-emerald-950/30",border:"border-emerald-200 dark:border-emerald-800",iconColor:"text-emerald-600 dark:text-emerald-400",labelColor:"text-emerald-700 dark:text-emerald-300"},improve:{label:"What needs to be improved",icon:"✗",bg:"bg-red-50 dark:bg-red-950/30",border:"border-red-200 dark:border-red-800",iconColor:"text-red-500 dark:text-red-400",labelColor:"text-red-700 dark:text-red-300"},next:{label:"Next concrete step",icon:"→",bg:"bg-blue-50 dark:bg-blue-950/30",border:"border-blue-200 dark:border-blue-800",iconColor:"text-blue-500 dark:text-blue-400",labelColor:"text-blue-700 dark:text-blue-300"}};return l.jsxs("div",{className:"space-y-1",children:[H.join(`
`).trim()&&l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none mb-3 [&>p]:mb-2 [&>p]:leading-relaxed",children:l.jsx(pc,{children:H.join(`
`)})}),K.map((F,V)=>{const Y=L[F.type];return Y?l.jsxs("div",{className:`rounded-xl border px-4 py-3 ${Y.bg} ${Y.border}`,children:[l.jsxs("div",{className:`flex items-center gap-1.5 font-semibold text-xs mb-2 ${Y.labelColor}`,children:[l.jsx("span",{className:Y.iconColor,children:Y.icon}),Y.label]}),l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&>p]:mb-2 [&>p]:leading-relaxed [&>p]:text-foreground [&>ul]:space-y-1 [&>li]:leading-relaxed [&>li]:text-foreground",children:l.jsx(pc,{children:F.lines.join(`
`).trim()})})]},V):null})]})};return l.jsx(gr,{showSidebar:!0,pageTitle:"Supervisor",fullWidth:!0,hidePlatformAssistant:!0,children:l.jsxs("div",{className:"flex h-[calc(100vh-4rem)] -m-4 md:-m-6 xl:-m-8",children:[l.jsx("div",{className:"hidden md:flex w-[280px] flex-shrink-0 flex-col gap-4 border-r border-border px-4 pt-6 pb-4",children:z}),l.jsxs("div",{className:"flex-1 flex flex-col min-w-0 px-4 md:px-6 pt-4 md:pt-6",children:[l.jsxs("div",{className:"flex items-center gap-3 pb-4 border-b border-border mb-4",children:[e&&l.jsxs(FNe,{open:x,onOpenChange:y,children:[l.jsx(VLt,{asChild:!0,children:l.jsx(ye,{variant:"ghost",size:"icon",className:"flex-shrink-0",children:l.jsx(PH,{className:"w-5 h-5"})})}),l.jsxs(mq,{side:"left",className:"w-[280px] p-4 flex flex-col gap-4",children:[l.jsx(gq,{className:"sr-only",children:"Chat History"}),z]})]}),l.jsx(WC,{isLoading:!1}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Thesis Supervisor"}),l.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e&&s?((W=r.find(N=>N.id===s))==null?void 0:W.title)||"AI-powered feedback":"AI-powered feedback on your work"})]})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto space-y-4 pb-4",children:[d.length===0&&!m&&l.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-6",children:[l.jsx(WC,{size:64}),l.jsx("p",{className:"text-muted-foreground text-center max-w-md",children:"Ask me questions about your thesis — I'll give you feedback like a supervisor.."}),l.jsx("div",{className:"flex flex-wrap justify-center gap-2",children:C4t.map(N=>l.jsx("button",{onClick:()=>C(N),className:"px-4 py-2 rounded-full border border-border text-sm text-foreground hover:bg-muted transition-colors",children:N},N))})]}),d.map((N,U)=>l.jsxs("div",{className:`flex gap-3 ${N.role==="user"?"justify-end":"justify-start"}`,children:[N.role==="assistant"&&l.jsx(WC,{size:32}),l.jsx("div",{className:`max-w-[85%] md:max-w-[75%] rounded-2xl px-4 text-sm ${N.role==="user"?"bg-purple-600 text-white rounded-br-md py-3":"bg-muted text-foreground rounded-bl-md shadow-sm py-4"}`,children:N.role==="assistant"?P(N.content):l.jsx("p",{className:"whitespace-pre-wrap",children:N.content})})]},U)),m&&l.jsxs("div",{className:"flex gap-3 justify-start",children:[l.jsx(WC,{size:32,isLoading:!0}),l.jsx("div",{className:"bg-muted rounded-2xl rounded-bl-md px-4 py-3",children:l.jsxs("div",{className:"flex gap-1",children:[l.jsx("span",{className:"w-2 h-2 bg-muted-foreground/40 rounded-full animate-bounce [animation-delay:0ms]"}),l.jsx("span",{className:"w-2 h-2 bg-muted-foreground/40 rounded-full animate-bounce [animation-delay:150ms]"}),l.jsx("span",{className:"w-2 h-2 bg-muted-foreground/40 rounded-full animate-bounce [animation-delay:300ms]"})]})})]}),l.jsx("div",{ref:v})]}),l.jsxs("div",{className:"border-t border-border pt-4 pb-4 flex flex-col gap-2",children:[b&&l.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted rounded-lg text-xs text-muted-foreground w-fit",children:[l.jsxs("span",{children:["📎 ",b.name]}),l.jsx("button",{onClick:()=>w(null),className:"hover:text-foreground",children:"✕"})]}),l.jsxs("div",{className:"flex gap-3",children:[l.jsx("input",{ref:S,type:"file",accept:".pdf,.txt,.docx",className:"hidden",onChange:M}),l.jsx(ye,{variant:"outline",size:"icon",className:"h-[60px] w-[60px] flex-shrink-0",onClick:()=>{var N;return(N=S.current)==null?void 0:N.click()},disabled:m,children:l.jsx(V2e,{className:"w-5 h-5"})}),l.jsx(ir,{value:f,onChange:N=>p(N.target.value),onKeyDown:A,placeholder:e?"Ask a question...":"Ask a question… (Enter to send, Shift+Enter for new line)",className:"min-h-[60px] max-h-[160px] resize-none",disabled:m||!s}),l.jsx(ye,{onClick:()=>C(f),disabled:m||!f.trim()||!s,size:"icon",className:"h-[60px] w-[60px] flex-shrink-0",children:l.jsx(Fce,{className:"w-5 h-5"})})]})]})]})]})})}function P4t(){const e=Ch().pathname==="/qualitative/kodierbogen-grid";return l.jsx(gr,{showSidebar:!0,fullWidth:e,children:l.jsx("div",{className:e?"w-full min-w-0":"container mx-auto p-6 max-w-7xl",children:l.jsx(AMe,{})})})}function O4t(){const{user:t,checkStudentPoints:e,studentPoints:r}=Dt(),[n,s]=j.useState(!1),{toast:i}=qn(),[a,o]=j.useState(""),[c,u]=j.useState(""),[d,h]=j.useState(""),[f,p]=j.useState("bachelor"),[m,g]=j.useState(""),[x,y]=j.useState("de"),[v,b]=j.useState(null),[w,S]=j.useState(!1),[k,E]=j.useState("both"),[C,A]=j.useState([]),[M,z]=j.useState("");j.useEffect(()=>{(async()=>{if(!(t!=null&&t.id))return;const{data:K,error:G}=await be.from("summaries").select("id, summary_text").eq("user_id",t.id).eq("summary_mode","topic_explorer").order("created_at",{ascending:!1});if(G){console.error("Error loading topic explorer entries:",G);return}const X=(K||[]).map(H=>{try{const B=JSON.parse(H.summary_text||"{}");return{id:H.id,title:B.title||"Unbenannt",data:B}}catch(B){return console.error("Failed to parse topic explorer entry:",B),null}}).filter(Boolean);A(X)})()},[t==null?void 0:t.id]);const P=()=>{var X;const U=C.find(H=>H.id===M);if(!U)return;const{data:K}=U;o(K.title||""),u(K.objectives||"");const G=((X=K.original_selection)==null?void 0:X.researchQuestions)||[];h(G.join(`
`)),i({title:"Topic adopted",description:"Working title, objectives, and research questions have been completed"})},W=async()=>{if(!e()){s(!0);return}if(!a.trim()){i({title:"Enter Work Title",variant:"destructive"});return}S(!0);try{const U=d.split(`
`).filter(X=>X.trim()),{data:K,error:G}=await be.functions.invoke("research_setup_builder",{body:{title:a.trim(),aim:c.trim(),questions:U,degree:f,discipline:m.trim(),language:x}});if(G)throw G;b(K),i({title:"Research setup successfully generated",description:K.summary_id?"Saved to library":void 0})}catch(U){console.error("Research setup error:",U),i({title:"Error during transfer",variant:"destructive"})}S(!1)},N=async U=>{if(!v)return;const K=v.codebook,G=v.meta??{};if(!K||!K.categories||!K.categories.length){i({title:"No coding sheet generated",variant:"destructive"});return}let X=K.categories;if(U!=="both"&&(X=X.filter(H=>H.source===U)),!X.length){i({title:`No categories found for source "${U}"`,variant:"destructive"});return}try{const{data:H,error:B}=await be.from("codebooks").insert({title:G.title?`Coding sheet – ${G.title}`:"Coding sheet",description:G.aim??null,degree:G.degree??null,discipline:G.discipline??null,language:G.language??null,user_id:t==null?void 0:t.id}).select().single();if(B)throw B;const L=X.map((V,Y)=>({codebook_id:H.id,name:V.name||"Category",definition:V.definition||"",coding_rule:V.coding_rule||"",anchor_example:V.anchor_example||"",order_index:Number.isFinite(V.order_index)?V.order_index:Y})),{error:F}=await be.from("codebook_categories").insert(L);if(F)throw F;i({title:`Coding sheet (${U}) adopted`})}catch(H){console.error(H),i({title:"Error during transfer",variant:"destructive"})}};return l.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Research Design Setup"})}),l.jsxs(Ge,{className:"space-y-4",children:[C.length>0&&l.jsxs("div",{className:"p-4 border rounded-lg space-y-3 bg-inherit",children:[l.jsx(_e,{className:"text-sm font-semibold",children:"Take from Topic Explorer"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(dt,{value:M,onValueChange:z,children:[l.jsx(lt,{className:"flex-1",children:l.jsx(ht,{placeholder:"Select a topic..."})}),l.jsx(ct,{children:C.map(U=>l.jsx(De,{value:U.id,children:U.title},U.id))})]}),l.jsx(ye,{onClick:P,disabled:!M,variant:"secondary",children:"Import topic"})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"title",children:"Working title"}),l.jsx(Be,{id:"title",value:a,onChange:U=>o(U.target.value),placeholder:"Title of the research paper"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"discipline",children:"Discipline"}),l.jsx(Be,{id:"discipline",value:m,onChange:U=>g(U.target.value),placeholder:"e.g., Sociology, Psychology"})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Degree"}),l.jsxs(dt,{value:f,onValueChange:p,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"bachelor",children:"Bachelor"}),l.jsx(De,{value:"master",children:"Master"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Language"}),l.jsxs(dt,{value:x,onValueChange:y,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"de",children:"Deutsch"}),l.jsx(De,{value:"en",children:"English"})]})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"aim",children:"Objectives"}),l.jsx(ir,{id:"aim",value:c,onChange:U=>u(U.target.value),rows:3,placeholder:"Description of research objectives"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{htmlFor:"questions",children:"Existing research questions (one per line)"}),l.jsx(ir,{id:"questions",value:d,onChange:U=>h(U.target.value),rows:4,placeholder:"Research Question 1 Research Question 2 ... "})]}),l.jsx("div",{className:"flex gap-4",children:l.jsxs(ye,{onClick:W,disabled:w,children:[w&&l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Generate Research Setup"]})}),v&&l.jsxs("div",{className:"space-y-4 mt-4",children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Add as Codebook"})}),l.jsxs(Ge,{className:"space-y-3",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Select Source"}),l.jsxs(dt,{value:k,onValueChange:U=>E(U),children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"participant",children:"Participant Interviews"}),l.jsx(De,{value:"expert",children:"Expert Interviews"}),l.jsx(De,{value:"both",children:"Both (merged)"})]})]})]}),l.jsxs(ye,{onClick:()=>N(k),variant:"outline",children:["Add as Codebook (",k,")"]})]})]}),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Forschungskontext"})}),l.jsxs(Ge,{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx(_e,{className:"font-semibold",children:"Titel"}),l.jsx("p",{className:"text-sm",children:v.meta.title})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"font-semibold",children:"Zielsetzung"}),l.jsx("p",{className:"text-sm",children:v.meta.aim})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"font-semibold",children:"Derived Research Questions"}),l.jsx("ul",{className:"list-disc list-inside text-sm space-y-1",children:v.meta.derived_research_questions.map((U,K)=>l.jsx("li",{children:U},K))})]})]})]}),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Teilnehmer-Interview"})}),l.jsxs(Ge,{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx(_e,{className:"font-semibold",children:"Introduction"}),l.jsx("p",{className:"text-sm whitespace-pre-line",children:v.participant_interview.intro})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"font-semibold",children:"Fragen"}),l.jsx("div",{className:"space-y-3 mt-2",children:v.participant_interview.questions.map((U,K)=>l.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[l.jsx("p",{className:"font-medium text-sm",children:U.question}),l.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["→ ",U.maps_to_rq]}),U.probes.length>0&&l.jsxs("div",{className:"mt-2",children:[l.jsx(_e,{className:"text-xs",children:"Nachfragen:"}),l.jsx("ul",{className:"list-disc list-inside text-xs space-y-1 ml-2",children:U.probes.map((G,X)=>l.jsx("li",{children:G},X))})]})]},K))})]})]})]}),l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Experten-Interview"})}),l.jsxs(Ge,{className:"space-y-3",children:[l.jsxs("div",{children:[l.jsx(_e,{className:"font-semibold",children:"Introduction"}),l.jsx("p",{className:"text-sm whitespace-pre-line",children:v.expert_interview.intro})]}),l.jsxs("div",{children:[l.jsx(_e,{className:"font-semibold",children:"Fragen"}),l.jsx("div",{className:"space-y-3 mt-2",children:v.expert_interview.questions.map((U,K)=>l.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[l.jsx("p",{className:"font-medium text-sm",children:U.question}),l.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["→ ",U.maps_to_rq]}),U.probes.length>0&&l.jsxs("div",{className:"mt-2",children:[l.jsx(_e,{className:"text-xs",children:"Nachfragen:"}),l.jsx("ul",{className:"list-disc list-inside text-xs space-y-1 ml-2",children:U.probes.map((G,X)=>l.jsx("li",{children:G},X))})]})]},K))})]})]})]})]})]})]}),l.jsx(Bu,{open:n,onClose:()=>s(!1),remainingPoints:(r==null?void 0:r.remaining)??0})]})}function I4t(){const{user:t}=Dt(),{toast:e}=qn(),[r,n]=j.useState([]),[s,i]=j.useState(""),[a,o]=j.useState([]),[c,u]=j.useState(!1),[d,h]=j.useState("");j.useEffect(()=>{t&&f()},[t]),j.useEffect(()=>{s&&p()},[s]);const f=async()=>{const{data:E,error:C}=await be.from("codebooks").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});C?e({title:"Error loading codebooks",variant:"destructive"}):n(E||[])},p=async()=>{if(!s)return;const{data:E,error:C}=await be.from("codebook_categories").select("*").eq("codebook_id",s).order("order_index",{ascending:!0});C?e({title:"Error loading categories",variant:"destructive"}):o(E||[])},m=async()=>{const E=d.trim();if(!E){e({title:"Please enter title",variant:"destructive"});return}if(!(t!=null&&t.id)){e({title:"Not signed in",variant:"destructive"});return}const C={title:E,user_id:t.id},{data:A,error:M}=await be.from("codebooks").insert(C).select().single();if(M){e({title:"Error creating",variant:"destructive"});return}h(""),await f(),i(A.id),e({title:"Codebook created"})},g=async()=>{if(!s){e({title:"No codebook selected",variant:"destructive"});return}try{const{error:E}=await be.from("codebooks").delete().eq("id",s);if(E)throw E;e({title:"Codebook deleted successfully"}),i(""),o([]),await f()}catch(E){console.error("Delete error:",E),e({title:"Error deleting",variant:"destructive"})}},x=()=>{o([...a,{id:`new-${Date.now()}`,codebook_id:s,name:"",definition:"",coding_rule:"",anchor_example:"",order_index:a.length}])},y=(E,C,A)=>{o(a.map(M=>M.id===E?{...M,[C]:A}:M))},v=async E=>{if(String(E).startsWith("new-")){o(a.filter(C=>C.id!==E));return}try{const{error:C}=await be.from("codebook_categories").delete().eq("id",E);if(C)throw C;o(a.filter(A=>A.id!==E)),e({title:"Category deleted successfully"})}catch{e({title:"Error deleting",variant:"destructive"})}},b=async()=>{if(s){u(!0);try{const E=a.filter(A=>!A.id.startsWith("new-")),C=a.filter(A=>A.id.startsWith("new-")).map(A=>({codebook_id:s,name:A.name,definition:A.definition,coding_rule:A.coding_rule,anchor_example:A.anchor_example,order_index:A.order_index}));if(E.length>0)for(const A of E){const{error:M}=await be.from("codebook_categories").update({name:A.name,definition:A.definition,coding_rule:A.coding_rule,anchor_example:A.anchor_example,order_index:A.order_index}).eq("id",A.id);if(M)throw M}if(C.length>0){const{error:A}=await be.from("codebook_categories").insert(C);if(A)throw A}e({title:"Categories saved successfully"}),p()}catch{e({title:"Error saving",variant:"destructive"})}u(!1)}},w=()=>{if(!s){e({title:"Select codebook",variant:"destructive"});return}const E=[["Category","Definition","Coding Rule","Anchor Example"]];for(const W of a)E.push([(W.name??"").replace(/\r?\n/g," ").trim(),(W.definition??"").replace(/\r?\n/g," ").trim(),(W.coding_rule??"").replace(/\r?\n/g," ").trim(),(W.anchor_example??"").replace(/\r?\n/g," ").trim()]);const C=rk.unparse(E,{delimiter:",",quotes:!0,newline:`\r
`}),A="\uFEFF",M=new Blob([A+C],{type:"text/csv;charset=utf-8"}),z=URL.createObjectURL(M),P=document.createElement("a");P.href=z,P.download=`codebook_${s}.csv`,P.click(),URL.revokeObjectURL(z)},S=async E=>{if(!s){e({title:"Select codebook",variant:"destructive"});return}try{const C=(z,P)=>new Promise((W,N)=>{const U=new FileReader;U.onload=()=>W(U.result),U.onerror=N,U.readAsText(z,P)});let A;try{A=await C(E,"UTF-8"),A.includes("�")&&(A=await C(E,"Windows-1252"))}catch{A=await C(E,"Windows-1252")}const M=A.charCodeAt(0)===65279?A.slice(1):A;if(!M.trim()){e({title:"Error",description:"CSV file is empty",variant:"destructive"});return}rk.parse(M,{header:!0,skipEmptyLines:!0,encoding:"UTF-8",delimiter:"",transformHeader:z=>(z||"").trim(),complete:async z=>{var P;try{if(!((P=z.data)!=null&&P.length)){e({title:"Error",description:"CSV contains no data",variant:"destructive"});return}const W=z.data[0];if(!(W&&W.hasOwnProperty("Category")&&W.hasOwnProperty("Definition")&&W.hasOwnProperty("Coding Rule")&&W.hasOwnProperty("Anchor Example"))){e({title:"Error",description:"CSV must contain headers 'Category', 'Definition', 'Coding Rule', 'Anchor Example'",variant:"destructive"});return}const U=z.data.map(X=>({name:(X.Category||"").trim(),definition:(X.Definition||"").trim(),coding_rule:(X["Coding Rule"]||"").trim(),anchor_example:(X["Anchor Example"]||"").trim()})).filter(X=>X.name);if(U.length===0){e({title:"No valid rows found",description:"No rows with category names",variant:"destructive"});return}let K=0,G=0;for(const X of U)try{const{data:H,error:B}=await be.from("codebook_categories").select("id").eq("codebook_id",s).eq("name",X.name).maybeSingle();if(B){console.error("Query error:",B);continue}if(H&&H.id){const{error:L}=await be.from("codebook_categories").update({definition:X.definition,coding_rule:X.coding_rule,anchor_example:X.anchor_example}).eq("id",H.id);L||K++}else{const{error:L}=await be.from("codebook_categories").insert({...X,codebook_id:s,order_index:U.indexOf(X)});L||G++}}catch(H){console.error("Error processing category:",X.name,H)}e({title:"Import complete",description:`${K} updated, ${G} newly added`}),await p()}catch(W){console.error("Import processing error:",W),e({title:"Error processing data",variant:"destructive"})}},error:z=>{console.error("CSV parsing error:",z),e({title:"Could not read CSV",description:"Please check file format",variant:"destructive"})}})}catch(C){console.error("File reading error:",C),e({title:"Could not read file",variant:"destructive"})}},k=async E=>{try{const{error:C}=await be.from("codebook_categories").update({name:E.name,definition:E.definition,coding_rule:E.coding_rule,anchor_example:E.anchor_example,order_index:E.order_index}).eq("id",E.id);if(C)throw C;e({title:"Category saved"})}catch(C){console.error(C),e({title:"Error saving",variant:"destructive"})}};return l.jsx("div",{className:"space-y-6",children:l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Edit Codebook"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsx("div",{className:"mb-4 p-3 border rounded-md",children:l.jsxs("div",{className:"flex items-end gap-3",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx(_e,{children:"Create New Codebook"}),l.jsx(Be,{value:d,onChange:E=>h(E.target.value),placeholder:"e.g. Codebook – ITIL Challenges"})]}),l.jsxs(ye,{onClick:m,children:[l.jsx(hl,{className:"h-4 w-4 mr-2"}),"Create"]})]})}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Select Codebook"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(dt,{value:s,onValueChange:i,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:r.length?"Select codebook...":"No codebook available yet"})}),l.jsx(ct,{children:r.map(E=>l.jsx(De,{value:E.id,children:E.title},E.id))})]}),s&&l.jsx(ye,{variant:"destructive",size:"icon",onClick:g,title:"Delete codebook",children:l.jsx(xi,{className:"h-4 w-4"})})]})]}),!r.length&&l.jsx("p",{className:"text-sm text-muted-foreground",children:'Create a codebook above or go to "Research Setup" and adopt a generated one.'}),s&&l.jsxs(l.Fragment,{children:[l.jsx(vi,{}),l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(ye,{variant:"outline",onClick:w,children:"Export CSV"}),l.jsxs("div",{children:[l.jsx("input",{id:"csv-import",type:"file",accept:".csv,text/csv",className:"hidden",onChange:E=>{var A;const C=(A=E.target.files)==null?void 0:A[0];C&&S(C),E.currentTarget.value=""}}),l.jsx(_e,{htmlFor:"csv-import",className:"cursor-pointer px-4 py-2 border rounded-md hover:bg-muted text-sm",children:"Import CSV"})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(ye,{onClick:x,size:"sm",children:[l.jsx(hl,{className:"h-4 w-4 mr-2"}),"Add Category"]}),l.jsxs(ye,{onClick:b,disabled:c,variant:"default",size:"sm",children:[c&&l.jsx(xt,{className:"h-4 w-4 mr-2 animate-spin"}),l.jsx(j$,{className:"h-4 w-4 mr-2"}),"Save All"]})]})]}),l.jsx("div",{className:"space-y-4",children:a.map((E,C)=>l.jsx(ze,{children:l.jsx(Ge,{className:"pt-4",children:l.jsxs("div",{className:"grid grid-cols-12 gap-4 items-start",children:[l.jsxs("div",{className:"col-span-3",children:[l.jsx(_e,{children:"Name"}),l.jsx(Be,{value:E.name,onChange:A=>y(E.id,"name",A.target.value),placeholder:"Category name"})]}),l.jsxs("div",{className:"col-span-3",children:[l.jsx(_e,{children:"Definition"}),l.jsx(ir,{value:E.definition||"",onChange:A=>y(E.id,"definition",A.target.value),placeholder:"Category definition",rows:2})]}),l.jsxs("div",{className:"col-span-3",children:[l.jsx(_e,{children:"Coding Rule"}),l.jsx(ir,{value:E.coding_rule||"",onChange:A=>y(E.id,"coding_rule",A.target.value),placeholder:"Rules for coding",rows:2})]}),l.jsxs("div",{className:"col-span-2",children:[l.jsx(_e,{children:"Anchor Example"}),l.jsx(ir,{value:E.anchor_example||"",onChange:A=>y(E.id,"anchor_example",A.target.value),placeholder:'e.g. "As an IT Service Manager I am..."',rows:2})]}),l.jsxs("div",{className:"col-span-1 flex flex-col gap-2 pt-6",children:[l.jsx(ye,{onClick:()=>k(E),size:"sm",variant:"outline",disabled:String(E.id).startsWith("new-"),title:String(E.id).startsWith("new-")?"Click 'Save All' above first":"Save this category",children:l.jsx(j$,{className:"h-4 w-4"})}),l.jsx(ye,{onClick:()=>v(E.id),size:"sm",variant:"destructive",children:l.jsx(xi,{className:"h-4 w-4"})})]})]})})},E.id))})]})]})]})})}function R4t({open:t,onOpenChange:e,categoryId:r,categoryName:n,interviewId:s,interviewTitle:i,codebookId:a,onSuccess:o}){const[c,u]=j.useState([]),[d,h]=j.useState(!1),[f,p]=j.useState(!1),{toast:m}=qn();j.useEffect(()=>{t&&r&&s&&g()},[t,r,s]);const g=async()=>{h(!0);try{const{data:w,error:S}=await be.from("coded_segments").select("id, snippet").eq("category_id",r).eq("interview_id",s).order("created_at",{ascending:!0});if(S)throw S;w&&w.length>0?u(w.map(k=>({id:k.id,snippet:k.snippet}))):u([{id:crypto.randomUUID(),snippet:"",isNew:!0}])}catch(w){m({title:"Error loading snippets",description:w.message,variant:"destructive"}),u([{id:crypto.randomUUID(),snippet:"",isNew:!0}])}finally{h(!1)}},x=()=>{u([...c,{id:crypto.randomUUID(),snippet:"",isNew:!0}])},y=w=>{if(c.length===1){m({title:"Cannot delete",description:"At least one snippet must remain",variant:"destructive"});return}u(c.filter(S=>S.id!==w))},v=(w,S)=>{u(c.map(k=>k.id===w?{...k,snippet:S}:k))},b=async()=>{p(!0);try{const{data:{user:w}}=await be.auth.getUser();if(!w)throw new Error("Not authenticated");const S=c.filter(z=>!z.isNew),k=c.filter(z=>z.isNew),{data:E}=await be.from("coded_segments").select("id").eq("category_id",r).eq("interview_id",s),C=(E==null?void 0:E.map(z=>z.id))||[],A=S.map(z=>z.id),M=C.filter(z=>!A.includes(z));if(M.length>0){const{error:z}=await be.from("coded_segments").delete().in("id",M);if(z)throw z}for(const z of S){const{error:P}=await be.from("coded_segments").update({snippet:z.snippet}).eq("id",z.id);if(P)throw P}if(k.length>0){const{error:z}=await be.from("coded_segments").insert(k.map(P=>({user_id:w.id,interview_id:s,codebook_id:a,category_id:r,snippet:P.snippet,start_char:0,end_char:P.snippet.length})));if(z)throw z}m({title:"Success",description:"Snippets saved successfully"}),o(),e(!1)}catch(w){m({title:"Error saving snippets",description:w.message,variant:"destructive"})}finally{p(!1)}};return l.jsx(Gr,{open:t,onOpenChange:e,children:l.jsxs(zr,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[l.jsx(Ur,{children:l.jsxs(Hr,{children:["Edit Snippets: ",n," - ",i]})}),d?l.jsx("div",{className:"py-8 text-center text-muted-foreground",children:"Loading..."}):l.jsxs("div",{className:"space-y-4",children:[c.map((w,S)=>l.jsxs("div",{className:"space-y-2 p-4 border border-border rounded-lg",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs(_e,{htmlFor:`snippet-${w.id}`,children:["Snippet ",S+1]}),l.jsx(ye,{type:"button",variant:"ghost",size:"sm",onClick:()=>y(w.id),disabled:c.length===1,children:l.jsx(xi,{className:"h-4 w-4"})})]}),l.jsx(ir,{id:`snippet-${w.id}`,value:w.snippet,onChange:k=>v(w.id,k.target.value),placeholder:"Enter snippet text...",className:"min-h-[100px]"})]},w.id)),l.jsxs(ye,{type:"button",variant:"outline",onClick:x,className:"w-full",children:[l.jsx(hl,{className:"h-4 w-4 mr-2"}),"Add Snippet"]})]}),l.jsxs(Th,{children:[l.jsx(ye,{type:"button",variant:"outline",onClick:()=>e(!1),disabled:f,children:"Cancel"}),l.jsx(ye,{type:"button",onClick:b,disabled:f||d,children:f?"Saving...":"Save Changes"})]})]})})}function M4t(){const[t,e]=j.useState([]),[r,n]=j.useState(""),[s,i]=j.useState([]),[a,o]=j.useState([]),[c,u]=j.useState({}),[d,h]=j.useState(!1),[f,p]=j.useState(!0),[m,g]=j.useState(""),[x,y]=j.useState(null),[v,b]=j.useState(!1),[w,S]=j.useState(null),k=j.useRef(null),[E,C]=j.useState(!1),[A,M]=j.useState("error"),[z,P]=j.useState(""),[W,N]=j.useState(""),[U,K]=j.useState([]),[G,X]=j.useState(null),[H,B]=j.useState(!1),{toast:L}=qn(),F=async()=>{p(!0);try{const{data:ae,error:q}=await be.from("codebooks").select("id, title").order("created_at",{ascending:!1});if(q)throw q;ae&&ae.length>0&&(e(ae),n(ae[0].id))}catch(ae){L({title:"Error loading codebooks",description:ae.message,variant:"destructive"})}finally{p(!1)}},V=async ae=>{if(!ae){i([]),o([]);return}h(!0);try{const{data:q,error:I}=await be.from("v_category_interview_matrix").select("*").eq("codebook_id",ae);if(I)throw I;const T={},$=new Set,se={};q==null||q.forEach(ne=>{var me;T[ne.category_id]||(T[ne.category_id]={category_id:ne.category_id,category_name:ne.category_name,order_index:ne.order_index||0,definition:ne.definition,coding_rule:ne.coding_rule,anchor_example:ne.anchor_example},se[ne.category_id]={}),ne.interview_title&&($.add(ne.interview_title),T[ne.category_id][ne.interview_title]=((me=ne.snippets)==null?void 0:me.join(`
— `))||"",se[ne.category_id][ne.interview_title]={interview_id:ne.interview_id,snippets:ne.snippets||[]})});const ue=Object.values(T).sort((ne,me)=>ne.order_index-me.order_index);i(ue),o(Array.from($)),u(se)}catch(q){L({title:"Error loading data",description:q.message,variant:"destructive"})}finally{h(!1)}};j.useEffect(()=>{F()},[]),j.useEffect(()=>{r&&V(r)},[r]);const Y=async(ae,q,I)=>{try{const T={};q==="definition"&&(T.definition=I),q==="coding_rule"&&(T.coding_rule=I),q==="anchor_example"&&(T.anchor_example=I);const{error:$}=await be.from("codebook_categories").update(T).eq("id",ae);if($)throw $;L({title:"Success",description:"Category updated successfully"}),r&&await V(r)}catch(T){L({title:"Error updating category",description:T.message,variant:"destructive"})}},ie=(ae,q,I)=>{var $;const T=($=c[ae])==null?void 0:$[I];if(!T){L({title:"Error",description:"Interview data not found",variant:"destructive"});return}S({categoryId:ae,categoryName:q,interviewId:T.interview_id,interviewTitle:I}),b(!0)},Q=()=>{r&&V(r)},D=()=>{const ae=[["Category","Definition","Coding Rule","Anchor Example",...a]];O.forEach(ue=>{ae.push([(ue.category_name??"").toString().replace(/\r?\n/g," ").replace(/"/g,'""').trim(),(ue.definition??"").toString().replace(/\r?\n/g," ").replace(/"/g,'""').trim(),(ue.coding_rule??"").toString().replace(/\r?\n/g," ").replace(/"/g,'""').trim(),(ue.anchor_example??"").toString().replace(/\r?\n/g," ").replace(/"/g,'""').trim(),...a.map(ne=>{const me=ue[ne];return(typeof me=="string"?me:(me??"").toString()).replace(/"/g,'""').replace(/\r?\n/g," ").trim()})])});const q=rk.unparse(ae,{delimiter:";",quotes:!0,escapeFormulae:!0,newline:`\r
`}),I="\uFEFF",T=new Blob([I+q],{type:"text/csv;charset=utf-8"}),$=URL.createObjectURL(T),se=document.createElement("a");se.href=$,se.download="codebook_grid.csv",se.click(),URL.revokeObjectURL($)},R=()=>{var ae;(ae=k.current)==null||ae.click()},J=async ae=>{var I;const q=(I=ae.target.files)==null?void 0:I[0];if(q){if(ae.target.value="",!r){L({title:"Error",description:"Please select a codebook first",variant:"destructive"});return}B(!0),rk.parse(q,{delimiter:";",header:!0,skipEmptyLines:!0,encoding:"UTF-8",complete:async T=>{try{await Z(T.data)}catch($){L({title:"Import-Error",description:$.message,variant:"destructive"})}finally{B(!1)}},error:T=>{B(!1),L({title:"Error reading CSV file",description:T.message,variant:"destructive"})}})}},Z=async ae=>{var Se;if(!ae||ae.length===0)throw new Error("CSV file is empty");const q=ae[0],I=["Category","Definition","Coding Rule","Anchor Example"],T=I.filter(ke=>!(ke in q));if(T.length>0)throw new Error(`Missing columns: ${T.join(", ")}`);const $=Object.keys(q).filter(ke=>!I.includes(ke)),{data:se,error:ue}=await be.from("codebook_categories").select("id, name").eq("codebook_id",r);if(ue)throw ue;const ne=new Map((se==null?void 0:se.map(ke=>[ke.name,ke.id]))||[]),ve=ae.map(ke=>ke.Category).filter(Boolean).filter(ke=>!ne.has(ke));if(ve.length>0){M("error"),P("Missing Categories"),N(`The following categories do not exist in the codebook. :
${ve.join(`
`)}
Please add these categories to the codebook first.`),C(!0);return}const{data:xe,error:oe}=await be.from("interviews").select("id, title").eq("user_id",(Se=(await be.auth.getUser()).data.user)==null?void 0:Se.id);if(oe)throw oe;const de=new Map((xe==null?void 0:xe.map(ke=>[ke.title,ke.id]))||[]),ge=$.filter(ke=>!de.has(ke));if(ge.length>0){M("warning"),P("Missing Interviews"),N(`The following interviews do not exist:
${ge.join(`
`)}
How would you like to proceed??`),K(ge),X({csvData:ae,categoryMap:ne,interviewMap:de,csvInterviewColumns:$}),C(!0);return}ee(ae,ne,de,$)},ee=(ae,q,I,T)=>{const $=new Set(ae.map(ue=>ue.Category)).size,se=T.filter(ue=>I.has(ue)).length;M("confirm"),P("Confirm Import"),N(`You are about to overwrite the codebook:
• ${$} categories will be updated
• ${se} interviews will be overwritten
• Existing codings will be replaced
Do you want to continue?`),X({csvData:ae,categoryMap:q,interviewMap:I,csvInterviewColumns:T}),C(!0)},re=async(ae=!1)=>{var ue;if(!G)return;const{csvData:q,categoryMap:I,interviewMap:T,csvInterviewColumns:$}=G,se=(ue=(await be.auth.getUser()).data.user)==null?void 0:ue.id;if(!se){L({title:"Error",description:"User not authenticated",variant:"destructive"});return}B(!0),C(!1);try{let ne=new Map(T);if(ae&&U.length>0)for(const ve of U){const{data:xe,error:oe}=await be.from("interviews").insert({user_id:se,title:ve,raw_text:"[Placeholder - Please add interview text]",source:"CSV Import"}).select("id").single();if(oe)throw oe;ne.set(ve,xe.id)}let me=0;for(const ve of q){const xe=ve.Category,oe=I.get(xe);if(oe)for(const de of $){const ge=ne.get(de);if(!ge)continue;const Se=ve[de]||"",{error:ke}=await be.from("coded_segments").delete().eq("category_id",oe).eq("interview_id",ge).eq("codebook_id",r);if(ke)throw ke;if(Se.trim()){const qe=Se.split(/\s*\|\s*/).filter(Ae=>Ae.trim()).map(Ae=>({user_id:se,interview_id:ge,codebook_id:r,category_id:oe,snippet:Ae.trim(),start_char:-1,end_char:-1}));if(qe.length>0){const{error:Ae}=await be.from("coded_segments").insert(qe);if(Ae)throw Ae;me+=qe.length}}}}L({title:"✅ Import successful",description:`${q.length} categories updated, ${me} snippets imported`}),await V(r)}catch(ne){L({title:"Import failed",description:ne.message,variant:"destructive"})}finally{B(!1),X(null),K([])}},he=ae=>{if(C(!1),ae==="cancel"){X(null),K([]);return}if(ae==="skip"&&G){const{csvData:q,categoryMap:I,interviewMap:T}=G,$=Object.keys(q[0]).filter(se=>!["Category","Definition","Coding Rule","Anchor Example"].includes(se)&&T.has(se));ee(q,I,T,$);return}if(ae==="placeholder"&&G){const{csvData:q,categoryMap:I,interviewMap:T,csvInterviewColumns:$}=G;ee(q,I,T,$);return}ae==="confirm"&&re(U.length>0)},O=s.filter(ae=>ae.category_name.toLowerCase().includes(m.toLowerCase()));return f?l.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:l.jsx(xt,{className:"h-8 w-8 animate-spin text-primary"})}):l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Codingbook (Grid)"}),l.jsx("p",{className:"text-muted-foreground mt-2",children:"Excel-like view of your entire codebook with all interviews"})]}),l.jsxs(ze,{className:"p-4 space-y-4",children:[l.jsxs("div",{children:[l.jsx(_e,{htmlFor:"codebook-select",className:"text-sm font-medium mb-2 block",children:"Select Coding Book"}),l.jsxs(dt,{value:r,onValueChange:n,children:[l.jsx(lt,{id:"codebook-select",className:"w-full max-w-md",children:l.jsx(ht,{placeholder:"Please select a codebook"})}),l.jsx(ct,{children:t.map(ae=>l.jsx(De,{value:ae.id,children:ae.title},ae.id))})]})]}),r&&l.jsxs("div",{className:"flex gap-4 items-center justify-between",children:[l.jsxs("div",{className:"relative flex-1 max-w-sm",children:[l.jsx(yl,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),l.jsx(Be,{placeholder:"Search categories...",value:m,onChange:ae=>g(ae.target.value),className:"pl-9"})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx("input",{ref:k,type:"file",accept:".csv",onChange:J,className:"hidden"}),l.jsxs(ye,{onClick:R,variant:"outline",disabled:H,children:[H?l.jsx(xt,{className:"h-4 w-4 mr-2 animate-spin"}):l.jsx(hh,{className:"h-4 w-4 mr-2"}),"Import CSV"]}),l.jsxs(ye,{onClick:D,variant:"outline",children:[l.jsx(Ga,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})]})]}),r?d?l.jsx(ze,{className:"p-12",children:l.jsx("div",{className:"flex items-center justify-center",children:l.jsx(xt,{className:"h-8 w-8 animate-spin text-primary"})})}):l.jsxs(ze,{className:"overflow-hidden",children:[l.jsx("div",{className:"overflow-x-auto",children:l.jsxs("table",{className:"w-full border-collapse",children:[l.jsx("thead",{className:"sticky top-0 bg-muted z-10",children:l.jsxs("tr",{children:[l.jsx("th",{className:"border border-border p-3 text-left font-semibold text-sm min-w-[150px]",children:"Category"}),l.jsx("th",{className:"border border-border p-3 text-left font-semibold text-sm min-w-[200px]",children:"Definition"}),l.jsx("th",{className:"border border-border p-3 text-left font-semibold text-sm min-w-[200px]",children:"Coding Rule"}),l.jsx("th",{className:"border border-border p-3 text-left font-semibold text-sm min-w-[200px]",children:"Anchor Example"}),a.map(ae=>l.jsx("th",{className:"border border-border p-3 text-left font-semibold text-sm min-w-[250px]",children:ae},ae))]})}),l.jsx("tbody",{children:O.map(ae=>l.jsxs("tr",{className:"hover:bg-muted/50 transition-colors",children:[l.jsx("td",{className:"border border-border p-3 text-sm font-medium",children:ae.category_name}),l.jsx("td",{className:"border border-border p-3 text-sm cursor-pointer hover:bg-accent/10",onClick:()=>y({rowId:ae.category_id,field:"definition"}),children:(x==null?void 0:x.rowId)===ae.category_id&&(x==null?void 0:x.field)==="definition"?l.jsx("textarea",{autoFocus:!0,defaultValue:ae.definition||"",onBlur:q=>{Y(ae.category_id,"definition",q.target.value),y(null)},onKeyDown:q=>{q.key==="Escape"&&y(null),q.key==="Enter"&&q.ctrlKey&&(Y(ae.category_id,"definition",q.currentTarget.value),y(null))},className:"w-full p-2 border-2 border-primary rounded bg-yellow-50 dark:bg-yellow-950/20 text-sm resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-primary"}):l.jsx("div",{className:"whitespace-pre-wrap",children:ae.definition||"—"})}),l.jsx("td",{className:"border border-border p-3 text-sm cursor-pointer hover:bg-accent/10",onClick:()=>y({rowId:ae.category_id,field:"coding_rule"}),children:(x==null?void 0:x.rowId)===ae.category_id&&(x==null?void 0:x.field)==="coding_rule"?l.jsx("textarea",{autoFocus:!0,defaultValue:ae.coding_rule||"",onBlur:q=>{Y(ae.category_id,"coding_rule",q.target.value),y(null)},onKeyDown:q=>{q.key==="Escape"&&y(null),q.key==="Enter"&&q.ctrlKey&&(Y(ae.category_id,"coding_rule",q.currentTarget.value),y(null))},className:"w-full p-2 border-2 border-primary rounded bg-yellow-50 dark:bg-yellow-950/20 text-sm resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-primary"}):l.jsx("div",{className:"whitespace-pre-wrap",children:ae.coding_rule||"—"})}),l.jsx("td",{className:"border border-border p-3 text-sm cursor-pointer hover:bg-accent/10",onClick:()=>y({rowId:ae.category_id,field:"anchor_example"}),children:(x==null?void 0:x.rowId)===ae.category_id&&(x==null?void 0:x.field)==="anchor_example"?l.jsx("textarea",{autoFocus:!0,defaultValue:ae.anchor_example||"",onBlur:q=>{Y(ae.category_id,"anchor_example",q.target.value),y(null)},onKeyDown:q=>{q.key==="Escape"&&y(null),q.key==="Enter"&&q.ctrlKey&&(Y(ae.category_id,"anchor_example",q.currentTarget.value),y(null))},className:"w-full p-2 border-2 border-primary rounded bg-yellow-50 dark:bg-yellow-950/20 text-sm resize-none min-h-[80px] focus:outline-none focus:ring-2 focus:ring-primary"}):l.jsx("div",{className:"whitespace-pre-wrap",children:ae.anchor_example||"—"})}),a.map(q=>l.jsx("td",{className:"border border-border p-3 text-sm align-top cursor-pointer hover:bg-accent/10",onClick:()=>ie(ae.category_id,ae.category_name,q),children:l.jsx("div",{className:"whitespace-pre-wrap text-muted-foreground",children:ae[q]||"—"})},q))]},ae.category_id))})]})}),O.length===0&&l.jsx("div",{className:"text-center py-12 text-muted-foreground",children:l.jsx("p",{children:"No categories found"})})]}):l.jsx(ze,{className:"p-12",children:l.jsx("div",{className:"text-center text-muted-foreground",children:l.jsx("p",{className:"text-lg",children:"Please select a codebook to view the data."})})}),v&&w&&r&&l.jsx(R4t,{open:v,onOpenChange:b,categoryId:w.categoryId,categoryName:w.categoryName,interviewId:w.interviewId,interviewTitle:w.interviewTitle,codebookId:r,onSuccess:Q}),l.jsx(va,{open:E,onOpenChange:C,children:l.jsxs(Hi,{children:[l.jsxs(Vi,{children:[l.jsxs(qi,{className:"flex items-center gap-2",children:[A==="error"&&l.jsx(rj,{className:"h-5 w-5 text-destructive"}),z]}),l.jsx(Gi,{className:"whitespace-pre-line",children:W})]}),l.jsxs(Wi,{children:[A==="error"&&l.jsx(bi,{onClick:()=>he("cancel"),children:"OK"}),A==="warning"&&l.jsxs(l.Fragment,{children:[l.jsx(ji,{onClick:()=>he("cancel"),children:"Abbrechen"}),l.jsx(ye,{onClick:()=>he("skip"),variant:"outline",children:"Nur existierende importieren"}),l.jsx(bi,{onClick:()=>he("placeholder"),children:"Mit Platzhaltern fortfahren"})]}),A==="confirm"&&l.jsxs(l.Fragment,{children:[l.jsx(ji,{onClick:()=>he("cancel"),children:"Abbrechen"}),l.jsx(bi,{onClick:()=>he("confirm"),children:"Import durchführen"})]})]})]})})]})}function D4t(){const{user:t}=Dt(),{toast:e}=qn(),[r,n]=j.useState([]),[s,i]=j.useState({title:"",source:"",raw_text:""}),[a,o]=j.useState(null),[c,u]=j.useState(null),[d,h]=j.useState({title:"",source:"",raw_text:""}),[f,p]=j.useState(!1);j.useEffect(()=>{t&&m()},[t]);const m=async()=>{const{data:v,error:b}=await be.from("interviews").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});b?e({title:"Error loading interviews",variant:"destructive"}):n(v||[])},g=async()=>{if(!s.title.trim()||!s.raw_text.trim()){e({title:"Title and text are required",variant:"destructive"});return}try{const{error:v}=await be.from("interviews").insert({title:s.title.trim(),source:s.source.trim(),raw_text:s.raw_text.trim(),user_id:t==null?void 0:t.id});if(v)throw v;e({title:"Interview added successfully"}),i({title:"",source:"",raw_text:""}),m()}catch{e({title:"Error adding",variant:"destructive"})}},x=v=>{u(v),h({title:v.title,source:v.source||"",raw_text:v.raw_text})},y=async()=>{if(!c||!d.title.trim()||!d.raw_text.trim()){e({title:"Title and text are required",variant:"destructive"});return}p(!0);try{const{error:v}=await be.from("interviews").update({title:d.title.trim(),source:d.source.trim(),raw_text:d.raw_text.trim()}).eq("id",c.id);if(v)throw v;e({title:"Interview updated successfully"}),u(null),m()}catch{e({title:"Error updating interview",variant:"destructive"})}finally{p(!1)}};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Manage Interviews"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Title"}),l.jsx(Be,{value:s.title,onChange:v=>i({...s,title:v.target.value}),placeholder:"Interview Title"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Source (optional)"}),l.jsx(Be,{value:s.source,onChange:v=>i({...s,source:v.target.value}),placeholder:"e.g. Person A, Document XYZ"})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Interview Text"}),l.jsx(ir,{value:s.raw_text,onChange:v=>i({...s,raw_text:v.target.value}),placeholder:"Complete interview text...",rows:8})]}),l.jsxs(ye,{onClick:g,children:[l.jsx(hl,{className:"h-4 w-4 mr-2"}),"Add Interview"]}),l.jsx(vi,{}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("h3",{className:"font-medium",children:["Existing Interviews (",r.length,")"]}),r.map(v=>l.jsx(ze,{children:l.jsxs(Ge,{className:"pt-4",children:[l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium",children:v.title}),v.source&&l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Source: ",v.source]}),l.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(v.created_at).toLocaleDateString()})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(ye,{onClick:()=>o(a===v.id?null:v.id),size:"sm",variant:"outline",children:[l.jsx(Xa,{className:"h-4 w-4 mr-2"}),a===v.id?"Close":"View Text"]}),l.jsxs(ye,{onClick:()=>x(v),size:"sm",variant:"outline",children:[l.jsx(Mce,{className:"h-4 w-4 mr-2"}),"Edit Interview"]})]})]}),a===v.id&&l.jsx("div",{className:"mt-4 p-4 bg-muted rounded max-h-60 overflow-y-auto",children:l.jsx("pre",{className:"whitespace-pre-wrap text-sm",children:v.raw_text})})]})},v.id))]})]})]}),l.jsx(Gr,{open:!!c,onOpenChange:v=>!v&&u(null),children:l.jsxs(zr,{className:"max-w-2xl",children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Edit Interview"})}),l.jsxs("div",{className:"space-y-4 py-4",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Title"}),l.jsx(Be,{value:d.title,onChange:v=>h({...d,title:v.target.value}),placeholder:"Interview Title"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Source (optional)"}),l.jsx(Be,{value:d.source,onChange:v=>h({...d,source:v.target.value}),placeholder:"e.g. Person A, Document XYZ"})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Interview Text"}),l.jsx(ir,{value:d.raw_text,onChange:v=>h({...d,raw_text:v.target.value}),placeholder:"Complete interview text...",rows:12})]})]}),l.jsxs(Th,{children:[l.jsx(ye,{variant:"outline",onClick:()=>u(null),children:"Cancel"}),l.jsx(ye,{onClick:y,disabled:f,children:f?"Saving...":"Save Changes"})]})]})})]})}function L4t({selectedCodebook:t,selectedInterviews:e,categories:r,interviews:n,userId:s,onCodingComplete:i}){const{toast:a}=qn(),[o,c]=j.useState([]),[u,d]=j.useState(!1),[h,f]=j.useState(!1),[p,m]=j.useState(new Set),[g,x]=j.useState(new Set);j.useEffect(()=>{t&&e.length>0?y():c([])},[t,e]);const y=async()=>{d(!0);try{const{data:C,error:A}=await be.from("coded_segments").select("*").eq("user_id",s).eq("codebook_id",t).in("interview_id",e).order("created_at",{ascending:!1});if(A)throw A;c(C||[])}catch(C){console.error("Error loading segments:",C),a({title:"Error loading segments",variant:"destructive"})}finally{d(!1)}},v=async(C,A)=>{f(!0);try{const M={codebook_id:t,interview_id:C};A&&(M.overwrite_existing=!0);const{data:z,error:P}=await be.functions.invoke("codebooks_apply",{body:M});if(P)throw P;a({title:`${z.created_segments} Segmente erstellt`,description:A?"Existing ones overwritten":"New added"}),await y(),i==null||i()}catch(M){console.error("Recode error:",M),a({title:"Encoding errors",variant:"destructive"})}finally{f(!1)}},b=()=>{const C={};return o.forEach(A=>{C[A.interview_id]||(C[A.interview_id]={}),C[A.interview_id][A.category_id]||(C[A.interview_id][A.category_id]=[]),C[A.interview_id][A.category_id].push(A)}),C},w=C=>{const A=new Set(p);A.has(C)?A.delete(C):A.add(C),m(A)},S=C=>{const A=new Set(g);A.has(C)?A.delete(C):A.add(C),x(A)},k=(C,A=220)=>C.length<=A?{truncated:C,isTruncated:!1}:{truncated:C.substring(0,A)+"...",isTruncated:!0};if(!t||e.length===0)return null;const E=b();return u?l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Latest encodings"})}),l.jsx(Ge,{className:"flex justify-center items-center py-8",children:l.jsx(xt,{className:"h-8 w-8 animate-spin"})})]}):o.length===0?l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Latest encodings"})}),l.jsx(Ge,{children:l.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[l.jsx("p",{children:"No codes are available yet."}),l.jsx("p",{className:"text-sm mt-2",children:"First, perform an automatic encoding."})]})})]}):l.jsxs(ze,{children:[l.jsx(et,{children:l.jsxs(at,{children:["Latest encodings (",o.length," Segmente)"]})}),l.jsx(Ge,{className:"space-y-6",children:e.map(C=>{const A=n.find(P=>P.id===C),M=E[C];if(!A||!M)return null;const z=Object.values(M).reduce((P,W)=>P+W.length,0);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold text-lg",children:A.title}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:[z," Segmente"]})]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(ye,{onClick:()=>v(C,!0),disabled:h,variant:"outline",size:"sm",children:[h&&l.jsx(xt,{className:"mr-2 h-3 w-3 animate-spin"}),"Overwrite"]}),l.jsxs(ye,{onClick:()=>v(C,!1),disabled:h,variant:"outline",size:"sm",children:[h&&l.jsx(xt,{className:"mr-2 h-3 w-3 animate-spin"}),"Attach"]})]})]}),l.jsx("div",{className:"space-y-3",children:Object.entries(M).map(([P,W])=>{const N=r.find(H=>H.id===P),U=`${C}-${P}`,K=p.has(U),G=K?W:W.slice(0,3),X=W.length>3;return l.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[l.jsxs("div",{className:"flex justify-between items-start",children:[l.jsxs("div",{children:[l.jsx("h4",{className:"font-medium",children:(N==null?void 0:N.name)||"Unknown category"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[W.length," ",W.length===1?"Segment":"Segmente"]})]}),X&&l.jsx(ye,{onClick:()=>w(U),variant:"ghost",size:"sm",children:K?l.jsxs(l.Fragment,{children:[l.jsx(Ace,{className:"h-4 w-4 mr-1"}),"Fewer"]}):l.jsxs(l.Fragment,{children:[l.jsx(Eh,{className:"h-4 w-4 mr-1"}),"Show all"]})})]}),l.jsx("div",{className:"space-y-2",children:G.map(H=>{var Y;const{truncated:B,isTruncated:L}=k(H.snippet),F=g.has(H.id),V=F?H.snippet:B;return l.jsxs("div",{className:"bg-muted/50 rounded p-3 space-y-2",children:[l.jsx("p",{className:"text-sm whitespace-pre-wrap",children:V}),L&&l.jsx(ye,{onClick:()=>S(H.id),variant:"ghost",size:"sm",className:"h-6 text-xs",children:F?"Show less":"Show full text"}),l.jsxs("div",{className:"flex gap-4 text-xs text-muted-foreground pt-2 border-t",children:[l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Confidence:"})," ",((Y=H.confidence)==null?void 0:Y.toFixed(2))||"N/A"]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Position:"})," ",H.start_char,"–",H.end_char]}),l.jsxs("div",{children:[l.jsx(_e,{className:"text-xs",children:"Created:"})," ",new Date(H.created_at).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})]})]})]},H.id)})})]},U)})})]},C)})})]})}function F4t(){const{user:t,checkStudentPoints:e,studentPoints:r}=Dt(),[n,s]=j.useState(!1),{toast:i}=qn(),[a,o]=j.useState([]),[c,u]=j.useState(""),[d,h]=j.useState([]),[f,p]=j.useState([]),[m,g]=j.useState([]),[x,y]=j.useState([]),[v,b]=j.useState(!1),[w,S]=j.useState("all");j.useEffect(()=>{t&&(k(),C())},[t]),j.useEffect(()=>{c&&E()},[c]),j.useEffect(()=>{c&&m.length>0&&M()},[c,m]);const k=async()=>{const{data:P,error:W}=await be.from("codebooks").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});W?i({title:"Error loading codebooks",variant:"destructive"}):o(P||[])},E=async()=>{if(!c)return;const{data:P,error:W}=await be.from("codebook_categories").select("*").eq("codebook_id",c).order("order_index",{ascending:!0});W?i({title:"Error loading categories",variant:"destructive"}):h(P||[])},C=async()=>{const{data:P,error:W}=await be.from("interviews").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});W?i({title:"Error loading interviews",variant:"destructive"}):p(P||[])},A=async()=>{if(!e()){s(!0);return}if(!c||m.length===0){i({title:"Select codebook and interviews",variant:"destructive"});return}b(!0);try{for(const P of m){const{data:W,error:N}=await be.functions.invoke("codebooks_apply",{body:{codebook_id:c,interview_id:P}});if(N)throw N;i({title:`${W.created_segments} Segments created for interview`})}M()}catch{i({title:"Error during automatic coding",variant:"destructive"})}b(!1)},M=async()=>{if(!c||m.length===0)return;const{data:P,error:W}=await be.from("coded_segments").select("*").eq("user_id",t==null?void 0:t.id).eq("codebook_id",c).in("interview_id",m).order("created_at",{ascending:!1});W?i({title:"Error loading coded segments",variant:"destructive"}):y(P||[])},z=w==="all"?x:x.filter(P=>P.category_id===w);return l.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Automatic coding"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Coding sheet"}),l.jsxs(dt,{value:c,onValueChange:u,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select codebook..."})}),l.jsx(ct,{children:a.map(P=>l.jsx(De,{value:P.id,children:P.title},P.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Interviews"}),l.jsxs(dt,{value:m.join(","),onValueChange:P=>g(P?[P]:[]),children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select interview..."})}),l.jsx(ct,{children:f.map(P=>l.jsx(De,{value:P.id,children:P.title},P.id))})]})]})]}),l.jsxs(ye,{onClick:A,disabled:v,children:[v&&l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Automatic encoding"]}),c&&m.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(vi,{}),l.jsxs("div",{className:"flex justify-between items-center",children:[l.jsxs("h3",{className:"font-medium",children:["Coded segments (",z.length,")"]}),l.jsxs(dt,{value:w,onValueChange:S,children:[l.jsx(lt,{className:"w-48",children:l.jsx(ht,{placeholder:"Filter by category..."})}),l.jsxs(ct,{children:[l.jsx(De,{value:"all",children:"All categories"}),d.map(P=>l.jsx(De,{value:P.id,children:P.name},P.id))]})]})]}),l.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:z.map(P=>{var N;const W=d.find(U=>U.id===P.category_id);return l.jsx(ze,{children:l.jsx(Ge,{className:"pt-4",children:l.jsxs("div",{className:"grid grid-cols-12 gap-4 items-start",children:[l.jsxs("div",{className:"col-span-2",children:[l.jsx(_e,{className:"text-xs",children:"category"}),l.jsx("p",{className:"text-sm font-medium",children:(W==null?void 0:W.name)||"Unknown"})]}),l.jsxs("div",{className:"col-span-5",children:[l.jsx(_e,{className:"text-xs",children:"Snippet"}),l.jsx("p",{className:"text-sm",children:P.snippet})]}),l.jsxs("div",{className:"col-span-3",children:[l.jsx(_e,{className:"text-xs",children:"Memo"}),l.jsx(ir,{value:P.memo||"",placeholder:"Add memo...",rows:2,className:"text-xs"})]}),l.jsxs("div",{className:"col-span-1",children:[l.jsx(_e,{className:"text-xs",children:"Confidence"}),l.jsx("p",{className:"text-sm",children:((N=P.confidence)==null?void 0:N.toFixed(2))||"N/A"})]}),l.jsxs("div",{className:"col-span-1",children:[l.jsx(_e,{className:"text-xs",children:"Position"}),l.jsxs("p",{className:"text-xs",children:[P.start_char,"-",P.end_char]})]})]})})},P.id)})})]})]})]}),l.jsx(L4t,{selectedCodebook:c,selectedInterviews:m,categories:d,interviews:f,userId:t==null?void 0:t.id,onCodingComplete:M}),l.jsx(Bu,{open:n,onClose:()=>s(!1),remainingPoints:(r==null?void 0:r.remaining)??0})]})}const vae={small:{wordMin:150,wordMax:300,overheadTokens:600},medium:{wordMin:300,wordMax:600,overheadTokens:700},big:{wordMin:500,wordMax:900,overheadTokens:800}},$4t=t=>Math.round(t*1.4),B4t=t=>Math.round(t/4);function z4t(){const{user:t,checkStudentPoints:e,studentPoints:r}=Dt(),[n,s]=j.useState(!1),{toast:i}=qn(),[a,o]=j.useState([]),[c,u]=j.useState(""),[d,h]=j.useState([]),[f,p]=j.useState(""),[m,g]=j.useState("medium"),[x,y]=j.useState("de"),[v,b]=j.useState(null),[w,S]=j.useState(!1),[k,E]=j.useState([]),[C,A]=j.useState(""),[M,z]=j.useState([]),[P,W]=j.useState(""),[N,U]=j.useState({prompt:0,completion:0,total:0}),[K,G]=j.useState(null),[X,H]=j.useState([]),[B,L]=j.useState(!1),[F,V]=j.useState(""),[Y,ie]=j.useState(""),[Q,D]=j.useState(!1);j.useEffect(()=>{t&&(Z(),re())},[t]),j.useEffect(()=>{c&&ee()},[c]),j.useEffect(()=>{C?(he(),R()):(z([]),W(""),H([]),V(""))},[C]);const R=async()=>{const{data:T}=await be.from("chapters").select("id, title, order_index").eq("thesis_id",C).order("order_index");H(T||[])},J=async()=>{if(!(!F||!v)){D(!0);try{const{data:T}=await be.from("sections").select("order_index").eq("chapter_id",F).order("order_index",{ascending:!1}).limit(1),$=T!=null&&T.length?T[0].order_index+1:0,se=v.category_conclusion?`
Fazit Kategorie: ${v.title}
${v.category_conclusion}`:"",ue=v.summary_text+se;await be.from("sections").insert({chapter_id:F,content:ue,title:Y.trim()||null,type:"other",order_index:$,status:"open"}),i({title:"Successfully imported",description:"Saved as section in chapter."}),L(!1),ie(""),V("")}catch{i({title:"Fehler beim Import",variant:"destructive"})}finally{D(!1)}}};j.useEffect(()=>{ae()},[f,P,c,d,M,m]);const Z=async()=>{const{data:T,error:$}=await be.from("codebooks").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});$?i({title:"Error loading codebooks",variant:"destructive"}):o(T||[])},ee=async()=>{if(!c)return;const{data:T,error:$}=await be.from("codebook_categories").select("*").eq("codebook_id",c).order("order_index",{ascending:!0});$?i({title:"Error loading categories",variant:"destructive"}):h(T||[])},re=async()=>{const{data:T,error:$}=await be.from("theses").select("id, title, description").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});$?i({title:"Error loading the theses",variant:"destructive"}):E(T||[])},he=async()=>{const{data:T,error:$}=await be.from("sections").select(`
id,
title,
content,
order_index,
chapters!inner(title, thesis_id, order_index)
`).eq("chapters.thesis_id",C);if($)console.error("Section load error:",$),i({title:"Error loading the Section",description:$.message,variant:"destructive"});else{const se=(T||[]).sort((ue,ne)=>{var me,ve;return(((me=ue.chapters)==null?void 0:me.order_index)||0)-(((ve=ne.chapters)==null?void 0:ve.order_index)||0)});z(se)}},O=T=>T?T.trim().split(/\s+/).slice(0,8).join(" ")+(T.split(/\s+/).length>8?"...":""):"",ae=async()=>{var oe,de,ge,Se;if(!c||!f){U({prompt:0,completion:0,total:0});return}const T=vae[m]??vae.medium,$=$4t((T.wordMin+T.wordMax)/2);let se=0;const ue=d.find(ke=>ke.id===f);ue&&(se+=((oe=ue.name)==null?void 0:oe.length)||0,se+=((de=ue.definition)==null?void 0:de.length)||0,se+=((ge=ue.anchor_example)==null?void 0:ge.length)||0,se+=((Se=ue.coding_rule)==null?void 0:Se.length)||0);const ne=M.find(ke=>ke.id===P);if(ne!=null&&ne.content&&(se+=ne.content.length),f&&c)try{const{data:ke}=await be.from("coded_segments").select("snippet, interviews!inner(title)").eq("category_id",f).eq("codebook_id",c);if(ke&&ke.length>0){ke.forEach(qe=>{var Ae,fe,Te;se+=((Ae=qe.snippet)==null?void 0:Ae.length)||0,se+=((Te=(fe=qe.interviews)==null?void 0:fe.title)==null?void 0:Te.length)||0});const Ne=[...new Set(ke.map(qe=>{var Ae;return((Ae=qe.interviews)==null?void 0:Ae.title)||""}))];se+=Ne.join(", ").length}}catch(ke){console.error("Error loading snippets for estimation:",ke)}const ve=T.overheadTokens+200+B4t(se),xe=ve+$;U({prompt:ve,completion:$,total:xe})},q=async()=>{var T,$,se;if(!e()){s(!0);return}if(!c||!f){i({title:"Select coding sheet and category",variant:"destructive"});return}S(!0),G(null);try{const{data:ue}=await be.from("codebook_categories").select("name, definition, anchor_example, coding_rule").eq("id",f).single(),{data:ne}=await be.from("coded_segments").select(`
snippet,
interviews!inner(title)
`).eq("category_id",f).eq("codebook_id",c),me=[...new Set((ne==null?void 0:ne.map(ge=>ge.interviews.title))||[])],ve=(ne==null?void 0:ne.map(ge=>({snippet:ge.snippet,interview_title:ge.interviews.title})))||[];let xe="";if(P){const{data:ge}=await be.from("sections").select("content").eq("id",P).single();xe=(ge==null?void 0:ge.content)||""}const{data:oe,error:de}=await be.functions.invoke("analysis_results",{body:{codebook_id:c,category_id:f,mode:m,language:x,thesis_id:C||null,section_id:P||null,category_metadata:{category_title:(ue==null?void 0:ue.name)||"",definition:(ue==null?void 0:ue.definition)||"",coding_rule:(ue==null?void 0:ue.coding_rule)||"",anchor_example:(ue==null?void 0:ue.anchor_example)||"",interviewer_names:me,snippet_count:ve.length,all_snippets:ve},section_content:xe}});if(de)throw de;b(oe),G({prompt:(T=oe==null?void 0:oe.usage)==null?void 0:T.prompt_tokens,completion:($=oe==null?void 0:oe.usage)==null?void 0:$.completion_tokens,total:(se=oe==null?void 0:oe.usage)==null?void 0:se.total_tokens}),i({title:"Analysis generated successfully!"})}catch(ue){console.error("Error:",ue),i({title:"Error during generation",description:ue.message,variant:"destructive"})}finally{S(!1)}},I=async()=>{if(!(!v||!c))try{const{error:T}=await be.from("qualitative_summaries").insert({codebook_id:c,category_id:f||null,title:v.title,summary_text:v.summary_text,proof_json:v.proof_json});if(T)throw T;i({title:"Summary saved to library"})}catch{i({title:"Error saving",variant:"destructive"})}};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{children:"Analysis configuration"})}),l.jsxs(Ge,{className:"space-y-4",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Coding sheet *"}),l.jsxs(dt,{value:c,onValueChange:u,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select coding sheet..."})}),l.jsx(ct,{children:a.map(T=>l.jsx(De,{value:T.id,children:T.title},T.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Kategorie *"}),l.jsxs(dt,{value:f,onValueChange:p,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select category..."})}),l.jsx(ct,{children:d.map(T=>l.jsx(De,{value:T.id,children:T.name},T.id))})]})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Mode"}),l.jsxs(dt,{value:m,onValueChange:g,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"small",children:"Short"}),l.jsx(De,{value:"medium",children:"Middle"}),l.jsx(De,{value:"big",children:"Large"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Language"}),l.jsxs(dt,{value:x,onValueChange:y,children:[l.jsx(lt,{children:l.jsx(ht,{})}),l.jsxs(ct,{children:[l.jsx(De,{value:"de",children:"German"}),l.jsx(De,{value:"en",children:"English"})]})]})]})]}),l.jsxs("div",{className:"border-t pt-4 mt-4",children:[l.jsx("h3",{className:"text-sm font-medium mb-3",children:"Thesis-Kontext"}),k.length===0&&l.jsxs(wh,{className:"mb-4",children:[l.jsx(rj,{className:"h-4 w-4"}),l.jsx(B9,{children:"No thesis available"}),l.jsxs(Sh,{children:["Please write a thesis first in"," ",l.jsx(bt,{to:"/thesis-builder",className:"underline font-medium",children:"Thesis Builder"}),", before you can perform an analysis."]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Thesis *"}),l.jsxs(dt,{value:C,onValueChange:T=>{A(T),W("")},children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Choose Thesis"})}),l.jsx(ct,{children:k.map(T=>l.jsx(De,{value:T.id,children:T.title},T.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Theory-Section"}),l.jsxs(dt,{value:P,onValueChange:W,disabled:!C,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:C?"Select section (optional)":"Select thesis first"})}),l.jsx(ct,{children:M.map(T=>l.jsx(De,{value:T.id,children:T.title?`${T.title} (${T.chapters.title})`:`${T.chapters.title} – ${O(T.content)}`},T.id))})]})]})]})]}),l.jsxs(ye,{onClick:q,disabled:w||!c||!f||!C,className:"w-full",children:[w&&l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Start analysis"]})]})]}),v&&l.jsxs(l.Fragment,{children:[l.jsxs(ze,{children:[l.jsx(et,{children:l.jsxs(at,{className:"flex justify-between items-center flex-wrap gap-2",children:[v.title,l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(ye,{onClick:()=>L(!0),variant:"outline",size:"sm",disabled:!v||!C,children:[l.jsx(sE,{className:"mr-2 h-4 w-4"}),"Import to Chapter"]}),l.jsx(ye,{onClick:I,variant:"outline",size:"sm",children:"Save to library"})]})]})}),l.jsxs(Ge,{className:"space-y-0",children:[l.jsx("div",{className:"prose max-w-none whitespace-pre-wrap",children:v.summary_text}),v.category_conclusion&&l.jsxs(l.Fragment,{children:[l.jsx("hr",{className:"my-6 border-border"}),l.jsxs("div",{className:"prose max-w-none",children:[l.jsxs("p",{className:"font-bold underline mb-2",children:["Conclusion Category: ",v.title]}),l.jsx("p",{className:"whitespace-pre-wrap",children:v.category_conclusion})]})]})]})]}),v.proof_json&&v.proof_json.length>0&&l.jsxs(ze,{children:[l.jsx(et,{children:l.jsx(at,{className:"text-base",children:"Supporting material"})}),l.jsx(Ge,{className:"space-y-3",children:v.proof_json.map((T,$)=>l.jsxs("div",{className:"p-4 bg-muted rounded-md",children:[l.jsxs("blockquote",{className:"italic text-sm mb-2",children:['"',T.quote,'"']}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:["(",T.interview_title,", Cell XY)"]})]},$))})]})]}),l.jsx(Gr,{open:B,onOpenChange:L,children:l.jsxs(zr,{children:[l.jsx(Ur,{children:l.jsx(Hr,{children:"Import as Section"})}),l.jsxs("div",{className:"space-y-4 py-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Target Chapter"}),l.jsxs(dt,{value:F,onValueChange:V,children:[l.jsx(lt,{children:l.jsx(ht,{placeholder:"Select chapter..."})}),l.jsx(ct,{children:X.map(T=>l.jsx(De,{value:T.id,children:T.title},T.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(_e,{children:"Section-Title (optional)"}),l.jsx(Be,{value:Y,onChange:T=>ie(T.target.value),placeholder:"e.g. Interview Analysis"})]})]}),l.jsxs(Th,{children:[l.jsx(ye,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),l.jsx(ye,{onClick:J,disabled:!F||Q,children:Q?l.jsxs(l.Fragment,{children:[l.jsx(xt,{className:"mr-2 h-4 w-4 animate-spin"}),"Import..."]}):l.jsxs(l.Fragment,{children:[l.jsx(vu,{className:"mr-2 h-4 w-4"}),"Import"]})})]})]})}),l.jsx(Bu,{open:n,onClose:()=>s(!1),remainingPoints:(r==null?void 0:r.remaining)??0})]})}const U4t=()=>{const t=Ch();return j.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),l.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:[l.jsx(Ui,{title:"Page Not Found | Academly.ai",description:"Private page on Academly.ai.",canonical:"https://academly.ai/404",noIndex:!0}),l.jsxs("div",{className:"text-center",children:[l.jsx("h1",{className:"text-4xl font-bold mb-4",children:"404"}),l.jsx("p",{className:"text-xl text-gray-600 mb-4",children:"Oops! Page not found"}),l.jsx("a",{href:"/",className:"text-blue-500 hover:text-blue-700 underline",children:"Return to Home"})]})]})},H4t=new wRe;function V4t(){return l.jsx(NRe,{client:H4t,children:l.jsxs(Zs,{children:[l.jsx(UPe,{}),l.jsx(bOe,{}),l.jsx(FMe,{children:l.jsxs(TMe,{children:[l.jsx(Mt,{path:"/",element:l.jsx(Avt,{})}),l.jsx(Mt,{path:"/pricing",element:l.jsx(Rvt,{})}),l.jsx(Mt,{path:"/subscription/success",element:l.jsx(Dvt,{})}),l.jsx(Mt,{path:"/subscription/cancel",element:l.jsx(Lvt,{})}),l.jsx(Mt,{path:"/how-it-works",element:l.jsx(zvt,{})}),l.jsx(Mt,{path:"/topic-ideas",element:l.jsx(Yvt,{})}),l.jsx(Mt,{path:"/literature-search",element:l.jsx(Jvt,{})}),l.jsx(Mt,{path:"/team",element:l.jsx(ebt,{})}),l.jsx(Mt,{path:"/waitlist",element:l.jsx(f0t,{})}),l.jsx(Mt,{path:"/legal",element:l.jsx(y0t,{})}),l.jsx(Mt,{path:"/login",element:l.jsx(S0t,{})}),l.jsx(Mt,{path:"/reset-password",element:l.jsx(_0t,{})}),l.jsx(Mt,{path:"/vs/*",element:l.jsx(uT,{to:"/blog/was-kann-academly",replace:!0})}),l.jsx(Mt,{path:"/blog",element:l.jsx(E0t,{})}),l.jsx(Mt,{path:"/blog/:slug",element:l.jsx(oSt,{})}),l.jsx(Mt,{path:"/dashboard",element:l.jsx(Yxt,{})}),l.jsx(Mt,{path:"/documents",element:l.jsx(Mjt,{})}),l.jsx(Mt,{path:"/summary",element:l.jsx(Fjt,{})}),l.jsx(Mt,{path:"/pdf-extract",element:l.jsx(g4t,{})}),l.jsx(Mt,{path:"/pdf-slicer",element:l.jsx(m4t,{})}),l.jsx(Mt,{path:"/topic-explorer",element:l.jsx(i4t,{})}),l.jsx(Mt,{path:"/topic-explorer/ideas",element:l.jsx(a4t,{})}),l.jsx(Mt,{path:"/topic-explorer/outline",element:l.jsx(o4t,{})}),l.jsx(Mt,{path:"/topic-explorer/keywords",element:l.jsx(l4t,{})}),l.jsx(Mt,{path:"/thesis-builder",element:l.jsx(lkt,{})}),l.jsx(Mt,{path:"/methods-approach",element:l.jsx(ckt,{})}),l.jsx(Mt,{path:"/discussion",element:l.jsx(dkt,{})}),l.jsx(Mt,{path:"/conclusion",element:l.jsx(fkt,{})}),l.jsx(Mt,{path:"/thesis-manager",element:l.jsx(wTt,{})}),l.jsx(Mt,{path:"/my-thesis-2",element:l.jsx(s4t,{})}),l.jsxs(Mt,{path:"/qualitative",element:l.jsx(P4t,{}),children:[l.jsx(Mt,{index:!0,element:l.jsx(uT,{to:"/qualitative/research-setup",replace:!0})}),l.jsx(Mt,{path:"research-setup",element:l.jsx(O4t,{})}),l.jsx(Mt,{path:"kodierbogen",element:l.jsx(I4t,{})}),l.jsx(Mt,{path:"kodierbogen-grid",element:l.jsx(M4t,{})}),l.jsx(Mt,{path:"interviews",element:l.jsx(D4t,{})}),l.jsx(Mt,{path:"kodieren",element:l.jsx(F4t,{})}),l.jsx(Mt,{path:"auswertung",element:l.jsx(z4t,{})})]}),l.jsx(Mt,{path:"/reference-checker",element:l.jsx(E4t,{})}),l.jsx(Mt,{path:"/supervisor",element:l.jsx(T4t,{})}),l.jsx(Mt,{path:"/citations",element:l.jsx(uT,{to:"/reference-checker",replace:!0})}),l.jsx(Mt,{path:"/history",element:l.jsx($jt,{})}),l.jsx(Mt,{path:"/account",element:l.jsx(okt,{})}),l.jsx(Mt,{path:"*",element:l.jsx(U4t,{})})]})})]})})}Wle(document.getElementById("root")).render(l.jsx(Qle,{children:l.jsx(L3e,{children:l.jsx(i4e,{children:l.jsx(V4t,{})})})}));