var O2e=Object.defineProperty;var KK=t=>{throw TypeError(t)};var M2e=(t,e,r)=>e in t?O2e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Ge=(t,e,r)=>M2e(t,typeof e!="symbol"?e+"":e,r),A5=(t,e,r)=>e.has(t)||KK("Cannot "+r);var _=(t,e,r)=>(A5(t,e,"read from private field"),r?r.call(t):e.get(t)),le=(t,e,r)=>e.has(t)?KK("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),te=(t,e,r,n)=>(A5(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),de=(t,e,r)=>(A5(t,e,"access private method"),r);var xi=(t,e,r,n)=>({set _(s){te(t,e,s,r)},get _(){return _(t,e,n)}});function D2e(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 $n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Er(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function L2e(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 Jce={exports:{}},SM={},eue={exports:{}},_r={};/**
 * @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 jE=Symbol.for("react.element"),$2e=Symbol.for("react.portal"),F2e=Symbol.for("react.fragment"),B2e=Symbol.for("react.strict_mode"),z2e=Symbol.for("react.profiler"),U2e=Symbol.for("react.provider"),H2e=Symbol.for("react.context"),W2e=Symbol.for("react.forward_ref"),V2e=Symbol.for("react.suspense"),q2e=Symbol.for("react.memo"),G2e=Symbol.for("react.lazy"),YK=Symbol.iterator;function K2e(t){return t===null||typeof t!="object"?null:(t=YK&&t[YK]||t["@@iterator"],typeof t=="function"?t:null)}var tue={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},rue=Object.assign,nue={};function Z1(t,e,r){this.props=t,this.context=e,this.refs=nue,this.updater=r||tue}Z1.prototype.isReactComponent={};Z1.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")};Z1.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function sue(){}sue.prototype=Z1.prototype;function $7(t,e,r){this.props=t,this.context=e,this.refs=nue,this.updater=r||tue}var F7=$7.prototype=new sue;F7.constructor=$7;rue(F7,Z1.prototype);F7.isPureReactComponent=!0;var XK=Array.isArray,iue=Object.prototype.hasOwnProperty,B7={current:null},aue={key:!0,ref:!0,__self:!0,__source:!0};function oue(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)iue.call(e,n)&&!aue.hasOwnProperty(n)&&(s[n]=e[n]);var l=arguments.length-2;if(l===1)s.children=r;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];s.children=c}if(t&&t.defaultProps)for(n in l=t.defaultProps,l)s[n]===void 0&&(s[n]=l[n]);return{$$typeof:jE,type:t,key:i,ref:a,props:s,_owner:B7.current}}function Y2e(t,e){return{$$typeof:jE,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function z7(t){return typeof t=="object"&&t!==null&&t.$$typeof===jE}function X2e(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(r){return e[r]})}var QK=/\/+/g;function T5(t,e){return typeof t=="object"&&t!==null&&t.key!=null?X2e(""+t.key):e.toString(36)}function E2(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 jE:case $2e:a=!0}}if(a)return a=t,s=s(a),t=n===""?"."+T5(a,0):n,XK(s)?(r="",t!=null&&(r=t.replace(QK,"$&/")+"/"),E2(s,e,r,"",function(u){return u})):s!=null&&(z7(s)&&(s=Y2e(s,r+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(QK,"$&/")+"/")+t)),e.push(s)),1;if(a=0,n=n===""?".":n+":",XK(t))for(var l=0;l<t.length;l++){i=t[l];var c=n+T5(i,l);a+=E2(i,e,r,c,s)}else if(c=K2e(t),typeof c=="function")for(t=c.call(t),l=0;!(i=t.next()).done;)i=i.value,c=n+T5(i,l++),a+=E2(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 TA(t,e,r){if(t==null)return t;var n=[],s=0;return E2(t,n,"","",function(i){return e.call(r,i,s++)}),n}function Q2e(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 Ja={current:null},A2={transition:null},Z2e={ReactCurrentDispatcher:Ja,ReactCurrentBatchConfig:A2,ReactCurrentOwner:B7};function lue(){throw Error("act(...) is not supported in production builds of React.")}_r.Children={map:TA,forEach:function(t,e,r){TA(t,function(){e.apply(this,arguments)},r)},count:function(t){var e=0;return TA(t,function(){e++}),e},toArray:function(t){return TA(t,function(e){return e})||[]},only:function(t){if(!z7(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};_r.Component=Z1;_r.Fragment=F2e;_r.Profiler=z2e;_r.PureComponent=$7;_r.StrictMode=B2e;_r.Suspense=V2e;_r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Z2e;_r.act=lue;_r.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=rue({},t.props),s=t.key,i=t.ref,a=t._owner;if(e!=null){if(e.ref!==void 0&&(i=e.ref,a=B7.current),e.key!==void 0&&(s=""+e.key),t.type&&t.type.defaultProps)var l=t.type.defaultProps;for(c in e)iue.call(e,c)&&!aue.hasOwnProperty(c)&&(n[c]=e[c]===void 0&&l!==void 0?l[c]:e[c])}var c=arguments.length-2;if(c===1)n.children=r;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];n.children=l}return{$$typeof:jE,type:t.type,key:s,ref:i,props:n,_owner:a}};_r.createContext=function(t){return t={$$typeof:H2e,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:U2e,_context:t},t.Consumer=t};_r.createElement=oue;_r.createFactory=function(t){var e=oue.bind(null,t);return e.type=t,e};_r.createRef=function(){return{current:null}};_r.forwardRef=function(t){return{$$typeof:W2e,render:t}};_r.isValidElement=z7;_r.lazy=function(t){return{$$typeof:G2e,_payload:{_status:-1,_result:t},_init:Q2e}};_r.memo=function(t,e){return{$$typeof:q2e,type:t,compare:e===void 0?null:e}};_r.startTransition=function(t){var e=A2.transition;A2.transition={};try{t()}finally{A2.transition=e}};_r.unstable_act=lue;_r.useCallback=function(t,e){return Ja.current.useCallback(t,e)};_r.useContext=function(t){return Ja.current.useContext(t)};_r.useDebugValue=function(){};_r.useDeferredValue=function(t){return Ja.current.useDeferredValue(t)};_r.useEffect=function(t,e){return Ja.current.useEffect(t,e)};_r.useId=function(){return Ja.current.useId()};_r.useImperativeHandle=function(t,e,r){return Ja.current.useImperativeHandle(t,e,r)};_r.useInsertionEffect=function(t,e){return Ja.current.useInsertionEffect(t,e)};_r.useLayoutEffect=function(t,e){return Ja.current.useLayoutEffect(t,e)};_r.useMemo=function(t,e){return Ja.current.useMemo(t,e)};_r.useReducer=function(t,e,r){return Ja.current.useReducer(t,e,r)};_r.useRef=function(t){return Ja.current.useRef(t)};_r.useState=function(t){return Ja.current.useState(t)};_r.useSyncExternalStore=function(t,e,r){return Ja.current.useSyncExternalStore(t,e,r)};_r.useTransition=function(){return Ja.current.useTransition()};_r.version="18.3.1";eue.exports=_r;var S=eue.exports;const ve=Er(S),U7=D2e({__proto__:null,default:ve},[S]);/**
 * @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 J2e=S,ePe=Symbol.for("react.element"),tPe=Symbol.for("react.fragment"),rPe=Object.prototype.hasOwnProperty,nPe=J2e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,sPe={key:!0,ref:!0,__self:!0,__source:!0};function cue(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)rPe.call(e,n)&&!sPe.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:ePe,type:t,key:i,ref:a,props:s,_owner:nPe.current}}SM.Fragment=tPe;SM.jsx=cue;SM.jsxs=cue;Jce.exports=SM;var o=Jce.exports,uue={exports:{}},ml={},due={exports:{}},hue={};/**
 * @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(ee,V){var B=ee.length;ee.push(V);e:for(;0<B;){var z=B-1>>>1,F=ee[z];if(0<s(F,V))ee[z]=V,ee[B]=F,B=z;else break e}}function r(ee){return ee.length===0?null:ee[0]}function n(ee){if(ee.length===0)return null;var V=ee[0],B=ee.pop();if(B!==V){ee[0]=B;e:for(var z=0,F=ee.length,G=F>>>1;z<G;){var Q=2*(z+1)-1,ie=ee[Q],se=Q+1,q=ee[se];if(0>s(ie,B))se<F&&0>s(q,ie)?(ee[z]=q,ee[se]=B,z=se):(ee[z]=ie,ee[Q]=B,z=Q);else if(se<F&&0>s(q,B))ee[z]=q,ee[se]=B,z=se;else break e}}return V}function s(ee,V){var B=ee.sortIndex-V.sortIndex;return B!==0?B:ee.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var a=Date,l=a.now();t.unstable_now=function(){return a.now()-l}}var c=[],u=[],d=1,h=null,f=3,p=!1,m=!1,g=!1,y=typeof setTimeout=="function"?setTimeout:null,x=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(ee){for(var V=r(u);V!==null;){if(V.callback===null)n(u);else if(V.startTime<=ee)n(u),V.sortIndex=V.expirationTime,e(c,V);else break;V=r(u)}}function w(ee){if(g=!1,b(ee),!m)if(r(c)!==null)m=!0,K(j);else{var V=r(u);V!==null&&H(w,V.startTime-ee)}}function j(ee,V){m=!1,g&&(g=!1,x(A),A=-1),p=!0;var B=f;try{for(b(V),h=r(c);h!==null&&(!(h.expirationTime>V)||ee&&!$());){var z=h.callback;if(typeof z=="function"){h.callback=null,f=h.priorityLevel;var F=z(h.expirationTime<=V);V=t.unstable_now(),typeof F=="function"?h.callback=F:h===r(c)&&n(c),b(V)}else n(c);h=r(c)}if(h!==null)var G=!0;else{var Q=r(u);Q!==null&&H(w,Q.startTime-V),G=!1}return G}finally{h=null,f=B,p=!1}}var N=!1,C=null,A=-1,E=5,O=-1;function $(){return!(t.unstable_now()-O<E)}function T(){if(C!==null){var ee=t.unstable_now();O=ee;var V=!0;try{V=C(!0,ee)}finally{V?M():(N=!1,C=null)}}else N=!1}var M;if(typeof v=="function")M=function(){v(T)};else if(typeof MessageChannel<"u"){var k=new MessageChannel,D=k.port2;k.port1.onmessage=T,M=function(){D.postMessage(null)}}else M=function(){y(T,0)};function K(ee){C=ee,N||(N=!0,M())}function H(ee,V){A=y(function(){ee(t.unstable_now())},V)}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(ee){ee.callback=null},t.unstable_continueExecution=function(){m||p||(m=!0,K(j))},t.unstable_forceFrameRate=function(ee){0>ee||125<ee?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<ee?Math.floor(1e3/ee):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_getFirstCallbackNode=function(){return r(c)},t.unstable_next=function(ee){switch(f){case 1:case 2:case 3:var V=3;break;default:V=f}var B=f;f=V;try{return ee()}finally{f=B}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(ee,V){switch(ee){case 1:case 2:case 3:case 4:case 5:break;default:ee=3}var B=f;f=ee;try{return V()}finally{f=B}},t.unstable_scheduleCallback=function(ee,V,B){var z=t.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?z+B:z):B=z,ee){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,ee={id:d++,callback:V,priorityLevel:ee,startTime:B,expirationTime:F,sortIndex:-1},B>z?(ee.sortIndex=B,e(u,ee),r(c)===null&&ee===r(u)&&(g?(x(A),A=-1):g=!0,H(w,B-z))):(ee.sortIndex=F,e(c,ee),m||p||(m=!0,K(j))),ee},t.unstable_shouldYield=$,t.unstable_wrapCallback=function(ee){var V=f;return function(){var B=f;f=V;try{return ee.apply(this,arguments)}finally{f=B}}}})(hue);due.exports=hue;var iPe=due.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 aPe=S,fl=iPe;function Je(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 fue=new Set,aN={};function kv(t,e){Xw(t,e),Xw(t+"Capture",e)}function Xw(t,e){for(aN[t]=e,t=0;t<e.length;t++)fue.add(e[t])}var tf=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),k6=Object.prototype.hasOwnProperty,oPe=/^[: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]*$/,ZK={},JK={};function lPe(t){return k6.call(JK,t)?!0:k6.call(ZK,t)?!1:oPe.test(t)?JK[t]=!0:(ZK[t]=!0,!1)}function cPe(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 uPe(t,e,r,n){if(e===null||typeof e>"u"||cPe(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 eo(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 la={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){la[t]=new eo(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];la[e]=new eo(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){la[t]=new eo(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){la[t]=new eo(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){la[t]=new eo(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){la[t]=new eo(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){la[t]=new eo(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){la[t]=new eo(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){la[t]=new eo(t,5,!1,t.toLowerCase(),null,!1,!1)});var H7=/[\-:]([a-z])/g;function W7(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(H7,W7);la[e]=new eo(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(H7,W7);la[e]=new eo(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(H7,W7);la[e]=new eo(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){la[t]=new eo(t,1,!1,t.toLowerCase(),null,!1,!1)});la.xlinkHref=new eo("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){la[t]=new eo(t,1,!1,t.toLowerCase(),null,!0,!0)});function V7(t,e,r,n){var s=la.hasOwnProperty(e)?la[e]:null;(s!==null?s.type!==0:n||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(uPe(e,r,s,n)&&(r=null),n||s===null?lPe(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 Sf=aPe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,PA=Symbol.for("react.element"),Pb=Symbol.for("react.portal"),Ib=Symbol.for("react.fragment"),q7=Symbol.for("react.strict_mode"),C6=Symbol.for("react.profiler"),pue=Symbol.for("react.provider"),mue=Symbol.for("react.context"),G7=Symbol.for("react.forward_ref"),E6=Symbol.for("react.suspense"),A6=Symbol.for("react.suspense_list"),K7=Symbol.for("react.memo"),sp=Symbol.for("react.lazy"),gue=Symbol.for("react.offscreen"),eY=Symbol.iterator;function $j(t){return t===null||typeof t!="object"?null:(t=eY&&t[eY]||t["@@iterator"],typeof t=="function"?t:null)}var ss=Object.assign,P5;function RS(t){if(P5===void 0)try{throw Error()}catch(r){var e=r.stack.trim().match(/\n( *(at )?)/);P5=e&&e[1]||""}return`
`+P5+t}var I5=!1;function R5(t,e){if(!t||I5)return"";I5=!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,l=i.length-1;1<=a&&0<=l&&s[a]!==i[l];)l--;for(;1<=a&&0<=l;a--,l--)if(s[a]!==i[l]){if(a!==1||l!==1)do if(a--,l--,0>l||s[a]!==i[l]){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<=l);break}}}finally{I5=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?RS(t):""}function dPe(t){switch(t.tag){case 5:return RS(t.type);case 16:return RS("Lazy");case 13:return RS("Suspense");case 19:return RS("SuspenseList");case 0:case 2:case 15:return t=R5(t.type,!1),t;case 11:return t=R5(t.type.render,!1),t;case 1:return t=R5(t.type,!0),t;default:return""}}function T6(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 Ib:return"Fragment";case Pb:return"Portal";case C6:return"Profiler";case q7:return"StrictMode";case E6:return"Suspense";case A6:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case mue:return(t.displayName||"Context")+".Consumer";case pue:return(t._context.displayName||"Context")+".Provider";case G7:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case K7:return e=t.displayName||null,e!==null?e:T6(t.type)||"Memo";case sp:e=t._payload,t=t._init;try{return T6(t(e))}catch{}}return null}function hPe(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 T6(e);case 8:return e===q7?"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 Fm(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function xue(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function fPe(t){var e=xue(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 IA(t){t._valueTracker||(t._valueTracker=fPe(t))}function yue(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=xue(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function KP(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 P6(t,e){var r=e.checked;return ss({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function tY(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=Fm(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 vue(t,e){e=e.checked,e!=null&&V7(t,"checked",e,!1)}function I6(t,e){vue(t,e);var r=Fm(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")?R6(t,e.type,r):e.hasOwnProperty("defaultValue")&&R6(t,e.type,Fm(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function rY(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 R6(t,e,r){(e!=="number"||KP(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var OS=Array.isArray;function s0(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=""+Fm(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 O6(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(Je(91));return ss({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function nY(t,e){var r=e.value;if(r==null){if(r=e.children,e=e.defaultValue,r!=null){if(e!=null)throw Error(Je(92));if(OS(r)){if(1<r.length)throw Error(Je(93));r=r[0]}e=r}e==null&&(e=""),r=e}t._wrapperState={initialValue:Fm(r)}}function bue(t,e){var r=Fm(e.value),n=Fm(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 sY(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function wue(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 M6(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?wue(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var RA,jue=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(RA=RA||document.createElement("div"),RA.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=RA.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function oN(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var v_={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},pPe=["Webkit","ms","Moz","O"];Object.keys(v_).forEach(function(t){pPe.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),v_[e]=v_[t]})});function Sue(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||v_.hasOwnProperty(t)&&v_[t]?(""+e).trim():e+"px"}function _ue(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,s=Sue(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,s):t[r]=s}}var mPe=ss({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 D6(t,e){if(e){if(mPe[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Je(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Je(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Je(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Je(62))}}function L6(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 $6=null;function Y7(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var F6=null,i0=null,a0=null;function iY(t){if(t=NE(t)){if(typeof F6!="function")throw Error(Je(280));var e=t.stateNode;e&&(e=EM(e),F6(t.stateNode,t.type,e))}}function Nue(t){i0?a0?a0.push(t):a0=[t]:i0=t}function kue(){if(i0){var t=i0,e=a0;if(a0=i0=null,iY(t),e)for(t=0;t<e.length;t++)iY(e[t])}}function Cue(t,e){return t(e)}function Eue(){}var O5=!1;function Aue(t,e,r){if(O5)return t(e,r);O5=!0;try{return Cue(t,e,r)}finally{O5=!1,(i0!==null||a0!==null)&&(Eue(),kue())}}function lN(t,e){var r=t.stateNode;if(r===null)return null;var n=EM(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(Je(231,e,typeof r));return r}var B6=!1;if(tf)try{var Fj={};Object.defineProperty(Fj,"passive",{get:function(){B6=!0}}),window.addEventListener("test",Fj,Fj),window.removeEventListener("test",Fj,Fj)}catch{B6=!1}function gPe(t,e,r,n,s,i,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{e.apply(r,u)}catch(d){this.onError(d)}}var b_=!1,YP=null,XP=!1,z6=null,xPe={onError:function(t){b_=!0,YP=t}};function yPe(t,e,r,n,s,i,a,l,c){b_=!1,YP=null,gPe.apply(xPe,arguments)}function vPe(t,e,r,n,s,i,a,l,c){if(yPe.apply(this,arguments),b_){if(b_){var u=YP;b_=!1,YP=null}else throw Error(Je(198));XP||(XP=!0,z6=u)}}function Cv(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 Tue(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 aY(t){if(Cv(t)!==t)throw Error(Je(188))}function bPe(t){var e=t.alternate;if(!e){if(e=Cv(t),e===null)throw Error(Je(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 aY(s),t;if(i===n)return aY(s),e;i=i.sibling}throw Error(Je(188))}if(r.return!==n.return)r=s,n=i;else{for(var a=!1,l=s.child;l;){if(l===r){a=!0,r=s,n=i;break}if(l===n){a=!0,n=s,r=i;break}l=l.sibling}if(!a){for(l=i.child;l;){if(l===r){a=!0,r=i,n=s;break}if(l===n){a=!0,n=i,r=s;break}l=l.sibling}if(!a)throw Error(Je(189))}}if(r.alternate!==n)throw Error(Je(190))}if(r.tag!==3)throw Error(Je(188));return r.stateNode.current===r?t:e}function Pue(t){return t=bPe(t),t!==null?Iue(t):null}function Iue(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=Iue(t);if(e!==null)return e;t=t.sibling}return null}var Rue=fl.unstable_scheduleCallback,oY=fl.unstable_cancelCallback,wPe=fl.unstable_shouldYield,jPe=fl.unstable_requestPaint,Cs=fl.unstable_now,SPe=fl.unstable_getCurrentPriorityLevel,X7=fl.unstable_ImmediatePriority,Oue=fl.unstable_UserBlockingPriority,QP=fl.unstable_NormalPriority,_Pe=fl.unstable_LowPriority,Mue=fl.unstable_IdlePriority,_M=null,rd=null;function NPe(t){if(rd&&typeof rd.onCommitFiberRoot=="function")try{rd.onCommitFiberRoot(_M,t,void 0,(t.current.flags&128)===128)}catch{}}var Gc=Math.clz32?Math.clz32:EPe,kPe=Math.log,CPe=Math.LN2;function EPe(t){return t>>>=0,t===0?32:31-(kPe(t)/CPe|0)|0}var OA=64,MA=4194304;function MS(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 ZP(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 l=a&~s;l!==0?n=MS(l):(i&=a,i!==0&&(n=MS(i)))}else a=r&~s,a!==0?n=MS(a):i!==0&&(n=MS(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-Gc(e),s=1<<r,n|=t[r],e&=~s;return n}function APe(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 TPe(t,e){for(var r=t.suspendedLanes,n=t.pingedLanes,s=t.expirationTimes,i=t.pendingLanes;0<i;){var a=31-Gc(i),l=1<<a,c=s[a];c===-1?(!(l&r)||l&n)&&(s[a]=APe(l,e)):c<=e&&(t.expiredLanes|=l),i&=~l}}function U6(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Due(){var t=OA;return OA<<=1,!(OA&4194240)&&(OA=64),t}function M5(t){for(var e=[],r=0;31>r;r++)e.push(t);return e}function SE(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Gc(e),t[e]=r}function PPe(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-Gc(r),i=1<<s;e[s]=0,n[s]=-1,t[s]=-1,r&=~i}}function Q7(t,e){var r=t.entangledLanes|=e;for(t=t.entanglements;r;){var n=31-Gc(r),s=1<<n;s&e|t[n]&e&&(t[n]|=e),r&=~s}}var rn=0;function Lue(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var $ue,Z7,Fue,Bue,zue,H6=!1,DA=[],vm=null,bm=null,wm=null,cN=new Map,uN=new Map,up=[],IPe="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 lY(t,e){switch(t){case"focusin":case"focusout":vm=null;break;case"dragenter":case"dragleave":bm=null;break;case"mouseover":case"mouseout":wm=null;break;case"pointerover":case"pointerout":cN.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":uN.delete(e.pointerId)}}function Bj(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=NE(e),e!==null&&Z7(e)),t):(t.eventSystemFlags|=n,e=t.targetContainers,s!==null&&e.indexOf(s)===-1&&e.push(s),t)}function RPe(t,e,r,n,s){switch(e){case"focusin":return vm=Bj(vm,t,e,r,n,s),!0;case"dragenter":return bm=Bj(bm,t,e,r,n,s),!0;case"mouseover":return wm=Bj(wm,t,e,r,n,s),!0;case"pointerover":var i=s.pointerId;return cN.set(i,Bj(cN.get(i)||null,t,e,r,n,s)),!0;case"gotpointercapture":return i=s.pointerId,uN.set(i,Bj(uN.get(i)||null,t,e,r,n,s)),!0}return!1}function Uue(t){var e=nx(t.target);if(e!==null){var r=Cv(e);if(r!==null){if(e=r.tag,e===13){if(e=Tue(r),e!==null){t.blockedOn=e,zue(t.priority,function(){Fue(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 T2(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var r=W6(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(r===null){r=t.nativeEvent;var n=new r.constructor(r.type,r);$6=n,r.target.dispatchEvent(n),$6=null}else return e=NE(r),e!==null&&Z7(e),t.blockedOn=r,!1;e.shift()}return!0}function cY(t,e,r){T2(t)&&r.delete(e)}function OPe(){H6=!1,vm!==null&&T2(vm)&&(vm=null),bm!==null&&T2(bm)&&(bm=null),wm!==null&&T2(wm)&&(wm=null),cN.forEach(cY),uN.forEach(cY)}function zj(t,e){t.blockedOn===e&&(t.blockedOn=null,H6||(H6=!0,fl.unstable_scheduleCallback(fl.unstable_NormalPriority,OPe)))}function dN(t){function e(s){return zj(s,t)}if(0<DA.length){zj(DA[0],t);for(var r=1;r<DA.length;r++){var n=DA[r];n.blockedOn===t&&(n.blockedOn=null)}}for(vm!==null&&zj(vm,t),bm!==null&&zj(bm,t),wm!==null&&zj(wm,t),cN.forEach(e),uN.forEach(e),r=0;r<up.length;r++)n=up[r],n.blockedOn===t&&(n.blockedOn=null);for(;0<up.length&&(r=up[0],r.blockedOn===null);)Uue(r),r.blockedOn===null&&up.shift()}var o0=Sf.ReactCurrentBatchConfig,JP=!0;function MPe(t,e,r,n){var s=rn,i=o0.transition;o0.transition=null;try{rn=1,J7(t,e,r,n)}finally{rn=s,o0.transition=i}}function DPe(t,e,r,n){var s=rn,i=o0.transition;o0.transition=null;try{rn=4,J7(t,e,r,n)}finally{rn=s,o0.transition=i}}function J7(t,e,r,n){if(JP){var s=W6(t,e,r,n);if(s===null)V5(t,e,n,eI,r),lY(t,n);else if(RPe(s,t,e,r,n))n.stopPropagation();else if(lY(t,n),e&4&&-1<IPe.indexOf(t)){for(;s!==null;){var i=NE(s);if(i!==null&&$ue(i),i=W6(t,e,r,n),i===null&&V5(t,e,n,eI,r),i===s)break;s=i}s!==null&&n.stopPropagation()}else V5(t,e,n,null,r)}}var eI=null;function W6(t,e,r,n){if(eI=null,t=Y7(n),t=nx(t),t!==null)if(e=Cv(t),e===null)t=null;else if(r=e.tag,r===13){if(t=Tue(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 eI=t,null}function Hue(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(SPe()){case X7:return 1;case Oue:return 4;case QP:case _Pe:return 16;case Mue:return 536870912;default:return 16}default:return 16}}var pm=null,eW=null,P2=null;function Wue(){if(P2)return P2;var t,e=eW,r=e.length,n,s="value"in pm?pm.value:pm.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 P2=s.slice(t,1<n?1-n:void 0)}function I2(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 LA(){return!0}function uY(){return!1}function gl(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 l in t)t.hasOwnProperty(l)&&(r=t[l],this[l]=r?r(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?LA:uY,this.isPropagationStopped=uY,this}return ss(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=LA)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=LA)},persist:function(){},isPersistent:LA}),e}var J1={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},tW=gl(J1),_E=ss({},J1,{view:0,detail:0}),LPe=gl(_E),D5,L5,Uj,NM=ss({},_E,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:rW,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!==Uj&&(Uj&&t.type==="mousemove"?(D5=t.screenX-Uj.screenX,L5=t.screenY-Uj.screenY):L5=D5=0,Uj=t),D5)},movementY:function(t){return"movementY"in t?t.movementY:L5}}),dY=gl(NM),$Pe=ss({},NM,{dataTransfer:0}),FPe=gl($Pe),BPe=ss({},_E,{relatedTarget:0}),$5=gl(BPe),zPe=ss({},J1,{animationName:0,elapsedTime:0,pseudoElement:0}),UPe=gl(zPe),HPe=ss({},J1,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),WPe=gl(HPe),VPe=ss({},J1,{data:0}),hY=gl(VPe),qPe={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},GPe={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"},KPe={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function YPe(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=KPe[t])?!!e[t]:!1}function rW(){return YPe}var XPe=ss({},_E,{key:function(t){if(t.key){var e=qPe[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=I2(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?GPe[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:rW,charCode:function(t){return t.type==="keypress"?I2(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?I2(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),QPe=gl(XPe),ZPe=ss({},NM,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),fY=gl(ZPe),JPe=ss({},_E,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:rW}),eIe=gl(JPe),tIe=ss({},J1,{propertyName:0,elapsedTime:0,pseudoElement:0}),rIe=gl(tIe),nIe=ss({},NM,{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}),sIe=gl(nIe),iIe=[9,13,27,32],nW=tf&&"CompositionEvent"in window,w_=null;tf&&"documentMode"in document&&(w_=document.documentMode);var aIe=tf&&"TextEvent"in window&&!w_,Vue=tf&&(!nW||w_&&8<w_&&11>=w_),pY=" ",mY=!1;function que(t,e){switch(t){case"keyup":return iIe.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Gue(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Rb=!1;function oIe(t,e){switch(t){case"compositionend":return Gue(e);case"keypress":return e.which!==32?null:(mY=!0,pY);case"textInput":return t=e.data,t===pY&&mY?null:t;default:return null}}function lIe(t,e){if(Rb)return t==="compositionend"||!nW&&que(t,e)?(t=Wue(),P2=eW=pm=null,Rb=!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 Vue&&e.locale!=="ko"?null:e.data;default:return null}}var cIe={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 gY(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!cIe[t.type]:e==="textarea"}function Kue(t,e,r,n){Nue(n),e=tI(e,"onChange"),0<e.length&&(r=new tW("onChange","change",null,r,n),t.push({event:r,listeners:e}))}var j_=null,hN=null;function uIe(t){ide(t,0)}function kM(t){var e=Db(t);if(yue(e))return t}function dIe(t,e){if(t==="change")return e}var Yue=!1;if(tf){var F5;if(tf){var B5="oninput"in document;if(!B5){var xY=document.createElement("div");xY.setAttribute("oninput","return;"),B5=typeof xY.oninput=="function"}F5=B5}else F5=!1;Yue=F5&&(!document.documentMode||9<document.documentMode)}function yY(){j_&&(j_.detachEvent("onpropertychange",Xue),hN=j_=null)}function Xue(t){if(t.propertyName==="value"&&kM(hN)){var e=[];Kue(e,hN,t,Y7(t)),Aue(uIe,e)}}function hIe(t,e,r){t==="focusin"?(yY(),j_=e,hN=r,j_.attachEvent("onpropertychange",Xue)):t==="focusout"&&yY()}function fIe(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return kM(hN)}function pIe(t,e){if(t==="click")return kM(e)}function mIe(t,e){if(t==="input"||t==="change")return kM(e)}function gIe(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var Jc=typeof Object.is=="function"?Object.is:gIe;function fN(t,e){if(Jc(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(!k6.call(e,s)||!Jc(t[s],e[s]))return!1}return!0}function vY(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function bY(t,e){var r=vY(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=vY(r)}}function Que(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Que(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Zue(){for(var t=window,e=KP();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=KP(t.document)}return e}function sW(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 xIe(t){var e=Zue(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&Que(r.ownerDocument.documentElement,r)){if(n!==null&&sW(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=bY(r,i);var a=bY(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 yIe=tf&&"documentMode"in document&&11>=document.documentMode,Ob=null,V6=null,S_=null,q6=!1;function wY(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;q6||Ob==null||Ob!==KP(n)||(n=Ob,"selectionStart"in n&&sW(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}),S_&&fN(S_,n)||(S_=n,n=tI(V6,"onSelect"),0<n.length&&(e=new tW("onSelect","select",null,e,r),t.push({event:e,listeners:n}),e.target=Ob)))}function $A(t,e){var r={};return r[t.toLowerCase()]=e.toLowerCase(),r["Webkit"+t]="webkit"+e,r["Moz"+t]="moz"+e,r}var Mb={animationend:$A("Animation","AnimationEnd"),animationiteration:$A("Animation","AnimationIteration"),animationstart:$A("Animation","AnimationStart"),transitionend:$A("Transition","TransitionEnd")},z5={},Jue={};tf&&(Jue=document.createElement("div").style,"AnimationEvent"in window||(delete Mb.animationend.animation,delete Mb.animationiteration.animation,delete Mb.animationstart.animation),"TransitionEvent"in window||delete Mb.transitionend.transition);function CM(t){if(z5[t])return z5[t];if(!Mb[t])return t;var e=Mb[t],r;for(r in e)if(e.hasOwnProperty(r)&&r in Jue)return z5[t]=e[r];return t}var ede=CM("animationend"),tde=CM("animationiteration"),rde=CM("animationstart"),nde=CM("transitionend"),sde=new Map,jY="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 tg(t,e){sde.set(t,e),kv(e,[t])}for(var U5=0;U5<jY.length;U5++){var H5=jY[U5],vIe=H5.toLowerCase(),bIe=H5[0].toUpperCase()+H5.slice(1);tg(vIe,"on"+bIe)}tg(ede,"onAnimationEnd");tg(tde,"onAnimationIteration");tg(rde,"onAnimationStart");tg("dblclick","onDoubleClick");tg("focusin","onFocus");tg("focusout","onBlur");tg(nde,"onTransitionEnd");Xw("onMouseEnter",["mouseout","mouseover"]);Xw("onMouseLeave",["mouseout","mouseover"]);Xw("onPointerEnter",["pointerout","pointerover"]);Xw("onPointerLeave",["pointerout","pointerover"]);kv("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));kv("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));kv("onBeforeInput",["compositionend","keypress","textInput","paste"]);kv("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));kv("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));kv("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var DS="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(" "),wIe=new Set("cancel close invalid load scroll toggle".split(" ").concat(DS));function SY(t,e,r){var n=t.type||"unknown-event";t.currentTarget=r,vPe(n,e,void 0,t),t.currentTarget=null}function ide(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 l=n[a],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==i&&s.isPropagationStopped())break e;SY(s,l,u),i=c}else for(a=0;a<n.length;a++){if(l=n[a],c=l.instance,u=l.currentTarget,l=l.listener,c!==i&&s.isPropagationStopped())break e;SY(s,l,u),i=c}}}if(XP)throw t=z6,XP=!1,z6=null,t}function On(t,e){var r=e[Q6];r===void 0&&(r=e[Q6]=new Set);var n=t+"__bubble";r.has(n)||(ade(e,t,2,!1),r.add(n))}function W5(t,e,r){var n=0;e&&(n|=4),ade(r,t,n,e)}var FA="_reactListening"+Math.random().toString(36).slice(2);function pN(t){if(!t[FA]){t[FA]=!0,fue.forEach(function(r){r!=="selectionchange"&&(wIe.has(r)||W5(r,!1,t),W5(r,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[FA]||(e[FA]=!0,W5("selectionchange",!1,e))}}function ade(t,e,r,n){switch(Hue(e)){case 1:var s=MPe;break;case 4:s=DPe;break;default:s=J7}r=s.bind(null,e,r,t),s=void 0,!B6||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 V5(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 l=n.stateNode.containerInfo;if(l===s||l.nodeType===8&&l.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(;l!==null;){if(a=nx(l),a===null)return;if(c=a.tag,c===5||c===6){n=i=a;continue e}l=l.parentNode}}n=n.return}Aue(function(){var u=i,d=Y7(r),h=[];e:{var f=sde.get(t);if(f!==void 0){var p=tW,m=t;switch(t){case"keypress":if(I2(r)===0)break e;case"keydown":case"keyup":p=QPe;break;case"focusin":m="focus",p=$5;break;case"focusout":m="blur",p=$5;break;case"beforeblur":case"afterblur":p=$5;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=dY;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=FPe;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=eIe;break;case ede:case tde:case rde:p=UPe;break;case nde:p=rIe;break;case"scroll":p=LPe;break;case"wheel":p=sIe;break;case"copy":case"cut":case"paste":p=WPe;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=fY}var g=(e&4)!==0,y=!g&&t==="scroll",x=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,x!==null&&(w=lN(v,x),w!=null&&g.push(mN(v,w,b)))),y)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!==$6&&(m=r.relatedTarget||r.fromElement)&&(nx(m)||m[rf]))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?nx(m):null,m!==null&&(y=Cv(m),m!==y||m.tag!==5&&m.tag!==6)&&(m=null)):(p=null,m=u),p!==m)){if(g=dY,w="onMouseLeave",x="onMouseEnter",v="mouse",(t==="pointerout"||t==="pointerover")&&(g=fY,w="onPointerLeave",x="onPointerEnter",v="pointer"),y=p==null?f:Db(p),b=m==null?f:Db(m),f=new g(w,v+"leave",p,r,d),f.target=y,f.relatedTarget=b,w=null,nx(d)===u&&(g=new g(x,v+"enter",m,r,d),g.target=b,g.relatedTarget=y,w=g),y=w,p&&m)t:{for(g=p,x=m,v=0,b=g;b;b=qv(b))v++;for(b=0,w=x;w;w=qv(w))b++;for(;0<v-b;)g=qv(g),v--;for(;0<b-v;)x=qv(x),b--;for(;v--;){if(g===x||x!==null&&g===x.alternate)break t;g=qv(g),x=qv(x)}g=null}else g=null;p!==null&&_Y(h,f,p,g,!1),m!==null&&y!==null&&_Y(h,y,m,g,!0)}}e:{if(f=u?Db(u):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var j=dIe;else if(gY(f))if(Yue)j=mIe;else{j=fIe;var N=hIe}else(p=f.nodeName)&&p.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(j=pIe);if(j&&(j=j(t,u))){Kue(h,j,r,d);break e}N&&N(t,f,u),t==="focusout"&&(N=f._wrapperState)&&N.controlled&&f.type==="number"&&R6(f,"number",f.value)}switch(N=u?Db(u):window,t){case"focusin":(gY(N)||N.contentEditable==="true")&&(Ob=N,V6=u,S_=null);break;case"focusout":S_=V6=Ob=null;break;case"mousedown":q6=!0;break;case"contextmenu":case"mouseup":case"dragend":q6=!1,wY(h,r,d);break;case"selectionchange":if(yIe)break;case"keydown":case"keyup":wY(h,r,d)}var C;if(nW)e:{switch(t){case"compositionstart":var A="onCompositionStart";break e;case"compositionend":A="onCompositionEnd";break e;case"compositionupdate":A="onCompositionUpdate";break e}A=void 0}else Rb?que(t,r)&&(A="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&(A="onCompositionStart");A&&(Vue&&r.locale!=="ko"&&(Rb||A!=="onCompositionStart"?A==="onCompositionEnd"&&Rb&&(C=Wue()):(pm=d,eW="value"in pm?pm.value:pm.textContent,Rb=!0)),N=tI(u,A),0<N.length&&(A=new hY(A,t,null,r,d),h.push({event:A,listeners:N}),C?A.data=C:(C=Gue(r),C!==null&&(A.data=C)))),(C=aIe?oIe(t,r):lIe(t,r))&&(u=tI(u,"onBeforeInput"),0<u.length&&(d=new hY("onBeforeInput","beforeinput",null,r,d),h.push({event:d,listeners:u}),d.data=C))}ide(h,e)})}function mN(t,e,r){return{instance:t,listener:e,currentTarget:r}}function tI(t,e){for(var r=e+"Capture",n=[];t!==null;){var s=t,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=lN(t,r),i!=null&&n.unshift(mN(t,i,s)),i=lN(t,e),i!=null&&n.push(mN(t,i,s))),t=t.return}return n}function qv(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function _Y(t,e,r,n,s){for(var i=e._reactName,a=[];r!==null&&r!==n;){var l=r,c=l.alternate,u=l.stateNode;if(c!==null&&c===n)break;l.tag===5&&u!==null&&(l=u,s?(c=lN(r,i),c!=null&&a.unshift(mN(r,c,l))):s||(c=lN(r,i),c!=null&&a.push(mN(r,c,l)))),r=r.return}a.length!==0&&t.push({event:e,listeners:a})}var jIe=/\r\n?/g,SIe=/\u0000|\uFFFD/g;function NY(t){return(typeof t=="string"?t:""+t).replace(jIe,`
`).replace(SIe,"")}function BA(t,e,r){if(e=NY(e),NY(t)!==e&&r)throw Error(Je(425))}function rI(){}var G6=null,K6=null;function Y6(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 X6=typeof setTimeout=="function"?setTimeout:void 0,_Ie=typeof clearTimeout=="function"?clearTimeout:void 0,kY=typeof Promise=="function"?Promise:void 0,NIe=typeof queueMicrotask=="function"?queueMicrotask:typeof kY<"u"?function(t){return kY.resolve(null).then(t).catch(kIe)}:X6;function kIe(t){setTimeout(function(){throw t})}function q5(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),dN(e);return}n--}else r!=="$"&&r!=="$?"&&r!=="$!"||n++;r=s}while(r);dN(e)}function jm(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 CY(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 ej=Math.random().toString(36).slice(2),Xu="__reactFiber$"+ej,gN="__reactProps$"+ej,rf="__reactContainer$"+ej,Q6="__reactEvents$"+ej,CIe="__reactListeners$"+ej,EIe="__reactHandles$"+ej;function nx(t){var e=t[Xu];if(e)return e;for(var r=t.parentNode;r;){if(e=r[rf]||r[Xu]){if(r=e.alternate,e.child!==null||r!==null&&r.child!==null)for(t=CY(t);t!==null;){if(r=t[Xu])return r;t=CY(t)}return e}t=r,r=t.parentNode}return null}function NE(t){return t=t[Xu]||t[rf],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Db(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(Je(33))}function EM(t){return t[gN]||null}var Z6=[],Lb=-1;function rg(t){return{current:t}}function Fn(t){0>Lb||(t.current=Z6[Lb],Z6[Lb]=null,Lb--)}function Tn(t,e){Lb++,Z6[Lb]=t.current,t.current=e}var Bm={},ka=rg(Bm),jo=rg(!1),Zy=Bm;function Qw(t,e){var r=t.type.contextTypes;if(!r)return Bm;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 So(t){return t=t.childContextTypes,t!=null}function nI(){Fn(jo),Fn(ka)}function EY(t,e,r){if(ka.current!==Bm)throw Error(Je(168));Tn(ka,e),Tn(jo,r)}function ode(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(Je(108,hPe(t)||"Unknown",s));return ss({},r,n)}function sI(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Bm,Zy=ka.current,Tn(ka,t),Tn(jo,jo.current),!0}function AY(t,e,r){var n=t.stateNode;if(!n)throw Error(Je(169));r?(t=ode(t,e,Zy),n.__reactInternalMemoizedMergedChildContext=t,Fn(jo),Fn(ka),Tn(ka,t)):Fn(jo),Tn(jo,r)}var Jd=null,AM=!1,G5=!1;function lde(t){Jd===null?Jd=[t]:Jd.push(t)}function AIe(t){AM=!0,lde(t)}function ng(){if(!G5&&Jd!==null){G5=!0;var t=0,e=rn;try{var r=Jd;for(rn=1;t<r.length;t++){var n=r[t];do n=n(!0);while(n!==null)}Jd=null,AM=!1}catch(s){throw Jd!==null&&(Jd=Jd.slice(t+1)),Rue(X7,ng),s}finally{rn=e,G5=!1}}return null}var $b=[],Fb=0,iI=null,aI=0,zl=[],Ul=0,Jy=null,Mh=1,Dh="";function Lg(t,e){$b[Fb++]=aI,$b[Fb++]=iI,iI=t,aI=e}function cde(t,e,r){zl[Ul++]=Mh,zl[Ul++]=Dh,zl[Ul++]=Jy,Jy=t;var n=Mh;t=Dh;var s=32-Gc(n)-1;n&=~(1<<s),r+=1;var i=32-Gc(e)+s;if(30<i){var a=s-s%5;i=(n&(1<<a)-1).toString(32),n>>=a,s-=a,Mh=1<<32-Gc(e)+s|r<<s|n,Dh=i+t}else Mh=1<<i|r<<s|n,Dh=t}function iW(t){t.return!==null&&(Lg(t,1),cde(t,1,0))}function aW(t){for(;t===iI;)iI=$b[--Fb],$b[Fb]=null,aI=$b[--Fb],$b[Fb]=null;for(;t===Jy;)Jy=zl[--Ul],zl[Ul]=null,Dh=zl[--Ul],zl[Ul]=null,Mh=zl[--Ul],zl[Ul]=null}var ol=null,al=null,Gn=!1,Bc=null;function ude(t,e){var r=Gl(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 TY(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,ol=t,al=jm(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,ol=t,al=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(r=Jy!==null?{id:Mh,overflow:Dh}:null,t.memoizedState={dehydrated:e,treeContext:r,retryLane:1073741824},r=Gl(18,null,null,0),r.stateNode=e,r.return=t,t.child=r,ol=t,al=null,!0):!1;default:return!1}}function J6(t){return(t.mode&1)!==0&&(t.flags&128)===0}function eB(t){if(Gn){var e=al;if(e){var r=e;if(!TY(t,e)){if(J6(t))throw Error(Je(418));e=jm(r.nextSibling);var n=ol;e&&TY(t,e)?ude(n,r):(t.flags=t.flags&-4097|2,Gn=!1,ol=t)}}else{if(J6(t))throw Error(Je(418));t.flags=t.flags&-4097|2,Gn=!1,ol=t}}}function PY(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;ol=t}function zA(t){if(t!==ol)return!1;if(!Gn)return PY(t),Gn=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!Y6(t.type,t.memoizedProps)),e&&(e=al)){if(J6(t))throw dde(),Error(Je(418));for(;e;)ude(t,e),e=jm(e.nextSibling)}if(PY(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(Je(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"){if(e===0){al=jm(t.nextSibling);break e}e--}else r!=="$"&&r!=="$!"&&r!=="$?"||e++}t=t.nextSibling}al=null}}else al=ol?jm(t.stateNode.nextSibling):null;return!0}function dde(){for(var t=al;t;)t=jm(t.nextSibling)}function Zw(){al=ol=null,Gn=!1}function oW(t){Bc===null?Bc=[t]:Bc.push(t)}var TIe=Sf.ReactCurrentBatchConfig;function Hj(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(Je(309));var n=r.stateNode}if(!n)throw Error(Je(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 l=s.refs;a===null?delete l[i]:l[i]=a},e._stringRef=i,e)}if(typeof t!="string")throw Error(Je(284));if(!r._owner)throw Error(Je(290,t))}return t}function UA(t,e){throw t=Object.prototype.toString.call(e),Error(Je(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function IY(t){var e=t._init;return e(t._payload)}function hde(t){function e(x,v){if(t){var b=x.deletions;b===null?(x.deletions=[v],x.flags|=16):b.push(v)}}function r(x,v){if(!t)return null;for(;v!==null;)e(x,v),v=v.sibling;return null}function n(x,v){for(x=new Map;v!==null;)v.key!==null?x.set(v.key,v):x.set(v.index,v),v=v.sibling;return x}function s(x,v){return x=km(x,v),x.index=0,x.sibling=null,x}function i(x,v,b){return x.index=b,t?(b=x.alternate,b!==null?(b=b.index,b<v?(x.flags|=2,v):b):(x.flags|=2,v)):(x.flags|=1048576,v)}function a(x){return t&&x.alternate===null&&(x.flags|=2),x}function l(x,v,b,w){return v===null||v.tag!==6?(v=e4(b,x.mode,w),v.return=x,v):(v=s(v,b),v.return=x,v)}function c(x,v,b,w){var j=b.type;return j===Ib?d(x,v,b.props.children,w,b.key):v!==null&&(v.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===sp&&IY(j)===v.type)?(w=s(v,b.props),w.ref=Hj(x,v,b),w.return=x,w):(w=F2(b.type,b.key,b.props,null,x.mode,w),w.ref=Hj(x,v,b),w.return=x,w)}function u(x,v,b,w){return v===null||v.tag!==4||v.stateNode.containerInfo!==b.containerInfo||v.stateNode.implementation!==b.implementation?(v=t4(b,x.mode,w),v.return=x,v):(v=s(v,b.children||[]),v.return=x,v)}function d(x,v,b,w,j){return v===null||v.tag!==7?(v=$y(b,x.mode,w,j),v.return=x,v):(v=s(v,b),v.return=x,v)}function h(x,v,b){if(typeof v=="string"&&v!==""||typeof v=="number")return v=e4(""+v,x.mode,b),v.return=x,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case PA:return b=F2(v.type,v.key,v.props,null,x.mode,b),b.ref=Hj(x,null,v),b.return=x,b;case Pb:return v=t4(v,x.mode,b),v.return=x,v;case sp:var w=v._init;return h(x,w(v._payload),b)}if(OS(v)||$j(v))return v=$y(v,x.mode,b,null),v.return=x,v;UA(x,v)}return null}function f(x,v,b,w){var j=v!==null?v.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return j!==null?null:l(x,v,""+b,w);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case PA:return b.key===j?c(x,v,b,w):null;case Pb:return b.key===j?u(x,v,b,w):null;case sp:return j=b._init,f(x,v,j(b._payload),w)}if(OS(b)||$j(b))return j!==null?null:d(x,v,b,w,null);UA(x,b)}return null}function p(x,v,b,w,j){if(typeof w=="string"&&w!==""||typeof w=="number")return x=x.get(b)||null,l(v,x,""+w,j);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case PA:return x=x.get(w.key===null?b:w.key)||null,c(v,x,w,j);case Pb:return x=x.get(w.key===null?b:w.key)||null,u(v,x,w,j);case sp:var N=w._init;return p(x,v,b,N(w._payload),j)}if(OS(w)||$j(w))return x=x.get(b)||null,d(v,x,w,j,null);UA(v,w)}return null}function m(x,v,b,w){for(var j=null,N=null,C=v,A=v=0,E=null;C!==null&&A<b.length;A++){C.index>A?(E=C,C=null):E=C.sibling;var O=f(x,C,b[A],w);if(O===null){C===null&&(C=E);break}t&&C&&O.alternate===null&&e(x,C),v=i(O,v,A),N===null?j=O:N.sibling=O,N=O,C=E}if(A===b.length)return r(x,C),Gn&&Lg(x,A),j;if(C===null){for(;A<b.length;A++)C=h(x,b[A],w),C!==null&&(v=i(C,v,A),N===null?j=C:N.sibling=C,N=C);return Gn&&Lg(x,A),j}for(C=n(x,C);A<b.length;A++)E=p(C,x,A,b[A],w),E!==null&&(t&&E.alternate!==null&&C.delete(E.key===null?A:E.key),v=i(E,v,A),N===null?j=E:N.sibling=E,N=E);return t&&C.forEach(function($){return e(x,$)}),Gn&&Lg(x,A),j}function g(x,v,b,w){var j=$j(b);if(typeof j!="function")throw Error(Je(150));if(b=j.call(b),b==null)throw Error(Je(151));for(var N=j=null,C=v,A=v=0,E=null,O=b.next();C!==null&&!O.done;A++,O=b.next()){C.index>A?(E=C,C=null):E=C.sibling;var $=f(x,C,O.value,w);if($===null){C===null&&(C=E);break}t&&C&&$.alternate===null&&e(x,C),v=i($,v,A),N===null?j=$:N.sibling=$,N=$,C=E}if(O.done)return r(x,C),Gn&&Lg(x,A),j;if(C===null){for(;!O.done;A++,O=b.next())O=h(x,O.value,w),O!==null&&(v=i(O,v,A),N===null?j=O:N.sibling=O,N=O);return Gn&&Lg(x,A),j}for(C=n(x,C);!O.done;A++,O=b.next())O=p(C,x,A,O.value,w),O!==null&&(t&&O.alternate!==null&&C.delete(O.key===null?A:O.key),v=i(O,v,A),N===null?j=O:N.sibling=O,N=O);return t&&C.forEach(function(T){return e(x,T)}),Gn&&Lg(x,A),j}function y(x,v,b,w){if(typeof b=="object"&&b!==null&&b.type===Ib&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case PA:e:{for(var j=b.key,N=v;N!==null;){if(N.key===j){if(j=b.type,j===Ib){if(N.tag===7){r(x,N.sibling),v=s(N,b.props.children),v.return=x,x=v;break e}}else if(N.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===sp&&IY(j)===N.type){r(x,N.sibling),v=s(N,b.props),v.ref=Hj(x,N,b),v.return=x,x=v;break e}r(x,N);break}else e(x,N);N=N.sibling}b.type===Ib?(v=$y(b.props.children,x.mode,w,b.key),v.return=x,x=v):(w=F2(b.type,b.key,b.props,null,x.mode,w),w.ref=Hj(x,v,b),w.return=x,x=w)}return a(x);case Pb:e:{for(N=b.key;v!==null;){if(v.key===N)if(v.tag===4&&v.stateNode.containerInfo===b.containerInfo&&v.stateNode.implementation===b.implementation){r(x,v.sibling),v=s(v,b.children||[]),v.return=x,x=v;break e}else{r(x,v);break}else e(x,v);v=v.sibling}v=t4(b,x.mode,w),v.return=x,x=v}return a(x);case sp:return N=b._init,y(x,v,N(b._payload),w)}if(OS(b))return m(x,v,b,w);if($j(b))return g(x,v,b,w);UA(x,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,v!==null&&v.tag===6?(r(x,v.sibling),v=s(v,b),v.return=x,x=v):(r(x,v),v=e4(b,x.mode,w),v.return=x,x=v),a(x)):r(x,v)}return y}var Jw=hde(!0),fde=hde(!1),oI=rg(null),lI=null,Bb=null,lW=null;function cW(){lW=Bb=lI=null}function uW(t){var e=oI.current;Fn(oI),t._currentValue=e}function tB(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 l0(t,e){lI=t,lW=Bb=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(xo=!0),t.firstContext=null)}function ic(t){var e=t._currentValue;if(lW!==t)if(t={context:t,memoizedValue:e,next:null},Bb===null){if(lI===null)throw Error(Je(308));Bb=t,lI.dependencies={lanes:0,firstContext:t}}else Bb=Bb.next=t;return e}var sx=null;function dW(t){sx===null?sx=[t]:sx.push(t)}function pde(t,e,r,n){var s=e.interleaved;return s===null?(r.next=r,dW(e)):(r.next=s.next,s.next=r),e.interleaved=r,nf(t,n)}function nf(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 ip=!1;function hW(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function mde(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 Gh(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Sm(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,zr&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,nf(t,r)}return s=n.interleaved,s===null?(e.next=e,dW(n)):(e.next=s.next,s.next=e),n.interleaved=e,nf(t,r)}function R2(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,Q7(t,r)}}function RY(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 cI(t,e,r,n){var s=t.updateQueue;ip=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?i=u:a.next=u,a=c;var d=t.alternate;d!==null&&(d=d.updateQueue,l=d.lastBaseUpdate,l!==a&&(l===null?d.firstBaseUpdate=u:l.next=u,d.lastBaseUpdate=c))}if(i!==null){var h=s.baseState;a=0,d=u=c=null,l=i;do{var f=l.lane,p=l.eventTime;if((n&f)===f){d!==null&&(d=d.next={eventTime:p,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var m=t,g=l;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=ss({},h,f);break e;case 2:ip=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,f=s.effects,f===null?s.effects=[l]:f.push(l))}else p={eventTime:p,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=p,c=h):d=d.next=p,a|=f;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;f=l,l=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);tv|=a,t.lanes=a,t.memoizedState=h}}function OY(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(Je(191,s));s.call(n)}}}var kE={},nd=rg(kE),xN=rg(kE),yN=rg(kE);function ix(t){if(t===kE)throw Error(Je(174));return t}function fW(t,e){switch(Tn(yN,e),Tn(xN,t),Tn(nd,kE),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:M6(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=M6(e,t)}Fn(nd),Tn(nd,e)}function e1(){Fn(nd),Fn(xN),Fn(yN)}function gde(t){ix(yN.current);var e=ix(nd.current),r=M6(e,t.type);e!==r&&(Tn(xN,t),Tn(nd,r))}function pW(t){xN.current===t&&(Fn(nd),Fn(xN))}var es=rg(0);function uI(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 K5=[];function mW(){for(var t=0;t<K5.length;t++)K5[t]._workInProgressVersionPrimary=null;K5.length=0}var O2=Sf.ReactCurrentDispatcher,Y5=Sf.ReactCurrentBatchConfig,ev=0,rs=null,Js=null,Ci=null,dI=!1,__=!1,vN=0,PIe=0;function ha(){throw Error(Je(321))}function gW(t,e){if(e===null)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(!Jc(t[r],e[r]))return!1;return!0}function xW(t,e,r,n,s,i){if(ev=i,rs=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,O2.current=t===null||t.memoizedState===null?MIe:DIe,t=r(n,s),__){i=0;do{if(__=!1,vN=0,25<=i)throw Error(Je(301));i+=1,Ci=Js=null,e.updateQueue=null,O2.current=LIe,t=r(n,s)}while(__)}if(O2.current=hI,e=Js!==null&&Js.next!==null,ev=0,Ci=Js=rs=null,dI=!1,e)throw Error(Je(300));return t}function yW(){var t=vN!==0;return vN=0,t}function bu(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ci===null?rs.memoizedState=Ci=t:Ci=Ci.next=t,Ci}function ac(){if(Js===null){var t=rs.alternate;t=t!==null?t.memoizedState:null}else t=Js.next;var e=Ci===null?rs.memoizedState:Ci.next;if(e!==null)Ci=e,Js=t;else{if(t===null)throw Error(Je(310));Js=t,t={memoizedState:Js.memoizedState,baseState:Js.baseState,baseQueue:Js.baseQueue,queue:Js.queue,next:null},Ci===null?rs.memoizedState=Ci=t:Ci=Ci.next=t}return Ci}function bN(t,e){return typeof e=="function"?e(t):e}function X5(t){var e=ac(),r=e.queue;if(r===null)throw Error(Je(311));r.lastRenderedReducer=t;var n=Js,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 l=a=null,c=null,u=i;do{var d=u.lane;if((ev&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?(l=c=h,a=n):c=c.next=h,rs.lanes|=d,tv|=d}u=u.next}while(u!==null&&u!==i);c===null?a=n:c.next=l,Jc(n,e.memoizedState)||(xo=!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,rs.lanes|=i,tv|=i,s=s.next;while(s!==t)}else s===null&&(r.lanes=0);return[e.memoizedState,r.dispatch]}function Q5(t){var e=ac(),r=e.queue;if(r===null)throw Error(Je(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);Jc(i,e.memoizedState)||(xo=!0),e.memoizedState=i,e.baseQueue===null&&(e.baseState=i),r.lastRenderedState=i}return[i,n]}function xde(){}function yde(t,e){var r=rs,n=ac(),s=e(),i=!Jc(n.memoizedState,s);if(i&&(n.memoizedState=s,xo=!0),n=n.queue,vW(wde.bind(null,r,n,t),[t]),n.getSnapshot!==e||i||Ci!==null&&Ci.memoizedState.tag&1){if(r.flags|=2048,wN(9,bde.bind(null,r,n,s,e),void 0,null),Ai===null)throw Error(Je(349));ev&30||vde(r,e,s)}return s}function vde(t,e,r){t.flags|=16384,t={getSnapshot:e,value:r},e=rs.updateQueue,e===null?(e={lastEffect:null,stores:null},rs.updateQueue=e,e.stores=[t]):(r=e.stores,r===null?e.stores=[t]:r.push(t))}function bde(t,e,r,n){e.value=r,e.getSnapshot=n,jde(e)&&Sde(t)}function wde(t,e,r){return r(function(){jde(e)&&Sde(t)})}function jde(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!Jc(t,r)}catch{return!0}}function Sde(t){var e=nf(t,1);e!==null&&Kc(e,t,1,-1)}function MY(t){var e=bu();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:bN,lastRenderedState:t},e.queue=t,t=t.dispatch=OIe.bind(null,rs,t),[e.memoizedState,t]}function wN(t,e,r,n){return t={tag:t,create:e,destroy:r,deps:n,next:null},e=rs.updateQueue,e===null?(e={lastEffect:null,stores:null},rs.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 _de(){return ac().memoizedState}function M2(t,e,r,n){var s=bu();rs.flags|=t,s.memoizedState=wN(1|e,r,void 0,n===void 0?null:n)}function TM(t,e,r,n){var s=ac();n=n===void 0?null:n;var i=void 0;if(Js!==null){var a=Js.memoizedState;if(i=a.destroy,n!==null&&gW(n,a.deps)){s.memoizedState=wN(e,r,i,n);return}}rs.flags|=t,s.memoizedState=wN(1|e,r,i,n)}function DY(t,e){return M2(8390656,8,t,e)}function vW(t,e){return TM(2048,8,t,e)}function Nde(t,e){return TM(4,2,t,e)}function kde(t,e){return TM(4,4,t,e)}function Cde(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 Ede(t,e,r){return r=r!=null?r.concat([t]):null,TM(4,4,Cde.bind(null,e,t),r)}function bW(){}function Ade(t,e){var r=ac();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&gW(e,n[1])?n[0]:(r.memoizedState=[t,e],t)}function Tde(t,e){var r=ac();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&gW(e,n[1])?n[0]:(t=t(),r.memoizedState=[t,e],t)}function Pde(t,e,r){return ev&21?(Jc(r,e)||(r=Due(),rs.lanes|=r,tv|=r,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,xo=!0),t.memoizedState=r)}function IIe(t,e){var r=rn;rn=r!==0&&4>r?r:4,t(!0);var n=Y5.transition;Y5.transition={};try{t(!1),e()}finally{rn=r,Y5.transition=n}}function Ide(){return ac().memoizedState}function RIe(t,e,r){var n=Nm(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},Rde(t))Ode(e,r);else if(r=pde(t,e,r,n),r!==null){var s=Ya();Kc(r,t,n,s),Mde(r,e,n)}}function OIe(t,e,r){var n=Nm(t),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(Rde(t))Ode(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,l=i(a,r);if(s.hasEagerState=!0,s.eagerState=l,Jc(l,a)){var c=e.interleaved;c===null?(s.next=s,dW(e)):(s.next=c.next,c.next=s),e.interleaved=s;return}}catch{}finally{}r=pde(t,e,s,n),r!==null&&(s=Ya(),Kc(r,t,n,s),Mde(r,e,n))}}function Rde(t){var e=t.alternate;return t===rs||e!==null&&e===rs}function Ode(t,e){__=dI=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function Mde(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,Q7(t,r)}}var hI={readContext:ic,useCallback:ha,useContext:ha,useEffect:ha,useImperativeHandle:ha,useInsertionEffect:ha,useLayoutEffect:ha,useMemo:ha,useReducer:ha,useRef:ha,useState:ha,useDebugValue:ha,useDeferredValue:ha,useTransition:ha,useMutableSource:ha,useSyncExternalStore:ha,useId:ha,unstable_isNewReconciler:!1},MIe={readContext:ic,useCallback:function(t,e){return bu().memoizedState=[t,e===void 0?null:e],t},useContext:ic,useEffect:DY,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,M2(4194308,4,Cde.bind(null,e,t),r)},useLayoutEffect:function(t,e){return M2(4194308,4,t,e)},useInsertionEffect:function(t,e){return M2(4,2,t,e)},useMemo:function(t,e){var r=bu();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=bu();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=RIe.bind(null,rs,t),[n.memoizedState,t]},useRef:function(t){var e=bu();return t={current:t},e.memoizedState=t},useState:MY,useDebugValue:bW,useDeferredValue:function(t){return bu().memoizedState=t},useTransition:function(){var t=MY(!1),e=t[0];return t=IIe.bind(null,t[1]),bu().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=rs,s=bu();if(Gn){if(r===void 0)throw Error(Je(407));r=r()}else{if(r=e(),Ai===null)throw Error(Je(349));ev&30||vde(n,e,r)}s.memoizedState=r;var i={value:r,getSnapshot:e};return s.queue=i,DY(wde.bind(null,n,i,t),[t]),n.flags|=2048,wN(9,bde.bind(null,n,i,r,e),void 0,null),r},useId:function(){var t=bu(),e=Ai.identifierPrefix;if(Gn){var r=Dh,n=Mh;r=(n&~(1<<32-Gc(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=vN++,0<r&&(e+="H"+r.toString(32)),e+=":"}else r=PIe++,e=":"+e+"r"+r.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},DIe={readContext:ic,useCallback:Ade,useContext:ic,useEffect:vW,useImperativeHandle:Ede,useInsertionEffect:Nde,useLayoutEffect:kde,useMemo:Tde,useReducer:X5,useRef:_de,useState:function(){return X5(bN)},useDebugValue:bW,useDeferredValue:function(t){var e=ac();return Pde(e,Js.memoizedState,t)},useTransition:function(){var t=X5(bN)[0],e=ac().memoizedState;return[t,e]},useMutableSource:xde,useSyncExternalStore:yde,useId:Ide,unstable_isNewReconciler:!1},LIe={readContext:ic,useCallback:Ade,useContext:ic,useEffect:vW,useImperativeHandle:Ede,useInsertionEffect:Nde,useLayoutEffect:kde,useMemo:Tde,useReducer:Q5,useRef:_de,useState:function(){return Q5(bN)},useDebugValue:bW,useDeferredValue:function(t){var e=ac();return Js===null?e.memoizedState=t:Pde(e,Js.memoizedState,t)},useTransition:function(){var t=Q5(bN)[0],e=ac().memoizedState;return[t,e]},useMutableSource:xde,useSyncExternalStore:yde,useId:Ide,unstable_isNewReconciler:!1};function _c(t,e){if(t&&t.defaultProps){e=ss({},e),t=t.defaultProps;for(var r in t)e[r]===void 0&&(e[r]=t[r]);return e}return e}function rB(t,e,r,n){e=t.memoizedState,r=r(n,e),r=r==null?e:ss({},e,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var PM={isMounted:function(t){return(t=t._reactInternals)?Cv(t)===t:!1},enqueueSetState:function(t,e,r){t=t._reactInternals;var n=Ya(),s=Nm(t),i=Gh(n,s);i.payload=e,r!=null&&(i.callback=r),e=Sm(t,i,s),e!==null&&(Kc(e,t,s,n),R2(e,t,s))},enqueueReplaceState:function(t,e,r){t=t._reactInternals;var n=Ya(),s=Nm(t),i=Gh(n,s);i.tag=1,i.payload=e,r!=null&&(i.callback=r),e=Sm(t,i,s),e!==null&&(Kc(e,t,s,n),R2(e,t,s))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var r=Ya(),n=Nm(t),s=Gh(r,n);s.tag=2,e!=null&&(s.callback=e),e=Sm(t,s,n),e!==null&&(Kc(e,t,n,r),R2(e,t,n))}};function LY(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?!fN(r,n)||!fN(s,i):!0}function Dde(t,e,r){var n=!1,s=Bm,i=e.contextType;return typeof i=="object"&&i!==null?i=ic(i):(s=So(e)?Zy:ka.current,n=e.contextTypes,i=(n=n!=null)?Qw(t,s):Bm),e=new e(r,i),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=PM,t.stateNode=e,e._reactInternals=t,n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=i),e}function $Y(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&&PM.enqueueReplaceState(e,e.state,null)}function nB(t,e,r,n){var s=t.stateNode;s.props=r,s.state=t.memoizedState,s.refs={},hW(t);var i=e.contextType;typeof i=="object"&&i!==null?s.context=ic(i):(i=So(e)?Zy:ka.current,s.context=Qw(t,i)),s.state=t.memoizedState,i=e.getDerivedStateFromProps,typeof i=="function"&&(rB(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&&PM.enqueueReplaceState(s,s.state,null),cI(t,r,s,n),s.state=t.memoizedState),typeof s.componentDidMount=="function"&&(t.flags|=4194308)}function t1(t,e){try{var r="",n=e;do r+=dPe(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 Z5(t,e,r){return{value:t,source:null,stack:r??null,digest:e??null}}function sB(t,e){try{console.error(e.value)}catch(r){setTimeout(function(){throw r})}}var $Ie=typeof WeakMap=="function"?WeakMap:Map;function Lde(t,e,r){r=Gh(-1,r),r.tag=3,r.payload={element:null};var n=e.value;return r.callback=function(){pI||(pI=!0,pB=n),sB(t,e)},r}function $de(t,e,r){r=Gh(-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(){sB(t,e)}}var i=t.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){sB(t,e),typeof n!="function"&&(_m===null?_m=new Set([this]):_m.add(this));var a=e.stack;this.componentDidCatch(e.value,{componentStack:a!==null?a:""})}),r}function FY(t,e,r){var n=t.pingCache;if(n===null){n=t.pingCache=new $Ie;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=ZIe.bind(null,t,e,r),e.then(t,t))}function BY(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 zY(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=Gh(-1,1),e.tag=2,Sm(r,e,1))),r.lanes|=1),t)}var FIe=Sf.ReactCurrentOwner,xo=!1;function Ua(t,e,r,n){e.child=t===null?fde(e,null,r,n):Jw(e,t.child,r,n)}function UY(t,e,r,n,s){r=r.render;var i=e.ref;return l0(e,s),n=xW(t,e,r,n,i,s),r=yW(),t!==null&&!xo?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,sf(t,e,s)):(Gn&&r&&iW(e),e.flags|=1,Ua(t,e,n,s),e.child)}function HY(t,e,r,n,s){if(t===null){var i=r.type;return typeof i=="function"&&!EW(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(e.tag=15,e.type=i,Fde(t,e,i,n,s)):(t=F2(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:fN,r(a,n)&&t.ref===e.ref)return sf(t,e,s)}return e.flags|=1,t=km(i,n),t.ref=e.ref,t.return=e,e.child=t}function Fde(t,e,r,n,s){if(t!==null){var i=t.memoizedProps;if(fN(i,n)&&t.ref===e.ref)if(xo=!1,e.pendingProps=n=i,(t.lanes&s)!==0)t.flags&131072&&(xo=!0);else return e.lanes=t.lanes,sf(t,e,s)}return iB(t,e,r,n,s)}function Bde(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(Ub,Zo),Zo|=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(Ub,Zo),Zo|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=i!==null?i.baseLanes:r,Tn(Ub,Zo),Zo|=n}else i!==null?(n=i.baseLanes|r,e.memoizedState=null):n=r,Tn(Ub,Zo),Zo|=n;return Ua(t,e,s,r),e.child}function zde(t,e){var r=e.ref;(t===null&&r!==null||t!==null&&t.ref!==r)&&(e.flags|=512,e.flags|=2097152)}function iB(t,e,r,n,s){var i=So(r)?Zy:ka.current;return i=Qw(e,i),l0(e,s),r=xW(t,e,r,n,i,s),n=yW(),t!==null&&!xo?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,sf(t,e,s)):(Gn&&n&&iW(e),e.flags|=1,Ua(t,e,r,s),e.child)}function WY(t,e,r,n,s){if(So(r)){var i=!0;sI(e)}else i=!1;if(l0(e,s),e.stateNode===null)D2(t,e),Dde(e,r,n),nB(e,r,n,s),n=!0;else if(t===null){var a=e.stateNode,l=e.memoizedProps;a.props=l;var c=a.context,u=r.contextType;typeof u=="object"&&u!==null?u=ic(u):(u=So(r)?Zy:ka.current,u=Qw(e,u));var d=r.getDerivedStateFromProps,h=typeof d=="function"||typeof a.getSnapshotBeforeUpdate=="function";h||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==n||c!==u)&&$Y(e,a,n,u),ip=!1;var f=e.memoizedState;a.state=f,cI(e,n,a,s),c=e.memoizedState,l!==n||f!==c||jo.current||ip?(typeof d=="function"&&(rB(e,r,d,n),c=e.memoizedState),(l=ip||LY(e,r,l,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=l):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),n=!1)}else{a=e.stateNode,mde(t,e),l=e.memoizedProps,u=e.type===e.elementType?l:_c(e.type,l),a.props=u,h=e.pendingProps,f=a.context,c=r.contextType,typeof c=="object"&&c!==null?c=ic(c):(c=So(r)?Zy:ka.current,c=Qw(e,c));var p=r.getDerivedStateFromProps;(d=typeof p=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==h||f!==c)&&$Y(e,a,n,c),ip=!1,f=e.memoizedState,a.state=f,cI(e,n,a,s);var m=e.memoizedState;l!==h||f!==m||jo.current||ip?(typeof p=="function"&&(rB(e,r,p,n),m=e.memoizedState),(u=ip||LY(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"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===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"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&f===t.memoizedState||(e.flags|=1024),n=!1)}return aB(t,e,r,n,i,s)}function aB(t,e,r,n,s,i){zde(t,e);var a=(e.flags&128)!==0;if(!n&&!a)return s&&AY(e,r,!1),sf(t,e,i);n=e.stateNode,FIe.current=e;var l=a&&typeof r.getDerivedStateFromError!="function"?null:n.render();return e.flags|=1,t!==null&&a?(e.child=Jw(e,t.child,null,i),e.child=Jw(e,null,l,i)):Ua(t,e,l,i),e.memoizedState=n.state,s&&AY(e,r,!0),e.child}function Ude(t){var e=t.stateNode;e.pendingContext?EY(t,e.pendingContext,e.pendingContext!==e.context):e.context&&EY(t,e.context,!1),fW(t,e.containerInfo)}function VY(t,e,r,n,s){return Zw(),oW(s),e.flags|=256,Ua(t,e,r,n),e.child}var oB={dehydrated:null,treeContext:null,retryLane:0};function lB(t){return{baseLanes:t,cachePool:null,transitions:null}}function Hde(t,e,r){var n=e.pendingProps,s=es.current,i=!1,a=(e.flags&128)!==0,l;if((l=a)||(l=t!==null&&t.memoizedState===null?!1:(s&2)!==0),l?(i=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(s|=1),Tn(es,s&1),t===null)return eB(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=OM(a,n,0,null),t=$y(t,n,r,null),i.return=e,t.return=e,i.sibling=t,e.child=i,e.child.memoizedState=lB(r),e.memoizedState=oB,t):wW(e,a));if(s=t.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return BIe(t,e,a,n,l,s,r);if(i){i=n.fallback,a=e.mode,s=t.child,l=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=km(s,c),n.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=km(l,i):(i=$y(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?lB(r):{baseLanes:a.baseLanes|r,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=t.childLanes&~r,e.memoizedState=oB,n}return i=t.child,t=i.sibling,n=km(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 wW(t,e){return e=OM({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function HA(t,e,r,n){return n!==null&&oW(n),Jw(e,t.child,null,r),t=wW(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function BIe(t,e,r,n,s,i,a){if(r)return e.flags&256?(e.flags&=-257,n=Z5(Error(Je(422))),HA(t,e,a,n)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(i=n.fallback,s=e.mode,n=OM({mode:"visible",children:n.children},s,0,null),i=$y(i,s,a,null),i.flags|=2,n.return=e,i.return=e,n.sibling=i,e.child=n,e.mode&1&&Jw(e,t.child,null,a),e.child.memoizedState=lB(a),e.memoizedState=oB,i);if(!(e.mode&1))return HA(t,e,a,null);if(s.data==="$!"){if(n=s.nextSibling&&s.nextSibling.dataset,n)var l=n.dgst;return n=l,i=Error(Je(419)),n=Z5(i,n,void 0),HA(t,e,a,n)}if(l=(a&t.childLanes)!==0,xo||l){if(n=Ai,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,nf(t,s),Kc(n,t,s,-1))}return CW(),n=Z5(Error(Je(421))),HA(t,e,a,n)}return s.data==="$?"?(e.flags|=128,e.child=t.child,e=JIe.bind(null,t),s._reactRetry=e,null):(t=i.treeContext,al=jm(s.nextSibling),ol=e,Gn=!0,Bc=null,t!==null&&(zl[Ul++]=Mh,zl[Ul++]=Dh,zl[Ul++]=Jy,Mh=t.id,Dh=t.overflow,Jy=e),e=wW(e,n.children),e.flags|=4096,e)}function qY(t,e,r){t.lanes|=e;var n=t.alternate;n!==null&&(n.lanes|=e),tB(t.return,e,r)}function J5(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 Wde(t,e,r){var n=e.pendingProps,s=n.revealOrder,i=n.tail;if(Ua(t,e,n.children,r),n=es.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&&qY(t,r,e);else if(t.tag===19)qY(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(es,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&&uI(t)===null&&(s=r),r=r.sibling;r=s,r===null?(s=e.child,e.child=null):(s=r.sibling,r.sibling=null),J5(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&&uI(t)===null){e.child=s;break}t=s.sibling,s.sibling=r,r=s,s=t}J5(e,!0,r,null,i);break;case"together":J5(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function D2(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function sf(t,e,r){if(t!==null&&(e.dependencies=t.dependencies),tv|=e.lanes,!(r&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(Je(153));if(e.child!==null){for(t=e.child,r=km(t,t.pendingProps),e.child=r,r.return=e;t.sibling!==null;)t=t.sibling,r=r.sibling=km(t,t.pendingProps),r.return=e;r.sibling=null}return e.child}function zIe(t,e,r){switch(e.tag){case 3:Ude(e),Zw();break;case 5:gde(e);break;case 1:So(e.type)&&sI(e);break;case 4:fW(e,e.stateNode.containerInfo);break;case 10:var n=e.type._context,s=e.memoizedProps.value;Tn(oI,n._currentValue),n._currentValue=s;break;case 13:if(n=e.memoizedState,n!==null)return n.dehydrated!==null?(Tn(es,es.current&1),e.flags|=128,null):r&e.child.childLanes?Hde(t,e,r):(Tn(es,es.current&1),t=sf(t,e,r),t!==null?t.sibling:null);Tn(es,es.current&1);break;case 19:if(n=(r&e.childLanes)!==0,t.flags&128){if(n)return Wde(t,e,r);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),Tn(es,es.current),n)break;return null;case 22:case 23:return e.lanes=0,Bde(t,e,r)}return sf(t,e,r)}var Vde,cB,qde,Gde;Vde=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}};cB=function(){};qde=function(t,e,r,n){var s=t.memoizedProps;if(s!==n){t=e.stateNode,ix(nd.current);var i=null;switch(r){case"input":s=P6(t,s),n=P6(t,n),i=[];break;case"select":s=ss({},s,{value:void 0}),n=ss({},n,{value:void 0}),i=[];break;case"textarea":s=O6(t,s),n=O6(t,n),i=[];break;default:typeof s.onClick!="function"&&typeof n.onClick=="function"&&(t.onclick=rI)}D6(r,n);var a;r=null;for(u in s)if(!n.hasOwnProperty(u)&&s.hasOwnProperty(u)&&s[u]!=null)if(u==="style"){var l=s[u];for(a in l)l.hasOwnProperty(a)&&(r||(r={}),r[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(aN.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in n){var c=n[u];if(l=s!=null?s[u]:void 0,n.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(r||(r={}),r[a]="");for(a in c)c.hasOwnProperty(a)&&l[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,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(aN.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&On("scroll",t),i||l===c||(i=[])):(i=i||[]).push(u,c))}r&&(i=i||[]).push("style",r);var u=i;(e.updateQueue=u)&&(e.flags|=4)}};Gde=function(t,e,r,n){r!==n&&(e.flags|=4)};function Wj(t,e){if(!Gn)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 fa(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 UIe(t,e,r){var n=e.pendingProps;switch(aW(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return fa(e),null;case 1:return So(e.type)&&nI(),fa(e),null;case 3:return n=e.stateNode,e1(),Fn(jo),Fn(ka),mW(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(t===null||t.child===null)&&(zA(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Bc!==null&&(xB(Bc),Bc=null))),cB(t,e),fa(e),null;case 5:pW(e);var s=ix(yN.current);if(r=e.type,t!==null&&e.stateNode!=null)qde(t,e,r,n,s),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!n){if(e.stateNode===null)throw Error(Je(166));return fa(e),null}if(t=ix(nd.current),zA(e)){n=e.stateNode,r=e.type;var i=e.memoizedProps;switch(n[Xu]=e,n[gN]=i,t=(e.mode&1)!==0,r){case"dialog":On("cancel",n),On("close",n);break;case"iframe":case"object":case"embed":On("load",n);break;case"video":case"audio":for(s=0;s<DS.length;s++)On(DS[s],n);break;case"source":On("error",n);break;case"img":case"image":case"link":On("error",n),On("load",n);break;case"details":On("toggle",n);break;case"input":tY(n,i),On("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!i.multiple},On("invalid",n);break;case"textarea":nY(n,i),On("invalid",n)}D6(r,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var l=i[a];a==="children"?typeof l=="string"?n.textContent!==l&&(i.suppressHydrationWarning!==!0&&BA(n.textContent,l,t),s=["children",l]):typeof l=="number"&&n.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&BA(n.textContent,l,t),s=["children",""+l]):aN.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&On("scroll",n)}switch(r){case"input":IA(n),rY(n,i,!0);break;case"textarea":IA(n),sY(n);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(n.onclick=rI)}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=wue(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[Xu]=e,t[gN]=n,Vde(t,e,!1,!1),e.stateNode=t;e:{switch(a=L6(r,n),r){case"dialog":On("cancel",t),On("close",t),s=n;break;case"iframe":case"object":case"embed":On("load",t),s=n;break;case"video":case"audio":for(s=0;s<DS.length;s++)On(DS[s],t);s=n;break;case"source":On("error",t),s=n;break;case"img":case"image":case"link":On("error",t),On("load",t),s=n;break;case"details":On("toggle",t),s=n;break;case"input":tY(t,n),s=P6(t,n),On("invalid",t);break;case"option":s=n;break;case"select":t._wrapperState={wasMultiple:!!n.multiple},s=ss({},n,{value:void 0}),On("invalid",t);break;case"textarea":nY(t,n),s=O6(t,n),On("invalid",t);break;default:s=n}D6(r,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?_ue(t,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&jue(t,c)):i==="children"?typeof c=="string"?(r!=="textarea"||c!=="")&&oN(t,c):typeof c=="number"&&oN(t,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(aN.hasOwnProperty(i)?c!=null&&i==="onScroll"&&On("scroll",t):c!=null&&V7(t,i,c,a))}switch(r){case"input":IA(t),rY(t,n,!1);break;case"textarea":IA(t),sY(t);break;case"option":n.value!=null&&t.setAttribute("value",""+Fm(n.value));break;case"select":t.multiple=!!n.multiple,i=n.value,i!=null?s0(t,!!n.multiple,i,!1):n.defaultValue!=null&&s0(t,!!n.multiple,n.defaultValue,!0);break;default:typeof s.onClick=="function"&&(t.onclick=rI)}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 fa(e),null;case 6:if(t&&e.stateNode!=null)Gde(t,e,t.memoizedProps,n);else{if(typeof n!="string"&&e.stateNode===null)throw Error(Je(166));if(r=ix(yN.current),ix(nd.current),zA(e)){if(n=e.stateNode,r=e.memoizedProps,n[Xu]=e,(i=n.nodeValue!==r)&&(t=ol,t!==null))switch(t.tag){case 3:BA(n.nodeValue,r,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&BA(n.nodeValue,r,(t.mode&1)!==0)}i&&(e.flags|=4)}else n=(r.nodeType===9?r:r.ownerDocument).createTextNode(n),n[Xu]=e,e.stateNode=n}return fa(e),null;case 13:if(Fn(es),n=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(Gn&&al!==null&&e.mode&1&&!(e.flags&128))dde(),Zw(),e.flags|=98560,i=!1;else if(i=zA(e),n!==null&&n.dehydrated!==null){if(t===null){if(!i)throw Error(Je(318));if(i=e.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Je(317));i[Xu]=e}else Zw(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;fa(e),i=!1}else Bc!==null&&(xB(Bc),Bc=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||es.current&1?ti===0&&(ti=3):CW())),e.updateQueue!==null&&(e.flags|=4),fa(e),null);case 4:return e1(),cB(t,e),t===null&&pN(e.stateNode.containerInfo),fa(e),null;case 10:return uW(e.type._context),fa(e),null;case 17:return So(e.type)&&nI(),fa(e),null;case 19:if(Fn(es),i=e.memoizedState,i===null)return fa(e),null;if(n=(e.flags&128)!==0,a=i.rendering,a===null)if(n)Wj(i,!1);else{if(ti!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(a=uI(t),a!==null){for(e.flags|=128,Wj(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(es,es.current&1|2),e.child}t=t.sibling}i.tail!==null&&Cs()>r1&&(e.flags|=128,n=!0,Wj(i,!1),e.lanes=4194304)}else{if(!n)if(t=uI(a),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),Wj(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!Gn)return fa(e),null}else 2*Cs()-i.renderingStartTime>r1&&r!==1073741824&&(e.flags|=128,n=!0,Wj(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=Cs(),e.sibling=null,r=es.current,Tn(es,n?r&1|2:r&1),e):(fa(e),null);case 22:case 23:return kW(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?Zo&1073741824&&(fa(e),e.subtreeFlags&6&&(e.flags|=8192)):fa(e),null;case 24:return null;case 25:return null}throw Error(Je(156,e.tag))}function HIe(t,e){switch(aW(e),e.tag){case 1:return So(e.type)&&nI(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return e1(),Fn(jo),Fn(ka),mW(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return pW(e),null;case 13:if(Fn(es),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Je(340));Zw()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Fn(es),null;case 4:return e1(),null;case 10:return uW(e.type._context),null;case 22:case 23:return kW(),null;case 24:return null;default:return null}}var WA=!1,wa=!1,WIe=typeof WeakSet=="function"?WeakSet:Set,jt=null;function zb(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){ps(t,e,n)}else r.current=null}function uB(t,e,r){try{r()}catch(n){ps(t,e,n)}}var GY=!1;function VIe(t,e){if(G6=JP,t=Zue(),sW(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,l=-1,c=-1,u=0,d=0,h=t,f=null;t:for(;;){for(var p;h!==r||s!==0&&h.nodeType!==3||(l=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&&(l=a),f===i&&++d===n&&(c=a),(p=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=p}r=l===-1||c===-1?null:{start:l,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(K6={focusedElem:t,selectionRange:r},JP=!1,jt=e;jt!==null;)if(e=jt,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,jt=t;else for(;jt!==null;){e=jt;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,y=m.memoizedState,x=e.stateNode,v=x.getSnapshotBeforeUpdate(e.elementType===e.type?g:_c(e.type,g),y);x.__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(Je(163))}}catch(w){ps(e,e.return,w)}if(t=e.sibling,t!==null){t.return=e.return,jt=t;break}jt=e.return}return m=GY,GY=!1,m}function N_(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&&uB(e,r,i)}s=s.next}while(s!==n)}}function IM(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 dB(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 Kde(t){var e=t.alternate;e!==null&&(t.alternate=null,Kde(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Xu],delete e[gN],delete e[Q6],delete e[CIe],delete e[EIe])),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 Yde(t){return t.tag===5||t.tag===3||t.tag===4}function KY(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Yde(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 hB(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=rI));else if(n!==4&&(t=t.child,t!==null))for(hB(t,e,r),t=t.sibling;t!==null;)hB(t,e,r),t=t.sibling}function fB(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(fB(t,e,r),t=t.sibling;t!==null;)fB(t,e,r),t=t.sibling}var Gi=null,$c=!1;function Ff(t,e,r){for(r=r.child;r!==null;)Xde(t,e,r),r=r.sibling}function Xde(t,e,r){if(rd&&typeof rd.onCommitFiberUnmount=="function")try{rd.onCommitFiberUnmount(_M,r)}catch{}switch(r.tag){case 5:wa||zb(r,e);case 6:var n=Gi,s=$c;Gi=null,Ff(t,e,r),Gi=n,$c=s,Gi!==null&&($c?(t=Gi,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Gi.removeChild(r.stateNode));break;case 18:Gi!==null&&($c?(t=Gi,r=r.stateNode,t.nodeType===8?q5(t.parentNode,r):t.nodeType===1&&q5(t,r),dN(t)):q5(Gi,r.stateNode));break;case 4:n=Gi,s=$c,Gi=r.stateNode.containerInfo,$c=!0,Ff(t,e,r),Gi=n,$c=s;break;case 0:case 11:case 14:case 15:if(!wa&&(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)&&uB(r,e,a),s=s.next}while(s!==n)}Ff(t,e,r);break;case 1:if(!wa&&(zb(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(l){ps(r,e,l)}Ff(t,e,r);break;case 21:Ff(t,e,r);break;case 22:r.mode&1?(wa=(n=wa)||r.memoizedState!==null,Ff(t,e,r),wa=n):Ff(t,e,r);break;default:Ff(t,e,r)}}function YY(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new WIe),e.forEach(function(n){var s=eRe.bind(null,t,n);r.has(n)||(r.add(n),n.then(s,s))})}}function mc(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,l=a;e:for(;l!==null;){switch(l.tag){case 5:Gi=l.stateNode,$c=!1;break e;case 3:Gi=l.stateNode.containerInfo,$c=!0;break e;case 4:Gi=l.stateNode.containerInfo,$c=!0;break e}l=l.return}if(Gi===null)throw Error(Je(160));Xde(i,a,s),Gi=null,$c=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){ps(s,e,u)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)Qde(e,t),e=e.sibling}function Qde(t,e){var r=t.alternate,n=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(mc(e,t),mu(t),n&4){try{N_(3,t,t.return),IM(3,t)}catch(g){ps(t,t.return,g)}try{N_(5,t,t.return)}catch(g){ps(t,t.return,g)}}break;case 1:mc(e,t),mu(t),n&512&&r!==null&&zb(r,r.return);break;case 5:if(mc(e,t),mu(t),n&512&&r!==null&&zb(r,r.return),t.flags&32){var s=t.stateNode;try{oN(s,"")}catch(g){ps(t,t.return,g)}}if(n&4&&(s=t.stateNode,s!=null)){var i=t.memoizedProps,a=r!==null?r.memoizedProps:i,l=t.type,c=t.updateQueue;if(t.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&vue(s,i),L6(l,a);var u=L6(l,i);for(a=0;a<c.length;a+=2){var d=c[a],h=c[a+1];d==="style"?_ue(s,h):d==="dangerouslySetInnerHTML"?jue(s,h):d==="children"?oN(s,h):V7(s,d,h,u)}switch(l){case"input":I6(s,i);break;case"textarea":bue(s,i);break;case"select":var f=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var p=i.value;p!=null?s0(s,!!i.multiple,p,!1):f!==!!i.multiple&&(i.defaultValue!=null?s0(s,!!i.multiple,i.defaultValue,!0):s0(s,!!i.multiple,i.multiple?[]:"",!1))}s[gN]=i}catch(g){ps(t,t.return,g)}}break;case 6:if(mc(e,t),mu(t),n&4){if(t.stateNode===null)throw Error(Je(162));s=t.stateNode,i=t.memoizedProps;try{s.nodeValue=i}catch(g){ps(t,t.return,g)}}break;case 3:if(mc(e,t),mu(t),n&4&&r!==null&&r.memoizedState.isDehydrated)try{dN(e.containerInfo)}catch(g){ps(t,t.return,g)}break;case 4:mc(e,t),mu(t);break;case 13:mc(e,t),mu(t),s=t.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(_W=Cs())),n&4&&YY(t);break;case 22:if(d=r!==null&&r.memoizedState!==null,t.mode&1?(wa=(u=wa)||d,mc(e,t),wa=u):mc(e,t),mu(t),n&8192){if(u=t.memoizedState!==null,(t.stateNode.isHidden=u)&&!d&&t.mode&1)for(jt=t,d=t.child;d!==null;){for(h=jt=d;jt!==null;){switch(f=jt,p=f.child,f.tag){case 0:case 11:case 14:case 15:N_(4,f,f.return);break;case 1:zb(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){ps(n,r,g)}}break;case 5:zb(f,f.return);break;case 22:if(f.memoizedState!==null){QY(h);continue}}p!==null?(p.return=f,jt=p):QY(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"):(l=h.stateNode,c=h.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Sue("display",a))}catch(g){ps(t,t.return,g)}}}else if(h.tag===6){if(d===null)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(g){ps(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:mc(e,t),mu(t),n&4&&YY(t);break;case 21:break;default:mc(e,t),mu(t)}}function mu(t){var e=t.flags;if(e&2){try{e:{for(var r=t.return;r!==null;){if(Yde(r)){var n=r;break e}r=r.return}throw Error(Je(160))}switch(n.tag){case 5:var s=n.stateNode;n.flags&32&&(oN(s,""),n.flags&=-33);var i=KY(t);fB(t,i,s);break;case 3:case 4:var a=n.stateNode.containerInfo,l=KY(t);hB(t,l,a);break;default:throw Error(Je(161))}}catch(c){ps(t,t.return,c)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function qIe(t,e,r){jt=t,Zde(t)}function Zde(t,e,r){for(var n=(t.mode&1)!==0;jt!==null;){var s=jt,i=s.child;if(s.tag===22&&n){var a=s.memoizedState!==null||WA;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||wa;l=WA;var u=wa;if(WA=a,(wa=c)&&!u)for(jt=s;jt!==null;)a=jt,c=a.child,a.tag===22&&a.memoizedState!==null?ZY(s):c!==null?(c.return=a,jt=c):ZY(s);for(;i!==null;)jt=i,Zde(i),i=i.sibling;jt=s,WA=l,wa=u}XY(t)}else s.subtreeFlags&8772&&i!==null?(i.return=s,jt=i):XY(t)}}function XY(t){for(;jt!==null;){var e=jt;if(e.flags&8772){var r=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:wa||IM(5,e);break;case 1:var n=e.stateNode;if(e.flags&4&&!wa)if(r===null)n.componentDidMount();else{var s=e.elementType===e.type?r.memoizedProps:_c(e.type,r.memoizedProps);n.componentDidUpdate(s,r.memoizedState,n.__reactInternalSnapshotBeforeUpdate)}var i=e.updateQueue;i!==null&&OY(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}OY(e,a,r)}break;case 5:var l=e.stateNode;if(r===null&&e.flags&4){r=l;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&&dN(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Je(163))}wa||e.flags&512&&dB(e)}catch(f){ps(e,e.return,f)}}if(e===t){jt=null;break}if(r=e.sibling,r!==null){r.return=e.return,jt=r;break}jt=e.return}}function QY(t){for(;jt!==null;){var e=jt;if(e===t){jt=null;break}var r=e.sibling;if(r!==null){r.return=e.return,jt=r;break}jt=e.return}}function ZY(t){for(;jt!==null;){var e=jt;try{switch(e.tag){case 0:case 11:case 15:var r=e.return;try{IM(4,e)}catch(c){ps(e,r,c)}break;case 1:var n=e.stateNode;if(typeof n.componentDidMount=="function"){var s=e.return;try{n.componentDidMount()}catch(c){ps(e,s,c)}}var i=e.return;try{dB(e)}catch(c){ps(e,i,c)}break;case 5:var a=e.return;try{dB(e)}catch(c){ps(e,a,c)}}}catch(c){ps(e,e.return,c)}if(e===t){jt=null;break}var l=e.sibling;if(l!==null){l.return=e.return,jt=l;break}jt=e.return}}var GIe=Math.ceil,fI=Sf.ReactCurrentDispatcher,jW=Sf.ReactCurrentOwner,Zl=Sf.ReactCurrentBatchConfig,zr=0,Ai=null,$s=null,sa=0,Zo=0,Ub=rg(0),ti=0,jN=null,tv=0,RM=0,SW=0,k_=null,po=null,_W=0,r1=1/0,Vd=null,pI=!1,pB=null,_m=null,VA=!1,mm=null,mI=0,C_=0,mB=null,L2=-1,$2=0;function Ya(){return zr&6?Cs():L2!==-1?L2:L2=Cs()}function Nm(t){return t.mode&1?zr&2&&sa!==0?sa&-sa:TIe.transition!==null?($2===0&&($2=Due()),$2):(t=rn,t!==0||(t=window.event,t=t===void 0?16:Hue(t.type)),t):1}function Kc(t,e,r,n){if(50<C_)throw C_=0,mB=null,Error(Je(185));SE(t,r,n),(!(zr&2)||t!==Ai)&&(t===Ai&&(!(zr&2)&&(RM|=r),ti===4&&dp(t,sa)),_o(t,n),r===1&&zr===0&&!(e.mode&1)&&(r1=Cs()+500,AM&&ng()))}function _o(t,e){var r=t.callbackNode;TPe(t,e);var n=ZP(t,t===Ai?sa:0);if(n===0)r!==null&&oY(r),t.callbackNode=null,t.callbackPriority=0;else if(e=n&-n,t.callbackPriority!==e){if(r!=null&&oY(r),e===1)t.tag===0?AIe(JY.bind(null,t)):lde(JY.bind(null,t)),NIe(function(){!(zr&6)&&ng()}),r=null;else{switch(Lue(n)){case 1:r=X7;break;case 4:r=Oue;break;case 16:r=QP;break;case 536870912:r=Mue;break;default:r=QP}r=ahe(r,Jde.bind(null,t))}t.callbackPriority=e,t.callbackNode=r}}function Jde(t,e){if(L2=-1,$2=0,zr&6)throw Error(Je(327));var r=t.callbackNode;if(c0()&&t.callbackNode!==r)return null;var n=ZP(t,t===Ai?sa:0);if(n===0)return null;if(n&30||n&t.expiredLanes||e)e=gI(t,n);else{e=n;var s=zr;zr|=2;var i=the();(Ai!==t||sa!==e)&&(Vd=null,r1=Cs()+500,Ly(t,e));do try{XIe();break}catch(l){ehe(t,l)}while(!0);cW(),fI.current=i,zr=s,$s!==null?e=0:(Ai=null,sa=0,e=ti)}if(e!==0){if(e===2&&(s=U6(t),s!==0&&(n=s,e=gB(t,s))),e===1)throw r=jN,Ly(t,0),dp(t,n),_o(t,Cs()),r;if(e===6)dp(t,n);else{if(s=t.current.alternate,!(n&30)&&!KIe(s)&&(e=gI(t,n),e===2&&(i=U6(t),i!==0&&(n=i,e=gB(t,i))),e===1))throw r=jN,Ly(t,0),dp(t,n),_o(t,Cs()),r;switch(t.finishedWork=s,t.finishedLanes=n,e){case 0:case 1:throw Error(Je(345));case 2:$g(t,po,Vd);break;case 3:if(dp(t,n),(n&130023424)===n&&(e=_W+500-Cs(),10<e)){if(ZP(t,0)!==0)break;if(s=t.suspendedLanes,(s&n)!==n){Ya(),t.pingedLanes|=t.suspendedLanes&s;break}t.timeoutHandle=X6($g.bind(null,t,po,Vd),e);break}$g(t,po,Vd);break;case 4:if(dp(t,n),(n&4194240)===n)break;for(e=t.eventTimes,s=-1;0<n;){var a=31-Gc(n);i=1<<a,a=e[a],a>s&&(s=a),n&=~i}if(n=s,n=Cs()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*GIe(n/1960))-n,10<n){t.timeoutHandle=X6($g.bind(null,t,po,Vd),n);break}$g(t,po,Vd);break;case 5:$g(t,po,Vd);break;default:throw Error(Je(329))}}}return _o(t,Cs()),t.callbackNode===r?Jde.bind(null,t):null}function gB(t,e){var r=k_;return t.current.memoizedState.isDehydrated&&(Ly(t,e).flags|=256),t=gI(t,e),t!==2&&(e=po,po=r,e!==null&&xB(e)),t}function xB(t){po===null?po=t:po.push.apply(po,t)}function KIe(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(!Jc(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 dp(t,e){for(e&=~SW,e&=~RM,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var r=31-Gc(e),n=1<<r;t[r]=-1,e&=~n}}function JY(t){if(zr&6)throw Error(Je(327));c0();var e=ZP(t,0);if(!(e&1))return _o(t,Cs()),null;var r=gI(t,e);if(t.tag!==0&&r===2){var n=U6(t);n!==0&&(e=n,r=gB(t,n))}if(r===1)throw r=jN,Ly(t,0),dp(t,e),_o(t,Cs()),r;if(r===6)throw Error(Je(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,$g(t,po,Vd),_o(t,Cs()),null}function NW(t,e){var r=zr;zr|=1;try{return t(e)}finally{zr=r,zr===0&&(r1=Cs()+500,AM&&ng())}}function rv(t){mm!==null&&mm.tag===0&&!(zr&6)&&c0();var e=zr;zr|=1;var r=Zl.transition,n=rn;try{if(Zl.transition=null,rn=1,t)return t()}finally{rn=n,Zl.transition=r,zr=e,!(zr&6)&&ng()}}function kW(){Zo=Ub.current,Fn(Ub)}function Ly(t,e){t.finishedWork=null,t.finishedLanes=0;var r=t.timeoutHandle;if(r!==-1&&(t.timeoutHandle=-1,_Ie(r)),$s!==null)for(r=$s.return;r!==null;){var n=r;switch(aW(n),n.tag){case 1:n=n.type.childContextTypes,n!=null&&nI();break;case 3:e1(),Fn(jo),Fn(ka),mW();break;case 5:pW(n);break;case 4:e1();break;case 13:Fn(es);break;case 19:Fn(es);break;case 10:uW(n.type._context);break;case 22:case 23:kW()}r=r.return}if(Ai=t,$s=t=km(t.current,null),sa=Zo=e,ti=0,jN=null,SW=RM=tv=0,po=k_=null,sx!==null){for(e=0;e<sx.length;e++)if(r=sx[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}sx=null}return t}function ehe(t,e){do{var r=$s;try{if(cW(),O2.current=hI,dI){for(var n=rs.memoizedState;n!==null;){var s=n.queue;s!==null&&(s.pending=null),n=n.next}dI=!1}if(ev=0,Ci=Js=rs=null,__=!1,vN=0,jW.current=null,r===null||r.return===null){ti=1,jN=e,$s=null;break}e:{var i=t,a=r.return,l=r,c=e;if(e=sa,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=l,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=BY(a);if(p!==null){p.flags&=-257,zY(p,a,l,i,e),p.mode&1&&FY(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)){FY(i,u,e),CW();break e}c=Error(Je(426))}}else if(Gn&&l.mode&1){var y=BY(a);if(y!==null){!(y.flags&65536)&&(y.flags|=256),zY(y,a,l,i,e),oW(t1(c,l));break e}}i=c=t1(c,l),ti!==4&&(ti=2),k_===null?k_=[i]:k_.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,e&=-e,i.lanes|=e;var x=Lde(i,c,e);RY(i,x);break e;case 1:l=c;var v=i.type,b=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(_m===null||!_m.has(b)))){i.flags|=65536,e&=-e,i.lanes|=e;var w=$de(i,l,e);RY(i,w);break e}}i=i.return}while(i!==null)}nhe(r)}catch(j){e=j,$s===r&&r!==null&&($s=r=r.return);continue}break}while(!0)}function the(){var t=fI.current;return fI.current=hI,t===null?hI:t}function CW(){(ti===0||ti===3||ti===2)&&(ti=4),Ai===null||!(tv&268435455)&&!(RM&268435455)||dp(Ai,sa)}function gI(t,e){var r=zr;zr|=2;var n=the();(Ai!==t||sa!==e)&&(Vd=null,Ly(t,e));do try{YIe();break}catch(s){ehe(t,s)}while(!0);if(cW(),zr=r,fI.current=n,$s!==null)throw Error(Je(261));return Ai=null,sa=0,ti}function YIe(){for(;$s!==null;)rhe($s)}function XIe(){for(;$s!==null&&!wPe();)rhe($s)}function rhe(t){var e=ihe(t.alternate,t,Zo);t.memoizedProps=t.pendingProps,e===null?nhe(t):$s=e,jW.current=null}function nhe(t){var e=t;do{var r=e.alternate;if(t=e.return,e.flags&32768){if(r=HIe(r,e),r!==null){r.flags&=32767,$s=r;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{ti=6,$s=null;return}}else if(r=UIe(r,e,Zo),r!==null){$s=r;return}if(e=e.sibling,e!==null){$s=e;return}$s=e=t}while(e!==null);ti===0&&(ti=5)}function $g(t,e,r){var n=rn,s=Zl.transition;try{Zl.transition=null,rn=1,QIe(t,e,r,n)}finally{Zl.transition=s,rn=n}return null}function QIe(t,e,r,n){do c0();while(mm!==null);if(zr&6)throw Error(Je(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(Je(177));t.callbackNode=null,t.callbackPriority=0;var i=r.lanes|r.childLanes;if(PPe(t,i),t===Ai&&($s=Ai=null,sa=0),!(r.subtreeFlags&2064)&&!(r.flags&2064)||VA||(VA=!0,ahe(QP,function(){return c0(),null})),i=(r.flags&15990)!==0,r.subtreeFlags&15990||i){i=Zl.transition,Zl.transition=null;var a=rn;rn=1;var l=zr;zr|=4,jW.current=null,VIe(t,r),Qde(r,t),xIe(K6),JP=!!G6,K6=G6=null,t.current=r,qIe(r),jPe(),zr=l,rn=a,Zl.transition=i}else t.current=r;if(VA&&(VA=!1,mm=t,mI=s),i=t.pendingLanes,i===0&&(_m=null),NPe(r.stateNode),_o(t,Cs()),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(pI)throw pI=!1,t=pB,pB=null,t;return mI&1&&t.tag!==0&&c0(),i=t.pendingLanes,i&1?t===mB?C_++:(C_=0,mB=t):C_=0,ng(),null}function c0(){if(mm!==null){var t=Lue(mI),e=Zl.transition,r=rn;try{if(Zl.transition=null,rn=16>t?16:t,mm===null)var n=!1;else{if(t=mm,mm=null,mI=0,zr&6)throw Error(Je(331));var s=zr;for(zr|=4,jt=t.current;jt!==null;){var i=jt,a=i.child;if(jt.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(jt=u;jt!==null;){var d=jt;switch(d.tag){case 0:case 11:case 15:N_(8,d,i)}var h=d.child;if(h!==null)h.return=d,jt=h;else for(;jt!==null;){d=jt;var f=d.sibling,p=d.return;if(Kde(d),d===u){jt=null;break}if(f!==null){f.return=p,jt=f;break}jt=p}}}var m=i.alternate;if(m!==null){var g=m.child;if(g!==null){m.child=null;do{var y=g.sibling;g.sibling=null,g=y}while(g!==null)}}jt=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,jt=a;else e:for(;jt!==null;){if(i=jt,i.flags&2048)switch(i.tag){case 0:case 11:case 15:N_(9,i,i.return)}var x=i.sibling;if(x!==null){x.return=i.return,jt=x;break e}jt=i.return}}var v=t.current;for(jt=v;jt!==null;){a=jt;var b=a.child;if(a.subtreeFlags&2064&&b!==null)b.return=a,jt=b;else e:for(a=v;jt!==null;){if(l=jt,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:IM(9,l)}}catch(j){ps(l,l.return,j)}if(l===a){jt=null;break e}var w=l.sibling;if(w!==null){w.return=l.return,jt=w;break e}jt=l.return}}if(zr=s,ng(),rd&&typeof rd.onPostCommitFiberRoot=="function")try{rd.onPostCommitFiberRoot(_M,t)}catch{}n=!0}return n}finally{rn=r,Zl.transition=e}}return!1}function eX(t,e,r){e=t1(r,e),e=Lde(t,e,1),t=Sm(t,e,1),e=Ya(),t!==null&&(SE(t,1,e),_o(t,e))}function ps(t,e,r){if(t.tag===3)eX(t,t,r);else for(;e!==null;){if(e.tag===3){eX(e,t,r);break}else if(e.tag===1){var n=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(_m===null||!_m.has(n))){t=t1(r,t),t=$de(e,t,1),e=Sm(e,t,1),t=Ya(),e!==null&&(SE(e,1,t),_o(e,t));break}}e=e.return}}function ZIe(t,e,r){var n=t.pingCache;n!==null&&n.delete(e),e=Ya(),t.pingedLanes|=t.suspendedLanes&r,Ai===t&&(sa&r)===r&&(ti===4||ti===3&&(sa&130023424)===sa&&500>Cs()-_W?Ly(t,0):SW|=r),_o(t,e)}function she(t,e){e===0&&(t.mode&1?(e=MA,MA<<=1,!(MA&130023424)&&(MA=4194304)):e=1);var r=Ya();t=nf(t,e),t!==null&&(SE(t,e,r),_o(t,r))}function JIe(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),she(t,r)}function eRe(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(Je(314))}n!==null&&n.delete(e),she(t,r)}var ihe;ihe=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||jo.current)xo=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return xo=!1,zIe(t,e,r);xo=!!(t.flags&131072)}else xo=!1,Gn&&e.flags&1048576&&cde(e,aI,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;D2(t,e),t=e.pendingProps;var s=Qw(e,ka.current);l0(e,r),s=xW(null,e,n,t,s,r);var i=yW();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,So(n)?(i=!0,sI(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,hW(e),s.updater=PM,e.stateNode=s,s._reactInternals=e,nB(e,n,t,r),e=aB(null,e,n,!0,i,r)):(e.tag=0,Gn&&i&&iW(e),Ua(null,e,s,r),e=e.child),e;case 16:n=e.elementType;e:{switch(D2(t,e),t=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=rRe(n),t=_c(n,t),s){case 0:e=iB(null,e,n,t,r);break e;case 1:e=WY(null,e,n,t,r);break e;case 11:e=UY(null,e,n,t,r);break e;case 14:e=HY(null,e,n,_c(n.type,t),r);break e}throw Error(Je(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:_c(n,s),iB(t,e,n,s,r);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:_c(n,s),WY(t,e,n,s,r);case 3:e:{if(Ude(e),t===null)throw Error(Je(387));n=e.pendingProps,i=e.memoizedState,s=i.element,mde(t,e),cI(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=t1(Error(Je(423)),e),e=VY(t,e,n,r,s);break e}else if(n!==s){s=t1(Error(Je(424)),e),e=VY(t,e,n,r,s);break e}else for(al=jm(e.stateNode.containerInfo.firstChild),ol=e,Gn=!0,Bc=null,r=fde(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Zw(),n===s){e=sf(t,e,r);break e}Ua(t,e,n,r)}e=e.child}return e;case 5:return gde(e),t===null&&eB(e),n=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,a=s.children,Y6(n,s)?a=null:i!==null&&Y6(n,i)&&(e.flags|=32),zde(t,e),Ua(t,e,a,r),e.child;case 6:return t===null&&eB(e),null;case 13:return Hde(t,e,r);case 4:return fW(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=Jw(e,null,n,r):Ua(t,e,n,r),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:_c(n,s),UY(t,e,n,s,r);case 7:return Ua(t,e,e.pendingProps,r),e.child;case 8:return Ua(t,e,e.pendingProps.children,r),e.child;case 12:return Ua(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(oI,n._currentValue),n._currentValue=a,i!==null)if(Jc(i.value,a)){if(i.children===s.children&&!jo.current){e=sf(t,e,r);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var l=i.dependencies;if(l!==null){a=i.child;for(var c=l.firstContext;c!==null;){if(c.context===n){if(i.tag===1){c=Gh(-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),tB(i.return,r,e),l.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(Je(341));a.lanes|=r,l=a.alternate,l!==null&&(l.lanes|=r),tB(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}Ua(t,e,s.children,r),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,l0(e,r),s=ic(s),n=n(s),e.flags|=1,Ua(t,e,n,r),e.child;case 14:return n=e.type,s=_c(n,e.pendingProps),s=_c(n.type,s),HY(t,e,n,s,r);case 15:return Fde(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:_c(n,s),D2(t,e),e.tag=1,So(n)?(t=!0,sI(e)):t=!1,l0(e,r),Dde(e,n,s),nB(e,n,s,r),aB(null,e,n,!0,t,r);case 19:return Wde(t,e,r);case 22:return Bde(t,e,r)}throw Error(Je(156,e.tag))};function ahe(t,e){return Rue(t,e)}function tRe(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 Gl(t,e,r,n){return new tRe(t,e,r,n)}function EW(t){return t=t.prototype,!(!t||!t.isReactComponent)}function rRe(t){if(typeof t=="function")return EW(t)?1:0;if(t!=null){if(t=t.$$typeof,t===G7)return 11;if(t===K7)return 14}return 2}function km(t,e){var r=t.alternate;return r===null?(r=Gl(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 F2(t,e,r,n,s,i){var a=2;if(n=t,typeof t=="function")EW(t)&&(a=1);else if(typeof t=="string")a=5;else e:switch(t){case Ib:return $y(r.children,s,i,e);case q7:a=8,s|=8;break;case C6:return t=Gl(12,r,e,s|2),t.elementType=C6,t.lanes=i,t;case E6:return t=Gl(13,r,e,s),t.elementType=E6,t.lanes=i,t;case A6:return t=Gl(19,r,e,s),t.elementType=A6,t.lanes=i,t;case gue:return OM(r,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case pue:a=10;break e;case mue:a=9;break e;case G7:a=11;break e;case K7:a=14;break e;case sp:a=16,n=null;break e}throw Error(Je(130,t==null?t:typeof t,""))}return e=Gl(a,r,e,s),e.elementType=t,e.type=n,e.lanes=i,e}function $y(t,e,r,n){return t=Gl(7,t,n,e),t.lanes=r,t}function OM(t,e,r,n){return t=Gl(22,t,n,e),t.elementType=gue,t.lanes=r,t.stateNode={isHidden:!1},t}function e4(t,e,r){return t=Gl(6,t,null,e),t.lanes=r,t}function t4(t,e,r){return e=Gl(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function nRe(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=M5(0),this.expirationTimes=M5(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=M5(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function AW(t,e,r,n,s,i,a,l,c){return t=new nRe(t,e,r,l,c),e===1?(e=1,i===!0&&(e|=8)):e=0,i=Gl(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},hW(i),t}function sRe(t,e,r){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Pb,key:n==null?null:""+n,children:t,containerInfo:e,implementation:r}}function ohe(t){if(!t)return Bm;t=t._reactInternals;e:{if(Cv(t)!==t||t.tag!==1)throw Error(Je(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(So(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(Je(171))}if(t.tag===1){var r=t.type;if(So(r))return ode(t,r,e)}return e}function lhe(t,e,r,n,s,i,a,l,c){return t=AW(r,n,!0,t,s,i,a,l,c),t.context=ohe(null),r=t.current,n=Ya(),s=Nm(r),i=Gh(n,s),i.callback=e??null,Sm(r,i,s),t.current.lanes=s,SE(t,s,n),_o(t,n),t}function MM(t,e,r,n){var s=e.current,i=Ya(),a=Nm(s);return r=ohe(r),e.context===null?e.context=r:e.pendingContext=r,e=Gh(i,a),e.payload={element:t},n=n===void 0?null:n,n!==null&&(e.callback=n),t=Sm(s,e,a),t!==null&&(Kc(t,s,a,i),R2(t,s,a)),a}function xI(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 tX(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<e?r:e}}function TW(t,e){tX(t,e),(t=t.alternate)&&tX(t,e)}function iRe(){return null}var che=typeof reportError=="function"?reportError:function(t){console.error(t)};function PW(t){this._internalRoot=t}DM.prototype.render=PW.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(Je(409));MM(t,e,null,null)};DM.prototype.unmount=PW.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;rv(function(){MM(null,t,null,null)}),e[rf]=null}};function DM(t){this._internalRoot=t}DM.prototype.unstable_scheduleHydration=function(t){if(t){var e=Bue();t={blockedOn:null,target:t,priority:e};for(var r=0;r<up.length&&e!==0&&e<up[r].priority;r++);up.splice(r,0,t),r===0&&Uue(t)}};function IW(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function LM(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function rX(){}function aRe(t,e,r,n,s){if(s){if(typeof n=="function"){var i=n;n=function(){var u=xI(a);i.call(u)}}var a=lhe(e,n,t,0,null,!1,!1,"",rX);return t._reactRootContainer=a,t[rf]=a.current,pN(t.nodeType===8?t.parentNode:t),rv(),a}for(;s=t.lastChild;)t.removeChild(s);if(typeof n=="function"){var l=n;n=function(){var u=xI(c);l.call(u)}}var c=AW(t,0,!1,null,null,!1,!1,"",rX);return t._reactRootContainer=c,t[rf]=c.current,pN(t.nodeType===8?t.parentNode:t),rv(function(){MM(e,c,r,n)}),c}function $M(t,e,r,n,s){var i=r._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var l=s;s=function(){var c=xI(a);l.call(c)}}MM(e,a,t,s)}else a=aRe(r,e,t,s,n);return xI(a)}$ue=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var r=MS(e.pendingLanes);r!==0&&(Q7(e,r|1),_o(e,Cs()),!(zr&6)&&(r1=Cs()+500,ng()))}break;case 13:rv(function(){var n=nf(t,1);if(n!==null){var s=Ya();Kc(n,t,1,s)}}),TW(t,1)}};Z7=function(t){if(t.tag===13){var e=nf(t,134217728);if(e!==null){var r=Ya();Kc(e,t,134217728,r)}TW(t,134217728)}};Fue=function(t){if(t.tag===13){var e=Nm(t),r=nf(t,e);if(r!==null){var n=Ya();Kc(r,t,e,n)}TW(t,e)}};Bue=function(){return rn};zue=function(t,e){var r=rn;try{return rn=t,e()}finally{rn=r}};F6=function(t,e,r){switch(e){case"input":if(I6(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=EM(n);if(!s)throw Error(Je(90));yue(n),I6(n,s)}}}break;case"textarea":bue(t,r);break;case"select":e=r.value,e!=null&&s0(t,!!r.multiple,e,!1)}};Cue=NW;Eue=rv;var oRe={usingClientEntryPoint:!1,Events:[NE,Db,EM,Nue,kue,NW]},Vj={findFiberByHostInstance:nx,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},lRe={bundleType:Vj.bundleType,version:Vj.version,rendererPackageName:Vj.rendererPackageName,rendererConfig:Vj.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Sf.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=Pue(t),t===null?null:t.stateNode},findFiberByHostInstance:Vj.findFiberByHostInstance||iRe,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 qA=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!qA.isDisabled&&qA.supportsFiber)try{_M=qA.inject(lRe),rd=qA}catch{}}ml.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=oRe;ml.createPortal=function(t,e){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!IW(e))throw Error(Je(200));return sRe(t,e,null,r)};ml.createRoot=function(t,e){if(!IW(t))throw Error(Je(299));var r=!1,n="",s=che;return e!=null&&(e.unstable_strictMode===!0&&(r=!0),e.identifierPrefix!==void 0&&(n=e.identifierPrefix),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=AW(t,1,!1,null,null,r,!1,n,s),t[rf]=e.current,pN(t.nodeType===8?t.parentNode:t),new PW(e)};ml.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(Je(188)):(t=Object.keys(t).join(","),Error(Je(268,t)));return t=Pue(e),t=t===null?null:t.stateNode,t};ml.flushSync=function(t){return rv(t)};ml.hydrate=function(t,e,r){if(!LM(e))throw Error(Je(200));return $M(null,t,e,!0,r)};ml.hydrateRoot=function(t,e,r){if(!IW(t))throw Error(Je(405));var n=r!=null&&r.hydratedSources||null,s=!1,i="",a=che;if(r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(i=r.identifierPrefix),r.onRecoverableError!==void 0&&(a=r.onRecoverableError)),e=lhe(e,null,t,1,r??null,s,!1,i,a),t[rf]=e.current,pN(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 DM(e)};ml.render=function(t,e,r){if(!LM(e))throw Error(Je(200));return $M(null,t,e,!1,r)};ml.unmountComponentAtNode=function(t){if(!LM(t))throw Error(Je(40));return t._reactRootContainer?(rv(function(){$M(null,null,t,!1,function(){t._reactRootContainer=null,t[rf]=null})}),!0):!1};ml.unstable_batchedUpdates=NW;ml.unstable_renderSubtreeIntoContainer=function(t,e,r,n){if(!LM(r))throw Error(Je(200));if(t==null||t._reactInternals===void 0)throw Error(Je(38));return $M(t,e,r,!1,n)};ml.version="18.3.1-next-f1338f8080-20240426";function uhe(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(uhe)}catch(t){console.error(t)}}uhe(),uue.exports=ml;var cc=uue.exports;const RW=Er(cc);var dhe,nX=cc;dhe=nX.createRoot,nX.hydrateRoot;var cRe=typeof Element<"u",uRe=typeof Map=="function",dRe=typeof Set=="function",hRe=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function B2(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(!B2(t[n],e[n]))return!1;return!0}var i;if(uRe&&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(!B2(n.value[1],e.get(n.value[0])))return!1;return!0}if(dRe&&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(hRe&&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(cRe&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((s[n]==="_owner"||s[n]==="__v"||s[n]==="__o")&&t.$$typeof)&&!B2(t[s[n]],e[s[n]]))return!1;return!0}return t!==t&&e!==e}var fRe=function(e,r){try{return B2(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 pRe=Er(fRe);var mRe=function(t,e,r,n,s,i,a,l){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,l],d=0;c=new Error(e.replace(/%s/g,function(){return u[d++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}},gRe=mRe;const sX=Er(gRe);var xRe=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),l=Object.keys(r);if(a.length!==l.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 yRe=Er(xRe);var hhe=(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))(hhe||{}),r4={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"]}},iX=Object.values(hhe),OW={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},vRe=Object.entries(OW).reduce((t,[e,r])=>(t[r]=e,t),{}),Wc="data-rh",u0={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},d0=(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},bRe=t=>{let e=d0(t,"title");const r=d0(t,u0.TITLE_TEMPLATE);if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,()=>e);const n=d0(t,u0.DEFAULT_TITLE);return e||n||void 0},wRe=t=>d0(t,u0.ON_CHANGE_CLIENT_STATE)||(()=>{}),n4=(t,e)=>e.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),jRe=(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 l=s[i].toLowerCase();if(t.indexOf(l)!==-1&&n[l])return r.concat(n)}}return r},[]),SRe=t=>console&&typeof console.warn=="function"&&console.warn(t),qj=(t,e,r)=>{const n={};return r.filter(s=>Array.isArray(s[t])?!0:(typeof s[t]<"u"&&SRe(`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 l=Object.keys(a);for(let c=0;c<l.length;c+=1){const u=l[c],d={...n[u],...a[u]};n[u]=d}return s},[]).reverse()},_Re=(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},NRe=t=>({baseTag:jRe(["href"],t),bodyAttributes:n4("bodyAttributes",t),defer:d0(t,u0.DEFER),encode:d0(t,u0.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:n4("htmlAttributes",t),linkTags:qj("link",["rel","href"],t),metaTags:qj("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:qj("noscript",["innerHTML"],t),onChangeClientState:wRe(t),scriptTags:qj("script",["src","innerHTML"],t),styleTags:qj("style",["cssText"],t),title:bRe(t),titleAttributes:n4("titleAttributes",t),prioritizeSeoTags:_Re(t,u0.PRIORITIZE_SEO_TAGS)}),fhe=t=>Array.isArray(t)?t.join(""):t,kRe=(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},s4=(t,e)=>Array.isArray(t)?t.reduce((r,n)=>(kRe(n,e)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},aX=(t,e)=>({...t,[e]:void 0}),CRe=["noscript","script","style"],yB=(t,e=!0)=>e===!1?String(t):String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;"),phe=t=>Object.keys(t).reduce((e,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return e?`${e} ${n}`:n},""),ERe=(t,e,r,n)=>{const s=phe(r),i=fhe(e);return s?`<${t} ${Wc}="true" ${s}>${yB(i,n)}</${t}>`:`<${t} ${Wc}="true">${yB(i,n)}</${t}>`},ARe=(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}="${yB(i[d],r)}"`;return u?`${u} ${h}`:h},""),l=i.innerHTML||i.cssText||"",c=CRe.indexOf(t)===-1;return`${n}<${t} ${Wc}="true" ${a}${c?"/>":`>${l}</${t}>`}`},""),mhe=(t,e={})=>Object.keys(t).reduce((r,n)=>{const s=OW[n];return r[s||n]=t[n],r},e),TRe=(t,e,r)=>{const n={key:e,[Wc]:!0},s=mhe(r,n);return[ve.createElement("title",s,e)]},z2=(t,e)=>e.map((r,n)=>{const s={key:n,[Wc]:!0};return Object.keys(r).forEach(i=>{const l=OW[i]||i;if(l==="innerHTML"||l==="cssText"){const c=r.innerHTML||r.cssText;s.dangerouslySetInnerHTML={__html:c}}else s[l]=r[i]}),ve.createElement(t,s)}),El=(t,e,r=!0)=>{switch(t){case"title":return{toComponent:()=>TRe(t,e.title,e.titleAttributes),toString:()=>ERe(t,e.title,e.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>mhe(e),toString:()=>phe(e)};default:return{toComponent:()=>z2(t,e),toString:()=>ARe(t,e,r)}}},PRe=({metaTags:t,linkTags:e,scriptTags:r,encode:n})=>{const s=s4(t,r4.meta),i=s4(e,r4.link),a=s4(r,r4.script);return{priorityMethods:{toComponent:()=>[...z2("meta",s.priority),...z2("link",i.priority),...z2("script",a.priority)],toString:()=>`${El("meta",s.priority,n)} ${El("link",i.priority,n)} ${El("script",a.priority,n)}`},metaTags:s.default,linkTags:i.default,scriptTags:a.default}},IRe=t=>{const{baseTag:e,bodyAttributes:r,encode:n=!0,htmlAttributes:s,noscriptTags:i,styleTags:a,title:l="",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}=PRe(t)),{priority:p,base:El("base",e,n),bodyAttributes:El("bodyAttributes",r,n),htmlAttributes:El("htmlAttributes",s,n),link:El("link",d,n),meta:El("meta",h,n),noscript:El("noscript",i,n),script:El("script",f,n),style:El("style",a,n),title:El("title",{title:l,titleAttributes:c},n)}},vB=IRe,GA=[],ghe=!!(typeof window<"u"&&window.document&&window.document.createElement),bB=class{constructor(t,e){Ge(this,"instances",[]);Ge(this,"canUseDOM",ghe);Ge(this,"context");Ge(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?GA:this.instances,add:t=>{(this.canUseDOM?GA:this.instances).push(t)},remove:t=>{const e=(this.canUseDOM?GA:this.instances).indexOf(t);(this.canUseDOM?GA:this.instances).splice(e,1)}}});this.context=t,this.canUseDOM=e||!1,e||(t.helmet=vB({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},RRe={},xhe=ve.createContext(RRe),jx,yhe=(jx=class extends S.Component{constructor(r){super(r);Ge(this,"helmetData");this.helmetData=new bB(this.props.context||{},jx.canUseDOM)}render(){return ve.createElement(xhe.Provider,{value:this.helmetData.value},this.props.children)}},Ge(jx,"canUseDOM",ghe),jx),Gv=(t,e)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Wc}]`),s=[].slice.call(n),i=[];let a;return e&&e.length&&e.forEach(l=>{const c=document.createElement(t);for(const u in l)if(Object.prototype.hasOwnProperty.call(l,u))if(u==="innerHTML")c.innerHTML=l.innerHTML;else if(u==="cssText")c.styleSheet?c.styleSheet.cssText=l.cssText:c.appendChild(document.createTextNode(l.cssText));else{const d=u,h=typeof l[d]>"u"?"":l[d];c.setAttribute(u,h)}c.setAttribute(Wc,"true"),s.some((u,d)=>(a=d,c.isEqualNode(u)))?s.splice(a,1):i.push(c)}),s.forEach(l=>{var c;return(c=l.parentNode)==null?void 0:c.removeChild(l)}),i.forEach(l=>r.appendChild(l)),{oldTags:s,newTags:i}},wB=(t,e)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Wc),s=n?n.split(","):[],i=[...s],a=Object.keys(e);for(const l of a){const c=e[l]||"";r.getAttribute(l)!==c&&r.setAttribute(l,c),s.indexOf(l)===-1&&s.push(l);const u=i.indexOf(l);u!==-1&&i.splice(u,1)}for(let l=i.length-1;l>=0;l-=1)r.removeAttribute(i[l]);s.length===i.length?r.removeAttribute(Wc):r.getAttribute(Wc)!==a.join(",")&&r.setAttribute(Wc,a.join(","))},ORe=(t,e)=>{typeof t<"u"&&document.title!==t&&(document.title=fhe(t)),wB("title",e)},oX=(t,e)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:s,linkTags:i,metaTags:a,noscriptTags:l,onChangeClientState:c,scriptTags:u,styleTags:d,title:h,titleAttributes:f}=t;wB("body",n),wB("html",s),ORe(h,f);const p={baseTag:Gv("base",r),linkTags:Gv("link",i),metaTags:Gv("meta",a),noscriptTags:Gv("noscript",l),scriptTags:Gv("script",u),styleTags:Gv("style",d)},m={},g={};Object.keys(p).forEach(y=>{const{newTags:x,oldTags:v}=p[y];x.length&&(m[y]=x),v.length&&(g[y]=p[y].oldTags)}),e&&e(),c(t,m,g)},Gj=null,MRe=t=>{Gj&&cancelAnimationFrame(Gj),t.defer?Gj=requestAnimationFrame(()=>{oX(t,()=>{Gj=null})}):(oX(t),Gj=null)},DRe=MRe,lX=class extends S.Component{constructor(){super(...arguments);Ge(this,"rendered",!1)}shouldComponentUpdate(e){return!yRe(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=NRe(e.get().map(i=>{const a={...i.props};return delete a.context,a}));yhe.canUseDOM?DRe(s):vB&&(n=vB(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}},N6,vhe=(N6=class extends S.Component{shouldComponentUpdate(t){return!pRe(aX(this.props,"helmetData"),aX(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 sX(iX.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 ${iX.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),sX(!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 ve.Children.forEach(t,n=>{if(!n||!n.props)return;const{children:s,...i}=n.props,a=Object.keys(i).reduce((c,u)=>(c[vRe[u]||u]=i[u],c),{});let{type:l}=n;switch(typeof l=="symbol"?l=l.toString():this.warnOnInvalidChildren(n,s),l){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 bB)){const s=n;n=new bB(s.context,!0),delete r.helmetData}return n?ve.createElement(lX,{...r,context:n.value}):ve.createElement(xhe.Consumer,null,s=>ve.createElement(lX,{...r,context:s}))}},Ge(N6,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),N6);const LRe=1,$Re=1e6;let i4=0;function FRe(){return i4=(i4+1)%Number.MAX_SAFE_INTEGER,i4.toString()}const a4=new Map,cX=t=>{if(a4.has(t))return;const e=setTimeout(()=>{a4.delete(t),E_({type:"REMOVE_TOAST",toastId:t})},$Re);a4.set(t,e)},BRe=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,LRe)};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?cX(r):t.toasts.forEach(n=>{cX(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)}}},U2=[];let H2={toasts:[]};function E_(t){H2=BRe(H2,t),U2.forEach(e=>{e(H2)})}function It({...t}){const e=FRe(),r=s=>E_({type:"UPDATE_TOAST",toast:{...s,id:e}}),n=()=>E_({type:"DISMISS_TOAST",toastId:e});return E_({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:s=>{s||n()}}}),{id:e,dismiss:n,update:r}}function Bn(){const[t,e]=S.useState(H2);return S.useEffect(()=>(U2.push(e),()=>{const r=U2.indexOf(e);r>-1&&U2.splice(r,1)}),[t]),{...t,toast:It,dismiss:r=>E_({type:"DISMISS_TOAST",toastId:r})}}function Qe(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 uX(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function FM(...t){return e=>{let r=!1;const n=t.map(s=>{const i=uX(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():uX(t[s],null)}}}}function qt(...t){return S.useCallback(FM(...t),t)}function zRe(t,e){const r=S.createContext(e),n=i=>{const{children:a,...l}=i,c=S.useMemo(()=>l,Object.values(l));return o.jsx(r.Provider,{value:c,children:a})};n.displayName=t+"Provider";function s(i){const a=S.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 Vs(t,e=[]){let r=[];function n(i,a){const l=S.createContext(a),c=r.length;r=[...r,a];const u=h=>{var x;const{scope:f,children:p,...m}=h,g=((x=f==null?void 0:f[t])==null?void 0:x[c])||l,y=S.useMemo(()=>m,Object.values(m));return o.jsx(g.Provider,{value:y,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])||l,m=S.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=>S.createContext(a));return function(l){const c=(l==null?void 0:l[t])||i;return S.useMemo(()=>({[`__scope${t}`]:{...l,[t]:c}}),[l,c])}};return s.scopeName=t,[n,URe(s,...e)]}function URe(...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((l,{useScope:c,scopeName:u})=>{const h=c(i)[`__scope${u}`];return{...l,...h}},{});return S.useMemo(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return r.scopeName=e.scopeName,r}function zm(t){const e=WRe(t),r=S.forwardRef((n,s)=>{const{children:i,...a}=n,l=S.Children.toArray(i),c=l.find(VRe);if(c){const u=c.props.children,d=l.map(h=>h===c?S.Children.count(u)>1?S.Children.only(null):S.isValidElement(u)?u.props.children:null:h);return o.jsx(e,{...a,ref:s,children:S.isValidElement(u)?S.cloneElement(u,void 0,d):null})}return o.jsx(e,{...a,ref:s,children:i})});return r.displayName=`${t}.Slot`,r}var HRe=zm("Slot");function WRe(t){const e=S.forwardRef((r,n)=>{const{children:s,...i}=r;if(S.isValidElement(s)){const a=GRe(s),l=qRe(i,s.props);return s.type!==S.Fragment&&(l.ref=n?FM(n,a):a),S.cloneElement(s,l)}return S.Children.count(s)>1?S.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var bhe=Symbol("radix.slottable");function whe(t){const e=({children:r})=>o.jsx(o.Fragment,{children:r});return e.displayName=`${t}.Slottable`,e.__radixId=bhe,e}function VRe(t){return S.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===bhe}function qRe(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]=(...l)=>{const c=i(...l);return s(...l),c}:s&&(r[n]=s):n==="style"?r[n]={...s,...i}:n==="className"&&(r[n]=[s,i].filter(Boolean).join(" "))}return{...t,...r}}function GRe(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 CE(t){const e=t+"CollectionProvider",[r,n]=Vs(e),[s,i]=r(e,{collectionRef:{current:null},itemMap:new Map}),a=g=>{const{scope:y,children:x}=g,v=ve.useRef(null),b=ve.useRef(new Map).current;return o.jsx(s,{scope:y,itemMap:b,collectionRef:v,children:x})};a.displayName=e;const l=t+"CollectionSlot",c=zm(l),u=ve.forwardRef((g,y)=>{const{scope:x,children:v}=g,b=i(l,x),w=qt(y,b.collectionRef);return o.jsx(c,{ref:w,children:v})});u.displayName=l;const d=t+"CollectionItemSlot",h="data-radix-collection-item",f=zm(d),p=ve.forwardRef((g,y)=>{const{scope:x,children:v,...b}=g,w=ve.useRef(null),j=qt(y,w),N=i(d,x);return ve.useEffect(()=>(N.itemMap.set(w,{ref:w,...b}),()=>void N.itemMap.delete(w))),o.jsx(f,{[h]:"",ref:j,children:v})});p.displayName=d;function m(g){const y=i(t+"CollectionConsumer",g);return ve.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const b=Array.from(v.querySelectorAll(`[${h}]`));return Array.from(y.itemMap.values()).sort((N,C)=>b.indexOf(N.ref.current)-b.indexOf(C.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:a,Slot:u,ItemSlot:p},m,n]}var KRe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ft=KRe.reduce((t,e)=>{const r=zm(`Primitive.${e}`),n=S.forwardRef((s,i)=>{const{asChild:a,...l}=s,c=a?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(c,{...l,ref:i})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function MW(t,e){t&&cc.flushSync(()=>t.dispatchEvent(e))}function ys(t){const e=S.useRef(t);return S.useEffect(()=>{e.current=t}),S.useMemo(()=>(...r)=>{var n;return(n=e.current)==null?void 0:n.call(e,...r)},[])}function YRe(t,e=globalThis==null?void 0:globalThis.document){const r=ys(t);S.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 XRe="DismissableLayer",jB="dismissableLayer.update",QRe="dismissableLayer.pointerDownOutside",ZRe="dismissableLayer.focusOutside",dX,jhe=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ev=S.forwardRef((t,e)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:i,onInteractOutside:a,onDismiss:l,...c}=t,u=S.useContext(jhe),[d,h]=S.useState(null),f=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=S.useState({}),m=qt(e,C=>h(C)),g=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),x=g.indexOf(y),v=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,w=v>=x,j=eOe(C=>{const A=C.target,E=[...u.branches].some(O=>O.contains(A));!w||E||(s==null||s(C),a==null||a(C),C.defaultPrevented||l==null||l())},f),N=tOe(C=>{const A=C.target;[...u.branches].some(O=>O.contains(A))||(i==null||i(C),a==null||a(C),C.defaultPrevented||l==null||l())},f);return YRe(C=>{v===u.layers.size-1&&(n==null||n(C),!C.defaultPrevented&&l&&(C.preventDefault(),l()))},f),S.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(dX=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),hX(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=dX)}},[d,f,r,u]),S.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),hX())},[d,u]),S.useEffect(()=>{const C=()=>p({});return document.addEventListener(jB,C),()=>document.removeEventListener(jB,C)},[]),o.jsx(ft.div,{...c,ref:m,style:{pointerEvents:b?w?"auto":"none":void 0,...t.style},onFocusCapture:Qe(t.onFocusCapture,N.onFocusCapture),onBlurCapture:Qe(t.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Qe(t.onPointerDownCapture,j.onPointerDownCapture)})});Ev.displayName=XRe;var JRe="DismissableLayerBranch",She=S.forwardRef((t,e)=>{const r=S.useContext(jhe),n=S.useRef(null),s=qt(e,n);return S.useEffect(()=>{const i=n.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),o.jsx(ft.div,{...t,ref:s})});She.displayName=JRe;function eOe(t,e=globalThis==null?void 0:globalThis.document){const r=ys(t),n=S.useRef(!1),s=S.useRef(()=>{});return S.useEffect(()=>{const i=l=>{if(l.target&&!n.current){let c=function(){_he(QRe,r,u,{discrete:!0})};const u={originalEvent:l};l.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 tOe(t,e=globalThis==null?void 0:globalThis.document){const r=ys(t),n=S.useRef(!1);return S.useEffect(()=>{const s=i=>{i.target&&!n.current&&_he(ZRe,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 hX(){const t=new CustomEvent(jB);document.dispatchEvent(t)}function _he(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?MW(s,i):s.dispatchEvent(i)}var rOe=Ev,nOe=She,bs=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},sOe="Portal",tj=S.forwardRef((t,e)=>{var l;const{container:r,...n}=t,[s,i]=S.useState(!1);bs(()=>i(!0),[]);const a=r||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return a?RW.createPortal(o.jsx(ft.div,{...n,ref:e}),a):null});tj.displayName=sOe;function iOe(t,e){return S.useReducer((r,n)=>e[r][n]??r,t)}var pi=t=>{const{present:e,children:r}=t,n=aOe(e),s=typeof r=="function"?r({present:n.isPresent}):S.Children.only(r),i=qt(n.ref,oOe(s));return typeof r=="function"||n.isPresent?S.cloneElement(s,{ref:i}):null};pi.displayName="Presence";function aOe(t){const[e,r]=S.useState(),n=S.useRef(null),s=S.useRef(t),i=S.useRef("none"),a=t?"mounted":"unmounted",[l,c]=iOe(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{const u=KA(n.current);i.current=l==="mounted"?u:"none"},[l]),bs(()=>{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]),bs(()=>{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 y=e.style.animationFillMode;e.style.animationFillMode="forwards",u=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=y)})}},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(l),ref:S.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function KA(t){return(t==null?void 0:t.animationName)||"none"}function oOe(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 lOe=U7[" useInsertionEffect ".trim().toString()]||bs;function ca({prop:t,defaultProp:e,onChange:r=()=>{},caller:n}){const[s,i,a]=cOe({defaultProp:e,onChange:r}),l=t!==void 0,c=l?t:s;{const d=S.useRef(t!==void 0);S.useEffect(()=>{const h=d.current;h!==l&&console.warn(`${n} is changing from ${h?"controlled":"uncontrolled"} to ${l?"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=l},[l,n])}const u=S.useCallback(d=>{var h;if(l){const f=uOe(d)?d(t):d;f!==t&&((h=a.current)==null||h.call(a,f))}else i(d)},[l,t,i,a]);return[c,u]}function cOe({defaultProp:t,onChange:e}){const[r,n]=S.useState(t),s=S.useRef(r),i=S.useRef(e);return lOe(()=>{i.current=e},[e]),S.useEffect(()=>{var a;s.current!==r&&((a=i.current)==null||a.call(i,r),s.current=r)},[r,s]),[r,n,i]}function uOe(t){return typeof t=="function"}var Nhe=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"}),dOe="VisuallyHidden",BM=S.forwardRef((t,e)=>o.jsx(ft.span,{...t,ref:e,style:{...Nhe,...t.style}}));BM.displayName=dOe;var hOe=BM,DW="ToastProvider",[LW,fOe,pOe]=CE("Toast"),[khe,nWt]=Vs("Toast",[pOe]),[mOe,zM]=khe(DW),Che=t=>{const{__scopeToast:e,label:r="Notification",duration:n=5e3,swipeDirection:s="right",swipeThreshold:i=50,children:a}=t,[l,c]=S.useState(null),[u,d]=S.useState(0),h=S.useRef(!1),f=S.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${DW}\`. Expected non-empty \`string\`.`),o.jsx(LW.Provider,{scope:e,children:o.jsx(mOe,{scope:e,label:r,duration:n,swipeDirection:s,swipeThreshold:i,toastCount:u,viewport:l,onViewportChange:c,onToastAdd:S.useCallback(()=>d(p=>p+1),[]),onToastRemove:S.useCallback(()=>d(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:f,children:a})})};Che.displayName=DW;var Ehe="ToastViewport",gOe=["F8"],SB="toast.viewportPause",_B="toast.viewportResume",Ahe=S.forwardRef((t,e)=>{const{__scopeToast:r,hotkey:n=gOe,label:s="Notifications ({hotkey})",...i}=t,a=zM(Ehe,r),l=fOe(r),c=S.useRef(null),u=S.useRef(null),d=S.useRef(null),h=S.useRef(null),f=qt(e,h,a.onViewportChange),p=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),m=a.toastCount>0;S.useEffect(()=>{const y=x=>{var b;n.length!==0&&n.every(w=>x[w]||x.code===w)&&((b=h.current)==null||b.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[n]),S.useEffect(()=>{const y=c.current,x=h.current;if(m&&y&&x){const v=()=>{if(!a.isClosePausedRef.current){const N=new CustomEvent(SB);x.dispatchEvent(N),a.isClosePausedRef.current=!0}},b=()=>{if(a.isClosePausedRef.current){const N=new CustomEvent(_B);x.dispatchEvent(N),a.isClosePausedRef.current=!1}},w=N=>{!y.contains(N.relatedTarget)&&b()},j=()=>{y.contains(document.activeElement)||b()};return y.addEventListener("focusin",v),y.addEventListener("focusout",w),y.addEventListener("pointermove",v),y.addEventListener("pointerleave",j),window.addEventListener("blur",v),window.addEventListener("focus",b),()=>{y.removeEventListener("focusin",v),y.removeEventListener("focusout",w),y.removeEventListener("pointermove",v),y.removeEventListener("pointerleave",j),window.removeEventListener("blur",v),window.removeEventListener("focus",b)}}},[m,a.isClosePausedRef]);const g=S.useCallback(({tabbingDirection:y})=>{const v=l().map(b=>{const w=b.ref.current,j=[w,...AOe(w)];return y==="forwards"?j:j.reverse()});return(y==="forwards"?v.reverse():v).flat()},[l]);return S.useEffect(()=>{const y=h.current;if(y){const x=v=>{var j,N,C;const b=v.altKey||v.ctrlKey||v.metaKey;if(v.key==="Tab"&&!b){const A=document.activeElement,E=v.shiftKey;if(v.target===y&&E){(j=u.current)==null||j.focus();return}const T=g({tabbingDirection:E?"backwards":"forwards"}),M=T.findIndex(k=>k===A);o4(T.slice(M+1))?v.preventDefault():E?(N=u.current)==null||N.focus():(C=d.current)==null||C.focus()}};return y.addEventListener("keydown",x),()=>y.removeEventListener("keydown",x)}},[l,g]),o.jsxs(nOe,{ref:c,role:"region","aria-label":s.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:m?void 0:"none"},children:[m&&o.jsx(NB,{ref:u,onFocusFromOutsideViewport:()=>{const y=g({tabbingDirection:"forwards"});o4(y)}}),o.jsx(LW.Slot,{scope:r,children:o.jsx(ft.ol,{tabIndex:-1,...i,ref:f})}),m&&o.jsx(NB,{ref:d,onFocusFromOutsideViewport:()=>{const y=g({tabbingDirection:"backwards"});o4(y)}})]})});Ahe.displayName=Ehe;var The="ToastFocusProxy",NB=S.forwardRef((t,e)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...s}=t,i=zM(The,r);return o.jsx(BM,{"aria-hidden":!0,tabIndex:0,...s,ref:e,style:{position:"fixed"},onFocus:a=>{var u;const l=a.relatedTarget;!((u=i.viewport)!=null&&u.contains(l))&&n()}})});NB.displayName=The;var EE="Toast",xOe="toast.swipeStart",yOe="toast.swipeMove",vOe="toast.swipeCancel",bOe="toast.swipeEnd",Phe=S.forwardRef((t,e)=>{const{forceMount:r,open:n,defaultOpen:s,onOpenChange:i,...a}=t,[l,c]=ca({prop:n,defaultProp:s??!0,onChange:i,caller:EE});return o.jsx(pi,{present:r||l,children:o.jsx(SOe,{open:l,...a,ref:e,onClose:()=>c(!1),onPause:ys(t.onPause),onResume:ys(t.onResume),onSwipeStart:Qe(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Qe(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:Qe(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:Qe(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)})})})});Phe.displayName=EE;var[wOe,jOe]=khe(EE,{onClose(){}}),SOe=S.forwardRef((t,e)=>{const{__scopeToast:r,type:n="foreground",duration:s,open:i,onClose:a,onEscapeKeyDown:l,onPause:c,onResume:u,onSwipeStart:d,onSwipeMove:h,onSwipeCancel:f,onSwipeEnd:p,...m}=t,g=zM(EE,r),[y,x]=S.useState(null),v=qt(e,k=>x(k)),b=S.useRef(null),w=S.useRef(null),j=s||g.duration,N=S.useRef(0),C=S.useRef(j),A=S.useRef(0),{onToastAdd:E,onToastRemove:O}=g,$=ys(()=>{var D;(y==null?void 0:y.contains(document.activeElement))&&((D=g.viewport)==null||D.focus()),a()}),T=S.useCallback(k=>{!k||k===1/0||(window.clearTimeout(A.current),N.current=new Date().getTime(),A.current=window.setTimeout($,k))},[$]);S.useEffect(()=>{const k=g.viewport;if(k){const D=()=>{T(C.current),u==null||u()},K=()=>{const H=new Date().getTime()-N.current;C.current=C.current-H,window.clearTimeout(A.current),c==null||c()};return k.addEventListener(SB,K),k.addEventListener(_B,D),()=>{k.removeEventListener(SB,K),k.removeEventListener(_B,D)}}},[g.viewport,j,c,u,T]),S.useEffect(()=>{i&&!g.isClosePausedRef.current&&T(j)},[i,j,g.isClosePausedRef,T]),S.useEffect(()=>(E(),()=>O()),[E,O]);const M=S.useMemo(()=>y?$he(y):null,[y]);return g.viewport?o.jsxs(o.Fragment,{children:[M&&o.jsx(_Oe,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:M}),o.jsx(wOe,{scope:r,onClose:$,children:cc.createPortal(o.jsx(LW.ItemSlot,{scope:r,children:o.jsx(rOe,{asChild:!0,onEscapeKeyDown:Qe(l,()=>{g.isFocusedToastEscapeKeyDownRef.current||$(),g.isFocusedToastEscapeKeyDownRef.current=!1}),children:o.jsx(ft.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:Qe(t.onKeyDown,k=>{k.key==="Escape"&&(l==null||l(k.nativeEvent),k.nativeEvent.defaultPrevented||(g.isFocusedToastEscapeKeyDownRef.current=!0,$()))}),onPointerDown:Qe(t.onPointerDown,k=>{k.button===0&&(b.current={x:k.clientX,y:k.clientY})}),onPointerMove:Qe(t.onPointerMove,k=>{if(!b.current)return;const D=k.clientX-b.current.x,K=k.clientY-b.current.y,H=!!w.current,ee=["left","right"].includes(g.swipeDirection),V=["left","up"].includes(g.swipeDirection)?Math.min:Math.max,B=ee?V(0,D):0,z=ee?0:V(0,K),F=k.pointerType==="touch"?10:2,G={x:B,y:z},Q={originalEvent:k,delta:G};H?(w.current=G,YA(yOe,h,Q,{discrete:!1})):fX(G,g.swipeDirection,F)?(w.current=G,YA(xOe,d,Q,{discrete:!1}),k.target.setPointerCapture(k.pointerId)):(Math.abs(D)>F||Math.abs(K)>F)&&(b.current=null)}),onPointerUp:Qe(t.onPointerUp,k=>{const D=w.current,K=k.target;if(K.hasPointerCapture(k.pointerId)&&K.releasePointerCapture(k.pointerId),w.current=null,b.current=null,D){const H=k.currentTarget,ee={originalEvent:k,delta:D};fX(D,g.swipeDirection,g.swipeThreshold)?YA(bOe,p,ee,{discrete:!0}):YA(vOe,f,ee,{discrete:!0}),H.addEventListener("click",V=>V.preventDefault(),{once:!0})}})})})}),g.viewport)})]}):null}),_Oe=t=>{const{__scopeToast:e,children:r,...n}=t,s=zM(EE,e),[i,a]=S.useState(!1),[l,c]=S.useState(!1);return COe(()=>a(!0)),S.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),l?null:o.jsx(tj,{asChild:!0,children:o.jsx(BM,{...n,children:i&&o.jsxs(o.Fragment,{children:[s.label," ",r]})})})},NOe="ToastTitle",Ihe=S.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return o.jsx(ft.div,{...n,ref:e})});Ihe.displayName=NOe;var kOe="ToastDescription",Rhe=S.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return o.jsx(ft.div,{...n,ref:e})});Rhe.displayName=kOe;var Ohe="ToastAction",Mhe=S.forwardRef((t,e)=>{const{altText:r,...n}=t;return r.trim()?o.jsx(Lhe,{altText:r,asChild:!0,children:o.jsx($W,{...n,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${Ohe}\`. Expected non-empty \`string\`.`),null)});Mhe.displayName=Ohe;var Dhe="ToastClose",$W=S.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t,s=jOe(Dhe,r);return o.jsx(Lhe,{asChild:!0,children:o.jsx(ft.button,{type:"button",...n,ref:e,onClick:Qe(t.onClick,s.onClose)})})});$W.displayName=Dhe;var Lhe=S.forwardRef((t,e)=>{const{__scopeToast:r,altText:n,...s}=t;return o.jsx(ft.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...s,ref:e})});function $he(t){const e=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&e.push(n.textContent),EOe(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(...$he(n))}}),e}function YA(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?MW(s,i):s.dispatchEvent(i)}var fX=(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 COe(t=()=>{}){const e=ys(t);bs(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[e])}function EOe(t){return t.nodeType===t.ELEMENT_NODE}function AOe(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 o4(t){const e=document.activeElement;return t.some(r=>r===e?!0:(r.focus(),document.activeElement!==e))}var TOe=Che,Fhe=Ahe,Bhe=Phe,zhe=Ihe,Uhe=Rhe,Hhe=Mhe,Whe=$W;function Vhe(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=Vhe(t[e]))&&(n&&(n+=" "),n+=r)}else for(r in t)t[r]&&(n&&(n+=" "),n+=r);return n}function $r(){for(var t,e,r=0,n="",s=arguments.length;r<s;r++)(t=arguments[r])&&(e=Vhe(t))&&(n&&(n+=" "),n+=e);return n}const pX=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,mX=$r,_f=(t,e)=>r=>{var n;if((e==null?void 0:e.variants)==null)return mX(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=pX(d)||pX(h);return s[u][f]}),l=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,y]=m;return Array.isArray(y)?y.includes({...i,...l}[g]):{...i,...l}[g]===y})?[...u,h,f]:u},[]);return mX(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 POe=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qhe=(...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 IOe={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 ROe=S.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:i,iconNode:a,...l},c)=>S.createElement("svg",{ref:c,...IOe,width:e,height:e,stroke:t,strokeWidth:n?Number(r)*24/Number(e):r,className:qhe("lucide",s),...l},[...a.map(([u,d])=>S.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 Ie=(t,e)=>{const r=S.forwardRef(({className:n,...s},i)=>S.createElement(ROe,{ref:i,iconNode:e,className:qhe(`lucide-${POe(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 gX=Ie("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 OOe=Ie("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/**
 * @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 MOe=Ie("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 Kg=Ie("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 As=Ie("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 DOe=Ie("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 LOe=Ie("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 nr=Ie("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 W2=Ie("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 $Oe=Ie("BookText",[["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:"M8 11h8",key:"vwpz6n"}],["path",{d:"M8 7h6",key:"1f0q6e"}]]);/**
 * @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 xX=Ie("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 FOe=Ie("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 yX=Ie("BriefcaseBusiness",[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M22 13a18.15 18.15 0 0 1-20 0",key:"12hx5q"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]]);/**
 * @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 vX=Ie("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 V2=Ie("CalendarDays",[["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"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);/**
 * @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 yI=Ie("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 nv=Ie("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 kr=Ie("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 ia=Ie("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 Ghe=Ie("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 AE=Ie("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 FW=Ie("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 af=Ie("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 uc=Ie("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 No=Ie("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 BOe=Ie("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 zOe=Ie("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 UOe=Ie("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
 * @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 Khe=Ie("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 HOe=Ie("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 n1=Ie("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 Yhe=Ie("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 l4=Ie("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 sg=Ie("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 Xhe=Ie("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 WOe=Ie("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 ws=Ie("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 VOe=Ie("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 ko=Ie("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 qOe=Ie("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 of=Ie("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 vI=Ie("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 pl=Ie("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 bX=Ie("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 GOe=Ie("FileInput",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
 * @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 KOe=Ie("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 jr=Ie("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 YOe=Ie("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 BW=Ie("FileUp",[["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 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]);/**
 * @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 XOe=Ie("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 QOe=Ie("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 SN=Ie("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 ZOe=Ie("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
 * @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 Qhe=Ie("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 _N=Ie("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 kB=Ie("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 JOe=Ie("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 eMe=Ie("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 tMe=Ie("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 rMe=Ie("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 nMe=Ie("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 sMe=Ie("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 iMe=Ie("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/**
 * @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 s1=Ie("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 lf=Ie("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 aMe=Ie("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 oMe=Ie("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 zW=Ie("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 lMe=Ie("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
 * @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 dd=Ie("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 cMe=Ie("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
 * @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 uMe=Ie("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 dMe=Ie("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 Xe=Ie("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 Ei=Ie("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 UM=Ie("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 hMe=Ie("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 Zhe=Ie("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 Jhe=Ie("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
 * @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=Ie("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 fMe=Ie("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["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 pMe=Ie("MessageSquareMore",[["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 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/**
 * @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 mMe=Ie("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 sv=Ie("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 HM=Ie("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 gMe=Ie("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 xMe=Ie("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 efe=Ie("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 UW=Ie("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 yMe=Ie("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
 * @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 vMe=Ie("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 CB=Ie("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 WM=Ie("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 tfe=Ie("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 HW=Ie("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 EB=Ie("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 Bs=Ie("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 bMe=Ie("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 ua=Ie("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 wMe=Ie("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 jMe=Ie("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 SMe=Ie("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/**
 * @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 rfe=Ie("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 _Me=Ie("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);/**
 * @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 nfe=Ie("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 NMe=Ie("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/**
 * @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 A_=Ie("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 kMe=Ie("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 Ti=Ie("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 WW=Ie("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 CMe=Ie("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 sfe=Ie("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 Sr=Ie("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 AB=Ie("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 EMe=Ie("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 AMe=Ie("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["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"}]]);/**
 * @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 T_=Ie("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/**
 * @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 TE=Ie("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 Pi=Ie("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 TMe=Ie("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 PMe=Ie("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 Jl=Ie("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 wX=Ie("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/**
 * @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 IMe=Ie("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 ife=Ie("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 cf=Ie("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 afe=Ie("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/**
 * @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 nj=Ie("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 NN=Ie("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 RMe=Ie("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);/**
 * @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 Yc=Ie("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 fn=Ie("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 TB=Ie("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 OMe=Ie("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"}]]),VW="-",MMe=t=>{const e=LMe(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:a=>{const l=a.split(VW);return l[0]===""&&l.length!==1&&l.shift(),ofe(l,e)||DMe(a)},getConflictingClassGroupIds:(a,l)=>{const c=r[a]||[];return l&&n[a]?[...c,...n[a]]:c}}},ofe=(t,e)=>{var a;if(t.length===0)return e.classGroupId;const r=t[0],n=e.nextPart.get(r),s=n?ofe(t.slice(1),n):void 0;if(s)return s;if(e.validators.length===0)return;const i=t.join(VW);return(a=e.validators.find(({validator:l})=>l(i)))==null?void 0:a.classGroupId},jX=/^\[(.+)\]$/,DMe=t=>{if(jX.test(t)){const e=jX.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},LMe=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return FMe(Object.entries(t.classGroups),r).forEach(([i,a])=>{PB(a,n,i,e)}),n},PB=(t,e,r,n)=>{t.forEach(s=>{if(typeof s=="string"){const i=s===""?e:SX(e,s);i.classGroupId=r;return}if(typeof s=="function"){if($Me(s)){PB(s(n),e,r,n);return}e.validators.push({validator:s,classGroupId:r});return}Object.entries(s).forEach(([i,a])=>{PB(a,SX(e,i),r,n)})})},SX=(t,e)=>{let r=t;return e.split(VW).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},$Me=t=>t.isThemeGetter,FMe=(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,l])=>[e+a,l])):i);return[r,s]}):t,BMe=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)}}},lfe="!",zMe=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,s=e[0],i=e.length,a=l=>{const c=[];let u=0,d=0,h;for(let y=0;y<l.length;y++){let x=l[y];if(u===0){if(x===s&&(n||l.slice(y,y+i)===e)){c.push(l.slice(d,y)),d=y+i;continue}if(x==="/"){h=y;continue}}x==="["?u++:x==="]"&&u--}const f=c.length===0?l:l.substring(d),p=f.startsWith(lfe),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?l=>r({className:l,parseClassName:a}):a},UMe=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},HMe=t=>({cache:BMe(t.cacheSize),parseClassName:zMe(t),...MMe(t)}),WMe=/\s+/,VMe=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s}=e,i=[],a=t.trim().split(WMe);let l="";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){l=u+(l.length>0?" "+l:l);continue}if(g=n(f),!g){l=u+(l.length>0?" "+l:l);continue}m=!1}const y=UMe(d).join(":"),x=h?y+lfe:y,v=x+g;if(i.includes(v))continue;i.push(v);const b=s(g,m);for(let w=0;w<b.length;++w){const j=b[w];i.push(x+j)}l=u+(l.length>0?" "+l:l)}return l};function qMe(){let t=0,e,r,n="";for(;t<arguments.length;)(e=arguments[t++])&&(r=cfe(e))&&(n&&(n+=" "),n+=r);return n}const cfe=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=cfe(t[n]))&&(r&&(r+=" "),r+=e);return r};function GMe(t,...e){let r,n,s,i=a;function a(c){const u=e.reduce((d,h)=>h(d),t());return r=HMe(u),n=r.cache.get,s=r.cache.set,i=l,l(c)}function l(c){const u=n(c);if(u)return u;const d=VMe(c,r);return s(c,d),d}return function(){return i(qMe.apply(null,arguments))}}const Rn=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},ufe=/^\[(?:([a-z-]+):)?(.+)\]$/i,KMe=/^\d+\/\d+$/,YMe=new Set(["px","full","screen"]),XMe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,QMe=/\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$/,ZMe=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,JMe=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,eDe=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Id=t=>h0(t)||YMe.has(t)||KMe.test(t),Bf=t=>sj(t,"length",lDe),h0=t=>!!t&&!Number.isNaN(Number(t)),c4=t=>sj(t,"number",h0),Kj=t=>!!t&&Number.isInteger(Number(t)),tDe=t=>t.endsWith("%")&&h0(t.slice(0,-1)),sr=t=>ufe.test(t),zf=t=>XMe.test(t),rDe=new Set(["length","size","percentage"]),nDe=t=>sj(t,rDe,dfe),sDe=t=>sj(t,"position",dfe),iDe=new Set(["image","url"]),aDe=t=>sj(t,iDe,uDe),oDe=t=>sj(t,"",cDe),Yj=()=>!0,sj=(t,e,r)=>{const n=ufe.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},lDe=t=>QMe.test(t)&&!ZMe.test(t),dfe=()=>!1,cDe=t=>JMe.test(t),uDe=t=>eDe.test(t),dDe=()=>{const t=Rn("colors"),e=Rn("spacing"),r=Rn("blur"),n=Rn("brightness"),s=Rn("borderColor"),i=Rn("borderRadius"),a=Rn("borderSpacing"),l=Rn("borderWidth"),c=Rn("contrast"),u=Rn("grayscale"),d=Rn("hueRotate"),h=Rn("invert"),f=Rn("gap"),p=Rn("gradientColorStops"),m=Rn("gradientColorStopPositions"),g=Rn("inset"),y=Rn("margin"),x=Rn("opacity"),v=Rn("padding"),b=Rn("saturate"),w=Rn("scale"),j=Rn("sepia"),N=Rn("skew"),C=Rn("space"),A=Rn("translate"),E=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],$=()=>["auto",sr,e],T=()=>[sr,e],M=()=>["",Id,Bf],k=()=>["auto",h0,sr],D=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],K=()=>["solid","dashed","dotted","double","none"],H=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ee=()=>["start","end","center","between","around","evenly","stretch"],V=()=>["","0",sr],B=()=>["auto","avoid","all","avoid-page","page","left","right","column"],z=()=>[h0,sr];return{cacheSize:500,separator:":",theme:{colors:[Yj],spacing:[Id,Bf],blur:["none","",zf,sr],brightness:z(),borderColor:[t],borderRadius:["none","","full",zf,sr],borderSpacing:T(),borderWidth:M(),contrast:z(),grayscale:V(),hueRotate:z(),invert:V(),gap:T(),gradientColorStops:[t],gradientColorStopPositions:[tDe,Bf],inset:$(),margin:$(),opacity:z(),padding:T(),saturate:z(),scale:z(),sepia:V(),skew:z(),space:T(),translate:T()},classGroups:{aspect:[{aspect:["auto","square","video",sr]}],container:["container"],columns:[{columns:[zf]}],"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:[...D(),sr]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:E()}],"overscroll-x":[{"overscroll-x":E()}],"overscroll-y":[{"overscroll-y":E()}],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",Kj,sr]}],basis:[{basis:$()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",sr]}],grow:[{grow:V()}],shrink:[{shrink:V()}],order:[{order:["first","last","none",Kj,sr]}],"grid-cols":[{"grid-cols":[Yj]}],"col-start-end":[{col:["auto",{span:["full",Kj,sr]},sr]}],"col-start":[{"col-start":k()}],"col-end":[{"col-end":k()}],"grid-rows":[{"grid-rows":[Yj]}],"row-start-end":[{row:["auto",{span:[Kj,sr]},sr]}],"row-start":[{"row-start":k()}],"row-end":[{"row-end":k()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",sr]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",sr]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...ee()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ee(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ee(),"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:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[C]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[C]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",sr,e]}],"min-w":[{"min-w":[sr,e,"min","max","fit"]}],"max-w":[{"max-w":[sr,e,"none","full","min","max","fit","prose",{screen:[zf]},zf]}],h:[{h:[sr,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[sr,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[sr,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[sr,e,"auto","min","max","fit"]}],"font-size":[{text:["base",zf,Bf]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",c4]}],"font-family":[{font:[Yj]}],"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",sr]}],"line-clamp":[{"line-clamp":["none",h0,c4]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Id,sr]}],"list-image":[{"list-image":["none",sr]}],"list-style-type":[{list:["none","disc","decimal",sr]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[x]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[x]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...K(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Id,Bf]}],"underline-offset":[{"underline-offset":["auto",Id,sr]}],"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:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",sr]}],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",sr]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[x]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...D(),sDe]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",nDe]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},aDe]}],"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:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[x]}],"border-style":[{border:[...K(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[x]}],"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":[Id,sr]}],"outline-w":[{outline:[Id,Bf]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:M()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[x]}],"ring-offset-w":[{"ring-offset":[Id,Bf]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",zf,oDe]}],"shadow-color":[{shadow:[Yj]}],opacity:[{opacity:[x]}],"mix-blend":[{"mix-blend":[...H(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":H()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",zf,sr]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[h]}],saturate:[{saturate:[b]}],sepia:[{sepia:[j]}],"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":[x]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[j]}],"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",sr]}],duration:[{duration:z()}],ease:[{ease:["linear","in","out","in-out",sr]}],delay:[{delay:z()}],animate:[{animate:["none","spin","ping","pulse","bounce",sr]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[Kj,sr]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[N]}],"skew-y":[{"skew-y":[N]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",sr]}],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",sr]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"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",sr]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Id,Bf,c4]}],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"]}}},hDe=GMe(dDe);function Pe(...t){return hDe($r(t))}const fDe=TOe,hfe=S.forwardRef(({className:t,...e},r)=>o.jsx(Fhe,{ref:r,className:Pe("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}));hfe.displayName=Fhe.displayName;const pDe=_f("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"}}),ffe=S.forwardRef(({className:t,variant:e,...r},n)=>o.jsx(Bhe,{ref:n,className:Pe(pDe({variant:e}),t),...r}));ffe.displayName=Bhe.displayName;const mDe=S.forwardRef(({className:t,...e},r)=>o.jsx(Hhe,{ref:r,className:Pe("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}));mDe.displayName=Hhe.displayName;const pfe=S.forwardRef(({className:t,...e},r)=>o.jsx(Whe,{ref:r,className:Pe("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:o.jsx(fn,{className:"h-4 w-4"})}));pfe.displayName=Whe.displayName;const mfe=S.forwardRef(({className:t,...e},r)=>o.jsx(zhe,{ref:r,className:Pe("text-sm font-semibold",t),...e}));mfe.displayName=zhe.displayName;const gfe=S.forwardRef(({className:t,...e},r)=>o.jsx(Uhe,{ref:r,className:Pe("text-sm opacity-90",t),...e}));gfe.displayName=Uhe.displayName;function gDe(){const{toasts:t}=Bn();return o.jsxs(fDe,{children:[t.map(function({id:e,title:r,description:n,action:s,...i}){return o.jsxs(ffe,{...i,children:[o.jsxs("div",{className:"grid gap-1",children:[r&&o.jsx(mfe,{children:r}),n&&o.jsx(gfe,{children:n})]}),s,o.jsx(pfe,{})]},e)}),o.jsx(hfe,{})]})}var _X=["light","dark"],xDe="(prefers-color-scheme: dark)",yDe=S.createContext(void 0),vDe={setTheme:t=>{},themes:[]},bDe=()=>{var t;return(t=S.useContext(yDe))!=null?t:vDe};S.memo(({forcedTheme:t,storageKey:e,attribute:r,enableSystem:n,enableColorScheme:s,defaultTheme:i,value:a,attrs:l,nonce:c})=>{let u=i==="system",d=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${l.map(m=>`'${m}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,h=s?_X.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,y=!0)=>{let x=a?a[m]:m,v=g?m+"|| ''":`'${x}'`,b="";return s&&y&&!g&&_X.includes(m)&&(b+=`d.style.colorScheme = '${m}';`),r==="class"?g||x?b+=`c.add(${v})`:b+="null":x&&(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='${xDe}',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 S.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:p}})});var wDe=t=>{switch(t){case"success":return _De;case"info":return kDe;case"warning":return NDe;case"error":return CDe;default:return null}},jDe=Array(12).fill(0),SDe=({visible:t,className:e})=>ve.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},ve.createElement("div",{className:"sonner-spinner"},jDe.map((r,n)=>ve.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),_De=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.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"})),NDe=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ve.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"})),kDe=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.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"})),CDe=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.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"})),EDe=ve.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"},ve.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ve.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ADe=()=>{let[t,e]=ve.useState(document.hidden);return ve.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},IB=1,TDe=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:IB++,i=this.toasts.find(l=>l.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(l=>l.id===s?(this.publish({...l,...t,id:s,title:r}),{...l,...t,id:s,dismissible:a,title:r}):l):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],ve.isValidElement(c))s=!1,this.create({id:r,type:"default",message:c});else if(IDe(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)}),l=()=>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:l}:Object.assign(r,{unwrap:l})},this.custom=(t,e)=>{let r=(e==null?void 0:e.id)||IB++;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}},ho=new TDe,PDe=(t,e)=>{let r=(e==null?void 0:e.id)||IB++;return ho.addToast({title:t,...e,id:r}),r},IDe=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",RDe=PDe,ODe=()=>ho.toasts,MDe=()=>ho.getActiveToasts(),Ke=Object.assign(RDe,{success:ho.success,info:ho.info,warning:ho.warning,error:ho.error,custom:ho.custom,message:ho.message,promise:ho.promise,dismiss:ho.dismiss,loading:ho.loading},{getHistory:ODe,getToasts:MDe});function DDe(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))}DDe(`: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 XA(t){return t.label!==void 0}var LDe=3,$De="32px",FDe="16px",NX=4e3,BDe=356,zDe=14,UDe=20,HDe=200;function gc(...t){return t.filter(Boolean).join(" ")}function WDe(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var VDe=t=>{var e,r,n,s,i,a,l,c,u,d,h;let{invert:f,toast:p,unstyled:m,interacting:g,setHeights:y,visibleToasts:x,heights:v,index:b,toasts:w,expanded:j,removeToast:N,defaultRichColors:C,closeButton:A,style:E,cancelButtonStyle:O,actionButtonStyle:$,className:T="",descriptionClassName:M="",duration:k,position:D,gap:K,loadingIcon:H,expandByDefault:ee,classNames:V,icons:B,closeButtonAriaLabel:z="Close toast",pauseWhenPageIsHidden:F}=t,[G,Q]=ve.useState(null),[ie,se]=ve.useState(null),[q,L]=ve.useState(!1),[Z,J]=ve.useState(!1),[W,X]=ve.useState(!1),[he,P]=ve.useState(!1),[oe,Y]=ve.useState(!1),[R,I]=ve.useState(0),[U,re]=ve.useState(0),ue=ve.useRef(p.duration||k||NX),ae=ve.useRef(null),ge=ve.useRef(null),we=b===0,ce=b+1<=x,ne=p.type,fe=p.dismissible!==!1,be=p.className||"",xe=p.descriptionClassName||"",_e=ve.useMemo(()=>v.findIndex(He=>He.toastId===p.id)||0,[v,p.id]),ke=ve.useMemo(()=>{var He;return(He=p.closeButton)!=null?He:A},[p.closeButton,A]),$e=ve.useMemo(()=>p.duration||k||NX,[p.duration,k]),Te=ve.useRef(0),ot=ve.useRef(0),wt=ve.useRef(0),Ct=ve.useRef(null),[pr,Kt]=D.split("-"),Re=ve.useMemo(()=>v.reduce((He,Ye,it)=>it>=_e?He:He+Ye.height,0),[v,_e]),ye=ADe(),Ne=p.invert||f,Ce=ne==="loading";ot.current=ve.useMemo(()=>_e*K+Re,[_e,Re]),ve.useEffect(()=>{ue.current=$e},[$e]),ve.useEffect(()=>{L(!0)},[]),ve.useEffect(()=>{let He=ge.current;if(He){let Ye=He.getBoundingClientRect().height;return re(Ye),y(it=>[{toastId:p.id,height:Ye,position:p.position},...it]),()=>y(it=>it.filter(zt=>zt.toastId!==p.id))}},[y,p.id]),ve.useLayoutEffect(()=>{if(!q)return;let He=ge.current,Ye=He.style.height;He.style.height="auto";let it=He.getBoundingClientRect().height;He.style.height=Ye,re(it),y(zt=>zt.find(Xt=>Xt.toastId===p.id)?zt.map(Xt=>Xt.toastId===p.id?{...Xt,height:it}:Xt):[{toastId:p.id,height:it,position:p.position},...zt])},[q,p.title,p.description,y,p.id]);let Fe=ve.useCallback(()=>{J(!0),I(ot.current),y(He=>He.filter(Ye=>Ye.toastId!==p.id)),setTimeout(()=>{N(p)},HDe)},[p,N,y,ot]);ve.useEffect(()=>{if(p.promise&&ne==="loading"||p.duration===1/0||p.type==="loading")return;let He;return j||g||F&&ye?(()=>{if(wt.current<Te.current){let Ye=new Date().getTime()-Te.current;ue.current=ue.current-Ye}wt.current=new Date().getTime()})():ue.current!==1/0&&(Te.current=new Date().getTime(),He=setTimeout(()=>{var Ye;(Ye=p.onAutoClose)==null||Ye.call(p,p),Fe()},ue.current)),()=>clearTimeout(He)},[j,g,p,ne,F,ye,Fe]),ve.useEffect(()=>{p.delete&&Fe()},[Fe,p.delete]);function yt(){var He,Ye,it;return B!=null&&B.loading?ve.createElement("div",{className:gc(V==null?void 0:V.loader,(He=p==null?void 0:p.classNames)==null?void 0:He.loader,"sonner-loader"),"data-visible":ne==="loading"},B.loading):H?ve.createElement("div",{className:gc(V==null?void 0:V.loader,(Ye=p==null?void 0:p.classNames)==null?void 0:Ye.loader,"sonner-loader"),"data-visible":ne==="loading"},H):ve.createElement(SDe,{className:gc(V==null?void 0:V.loader,(it=p==null?void 0:p.classNames)==null?void 0:it.loader),visible:ne==="loading"})}return ve.createElement("li",{tabIndex:0,ref:ge,className:gc(T,be,V==null?void 0:V.toast,(e=p==null?void 0:p.classNames)==null?void 0:e.toast,V==null?void 0:V.default,V==null?void 0:V[ne],(r=p==null?void 0:p.classNames)==null?void 0:r[ne]),"data-sonner-toast":"","data-rich-colors":(n=p.richColors)!=null?n:C,"data-styled":!(p.jsx||p.unstyled||m),"data-mounted":q,"data-promise":!!p.promise,"data-swiped":oe,"data-removed":Z,"data-visible":ce,"data-y-position":pr,"data-x-position":Kt,"data-index":b,"data-front":we,"data-swiping":W,"data-dismissible":fe,"data-type":ne,"data-invert":Ne,"data-swipe-out":he,"data-swipe-direction":ie,"data-expanded":!!(j||ee&&q),style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${Z?R:ot.current}px`,"--initial-height":ee?"auto":`${U}px`,...E,...p.style},onDragEnd:()=>{X(!1),Q(null),Ct.current=null},onPointerDown:He=>{Ce||!fe||(ae.current=new Date,I(ot.current),He.target.setPointerCapture(He.pointerId),He.target.tagName!=="BUTTON"&&(X(!0),Ct.current={x:He.clientX,y:He.clientY}))},onPointerUp:()=>{var He,Ye,it,zt;if(he||!fe)return;Ct.current=null;let Xt=Number(((He=ge.current)==null?void 0:He.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Mr=Number(((Ye=ge.current)==null?void 0:Ye.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ur=new Date().getTime()-((it=ae.current)==null?void 0:it.getTime()),Fr=G==="x"?Xt:Mr,Kr=Math.abs(Fr)/ur;if(Math.abs(Fr)>=UDe||Kr>.11){I(ot.current),(zt=p.onDismiss)==null||zt.call(p,p),se(G==="x"?Xt>0?"right":"left":Mr>0?"down":"up"),Fe(),P(!0),Y(!1);return}X(!1),Q(null)},onPointerMove:He=>{var Ye,it,zt,Xt;if(!Ct.current||!fe||((Ye=window.getSelection())==null?void 0:Ye.toString().length)>0)return;let Mr=He.clientY-Ct.current.y,ur=He.clientX-Ct.current.x,Fr=(it=t.swipeDirections)!=null?it:WDe(D);!G&&(Math.abs(ur)>1||Math.abs(Mr)>1)&&Q(Math.abs(ur)>Math.abs(Mr)?"x":"y");let Kr={x:0,y:0};G==="y"?(Fr.includes("top")||Fr.includes("bottom"))&&(Fr.includes("top")&&Mr<0||Fr.includes("bottom")&&Mr>0)&&(Kr.y=Mr):G==="x"&&(Fr.includes("left")||Fr.includes("right"))&&(Fr.includes("left")&&ur<0||Fr.includes("right")&&ur>0)&&(Kr.x=ur),(Math.abs(Kr.x)>0||Math.abs(Kr.y)>0)&&Y(!0),(zt=ge.current)==null||zt.style.setProperty("--swipe-amount-x",`${Kr.x}px`),(Xt=ge.current)==null||Xt.style.setProperty("--swipe-amount-y",`${Kr.y}px`)}},ke&&!p.jsx?ve.createElement("button",{"aria-label":z,"data-disabled":Ce,"data-close-button":!0,onClick:Ce||!fe?()=>{}:()=>{var He;Fe(),(He=p.onDismiss)==null||He.call(p,p)},className:gc(V==null?void 0:V.closeButton,(s=p==null?void 0:p.classNames)==null?void 0:s.closeButton)},(i=B==null?void 0:B.close)!=null?i:EDe):null,p.jsx||S.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:ve.createElement(ve.Fragment,null,ne||p.icon||p.promise?ve.createElement("div",{"data-icon":"",className:gc(V==null?void 0:V.icon,(a=p==null?void 0:p.classNames)==null?void 0:a.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||yt():null,p.type!=="loading"?p.icon||(B==null?void 0:B[ne])||wDe(ne):null):null,ve.createElement("div",{"data-content":"",className:gc(V==null?void 0:V.content,(l=p==null?void 0:p.classNames)==null?void 0:l.content)},ve.createElement("div",{"data-title":"",className:gc(V==null?void 0:V.title,(c=p==null?void 0:p.classNames)==null?void 0:c.title)},typeof p.title=="function"?p.title():p.title),p.description?ve.createElement("div",{"data-description":"",className:gc(M,xe,V==null?void 0:V.description,(u=p==null?void 0:p.classNames)==null?void 0:u.description)},typeof p.description=="function"?p.description():p.description):null),S.isValidElement(p.cancel)?p.cancel:p.cancel&&XA(p.cancel)?ve.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||O,onClick:He=>{var Ye,it;XA(p.cancel)&&fe&&((it=(Ye=p.cancel).onClick)==null||it.call(Ye,He),Fe())},className:gc(V==null?void 0:V.cancelButton,(d=p==null?void 0:p.classNames)==null?void 0:d.cancelButton)},p.cancel.label):null,S.isValidElement(p.action)?p.action:p.action&&XA(p.action)?ve.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||$,onClick:He=>{var Ye,it;XA(p.action)&&((it=(Ye=p.action).onClick)==null||it.call(Ye,He),!He.defaultPrevented&&Fe())},className:gc(V==null?void 0:V.actionButton,(h=p==null?void 0:p.classNames)==null?void 0:h.actionButton)},p.action.label):null))};function kX(){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 qDe(t,e){let r={};return[t,e].forEach((n,s)=>{let i=s===1,a=i?"--mobile-offset":"--offset",l=i?FDe:$De;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}`]=l:r[`${a}-${u}`]=typeof n[u]=="number"?`${n[u]}px`:n[u]}):c(l)}),r}var GDe=S.forwardRef(function(t,e){let{invert:r,position:n="bottom-right",hotkey:s=["altKey","KeyT"],expand:i,closeButton:a,className:l,offset:c,mobileOffset:u,theme:d="light",richColors:h,duration:f,style:p,visibleToasts:m=LDe,toastOptions:g,dir:y=kX(),gap:x=zDe,loadingIcon:v,icons:b,containerAriaLabel:w="Notifications",pauseWhenPageIsHidden:j}=t,[N,C]=ve.useState([]),A=ve.useMemo(()=>Array.from(new Set([n].concat(N.filter(F=>F.position).map(F=>F.position)))),[N,n]),[E,O]=ve.useState([]),[$,T]=ve.useState(!1),[M,k]=ve.useState(!1),[D,K]=ve.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=ve.useRef(null),ee=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),V=ve.useRef(null),B=ve.useRef(!1),z=ve.useCallback(F=>{C(G=>{var Q;return(Q=G.find(ie=>ie.id===F.id))!=null&&Q.delete||ho.dismiss(F.id),G.filter(({id:ie})=>ie!==F.id)})},[]);return ve.useEffect(()=>ho.subscribe(F=>{if(F.dismiss){C(G=>G.map(Q=>Q.id===F.id?{...Q,delete:!0}:Q));return}setTimeout(()=>{RW.flushSync(()=>{C(G=>{let Q=G.findIndex(ie=>ie.id===F.id);return Q!==-1?[...G.slice(0,Q),{...G[Q],...F},...G.slice(Q+1)]:[F,...G]})})})}),[]),ve.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:G})=>{K(G?"dark":"light")})}catch{F.addListener(({matches:Q})=>{try{K(Q?"dark":"light")}catch(ie){console.error(ie)}})}},[d]),ve.useEffect(()=>{N.length<=1&&T(!1)},[N]),ve.useEffect(()=>{let F=G=>{var Q,ie;s.every(se=>G[se]||G.code===se)&&(T(!0),(Q=H.current)==null||Q.focus()),G.code==="Escape"&&(document.activeElement===H.current||(ie=H.current)!=null&&ie.contains(document.activeElement))&&T(!1)};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[s]),ve.useEffect(()=>{if(H.current)return()=>{V.current&&(V.current.focus({preventScroll:!0}),V.current=null,B.current=!1)}},[H.current]),ve.createElement("section",{ref:e,"aria-label":`${w} ${ee}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},A.map((F,G)=>{var Q;let[ie,se]=F.split("-");return N.length?ve.createElement("ol",{key:F,dir:y==="auto"?kX():y,tabIndex:-1,ref:H,className:l,"data-sonner-toaster":!0,"data-theme":D,"data-y-position":ie,"data-lifted":$&&N.length>1&&!i,"data-x-position":se,style:{"--front-toast-height":`${((Q=E[0])==null?void 0:Q.height)||0}px`,"--width":`${BDe}px`,"--gap":`${x}px`,...p,...qDe(c,u)},onBlur:q=>{B.current&&!q.currentTarget.contains(q.relatedTarget)&&(B.current=!1,V.current&&(V.current.focus({preventScroll:!0}),V.current=null))},onFocus:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||B.current||(B.current=!0,V.current=q.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{M||T(!1)},onDragEnd:()=>T(!1),onPointerDown:q=>{q.target instanceof HTMLElement&&q.target.dataset.dismissible==="false"||k(!0)},onPointerUp:()=>k(!1)},N.filter(q=>!q.position&&G===0||q.position===F).map((q,L)=>{var Z,J;return ve.createElement(VDe,{key:q.id,icons:b,index:L,toast:q,defaultRichColors:h,duration:(Z=g==null?void 0:g.duration)!=null?Z:f,className:g==null?void 0:g.className,descriptionClassName:g==null?void 0:g.descriptionClassName,invert:r,visibleToasts:m,closeButton:(J=g==null?void 0:g.closeButton)!=null?J:a,interacting:M,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:z,toasts:N.filter(W=>W.position==q.position),heights:E.filter(W=>W.position==q.position),setHeights:O,expandByDefault:i,gap:x,loadingIcon:v,expanded:$,pauseWhenPageIsHidden:j,swipeDirections:t.swipeDirections})})):null}))});const KDe=({...t})=>{const{theme:e="system"}=bDe();return o.jsx(GDe,{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 YDe=U7[" useId ".trim().toString()]||(()=>{}),XDe=0;function Co(t){const[e,r]=S.useState(YDe());return bs(()=>{r(n=>n??String(XDe++))},[t]),e?`radix-${e}`:""}const QDe=["top","right","bottom","left"],Um=Math.min,el=Math.max,bI=Math.round,QA=Math.floor,sd=t=>({x:t,y:t}),ZDe={left:"right",right:"left",bottom:"top",top:"bottom"},JDe={start:"end",end:"start"};function RB(t,e,r){return el(t,Um(e,r))}function uf(t,e){return typeof t=="function"?t(e):t}function df(t){return t.split("-")[0]}function ij(t){return t.split("-")[1]}function qW(t){return t==="x"?"y":"x"}function GW(t){return t==="y"?"height":"width"}const eLe=new Set(["top","bottom"]);function Ju(t){return eLe.has(df(t))?"y":"x"}function KW(t){return qW(Ju(t))}function tLe(t,e,r){r===void 0&&(r=!1);const n=ij(t),s=KW(t),i=GW(s);let a=s==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(a=wI(a)),[a,wI(a)]}function rLe(t){const e=wI(t);return[OB(t),e,OB(e)]}function OB(t){return t.replace(/start|end/g,e=>JDe[e])}const CX=["left","right"],EX=["right","left"],nLe=["top","bottom"],sLe=["bottom","top"];function iLe(t,e,r){switch(t){case"top":case"bottom":return r?e?EX:CX:e?CX:EX;case"left":case"right":return e?nLe:sLe;default:return[]}}function aLe(t,e,r,n){const s=ij(t);let i=iLe(df(t),r==="start",n);return s&&(i=i.map(a=>a+"-"+s),e&&(i=i.concat(i.map(OB)))),i}function wI(t){return t.replace(/left|right|bottom|top/g,e=>ZDe[e])}function oLe(t){return{top:0,right:0,bottom:0,left:0,...t}}function xfe(t){return typeof t!="number"?oLe(t):{top:t,right:t,bottom:t,left:t}}function jI(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 AX(t,e,r){let{reference:n,floating:s}=t;const i=Ju(e),a=KW(e),l=GW(a),c=df(e),u=i==="y",d=n.x+n.width/2-s.width/2,h=n.y+n.height/2-s.height/2,f=n[l]/2-s[l]/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(ij(e)){case"start":p[a]-=f*(r&&u?-1:1);break;case"end":p[a]+=f*(r&&u?-1:1);break}return p}const lLe=async(t,e,r)=>{const{placement:n="bottom",strategy:s="absolute",middleware:i=[],platform:a}=r,l=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}=AX(u,n,c),f=n,p={},m=0;for(let g=0;g<l.length;g++){const{name:y,fn:x}=l[g],{x:v,y:b,data:w,reset:j}=await x({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,[y]:{...p[y],...w}},j&&m<=50&&(m++,typeof j=="object"&&(j.placement&&(f=j.placement),j.rects&&(u=j.rects===!0?await a.getElementRects({reference:t,floating:e,strategy:s}):j.rects),{x:d,y:h}=AX(u,f,c)),g=-1)}return{x:d,y:h,placement:f,strategy:s,middlewareData:p}};async function kN(t,e){var r;e===void 0&&(e={});const{x:n,y:s,platform:i,rects:a,elements:l,strategy:c}=t,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=uf(e,t),m=xfe(p),y=l[f?h==="floating"?"reference":"floating":h],x=jI(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(y)))==null||r?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.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(l.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},j=jI(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:b,strategy:c}):v);return{top:(x.top-j.top+m.top)/w.y,bottom:(j.bottom-x.bottom+m.bottom)/w.y,left:(x.left-j.left+m.left)/w.x,right:(j.right-x.right+m.right)/w.x}}const cLe=t=>({name:"arrow",options:t,async fn(e){const{x:r,y:n,placement:s,rects:i,platform:a,elements:l,middlewareData:c}=e,{element:u,padding:d=0}=uf(t,e)||{};if(u==null)return{};const h=xfe(d),f={x:r,y:n},p=KW(s),m=GW(p),g=await a.getDimensions(u),y=p==="y",x=y?"top":"left",v=y?"bottom":"right",b=y?"clientHeight":"clientWidth",w=i.reference[m]+i.reference[p]-f[p]-i.floating[m],j=f[p]-i.reference[p],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let C=N?N[b]:0;(!C||!await(a.isElement==null?void 0:a.isElement(N)))&&(C=l.floating[b]||i.floating[m]);const A=w/2-j/2,E=C/2-g[m]/2-1,O=Um(h[x],E),$=Um(h[v],E),T=O,M=C-g[m]-$,k=C/2-g[m]/2+A,D=RB(T,k,M),K=!c.arrow&&ij(s)!=null&&k!==D&&i.reference[m]/2-(k<T?O:$)-g[m]/2<0,H=K?k<T?k-T:k-M:0;return{[p]:f[p]+H,data:{[p]:D,centerOffset:k-D-H,...K&&{alignmentOffset:H}},reset:K}}}),uLe=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:l,platform:c,elements:u}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...y}=uf(t,e);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const x=df(s),v=Ju(l),b=df(l)===l,w=await(c.isRTL==null?void 0:c.isRTL(u.floating)),j=f||(b||!g?[wI(l)]:rLe(l)),N=m!=="none";!f&&N&&j.push(...aLe(l,g,m,w));const C=[l,...j],A=await kN(e,y),E=[];let O=((n=i.flip)==null?void 0:n.overflows)||[];if(d&&E.push(A[x]),h){const k=tLe(s,a,w);E.push(A[k[0]],A[k[1]])}if(O=[...O,{placement:s,overflows:E}],!E.every(k=>k<=0)){var $,T;const k=((($=i.flip)==null?void 0:$.index)||0)+1,D=C[k];if(D&&(!(h==="alignment"?v!==Ju(D):!1)||O.every(ee=>Ju(ee.placement)===v?ee.overflows[0]>0:!0)))return{data:{index:k,overflows:O},reset:{placement:D}};let K=(T=O.filter(H=>H.overflows[0]<=0).sort((H,ee)=>H.overflows[1]-ee.overflows[1])[0])==null?void 0:T.placement;if(!K)switch(p){case"bestFit":{var M;const H=(M=O.filter(ee=>{if(N){const V=Ju(ee.placement);return V===v||V==="y"}return!0}).map(ee=>[ee.placement,ee.overflows.filter(V=>V>0).reduce((V,B)=>V+B,0)]).sort((ee,V)=>ee[1]-V[1])[0])==null?void 0:M[0];H&&(K=H);break}case"initialPlacement":K=l;break}if(s!==K)return{reset:{placement:K}}}return{}}}};function TX(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function PX(t){return QDe.some(e=>t[e]>=0)}const dLe=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:r}=e,{strategy:n="referenceHidden",...s}=uf(t,e);switch(n){case"referenceHidden":{const i=await kN(e,{...s,elementContext:"reference"}),a=TX(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:PX(a)}}}case"escaped":{const i=await kN(e,{...s,altBoundary:!0}),a=TX(i,r.floating);return{data:{escapedOffsets:a,escaped:PX(a)}}}default:return{}}}}},yfe=new Set(["left","top"]);async function hLe(t,e){const{placement:r,platform:n,elements:s}=t,i=await(n.isRTL==null?void 0:n.isRTL(s.floating)),a=df(r),l=ij(r),c=Ju(r)==="y",u=yfe.has(a)?-1:1,d=i&&c?-1:1,h=uf(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 l&&typeof m=="number"&&(p=l==="end"?m*-1:m),c?{x:p*d,y:f*u}:{x:f*u,y:p*d}}const fLe=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:l}=e,c=await hLe(e,t);return a===((r=l.offset)==null?void 0:r.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:s+c.x,y:i+c.y,data:{...c,placement:a}}}}},pLe=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:l={fn:y=>{let{x,y:v}=y;return{x,y:v}}},...c}=uf(t,e),u={x:r,y:n},d=await kN(e,c),h=Ju(df(s)),f=qW(h);let p=u[f],m=u[h];if(i){const y=f==="y"?"top":"left",x=f==="y"?"bottom":"right",v=p+d[y],b=p-d[x];p=RB(v,p,b)}if(a){const y=h==="y"?"top":"left",x=h==="y"?"bottom":"right",v=m+d[y],b=m-d[x];m=RB(v,m,b)}const g=l.fn({...e,[f]:p,[h]:m});return{...g,data:{x:g.x-r,y:g.y-n,enabled:{[f]:i,[h]:a}}}}}},mLe=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:r,y:n,placement:s,rects:i,middlewareData:a}=e,{offset:l=0,mainAxis:c=!0,crossAxis:u=!0}=uf(t,e),d={x:r,y:n},h=Ju(s),f=qW(h);let p=d[f],m=d[h];const g=uf(l,e),y=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]+y.mainAxis,j=i.reference[f]+i.reference[b]-y.mainAxis;p<w?p=w:p>j&&(p=j)}if(u){var x,v;const b=f==="y"?"width":"height",w=yfe.has(df(s)),j=i.reference[h]-i.floating[b]+(w&&((x=a.offset)==null?void 0:x[h])||0)+(w?0:y.crossAxis),N=i.reference[h]+i.reference[b]+(w?0:((v=a.offset)==null?void 0:v[h])||0)-(w?y.crossAxis:0);m<j?m=j:m>N&&(m=N)}return{[f]:p,[h]:m}}}},gLe=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:l}=e,{apply:c=()=>{},...u}=uf(t,e),d=await kN(e,u),h=df(s),f=ij(s),p=Ju(s)==="y",{width:m,height:g}=i.floating;let y,x;h==="top"||h==="bottom"?(y=h,x=f===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(x=h,y=f==="end"?"top":"bottom");const v=g-d.top-d.bottom,b=m-d.left-d.right,w=Um(g-d[y],v),j=Um(m-d[x],b),N=!e.middlewareData.shift;let C=w,A=j;if((r=e.middlewareData.shift)!=null&&r.enabled.x&&(A=b),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(C=v),N&&!f){const O=el(d.left,0),$=el(d.right,0),T=el(d.top,0),M=el(d.bottom,0);p?A=m-2*(O!==0||$!==0?O+$:el(d.left,d.right)):C=g-2*(T!==0||M!==0?T+M:el(d.top,d.bottom))}await c({...e,availableWidth:A,availableHeight:C});const E=await a.getDimensions(l.floating);return m!==E.width||g!==E.height?{reset:{rects:!0}}:{}}}};function VM(){return typeof window<"u"}function aj(t){return vfe(t)?(t.nodeName||"").toLowerCase():"#document"}function ll(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function yd(t){var e;return(e=(vfe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function vfe(t){return VM()?t instanceof Node||t instanceof ll(t).Node:!1}function eu(t){return VM()?t instanceof Element||t instanceof ll(t).Element:!1}function hd(t){return VM()?t instanceof HTMLElement||t instanceof ll(t).HTMLElement:!1}function IX(t){return!VM()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ll(t).ShadowRoot}const xLe=new Set(["inline","contents"]);function PE(t){const{overflow:e,overflowX:r,overflowY:n,display:s}=tu(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+r)&&!xLe.has(s)}const yLe=new Set(["table","td","th"]);function vLe(t){return yLe.has(aj(t))}const bLe=[":popover-open",":modal"];function qM(t){return bLe.some(e=>{try{return t.matches(e)}catch{return!1}})}const wLe=["transform","translate","scale","rotate","perspective"],jLe=["transform","translate","scale","rotate","perspective","filter"],SLe=["paint","layout","strict","content"];function YW(t){const e=XW(),r=eu(t)?tu(t):t;return wLe.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)||jLe.some(n=>(r.willChange||"").includes(n))||SLe.some(n=>(r.contain||"").includes(n))}function _Le(t){let e=Hm(t);for(;hd(e)&&!i1(e);){if(YW(e))return e;if(qM(e))return null;e=Hm(e)}return null}function XW(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const NLe=new Set(["html","body","#document"]);function i1(t){return NLe.has(aj(t))}function tu(t){return ll(t).getComputedStyle(t)}function GM(t){return eu(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Hm(t){if(aj(t)==="html")return t;const e=t.assignedSlot||t.parentNode||IX(t)&&t.host||yd(t);return IX(e)?e.host:e}function bfe(t){const e=Hm(t);return i1(e)?t.ownerDocument?t.ownerDocument.body:t.body:hd(e)&&PE(e)?e:bfe(e)}function CN(t,e,r){var n;e===void 0&&(e=[]),r===void 0&&(r=!0);const s=bfe(t),i=s===((n=t.ownerDocument)==null?void 0:n.body),a=ll(s);if(i){const l=MB(a);return e.concat(a,a.visualViewport||[],PE(s)?s:[],l&&r?CN(l):[])}return e.concat(s,CN(s,[],r))}function MB(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function wfe(t){const e=tu(t);let r=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=hd(t),i=s?t.offsetWidth:r,a=s?t.offsetHeight:n,l=bI(r)!==i||bI(n)!==a;return l&&(r=i,n=a),{width:r,height:n,$:l}}function QW(t){return eu(t)?t:t.contextElement}function f0(t){const e=QW(t);if(!hd(e))return sd(1);const r=e.getBoundingClientRect(),{width:n,height:s,$:i}=wfe(e);let a=(i?bI(r.width):r.width)/n,l=(i?bI(r.height):r.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const kLe=sd(0);function jfe(t){const e=ll(t);return!XW()||!e.visualViewport?kLe:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function CLe(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==ll(t)?!1:e}function iv(t,e,r,n){e===void 0&&(e=!1),r===void 0&&(r=!1);const s=t.getBoundingClientRect(),i=QW(t);let a=sd(1);e&&(n?eu(n)&&(a=f0(n)):a=f0(t));const l=CLe(i,r,n)?jfe(i):sd(0);let c=(s.left+l.x)/a.x,u=(s.top+l.y)/a.y,d=s.width/a.x,h=s.height/a.y;if(i){const f=ll(i),p=n&&eu(n)?ll(n):n;let m=f,g=MB(m);for(;g&&n&&p!==m;){const y=f0(g),x=g.getBoundingClientRect(),v=tu(g),b=x.left+(g.clientLeft+parseFloat(v.paddingLeft))*y.x,w=x.top+(g.clientTop+parseFloat(v.paddingTop))*y.y;c*=y.x,u*=y.y,d*=y.x,h*=y.y,c+=b,u+=w,m=ll(g),g=MB(m)}}return jI({width:d,height:h,x:c,y:u})}function KM(t,e){const r=GM(t).scrollLeft;return e?e.left+r:iv(yd(t)).left+r}function Sfe(t,e){const r=t.getBoundingClientRect(),n=r.left+e.scrollLeft-KM(t,r),s=r.top+e.scrollTop;return{x:n,y:s}}function ELe(t){let{elements:e,rect:r,offsetParent:n,strategy:s}=t;const i=s==="fixed",a=yd(n),l=e?qM(e.floating):!1;if(n===a||l&&i)return r;let c={scrollLeft:0,scrollTop:0},u=sd(1);const d=sd(0),h=hd(n);if((h||!h&&!i)&&((aj(n)!=="body"||PE(a))&&(c=GM(n)),hd(n))){const p=iv(n);u=f0(n),d.x=p.x+n.clientLeft,d.y=p.y+n.clientTop}const f=a&&!h&&!i?Sfe(a,c):sd(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 ALe(t){return Array.from(t.getClientRects())}function TLe(t){const e=yd(t),r=GM(t),n=t.ownerDocument.body,s=el(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=el(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let a=-r.scrollLeft+KM(t);const l=-r.scrollTop;return tu(n).direction==="rtl"&&(a+=el(e.clientWidth,n.clientWidth)-s),{width:s,height:i,x:a,y:l}}const RX=25;function PLe(t,e){const r=ll(t),n=yd(t),s=r.visualViewport;let i=n.clientWidth,a=n.clientHeight,l=0,c=0;if(s){i=s.width,a=s.height;const d=XW();(!d||d&&e==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=KM(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<=RX&&(i-=m)}else u<=RX&&(i+=u);return{width:i,height:a,x:l,y:c}}const ILe=new Set(["absolute","fixed"]);function RLe(t,e){const r=iv(t,!0,e==="fixed"),n=r.top+t.clientTop,s=r.left+t.clientLeft,i=hd(t)?f0(t):sd(1),a=t.clientWidth*i.x,l=t.clientHeight*i.y,c=s*i.x,u=n*i.y;return{width:a,height:l,x:c,y:u}}function OX(t,e,r){let n;if(e==="viewport")n=PLe(t,r);else if(e==="document")n=TLe(yd(t));else if(eu(e))n=RLe(e,r);else{const s=jfe(t);n={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return jI(n)}function _fe(t,e){const r=Hm(t);return r===e||!eu(r)||i1(r)?!1:tu(r).position==="fixed"||_fe(r,e)}function OLe(t,e){const r=e.get(t);if(r)return r;let n=CN(t,[],!1).filter(l=>eu(l)&&aj(l)!=="body"),s=null;const i=tu(t).position==="fixed";let a=i?Hm(t):t;for(;eu(a)&&!i1(a);){const l=tu(a),c=YW(a);!c&&l.position==="fixed"&&(s=null),(i?!c&&!s:!c&&l.position==="static"&&!!s&&ILe.has(s.position)||PE(a)&&!c&&_fe(t,a))?n=n.filter(d=>d!==a):s=l,a=Hm(a)}return e.set(t,n),n}function MLe(t){let{element:e,boundary:r,rootBoundary:n,strategy:s}=t;const a=[...r==="clippingAncestors"?qM(e)?[]:OLe(e,this._c):[].concat(r),n],l=a[0],c=a.reduce((u,d)=>{const h=OX(e,d,s);return u.top=el(h.top,u.top),u.right=Um(h.right,u.right),u.bottom=Um(h.bottom,u.bottom),u.left=el(h.left,u.left),u},OX(e,l,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function DLe(t){const{width:e,height:r}=wfe(t);return{width:e,height:r}}function LLe(t,e,r){const n=hd(e),s=yd(e),i=r==="fixed",a=iv(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const c=sd(0);function u(){c.x=KM(s)}if(n||!n&&!i)if((aj(e)!=="body"||PE(s))&&(l=GM(e)),n){const p=iv(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?Sfe(s,l):sd(0),h=a.left+l.scrollLeft-c.x-d.x,f=a.top+l.scrollTop-c.y-d.y;return{x:h,y:f,width:a.width,height:a.height}}function u4(t){return tu(t).position==="static"}function MX(t,e){if(!hd(t)||tu(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return yd(t)===r&&(r=r.ownerDocument.body),r}function Nfe(t,e){const r=ll(t);if(qM(t))return r;if(!hd(t)){let s=Hm(t);for(;s&&!i1(s);){if(eu(s)&&!u4(s))return s;s=Hm(s)}return r}let n=MX(t,e);for(;n&&vLe(n)&&u4(n);)n=MX(n,e);return n&&i1(n)&&u4(n)&&!YW(n)?r:n||_Le(t)||r}const $Le=async function(t){const e=this.getOffsetParent||Nfe,r=this.getDimensions,n=await r(t.floating);return{reference:LLe(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function FLe(t){return tu(t).direction==="rtl"}const BLe={convertOffsetParentRelativeRectToViewportRelativeRect:ELe,getDocumentElement:yd,getClippingRect:MLe,getOffsetParent:Nfe,getElementRects:$Le,getClientRects:ALe,getDimensions:DLe,getScale:f0,isElement:eu,isRTL:FLe};function kfe(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function zLe(t,e){let r=null,n;const s=yd(t);function i(){var l;clearTimeout(n),(l=r)==null||l.disconnect(),r=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const u=t.getBoundingClientRect(),{left:d,top:h,width:f,height:p}=u;if(l||e(),!f||!p)return;const m=QA(h),g=QA(s.clientWidth-(d+f)),y=QA(s.clientHeight-(h+p)),x=QA(d),b={rootMargin:-m+"px "+-g+"px "+-y+"px "+-x+"px",threshold:el(0,Um(1,c))||1};let w=!0;function j(N){const C=N[0].intersectionRatio;if(C!==c){if(!w)return a();C?a(!1,C):n=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!kfe(u,t.getBoundingClientRect())&&a(),w=!1}try{r=new IntersectionObserver(j,{...b,root:s.ownerDocument})}catch{r=new IntersectionObserver(j,b)}r.observe(t)}return a(!0),i}function ULe(t,e,r,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,u=QW(t),d=s||i?[...u?CN(u):[],...CN(e)]:[];d.forEach(x=>{s&&x.addEventListener("scroll",r,{passive:!0}),i&&x.addEventListener("resize",r)});const h=u&&l?zLe(u,r):null;let f=-1,p=null;a&&(p=new ResizeObserver(x=>{let[v]=x;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?iv(t):null;c&&y();function y(){const x=iv(t);g&&!kfe(g,x)&&r(),g=x,m=requestAnimationFrame(y)}return r(),()=>{var x;d.forEach(v=>{s&&v.removeEventListener("scroll",r),i&&v.removeEventListener("resize",r)}),h==null||h(),(x=p)==null||x.disconnect(),p=null,c&&cancelAnimationFrame(m)}}const HLe=fLe,WLe=pLe,VLe=uLe,qLe=gLe,GLe=dLe,DX=cLe,KLe=mLe,YLe=(t,e,r)=>{const n=new Map,s={platform:BLe,...r},i={...s.platform,_c:n};return lLe(t,e,{...s,platform:i})};var XLe=typeof document<"u",QLe=function(){},q2=XLe?S.useLayoutEffect:QLe;function SI(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(!SI(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)&&!SI(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function Cfe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function LX(t,e){const r=Cfe(t);return Math.round(e*r)/r}function d4(t){const e=S.useRef(t);return q2(()=>{e.current=t}),e}function ZLe(t){t===void 0&&(t={});const{placement:e="bottom",strategy:r="absolute",middleware:n=[],platform:s,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=t,[d,h]=S.useState({x:0,y:0,strategy:r,placement:e,middlewareData:{},isPositioned:!1}),[f,p]=S.useState(n);SI(f,n)||p(n);const[m,g]=S.useState(null),[y,x]=S.useState(null),v=S.useCallback(ee=>{ee!==N.current&&(N.current=ee,g(ee))},[]),b=S.useCallback(ee=>{ee!==C.current&&(C.current=ee,x(ee))},[]),w=i||m,j=a||y,N=S.useRef(null),C=S.useRef(null),A=S.useRef(d),E=c!=null,O=d4(c),$=d4(s),T=d4(u),M=S.useCallback(()=>{if(!N.current||!C.current)return;const ee={placement:e,strategy:r,middleware:f};$.current&&(ee.platform=$.current),YLe(N.current,C.current,ee).then(V=>{const B={...V,isPositioned:T.current!==!1};k.current&&!SI(A.current,B)&&(A.current=B,cc.flushSync(()=>{h(B)}))})},[f,e,r,$,T]);q2(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,h(ee=>({...ee,isPositioned:!1})))},[u]);const k=S.useRef(!1);q2(()=>(k.current=!0,()=>{k.current=!1}),[]),q2(()=>{if(w&&(N.current=w),j&&(C.current=j),w&&j){if(O.current)return O.current(w,j,M);M()}},[w,j,M,O,E]);const D=S.useMemo(()=>({reference:N,floating:C,setReference:v,setFloating:b}),[v,b]),K=S.useMemo(()=>({reference:w,floating:j}),[w,j]),H=S.useMemo(()=>{const ee={position:r,left:0,top:0};if(!K.floating)return ee;const V=LX(K.floating,d.x),B=LX(K.floating,d.y);return l?{...ee,transform:"translate("+V+"px, "+B+"px)",...Cfe(K.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:V,top:B}},[r,l,K.floating,d.x,d.y]);return S.useMemo(()=>({...d,update:M,refs:D,elements:K,floatingStyles:H}),[d,M,D,K,H])}const JLe=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?DX({element:n.current,padding:s}).fn(r):{}:n?DX({element:n,padding:s}).fn(r):{}}}},e5e=(t,e)=>({...HLe(t),options:[t,e]}),t5e=(t,e)=>({...WLe(t),options:[t,e]}),r5e=(t,e)=>({...KLe(t),options:[t,e]}),n5e=(t,e)=>({...VLe(t),options:[t,e]}),s5e=(t,e)=>({...qLe(t),options:[t,e]}),i5e=(t,e)=>({...GLe(t),options:[t,e]}),a5e=(t,e)=>({...JLe(t),options:[t,e]});var o5e="Arrow",Efe=S.forwardRef((t,e)=>{const{children:r,width:n=10,height:s=5,...i}=t;return o.jsx(ft.svg,{...i,ref:e,width:n,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});Efe.displayName=o5e;var l5e=Efe;function ZW(t){const[e,r]=S.useState(void 0);return bs(()=>{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,l;if("borderBoxSize"in i){const c=i.borderBoxSize,u=Array.isArray(c)?c[0]:c;a=u.inlineSize,l=u.blockSize}else a=t.offsetWidth,l=t.offsetHeight;r({width:a,height:l})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),e}var JW="Popper",[Afe,ig]=Vs(JW),[c5e,Tfe]=Afe(JW),Pfe=t=>{const{__scopePopper:e,children:r}=t,[n,s]=S.useState(null);return o.jsx(c5e,{scope:e,anchor:n,onAnchorChange:s,children:r})};Pfe.displayName=JW;var Ife="PopperAnchor",Rfe=S.forwardRef((t,e)=>{const{__scopePopper:r,virtualRef:n,...s}=t,i=Tfe(Ife,r),a=S.useRef(null),l=qt(e,a);return S.useEffect(()=>{i.onAnchorChange((n==null?void 0:n.current)||a.current)}),n?null:o.jsx(ft.div,{...s,ref:l})});Rfe.displayName=Ife;var e9="PopperContent",[u5e,d5e]=Afe(e9),Ofe=S.forwardRef((t,e)=>{var q,L,Z,J,W,X;const{__scopePopper:r,side:n="bottom",sideOffset:s=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:m,...g}=t,y=Tfe(e9,r),[x,v]=S.useState(null),b=qt(e,he=>v(he)),[w,j]=S.useState(null),N=ZW(w),C=(N==null?void 0:N.width)??0,A=(N==null?void 0:N.height)??0,E=n+(i!=="center"?"-"+i:""),O=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},$=Array.isArray(u)?u:[u],T=$.length>0,M={padding:O,boundary:$.filter(f5e),altBoundary:T},{refs:k,floatingStyles:D,placement:K,isPositioned:H,middlewareData:ee}=ZLe({strategy:"fixed",placement:E,whileElementsMounted:(...he)=>ULe(...he,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[e5e({mainAxis:s+A,alignmentAxis:a}),c&&t5e({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?r5e():void 0,...M}),c&&n5e({...M}),s5e({...M,apply:({elements:he,rects:P,availableWidth:oe,availableHeight:Y})=>{const{width:R,height:I}=P.reference,U=he.floating.style;U.setProperty("--radix-popper-available-width",`${oe}px`),U.setProperty("--radix-popper-available-height",`${Y}px`),U.setProperty("--radix-popper-anchor-width",`${R}px`),U.setProperty("--radix-popper-anchor-height",`${I}px`)}}),w&&a5e({element:w,padding:l}),p5e({arrowWidth:C,arrowHeight:A}),f&&i5e({strategy:"referenceHidden",...M})]}),[V,B]=Lfe(K),z=ys(m);bs(()=>{H&&(z==null||z())},[H,z]);const F=(q=ee.arrow)==null?void 0:q.x,G=(L=ee.arrow)==null?void 0:L.y,Q=((Z=ee.arrow)==null?void 0:Z.centerOffset)!==0,[ie,se]=S.useState();return bs(()=>{x&&se(window.getComputedStyle(x).zIndex)},[x]),o.jsx("div",{ref:k.setFloating,"data-radix-popper-content-wrapper":"",style:{...D,transform:H?D.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ie,"--radix-popper-transform-origin":[(J=ee.transformOrigin)==null?void 0:J.x,(W=ee.transformOrigin)==null?void 0:W.y].join(" "),...((X=ee.hide)==null?void 0:X.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:o.jsx(u5e,{scope:r,placedSide:V,onArrowChange:j,arrowX:F,arrowY:G,shouldHideArrow:Q,children:o.jsx(ft.div,{"data-side":V,"data-align":B,...g,ref:b,style:{...g.style,animation:H?void 0:"none"}})})})});Ofe.displayName=e9;var Mfe="PopperArrow",h5e={top:"bottom",right:"left",bottom:"top",left:"right"},Dfe=S.forwardRef(function(e,r){const{__scopePopper:n,...s}=e,i=d5e(Mfe,n),a=h5e[i.placedSide];return o.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:o.jsx(l5e,{...s,ref:r,style:{...s.style,display:"block"}})})});Dfe.displayName=Mfe;function f5e(t){return t!==null}var p5e=t=>({name:"transformOrigin",options:t,fn(e){var y,x,v;const{placement:r,rects:n,middlewareData:s}=e,a=((y=s.arrow)==null?void 0:y.centerOffset)!==0,l=a?0:t.arrowWidth,c=a?0:t.arrowHeight,[u,d]=Lfe(r),h={start:"0%",center:"50%",end:"100%"}[d],f=(((x=s.arrow)==null?void 0:x.x)??0)+l/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 Lfe(t){const[e,r="center"]=t.split("-");return[e,r]}var YM=Pfe,IE=Rfe,XM=Ofe,QM=Dfe,[ZM,sWt]=Vs("Tooltip",[ig]),JM=ig(),$fe="TooltipProvider",m5e=700,DB="tooltip.open",[g5e,t9]=ZM($fe),Ffe=t=>{const{__scopeTooltip:e,delayDuration:r=m5e,skipDelayDuration:n=300,disableHoverableContent:s=!1,children:i}=t,a=S.useRef(!0),l=S.useRef(!1),c=S.useRef(0);return S.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),o.jsx(g5e,{scope:e,isOpenDelayedRef:a,delayDuration:r,onOpen:S.useCallback(()=>{window.clearTimeout(c.current),a.current=!1},[]),onClose:S.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,n)},[n]),isPointerInTransitRef:l,onPointerInTransitChange:S.useCallback(u=>{l.current=u},[]),disableHoverableContent:s,children:i})};Ffe.displayName=$fe;var EN="Tooltip",[x5e,eD]=ZM(EN),Bfe=t=>{const{__scopeTooltip:e,children:r,open:n,defaultOpen:s,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=t,c=t9(EN,t.__scopeTooltip),u=JM(e),[d,h]=S.useState(null),f=Co(),p=S.useRef(0),m=a??c.disableHoverableContent,g=l??c.delayDuration,y=S.useRef(!1),[x,v]=ca({prop:n,defaultProp:s??!1,onChange:C=>{C?(c.onOpen(),document.dispatchEvent(new CustomEvent(DB))):c.onClose(),i==null||i(C)},caller:EN}),b=S.useMemo(()=>x?y.current?"delayed-open":"instant-open":"closed",[x]),w=S.useCallback(()=>{window.clearTimeout(p.current),p.current=0,y.current=!1,v(!0)},[v]),j=S.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),N=S.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{y.current=!0,v(!0),p.current=0},g)},[g,v]);return S.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),o.jsx(YM,{...u,children:o.jsx(x5e,{scope:e,contentId:f,open:x,stateAttribute:b,trigger:d,onTriggerChange:h,onTriggerEnter:S.useCallback(()=>{c.isOpenDelayedRef.current?N():w()},[c.isOpenDelayedRef,N,w]),onTriggerLeave:S.useCallback(()=>{m?j():(window.clearTimeout(p.current),p.current=0)},[j,m]),onOpen:w,onClose:j,disableHoverableContent:m,children:r})})};Bfe.displayName=EN;var LB="TooltipTrigger",zfe=S.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=eD(LB,r),i=t9(LB,r),a=JM(r),l=S.useRef(null),c=qt(e,l,s.onTriggerChange),u=S.useRef(!1),d=S.useRef(!1),h=S.useCallback(()=>u.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),o.jsx(IE,{asChild:!0,...a,children:o.jsx(ft.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:c,onPointerMove:Qe(t.onPointerMove,f=>{f.pointerType!=="touch"&&!d.current&&!i.isPointerInTransitRef.current&&(s.onTriggerEnter(),d.current=!0)}),onPointerLeave:Qe(t.onPointerLeave,()=>{s.onTriggerLeave(),d.current=!1}),onPointerDown:Qe(t.onPointerDown,()=>{s.open&&s.onClose(),u.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Qe(t.onFocus,()=>{u.current||s.onOpen()}),onBlur:Qe(t.onBlur,s.onClose),onClick:Qe(t.onClick,s.onClose)})})});zfe.displayName=LB;var y5e="TooltipPortal",[iWt,v5e]=ZM(y5e,{forceMount:void 0}),a1="TooltipContent",Ufe=S.forwardRef((t,e)=>{const r=v5e(a1,t.__scopeTooltip),{forceMount:n=r.forceMount,side:s="top",...i}=t,a=eD(a1,t.__scopeTooltip);return o.jsx(pi,{present:n||a.open,children:a.disableHoverableContent?o.jsx(Hfe,{side:s,...i,ref:e}):o.jsx(b5e,{side:s,...i,ref:e})})}),b5e=S.forwardRef((t,e)=>{const r=eD(a1,t.__scopeTooltip),n=t9(a1,t.__scopeTooltip),s=S.useRef(null),i=qt(e,s),[a,l]=S.useState(null),{trigger:c,onClose:u}=r,d=s.current,{onPointerInTransitChange:h}=n,f=S.useCallback(()=>{l(null),h(!1)},[h]),p=S.useCallback((m,g)=>{const y=m.currentTarget,x={x:m.clientX,y:m.clientY},v=N5e(x,y.getBoundingClientRect()),b=k5e(x,v),w=C5e(g.getBoundingClientRect()),j=A5e([...b,...w]);l(j),h(!0)},[h]);return S.useEffect(()=>()=>f(),[f]),S.useEffect(()=>{if(c&&d){const m=y=>p(y,d),g=y=>p(y,c);return c.addEventListener("pointerleave",m),d.addEventListener("pointerleave",g),()=>{c.removeEventListener("pointerleave",m),d.removeEventListener("pointerleave",g)}}},[c,d,p,f]),S.useEffect(()=>{if(a){const m=g=>{const y=g.target,x={x:g.clientX,y:g.clientY},v=(c==null?void 0:c.contains(y))||(d==null?void 0:d.contains(y)),b=!E5e(x,a);v?f():b&&(f(),u())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[c,d,a,u,f]),o.jsx(Hfe,{...t,ref:i})}),[w5e,j5e]=ZM(EN,{isInside:!1}),S5e=whe("TooltipContent"),Hfe=S.forwardRef((t,e)=>{const{__scopeTooltip:r,children:n,"aria-label":s,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=t,c=eD(a1,r),u=JM(r),{onClose:d}=c;return S.useEffect(()=>(document.addEventListener(DB,d),()=>document.removeEventListener(DB,d)),[d]),S.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]),o.jsx(Ev,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:h=>h.preventDefault(),onDismiss:d,children:o.jsxs(XM,{"data-state":c.stateAttribute,...u,...l,ref:e,style:{...l.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:[o.jsx(S5e,{children:n}),o.jsx(w5e,{scope:r,isInside:!0,children:o.jsx(hOe,{id:c.contentId,role:"tooltip",children:s||n})})]})})});Ufe.displayName=a1;var Wfe="TooltipArrow",_5e=S.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=JM(r);return j5e(Wfe,r).isInside?null:o.jsx(QM,{...s,...n,ref:e})});_5e.displayName=Wfe;function N5e(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 k5e(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 C5e(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 E5e(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 l=e[i],c=e[a],u=l.x,d=l.y,h=c.x,f=c.y;d>n!=f>n&&r<(h-u)*(n-d)/(f-d)+u&&(s=!s)}return s}function A5e(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),T5e(e)}function T5e(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 P5e=Ffe,I5e=Bfe,R5e=zfe,Vfe=Ufe;const ri=P5e,br=I5e,wr=R5e,xr=S.forwardRef(({className:t,sideOffset:e=4,...r},n)=>o.jsx(Vfe,{ref:n,sideOffset:e,className:Pe("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}));xr.displayName=Vfe.displayName;var oj=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(){}},av=typeof window>"u"||"Deno"in globalThis;function Wa(){}function O5e(t,e){return typeof t=="function"?t(e):t}function $B(t){return typeof t=="number"&&t>=0&&t!==1/0}function qfe(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Cm(t,e){return typeof t=="function"?t(e):t}function Fl(t,e){return typeof t=="function"?t(e):t}function $X(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:i,queryKey:a,stale:l}=t;if(a){if(n){if(e.queryHash!==r9(a,e.options))return!1}else if(!AN(e.queryKey,a))return!1}if(r!=="all"){const c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||s&&s!==e.state.fetchStatus||i&&!i(e))}function FX(t,e){const{exact:r,status:n,predicate:s,mutationKey:i}=t;if(i){if(!e.options.mutationKey)return!1;if(r){if(ov(e.options.mutationKey)!==ov(i))return!1}else if(!AN(e.options.mutationKey,i))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function r9(t,e){return((e==null?void 0:e.queryKeyHashFn)||ov)(t)}function ov(t){return JSON.stringify(t,(e,r)=>FB(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function AN(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>AN(t[r],e[r])):!1}function Gfe(t,e){if(t===e)return t;const r=BX(t)&&BX(e);if(r||FB(t)&&FB(e)){const n=r?t:Object.keys(t),s=n.length,i=r?e:Object.keys(e),a=i.length,l=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?(l[h]=void 0,u++):(l[h]=Gfe(t[h],e[h]),l[h]===t[h]&&t[h]!==void 0&&u++)}return s===a&&u===s?t:l}return e}function _I(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 BX(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function FB(t){if(!zX(t))return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(!zX(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function zX(t){return Object.prototype.toString.call(t)==="[object Object]"}function M5e(t){return new Promise(e=>{setTimeout(e,t)})}function BB(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Gfe(t,e):e}function D5e(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function L5e(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var n9=Symbol();function Kfe(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===n9?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Yfe(t,e){return typeof t=="function"?t(...e):!!t}var Sx,gp,A0,Bce,$5e=(Bce=class extends oj{constructor(){super();le(this,Sx);le(this,gp);le(this,A0);te(this,A0,e=>{if(!av&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){_(this,gp)||this.setEventListener(_(this,A0))}onUnsubscribe(){var e;this.hasListeners()||((e=_(this,gp))==null||e.call(this),te(this,gp,void 0))}setEventListener(e){var r;te(this,A0,e),(r=_(this,gp))==null||r.call(this),te(this,gp,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){_(this,Sx)!==e&&(te(this,Sx,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof _(this,Sx)=="boolean"?_(this,Sx):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},Sx=new WeakMap,gp=new WeakMap,A0=new WeakMap,Bce),s9=new $5e,T0,xp,P0,zce,F5e=(zce=class extends oj{constructor(){super();le(this,T0,!0);le(this,xp);le(this,P0);te(this,P0,e=>{if(!av&&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,xp)||this.setEventListener(_(this,P0))}onUnsubscribe(){var e;this.hasListeners()||((e=_(this,xp))==null||e.call(this),te(this,xp,void 0))}setEventListener(e){var r;te(this,P0,e),(r=_(this,xp))==null||r.call(this),te(this,xp,e(this.setOnline.bind(this)))}setOnline(e){_(this,T0)!==e&&(te(this,T0,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return _(this,T0)}},T0=new WeakMap,xp=new WeakMap,P0=new WeakMap,zce),NI=new F5e;function zB(){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 B5e(t){return Math.min(1e3*2**t,3e4)}function Xfe(t){return(t??"online")==="online"?NI.isOnline():!0}var Qfe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function h4(t){return t instanceof Qfe}function Zfe(t){let e=!1,r=0,n=!1,s;const i=zB(),a=g=>{var y;n||(f(new Qfe(g)),(y=t.abort)==null||y.call(t))},l=()=>{e=!0},c=()=>{e=!1},u=()=>s9.isFocused()&&(t.networkMode==="always"||NI.isOnline())&&t.canRun(),d=()=>Xfe(t.networkMode)&&t.canRun(),h=g=>{var y;n||(n=!0,(y=t.onSuccess)==null||y.call(t,g),s==null||s(),i.resolve(g))},f=g=>{var y;n||(n=!0,(y=t.onError)==null||y.call(t,g),s==null||s(),i.reject(g))},p=()=>new Promise(g=>{var y;s=x=>{(n||u())&&g(x)},(y=t.onPause)==null||y.call(t)}).then(()=>{var g;s=void 0,n||(g=t.onContinue)==null||g.call(t)}),m=()=>{if(n)return;let g;const y=r===0?t.initialPromise:void 0;try{g=y??t.fn()}catch(x){g=Promise.reject(x)}Promise.resolve(g).then(h).catch(x=>{var N;if(n)return;const v=t.retry??(av?0:3),b=t.retryDelay??B5e,w=typeof b=="function"?b(r,x):b,j=v===!0||typeof v=="number"&&r<v||typeof v=="function"&&v(r,x);if(e||!j){f(x);return}r++,(N=t.onFail)==null||N.call(t,r,x),M5e(w).then(()=>u()?void 0:p()).then(()=>{e?f(x):m()})})};return{promise:i,cancel:a,continue:()=>(s==null||s(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?m():p().then(m),i)}}var z5e=t=>setTimeout(t,0);function U5e(){let t=[],e=0,r=l=>{l()},n=l=>{l()},s=z5e;const i=l=>{e?t.push(l):s(()=>{r(l)})},a=()=>{const l=t;t=[],l.length&&s(()=>{n(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;e++;try{c=l()}finally{e--,e||a()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{n=l},setScheduler:l=>{s=l}}}var ei=U5e(),_x,Uce,Jfe=(Uce=class{constructor(){le(this,_x)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),$B(this.gcTime)&&te(this,_x,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(av?1/0:5*60*1e3))}clearGcTimeout(){_(this,_x)&&(clearTimeout(_(this,_x)),te(this,_x,void 0))}},_x=new WeakMap,Uce),I0,Nx,Al,kx,ga,Hk,Cx,Nc,$d,Hce,H5e=(Hce=class extends Jfe{constructor(e){super();le(this,Nc);le(this,I0);le(this,Nx);le(this,Al);le(this,kx);le(this,ga);le(this,Hk);le(this,Cx);te(this,Cx,!1),te(this,Hk,e.defaultOptions),this.setOptions(e.options),this.observers=[],te(this,kx,e.client),te(this,Al,_(this,kx).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,te(this,I0,W5e(this.options)),this.state=e.state??_(this,I0),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=_(this,ga))==null?void 0:e.promise}setOptions(e){this.options={..._(this,Hk),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&_(this,Al).remove(this)}setData(e,r){const n=BB(this.state.data,e,this.options);return de(this,Nc,$d).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){de(this,Nc,$d).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=_(this,ga))==null?void 0:n.promise;return(s=_(this,ga))==null||s.cancel(e),r?r.then(Wa).catch(Wa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(_(this,I0))}isActive(){return this.observers.some(e=>Fl(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===n9||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Cm(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:!qfe(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=_(this,ga))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=_(this,ga))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),_(this,Al).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,ga)&&(_(this,Cx)?_(this,ga).cancel({revert:!0}):_(this,ga).cancelRetry()),this.scheduleGc()),_(this,Al).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||de(this,Nc,$d).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,ga))return _(this,ga).continueRetry(),_(this,ga).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,Cx,!0),n.signal)})},i=()=>{const f=Kfe(this.options,r),m=(()=>{const g={client:_(this,kx),queryKey:this.queryKey,meta:this.meta};return s(g),g})();return te(this,Cx,!1),this.options.persister?this.options.persister(f,m,this):f(m)},l=(()=>{const f={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:_(this,kx),state:this.state,fetchFn:i};return s(f),f})();(u=this.options.behavior)==null||u.onFetch(l,this),te(this,Nx,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&de(this,Nc,$d).call(this,{type:"fetch",meta:(h=l.fetchOptions)==null?void 0:h.meta});const c=f=>{var p,m,g,y;h4(f)&&f.silent||de(this,Nc,$d).call(this,{type:"error",error:f}),h4(f)||((m=(p=_(this,Al).config).onError)==null||m.call(p,f,this),(y=(g=_(this,Al).config).onSettled)==null||y.call(g,this.state.data,f,this)),this.scheduleGc()};return te(this,ga,Zfe({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,abort:n.abort.bind(n),onSuccess:f=>{var p,m,g,y;if(f===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(x){c(x);return}(m=(p=_(this,Al).config).onSuccess)==null||m.call(p,f,this),(y=(g=_(this,Al).config).onSettled)==null||y.call(g,f,this.state.error,this),this.scheduleGc()},onError:c,onFail:(f,p)=>{de(this,Nc,$d).call(this,{type:"failed",failureCount:f,error:p})},onPause:()=>{de(this,Nc,$d).call(this,{type:"pause"})},onContinue:()=>{de(this,Nc,$d).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0})),_(this,ga).start()}},I0=new WeakMap,Nx=new WeakMap,Al=new WeakMap,kx=new WeakMap,ga=new WeakMap,Hk=new WeakMap,Cx=new WeakMap,Nc=new WeakSet,$d=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,...epe(n.data,this.options),fetchMeta:e.meta??null};case"success":return te(this,Nx,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 h4(s)&&s.revert&&_(this,Nx)?{..._(this,Nx),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),ei.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),_(this,Al).notify({query:this,type:"updated",action:e})})},Hce);function epe(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Xfe(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function W5e(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 Cu,Wce,V5e=(Wce=class extends oj{constructor(e={}){super();le(this,Cu);this.config=e,te(this,Cu,new Map)}build(e,r,n){const s=r.queryKey,i=r.queryHash??r9(s,r);let a=this.get(i);return a||(a=new H5e({client:e,queryKey:s,queryHash:i,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(a)),a}add(e){_(this,Cu).has(e.queryHash)||(_(this,Cu).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=_(this,Cu).get(e.queryHash);r&&(e.destroy(),r===e&&_(this,Cu).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ei.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return _(this,Cu).get(e)}getAll(){return[..._(this,Cu).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>$X(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>$X(e,n)):r}notify(e){ei.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){ei.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ei.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Cu=new WeakMap,Wce),Eu,Ma,Ex,Au,Zf,Vce,q5e=(Vce=class extends Jfe{constructor(e){super();le(this,Au);le(this,Eu);le(this,Ma);le(this,Ex);this.mutationId=e.mutationId,te(this,Ma,e.mutationCache),te(this,Eu,[]),this.state=e.state||tpe(),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,Eu).includes(e)||(_(this,Eu).push(e),this.clearGcTimeout(),_(this,Ma).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){te(this,Eu,_(this,Eu).filter(r=>r!==e)),this.scheduleGc(),_(this,Ma).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){_(this,Eu).length||(this.state.status==="pending"?this.scheduleGc():_(this,Ma).remove(this))}continue(){var e;return((e=_(this,Ex))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var i,a,l,c,u,d,h,f,p,m,g,y,x,v,b,w,j,N,C,A;const r=()=>{de(this,Au,Zf).call(this,{type:"continue"})};te(this,Ex,Zfe({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(E,O)=>{de(this,Au,Zf).call(this,{type:"failed",failureCount:E,error:O})},onPause:()=>{de(this,Au,Zf).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>_(this,Ma).canRun(this)}));const n=this.state.status==="pending",s=!_(this,Ex).canStart();try{if(n)r();else{de(this,Au,Zf).call(this,{type:"pending",variables:e,isPaused:s}),await((a=(i=_(this,Ma).config).onMutate)==null?void 0:a.call(i,e,this));const O=await((c=(l=this.options).onMutate)==null?void 0:c.call(l,e));O!==this.state.context&&de(this,Au,Zf).call(this,{type:"pending",context:O,variables:e,isPaused:s})}const E=await _(this,Ex).start();return await((d=(u=_(this,Ma).config).onSuccess)==null?void 0:d.call(u,E,e,this.state.context,this)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,E,e,this.state.context)),await((m=(p=_(this,Ma).config).onSettled)==null?void 0:m.call(p,E,null,this.state.variables,this.state.context,this)),await((y=(g=this.options).onSettled)==null?void 0:y.call(g,E,null,e,this.state.context)),de(this,Au,Zf).call(this,{type:"success",data:E}),E}catch(E){try{throw await((v=(x=_(this,Ma).config).onError)==null?void 0:v.call(x,E,e,this.state.context,this)),await((w=(b=this.options).onError)==null?void 0:w.call(b,E,e,this.state.context)),await((N=(j=_(this,Ma).config).onSettled)==null?void 0:N.call(j,void 0,E,this.state.variables,this.state.context,this)),await((A=(C=this.options).onSettled)==null?void 0:A.call(C,void 0,E,e,this.state.context)),E}finally{de(this,Au,Zf).call(this,{type:"error",error:E})}}finally{_(this,Ma).runNext(this)}}},Eu=new WeakMap,Ma=new WeakMap,Ex=new WeakMap,Au=new WeakSet,Zf=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),ei.batch(()=>{_(this,Eu).forEach(n=>{n.onMutationUpdate(e)}),_(this,Ma).notify({mutation:this,type:"updated",action:e})})},Vce);function tpe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var eh,kc,Wk,qce,G5e=(qce=class extends oj{constructor(e={}){super();le(this,eh);le(this,kc);le(this,Wk);this.config=e,te(this,eh,new Set),te(this,kc,new Map),te(this,Wk,0)}build(e,r,n){const s=new q5e({mutationCache:this,mutationId:++xi(this,Wk)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){_(this,eh).add(e);const r=ZA(e);if(typeof r=="string"){const n=_(this,kc).get(r);n?n.push(e):_(this,kc).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(_(this,eh).delete(e)){const r=ZA(e);if(typeof r=="string"){const n=_(this,kc).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&_(this,kc).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=ZA(e);if(typeof r=="string"){const n=_(this,kc).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=ZA(e);if(typeof r=="string"){const s=(n=_(this,kc).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(){ei.batch(()=>{_(this,eh).forEach(e=>{this.notify({type:"removed",mutation:e})}),_(this,eh).clear(),_(this,kc).clear()})}getAll(){return Array.from(_(this,eh))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>FX(r,n))}findAll(e={}){return this.getAll().filter(r=>FX(e,r))}notify(e){ei.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return ei.batch(()=>Promise.all(e.map(r=>r.continue().catch(Wa))))}},eh=new WeakMap,kc=new WeakMap,Wk=new WeakMap,qce);function ZA(t){var e;return(e=t.options.scope)==null?void 0:e.id}function UX(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 l={pages:[],pageParams:[]},c=0;const u=async()=>{let g=!1;const y=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?g=!0:e.signal.addEventListener("abort",()=>{g=!0}),e.signal)})},x=Kfe(e.options,e.fetchOptions),v=async(b,w,j)=>{if(g)return Promise.reject();if(w==null&&b.pages.length)return Promise.resolve(b);const C=(()=>{const $={client:e.client,queryKey:e.queryKey,pageParam:w,direction:j?"backward":"forward",meta:e.options.meta};return y($),$})(),A=await x(C),{maxPages:E}=e.options,O=j?L5e:D5e;return{pages:O(b.pages,A,E),pageParams:O(b.pageParams,w,E)}};if(s&&i.length){const b=s==="backward",w=b?K5e:HX,j={pages:i,pageParams:a},N=w(n,j);l=await v(j,N,b)}else{const b=t??i.length;do{const w=c===0?a[0]??n.initialPageParam:HX(n,l);if(c>0&&w==null)break;l=await v(l,w),c++}while(c<b)}return l};e.options.persister?e.fetchFn=()=>{var g,y;return(y=(g=e.options).persister)==null?void 0:y.call(g,u,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=u}}}function HX(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 K5e(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 ds,yp,vp,R0,O0,bp,M0,D0,Gce,Y5e=(Gce=class{constructor(t={}){le(this,ds);le(this,yp);le(this,vp);le(this,R0);le(this,O0);le(this,bp);le(this,M0);le(this,D0);te(this,ds,t.queryCache||new V5e),te(this,yp,t.mutationCache||new G5e),te(this,vp,t.defaultOptions||{}),te(this,R0,new Map),te(this,O0,new Map),te(this,bp,0)}mount(){xi(this,bp)._++,_(this,bp)===1&&(te(this,M0,s9.subscribe(async t=>{t&&(await this.resumePausedMutations(),_(this,ds).onFocus())})),te(this,D0,NI.subscribe(async t=>{t&&(await this.resumePausedMutations(),_(this,ds).onOnline())})))}unmount(){var t,e;xi(this,bp)._--,_(this,bp)===0&&((t=_(this,M0))==null||t.call(this),te(this,M0,void 0),(e=_(this,D0))==null||e.call(this),te(this,D0,void 0))}isFetching(t){return _(this,ds).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return _(this,yp).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=_(this,ds).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=_(this,ds).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Cm(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return _(this,ds).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,ds).get(n.queryHash),i=s==null?void 0:s.state.data,a=O5e(e,i);if(a!==void 0)return _(this,ds).build(this,n).setData(a,{...r,manual:!0})}setQueriesData(t,e,r){return ei.batch(()=>_(this,ds).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=_(this,ds).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=_(this,ds);ei.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=_(this,ds);return ei.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=ei.batch(()=>_(this,ds).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(Wa).catch(Wa)}invalidateQueries(t,e={}){return ei.batch(()=>(_(this,ds).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=ei.batch(()=>_(this,ds).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,r);return r.throwOnError||(i=i.catch(Wa)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(n).then(Wa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=_(this,ds).build(this,e);return r.isStaleByTime(Cm(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Wa).catch(Wa)}fetchInfiniteQuery(t){return t.behavior=UX(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Wa).catch(Wa)}ensureInfiniteQueryData(t){return t.behavior=UX(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return NI.isOnline()?_(this,yp).resumePausedMutations():Promise.resolve()}getQueryCache(){return _(this,ds)}getMutationCache(){return _(this,yp)}getDefaultOptions(){return _(this,vp)}setDefaultOptions(t){te(this,vp,t)}setQueryDefaults(t,e){_(this,R0).set(ov(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[..._(this,R0).values()],r={};return e.forEach(n=>{AN(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){_(this,O0).set(ov(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[..._(this,O0).values()],r={};return e.forEach(n=>{AN(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={..._(this,vp).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=r9(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===n9&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{..._(this,vp).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){_(this,ds).clear(),_(this,yp).clear()}},ds=new WeakMap,yp=new WeakMap,vp=new WeakMap,R0=new WeakMap,O0=new WeakMap,bp=new WeakMap,M0=new WeakMap,D0=new WeakMap,Gce),ao,Pr,Vk,Da,Ax,L0,wp,jp,qk,$0,F0,Tx,Px,Sp,B0,Qr,LS,UB,HB,WB,VB,qB,GB,KB,rpe,Kce,X5e=(Kce=class extends oj{constructor(e,r){super();le(this,Qr);le(this,ao);le(this,Pr);le(this,Vk);le(this,Da);le(this,Ax);le(this,L0);le(this,wp);le(this,jp);le(this,qk);le(this,$0);le(this,F0);le(this,Tx);le(this,Px);le(this,Sp);le(this,B0,new Set);this.options=r,te(this,ao,e),te(this,jp,null),te(this,wp,zB()),this.options.experimental_prefetchInRender||_(this,wp).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,Pr).addObserver(this),WX(_(this,Pr),this.options)?de(this,Qr,LS).call(this):this.updateResult(),de(this,Qr,VB).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return YB(_(this,Pr),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return YB(_(this,Pr),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,de(this,Qr,qB).call(this),de(this,Qr,GB).call(this),_(this,Pr).removeObserver(this)}setOptions(e){const r=this.options,n=_(this,Pr);if(this.options=_(this,ao).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Fl(this.options.enabled,_(this,Pr))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");de(this,Qr,KB).call(this),_(this,Pr).setOptions(this.options),r._defaulted&&!_I(this.options,r)&&_(this,ao).getQueryCache().notify({type:"observerOptionsUpdated",query:_(this,Pr),observer:this});const s=this.hasListeners();s&&VX(_(this,Pr),n,this.options,r)&&de(this,Qr,LS).call(this),this.updateResult(),s&&(_(this,Pr)!==n||Fl(this.options.enabled,_(this,Pr))!==Fl(r.enabled,_(this,Pr))||Cm(this.options.staleTime,_(this,Pr))!==Cm(r.staleTime,_(this,Pr)))&&de(this,Qr,UB).call(this);const i=de(this,Qr,HB).call(this);s&&(_(this,Pr)!==n||Fl(this.options.enabled,_(this,Pr))!==Fl(r.enabled,_(this,Pr))||i!==_(this,Sp))&&de(this,Qr,WB).call(this,i)}getOptimisticResult(e){const r=_(this,ao).getQueryCache().build(_(this,ao),e),n=this.createResult(r,e);return Z5e(this,n)&&(te(this,Da,n),te(this,L0,this.options),te(this,Ax,_(this,Pr).state)),n}getCurrentResult(){return _(this,Da)}trackResult(e,r){return new Proxy(e,{get:(n,s)=>(this.trackProp(s),r==null||r(s),Reflect.get(n,s))})}trackProp(e){_(this,B0).add(e)}getCurrentQuery(){return _(this,Pr)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=_(this,ao).defaultQueryOptions(e),n=_(this,ao).getQueryCache().build(_(this,ao),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return de(this,Qr,LS).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),_(this,Da)))}createResult(e,r){var E;const n=_(this,Pr),s=this.options,i=_(this,Da),a=_(this,Ax),l=_(this,L0),u=e!==n?e.state:_(this,Vk),{state:d}=e;let h={...d},f=!1,p;if(r._optimisticResults){const O=this.hasListeners(),$=!O&&WX(e,r),T=O&&VX(e,n,r,s);($||T)&&(h={...h,...epe(d.data,e.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:m,errorUpdatedAt:g,status:y}=h;p=h.data;let x=!1;if(r.placeholderData!==void 0&&p===void 0&&y==="pending"){let O;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?(O=i.data,x=!0):O=typeof r.placeholderData=="function"?r.placeholderData((E=_(this,F0))==null?void 0:E.state.data,_(this,F0)):r.placeholderData,O!==void 0&&(y="success",p=BB(i==null?void 0:i.data,O,r),f=!0)}if(r.select&&p!==void 0&&!x)if(i&&p===(a==null?void 0:a.data)&&r.select===_(this,qk))p=_(this,$0);else try{te(this,qk,r.select),p=r.select(p),p=BB(i==null?void 0:i.data,p,r),te(this,$0,p),te(this,jp,null)}catch(O){te(this,jp,O)}_(this,jp)&&(m=_(this,jp),p=_(this,$0),g=Date.now(),y="error");const v=h.fetchStatus==="fetching",b=y==="pending",w=y==="error",j=b&&v,N=p!==void 0,A={status:y,fetchStatus:h.fetchStatus,isPending:b,isSuccess:y==="success",isError:w,isInitialLoading:j,isLoading:j,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&&!N,isPaused:h.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:w&&N,isStale:i9(e,r),refetch:this.refetch,promise:_(this,wp),isEnabled:Fl(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const O=M=>{A.status==="error"?M.reject(A.error):A.data!==void 0&&M.resolve(A.data)},$=()=>{const M=te(this,wp,A.promise=zB());O(M)},T=_(this,wp);switch(T.status){case"pending":e.queryHash===n.queryHash&&O(T);break;case"fulfilled":(A.status==="error"||A.data!==T.value)&&$();break;case"rejected":(A.status!=="error"||A.error!==T.reason)&&$();break}}return A}updateResult(){const e=_(this,Da),r=this.createResult(_(this,Pr),this.options);if(te(this,Ax,_(this,Pr).state),te(this,L0,this.options),_(this,Ax).data!==void 0&&te(this,F0,_(this,Pr)),_I(r,e))return;te(this,Da,r);const n=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!_(this,B0).size)return!0;const a=new Set(i??_(this,B0));return this.options.throwOnError&&a.add("error"),Object.keys(_(this,Da)).some(l=>{const c=l;return _(this,Da)[c]!==e[c]&&a.has(c)})};de(this,Qr,rpe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&de(this,Qr,VB).call(this)}},ao=new WeakMap,Pr=new WeakMap,Vk=new WeakMap,Da=new WeakMap,Ax=new WeakMap,L0=new WeakMap,wp=new WeakMap,jp=new WeakMap,qk=new WeakMap,$0=new WeakMap,F0=new WeakMap,Tx=new WeakMap,Px=new WeakMap,Sp=new WeakMap,B0=new WeakMap,Qr=new WeakSet,LS=function(e){de(this,Qr,KB).call(this);let r=_(this,Pr).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(Wa)),r},UB=function(){de(this,Qr,qB).call(this);const e=Cm(this.options.staleTime,_(this,Pr));if(av||_(this,Da).isStale||!$B(e))return;const n=qfe(_(this,Da).dataUpdatedAt,e)+1;te(this,Tx,setTimeout(()=>{_(this,Da).isStale||this.updateResult()},n))},HB=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(_(this,Pr)):this.options.refetchInterval)??!1},WB=function(e){de(this,Qr,GB).call(this),te(this,Sp,e),!(av||Fl(this.options.enabled,_(this,Pr))===!1||!$B(_(this,Sp))||_(this,Sp)===0)&&te(this,Px,setInterval(()=>{(this.options.refetchIntervalInBackground||s9.isFocused())&&de(this,Qr,LS).call(this)},_(this,Sp)))},VB=function(){de(this,Qr,UB).call(this),de(this,Qr,WB).call(this,de(this,Qr,HB).call(this))},qB=function(){_(this,Tx)&&(clearTimeout(_(this,Tx)),te(this,Tx,void 0))},GB=function(){_(this,Px)&&(clearInterval(_(this,Px)),te(this,Px,void 0))},KB=function(){const e=_(this,ao).getQueryCache().build(_(this,ao),this.options);if(e===_(this,Pr))return;const r=_(this,Pr);te(this,Pr,e),te(this,Vk,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},rpe=function(e){ei.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(_(this,Da))}),_(this,ao).getQueryCache().notify({query:_(this,Pr),type:"observerResultsUpdated"})})},Kce);function Q5e(t,e){return Fl(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function WX(t,e){return Q5e(t,e)||t.state.data!==void 0&&YB(t,e,e.refetchOnMount)}function YB(t,e,r){if(Fl(e.enabled,t)!==!1&&Cm(e.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&i9(t,e)}return!1}function VX(t,e,r,n){return(t!==e||Fl(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&i9(t,r)}function i9(t,e){return Fl(e.enabled,t)!==!1&&t.isStaleByTime(Cm(e.staleTime,t))}function Z5e(t,e){return!_I(t.getCurrentResult(),e)}var _p,Np,oo,th,Zh,G2,XB,Yce,J5e=(Yce=class extends oj{constructor(r,n){super();le(this,Zh);le(this,_p);le(this,Np);le(this,oo);le(this,th);te(this,_p,r),this.setOptions(n),this.bindMethods(),de(this,Zh,G2).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,_p).defaultMutationOptions(r),_I(this.options,n)||_(this,_p).getMutationCache().notify({type:"observerOptionsUpdated",mutation:_(this,oo),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&ov(n.mutationKey)!==ov(this.options.mutationKey)?this.reset():((s=_(this,oo))==null?void 0:s.state.status)==="pending"&&_(this,oo).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=_(this,oo))==null||r.removeObserver(this)}onMutationUpdate(r){de(this,Zh,G2).call(this),de(this,Zh,XB).call(this,r)}getCurrentResult(){return _(this,Np)}reset(){var r;(r=_(this,oo))==null||r.removeObserver(this),te(this,oo,void 0),de(this,Zh,G2).call(this),de(this,Zh,XB).call(this)}mutate(r,n){var s;return te(this,th,n),(s=_(this,oo))==null||s.removeObserver(this),te(this,oo,_(this,_p).getMutationCache().build(_(this,_p),this.options)),_(this,oo).addObserver(this),_(this,oo).execute(r)}},_p=new WeakMap,Np=new WeakMap,oo=new WeakMap,th=new WeakMap,Zh=new WeakSet,G2=function(){var n;const r=((n=_(this,oo))==null?void 0:n.state)??tpe();te(this,Np,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},XB=function(r){ei.batch(()=>{var n,s,i,a,l,c,u,d;if(_(this,th)&&this.hasListeners()){const h=_(this,Np).variables,f=_(this,Np).context;(r==null?void 0:r.type)==="success"?((s=(n=_(this,th)).onSuccess)==null||s.call(n,r.data,h,f),(a=(i=_(this,th)).onSettled)==null||a.call(i,r.data,null,h,f)):(r==null?void 0:r.type)==="error"&&((c=(l=_(this,th)).onError)==null||c.call(l,r.error,h,f),(d=(u=_(this,th)).onSettled)==null||d.call(u,void 0,r.error,h,f))}this.listeners.forEach(h=>{h(_(this,Np))})})},Yce),npe=S.createContext(void 0),a9=t=>{const e=S.useContext(npe);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},e4e=({client:t,children:e})=>(S.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),o.jsx(npe.Provider,{value:t,children:e})),spe=S.createContext(!1),t4e=()=>S.useContext(spe);spe.Provider;function r4e(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var n4e=S.createContext(r4e()),s4e=()=>S.useContext(n4e),i4e=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},a4e=t=>{S.useEffect(()=>{t.clearReset()},[t])},o4e=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||Yfe(r,[t.error,n])),l4e=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))}},c4e=(t,e)=>t.isLoading&&t.isFetching&&!e,u4e=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,qX=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function d4e(t,e,r){var h,f,p,m,g;const n=t4e(),s=s4e(),i=a9(),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",l4e(a),i4e(a,s),a4e(s);const l=!i.getQueryCache().get(a.queryHash),[c]=S.useState(()=>new e(i,a)),u=c.getOptimisticResult(a),d=!n&&t.subscribed!==!1;if(S.useSyncExternalStore(S.useCallback(y=>{const x=d?c.subscribe(ei.batchCalls(y)):Wa;return c.updateResult(),x},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),S.useEffect(()=>{c.setOptions(a)},[a,c]),u4e(a,u))throw qX(a,c,s);if(o4e({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&&!av&&c4e(u,n)){const y=l?qX(a,c,s):(g=i.getQueryCache().get(a.queryHash))==null?void 0:g.promise;y==null||y.catch(Wa).finally(()=>{c.updateResult()})}return a.notifyOnChangeProps?u:c.trackResult(u)}function tD(t,e){return d4e(t,X5e)}function f4(t,e){const r=a9(),[n]=S.useState(()=>new J5e(r,t));S.useEffect(()=>{n.setOptions(t)},[n,t]);const s=S.useSyncExternalStore(S.useCallback(a=>n.subscribe(ei.batchCalls(a)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),i=S.useCallback((a,l)=>{n.mutate(a,l).catch(Wa)},[n]);if(s.error&&Yfe(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 TN(){return TN=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},TN.apply(this,arguments)}var gm;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(gm||(gm={}));const GX="popstate";function h4e(t){t===void 0&&(t={});function e(n,s){let{pathname:i,search:a,hash:l}=n.location;return QB("",{pathname:i,search:a,hash:l},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function r(n,s){return typeof s=="string"?s:kI(s)}return p4e(e,r,null,t)}function ns(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function ipe(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function f4e(){return Math.random().toString(36).substr(2,8)}function KX(t,e){return{usr:t.state,key:t.key,idx:e}}function QB(t,e,r,n){return r===void 0&&(r=null),TN({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?lj(e):e,{state:r,key:e&&e.key||n||f4e()})}function kI(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 lj(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 p4e(t,e,r,n){n===void 0&&(n={});let{window:s=document.defaultView,v5Compat:i=!1}=n,a=s.history,l=gm.Pop,c=null,u=d();u==null&&(u=0,a.replaceState(TN({},a.state,{idx:u}),""));function d(){return(a.state||{idx:null}).idx}function h(){l=gm.Pop;let y=d(),x=y==null?null:y-u;u=y,c&&c({action:l,location:g.location,delta:x})}function f(y,x){l=gm.Push;let v=QB(g.location,y,x);u=d()+1;let b=KX(v,u),w=g.createHref(v);try{a.pushState(b,"",w)}catch(j){if(j instanceof DOMException&&j.name==="DataCloneError")throw j;s.location.assign(w)}i&&c&&c({action:l,location:g.location,delta:1})}function p(y,x){l=gm.Replace;let v=QB(g.location,y,x);u=d();let b=KX(v,u),w=g.createHref(v);a.replaceState(b,"",w),i&&c&&c({action:l,location:g.location,delta:0})}function m(y){let x=s.location.origin!=="null"?s.location.origin:s.location.href,v=typeof y=="string"?y:kI(y);return v=v.replace(/ $/,"%20"),ns(x,"No window.location.(origin|href) available to create URL for href: "+v),new URL(v,x)}let g={get action(){return l},get location(){return t(s,a)},listen(y){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(GX,h),c=y,()=>{s.removeEventListener(GX,h),c=null}},createHref(y){return e(s,y)},createURL:m,encodeLocation(y){let x=m(y);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:f,replace:p,go(y){return a.go(y)}};return g}var YX;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(YX||(YX={}));function m4e(t,e,r){return r===void 0&&(r="/"),g4e(t,e,r,!1)}function g4e(t,e,r,n){let s=typeof e=="string"?lj(e):e,i=o1(s.pathname||"/",r);if(i==null)return null;let a=ape(t);x4e(a);let l=null;for(let c=0;l==null&&c<a.length;++c){let u=E4e(i);l=k4e(a[c],u,n)}return l}function ape(t,e,r,n){e===void 0&&(e=[]),r===void 0&&(r=[]),n===void 0&&(n="");let s=(i,a,l)=>{let c={relativePath:l===void 0?i.path||"":l,caseSensitive:i.caseSensitive===!0,childrenIndex:a,route:i};c.relativePath.startsWith("/")&&(ns(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=Em([n,c.relativePath]),d=r.concat(c);i.children&&i.children.length>0&&(ns(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),ape(i.children,e,d,u)),!(i.path==null&&!i.index)&&e.push({path:u,score:_4e(u,i.index),routesMeta:d})};return t.forEach((i,a)=>{var l;if(i.path===""||!((l=i.path)!=null&&l.includes("?")))s(i,a);else for(let c of ope(i.path))s(i,a,c)}),e}function ope(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=ope(n.join("/")),l=[];return l.push(...a.map(c=>c===""?i:[i,c].join("/"))),s&&l.push(...a),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function x4e(t){t.sort((e,r)=>e.score!==r.score?r.score-e.score:N4e(e.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const y4e=/^:[\w-]+$/,v4e=3,b4e=2,w4e=1,j4e=10,S4e=-2,XX=t=>t==="*";function _4e(t,e){let r=t.split("/"),n=r.length;return r.some(XX)&&(n+=S4e),e&&(n+=b4e),r.filter(s=>!XX(s)).reduce((s,i)=>s+(y4e.test(i)?v4e:i===""?w4e:j4e),n)}function N4e(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 k4e(t,e,r){let{routesMeta:n}=t,s={},i="/",a=[];for(let l=0;l<n.length;++l){let c=n[l],u=l===n.length-1,d=i==="/"?e:e.slice(i.length)||"/",h=CI({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),f=c.route;if(!h&&u&&r&&!n[n.length-1].route.index&&(h=CI({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(s,h.params),a.push({params:s,pathname:Em([i,h.pathname]),pathnameBase:I4e(Em([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=Em([i,h.pathnameBase]))}return a}function CI(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[r,n]=C4e(t.path,t.caseSensitive,t.end),s=e.match(r);if(!s)return null;let i=s[0],a=i.replace(/(.)\/+$/,"$1"),l=s.slice(1);return{params:n.reduce((u,d,h)=>{let{paramName:f,isOptional:p}=d;if(f==="*"){let g=l[h]||"";a=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const m=l[h];return p&&!m?u[f]=void 0:u[f]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:a,pattern:t}}function C4e(t,e,r){e===void 0&&(e=!1),r===void 0&&(r=!0),ipe(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,l,c)=>(n.push({paramName:l,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 E4e(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return ipe(!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 o1(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 A4e(t,e){e===void 0&&(e="/");let{pathname:r,search:n="",hash:s=""}=typeof t=="string"?lj(t):t;return{pathname:r?r.startsWith("/")?r:T4e(r,e):e,search:R4e(n),hash:O4e(s)}}function T4e(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 p4(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 P4e(t){return t.filter((e,r)=>r===0||e.route.path&&e.route.path.length>0)}function o9(t,e){let r=P4e(t);return e?r.map((n,s)=>s===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function l9(t,e,r,n){n===void 0&&(n=!1);let s;typeof t=="string"?s=lj(t):(s=TN({},t),ns(!s.pathname||!s.pathname.includes("?"),p4("?","pathname","search",s)),ns(!s.pathname||!s.pathname.includes("#"),p4("#","pathname","hash",s)),ns(!s.search||!s.search.includes("#"),p4("#","search","hash",s)));let i=t===""||s.pathname==="",a=i?"/":s.pathname,l;if(a==null)l=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("/")}l=h>=0?e[h]:"/"}let c=A4e(s,l),u=a&&a!=="/"&&a.endsWith("/"),d=(i||a===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Em=t=>t.join("/").replace(/\/\/+/g,"/"),I4e=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),R4e=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,O4e=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function M4e(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const lpe=["post","put","patch","delete"];new Set(lpe);const D4e=["get",...lpe];new Set(D4e);/**
 * 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 PN(){return PN=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},PN.apply(this,arguments)}const rD=S.createContext(null),cpe=S.createContext(null),Nf=S.createContext(null),nD=S.createContext(null),vd=S.createContext({outlet:null,matches:[],isDataRoute:!1}),upe=S.createContext(null);function L4e(t,e){let{relative:r}=e===void 0?{}:e;cj()||ns(!1);let{basename:n,navigator:s}=S.useContext(Nf),{hash:i,pathname:a,search:l}=sD(t,{relative:r}),c=a;return n!=="/"&&(c=a==="/"?n:Em([n,a])),s.createHref({pathname:c,search:l,hash:i})}function cj(){return S.useContext(nD)!=null}function bd(){return cj()||ns(!1),S.useContext(nD).location}function dpe(t){S.useContext(Nf).static||S.useLayoutEffect(t)}function Or(){let{isDataRoute:t}=S.useContext(vd);return t?Z4e():$4e()}function $4e(){cj()||ns(!1);let t=S.useContext(rD),{basename:e,future:r,navigator:n}=S.useContext(Nf),{matches:s}=S.useContext(vd),{pathname:i}=bd(),a=JSON.stringify(o9(s,r.v7_relativeSplatPath)),l=S.useRef(!1);return dpe(()=>{l.current=!0}),S.useCallback(function(u,d){if(d===void 0&&(d={}),!l.current)return;if(typeof u=="number"){n.go(u);return}let h=l9(u,JSON.parse(a),i,d.relative==="path");t==null&&e!=="/"&&(h.pathname=h.pathname==="/"?e:Em([e,h.pathname])),(d.replace?n.replace:n.push)(h,d.state,d)},[e,n,a,i,t])}const F4e=S.createContext(null);function B4e(t){let e=S.useContext(vd).outlet;return e&&S.createElement(F4e.Provider,{value:t},e)}function hpe(){let{matches:t}=S.useContext(vd),e=t[t.length-1];return e?e.params:{}}function sD(t,e){let{relative:r}=e===void 0?{}:e,{future:n}=S.useContext(Nf),{matches:s}=S.useContext(vd),{pathname:i}=bd(),a=JSON.stringify(o9(s,n.v7_relativeSplatPath));return S.useMemo(()=>l9(t,JSON.parse(a),i,r==="path"),[t,a,i,r])}function z4e(t,e){return U4e(t,e)}function U4e(t,e,r,n){cj()||ns(!1);let{navigator:s}=S.useContext(Nf),{matches:i}=S.useContext(vd),a=i[i.length-1],l=a?a.params:{};a&&a.pathname;let c=a?a.pathnameBase:"/";a&&a.route;let u=bd(),d;if(e){var h;let y=typeof e=="string"?lj(e):e;c==="/"||(h=y.pathname)!=null&&h.startsWith(c)||ns(!1),d=y}else d=u;let f=d.pathname||"/",p=f;if(c!=="/"){let y=c.replace(/^\//,"").split("/");p="/"+f.replace(/^\//,"").split("/").slice(y.length).join("/")}let m=m4e(t,{pathname:p}),g=G4e(m&&m.map(y=>Object.assign({},y,{params:Object.assign({},l,y.params),pathname:Em([c,s.encodeLocation?s.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?c:Em([c,s.encodeLocation?s.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),i,r,n);return e&&g?S.createElement(nD.Provider,{value:{location:PN({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:gm.Pop}},g):g}function H4e(){let t=Q4e(),e=M4e(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 S.createElement(S.Fragment,null,S.createElement("h2",null,"Unexpected Application Error!"),S.createElement("h3",{style:{fontStyle:"italic"}},e),r?S.createElement("pre",{style:s},r):null,null)}const W4e=S.createElement(H4e,null);class V4e extends S.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?S.createElement(vd.Provider,{value:this.props.routeContext},S.createElement(upe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function q4e(t){let{routeContext:e,match:r,children:n}=t,s=S.useContext(rD);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),S.createElement(vd.Provider,{value:e},n)}function G4e(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,l=(s=r)==null?void 0:s.errors;if(l!=null){let d=a.findIndex(h=>h.route.id&&(l==null?void 0:l[h.route.id])!==void 0);d>=0||ns(!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,y=null;r&&(p=l&&h.route.id?l[h.route.id]:void 0,g=h.route.errorElement||W4e,c&&(u<0&&f===0?(m=!0,y=null):u===f&&(m=!0,y=h.route.hydrateFallbackElement||null)));let x=e.concat(a.slice(0,f+1)),v=()=>{let b;return p?b=g:m?b=y:h.route.Component?b=S.createElement(h.route.Component,null):h.route.element?b=h.route.element:b=d,S.createElement(q4e,{match:h,routeContext:{outlet:d,matches:x,isDataRoute:r!=null},children:b})};return r&&(h.route.ErrorBoundary||h.route.errorElement||f===0)?S.createElement(V4e,{location:r.location,revalidation:r.revalidation,component:g,error:p,children:v(),routeContext:{outlet:null,matches:x,isDataRoute:!0}}):v()},null)}var fpe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(fpe||{}),EI=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}(EI||{});function K4e(t){let e=S.useContext(rD);return e||ns(!1),e}function Y4e(t){let e=S.useContext(cpe);return e||ns(!1),e}function X4e(t){let e=S.useContext(vd);return e||ns(!1),e}function ppe(t){let e=X4e(),r=e.matches[e.matches.length-1];return r.route.id||ns(!1),r.route.id}function Q4e(){var t;let e=S.useContext(upe),r=Y4e(EI.UseRouteError),n=ppe(EI.UseRouteError);return e!==void 0?e:(t=r.errors)==null?void 0:t[n]}function Z4e(){let{router:t}=K4e(fpe.UseNavigateStable),e=ppe(EI.UseNavigateStable),r=S.useRef(!1);return dpe(()=>{r.current=!0}),S.useCallback(function(s,i){i===void 0&&(i={}),r.current&&(typeof s=="number"?t.navigate(s):t.navigate(s,PN({fromRouteId:e},i)))},[t,e])}function J4e(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function p0(t){let{to:e,replace:r,state:n,relative:s}=t;cj()||ns(!1);let{future:i,static:a}=S.useContext(Nf),{matches:l}=S.useContext(vd),{pathname:c}=bd(),u=Or(),d=l9(e,o9(l,i.v7_relativeSplatPath),c,s==="path"),h=JSON.stringify(d);return S.useEffect(()=>u(JSON.parse(h),{replace:r,state:n,relative:s}),[u,h,s,r,n]),null}function e3e(t){return B4e(t.context)}function Wt(t){ns(!1)}function t3e(t){let{basename:e="/",children:r=null,location:n,navigationType:s=gm.Pop,navigator:i,static:a=!1,future:l}=t;cj()&&ns(!1);let c=e.replace(/^\/*/,"/"),u=S.useMemo(()=>({basename:c,navigator:i,static:a,future:PN({v7_relativeSplatPath:!1},l)}),[c,l,i,a]);typeof n=="string"&&(n=lj(n));let{pathname:d="/",search:h="",hash:f="",state:p=null,key:m="default"}=n,g=S.useMemo(()=>{let y=o1(d,c);return y==null?null:{location:{pathname:y,search:h,hash:f,state:p,key:m},navigationType:s}},[c,d,h,f,p,m,s]);return g==null?null:S.createElement(Nf.Provider,{value:u},S.createElement(nD.Provider,{children:r,value:g}))}function r3e(t){let{children:e,location:r}=t;return z4e(ZB(e),r)}new Promise(()=>{});function ZB(t,e){e===void 0&&(e=[]);let r=[];return S.Children.forEach(t,(n,s)=>{if(!S.isValidElement(n))return;let i=[...e,s];if(n.type===S.Fragment){r.push.apply(r,ZB(n.props.children,i));return}n.type!==Wt&&ns(!1),!n.props.index||!n.props.children||ns(!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=ZB(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 AI(){return AI=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},AI.apply(this,arguments)}function mpe(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 n3e(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function s3e(t,e){return t.button===0&&(!e||e==="_self")&&!n3e(t)}function JB(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 i3e(t,e){let r=JB(t);return e&&e.forEach((n,s)=>{r.has(s)||e.getAll(s).forEach(i=>{r.append(s,i)})}),r}const a3e=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],o3e=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],l3e="6";try{window.__reactRouterVersion=l3e}catch{}const c3e=S.createContext({isTransitioning:!1}),u3e="startTransition",QX=U7[u3e];function d3e(t){let{basename:e,children:r,future:n,window:s}=t,i=S.useRef();i.current==null&&(i.current=h4e({window:s,v5Compat:!0}));let a=i.current,[l,c]=S.useState({action:a.action,location:a.location}),{v7_startTransition:u}=n||{},d=S.useCallback(h=>{u&&QX?QX(()=>c(h)):c(h)},[c,u]);return S.useLayoutEffect(()=>a.listen(d),[a,d]),S.useEffect(()=>J4e(n),[n]),S.createElement(t3e,{basename:e,children:r,location:l.location,navigationType:l.action,navigator:a,future:n})}const h3e=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",f3e=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Nt=S.forwardRef(function(e,r){let{onClick:n,relative:s,reloadDocument:i,replace:a,state:l,target:c,to:u,preventScrollReset:d,viewTransition:h}=e,f=mpe(e,a3e),{basename:p}=S.useContext(Nf),m,g=!1;if(typeof u=="string"&&f3e.test(u)&&(m=u,h3e))try{let b=new URL(window.location.href),w=u.startsWith("//")?new URL(b.protocol+u):new URL(u),j=o1(w.pathname,p);w.origin===b.origin&&j!=null?u=j+w.search+w.hash:g=!0}catch{}let y=L4e(u,{relative:s}),x=g3e(u,{replace:a,state:l,target:c,preventScrollReset:d,relative:s,viewTransition:h});function v(b){n&&n(b),b.defaultPrevented||x(b)}return S.createElement("a",AI({},f,{href:m||y,onClick:g||i?n:v,ref:r,target:c}))}),p3e=S.forwardRef(function(e,r){let{"aria-current":n="page",caseSensitive:s=!1,className:i="",end:a=!1,style:l,to:c,viewTransition:u,children:d}=e,h=mpe(e,o3e),f=sD(c,{relative:h.relative}),p=bd(),m=S.useContext(cpe),{navigator:g,basename:y}=S.useContext(Nf),x=m!=null&&x3e(f)&&u===!0,v=g.encodeLocation?g.encodeLocation(f).pathname:f.pathname,b=p.pathname,w=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;s||(b=b.toLowerCase(),w=w?w.toLowerCase():null,v=v.toLowerCase()),w&&y&&(w=o1(w,y)||w);const j=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let N=b===v||!a&&b.startsWith(v)&&b.charAt(j)==="/",C=w!=null&&(w===v||!a&&w.startsWith(v)&&w.charAt(v.length)==="/"),A={isActive:N,isPending:C,isTransitioning:x},E=N?n:void 0,O;typeof i=="function"?O=i(A):O=[i,N?"active":null,C?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let $=typeof l=="function"?l(A):l;return S.createElement(Nt,AI({},h,{"aria-current":E,className:O,ref:r,style:$,to:c,viewTransition:u}),typeof d=="function"?d(A):d)});var e8;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(e8||(e8={}));var ZX;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(ZX||(ZX={}));function m3e(t){let e=S.useContext(rD);return e||ns(!1),e}function g3e(t,e){let{target:r,replace:n,state:s,preventScrollReset:i,relative:a,viewTransition:l}=e===void 0?{}:e,c=Or(),u=bd(),d=sD(t,{relative:a});return S.useCallback(h=>{if(s3e(h,r)){h.preventDefault();let f=n!==void 0?n:kI(u)===kI(d);c(t,{replace:f,state:s,preventScrollReset:i,relative:a,viewTransition:l})}},[u,c,d,n,s,r,t,i,a,l])}function uj(t){let e=S.useRef(JB(t)),r=S.useRef(!1),n=bd(),s=S.useMemo(()=>i3e(n.search,r.current?null:e.current),[n.search]),i=Or(),a=S.useCallback((l,c)=>{const u=JB(typeof l=="function"?l(s):l);r.current=!0,i("?"+u,c)},[i,s]);return[s,a]}function x3e(t,e){e===void 0&&(e={});let r=S.useContext(c3e);r==null&&ns(!1);let{basename:n}=m3e(e8.useViewTransitionState),s=sD(t,{relative:e.relative});if(!r.isTransitioning)return!1;let i=o1(r.currentLocation.pathname,n)||r.currentLocation.pathname,a=o1(r.nextLocation.pathname,n)||r.nextLocation.pathname;return CI(s.pathname,a)!=null||CI(s.pathname,i)!=null}const y3e="modulepreload",v3e=function(t){return"/"+t},JX={},RE=function(e,r,n){let s=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(r.map(c=>{if(c=v3e(c),c in JX)return;JX[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":y3e,u||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),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 l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&i(l.reason);return e().catch(i)})},b3e=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>RE(async()=>{const{default:n}=await Promise.resolve().then(()=>dj);return{default:n}},[]).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)};class c9 extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}}class w3e extends c9{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class eQ extends c9{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class tQ extends c9{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var t8;(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"})(t8||(t8={}));var j3e=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 l(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(l,c)}u((n=n.apply(t,e||[])).next())})};class S3e{constructor(e,{headers:r={},customFetch:n,region:s=t8.Any}={}){this.url=e,this.headers=r,this.region=s,this.fetch=b3e(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,r={}){var n;return j3e(this,void 0,void 0,function*(){try{const{headers:s,method:i,body:a}=r;let l={},{region:c}=r;c||(c=this.region);const u=new URL(`${this.url}/${e}`);c&&c!=="any"&&(l["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?(l["Content-Type"]="application/octet-stream",d=a):typeof a=="string"?(l["Content-Type"]="text/plain",d=a):typeof FormData<"u"&&a instanceof FormData?d=a:(l["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({},l),this.headers),s),body:d}).catch(g=>{throw new w3e(g)}),f=h.headers.get("x-relay-error");if(f&&f==="true")throw new eQ(h);if(!h.ok)throw new tQ(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 tQ||s instanceof eQ?s.context:void 0}}})}}var mo={},u9={},iD={},OE={},aD={},oD={},_3e=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")},l1=_3e();const N3e=l1.fetch,gpe=l1.fetch.bind(l1),xpe=l1.Headers,k3e=l1.Request,C3e=l1.Response,dj=Object.freeze(Object.defineProperty({__proto__:null,Headers:xpe,Request:k3e,Response:C3e,default:gpe,fetch:N3e},Symbol.toStringTag,{value:"Module"})),E3e=L2e(dj);var lD={};Object.defineProperty(lD,"__esModule",{value:!0});let A3e=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.code=e.code}};lD.default=A3e;var ype=$n&&$n.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(oD,"__esModule",{value:!0});const T3e=ype(E3e),P3e=ype(lD);let I3e=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=T3e.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,l,c;let u=null,d=null,h=null,f=i.status,p=i.statusText;if(i.ok){if(this.method!=="HEAD"){const x=await i.text();x===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?d=x:d=JSON.parse(x))}const g=(a=this.headers.Prefer)===null||a===void 0?void 0:a.match(/count=(exact|planned|estimated)/),y=(l=i.headers.get("content-range"))===null||l===void 0?void 0:l.split("/");g&&y&&y.length>1&&(h=parseInt(y[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 P3e.default(u)}return{error:u,data:d,count:h,status:f,statusText:p}});return this.shouldThrowOnError||(s=s.catch(i=>{var a,l,c;return{error:{message:`${(a=i==null?void 0:i.name)!==null&&a!==void 0?a:"FetchError"}: ${i==null?void 0:i.message}`,details:`${(l=i==null?void 0:i.stack)!==null&&l!==void 0?l:""}`,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}};oD.default=I3e;var R3e=$n&&$n.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(aD,"__esModule",{value:!0});const O3e=R3e(oD);let M3e=class extends O3e.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",l=this.url.searchParams.get(a);return this.url.searchParams.set(a,`${l?`${l},`:""}${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 l;const c=[e?"analyze":null,r?"verbose":null,n?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),u=(l=this.headers.Accept)!==null&&l!==void 0?l:"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}};aD.default=M3e;var D3e=$n&&$n.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(OE,"__esModule",{value:!0});const L3e=D3e(aD);let $3e=class extends L3e.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}};OE.default=$3e;var F3e=$n&&$n.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(iD,"__esModule",{value:!0});const Xj=F3e(OE);let B3e=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(l=>/\s/.test(l)&&!i?"":(l==='"'&&(i=!i),l)).join("");return this.url.searchParams.set("select",a),n&&(this.headers.Prefer=`count=${n}`),new Xj.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((l,c)=>l.concat(Object.keys(c)),[]);if(a.length>0){const l=[...new Set(a)].map(c=>`"${c}"`);this.url.searchParams.set("columns",l.join(","))}}return new Xj.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",l=[`resolution=${n?"ignore":"merge"}-duplicates`];if(r!==void 0&&this.url.searchParams.set("on_conflict",r),this.headers.Prefer&&l.push(this.headers.Prefer),s&&l.push(`count=${s}`),i||l.push("missing=default"),this.headers.Prefer=l.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 Xj.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 Xj.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 Xj.default({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}};iD.default=B3e;var cD={},uD={};Object.defineProperty(uD,"__esModule",{value:!0});uD.version=void 0;uD.version="0.0.0-automated";Object.defineProperty(cD,"__esModule",{value:!0});cD.DEFAULT_HEADERS=void 0;const z3e=uD;cD.DEFAULT_HEADERS={"X-Client-Info":`postgrest-js/${z3e.version}`};var vpe=$n&&$n.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(u9,"__esModule",{value:!0});const U3e=vpe(iD),H3e=vpe(OE),W3e=cD;let V3e=class bpe{constructor(e,{headers:r={},schema:n,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},W3e.DEFAULT_HEADERS),r),this.schemaName=n,this.fetch=s}from(e){const r=new URL(`${this.url}/${e}`);return new U3e.default(r,{headers:Object.assign({},this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new bpe(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,r={},{head:n=!1,get:s=!1,count:i}={}){let a;const l=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])=>{l.searchParams.append(d,h)})):(a="POST",c=r);const u=Object.assign({},this.headers);return i&&(u.Prefer=`count=${i}`),new H3e.default({method:a,url:l,headers:u,schema:this.schemaName,body:c,fetch:this.fetch,allowEmpty:!1})}};u9.default=V3e;var hj=$n&&$n.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(mo,"__esModule",{value:!0});mo.PostgrestError=mo.PostgrestBuilder=mo.PostgrestTransformBuilder=mo.PostgrestFilterBuilder=mo.PostgrestQueryBuilder=mo.PostgrestClient=void 0;const wpe=hj(u9);mo.PostgrestClient=wpe.default;const jpe=hj(iD);mo.PostgrestQueryBuilder=jpe.default;const Spe=hj(OE);mo.PostgrestFilterBuilder=Spe.default;const _pe=hj(aD);mo.PostgrestTransformBuilder=_pe.default;const Npe=hj(oD);mo.PostgrestBuilder=Npe.default;const kpe=hj(lD);mo.PostgrestError=kpe.default;var q3e=mo.default={PostgrestClient:wpe.default,PostgrestQueryBuilder:jpe.default,PostgrestFilterBuilder:Spe.default,PostgrestTransformBuilder:_pe.default,PostgrestBuilder:Npe.default,PostgrestError:kpe.default};const{PostgrestClient:G3e,PostgrestQueryBuilder:hWt,PostgrestFilterBuilder:fWt,PostgrestTransformBuilder:pWt,PostgrestBuilder:mWt,PostgrestError:gWt}=q3e;class K3e{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 Y3e="2.15.0",X3e=`realtime-js/${Y3e}`,Q3e="1.0.0",r8=1e4,Z3e=1e3,J3e=100;var P_;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(P_||(P_={}));var Gs;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Gs||(Gs={}));var Fc;(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"})(Fc||(Fc={}));var n8;(function(t){t.websocket="websocket"})(n8||(n8={}));var Yg;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(Yg||(Yg={}));class e$e{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 l=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:l,event:c,payload:u}}}let Cpe=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 Nn;(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"})(Nn||(Nn={}));const rQ=(t,e,r={})=>{var n;const s=(n=r.skipTypes)!==null&&n!==void 0?n:[];return Object.keys(e).reduce((i,a)=>(i[a]=t$e(a,t,e,s),i),{})},t$e=(t,e,r,n)=>{const s=e.find(l=>l.name===t),i=s==null?void 0:s.type,a=r[t];return i&&!n.includes(i)?Epe(i,a):s8(a)},Epe=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return i$e(e,r)}switch(t){case Nn.bool:return r$e(e);case Nn.float4:case Nn.float8:case Nn.int2:case Nn.int4:case Nn.int8:case Nn.numeric:case Nn.oid:return n$e(e);case Nn.json:case Nn.jsonb:return s$e(e);case Nn.timestamp:return a$e(e);case Nn.abstime:case Nn.date:case Nn.daterange:case Nn.int4range:case Nn.int8range:case Nn.money:case Nn.reltime:case Nn.text:case Nn.time:case Nn.timestamptz:case Nn.timetz:case Nn.tsrange:case Nn.tstzrange:return s8(e);default:return s8(e)}},s8=t=>t,r$e=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},n$e=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},s$e=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(e){return console.log(`JSON parse error: ${e}`),t}return t},i$e=(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(l=>Epe(e,l))}return t},a$e=t=>typeof t=="string"?t.replace(" ","T"):t,Ape=t=>{let e=t;return e=e.replace(/^ws/i,"http"),e=e.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),e.replace(/\/+$/,"")+"/api/broadcast"};class m4{constructor(e,r,n={},s=r8){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 nQ;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(nQ||(nQ={}));class I_{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:l}=this.caller;this.joinRef=this.channel._joinRef(),this.state=I_.syncState(this.state,s,i,a),this.pendingDiffs.forEach(c=>{this.state=I_.syncDiff(this.state,c,i,a)}),this.pendingDiffs=[],l()}),this.channel._on(n.diff,{},s=>{const{onJoin:i,onLeave:a,onSync:l}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=I_.syncDiff(this.state,s,i,a),l())}),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),l={},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(y=>y.presence_ref),p=h.map(y=>y.presence_ref),m=d.filter(y=>p.indexOf(y.presence_ref)<0),g=h.filter(y=>f.indexOf(y.presence_ref)<0);m.length>0&&(l[u]=m),g.length>0&&(c[u]=g)}else l[u]=d}),this.syncDiff(i,{joins:l,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,(l,c)=>{var u;const d=(u=e[l])!==null&&u!==void 0?u:[];if(e[l]=this.cloneDeep(c),d.length>0){const h=e[l].map(p=>p.presence_ref),f=d.filter(p=>h.indexOf(p.presence_ref)<0);e[l].unshift(...f)}n(l,d,c)}),this.map(a,(l,c)=>{let u=e[l];if(!u)return;const d=c.map(h=>h.presence_ref);u=u.filter(h=>d.indexOf(h.presence_ref)<0),e[l]=u,s(l,u,c),u.length===0&&delete e[l]}),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 sQ;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(sQ||(sQ={}));var R_;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(R_||(R_={}));var qd;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(qd||(qd={}));class d9{constructor(e,r={config:{}},n){this.topic=e,this.params=r,this.socket=n,this.bindings={},this.state=Gs.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 m4(this,Fc.join,this.params,this.timeout),this.rejoinTimer=new Cpe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Gs.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=Gs.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=Gs.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Gs.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=Gs.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Fc.reply,{},(s,i)=>{this._trigger(this._replyEventName(i),s)}),this.presence=new I_(this),this.broadcastEndpointURL=Ape(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==Gs.closed){const{config:{broadcast:i,presence:a,private:l}}=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[R_.PRESENCE]&&this.bindings[R_.PRESENCE].length>0,d={},h={broadcast:i,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:c,private:l};this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this._onError(f=>e==null?void 0:e(qd.CHANNEL_ERROR,f)),this._onClose(()=>e==null?void 0:e(qd.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(qd.SUBSCRIBED);return}else{const m=this.bindings.postgres_changes,g=(p=m==null?void 0:m.length)!==null&&p!==void 0?p:0,y=[];for(let x=0;x<g;x++){const v=m[x],{filter:{event:b,schema:w,table:j,filter:N}}=v,C=f&&f[x];if(C&&C.event===b&&C.schema===w&&C.table===j&&C.filter===N)y.push(Object.assign(Object.assign({},v),{id:C.id}));else{this.unsubscribe(),this.state=Gs.errored,e==null||e(qd.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=y,e&&e(qd.SUBSCRIBED);return}}).receive("error",f=>{this.state=Gs.errored,e==null||e(qd.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(f).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(qd.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===Gs.joined&&e===R_.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,l,c;const u=this._push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((c=(l=(a=this.params)===null||a===void 0?void 0:a.config)===null||l===void 0?void 0:l.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=Gs.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Fc.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(s=>{n=new m4(this,Fc.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=Gs.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 m4(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>J3e){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:l,error:c,leave:u,join:d}=Fc;if(n&&[l,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,y;return((m=p.filter)===null||m===void 0?void 0:m.event)==="*"||((y=(g=p.filter)===null||g===void 0?void 0:g.event)===null||y===void 0?void 0:y.toLocaleLowerCase())===a}).map(p=>p.callback(f,n)):(i=this.bindings[a])===null||i===void 0||i.filter(p=>{var m,g,y,x,v,b;if(["broadcast","presence","postgres_changes"].includes(a))if("id"in p){const w=p.id,j=(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))&&(j==="*"||(j==null?void 0:j.toLocaleLowerCase())===((y=r.data)===null||y===void 0?void 0:y.type.toLocaleLowerCase()))}else{const w=(v=(x=p==null?void 0:p.filter)===null||x===void 0?void 0:x.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:y,commit_timestamp:x,type:v,errors:b}=m;f=Object.assign(Object.assign({},{schema:g,table:y,commit_timestamp:x,eventType:v,new:{},old:{},errors:b}),this._getPayloadRecords(m))}p.callback(f,n)})}_isClosed(){return this.state===Gs.closed}_isJoined(){return this.state===Gs.joined}_isJoining(){return this.state===Gs.joining}_isLeaving(){return this.state===Gs.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&&d9.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(Fc.close,{},e)}_onError(e){this._on(Fc.error,{},r=>e(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Gs.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=rQ(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=rQ(e.columns,e.old_record)),r}}const iQ=()=>{},JA={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},o$e=[1e3,2e3,5e3,1e4],l$e=1e4,c$e=`
  addEventListener("message", (e) => {
    if (e.data.event === "start") {
      setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
    }
  });`;class u$e{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=r8,this.transport=null,this.heartbeatIntervalMs=JA.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=iQ,this.ref=0,this.reconnectTimer=null,this.logger=iQ,this.conn=null,this.sendBuffer=[],this.serializer=new e$e,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)=>RE(async()=>{const{default:l}=await Promise.resolve().then(()=>dj);return{default:l}},void 0).then(({default:l})=>l(...a)).catch(l=>{throw new Error(`Failed to load @supabase/node-fetch: ${l.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}/${n8.websocket}`,this.httpEndpoint=Ape(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=K3e.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:Q3e}))}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 P_.connecting:return Yg.Connecting;case P_.open:return Yg.Open;case P_.closing:return Yg.Closing;default:return Yg.Closed}}isConnected(){return this.connectionState()===Yg.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 d9(`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,l=>{var c;(c=this.conn)===null||c===void 0||c.send(l)})};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(Z3e,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},JA.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,l=a?`(${a})`:"",c=i.status||"";this.log("receive",`${c} ${n} ${s} ${l}`.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(Fc.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([c$e],{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:X3e};r&&n.updateJoinPayload(s),n.joinedOnce&&n._isJoined()&&n._push(Fc.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 Cpe(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},JA.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var r,n,s,i,a,l,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:r8,this.heartbeatIntervalMs=(s=e==null?void 0:e.heartbeatIntervalMs)!==null&&s!==void 0?s:JA.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=(l=e==null?void 0:e.reconnectAfterMs)!==null&&l!==void 0?l:d=>o$e[d-1]||l$e,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 h9 extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function Ni(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class d$e extends h9{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 i8 extends h9{constructor(e,r){super(e),this.name="StorageUnknownError",this.originalError=r}}var h$e=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 l(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(l,c)}u((n=n.apply(t,e||[])).next())})};const Tpe=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>RE(async()=>{const{default:n}=await Promise.resolve().then(()=>dj);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},f$e=()=>h$e(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield RE(()=>Promise.resolve().then(()=>dj),void 0)).Response:Response}),a8=t=>{if(Array.isArray(t))return t.map(r=>a8(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]=a8(n)}),e},p$e=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 Av=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 l(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(l,c)}u((n=n.apply(t,e||[])).next())})};const g4=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),m$e=(t,e,r)=>Av(void 0,void 0,void 0,function*(){const n=yield f$e();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 d$e(g4(s),i,a))}).catch(s=>{e(new i8(g4(s),s))}):e(new i8(g4(t),t))}),g$e=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"||!n?s:(p$e(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 ME(t,e,r,n,s,i){return Av(this,void 0,void 0,function*(){return new Promise((a,l)=>{t(r,g$e(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=>m$e(c,l,n))})})}function TI(t,e,r,n){return Av(this,void 0,void 0,function*(){return ME(t,"GET",e,r,n)})}function Gd(t,e,r,n,s){return Av(this,void 0,void 0,function*(){return ME(t,"POST",e,n,s,r)})}function o8(t,e,r,n,s){return Av(this,void 0,void 0,function*(){return ME(t,"PUT",e,n,s,r)})}function x$e(t,e,r,n){return Av(this,void 0,void 0,function*(){return ME(t,"HEAD",e,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function Ppe(t,e,r,n,s){return Av(this,void 0,void 0,function*(){return ME(t,"DELETE",e,n,s,r)})}var ro=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 l(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(l,c)}u((n=n.apply(t,e||[])).next())})};const y$e={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},aQ={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class v$e{constructor(e,r={},n,s){this.url=e,this.headers=r,this.bucketId=n,this.fetch=Tpe(s)}uploadOrUpdate(e,r,n,s){return ro(this,void 0,void 0,function*(){try{let i;const a=Object.assign(Object.assign({},aQ),s);let l=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,l["cache-control"]=`max-age=${a.cacheControl}`,l["content-type"]=a.contentType,c&&(l["x-metadata"]=this.toBase64(this.encodeMetadata(c)))),s!=null&&s.headers&&(l=Object.assign(Object.assign({},l),s.headers));const u=this._removeEmptyFolders(r),d=this._getFinalPath(u),h=yield(e=="PUT"?o8:Gd)(this.fetch,`${this.url}/object/${d}`,i,Object.assign({headers:l},a!=null&&a.duplex?{duplex:a.duplex}:{}));return{data:{path:u,id:h.Id,fullPath:h.Key},error:null}}catch(i){if(Ni(i))return{data:null,error:i};throw i}})}upload(e,r,n){return ro(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,r,n)})}uploadToSignedUrl(e,r,n,s){return ro(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(e),a=this._getFinalPath(i),l=new URL(this.url+`/object/upload/sign/${a}`);l.searchParams.set("token",r);try{let c;const u=Object.assign({upsert:aQ.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 o8(this.fetch,l.toString(),c,{headers:d});return{data:{path:i,fullPath:h.Key},error:null}}catch(c){if(Ni(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(e,r){return ro(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 Gd(this.fetch,`${this.url}/object/upload/sign/${n}`,{},{headers:s}),a=new URL(this.url+i.url),l=a.searchParams.get("token");if(!l)throw new h9("No token returned by API");return{data:{signedUrl:a.toString(),path:e,token:l},error:null}}catch(n){if(Ni(n))return{data:null,error:n};throw n}})}update(e,r,n){return ro(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,r,n)})}move(e,r,n){return ro(this,void 0,void 0,function*(){try{return{data:yield Gd(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(Ni(s))return{data:null,error:s};throw s}})}copy(e,r,n){return ro(this,void 0,void 0,function*(){try{return{data:{path:(yield Gd(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(Ni(s))return{data:null,error:s};throw s}})}createSignedUrl(e,r,n){return ro(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield Gd(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(Ni(s))return{data:null,error:s};throw s}})}createSignedUrls(e,r,n){return ro(this,void 0,void 0,function*(){try{const s=yield Gd(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(Ni(s))return{data:null,error:s};throw s}})}download(e,r){return ro(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 l=this._getFinalPath(e);return{data:yield(yield TI(this.fetch,`${this.url}/${s}/${l}${a}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(l){if(Ni(l))return{data:null,error:l};throw l}})}info(e){return ro(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{const n=yield TI(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:a8(n),error:null}}catch(n){if(Ni(n))return{data:null,error:n};throw n}})}exists(e){return ro(this,void 0,void 0,function*(){const r=this._getFinalPath(e);try{return yield x$e(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(Ni(n)&&n instanceof i8){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 l=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}/${l}/public/${n}${u}`)}}}remove(e){return ro(this,void 0,void 0,function*(){try{return{data:yield Ppe(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(r){if(Ni(r))return{data:null,error:r};throw r}})}list(e,r,n){return ro(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},y$e),r),{prefix:e||""});return{data:yield Gd(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},n),error:null}}catch(s){if(Ni(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 b$e="2.10.4",w$e={"X-Client-Info":`storage-js/${b$e}`};var Kv=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 l(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(l,c)}u((n=n.apply(t,e||[])).next())})};class j$e{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({},w$e),r),this.fetch=Tpe(n)}listBuckets(){return Kv(this,void 0,void 0,function*(){try{return{data:yield TI(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(Ni(e))return{data:null,error:e};throw e}})}getBucket(e){return Kv(this,void 0,void 0,function*(){try{return{data:yield TI(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(r){if(Ni(r))return{data:null,error:r};throw r}})}createBucket(e,r={public:!1}){return Kv(this,void 0,void 0,function*(){try{return{data:yield Gd(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(Ni(n))return{data:null,error:n};throw n}})}updateBucket(e,r){return Kv(this,void 0,void 0,function*(){try{return{data:yield o8(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(Ni(n))return{data:null,error:n};throw n}})}emptyBucket(e){return Kv(this,void 0,void 0,function*(){try{return{data:yield Gd(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(Ni(r))return{data:null,error:r};throw r}})}deleteBucket(e){return Kv(this,void 0,void 0,function*(){try{return{data:yield Ppe(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(r){if(Ni(r))return{data:null,error:r};throw r}})}}class S$e extends j$e{constructor(e,r={},n,s){super(e,r,n,s)}from(e){return new v$e(this.url,this.headers,e,this.fetch)}}const _$e="2.54.0";let $S="";typeof Deno<"u"?$S="deno":typeof document<"u"?$S="web":typeof navigator<"u"&&navigator.product==="ReactNative"?$S="react-native":$S="node";const N$e={"X-Client-Info":`supabase-js-${$S}/${_$e}`},k$e={headers:N$e},C$e={schema:"public"},E$e={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},A$e={};var T$e=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 l(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(l,c)}u((n=n.apply(t,e||[])).next())})};const P$e=t=>{let e;return t?e=t:typeof fetch>"u"?e=gpe:e=fetch,(...r)=>e(...r)},I$e=()=>typeof Headers>"u"?xpe:Headers,R$e=(t,e,r)=>{const n=P$e(r),s=I$e();return(i,a)=>T$e(void 0,void 0,void 0,function*(){var l;const c=(l=yield e())!==null&&l!==void 0?l: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 O$e=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 l(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(l,c)}u((n=n.apply(t,e||[])).next())})};function M$e(t){return t.endsWith("/")?t:t+"/"}function D$e(t,e){var r,n;const{db:s,auth:i,realtime:a,global:l}=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),l),{headers:Object.assign(Object.assign({},(r=h==null?void 0:h.headers)!==null&&r!==void 0?r:{}),(n=l==null?void 0:l.headers)!==null&&n!==void 0?n:{})}),accessToken:()=>O$e(this,void 0,void 0,function*(){return""})};return t.accessToken?f.accessToken=t.accessToken:delete f.accessToken,f}const Ipe="2.71.1",fb=30*1e3,l8=3,x4=l8*fb,L$e="http://localhost:9999",$$e="supabase.auth.token",F$e={"X-Client-Info":`gotrue-js/${Ipe}`},c8="X-Supabase-Api-Version",Rpe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},B$e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,z$e=10*60*1e3;class f9 extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Jt(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class U$e extends f9{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function H$e(t){return Jt(t)&&t.name==="AuthApiError"}class Ope extends f9{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class ag extends f9{constructor(e,r,n,s){super(e,n,s),this.name=r,this.status=n}}class Jf extends ag{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function W$e(t){return Jt(t)&&t.name==="AuthSessionMissingError"}class eT extends ag{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class tT extends ag{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class rT extends ag{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 V$e(t){return Jt(t)&&t.name==="AuthImplicitGrantRedirectError"}class oQ extends ag{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 u8 extends ag{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function y4(t){return Jt(t)&&t.name==="AuthRetryableFetchError"}class lQ extends ag{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class d8 extends ag{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const PI="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),cQ=` 	
\r=`.split(""),q$e=(()=>{const t=new Array(128);for(let e=0;e<t.length;e+=1)t[e]=-1;for(let e=0;e<cQ.length;e+=1)t[cQ[e].charCodeAt(0)]=-2;for(let e=0;e<PI.length;e+=1)t[PI[e].charCodeAt(0)]=e;return t})();function uQ(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(PI[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(PI[n]),e.queuedBits-=6}}function Mpe(t,e,r){const n=q$e[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 dQ(t){const e=[],r=a=>{e.push(String.fromCodePoint(a))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=a=>{Y$e(a,n,r)};for(let a=0;a<t.length;a+=1)Mpe(t.charCodeAt(a),s,i);return e.join("")}function G$e(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 K$e(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}G$e(n,e)}}function Y$e(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 X$e(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};for(let s=0;s<t.length;s+=1)Mpe(t.charCodeAt(s),r,n);return new Uint8Array(e)}function Q$e(t){const e=[];return K$e(t,r=>e.push(r)),new Uint8Array(e)}function Z$e(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};return t.forEach(s=>uQ(s,r,n)),uQ(null,r,n),e.join("")}function J$e(t){return Math.round(Date.now()/1e3)+t}function eFe(){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 bc=()=>typeof window<"u"&&typeof document<"u",Sg={tested:!1,writable:!1},Dpe=()=>{if(!bc())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(Sg.tested)return Sg.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),Sg.tested=!0,Sg.writable=!0}catch{Sg.tested=!0,Sg.writable=!1}return Sg.writable};function tFe(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 Lpe=t=>{let e;return t?e=t:typeof fetch>"u"?e=(...r)=>RE(async()=>{const{default:n}=await Promise.resolve().then(()=>dj);return{default:n}},void 0).then(({default:n})=>n(...r)):e=fetch,(...r)=>e(...r)},rFe=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",pb=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},_g=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Uf=async(t,e)=>{await t.removeItem(e)};class dD{constructor(){this.promise=new dD.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}dD.promiseConstructor=Promise;function v4(t){const e=t.split(".");if(e.length!==3)throw new d8("Invalid JWT structure");for(let n=0;n<e.length;n++)if(!B$e.test(e[n]))throw new d8("JWT not in base64url format");return{header:JSON.parse(dQ(e[0])),payload:JSON.parse(dQ(e[1])),signature:X$e(e[2]),raw:{header:e[0],payload:e[1]}}}async function nFe(t){return await new Promise(e=>{setTimeout(()=>e(null),t)})}function sFe(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 iFe(t){return("0"+t.toString(16)).substr(-2)}function aFe(){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,iFe).join("")}async function oFe(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 lFe(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 oFe(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Yv(t,e,r=!1){const n=aFe();let s=n;r&&(s+="/PASSWORD_RECOVERY"),await pb(t,`${e}-code-verifier`,s);const i=await lFe(n);return[i,n===i?"plain":"s256"]}const cFe=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function uFe(t){const e=t.headers.get(c8);if(!e||!e.match(cFe))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function dFe(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 hFe(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 fFe=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Xv(t){if(!fFe.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function b4(){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 hQ(t){return JSON.parse(JSON.stringify(t))}var pFe=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 Fg=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),mFe=[502,503,504];async function fQ(t){var e;if(!rFe(t))throw new u8(Fg(t),0);if(mFe.includes(t.status))throw new u8(Fg(t),t.status);let r;try{r=await t.json()}catch(i){throw new Ope(Fg(i),i)}let n;const s=uFe(t);if(s&&s.getTime()>=Rpe["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 lQ(Fg(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new Jf}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 lQ(Fg(r),t.status,r.weak_password.reasons);throw new U$e(Fg(r),t.status||500,n)}const gFe=(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 yr(t,e,r,n){var s;const i=Object.assign({},n==null?void 0:n.headers);i[c8]||(i[c8]=Rpe["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 l=Object.keys(a).length?"?"+new URLSearchParams(a).toString():"",c=await xFe(t,e,r+l,{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 xFe(t,e,r,n,s,i){const a=gFe(e,n,s,i);let l;try{l=await t(r,Object.assign({},a))}catch(c){throw console.error(c),new u8(Fg(c),0)}if(l.ok||await fQ(l),n!=null&&n.noResolveJson)return l;try{return await l.json()}catch(c){await fQ(c)}}function Fd(t){var e;let r=null;wFe(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=J$e(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}function pQ(t){const e=Fd(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 hp(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function yFe(t){return{data:t,error:null}}function vFe(t){const{action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i}=t,a=pFe(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),l={action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:i},c=Object.assign({},a);return{data:{properties:l,user:c},error:null}}function bFe(t){return t}function wFe(t){return t.access_token&&t.refresh_token&&t.expires_in}const w4=["global","local","others"];var jFe=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 SFe{constructor({url:e="",headers:r={},fetch:n}){this.url=e,this.headers=r,this.fetch=Lpe(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(e,r=w4[0]){if(w4.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${w4.join(", ")}`);try{return await yr(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Jt(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,r={}){try{return await yr(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:hp})}catch(n){if(Jt(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{const{options:r}=e,n=jFe(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 yr(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:vFe,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Jt(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await yr(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:hp})}catch(r){if(Jt(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,n,s,i,a,l,c;try{const u={nextPage:null,lastPage:0,total:0},d=await yr(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:bFe});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=(l=d.headers.get("link"))===null||l===void 0?void 0:l.split(","))!==null&&c!==void 0?c:[];return p.length>0&&(p.forEach(m=>{const g=parseInt(m.split(";")[0].split("=")[1].substring(0,1)),y=JSON.parse(m.split(";")[1].split("=")[1]);u[`${y}Page`]=g}),u.total=parseInt(f)),{data:Object.assign(Object.assign({},h),u),error:null}}catch(u){if(Jt(u))return{data:{users:[]},error:u};throw u}}async getUserById(e){Xv(e);try{return await yr(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:hp})}catch(r){if(Jt(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){Xv(e);try{return await yr(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:hp})}catch(n){if(Jt(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){Xv(e);try{return await yr(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:hp})}catch(n){if(Jt(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){Xv(e.userId);try{const{data:r,error:n}=await yr(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(Jt(r))return{data:null,error:r};throw r}}async _deleteFactor(e){Xv(e.userId),Xv(e.id);try{return{data:await yr(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(Jt(r))return{data:null,error:r};throw r}}}function mQ(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}function _Fe(){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 Qv={debug:!!(globalThis&&Dpe()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class $pe extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class NFe extends $pe{}async function kFe(t,e,r){Qv.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),Qv.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){Qv.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await r()}finally{Qv.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw Qv.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new NFe(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(Qv.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()}}))}_Fe();const CFe={url:L$e,storageKey:$$e,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:F$e,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function gQ(t,e,r){return await r()}const Zv={};class IN{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=IN.nextInstanceID,IN.nextInstanceID+=1,this.instanceID>0&&bc()&&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({},CFe),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 SFe({url:s.url,headers:s.headers,fetch:s.fetch}),this.url=s.url,this.headers=s.headers,this.fetch=Lpe(s.fetch),this.lock=s.lock||gQ,this.detectSessionInUrl=s.detectSessionInUrl,this.flowType=s.flowType,this.hasCustomAuthorizationHeader=s.hasCustomAuthorizationHeader,s.lock?this.lock=s.lock:bc()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=kFe:this.lock=gQ,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:Dpe()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=mQ(this.memoryStorage)),s.userStorage&&(this.userStorage=s.userStorage)):(this.memoryStorage={},this.storage=mQ(this.memoryStorage)),bc()&&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=Zv[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){Zv[this.storageKey]=Object.assign(Object.assign({},Zv[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=Zv[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){Zv[this.storageKey]=Object.assign(Object.assign({},Zv[this.storageKey]),{cachedAt:e})}_debug(...e){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${Ipe}) ${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=tFe(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),bc()&&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),V$e(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:l}=s;return this._debug("#_initialize()","detected session in URL",a,"redirect type",l),await this._saveSession(a),setTimeout(async()=>{l==="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 Jt(r)?{error:r}:{error:new Ope("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,s;try{const i=await yr(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:Fd}),{data:a,error:l}=i;if(l||!a)return{data:{user:null,session:null},error:l};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(Jt(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 Yv(this.storage,this.storageKey)),i=await yr(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:Fd})}else if("phone"in e){const{phone:d,password:h,options:f}=e;i=await yr(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:Fd})}else throw new tT("You must provide either an email or phone number and a password");const{data:a,error:l}=i;if(l||!a)return{data:{user:null,session:null},error:l};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(Jt(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:l}=e;r=await yr(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:a,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:pQ})}else if("phone"in e){const{phone:i,password:a,options:l}=e;r=await yr(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:a,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:pQ})}else throw new tT("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 eT}:(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(Jt(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,l,c,u,d,h,f,p;let m,g;if("message"in e)m=e.message,g=e.signature;else{const{chain:y,wallet:x,statement:v,options:b}=e;let w;if(bc())if(typeof x=="object")w=x;else{const N=window;if("solana"in N&&typeof N.solana=="object"&&("signIn"in N.solana&&typeof N.solana.signIn=="function"||"signMessage"in N.solana&&typeof N.solana.signMessage=="function"))w=N.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 x!="object"||!(b!=null&&b.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");w=x}const j=new URL((r=b==null?void 0:b.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in w&&w.signIn){const N=await w.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},b==null?void 0:b.signInWithSolana),{version:"1",domain:j.host,uri:j.href}),v?{statement:v}:null));let C;if(Array.isArray(N)&&N[0]&&typeof N[0]=="object")C=N[0];else if(N&&typeof N=="object"&&"signedMessage"in N&&"signature"in N)C=N;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in C&&"signature"in C&&(typeof C.signedMessage=="string"||C.signedMessage instanceof Uint8Array)&&C.signature instanceof Uint8Array)m=typeof C.signedMessage=="string"?C.signedMessage:new TextDecoder().decode(C.signedMessage),g=C.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=[`${j.host} wants you to sign in with your Solana account:`,w.publicKey.toBase58(),...v?["",v,""]:[""],"Version: 1",`URI: ${j.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}`]:[],...!((l=b==null?void 0:b.signInWithSolana)===null||l===void 0)&&l.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(C=>`- ${C}`)]:[]].join(`
`);const N=await w.signMessage(new TextEncoder().encode(m),"utf8");if(!N||!(N instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");g=N}}try{const{data:y,error:x}=await yr(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:m,signature:Z$e(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:Fd});if(x)throw x;return!y||!y.session||!y.user?{data:{user:null,session:null},error:new eT}:(y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("SIGNED_IN",y.session)),{data:Object.assign({},y),error:x})}catch(y){if(Jt(y))return{data:{user:null,session:null},error:y};throw y}}async _exchangeCodeForSession(e){const r=await _g(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(r??"").split("/");try{const{data:i,error:a}=await yr(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Fd});if(await Uf(this.storage,`${this.storageKey}-code-verifier`),a)throw a;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new eT}:(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(Jt(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,l=await yr(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:Fd}),{data:c,error:u}=l;return u?{data:{user:null,session:null},error:u}:!c||!c.session||!c.user?{data:{user:null,session:null},error:new eT}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:u})}catch(r){if(Jt(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:l,options:c}=e;let u=null,d=null;this.flowType==="pkce"&&([u,d]=await Yv(this.storage,this.storageKey));const{error:h}=await yr(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:l,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:l,options:c}=e,{data:u,error:d}=await yr(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:l,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 tT("You must provide either an email or phone number.")}catch(l){if(Jt(l))return{data:{user:null,session:null},error:l};throw l}}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:l}=await yr(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:i}}),redirectTo:s,xform:Fd});if(l)throw l;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(Jt(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 Yv(this.storage,this.storageKey)),await yr(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:yFe})}catch(i){if(Jt(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 Jf;const{error:s}=await yr(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:s}})}catch(e){if(Jt(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 yr(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:l}=await yr(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:l}}throw new tT("You must provide either an email or phone number and a type")}catch(r){if(Jt(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 _g(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()<x4:!1;if(this._debug("#__loadSession()",`session has${n?"":" not"} expired`,"expires_at",e.expires_at),!n){if(this.userStorage){const a=await _g(this.userStorage,this.storageKey+"-user");a!=null&&a.user?e.user=a.user:e.user=b4()}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 yr(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:hp}):await this._useSession(async r=>{var n,s,i;const{data:a,error:l}=r;if(l)throw l;return!(!((n=a.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new Jf}:await yr(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:hp})})}catch(r){if(Jt(r))return W$e(r)&&(await this._removeSession(),await Uf(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 Jf;const a=s.session;let l=null,c=null;this.flowType==="pkce"&&e.email!=null&&([l,c]=await Yv(this.storage,this.storageKey));const{data:u,error:d}=await yr(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:l,code_challenge_method:c}),jwt:a.access_token,xform:hp});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(Jt(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 Jf;const r=Date.now()/1e3;let n=r,s=!0,i=null;const{payload:a}=v4(e.access_token);if(a.exp&&(n=a.exp,s=n<=r),s){const{session:l,error:c}=await this._callRefreshToken(e.refresh_token);if(c)return{data:{user:null,session:null},error:c};if(!l)return{data:{user:null,session:null},error:null};i=l}else{const{data:l,error:c}=await this._getUser(e.access_token);if(c)throw c;i={access_token:e.access_token,refresh_token:e.refresh_token,user:l.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(Jt(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:l}=r;if(l)throw l;e=(n=a.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new Jf;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(Jt(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(e,r){try{if(!bc())throw new rT("No browser detected.");if(e.error||e.error_description||e.error_code)throw new rT(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 oQ("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new rT("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 oQ("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:l,expires_at:c,token_type:u}=e;if(!i||!l||!a||!u)throw new rT("No session defined in URL");const d=Math.round(Date.now()/1e3),h=parseInt(l);let f=d+h;c&&(f=parseInt(c));const p=f-d;p*1e3<=fb&&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:y}=await this._getUser(i);if(y)throw y;const x={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:x,redirectType:e.type},error:null}}catch(n){if(Jt(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 _g(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:l}=await this.admin.signOut(a,e);if(l&&!(H$e(l)&&(l.status===404||l.status===401||l.status===403)))return{error:l}}return e!=="others"&&(await this._removeSession(),await Uf(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(e){const r=eFe(),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 Yv(this.storage,this.storageKey,!0));try{return await yr(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(Jt(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(Jt(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,l,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:(l=e.options)===null||l===void 0?void 0:l.scopes,queryParams:(c=e.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await yr(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 bc()&&!(!((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(Jt(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 yr(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(Jt(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 sFe(async s=>(s>0&&await nFe(200*Math.pow(2,s-1)),this._debug(r,"refreshing attempt",s),await yr(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Fd})),(s,i)=>{const a=200*Math.pow(2,s);return i&&y4(i)&&Date.now()+a-n<fb})}catch(n){if(this._debug(r,"error",n),Jt(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),bc()&&!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 _g(this.storage,this.storageKey);if(s&&this.userStorage){let a=await _g(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!a&&(a={user:s.user},await pb(this.userStorage,this.storageKey+"-user",a)),s.user=(e=a==null?void 0:a.user)!==null&&e!==void 0?e:b4()}else if(s&&!s.user&&!s.user){const a=await _g(this.storage,this.storageKey+"-user");a&&(a!=null&&a.user)?(s.user=a.user,await Uf(this.storage,this.storageKey+"-user"),await pb(this.storage,this.storageKey,s)):s.user=b4()}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()<x4;if(this._debug(n,`session has${i?"":" not"} expired with margin of ${x4}s`),i){if(this.autoRefreshToken&&s.refresh_token){const{error:a}=await this._callRefreshToken(s.refresh_token);a&&(console.error(a),y4(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:l}=await this._getUser(s.access_token);!l&&(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 Jf;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const s=`#_callRefreshToken(${e.substring(0,5)}...)`;this._debug(s,"begin");try{this.refreshingDeferred=new dD;const{data:i,error:a}=await this._refreshAccessToken(e);if(a)throw a;if(!i.session)throw new Jf;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const l={session:i.session,error:null};return this.refreshingDeferred.resolve(l),l}catch(i){if(this._debug(s,"error",i),Jt(i)){const a={session:null,error:i};return y4(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 l=>{try{await l.callback(e,r)}catch(c){i.push(c)}});if(await Promise.all(a),i.length>0){for(let l=0;l<i.length;l+=1)console.error(i[l]);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 pb(this.userStorage,this.storageKey+"-user",{user:r.user});const s=Object.assign({},r);delete s.user;const i=hQ(s);await pb(this.storage,this.storageKey,i)}else{const s=hQ(r);await pb(this.storage,this.storageKey,s)}}async _removeSession(){this._debug("#_removeSession()"),await Uf(this.storage,this.storageKey),await Uf(this.storage,this.storageKey+"-code-verifier"),await Uf(this.storage,this.storageKey+"-user"),this.userStorage&&await Uf(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&bc()&&(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(),fb);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)/fb);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${fb}ms, refresh threshold is ${l8} ticks`),s<=l8&&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 $pe)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!bc()||!(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 Yv(this.storage,this.storageKey),l=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(a)}`});s.push(l.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 yr(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(Jt(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 l=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:{issuer:e.issuer}),{data:c,error:u}=await yr(this.fetch,"POST",`${this.url}/factors`,{body:l,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(Jt(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:l}=await yr(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 l?{data:null,error:l}:(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:l})})}catch(r){if(Jt(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 yr(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(Jt(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}=v4(s.access_token);let l=null;a.aal&&(l=a.aal);let c=l;((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:l,nextLevel:c,currentAuthenticationMethods:d},error:null}}))}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(l=>l.kid===e);if(n)return n;const s=Date.now();if(n=this.jwks.keys.find(l=>l.kid===e),n&&this.jwks_cached_at+z$e>s)return n;const{data:i,error:a}=await yr(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(l=>l.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:l,payload:c}}=v4(n);r!=null&&r.allowExpired||dFe(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=hFe(s.alg),h=await crypto.subtle.importKey("jwk",u,d,!0,["verify"]);if(!await crypto.subtle.verify(d,h,a,Q$e(`${l}.${c}`)))throw new d8("Invalid JWT signature");return{data:{claims:i,header:s,signature:a},error:null}}catch(n){if(Jt(n))return{data:null,error:n};throw n}}}IN.nextInstanceID=0;const EFe=IN;class AFe extends EFe{constructor(e){super(e)}}var TFe=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 l(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(l,c)}u((n=n.apply(t,e||[])).next())})};class PFe{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 l=M$e(e),c=new URL(l);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:C$e,realtime:A$e,auth:Object.assign(Object.assign({},E$e),{storageKey:u}),global:k$e},h=D$e(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=R$e(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 G3e(new URL("rest/v1",c).href,{headers:this.headers,schema:h.db.schema,fetch:this.fetch}),this.storage=new S$e(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),h.accessToken||this._listenForAuthEvents()}get functions(){return new S3e(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 TFe(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:l,debug:c},u,d){const h={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new AFe({url:this.authUrl.href,headers:Object.assign(Object.assign({},h),u),storageKey:i,autoRefreshToken:e,persistSession:r,detectSessionInUrl:n,storage:s,flowType:a,lock:l,debug:c,fetch:d,hasCustomAuthorizationHeader:"Authorization"in this.headers})}_initRealtimeClient(e){return new u$e(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 Fpe=(t,e,r)=>new PFe(t,e,r);function IFe(){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}IFe()&&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 RFe="https://nqibmbtqcjucktqcreob.supabase.co",OFe="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5xaWJtYnRxY2p1Y2t0cWNyZW9iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1NTk5MTAsImV4cCI6MjA3MDEzNTkxMH0.UnFk-GqYCZtlkXNlxyHUTaFAnS6Q4hIgDgWKANrxEHg",vn=Fpe(RFe,OFe,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),Bpe=S.createContext(void 0);function MFe({children:t}){const[e,r]=S.useState(null),[n,s]=S.useState(null),[i,a]=S.useState(null),[l,c]=S.useState(null),[u,d]=S.useState(!0),h=async M=>{try{await Promise.all([f(M),p(M),m(M)])}catch(k){console.error("Error loading user data:",k)}finally{d(!1)}};S.useEffect(()=>{let M=!0;vn.auth.getSession().then(async({data:{session:D}})=>{M&&(r((D==null?void 0:D.user)??null),D!=null&&D.user?await h(D.user.id):d(!1))});const{data:{subscription:k}}=vn.auth.onAuthStateChange((D,K)=>{M&&(D==="SIGNED_IN"&&d(!0),r((K==null?void 0:K.user)??null),K!=null&&K.user?setTimeout(async()=>{M&&await h(K.user.id)},0):(s(null),a(null),c(null),d(!1)))});return()=>{M=!1,k.unsubscribe()}},[]);const f=async M=>{try{const{data:k,error:D}=await vn.from("users").select("*").eq("id",M).maybeSingle();if(D){if(console.error("Error fetching user profile:",D),D.code==="PGRST116"){await x(M);return}}else k?s(k):await x(M)}catch(k){console.error("Error in fetchUserProfile:",k)}},p=async M=>{try{const{data:k,error:D}=await vn.from("user_profiles").select("*").eq("user_id",M).maybeSingle();if(D&&D.code!=="PGRST116"){console.error("Error fetching research profile:",D);return}a(k)}catch(k){console.error("Error in fetchResearchProfile:",k)}},m=async M=>{try{const{data:k,error:D}=await vn.from("user_student_points").select("total_purchased, used_points, remaining_points").eq("user_id",M).maybeSingle();if(D)throw D;if(!k){console.warn("No student-points row returned for user:",M),c(null);return}c({total:Number(k.total_purchased??0),used:Number(k.used_points??0),remaining:Number(k.remaining_points??0)})}catch(k){console.error("Error fetching student points:",k),c(null)}},g=async M=>{await m(M)},y=async()=>{e&&(await f(e.id),await m(e.id))},x=async(M,k)=>{var D;try{const{data:K}=await vn.auth.getUser();if(!((D=K.user)!=null&&D.email))return;const H={id:M,email:K.user.email,plan:"free",current_token_balance:30};if(k)H.terms_accepted_at=k.terms_accepted_at,H.privacy_accepted_at=k.privacy_accepted_at,H.terms_version=k.terms_version,H.privacy_version=k.privacy_version,H.marketing_consent=!0,H.marketing_consent_at=k.terms_accepted_at;else if(K.user.user_metadata){const B=K.user.user_metadata;B.terms_accepted_at&&(H.terms_accepted_at=B.terms_accepted_at,H.privacy_accepted_at=B.privacy_accepted_at,H.terms_version=B.terms_version,H.privacy_version=B.privacy_version,H.marketing_consent=!0,H.marketing_consent_at=B.terms_accepted_at)}const{data:ee,error:V}=await vn.from("users").insert(H).select().single();if(V)if(V.code==="23505"){console.log("User profile already exists, fetching...");const{data:B}=await vn.from("users").select("*").eq("id",M).single();B&&s(B)}else console.error("Error creating user profile:",V);else s(ee)}catch(K){console.error("Error in createUserProfile:",K)}},v=async(M,k)=>{if(!M||!M.includes("@"))return{error:{message:"Please enter a valid email address"}};if(!k||k.length<6)return{error:{message:"Password must be at least 6 characters"}};const{error:D}=await vn.auth.signInWithPassword({email:M.trim().toLowerCase(),password:k});return D||typeof window<"u"&&window.umami&&window.umami.track("user-login"),{error:D}},b=async(M,k,D)=>{if(!M||!M.includes("@"))return{error:{message:"Please enter a valid email address"}};if(!k||k.length<6)return{error:{message:"Password must be at least 6 characters"}};const{data:K,error:H}=await vn.auth.signUp({email:M.trim().toLowerCase(),password:k,options:{emailRedirectTo:`${window.location.origin}/dashboard`,data:D?{terms_accepted_at:D.terms_accepted_at,privacy_accepted_at:D.privacy_accepted_at,terms_version:D.terms_version,privacy_version:D.privacy_version}:void 0}});return!H&&K.user&&D&&await x(K.user.id,D),{error:H}},w=async()=>{const{error:M}=await vn.auth.signOut();return M||(r(null),s(null),a(null),c(null)),{error:M}},j=M=>{switch(M){case"free":return 30;case"pro":return 100;case"author":return 200;default:return 30}},N=async M=>{try{const{data:k,error:D}=await vn.rpc("consume_tokens",{pages_to_consume:M});return D?(console.error("Token consumption error:",D),{success:!1,error:D.message}):(e&&await f(e.id),k)}catch(k){return console.error("Token consumption error:",k),{success:!1,error:k.message||"Failed to consume tokens"}}},C=-20,A=()=>l?l.remaining>C:!1,E=async M=>{if(!e)throw new Error("No authenticated user");if(!e.email)throw new Error("Authenticated user has no email address");try{const{error:k}=await vn.from("users").upsert({id:e.id,email:e.email},{onConflict:"id",ignoreDuplicates:!0});if(k)throw k;const D=Object.fromEntries(Object.entries(M).filter(([,ee])=>ee!==void 0)),{data:K,error:H}=await vn.from("user_profiles").upsert({user_id:e.id,...D,updated_at:new Date().toISOString()},{onConflict:"user_id"}).select("*").single();if(H)throw H;a(K)}catch(k){throw console.error("Error updating research profile:",k),k}},T={user:e,userProfile:n,researchProfile:i,studentPoints:l,loading:u,signIn:v,signUp:b,signOut:w,getPlanLimit:j,consumeTokens:N,fetchStudentPoints:g,refreshProfile:y,checkStudentPoints:A,updateResearchProfile:E,uploadAvatar:async M=>{if(!e)throw new Error("No user logged in");try{const k=M.name.split(".").pop(),D=`${e.id}/avatar.${k}`,{error:K}=await vn.storage.from("avatars").upload(D,M,{upsert:!0});if(K)throw K;return await E({avatar_url:D}),D}catch(k){throw console.error("Error uploading avatar:",k),k}},selectPublicAvatar:async M=>{if(!e)throw new Error("No user logged in");await E({avatar_url:M})}};return o.jsx(Bpe.Provider,{value:T,children:t})}function Ht(){const t=S.useContext(Bpe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const p9=_f("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"}}),me=S.forwardRef(({className:t,variant:e,size:r,asChild:n=!1,...s},i)=>{const a=n?HRe:"button";return o.jsx(a,{className:Pe(p9({variant:e,size:r,className:t})),ref:i,...s})});me.displayName="Button";var DFe=S.createContext(void 0);function Tv(t){const e=S.useContext(DFe);return t||e||"ltr"}var j4=0;function hD(){S.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??xQ()),document.body.insertAdjacentElement("beforeend",t[1]??xQ()),j4++,()=>{j4===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),j4--}},[])}function xQ(){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 S4="focusScope.autoFocusOnMount",_4="focusScope.autoFocusOnUnmount",yQ={bubbles:!1,cancelable:!0},LFe="FocusScope",DE=S.forwardRef((t,e)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:i,...a}=t,[l,c]=S.useState(null),u=ys(s),d=ys(i),h=S.useRef(null),f=qt(e,g=>c(g)),p=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(n){let g=function(b){if(p.paused||!l)return;const w=b.target;l.contains(w)?h.current=w:ep(h.current,{select:!0})},y=function(b){if(p.paused||!l)return;const w=b.relatedTarget;w!==null&&(l.contains(w)||ep(h.current,{select:!0}))},x=function(b){if(document.activeElement===document.body)for(const j of b)j.removedNodes.length>0&&ep(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",y);const v=new MutationObserver(x);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",y),v.disconnect()}}},[n,l,p.paused]),S.useEffect(()=>{if(l){bQ.add(p);const g=document.activeElement;if(!l.contains(g)){const x=new CustomEvent(S4,yQ);l.addEventListener(S4,u),l.dispatchEvent(x),x.defaultPrevented||($Fe(HFe(zpe(l)),{select:!0}),document.activeElement===g&&ep(l))}return()=>{l.removeEventListener(S4,u),setTimeout(()=>{const x=new CustomEvent(_4,yQ);l.addEventListener(_4,d),l.dispatchEvent(x),x.defaultPrevented||ep(g??document.body,{select:!0}),l.removeEventListener(_4,d),bQ.remove(p)},0)}}},[l,u,d,p]);const m=S.useCallback(g=>{if(!r&&!n||p.paused)return;const y=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,x=document.activeElement;if(y&&x){const v=g.currentTarget,[b,w]=FFe(v);b&&w?!g.shiftKey&&x===w?(g.preventDefault(),r&&ep(b,{select:!0})):g.shiftKey&&x===b&&(g.preventDefault(),r&&ep(w,{select:!0})):x===v&&g.preventDefault()}},[r,n,p.paused]);return o.jsx(ft.div,{tabIndex:-1,...a,ref:f,onKeyDown:m})});DE.displayName=LFe;function $Fe(t,{select:e=!1}={}){const r=document.activeElement;for(const n of t)if(ep(n,{select:e}),document.activeElement!==r)return}function FFe(t){const e=zpe(t),r=vQ(e,t),n=vQ(e.reverse(),t);return[r,n]}function zpe(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 vQ(t,e){for(const r of t)if(!BFe(r,{upTo:e}))return r}function BFe(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 zFe(t){return t instanceof HTMLInputElement&&"select"in t}function ep(t,{select:e=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&zFe(t)&&e&&t.select()}}var bQ=UFe();function UFe(){let t=[];return{add(e){const r=t[0];e!==r&&(r==null||r.pause()),t=wQ(t,e),t.unshift(e)},remove(e){var r;t=wQ(t,e),(r=t[0])==null||r.resume()}}}function wQ(t,e){const r=[...t],n=r.indexOf(e);return n!==-1&&r.splice(n,1),r}function HFe(t){return t.filter(e=>e.tagName!=="A")}var N4="rovingFocusGroup.onEntryFocus",WFe={bubbles:!1,cancelable:!0},LE="RovingFocusGroup",[h8,Upe,VFe]=CE(LE),[qFe,fj]=Vs(LE,[VFe]),[GFe,KFe]=qFe(LE),Hpe=S.forwardRef((t,e)=>o.jsx(h8.Provider,{scope:t.__scopeRovingFocusGroup,children:o.jsx(h8.Slot,{scope:t.__scopeRovingFocusGroup,children:o.jsx(YFe,{...t,ref:e})})}));Hpe.displayName=LE;var YFe=S.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:s=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...h}=t,f=S.useRef(null),p=qt(e,f),m=Tv(i),[g,y]=ca({prop:a,defaultProp:l??null,onChange:c,caller:LE}),[x,v]=S.useState(!1),b=ys(u),w=Upe(r),j=S.useRef(!1),[N,C]=S.useState(0);return S.useEffect(()=>{const A=f.current;if(A)return A.addEventListener(N4,b),()=>A.removeEventListener(N4,b)},[b]),o.jsx(GFe,{scope:r,orientation:n,dir:m,loop:s,currentTabStopId:g,onItemFocus:S.useCallback(A=>y(A),[y]),onItemShiftTab:S.useCallback(()=>v(!0),[]),onFocusableItemAdd:S.useCallback(()=>C(A=>A+1),[]),onFocusableItemRemove:S.useCallback(()=>C(A=>A-1),[]),children:o.jsx(ft.div,{tabIndex:x||N===0?-1:0,"data-orientation":n,...h,ref:p,style:{outline:"none",...t.style},onMouseDown:Qe(t.onMouseDown,()=>{j.current=!0}),onFocus:Qe(t.onFocus,A=>{const E=!j.current;if(A.target===A.currentTarget&&E&&!x){const O=new CustomEvent(N4,WFe);if(A.currentTarget.dispatchEvent(O),!O.defaultPrevented){const $=w().filter(K=>K.focusable),T=$.find(K=>K.active),M=$.find(K=>K.id===g),D=[T,M,...$].filter(Boolean).map(K=>K.ref.current);qpe(D,d)}}j.current=!1}),onBlur:Qe(t.onBlur,()=>v(!1))})})}),Wpe="RovingFocusGroupItem",Vpe=S.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:s=!1,tabStopId:i,children:a,...l}=t,c=Co(),u=i||c,d=KFe(Wpe,r),h=d.currentTabStopId===u,f=Upe(r),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:g}=d;return S.useEffect(()=>{if(n)return p(),()=>m()},[n,p,m]),o.jsx(h8.ItemSlot,{scope:r,id:u,focusable:n,active:s,children:o.jsx(ft.span,{tabIndex:h?0:-1,"data-orientation":d.orientation,...l,ref:e,onMouseDown:Qe(t.onMouseDown,y=>{n?d.onItemFocus(u):y.preventDefault()}),onFocus:Qe(t.onFocus,()=>d.onItemFocus(u)),onKeyDown:Qe(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){d.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const x=ZFe(y,d.orientation,d.dir);if(x!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let b=f().filter(w=>w.focusable).map(w=>w.ref.current);if(x==="last")b.reverse();else if(x==="prev"||x==="next"){x==="prev"&&b.reverse();const w=b.indexOf(y.currentTarget);b=d.loop?JFe(b,w+1):b.slice(w+1)}setTimeout(()=>qpe(b))}}),children:typeof a=="function"?a({isCurrentTabStop:h,hasTabStop:g!=null}):a})})});Vpe.displayName=Wpe;var XFe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function QFe(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function ZFe(t,e,r){const n=QFe(t.key,r);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return XFe[n]}function qpe(t,e=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:e}),document.activeElement!==r))return}function JFe(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var m9=Hpe,g9=Vpe,e6e=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Jv=new WeakMap,nT=new WeakMap,sT={},k4=0,Gpe=function(t){return t&&(t.host||Gpe(t.parentNode))},t6e=function(t,e){return e.map(function(r){if(t.contains(r))return r;var n=Gpe(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})},r6e=function(t,e,r,n){var s=t6e(e,Array.isArray(t)?t:[t]);sT[r]||(sT[r]=new WeakMap);var i=sT[r],a=[],l=new Set,c=new Set(s),u=function(h){!h||l.has(h)||(l.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(l.has(f))d(f);else try{var p=f.getAttribute(n),m=p!==null&&p!=="false",g=(Jv.get(f)||0)+1,y=(i.get(f)||0)+1;Jv.set(f,g),i.set(f,y),a.push(f),g===1&&m&&nT.set(f,!0),y===1&&f.setAttribute(r,"true"),m||f.setAttribute(n,"true")}catch(x){console.error("aria-hidden: cannot operate on ",f,x)}})};return d(e),l.clear(),k4++,function(){a.forEach(function(h){var f=Jv.get(h)-1,p=i.get(h)-1;Jv.set(h,f),i.set(h,p),f||(nT.has(h)||h.removeAttribute(n),nT.delete(h)),p||h.removeAttribute(r)}),k4--,k4||(Jv=new WeakMap,Jv=new WeakMap,nT=new WeakMap,sT={})}},fD=function(t,e,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),s=e6e(t);return s?(n.push.apply(n,Array.from(s.querySelectorAll("[aria-live]"))),r6e(n,s,r,"aria-hidden")):function(){return null}},Qu=function(){return Qu=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},Qu.apply(this,arguments)};function Kpe(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 n6e(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 K2="right-scroll-bar-position",Y2="width-before-scroll-bar",s6e="with-scroll-bars-hidden",i6e="--removed-body-scroll-bar-size";function C4(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function a6e(t,e){var r=S.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 o6e=typeof window<"u"?S.useLayoutEffect:S.useEffect,jQ=new WeakMap;function l6e(t,e){var r=a6e(null,function(n){return t.forEach(function(s){return C4(s,n)})});return o6e(function(){var n=jQ.get(r);if(n){var s=new Set(n),i=new Set(t),a=r.current;s.forEach(function(l){i.has(l)||C4(l,null)}),i.forEach(function(l){s.has(l)||C4(l,a)})}jQ.set(r,t)},[t]),r}function c6e(t){return t}function u6e(t,e){e===void 0&&(e=c6e);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(l){return l!==a})}},assignSyncMedium:function(i){for(n=!0;r.length;){var a=r;r=[],a.forEach(i)}r={push:function(l){return i(l)},filter:function(){return r}}},assignMedium:function(i){n=!0;var a=[];if(r.length){var l=r;r=[],l.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 d6e(t){t===void 0&&(t={});var e=u6e(null);return e.options=Qu({async:!0,ssr:!1},t),e}var Ype=function(t){var e=t.sideCar,r=Kpe(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 S.createElement(n,Qu({},r))};Ype.isSideCarExport=!0;function h6e(t,e){return t.useMedium(e),Ype}var Xpe=d6e(),E4=function(){},pD=S.forwardRef(function(t,e){var r=S.useRef(null),n=S.useState({onScrollCapture:E4,onWheelCapture:E4,onTouchMoveCapture:E4}),s=n[0],i=n[1],a=t.forwardProps,l=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,y=t.allowPinchZoom,x=t.as,v=x===void 0?"div":x,b=t.gapMode,w=Kpe(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=f,N=l6e([r,e]),C=Qu(Qu({},w),s);return S.createElement(S.Fragment,null,d&&S.createElement(j,{sideCar:Xpe,removeScrollBar:u,shards:h,noRelative:p,noIsolation:m,inert:g,setCallbacks:i,allowPinchZoom:!!y,lockRef:r,gapMode:b}),a?S.cloneElement(S.Children.only(l),Qu(Qu({},C),{ref:N})):S.createElement(v,Qu({},C,{className:c,ref:N}),l))});pD.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};pD.classNames={fullWidth:Y2,zeroRight:K2};var f6e=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function p6e(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=f6e();return e&&t.setAttribute("nonce",e),t}function m6e(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function g6e(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var x6e=function(){var t=0,e=null;return{add:function(r){t==0&&(e=p6e())&&(m6e(e,r),g6e(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},y6e=function(){var t=x6e();return function(e,r){S.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&r])}},Qpe=function(){var t=y6e(),e=function(r){var n=r.styles,s=r.dynamic;return t(n,s),null};return e},v6e={left:0,top:0,right:0,gap:0},A4=function(t){return parseInt(t||"",10)||0},b6e=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[A4(r),A4(n),A4(s)]},w6e=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return v6e;var e=b6e(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])}},j6e=Qpe(),m0="data-scroll-locked",S6e=function(t,e,r,n){var s=t.left,i=t.top,a=t.right,l=t.gap;return r===void 0&&(r="margin"),`
  .`.concat(s6e,` {
   overflow: hidden `).concat(n,`;
   padding-right: `).concat(l,"px ").concat(n,`;
  }
  body[`).concat(m0,`] {
    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(l,"px ").concat(n,`;
    `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(n,";")].filter(Boolean).join(""),`
  }
  
  .`).concat(K2,` {
    right: `).concat(l,"px ").concat(n,`;
  }
  
  .`).concat(Y2,` {
    margin-right: `).concat(l,"px ").concat(n,`;
  }
  
  .`).concat(K2," .").concat(K2,` {
    right: 0 `).concat(n,`;
  }
  
  .`).concat(Y2," .").concat(Y2,` {
    margin-right: 0 `).concat(n,`;
  }
  
  body[`).concat(m0,`] {
    `).concat(i6e,": ").concat(l,`px;
  }
`)},SQ=function(){var t=parseInt(document.body.getAttribute(m0)||"0",10);return isFinite(t)?t:0},_6e=function(){S.useEffect(function(){return document.body.setAttribute(m0,(SQ()+1).toString()),function(){var t=SQ()-1;t<=0?document.body.removeAttribute(m0):document.body.setAttribute(m0,t.toString())}},[])},N6e=function(t){var e=t.noRelative,r=t.noImportant,n=t.gapMode,s=n===void 0?"margin":n;_6e();var i=S.useMemo(function(){return w6e(s)},[s]);return S.createElement(j6e,{styles:S6e(i,!e,s,r?"":"!important")})},f8=!1;if(typeof window<"u")try{var iT=Object.defineProperty({},"passive",{get:function(){return f8=!0,!0}});window.addEventListener("test",iT,iT),window.removeEventListener("test",iT,iT)}catch{f8=!1}var eb=f8?{passive:!1}:!1,k6e=function(t){return t.tagName==="TEXTAREA"},Zpe=function(t,e){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[e]!=="hidden"&&!(r.overflowY===r.overflowX&&!k6e(t)&&r[e]==="visible")},C6e=function(t){return Zpe(t,"overflowY")},E6e=function(t){return Zpe(t,"overflowX")},_Q=function(t,e){var r=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var s=Jpe(t,n);if(s){var i=eme(t,n),a=i[1],l=i[2];if(a>l)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},A6e=function(t){var e=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[e,r,n]},T6e=function(t){var e=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[e,r,n]},Jpe=function(t,e){return t==="v"?C6e(e):E6e(e)},eme=function(t,e){return t==="v"?A6e(e):T6e(e)},P6e=function(t,e){return t==="h"&&e==="rtl"?-1:1},I6e=function(t,e,r,n,s){var i=P6e(t,window.getComputedStyle(e).direction),a=i*n,l=r.target,c=e.contains(l),u=!1,d=a>0,h=0,f=0;do{if(!l)break;var p=eme(t,l),m=p[0],g=p[1],y=p[2],x=g-y-i*m;(m||x)&&Jpe(t,l)&&(h+=x,f+=m);var v=l.parentNode;l=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!c&&l!==document.body||c&&(e.contains(l)||e===l));return(d&&(Math.abs(h)<1||!s)||!d&&(Math.abs(f)<1||!s))&&(u=!0),u},aT=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},NQ=function(t){return[t.deltaX,t.deltaY]},kQ=function(t){return t&&"current"in t?t.current:t},R6e=function(t,e){return t[0]===e[0]&&t[1]===e[1]},O6e=function(t){return`
  .block-interactivity-`.concat(t,` {pointer-events: none;}
  .allow-interactivity-`).concat(t,` {pointer-events: all;}
`)},M6e=0,tb=[];function D6e(t){var e=S.useRef([]),r=S.useRef([0,0]),n=S.useRef(),s=S.useState(M6e++)[0],i=S.useState(Qpe)[0],a=S.useRef(t);S.useEffect(function(){a.current=t},[t]),S.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var g=n6e([t.lockRef.current],(t.shards||[]).map(kQ),!0).filter(Boolean);return g.forEach(function(y){return y.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),g.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var l=S.useCallback(function(g,y){if("touches"in g&&g.touches.length===2||g.type==="wheel"&&g.ctrlKey)return!a.current.allowPinchZoom;var x=aT(g),v=r.current,b="deltaX"in g?g.deltaX:v[0]-x[0],w="deltaY"in g?g.deltaY:v[1]-x[1],j,N=g.target,C=Math.abs(b)>Math.abs(w)?"h":"v";if("touches"in g&&C==="h"&&N.type==="range")return!1;var A=_Q(C,N);if(!A)return!0;if(A?j=C:(j=C==="v"?"h":"v",A=_Q(C,N)),!A)return!1;if(!n.current&&"changedTouches"in g&&(b||w)&&(n.current=j),!j)return!0;var E=n.current||j;return I6e(E,y,g,E==="h"?b:w,!0)},[]),c=S.useCallback(function(g){var y=g;if(!(!tb.length||tb[tb.length-1]!==i)){var x="deltaY"in y?NQ(y):aT(y),v=e.current.filter(function(j){return j.name===y.type&&(j.target===y.target||y.target===j.shadowParent)&&R6e(j.delta,x)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var b=(a.current.shards||[]).map(kQ).filter(Boolean).filter(function(j){return j.contains(y.target)}),w=b.length>0?l(y,b[0]):!a.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),u=S.useCallback(function(g,y,x,v){var b={name:g,delta:y,target:x,should:v,shadowParent:L6e(x)};e.current.push(b),setTimeout(function(){e.current=e.current.filter(function(w){return w!==b})},1)},[]),d=S.useCallback(function(g){r.current=aT(g),n.current=void 0},[]),h=S.useCallback(function(g){u(g.type,NQ(g),g.target,l(g,t.lockRef.current))},[]),f=S.useCallback(function(g){u(g.type,aT(g),g.target,l(g,t.lockRef.current))},[]);S.useEffect(function(){return tb.push(i),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,eb),document.addEventListener("touchmove",c,eb),document.addEventListener("touchstart",d,eb),function(){tb=tb.filter(function(g){return g!==i}),document.removeEventListener("wheel",c,eb),document.removeEventListener("touchmove",c,eb),document.removeEventListener("touchstart",d,eb)}},[]);var p=t.removeScrollBar,m=t.inert;return S.createElement(S.Fragment,null,m?S.createElement(i,{styles:O6e(s)}):null,p?S.createElement(N6e,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function L6e(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const $6e=h6e(Xpe,D6e);var $E=S.forwardRef(function(t,e){return S.createElement(pD,Qu({},t,{ref:e,sideCar:$6e}))});$E.classNames=pD.classNames;var p8=["Enter"," "],F6e=["ArrowDown","PageUp","Home"],tme=["ArrowUp","PageDown","End"],B6e=[...F6e,...tme],z6e={ltr:[...p8,"ArrowRight"],rtl:[...p8,"ArrowLeft"]},U6e={ltr:["ArrowLeft"],rtl:["ArrowRight"]},FE="Menu",[RN,H6e,W6e]=CE(FE),[Pv,rme]=Vs(FE,[W6e,ig,fj]),mD=ig(),nme=fj(),[V6e,Iv]=Pv(FE),[q6e,BE]=Pv(FE),sme=t=>{const{__scopeMenu:e,open:r=!1,children:n,dir:s,onOpenChange:i,modal:a=!0}=t,l=mD(e),[c,u]=S.useState(null),d=S.useRef(!1),h=ys(i),f=Tv(s);return S.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})}},[]),o.jsx(YM,{...l,children:o.jsx(V6e,{scope:e,open:r,onOpenChange:h,content:c,onContentChange:u,children:o.jsx(q6e,{scope:e,onClose:S.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:d,dir:f,modal:a,children:n})})})};sme.displayName=FE;var G6e="MenuAnchor",x9=S.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=mD(r);return o.jsx(IE,{...s,...n,ref:e})});x9.displayName=G6e;var y9="MenuPortal",[K6e,ime]=Pv(y9,{forceMount:void 0}),ame=t=>{const{__scopeMenu:e,forceMount:r,children:n,container:s}=t,i=Iv(y9,e);return o.jsx(K6e,{scope:e,forceMount:r,children:o.jsx(pi,{present:r||i.open,children:o.jsx(tj,{asChild:!0,container:s,children:n})})})};ame.displayName=y9;var ec="MenuContent",[Y6e,v9]=Pv(ec),ome=S.forwardRef((t,e)=>{const r=ime(ec,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,i=Iv(ec,t.__scopeMenu),a=BE(ec,t.__scopeMenu);return o.jsx(RN.Provider,{scope:t.__scopeMenu,children:o.jsx(pi,{present:n||i.open,children:o.jsx(RN.Slot,{scope:t.__scopeMenu,children:a.modal?o.jsx(X6e,{...s,ref:e}):o.jsx(Q6e,{...s,ref:e})})})})}),X6e=S.forwardRef((t,e)=>{const r=Iv(ec,t.__scopeMenu),n=S.useRef(null),s=qt(e,n);return S.useEffect(()=>{const i=n.current;if(i)return fD(i)},[]),o.jsx(b9,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Qe(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),Q6e=S.forwardRef((t,e)=>{const r=Iv(ec,t.__scopeMenu);return o.jsx(b9,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Z6e=zm("MenuContent.ScrollLock"),b9=S.forwardRef((t,e)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...g}=t,y=Iv(ec,r),x=BE(ec,r),v=mD(r),b=nme(r),w=H6e(r),[j,N]=S.useState(null),C=S.useRef(null),A=qt(e,C,y.onContentChange),E=S.useRef(0),O=S.useRef(""),$=S.useRef(0),T=S.useRef(null),M=S.useRef("right"),k=S.useRef(0),D=m?$E:S.Fragment,K=m?{as:Z6e,allowPinchZoom:!0}:void 0,H=V=>{var q,L;const B=O.current+V,z=w().filter(Z=>!Z.disabled),F=document.activeElement,G=(q=z.find(Z=>Z.ref.current===F))==null?void 0:q.textValue,Q=z.map(Z=>Z.textValue),ie=uBe(Q,B,G),se=(L=z.find(Z=>Z.textValue===ie))==null?void 0:L.ref.current;(function Z(J){O.current=J,window.clearTimeout(E.current),J!==""&&(E.current=window.setTimeout(()=>Z(""),1e3))})(B),se&&setTimeout(()=>se.focus())};S.useEffect(()=>()=>window.clearTimeout(E.current),[]),hD();const ee=S.useCallback(V=>{var z,F;return M.current===((z=T.current)==null?void 0:z.side)&&hBe(V,(F=T.current)==null?void 0:F.area)},[]);return o.jsx(Y6e,{scope:r,searchRef:O,onItemEnter:S.useCallback(V=>{ee(V)&&V.preventDefault()},[ee]),onItemLeave:S.useCallback(V=>{var B;ee(V)||((B=C.current)==null||B.focus(),N(null))},[ee]),onTriggerLeave:S.useCallback(V=>{ee(V)&&V.preventDefault()},[ee]),pointerGraceTimerRef:$,onPointerGraceIntentChange:S.useCallback(V=>{T.current=V},[]),children:o.jsx(D,{...K,children:o.jsx(DE,{asChild:!0,trapped:s,onMountAutoFocus:Qe(i,V=>{var B;V.preventDefault(),(B=C.current)==null||B.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:o.jsx(Ev,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:h,onInteractOutside:f,onDismiss:p,children:o.jsx(m9,{asChild:!0,...b,dir:x.dir,orientation:"vertical",loop:n,currentTabStopId:j,onCurrentTabStopIdChange:N,onEntryFocus:Qe(c,V=>{x.isUsingKeyboardRef.current||V.preventDefault()}),preventScrollOnEntryFocus:!0,children:o.jsx(XM,{role:"menu","aria-orientation":"vertical","data-state":Sme(y.open),"data-radix-menu-content":"",dir:x.dir,...v,...g,ref:A,style:{outline:"none",...g.style},onKeyDown:Qe(g.onKeyDown,V=>{const z=V.target.closest("[data-radix-menu-content]")===V.currentTarget,F=V.ctrlKey||V.altKey||V.metaKey,G=V.key.length===1;z&&(V.key==="Tab"&&V.preventDefault(),!F&&G&&H(V.key));const Q=C.current;if(V.target!==Q||!B6e.includes(V.key))return;V.preventDefault();const se=w().filter(q=>!q.disabled).map(q=>q.ref.current);tme.includes(V.key)&&se.reverse(),lBe(se)}),onBlur:Qe(t.onBlur,V=>{V.currentTarget.contains(V.target)||(window.clearTimeout(E.current),O.current="")}),onPointerMove:Qe(t.onPointerMove,ON(V=>{const B=V.target,z=k.current!==V.clientX;if(V.currentTarget.contains(B)&&z){const F=V.clientX>k.current?"right":"left";M.current=F,k.current=V.clientX}}))})})})})})})});ome.displayName=ec;var J6e="MenuGroup",w9=S.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return o.jsx(ft.div,{role:"group",...n,ref:e})});w9.displayName=J6e;var eBe="MenuLabel",lme=S.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return o.jsx(ft.div,{...n,ref:e})});lme.displayName=eBe;var II="MenuItem",CQ="menu.itemSelect",gD=S.forwardRef((t,e)=>{const{disabled:r=!1,onSelect:n,...s}=t,i=S.useRef(null),a=BE(II,t.__scopeMenu),l=v9(II,t.__scopeMenu),c=qt(e,i),u=S.useRef(!1),d=()=>{const h=i.current;if(!r&&h){const f=new CustomEvent(CQ,{bubbles:!0,cancelable:!0});h.addEventListener(CQ,p=>n==null?void 0:n(p),{once:!0}),MW(h,f),f.defaultPrevented?u.current=!1:a.onClose()}};return o.jsx(cme,{...s,ref:c,disabled:r,onClick:Qe(t.onClick,d),onPointerDown:h=>{var f;(f=t.onPointerDown)==null||f.call(t,h),u.current=!0},onPointerUp:Qe(t.onPointerUp,h=>{var f;u.current||(f=h.currentTarget)==null||f.click()}),onKeyDown:Qe(t.onKeyDown,h=>{const f=l.searchRef.current!=="";r||f&&h.key===" "||p8.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});gD.displayName=II;var cme=S.forwardRef((t,e)=>{const{__scopeMenu:r,disabled:n=!1,textValue:s,...i}=t,a=v9(II,r),l=nme(r),c=S.useRef(null),u=qt(e,c),[d,h]=S.useState(!1),[f,p]=S.useState("");return S.useEffect(()=>{const m=c.current;m&&p((m.textContent??"").trim())},[i.children]),o.jsx(RN.ItemSlot,{scope:r,disabled:n,textValue:s??f,children:o.jsx(g9,{asChild:!0,...l,focusable:!n,children:o.jsx(ft.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...i,ref:u,onPointerMove:Qe(t.onPointerMove,ON(m=>{n?a.onItemLeave(m):(a.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Qe(t.onPointerLeave,ON(m=>a.onItemLeave(m))),onFocus:Qe(t.onFocus,()=>h(!0)),onBlur:Qe(t.onBlur,()=>h(!1))})})})}),tBe="MenuCheckboxItem",ume=S.forwardRef((t,e)=>{const{checked:r=!1,onCheckedChange:n,...s}=t;return o.jsx(mme,{scope:t.__scopeMenu,checked:r,children:o.jsx(gD,{role:"menuitemcheckbox","aria-checked":RI(r)?"mixed":r,...s,ref:e,"data-state":S9(r),onSelect:Qe(s.onSelect,()=>n==null?void 0:n(RI(r)?!0:!r),{checkForDefaultPrevented:!1})})})});ume.displayName=tBe;var dme="MenuRadioGroup",[rBe,nBe]=Pv(dme,{value:void 0,onValueChange:()=>{}}),hme=S.forwardRef((t,e)=>{const{value:r,onValueChange:n,...s}=t,i=ys(n);return o.jsx(rBe,{scope:t.__scopeMenu,value:r,onValueChange:i,children:o.jsx(w9,{...s,ref:e})})});hme.displayName=dme;var fme="MenuRadioItem",pme=S.forwardRef((t,e)=>{const{value:r,...n}=t,s=nBe(fme,t.__scopeMenu),i=r===s.value;return o.jsx(mme,{scope:t.__scopeMenu,checked:i,children:o.jsx(gD,{role:"menuitemradio","aria-checked":i,...n,ref:e,"data-state":S9(i),onSelect:Qe(n.onSelect,()=>{var a;return(a=s.onValueChange)==null?void 0:a.call(s,r)},{checkForDefaultPrevented:!1})})})});pme.displayName=fme;var j9="MenuItemIndicator",[mme,sBe]=Pv(j9,{checked:!1}),gme=S.forwardRef((t,e)=>{const{__scopeMenu:r,forceMount:n,...s}=t,i=sBe(j9,r);return o.jsx(pi,{present:n||RI(i.checked)||i.checked===!0,children:o.jsx(ft.span,{...s,ref:e,"data-state":S9(i.checked)})})});gme.displayName=j9;var iBe="MenuSeparator",xme=S.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return o.jsx(ft.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});xme.displayName=iBe;var aBe="MenuArrow",yme=S.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=mD(r);return o.jsx(QM,{...s,...n,ref:e})});yme.displayName=aBe;var oBe="MenuSub",[yWt,vme]=Pv(oBe),FS="MenuSubTrigger",bme=S.forwardRef((t,e)=>{const r=Iv(FS,t.__scopeMenu),n=BE(FS,t.__scopeMenu),s=vme(FS,t.__scopeMenu),i=v9(FS,t.__scopeMenu),a=S.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=i,u={__scopeMenu:t.__scopeMenu},d=S.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return S.useEffect(()=>d,[d]),S.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),c(null)}},[l,c]),o.jsx(x9,{asChild:!0,...u,children:o.jsx(cme,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":Sme(r.open),...t,ref:FM(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:Qe(t.onPointerMove,ON(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:Qe(t.onPointerLeave,ON(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,y=g==="right",x=y?-5:5,v=f[y?"left":"right"],b=f[y?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+x,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(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Qe(t.onKeyDown,h=>{var p;const f=i.searchRef.current!=="";t.disabled||f&&h.key===" "||z6e[n.dir].includes(h.key)&&(r.onOpenChange(!0),(p=r.content)==null||p.focus(),h.preventDefault())})})})});bme.displayName=FS;var wme="MenuSubContent",jme=S.forwardRef((t,e)=>{const r=ime(ec,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,i=Iv(ec,t.__scopeMenu),a=BE(ec,t.__scopeMenu),l=vme(wme,t.__scopeMenu),c=S.useRef(null),u=qt(e,c);return o.jsx(RN.Provider,{scope:t.__scopeMenu,children:o.jsx(pi,{present:n||i.open,children:o.jsx(RN.Slot,{scope:t.__scopeMenu,children:o.jsx(b9,{id:l.contentId,"aria-labelledby":l.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:Qe(t.onFocusOutside,d=>{d.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Qe(t.onEscapeKeyDown,d=>{a.onClose(),d.preventDefault()}),onKeyDown:Qe(t.onKeyDown,d=>{var p;const h=d.currentTarget.contains(d.target),f=U6e[a.dir].includes(d.key);h&&f&&(i.onOpenChange(!1),(p=l.trigger)==null||p.focus(),d.preventDefault())})})})})})});jme.displayName=wme;function Sme(t){return t?"open":"closed"}function RI(t){return t==="indeterminate"}function S9(t){return RI(t)?"indeterminate":t?"checked":"unchecked"}function lBe(t){const e=document.activeElement;for(const r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function cBe(t,e){return t.map((r,n)=>t[(e+n)%t.length])}function uBe(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=cBe(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 dBe(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 l=e[i],c=e[a],u=l.x,d=l.y,h=c.x,f=c.y;d>n!=f>n&&r<(h-u)*(n-d)/(f-d)+u&&(s=!s)}return s}function hBe(t,e){if(!e)return!1;const r={x:t.clientX,y:t.clientY};return dBe(r,e)}function ON(t){return e=>e.pointerType==="mouse"?t(e):void 0}var fBe=sme,pBe=x9,mBe=ame,gBe=ome,xBe=w9,yBe=lme,vBe=gD,bBe=ume,wBe=hme,jBe=pme,SBe=gme,_Be=xme,NBe=yme,kBe=bme,CBe=jme,xD="DropdownMenu",[EBe,vWt]=Vs(xD,[rme]),to=rme(),[ABe,_me]=EBe(xD),Nme=t=>{const{__scopeDropdownMenu:e,children:r,dir:n,open:s,defaultOpen:i,onOpenChange:a,modal:l=!0}=t,c=to(e),u=S.useRef(null),[d,h]=ca({prop:s,defaultProp:i??!1,onChange:a,caller:xD});return o.jsx(ABe,{scope:e,triggerId:Co(),triggerRef:u,contentId:Co(),open:d,onOpenChange:h,onOpenToggle:S.useCallback(()=>h(f=>!f),[h]),modal:l,children:o.jsx(fBe,{...c,open:d,onOpenChange:h,dir:n,modal:l,children:r})})};Nme.displayName=xD;var kme="DropdownMenuTrigger",Cme=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...s}=t,i=_me(kme,r),a=to(r);return o.jsx(pBe,{asChild:!0,...a,children:o.jsx(ft.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:FM(e,i.triggerRef),onPointerDown:Qe(t.onPointerDown,l=>{!n&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:Qe(t.onKeyDown,l=>{n||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});Cme.displayName=kme;var TBe="DropdownMenuPortal",Eme=t=>{const{__scopeDropdownMenu:e,...r}=t,n=to(e);return o.jsx(mBe,{...n,...r})};Eme.displayName=TBe;var Ame="DropdownMenuContent",Tme=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=_me(Ame,r),i=to(r),a=S.useRef(!1);return o.jsx(gBe,{id:s.contentId,"aria-labelledby":s.triggerId,...i,...n,ref:e,onCloseAutoFocus:Qe(t.onCloseAutoFocus,l=>{var c;a.current||(c=s.triggerRef.current)==null||c.focus(),a.current=!1,l.preventDefault()}),onInteractOutside:Qe(t.onInteractOutside,l=>{const c=l.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)"}})});Tme.displayName=Ame;var PBe="DropdownMenuGroup",IBe=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(xBe,{...s,...n,ref:e})});IBe.displayName=PBe;var RBe="DropdownMenuLabel",Pme=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(yBe,{...s,...n,ref:e})});Pme.displayName=RBe;var OBe="DropdownMenuItem",Ime=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(vBe,{...s,...n,ref:e})});Ime.displayName=OBe;var MBe="DropdownMenuCheckboxItem",Rme=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(bBe,{...s,...n,ref:e})});Rme.displayName=MBe;var DBe="DropdownMenuRadioGroup",LBe=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(wBe,{...s,...n,ref:e})});LBe.displayName=DBe;var $Be="DropdownMenuRadioItem",Ome=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(jBe,{...s,...n,ref:e})});Ome.displayName=$Be;var FBe="DropdownMenuItemIndicator",Mme=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(SBe,{...s,...n,ref:e})});Mme.displayName=FBe;var BBe="DropdownMenuSeparator",Dme=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(_Be,{...s,...n,ref:e})});Dme.displayName=BBe;var zBe="DropdownMenuArrow",UBe=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(NBe,{...s,...n,ref:e})});UBe.displayName=zBe;var HBe="DropdownMenuSubTrigger",Lme=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(kBe,{...s,...n,ref:e})});Lme.displayName=HBe;var WBe="DropdownMenuSubContent",$me=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=to(r);return o.jsx(CBe,{...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)"}})});$me.displayName=WBe;var VBe=Nme,qBe=Cme,GBe=Eme,Fme=Tme,Bme=Pme,zme=Ime,Ume=Rme,Hme=Ome,Wme=Mme,Vme=Dme,qme=Lme,Gme=$me;const _9=VBe,N9=qBe,KBe=S.forwardRef(({className:t,inset:e,children:r,...n},s)=>o.jsxs(qme,{ref:s,className:Pe("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,o.jsx(AE,{className:"ml-auto h-4 w-4"})]}));KBe.displayName=qme.displayName;const YBe=S.forwardRef(({className:t,...e},r)=>o.jsx(Gme,{ref:r,className:Pe("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}));YBe.displayName=Gme.displayName;const yD=S.forwardRef(({className:t,sideOffset:e=4,...r},n)=>o.jsx(GBe,{children:o.jsx(Fme,{ref:n,sideOffset:e,className:Pe("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})}));yD.displayName=Fme.displayName;const Ha=S.forwardRef(({className:t,inset:e,...r},n)=>o.jsx(zme,{ref:n,className:Pe("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}));Ha.displayName=zme.displayName;const XBe=S.forwardRef(({className:t,children:e,checked:r,...n},s)=>o.jsxs(Ume,{ref:s,className:Pe("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:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(Wme,{children:o.jsx(kr,{className:"h-4 w-4"})})}),e]}));XBe.displayName=Ume.displayName;const QBe=S.forwardRef(({className:t,children:e,...r},n)=>o.jsxs(Hme,{ref:n,className:Pe("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:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(Wme,{children:o.jsx(n1,{className:"h-2 w-2 fill-current"})})}),e]}));QBe.displayName=Hme.displayName;const ZBe=S.forwardRef(({className:t,inset:e,...r},n)=>o.jsx(Bme,{ref:n,className:Pe("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...r}));ZBe.displayName=Bme.displayName;const g0=S.forwardRef(({className:t,...e},r)=>o.jsx(Vme,{ref:r,className:Pe("-mx-1 my-1 h-px bg-muted",t),...e}));g0.displayName=Vme.displayName;var Kme={exports:{}},Yme={};/**
 * @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 c1=S;function JBe(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var e8e=typeof Object.is=="function"?Object.is:JBe,t8e=c1.useState,r8e=c1.useEffect,n8e=c1.useLayoutEffect,s8e=c1.useDebugValue;function i8e(t,e){var r=e(),n=t8e({inst:{value:r,getSnapshot:e}}),s=n[0].inst,i=n[1];return n8e(function(){s.value=r,s.getSnapshot=e,T4(s)&&i({inst:s})},[t,r,e]),r8e(function(){return T4(s)&&i({inst:s}),t(function(){T4(s)&&i({inst:s})})},[t]),s8e(r),r}function T4(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!e8e(t,r)}catch{return!0}}function a8e(t,e){return e()}var o8e=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?a8e:i8e;Yme.useSyncExternalStore=c1.useSyncExternalStore!==void 0?c1.useSyncExternalStore:o8e;Kme.exports=Yme;var vD=Kme.exports;function l8e(){return vD.useSyncExternalStore(c8e,()=>!0,()=>!1)}function c8e(){return()=>{}}var k9="Avatar",[u8e,bWt]=Vs(k9),[d8e,Xme]=u8e(k9),Qme=S.forwardRef((t,e)=>{const{__scopeAvatar:r,...n}=t,[s,i]=S.useState("idle");return o.jsx(d8e,{scope:r,imageLoadingStatus:s,onImageLoadingStatusChange:i,children:o.jsx(ft.span,{...n,ref:e})})});Qme.displayName=k9;var Zme="AvatarImage",Jme=S.forwardRef((t,e)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:s=()=>{},...i}=t,a=Xme(Zme,r),l=h8e(n,i),c=ys(u=>{s(u),a.onImageLoadingStatusChange(u)});return bs(()=>{l!=="idle"&&c(l)},[l,c]),l==="loaded"?o.jsx(ft.img,{...i,ref:e,src:n}):null});Jme.displayName=Zme;var ege="AvatarFallback",tge=S.forwardRef((t,e)=>{const{__scopeAvatar:r,delayMs:n,...s}=t,i=Xme(ege,r),[a,l]=S.useState(n===void 0);return S.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>l(!0),n);return()=>window.clearTimeout(c)}},[n]),a&&i.imageLoadingStatus!=="loaded"?o.jsx(ft.span,{...s,ref:e}):null});tge.displayName=ege;function EQ(t,e){return t?e?(t.src!==e&&(t.src=e),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function h8e(t,{referrerPolicy:e,crossOrigin:r}){const n=l8e(),s=S.useRef(null),i=n?(s.current||(s.current=new window.Image),s.current):null,[a,l]=S.useState(()=>EQ(i,t));return bs(()=>{l(EQ(i,t))},[i,t]),bs(()=>{const c=h=>()=>{l(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 rge=Qme,nge=Jme,sge=tge;const C9=S.forwardRef(({className:t,...e},r)=>o.jsx(rge,{ref:r,className:Pe("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...e}));C9.displayName=rge.displayName;const E9=S.forwardRef(({className:t,...e},r)=>o.jsx(nge,{ref:r,className:Pe("aspect-square h-full w-full",t),...e}));E9.displayName=nge.displayName;const A9=S.forwardRef(({className:t,...e},r)=>o.jsx(sge,{ref:r,className:Pe("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...e}));A9.displayName=sge.displayName;const ige=S.createContext(void 0),f8e=({children:t})=>{const[e,r]=S.useState(()=>localStorage.getItem("theme")||"light");S.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 o.jsx(ige.Provider,{value:{theme:e,toggleTheme:n},children:t})},T9=()=>{const t=S.useContext(ige);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t};function p8e(){const{toggleTheme:t}=T9();return o.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:[o.jsx(EMe,{className:"hidden h-5 w-5 dark:block"}),o.jsx(UW,{className:"h-5 w-5 dark:hidden"})]})}var bD="Dialog",[age,oge]=Vs(bD),[m8e,au]=age(bD),lge=t=>{const{__scopeDialog:e,children:r,open:n,defaultOpen:s,onOpenChange:i,modal:a=!0}=t,l=S.useRef(null),c=S.useRef(null),[u,d]=ca({prop:n,defaultProp:s??!1,onChange:i,caller:bD});return o.jsx(m8e,{scope:e,triggerRef:l,contentRef:c,contentId:Co(),titleId:Co(),descriptionId:Co(),open:u,onOpenChange:d,onOpenToggle:S.useCallback(()=>d(h=>!h),[d]),modal:a,children:r})};lge.displayName=bD;var cge="DialogTrigger",uge=S.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=au(cge,r),i=qt(e,s.triggerRef);return o.jsx(ft.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":R9(s.open),...n,ref:i,onClick:Qe(t.onClick,s.onOpenToggle)})});uge.displayName=cge;var P9="DialogPortal",[g8e,dge]=age(P9,{forceMount:void 0}),hge=t=>{const{__scopeDialog:e,forceMount:r,children:n,container:s}=t,i=au(P9,e);return o.jsx(g8e,{scope:e,forceMount:r,children:S.Children.map(n,a=>o.jsx(pi,{present:r||i.open,children:o.jsx(tj,{asChild:!0,container:s,children:a})}))})};hge.displayName=P9;var OI="DialogOverlay",fge=S.forwardRef((t,e)=>{const r=dge(OI,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,i=au(OI,t.__scopeDialog);return i.modal?o.jsx(pi,{present:n||i.open,children:o.jsx(y8e,{...s,ref:e})}):null});fge.displayName=OI;var x8e=zm("DialogOverlay.RemoveScroll"),y8e=S.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=au(OI,r);return o.jsx($E,{as:x8e,allowPinchZoom:!0,shards:[s.contentRef],children:o.jsx(ft.div,{"data-state":R9(s.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),lv="DialogContent",pge=S.forwardRef((t,e)=>{const r=dge(lv,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,i=au(lv,t.__scopeDialog);return o.jsx(pi,{present:n||i.open,children:i.modal?o.jsx(v8e,{...s,ref:e}):o.jsx(b8e,{...s,ref:e})})});pge.displayName=lv;var v8e=S.forwardRef((t,e)=>{const r=au(lv,t.__scopeDialog),n=S.useRef(null),s=qt(e,r.contentRef,n);return S.useEffect(()=>{const i=n.current;if(i)return fD(i)},[]),o.jsx(mge,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qe(t.onCloseAutoFocus,i=>{var a;i.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Qe(t.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:Qe(t.onFocusOutside,i=>i.preventDefault())})}),b8e=S.forwardRef((t,e)=>{const r=au(lv,t.__scopeDialog),n=S.useRef(!1),s=S.useRef(!1);return o.jsx(mge,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,l;(a=t.onCloseAutoFocus)==null||a.call(t,i),i.defaultPrevented||(n.current||(l=r.triggerRef.current)==null||l.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()}})}),mge=S.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:i,...a}=t,l=au(lv,r),c=S.useRef(null),u=qt(e,c);return hD(),o.jsxs(o.Fragment,{children:[o.jsx(DE,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:i,children:o.jsx(Ev,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":R9(l.open),...a,ref:u,onDismiss:()=>l.onOpenChange(!1)})}),o.jsxs(o.Fragment,{children:[o.jsx(j8e,{titleId:l.titleId}),o.jsx(_8e,{contentRef:c,descriptionId:l.descriptionId})]})]})}),I9="DialogTitle",gge=S.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=au(I9,r);return o.jsx(ft.h2,{id:s.titleId,...n,ref:e})});gge.displayName=I9;var xge="DialogDescription",yge=S.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=au(xge,r);return o.jsx(ft.p,{id:s.descriptionId,...n,ref:e})});yge.displayName=xge;var vge="DialogClose",bge=S.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=au(vge,r);return o.jsx(ft.button,{type:"button",...n,ref:e,onClick:Qe(t.onClick,()=>s.onOpenChange(!1))})});bge.displayName=vge;function R9(t){return t?"open":"closed"}var wge="DialogTitleWarning",[w8e,jge]=zRe(wge,{contentName:lv,titleName:I9,docsSlug:"dialog"}),j8e=({titleId:t})=>{const e=jge(wge),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 S.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},S8e="DialogDescriptionWarning",_8e=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${jge(S8e).contentName}}.`;return S.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},O9=lge,M9=uge,D9=hge,zE=fge,UE=pge,HE=gge,WE=yge,wD=bge;const jn=O9,fd=M9,N8e=D9,Sge=S.forwardRef(({className:t,...e},r)=>o.jsx(zE,{ref:r,className:Pe("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}));Sge.displayName=zE.displayName;const pn=S.forwardRef(({className:t,children:e,...r},n)=>o.jsxs(N8e,{children:[o.jsx(Sge,{}),o.jsxs(UE,{ref:n,className:Pe("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,o.jsxs(wD,{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:[o.jsx(fn,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));pn.displayName=UE.displayName;const mn=({className:t,...e})=>o.jsx("div",{className:Pe("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});mn.displayName="DialogHeader";const kf=({className:t,...e})=>o.jsx("div",{className:Pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});kf.displayName="DialogFooter";const gn=S.forwardRef(({className:t,...e},r)=>o.jsx(HE,{ref:r,className:Pe("text-lg font-semibold leading-none tracking-tight",t),...e}));gn.displayName=HE.displayName;const og=S.forwardRef(({className:t,...e},r)=>o.jsx(WE,{ref:r,className:Pe("text-sm text-muted-foreground",t),...e}));og.displayName=WE.displayName;const lr=S.forwardRef(({className:t,...e},r)=>o.jsx("textarea",{className:Pe("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}));lr.displayName="Textarea";function m8(t,[e,r]){return Math.min(r,Math.max(e,t))}function k8e(t,e){return S.useReducer((r,n)=>e[r][n]??r,t)}var L9="ScrollArea",[_ge,wWt]=Vs(L9),[C8e,dc]=_ge(L9),Nge=S.forwardRef((t,e)=>{const{__scopeScrollArea:r,type:n="hover",dir:s,scrollHideDelay:i=600,...a}=t,[l,c]=S.useState(null),[u,d]=S.useState(null),[h,f]=S.useState(null),[p,m]=S.useState(null),[g,y]=S.useState(null),[x,v]=S.useState(0),[b,w]=S.useState(0),[j,N]=S.useState(!1),[C,A]=S.useState(!1),E=qt(e,$=>c($)),O=Tv(s);return o.jsx(C8e,{scope:r,type:n,dir:O,scrollHideDelay:i,scrollArea:l,viewport:u,onViewportChange:d,content:h,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:j,onScrollbarXEnabledChange:N,scrollbarY:g,onScrollbarYChange:y,scrollbarYEnabled:C,onScrollbarYEnabledChange:A,onCornerWidthChange:v,onCornerHeightChange:w,children:o.jsx(ft.div,{dir:O,...a,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":b+"px",...t.style}})})});Nge.displayName=L9;var kge="ScrollAreaViewport",Cge=S.forwardRef((t,e)=>{const{__scopeScrollArea:r,children:n,nonce:s,...i}=t,a=dc(kge,r),l=S.useRef(null),c=qt(e,l,a.onViewportChange);return o.jsxs(o.Fragment,{children:[o.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}),o.jsx(ft.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...t.style},children:o.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});Cge.displayName=kge;var wd="ScrollAreaScrollbar",$9=S.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=dc(wd,t.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=s,l=t.orientation==="horizontal";return S.useEffect(()=>(l?i(!0):a(!0),()=>{l?i(!1):a(!1)}),[l,i,a]),s.type==="hover"?o.jsx(E8e,{...n,ref:e,forceMount:r}):s.type==="scroll"?o.jsx(A8e,{...n,ref:e,forceMount:r}):s.type==="auto"?o.jsx(Ege,{...n,ref:e,forceMount:r}):s.type==="always"?o.jsx(F9,{...n,ref:e}):null});$9.displayName=wd;var E8e=S.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=dc(wd,t.__scopeScrollArea),[i,a]=S.useState(!1);return S.useEffect(()=>{const l=s.scrollArea;let c=0;if(l){const u=()=>{window.clearTimeout(c),a(!0)},d=()=>{c=window.setTimeout(()=>a(!1),s.scrollHideDelay)};return l.addEventListener("pointerenter",u),l.addEventListener("pointerleave",d),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",u),l.removeEventListener("pointerleave",d)}}},[s.scrollArea,s.scrollHideDelay]),o.jsx(pi,{present:r||i,children:o.jsx(Ege,{"data-state":i?"visible":"hidden",...n,ref:e})})}),A8e=S.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=dc(wd,t.__scopeScrollArea),i=t.orientation==="horizontal",a=SD(()=>c("SCROLL_END"),100),[l,c]=k8e("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 S.useEffect(()=>{if(l==="idle"){const u=window.setTimeout(()=>c("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[l,s.scrollHideDelay,c]),S.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]),o.jsx(pi,{present:r||l!=="hidden",children:o.jsx(F9,{"data-state":l==="hidden"?"hidden":"visible",...n,ref:e,onPointerEnter:Qe(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Qe(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),Ege=S.forwardRef((t,e)=>{const r=dc(wd,t.__scopeScrollArea),{forceMount:n,...s}=t,[i,a]=S.useState(!1),l=t.orientation==="horizontal",c=SD(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,d=r.viewport.offsetHeight<r.viewport.scrollHeight;a(l?u:d)}},10);return u1(r.viewport,c),u1(r.content,c),o.jsx(pi,{present:n||i,children:o.jsx(F9,{"data-state":i?"visible":"hidden",...s,ref:e})})}),F9=S.forwardRef((t,e)=>{const{orientation:r="vertical",...n}=t,s=dc(wd,t.__scopeScrollArea),i=S.useRef(null),a=S.useRef(0),[l,c]=S.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Rge(l.viewport,l.content),d={...n,sizes:l,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 M8e(f,a.current,l,p)}return r==="horizontal"?o.jsx(T8e,{...d,ref:e,onThumbPositionChange:()=>{if(s.viewport&&i.current){const f=s.viewport.scrollLeft,p=AQ(f,l,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"?o.jsx(P8e,{...d,ref:e,onThumbPositionChange:()=>{if(s.viewport&&i.current){const f=s.viewport.scrollTop,p=AQ(f,l);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}),T8e=S.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,i=dc(wd,t.__scopeScrollArea),[a,l]=S.useState(),c=S.useRef(null),u=qt(e,c,i.onScrollbarXChange);return S.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),o.jsx(Tge,{"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":jD(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),Mge(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:DI(a.paddingLeft),paddingEnd:DI(a.paddingRight)}})}})}),P8e=S.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,i=dc(wd,t.__scopeScrollArea),[a,l]=S.useState(),c=S.useRef(null),u=qt(e,c,i.onScrollbarYChange);return S.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),o.jsx(Tge,{"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":jD(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),Mge(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:DI(a.paddingTop),paddingEnd:DI(a.paddingBottom)}})}})}),[I8e,Age]=_ge(wd),Tge=S.forwardRef((t,e)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:s,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:d,onResize:h,...f}=t,p=dc(wd,r),[m,g]=S.useState(null),y=qt(e,E=>g(E)),x=S.useRef(null),v=S.useRef(""),b=p.viewport,w=n.content-n.viewport,j=ys(d),N=ys(c),C=SD(h,10);function A(E){if(x.current){const O=E.clientX-x.current.left,$=E.clientY-x.current.top;u({x:O,y:$})}}return S.useEffect(()=>{const E=O=>{const $=O.target;(m==null?void 0:m.contains($))&&j(O,w)};return document.addEventListener("wheel",E,{passive:!1}),()=>document.removeEventListener("wheel",E,{passive:!1})},[b,m,w,j]),S.useEffect(N,[n,N]),u1(m,C),u1(p.content,C),o.jsx(I8e,{scope:r,scrollbar:m,hasThumb:s,onThumbChange:ys(i),onThumbPointerUp:ys(a),onThumbPositionChange:N,onThumbPointerDown:ys(l),children:o.jsx(ft.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Qe(t.onPointerDown,E=>{E.button===0&&(E.target.setPointerCapture(E.pointerId),x.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(E))}),onPointerMove:Qe(t.onPointerMove,A),onPointerUp:Qe(t.onPointerUp,E=>{const O=E.target;O.hasPointerCapture(E.pointerId)&&O.releasePointerCapture(E.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),MI="ScrollAreaThumb",Pge=S.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=Age(MI,t.__scopeScrollArea);return o.jsx(pi,{present:r||s.hasThumb,children:o.jsx(R8e,{ref:e,...n})})}),R8e=S.forwardRef((t,e)=>{const{__scopeScrollArea:r,style:n,...s}=t,i=dc(MI,r),a=Age(MI,r),{onThumbPositionChange:l}=a,c=qt(e,h=>a.onThumbChange(h)),u=S.useRef(void 0),d=SD(()=>{u.current&&(u.current(),u.current=void 0)},100);return S.useEffect(()=>{const h=i.viewport;if(h){const f=()=>{if(d(),!u.current){const p=D8e(h,l);u.current=p,l()}};return l(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[i.viewport,d,l]),o.jsx(ft.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:Qe(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:Qe(t.onPointerUp,a.onThumbPointerUp)})});Pge.displayName=MI;var B9="ScrollAreaCorner",Ige=S.forwardRef((t,e)=>{const r=dc(B9,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?o.jsx(O8e,{...t,ref:e}):null});Ige.displayName=B9;var O8e=S.forwardRef((t,e)=>{const{__scopeScrollArea:r,...n}=t,s=dc(B9,r),[i,a]=S.useState(0),[l,c]=S.useState(0),u=!!(i&&l);return u1(s.scrollbarX,()=>{var h;const d=((h=s.scrollbarX)==null?void 0:h.offsetHeight)||0;s.onCornerHeightChange(d),c(d)}),u1(s.scrollbarY,()=>{var h;const d=((h=s.scrollbarY)==null?void 0:h.offsetWidth)||0;s.onCornerWidthChange(d),a(d)}),u?o.jsx(ft.div,{...n,ref:e,style:{width:i,height:l,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function DI(t){return t?parseInt(t,10):0}function Rge(t,e){const r=t/e;return isNaN(r)?0:r}function jD(t){const e=Rge(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*e;return Math.max(n,18)}function M8e(t,e,r,n="ltr"){const s=jD(r),i=s/2,a=e||i,l=s-a,c=r.scrollbar.paddingStart+a,u=r.scrollbar.size-r.scrollbar.paddingEnd-l,d=r.content-r.viewport,h=n==="ltr"?[0,d]:[d*-1,0];return Oge([c,u],h)(t)}function AQ(t,e,r="ltr"){const n=jD(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,i=e.scrollbar.size-s,a=e.content-e.viewport,l=i-n,c=r==="ltr"?[0,a]:[a*-1,0],u=m8(t,c);return Oge([0,a],[0,l])(u)}function Oge(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 Mge(t,e){return t>0&&t<e}var D8e=(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,l=r.top!==i.top;(a||l)&&e(),r=i,n=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(n)};function SD(t,e){const r=ys(t),n=S.useRef(0);return S.useEffect(()=>()=>window.clearTimeout(n.current),[]),S.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,e)},[r,e])}function u1(t,e){const r=ys(e);bs(()=>{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 Dge=Nge,L8e=Cge,$8e=Ige;const Am=S.forwardRef(({className:t,children:e,...r},n)=>o.jsxs(Dge,{ref:n,className:Pe("relative overflow-hidden",t),...r,children:[o.jsx(L8e,{className:"h-full w-full rounded-[inherit]",children:e}),o.jsx(Lge,{}),o.jsx($8e,{})]}));Am.displayName=Dge.displayName;const Lge=S.forwardRef(({className:t,orientation:e="vertical",...r},n)=>o.jsx($9,{ref:n,orientation:e,className:Pe("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:o.jsx(Pge,{className:"relative flex-1 rounded-full bg-border"})}));Lge.displayName=$9.displayName;var F8e="Separator",TQ="horizontal",B8e=["horizontal","vertical"],$ge=S.forwardRef((t,e)=>{const{decorative:r,orientation:n=TQ,...s}=t,i=z8e(n)?n:TQ,l=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return o.jsx(ft.div,{"data-orientation":i,...l,...s,ref:e})});$ge.displayName=F8e;function z8e(t){return B8e.includes(t)}var Fge=$ge;const Eo=S.forwardRef(({className:t,orientation:e="horizontal",decorative:r=!0,...n},s)=>o.jsx(Fge,{ref:s,decorative:r,orientation:e,className:Pe("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));Eo.displayName=Fge.displayName;function en({className:t,...e}){return o.jsx("div",{className:Pe("animate-pulse rounded-md bg-muted",t),...e})}const U8e="lovable-preview-auth:result";function H8e(t,e){return typeof t!="object"||t===null||!("type"in t)||t.type!==U8e||!("requestId"in t)||t.requestId!==e?null:{ok:"ok"in t&&!!t.ok,value:"value"in t&&typeof t.value=="string"?t.value:null}}function W8e(){var v,b,w;if(typeof window>"u")return;const t=location.hostname,r=["lovableproject.com","lovableproject-dev.com","lovable.app","gpt-eng.com","gptengineer.run"].some(j=>t===j||t.endsWith("."+j)),n="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",s=r?((v=new RegExp("^(?:id-preview(?:-[a-z0-9]+)?|project)--("+n+")(?:-dev)?(?=\\.|$)","i").exec(t))==null?void 0:v[1])??((b=new RegExp("^live--("+n+")(?:-thr_[a-z0-9]+)?(?=\\.|$)","i").exec(t))==null?void 0:b[1])??((w=new RegExp("^("+n+")(?=[.-])","i").exec(t))==null?void 0:w[1]):void 0,i=window.parent;if(!s||!(i!==null&&i!==window))return localStorage;const l=t.endsWith(".lovableproject-dev.com")||t.endsWith(".gpt-eng.com"),c=l?/^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$|^http:\/\/localhost:3000$/:/^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$/,u=location.ancestorOrigins,d=(u==null?void 0:u[0])??(document.referrer?new URL(document.referrer).origin:""),h=d&&c.test(d)?[d]:l?["https://lovable.dev","http://localhost:3000"]:["https://lovable.dev"],f=2e3,p=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),m=(j,N,C)=>new Promise(A=>{const E=p();let O=!1;const $=D=>{O||(O=!0,clearTimeout(M),window.removeEventListener("message",T),A(D))},T=D=>{if(!h.includes(D.origin))return;const K=H8e(D.data,E);K&&$(K)};window.addEventListener("message",T);const M=setTimeout(()=>{$(null)},f),k={type:j,requestId:E,projectId:s,key:N};C!==void 0&&(k.value=C);for(const D of h)window.parent.postMessage(k,D)});let g=!0;const y=250,x=j=>{try{return localStorage.getItem(j)}catch{return}};return{getItem:async j=>{const N=x(j);let C=await m("lovable-preview-auth:get",j,N??void 0);if(!C&&g&&(await new Promise(A=>setTimeout(A,y)),C=await m("lovable-preview-auth:get",j,N??void 0)),g=!1,C!=null&&C.ok&&C.value!==null){if(C.value==="")return N!==void 0&&x(j)===N&&localStorage.removeItem(j),null;if(N===null&&x(j)===null)try{localStorage.setItem(j,C.value)}catch{}return C.value}return localStorage.getItem(j)},setItem:(j,N)=>(localStorage.setItem(j,N),m("lovable-preview-auth:set",j,N).then(C=>{C!=null&&C.ok&&C.value!==null&&localStorage.getItem(j)===N&&(C.value===""?localStorage.removeItem(j):localStorage.setItem(j,C.value))})),removeItem:j=>{const N=x(j);return localStorage.removeItem(j),m("lovable-preview-auth:remove",j,N??void 0).then(()=>{})}}}const V8e="https://nqibmbtqcjucktqcreob.supabase.co",q8e="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5xaWJtYnRxY2p1Y2t0cWNyZW9iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1NTk5MTAsImV4cCI6MjA3MDEzNTkxMH0.UnFk-GqYCZtlkXNlxyHUTaFAnS6Q4hIgDgWKANrxEHg",pe=Fpe(V8e,q8e,{auth:{storage:W8e(),persistSession:!0,autoRefreshToken:!0}});function Xr(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 hf(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function G8e(t,e){const r=Xr(t);return isNaN(e)?hf(t,NaN):(r.setDate(r.getDate()+e),r)}const Bge=6048e5,K8e=864e5,oT=43200,PQ=1440;let Y8e={};function VE(){return Y8e}function MN(t,e){var l,c,u,d;const r=VE(),n=(e==null?void 0:e.weekStartsOn)??((c=(l=e==null?void 0:e.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((d=(u=r.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,s=Xr(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 LI(t){return MN(t,{weekStartsOn:1})}function zge(t){const e=Xr(t),r=e.getFullYear(),n=hf(t,0);n.setFullYear(r+1,0,4),n.setHours(0,0,0,0);const s=LI(n),i=hf(t,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const a=LI(i);return e.getTime()>=s.getTime()?r+1:e.getTime()>=a.getTime()?r:r-1}function $I(t){const e=Xr(t);return e.setHours(0,0,0,0),e}function FI(t){const e=Xr(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 Uge(t,e){const r=$I(t),n=$I(e),s=+r-FI(r),i=+n-FI(n);return Math.round((s-i)/K8e)}function X8e(t){const e=zge(t),r=hf(t,0);return r.setFullYear(e,0,4),r.setHours(0,0,0,0),LI(r)}function X2(t,e){const r=Xr(t),n=Xr(e),s=r.getTime()-n.getTime();return s<0?-1:s>0?1:s}function z9(t){return hf(t,Date.now())}function Hge(t,e){const r=$I(t),n=$I(e);return+r==+n}function Q8e(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Z8e(t){if(!Q8e(t)&&typeof t!="number")return!1;const e=Xr(t);return!isNaN(Number(e))}function J8e(t,e){const r=Xr(t),n=Xr(e),s=r.getFullYear()-n.getFullYear(),i=r.getMonth()-n.getMonth();return s*12+i}function P4(t,e){const r=Xr(t),n=Xr(e),s=IQ(r,n),i=Math.abs(Uge(r,n));r.setDate(r.getDate()-s*i);const a=+(IQ(r,n)===-s),l=s*(i-a);return l===0?0:l}function IQ(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 eze(t){return e=>{const n=(t?Math[t]:Math.trunc)(e);return n===0?0:n}}function tze(t,e){return+Xr(t)-+Xr(e)}function rze(t){const e=Xr(t);return e.setHours(23,59,59,999),e}function nze(t){const e=Xr(t),r=e.getMonth();return e.setFullYear(e.getFullYear(),r+1,0),e.setHours(23,59,59,999),e}function sze(t){const e=Xr(t);return+rze(e)==+nze(e)}function ize(t,e){const r=Xr(t),n=Xr(e),s=X2(r,n),i=Math.abs(J8e(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 l=X2(r,n)===-s;sze(Xr(t))&&i===1&&X2(t,n)===1&&(l=!1),a=s*(i-Number(l))}return a===0?0:a}function aze(t,e,r){const n=tze(t,e)/1e3;return eze(r==null?void 0:r.roundingMethod)(n)}function oze(t){const e=Xr(t),r=hf(t,0);return r.setFullYear(e.getFullYear(),0,1),r.setHours(0,0,0,0),r}const lze={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"}},cze=(t,e,r)=>{let n;const s=lze[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 I4(t){return(e={})=>{const r=e.width?String(e.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const uze={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},dze={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},hze={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},fze={date:I4({formats:uze,defaultWidth:"full"}),time:I4({formats:dze,defaultWidth:"full"}),dateTime:I4({formats:hze,defaultWidth:"full"})},pze={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},mze=(t,e,r,n)=>pze[t];function Qj(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,l=r!=null&&r.width?String(r.width):a;s=t.formattingValues[l]||t.formattingValues[a]}else{const a=t.defaultWidth,l=r!=null&&r.width?String(r.width):t.defaultWidth;s=t.values[l]||t.values[a]}const i=t.argumentCallback?t.argumentCallback(e):e;return s[i]}}const gze={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},xze={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},yze={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"]},vze={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"]},bze={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"}},wze={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"}},jze=(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"},Sze={ordinalNumber:jze,era:Qj({values:gze,defaultWidth:"wide"}),quarter:Qj({values:xze,defaultWidth:"wide",argumentCallback:t=>t-1}),month:Qj({values:yze,defaultWidth:"wide"}),day:Qj({values:vze,defaultWidth:"wide"}),dayPeriod:Qj({values:bze,defaultWidth:"wide",formattingValues:wze,defaultFormattingWidth:"wide"})};function Zj(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],l=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(l)?Nze(l,h=>h.test(a)):_ze(l,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 _ze(t,e){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&e(t[r]))return r}function Nze(t,e){for(let r=0;r<t.length;r++)if(e(t[r]))return r}function kze(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 l=e.slice(s.length);return{value:a,rest:l}}}const Cze=/^(\d+)(th|st|nd|rd)?/i,Eze=/\d+/i,Aze={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},Tze={any:[/^b/i,/^(a|c)/i]},Pze={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Ize={any:[/1/i,/2/i,/3/i,/4/i]},Rze={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},Oze={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]},Mze={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},Dze={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]},Lze={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},$ze={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}},Fze={ordinalNumber:kze({matchPattern:Cze,parsePattern:Eze,valueCallback:t=>parseInt(t,10)}),era:Zj({matchPatterns:Aze,defaultMatchWidth:"wide",parsePatterns:Tze,defaultParseWidth:"any"}),quarter:Zj({matchPatterns:Pze,defaultMatchWidth:"wide",parsePatterns:Ize,defaultParseWidth:"any",valueCallback:t=>t+1}),month:Zj({matchPatterns:Rze,defaultMatchWidth:"wide",parsePatterns:Oze,defaultParseWidth:"any"}),day:Zj({matchPatterns:Mze,defaultMatchWidth:"wide",parsePatterns:Dze,defaultParseWidth:"any"}),dayPeriod:Zj({matchPatterns:Lze,defaultMatchWidth:"any",parsePatterns:$ze,defaultParseWidth:"any"})},_D={code:"en-US",formatDistance:cze,formatLong:fze,formatRelative:mze,localize:Sze,match:Fze,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Bze(t){const e=Xr(t);return Uge(e,oze(e))+1}function zze(t){const e=Xr(t),r=+LI(e)-+X8e(e);return Math.round(r/Bge)+1}function Wge(t,e){var d,h,f,p;const r=Xr(t),n=r.getFullYear(),s=VE(),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=hf(t,0);a.setFullYear(n+1,0,i),a.setHours(0,0,0,0);const l=MN(a,e),c=hf(t,0);c.setFullYear(n,0,i),c.setHours(0,0,0,0);const u=MN(c,e);return r.getTime()>=l.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function Uze(t,e){var l,c,u,d;const r=VE(),n=(e==null?void 0:e.firstWeekContainsDate)??((c=(l=e==null?void 0:e.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((d=(u=r.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,s=Wge(t,e),i=hf(t,0);return i.setFullYear(s,0,n),i.setHours(0,0,0,0),MN(i,e)}function Hze(t,e){const r=Xr(t),n=+MN(r,e)-+Uze(r,e);return Math.round(n/Bge)+1}function tn(t,e){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(e,"0");return r+n}const Hf={y(t,e){const r=t.getFullYear(),n=r>0?r:1-r;return tn(e==="yy"?n%100:n,e.length)},M(t,e){const r=t.getMonth();return e==="M"?String(r+1):tn(r+1,2)},d(t,e){return tn(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 tn(t.getHours()%12||12,e.length)},H(t,e){return tn(t.getHours(),e.length)},m(t,e){return tn(t.getMinutes(),e.length)},s(t,e){return tn(t.getSeconds(),e.length)},S(t,e){const r=e.length,n=t.getMilliseconds(),s=Math.trunc(n*Math.pow(10,r-3));return tn(s,e.length)}},rb={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},RQ={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 Hf.y(t,e)},Y:function(t,e,r,n){const s=Wge(t,n),i=s>0?s:1-s;if(e==="YY"){const a=i%100;return tn(a,2)}return e==="Yo"?r.ordinalNumber(i,{unit:"year"}):tn(i,e.length)},R:function(t,e){const r=zge(t);return tn(r,e.length)},u:function(t,e){const r=t.getFullYear();return tn(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 tn(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 tn(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 Hf.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 tn(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=Hze(t,n);return e==="wo"?r.ordinalNumber(s,{unit:"week"}):tn(s,e.length)},I:function(t,e,r){const n=zze(t);return e==="Io"?r.ordinalNumber(n,{unit:"week"}):tn(n,e.length)},d:function(t,e,r){return e==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Hf.d(t,e)},D:function(t,e,r){const n=Bze(t);return e==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):tn(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 tn(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 tn(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 tn(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=rb.noon:n===0?s=rb.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=rb.evening:n>=12?s=rb.afternoon:n>=4?s=rb.morning:s=rb.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 Hf.h(t,e)},H:function(t,e,r){return e==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Hf.H(t,e)},K:function(t,e,r){const n=t.getHours()%12;return e==="Ko"?r.ordinalNumber(n,{unit:"hour"}):tn(n,e.length)},k:function(t,e,r){let n=t.getHours();return n===0&&(n=24),e==="ko"?r.ordinalNumber(n,{unit:"hour"}):tn(n,e.length)},m:function(t,e,r){return e==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Hf.m(t,e)},s:function(t,e,r){return e==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Hf.s(t,e)},S:function(t,e){return Hf.S(t,e)},X:function(t,e,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return MQ(n);case"XXXX":case"XX":return Bg(n);case"XXXXX":case"XXX":default:return Bg(n,":")}},x:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"x":return MQ(n);case"xxxx":case"xx":return Bg(n);case"xxxxx":case"xxx":default:return Bg(n,":")}},O:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+OQ(n,":");case"OOOO":default:return"GMT"+Bg(n,":")}},z:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+OQ(n,":");case"zzzz":default:return"GMT"+Bg(n,":")}},t:function(t,e,r){const n=Math.trunc(t.getTime()/1e3);return tn(n,e.length)},T:function(t,e,r){const n=t.getTime();return tn(n,e.length)}};function OQ(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+tn(i,2)}function MQ(t,e){return t%60===0?(t>0?"-":"+")+tn(Math.abs(t)/60,2):Bg(t,e)}function Bg(t,e=""){const r=t>0?"-":"+",n=Math.abs(t),s=tn(Math.trunc(n/60),2),i=tn(n%60,2);return r+s+e+i}const DQ=(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"})}},Vge=(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"})}},Wze=(t,e)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],s=r[2];if(!s)return DQ(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}}",DQ(n,e)).replace("{{time}}",Vge(s,e))},Vze={p:Vge,P:Wze},qze=/^D+$/,Gze=/^Y+$/,Kze=["D","DD","YY","YYYY"];function Yze(t){return qze.test(t)}function Xze(t){return Gze.test(t)}function Qze(t,e,r){const n=Zze(t,e,r);if(console.warn(n),Kze.includes(t))throw new RangeError(n)}function Zze(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 Jze=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,eUe=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,tUe=/^'([^]*?)'?$/,rUe=/''/g,nUe=/[a-zA-Z]/;function d1(t,e,r){var d,h,f,p,m,g,y,x;const n=VE(),s=(r==null?void 0:r.locale)??n.locale??_D,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??((x=(y=n.locale)==null?void 0:y.options)==null?void 0:x.weekStartsOn)??0,l=Xr(t);if(!Z8e(l))throw new RangeError("Invalid time value");let c=e.match(eUe).map(v=>{const b=v[0];if(b==="p"||b==="P"){const w=Vze[b];return w(v,s.formatLong)}return v}).join("").match(Jze).map(v=>{if(v==="''")return{isToken:!1,value:"'"};const b=v[0];if(b==="'")return{isToken:!1,value:sUe(v)};if(RQ[b])return{isToken:!0,value:v};if(b.match(nUe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+b+"`");return{isToken:!1,value:v}});s.localize.preprocessor&&(c=s.localize.preprocessor(l,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)&&Xze(b)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&Yze(b))&&Qze(b,e,String(t));const w=RQ[b[0]];return w(l,b,s.localize,u)}).join("")}function sUe(t){const e=t.match(tUe);return e?e[1].replace(rUe,"'"):t}function iUe(t,e,r){const n=VE(),s=(r==null?void 0:r.locale)??n.locale??_D,i=2520,a=X2(t,e);if(isNaN(a))throw new RangeError("Invalid time value");const l=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:a});let c,u;a>0?(c=Xr(e),u=Xr(t)):(c=Xr(t),u=Xr(e));const d=aze(u,c),h=(FI(u)-FI(c))/1e3,f=Math.round((d-h)/60);let p;if(f<2)return r!=null&&r.includeSeconds?d<5?s.formatDistance("lessThanXSeconds",5,l):d<10?s.formatDistance("lessThanXSeconds",10,l):d<20?s.formatDistance("lessThanXSeconds",20,l):d<40?s.formatDistance("halfAMinute",0,l):d<60?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",1,l):f===0?s.formatDistance("lessThanXMinutes",1,l):s.formatDistance("xMinutes",f,l);if(f<45)return s.formatDistance("xMinutes",f,l);if(f<90)return s.formatDistance("aboutXHours",1,l);if(f<PQ){const m=Math.round(f/60);return s.formatDistance("aboutXHours",m,l)}else{if(f<i)return s.formatDistance("xDays",1,l);if(f<oT){const m=Math.round(f/PQ);return s.formatDistance("xDays",m,l)}else if(f<oT*2)return p=Math.round(f/oT),s.formatDistance("aboutXMonths",p,l)}if(p=ize(u,c),p<12){const m=Math.round(f/oT);return s.formatDistance("xMonths",m,l)}else{const m=p%12,g=Math.trunc(p/12);return m<3?s.formatDistance("aboutXYears",g,l):m<9?s.formatDistance("overXYears",g,l):s.formatDistance("almostXYears",g+1,l)}}function LQ(t,e){return iUe(t,z9(t),e)}function aUe(t){return Hge(t,z9(t))}function oUe(t,e){return G8e(t,-e)}function lUe(t){return Hge(t,oUe(z9(t),1))}function cUe(t){if(!t||t.length===0)return[];const e=new Map;return t.forEach(r=>{const n=new Date(r.created_at),s=d1(n,"yyyy-MM-dd");let i;aUe(n)?i="Today":lUe(n)?i="Yesterday":i=d1(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 uUe(t){return d1(new Date(t),"HH:mm")}function dUe(){const{user:t}=Ht(),{toast:e}=Bn(),r=a9(),n=["user-notes",t==null?void 0:t.id],{data:s,isLoading:i,error:a}=tD({queryKey:n,queryFn:async()=>{const{data:h,error:f}=await pe.from("user_notes").select("*").order("created_at",{ascending:!1});if(f)throw f;return h},enabled:!!t}),l=f4({mutationFn:async h=>{if(!t)throw new Error("Not authenticated");const{data:f,error:p}=await pe.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=f4({mutationFn:async({id:h,content:f})=>{const{data:p,error:m}=await pe.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=f4({mutationFn:async h=>{const{error:f}=await pe.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=S.useMemo(()=>cUe(s),[s]);return{notes:s,groupedNotes:d,isLoading:i,error:a,createNote:async h=>{await l.mutateAsync(h)},updateNote:async h=>{await c.mutateAsync(h)},deleteNote:async h=>{await u.mutateAsync(h)},isCreating:l.isPending,isUpdating:c.isPending,isDeleting:u.isPending}}function hUe({note:t,onUpdate:e,onDelete:r,isUpdating:n,isDeleting:s}){const[i,a]=S.useState(!1),[l,c]=S.useState(t.content),u=async()=>{l.trim()&&l!==t.content&&await e(t.id,l.trim()),a(!1)},d=()=>{c(t.content),a(!1)},h=async()=>{await r(t.id)};return i?o.jsxs("div",{className:"group relative p-3 rounded-lg bg-muted/50 border border-border mb-2",children:[o.jsx(lr,{value:l,onChange:f=>c(f.target.value),className:"min-h-[80px] resize-none text-sm",autoFocus:!0}),o.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[o.jsxs(me,{size:"sm",variant:"ghost",onClick:d,disabled:n,children:[o.jsx(fn,{className:"h-4 w-4 mr-1"}),"Cancel"]}),o.jsxs(me,{size:"sm",onClick:u,disabled:n||!l.trim(),children:[o.jsx(kr,{className:"h-4 w-4 mr-1"}),"Save"]})]})]}):o.jsxs("div",{className:"group relative p-3 rounded-lg hover:bg-muted/50 transition-colors mb-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:uUe(t.created_at)}),o.jsx("p",{className:"text-sm text-foreground mt-1 whitespace-pre-wrap break-words",children:t.content}),o.jsxs("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity flex gap-1",children:[o.jsx(me,{size:"icon",variant:"ghost",className:"h-7 w-7",onClick:()=>a(!0),disabled:s,children:o.jsx(EB,{className:"h-3.5 w-3.5"})}),o.jsx(me,{size:"icon",variant:"ghost",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:h,disabled:s,children:o.jsx(Pi,{className:"h-3.5 w-3.5"})})]})]})}function fUe({open:t,onOpenChange:e}){const[r,n]=S.useState(""),{groupedNotes:s,isLoading:i,createNote:a,updateNote:l,deleteNote:c,isCreating:u,isUpdating:d,isDeleting:h}=dUe(),f=async()=>{!r.trim()||u||(await a(r.trim()),n(""))},p=m=>{(m.ctrlKey||m.metaKey)&&m.key==="Enter"&&(m.preventDefault(),f())};return o.jsx(jn,{open:t,onOpenChange:e,children:o.jsxs(pn,{className:"sm:max-w-[800px] h-[80vh] flex flex-col p-0",children:[o.jsx(mn,{className:"px-6 py-4 border-b border-border",children:o.jsxs(gn,{className:"flex items-center gap-2",children:[o.jsx(AB,{className:"h-5 w-5 text-primary"}),"My Notebook"]})}),o.jsx(Am,{className:"flex-1 px-6 overflow-y-auto",children:i?o.jsx("div",{className:"py-4 space-y-4",children:[1,2,3].map(m=>o.jsxs("div",{className:"space-y-2",children:[o.jsx(en,{className:"h-4 w-24"}),o.jsx(en,{className:"h-16 w-full"})]},m))}):s.length===0?o.jsxs("div",{className:"py-12 text-center",children:[o.jsx(AB,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground text-sm",children:"No notes yet."}),o.jsx("p",{className:"text-muted-foreground text-xs mt-1",children:"Write your first note below."})]}):o.jsx("div",{className:"py-4",children:s.map(m=>o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-3 my-4 first:mt-0",children:[o.jsx(Eo,{className:"flex-1"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground whitespace-nowrap",children:m.date}),o.jsx(Eo,{className:"flex-1"})]}),m.notes.map(g=>o.jsx(hUe,{note:g,onUpdate:(y,x)=>l({id:y,content:x}),onDelete:c,isUpdating:d,isDeleting:h},g.id))]},m.dateKey))})}),o.jsxs("div",{className:"border-t border-border p-4 bg-background",children:[o.jsxs("div",{className:"relative",children:[o.jsx(lr,{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}),o.jsx(me,{size:"icon",className:"absolute bottom-2 right-2 h-8 w-8",onClick:f,disabled:!r.trim()||u,children:o.jsx(WW,{className:"h-4 w-4"})})]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center",children:"Your notes are saved automatically"})]})]})})}async function U9(t,e,r=3600){if(!e)return null;const{data:n,error:s}=await pe.storage.from(t).createSignedUrl(e,r);return s?(console.error("Signed URL error:",s),null):n.signedUrl}async function pUe(t,e=3600){if(!t)return null;const{data:r,error:n}=await pe.storage.from("avatars").createSignedUrl(t,e);return n?(console.error("Avatar signed URL error:",n),null):r.signedUrl}async function x0(t){return t?t.startsWith("https://")?t:pUe(t):null}async function H9(t,e){const r={};return await Promise.all(t.map(async n=>{if(n.storage_path){const s=await U9(e,n.storage_path);s&&(r[n.id]=s)}})),r}const $Q=({pageTitle:t="Dashboard",onToggleSidebar:e,onToggleMobile:r,isMobileOpen:n,showSidebarControls:s=!0})=>{const{user:i,studentPoints:a,researchProfile:l,signOut:c}=Ht(),u=Or(),{theme:d}=T9(),[h,f]=S.useState(!1),[p,m]=S.useState(null);S.useEffect(()=>{(async()=>{const b=await x0(l==null?void 0:l.avatar_url);m(b)})()},[l==null?void 0:l.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",y=async()=>{await c(),u("/login")},x=()=>l!=null&&l.nickname?l.nickname.slice(0,2).toUpperCase():i!=null&&i.email?i.email.slice(0,2).toUpperCase():"U";return!i||!s?o.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:[o.jsx(Nt,{to:"/",className:"flex items-center",children:o.jsx("img",{src:g,alt:"Academly.ai",className:"h-8 w-auto"})}),o.jsxs("div",{className:"flex items-center space-x-4",children:[o.jsx(Nt,{to:"/pricing",className:"text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:"Pricing"}),o.jsx(Nt,{to:"/how-it-works",className:"text-sm font-medium text-muted-foreground hover:text-foreground transition-colors",children:"How it works"}),i?o.jsx(me,{asChild:!0,size:"sm",children:o.jsx(Nt,{to:"/dashboard",children:"Dashboard"})}):o.jsx(me,{asChild:!0,size:"sm",children:o.jsx(Nt,{to:"/login",children:"Login"})})]})]}):o.jsx("header",{className:"ta-header astro-header",children:o.jsxs("div",{className:"ta-header-content",children:[o.jsxs("div",{className:"ta-header-left",children:[o.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?o.jsx(fn,{className:"w-5 h-5"}):o.jsx(rj,{className:"w-5 h-5"})}),o.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:o.jsx("svg",{width:"16",height:"12",viewBox:"0 0 16 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:o.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"})})}),o.jsx(Nt,{to:"/dashboard",className:"lg:hidden",children:o.jsx("img",{src:g,alt:"Academly.ai",className:"h-8 w-auto"})}),o.jsx("h1",{className:"ta-header-title",children:t})]}),o.jsxs("div",{className:"ta-header-right",children:[o.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:o.jsx(AB,{className:"w-5 h-5"})}),o.jsx(p8e,{}),o.jsx(fUe,{open:h,onOpenChange:f}),a&&o.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:[o.jsx(Sr,{className:"h-4 w-4 text-primary"}),o.jsxs("span",{className:"text-sm font-semibold text-primary",children:[Math.floor(a.remaining).toLocaleString("de-DE")," SP"]})]}),o.jsxs(_9,{children:[o.jsx(N9,{asChild:!0,children:o.jsx("button",{className:"flex items-center gap-3 hover:opacity-80 transition-opacity",children:o.jsxs(C9,{className:"h-10 w-10 border-2 border-border",children:[p?o.jsx(E9,{src:p,alt:"Avatar"}):null,o.jsx(A9,{className:"bg-brand-50 text-brand-500 font-semibold",children:x()})]})})}),o.jsxs(yD,{className:"w-60",align:"end",forceMount:!0,children:[o.jsxs("div",{className:"px-4 py-3 border-b border-border",children:[o.jsx("p",{className:"font-medium text-foreground",children:(l==null?void 0:l.nickname)||"User"}),o.jsx("p",{className:"text-sm text-muted-foreground truncate",children:i==null?void 0:i.email})]}),o.jsxs(Ha,{onClick:()=>u("/account"),className:"cursor-pointer",children:[o.jsx(nj,{className:"mr-2 h-4 w-4"}),o.jsx("span",{children:"Manage Account"})]}),o.jsxs(Ha,{onClick:()=>u("/history"),className:"cursor-pointer",children:[o.jsx(sMe,{className:"mr-2 h-4 w-4"}),o.jsx("span",{children:"History"})]}),o.jsx(g0,{}),o.jsxs(Ha,{onClick:y,className:"cursor-pointer text-destructive focus:text-destructive",children:[o.jsx(hMe,{className:"mr-2 h-4 w-4"}),o.jsx("span",{children:"Sign Out"})]})]})]})]})]})})},mUe={reading:"max-w-4xl",default:"max-w-[1400px]",wide:"max-w-[1400px]"},Kn=({children:t,className:e="",size:r="default"})=>o.jsx("div",{className:`${mUe[r]} mx-auto w-full px-5 sm:px-6 lg:px-8 ${e}`,children:t}),Ii=()=>o.jsx("footer",{className:"border-t border-border/70 bg-card",children:o.jsx(Kn,{children:o.jsxs("div",{className:"py-14 lg:py-18",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-10 md:grid-cols-4 lg:gap-14",children:[o.jsxs("div",{className:"col-span-2 md:col-span-1",children:[o.jsxs(Nt,{to:"/",className:"mb-5 inline-flex items-center gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary shadow-sm shadow-primary/20",children:o.jsx("span",{className:"text-sm font-bold text-primary-foreground",children:"A"})}),o.jsx("span",{className:"text-xl font-bold tracking-tight text-foreground",children:"Academly.ai"})]}),o.jsx("p",{className:"max-w-xs text-sm leading-6 text-muted-foreground",children:"Thesis platform built around source-backed academic writing."}),o.jsxs("div",{className:"mt-5 inline-flex items-center gap-2 rounded-full border border-border/70 bg-muted/30 px-3 py-1.5 text-xs font-medium text-muted-foreground",children:[o.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"}),"Built for serious academic work"]})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"mb-5 text-sm font-semibold uppercase tracking-[0.12em] text-foreground",children:"Product"}),o.jsxs("ul",{className:"space-y-3.5",children:[o.jsx("li",{children:o.jsx(Nt,{to:"/#features",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Features"})}),o.jsx("li",{children:o.jsx(Nt,{to:"/#how-it-works",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"How It Works"})}),o.jsx("li",{children:o.jsx(Nt,{to:"/pricing",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Pricing"})})]})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"mb-5 text-sm font-semibold uppercase tracking-[0.12em] text-foreground",children:"Free Tools"}),o.jsxs("ul",{className:"space-y-3.5",children:[o.jsx("li",{children:o.jsx(Nt,{to:"/topic-ideas",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Topic Generator"})}),o.jsx("li",{children:o.jsx(Nt,{to:"/literature-search",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Literature Search"})})]})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"mb-5 text-sm font-semibold uppercase tracking-[0.12em] text-foreground",children:"Company"}),o.jsxs("ul",{className:"space-y-3.5",children:[o.jsx("li",{children:o.jsx(Nt,{to:"/blog",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Blog"})}),o.jsx("li",{children:o.jsx(Nt,{to:"/team",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Team"})}),o.jsx("li",{children:o.jsx(Nt,{to:"/docs",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Docs"})}),o.jsx("li",{children:o.jsx("a",{href:"mailto:contact@academly.ai",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Support"})}),o.jsx("li",{children:o.jsx(Nt,{to:"/legal#privacy",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Privacy"})}),o.jsx("li",{children:o.jsx(Nt,{to:"/legal#terms",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Terms"})}),o.jsx("li",{children:o.jsx(Nt,{to:"/legal",className:"text-sm text-muted-foreground transition-colors hover:text-primary",children:"Imprint"})})]})]})]}),o.jsxs("div",{className:"mt-12 flex flex-col items-center justify-between gap-5 border-t border-border/70 pt-7 md:flex-row",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:["© ",new Date().getFullYear()," Academly.ai. All rights reserved."]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("a",{href:"https://youtube.com/@academly-ai?si=hAadi72xwmt5fJ3u",target:"_blank",rel:"noopener noreferrer",className:"flex h-9 w-9 items-center justify-center rounded-lg border border-border/70 text-muted-foreground transition hover:border-primary/30 hover:bg-primary/5 hover:text-primary","aria-label":"YouTube",children:o.jsx("svg",{className:"h-4.5 w-4.5",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o.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"})})}),o.jsx("a",{href:"https://discord.gg/YFHAZY8d9",target:"_blank",rel:"noopener noreferrer",className:"flex h-9 w-9 items-center justify-center rounded-lg border border-border/70 text-muted-foreground transition hover:border-primary/30 hover:bg-primary/5 hover:text-primary","aria-label":"Discord",children:o.jsx("svg",{className:"h-4.5 w-4.5",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o.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"})})}),o.jsx("a",{href:"https://www.linkedin.com/company/academly-ai",target:"_blank",rel:"noopener noreferrer",className:"flex h-9 w-9 items-center justify-center rounded-lg border border-border/70 text-muted-foreground transition hover:border-primary/30 hover:bg-primary/5 hover:text-primary","aria-label":"LinkedIn",children:o.jsx("svg",{className:"h-4.5 w-4.5",fill:"currentColor",viewBox:"0 0 24 24","aria-hidden":"true",children:o.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"})})})]})]})]})})});function W9(t){const e=S.useRef({value:t,previous:t});return S.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var gUe=[" ","Enter","ArrowUp","ArrowDown"],xUe=[" ","Enter"],cv="Select",[ND,kD,yUe]=CE(cv),[pj,jWt]=Vs(cv,[yUe,ig]),CD=ig(),[vUe,lg]=pj(cv),[bUe,wUe]=pj(cv),qge=t=>{const{__scopeSelect:e,children:r,open:n,defaultOpen:s,onOpenChange:i,value:a,defaultValue:l,onValueChange:c,dir:u,name:d,autoComplete:h,disabled:f,required:p,form:m}=t,g=CD(e),[y,x]=S.useState(null),[v,b]=S.useState(null),[w,j]=S.useState(!1),N=Tv(u),[C,A]=ca({prop:n,defaultProp:s??!1,onChange:i,caller:cv}),[E,O]=ca({prop:a,defaultProp:l,onChange:c,caller:cv}),$=S.useRef(null),T=y?m||!!y.closest("form"):!0,[M,k]=S.useState(new Set),D=Array.from(M).map(K=>K.props.value).join(";");return o.jsx(YM,{...g,children:o.jsxs(vUe,{required:p,scope:e,trigger:y,onTriggerChange:x,valueNode:v,onValueNodeChange:b,valueNodeHasChildren:w,onValueNodeHasChildrenChange:j,contentId:Co(),value:E,onValueChange:O,open:C,onOpenChange:A,dir:N,triggerPointerDownPosRef:$,disabled:f,children:[o.jsx(ND.Provider,{scope:e,children:o.jsx(bUe,{scope:t.__scopeSelect,onNativeOptionAdd:S.useCallback(K=>{k(H=>new Set(H).add(K))},[]),onNativeOptionRemove:S.useCallback(K=>{k(H=>{const ee=new Set(H);return ee.delete(K),ee})},[]),children:r})}),T?o.jsxs(xxe,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:h,value:E,onChange:K=>O(K.target.value),disabled:f,form:m,children:[E===void 0?o.jsx("option",{value:""}):null,Array.from(M)]},D):null]})})};qge.displayName=cv;var Gge="SelectTrigger",Kge=S.forwardRef((t,e)=>{const{__scopeSelect:r,disabled:n=!1,...s}=t,i=CD(r),a=lg(Gge,r),l=a.disabled||n,c=qt(e,a.onTriggerChange),u=kD(r),d=S.useRef("touch"),[h,f,p]=vxe(g=>{const y=u().filter(b=>!b.disabled),x=y.find(b=>b.value===a.value),v=bxe(y,g,x);v!==void 0&&a.onValueChange(v.value)}),m=g=>{l||(a.onOpenChange(!0),p()),g&&(a.triggerPointerDownPosRef.current={x:Math.round(g.pageX),y:Math.round(g.pageY)})};return o.jsx(IE,{asChild:!0,...i,children:o.jsx(ft.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:l,"data-disabled":l?"":void 0,"data-placeholder":yxe(a.value)?"":void 0,...s,ref:c,onClick:Qe(s.onClick,g=>{g.currentTarget.focus(),d.current!=="mouse"&&m(g)}),onPointerDown:Qe(s.onPointerDown,g=>{d.current=g.pointerType;const y=g.target;y.hasPointerCapture(g.pointerId)&&y.releasePointerCapture(g.pointerId),g.button===0&&g.ctrlKey===!1&&g.pointerType==="mouse"&&(m(g),g.preventDefault())}),onKeyDown:Qe(s.onKeyDown,g=>{const y=h.current!=="";!(g.ctrlKey||g.altKey||g.metaKey)&&g.key.length===1&&f(g.key),!(y&&g.key===" ")&&gUe.includes(g.key)&&(m(),g.preventDefault())})})})});Kge.displayName=Gge;var Yge="SelectValue",Xge=S.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,children:i,placeholder:a="",...l}=t,c=lg(Yge,r),{onValueNodeHasChildrenChange:u}=c,d=i!==void 0,h=qt(e,c.onValueNodeChange);return bs(()=>{u(d)},[u,d]),o.jsx(ft.span,{...l,ref:h,style:{pointerEvents:"none"},children:yxe(c.value)?o.jsx(o.Fragment,{children:a}):i})});Xge.displayName=Yge;var jUe="SelectIcon",Qge=S.forwardRef((t,e)=>{const{__scopeSelect:r,children:n,...s}=t;return o.jsx(ft.span,{"aria-hidden":!0,...s,ref:e,children:n||"▼"})});Qge.displayName=jUe;var SUe="SelectPortal",Zge=t=>o.jsx(tj,{asChild:!0,...t});Zge.displayName=SUe;var uv="SelectContent",Jge=S.forwardRef((t,e)=>{const r=lg(uv,t.__scopeSelect),[n,s]=S.useState();if(bs(()=>{s(new DocumentFragment)},[]),!r.open){const i=n;return i?cc.createPortal(o.jsx(exe,{scope:t.__scopeSelect,children:o.jsx(ND.Slot,{scope:t.__scopeSelect,children:o.jsx("div",{children:t.children})})}),i):null}return o.jsx(txe,{...t,ref:e})});Jge.displayName=uv;var wc=10,[exe,cg]=pj(uv),_Ue="SelectContentImpl",NUe=zm("SelectContent.RemoveScroll"),txe=S.forwardRef((t,e)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:i,onPointerDownOutside:a,side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:y,...x}=t,v=lg(uv,r),[b,w]=S.useState(null),[j,N]=S.useState(null),C=qt(e,q=>w(q)),[A,E]=S.useState(null),[O,$]=S.useState(null),T=kD(r),[M,k]=S.useState(!1),D=S.useRef(!1);S.useEffect(()=>{if(b)return fD(b)},[b]),hD();const K=S.useCallback(q=>{const[L,...Z]=T().map(X=>X.ref.current),[J]=Z.slice(-1),W=document.activeElement;for(const X of q)if(X===W||(X==null||X.scrollIntoView({block:"nearest"}),X===L&&j&&(j.scrollTop=0),X===J&&j&&(j.scrollTop=j.scrollHeight),X==null||X.focus(),document.activeElement!==W))return},[T,j]),H=S.useCallback(()=>K([A,b]),[K,A,b]);S.useEffect(()=>{M&&H()},[M,H]);const{onOpenChange:ee,triggerPointerDownPosRef:V}=v;S.useEffect(()=>{if(b){let q={x:0,y:0};const L=J=>{var W,X;q={x:Math.abs(Math.round(J.pageX)-(((W=V.current)==null?void 0:W.x)??0)),y:Math.abs(Math.round(J.pageY)-(((X=V.current)==null?void 0:X.y)??0))}},Z=J=>{q.x<=10&&q.y<=10?J.preventDefault():b.contains(J.target)||ee(!1),document.removeEventListener("pointermove",L),V.current=null};return V.current!==null&&(document.addEventListener("pointermove",L),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",Z,{capture:!0})}}},[b,ee,V]),S.useEffect(()=>{const q=()=>ee(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[ee]);const[B,z]=vxe(q=>{const L=T().filter(W=>!W.disabled),Z=L.find(W=>W.ref.current===document.activeElement),J=bxe(L,q,Z);J&&setTimeout(()=>J.ref.current.focus())}),F=S.useCallback((q,L,Z)=>{const J=!D.current&&!Z;(v.value!==void 0&&v.value===L||J)&&(E(q),J&&(D.current=!0))},[v.value]),G=S.useCallback(()=>b==null?void 0:b.focus(),[b]),Q=S.useCallback((q,L,Z)=>{const J=!D.current&&!Z;(v.value!==void 0&&v.value===L||J)&&$(q)},[v.value]),ie=n==="popper"?g8:rxe,se=ie===g8?{side:l,sideOffset:c,align:u,alignOffset:d,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:g,avoidCollisions:y}:{};return o.jsx(exe,{scope:r,content:b,viewport:j,onViewportChange:N,itemRefCallback:F,selectedItem:A,onItemLeave:G,itemTextRefCallback:Q,focusSelectedItem:H,selectedItemText:O,position:n,isPositioned:M,searchRef:B,children:o.jsx($E,{as:NUe,allowPinchZoom:!0,children:o.jsx(DE,{asChild:!0,trapped:v.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:Qe(s,q=>{var L;(L=v.trigger)==null||L.focus({preventScroll:!0}),q.preventDefault()}),children:o.jsx(Ev,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:o.jsx(ie,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:q=>q.preventDefault(),...x,...se,onPlaced:()=>k(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:Qe(x.onKeyDown,q=>{const L=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!L&&q.key.length===1&&z(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let J=T().filter(W=>!W.disabled).map(W=>W.ref.current);if(["ArrowUp","End"].includes(q.key)&&(J=J.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const W=q.target,X=J.indexOf(W);J=J.slice(X+1)}setTimeout(()=>K(J)),q.preventDefault()}})})})})})})});txe.displayName=_Ue;var kUe="SelectItemAlignedPosition",rxe=S.forwardRef((t,e)=>{const{__scopeSelect:r,onPlaced:n,...s}=t,i=lg(uv,r),a=cg(uv,r),[l,c]=S.useState(null),[u,d]=S.useState(null),h=qt(e,C=>d(C)),f=kD(r),p=S.useRef(!1),m=S.useRef(!0),{viewport:g,selectedItem:y,selectedItemText:x,focusSelectedItem:v}=a,b=S.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&u&&g&&y&&x){const C=i.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),E=i.valueNode.getBoundingClientRect(),O=x.getBoundingClientRect();if(i.dir!=="rtl"){const W=O.left-A.left,X=E.left-W,he=C.left-X,P=C.width+he,oe=Math.max(P,A.width),Y=window.innerWidth-wc,R=m8(X,[wc,Math.max(wc,Y-oe)]);l.style.minWidth=P+"px",l.style.left=R+"px"}else{const W=A.right-O.right,X=window.innerWidth-E.right-W,he=window.innerWidth-C.right-X,P=C.width+he,oe=Math.max(P,A.width),Y=window.innerWidth-wc,R=m8(X,[wc,Math.max(wc,Y-oe)]);l.style.minWidth=P+"px",l.style.right=R+"px"}const $=f(),T=window.innerHeight-wc*2,M=g.scrollHeight,k=window.getComputedStyle(u),D=parseInt(k.borderTopWidth,10),K=parseInt(k.paddingTop,10),H=parseInt(k.borderBottomWidth,10),ee=parseInt(k.paddingBottom,10),V=D+K+M+ee+H,B=Math.min(y.offsetHeight*5,V),z=window.getComputedStyle(g),F=parseInt(z.paddingTop,10),G=parseInt(z.paddingBottom,10),Q=C.top+C.height/2-wc,ie=T-Q,se=y.offsetHeight/2,q=y.offsetTop+se,L=D+K+q,Z=V-L;if(L<=Q){const W=$.length>0&&y===$[$.length-1].ref.current;l.style.bottom="0px";const X=u.clientHeight-g.offsetTop-g.offsetHeight,he=Math.max(ie,se+(W?G:0)+X+H),P=L+he;l.style.height=P+"px"}else{const W=$.length>0&&y===$[0].ref.current;l.style.top="0px";const he=Math.max(Q,D+g.offsetTop+(W?F:0)+se)+Z;l.style.height=he+"px",g.scrollTop=L-Q+g.offsetTop}l.style.margin=`${wc}px 0`,l.style.minHeight=B+"px",l.style.maxHeight=T+"px",n==null||n(),requestAnimationFrame(()=>p.current=!0)}},[f,i.trigger,i.valueNode,l,u,g,y,x,i.dir,n]);bs(()=>b(),[b]);const[w,j]=S.useState();bs(()=>{u&&j(window.getComputedStyle(u).zIndex)},[u]);const N=S.useCallback(C=>{C&&m.current===!0&&(b(),v==null||v(),m.current=!1)},[b,v]);return o.jsx(EUe,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:p,onScrollButtonChange:N,children:o.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:o.jsx(ft.div,{...s,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});rxe.displayName=kUe;var CUe="SelectPopperPosition",g8=S.forwardRef((t,e)=>{const{__scopeSelect:r,align:n="start",collisionPadding:s=wc,...i}=t,a=CD(r);return o.jsx(XM,{...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)"}})});g8.displayName=CUe;var[EUe,V9]=pj(uv,{}),x8="SelectViewport",nxe=S.forwardRef((t,e)=>{const{__scopeSelect:r,nonce:n,...s}=t,i=cg(x8,r),a=V9(x8,r),l=qt(e,i.onViewportChange),c=S.useRef(0);return o.jsxs(o.Fragment,{children:[o.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}),o.jsx(ND.Slot,{scope:r,children:o.jsx(ft.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Qe(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-wc*2,g=parseFloat(h.style.minHeight),y=parseFloat(h.style.height),x=Math.max(g,y);if(x<m){const v=x+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})})})]})});nxe.displayName=x8;var sxe="SelectGroup",[AUe,TUe]=pj(sxe),ixe=S.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=Co();return o.jsx(AUe,{scope:r,id:s,children:o.jsx(ft.div,{role:"group","aria-labelledby":s,...n,ref:e})})});ixe.displayName=sxe;var axe="SelectLabel",oxe=S.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=TUe(axe,r);return o.jsx(ft.div,{id:s.id,...n,ref:e})});oxe.displayName=axe;var BI="SelectItem",[PUe,lxe]=pj(BI),cxe=S.forwardRef((t,e)=>{const{__scopeSelect:r,value:n,disabled:s=!1,textValue:i,...a}=t,l=lg(BI,r),c=cg(BI,r),u=l.value===n,[d,h]=S.useState(i??""),[f,p]=S.useState(!1),m=qt(e,v=>{var b;return(b=c.itemRefCallback)==null?void 0:b.call(c,v,n,s)}),g=Co(),y=S.useRef("touch"),x=()=>{s||(l.onValueChange(n),l.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 o.jsx(PUe,{scope:r,value:n,disabled:s,textId:g,isSelected:u,onItemTextChange:S.useCallback(v=>{h(b=>b||((v==null?void 0:v.textContent)??"").trim())},[]),children:o.jsx(ND.ItemSlot,{scope:r,value:n,disabled:s,textValue:d,children:o.jsx(ft.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:Qe(a.onFocus,()=>p(!0)),onBlur:Qe(a.onBlur,()=>p(!1)),onClick:Qe(a.onClick,()=>{y.current!=="mouse"&&x()}),onPointerUp:Qe(a.onPointerUp,()=>{y.current==="mouse"&&x()}),onPointerDown:Qe(a.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:Qe(a.onPointerMove,v=>{var b;y.current=v.pointerType,s?(b=c.onItemLeave)==null||b.call(c):y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Qe(a.onPointerLeave,v=>{var b;v.currentTarget===document.activeElement&&((b=c.onItemLeave)==null||b.call(c))}),onKeyDown:Qe(a.onKeyDown,v=>{var w;((w=c.searchRef)==null?void 0:w.current)!==""&&v.key===" "||(xUe.includes(v.key)&&x(),v.key===" "&&v.preventDefault())})})})})});cxe.displayName=BI;var BS="SelectItemText",uxe=S.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,...i}=t,a=lg(BS,r),l=cg(BS,r),c=lxe(BS,r),u=wUe(BS,r),[d,h]=S.useState(null),f=qt(e,x=>h(x),c.onItemTextChange,x=>{var v;return(v=l.itemTextRefCallback)==null?void 0:v.call(l,x,c.value,c.disabled)}),p=d==null?void 0:d.textContent,m=S.useMemo(()=>o.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:g,onNativeOptionRemove:y}=u;return bs(()=>(g(m),()=>y(m)),[g,y,m]),o.jsxs(o.Fragment,{children:[o.jsx(ft.span,{id:c.textId,...i,ref:f}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?cc.createPortal(i.children,a.valueNode):null]})});uxe.displayName=BS;var dxe="SelectItemIndicator",hxe=S.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return lxe(dxe,r).isSelected?o.jsx(ft.span,{"aria-hidden":!0,...n,ref:e}):null});hxe.displayName=dxe;var y8="SelectScrollUpButton",fxe=S.forwardRef((t,e)=>{const r=cg(y8,t.__scopeSelect),n=V9(y8,t.__scopeSelect),[s,i]=S.useState(!1),a=qt(e,n.onScrollButtonChange);return bs(()=>{if(r.viewport&&r.isPositioned){let l=function(){const u=c.scrollTop>0;i(u)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),s?o.jsx(mxe,{...t,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});fxe.displayName=y8;var v8="SelectScrollDownButton",pxe=S.forwardRef((t,e)=>{const r=cg(v8,t.__scopeSelect),n=V9(v8,t.__scopeSelect),[s,i]=S.useState(!1),a=qt(e,n.onScrollButtonChange);return bs(()=>{if(r.viewport&&r.isPositioned){let l=function(){const u=c.scrollHeight-c.clientHeight,d=Math.ceil(c.scrollTop)<u;i(d)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),s?o.jsx(mxe,{...t,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});pxe.displayName=v8;var mxe=S.forwardRef((t,e)=>{const{__scopeSelect:r,onAutoScroll:n,...s}=t,i=cg("SelectScrollButton",r),a=S.useRef(null),l=kD(r),c=S.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return S.useEffect(()=>()=>c(),[c]),bs(()=>{var d;const u=l().find(h=>h.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[l]),o.jsx(ft.div,{"aria-hidden":!0,...s,ref:e,style:{flexShrink:0,...s.style},onPointerDown:Qe(s.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(n,50))}),onPointerMove:Qe(s.onPointerMove,()=>{var u;(u=i.onItemLeave)==null||u.call(i),a.current===null&&(a.current=window.setInterval(n,50))}),onPointerLeave:Qe(s.onPointerLeave,()=>{c()})})}),IUe="SelectSeparator",gxe=S.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return o.jsx(ft.div,{"aria-hidden":!0,...n,ref:e})});gxe.displayName=IUe;var b8="SelectArrow",RUe=S.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=CD(r),i=lg(b8,r),a=cg(b8,r);return i.open&&a.position==="popper"?o.jsx(QM,{...s,...n,ref:e}):null});RUe.displayName=b8;var OUe="SelectBubbleInput",xxe=S.forwardRef(({__scopeSelect:t,value:e,...r},n)=>{const s=S.useRef(null),i=qt(n,s),a=W9(e);return S.useEffect(()=>{const l=s.current;if(!l)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(l,e),l.dispatchEvent(h)}},[a,e]),o.jsx(ft.select,{...r,style:{...Nhe,...r.style},ref:i,defaultValue:e})});xxe.displayName=OUe;function yxe(t){return t===""||t===void 0}function vxe(t){const e=ys(t),r=S.useRef(""),n=S.useRef(0),s=S.useCallback(a=>{const l=r.current+a;e(l),function c(u){r.current=u,window.clearTimeout(n.current),u!==""&&(n.current=window.setTimeout(()=>c(""),1e3))}(l)},[e]),i=S.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return S.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,s,i]}function bxe(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=MUe(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 MUe(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var DUe=qge,wxe=Kge,LUe=Xge,$Ue=Qge,FUe=Zge,jxe=Jge,BUe=nxe,zUe=ixe,Sxe=oxe,_xe=cxe,UUe=uxe,HUe=hxe,Nxe=fxe,kxe=pxe,Cxe=gxe;const pt=DUe,WUe=zUe,mt=LUe,ut=S.forwardRef(({className:t,children:e,...r},n)=>o.jsxs(wxe,{ref:n,className:Pe("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,o.jsx($Ue,{asChild:!0,children:o.jsx(ia,{className:"h-4 w-4 opacity-50"})})]}));ut.displayName=wxe.displayName;const Exe=S.forwardRef(({className:t,...e},r)=>o.jsx(Nxe,{ref:r,className:Pe("flex cursor-default items-center justify-center py-1",t),...e,children:o.jsx(FW,{className:"h-4 w-4"})}));Exe.displayName=Nxe.displayName;const Axe=S.forwardRef(({className:t,...e},r)=>o.jsx(kxe,{ref:r,className:Pe("flex cursor-default items-center justify-center py-1",t),...e,children:o.jsx(ia,{className:"h-4 w-4"})}));Axe.displayName=kxe.displayName;const dt=S.forwardRef(({className:t,children:e,position:r="popper",...n},s)=>o.jsx(FUe,{children:o.jsxs(jxe,{ref:s,className:Pe("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:[o.jsx(Exe,{}),o.jsx(BUe,{className:Pe("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),o.jsx(Axe,{})]})}));dt.displayName=jxe.displayName;const Txe=S.forwardRef(({className:t,...e},r)=>o.jsx(Sxe,{ref:r,className:Pe("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...e}));Txe.displayName=Sxe.displayName;const Le=S.forwardRef(({className:t,children:e,...r},n)=>o.jsxs(_xe,{ref:n,className:Pe("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:[o.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:o.jsx(HUe,{children:o.jsx(kr,{className:"h-4 w-4"})})}),o.jsx(UUe,{children:e})]}));Le.displayName=_xe.displayName;const VUe=S.forwardRef(({className:t,...e},r)=>o.jsx(Cxe,{ref:r,className:Pe("-mx-1 my-1 h-px bg-muted",t),...e}));VUe.displayName=Cxe.displayName;const FQ=["Thesis","Qualitative","Writing & Export"],Ng=[{id:"new-thesis",group:"Thesis",shortTitle:"New Thesis",title:"How to Create a New Thesis Project",description:"Set up your thesis title, structure, literature and citation settings.",videoUrl:"https://youtu.be/6bTAiNIVkrI"},{id:"library",group:"Thesis",shortTitle:"Library",title:"How to Upload Sources to Your Library & Correct PDF Page Numbers",description:"Upload PDFs and align page numbers with the printed source.",videoUrl:"https://youtu.be/oO4qHB2iya8"},{id:"theory",group:"Thesis",shortTitle:"Theory",title:"How to Create a Theory & Background Section",description:"Generate a theory section grounded in your selected sources.",videoUrl:"https://youtu.be/xs1QLaPItXQ"},{id:"openalex",group:"Thesis",shortTitle:"OpenAlex",title:"How to Find and Add External Research with OpenAlex",description:"Search external literature and add it to your library.",videoUrl:"https://youtu.be/egQI1kjwNkk"},{id:"methodology",group:"Thesis",shortTitle:"Methodology",title:"How to Generate a Methodology Section",description:"Describe your approach and build a source-based methodology.",videoUrl:"https://youtu.be/jqSGrrqs3so"},{id:"evidence",group:"Thesis",shortTitle:"Evidence",title:"How to Verify Citations and Evidence",description:"Check every citation against the exact source passage.",videoUrl:"https://youtu.be/hg_qb2Ltto0"},{id:"discussion",group:"Thesis",shortTitle:"Discussion",title:"How to Generate a Discussion",description:"Build a discussion from the chapters you have already written.",videoUrl:"https://youtu.be/uWE6AVoe0TU"},{id:"conclusion",group:"Thesis",shortTitle:"Conclusion",title:"How to Generate a Conclusion",description:"Summarise your work with limitations and an outlook.",videoUrl:"https://youtu.be/LjkTERx5K-0"},{id:"metadata",group:"Thesis",shortTitle:"Metadata",title:"How to Add Citation Metadata with DOI or ISBN",description:"Complete source details automatically from a DOI or ISBN.",videoUrl:"https://youtu.be/zmDjEv1nXAE"},{id:"research-design",group:"Qualitative",shortTitle:"Research Design",title:"How to Set Up Your Qualitative Research Design",description:"Define your research context, questions and interview guides.",videoUrl:"https://youtu.be/jquXc_CNxTE"},{id:"codebook",group:"Qualitative",shortTitle:"Codebook",title:"How to Build and Edit a Qualitative Codebook",description:"Create categories with definitions, rules and anchor examples.",videoUrl:"https://youtu.be/tX-Ucl_qTwM"},{id:"interviews",group:"Qualitative",shortTitle:"Interviews",title:"How to Import and Organize Interview Transcripts",description:"Add, view and edit your interview transcripts.",videoUrl:"https://youtu.be/Fjk3gJm9g4I"},{id:"ai-coding",group:"Qualitative",shortTitle:"AI Coding",title:"How to Code Interview Transcripts with AI",description:"Apply your codebook to transcripts with AI assistance.",videoUrl:"https://youtu.be/p0PM-D6Zso8"},{id:"results",group:"Qualitative",shortTitle:"Results",title:"How to Analyze Qualitative Results and Import Them into Your Thesis",description:"Review coded results and bring them into your thesis.",videoUrl:"https://youtu.be/wji1fS68qio"},{id:"fox-ai",group:"Writing & Export",shortTitle:"Fox AI",title:"How to Use Fox AI",description:"Get inline writing suggestions while you work."},{id:"supervisor",group:"Writing & Export",shortTitle:"Supervisor",title:"How to Use the Thesis Supervisor for Feedback and Revision",description:"Receive structured feedback and revise your chapters."},{id:"export",group:"Writing & Export",shortTitle:"Export",title:"How to Export Your Thesis",description:"Export your finished thesis as a formatted document."}];function BQ(t){if(!(t!=null&&t.trim()))return null;try{const e=new URL(t.trim()),r=e.hostname.replace(/^www\.|^m\./,"");let n=null;if(r==="youtu.be")n=e.pathname.slice(1).split("/")[0];else if(r==="youtube.com"||r==="youtube-nocookie.com")if(e.pathname==="/watch")n=e.searchParams.get("v");else{const s=e.pathname.match(/^\/(embed|shorts|live)\/([^/?]+)/);s&&(n=s[2])}if(n)return`https://www.youtube-nocookie.com/embed/${encodeURIComponent(n)}?rel=0`;if(r==="vimeo.com"){const s=e.pathname.split("/").filter(Boolean)[0];if(s&&/^\d+$/.test(s))return`https://player.vimeo.com/video/${s}`}if(r==="player.vimeo.com")return e.toString();if(r==="loom.com"){const s=e.pathname.match(/^\/(share|embed)\/([^/?]+)/);if(s)return`https://www.loom.com/embed/${s[2]}`}return null}catch{return null}}function qUe({open:t,onOpenChange:e}){const[r,n]=S.useState(Ng[0].id);S.useEffect(()=>{t&&n((Ng.find(a=>BQ(a.videoUrl))??Ng[0]).id)},[t]);const s=Ng.find(a=>a.id===r)??Ng[0],i=BQ(s.videoUrl);return o.jsx(jn,{open:t,onOpenChange:e,children:o.jsxs(pn,{className:"max-w-5xl gap-0 overflow-hidden rounded-2xl p-0 max-h-[90vh] flex flex-col",children:[o.jsxs(mn,{className:"border-b border-border/70 px-6 py-4 text-left",children:[o.jsx(gn,{className:"text-lg font-semibold",children:"Video Tutorials"}),o.jsx(og,{className:"sr-only",children:"Short videos explaining Academly workflows."})]}),o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[o.jsx("div",{className:"border-b border-border/70 p-4 md:hidden",children:o.jsxs(pt,{value:r,onValueChange:n,children:[o.jsx(ut,{className:"rounded-xl",children:o.jsx(mt,{})}),o.jsx(dt,{children:FQ.map(a=>o.jsxs(WUe,{children:[o.jsx(Txe,{children:a}),Ng.filter(l=>l.group===a).map(l=>o.jsx(Le,{value:l.id,children:l.shortTitle},l.id))]},a))})]})}),o.jsx("nav",{className:"hidden w-56 shrink-0 overflow-y-auto border-r border-border/70 bg-muted/20 p-3 md:block",children:FQ.map(a=>o.jsxs("div",{className:"mb-4 last:mb-0",children:[o.jsx("p",{className:"px-3 pb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:a}),o.jsx("ul",{className:"space-y-0.5",children:Ng.filter(l=>l.group===a).map(l=>o.jsx("li",{children:o.jsx("button",{type:"button",onClick:()=>n(l.id),"aria-current":l.id===r?"true":void 0,className:Pe("w-full rounded-xl px-3 py-1.5 text-left text-sm transition-colors",l.id===r?"bg-primary/10 font-medium text-primary":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:l.shortTitle})},l.id))})]},a))}),o.jsxs("section",{className:"min-w-0 flex-1 overflow-y-auto p-6",children:[o.jsx("div",{className:"aspect-video w-full overflow-hidden rounded-xl border border-border/70 bg-muted/20 shadow-sm",children:i?o.jsx("iframe",{src:i,title:s.title,className:"h-full w-full",allow:"encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0,loading:"lazy"},s.id):o.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-center",children:[o.jsx(UOe,{className:"h-10 w-10 text-primary/40",strokeWidth:1.5}),o.jsx("p",{className:"text-sm font-medium text-foreground",children:"Coming soon"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"This video is being recorded."})]})}),o.jsx("h3",{className:"mt-5 text-base font-semibold text-foreground",children:s.title}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s.description})]})]})]})})}const GUe=[{name:"Dashboard",path:"/dashboard",icon:o.jsx(zW,{className:"w-5 h-5"})},{name:"My Library",path:"/documents",icon:o.jsx(jr,{className:"w-5 h-5"})},{name:"My Citations",path:"/reference-checker",icon:o.jsx(ua,{className:"w-5 h-5"})},{name:"My Thesis",path:"/my-thesis-2",icon:o.jsx(WM,{className:"w-5 h-5"})}],KUe=[{name:"Qualitative",icon:o.jsx(mMe,{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"}]}];function YUe(t){return[{label:"",items:GUe,type:"workspace"},{label:"",items:KUe,type:"qualitative"}]}function XUe({isExpanded:t,isHovered:e,isMobileOpen:r,onHoverChange:n,onMobileClose:s}){const i=bd(),a=Or(),l=i.pathname,{theme:c}=T9(),[u,d]=S.useState(null),[h,f]=S.useState({}),[p,m]=S.useState(!1),g=S.useRef({}),y=!1;S.useEffect(()=>{const N=()=>{s(),a("/my-thesis-2/new")};return window.addEventListener("academly-open-new-thesis",N),()=>window.removeEventListener("academly-open-new-thesis",N)},[a,s]);const x=S.useMemo(()=>YUe(),[y]),v=S.useCallback(N=>l===N,[l]),b=t||e||r;S.useEffect(()=>{let N=!1;x.forEach(C=>{C.items.forEach((A,E)=>{A.subItems&&A.subItems.forEach(O=>{v(O.path)&&(d({type:C.type,index:E}),N=!0)})})}),N||d(null)},[i,v]),S.useEffect(()=>{if(u!==null){const N=`${u.type}-${u.index}`;g.current[N]&&f(C=>{var A;return{...C,[N]:((A=g.current[N])==null?void 0:A.scrollHeight)||0}})}},[u]);const w=(N,C)=>{d(A=>A&&A.type===C&&A.index===N?null:{type:C,index:N})},j=(N,C)=>o.jsx("ul",{className:"flex flex-col gap-1.5",children:N.map((A,E)=>o.jsx("li",{children:A.subItems?o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:()=>w(E,C),className:`astro-menu-item group w-full ${(u==null?void 0:u.type)===C&&(u==null?void 0:u.index)===E?"astro-menu-item-active":"astro-menu-item-inactive"} ${b?"":"justify-center"}`,children:[o.jsx("span",{className:`w-5 h-5 flex-shrink-0 transition-colors ${(u==null?void 0:u.type)===C&&(u==null?void 0:u.index)===E?"text-primary":"text-muted-foreground group-hover:text-foreground"}`,children:A.icon}),b&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"flex-1 text-left",children:A.name}),o.jsx(ia,{className:`w-4 h-4 transition-transform duration-300 ${(u==null?void 0:u.type)===C&&(u==null?void 0:u.index)===E?"rotate-180":""}`})]})]}),b&&o.jsx("div",{ref:O=>{g.current[`${C}-${E}`]=O},className:"overflow-hidden transition-all duration-300 ease-out",style:{height:(u==null?void 0:u.type)===C&&(u==null?void 0:u.index)===E?`${h[`${C}-${E}`]}px`:"0px"},children:o.jsx("ul",{className:"mt-2 ml-9 space-y-1",children:A.subItems.map(O=>o.jsx("li",{children:o.jsx(Nt,{to:O.path,onClick:s,className:`astro-dropdown-item ${v(O.path)?"astro-dropdown-item-active":"astro-dropdown-item-inactive"}`,children:O.name})},O.name))})})]}):A.path?o.jsxs(Nt,{to:A.path,onClick:s,className:`astro-menu-item group ${v(A.path)?"astro-menu-item-active":"astro-menu-item-inactive"} ${b?"":"justify-center"}`,children:[o.jsx("span",{className:`w-5 h-5 flex-shrink-0 transition-colors ${v(A.path)?"text-primary":"text-muted-foreground group-hover:text-foreground"}`,children:A.icon}),b&&o.jsx("span",{children:A.name})]}):null},A.name))});return o.jsxs(o.Fragment,{children:[r&&o.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 lg:hidden",onClick:s}),o.jsxs("aside",{className:`ta-sidebar astro-sidebar ${b?"ta-sidebar-expanded":"ta-sidebar-collapsed"} ${r?"ta-sidebar-mobile-open":"ta-sidebar-mobile-closed"}`,onMouseEnter:()=>!t&&n(!0),onMouseLeave:()=>n(!1),children:[o.jsx("div",{className:`ta-sidebar-logo ${b?"":"justify-center"}`,children:o.jsx(Nt,{to:"/dashboard",className:"flex items-center",children:b?o.jsx("img",{src:c==="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"}):o.jsx("div",{className:"w-8 h-8 bg-primary rounded-lg flex items-center justify-center",children:o.jsx("span",{className:"text-primary-foreground font-bold text-sm",children:"ST"})})})}),o.jsx("div",{className:`px-3 pt-3 pb-2 ${b?"":"flex justify-center"}`,children:o.jsxs("button",{onClick:()=>{s(),a("/my-thesis-2/new")},className:Pe("astro-menu-item group w-full border border-primary/15 bg-primary/[0.06] text-foreground hover:border-primary/25 hover:bg-primary/[0.09]",l==="/my-thesis-2/new"&&"border-primary/25 bg-primary/[0.10]",!b&&"justify-center"),"aria-label":"New Thesis",children:[o.jsx("span",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary transition-colors group-hover:bg-primary/15",children:o.jsx(Bs,{className:"h-4 w-4"})}),b&&o.jsxs("span",{className:"flex-1 text-left",children:[o.jsx("span",{className:"block text-sm font-medium",children:"New Thesis"}),o.jsx("span",{className:"mt-0.5 block text-[10px] font-normal text-muted-foreground",children:"Create or import"})]})]})}),o.jsx("nav",{className:"ta-sidebar-nav no-scrollbar",children:x.map(N=>o.jsxs("div",{className:"ta-sidebar-section",children:[N.label&&o.jsx("h2",{className:`ta-sidebar-section-label ${b?"":"text-center"}`,children:b?N.label:"•••"}),j(N.items,N.type)]},N.type))}),o.jsx("div",{className:"border-t border-border/70 px-5 py-3",children:o.jsx(ri,{delayDuration:200,children:o.jsx("ul",{className:"flex flex-col gap-1",children:[{name:"Tutorials",icon:o.jsx(RMe,{className:"h-5 w-5"}),onClick:()=>{s(),m(!0)}},{name:"Documentation",icon:o.jsx($Oe,{className:"h-5 w-5"}),onClick:()=>{s(),a("/docs")}}].map(N=>o.jsx("li",{children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsxs("button",{type:"button",onClick:N.onClick,"aria-label":N.name,className:`astro-menu-item astro-menu-item-inactive group w-full ${b?"":"justify-center"}`,children:[o.jsx("span",{className:"w-5 h-5 flex-shrink-0 text-muted-foreground transition-colors group-hover:text-foreground",children:N.icon}),b&&o.jsx("span",{className:"flex-1 text-left",children:N.name})]})}),!b&&o.jsx(xr,{side:"right",children:N.name})]})},N.name))})})})]}),o.jsx(qUe,{open:p,onOpenChange:m})]})}const Cr=({children:t,showSidebar:e=!1,pageTitle:r="Dashboard",fullWidth:n=!1,hidePlatformAssistant:s=!1})=>{const{user:i}=Ht(),[a,l]=S.useState(!0),[c,u]=S.useState(!1),[d,h]=S.useState(!1),f=a||c;return e&&i?o.jsxs("div",{className:"ta-layout astro-gradient-bg min-h-screen",children:[o.jsx(XUe,{isExpanded:a,isHovered:c,isMobileOpen:d,onHoverChange:u,onMobileClose:()=>h(!1)}),o.jsxs("div",{className:`ta-main ${f?"ta-main-expanded":"ta-main-collapsed"}`,children:[o.jsx($Q,{pageTitle:r,onToggleSidebar:()=>l(!a),onToggleMobile:()=>h(!d),isMobileOpen:d}),o.jsx("main",{className:`flex-1 animate-fade-in ${n?"p-5 md:p-6 xl:p-8":"ta-content"}`,children:o.jsx("div",{className:n?"w-full":"max-w-screen-xl mx-auto",children:t})})]})]}):o.jsxs("div",{className:"min-h-screen flex flex-col w-full bg-background",children:[o.jsx($Q,{showSidebarControls:!1}),o.jsx("main",{className:"flex-1 w-full",children:t}),o.jsx(Ii,{})]})};function QUe(){const[t,e]=S.useState(null),[r,n]=S.useState([]),[s,i]=S.useState(!0),[a,l]=S.useState(null),c=async()=>{try{i(!0),l(null);const{data:u,error:d}=await pe.from("v_dashboard_stats").select("*").single();if(d)throw d;if(e(u),!(u!=null&&u.active_thesis_id)){n([]);return}const{data:h,error:f}=await pe.from("chapters").select("id,title,order_index,status,progress,target_share,updated_at").eq("thesis_id",u.active_thesis_id).is("parent_id",null).order("order_index",{ascending:!0});if(f)throw f;n(h??[])}catch(u){console.error("Error fetching dashboard stats:",u),l(u)}finally{i(!1)}};return S.useEffect(()=>{c()},[]),{stats:t,chapters:r,loading:s,error:a,refetch:c}}const Ze=S.forwardRef(({className:t,...e},r)=>o.jsx("div",{ref:r,className:Pe("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 Ot=S.forwardRef(({className:t,...e},r)=>o.jsx("div",{ref:r,className:Pe("flex flex-col space-y-1.5 px-5 py-4",t),...e}));Ot.displayName="CardHeader";const Ft=S.forwardRef(({className:t,...e},r)=>o.jsx("h3",{ref:r,className:Pe("text-base font-semibold leading-none tracking-tight text-foreground",t),...e}));Ft.displayName="CardTitle";const Es=S.forwardRef(({className:t,...e},r)=>o.jsx("p",{ref:r,className:Pe("text-sm text-muted-foreground",t),...e}));Es.displayName="CardDescription";const st=S.forwardRef(({className:t,...e},r)=>o.jsx("div",{ref:r,className:Pe("px-5 pb-5 pt-0",t),...e}));st.displayName="CardContent";const ZUe=S.forwardRef(({className:t,...e},r)=>o.jsx("div",{ref:r,className:Pe("flex items-center px-5 pb-5 pt-0",t),...e}));ZUe.displayName="CardFooter";var q9="Progress",G9=100,[JUe,SWt]=Vs(q9),[eHe,tHe]=JUe(q9),Pxe=S.forwardRef((t,e)=>{const{__scopeProgress:r,value:n=null,max:s,getValueLabel:i=rHe,...a}=t;(s||s===0)&&!zQ(s)&&console.error(nHe(`${s}`,"Progress"));const l=zQ(s)?s:G9;n!==null&&!UQ(n,l)&&console.error(sHe(`${n}`,"Progress"));const c=UQ(n,l)?n:null,u=zI(c)?i(c,l):void 0;return o.jsx(eHe,{scope:r,value:c,max:l,children:o.jsx(ft.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":zI(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":Oxe(c,l),"data-value":c??void 0,"data-max":l,...a,ref:e})})});Pxe.displayName=q9;var Ixe="ProgressIndicator",Rxe=S.forwardRef((t,e)=>{const{__scopeProgress:r,...n}=t,s=tHe(Ixe,r);return o.jsx(ft.div,{"data-state":Oxe(s.value,s.max),"data-value":s.value??void 0,"data-max":s.max,...n,ref:e})});Rxe.displayName=Ixe;function rHe(t,e){return`${Math.round(t/e*100)}%`}function Oxe(t,e){return t==null?"indeterminate":t===e?"complete":"loading"}function zI(t){return typeof t=="number"}function zQ(t){return zI(t)&&!isNaN(t)&&t>0}function UQ(t,e){return zI(t)&&!isNaN(t)&&t<=e&&t>=0}function nHe(t,e){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${e}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${G9}\`.`}function sHe(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 ${G9} if no \`max\` prop is set)
  - \`null\` or \`undefined\` if the progress is indeterminate.

Defaulting to \`null\`.`}var Mxe=Pxe,iHe=Rxe;const Dxe=S.createContext({});function aHe(t){const e=S.useRef(null);return e.current===null&&(e.current=t()),e.current}const K9=typeof window<"u",oHe=K9?S.useLayoutEffect:S.useEffect,Y9=S.createContext(null);function X9(t,e){t.indexOf(e)===-1&&t.push(e)}function Q9(t,e){const r=t.indexOf(e);r>-1&&t.splice(r,1)}const ff=(t,e,r)=>r>e?e:r<t?t:r;let UI=()=>{};const pf={},Lxe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function $xe(t){return typeof t=="object"&&t!==null}const Fxe=t=>/^0[^.\s]+$/u.test(t);function Z9(t){let e;return()=>(e===void 0&&(e=t()),e)}const tc=t=>t,lHe=(t,e)=>r=>e(t(r)),qE=(...t)=>t.reduce(lHe),DN=(t,e,r)=>{const n=e-t;return n===0?1:(r-t)/n};class J9{constructor(){this.subscriptions=[]}add(e){return X9(this.subscriptions,e),()=>Q9(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 id=t=>t*1e3,Kl=t=>t/1e3;function Bxe(t,e){return e?t*(1e3/e):0}const zxe=(t,e,r)=>(((1-3*r+3*e)*t+(3*r-6*e))*t+3*e)*t,cHe=1e-7,uHe=12;function dHe(t,e,r,n,s){let i,a,l=0;do a=e+(r-e)/2,i=zxe(a,n,s)-t,i>0?r=a:e=a;while(Math.abs(i)>cHe&&++l<uHe);return a}function GE(t,e,r,n){if(t===e&&r===n)return tc;const s=i=>dHe(i,0,1,t,r);return i=>i===0||i===1?i:zxe(s(i),e,n)}const Uxe=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,Hxe=t=>e=>1-t(1-e),Wxe=GE(.33,1.53,.69,.99),eV=Hxe(Wxe),Vxe=Uxe(eV),qxe=t=>(t*=2)<1?.5*eV(t):.5*(2-Math.pow(2,-10*(t-1))),tV=t=>1-Math.sin(Math.acos(t)),Gxe=Hxe(tV),Kxe=Uxe(tV),hHe=GE(.42,0,1,1),fHe=GE(0,0,.58,1),Yxe=GE(.42,0,.58,1),pHe=t=>Array.isArray(t)&&typeof t[0]!="number",Xxe=t=>Array.isArray(t)&&typeof t[0]=="number",HQ={linear:tc,easeIn:hHe,easeInOut:Yxe,easeOut:fHe,circIn:tV,circInOut:Kxe,circOut:Gxe,backIn:eV,backInOut:Vxe,backOut:Wxe,anticipate:qxe},mHe=t=>typeof t=="string",WQ=t=>{if(Xxe(t)){UI(t.length===4);const[e,r,n,s]=t;return GE(e,r,n,s)}else if(mHe(t))return UI(HQ[t]!==void 0),HQ[t];return t},lT=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],VQ={value:null,addProjectionMetrics:null};function gHe(t,e){let r=new Set,n=new Set,s=!1,i=!1;const a=new WeakSet;let l={delta:0,timestamp:0,isProcessing:!1},c=0;function u(h){a.has(h)&&(d.schedule(h),t()),c++,h(l)}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(l=h,s){i=!0;return}s=!0,[r,n]=[n,r],r.forEach(u),e&&VQ.value&&VQ.value.frameloop[e].push(c),c=0,r.clear(),s=!1,i&&(i=!1,d.process(h))}};return d}const xHe=40;function Qxe(t,e){let r=!1,n=!0;const s={delta:0,timestamp:0,isProcessing:!1},i=()=>r=!0,a=lT.reduce((b,w)=>(b[w]=gHe(i,e?w:void 0),b),{}),{setup:l,read:c,resolveKeyframes:u,preUpdate:d,update:h,preRender:f,render:p,postRender:m}=a,g=()=>{const b=pf.useManualTiming?s.timestamp:performance.now();r=!1,pf.useManualTiming||(s.delta=n?1e3/60:Math.max(Math.min(b-s.timestamp,xHe),1)),s.timestamp=b,s.isProcessing=!0,l.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))},y=()=>{r=!0,n=!0,s.isProcessing||t(g)};return{schedule:lT.reduce((b,w)=>{const j=a[w];return b[w]=(N,C=!1,A=!1)=>(r||y(),j.schedule(N,C,A)),b},{}),cancel:b=>{for(let w=0;w<lT.length;w++)a[lT[w]].cancel(b)},state:s,steps:a}}const{schedule:Yn,cancel:Wm,state:Yi,steps:R4}=Qxe(typeof requestAnimationFrame<"u"?requestAnimationFrame:tc,!0);let Q2;function yHe(){Q2=void 0}const yo={now:()=>(Q2===void 0&&yo.set(Yi.isProcessing||pf.useManualTiming?Yi.timestamp:performance.now()),Q2),set:t=>{Q2=t,queueMicrotask(yHe)}},Zxe=t=>e=>typeof e=="string"&&e.startsWith(t),Jxe=Zxe("--"),vHe=Zxe("var(--"),rV=t=>vHe(t)?bHe.test(t.split("/*")[0].trim()):!1,bHe=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,mj={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},LN={...mj,transform:t=>ff(0,1,t)},cT={...mj,default:1},O_=t=>Math.round(t*1e5)/1e5,nV=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function wHe(t){return t==null}const jHe=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,sV=(t,e)=>r=>!!(typeof r=="string"&&jHe.test(r)&&r.startsWith(t)||e&&!wHe(r)&&Object.prototype.hasOwnProperty.call(r,e)),eye=(t,e,r)=>n=>{if(typeof n!="string")return n;const[s,i,a,l]=n.match(nV);return{[t]:parseFloat(s),[e]:parseFloat(i),[r]:parseFloat(a),alpha:l!==void 0?parseFloat(l):1}},SHe=t=>ff(0,255,t),O4={...mj,transform:t=>Math.round(SHe(t))},ax={test:sV("rgb","red"),parse:eye("red","green","blue"),transform:({red:t,green:e,blue:r,alpha:n=1})=>"rgba("+O4.transform(t)+", "+O4.transform(e)+", "+O4.transform(r)+", "+O_(LN.transform(n))+")"};function _He(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 w8={test:sV("#"),parse:_He,transform:ax.transform},KE=t=>({test:e=>typeof e=="string"&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),tp=KE("deg"),ad=KE("%"),Vt=KE("px"),NHe=KE("vh"),kHe=KE("vw"),qQ={...ad,parse:t=>ad.parse(t)/100,transform:t=>ad.transform(t*100)},Hb={test:sV("hsl","hue"),parse:eye("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+ad.transform(O_(e))+", "+ad.transform(O_(r))+", "+O_(LN.transform(n))+")"},Ds={test:t=>ax.test(t)||w8.test(t)||Hb.test(t),parse:t=>ax.test(t)?ax.parse(t):Hb.test(t)?Hb.parse(t):w8.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?ax.transform(t):Hb.transform(t),getAnimatableNone:t=>{const e=Ds.parse(t);return e.alpha=0,Ds.transform(e)}},CHe=/(?:#[\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(nV))==null?void 0:e.length)||0)+(((r=t.match(CHe))==null?void 0:r.length)||0)>0}const tye="number",rye="color",AHe="var",THe="var(",GQ="${}",PHe=/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 $N(t){const e=t.toString(),r=[],n={color:[],number:[],var:[]},s=[];let i=0;const l=e.replace(PHe,c=>(Ds.test(c)?(n.color.push(i),s.push(rye),r.push(Ds.parse(c))):c.startsWith(THe)?(n.var.push(i),s.push(AHe),r.push(c)):(n.number.push(i),s.push(tye),r.push(parseFloat(c))),++i,GQ)).split(GQ);return{values:r,split:l,indexes:n,types:s}}function nye(t){return $N(t).values}function sye(t){const{split:e,types:r}=$N(t),n=e.length;return s=>{let i="";for(let a=0;a<n;a++)if(i+=e[a],s[a]!==void 0){const l=r[a];l===tye?i+=O_(s[a]):l===rye?i+=Ds.transform(s[a]):i+=s[a]}return i}}const IHe=t=>typeof t=="number"?0:Ds.test(t)?Ds.getAnimatableNone(t):t;function RHe(t){const e=nye(t);return sye(t)(e.map(IHe))}const Vm={test:EHe,parse:nye,createTransformer:sye,getAnimatableNone:RHe};function M4(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 OHe({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 l=r<.5?r*(1+e):r+e-r*e,c=2*r-l;s=M4(c,l,t+1/3),i=M4(c,l,t),a=M4(c,l,t-1/3)}return{red:Math.round(s*255),green:Math.round(i*255),blue:Math.round(a*255),alpha:n}}function HI(t,e){return r=>r>0?e:t}const ts=(t,e,r)=>t+(e-t)*r,D4=(t,e,r)=>{const n=t*t,s=r*(e*e-n)+n;return s<0?0:Math.sqrt(s)},MHe=[w8,ax,Hb],DHe=t=>MHe.find(e=>e.test(t));function KQ(t){const e=DHe(t);if(!e)return!1;let r=e.parse(t);return e===Hb&&(r=OHe(r)),r}const YQ=(t,e)=>{const r=KQ(t),n=KQ(e);if(!r||!n)return HI(t,e);const s={...r};return i=>(s.red=D4(r.red,n.red,i),s.green=D4(r.green,n.green,i),s.blue=D4(r.blue,n.blue,i),s.alpha=ts(r.alpha,n.alpha,i),ax.transform(s))},j8=new Set(["none","hidden"]);function LHe(t,e){return j8.has(t)?r=>r<=0?t:e:r=>r>=1?e:t}function $He(t,e){return r=>ts(t,e,r)}function iV(t){return typeof t=="number"?$He:typeof t=="string"?rV(t)?HI:Ds.test(t)?YQ:zHe:Array.isArray(t)?iye:typeof t=="object"?Ds.test(t)?YQ:FHe:HI}function iye(t,e){const r=[...t],n=r.length,s=t.map((i,a)=>iV(i)(i,e[a]));return i=>{for(let a=0;a<n;a++)r[a]=s[a](i);return r}}function FHe(t,e){const r={...t,...e},n={};for(const s in r)t[s]!==void 0&&e[s]!==void 0&&(n[s]=iV(t[s])(t[s],e[s]));return s=>{for(const i in n)r[i]=n[i](s);return r}}function BHe(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]],l=t.values[a]??0;r[s]=l,n[i]++}return r}const zHe=(t,e)=>{const r=Vm.createTransformer(e),n=$N(t),s=$N(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?j8.has(t)&&!s.values.length||j8.has(e)&&!n.values.length?LHe(t,e):qE(iye(BHe(n,s),s.values),r):HI(t,e)};function aye(t,e,r){return typeof t=="number"&&typeof e=="number"&&typeof r=="number"?ts(t,e,r):iV(t)(t,e)}const UHe=t=>{const e=({timestamp:r})=>t(r);return{start:(r=!0)=>Yn.update(e,r),stop:()=>Wm(e),now:()=>Yi.isProcessing?Yi.timestamp:yo.now()}},oye=(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)})`},WI=2e4;function aV(t){let e=0;const r=50;let n=t.next(e);for(;!n.done&&e<WI;)e+=r,n=t.next(e);return e>=WI?1/0:e}function HHe(t,e=100,r){const n=r({...t,keyframes:[0,e]}),s=Math.min(aV(n),WI);return{type:"keyframes",ease:i=>n.next(s*i).value/e,duration:Kl(s)}}const WHe=5;function lye(t,e,r){const n=Math.max(e-WHe,0);return Bxe(r-t(n),e-n)}const fs={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},L4=.001;function VHe({duration:t=fs.duration,bounce:e=fs.bounce,velocity:r=fs.velocity,mass:n=fs.mass}){let s,i,a=1-e;a=ff(fs.minDamping,fs.maxDamping,a),t=ff(fs.minDuration,fs.maxDuration,Kl(t)),a<1?(s=u=>{const d=u*a,h=d*t,f=d-r,p=S8(u,a),m=Math.exp(-h);return L4-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=S8(Math.pow(u,2),a);return(-s(u)+L4>0?-1:1)*((f-p)*m)/g}):(s=u=>{const d=Math.exp(-u*t),h=(u-r)*t+1;return-L4+d*h},i=u=>{const d=Math.exp(-u*t),h=(r-u)*(t*t);return d*h});const l=5/t,c=GHe(s,i,l);if(t=id(t),isNaN(c))return{stiffness:fs.stiffness,damping:fs.damping,duration:t};{const u=Math.pow(c,2)*n;return{stiffness:u,damping:a*2*Math.sqrt(n*u),duration:t}}}const qHe=12;function GHe(t,e,r){let n=r;for(let s=1;s<qHe;s++)n=n-t(n)/e(n);return n}function S8(t,e){return t*Math.sqrt(1-e*e)}const KHe=["duration","bounce"],YHe=["stiffness","damping","mass"];function XQ(t,e){return e.some(r=>t[r]!==void 0)}function XHe(t){let e={velocity:fs.velocity,stiffness:fs.stiffness,damping:fs.damping,mass:fs.mass,isResolvedFromDuration:!1,...t};if(!XQ(t,YHe)&&XQ(t,KHe))if(t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),s=n*n,i=2*ff(.05,1,1-(t.bounce||0))*Math.sqrt(s);e={...e,mass:fs.mass,stiffness:s,damping:i}}else{const r=VHe(t);e={...e,...r,mass:fs.mass},e.isResolvedFromDuration=!0}return e}function VI(t=fs.visualDuration,e=fs.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],l={done:!1,value:i},{stiffness:c,damping:u,mass:d,duration:h,velocity:f,isResolvedFromDuration:p}=XHe({...r,velocity:-Kl(r.velocity||0)}),m=f||0,g=u/(2*Math.sqrt(c*d)),y=a-i,x=Kl(Math.sqrt(c/d)),v=Math.abs(y)<5;n||(n=v?fs.restSpeed.granular:fs.restSpeed.default),s||(s=v?fs.restDelta.granular:fs.restDelta.default);let b;if(g<1){const j=S8(x,g);b=N=>{const C=Math.exp(-g*x*N);return a-C*((m+g*x*y)/j*Math.sin(j*N)+y*Math.cos(j*N))}}else if(g===1)b=j=>a-Math.exp(-x*j)*(y+(m+x*y)*j);else{const j=x*Math.sqrt(g*g-1);b=N=>{const C=Math.exp(-g*x*N),A=Math.min(j*N,300);return a-C*((m+g*x*y)*Math.sinh(A)+j*y*Math.cosh(A))/j}}const w={calculatedDuration:p&&h||null,next:j=>{const N=b(j);if(p)l.done=j>=h;else{let C=j===0?m:0;g<1&&(C=j===0?id(m):lye(b,j,N));const A=Math.abs(C)<=n,E=Math.abs(a-N)<=s;l.done=A&&E}return l.value=l.done?a:N,l},toString:()=>{const j=Math.min(aV(w),WI),N=oye(C=>w.next(j*C).value,j,30);return j+"ms "+N},toTransition:()=>{}};return w}VI.applyToOptions=t=>{const e=HHe(t,100,VI);return t.ease=e.ease,t.duration=id(e.duration),t.type="keyframes",t};function _8({keyframes:t,velocity:e=0,power:r=.8,timeConstant:n=325,bounceDamping:s=10,bounceStiffness:i=500,modifyTarget:a,min:l,max:c,restDelta:u=.5,restSpeed:d}){const h=t[0],f={done:!1,value:h},p=A=>l!==void 0&&A<l||c!==void 0&&A>c,m=A=>l===void 0?c:c===void 0||Math.abs(l-A)<Math.abs(c-A)?l:c;let g=r*e;const y=h+g,x=a===void 0?y:a(y);x!==y&&(g=x-h);const v=A=>-g*Math.exp(-A/n),b=A=>x+v(A),w=A=>{const E=v(A),O=b(A);f.done=Math.abs(E)<=u,f.value=f.done?x:O};let j,N;const C=A=>{p(f.value)&&(j=A,N=VI({keyframes:[f.value,m(f.value)],velocity:lye(b,A,f.value),damping:s,stiffness:i,restDelta:u,restSpeed:d}))};return C(0),{calculatedDuration:null,next:A=>{let E=!1;return!N&&j===void 0&&(E=!0,w(A),C(A)),j!==void 0&&A>=j?N.next(A-j):(!E&&w(A),f)}}}function QHe(t,e,r){const n=[],s=r||pf.mix||aye,i=t.length-1;for(let a=0;a<i;a++){let l=s(t[a],t[a+1]);if(e){const c=Array.isArray(e)?e[a]||tc:e;l=qE(c,l)}n.push(l)}return n}function ZHe(t,e,{clamp:r=!0,ease:n,mixer:s}={}){const i=t.length;if(UI(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 l=QHe(e,n,s),c=l.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=DN(t[h],t[h+1],d);return l[h](f)};return r?d=>u(ff(t[0],t[i-1],d)):u}function JHe(t,e){const r=t[t.length-1];for(let n=1;n<=e;n++){const s=DN(0,e,n);t.push(ts(r,1,s))}}function e7e(t){const e=[0];return JHe(e,t.length-1),e}function t7e(t,e){return t.map(r=>r*e)}function r7e(t,e){return t.map(()=>e||Yxe).splice(0,t.length-1)}function M_({duration:t=300,keyframes:e,times:r,ease:n="easeInOut"}){const s=pHe(n)?n.map(WQ):WQ(n),i={done:!1,value:e[0]},a=t7e(r&&r.length===e.length?r:e7e(e),t),l=ZHe(a,e,{ease:Array.isArray(s)?s:r7e(e,s)});return{calculatedDuration:t,next:c=>(i.value=l(c),i.done=c>=t,i)}}const n7e=t=>t!==null;function oV(t,{repeat:e,repeatType:r="loop"},n,s=1){const i=t.filter(n7e),l=s<0||e&&r!=="loop"&&e%2===1?0:i.length-1;return!l||n===void 0?i[l]:n}const s7e={decay:_8,inertia:_8,tween:M_,keyframes:M_,spring:VI};function cye(t){typeof t.type=="string"&&(t.type=s7e[t.type])}class lV{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 i7e=t=>t/100;class cV extends lV{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!==yo.now()&&this.tick(yo.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;cye(e);const{type:r=M_,repeat:n=0,repeatDelay:s=0,repeatType:i,velocity:a=0}=e;let{keyframes:l}=e;const c=r||M_;c!==M_&&typeof l[0]!="number"&&(this.mixKeyframes=qE(i7e,aye(l[0],l[1])),l=[0,100]);const u=c({...e,keyframes:l});i==="mirror"&&(this.mirroredGenerator=c({...e,keyframes:[...l].reverse(),velocity:-a})),u.calculatedDuration===null&&(u.calculatedDuration=aV(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:l,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:y}=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 x=this.currentTime-u*(this.playbackSpeed>=0?1:-1),v=this.playbackSpeed>=0?x<0:x>s;this.currentTime=Math.max(x,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=s);let b=this.currentTime,w=n;if(h){const A=Math.min(this.currentTime,s)/l;let E=Math.floor(A),O=A%1;!O&&A>=1&&(O=1),O===1&&E--,E=Math.min(E,h+1),!!(E%2)&&(f==="reverse"?(O=1-O,p&&(O-=p/l)):f==="mirror"&&(w=a)),b=ff(0,1,O)*l}const j=v?{done:!1,value:d[0]}:w.next(b);i&&(j.value=i(j.value));let{done:N}=j;!v&&c!==null&&(N=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const C=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&N);return C&&m!==_8&&(j.value=oV(d,this.options,y,this.speed)),g&&g(j.value),C&&this.finish(),j}then(e,r){return this.finished.then(e,r)}get duration(){return Kl(this.calculatedDuration)}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Kl(e)}get time(){return Kl(this.currentTime)}set time(e){var r;e=id(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(yo.now());const r=this.playbackSpeed!==e;this.playbackSpeed=e,r&&(this.time=Kl(this.currentTime))}play(){var s,i;if(this.isStopped)return;const{driver:e=UHe,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(yo.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 a7e(t){for(let e=1;e<t.length;e++)t[e]??(t[e]=t[e-1])}const ox=t=>t*180/Math.PI,N8=t=>{const e=ox(Math.atan2(t[1],t[0]));return k8(e)},o7e={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:N8,rotateZ:N8,skewX:t=>ox(Math.atan(t[1])),skewY:t=>ox(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},k8=t=>(t=t%360,t<0&&(t+=360),t),QQ=N8,ZQ=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),JQ=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),l7e={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ZQ,scaleY:JQ,scale:t=>(ZQ(t)+JQ(t))/2,rotateX:t=>k8(ox(Math.atan2(t[6],t[5]))),rotateY:t=>k8(ox(Math.atan2(-t[2],t[0]))),rotateZ:QQ,rotate:QQ,skewX:t=>ox(Math.atan(t[4])),skewY:t=>ox(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function C8(t){return t.includes("scale")?1:0}function E8(t,e){if(!t||t==="none")return C8(e);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,s;if(r)n=l7e,s=r;else{const l=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=o7e,s=l}if(!s)return C8(e);const i=n[e],a=s[1].split(",").map(u7e);return typeof i=="function"?i(a):a[i]}const c7e=(t,e)=>{const{transform:r="none"}=getComputedStyle(t);return E8(r,e)};function u7e(t){return parseFloat(t.trim())}const gj=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],xj=new Set(gj),eZ=t=>t===mj||t===Vt,d7e=new Set(["x","y","z"]),h7e=gj.filter(t=>!d7e.has(t));function f7e(t){const e=[];return h7e.forEach(r=>{const n=t.getValue(r);n!==void 0&&(e.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),e}const Fy={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})=>E8(e,"x"),y:(t,{transform:e})=>E8(e,"y")};Fy.translateX=Fy.x;Fy.translateY=Fy.y;const By=new Set;let A8=!1,T8=!1,P8=!1;function uye(){if(T8){const t=Array.from(By).filter(n=>n.needsMeasurement),e=new Set(t.map(n=>n.element)),r=new Map;e.forEach(n=>{const s=f7e(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 l;(l=n.getValue(i))==null||l.set(a)})}),t.forEach(n=>n.measureEndState()),t.forEach(n=>{n.suspendedScrollY!==void 0&&window.scrollTo(0,n.suspendedScrollY)})}T8=!1,A8=!1,By.forEach(t=>t.complete(P8)),By.clear()}function dye(){By.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(T8=!0)})}function p7e(){P8=!0,dye(),uye(),P8=!1}class uV{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?(By.add(this),A8||(A8=!0,Yn.read(dye),Yn.resolveKeyframes(uye))):(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 l=n.readValue(r,a);l!=null&&(e[0]=l)}e[0]===void 0&&(e[0]=a),s&&i===void 0&&s.set(e[0])}a7e(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),By.delete(this)}cancel(){this.state==="scheduled"&&(By.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const m7e=t=>t.startsWith("--");function g7e(t,e,r){m7e(e)?t.style.setProperty(e,r):t.style[e]=r}const x7e=Z9(()=>window.ScrollTimeline!==void 0),y7e={};function v7e(t,e){const r=Z9(t);return()=>y7e[e]??r()}const hye=v7e(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),zS=([t,e,r,n])=>`cubic-bezier(${t}, ${e}, ${r}, ${n})`,tZ={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:zS([0,.65,.55,1]),circOut:zS([.55,0,1,.45]),backIn:zS([.31,.01,.66,-.59]),backOut:zS([.33,1.53,.69,.99])};function fye(t,e){if(t)return typeof t=="function"?hye()?oye(t,e):"ease-out":Xxe(t)?zS(t):Array.isArray(t)?t.map(r=>fye(r,e)||tZ.easeOut):tZ[t]}function b7e(t,e,r,{delay:n=0,duration:s=300,repeat:i=0,repeatType:a="loop",ease:l="easeOut",times:c}={},u=void 0){const d={[e]:r};c&&(d.offset=c);const h=fye(l,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 pye(t){return typeof t=="function"&&"applyToOptions"in t}function w7e({type:t,...e}){return pye(t)&&hye()?t.applyToOptions(e):(e.duration??(e.duration=300),e.ease??(e.ease="easeOut"),e)}class j7e extends lV{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:l,onComplete:c}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,UI(typeof e.type!="string");const u=w7e(e);this.animation=b7e(r,n,s,u,i),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){const d=oV(s,this.options,l,this.speed);this.updateMotionValue?this.updateMotionValue(d):g7e(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 Kl(Number(e))}get iterationDuration(){const{delay:e=0}=this.options||{};return this.duration+Kl(e)}get time(){return Kl(Number(this.animation.currentTime)||0)}set time(e){this.finishedTime=null,this.animation.currentTime=id(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&&x7e()?(this.animation.timeline=e,tc):r(this)}}const mye={anticipate:qxe,backInOut:Vxe,circInOut:Kxe};function S7e(t){return t in mye}function _7e(t){typeof t.ease=="string"&&S7e(t.ease)&&(t.ease=mye[t.ease])}const rZ=10;class N7e extends j7e{constructor(e){_7e(e),cye(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 l=new cV({...a,autoplay:!1}),c=id(this.finishedTime??this.time);r.setWithVelocity(l.sample(c-rZ).value,l.sample(c).value,rZ),l.stop()}}const nZ=(t,e)=>e==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(Vm.test(t)||t==="0")&&!t.startsWith("url("));function k7e(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 C7e(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=nZ(s,e),l=nZ(i,e);return!a||!l?!1:k7e(t)||(r==="spring"||pye(r))&&n}function I8(t){t.duration=0,t.type="keyframes"}const E7e=new Set(["opacity","clipPath","filter","transform"]),A7e=Z9(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function T7e(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 A7e()&&r&&E7e.has(r)&&(r!=="transform"||!u)&&!c&&!n&&s!=="mirror"&&i!==0&&a!=="inertia"}const P7e=40;class I7e extends lV{constructor({autoplay:e=!0,delay:r=0,type:n="keyframes",repeat:s=0,repeatDelay:i=0,repeatType:a="loop",keyframes:l,name:c,motionValue:u,element:d,...h}){var m;super(),this.stop=()=>{var g,y;this._animation&&(this._animation.stop(),(g=this.stopTimeline)==null||g.call(this)),(y=this.keyframeResolver)==null||y.cancel()},this.createdAt=yo.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)||uV;this.keyframeResolver=new p(l,(g,y,x)=>this.onKeyframesResolved(g,y,f,!x),c,u,d),(m=this.keyframeResolver)==null||m.scheduleResolve()}onKeyframesResolved(e,r,n,s){this.keyframeResolver=void 0;const{name:i,type:a,velocity:l,delay:c,isHandoff:u,onUpdate:d}=n;this.resolvedAt=yo.now(),C7e(e,i,a,l)||((pf.instantAnimations||!c)&&(d==null||d(oV(e,n,r))),e[0]=e[e.length-1],I8(n),n.repeat=0);const f={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>P7e?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:e},p=!u&&T7e(f)?new N7e({...f,element:f.motionValue.owner.current}):new cV(f);p.finished.then(()=>this.notifyFinished()).catch(tc),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(),p7e()),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 R7e=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function O7e(t){const e=R7e.exec(t);if(!e)return[,];const[,r,n,s]=e;return[`--${r??n}`,s]}function gye(t,e,r=1){const[n,s]=O7e(t);if(!n)return;const i=window.getComputedStyle(e).getPropertyValue(n);if(i){const a=i.trim();return Lxe(a)?parseFloat(a):a}return rV(s)?gye(s,e,r+1):s}function dV(t,e){return(t==null?void 0:t[e])??(t==null?void 0:t.default)??t}const xye=new Set(["width","height","top","left","right","bottom",...gj]),M7e={test:t=>t==="auto",parse:t=>t},yye=t=>e=>e.test(t),vye=[mj,Vt,ad,tp,kHe,NHe,M7e],sZ=t=>vye.find(yye(t));function D7e(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||Fxe(t):!0}const L7e=new Set(["brightness","contrast","saturate","opacity"]);function $7e(t){const[e,r]=t.slice(0,-1).split("(");if(e==="drop-shadow")return t;const[n]=r.match(nV)||[];if(!n)return t;const s=r.replace(n,"");let i=L7e.has(e)?1:0;return n!==r&&(i*=100),e+"("+i+s+")"}const F7e=/\b([a-z-]*)\(.*?\)/gu,R8={...Vm,getAnimatableNone:t=>{const e=t.match(F7e);return e?e.map($7e).join(" "):t}},iZ={...mj,transform:Math.round},B7e={rotate:tp,rotateX:tp,rotateY:tp,rotateZ:tp,scale:cT,scaleX:cT,scaleY:cT,scaleZ:cT,skew:tp,skewX:tp,skewY:tp,distance:Vt,translateX:Vt,translateY:Vt,translateZ:Vt,x:Vt,y:Vt,z:Vt,perspective:Vt,transformPerspective:Vt,opacity:LN,originX:qQ,originY:qQ,originZ:Vt},hV={borderWidth:Vt,borderTopWidth:Vt,borderRightWidth:Vt,borderBottomWidth:Vt,borderLeftWidth:Vt,borderRadius:Vt,radius:Vt,borderTopLeftRadius:Vt,borderTopRightRadius:Vt,borderBottomRightRadius:Vt,borderBottomLeftRadius:Vt,width:Vt,maxWidth:Vt,height:Vt,maxHeight:Vt,top:Vt,right:Vt,bottom:Vt,left:Vt,padding:Vt,paddingTop:Vt,paddingRight:Vt,paddingBottom:Vt,paddingLeft:Vt,margin:Vt,marginTop:Vt,marginRight:Vt,marginBottom:Vt,marginLeft:Vt,backgroundPositionX:Vt,backgroundPositionY:Vt,...B7e,zIndex:iZ,fillOpacity:LN,strokeOpacity:LN,numOctaves:iZ},z7e={...hV,color:Ds,backgroundColor:Ds,outlineColor:Ds,fill:Ds,stroke:Ds,borderColor:Ds,borderTopColor:Ds,borderRightColor:Ds,borderBottomColor:Ds,borderLeftColor:Ds,filter:R8,WebkitFilter:R8},bye=t=>z7e[t];function wye(t,e){let r=bye(t);return r!==R8&&(r=Vm),r.getAnimatableNone?r.getAnimatableNone(e):void 0}const U7e=new Set(["auto","none","0"]);function H7e(t,e,r){let n=0,s;for(;n<t.length&&!s;){const i=t[n];typeof i=="string"&&!U7e.has(i)&&$N(i).values.length&&(s=t[n]),n++}if(s&&r)for(const i of e)t[i]=wye(r,s)}class W7e extends uV{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(),rV(u))){const d=gye(u,r.current);d!==void 0&&(e[c]=d),c===e.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!xye.has(n)||e.length!==2)return;const[s,i]=e,a=sZ(s),l=sZ(i);if(a!==l)if(eZ(a)&&eZ(l))for(let c=0;c<e.length;c++){const u=e[c];typeof u=="string"&&(e[c]=parseFloat(u))}else Fy[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:e,name:r}=this,n=[];for(let s=0;s<e.length;s++)(e[s]===null||D7e(e[s]))&&n.push(s);n.length&&H7e(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=Fy[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 l;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]=Fy[r](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),(l=this.removedTransforms)!=null&&l.length&&this.removedTransforms.forEach(([c,u])=>{e.getValue(c).set(u)}),this.resolveNoneKeyframes()}}function V7e(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 jye=(t,e)=>e&&typeof t=="number"?e.transform(t):t;function q7e(t){return $xe(t)&&"offsetHeight"in t}const aZ=30,G7e=t=>!isNaN(parseFloat(t));class K7e{constructor(e,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var i;const s=yo.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=yo.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=G7e(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 J9);const n=this.events[e].add(r);return e==="change"?()=>{n(),Yn.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=yo.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>aZ)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,aZ);return Bxe(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 h1(t,e){return new K7e(t,e)}const{schedule:fV,cancel:_Wt}=Qxe(queueMicrotask,!1),jc={x:!1,y:!1};function Sye(){return jc.x||jc.y}function Y7e(t){return t==="x"||t==="y"?jc[t]?null:(jc[t]=!0,()=>{jc[t]=!1}):jc.x||jc.y?null:(jc.x=jc.y=!0,()=>{jc.x=jc.y=!1})}function _ye(t,e){const r=V7e(t),n=new AbortController,s={passive:!0,...e,signal:n.signal};return[r,s,()=>n.abort()]}function oZ(t){return!(t.pointerType==="touch"||Sye())}function X7e(t,e,r={}){const[n,s,i]=_ye(t,r),a=l=>{if(!oZ(l))return;const{target:c}=l,u=e(c,l);if(typeof u!="function"||!c)return;const d=h=>{oZ(h)&&(u(h),c.removeEventListener("pointerleave",d))};c.addEventListener("pointerleave",d,s)};return n.forEach(l=>{l.addEventListener("pointerenter",a,s)}),i}const Nye=(t,e)=>e?t===e?!0:Nye(t,e.parentElement):!1,pV=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,Q7e=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Z7e(t){return Q7e.has(t.tagName)||t.tabIndex!==-1}const Z2=new WeakSet;function lZ(t){return e=>{e.key==="Enter"&&t(e)}}function $4(t,e){t.dispatchEvent(new PointerEvent("pointer"+e,{isPrimary:!0,bubbles:!0}))}const J7e=(t,e)=>{const r=t.currentTarget;if(!r)return;const n=lZ(()=>{if(Z2.has(r))return;$4(r,"down");const s=lZ(()=>{$4(r,"up")}),i=()=>$4(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 cZ(t){return pV(t)&&!Sye()}function eWe(t,e,r={}){const[n,s,i]=_ye(t,r),a=l=>{const c=l.currentTarget;if(!cZ(l))return;Z2.add(c);const u=e(c,l),d=(p,m)=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",f),Z2.has(c)&&Z2.delete(c),cZ(p)&&typeof u=="function"&&u(p,{success:m})},h=p=>{d(p,c===window||c===document||r.useGlobalTarget||Nye(c,p.target))},f=p=>{d(p,!1)};window.addEventListener("pointerup",h,s),window.addEventListener("pointercancel",f,s)};return n.forEach(l=>{(r.useGlobalTarget?window:l).addEventListener("pointerdown",a,s),q7e(l)&&(l.addEventListener("focus",u=>J7e(u,s)),!Z7e(l)&&!l.hasAttribute("tabindex")&&(l.tabIndex=0))}),i}function kye(t){return $xe(t)&&"ownerSVGElement"in t}function tWe(t){return kye(t)&&t.tagName==="svg"}const _a=t=>!!(t&&t.getVelocity),rWe=[...vye,Ds,Vm],nWe=t=>rWe.find(yye(t)),Cye=S.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function sWe(t=!0){const e=S.useContext(Y9);if(e===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:s}=e,i=S.useId();S.useEffect(()=>{if(t)return s(i)},[t]);const a=S.useCallback(()=>t&&n&&n(i),[i,n,t]);return!r&&n?[!1,a]:[!0]}const Eye=S.createContext({strict:!1}),uZ={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"]},f1={};for(const t in uZ)f1[t]={isEnabled:e=>uZ[t].some(r=>!!e[r])};function iWe(t){for(const e in t)f1[e]={...f1[e],...t[e]}}const aWe=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 qI(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||aWe.has(t)}let Aye=t=>!qI(t);function oWe(t){typeof t=="function"&&(Aye=e=>e.startsWith("on")?!qI(e):t(e))}try{oWe(require("@emotion/is-prop-valid").default)}catch{}function lWe(t,e,r){const n={};for(const s in t)s==="values"&&typeof t.values=="object"||(Aye(s)||r===!0&&qI(s)||!e&&!qI(s)||t.draggable&&s.startsWith("onDrag"))&&(n[s]=t[s]);return n}const ED=S.createContext({});function AD(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function FN(t){return typeof t=="string"||Array.isArray(t)}const mV=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],gV=["initial",...mV];function TD(t){return AD(t.animate)||gV.some(e=>FN(t[e]))}function Tye(t){return!!(TD(t)||t.variants)}function cWe(t,e){if(TD(t)){const{initial:r,animate:n}=t;return{initial:r===!1||FN(r)?r:void 0,animate:FN(n)?n:void 0}}return t.inherit!==!1?e:{}}function uWe(t){const{initial:e,animate:r}=cWe(t,S.useContext(ED));return S.useMemo(()=>({initial:e,animate:r}),[dZ(e),dZ(r)])}function dZ(t){return Array.isArray(t)?t.join(" "):t}function hZ(t,e){return e.max===e.min?0:t/(e.max-e.min)*100}const Jj={correct:(t,e)=>{if(!e.target)return t;if(typeof t=="string")if(Vt.test(t))t=parseFloat(t);else return t;const r=hZ(t,e.target.x),n=hZ(t,e.target.y);return`${r}% ${n}%`}},dWe={correct:(t,{treeScale:e,projectionDelta:r})=>{const n=t,s=Vm.parse(t);if(s.length>5)return n;const i=Vm.createTransformer(t),a=typeof s[0]!="number"?1:0,l=r.x.scale*e.x,c=r.y.scale*e.y;s[0+a]/=l,s[1+a]/=c;const u=ts(l,c,.5);return typeof s[2+a]=="number"&&(s[2+a]/=u),typeof s[3+a]=="number"&&(s[3+a]/=u),i(s)}},O8={borderRadius:{...Jj,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Jj,borderTopRightRadius:Jj,borderBottomLeftRadius:Jj,borderBottomRightRadius:Jj,boxShadow:dWe};function Pye(t,{layout:e,layoutId:r}){return xj.has(t)||t.startsWith("origin")||(e||r!==void 0)&&(!!O8[t]||t==="opacity")}const hWe={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},fWe=gj.length;function pWe(t,e,r){let n="",s=!0;for(let i=0;i<fWe;i++){const a=gj[i],l=t[a];if(l===void 0)continue;let c=!0;if(typeof l=="number"?c=l===(a.startsWith("scale")?1:0):c=parseFloat(l)===0,!c||r){const u=jye(l,hV[a]);if(!c){s=!1;const d=hWe[a]||a;n+=`${d}(${u}) `}r&&(e[a]=u)}}return n=n.trim(),r?n=r(e,s?"":n):s&&(n="none"),n}function xV(t,e,r){const{style:n,vars:s,transformOrigin:i}=t;let a=!1,l=!1;for(const c in e){const u=e[c];if(xj.has(c)){a=!0;continue}else if(Jxe(c)){s[c]=u;continue}else{const d=jye(u,hV[c]);c.startsWith("origin")?(l=!0,i[c]=d):n[c]=d}}if(e.transform||(a||r?n.transform=pWe(e,t.transform,r):n.transform&&(n.transform="none")),l){const{originX:c="50%",originY:u="50%",originZ:d=0}=i;n.transformOrigin=`${c} ${u} ${d}`}}const yV=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Iye(t,e,r){for(const n in e)!_a(e[n])&&!Pye(n,r)&&(t[n]=e[n])}function mWe({transformTemplate:t},e){return S.useMemo(()=>{const r=yV();return xV(r,e,t),Object.assign({},r.vars,r.style)},[e])}function gWe(t,e){const r=t.style||{},n={};return Iye(n,r,t),Object.assign(n,mWe(t,e)),n}function xWe(t,e){const r={},n=gWe(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 yWe={offset:"stroke-dashoffset",array:"stroke-dasharray"},vWe={offset:"strokeDashoffset",array:"strokeDasharray"};function bWe(t,e,r=1,n=0,s=!0){t.pathLength=1;const i=s?yWe:vWe;t[i.offset]=Vt.transform(-n);const a=Vt.transform(e),l=Vt.transform(r);t[i.array]=`${a} ${l}`}function Rye(t,{attrX:e,attrY:r,attrScale:n,pathLength:s,pathSpacing:i=1,pathOffset:a=0,...l},c,u,d){if(xV(t,l,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&&bWe(h,s,i,a,!1)}const Oye=()=>({...yV(),attrs:{}}),Mye=t=>typeof t=="string"&&t.toLowerCase()==="svg";function wWe(t,e,r,n){const s=S.useMemo(()=>{const i=Oye();return Rye(i,e,Mye(n),t.transformTemplate,t.style),{...i.attrs,style:{...i.style}}},[e]);if(t.style){const i={};Iye(i,t.style,t),s.style={...i,...s.style}}return s}const jWe=["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 vV(t){return typeof t!="string"||t.includes("-")?!1:!!(jWe.indexOf(t)>-1||/[A-Z]/u.test(t))}function SWe(t,e,r,{latestValues:n},s,i=!1){const l=(vV(t)?wWe:xWe)(e,n,s,t),c=lWe(e,typeof t=="string",i),u=t!==S.Fragment?{...c,...l,ref:r}:{},{children:d}=e,h=S.useMemo(()=>_a(d)?d.get():d,[d]);return S.createElement(t,{...u,children:h})}function fZ(t){const e=[{},{}];return t==null||t.values.forEach((r,n)=>{e[0][n]=r.get(),e[1][n]=r.getVelocity()}),e}function bV(t,e,r,n){if(typeof e=="function"){const[s,i]=fZ(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]=fZ(n);e=e(r!==void 0?r:t.custom,s,i)}return e}function J2(t){return _a(t)?t.get():t}function _We({scrapeMotionValuesFromProps:t,createRenderState:e},r,n,s){return{latestValues:NWe(r,n,s,t),renderState:e()}}function NWe(t,e,r,n){const s={},i=n(t,{});for(const f in i)s[f]=J2(i[f]);let{initial:a,animate:l}=t;const c=TD(t),u=Tye(t);e&&u&&!c&&t.inherit!==!1&&(a===void 0&&(a=e.initial),l===void 0&&(l=e.animate));let d=r?r.initial===!1:!1;d=d||a===!1;const h=d?l:a;if(h&&typeof h!="boolean"&&!AD(h)){const f=Array.isArray(h)?h:[h];for(let p=0;p<f.length;p++){const m=bV(t,f[p]);if(m){const{transitionEnd:g,transition:y,...x}=m;for(const v in x){let b=x[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 Dye=t=>(e,r)=>{const n=S.useContext(ED),s=S.useContext(Y9),i=()=>_We(t,e,n,s);return r?i():aHe(i)};function wV(t,e,r){var i;const{style:n}=t,s={};for(const a in n)(_a(n[a])||e.style&&_a(e.style[a])||Pye(a,t)||((i=r==null?void 0:r.getValue(a))==null?void 0:i.liveStyle)!==void 0)&&(s[a]=n[a]);return s}const kWe=Dye({scrapeMotionValuesFromProps:wV,createRenderState:yV});function Lye(t,e,r){const n=wV(t,e,r);for(const s in t)if(_a(t[s])||_a(e[s])){const i=gj.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;n[i]=t[s]}return n}const CWe=Dye({scrapeMotionValuesFromProps:Lye,createRenderState:Oye}),EWe=Symbol.for("motionComponentSymbol");function Wb(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function AWe(t,e,r){return S.useCallback(n=>{n&&t.onMount&&t.onMount(n),e&&(n?e.mount(n):e.unmount()),r&&(typeof r=="function"?r(n):Wb(r)&&(r.current=n))},[e])}const jV=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),TWe="framerAppearId",$ye="data-"+jV(TWe),Fye=S.createContext({});function PWe(t,e,r,n,s){var g,y;const{visualElement:i}=S.useContext(ED),a=S.useContext(Eye),l=S.useContext(Y9),c=S.useContext(Cye).reducedMotion,u=S.useRef(null);n=n||a.renderer,!u.current&&n&&(u.current=n(t,{visualState:e,parent:i,props:r,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:c}));const d=u.current,h=S.useContext(Fye);d&&!d.projection&&s&&(d.type==="html"||d.type==="svg")&&IWe(u.current,r,s,h);const f=S.useRef(!1);S.useInsertionEffect(()=>{d&&f.current&&d.update(r,l)});const p=r[$ye],m=S.useRef(!!p&&!((g=window.MotionHandoffIsComplete)!=null&&g.call(window,p))&&((y=window.MotionHasOptimisedAnimation)==null?void 0:y.call(window,p)));return oHe(()=>{d&&(f.current=!0,window.MotionIsMounted=!0,d.updateFeatures(),d.scheduleRenderMicrotask(),m.current&&d.animationState&&d.animationState.animateChanges())}),S.useEffect(()=>{d&&(!m.current&&d.animationState&&d.animationState.animateChanges(),m.current&&(queueMicrotask(()=>{var x;(x=window.MotionHandoffMarkAsComplete)==null||x.call(window,p)}),m.current=!1),d.enteringChildren=void 0)}),d}function IWe(t,e,r,n){const{layoutId:s,layout:i,drag:a,dragConstraints:l,layoutScroll:c,layoutRoot:u,layoutCrossfade:d}=e;t.projection=new r(t.latestValues,e["data-framer-portal-id"]?void 0:Bye(t.parent)),t.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!a||l&&Wb(l),visualElement:t,animationType:typeof i=="string"?i:"both",initialPromotionConfig:n,crossfade:d,layoutScroll:c,layoutRoot:u})}function Bye(t){if(t)return t.options.allowProjection!==!1?t.projection:Bye(t.parent)}function F4(t,{forwardMotionProps:e=!1}={},r,n){r&&iWe(r);const s=vV(t)?CWe:kWe;function i(l,c){let u;const d={...S.useContext(Cye),...l,layoutId:RWe(l)},{isStatic:h}=d,f=uWe(l),p=s(l,h);if(!h&&K9){OWe();const m=MWe(d);u=m.MeasureLayout,f.visualElement=PWe(t,p,d,n,m.ProjectionNode)}return o.jsxs(ED.Provider,{value:f,children:[u&&f.visualElement?o.jsx(u,{visualElement:f.visualElement,...d}):null,SWe(t,l,AWe(p,f.visualElement,c),p,h,e)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const a=S.forwardRef(i);return a[EWe]=t,a}function RWe({layoutId:t}){const e=S.useContext(Dxe).id;return e&&t!==void 0?e+"-"+t:t}function OWe(t,e){S.useContext(Eye).strict}function MWe(t){const{drag:e,layout:r}=f1;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 DWe(t,e){if(typeof Proxy>"u")return F4;const r=new Map,n=(i,a)=>F4(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,F4(a,void 0,t,e)),r.get(a))})}function zye({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 $We(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 B4(t){return t===void 0||t===1}function M8({scale:t,scaleX:e,scaleY:r}){return!B4(t)||!B4(e)||!B4(r)}function zg(t){return M8(t)||Uye(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function Uye(t){return pZ(t.x)||pZ(t.y)}function pZ(t){return t&&t!=="0%"}function GI(t,e,r){const n=t-r,s=e*n;return r+s}function mZ(t,e,r,n,s){return s!==void 0&&(t=GI(t,s,n)),GI(t,r,n)+e}function D8(t,e=0,r=1,n,s){t.min=mZ(t.min,e,r,n,s),t.max=mZ(t.max,e,r,n,s)}function Hye(t,{x:e,y:r}){D8(t.x,e.translate,e.scale,e.originPoint),D8(t.y,r.translate,r.scale,r.originPoint)}const gZ=.999999999999,xZ=1.0000000000001;function FWe(t,e,r,n=!1){const s=r.length;if(!s)return;e.x=e.y=1;let i,a;for(let l=0;l<s;l++){i=r[l],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&&qb(t,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),a&&(e.x*=a.x.scale,e.y*=a.y.scale,Hye(t,a)),n&&zg(i.latestValues)&&qb(t,i.latestValues))}e.x<xZ&&e.x>gZ&&(e.x=1),e.y<xZ&&e.y>gZ&&(e.y=1)}function Vb(t,e){t.min=t.min+e,t.max=t.max+e}function yZ(t,e,r,n,s=.5){const i=ts(t.min,t.max,s);D8(t,e,r,i,n)}function qb(t,e){yZ(t.x,e.x,e.scaleX,e.scale,e.originX),yZ(t.y,e.y,e.scaleY,e.scale,e.originY)}function Wye(t,e){return zye($We(t.getBoundingClientRect(),e))}function BWe(t,e,r){const n=Wye(t,r),{scroll:s}=e;return s&&(Vb(n.x,s.offset.x),Vb(n.y,s.offset.y)),n}const vZ=()=>({translate:0,scale:1,origin:0,originPoint:0}),Gb=()=>({x:vZ(),y:vZ()}),bZ=()=>({min:0,max:0}),Zs=()=>({x:bZ(),y:bZ()}),L8={current:null},Vye={current:!1};function zWe(){if(Vye.current=!0,!!K9)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),e=()=>L8.current=t.matches;t.addEventListener("change",e),e()}else L8.current=!1}const UWe=new WeakMap;function HWe(t,e,r){for(const n in e){const s=e[n],i=r[n];if(_a(s))t.addValue(n,s);else if(_a(i))t.addValue(n,h1(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,h1(a!==void 0?a:s,{owner:t}))}}for(const n in r)e[n]===void 0&&t.removeValue(n);return e}const wZ=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class WWe{scrapeMotionValuesFromProps(e,r,n){return{}}constructor({parent:e,props:r,presenceContext:n,reducedMotionConfig:s,blockInitialAnimation:i,visualState:a},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=uV,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=yo.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,Yn.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=l,this.blockInitialAnimation=!!i,this.isControllingVariants=TD(r),this.isVariantNode=Tye(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&&_a(p)&&p.set(c[f])}}mount(e){var r;this.current=e,UWe.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)),Vye.current||zWe(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:L8.current,(r=this.parent)==null||r.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var e;this.projection&&this.projection.unmount(),Wm(this.notifyUpdate),Wm(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=xj.has(e);n&&this.onBindTransform&&this.onBindTransform();const s=r.on("change",a=>{this.latestValues[e]=a,this.props.onUpdate&&Yn.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 f1){const r=f1[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):Zs()}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<wZ.length;n++){const s=wZ[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=HWe(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=h1(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"&&(Lxe(n)||Fxe(n))?n=parseFloat(n):!nWe(n)&&Vm.test(r)&&(n=wye(e,r)),this.setBaseTarget(e,_a(n)?n.get():n)),_a(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=bV(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&&!_a(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 J9),this.events[e].add(r)}notify(e,...r){this.events[e]&&this.events[e].notify(...r)}scheduleRenderMicrotask(){fV.render(this.render)}}class qye extends WWe{constructor(){super(...arguments),this.KeyframeResolver=W7e}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;_a(e)&&(this.childSubscription=e.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}function Gye(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 VWe(t){return window.getComputedStyle(t)}class qWe extends qye{constructor(){super(...arguments),this.type="html",this.renderInstance=Gye}readValueFromInstance(e,r){var n;if(xj.has(r))return(n=this.projection)!=null&&n.isProjecting?C8(r):c7e(e,r);{const s=VWe(e),i=(Jxe(r)?s.getPropertyValue(r):s[r])||0;return typeof i=="string"?i.trim():i}}measureInstanceViewportBox(e,{transformPagePoint:r}){return Wye(e,r)}build(e,r,n){xV(e,r,n.transformTemplate)}scrapeMotionValuesFromProps(e,r,n){return wV(e,r,n)}}const Kye=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 GWe(t,e,r,n){Gye(t,e,void 0,n);for(const s in e.attrs)t.setAttribute(Kye.has(s)?s:jV(s),e.attrs[s])}class KWe extends qye{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Zs}getBaseTargetFromProps(e,r){return e[r]}readValueFromInstance(e,r){if(xj.has(r)){const n=bye(r);return n&&n.default||0}return r=Kye.has(r)?r:jV(r),e.getAttribute(r)}scrapeMotionValuesFromProps(e,r,n){return Lye(e,r,n)}build(e,r,n){Rye(e,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,r,n,s){GWe(e,r,n,s)}mount(e){this.isSVGTag=Mye(e.tagName),super.mount(e)}}const YWe=(t,e)=>vV(t)?new KWe(e):new qWe(e,{allowProjection:t!==S.Fragment});function y0(t,e,r){const n=t.getProps();return bV(n,e,r!==void 0?r:n.custom,t)}const $8=t=>Array.isArray(t);function XWe(t,e,r){t.hasValue(e)?t.getValue(e).set(r):t.addValue(e,h1(r))}function QWe(t){return $8(t)?t[t.length-1]||0:t}function ZWe(t,e){const r=y0(t,e);let{transitionEnd:n={},transition:s={},...i}=r||{};i={...i,...n};for(const a in i){const l=QWe(i[a]);XWe(t,a,l)}}function JWe(t){return!!(_a(t)&&t.add)}function F8(t,e){const r=t.getValue("willChange");if(JWe(r))return r.add(e);if(!r&&pf.WillChange){const n=new pf.WillChange("auto");t.addValue("willChange",n),n.add(e)}}function Yye(t){return t.props[$ye]}const e9e=t=>t!==null;function t9e(t,{repeat:e,repeatType:r="loop"},n){const s=t.filter(e9e),i=e&&r!=="loop"&&e%2===1?0:s.length-1;return!i||n===void 0?s[i]:n}const r9e={type:"spring",stiffness:500,damping:25,restSpeed:10},n9e=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),s9e={type:"keyframes",duration:.8},i9e={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},a9e=(t,{keyframes:e})=>e.length>2?s9e:xj.has(t)?t.startsWith("scale")?n9e(e[1]):r9e:i9e;function o9e({when:t,delay:e,delayChildren:r,staggerChildren:n,staggerDirection:s,repeat:i,repeatType:a,repeatDelay:l,from:c,elapsed:u,...d}){return!!Object.keys(d).length}const SV=(t,e,r,n={},s,i)=>a=>{const l=dV(n,t)||{},c=l.delay||n.delay||0;let{elapsed:u=0}=n;u=u-id(c);const d={keyframes:Array.isArray(r)?r:[null,r],ease:"easeOut",velocity:e.getVelocity(),...l,delay:-u,onUpdate:f=>{e.set(f),l.onUpdate&&l.onUpdate(f)},onComplete:()=>{a(),l.onComplete&&l.onComplete()},name:t,motionValue:e,element:i?void 0:s};o9e(l)||Object.assign(d,a9e(t,d)),d.duration&&(d.duration=id(d.duration)),d.repeatDelay&&(d.repeatDelay=id(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let h=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(I8(d),d.delay===0&&(h=!0)),(pf.instantAnimations||pf.skipAnimations)&&(h=!0,I8(d),d.delay=0),d.allowFlatten=!l.type&&!l.ease,h&&!i&&e.get()!==void 0){const f=t9e(d.keyframes,l);if(f!==void 0){Yn.update(()=>{d.onUpdate(f),d.onComplete()});return}}return l.isSync?new cV(d):new I7e(d)};function l9e({protectedKeys:t,needsAnimating:e},r){const n=t.hasOwnProperty(r)&&e[r]!==!0;return e[r]=!1,n}function Xye(t,e,{delay:r=0,transitionOverride:n,type:s}={}){let{transition:i=t.getDefaultTransition(),transitionEnd:a,...l}=e;n&&(i=n);const c=[],u=s&&t.animationState&&t.animationState.getState()[s];for(const d in l){const h=t.getValue(d,t.latestValues[d]??null),f=l[d];if(f===void 0||u&&l9e(u,d))continue;const p={delay:r,...dV(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 x=Yye(t);if(x){const v=window.MotionHandoffAnimation(x,d,Yn);v!==null&&(p.startTime=v,g=!0)}}F8(t,d),h.start(SV(d,h,f,t.shouldReduceMotion&&xye.has(d)?{type:!1}:p,t,g));const y=h.animation;y&&c.push(y)}return a&&Promise.all(c).then(()=>{Yn.update(()=>{a&&ZWe(t,a)})}),c}function Qye(t,e,r,n=0,s=1){const i=Array.from(t).sort((u,d)=>u.sortNodePosition(d)).indexOf(e),a=t.size,l=(a-1)*n;return typeof r=="function"?r(i,a):s===1?i*n:l-i*n}function B8(t,e,r={}){var c;const n=y0(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(Xye(t,n,r)):()=>Promise.resolve(),a=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:d=0,staggerChildren:h,staggerDirection:f}=s;return c9e(t,e,u,d,h,f,r)}:()=>Promise.resolve(),{when:l}=s;if(l){const[u,d]=l==="beforeChildren"?[i,a]:[a,i];return u().then(()=>d())}else return Promise.all([i(),a(r.delay)])}function c9e(t,e,r=0,n=0,s=0,i=1,a){const l=[];for(const c of t.variantChildren)c.notify("AnimationStart",e),l.push(B8(c,e,{...a,delay:r+(typeof n=="function"?0:n)+Qye(t.variantChildren,c,n,s,i)}).then(()=>c.notify("AnimationComplete",e)));return Promise.all(l)}function u9e(t,e,r={}){t.notify("AnimationStart",e);let n;if(Array.isArray(e)){const s=e.map(i=>B8(t,i,r));n=Promise.all(s)}else if(typeof e=="string")n=B8(t,e,r);else{const s=typeof e=="function"?y0(t,e,r.custom):e;n=Promise.all(Xye(t,s,r))}return n.then(()=>{t.notify("AnimationComplete",e)})}function Zye(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 d9e=gV.length;function Jye(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?Jye(t.parent)||{}:{};return t.props.initial!==void 0&&(r.initial=t.props.initial),r}const e={};for(let r=0;r<d9e;r++){const n=gV[r],s=t.props[n];(FN(s)||s===!1)&&(e[n]=s)}return e}const h9e=[...mV].reverse(),f9e=mV.length;function p9e(t){return e=>Promise.all(e.map(({animation:r,options:n})=>u9e(t,r,n)))}function m9e(t){let e=p9e(t),r=jZ(),n=!0;const s=c=>(u,d)=>{var f;const h=y0(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=Jye(t.parent)||{},h=[],f=new Set;let p={},m=1/0;for(let y=0;y<f9e;y++){const x=h9e[y],v=r[x],b=u[x]!==void 0?u[x]:d[x],w=FN(b),j=x===c?v.isActive:null;j===!1&&(m=y);let N=b===d[x]&&b!==u[x]&&w;if(N&&n&&t.manuallyAnimateOnMount&&(N=!1),v.protectedKeys={...p},!v.isActive&&j===null||!b&&!v.prevProp||AD(b)||typeof b=="boolean")continue;const C=g9e(v.prevProp,b);let A=C||x===c&&v.isActive&&!N&&w||y>m&&w,E=!1;const O=Array.isArray(b)?b:[b];let $=O.reduce(s(x),{});j===!1&&($={});const{prevResolvedValues:T={}}=v,M={...T,...$},k=H=>{A=!0,f.has(H)&&(E=!0,f.delete(H)),v.needsAnimating[H]=!0;const ee=t.getValue(H);ee&&(ee.liveStyle=!1)};for(const H in M){const ee=$[H],V=T[H];if(p.hasOwnProperty(H))continue;let B=!1;$8(ee)&&$8(V)?B=!Zye(ee,V):B=ee!==V,B?ee!=null?k(H):f.add(H):ee!==void 0&&f.has(H)?k(H):v.protectedKeys[H]=!0}v.prevProp=b,v.prevResolvedValues=$,v.isActive&&(p={...p,...$}),n&&t.blockInitialAnimation&&(A=!1);const D=N&&C;A&&(!D||E)&&h.push(...O.map(H=>{const ee={type:x};if(typeof H=="string"&&n&&!D&&t.manuallyAnimateOnMount&&t.parent){const{parent:V}=t,B=y0(V,H);if(V.enteringChildren&&B){const{delayChildren:z}=B.transition||{};ee.delay=Qye(V.enteringChildren,t,z)}}return{animation:H,options:ee}}))}if(f.size){const y={};if(typeof u.initial!="boolean"){const x=y0(t,Array.isArray(u.initial)?u.initial[0]:u.initial);x&&x.transition&&(y.transition=x.transition)}f.forEach(x=>{const v=t.getBaseTarget(x),b=t.getValue(x);b&&(b.liveStyle=!0),y[x]=v??null}),h.push({animation:y})}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 l(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:l,setAnimateFunction:i,getState:()=>r,reset:()=>{r=jZ()}}}function g9e(t,e){return typeof e=="string"?e!==t:Array.isArray(e)?!Zye(e,t):!1}function kg(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function jZ(){return{animate:kg(!0),whileInView:kg(),whileHover:kg(),whileTap:kg(),whileDrag:kg(),whileFocus:kg(),exit:kg()}}class ug{constructor(e){this.isMounted=!1,this.node=e}update(){}}class x9e extends ug{constructor(e){super(e),e.animationState||(e.animationState=m9e(e))}updateAnimationControlsSubscription(){const{animate:e}=this.node.getProps();AD(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 y9e=0;class v9e extends ug{constructor(){super(...arguments),this.id=y9e++}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 b9e={animation:{Feature:x9e},exit:{Feature:v9e}};function BN(t,e,r,n={passive:!0}){return t.addEventListener(e,r,n),()=>t.removeEventListener(e,r)}function YE(t){return{point:{x:t.pageX,y:t.pageY}}}const w9e=t=>e=>pV(e)&&t(e,YE(e));function D_(t,e,r,n){return BN(t,e,w9e(r),n)}const eve=1e-4,j9e=1-eve,S9e=1+eve,tve=.01,_9e=0-tve,N9e=0+tve;function qa(t){return t.max-t.min}function k9e(t,e,r){return Math.abs(t-e)<=r}function SZ(t,e,r,n=.5){t.origin=n,t.originPoint=ts(e.min,e.max,t.origin),t.scale=qa(r)/qa(e),t.translate=ts(r.min,r.max,t.origin)-t.originPoint,(t.scale>=j9e&&t.scale<=S9e||isNaN(t.scale))&&(t.scale=1),(t.translate>=_9e&&t.translate<=N9e||isNaN(t.translate))&&(t.translate=0)}function L_(t,e,r,n){SZ(t.x,e.x,r.x,n?n.originX:void 0),SZ(t.y,e.y,r.y,n?n.originY:void 0)}function _Z(t,e,r){t.min=r.min+e.min,t.max=t.min+qa(e)}function C9e(t,e,r){_Z(t.x,e.x,r.x),_Z(t.y,e.y,r.y)}function NZ(t,e,r){t.min=e.min-r.min,t.max=t.min+qa(e)}function KI(t,e,r){NZ(t.x,e.x,r.x),NZ(t.y,e.y,r.y)}function kl(t){return[t("x"),t("y")]}const rve=({current:t})=>t?t.ownerDocument.defaultView:null,kZ=(t,e)=>Math.abs(t-e);function E9e(t,e){const r=kZ(t.x,e.x),n=kZ(t.y,e.y);return Math.sqrt(r**2+n**2)}class nve{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=U4(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,m=E9e(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!m)return;const{point:g}=f,{timestamp:y}=Yi;this.history.push({...g,timestamp:y});const{onStart:x,onMove:v}=this.handlers;p||(x&&x(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),v&&v(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=z4(p,this.transformPagePoint),Yn.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:m,onSessionEnd:g,resumeAnimation:y}=this.handlers;if(this.dragSnapToOrigin&&y&&y(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const x=U4(f.type==="pointercancel"?this.lastMoveEventInfo:z4(p,this.transformPagePoint),this.history);this.startEvent&&m&&m(f,x),g&&g(f,x)},!pV(e))return;this.dragSnapToOrigin=i,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=s||window;const l=YE(e),c=z4(l,this.transformPagePoint),{point:u}=c,{timestamp:d}=Yi;this.history=[{...u,timestamp:d}];const{onSessionStart:h}=r;h&&h(e,U4(c,this.history)),this.removeListeners=qE(D_(this.contextWindow,"pointermove",this.handlePointerMove),D_(this.contextWindow,"pointerup",this.handlePointerUp),D_(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),Wm(this.updatePoint)}}function z4(t,e){return e?{point:e(t.point)}:t}function CZ(t,e){return{x:t.x-e.x,y:t.y-e.y}}function U4({point:t},e){return{point:t,delta:CZ(t,sve(e)),offset:CZ(t,A9e(e)),velocity:T9e(e,.1)}}function A9e(t){return t[0]}function sve(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=sve(t);for(;r>=0&&(n=t[r],!(s.timestamp-n.timestamp>id(e)));)r--;if(!n)return{x:0,y:0};const i=Kl(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 P9e(t,{min:e,max:r},n){return e!==void 0&&t<e?t=n?ts(e,t,n.min):Math.max(t,e):r!==void 0&&t>r&&(t=n?ts(r,t,n.max):Math.min(t,r)),t}function EZ(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 I9e(t,{top:e,left:r,bottom:n,right:s}){return{x:EZ(t.x,r,s),y:EZ(t.y,e,n)}}function AZ(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 R9e(t,e){return{x:AZ(t.x,e.x),y:AZ(t.y,e.y)}}function O9e(t,e){let r=.5;const n=qa(t),s=qa(e);return s>n?r=DN(e.min,e.max-n,t.min):n>s&&(r=DN(t.min,t.max-s,e.min)),ff(0,1,r)}function M9e(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 z8=.35;function D9e(t=z8){return t===!1?t=0:t===!0&&(t=z8),{x:TZ(t,"left","right"),y:TZ(t,"top","bottom")}}function TZ(t,e,r){return{min:PZ(t,e),max:PZ(t,r)}}function PZ(t,e){return typeof t=="number"?t:t[e]||0}const L9e=new WeakMap;class $9e{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=Zs(),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(YE(h).point)},a=(h,f)=>{const{drag:p,dragPropagation:m,onDragStart:g}=this.getProps();if(p&&!m&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Y7e(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),kl(x=>{let v=this.getAxisMotionValue(x).get()||0;if(ad.test(v)){const{projection:b}=this.visualElement;if(b&&b.layout){const w=b.layout.layoutBox[x];w&&(v=qa(w)*(parseFloat(v)/100))}}this.originPoint[x]=v}),g&&Yn.postRender(()=>g(h,f)),F8(this.visualElement,"transform");const{animationState:y}=this.visualElement;y&&y.setActive("whileDrag",!0)},l=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:m,onDirectionLock:g,onDrag:y}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:x}=f;if(m&&this.currentDirection===null){this.currentDirection=F9e(x),this.currentDirection!==null&&g&&g(this.currentDirection);return}this.updateAxis("x",f.point,x),this.updateAxis("y",f.point,x),this.visualElement.render(),y&&y(h,f)},c=(h,f)=>{this.latestPointerEvent=h,this.latestPanInfo=f,this.stop(h,f),this.latestPointerEvent=null,this.latestPanInfo=null},u=()=>kl(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 nve(e,{onSessionStart:i,onStart:a,onMove:l,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:d,distanceThreshold:n,contextWindow:rve(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:l}=this.getProps();l&&Yn.postRender(()=>l(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||!uT(e,s,this.currentDirection))return;const i=this.getAxisMotionValue(e);let a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=P9e(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&&Wb(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=I9e(n.layoutBox,e):this.constraints=!1,this.elastic=D9e(r),s!==this.constraints&&n&&this.constraints&&!this.hasMutatedConstraints&&kl(a=>{this.constraints!==!1&&this.getAxisMotionValue(a)&&(this.constraints[a]=M9e(n.layoutBox[a],this.constraints[a]))})}resolveRefConstraints(){const{dragConstraints:e,onMeasureDragConstraints:r}=this.getProps();if(!e||!Wb(e))return!1;const n=e.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const i=BWe(n,s.root,this.visualElement.getTransformPagePoint());let a=R9e(s.layout.layoutBox,i);if(r){const l=r(LWe(a));this.hasMutatedConstraints=!!l,l&&(a=zye(l))}return a}startAnimation(e){const{drag:r,dragMomentum:n,dragElastic:s,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},u=kl(d=>{if(!uT(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(l)}startAxisValueAnimation(e,r){const n=this.getAxisMotionValue(e);return F8(this.visualElement,e),n.start(SV(e,n,0,r,this.visualElement,!1))}stopAnimation(){kl(e=>this.getAxisMotionValue(e).stop())}pauseAnimation(){kl(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){kl(r=>{const{drag:n}=this.getProps();if(!uT(r,n,this.currentDirection))return;const{projection:s}=this.visualElement,i=this.getAxisMotionValue(r);if(s&&s.layout){const{min:a,max:l}=s.layout.layoutBox[r];i.set(e[r]-ts(a,l,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:e,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!Wb(r)||!n||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};kl(a=>{const l=this.getAxisMotionValue(a);if(l&&this.constraints!==!1){const c=l.get();s[a]=O9e({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(),kl(a=>{if(!uT(a,e,null))return;const l=this.getAxisMotionValue(a),{min:c,max:u}=this.constraints[a];l.set(ts(c,u,s[a]))})}addListeners(){if(!this.visualElement.current)return;L9e.set(this.visualElement,this);const e=this.visualElement.current,r=D_(e,"pointerdown",c=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(c)}),n=()=>{const{dragConstraints:c}=this.getProps();Wb(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()),Yn.read(n);const a=BN(window,"resize",()=>this.scalePositionWithinConstraints()),l=s.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(kl(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(),l&&l()}}getProps(){const e=this.visualElement.getProps(),{drag:r=!1,dragDirectionLock:n=!1,dragPropagation:s=!1,dragConstraints:i=!1,dragElastic:a=z8,dragMomentum:l=!0}=e;return{...e,drag:r,dragDirectionLock:n,dragPropagation:s,dragConstraints:i,dragElastic:a,dragMomentum:l}}}function uT(t,e,r){return(e===!0||e===t)&&(r===null||r===t)}function F9e(t,e=10){let r=null;return Math.abs(t.y)>e?r="y":Math.abs(t.x)>e&&(r="x"),r}class B9e extends ug{constructor(e){super(e),this.removeGroupControls=tc,this.removeListeners=tc,this.controls=new $9e(e)}mount(){const{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||tc}unmount(){this.removeGroupControls(),this.removeListeners()}}const IZ=t=>(e,r)=>{t&&Yn.postRender(()=>t(e,r))};class z9e extends ug{constructor(){super(...arguments),this.removePointerDownListener=tc}onPointerDown(e){this.session=new nve(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:rve(this.node)})}createPanHandlers(){const{onPanSessionStart:e,onPanStart:r,onPan:n,onPanEnd:s}=this.node.getProps();return{onSessionStart:IZ(e),onStart:IZ(r),onMove:n,onEnd:(i,a)=>{delete this.session,s&&Yn.postRender(()=>s(i,a))}}}mount(){this.removePointerDownListener=D_(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 eP={hasAnimatedSinceResize:!0,hasEverUpdated:!1};let H4=!1;class U9e extends S.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),H4&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),eP.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){const{layoutDependency:r,visualElement:n,drag:s,isPresent:i}=this.props,{projection:a}=n;return a&&(a.isPresent=i,H4=!0,s||e.layoutDependency!==r||r===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Yn.postRender(()=>{const l=a.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),fV.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:e,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:s}=e;H4=!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 ive(t){const[e,r]=sWe(),n=S.useContext(Dxe);return o.jsx(U9e,{...t,layoutGroup:n,switchLayoutGroup:S.useContext(Fye),isPresent:e,safeToRemove:r})}function H9e(t,e,r){const n=_a(t)?t:h1(t);return n.start(SV("",n,e,r)),n.animation}const W9e=(t,e)=>t.depth-e.depth;class V9e{constructor(){this.children=[],this.isDirty=!1}add(e){X9(this.children,e),this.isDirty=!0}remove(e){Q9(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(W9e),this.isDirty=!1,this.children.forEach(e)}}function q9e(t,e){const r=yo.now(),n=({timestamp:s})=>{const i=s-r;i>=e&&(Wm(n),t(i-e))};return Yn.setup(n,!0),()=>Wm(n)}const ave=["TopLeft","TopRight","BottomLeft","BottomRight"],G9e=ave.length,RZ=t=>typeof t=="string"?parseFloat(t):t,OZ=t=>typeof t=="number"||Vt.test(t);function K9e(t,e,r,n,s,i){s?(t.opacity=ts(0,r.opacity??1,Y9e(n)),t.opacityExit=ts(e.opacity??1,0,X9e(n))):i&&(t.opacity=ts(e.opacity??1,r.opacity??1,n));for(let a=0;a<G9e;a++){const l=`border${ave[a]}Radius`;let c=MZ(e,l),u=MZ(r,l);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||OZ(c)===OZ(u)?(t[l]=Math.max(ts(RZ(c),RZ(u),n),0),(ad.test(u)||ad.test(c))&&(t[l]+="%")):t[l]=u}(e.rotate||r.rotate)&&(t.rotate=ts(e.rotate||0,r.rotate||0,n))}function MZ(t,e){return t[e]!==void 0?t[e]:t.borderRadius}const Y9e=ove(0,.5,Gxe),X9e=ove(.5,.95,tc);function ove(t,e,r){return n=>n<t?0:n>e?1:r(DN(t,e,n))}function DZ(t,e){t.min=e.min,t.max=e.max}function xc(t,e){DZ(t.x,e.x),DZ(t.y,e.y)}function LZ(t,e){t.translate=e.translate,t.scale=e.scale,t.originPoint=e.originPoint,t.origin=e.origin}function $Z(t,e,r,n,s){return t-=e,t=GI(t,1/r,n),s!==void 0&&(t=GI(t,1/s,n)),t}function Q9e(t,e=0,r=1,n=.5,s,i=t,a=t){if(ad.test(e)&&(e=parseFloat(e),e=ts(a.min,a.max,e/100)-a.min),typeof e!="number")return;let l=ts(i.min,i.max,n);t===i&&(l-=e),t.min=$Z(t.min,e,r,l,s),t.max=$Z(t.max,e,r,l,s)}function FZ(t,e,[r,n,s],i,a){Q9e(t,e[r],e[n],e[s],e.scale,i,a)}const Z9e=["x","scaleX","originX"],J9e=["y","scaleY","originY"];function BZ(t,e,r,n){FZ(t.x,e,Z9e,r?r.x:void 0,n?n.x:void 0),FZ(t.y,e,J9e,r?r.y:void 0,n?n.y:void 0)}function zZ(t){return t.translate===0&&t.scale===1}function lve(t){return zZ(t.x)&&zZ(t.y)}function UZ(t,e){return t.min===e.min&&t.max===e.max}function eVe(t,e){return UZ(t.x,e.x)&&UZ(t.y,e.y)}function HZ(t,e){return Math.round(t.min)===Math.round(e.min)&&Math.round(t.max)===Math.round(e.max)}function cve(t,e){return HZ(t.x,e.x)&&HZ(t.y,e.y)}function WZ(t){return qa(t.x)/qa(t.y)}function VZ(t,e){return t.translate===e.translate&&t.scale===e.scale&&t.originPoint===e.originPoint}class tVe{constructor(){this.members=[]}add(e){X9(this.members,e),e.scheduleRender()}remove(e){if(Q9(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 rVe(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 l=t.x.scale*e.x,c=t.y.scale*e.y;return(l!==1||c!==1)&&(n+=`scale(${l}, ${c})`),n||"none"}const W4=["","X","Y","Z"],nVe=1e3;let sVe=0;function V4(t,e,r,n){const{latestValues:s}=e;s[t]&&(r[t]=s[t],e.setStaticValue(t,0),n&&(n[t]=0))}function uve(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:e}=t.options;if(!e)return;const r=Yye(e);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:s,layoutId:i}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Yn,!(s||i))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&uve(n)}function dve({attachResizeListener:t,defaultParent:e,measureScroll:r,checkIsScrollRoot:n,resetTransform:s}){return class{constructor(a={},l=e==null?void 0:e()){this.id=sVe++,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(oVe),this.nodes.forEach(dVe),this.nodes.forEach(hVe),this.nodes.forEach(lVe)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=a,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new V9e)}addEventListener(a,l){return this.eventHandlers.has(a)||this.eventHandlers.set(a,new J9),this.eventHandlers.get(a).add(l)}notifyListeners(a,...l){const c=this.eventHandlers.get(a);c&&c.notify(...l)}hasListeners(a){return this.eventHandlers.has(a)}mount(a){if(this.instance)return;this.isSVG=kye(a)&&!tWe(a),this.instance=a;const{layoutId:l,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||l)&&(this.isLayoutDirty=!0),t){let d,h=0;const f=()=>this.root.updateBlockedByResize=!1;Yn.read(()=>{h=window.innerWidth}),t(a,()=>{const p=window.innerWidth;p!==h&&(h=p,this.root.updateBlockedByResize=!0,d&&d(),d=q9e(f,250),eP.hasAnimatedSinceResize&&(eP.hasAnimatedSinceResize=!1,this.nodes.forEach(KZ)))})}l&&this.root.registerSharedNode(l,this),this.options.animate!==!1&&u&&(l||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()||xVe,{onLayoutAnimationStart:g,onLayoutAnimationComplete:y}=u.getProps(),x=!this.targetLayout||!cve(this.targetLayout,p),v=!h&&f;if(this.options.layoutRoot||this.resumeFrom||v||h&&(x||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const b={...dV(m,"layout"),onPlay:g,onComplete:y};(u.shouldReduceMotion||this.options.layoutRoot)&&(b.delay=0,b.type=!1),this.startAnimation(b),this.setAnimationOrigin(d,v)}else h||KZ(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(),Wm(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(fVe),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&&uve(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:l,layout:c}=this.options;if(l===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(qZ);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(GZ);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(uVe),this.nodes.forEach(iVe),this.nodes.forEach(aVe)):this.nodes.forEach(GZ),this.clearAllSnapshots();const l=yo.now();Yi.delta=ff(0,1e3/60,l-Yi.timestamp),Yi.timestamp=l,Yi.isProcessing=!0,R4.update.process(Yi),R4.preRender.process(Yi),R4.render.process(Yi),Yi.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,fV.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(cVe),this.sharedNodes.forEach(pVe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Yn.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Yn.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!qa(this.snapshot.measuredBox.x)&&!qa(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=Zs(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,a?a.layoutBox:void 0)}updateScroll(a="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===a&&(l=!1),l&&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,l=this.projectionDelta&&!lve(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;a&&this.instance&&(l||zg(this.latestValues)||d)&&(s(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(a=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return a&&(c=this.removeTransform(c)),yVe(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var u;const{visualElement:a}=this.options;if(!a)return Zs();const l=a.measureViewportBox();if(!(((u=this.scroll)==null?void 0:u.wasRoot)||this.path.some(vVe))){const{scroll:d}=this.root;d&&(Vb(l.x,d.offset.x),Vb(l.y,d.offset.y))}return l}removeElementScroll(a){var c;const l=Zs();if(xc(l,a),(c=this.scroll)!=null&&c.wasRoot)return l;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&&xc(l,a),Vb(l.x,h.offset.x),Vb(l.y,h.offset.y))}return l}applyTransform(a,l=!1){const c=Zs();xc(c,a);for(let u=0;u<this.path.length;u++){const d=this.path[u];!l&&d.options.layoutScroll&&d.scroll&&d!==d.root&&qb(c,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),zg(d.latestValues)&&qb(c,d.latestValues)}return zg(this.latestValues)&&qb(c,this.latestValues),c}removeTransform(a){const l=Zs();xc(l,a);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!zg(u.latestValues))continue;M8(u.latestValues)&&u.updateSnapshot();const d=Zs(),h=u.measurePageBox();xc(d,h),BZ(l,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return zg(this.latestValues)&&BZ(l,this.latestValues),l}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!==Yi.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(a=!1){var p;const l=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=l.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=l.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=l.isSharedProjectionDirty);const c=!!this.resumingFrom||this!==l;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=Yi.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=Zs(),this.targetWithTransforms=Zs()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),C9e(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):xc(this.target,this.layout.layoutBox),Hye(this.target,this.targetDelta)):xc(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||M8(this.parent.latestValues)||Uye(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,l,c){this.relativeParent=a,this.linkedParentVersion=a.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Zs(),this.relativeTargetOrigin=Zs(),KI(this.relativeTargetOrigin,l,c),xc(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var m;const a=this.getLead(),l=!!this.resumingFrom||this!==a;let c=!0;if((this.isProjectionDirty||(m=this.parent)!=null&&m.isProjectionDirty)&&(c=!1),l&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(c=!1),this.resolvedRelativeTargetAt===Yi.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;xc(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,f=this.treeScale.y;FWe(this.layoutCorrected,this.treeScale,this.path,l),a.layout&&!a.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(a.target=a.layout.layoutBox,a.targetWithTransforms=Zs());const{target:p}=a;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(LZ(this.prevProjectionDelta.x,this.projectionDelta.x),LZ(this.prevProjectionDelta.y,this.projectionDelta.y)),L_(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==f||!VZ(this.projectionDelta.x,this.prevProjectionDelta.x)||!VZ(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 l;if((l=this.options.visualElement)==null||l.scheduleRender(),a){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Gb(),this.projectionDelta=Gb(),this.projectionDeltaWithTransform=Gb()}setAnimationOrigin(a,l=!1){const c=this.snapshot,u=c?c.latestValues:{},d={...this.latestValues},h=Gb();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const f=Zs(),p=c?c.source:void 0,m=this.layout?this.layout.source:void 0,g=p!==m,y=this.getStack(),x=!y||y.members.length<=1,v=!!(g&&!x&&this.options.crossfade===!0&&!this.path.some(gVe));this.animationProgress=0;let b;this.mixTargetDelta=w=>{const j=w/1e3;YZ(h.x,a.x,j),YZ(h.y,a.y,j),this.setTargetDelta(h),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(KI(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),mVe(this.relativeTarget,this.relativeTargetOrigin,f,j),b&&eVe(this.relativeTarget,b)&&(this.isProjectionDirty=!1),b||(b=Zs()),xc(b,this.relativeTarget)),g&&(this.animationValues=d,K9e(d,u,this.latestValues,j,v,x)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=j},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(a){var l,c,u;this.notifyListeners("animationStart"),(l=this.currentAnimation)==null||l.stop(),(u=(c=this.resumingFrom)==null?void 0:c.currentAnimation)==null||u.stop(),this.pendingAnimation&&(Wm(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Yn.update(()=>{eP.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=h1(0)),this.currentAnimation=H9e(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(nVe),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const a=this.getLead();let{targetWithTransforms:l,target:c,layout:u,latestValues:d}=a;if(!(!l||!c||!u)){if(this!==a&&this.layout&&u&&hve(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||Zs();const h=qa(this.layout.layoutBox.x);c.x.min=a.target.x.min,c.x.max=c.x.min+h;const f=qa(this.layout.layoutBox.y);c.y.min=a.target.y.min,c.y.max=c.y.min+f}xc(l,c),qb(l,d),L_(this.projectionDeltaWithTransform,this.layoutCorrected,l,d)}}registerSharedNode(a,l){this.sharedNodes.has(a)||this.sharedNodes.set(a,new tVe),this.sharedNodes.get(a).add(l);const u=l.options.initialPromotionConfig;l.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(l):void 0})}isLead(){const a=this.getStack();return a?a.lead===this:!0}getLead(){var l;const{layoutId:a}=this.options;return a?((l=this.getStack())==null?void 0:l.lead)||this:this}getPrevLead(){var l;const{layoutId:a}=this.options;return a?(l=this.getStack())==null?void 0:l.prevLead:void 0}getStack(){const{layoutId:a}=this.options;if(a)return this.root.sharedNodes.get(a)}promote({needsReset:a,transition:l,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),a&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const a=this.getStack();return a?a.relegate(this):!1}resetSkewAndRotation(){const{visualElement:a}=this.options;if(!a)return;let l=!1;const{latestValues:c}=a;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const u={};c.z&&V4("z",a,u,this.animationValues);for(let d=0;d<W4.length;d++)V4(`rotate${W4[d]}`,a,u,this.animationValues),V4(`skew${W4[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,l){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=J2(l==null?void 0:l.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=J2(l==null?void 0:l.pointerEvents)||""),this.hasProjected&&!zg(this.latestValues)&&(a.transform=c?c({},""):"none",this.hasProjected=!1);return}a.visibility="";const d=u.animationValues||u.latestValues;this.applyTransformsToTarget();let h=rVe(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 O8){if(d[m]===void 0)continue;const{correct:g,applyTo:y,isCSSVariable:x}=O8[m],v=h==="none"?d[m]:g(d[m],u);if(y){const b=y.length;for(let w=0;w<b;w++)a[y[w]]=v}else x?this.options.visualElement.renderState.vars[m]=v:a[m]=v}this.options.layoutId&&(a.pointerEvents=u===this?J2(l==null?void 0:l.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(a=>{var l;return(l=a.currentAnimation)==null?void 0:l.stop()}),this.root.nodes.forEach(qZ),this.root.sharedNodes.clear()}}}function iVe(t){t.updateLayout()}function aVe(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"?kl(h=>{const f=a?e.measuredBox[h]:e.layoutBox[h],p=qa(f);f.min=n[h].min,f.max=f.min+p}):hve(i,e.layoutBox,n)&&kl(h=>{const f=a?e.measuredBox[h]:e.layoutBox[h],p=qa(n[h]);f.max=f.min+p,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[h].max=t.relativeTarget[h].min+p)});const l=Gb();L_(l,n,e.layoutBox);const c=Gb();a?L_(c,t.applyTransform(s,!0),e.measuredBox):L_(c,n,e.layoutBox);const u=!lve(l);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=Zs();KI(m,e.layoutBox,f.layoutBox);const g=Zs();KI(g,n,p.layoutBox),cve(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:l,hasLayoutChanged:u,hasRelativeLayoutChanged:d})}else if(t.isLead()){const{onExitComplete:n}=t.options;n&&n()}t.options.transition=void 0}function oVe(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 lVe(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function cVe(t){t.clearSnapshot()}function qZ(t){t.clearMeasurements()}function GZ(t){t.isLayoutDirty=!1}function uVe(t){const{visualElement:e}=t.options;e&&e.getProps().onBeforeLayoutMeasure&&e.notify("BeforeLayoutMeasure"),t.resetTransform()}function KZ(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function dVe(t){t.resolveTargetDelta()}function hVe(t){t.calcProjection()}function fVe(t){t.resetSkewAndRotation()}function pVe(t){t.removeLeadSnapshot()}function YZ(t,e,r){t.translate=ts(e.translate,0,r),t.scale=ts(e.scale,1,r),t.origin=e.origin,t.originPoint=e.originPoint}function XZ(t,e,r,n){t.min=ts(e.min,r.min,n),t.max=ts(e.max,r.max,n)}function mVe(t,e,r,n){XZ(t.x,e.x,r.x,n),XZ(t.y,e.y,r.y,n)}function gVe(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const xVe={duration:.45,ease:[.4,0,.1,1]},QZ=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),ZZ=QZ("applewebkit/")&&!QZ("chrome/")?Math.round:tc;function JZ(t){t.min=ZZ(t.min),t.max=ZZ(t.max)}function yVe(t){JZ(t.x),JZ(t.y)}function hve(t,e,r){return t==="position"||t==="preserve-aspect"&&!k9e(WZ(e),WZ(r),.2)}function vVe(t){var e;return t!==t.root&&((e=t.scroll)==null?void 0:e.wasRoot)}const bVe=dve({attachResizeListener:(t,e)=>BN(t,"resize",e),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),q4={current:void 0},fve=dve({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!q4.current){const t=new bVe({});t.mount(window),t.setOptions({layoutScroll:!0}),q4.current=t}return q4.current},resetTransform:(t,e)=>{t.style.transform=e!==void 0?e:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),wVe={pan:{Feature:z9e},drag:{Feature:B9e,ProjectionNode:fve,MeasureLayout:ive}};function eJ(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&&Yn.postRender(()=>i(e,YE(e)))}class jVe extends ug{mount(){const{current:e}=this.node;e&&(this.unmount=X7e(e,(r,n)=>(eJ(this.node,n,"Start"),s=>eJ(this.node,s,"End"))))}unmount(){}}class SVe extends ug{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=qE(BN(this.node.current,"focus",()=>this.onFocus()),BN(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function tJ(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&&Yn.postRender(()=>i(e,YE(e)))}class _Ve extends ug{mount(){const{current:e}=this.node;e&&(this.unmount=eWe(e,(r,n)=>(tJ(this.node,n,"Start"),(s,{success:i})=>tJ(this.node,s,i?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const U8=new WeakMap,G4=new WeakMap,NVe=t=>{const e=U8.get(t.target);e&&e(t)},kVe=t=>{t.forEach(NVe)};function CVe({root:t,...e}){const r=t||document;G4.has(r)||G4.set(r,{});const n=G4.get(r),s=JSON.stringify(e);return n[s]||(n[s]=new IntersectionObserver(kVe,{root:t,...e})),n[s]}function EVe(t,e,r){const n=CVe(e);return U8.set(t,r),n.observe(t),()=>{U8.delete(t),n.unobserve(t)}}const AVe={some:0,all:1};class TVe extends ug{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:AVe[s]},l=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 EVe(this.node.current,a,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:e,prevProps:r}=this.node;["amount","margin","root"].some(PVe(e,r))&&this.startObserver()}unmount(){}}function PVe({viewport:t={}},{viewport:e={}}={}){return r=>t[r]!==e[r]}const IVe={inView:{Feature:TVe},tap:{Feature:_Ve},focus:{Feature:SVe},hover:{Feature:jVe}},RVe={layout:{ProjectionNode:fve,MeasureLayout:ive}},OVe={...b9e,...IVe,...wVe,...RVe},Zu=DWe(OVe,YWe),MVe=_f("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"}}),DVe=_f("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"}}),yj=S.forwardRef(({className:t,value:e=0,variant:r,size:n,showValue:s=!1,animated:i=!0,label:a,...l},c)=>{const u=Math.min(Math.max(e,0),100);return o.jsxs("div",{className:"space-y-2",children:[a&&o.jsx("div",{className:"text-sm text-foreground",children:a}),o.jsx(Mxe,{ref:c,className:Pe(MVe({variant:r,size:n}),t),...l,children:o.jsx(iHe,{className:Pe(DVe({variant:r})),asChild:!0,children:o.jsx(Zu.div,{initial:{transform:"translateX(-100%)"},animate:{transform:`translateX(-${100-u}%)`},transition:{duration:i?1.2:0,ease:"easeInOut"}})})}),s&&o.jsxs(Zu.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),"%"]})]})});yj.displayName=Mxe.displayName;const Ue=S.forwardRef(({className:t,type:e,...r},n)=>o.jsx("input",{type:e,className:Pe("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}));Ue.displayName="Input";var LVe="Label",pve=S.forwardRef((t,e)=>o.jsx(ft.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())}}));pve.displayName=LVe;var mve=pve;const $Ve=_f("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Se=S.forwardRef(({className:t,...e},r)=>o.jsx(mve,{ref:r,className:Pe($Ve(),t),...e}));Se.displayName=mve.displayName;var gve="AlertDialog",[FVe,kWt]=Vs(gve,[oge]),Cf=oge(),xve=t=>{const{__scopeAlertDialog:e,...r}=t,n=Cf(e);return o.jsx(O9,{...n,...r,modal:!0})};xve.displayName=gve;var BVe="AlertDialogTrigger",yve=S.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Cf(r);return o.jsx(M9,{...s,...n,ref:e})});yve.displayName=BVe;var zVe="AlertDialogPortal",vve=t=>{const{__scopeAlertDialog:e,...r}=t,n=Cf(e);return o.jsx(D9,{...n,...r})};vve.displayName=zVe;var UVe="AlertDialogOverlay",bve=S.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Cf(r);return o.jsx(zE,{...s,...n,ref:e})});bve.displayName=UVe;var v0="AlertDialogContent",[HVe,WVe]=FVe(v0),VVe=whe("AlertDialogContent"),wve=S.forwardRef((t,e)=>{const{__scopeAlertDialog:r,children:n,...s}=t,i=Cf(r),a=S.useRef(null),l=qt(e,a),c=S.useRef(null);return o.jsx(w8e,{contentName:v0,titleName:jve,docsSlug:"alert-dialog",children:o.jsx(HVe,{scope:r,cancelRef:c,children:o.jsxs(UE,{role:"alertdialog",...i,...s,ref:l,onOpenAutoFocus:Qe(s.onOpenAutoFocus,u=>{var d;u.preventDefault(),(d=c.current)==null||d.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[o.jsx(VVe,{children:n}),o.jsx(GVe,{contentRef:a})]})})})});wve.displayName=v0;var jve="AlertDialogTitle",Sve=S.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Cf(r);return o.jsx(HE,{...s,...n,ref:e})});Sve.displayName=jve;var _ve="AlertDialogDescription",Nve=S.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Cf(r);return o.jsx(WE,{...s,...n,ref:e})});Nve.displayName=_ve;var qVe="AlertDialogAction",kve=S.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,s=Cf(r);return o.jsx(wD,{...s,...n,ref:e})});kve.displayName=qVe;var Cve="AlertDialogCancel",Eve=S.forwardRef((t,e)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:s}=WVe(Cve,r),i=Cf(r),a=qt(e,s);return o.jsx(wD,{...i,...n,ref:a})});Eve.displayName=Cve;var GVe=({contentRef:t})=>{const e=`\`${v0}\` requires a description for the component to be accessible for screen reader users.

You can add a description to the \`${v0}\` by passing a \`${_ve}\` 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 \`${v0}\`. 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 S.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(e)},[e,t]),null},KVe=xve,YVe=yve,XVe=vve,Ave=bve,Tve=wve,Pve=kve,Ive=Eve,Rve=Sve,Ove=Nve;const Mi=KVe,ru=YVe,QVe=XVe,Mve=S.forwardRef(({className:t,...e},r)=>o.jsx(Ave,{className:Pe("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}));Mve.displayName=Ave.displayName;const li=S.forwardRef(({className:t,...e},r)=>o.jsxs(QVe,{children:[o.jsx(Mve,{}),o.jsx(Tve,{ref:r,className:Pe("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})]}));li.displayName=Tve.displayName;const ci=({className:t,...e})=>o.jsx("div",{className:Pe("flex flex-col space-y-2 text-center sm:text-left",t),...e});ci.displayName="AlertDialogHeader";const ui=({className:t,...e})=>o.jsx("div",{className:Pe("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});ui.displayName="AlertDialogFooter";const di=S.forwardRef(({className:t,...e},r)=>o.jsx(Rve,{ref:r,className:Pe("text-lg font-semibold",t),...e}));di.displayName=Rve.displayName;const hi=S.forwardRef(({className:t,...e},r)=>o.jsx(Ove,{ref:r,className:Pe("text-sm text-muted-foreground",t),...e}));hi.displayName=Ove.displayName;const ai=S.forwardRef(({className:t,...e},r)=>o.jsx(Pve,{ref:r,className:Pe(p9(),t),...e}));ai.displayName=Pve.displayName;const Ws=S.forwardRef(({className:t,...e},r)=>o.jsx(Ive,{ref:r,className:Pe(p9({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));Ws.displayName=Ive.displayName;async function ZVe(t){const e=pe,{data:r,error:n}=await e.from("chapters").select("id").eq("thesis_id",t);if(n)throw n;const s=(r??[]).map(a=>a.id);if(s.length){const{data:a,error:l}=await e.from("sections").select("id").in("chapter_id",s);if(l)throw l;const c=(a??[]).map(d=>d.id);if(c.length){const{error:d}=await e.from("section_evidence").delete().in("section_id",c);if(d)throw d;const{error:h}=await e.from("sections").delete().in("id",c);if(h)throw h}const{error:u}=await e.from("chapters").delete().eq("thesis_id",t);if(u)throw u}const{error:i}=await e.from("theses").delete().eq("id",t);if(i)throw i}async function JVe(t,e){try{const r=`${t}/thesis-images/${e}`,{data:n,error:s}=await pe.storage.from("documents").list(r);if(s)return s.message;if(!n||n.length===0)return null;const i=n.map(l=>`${r}/${l.name}`),{error:a}=await pe.storage.from("documents").remove(i);return a?a.message:null}catch(r){return(r==null?void 0:r.message)||"Unknown storage error"}}function Dve({open:t,onOpenChange:e,thesis:r,onUpdated:n,onDeleted:s}){const[i,a]=S.useState({title:"",degree:"bachelor",description:"",due_date:"",target_word_count:15e3}),[l,c]=S.useState(!1),[u,d]=S.useState(!1),[h,f]=S.useState(!1),p=async()=>{var g;if(r){f(!0);try{await ZVe(r.id);const{data:y}=await pe.auth.getUser();if((g=y==null?void 0:y.user)!=null&&g.id){const x=await JVe(y.user.id,r.id);x&&(console.warn("Thesis image cleanup failed (thesis itself was deleted):",x),It({title:"Thesis deleted, but image cleanup failed",description:"Some thesis images could not be removed from storage. This does not affect the deletion."}))}It({title:"Thesis deleted",description:`"${r.title}" was permanently deleted.`}),d(!1),e(!1),s==null||s(r.id)}catch(y){console.error("Error deleting thesis:",y),It({title:"Could not delete thesis",description:(y==null?void 0:y.message)||"Please try again.",variant:"destructive"})}finally{f(!1)}}};S.useEffect(()=>{t&&r&&a({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 m=async()=>{if(r){if(!i.title.trim()){It({title:"Error",description:"Title is required.",variant:"destructive"});return}c(!0);try{const g={title:i.title,degree:i.degree,description:i.description||null,due_date:i.due_date||null,target_word_count:i.target_word_count},{error:y}=await pe.from("theses").update(g).eq("id",r.id);if(y)throw y;It({title:"Success",description:"Thesis updated successfully."}),n==null||n({...r,...g}),e(!1)}catch(g){console.error("Error updating thesis:",g),It({title:"Error",description:(g==null?void 0:g.message)||"Failed to update thesis.",variant:"destructive"})}finally{c(!1)}}};return o.jsxs(jn,{open:t,onOpenChange:e,children:[o.jsxs(pn,{children:[o.jsx(mn,{children:o.jsx(gn,{children:"Edit Thesis"})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"edit-title",children:"Title *"}),o.jsx(Ue,{id:"edit-title",value:i.title,onChange:g=>a(y=>({...y,title:g.target.value})),placeholder:"Thesis title"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"edit-degree",children:"Degree"}),o.jsxs(pt,{value:i.degree,onValueChange:g=>a(y=>({...y,degree:g})),children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"bachelor",children:"Bachelor"}),o.jsx(Le,{value:"master",children:"Master"})]})]})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"edit-description",children:"Description (optional)"}),o.jsx(lr,{id:"edit-description",value:i.description,onChange:g=>a(y=>({...y,description:g.target.value})),placeholder:"Brief description of the thesis"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"edit-due_date",children:"Due Date (optional)"}),o.jsx(Ue,{id:"edit-due_date",type:"date",value:i.due_date,onChange:g=>a(y=>({...y,due_date:g.target.value}))})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Se,{htmlFor:"edit-target_word_count",children:"Target Word Count"}),o.jsx(ri,{children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(lf,{className:"h-4 w-4 text-muted-foreground cursor-help"})}),o.jsxs(xr,{side:"right",className:"max-w-[260px] text-xs leading-relaxed",children:[o.jsx("p",{className:"font-medium mb-1",children:"Approximate page count (A4, 12pt, 1.5 spacing):"}),o.jsxs("ul",{className:"space-y-0.5",children:[o.jsx("li",{children:"~3,000 words ≈ 10–12 pages"}),o.jsx("li",{children:"~5,000 words ≈ 18–20 pages"}),o.jsx("li",{children:"~10,000 words ≈ 35–40 pages"}),o.jsx("li",{children:"~15,000 words ≈ 55–60 pages"})]})]})]})})]}),o.jsx(Ue,{id:"edit-target_word_count",type:"number",min:"1000",step:"500",value:i.target_word_count,onChange:g=>a(y=>({...y,target_word_count:parseInt(g.target.value)||15e3})),placeholder:"15000"})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(me,{variant:"outline",onClick:()=>e(!1),disabled:l,children:"Cancel"}),o.jsx(me,{onClick:m,disabled:l,children:l?"Saving…":"Save Changes"})]}),o.jsxs("div",{className:"mt-2 rounded-lg border border-destructive/40 bg-destructive/5 p-4",children:[o.jsx("p",{className:"text-sm font-semibold text-destructive",children:"Danger zone"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Permanently delete this thesis with all its chapters and sections. Your library sources stay untouched."}),o.jsx(me,{variant:"destructive",size:"sm",className:"mt-3",onClick:()=>d(!0),disabled:l||h||!r,children:"Delete thesis"})]})]})]}),o.jsx(Mi,{open:u,onOpenChange:g=>!h&&d(g),children:o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsxs(di,{children:['Delete "',r==null?void 0:r.title,'"?']}),o.jsx(hi,{children:"This permanently deletes the thesis together with all of its chapters, sections, written text and evidence links. This cannot be undone. Documents in your library are not deleted."})]}),o.jsxs(ui,{children:[o.jsx(Ws,{disabled:h,children:"Cancel"}),o.jsx(me,{variant:"destructive",onClick:p,disabled:h,children:h?"Deleting…":"Delete permanently"})]})]})})]})}function eqe({stats:t,onUpdated:e}){const r=Or(),[n,s]=S.useState(!1),[i,a]=S.useState(null),l=async()=>{if(!(t!=null&&t.active_thesis_id))return;const{data:j,error:N}=await pe.from("theses").select("id,title,degree,description,due_date,target_word_count").eq("id",t.active_thesis_id).maybeSingle();if(N||!j){Ke.error("Could not load thesis");return}a(j),s(!0)},c=o.jsx(Dve,{open:n,onOpenChange:s,thesis:i,onUpdated:()=>e==null?void 0:e()});if(!(t!=null&&t.active_thesis_id))return o.jsxs(Ze,{className:"h-full rounded-lg border-border bg-card shadow-theme-xs",children:[o.jsx(Ot,{children:o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(V2,{className:"h-5 w-5 text-primary"}),"Timeline"]})}),o.jsxs(st,{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"No thesis created yet. Create one to track your deadline."}),o.jsx(me,{size:"sm",variant:"outline",onClick:()=>r("/my-thesis-2"),children:"Go to My Thesis"})]})]});if(!(t!=null&&t.active_thesis_due_date))return o.jsxs(Ze,{className:"h-full rounded-lg border-border bg-card shadow-theme-xs",children:[o.jsx(Ot,{children:o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(V2,{className:"h-5 w-5 text-primary"}),"Timeline"]})}),o.jsxs(st,{className:"space-y-3",children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"No deadline set. Add one in your thesis."}),o.jsx(me,{size:"sm",variant:"outline",onClick:l,children:"Set Deadline"})]}),c]});const u=new Date(t.active_thesis_due_date),d=new Date,h=t.active_thesis_created_at?new Date(t.active_thesis_created_at):new Date(d.getTime()-180*24*60*60*1e3),f=P4(u,h),p=P4(d,h),m=P4(u,d),g=f>0?Math.min(100,Math.max(0,p/f*100)):100,y=t.active_thesis_target_words||15e3,x=t.total_word_count||0,v=Math.max(0,y-x),b=m>0?Math.ceil(v/m):0;let w="success";return m<7?w="destructive":m<30&&(w="warning"),o.jsxs(Ze,{className:"h-full rounded-lg border-border bg-card shadow-theme-xs",children:[o.jsxs(Ot,{className:"flex-row items-center justify-between space-y-0 pb-3",children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(V2,{className:"h-5 w-5 text-primary"}),"Timeline"]}),o.jsx(me,{size:"sm",variant:"outline",onClick:l,children:"Edit Deadline"})]}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Deadline"}),o.jsx("span",{className:"font-semibold",children:d1(u,"MMMM d, yyyy",{locale:_D})})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"font-semibold",children:m>0?`${m} days remaining`:"Overdue"}),o.jsxs("span",{className:"text-muted-foreground",children:[Math.round(g),"%"]})]}),o.jsx(yj,{value:g,variant:w,size:"default",animated:!0})]})]}),v>0&&m>0&&o.jsx("div",{className:"pt-3 border-t",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Recommended:"}),o.jsxs("span",{className:"font-semibold text-primary",children:["~",b," words/day"]})]})})]}),c]})}function tqe({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 o.jsxs(Ze,{className:"h-full rounded-lg border-border bg-card shadow-theme-xs",children:[o.jsx(Ot,{className:"pb-3",children:o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(jr,{className:"h-5 w-5 text-primary"})," Writing Progress"]})}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-end justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Words written"}),o.jsxs("div",{className:"text-right",children:[o.jsx("span",{className:"text-2xl font-semibold tabular-nums",children:e.toLocaleString()}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Goal: ",r.toLocaleString()," words"]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsxs("span",{className:"font-semibold",children:[Math.round(n),"%"]}),o.jsxs("span",{className:"text-muted-foreground",children:[s.toLocaleString()," remaining"]})]}),o.jsx(yj,{value:n,variant:"primary",size:"default",animated:!0})]})]}),s>0&&o.jsx("div",{className:"rounded-lg bg-primary/5 p-3",children:o.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[o.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10",children:o.jsx(wX,{className:"h-4 w-4 text-primary"})}),o.jsx("span",{className:"text-muted-foreground",children:"Keep going - every section brings you closer to your goal."})]})}),s===0&&o.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-primary/5 p-3 text-sm",children:[o.jsx(wX,{className:"h-5 w-5 text-primary"}),o.jsxs("span",{children:[o.jsx("strong",{children:"Amazing work!"})," You've reached your writing goal."]})]})]})]})}function rqe({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?o.jsxs(Ze,{className:"h-full rounded-lg border-border bg-card shadow-theme-xs",children:[o.jsxs(Ot,{className:"flex-row items-start justify-between space-y-0 pb-3",children:[o.jsxs("div",{children:[o.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[o.jsx(nv,{className:"h-5 w-5 text-primary"}),"Qualitative Analysis"]}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Your qualitative research at a glance."})]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>e("/qualitative"),children:["Open Analysis ",o.jsx(As,{className:"ml-2 h-4 w-4"})]})]}),o.jsx(st,{children:o.jsx("div",{className:"grid grid-cols-2 divide-x divide-border sm:grid-cols-4",children:[{label:"Codebooks",value:(t==null?void 0:t.total_codebooks)||0,Icon:WOe},{label:"Interviews",value:(t==null?void 0:t.total_interviews)||0,Icon:HM},{label:"Coded Segments",value:(t==null?void 0:t.total_codings)||0,Icon:SN},{label:"Analyses",value:(t==null?void 0:t.total_analyses)||0,Icon:nv}].map(({label:n,value:s,Icon:i})=>o.jsxs("div",{className:"px-3 py-2 first:pl-0 last:pr-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(i,{className:"h-4 w-4 text-primary"}),o.jsx("span",{className:"text-lg font-semibold tabular-nums",children:s})]}),o.jsx("p",{className:"mt-1 truncate text-xs text-muted-foreground",children:n})]},n))})})]}):o.jsxs(Ze,{className:"h-full rounded-lg border-border bg-card shadow-theme-xs",children:[o.jsx(Ot,{className:"pb-3",children:o.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[o.jsx(SN,{className:"h-5 w-5 text-primary"}),"Qualitative Analysis"]})}),o.jsxs(st,{children:[o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"No qualitative data yet"}),o.jsx(me,{variant:"outline",size:"sm",className:"w-full",onClick:()=>e("/qualitative"),children:"Start Analysis"})]})]})}const nqe=["subscription","subscription_renewal","lifetime_purchase","initial"],sqe={subscription:"Subscription",subscription_renewal:"Renewal",lifetime_purchase:"Lifetime",initial:"Starter credit"};function iqe(){const{user:t,studentPoints:e,userProfile:r}=Ht(),[n,s]=S.useState(null);S.useEffect(()=>{if(!(t!=null&&t.id))return;let g=!1;return pe.from("student_points_transactions").select("amount, created_at, type").eq("user_id",t.id).gt("amount",0).in("type",nqe).order("created_at",{ascending:!1}).limit(1).maybeSingle().then(({data:y,error:x})=>{if(!g){if(x){console.error("Error loading last SP grant:",x);return}s(y?{amount:Number(y.amount),created_at:y.created_at,type:y.type}:null)}}),()=>{g=!0}},[t==null?void 0:t.id]);const i=(e==null?void 0:e.remaining)||0,a=n!=null&&n.amount&&n.amount>0?n.amount:(e==null?void 0:e.total)||0,l=a>0?Math.min(100,Math.max(0,i/a*100)):0,c=l>=50?"--success":l>=25?"--warning":"--destructive",u=140,d=14,h=(u-d)/2,f=2*Math.PI*h,p=f*(1-l/100),m=r!=null&&r.plan&&r.plan!=="free"?r.plan.charAt(0).toUpperCase()+r.plan.slice(1):n?sqe[n.type]:null;return o.jsx(Ze,{className:"h-full overflow-hidden rounded-lg border-border bg-card shadow-theme-xs",children:o.jsxs(st,{className:"flex min-h-[220px] flex-col px-5 py-4",children:[o.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[o.jsxs("span",{className:"flex items-center gap-2 text-base font-semibold text-foreground",children:["Student Points ",o.jsx(lf,{className:"h-4 w-4 text-muted-foreground"})]}),l<25&&o.jsxs("div",{className:"flex items-center gap-1 text-destructive",children:[o.jsx(TMe,{className:"h-3 w-3"}),o.jsx("span",{className:"text-xs font-medium",children:"Low"})]})]}),o.jsx("div",{className:"flex flex-1 items-center justify-center py-2",children:o.jsxs("div",{className:"relative",style:{width:u,height:u},children:[o.jsxs("svg",{width:u,height:u,viewBox:`0 0 ${u} ${u}`,className:"-rotate-90",children:[o.jsx("circle",{cx:u/2,cy:u/2,r:h,fill:"none",stroke:"hsl(var(--muted))",strokeWidth:d}),o.jsx("circle",{cx:u/2,cy:u/2,r:h,fill:"none",stroke:`hsl(var(${c}))`,strokeWidth:d,strokeLinecap:"round",strokeDasharray:f,strokeDashoffset:p,className:"transition-[stroke-dashoffset] duration-700 ease-out motion-reduce:transition-none"})]}),o.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:o.jsxs("span",{className:"text-3xl font-bold tabular-nums text-foreground",children:[Math.round(l),"%"]})})]})}),o.jsxs("div",{className:"mt-1 text-center",children:[o.jsxs("p",{className:"text-sm font-medium text-foreground",children:[i.toLocaleString()," SP remaining"]}),(n==null?void 0:n.created_at)&&o.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[n.amount.toLocaleString()," SP received on"," ",d1(new Date(n.created_at),"d MMM yyyy",{locale:_D}),m?` (${m})`:""]})]})]})})}function aqe({stats:t}){const e=Or(),r=[{label:"Run Analysis",description:"Analyse your data",icon:nv,onClick:()=>e("/qualitative/auswertung"),variant:"outline"},{label:"View Codebook",description:"Open your codebook grid",icon:kB,onClick:()=>e("/qualitative/kodierbogen-grid"),variant:"outline"}];return o.jsxs(Ze,{className:"h-full rounded-lg border-border bg-card shadow-theme-xs",children:[o.jsxs(Ot,{className:"pb-3",children:[o.jsxs(Ft,{className:"flex items-center gap-2 text-base",children:[o.jsx(TB,{className:"h-5 w-5 text-primary"}),"Quick Actions"]}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Jump into your most important tasks."})]}),o.jsx(st,{className:"space-y-3",children:o.jsx("div",{className:"space-y-2",children:o.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:r.map((n,s)=>o.jsxs(me,{variant:n.variant,size:"sm",className:"h-auto min-h-14 w-full justify-between px-3 py-2 text-left",onClick:n.onClick,children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[o.jsx(n.icon,{className:"h-5 w-5 shrink-0 text-primary"}),o.jsxs("span",{className:"min-w-0",children:[o.jsx("span",{className:"block truncate font-medium",children:n.label}),o.jsx("span",{className:"block truncate text-xs font-normal text-muted-foreground",children:n.description})]})]}),o.jsx(As,{className:"h-4 w-4 shrink-0 text-muted-foreground"})]},s))})})})]})}function Lve(){return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"grid grid-cols-1 gap-3 xl:grid-cols-12",children:[o.jsx(Ze,{className:"xl:col-span-5",children:o.jsxs("div",{className:"flex items-center gap-6 p-6",children:[o.jsx(en,{className:"h-20 w-20 rounded-full"}),o.jsxs("div",{className:"space-y-3",children:[o.jsx(en,{className:"h-4 w-24"}),o.jsx(en,{className:"h-8 w-48"}),o.jsx(en,{className:"h-6 w-64"})]})]})}),o.jsx(Ze,{className:"xl:col-span-3",children:o.jsxs(st,{className:"py-4 px-4",children:[o.jsx(en,{className:"h-4 w-24 mb-2"}),o.jsx("div",{className:"flex items-center justify-center h-[140px]",children:o.jsx(en,{className:"h-[120px] w-[120px] rounded-full"})}),o.jsx(en,{className:"h-4 w-32 mx-auto mt-1"})]})}),o.jsx(Ze,{className:"xl:col-span-4 xl:row-span-2",children:o.jsxs(st,{className:"space-y-4 py-5",children:[o.jsx(en,{className:"h-5 w-28"}),o.jsx(en,{className:"mx-auto h-28 w-28 rounded-full"}),[1,2,3,4].map(t=>o.jsx(en,{className:"h-3 w-full"},t))]})}),o.jsx(Ze,{className:"xl:col-span-8",children:o.jsx(st,{className:"grid grid-cols-2 gap-2 py-5 lg:grid-cols-4",children:[1,2,3,4].map(t=>o.jsx(en,{className:"h-16 w-full"},t))})})]}),o.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[o.jsxs(Ze,{className:"astro-card",children:[o.jsx(Ot,{children:o.jsx(en,{className:"h-6 w-32"})}),o.jsxs(st,{className:"space-y-3",children:[o.jsx(en,{className:"h-12 w-full"}),o.jsx(en,{className:"h-4 w-3/4"})]})]}),o.jsxs(Ze,{className:"astro-card",children:[o.jsx(Ot,{children:o.jsx(en,{className:"h-6 w-40"})}),o.jsxs(st,{className:"space-y-3",children:[o.jsx(en,{className:"h-12 w-full"}),o.jsx(en,{className:"h-4 w-3/4"})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[o.jsxs(Ze,{className:"astro-card",children:[o.jsx(Ot,{children:o.jsx(en,{className:"h-6 w-36"})}),o.jsx(st,{className:"space-y-3",children:o.jsxs("div",{className:"flex justify-between",children:[o.jsx(en,{className:"h-10 w-16"}),o.jsx(en,{className:"h-10 w-16"}),o.jsx(en,{className:"h-10 w-16"})]})})]}),o.jsxs(Ze,{className:"astro-card",children:[o.jsx(Ot,{children:o.jsx(en,{className:"h-6 w-44"})}),o.jsx(st,{className:"space-y-3",children:o.jsxs("div",{className:"flex justify-between",children:[o.jsx(en,{className:"h-10 w-16"}),o.jsx(en,{className:"h-10 w-16"}),o.jsx(en,{className:"h-10 w-16"})]})})]})]})]})}function oqe({stats:t}){const{researchProfile:e}=Ht(),[r,n]=S.useState(null),s=Or(),i=(e==null?void 0:e.nickname)||"Researcher",a=t==null?void 0:t.active_thesis_title;S.useEffect(()=>{(async()=>{const u=await x0(e==null?void 0:e.avatar_url);n(u)})()},[e==null?void 0:e.avatar_url]);const l=i.split(" ").map(c=>c[0]).join("").toUpperCase().slice(0,2);return o.jsxs("div",{className:"relative flex h-full min-h-[220px] flex-col justify-between overflow-hidden bg-primary/5 p-5 sm:p-6",children:[o.jsx("div",{className:"absolute -bottom-16 -right-12 h-52 w-52 rounded-full bg-primary/10","aria-hidden":"true"}),o.jsx("div",{className:"absolute bottom-5 right-24 h-28 w-28 rounded-full bg-primary/5","aria-hidden":"true"}),o.jsxs("div",{className:"relative flex items-start justify-between gap-5",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("p",{className:"flex items-center gap-2 text-sm font-medium text-primary",children:[o.jsx(Sr,{className:"h-4 w-4"})," Good to see you again!"]}),o.jsxs("h1",{className:"mt-2 text-3xl font-bold leading-tight text-foreground sm:text-4xl",children:["Welcome back,",o.jsx("br",{}),i]}),a?o.jsxs("p",{className:"mt-3 max-w-md line-clamp-2 text-sm text-muted-foreground",children:["Working on ",o.jsx("span",{className:"font-medium text-foreground",children:a})]}):o.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Your research workspace is ready when you are."})]}),o.jsxs(C9,{className:"h-20 w-20 shrink-0 border-4 border-card shadow-theme-md sm:h-24 sm:w-24",children:[o.jsx(E9,{src:r||void 0,alt:i,className:"object-cover"}),o.jsx(A9,{className:"bg-primary/10 text-base font-semibold text-primary",children:l||"R"})]})]}),o.jsxs("div",{className:"relative mt-5 flex flex-wrap gap-2",children:[o.jsxs(me,{size:"sm",onClick:()=>s("/my-thesis-2"),children:["Continue Writing ",o.jsx(As,{className:"ml-2 h-4 w-4"})]}),o.jsxs(me,{size:"sm",variant:"outline",onClick:()=>s("/my-thesis-2"),children:[o.jsx(nr,{className:"mr-2 h-4 w-4"})," View Thesis"]})]})]})}var lqe=Array.isArray,To=lqe,cqe=typeof $n=="object"&&$n&&$n.Object===Object&&$n,$ve=cqe,uqe=$ve,dqe=typeof self=="object"&&self&&self.Object===Object&&self,hqe=uqe||dqe||Function("return this")(),jd=hqe,fqe=jd,pqe=fqe.Symbol,XE=pqe,rJ=XE,Fve=Object.prototype,mqe=Fve.hasOwnProperty,gqe=Fve.toString,eS=rJ?rJ.toStringTag:void 0;function xqe(t){var e=mqe.call(t,eS),r=t[eS];try{t[eS]=void 0;var n=!0}catch{}var s=gqe.call(t);return n&&(e?t[eS]=r:delete t[eS]),s}var yqe=xqe,vqe=Object.prototype,bqe=vqe.toString;function wqe(t){return bqe.call(t)}var jqe=wqe,nJ=XE,Sqe=yqe,_qe=jqe,Nqe="[object Null]",kqe="[object Undefined]",sJ=nJ?nJ.toStringTag:void 0;function Cqe(t){return t==null?t===void 0?kqe:Nqe:sJ&&sJ in Object(t)?Sqe(t):_qe(t)}var Ef=Cqe;function Eqe(t){return t!=null&&typeof t=="object"}var Af=Eqe,Aqe=Ef,Tqe=Af,Pqe="[object Symbol]";function Iqe(t){return typeof t=="symbol"||Tqe(t)&&Aqe(t)==Pqe}var vj=Iqe,Rqe=To,Oqe=vj,Mqe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Dqe=/^\w*$/;function Lqe(t,e){if(Rqe(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Oqe(t)?!0:Dqe.test(t)||!Mqe.test(t)||e!=null&&t in Object(e)}var _V=Lqe;function $qe(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var dg=$qe;const bj=Er(dg);var Fqe=Ef,Bqe=dg,zqe="[object AsyncFunction]",Uqe="[object Function]",Hqe="[object GeneratorFunction]",Wqe="[object Proxy]";function Vqe(t){if(!Bqe(t))return!1;var e=Fqe(t);return e==Uqe||e==Hqe||e==zqe||e==Wqe}var NV=Vqe;const hr=Er(NV);var qqe=jd,Gqe=qqe["__core-js_shared__"],Kqe=Gqe,K4=Kqe,iJ=function(){var t=/[^.]+$/.exec(K4&&K4.keys&&K4.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function Yqe(t){return!!iJ&&iJ in t}var Xqe=Yqe,Qqe=Function.prototype,Zqe=Qqe.toString;function Jqe(t){if(t!=null){try{return Zqe.call(t)}catch{}try{return t+""}catch{}}return""}var Bve=Jqe,eGe=NV,tGe=Xqe,rGe=dg,nGe=Bve,sGe=/[\\^$.*+?()[\]{}|]/g,iGe=/^\[object .+?Constructor\]$/,aGe=Function.prototype,oGe=Object.prototype,lGe=aGe.toString,cGe=oGe.hasOwnProperty,uGe=RegExp("^"+lGe.call(cGe).replace(sGe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function dGe(t){if(!rGe(t)||tGe(t))return!1;var e=eGe(t)?uGe:iGe;return e.test(nGe(t))}var hGe=dGe;function fGe(t,e){return t==null?void 0:t[e]}var pGe=fGe,mGe=hGe,gGe=pGe;function xGe(t,e){var r=gGe(t,e);return mGe(r)?r:void 0}var Rv=xGe,yGe=Rv,vGe=yGe(Object,"create"),PD=vGe,aJ=PD;function bGe(){this.__data__=aJ?aJ(null):{},this.size=0}var wGe=bGe;function jGe(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var SGe=jGe,_Ge=PD,NGe="__lodash_hash_undefined__",kGe=Object.prototype,CGe=kGe.hasOwnProperty;function EGe(t){var e=this.__data__;if(_Ge){var r=e[t];return r===NGe?void 0:r}return CGe.call(e,t)?e[t]:void 0}var AGe=EGe,TGe=PD,PGe=Object.prototype,IGe=PGe.hasOwnProperty;function RGe(t){var e=this.__data__;return TGe?e[t]!==void 0:IGe.call(e,t)}var OGe=RGe,MGe=PD,DGe="__lodash_hash_undefined__";function LGe(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=MGe&&e===void 0?DGe:e,this}var $Ge=LGe,FGe=wGe,BGe=SGe,zGe=AGe,UGe=OGe,HGe=$Ge;function wj(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])}}wj.prototype.clear=FGe;wj.prototype.delete=BGe;wj.prototype.get=zGe;wj.prototype.has=UGe;wj.prototype.set=HGe;var WGe=wj;function VGe(){this.__data__=[],this.size=0}var qGe=VGe;function GGe(t,e){return t===e||t!==t&&e!==e}var kV=GGe,KGe=kV;function YGe(t,e){for(var r=t.length;r--;)if(KGe(t[r][0],e))return r;return-1}var ID=YGe,XGe=ID,QGe=Array.prototype,ZGe=QGe.splice;function JGe(t){var e=this.__data__,r=XGe(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():ZGe.call(e,r,1),--this.size,!0}var eKe=JGe,tKe=ID;function rKe(t){var e=this.__data__,r=tKe(e,t);return r<0?void 0:e[r][1]}var nKe=rKe,sKe=ID;function iKe(t){return sKe(this.__data__,t)>-1}var aKe=iKe,oKe=ID;function lKe(t,e){var r=this.__data__,n=oKe(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}var cKe=lKe,uKe=qGe,dKe=eKe,hKe=nKe,fKe=aKe,pKe=cKe;function jj(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])}}jj.prototype.clear=uKe;jj.prototype.delete=dKe;jj.prototype.get=hKe;jj.prototype.has=fKe;jj.prototype.set=pKe;var RD=jj,mKe=Rv,gKe=jd,xKe=mKe(gKe,"Map"),CV=xKe,oJ=WGe,yKe=RD,vKe=CV;function bKe(){this.size=0,this.__data__={hash:new oJ,map:new(vKe||yKe),string:new oJ}}var wKe=bKe;function jKe(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var SKe=jKe,_Ke=SKe;function NKe(t,e){var r=t.__data__;return _Ke(e)?r[typeof e=="string"?"string":"hash"]:r.map}var OD=NKe,kKe=OD;function CKe(t){var e=kKe(this,t).delete(t);return this.size-=e?1:0,e}var EKe=CKe,AKe=OD;function TKe(t){return AKe(this,t).get(t)}var PKe=TKe,IKe=OD;function RKe(t){return IKe(this,t).has(t)}var OKe=RKe,MKe=OD;function DKe(t,e){var r=MKe(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}var LKe=DKe,$Ke=wKe,FKe=EKe,BKe=PKe,zKe=OKe,UKe=LKe;function Sj(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])}}Sj.prototype.clear=$Ke;Sj.prototype.delete=FKe;Sj.prototype.get=BKe;Sj.prototype.has=zKe;Sj.prototype.set=UKe;var EV=Sj,zve=EV,HKe="Expected a function";function AV(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(HKe);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(AV.Cache||zve),r}AV.Cache=zve;var Uve=AV;const WKe=Er(Uve);var VKe=Uve,qKe=500;function GKe(t){var e=VKe(t,function(n){return r.size===qKe&&r.clear(),n}),r=e.cache;return e}var KKe=GKe,YKe=KKe,XKe=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,QKe=/\\(\\)?/g,ZKe=YKe(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(XKe,function(r,n,s,i){e.push(s?i.replace(QKe,"$1"):n||r)}),e}),JKe=ZKe;function eYe(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 TV=eYe,lJ=XE,tYe=TV,rYe=To,nYe=vj,sYe=1/0,cJ=lJ?lJ.prototype:void 0,uJ=cJ?cJ.toString:void 0;function Hve(t){if(typeof t=="string")return t;if(rYe(t))return tYe(t,Hve)+"";if(nYe(t))return uJ?uJ.call(t):"";var e=t+"";return e=="0"&&1/t==-sYe?"-0":e}var iYe=Hve,aYe=iYe;function oYe(t){return t==null?"":aYe(t)}var Wve=oYe,lYe=To,cYe=_V,uYe=JKe,dYe=Wve;function hYe(t,e){return lYe(t)?t:cYe(t,e)?[t]:uYe(dYe(t))}var Vve=hYe,fYe=vj,pYe=1/0;function mYe(t){if(typeof t=="string"||fYe(t))return t;var e=t+"";return e=="0"&&1/t==-pYe?"-0":e}var MD=mYe,gYe=Vve,xYe=MD;function yYe(t,e){e=gYe(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[xYe(e[r++])];return r&&r==n?t:void 0}var PV=yYe,vYe=PV;function bYe(t,e,r){var n=t==null?void 0:vYe(t,e);return n===void 0?r:n}var qve=bYe;const Xc=Er(qve);function wYe(t){return t==null}var jYe=wYe;const Rr=Er(jYe);var SYe=Ef,_Ye=To,NYe=Af,kYe="[object String]";function CYe(t){return typeof t=="string"||!_Ye(t)&&NYe(t)&&SYe(t)==kYe}var EYe=CYe;const QE=Er(EYe);var Gve={exports:{}},sn={};/**
 * @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 IV=Symbol.for("react.element"),RV=Symbol.for("react.portal"),DD=Symbol.for("react.fragment"),LD=Symbol.for("react.strict_mode"),$D=Symbol.for("react.profiler"),FD=Symbol.for("react.provider"),BD=Symbol.for("react.context"),AYe=Symbol.for("react.server_context"),zD=Symbol.for("react.forward_ref"),UD=Symbol.for("react.suspense"),HD=Symbol.for("react.suspense_list"),WD=Symbol.for("react.memo"),VD=Symbol.for("react.lazy"),TYe=Symbol.for("react.offscreen"),Kve;Kve=Symbol.for("react.module.reference");function hc(t){if(typeof t=="object"&&t!==null){var e=t.$$typeof;switch(e){case IV:switch(t=t.type,t){case DD:case $D:case LD:case UD:case HD:return t;default:switch(t=t&&t.$$typeof,t){case AYe:case BD:case zD:case VD:case WD:case FD:return t;default:return e}}case RV:return e}}}sn.ContextConsumer=BD;sn.ContextProvider=FD;sn.Element=IV;sn.ForwardRef=zD;sn.Fragment=DD;sn.Lazy=VD;sn.Memo=WD;sn.Portal=RV;sn.Profiler=$D;sn.StrictMode=LD;sn.Suspense=UD;sn.SuspenseList=HD;sn.isAsyncMode=function(){return!1};sn.isConcurrentMode=function(){return!1};sn.isContextConsumer=function(t){return hc(t)===BD};sn.isContextProvider=function(t){return hc(t)===FD};sn.isElement=function(t){return typeof t=="object"&&t!==null&&t.$$typeof===IV};sn.isForwardRef=function(t){return hc(t)===zD};sn.isFragment=function(t){return hc(t)===DD};sn.isLazy=function(t){return hc(t)===VD};sn.isMemo=function(t){return hc(t)===WD};sn.isPortal=function(t){return hc(t)===RV};sn.isProfiler=function(t){return hc(t)===$D};sn.isStrictMode=function(t){return hc(t)===LD};sn.isSuspense=function(t){return hc(t)===UD};sn.isSuspenseList=function(t){return hc(t)===HD};sn.isValidElementType=function(t){return typeof t=="string"||typeof t=="function"||t===DD||t===$D||t===LD||t===UD||t===HD||t===TYe||typeof t=="object"&&t!==null&&(t.$$typeof===VD||t.$$typeof===WD||t.$$typeof===FD||t.$$typeof===BD||t.$$typeof===zD||t.$$typeof===Kve||t.getModuleId!==void 0)};sn.typeOf=hc;Gve.exports=sn;var PYe=Gve.exports,IYe=Ef,RYe=Af,OYe="[object Number]";function MYe(t){return typeof t=="number"||RYe(t)&&IYe(t)==OYe}var Yve=MYe;const DYe=Er(Yve);var LYe=Yve;function $Ye(t){return LYe(t)&&t!=+t}var FYe=$Ye;const ZE=Er(FYe);var Yl=function(e){return e===0?0:e>0?1:-1},lx=function(e){return QE(e)&&e.indexOf("%")===e.length-1},gt=function(e){return DYe(e)&&!ZE(e)},ni=function(e){return gt(e)||QE(e)},BYe=0,qD=function(e){var r=++BYe;return"".concat(e||"").concat(r)},vo=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(!gt(e)&&!QE(e))return n;var i;if(lx(e)){var a=e.indexOf("%");i=r*parseFloat(e.slice(0,a))/100}else i=+e;return ZE(i)&&(i=n),s&&i>r&&(i=r),i},mb=function(e){if(!e)return null;var r=Object.keys(e);return r&&r.length?e[r[0]]:null},zYe=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},dJ=function(e,r){return gt(e)&&gt(r)?function(n){return e+n*(r-e)}:function(){return r}};function H8(t,e,r){return!t||!t.length?null:t.find(function(n){return n&&(typeof e=="function"?e(n):Xc(n,e))===r})}function W8(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 V8(t){"@babel/helpers - typeof";return V8=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},V8(t)}var UYe=["viewBox","children"],HYe=["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"],hJ=["points","pathLength"],Y4={svg:UYe,polygon:hJ,polyline:hJ},OV=["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"],YI=function(e,r){if(!e||typeof e=="function"||typeof e=="boolean")return null;var n=e;if(S.isValidElement(e)&&(n=e.props),!bj(n))return null;var s={};return Object.keys(n).forEach(function(i){OV.includes(i)&&(s[i]=r||function(a){return n[i](n,a)})}),s},WYe=function(e,r,n){return function(s){return e(r,n,s),null}},GD=function(e,r,n){if(!bj(e)||V8(e)!=="object")return null;var s=null;return Object.keys(e).forEach(function(i){var a=e[i];OV.includes(i)&&typeof a=="function"&&(s||(s={}),s[i]=WYe(a,r,n))}),s},VYe=["children"],qYe=["children"];function fJ(t,e){if(t==null)return{};var r=GYe(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 GYe(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 pJ={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"},Kh=function(e){return typeof e=="string"?e:e?e.displayName||e.name||"Component":""},mJ=null,X4=null,MV=function t(e){if(e===mJ&&Array.isArray(X4))return X4;var r=[];return S.Children.forEach(e,function(n){Rr(n)||(PYe.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),X4=r,mJ=e,r};function od(t,e){var r=[],n=[];return Array.isArray(e)?n=e.map(function(s){return Kh(s)}):n=[Kh(e)],MV(t).forEach(function(s){var i=Xc(s,"type.displayName")||Xc(s,"type.name");n.indexOf(i)!==-1&&r.push(s)}),r}function $l(t,e){var r=od(t,e);return r&&r[0]}var gJ=function(e){if(!e||!e.props)return!1;var r=e.props,n=r.width,s=r.height;return!(!gt(n)||n<=0||!gt(s)||s<=0)},KYe=["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"],YYe=function(e){return e&&e.type&&QE(e.type)&&KYe.indexOf(e.type)>=0},XYe=function(e,r,n,s){var i,a=(i=Y4==null?void 0:Y4[s])!==null&&i!==void 0?i:[];return r.startsWith("data-")||!hr(e)&&(s&&a.includes(r)||HYe.includes(r))||n&&OV.includes(r)},cr=function(e,r,n){if(!e||typeof e=="function"||typeof e=="boolean")return null;var s=e;if(S.isValidElement(e)&&(s=e.props),!bj(s))return null;var i={};return Object.keys(s).forEach(function(a){var l;XYe((l=s)===null||l===void 0?void 0:l[a],a,r,n)&&(i[a]=s[a])}),i},q8=function t(e,r){if(e===r)return!0;var n=S.Children.count(e);if(n!==S.Children.count(r))return!1;if(n===0)return!0;if(n===1)return xJ(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(!xJ(i,a))return!1}return!0},xJ=function(e,r){if(Rr(e)&&Rr(r))return!0;if(!Rr(e)&&!Rr(r)){var n=e.props||{},s=n.children,i=fJ(n,VYe),a=r.props||{},l=a.children,c=fJ(a,qYe);return s&&l?W8(i,c)&&q8(s,l):!s&&!l?W8(i,c):!1}return!1},yJ=function(e,r){var n=[],s={};return MV(e).forEach(function(i,a){if(YYe(i))n.push(i);else if(i){var l=Kh(i.type),c=r[l]||{},u=c.handler,d=c.once;if(u&&(!d||!s[l])){var h=u(i,l,a);n.push(h),s[l]=!0}}}),n},QYe=function(e){var r=e&&e.type;return r&&pJ[r]?pJ[r]:null},ZYe=function(e,r){return MV(r).indexOf(e)},JYe=["children","width","height","viewBox","className","style","title","desc"];function G8(){return G8=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},G8.apply(this,arguments)}function eXe(t,e){if(t==null)return{};var r=tXe(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 tXe(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 K8(t){var e=t.children,r=t.width,n=t.height,s=t.viewBox,i=t.className,a=t.style,l=t.title,c=t.desc,u=eXe(t,JYe),d=s||{width:r,height:n,x:0,y:0},h=$r("recharts-surface",i);return ve.createElement("svg",G8({},cr(u,!0,"svg"),{className:h,width:r,height:n,style:a,viewBox:"".concat(d.x," ").concat(d.y," ").concat(d.width," ").concat(d.height)}),ve.createElement("title",null,l),ve.createElement("desc",null,c),e)}var rXe=["children","className"];function Y8(){return Y8=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},Y8.apply(this,arguments)}function nXe(t,e){if(t==null)return{};var r=sXe(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 sXe(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 vs=ve.forwardRef(function(t,e){var r=t.children,n=t.className,s=nXe(t,rXe),i=$r("recharts-layer",n);return ve.createElement("g",Y8({className:i},cr(s,!0),{ref:e}),r)}),Yh=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 iXe(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 aXe=iXe,oXe=aXe;function lXe(t,e,r){var n=t.length;return r=r===void 0?n:r,!e&&r>=n?t:oXe(t,e,r)}var cXe=lXe,uXe="\\ud800-\\udfff",dXe="\\u0300-\\u036f",hXe="\\ufe20-\\ufe2f",fXe="\\u20d0-\\u20ff",pXe=dXe+hXe+fXe,mXe="\\ufe0e\\ufe0f",gXe="\\u200d",xXe=RegExp("["+gXe+uXe+pXe+mXe+"]");function yXe(t){return xXe.test(t)}var Xve=yXe;function vXe(t){return t.split("")}var bXe=vXe,Qve="\\ud800-\\udfff",wXe="\\u0300-\\u036f",jXe="\\ufe20-\\ufe2f",SXe="\\u20d0-\\u20ff",_Xe=wXe+jXe+SXe,NXe="\\ufe0e\\ufe0f",kXe="["+Qve+"]",X8="["+_Xe+"]",Q8="\\ud83c[\\udffb-\\udfff]",CXe="(?:"+X8+"|"+Q8+")",Zve="[^"+Qve+"]",Jve="(?:\\ud83c[\\udde6-\\uddff]){2}",ebe="[\\ud800-\\udbff][\\udc00-\\udfff]",EXe="\\u200d",tbe=CXe+"?",rbe="["+NXe+"]?",AXe="(?:"+EXe+"(?:"+[Zve,Jve,ebe].join("|")+")"+rbe+tbe+")*",TXe=rbe+tbe+AXe,PXe="(?:"+[Zve+X8+"?",X8,Jve,ebe,kXe].join("|")+")",IXe=RegExp(Q8+"(?="+Q8+")|"+PXe+TXe,"g");function RXe(t){return t.match(IXe)||[]}var OXe=RXe,MXe=bXe,DXe=Xve,LXe=OXe;function $Xe(t){return DXe(t)?LXe(t):MXe(t)}var FXe=$Xe,BXe=cXe,zXe=Xve,UXe=FXe,HXe=Wve;function WXe(t){return function(e){e=HXe(e);var r=zXe(e)?UXe(e):void 0,n=r?r[0]:e.charAt(0),s=r?BXe(r,1).join(""):e.slice(1);return n[t]()+s}}var VXe=WXe,qXe=VXe,GXe=qXe("toUpperCase"),KXe=GXe;const KD=Er(KXe);function An(t){return function(){return t}}const nbe=Math.cos,XI=Math.sin,ou=Math.sqrt,QI=Math.PI,YD=2*QI,Z8=Math.PI,J8=2*Z8,Ug=1e-6,YXe=J8-Ug;function sbe(t){this._+=t[0];for(let e=1,r=t.length;e<r;++e)this._+=arguments[e]+t[e]}function XXe(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return sbe;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 QXe{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?sbe:XXe(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,l=this._y1,c=n-e,u=s-r,d=a-e,h=l-r,f=d*d+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=r}`;else if(f>Ug)if(!(Math.abs(h*c-u*d)>Ug)||!i)this._append`L${this._x1=e},${this._y1=r}`;else{let p=n-a,m=s-l,g=c*c+u*u,y=p*p+m*m,x=Math.sqrt(g),v=Math.sqrt(f),b=i*Math.tan((Z8-Math.acos((g+f-y)/(2*x*v)))/2),w=b/v,j=b/x;Math.abs(w-1)>Ug&&this._append`L${e+w*d},${r+w*h}`,this._append`A${i},${i},0,0,${+(h*p>d*m)},${this._x1=e+j*c},${this._y1=r+j*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 l=n*Math.cos(s),c=n*Math.sin(s),u=e+l,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)>Ug||Math.abs(this._y1-d)>Ug)&&this._append`L${u},${d}`,n&&(f<0&&(f=f%J8+J8),f>YXe?this._append`A${n},${n},0,1,${h},${e-l},${r-c}A${n},${n},0,1,${h},${this._x1=u},${this._y1=d}`:f>Ug&&this._append`A${n},${n},0,${+(f>=Z8)},${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 DV(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 QXe(e)}function LV(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function ibe(t){this._context=t}ibe.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 XD(t){return new ibe(t)}function abe(t){return t[0]}function obe(t){return t[1]}function lbe(t,e){var r=An(!0),n=null,s=XD,i=null,a=DV(l);t=typeof t=="function"?t:t===void 0?abe:An(t),e=typeof e=="function"?e:e===void 0?obe:An(e);function l(c){var u,d=(c=LV(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 l.x=function(c){return arguments.length?(t=typeof c=="function"?c:An(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:An(+c),l):e},l.defined=function(c){return arguments.length?(r=typeof c=="function"?c:An(!!c),l):r},l.curve=function(c){return arguments.length?(s=c,n!=null&&(i=s(n)),l):s},l.context=function(c){return arguments.length?(c==null?n=i=null:i=s(n=c),l):n},l}function dT(t,e,r){var n=null,s=An(!0),i=null,a=XD,l=null,c=DV(u);t=typeof t=="function"?t:t===void 0?abe:An(+t),e=typeof e=="function"?e:An(e===void 0?0:+e),r=typeof r=="function"?r:r===void 0?obe:An(+r);function u(h){var f,p,m,g=(h=LV(h)).length,y,x=!1,v,b=new Array(g),w=new Array(g);for(i==null&&(l=a(v=c())),f=0;f<=g;++f){if(!(f<g&&s(y=h[f],f,h))===x)if(x=!x)p=f,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),m=f-1;m>=p;--m)l.point(b[m],w[m]);l.lineEnd(),l.areaEnd()}x&&(b[f]=+t(y,f,h),w[f]=+e(y,f,h),l.point(n?+n(y,f,h):b[f],r?+r(y,f,h):w[f]))}if(v)return l=null,v+""||null}function d(){return lbe().defined(s).curve(a).context(i)}return u.x=function(h){return arguments.length?(t=typeof h=="function"?h:An(+h),n=null,u):t},u.x0=function(h){return arguments.length?(t=typeof h=="function"?h:An(+h),u):t},u.x1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:An(+h),u):n},u.y=function(h){return arguments.length?(e=typeof h=="function"?h:An(+h),r=null,u):e},u.y0=function(h){return arguments.length?(e=typeof h=="function"?h:An(+h),u):e},u.y1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:An(+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:An(!!h),u):s},u.curve=function(h){return arguments.length?(a=h,i!=null&&(l=a(i)),u):a},u.context=function(h){return arguments.length?(h==null?i=l=null:l=a(i=h),u):i},u}class cbe{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 ZXe(t){return new cbe(t,!0)}function JXe(t){return new cbe(t,!1)}const $V={draw(t,e){const r=ou(e/QI);t.moveTo(r,0),t.arc(0,0,r,0,YD)}},eQe={draw(t,e){const r=ou(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()}},ube=ou(1/3),tQe=ube*2,rQe={draw(t,e){const r=ou(e/tQe),n=r*ube;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},nQe={draw(t,e){const r=ou(e),n=-r/2;t.rect(n,n,r,r)}},sQe=.8908130915292852,dbe=XI(QI/10)/XI(7*QI/10),iQe=XI(YD/10)*dbe,aQe=-nbe(YD/10)*dbe,oQe={draw(t,e){const r=ou(e*sQe),n=iQe*r,s=aQe*r;t.moveTo(0,-r),t.lineTo(n,s);for(let i=1;i<5;++i){const a=YD*i/5,l=nbe(a),c=XI(a);t.lineTo(c*r,-l*r),t.lineTo(l*n-c*s,c*n+l*s)}t.closePath()}},Q4=ou(3),lQe={draw(t,e){const r=-ou(e/(Q4*3));t.moveTo(0,r*2),t.lineTo(-Q4*r,-r),t.lineTo(Q4*r,-r),t.closePath()}},bl=-.5,wl=ou(3)/2,ez=1/ou(12),cQe=(ez/2+1)*3,uQe={draw(t,e){const r=ou(e/cQe),n=r/2,s=r*ez,i=n,a=r*ez+r,l=-i,c=a;t.moveTo(n,s),t.lineTo(i,a),t.lineTo(l,c),t.lineTo(bl*n-wl*s,wl*n+bl*s),t.lineTo(bl*i-wl*a,wl*i+bl*a),t.lineTo(bl*l-wl*c,wl*l+bl*c),t.lineTo(bl*n+wl*s,bl*s-wl*n),t.lineTo(bl*i+wl*a,bl*a-wl*i),t.lineTo(bl*l+wl*c,bl*c-wl*l),t.closePath()}};function dQe(t,e){let r=null,n=DV(s);t=typeof t=="function"?t:An(t||$V),e=typeof e=="function"?e:An(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:An(i),s):t},s.size=function(i){return arguments.length?(e=typeof i=="function"?i:An(+i),s):e},s.context=function(i){return arguments.length?(r=i??null,s):r},s}function ZI(){}function JI(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 hbe(t){this._context=t}hbe.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:JI(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:JI(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function hQe(t){return new hbe(t)}function fbe(t){this._context=t}fbe.prototype={areaStart:ZI,areaEnd:ZI,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:JI(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function fQe(t){return new fbe(t)}function pbe(t){this._context=t}pbe.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:JI(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function pQe(t){return new pbe(t)}function mbe(t){this._context=t}mbe.prototype={areaStart:ZI,areaEnd:ZI,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 mQe(t){return new mbe(t)}function vJ(t){return t<0?-1:1}function bJ(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),l=(i*s+a*n)/(n+s);return(vJ(i)+vJ(a))*Math.min(Math.abs(i),Math.abs(a),.5*Math.abs(l))||0}function wJ(t,e){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-e)/2:e}function Z4(t,e,r){var n=t._x0,s=t._y0,i=t._x1,a=t._y1,l=(i-n)/3;t._context.bezierCurveTo(n+l,s+l*e,i-l,a-l*r,i,a)}function eR(t){this._context=t}eR.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:Z4(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,Z4(this,wJ(this,r=bJ(this,t,e)),r);break;default:Z4(this,this._t0,r=bJ(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=r}}};function gbe(t){this._context=new xbe(t)}(gbe.prototype=Object.create(eR.prototype)).point=function(t,e){eR.prototype.point.call(this,e,t)};function xbe(t){this._context=t}xbe.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 gQe(t){return new eR(t)}function xQe(t){return new gbe(t)}function ybe(t){this._context=t}ybe.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=jJ(t),s=jJ(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 jJ(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 yQe(t){return new ybe(t)}function QD(t,e){this._context=t,this._t=e}QD.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 vQe(t){return new QD(t,.5)}function bQe(t){return new QD(t,0)}function wQe(t){return new QD(t,1)}function p1(t,e){if((a=t.length)>1)for(var r=1,n,s,i=t[e[0]],a,l=i.length;r<a;++r)for(s=i,i=t[e[r]],n=0;n<l;++n)i[n][1]+=i[n][0]=isNaN(s[n][1])?s[n][0]:s[n][1]}function tz(t){for(var e=t.length,r=new Array(e);--e>=0;)r[e]=e;return r}function jQe(t,e){return t[e]}function SQe(t){const e=[];return e.key=t,e}function _Qe(){var t=An([]),e=tz,r=p1,n=jQe;function s(i){var a=Array.from(t.apply(this,arguments),SQe),l,c=a.length,u=-1,d;for(const h of i)for(l=0,++u;l<c;++l)(a[l][u]=[0,+n(h,a[l].key,u,i)]).data=h;for(l=0,d=LV(e(a));l<c;++l)a[d[l]].index=l;return r(a,d),a}return s.keys=function(i){return arguments.length?(t=typeof i=="function"?i:An(Array.from(i)),s):t},s.value=function(i){return arguments.length?(n=typeof i=="function"?i:An(+i),s):n},s.order=function(i){return arguments.length?(e=i==null?tz:typeof i=="function"?i:An(Array.from(i)),s):e},s.offset=function(i){return arguments.length?(r=i??p1,s):r},s}function NQe(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}p1(t,e)}}function kQe(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,l=0;a<s;++a)l+=t[a][r][1]||0;n[r][1]+=n[r][0]=-l/2}p1(t,e)}}function CQe(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 l=0,c=0,u=0;l<a;++l){for(var d=t[e[l]],h=d[n][1]||0,f=d[n-1][1]||0,p=(h-f)/2,m=0;m<l;++m){var g=t[e[m]],y=g[n][1]||0,x=g[n-1][1]||0;p+=y-x}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,p1(t,e)}}function zN(t){"@babel/helpers - typeof";return zN=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},zN(t)}var EQe=["type","size","sizeType"];function rz(){return rz=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},rz.apply(this,arguments)}function SJ(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 _J(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?SJ(Object(r),!0).forEach(function(n){AQe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):SJ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function AQe(t,e,r){return e=TQe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function TQe(t){var e=PQe(t,"string");return zN(e)=="symbol"?e:e+""}function PQe(t,e){if(zN(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(zN(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function IQe(t,e){if(t==null)return{};var r=RQe(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 RQe(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 vbe={symbolCircle:$V,symbolCross:eQe,symbolDiamond:rQe,symbolSquare:nQe,symbolStar:oQe,symbolTriangle:lQe,symbolWye:uQe},OQe=Math.PI/180,MQe=function(e){var r="symbol".concat(KD(e));return vbe[r]||$V},DQe=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*OQe;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}},LQe=function(e,r){vbe["symbol".concat(KD(e))]=r},FV=function(e){var r=e.type,n=r===void 0?"circle":r,s=e.size,i=s===void 0?64:s,a=e.sizeType,l=a===void 0?"area":a,c=IQe(e,EQe),u=_J(_J({},c),{},{type:n,size:i,sizeType:l}),d=function(){var y=MQe(n),x=dQe().type(y).size(DQe(i,l,n));return x()},h=u.className,f=u.cx,p=u.cy,m=cr(u,!0);return f===+f&&p===+p&&i===+i?ve.createElement("path",rz({},m,{className:$r("recharts-symbols",h),transform:"translate(".concat(f,", ").concat(p,")"),d:d()})):null};FV.registerSymbol=LQe;function m1(t){"@babel/helpers - typeof";return m1=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},m1(t)}function nz(){return nz=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},nz.apply(this,arguments)}function NJ(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 $Qe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?NJ(Object(r),!0).forEach(function(n){UN(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):NJ(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function FQe(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function BQe(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,wbe(n.key),n)}}function zQe(t,e,r){return e&&BQe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function UQe(t,e,r){return e=tR(e),HQe(t,bbe()?Reflect.construct(e,r||[],tR(t).constructor):e.apply(t,r))}function HQe(t,e){if(e&&(m1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return WQe(t)}function WQe(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function bbe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(bbe=function(){return!!t})()}function tR(t){return tR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},tR(t)}function VQe(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&&sz(t,e)}function sz(t,e){return sz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},sz(t,e)}function UN(t,e,r){return e=wbe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function wbe(t){var e=qQe(t,"string");return m1(e)=="symbol"?e:e+""}function qQe(t,e){if(m1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(m1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var jl=32,BV=function(t){function e(){return FQe(this,e),UQe(this,e,arguments)}return VQe(e,t),zQe(e,[{key:"renderIcon",value:function(n){var s=this.props.inactiveColor,i=jl/2,a=jl/6,l=jl/3,c=n.inactive?s:n.color;if(n.type==="plainline")return ve.createElement("line",{strokeWidth:4,fill:"none",stroke:c,strokeDasharray:n.payload.strokeDasharray,x1:0,y1:i,x2:jl,y2:i,className:"recharts-legend-icon"});if(n.type==="line")return ve.createElement("path",{strokeWidth:4,fill:"none",stroke:c,d:"M0,".concat(i,"h").concat(l,`
            A`).concat(a,",").concat(a,",0,1,1,").concat(2*l,",").concat(i,`
            H`).concat(jl,"M").concat(2*l,",").concat(i,`
            A`).concat(a,",").concat(a,",0,1,1,").concat(l,",").concat(i),className:"recharts-legend-icon"});if(n.type==="rect")return ve.createElement("path",{stroke:"none",fill:c,d:"M0,".concat(jl/8,"h").concat(jl,"v").concat(jl*3/4,"h").concat(-jl,"z"),className:"recharts-legend-icon"});if(ve.isValidElement(n.legendIcon)){var u=$Qe({},n);return delete u.legendIcon,ve.cloneElement(n.legendIcon,u)}return ve.createElement(FV,{fill:c,cx:i,cy:i,size:jl,sizeType:"diameter",type:n.type})}},{key:"renderItems",value:function(){var n=this,s=this.props,i=s.payload,a=s.iconSize,l=s.layout,c=s.formatter,u=s.inactiveColor,d={x:0,y:0,width:jl,height:jl},h={display:l==="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,y=$r(UN(UN({"recharts-legend-item":!0},"legend-item-".concat(m),!0),"inactive",p.inactive));if(p.type==="none")return null;var x=hr(p.value)?null:p.value;Yh(!hr(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 ve.createElement("li",nz({className:y,style:h,key:"legend-item-".concat(m)},GD(n.props,p,m)),ve.createElement(K8,{width:a,height:a,viewBox:d,style:f},n.renderIcon(p)),ve.createElement("span",{className:"recharts-legend-item-text",style:{color:v}},g?g(x,p,m):x))})}},{key:"render",value:function(){var n=this.props,s=n.payload,i=n.layout,a=n.align;if(!s||!s.length)return null;var l={padding:0,margin:0,textAlign:i==="horizontal"?a:"left"};return ve.createElement("ul",{className:"recharts-default-legend",style:l},this.renderItems())}}])}(S.PureComponent);UN(BV,"displayName","Legend");UN(BV,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var GQe=RD;function KQe(){this.__data__=new GQe,this.size=0}var YQe=KQe;function XQe(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var QQe=XQe;function ZQe(t){return this.__data__.get(t)}var JQe=ZQe;function eZe(t){return this.__data__.has(t)}var tZe=eZe,rZe=RD,nZe=CV,sZe=EV,iZe=200;function aZe(t,e){var r=this.__data__;if(r instanceof rZe){var n=r.__data__;if(!nZe||n.length<iZe-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new sZe(n)}return r.set(t,e),this.size=r.size,this}var oZe=aZe,lZe=RD,cZe=YQe,uZe=QQe,dZe=JQe,hZe=tZe,fZe=oZe;function _j(t){var e=this.__data__=new lZe(t);this.size=e.size}_j.prototype.clear=cZe;_j.prototype.delete=uZe;_j.prototype.get=dZe;_j.prototype.has=hZe;_j.prototype.set=fZe;var jbe=_j,pZe="__lodash_hash_undefined__";function mZe(t){return this.__data__.set(t,pZe),this}var gZe=mZe;function xZe(t){return this.__data__.has(t)}var yZe=xZe,vZe=EV,bZe=gZe,wZe=yZe;function rR(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new vZe;++e<r;)this.add(t[e])}rR.prototype.add=rR.prototype.push=bZe;rR.prototype.has=wZe;var Sbe=rR;function jZe(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 _be=jZe;function SZe(t,e){return t.has(e)}var Nbe=SZe,_Ze=Sbe,NZe=_be,kZe=Nbe,CZe=1,EZe=2;function AZe(t,e,r,n,s,i){var a=r&CZe,l=t.length,c=e.length;if(l!=c&&!(a&&c>l))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&EZe?new _Ze:void 0;for(i.set(t,e),i.set(e,t);++h<l;){var m=t[h],g=e[h];if(n)var y=a?n(g,m,h,e,t,i):n(m,g,h,t,e,i);if(y!==void 0){if(y)continue;f=!1;break}if(p){if(!NZe(e,function(x,v){if(!kZe(p,v)&&(m===x||s(m,x,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 kbe=AZe,TZe=jd,PZe=TZe.Uint8Array,IZe=PZe;function RZe(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}var OZe=RZe;function MZe(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var zV=MZe,kJ=XE,CJ=IZe,DZe=kV,LZe=kbe,$Ze=OZe,FZe=zV,BZe=1,zZe=2,UZe="[object Boolean]",HZe="[object Date]",WZe="[object Error]",VZe="[object Map]",qZe="[object Number]",GZe="[object RegExp]",KZe="[object Set]",YZe="[object String]",XZe="[object Symbol]",QZe="[object ArrayBuffer]",ZZe="[object DataView]",EJ=kJ?kJ.prototype:void 0,J4=EJ?EJ.valueOf:void 0;function JZe(t,e,r,n,s,i,a){switch(r){case ZZe:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case QZe:return!(t.byteLength!=e.byteLength||!i(new CJ(t),new CJ(e)));case UZe:case HZe:case qZe:return DZe(+t,+e);case WZe:return t.name==e.name&&t.message==e.message;case GZe:case YZe:return t==e+"";case VZe:var l=$Ze;case KZe:var c=n&BZe;if(l||(l=FZe),t.size!=e.size&&!c)return!1;var u=a.get(t);if(u)return u==e;n|=zZe,a.set(t,e);var d=LZe(l(t),l(e),n,s,i,a);return a.delete(t),d;case XZe:if(J4)return J4.call(t)==J4.call(e)}return!1}var eJe=JZe;function tJe(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}var Cbe=tJe,rJe=Cbe,nJe=To;function sJe(t,e,r){var n=e(t);return nJe(t)?n:rJe(n,r(t))}var iJe=sJe;function aJe(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 oJe=aJe;function lJe(){return[]}var cJe=lJe,uJe=oJe,dJe=cJe,hJe=Object.prototype,fJe=hJe.propertyIsEnumerable,AJ=Object.getOwnPropertySymbols,pJe=AJ?function(t){return t==null?[]:(t=Object(t),uJe(AJ(t),function(e){return fJe.call(t,e)}))}:dJe,mJe=pJe;function gJe(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}var xJe=gJe,yJe=Ef,vJe=Af,bJe="[object Arguments]";function wJe(t){return vJe(t)&&yJe(t)==bJe}var jJe=wJe,TJ=jJe,SJe=Af,Ebe=Object.prototype,_Je=Ebe.hasOwnProperty,NJe=Ebe.propertyIsEnumerable,kJe=TJ(function(){return arguments}())?TJ:function(t){return SJe(t)&&_Je.call(t,"callee")&&!NJe.call(t,"callee")},UV=kJe,nR={exports:{}};function CJe(){return!1}var EJe=CJe;nR.exports;(function(t,e){var r=jd,n=EJe,s=e&&!e.nodeType&&e,i=s&&!0&&t&&!t.nodeType&&t,a=i&&i.exports===s,l=a?r.Buffer:void 0,c=l?l.isBuffer:void 0,u=c||n;t.exports=u})(nR,nR.exports);var Abe=nR.exports,AJe=9007199254740991,TJe=/^(?:0|[1-9]\d*)$/;function PJe(t,e){var r=typeof t;return e=e??AJe,!!e&&(r=="number"||r!="symbol"&&TJe.test(t))&&t>-1&&t%1==0&&t<e}var HV=PJe,IJe=9007199254740991;function RJe(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=IJe}var WV=RJe,OJe=Ef,MJe=WV,DJe=Af,LJe="[object Arguments]",$Je="[object Array]",FJe="[object Boolean]",BJe="[object Date]",zJe="[object Error]",UJe="[object Function]",HJe="[object Map]",WJe="[object Number]",VJe="[object Object]",qJe="[object RegExp]",GJe="[object Set]",KJe="[object String]",YJe="[object WeakMap]",XJe="[object ArrayBuffer]",QJe="[object DataView]",ZJe="[object Float32Array]",JJe="[object Float64Array]",eet="[object Int8Array]",tet="[object Int16Array]",ret="[object Int32Array]",net="[object Uint8Array]",set="[object Uint8ClampedArray]",iet="[object Uint16Array]",aet="[object Uint32Array]",Mn={};Mn[ZJe]=Mn[JJe]=Mn[eet]=Mn[tet]=Mn[ret]=Mn[net]=Mn[set]=Mn[iet]=Mn[aet]=!0;Mn[LJe]=Mn[$Je]=Mn[XJe]=Mn[FJe]=Mn[QJe]=Mn[BJe]=Mn[zJe]=Mn[UJe]=Mn[HJe]=Mn[WJe]=Mn[VJe]=Mn[qJe]=Mn[GJe]=Mn[KJe]=Mn[YJe]=!1;function oet(t){return DJe(t)&&MJe(t.length)&&!!Mn[OJe(t)]}var cet=oet;function uet(t){return function(e){return t(e)}}var Tbe=uet,sR={exports:{}};sR.exports;(function(t,e){var r=$ve,n=e&&!e.nodeType&&e,s=n&&!0&&t&&!t.nodeType&&t,i=s&&s.exports===n,a=i&&r.process,l=function(){try{var c=s&&s.require&&s.require("util").types;return c||a&&a.binding&&a.binding("util")}catch{}}();t.exports=l})(sR,sR.exports);var det=sR.exports,het=cet,fet=Tbe,PJ=det,IJ=PJ&&PJ.isTypedArray,pet=IJ?fet(IJ):het,Pbe=pet,met=xJe,get=UV,xet=To,yet=Abe,vet=HV,bet=Pbe,wet=Object.prototype,jet=wet.hasOwnProperty;function _et(t,e){var r=xet(t),n=!r&&get(t),s=!r&&!n&&yet(t),i=!r&&!n&&!s&&bet(t),a=r||n||s||i,l=a?met(t.length,String):[],c=l.length;for(var u in t)(e||jet.call(t,u))&&!(a&&(u=="length"||s&&(u=="offset"||u=="parent")||i&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||vet(u,c)))&&l.push(u);return l}var Net=_et,ket=Object.prototype;function Cet(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||ket;return t===r}var Eet=Cet;function Aet(t,e){return function(r){return t(e(r))}}var Ibe=Aet,Tet=Ibe,Pet=Tet(Object.keys,Object),Iet=Pet,Ret=Eet,Oet=Iet,Met=Object.prototype,Det=Met.hasOwnProperty;function Let(t){if(!Ret(t))return Oet(t);var e=[];for(var r in Object(t))Det.call(t,r)&&r!="constructor"&&e.push(r);return e}var $et=Let,Fet=NV,Bet=WV;function zet(t){return t!=null&&Bet(t.length)&&!Fet(t)}var ZD=zet,Uet=Net,Het=$et,Wet=ZD;function Vet(t){return Wet(t)?Uet(t):Het(t)}var VV=Vet,qet=iJe,Get=mJe,Ket=VV;function Yet(t){return qet(t,Ket,Get)}var Xet=Yet,RJ=Xet,Qet=1,Zet=Object.prototype,Jet=Zet.hasOwnProperty;function ett(t,e,r,n,s,i){var a=r&Qet,l=RJ(t),c=l.length,u=RJ(e),d=u.length;if(c!=d&&!a)return!1;for(var h=c;h--;){var f=l[h];if(!(a?f in e:Jet.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 y=a;++h<c;){f=l[h];var x=t[f],v=e[f];if(n)var b=a?n(v,x,f,e,t,i):n(x,v,f,t,e,i);if(!(b===void 0?x===v||s(x,v,r,n,i):b)){g=!1;break}y||(y=f=="constructor")}if(g&&!y){var w=t.constructor,j=e.constructor;w!=j&&"constructor"in t&&"constructor"in e&&!(typeof w=="function"&&w instanceof w&&typeof j=="function"&&j instanceof j)&&(g=!1)}return i.delete(t),i.delete(e),g}var ttt=ett,rtt=Rv,ntt=jd,stt=rtt(ntt,"DataView"),itt=stt,att=Rv,ott=jd,ltt=att(ott,"Promise"),ctt=ltt,utt=Rv,dtt=jd,htt=utt(dtt,"Set"),Rbe=htt,ftt=Rv,ptt=jd,mtt=ftt(ptt,"WeakMap"),gtt=mtt,iz=itt,az=CV,oz=ctt,lz=Rbe,cz=gtt,Obe=Ef,Nj=Bve,OJ="[object Map]",xtt="[object Object]",MJ="[object Promise]",DJ="[object Set]",LJ="[object WeakMap]",$J="[object DataView]",ytt=Nj(iz),vtt=Nj(az),btt=Nj(oz),wtt=Nj(lz),jtt=Nj(cz),Hg=Obe;(iz&&Hg(new iz(new ArrayBuffer(1)))!=$J||az&&Hg(new az)!=OJ||oz&&Hg(oz.resolve())!=MJ||lz&&Hg(new lz)!=DJ||cz&&Hg(new cz)!=LJ)&&(Hg=function(t){var e=Obe(t),r=e==xtt?t.constructor:void 0,n=r?Nj(r):"";if(n)switch(n){case ytt:return $J;case vtt:return OJ;case btt:return MJ;case wtt:return DJ;case jtt:return LJ}return e});var Stt=Hg,e3=jbe,_tt=kbe,Ntt=eJe,ktt=ttt,FJ=Stt,BJ=To,zJ=Abe,Ctt=Pbe,Ett=1,UJ="[object Arguments]",HJ="[object Array]",hT="[object Object]",Att=Object.prototype,WJ=Att.hasOwnProperty;function Ttt(t,e,r,n,s,i){var a=BJ(t),l=BJ(e),c=a?HJ:FJ(t),u=l?HJ:FJ(e);c=c==UJ?hT:c,u=u==UJ?hT:u;var d=c==hT,h=u==hT,f=c==u;if(f&&zJ(t)){if(!zJ(e))return!1;a=!0,d=!1}if(f&&!d)return i||(i=new e3),a||Ctt(t)?_tt(t,e,r,n,s,i):Ntt(t,e,c,r,n,s,i);if(!(r&Ett)){var p=d&&WJ.call(t,"__wrapped__"),m=h&&WJ.call(e,"__wrapped__");if(p||m){var g=p?t.value():t,y=m?e.value():e;return i||(i=new e3),s(g,y,r,n,i)}}return f?(i||(i=new e3),ktt(t,e,r,n,s,i)):!1}var Ptt=Ttt,Itt=Ptt,VJ=Af;function Mbe(t,e,r,n,s){return t===e?!0:t==null||e==null||!VJ(t)&&!VJ(e)?t!==t&&e!==e:Itt(t,e,r,n,Mbe,s)}var qV=Mbe,Rtt=jbe,Ott=qV,Mtt=1,Dtt=2;function Ltt(t,e,r,n){var s=r.length,i=s,a=!n;if(t==null)return!i;for(t=Object(t);s--;){var l=r[s];if(a&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<i;){l=r[s];var c=l[0],u=t[c],d=l[1];if(a&&l[2]){if(u===void 0&&!(c in t))return!1}else{var h=new Rtt;if(n)var f=n(u,d,c,t,e,h);if(!(f===void 0?Ott(d,u,Mtt|Dtt,n,h):f))return!1}}return!0}var $tt=Ltt,Ftt=dg;function Btt(t){return t===t&&!Ftt(t)}var Dbe=Btt,ztt=Dbe,Utt=VV;function Htt(t){for(var e=Utt(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,ztt(s)]}return e}var Wtt=Htt;function Vtt(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}var Lbe=Vtt,qtt=$tt,Gtt=Wtt,Ktt=Lbe;function Ytt(t){var e=Gtt(t);return e.length==1&&e[0][2]?Ktt(e[0][0],e[0][1]):function(r){return r===t||qtt(r,t,e)}}var Xtt=Ytt;function Qtt(t,e){return t!=null&&e in Object(t)}var Ztt=Qtt,Jtt=Vve,ert=UV,trt=To,rrt=HV,nrt=WV,srt=MD;function irt(t,e,r){e=Jtt(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var a=srt(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&&nrt(s)&&rrt(a,s)&&(trt(t)||ert(t)))}var art=irt,ort=Ztt,lrt=art;function crt(t,e){return t!=null&&lrt(t,e,ort)}var urt=crt,drt=qV,hrt=qve,frt=urt,prt=_V,mrt=Dbe,grt=Lbe,xrt=MD,yrt=1,vrt=2;function brt(t,e){return prt(t)&&mrt(e)?grt(xrt(t),e):function(r){var n=hrt(r,t);return n===void 0&&n===e?frt(r,t):drt(e,n,yrt|vrt)}}var wrt=brt;function jrt(t){return t}var kj=jrt;function Srt(t){return function(e){return e==null?void 0:e[t]}}var _rt=Srt,Nrt=PV;function krt(t){return function(e){return Nrt(e,t)}}var Crt=krt,Ert=_rt,Art=Crt,Trt=_V,Prt=MD;function Irt(t){return Trt(t)?Ert(Prt(t)):Art(t)}var Rrt=Irt,Ort=Xtt,Mrt=wrt,Drt=kj,Lrt=To,$rt=Rrt;function Frt(t){return typeof t=="function"?t:t==null?Drt:typeof t=="object"?Lrt(t)?Mrt(t[0],t[1]):Ort(t):$rt(t)}var hg=Frt;function Brt(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 zrt=Brt;function Urt(t){return t!==t}var Hrt=Urt;function Wrt(t,e,r){for(var n=r-1,s=t.length;++n<s;)if(t[n]===e)return n;return-1}var Vrt=Wrt,qrt=zrt,Grt=Hrt,Krt=Vrt;function Yrt(t,e,r){return e===e?Krt(t,e,r):qrt(t,Grt,r)}var Xrt=Yrt,Qrt=Xrt;function Zrt(t,e){var r=t==null?0:t.length;return!!r&&Qrt(t,e,0)>-1}var Jrt=Zrt;function ent(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 tnt=ent;function rnt(){}var nnt=rnt,t3=Rbe,snt=nnt,int=zV,ant=1/0,ont=t3&&1/int(new t3([,-0]))[1]==ant?function(t){return new t3(t)}:snt,lnt=ont,cnt=Sbe,unt=Jrt,dnt=tnt,hnt=Nbe,fnt=lnt,pnt=zV,mnt=200;function gnt(t,e,r){var n=-1,s=unt,i=t.length,a=!0,l=[],c=l;if(r)a=!1,s=dnt;else if(i>=mnt){var u=e?null:fnt(t);if(u)return pnt(u);a=!1,s=hnt,c=new cnt}else c=e?[]:l;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),l.push(d)}else s(c,h,r)||(c!==l&&c.push(h),l.push(d))}return l}var xnt=gnt,ynt=hg,vnt=xnt;function bnt(t,e){return t&&t.length?vnt(t,ynt(e)):[]}var wnt=bnt;const qJ=Er(wnt);function $be(t,e,r){return e===!0?qJ(t,r):hr(e)?qJ(t,e):t}function g1(t){"@babel/helpers - typeof";return g1=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},g1(t)}var jnt=["ref"];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 Rd(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){JD(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 Snt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function KJ(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,Bbe(n.key),n)}}function _nt(t,e,r){return e&&KJ(t.prototype,e),r&&KJ(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Nnt(t,e,r){return e=iR(e),knt(t,Fbe()?Reflect.construct(e,r||[],iR(t).constructor):e.apply(t,r))}function knt(t,e){if(e&&(g1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Cnt(t)}function Cnt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Fbe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Fbe=function(){return!!t})()}function iR(t){return iR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},iR(t)}function Ent(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&&uz(t,e)}function uz(t,e){return uz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},uz(t,e)}function JD(t,e,r){return e=Bbe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Bbe(t){var e=Ant(t,"string");return g1(e)=="symbol"?e:e+""}function Ant(t,e){if(g1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(g1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Tnt(t,e){if(t==null)return{};var r=Pnt(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 Pnt(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 Int(t){return t.value}function Rnt(t,e){if(ve.isValidElement(t))return ve.cloneElement(t,e);if(typeof t=="function")return ve.createElement(t,e);e.ref;var r=Tnt(e,jnt);return ve.createElement(BV,r)}var YJ=1,b0=function(t){function e(){var r;Snt(this,e);for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];return r=Nnt(this,e,[].concat(s)),JD(r,"lastBoundingBox",{width:-1,height:-1}),r}return Ent(e,t),_nt(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)>YJ||Math.abs(s.height-this.lastBoundingBox.height)>YJ)&&(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?Rd({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(n){var s=this.props,i=s.layout,a=s.align,l=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(l==="middle"){var m=this.getBBoxSnapshot();f={top:((d||0)-m.height)/2}}else f=l==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return Rd(Rd({},h),f)}},{key:"render",value:function(){var n=this,s=this.props,i=s.content,a=s.width,l=s.height,c=s.wrapperStyle,u=s.payloadUniqBy,d=s.payload,h=Rd(Rd({position:"absolute",width:a||"auto",height:l||"auto"},this.getDefaultPosition(c)),c);return ve.createElement("div",{className:"recharts-legend-wrapper",style:h,ref:function(p){n.wrapperNode=p}},Rnt(i,Rd(Rd({},this.props),{},{payload:$be(d,u,Int)})))}}],[{key:"getWithHeight",value:function(n,s){var i=Rd(Rd({},this.defaultProps),n.props),a=i.layout;return a==="vertical"&&gt(n.props.height)?{height:n.props.height}:a==="horizontal"?{width:n.props.width||s}:null}}])}(S.PureComponent);JD(b0,"displayName","Legend");JD(b0,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var XJ=XE,Ont=UV,Mnt=To,QJ=XJ?XJ.isConcatSpreadable:void 0;function Dnt(t){return Mnt(t)||Ont(t)||!!(QJ&&t&&t[QJ])}var Lnt=Dnt,$nt=Cbe,Fnt=Lnt;function zbe(t,e,r,n,s){var i=-1,a=t.length;for(r||(r=Fnt),s||(s=[]);++i<a;){var l=t[i];e>0&&r(l)?e>1?zbe(l,e-1,r,n,s):$nt(s,l):n||(s[s.length]=l)}return s}var Ube=zbe;function Bnt(t){return function(e,r,n){for(var s=-1,i=Object(e),a=n(e),l=a.length;l--;){var c=a[t?l:++s];if(r(i[c],c,i)===!1)break}return e}}var znt=Bnt,Unt=znt,Hnt=Unt(),Wnt=Hnt,Vnt=Wnt,qnt=VV;function Gnt(t,e){return t&&Vnt(t,e,qnt)}var Hbe=Gnt,Knt=ZD;function Ynt(t,e){return function(r,n){if(r==null)return r;if(!Knt(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 Xnt=Ynt,Qnt=Hbe,Znt=Xnt,Jnt=Znt(Qnt),GV=Jnt,est=GV,tst=ZD;function rst(t,e){var r=-1,n=tst(t)?Array(t.length):[];return est(t,function(s,i,a){n[++r]=e(s,i,a)}),n}var Wbe=rst;function nst(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}var sst=nst,ZJ=vj;function ist(t,e){if(t!==e){var r=t!==void 0,n=t===null,s=t===t,i=ZJ(t),a=e!==void 0,l=e===null,c=e===e,u=ZJ(e);if(!l&&!u&&!i&&t>e||i&&a&&c&&!l&&!u||n&&a&&c||!r&&c||!s)return 1;if(!n&&!i&&!u&&t<e||u&&r&&s&&!n&&!i||l&&r&&s||!a&&s||!c)return-1}return 0}var ast=ist,ost=ast;function lst(t,e,r){for(var n=-1,s=t.criteria,i=e.criteria,a=s.length,l=r.length;++n<a;){var c=ost(s[n],i[n]);if(c){if(n>=l)return c;var u=r[n];return c*(u=="desc"?-1:1)}}return t.index-e.index}var cst=lst,r3=TV,ust=PV,dst=hg,hst=Wbe,fst=sst,pst=Tbe,mst=cst,gst=kj,xst=To;function yst(t,e,r){e.length?e=r3(e,function(i){return xst(i)?function(a){return ust(a,i.length===1?i[0]:i)}:i}):e=[gst];var n=-1;e=r3(e,pst(dst));var s=hst(t,function(i,a,l){var c=r3(e,function(u){return u(i)});return{criteria:c,index:++n,value:i}});return fst(s,function(i,a){return mst(i,a,r)})}var vst=yst;function bst(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 wst=bst,jst=wst,JJ=Math.max;function Sst(t,e,r){return e=JJ(e===void 0?t.length-1:e,0),function(){for(var n=arguments,s=-1,i=JJ(n.length-e,0),a=Array(i);++s<i;)a[s]=n[e+s];s=-1;for(var l=Array(e+1);++s<e;)l[s]=n[s];return l[e]=r(a),jst(t,this,l)}}var _st=Sst;function Nst(t){return function(){return t}}var kst=Nst,Cst=Rv,Est=function(){try{var t=Cst(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Vbe=Est,Ast=kst,eee=Vbe,Tst=kj,Pst=eee?function(t,e){return eee(t,"toString",{configurable:!0,enumerable:!1,value:Ast(e),writable:!0})}:Tst,Ist=Pst,Rst=800,Ost=16,Mst=Date.now;function Dst(t){var e=0,r=0;return function(){var n=Mst(),s=Ost-(n-r);if(r=n,s>0){if(++e>=Rst)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Lst=Dst,$st=Ist,Fst=Lst,Bst=Fst($st),zst=Bst,Ust=kj,Hst=_st,Wst=zst;function Vst(t,e){return Wst(Hst(t,e,Ust),t+"")}var qst=Vst,Gst=kV,Kst=ZD,Yst=HV,Xst=dg;function Qst(t,e,r){if(!Xst(r))return!1;var n=typeof e;return(n=="number"?Kst(r)&&Yst(e,r.length):n=="string"&&e in r)?Gst(r[e],t):!1}var eL=Qst,Zst=Ube,Jst=vst,eit=qst,tee=eL,tit=eit(function(t,e){if(t==null)return[];var r=e.length;return r>1&&tee(t,e[0],e[1])?e=[]:r>2&&tee(e[0],e[1],e[2])&&(e=[e[0]]),Jst(t,Zst(e,1),[])}),rit=tit;const KV=Er(rit);function HN(t){"@babel/helpers - typeof";return HN=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},HN(t)}function dz(){return dz=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},dz.apply(this,arguments)}function nit(t,e){return oit(t)||ait(t,e)||iit(t,e)||sit()}function sit(){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 iit(t,e){if(t){if(typeof t=="string")return ree(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 ree(t,e)}}function ree(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 ait(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function oit(t){if(Array.isArray(t))return t}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 n3(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){lit(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 lit(t,e,r){return e=cit(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cit(t){var e=uit(t,"string");return HN(e)=="symbol"?e:e+""}function uit(t,e){if(HN(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(HN(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dit(t){return Array.isArray(t)&&ni(t[0])&&ni(t[1])?t.join(" ~ "):t}var hit=function(e){var r=e.separator,n=r===void 0?" : ":r,s=e.contentStyle,i=s===void 0?{}:s,a=e.itemStyle,l=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,y=e.labelFormatter,x=e.accessibilityLayer,v=x===void 0?!1:x,b=function(){if(d&&d.length){var T={padding:0,margin:0},M=(f?KV(d,f):d).map(function(k,D){if(k.type==="none")return null;var K=n3({display:"block",paddingTop:4,paddingBottom:4,color:k.color||"#000"},l),H=k.formatter||h||dit,ee=k.value,V=k.name,B=ee,z=V;if(H&&B!=null&&z!=null){var F=H(ee,V,k,D,d);if(Array.isArray(F)){var G=nit(F,2);B=G[0],z=G[1]}else B=F}return ve.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(D),style:K},ni(z)?ve.createElement("span",{className:"recharts-tooltip-item-name"},z):null,ni(z)?ve.createElement("span",{className:"recharts-tooltip-item-separator"},n):null,ve.createElement("span",{className:"recharts-tooltip-item-value"},B),ve.createElement("span",{className:"recharts-tooltip-item-unit"},k.unit||""))});return ve.createElement("ul",{className:"recharts-tooltip-item-list",style:T},M)}return null},w=n3({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},i),j=n3({margin:0},u),N=!Rr(g),C=N?g:"",A=$r("recharts-default-tooltip",p),E=$r("recharts-tooltip-label",m);N&&y&&d!==void 0&&d!==null&&(C=y(g,d));var O=v?{role:"status","aria-live":"assertive"}:{};return ve.createElement("div",dz({className:A,style:w},O),ve.createElement("p",{className:E,style:j},ve.isValidElement(C)?C:"".concat(C)),b())};function WN(t){"@babel/helpers - typeof";return WN=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},WN(t)}function fT(t,e,r){return e=fit(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function fit(t){var e=pit(t,"string");return WN(e)=="symbol"?e:e+""}function pit(t,e){if(WN(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(WN(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var tS="recharts-tooltip-wrapper",mit={visibility:"hidden"};function git(t){var e=t.coordinate,r=t.translateX,n=t.translateY;return $r(tS,fT(fT(fT(fT({},"".concat(tS,"-right"),gt(r)&&e&&gt(e.x)&&r>=e.x),"".concat(tS,"-left"),gt(r)&&e&&gt(e.x)&&r<e.x),"".concat(tS,"-bottom"),gt(n)&&e&&gt(e.y)&&n>=e.y),"".concat(tS,"-top"),gt(n)&&e&&gt(e.y)&&n<e.y))}function see(t){var e=t.allowEscapeViewBox,r=t.coordinate,n=t.key,s=t.offsetTopLeft,i=t.position,a=t.reverseDirection,l=t.tooltipDimension,c=t.viewBox,u=t.viewBoxDimension;if(i&&gt(i[n]))return i[n];var d=r[n]-l-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+l,g=c[n]+u;return m>g?Math.max(d,c[n]):Math.max(h,c[n])}function xit(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 yit(t){var e=t.allowEscapeViewBox,r=t.coordinate,n=t.offsetTopLeft,s=t.position,i=t.reverseDirection,a=t.tooltipBox,l=t.useTranslate3d,c=t.viewBox,u,d,h;return a.height>0&&a.width>0&&r?(d=see({allowEscapeViewBox:e,coordinate:r,key:"x",offsetTopLeft:n,position:s,reverseDirection:i,tooltipDimension:a.width,viewBox:c,viewBoxDimension:c.width}),h=see({allowEscapeViewBox:e,coordinate:r,key:"y",offsetTopLeft:n,position:s,reverseDirection:i,tooltipDimension:a.height,viewBox:c,viewBoxDimension:c.height}),u=xit({translateX:d,translateY:h,useTranslate3d:l})):u=mit,{cssProperties:u,cssClasses:git({translateX:d,translateY:h,coordinate:r})}}function x1(t){"@babel/helpers - typeof";return x1=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},x1(t)}function iee(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 aee(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?iee(Object(r),!0).forEach(function(n){fz(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):iee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function vit(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function bit(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,Gbe(n.key),n)}}function wit(t,e,r){return e&&bit(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function jit(t,e,r){return e=aR(e),Sit(t,qbe()?Reflect.construct(e,r||[],aR(t).constructor):e.apply(t,r))}function Sit(t,e){if(e&&(x1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _it(t)}function _it(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function qbe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(qbe=function(){return!!t})()}function aR(t){return aR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},aR(t)}function Nit(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&&hz(t,e)}function hz(t,e){return hz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},hz(t,e)}function fz(t,e,r){return e=Gbe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Gbe(t){var e=kit(t,"string");return x1(e)=="symbol"?e:e+""}function kit(t,e){if(x1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(x1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var oee=1,Cit=function(t){function e(){var r;vit(this,e);for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];return r=jit(this,e,[].concat(s)),fz(r,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0},lastBoundingBox:{width:-1,height:-1}}),fz(r,"handleKeyDown",function(a){if(a.key==="Escape"){var l,c,u,d;r.setState({dismissed:!0,dismissedAtCoordinate:{x:(l=(c=r.props.coordinate)===null||c===void 0?void 0:c.x)!==null&&l!==void 0?l:0,y:(u=(d=r.props.coordinate)===null||d===void 0?void 0:d.y)!==null&&u!==void 0?u:0}})}}),r}return Nit(e,t),wit(e,[{key:"updateBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var n=this.wrapperNode.getBoundingClientRect();(Math.abs(n.width-this.state.lastBoundingBox.width)>oee||Math.abs(n.height-this.state.lastBoundingBox.height)>oee)&&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,l=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,y=s.useTranslate3d,x=s.viewBox,v=s.wrapperStyle,b=yit({allowEscapeViewBox:a,coordinate:d,offsetTopLeft:p,position:m,reverseDirection:g,tooltipBox:this.state.lastBoundingBox,useTranslate3d:y,viewBox:x}),w=b.cssClasses,j=b.cssProperties,N=aee(aee({transition:f&&i?"transform ".concat(l,"ms ").concat(c):void 0},j),{},{pointerEvents:"none",visibility:!this.state.dismissed&&i&&h?"visible":"hidden",position:"absolute",top:0,left:0},v);return ve.createElement("div",{tabIndex:-1,className:w,style:N,ref:function(A){n.wrapperNode=A}},u)}}])}(S.PureComponent),Eit=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},zy={isSsr:Eit(),get:function(e){return zy[e]},set:function(e,r){if(typeof e=="string")zy[e]=r;else{var n=Object.keys(e);n&&n.length&&n.forEach(function(s){zy[s]=e[s]})}}};function y1(t){"@babel/helpers - typeof";return y1=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},y1(t)}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 cee(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){YV(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 Ait(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Tit(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,Ybe(n.key),n)}}function Pit(t,e,r){return e&&Tit(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Iit(t,e,r){return e=oR(e),Rit(t,Kbe()?Reflect.construct(e,r||[],oR(t).constructor):e.apply(t,r))}function Rit(t,e){if(e&&(y1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Oit(t)}function Oit(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Kbe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Kbe=function(){return!!t})()}function oR(t){return oR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},oR(t)}function Mit(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&&pz(t,e)}function pz(t,e){return pz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},pz(t,e)}function YV(t,e,r){return e=Ybe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ybe(t){var e=Dit(t,"string");return y1(e)=="symbol"?e:e+""}function Dit(t,e){if(y1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(y1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Lit(t){return t.dataKey}function $it(t,e){return ve.isValidElement(t)?ve.cloneElement(t,e):typeof t=="function"?ve.createElement(t,e):ve.createElement(hit,e)}var Kd=function(t){function e(){return Ait(this,e),Iit(this,e,arguments)}return Mit(e,t),Pit(e,[{key:"render",value:function(){var n=this,s=this.props,i=s.active,a=s.allowEscapeViewBox,l=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,y=s.position,x=s.reverseDirection,v=s.useTranslate3d,b=s.viewBox,w=s.wrapperStyle,j=m??[];h&&j.length&&(j=$be(m.filter(function(C){return C.value!=null&&(C.hide!==!0||n.props.includeHidden)}),g,Lit));var N=j.length>0;return ve.createElement(Cit,{allowEscapeViewBox:a,animationDuration:l,animationEasing:c,isAnimationActive:f,active:i,coordinate:d,hasPayload:N,offset:p,position:y,reverseDirection:x,useTranslate3d:v,viewBox:b,wrapperStyle:w},$it(u,cee(cee({},this.props),{},{payload:j})))}}])}(S.PureComponent);YV(Kd,"displayName","Tooltip");YV(Kd,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!zy.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 Fit=jd,Bit=function(){return Fit.Date.now()},zit=Bit,Uit=/\s/;function Hit(t){for(var e=t.length;e--&&Uit.test(t.charAt(e)););return e}var Wit=Hit,Vit=Wit,qit=/^\s+/;function Git(t){return t&&t.slice(0,Vit(t)+1).replace(qit,"")}var Kit=Git,Yit=Kit,uee=dg,Xit=vj,dee=NaN,Qit=/^[-+]0x[0-9a-f]+$/i,Zit=/^0b[01]+$/i,Jit=/^0o[0-7]+$/i,eat=parseInt;function tat(t){if(typeof t=="number")return t;if(Xit(t))return dee;if(uee(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=uee(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=Yit(t);var r=Zit.test(t);return r||Jit.test(t)?eat(t.slice(2),r?2:8):Qit.test(t)?dee:+t}var Xbe=tat,rat=dg,s3=zit,hee=Xbe,nat="Expected a function",sat=Math.max,iat=Math.min;function aat(t,e,r){var n,s,i,a,l,c,u=0,d=!1,h=!1,f=!0;if(typeof t!="function")throw new TypeError(nat);e=hee(e)||0,rat(r)&&(d=!!r.leading,h="maxWait"in r,i=h?sat(hee(r.maxWait)||0,e):i,f="trailing"in r?!!r.trailing:f);function p(N){var C=n,A=s;return n=s=void 0,u=N,a=t.apply(A,C),a}function m(N){return u=N,l=setTimeout(x,e),d?p(N):a}function g(N){var C=N-c,A=N-u,E=e-C;return h?iat(E,i-A):E}function y(N){var C=N-c,A=N-u;return c===void 0||C>=e||C<0||h&&A>=i}function x(){var N=s3();if(y(N))return v(N);l=setTimeout(x,g(N))}function v(N){return l=void 0,f&&n?p(N):(n=s=void 0,a)}function b(){l!==void 0&&clearTimeout(l),u=0,n=c=s=l=void 0}function w(){return l===void 0?a:v(s3())}function j(){var N=s3(),C=y(N);if(n=arguments,s=this,c=N,C){if(l===void 0)return m(c);if(h)return clearTimeout(l),l=setTimeout(x,e),p(c)}return l===void 0&&(l=setTimeout(x,e)),a}return j.cancel=b,j.flush=w,j}var oat=aat,lat=oat,cat=dg,uat="Expected a function";function dat(t,e,r){var n=!0,s=!0;if(typeof t!="function")throw new TypeError(uat);return cat(r)&&(n="leading"in r?!!r.leading:n,s="trailing"in r?!!r.trailing:s),lat(t,e,{leading:n,maxWait:e,trailing:s})}var hat=dat;const Qbe=Er(hat);function VN(t){"@babel/helpers - typeof";return VN=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},VN(t)}function fee(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 pT(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?fee(Object(r),!0).forEach(function(n){fat(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):fee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function fat(t,e,r){return e=pat(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pat(t){var e=mat(t,"string");return VN(e)=="symbol"?e:e+""}function mat(t,e){if(VN(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(VN(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function gat(t,e){return bat(t)||vat(t,e)||yat(t,e)||xat()}function xat(){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 yat(t,e){if(t){if(typeof t=="string")return pee(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 pee(t,e)}}function pee(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 vat(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function bat(t){if(Array.isArray(t))return t}var wat=S.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,l=t.height,c=l===void 0?"100%":l,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,y=t.id,x=t.className,v=t.onResize,b=t.style,w=b===void 0?{}:b,j=S.useRef(null),N=S.useRef();N.current=v,S.useImperativeHandle(e,function(){return Object.defineProperty(j.current,"current",{get:function(){return console.warn("The usage of ref.current.current is deprecated and will no longer be supported."),j.current},configurable:!0})});var C=S.useState({containerWidth:s.width,containerHeight:s.height}),A=gat(C,2),E=A[0],O=A[1],$=S.useCallback(function(M,k){O(function(D){var K=Math.round(M),H=Math.round(k);return D.containerWidth===K&&D.containerHeight===H?D:{containerWidth:K,containerHeight:H}})},[]);S.useEffect(function(){var M=function(V){var B,z=V[0].contentRect,F=z.width,G=z.height;$(F,G),(B=N.current)===null||B===void 0||B.call(N,F,G)};g>0&&(M=Qbe(M,g,{trailing:!0,leading:!1}));var k=new ResizeObserver(M),D=j.current.getBoundingClientRect(),K=D.width,H=D.height;return $(K,H),k.observe(j.current),function(){k.disconnect()}},[$,g]);var T=S.useMemo(function(){var M=E.containerWidth,k=E.containerHeight;if(M<0||k<0)return null;Yh(lx(a)||lx(c),`The width(%s) and height(%s) are both fixed numbers,
       maybe you don't need to use a ResponsiveContainer.`,a,c),Yh(!r||r>0,"The aspect(%s) must be greater than zero.",r);var D=lx(a)?M:a,K=lx(c)?k:c;r&&r>0&&(D?K=D/r:K&&(D=K*r),f&&K>f&&(K=f)),Yh(D>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.`,D,K,a,c,d,h,r);var H=!Array.isArray(p)&&Kh(p.type).endsWith("Chart");return ve.Children.map(p,function(ee){return ve.isValidElement(ee)?S.cloneElement(ee,pT({width:D,height:K},H?{style:pT({height:"100%",width:"100%",maxHeight:K,maxWidth:D},ee.props.style)}:{})):ee})},[r,p,c,f,h,d,E,a]);return ve.createElement("div",{id:y?"".concat(y):void 0,className:$r("recharts-responsive-container",x),style:pT(pT({},w),{},{width:a,height:c,minWidth:d,minHeight:h,maxHeight:f}),ref:j},T)}),lR=function(e){return null};lR.displayName="Cell";function qN(t){"@babel/helpers - typeof";return qN=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},qN(t)}function mee(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 mz(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?mee(Object(r),!0).forEach(function(n){jat(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):mee(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function jat(t,e,r){return e=Sat(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sat(t){var e=_at(t,"string");return qN(e)=="symbol"?e:e+""}function _at(t,e){if(qN(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(qN(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var nb={widthCache:{},cacheCount:0},Nat=2e3,kat={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},gee="recharts_measurement_span";function Cat(t){var e=mz({},t);return Object.keys(e).forEach(function(r){e[r]||delete e[r]}),e}var xee=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||zy.isSsr)return{width:0,height:0};var n=Cat(r),s=JSON.stringify({text:e,copyStyle:n});if(nb.widthCache[s])return nb.widthCache[s];try{var i=document.getElementById(gee);i||(i=document.createElement("span"),i.setAttribute("id",gee),i.setAttribute("aria-hidden","true"),document.body.appendChild(i));var a=mz(mz({},kat),n);Object.assign(i.style,a),i.textContent="".concat(e);var l=i.getBoundingClientRect(),c={width:l.width,height:l.height};return nb.widthCache[s]=c,++nb.cacheCount>Nat&&(nb.cacheCount=0,nb.widthCache={}),c}catch{return{width:0,height:0}}},Eat=function(e){return{top:e.top+window.scrollY-document.documentElement.clientTop,left:e.left+window.scrollX-document.documentElement.clientLeft}};function GN(t){"@babel/helpers - typeof";return GN=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},GN(t)}function cR(t,e){return Iat(t)||Pat(t,e)||Tat(t,e)||Aat()}function Aat(){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 Tat(t,e){if(t){if(typeof t=="string")return yee(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 yee(t,e)}}function yee(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 Pat(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],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)&&(l.push(n.value),l.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 l}}function Iat(t){if(Array.isArray(t))return t}function Rat(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function vee(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,Mat(n.key),n)}}function Oat(t,e,r){return e&&vee(t.prototype,e),r&&vee(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Mat(t){var e=Dat(t,"string");return GN(e)=="symbol"?e:e+""}function Dat(t,e){if(GN(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(GN(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var bee=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,wee=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Lat=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,$at=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,Zbe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},Fat=Object.keys(Zbe),Kb="NaN";function Bat(t,e){return t*Zbe[e]}var mT=function(){function t(e,r){Rat(this,t),this.num=e,this.unit=r,this.num=e,this.unit=r,Number.isNaN(e)&&(this.unit=""),r!==""&&!Lat.test(r)&&(this.num=NaN,this.unit=""),Fat.includes(r)&&(this.num=Bat(e,r),this.unit="px")}return Oat(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=$at.exec(r))!==null&&n!==void 0?n:[],i=cR(s,3),a=i[1],l=i[2];return new t(parseFloat(a),l??"")}}])}();function Jbe(t){if(t.includes(Kb))return Kb;for(var e=t;e.includes("*")||e.includes("/");){var r,n=(r=bee.exec(e))!==null&&r!==void 0?r:[],s=cR(n,4),i=s[1],a=s[2],l=s[3],c=mT.parse(i??""),u=mT.parse(l??""),d=a==="*"?c.multiply(u):c.divide(u);if(d.isNaN())return Kb;e=e.replace(bee,d.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var h,f=(h=wee.exec(e))!==null&&h!==void 0?h:[],p=cR(f,4),m=p[1],g=p[2],y=p[3],x=mT.parse(m??""),v=mT.parse(y??""),b=g==="+"?x.add(v):x.subtract(v);if(b.isNaN())return Kb;e=e.replace(wee,b.toString())}return e}var jee=/\(([^()]*)\)/;function zat(t){for(var e=t;e.includes("(");){var r=jee.exec(e),n=cR(r,2),s=n[1];e=e.replace(jee,Jbe(s))}return e}function Uat(t){var e=t.replace(/\s+/g,"");return e=zat(e),e=Jbe(e),e}function Hat(t){try{return Uat(t)}catch{return Kb}}function i3(t){var e=Hat(t.slice(5,-1));return e===Kb?"":e}var Wat=["x","y","lineHeight","capHeight","scaleToFit","textAnchor","verticalAnchor","fill"],Vat=["dx","dy","angle","className","breakAll"];function gz(){return gz=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},gz.apply(this,arguments)}function See(t,e){if(t==null)return{};var r=qat(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 qat(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 _ee(t,e){return Xat(t)||Yat(t,e)||Kat(t,e)||Gat()}function Gat(){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 Kat(t,e){if(t){if(typeof t=="string")return Nee(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 Nee(t,e)}}function Nee(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 Yat(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],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)&&(l.push(n.value),l.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 l}}function Xat(t){if(Array.isArray(t))return t}var e0e=/[ \f\n\r\t\v\u2028\u2029]+/,t0e=function(e){var r=e.children,n=e.breakAll,s=e.style;try{var i=[];Rr(r)||(n?i=r.toString().split(""):i=r.toString().split(e0e));var a=i.map(function(c){return{word:c,width:xee(c,s).width}}),l=n?0:xee(" ",s).width;return{wordsWithComputedWidth:a,spaceWidth:l}}catch{return null}},Qat=function(e,r,n,s,i){var a=e.maxLines,l=e.children,c=e.style,u=e.breakAll,d=gt(a),h=l,f=function(){var D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return D.reduce(function(K,H){var ee=H.word,V=H.width,B=K[K.length-1];if(B&&(s==null||i||B.width+V+n<Number(s)))B.words.push(ee),B.width+=V+n;else{var z={words:[ee],width:V};K.push(z)}return K},[])},p=f(r),m=function(D){return D.reduce(function(K,H){return K.width>H.width?K:H})};if(!d)return p;for(var g="…",y=function(D){var K=h.slice(0,D),H=t0e({breakAll:u,style:c,children:K+g}).wordsWithComputedWidth,ee=f(H),V=ee.length>a||m(ee).width>Number(s);return[V,ee]},x=0,v=h.length-1,b=0,w;x<=v&&b<=h.length-1;){var j=Math.floor((x+v)/2),N=j-1,C=y(N),A=_ee(C,2),E=A[0],O=A[1],$=y(j),T=_ee($,1),M=T[0];if(!E&&!M&&(x=j+1),E&&M&&(v=j-1),!E&&M){w=O;break}b++}return w||p},kee=function(e){var r=Rr(e)?[]:e.toString().split(e0e);return[{words:r}]},Zat=function(e){var r=e.width,n=e.scaleToFit,s=e.children,i=e.style,a=e.breakAll,l=e.maxLines;if((r||n)&&!zy.isSsr){var c,u,d=t0e({breakAll:a,children:s,style:i});if(d){var h=d.wordsWithComputedWidth,f=d.spaceWidth;c=h,u=f}else return kee(s);return Qat({breakAll:a,children:s,maxLines:l,style:i},c,u,r,n)}return kee(s)},Cee="#808080",v1=function(e){var r=e.x,n=r===void 0?0:r,s=e.y,i=s===void 0?0:s,a=e.lineHeight,l=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,y=e.fill,x=y===void 0?Cee:y,v=See(e,Wat),b=S.useMemo(function(){return Zat({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,j=v.dy,N=v.angle,C=v.className,A=v.breakAll,E=See(v,Vat);if(!ni(n)||!ni(i))return null;var O=n+(gt(w)?w:0),$=i+(gt(j)?j:0),T;switch(g){case"start":T=i3("calc(".concat(u,")"));break;case"middle":T=i3("calc(".concat((b.length-1)/2," * -").concat(l," + (").concat(u," / 2))"));break;default:T=i3("calc(".concat(b.length-1," * -").concat(l,")"));break}var M=[];if(h){var k=b[0].width,D=v.width;M.push("scale(".concat((gt(D)?D/k:1)/k,")"))}return N&&M.push("rotate(".concat(N,", ").concat(O,", ").concat($,")")),M.length&&(E.transform=M.join(" ")),ve.createElement("text",gz({},cr(E,!0),{x:O,y:$,className:$r("recharts-text",C),textAnchor:p,fill:x.includes("url")?Cee:x}),b.map(function(K,H){var ee=K.words.join(A?"":" ");return ve.createElement("tspan",{x:O,dy:H===0?T:l,key:"".concat(ee,"-").concat(H)},ee)}))};function Tm(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Jat(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function XV(t){let e,r,n;t.length!==2?(e=Tm,r=(l,c)=>Tm(t(l),c),n=(l,c)=>t(l)-c):(e=t===Tm||t===Jat?t:eot,r=t,n=t);function s(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const h=u+d>>>1;r(l[h],c)<0?u=h+1:d=h}while(u<d)}return u}function i(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const h=u+d>>>1;r(l[h],c)<=0?u=h+1:d=h}while(u<d)}return u}function a(l,c,u=0,d=l.length){const h=s(l,c,u,d-1);return h>u&&n(l[h-1],c)>-n(l[h],c)?h-1:h}return{left:s,center:a,right:i}}function eot(){return 0}function r0e(t){return t===null?NaN:+t}function*tot(t,e){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const rot=XV(Tm),JE=rot.right;XV(r0e).center;class Eee extends Map{constructor(e,r=iot){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(Aee(this,e))}has(e){return super.has(Aee(this,e))}set(e,r){return super.set(not(this,e),r)}delete(e){return super.delete(sot(this,e))}}function Aee({_intern:t,_key:e},r){const n=e(r);return t.has(n)?t.get(n):r}function not({_intern:t,_key:e},r){const n=e(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function sot({_intern:t,_key:e},r){const n=e(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function iot(t){return t!==null&&typeof t=="object"?t.valueOf():t}function aot(t=Tm){if(t===Tm)return n0e;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 n0e(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const oot=Math.sqrt(50),lot=Math.sqrt(10),cot=Math.sqrt(2);function uR(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>=oot?10:i>=lot?5:i>=cot?2:1;let l,c,u;return s<0?(u=Math.pow(10,-s)/a,l=Math.round(t*u),c=Math.round(e*u),l/u<t&&++l,c/u>e&&--c,u=-u):(u=Math.pow(10,s)*a,l=Math.round(t/u),c=Math.round(e/u),l*u<t&&++l,c*u>e&&--c),c<l&&.5<=r&&r<2?uR(t,e,r*2):[l,c,u]}function xz(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?uR(e,t,r):uR(t,e,r);if(!(i>=s))return[];const l=i-s+1,c=new Array(l);if(n)if(a<0)for(let u=0;u<l;++u)c[u]=(i-u)/-a;else for(let u=0;u<l;++u)c[u]=(i-u)*a;else if(a<0)for(let u=0;u<l;++u)c[u]=(s+u)/-a;else for(let u=0;u<l;++u)c[u]=(s+u)*a;return c}function yz(t,e,r){return e=+e,t=+t,r=+r,uR(t,e,r)[2]}function vz(t,e,r){e=+e,t=+t,r=+r;const n=e<t,s=n?yz(e,t,r):yz(t,e,r);return(n?-1:1)*(s<0?1/-s:s)}function Tee(t,e){let r;for(const n of t)n!=null&&(r<n||r===void 0&&n>=n)&&(r=n);return r}function Pee(t,e){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function s0e(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?n0e:aot(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));s0e(t,e,p,m,s)}const i=t[e];let a=r,l=n;for(rS(t,r,e),s(t[n],i)>0&&rS(t,r,n);a<l;){for(rS(t,a,l),++a,--l;s(t[a],i)<0;)++a;for(;s(t[l],i)>0;)--l}s(t[r],i)===0?rS(t,r,l):(++l,rS(t,l,n)),l<=e&&(r=l+1),e<=l&&(n=l-1)}return t}function rS(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function uot(t,e,r){if(t=Float64Array.from(tot(t)),!(!(n=t.length)||isNaN(e=+e))){if(e<=0||n<2)return Pee(t);if(e>=1)return Tee(t);var n,s=(n-1)*e,i=Math.floor(s),a=Tee(s0e(t,i).subarray(0,i+1)),l=Pee(t.subarray(i+1));return a+(l-a)*(s-i)}}function dot(t,e,r=r0e){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),l=+r(t[i+1],i+1,t);return a+(l-a)*(s-i)}}function hot(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 fc(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Tf(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 bz=Symbol("implicit");function QV(){var t=new Eee,e=[],r=[],n=bz;function s(i){let a=t.get(i);if(a===void 0){if(n!==bz)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 Eee;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 QV(e,r).unknown(n)},fc.apply(s,arguments),s}function KN(){var t=QV().unknown(void 0),e=t.domain,r=t.range,n=0,s=1,i,a,l=!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),l&&(i=Math.floor(i)),m+=(g-m-i*(f-c))*d,a=i*(1-c),l&&(m=Math.round(m),a=Math.round(a));var y=hot(f).map(function(x){return m+i*x});return r(p?y.reverse():y)}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,l=!0,h()},t.bandwidth=function(){return a},t.step=function(){return i},t.round=function(f){return arguments.length?(l=!!f,h()):l},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 KN(e(),[n,s]).round(l).paddingInner(c).paddingOuter(u).align(d)},fc.apply(h(),arguments)}function i0e(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return i0e(e())},t}function $_(){return i0e(KN.apply(null,arguments).paddingInner(1))}function ZV(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function a0e(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function eA(){}var YN=.7,dR=1/YN,w0="\\s*([+-]?\\d+)\\s*",XN="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ld="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",fot=/^#([0-9a-f]{3,8})$/,pot=new RegExp(`^rgb\\(${w0},${w0},${w0}\\)$`),mot=new RegExp(`^rgb\\(${ld},${ld},${ld}\\)$`),got=new RegExp(`^rgba\\(${w0},${w0},${w0},${XN}\\)$`),xot=new RegExp(`^rgba\\(${ld},${ld},${ld},${XN}\\)$`),yot=new RegExp(`^hsl\\(${XN},${ld},${ld}\\)$`),vot=new RegExp(`^hsla\\(${XN},${ld},${ld},${XN}\\)$`),Iee={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};ZV(eA,QN,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Ree,formatHex:Ree,formatHex8:bot,formatHsl:wot,formatRgb:Oee,toString:Oee});function Ree(){return this.rgb().formatHex()}function bot(){return this.rgb().formatHex8()}function wot(){return o0e(this).formatHsl()}function Oee(){return this.rgb().formatRgb()}function QN(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=fot.exec(t))?(r=e[1].length,e=parseInt(e[1],16),r===6?Mee(e):r===3?new bo(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):r===8?gT(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):r===4?gT(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=pot.exec(t))?new bo(e[1],e[2],e[3],1):(e=mot.exec(t))?new bo(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=got.exec(t))?gT(e[1],e[2],e[3],e[4]):(e=xot.exec(t))?gT(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=yot.exec(t))?$ee(e[1],e[2]/100,e[3]/100,1):(e=vot.exec(t))?$ee(e[1],e[2]/100,e[3]/100,e[4]):Iee.hasOwnProperty(t)?Mee(Iee[t]):t==="transparent"?new bo(NaN,NaN,NaN,0):null}function Mee(t){return new bo(t>>16&255,t>>8&255,t&255,1)}function gT(t,e,r,n){return n<=0&&(t=e=r=NaN),new bo(t,e,r,n)}function jot(t){return t instanceof eA||(t=QN(t)),t?(t=t.rgb(),new bo(t.r,t.g,t.b,t.opacity)):new bo}function wz(t,e,r,n){return arguments.length===1?jot(t):new bo(t,e,r,n??1)}function bo(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}ZV(bo,wz,a0e(eA,{brighter(t){return t=t==null?dR:Math.pow(dR,t),new bo(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?YN:Math.pow(YN,t),new bo(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new bo(Uy(this.r),Uy(this.g),Uy(this.b),hR(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:Dee,formatHex:Dee,formatHex8:Sot,formatRgb:Lee,toString:Lee}));function Dee(){return`#${cx(this.r)}${cx(this.g)}${cx(this.b)}`}function Sot(){return`#${cx(this.r)}${cx(this.g)}${cx(this.b)}${cx((isNaN(this.opacity)?1:this.opacity)*255)}`}function Lee(){const t=hR(this.opacity);return`${t===1?"rgb(":"rgba("}${Uy(this.r)}, ${Uy(this.g)}, ${Uy(this.b)}${t===1?")":`, ${t})`}`}function hR(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Uy(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function cx(t){return t=Uy(t),(t<16?"0":"")+t.toString(16)}function $ee(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new zc(t,e,r,n)}function o0e(t){if(t instanceof zc)return new zc(t.h,t.s,t.l,t.opacity);if(t instanceof eA||(t=QN(t)),!t)return new zc;if(t instanceof zc)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,l=i-s,c=(i+s)/2;return l?(e===i?a=(r-n)/l+(r<n)*6:r===i?a=(n-e)/l+2:a=(e-r)/l+4,l/=c<.5?i+s:2-i-s,a*=60):l=c>0&&c<1?0:a,new zc(a,l,c,t.opacity)}function _ot(t,e,r,n){return arguments.length===1?o0e(t):new zc(t,e,r,n??1)}function zc(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}ZV(zc,_ot,a0e(eA,{brighter(t){return t=t==null?dR:Math.pow(dR,t),new zc(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?YN:Math.pow(YN,t),new zc(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 bo(a3(t>=240?t-240:t+120,s,n),a3(t,s,n),a3(t<120?t+240:t-120,s,n),this.opacity)},clamp(){return new zc(Fee(this.h),xT(this.s),xT(this.l),hR(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=hR(this.opacity);return`${t===1?"hsl(":"hsla("}${Fee(this.h)}, ${xT(this.s)*100}%, ${xT(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Fee(t){return t=(t||0)%360,t<0?t+360:t}function xT(t){return Math.max(0,Math.min(1,t||0))}function a3(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 JV=t=>()=>t;function Not(t,e){return function(r){return t+r*e}}function kot(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 Cot(t){return(t=+t)==1?l0e:function(e,r){return r-e?kot(e,r,t):JV(isNaN(e)?r:e)}}function l0e(t,e){var r=e-t;return r?Not(t,r):JV(isNaN(t)?e:t)}const Bee=function t(e){var r=Cot(e);function n(s,i){var a=r((s=wz(s)).r,(i=wz(i)).r),l=r(s.g,i.g),c=r(s.b,i.b),u=l0e(s.opacity,i.opacity);return function(d){return s.r=a(d),s.g=l(d),s.b=c(d),s.opacity=u(d),s+""}}return n.gamma=t,n}(1);function Eot(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 Aot(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Tot(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]=Cj(t[a],e[a]);for(;a<r;++a)i[a]=e[a];return function(l){for(a=0;a<n;++a)i[a]=s[a](l);return i}}function Pot(t,e){var r=new Date;return t=+t,e=+e,function(n){return r.setTime(t*(1-n)+e*n),r}}function fR(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function Iot(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]=Cj(t[s],e[s]):n[s]=e[s];return function(i){for(s in r)n[s]=r[s](i);return n}}var jz=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,o3=new RegExp(jz.source,"g");function Rot(t){return function(){return t}}function Oot(t){return function(e){return t(e)+""}}function Mot(t,e){var r=jz.lastIndex=o3.lastIndex=0,n,s,i,a=-1,l=[],c=[];for(t=t+"",e=e+"";(n=jz.exec(t))&&(s=o3.exec(e));)(i=s.index)>r&&(i=e.slice(r,i),l[a]?l[a]+=i:l[++a]=i),(n=n[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,c.push({i:a,x:fR(n,s)})),r=o3.lastIndex;return r<e.length&&(i=e.slice(r),l[a]?l[a]+=i:l[++a]=i),l.length<2?c[0]?Oot(c[0].x):Rot(e):(e=c.length,function(u){for(var d=0,h;d<e;++d)l[(h=c[d]).i]=h.x(u);return l.join("")})}function Cj(t,e){var r=typeof e,n;return e==null||r==="boolean"?JV(e):(r==="number"?fR:r==="string"?(n=QN(e))?(e=n,Bee):Mot:e instanceof QN?Bee:e instanceof Date?Pot:Aot(e)?Eot:Array.isArray(e)?Tot:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Iot:fR)(t,e)}function eq(t,e){return t=+t,e=+e,function(r){return Math.round(t*(1-r)+e*r)}}function Dot(t,e){e===void 0&&(e=t,t=Cj);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 l=Math.max(0,Math.min(n-1,Math.floor(a*=n)));return i[l](a-l)}}function Lot(t){return function(){return t}}function pR(t){return+t}var zee=[0,1];function Ga(t){return t}function Sz(t,e){return(e-=t=+t)?function(r){return(r-t)/e}:Lot(isNaN(e)?NaN:.5)}function $ot(t,e){var r;return t>e&&(r=t,t=e,e=r),function(n){return Math.max(t,Math.min(e,n))}}function Fot(t,e,r){var n=t[0],s=t[1],i=e[0],a=e[1];return s<n?(n=Sz(s,n),i=r(a,i)):(n=Sz(n,s),i=r(i,a)),function(l){return i(n(l))}}function Bot(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]=Sz(t[a],t[a+1]),i[a]=r(e[a],e[a+1]);return function(l){var c=JE(t,l,1,n)-1;return i[c](s[c](l))}}function tA(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function tL(){var t=zee,e=zee,r=Cj,n,s,i,a=Ga,l,c,u;function d(){var f=Math.min(t.length,e.length);return a!==Ga&&(a=$ot(t[0],t[f-1])),l=f>2?Bot:Fot,c=u=null,h}function h(f){return f==null||isNaN(f=+f)?i:(c||(c=l(t.map(n),e,r)))(n(a(f)))}return h.invert=function(f){return a(s((u||(u=l(e,t.map(n),fR)))(f)))},h.domain=function(f){return arguments.length?(t=Array.from(f,pR),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=eq,d()},h.clamp=function(f){return arguments.length?(a=f?!0:Ga,d()):a!==Ga},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 tq(){return tL()(Ga,Ga)}function zot(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function mR(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 b1(t){return t=mR(Math.abs(t)),t?t[1]:NaN}function Uot(t,e){return function(r,n){for(var s=r.length,i=[],a=0,l=t[0],c=0;s>0&&l>0&&(c+l+1>n&&(l=Math.max(1,n-c)),i.push(r.substring(s-=l,s+l)),!((c+=l+1)>n));)l=t[a=(a+1)%t.length];return i.reverse().join(e)}}function Hot(t){return function(e){return e.replace(/[0-9]/g,function(r){return t[+r]})}}var Wot=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ZN(t){if(!(e=Wot.exec(t)))throw new Error("invalid format: "+t);var e;return new rq({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]})}ZN.prototype=rq.prototype;function rq(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+""}rq.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 Vot(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 c0e;function qot(t,e){var r=mR(t,e);if(!r)return t+"";var n=r[0],s=r[1],i=s-(c0e=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")+mR(t,Math.max(0,e+i-1))[0]}function Uee(t,e){var r=mR(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 Hee={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:zot,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)=>Uee(t*100,e),r:Uee,s:qot,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Wee(t){return t}var Vee=Array.prototype.map,qee=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Got(t){var e=t.grouping===void 0||t.thousands===void 0?Wee:Uot(Vee.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?Wee:Hot(Vee.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(h){h=ZN(h);var f=h.fill,p=h.align,m=h.sign,g=h.symbol,y=h.zero,x=h.width,v=h.comma,b=h.precision,w=h.trim,j=h.type;j==="n"?(v=!0,j="g"):Hee[j]||(b===void 0&&(b=12),w=!0,j="g"),(y||f==="0"&&p==="=")&&(y=!0,f="0",p="=");var N=g==="$"?r:g==="#"&&/[boxX]/.test(j)?"0"+j.toLowerCase():"",C=g==="$"?n:/[%p]/.test(j)?a:"",A=Hee[j],E=/[defgprs%]/.test(j);b=b===void 0?6:/[gprs]/.test(j)?Math.max(1,Math.min(21,b)):Math.max(0,Math.min(20,b));function O($){var T=N,M=C,k,D,K;if(j==="c")M=A($)+M,$="";else{$=+$;var H=$<0||1/$<0;if($=isNaN($)?c:A(Math.abs($),b),w&&($=Vot($)),H&&+$==0&&m!=="+"&&(H=!1),T=(H?m==="("?m:l:m==="-"||m==="("?"":m)+T,M=(j==="s"?qee[8+c0e/3]:"")+M+(H&&m==="("?")":""),E){for(k=-1,D=$.length;++k<D;)if(K=$.charCodeAt(k),48>K||K>57){M=(K===46?s+$.slice(k+1):$.slice(k))+M,$=$.slice(0,k);break}}}v&&!y&&($=e($,1/0));var ee=T.length+$.length+M.length,V=ee<x?new Array(x-ee+1).join(f):"";switch(v&&y&&($=e(V+$,V.length?x-M.length:1/0),V=""),p){case"<":$=T+$+M+V;break;case"=":$=T+V+$+M;break;case"^":$=V.slice(0,ee=V.length>>1)+T+$+M+V.slice(ee);break;default:$=V+T+$+M;break}return i($)}return O.toString=function(){return h+""},O}function d(h,f){var p=u((h=ZN(h),h.type="f",h)),m=Math.max(-8,Math.min(8,Math.floor(b1(f)/3)))*3,g=Math.pow(10,-m),y=qee[8+m/3];return function(x){return p(g*x)+y}}return{format:u,formatPrefix:d}}var yT,nq,u0e;Kot({thousands:",",grouping:[3],currency:["$",""]});function Kot(t){return yT=Got(t),nq=yT.format,u0e=yT.formatPrefix,yT}function Yot(t){return Math.max(0,-b1(Math.abs(t)))}function Xot(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(b1(e)/3)))*3-b1(Math.abs(t)))}function Qot(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,b1(e)-b1(t))+1}function d0e(t,e,r,n){var s=vz(t,e,r),i;switch(n=ZN(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return n.precision==null&&!isNaN(i=Xot(s,a))&&(n.precision=i),u0e(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(i=Qot(s,Math.max(Math.abs(t),Math.abs(e))))&&(n.precision=i-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(i=Yot(s))&&(n.precision=i-(n.type==="%")*2);break}}return nq(n)}function fg(t){var e=t.domain;return t.ticks=function(r){var n=e();return xz(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var s=e();return d0e(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],l=n[i],c,u,d=10;for(l<a&&(u=a,a=l,l=u,u=s,s=i,i=u);d-- >0;){if(u=yz(a,l,r),u===c)return n[s]=a,n[i]=l,e(n);if(u>0)a=Math.floor(a/u)*u,l=Math.ceil(l/u)*u;else if(u<0)a=Math.ceil(a*u)/u,l=Math.floor(l*u)/u;else break;c=u}return t},t}function gR(){var t=tq();return t.copy=function(){return tA(t,gR())},fc.apply(t,arguments),fg(t)}function h0e(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,pR),r):t.slice()},r.unknown=function(n){return arguments.length?(e=n,r):e},r.copy=function(){return h0e(t).unknown(e)},t=arguments.length?Array.from(t,pR):[0,1],fg(r)}function f0e(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 Gee(t){return Math.log(t)}function Kee(t){return Math.exp(t)}function Zot(t){return-Math.log(-t)}function Jot(t){return-Math.exp(-t)}function elt(t){return isFinite(t)?+("1e"+t):t<0?0:t}function tlt(t){return t===10?elt:t===Math.E?Math.exp:e=>Math.pow(t,e)}function rlt(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 Yee(t){return(e,r)=>-t(-e,r)}function sq(t){const e=t(Gee,Kee),r=e.domain;let n=10,s,i;function a(){return s=rlt(n),i=tlt(n),r()[0]<0?(s=Yee(s),i=Yee(i),t(Zot,Jot)):t(Gee,Kee),e}return e.base=function(l){return arguments.length?(n=+l,a()):n},e.domain=function(l){return arguments.length?(r(l),a()):r()},e.ticks=l=>{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 y=l==null?10:+l;let x=[];if(!(n%1)&&p-f<y){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;x.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;x.push(g)}x.length*2<y&&(x=xz(u,d,y))}else x=xz(f,p,Math.min(p-f,y)).map(i);return h?x.reverse():x},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=ZN(c)).precision==null&&(c.trim=!0),c=nq(c)),l===1/0)return c;const u=Math.max(1,n*l/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(f0e(r(),{floor:l=>i(Math.floor(s(l))),ceil:l=>i(Math.ceil(s(l)))})),e}function p0e(){const t=sq(tL()).domain([1,10]);return t.copy=()=>tA(t,p0e()).base(t.base()),fc.apply(t,arguments),t}function Xee(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function Qee(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function iq(t){var e=1,r=t(Xee(e),Qee(e));return r.constant=function(n){return arguments.length?t(Xee(e=+n),Qee(e)):e},fg(r)}function m0e(){var t=iq(tL());return t.copy=function(){return tA(t,m0e()).constant(t.constant())},fc.apply(t,arguments)}function Zee(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function nlt(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function slt(t){return t<0?-t*t:t*t}function aq(t){var e=t(Ga,Ga),r=1;function n(){return r===1?t(Ga,Ga):r===.5?t(nlt,slt):t(Zee(r),Zee(1/r))}return e.exponent=function(s){return arguments.length?(r=+s,n()):r},fg(e)}function oq(){var t=aq(tL());return t.copy=function(){return tA(t,oq()).exponent(t.exponent())},fc.apply(t,arguments),t}function ilt(){return oq.apply(null,arguments).exponent(.5)}function Jee(t){return Math.sign(t)*t*t}function alt(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function g0e(){var t=tq(),e=[0,1],r=!1,n;function s(i){var a=alt(t(i));return isNaN(a)?n:r?Math.round(a):a}return s.invert=function(i){return t.invert(Jee(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,pR)).map(Jee)),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 g0e(t.domain(),e).round(r).clamp(t.clamp()).unknown(n)},fc.apply(s,arguments),fg(s)}function x0e(){var t=[],e=[],r=[],n;function s(){var a=0,l=Math.max(1,e.length);for(r=new Array(l-1);++a<l;)r[a-1]=dot(t,a/l);return i}function i(a){return a==null||isNaN(a=+a)?n:e[JE(r,a)]}return i.invertExtent=function(a){var l=e.indexOf(a);return l<0?[NaN,NaN]:[l>0?r[l-1]:t[0],l<r.length?r[l]:t[t.length-1]]},i.domain=function(a){if(!arguments.length)return t.slice();t=[];for(let l of a)l!=null&&!isNaN(l=+l)&&t.push(l);return t.sort(Tm),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 x0e().domain(t).range(e).unknown(n)},fc.apply(i,arguments)}function y0e(){var t=0,e=1,r=1,n=[.5],s=[0,1],i;function a(c){return c!=null&&c<=c?s[JE(n,c,0,r)]:i}function l(){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,l()):[t,e]},a.range=function(c){return arguments.length?(r=(s=Array.from(c)).length-1,l()):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 y0e().domain([t,e]).range(s).unknown(i)},fc.apply(fg(a),arguments)}function v0e(){var t=[.5],e=[0,1],r,n=1;function s(i){return i!=null&&i<=i?e[JE(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 v0e().domain(t).range(e).unknown(r)},fc.apply(s,arguments)}const l3=new Date,c3=new Date;function mi(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),l=s.ceil(i);return i-a<l-i?a:l},s.offset=(i,a)=>(e(i=new Date(+i),a==null?1:Math.floor(a)),i),s.range=(i,a,l)=>{const c=[];if(i=s.ceil(i),l=l==null?1:Math.floor(l),!(i<a)||!(l>0))return c;let u;do c.push(u=new Date(+i)),e(i,l),t(i);while(u<i&&i<a);return c},s.filter=i=>mi(a=>{if(a>=a)for(;t(a),!i(a);)a.setTime(a-1)},(a,l)=>{if(a>=a)if(l<0)for(;++l<=0;)for(;e(a,-1),!i(a););else for(;--l>=0;)for(;e(a,1),!i(a););}),r&&(s.count=(i,a)=>(l3.setTime(+i),c3.setTime(+a),t(l3),t(c3),Math.floor(r(l3,c3))),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 xR=mi(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);xR.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?mi(e=>{e.setTime(Math.floor(e/t)*t)},(e,r)=>{e.setTime(+e+r*t)},(e,r)=>(r-e)/t):xR);xR.range;const Lh=1e3,Xl=Lh*60,$h=Xl*60,mf=$h*24,lq=mf*7,ete=mf*30,u3=mf*365,ux=mi(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Lh)},(t,e)=>(e-t)/Lh,t=>t.getUTCSeconds());ux.range;const cq=mi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Lh)},(t,e)=>{t.setTime(+t+e*Xl)},(t,e)=>(e-t)/Xl,t=>t.getMinutes());cq.range;const uq=mi(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Xl)},(t,e)=>(e-t)/Xl,t=>t.getUTCMinutes());uq.range;const dq=mi(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Lh-t.getMinutes()*Xl)},(t,e)=>{t.setTime(+t+e*$h)},(t,e)=>(e-t)/$h,t=>t.getHours());dq.range;const hq=mi(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*$h)},(t,e)=>(e-t)/$h,t=>t.getUTCHours());hq.range;const rA=mi(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Xl)/mf,t=>t.getDate()-1);rA.range;const rL=mi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/mf,t=>t.getUTCDate()-1);rL.range;const b0e=mi(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/mf,t=>Math.floor(t/mf));b0e.range;function Ov(t){return mi(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())*Xl)/lq)}const nL=Ov(0),yR=Ov(1),olt=Ov(2),llt=Ov(3),w1=Ov(4),clt=Ov(5),ult=Ov(6);nL.range;yR.range;olt.range;llt.range;w1.range;clt.range;ult.range;function Mv(t){return mi(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)/lq)}const sL=Mv(0),vR=Mv(1),dlt=Mv(2),hlt=Mv(3),j1=Mv(4),flt=Mv(5),plt=Mv(6);sL.range;vR.range;dlt.range;hlt.range;j1.range;flt.range;plt.range;const fq=mi(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());fq.range;const pq=mi(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());pq.range;const gf=mi(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());gf.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:mi(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)});gf.range;const xf=mi(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());xf.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:mi(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)});xf.range;function w0e(t,e,r,n,s,i){const a=[[ux,1,Lh],[ux,5,5*Lh],[ux,15,15*Lh],[ux,30,30*Lh],[i,1,Xl],[i,5,5*Xl],[i,15,15*Xl],[i,30,30*Xl],[s,1,$h],[s,3,3*$h],[s,6,6*$h],[s,12,12*$h],[n,1,mf],[n,2,2*mf],[r,1,lq],[e,1,ete],[e,3,3*ete],[t,1,u3]];function l(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=XV(([,,y])=>y).right(a,f);if(p===a.length)return t.every(vz(u/u3,d/u3,h));if(p===0)return xR.every(Math.max(vz(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[l,c]}const[mlt,glt]=w0e(xf,pq,sL,b0e,hq,uq),[xlt,ylt]=w0e(gf,fq,nL,rA,dq,cq);function d3(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 h3(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 nS(t,e,r){return{y:t,m:e,d:r,H:0,M:0,S:0,L:0}}function vlt(t){var e=t.dateTime,r=t.date,n=t.time,s=t.periods,i=t.days,a=t.shortDays,l=t.months,c=t.shortMonths,u=sS(s),d=iS(s),h=sS(i),f=iS(i),p=sS(a),m=iS(a),g=sS(l),y=iS(l),x=sS(c),v=iS(c),b={a:H,A:ee,b:V,B,c:null,d:ate,e:ate,f:Ult,g:Zlt,G:ect,H:Flt,I:Blt,j:zlt,L:j0e,m:Hlt,M:Wlt,p:z,q:F,Q:cte,s:ute,S:Vlt,u:qlt,U:Glt,V:Klt,w:Ylt,W:Xlt,x:null,X:null,y:Qlt,Y:Jlt,Z:tct,"%":lte},w={a:G,A:Q,b:ie,B:se,c:null,d:ote,e:ote,f:ict,g:mct,G:xct,H:rct,I:nct,j:sct,L:_0e,m:act,M:oct,p:q,q:L,Q:cte,s:ute,S:lct,u:cct,U:uct,V:dct,w:hct,W:fct,x:null,X:null,y:pct,Y:gct,Z:yct,"%":lte},j={a:O,A:$,b:T,B:M,c:k,d:ste,e:ste,f:Mlt,g:nte,G:rte,H:ite,I:ite,j:Plt,L:Olt,m:Tlt,M:Ilt,p:E,q:Alt,Q:Llt,s:$lt,S:Rlt,u:_lt,U:Nlt,V:klt,w:Slt,W:Clt,x:D,X:K,y:nte,Y:rte,Z:Elt,"%":Dlt};b.x=N(r,b),b.X=N(n,b),b.c=N(e,b),w.x=N(r,w),w.X=N(n,w),w.c=N(e,w);function N(Z,J){return function(W){var X=[],he=-1,P=0,oe=Z.length,Y,R,I;for(W instanceof Date||(W=new Date(+W));++he<oe;)Z.charCodeAt(he)===37&&(X.push(Z.slice(P,he)),(R=tte[Y=Z.charAt(++he)])!=null?Y=Z.charAt(++he):R=Y==="e"?" ":"0",(I=J[Y])&&(Y=I(W,R)),X.push(Y),P=he+1);return X.push(Z.slice(P,he)),X.join("")}}function C(Z,J){return function(W){var X=nS(1900,void 0,1),he=A(X,Z,W+="",0),P,oe;if(he!=W.length)return null;if("Q"in X)return new Date(X.Q);if("s"in X)return new Date(X.s*1e3+("L"in X?X.L:0));if(J&&!("Z"in X)&&(X.Z=0),"p"in X&&(X.H=X.H%12+X.p*12),X.m===void 0&&(X.m="q"in X?X.q:0),"V"in X){if(X.V<1||X.V>53)return null;"w"in X||(X.w=1),"Z"in X?(P=h3(nS(X.y,0,1)),oe=P.getUTCDay(),P=oe>4||oe===0?vR.ceil(P):vR(P),P=rL.offset(P,(X.V-1)*7),X.y=P.getUTCFullYear(),X.m=P.getUTCMonth(),X.d=P.getUTCDate()+(X.w+6)%7):(P=d3(nS(X.y,0,1)),oe=P.getDay(),P=oe>4||oe===0?yR.ceil(P):yR(P),P=rA.offset(P,(X.V-1)*7),X.y=P.getFullYear(),X.m=P.getMonth(),X.d=P.getDate()+(X.w+6)%7)}else("W"in X||"U"in X)&&("w"in X||(X.w="u"in X?X.u%7:"W"in X?1:0),oe="Z"in X?h3(nS(X.y,0,1)).getUTCDay():d3(nS(X.y,0,1)).getDay(),X.m=0,X.d="W"in X?(X.w+6)%7+X.W*7-(oe+5)%7:X.w+X.U*7-(oe+6)%7);return"Z"in X?(X.H+=X.Z/100|0,X.M+=X.Z%100,h3(X)):d3(X)}}function A(Z,J,W,X){for(var he=0,P=J.length,oe=W.length,Y,R;he<P;){if(X>=oe)return-1;if(Y=J.charCodeAt(he++),Y===37){if(Y=J.charAt(he++),R=j[Y in tte?J.charAt(he++):Y],!R||(X=R(Z,W,X))<0)return-1}else if(Y!=W.charCodeAt(X++))return-1}return X}function E(Z,J,W){var X=u.exec(J.slice(W));return X?(Z.p=d.get(X[0].toLowerCase()),W+X[0].length):-1}function O(Z,J,W){var X=p.exec(J.slice(W));return X?(Z.w=m.get(X[0].toLowerCase()),W+X[0].length):-1}function $(Z,J,W){var X=h.exec(J.slice(W));return X?(Z.w=f.get(X[0].toLowerCase()),W+X[0].length):-1}function T(Z,J,W){var X=x.exec(J.slice(W));return X?(Z.m=v.get(X[0].toLowerCase()),W+X[0].length):-1}function M(Z,J,W){var X=g.exec(J.slice(W));return X?(Z.m=y.get(X[0].toLowerCase()),W+X[0].length):-1}function k(Z,J,W){return A(Z,e,J,W)}function D(Z,J,W){return A(Z,r,J,W)}function K(Z,J,W){return A(Z,n,J,W)}function H(Z){return a[Z.getDay()]}function ee(Z){return i[Z.getDay()]}function V(Z){return c[Z.getMonth()]}function B(Z){return l[Z.getMonth()]}function z(Z){return s[+(Z.getHours()>=12)]}function F(Z){return 1+~~(Z.getMonth()/3)}function G(Z){return a[Z.getUTCDay()]}function Q(Z){return i[Z.getUTCDay()]}function ie(Z){return c[Z.getUTCMonth()]}function se(Z){return l[Z.getUTCMonth()]}function q(Z){return s[+(Z.getUTCHours()>=12)]}function L(Z){return 1+~~(Z.getUTCMonth()/3)}return{format:function(Z){var J=N(Z+="",b);return J.toString=function(){return Z},J},parse:function(Z){var J=C(Z+="",!1);return J.toString=function(){return Z},J},utcFormat:function(Z){var J=N(Z+="",w);return J.toString=function(){return Z},J},utcParse:function(Z){var J=C(Z+="",!0);return J.toString=function(){return Z},J}}}var tte={"-":"",_:" ",0:"0"},$i=/^\s*\d+/,blt=/^%/,wlt=/[\\^$*+?|[\]().{}]/g;function qr(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 jlt(t){return t.replace(wlt,"\\$&")}function sS(t){return new RegExp("^(?:"+t.map(jlt).join("|")+")","i")}function iS(t){return new Map(t.map((e,r)=>[e.toLowerCase(),r]))}function Slt(t,e,r){var n=$i.exec(e.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function _lt(t,e,r){var n=$i.exec(e.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function Nlt(t,e,r){var n=$i.exec(e.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function klt(t,e,r){var n=$i.exec(e.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function Clt(t,e,r){var n=$i.exec(e.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function rte(t,e,r){var n=$i.exec(e.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function nte(t,e,r){var n=$i.exec(e.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function Elt(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 Alt(t,e,r){var n=$i.exec(e.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function Tlt(t,e,r){var n=$i.exec(e.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function ste(t,e,r){var n=$i.exec(e.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function Plt(t,e,r){var n=$i.exec(e.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function ite(t,e,r){var n=$i.exec(e.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function Ilt(t,e,r){var n=$i.exec(e.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function Rlt(t,e,r){var n=$i.exec(e.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function Olt(t,e,r){var n=$i.exec(e.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Mlt(t,e,r){var n=$i.exec(e.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function Dlt(t,e,r){var n=blt.exec(e.slice(r,r+1));return n?r+n[0].length:-1}function Llt(t,e,r){var n=$i.exec(e.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function $lt(t,e,r){var n=$i.exec(e.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function ate(t,e){return qr(t.getDate(),e,2)}function Flt(t,e){return qr(t.getHours(),e,2)}function Blt(t,e){return qr(t.getHours()%12||12,e,2)}function zlt(t,e){return qr(1+rA.count(gf(t),t),e,3)}function j0e(t,e){return qr(t.getMilliseconds(),e,3)}function Ult(t,e){return j0e(t,e)+"000"}function Hlt(t,e){return qr(t.getMonth()+1,e,2)}function Wlt(t,e){return qr(t.getMinutes(),e,2)}function Vlt(t,e){return qr(t.getSeconds(),e,2)}function qlt(t){var e=t.getDay();return e===0?7:e}function Glt(t,e){return qr(nL.count(gf(t)-1,t),e,2)}function S0e(t){var e=t.getDay();return e>=4||e===0?w1(t):w1.ceil(t)}function Klt(t,e){return t=S0e(t),qr(w1.count(gf(t),t)+(gf(t).getDay()===4),e,2)}function Ylt(t){return t.getDay()}function Xlt(t,e){return qr(yR.count(gf(t)-1,t),e,2)}function Qlt(t,e){return qr(t.getFullYear()%100,e,2)}function Zlt(t,e){return t=S0e(t),qr(t.getFullYear()%100,e,2)}function Jlt(t,e){return qr(t.getFullYear()%1e4,e,4)}function ect(t,e){var r=t.getDay();return t=r>=4||r===0?w1(t):w1.ceil(t),qr(t.getFullYear()%1e4,e,4)}function tct(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+qr(e/60|0,"0",2)+qr(e%60,"0",2)}function ote(t,e){return qr(t.getUTCDate(),e,2)}function rct(t,e){return qr(t.getUTCHours(),e,2)}function nct(t,e){return qr(t.getUTCHours()%12||12,e,2)}function sct(t,e){return qr(1+rL.count(xf(t),t),e,3)}function _0e(t,e){return qr(t.getUTCMilliseconds(),e,3)}function ict(t,e){return _0e(t,e)+"000"}function act(t,e){return qr(t.getUTCMonth()+1,e,2)}function oct(t,e){return qr(t.getUTCMinutes(),e,2)}function lct(t,e){return qr(t.getUTCSeconds(),e,2)}function cct(t){var e=t.getUTCDay();return e===0?7:e}function uct(t,e){return qr(sL.count(xf(t)-1,t),e,2)}function N0e(t){var e=t.getUTCDay();return e>=4||e===0?j1(t):j1.ceil(t)}function dct(t,e){return t=N0e(t),qr(j1.count(xf(t),t)+(xf(t).getUTCDay()===4),e,2)}function hct(t){return t.getUTCDay()}function fct(t,e){return qr(vR.count(xf(t)-1,t),e,2)}function pct(t,e){return qr(t.getUTCFullYear()%100,e,2)}function mct(t,e){return t=N0e(t),qr(t.getUTCFullYear()%100,e,2)}function gct(t,e){return qr(t.getUTCFullYear()%1e4,e,4)}function xct(t,e){var r=t.getUTCDay();return t=r>=4||r===0?j1(t):j1.ceil(t),qr(t.getUTCFullYear()%1e4,e,4)}function yct(){return"+0000"}function lte(){return"%"}function cte(t){return+t}function ute(t){return Math.floor(+t/1e3)}var sb,k0e,C0e;vct({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 vct(t){return sb=vlt(t),k0e=sb.format,sb.parse,C0e=sb.utcFormat,sb.utcParse,sb}function bct(t){return new Date(t)}function wct(t){return t instanceof Date?+t:+new Date(+t)}function mq(t,e,r,n,s,i,a,l,c,u){var d=tq(),h=d.invert,f=d.domain,p=u(".%L"),m=u(":%S"),g=u("%I:%M"),y=u("%I %p"),x=u("%a %d"),v=u("%b %d"),b=u("%B"),w=u("%Y");function j(N){return(c(N)<N?p:l(N)<N?m:a(N)<N?g:i(N)<N?y:n(N)<N?s(N)<N?x:v:r(N)<N?b:w)(N)}return d.invert=function(N){return new Date(h(N))},d.domain=function(N){return arguments.length?f(Array.from(N,wct)):f().map(bct)},d.ticks=function(N){var C=f();return t(C[0],C[C.length-1],N??10)},d.tickFormat=function(N,C){return C==null?j:u(C)},d.nice=function(N){var C=f();return(!N||typeof N.range!="function")&&(N=e(C[0],C[C.length-1],N??10)),N?f(f0e(C,N)):d},d.copy=function(){return tA(d,mq(t,e,r,n,s,i,a,l,c,u))},d}function jct(){return fc.apply(mq(xlt,ylt,gf,fq,nL,rA,dq,cq,ux,k0e).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Sct(){return fc.apply(mq(mlt,glt,xf,pq,sL,rL,hq,uq,ux,C0e).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function iL(){var t=0,e=1,r,n,s,i,a=Ga,l=!1,c;function u(h){return h==null||isNaN(h=+h)?c:a(s===0?.5:(h=(i(h)-r)*s,l?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?(l=!!h,u):l},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(Cj),u.rangeRound=d(eq),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 pg(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function E0e(){var t=fg(iL()(Ga));return t.copy=function(){return pg(t,E0e())},Tf.apply(t,arguments)}function A0e(){var t=sq(iL()).domain([1,10]);return t.copy=function(){return pg(t,A0e()).base(t.base())},Tf.apply(t,arguments)}function T0e(){var t=iq(iL());return t.copy=function(){return pg(t,T0e()).constant(t.constant())},Tf.apply(t,arguments)}function gq(){var t=aq(iL());return t.copy=function(){return pg(t,gq()).exponent(t.exponent())},Tf.apply(t,arguments)}function _ct(){return gq.apply(null,arguments).exponent(.5)}function P0e(){var t=[],e=Ga;function r(n){if(n!=null&&!isNaN(n=+n))return e((JE(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(Tm),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)=>uot(t,i/n))},r.copy=function(){return P0e(e).domain(t)},Tf.apply(r,arguments)}function aL(){var t=0,e=.5,r=1,n=1,s,i,a,l,c,u=Ga,d,h=!1,f;function p(g){return isNaN(g=+g)?f:(g=.5+((g=+d(g))-i)*(n*g<n*i?l: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),l=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(y){var x,v,b;return arguments.length?([x,v,b]=y,u=Dot(g,[x,v,b]),p):[u(0),u(.5),u(1)]}}return p.range=m(Cj),p.rangeRound=m(eq),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),l=s===i?0:.5/(i-s),c=i===a?0:.5/(a-i),n=i<s?-1:1,p}}function I0e(){var t=fg(aL()(Ga));return t.copy=function(){return pg(t,I0e())},Tf.apply(t,arguments)}function R0e(){var t=sq(aL()).domain([.1,1,10]);return t.copy=function(){return pg(t,R0e()).base(t.base())},Tf.apply(t,arguments)}function O0e(){var t=iq(aL());return t.copy=function(){return pg(t,O0e()).constant(t.constant())},Tf.apply(t,arguments)}function xq(){var t=aq(aL());return t.copy=function(){return pg(t,xq()).exponent(t.exponent())},Tf.apply(t,arguments)}function Nct(){return xq.apply(null,arguments).exponent(.5)}const dte=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:KN,scaleDiverging:I0e,scaleDivergingLog:R0e,scaleDivergingPow:xq,scaleDivergingSqrt:Nct,scaleDivergingSymlog:O0e,scaleIdentity:h0e,scaleImplicit:bz,scaleLinear:gR,scaleLog:p0e,scaleOrdinal:QV,scalePoint:$_,scalePow:oq,scaleQuantile:x0e,scaleQuantize:y0e,scaleRadial:g0e,scaleSequential:E0e,scaleSequentialLog:A0e,scaleSequentialPow:gq,scaleSequentialQuantile:P0e,scaleSequentialSqrt:_ct,scaleSequentialSymlog:T0e,scaleSqrt:ilt,scaleSymlog:m0e,scaleThreshold:v0e,scaleTime:jct,scaleUtc:Sct,tickFormat:d0e},Symbol.toStringTag,{value:"Module"}));var kct=vj;function Cct(t,e,r){for(var n=-1,s=t.length;++n<s;){var i=t[n],a=e(i);if(a!=null&&(l===void 0?a===a&&!kct(a):r(a,l)))var l=a,c=i}return c}var oL=Cct;function Ect(t,e){return t>e}var M0e=Ect,Act=oL,Tct=M0e,Pct=kj;function Ict(t){return t&&t.length?Act(t,Pct,Tct):void 0}var Rct=Ict;const lL=Er(Rct);function Oct(t,e){return t<e}var D0e=Oct,Mct=oL,Dct=D0e,Lct=kj;function $ct(t){return t&&t.length?Mct(t,Lct,Dct):void 0}var Fct=$ct;const cL=Er(Fct);var Bct=TV,zct=hg,Uct=Wbe,Hct=To;function Wct(t,e){var r=Hct(t)?Bct:Uct;return r(t,zct(e))}var Vct=Wct,qct=Ube,Gct=Vct;function Kct(t,e){return qct(Gct(t,e),1)}var Yct=Kct;const Xct=Er(Yct);var Qct=qV;function Zct(t,e){return Qct(t,e)}var Jct=Zct;const yq=Er(Jct);var Ej=1e9,eut={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},bq,Xn=!0,oc="[DecimalError] ",Hy=oc+"Invalid argument: ",vq=oc+"Exponent out of range: ",Aj=Math.floor,Wg=Math.pow,tut=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,rl,ki=1e7,Ln=7,L0e=9007199254740991,bR=Aj(L0e/Ln),St={};St.absoluteValue=St.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};St.comparedTo=St.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};St.decimalPlaces=St.dp=function(){var t=this,e=t.d.length-1,r=(e-t.e)*Ln;if(e=t.d[e],e)for(;e%10==0;e/=10)r--;return r<0?0:r};St.dividedBy=St.div=function(t){return Xh(this,new this.constructor(t))};St.dividedToIntegerBy=St.idiv=function(t){var e=this,r=e.constructor;return wn(Xh(e,new r(t),0,1),r.precision)};St.equals=St.eq=function(t){return!this.cmp(t)};St.exponent=function(){return Us(this)};St.greaterThan=St.gt=function(t){return this.cmp(t)>0};St.greaterThanOrEqualTo=St.gte=function(t){return this.cmp(t)>=0};St.isInteger=St.isint=function(){return this.e>this.d.length-2};St.isNegative=St.isneg=function(){return this.s<0};St.isPositive=St.ispos=function(){return this.s>0};St.isZero=function(){return this.s===0};St.lessThan=St.lt=function(t){return this.cmp(t)<0};St.lessThanOrEqualTo=St.lte=function(t){return this.cmp(t)<1};St.logarithm=St.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(rl))throw Error(oc+"NaN");if(r.s<1)throw Error(oc+(r.s?"NaN":"-Infinity"));return r.eq(rl)?new n(0):(Xn=!1,e=Xh(JN(r,i),JN(t,i),i),Xn=!0,wn(e,s))};St.minus=St.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?B0e(e,t):$0e(e,(t.s=-t.s,t))};St.modulo=St.mod=function(t){var e,r=this,n=r.constructor,s=n.precision;if(t=new n(t),!t.s)throw Error(oc+"NaN");return r.s?(Xn=!1,e=Xh(r,t,0,1).times(t),Xn=!0,r.minus(e)):wn(new n(r),s)};St.naturalExponential=St.exp=function(){return F0e(this)};St.naturalLogarithm=St.ln=function(){return JN(this)};St.negated=St.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};St.plus=St.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?$0e(e,t):B0e(e,(t.s=-t.s,t))};St.precision=St.sd=function(t){var e,r,n,s=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Hy+t);if(e=Us(s)+1,n=s.d.length-1,r=n*Ln+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};St.squareRoot=St.sqrt=function(){var t,e,r,n,s,i,a,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(oc+"NaN")}for(t=Us(l),Xn=!1,s=Math.sqrt(+l),s==0||s==1/0?(e=ed(l.d),(e.length+t)%2==0&&(e+="0"),s=Math.sqrt(e),t=Aj((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(Xh(l,i,a+2)).times(.5),ed(i.d).slice(0,a)===(e=ed(n.d)).slice(0,a)){if(e=e.slice(a-3,a+1),s==a&&e=="4999"){if(wn(i,r+1,0),i.times(i).eq(l)){n=i;break}}else if(e!="9999")break;a+=4}return Xn=!0,wn(n,r)};St.times=St.mul=function(t){var e,r,n,s,i,a,l,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;)l=i[s]+p[n]*f[s-n-1]+e,i[s--]=l%ki|0,e=l/ki|0;i[s]=(i[s]+e)%ki|0}for(;!i[--a];)i.pop();return e?++r:i.shift(),t.d=i,t.e=r,Xn?wn(t,h.precision):t};St.toDecimalPlaces=St.todp=function(t,e){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(pd(t,0,Ej),e===void 0?e=n.rounding:pd(e,0,8),wn(r,t+Us(r)+1,e))};St.toExponential=function(t,e){var r,n=this,s=n.constructor;return t===void 0?r=dv(n,!0):(pd(t,0,Ej),e===void 0?e=s.rounding:pd(e,0,8),n=wn(new s(n),t+1,e),r=dv(n,!0,t+1)),r};St.toFixed=function(t,e){var r,n,s=this,i=s.constructor;return t===void 0?dv(s):(pd(t,0,Ej),e===void 0?e=i.rounding:pd(e,0,8),n=wn(new i(s),t+Us(s)+1,e),r=dv(n.abs(),!1,t+Us(n)+1),s.isneg()&&!s.isZero()?"-"+r:r)};St.toInteger=St.toint=function(){var t=this,e=t.constructor;return wn(new e(t),Us(t)+1,e.rounding)};St.toNumber=function(){return+this};St.toPower=St.pow=function(t){var e,r,n,s,i,a,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(rl);if(l=new c(l),!l.s){if(t.s<1)throw Error(oc+"Infinity");return l}if(l.eq(rl))return l;if(n=c.precision,t.eq(rl))return wn(l,n);if(e=t.e,r=t.d.length-1,a=e>=r,i=l.s,a){if((r=d<0?-d:d)<=L0e){for(s=new c(rl),e=Math.ceil(n/Ln+4),Xn=!1;r%2&&(s=s.times(l),fte(s.d,e)),r=Aj(r/2),r!==0;)l=l.times(l),fte(l.d,e);return Xn=!0,t.s<0?new c(rl).div(s):wn(s,n)}}else if(i<0)throw Error(oc+"NaN");return i=i<0&&t.d[Math.max(e,r)]&1?-1:1,l.s=1,Xn=!1,s=t.times(JN(l,n+u)),Xn=!0,s=F0e(s),s.s=i,s};St.toPrecision=function(t,e){var r,n,s=this,i=s.constructor;return t===void 0?(r=Us(s),n=dv(s,r<=i.toExpNeg||r>=i.toExpPos)):(pd(t,1,Ej),e===void 0?e=i.rounding:pd(e,0,8),s=wn(new i(s),t,e),r=Us(s),n=dv(s,t<=r||r<=i.toExpNeg,t)),n};St.toSignificantDigits=St.tosd=function(t,e){var r=this,n=r.constructor;return t===void 0?(t=n.precision,e=n.rounding):(pd(t,1,Ej),e===void 0?e=n.rounding:pd(e,0,8)),wn(new n(r),t,e)};St.toString=St.valueOf=St.val=St.toJSON=St[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=Us(t),r=t.constructor;return dv(t,e<=r.toExpNeg||e>=r.toExpPos)};function $0e(t,e){var r,n,s,i,a,l,c,u,d=t.constructor,h=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),Xn?wn(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,l=u.length):(n=u,s=a,l=c.length),a=Math.ceil(h/Ln),l=a>l?a+1:l+1,i>l&&(i=l,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(l=c.length,i=u.length,l-i<0&&(i=l,n=u,u=c,c=n),r=0;i;)r=(c[--i]=c[i]+u[i]+r)/ki|0,c[i]%=ki;for(r&&(c.unshift(r),++s),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=s,Xn?wn(e,h):e}function pd(t,e,r){if(t!==~~t||t<e||t>r)throw Error(Hy+t)}function ed(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=Ln-n.length,r&&(i+=ap(r)),i+=n;a=t[e],n=a+"",r=Ln-n.length,r&&(i+=ap(r))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}var Xh=function(){function t(n,s){var i,a=0,l=n.length;for(n=n.slice();l--;)i=n[l]*s+a,n[l]=i%ki|0,a=i/ki|0;return a&&n.unshift(a),n}function e(n,s,i,a){var l,c;if(i!=a)c=i>a?1:-1;else for(l=c=0;l<i;l++)if(n[l]!=s[l]){c=n[l]>s[l]?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*ki+n[i]-s[i];for(;!n[0]&&n.length>1;)n.shift()}return function(n,s,i,a){var l,c,u,d,h,f,p,m,g,y,x,v,b,w,j,N,C,A,E=n.constructor,O=n.s==s.s?1:-1,$=n.d,T=s.d;if(!n.s)return new E(n);if(!s.s)throw Error(oc+"Division by zero");for(c=n.e-s.e,C=T.length,j=$.length,p=new E(O),m=p.d=[],u=0;T[u]==($[u]||0);)++u;if(T[u]>($[u]||0)&&--c,i==null?v=i=E.precision:a?v=i+(Us(n)-Us(s))+1:v=i,v<0)return new E(0);if(v=v/Ln+2|0,u=0,C==1)for(d=0,T=T[0],v++;(u<j||d)&&v--;u++)b=d*ki+($[u]||0),m[u]=b/T|0,d=b%T|0;else{for(d=ki/(T[0]+1)|0,d>1&&(T=t(T,d),$=t($,d),C=T.length,j=$.length),w=C,g=$.slice(0,C),y=g.length;y<C;)g[y++]=0;A=T.slice(),A.unshift(0),N=T[0],T[1]>=ki/2&&++N;do d=0,l=e(T,g,C,y),l<0?(x=g[0],C!=y&&(x=x*ki+(g[1]||0)),d=x/N|0,d>1?(d>=ki&&(d=ki-1),h=t(T,d),f=h.length,y=g.length,l=e(h,g,f,y),l==1&&(d--,r(h,C<f?A:T,f))):(d==0&&(l=d=1),h=T.slice()),f=h.length,f<y&&h.unshift(0),r(g,h,y),l==-1&&(y=g.length,l=e(T,g,C,y),l<1&&(d++,r(g,C<y?A:T,y))),y=g.length):l===0&&(d++,g=[0]),m[u++]=d,l&&g[0]?g[y++]=$[w]||0:(g=[$[w]],y=1);while((w++<j||g[0]!==void 0)&&v--)}return m[0]||m.shift(),p.e=c,wn(p,a?i+Us(p)+1:i)}}();function F0e(t,e){var r,n,s,i,a,l,c=0,u=0,d=t.constructor,h=d.precision;if(Us(t)>16)throw Error(vq+Us(t));if(!t.s)return new d(rl);for(e==null?(Xn=!1,l=h):l=e,a=new d(.03125);t.abs().gte(.1);)t=t.times(a),u+=5;for(n=Math.log(Wg(2,u))/Math.LN10*2+5|0,l+=n,r=s=i=new d(rl),d.precision=l;;){if(s=wn(s.times(t),l),r=r.times(++c),a=i.plus(Xh(s,r,l)),ed(a.d).slice(0,l)===ed(i.d).slice(0,l)){for(;u--;)i=wn(i.times(i),l);return d.precision=h,e==null?(Xn=!0,wn(i,h)):i}i=a}}function Us(t){for(var e=t.e*Ln,r=t.d[0];r>=10;r/=10)e++;return e}function f3(t,e,r){if(e>t.LN10.sd())throw Xn=!0,r&&(t.precision=r),Error(oc+"LN10 precision limit exceeded");return wn(new t(t.LN10),e)}function ap(t){for(var e="";t--;)e+="0";return e}function JN(t,e){var r,n,s,i,a,l,c,u,d,h=1,f=10,p=t,m=p.d,g=p.constructor,y=g.precision;if(p.s<1)throw Error(oc+(p.s?"NaN":"-Infinity"));if(p.eq(rl))return new g(0);if(e==null?(Xn=!1,u=y):u=e,p.eq(10))return e==null&&(Xn=!0),f3(g,u);if(u+=f,g.precision=u,r=ed(m),n=r.charAt(0),i=Us(p),Math.abs(i)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)p=p.times(t),r=ed(p.d),n=r.charAt(0),h++;i=Us(p),n>1?(p=new g("0."+r),i++):p=new g(n+"."+r.slice(1))}else return c=f3(g,u+2,y).times(i+""),p=JN(new g(n+"."+r.slice(1)),u-f).plus(c),g.precision=y,e==null?(Xn=!0,wn(p,y)):p;for(l=a=p=Xh(p.minus(rl),p.plus(rl),u),d=wn(p.times(p),u),s=3;;){if(a=wn(a.times(d),u),c=l.plus(Xh(a,new g(s),u)),ed(c.d).slice(0,u)===ed(l.d).slice(0,u))return l=l.times(2),i!==0&&(l=l.plus(f3(g,u+2,y).times(i+""))),l=Xh(l,new g(h),u),g.precision=y,e==null?(Xn=!0,wn(l,y)):l;l=c,s+=2}}function hte(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=Aj(r/Ln),t.d=[],n=(r+1)%Ln,r<0&&(n+=Ln),n<s){for(n&&t.d.push(+e.slice(0,n)),s-=Ln;n<s;)t.d.push(+e.slice(n,n+=Ln));e=e.slice(n),n=Ln-e.length}else n-=s;for(;n--;)e+="0";if(t.d.push(+e),Xn&&(t.e>bR||t.e<-bR))throw Error(vq+r)}else t.s=0,t.e=0,t.d=[0];return t}function wn(t,e,r){var n,s,i,a,l,c,u,d,h=t.d;for(a=1,i=h[0];i>=10;i/=10)a++;if(n=e-a,n<0)n+=Ln,s=e,u=h[d=0];else{if(d=Math.ceil((n+1)/Ln),i=h.length,d>=i)return t;for(u=i=h[d],a=1;i>=10;i/=10)a++;n%=Ln,s=n-Ln+a}if(r!==void 0&&(i=Wg(10,a-s-1),l=u/i%10|0,c=e<0||h[d+1]!==void 0||u%i,c=r<4?(l||c)&&(r==0||r==(t.s<0?3:2)):l>5||l==5&&(r==4||c||r==6&&(n>0?s>0?u/Wg(10,a-s):0:h[d-1])%10&1||r==(t.s<0?8:7))),e<1||!h[0])return c?(i=Us(t),h.length=1,e=e-i-1,h[0]=Wg(10,(Ln-e%Ln)%Ln),t.e=Aj(-e/Ln)||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=Wg(10,Ln-n),h[d]=s>0?(u/Wg(10,a-s)%Wg(10,s)|0)*i:0),c)for(;;)if(d==0){(h[0]+=i)==ki&&(h[0]=1,++t.e);break}else{if(h[d]+=i,h[d]!=ki)break;h[d--]=0,i=1}for(n=h.length;h[--n]===0;)h.pop();if(Xn&&(t.e>bR||t.e<-bR))throw Error(vq+Us(t));return t}function B0e(t,e){var r,n,s,i,a,l,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),Xn?wn(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,l=h.length):(r=h,n=u,l=c.length),s=Math.max(Math.ceil(p/Ln),l)+2,a>s&&(a=s,r.length=1),r.reverse(),s=a;s--;)r.push(0);r.reverse()}else{for(s=c.length,l=h.length,d=s<l,d&&(l=s),s=0;s<l;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),l=c.length,s=h.length-l;s>0;--s)c[l++]=0;for(s=h.length;s>a;){if(c[--s]<h[s]){for(i=s;i&&c[--i]===0;)c[i]=ki-1;--c[i],c[s]+=ki}c[s]-=h[s]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--n;return c[0]?(e.d=c,e.e=n,Xn?wn(e,p):e):new f(0)}function dv(t,e,r){var n,s=Us(t),i=ed(t.d),a=i.length;return e?(r&&(n=r-a)>0?i=i.charAt(0)+"."+i.slice(1)+ap(n):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(s<0?"e":"e+")+s):s<0?(i="0."+ap(-s-1)+i,r&&(n=r-a)>0&&(i+=ap(n))):s>=a?(i+=ap(s+1-a),r&&(n=r-s-1)>0&&(i=i+"."+ap(n))):((n=s+1)<a&&(i=i.slice(0,n)+"."+i.slice(n)),r&&(n=r-a)>0&&(s+1===a&&(i+="."),i+=ap(n))),t.s<0?"-"+i:i}function fte(t,e){if(t.length>e)return t.length=e,!0}function z0e(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(Hy+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 hte(a,i.toString())}else if(typeof i!="string")throw Error(Hy+i);if(i.charCodeAt(0)===45?(i=i.slice(1),a.s=-1):a.s=1,tut.test(i))hte(a,i);else throw Error(Hy+i)}if(s.prototype=St,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=z0e,s.config=s.set=rut,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 rut(t){if(!t||typeof t!="object")throw Error(oc+"Object expected");var e,r,n,s=["precision",1,Ej,"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(Aj(n)===n&&n>=s[e+1]&&n<=s[e+2])this[r]=n;else throw Error(Hy+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(Hy+r+": "+n);return this}var bq=z0e(eut);rl=new bq(1);const un=bq;function nut(t){return out(t)||aut(t)||iut(t)||sut()}function sut(){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 iut(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 aut(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function out(t){if(Array.isArray(t))return _z(t)}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}var lut=function(e){return e},U0e={"@@functional/placeholder":!0},H0e=function(e){return e===U0e},pte=function(e){return function r(){return arguments.length===0||arguments.length===1&&H0e(arguments.length<=0?void 0:arguments[0])?r:e.apply(void 0,arguments)}},cut=function t(e,r){return e===1?r:pte(function(){for(var n=arguments.length,s=new Array(n),i=0;i<n;i++)s[i]=arguments[i];var a=s.filter(function(l){return l!==U0e}).length;return a>=e?r.apply(void 0,s):t(e-a,pte(function(){for(var l=arguments.length,c=new Array(l),u=0;u<l;u++)c[u]=arguments[u];var d=s.map(function(h){return H0e(h)?c.shift():h});return r.apply(void 0,nut(d).concat(c))}))})},uL=function(e){return cut(e.length,e)},Nz=function(e,r){for(var n=[],s=e;s<r;++s)n[s-e]=s;return n},uut=uL(function(t,e){return Array.isArray(e)?e.map(t):Object.keys(e).map(function(r){return e[r]}).map(t)}),dut=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];if(!r.length)return lut;var s=r.reverse(),i=s[0],a=s.slice(1);return function(){return a.reduce(function(l,c){return c(l)},i.apply(void 0,arguments))}},kz=function(e){return Array.isArray(e)?e.reverse():e.split("").reverse.join("")},W0e=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(l,c){return l===r[c]})||(r=i,n=e.apply(void 0,i)),n}};function hut(t){var e;return t===0?e=1:e=Math.floor(new un(t).abs().log(10).toNumber())+1,e}function fut(t,e,r){for(var n=new un(t),s=0,i=[];n.lt(e)&&s<1e5;)i.push(n.toNumber()),n=n.add(r),s++;return i}var put=uL(function(t,e,r){var n=+t,s=+e;return n+r*(s-n)}),mut=uL(function(t,e,r){var n=e-+t;return n=n||1/0,(r-t)/n}),gut=uL(function(t,e,r){var n=e-+t;return n=n||1/0,Math.max(0,Math.min(1,(r-t)/n))});const dL={rangeStep:fut,getDigitCount:hut,interpolateNumber:put,uninterpolateNumber:mut,uninterpolateTruncation:gut};function Cz(t){return vut(t)||yut(t)||V0e(t)||xut()}function xut(){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 yut(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function vut(t){if(Array.isArray(t))return Ez(t)}function ek(t,e){return jut(t)||wut(t,e)||V0e(t,e)||but()}function but(){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 V0e(t,e){if(t){if(typeof t=="string")return Ez(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 Ez(t,e)}}function Ez(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 wut(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](),l;!(n=(l=a.next()).done)&&(r.push(l.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 jut(t){if(Array.isArray(t))return t}function q0e(t){var e=ek(t,2),r=e[0],n=e[1],s=r,i=n;return r>n&&(s=n,i=r),[s,i]}function G0e(t,e,r){if(t.lte(0))return new un(0);var n=dL.getDigitCount(t.toNumber()),s=new un(10).pow(n),i=t.div(s),a=n!==1?.05:.1,l=new un(Math.ceil(i.div(a).toNumber())).add(r).mul(a),c=l.mul(s);return e?c:new un(Math.ceil(c))}function Sut(t,e,r){var n=1,s=new un(t);if(!s.isint()&&r){var i=Math.abs(t);i<1?(n=new un(10).pow(dL.getDigitCount(t)-1),s=new un(Math.floor(s.div(n).toNumber())).mul(n)):i>1&&(s=new un(Math.floor(t)))}else t===0?s=new un(Math.floor((e-1)/2)):r||(s=new un(Math.floor(t)));var a=Math.floor((e-1)/2),l=dut(uut(function(c){return s.add(new un(c-a).mul(n)).toNumber()}),Nz);return l(0,e)}function K0e(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 un(0),tickMin:new un(0),tickMax:new un(0)};var i=G0e(new un(e).sub(t).div(r-1),n,s),a;t<=0&&e>=0?a=new un(0):(a=new un(t).add(e).div(2),a=a.sub(new un(a).mod(i)));var l=Math.ceil(a.sub(t).div(i).toNumber()),c=Math.ceil(new un(e).sub(a).div(i).toNumber()),u=l+c+1;return u>r?K0e(t,e,r,n,s+1):(u<r&&(c=e>0?c+(r-u):c,l=e>0?l:l+(r-u)),{step:i,tickMin:a.sub(new un(l).mul(i)),tickMax:a.add(new un(c).mul(i))})}function _ut(t){var e=ek(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),l=q0e([r,n]),c=ek(l,2),u=c[0],d=c[1];if(u===-1/0||d===1/0){var h=d===1/0?[u].concat(Cz(Nz(0,s-1).map(function(){return 1/0}))):[].concat(Cz(Nz(0,s-1).map(function(){return-1/0})),[d]);return r>n?kz(h):h}if(u===d)return Sut(u,s,i);var f=K0e(u,d,a,i),p=f.step,m=f.tickMin,g=f.tickMax,y=dL.rangeStep(m,g.add(new un(.1).mul(p)),p);return r>n?kz(y):y}function Nut(t,e){var r=ek(t,2),n=r[0],s=r[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=q0e([n,s]),l=ek(a,2),c=l[0],u=l[1];if(c===-1/0||u===1/0)return[n,s];if(c===u)return[c];var d=Math.max(e,2),h=G0e(new un(u).sub(c).div(d-1),i,0),f=[].concat(Cz(dL.rangeStep(new un(c),new un(u).sub(new un(.99).mul(h)),h)),[u]);return n>s?kz(f):f}var kut=W0e(_ut),Cut=W0e(Nut),Eut="Invariant failed";function S1(t,e){throw new Error(Eut)}var Aut=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function _1(t){"@babel/helpers - typeof";return _1=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},_1(t)}function wR(){return wR=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},wR.apply(this,arguments)}function Tut(t,e){return Out(t)||Rut(t,e)||Iut(t,e)||Put()}function Put(){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 Iut(t,e){if(t){if(typeof t=="string")return mte(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 mte(t,e)}}function mte(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 Rut(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function Out(t){if(Array.isArray(t))return t}function Mut(t,e){if(t==null)return{};var r=Dut(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 Dut(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 Lut(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function $ut(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,Q0e(n.key),n)}}function Fut(t,e,r){return e&&$ut(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function But(t,e,r){return e=jR(e),zut(t,Y0e()?Reflect.construct(e,r||[],jR(t).constructor):e.apply(t,r))}function zut(t,e){if(e&&(_1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Uut(t)}function Uut(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Y0e(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Y0e=function(){return!!t})()}function jR(t){return jR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},jR(t)}function Hut(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&&Az(t,e)}function Az(t,e){return Az=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},Az(t,e)}function X0e(t,e,r){return e=Q0e(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Q0e(t){var e=Wut(t,"string");return _1(e)=="symbol"?e:e+""}function Wut(t,e){if(_1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(_1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var wq=function(t){function e(){return Lut(this,e),But(this,e,arguments)}return Hut(e,t),Fut(e,[{key:"render",value:function(){var n=this.props,s=n.offset,i=n.layout,a=n.width,l=n.dataKey,c=n.data,u=n.dataPointFormatter,d=n.xAxis,h=n.yAxis,f=Mut(n,Aut),p=cr(f,!1);this.props.direction==="x"&&d.type!=="number"&&S1();var m=c.map(function(g){var y=u(g,l),x=y.x,v=y.y,b=y.value,w=y.errorVal;if(!w)return null;var j=[],N,C;if(Array.isArray(w)){var A=Tut(w,2);N=A[0],C=A[1]}else N=C=w;if(i==="vertical"){var E=d.scale,O=v+s,$=O+a,T=O-a,M=E(b-N),k=E(b+C);j.push({x1:k,y1:$,x2:k,y2:T}),j.push({x1:M,y1:O,x2:k,y2:O}),j.push({x1:M,y1:$,x2:M,y2:T})}else if(i==="horizontal"){var D=h.scale,K=x+s,H=K-a,ee=K+a,V=D(b-N),B=D(b+C);j.push({x1:H,y1:B,x2:ee,y2:B}),j.push({x1:K,y1:V,x2:K,y2:B}),j.push({x1:H,y1:V,x2:ee,y2:V})}return ve.createElement(vs,wR({className:"recharts-errorBar",key:"bar-".concat(j.map(function(z){return"".concat(z.x1,"-").concat(z.x2,"-").concat(z.y1,"-").concat(z.y2)}))},p),j.map(function(z){return ve.createElement("line",wR({},z,{key:"line-".concat(z.x1,"-").concat(z.x2,"-").concat(z.y1,"-").concat(z.y2)}))}))});return ve.createElement(vs,{className:"recharts-errorBars"},m)}}])}(ve.Component);X0e(wq,"defaultProps",{stroke:"black",strokeWidth:1.5,width:5,offset:0,layout:"horizontal"});X0e(wq,"displayName","ErrorBar");function tk(t){"@babel/helpers - typeof";return tk=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},tk(t)}function gte(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 Cg(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?gte(Object(r),!0).forEach(function(n){Vut(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):gte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Vut(t,e,r){return e=qut(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qut(t){var e=Gut(t,"string");return tk(e)=="symbol"?e:e+""}function Gut(t,e){if(tk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(tk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Z0e=function(e){var r=e.children,n=e.formattedGraphicalItems,s=e.legendWidth,i=e.legendContent,a=$l(r,b0);if(!a)return null;var l=b0.defaultProps,c=l!==void 0?Cg(Cg({},l),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?Cg(Cg({},f),h.props):{},m=p.dataKey,g=p.name,y=p.legendType,x=p.hide;return{inactive:x,dataKey:m,type:c.iconType||y||"square",color:jq(h),value:g||m,payload:p}}),Cg(Cg(Cg({},c),b0.getWithHeight(a,s)),{},{payload:u,item:a})};function rk(t){"@babel/helpers - typeof";return rk=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},rk(t)}function xte(t){return Qut(t)||Xut(t)||Yut(t)||Kut()}function Kut(){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 Yut(t,e){if(t){if(typeof t=="string")return Tz(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 Tz(t,e)}}function Xut(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Qut(t){if(Array.isArray(t))return Tz(t)}function Tz(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 yte(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 ms(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?yte(Object(r),!0).forEach(function(n){j0(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):yte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function j0(t,e,r){return e=Zut(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zut(t){var e=Jut(t,"string");return rk(e)=="symbol"?e:e+""}function Jut(t,e){if(rk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(rk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function nl(t,e,r){return Rr(t)||Rr(e)?r:ni(e)?Xc(t,e,r):hr(e)?e(t):r}function F_(t,e,r,n){var s=Xct(t,function(l){return nl(l,e)});if(r==="number"){var i=s.filter(function(l){return gt(l)||parseFloat(l)});return i.length?[cL(i),lL(i)]:[1/0,-1/0]}var a=n?s.filter(function(l){return!Rr(l)}):s;return a.map(function(l){return ni(l)||l instanceof Date?l:""})}var edt=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,l=(r=n==null?void 0:n.length)!==null&&r!==void 0?r:0;if(l<=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<l;u++){var d=u>0?s[u-1].coordinate:s[l-1].coordinate,h=s[u].coordinate,f=u>=l-1?s[0].coordinate:s[u+1].coordinate,p=void 0;if(Yl(h-d)!==Yl(f-h)){var m=[];if(Yl(f-h)===Yl(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 y=f+c[1]-c[0];m[0]=Math.min(h,(y+h)/2),m[1]=Math.max(h,(y+h)/2)}var x=[Math.min(h,(p+h)/2),Math.max(h,(p+h)/2)];if(e>x[0]&&e<=x[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<l;w++)if(w===0&&e<=(n[w].coordinate+n[w+1].coordinate)/2||w>0&&w<l-1&&e>(n[w].coordinate+n[w-1].coordinate)/2&&e<=(n[w].coordinate+n[w+1].coordinate)/2||w===l-1&&e>(n[w].coordinate+n[w-1].coordinate)/2){a=n[w].index;break}return a},jq=function(e){var r,n=e,s=n.type.displayName,i=(r=e.type)!==null&&r!==void 0&&r.defaultProps?ms(ms({},e.type.defaultProps),e.props):e.props,a=i.stroke,l=i.fill,c;switch(s){case"Line":c=a;break;case"Area":case"Radar":c=a&&a!=="none"?a:l;break;default:c=l;break}return c},tdt=function(e){var r=e.barSize,n=e.totalSize,s=e.stackGroups,i=s===void 0?{}:s;if(!i)return{};for(var a={},l=Object.keys(i),c=0,u=l.length;c<u;c++)for(var d=i[l[c]].stackGroups,h=Object.keys(d),f=0,p=h.length;f<p;f++){var m=d[h[f]],g=m.items,y=m.cateAxisId,x=g.filter(function(C){return Kh(C.type).indexOf("Bar")>=0});if(x&&x.length){var v=x[0].type.defaultProps,b=v!==void 0?ms(ms({},v),x[0].props):x[0].props,w=b.barSize,j=b[y];a[j]||(a[j]=[]);var N=Rr(w)?r:w;a[j].push({item:x[0],stackList:x.slice(1),barSize:Rr(N)?void 0:vo(N,n,0)})}}return a},rdt=function(e){var r=e.barGap,n=e.barCategoryGap,s=e.bandSize,i=e.sizeList,a=i===void 0?[]:i,l=e.maxBarSize,c=a.length;if(c<1)return null;var u=vo(r,s,0,!0),d,h=[];if(a[0].barSize===+a[0].barSize){var f=!1,p=s/c,m=a.reduce(function(w,j){return w+j.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,y={offset:g-u,size:0};d=a.reduce(function(w,j){var N={item:j.item,position:{offset:y.offset+y.size+u,size:f?p:j.barSize}},C=[].concat(xte(w),[N]);return y=C[C.length-1].position,j.stackList&&j.stackList.length&&j.stackList.forEach(function(A){C.push({item:A,position:y})}),C},h)}else{var x=vo(n,s,0,!0);s-2*x-(c-1)*u<=0&&(u=0);var v=(s-2*x-(c-1)*u)/c;v>1&&(v>>=0);var b=l===+l?Math.min(v,l):v;d=a.reduce(function(w,j,N){var C=[].concat(xte(w),[{item:j.item,position:{offset:x+(v+u)*N+(v-b)/2,size:b}}]);return j.stackList&&j.stackList.length&&j.stackList.forEach(function(A){C.push({item:A,position:C[C.length-1].position})}),C},h)}return d},ndt=function(e,r,n,s){var i=n.children,a=n.width,l=n.margin,c=a-(l.left||0)-(l.right||0),u=Z0e({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"&&gt(e[p]))return ms(ms({},e),{},j0({},p,e[p]+(h||0)));if((g==="horizontal"||g==="vertical"&&p==="center")&&m!=="middle"&&gt(e[m]))return ms(ms({},e),{},j0({},m,e[m]+(f||0)))}return e},sdt=function(e,r,n){return Rr(r)?!0:e==="horizontal"?r==="yAxis":e==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},J0e=function(e,r,n,s,i){var a=r.props.children,l=od(a,wq).filter(function(u){return sdt(s,i,u.props.direction)});if(l&&l.length){var c=l.map(function(u){return u.props.dataKey});return e.reduce(function(u,d){var h=nl(d,n);if(Rr(h))return u;var f=Array.isArray(h)?[cL(h),lL(h)]:[h,h],p=c.reduce(function(m,g){var y=nl(d,g,0),x=f[0]-Math.abs(Array.isArray(y)?y[0]:y),v=f[1]+Math.abs(Array.isArray(y)?y[1]:y);return[Math.min(x,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},idt=function(e,r,n,s,i){var a=r.map(function(l){return J0e(e,l,n,i,s)}).filter(function(l){return!Rr(l)});return a&&a.length?a.reduce(function(l,c){return[Math.min(l[0],c[0]),Math.max(l[1],c[1])]},[1/0,-1/0]):null},ewe=function(e,r,n,s,i){var a=r.map(function(c){var u=c.props.dataKey;return n==="number"&&u&&J0e(e,c,u,s)||F_(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 l={};return a.reduce(function(c,u){for(var d=0,h=u.length;d<h;d++)l[u[d]]||(l[u[d]]=!0,c.push(u[d]));return c},[])},twe=function(e,r){return e==="horizontal"&&r==="xAxis"||e==="vertical"&&r==="yAxis"||e==="centric"&&r==="angleAxis"||e==="radial"&&r==="radiusAxis"},US=function(e,r,n){if(!e)return null;var s=e.scale,i=e.duplicateDomain,a=e.type,l=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"&&(l==null?void 0:l.length)>=2?Yl(l[0]-l[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!ZE(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}})},p3=new WeakMap,vT=function(e,r){if(typeof r!="function")return e;p3.has(e)||p3.set(e,new WeakMap);var n=p3.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},adt=function(e,r,n){var s=e.scale,i=e.type,a=e.layout,l=e.axisType;if(s==="auto")return a==="radial"&&l==="radiusAxis"?{scale:KN(),realScaleType:"band"}:a==="radial"&&l==="angleAxis"?{scale:gR(),realScaleType:"linear"}:i==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:$_(),realScaleType:"point"}:i==="category"?{scale:KN(),realScaleType:"band"}:{scale:gR(),realScaleType:"linear"};if(QE(s)){var c="scale".concat(KD(s));return{scale:(dte[c]||$_)(),realScaleType:dte[c]?c:"point"}}return hr(s)?{scale:s}:{scale:$_(),realScaleType:"point"}},vte=1e-4,odt=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])-vte,a=Math.max(s[0],s[1])+vte,l=e(r[0]),c=e(r[n-1]);(l<i||l>a||c<i||c>a)&&e.domain([r[0],r[n-1]])}},ldt=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,l=0;l<r;++l){var c=ZE(e[l][n][1])?e[l][n][0]:e[l][n][1];c>=0?(e[l][n][0]=i,e[l][n][1]=i+c,i=e[l][n][1]):(e[l][n][0]=a,e[l][n][1]=a+c,a=e[l][n][1])}},cdt=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 l=ZE(e[a][n][1])?e[a][n][0]:e[a][n][1];l>=0?(e[a][n][0]=i,e[a][n][1]=i+l,i=e[a][n][1]):(e[a][n][0]=0,e[a][n][1]=0)}},udt={sign:ldt,expand:NQe,none:p1,silhouette:kQe,wiggle:CQe,positive:cdt},ddt=function(e,r,n){var s=r.map(function(l){return l.props.dataKey}),i=udt[n],a=_Qe().keys(s).value(function(l,c){return+nl(l,c,0)}).order(tz).offset(i);return a(e)},hdt=function(e,r,n,s,i,a){if(!e)return null;var l=a?r.reverse():r,c={},u=l.reduce(function(h,f){var p,m=(p=f.type)!==null&&p!==void 0&&p.defaultProps?ms(ms({},f.type.defaultProps),f.props):f.props,g=m.stackId,y=m.hide;if(y)return h;var x=m[n],v=h[x]||{hasStack:!1,stackGroups:{}};if(ni(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[qD("_stackId_")]={numericAxisId:n,cateAxisId:s,items:[f]};return ms(ms({},h),{},j0({},x,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,y){var x=p.stackGroups[y];return ms(ms({},g),{},j0({},y,{numericAxisId:n,cateAxisId:s,items:x.items,stackedData:ddt(e,x.items,i)}))},m)}return ms(ms({},h),{},j0({},f,p))},d)},fdt=function(e,r){var n=r.realScaleType,s=r.type,i=r.tickCount,a=r.originalDomain,l=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=kut(u,i,l);return e.domain([cL(d),lL(d)]),{niceTicks:d}}if(i&&s==="number"){var h=e.domain(),f=Cut(h,i,l);return{niceTicks:f}}return null},pdt=function(e,r){var n,s=(n=e.type)!==null&&n!==void 0&&n.defaultProps?ms(ms({},e.type.defaultProps),e.props):e.props,i=s.stackId;if(ni(i)){var a=r[i];if(a){var l=a.items.indexOf(e);return l>=0?a.stackedData[l]:null}}return null},mdt=function(e){return e.reduce(function(r,n){return[cL(n.concat([r[0]]).filter(gt)),lL(n.concat([r[1]]).filter(gt))]},[1/0,-1/0])},rwe=function(e,r,n){return Object.keys(e).reduce(function(s,i){var a=e[i],l=a.stackedData,c=l.reduce(function(u,d){var h=mdt(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})},bte=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,wte=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Pz=function(e,r,n){if(hr(e))return e(r,n);if(!Array.isArray(e))return r;var s=[];if(gt(e[0]))s[0]=n?e[0]:Math.min(e[0],r[0]);else if(bte.test(e[0])){var i=+bte.exec(e[0])[1];s[0]=r[0]-i}else hr(e[0])?s[0]=e[0](r[0]):s[0]=r[0];if(gt(e[1]))s[1]=n?e[1]:Math.max(e[1],r[1]);else if(wte.test(e[1])){var a=+wte.exec(e[1])[1];s[1]=r[1]+a}else hr(e[1])?s[1]=e[1](r[1]):s[1]=r[1];return s},Iz=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=KV(r,function(h){return h.coordinate}),a=1/0,l=1,c=i.length;l<c;l++){var u=i[l],d=i[l-1];a=Math.min((u.coordinate||0)-(d.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0},jte=function(e,r,n){return!e||!e.length||yq(e,Xc(n,"type.defaultProps.domain"))?r:e},gdt=function(e,r){var n=e.type.defaultProps?ms(ms({},e.type.defaultProps),e.props):e.props,s=n.dataKey,i=n.name,a=n.unit,l=n.formatter,c=n.tooltipType,u=n.chartType,d=n.hide;return ms(ms({},cr(e,!1)),{},{dataKey:s,unit:a,formatter:l,name:i||s,color:jq(e),value:nl(r,s),type:c,payload:r,chartType:u,hide:d})};function nk(t){"@babel/helpers - typeof";return nk=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},nk(t)}function Ste(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 Yd(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ste(Object(r),!0).forEach(function(n){nwe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ste(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function nwe(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=ydt(t,"string");return nk(e)=="symbol"?e:e+""}function ydt(t,e){if(nk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(nk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function vdt(t,e){return Sdt(t)||jdt(t,e)||wdt(t,e)||bdt()}function bdt(){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 wdt(t,e){if(t){if(typeof t=="string")return _te(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 _te(t,e)}}function _te(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 jdt(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function Sdt(t){if(Array.isArray(t))return t}var SR=Math.PI/180,_dt=function(e){return e*180/Math.PI},In=function(e,r,n,s){return{x:e+Math.cos(-SR*s)*n,y:r+Math.sin(-SR*s)*n}},swe=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},Ndt=function(e,r,n,s,i){var a=e.width,l=e.height,c=e.startAngle,u=e.endAngle,d=vo(e.cx,a,a/2),h=vo(e.cy,l,l/2),f=swe(a,l,n),p=vo(e.innerRadius,f,0),m=vo(e.outerRadius,f,f*.8),g=Object.keys(r);return g.reduce(function(y,x){var v=r[x],b=v.domain,w=v.reversed,j;if(Rr(v.range))s==="angleAxis"?j=[c,u]:s==="radiusAxis"&&(j=[p,m]),w&&(j=[j[1],j[0]]);else{j=v.range;var N=j,C=vdt(N,2);c=C[0],u=C[1]}var A=adt(v,i),E=A.realScaleType,O=A.scale;O.domain(b).range(j),odt(O);var $=fdt(O,Yd(Yd({},v),{},{realScaleType:E})),T=Yd(Yd(Yd({},v),$),{},{range:j,radius:m,realScaleType:E,scale:O,cx:d,cy:h,innerRadius:p,outerRadius:m,startAngle:c,endAngle:u});return Yd(Yd({},y),{},nwe({},x,T))},{})},kdt=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))},Cdt=function(e,r){var n=e.x,s=e.y,i=r.cx,a=r.cy,l=kdt({x:n,y:s},{x:i,y:a});if(l<=0)return{radius:l};var c=(n-i)/l,u=Math.acos(c);return s>a&&(u=2*Math.PI-u),{radius:l,angle:_dt(u),angleInRadian:u}},Edt=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}},Adt=function(e,r){var n=r.startAngle,s=r.endAngle,i=Math.floor(n/360),a=Math.floor(s/360),l=Math.min(i,a);return e+l*360},Nte=function(e,r){var n=e.x,s=e.y,i=Cdt({x:n,y:s},r),a=i.radius,l=i.angle,c=r.innerRadius,u=r.outerRadius;if(a<c||a>u)return!1;if(a===0)return!0;var d=Edt(r),h=d.startAngle,f=d.endAngle,p=l,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?Yd(Yd({},r),{},{radius:a,angle:Adt(p,r)}):null},iwe=function(e){return!S.isValidElement(e)&&!hr(e)&&typeof e!="boolean"?e.className:""};function sk(t){"@babel/helpers - typeof";return sk=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},sk(t)}var Tdt=["offset"];function Pdt(t){return Mdt(t)||Odt(t)||Rdt(t)||Idt()}function Idt(){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 Rdt(t,e){if(t){if(typeof t=="string")return Rz(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 Rz(t,e)}}function Odt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Mdt(t){if(Array.isArray(t))return Rz(t)}function Rz(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 Ddt(t,e){if(t==null)return{};var r=Ldt(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 Ldt(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 kte(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 qs(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?kte(Object(r),!0).forEach(function(n){$dt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):kte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function $dt(t,e,r){return e=Fdt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Fdt(t){var e=Bdt(t,"string");return sk(e)=="symbol"?e:e+""}function Bdt(t,e){if(sk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(sk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ik(){return ik=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},ik.apply(this,arguments)}var zdt=function(e){var r=e.value,n=e.formatter,s=Rr(e.children)?r:e.children;return hr(n)?n(s):s},Udt=function(e,r){var n=Yl(r-e),s=Math.min(Math.abs(r-e),360);return n*s},Hdt=function(e,r,n){var s=e.position,i=e.viewBox,a=e.offset,l=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,y=(h+f)/2,x=Udt(p,m),v=x>=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=x<=0?w:!w;var j=In(u,d,y,b),N=In(u,d,y,b+(w?1:-1)*359),C="M".concat(j.x,",").concat(j.y,`
    A`).concat(y,",").concat(y,",0,1,").concat(w?0:1,`,
    `).concat(N.x,",").concat(N.y),A=Rr(e.id)?qD("recharts-radial-line-"):e.id;return ve.createElement("text",ik({},n,{dominantBaseline:"central",className:$r("recharts-radial-bar-label",l)}),ve.createElement("defs",null,ve.createElement("path",{id:A,d:C})),ve.createElement("textPath",{xlinkHref:"#".concat(A)},r))},Wdt=function(e){var r=e.viewBox,n=e.offset,s=e.position,i=r,a=i.cx,l=i.cy,c=i.innerRadius,u=i.outerRadius,d=i.startAngle,h=i.endAngle,f=(d+h)/2;if(s==="outside"){var p=In(a,l,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:l,textAnchor:"middle",verticalAnchor:"middle"};if(s==="centerTop")return{x:a,y:l,textAnchor:"middle",verticalAnchor:"start"};if(s==="centerBottom")return{x:a,y:l,textAnchor:"middle",verticalAnchor:"end"};var y=(c+u)/2,x=In(a,l,y,f),v=x.x,b=x.y;return{x:v,y:b,textAnchor:"middle",verticalAnchor:"middle"}},Vdt=function(e){var r=e.viewBox,n=e.parentViewBox,s=e.offset,i=e.position,a=r,l=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,y=g*s,x=g>0?"end":"start",v=g>0?"start":"end";if(i==="top"){var b={x:l+u/2,y:c-h*s,textAnchor:"middle",verticalAnchor:p};return qs(qs({},b),n?{height:Math.max(c-n.y,0),width:u}:{})}if(i==="bottom"){var w={x:l+u/2,y:c+d+f,textAnchor:"middle",verticalAnchor:m};return qs(qs({},w),n?{height:Math.max(n.y+n.height-(c+d),0),width:u}:{})}if(i==="left"){var j={x:l-y,y:c+d/2,textAnchor:x,verticalAnchor:"middle"};return qs(qs({},j),n?{width:Math.max(j.x-n.x,0),height:d}:{})}if(i==="right"){var N={x:l+u+y,y:c+d/2,textAnchor:v,verticalAnchor:"middle"};return qs(qs({},N),n?{width:Math.max(n.x+n.width-N.x,0),height:d}:{})}var C=n?{width:u,height:d}:{};return i==="insideLeft"?qs({x:l+y,y:c+d/2,textAnchor:v,verticalAnchor:"middle"},C):i==="insideRight"?qs({x:l+u-y,y:c+d/2,textAnchor:x,verticalAnchor:"middle"},C):i==="insideTop"?qs({x:l+u/2,y:c+f,textAnchor:"middle",verticalAnchor:m},C):i==="insideBottom"?qs({x:l+u/2,y:c+d-f,textAnchor:"middle",verticalAnchor:p},C):i==="insideTopLeft"?qs({x:l+y,y:c+f,textAnchor:v,verticalAnchor:m},C):i==="insideTopRight"?qs({x:l+u-y,y:c+f,textAnchor:x,verticalAnchor:m},C):i==="insideBottomLeft"?qs({x:l+y,y:c+d-f,textAnchor:v,verticalAnchor:p},C):i==="insideBottomRight"?qs({x:l+u-y,y:c+d-f,textAnchor:x,verticalAnchor:p},C):bj(i)&&(gt(i.x)||lx(i.x))&&(gt(i.y)||lx(i.y))?qs({x:l+vo(i.x,u),y:c+vo(i.y,d),textAnchor:"end",verticalAnchor:"end"},C):qs({x:l+u/2,y:c+d/2,textAnchor:"middle",verticalAnchor:"middle"},C)},qdt=function(e){return"cx"in e&&gt(e.cx)};function Zi(t){var e=t.offset,r=e===void 0?5:e,n=Ddt(t,Tdt),s=qs({offset:r},n),i=s.viewBox,a=s.position,l=s.value,c=s.children,u=s.content,d=s.className,h=d===void 0?"":d,f=s.textBreakAll;if(!i||Rr(l)&&Rr(c)&&!S.isValidElement(u)&&!hr(u))return null;if(S.isValidElement(u))return S.cloneElement(u,s);var p;if(hr(u)){if(p=S.createElement(u,s),S.isValidElement(p))return p}else p=zdt(s);var m=qdt(i),g=cr(s,!0);if(m&&(a==="insideStart"||a==="insideEnd"||a==="end"))return Hdt(s,p,g);var y=m?Wdt(s):Vdt(s);return ve.createElement(v1,ik({className:$r("recharts-label",h)},g,y,{breakAll:f}),p)}Zi.displayName="Label";var awe=function(e){var r=e.cx,n=e.cy,s=e.angle,i=e.startAngle,a=e.endAngle,l=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,y=e.height,x=e.clockWise,v=e.labelViewBox;if(v)return v;if(gt(g)&&gt(y)){if(gt(h)&&gt(f))return{x:h,y:f,width:g,height:y};if(gt(p)&&gt(m))return{x:p,y:m,width:g,height:y}}return gt(h)&&gt(f)?{x:h,y:f,width:0,height:0}:gt(r)&&gt(n)?{cx:r,cy:n,startAngle:i||s||0,endAngle:a||s||0,innerRadius:u||0,outerRadius:d||c||l||0,clockWise:x}:e.viewBox?e.viewBox:{}},Gdt=function(e,r){return e?e===!0?ve.createElement(Zi,{key:"label-implicit",viewBox:r}):ni(e)?ve.createElement(Zi,{key:"label-implicit",viewBox:r,value:e}):S.isValidElement(e)?e.type===Zi?S.cloneElement(e,{key:"label-implicit",viewBox:r}):ve.createElement(Zi,{key:"label-implicit",content:e,viewBox:r}):hr(e)?ve.createElement(Zi,{key:"label-implicit",content:e,viewBox:r}):bj(e)?ve.createElement(Zi,ik({viewBox:r},e,{key:"label-implicit"})):null:null},Kdt=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=awe(e),a=od(s,Zi).map(function(c,u){return S.cloneElement(c,{viewBox:r||i,key:"label-".concat(u)})});if(!n)return a;var l=Gdt(e.label,r||i);return[l].concat(Pdt(a))};Zi.parseViewBox=awe;Zi.renderCallByParent=Kdt;function Ydt(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}var Xdt=Ydt;const Qdt=Er(Xdt);function ak(t){"@babel/helpers - typeof";return ak=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},ak(t)}var Zdt=["valueAccessor"],Jdt=["data","dataKey","clockWise","id","textBreakAll"];function eht(t){return sht(t)||nht(t)||rht(t)||tht()}function tht(){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 rht(t,e){if(t){if(typeof t=="string")return Oz(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 Oz(t,e)}}function nht(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function sht(t){if(Array.isArray(t))return Oz(t)}function Oz(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 _R(){return _R=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},_R.apply(this,arguments)}function Cte(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 Ete(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Cte(Object(r),!0).forEach(function(n){iht(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Cte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function iht(t,e,r){return e=aht(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function aht(t){var e=oht(t,"string");return ak(e)=="symbol"?e:e+""}function oht(t,e){if(ak(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(ak(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ate(t,e){if(t==null)return{};var r=lht(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 lht(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 cht=function(e){return Array.isArray(e.value)?Qdt(e.value):e.value};function Wy(t){var e=t.valueAccessor,r=e===void 0?cht:e,n=Ate(t,Zdt),s=n.data,i=n.dataKey,a=n.clockWise,l=n.id,c=n.textBreakAll,u=Ate(n,Jdt);return!s||!s.length?null:ve.createElement(vs,{className:"recharts-label-list"},s.map(function(d,h){var f=Rr(i)?r(d,h):nl(d&&d.payload,i),p=Rr(l)?{}:{id:"".concat(l,"-").concat(h)};return ve.createElement(Zi,_R({},cr(d,!0),u,p,{parentViewBox:d.parentViewBox,value:f,textBreakAll:c,viewBox:Zi.parseViewBox(Rr(a)?d:Ete(Ete({},d),{},{clockWise:a})),key:"label-".concat(h),index:h}))}))}Wy.displayName="LabelList";function uht(t,e){return t?t===!0?ve.createElement(Wy,{key:"labelList-implicit",data:e}):ve.isValidElement(t)||hr(t)?ve.createElement(Wy,{key:"labelList-implicit",data:e,content:t}):bj(t)?ve.createElement(Wy,_R({data:e},t,{key:"labelList-implicit"})):null:null}function dht(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=od(n,Wy).map(function(a,l){return S.cloneElement(a,{data:e,key:"labelList-".concat(l)})});if(!r)return s;var i=uht(t.label,e);return[i].concat(eht(s))}Wy.renderCallByParent=dht;function ok(t){"@babel/helpers - typeof";return ok=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},ok(t)}function Mz(){return Mz=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},Mz.apply(this,arguments)}function Tte(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 Pte(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Tte(Object(r),!0).forEach(function(n){hht(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Tte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function hht(t,e,r){return e=fht(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function fht(t){var e=pht(t,"string");return ok(e)=="symbol"?e:e+""}function pht(t,e){if(ok(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(ok(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var mht=function(e,r){var n=Yl(r-e),s=Math.min(Math.abs(r-e),359.999);return n*s},bT=function(e){var r=e.cx,n=e.cy,s=e.radius,i=e.angle,a=e.sign,l=e.isExternal,c=e.cornerRadius,u=e.cornerIsExternal,d=c*(l?1:-1)+s,h=Math.asin(c/d)/SR,f=u?i:i+a*h,p=In(r,n,d,f),m=In(r,n,s,f),g=u?i-a*h:i,y=In(r,n,d*Math.cos(h*SR),g);return{center:p,circleTangency:m,lineTangency:y,theta:h}},owe=function(e){var r=e.cx,n=e.cy,s=e.innerRadius,i=e.outerRadius,a=e.startAngle,l=e.endAngle,c=mht(a,l),u=a+c,d=In(r,n,i,a),h=In(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=In(r,n,s,a),m=In(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},ght=function(e){var r=e.cx,n=e.cy,s=e.innerRadius,i=e.outerRadius,a=e.cornerRadius,l=e.forceCornerRadius,c=e.cornerIsExternal,u=e.startAngle,d=e.endAngle,h=Yl(d-u),f=bT({cx:r,cy:n,radius:i,angle:u,sign:h,cornerRadius:a,cornerIsExternal:c}),p=f.circleTangency,m=f.lineTangency,g=f.theta,y=bT({cx:r,cy:n,radius:i,angle:d,sign:-h,cornerRadius:a,cornerIsExternal:c}),x=y.circleTangency,v=y.lineTangency,b=y.theta,w=c?Math.abs(u-d):Math.abs(u-d)-g-b;if(w<0)return l?"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
      `):owe({cx:r,cy:n,innerRadius:s,outerRadius:i,startAngle:u,endAngle:d});var j="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(x.x,",").concat(x.y,`
    A`).concat(a,",").concat(a,",0,0,").concat(+(h<0),",").concat(v.x,",").concat(v.y,`
  `);if(s>0){var N=bT({cx:r,cy:n,radius:s,angle:u,sign:h,isExternal:!0,cornerRadius:a,cornerIsExternal:c}),C=N.circleTangency,A=N.lineTangency,E=N.theta,O=bT({cx:r,cy:n,radius:s,angle:d,sign:-h,isExternal:!0,cornerRadius:a,cornerIsExternal:c}),$=O.circleTangency,T=O.lineTangency,M=O.theta,k=c?Math.abs(u-d):Math.abs(u-d)-E-M;if(k<0&&a===0)return"".concat(j,"L").concat(r,",").concat(n,"Z");j+="L".concat(T.x,",").concat(T.y,`
      A`).concat(a,",").concat(a,",0,0,").concat(+(h<0),",").concat($.x,",").concat($.y,`
      A`).concat(s,",").concat(s,",0,").concat(+(k>180),",").concat(+(h>0),",").concat(C.x,",").concat(C.y,`
      A`).concat(a,",").concat(a,",0,0,").concat(+(h<0),",").concat(A.x,",").concat(A.y,"Z")}else j+="L".concat(r,",").concat(n,"Z");return j},xht={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},lwe=function(e){var r=Pte(Pte({},xht),e),n=r.cx,s=r.cy,i=r.innerRadius,a=r.outerRadius,l=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=$r("recharts-sector",f),m=a-i,g=vo(l,m,0,!0),y;return g>0&&Math.abs(d-h)<360?y=ght({cx:n,cy:s,innerRadius:i,outerRadius:a,cornerRadius:Math.min(g,m/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:d,endAngle:h}):y=owe({cx:n,cy:s,innerRadius:i,outerRadius:a,startAngle:d,endAngle:h}),ve.createElement("path",Mz({},cr(r,!0),{className:p,d:y,role:"img"}))};function lk(t){"@babel/helpers - typeof";return lk=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},lk(t)}function Dz(){return Dz=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},Dz.apply(this,arguments)}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 Rte(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){yht(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 yht(t,e,r){return e=vht(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vht(t){var e=bht(t,"string");return lk(e)=="symbol"?e:e+""}function bht(t,e){if(lk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(lk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ote={curveBasisClosed:fQe,curveBasisOpen:pQe,curveBasis:hQe,curveBumpX:ZXe,curveBumpY:JXe,curveLinearClosed:mQe,curveLinear:XD,curveMonotoneX:gQe,curveMonotoneY:xQe,curveNatural:yQe,curveStep:vQe,curveStepAfter:wQe,curveStepBefore:bQe},wT=function(e){return e.x===+e.x&&e.y===+e.y},aS=function(e){return e.x},oS=function(e){return e.y},wht=function(e,r){if(hr(e))return e;var n="curve".concat(KD(e));return(n==="curveMonotone"||n==="curveBump")&&r?Ote["".concat(n).concat(r==="vertical"?"Y":"X")]:Ote[n]||XD},jht=function(e){var r=e.type,n=r===void 0?"linear":r,s=e.points,i=s===void 0?[]:s,a=e.baseLine,l=e.layout,c=e.connectNulls,u=c===void 0?!1:c,d=wht(n,l),h=u?i.filter(function(g){return wT(g)}):i,f;if(Array.isArray(a)){var p=u?a.filter(function(g){return wT(g)}):a,m=h.map(function(g,y){return Rte(Rte({},g),{},{base:p[y]})});return l==="vertical"?f=dT().y(oS).x1(aS).x0(function(g){return g.base.x}):f=dT().x(aS).y1(oS).y0(function(g){return g.base.y}),f.defined(wT).curve(d),f(m)}return l==="vertical"&&gt(a)?f=dT().y(oS).x1(aS).x0(a):gt(a)?f=dT().x(aS).y1(oS).y0(a):f=lbe().x(aS).y(oS),f.defined(wT).curve(d),f(h)},Lz=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?jht(e):s;return S.createElement("path",Dz({},cr(e,!1),YI(e),{className:$r("recharts-curve",r),d:a,ref:i}))},cwe={exports:{}},Sht="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",_ht=Sht,Nht=_ht;function uwe(){}function dwe(){}dwe.resetWarningCache=uwe;var kht=function(){function t(n,s,i,a,l,c){if(c!==Nht){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:dwe,resetWarningCache:uwe};return r.PropTypes=r,r};cwe.exports=kht();var Cht=cwe.exports;const Yr=Er(Cht),{getOwnPropertyNames:Eht,getOwnPropertySymbols:Aht}=Object,{hasOwnProperty:Tht}=Object.prototype;function lS(t,e){return function(n,s,i){return t(n,s,i)&&e(n,s,i)}}function cS(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),l=i.get(n);if(a&&l)return a===n&&l===r;i.set(r,n),i.set(n,r);const c=t(r,n,s);return i.delete(r),i.delete(n),c}}function Pht(t){return t!=null?t[Symbol.toStringTag]:void 0}function Mte(t){return Eht(t).concat(Aht(t))}const Iht=Object.hasOwn||((t,e)=>Tht.call(t,e));function Dv(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const Rht="__v",Oht="__o",Mht="_owner",{getOwnPropertyDescriptor:$z,keys:Dte}=Object,Dht=$z(Object.getPrototypeOf(Int8Array.prototype),Symbol.toStringTag).get;function Lht(t,e){return t.byteLength===e.byteLength&&NR(new Uint8Array(t),new Uint8Array(e))}function $ht(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 Fht(t,e){return t.byteLength===e.byteLength&&NR(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Bht(t,e){return Dv(t.getTime(),e.getTime())}function Lte(t,e,r){return t.name===e.name&&t.message===e.message&&t.stack===e.stack&&r.equals(t.cause,e.cause,"cause","cause",t,e,r)}function zht(t,e){return t===e}function $te(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,l,c=0;for(;(a=i.next())&&!a.done;){const u=e.entries();let d=!1,h=0;for(;(l=u.next())&&!l.done;){if(s[h]){h++;continue}const f=a.value,p=l.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 Uht=Dv;function Fte(t,e,r){const n=Dte(t);let s=n.length;if(Dte(e).length!==s)return!1;for(;s-- >0;)if(!hwe(t,e,r,n[s]))return!1;return!0}function ib(t,e,r){const n=Mte(t);let s=n.length;if(Mte(e).length!==s)return!1;let i,a,l;for(;s-- >0;)if(i=n[s],!hwe(t,e,r,i)||(a=$z(t,i),l=$z(e,i),(a||l)&&(!a||!l||a.configurable!==l.configurable||a.enumerable!==l.enumerable||a.writable!==l.writable)))return!1;return!0}function Hht(t,e){return Dv(t.valueOf(),e.valueOf())}function Wht(t,e){return t.source===e.source&&t.flags===e.flags}function Bte(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,l;for(;(a=i.next())&&!a.done;){const c=e.values();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(!s[d]&&r.equals(a.value,l.value,a.value,l.value,t,e,r)){u=s[d]=!0;break}d++}if(!u)return!1}return!0}function NR(t,e){let r=t.length;if(e.length!==r||t.byteOffset!==e.byteOffset)return!1;const n=Dht.call(t);if(n==="Float64Array"||n==="Float32Array"||n==="Float16Array"){for(;r-- >0;)if(t[r]!==e[r]&&(t[r]===t[r]||e[r]===e[r]))return!1;return!0}for(;r-- >0;)if(t[r]!==e[r])return!1;return!0}function Vht(t,e){return t.href===e.href?!0:t.protocol===e.protocol&&t.username===e.username&&t.password===e.password&&t.host===e.host&&t.pathname===e.pathname&&t.hash===e.hash&&qht(t.searchParams,e.searchParams)}function qht(t,e){const r=t.toString(),n=e.toString();return r===n||zte(r)===zte(n)}function zte(t){return t.split("&").sort().join("&")}function hwe(t,e,r,n){return(n===Mht||n===Oht||n===Rht)&&(t.$$typeof||e.$$typeof)?!0:Iht(e,n)&&r.equals(t[n],e[n],n,n,t,e,r)}const Ght="[object ArrayBuffer]",Kht="[object Arguments]",Yht="[object Boolean]",Xht="[object DataView]",Qht="[object Date]",Zht="[object Error]",Jht="[object Map]",eft="[object Number]",tft="[object Object]",rft="[object RegExp]",nft="[object Set]",sft="[object String]",ift={"[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},aft="[object URL]",oft=Object.prototype.toString;function lft({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:r,areDatesEqual:n,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:a,areNumbersEqual:l,areObjectsEqual:c,arePrimitiveWrappersEqual:u,areRegExpsEqual:d,areSetsEqual:h,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(y,x,v){if(y===x)return!0;if(y==null||x==null)return!1;const b=typeof y;if(b!==typeof x)return!1;if(b!=="object")return b==="number"?l(y,x,v):b==="function"?i(y,x,v):!1;const w=y.constructor;if(w!==x.constructor)return!1;if(w===Object)return c(y,x,v);if(Array.isArray(y))return e(y,x,v);if(w===Date)return n(y,x,v);if(w===RegExp)return d(y,x,v);if(w===Map)return a(y,x,v);if(w===Set)return h(y,x,v);if(w==null)return c(y,x,v);const j=oft.call(y);if(j===Qht)return n(y,x,v);if(j===rft)return d(y,x,v);if(j===Jht)return a(y,x,v);if(j===nft)return h(y,x,v);if(j===tft)return typeof y.then!="function"&&typeof x.then!="function"&&c(y,x,v);if(j===aft)return p(y,x,v);if(j===Zht)return s(y,x,v);if(j===Kht)return c(y,x,v);if(ift[j])return f(y,x,v);if(j===Ght)return t(y,x,v);if(j===Xht)return r(y,x,v);if(j===Yht||j===eft||j===sft)return u(y,x,v);if(m){let N=m[j];if(!N){const C=Pht(y);C&&(N=m[C])}if(N)return N(y,x,v)}return!1}}function cft({circular:t,createCustomConfig:e,strict:r}){let n={areArrayBuffersEqual:Lht,areArraysEqual:r?ib:$ht,areDataViewsEqual:Fht,areDatesEqual:Bht,areErrorsEqual:r?lS(Lte,ib):lS(Lte,Fte),areFunctionsEqual:zht,areMapsEqual:r?lS($te,ib):$te,areNumbersEqual:Uht,areObjectsEqual:r?ib:Fte,arePrimitiveWrappersEqual:Hht,areRegExpsEqual:Wht,areSetsEqual:r?lS(Bte,ib):Bte,areTypedArraysEqual:r?lS(NR,ib):NR,areUrlsEqual:Vht,unknownTagComparators:void 0};if(e&&(n=Object.assign({},n,e(n))),t){const s=cS(n.areArraysEqual),i=cS(n.areErrorsEqual),a=cS(n.areMapsEqual),l=cS(n.areObjectsEqual),c=cS(n.areSetsEqual);n=Object.assign({},n,{areArraysEqual:s,areErrorsEqual:i,areMapsEqual:a,areObjectsEqual:l,areSetsEqual:c})}return n}function uft(t){return function(e,r,n,s,i,a,l){return t(e,r,l)}}function dft({circular:t,comparator:e,createState:r,equals:n,strict:s}){if(r)return function(l,c){const{cache:u=t?new WeakMap:void 0,meta:d}=r();return e(l,c,{cache:u,equals:n,meta:d,strict:s})};if(t)return function(l,c){return e(l,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(l,c){return e(l,c,i)}}const fwe=mg();mg({strict:!0});mg({circular:!0});mg({circular:!0,strict:!0});mg({createInternalComparator:()=>Dv});mg({strict:!0,createInternalComparator:()=>Dv});mg({circular:!0,createInternalComparator:()=>Dv});mg({circular:!0,createInternalComparator:()=>Dv,strict:!0});function mg(t={}){const{circular:e=!1,createInternalComparator:r,createState:n,strict:s=!1}=t,i=cft(t),a=lft(i),l=r?r(a):uft(a);return dft({circular:e,comparator:a,createState:n,equals:l,strict:s})}function hft(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function Ute(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):hft(s)};requestAnimationFrame(n)}function Fz(t){"@babel/helpers - typeof";return Fz=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},Fz(t)}function fft(t){return xft(t)||gft(t)||mft(t)||pft()}function pft(){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 mft(t,e){if(t){if(typeof t=="string")return Hte(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 Hte(t,e)}}function Hte(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 gft(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function xft(t){if(Array.isArray(t))return t}function yft(){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,l=fft(a),c=l[0],u=l.slice(1);if(typeof c=="number"){Ute(s.bind(null,u),c);return}s(c),Ute(s.bind(null,u));return}Fz(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 ck(t){"@babel/helpers - typeof";return ck=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},ck(t)}function Wte(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 Vte(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Wte(Object(r),!0).forEach(function(n){pwe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Wte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function pwe(t,e,r){return e=vft(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function vft(t){var e=bft(t,"string");return ck(e)==="symbol"?e:String(e)}function bft(t,e){if(ck(t)!=="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(ck(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var wft=function(e,r){return[Object.keys(e),Object.keys(r)].reduce(function(n,s){return n.filter(function(i){return s.includes(i)})})},jft=function(e){return e},Sft=function(e){return e.replace(/([A-Z])/g,function(r){return"-".concat(r.toLowerCase())})},B_=function(e,r){return Object.keys(r).reduce(function(n,s){return Vte(Vte({},n),{},pwe({},s,e(s,r[s])))},{})},qte=function(e,r,n){return e.map(function(s){return"".concat(Sft(s)," ").concat(r,"ms ").concat(n)}).join(",")};function _ft(t,e){return Cft(t)||kft(t,e)||mwe(t,e)||Nft()}function Nft(){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 kft(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function Cft(t){if(Array.isArray(t))return t}function Eft(t){return Pft(t)||Tft(t)||mwe(t)||Aft()}function Aft(){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 mwe(t,e){if(t){if(typeof t=="string")return Bz(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 Bz(t,e)}}function Tft(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Pft(t){if(Array.isArray(t))return Bz(t)}function Bz(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 kR=1e-4,gwe=function(e,r){return[0,3*e,3*r-6*e,3*e-3*r+1]},xwe=function(e,r){return e.map(function(n,s){return n*Math.pow(r,s)}).reduce(function(n,s){return n+s})},Gte=function(e,r){return function(n){var s=gwe(e,r);return xwe(s,n)}},Ift=function(e,r){return function(n){var s=gwe(e,r),i=[].concat(Eft(s.map(function(a,l){return a*l}).slice(1)),[0]);return xwe(i,n)}},Kte=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],l=r[3];if(r.length===1)switch(r[0]){case"linear":s=0,i=0,a=1,l=1;break;case"ease":s=.25,i=.1,a=.25,l=1;break;case"ease-in":s=.42,i=0,a=1,l=1;break;case"ease-out":s=.42,i=0,a=.58,l=1;break;case"ease-in-out":s=0,i=0,a=.58,l=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(y){return parseFloat(y)}),d=_ft(u,4);s=d[0],i=d[1],a=d[2],l=d[3]}}}var h=Gte(s,a),f=Gte(i,l),p=Ift(s,a),m=function(x){return x>1?1:x<0?0:x},g=function(x){for(var v=x>1?1:x,b=v,w=0;w<8;++w){var j=h(b)-v,N=p(b);if(Math.abs(j-v)<kR||N<kR)return f(b);b=m(b-j/N)}return f(b)};return g.isStepper=!1,g},Rft=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,l=a===void 0?17:a,c=function(d,h,f){var p=-(d-h)*n,m=f*i,g=f+(p-m)*l/1e3,y=f*l/1e3+d;return Math.abs(y-h)<kR&&Math.abs(g)<kR?[h,0]:[y,g]};return c.isStepper=!0,c.dt=l,c},Oft=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 Kte(s);case"spring":return Rft();default:if(s.split("(")[0]==="cubic-bezier")return Kte(s)}return typeof s=="function"?s:null};function uk(t){"@babel/helpers - typeof";return uk=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},uk(t)}function Yte(t){return Lft(t)||Dft(t)||ywe(t)||Mft()}function Mft(){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 Dft(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Lft(t){if(Array.isArray(t))return Uz(t)}function Xte(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 qi(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Xte(Object(r),!0).forEach(function(n){zz(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function zz(t,e,r){return e=$ft(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $ft(t){var e=Fft(t,"string");return uk(e)==="symbol"?e:String(e)}function Fft(t,e){if(uk(t)!=="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(uk(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bft(t,e){return Hft(t)||Uft(t,e)||ywe(t,e)||zft()}function zft(){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 ywe(t,e){if(t){if(typeof t=="string")return Uz(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 Uz(t,e)}}function Uz(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 Uft(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function Hft(t){if(Array.isArray(t))return t}var CR=function(e,r,n){return e+(r-e)*n},Hz=function(e){var r=e.from,n=e.to;return r!==n},Wft=function t(e,r,n){var s=B_(function(i,a){if(Hz(a)){var l=e(a.from,a.to,a.velocity),c=Bft(l,2),u=c[0],d=c[1];return qi(qi({},a),{},{from:u,velocity:d})}return a},r);return n<1?B_(function(i,a){return Hz(a)?qi(qi({},a),{},{velocity:CR(a.velocity,s[i].velocity,n),from:CR(a.from,s[i].from,n)}):a},r):t(e,s,n-1)};const Vft=function(t,e,r,n,s){var i=wft(t,e),a=i.reduce(function(y,x){return qi(qi({},y),{},zz({},x,[t[x],e[x]]))},{}),l=i.reduce(function(y,x){return qi(qi({},y),{},zz({},x,{from:t[x],velocity:0,to:e[x]}))},{}),c=-1,u,d,h=function(){return null},f=function(){return B_(function(x,v){return v.from},l)},p=function(){return!Object.values(l).filter(Hz).length},m=function(x){u||(u=x);var v=x-u,b=v/r.dt;l=Wft(r,l,b),s(qi(qi(qi({},t),e),f())),u=x,p()||(c=requestAnimationFrame(h))},g=function(x){d||(d=x);var v=(x-d)/n,b=B_(function(j,N){return CR.apply(void 0,Yte(N).concat([r(v)]))},a);if(s(qi(qi(qi({},t),e),b)),v<1)c=requestAnimationFrame(h);else{var w=B_(function(j,N){return CR.apply(void 0,Yte(N).concat([r(1)]))},a);s(qi(qi(qi({},t),e),w))}};return h=r.isStepper?m:g,function(){return requestAnimationFrame(h),function(){cancelAnimationFrame(c)}}};function N1(t){"@babel/helpers - typeof";return N1=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},N1(t)}var qft=["children","begin","duration","attributeName","easing","isActive","steps","from","to","canBegin","onAnimationEnd","shouldReAnimate","onAnimationReStart"];function Gft(t,e){if(t==null)return{};var r=Kft(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 Kft(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 m3(t){return Zft(t)||Qft(t)||Xft(t)||Yft()}function Yft(){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 Xft(t,e){if(t){if(typeof t=="string")return Wz(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 Wz(t,e)}}function Qft(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Zft(t){if(Array.isArray(t))return Wz(t)}function Wz(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 Qte(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 yc(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Qte(Object(r),!0).forEach(function(n){HS(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Qte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function HS(t,e,r){return e=vwe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Jft(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ept(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,vwe(n.key),n)}}function tpt(t,e,r){return e&&ept(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function vwe(t){var e=rpt(t,"string");return N1(e)==="symbol"?e:String(e)}function rpt(t,e){if(N1(t)!=="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(N1(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function npt(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&&Vz(t,e)}function Vz(t,e){return Vz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},Vz(t,e)}function spt(t){var e=ipt();return function(){var n=ER(t),s;if(e){var i=ER(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return qz(this,s)}}function qz(t,e){if(e&&(N1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Gz(t)}function Gz(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function ipt(){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 ER(t){return ER=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},ER(t)}var qm=function(t){npt(r,t);var e=spt(r);function r(n,s){var i;Jft(this,r),i=e.call(this,n,s);var a=i.props,l=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(Gz(i)),i.changeStyle=i.changeStyle.bind(Gz(i)),!l||p<=0)return i.state={style:{}},typeof f=="function"&&(i.state={style:d}),qz(i);if(h&&h.length)i.state={style:h[0].style};else if(u){if(typeof f=="function")return i.state={style:u},qz(i);i.state={style:c?HS({},c,u):u}}else i.state={style:{}};return i}return tpt(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,l=i.canBegin,c=i.attributeName,u=i.shouldReAnimate,d=i.to,h=i.from,f=this.state.style;if(l){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(!(fwe(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 y={style:c?HS({},c,g):g};(c&&f[c]!==g||!c&&f!==g)&&this.setState(y)}this.runAnimation(yc(yc({},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,l=s.to,c=s.duration,u=s.easing,d=s.begin,h=s.onAnimationEnd,f=s.onAnimationStart,p=Vft(a,l,Oft(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,l=s.begin,c=s.onAnimationStart,u=a[0],d=u.style,h=u.duration,f=h===void 0?0:h,p=function(g,y,x){if(x===0)return g;var v=y.duration,b=y.easing,w=b===void 0?"ease":b,j=y.style,N=y.properties,C=y.onAnimationEnd,A=x>0?a[x-1]:y,E=N||Object.keys(j);if(typeof w=="function"||w==="spring")return[].concat(m3(g),[i.runJSAnimation.bind(i,{from:A.style,to:j,duration:v,easing:w}),v]);var O=qte(E,v,w),$=yc(yc(yc({},A.style),j),{},{transition:O});return[].concat(m3(g),[$,v,C]).filter(jft)};return this.manager.start([c].concat(m3(a.reduce(p,[d,Math.max(f,l)])),[s.onAnimationEnd]))}},{key:"runAnimation",value:function(s){this.manager||(this.manager=yft());var i=s.begin,a=s.duration,l=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=l?HS({},l,c):c,y=qte(Object.keys(g),a,u);m.start([d,i,yc(yc({},g),{},{transition:y}),a,h])}},{key:"render",value:function(){var s=this.props,i=s.children;s.begin;var a=s.duration;s.attributeName,s.easing;var l=s.isActive;s.steps,s.from,s.to,s.canBegin,s.onAnimationEnd,s.shouldReAnimate,s.onAnimationReStart;var c=Gft(s,qft),u=S.Children.count(i),d=this.state.style;if(typeof i=="function")return i(d);if(!l||u===0||a<=0)return i;var h=function(p){var m=p.props,g=m.style,y=g===void 0?{}:g,x=m.className,v=S.cloneElement(p,yc(yc({},c),{},{style:yc(yc({},y),d),className:x}));return v};return u===1?h(S.Children.only(i)):ve.createElement("div",null,S.Children.map(i,function(f){return h(f)}))}}]),r}(S.PureComponent);qm.displayName="Animate";qm.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};qm.propTypes={from:Yr.oneOfType([Yr.object,Yr.string]),to:Yr.oneOfType([Yr.object,Yr.string]),attributeName:Yr.string,duration:Yr.number,begin:Yr.number,easing:Yr.oneOfType([Yr.string,Yr.func]),steps:Yr.arrayOf(Yr.shape({duration:Yr.number.isRequired,style:Yr.object.isRequired,easing:Yr.oneOfType([Yr.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),Yr.func]),properties:Yr.arrayOf("string"),onAnimationEnd:Yr.func})),children:Yr.oneOfType([Yr.node,Yr.func]),isActive:Yr.bool,canBegin:Yr.bool,onAnimationEnd:Yr.func,shouldReAnimate:Yr.bool,onAnimationStart:Yr.func,onAnimationReStart:Yr.func};function dk(t){"@babel/helpers - typeof";return dk=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},dk(t)}function AR(){return AR=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},AR.apply(this,arguments)}function apt(t,e){return upt(t)||cpt(t,e)||lpt(t,e)||opt()}function opt(){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 lpt(t,e){if(t){if(typeof t=="string")return Zte(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 Zte(t,e)}}function Zte(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 cpt(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function upt(t){if(Array.isArray(t))return t}function Jte(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 ere(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Jte(Object(r),!0).forEach(function(n){dpt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Jte(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function dpt(t,e,r){return e=hpt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function hpt(t){var e=fpt(t,"string");return dk(e)=="symbol"?e:e+""}function fpt(t,e){if(dk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(dk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var tre=function(e,r,n,s,i){var a=Math.min(Math.abs(n)/2,Math.abs(s)/2),l=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+l*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+l*h[1])),d+="L ".concat(e+n,",").concat(r+s-l*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-l*h[3])),d+="Z"}else if(a>0&&i===+i&&i>0){var m=Math.min(a,i);d="M ".concat(e,",").concat(r+l*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+l*m,`
            L `).concat(e+n,",").concat(r+s-l*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-l*m," Z")}else d="M ".concat(e,",").concat(r," h ").concat(n," v ").concat(s," h ").concat(-n," Z");return d},ppt=function(e,r){if(!e||!r)return!1;var n=e.x,s=e.y,i=r.x,a=r.y,l=r.width,c=r.height;if(Math.abs(l)>0&&Math.abs(c)>0){var u=Math.min(i,i+l),d=Math.max(i,i+l),h=Math.min(a,a+c),f=Math.max(a,a+c);return n>=u&&n<=d&&s>=h&&s<=f}return!1},mpt={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Sq=function(e){var r=ere(ere({},mpt),e),n=S.useRef(),s=S.useState(-1),i=apt(s,2),a=i[0],l=i[1];S.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var w=n.current.getTotalLength();w&&l(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,y=r.animationBegin,x=r.isAnimationActive,v=r.isUpdateAnimationActive;if(c!==+c||u!==+u||d!==+d||h!==+h||d===0||h===0)return null;var b=$r("recharts-rectangle",p);return v?ve.createElement(qm,{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 j=w.width,N=w.height,C=w.x,A=w.y;return ve.createElement(qm,{canBegin:a>0,from:"0px ".concat(a===-1?1:a,"px"),to:"".concat(a,"px 0px"),attributeName:"strokeDasharray",begin:y,duration:g,isActive:x,easing:m},ve.createElement("path",AR({},cr(r,!0),{className:b,d:tre(C,A,j,N,f),ref:n})))}):ve.createElement("path",AR({},cr(r,!0),{className:b,d:tre(c,u,d,h,f)}))},gpt=["points","className","baseLinePoints","connectNulls"];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 xpt(t,e){if(t==null)return{};var r=ypt(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 ypt(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 rre(t){return jpt(t)||wpt(t)||bpt(t)||vpt()}function vpt(){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 bpt(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 wpt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function jpt(t){if(Array.isArray(t))return Kz(t)}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}var nre=function(e){return e&&e.x===+e.x&&e.y===+e.y},Spt=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],r=[[]];return e.forEach(function(n){nre(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),nre(e[0])&&r[r.length-1].push(e[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},z_=function(e,r){var n=Spt(e);r&&(n=[n.reduce(function(i,a){return[].concat(rre(i),rre(a))},[])]);var s=n.map(function(i){return i.reduce(function(a,l,c){return"".concat(a).concat(c===0?"M":"L").concat(l.x,",").concat(l.y)},"")}).join("");return n.length===1?"".concat(s,"Z"):s},_pt=function(e,r,n){var s=z_(e,n);return"".concat(s.slice(-1)==="Z"?s.slice(0,-1):s,"L").concat(z_(r.reverse(),n).slice(1))},Npt=function(e){var r=e.points,n=e.className,s=e.baseLinePoints,i=e.connectNulls,a=xpt(e,gpt);if(!r||!r.length)return null;var l=$r("recharts-polygon",n);if(s&&s.length){var c=a.stroke&&a.stroke!=="none",u=_pt(r,s,i);return ve.createElement("g",{className:l},ve.createElement("path",Yb({},cr(a,!0),{fill:u.slice(-1)==="Z"?a.fill:"none",stroke:"none",d:u})),c?ve.createElement("path",Yb({},cr(a,!0),{fill:"none",d:z_(r,i)})):null,c?ve.createElement("path",Yb({},cr(a,!0),{fill:"none",d:z_(s,i)})):null)}var d=z_(r,i);return ve.createElement("path",Yb({},cr(a,!0),{fill:d.slice(-1)==="Z"?a.fill:"none",className:l,d}))};function Yz(){return Yz=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},Yz.apply(this,arguments)}var _q=function(e){var r=e.cx,n=e.cy,s=e.r,i=e.className,a=$r("recharts-dot",i);return r===+r&&n===+n&&s===+s?S.createElement("circle",Yz({},cr(e,!1),YI(e),{className:a,cx:r,cy:n,r:s})):null};function hk(t){"@babel/helpers - typeof";return hk=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},hk(t)}var kpt=["x","y","top","left","width","height","className"];function Xz(){return Xz=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},Xz.apply(this,arguments)}function sre(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 Cpt(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?sre(Object(r),!0).forEach(function(n){Ept(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):sre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ept(t,e,r){return e=Apt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Apt(t){var e=Tpt(t,"string");return hk(e)=="symbol"?e:e+""}function Tpt(t,e){if(hk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(hk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ppt(t,e){if(t==null)return{};var r=Ipt(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 Ipt(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 Rpt=function(e,r,n,s,i,a){return"M".concat(e,",").concat(i,"v").concat(s,"M").concat(a,",").concat(r,"h").concat(n)},Opt=function(e){var r=e.x,n=r===void 0?0:r,s=e.y,i=s===void 0?0:s,a=e.top,l=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=Ppt(e,kpt),y=Cpt({x:n,y:i,top:l,left:u,width:h,height:p},g);return!gt(n)||!gt(i)||!gt(h)||!gt(p)||!gt(l)||!gt(u)?null:ve.createElement("path",Xz({},cr(y,!0),{className:$r("recharts-cross",m),d:Rpt(n,i,h,p,l,u)}))},Mpt=oL,Dpt=M0e,Lpt=hg;function $pt(t,e){return t&&t.length?Mpt(t,Lpt(e),Dpt):void 0}var Fpt=$pt;const Bpt=Er(Fpt);var zpt=oL,Upt=hg,Hpt=D0e;function Wpt(t,e){return t&&t.length?zpt(t,Upt(e),Hpt):void 0}var Vpt=Wpt;const qpt=Er(Vpt);var Gpt=["cx","cy","angle","ticks","axisLine"],Kpt=["ticks","tick","angle","tickFormatter","stroke"];function k1(t){"@babel/helpers - typeof";return k1=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},k1(t)}function U_(){return U_=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},U_.apply(this,arguments)}function ire(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 Eg(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ire(Object(r),!0).forEach(function(n){hL(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ire(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function are(t,e){if(t==null)return{};var r=Ypt(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 Ypt(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 Xpt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ore(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,wwe(n.key),n)}}function Qpt(t,e,r){return e&&ore(t.prototype,e),r&&ore(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Zpt(t,e,r){return e=TR(e),Jpt(t,bwe()?Reflect.construct(e,r||[],TR(t).constructor):e.apply(t,r))}function Jpt(t,e){if(e&&(k1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return emt(t)}function emt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function bwe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(bwe=function(){return!!t})()}function TR(t){return TR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},TR(t)}function tmt(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&&Qz(t,e)}function Qz(t,e){return Qz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},Qz(t,e)}function hL(t,e,r){return e=wwe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function wwe(t){var e=rmt(t,"string");return k1(e)=="symbol"?e:e+""}function rmt(t,e){if(k1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(k1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var fL=function(t){function e(){return Xpt(this,e),Zpt(this,e,arguments)}return tmt(e,t),Qpt(e,[{key:"getTickValueCoord",value:function(n){var s=n.coordinate,i=this.props,a=i.angle,l=i.cx,c=i.cy;return In(l,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,l=n.ticks,c=Bpt(l,function(d){return d.coordinate||0}),u=qpt(l,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,l=n.ticks,c=n.axisLine,u=are(n,Gpt),d=l.reduce(function(m,g){return[Math.min(m[0],g.coordinate),Math.max(m[1],g.coordinate)]},[1/0,-1/0]),h=In(s,i,d[0],a),f=In(s,i,d[1],a),p=Eg(Eg(Eg({},cr(u,!1)),{},{fill:"none"},cr(c,!1)),{},{x1:h.x,y1:h.y,x2:f.x,y2:f.y});return ve.createElement("line",U_({className:"recharts-polar-radius-axis-line"},p))}},{key:"renderTicks",value:function(){var n=this,s=this.props,i=s.ticks,a=s.tick,l=s.angle,c=s.tickFormatter,u=s.stroke,d=are(s,Kpt),h=this.getTickTextAnchor(),f=cr(d,!1),p=cr(a,!1),m=i.map(function(g,y){var x=n.getTickValueCoord(g),v=Eg(Eg(Eg(Eg({textAnchor:h,transform:"rotate(".concat(90-l,", ").concat(x.x,", ").concat(x.y,")")},f),{},{stroke:"none",fill:u},p),{},{index:y},x),{},{payload:g});return ve.createElement(vs,U_({className:$r("recharts-polar-radius-axis-tick",iwe(a)),key:"tick-".concat(g.coordinate)},GD(n.props,g,y)),e.renderTickItem(a,v,c?c(g.value,y):g.value))});return ve.createElement(vs,{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:ve.createElement(vs,{className:$r("recharts-polar-radius-axis",this.props.className)},i&&this.renderAxisLine(),a&&this.renderTicks(),Zi.renderCallByParent(this.props,this.getViewBox()))}}],[{key:"renderTickItem",value:function(n,s,i){var a;return ve.isValidElement(n)?a=ve.cloneElement(n,s):hr(n)?a=n(s):a=ve.createElement(v1,U_({},s,{className:"recharts-polar-radius-axis-tick-value"}),i),a}}])}(S.PureComponent);hL(fL,"displayName","PolarRadiusAxis");hL(fL,"axisType","radiusAxis");hL(fL,"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 C1(t){"@babel/helpers - typeof";return C1=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},C1(t)}function Xg(){return Xg=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},Xg.apply(this,arguments)}function lre(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 Ag(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?lre(Object(r),!0).forEach(function(n){pL(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):lre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function nmt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function cre(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,Swe(n.key),n)}}function smt(t,e,r){return e&&cre(t.prototype,e),r&&cre(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function imt(t,e,r){return e=PR(e),amt(t,jwe()?Reflect.construct(e,r||[],PR(t).constructor):e.apply(t,r))}function amt(t,e){if(e&&(C1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return omt(t)}function omt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function jwe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(jwe=function(){return!!t})()}function PR(t){return PR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},PR(t)}function lmt(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&&Zz(t,e)}function Zz(t,e){return Zz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},Zz(t,e)}function pL(t,e,r){return e=Swe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Swe(t){var e=cmt(t,"string");return C1(e)=="symbol"?e:e+""}function cmt(t,e){if(C1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(C1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var umt=Math.PI/180,ure=1e-5,mL=function(t){function e(){return nmt(this,e),imt(this,e,arguments)}return lmt(e,t),smt(e,[{key:"getTickLineCoord",value:function(n){var s=this.props,i=s.cx,a=s.cy,l=s.radius,c=s.orientation,u=s.tickSize,d=u||8,h=In(i,a,l,n.coordinate),f=In(i,a,l+(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*umt),a;return i>ure?a=s==="outer"?"start":"end":i<-ure?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,l=n.axisLine,c=n.axisLineType,u=Ag(Ag({},cr(this.props,!1)),{},{fill:"none"},cr(l,!1));if(c==="circle")return ve.createElement(_q,Xg({className:"recharts-polar-angle-axis-line"},u,{cx:s,cy:i,r:a}));var d=this.props.ticks,h=d.map(function(f){return In(s,i,a,f.coordinate)});return ve.createElement(Npt,Xg({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,l=s.tickLine,c=s.tickFormatter,u=s.stroke,d=cr(this.props,!1),h=cr(a,!1),f=Ag(Ag({},d),{},{fill:"none"},cr(l,!1)),p=i.map(function(m,g){var y=n.getTickLineCoord(m),x=n.getTickTextAnchor(m),v=Ag(Ag(Ag({textAnchor:x},d),{},{stroke:"none",fill:u},h),{},{index:g,payload:m,x:y.x2,y:y.y2});return ve.createElement(vs,Xg({className:$r("recharts-polar-angle-axis-tick",iwe(a)),key:"tick-".concat(m.coordinate)},GD(n.props,m,g)),l&&ve.createElement("line",Xg({className:"recharts-polar-angle-axis-tick-line"},f,y)),a&&e.renderTickItem(a,v,c?c(m.value,g):m.value))});return ve.createElement(vs,{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:ve.createElement(vs,{className:$r("recharts-polar-angle-axis",this.props.className)},a&&this.renderAxisLine(),this.renderTicks())}}],[{key:"renderTickItem",value:function(n,s,i){var a;return ve.isValidElement(n)?a=ve.cloneElement(n,s):hr(n)?a=n(s):a=ve.createElement(v1,Xg({},s,{className:"recharts-polar-angle-axis-tick-value"}),i),a}}])}(S.PureComponent);pL(mL,"displayName","PolarAngleAxis");pL(mL,"axisType","angleAxis");pL(mL,"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 dmt=Ibe,hmt=dmt(Object.getPrototypeOf,Object),fmt=hmt,pmt=Ef,mmt=fmt,gmt=Af,xmt="[object Object]",ymt=Function.prototype,vmt=Object.prototype,_we=ymt.toString,bmt=vmt.hasOwnProperty,wmt=_we.call(Object);function jmt(t){if(!gmt(t)||pmt(t)!=xmt)return!1;var e=mmt(t);if(e===null)return!0;var r=bmt.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&_we.call(r)==wmt}var Smt=jmt;const _mt=Er(Smt);var Nmt=Ef,kmt=Af,Cmt="[object Boolean]";function Emt(t){return t===!0||t===!1||kmt(t)&&Nmt(t)==Cmt}var Amt=Emt;const Tmt=Er(Amt);function fk(t){"@babel/helpers - typeof";return fk=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},fk(t)}function IR(){return IR=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},IR.apply(this,arguments)}function Pmt(t,e){return Mmt(t)||Omt(t,e)||Rmt(t,e)||Imt()}function Imt(){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 Rmt(t,e){if(t){if(typeof t=="string")return dre(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 dre(t,e)}}function dre(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 Omt(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function Mmt(t){if(Array.isArray(t))return t}function hre(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 fre(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?hre(Object(r),!0).forEach(function(n){Dmt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):hre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Dmt(t,e,r){return e=Lmt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lmt(t){var e=$mt(t,"string");return fk(e)=="symbol"?e:e+""}function $mt(t,e){if(fk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(fk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var pre=function(e,r,n,s,i){var a=n-s,l;return l="M ".concat(e,",").concat(r),l+="L ".concat(e+n,",").concat(r),l+="L ".concat(e+n-a/2,",").concat(r+i),l+="L ".concat(e+n-a/2-s,",").concat(r+i),l+="L ".concat(e,",").concat(r," Z"),l},Fmt={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},Bmt=function(e){var r=fre(fre({},Fmt),e),n=S.useRef(),s=S.useState(-1),i=Pmt(s,2),a=i[0],l=i[1];S.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var b=n.current.getTotalLength();b&&l(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,y=r.animationBegin,x=r.isUpdateAnimationActive;if(c!==+c||u!==+u||d!==+d||h!==+h||f!==+f||d===0&&h===0||f===0)return null;var v=$r("recharts-trapezoid",p);return x?ve.createElement(qm,{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:x},function(b){var w=b.upperWidth,j=b.lowerWidth,N=b.height,C=b.x,A=b.y;return ve.createElement(qm,{canBegin:a>0,from:"0px ".concat(a===-1?1:a,"px"),to:"".concat(a,"px 0px"),attributeName:"strokeDasharray",begin:y,duration:g,easing:m},ve.createElement("path",IR({},cr(r,!0),{className:v,d:pre(C,A,w,j,N),ref:n})))}):ve.createElement("g",null,ve.createElement("path",IR({},cr(r,!0),{className:v,d:pre(c,u,d,h,f)})))},zmt=["option","shapeType","propTransformer","activeClassName","isActive"];function pk(t){"@babel/helpers - typeof";return pk=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},pk(t)}function Umt(t,e){if(t==null)return{};var r=Hmt(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 Hmt(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 mre(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 RR(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?mre(Object(r),!0).forEach(function(n){Wmt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):mre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Wmt(t,e,r){return e=Vmt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Vmt(t){var e=qmt(t,"string");return pk(e)=="symbol"?e:e+""}function qmt(t,e){if(pk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(pk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Gmt(t,e){return RR(RR({},e),t)}function Kmt(t,e){return t==="symbols"}function gre(t){var e=t.shapeType,r=t.elementProps;switch(e){case"rectangle":return ve.createElement(Sq,r);case"trapezoid":return ve.createElement(Bmt,r);case"sector":return ve.createElement(lwe,r);case"symbols":if(Kmt(e))return ve.createElement(FV,r);break;default:return null}}function Ymt(t){return S.isValidElement(t)?t.props:t}function Xmt(t){var e=t.option,r=t.shapeType,n=t.propTransformer,s=n===void 0?Gmt:n,i=t.activeClassName,a=i===void 0?"recharts-active-shape":i,l=t.isActive,c=Umt(t,zmt),u;if(S.isValidElement(e))u=S.cloneElement(e,RR(RR({},c),Ymt(e)));else if(hr(e))u=e(c);else if(_mt(e)&&!Tmt(e)){var d=s(e,c);u=ve.createElement(gre,{shapeType:r,elementProps:d})}else{var h=c;u=ve.createElement(gre,{shapeType:r,elementProps:h})}return l?ve.createElement(vs,{className:a},u):u}function gL(t,e){return e!=null&&"trapezoids"in t.props}function xL(t,e){return e!=null&&"sectors"in t.props}function mk(t,e){return e!=null&&"points"in t.props}function Qmt(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 Zmt(t,e){var r=t.endAngle===e.endAngle,n=t.startAngle===e.startAngle;return r&&n}function Jmt(t,e){var r=t.x===e.x,n=t.y===e.y,s=t.z===e.z;return r&&n&&s}function egt(t,e){var r;return gL(t,e)?r=Qmt:xL(t,e)?r=Zmt:mk(t,e)&&(r=Jmt),r}function tgt(t,e){var r;return gL(t,e)?r="trapezoids":xL(t,e)?r="sectors":mk(t,e)&&(r="points"),r}function rgt(t,e){if(gL(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(xL(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 mk(t,e)?e.payload:{}}function ngt(t){var e=t.activeTooltipItem,r=t.graphicalItem,n=t.itemData,s=tgt(r,e),i=rgt(r,e),a=n.filter(function(c,u){var d=yq(i,c),h=r.props[s].filter(function(m){var g=egt(r,e);return g(m,e)}),f=r.props[s].indexOf(h[h.length-1]),p=u===f;return d&&p}),l=n.indexOf(a[a.length-1]);return l}var tP;function E1(t){"@babel/helpers - typeof";return E1=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},E1(t)}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 xre(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 En(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?xre(Object(r),!0).forEach(function(n){Wl(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):xre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function sgt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function yre(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,kwe(n.key),n)}}function igt(t,e,r){return e&&yre(t.prototype,e),r&&yre(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function agt(t,e,r){return e=OR(e),ogt(t,Nwe()?Reflect.construct(e,r||[],OR(t).constructor):e.apply(t,r))}function ogt(t,e){if(e&&(E1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return lgt(t)}function lgt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Nwe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Nwe=function(){return!!t})()}function OR(t){return OR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},OR(t)}function cgt(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&&Jz(t,e)}function Jz(t,e){return Jz=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},Jz(t,e)}function Wl(t,e,r){return e=kwe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function kwe(t){var e=ugt(t,"string");return E1(e)=="symbol"?e:e+""}function ugt(t,e){if(E1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(E1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Pf=function(t){function e(r){var n;return sgt(this,e),n=agt(this,e,[r]),Wl(n,"pieRef",null),Wl(n,"sectorRefs",[]),Wl(n,"id",qD("recharts-pie-")),Wl(n,"handleAnimationEnd",function(){var s=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),hr(s)&&s()}),Wl(n,"handleAnimationStart",function(){var s=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),hr(s)&&s()}),n.state={isAnimationFinished:!r.isAnimationActive,prevIsAnimationActive:r.isAnimationActive,prevAnimationId:r.animationId,sectorToFocus:0},n}return cgt(e,t),igt(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,l=i.labelLine,c=i.dataKey,u=i.valueKey,d=cr(this.props,!1),h=cr(a,!1),f=cr(l,!1),p=a&&a.offsetRadius||20,m=n.map(function(g,y){var x=(g.startAngle+g.endAngle)/2,v=In(g.cx,g.cy,g.outerRadius+p,x),b=En(En(En(En({},d),g),{},{stroke:"none"},h),{},{index:y,textAnchor:e.getTextAnchor(v.x,g.cx)},v),w=En(En(En(En({},d),g),{},{fill:"none",stroke:g.fill},f),{},{index:y,points:[In(g.cx,g.cy,g.outerRadius,x),v]}),j=c;return Rr(c)&&Rr(u)?j="value":Rr(c)&&(j=u),ve.createElement(vs,{key:"label-".concat(g.startAngle,"-").concat(g.endAngle,"-").concat(g.midAngle,"-").concat(y)},l&&e.renderLabelLineItem(l,w,"line"),e.renderLabelItem(a,b,nl(g,j)))});return ve.createElement(vs,{className:"recharts-pie-labels"},m)}},{key:"renderSectorsStatically",value:function(n){var s=this,i=this.props,a=i.activeShape,l=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=En(En({},u),{},{stroke:l?u.fill:u.stroke,tabIndex:-1});return ve.createElement(vs,Xb({ref:function(y){y&&!s.sectorRefs.includes(y)&&s.sectorRefs.push(y)},tabIndex:-1,className:"recharts-pie-sector"},GD(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)}),ve.createElement(Xmt,Xb({option:p,isActive:h,shapeType:"sector"},m)))})}},{key:"renderSectorsWithAnimation",value:function(){var n=this,s=this.props,i=s.sectors,a=s.isAnimationActive,l=s.animationBegin,c=s.animationDuration,u=s.animationEasing,d=s.animationId,h=this.state,f=h.prevSectors,p=h.prevIsAnimationActive;return ve.createElement(qm,{begin:l,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,y=[],x=i&&i[0],v=x.startAngle;return i.forEach(function(b,w){var j=f&&f[w],N=w>0?Xc(b,"paddingAngle",0):0;if(j){var C=dJ(j.endAngle-j.startAngle,b.endAngle-b.startAngle),A=En(En({},b),{},{startAngle:v+N,endAngle:v+C(g)+N});y.push(A),v=A.endAngle}else{var E=b.endAngle,O=b.startAngle,$=dJ(0,E-O),T=$(g),M=En(En({},b),{},{startAngle:v+N,endAngle:v+T+N});y.push(M),v=M.endAngle}}),ve.createElement(vs,null,n.renderSectorsStatically(y))})}},{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 l=--s.state.sectorToFocus<0?s.sectorRefs.length-1:s.state.sectorToFocus%s.sectorRefs.length;s.sectorRefs[l].focus(),s.setState({sectorToFocus:l});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||!yq(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,l=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||!gt(u)||!gt(d)||!gt(h)||!gt(f))return null;var g=$r("recharts-pie",l);return ve.createElement(vs,{tabIndex:this.props.rootTabIndex,className:g,ref:function(x){n.pieRef=x}},this.renderSectors(),c&&this.renderLabels(a),Zi.renderCallByParent(this.props,null,!1),(!p||m)&&Wy.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(ve.isValidElement(n))return ve.cloneElement(n,s);if(hr(n))return n(s);var a=$r("recharts-pie-label-line",typeof n!="boolean"?n.className:"");return ve.createElement(Lz,Xb({},s,{key:i,type:"linear",className:a}))}},{key:"renderLabelItem",value:function(n,s,i){if(ve.isValidElement(n))return ve.cloneElement(n,s);var a=i;if(hr(n)&&(a=n(s),ve.isValidElement(a)))return a;var l=$r("recharts-pie-label-text",typeof n!="boolean"&&!hr(n)?n.className:"");return ve.createElement(v1,Xb({},s,{alignmentBaseline:"middle",className:l}),a)}}])}(S.PureComponent);tP=Pf;Wl(Pf,"displayName","Pie");Wl(Pf,"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:!zy.isSsr,animationBegin:400,animationDuration:1500,animationEasing:"ease",nameKey:"name",blendStroke:!1,rootTabIndex:0});Wl(Pf,"parseDeltaAngle",function(t,e){var r=Yl(e-t),n=Math.min(Math.abs(e-t),360);return r*n});Wl(Pf,"getRealPieData",function(t){var e=t.data,r=t.children,n=cr(t,!1),s=od(r,lR);return e&&e.length?e.map(function(i,a){return En(En(En({payload:i},n),i),s&&s[a]&&s[a].props)}):s&&s.length?s.map(function(i){return En(En({},n),i.props)}):[]});Wl(Pf,"parseCoordinateOfPie",function(t,e){var r=e.top,n=e.left,s=e.width,i=e.height,a=swe(s,i),l=n+vo(t.cx,s,s/2),c=r+vo(t.cy,i,i/2),u=vo(t.innerRadius,a,0),d=vo(t.outerRadius,a,a*.8),h=t.maxRadius||Math.sqrt(s*s+i*i)/2;return{cx:l,cy:c,innerRadius:u,outerRadius:d,maxRadius:h}});Wl(Pf,"getComposedData",function(t){var e=t.item,r=t.offset,n=e.type.defaultProps!==void 0?En(En({},e.type.defaultProps),e.props):e.props,s=tP.getRealPieData(n);if(!s||!s.length)return null;var i=n.cornerRadius,a=n.startAngle,l=n.endAngle,c=n.paddingAngle,u=n.dataKey,d=n.nameKey,h=n.valueKey,f=n.tooltipType,p=Math.abs(n.minAngle),m=tP.parseCoordinateOfPie(n,r),g=tP.parseDeltaAngle(a,l),y=Math.abs(g),x=u;Rr(u)&&Rr(h)?(Yh(!1,`Use "dataKey" to specify the value of pie,
      the props "valueKey" will be deprecated in 1.1.0`),x="value"):Rr(u)&&(Yh(!1,`Use "dataKey" to specify the value of pie,
      the props "valueKey" will be deprecated in 1.1.0`),x=h);var v=s.filter(function(A){return nl(A,x,0)!==0}).length,b=(y>=360?v:v-1)*c,w=y-v*p-b,j=s.reduce(function(A,E){var O=nl(E,x,0);return A+(gt(O)?O:0)},0),N;if(j>0){var C;N=s.map(function(A,E){var O=nl(A,x,0),$=nl(A,d,E),T=(gt(O)?O:0)/j,M;E?M=C.endAngle+Yl(g)*c*(O!==0?1:0):M=a;var k=M+Yl(g)*((O!==0?p:0)+T*w),D=(M+k)/2,K=(m.innerRadius+m.outerRadius)/2,H=[{name:$,value:O,payload:A,dataKey:x,type:f}],ee=In(m.cx,m.cy,K,D);return C=En(En(En({percent:T,cornerRadius:i,name:$,tooltipPayload:H,midAngle:D,middleRadius:K,tooltipPosition:ee},A),m),{},{value:nl(A,x),startAngle:M,endAngle:k,payload:A,paddingAngle:Yl(g)*c}),C})}return En(En({},m),{},{sectors:N,data:s})});var dgt=Math.ceil,hgt=Math.max;function fgt(t,e,r,n){for(var s=-1,i=hgt(dgt((e-t)/(r||1)),0),a=Array(i);i--;)a[n?i:++s]=t,t+=r;return a}var pgt=fgt,mgt=Xbe,vre=1/0,ggt=17976931348623157e292;function xgt(t){if(!t)return t===0?t:0;if(t=mgt(t),t===vre||t===-vre){var e=t<0?-1:1;return e*ggt}return t===t?t:0}var ygt=xgt,vgt=pgt,bgt=eL,g3=ygt;function wgt(t){return function(e,r,n){return n&&typeof n!="number"&&bgt(e,r,n)&&(r=n=void 0),e=g3(e),r===void 0?(r=e,e=0):r=g3(r),n=n===void 0?e<r?1:-1:g3(n),vgt(e,r,n,t)}}var jgt=wgt,Sgt=jgt,_gt=Sgt(),Ngt=_gt;const MR=Er(Ngt);function gk(t){"@babel/helpers - typeof";return gk=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},gk(t)}function bre(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 wre(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?bre(Object(r),!0).forEach(function(n){Cwe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):bre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Cwe(t,e,r){return e=kgt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function kgt(t){var e=Cgt(t,"string");return gk(e)=="symbol"?e:e+""}function Cgt(t,e){if(gk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(gk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Egt=["Webkit","Moz","O","ms"],Agt=function(e,r){var n=e.replace(/(\w)/,function(i){return i.toUpperCase()}),s=Egt.reduce(function(i,a){return wre(wre({},i),{},Cwe({},a+n,r))},{});return s[e]=r,s};function A1(t){"@babel/helpers - typeof";return A1=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},A1(t)}function DR(){return DR=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},DR.apply(this,arguments)}function jre(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 x3(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?jre(Object(r),!0).forEach(function(n){Oo(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):jre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Tgt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Sre(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,Awe(n.key),n)}}function Pgt(t,e,r){return e&&Sre(t.prototype,e),r&&Sre(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Igt(t,e,r){return e=LR(e),Rgt(t,Ewe()?Reflect.construct(e,r||[],LR(t).constructor):e.apply(t,r))}function Rgt(t,e){if(e&&(A1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ogt(t)}function Ogt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ewe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ewe=function(){return!!t})()}function LR(t){return LR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},LR(t)}function Mgt(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&&eU(t,e)}function eU(t,e){return eU=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},eU(t,e)}function Oo(t,e,r){return e=Awe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Awe(t){var e=Dgt(t,"string");return A1(e)=="symbol"?e:e+""}function Dgt(t,e){if(A1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(A1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Lgt=function(e){var r=e.data,n=e.startIndex,s=e.endIndex,i=e.x,a=e.width,l=e.travellerWidth;if(!r||!r.length)return{};var c=r.length,u=$_().domain(MR(0,c)).range([i,i+a-l]),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}},_re=function(e){return e.changedTouches&&!!e.changedTouches.length},T1=function(t){function e(r){var n;return Tgt(this,e),n=Igt(this,e,[r]),Oo(n,"handleDrag",function(s){n.leaveTimer&&(clearTimeout(n.leaveTimer),n.leaveTimer=null),n.state.isTravellerMoving?n.handleTravellerMove(s):n.state.isSlideMoving&&n.handleSlideDrag(s)}),Oo(n,"handleTouchMove",function(s){s.changedTouches!=null&&s.changedTouches.length>0&&n.handleDrag(s.changedTouches[0])}),Oo(n,"handleDragEnd",function(){n.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var s=n.props,i=s.endIndex,a=s.onDragEnd,l=s.startIndex;a==null||a({endIndex:i,startIndex:l})}),n.detachDragEndListener()}),Oo(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Oo(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Oo(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Oo(n,"handleSlideDragStart",function(s){var i=_re(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 Mgt(e,t),Pgt(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,l=this.props,c=l.gap,u=l.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,l=s.dataKey,c=nl(i[n],l,n);return hr(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,l=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-l,u+d-h-a):g<0&&(g=Math.max(g,u-a,u-l));var y=this.getIndex({startX:a+g,endX:l+g});(y.startIndex!==f||y.endIndex!==p)&&m&&m(y),this.setState({startX:a+g,endX:l+g,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,s){var i=_re(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,l=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,y=d.data,x={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)),x[a]=u+v;var b=this.getIndex(x),w=b.startIndex,j=b.endIndex,N=function(){var A=y.length-1;return a==="startX"&&(l>c?w%g===0:j%g===0)||l<c&&j===A||a==="endX"&&(l>c?j%g===0:w%g===0)||l>c&&j===A};this.setState(Oo(Oo({},a,u+v),"brushMoveStartX",n.pageX),function(){m&&N()&&m(b)})}},{key:"handleTravellerMoveKeyboard",value:function(n,s){var i=this,a=this.state,l=a.scaleValues,c=a.startX,u=a.endX,d=this.state[s],h=l.indexOf(d);if(h!==-1){var f=h+n;if(!(f===-1||f>=l.length)){var p=l[f];s==="startX"&&p>=u||s==="endX"&&p<=c||this.setState(Oo({},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,l=n.height,c=n.fill,u=n.stroke;return ve.createElement("rect",{stroke:u,fill:c,x:s,y:i,width:a,height:l})}},{key:"renderPanorama",value:function(){var n=this.props,s=n.x,i=n.y,a=n.width,l=n.height,c=n.data,u=n.children,d=n.padding,h=S.Children.only(u);return h?ve.cloneElement(h,{x:s,y:i,width:a,height:l,margin:d,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(n,s){var i,a,l=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,y=c.endIndex,x=Math.max(n,this.props.x),v=x3(x3({},cr(this.props,!1)),{},{x,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[y])===null||a===void 0?void 0:a.name);return ve.createElement(vs,{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(j){["ArrowLeft","ArrowRight"].includes(j.key)&&(j.preventDefault(),j.stopPropagation(),l.handleTravellerMoveKeyboard(j.key==="ArrowRight"?1:-1,s))},onFocus:function(){l.setState({isTravellerFocused:!0})},onBlur:function(){l.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},e.renderTraveller(f,v))}},{key:"renderSlide",value:function(n,s){var i=this.props,a=i.y,l=i.height,c=i.stroke,u=i.travellerWidth,d=Math.min(n,s)+u,h=Math.max(Math.abs(s-n)-u,0);return ve.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:l})}},{key:"renderText",value:function(){var n=this.props,s=n.startIndex,i=n.endIndex,a=n.y,l=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 ve.createElement(vs,{className:"recharts-brush-texts"},ve.createElement(v1,DR({textAnchor:"end",verticalAnchor:"middle",x:Math.min(h,f)-p,y:a+l/2},m),this.getTextOfTick(s)),ve.createElement(v1,DR({textAnchor:"start",verticalAnchor:"middle",x:Math.max(h,f)+c+p,y:a+l/2},m),this.getTextOfTick(i)))}},{key:"render",value:function(){var n=this.props,s=n.data,i=n.className,a=n.children,l=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,y=f.isSlideMoving,x=f.isTravellerMoving,v=f.isTravellerFocused;if(!s||!s.length||!gt(l)||!gt(c)||!gt(u)||!gt(d)||u<=0||d<=0)return null;var b=$r("recharts-brush",i),w=ve.Children.count(a)===1,j=Agt("userSelect","none");return ve.createElement(vs,{className:b,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:j},this.renderBackground(),w&&this.renderPanorama(),this.renderSlide(p,m),this.renderTravellerLayer(p,"startX"),this.renderTravellerLayer(m,"endX"),(g||y||x||v||h)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(n){var s=n.x,i=n.y,a=n.width,l=n.height,c=n.stroke,u=Math.floor(i+l/2)-1;return ve.createElement(ve.Fragment,null,ve.createElement("rect",{x:s,y:i,width:a,height:l,fill:c,stroke:"none"}),ve.createElement("line",{x1:s+1,y1:u,x2:s+a-1,y2:u,fill:"none",stroke:"#fff"}),ve.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 ve.isValidElement(n)?i=ve.cloneElement(n,s):hr(n)?i=n(s):i=e.renderDefaultTraveller(s),i}},{key:"getDerivedStateFromProps",value:function(n,s){var i=n.data,a=n.width,l=n.x,c=n.travellerWidth,u=n.updateId,d=n.startIndex,h=n.endIndex;if(i!==s.prevData||u!==s.prevUpdateId)return x3({prevData:i,prevTravellerWidth:c,prevUpdateId:u,prevX:l,prevWidth:a},i&&i.length?Lgt({data:i,width:a,x:l,travellerWidth:c,startIndex:d,endIndex:h}):{scale:null,scaleValues:null});if(s.scale&&(a!==s.prevWidth||l!==s.prevX||c!==s.prevTravellerWidth)){s.scale.range([l,l+a-c]);var f=s.scale.domain().map(function(p){return s.scale(p)});return{prevData:i,prevTravellerWidth:c,prevUpdateId:u,prevX:l,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,l=i-1;l-a>1;){var c=Math.floor((a+l)/2);n[c]>s?l=c:a=c}return s>=n[l]?l:a}}])}(S.PureComponent);Oo(T1,"displayName","Brush");Oo(T1,"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 $gt=GV;function Fgt(t,e){var r;return $gt(t,function(n,s,i){return r=e(n,s,i),!r}),!!r}var Bgt=Fgt,zgt=_be,Ugt=hg,Hgt=Bgt,Wgt=To,Vgt=eL;function qgt(t,e,r){var n=Wgt(t)?zgt:Hgt;return r&&Vgt(t,e,r)&&(e=void 0),n(t,Ugt(e))}var Ggt=qgt;const Kgt=Er(Ggt);var cd=function(e,r){var n=e.alwaysShow,s=e.ifOverflow;return n&&(s="extendDomain"),s===r},Nre=Vbe;function Ygt(t,e,r){e=="__proto__"&&Nre?Nre(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Xgt=Ygt,Qgt=Xgt,Zgt=Hbe,Jgt=hg;function ext(t,e){var r={};return e=Jgt(e),Zgt(t,function(n,s,i){Qgt(r,s,e(n,s,i))}),r}var txt=ext;const rxt=Er(txt);function nxt(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 sxt=nxt,ixt=GV;function axt(t,e){var r=!0;return ixt(t,function(n,s,i){return r=!!e(n,s,i),r}),r}var oxt=axt,lxt=sxt,cxt=oxt,uxt=hg,dxt=To,hxt=eL;function fxt(t,e,r){var n=dxt(t)?lxt:cxt;return r&&hxt(t,e,r)&&(e=void 0),n(t,uxt(e))}var pxt=fxt;const mxt=Er(pxt);function xk(t){"@babel/helpers - typeof";return xk=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},xk(t)}function gxt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function kre(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,Twe(n.key),n)}}function xxt(t,e,r){return e&&kre(t.prototype,e),r&&kre(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Cre(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 jT(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Cre(Object(r),!0).forEach(function(n){Nq(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Cre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Nq(t,e,r){return e=Twe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Twe(t){var e=yxt(t,"string");return xk(e)=="symbol"?e:e+""}function yxt(t,e){if(xk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(xk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Pwe=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)}},vxt=function(e){var r=e.x1,n=e.y1,s=e.x2,i=e.y2;return Pwe({x:r,y:n},{x:s,y:i})},Iwe=function(){function t(e){gxt(this,t),this.scale=e}return xxt(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 l=this.bandwidth?this.bandwidth():0;return this.scale(r)+l}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)}}])}();Nq(Iwe,"EPS",1e-4);var kq=function(e){var r=Object.keys(e).reduce(function(n,s){return jT(jT({},n),{},Nq({},s,Iwe.create(e[s])))},{});return jT(jT({},r),{},{apply:function(s){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=i.bandAware,l=i.position;return rxt(s,function(c,u){return r[u].apply(c,{bandAware:a,position:l})})},isInRange:function(s){return mxt(s,function(i,a){return r[a].isInRange(i)})}})},bxt=WKe(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("")}),Rwe=S.createContext(void 0),Owe=S.createContext(void 0),Mwe=S.createContext(void 0),wxt=S.createContext({}),Dwe=S.createContext(void 0),jxt=S.createContext(0),Sxt=S.createContext(0),Ere=function(e){var r=e.state,n=r.xAxisMap,s=r.yAxisMap,i=r.offset,a=e.clipPathId,l=e.children,c=e.width,u=e.height,d=bxt(i);return ve.createElement(Rwe.Provider,{value:n},ve.createElement(Owe.Provider,{value:s},ve.createElement(wxt.Provider,{value:i},ve.createElement(Mwe.Provider,{value:d},ve.createElement(Dwe.Provider,{value:a},ve.createElement(jxt.Provider,{value:u},ve.createElement(Sxt.Provider,{value:c},l)))))))},_xt=function(){return S.useContext(Dwe)},Nxt=function(e){var r=S.useContext(Rwe);r==null&&S1();var n=r[e];return n==null&&S1(),n},kxt=function(e){var r=S.useContext(Owe);r==null&&S1();var n=r[e];return n==null&&S1(),n},Cxt=function(){var e=S.useContext(Mwe);return e};function P1(t){"@babel/helpers - typeof";return P1=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},P1(t)}function Ext(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Axt(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,$we(n.key),n)}}function Txt(t,e,r){return e&&Axt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Pxt(t,e,r){return e=$R(e),Ixt(t,Lwe()?Reflect.construct(e,r||[],$R(t).constructor):e.apply(t,r))}function Ixt(t,e){if(e&&(P1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Rxt(t)}function Rxt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Lwe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Lwe=function(){return!!t})()}function $R(t){return $R=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$R(t)}function Oxt(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&&tU(t,e)}function tU(t,e){return tU=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},tU(t,e)}function Are(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 Tre(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Are(Object(r),!0).forEach(function(n){Cq(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Are(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Cq(t,e,r){return e=$we(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $we(t){var e=Mxt(t,"string");return P1(e)=="symbol"?e:e+""}function Mxt(t,e){if(P1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(P1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Dxt(t,e){return Bxt(t)||Fxt(t,e)||$xt(t,e)||Lxt()}function Lxt(){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 $xt(t,e){if(t){if(typeof t=="string")return Pre(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 Pre(t,e)}}function Pre(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 Fxt(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function Bxt(t){if(Array.isArray(t))return t}function rU(){return rU=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},rU.apply(this,arguments)}var zxt=function(e,r){var n;return ve.isValidElement(e)?n=ve.cloneElement(e,r):hr(e)?n=e(r):n=ve.createElement("line",rU({},r,{className:"recharts-reference-line-line"})),n},Uxt=function(e,r,n,s,i,a,l,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(cd(u,"discard")&&!e.y.isInRange(g))return null;var y=[{x:d+f,y:g},{x:d,y:g}];return c==="left"?y.reverse():y}if(r){var x=u.x,v=e.x.apply(x,{position:a});if(cd(u,"discard")&&!e.x.isInRange(v))return null;var b=[{x:v,y:h+p},{x:v,y:h}];return l==="top"?b.reverse():b}if(s){var w=u.segment,j=w.map(function(N){return e.apply(N,{position:a})});return cd(u,"discard")&&Kgt(j,function(N){return!e.isInRange(N)})?null:j}return null};function Hxt(t){var e=t.x,r=t.y,n=t.segment,s=t.xAxisId,i=t.yAxisId,a=t.shape,l=t.className,c=t.alwaysShow,u=_xt(),d=Nxt(s),h=kxt(i),f=Cxt();if(!u||!f)return null;Yh(c===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var p=kq({x:d.scale,y:h.scale}),m=ni(e),g=ni(r),y=n&&n.length===2,x=Uxt(p,m,g,y,f,t.position,d.orientation,h.orientation,t);if(!x)return null;var v=Dxt(x,2),b=v[0],w=b.x,j=b.y,N=v[1],C=N.x,A=N.y,E=cd(t,"hidden")?"url(#".concat(u,")"):void 0,O=Tre(Tre({clipPath:E},cr(t,!0)),{},{x1:w,y1:j,x2:C,y2:A});return ve.createElement(vs,{className:$r("recharts-reference-line",l)},zxt(a,O),Zi.renderCallByParent(t,vxt({x1:w,y1:j,x2:C,y2:A})))}var Eq=function(t){function e(){return Ext(this,e),Pxt(this,e,arguments)}return Oxt(e,t),Txt(e,[{key:"render",value:function(){return ve.createElement(Hxt,this.props)}}])}(ve.Component);Cq(Eq,"displayName","ReferenceLine");Cq(Eq,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle"});function nU(){return nU=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},nU.apply(this,arguments)}function I1(t){"@babel/helpers - typeof";return I1=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},I1(t)}function Ire(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 Rre(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ire(Object(r),!0).forEach(function(n){yL(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ire(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Wxt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Vxt(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,Bwe(n.key),n)}}function qxt(t,e,r){return e&&Vxt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Gxt(t,e,r){return e=FR(e),Kxt(t,Fwe()?Reflect.construct(e,r||[],FR(t).constructor):e.apply(t,r))}function Kxt(t,e){if(e&&(I1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Yxt(t)}function Yxt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Fwe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Fwe=function(){return!!t})()}function FR(t){return FR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},FR(t)}function Xxt(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&&sU(t,e)}function sU(t,e){return sU=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},sU(t,e)}function yL(t,e,r){return e=Bwe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Bwe(t){var e=Qxt(t,"string");return I1(e)=="symbol"?e:e+""}function Qxt(t,e){if(I1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(I1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Zxt=function(e){var r=e.x,n=e.y,s=e.xAxis,i=e.yAxis,a=kq({x:s.scale,y:i.scale}),l=a.apply({x:r,y:n},{bandAware:!0});return cd(e,"discard")&&!a.isInRange(l)?null:l},vL=function(t){function e(){return Wxt(this,e),Gxt(this,e,arguments)}return Xxt(e,t),qxt(e,[{key:"render",value:function(){var n=this.props,s=n.x,i=n.y,a=n.r,l=n.alwaysShow,c=n.clipPathId,u=ni(s),d=ni(i);if(Yh(l===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.'),!u||!d)return null;var h=Zxt(this.props);if(!h)return null;var f=h.x,p=h.y,m=this.props,g=m.shape,y=m.className,x=cd(this.props,"hidden")?"url(#".concat(c,")"):void 0,v=Rre(Rre({clipPath:x},cr(this.props,!0)),{},{cx:f,cy:p});return ve.createElement(vs,{className:$r("recharts-reference-dot",y)},e.renderDot(g,v),Zi.renderCallByParent(this.props,{x:f-a,y:p-a,width:2*a,height:2*a}))}}])}(ve.Component);yL(vL,"displayName","ReferenceDot");yL(vL,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#fff",stroke:"#ccc",fillOpacity:1,strokeWidth:1});yL(vL,"renderDot",function(t,e){var r;return ve.isValidElement(t)?r=ve.cloneElement(t,e):hr(t)?r=t(e):r=ve.createElement(_q,nU({},e,{cx:e.cx,cy:e.cy,className:"recharts-reference-dot-dot"})),r});function iU(){return iU=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},iU.apply(this,arguments)}function R1(t){"@babel/helpers - typeof";return R1=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},R1(t)}function Ore(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 Mre(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ore(Object(r),!0).forEach(function(n){bL(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ore(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Jxt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function eyt(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,Uwe(n.key),n)}}function tyt(t,e,r){return e&&eyt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function ryt(t,e,r){return e=BR(e),nyt(t,zwe()?Reflect.construct(e,r||[],BR(t).constructor):e.apply(t,r))}function nyt(t,e){if(e&&(R1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return syt(t)}function syt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function zwe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(zwe=function(){return!!t})()}function BR(t){return BR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},BR(t)}function iyt(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&&aU(t,e)}function aU(t,e){return aU=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},aU(t,e)}function bL(t,e,r){return e=Uwe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Uwe(t){var e=ayt(t,"string");return R1(e)=="symbol"?e:e+""}function ayt(t,e){if(R1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(R1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var oyt=function(e,r,n,s,i){var a=i.x1,l=i.x2,c=i.y1,u=i.y2,d=i.xAxis,h=i.yAxis;if(!d||!h)return null;var f=kq({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(l,{position:"end"}):f.x.rangeMax,y:s?f.y.apply(u,{position:"end"}):f.y.rangeMax};return cd(i,"discard")&&(!f.isInRange(p)||!f.isInRange(m))?null:Pwe(p,m)},wL=function(t){function e(){return Jxt(this,e),ryt(this,e,arguments)}return iyt(e,t),tyt(e,[{key:"render",value:function(){var n=this.props,s=n.x1,i=n.x2,a=n.y1,l=n.y2,c=n.className,u=n.alwaysShow,d=n.clipPathId;Yh(u===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var h=ni(s),f=ni(i),p=ni(a),m=ni(l),g=this.props.shape;if(!h&&!f&&!p&&!m&&!g)return null;var y=oyt(h,f,p,m,this.props);if(!y&&!g)return null;var x=cd(this.props,"hidden")?"url(#".concat(d,")"):void 0;return ve.createElement(vs,{className:$r("recharts-reference-area",c)},e.renderRect(g,Mre(Mre({clipPath:x},cr(this.props,!0)),y)),Zi.renderCallByParent(this.props,y))}}])}(ve.Component);bL(wL,"displayName","ReferenceArea");bL(wL,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#ccc",fillOpacity:.5,stroke:"none",strokeWidth:1});bL(wL,"renderRect",function(t,e){var r;return ve.isValidElement(t)?r=ve.cloneElement(t,e):hr(t)?r=t(e):r=ve.createElement(Sq,iU({},e,{className:"recharts-reference-area-rect"})),r});function Dre(t){return dyt(t)||uyt(t)||cyt(t)||lyt()}function lyt(){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 cyt(t,e){if(t){if(typeof t=="string")return oU(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 oU(t,e)}}function uyt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function dyt(t){if(Array.isArray(t))return oU(t)}function oU(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 lU=function(e,r,n,s,i){var a=od(e,Eq),l=od(e,vL),c=[].concat(Dre(a),Dre(l)),u=od(e,wL),d="".concat(s,"Id"),h=s[0],f=r;if(c.length&&(f=c.reduce(function(g,y){if(y.props[d]===n&&cd(y.props,"extendDomain")&&gt(y.props[h])){var x=y.props[h];return[Math.min(g[0],x),Math.max(g[1],x)]}return g},f)),u.length){var p="".concat(h,"1"),m="".concat(h,"2");f=u.reduce(function(g,y){if(y.props[d]===n&&cd(y.props,"extendDomain")&&gt(y.props[p])&&gt(y.props[m])){var x=y.props[p],v=y.props[m];return[Math.min(g[0],x,v),Math.max(g[1],x,v)]}return g},f)}return i&&i.length&&(f=i.reduce(function(g,y){return gt(y)?[Math.min(g[0],y),Math.max(g[1],y)]:g},f)),f},Hwe={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 l(){this._events=new n,this._eventsCount=0}l.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},l.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},l.prototype.listenerCount=function(u){var d=r?r+u:u,h=this._events[d];return h?h.fn?1:h.length:0},l.prototype.emit=function(u,d,h,f,p,m){var g=r?r+u:u;if(!this._events[g])return!1;var y=this._events[g],x=arguments.length,v,b;if(y.fn){switch(y.once&&this.removeListener(u,y.fn,void 0,!0),x){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,h),!0;case 4:return y.fn.call(y.context,d,h,f),!0;case 5:return y.fn.call(y.context,d,h,f,p),!0;case 6:return y.fn.call(y.context,d,h,f,p,m),!0}for(b=1,v=new Array(x-1);b<x;b++)v[b-1]=arguments[b];y.fn.apply(y.context,v)}else{var w=y.length,j;for(b=0;b<w;b++)switch(y[b].once&&this.removeListener(u,y[b].fn,void 0,!0),x){case 1:y[b].fn.call(y[b].context);break;case 2:y[b].fn.call(y[b].context,d);break;case 3:y[b].fn.call(y[b].context,d,h);break;case 4:y[b].fn.call(y[b].context,d,h,f);break;default:if(!v)for(j=1,v=new Array(x-1);j<x;j++)v[j-1]=arguments[j];y[b].fn.apply(y[b].context,v)}}return!0},l.prototype.on=function(u,d,h){return i(this,u,d,h,!1)},l.prototype.once=function(u,d,h){return i(this,u,d,h,!0)},l.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,y=[],x=m.length;g<x;g++)(m[g].fn!==d||f&&!m[g].once||h&&m[g].context!==h)&&y.push(m[g]);y.length?this._events[p]=y.length===1?y[0]:y:a(this,p)}return this},l.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},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=r,l.EventEmitter=l,t.exports=l})(Hwe);var hyt=Hwe.exports;const fyt=Er(hyt);var y3=new fyt,v3="recharts.syncMouseEvents";function yk(t){"@babel/helpers - typeof";return yk=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},yk(t)}function pyt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function myt(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,Wwe(n.key),n)}}function gyt(t,e,r){return e&&myt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function b3(t,e,r){return e=Wwe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Wwe(t){var e=xyt(t,"string");return yk(e)=="symbol"?e:e+""}function xyt(t,e){if(yk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(yk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var yyt=function(){function t(){pyt(this,t),b3(this,"activeIndex",0),b3(this,"coordinateList",[]),b3(this,"layout","horizontal")}return gyt(t,[{key:"setDetails",value:function(r){var n,s=r.coordinateList,i=s===void 0?null:s,a=r.container,l=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=l??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,l=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+l/2+d;this.mouseHandlerCallback({pageX:h,pageY:f})}}}])}();function vyt(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&&gt(n)&&gt(s))return!0}return!1}function byt(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 Vwe(t){var e=t.cx,r=t.cy,n=t.radius,s=t.startAngle,i=t.endAngle,a=In(e,r,n,s),l=In(e,r,n,i);return{points:[a,l],cx:e,cy:r,radius:n,startAngle:s,endAngle:i}}function wyt(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 l=e.cx,c=e.cy,u=e.innerRadius,d=e.outerRadius,h=e.angle,f=In(l,c,u,h),p=In(l,c,d,h);n=f.x,s=f.y,i=p.x,a=p.y}else return Vwe(e);return[{x:n,y:s},{x:i,y:a}]}function vk(t){"@babel/helpers - typeof";return vk=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},vk(t)}function Lre(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 ST(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Lre(Object(r),!0).forEach(function(n){jyt(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Lre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function jyt(t,e,r){return e=Syt(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Syt(t){var e=_yt(t,"string");return vk(e)=="symbol"?e:e+""}function _yt(t,e){if(vk(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(vk(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Nyt(t){var e,r,n=t.element,s=t.tooltipEventType,i=t.isActive,a=t.activeCoordinate,l=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=Lz;if(f==="ScatterChart")m=a,g=Opt;else if(f==="BarChart")m=byt(h,a,c,d),g=Sq;else if(h==="radial"){var y=Vwe(a),x=y.cx,v=y.cy,b=y.radius,w=y.startAngle,j=y.endAngle;m={cx:x,cy:v,startAngle:w,endAngle:j,innerRadius:b,outerRadius:b},g=lwe}else m={points:wyt(h,a,c)},g=Lz;var N=ST(ST(ST(ST({stroke:"#ccc",pointerEvents:"none"},c),m),cr(p,!1)),{},{payload:l,payloadIndex:u,className:$r("recharts-tooltip-cursor",p.className)});return S.isValidElement(p)?S.cloneElement(p,N):S.createElement(g,N)}var kyt=["item"],Cyt=["children","className","width","height","style","compact","title","desc"];function O1(t){"@babel/helpers - typeof";return O1=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},O1(t)}function Qb(){return Qb=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},Qb.apply(this,arguments)}function $re(t,e){return Tyt(t)||Ayt(t,e)||Gwe(t,e)||Eyt()}function Eyt(){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 Ayt(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,s,i,a,l=[],c=!0,u=!1;try{if(i=(r=r.call(t)).next,e!==0)for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.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 l}}function Tyt(t){if(Array.isArray(t))return t}function Fre(t,e){if(t==null)return{};var r=Pyt(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 Pyt(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 Iyt(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Ryt(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,Kwe(n.key),n)}}function Oyt(t,e,r){return e&&Ryt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Myt(t,e,r){return e=zR(e),Dyt(t,qwe()?Reflect.construct(e,r||[],zR(t).constructor):e.apply(t,r))}function Dyt(t,e){if(e&&(O1(e)==="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Lyt(t)}function Lyt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function qwe(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(qwe=function(){return!!t})()}function zR(t){return zR=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},zR(t)}function $yt(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&&cU(t,e)}function cU(t,e){return cU=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,s){return n.__proto__=s,n},cU(t,e)}function M1(t){return zyt(t)||Byt(t)||Gwe(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 Gwe(t,e){if(t){if(typeof t=="string")return uU(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 uU(t,e)}}function Byt(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function zyt(t){if(Array.isArray(t))return uU(t)}function uU(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 Bre(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 Oe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Bre(Object(r),!0).forEach(function(n){Ut(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Bre(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ut(t,e,r){return e=Kwe(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Kwe(t){var e=Uyt(t,"string");return O1(e)=="symbol"?e:e+""}function Uyt(t,e){if(O1(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(O1(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Hyt={xAxis:["bottom","top"],yAxis:["left","right"]},Wyt={width:"100%",height:"100%"},Ywe={x:0,y:0};function _T(t){return t}var Vyt=function(e,r){return r==="horizontal"?e.x:r==="vertical"?e.y:r==="centric"?e.angle:e.radius},qyt=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,l=s.radius;return Oe(Oe(Oe({},s),In(s.cx,s.cy,l,a)),{},{angle:a,radius:l})}var c=i.coordinate,u=s.angle;return Oe(Oe(Oe({},s),In(s.cx,s.cy,c,u)),{},{angle:u,radius:c})}return Ywe},jL=function(e,r){var n=r.graphicalItems,s=r.dataStartIndex,i=r.dataEndIndex,a=(n??[]).reduce(function(l,c){var u=c.props.data;return u&&u.length?[].concat(M1(l),M1(u)):l},[]);return a.length>0?a:e&&e.length&&gt(s)&&gt(i)?e.slice(s,i+1):[]};function Xwe(t){return t==="number"?[0,"auto"]:void 0}var dU=function(e,r,n,s){var i=e.graphicalItems,a=e.tooltipAxis,l=jL(r,e);return n<0||!i||!i.length||n>=l.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?l:h;f=H8(p,a.dataKey,s)}else f=h&&h[n]||l[n];return f?[].concat(M1(c),[gdt(u,f)]):c},[])},zre=function(e,r,n,s){var i=s||{x:e.chartX,y:e.chartY},a=Vyt(i,n),l=e.orderedTooltipTicks,c=e.tooltipAxis,u=e.tooltipTicks,d=edt(a,l,u,c);if(d>=0&&u){var h=u[d]&&u[d].value,f=dU(e,r,d,h),p=qyt(n,l,d,i);return{activeTooltipIndex:d,activeLabel:h,activePayload:f,activeCoordinate:p}}return null},Gyt=function(e,r){var n=r.axes,s=r.graphicalItems,i=r.axisType,a=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,d=e.layout,h=e.children,f=e.stackOffset,p=twe(d,i);return n.reduce(function(m,g){var y,x=g.type.defaultProps!==void 0?Oe(Oe({},g.type.defaultProps),g.props):g.props,v=x.type,b=x.dataKey,w=x.allowDataOverflow,j=x.allowDuplicatedCategory,N=x.scale,C=x.ticks,A=x.includeHidden,E=x[a];if(m[E])return m;var O=jL(e.data,{graphicalItems:s.filter(function(F){var G,Q=a in F.props?F.props[a]:(G=F.type.defaultProps)===null||G===void 0?void 0:G[a];return Q===E}),dataStartIndex:c,dataEndIndex:u}),$=O.length,T,M,k;vyt(x.domain,w,v)&&(T=Pz(x.domain,null,w),p&&(v==="number"||N!=="auto")&&(k=F_(O,b,"category")));var D=Xwe(v);if(!T||T.length===0){var K,H=(K=x.domain)!==null&&K!==void 0?K:D;if(b){if(T=F_(O,b,v),v==="category"&&p){var ee=zYe(T);j&&ee?(M=T,T=MR(0,$)):j||(T=jte(H,T,g).reduce(function(F,G){return F.indexOf(G)>=0?F:[].concat(M1(F),[G])},[]))}else if(v==="category")j?T=T.filter(function(F){return F!==""&&!Rr(F)}):T=jte(H,T,g).reduce(function(F,G){return F.indexOf(G)>=0||G===""||Rr(G)?F:[].concat(M1(F),[G])},[]);else if(v==="number"){var V=idt(O,s.filter(function(F){var G,Q,ie=a in F.props?F.props[a]:(G=F.type.defaultProps)===null||G===void 0?void 0:G[a],se="hide"in F.props?F.props.hide:(Q=F.type.defaultProps)===null||Q===void 0?void 0:Q.hide;return ie===E&&(A||!se)}),b,i,d);V&&(T=V)}p&&(v==="number"||N!=="auto")&&(k=F_(O,b,"category"))}else p?T=MR(0,$):l&&l[E]&&l[E].hasStack&&v==="number"?T=f==="expand"?[0,1]:rwe(l[E].stackGroups,c,u):T=ewe(O,s.filter(function(F){var G=a in F.props?F.props[a]:F.type.defaultProps[a],Q="hide"in F.props?F.props.hide:F.type.defaultProps.hide;return G===E&&(A||!Q)}),v,d,!0);if(v==="number")T=lU(h,T,E,i,C),H&&(T=Pz(H,T,w));else if(v==="category"&&H){var B=H,z=T.every(function(F){return B.indexOf(F)>=0});z&&(T=B)}}return Oe(Oe({},m),{},Ut({},E,Oe(Oe({},x),{},{axisType:i,domain:T,categoricalDomain:k,duplicateDomain:M,originalDomain:(y=x.domain)!==null&&y!==void 0?y:D,isCategorical:p,layout:d})))},{})},Kyt=function(e,r){var n=r.graphicalItems,s=r.Axis,i=r.axisType,a=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,d=e.layout,h=e.children,f=jL(e.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:u}),p=f.length,m=twe(d,i),g=-1;return n.reduce(function(y,x){var v=x.type.defaultProps!==void 0?Oe(Oe({},x.type.defaultProps),x.props):x.props,b=v[a],w=Xwe("number");if(!y[b]){g++;var j;return m?j=MR(0,p):l&&l[b]&&l[b].hasStack?(j=rwe(l[b].stackGroups,c,u),j=lU(h,j,b,i)):(j=Pz(w,ewe(f,n.filter(function(N){var C,A,E=a in N.props?N.props[a]:(C=N.type.defaultProps)===null||C===void 0?void 0:C[a],O="hide"in N.props?N.props.hide:(A=N.type.defaultProps)===null||A===void 0?void 0:A.hide;return E===b&&!O}),"number",d),s.defaultProps.allowDataOverflow),j=lU(h,j,b,i)),Oe(Oe({},y),{},Ut({},b,Oe(Oe({axisType:i},s.defaultProps),{},{hide:!0,orientation:Xc(Hyt,"".concat(i,".").concat(g%2),null),domain:j,originalDomain:w,isCategorical:m,layout:d})))}return y},{})},Yyt=function(e,r){var n=r.axisType,s=n===void 0?"xAxis":n,i=r.AxisComp,a=r.graphicalItems,l=r.stackGroups,c=r.dataStartIndex,u=r.dataEndIndex,d=e.children,h="".concat(s,"Id"),f=od(d,i),p={};return f&&f.length?p=Gyt(e,{axes:f,graphicalItems:a,axisType:s,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:u}):a&&a.length&&(p=Kyt(e,{Axis:i,graphicalItems:a,axisType:s,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:u})),p},Xyt=function(e){var r=mb(e),n=US(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:KV(n,function(s){return s.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Iz(r,n)}},Ure=function(e){var r=e.children,n=e.defaultShowTooltip,s=$l(r,T1),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}},Qyt=function(e){return!e||!e.length?!1:e.some(function(r){var n=Kh(r&&r.type);return n&&n.indexOf("Bar")>=0})},Hre=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"}},Zyt=function(e,r){var n=e.props,s=e.graphicalItems,i=e.xAxisMap,a=i===void 0?{}:i,l=e.yAxisMap,c=l===void 0?{}:l,u=n.width,d=n.height,h=n.children,f=n.margin||{},p=$l(h,T1),m=$l(h,b0),g=Object.keys(c).reduce(function(j,N){var C=c[N],A=C.orientation;return!C.mirror&&!C.hide?Oe(Oe({},j),{},Ut({},A,j[A]+C.width)):j},{left:f.left||0,right:f.right||0}),y=Object.keys(a).reduce(function(j,N){var C=a[N],A=C.orientation;return!C.mirror&&!C.hide?Oe(Oe({},j),{},Ut({},A,Xc(j,"".concat(A))+C.height)):j},{top:f.top||0,bottom:f.bottom||0}),x=Oe(Oe({},y),g),v=x.bottom;p&&(x.bottom+=p.props.height||T1.defaultProps.height),m&&r&&(x=ndt(x,s,n,r));var b=u-x.left-x.right,w=d-x.top-x.bottom;return Oe(Oe({brushBottom:v},x),{},{width:Math.max(b,0),height:Math.max(w,0)})},Jyt=function(e,r){if(r==="xAxis")return e[r].width;if(r==="yAxis")return e[r].height},evt=function(e){var r=e.chartName,n=e.GraphicalChild,s=e.defaultTooltipEventType,i=s===void 0?"axis":s,a=e.validateTooltipEventTypes,l=a===void 0?["axis"]:a,c=e.axisComponents,u=e.legendContent,d=e.formatAxisMap,h=e.defaultProps,f=function(x,v){var b=v.graphicalItems,w=v.stackGroups,j=v.offset,N=v.updateId,C=v.dataStartIndex,A=v.dataEndIndex,E=x.barSize,O=x.layout,$=x.barGap,T=x.barCategoryGap,M=x.maxBarSize,k=Hre(O),D=k.numericAxisName,K=k.cateAxisName,H=Qyt(b),ee=[];return b.forEach(function(V,B){var z=jL(x.data,{graphicalItems:[V],dataStartIndex:C,dataEndIndex:A}),F=V.type.defaultProps!==void 0?Oe(Oe({},V.type.defaultProps),V.props):V.props,G=F.dataKey,Q=F.maxBarSize,ie=F["".concat(D,"Id")],se=F["".concat(K,"Id")],q={},L=c.reduce(function(ue,ae){var ge=v["".concat(ae.axisType,"Map")],we=F["".concat(ae.axisType,"Id")];ge&&ge[we]||ae.axisType==="zAxis"||S1();var ce=ge[we];return Oe(Oe({},ue),{},Ut(Ut({},ae.axisType,ce),"".concat(ae.axisType,"Ticks"),US(ce)))},q),Z=L[K],J=L["".concat(K,"Ticks")],W=w&&w[ie]&&w[ie].hasStack&&pdt(V,w[ie].stackGroups),X=Kh(V.type).indexOf("Bar")>=0,he=Iz(Z,J),P=[],oe=H&&tdt({barSize:E,stackGroups:w,totalSize:Jyt(L,K)});if(X){var Y,R,I=Rr(Q)?M:Q,U=(Y=(R=Iz(Z,J,!0))!==null&&R!==void 0?R:I)!==null&&Y!==void 0?Y:0;P=rdt({barGap:$,barCategoryGap:T,bandSize:U!==he?U:he,sizeList:oe[se],maxBarSize:I}),U!==he&&(P=P.map(function(ue){return Oe(Oe({},ue),{},{position:Oe(Oe({},ue.position),{},{offset:ue.position.offset-U/2})})}))}var re=V&&V.type&&V.type.getComposedData;re&&ee.push({props:Oe(Oe({},re(Oe(Oe({},L),{},{displayedData:z,props:x,dataKey:G,item:V,bandSize:he,barPosition:P,offset:j,stackedData:W,layout:O,dataStartIndex:C,dataEndIndex:A}))),{},Ut(Ut(Ut({key:V.key||"item-".concat(B)},D,L[D]),K,L[K]),"animationId",N)),childIndex:ZYe(V,x.children),item:V})}),ee},p=function(x,v){var b=x.props,w=x.dataStartIndex,j=x.dataEndIndex,N=x.updateId;if(!gJ({props:b}))return null;var C=b.children,A=b.layout,E=b.stackOffset,O=b.data,$=b.reverseStackOrder,T=Hre(A),M=T.numericAxisName,k=T.cateAxisName,D=od(C,n),K=hdt(O,D,"".concat(M,"Id"),"".concat(k,"Id"),E,$),H=c.reduce(function(F,G){var Q="".concat(G.axisType,"Map");return Oe(Oe({},F),{},Ut({},Q,Yyt(b,Oe(Oe({},G),{},{graphicalItems:D,stackGroups:G.axisType===M&&K,dataStartIndex:w,dataEndIndex:j}))))},{}),ee=Zyt(Oe(Oe({},H),{},{props:b,graphicalItems:D}),v==null?void 0:v.legendBBox);Object.keys(H).forEach(function(F){H[F]=d(b,H[F],ee,F.replace("Map",""),r)});var V=H["".concat(k,"Map")],B=Xyt(V),z=f(b,Oe(Oe({},H),{},{dataStartIndex:w,dataEndIndex:j,updateId:N,graphicalItems:D,stackGroups:K,offset:ee}));return Oe(Oe({formattedGraphicalItems:z,graphicalItems:D,offset:ee,stackGroups:K},B),H)},m=function(y){function x(v){var b,w,j;return Iyt(this,x),j=Myt(this,x,[v]),Ut(j,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),Ut(j,"accessibilityManager",new yyt),Ut(j,"handleLegendBBoxUpdate",function(N){if(N){var C=j.state,A=C.dataStartIndex,E=C.dataEndIndex,O=C.updateId;j.setState(Oe({legendBBox:N},p({props:j.props,dataStartIndex:A,dataEndIndex:E,updateId:O},Oe(Oe({},j.state),{},{legendBBox:N}))))}}),Ut(j,"handleReceiveSyncEvent",function(N,C,A){if(j.props.syncId===N){if(A===j.eventEmitterSymbol&&typeof j.props.syncMethod!="function")return;j.applySyncEvent(C)}}),Ut(j,"handleBrushChange",function(N){var C=N.startIndex,A=N.endIndex;if(C!==j.state.dataStartIndex||A!==j.state.dataEndIndex){var E=j.state.updateId;j.setState(function(){return Oe({dataStartIndex:C,dataEndIndex:A},p({props:j.props,dataStartIndex:C,dataEndIndex:A,updateId:E},j.state))}),j.triggerSyncEvent({dataStartIndex:C,dataEndIndex:A})}}),Ut(j,"handleMouseEnter",function(N){var C=j.getMouseInfo(N);if(C){var A=Oe(Oe({},C),{},{isTooltipActive:!0});j.setState(A),j.triggerSyncEvent(A);var E=j.props.onMouseEnter;hr(E)&&E(A,N)}}),Ut(j,"triggeredAfterMouseMove",function(N){var C=j.getMouseInfo(N),A=C?Oe(Oe({},C),{},{isTooltipActive:!0}):{isTooltipActive:!1};j.setState(A),j.triggerSyncEvent(A);var E=j.props.onMouseMove;hr(E)&&E(A,N)}),Ut(j,"handleItemMouseEnter",function(N){j.setState(function(){return{isTooltipActive:!0,activeItem:N,activePayload:N.tooltipPayload,activeCoordinate:N.tooltipPosition||{x:N.cx,y:N.cy}}})}),Ut(j,"handleItemMouseLeave",function(){j.setState(function(){return{isTooltipActive:!1}})}),Ut(j,"handleMouseMove",function(N){N.persist(),j.throttleTriggeredAfterMouseMove(N)}),Ut(j,"handleMouseLeave",function(N){j.throttleTriggeredAfterMouseMove.cancel();var C={isTooltipActive:!1};j.setState(C),j.triggerSyncEvent(C);var A=j.props.onMouseLeave;hr(A)&&A(C,N)}),Ut(j,"handleOuterEvent",function(N){var C=QYe(N),A=Xc(j.props,"".concat(C));if(C&&hr(A)){var E,O;/.*touch.*/i.test(C)?O=j.getMouseInfo(N.changedTouches[0]):O=j.getMouseInfo(N),A((E=O)!==null&&E!==void 0?E:{},N)}}),Ut(j,"handleClick",function(N){var C=j.getMouseInfo(N);if(C){var A=Oe(Oe({},C),{},{isTooltipActive:!0});j.setState(A),j.triggerSyncEvent(A);var E=j.props.onClick;hr(E)&&E(A,N)}}),Ut(j,"handleMouseDown",function(N){var C=j.props.onMouseDown;if(hr(C)){var A=j.getMouseInfo(N);C(A,N)}}),Ut(j,"handleMouseUp",function(N){var C=j.props.onMouseUp;if(hr(C)){var A=j.getMouseInfo(N);C(A,N)}}),Ut(j,"handleTouchMove",function(N){N.changedTouches!=null&&N.changedTouches.length>0&&j.throttleTriggeredAfterMouseMove(N.changedTouches[0])}),Ut(j,"handleTouchStart",function(N){N.changedTouches!=null&&N.changedTouches.length>0&&j.handleMouseDown(N.changedTouches[0])}),Ut(j,"handleTouchEnd",function(N){N.changedTouches!=null&&N.changedTouches.length>0&&j.handleMouseUp(N.changedTouches[0])}),Ut(j,"handleDoubleClick",function(N){var C=j.props.onDoubleClick;if(hr(C)){var A=j.getMouseInfo(N);C(A,N)}}),Ut(j,"handleContextMenu",function(N){var C=j.props.onContextMenu;if(hr(C)){var A=j.getMouseInfo(N);C(A,N)}}),Ut(j,"triggerSyncEvent",function(N){j.props.syncId!==void 0&&y3.emit(v3,j.props.syncId,N,j.eventEmitterSymbol)}),Ut(j,"applySyncEvent",function(N){var C=j.props,A=C.layout,E=C.syncMethod,O=j.state.updateId,$=N.dataStartIndex,T=N.dataEndIndex;if(N.dataStartIndex!==void 0||N.dataEndIndex!==void 0)j.setState(Oe({dataStartIndex:$,dataEndIndex:T},p({props:j.props,dataStartIndex:$,dataEndIndex:T,updateId:O},j.state)));else if(N.activeTooltipIndex!==void 0){var M=N.chartX,k=N.chartY,D=N.activeTooltipIndex,K=j.state,H=K.offset,ee=K.tooltipTicks;if(!H)return;if(typeof E=="function")D=E(ee,N);else if(E==="value"){D=-1;for(var V=0;V<ee.length;V++)if(ee[V].value===N.activeLabel){D=V;break}}var B=Oe(Oe({},H),{},{x:H.left,y:H.top}),z=Math.min(M,B.x+B.width),F=Math.min(k,B.y+B.height),G=ee[D]&&ee[D].value,Q=dU(j.state,j.props.data,D),ie=ee[D]?{x:A==="horizontal"?ee[D].coordinate:z,y:A==="horizontal"?F:ee[D].coordinate}:Ywe;j.setState(Oe(Oe({},N),{},{activeLabel:G,activeCoordinate:ie,activePayload:Q,activeTooltipIndex:D}))}else j.setState(N)}),Ut(j,"renderCursor",function(N){var C,A=j.state,E=A.isTooltipActive,O=A.activeCoordinate,$=A.activePayload,T=A.offset,M=A.activeTooltipIndex,k=A.tooltipAxisBandSize,D=j.getTooltipEventType(),K=(C=N.props.active)!==null&&C!==void 0?C:E,H=j.props.layout,ee=N.key||"_recharts-cursor";return ve.createElement(Nyt,{key:ee,activeCoordinate:O,activePayload:$,activeTooltipIndex:M,chartName:r,element:N,isActive:K,layout:H,offset:T,tooltipAxisBandSize:k,tooltipEventType:D})}),Ut(j,"renderPolarAxis",function(N,C,A){var E=Xc(N,"type.axisType"),O=Xc(j.state,"".concat(E,"Map")),$=N.type.defaultProps,T=$!==void 0?Oe(Oe({},$),N.props):N.props,M=O&&O[T["".concat(E,"Id")]];return S.cloneElement(N,Oe(Oe({},M),{},{className:$r(E,M.className),key:N.key||"".concat(C,"-").concat(A),ticks:US(M,!0)}))}),Ut(j,"renderPolarGrid",function(N){var C=N.props,A=C.radialLines,E=C.polarAngles,O=C.polarRadius,$=j.state,T=$.radiusAxisMap,M=$.angleAxisMap,k=mb(T),D=mb(M),K=D.cx,H=D.cy,ee=D.innerRadius,V=D.outerRadius;return S.cloneElement(N,{polarAngles:Array.isArray(E)?E:US(D,!0).map(function(B){return B.coordinate}),polarRadius:Array.isArray(O)?O:US(k,!0).map(function(B){return B.coordinate}),cx:K,cy:H,innerRadius:ee,outerRadius:V,key:N.key||"polar-grid",radialLines:A})}),Ut(j,"renderLegend",function(){var N=j.state.formattedGraphicalItems,C=j.props,A=C.children,E=C.width,O=C.height,$=j.props.margin||{},T=E-($.left||0)-($.right||0),M=Z0e({children:A,formattedGraphicalItems:N,legendWidth:T,legendContent:u});if(!M)return null;var k=M.item,D=Fre(M,kyt);return S.cloneElement(k,Oe(Oe({},D),{},{chartWidth:E,chartHeight:O,margin:$,onBBoxUpdate:j.handleLegendBBoxUpdate}))}),Ut(j,"renderTooltip",function(){var N,C=j.props,A=C.children,E=C.accessibilityLayer,O=$l(A,Kd);if(!O)return null;var $=j.state,T=$.isTooltipActive,M=$.activeCoordinate,k=$.activePayload,D=$.activeLabel,K=$.offset,H=(N=O.props.active)!==null&&N!==void 0?N:T;return S.cloneElement(O,{viewBox:Oe(Oe({},K),{},{x:K.left,y:K.top}),active:H,label:D,payload:H?k:[],coordinate:M,accessibilityLayer:E})}),Ut(j,"renderBrush",function(N){var C=j.props,A=C.margin,E=C.data,O=j.state,$=O.offset,T=O.dataStartIndex,M=O.dataEndIndex,k=O.updateId;return S.cloneElement(N,{key:N.key||"_recharts-brush",onChange:vT(j.handleBrushChange,N.props.onChange),data:E,x:gt(N.props.x)?N.props.x:$.left,y:gt(N.props.y)?N.props.y:$.top+$.height+$.brushBottom-(A.bottom||0),width:gt(N.props.width)?N.props.width:$.width,startIndex:T,endIndex:M,updateId:"brush-".concat(k)})}),Ut(j,"renderReferenceElement",function(N,C,A){if(!N)return null;var E=j,O=E.clipPathId,$=j.state,T=$.xAxisMap,M=$.yAxisMap,k=$.offset,D=N.type.defaultProps||{},K=N.props,H=K.xAxisId,ee=H===void 0?D.xAxisId:H,V=K.yAxisId,B=V===void 0?D.yAxisId:V;return S.cloneElement(N,{key:N.key||"".concat(C,"-").concat(A),xAxis:T[ee],yAxis:M[B],viewBox:{x:k.left,y:k.top,width:k.width,height:k.height},clipPathId:O})}),Ut(j,"renderActivePoints",function(N){var C=N.item,A=N.activePoint,E=N.basePoint,O=N.childIndex,$=N.isRange,T=[],M=C.props.key,k=C.item.type.defaultProps!==void 0?Oe(Oe({},C.item.type.defaultProps),C.item.props):C.item.props,D=k.activeDot,K=k.dataKey,H=Oe(Oe({index:O,dataKey:K,cx:A.x,cy:A.y,r:4,fill:jq(C.item),strokeWidth:2,stroke:"#fff",payload:A.payload,value:A.value},cr(D,!1)),YI(D));return T.push(x.renderActiveDot(D,H,"".concat(M,"-activePoint-").concat(O))),E?T.push(x.renderActiveDot(D,Oe(Oe({},H),{},{cx:E.x,cy:E.y}),"".concat(M,"-basePoint-").concat(O))):$&&T.push(null),T}),Ut(j,"renderGraphicChild",function(N,C,A){var E=j.filterFormatItem(N,C,A);if(!E)return null;var O=j.getTooltipEventType(),$=j.state,T=$.isTooltipActive,M=$.tooltipAxis,k=$.activeTooltipIndex,D=$.activeLabel,K=j.props.children,H=$l(K,Kd),ee=E.props,V=ee.points,B=ee.isRange,z=ee.baseLine,F=E.item.type.defaultProps!==void 0?Oe(Oe({},E.item.type.defaultProps),E.item.props):E.item.props,G=F.activeDot,Q=F.hide,ie=F.activeBar,se=F.activeShape,q=!!(!Q&&T&&H&&(G||ie||se)),L={};O!=="axis"&&H&&H.props.trigger==="click"?L={onClick:vT(j.handleItemMouseEnter,N.props.onClick)}:O!=="axis"&&(L={onMouseLeave:vT(j.handleItemMouseLeave,N.props.onMouseLeave),onMouseEnter:vT(j.handleItemMouseEnter,N.props.onMouseEnter)});var Z=S.cloneElement(N,Oe(Oe({},E.props),L));function J(ae){return typeof M.dataKey=="function"?M.dataKey(ae.payload):null}if(q)if(k>=0){var W,X;if(M.dataKey&&!M.allowDuplicatedCategory){var he=typeof M.dataKey=="function"?J:"payload.".concat(M.dataKey.toString());W=H8(V,he,D),X=B&&z&&H8(z,he,D)}else W=V==null?void 0:V[k],X=B&&z&&z[k];if(se||ie){var P=N.props.activeIndex!==void 0?N.props.activeIndex:k;return[S.cloneElement(N,Oe(Oe(Oe({},E.props),L),{},{activeIndex:P})),null,null]}if(!Rr(W))return[Z].concat(M1(j.renderActivePoints({item:E,activePoint:W,basePoint:X,childIndex:k,isRange:B})))}else{var oe,Y=(oe=j.getItemByXY(j.state.activeCoordinate))!==null&&oe!==void 0?oe:{graphicalItem:Z},R=Y.graphicalItem,I=R.item,U=I===void 0?N:I,re=R.childIndex,ue=Oe(Oe(Oe({},E.props),L),{},{activeIndex:re});return[S.cloneElement(U,ue),null,null]}return B?[Z,null,null]:[Z,null]}),Ut(j,"renderCustomized",function(N,C,A){return S.cloneElement(N,Oe(Oe({key:"recharts-customized-".concat(A)},j.props),j.state))}),Ut(j,"renderMap",{CartesianGrid:{handler:_T,once:!0},ReferenceArea:{handler:j.renderReferenceElement},ReferenceLine:{handler:_T},ReferenceDot:{handler:j.renderReferenceElement},XAxis:{handler:_T},YAxis:{handler:_T},Brush:{handler:j.renderBrush,once:!0},Bar:{handler:j.renderGraphicChild},Line:{handler:j.renderGraphicChild},Area:{handler:j.renderGraphicChild},Radar:{handler:j.renderGraphicChild},RadialBar:{handler:j.renderGraphicChild},Scatter:{handler:j.renderGraphicChild},Pie:{handler:j.renderGraphicChild},Funnel:{handler:j.renderGraphicChild},Tooltip:{handler:j.renderCursor,once:!0},PolarGrid:{handler:j.renderPolarGrid,once:!0},PolarAngleAxis:{handler:j.renderPolarAxis},PolarRadiusAxis:{handler:j.renderPolarAxis},Customized:{handler:j.renderCustomized}}),j.clipPathId="".concat((b=v.id)!==null&&b!==void 0?b:qD("recharts"),"-clip"),j.throttleTriggeredAfterMouseMove=Qbe(j.triggeredAfterMouseMove,(w=v.throttleDelay)!==null&&w!==void 0?w:1e3/60),j.state={},j}return $yt(x,y),Oyt(x,[{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,j=b.data,N=b.height,C=b.layout,A=$l(w,Kd);if(A){var E=A.props.defaultIndex;if(!(typeof E!="number"||E<0||E>this.state.tooltipTicks.length-1)){var O=this.state.tooltipTicks[E]&&this.state.tooltipTicks[E].value,$=dU(this.state,j,E,O),T=this.state.tooltipTicks[E].coordinate,M=(this.state.offset.top+N)/2,k=C==="horizontal",D=k?{x:T,y:M}:{y:T,x:M},K=this.state.formattedGraphicalItems.find(function(ee){var V=ee.item;return V.type.name==="Scatter"});K&&(D=Oe(Oe({},D),K.props.points[E].tooltipPosition),$=K.props.points[E].tooltipPayload);var H={activeTooltipIndex:E,isTooltipActive:!0,activeLabel:O,activePayload:$,activeCoordinate:D};this.setState(H),this.renderCursor(A),this.accessibilityManager.setIndex(E)}}}},{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 j,N;this.accessibilityManager.setDetails({offset:{left:(j=this.props.margin.left)!==null&&j!==void 0?j:0,top:(N=this.props.margin.top)!==null&&N!==void 0?N:0}})}return null}},{key:"componentDidUpdate",value:function(b){q8([$l(b.children,Kd)],[$l(this.props.children,Kd)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var b=$l(this.props.children,Kd);if(b&&typeof b.props.shared=="boolean"){var w=b.props.shared?"axis":"item";return l.indexOf(w)>=0?w:i}return i}},{key:"getMouseInfo",value:function(b){if(!this.container)return null;var w=this.container,j=w.getBoundingClientRect(),N=Eat(j),C={chartX:Math.round(b.pageX-N.left),chartY:Math.round(b.pageY-N.top)},A=j.width/w.offsetWidth||1,E=this.inRange(C.chartX,C.chartY,A);if(!E)return null;var O=this.state,$=O.xAxisMap,T=O.yAxisMap,M=this.getTooltipEventType(),k=zre(this.state,this.props.data,this.props.layout,E);if(M!=="axis"&&$&&T){var D=mb($).scale,K=mb(T).scale,H=D&&D.invert?D.invert(C.chartX):null,ee=K&&K.invert?K.invert(C.chartY):null;return Oe(Oe({},C),{},{xValue:H,yValue:ee},k)}return k?Oe(Oe({},C),k):null}},{key:"inRange",value:function(b,w){var j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,N=this.props.layout,C=b/j,A=w/j;if(N==="horizontal"||N==="vertical"){var E=this.state.offset,O=C>=E.left&&C<=E.left+E.width&&A>=E.top&&A<=E.top+E.height;return O?{x:C,y:A}:null}var $=this.state,T=$.angleAxisMap,M=$.radiusAxisMap;if(T&&M){var k=mb(T);return Nte({x:C,y:A},k)}return null}},{key:"parseEventsOfWrapper",value:function(){var b=this.props.children,w=this.getTooltipEventType(),j=$l(b,Kd),N={};j&&w==="axis"&&(j.props.trigger==="click"?N={onClick:this.handleClick}:N={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 C=YI(this.props,this.handleOuterEvent);return Oe(Oe({},C),N)}},{key:"addListener",value:function(){y3.on(v3,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){y3.removeListener(v3,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(b,w,j){for(var N=this.state.formattedGraphicalItems,C=0,A=N.length;C<A;C++){var E=N[C];if(E.item===b||E.props.key===b.key||w===Kh(E.item.type)&&j===E.childIndex)return E}return null}},{key:"renderClipPath",value:function(){var b=this.clipPathId,w=this.state.offset,j=w.left,N=w.top,C=w.height,A=w.width;return ve.createElement("defs",null,ve.createElement("clipPath",{id:b},ve.createElement("rect",{x:j,y:N,height:C,width:A})))}},{key:"getXScales",value:function(){var b=this.state.xAxisMap;return b?Object.entries(b).reduce(function(w,j){var N=$re(j,2),C=N[0],A=N[1];return Oe(Oe({},w),{},Ut({},C,A.scale))},{}):null}},{key:"getYScales",value:function(){var b=this.state.yAxisMap;return b?Object.entries(b).reduce(function(w,j){var N=$re(j,2),C=N[0],A=N[1];return Oe(Oe({},w),{},Ut({},C,A.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,j=w.formattedGraphicalItems,N=w.activeItem;if(j&&j.length)for(var C=0,A=j.length;C<A;C++){var E=j[C],O=E.props,$=E.item,T=$.type.defaultProps!==void 0?Oe(Oe({},$.type.defaultProps),$.props):$.props,M=Kh($.type);if(M==="Bar"){var k=(O.data||[]).find(function(ee){return ppt(b,ee)});if(k)return{graphicalItem:E,payload:k}}else if(M==="RadialBar"){var D=(O.data||[]).find(function(ee){return Nte(b,ee)});if(D)return{graphicalItem:E,payload:D}}else if(gL(E,N)||xL(E,N)||mk(E,N)){var K=ngt({graphicalItem:E,activeTooltipItem:N,itemData:T.data}),H=T.activeIndex===void 0?K:T.activeIndex;return{graphicalItem:Oe(Oe({},E),{},{childIndex:H}),payload:mk(E,N)?T.data[K]:E.props.data[K]}}}return null}},{key:"render",value:function(){var b=this;if(!gJ(this))return null;var w=this.props,j=w.children,N=w.className,C=w.width,A=w.height,E=w.style,O=w.compact,$=w.title,T=w.desc,M=Fre(w,Cyt),k=cr(M,!1);if(O)return ve.createElement(Ere,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},ve.createElement(K8,Qb({},k,{width:C,height:A,title:$,desc:T}),this.renderClipPath(),yJ(j,this.renderMap)));if(this.props.accessibilityLayer){var D,K;k.tabIndex=(D=this.props.tabIndex)!==null&&D!==void 0?D:0,k.role=(K=this.props.role)!==null&&K!==void 0?K:"application",k.onKeyDown=function(ee){b.accessibilityManager.keyboardEvent(ee)},k.onFocus=function(){b.accessibilityManager.focus()}}var H=this.parseEventsOfWrapper();return ve.createElement(Ere,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},ve.createElement("div",Qb({className:$r("recharts-wrapper",N),style:Oe({position:"relative",cursor:"default",width:C,height:A},E)},H,{ref:function(V){b.container=V}}),ve.createElement(K8,Qb({},k,{width:C,height:A,title:$,desc:T,style:Wyt}),this.renderClipPath(),yJ(j,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(S.Component);Ut(m,"displayName",r),Ut(m,"defaultProps",Oe({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},h)),Ut(m,"getDerivedStateFromProps",function(y,x){var v=y.dataKey,b=y.data,w=y.children,j=y.width,N=y.height,C=y.layout,A=y.stackOffset,E=y.margin,O=x.dataStartIndex,$=x.dataEndIndex;if(x.updateId===void 0){var T=Ure(y);return Oe(Oe(Oe({},T),{},{updateId:0},p(Oe(Oe({props:y},T),{},{updateId:0}),x)),{},{prevDataKey:v,prevData:b,prevWidth:j,prevHeight:N,prevLayout:C,prevStackOffset:A,prevMargin:E,prevChildren:w})}if(v!==x.prevDataKey||b!==x.prevData||j!==x.prevWidth||N!==x.prevHeight||C!==x.prevLayout||A!==x.prevStackOffset||!W8(E,x.prevMargin)){var M=Ure(y),k={chartX:x.chartX,chartY:x.chartY,isTooltipActive:x.isTooltipActive},D=Oe(Oe({},zre(x,b,C)),{},{updateId:x.updateId+1}),K=Oe(Oe(Oe({},M),k),D);return Oe(Oe(Oe({},K),p(Oe({props:y},K),x)),{},{prevDataKey:v,prevData:b,prevWidth:j,prevHeight:N,prevLayout:C,prevStackOffset:A,prevMargin:E,prevChildren:w})}if(!q8(w,x.prevChildren)){var H,ee,V,B,z=$l(w,T1),F=z&&(H=(ee=z.props)===null||ee===void 0?void 0:ee.startIndex)!==null&&H!==void 0?H:O,G=z&&(V=(B=z.props)===null||B===void 0?void 0:B.endIndex)!==null&&V!==void 0?V:$,Q=F!==O||G!==$,ie=!Rr(b),se=ie&&!Q?x.updateId:x.updateId+1;return Oe(Oe({updateId:se},p(Oe(Oe({props:y},x),{},{updateId:se,dataStartIndex:F,dataEndIndex:G}),x)),{},{prevChildren:w,dataStartIndex:F,dataEndIndex:G})}return null}),Ut(m,"renderActiveDot",function(y,x,v){var b;return S.isValidElement(y)?b=S.cloneElement(y,x):hr(y)?b=y(x):b=ve.createElement(_q,x),ve.createElement(vs,{className:"recharts-active-dot",key:v},b)});var g=S.forwardRef(function(x,v){return ve.createElement(m,Qb({},x,{ref:v}))});return g.displayName=m.displayName,g},tvt=evt({chartName:"PieChart",GraphicalChild:Pf,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:mL},{axisType:"radiusAxis",AxisComp:fL}],formatAxisMap:Ndt,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});function rvt({stats:t,chapters:e}){const r=(t==null?void 0:t.active_thesis_progress)??0,n=t==null?void 0:t.active_thesis_title,s=c=>c<=25?"The start is made.":c<=50?"Well on your way! Keep the pace.":c<=75?"Halfway done and you're great!":"The final stretch is on. Almost there!",i=[{name:"completed",value:r},{name:"remaining",value:Math.max(0,100-r)}],a=c=>c>=75?"hsl(var(--success))":c>=50?"hsl(var(--warning))":c>=25?"hsl(var(--primary))":"hsl(var(--muted-foreground))";if(!n)return o.jsx(Ze,{className:"h-full rounded-lg border-border bg-card shadow-theme-xs",children:o.jsxs(st,{className:"flex flex-col items-center justify-center h-full py-8",children:[o.jsx("div",{className:"w-16 h-16 rounded-full bg-muted/50 flex items-center justify-center mb-4",children:o.jsx(_N,{className:"w-8 h-8 text-muted-foreground"})}),o.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"No active thesis yet"}),o.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1",children:"Create one to track progress"})]})});const l=a(r);return o.jsx(Ze,{className:"h-full overflow-hidden rounded-lg border-border bg-card shadow-theme-xs",children:o.jsxs(st,{className:"px-5 py-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-base font-semibold text-foreground",children:"Thesis Progress"}),r>=50&&o.jsxs("div",{className:"flex items-center gap-1 text-success",children:[o.jsx(PMe,{className:"w-3 h-3"}),o.jsx("span",{className:"text-xs font-medium",children:"On track"})]})]}),o.jsxs("div",{className:"flex items-center gap-4 border-b border-border pb-4",children:[o.jsxs("div",{className:"relative h-[126px] w-[126px] shrink-0",children:[o.jsx(wat,{width:"100%",height:"100%",children:o.jsxs(tvt,{children:[o.jsx("defs",{children:o.jsxs("filter",{id:"glow",children:[o.jsx("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),o.jsxs("feMerge",{children:[o.jsx("feMergeNode",{in:"coloredBlur"}),o.jsx("feMergeNode",{in:"SourceGraphic"})]})]})}),o.jsxs(Pf,{data:i,cx:"50%",cy:"50%",innerRadius:45,outerRadius:60,startAngle:90,endAngle:-270,paddingAngle:2,dataKey:"value",strokeWidth:0,filter:r>=50?"url(#glow)":void 0,children:[o.jsx(lR,{fill:l}),o.jsx(lR,{fill:"hsl(var(--muted))"})]})]})}),o.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:o.jsxs("span",{className:"text-3xl font-bold text-foreground",children:[Math.round(r),"%"]})})]}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"font-semibold text-foreground",children:"Thesis Progress"}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:s(r)})]})]}),o.jsxs("div",{className:"pt-4",children:[o.jsx("p",{className:"mb-3 text-sm font-semibold text-foreground",children:"Chapter Progress"}),e.length>0?o.jsx("div",{className:"space-y-2.5",children:e.map((c,u)=>{const d=Math.min(100,Math.max(0,Number(c.progress)||0));return o.jsxs("div",{className:"grid grid-cols-[18px_minmax(90px,1fr)_minmax(90px,1.6fr)_38px] items-center gap-2 text-xs",children:[o.jsxs("span",{className:"text-muted-foreground",children:[u+1,"."]}),o.jsx("span",{className:"truncate text-muted-foreground",title:c.title,children:c.title}),o.jsx(yj,{value:d,size:"sm",animated:!1}),o.jsxs("span",{className:"text-right font-medium tabular-nums text-foreground",children:[Math.round(d),"%"]})]},c.id)})}):o.jsx("p",{className:"py-4 text-center text-sm text-muted-foreground",children:"No chapters available yet."})]})]})})}function nvt(){const{stats:t,chapters:e,loading:r,refetch:n}=QUe(),{userProfile:s}=Ht(),i=Or();return r?o.jsx(Lve,{}):o.jsxs("div",{className:"space-y-3 animate-fade-in motion-reduce:animate-none",children:[(s==null?void 0:s.plan)==="free"&&o.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:[o.jsx(Sr,{className:"h-5 w-5 text-amber-600 mt-0.5 shrink-0"}),o.jsxs("div",{children:[o.jsx("p",{className:"font-semibold text-amber-900 dark:text-amber-200",children:"Welcome to Academly Beta! 🎉"}),o.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."}),o.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2",children:"Beta period · Free access · No credit card needed"})]})]}),o.jsxs("div",{className:"grid grid-cols-1 gap-3 xl:grid-cols-12",children:[o.jsx(Ze,{className:"overflow-hidden rounded-lg border-border bg-card shadow-theme-xs xl:col-span-5",children:o.jsx(oqe,{stats:t})}),o.jsx("div",{className:"xl:col-span-3",children:o.jsx(iqe,{})}),o.jsx("div",{className:"xl:col-span-4 xl:row-span-2",children:o.jsx(rvt,{stats:t,chapters:e})}),o.jsxs(Ze,{className:"rounded-lg border-border bg-card shadow-theme-xs xl:col-span-8",children:[o.jsxs("div",{className:"flex items-start justify-between gap-4 px-4 pt-4",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-base font-semibold",children:"Research Summary"}),o.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:"An overview of your research material and progress."})]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>i("/documents"),children:["View All ",o.jsx(As,{className:"ml-2 h-4 w-4"})]})]}),o.jsx("div",{className:"grid grid-cols-2 gap-2 p-4 lg:grid-cols-4",children:[{label:"Documents",value:(t==null?void 0:t.total_documents)??0,Icon:jr,tone:"bg-primary/10 text-primary"},{label:"Theory Blocks",value:(t==null?void 0:t.total_theories)??0,Icon:nr,tone:"bg-success/10 text-success"},{label:"Methodologies",value:(t==null?void 0:t.total_methods)??0,Icon:xMe,tone:"bg-accent text-accent-foreground"},{label:"Interviews",value:(t==null?void 0:t.total_interviews)??0,Icon:NN,tone:"bg-warning/10 text-warning"}].map(({label:a,value:l,Icon:c,tone:u})=>o.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-lg border border-border/70 bg-muted/30 p-3",children:[o.jsx("div",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full ${u}`,children:o.jsx(c,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-xl font-semibold tabular-nums text-foreground",children:l.toLocaleString()}),o.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a})]})]},a))})]})]}),o.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[o.jsx(eqe,{stats:t,onUpdated:n}),o.jsx(tqe,{stats:t})]}),o.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[o.jsx(aqe,{stats:t}),o.jsx(rqe,{stats:t})]})]})}const svt=[{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"}}],ivt=[{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"}],avt=[{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"}}],ovt=[{value:"qualitative",label:{de:"Qualitativ",en:"Qualitative"}},{value:"quantitative",label:{de:"Quantitativ",en:"Quantitative"}},{value:"mixed",label:{de:"Mixed Methods",en:"Mixed Methods"}}],Qwe=[{value:"de",label:"🇩🇪 Deutsch"},{value:"en",label:"🇬🇧 English"},{value:"fr",label:"🇫🇷 Français"},{value:"es",label:"🇪🇸 Español"},{value:"it",label:"🇮🇹 Italiano"}],lvt=["Business & Economics","Computer Science","Education","Engineering","Health Sciences","Humanities","Law","Natural Sciences","Psychology","Social Sciences","Other"],cvt=["en","de"],uvt=Qwe.filter(t=>cvt.includes(t.value)),Wre=["Research","Academic","Curious","Clever","Studious","Thoughtful","Diligent","Bright"],Vre=["Fox","Owl","Scholar","Falcon","Otter","Panda","Heron","Lynx","Badger","Raven"];function dvt(){const t=Wre[Math.floor(Math.random()*Wre.length)],e=Vre[Math.floor(Math.random()*Vre.length)],r=Math.floor(Math.random()*90)+10;return`${t}${e}${r}`}function qre({label:t,tooltip:e,required:r}){return o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs(Se,{className:"text-foreground font-medium",children:[t,r&&o.jsx("span",{className:"text-destructive ml-0.5",children:"*"})]}),o.jsx(ri,{children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(lf,{className:"w-3.5 h-3.5 text-muted-foreground cursor-help"})}),o.jsx(xr,{side:"top",className:"max-w-[250px] text-xs",children:e})]})})]})}function hvt({open:t,onComplete:e}){const{updateResearchProfile:r,researchProfile:n}=Ht(),[s,i]=S.useState(!1),[a,l]=S.useState(null),[c,u]=S.useState((n==null?void 0:n.nickname)||""),[d,h]=S.useState((n==null?void 0:n.discipline)||""),[f,p]=S.useState((n==null?void 0:n.preferred_language)==="de"?"de":"en"),m=S.useRef(!1),g=S.useRef(!1);S.useEffect(()=>{if(!(!t||m.current)){if(n!=null&&n.nickname){m.current=!0,u(n.nickname);return}m.current=!0,u(x=>x.trim()?x:dvt())}},[t,n==null?void 0:n.nickname]),S.useEffect(()=>{if(!t||g.current)return;if(n!=null&&n.avatar_url){g.current=!0,l(null);return}g.current=!0,(async()=>{try{const{data:v,error:b}=await pe.storage.from("avatars-public").list("",{limit:50});if(b||!(v!=null&&v.length))return;const w=v.filter(C=>/\.(png|jpg|jpeg|webp|svg)$/i.test(C.name));if(!w.length)return;const j=w[Math.floor(Math.random()*w.length)],{data:N}=pe.storage.from("avatars-public").getPublicUrl(j.name);if(!(N!=null&&N.publicUrl))return;l(N.publicUrl)}catch(v){console.error("Automatic avatar resolution failed:",v)}})()},[t,n==null?void 0:n.avatar_url]);const y=async()=>{if(!c.trim()){Ke.error("Please enter a nickname");return}i(!0);try{await r({nickname:c.trim(),discipline:d||null,preferred_language:f,...a?{avatar_url:a}:{}}),Ke.success("Profile saved! Welcome to Academly."),e()}catch(x){console.error("Error saving profile:",x),Ke.error((x==null?void 0:x.message)||"Failed to save profile. Please try again.")}finally{i(!1)}};return o.jsx(jn,{open:t,onOpenChange:()=>{},children:o.jsxs(pn,{className:"sm:max-w-[500px] max-h-[90vh] overflow-y-auto",onPointerDownOutside:x=>x.preventDefault(),onEscapeKeyDown:x=>x.preventDefault(),children:[o.jsxs(mn,{className:"text-center pb-2",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center mx-auto mb-3",children:o.jsx(Sr,{className:"w-6 h-6 text-primary"})}),o.jsx(gn,{className:"text-xl",children:"Welcome to Academly!"}),o.jsx(og,{children:"Just a few details to personalize your experience."})]}),o.jsxs("div",{className:"space-y-5 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{className:"text-foreground font-medium",children:["Nickname ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ue,{value:c,onChange:x=>u(x.target.value),placeholder:"How should we call you?",className:"h-10"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(qre,{label:"Preferred Writing Language",tooltip:"Used as the default language for your academic writing across Academly."}),o.jsxs(pt,{value:f||"en",onValueChange:x=>p(x),children:[o.jsx(ut,{className:"h-10",children:o.jsx(mt,{placeholder:"Select language"})}),o.jsx(dt,{children:uvt.map(x=>o.jsx(Le,{value:x.value,children:x.label},x.value))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(qre,{label:"Discipline",tooltip:"Enables discipline-specific citation styles and terminology suggestions."}),o.jsxs(pt,{value:d,onValueChange:h,children:[o.jsx(ut,{className:"h-10",children:o.jsx(mt,{placeholder:"Select your field"})}),o.jsx(dt,{children:lvt.map(x=>o.jsx(Le,{value:x,children:x},x))})]})]})]}),o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.jsx(me,{onClick:y,disabled:s||!c.trim(),className:"w-full h-11 rounded-full",children:s?"Saving...":"Save & Continue"})})]})})}const fvt=()=>{const{user:t,loading:e,researchProfile:r}=Ht(),n=Or(),[s,i]=S.useState(!1);S.useEffect(()=>{!t&&!e&&n("/login")},[t,e,n]),S.useEffect(()=>{if(t&&!e){const l=!r||!r.nickname;i(l)}else i(!1)},[t,e,r]);const a=()=>{i(!1)};return e?o.jsx(Cr,{showSidebar:!0,children:o.jsx(Lve,{})}):t?o.jsxs(Cr,{showSidebar:!0,children:[o.jsx(nvt,{}),o.jsx(hvt,{open:s,onComplete:a})]}):null},Ri=()=>{const{user:t}=Ht(),[e,r]=S.useState(!1);return o.jsxs("header",{className:"absolute inset-x-0 top-0 z-50",children:[o.jsxs("nav",{className:"mx-auto flex w-full max-w-[1400px] items-center justify-between px-5 py-6 sm:px-6 lg:px-8",children:[o.jsx(Nt,{to:"/",className:"flex items-center",children:o.jsx("img",{src:"https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/src/logo_new.png",alt:"Academly.ai",className:"h-11 w-auto object-contain"})}),o.jsxs("div",{className:"hidden lg:flex lg:items-center lg:gap-10",children:[o.jsx(Nt,{to:"/#features",className:"text-[15px] font-medium text-foreground/75 transition-colors hover:text-foreground",children:"Features"}),o.jsx(Nt,{to:"/pricing",className:"text-[15px] font-medium text-foreground/75 transition-colors hover:text-foreground",children:"Pricing"}),o.jsx(Nt,{to:"/blog",className:"text-[15px] font-medium text-foreground/75 transition-colors hover:text-foreground",children:"Blog"})]}),o.jsx("div",{className:"hidden lg:flex lg:items-center lg:gap-4",children:t?o.jsx(me,{asChild:!0,className:"h-11 rounded-xl px-6 text-[15px] font-semibold shadow-sm",children:o.jsx(Nt,{to:"/dashboard",children:"Dashboard"})}):o.jsxs(o.Fragment,{children:[o.jsx(Nt,{to:"/login",className:"px-2 text-[15px] font-medium text-foreground/75 transition-colors hover:text-foreground",children:"Login"}),o.jsx(me,{asChild:!0,className:"h-11 rounded-xl px-6 text-[15px] font-semibold shadow-sm","data-umami-event":"cta-signup-click","data-umami-event-location":"header-desktop",children:o.jsx(Nt,{to:"/login?mode=signup",children:"Start Writing Free"})})]})}),o.jsx("div",{className:"flex items-center gap-3 lg:hidden",children:o.jsx("button",{onClick:()=>r(!e),className:"flex h-11 w-11 items-center justify-center rounded-xl border border-border/70 bg-background/80 text-foreground/80 shadow-sm backdrop-blur-sm transition hover:bg-muted","aria-label":e?"Close menu":"Open menu","aria-expanded":e,children:e?o.jsx(fn,{className:"h-5 w-5"}):o.jsx(rj,{className:"h-5 w-5"})})})]}),e&&o.jsx("div",{className:"px-5 sm:px-6 lg:hidden",children:o.jsxs("div",{className:"mx-auto max-w-[1400px] overflow-hidden rounded-2xl border border-border/70 bg-background/95 p-5 shadow-lg backdrop-blur-xl",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx(Nt,{to:"/#features",className:"block rounded-xl px-3 py-3 text-sm font-medium text-foreground/80 transition hover:bg-muted/60 hover:text-foreground",onClick:()=>r(!1),children:"Features"}),o.jsx(Nt,{to:"/pricing",className:"block rounded-xl px-3 py-3 text-sm font-medium text-foreground/80 transition hover:bg-muted/60 hover:text-foreground",onClick:()=>r(!1),children:"Pricing"}),o.jsx(Nt,{to:"/blog",className:"block rounded-xl px-3 py-3 text-sm font-medium text-foreground/80 transition hover:bg-muted/60 hover:text-foreground",onClick:()=>r(!1),children:"Blog"})]}),o.jsx("div",{className:"mt-4 border-t border-border/70 pt-4",children:t?o.jsx(me,{asChild:!0,className:"h-11 w-full rounded-xl",children:o.jsx(Nt,{to:"/dashboard",children:"Dashboard"})}):o.jsxs("div",{className:"space-y-3",children:[o.jsx(Nt,{to:"/login",className:"block rounded-xl px-3 py-3 text-sm font-medium text-foreground/80 transition hover:bg-muted/60 hover:text-foreground",onClick:()=>r(!1),children:"Login"}),o.jsx(me,{asChild:!0,className:"h-11 w-full rounded-xl","data-umami-event":"cta-signup-click","data-umami-event-location":"header-mobile",children:o.jsx(Nt,{to:"/login?mode=signup",children:"Start Writing Free"})})]})})]})})]})},Zwe="/assets/logo-icon-FLGou0Tt.png",pvt=["Previous research shows that clinical documentation in outpatient psychotherapy creates a considerable administrative burden and contributes to practitioner strain (Schwarz & Goer, 2026, p. 1). In this context, AI-based documentation systems, known as ambient AI scribes, are increasingly being adopted. Using large language models, these systems transform recorded conversations into written clinical notes and may therefore reduce administrative workload (Schwarz & Goer, 2026, pp. 1–2).","Studies indicate that these technologies can save time and reduce emotional and cognitive load, allowing psychotherapists to be more present during sessions (Schwarz & Goer, 2026, pp. 3–4). Users report that AI-supported documentation helps them focus more closely on patients and lowers administrative pressure, contributing to improved working conditions. A meta-analysis by Bracken et al. (2025) likewise identifies substantial potential for efficiency gains among medical professionals (Schwarz & Goer, 2026, p. 5).","Despite these benefits, important limitations remain. Documentation quality can be affected by errors and AI hallucinations, making careful professional review essential (Schwarz & Goer, 2026, p. 5). Responsibility for the accuracy of clinical records continues to rest with the psychotherapist, while data protection and information security remain central concerns (Schwarz & Goer, 2026, pp. 4–5)."],NT=pvt.join(`

`),mvt=11,gvt=900,xvt=4500,yvt=500,vvt=[{label:"Dashboard",icon:zW},{label:"My Library",icon:nr},{label:"My Citations",icon:ua},{label:"My Thesis",icon:WM,active:!0},{label:"Qualitative",icon:sv}],bvt=[{number:"1",label:"Introduction",state:"current"},{number:"2",label:"Theoretical Foundations",state:"done"},{number:"3",label:"Methodology",state:"done"},{number:"4",label:"Results",state:"open"},{number:"5",label:"Discussion",state:"open"},{number:"6",label:"Conclusion",state:"done"},{number:"7",label:"References",state:"open"}];function wvt({text:t}){const e=S.useMemo(()=>t.split(/(\([^\n()]*?(?:19|20)\d{2}[^\n()]*?\))/g),[t]);return o.jsx(o.Fragment,{children:e.map((r,n)=>/^\([^\n()]*?(?:19|20)\d{2}[^\n()]*?\)$/.test(r)?o.jsx("span",{className:"font-medium text-primary",children:r},`${r}-${n}`):o.jsx("span",{children:r},`${r}-${n}`))})}function jvt(){const[t,e]=S.useState(""),[r,n]=S.useState(!1);S.useEffect(()=>{const i=[];let a=!1;const l=(d,h)=>{const f=setTimeout(()=>{a||d()},h);i.push(f)},c=window.matchMedia("(prefers-reduced-motion: reduce)").matches,u=()=>{a||(n(!1),e(c?NT:""),!c&&l(()=>{let d=0;const h=()=>{if(d+=1,e(NT.slice(0,d)),d<NT.length){l(h,mvt);return}l(()=>{n(!0),l(u,yvt)},xvt)};h()},gvt))};return u(),()=>{a=!0,i.forEach(clearTimeout)}},[]);const s=t.length>0&&t.length<NT.length;return o.jsx("div",{className:"relative left-1/2 my-10 w-[calc(100vw-2rem)] max-w-[1180px] -translate-x-1/2 md:my-12",children:o.jsx("div",{className:"overflow-hidden rounded-2xl border border-border bg-card text-left shadow-xl",children:o.jsxs("div",{className:"grid h-[470px] grid-cols-[48px_minmax(0,1fr)] md:h-[560px] md:grid-cols-[150px_minmax(0,1fr)] lg:grid-cols-[170px_minmax(0,1fr)]",children:[o.jsxs("aside",{className:"border-r border-border bg-muted/20",children:[o.jsxs("div",{className:"flex h-14 items-center justify-center gap-2 border-b border-border px-2 md:justify-start md:px-4",children:[o.jsx("img",{src:Zwe,alt:"",className:"h-7 w-7 object-contain"}),o.jsx("span",{className:"hidden text-xs font-bold text-foreground md:inline",children:"Academly"})]}),o.jsxs("div",{className:"p-2 md:p-3",children:[o.jsxs("div",{className:"mb-3 flex h-8 items-center justify-center gap-1.5 rounded-md bg-primary text-primary-foreground",children:[o.jsx(Bs,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden text-[10px] font-semibold md:inline",children:"New Thesis"})]}),o.jsx("div",{className:"space-y-1",children:vvt.map(i=>{const a=i.icon;return o.jsxs("div",{className:`flex h-9 items-center justify-center gap-2 rounded-md px-2 text-[10px] md:justify-start ${i.active?"bg-primary/10 text-primary":"text-muted-foreground"}`,children:[o.jsx(a,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"hidden truncate md:inline",children:i.label})]},i.label)})})]})]}),o.jsxs("div",{className:"flex min-w-0 flex-col bg-background",children:[o.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-border px-3 md:px-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md border border-border text-muted-foreground",children:o.jsx(rj,{className:"h-3.5 w-3.5"})}),o.jsx("span",{className:"text-xs font-semibold text-foreground",children:"My Thesis"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"hidden h-7 w-7 items-center justify-center rounded-full border border-border text-muted-foreground sm:flex",children:o.jsx(jr,{className:"h-3.5 w-3.5"})}),o.jsx("div",{className:"hidden h-7 w-7 items-center justify-center rounded-full border border-border text-muted-foreground sm:flex",children:o.jsx(UW,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{className:"flex h-7 items-center gap-1 rounded-full border border-primary/20 bg-primary/5 px-2 text-[9px] font-semibold text-primary",children:[o.jsx(Sr,{className:"h-3 w-3"})," 4,000 SP"]})]})]}),o.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-border px-3 text-muted-foreground md:px-5",children:[o.jsxs("div",{className:"flex items-center gap-2 text-[9px]",children:[o.jsx("span",{children:"↶"}),o.jsx("span",{children:"↷"}),o.jsx("span",{className:"font-semibold text-foreground",children:"H₁"}),o.jsx("span",{children:"H₂"}),o.jsx("span",{className:"font-semibold text-foreground",children:"B"}),o.jsx("span",{className:"italic",children:"I"}),o.jsx("span",{className:"underline",children:"U"}),o.jsx("span",{children:"☷"}),o.jsx(ua,{className:"h-3 w-3"})]}),o.jsxs("div",{className:"hidden max-w-44 items-center gap-1 rounded-md border border-border px-2 py-1 text-[8px] lg:flex",children:["AI-supported interventions ",o.jsx(ia,{className:"h-2.5 w-2.5"})]})]}),o.jsxs("div",{className:"grid min-h-0 flex-1 lg:grid-cols-[minmax(0,1fr)_205px]",children:[o.jsx("main",{className:"min-w-0 overflow-hidden px-4 py-5 md:px-8 lg:px-10",children:o.jsxs("div",{className:`mx-auto max-w-2xl transition-opacity duration-500 ${r?"opacity-0":"opacity-100"}`,children:[o.jsx("h2",{className:"mb-2 text-base font-bold text-foreground md:text-xl",children:"2.0 Theoretical Foundations of AI in Psychotherapy"}),o.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 text-[9px]",children:[o.jsx("span",{className:"rounded-md bg-primary/10 px-2 py-1 font-medium text-primary",children:"Draft available"}),o.jsx("span",{className:"text-muted-foreground",children:"Generated moments ago"})]}),o.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[o.jsx("h3",{className:"text-xs font-semibold text-foreground md:text-sm",children:"2.1 Previous Research on AI Documentation"}),o.jsx("span",{className:"hidden rounded-full bg-warning/10 px-2 py-1 text-[8px] font-medium text-warning-foreground sm:inline",children:"Evidence (13)"})]}),o.jsxs("div",{className:"whitespace-pre-line text-[10px] leading-[1.65] text-foreground md:text-[11px] lg:text-xs",children:[o.jsx(wvt,{text:t}),s&&o.jsx("span",{className:"ml-0.5 inline-block h-3 w-[2px] animate-pulse bg-primary align-middle"})]})]})}),o.jsx("aside",{className:"hidden border-l border-border bg-card p-3 lg:block",children:o.jsxs("div",{className:"rounded-lg border border-border p-3 shadow-sm",children:[o.jsx("p",{className:"mb-2 text-[8px] font-semibold uppercase tracking-widest text-muted-foreground",children:"Thesis Navigator"}),o.jsx("p",{className:"mb-3 text-[9px] font-semibold leading-snug text-foreground",children:"AI-Supported Interventions in Psychotherapy"}),o.jsxs("div",{className:"mb-1 flex justify-between text-[8px] text-muted-foreground",children:[o.jsx("span",{children:"Progress"}),o.jsx("span",{className:"font-semibold text-foreground",children:"100%"})]}),o.jsx("div",{className:"mb-3 h-1 rounded-full bg-muted",children:o.jsx("div",{className:"h-full w-full rounded-full bg-primary"})}),o.jsxs("div",{className:"mb-3 grid grid-cols-3 gap-1 border-b border-border pb-3 text-[8px]",children:[o.jsxs("div",{children:[o.jsx("span",{className:"block text-muted-foreground",children:"Words"}),o.jsx("b",{className:"text-foreground",children:"19,418"})]}),o.jsxs("div",{children:[o.jsx("span",{className:"block text-muted-foreground",children:"Sources"}),o.jsx("b",{className:"text-foreground",children:"67"})]}),o.jsxs("div",{children:[o.jsx("span",{className:"block text-muted-foreground",children:"Chapters"}),o.jsx("b",{className:"text-foreground",children:"3 / 6"})]})]}),o.jsx("div",{className:"space-y-1",children:bvt.map(i=>o.jsxs("div",{className:`flex h-6 items-center gap-2 rounded px-1.5 text-[8px] ${i.state==="current"?"bg-primary/10 text-primary":"text-muted-foreground"}`,children:[o.jsx("span",{children:i.number}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:i.label}),i.state==="done"?o.jsx(kr,{className:"h-2.5 w-2.5 text-success"}):o.jsx(n1,{className:"h-2.5 w-2.5"})]},i.number))})]})})]})]})]})})})}const Svt=["Citations only from uploaded PDFs","Verified page references","No hallucinated references","GDPR compliant","EU hosted"],_vt=()=>o.jsxs("section",{className:"relative overflow-hidden",id:"home",children:[o.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-24 mx-auto grid h-max w-full grid-cols-2 -space-x-52 opacity-40",children:[o.jsx("div",{className:"h-56 blur-[106px] bg-gradient-to-br from-primary to-purple-400"}),o.jsx("div",{className:"h-32 blur-[106px] bg-gradient-to-r from-cyan-400 to-sky-300"})]}),o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute left-1/2 top-24 h-[360px] w-[720px] -translate-x-1/2 rounded-full bg-primary/[0.06] blur-[110px]"}),o.jsxs("div",{className:"relative mx-auto w-full max-w-[1400px] px-5 pb-12 pt-36 sm:px-6 md:pt-40 lg:px-8 lg:pb-16 lg:pt-44",children:[o.jsxs("div",{className:"mx-auto max-w-5xl text-center",children:[o.jsxs("h1",{className:"text-balance text-[3.4rem] font-bold leading-[0.98] tracking-[-0.045em] text-foreground sm:text-[4rem] md:text-[4.8rem] lg:text-[5.4rem]",children:["Write your thesis with ",o.jsx("span",{className:"text-primary",children:"real citations"})," from your own sources."]}),o.jsx("p",{className:"mx-auto mt-7 max-w-3xl text-base leading-7 text-muted-foreground sm:text-lg md:text-xl md:leading-8",children:"Upload academic PDFs, generate structured thesis chapters, and keep every citation connected to real research with verified page references."}),o.jsxs("div",{className:"mt-9 flex flex-col items-center justify-center gap-3 sm:flex-row",children:[o.jsx(Nt,{to:"/login?mode=signup",className:"inline-flex h-12 w-full items-center justify-center rounded-xl bg-primary px-8 text-base font-semibold text-primary-foreground shadow-sm transition hover:opacity-90 active:translate-y-px sm:w-auto","data-umami-event":"cta-signup-click","data-umami-event-location":"hero",children:"Start Writing Free"}),o.jsx("a",{href:"#how-it-works",className:"inline-flex h-12 w-full items-center justify-center rounded-xl border border-border/80 bg-background/80 px-8 text-base font-semibold text-foreground shadow-sm backdrop-blur-sm transition hover:bg-muted/50 active:translate-y-px sm:w-auto",children:"See How It Works"})]}),o.jsx("ul",{className:"mx-auto mt-7 flex max-w-4xl flex-wrap items-center justify-center gap-x-5 gap-y-2.5 text-sm text-muted-foreground",children:Svt.map(t=>o.jsxs("li",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary/10",children:o.jsx(kr,{className:"h-3.5 w-3.5 text-primary"})}),o.jsx("span",{children:t})]},t))})]}),o.jsxs("div",{className:"relative mt-16 md:mt-20 lg:mt-24",children:[o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-20 top-10 -z-10 h-64 rounded-full bg-primary/[0.11] blur-[105px]"}),o.jsx(jvt,{})]})]})]}),UR=["Previous research shows that clinical documentation in outpatient psychotherapy creates a considerable administrative burden and contributes to practitioner strain (Goer & Schwarz, 2026, p. 1). In this context, AI-based documentation systems, known as ambient AI scribes, are increasingly being adopted. Using large language models, these systems transform recorded conversations into written clinical notes and may therefore reduce administrative workload (Goer & Schwarz, 2026, pp. 1–2).","Studies indicate that these technologies can save time and reduce emotional and cognitive load, allowing psychotherapists to be more present during sessions (Goer & Schwarz, 2026, pp. 3–4). Users report that AI-supported documentation helps them focus more closely on patients and lowers administrative pressure, contributing to improved working conditions (Goer & Schwarz, 2026, p. 5).","Despite these benefits, documentation quality can be affected by errors and AI hallucinations, making careful professional review essential. Future studies should evaluate effects on burnout, the therapeutic relationship, quality of care, and the patient perspective (Goer & Schwarz, 2026, p. 6)."],Gre=UR.join(`

`),w3=UR.slice(0,-1).join(`

`)+`

`,Kre=UR[UR.length-1],Nvt=7,kvt=800,uS=850,j3=1250,Yre=1700,Cvt=4200,Evt=500,Jwe="Future studies should specifically evaluate quantitative effects on burnout, the therapeutic relationship, and quality of care, and include the patient perspective in order to comprehensively assess acceptance factors and outcomes. This study provides the first insights into experiences and needs concerning AI documentation software from the perspective of psychotherapists in Germany.",Xre=[{page:"p. 1",citation:"(Goer & Schwarz, 2026, p. 1)",quote:"Clinical documentation causes considerable administrative burden in outpatient psychotherapy."},{page:"p. 5",citation:"(Goer & Schwarz, 2026, p. 5)",quote:"Participants reported high satisfaction, significant time savings, and reduced cognitive burden."},{page:"p. 5",citation:"(Goer & Schwarz, 2026, p. 5)",quote:"Errors and hallucinations require careful professional review of the generated notes."},{page:"p. 4",citation:"(Goer & Schwarz, 2026, p. 4)",quote:"Data security remains a central concern when implementing AI documentation."},{page:"p. 6",citation:"(Goer & Schwarz, 2026, p. 6)",quote:Jwe}],Avt=[{label:"Dashboard",icon:zW},{label:"My Library",icon:nr},{label:"My Citations",icon:ua},{label:"My Thesis",icon:WM,active:!0},{label:"Qualitative",icon:sv}],Tvt=[{number:"1",label:"Introduction",state:"current"},{number:"2",label:"Theoretical Foundations",state:"done"},{number:"3",label:"Methodology",state:"done"},{number:"4",label:"Results",state:"open"},{number:"5",label:"Discussion",state:"open"},{number:"6",label:"Conclusion",state:"done"},{number:"7",label:"References",state:"open"}];function Pvt({text:t}){const e=S.useMemo(()=>t.split(/(\([^\n()]*?(?:19|20)\d{2}[^\n()]*?\))/g),[t]);return o.jsx(o.Fragment,{children:e.map((r,n)=>/^\([^\n()]*?(?:19|20)\d{2}[^\n()]*?\)$/.test(r)?o.jsx("span",{className:"font-medium text-primary",children:r},`${r}-${n}`):o.jsx("span",{children:r},`${r}-${n}`))})}function Ivt(){return o.jsxs("div",{className:"overflow-hidden rounded-md border border-border bg-card shadow-sm",children:[o.jsxs("div",{className:"flex h-7 items-center justify-between border-b border-border bg-muted/30 px-3 text-[7px] font-medium text-muted-foreground",children:[o.jsx("span",{children:"AI DOCUMENTATION IN PSYCHOTHERAPY"}),o.jsx("span",{children:"6 / 8"})]}),o.jsxs("div",{className:"grid min-h-[250px] grid-cols-[0.82fr_1.18fr] gap-4 p-4 text-[6px] leading-[1.5] text-foreground md:text-[7px]",children:[o.jsxs("div",{children:[o.jsx("p",{className:"mb-2 text-[9px] font-bold text-primary",children:"Limitations and strengths of the study"}),o.jsx("p",{children:"The small sample size and the early stage of this technology limit the generalisability of the findings. Further evaluation is needed to understand how ambient AI scribes affect clinical routines and treatment."}),o.jsx("p",{className:"mt-3",children:"The present study nevertheless offers an early view of psychotherapists’ experiences and identifies practical requirements for responsible implementation."})]}),o.jsxs("div",{children:[o.jsx("div",{className:"mb-2 border-b border-primary/40 pb-1",children:o.jsx("span",{className:"bg-primary px-1.5 py-0.5 text-[6px] font-bold text-primary-foreground",children:"Abstract"})}),o.jsx("h4",{className:"mb-1 text-[9px] font-bold text-primary",children:"Ambient artificial intelligence scribes in psychotherapy documentation"}),o.jsx("p",{children:"AI-assisted documentation is perceived as a useful support with potential to reduce administrative burden. Safe implementation requires mandatory professional review, error classifications, and clear data protection regulations."}),o.jsx("p",{className:"mt-3 rounded-sm bg-warning/25 px-1 py-0.5 ring-1 ring-warning/50",children:"Future studies should evaluate effects on burnout, the therapeutic relationship, and quality of care, and include the patient perspective to assess acceptance factors and outcomes comprehensively."}),o.jsx("p",{className:"mt-2 rounded-sm bg-warning/25 px-1 py-0.5 ring-1 ring-warning/50",children:"This study provides first insights into the use of AI documentation software from the perspective of psychotherapists in Germany and addresses an important gap in current research."}),o.jsx("p",{className:"mt-3 font-semibold text-primary",children:"Keywords"}),o.jsx("p",{children:"Generative AI · Psychotherapy · Ambient AI scribes · Data protection · Workload"})]})]})]})}function Rvt({phase:t,scrollRef:e}){const r=t==="selected"||t==="pdf";return o.jsxs("section",{className:"absolute inset-y-0 right-0 z-30 flex w-full flex-col border-l border-border bg-background shadow-xl transition-transform duration-500 ease-out sm:w-[72%] lg:w-[58%]",children:[o.jsxs("div",{className:"flex h-14 shrink-0 items-start justify-between border-b border-border px-4 py-2.5",children:[o.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[o.jsx("span",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:o.jsx(jr,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h3",{className:"text-[11px] font-semibold text-foreground",children:"Citation evidence"}),o.jsx("p",{className:"truncate text-[8px] text-muted-foreground",children:"Verify source passages and open the cited PDFs."})]})]}),o.jsx(fn,{className:"mt-1 h-3.5 w-3.5 text-muted-foreground"})]}),o.jsxs("div",{className:"flex h-9 shrink-0 items-end gap-4 border-b border-border px-4 text-[8px] font-medium",children:[o.jsx("span",{className:"border-b-2 border-primary pb-2 text-foreground",children:"Quotes (13)"}),o.jsx("span",{className:"pb-2 text-muted-foreground",children:"PDFs (1)"})]}),o.jsxs("div",{ref:e,className:"min-h-0 flex-1 overflow-y-auto scroll-smooth px-4 py-3",children:[o.jsxs("div",{className:"mb-2 flex items-end justify-between gap-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-[7px] font-semibold uppercase text-muted-foreground",children:"Evidence"}),o.jsx("p",{className:"text-[8px] text-muted-foreground",children:"13 stored passages"})]}),o.jsx("span",{className:"rounded-full border border-success/30 bg-success/10 px-2 py-0.5 text-[7px] font-semibold text-success",children:"13 verified"})]}),o.jsx("div",{className:"space-y-1.5",children:Xre.map((n,s)=>{const i=s===Xre.length-1;return o.jsxs("div",{"data-evidence-final":i?"true":void 0,className:`rounded-md border p-2 transition-all duration-300 ${i&&r?"border-primary/50 bg-primary/5 ring-1 ring-primary/20":"border-border bg-card"}`,children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("p",{className:"min-w-0 truncate text-[8px] font-semibold text-foreground",children:"AI Documentation in Psychotherapy"}),o.jsx("span",{className:"shrink-0 rounded bg-muted px-1 py-0.5 text-[7px] text-muted-foreground",children:n.page})]}),o.jsx("p",{className:"mt-0.5 text-[7px] font-medium text-primary",children:n.citation}),o.jsxs("p",{className:"mt-1 line-clamp-2 text-[7px] leading-relaxed text-muted-foreground",children:["“",n.quote,"”"]})]},`${n.page}-${s}`)})}),r&&o.jsxs("div",{"data-source-detail":"true",className:"animate-fade-in pt-4",children:[o.jsx("p",{className:"mb-2 text-[7px] font-semibold uppercase text-muted-foreground",children:"Selected evidence"}),o.jsxs("div",{className:"mb-2 rounded-md border border-border bg-card p-3",children:[o.jsx("p",{className:"text-[7px] uppercase text-muted-foreground",children:"Source"}),o.jsx("p",{className:"mt-0.5 text-[9px] font-semibold text-foreground",children:"AI Documentation in Psychotherapy"}),o.jsxs("div",{className:"mt-1 flex items-center justify-between text-[7px] text-muted-foreground",children:[o.jsx("span",{children:"(Goer & Schwarz, 2026, p. 6)"}),o.jsxs("span",{className:"flex items-center gap-1 text-primary",children:["Open full PDF ",o.jsx(of,{className:"h-2.5 w-2.5"})]})]})]}),o.jsxs("div",{className:"mb-3 rounded-md border border-warning/40 bg-warning/10 p-3",children:[o.jsx("p",{className:"mb-1 text-[7px] font-semibold uppercase text-warning-foreground",children:"Original quote"}),o.jsxs("blockquote",{className:"text-[8px] leading-relaxed text-foreground",children:["“",Jwe,"”"]})]}),o.jsx("p",{className:"mb-2 text-[7px] font-semibold uppercase text-muted-foreground",children:"Cited page"}),o.jsx(Ivt,{}),o.jsx("div",{className:"h-3"})]})]})]})}function Ovt(){const[t,e]=S.useState(w3),[r,n]=S.useState("writing"),[s,i]=S.useState(!1),a=S.useRef(null),l=S.useRef(!1);S.useEffect(()=>{const d=[];let h=!1;const f=(g,y)=>{const x=setTimeout(()=>{h||g()},y);d.push(x)},p=window.matchMedia("(prefers-reduced-motion: reduce)").matches;l.current=p;const m=()=>{h||(i(!1),n(p?"pdf":"writing"),e(p?Gre:w3),!p&&f(()=>{let g=0;const y=()=>{if(g+=1,e(w3+Kre.slice(0,g)),g<Kre.length){f(y,Nvt);return}f(()=>n("targeting"),uS),f(()=>n("panel"),uS+650),f(()=>n("selected"),uS+650+j3),f(()=>n("pdf"),uS+650+j3+Yre),f(()=>{i(!0),f(m,Evt)},uS+650+j3+Yre+Cvt)};y()},kvt))};return m(),()=>{h=!0,d.forEach(clearTimeout)}},[]),S.useEffect(()=>{if(r!=="selected"&&r!=="pdf"||l.current)return;const d=a.current;if(!d)return;const h=d.querySelector(r==="selected"?"[data-evidence-final='true']":"[data-source-detail='true']");if(!h)return;const f=d.getBoundingClientRect(),p=h.getBoundingClientRect(),m=45,g=r==="selected"?(d.clientHeight-h.clientHeight)/2:0,y=d.scrollTop+p.top-f.top-g-m;d.scrollTo({top:Math.max(0,y),behavior:"smooth"})},[r]);const c=t.length>0&&t.length<Gre.length,u=r==="panel"||r==="selected"||r==="pdf";return o.jsx("div",{className:"relative left-1/2 my-10 w-[calc(100vw-2rem)] max-w-[1180px] -translate-x-1/2 md:my-12",children:o.jsx("div",{className:`overflow-hidden rounded-2xl border border-border bg-card text-left shadow-xl transition-opacity duration-500 ${s?"opacity-0":"opacity-100"}`,children:o.jsxs("div",{className:"grid h-[520px] grid-cols-[48px_minmax(0,1fr)] md:h-[590px] md:grid-cols-[150px_minmax(0,1fr)] lg:grid-cols-[170px_minmax(0,1fr)]",children:[o.jsxs("aside",{className:"border-r border-border bg-muted/20",children:[o.jsxs("div",{className:"flex h-14 items-center justify-center gap-2 border-b border-border px-2 md:justify-start md:px-4",children:[o.jsx("img",{src:Zwe,alt:"",className:"h-7 w-7 object-contain"}),o.jsx("span",{className:"hidden text-xs font-bold text-foreground md:inline",children:"Academly"})]}),o.jsxs("div",{className:"p-2 md:p-3",children:[o.jsxs("div",{className:"mb-3 flex h-8 items-center justify-center gap-1.5 rounded-md bg-primary text-primary-foreground",children:[o.jsx(Bs,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden text-[10px] font-semibold md:inline",children:"New Thesis"})]}),o.jsx("div",{className:"space-y-1",children:Avt.map(d=>{const h=d.icon;return o.jsxs("div",{className:`flex h-9 items-center justify-center gap-2 rounded-md px-2 text-[10px] md:justify-start ${d.active?"bg-primary/10 text-primary":"text-muted-foreground"}`,children:[o.jsx(h,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"hidden truncate md:inline",children:d.label})]},d.label)})})]})]}),o.jsxs("div",{className:"flex min-w-0 flex-col bg-background",children:[o.jsxs("div",{className:"flex h-14 shrink-0 items-center justify-between border-b border-border px-3 md:px-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-md border border-border text-muted-foreground",children:o.jsx(rj,{className:"h-3.5 w-3.5"})}),o.jsx("span",{className:"text-xs font-semibold text-foreground",children:"My Thesis"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"hidden h-7 w-7 items-center justify-center rounded-full border border-border text-muted-foreground sm:flex",children:o.jsx(jr,{className:"h-3.5 w-3.5"})}),o.jsx("div",{className:"hidden h-7 w-7 items-center justify-center rounded-full border border-border text-muted-foreground sm:flex",children:o.jsx(UW,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{className:"flex h-7 items-center gap-1 rounded-full border border-primary/20 bg-primary/5 px-2 text-[9px] font-semibold text-primary",children:[o.jsx(Sr,{className:"h-3 w-3"})," 4,000 SP"]})]})]}),o.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-border px-3 text-muted-foreground md:px-5",children:[o.jsxs("div",{className:"flex items-center gap-2 text-[9px]",children:[o.jsx("span",{children:"↶"}),o.jsx("span",{children:"↷"}),o.jsx("span",{className:"font-semibold text-foreground",children:"H₁"}),o.jsx("span",{children:"H₂"}),o.jsx("span",{className:"font-semibold text-foreground",children:"B"}),o.jsx("span",{className:"italic",children:"I"}),o.jsx("span",{className:"underline",children:"U"}),o.jsx("span",{children:"☷"}),o.jsx(ua,{className:"h-3 w-3"})]}),o.jsxs("div",{className:"hidden max-w-44 items-center gap-1 rounded-md border border-border px-2 py-1 text-[8px] lg:flex",children:["AI-supported interventions ",o.jsx(ia,{className:"h-2.5 w-2.5"})]})]}),o.jsxs("div",{className:"relative grid min-h-0 flex-1 overflow-hidden lg:grid-cols-[minmax(0,1fr)_205px]",children:[o.jsx("main",{className:`min-w-0 overflow-hidden px-4 py-5 transition-[filter,opacity] duration-500 md:px-8 lg:px-10 ${u?"opacity-45 blur-[1px]":""}`,children:o.jsxs("div",{className:"mx-auto max-w-2xl",children:[o.jsx("h2",{className:"mb-2 text-base font-bold text-foreground md:text-xl",children:"2.0 Theoretical Foundations of AI in Psychotherapy"}),o.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-2 text-[9px]",children:[o.jsx("span",{className:"rounded-md bg-primary/10 px-2 py-1 font-medium text-primary",children:"Draft available"}),o.jsx("span",{className:"text-muted-foreground",children:"Generated moments ago"})]}),o.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[o.jsx("h3",{className:"text-xs font-semibold text-foreground md:text-sm",children:"2.1 Previous Research on AI Documentation"}),o.jsxs("div",{className:`relative shrink-0 rounded-full border px-2 py-1 text-[8px] font-medium transition-all duration-300 ${r==="targeting"?"scale-105 border-warning bg-warning/20 text-warning-foreground ring-4 ring-warning/10":"border-warning/30 bg-warning/10 text-warning-foreground"}`,children:[o.jsxs("span",{className:"inline-flex items-center gap-1",children:[o.jsx(ua,{className:"h-2.5 w-2.5"})," Evidence (13)"]}),r==="targeting"&&o.jsx(yMe,{className:"absolute -bottom-4 -right-3 h-5 w-5 animate-scale-in fill-primary text-primary drop-shadow-sm"})]})]}),o.jsxs("div",{className:"whitespace-pre-line text-[10px] leading-[1.65] text-foreground md:text-[11px] lg:text-xs",children:[o.jsx(Pvt,{text:t}),c&&o.jsx("span",{className:"ml-0.5 inline-block h-3 w-[2px] animate-pulse bg-primary align-middle"})]})]})}),o.jsx("aside",{className:`hidden border-l border-border bg-card p-3 transition-opacity duration-300 lg:block ${u?"opacity-30":""}`,children:o.jsxs("div",{className:"rounded-lg border border-border p-3 shadow-sm",children:[o.jsx("p",{className:"mb-2 text-[8px] font-semibold uppercase tracking-widest text-muted-foreground",children:"Thesis Navigator"}),o.jsx("p",{className:"mb-3 text-[9px] font-semibold leading-snug text-foreground",children:"AI-Supported Interventions in Psychotherapy"}),o.jsxs("div",{className:"mb-1 flex justify-between text-[8px] text-muted-foreground",children:[o.jsx("span",{children:"Progress"}),o.jsx("span",{className:"font-semibold text-foreground",children:"100%"})]}),o.jsx("div",{className:"mb-3 h-1 rounded-full bg-muted",children:o.jsx("div",{className:"h-full w-full rounded-full bg-primary"})}),o.jsxs("div",{className:"mb-3 grid grid-cols-3 gap-1 border-b border-border pb-3 text-[8px]",children:[o.jsxs("div",{children:[o.jsx("span",{className:"block text-muted-foreground",children:"Words"}),o.jsx("b",{className:"text-foreground",children:"19,418"})]}),o.jsxs("div",{children:[o.jsx("span",{className:"block text-muted-foreground",children:"Sources"}),o.jsx("b",{className:"text-foreground",children:"67"})]}),o.jsxs("div",{children:[o.jsx("span",{className:"block text-muted-foreground",children:"Chapters"}),o.jsx("b",{className:"text-foreground",children:"3 / 6"})]})]}),o.jsx("div",{className:"space-y-1",children:Tvt.map(d=>o.jsxs("div",{className:`flex h-6 items-center gap-2 rounded px-1.5 text-[8px] ${d.state==="current"?"bg-primary/10 text-primary":"text-muted-foreground"}`,children:[o.jsx("span",{children:d.number}),o.jsx("span",{className:"min-w-0 flex-1 truncate",children:d.label}),d.state==="done"?o.jsx(kr,{className:"h-2.5 w-2.5 text-success"}):o.jsx(n1,{className:"h-2.5 w-2.5"})]},d.number))})]})}),o.jsx("div",{className:`absolute inset-0 z-20 bg-foreground/5 transition-opacity duration-300 ${u?"opacity-100":"pointer-events-none opacity-0"}`}),o.jsx("div",{className:`absolute inset-0 z-30 transition-transform duration-500 ease-out ${u?"translate-x-0":"translate-x-full"}`,children:o.jsx(Rvt,{phase:r,scrollRef:a})})]})]})]})})})}const Qre="AI in Education",Mvt=65,Dvt=900,Lvt=450,$vt=250,Fvt=6500,Bvt=600,zvt=[{title:"AI-Driven Personalized Learning in Higher Education",question:"How can AI-supported learning paths adapt to individual student needs in higher education?",method:"Comparative case study across university courses using learner outcomes and student feedback.",relevance:"Personalized learning may help universities support different learning speeds, prior knowledge and study needs.",sources:["AI in Education research","Personalized learning studies"]},{title:"Student Acceptance of AI-Based Learning Assistants",question:"Which factors influence students' willingness to use AI-based learning assistants in university courses?",method:"Quantitative survey with follow-up interviews based on an adapted technology acceptance framework.",relevance:"Understanding adoption barriers can help universities introduce AI tools more responsibly and effectively.",sources:["Technology acceptance literature","Higher education AI adoption studies"]}],Uvt=()=>{const[t,e]=S.useState(""),[r,n]=S.useState(!1),[s,i]=S.useState(0),[a,l]=S.useState(!1);return S.useEffect(()=>{const c=[],u=[];let d=!1;const h=()=>{d||(e(""),n(!1),i(0),l(!1),c.push(setTimeout(()=>{let f=0;const p=setInterval(()=>{f+=1,e(Qre.slice(0,f)),f>=Qre.length&&(clearInterval(p),c.push(setTimeout(()=>{n(!0),c.push(setTimeout(()=>n(!1),Lvt)),c.push(setTimeout(()=>{i(1),c.push(setTimeout(()=>i(2),$vt)),c.push(setTimeout(()=>{l(!0),c.push(setTimeout(h,Bvt))},Fvt))},450))},180)))},Mvt);u.push(p)},Dvt)))};return h(),()=>{d=!0,c.forEach(clearTimeout),u.forEach(clearInterval)}},[]),o.jsx("section",{className:"py-6",children:o.jsx("div",{className:`transition-opacity duration-500 ${a?"opacity-0":"opacity-100"}`,children:o.jsxs("div",{className:"grid gap-6 lg:grid-cols-[0.82fr_1.18fr]",children:[o.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card p-5 shadow-sm md:p-6",children:[o.jsxs("div",{className:"mb-6 flex items-start gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(dd,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Topic Generator"}),o.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Turn a broad idea into structured thesis directions."})]})]}),o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{children:[o.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"Topic idea"}),o.jsxs("div",{className:"flex min-h-[46px] items-center rounded-xl border border-border/80 bg-background px-4 text-sm text-foreground shadow-sm",children:[t,o.jsx("span",{className:"ml-0.5 inline-block h-4 w-[2px] animate-pulse bg-primary"})]})]}),o.jsxs("div",{className:"grid gap-4 sm:grid-cols-[1fr_auto]",children:[o.jsxs("div",{children:[o.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"Context"}),o.jsx("div",{className:"min-h-[88px] rounded-xl border border-border/80 bg-background px-4 py-3 text-sm leading-6 text-muted-foreground shadow-sm",children:"Higher education, personalized learning, student experience and academic performance."})]}),o.jsxs("div",{className:"sm:w-[116px]",children:[o.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"Language"}),o.jsxs("div",{className:"flex rounded-xl border border-border/80 bg-background p-1 shadow-sm",children:[o.jsx("span",{className:"flex-1 rounded-lg px-3 py-2 text-center text-xs text-muted-foreground",children:"DE"}),o.jsx("span",{className:"flex-1 rounded-lg bg-primary px-3 py-2 text-center text-xs font-semibold text-primary-foreground",children:"EN"})]})]})]}),o.jsx("div",{className:`flex h-11 w-full items-center justify-center rounded-xl bg-primary text-sm font-semibold text-primary-foreground shadow-sm transition-transform duration-300 ${r?"scale-[1.015] shadow-md shadow-primary/20":"scale-100"}`,children:"Generate Suggestions"}),o.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Academly structures ideas into research questions, suitable methods and academic relevance."})]})]}),o.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-background p-4 shadow-sm md:p-5",children:[o.jsxs("div",{className:"mb-4 flex items-center justify-between px-1",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Suggested thesis directions"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Two structured starting points based on your idea."})]}),o.jsx("div",{className:"hidden h-9 w-9 items-center justify-center rounded-xl bg-primary/10 text-primary sm:flex",children:o.jsx(Sr,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"space-y-4",children:zvt.map((c,u)=>o.jsx("article",{className:`rounded-2xl border border-border/70 bg-card p-5 transition-all duration-500 ${s>u?"translate-y-0 opacity-100":"translate-y-2 opacity-0"}`,children:o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsxs("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-xs font-bold text-primary",children:["0",u+1]}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h4",{className:"text-base font-semibold leading-6 tracking-tight text-foreground md:text-lg",children:c.title}),o.jsxs("div",{className:"mt-4 grid gap-4 xl:grid-cols-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-xs font-semibold text-primary",children:[o.jsx(TE,{className:"h-3.5 w-3.5"}),"Research question"]}),o.jsx("p",{className:"text-sm leading-6 text-foreground/85",children:c.question})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-xs font-semibold text-primary",children:[o.jsx(SN,{className:"h-3.5 w-3.5"}),"Method"]}),o.jsx("p",{className:"text-sm leading-6 text-foreground/85",children:c.method})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-xs font-semibold text-primary",children:[o.jsx(Sr,{className:"h-3.5 w-3.5"}),"Why it matters"]}),o.jsx("p",{className:"text-sm leading-6 text-foreground/85",children:c.relevance})]})]}),o.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 border-t border-border/60 pt-4",children:[o.jsxs("div",{className:"mr-1 flex items-center gap-1.5 text-xs font-medium text-muted-foreground",children:[o.jsx(nr,{className:"h-3.5 w-3.5 text-primary"}),"Suggested starting points"]}),c.sources.map(d=>o.jsx("span",{className:"rounded-full border border-border/70 bg-muted/20 px-2.5 py-1 text-[11px] text-muted-foreground",children:d},d))]})]})]})},c.title))})]})]})})})},Hvt=[{icon:nr,title:"Real Sources Only",text:"Academly works with the academic sources you upload, so your research stays grounded in your own material.",visual:"sources"},{icon:ua,title:"Traceable Evidence",text:"See the original passage behind a citation, including the exact source and page used as evidence.",visual:"evidence"},{icon:CMe,title:"GDPR & EU Hosted",text:"Built with privacy-conscious students and universities in mind, with GDPR-aligned workflows and EU hosting.",visual:"privacy"}],Wvt=({type:t})=>t==="sources"?o.jsxs("div",{className:"relative h-44 overflow-hidden rounded-2xl bg-gradient-to-br from-primary/[0.10] via-background to-primary/[0.035] p-5",children:[o.jsx("div",{className:"absolute -right-8 -top-8 h-28 w-28 rounded-full bg-primary/10 blur-2xl"}),o.jsxs("div",{className:"relative mx-auto mt-4 max-w-[250px]",children:[o.jsx("div",{className:"absolute left-6 top-3 h-24 w-40 rotate-[-6deg] rounded-xl border border-border/70 bg-background shadow-sm"}),o.jsx("div",{className:"absolute right-5 top-2 h-24 w-40 rotate-[5deg] rounded-xl border border-border/70 bg-background shadow-sm"}),o.jsxs("div",{className:"relative mx-auto mt-8 h-24 w-44 rounded-xl border border-primary/20 bg-background p-4 shadow-md shadow-primary/5",children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(nr,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("div",{className:"h-2 w-20 rounded bg-foreground/70"}),o.jsx("div",{className:"mt-1.5 h-1.5 w-14 rounded bg-muted-foreground/25"})]})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("div",{className:"h-1.5 w-full rounded bg-muted-foreground/15"}),o.jsx("div",{className:"h-1.5 w-4/5 rounded bg-muted-foreground/15"})]})]})]})]}):t==="evidence"?o.jsx("div",{className:"relative h-44 overflow-hidden rounded-2xl bg-gradient-to-br from-primary/[0.08] via-background to-emerald-500/[0.045] p-5",children:o.jsxs("div",{className:"mx-auto mt-2 max-w-[260px] rounded-xl border border-border/70 bg-background p-4 shadow-md shadow-primary/5",children:[o.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(jr,{className:"h-3.5 w-3.5"})}),o.jsx("div",{className:"h-2.5 w-24 rounded bg-foreground/70"})]}),o.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-1 text-[10px] font-semibold text-primary",children:"p. 24"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"h-1.5 w-full rounded bg-muted-foreground/15"}),o.jsxs("div",{className:"rounded-md border-l-2 border-primary bg-primary/[0.07] px-2 py-2",children:[o.jsx("div",{className:"h-1.5 w-full rounded bg-primary/30"}),o.jsx("div",{className:"mt-1.5 h-1.5 w-5/6 rounded bg-primary/25"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-emerald-600",children:[o.jsx(kr,{className:"h-3 w-3"}),"Original passage verified"]})]})]})}):o.jsxs("div",{className:"relative h-44 overflow-hidden rounded-2xl bg-gradient-to-br from-primary/[0.07] via-background to-primary/[0.03] p-5",children:[o.jsx("div",{className:"absolute left-1/2 top-1/2 h-32 w-32 -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary/[0.08] blur-2xl"}),o.jsxs("div",{className:"relative mx-auto flex h-full max-w-[250px] items-center justify-center gap-4",children:[o.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-2xl border border-border/70 bg-background shadow-md shadow-primary/5",children:o.jsx(UM,{className:"h-8 w-8 text-primary"})}),o.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-2xl border border-border/70 bg-background shadow-md shadow-primary/5",children:o.jsx(Jhe,{className:"h-8 w-8 text-primary"})})]}),o.jsx("div",{className:"absolute inset-x-0 bottom-5 flex justify-center",children:o.jsx("span",{className:"rounded-full border border-border/70 bg-background/90 px-3 py-1 text-[10px] font-semibold text-muted-foreground shadow-sm",children:"GDPR · EU"})})]}),Vvt=()=>o.jsx("section",{className:"bg-background py-20 md:py-24 lg:py-28",children:o.jsxs(Kn,{children:[o.jsxs("div",{className:"mx-auto mb-12 max-w-3xl text-center md:mb-14",children:[o.jsx("span",{className:"inline-flex items-center rounded-full border border-primary/15 bg-primary/[0.07] px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-primary",children:"Academic trust"}),o.jsx("h2",{className:"mt-5 text-3xl font-bold tracking-tight text-foreground md:text-4xl lg:text-[2.75rem] lg:leading-[1.1]",children:"Built for academic trust."}),o.jsx("p",{className:"mx-auto mt-5 max-w-2xl text-base leading-7 text-muted-foreground md:text-lg",children:"Unlike generic AI tools, Academly is designed around verifiable academic work."})]}),o.jsx("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-3",children:Hvt.map(t=>{const e=t.icon;return o.jsxs("article",{className:"group rounded-2xl border border-border/70 bg-card p-3 shadow-sm transition duration-200 hover:-translate-y-0.5 hover:shadow-md",children:[o.jsx(Wvt,{type:t.visual}),o.jsxs("div",{className:"px-3 pb-4 pt-5",children:[o.jsx("div",{className:"mb-4 flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(e,{className:"h-5 w-5"})}),o.jsx("h3",{className:"text-lg font-semibold tracking-tight text-foreground",children:t.title}),o.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:t.text})]})]},t.title)})})]})}),Zre=[{icon:cf,title:"Upload Interviews",text:"Bring your interview material into one structured workspace."},{icon:oMe,title:"Create Categories",text:"Build and refine your qualitative codebook."},{icon:nv,title:"Analyze Findings",text:"Code material and identify recurring patterns across interviews."},{icon:jr,title:"Generate Discussion",text:"Turn your findings into a structured basis for academic discussion."}],qvt=()=>o.jsx("section",{className:"bg-background py-20 md:py-24 lg:py-28",children:o.jsxs(Kn,{children:[o.jsxs("div",{className:"mx-auto max-w-3xl text-center",children:[o.jsx("span",{className:"inline-flex items-center rounded-full border border-primary/15 bg-primary/[0.07] px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-primary",children:"Qualitative Analysis"}),o.jsx("h2",{className:"mt-5 text-3xl font-bold tracking-tight text-foreground md:text-4xl lg:text-[2.75rem] lg:leading-[1.1]",children:"A complete qualitative workflow, built into your thesis workspace."}),o.jsx("p",{className:"mx-auto mt-5 max-w-2xl text-base leading-7 text-muted-foreground md:text-lg",children:"From interview material and categories to coding, analysis and discussion."})]}),o.jsxs("div",{className:"relative mx-auto mt-14 max-w-6xl",children:[o.jsx("div",{className:"hidden md:block absolute left-[12%] right-[12%] top-10 h-px bg-border"}),o.jsx("div",{className:"grid grid-cols-1 gap-5 md:grid-cols-4",children:Zre.map((t,e)=>{const r=t.icon;return o.jsxs("div",{className:"relative",children:[o.jsxs("div",{className:"relative h-full rounded-2xl border border-border/70 bg-card p-6 shadow-sm",children:[o.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[o.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(r,{className:"h-5 w-5"})}),o.jsxs("span",{className:"text-xs font-semibold text-muted-foreground",children:["0",e+1]})]}),o.jsx("h3",{className:"text-base font-semibold tracking-tight text-foreground",children:t.title}),o.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:t.text})]}),e<Zre.length-1&&o.jsx(As,{className:"absolute -right-3 top-9 z-10 hidden h-5 w-5 text-primary/50 md:block"})]},t.title)})})]}),o.jsx("div",{className:"mt-10 text-center",children:o.jsx(me,{asChild:!0,size:"lg",className:"rounded-xl px-7 shadow-sm",children:o.jsx(Nt,{to:"/login?mode=signup",children:"Explore Qualitative Analysis"})})})]})}),Gvt=[{icon:tfe,title:"Turn research into thesis chapters",description:"Generate structured theory, methods, discussion and conclusion chapters directly from your sources."},{icon:nv,title:"Complete Mayring workflow in one place",description:"Code interviews, create categories and generate findings without switching tools."},{icon:HM,title:"Get feedback before your supervisor sees it",description:"Identify weak arguments, missing sections and unclear writing before submission."},{icon:ua,title:"Never lose track of a source again",description:"Every citation stays connected to real PDFs and verified page references."}],Kvt=()=>o.jsx("div",{id:"features",className:"py-16 lg:py-24",children:o.jsxs(Kn,{children:[o.jsxs("div",{className:"md:w-2/3 lg:w-1/2",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary mb-3",children:"Why Academly"}),o.jsx("h2",{className:"my-4 text-2xl font-bold text-foreground md:text-4xl",children:"Built for thesis writing, not generic chatting."}),o.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."})]}),o.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:Gvt.map((t,e)=>o.jsx("div",{className:"group relative bg-card transition hover:z-[1] hover:shadow-2xl hover:shadow-gray-600/10",children:o.jsxs("div",{className:"relative space-y-6 py-10 p-7",children:[o.jsx(t.icon,{className:"w-10 h-10 text-primary"}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h3",{className:"text-lg font-semibold text-foreground transition group-hover:text-primary",children:t.title}),o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:t.description})]})]})},e))}),o.jsxs("div",{className:"mt-24 max-w-3xl mx-auto",children:[o.jsx("p",{className:"text-center text-xs font-semibold uppercase tracking-widest text-primary mb-3",children:"ChatGPT vs Academly"}),o.jsx("h3",{className:"text-center text-2xl md:text-3xl font-bold text-foreground mb-3",children:"Why students switch from ChatGPT to Academly"}),o.jsxs("p",{className:"text-center text-muted-foreground mb-10",children:["ChatGPT helps you write. Academly helps you write ",o.jsx("em",{children:"academically"}),"."]}),o.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"rounded-2xl bg-primary p-7 text-primary-foreground",children:[o.jsx("p",{className:"font-bold text-lg mb-6",children:"Academly"}),o.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=>o.jsxs("li",{className:"flex items-start gap-3 text-sm",children:[o.jsx(kr,{className:"w-4 h-4 mt-0.5 shrink-0 opacity-90"}),o.jsx("span",{children:t})]},t))})]}),o.jsxs("div",{className:"rounded-2xl border border-border bg-card p-7",children:[o.jsx("p",{className:"font-bold text-lg text-muted-foreground mb-6",children:"ChatGPT"}),o.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=>o.jsxs("li",{className:"flex items-start gap-3 text-sm",children:[o.jsx(fn,{className:"w-4 h-4 mt-0.5 shrink-0 text-muted-foreground"}),o.jsx("span",{className:"text-muted-foreground",children:t})]},t))})]})]})]})]})}),Yvt=[{icon:cf,title:"Upload academic sources",text:"Add the PDFs, papers and interviews you want your thesis to be built on."},{icon:vMe,title:"Select relevant pages",text:"Pick the exact pages and passages Academly should write from."},{icon:Sr,title:"Generate source-based drafts",text:"Produce theory, methods, discussion and conclusion text grounded in those sources."},{icon:DOe,title:"Verify citations",text:"Every quote and reference links back to the original PDF and page number."},{icon:nr,title:"Build your thesis",text:"Assemble verified chapters into a structured Bachelor or Master thesis."}],Xvt=()=>o.jsx("section",{id:"how-it-works",className:"py-16 lg:py-24",children:o.jsxs(Kn,{children:[o.jsxs("div",{className:"max-w-2xl mx-auto text-center mb-12",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-primary mb-3",children:"Workflow"}),o.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground",children:"How Academly works"})]}),o.jsx("ol",{className:"grid gap-4 md:grid-cols-5 max-w-6xl mx-auto",children:Yvt.map((t,e)=>{const r=t.icon;return o.jsxs("li",{className:"relative rounded-2xl border border-border bg-card p-5 shadow-sm",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[o.jsx("div",{className:"w-9 h-9 rounded-lg bg-primary/10 text-primary flex items-center justify-center",children:o.jsx(r,{className:"w-4 h-4"})}),o.jsxs("span",{className:"text-[11px] font-bold uppercase tracking-widest text-primary/60",children:["Step ",e+1]})]}),o.jsx("h3",{className:"font-semibold text-foreground mb-1.5 text-sm",children:t.title}),o.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:t.text})]},t.title)})})]})}),Qvt=_f("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 o.jsx("div",{className:Pe(Qvt({variant:e}),t),...r})}const Jre=[{quarter:"Q3 2025",title:"Core Platform",description:"Dashboard, Document Library, PDF Upload, Text Extractor, Page Selector",icon:o.jsx(No,{className:"h-4 w-4"})},{quarter:"Q4 2025",title:"Writing Suite",description:"Topic Explorer (Ideas, Outline, Keywords), Theory & Background, Methods & Approach, Discussion Generator",icon:o.jsx(No,{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:o.jsx(No,{className:"h-4 w-4"})}],S3=[{key:"student-hub",label:"Student Hub",icon:o.jsx(NN,{className:"h-4 w-4"}),timeline:[{quarter:"Q1 2027",title:"Development",description:"Building user exchange and community chat features."},{quarter:"Q1 2027",title:"Beta Testing",description:"Early adopters test collaboration and resource sharing."},{quarter:"Q2 2027",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:o.jsx(gMe,{className:"h-4 w-4"}),timeline:[{quarter:"Q2 2027",title:"Development",description:"Core audio/video transcription engine for interviews."},{quarter:"Q2 2027",title:"Beta Multilanguage",description:"Testing German, English and additional language support."},{quarter:"Q3 2027",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:o.jsx(nv,{className:"h-4 w-4"}),timeline:[{quarter:"Q2 2027",title:"Exploring Modular Design",description:"Defining the architecture for pluggable analysis modules."},{quarter:"Q2 2027",title:"Data Visualization",description:"Developing charts, boxplots and visual analysis tools."},{quarter:"Q3 2027",title:"Beta Testing",description:"Validating statistical workflows with early testers."},{quarter:"Q3 2027",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:o.jsx(ua,{className:"h-4 w-4"}),timeline:[{quarter:"Q2 2027",title:"Development",description:"Implementing MLA, Chicago, Harvard and Vancouver parsers."},{quarter:"Q2 2027",title:"Beta Testing",description:"Testing citation accuracy across multiple style guides."},{quarter:"Q3 2027",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."}]}],Zvt={done:{label:"Done",variant:"success"},planned:{label:"Planned",variant:"default"},exploring:{label:"Exploring",variant:"warning"}},Jvt=({milestones:t})=>o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"hidden md:block relative mb-10",children:[o.jsx("div",{className:"absolute top-4 left-0 right-0 h-0.5 bg-border"}),o.jsx("div",{className:"grid gap-8 relative",style:{gridTemplateColumns:`repeat(${t.length}, minmax(0, 1fr))`},children:t.map((e,r)=>o.jsxs(Zu.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:[o.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:o.jsx(vX,{className:"h-3.5 w-3.5"})}),o.jsx(kt,{variant:"default",className:"mb-1 text-[10px]",children:e.quarter}),o.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),e.description&&o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 max-w-[180px] leading-relaxed",children:e.description})]},r))})]}),o.jsxs("div",{className:"md:hidden space-y-4 relative pl-7 mb-8",children:[o.jsx("div",{className:"absolute left-[13px] top-0 bottom-0 w-0.5 bg-border"}),t.map((e,r)=>o.jsxs(Zu.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},transition:{duration:.3,delay:r*.08},className:"relative",children:[o.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:o.jsx(vX,{className:"h-3 w-3"})}),o.jsx(kt,{variant:"default",className:"mb-0.5 text-[10px]",children:e.quarter}),o.jsx("p",{className:"text-sm font-medium text-foreground",children:e.title}),e.description&&o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 leading-relaxed",children:e.description})]},r))]})]}),ebt=()=>{const[t,e]=S.useState(S3[0].key),r=S3.find(n=>n.key===t);return o.jsx("section",{id:"roadmap",className:"bg-background py-20 sm:py-28",children:o.jsxs(Kn,{children:[o.jsxs(Zu.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.5},className:"text-center mb-16",children:[o.jsx(kt,{variant:"secondary",className:"mb-4",children:"Roadmap"}),o.jsx("h2",{className:"text-3xl sm:text-4xl font-bold tracking-tight text-foreground mb-4",children:"Building the Future of Academic Writing"}),o.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."})]}),o.jsxs("div",{className:"mb-20",children:[o.jsx("h3",{className:"text-sm font-semibold uppercase tracking-wider text-muted-foreground mb-8 text-center",children:"What we've shipped"}),o.jsxs("div",{className:"hidden md:block relative",children:[o.jsx("div",{className:"absolute top-5 left-0 right-0 h-0.5 bg-border"}),o.jsx("div",{className:"grid grid-cols-3 gap-8 relative",children:Jre.map((n,s)=>o.jsxs(Zu.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:[o.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}),o.jsx(kt,{variant:"success",className:"mb-2",children:n.quarter}),o.jsx("p",{className:"font-semibold text-foreground mb-1",children:n.title}),o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:n.description})]},n.quarter))})]}),o.jsxs("div",{className:"md:hidden space-y-6 relative pl-8",children:[o.jsx("div",{className:"absolute left-[15px] top-0 bottom-0 w-0.5 bg-border"}),Jre.map((n,s)=>o.jsxs(Zu.div,{initial:{opacity:0,x:-10},whileInView:{opacity:1,x:0},viewport:{once:!0},transition:{duration:.4,delay:s*.1},className:"relative",children:[o.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}),o.jsx(kt,{variant:"success",className:"mb-1",children:n.quarter}),o.jsx("p",{className:"font-semibold text-foreground",children:n.title}),o.jsx("p",{className:"text-sm text-muted-foreground",children:n.description})]},n.quarter))]})]}),o.jsxs("div",{children:[o.jsxs(Zu.div,{initial:{opacity:0,y:16},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4},className:"text-center mb-8",children:[o.jsx("h3",{className:"text-2xl sm:text-3xl font-bold tracking-tight text-foreground mb-2",children:"What's Next"}),o.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."})]}),o.jsx("div",{className:"flex flex-wrap items-center justify-center gap-2 mb-10",children:S3.map(n=>o.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))}),o.jsxs(Zu.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.3},children:[r.timeline&&o.jsx(Jvt,{milestones:r.timeline}),o.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:r.items.map((n,s)=>{const i=Zvt[n.status];return o.jsx(Ze,{className:"flex flex-col",children:o.jsxs(st,{className:"pt-6 flex flex-col flex-1",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[o.jsx("h4",{className:"font-semibold text-foreground leading-snug",children:n.title}),o.jsx(kt,{variant:i.variant,className:"shrink-0",children:i.label})]}),o.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed mb-3 flex-1",children:n.description}),o.jsxs("p",{className:"text-xs text-muted-foreground/70 flex items-start gap-1.5",children:[o.jsx(dd,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),n.why]})]})},s)})})]},t)]})]})})},tbt=()=>o.jsxs("div",{className:"relative py-16 lg:py-24",children:[o.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:[o.jsx("div",{className:"blur-[106px] h-56 bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),o.jsx("div",{className:"blur-[106px] h-32 bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),o.jsx(Kn,{children:o.jsxs("div",{className:"relative m-auto space-y-6 md:w-9/12 lg:w-8/12",children:[o.jsx("h2",{className:"text-center text-4xl font-bold text-foreground md:text-5xl",children:"Stop wasting weeks organizing sources."}),o.jsx("p",{className:"text-center text-xl text-muted-foreground",children:"Write faster, stay academically safe and keep every citation connected to real research."}),o.jsxs("div",{className:"flex flex-wrap justify-center gap-6 pt-2",children:[o.jsx(Nt,{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:o.jsx("span",{className:"relative text-base font-semibold text-primary-foreground",children:"Start Free"})}),o.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:o.jsx("span",{className:"relative text-base font-semibold text-primary dark:text-white",children:"See Source Demo"})})]})]})})]}),Di=({title:t,description:e,canonical:r,ogImage:n="https://academly.ai/og-image.png",jsonLd:s,noIndex:i=!1})=>o.jsxs(vhe,{children:[o.jsx("title",{children:t}),o.jsx("meta",{name:"description",content:e}),o.jsx("link",{rel:"canonical",href:r}),i?o.jsx("meta",{name:"robots",content:"noindex, nofollow"}):o.jsx("meta",{name:"robots",content:"index, follow"}),o.jsx("meta",{property:"og:title",content:t}),o.jsx("meta",{property:"og:description",content:e}),o.jsx("meta",{property:"og:url",content:r}),o.jsx("meta",{property:"og:type",content:"website"}),o.jsx("meta",{property:"og:image",content:n}),o.jsx("meta",{property:"og:site_name",content:"Academly.ai"}),o.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),o.jsx("meta",{name:"twitter:title",content:t}),o.jsx("meta",{name:"twitter:description",content:e}),o.jsx("meta",{name:"twitter:image",content:n}),s&&o.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})]}),rbt=[{"@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"}}],nbt=()=>o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{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:rbt}),o.jsx(Ri,{}),o.jsxs("main",{className:"overflow-hidden",children:[o.jsx(_vt,{}),o.jsxs("section",{id:"source-demo",className:"relative py-20 md:py-24 lg:py-28",children:[o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 -z-10 h-[520px] bg-gradient-to-b from-primary/[0.045] via-primary/[0.018] to-transparent"}),o.jsxs("div",{className:"mx-auto max-w-4xl px-5 text-center sm:px-6 lg:px-8",children:[o.jsx("span",{className:"inline-flex items-center rounded-full border border-primary/15 bg-primary/[0.07] px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-primary",children:"Source-backed writing"}),o.jsx("h2",{className:"mt-5 text-3xl font-bold tracking-tight text-foreground md:text-4xl lg:text-[2.85rem] lg:leading-[1.1]",children:"See exactly how Academly writes from your research."}),o.jsx("p",{className:"mx-auto mt-5 max-w-3xl text-base leading-7 text-muted-foreground md:text-lg",children:"Upload PDFs, select source pages, generate academic text and verify every citation."})]}),o.jsxs("div",{className:"relative mx-auto mt-12 w-full max-w-[1400px] px-5 sm:px-6 lg:px-8",children:[o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-16 top-8 -z-10 h-56 rounded-full bg-primary/10 blur-[90px]"}),o.jsx(Ovt,{})]}),o.jsxs("div",{className:"mx-auto mt-9 max-w-3xl px-5 text-center sm:px-6 lg:px-8",children:[o.jsx("p",{className:"text-base font-medium text-foreground",children:"Every statement stays connected to real academic sources."}),o.jsx(me,{asChild:!0,size:"lg",className:"mt-5 rounded-xl px-7 shadow-sm",children:o.jsx(Nt,{to:"/login?mode=signup",children:"Try it with your own sources"})})]})]}),o.jsx(Vvt,{}),o.jsxs("section",{className:"py-20 md:py-24 lg:py-28",children:[o.jsxs("div",{className:"mx-auto max-w-4xl px-5 text-center sm:px-6 lg:px-8",children:[o.jsx("span",{className:"inline-flex items-center rounded-full border border-primary/15 bg-primary/[0.07] px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-primary",children:"Free academic tool"}),o.jsx("h2",{className:"mt-5 text-3xl font-bold tracking-tight text-foreground md:text-4xl lg:text-[2.85rem] lg:leading-[1.1]",children:"Free Bachelor & Master Thesis Topic Generator"}),o.jsx("p",{className:"mx-auto mt-5 max-w-3xl text-base leading-7 text-muted-foreground md:text-lg",children:"Generate thesis ideas, research questions and methodology suggestions in seconds."})]}),o.jsxs("div",{className:"relative mx-auto mt-12 w-full max-w-[1400px] px-5 sm:px-6 lg:px-8",children:[o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-20 top-8 -z-10 h-52 rounded-full bg-primary/[0.09] blur-[90px]"}),o.jsx(Uvt,{})]}),o.jsx("div",{className:"mx-auto mt-9 max-w-3xl px-5 text-center sm:px-6 lg:px-8",children:o.jsx(me,{asChild:!0,size:"lg",className:"rounded-xl px-7 shadow-sm",children:o.jsx(Nt,{to:"/topic-ideas",children:"Generate Thesis Topics Free"})})})]}),o.jsx("section",{className:"py-20 md:py-24 lg:py-28",children:o.jsx(Kvt,{})}),o.jsx(qvt,{}),o.jsx("section",{className:"py-20 md:py-24 lg:py-28",children:o.jsx(Xvt,{})}),o.jsx(ebt,{}),o.jsx("section",{className:"py-20 md:py-24",children:o.jsx(tbt,{})})]}),o.jsx(Ii,{})]});function e1e(){const{user:t,userProfile:e}=Ht(),[r,n]=S.useState(!1);return{loading:r,createCheckoutSession:async(l,c)=>{if(!t){Ke.error("Please log in to subscribe");return}n(!0);try{const{data:u,error:d}=await vn.functions.invoke("create-checkout-session",{body:l==="lifetime"?{plan:l}:{plan:l,billingInterval:c??"monthly"}});if(d)throw d;if(u!=null&&u.url)window.location.href=u.url;else throw new Error("No checkout URL received")}catch(u){console.error("Checkout error:",u),Ke.error(u.message||"Failed to create checkout session")}finally{n(!1)}},openCustomerPortal:async(l,c)=>{if(!t){Ke.error("Please log in to manage subscription");return}n(!0);try{const u=l&&c?{targetPlan:l,targetInterval:c}:{},{data:d,error:h}=await vn.functions.invoke("create-customer-portal",{body:u});if(h)throw h;if(d!=null&&d.url)window.location.href=d.url;else throw new Error("No portal URL received")}catch(u){console.error("Portal error:",u),Ke.error(u.message||"Failed to open customer portal")}finally{n(!1)}},getSubscriptionStatus:()=>e?{plan:e.plan,status:e.subscription_status,endsAt:e.subscription_ends_at,interval:e.subscription_interval??null,isActive:e.subscription_status==="active",hasSubscription:!!e.stripe_subscription_id}:null}}const ene=[{name:"Free",description:"For exploring Academly"},{name:"Pro",description:"For active thesis work",highlighted:!0},{name:"Author / Lifetime",description:"For intensive academic work"}],kT=1,sbt=[{title:"Thesis Writing",rows:[{label:"Theory Builder",values:[{value:"up to 4"},{value:"up to 66"},{value:"up to 133"}]},{label:"Methodology Builder",values:[{value:"up to 4"},{value:"up to 66"},{value:"up to 133"}]},{label:"Discussion Builder",values:[{value:"up to 7"},{value:"up to 100"},{value:"up to 200"}]},{label:"Conclusion Builder",values:[{value:"up to 7"},{value:"up to 100"},{value:"up to 200"}]},{label:"Fox AI",values:[{value:"up to 70"},{value:"up to 1,000"},{value:"up to 2,000"}]},{label:"AI Supervisor",values:[{value:"up to 9"},{value:"up to 133"},{value:"up to 266"}]}]},{title:"Uploads & Sources",rows:[{label:"Library Uploads",values:[{value:"10"},{value:"100"},{value:"500"}]},{label:"PDF Size",values:[{value:"10 MB"},{value:"25 MB"},{value:"50 MB"}]},{label:"PDF Page Count",values:[{value:"100 pages"},{value:"2,000 pages"},{value:"8,000 pages"}]}]},{title:"Exports",rows:[{label:"Document Export",values:[{value:"check"},{value:"check"},{value:"check"}]},{label:"Library Export",values:[{value:"Basic"},{value:"check"},{value:"check"}]}]},{title:"Additional Features",rows:[{label:"Citation Styles",values:[{value:"check"},{value:"check"},{value:"check"}]},{label:"Talk to PDF (planned)",values:[{value:"dash"},{value:"dash"},{value:"check"}]},{label:"Advanced PDF / Source Chat (later)",values:[{value:"dash"},{value:"dash"},{value:"check"}]}]},{title:"Qualitative Research",rows:[{label:"Research Setup",values:[{value:"Limited"},{value:"check"},{value:"check"}]},{label:"Codebook",values:[{value:"dash"},{value:"check"},{value:"check"}]},{label:"Codebook Grid",values:[{value:"dash"},{value:"check"},{value:"check"}]},{label:"Interviews",values:[{value:"dash"},{value:"check"},{value:"check"}]},{label:"Coding",values:[{value:"dash"},{value:"check"},{value:"check"}]},{label:"Analysis",values:[{value:"dash"},{value:"check"},{value:"check"}]},{label:"Student Points",values:[{value:"140 included"},{value:"2,000 / month"},{value:"4,000 / month",sub:"Forever with Lifetime"}]},{label:"Support",values:[{value:"Standard"},{value:"Standard"},{value:"Priority"}]}]}];function ibt({cell:t,highlighted:e}){return t.value==="check"?o.jsx("span",{className:`inline-flex h-7 w-7 items-center justify-center rounded-full ${e?"bg-primary text-primary-foreground shadow-sm":"bg-primary/10 text-primary"}`,"aria-label":"Included",children:o.jsx(kr,{className:"h-4 w-4"})}):t.value==="dash"?o.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-full bg-muted/40",children:o.jsx(efe,{className:"h-4 w-4 text-muted-foreground/40","aria-label":"Not included"})}):o.jsxs("span",{className:"flex flex-col gap-1",children:[o.jsx("span",{className:`text-sm ${e?"font-semibold text-foreground":"font-medium text-foreground/80"}`,children:t.value}),t.sub&&o.jsx("span",{className:"max-w-[150px] text-xs leading-5 text-muted-foreground",children:t.sub})]})}function abt(){return o.jsxs("section",{className:"mt-24 md:mt-28",children:[o.jsxs("div",{className:"mx-auto max-w-3xl text-center",children:[o.jsx("span",{className:"inline-flex items-center rounded-full border border-primary/15 bg-primary/[0.07] px-3 py-1.5 text-[11px] font-semibold uppercase tracking-[0.16em] text-primary",children:"Plan comparison"}),o.jsx("h2",{className:"mt-5 text-3xl font-bold tracking-tight text-foreground md:text-4xl",children:"Compare plans at a glance."}),o.jsx("p",{className:"mx-auto mt-4 max-w-2xl text-base leading-7 text-muted-foreground",children:"Usage examples assume all available Student Points are spent on a single feature."})]}),o.jsx("div",{className:"mt-12 overflow-x-auto",children:o.jsxs("div",{className:"min-w-[900px]",children:[o.jsxs("div",{className:"grid grid-cols-[minmax(250px,1.35fr)_repeat(3,minmax(190px,1fr))] border-b border-border/70",children:[o.jsx("div",{className:"px-6 pb-5",children:o.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-muted-foreground",children:"Feature"})}),ene.map((t,e)=>o.jsxs("div",{className:`relative px-6 pb-5 ${e===kT?"rounded-t-2xl border-x border-t border-primary/15 bg-primary/[0.045]":""}`,children:[e===kT&&o.jsxs("div",{className:"mb-3 inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-primary",children:[o.jsx(Sr,{className:"h-3 w-3"}),"Most popular"]}),o.jsx("h3",{className:"text-lg font-semibold tracking-tight text-foreground",children:t.name}),o.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:t.description})]},t.name))]}),o.jsx("div",{children:sbt.map((t,e)=>o.jsxs(S.Fragment,{children:[o.jsx("div",{className:`grid grid-cols-[minmax(250px,1.35fr)_repeat(3,minmax(190px,1fr))] ${e>0?"mt-7":"mt-3"}`,children:o.jsx("div",{className:"col-span-4 border-b border-border/70 px-6 pb-3 pt-2",children:o.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-primary",children:t.title})})}),t.rows.map((r,n)=>o.jsxs("div",{className:`group grid grid-cols-[minmax(250px,1.35fr)_repeat(3,minmax(190px,1fr))] ${n<t.rows.length-1?"border-b border-border/45":""}`,children:[o.jsx("div",{className:"px-6 py-4.5",children:o.jsx("span",{className:"text-sm font-medium text-foreground/90",children:r.label})}),r.values.map((s,i)=>o.jsx("div",{className:`flex min-h-[58px] items-center px-6 py-4 ${i===kT?"border-x border-primary/10 bg-primary/[0.028]":""}`,children:o.jsx(ibt,{cell:s,highlighted:i===kT})},`${r.label}-${ene[i].name}`))]},`${t.title}-${r.label}`))]},t.title))}),o.jsxs("div",{className:"grid grid-cols-[minmax(250px,1.35fr)_repeat(3,minmax(190px,1fr))]",children:[o.jsx("div",{}),o.jsx("div",{}),o.jsx("div",{className:"h-4 rounded-b-2xl border-x border-b border-primary/10 bg-primary/[0.028]"}),o.jsx("div",{})]})]})}),o.jsx("p",{className:"mt-8 text-center text-sm text-muted-foreground",children:"Student Points can be used flexibly across all Academly tools."})]})}const obt=!0,lbt=250,cbt=[{id:"free",name:"Free",monthlyPrice:0,annualPrice:0,oneTimePrice:null,points:"140",description:"Perfect for getting started",features:["140 Student Points on signup","PDF upload up to 5 MB","Basic summaries","Automatic citations"],popular:!1,enabled:!0},{id:"pro",name:"Pro",monthlyPrice:24,annualPrice:144,oneTimePrice:null,points:"2,000",description:"Ideal for active researchers",features:["2,000 Student Points refreshed monthly","PDF upload up to 50 MB","Advanced summaries","Methodology Builder","Theory Builder","Discussion Builder","Qualitative Analysis","Export to multiple formats"],popular:!0,enabled:!0},{id:"author",name:"Author",monthlyPrice:45,annualPrice:270,oneTimePrice:null,points:"4,000",description:"For students & professionals",features:["4,000 Student Points refreshed monthly","PDF upload up to 50 MB","All Pro features","AI-powered text blocks","Collaboration features","Custom citation styles"],popular:!1,enabled:!0},{id:"lifetime",name:"Lifetime",monthlyPrice:null,annualPrice:null,oneTimePrice:399,points:"4,000",description:"One-time payment, lifetime access",features:["4,000 Student Points refreshed monthly","Lifetime access to all features","All Author features included","One-time payment, no subscription","Future feature updates included"],popular:!1,isLifetime:!0,enabled:obt}],ubt=cbt.filter(t=>t.enabled!==!1),dbt={"@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"},hbt=()=>{const t=Or(),{user:e,userProfile:r,loading:n}=Ht(),{createCheckoutSession:s,openCustomerPortal:i,loading:a}=e1e(),[l,c]=S.useState(null),[u,d]=S.useState("monthly"),h=(r==null?void 0:r.plan)||"free",f=(r==null?void 0:r.subscription_status)==="active";S.useEffect(()=>{(async()=>{const{data:x,error:v}=await vn.rpc("get_lifetime_sold_count");!v&&x!==null&&c(x)})()},[]),S.useEffect(()=>{typeof window<"u"&&window.umami&&window.umami.track("pricing-page-view")},[]);const p=async y=>{if(y==="free"){t(e?"/dashboard":"/login");return}if(!e){t("/login");return}if(y==="lifetime"){await s(y);return}if(h===y&&f){await i();return}if(f){await i(y,u);return}await s(y,u)},m=y=>y==="free"?e?"Current Plan":"Get Started":y==="lifetime"?h==="lifetime"?"Current Plan":"Buy Lifetime Access":e?h===y&&f?"Manage Plan":f?"Change Plan":"Subscribe Now":"Start Trial",g=y=>y==="lifetime"&&h==="lifetime"||y==="free"&&h==="free"&&!f?!0:h===y&&f;return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{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:dbt}),o.jsx(Ri,{}),o.jsxs("section",{className:"relative pt-32 pb-20 overflow-visible",children:[o.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:[o.jsx("div",{className:"blur-[106px] h-[400px] bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),o.jsx("div",{className:"blur-[106px] h-[300px] bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),o.jsx(Kn,{className:"relative",children:o.jsxs("div",{className:"text-center max-w-3xl mx-auto",children:[o.jsxs("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-foreground mb-6",children:["Simple, Transparent",o.jsx("span",{className:"text-primary",children:" Pricing"})]}),o.jsx("p",{className:"text-xl text-muted-foreground",children:"Choose the plan that fits your research needs. No hidden fees, cancel anytime."})]})})]}),o.jsx("section",{className:"relative py-20 overflow-visible",children:o.jsxs(Kn,{className:"max-w-screen-xl",children:[o.jsx("div",{className:"flex justify-center mb-12",children:o.jsxs("div",{className:"inline-flex items-center rounded-full border border-border bg-card p-1",children:[o.jsx("button",{type:"button",onClick:()=>d("monthly"),className:`px-6 py-2 text-sm font-semibold rounded-full transition-colors ${u==="monthly"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:"Monthly"}),o.jsxs("button",{type:"button",onClick:()=>d("annual"),className:`px-6 py-2 text-sm font-semibold rounded-full transition-colors flex items-center gap-2 ${u==="annual"?"bg-primary text-primary-foreground":"text-muted-foreground hover:text-foreground"}`,children:["Annual",o.jsx("span",{className:"text-xs font-bold text-amber-500",children:"Save 50%"})]})]})}),o.jsx("div",{className:"grid md:grid-cols-2 xl:grid-cols-4 gap-8",children:ubt.map(y=>o.jsxs("div",{className:`relative rounded-3xl p-8 transition-all duration-300 hover:shadow-2xl ${y.popular?"bg-primary text-primary-foreground scale-105 shadow-2xl":y.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:[o.jsxs("div",{className:"absolute -top-4 left-1/2 -translate-x-1/2 flex gap-2",children:[y.popular&&o.jsx("span",{className:"bg-orange-500 text-white text-sm font-medium px-4 py-1 rounded-full whitespace-nowrap",children:"Most Popular"}),y.isLifetime&&o.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:[o.jsx(sg,{className:"h-3.5 w-3.5"}),"Limited Offer"]})]}),u==="annual"&&!y.isLifetime&&y.id!=="free"&&o.jsx("div",{className:"absolute -top-3 right-4",children:o.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:[o.jsx(Sr,{className:"h-3 w-3"}),"Save 50%"]})}),y.isLifetime&&l!==null&&o.jsx("div",{className:"absolute -top-3 right-4",children:o.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:[l,"/",lbt," sold"]})}),o.jsxs("div",{className:"text-center mb-8 mt-2",children:[o.jsx("h3",{className:`text-2xl font-bold mb-2 ${y.popular?"":"text-foreground"}`,children:y.name}),o.jsx("p",{className:`text-sm mb-4 ${y.popular?"text-primary-foreground/80":"text-muted-foreground"}`,children:y.description}),o.jsxs("div",{className:"mb-2",children:[o.jsxs("div",{children:[y.id!=="free"&&!y.isLifetime&&u==="annual"?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-4xl font-bold",children:["$",(y.monthlyPrice??0)%2===0?y.monthlyPrice/2:(y.monthlyPrice/2).toFixed(2)]}),o.jsx("span",{className:y.popular?"text-primary-foreground/80":"text-muted-foreground",children:"/month"})]}):o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"text-4xl font-bold",children:["$",y.isLifetime?y.oneTimePrice:u==="annual"?y.annualPrice:y.monthlyPrice]}),y.id!=="free"&&!y.isLifetime&&o.jsx("span",{className:y.popular?"text-primary-foreground/80":"text-muted-foreground",children:u==="annual"?"/year":"/month"})]}),y.isLifetime&&o.jsxs("span",{className:y.popular?"text-primary-foreground/80":"text-muted-foreground",children:[" ","one-time"]})]}),y.id!=="free"&&!y.isLifetime&&u==="annual"&&o.jsxs("p",{className:`text-xs mt-1 ${y.popular?"text-primary-foreground/70":"text-muted-foreground"}`,children:["$",y.annualPrice," instead of"," ",o.jsxs("span",{className:"line-through",children:["$",(y.annualPrice??0)*2]})]}),y.id!=="free"&&!y.isLifetime&&u==="annual"&&o.jsx("p",{className:`text-[11px] mt-0.5 opacity-60 ${y.popular?"text-primary-foreground/60":"text-muted-foreground"}`,children:"Billed annually"})]}),o.jsx("p",{className:`text-sm ${y.popular?"text-primary-foreground/80":"text-muted-foreground"}`,children:y.id==="free"?`${y.points} Student Points`:`${y.points} Student Points refreshed monthly`})]}),o.jsx("ul",{className:"space-y-4 mb-8",children:y.features.map((x,v)=>o.jsxs("li",{className:"flex items-start gap-3",children:[o.jsx(uc,{className:`h-5 w-5 flex-shrink-0 mt-0.5 ${y.popular?"text-primary-foreground":"text-primary"}`}),o.jsx("span",{className:`text-sm ${y.popular?"":"text-muted-foreground"}`,children:x})]},v))}),o.jsx(me,{onClick:()=>p(y.id),disabled:a||n||g(y.id),className:`w-full rounded-full h-12 text-base font-semibold ${y.popular?"bg-white text-primary hover:bg-white/90":""}`,variant:y.popular?"secondary":"default","data-umami-event":"pricing-plan-click","data-umami-event-plan":y.id,children:a?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):g(y.id)?"Current Plan":m(y.id)})]},y.name))}),o.jsx(abt,{}),o.jsxs("div",{className:"text-center mt-16",children:[o.jsx("p",{className:"text-muted-foreground mb-4"}),o.jsxs("p",{className:"text-sm text-muted-foreground",children:["Need a custom plan?"," ",o.jsx("a",{href:"mailto:contact@academly.ai",className:"text-primary hover:underline",children:"Contact us"})]})]})]})}),o.jsx(Ii,{})]})};var Aq={};(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",l=function(){if(!e.OffscreenCanvas)return!1;try{var B=new OffscreenCanvas(1,1),z=B.getContext("2d");z.fillRect(0,0,1,1);var F=B.transferToImageBitmap();z.createPattern(F,"no-repeat")}catch{return!1}return!0}();function c(){}function u(B){var z=r.exports.Promise,F=z!==void 0?z:e.Promise;return typeof F=="function"?new F(B):(B(c,c),null)}var d=function(B,z){return{transform:function(F){if(B)return F;if(z.has(F))return z.get(F);var G=new OffscreenCanvas(F.width,F.height),Q=G.getContext("2d");return Q.drawImage(F,0,0),z.set(F,G),G},clear:function(){z.clear()}}}(l,new Map),h=function(){var B=Math.floor(16.666666666666668),z,F,G={},Q=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(z=function(ie){var se=Math.random();return G[se]=requestAnimationFrame(function q(L){Q===L||Q+B-1<L?(Q=L,delete G[se],ie()):G[se]=requestAnimationFrame(q)}),se},F=function(ie){G[ie]&&cancelAnimationFrame(G[ie])}):(z=function(ie){return setTimeout(ie,B)},F=function(ie){return clearTimeout(ie)}),{frame:z,cancel:F}}(),f=function(){var B,z,F={};function G(Q){function ie(se,q){Q.postMessage({options:se||{},callback:q})}Q.init=function(q){var L=q.transferControlToOffscreen();Q.postMessage({canvas:L},[L])},Q.fire=function(q,L,Z){if(z)return ie(q,null),z;var J=Math.random().toString(36).slice(2);return z=u(function(W){function X(he){he.data.callback===J&&(delete F[J],Q.removeEventListener("message",X),z=null,d.clear(),Z(),W())}Q.addEventListener("message",X),ie(q,J),F[J]=X.bind(null,{data:{callback:J}})}),z},Q.reset=function(){Q.postMessage({reset:!0});for(var q in F)F[q](),delete F[q]}}return function(){if(B)return B;if(!n&&i){var Q=["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([Q])))}catch(ie){return typeof console<"u"&&typeof console.warn=="function"&&console.warn("🎊 Could not load worker",ie),null}G(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,z){return z?z(B):B}function g(B){return B!=null}function y(B,z,F){return m(B&&g(B[z])?B[z]:p[z],F)}function x(B){return B<0?0:Math.floor(B)}function v(B,z){return Math.floor(Math.random()*(z-B))+B}function b(B){return parseInt(B,16)}function w(B){return B.map(j)}function j(B){var z=String(B).replace(/[^0-9a-f]/gi,"");return z.length<6&&(z=z[0]+z[0]+z[1]+z[1]+z[2]+z[2]),{r:b(z.substring(0,2)),g:b(z.substring(2,4)),b:b(z.substring(4,6))}}function N(B){var z=y(B,"origin",Object);return z.x=y(z,"x",Number),z.y=y(z,"y",Number),z}function C(B){B.width=document.documentElement.clientWidth,B.height=document.documentElement.clientHeight}function A(B){var z=B.getBoundingClientRect();B.width=z.width,B.height=z.height}function E(B){var z=document.createElement("canvas");return z.style.position="fixed",z.style.top="0px",z.style.left="0px",z.style.pointerEvents="none",z.style.zIndex=B,z}function O(B,z,F,G,Q,ie,se,q,L){B.save(),B.translate(z,F),B.rotate(ie),B.scale(G,Q),B.arc(0,0,1,se,q,L),B.restore()}function $(B){var z=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:-z+(.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 T(B,z){z.x+=Math.cos(z.angle2D)*z.velocity+z.drift,z.y+=Math.sin(z.angle2D)*z.velocity+z.gravity,z.velocity*=z.decay,z.flat?(z.wobble=0,z.wobbleX=z.x+10*z.scalar,z.wobbleY=z.y+10*z.scalar,z.tiltSin=0,z.tiltCos=0,z.random=1):(z.wobble+=z.wobbleSpeed,z.wobbleX=z.x+10*z.scalar*Math.cos(z.wobble),z.wobbleY=z.y+10*z.scalar*Math.sin(z.wobble),z.tiltAngle+=.1,z.tiltSin=Math.sin(z.tiltAngle),z.tiltCos=Math.cos(z.tiltAngle),z.random=Math.random()+2);var F=z.tick++/z.totalTicks,G=z.x+z.random*z.tiltCos,Q=z.y+z.random*z.tiltSin,ie=z.wobbleX+z.random*z.tiltCos,se=z.wobbleY+z.random*z.tiltSin;if(B.fillStyle="rgba("+z.color.r+", "+z.color.g+", "+z.color.b+", "+(1-F)+")",B.beginPath(),a&&z.shape.type==="path"&&typeof z.shape.path=="string"&&Array.isArray(z.shape.matrix))B.fill(H(z.shape.path,z.shape.matrix,z.x,z.y,Math.abs(ie-G)*.1,Math.abs(se-Q)*.1,Math.PI/10*z.wobble));else if(z.shape.type==="bitmap"){var q=Math.PI/10*z.wobble,L=Math.abs(ie-G)*.1,Z=Math.abs(se-Q)*.1,J=z.shape.bitmap.width*z.scalar,W=z.shape.bitmap.height*z.scalar,X=new DOMMatrix([Math.cos(q)*L,Math.sin(q)*L,-Math.sin(q)*Z,Math.cos(q)*Z,z.x,z.y]);X.multiplySelf(new DOMMatrix(z.shape.matrix));var he=B.createPattern(d.transform(z.shape.bitmap),"no-repeat");he.setTransform(X),B.globalAlpha=1-F,B.fillStyle=he,B.fillRect(z.x-J/2,z.y-W/2,J,W),B.globalAlpha=1}else if(z.shape==="circle")B.ellipse?B.ellipse(z.x,z.y,Math.abs(ie-G)*z.ovalScalar,Math.abs(se-Q)*z.ovalScalar,Math.PI/10*z.wobble,0,2*Math.PI):O(B,z.x,z.y,Math.abs(ie-G)*z.ovalScalar,Math.abs(se-Q)*z.ovalScalar,Math.PI/10*z.wobble,0,2*Math.PI);else if(z.shape==="star")for(var P=Math.PI/2*3,oe=4*z.scalar,Y=8*z.scalar,R=z.x,I=z.y,U=5,re=Math.PI/U;U--;)R=z.x+Math.cos(P)*Y,I=z.y+Math.sin(P)*Y,B.lineTo(R,I),P+=re,R=z.x+Math.cos(P)*oe,I=z.y+Math.sin(P)*oe,B.lineTo(R,I),P+=re;else B.moveTo(Math.floor(z.x),Math.floor(z.y)),B.lineTo(Math.floor(z.wobbleX),Math.floor(Q)),B.lineTo(Math.floor(ie),Math.floor(se)),B.lineTo(Math.floor(G),Math.floor(z.wobbleY));return B.closePath(),B.fill(),z.tick<z.totalTicks}function M(B,z,F,G,Q){var ie=z.slice(),se=B.getContext("2d"),q,L,Z=u(function(J){function W(){q=L=null,se.clearRect(0,0,G.width,G.height),d.clear(),Q(),J()}function X(){n&&!(G.width===s.width&&G.height===s.height)&&(G.width=B.width=s.width,G.height=B.height=s.height),!G.width&&!G.height&&(F(B),G.width=B.width,G.height=B.height),se.clearRect(0,0,G.width,G.height),ie=ie.filter(function(he){return T(se,he)}),ie.length?q=h.frame(X):W()}q=h.frame(X),L=W});return{addFettis:function(J){return ie=ie.concat(J),Z},canvas:B,promise:Z,reset:function(){q&&h.cancel(q),L&&L()}}}function k(B,z){var F=!B,G=!!y(z||{},"resize"),Q=!1,ie=y(z,"disableForReducedMotion",Boolean),se=i&&!!y(z||{},"useWorker"),q=se?f():null,L=F?C:A,Z=B&&q?!!B.__confetti_initialized:!1,J=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion)").matches,W;function X(P,oe,Y){for(var R=y(P,"particleCount",x),I=y(P,"angle",Number),U=y(P,"spread",Number),re=y(P,"startVelocity",Number),ue=y(P,"decay",Number),ae=y(P,"gravity",Number),ge=y(P,"drift",Number),we=y(P,"colors",w),ce=y(P,"ticks",Number),ne=y(P,"shapes"),fe=y(P,"scalar"),be=!!y(P,"flat"),xe=N(P),_e=R,ke=[],$e=B.width*xe.x,Te=B.height*xe.y;_e--;)ke.push($({x:$e,y:Te,angle:I,spread:U,startVelocity:re,color:we[_e%we.length],shape:ne[v(0,ne.length)],ticks:ce,decay:ue,gravity:ae,drift:ge,scalar:fe,flat:be}));return W?W.addFettis(ke):(W=M(B,ke,L,oe,Y),W.promise)}function he(P){var oe=ie||y(P,"disableForReducedMotion",Boolean),Y=y(P,"zIndex",Number);if(oe&&J)return u(function(re){re()});F&&W?B=W.canvas:F&&!B&&(B=E(Y),document.body.appendChild(B)),G&&!Z&&L(B);var R={width:B.width,height:B.height};q&&!Z&&q.init(B),Z=!0,q&&(B.__confetti_initialized=!0);function I(){if(q){var re={getBoundingClientRect:function(){if(!F)return B.getBoundingClientRect()}};L(re),q.postMessage({resize:{width:re.width,height:re.height}});return}R.width=R.height=null}function U(){W=null,G&&(Q=!1,e.removeEventListener("resize",I)),F&&B&&(document.body.contains(B)&&document.body.removeChild(B),B=null,Z=!1)}return G&&!Q&&(Q=!0,e.addEventListener("resize",I,!1)),q?q.fire(P,R,U):X(P,R,U)}return he.reset=function(){q&&q.reset(),W&&W.reset()},he}var D;function K(){return D||(D=k(null,{useWorker:!0,resize:!0})),D}function H(B,z,F,G,Q,ie,se){var q=new Path2D(B),L=new Path2D;L.addPath(q,new DOMMatrix(z));var Z=new Path2D;return Z.addPath(L,new DOMMatrix([Math.cos(se)*Q,Math.sin(se)*Q,-Math.sin(se)*ie,Math.cos(se)*ie,F,G])),Z}function ee(B){if(!a)throw new Error("path confetti are not supported in this browser");var z,F;typeof B=="string"?z=B:(z=B.path,F=B.matrix);var G=new Path2D(z),Q=document.createElement("canvas"),ie=Q.getContext("2d");if(!F){for(var se=1e3,q=se,L=se,Z=0,J=0,W,X,he=0;he<se;he+=2)for(var P=0;P<se;P+=2)ie.isPointInPath(G,he,P,"nonzero")&&(q=Math.min(q,he),L=Math.min(L,P),Z=Math.max(Z,he),J=Math.max(J,P));W=Z-q,X=J-L;var oe=10,Y=Math.min(oe/W,oe/X);F=[Y,0,0,Y,-Math.round(W/2+q)*Y,-Math.round(X/2+L)*Y]}return{type:"path",path:z,matrix:F}}function V(B){var z,F=1,G="#000000",Q='"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"?z=B:(z=B.text,F="scalar"in B?B.scalar:F,Q="fontFamily"in B?B.fontFamily:Q,G="color"in B?B.color:G);var ie=10*F,se=""+ie+"px "+Q,q=new OffscreenCanvas(ie,ie),L=q.getContext("2d");L.font=se;var Z=L.measureText(z),J=Math.ceil(Z.actualBoundingBoxRight+Z.actualBoundingBoxLeft),W=Math.ceil(Z.actualBoundingBoxAscent+Z.actualBoundingBoxDescent),X=2,he=Z.actualBoundingBoxLeft+X,P=Z.actualBoundingBoxAscent+X;J+=X+X,W+=X+X,q=new OffscreenCanvas(J,W),L=q.getContext("2d"),L.font=se,L.fillStyle=G,L.fillText(z,he,P);var oe=1/F;return{type:"bitmap",bitmap:q.transferToImageBitmap(),matrix:[oe,0,0,oe,-J*oe/2,-W*oe/2]}}r.exports=function(){return K().apply(this,arguments)},r.exports.reset=function(){K().reset()},r.exports.create=k,r.exports.shapeFromPath=ee,r.exports.shapeFromText=V})(function(){return typeof window<"u"?window:typeof self<"u"?self:this||{}}(),Aq,!1);const fbt=Aq.exports;Aq.exports.create;const tne={pro:"Pro",author:"Author",lifetime:"Lifetime"},pbt=()=>{const{userProfile:t,refreshProfile:e}=Ht(),[r]=uj(),n=r.get("upgraded")==="true",[s,i]=S.useState(n),[a,l]=S.useState(0),c=S.useMemo(()=>{const d=t==null?void 0:t.plan;return d&&tne[d]?tne[d]:"Premium"},[t==null?void 0:t.plan]);S.useEffect(()=>{if(!n||!s)return;if(a>=10){i(!1);return}const d=setTimeout(async()=>{await(e==null?void 0:e()),l(h=>h+1)},1500);return()=>clearTimeout(d)},[n,s,a,e]),S.useEffect(()=>{s||fbt({particleCount:100,spread:70,origin:{y:.6}})},[s]),S.useEffect(()=>{const d=["pro","author","lifetime"];n&&(t!=null&&t.plan)&&d.includes(t.plan)&&i(!1)},[t==null?void 0:t.plan,n]);const u=o.jsx(Di,{title:"Subscription Confirmed | Academly.ai",description:"Private page on Academly.ai.",canonical:"https://academly.ai/subscription/success",noIndex:!0});return s?o.jsxs("div",{className:"min-h-screen bg-background",children:[u,o.jsx(Ri,{}),o.jsx("section",{className:"relative pt-32 pb-20",children:o.jsx(Kn,{className:"relative",children:o.jsxs("div",{className:"text-center max-w-2xl mx-auto",children:[o.jsx("div",{className:"w-20 h-20 bg-primary/10 rounded-full flex items-center justify-center mx-auto mb-6",children:o.jsx(Xe,{className:"h-10 w-10 text-primary animate-spin"})}),o.jsx("h1",{className:"text-3xl font-bold text-foreground mb-4",children:"Finalizing your upgrade..."}),o.jsx("p",{className:"text-muted-foreground",children:"Just a moment while we activate your new plan."})]})})}),o.jsx(Ii,{})]}):o.jsxs("div",{className:"min-h-screen bg-background",children:[u,o.jsx(Ri,{}),o.jsxs("section",{className:"relative pt-32 pb-20",children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-transparent to-transparent"}),o.jsx(Kn,{className:"relative",children:o.jsxs("div",{className:"text-center max-w-2xl mx-auto",children:[o.jsx("div",{className:"w-20 h-20 bg-primary/10 rounded-full flex items-center justify-center mx-auto mb-6",children:o.jsx(uc,{className:"h-10 w-10 text-primary"})}),o.jsxs("h1",{className:"text-4xl md:text-5xl font-bold text-foreground mb-4",children:["Welcome to ",o.jsx("span",{className:"text-primary",children:c}),"!"]}),o.jsx("p",{className:"text-xl text-muted-foreground mb-8",children:"Your subscription is now active. You have full access to all premium features."}),o.jsxs("div",{className:"bg-card border border-border rounded-2xl p-6 mb-8",children:[o.jsxs("div",{className:"flex items-center justify-center gap-2 mb-4",children:[o.jsx(Sr,{className:"h-5 w-5 text-primary"}),o.jsx("span",{className:"font-semibold",children:"Your Student Points have been credited"})]}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Check your dashboard to see your updated balance."})]}),o.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[o.jsx(me,{asChild:!0,size:"lg",className:"rounded-full",children:o.jsx(Nt,{to:"/dashboard",children:"Go to Dashboard"})}),o.jsx(me,{asChild:!0,variant:"outline",size:"lg",className:"rounded-full",children:o.jsx(Nt,{to:"/summary",children:"Create Your First Summary"})})]})]})})]}),o.jsx(Ii,{})]})},mbt=()=>o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{title:"Checkout Cancelled | Academly.ai",description:"Private page on Academly.ai.",canonical:"https://academly.ai/subscription/cancel",noIndex:!0}),o.jsx(Ri,{}),o.jsxs("section",{className:"relative pt-32 pb-20",children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-muted/50 via-transparent to-transparent"}),o.jsx(Kn,{className:"relative",children:o.jsxs("div",{className:"text-center max-w-2xl mx-auto",children:[o.jsx("div",{className:"w-20 h-20 bg-muted rounded-full flex items-center justify-center mx-auto mb-6",children:o.jsx(HOe,{className:"h-10 w-10 text-muted-foreground"})}),o.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-foreground mb-4",children:"Checkout Cancelled"}),o.jsx("p",{className:"text-xl text-muted-foreground mb-8",children:"No worries! Your checkout was cancelled and you haven't been charged."}),o.jsx("div",{className:"bg-card border border-border rounded-2xl p-6 mb-8",children:o.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."})}),o.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[o.jsx(me,{asChild:!0,size:"lg",className:"rounded-full",children:o.jsxs(Nt,{to:"/pricing",children:[o.jsx(Kg,{className:"mr-2 h-4 w-4"}),"Back to Pricing"]})}),o.jsx(me,{asChild:!0,variant:"outline",size:"lg",className:"rounded-full",children:o.jsx(Nt,{to:"/dashboard",children:"Go to Dashboard"})})]})]})})]}),o.jsx(Ii,{})]}),gbt=[{icon:jr,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:SN,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:nr,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:sv,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"}],xbt=[{step:"01",icon:cf,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:Sr,title:"AI Analysis",description:"Our AI analyzes your documents, extracting key information, citations, and relevant content for your research."},{step:"03",icon:ko,title:"Export & Integrate",description:"Download your summaries, citations, and generated content in various formats ready for your thesis."}],ybt={"@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"},vbt=()=>o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{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:ybt}),o.jsx(Ri,{}),o.jsxs("section",{className:"relative pt-32 pb-32 overflow-visible",children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-primary/3 to-transparent pointer-events-none"}),o.jsx("div",{className:"absolute -bottom-32 left-0 right-0 h-64 bg-gradient-to-b from-primary/3 to-transparent pointer-events-none"}),o.jsx("div",{className:"absolute top-20 left-1/4 w-72 h-72 bg-primary/20 rounded-full blur-3xl pointer-events-none"}),o.jsx("div",{className:"absolute top-40 right-1/4 w-96 h-96 bg-purple-500/10 rounded-full blur-3xl pointer-events-none"}),o.jsx(Kn,{className:"relative",children:o.jsxs("div",{className:"text-center max-w-4xl mx-auto",children:[o.jsxs("h1",{className:"text-4xl md:text-5xl lg:text-6xl font-bold text-foreground mb-6",children:["Your Complete",o.jsx("span",{className:"text-primary",children:" Research Toolkit"})]}),o.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."})]})})]}),o.jsx("section",{className:"py-20",children:o.jsxs(Kn,{children:[o.jsxs("div",{className:"text-center mb-16",children:[o.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4",children:"Powerful Features"}),o.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Everything you need to write better academic papers, faster."})]}),o.jsx("div",{className:"grid md:grid-cols-2 gap-8",children:gbt.map((t,e)=>{const r=t.icon;return o.jsxs(Zu.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:[o.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"}),o.jsx("div",{className:`w-16 h-16 rounded-2xl ${t.color} flex items-center justify-center mb-6`,children:o.jsx(r,{className:"w-8 h-8"})}),o.jsx("h3",{className:"text-2xl font-bold text-foreground mb-3",children:t.title}),o.jsx("p",{className:"text-muted-foreground mb-6",children:t.description}),o.jsx("ul",{className:"space-y-3",children:t.highlights.map((n,s)=>o.jsxs("li",{className:"flex items-center gap-3",children:[o.jsx(uc,{className:"w-5 h-5 text-primary flex-shrink-0"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:n})]},s))})]},e)})})]})}),o.jsx("section",{className:"py-20 bg-muted/30",children:o.jsxs(Kn,{children:[o.jsxs("div",{className:"text-center mb-16",children:[o.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4",children:"Simple 3-Step Workflow"}),o.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Get started in minutes. No complex setup required."})]}),o.jsx("div",{className:"grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",children:xbt.map((t,e)=>{const r=t.icon;return o.jsxs("div",{className:"text-center",children:[o.jsxs("div",{className:"relative mb-6",children:[o.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center mx-auto",children:o.jsx(r,{className:"w-10 h-10 text-primary"})}),o.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})]}),o.jsx("h3",{className:"text-xl font-bold text-foreground mb-3",children:t.title}),o.jsx("p",{className:"text-muted-foreground",children:t.description})]},e)})})]})}),o.jsx("section",{className:"py-20",children:o.jsx(Kn,{children:o.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:[o.jsx("div",{className:"absolute inset-0 bg-[url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGZpbGw9IiNmZmYiIGZpbGwtb3BhY2l0eT0iMC4xIj48cGF0aCBkPSJNMzYgMzRjMC0yIDItNCAyLTRzLTItMi00LTJsLTIgMnYyaDJ2Mmw0LTR6Ii8+PC9nPjwvZz48L3N2Zz4=')] opacity-30"}),o.jsxs("div",{className:"relative",children:[o.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-primary-foreground mb-4",children:"Ready to Transform Your Research?"}),o.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."}),o.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 justify-center",children:[o.jsx(me,{asChild:!0,size:"lg",className:"rounded-full h-14 px-8 text-base font-semibold bg-white text-primary hover:bg-white/90",children:o.jsx(Nt,{to:"/login",children:"Get Started Free"})}),o.jsx(me,{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:o.jsx(Nt,{to:"/pricing",children:"View Pricing"})})]})]})]})})}),o.jsx(Ii,{})]});var t1e="Toggle",Tq=S.forwardRef((t,e)=>{const{pressed:r,defaultPressed:n,onPressedChange:s,...i}=t,[a,l]=ca({prop:r,onChange:s,defaultProp:n??!1,caller:t1e});return o.jsx(ft.button,{type:"button","aria-pressed":a,"data-state":a?"on":"off","data-disabled":t.disabled?"":void 0,...i,ref:e,onClick:Qe(t.onClick,()=>{t.disabled||l(!a)})})});Tq.displayName=t1e;var r1e=Tq,gg="ToggleGroup",[n1e,CWt]=Vs(gg,[fj]),s1e=fj(),Pq=ve.forwardRef((t,e)=>{const{type:r,...n}=t;if(r==="single"){const s=n;return o.jsx(bbt,{...s,ref:e})}if(r==="multiple"){const s=n;return o.jsx(wbt,{...s,ref:e})}throw new Error(`Missing prop \`type\` expected on \`${gg}\``)});Pq.displayName=gg;var[i1e,a1e]=n1e(gg),bbt=ve.forwardRef((t,e)=>{const{value:r,defaultValue:n,onValueChange:s=()=>{},...i}=t,[a,l]=ca({prop:r,defaultProp:n??"",onChange:s,caller:gg});return o.jsx(i1e,{scope:t.__scopeToggleGroup,type:"single",value:ve.useMemo(()=>a?[a]:[],[a]),onItemActivate:l,onItemDeactivate:ve.useCallback(()=>l(""),[l]),children:o.jsx(o1e,{...i,ref:e})})}),wbt=ve.forwardRef((t,e)=>{const{value:r,defaultValue:n,onValueChange:s=()=>{},...i}=t,[a,l]=ca({prop:r,defaultProp:n??[],onChange:s,caller:gg}),c=ve.useCallback(d=>l((h=[])=>[...h,d]),[l]),u=ve.useCallback(d=>l((h=[])=>h.filter(f=>f!==d)),[l]);return o.jsx(i1e,{scope:t.__scopeToggleGroup,type:"multiple",value:a,onItemActivate:c,onItemDeactivate:u,children:o.jsx(o1e,{...i,ref:e})})});Pq.displayName=gg;var[jbt,Sbt]=n1e(gg),o1e=ve.forwardRef((t,e)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:s=!0,orientation:i,dir:a,loop:l=!0,...c}=t,u=s1e(r),d=Tv(a),h={role:"group",dir:d,...c};return o.jsx(jbt,{scope:r,rovingFocus:s,disabled:n,children:s?o.jsx(m9,{asChild:!0,...u,orientation:i,dir:d,loop:l,children:o.jsx(ft.div,{...h,ref:e})}):o.jsx(ft.div,{...h,ref:e})})}),HR="ToggleGroupItem",l1e=ve.forwardRef((t,e)=>{const r=a1e(HR,t.__scopeToggleGroup),n=Sbt(HR,t.__scopeToggleGroup),s=s1e(t.__scopeToggleGroup),i=r.value.includes(t.value),a=n.disabled||t.disabled,l={...t,pressed:i,disabled:a},c=ve.useRef(null);return n.rovingFocus?o.jsx(g9,{asChild:!0,...s,focusable:!a,active:i,ref:c,children:o.jsx(rne,{...l,ref:e})}):o.jsx(rne,{...l,ref:e})});l1e.displayName=HR;var rne=ve.forwardRef((t,e)=>{const{__scopeToggleGroup:r,value:n,...s}=t,i=a1e(HR,r),a={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},l=i.type==="single"?a:void 0;return o.jsx(Tq,{...l,...s,ref:e,onPressedChange:c=>{c?i.onItemActivate(n):i.onItemDeactivate(n)}})}),c1e=Pq,u1e=l1e;const d1e=_f("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"}}),_bt=S.forwardRef(({className:t,variant:e,size:r,...n},s)=>o.jsx(r1e,{ref:s,className:Pe(d1e({variant:e,size:r,className:t})),...n}));_bt.displayName=r1e.displayName;const h1e=S.createContext({size:"default",variant:"default"}),Tj=S.forwardRef(({className:t,variant:e,size:r,children:n,...s},i)=>o.jsx(c1e,{ref:i,className:Pe("flex items-center justify-center gap-1",t),...s,children:o.jsx(h1e.Provider,{value:{variant:e,size:r},children:n})}));Tj.displayName=c1e.displayName;const nu=S.forwardRef(({className:t,children:e,variant:r,size:n,...s},i)=>{const a=S.useContext(h1e);return o.jsx(u1e,{ref:i,className:Pe(d1e({variant:a.variant||r,size:a.size||n}),t),...s,children:e})});nu.displayName=u1e.displayName;const Nbt="https://nqibmbtqcjucktqcreob.supabase.co",kbt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5xaWJtYnRxY2p1Y2t0cWNyZW9iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1NTk5MTAsImV4cCI6MjA3MDEzNTkxMH0.UnFk-GqYCZtlkXNlxyHUTaFAnS6Q4hIgDgWKANrxEHg";function Cbt(){const{toast:t}=Bn(),[e,r]=S.useState("EN"),[n,s]=S.useState(""),[i,a]=S.useState(""),[l,c]=S.useState(!1),[u,d]=S.useState([]),[h,f]=S.useState(null),[p,m]=S.useState(!1),g=b=>{navigator.clipboard.writeText(b).then(()=>{t({title:"Copied!",description:"Copied to clipboard."})})},y=async()=>{if(n.trim()){c(!0),m(!1),f(null);try{const b=await fetch(`${Nbt}/functions/v1/demo-topic-ideas`,{method:"POST",headers:{"Content-Type":"application/json",apikey:kbt},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 j=(w.suggestions||[]).map((N,C)=>{var A;return{id:((A=crypto.randomUUID)==null?void 0:A.call(crypto))||String(C),title:N.title,research_questions:N.research_questions??N.researchQuestions??[],method:N.method,relevance:N.relevance,sources:Array.isArray(N.sources)?N.sources:[]}});d(j)}catch(b){console.error(b),t({title:"Error",description:"Generation failed. Please try again.",variant:"destructive"})}finally{c(!1)}}},x=b=>{f(b),setTimeout(()=>{var w;(w=document.getElementById("selected-topic"))==null||w.scrollIntoView({behavior:"smooth",block:"start"})},50)},v=b=>{var j;let w=`${b.title}

Research Questions:
${b.research_questions.map((N,C)=>`${C+1}. ${N}`).join(`
`)}

Method:
${b.method}

Relevance:
${b.relevance}`;return(j=b.sources)!=null&&j.length&&(w+=`

Initial Sources:
${b.sources.map((N,C)=>`${C+1}. ${N.title}${N.doi?` (DOI: ${N.doi})`:""}${N.isbn?` (ISBN: ${N.isbn})`:""}`).join(`
`)}`),w};return o.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[o.jsx(Di,{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"}),o.jsx(Ri,{}),o.jsxs("section",{className:"relative overflow-hidden pb-14 pt-32 md:pb-16",children:[o.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 -z-10 mx-auto grid h-[520px] w-full grid-cols-2 -space-x-52 overflow-hidden opacity-20 md:opacity-25",children:[o.jsx("div",{className:"h-[320px] blur-[106px] bg-gradient-to-br from-primary to-purple-400"}),o.jsx("div",{className:"h-[260px] blur-[106px] bg-gradient-to-r from-cyan-400 to-sky-300"})]}),o.jsxs("div",{className:"relative mx-auto max-w-4xl px-6 text-center",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-primary",children:"Free topic generator"}),o.jsx("h1",{className:"mt-5 text-4xl font-bold tracking-tight text-foreground md:text-5xl lg:text-6xl",children:"Find a thesis topic worth researching."}),o.jsx("p",{className:"mx-auto mt-6 max-w-2xl text-base leading-7 text-muted-foreground md:text-lg",children:"Turn a broad idea into structured thesis directions with research questions, suitable methods and academic relevance. No account required."}),o.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"3 free generations per day."})]})]}),o.jsxs("main",{className:"flex-1 w-full",children:[o.jsx("section",{className:"pb-16 pt-6 md:pb-20",children:o.jsx("div",{className:"mx-auto w-full max-w-[1180px] px-5 sm:px-6 lg:px-8",children:o.jsxs("div",{className:"grid gap-6 lg:grid-cols-[0.78fr_1.22fr]",children:[o.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card p-6 shadow-sm md:p-7",children:[o.jsxs("div",{className:"mb-6 flex items-start gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(dd,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-base font-semibold text-foreground",children:"Topic Generator"}),o.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Start with a broad idea and add context if useful."})]})]}),o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-foreground",children:"Topic idea"}),o.jsx(Ue,{placeholder:"e.g. AI in Education",value:n,onChange:b=>s(b.target.value),className:"h-12 rounded-xl border-border/80 bg-background px-4 text-sm shadow-sm"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Context ",o.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),o.jsx(lr,{placeholder:"Program, scope, population, methodology or context...",value:i,onChange:b=>a(b.target.value),rows:5,className:"resize-none rounded-xl border-border/80 bg-background px-4 py-3 text-sm shadow-sm"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"mb-2 block text-xs font-medium text-foreground",children:"Output language"}),o.jsxs(Tj,{type:"single",value:e,onValueChange:b=>b&&r(b),className:"inline-flex rounded-xl border border-border/80 bg-background p-1 shadow-sm",children:[o.jsx(nu,{value:"DE",className:"h-9 rounded-lg px-5 text-xs",children:"DE"}),o.jsx(nu,{value:"EN",className:"h-9 rounded-lg px-5 text-xs",children:"EN"})]})]}),o.jsx(me,{onClick:y,disabled:!n.trim()||l,className:"h-12 w-full rounded-xl text-sm font-semibold shadow-sm",children:l?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Sr,{className:"mr-2 h-4 w-4"}),"Generate Suggestions"]})}),o.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Each generation returns structured topic directions you can review, copy or continue with in Academly."})]})]}),o.jsx("div",{className:"flex min-h-[430px] items-center justify-center rounded-[26px] border border-border/70 bg-background p-6 shadow-sm md:p-8",children:u.length===0&&!l&&!p?o.jsxs("div",{className:"max-w-md text-center",children:[o.jsx("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:o.jsx(Sr,{className:"h-6 w-6"})}),o.jsx("h3",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground",children:"Your thesis directions will appear here."}),o.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:"Add a topic idea on the left. Academly will structure it into research questions, a suitable method and a clear academic rationale."})]}):l?o.jsxs("div",{className:"text-center",children:[o.jsx(Xe,{className:"mx-auto h-7 w-7 animate-spin text-primary"}),o.jsx("p",{className:"mt-4 text-sm font-medium text-foreground",children:"Building topic suggestions..."}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Structuring questions, methods and relevance."})]}):o.jsxs("div",{className:"w-full",children:[o.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Topic suggestions"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Structured directions based on your idea."})]}),o.jsxs("span",{className:"rounded-full bg-primary/10 px-2.5 py-1 text-[10px] font-semibold text-primary",children:[u.length," generated"]})]}),o.jsx("div",{className:"space-y-4",children:u.slice(0,2).map((b,w)=>o.jsx("div",{className:"rounded-2xl border border-border/70 bg-card p-5",children:o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsxs("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-xs font-bold text-primary",children:["0",w+1]}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h3",{className:"text-base font-semibold leading-6 text-foreground",children:b.title}),b.research_questions[0]&&o.jsxs("div",{className:"mt-4",children:[o.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-xs font-semibold text-primary",children:[o.jsx(TE,{className:"h-3.5 w-3.5"}),"Research question"]}),o.jsx("p",{className:"text-sm leading-6 text-foreground/80",children:b.research_questions[0]})]}),o.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-xs font-semibold text-primary",children:[o.jsx(SN,{className:"h-3.5 w-3.5"}),"Method"]}),o.jsx("p",{className:"line-clamp-3 text-xs leading-5 text-muted-foreground",children:b.method})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1.5 flex items-center gap-2 text-xs font-semibold text-primary",children:[o.jsx(Sr,{className:"h-3.5 w-3.5"}),"Relevance"]}),o.jsx("p",{className:"line-clamp-3 text-xs leading-5 text-muted-foreground",children:b.relevance})]})]}),o.jsxs("div",{className:"mt-4 flex gap-2 border-t border-border/60 pt-4",children:[o.jsxs(me,{size:"sm",onClick:()=>x(b),className:"h-9 rounded-xl px-4",children:["View structure",o.jsx(As,{className:"ml-1.5 h-3.5 w-3.5"})]}),o.jsx(me,{size:"sm",variant:"outline",onClick:()=>g(v(b)),className:"h-9 w-9 rounded-xl p-0","aria-label":"Copy suggestion",children:o.jsx(ws,{className:"h-3.5 w-3.5"})})]})]})]})},b.id))})]})})]})})}),p&&o.jsx("section",{className:"pb-16",children:o.jsx("div",{className:"mx-auto max-w-3xl px-5 sm:px-6",children:o.jsxs("div",{className:"rounded-2xl border border-amber-500/25 bg-amber-500/[0.05] p-7 md:p-8",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx(sg,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"}),o.jsx("h3",{className:"text-lg font-bold text-amber-900 dark:text-amber-200",children:"Daily limit reached"})]}),o.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."}),o.jsx(me,{asChild:!0,className:"h-12 rounded-xl px-8",children:o.jsxs(Nt,{to:"/login",children:["Get started free ",o.jsx(As,{className:"h-4 w-4 ml-2"})]})})]})})}),h&&o.jsx("section",{className:"pb-20 pt-4",children:o.jsx("div",{className:"mx-auto max-w-4xl px-5 sm:px-6",children:o.jsx("div",{id:"selected-topic",className:"rounded-[26px] border border-border/70 bg-card shadow-sm",children:o.jsxs("div",{className:"p-7 md:p-9",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[o.jsx("div",{className:"rounded-xl bg-primary/10 p-2.5 text-primary",children:o.jsx(nr,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-xl font-bold text-foreground",children:"Your Topic Structure"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Based on your selected topic idea"})]})]}),o.jsxs("div",{className:"space-y-6 rounded-2xl border border-border/70 bg-background p-6 text-foreground md:p-8",children:[o.jsx("h3",{className:"text-2xl font-bold",children:h.title}),h.research_questions.length>0&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-base font-semibold text-primary mb-3",children:"Research Questions"}),o.jsx("ul",{className:"space-y-2",children:h.research_questions.map((b,w)=>o.jsxs("li",{className:"flex gap-2 text-sm",children:[o.jsx("span",{className:"text-primary mt-0.5",children:"•"}),o.jsx("span",{className:"leading-relaxed",children:b})]},w))})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-base font-semibold text-primary mb-3",children:"Method"}),o.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:h.method})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-base font-semibold text-primary mb-3",children:"Relevance"}),o.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:h.relevance})]}),h.sources.length>0&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-base font-semibold text-primary mb-3",children:"Sources"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:h.sources.map((b,w)=>o.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))})]})]}),o.jsx("div",{className:"rounded-2xl border border-primary/20 bg-primary/5 p-6 mt-6",children:o.jsxs("p",{className:"text-sm text-foreground leading-relaxed",children:[o.jsx("span",{className:"font-semibold",children:"Want to continue with this topic?"}),o.jsx("br",{}),"Sign up free to generate a full outline, theory chapter, and methodology."]})}),o.jsxs("div",{className:"flex flex-wrap gap-3 mt-6",children:[o.jsx(me,{asChild:!0,className:"h-12 rounded-xl px-8",children:o.jsxs(Nt,{to:"/login",children:["Continue in Academly ",o.jsx(As,{className:"h-4 w-4 ml-2"})]})}),o.jsxs(me,{variant:"outline",onClick:()=>g(v(h)),className:"h-12 rounded-xl px-6",children:[o.jsx(ws,{className:"h-4 w-4 mr-2"}),"Copy"]})]})]})})})})]}),o.jsx(Ii,{})]})}const Ebt="https://nqibmbtqcjucktqcreob.supabase.co",nne="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5xaWJtYnRxY2p1Y2t0cWNyZW9iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1NTk5MTAsImV4cCI6MjA3MDEzNTkxMH0.UnFk-GqYCZtlkXNlxyHUTaFAnS6Q4hIgDgWKANrxEHg";function Abt(){var O,$,T,M;const{toast:t}=Bn(),[e,r]=S.useState("EN"),[n,s]=S.useState(""),[i,a]=S.useState(""),[l,c]=S.useState(!1),[u,d]=S.useState(null),[h,f]=S.useState(!1),[p,m]=S.useState(!1),[g,y]=S.useState(""),[x,v]=S.useState([]),[b,w]=S.useState(1),j=k=>{navigator.clipboard.writeText(k).then(()=>{t({title:"Copied!",description:"Copied to clipboard."})})},N=async k=>fetch(`${Ebt}/functions/v1/demo-keywords`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${nne}`,apikey:nne},body:JSON.stringify(k)}),C=async k=>{if(k.trim()){m(!0);try{const D=await N({action:"search_literature",keywords:k,language:e});if(D.status===429){f(!0);return}const K=await D.json();if(!D.ok||K.error)throw new Error(K.error||"Search failed");v(K.results||[]),w(1)}catch(D){console.error(D),t({title:"Error",description:"Literature search failed.",variant:"destructive"})}finally{m(!1)}}},A=async()=>{var k,D;if(n.trim()){c(!0),f(!1),v([]);try{const K=await N({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 H=await K.json();if(!K.ok||H.error)throw new Error(H.error||"Request failed");const ee=H.keywords||H;d(ee);const V=((D=(k=ee==null?void 0:ee.keyword_combinations)==null?void 0:k[0])==null?void 0:D.combination)||n;y(V),await C(V)}catch(K){console.error(K),t({title:"Error",description:"Generation failed. Please try again.",variant:"destructive"})}finally{c(!1)}}},E=()=>{var D,K,H,ee;if(!u)return;const k=[];(D=u.keyword_combinations)!=null&&D.length&&(k.push("Search Combinations:"),u.keyword_combinations.forEach(V=>k.push(`- ${V.combination} — ${V.purpose}`))),(K=u.known_authors)!=null&&K.length&&(k.push(`
Known Authors:`),u.known_authors.forEach(V=>k.push(`- ${V.name} (${V.relevance})`))),(H=u.known_works)!=null&&H.length&&(k.push(`
Known Works:`),u.known_works.forEach(V=>k.push(`- ${V.title} — ${V.author} (${V.year}): ${V.relevance}`))),(ee=u.database_suggestions)!=null&&ee.length&&(k.push(`
Recommended Databases:`),k.push(u.database_suggestions.join(", "))),u.search_tips&&(k.push(`
Search Tips:`),k.push(u.search_tips)),j(k.join(`
`))};return o.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[o.jsx(Di,{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"}),o.jsx(Ri,{}),o.jsxs("section",{className:"relative overflow-hidden pb-14 pt-32 md:pb-16",children:[o.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 -z-10 mx-auto grid h-[520px] w-full grid-cols-2 -space-x-52 overflow-hidden opacity-20 md:opacity-25",children:[o.jsx("div",{className:"h-[320px] blur-[106px] bg-gradient-to-br from-primary to-purple-400"}),o.jsx("div",{className:"h-[260px] blur-[106px] bg-gradient-to-r from-cyan-400 to-sky-300"})]}),o.jsxs("div",{className:"relative mx-auto max-w-4xl px-6 text-center",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-primary",children:"Free literature search"}),o.jsx("h1",{className:"mt-5 text-4xl font-bold tracking-tight text-foreground md:text-5xl lg:text-6xl",children:"Turn your research question into a better search strategy."}),o.jsx("p",{className:"mx-auto mt-6 max-w-2xl text-base leading-7 text-muted-foreground md:text-lg",children:"Generate search combinations, discover relevant authors and works, and search academic literature from one structured workflow."}),o.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"No account required · 3 free generations per day"})]})]}),o.jsxs("main",{className:"flex-1 w-full",children:[o.jsx("section",{className:"pb-12 pt-6 md:pb-16",children:o.jsx("div",{className:"mx-auto w-full max-w-[1240px] px-5 sm:px-6 lg:px-8",children:o.jsxs("div",{className:"grid gap-6 lg:grid-cols-[0.78fr_1.22fr]",children:[o.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card p-6 shadow-sm md:p-7",children:[o.jsxs("div",{className:"mb-6 flex items-start gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(Ti,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-base font-semibold text-foreground",children:"Literature Search"}),o.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Start with your topic and optional research questions."})]})]}),o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-xs font-medium text-foreground",children:"Title / Topic"}),o.jsx(Ue,{placeholder:"e.g. AI in Education",value:n,onChange:k=>s(k.target.value),className:"h-12 rounded-xl border-border/80 bg-background px-4 text-sm shadow-sm"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("label",{className:"text-xs font-medium text-foreground",children:["Research Questions ",o.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),o.jsx(lr,{placeholder:"One question per line...",value:i,onChange:k=>a(k.target.value),rows:4,className:"resize-none rounded-xl border-border/80 bg-background px-4 py-3 text-sm shadow-sm"})]}),o.jsxs("div",{children:[o.jsx("label",{className:"mb-2 block text-xs font-medium text-foreground",children:"Output language"}),o.jsxs(Tj,{type:"single",value:e,onValueChange:k=>k&&r(k),className:"inline-flex rounded-xl border border-border/80 bg-background p-1 shadow-sm",children:[o.jsx(nu,{value:"DE",className:"h-9 rounded-lg px-5 text-xs",children:"DE"}),o.jsx(nu,{value:"EN",className:"h-9 rounded-lg px-5 text-xs",children:"EN"})]})]}),o.jsx(me,{onClick:A,disabled:!n.trim()||l||p,className:"h-12 w-full rounded-xl text-sm font-semibold shadow-sm",children:l||p?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating & Searching..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Sr,{className:"mr-2 h-4 w-4"}),"Build Search Strategy"]})}),o.jsx("p",{className:"text-xs leading-5 text-muted-foreground",children:"Academly combines keyword planning with a direct literature search so you can move from topic to sources without switching tools."})]})]}),o.jsx("div",{className:"rounded-[26px] border border-border/70 bg-background p-5 shadow-sm md:p-6",children:!u&&!l&&!p&&!h?o.jsx("div",{className:"flex min-h-[430px] items-center justify-center",children:o.jsxs("div",{className:"max-w-md text-center",children:[o.jsx("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:o.jsx(dd,{className:"h-6 w-6"})}),o.jsx("h3",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground",children:"Your search strategy will appear here."}),o.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:"Academly turns your topic into search combinations, suggested authors, relevant works and database directions before searching the literature."})]})}):l||p&&!u?o.jsx("div",{className:"flex min-h-[430px] items-center justify-center text-center",children:o.jsxs("div",{children:[o.jsx(Xe,{className:"mx-auto h-7 w-7 animate-spin text-primary"}),o.jsx("p",{className:"mt-4 text-sm font-medium text-foreground",children:"Building your search strategy..."}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Generating terms and checking academic literature."})]})}):u?o.jsxs("div",{children:[o.jsxs("div",{className:"mb-5 flex items-center justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Search strategy"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Suggested terms and starting points for your literature review."})]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:E,className:"h-9 rounded-xl px-3",children:[o.jsx(ws,{className:"mr-2 h-3.5 w-3.5"}),"Copy all"]})]}),o.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsx(dd,{className:"h-4 w-4 text-primary"}),o.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Search combinations"})]}),o.jsx("div",{className:"space-y-2",children:(O=u.keyword_combinations)==null?void 0:O.slice(0,3).map((k,D)=>o.jsxs("button",{type:"button",onClick:()=>j(k.combination),className:"block w-full rounded-xl border border-border/60 bg-background p-3 text-left transition hover:border-primary/20",children:[o.jsx("code",{className:"block text-xs text-foreground",children:k.combination}),o.jsx("span",{className:"mt-1 block text-[11px] leading-4 text-muted-foreground",children:k.purpose})]},D))})]}),o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsx(nj,{className:"h-4 w-4 text-primary"}),o.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Known authors"})]}),o.jsx("div",{className:"space-y-3",children:($=u.known_authors)==null?void 0:$.slice(0,4).map((k,D)=>o.jsxs("button",{type:"button",onClick:()=>j(k.name),className:"block w-full text-left",children:[o.jsx("span",{className:"block text-sm font-medium text-foreground",children:k.name}),o.jsx("span",{className:"mt-0.5 block text-[11px] leading-4 text-muted-foreground",children:k.relevance})]},D))})]}),o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsx(nr,{className:"h-4 w-4 text-primary"}),o.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Known works"})]}),o.jsx("div",{className:"space-y-3",children:(T=u.known_works)==null?void 0:T.slice(0,3).map((k,D)=>o.jsxs("button",{type:"button",onClick:()=>j(k.title),className:"block w-full text-left",children:[o.jsx("span",{className:"block text-sm font-medium leading-5 text-foreground",children:k.title}),o.jsxs("span",{className:"mt-0.5 block text-[11px] text-muted-foreground",children:[k.author," · ",k.year]})]},D))})]}),o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsx(Ti,{className:"h-4 w-4 text-primary"}),o.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Search direction"})]}),o.jsx("div",{className:"flex flex-wrap gap-2",children:(M=u.database_suggestions)==null?void 0:M.map((k,D)=>o.jsx(kt,{variant:"secondary",className:"rounded-lg",children:k},D))}),u.search_tips&&o.jsx("p",{className:"mt-3 whitespace-pre-wrap text-xs leading-5 text-muted-foreground",children:u.search_tips})]})]})]}):null})]})})}),h&&o.jsx("section",{className:"pb-12",children:o.jsx("div",{className:"mx-auto max-w-3xl px-5 sm:px-6",children:o.jsxs("div",{className:"rounded-2xl border border-amber-500/25 bg-amber-500/[0.05] p-7 md:p-8",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[o.jsx(sg,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"}),o.jsx("h3",{className:"text-lg font-bold text-amber-900 dark:text-amber-200",children:"Daily limit reached"})]}),o.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."}),o.jsx(me,{asChild:!0,className:"h-11 rounded-xl px-6",children:o.jsxs(Nt,{to:"/login",children:["Get started free ",o.jsx(As,{className:"h-4 w-4 ml-2"})]})})]})})}),u&&!h&&o.jsx("section",{className:"pb-20 pt-4",children:o.jsxs("div",{className:"mx-auto w-full max-w-[1240px] px-5 sm:px-6 lg:px-8",children:[o.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-card p-6 shadow-sm md:p-8",children:[o.jsxs("div",{className:"flex flex-col justify-between gap-4 border-b border-border/60 pb-6 md:flex-row md:items-end",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-primary",children:"Academic literature"}),o.jsx("h2",{className:"mt-2 text-2xl font-bold tracking-tight text-foreground md:text-3xl",children:"Search real papers"}),o.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Refine the generated query or search again with your own keywords."})]}),o.jsxs("div",{className:"flex w-full gap-2 md:max-w-xl",children:[o.jsx(Ue,{value:g,onChange:k=>y(k.target.value),placeholder:"Search query...",className:"h-11 flex-1 rounded-xl border-border/80 bg-background text-sm"}),o.jsx(me,{onClick:()=>C(g),disabled:!g.trim()||p,className:"h-11 rounded-xl px-5",children:p?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsxs(o.Fragment,{children:[o.jsx(Ti,{className:"mr-2 h-4 w-4"}),"Search"]})})]})]}),x.length>0?o.jsx("div",{className:"mt-2 divide-y divide-border/60",children:x.slice((b-1)*10,b*10).map((k,D)=>o.jsx("article",{className:"py-6 first:pt-5",children:o.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-start md:justify-between md:gap-8",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("h3",{className:"text-base font-semibold leading-6 text-foreground",children:k.title||"Untitled"}),o.jsxs("p",{className:"mt-1.5 text-xs leading-5 text-muted-foreground",children:[Array.isArray(k.authors)?k.authors.join(", "):k.authors,k.year?` · ${k.year}`:"",k.journal?` · ${k.journal}`:""]}),k.abstract&&o.jsx("p",{className:"mt-3 line-clamp-3 max-w-4xl text-sm leading-6 text-muted-foreground",children:k.abstract}),o.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[k.source&&o.jsx("span",{className:"rounded-lg bg-primary/10 px-2.5 py-1 text-[11px] font-medium text-primary",children:k.source}),k.doi&&o.jsxs("span",{className:"text-[11px] text-muted-foreground",children:["DOI: ",k.doi]})]})]}),(k.url||k.doi)&&o.jsxs("a",{href:k.url||`https://doi.org/${k.doi}`,target:"_blank",rel:"noreferrer",className:"inline-flex shrink-0 items-center gap-1.5 text-sm font-semibold text-primary hover:underline",children:["View source",o.jsx(As,{className:"h-3.5 w-3.5"})]})]})},D))}):!p&&o.jsxs("div",{className:"py-12 text-center",children:[o.jsx(nr,{className:"mx-auto h-6 w-6 text-primary"}),o.jsx("p",{className:"mt-3 text-sm font-medium text-foreground",children:"No literature results yet."}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Adjust the search query and try again."})]}),x.length>10&&o.jsxs("div",{className:"mt-5 flex items-center justify-between border-t border-border/60 pt-5",children:[o.jsx(me,{variant:"outline",size:"sm",className:"rounded-xl",disabled:b===1,onClick:()=>w(k=>k-1),children:"Previous"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Page ",b," of ",Math.ceil(x.length/10)]}),o.jsx(me,{variant:"outline",size:"sm",className:"rounded-xl",disabled:b*10>=x.length,onClick:()=>w(k=>k+1),children:"Next"})]})]}),o.jsxs("div",{className:"mt-6 flex flex-col items-start justify-between gap-4 rounded-2xl border border-border/70 bg-background px-6 py-5 sm:flex-row sm:items-center",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-foreground",children:"Continue your literature review in Academly."}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Search, save and cite academic sources directly in your thesis workspace."})]}),o.jsx(me,{asChild:!0,className:"h-10 shrink-0 rounded-xl px-5 shadow-sm",children:o.jsxs(Nt,{to:"/login?mode=signup",children:["Start Free",o.jsx(As,{className:"ml-2 h-4 w-4"})]})})]})]})})]}),o.jsx(Ii,{})]})}const Tbt=[{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."}],Pbt=[{icon:sfe,title:"GDPR Compliant",description:"Fully compliant with European data protection regulations."},{icon:UM,title:"Security-First",description:"Built by IT security specialists with penetration testing expertise."},{icon:XOe,title:"No Training on User Documents",description:"Your academic work stays yours. We never train AI models on your data."}];function Ibt(){return o.jsxs(o.Fragment,{children:[o.jsx(Di,{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"}),o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Ri,{}),o.jsxs("div",{className:"relative pt-32 pb-16",children:[o.jsxs("div",{"aria-hidden":"true",className:"absolute inset-0 grid grid-cols-2 -space-x-52 opacity-40 dark:opacity-20",children:[o.jsx("div",{className:"blur-[106px] h-56 bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),o.jsx("div",{className:"blur-[106px] h-32 bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),o.jsx(Kn,{children:o.jsx("div",{className:"relative",children:o.jsxs("div",{className:"mx-auto max-w-3xl text-center",children:[o.jsxs("h1",{className:"text-4xl font-bold tracking-tight text-foreground sm:text-5xl md:text-6xl",children:["The team behind"," ",o.jsx("span",{className:"text-primary",children:"Academly"})]}),o.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."})]})})})]}),o.jsx("section",{className:"pb-16",children:o.jsx(Kn,{children:o.jsx("div",{className:"mx-auto max-w-3xl space-y-6",children:Tbt.map((t,e)=>o.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:[o.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:o.jsx("span",{className:"text-2xl sm:text-3xl font-bold text-primary",children:t.name.slice(0,2).toUpperCase()})}),o.jsxs("div",{className:"flex-1",children:[o.jsx("h3",{className:"text-xl sm:text-2xl font-semibold text-foreground group-hover:text-primary transition-colors",children:t.name}),o.jsx("p",{className:"text-sm font-medium text-primary mt-1",children:t.role}),o.jsx("p",{className:"mt-3 text-muted-foreground leading-relaxed",children:t.description})]})]},t.name))})})}),o.jsxs("section",{className:"relative py-20",children:[o.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:[o.jsx("div",{className:"blur-[106px] h-40 bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),o.jsx("div",{className:"blur-[106px] h-24 bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),o.jsx(Kn,{children:o.jsxs("div",{className:"relative",children:[o.jsx("h2",{className:"text-center text-2xl sm:text-3xl font-bold text-foreground mb-12",children:"Your data is safe with us"}),o.jsx("div",{className:"grid gap-8 sm:grid-cols-3",children:Pbt.map((t,e)=>o.jsxs("div",{className:"text-center group animate-fade-in",style:{animationDelay:`${e*100}ms`},children:[o.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:o.jsx(t.icon,{className:"h-8 w-8 text-primary"})}),o.jsx("h3",{className:"font-semibold text-foreground text-lg",children:t.title}),o.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:t.description})]},t.title))})]})})]}),o.jsx(Ii,{})]})]})}var SL="Checkbox",[Rbt,EWt]=Vs(SL),[Obt,Iq]=Rbt(SL);function Mbt(t){const{__scopeCheckbox:e,checked:r,children:n,defaultChecked:s,disabled:i,form:a,name:l,onCheckedChange:c,required:u,value:d="on",internal_do_not_use_render:h}=t,[f,p]=ca({prop:r,defaultProp:s??!1,onChange:c,caller:SL}),[m,g]=S.useState(null),[y,x]=S.useState(null),v=S.useRef(!1),b=m?!!a||!!m.closest("form"):!0,w={checked:f,disabled:i,setChecked:p,control:m,setControl:g,name:l,form:a,value:d,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:Pm(s)?!1:s,isFormControl:b,bubbleInput:y,setBubbleInput:x};return o.jsx(Obt,{scope:e,...w,children:Dbt(h)?h(w):n})}var f1e="CheckboxTrigger",p1e=S.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:r,...n},s)=>{const{control:i,value:a,disabled:l,checked:c,required:u,setControl:d,setChecked:h,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=Iq(f1e,t),g=qt(s,d),y=S.useRef(c);return S.useEffect(()=>{const x=i==null?void 0:i.form;if(x){const v=()=>h(y.current);return x.addEventListener("reset",v),()=>x.removeEventListener("reset",v)}},[i,h]),o.jsx(ft.button,{type:"button",role:"checkbox","aria-checked":Pm(c)?"mixed":c,"aria-required":u,"data-state":v1e(c),"data-disabled":l?"":void 0,disabled:l,value:a,...n,ref:g,onKeyDown:Qe(e,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Qe(r,x=>{h(v=>Pm(v)?!0:!v),m&&p&&(f.current=x.isPropagationStopped(),f.current||x.stopPropagation())})})});p1e.displayName=f1e;var Rq=S.forwardRef((t,e)=>{const{__scopeCheckbox:r,name:n,checked:s,defaultChecked:i,required:a,disabled:l,value:c,onCheckedChange:u,form:d,...h}=t;return o.jsx(Mbt,{__scopeCheckbox:r,checked:s,defaultChecked:i,disabled:l,required:a,onCheckedChange:u,name:n,form:d,value:c,internal_do_not_use_render:({isFormControl:f})=>o.jsxs(o.Fragment,{children:[o.jsx(p1e,{...h,ref:e,__scopeCheckbox:r}),f&&o.jsx(y1e,{__scopeCheckbox:r})]})})});Rq.displayName=SL;var m1e="CheckboxIndicator",g1e=S.forwardRef((t,e)=>{const{__scopeCheckbox:r,forceMount:n,...s}=t,i=Iq(m1e,r);return o.jsx(pi,{present:n||Pm(i.checked)||i.checked===!0,children:o.jsx(ft.span,{"data-state":v1e(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:e,style:{pointerEvents:"none",...t.style}})})});g1e.displayName=m1e;var x1e="CheckboxBubbleInput",y1e=S.forwardRef(({__scopeCheckbox:t,...e},r)=>{const{control:n,hasConsumerStoppedPropagationRef:s,checked:i,defaultChecked:a,required:l,disabled:c,name:u,value:d,form:h,bubbleInput:f,setBubbleInput:p}=Iq(x1e,t),m=qt(r,p),g=W9(i),y=ZW(n);S.useEffect(()=>{const v=f;if(!v)return;const b=window.HTMLInputElement.prototype,j=Object.getOwnPropertyDescriptor(b,"checked").set,N=!s.current;if(g!==i&&j){const C=new Event("click",{bubbles:N});v.indeterminate=Pm(i),j.call(v,Pm(i)?!1:i),v.dispatchEvent(C)}},[f,g,i,s]);const x=S.useRef(Pm(i)?!1:i);return o.jsx(ft.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??x.current,required:l,disabled:c,name:u,value:d,form:h,...e,tabIndex:-1,ref:m,style:{...e.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});y1e.displayName=x1e;function Dbt(t){return typeof t=="function"}function Pm(t){return t==="indeterminate"}function v1e(t){return Pm(t)?"indeterminate":t?"checked":"unchecked"}const aa=S.forwardRef(({className:t,...e},r)=>o.jsx(Rq,{ref:r,className:Pe("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:o.jsx(g1e,{className:Pe("flex items-center justify-center text-current"),children:o.jsx(kr,{className:"h-4 w-4"})})}));aa.displayName=Rq.displayName;function b1e({id:t,checked:e,onCheckedChange:r,required:n=!1,className:s,children:i}){return o.jsxs("div",{className:Pe("flex items-start gap-3",s),children:[o.jsx(aa,{id:t,checked:e,onCheckedChange:a=>r(a===!0),required:n,className:"mt-0.5 flex-shrink-0"}),o.jsx("label",{htmlFor:t,className:"text-sm text-muted-foreground leading-relaxed cursor-pointer select-none",children:i})]})}var Lbt=Object.defineProperty,w1e=t=>{throw TypeError(t)},$bt=(t,e,r)=>e in t?Lbt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wf=(t,e,r)=>$bt(t,typeof e!="symbol"?e+"":e,r),Fbt=(t,e,r)=>e.has(t)||w1e("Cannot "+r),sne=(t,e,r)=>(Fbt(t,e,"read from private field"),e.get(t)),Bbt=(t,e,r)=>e.has(t)?w1e("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r);function zbt(t){return t==null?[]:Array.isArray(t)?t:[t]}var ine=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(!Oq(t[r],e[r]))return!1;return!0},Oq=(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(ine(t)&&ine(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(!Oq(t[i],e[i]))return!1}return!0},Hbt=t=>t!=null&&typeof t=="object",rP=t=>typeof t=="string",dx=t=>typeof t=="function",j1e=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Wbt=t=>Object.prototype.toString.call(t),S1e=Function.prototype.toString,Vbt=S1e.call(Object),qbt=t=>{if(!Hbt(t)||Wbt(t)!="[object Object]"||Ybt(t))return!1;const e=Object.getPrototypeOf(t);if(e===null)return!0;const r=j1e(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&S1e.call(r)==Vbt},Gbt=t=>typeof t=="object"&&t!==null&&"$$typeof"in t&&"props"in t,Kbt=t=>typeof t=="object"&&t!==null&&"__v_isVNode"in t,Ybt=t=>Gbt(t)||Kbt(t),Xbt=t=>t(),Qbt=(...t)=>(...e)=>{t.forEach(function(r){r==null||r(...e)})};function _1e(t,e,...r){var s;if(t in e){const i=e[t];return dx(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,_1e),n}var{floor:AWt,abs:TWt,round:PWt,min:Zbt,max:Jbt,pow:IWt,sign:RWt}=Math,e0t=t=>Number.isNaN(t),t0t=t=>e0t(t)?0:t,r0t=(t,e,r)=>Zbt(Jbt(t0t(t),e),r);function N1e(t){if(!qbt(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]=N1e(s))}return r}var CT=()=>performance.now(),nP,k1e=class{constructor(t){this.onTick=t,Wf(this,"frameId",null),Wf(this,"pausedAtMs",null),Wf(this,"context"),Wf(this,"cancelFrame",()=>{this.frameId!==null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}),Wf(this,"setStartMs",e=>{this.context.startMs=e}),Wf(this,"start",()=>{if(this.frameId!==null)return;const e=CT();this.pausedAtMs!==null?(this.context.startMs+=e-this.pausedAtMs,this.pausedAtMs=null):this.context.startMs=e,this.frameId=requestAnimationFrame(sne(this,nP))}),Wf(this,"pause",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=CT())}),Wf(this,"stop",()=>{this.frameId!==null&&(this.cancelFrame(),this.pausedAtMs=null)}),Bbt(this,nP,e=>{if(this.context.now=e,this.context.deltaMs=e-this.context.startMs,this.onTick(this.context)===!1){this.stop();return}this.frameId=requestAnimationFrame(sne(this,nP))}),this.context={now:0,startMs:CT(),deltaMs:0}}get elapsedMs(){return this.pausedAtMs!==null?this.pausedAtMs-this.context.startMs:CT()-this.context.startMs}};nP=new WeakMap;function n0t(t,e){const r=new k1e(({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 s0t(t,e){const r=new k1e(({deltaMs:n})=>{if(n>=e)return t(),!1});return r.start(),()=>r.stop()}function ane(...t){const e=t.length===1?t[0]:t[1],r=t.length===2?t[0]:!0}function i0t(t,e){if(t==null)throw new Error(e())}var C1e=t=>typeof t=="object"&&t!==null,a0t=9,o0t=t=>C1e(t)&&t.nodeType===a0t,l0t=t=>C1e(t)&&t===t.window;function c0t(t){if(!t)return!1;const e=t.getRootNode();return E1e(e)===t}function u0t(t){return o0t(t)?t:l0t(t)?t.document:(t==null?void 0:t.ownerDocument)??document}function E1e(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 d0t=(...t)=>t.map(e=>{var r;return(r=e==null?void 0:e.trim)==null?void 0:r.call(e)}).filter(Boolean).join(" "),h0t=/((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g,one=t=>{const e={};let r;for(;r=h0t.exec(t);)e[r[1]]=r[2];return e},f0t=(t,e)=>{if(rP(t)){if(rP(e))return`${t};${e}`;t=one(t)}else rP(e)&&(e=one(e));return Object.assign({},t??{},e??{})};function _L(...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]=Qbt(r[s],e[s]);continue}if(s==="className"||s==="class"){e[s]=d0t(e[s],r[s]);continue}if(s==="style"){e[s]=f0t(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 p0t(t,e,r){let n=[],s;return i=>{const a=t(i);return(a.length!==n.length||a.some((c,u)=>!Oq(n[u],c)))&&(n=a,s=e(a,i)),s}}var gb=(t=>(t.NotStarted="Not Started",t.Started="Started",t.Stopped="Stopped",t))(gb||{}),_3="__init__";function m0t(t){const e=()=>{var a;return((a=t.getRootNode)==null?void 0:a.call(t))??document},r=()=>u0t(e());return{...t,getRootNode:e,getDoc:r,getWin:()=>r().defaultView??window,getActiveElement:()=>E1e(e()),isActiveElement:c0t,getById:a=>e().getElementById(a)}}function g0t(t){return new Proxy({},{get(e,r){return r==="style"?n=>t({style:n}).style:t}})}var x0t=()=>t=>Array.from(new Set(t)),A1e=typeof globalThis.document<"u"?S.useLayoutEffect:S.useEffect;function WR(t){const e=t().value??t().defaultValue,r=t().isEqual??Object.is,[n]=S.useState(e),[s,i]=S.useState(n),a=t().value!==void 0,l=S.useRef(s);l.current=a?t().value:s;const c=S.useRef(l.current);A1e(()=>{c.current=l.current},[s,t().value]);const u=h=>{var m,g;const f=c.current,p=dx(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:l,get:d,set(h){(t().sync?cc.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)}}}WR.cleanup=t=>{S.useEffect(()=>t,[])};WR.ref=t=>{const e=S.useRef(t);return{get:()=>e.current,set:r=>{e.current=r}}};function y0t(t){const e=S.useRef(t);return{get(r){return e.current[r]},set(r,n){e.current[r]=n}}}var v0t=(t,e)=>{const r=S.useRef(!1),n=S.useRef(!1);S.useEffect(()=>{if(r.current&&n.current)return e();n.current=!0},[...(t??[]).map(s=>typeof s=="function"?s():s)]),S.useEffect(()=>(r.current=!0,()=>{r.current=!1}),[])};function b0t(t,e={}){var $,T,M,k;const r=S.useMemo(()=>{const{id:D,ids:K,getRootNode:H}=e;return m0t({id:D,ids:K,getRootNode:H})},[e]),n=(...D)=>{t.debug&&console.log(...D)},s=(($=t.props)==null?void 0:$.call(t,{props:N1e(e),scope:r}))??e,i=w0t(s),a=(T=t.context)==null?void 0:T.call(t,{prop:i,bindable:WR,scope:r,flush:lne,getContext(){return c},getComputed(){return j},getRefs(){return g},getEvent(){return p()}}),l=T1e(a),c={get(D){var K;return(K=l.current)==null?void 0:K[D].ref.current},set(D,K){var H;(H=l.current)==null||H[D].set(K)},initial(D){var K;return(K=l.current)==null?void 0:K[D].initial},hash(D){var H,ee;const K=(H=l.current)==null?void 0:H[D].get();return(ee=l.current)==null?void 0:ee[D].hash(K)}},u=S.useRef(new Map),d=S.useRef(null),h=S.useRef(null),f=S.useRef({type:""}),p=()=>({...f.current,current(){return f.current},previous(){return h.current}}),m=()=>({...N,matches(...D){return D.includes(N.ref.current)},hasTag(D){var K,H;return!!((H=(K=t.states[N.ref.current])==null?void 0:K.tags)!=null&&H.includes(D))}}),g=y0t(((M=t.refs)==null?void 0:M.call(t,{prop:i,context:c}))??{}),y=()=>({state:m(),context:c,event:p(),prop:i,send:O,action:x,guard:v,track:v0t,refs:g,computed:j,flush:lne,scope:r,choose:w}),x=D=>{const K=dx(D)?D(y()):D;if(!K)return;const H=K.map(ee=>{var B,z;const V=(z=(B=t.implementations)==null?void 0:B.actions)==null?void 0:z[ee];return V||ane(`[zag-js] No implementation found for action "${JSON.stringify(ee)}"`),V});for(const ee of H)ee==null||ee(y())},v=D=>{var K,H;return dx(D)?D(y()):(H=(K=t.implementations)==null?void 0:K.guards)==null?void 0:H[D](y())},b=D=>{const K=dx(D)?D(y()):D;if(!K)return;const H=K.map(V=>{var z,F;const B=(F=(z=t.implementations)==null?void 0:z.effects)==null?void 0:F[V];return B||ane(`[zag-js] No implementation found for effect "${JSON.stringify(V)}"`),B}),ee=[];for(const V of H){const B=V==null?void 0:V(y());B&&ee.push(B)}return()=>ee.forEach(V=>V==null?void 0:V())},w=D=>zbt(D).find(K=>{let H=!K.guard;return rP(K.guard)?H=!!v(K.guard):dx(K.guard)&&(H=K.guard(y())),H}),j=D=>{i0t(t.computed,()=>"[zag-js] No computed object found on machine");const K=t.computed[D];return K({context:c,event:p(),prop:i,refs:g,scope:r,computed:j})},N=WR(()=>({defaultValue:t.initialState({prop:i}),onChange(D,K){var ee,V,B,z;if(K){const F=u.current.get(K);F==null||F(),u.current.delete(K)}K&&x((ee=t.states[K])==null?void 0:ee.exit),x((V=d.current)==null?void 0:V.actions);const H=b((B=t.states[D])==null?void 0:B.effects);if(H&&u.current.set(D,H),K===_3){x(t.entry);const F=b(t.effects);F&&u.current.set(_3,F)}x((z=t.states[D])==null?void 0:z.entry)}})),C=S.useRef(void 0),A=S.useRef(gb.NotStarted);A1e(()=>{queueMicrotask(()=>{const H=A.current===gb.Started;A.current=gb.Started,n(H?"rehydrating...":"initializing...");const ee=C.current??N.initial;N.invoke(ee,H?N.get():_3)});const D=u.current,K=N.ref.current;return()=>{n("unmounting..."),C.current=K,A.current=gb.Stopped,D.forEach(H=>H==null?void 0:H()),u.current=new Map,d.current=null,queueMicrotask(()=>{x(t.exit)})}},[]);const E=()=>"ref"in N?N.ref.current:N.get(),O=D=>{queueMicrotask(()=>{var z,F;if(A.current!==gb.Started)return;h.current=f.current,f.current=D;let K=E();const H=((z=t.states[K].on)==null?void 0:z[D.type])??((F=t.on)==null?void 0:F[D.type]),ee=w(H);if(!ee)return;d.current=ee;const V=ee.target??K;n("transition",D.type,ee.target||K,`(${ee.actions})`);const B=V!==K;B?cc.flushSync(()=>N.set(V)):ee.reenter&&!B?N.invoke(K,K):x(ee.actions??[])})};return(k=t.watch)==null||k.call(t,y()),{state:m(),send:O,context:c,prop:i,scope:r,refs:g,computed:j,event:p(),getStatus:()=>A.current}}function T1e(t){const e=S.useRef(t);return e.current=t,e}function w0t(t){const e=T1e(t);return function(n){return e.current[n]}}function lne(t){queueMicrotask(()=>{cc.flushSync(()=>t())})}var j0t=g0t(t=>t);const P1e=()=>(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 S0t(...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 _0t(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 N3=t=>{const e=S.memo(S.forwardRef((r,n)=>{const{asChild:s,children:i,...a}=r;if(!s)return S.createElement(t,{...a,ref:n},i);if(!S.isValidElement(i))return null;const l=S.Children.only(i),c=_0t(l);return S.cloneElement(l,{..._L(a,l.props),ref:n?S0t(n,c):c})}));return e.displayName=t.displayName||t.name,e},N0t=()=>{const t=new Map;return new Proxy(N3,{apply(e,r,n){return N3(n[0])},get(e,r){const n=r;return t.has(n)||t.set(n,N3(n)),t.get(n)}})},Mq=N0t();function k0t(t,e){return`${t} returned \`undefined\`. Seems you forgot to wrap component within ${e}`}function I1e(t={}){const{name:e,strict:r=!0,hookName:n="useContext",providerName:s="Provider",errorMessage:i,defaultValue:a}=t,l=S.createContext(a);l.displayName=e;function c(){const u=S.useContext(l);if(!u&&r){const d=new Error(i??k0t(n,s));throw d.name="ContextError",j1e(Error,"captureStackTrace")&&dx(Error.captureStackTrace)&&Error.captureStackTrace(d,c),d}return u}return[l.Provider,c,l]}const[C0t,R1e]=I1e({name:"TimerContext",hookName:"useTimerContext",providerName:"<TimerProvider />"}),O1e=S.forwardRef((t,e)=>{const r=R1e(),n=_L(r.getAreaProps(),t);return o.jsx(Mq.div,{...n,ref:e})});O1e.displayName="TimerArea";const E0t=P1e(),WS=S.forwardRef((t,e)=>{const[r,n]=E0t(t,["type"]),s=R1e(),i=_L(s.getItemProps(r),n);return o.jsx(Mq.div,{...i,ref:e,children:s.formattedTime[r.type]})});WS.displayName="TimerItem";var VS=(t,e=[])=>({parts:(...r)=>{if(A0t(e))return VS(t,r);throw new Error("createAnatomy().parts(...) should only be called once. Did you mean to use .extendWith(...) ?")},extendWith:(...r)=>VS(t,[...e,...r]),omit:(...r)=>VS(t,e.filter(n=>!r.includes(n))),rename:r=>VS(r,e),keys:()=>e,build:()=>[...new Set(e)].reduce((r,n)=>Object.assign(r,{[n]:{selector:[`&[data-scope="${ab(t)}"][data-part="${ab(n)}"]`,`& [data-scope="${ab(t)}"][data-part="${ab(n)}"]`].join(", "),attrs:{"data-scope":ab(t),"data-part":ab(n)}}}),{})}),ab=t=>t.replace(/([A-Z])([A-Z])/g,"$1-$2").replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase(),A0t=t=>t.length===0,T0t=VS("timer").parts("root","area","control","item","itemValue","itemLabel","actionTrigger","separator"),Vf=T0t.build(),P0t=t=>{var e;return((e=t.ids)==null?void 0:e.root)??`timer:${t.id}:root`},I0t=t=>{var e;return((e=t.ids)==null?void 0:e.area)??`timer:${t.id}:area`},cne=new Set(["start","pause","resume","reset","restart"]);function R0t(t,e){const{state:r,send:n,computed:s,scope:i}=t,a=r.matches("running"),l=r.matches("paused"),c=s("time"),u=s("formattedTime"),d=s("progressPercent");return{running:a,paused:l,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:P0t(i),...Vf.root.attrs})},getAreaProps(){return e.element({role:"timer",id:I0t(i),"aria-label":`${c.days} days ${u.hours}:${u.minutes}:${u.seconds}`,"aria-atomic":!0,...Vf.area.attrs})},getControlProps(){return e.element({...Vf.control.attrs})},getItemProps(h){const f=c[h.type];return e.element({...Vf.item.attrs,"data-type":h.type,style:{"--value":f}})},getItemLabelProps(h){return e.element({...Vf.itemLabel.attrs,"data-type":h.type})},getItemValueProps(h){return e.element({...Vf.itemValue.attrs,"data-type":h.type})},getSeparatorProps(){return e.element({"aria-hidden":!0,...Vf.separator.attrs})},getActionTriggerProps(h){if(!cne.has(h.action))throw new Error(`[zag-js] Invalid action: ${h.action}. Must be one of: ${Array.from(cne).join(", ")}`);return e.button({...Vf.actionTrigger.attrs,hidden:_1e(h.action,{start:()=>a||l,pause:()=>!a,reset:()=>!a&&!l,resume:()=>!l,restart:()=>!1}),type:"button",onClick(f){f.defaultPrevented||n({type:h.action.toUpperCase()})}})}}}var O0t={props({props:t}){return $0t(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})=>M0t(t.get("currentMs")),formattedTime:({computed:t})=>L0t(t("time")),progressPercent:p0t(({context:t,prop:e})=>[t.get("currentMs"),e("targetMs"),e("startMs"),e("countdown")],([t,e=0,r,n])=>{const s=n?une(t,e,r):une(t,r,e);return r0t(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 n0t(({deltaMs:r})=>{e({type:"TICK",deltaMs:r})},t("interval"))},waitForNextTick({send:t}){return s0t(()=>{t({type:"CONTINUE"})},0)}},actions:{updateTime({context:t,prop:e,event:r}){const n=e("countdown")?-1:1,s=D0t(r.deltaMs,e("interval"));t.set("currentMs",i=>{const a=i+n*s;let l=e("targetMs");return l==null&&e("countdown")&&(l=0),e("countdown")&&l!=null?Math.max(a,l):!e("countdown")&&l!=null?Math.min(a,l):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 M0t(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 une(t,e,r){const n=r-e;return n===0?0:(t-e)/n}function dS(t,e=2){return t.toString().padStart(e,"0")}function D0t(t,e){return Math.floor(t/e)*e}function L0t(t){const{days:e,hours:r,minutes:n,seconds:s}=t;return{days:dS(e),hours:dS(r),minutes:dS(n),seconds:dS(s),milliseconds:dS(t.milliseconds,3)}}function $0t(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.`)}x0t()(["autoStart","countdown","getRootNode","id","ids","interval","onComplete","onTick","startMs","targetMs"]);const[OWt,F0t]=I1e({name:"EnvironmentContext",hookName:"useEnvironmentContext",providerName:"<EnvironmentProvider />",strict:!1,defaultValue:{getRootNode:()=>document,getDocument:()=>document,getWindow:()=>window}}),B0t=t=>{const e=S.useId(),{getRootNode:r}=F0t(),n={id:e,getRootNode:r,...t},s=b0t(O0t,n);return R0t(s,j0t)},z0t=P1e(),M1e=S.forwardRef((t,e)=>{const[r,n]=z0t(t,["id","ids","autoStart","interval","countdown","startMs","targetMs","onComplete","onTick"]),s=B0t(r),i=_L(s.getRootProps(),n);return o.jsx(C0t,{value:s,children:o.jsx(Mq.div,{...i,ref:e})})});M1e.displayName="TimerRoot";const U0t="2026-05-04",H0t=[{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"}],W0t=[{value:"qualitative",label:"Qualitative"},{value:"quantitative",label:"Quantitative"},{value:"mixed",label:"Mixed methods"},{value:"not_sure",label:"Not sure yet"}];function V0t(){const[t,e]=S.useState(""),[r,n]=S.useState(""),[s,i]=S.useState(""),[a,l]=S.useState(!1),[c,u]=S.useState(!1),[d,h]=S.useState(!1),f=async g=>{if(g.preventDefault(),!t){Ke.error("Please enter your email address");return}if(!a){Ke.error("Please accept the privacy terms to join the waitlist");return}u(!0);try{const y=new Date().toISOString(),{error:x}=await pe.from("waitlist_signups").insert({email:t.toLowerCase().trim(),planned_start:r||null,research_method:s||null,source:"landingpage",privacy_accepted_at:y,privacy_version:U0t,marketing_consent:!0,marketing_consent_at:y});if(x)if(x.code==="23505")Ke.error("This email is already on the waitlist!");else throw x;else h(!0),Ke.success("You're on the list!")}catch(y){console.error("Waitlist signup error:",y),Ke.error("Something went wrong. Please try again.")}finally{u(!1)}},m=(()=>{const g=new Date("2026-05-30T23:59:59"),y=new Date;return Math.max(0,g.getTime()-y.getTime())})();return o.jsxs(o.Fragment,{children:[o.jsx(Di,{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"}),o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Ri,{}),o.jsxs("div",{className:"relative pt-32 pb-20",children:[o.jsxs("div",{"aria-hidden":"true",className:"absolute inset-0 grid grid-cols-2 -space-x-52 opacity-40 dark:opacity-20",children:[o.jsx("div",{className:"blur-[106px] h-56 bg-gradient-to-br from-primary to-purple-400 dark:from-blue-700"}),o.jsx("div",{className:"blur-[106px] h-32 bg-gradient-to-r from-cyan-400 to-sky-300 dark:to-indigo-600"})]}),o.jsx(Kn,{children:o.jsx("div",{className:"relative",children:o.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[o.jsxs("h1",{className:"text-4xl font-bold tracking-tight text-foreground sm:text-5xl md:text-6xl",children:["Get early access to ",o.jsx("span",{className:"text-primary",children:"Academly"})]}),o.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."}),o.jsx("div",{className:"mt-12",children:m>0?o.jsx(M1e,{autoStart:!0,countdown:!0,startMs:m,children:o.jsxs(O1e,{className:"flex flex-col items-center",children:[o.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-4 uppercase tracking-wider",children:"Public Beta Launches In"}),o.jsxs("div",{className:"flex items-center gap-2 sm:gap-4",children:[o.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:[o.jsx(WS,{type:"days",className:"text-3xl sm:text-5xl font-bold text-foreground tabular-nums"}),o.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"days"})]}),o.jsx("span",{className:"text-2xl sm:text-4xl font-light text-muted-foreground/50",children:":"}),o.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:[o.jsx(WS,{type:"hours",className:"text-3xl sm:text-5xl font-bold text-foreground tabular-nums"}),o.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"hrs"})]}),o.jsx("span",{className:"text-2xl sm:text-4xl font-light text-muted-foreground/50",children:":"}),o.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:[o.jsx(WS,{type:"minutes",className:"text-3xl sm:text-5xl font-bold text-foreground tabular-nums"}),o.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"min"})]}),o.jsx("span",{className:"text-2xl sm:text-4xl font-light text-muted-foreground/50",children:":"}),o.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:[o.jsx(WS,{type:"seconds",className:"text-3xl sm:text-5xl font-bold text-foreground tabular-nums"}),o.jsx("span",{className:"text-xs sm:text-sm text-muted-foreground mt-1",children:"sec"})]})]})]})}):o.jsxs("div",{className:"flex flex-col items-center",children:[o.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-4 uppercase tracking-wider",children:"Public Beta"}),o.jsx("p",{className:"text-3xl sm:text-5xl font-bold text-primary",children:"Launching soon!"})]})})]})})})]}),o.jsx("section",{className:"pb-20 px-6 lg:px-12",children:o.jsx(Kn,{children:o.jsx("div",{className:"mx-auto max-w-md",children:d?o.jsxs("div",{className:"rounded-3xl border border-border bg-card p-8 shadow-xl shadow-primary/5 text-center animate-fade-in",children:[o.jsx("div",{className:"mx-auto mb-6 flex h-16 w-16 items-center justify-center rounded-full bg-success/10",children:o.jsx(uc,{className:"h-8 w-8 text-success"})}),o.jsx("h3",{className:"text-2xl font-semibold text-foreground",children:"You're on the list!"}),o.jsx("p",{className:"mt-3 text-muted-foreground",children:"We'll notify you when we launch. Check your inbox for updates."})]}):o.jsx("form",{onSubmit:f,className:"rounded-3xl border border-border bg-card p-8 shadow-xl shadow-primary/5",children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"email",className:"flex items-center gap-2",children:[o.jsx(Zhe,{className:"h-4 w-4 text-muted-foreground"}),"Email address ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ue,{id:"email",type:"email",placeholder:"you@university.edu",value:t,onChange:g=>e(g.target.value),required:!0,className:"h-12"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"planned-start",children:"Planned start (optional)"}),o.jsxs(pt,{value:r,onValueChange:n,children:[o.jsx(ut,{id:"planned-start",className:"h-12",children:o.jsx(mt,{placeholder:"Select..."})}),o.jsx(dt,{children:H0t.map(g=>o.jsx(Le,{value:g.value,children:g.label},g.value))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"research-method",children:"Research method (optional)"}),o.jsxs(pt,{value:s,onValueChange:i,children:[o.jsx(ut,{id:"research-method",className:"h-12",children:o.jsx(mt,{placeholder:"Select..."})}),o.jsx(dt,{children:W0t.map(g=>o.jsx(Le,{value:g.value,children:g.label},g.value))})]})]}),o.jsxs(b1e,{id:"marketing-consent",checked:a,onCheckedChange:l,required:!0,children:["I agree that Academly may contact me about early access and product updates. I have read the"," ",o.jsx(Nt,{to:"/legal?tab=privacy",className:"text-primary hover:underline font-medium",target:"_blank",children:"Privacy Policy"}),"."]}),o.jsx(me,{type:"submit",size:"lg",className:"w-full h-12 text-base font-semibold rounded-full",disabled:c||!a,children:c?"Joining...":"Join the Waitlist"}),o.jsxs("p",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:[o.jsx(UM,{className:"h-3 w-3"}),"No spam. No data sharing. Unsubscribe anytime."]})]})})})})}),o.jsx(Ii,{})]})]})}var NL="Tabs",[q0t,MWt]=Vs(NL,[fj]),D1e=fj(),[G0t,Dq]=q0t(NL),L1e=S.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,onValueChange:s,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:c="automatic",...u}=t,d=Tv(l),[h,f]=ca({prop:n,onChange:s,defaultProp:i??"",caller:NL});return o.jsx(G0t,{scope:r,baseId:Co(),value:h,onValueChange:f,orientation:a,dir:d,activationMode:c,children:o.jsx(ft.div,{dir:d,"data-orientation":a,...u,ref:e})})});L1e.displayName=NL;var $1e="TabsList",F1e=S.forwardRef((t,e)=>{const{__scopeTabs:r,loop:n=!0,...s}=t,i=Dq($1e,r),a=D1e(r);return o.jsx(m9,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:n,children:o.jsx(ft.div,{role:"tablist","aria-orientation":i.orientation,...s,ref:e})})});F1e.displayName=$1e;var B1e="TabsTrigger",z1e=S.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,disabled:s=!1,...i}=t,a=Dq(B1e,r),l=D1e(r),c=W1e(a.baseId,n),u=V1e(a.baseId,n),d=n===a.value;return o.jsx(g9,{asChild:!0,...l,focusable:!s,active:d,children:o.jsx(ft.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:Qe(t.onMouseDown,h=>{!s&&h.button===0&&h.ctrlKey===!1?a.onValueChange(n):h.preventDefault()}),onKeyDown:Qe(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&a.onValueChange(n)}),onFocus:Qe(t.onFocus,()=>{const h=a.activationMode!=="manual";!d&&!s&&h&&a.onValueChange(n)})})})});z1e.displayName=B1e;var U1e="TabsContent",H1e=S.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,forceMount:s,children:i,...a}=t,l=Dq(U1e,r),c=W1e(l.baseId,n),u=V1e(l.baseId,n),d=n===l.value,h=S.useRef(d);return S.useEffect(()=>{const f=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(f)},[]),o.jsx(pi,{present:s||d,children:({present:f})=>o.jsx(ft.div,{"data-state":d?"active":"inactive","data-orientation":l.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})})});H1e.displayName=U1e;function W1e(t,e){return`${t}-trigger-${e}`}function V1e(t,e){return`${t}-content-${e}`}var K0t=L1e,q1e=F1e,G1e=z1e,K1e=H1e;const VR=K0t,bk=S.forwardRef(({className:t,...e},r)=>o.jsx(q1e,{ref:r,className:Pe("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));bk.displayName=q1e.displayName;const Fh=S.forwardRef(({className:t,...e},r)=>o.jsx(G1e,{ref:r,className:Pe("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}));Fh.displayName=G1e.displayName;const hv=S.forwardRef(({className:t,...e},r)=>o.jsx(K1e,{ref:r,className:Pe("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));hv.displayName=K1e.displayName;const Y0t=()=>{const[t]=uj(),e=t.get("tab"),[r,n]=S.useState(e==="privacy"?"privacy":"terms");return S.useEffect(()=>{(e==="privacy"||e==="terms")&&n(e)},[e]),o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{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"}),o.jsx(Ri,{}),o.jsxs("section",{className:"relative pt-32 pb-12",children:[o.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-primary/5 via-transparent to-transparent"}),o.jsx(Kn,{className:"relative",children:o.jsxs("div",{className:"text-center max-w-3xl mx-auto",children:[o.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-foreground mb-6",children:"Legal Information"}),o.jsx("p",{className:"text-xl text-muted-foreground",children:"Transparency and trust are important to us"})]})})]}),o.jsx("section",{className:"py-12 pb-20",children:o.jsx(Kn,{children:o.jsx("div",{className:"max-w-4xl mx-auto",children:o.jsxs(VR,{value:r,onValueChange:n,className:"w-full",children:[o.jsxs(bk,{className:"grid w-full grid-cols-2 rounded-full p-1 h-14 bg-muted",children:[o.jsx(Fh,{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"}),o.jsx(Fh,{value:"privacy",className:"rounded-full data-[state=active]:bg-background data-[state=active]:shadow-sm h-12 text-base font-medium",children:"Privacy Policy"})]}),o.jsx(hv,{value:"terms",className:"mt-8",children:o.jsxs("div",{className:"rounded-3xl border border-border bg-card p-8 md:p-12",children:[o.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"TERMS OF SERVICE"}),o.jsxs("p",{className:"text-muted-foreground mb-8",children:["for the use of the SaaS platform Academly.ai",o.jsx("br",{}),"Effective: 15 January 2026, last amended May 2026"]}),o.jsxs("div",{className:"space-y-8 text-muted-foreground leading-relaxed",children:[o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"1. Scope and Contracting Parties"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.1 Provider"}),o.jsx("p",{children:'The provider of the platform available under the domain academly.ai (hereinafter the "Platform" or "Service") is:'}),o.jsxs("p",{className:"mt-2",children:["Academly",o.jsx("br",{}),"Contact: contact@academly.ai"]}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.2 Scope of these Terms"}),o.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.'}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.3 Changes to these Terms"}),o.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."}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"2. Service Description"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.1 Description of the Platform"}),o.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."}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.2 AI-assisted Functions"}),o.jsx("p",{children:"Academly.ai provides AI-assisted features that may vary depending on the selected plan. These include in particular:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"AI-generated summaries of uploaded content, structured and condensed;"}),o.jsx("li",{children:"outline/structure and drafting functions (e.g., theory, methodology, or structural building blocks);"}),o.jsx("li",{children:"document analysis (e.g., identification of relevant passages, structural suggestions, extraction)."})]}),o.jsxs("p",{className:"mt-2",children:[o.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."]}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.3 Document Processing"}),o.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."}),o.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."}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.4 Export and Backup Features"}),o.jsx("p",{children:"Users may export generated content, in particular summaries, outlines, and drafts, in common formats (e.g., DOCX, TXT) and store it locally."}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.5 Use in Different Countries"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.6 Changes, Corrections and Further Development"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.7 Third-party Offers and Links"}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"3. Registration and User Account"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.1 Registration Requirements"}),o.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."}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.2 Account Security"}),o.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."}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.3 Account Termination and Deletion"}),o.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."}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"4. Subscriptions and Payments"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.1 Available Plans"}),o.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."}),o.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."}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.2 Payments via Stripe"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.3 Right of Withdrawal (Consumers) – Austria"}),o.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."}),o.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"}),o.jsxs("p",{className:"mt-2",children:[o.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."]}),o.jsxs("p",{className:"mt-2",children:[o.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."]})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"5. Usage Rights and Restrictions"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.1 Granted Usage Rights"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.2 Prohibited Use"}),o.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."}),o.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."}),o.jsx("p",{className:"mt-2",children:"In particular, the following is also prohibited:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"systematically reading or extracting data (scraping) without permission;"}),o.jsx("li",{children:"bypassing or manipulating technical protection measures;"}),o.jsx("li",{children:"reverse engineering, decompilation, or other analysis of the Platform unless mandatory law permits it;"}),o.jsx("li",{children:"using automated systems or scripts that place excessive load on the Platform;"}),o.jsx("li",{children:"using the Platform to deceive third parties (e.g., phishing, identity misuse);"}),o.jsx("li",{children:"uploading content that infringes third-party rights;"}),o.jsx("li",{children:"introducing malware or other disruptions;"}),o.jsx("li",{children:"account sharing or allowing multiple persons to use one account."})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.3 Fair Use and Abuse Prevention"}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"6. Intellectual Property"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.1 Rights in the Platform"}),o.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."}),o.jsxs("p",{className:"mt-2",children:[o.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.`]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.2 Rights in User Content"}),o.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.'})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.3 Rights in AI-generated Content"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.4 Feedback"}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"7. Academic Integrity and Notices"}),o.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."})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"8. Limitation of Liability"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:'8.1 Platform Availability ("Best Effort")'}),o.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.'}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.2 Data Loss"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.3 Liability Cap"}),o.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."}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"9. Final Provisions"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.1 Governing Law"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.2 Jurisdiction and Dispute Resolution"}),o.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:"," ",o.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"})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.3 Severability"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.4 Contact"}),o.jsx("p",{children:"Questions or complaints may be sent to contact@academly.ai."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.5 Electronic Communication"}),o.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."})]})]})]})]})]})}),o.jsx(hv,{value:"privacy",className:"mt-8",children:o.jsxs("div",{className:"rounded-3xl border border-border bg-card p-8 md:p-12",children:[o.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"PRIVACY POLICY"}),o.jsxs("p",{className:"text-muted-foreground mb-8",children:["for the use of the SaaS platform Academly.ai",o.jsx("br",{}),"Last updated: May 2026"]}),o.jsxs("div",{className:"space-y-8 text-muted-foreground leading-relaxed",children:[o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"1. Introduction and Controller"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.1 Controller name and contact details"}),o.jsx("p",{children:"The controller within the meaning of the General Data Protection Regulation (GDPR) and other applicable data protection laws is:"}),o.jsxs("p",{className:"mt-2",children:["Academly",o.jsx("br",{}),"Email: contact@academly.ai"]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.2 Data Protection Officer"}),o.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."}),o.jsx("p",{className:"mt-2",children:"For any data protection inquiries, please contact us using the contact details above."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"1.3 Scope of this Privacy Policy"}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"2. Principles of Data Processing"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.1 Legal bases for processing"}),o.jsx("p",{children:"We process personal data only on the basis of one of the following legal bases under Art. 6(1) GDPR:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-2",children:[o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"(a) Consent (Art. 6(1)(a) GDPR)"}),o.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."]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"(b) Performance of a contract (Art. 6(1)(b) GDPR)"}),o.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."]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"(c) Legal obligation (Art. 6(1)(c) GDPR)"}),o.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."]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"(d) Legitimate interests (Art. 6(1)(f) GDPR)"}),o.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."]})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.2 Categories of data processed"}),o.jsx("p",{children:"When you use our platform, we may process the following categories of personal data:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Account data:"})," email address, nickname, profile information (university, degree program), account-related information"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Usage data:"})," IP address, access time, pages accessed, browser type, operating system, referrer URL, device information"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Content data:"})," uploaded documents, AI-generated content (summaries, thesis drafts, analyses), stored projects and notes"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Payment-related data:"})," billing address, payment history, subscription status (full payment details are processed exclusively by Stripe)"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Meta and communication data:"})," token usage, student points, activity history, communication with support"]})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"2.3 Purposes of processing"}),o.jsx("p",{children:"We process personal data for the following purposes:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Providing the platform and its features"}),o.jsx("li",{children:"User account administration and authentication"}),o.jsx("li",{children:"Processing documents for AI-assisted analysis"}),o.jsx("li",{children:"Generating summaries, thesis drafts and other AI-generated outputs"}),o.jsx("li",{children:"Payment processing and subscription management"}),o.jsx("li",{children:"Ensuring IT security and fraud prevention"}),o.jsx("li",{children:"Analytics and service improvement"}),o.jsx("li",{children:"Compliance with statutory retention obligations"}),o.jsx("li",{children:"Communication with users (support and service messages)"})]})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"3. Data Collection When Using the Platform"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.1 Registration and user account"}),o.jsx("p",{children:"When you register for a user account, we collect:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Email address:"})," required to create an account, authenticate you and communicate with you"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Password:"})," stored only in hashed form; plaintext passwords are never stored or transmitted"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Profile information (optional):"})," nickname, university, degree program, research interests"]})]}),o.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)."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.2 Document upload and processing"}),o.jsx("p",{children:"Users may upload documents (in particular PDF files) to the platform. These documents are:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Stored securely in Supabase Storage"}),o.jsx("li",{children:"Processed to provide AI-assisted analysis features"}),o.jsx("li",{children:"Retained for the duration of the account use or until deleted by the user"})]}),o.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)."}),o.jsxs("p",{className:"mt-2",children:[o.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."]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.3 AI-generated content"}),o.jsx("p",{children:"In the course of using the platform, AI-generated content is created, including:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Thesis drafts and outlines"}),o.jsx("li",{children:"Summaries of uploaded documents"}),o.jsx("li",{children:"Theory building blocks and methodology suggestions"}),o.jsx("li",{children:"Document analyses and structure suggestions"})]}),o.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)."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"3.4 Usage data and statistics"}),o.jsx("p",{children:"To provide and improve our services, we collect:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Token usage:"})," for billing and quota monitoring"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Student points:"})," to manage the credit system"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Activity history:"})," to track usage history"]})]}),o.jsx("p",{className:"mt-2",children:"Processing is based on our legitimate interests in service improvement and fraud prevention (Art. 6(1)(f) GDPR)."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"4. Hosting and Infrastructure"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.1 Vercel (frontend hosting)"}),o.jsx("p",{children:"Our frontend is hosted by Vercel Inc. Each time you access the platform, the following data may be processed automatically:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"IP address of the accessing device"}),o.jsx("li",{children:"Date and time of access"}),o.jsx("li",{children:"Browser type and version"}),o.jsx("li",{children:"Operating system"}),o.jsx("li",{children:"Referrer URL"})]}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Provider:"})," Vercel Inc., 340 S Lemon Ave #4133, Walnut, CA 91789, USA"]}),o.jsxs("p",{className:"mt-2",children:[o.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."]}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," legitimate interest in the technical provision of the platform (Art. 6(1)(f) GDPR)."]}),o.jsxs("p",{className:"mt-2",children:[o.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."]}),o.jsxs("p",{className:"mt-2",children:["Further information:"," ",o.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"})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.2 Supabase (backend infrastructure)"}),o.jsx("p",{children:"We use Supabase for backend services, including:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Database:"})," storage of account data, projects and generated content"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Authentication:"})," user account and login management"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"File storage:"})," secure storage of uploaded documents"]})]}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Provider:"})," Supabase Inc., 970 Toa Payoh North #07-04, Singapore 318992"]}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Server location:"})," our Supabase instance is hosted in the EU region (Frankfurt, Germany)."]}),o.jsxs("p",{className:"mt-2",children:[o.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)."]}),o.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."}),o.jsxs("p",{className:"mt-2",children:["Further information:"," ",o.jsx("a",{href:"https://supabase.com/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://supabase.com/privacy"})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"4.3 Edge Functions (serverless)"}),o.jsx("p",{children:"To process AI requests, we use serverless functions (edge functions) executed on Supabase infrastructure. These functions:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Process requests to AI APIs in real time"}),o.jsx("li",{children:"Are executed in the EU region"}),o.jsx("li",{children:"Do not store persistent data outside the database"})]}),o.jsx("p",{className:"mt-2",children:"Processing is necessary for performance of the contract (Art. 6(1)(b) GDPR)."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"5. Payment Processing"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.1 Stripe as payment service provider"}),o.jsx("p",{children:"Payments are processed via Stripe, an external payment service provider. Stripe processes:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Credit card or other payment information"}),o.jsx("li",{children:"Billing address"}),o.jsx("li",{children:"Email address"}),o.jsx("li",{children:"Transaction data"})]}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Provider:"})," Stripe Payments Europe Ltd., 1 Grand Canal Street Lower, Grand Canal Dock, Dublin, D02 H210, Ireland"]}),o.jsxs("p",{className:"mt-2",children:[o.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."]}),o.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."}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," performance of the contract (Art. 6(1)(b) GDPR)."]}),o.jsxs("p",{className:"mt-2",children:["Further information:"," ",o.jsx("a",{href:"https://stripe.com/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://stripe.com/privacy"})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"5.2 Invoice data"}),o.jsx("p",{children:"Invoice data (billing address, invoice amounts, invoice date) is stored for tax and accounting purposes."}),o.jsxs("p",{className:"mt-2",children:[o.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."]}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Retention period:"})," 7 years under Austrian tax law."]})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"6. Analytics and Tracking"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.1 Plausible Analytics"}),o.jsx("p",{children:"We use Plausible Analytics, a privacy-friendly web analytics service."}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Provider:"})," Plausible Insights OÜ, Västriku tn 2, 50403, Tartu, Estonia"]}),o.jsx("p",{className:"mt-2",children:o.jsx("strong",{className:"text-foreground",children:"Key characteristics:"})}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"No cookies"}),o.jsx("li",{children:"No collection of directly identifying personal data"}),o.jsx("li",{children:"No cross-device tracking"}),o.jsx("li",{children:"GDPR-compliant without consent"}),o.jsx("li",{children:"Servers located in the EU"})]}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Data processed:"})," aggregated, anonymized usage statistics (page views, time on page, device type, country based on anonymized IP)."]}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," legitimate interest in analytics and optimization of our platform (Art. 6(1)(f) GDPR)."]}),o.jsxs("p",{className:"mt-2",children:["Further information:"," ",o.jsx("a",{href:"https://plausible.io/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://plausible.io/privacy"})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.2 Cookie policy"}),o.jsx("p",{children:"Our platform uses only technically necessary cookies required for operating the platform, such as:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Authentication cookies (session management)"}),o.jsx("li",{children:"Security cookies (CSRF protection)"})]}),o.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."}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Analytics cookies:"})," currently not used. Plausible Analytics works without cookies."]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"6.3 Notice regarding possible future use of Google Analytics"}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"7. Email Communication"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"7.1 Transactional emails"}),o.jsx("p",{children:"We send transactional emails that are necessary for performing the contract, such as:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Account confirmation upon registration"}),o.jsx("li",{children:"Password reset"}),o.jsx("li",{children:"Payment confirmations and invoices"}),o.jsx("li",{children:"Important service messages (e.g., changes to the Terms of Service)"})]}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Legal basis:"})," performance of the contract (Art. 6(1)(b) GDPR)."]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"7.2 Marketing and product updates"}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"8. Disclosure to Third Parties"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.1 Service providers"}),o.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."}),o.jsx("div",{className:"mt-4 overflow-x-auto",children:o.jsxs("table",{className:"w-full border-collapse border border-border text-sm",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"bg-muted",children:[o.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Provider"}),o.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Role"}),o.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Purpose"}),o.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Location"})]})}),o.jsxs("tbody",{children:[o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"Supabase Inc."}),o.jsx("td",{className:"border border-border p-2",children:"Processor"}),o.jsx("td",{className:"border border-border p-2",children:"Database, authentication, storage"}),o.jsx("td",{className:"border border-border p-2",children:"EU (Frankfurt)"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"Vercel Inc."}),o.jsx("td",{className:"border border-border p-2",children:"Processor"}),o.jsx("td",{className:"border border-border p-2",children:"Frontend hosting/delivery"}),o.jsx("td",{className:"border border-border p-2",children:"Global (including EU/USA)"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"Plausible Insights OÜ"}),o.jsx("td",{className:"border border-border p-2",children:"Processor"}),o.jsx("td",{className:"border border-border p-2",children:"Web analytics (aggregated, cookie-free)"}),o.jsx("td",{className:"border border-border p-2",children:"EU (Estonia)"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"OpenAI, LLC"}),o.jsx("td",{className:"border border-border p-2",children:"Processor"}),o.jsx("td",{className:"border border-border p-2",children:"AI processing via API"}),o.jsx("td",{className:"border border-border p-2",children:"USA"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"Stripe Payments Europe Ltd."}),o.jsx("td",{className:"border border-border p-2",children:"Independent controller"}),o.jsx("td",{className:"border border-border p-2",children:"Payment processing"}),o.jsx("td",{className:"border border-border p-2",children:"Ireland/EU"})]})]})]})}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.2 International transfers"}),o.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:"}),o.jsx("p",{className:"mt-2",children:o.jsx("strong",{className:"text-foreground",children:"USA:"})}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Standard Contractual Clauses pursuant to Art. 46(2)(c) GDPR (SCCs)"}),o.jsx("li",{children:"Where applicable: EU–US Data Privacy Framework for appropriately certified companies"}),o.jsx("li",{children:"Supplementary technical and organizational measures"})]}),o.jsx("p",{className:"mt-2",children:o.jsx("strong",{className:"text-foreground",children:"Affected services:"})}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Vercel Inc. (hosting) – SCCs; where applicable EU–US DPF"}),o.jsx("li",{children:"OpenAI, LLC (AI processing) – SCCs"})]}),o.jsx("p",{className:"mt-2",children:"Users may request copies of the Standard Contractual Clauses by contacting contact@academly.ai."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"8.3 AI Provider — Important Notice"}),o.jsxs("p",{children:[o.jsx("strong",{className:"text-foreground",children:"OpenAI, LLC"}),o.jsx("br",{}),"3180 18th Street, San Francisco, CA 94110, USA"]}),o.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:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Theory & Background Builder"}),o.jsx("li",{children:"Methods & Approach Builder"}),o.jsx("li",{children:"Supervisor Chat"}),o.jsx("li",{children:"Qualitative Analysis (interview evaluation, codebooks)"}),o.jsx("li",{children:"Document Summaries"}),o.jsx("li",{children:"Topic Explorer"})]}),o.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 ",o.jsx("strong",{className:"text-foreground",children:"not used to train their models"}),"."]}),o.jsx("p",{className:"mt-2",children:o.jsx("strong",{className:"text-foreground",children:"Important notes:"})}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Transmission is encrypted"}),o.jsx("li",{children:"Standard Contractual Clauses apply for international transfers"}),o.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"})]}),o.jsxs("p",{className:"mt-2",children:[o.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."]}),o.jsxs("p",{className:"mt-2",children:["Further information:"," ",o.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"})]})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"9. Retention and Deletion"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.1 Retention periods by data category"}),o.jsx("div",{className:"mt-4 overflow-x-auto",children:o.jsxs("table",{className:"w-full border-collapse border border-border text-sm",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"bg-muted",children:[o.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Data category"}),o.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Retention period"}),o.jsx("th",{className:"border border-border p-2 text-left text-foreground",children:"Reason"})]})}),o.jsxs("tbody",{children:[o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"Account data"}),o.jsx("td",{className:"border border-border p-2",children:"Until account deletion"}),o.jsx("td",{className:"border border-border p-2",children:"Performance of contract"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"Documents"}),o.jsx("td",{className:"border border-border p-2",children:"Per user settings or upon account deletion"}),o.jsx("td",{className:"border border-border p-2",children:"Performance of contract"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"AI-generated content"}),o.jsx("td",{className:"border border-border p-2",children:"Until deleted by user or account deletion"}),o.jsx("td",{className:"border border-border p-2",children:"Performance of contract"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"Usage statistics"}),o.jsx("td",{className:"border border-border p-2",children:"12 months"}),o.jsx("td",{className:"border border-border p-2",children:"Legitimate interests"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"Payment/invoice data"}),o.jsx("td",{className:"border border-border p-2",children:"7 years"}),o.jsx("td",{className:"border border-border p-2",children:"Statutory retention obligation"})]}),o.jsxs("tr",{children:[o.jsx("td",{className:"border border-border p-2",children:"Server logs"}),o.jsx("td",{className:"border border-border p-2",children:"30 days"}),o.jsx("td",{className:"border border-border p-2",children:"IT security"})]})]})]})})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.2 Automatic deletion of inactive accounts"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"9.3 Backup retention"}),o.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."})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"10. Data Security"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"10.1 Technical measures"}),o.jsx("p",{children:"We implement technical measures to protect personal data, including:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Encryption:"})," all data transmissions via TLS/HTTPS (at least TLS 1.2)"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Password hashing:"})," passwords stored using secure, up-to-date hashing algorithms"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Row Level Security (RLS):"})," database access restricted via row-level policies"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Access controls:"})," restricting access to authorized systems"]}),o.jsxs("li",{children:[o.jsx("strong",{className:"text-foreground",children:"Regular updates:"})," applying security patches and updates"]})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"10.2 Organizational measures"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Access to personal data is limited to what is necessary"}),o.jsx("li",{children:"Security-relevant accesses are logged where appropriate"}),o.jsx("li",{children:"Security measures are reviewed regularly"})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"10.3 Incident response"}),o.jsx("p",{children:"In the event of a personal data breach, we will:"}),o.jsxs("ul",{className:"list-disc list-inside mt-2 space-y-1",children:[o.jsx("li",{children:"Notify the competent supervisory authority within 72 hours where required under Art. 33 GDPR"}),o.jsx("li",{children:"Notify affected individuals without undue delay where required under Art. 34 GDPR"}),o.jsx("li",{children:"Document the incident and take remedial measures"})]})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"11. Data Subject Rights"}),o.jsx("p",{className:"mb-4",children:"You have the following rights regarding your personal data:"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.1 Right of access (Art. 15 GDPR)"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.2 Right to rectification (Art. 16 GDPR)"}),o.jsx("p",{children:"You have the right to request correction of inaccurate personal data. Many data fields can be edited directly in your account."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.3 Right to erasure (Art. 17 GDPR)"}),o.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."}),o.jsxs("div",{className:"mt-4 p-4 bg-muted/50 rounded-lg border border-border",children:[o.jsx("h5",{className:"font-medium text-foreground mb-3",children:"What happens when you delete your account:"}),o.jsx("p",{className:"text-sm mb-2",children:o.jsx("strong",{className:"text-foreground",children:"Immediately and permanently deleted:"})}),o.jsxs("ul",{className:"list-disc list-inside text-sm space-y-1 mb-4",children:[o.jsx("li",{children:"Your email address and profile information (nickname, university, research interests)"}),o.jsx("li",{children:"All uploaded documents and PDFs"}),o.jsx("li",{children:"All generated summaries and analyses"}),o.jsx("li",{children:"All thesis drafts, chapters, and sections"}),o.jsx("li",{children:"All research setups and topic explorations"}),o.jsx("li",{children:"All qualitative coding data (interviews, codebooks, coded segments)"}),o.jsx("li",{children:"All files stored in our cloud storage"})]}),o.jsx("p",{className:"text-sm mb-2",children:o.jsx("strong",{className:"text-foreground",children:"Anonymized (retained without personal reference):"})}),o.jsxs("ul",{className:"list-disc list-inside text-sm space-y-1 mb-4",children:[o.jsx("li",{children:"Transaction records required for tax/accounting compliance (§ 132 BAO Austria: 7 years)"}),o.jsx("li",{children:"Usage statistics (aggregated, with no possibility of personal identification)"})]}),o.jsx("p",{className:"text-sm mb-2",children:o.jsx("strong",{className:"text-foreground",children:"Third-party data:"})}),o.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."}),o.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/50 p-3 rounded-md border border-amber-200 dark:border-amber-800",children:o.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[o.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.']})})]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.4 Right to restriction of processing (Art. 18 GDPR)"}),o.jsx("p",{children:"Under certain conditions, you have the right to request restriction of processing."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.5 Right to data portability (Art. 20 GDPR)"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.6 Right to object (Art. 21 GDPR)"}),o.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."}),o.jsx("p",{className:"mt-2",children:"You may object to direct marketing at any time without giving reasons."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.7 Withdrawal of consent (Art. 7(3) GDPR)"}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"11.8 Right to lodge a complaint with a supervisory authority"}),o.jsx("p",{children:"You have the right to lodge a complaint with a data protection supervisory authority. The competent authority for us is:"}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Austrian Data Protection Authority (Österreichische Datenschutzbehörde)"}),o.jsx("br",{}),"Barichgasse 40-42",o.jsx("br",{}),"1030 Vienna, Austria",o.jsx("br",{}),"Email: dsb@dsb.gv.at"]}),o.jsxs("p",{className:"mt-2",children:["Website:"," ",o.jsx("a",{href:"https://www.dsb.gv.at",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://www.dsb.gv.at"})]})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"12. Special Notes on AI Processing"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"12.1 Automated decision-making"}),o.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)."}),o.jsx("p",{className:"mt-2",children:"AI-generated content is provided as working drafts only and has no legal or academic binding effect."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"12.2 Use of data for AI training"}),o.jsxs("p",{children:[o.jsx("strong",{className:"text-foreground",children:"Important note:"})," User data is not used to train external AI models."]}),o.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."})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"12.3 AI-generated content"}),o.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)."}),o.jsxs("p",{className:"mt-2",children:[o.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."]})]})]})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"13. Changes to this Privacy Policy"}),o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"13.1 Updates"}),o.jsx("p",{children:"We reserve the right to update this Privacy Policy to reflect changes in legal requirements or changes to our services."}),o.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."}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Date of last update:"})," May 2026"]})]})})]}),o.jsxs("section",{children:[o.jsx("h3",{className:"font-semibold text-xl text-foreground mb-4",children:"14. Contact"}),o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-foreground mb-2",children:"14.1 Data protection inquiries"}),o.jsx("p",{children:"For questions about data protection, exercising your rights, or complaints, please contact:"}),o.jsxs("p",{className:"mt-2",children:[o.jsx("strong",{className:"text-foreground",children:"Email:"})," contact@academly.ai"]}),o.jsx("p",{className:"mt-2",children:"We aim to respond to requests within one month."})]})})]})]})]})})]})})})}),o.jsx(Ii,{})]})},X0t=_f("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"}}),yf=S.forwardRef(({className:t,variant:e,...r},n)=>o.jsx("div",{ref:n,role:"alert",className:Pe(X0t({variant:e}),t),...r}));yf.displayName="Alert";const Lq=S.forwardRef(({className:t,...e},r)=>o.jsx("h5",{ref:r,className:Pe("mb-1 font-medium leading-none tracking-tight",t),...e}));Lq.displayName="AlertTitle";const vf=S.forwardRef(({className:t,...e},r)=>o.jsx("div",{ref:r,className:Pe("text-sm [&_p]:leading-relaxed",t),...e}));vf.displayName="AlertDescription";const dne="2026-01-15",Q0t="ACAD58EMY",Z0t=!0;function J0t({defaultIsLogin:t=!1}){const[e,r]=S.useState(t),[n,s]=S.useState(""),[i,a]=S.useState(""),[l,c]=S.useState(""),[u,d]=S.useState(!1),[h,f]=S.useState(!1),[p,m]=S.useState(""),[g,y]=S.useState(!1),[x,v]=S.useState(!1),[b,w]=S.useState(""),[j,N]=S.useState(!1),[C,A]=S.useState(!1),[E,O]=S.useState(""),[$,T]=S.useState(!1),[M,k]=S.useState(!1),{signIn:D,signUp:K}=Ht(),H=async B=>{if(B.preventDefault(),v(!0),w(""),e){const{error:z}=await D(n,i);z&&w(z.message)}else{if(i!==l){w("Passwords do not match"),v(!1);return}if(p.toUpperCase()!==Q0t){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 z={terms_accepted_at:new Date().toISOString(),privacy_accepted_at:new Date().toISOString(),terms_version:dne,privacy_version:dne},{error:F}=await K(n,i,z);F?w(F.message):N(!0)}v(!1)},ee=async B=>{B.preventDefault(),k(!0),w("");try{const{error:z}=await pe.auth.resetPasswordForEmail(E,{redirectTo:"https://academly.ai/reset-password"});if(z)throw z;T(!0)}catch(z){w(z.message||"Failed to send reset email")}finally{k(!1)}},V=()=>{r(!e),A(!1),c(""),d(!1),f(!1),m(""),y(!1),w(""),N(!1),T(!1)};return j?o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mx-auto mb-6 flex h-14 w-14 items-center justify-center rounded-full bg-emerald-500/10",children:o.jsx(No,{className:"h-7 w-7 text-emerald-500"})}),o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-primary",children:"Account created"}),o.jsx("h1",{className:"mt-3 text-3xl font-bold tracking-tight text-foreground",children:"Check your inbox."}),o.jsxs("div",{className:"mt-4 flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Zhe,{className:"h-4 w-4"}),o.jsx("span",{children:n})]}),o.jsx("p",{className:"mx-auto mt-5 max-w-sm text-sm leading-6 text-muted-foreground",children:"We've sent a confirmation email to your address. Open the link in that email to activate your Academly account."}),o.jsx("p",{className:"mt-5 text-xs text-muted-foreground",children:"Didn't receive it? Check your spam folder before trying again."}),o.jsx(me,{variant:"outline",onClick:V,className:"mt-7 h-11 w-full rounded-xl",children:"Back to Login"})]}):C?$?o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mx-auto mb-6 flex h-14 w-14 items-center justify-center rounded-full bg-emerald-500/10",children:o.jsx(No,{className:"h-7 w-7 text-emerald-500"})}),o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-primary",children:"Password reset"}),o.jsx("h1",{className:"mt-3 text-3xl font-bold tracking-tight text-foreground",children:"Reset email sent."}),o.jsx("p",{className:"mx-auto mt-4 max-w-sm text-sm leading-6 text-muted-foreground",children:"Check your inbox and follow the reset link to choose a new password."}),o.jsx(me,{variant:"outline",onClick:()=>{A(!1),T(!1)},className:"mt-7 h-11 w-full rounded-xl",children:"Back to Login"})]}):o.jsxs("form",{onSubmit:ee,children:[o.jsxs("div",{className:"mb-8",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-primary",children:"Account access"}),o.jsx("h1",{className:"mt-3 text-3xl font-bold tracking-tight text-foreground",children:"Reset your password."}),o.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:"Enter the email address associated with your Academly account."})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"forgotEmail",className:"text-sm font-medium text-foreground",children:"Email address"}),o.jsx(Ue,{id:"forgotEmail",type:"email",value:E,onChange:B=>O(B.target.value),required:!0,className:"h-12 rounded-xl border-border/80 bg-background px-4 shadow-sm focus-visible:ring-primary/30",placeholder:"you@example.com"})]}),b&&o.jsx(yf,{className:"mt-5 border-destructive/40 bg-destructive/5",children:o.jsx(vf,{className:"text-destructive",children:b})}),o.jsx(me,{type:"submit",disabled:M,className:"mt-6 h-12 w-full rounded-xl text-base font-semibold shadow-sm",children:M?"Sending...":"Send Reset Link"}),o.jsx("button",{type:"button",onClick:()=>{A(!1),w("")},className:"mt-5 w-full text-center text-sm font-medium text-primary transition hover:text-primary-hover",children:"Back to Login"})]}):o.jsxs("div",{children:[o.jsxs("div",{className:"mb-8",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-primary",children:e?"Welcome back":"Create your account"}),o.jsx("h1",{className:"mt-3 text-3xl font-bold tracking-tight text-foreground sm:text-[2.4rem]",children:e?"Sign in to Academly.":"Start working with Academly."}),o.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground",children:e?"Continue to your research and thesis workspace.":"Create your account and start building your thesis around real academic sources."})]}),o.jsxs("form",{onSubmit:H,className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"email",className:"text-sm font-medium text-foreground",children:"Email address"}),o.jsx(Ue,{id:"email",type:"email",value:n,onChange:B=>s(B.target.value),required:!0,className:"h-12 rounded-xl border-border/80 bg-background px-4 shadow-sm focus-visible:ring-primary/30",placeholder:"you@example.com"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Se,{htmlFor:"password",className:"text-sm font-medium text-foreground",children:"Password"}),e&&o.jsx("button",{type:"button",onClick:()=>{A(!0),O(n),w("")},className:"text-xs font-medium text-primary transition hover:text-primary-hover",children:"Forgot password?"})]}),o.jsxs("div",{className:"relative",children:[o.jsx(Ue,{id:"password",type:u?"text":"password",value:i,onChange:B=>a(B.target.value),required:!0,className:"h-12 rounded-xl border-border/80 bg-background px-4 pr-12 shadow-sm focus-visible:ring-primary/30",placeholder:e?"Enter your password":"At least 6 characters"}),o.jsx("button",{type:"button",onClick:()=>d(!u),className:"absolute right-3 top-1/2 flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-muted/60 hover:text-foreground",tabIndex:-1,"aria-label":u?"Hide password":"Show password",children:u?o.jsx(vI,{className:"h-[18px] w-[18px]"}):o.jsx(pl,{className:"h-[18px] w-[18px]"})})]})]}),!e&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"confirmPassword",className:"text-sm font-medium text-foreground",children:"Confirm password"}),o.jsxs("div",{className:"relative",children:[o.jsx(Ue,{id:"confirmPassword",type:h?"text":"password",value:l,onChange:B=>c(B.target.value),required:!0,className:"h-12 rounded-xl border-border/80 bg-background px-4 pr-12 shadow-sm focus-visible:ring-primary/30",placeholder:"Repeat your password"}),o.jsx("button",{type:"button",onClick:()=>f(!h),className:"absolute right-3 top-1/2 flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-lg text-muted-foreground transition hover:bg-muted/60 hover:text-foreground",tabIndex:-1,"aria-label":h?"Hide confirmation password":"Show confirmation password",children:h?o.jsx(vI,{className:"h-[18px] w-[18px]"}):o.jsx(pl,{className:"h-[18px] w-[18px]"})})]})]}),!e&&Z0t&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"inviteCode",className:"text-sm font-medium text-foreground",children:"Invite code"}),o.jsx(Ue,{id:"inviteCode",type:"text",value:p,onChange:B=>m(B.target.value),required:!0,className:"h-12 rounded-xl border-border/80 bg-background px-4 shadow-sm focus-visible:ring-primary/30",placeholder:"Enter your beta invite code"})]}),!e&&o.jsx("div",{className:"rounded-xl border border-border/70 bg-muted/20 p-3.5",children:o.jsxs(b1e,{id:"terms-consent",checked:g,onCheckedChange:y,required:!0,children:["I agree to the"," ",o.jsx(Nt,{to:"/legal?tab=terms",className:"font-medium text-primary hover:underline",target:"_blank",children:"Terms of Service"})," ","and acknowledge the"," ",o.jsx(Nt,{to:"/legal?tab=privacy",className:"font-medium text-primary hover:underline",target:"_blank",children:"Privacy Policy"}),"."]})}),b&&o.jsx(yf,{className:"border-destructive/40 bg-destructive/5",children:o.jsx(vf,{className:"text-destructive",children:b})}),o.jsx(me,{type:"submit",disabled:x||!e&&!g,className:"h-12 w-full rounded-xl text-base font-semibold shadow-sm",children:x?"Loading...":e?"Sign In":"Create Account"}),!e&&o.jsx("p",{className:"text-center text-xs leading-5 text-muted-foreground",children:"We'll send you account-related emails and occasional product updates. You can unsubscribe anytime."})]}),o.jsx("div",{className:"mt-7 border-t border-border/70 pt-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:[e?"Don't have an account?":"Already have an account?"," ",o.jsx("button",{type:"button",onClick:V,className:"font-semibold text-primary transition hover:text-primary-hover",children:e?"Create one":"Sign in"})]})})]})}const ewt=()=>{const{user:t,loading:e}=Ht(),r=Or(),[n]=uj(),i=n.get("mode")!=="signup";return S.useEffect(()=>{t&&!e&&r("/dashboard")},[t,e,r]),e?o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Ri,{}),o.jsx("main",{className:"flex min-h-[65vh] items-center justify-center pt-20",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-2 border-primary/20 border-b-primary"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})]})}),o.jsx(Ii,{})]}):t?null:o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{title:i?"Sign In | Academly.ai":"Create Account | Academly.ai",description:"Access your Academly thesis and research workspace.",canonical:"https://academly.ai/login",noIndex:!0}),o.jsx(Ri,{}),o.jsx("main",{className:"pt-20",children:o.jsxs("section",{className:"relative overflow-hidden border-b border-border/60",children:[o.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 -z-10 mx-auto grid h-[620px] w-full grid-cols-2 -space-x-52 overflow-hidden opacity-20 md:opacity-25",children:[o.jsx("div",{className:"h-[380px] blur-[106px] bg-gradient-to-br from-primary to-purple-400"}),o.jsx("div",{className:"h-[300px] blur-[106px] bg-gradient-to-r from-cyan-400 to-sky-300"})]}),o.jsx("div",{className:"mx-auto max-w-[1320px] px-5 py-10 sm:px-6 md:py-14 lg:px-8 lg:py-16",children:o.jsx("div",{className:"overflow-hidden rounded-[30px] border border-border/70 bg-background shadow-sm",children:o.jsxs("div",{className:"grid lg:grid-cols-[1.04fr_0.96fr]",children:[o.jsxs("div",{className:"relative hidden overflow-hidden border-r border-border/60 bg-gradient-to-br from-primary/[0.07] via-background to-primary/[0.02] p-8 lg:flex lg:items-center xl:p-12",children:[o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute -left-20 top-20 h-80 w-80 rounded-full bg-primary/[0.10] blur-[110px]"}),o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute bottom-0 right-0 h-72 w-72 rounded-full bg-primary/[0.07] blur-[100px]"}),o.jsxs("div",{className:"relative z-10 mx-auto w-full max-w-xl",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-primary",children:"Academic writing with traceable evidence"}),o.jsx("h1",{className:"mt-5 max-w-lg text-[2.8rem] font-bold leading-[1.04] tracking-[-0.04em] text-foreground xl:text-[3.4rem]",children:"Stay close to your sources while you write."}),o.jsx("p",{className:"mt-5 max-w-lg text-base leading-7 text-muted-foreground",children:"Academly keeps your academic writing connected to the source material behind it, from first draft to final citation."}),o.jsxs("div",{className:"relative mt-9",children:[o.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-12 top-12 -z-10 h-44 rounded-full bg-primary/[0.10] blur-[85px]"}),o.jsxs("div",{className:"rounded-[26px] border border-border/70 bg-background/90 p-5 shadow-[0_28px_80px_-42px_hsl(var(--primary)/0.28)] backdrop-blur-sm",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-border/70 pb-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(jr,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Original source evidence"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Research article · p. 24"})]})]}),o.jsx("span",{className:"rounded-full bg-emerald-500/10 px-2.5 py-1 text-[11px] font-semibold text-emerald-600",children:"Verified"})]}),o.jsxs("div",{className:"mt-5 grid gap-4 xl:grid-cols-[1.15fr_0.85fr]",children:[o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[o.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[o.jsx(nr,{className:"h-4 w-4 text-primary"}),o.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Source passage"})]}),o.jsxs("div",{className:"space-y-2.5",children:[o.jsx("div",{className:"h-2 w-full rounded bg-muted-foreground/15"}),o.jsx("div",{className:"h-2 w-11/12 rounded bg-muted-foreground/15"}),o.jsxs("div",{className:"rounded-lg border-l-2 border-primary bg-primary/[0.07] px-3 py-3",children:[o.jsx("div",{className:"h-2 w-full rounded bg-primary/30"}),o.jsx("div",{className:"mt-2 h-2 w-5/6 rounded bg-primary/25"}),o.jsx("div",{className:"mt-2 h-2 w-4/6 rounded bg-primary/20"})]}),o.jsx("div",{className:"h-2 w-8/12 rounded bg-muted-foreground/15"})]})]}),o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-4",children:[o.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Citation evidence"}),o.jsxs("div",{className:"mt-4 space-y-3",children:[o.jsxs("div",{className:"flex items-start gap-2.5",children:[o.jsx("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-emerald-500/10",children:o.jsx(kr,{className:"h-3.5 w-3.5 text-emerald-600"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-foreground",children:"Exact page reference"}),o.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Linked back to the original PDF"})]})]}),o.jsxs("div",{className:"flex items-start gap-2.5",children:[o.jsx("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10",children:o.jsx(nr,{className:"h-3.5 w-3.5 text-primary"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-foreground",children:"Your own sources"}),o.jsx("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Evidence from uploaded research"})]})]})]})]})]})]})]}),o.jsxs("div",{className:"mt-7 flex flex-wrap gap-x-5 gap-y-3 text-sm text-muted-foreground",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(nr,{className:"h-4 w-4 text-primary"}),o.jsx("span",{children:"Your sources"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(kr,{className:"h-4 w-4 text-primary"}),o.jsx("span",{children:"Traceable evidence"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(UM,{className:"h-4 w-4 text-primary"}),o.jsx("span",{children:"GDPR compliant"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Jhe,{className:"h-4 w-4 text-primary"}),o.jsx("span",{children:"EU hosted"})]})]})]})]}),o.jsx("div",{className:"flex items-center bg-background px-5 py-10 sm:px-8 md:py-12 lg:px-10 xl:px-14",children:o.jsx("div",{className:"mx-auto w-full max-w-md",children:o.jsx(J0t,{defaultIsLogin:i})})})]})})})]})}),o.jsx(Ii,{})]})},twt=()=>{const t=Or(),[e,r]=S.useState(""),[n,s]=S.useState(""),[i,a]=S.useState(!1),[l,c]=S.useState(!1),[u,d]=S.useState(!1),[h,f]=S.useState(""),[p,m]=S.useState(!1);S.useEffect(()=>{const{data:{subscription:y}}=pe.auth.onAuthStateChange((x,v)=>{x==="PASSWORD_RECOVERY"||(x==="SIGNED_OUT"||!v&&!window.location.hash.includes("access_token"))&&t("/login")});return()=>y.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:y}=await pe.auth.updateUser({password:e});if(y)throw y;m(!0),setTimeout(()=>t("/login"),3e3)}catch(y){f(y.message||"Failed to update password")}finally{d(!1)}};return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{title:"Reset Password | Academly.ai",description:"Private page on Academly.ai.",canonical:"https://academly.ai/reset-password",noIndex:!0}),o.jsx(Ri,{}),o.jsxs("div",{className:"fixed inset-0 -z-10",children:[o.jsx("div",{className:"absolute top-20 left-1/4 w-72 h-72 bg-primary/20 rounded-full blur-3xl"}),o.jsx("div",{className:"absolute top-40 right-1/4 w-96 h-96 bg-purple-500/10 rounded-full blur-3xl"})]}),o.jsx("section",{className:"pt-32 pb-20",children:o.jsx(Kn,{children:o.jsx("div",{className:"max-w-md mx-auto",children:o.jsxs(Ze,{children:[o.jsxs(Ot,{className:"text-center",children:[o.jsx(Ft,{className:"text-2xl",children:"Set new password"}),o.jsx(Es,{children:"Enter your new password below."})]}),o.jsx(st,{children:p?o.jsxs("div",{className:"flex flex-col items-center gap-3 py-6 text-center",children:[o.jsx(uc,{className:"w-12 h-12 text-green-500"}),o.jsx("p",{className:"text-lg font-medium",children:"Password updated successfully!"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Redirecting to login…"})]}):o.jsxs("form",{onSubmit:y=>{y.preventDefault(),g()},className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"password",children:"New Password"}),o.jsxs("div",{className:"relative",children:[o.jsx(Ue,{id:"password",type:i?"text":"password",value:e,onChange:y=>r(y.target.value),placeholder:"Min. 6 characters",required:!0}),o.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?o.jsx(vI,{className:"w-4 h-4"}):o.jsx(pl,{className:"w-4 h-4"})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"confirm",children:"Confirm Password"}),o.jsxs("div",{className:"relative",children:[o.jsx(Ue,{id:"confirm",type:l?"text":"password",value:n,onChange:y=>s(y.target.value),placeholder:"Repeat password",required:!0}),o.jsx("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",onClick:()=>c(!l),children:l?o.jsx(vI,{className:"w-4 h-4"}):o.jsx(pl,{className:"w-4 h-4"})})]})]}),h&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[o.jsx(af,{className:"w-4 h-4 shrink-0"}),h]}),o.jsx(me,{type:"submit",className:"w-full",disabled:u,children:u?"Updating…":"Update Password"})]})})]})})})})]})},hU="id,slug,language,title,excerpt,category,cluster,tags,author_name,reading_time,cover_image,og_image,featured,published_at";function rwt(t){return tD({queryKey:["articles","list","all"],queryFn:async()=>{let e=pe.from("articles").select(hU).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 nwt(t){return tD({queryKey:["article",t],enabled:!!t,queryFn:async()=>{const{data:e,error:r}=await pe.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([pe.from("article_faq").select("*").eq("article_id",e.id).order("order_index",{ascending:!0}),swt(e)]);return{article:e,faqs:n??[],related:s}}})}async function swt(t){var s;let e=pe.from("articles").select(hU).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 pe.from("articles").select(hU).eq("status","published").eq("language",t.language).neq("id",t.id).overlaps("tags",t.tags).limit(3),a=new Set(n.map(l=>l.id));for(const l of i??[])!a.has(l.id)&&n.length<3&&n.push(l)}return n}const iwt=(t,e)=>t?new Date(t).toLocaleDateString(e==="de"?"de-DE":"en-US",{year:"numeric",month:"short",day:"numeric"}):null,Y1e=({article:t})=>{const e=iwt(t.published_at,t.language),r=t.cover_image||t.og_image;return o.jsxs(Nt,{to:`/blog/${t.slug}`,className:"group flex h-full flex-col overflow-hidden rounded-2xl border border-border/70 bg-card shadow-sm transition duration-200 hover:-translate-y-0.5 hover:border-primary/20 hover:shadow-md",children:[o.jsxs("div",{className:"relative aspect-[16/9] overflow-hidden bg-gradient-to-br from-primary/[0.10] via-background to-primary/[0.035]",children:[r?o.jsx("img",{src:r,alt:t.title,className:"h-full w-full object-cover transition duration-500 group-hover:scale-[1.02]",loading:"lazy"}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-2xl border border-primary/10 bg-background/85 text-primary shadow-sm",children:o.jsx(nr,{className:"h-7 w-7"})})}),t.category&&o.jsx("span",{className:"absolute left-4 top-4 rounded-full border border-white/30 bg-background/90 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.12em] text-primary shadow-sm backdrop-blur-sm",children:t.category})]}),o.jsxs("div",{className:"flex flex-1 flex-col p-5 md:p-6",children:[o.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[e&&o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(yI,{className:"h-3.5 w-3.5"}),e]}),o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(sg,{className:"h-3.5 w-3.5"}),t.reading_time??5," min"]})]}),o.jsx("h2",{className:"text-xl font-semibold leading-7 tracking-tight text-foreground transition-colors group-hover:text-primary",children:t.title}),t.excerpt&&o.jsx("p",{className:"mt-3 line-clamp-3 text-sm leading-6 text-muted-foreground",children:t.excerpt}),o.jsx("div",{className:"mt-auto pt-5",children:o.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-semibold text-primary",children:[t.language==="de"?"Artikel lesen":"Read article",o.jsx(As,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})})]})]})},awt=({articles:t})=>o.jsx("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:t.slice(0,3).map(e=>o.jsx(Y1e,{article:e},e.id))}),hne=[{key:"Researching",icon:KOe},{key:"Writing",icon:tfe},{key:"Citing",icon:ua}],owt={en:{eyebrow:"Academly resources",title:"Research, write and cite with confidence.",intro:"Practical guides for thesis planning, academic writing, research methods and source work.",search:"Search articles and topics…",latest:"Latest from Academly",latestIntro:"Fresh guides, updates and practical academic resources.",browse:"Browse by topic",browseIntro:"Start with the part of your thesis you are working on right now.",empty:"No articles match your search.",desc:{Researching:"Plan your study, develop research questions and work through methodology.",Writing:"Structure chapters, improve academic style and turn ideas into clear arguments.",Citing:"Work confidently with sources, citation rules and academic referencing."}},de:{eyebrow:"Academly Ressourcen",title:"Sicher recherchieren, schreiben und zitieren.",intro:"Praxisnahe Guides für Themenfindung, wissenschaftliches Schreiben, Methoden und Quellenarbeit.",search:"Artikel und Themen durchsuchen…",latest:"Neu bei Academly",latestIntro:"Neue Guides, Updates und praktische Ressourcen für deine Abschlussarbeit.",browse:"Nach Thema stöbern",browseIntro:"Starte bei dem Teil deiner Abschlussarbeit, an dem du gerade arbeitest.",empty:"Keine Artikel passen zu deiner Suche.",desc:{Researching:"Plane deine Studie, entwickle Forschungsfragen und arbeite deine Methodik aus.",Writing:"Strukturiere Kapitel, verbessere deinen Stil und formuliere klare Argumente.",Citing:"Arbeite sicher mit Quellen, Zitierregeln und wissenschaftlichen Nachweisen."}}},lwt=({language:t,articles:e,onLanguageChange:r})=>{const n=owt[t],[s,i]=S.useState(""),[a,l]=S.useState(new Set),c=s.trim().toLowerCase(),u=S.useMemo(()=>{const p={Researching:[],Writing:[],Citing:[]};for(const m of e){const g=m.category;if(!(g in p)||!m.cluster)continue;let y=p[g].find(x=>x.cluster===m.cluster);y||(y={cluster:m.cluster,articles:[]},p[g].push(y)),y.articles.push(m)}return Object.keys(p).forEach(m=>{p[m].sort((g,y)=>g.cluster.localeCompare(y.cluster)),p[m].forEach(g=>{g.articles.sort((y,x)=>y.title.localeCompare(x.title))}),c&&(p[m]=p[m].map(g=>g.cluster.toLowerCase().includes(c)?g:{...g,articles:g.articles.filter(y=>[y.title,y.excerpt??"",...y.tags??[]].join(" ").toLowerCase().includes(c))}).filter(g=>g.articles.length>0))}),p},[e,c]),d=S.useMemo(()=>[...e].sort((p,m)=>(m.published_at??"").localeCompare(p.published_at??"")).slice(0,3),[e]),h=!!c&&hne.every(({key:p})=>u[p].length===0),f=(p,m)=>{const g=`${p}:${m}`;l(y=>{const x=new Set(y);return x.has(g)?x.delete(g):x.add(g),x})};return o.jsxs("section",{"aria-labelledby":`blog-${t}`,children:[o.jsxs("div",{className:"relative overflow-hidden border-b border-border/60",children:[o.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 top-0 -z-10 mx-auto grid h-[520px] w-full grid-cols-2 -space-x-52 overflow-hidden opacity-20 md:opacity-25",children:[o.jsx("div",{className:"h-[320px] blur-[106px] bg-gradient-to-br from-primary to-purple-400"}),o.jsx("div",{className:"h-[260px] blur-[106px] bg-gradient-to-r from-cyan-400 to-sky-300"})]}),o.jsx("div",{className:"mx-auto max-w-[1180px] px-5 pb-16 pt-16 sm:px-6 md:pb-20 md:pt-20 lg:px-8",children:o.jsxs("div",{className:"mx-auto max-w-3xl text-center",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-primary",children:n.eyebrow}),o.jsx("h2",{id:`blog-${t}`,className:"mt-5 text-4xl font-bold tracking-tight text-foreground md:text-5xl lg:text-[3.6rem] lg:leading-[1.02]",children:n.title}),o.jsx("p",{className:"mx-auto mt-6 max-w-2xl text-base leading-7 text-muted-foreground md:text-lg",children:n.intro}),o.jsx("div",{className:"mt-8 flex justify-center",children:o.jsxs("div",{className:"inline-flex rounded-xl border border-border/70 bg-background/85 p-1 shadow-sm backdrop-blur-sm",children:[o.jsx("button",{type:"button",onClick:()=>r("en"),className:`rounded-lg px-4 py-2 text-sm font-semibold transition ${t==="en"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"English"}),o.jsx("button",{type:"button",onClick:()=>r("de"),className:`rounded-lg px-4 py-2 text-sm font-semibold transition ${t==="de"?"bg-primary text-primary-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"Deutsch"})]})}),o.jsxs("div",{className:"relative mx-auto mt-8 max-w-xl",children:[o.jsx(Ti,{className:"absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),o.jsx("input",{type:"search",value:s,onChange:p=>i(p.target.value),placeholder:n.search,"aria-label":n.search,className:"h-12 w-full rounded-xl border border-border/70 bg-background/90 pl-11 pr-4 text-sm text-foreground shadow-sm outline-none backdrop-blur-sm transition focus:border-primary/40 focus:ring-2 focus:ring-primary/10"})]})]})})]}),o.jsxs("div",{className:"mx-auto max-w-[1180px] px-5 py-16 sm:px-6 md:py-20 lg:px-8",children:[!c&&d.length>0&&o.jsxs("section",{children:[o.jsxs("div",{className:"mb-8",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-primary",children:n.latest}),o.jsx("h3",{className:"mt-2 text-2xl font-bold tracking-tight text-foreground md:text-3xl",children:t==="de"?"Die neuesten Artikel":"Recently published"}),o.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:n.latestIntro})]}),o.jsx(awt,{articles:d})]}),o.jsxs("section",{className:c?"":"mt-20 md:mt-24",children:[o.jsxs("div",{className:"mb-8",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-primary",children:n.browse}),o.jsx("h3",{className:"mt-2 text-2xl font-bold tracking-tight text-foreground md:text-3xl",children:t==="de"?"Was möchtest du bearbeiten?":"What are you working on?"}),o.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:n.browseIntro})]}),h?o.jsx("div",{className:"rounded-2xl border border-border/70 bg-card px-6 py-12 text-center",children:o.jsx("p",{className:"text-sm text-muted-foreground",children:n.empty})}):o.jsx("div",{className:"grid gap-6 lg:grid-cols-3",children:hne.map(({key:p,icon:m})=>{const g=u[p];return o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-6 shadow-sm md:p-7",children:[o.jsxs("div",{className:"flex items-start gap-4",children:[o.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(m,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h4",{className:"text-xl font-semibold tracking-tight text-foreground",children:p}),o.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:n.desc[p]})]})]}),o.jsx("div",{className:"mt-6 border-t border-border/60 pt-5",children:g.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:t==="de"?"Noch keine Artikel in diesem Bereich.":"No articles in this section yet."}):o.jsx("ul",{className:"space-y-4",children:g.map(y=>{const x=!!c||!a.has(`${p}:${y.cluster}`);return o.jsxs("li",{children:[o.jsxs("button",{type:"button",onClick:()=>f(p,y.cluster),"aria-expanded":x,className:"flex w-full items-center justify-between gap-3 text-left",children:[o.jsx("span",{className:"text-sm font-semibold text-foreground transition hover:text-primary",children:y.cluster}),o.jsx(AE,{className:`h-4 w-4 shrink-0 text-muted-foreground transition-transform ${x?"rotate-90":""}`})]}),x&&o.jsx("ul",{className:"mt-3 space-y-2.5",children:y.articles.map(v=>o.jsx("li",{children:o.jsxs(Nt,{to:`/blog/${v.slug}`,className:"group/link flex items-start justify-between gap-3 rounded-lg py-1 text-sm leading-5 text-muted-foreground transition hover:text-primary",children:[o.jsx("span",{children:v.title}),o.jsx(As,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 opacity-0 transition group-hover/link:translate-x-0.5 group-hover/link:opacity-100"})]})},v.id))})]},y.cluster)})})})]},p)})})]})]})]})};function X1e(t,e){S.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 cwt=t=>t==="de"||t==="en"?t:typeof navigator<"u"&&navigator.language.toLowerCase().startsWith("de")?"de":"en",uwt=()=>{const{data:t=[],isLoading:e}=rwt(),[r,n]=uj(),s=S.useMemo(()=>cwt(r.get("lang")),[r]);S.useEffect(()=>{const l=r.get("lang");if(l==="en"||l==="de")return;const c=new URLSearchParams(r);c.set("lang",s),n(c,{replace:!0})},[s,r,n]),X1e(!e);const i=l=>{const c=new URLSearchParams(r);c.set("lang",l),n(c,{replace:!0})},a=t.filter(l=>l.language===s);return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{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"}),o.jsx(Ri,{}),o.jsxs("main",{className:"pt-20",children:[o.jsx("h1",{className:"sr-only",children:"Academly Blog: Thesis Writing Guides"}),o.jsx(lwt,{language:s,articles:a,onLanguageChange:i})]}),o.jsx(Ii,{})]})};function dwt(t,e){const r={};return(t[t.length-1]===""?[...t,""]:t).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const hwt=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,fwt=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,pwt={};function fne(t,e){return(pwt.jsx?fwt:hwt).test(t)}const mwt=/[ \t\n\f\r]/g;function gwt(t){return typeof t=="object"?t.type==="text"?pne(t.value):!1:pne(t)}function pne(t){return t.replace(mwt,"")===""}let nA=class{constructor(e,r,n){this.normal=r,this.property=e,n&&(this.space=n)}};nA.prototype.normal={};nA.prototype.property={};nA.prototype.space=void 0;function Q1e(t,e){const r={},n={};for(const s of t)Object.assign(r,s.property),Object.assign(n,s.normal);return new nA(r,n,e)}function fU(t){return t.toLowerCase()}class Po{constructor(e,r){this.attribute=r,this.property=e}}Po.prototype.attribute="";Po.prototype.booleanish=!1;Po.prototype.boolean=!1;Po.prototype.commaOrSpaceSeparated=!1;Po.prototype.commaSeparated=!1;Po.prototype.defined=!1;Po.prototype.mustUseProperty=!1;Po.prototype.number=!1;Po.prototype.overloadedBoolean=!1;Po.prototype.property="";Po.prototype.spaceSeparated=!1;Po.prototype.space=void 0;let xwt=0;const ir=Lv(),Ms=Lv(),pU=Lv(),tt=Lv(),Cn=Lv(),S0=Lv(),Io=Lv();function Lv(){return 2**++xwt}const mU=Object.freeze(Object.defineProperty({__proto__:null,boolean:ir,booleanish:Ms,commaOrSpaceSeparated:Io,commaSeparated:S0,number:tt,overloadedBoolean:pU,spaceSeparated:Cn},Symbol.toStringTag,{value:"Module"})),k3=Object.keys(mU);class $q extends Po{constructor(e,r,n,s){let i=-1;if(super(e,r),mne(this,"space",s),typeof n=="number")for(;++i<k3.length;){const a=k3[i];mne(this,k3[i],(n&mU[a])===mU[a])}}}$q.prototype.defined=!0;function mne(t,e,r){r&&(t[e]=r)}function Pj(t){const e={},r={};for(const[n,s]of Object.entries(t.properties)){const i=new $q(n,t.transform(t.attributes||{},n),s,t.space);t.mustUseProperty&&t.mustUseProperty.includes(n)&&(i.mustUseProperty=!0),e[n]=i,r[fU(n)]=n,r[fU(i.attribute)]=n}return new nA(e,r,t.space)}const Z1e=Pj({properties:{ariaActiveDescendant:null,ariaAtomic:Ms,ariaAutoComplete:null,ariaBusy:Ms,ariaChecked:Ms,ariaColCount:tt,ariaColIndex:tt,ariaColSpan:tt,ariaControls:Cn,ariaCurrent:null,ariaDescribedBy:Cn,ariaDetails:null,ariaDisabled:Ms,ariaDropEffect:Cn,ariaErrorMessage:null,ariaExpanded:Ms,ariaFlowTo:Cn,ariaGrabbed:Ms,ariaHasPopup:null,ariaHidden:Ms,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Cn,ariaLevel:tt,ariaLive:null,ariaModal:Ms,ariaMultiLine:Ms,ariaMultiSelectable:Ms,ariaOrientation:null,ariaOwns:Cn,ariaPlaceholder:null,ariaPosInSet:tt,ariaPressed:Ms,ariaReadOnly:Ms,ariaRelevant:null,ariaRequired:Ms,ariaRoleDescription:Cn,ariaRowCount:tt,ariaRowIndex:tt,ariaRowSpan:tt,ariaSelected:Ms,ariaSetSize:tt,ariaSort:null,ariaValueMax:tt,ariaValueMin:tt,ariaValueNow:tt,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function J1e(t,e){return e in t?t[e]:e}function eje(t,e){return J1e(t,e.toLowerCase())}const ywt=Pj({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:S0,acceptCharset:Cn,accessKey:Cn,action:null,allow:null,allowFullScreen:ir,allowPaymentRequest:ir,allowUserMedia:ir,alt:null,as:null,async:ir,autoCapitalize:null,autoComplete:Cn,autoFocus:ir,autoPlay:ir,blocking:Cn,capture:null,charSet:null,checked:ir,cite:null,className:Cn,cols:tt,colSpan:null,content:null,contentEditable:Ms,controls:ir,controlsList:Cn,coords:tt|S0,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ir,defer:ir,dir:null,dirName:null,disabled:ir,download:pU,draggable:Ms,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ir,formTarget:null,headers:Cn,height:tt,hidden:pU,high:tt,href:null,hrefLang:null,htmlFor:Cn,httpEquiv:Cn,id:null,imageSizes:null,imageSrcSet:null,inert:ir,inputMode:null,integrity:null,is:null,isMap:ir,itemId:null,itemProp:Cn,itemRef:Cn,itemScope:ir,itemType:Cn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ir,low:tt,manifest:null,max:null,maxLength:tt,media:null,method:null,min:null,minLength:tt,multiple:ir,muted:ir,name:null,nonce:null,noModule:ir,noValidate:ir,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:ir,optimum:tt,pattern:null,ping:Cn,placeholder:null,playsInline:ir,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ir,referrerPolicy:null,rel:Cn,required:ir,reversed:ir,rows:tt,rowSpan:tt,sandbox:Cn,scope:null,scoped:ir,seamless:ir,selected:ir,shadowRootClonable:ir,shadowRootDelegatesFocus:ir,shadowRootMode:null,shape:null,size:tt,sizes:null,slot:null,span:tt,spellCheck:Ms,src:null,srcDoc:null,srcLang:null,srcSet:null,start:tt,step:null,style:null,tabIndex:tt,target:null,title:null,translate:null,type:null,typeMustMatch:ir,useMap:null,value:Ms,width:tt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Cn,axis:null,background:null,bgColor:null,border:tt,borderColor:null,bottomMargin:tt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ir,declare:ir,event:null,face:null,frame:null,frameBorder:null,hSpace:tt,leftMargin:tt,link:null,longDesc:null,lowSrc:null,marginHeight:tt,marginWidth:tt,noResize:ir,noHref:ir,noShade:ir,noWrap:ir,object:null,profile:null,prompt:null,rev:null,rightMargin:tt,rules:null,scheme:null,scrolling:Ms,standby:null,summary:null,text:null,topMargin:tt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:tt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:ir,disableRemotePlayback:ir,prefix:null,property:null,results:tt,security:null,unselectable:null},space:"html",transform:eje}),vwt=Pj({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:Io,accentHeight:tt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:tt,amplitude:tt,arabicForm:null,ascent:tt,attributeName:null,attributeType:null,azimuth:tt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:tt,by:null,calcMode:null,capHeight:tt,className:Cn,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:tt,diffuseConstant:tt,direction:null,display:null,dur:null,divisor:tt,dominantBaseline:null,download:ir,dx:null,dy:null,edgeMode:null,editable:null,elevation:tt,enableBackground:null,end:null,event:null,exponent:tt,externalResourcesRequired:null,fill:null,fillOpacity:tt,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:S0,g2:S0,glyphName:S0,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:tt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:tt,horizOriginX:tt,horizOriginY:tt,id:null,ideographic:tt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:tt,k:tt,k1:tt,k2:tt,k3:tt,k4:tt,kernelMatrix:Io,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:tt,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:tt,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:tt,overlineThickness:tt,paintOrder:null,panose1:null,path:null,pathLength:tt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Cn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:tt,pointsAtY:tt,pointsAtZ:tt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Io,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Io,rev:Io,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Io,requiredFeatures:Io,requiredFonts:Io,requiredFormats:Io,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:tt,specularExponent:tt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:tt,strikethroughThickness:tt,string:null,stroke:null,strokeDashArray:Io,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:tt,strokeOpacity:tt,strokeWidth:null,style:null,surfaceScale:tt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Io,tabIndex:tt,tableValues:null,target:null,targetX:tt,targetY:tt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Io,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:tt,underlineThickness:tt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:tt,values:null,vAlphabetic:tt,vMathematical:tt,vectorEffect:null,vHanging:tt,vIdeographic:tt,version:null,vertAdvY:tt,vertOriginX:tt,vertOriginY:tt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:tt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:J1e}),tje=Pj({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()}}),rje=Pj({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:eje}),nje=Pj({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),bwt={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"},wwt=/[A-Z]/g,gne=/-[a-z]/g,jwt=/^data[-\w.:]+$/i;function Swt(t,e){const r=fU(e);let n=e,s=Po;if(r in t.normal)return t.property[t.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&jwt.test(e)){if(e.charAt(4)==="-"){const i=e.slice(5).replace(gne,Nwt);n="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=e.slice(4);if(!gne.test(i)){let a=i.replace(wwt,_wt);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}s=$q}return new s(n,e)}function _wt(t){return"-"+t.toLowerCase()}function Nwt(t){return t.charAt(1).toUpperCase()}const kwt=Q1e([Z1e,ywt,tje,rje,nje],"html"),Fq=Q1e([Z1e,vwt,tje,rje,nje],"svg");function Cwt(t){return t.join(" ").trim()}var Bq={},xne=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Ewt=/\n/g,Awt=/^\s*/,Twt=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Pwt=/^:\s*/,Iwt=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Rwt=/^[;\s]*/,Owt=/^\s+|\s+$/g,Mwt=`
`,yne="/",vne="*",Qg="",Dwt="comment",Lwt="declaration",$wt=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(Ewt);g&&(r+=g.length);var y=m.lastIndexOf(Mwt);n=~y?m.length-y: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 l(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 y=g[0];return s(y),t=t.slice(y.length),g}}function u(){c(Awt)}function d(m){var g;for(m=m||[];g=h();)g!==!1&&m.push(g);return m}function h(){var m=i();if(!(yne!=t.charAt(0)||vne!=t.charAt(1))){for(var g=2;Qg!=t.charAt(g)&&(vne!=t.charAt(g)||yne!=t.charAt(g+1));)++g;if(g+=2,Qg===t.charAt(g-1))return l("End of comment missing");var y=t.slice(2,g-2);return n+=2,s(y),t=t.slice(g),n+=2,m({type:Dwt,comment:y})}}function f(){var m=i(),g=c(Twt);if(g){if(h(),!c(Pwt))return l("property missing ':'");var y=c(Iwt),x=m({type:Lwt,property:bne(g[0].replace(xne,Qg)),value:y?bne(y[0].replace(xne,Qg)):Qg});return c(Rwt),x}}function p(){var m=[];d(m);for(var g;g=f();)g!==!1&&(m.push(g),d(m));return m}return u(),p()};function bne(t){return t?t.replace(Owt,Qg):Qg}var Fwt=$n&&$n.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Bq,"__esModule",{value:!0});Bq.default=zwt;var Bwt=Fwt($wt);function zwt(t,e){var r=null;if(!t||typeof t!="string")return r;var n=(0,Bwt.default)(t),s=typeof e=="function";return n.forEach(function(i){if(i.type==="declaration"){var a=i.property,l=i.value;s?e(a,l,i):l&&(r=r||{},r[a]=l)}}),r}var kL={};Object.defineProperty(kL,"__esModule",{value:!0});kL.camelCase=void 0;var Uwt=/^--[a-zA-Z0-9_-]+$/,Hwt=/-([a-z])/g,Wwt=/^[^-]+$/,Vwt=/^-(webkit|moz|ms|o|khtml)-/,qwt=/^-(ms)-/,Gwt=function(t){return!t||Wwt.test(t)||Uwt.test(t)},Kwt=function(t,e){return e.toUpperCase()},wne=function(t,e){return"".concat(e,"-")},Ywt=function(t,e){return e===void 0&&(e={}),Gwt(t)?t:(t=t.toLowerCase(),e.reactCompat?t=t.replace(qwt,wne):t=t.replace(Vwt,wne),t.replace(Hwt,Kwt))};kL.camelCase=Ywt;var Xwt=$n&&$n.__importDefault||function(t){return t&&t.__esModule?t:{default:t}},Qwt=Xwt(Bq),Zwt=kL;function gU(t,e){var r={};return!t||typeof t!="string"||(0,Qwt.default)(t,function(n,s){n&&s&&(r[(0,Zwt.camelCase)(n,e)]=s)}),r}gU.default=gU;var Jwt=gU;const e1t=Er(Jwt),sje=ije("end"),zq=ije("start");function ije(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 t1t(t){const e=zq(t),r=sje(t);if(e&&r)return{start:e,end:r}}function H_(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?jne(t.position):"start"in t||"end"in t?jne(t):"line"in t||"column"in t?xU(t):""}function xU(t){return Sne(t&&t.line)+":"+Sne(t&&t.column)}function jne(t){return xU(t&&t.start)+"-"+xU(t&&t.end)}function Sne(t){return t&&typeof t=="number"?t:1}class Ta 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 l=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=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=l?l.line:void 0,this.name=H_(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}}Ta.prototype.file="";Ta.prototype.name="";Ta.prototype.reason="";Ta.prototype.message="";Ta.prototype.stack="";Ta.prototype.column=void 0;Ta.prototype.line=void 0;Ta.prototype.ancestors=void 0;Ta.prototype.cause=void 0;Ta.prototype.fatal=void 0;Ta.prototype.place=void 0;Ta.prototype.ruleId=void 0;Ta.prototype.source=void 0;const Uq={}.hasOwnProperty,r1t=new Map,n1t=/[A-Z]/g,s1t=new Set(["table","tbody","thead","tfoot","tr"]),i1t=new Set(["td","th"]),aje="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function a1t(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=p1t(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=f1t(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"?Fq:kwt,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},i=oje(s,t,void 0);return i&&typeof i!="string"?i:s.create(t,s.Fragment,{children:i||void 0},void 0)}function oje(t,e,r){if(e.type==="element")return o1t(t,e,r);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return l1t(t,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return u1t(t,e,r);if(e.type==="mdxjsEsm")return c1t(t,e);if(e.type==="root")return d1t(t,e,r);if(e.type==="text")return h1t(t,e)}function o1t(t,e,r){const n=t.schema;let s=n;e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(s=Fq,t.schema=s),t.ancestors.push(e);const i=cje(t,e.tagName,!1),a=m1t(t,e);let l=Wq(t,e);return s1t.has(e.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!gwt(c):!0})),lje(t,a,i,e),Hq(a,l),t.ancestors.pop(),t.schema=n,t.create(e,i,a,r)}function l1t(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)}wk(t,e.position)}function c1t(t,e){if(e.data&&e.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(e.data.estree);wk(t,e.position)}function u1t(t,e,r){const n=t.schema;let s=n;e.name==="svg"&&n.space==="html"&&(s=Fq,t.schema=s),t.ancestors.push(e);const i=e.name===null?t.Fragment:cje(t,e.name,!0),a=g1t(t,e),l=Wq(t,e);return lje(t,a,i,e),Hq(a,l),t.ancestors.pop(),t.schema=n,t.create(e,i,a,r)}function d1t(t,e,r){const n={};return Hq(n,Wq(t,e)),t.create(e,t.Fragment,n,r)}function h1t(t,e){return e.value}function lje(t,e,r,n){typeof r!="string"&&r!==t.Fragment&&t.passNode&&(e.node=n)}function Hq(t,e){if(e.length>0){const r=e.length>1?e:e[0];r&&(t.children=r)}}function f1t(t,e,r){return n;function n(s,i,a,l){const u=Array.isArray(a.children)?r:e;return l?u(i,a,l):u(i,a)}}function p1t(t,e){return r;function r(n,s,i,a){const l=Array.isArray(i.children),c=zq(n);return e(s,i,a,l,{columnNumber:c?c.column-1:void 0,fileName:t,lineNumber:c?c.line:void 0},void 0)}}function m1t(t,e){const r={};let n,s;for(s in e.properties)if(s!=="children"&&Uq.call(e.properties,s)){const i=x1t(t,s,e.properties[s]);if(i){const[a,l]=i;t.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&i1t.has(e.tagName)?n=l:r[a]=l}}if(n){const i=r.style||(r.style={});i[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return r}function g1t(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 l=a.properties[0];l.type,Object.assign(r,t.evaluater.evaluateExpression(l.argument))}else wk(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 l=n.value.data.estree.body[0];l.type,i=t.evaluater.evaluateExpression(l.expression)}else wk(t,e.position);else i=n.value===null?!0:n.value;r[s]=i}return r}function Wq(t,e){const r=[];let n=-1;const s=t.passKeys?new Map:r1t;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 l=oje(t,i,a);l!==void 0&&r.push(l)}return r}function x1t(t,e,r){const n=Swt(t.schema,e);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=n.commaSeparated?dwt(r):Cwt(r)),n.property==="style"){let s=typeof r=="object"?r:y1t(t,String(r));return t.stylePropertyNameCase==="css"&&(s=v1t(s)),["style",s]}return[t.elementAttributeNameCase==="react"&&n.space?bwt[n.property]||n.property:n.attribute,r]}}function y1t(t,e){try{return e1t(e,{reactCompat:!0})}catch(r){if(t.ignoreInvalidStyle)return{};const n=r,s=new Ta("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=aje+"#cannot-parse-style-attribute",s}}function cje(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 l=fne(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}n=a}else n=fne(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(n.type==="Literal"){const s=n.value;return Uq.call(t.components,s)?t.components[s]:s}if(t.evaluater)return t.evaluater.evaluateExpression(n);wk(t)}function wk(t,e){const r=new Ta("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=aje+"#cannot-handle-mdx-estrees-without-createevaluater",r}function v1t(t){const e={};let r;for(r in t)Uq.call(t,r)&&(e[b1t(r)]=t[r]);return e}function b1t(t){let e=t.replace(n1t,w1t);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function w1t(t){return"-"+t.toLowerCase()}const C3={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"]},j1t={};function Vq(t,e){const r=j1t,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,s=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return uje(t,n,s)}function uje(t,e,r){if(S1t(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 _ne(t.children,e,r)}return Array.isArray(t)?_ne(t,e,r):""}function _ne(t,e,r){const n=[];let s=-1;for(;++s<t.length;)n[s]=uje(t[s],e,r);return n.join("")}function S1t(t){return!!(t&&typeof t=="object")}const Nne=document.createElement("i");function qq(t){const e="&"+t+";";Nne.innerHTML=e;const r=Nne.textContent;return r.charCodeAt(r.length-1)===59&&t!=="semi"||r===e?!1:r}function cl(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 Hl(t,e){return t.length>0?(cl(t,t.length,0,e),t):e}const kne={}.hasOwnProperty;function dje(t){const e={};let r=-1;for(;++r<t.length;)_1t(e,t[r]);return e}function _1t(t,e){let r;for(r in e){const s=(kne.call(t,r)?t[r]:void 0)||(t[r]={}),i=e[r];let a;if(i)for(a in i){kne.call(s,a)||(s[a]=[]);const l=i[a];N1t(s[a],Array.isArray(l)?l:l?[l]:[])}}}function N1t(t,e){let r=-1;const n=[];for(;++r<e.length;)(e[r].add==="after"?t:n).push(e[r]);cl(t,0,0,n)}function hje(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 Qc(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Va=xg(/[A-Za-z]/),Na=xg(/[\dA-Za-z]/),k1t=xg(/[#-'*+\--9=?A-Z^-~]/);function qR(t){return t!==null&&(t<32||t===127)}const yU=xg(/\d/),C1t=xg(/[\dA-Fa-f]/),E1t=xg(/[!-/:-@[-`{-~]/);function $t(t){return t!==null&&t<-2}function Sn(t){return t!==null&&(t<0||t===32)}function vr(t){return t===-2||t===-1||t===32}const CL=xg(new RegExp("\\p{P}|\\p{S}","u")),fv=xg(/\s/);function xg(t){return e;function e(r){return r!==null&&r>-1&&t.test(String.fromCharCode(r))}}function Ij(t){const e=[];let r=-1,n=0,s=0;for(;++r<t.length;){const i=t.charCodeAt(r);let a="";if(i===37&&Na(t.charCodeAt(r+1))&&Na(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 l=t.charCodeAt(r+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),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 Lr(t,e,r,n){const s=n?n-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(c){return vr(c)?(t.enter(r),l(c)):e(c)}function l(c){return vr(c)&&i++<s?(t.consume(c),l):(t.exit(r),e(c))}}const A1t={tokenize:T1t};function T1t(t){const e=t.attempt(this.parser.constructs.contentInitial,n,s);let r;return e;function n(l){if(l===null){t.consume(l);return}return t.enter("lineEnding"),t.consume(l),t.exit("lineEnding"),Lr(t,e,"linePrefix")}function s(l){return t.enter("paragraph"),i(l)}function i(l){const c=t.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=c),r=c,a(l)}function a(l){if(l===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(l);return}return $t(l)?(t.consume(l),t.exit("chunkText"),i):(t.consume(l),a)}}const P1t={tokenize:I1t},Cne={tokenize:R1t};function I1t(t){const e=this,r=[];let n=0,s,i,a;return l;function l(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 j=w,N;for(;j--;)if(e.events[j][0]==="exit"&&e.events[j][1].type==="chunkFlow"){N=e.events[j][1].end;break}x(n);let C=w;for(;C<e.events.length;)e.events[C][1].end={...N},C++;return cl(e.events,j+1,0,e.events.slice(w)),e.events.length=C,u(b)}return l(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(Cne,d,h)(b)}function d(b){return s&&v(),x(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(Cne,p,m)(b)}function p(b){return n++,r.push([e.currentConstruct,e.containerState]),f(b)}function m(b){if(b===null){s&&v(),x(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){y(t.exit("chunkFlow"),!0),x(0),t.consume(b);return}return $t(b)?(t.consume(b),y(t.exit("chunkFlow")),n=0,e.interrupt=void 0,l):(t.consume(b),g)}function y(b,w){const j=e.sliceStream(b);if(w&&j.push(null),b.previous=i,i&&(i.next=b),i=b,s.defineSkip(b.start),s.write(j),e.parser.lazy[b.start.line]){let N=s.events.length;for(;N--;)if(s.events[N][1].start.offset<a&&(!s.events[N][1].end||s.events[N][1].end.offset>a))return;const C=e.events.length;let A=C,E,O;for(;A--;)if(e.events[A][0]==="exit"&&e.events[A][1].type==="chunkFlow"){if(E){O=e.events[A][1].end;break}E=!0}for(x(n),N=C;N<e.events.length;)e.events[N][1].end={...O},N++;cl(e.events,A+1,0,e.events.slice(C)),e.events.length=N}}function x(b){let w=r.length;for(;w-- >b;){const j=r[w];e.containerState=j[1],j[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 R1t(t,e,r){return Lr(t,t.attempt(this.parser.constructs.document,e,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function D1(t){if(t===null||Sn(t)||fv(t))return 1;if(CL(t))return 2}function EL(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 vU={name:"attention",resolveAll:O1t,tokenize:M1t};function O1t(t,e){let r=-1,n,s,i,a,l,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};Ene(h,-c),Ene(f,c),a={type:c>1?"strongSequence":"emphasisSequence",start:h,end:{...t[n][1].end}},l={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:{...l.end}},t[n][1].end={...a.start},t[r][1].start={...l.end},u=[],t[n][1].end.offset-t[n][1].start.offset&&(u=Hl(u,[["enter",t[n][1],e],["exit",t[n][1],e]])),u=Hl(u,[["enter",s,e],["enter",a,e],["exit",a,e],["enter",i,e]]),u=Hl(u,EL(e.parser.constructs.insideSpan.null,t.slice(n+1,r),e)),u=Hl(u,[["exit",i,e],["enter",l,e],["exit",l,e],["exit",s,e]]),t[r][1].end.offset-t[r][1].start.offset?(d=2,u=Hl(u,[["enter",t[r][1],e],["exit",t[r][1],e]])):d=0,cl(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 M1t(t,e){const r=this.parser.constructs.attentionMarkers.null,n=this.previous,s=D1(n);let i;return a;function a(c){return i=c,t.enter("attentionSequence"),l(c)}function l(c){if(c===i)return t.consume(c),l;const u=t.exit("attentionSequence"),d=D1(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 Ene(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const D1t={name:"autolink",tokenize:L1t};function L1t(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 Va(p)?(t.consume(p),a):p===64?r(p):u(p)}function a(p){return p===43||p===45||p===46||Na(p)?(n=1,l(p)):u(p)}function l(p){return p===58?(t.consume(p),n=0,c):(p===43||p===45||p===46||Na(p))&&n++<32?(t.consume(p),l):(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||qR(p)?r(p):(t.consume(p),c)}function u(p){return p===64?(t.consume(p),d):k1t(p)?(t.consume(p),u):r(p)}function d(p){return Na(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||Na(p))&&n++<63){const m=p===45?f:h;return t.consume(p),m}return r(p)}}const sA={partial:!0,tokenize:$1t};function $1t(t,e,r){return n;function n(i){return vr(i)?Lr(t,s,"linePrefix")(i):s(i)}function s(i){return i===null||$t(i)?e(i):r(i)}}const fje={continuation:{tokenize:B1t},exit:z1t,name:"blockQuote",tokenize:F1t};function F1t(t,e,r){const n=this;return s;function s(a){if(a===62){const l=n.containerState;return l.open||(t.enter("blockQuote",{_container:!0}),l.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(a),t.exit("blockQuoteMarker"),i}return r(a)}function i(a){return vr(a)?(t.enter("blockQuotePrefixWhitespace"),t.consume(a),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(a))}}function B1t(t,e,r){const n=this;return s;function s(a){return vr(a)?Lr(t,i,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return t.attempt(fje,e,r)(a)}}function z1t(t){t.exit("blockQuote")}const pje={name:"characterEscape",tokenize:U1t};function U1t(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 E1t(i)?(t.enter("characterEscapeValue"),t.consume(i),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):r(i)}}const mje={name:"characterReference",tokenize:H1t};function H1t(t,e,r){const n=this;let s=0,i,a;return l;function l(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=Na,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=C1t,d):(t.enter("characterReferenceValue"),i=7,a=yU,d(h))}function d(h){if(h===59&&s){const f=t.exit("characterReferenceValue");return a===Na&&!qq(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 Ane={partial:!0,tokenize:V1t},Tne={concrete:!0,name:"codeFenced",tokenize:W1t};function W1t(t,e,r){const n=this,s={partial:!0,tokenize:j};let i=0,a=0,l;return c;function c(N){return u(N)}function u(N){const C=n.events[n.events.length-1];return i=C&&C[1].type==="linePrefix"?C[2].sliceSerialize(C[1],!0).length:0,l=N,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),d(N)}function d(N){return N===l?(a++,t.consume(N),d):a<3?r(N):(t.exit("codeFencedFenceSequence"),vr(N)?Lr(t,h,"whitespace")(N):h(N))}function h(N){return N===null||$t(N)?(t.exit("codeFencedFence"),n.interrupt?e(N):t.check(Ane,g,w)(N)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),f(N))}function f(N){return N===null||$t(N)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),h(N)):vr(N)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Lr(t,p,"whitespace")(N)):N===96&&N===l?r(N):(t.consume(N),f)}function p(N){return N===null||$t(N)?h(N):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),m(N))}function m(N){return N===null||$t(N)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),h(N)):N===96&&N===l?r(N):(t.consume(N),m)}function g(N){return t.attempt(s,w,y)(N)}function y(N){return t.enter("lineEnding"),t.consume(N),t.exit("lineEnding"),x}function x(N){return i>0&&vr(N)?Lr(t,v,"linePrefix",i+1)(N):v(N)}function v(N){return N===null||$t(N)?t.check(Ane,g,w)(N):(t.enter("codeFlowValue"),b(N))}function b(N){return N===null||$t(N)?(t.exit("codeFlowValue"),v(N)):(t.consume(N),b)}function w(N){return t.exit("codeFenced"),e(N)}function j(N,C,A){let E=0;return O;function O(D){return N.enter("lineEnding"),N.consume(D),N.exit("lineEnding"),$}function $(D){return N.enter("codeFencedFence"),vr(D)?Lr(N,T,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):T(D)}function T(D){return D===l?(N.enter("codeFencedFenceSequence"),M(D)):A(D)}function M(D){return D===l?(E++,N.consume(D),M):E>=a?(N.exit("codeFencedFenceSequence"),vr(D)?Lr(N,k,"whitespace")(D):k(D)):A(D)}function k(D){return D===null||$t(D)?(N.exit("codeFencedFence"),C(D)):A(D)}}}function V1t(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 E3={name:"codeIndented",tokenize:G1t},q1t={partial:!0,tokenize:K1t};function G1t(t,e,r){const n=this;return s;function s(u){return t.enter("codeIndented"),Lr(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):$t(u)?t.attempt(q1t,a,c)(u):(t.enter("codeFlowValue"),l(u))}function l(u){return u===null||$t(u)?(t.exit("codeFlowValue"),a(u)):(t.consume(u),l)}function c(u){return t.exit("codeIndented"),e(u)}}function K1t(t,e,r){const n=this;return s;function s(a){return n.parser.lazy[n.now().line]?r(a):$t(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),s):Lr(t,i,"linePrefix",5)(a)}function i(a){const l=n.events[n.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(a):$t(a)?s(a):r(a)}}const Y1t={name:"codeText",previous:Q1t,resolve:X1t,tokenize:Z1t};function X1t(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 Q1t(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Z1t(t,e,r){let n=0,s,i;return a;function a(h){return t.enter("codeText"),t.enter("codeTextSequence"),l(h)}function l(h){return h===96?(t.consume(h),n++,l):(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)):$t(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||$t(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 J1t{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&&hS(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),hS(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),hS(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);hS(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);hS(this.left,r.reverse())}}}function hS(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 gje(t){const e={};let r=-1,n,s,i,a,l,c,u;const d=new J1t(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,ejt(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},l=d.slice(s,r),l.unshift(n),d.splice(s,r-s+1,l))}}return cl(t,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function ejt(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 l=a.events,c=[],u={};let d,h,f=-1,p=r,m=0,g=0;const y=[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<l.length;)l[f][0]==="exit"&&l[f-1][0]==="enter"&&l[f][1].type===l[f-1][1].type&&l[f][1].start.line!==l[f][1].end.line&&(g=f+1,y.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):y.pop(),f=y.length;f--;){const x=l.slice(y[f],y[f+1]),v=i.pop();c.push([v,v+x.length-1]),t.splice(v,2,x)}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 tjt={resolve:njt,tokenize:sjt},rjt={partial:!0,tokenize:ijt};function njt(t){return gje(t),t}function sjt(t,e){let r;return n;function n(l){return t.enter("content"),r=t.enter("chunkContent",{contentType:"content"}),s(l)}function s(l){return l===null?i(l):$t(l)?t.check(rjt,a,i)(l):(t.consume(l),s)}function i(l){return t.exit("chunkContent"),t.exit("content"),e(l)}function a(l){return t.consume(l),t.exit("chunkContent"),r.next=t.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,s}}function ijt(t,e,r){const n=this;return s;function s(a){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),Lr(t,i,"linePrefix")}function i(a){if(a===null||$t(a))return r(a);const l=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?e(a):t.interrupt(n.parser.constructs.flow,r,e)(a)}}function xje(t,e,r,n,s,i,a,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return h;function h(x){return x===60?(t.enter(n),t.enter(s),t.enter(i),t.consume(x),t.exit(i),f):x===null||x===32||x===41||qR(x)?r(x):(t.enter(n),t.enter(a),t.enter(l),t.enter("chunkString",{contentType:"string"}),g(x))}function f(x){return x===62?(t.enter(i),t.consume(x),t.exit(i),t.exit(s),t.exit(n),e):(t.enter(l),t.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(t.exit("chunkString"),t.exit(l),f(x)):x===null||x===60||$t(x)?r(x):(t.consume(x),x===92?m:p)}function m(x){return x===60||x===62||x===92?(t.consume(x),p):p(x)}function g(x){return!d&&(x===null||x===41||Sn(x))?(t.exit("chunkString"),t.exit(l),t.exit(a),t.exit(n),e(x)):d<u&&x===40?(t.consume(x),d++,g):x===41?(t.consume(x),d--,g):x===null||x===32||x===40||qR(x)?r(x):(t.consume(x),x===92?y:g)}function y(x){return x===40||x===41||x===92?(t.consume(x),g):g(x)}}function yje(t,e,r,n,s,i){const a=this;let l=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 l>999||p===null||p===91||p===93&&!c||p===94&&!l&&"_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):$t(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||$t(p)||l++>999?(t.exit("chunkString"),d(p)):(t.consume(p),c||(c=!vr(p)),p===92?f:h)}function f(p){return p===91||p===92||p===93?(t.consume(p),l++,h):h(p)}}function vje(t,e,r,n,s,i){let a;return l;function l(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):$t(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),Lr(t,u,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===a||f===null||$t(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 W_(t,e){let r;return n;function n(s){return $t(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),r=!0,n):vr(s)?Lr(t,n,r?"linePrefix":"lineSuffix")(s):e(s)}}const ajt={name:"definition",tokenize:ljt},ojt={partial:!0,tokenize:cjt};function ljt(t,e,r){const n=this;let s;return i;function i(p){return t.enter("definition"),a(p)}function a(p){return yje.call(n,t,l,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function l(p){return s=Qc(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 Sn(p)?W_(t,u)(p):u(p)}function u(p){return xje(t,d,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return t.attempt(ojt,h,h)(p)}function h(p){return vr(p)?Lr(t,f,"whitespace")(p):f(p)}function f(p){return p===null||$t(p)?(t.exit("definition"),n.parser.defined.push(s),e(p)):r(p)}}function cjt(t,e,r){return n;function n(l){return Sn(l)?W_(t,s)(l):r(l)}function s(l){return vje(t,i,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return vr(l)?Lr(t,a,"whitespace")(l):a(l)}function a(l){return l===null||$t(l)?e(l):r(l)}}const ujt={name:"hardBreakEscape",tokenize:djt};function djt(t,e,r){return n;function n(i){return t.enter("hardBreakEscape"),t.consume(i),s}function s(i){return $t(i)?(t.exit("hardBreakEscape"),e(i)):r(i)}}const hjt={name:"headingAtx",resolve:fjt,tokenize:pjt};function fjt(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"},cl(t,n,r-n+1,[["enter",s,e],["enter",i,e],["exit",i,e],["exit",s,e]])),t}function pjt(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||Sn(d)?(t.exit("atxHeadingSequence"),l(d)):r(d)}function l(d){return d===35?(t.enter("atxHeadingSequence"),c(d)):d===null||$t(d)?(t.exit("atxHeading"),e(d)):vr(d)?Lr(t,l,"whitespace")(d):(t.enter("atxHeadingText"),u(d))}function c(d){return d===35?(t.consume(d),c):(t.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||Sn(d)?(t.exit("atxHeadingText"),l(d)):(t.consume(d),u)}}const mjt=["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"],Pne=["pre","script","style","textarea"],gjt={concrete:!0,name:"htmlFlow",resolveTo:vjt,tokenize:bjt},xjt={partial:!0,tokenize:jjt},yjt={partial:!0,tokenize:wjt};function vjt(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 bjt(t,e,r){const n=this;let s,i,a,l,c;return u;function u(G){return d(G)}function d(G){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(G),h}function h(G){return G===33?(t.consume(G),f):G===47?(t.consume(G),i=!0,g):G===63?(t.consume(G),s=3,n.interrupt?e:B):Va(G)?(t.consume(G),a=String.fromCharCode(G),y):r(G)}function f(G){return G===45?(t.consume(G),s=2,p):G===91?(t.consume(G),s=5,l=0,m):Va(G)?(t.consume(G),s=4,n.interrupt?e:B):r(G)}function p(G){return G===45?(t.consume(G),n.interrupt?e:B):r(G)}function m(G){const Q="CDATA[";return G===Q.charCodeAt(l++)?(t.consume(G),l===Q.length?n.interrupt?e:T:m):r(G)}function g(G){return Va(G)?(t.consume(G),a=String.fromCharCode(G),y):r(G)}function y(G){if(G===null||G===47||G===62||Sn(G)){const Q=G===47,ie=a.toLowerCase();return!Q&&!i&&Pne.includes(ie)?(s=1,n.interrupt?e(G):T(G)):mjt.includes(a.toLowerCase())?(s=6,Q?(t.consume(G),x):n.interrupt?e(G):T(G)):(s=7,n.interrupt&&!n.parser.lazy[n.now().line]?r(G):i?v(G):b(G))}return G===45||Na(G)?(t.consume(G),a+=String.fromCharCode(G),y):r(G)}function x(G){return G===62?(t.consume(G),n.interrupt?e:T):r(G)}function v(G){return vr(G)?(t.consume(G),v):O(G)}function b(G){return G===47?(t.consume(G),O):G===58||G===95||Va(G)?(t.consume(G),w):vr(G)?(t.consume(G),b):O(G)}function w(G){return G===45||G===46||G===58||G===95||Na(G)?(t.consume(G),w):j(G)}function j(G){return G===61?(t.consume(G),N):vr(G)?(t.consume(G),j):b(G)}function N(G){return G===null||G===60||G===61||G===62||G===96?r(G):G===34||G===39?(t.consume(G),c=G,C):vr(G)?(t.consume(G),N):A(G)}function C(G){return G===c?(t.consume(G),c=null,E):G===null||$t(G)?r(G):(t.consume(G),C)}function A(G){return G===null||G===34||G===39||G===47||G===60||G===61||G===62||G===96||Sn(G)?j(G):(t.consume(G),A)}function E(G){return G===47||G===62||vr(G)?b(G):r(G)}function O(G){return G===62?(t.consume(G),$):r(G)}function $(G){return G===null||$t(G)?T(G):vr(G)?(t.consume(G),$):r(G)}function T(G){return G===45&&s===2?(t.consume(G),K):G===60&&s===1?(t.consume(G),H):G===62&&s===4?(t.consume(G),z):G===63&&s===3?(t.consume(G),B):G===93&&s===5?(t.consume(G),V):$t(G)&&(s===6||s===7)?(t.exit("htmlFlowData"),t.check(xjt,F,M)(G)):G===null||$t(G)?(t.exit("htmlFlowData"),M(G)):(t.consume(G),T)}function M(G){return t.check(yjt,k,F)(G)}function k(G){return t.enter("lineEnding"),t.consume(G),t.exit("lineEnding"),D}function D(G){return G===null||$t(G)?M(G):(t.enter("htmlFlowData"),T(G))}function K(G){return G===45?(t.consume(G),B):T(G)}function H(G){return G===47?(t.consume(G),a="",ee):T(G)}function ee(G){if(G===62){const Q=a.toLowerCase();return Pne.includes(Q)?(t.consume(G),z):T(G)}return Va(G)&&a.length<8?(t.consume(G),a+=String.fromCharCode(G),ee):T(G)}function V(G){return G===93?(t.consume(G),B):T(G)}function B(G){return G===62?(t.consume(G),z):G===45&&s===2?(t.consume(G),B):T(G)}function z(G){return G===null||$t(G)?(t.exit("htmlFlowData"),F(G)):(t.consume(G),z)}function F(G){return t.exit("htmlFlow"),e(G)}}function wjt(t,e,r){const n=this;return s;function s(a){return $t(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 jjt(t,e,r){return n;function n(s){return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),t.attempt(sA,e,r)}}const Sjt={name:"htmlText",tokenize:_jt};function _jt(t,e,r){const n=this;let s,i,a;return l;function l(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),j):B===63?(t.consume(B),b):Va(B)?(t.consume(B),A):r(B)}function u(B){return B===45?(t.consume(B),d):B===91?(t.consume(B),i=0,m):Va(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):$t(B)?(a=h,H(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 z="CDATA[";return B===z.charCodeAt(i++)?(t.consume(B),i===z.length?g:m):r(B)}function g(B){return B===null?r(B):B===93?(t.consume(B),y):$t(B)?(a=g,H(B)):(t.consume(B),g)}function y(B){return B===93?(t.consume(B),x):g(B)}function x(B){return B===62?K(B):B===93?(t.consume(B),x):g(B)}function v(B){return B===null||B===62?K(B):$t(B)?(a=v,H(B)):(t.consume(B),v)}function b(B){return B===null?r(B):B===63?(t.consume(B),w):$t(B)?(a=b,H(B)):(t.consume(B),b)}function w(B){return B===62?K(B):b(B)}function j(B){return Va(B)?(t.consume(B),N):r(B)}function N(B){return B===45||Na(B)?(t.consume(B),N):C(B)}function C(B){return $t(B)?(a=C,H(B)):vr(B)?(t.consume(B),C):K(B)}function A(B){return B===45||Na(B)?(t.consume(B),A):B===47||B===62||Sn(B)?E(B):r(B)}function E(B){return B===47?(t.consume(B),K):B===58||B===95||Va(B)?(t.consume(B),O):$t(B)?(a=E,H(B)):vr(B)?(t.consume(B),E):K(B)}function O(B){return B===45||B===46||B===58||B===95||Na(B)?(t.consume(B),O):$(B)}function $(B){return B===61?(t.consume(B),T):$t(B)?(a=$,H(B)):vr(B)?(t.consume(B),$):E(B)}function T(B){return B===null||B===60||B===61||B===62||B===96?r(B):B===34||B===39?(t.consume(B),s=B,M):$t(B)?(a=T,H(B)):vr(B)?(t.consume(B),T):(t.consume(B),k)}function M(B){return B===s?(t.consume(B),s=void 0,D):B===null?r(B):$t(B)?(a=M,H(B)):(t.consume(B),M)}function k(B){return B===null||B===34||B===39||B===60||B===61||B===96?r(B):B===47||B===62||Sn(B)?E(B):(t.consume(B),k)}function D(B){return B===47||B===62||Sn(B)?E(B):r(B)}function K(B){return B===62?(t.consume(B),t.exit("htmlTextData"),t.exit("htmlText"),e):r(B)}function H(B){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(B),t.exit("lineEnding"),ee}function ee(B){return vr(B)?Lr(t,V,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):V(B)}function V(B){return t.enter("htmlTextData"),a(B)}}const Gq={name:"labelEnd",resolveAll:Ejt,resolveTo:Ajt,tokenize:Tjt},Njt={tokenize:Pjt},kjt={tokenize:Ijt},Cjt={tokenize:Rjt};function Ejt(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&&cl(t,0,t.length,r),t}function Ajt(t,e){let r=t.length,n=0,s,i,a,l;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 l=[["enter",c,e],["enter",u,e]],l=Hl(l,t.slice(i+1,i+n+3)),l=Hl(l,[["enter",d,e]]),l=Hl(l,EL(e.parser.constructs.insideSpan.null,t.slice(i+n+4,a-3),e)),l=Hl(l,[["exit",d,e],t[a-2],t[a-1],["exit",u,e]]),l=Hl(l,t.slice(a+1)),l=Hl(l,[["exit",c,e]]),cl(t,i,t.length,l),t}function Tjt(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 l;function l(f){return i?i._inactive?h(f):(a=n.parser.defined.includes(Qc(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(Njt,d,a?d:h)(f):f===91?t.attempt(kjt,d,a?u:h)(f):a?d(f):h(f)}function u(f){return t.attempt(Cjt,d,h)(f)}function d(f){return e(f)}function h(f){return i._balanced=!0,r(f)}}function Pjt(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 Sn(h)?W_(t,i)(h):i(h)}function i(h){return h===41?d(h):xje(t,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function a(h){return Sn(h)?W_(t,c)(h):d(h)}function l(h){return r(h)}function c(h){return h===34||h===39||h===40?vje(t,u,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):d(h)}function u(h){return Sn(h)?W_(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 Ijt(t,e,r){const n=this;return s;function s(l){return yje.call(n,t,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return n.parser.defined.includes(Qc(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?e(l):r(l)}function a(l){return r(l)}}function Rjt(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 Ojt={name:"labelStartImage",resolveAll:Gq.resolveAll,tokenize:Mjt};function Mjt(t,e,r){const n=this;return s;function s(l){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(l),t.exit("labelImageMarker"),i}function i(l){return l===91?(t.enter("labelMarker"),t.consume(l),t.exit("labelMarker"),t.exit("labelImage"),a):r(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(l):e(l)}}const Djt={name:"labelStartLink",resolveAll:Gq.resolveAll,tokenize:Ljt};function Ljt(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 A3={name:"lineEnding",tokenize:$jt};function $jt(t,e){return r;function r(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),Lr(t,e,"linePrefix")}}const sP={name:"thematicBreak",tokenize:Fjt};function Fjt(t,e,r){let n=0,s;return i;function i(u){return t.enter("thematicBreak"),a(u)}function a(u){return s=u,l(u)}function l(u){return u===s?(t.enter("thematicBreakSequence"),c(u)):n>=3&&(u===null||$t(u))?(t.exit("thematicBreak"),e(u)):r(u)}function c(u){return u===s?(t.consume(u),n++,c):(t.exit("thematicBreakSequence"),vr(u)?Lr(t,l,"whitespace")(u):l(u))}}const no={continuation:{tokenize:Hjt},exit:Vjt,name:"list",tokenize:Ujt},Bjt={partial:!0,tokenize:qjt},zjt={partial:!0,tokenize:Wjt};function Ujt(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 l;function l(p){const m=n.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!n.containerState.marker||p===n.containerState.marker:yU(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(sP,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 yU(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(sA,n.interrupt?r:d,t.attempt(Bjt,f,h))}function d(p){return n.containerState.initialBlankLine=!0,i++,f(p)}function h(p){return vr(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 Hjt(t,e,r){const n=this;return n.containerState._closeFlow=void 0,t.check(sA,s,i);function s(l){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,Lr(t,e,"listItemIndent",n.containerState.size+1)(l)}function i(l){return n.containerState.furtherBlankLines||!vr(l)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,a(l)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,t.attempt(zjt,e,a)(l))}function a(l){return n.containerState._closeFlow=!0,n.interrupt=void 0,Lr(t,t.attempt(no,e,r),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function Wjt(t,e,r){const n=this;return Lr(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 Vjt(t){t.exit(this.containerState.type)}function qjt(t,e,r){const n=this;return Lr(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!vr(i)&&a&&a[1].type==="listItemPrefixWhitespace"?e(i):r(i)}}const Ine={name:"setextUnderline",resolveTo:Gjt,tokenize:Kjt};function Gjt(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 Kjt(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"),l(u)}function l(u){return u===s?(t.consume(u),l):(t.exit("setextHeadingLineSequence"),vr(u)?Lr(t,c,"lineSuffix")(u):c(u))}function c(u){return u===null||$t(u)?(t.exit("setextHeadingLine"),e(u)):r(u)}}const Yjt={tokenize:Xjt};function Xjt(t){const e=this,r=t.attempt(sA,n,t.attempt(this.parser.constructs.flowInitial,s,Lr(t,t.attempt(this.parser.constructs.flow,s,t.attempt(tjt,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 Qjt={resolveAll:wje()},Zjt=bje("string"),Jjt=bje("text");function bje(t){return{resolveAll:wje(t==="text"?eSt:void 0),tokenize:e};function e(r){const n=this,s=this.parser.constructs[t],i=r.attempt(s,a,l);return a;function a(d){return u(d)?i(d):l(d)}function l(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 wje(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 eSt(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,l=0,c;for(;i--;){const u=s[i];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)c=!0,l++;else if(u!==-1){i++;break}}if(e._contentTypeTextTrailing&&r===t.length&&(l=0),l){const u={type:r===t.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:n.start._bufferIndex+a,_index:n.start._index+i,line:n.end.line,column:n.end.column-l,offset:n.end.offset-l},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 tSt={42:no,43:no,45:no,48:no,49:no,50:no,51:no,52:no,53:no,54:no,55:no,56:no,57:no,62:fje},rSt={91:ajt},nSt={[-2]:E3,[-1]:E3,32:E3},sSt={35:hjt,42:sP,45:[Ine,sP],60:gjt,61:Ine,95:sP,96:Tne,126:Tne},iSt={38:mje,92:pje},aSt={[-5]:A3,[-4]:A3,[-3]:A3,33:Ojt,38:mje,42:vU,60:[D1t,Sjt],91:Djt,92:[ujt,pje],93:Gq,95:vU,96:Y1t},oSt={null:[vU,Qjt]},lSt={null:[42,95]},cSt={null:[]},uSt=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:lSt,contentInitial:rSt,disable:cSt,document:tSt,flow:sSt,flowInitial:nSt,insideSpan:oSt,string:iSt,text:aSt},Symbol.toStringTag,{value:"Module"}));function dSt(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=[],l=[];const c={attempt:C(j),check:C(N),consume:v,enter:b,exit:w,interrupt:C(N,{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($){return a=Hl(a,$),y(),a[a.length-1]!==null?[]:(A(e,0),u.events=EL(i,u.events,u),u.events)}function f($,T){return fSt(p($),T)}function p($){return hSt(a,$)}function m(){const{_bufferIndex:$,_index:T,line:M,column:k,offset:D}=n;return{_bufferIndex:$,_index:T,line:M,column:k,offset:D}}function g($){s[$.line]=$.column,O()}function y(){let $;for(;n._index<a.length;){const T=a[n._index];if(typeof T=="string")for($=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===$&&n._bufferIndex<T.length;)x(T.charCodeAt(n._bufferIndex));else x(T)}}function x($){d=d($)}function v($){$t($)?(n.line++,n.column=1,n.offset+=$===-3?2:1,O()):$!==-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=$}function b($,T){const M=T||{};return M.type=$,M.start=m(),u.events.push(["enter",M,u]),l.push(M),M}function w($){const T=l.pop();return T.end=m(),u.events.push(["exit",T,u]),T}function j($,T){A($,T.from)}function N($,T){T.restore()}function C($,T){return M;function M(k,D,K){let H,ee,V,B;return Array.isArray(k)?F(k):"tokenize"in k?F([k]):z(k);function z(se){return q;function q(L){const Z=L!==null&&se[L],J=L!==null&&se.null,W=[...Array.isArray(Z)?Z:Z?[Z]:[],...Array.isArray(J)?J:J?[J]:[]];return F(W)(L)}}function F(se){return H=se,ee=0,se.length===0?K:G(se[ee])}function G(se){return q;function q(L){return B=E(),V=se,se.partial||(u.currentConstruct=se),se.name&&u.parser.constructs.disable.null.includes(se.name)?ie():se.tokenize.call(T?Object.assign(Object.create(u),T):u,c,Q,ie)(L)}}function Q(se){return $(V,B),D}function ie(se){return B.restore(),++ee<H.length?G(H[ee]):K}}}function A($,T){$.resolveAll&&!i.includes($)&&i.push($),$.resolve&&cl(u.events,T,u.events.length-T,$.resolve(u.events.slice(T),u)),$.resolveTo&&(u.events=$.resolveTo(u.events,u))}function E(){const $=m(),T=u.previous,M=u.currentConstruct,k=u.events.length,D=Array.from(l);return{from:k,restore:K};function K(){n=$,u.previous=T,u.currentConstruct=M,u.events.length=k,l=D,O()}}function O(){n.line in s&&n.column<2&&(n.column=s[n.line],n.offset+=s[n.line]-1)}}function hSt(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 l=a[0];typeof l=="string"?a[0]=l.slice(n):a.shift()}i>0&&a.push(t[s].slice(0,i))}return a}function fSt(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 pSt(t){const n={constructs:dje([uSt,...(t||{}).extensions||[]]),content:s(A1t),defined:[],document:s(P1t),flow:s(Yjt),lazy:{},string:s(Zjt),text:s(Jjt)};return n;function s(i){return a;function a(l){return dSt(n,i,l)}}}function mSt(t){for(;!gje(t););return t}const Rne=/[\0\t\n\r]/g;function gSt(){let t=1,e="",r=!0,n;return s;function s(i,a,l){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(Rne.lastIndex=h,u=Rne.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 l&&(n&&c.push(-5),e&&c.push(e),c.push(null)),c}}const xSt=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ySt(t){return t.replace(xSt,vSt)}function vSt(t,e,r){if(e)return e;if(r.charCodeAt(0)===35){const s=r.charCodeAt(1),i=s===120||s===88;return hje(r.slice(i?2:1),i?16:10)}return qq(r)||t}const jje={}.hasOwnProperty;function bSt(t,e,r){return typeof e!="string"&&(r=e,e=void 0),wSt(r)(mSt(pSt(r).document().write(gSt()(t,e,!0))))}function wSt(t){const e={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(U),autolinkProtocol:E,autolinkEmail:E,atxHeading:i(oe),blockQuote:i(J),characterEscape:E,characterReference:E,codeFenced:i(W),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(W,a),codeText:i(X,a),codeTextData:E,data:E,codeFlowValue:E,definition:i(he),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(P),hardBreakEscape:i(Y),hardBreakTrailing:i(Y),htmlFlow:i(R,a),htmlFlowData:E,htmlText:i(R,a),htmlTextData:E,image:i(I),label:a,link:i(U),listItem:i(ue),listItemValue:f,listOrdered:i(re,h),listUnordered:i(re),paragraph:i(ae),reference:G,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(oe),strong:i(ge),thematicBreak:i(ce)},exit:{atxHeading:c(),atxHeadingSequence:j,autolink:c(),autolinkEmail:Z,autolinkProtocol:L,blockQuote:c(),characterEscapeValue:O,characterReferenceMarkerHexadecimal:ie,characterReferenceMarkerNumeric:ie,characterReferenceValue:se,characterReference:q,codeFenced:c(y),codeFencedFence:g,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:O,codeIndented:c(x),codeText:c(D),codeTextData:O,data:O,definition:c(),definitionDestinationString:w,definitionLabelString:v,definitionTitleString:b,emphasis:c(),hardBreakEscape:c(T),hardBreakTrailing:c(T),htmlFlow:c(M),htmlFlowData:O,htmlText:c(k),htmlTextData:O,image:c(H),label:V,labelText:ee,lineEnding:$,link:c(K),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:Q,resourceDestinationString:B,resourceTitleString:z,resource:F,setextHeading:c(A),setextHeadingLineSequence:C,setextHeadingText:N,strong:c(),thematicBreak:c()}};Sje(e,(t||{}).mdastExtensions||[]);const r={};return n;function n(ne){let fe={type:"root",children:[]};const be={stack:[fe],tokenStack:[],config:e,enter:l,exit:u,buffer:a,resume:d,data:r},xe=[];let _e=-1;for(;++_e<ne.length;)if(ne[_e][1].type==="listOrdered"||ne[_e][1].type==="listUnordered")if(ne[_e][0]==="enter")xe.push(_e);else{const ke=xe.pop();_e=s(ne,ke,_e)}for(_e=-1;++_e<ne.length;){const ke=e[ne[_e][0]];jje.call(ke,ne[_e][1].type)&&ke[ne[_e][1].type].call(Object.assign({sliceSerialize:ne[_e][2].sliceSerialize},be),ne[_e][1])}if(be.tokenStack.length>0){const ke=be.tokenStack[be.tokenStack.length-1];(ke[1]||One).call(be,void 0,ke[0])}for(fe.position={start:qf(ne.length>0?ne[0][1].start:{line:1,column:1,offset:0}),end:qf(ne.length>0?ne[ne.length-2][1].end:{line:1,column:1,offset:0})},_e=-1;++_e<e.transforms.length;)fe=e.transforms[_e](fe)||fe;return fe}function s(ne,fe,be){let xe=fe-1,_e=-1,ke=!1,$e,Te,ot,wt;for(;++xe<=be;){const Ct=ne[xe];switch(Ct[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ct[0]==="enter"?_e++:_e--,wt=void 0;break}case"lineEndingBlank":{Ct[0]==="enter"&&($e&&!wt&&!_e&&!ot&&(ot=xe),wt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:wt=void 0}if(!_e&&Ct[0]==="enter"&&Ct[1].type==="listItemPrefix"||_e===-1&&Ct[0]==="exit"&&(Ct[1].type==="listUnordered"||Ct[1].type==="listOrdered")){if($e){let pr=xe;for(Te=void 0;pr--;){const Kt=ne[pr];if(Kt[1].type==="lineEnding"||Kt[1].type==="lineEndingBlank"){if(Kt[0]==="exit")continue;Te&&(ne[Te][1].type="lineEndingBlank",ke=!0),Kt[1].type="lineEnding",Te=pr}else if(!(Kt[1].type==="linePrefix"||Kt[1].type==="blockQuotePrefix"||Kt[1].type==="blockQuotePrefixWhitespace"||Kt[1].type==="blockQuoteMarker"||Kt[1].type==="listItemIndent"))break}ot&&(!Te||ot<Te)&&($e._spread=!0),$e.end=Object.assign({},Te?ne[Te][1].start:Ct[1].end),ne.splice(Te||xe,0,["exit",$e,Ct[2]]),xe++,be++}if(Ct[1].type==="listItemPrefix"){const pr={type:"listItem",_spread:!1,start:Object.assign({},Ct[1].start),end:void 0};$e=pr,ne.splice(xe,0,["enter",pr,Ct[2]]),xe++,be++,ot=void 0,wt=!0}}}return ne[fe][1]._spread=ke,be}function i(ne,fe){return be;function be(xe){l.call(this,ne(xe),xe),fe&&fe.call(this,xe)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ne,fe,be){this.stack[this.stack.length-1].children.push(ne),this.stack.push(ne),this.tokenStack.push([fe,be||void 0]),ne.position={start:qf(fe.start),end:void 0}}function c(ne){return fe;function fe(be){ne&&ne.call(this,be),u.call(this,be)}}function u(ne,fe){const be=this.stack.pop(),xe=this.tokenStack.pop();if(xe)xe[0].type!==ne.type&&(fe?fe.call(this,ne,xe[0]):(xe[1]||One).call(this,ne,xe[0]));else throw new Error("Cannot close `"+ne.type+"` ("+H_({start:ne.start,end:ne.end})+"): it’s not open");be.position.end=qf(ne.end)}function d(){return Vq(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function f(ne){if(this.data.expectingFirstListItemValue){const fe=this.stack[this.stack.length-2];fe.start=Number.parseInt(this.sliceSerialize(ne),10),this.data.expectingFirstListItemValue=void 0}}function p(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.lang=ne}function m(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.meta=ne}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function y(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.value=ne.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.value=ne.replace(/(\r?\n|\r)$/g,"")}function v(ne){const fe=this.resume(),be=this.stack[this.stack.length-1];be.label=fe,be.identifier=Qc(this.sliceSerialize(ne)).toLowerCase()}function b(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.title=ne}function w(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.url=ne}function j(ne){const fe=this.stack[this.stack.length-1];if(!fe.depth){const be=this.sliceSerialize(ne).length;fe.depth=be}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function C(ne){const fe=this.stack[this.stack.length-1];fe.depth=this.sliceSerialize(ne).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function E(ne){const be=this.stack[this.stack.length-1].children;let xe=be[be.length-1];(!xe||xe.type!=="text")&&(xe=we(),xe.position={start:qf(ne.start),end:void 0},be.push(xe)),this.stack.push(xe)}function O(ne){const fe=this.stack.pop();fe.value+=this.sliceSerialize(ne),fe.position.end=qf(ne.end)}function $(ne){const fe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const be=fe.children[fe.children.length-1];be.position.end=qf(ne.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&e.canContainEols.includes(fe.type)&&(E.call(this,ne),O.call(this,ne))}function T(){this.data.atHardBreak=!0}function M(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.value=ne}function k(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.value=ne}function D(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.value=ne}function K(){const ne=this.stack[this.stack.length-1];if(this.data.inReference){const fe=this.data.referenceType||"shortcut";ne.type+="Reference",ne.referenceType=fe,delete ne.url,delete ne.title}else delete ne.identifier,delete ne.label;this.data.referenceType=void 0}function H(){const ne=this.stack[this.stack.length-1];if(this.data.inReference){const fe=this.data.referenceType||"shortcut";ne.type+="Reference",ne.referenceType=fe,delete ne.url,delete ne.title}else delete ne.identifier,delete ne.label;this.data.referenceType=void 0}function ee(ne){const fe=this.sliceSerialize(ne),be=this.stack[this.stack.length-2];be.label=ySt(fe),be.identifier=Qc(fe).toLowerCase()}function V(){const ne=this.stack[this.stack.length-1],fe=this.resume(),be=this.stack[this.stack.length-1];if(this.data.inReference=!0,be.type==="link"){const xe=ne.children;be.children=xe}else be.alt=fe}function B(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.url=ne}function z(){const ne=this.resume(),fe=this.stack[this.stack.length-1];fe.title=ne}function F(){this.data.inReference=void 0}function G(){this.data.referenceType="collapsed"}function Q(ne){const fe=this.resume(),be=this.stack[this.stack.length-1];be.label=fe,be.identifier=Qc(this.sliceSerialize(ne)).toLowerCase(),this.data.referenceType="full"}function ie(ne){this.data.characterReferenceType=ne.type}function se(ne){const fe=this.sliceSerialize(ne),be=this.data.characterReferenceType;let xe;be?(xe=hje(fe,be==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):xe=qq(fe);const _e=this.stack[this.stack.length-1];_e.value+=xe}function q(ne){const fe=this.stack.pop();fe.position.end=qf(ne.end)}function L(ne){O.call(this,ne);const fe=this.stack[this.stack.length-1];fe.url=this.sliceSerialize(ne)}function Z(ne){O.call(this,ne);const fe=this.stack[this.stack.length-1];fe.url="mailto:"+this.sliceSerialize(ne)}function J(){return{type:"blockquote",children:[]}}function W(){return{type:"code",lang:null,meta:null,value:""}}function X(){return{type:"inlineCode",value:""}}function he(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function P(){return{type:"emphasis",children:[]}}function oe(){return{type:"heading",depth:0,children:[]}}function Y(){return{type:"break"}}function R(){return{type:"html",value:""}}function I(){return{type:"image",title:null,url:"",alt:null}}function U(){return{type:"link",title:null,url:"",children:[]}}function re(ne){return{type:"list",ordered:ne.type==="listOrdered",start:null,spread:ne._spread,children:[]}}function ue(ne){return{type:"listItem",spread:ne._spread,checked:null,children:[]}}function ae(){return{type:"paragraph",children:[]}}function ge(){return{type:"strong",children:[]}}function we(){return{type:"text",value:""}}function ce(){return{type:"thematicBreak"}}}function qf(t){return{line:t.line,column:t.column,offset:t.offset}}function Sje(t,e){let r=-1;for(;++r<e.length;){const n=e[r];Array.isArray(n)?Sje(t,n):jSt(t,n)}}function jSt(t,e){let r;for(r in e)if(jje.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 One(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+H_({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+H_({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+H_({start:e.start,end:e.end})+") is still open")}function SSt(t){const e=this;e.parser=r;function r(n){return bSt(n,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function _St(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 NSt(t,e){const r={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,r),[t.applyData(e,r),{type:"text",value:`
`}]}function kSt(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 CSt(t,e){const r={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function ESt(t,e){const r={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function ASt(t,e){const r=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",n=String(e.identifier).toUpperCase(),s=Ij(n.toLowerCase()),i=t.footnoteOrder.indexOf(n);let a,l=t.footnoteCounts.get(n);l===void 0?(l=0,t.footnoteOrder.push(n),a=t.footnoteOrder.length):a=i+1,l+=1,t.footnoteCounts.set(n,l);const c={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+s,id:r+"fnref-"+s+(l>1?"-"+l:""),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 TSt(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 PSt(t,e){if(t.options.allowDangerousHtml){const r={type:"raw",value:e.value};return t.patch(e,r),t.applyData(e,r)}}function _je(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 ISt(t,e){const r=String(e.identifier).toUpperCase(),n=t.definitionById.get(r);if(!n)return _je(t,e);const s={src:Ij(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 RSt(t,e){const r={src:Ij(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 OSt(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 MSt(t,e){const r=String(e.identifier).toUpperCase(),n=t.definitionById.get(r);if(!n)return _je(t,e);const s={href:Ij(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 DSt(t,e){const r={href:Ij(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 LSt(t,e,r){const n=t.all(e),s=r?$St(r):Nje(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 l=-1;for(;++l<n.length;){const d=n[l];(s||l!==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 $St(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=Nje(r[n])}return e}function Nje(t){const e=t.spread;return e??t.children.length>1}function FSt(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 BSt(t,e){const r={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function zSt(t,e){const r={type:"root",children:t.wrap(t.all(e))};return t.patch(e,r),t.applyData(e,r)}function USt(t,e){const r={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}function HSt(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)},l=zq(e.children[1]),c=sje(e.children[e.children.length-1]);l&&c&&(a.position={start:l,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 WSt(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,l=a?a.length:e.children.length;let c=-1;const u=[];for(;++c<l;){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 VSt(t,e){const r={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,r),t.applyData(e,r)}const Mne=9,Dne=32;function qSt(t){const e=String(t),r=/\r?\n|\r/g;let n=r.exec(e),s=0;const i=[];for(;n;)i.push(Lne(e.slice(s,n.index),s>0,!0),n[0]),s=n.index+n[0].length,n=r.exec(e);return i.push(Lne(e.slice(s),s>0,!1)),i.join("")}function Lne(t,e,r){let n=0,s=t.length;if(e){let i=t.codePointAt(n);for(;i===Mne||i===Dne;)n++,i=t.codePointAt(n)}if(r){let i=t.codePointAt(s-1);for(;i===Mne||i===Dne;)s--,i=t.codePointAt(s-1)}return s>n?t.slice(n,s):""}function GSt(t,e){const r={type:"text",value:qSt(String(e.value))};return t.patch(e,r),t.applyData(e,r)}function KSt(t,e){const r={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,r),t.applyData(e,r)}const YSt={blockquote:_St,break:NSt,code:kSt,delete:CSt,emphasis:ESt,footnoteReference:ASt,heading:TSt,html:PSt,imageReference:ISt,image:RSt,inlineCode:OSt,linkReference:MSt,link:DSt,listItem:LSt,list:FSt,paragraph:BSt,root:zSt,strong:USt,table:HSt,tableCell:VSt,tableRow:WSt,text:GSt,thematicBreak:KSt,toml:ET,yaml:ET,definition:ET,footnoteDefinition:ET};function ET(){}const kje=-1,AL=0,V_=1,GR=2,Kq=3,Yq=4,Xq=5,Qq=6,Cje=7,Eje=8,$ne=typeof self=="object"?self:globalThis,XSt=(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 AL:case kje:return r(a,s);case V_:{const l=r([],s);for(const c of a)l.push(n(c));return l}case GR:{const l=r({},s);for(const[c,u]of a)l[n(c)]=n(u);return l}case Kq:return r(new Date(a),s);case Yq:{const{source:l,flags:c}=a;return r(new RegExp(l,c),s)}case Xq:{const l=r(new Map,s);for(const[c,u]of a)l.set(n(c),n(u));return l}case Qq:{const l=r(new Set,s);for(const c of a)l.add(n(c));return l}case Cje:{const{name:l,message:c}=a;return r(new $ne[l](c),s)}case Eje: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:l}=new Uint8Array(a);return r(new DataView(l),a)}}return r(new $ne[i](a),s)};return n},Fne=t=>XSt(new Map,t)(0),ob="",{toString:QSt}={},{keys:ZSt}=Object,fS=t=>{const e=typeof t;if(e!=="object"||!t)return[AL,e];const r=QSt.call(t).slice(8,-1);switch(r){case"Array":return[V_,ob];case"Object":return[GR,ob];case"Date":return[Kq,ob];case"RegExp":return[Yq,ob];case"Map":return[Xq,ob];case"Set":return[Qq,ob];case"DataView":return[V_,r]}return r.includes("Array")?[V_,r]:r.includes("Error")?[Cje,r]:[GR,r]},AT=([t,e])=>t===AL&&(e==="function"||e==="symbol"),JSt=(t,e,r,n)=>{const s=(a,l)=>{const c=n.push(a)-1;return r.set(l,c),c},i=a=>{if(r.has(a))return r.get(a);let[l,c]=fS(a);switch(l){case AL:{let d=a;switch(c){case"bigint":l=Eje,d=a.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return s([kje],a)}return s([l,d],a)}case V_:{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([l,d],a);for(const f of a)d.push(i(f));return h}case GR:{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([l,d],a);for(const f of ZSt(a))(t||!AT(fS(a[f])))&&d.push([i(f),i(a[f])]);return h}case Kq:return s([l,a.toISOString()],a);case Yq:{const{source:d,flags:h}=a;return s([l,{source:d,flags:h}],a)}case Xq:{const d=[],h=s([l,d],a);for(const[f,p]of a)(t||!(AT(fS(f))||AT(fS(p))))&&d.push([i(f),i(p)]);return h}case Qq:{const d=[],h=s([l,d],a);for(const f of a)(t||!AT(fS(f)))&&d.push(i(f));return h}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return i},Bne=(t,{json:e,lossy:r}={})=>{const n=[];return JSt(!(e||r),!!e,new Map,n)(t),n},KR=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?Fne(Bne(t,e)):structuredClone(t):(t,e)=>Fne(Bne(t,e));function e_t(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 t_t(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}function r_t(t){const e=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",r=t.options.footnoteBackContent||e_t,n=t.options.footnoteBackLabel||t_t,s=t.options.footnoteLabel||"Footnotes",i=t.options.footnoteLabelTagName||"h2",a=t.options.footnoteLabelProperties||{className:["sr-only"]},l=[];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=Ij(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 y=d[d.length-1];if(y&&y.type==="element"&&y.tagName==="p"){const v=y.children[y.children.length-1];v&&v.type==="text"?v.value+=" ":y.children.push({type:"text",value:" "}),y.children.push(...m)}else d.push(...m);const x={type:"element",tagName:"li",properties:{id:e+"fn-"+f},children:t.wrap(d,!0)};t.patch(u,x),l.push(x)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...KR(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
`},{type:"element",tagName:"ol",properties:{},children:t.wrap(l,!0)},{type:"text",value:`
`}]}}const TL=function(t){if(t==null)return a_t;if(typeof t=="function")return PL(t);if(typeof t=="object")return Array.isArray(t)?n_t(t):s_t(t);if(typeof t=="string")return i_t(t);throw new Error("Expected function, string, or object as test")};function n_t(t){const e=[];let r=-1;for(;++r<t.length;)e[r]=TL(t[r]);return PL(n);function n(...s){let i=-1;for(;++i<e.length;)if(e[i].apply(this,s))return!0;return!1}}function s_t(t){const e=t;return PL(r);function r(n){const s=n;let i;for(i in t)if(s[i]!==e[i])return!1;return!0}}function i_t(t){return PL(e);function e(r){return r&&r.type===t}}function PL(t){return e;function e(r,n,s){return!!(o_t(r)&&t.call(this,r,typeof n=="number"?n:void 0,s||void 0))}}function a_t(){return!0}function o_t(t){return t!==null&&typeof t=="object"&&"type"in t}const Aje=[],l_t=!0,bU=!1,c_t="skip";function Tje(t,e,r,n){let s;typeof e=="function"&&typeof r!="function"?(n=r,r=e):s=e;const i=TL(s),a=n?-1:1;l(t,void 0,[])();function l(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=Aje,m,g,y;if((!e||i(c,u,d[d.length-1]||void 0))&&(p=u_t(r(c,d)),p[0]===bU))return p;if("children"in c&&c.children){const x=c;if(x.children&&p[0]!==c_t)for(g=(n?x.children.length:-1)+a,y=d.concat(x);g>-1&&g<x.children.length;){const v=x.children[g];if(m=l(v,g,y)(),m[0]===bU)return m;g=typeof m[1]=="number"?m[1]:g+a}}return p}}}function u_t(t){return Array.isArray(t)?t:typeof t=="number"?[l_t,t]:t==null?Aje:[t]}function Zq(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),Tje(t,i,l,s);function l(c,u){const d=u[u.length-1],h=d?d.children.indexOf(c):void 0;return a(c,h,d)}}const wU={}.hasOwnProperty,d_t={};function h_t(t,e){const r=e||d_t,n=new Map,s=new Map,i=new Map,a={...YSt,...r.handlers},l={all:u,applyData:p_t,definitionById:n,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:c,options:r,patch:f_t,wrap:g_t};return Zq(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)}}),l;function c(d,h){const f=d.type,p=l.handlers[f];if(wU.call(l.handlers,f)&&p)return p(l,d,h);if(l.options.passThrough&&l.options.passThrough.includes(f)){if("children"in d){const{children:g,...y}=d,x=KR(y);return x.children=l.all(d),x}return KR(d)}return(l.options.unknownHandler||m_t)(l,d,h)}function u(d){const h=[];if("children"in d){const f=d.children;let p=-1;for(;++p<f.length;){const m=l.one(f[p],d);if(m){if(p&&f[p-1].type==="break"&&(!Array.isArray(m)&&m.type==="text"&&(m.value=zne(m.value)),!Array.isArray(m)&&m.type==="element")){const g=m.children[0];g&&g.type==="text"&&(g.value=zne(g.value))}Array.isArray(m)?h.push(...m):h.push(m)}}}return h}}function f_t(t,e){t.position&&(e.position=t1t(t))}function p_t(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,KR(i)),"children"in r&&r.children&&s!==null&&s!==void 0&&(r.children=s)}return r}function m_t(t,e){const r=e.data||{},n="value"in e&&!(wU.call(r,"hProperties")||wU.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 g_t(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 zne(t){let e=0,r=t.charCodeAt(e);for(;r===9||r===32;)e++,r=t.charCodeAt(e);return t.slice(e)}function Une(t,e){const r=h_t(t,e),n=r.one(t,void 0),s=r_t(r),i=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
`},s),i}function x_t(t,e){return t&&"run"in t?async function(r,n){const s=Une(r,{file:n,...e});await t.run(s,n)}:function(r,n){return Une(r,{file:n,...t||e})}}function Hne(t){if(t)throw t}var iP=Object.prototype.hasOwnProperty,Pje=Object.prototype.toString,Wne=Object.defineProperty,Vne=Object.getOwnPropertyDescriptor,qne=function(e){return typeof Array.isArray=="function"?Array.isArray(e):Pje.call(e)==="[object Array]"},Gne=function(e){if(!e||Pje.call(e)!=="[object Object]")return!1;var r=iP.call(e,"constructor"),n=e.constructor&&e.constructor.prototype&&iP.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!r&&!n)return!1;var s;for(s in e);return typeof s>"u"||iP.call(e,s)},Kne=function(e,r){Wne&&r.name==="__proto__"?Wne(e,r.name,{enumerable:!0,configurable:!0,value:r.newValue,writable:!0}):e[r.name]=r.newValue},Yne=function(e,r){if(r==="__proto__")if(iP.call(e,r)){if(Vne)return Vne(e,r).value}else return;return e[r]},y_t=function t(){var e,r,n,s,i,a,l=arguments[0],c=1,u=arguments.length,d=!1;for(typeof l=="boolean"&&(d=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<u;++c)if(e=arguments[c],e!=null)for(r in e)n=Yne(l,r),s=Yne(e,r),l!==s&&(d&&s&&(Gne(s)||(i=qne(s)))?(i?(i=!1,a=n&&qne(n)?n:[]):a=n&&Gne(n)?n:{},Kne(l,{name:r,newValue:t(d,a,s)})):typeof s<"u"&&Kne(l,{name:r,newValue:s}));return l};const T3=Er(y_t);function jU(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 v_t(){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);l(null,...s);function l(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?b_t(d,l)(...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 b_t(t,e){let r;return n;function n(...a){const l=t.length>a.length;let c;l&&a.push(s);try{c=t.apply(this,a)}catch(u){const d=u;if(l&&r)throw d;return s(d)}l||(c&&c.then&&typeof c.then=="function"?c.then(i,s):c instanceof Error?s(c):i(c))}function s(a,...l){r||(r=!0,e(a,...l))}function i(a){s(null,a)}}const wu={basename:w_t,dirname:j_t,extname:S_t,join:__t,sep:"/"};function w_t(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');iA(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,l=e.length-1;for(;s--;)if(t.codePointAt(s)===47){if(i){r=s+1;break}}else a<0&&(i=!0,a=s+1),l>-1&&(t.codePointAt(s)===e.codePointAt(l--)?l<0&&(n=s):(l=-1,n=a));return r===n?n=a:n<0&&(n=t.length),t.slice(r,n)}function j_t(t){if(iA(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 S_t(t){iA(t);let e=t.length,r=-1,n=0,s=-1,i=0,a;for(;e--;){const l=t.codePointAt(e);if(l===47){if(a){n=e+1;break}continue}r<0&&(a=!0,r=e+1),l===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 __t(...t){let e=-1,r;for(;++e<t.length;)iA(t[e]),t[e]&&(r=r===void 0?t[e]:r+"/"+t[e]);return r===void 0?".":N_t(r)}function N_t(t){iA(t);const e=t.codePointAt(0)===47;let r=k_t(t,!e);return r.length===0&&!e&&(r="."),r.length>0&&t.codePointAt(t.length-1)===47&&(r+="/"),e?"/"+r:r}function k_t(t,e){let r="",n=0,s=-1,i=0,a=-1,l,c;for(;++a<=t.length;){if(a<t.length)l=t.codePointAt(a);else{if(l===47)break;l=47}if(l===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 l===46&&i>-1?i++:i=-1}return r}function iA(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const C_t={cwd:E_t};function E_t(){return"/"}function SU(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function A_t(t){if(typeof t=="string")t=new URL(t);else if(!SU(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 T_t(t)}function T_t(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 P3=["history","path","basename","stem","extname","dirname"];class Ije{constructor(e){let r;e?SU(e)?r={path:e}:typeof e=="string"||P_t(e)?r={value:e}:r=e:r={},this.cwd="cwd"in r?"":C_t.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<P3.length;){const i=P3[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)P3.includes(s)||(this[s]=r[s])}get basename(){return typeof this.path=="string"?wu.basename(this.path):void 0}set basename(e){R3(e,"basename"),I3(e,"basename"),this.path=wu.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?wu.dirname(this.path):void 0}set dirname(e){Xne(this.basename,"dirname"),this.path=wu.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?wu.extname(this.path):void 0}set extname(e){if(I3(e,"extname"),Xne(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=wu.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){SU(e)&&(e=A_t(e)),R3(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?wu.basename(this.path,this.extname):void 0}set stem(e){R3(e,"stem"),I3(e,"stem"),this.path=wu.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 Ta(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 I3(t,e){if(t&&t.includes(wu.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+wu.sep+"`")}function R3(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function Xne(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}function P_t(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const I_t=function(t){const n=this.constructor.prototype,s=n[t],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,n),i},R_t={}.hasOwnProperty;class Jq extends I_t{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=v_t()}copy(){const e=new Jq;let r=-1;for(;++r<this.attachers.length;){const n=this.attachers[r];e.use(...n)}return e.data(T3(!0,{},this.namespace)),e}data(e,r){return typeof e=="string"?arguments.length===2?(D3("data",this.frozen),this.namespace[e]=r,this):R_t.call(this.namespace,e)&&this.namespace[e]||void 0:e?(D3("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=TT(e),n=this.parser||this.Parser;return O3("parse",n),n(String(r),r)}process(e,r){const n=this;return this.freeze(),O3("process",this.parser||this.Parser),M3("process",this.compiler||this.Compiler),r?s(void 0,r):new Promise(s);function s(i,a){const l=TT(e),c=n.parse(l);n.run(c,l,function(d,h,f){if(d||!h||!f)return u(d);const p=h,m=n.stringify(p,f);D_t(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(),O3("processSync",this.parser||this.Parser),M3("processSync",this.compiler||this.Compiler),this.process(e,s),Zne("processSync","process",r),n;function s(i,a){r=!0,Hne(i),n=a}}run(e,r,n){Qne(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,l){const c=TT(r);s.run(e,c,u);function u(d,h,f){const p=h||e;d?l(d):a?a(p):n(void 0,p,f)}}}runSync(e,r){let n=!1,s;return this.run(e,r,i),Zne("runSync","run",n),s;function i(a,l){Hne(a),s=l,n=!0}}stringify(e,r){this.freeze();const n=TT(r),s=this.compiler||this.Compiler;return M3("stringify",s),Qne(e),s(e,n)}use(e,...r){const n=this.attachers,s=this.namespace;if(D3("use",this.frozen),e!=null)if(typeof e=="function")c(e,r);else if(typeof e=="object")Array.isArray(e)?l(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");l(u.plugins),u.settings&&(s.settings=T3(!0,s.settings,u.settings))}function l(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];jU(g)&&jU(p)&&(p=T3(!0,g,p)),n[f]=[u,p,...m]}}}}const O_t=new Jq().freeze();function O3(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function M3(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function D3(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 Qne(t){if(!jU(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Zne(t,e,r){if(!r)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function TT(t){return M_t(t)?t:new Ije(t)}function M_t(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function D_t(t){return typeof t=="string"||L_t(t)}function L_t(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const $_t="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Jne=[],ese={allowDangerousHtml:!0},F_t=/^(https?|ircs?|mailto|xmpp)$/i,B_t=[{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 rc(t){const e=z_t(t),r=U_t(t);return H_t(e.runSync(e.parse(r),r),t)}function z_t(t){const e=t.rehypePlugins||Jne,r=t.remarkPlugins||Jne,n=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...ese}:ese;return O_t().use(SSt).use(r).use(x_t,n).use(e)}function U_t(t){const e=t.children||"",r=new Ije;return typeof e=="string"&&(r.value=e),r}function H_t(t,e){const r=e.allowedElements,n=e.allowElement,s=e.components,i=e.disallowedElements,a=e.skipHtml,l=e.unwrapDisallowed,c=e.urlTransform||W_t;for(const d of B_t)Object.hasOwn(e,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+$_t+d.id,void 0);return Zq(t,u),a1t(t,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.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 C3)if(Object.hasOwn(C3,p)&&Object.hasOwn(d.properties,p)){const m=d.properties[p],g=C3[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 l&&d.children?f.children.splice(h,1,...d.children):f.children.splice(h,1),h}}}function W_t(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||F_t.test(t.slice(0,e))?t:""}function tse(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 V_t(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function q_t(t,e,r){const s=TL((r||{}).ignore||[]),i=G_t(e);let a=-1;for(;++a<i.length;)Tje(t,"text",l);function l(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 y=h.children.indexOf(u);let x=!1,v=[];f.lastIndex=0;let b=f.exec(u.value);for(;b;){const j=b.index,N={index:b.index,input:b.input,stack:[...d,u]};let C=p(...b,N);if(typeof C=="string"&&(C=C.length>0?{type:"text",value:C}:void 0),C===!1)f.lastIndex=j+1;else{if(m!==j&&w({type:"text",value:u.value.slice(m,j)}),Array.isArray(C))for(const A of C)w(A);else C&&w(C);m=j+b[0].length,x=!0}if(!f.global)break;b=f.exec(u.value)}return x?(m<u.value.length&&w({type:"text",value:u.value.slice(m)}),h.children.splice(y,1,...v)):v=[u],y+v.length;function w(j){const N=v[v.length-1];N&&N.type==="text"&&j.type==="text"?N.value+=j.value:v.push(j)}}}function G_t(t){if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const e=[],r=!t[0]||Array.isArray(t[0])?t:[t];let n=-1;for(;++n<r.length;){const s=r[n];e.push([K_t(s[0]),Y_t(s[1])])}return e}function K_t(t){return typeof t=="string"?new RegExp(V_t(t),"g"):t}function Y_t(t){return typeof t=="function"?t:function(){return t}}const L3="phrasing",$3=["autolink","link","image","label"];function X_t(){return{transforms:[nNt],enter:{literalAutolink:Z_t,literalAutolinkEmail:F3,literalAutolinkHttp:F3,literalAutolinkWww:F3},exit:{literalAutolink:rNt,literalAutolinkEmail:tNt,literalAutolinkHttp:J_t,literalAutolinkWww:eNt}}}function Q_t(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:L3,notInConstruct:$3},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:L3,notInConstruct:$3},{character:":",before:"[ps]",after:"\\/",inConstruct:L3,notInConstruct:$3}]}}function Z_t(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function F3(t){this.config.enter.autolinkProtocol.call(this,t)}function J_t(t){this.config.exit.autolinkProtocol.call(this,t)}function eNt(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 tNt(t){this.config.exit.autolinkEmail.call(this,t)}function rNt(t){this.exit(t)}function nNt(t){q_t(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,sNt],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),iNt]],{ignore:["link","linkReference"]})}function sNt(t,e,r,n,s){let i="";if(!Rje(s)||(/^w/i.test(e)&&(r=e+r,e="",i="http://"),!aNt(r)))return!1;const a=oNt(r+n);if(!a[0])return!1;const l={type:"link",title:null,url:i+e+a[0],children:[{type:"text",value:e+a[0]}]};return a[1]?[l,{type:"text",value:a[1]}]:l}function iNt(t,e,r,n){return!Rje(n,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+r,children:[{type:"text",value:e+"@"+r}]}}function aNt(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 oNt(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=tse(t,"(");let i=tse(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 Rje(t,e){const r=t.input.charCodeAt(t.index-1);return(t.index===0||fv(r)||CL(r))&&(!e||r!==47)}Oje.peek=gNt;function lNt(){this.buffer()}function cNt(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function uNt(){this.buffer()}function dNt(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function hNt(t){const e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Qc(this.sliceSerialize(t)).toLowerCase(),r.label=e}function fNt(t){this.exit(t)}function pNt(t){const e=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Qc(this.sliceSerialize(t)).toLowerCase(),r.label=e}function mNt(t){this.exit(t)}function gNt(){return"["}function Oje(t,e,r,n){const s=r.createTracker(n);let i=s.move("[^");const a=r.enter("footnoteReference"),l=r.enter("reference");return i+=s.move(r.safe(r.associationId(t),{after:"]",before:i})),l(),a(),i+=s.move("]"),i}function xNt(){return{enter:{gfmFootnoteCallString:lNt,gfmFootnoteCall:cNt,gfmFootnoteDefinitionLabelString:uNt,gfmFootnoteDefinition:dNt},exit:{gfmFootnoteCallString:hNt,gfmFootnoteCall:fNt,gfmFootnoteDefinitionLabelString:pNt,gfmFootnoteDefinition:mNt}}}function yNt(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:r,footnoteReference:Oje},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(n,s,i,a){const l=i.createTracker(a);let c=l.move("[^");const u=i.enter("footnoteDefinition"),d=i.enter("label");return c+=l.move(i.safe(i.associationId(n),{before:c,after:"]"})),d(),c+=l.move("]:"),n.children&&n.children.length>0&&(l.shift(4),c+=l.move((e?`
`:" ")+i.indentLines(i.containerFlow(n,l.current()),e?Mje:vNt))),u(),c}}function vNt(t,e,r){return e===0?t:Mje(t,e,r)}function Mje(t,e,r){return(r?"":"    ")+t}const bNt=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];eG.attention=NNt;eG.peek=kNt;function wNt(){return{canContainEols:["delete"],enter:{strikethrough:SNt},exit:{strikethrough:_Nt}}}function jNt(){return{handlers:{delete:eG},unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:bNt}]}}function SNt(t){this.enter({type:"delete",children:[],position:void 0},t)}function _Nt(t){this.exit(t)}function eG(t,e,r,n){const s=r.createTracker(n),i=r.stack.includes("strikethrough")?"~":"~~",a=r.enter("strikethrough");let l=s.move(i);return l+=r.containerPhrasing(t,{...s.current(),before:l,after:"~"}),l+=s.move(i),a(),l}function NNt(){return{construct:"strikethrough",markers:["~"],sizes:[2,1]}}function kNt(){return"~"}function CNt(t){return t.length}function ENt(t,e){const r=e||{},n=(r.align||[]).concat(),s=r.stringLength||CNt,i=[],a=[],l=[],c=[];let u=0,d=-1;for(;++d<t.length;){const g=[],y=[];let x=-1;for(t[d].length>u&&(u=t[d].length);++x<t[d].length;){const v=ANt(t[d][x]);if(r.alignDelimiters!==!1){const b=s(v);y[x]=b,(c[x]===void 0||b>c[x])&&(c[x]=b)}g.push(v)}a[d]=g,l[d]=y}let h=-1;if(typeof n=="object"&&"length"in n)for(;++h<u;)i[h]=rse(n[h]);else{const g=rse(n);for(;++h<u;)i[h]=g}h=-1;const f=[],p=[];for(;++h<u;){const g=i[h];let y="",x="";g===99?(y=":",x=":"):g===108?y=":":g===114&&(x=":");let v=r.alignDelimiters===!1?1:Math.max(1,c[h]-y.length-x.length);const b=y+"-".repeat(v)+x;r.alignDelimiters!==!1&&(v=y.length+v+x.length,v>c[h]&&(c[h]=v),p[h]=v),f[h]=b}a.splice(1,0,f),l.splice(1,0,p),d=-1;const m=[];for(;++d<a.length;){const g=a[d],y=l[d];h=-1;const x=[];for(;++h<u;){const v=g[h]||"";let b="",w="";if(r.alignDelimiters!==!1){const j=c[h]-(y[h]||0),N=i[h];N===114?b=" ".repeat(j):N===99?j%2?(b=" ".repeat(j/2+.5),w=" ".repeat(j/2-.5)):(b=" ".repeat(j/2),w=b):w=" ".repeat(j)}r.delimiterStart!==!1&&!h&&x.push("|"),r.padding!==!1&&!(r.alignDelimiters===!1&&v==="")&&(r.delimiterStart!==!1||h)&&x.push(" "),r.alignDelimiters!==!1&&x.push(b),x.push(v),r.alignDelimiters!==!1&&x.push(w),r.padding!==!1&&x.push(" "),(r.delimiterEnd!==!1||h!==u-1)&&x.push("|")}m.push(r.delimiterEnd===!1?x.join("").replace(/ +$/,""):x.join(""))}return m.join(`
`)}function ANt(t){return t==null?"":String(t)}function rse(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 TNt(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()),PNt);return s(),a}function PNt(t,e,r){return">"+(r?"":" ")+t}function INt(t,e){return nse(t,e.inConstruct,!0)&&!nse(t,e.notInConstruct,!1)}function nse(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 sse(t,e,r,n){let s=-1;for(;++s<r.unsafe.length;)if(r.unsafe[s].character===`
`&&INt(r.stack,r.unsafe[s]))return/[ \t]/.test(n.before)?"":" ";return`\\
`}function RNt(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 ONt(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 MNt(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 DNt(t,e,r,n){const s=MNt(r),i=t.value||"",a=s==="`"?"GraveAccent":"Tilde";if(ONt(t,r)){const h=r.enter("codeIndented"),f=r.indentLines(i,LNt);return h(),f}const l=r.createTracker(n),c=s.repeat(Math.max(RNt(i,s)+1,3)),u=r.enter("codeFenced");let d=l.move(c);if(t.lang){const h=r.enter(`codeFencedLang${a}`);d+=l.move(r.safe(t.lang,{before:d,after:" ",encode:["`"],...l.current()})),h()}if(t.lang&&t.meta){const h=r.enter(`codeFencedMeta${a}`);d+=l.move(" "),d+=l.move(r.safe(t.meta,{before:d,after:`
`,encode:["`"],...l.current()})),h()}return d+=l.move(`
`),i&&(d+=l.move(i+`
`)),d+=l.move(c),u(),d}function LNt(t,e,r){return(r?"":"    ")+t}function tG(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 $Nt(t,e,r,n){const s=tG(r),i=s==='"'?"Quote":"Apostrophe",a=r.enter("definition");let l=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("]: "),l(),!t.url||/[\0- \u007F]/.test(t.url)?(l=r.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(r.safe(t.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(l=r.enter("destinationRaw"),u+=c.move(r.safe(t.url,{before:u,after:t.title?" ":`
`,...c.current()}))),l(),t.title&&(l=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),l()),a(),u}function FNt(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 jk(t){return"&#x"+t.toString(16).toUpperCase()+";"}function YR(t,e,r){const n=D1(t),s=D1(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}}Dje.peek=BNt;function Dje(t,e,r,n){const s=FNt(r),i=r.enter("emphasis"),a=r.createTracker(n),l=a.move(s);let c=a.move(r.containerPhrasing(t,{after:s,before:l,...a.current()}));const u=c.charCodeAt(0),d=YR(n.before.charCodeAt(n.before.length-1),u,s);d.inside&&(c=jk(u)+c.slice(1));const h=c.charCodeAt(c.length-1),f=YR(n.after.charCodeAt(0),h,s);f.inside&&(c=c.slice(0,-1)+jk(h));const p=a.move(s);return i(),r.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},l+c+p}function BNt(t,e,r){return r.options.emphasis||"*"}function zNt(t,e){let r=!1;return Zq(t,function(n){if("value"in n&&/\r?\n|\r/.test(n.value)||n.type==="break")return r=!0,bU}),!!((!t.depth||t.depth<3)&&Vq(t)&&(e.options.setext||r))}function UNt(t,e,r,n){const s=Math.max(Math.min(6,t.depth||1),1),i=r.createTracker(n);if(zNt(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),l=r.enter("headingAtx"),c=r.enter("phrasing");i.move(a+" ");let u=r.containerPhrasing(t,{before:"# ",after:`
`,...i.current()});return/^[\t ]/.test(u)&&(u=jk(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,r.options.closeAtx&&(u+=" "+a),c(),l(),u}Lje.peek=HNt;function Lje(t){return t.value||""}function HNt(){return"<"}$je.peek=WNt;function $je(t,e,r,n){const s=tG(r),i=s==='"'?"Quote":"Apostrophe",a=r.enter("image");let l=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("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=r.enter("destinationLiteral"),u+=c.move("<"),u+=c.move(r.safe(t.url,{before:u,after:">",...c.current()})),u+=c.move(">")):(l=r.enter("destinationRaw"),u+=c.move(r.safe(t.url,{before:u,after:t.title?" ":")",...c.current()}))),l(),t.title&&(l=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),l()),u+=c.move(")"),a(),u}function WNt(){return"!"}Fje.peek=VNt;function Fje(t,e,r,n){const s=t.referenceType,i=r.enter("imageReference");let a=r.enter("label");const l=r.createTracker(n);let c=l.move("![");const u=r.safe(t.alt,{before:c,after:"]",...l.current()});c+=l.move(u+"]["),a();const d=r.stack;r.stack=[],a=r.enter("reference");const h=r.safe(r.associationId(t),{before:c,after:"]",...l.current()});return a(),r.stack=d,i(),s==="full"||!u||u!==h?c+=l.move(h+"]"):s==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}function VNt(){return"!"}Bje.peek=qNt;function Bje(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],l=r.compilePattern(a);let c;if(a.atBreak)for(;c=l.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 qNt(){return"`"}function zje(t,e){const r=Vq(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))}Uje.peek=GNt;function Uje(t,e,r,n){const s=tG(r),i=s==='"'?"Quote":"Apostrophe",a=r.createTracker(n);let l,c;if(zje(t,r)){const d=r.stack;r.stack=[],l=r.enter("autolink");let h=a.move("<");return h+=a.move(r.containerPhrasing(t,{before:h,after:">",...a.current()})),h+=a.move(">"),l(),r.stack=d,h}l=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(")"),l(),u}function GNt(t,e,r){return zje(t,r)?"<":"["}Hje.peek=KNt;function Hje(t,e,r,n){const s=t.referenceType,i=r.enter("linkReference");let a=r.enter("label");const l=r.createTracker(n);let c=l.move("[");const u=r.containerPhrasing(t,{before:c,after:"]",...l.current()});c+=l.move(u+"]["),a();const d=r.stack;r.stack=[],a=r.enter("reference");const h=r.safe(r.associationId(t),{before:c,after:"]",...l.current()});return a(),r.stack=d,i(),s==="full"||!u||u!==h?c+=l.move(h+"]"):s==="shortcut"?c=c.slice(0,-1):c+=l.move("]"),c}function KNt(){return"["}function rG(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 YNt(t){const e=rG(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 XNt(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 Wje(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 QNt(t,e,r,n){const s=r.enter("list"),i=r.bulletCurrent;let a=t.ordered?XNt(r):rG(r);const l=t.ordered?a==="."?")":".":YNt(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),Wje(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=l),r.bulletCurrent=a;const u=r.containerFlow(t,n);return r.bulletLastUsed=a,r.bulletCurrent=i,s(),u}function ZNt(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 JNt(t,e,r,n){const s=ZNt(r);let i=r.bulletCurrent||rG(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 l=r.createTracker(n);l.move(i+" ".repeat(a-i.length)),l.shift(a);const c=r.enter("listItem"),u=r.indentLines(r.containerFlow(t,l.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 ekt(t,e,r,n){const s=r.enter("paragraph"),i=r.enter("phrasing"),a=r.containerPhrasing(t,n);return i(),s(),a}const tkt=TL(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function rkt(t,e,r,n){return(t.children.some(function(a){return tkt(a)})?r.containerPhrasing:r.containerFlow).call(r,t,n)}function nkt(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Vje.peek=skt;function Vje(t,e,r,n){const s=nkt(r),i=r.enter("strong"),a=r.createTracker(n),l=a.move(s+s);let c=a.move(r.containerPhrasing(t,{after:s,before:l,...a.current()}));const u=c.charCodeAt(0),d=YR(n.before.charCodeAt(n.before.length-1),u,s);d.inside&&(c=jk(u)+c.slice(1));const h=c.charCodeAt(c.length-1),f=YR(n.after.charCodeAt(0),h,s);f.inside&&(c=c.slice(0,-1)+jk(h));const p=a.move(s+s);return i(),r.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},l+c+p}function skt(t,e,r){return r.options.strong||"*"}function ikt(t,e,r,n){return r.safe(t.value,n)}function akt(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 okt(t,e,r){const n=(Wje(r)+(r.options.ruleSpaces?" ":"")).repeat(akt(r));return r.options.ruleSpaces?n.slice(0,-1):n}const qje={blockquote:TNt,break:sse,code:DNt,definition:$Nt,emphasis:Dje,hardBreak:sse,heading:UNt,html:Lje,image:$je,imageReference:Fje,inlineCode:Bje,link:Uje,linkReference:Hje,list:QNt,listItem:JNt,paragraph:ekt,root:rkt,strong:Vje,text:ikt,thematicBreak:okt};function lkt(){return{enter:{table:ckt,tableData:ise,tableHeader:ise,tableRow:dkt},exit:{codeText:hkt,table:ukt,tableData:B3,tableHeader:B3,tableRow:B3}}}function ckt(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 ukt(t){this.exit(t),this.data.inTable=void 0}function dkt(t){this.enter({type:"tableRow",children:[]},t)}function B3(t){this.exit(t)}function ise(t){this.enter({type:"tableCell",children:[]},t)}function hkt(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,fkt));const r=this.stack[this.stack.length-1];r.type,r.value=e,this.exit(t)}function fkt(t,e){return e==="|"?e:t}function pkt(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:l}};function a(p,m,g,y){return u(d(p,g,y),p.align)}function l(p,m,g,y){const x=h(p,g,y),v=u([x]);return v.slice(0,v.indexOf(`
`))}function c(p,m,g,y){const x=g.enter("tableCell"),v=g.enter("phrasing"),b=g.containerPhrasing(p,{...y,before:i,after:i});return v(),x(),b}function u(p,m){return ENt(p,{align:m,alignDelimiters:n,padding:r,stringLength:s})}function d(p,m,g){const y=p.children;let x=-1;const v=[],b=m.enter("table");for(;++x<y.length;)v[x]=h(y[x],m,g);return b(),v}function h(p,m,g){const y=p.children;let x=-1;const v=[],b=m.enter("tableRow");for(;++x<y.length;)v[x]=c(y[x],p,m,g);return b(),v}function f(p,m,g){let y=qje.inlineCode(p,m,g);return g.stack.includes("tableCell")&&(y=y.replace(/\|/g,"\\$&")),y}}function mkt(){return{exit:{taskListCheckValueChecked:ase,taskListCheckValueUnchecked:ase,paragraph:xkt}}}function gkt(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:ykt}}}function ase(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function xkt(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 l=s[i];if(l.type==="paragraph"){a=l;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 ykt(t,e,r,n){const s=t.children[0],i=typeof t.checked=="boolean"&&s&&s.type==="paragraph",a="["+(t.checked?"x":" ")+"] ",l=r.createTracker(n);i&&l.move(a);let c=qje.listItem(t,e,r,{...n,...l.current()});return i&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),c;function u(d){return d+a}}function vkt(){return[X_t(),xNt(),wNt(),lkt(),mkt()]}function bkt(t){return{extensions:[Q_t(),yNt(t),jNt(),pkt(t),gkt()]}}const wkt={tokenize:Ckt,partial:!0},Gje={tokenize:Ekt,partial:!0},Kje={tokenize:Akt,partial:!0},Yje={tokenize:Tkt,partial:!0},jkt={tokenize:Pkt,partial:!0},Xje={name:"wwwAutolink",tokenize:Nkt,previous:Zje},Qje={name:"protocolAutolink",tokenize:kkt,previous:Jje},If={name:"emailAutolink",tokenize:_kt,previous:eSe},Sd={};function Skt(){return{text:Sd}}let Tg=48;for(;Tg<123;)Sd[Tg]=If,Tg++,Tg===58?Tg=65:Tg===91&&(Tg=97);Sd[43]=If;Sd[45]=If;Sd[46]=If;Sd[95]=If;Sd[72]=[If,Qje];Sd[104]=[If,Qje];Sd[87]=[If,Xje];Sd[119]=[If,Xje];function _kt(t,e,r){const n=this;let s,i;return a;function a(h){return!_U(h)||!eSe.call(n,n.previous)||nG(n.events)?r(h):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),l(h))}function l(h){return _U(h)?(t.consume(h),l):h===64?(t.consume(h),c):r(h)}function c(h){return h===46?t.check(jkt,d,u)(h):h===45||h===95||Na(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&&Va(n.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(h)):r(h)}}function Nkt(t,e,r){const n=this;return s;function s(a){return a!==87&&a!==119||!Zje.call(n,n.previous)||nG(n.events)?r(a):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(wkt,t.attempt(Gje,t.attempt(Kje,i),r),r)(a))}function i(a){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(a)}}function kkt(t,e,r){const n=this;let s="",i=!1;return a;function a(h){return(h===72||h===104)&&Jje.call(n,n.previous)&&!nG(n.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),s+=String.fromCodePoint(h),t.consume(h),l):r(h)}function l(h){if(Va(h)&&s.length<5)return s+=String.fromCodePoint(h),t.consume(h),l;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||qR(h)||Sn(h)||fv(h)||CL(h)?r(h):t.attempt(Gje,t.attempt(Kje,d),r)(h)}function d(h){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(h)}}function Ckt(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 Ekt(t,e,r){let n,s,i;return a;function a(u){return u===46||u===95?t.check(Yje,c,l)(u):u===null||Sn(u)||fv(u)||u!==45&&CL(u)?c(u):(i=!0,t.consume(u),a)}function l(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 Akt(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(Yje,e,i)(a):a===null||Sn(a)||fv(a)?e(a):(t.consume(a),s)}function i(a){return a===41&&n++,t.consume(a),s}}function Tkt(t,e,r){return n;function n(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(t.consume(l),n):l===38?(t.consume(l),i):l===93?(t.consume(l),s):l===60||l===null||Sn(l)||fv(l)?e(l):r(l)}function s(l){return l===null||l===40||l===91||Sn(l)||fv(l)?e(l):n(l)}function i(l){return Va(l)?a(l):r(l)}function a(l){return l===59?(t.consume(l),n):Va(l)?(t.consume(l),a):r(l)}}function Pkt(t,e,r){return n;function n(i){return t.consume(i),s}function s(i){return Na(i)?r(i):e(i)}}function Zje(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Sn(t)}function Jje(t){return!Va(t)}function eSe(t){return!(t===47||_U(t))}function _U(t){return t===43||t===45||t===46||t===95||Na(t)}function nG(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 Ikt={tokenize:Bkt,partial:!0};function Rkt(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Lkt,continuation:{tokenize:$kt},exit:Fkt}},text:{91:{name:"gfmFootnoteCall",tokenize:Dkt},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Okt,resolveTo:Mkt}}}}function Okt(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 l;function l(c){if(!a||!a._balanced)return r(c);const u=Qc(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 Mkt(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)},l=[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,...l),t}function Dkt(t,e,r){const n=this,s=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let i=0,a;return l;function l(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||Sn(h))return r(h);if(h===93){t.exit("chunkString");const f=t.exit("gfmFootnoteCallString");return s.includes(Qc(n.sliceSerialize(f)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):r(h)}return Sn(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 Lkt(t,e,r){const n=this,s=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let i,a=0,l;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&&!l||m===null||m===91||Sn(m))return r(m);if(m===93){t.exit("chunkString");const g=t.exit("gfmFootnoteDefinitionLabelString");return i=Qc(n.sliceSerialize(g)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(m),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),f}return Sn(m)||(l=!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),Lr(t,p,"gfmFootnoteDefinitionWhitespace")):r(m)}function p(m){return e(m)}}function $kt(t,e,r){return t.check(sA,e,t.attempt(Ikt,e,r))}function Fkt(t){t.exit("gfmFootnoteDefinition")}function Bkt(t,e,r){const n=this;return Lr(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 zkt(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,l){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,l],["enter",a[u][1],l],["exit",a[u][1],l],["enter",h,l]],p=l.parser.constructs.insideSpan.null;p&&cl(f,f.length,0,EL(p,a.slice(u+1,c),l)),cl(f,f.length,0,[["exit",h,l],["enter",a[c][1],l],["exit",a[c][1],l],["exit",d,l]]),cl(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,l,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=D1(u);if(m===126)return h>1?c(m):(a.consume(m),h++,p);if(h<2&&!r)return c(m);const y=a.exit("strikethroughSequenceTemporary"),x=D1(m);return y._open=!x||x===2&&!!g,y._close=!g||g===2&&!!x,l(m)}}}class Ukt{constructor(){this.map=[],this.index=new Map}add(e,r,n){Hkt(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,this.index.clear()}}function Hkt(t,e,r,n){if(r===0&&n.length===0)return;const s=t.index.get(e);if(s){s[1]+=r,s[2].push(...n);return}const i=[e,r,n];t.map.push(i),t.index.set(e,i)}function Wkt(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 Vkt(){return{flow:{null:{name:"table",tokenize:qkt,resolveAll:Gkt}}}}function qkt(t,e,r){const n=this;let s=0,i=0,a;return l;function l(O){let $=n.events.length-1;for(;$>-1;){const{type:k}=n.events[$][1];if(k==="lineEnding"||k==="linePrefix")$--;else break}const T=$>-1?n.events[$][1].type:null,M=T==="tableHead"||T==="tableRow"?N:c;return M===N&&n.parser.lazy[n.now().line]?r(O):M(O)}function c(O){return t.enter("tableHead"),t.enter("tableRow"),u(O)}function u(O){return O===124||(a=!0,i+=1),d(O)}function d(O){return O===null?r(O):$t(O)?i>1?(i=0,n.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),p):r(O):vr(O)?Lr(t,d,"whitespace")(O):(i+=1,a&&(a=!1,s+=1),O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),a=!0,d):(t.enter("data"),h(O)))}function h(O){return O===null||O===124||Sn(O)?(t.exit("data"),d(O)):(t.consume(O),O===92?f:h)}function f(O){return O===92||O===124?(t.consume(O),h):h(O)}function p(O){return n.interrupt=!1,n.parser.lazy[n.now().line]?r(O):(t.enter("tableDelimiterRow"),a=!1,vr(O)?Lr(t,m,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):m(O))}function m(O){return O===45||O===58?y(O):O===124?(a=!0,t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),g):j(O)}function g(O){return vr(O)?Lr(t,y,"whitespace")(O):y(O)}function y(O){return O===58?(i+=1,a=!0,t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),x):O===45?(i+=1,x(O)):O===null||$t(O)?w(O):j(O)}function x(O){return O===45?(t.enter("tableDelimiterFiller"),v(O)):j(O)}function v(O){return O===45?(t.consume(O),v):O===58?(a=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),b):(t.exit("tableDelimiterFiller"),b(O))}function b(O){return vr(O)?Lr(t,w,"whitespace")(O):w(O)}function w(O){return O===124?m(O):O===null||$t(O)?!a||s!==i?j(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(O)):j(O)}function j(O){return r(O)}function N(O){return t.enter("tableRow"),C(O)}function C(O){return O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),C):O===null||$t(O)?(t.exit("tableRow"),e(O)):vr(O)?Lr(t,C,"whitespace")(O):(t.enter("data"),A(O))}function A(O){return O===null||O===124||Sn(O)?(t.exit("data"),C(O)):(t.consume(O),O===92?E:A)}function E(O){return O===92||O===124?(t.consume(O),A):A(O)}}function Gkt(t,e){let r=-1,n=!0,s=0,i=[0,0,0,0],a=[0,0,0,0],l=!1,c=0,u,d,h;const f=new Ukt;for(;++r<t.length;){const p=t[r],m=p[1];p[0]==="enter"?m.type==="tableHead"?(l=!1,c!==0&&(ose(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],l&&(l=!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=PT(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=PT(f,e,i,s,void 0,h)),i=a,a=[i[1],r,0,0])):m.type==="tableHead"?(l=!0,c=r):m.type==="tableRow"||m.type==="tableDelimiterRow"?(c=r,i[1]!==0?(a[0]=a[1],h=PT(f,e,i,s,r,h)):a[1]!==0&&(h=PT(f,e,a,s,r,h)),s=0):s&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(a[3]=r)}for(c!==0&&ose(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=Wkt(e.events,r))}return t}function PT(t,e,r,n,s,i){const a=n===1?"tableHeader":n===2?"tableDelimiter":"tableData",l="tableContent";r[0]!==0&&(i.end=Object.assign({},xb(e.events,r[0])),t.add(r[0],0,[["exit",i,e]]));const c=xb(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=xb(e.events,r[2]),d=xb(e.events,r[3]),h={type:l,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({},xb(e.events,s)),t.add(s,0,[["exit",i,e]]),i=void 0),i}function ose(t,e,r,n,s){const i=[],a=xb(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 xb(t,e){const r=t[e],n=r[0]==="enter"?"start":"end";return r[1][n]}const Kkt={name:"tasklistCheck",tokenize:Xkt};function Ykt(){return{text:{91:Kkt}}}function Xkt(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 Sn(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"),l):r(c)}function l(c){return $t(c)?e(c):vr(c)?t.check({tokenize:Qkt},e,r)(c):r(c)}}function Qkt(t,e,r){return Lr(t,n,"whitespace");function n(s){return s===null?r(s):e(s)}}function Zkt(t){return dje([Skt(),Rkt(),zkt(t),Vkt(),Ykt()])}const Jkt={};function tSe(t){const e=this,r=t||Jkt,n=e.data(),s=n.micromarkExtensions||(n.micromarkExtensions=[]),i=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),a=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);s.push(Zkt(r)),i.push(vkt()),a.push(bkt(r))}function eCt(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 tCt(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 rCt=/\{\{(youtube|vimeo):([^}]+)\}\}/g;function nCt(t){return t.replace(rCt,(e,r,n)=>{if(r==="youtube"){const s=eCt(n);if(s)return`

[[EMBED:youtube:${s}]]

`}else if(r==="vimeo"){const s=tCt(n);if(s)return`

[[EMBED:vimeo:${s}]]

`}return""})}const lse=/^\[\[EMBED:(youtube|vimeo):([a-zA-Z0-9_-]+)\]\]$/;function cse({kind:t,id:e}){const r=t==="youtube"?`https://www.youtube-nocookie.com/embed/${e}`:`https://player.vimeo.com/video/${e}`;return o.jsx("div",{className:"my-8 relative w-full overflow-hidden rounded-xl border border-border bg-muted aspect-video",children:o.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 z3=({content:t})=>{const e=S.useMemo(()=>nCt(t??""),[t]),[r,n]=S.useState(null);return S.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]),o.jsxs(o.Fragment,{children:[o.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:o.jsx(rc,{remarkPlugins:[tSe],components:{a:({href:s,children:i,...a})=>{if(!s)return o.jsx("a",{...a,children:i});if((s.startsWith("/")||s.startsWith("#"))&&!s.startsWith("#"))return o.jsx(Nt,{to:s,children:i});const c=/^https?:\/\//i.test(s);return o.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?o.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:[o.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]"}),o.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:o.jsx(OMe,{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(lse);if(a)return o.jsx(cse,{kind:a[1],id:a[2]})}if(typeof s=="string"){const a=s.match(lse);if(a)return o.jsx(cse,{kind:a[1],id:a[2]})}return o.jsx("p",{...i,children:s})}},children:e})}),r&&o.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:[o.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:o.jsx(fn,{className:"h-5 w-5"})}),o.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 IL="Collapsible",[sCt,rSe]=Vs(IL),[iCt,sG]=sCt(IL),nSe=S.forwardRef((t,e)=>{const{__scopeCollapsible:r,open:n,defaultOpen:s,disabled:i,onOpenChange:a,...l}=t,[c,u]=ca({prop:n,defaultProp:s??!1,onChange:a,caller:IL});return o.jsx(iCt,{scope:r,disabled:i,contentId:Co(),open:c,onOpenToggle:S.useCallback(()=>u(d=>!d),[u]),children:o.jsx(ft.div,{"data-state":lG(c),"data-disabled":i?"":void 0,...l,ref:e})})});nSe.displayName=IL;var sSe="CollapsibleTrigger",iG=S.forwardRef((t,e)=>{const{__scopeCollapsible:r,...n}=t,s=sG(sSe,r);return o.jsx(ft.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":lG(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...n,ref:e,onClick:Qe(t.onClick,s.onOpenToggle)})});iG.displayName=sSe;var aG="CollapsibleContent",oG=S.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=sG(aG,t.__scopeCollapsible);return o.jsx(pi,{present:r||s.open,children:({present:i})=>o.jsx(aCt,{...n,ref:e,present:i})})});oG.displayName=aG;var aCt=S.forwardRef((t,e)=>{const{__scopeCollapsible:r,present:n,children:s,...i}=t,a=sG(aG,r),[l,c]=S.useState(n),u=S.useRef(null),d=qt(e,u),h=S.useRef(0),f=h.current,p=S.useRef(0),m=p.current,g=a.open||l,y=S.useRef(g),x=S.useRef(void 0);return S.useEffect(()=>{const v=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(v)},[]),bs(()=>{const v=u.current;if(v){x.current=x.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,y.current||(v.style.transitionDuration=x.current.transitionDuration,v.style.animationName=x.current.animationName),c(n)}},[a.open,n]),o.jsx(ft.div,{"data-state":lG(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 lG(t){return t?"open":"closed"}var iSe=nSe,oCt=iG,lCt=oG,lu="Accordion",cCt=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[cG,uCt,dCt]=CE(lu),[RL,LWt]=Vs(lu,[dCt,rSe]),uG=rSe(),aSe=ve.forwardRef((t,e)=>{const{type:r,...n}=t,s=n,i=n;return o.jsx(cG.Provider,{scope:t.__scopeAccordion,children:r==="multiple"?o.jsx(mCt,{...i,ref:e}):o.jsx(pCt,{...s,ref:e})})});aSe.displayName=lu;var[oSe,hCt]=RL(lu),[lSe,fCt]=RL(lu,{collapsible:!1}),pCt=ve.forwardRef((t,e)=>{const{value:r,defaultValue:n,onValueChange:s=()=>{},collapsible:i=!1,...a}=t,[l,c]=ca({prop:r,defaultProp:n??"",onChange:s,caller:lu});return o.jsx(oSe,{scope:t.__scopeAccordion,value:ve.useMemo(()=>l?[l]:[],[l]),onItemOpen:c,onItemClose:ve.useCallback(()=>i&&c(""),[i,c]),children:o.jsx(lSe,{scope:t.__scopeAccordion,collapsible:i,children:o.jsx(cSe,{...a,ref:e})})})}),mCt=ve.forwardRef((t,e)=>{const{value:r,defaultValue:n,onValueChange:s=()=>{},...i}=t,[a,l]=ca({prop:r,defaultProp:n??[],onChange:s,caller:lu}),c=ve.useCallback(d=>l((h=[])=>[...h,d]),[l]),u=ve.useCallback(d=>l((h=[])=>h.filter(f=>f!==d)),[l]);return o.jsx(oSe,{scope:t.__scopeAccordion,value:a,onItemOpen:c,onItemClose:u,children:o.jsx(lSe,{scope:t.__scopeAccordion,collapsible:!0,children:o.jsx(cSe,{...i,ref:e})})})}),[gCt,OL]=RL(lu),cSe=ve.forwardRef((t,e)=>{const{__scopeAccordion:r,disabled:n,dir:s,orientation:i="vertical",...a}=t,l=ve.useRef(null),c=qt(l,e),u=uCt(r),h=Tv(s)==="ltr",f=Qe(t.onKeyDown,p=>{var A;if(!cCt.includes(p.key))return;const m=p.target,g=u().filter(E=>{var O;return!((O=E.ref.current)!=null&&O.disabled)}),y=g.findIndex(E=>E.ref.current===m),x=g.length;if(y===-1)return;p.preventDefault();let v=y;const b=0,w=x-1,j=()=>{v=y+1,v>w&&(v=b)},N=()=>{v=y-1,v<b&&(v=w)};switch(p.key){case"Home":v=b;break;case"End":v=w;break;case"ArrowRight":i==="horizontal"&&(h?j():N());break;case"ArrowDown":i==="vertical"&&j();break;case"ArrowLeft":i==="horizontal"&&(h?N():j());break;case"ArrowUp":i==="vertical"&&N();break}const C=v%x;(A=g[C].ref.current)==null||A.focus()});return o.jsx(gCt,{scope:r,disabled:n,direction:s,orientation:i,children:o.jsx(cG.Slot,{scope:r,children:o.jsx(ft.div,{...a,"data-orientation":i,ref:c,onKeyDown:n?void 0:f})})})}),XR="AccordionItem",[xCt,dG]=RL(XR),uSe=ve.forwardRef((t,e)=>{const{__scopeAccordion:r,value:n,...s}=t,i=OL(XR,r),a=hCt(XR,r),l=uG(r),c=Co(),u=n&&a.value.includes(n)||!1,d=i.disabled||t.disabled;return o.jsx(xCt,{scope:r,open:u,disabled:d,triggerId:c,children:o.jsx(iSe,{"data-orientation":i.orientation,"data-state":gSe(u),...l,...s,ref:e,disabled:d,open:u,onOpenChange:h=>{h?a.onItemOpen(n):a.onItemClose(n)}})})});uSe.displayName=XR;var dSe="AccordionHeader",hSe=ve.forwardRef((t,e)=>{const{__scopeAccordion:r,...n}=t,s=OL(lu,r),i=dG(dSe,r);return o.jsx(ft.h3,{"data-orientation":s.orientation,"data-state":gSe(i.open),"data-disabled":i.disabled?"":void 0,...n,ref:e})});hSe.displayName=dSe;var NU="AccordionTrigger",fSe=ve.forwardRef((t,e)=>{const{__scopeAccordion:r,...n}=t,s=OL(lu,r),i=dG(NU,r),a=fCt(NU,r),l=uG(r);return o.jsx(cG.ItemSlot,{scope:r,children:o.jsx(oCt,{"aria-disabled":i.open&&!a.collapsible||void 0,"data-orientation":s.orientation,id:i.triggerId,...l,...n,ref:e})})});fSe.displayName=NU;var pSe="AccordionContent",mSe=ve.forwardRef((t,e)=>{const{__scopeAccordion:r,...n}=t,s=OL(lu,r),i=dG(pSe,r),a=uG(r);return o.jsx(lCt,{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}})});mSe.displayName=pSe;function gSe(t){return t?"open":"closed"}var yCt=aSe,vCt=uSe,bCt=hSe,xSe=fSe,ySe=mSe;const hG=yCt,ML=S.forwardRef(({className:t,...e},r)=>o.jsx(vCt,{ref:r,className:Pe("border-b",t),...e}));ML.displayName="AccordionItem";const DL=S.forwardRef(({className:t,children:e,...r},n)=>o.jsx(bCt,{className:"flex",children:o.jsxs(xSe,{ref:n,className:Pe("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,o.jsx(ia,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));DL.displayName=xSe.displayName;const LL=S.forwardRef(({className:t,children:e,...r},n)=>o.jsx(ySe,{ref:n,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:o.jsx("div",{className:Pe("pb-4 pt-0",t),children:e})}));LL.displayName=ySe.displayName;const wCt=({faqs:t})=>t.length?o.jsxs("section",{className:"mt-16 border-t border-border pt-12",children:[o.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-foreground mb-6",children:"Frequently asked questions"}),o.jsx(hG,{type:"single",collapsible:!0,className:"w-full",children:t.map(e=>o.jsxs(ML,{value:e.id,children:[o.jsx(DL,{className:"text-left text-base font-semibold",children:e.question}),o.jsx(LL,{className:"text-muted-foreground leading-relaxed whitespace-pre-line",children:e.answer})]},e.id))})]}):null,jCt=({items:t})=>o.jsx("nav",{"aria-label":"Breadcrumb",className:"text-sm text-muted-foreground",children:o.jsx("ol",{className:"flex flex-wrap items-center gap-1.5",children:t.map((e,r)=>{const n=r===t.length-1;return o.jsxs("li",{className:"flex items-center gap-1.5",children:[e.href&&!n?o.jsx(Nt,{to:e.href,className:"hover:text-primary transition-colors",children:e.label}):o.jsx("span",{className:n?"text-foreground font-medium":"",children:e.label}),!n&&o.jsx(AE,{className:"h-3.5 w-3.5"})]},r)})})});function SCt(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 _Ct=t=>t.replace(/-/g," "),NCt=t=>tD({queryKey:["articles","sidebar",t],queryFn:async()=>{const{data:e,error:r}=await pe.from("articles").select("slug,category,title,content_md").eq("status","published").eq("language",t);if(r)throw r;return e??[]}}),kCt=({language:t,category:e,currentSlug:r})=>{const{data:n}=NCt(t),[s,i]=S.useState(""),a=s.trim().toLowerCase(),l=S.useMemo(()=>e?(n??[]).filter(c=>c.category===e).map(c=>({slug:c.slug,label:_Ct(c.slug),title:c.title,body:c.content_md})).sort((c,u)=>c.label.localeCompare(u.label)).filter(c=>!a||c.label.includes(a)||c.title.toLowerCase().includes(a)||c.body.toLowerCase().includes(a)):[],[n,e,a]);return o.jsxs("aside",{className:"lg:sticky lg:top-28 self-start w-full",children:[o.jsxs("div",{className:"relative",children:[o.jsx(Ti,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),o.jsx("input",{type:"search",value:s,onChange:c=>i(c.target.value),placeholder:"Search…","aria-label":"Search articles",className:"w-full h-10 rounded-lg bg-card text-foreground pl-9 pr-3 text-sm border border-border shadow-sm focus:outline-none focus:ring-2 focus:ring-ring"})]}),e&&o.jsx("h2",{className:"text-xl font-bold text-foreground mt-6 mb-3",children:e}),o.jsxs("ul",{className:"space-y-2",children:[l.map(c=>{const u=c.slug===r;return o.jsx("li",{children:u?o.jsx("span",{className:"block text-sm font-semibold text-primary leading-snug",children:c.label}):o.jsx(Nt,{to:`/blog/${c.slug}`,className:"block text-sm text-foreground/80 hover:text-primary transition-colors leading-snug",children:c.label})},c.slug)}),l.length===0&&o.jsx("li",{className:"text-sm text-muted-foreground py-2",children:"No matching articles."})]})]})},U3="https://academly.ai",CCt=()=>{var m,g;const{slug:t}=hpe(),{data:e,isLoading:r,isError:n}=nwt(t),s=!r&&(!e||!e.article);if(X1e(!r,s?404:200),r)return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Ri,{}),o.jsxs("div",{className:"max-w-[760px] mx-auto px-6 pt-32 pb-24 animate-pulse",children:[o.jsx("div",{className:"h-4 w-32 bg-muted rounded mb-6"}),o.jsx("div",{className:"h-10 w-3/4 bg-muted rounded mb-4"}),o.jsx("div",{className:"h-4 w-full bg-muted rounded mb-2"}),o.jsx("div",{className:"h-4 w-5/6 bg-muted rounded"})]}),o.jsx(Ii,{})]});if(s||n)return o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{title:"Article not found | Academly",description:"The article you are looking for does not exist.",canonical:`${U3}/blog/${t??""}`,noIndex:!0}),o.jsx(Ri,{}),o.jsxs("main",{className:"max-w-[760px] mx-auto px-6 pt-32 pb-24 text-center",children:[o.jsx("h1",{className:"text-3xl font-bold text-foreground mb-4",children:"Article not found"}),o.jsx("p",{className:"text-muted-foreground mb-8",children:"This article doesn't exist or hasn't been published yet."}),o.jsx(Nt,{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"})]}),o.jsx(Ii,{})]});const{article:i,faqs:a,related:l}=e,c=i.canonical_url||`${U3}/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},SCt(f,U3)];return a.length&&p.push({"@context":"https://schema.org","@type":"FAQPage",mainEntity:a.map(y=>({"@type":"Question",name:y.question,acceptedAnswer:{"@type":"Answer",text:y.answer}}))}),i.schema_json&&p.push(i.schema_json),o.jsxs("div",{className:"min-h-screen bg-background",children:[o.jsx(Di,{title:u,description:d,canonical:c,ogImage:i.og_image||i.cover_image||void 0,jsonLd:p}),o.jsx(vhe,{children:o.jsx("html",{lang:i.language})}),o.jsx(Ri,{}),o.jsxs("main",{children:[o.jsx("article",{className:"pt-28 pb-16",children:o.jsxs("div",{className:"max-w-[1160px] mx-auto px-6 lg:grid lg:grid-cols-[260px_1fr] lg:gap-14 items-start",children:[o.jsx(kCt,{language:i.language,category:i.category,currentSlug:i.slug}),o.jsxs("div",{className:"max-w-[760px]",children:[o.jsx(jCt,{items:f}),o.jsxs("header",{className:"mt-6 mb-10",children:[i.category&&o.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}),o.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground leading-tight mb-4",children:i.title}),o.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-x-5 gap-y-2 text-sm text-muted-foreground",children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(nj,{className:"h-4 w-4"}),i.author_name]}),o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(yI,{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&&o.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[o.jsx(sg,{className:"h-4 w-4"}),i.reading_time," min read"]})]})]}),i.cover_image&&o.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 y=i.content_md??"";if(!!!i.cta_headline)return o.jsx(z3,{content:y});const v=y.split(`
`);let b=!1,w=0,j=-1;for(let A=0;A<v.length;A++){const E=v[A];if(/^\s*```/.test(E)&&(b=!b),!b&&/^##\s+/.test(E)&&(w+=1,w===2)){j=A;break}}const N=j===-1?y:v.slice(0,j).join(`
`),C=j===-1?"":v.slice(j).join(`
`);return o.jsxs(o.Fragment,{children:[o.jsx(z3,{content:N}),o.jsxs("aside",{className:"my-10 rounded-2xl bg-primary text-primary-foreground p-8 text-center shadow-theme-md not-prose",children:[o.jsx("h3",{className:"text-2xl font-bold text-white mb-3",children:i.cta_headline}),i.cta_text&&o.jsx("p",{className:"text-base text-white/90 mx-auto max-w-[500px] mb-6 leading-relaxed",children:i.cta_text}),o.jsx(Nt,{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"})]}),C&&o.jsx(z3,{content:C})]})})(),!!((g=i.tags)!=null&&g.length)&&o.jsx("div",{className:"mt-12 flex flex-wrap gap-2",children:i.tags.map(y=>o.jsxs("span",{className:"inline-flex rounded-full bg-muted text-muted-foreground text-xs px-3 py-1",children:["#",y]},y))}),o.jsx(wCt,{faqs:a})]})]})}),!!l.length&&o.jsx("section",{className:"pb-24",children:o.jsxs("div",{className:"max-w-5xl mx-auto px-6",children:[o.jsx("h2",{className:"text-2xl font-bold text-foreground mb-6",children:"Related articles"}),o.jsx("div",{className:"grid md:grid-cols-3 gap-6",children:l.map(y=>o.jsx(Y1e,{article:y},y.id))})]})})]}),o.jsx(Ii,{})]})},_d=S.forwardRef(({className:t,...e},r)=>o.jsx("div",{className:"relative w-full overflow-auto",children:o.jsx("table",{ref:r,className:Pe("w-full caption-bottom text-sm",t),...e})}));_d.displayName="Table";const Nd=S.forwardRef(({className:t,...e},r)=>o.jsx("thead",{ref:r,className:Pe("[&_tr]:border-b",t),...e}));Nd.displayName="TableHeader";const kd=S.forwardRef(({className:t,...e},r)=>o.jsx("tbody",{ref:r,className:Pe("[&_tr:last-child]:border-0",t),...e}));kd.displayName="TableBody";const ECt=S.forwardRef(({className:t,...e},r)=>o.jsx("tfoot",{ref:r,className:Pe("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...e}));ECt.displayName="TableFooter";const fi=S.forwardRef(({className:t,...e},r)=>o.jsx("tr",{ref:r,className:Pe("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));fi.displayName="TableRow";const tr=S.forwardRef(({className:t,...e},r)=>o.jsx("th",{ref:r,className:Pe("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));tr.displayName="TableHead";const rr=S.forwardRef(({className:t,...e},r)=>o.jsx("td",{ref:r,className:Pe("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));rr.displayName="TableCell";const ACt=S.forwardRef(({className:t,...e},r)=>o.jsx("caption",{ref:r,className:Pe("mt-4 text-sm text-muted-foreground",t),...e}));ACt.displayName="TableCaption";const aA=O9,vSe=M9,TCt=D9,bSe=S.forwardRef(({className:t,...e},r)=>o.jsx(zE,{className:Pe("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}));bSe.displayName=zE.displayName;const PCt=_f("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"}}),Rj=S.forwardRef(({side:t="right",className:e,children:r,...n},s)=>o.jsxs(TCt,{children:[o.jsx(bSe,{}),o.jsxs(UE,{ref:s,className:Pe(PCt({side:t}),e),...n,children:[r,o.jsxs(wD,{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:[o.jsx(fn,{className:"h-4 w-4"}),o.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Rj.displayName=UE.displayName;const $L=({className:t,...e})=>o.jsx("div",{className:Pe("flex flex-col space-y-2 text-center sm:text-left",t),...e});$L.displayName="SheetHeader";const oA=S.forwardRef(({className:t,...e},r)=>o.jsx(HE,{ref:r,className:Pe("text-lg font-semibold text-foreground",t),...e}));oA.displayName=HE.displayName;const ICt=S.forwardRef(({className:t,...e},r)=>o.jsx(WE,{ref:r,className:Pe("text-sm text-muted-foreground",t),...e}));ICt.displayName=WE.displayName;const Ba=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),kU=[.001,0,0,.001,0,0],H3=1.35,Xo={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},fp={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},wSe="pdfjs_internal_editor_",Qt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101,COMMENT:102},Ir={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},RCt={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},pa={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},aP={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Os={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},yb={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},FL={ERRORS:0,WARNINGS:1,INFOS:5},QR={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},IT={moveTo:0,lineTo:1,curveTo:2,closePath:3},OCt={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let BL=FL.WARNINGS;function MCt(t){Number.isInteger(t)&&(BL=t)}function DCt(){return BL}function zL(t){BL>=FL.INFOS&&console.log(`Info: ${t}`)}function Zt(t){BL>=FL.WARNINGS&&console.log(`Warning: ${t}`)}function hn(t){throw new Error(t)}function Fs(t,e){t||hn(e)}function LCt(t){switch(t==null?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function jSe(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=UCt(t)}catch{}}const n=e?URL.parse(t,e):URL.parse(t);return LCt(n)?n:null}function SSe(t,e,r=!1){const n=URL.parse(t);return n?(n.hash=e,n.href):r&&jSe(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function gr(t,e,r,n=!1){return Object.defineProperty(t,e,{value:r,enumerable:!n,configurable:!0,writable:!1}),r}const $v=function(){function e(r,n){this.message=r,this.name=n}return e.prototype=new Error,e.constructor=e,e}();class use extends $v{constructor(e,r){super(e,"PasswordException"),this.code=r}}class W3 extends $v{constructor(e,r){super(e,"UnknownErrorException"),this.details=r}}class CU extends $v{constructor(e){super(e,"InvalidPDFException")}}class ZR extends $v{constructor(e,r,n){super(e,"ResponseException"),this.status=r,this.missing=n}}class $Ct extends $v{constructor(e){super(e,"FormatError")}}class Gm extends $v{constructor(e){super(e,"AbortException")}}function _Se(t){(typeof t!="object"||(t==null?void 0:t.length)===void 0)&&hn("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 lA(t){typeof t!="string"&&hn("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 FCt(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255)}function BCt(){const t=new Uint8Array(4);return t[0]=1,new Uint32Array(t.buffer,0,1)[0]===1}function zCt(){try{return new Function(""),!0}catch{return!1}}class oa{static get isLittleEndian(){return gr(this,"isLittleEndian",BCt())}static get isEvalSupported(){return gr(this,"isEvalSupported",zCt())}static get isOffscreenCanvasSupported(){return gr(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return gr(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:e,userAgent:r}=navigator;return gr(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 gr(this,"isCSSRoundSupported",(r=(e=globalThis.CSS)==null?void 0:e.supports)==null?void 0:r.call(e,"width: round(1.5px, 1px)"))}}const V3=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));var Jh,oP,EU;class Rt{static makeHexColor(e,r,n){return`#${V3[e]}${V3[r]}${V3[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],l=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*l+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],l=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,y=s*f+c,x=y,v=l*h+u,b=v,w=l*p+u,j=w;if(i!==0||a!==0){const N=i*d,C=i*f,A=a*h,E=a*p;m+=A,x+=A,y+=E,g+=E,v+=N,j+=N,w+=C,b+=C}n[0]=Math.min(n[0],m,y,g,x),n[1]=Math.min(n[1],v,w,b,j),n[2]=Math.max(n[2],m,y,g,x),n[3]=Math.max(n[3],v,w,b,j)}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],l=n**2+s**2,c=n*i+s*a,u=i**2+a**2,d=(l+u)/2,h=Math.sqrt(d**2-(l*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,l,c,u){u[0]=Math.min(u[0],e,l),u[1]=Math.min(u[1],r,c),u[2]=Math.max(u[2],e,l),u[3]=Math.max(u[3],r,c),de(this,Jh,EU).call(this,e,n,i,l,r,s,a,c,3*(-e+3*(n-i)+l),6*(e-2*n+i),3*(n-e),u),de(this,Jh,EU).call(this,e,n,i,l,r,s,a,c,3*(-r+3*(s-a)+c),6*(r-2*s+a),3*(s-r),u)}}Jh=new WeakSet,oP=function(e,r,n,s,i,a,l,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*l)+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)},EU=function(e,r,n,s,i,a,l,c,u,d,h,f){if(Math.abs(u)<1e-12){Math.abs(d)>=1e-12&&de(this,Jh,oP).call(this,e,r,n,s,i,a,l,c,-h/d,f);return}const p=d**2-4*h*u;if(p<0)return;const m=Math.sqrt(p),g=2*u;de(this,Jh,oP).call(this,e,r,n,s,i,a,l,c,(-d+m)/g,f),de(this,Jh,oP).call(this,e,r,n,s,i,a,l,c,(-d-m)/g,f)},le(Rt,Jh);function UCt(t){return decodeURIComponent(escape(t))}let q3=null,dse=null;function HCt(t){return q3||(q3=/([\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,dse=new Map([["ſt","ſt"]])),t.replaceAll(q3,(e,r,n)=>r?r.normalize("NFKC"):dse.get(n))}function NSe(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),_Se(t)}const fG="pdfjs_internal_id_";function WCt(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 l=!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;l=!1;break;default:return!1}for(const c of i)if(!(typeof c=="number"||l&&c===null))return!1;return!0}function za(t,e,r){return Math.min(Math.max(t,e),r)}function kSe(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(_Se(t))}function VCt(t){return Uint8Array.fromBase64?Uint8Array.fromBase64(t):lA(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 Bd="http://www.w3.org/2000/svg",ex=class ex{};Ge(ex,"CSS",96),Ge(ex,"PDF",72),Ge(ex,"PDF_TO_CSS_UNITS",ex.CSS/ex.PDF);let Km=ex;async function cA(t,e="text"){if(qS(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 uA{constructor({viewBox:e,userUnit:r,scale:n,rotation:s,offsetX:i=0,offsetY:a=0,dontFlip:l=!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.")}l&&(f=-f,p=-p);let m,g,y,x;d===0?(m=Math.abs(u-e[1])*n+i,g=Math.abs(c-e[0])*n+a,y=(e[3]-e[1])*n,x=(e[2]-e[0])*n):(m=Math.abs(c-e[0])*n+i,g=Math.abs(u-e[1])*n+a,y=(e[2]-e[0])*n,x=(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=y,this.height=x}get rawDims(){const e=this.viewBox;return gr(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 uA({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 Rt.applyTransform(n,this.transform),n}convertToViewportRectangle(e){const r=[e[0],e[1]];Rt.applyTransform(r,this.transform);const n=[e[2],e[3]];return Rt.applyTransform(n,this.transform),[r[0],r[1],n[0],n[1]]}convertToPdfPoint(e,r){const n=[e,r];return Rt.applyInverseTransform(n,this.transform),n}}class pG extends $v{constructor(e,r=0){super(e,"RenderingCancelledException"),this.extraDelay=r}}function UL(t){const e=t.length;let r=0;for(;r<e&&t[r].trim()==="";)r++;return t.substring(r,r+5).toLowerCase()==="data:"}function mG(t){return typeof t=="string"&&/\.pdf$/i.test(t)}function qCt(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function GCt(t,e="document.pdf"){if(typeof t!="string")return e;if(UL(t))return Zt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const n=(l=>{try{return new URL(l)}catch{try{return new URL(decodeURIComponent(l))}catch{try{return new URL(l,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(l),"https://foo.bar")}catch{return null}}}}})(t);if(!n)return e;const s=l=>{try{let c=decodeURIComponent(l);return c.includes("/")?(c=c.split("/").at(-1),c.test(/^\.pdf$/i)?c:l):c}catch{return l}},i=/\.pdf$/i,a=n.pathname.split("/").at(-1);if(i.test(a))return s(a);if(n.searchParams.size>0){const l=Array.from(n.searchParams.values()).reverse();for(const u of l)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 hse{constructor(){Ge(this,"started",Object.create(null));Ge(this,"times",[])}time(e){e in this.started&&Zt(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||Zt(`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 qS(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 lc(t){t.preventDefault()}function Ls(t){t.preventDefault(),t.stopPropagation()}function KCt(t){console.log("Deprecated API usage: "+t)}var Gk;class JR{static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!="string")return null;_(this,Gk)||te(this,Gk,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const r=_(this,Gk).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 l=parseInt(r[5],10);l=l>=0&&l<=59?l: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,l+=h):u==="+"&&(a-=d,l-=h),new Date(Date.UTC(n,s,i,a,l,c))}}Gk=new WeakMap,le(JR,Gk);function YCt(t,{scale:e=1,rotation:r=0}){const{width:n,height:s}=t.attributes.style,i=[0,0,parseInt(n),parseInt(s)];return new uA({viewBox:i,userUnit:1,scale:e,rotation:r})}function HL(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):(Zt(`Not a valid color format: "${t}"`),[0,0,0])}function XCt(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,HL(n))}e.remove()}function Jn(t){const{a:e,b:r,c:n,d:s,e:i,f:a}=t.getTransform();return[e,r,n,s,i,a]}function gu(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 pv(t,e,r=!1,n=!0){if(e instanceof uA){const{pageWidth:s,pageHeight:i}=e.rawDims,{style:a}=t,l=oa.isCSSRoundSupported,c=`var(--total-scale-factor) * ${s}px`,u=`var(--total-scale-factor) * ${i}px`,d=l?`round(down, ${c}, var(--scale-round-x))`:`calc(${c})`,h=l?`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 md{constructor(){const{pixelRatio:e}=md;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,l=1/0,c=1/0;n=md.capPixels(n,i),n>0&&(a=Math.sqrt(n/(e*r))),s!==-1&&(l=s/e,c=s/r);const u=Math.min(a,l,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 AU=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];var kp,Cp,Tl,rh,Kk,z0,U0,Yk,sM,CSe,ra,ESe,ASe,vb,GS;const Qd=class Qd{constructor(e){le(this,ra);le(this,kp,null);le(this,Cp,null);le(this,Tl);le(this,rh,null);le(this,Kk,null);le(this,z0,null);le(this,U0,null);te(this,Tl,e),_(Qd,Yk)||te(Qd,Yk,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,kp,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const r=_(this,Tl)._uiManager._signal;e.addEventListener("contextmenu",lc,{signal:r}),e.addEventListener("pointerdown",de(Qd,sM,CSe),{signal:r});const n=te(this,rh,document.createElement("div"));n.className="buttons",e.append(n);const s=_(this,Tl).toolbarPosition;if(s){const{style:i}=e,a=_(this,Tl)._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,kp)}hide(){var e;_(this,kp).classList.add("hidden"),(e=_(this,Cp))==null||e.hideDropdown()}show(){var e,r;_(this,kp).classList.remove("hidden"),(e=_(this,Kk))==null||e.shown(),(r=_(this,z0))==null||r.shown()}addDeleteButton(){const{editorType:e,_uiManager:r}=_(this,Tl),n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",_(Qd,Yk)[e]),de(this,ra,vb).call(this,n),n.addEventListener("click",s=>{r.delete()},{signal:r._signal}),_(this,rh).append(n)}async addAltText(e){const r=await e.render();de(this,ra,vb).call(this,r),_(this,rh).append(r,_(this,ra,GS)),te(this,Kk,e)}addComment(e){if(_(this,z0))return;const r=e.render();r&&(de(this,ra,vb).call(this,r),_(this,rh).prepend(r,_(this,ra,GS)),te(this,z0,e),e.toolbar=this)}addColorPicker(e){if(_(this,Cp))return;te(this,Cp,e);const r=e.renderButton();de(this,ra,vb).call(this,r),_(this,rh).append(r,_(this,ra,GS))}async addEditSignatureButton(e){const r=te(this,U0,await e.renderEditButton(_(this,Tl)));de(this,ra,vb).call(this,r),_(this,rh).append(r,_(this,ra,GS))}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,U0)&&(_(this,U0).title=e)}remove(){var e;_(this,kp).remove(),(e=_(this,Cp))==null||e.destroy(),te(this,Cp,null)}};kp=new WeakMap,Cp=new WeakMap,Tl=new WeakMap,rh=new WeakMap,Kk=new WeakMap,z0=new WeakMap,U0=new WeakMap,Yk=new WeakMap,sM=new WeakSet,CSe=function(e){e.stopPropagation()},ra=new WeakSet,ESe=function(e){_(this,Tl)._focusEventsAllowed=!1,Ls(e)},ASe=function(e){_(this,Tl)._focusEventsAllowed=!0,Ls(e)},vb=function(e){const r=_(this,Tl)._uiManager._signal;e.addEventListener("focusin",de(this,ra,ESe).bind(this),{capture:!0,signal:r}),e.addEventListener("focusout",de(this,ra,ASe).bind(this),{capture:!0,signal:r}),e.addEventListener("contextmenu",lc,{signal:r})},GS=function(){const e=document.createElement("div");return e.className="divider",e},le(Qd,sM),le(Qd,Yk,null);let TU=Qd;var Xk,Ix,Rx,Zm,TSe,PSe,ISe;class QCt{constructor(e){le(this,Zm);le(this,Xk,null);le(this,Ix,null);le(this,Rx);te(this,Rx,e)}show(e,r,n){const[s,i]=de(this,Zm,PSe).call(this,r,n),{style:a}=_(this,Ix)||te(this,Ix,de(this,Zm,TSe).call(this));e.append(_(this,Ix)),a.insetInlineEnd=`${100*s}%`,a.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){_(this,Ix).remove()}}Xk=new WeakMap,Ix=new WeakMap,Rx=new WeakMap,Zm=new WeakSet,TSe=function(){const e=te(this,Ix,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",lc,{signal:_(this,Rx)._signal});const r=te(this,Xk,document.createElement("div"));return r.className="buttons",e.append(r),de(this,Zm,ISe).call(this),e},PSe=function(e,r){let n=0,s=0;for(const i of e){const a=i.y+i.height;if(a<n)continue;const l=i.x+(r?i.width:0);if(a>n){s=l,n=a;continue}r?l>s&&(s=l):l<s&&(s=l)}return[r?1-s:s,n]},ISe=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,Rx)._signal;e.addEventListener("contextmenu",lc,{signal:n}),e.addEventListener("click",()=>{_(this,Rx).highlightSelection("floating_button")},{signal:n}),_(this,Xk).append(e)};function RSe(t,e,r){for(const n of r)e.addEventListener(n,t[n].bind(t))}var iM;class ZCt{constructor(){le(this,iM,0)}get id(){return`${wSe}${xi(this,iM)._++}`}}iM=new WeakMap;var H0,Qk,xa,W0,lP;const zK=class zK{constructor(){le(this,W0);le(this,H0,NSe());le(this,Qk,0);le(this,xa,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 gr(this,"_isSVGFittingCanvas",i)}async getFromFile(e){const{lastModified:r,name:n,size:s,type:i}=e;return de(this,W0,lP).call(this,`${r}_${n}_${s}_${i}`,e)}async getFromUrl(e){return de(this,W0,lP).call(this,e,e)}async getFromBlob(e,r){const n=await r;return de(this,W0,lP).call(this,e,n)}async getFromId(e){_(this,xa)||te(this,xa,new Map);const r=_(this,xa).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,xa)||te(this,xa,new Map);let n=_(this,xa).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,H0)}_${xi(this,Qk)._++}`,refCounter:1,isSvg:!1},_(this,xa).set(e,n),_(this,xa).set(n.id,n),n}getSvgUrl(e){const r=_(this,xa).get(e);return r!=null&&r.isSvg?r.svgUrl:null}deleteId(e){var s;_(this,xa)||te(this,xa,new Map);const r=_(this,xa).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,H0)}_`)}};H0=new WeakMap,Qk=new WeakMap,xa=new WeakMap,W0=new WeakSet,lP=async function(e,r){_(this,xa)||te(this,xa,new Map);let n=_(this,xa).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,H0)}_${xi(this,Qk)._++}`,refCounter:0,isSvg:!1});let s;if(typeof r=="string"?(n.url=r,s=await cA(r,"blob")):r instanceof File?s=n.file=r:r instanceof Blob&&(s=r),s.type==="image/svg+xml"){const i=zK._isSVGFittingCanvas,a=new FileReader,l=new Image,c=new Promise((u,d)=>{l.onload=()=>{n.bitmap=l,n.isSvg=!0,u()},a.onload=async()=>{const h=n.svgUrl=a.result;l.src=await i?`${h}#svgView(preserveAspectRatio(none))`:h},l.onerror=a.onerror=d});a.readAsDataURL(s),await c}else n.bitmap=await createImageBitmap(s);n.refCounter=1}catch(s){Zt(s),n=null}return _(this,xa).set(e,n),n&&_(this,xa).set(n.id,n),n};let PU=zK;var Ss,Ep,Zk,Zn,Xce;let JCt=(Xce=class{constructor(e=128){le(this,Ss,[]);le(this,Ep,!1);le(this,Zk);le(this,Zn,-1);te(this,Zk,e)}add({cmd:e,undo:r,post:n,mustExec:s,type:i=NaN,overwriteIfSameType:a=!1,keepUndo:l=!1}){if(s&&e(),_(this,Ep))return;const c={cmd:e,undo:r,post:n,type:i};if(_(this,Zn)===-1){_(this,Ss).length>0&&(_(this,Ss).length=0),te(this,Zn,0),_(this,Ss).push(c);return}if(a&&_(this,Ss)[_(this,Zn)].type===i){l&&(c.undo=_(this,Ss)[_(this,Zn)].undo),_(this,Ss)[_(this,Zn)]=c;return}const u=_(this,Zn)+1;u===_(this,Zk)?_(this,Ss).splice(0,1):(te(this,Zn,u),u<_(this,Ss).length&&_(this,Ss).splice(u)),_(this,Ss).push(c)}undo(){if(_(this,Zn)===-1)return;te(this,Ep,!0);const{undo:e,post:r}=_(this,Ss)[_(this,Zn)];e(),r==null||r(),te(this,Ep,!1),te(this,Zn,_(this,Zn)-1)}redo(){if(_(this,Zn)<_(this,Ss).length-1){te(this,Zn,_(this,Zn)+1),te(this,Ep,!0);const{cmd:e,post:r}=_(this,Ss)[_(this,Zn)];e(),r==null||r(),te(this,Ep,!1)}}hasSomethingToUndo(){return _(this,Zn)!==-1}hasSomethingToRedo(){return _(this,Zn)<_(this,Ss).length-1}cleanType(e){if(_(this,Zn)!==-1){for(let r=_(this,Zn);r>=0;r--)if(_(this,Ss)[r].type!==e){_(this,Ss).splice(r+1,_(this,Zn)-r),te(this,Zn,r);return}_(this,Ss).length=0,te(this,Zn,-1)}}destroy(){te(this,Ss,null)}},Ss=new WeakMap,Ep=new WeakMap,Zk=new WeakMap,Zn=new WeakMap,Xce);var aM,OSe;class dA{constructor(e){le(this,aM);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:r}=oa.platform;for(const[n,s,i={}]of e)for(const a of n){const l=a.startsWith("mac+");r&&l?(this.callbacks.set(a.slice(4),{callback:s,options:i}),this.allKeys.add(a.split("+").at(-1))):!r&&!l&&(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(de(this,aM,OSe).call(this,r));if(!n)return;const{callback:s,options:{bubbles:i=!1,args:a=[],checker:l=null}}=n;l&&!l(e,r)||(s.bind(e,...a,r)(),i||Ls(r))}}aM=new WeakSet,OSe=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 oM=class oM{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return XCt(e),gr(this,"_colors",e)}convert(e){const r=HL(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 oM._colorsMapping.get(n);return r}getHexCode(e){const r=this._colors.get(e);return r?Rt.makeHexColor(...r):e}};Ge(oM,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let IU=oM;var V0,Mo,Xs,Bi,q0,nh,G0,Pl,Ox,Ap,Tp,K0,Mx,Tu,Cc,Dx,Jk,eC,Y0,tC,Pu,Pp,X0,Ip,Iu,lM,Rp,rC,Op,Lx,Q0,Mp,nC,yi,Jr,sh,Dp,Lp,sC,iC,$p,Ru,ih,aC,oC,Il,lt,cP,RU,MSe,DSe,uP,LSe,$Se,FSe,OU,BSe,MU,DU,zSe,Ra,zd,USe,HSe,LU,WSe,KS,$U;const r0=class r0{constructor(e,r,n,s,i,a,l,c,u,d,h,f,p,m,g,y){le(this,lt);le(this,V0,new AbortController);le(this,Mo,null);le(this,Xs,new Map);le(this,Bi,new Map);le(this,q0,null);le(this,nh,null);le(this,G0,null);le(this,Pl,new JCt);le(this,Ox,null);le(this,Ap,null);le(this,Tp,null);le(this,K0,0);le(this,Mx,new Set);le(this,Tu,null);le(this,Cc,null);le(this,Dx,new Set);Ge(this,"_editorUndoBar",null);le(this,Jk,!1);le(this,eC,!1);le(this,Y0,!1);le(this,tC,null);le(this,Pu,null);le(this,Pp,null);le(this,X0,null);le(this,Ip,!1);le(this,Iu,null);le(this,lM,new ZCt);le(this,Rp,!1);le(this,rC,!1);le(this,Op,null);le(this,Lx,null);le(this,Q0,null);le(this,Mp,null);le(this,nC,null);le(this,yi,Qt.NONE);le(this,Jr,new Set);le(this,sh,null);le(this,Dp,null);le(this,Lp,null);le(this,sC,null);le(this,iC,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});le(this,$p,[0,0]);le(this,Ru,null);le(this,ih,null);le(this,aC,null);le(this,oC,null);le(this,Il,null);const x=this._signal=_(this,V0).signal;te(this,ih,e),te(this,aC,r),te(this,oC,n),te(this,q0,s),te(this,Ox,i),te(this,Dp,a),this._eventBus=l,l._on("editingaction",this.onEditingAction.bind(this),{signal:x}),l._on("pagechanging",this.onPageChanging.bind(this),{signal:x}),l._on("scalechanging",this.onScaleChanging.bind(this),{signal:x}),l._on("rotationchanging",this.onRotationChanging.bind(this),{signal:x}),l._on("setpreference",this.onSetPreference.bind(this),{signal:x}),l._on("switchannotationeditorparams",v=>this.updateParams(v.type,v.value),{signal:x}),de(this,lt,LSe).call(this),de(this,lt,zSe).call(this),de(this,lt,OU).call(this),te(this,nh,c.annotationStorage),te(this,tC,c.filterFactory),te(this,Lp,u),te(this,X0,d||null),te(this,Jk,h),te(this,eC,f),te(this,Y0,p),te(this,nC,m||null),this.viewParameters={realScale:Km.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=y!==!1}static get _keyboardManager(){const e=r0.prototype,r=a=>_(a,ih).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),n=(a,{target:l})=>{if(l instanceof HTMLInputElement){const{type:c}=l;return c!=="text"&&c!=="number"}return!0},s=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return gr(this,"_keyboardManager",new dA([[["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:l})=>!(l instanceof HTMLButtonElement)&&_(a,ih).contains(l)&&!a.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(a,{target:l})=>!(l instanceof HTMLButtonElement)&&_(a,ih).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,l,c,u;(e=_(this,Il))==null||e.resolve(),te(this,Il,null),(r=_(this,V0))==null||r.abort(),te(this,V0,null),this._signal=null;for(const d of _(this,Bi).values())d.destroy();_(this,Bi).clear(),_(this,Xs).clear(),_(this,Dx).clear(),(n=_(this,Mp))==null||n.clear(),te(this,Mo,null),_(this,Jr).clear(),_(this,Pl).destroy(),(s=_(this,q0))==null||s.destroy(),(i=_(this,Ox))==null||i.destroy(),(a=_(this,Dp))==null||a.destroy(),(l=_(this,Iu))==null||l.hide(),te(this,Iu,null),(c=_(this,Q0))==null||c.destroy(),te(this,Q0,null),_(this,Pu)&&(clearTimeout(_(this,Pu)),te(this,Pu,null)),_(this,Ru)&&(clearTimeout(_(this,Ru)),te(this,Ru,null)),(u=this._editorUndoBar)==null||u.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return _(this,nC)}get useNewAltTextFlow(){return _(this,eC)}get useNewAltTextWhenAddingImage(){return _(this,Y0)}get hcmFilter(){return gr(this,"hcmFilter",_(this,Lp)?_(this,tC).addHCMFilter(_(this,Lp).foreground,_(this,Lp).background):"none")}get direction(){return gr(this,"direction",getComputedStyle(_(this,ih)).direction)}get _highlightColors(){return gr(this,"_highlightColors",_(this,X0)?new Map(_(this,X0).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 gr(this,"highlightColors",null);const r=new Map,n=!!_(this,Lp);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 gr(this,"highlightColors",r)}get highlightColorNames(){return gr(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,Tp,e)}setMainHighlightColorPicker(e){te(this,Q0,e)}editAltText(e,r=!1){var n;(n=_(this,q0))==null||n.editAltText(this,e,r)}hasCommentManager(){return!!_(this,Ox)}editComment(e,r){var n;(n=_(this,Ox))==null||n.open(this,e,r)}getSignature(e){var r;(r=_(this,Dp))==null||r.getSignature({uiManager:this,editor:e})}get signatureManager(){return _(this,Dp)}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,Y0,r);break}}onPageChanging({pageNumber:e}){te(this,K0,e-1)}focusMainContainer(){_(this,ih).focus()}findParent(e,r){for(const n of _(this,Bi).values()){const{x:s,y:i,width:a,height:l}=n.div.getBoundingClientRect();if(e>=s&&e<=s+a&&r>=i&&r<=i+l)return n}return null}disableUserSelect(e=!1){_(this,aC).classList.toggle("noUserSelect",e)}addShouldRescale(e){_(this,Dx).add(e)}removeShouldRescale(e){_(this,Dx).delete(e)}onScaleChanging({scale:e}){var r;this.commitOrRemove(),this.viewParameters.realScale=e*Km.PDF_TO_CSS_UNITS;for(const n of _(this,Dx))n.onScaleChanging();(r=_(this,Tp))==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,l=r.toString(),u=de(this,lt,cP).call(this,r).closest(".textLayer"),d=this.getSelectionBoxes(u);if(!d)return;r.empty();const h=de(this,lt,RU).call(this,u),f=_(this,yi)===Qt.NONE,p=()=>{h==null||h.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:d,anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:a,text:l}),f&&this.showAllEditors("highlight",!0,!0)};if(f){this.switchToMode(Qt.HIGHLIGHT,p);return}p()}addToAnnotationStorage(e){!e.isEmpty()&&_(this,nh)&&!_(this,nh).has(e.id)&&_(this,nh).setValue(e.id,e)}a11yAlert(e,r=null){const n=_(this,oC);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,Ip)&&(te(this,Ip,!1),de(this,lt,uP).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const r of _(this,Jr))if(r.div.contains(e)){te(this,Lx,[r,e]),r._focusEventsAllowed=!1;break}}focus(){if(!_(this,Lx))return;const[e,r]=_(this,Lx);te(this,Lx,null),r.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),r.focus()}addEditListeners(){de(this,lt,OU).call(this),de(this,lt,MU).call(this)}removeEditListeners(){de(this,lt,BSe).call(this),de(this,lt,DU).call(this)}dragOver(e){for(const{type:r}of e.dataTransfer.items)for(const n of _(this,Cc))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,Cc))if(n.isHandlingMimeForPasting(r.type)){n.paste(r,this.currentLayer),e.preventDefault();return}}copy(e){var n;if(e.preventDefault(),(n=_(this,Mo))==null||n.commitOrRemove(),!this.hasSelection)return;const r=[];for(const s of _(this,Jr)){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,Cc))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){Zt(`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)de(this,lt,LU).call(this,c);de(this,lt,$U).call(this,i)},l=()=>{for(const c of i)c.remove()};this.addCommands({cmd:a,undo:l,mustExec:!0})}catch(i){Zt(`paste: "${i.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),_(this,yi)!==Qt.NONE&&!this.isEditorHandlingKeyboard&&r0._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,_(this,Ip)&&(te(this,Ip,!1),de(this,lt,uP).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?(de(this,lt,$Se).call(this),de(this,lt,MU).call(this),de(this,lt,Ra).call(this,{isEditing:_(this,yi)!==Qt.NONE,isEmpty:de(this,lt,KS).call(this),hasSomethingToUndo:_(this,Pl).hasSomethingToUndo(),hasSomethingToRedo:_(this,Pl).hasSomethingToRedo(),hasSelectedEditor:!1})):(de(this,lt,FSe).call(this),de(this,lt,DU).call(this),de(this,lt,Ra).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!_(this,Cc)){te(this,Cc,e);for(const r of _(this,Cc))de(this,lt,zd).call(this,r.defaultPropertiesToUpdate)}}getId(){return _(this,lM).id}get currentLayer(){return _(this,Bi).get(_(this,K0))}getLayer(e){return _(this,Bi).get(e)}get currentPageIndex(){return _(this,K0)}addLayer(e){_(this,Bi).set(e.pageIndex,e),_(this,Rp)?e.enable():e.disable()}removeLayer(e){_(this,Bi).delete(e.pageIndex)}async updateMode(e,r=null,n=!1,s=!1,i=!1){var a,l,c;if(_(this,yi)!==e&&!(_(this,Il)&&(await _(this,Il).promise,!_(this,Il)))){if(te(this,Il,Promise.withResolvers()),(a=_(this,Tp))==null||a.commitOrRemove(),te(this,yi,e),e===Qt.NONE){this.setEditingState(!1),de(this,lt,HSe).call(this),(l=this._editorUndoBar)==null||l.hide(),_(this,Il).resolve();return}e===Qt.SIGNATURE&&await((c=_(this,Dp))==null?void 0:c.loadSignatures()),this.setEditingState(!0),await de(this,lt,USe).call(this),this.unselectAll();for(const u of _(this,Bi).values())u.updateMode(e);if(!r){n&&this.addNewEditorFromKeyboard(),_(this,Il).resolve();return}for(const u of _(this,Xs).values())u.annotationElementId===r||u.id===r?(this.setSelected(u),i?u.editComment():s&&u.enterInEditMode()):u.unselect();_(this,Il).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==_(this,yi)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,r){if(_(this,Cc)){switch(e){case Ir.CREATE:this.currentLayer.addNewEditor(r);return;case Ir.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(_(this,sC)||te(this,sC,new Map)).set(e,r),this.showAllEditors("highlight",r);break}if(this.hasSelection)for(const n of _(this,Jr))n.updateParams(e,r);else for(const n of _(this,Cc))n.updateDefaultParams(e,r)}}showAllEditors(e,r,n=!1){var i;for(const a of _(this,Xs).values())a.editorType===e&&a.show(r);(((i=_(this,sC))==null?void 0:i.get(Ir.HIGHLIGHT_SHOW_ALL))??!0)!==r&&de(this,lt,zd).call(this,[[Ir.HIGHLIGHT_SHOW_ALL,r]])}enableWaiting(e=!1){if(_(this,rC)!==e){te(this,rC,e);for(const r of _(this,Bi).values())e?r.disableClick():r.enableClick(),r.div.classList.toggle("waiting",e)}}getEditors(e){const r=[];for(const n of _(this,Xs).values())n.pageIndex===e&&r.push(n);return r}getEditor(e){return _(this,Xs).get(e)}addEditor(e){_(this,Xs).set(e.id,e)}removeEditor(e){var r,n;e.div.contains(document.activeElement)&&(_(this,Pu)&&clearTimeout(_(this,Pu)),te(this,Pu,setTimeout(()=>{this.focusMainContainer(),te(this,Pu,null)},0))),_(this,Xs).delete(e.id),e.annotationElementId&&((r=_(this,Mp))==null||r.delete(e.annotationElementId)),this.unselect(e),(!e.annotationElementId||!_(this,Mx).has(e.annotationElementId))&&((n=_(this,nh))==null||n.remove(e.id))}addDeletedAnnotationElement(e){_(this,Mx).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return _(this,Mx).has(e)}removeDeletedAnnotationElement(e){_(this,Mx).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){_(this,Mo)!==e&&(te(this,Mo,e),e&&de(this,lt,zd).call(this,e.propertiesToUpdate))}updateUI(e){_(this,lt,WSe)===e&&de(this,lt,zd).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){de(this,lt,zd).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(_(this,Jr).has(e)){_(this,Jr).delete(e),e.unselect(),de(this,lt,Ra).call(this,{hasSelectedEditor:this.hasSelection});return}_(this,Jr).add(e),e.select(),de(this,lt,zd).call(this,e.propertiesToUpdate),de(this,lt,Ra).call(this,{hasSelectedEditor:!0})}setSelected(e){var r;this.updateToolbar({mode:e.mode,editId:e.id}),(r=_(this,Tp))==null||r.commitOrRemove();for(const n of _(this,Jr))n!==e&&n.unselect();_(this,Jr).clear(),_(this,Jr).add(e),e.select(),de(this,lt,zd).call(this,e.propertiesToUpdate),de(this,lt,Ra).call(this,{hasSelectedEditor:!0})}isSelected(e){return _(this,Jr).has(e)}get firstSelectedEditor(){return _(this,Jr).values().next().value}unselect(e){e.unselect(),_(this,Jr).delete(e),de(this,lt,Ra).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return _(this,Jr).size!==0}get isEnterHandled(){return _(this,Jr).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var e;_(this,Pl).undo(),de(this,lt,Ra).call(this,{hasSomethingToUndo:_(this,Pl).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:de(this,lt,KS).call(this)}),(e=this._editorUndoBar)==null||e.hide()}redo(){_(this,Pl).redo(),de(this,lt,Ra).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:_(this,Pl).hasSomethingToRedo(),isEmpty:de(this,lt,KS).call(this)})}addCommands(e){_(this,Pl).add(e),de(this,lt,Ra).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:de(this,lt,KS).call(this)})}cleanUndoStack(e){_(this,Pl).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,Jr)],n=()=>{var a;(a=this._editorUndoBar)==null||a.show(s,r.length===1?r[0].editorType:r.length);for(const l of r)l.remove()},s=()=>{for(const a of r)de(this,lt,LU).call(this,a)};this.addCommands({cmd:n,undo:s,mustExec:!0})}commitOrRemove(){var e;(e=_(this,Mo))==null||e.commitOrRemove()}hasSomethingToControl(){return _(this,Mo)||this.hasSelection}selectAll(){for(const e of _(this,Jr))e.commit();de(this,lt,$U).call(this,_(this,Xs).values())}unselectAll(){var e;if(!(_(this,Mo)&&(_(this,Mo).commitOrRemove(),_(this,yi)!==Qt.NONE))&&!((e=_(this,Tp))!=null&&e.commitOrRemove())&&this.hasSelection){for(const r of _(this,Jr))r.unselect();_(this,Jr).clear(),de(this,lt,Ra).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,r,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;_(this,$p)[0]+=e,_(this,$p)[1]+=r;const[s,i]=_(this,$p),a=[..._(this,Jr)],l=1e3;_(this,Ru)&&clearTimeout(_(this,Ru)),te(this,Ru,setTimeout(()=>{te(this,Ru,null),_(this,$p)[0]=_(this,$p)[1]=0,this.addCommands({cmd:()=>{for(const c of a)_(this,Xs).has(c.id)&&(c.translateInPage(s,i),c.translationDone())},undo:()=>{for(const c of a)_(this,Xs).has(c.id)&&(c.translateInPage(-s,-i),c.translationDone())},mustExec:!1})},l));for(const c of a)c.translateInPage(e,r),c.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),te(this,Tu,new Map);for(const e of _(this,Jr))_(this,Tu).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!_(this,Tu))return!1;this.disableUserSelect(!1);const e=_(this,Tu);te(this,Tu,null);let r=!1;for(const[{x:s,y:i,pageIndex:a},l]of e)l.newX=s,l.newY=i,l.newPageIndex=a,r||(r=s!==l.savedX||i!==l.savedY||a!==l.savedPageIndex);if(!r)return!1;const n=(s,i,a,l)=>{if(_(this,Xs).has(s.id)){const c=_(this,Bi).get(l);c?s._setParentAndPosition(c,i,a):(s.pageIndex=l,s.x=i,s.y=a)}};return this.addCommands({cmd:()=>{for(const[s,{newX:i,newY:a,newPageIndex:l}]of e)n(s,i,a,l)},undo:()=>{for(const[s,{savedX:i,savedY:a,savedPageIndex:l}]of e)n(s,i,a,l)},mustExec:!0}),!0}dragSelectedEditors(e,r){if(_(this,Tu))for(const n of _(this,Tu).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,Jr).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return _(this,Mo)===e}getActive(){return _(this,Mo)}getMode(){return _(this,yi)}get imageManager(){return gr(this,"imageManager",new PU)}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 l;switch(e.getAttribute("data-main-rotation")){case"90":l=(u,d,h,f)=>({x:(d-s)/a,y:1-(u+h-n)/i,width:f/a,height:h/i});break;case"180":l=(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":l=(u,d,h,f)=>({x:1-(d+f-s)/a,y:(u-n)/i,width:f/a,height:h/i});break;default:l=(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(l(f,p,m,g))}return c.length===0?null:c}addChangedExistingAnnotation({annotationElementId:e,id:r}){(_(this,G0)||te(this,G0,new Map)).set(e,r)}removeChangedExistingAnnotation({annotationElementId:e}){var r;(r=_(this,G0))==null||r.delete(e)}renderAnnotationElement(e){var s;const r=(s=_(this,G0))==null?void 0:s.get(e.data.id);if(!r)return;const n=_(this,nh).getRawValue(r);n&&(_(this,yi)===Qt.NONE&&!n.hasBeenModified||n.renderAnnotationElement(e))}setMissingCanvas(e,r,n){var i;const s=(i=_(this,Mp))==null?void 0:i.get(e);s&&(s.setCanvas(r,n),_(this,Mp).delete(e))}addMissingCanvas(e,r){(_(this,Mp)||te(this,Mp,new Map)).set(e,r)}};V0=new WeakMap,Mo=new WeakMap,Xs=new WeakMap,Bi=new WeakMap,q0=new WeakMap,nh=new WeakMap,G0=new WeakMap,Pl=new WeakMap,Ox=new WeakMap,Ap=new WeakMap,Tp=new WeakMap,K0=new WeakMap,Mx=new WeakMap,Tu=new WeakMap,Cc=new WeakMap,Dx=new WeakMap,Jk=new WeakMap,eC=new WeakMap,Y0=new WeakMap,tC=new WeakMap,Pu=new WeakMap,Pp=new WeakMap,X0=new WeakMap,Ip=new WeakMap,Iu=new WeakMap,lM=new WeakMap,Rp=new WeakMap,rC=new WeakMap,Op=new WeakMap,Lx=new WeakMap,Q0=new WeakMap,Mp=new WeakMap,nC=new WeakMap,yi=new WeakMap,Jr=new WeakMap,sh=new WeakMap,Dp=new WeakMap,Lp=new WeakMap,sC=new WeakMap,iC=new WeakMap,$p=new WeakMap,Ru=new WeakMap,ih=new WeakMap,aC=new WeakMap,oC=new WeakMap,Il=new WeakMap,lt=new WeakSet,cP=function({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e},RU=function(e){const{currentLayer:r}=this;if(r.hasTextLayer(e))return r;for(const n of _(this,Bi).values())if(n.hasTextLayer(e))return n;return null},MSe=function(){const e=document.getSelection();if(!e||e.isCollapsed)return;const n=de(this,lt,cP).call(this,e).closest(".textLayer"),s=this.getSelectionBoxes(n);s&&(_(this,Iu)||te(this,Iu,new QCt(this)),_(this,Iu).show(n,s,this.direction==="ltr"))},DSe=function(){var i,a,l;const e=document.getSelection();if(!e||e.isCollapsed){_(this,sh)&&((i=_(this,Iu))==null||i.hide(),te(this,sh,null),de(this,lt,Ra).call(this,{hasSelectedText:!1}));return}const{anchorNode:r}=e;if(r===_(this,sh))return;const s=de(this,lt,cP).call(this,e).closest(".textLayer");if(!s){_(this,sh)&&((a=_(this,Iu))==null||a.hide(),te(this,sh,null),de(this,lt,Ra).call(this,{hasSelectedText:!1}));return}if((l=_(this,Iu))==null||l.hide(),te(this,sh,r),de(this,lt,Ra).call(this,{hasSelectedText:!0}),!(_(this,yi)!==Qt.HIGHLIGHT&&_(this,yi)!==Qt.NONE)&&(_(this,yi)===Qt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),te(this,Ip,this.isShiftKeyDown),!this.isShiftKeyDown)){const c=_(this,yi)===Qt.HIGHLIGHT?de(this,lt,RU).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"&&de(this,lt,uP).call(this,"main_toolbar"))};window.addEventListener("pointerup",h,{signal:d}),window.addEventListener("blur",h,{signal:d})}},uP=function(e=""){_(this,yi)===Qt.HIGHLIGHT?this.highlightSelection(e):_(this,Jk)&&de(this,lt,MSe).call(this)},LSe=function(){document.addEventListener("selectionchange",de(this,lt,DSe).bind(this),{signal:this._signal})},$Se=function(){if(_(this,Pp))return;te(this,Pp,new AbortController);const e=this.combinedSignal(_(this,Pp));window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})},FSe=function(){var e;(e=_(this,Pp))==null||e.abort(),te(this,Pp,null)},OU=function(){if(_(this,Op))return;te(this,Op,new AbortController);const e=this.combinedSignal(_(this,Op));window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})},BSe=function(){var e;(e=_(this,Op))==null||e.abort(),te(this,Op,null)},MU=function(){if(_(this,Ap))return;te(this,Ap,new AbortController);const e=this.combinedSignal(_(this,Ap));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})},DU=function(){var e;(e=_(this,Ap))==null||e.abort(),te(this,Ap,null)},zSe=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},Ra=function(e){Object.entries(e).some(([n,s])=>_(this,iC)[n]!==s)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(_(this,iC),e)}),_(this,yi)===Qt.HIGHLIGHT&&e.hasSelectedEditor===!1&&de(this,lt,zd).call(this,[[Ir.HIGHLIGHT_FREE,!0]]))},zd=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},USe=async function(){if(!_(this,Rp)){te(this,Rp,!0);const e=[];for(const r of _(this,Bi).values())e.push(r.enable());await Promise.all(e);for(const r of _(this,Xs).values())r.enable()}},HSe=function(){if(this.unselectAll(),_(this,Rp)){te(this,Rp,!1);for(const e of _(this,Bi).values())e.disable();for(const e of _(this,Xs).values())e.disable()}},LU=function(e){const r=_(this,Bi).get(e.pageIndex);r?r.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},WSe=function(){let e=null;for(e of _(this,Jr));return e},KS=function(){if(_(this,Xs).size===0)return!0;if(_(this,Xs).size===1)for(const e of _(this,Xs).values())return e.isEmpty();return!1},$U=function(e){for(const r of _(this,Jr))r.unselect();_(this,Jr).clear();for(const r of e)r.isEmpty()||(_(this,Jr).add(r),r.select());de(this,lt,Ra).call(this,{hasSelectedEditor:this.hasSelection})},Ge(r0,"TRANSLATE_SMALL",1),Ge(r0,"TRANSLATE_BIG",10);let mv=r0;var vi,Ou,Ec,Z0,Mu,Do,J0,Du,lo,ah,$x,Lu,Fp,qc,YS,dP;const Oa=class Oa{constructor(e){le(this,qc);le(this,vi,null);le(this,Ou,!1);le(this,Ec,null);le(this,Z0,null);le(this,Mu,null);le(this,Do,null);le(this,J0,!1);le(this,Du,null);le(this,lo,null);le(this,ah,null);le(this,$x,null);le(this,Lu,!1);te(this,lo,e),te(this,Lu,e._uiManager.useNewAltTextFlow),_(Oa,Fp)||te(Oa,Fp,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){Oa._l10n??(Oa._l10n=e)}async render(){const e=te(this,Ec,document.createElement("button"));e.className="altText",e.tabIndex="0";const r=te(this,Z0,document.createElement("span"));e.append(r),_(this,Lu)?(e.classList.add("new"),e.setAttribute("data-l10n-id",_(Oa,Fp).missing),r.setAttribute("data-l10n-id",_(Oa,Fp)["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,lo)._uiManager._signal;e.addEventListener("contextmenu",lc,{signal:n}),e.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:n});const s=i=>{i.preventDefault(),_(this,lo)._uiManager.editAltText(_(this,lo)),_(this,Lu)&&_(this,lo)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:_(this,qc,YS)}})};return e.addEventListener("click",s,{capture:!0,signal:n}),e.addEventListener("keydown",i=>{i.target===e&&i.key==="Enter"&&(te(this,J0,!0),s(i))},{signal:n}),await de(this,qc,dP).call(this),e}finish(){_(this,Ec)&&(_(this,Ec).focus({focusVisible:_(this,J0)}),te(this,J0,!1))}isEmpty(){return _(this,Lu)?_(this,vi)===null:!_(this,vi)&&!_(this,Ou)}hasData(){return _(this,Lu)?_(this,vi)!==null||!!_(this,ah):this.isEmpty()}get guessedText(){return _(this,ah)}async setGuessedText(e){_(this,vi)===null&&(te(this,ah,e),te(this,$x,await Oa._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),de(this,qc,dP).call(this))}toggleAltTextBadge(e=!1){var r;if(!_(this,Lu)||_(this,vi)){(r=_(this,Du))==null||r.remove(),te(this,Du,null);return}if(!_(this,Du)){const n=te(this,Du,document.createElement("div"));n.className="noAltTextBadge",_(this,lo).div.append(n)}_(this,Du).classList.toggle("hidden",!e)}serialize(e){let r=_(this,vi);return!e&&_(this,ah)===r&&(r=_(this,$x)),{altText:r,decorative:_(this,Ou),guessedText:_(this,ah),textWithDisclaimer:_(this,$x)}}get data(){return{altText:_(this,vi),decorative:_(this,Ou)}}set data({altText:e,decorative:r,guessedText:n,textWithDisclaimer:s,cancel:i=!1}){n&&(te(this,ah,n),te(this,$x,s)),!(_(this,vi)===e&&_(this,Ou)===r)&&(i||(te(this,vi,e),te(this,Ou,r)),de(this,qc,dP).call(this))}toggle(e=!1){_(this,Ec)&&(!e&&_(this,Do)&&(clearTimeout(_(this,Do)),te(this,Do,null)),_(this,Ec).disabled=!e)}shown(){_(this,lo)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:_(this,qc,YS)}})}destroy(){var e,r;(e=_(this,Ec))==null||e.remove(),te(this,Ec,null),te(this,Z0,null),te(this,Mu,null),(r=_(this,Du))==null||r.remove(),te(this,Du,null)}};vi=new WeakMap,Ou=new WeakMap,Ec=new WeakMap,Z0=new WeakMap,Mu=new WeakMap,Do=new WeakMap,J0=new WeakMap,Du=new WeakMap,lo=new WeakMap,ah=new WeakMap,$x=new WeakMap,Lu=new WeakMap,Fp=new WeakMap,qc=new WeakSet,YS=function(){return _(this,vi)&&"added"||_(this,vi)===null&&this.guessedText&&"review"||"missing"},dP=async function(){var s,i,a;const e=_(this,Ec);if(!e)return;if(_(this,Lu)){if(e.classList.toggle("done",!!_(this,vi)),e.setAttribute("data-l10n-id",_(Oa,Fp)[_(this,qc,YS)]),(s=_(this,Z0))==null||s.setAttribute("data-l10n-id",_(Oa,Fp)[`${_(this,qc,YS)}-label`]),!_(this,vi)){(i=_(this,Mu))==null||i.remove();return}}else{if(!_(this,vi)&&!_(this,Ou)){e.classList.remove("done"),(a=_(this,Mu))==null||a.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let r=_(this,Mu);if(!r){te(this,Mu,r=document.createElement("span")),r.className="tooltip",r.setAttribute("role","tooltip"),r.id=`alt-text-tooltip-${_(this,lo).id}`;const l=100,c=_(this,lo)._uiManager._signal;c.addEventListener("abort",()=>{clearTimeout(_(this,Do)),te(this,Do,null)},{once:!0}),e.addEventListener("mouseenter",()=>{te(this,Do,setTimeout(()=>{te(this,Do,null),_(this,Mu).classList.add("show"),_(this,lo)._reportTelemetry({action:"alt_text_tooltip"})},l))},{signal:c}),e.addEventListener("mouseleave",()=>{var u;_(this,Do)&&(clearTimeout(_(this,Do)),te(this,Do,null)),(u=_(this,Mu))==null||u.classList.remove("show")},{signal:c})}_(this,Ou)?r.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(r.removeAttribute("data-l10n-id"),r.textContent=_(this,vi)),r.parentNode||e.append(r);const n=_(this,lo).getElementForAltText();n==null||n.setAttribute("aria-describedby",r.id)},le(Oa,Fp,null),Ge(Oa,"_l10n",null);let eO=Oa;var $u,Fx,Ac,lC,oh,ew,Bp,Qce;let RT=(Qce=class{constructor(e){le(this,$u,null);le(this,Fx,!1);le(this,Ac,null);le(this,lC,null);le(this,oh,null);le(this,ew,null);le(this,Bp,!1);te(this,Ac,e),this.toolbar=null}render(){if(!_(this,Ac)._uiManager.hasCommentManager())return null;const e=te(this,$u,document.createElement("button"));e.className="comment",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button");const r=_(this,Ac)._uiManager._signal;e.addEventListener("contextmenu",lc,{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,Fx,!0),n(s))},{signal:r}),e}edit(){const{bottom:e,left:r,right:n}=_(this,Ac).getClientDimensions(),s={top:e};_(this,Ac)._uiManager.direction==="ltr"?s.right=n:s.left=r,_(this,Ac)._uiManager.editComment(_(this,Ac),s)}finish(){_(this,$u)&&(_(this,$u).focus({focusVisible:_(this,Fx)}),te(this,Fx,!1))}isDeleted(){return _(this,Bp)||_(this,oh)===""}hasBeenEdited(){return this.isDeleted()||_(this,oh)!==_(this,lC)}serialize(){return this.data}get data(){return{text:_(this,oh),date:_(this,ew),deleted:_(this,Bp)}}set data(e){if(e===null){te(this,oh,""),te(this,Bp,!0);return}te(this,oh,e),te(this,ew,new Date),te(this,Bp,!1)}setInitialText(e){te(this,lC,e),this.data=e}toggle(e=!1){_(this,$u)&&(_(this,$u).disabled=!e)}shown(){}destroy(){var e;(e=_(this,$u))==null||e.remove(),te(this,$u,null),te(this,oh,""),te(this,ew,null),te(this,Ac,null),te(this,Fx,!1),te(this,Bp,!1)}},$u=new WeakMap,Fx=new WeakMap,Ac=new WeakMap,lC=new WeakMap,oh=new WeakMap,ew=new WeakMap,Bp=new WeakMap,Qce);var tw,Bx,cC,uC,dC,hC,fC,lh,zx,ch,Ux,uh,Jm,VSe,qSe,GSe;const UK=class UK{constructor({container:e,isPinchingDisabled:r=null,isPinchingStopped:n=null,onPinchStart:s=null,onPinching:i=null,onPinchEnd:a=null,signal:l}){le(this,Jm);le(this,tw);le(this,Bx,!1);le(this,cC,null);le(this,uC);le(this,dC);le(this,hC);le(this,fC);le(this,lh,null);le(this,zx);le(this,ch,null);le(this,Ux);le(this,uh,null);te(this,tw,e),te(this,cC,n),te(this,uC,r),te(this,dC,s),te(this,hC,i),te(this,fC,a),te(this,Ux,new AbortController),te(this,zx,AbortSignal.any([l,_(this,Ux).signal])),e.addEventListener("touchstart",de(this,Jm,VSe).bind(this),{passive:!1,signal:_(this,zx)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/md.pixelRatio}destroy(){var e,r;(e=_(this,Ux))==null||e.abort(),te(this,Ux,null),(r=_(this,lh))==null||r.abort(),te(this,lh,null)}};tw=new WeakMap,Bx=new WeakMap,cC=new WeakMap,uC=new WeakMap,dC=new WeakMap,hC=new WeakMap,fC=new WeakMap,lh=new WeakMap,zx=new WeakMap,ch=new WeakMap,Ux=new WeakMap,uh=new WeakMap,Jm=new WeakSet,VSe=function(e){var s,i,a;if((s=_(this,uC))!=null&&s.call(this))return;if(e.touches.length===1){if(_(this,lh))return;const l=te(this,lh,new AbortController),c=AbortSignal.any([_(this,zx),l.signal]),u=_(this,tw),d={capture:!0,signal:c,passive:!1},h=f=>{var p;f.pointerType==="touch"&&((p=_(this,lh))==null||p.abort(),te(this,lh,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,uh)){te(this,uh,new AbortController);const l=AbortSignal.any([_(this,zx),_(this,uh).signal]),c=_(this,tw),u={signal:l,capture:!1,passive:!1};c.addEventListener("touchmove",de(this,Jm,qSe).bind(this),u);const d=de(this,Jm,GSe).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,dC))==null||i.call(this)}if(Ls(e),e.touches.length!==2||(a=_(this,cC))!=null&&a.call(this)){te(this,ch,null);return}let[r,n]=e.touches;r.identifier>n.identifier&&([r,n]=[n,r]),te(this,ch,{touch0X:r.screenX,touch0Y:r.screenY,touch1X:n.screenX,touch1Y:n.screenY})},qSe=function(e){var w;if(!_(this,ch)||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:l}=n,c=_(this,ch),{touch0X:u,touch0Y:d,touch1X:h,touch1Y:f}=c,p=h-u,m=f-d,g=a-s,y=l-i,x=Math.hypot(g,y)||1,v=Math.hypot(p,m)||1;if(!_(this,Bx)&&Math.abs(v-x)<=UK.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=s,c.touch0Y=i,c.touch1X=a,c.touch1Y=l,!_(this,Bx)){te(this,Bx,!0);return}const b=[(s+a)/2,(i+l)/2];(w=_(this,hC))==null||w.call(this,b,v,x)},GSe=function(e){var r;e.touches.length>=2||(_(this,uh)&&(_(this,uh).abort(),te(this,uh,null),(r=_(this,fC))==null||r.call(this)),_(this,ch)&&(Ls(e),te(this,ch,null),te(this,Bx,!1)))};let tO=UK;var Hx,Tc,Hn,zi,rw,zp,pC,Wx,Ui,Vx,dh,Up,mC,qx,Lo,gC,Gx,hh,Fu,nw,sw,Rl,Kx,xC,cM,Bt,FU,yC,BU,hP,KSe,YSe,zU,fP,UU,XSe,QSe,ZSe,HU,JSe,WU,e_e,t_e,r_e,VU,XS;const ar=class ar{constructor(e){le(this,Bt);le(this,Hx,null);le(this,Tc,null);le(this,Hn,null);le(this,zi,null);le(this,rw,!1);le(this,zp,null);le(this,pC,"");le(this,Wx,!1);le(this,Ui,null);le(this,Vx,null);le(this,dh,null);le(this,Up,null);le(this,mC,"");le(this,qx,!1);le(this,Lo,null);le(this,gC,!1);le(this,Gx,!1);le(this,hh,!1);le(this,Fu,null);le(this,nw,0);le(this,sw,0);le(this,Rl,null);le(this,Kx,null);Ge(this,"isSelected",!1);Ge(this,"_isCopy",!1);Ge(this,"_editToolbar",null);Ge(this,"_initialOptions",Object.create(null));Ge(this,"_initialData",null);Ge(this,"_isVisible",!0);Ge(this,"_uiManager",null);Ge(this,"_focusEventsAllowed",!0);le(this,xC,!1);le(this,cM,ar._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[l,c]=this.parentDimensions;this.x=e.x/l,this.y=e.y/c,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=ar.prototype._resizeWithKeyboard,r=mv.TRANSLATE_SMALL,n=mv.TRANSLATE_BIG;return gr(this,"_resizerKeyboardManager",new dA([[["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"],ar.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 gr(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const r=new eEt({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(ar._l10n??(ar._l10n=e),ar._l10nResizer||(ar._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"})),ar._borderLineWidth!==-1)return;const n=getComputedStyle(document.documentElement);ar._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,r){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,r){hn("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return _(this,xC)}set _isDraggable(e){var r;te(this,xC,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,cM)}setParent(e){e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):de(this,Bt,XS).call(this),this.parent=e}focusin(e){this._focusEventsAllowed&&(_(this,qx)?te(this,qx,!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){de(this,Bt,FU).call(this,this.parentDimensions,e,r)}translateInPage(e,r){_(this,Lo)||te(this,Lo,[this.x,this.y,this.width,this.height]),de(this,Bt,FU).call(this,this.pageDimensions,e,r),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,r){_(this,Lo)||te(this,Lo,[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:l}=this;const[c,u]=this.getBaseTranslation();a+=c,l+=u;const{style:d}=n;d.left=`${(100*a).toFixed(2)}%`,d.top=`${(100*l).toFixed(2)}%`,this._onTranslating(a,l),n.scrollIntoView({block:"nearest"})}_onTranslating(e,r){}_onTranslated(e,r){}get _hasBeenMoved(){return!!_(this,Lo)&&(_(this,Lo)[0]!==this.x||_(this,Lo)[1]!==this.y)}get _hasBeenResized(){return!!_(this,Lo)&&(_(this,Lo)[2]!==this.width||_(this,Lo)[3]!==this.height)}getBaseTranslation(){const[e,r]=this.parentDimensions,{_borderLineWidth:n}=ar,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:l,height:c}=this;if(l*=n,c*=s,i*=n,a*=s,this._mustFixPosition)switch(e){case 0:i=za(i,0,n-l),a=za(a,0,s-c);break;case 90:i=za(i,0,n-c),a=za(a,l,s);break;case 180:i=za(i,l,n),a=za(a,c,s);break;case 270:i=za(i,c,n),a=za(a,0,s-l);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 de(n=ar,yC,BU).call(n,e,r,this.parentRotation)}pageTranslationToScreen(e,r){var n;return de(n=ar,yC,BU).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,Wx)||(i.height=`${(100*r/s).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:r,width:n}=e,s=n.endsWith("%"),i=!_(this,Wx)&&r.endsWith("%");if(s&&i)return;const[a,l]=this.parentDimensions;s||(e.width=`${(100*parseFloat(n)/a).toFixed(2)}%`),!_(this,Wx)&&!i&&(e.height=`${(100*parseFloat(r)/l).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(e*1e4)/1e4}_onResizing(){}altTextFinish(){var e;(e=_(this,Hn))==null||e.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||_(this,Gx))return this._editToolbar;this._editToolbar=new TU(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,Hn))==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,Hn)||(eO.initialize(ar._l10n),te(this,Hn,new eO(this)),_(this,Hx)&&(_(this,Hn).data=_(this,Hx),te(this,Hx,null))),_(this,Hn)}get altTextData(){var e;return(e=_(this,Hn))==null?void 0:e.data}set altTextData(e){_(this,Hn)&&(_(this,Hn).data=e)}get guessedAltText(){var e;return(e=_(this,Hn))==null?void 0:e.guessedText}async setGuessedAltText(e){var r;await((r=_(this,Hn))==null?void 0:r.setGuessedText(e))}serializeAltText(e){var r;return(r=_(this,Hn))==null?void 0:r.serialize(e)}hasAltText(){return!!_(this,Hn)&&!_(this,Hn).isEmpty()}hasAltTextData(){var e;return((e=_(this,Hn))==null?void 0:e.hasData())??!1}addCommentButton(){return _(this,zi)?_(this,zi):te(this,zi,new RT(this))}get commentColor(){return null}get comment(){const e=_(this,zi);return{text:e.data.text,date:e.data.date,deleted:e.isDeleted(),color:this.commentColor}}set comment(e){_(this,zi)||te(this,zi,new RT(this)),_(this,zi).data=e}setCommentData(e){_(this,zi)||te(this,zi,new RT(this)),_(this,zi).setInitialText(e)}get hasEditedComment(){var e;return(e=_(this,zi))==null?void 0:e.hasBeenEdited()}async editComment(){_(this,zi)||te(this,zi,new RT(this)),_(this,zi).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,rw)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),de(this,Bt,WU).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),RSe(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(_(this,Kx)||te(this,Kx,new tO({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:de(this,Bt,XSe).bind(this),onPinching:de(this,Bt,QSe).bind(this),onPinchEnd:de(this,Bt,ZSe).bind(this),signal:this._uiManager._signal}))),(a=this._uiManager._editorUndoBar)==null||a.hide(),e}pointerdown(e){const{isMac:r}=oa.platform;if(e.button!==0||e.ctrlKey&&r){e.preventDefault();return}if(te(this,qx,!0),this._isDraggable){de(this,Bt,JSe).call(this,e);return}de(this,Bt,HU).call(this,e)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){_(this,Fu)&&clearTimeout(_(this,Fu)),te(this,Fu,setTimeout(()=>{var e;te(this,Fu,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,[l,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+l,a-f-d-m+c,h+u+p+l,a-f-d+c];case 90:return[h+d+l,a-f+u+c,h+d+m+l,a-f+u+p+c];case 180:return[h-u-p+l,a-f+d+c,h-u+l,a-f+d+m+c];case 270:return[h-d-m+l,a-f-u-p+c,h-d+l,a-f-u+c];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,r){const[n,s,i,a]=e,l=i-n,c=a-s;switch(this.rotation){case 0:return[n,r-a,l,c];case 90:return[n,r-s,c,l];case 180:return[i,r-s,l,c];case 270:return[i,r-a,c,l];default:throw new Error("Invalid rotation")}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),te(this,Gx,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),te(this,Gx,!1),!0):!1}isInEditMode(){return _(this,Gx)}shouldGetKeyboardEvents(){return _(this,hh)}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(){de(this,Bt,WU).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){hn("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,Hx,e.accessibilityData),s._isCopy=e.isCopy||!1;const[i,a]=s.pageDimensions,[l,c,u,d]=s.getRectInCurrentCoords(e.rect,a);return s.x=l/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,Up))==null||e.abort(),te(this,Up,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),_(this,Fu)&&(clearTimeout(_(this,Fu)),te(this,Fu,null)),de(this,Bt,XS).call(this),this.removeEditToolbar(),_(this,Rl)){for(const n of _(this,Rl).values())clearTimeout(n);te(this,Rl,null)}this.parent=null,(r=_(this,Kx))==null||r.destroy(),te(this,Kx,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(de(this,Bt,KSe).call(this),_(this,Ui).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,dh,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const r=_(this,Ui).children;if(!_(this,Tc)){te(this,Tc,Array.from(r));const a=de(this,Bt,e_e).bind(this),l=de(this,Bt,t_e).bind(this),c=this._uiManager._signal;for(const u of _(this,Tc)){const d=u.getAttribute("data-resizer-name");u.setAttribute("role","spinbutton"),u.addEventListener("keydown",a,{signal:c}),u.addEventListener("blur",l,{signal:c}),u.addEventListener("focus",de(this,Bt,r_e).bind(this,d),{signal:c}),u.setAttribute("data-l10n-id",ar._l10nResizer[d])}}const n=_(this,Tc)[0];let s=0;for(const a of r){if(a===n)break;s++}const i=(360-this.rotation+this.parentRotation)%360/90*(_(this,Tc).length/4);if(i!==s){if(i<s)for(let l=0;l<s-i;l++)_(this,Ui).append(_(this,Ui).firstChild);else if(i>s)for(let l=0;l<i-s;l++)_(this,Ui).firstChild.before(_(this,Ui).lastChild);let a=0;for(const l of r){const u=_(this,Tc)[a++].getAttribute("data-resizer-name");l.setAttribute("data-l10n-id",ar._l10nResizer[u])}}de(this,Bt,VU).call(this,0),te(this,hh,!0),_(this,Ui).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(e,r){_(this,hh)&&de(this,Bt,UU).call(this,_(this,mC),{deltaX:e,deltaY:r,fromKeyboard:!0})}_stopResizingWithKeyboard(){de(this,Bt,XS).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,Hn))==null||n.toggleAltTextBadge(!1)}}unselect(){var e,r,n,s,i;this.isSelected&&(this.isSelected=!1,(e=_(this,Ui))==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,Hn))==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,gC)}set isEditing(e){te(this,gC,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,r){te(this,Wx,!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,Rl)||te(this,Rl,new Map);const{action:n}=e;let s=_(this,Rl).get(n);s&&clearTimeout(s),s=setTimeout(()=>{this._reportTelemetry(e),_(this,Rl).delete(n),_(this,Rl).size===0&&te(this,Rl,null)},ar._telemetryTimeout),_(this,Rl).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,rw,!1)}disable(){this.div&&(this.div.tabIndex=-1),te(this,rw,!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()}};Hx=new WeakMap,Tc=new WeakMap,Hn=new WeakMap,zi=new WeakMap,rw=new WeakMap,zp=new WeakMap,pC=new WeakMap,Wx=new WeakMap,Ui=new WeakMap,Vx=new WeakMap,dh=new WeakMap,Up=new WeakMap,mC=new WeakMap,qx=new WeakMap,Lo=new WeakMap,gC=new WeakMap,Gx=new WeakMap,hh=new WeakMap,Fu=new WeakMap,nw=new WeakMap,sw=new WeakMap,Rl=new WeakMap,Kx=new WeakMap,xC=new WeakMap,cM=new WeakMap,Bt=new WeakSet,FU=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()},yC=new WeakSet,BU=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]}},hP=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]}},KSe=function(){if(_(this,Ui))return;te(this,Ui,document.createElement("div")),_(this,Ui).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,Ui).append(s),s.classList.add("resizer",n),s.setAttribute("data-resizer-name",n),s.addEventListener("pointerdown",de(this,Bt,YSe).bind(this,n),{signal:r}),s.addEventListener("contextmenu",lc,{signal:r}),s.tabIndex=-1}this.div.prepend(_(this,Ui))},YSe=function(e,r){var d;r.preventDefault();const{isMac:n}=oa.platform;if(r.button!==0||r.ctrlKey&&n)return;(d=_(this,Hn))==null||d.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,te(this,Vx,[r.screenX,r.screenY]);const i=new AbortController,a=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",de(this,Bt,UU).bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Ls,{passive:!1,signal:a}),window.addEventListener("contextmenu",lc,{signal:a}),te(this,dh,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const l=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,Hn))==null||h.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=l,this.div.style.cursor=c,de(this,Bt,fP).call(this)};window.addEventListener("pointerup",u,{signal:a}),window.addEventListener("blur",u,{signal:a})},zU=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()},fP=function(){if(!_(this,dh))return;const{savedX:e,savedY:r,savedWidth:n,savedHeight:s}=_(this,dh);te(this,dh,null);const i=this.x,a=this.y,l=this.width,c=this.height;i===e&&a===r&&l===n&&c===s||this.addCommands({cmd:de(this,Bt,zU).bind(this,i,a,l,c),undo:de(this,Bt,zU).bind(this,e,r,n,s),mustExec:!0})},UU=function(e,r){const[n,s]=this.parentDimensions,i=this.x,a=this.y,l=this.width,c=this.height,u=ar.MIN_SIZE/n,d=ar.MIN_SIZE/s,h=de(this,Bt,hP).call(this,this.rotation),f=(K,H)=>[h[0]*K+h[2]*H,h[1]*K+h[3]*H],p=de(this,Bt,hP).call(this,360-this.rotation),m=(K,H)=>[p[0]*K+p[2]*H,p[1]*K+p[3]*H];let g,y,x=!1,v=!1;switch(e){case"topLeft":x=!0,g=(K,H)=>[0,0],y=(K,H)=>[K,H];break;case"topMiddle":g=(K,H)=>[K/2,0],y=(K,H)=>[K/2,H];break;case"topRight":x=!0,g=(K,H)=>[K,0],y=(K,H)=>[0,H];break;case"middleRight":v=!0,g=(K,H)=>[K,H/2],y=(K,H)=>[0,H/2];break;case"bottomRight":x=!0,g=(K,H)=>[K,H],y=(K,H)=>[0,0];break;case"bottomMiddle":g=(K,H)=>[K/2,H],y=(K,H)=>[K/2,0];break;case"bottomLeft":x=!0,g=(K,H)=>[0,H],y=(K,H)=>[K,0];break;case"middleLeft":v=!0,g=(K,H)=>[0,H/2],y=(K,H)=>[K,H/2];break}const b=g(l,c),w=y(l,c);let j=f(...w);const N=ar._round(i+j[0]),C=ar._round(a+j[1]);let A=1,E=1,O,$;if(r.fromKeyboard)({deltaX:O,deltaY:$}=r);else{const{screenX:K,screenY:H}=r,[ee,V]=_(this,Vx);[O,$]=this.screenToPageTranslation(K-ee,H-V),_(this,Vx)[0]=K,_(this,Vx)[1]=H}if([O,$]=m(O/n,$/s),x){const K=Math.hypot(l,c);A=E=Math.max(Math.min(Math.hypot(w[0]-b[0]-O,w[1]-b[1]-$)/K,1/l,1/c),u/l,d/c)}else v?A=za(Math.abs(w[0]-b[0]-O),u,1)/l:E=za(Math.abs(w[1]-b[1]-$),d,1)/c;const T=ar._round(l*A),M=ar._round(c*E);j=f(...y(T,M));const k=N-j[0],D=C-j[1];_(this,Lo)||te(this,Lo,[this.x,this.y,this.width,this.height]),this.width=T,this.height=M,this.x=k,this.y=D,this.setDims(n*T,s*M),this.fixAndSetPosition(),this._onResizing()},XSe=function(){var e;te(this,dh,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(e=_(this,Hn))==null||e.toggle(!1),this.parent.togglePointerEvents(!1)},QSe=function(e,r,n){let i=.7*(n/r)+1-.7;if(i===1)return;const a=de(this,Bt,hP).call(this,this.rotation),l=(N,C)=>[a[0]*N+a[2]*C,a[1]*N+a[3]*C],[c,u]=this.parentDimensions,d=this.x,h=this.y,f=this.width,p=this.height,m=ar.MIN_SIZE/c,g=ar.MIN_SIZE/u;i=Math.max(Math.min(i,1/f,1/p),m/f,g/p);const y=ar._round(f*i),x=ar._round(p*i);if(y===f&&x===p)return;_(this,Lo)||te(this,Lo,[d,h,f,p]);const v=l(f/2,p/2),b=ar._round(d+v[0]),w=ar._round(h+v[1]),j=l(y/2,x/2);this.x=b-j[0],this.y=w-j[1],this.width=y,this.height=x,this.setDims(c*y,u*x),this.fixAndSetPosition(),this._onResizing()},ZSe=function(){var e;(e=_(this,Hn))==null||e.toggle(!0),this.parent.togglePointerEvents(!0),de(this,Bt,fP).call(this)},HU=function(e){const{isMac:r}=oa.platform;e.ctrlKey&&!r||e.shiftKey||e.metaKey&&r?this.parent.toggleSelected(this):this.parent.setSelected(this)},JSe=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},l=u=>{s.abort(),te(this,zp,null),te(this,qx,!1),this._uiManager.endDragSession()||de(this,Bt,HU).call(this,u),n&&this._onStopDragging()};r&&(te(this,nw,e.clientX),te(this,sw,e.clientY),te(this,zp,e.pointerId),te(this,pC,e.pointerType),window.addEventListener("pointermove",u=>{n||(n=!0,this._onStartDragging());const{clientX:d,clientY:h,pointerId:f}=u;if(f!==_(this,zp)){Ls(u);return}const[p,m]=this.screenToPageTranslation(d-_(this,nw),h-_(this,sw));te(this,nw,d),te(this,sw,h),this._uiManager.dragSelectedEditors(p,m)},a),window.addEventListener("touchmove",Ls,a),window.addEventListener("pointerdown",u=>{u.pointerType===_(this,pC)&&(_(this,Kx)||u.isPrimary)&&l(u),Ls(u)},a));const c=u=>{if(!_(this,zp)||_(this,zp)===u.pointerId){l(u);return}Ls(u)};window.addEventListener("pointerup",c,{signal:i}),window.addEventListener("blur",c,{signal:i})},WU=function(){if(_(this,Up)||!this.div)return;te(this,Up,new AbortController);const e=this._uiManager.combinedSignal(_(this,Up));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})},e_e=function(e){ar._resizerKeyboardManager.exec(this,e)},t_e=function(e){var r;_(this,hh)&&((r=e.relatedTarget)==null?void 0:r.parentNode)!==_(this,Ui)&&de(this,Bt,XS).call(this)},r_e=function(e){te(this,mC,_(this,hh)?e:"")},VU=function(e){if(_(this,Tc))for(const r of _(this,Tc))r.tabIndex=e},XS=function(){te(this,hh,!1),de(this,Bt,VU).call(this,-1),de(this,Bt,fP).call(this)},le(ar,yC),Ge(ar,"_l10n",null),Ge(ar,"_l10nResizer",null),Ge(ar,"_borderLineWidth",-1),Ge(ar,"_colorManager",new IU),Ge(ar,"_zIndex",1),Ge(ar,"_telemetryTimeout",1e3);let Pn=ar;class eEt extends Pn{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const fse=3285377520,Sl=4294901760,xu=65535;class n_e{constructor(e){this.h1=e?e&4294967295:fse,this.h2=e?e&4294967295:fse}update(e){let r,n;if(typeof e=="string"){r=new Uint8Array(e.length*2),n=0;for(let g=0,y=e.length;g<y;g++){const x=e.charCodeAt(g);x<=255?r[n++]=x:(r[n++]=x>>>8,r[n++]=x&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 l=0,c=0,u=this.h1,d=this.h2;const h=3432918353,f=461845907,p=h&xu,m=f&xu;for(let g=0;g<s;g++)g&1?(l=a[g],l=l*h&Sl|l*p&xu,l=l<<15|l>>>17,l=l*f&Sl|l*m&xu,u^=l,u=u<<13|u>>>19,u=u*5+3864292196):(c=a[g],c=c*h&Sl|c*p&xu,c=c<<15|c>>>17,c=c*f&Sl|c*m&xu,d^=c,d=d<<13|d>>>19,d=d*5+3864292196);switch(l=0,i){case 3:l^=r[s*4+2]<<16;case 2:l^=r[s*4+1]<<8;case 1:l^=r[s*4],l=l*h&Sl|l*p&xu,l=l<<15|l>>>17,l=l*f&Sl|l*m&xu,s&1?u^=l:d^=l}this.h1=u,this.h2=d}hexdigest(){let e=this.h1,r=this.h2;return e^=r>>>1,e=e*3981806797&Sl|e*36045&xu,r=r*4283543511&Sl|((r<<16|e>>>16)*2950163797&Sl)>>>16,e^=r>>>1,e=e*444984403&Sl|e*60499&xu,r=r*3301882366&Sl|((r<<16|e>>>16)*3120437893&Sl)>>>16,e^=r>>>1,(e>>>0).toString(16).padStart(8,"0")+(r>>>0).toString(16).padStart(8,"0")}}const qU=Object.freeze({map:null,hash:"",transfer:void 0});var Yx,Xx,Hi,uM,s_e;class gG{constructor(){le(this,uM);le(this,Yx,!1);le(this,Xx,null);le(this,Hi,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,r){const n=_(this,Hi).get(e);return n===void 0?r:Object.assign(r,n)}getRawValue(e){return _(this,Hi).get(e)}remove(e){if(_(this,Hi).delete(e),_(this,Hi).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const r of _(this,Hi).values())if(r instanceof Pn)return;this.onAnnotationEditor(null)}}setValue(e,r){const n=_(this,Hi).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,Hi).set(e,r);s&&de(this,uM,s_e).call(this),r instanceof Pn&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(r.constructor._type)}has(e){return _(this,Hi).has(e)}get size(){return _(this,Hi).size}resetModified(){_(this,Yx)&&(te(this,Yx,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new i_e(this)}get serializable(){if(_(this,Hi).size===0)return qU;const e=new Map,r=new n_e,n=[],s=Object.create(null);let i=!1;for(const[a,l]of _(this,Hi)){const c=l instanceof Pn?l.serialize(!1,s):l;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}:qU}get editorStats(){let e=null;const r=new Map;for(const n of _(this,Hi).values()){if(!(n instanceof Pn))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[l,c]of Object.entries(s)){if(l==="type")continue;let u=a.get(l);u||(u=new Map,a.set(l,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,Xx,null)}get modifiedIds(){if(_(this,Xx))return _(this,Xx);const e=[];for(const r of _(this,Hi).values())!(r instanceof Pn)||!r.annotationElementId||!r.serialize()||e.push(r.annotationElementId);return te(this,Xx,{ids:new Set(e),hash:e.join(",")})}[Symbol.iterator](){return _(this,Hi).entries()}}Yx=new WeakMap,Xx=new WeakMap,Hi=new WeakMap,uM=new WeakSet,s_e=function(){_(this,Yx)||(te(this,Yx,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var vC;class i_e extends gG{constructor(r){super();le(this,vC);const{map:n,hash:s,transfer:i}=r.serializable,a=structuredClone(n,i?{transfer:i}:null);te(this,vC,{map:a,hash:s,transfer:i})}get print(){hn("Should not call PrintAnnotationStorage.print")}get serializable(){return _(this,vC)}get modifiedIds(){return gr(this,"modifiedIds",{ids:new Set,hash:""})}}vC=new WeakMap;var iw;class tEt{constructor({ownerDocument:e=globalThis.document,styleElement:r=null}){le(this,iw,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,iw).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,disableFontFace:r,_inspectFont:n}){if(!(!e||_(this,iw).has(e.loadedName))){if(Fs(!r,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:a}=e,l=new FontFace(s,i,a);this.addNativeFontFace(l);try{await l.load(),_(this,iw).add(s),n==null||n(e)}catch{Zt(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(l)}return}hn("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 Zt(`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 gr(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return gr(this,"isSyncFontLoadingSupported",Ba||oa.platform.isFirefox)}_queueLoadingCallback(e){function r(){for(Fs(!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 gr(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,r){function n(w,j){return w.charCodeAt(j)<<24|w.charCodeAt(j+1)<<16|w.charCodeAt(j+2)<<8|w.charCodeAt(j+3)&255}function s(w,j,N,C){const A=w.substring(0,j),E=w.substring(j+N);return A+C+E}let i,a;const l=this._document.createElement("canvas");l.width=1,l.height=1;const c=l.getContext("2d");let u=0;function d(w,j){if(++u>30){Zt("Load test font never loaded."),j();return}if(c.font="30px "+w,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){j();return}setTimeout(d.bind(null,w,j))}const h=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=s(f,976,h.length,h);const m=16,g=1482184792;let y=n(f,m);for(i=0,a=h.length-3;i<a;i+=4)y=y-g+n(h,i)|0;i<h.length&&(y=y-g+n(h+"XXX",i)|0),f=s(f,m,4,FCt(y));const x=`url(data:font/opentype;base64,${btoa(f)});`,v=`@font-face {font-family:"${h}";src:${x}}`;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 j=this._document.createElement("span");j.textContent="Hi",j.style.fontFamily=w,b.append(j)}this._document.body.append(b),d(h,()=>{b.remove(),r.complete()})}}iw=new WeakMap;class rEt{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,${kSe(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){Zt(`getPathGenerator - ignoring character: "${a}".`)}const i=new Path2D(s||"");return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[r]=i}}function nEt(t){if(t instanceof URL)return t.href;if(typeof t=="string"){if(Ba)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 sEt(t){if(Ba&&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 lA(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 OT(t){if(typeof t!="string")return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const GU=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,iEt=t=>typeof t=="object"&&typeof(t==null?void 0:t.name)=="string",aEt=WCt.bind(null,GU,iEt);var fh,dM;class oEt{constructor(){le(this,fh,new Map);le(this,dM,Promise.resolve())}postMessage(e,r){const n={data:structuredClone(e,r?{transfer:r}:null)};_(this,dM).then(()=>{for(const[s]of _(this,fh))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){Zt("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(e,r);s=()=>i.removeEventListener("abort",a),i.addEventListener("abort",a)}_(this,fh).set(r,s)}removeEventListener(e,r){const n=_(this,fh).get(r);n==null||n(),_(this,fh).delete(r)}terminate(){for(const[,e]of _(this,fh))e==null||e();_(this,fh).clear()}}fh=new WeakMap,dM=new WeakMap;const MT={DATA:1,ERROR:2},Rs={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function pse(){}function so(t){if(t instanceof Gm||t instanceof CU||t instanceof use||t instanceof ZR||t instanceof W3)return t;switch(t instanceof Error||typeof t=="object"&&t!==null||hn('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Gm(t.message);case"InvalidPDFException":return new CU(t.message);case"PasswordException":return new use(t.message,t.code);case"ResponseException":return new ZR(t.message,t.status,t.missing);case"UnknownErrorException":return new W3(t.message,t.details)}return new W3(t.message,t.toString())}var aw,sc,a_e,o_e,l_e,pP;class QS{constructor(e,r,n){le(this,sc);le(this,aw,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",de(this,sc,a_e).bind(this),{signal:_(this,aw).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,l=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:l,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:l,stream:Rs.PULL,streamId:i,desiredSize:u.desiredSize}),d.promise},cancel:u=>{Fs(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:l,stream:Rs.CANCEL,streamId:i,reason:so(u)}),d.promise}},n)}destroy(){var e;(e=_(this,aw))==null||e.abort(),te(this,aw,null)}}aw=new WeakMap,sc=new WeakSet,a_e=function({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){de(this,sc,l_e).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===MT.DATA)s.resolve(e.data);else if(e.callback===MT.ERROR)s.reject(so(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:MT.DATA,callbackId:e.callbackId,data:a})},function(a){i.postMessage({sourceName:n,targetName:s,callback:MT.ERROR,callbackId:e.callbackId,reason:so(a)})});return}if(e.streamId){de(this,sc,o_e).call(this,e);return}r(e.data)},o_e=function(e){const r=e.streamId,n=this.sourceName,s=e.sourceName,i=this.comObj,a=this,l=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:Rs.ENQUEUE,streamId:r,chunk:u},h)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:s,stream:Rs.CLOSE,streamId:r}),delete a.streamSinks[r])},error(u){Fs(u instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:n,targetName:s,stream:Rs.ERROR,streamId:r,reason:so(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(l,e.data,c).then(function(){i.postMessage({sourceName:n,targetName:s,stream:Rs.START_COMPLETE,streamId:r,success:!0})},function(u){i.postMessage({sourceName:n,targetName:s,stream:Rs.START_COMPLETE,streamId:r,reason:so(u)})})},l_e=function(e){const r=e.streamId,n=this.sourceName,s=e.sourceName,i=this.comObj,a=this.streamControllers[r],l=this.streamSinks[r];switch(e.stream){case Rs.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(so(e.reason));break;case Rs.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(so(e.reason));break;case Rs.PULL:if(!l){i.postMessage({sourceName:n,targetName:s,stream:Rs.PULL_COMPLETE,streamId:r,success:!0});break}l.desiredSize<=0&&e.desiredSize>0&&l.sinkCapability.resolve(),l.desiredSize=e.desiredSize,Promise.try(l.onPull||pse).then(function(){i.postMessage({sourceName:n,targetName:s,stream:Rs.PULL_COMPLETE,streamId:r,success:!0})},function(u){i.postMessage({sourceName:n,targetName:s,stream:Rs.PULL_COMPLETE,streamId:r,reason:so(u)})});break;case Rs.ENQUEUE:if(Fs(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(e.chunk);break;case Rs.CLOSE:if(Fs(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),de(this,sc,pP).call(this,a,r);break;case Rs.ERROR:Fs(a,"error should have stream controller"),a.controller.error(so(e.reason)),de(this,sc,pP).call(this,a,r);break;case Rs.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(so(e.reason)),de(this,sc,pP).call(this,a,r);break;case Rs.CANCEL:if(!l)break;const c=so(e.reason);Promise.try(l.onCancel||pse,c).then(function(){i.postMessage({sourceName:n,targetName:s,stream:Rs.CANCEL_COMPLETE,streamId:r,success:!0})},function(u){i.postMessage({sourceName:n,targetName:s,stream:Rs.CANCEL_COMPLETE,streamId:r,reason:so(u)})}),l.sinkCapability.reject(c),l.isCancelled=!0,delete this.streamSinks[r];break;default:throw new Error("Unexpected stream case")}},pP=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 bC;class c_e{constructor({enableHWA:e=!1}){le(this,bC,!1);te(this,bC,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,bC)})}}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){hn("Abstract method `_createCanvas` called.")}}bC=new WeakMap;class lEt extends c_e{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 u_e{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){hn("Abstract method `_fetch` called.")}}class mse extends u_e{async _fetch(e){const r=await cA(e,this.isCompressed?"arraybuffer":"text");return r instanceof ArrayBuffer?new Uint8Array(r):lA(r)}}class d_e{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 Qx,ow,ph,mh,ya,Zx,Jx,xt,ma,ZS,bb,mP,wb,h_e,KU,jb,JS,e_,YU,t_;class cEt extends d_e{constructor({docId:r,ownerDocument:n=globalThis.document}){super();le(this,xt);le(this,Qx);le(this,ow);le(this,ph);le(this,mh);le(this,ya);le(this,Zx);le(this,Jx,0);te(this,mh,r),te(this,ya,n)}addFilter(r){if(!r)return"none";let n=_(this,xt,ma).get(r);if(n)return n;const[s,i,a]=de(this,xt,mP).call(this,r),l=r.length===1?s:`${s}${i}${a}`;if(n=_(this,xt,ma).get(l),n)return _(this,xt,ma).set(r,n),n;const c=`g_${_(this,mh)}_transfer_map_${xi(this,Jx)._++}`,u=de(this,xt,wb).call(this,c);_(this,xt,ma).set(r,u),_(this,xt,ma).set(l,u);const d=de(this,xt,jb).call(this,c);return de(this,xt,e_).call(this,s,i,a,d),u}addHCMFilter(r,n){var m;const s=`${r}-${n}`,i="base";let a=_(this,xt,ZS).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,xt,ZS).set(i,a)),!r||!n))return a.url;const l=de(this,xt,t_).call(this,r);r=Rt.makeHexColor(...l);const c=de(this,xt,t_).call(this,n);if(n=Rt.makeHexColor(...c),_(this,xt,bb).style.color="",r==="#000000"&&n==="#ffffff"||r===n)return a.url;const u=new Array(256);for(let g=0;g<=255;g++){const y=g/255;u[g]=y<=.03928?y/12.92:((y+.055)/1.055)**2.4}const d=u.join(","),h=`g_${_(this,mh)}_hcm_filter`,f=a.filter=de(this,xt,jb).call(this,h);de(this,xt,e_).call(this,d,d,d,f),de(this,xt,KU).call(this,f);const p=(g,y)=>{const x=l[g]/255,v=c[g]/255,b=new Array(y+1);for(let w=0;w<=y;w++)b[w]=x+w/y*(v-x);return b.join(",")};return de(this,xt,e_).call(this,p(0,5),p(1,5),p(2,5),f),a.url=de(this,xt,wb).call(this,h),a.url}addAlphaFilter(r){let n=_(this,xt,ma).get(r);if(n)return n;const[s]=de(this,xt,mP).call(this,[r]),i=`alpha_${s}`;if(n=_(this,xt,ma).get(i),n)return _(this,xt,ma).set(r,n),n;const a=`g_${_(this,mh)}_alpha_map_${xi(this,Jx)._++}`,l=de(this,xt,wb).call(this,a);_(this,xt,ma).set(r,l),_(this,xt,ma).set(i,l);const c=de(this,xt,jb).call(this,a);return de(this,xt,YU).call(this,s,c),l}addLuminosityFilter(r){let n=_(this,xt,ma).get(r||"luminosity");if(n)return n;let s,i;if(r?([s]=de(this,xt,mP).call(this,[r]),i=`luminosity_${s}`):i="luminosity",n=_(this,xt,ma).get(i),n)return _(this,xt,ma).set(r,n),n;const a=`g_${_(this,mh)}_luminosity_map_${xi(this,Jx)._++}`,l=de(this,xt,wb).call(this,a);_(this,xt,ma).set(r,l),_(this,xt,ma).set(i,l);const c=de(this,xt,jb).call(this,a);return de(this,xt,h_e).call(this,c),r&&de(this,xt,YU).call(this,s,c),l}addHighlightHCMFilter(r,n,s,i,a){var v;const l=`${n}-${s}-${i}-${a}`;let c=_(this,xt,ZS).get(r);if((c==null?void 0:c.key)===l||(c?((v=c.filter)==null||v.remove(),c.key=l,c.url="none",c.filter=null):(c={key:l,url:"none",filter:null},_(this,xt,ZS).set(r,c)),!n||!s))return c.url;const[u,d]=[n,s].map(de(this,xt,t_).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(de(this,xt,t_).bind(this));f<h&&([h,f,p,m]=[f,h,m,p]),_(this,xt,bb).style.color="";const g=(b,w,j)=>{const N=new Array(256),C=(f-h)/j,A=b/255,E=(w-b)/(255*j);let O=0;for(let $=0;$<=j;$++){const T=Math.round(h+$*C),M=A+$*E;for(let k=O;k<=T;k++)N[k]=M;O=T+1}for(let $=O;$<256;$++)N[$]=N[O-1];return N.join(",")},y=`g_${_(this,mh)}_hcm_${r}_filter`,x=c.filter=de(this,xt,jb).call(this,y);return de(this,xt,KU).call(this,x),de(this,xt,e_).call(this,g(p[0],m[0],5),g(p[1],m[1],5),g(p[2],m[2],5),x),c.url=de(this,xt,wb).call(this,y),c.url}destroy(r=!1){var n,s,i,a;r&&((n=_(this,Zx))!=null&&n.size)||((s=_(this,ph))==null||s.parentNode.parentNode.remove(),te(this,ph,null),(i=_(this,ow))==null||i.clear(),te(this,ow,null),(a=_(this,Zx))==null||a.clear(),te(this,Zx,null),te(this,Jx,0))}}Qx=new WeakMap,ow=new WeakMap,ph=new WeakMap,mh=new WeakMap,ya=new WeakMap,Zx=new WeakMap,Jx=new WeakMap,xt=new WeakSet,ma=function(){return _(this,ow)||te(this,ow,new Map)},ZS=function(){return _(this,Zx)||te(this,Zx,new Map)},bb=function(){if(!_(this,ph)){const r=_(this,ya).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,ya).createElementNS(Bd,"svg");s.setAttribute("width",0),s.setAttribute("height",0),te(this,ph,_(this,ya).createElementNS(Bd,"defs")),r.append(s),s.append(_(this,ph)),_(this,ya).body.append(r)}return _(this,ph)},mP=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),l=new Array(256),c=new Array(256);for(let u=0;u<256;u++)a[u]=n[u]/255,l[u]=s[u]/255,c[u]=i[u]/255;return[a.join(","),l.join(","),c.join(",")]},wb=function(r){if(_(this,Qx)===void 0){te(this,Qx,"");const n=_(this,ya).URL;n!==_(this,ya).baseURI&&(UL(n)?Zt('#createUrl: ignore "data:"-URL for performance reasons.'):te(this,Qx,SSe(n,"")))}return`url(${_(this,Qx)}#${r})`},h_e=function(r){const n=_(this,ya).createElementNS(Bd,"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)},KU=function(r){const n=_(this,ya).createElementNS(Bd,"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)},jb=function(r){const n=_(this,ya).createElementNS(Bd,"filter");return n.setAttribute("color-interpolation-filters","sRGB"),n.setAttribute("id",r),_(this,xt,bb).append(n),n},JS=function(r,n,s){const i=_(this,ya).createElementNS(Bd,n);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),r.append(i)},e_=function(r,n,s,i){const a=_(this,ya).createElementNS(Bd,"feComponentTransfer");i.append(a),de(this,xt,JS).call(this,a,"feFuncR",r),de(this,xt,JS).call(this,a,"feFuncG",n),de(this,xt,JS).call(this,a,"feFuncB",s)},YU=function(r,n){const s=_(this,ya).createElementNS(Bd,"feComponentTransfer");n.append(s),de(this,xt,JS).call(this,s,"feFuncA",r)},t_=function(r){return _(this,xt,bb).style.color=r,HL(getComputedStyle(_(this,xt,bb)).getPropertyValue("color"))};class f_e{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){hn("Abstract method `_fetch` called.")}}class gse extends f_e{async _fetch(e){const r=await cA(e,"arraybuffer");return new Uint8Array(r)}}class p_e{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){hn("Abstract method `_fetch` called.")}}class xse extends p_e{async _fetch(e){const r=await cA(e,"arraybuffer");return new Uint8Array(r)}}Ba&&Zt("Please use the `legacy` build in Node.js environments.");async function xG(t){const r=await process.getBuiltinModule("fs").promises.readFile(t);return new Uint8Array(r)}class uEt extends d_e{}class dEt extends c_e{_createCanvas(e,r){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,r)}}class hEt extends u_e{async _fetch(e){return xG(e)}}class fEt extends f_e{async _fetch(e){return xG(e)}}class pEt extends p_e{async _fetch(e){return xG(e)}}const Xi={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function XU(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 yG{isModifyingCurrentTransform(){return!1}getPattern(){hn("Abstract method `getPattern` called.")}}class mEt extends yG{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===Xi.STROKE||s===Xi.FILL){const a=r.current.getClippedPathBoundingBox(s,Jn(e))||[0,0,0,0],l=Math.ceil(a[2]-a[0])||1,c=Math.ceil(a[3]-a[1])||1,u=r.cachedCanvases.getCanvas("pattern",l,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=Rt.transform(n,[1,0,0,1,a[0],a[1]]),d.transform(...r.baseTransform),this.matrix&&d.transform(...this.matrix),XU(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 XU(e,this._bbox),i=this._createGradient(e);return i}}function G3(t,e,r,n,s,i,a,l){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=l,l=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,y=(c[n+1]+e.offsetY)*e.scaleY,x=(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],j=u[i+2],N=u[a],C=u[a+1],A=u[a+2],E=u[l],O=u[l+1],$=u[l+2],T=Math.round(m),M=Math.round(v);let k,D,K,H,ee,V,B,z;for(let F=T;F<=M;F++){if(F<y){const q=F<m?0:(m-F)/(m-y);k=p-(p-g)*q,D=b-(b-N)*q,K=w-(w-C)*q,H=j-(j-A)*q}else{let q;F>v?q=1:y===v?q=0:q=(y-F)/(y-v),k=g-(g-x)*q,D=N-(N-E)*q,K=C-(C-O)*q,H=A-(A-$)*q}let G;F<m?G=0:F>v?G=1:G=(m-F)/(m-v),ee=p-(p-x)*G,V=b-(b-E)*G,B=w-(w-O)*G,z=j-(j-$)*G;const Q=Math.round(Math.min(k,ee)),ie=Math.round(Math.max(k,ee));let se=h*F+Q*4;for(let q=Q;q<=ie;q++)G=(k-q)/(k-ee),G<0?G=0:G>1&&(G=1),d[se++]=D-(D-V)*G|0,d[se++]=K-(K-B)*G|0,d[se++]=H-(H-z)*G|0,d[se++]=255}}function gEt(t,e,r){const n=e.coords,s=e.colors;let i,a;switch(e.type){case"lattice":const l=e.verticesPerRow,c=Math.floor(n.length/l)-1,u=l-1;for(i=0;i<c;i++){let d=i*l;for(let h=0;h<u;h++,d++)G3(t,r,n[d],n[d+1],n[d+l],s[d],s[d+1],s[d+l]),G3(t,r,n[d+l+1],n[d+1],n[d+l],s[d+l+1],s[d+1],s[d+l])}break;case"triangles":for(i=0,a=n.length;i<a;i+=3)G3(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 xEt extends yG{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 l=Math.floor(this._bounds[0]),c=Math.floor(this._bounds[1]),u=Math.ceil(this._bounds[2])-l,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:-l,offsetY:-c,scaleX:1/p,scaleY:1/m},y=h+2*2,x=f+2*2,v=n.getCanvas("mesh",y,x),b=v.context,w=b.createImageData(h,f);if(r){const N=w.data;for(let C=0,A=N.length;C<A;C+=4)N[C]=r[0],N[C+1]=r[1],N[C+2]=r[2],N[C+3]=255}for(const N of this._figures)gEt(w,N,g);return b.putImageData(w,2,2),{canvas:v.canvas,offsetX:l-2*p,offsetY:c-2*m,scaleX:p,scaleY:m}}isModifyingCurrentTransform(){return!0}getPattern(e,r,n,s){XU(e,this._bbox);const i=new Float32Array(2);if(s===Xi.SHADING)Rt.singularValueDecompose2dScale(Jn(e),i);else if(this.matrix){Rt.singularValueDecompose2dScale(this.matrix,i);const[l,c]=i;Rt.singularValueDecompose2dScale(r.baseTransform,i),i[0]*=l,i[1]*=c}else Rt.singularValueDecompose2dScale(r.baseTransform,i);const a=this._createMeshCanvas(i,s===Xi.SHADING?null:this._background,r.cachedCanvases);return s!==Xi.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 yEt extends yG{getPattern(){return"hotpink"}}function vEt(t){switch(t[0]){case"RadialAxial":return new mEt(t);case"Mesh":return new xEt(t);case"Dummy":return new yEt}throw new Error(`Unknown IR type: ${t[0]}`)}const yse={COLORED:1,UNCOLORED:2},hM=class hM{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:l}=this;let{xstep:c,ystep:u}=this;c=Math.abs(c),u=Math.abs(u),zL("TilingType: "+i);const d=r[0],h=r[1],f=r[2],p=r[3],m=f-d,g=p-h,y=new Float32Array(2);Rt.singularValueDecompose2dScale(this.matrix,y);const[x,v]=y;Rt.singularValueDecompose2dScale(this.baseTransform,y);const b=x*y[0],w=v*y[1];let j=m,N=g,C=!1,A=!1;const E=Math.ceil(c*b),O=Math.ceil(u*w),$=Math.ceil(m*b),T=Math.ceil(g*w);E>=$?j=c:C=!0,O>=T?N=u:A=!0;const M=this.getSizeAndScale(j,this.ctx.canvas.width,b),k=this.getSizeAndScale(N,this.ctx.canvas.height,w),D=e.cachedCanvases.getCanvas("pattern",M.size,k.size),K=D.context,H=l.createCanvasGraphics(K);if(H.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(H,s,a),K.translate(-M.scale*d,-k.scale*h),H.transform(M.scale,0,0,k.scale,0,0),K.save(),this.clipBbox(H,d,h,f,p),H.baseTransform=Jn(H.ctx),H.executeOperatorList(n),H.endDrawing(),K.restore(),C||A){const ee=D.canvas;C&&(j=c),A&&(N=u);const V=this.getSizeAndScale(j,this.ctx.canvas.width,b),B=this.getSizeAndScale(N,this.ctx.canvas.height,w),z=V.size,F=B.size,G=e.cachedCanvases.getCanvas("pattern-workaround",z,F),Q=G.context,ie=C?Math.floor(m/c):0,se=A?Math.floor(g/u):0;for(let q=0;q<=ie;q++)for(let L=0;L<=se;L++)Q.drawImage(ee,z*q,F*L,z,F,0,0,z,F);return{canvas:G.canvas,scaleX:V.scale,scaleY:B.scale,offsetX:d,offsetY:h}}return{canvas:D.canvas,scaleX:M.scale,scaleY:k.scale,offsetX:d,offsetY:h}}getSizeAndScale(e,r,n){const s=Math.max(hM.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,l=i-n;e.ctx.rect(r,n,a,l),Rt.axialAlignedBoundingBox([r,n,s,i],Jn(e.ctx),e.current.minMax),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,r,n){const s=e.ctx,i=e.current;switch(r){case yse.COLORED:const{fillStyle:a,strokeStyle:l}=this.ctx;s.fillStyle=i.fillColor=a,s.strokeStyle=i.strokeColor=l;break;case yse.UNCOLORED:s.fillStyle=s.strokeStyle=n,i.fillColor=i.strokeColor=n;break;default:throw new $Ct(`Unsupported paint type: ${r}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,r,n,s){let i=n;s!==Xi.SHADING&&(i=Rt.transform(i,r.baseTransform),this.matrix&&(i=Rt.transform(i,this.matrix)));const a=this.createPatternCanvas(r);let l=new DOMMatrix(i);l=l.translate(a.offsetX,a.offsetY),l=l.scale(1/a.scaleX,1/a.scaleY);const c=e.createPattern(a.canvas,"repeat");return c.setTransform(l),c}};Ge(hM,"MAX_PATTERN_SIZE",3e3);let QU=hM;function bEt({src:t,srcPos:e=0,dest:r,width:n,height:s,nonBlackColor:i=4294967295,inverseDecode:a=!1}){const l=oa.isLittleEndian?4278190080:255,[c,u]=a?[i,l]:[l,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 y=e+d;e<y;e++){const x=e<f?t[e]:255;r[p++]=x&128?u:c,r[p++]=x&64?u:c,r[p++]=x&32?u:c,r[p++]=x&16?u:c,r[p++]=x&8?u:c,r[p++]=x&4?u:c,r[p++]=x&2?u:c,r[p++]=x&1?u:c}if(h===0)continue;const g=e<f?t[e++]:255;for(let y=0;y<h;y++)r[p++]=g&1<<7-y?u:c}return{srcPos:e,destPos:p}}const vse=16,bse=100,wEt=15,wse=10,fo=16,K3=new DOMMatrix,Jo=new Float32Array(2),Zb=new Float32Array([1/0,1/0,-1/0,-1/0]);function jEt(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,l){e.transform(r,n,s,i,a,l),this.__originalTransform(r,n,s,i,a,l)},t.setTransform=function(r,n,s,i,a,l){e.setTransform(r,n,s,i,a,l),this.__originalSetTransform(r,n,s,i,a,l)},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,l){e.bezierCurveTo(r,n,s,i,a,l),this.__originalBezierCurveTo(r,n,s,i,a,l)},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 SEt{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 DT(t,e,r,n,s,i,a,l,c,u){const[d,h,f,p,m,g]=Jn(t);if(h===0&&f===0){const v=a*d+m,b=Math.round(v),w=l*p+g,j=Math.round(w),N=(a+c)*d+m,C=Math.abs(Math.round(N)-b)||1,A=(l+u)*p+g,E=Math.abs(Math.round(A)-j)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),b,j),t.drawImage(e,r,n,s,i,0,0,C,E),t.setTransform(d,h,f,p,m,g),[C,E]}if(d===0&&p===0){const v=l*f+m,b=Math.round(v),w=a*h+g,j=Math.round(w),N=(l+u)*f+m,C=Math.abs(Math.round(N)-b)||1,A=(a+c)*h+g,E=Math.abs(Math.round(A)-j)||1;return t.setTransform(0,Math.sign(h),Math.sign(f),0,b,j),t.drawImage(e,r,n,s,i,0,0,E,C),t.setTransform(d,h,f,p,m,g),[E,C]}t.drawImage(e,r,n,s,i,a,l,c,u);const y=Math.hypot(d,h),x=Math.hypot(f,p);return[y*c,x*u]}class jse{constructor(e,r){Ge(this,"alphaIsShape",!1);Ge(this,"fontSize",0);Ge(this,"fontSizeScale",1);Ge(this,"textMatrix",null);Ge(this,"textMatrixScale",1);Ge(this,"fontMatrix",kU);Ge(this,"leading",0);Ge(this,"x",0);Ge(this,"y",0);Ge(this,"lineX",0);Ge(this,"lineY",0);Ge(this,"charSpacing",0);Ge(this,"wordSpacing",0);Ge(this,"textHScale",1);Ge(this,"textRenderingMode",pa.FILL);Ge(this,"textRise",0);Ge(this,"fillColor","#000000");Ge(this,"strokeColor","#000000");Ge(this,"patternFill",!1);Ge(this,"patternStroke",!1);Ge(this,"fillAlpha",1);Ge(this,"strokeAlpha",1);Ge(this,"lineWidth",1);Ge(this,"activeSMask",null);Ge(this,"transferMaps","none");this.clipBox=new Float32Array([0,0,e,r]),this.minMax=Zb.slice()}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e.minMax=this.minMax.slice(),e}getPathBoundingBox(e=Xi.FILL,r=null){const n=this.minMax.slice();if(e===Xi.STROKE){r||hn("Stroke bounding box must include transform."),Rt.singularValueDecompose2dScale(r,Jo);const s=Jo[0]*this.lineWidth/2,i=Jo[1]*this.lineWidth/2;n[0]-=s,n[1]-=i,n[2]+=s,n[3]+=i}return n}updateClipFromPath(){const e=Rt.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(Zb,0)}getClippedPathBoundingBox(e=Xi.FILL,r=null){return Rt.intersect(this.clipBox,this.getPathBoundingBox(e,r))}}function Sse(t,e){if(e instanceof ImageData){t.putImageData(e,0,0);return}const r=e.height,n=e.width,s=r%fo,i=(r-s)/fo,a=s===0?i:i+1,l=t.createImageData(n,fo);let c=0,u;const d=e.data,h=l.data;let f,p,m,g;if(e.kind===aP.GRAYSCALE_1BPP){const y=d.byteLength,x=new Uint32Array(h.buffer,0,h.byteLength>>2),v=x.length,b=n+7>>3,w=4294967295,j=oa.isLittleEndian?4278190080:255;for(f=0;f<a;f++){for(m=f<i?fo:s,u=0,p=0;p<m;p++){const N=y-c;let C=0;const A=N>b?n:N*8-7,E=A&-8;let O=0,$=0;for(;C<E;C+=8)$=d[c++],x[u++]=$&128?w:j,x[u++]=$&64?w:j,x[u++]=$&32?w:j,x[u++]=$&16?w:j,x[u++]=$&8?w:j,x[u++]=$&4?w:j,x[u++]=$&2?w:j,x[u++]=$&1?w:j;for(;C<A;C++)O===0&&($=d[c++],O=128),x[u++]=$&O?w:j,O>>=1}for(;u<v;)x[u++]=0;t.putImageData(l,0,f*fo)}}else if(e.kind===aP.RGBA_32BPP){for(p=0,g=n*fo*4,f=0;f<i;f++)h.set(d.subarray(c,c+g)),c+=g,t.putImageData(l,0,p),p+=fo;f<a&&(g=n*s*4,h.set(d.subarray(c,c+g)),t.putImageData(l,0,p))}else if(e.kind===aP.RGB_24BPP)for(m=fo,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(l,0,f*fo)}else throw new Error(`bad image kind: ${e.kind}`)}function _se(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}const r=e.height,n=e.width,s=r%fo,i=(r-s)/fo,a=s===0?i:i+1,l=t.createImageData(n,fo);let c=0;const u=e.data,d=l.data;for(let h=0;h<a;h++){const f=h<i?fo:s;({srcPos:c}=bEt({src:u,srcPos:c,dest:d,width:n,height:f,nonBlackColor:0})),t.putImageData(l,0,h*fo)}}function pS(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 LT(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 Nse(t,e){if(e)return!0;Rt.singularValueDecompose2dScale(t,Jo);const r=Math.fround(md.pixelRatio*Km.PDF_TO_CSS_UNITS);return Jo[0]<=r&&Jo[1]<=r}const _Et=["butt","round","square"],NEt=["miter","round","bevel"],kEt={},kse={};var iu,ZU,JU,eH;const HK=class HK{constructor(e,r,n,s,i,{optionalContentConfig:a,markedContentStack:l=null},c,u){le(this,iu);this.ctx=e,this.current=new jse(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=l||[],this.optionalContentConfig=a,this.cachedCanvases=new SEt(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,l=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,i,a),this.ctx.fillStyle=l,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(...Jn(this.compositeCtx))}this.ctx.save(),LT(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=Jn(this.ctx)}executeOperatorList(e,r,n,s){const i=e.argsArray,a=e.fnArray;let l=r||0;const c=i.length;if(c===l)return l;const u=c-l>wse&&typeof n=="function",d=u?Date.now()+wEt:0;let h=0;const f=this.commonObjs,p=this.objs;let m;for(;;){if(s!==void 0&&l===s.nextBreakPoint)return s.breakIt(l,n),l;if(m=a[l],m!==QR.dependency)this[m].apply(this,i[l]);else for(const g of i[l]){const y=g.startsWith("g_")?f:p;if(!y.has(g))return y.get(g,n),l}if(l++,l===c)return l;if(u&&++h>wse){if(Date.now()>d)return n(),l;h=0}}}endDrawing(){de(this,iu,ZU).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(),de(this,iu,JU).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),l=n,c=s,u="prescale1",d,h;for(;i>2&&l>1||a>2&&c>1;){let f=l,p=c;i>2&&l>1&&(f=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),i/=l/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,l,c,0,0,f,p),e=d.canvas,l=f,c=p,u=u==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:c}}_createMaskCanvas(e){const r=this.ctx,{width:n,height:s}=e,i=this.current.fillColor,a=this.current.patternFill,l=Jn(r);let c,u,d,h;if((e.bitmap||e.data)&&e.count>1){const E=e.bitmap||e.data.buffer;u=JSON.stringify(a?l:[l.slice(0,4),i]),c=this._cachedBitmapsMap.get(E),c||(c=new Map,this._cachedBitmapsMap.set(E,c));const O=c.get(u);if(O&&!a){const $=Math.round(Math.min(l[0],l[2])+l[4]),T=Math.round(Math.min(l[1],l[3])+l[5]);return{canvas:O,offsetX:$,offsetY:T}}d=O}d||(h=this.cachedCanvases.getCanvas("maskCanvas",n,s),_se(h.context,e));let f=Rt.transform(l,[1/n,0,0,-1/s,0,0]);f=Rt.transform(f,[1,0,0,1,0,-s]);const p=Zb.slice();Rt.axialAlignedBoundingBox([0,0,n,s],f,p);const[m,g,y,x]=p,v=Math.round(y-m)||1,b=Math.round(x-g)||1,w=this.cachedCanvases.getCanvas("fillCanvas",v,b),j=w.context,N=m,C=g;j.translate(-N,-C),j.transform(...f),d||(d=this._scaleImage(h.canvas,gu(j)),d=d.img,c&&a&&c.set(u,d)),j.imageSmoothingEnabled=Nse(Jn(j),e.interpolate),DT(j,d,0,0,d.width,d.height,0,0,n,s),j.globalCompositeOperation="source-in";const A=Rt.transform(gu(j),[1,0,0,1,-N,-C]);return j.fillStyle=a?i.getPattern(r,this,A,Xi.FILL):i,j.fillRect(0,0,n,s),c&&!a&&(this.cachedCanvases.delete("fillCanvas"),c.set(u,w.canvas)),{canvas:w.canvas,offsetX:Math.round(N),offsetY:Math.round(C)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=_Et[e]}setLineJoin(e){this.ctx.lineJoin=NEt[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()),pS(this.suspendedCtx,i),jEt(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(),pS(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],l=s[2]-i,c=s[3]-a;l===0||c===0||(this.genericComposeSMask(r.context,n,l,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,l,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 y=this.cachedCanvases.getCanvas("maskExtension",n,s),x=y.context;x.drawImage(f,-p,-m),x.globalCompositeOperation="destination-atop",x.fillStyle=a,x.fillRect(0,0,n,s),x.globalCompositeOperation="source-over",f=y.canvas,p=m=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const y=new Path2D;y.rect(p,m,n,s),e.clip(y),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"&&l?r.filter=this.filterFactory.addAlphaFilter(l):i==="Luminosity"&&(r.filter=this.filterFactory.addLuminosityFilter(l));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&&pS(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&&pS(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,l=s.length;a<l;)switch(s[a++]){case IT.moveTo:i.moveTo(s[a++],s[a++]);break;case IT.lineTo:i.lineTo(s[a++],s[a++]);break;case IT.curveTo:i.bezierCurveTo(s[a++],s[a++],s[a++],s[a++],s[a++],s[a++]);break;case IT.closePath:i.closePath();break;default:Zt(`Unrecognized drawing path operator: ${s[a-1]}`);break}s=i}Rt.axialAlignedBoundingBox(n,Jn(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,gu(n),Xi.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(Xi.STROKE,Jn(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,gu(n),Xi.FILL),c){const u=new Path2D;u.addPath(e,n.getTransform().invertSelf().multiplySelf(c)),e=u}a=!0}const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),a&&n.restore(),r&&this.consumePath(e,l)}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=kEt}eoClip(){this.pendingClip=kse}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:l,fontSize:c,path:u}of e)u&&n.addPath(u,new DOMMatrix(i).preMultiplySelf(s).translate(a,l).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||kU,(s.fontMatrix[0]===0||s.fontMatrix[3]===0)&&Zt("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 l="normal";n.black?l="900":n.bold&&(l="bold");const c=n.italic?"italic":"normal";let u=r;r<vse?u=vse:r>bse&&(u=bse),this.current.fontSizeScale=r/u,this.ctx.font=`${c} ${l} ${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,l=this.current,c=l.font,u=l.textRenderingMode,d=l.fontSize/l.fontSizeScale,h=u&pa.FILL_STROKE_MASK,f=!!(u&pa.ADD_TO_PATH_FLAG),p=l.patternFill&&!c.missingFile,m=l.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 y;if((h===pa.FILL||h===pa.FILL_STROKE)&&(s?(y=a.getTransform(),a.setTransform(...s),a.fill(de(this,iu,eH).call(this,g,y,s))):a.fill(g)),h===pa.STROKE||h===pa.FILL_STROKE)if(i){y||(y=a.getTransform()),a.setTransform(...i);const{a:x,b:v,c:b,d:w}=y,j=Rt.inverseTransform(i),N=Rt.transform([x,v,b,w,0,0],j);Rt.singularValueDecompose2dScale(N,Jo),a.lineWidth*=Math.max(Jo[0],Jo[1])/d,a.stroke(de(this,iu,eH).call(this,g,y,i))}else a.lineWidth/=d,a.stroke(g);a.restore()}else(h===pa.FILL||h===pa.FILL_STROKE)&&a.fillText(e,r,n),(h===pa.STROKE||h===pa.FILL_STROKE)&&a.strokeText(e,r,n);f&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Jn(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 gr(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,l=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],y=r.textRenderingMode===pa.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 x,v;if(r.patternFill){i.save();const C=r.fillColor.getPattern(i,this,gu(i),Xi.FILL);x=Jn(i),i.restore(),i.fillStyle=C}if(r.patternStroke){i.save();const C=r.strokeColor.getPattern(i,this,gu(i),Xi.STROKE);v=Jn(i),i.restore(),i.strokeStyle=C}let b=r.lineWidth;const w=r.textMatrixScale;if(w===0||b===0){const C=r.textRenderingMode&pa.FILL_STROKE_MASK;(C===pa.STROKE||C===pa.FILL_STROKE)&&(b=this.getSinglePixelWidth())}else b/=w;if(a!==1&&(i.scale(a,a),b/=a),i.lineWidth=b,n.isInvalidPDFjsFont){const C=[];let A=0;for(const E of e)C.push(E.unicode),A+=E.width;i.fillText(C.join(""),0,0),r.x+=A*g*d,i.restore(),this.compose();return}let j=0,N;for(N=0;N<h;++N){const C=e[N];if(typeof C=="number"){j+=p*C*s/1e3;continue}let A=!1;const E=(C.isSpace?c:0)+l,O=C.fontChar,$=C.accent;let T,M,k=C.width;if(f){const K=C.vmetric||m,H=-(C.vmetric?K[1]:k*.5)*g,ee=K[2]*g;k=K?-K[0]:k,T=H/a,M=(j+ee)/a}else T=j/a,M=0;if(n.remeasure&&k>0){const K=i.measureText(O).width*1e3/s*a;if(k<K&&this.isFontSubpixelAAEnabled){const H=k/K;A=!0,i.save(),i.scale(H,1),T/=H}else k!==K&&(T+=(k-K)/2e3*s/a)}if(this.contentVisible&&(C.isInFont||n.missingFile)){if(y&&!$)i.fillText(O,T,M);else if(this.paintChar(O,T,M,x,v),$){const K=T+s*$.offset.x/a,H=M-s*$.offset.y/a;this.paintChar($.fontChar,K,H,x,v)}}const D=f?k*g-E*u:k*g+E*u;j+=D,A&&i.restore()}f?r.y-=j:r.x+=j*d,i.restore(),this.compose()}showType3Text(e){const r=this.ctx,n=this.current,s=n.font,i=n.fontSize,a=n.fontDirection,l=s.vertical?1:-1,c=n.charSpacing,u=n.wordSpacing,d=n.textHScale*a,h=n.fontMatrix||kU,f=e.length,p=n.textRenderingMode===pa.INVISIBLE;let m,g,y,x;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"){x=l*g*i/1e3,this.ctx.translate(x,0),n.x+=x*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()):Zt(`Type3 character "${g.operatorListId}" is not available.`);const w=[g.width,0];Rt.applyTransform(w,h),y=w[0]*i+v,r.translate(y,0),n.x+=y*d}r.restore()}}setCharWidth(e,r){}setCharWidthAndBounds(e,r,n,s,i,a){const l=new Path2D;l.rect(n,s,i-n,a-s),this.ctx.clip(l),this.endPath()}getColorN_Pattern(e){let r;if(e[0]==="TilingPattern"){const n=this.baseTransform||Jn(this.ctx),s={createCanvasGraphics:i=>new HK(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};r=new QU(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=vEt(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,gu(r),Xi.SHADING);const s=gu(r);if(s){const{width:i,height:a}=r.canvas,l=Zb.slice();Rt.axialAlignedBoundingBox([0,0,i,a],s,l);const[c,u,d,h]=l;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(){hn("Should not call beginInlineImage")}beginImageData(){hn("Should not call beginImageData")}paintFormXObjectBegin(e,r){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=Jn(this.ctx),r)){Rt.axialAlignedBoundingBox(r,this.baseTransform,this.current.minMax);const[n,s,i,a]=r,l=new Path2D;l.rect(n,s,i-n,a-s),this.ctx.clip(l),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||zL("TODO: Support non-isolated groups."),e.knockout&&Zt("Knockout groups not supported.");const n=Jn(r);if(e.matrix&&r.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let s=Zb.slice();Rt.axialAlignedBoundingBox(e.bbox,Jn(r),s);const i=[0,0,r.canvas.width,r.canvas.height];s=Rt.intersect(s,i)||[0,0,0,0];const a=Math.floor(s[0]),l=Math.floor(s[1]),c=Math.max(Math.ceil(s[2])-a,1),u=Math.max(Math.ceil(s[3])-l,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,-l),f.transform(...n);let p=new Path2D;const[m,g,y,x]=e.bbox;if(p.rect(m,g,y-m,x-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:l,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,l),r.save()),pS(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=Jn(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...s);const i=Zb.slice();Rt.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(de(this,iu,ZU).call(this),LT(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),r){const a=r[2]-r[0],l=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]=l,Rt.singularValueDecompose2dScale(Jn(this.ctx),Jo);const{viewportScale:c}=this,u=Math.ceil(a*this.outputScaleX*c),d=Math.ceil(l*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(Jo[0],0,0,-Jo[1],0,l*Jo[1]),LT(this.ctx)}else{LT(this.ctx),this.endPath();const c=new Path2D;c.rect(r[0],r[1],a,l),this.ctx.clip(c)}}this.current=new jse(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),de(this,iu,JU).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 l=this.ctx;l.save();const c=Jn(l);l.transform(r,n,s,i,0,0);const u=this._createMaskCanvas(e);l.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=Rt.transform(c,[r,n,s,i,a[d],a[d+1]]);l.drawImage(u.canvas,f[4],f[5])}l.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:l,height:c,transform:u}=i,d=this.cachedCanvases.getCanvas("maskCanvas",l,c),h=d.context;h.save();const f=this.getObject(a,i);_se(h,f),h.globalCompositeOperation="source-in",h.fillStyle=s?n.getPattern(h,this,gu(r),Xi.FILL):n,h.fillRect(0,0,l,c),h.restore(),r.save(),r.transform(...u),r.scale(1,-1),DT(r,d.canvas,0,0,l,c,0,-1,1,1),r.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;const r=this.getObject(e);if(!r){Zt("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){Zt("Dependent image isn't ready yet");return}const a=i.width,l=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:l});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;Sse(u,e),a=this.applyTransferMapsToCanvas(u)}const l=this._scaleImage(a,gu(s));s.imageSmoothingEnabled=Nse(Jn(s),e.interpolate),DT(s,l.img,0,0,l.paintWidth,l.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;Sse(c,e),s=this.applyTransferMapsToCanvas(c)}for(const i of r)n.save(),n.transform(...i.transform),n.scale(1,-1),DT(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===kse?s.clip(e,"evenodd"):s.clip(e)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=Jn(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,l;if(n===0&&s===0){const c=Math.abs(r),u=Math.abs(i);if(c===u)if(e===0)a=l=1/c;else{const d=c*e;a=l=d<1?1/d:1}else if(e===0)a=1/c,l=1/u;else{const d=c*e,h=u*e;a=d<1?1/d:1,l=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,l=u/c;else{const h=e*c;a=d>h?d/h:1,l=u>h?u/h:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=l}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 l=n.getLineDash();r&&n.save(),n.scale(i,a),K3.a=1/i,K3.d=1/a;const c=new Path2D;if(c.addPath(e,K3),l.length>0){const u=Math.max(i,a);n.setLineDash(l.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}};iu=new WeakSet,ZU=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)},JU=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}}},eH=function(e,r,n){const s=new Path2D;return s.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(r)),s};let _0=HK;for(const t in QR)_0.prototype[t]!==void 0&&(_0.prototype[QR[t]]=_0.prototype[t]);var wC,jC;class Vl{static get workerPort(){return _(this,wC)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");te(this,wC,e)}static get workerSrc(){return _(this,jC)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");te(this,jC,e)}}wC=new WeakMap,jC=new WeakMap,le(Vl,wC,null),le(Vl,jC,"");var lw,SC;class CEt{constructor({parsedData:e,rawData:r}){le(this,lw);le(this,SC);te(this,lw,e),te(this,SC,r)}getRaw(){return _(this,SC)}get(e){return _(this,lw).get(e)??null}[Symbol.iterator](){return _(this,lw).entries()}}lw=new WeakMap,SC=new WeakMap;const Sb=Symbol("INTERNAL");var _C,NC,kC,cw;class EEt{constructor(e,{name:r,intent:n,usage:s,rbGroups:i}){le(this,_C,!1);le(this,NC,!1);le(this,kC,!1);le(this,cw,!0);te(this,_C,!!(e&Xo.DISPLAY)),te(this,NC,!!(e&Xo.PRINT)),this.name=r,this.intent=n,this.usage=s,this.rbGroups=i}get visible(){if(_(this,kC))return _(this,cw);if(!_(this,cw))return!1;const{print:e,view:r}=this.usage;return _(this,_C)?(r==null?void 0:r.viewState)!=="OFF":_(this,NC)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,r,n=!1){e!==Sb&&hn("Internal method `_setVisible` called."),te(this,kC,n),te(this,cw,r)}}_C=new WeakMap,NC=new WeakMap,kC=new WeakMap,cw=new WeakMap;var Hp,ln,uw,dw,CC,tH;class AEt{constructor(e,r=Xo.DISPLAY){le(this,CC);le(this,Hp,null);le(this,ln,new Map);le(this,uw,null);le(this,dw,null);if(this.renderingIntent=r,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,te(this,dw,e.order);for(const n of e.groups)_(this,ln).set(n.id,new EEt(r,n));if(e.baseState==="OFF")for(const n of _(this,ln).values())n._setVisible(Sb,!1);for(const n of e.on)_(this,ln).get(n)._setVisible(Sb,!0);for(const n of e.off)_(this,ln).get(n)._setVisible(Sb,!1);te(this,uw,this.getHash())}}isVisible(e){if(_(this,ln).size===0)return!0;if(!e)return zL("Optional content group not defined."),!0;if(e.type==="OCG")return _(this,ln).has(e.id)?_(this,ln).get(e.id).visible:(Zt(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return de(this,CC,tH).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const r of e.ids){if(!_(this,ln).has(r))return Zt(`Optional content group not found: ${r}`),!0;if(_(this,ln).get(r).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const r of e.ids){if(!_(this,ln).has(r))return Zt(`Optional content group not found: ${r}`),!0;if(!_(this,ln).get(r).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const r of e.ids){if(!_(this,ln).has(r))return Zt(`Optional content group not found: ${r}`),!0;if(!_(this,ln).get(r).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const r of e.ids){if(!_(this,ln).has(r))return Zt(`Optional content group not found: ${r}`),!0;if(_(this,ln).get(r).visible)return!1}return!0}return Zt(`Unknown optional content policy ${e.policy}.`),!0}return Zt(`Unknown group type ${e.type}.`),!0}setVisibility(e,r=!0,n=!0){var i;const s=_(this,ln).get(e);if(!s){Zt(`Optional content group not found: ${e}`);return}if(n&&r&&s.rbGroups.length)for(const a of s.rbGroups)for(const l of a)l!==e&&((i=_(this,ln).get(l))==null||i._setVisible(Sb,!1,!0));s._setVisible(Sb,!!r,!0),te(this,Hp,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,ln).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,Hp,null)}get hasInitialVisibility(){return _(this,uw)===null||this.getHash()===_(this,uw)}getOrder(){return _(this,ln).size?_(this,dw)?_(this,dw).slice():[..._(this,ln).keys()]:null}getGroup(e){return _(this,ln).get(e)||null}getHash(){if(_(this,Hp)!==null)return _(this,Hp);const e=new n_e;for(const[r,n]of _(this,ln))e.update(`${r}:${n.visible}`);return te(this,Hp,e.hexdigest())}[Symbol.iterator](){return _(this,ln).entries()}}Hp=new WeakMap,ln=new WeakMap,uw=new WeakMap,dw=new WeakMap,CC=new WeakSet,tH=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=de(this,CC,tH).call(this,i);else if(_(this,ln).has(i))a=_(this,ln).get(i).visible;else return Zt(`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 TEt{constructor(e,{disableRange:r=!1,disableStream:n=!1}){Fs(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:i,progressiveDone:a,contentDispositionFilename:l}=e;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=l,(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)});Fs(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(){Fs(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new PEt(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,r){if(r<=this._progressiveDataLength)return null;const n=new IEt(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 PEt{constructor(e,r,n=!1,s=null){this._stream=e,this._done=n||!1,this._filename=mG(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 IEt{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 REt(t){let e=!0,r=n("filename\\*","i").exec(t);if(r){r=r[1];let d=l(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=l(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=lA(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,y,x]=f;if(g=parseInt(g,10),g in h){if(g===0)break;continue}h[g]=[y,x]}const m=[];for(let g=0;g<h.length&&g in h;++g){let[y,x]=h[g];x=l(x),y&&(x=unescape(x),g===0&&(x=c(x))),m.push(x)}return m.join("")}function l(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,y){return String.fromCharCode(parseInt(y,16))}),s(f,m);try{m=atob(m)}catch{}return s(f,m)})}return""}function m_e(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 WL(t){var e;return((e=URL.parse(t))==null?void 0:e.origin)??null}function g_e({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 x_e(t){const e=t.get("Content-Disposition");if(e){let r=REt(e);if(r.includes("%"))try{r=decodeURIComponent(r)}catch{}if(mG(r))return r}return null}function hA(t,e){return new ZR(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,t===404||t===0&&e.startsWith("file:"))}function y_e(t){return t===200||t===206}function v_e(t,e,r){return{method:"GET",headers:t,signal:r.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function b_e(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(Zt(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class OEt{constructor(e){Ge(this,"_responseOrigin",null);this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=m_e(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 Fs(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new MEt(this),this._fullRequestReader}getRangeReader(e,r){if(r<=this._progressiveDataLength)return null;const n=new DEt(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 MEt{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,v_e(n,this._withCredentials,this._abortController)).then(i=>{if(e._responseOrigin=WL(i.url),!y_e(i.status))throw hA(i.status,s);this._reader=i.body.getReader(),this._headersCapability.resolve();const a=i.headers,{allowRangeRequests:l,suggestedLength:c}=g_e({responseHeaders:a,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=l,this._contentLength=c||this._contentLength,this._filename=x_e(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Gm("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:b_e(e),done:!1})}cancel(e){var r;(r=this._reader)==null||r.cancel(e),this._abortController.abort()}}class DEt{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,v_e(i,this._withCredentials,this._abortController)).then(l=>{const c=WL(l.url);if(c!==e._responseOrigin)throw new Error(`Expected range response-origin "${c}" to match "${e._responseOrigin}".`);if(!y_e(l.status))throw hA(l.status,a);this._readCapability.resolve(),this._reader=l.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:b_e(e),done:!1})}cancel(e){var r;(r=this._reader)==null||r.cancel(e),this._abortController.abort()}}const Y3=200,X3=206;function LEt(t){const e=t.response;return typeof e!="string"?e:lA(e).buffer}class $Et{constructor({url:e,httpHeaders:r,withCredentials:n}){Ge(this,"_responseOrigin",null);this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=m_e(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=X3):s.expectedStatus=Y3,r.responseType="arraybuffer",Fs(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||Y3;if(!(i===Y3&&n.expectedStatus===X3)&&i!==n.expectedStatus){n.onError(s.status);return}const l=LEt(s);if(i===X3){const c=s.getResponseHeader("Content-Range"),u=/bytes (\d+)-(\d+)\/(\d+)/.exec(c);u?n.onDone({begin:parseInt(u[1],10),chunk:l}):(Zt('Missing or invalid "Content-Range" header.'),n.onError(0))}else l?n.onDone({begin:0,chunk:l}):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 FEt{constructor(e){this._source=e,this._manager=new $Et(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 Fs(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new BEt(this._manager,this._source),this._fullRequestReader}getRangeReader(e,r){const n=new zEt(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 BEt{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=WL(r.responseURL);const n=r.getAllResponseHeaders(),s=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(l=>{const[c,...u]=l.split(": ");return[c,u.join(": ")]}):[]),{allowRangeRequests:i,suggestedLength:a}=g_e({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=x_e(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=hA(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 zEt{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=WL((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=hA(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 UEt=/^[a-z][a-z0-9\-+.]+:/i;function HEt(t){if(UEt.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}class WEt{constructor(e){this.source=e,this.url=HEt(e.url),Fs(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 Fs(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new VEt(this),this._fullRequestReader}getRangeReader(e,r){if(r<=this._progressiveDataLength)return null;const n=new qEt(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 VEt{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=hA(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 Gm("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class qEt{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 mS=Symbol("INITIAL_DATA");var $o,EC,rH;class w_e{constructor(){le(this,EC);le(this,$o,Object.create(null))}get(e,r=null){if(r){const s=de(this,EC,rH).call(this,e);return s.promise.then(()=>r(s.data)),null}const n=_(this,$o)[e];if(!n||n.data===mS)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){const r=_(this,$o)[e];return!!r&&r.data!==mS}delete(e){const r=_(this,$o)[e];return!r||r.data===mS?!1:(delete _(this,$o)[e],!0)}resolve(e,r=null){const n=de(this,EC,rH).call(this,e);n.data=r,n.resolve()}clear(){var e;for(const r in _(this,$o)){const{data:n}=_(this,$o)[r];(e=n==null?void 0:n.bitmap)==null||e.close()}te(this,$o,Object.create(null))}*[Symbol.iterator](){for(const e in _(this,$o)){const{data:r}=_(this,$o)[e];r!==mS&&(yield[e,r])}}}$o=new WeakMap,EC=new WeakSet,rH=function(e){var r;return(r=_(this,$o))[e]||(r[e]={...Promise.withResolvers(),data:mS})};const GEt=1e5,Cse=30;var Zce,Wp,co,AC,TC,ey,gh,PC,IC,ty,hw,fw,Vp,pw,RC,mw,ry,OC,MC,gw,ny,DC,qp,xw,jf,j_e,S_e,nH,hl,gP,sH,__e,N_e;const Ks=class Ks{constructor({textContentSource:e,container:r,viewport:n}){le(this,jf);le(this,Wp,Promise.withResolvers());le(this,co,null);le(this,AC,!1);le(this,TC,!!((Zce=globalThis.FontInspector)!=null&&Zce.enabled));le(this,ey,null);le(this,gh,null);le(this,PC,0);le(this,IC,0);le(this,ty,null);le(this,hw,null);le(this,fw,0);le(this,Vp,0);le(this,pw,Object.create(null));le(this,RC,[]);le(this,mw,null);le(this,ry,[]);le(this,OC,new WeakMap);le(this,MC,null);var c;if(e instanceof ReadableStream)te(this,mw,e);else if(typeof e=="object")te(this,mw,new ReadableStream({start(u){u.enqueue(e),u.close()}}));else throw new Error('No "textContentSource" parameter specified.');te(this,co,te(this,hw,r)),te(this,Vp,n.scale*md.pixelRatio),te(this,fw,n.rotation),te(this,gh,{div:null,properties:null,ctx:null});const{pageWidth:s,pageHeight:i,pageX:a,pageY:l}=n.rawDims;te(this,MC,[1,0,0,-1,-a,l+i]),te(this,IC,s),te(this,PC,i),de(c=Ks,hl,__e).call(c),pv(r,n),_(this,Wp).promise.finally(()=>{_(Ks,xw).delete(this),te(this,gh,null),te(this,pw,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:r}=oa.platform;return gr(this,"fontFamilyMap",new Map([["sans-serif",`${e&&r?"Calibri, ":""}sans-serif`],["monospace",`${e&&r?"Lucida Console, ":""}monospace`]]))}render(){const e=()=>{_(this,ty).read().then(({value:r,done:n})=>{if(n){_(this,Wp).resolve();return}_(this,ey)??te(this,ey,r.lang),Object.assign(_(this,pw),r.styles),de(this,jf,j_e).call(this,r.items),e()},_(this,Wp).reject)};return te(this,ty,_(this,mw).getReader()),_(Ks,xw).add(this),e(),_(this,Wp).promise}update({viewport:e,onBefore:r=null}){var i;const n=e.scale*md.pixelRatio,s=e.rotation;if(s!==_(this,fw)&&(r==null||r(),te(this,fw,s),pv(_(this,hw),{rotation:s})),n!==_(this,Vp)){r==null||r(),te(this,Vp,n);const a={div:null,properties:null,ctx:de(i=Ks,hl,gP).call(i,_(this,ey))};for(const l of _(this,ry))a.properties=_(this,OC).get(l),a.div=l,de(this,jf,nH).call(this,a)}}cancel(){var r;const e=new Gm("TextLayer task cancelled.");(r=_(this,ty))==null||r.cancel(e).catch(()=>{}),te(this,ty,null),_(this,Wp).reject(e)}get textDivs(){return _(this,ry)}get textContentItemsStr(){return _(this,RC)}static cleanup(){if(!(_(this,xw).size>0)){_(this,gw).clear();for(const{canvas:e}of _(this,ny).values())e.remove();_(this,ny).clear()}}};Wp=new WeakMap,co=new WeakMap,AC=new WeakMap,TC=new WeakMap,ey=new WeakMap,gh=new WeakMap,PC=new WeakMap,IC=new WeakMap,ty=new WeakMap,hw=new WeakMap,fw=new WeakMap,Vp=new WeakMap,pw=new WeakMap,RC=new WeakMap,mw=new WeakMap,ry=new WeakMap,OC=new WeakMap,MC=new WeakMap,gw=new WeakMap,ny=new WeakMap,DC=new WeakMap,qp=new WeakMap,xw=new WeakMap,jf=new WeakSet,j_e=function(e){var s,i;if(_(this,AC))return;(i=_(this,gh)).ctx??(i.ctx=de(s=Ks,hl,gP).call(s,_(this,ey)));const r=_(this,ry),n=_(this,RC);for(const a of e){if(r.length>GEt){Zt("Ignoring additional textDivs for performance reasons."),te(this,AC,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const l=_(this,co);te(this,co,document.createElement("span")),_(this,co).classList.add("markedContent"),a.id&&_(this,co).setAttribute("id",`${a.id}`),l.append(_(this,co))}else a.type==="endMarkedContent"&&te(this,co,_(this,co).parentNode);continue}n.push(a.str),de(this,jf,S_e).call(this,a)}},S_e=function(e){var g;const r=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};_(this,ry).push(r);const s=Rt.transform(_(this,MC),e.transform);let i=Math.atan2(s[1],s[0]);const a=_(this,pw)[e.fontName];a.vertical&&(i+=Math.PI/2);let l=_(this,TC)&&a.fontSubstitution||a.fontFamily;l=Ks.fontFamilyMap.get(l)||l;const c=Math.hypot(s[2],s[3]),u=c*de(g=Ks,hl,N_e).call(g,l,a,_(this,ey));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,co)===_(this,hw)?(p.left=`${(100*d/_(this,IC)).toFixed(2)}%`,p.top=`${(100*h/_(this,PC)).toFixed(2)}%`):(p.left=`${f}${d.toFixed(2)}px)`,p.top=`${f}${h.toFixed(2)}px)`),p.fontSize=`${f}${(_(Ks,qp)*c).toFixed(2)}px)`,p.fontFamily=l,n.fontSize=c,r.setAttribute("role","presentation"),r.textContent=e.str,r.dir=e.dir,_(this,TC)&&(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 y=Math.abs(e.transform[0]),x=Math.abs(e.transform[3]);y!==x&&Math.max(y,x)/Math.min(y,x)>1.5&&(m=!0)}if(m&&(n.canvasWidth=a.vertical?e.height:e.width),_(this,OC).set(r,n),_(this,gh).div=r,_(this,gh).properties=n,de(this,jf,nH).call(this,_(this,gh)),n.hasText&&_(this,co).append(r),n.hasEOL){const y=document.createElement("br");y.setAttribute("role","presentation"),_(this,co).append(y)}},nH=function(e){var l;const{div:r,properties:n,ctx:s}=e,{style:i}=r;let a="";if(_(Ks,qp)>1&&(a=`scale(${1/_(Ks,qp)})`),n.canvasWidth!==0&&n.hasText){const{fontFamily:c}=i,{canvasWidth:u,fontSize:d}=n;de(l=Ks,hl,sH).call(l,s,d*_(this,Vp),c);const{width:h}=s.measureText(r.textContent);h>0&&(a=`scaleX(${u*_(this,Vp)/h}) ${a}`)}n.angle!==0&&(a=`rotate(${n.angle}deg) ${a}`),a.length>0&&(i.transform=a)},hl=new WeakSet,gP=function(e=null){let r=_(this,ny).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,ny).set(e,r),_(this,DC).set(r,{size:0,family:""})}return r},sH=function(e,r,n){const s=_(this,DC).get(e);r===s.size&&n===s.family||(e.font=`${r}px ${n}`,s.size=r,s.family=n)},__e=function(){if(_(this,qp)!==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,qp,e.getBoundingClientRect().height),e.remove()},N_e=function(e,r,n){const s=_(this,gw).get(e);if(s)return s;const i=de(this,hl,gP).call(this,n);i.canvas.width=i.canvas.height=Cse,de(this,hl,sH).call(this,i,Cse,e);const a=i.measureText(""),l=a.fontBoundingBoxAscent,c=Math.abs(a.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let u=.8;return l?u=l/(l+c):(oa.platform.isFirefox&&Zt("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,gw).set(e,u),u},le(Ks,hl),le(Ks,gw,new Map),le(Ks,ny,new Map),le(Ks,DC,new WeakMap),le(Ks,qp,null),le(Ks,xw,new Set);let L1=Ks;class Sk{static textContent(e){const r=[],n={items:r,styles:Object.create(null)};function s(i){var c;if(!i)return;let a=null;const l=i.name;if(l==="#text")a=i.value;else if(Sk.shouldBuildText(l))(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 KEt=100;function VL(t={}){typeof t=="string"||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new iH,{docId:r}=e,n=t.url?nEt(t.url):null,s=t.data?sEt(t.data):null,i=t.httpHeaders||null,a=t.withCredentials===!0,l=t.password??null,c=t.range instanceof k_e?t.range:null,u=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:2**16;let d=t.worker instanceof _k?t.worker:null;const h=t.verbosity,f=typeof t.docBaseUrl=="string"&&!UL(t.docBaseUrl)?t.docBaseUrl:null,p=OT(t.cMapUrl),m=t.cMapPacked!==!1,g=t.CMapReaderFactory||(Ba?hEt:mse),y=OT(t.iccUrl),x=OT(t.standardFontDataUrl),v=t.StandardFontDataFactory||(Ba?fEt:gse),b=OT(t.wasmUrl),w=t.WasmFactory||(Ba?pEt:xse),j=t.stopAtErrors!==!0,N=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,C=t.isEvalSupported!==!1,A=typeof t.isOffscreenCanvasSupported=="boolean"?t.isOffscreenCanvasSupported:!Ba,E=typeof t.isImageDecoderSupported=="boolean"?t.isImageDecoderSupported:!Ba&&(oa.platform.isFirefox||!globalThis.chrome),O=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,$=typeof t.disableFontFace=="boolean"?t.disableFontFace:Ba,T=t.fontExtraProperties===!0,M=t.enableXfa===!0,k=t.ownerDocument||globalThis.document,D=t.disableRange===!0,K=t.disableStream===!0,H=t.disableAutoFetch===!0,ee=t.pdfBug===!0,V=t.CanvasFactory||(Ba?dEt:lEt),B=t.FilterFactory||(Ba?uEt:cEt),z=t.enableHWA===!0,F=t.useWasm!==!1,G=c?c.length:t.length??NaN,Q=typeof t.useSystemFonts=="boolean"?t.useSystemFonts:!Ba&&!$,ie=typeof t.useWorkerFetch=="boolean"?t.useWorkerFetch:!!(g===mse&&v===gse&&w===xse&&p&&x&&b&&qS(p,document.baseURI)&&qS(x,document.baseURI)&&qS(b,document.baseURI)),se=null;MCt(h);const q={canvasFactory:new V({ownerDocument:k,enableHWA:z}),filterFactory:new B({docId:r,ownerDocument:k}),cMapReaderFactory:ie?null:new g({baseUrl:p,isCompressed:m}),standardFontDataFactory:ie?null:new v({baseUrl:x}),wasmFactory:ie?null:new w({baseUrl:b})};d||(d=_k.create({verbosity:h,port:Vl.workerPort}),e._worker=d);const L={docId:r,apiVersion:"5.4.54",data:s,password:l,disableAutoFetch:H,rangeChunkSize:u,length:G,docBaseUrl:f,enableXfa:M,evaluatorOptions:{maxImageSize:N,disableFontFace:$,ignoreErrors:j,isEvalSupported:C,isOffscreenCanvasSupported:A,isImageDecoderSupported:E,canvasMaxAreaInBytes:O,fontExtraProperties:T,useSystemFonts:Q,useWasm:F,useWorkerFetch:ie,cMapUrl:p,iccUrl:y,standardFontDataUrl:x,wasmUrl:b}},Z={ownerDocument:k,pdfBug:ee,styleElement:se,loadingParams:{disableAutoFetch:H,enableXfa:M}};return d.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const J=d.messageHandler.sendWithPromise("GetDocRequest",L,s?[s.buffer]:null);let W;if(c)W=new TEt(c,{disableRange:D,disableStream:K});else if(!s){if(!n)throw new Error("getDocument - no `url` parameter provided.");const X=qS(n)?OEt:Ba?WEt:FEt;W=new X({url:n,length:G,httpHeaders:i,withCredentials:a,rangeChunkSize:u,disableRange:D,disableStream:K})}return J.then(X=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const he=new QS(r,X,d.port),P=new QEt(he,e,W,Z,q,z);e._transport=P,he.send("Ready",null)})}).catch(e._capability.reject),e}var fM;const pM=class pM{constructor(){Ge(this,"_capability",Promise.withResolvers());Ge(this,"_transport",null);Ge(this,"_worker",null);Ge(this,"docId",`d${xi(pM,fM)._++}`);Ge(this,"destroyed",!1);Ge(this,"onPassword",null);Ge(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()}};fM=new WeakMap,le(pM,fM,0);let iH=pM;var sy,LC,$C,FC,BC;class k_e{constructor(e,r,n=!1,s=null){le(this,sy,Promise.withResolvers());le(this,LC,[]);le(this,$C,[]);le(this,FC,[]);le(this,BC,[]);this.length=e,this.initialData=r,this.progressiveDone=n,this.contentDispositionFilename=s}addRangeListener(e){_(this,BC).push(e)}addProgressListener(e){_(this,FC).push(e)}addProgressiveReadListener(e){_(this,$C).push(e)}addProgressiveDoneListener(e){_(this,LC).push(e)}onDataRange(e,r){for(const n of _(this,BC))n(e,r)}onDataProgress(e,r){_(this,sy).promise.then(()=>{for(const n of _(this,FC))n(e,r)})}onDataProgressiveRead(e){_(this,sy).promise.then(()=>{for(const r of _(this,$C))r(e)})}onDataProgressiveDone(){_(this,sy).promise.then(()=>{for(const e of _(this,LC))e()})}transportReady(){_(this,sy).resolve()}requestDataRange(e,r){hn("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}sy=new WeakMap,LC=new WeakMap,$C=new WeakMap,FC=new WeakMap,BC=new WeakMap;class YEt{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 gr(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 xh,iy,r_;class XEt{constructor(e,r,n,s=!1){le(this,iy);le(this,xh,!1);this._pageIndex=e,this._pageInfo=r,this._transport=n,this._stats=s?new hse:null,this._pdfBug=s,this.commonObjs=n.commonObjs,this.objs=new w_e,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 uA({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 gr(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=fp.ENABLE,transform:a=null,background:l=null,optionalContentConfigPromise:c=null,annotationCanvasMap:u=null,pageColors:d=null,printAnnotationStorage:h=null,isEditing:f=!1}){var j,N;(j=this._stats)==null||j.time("Overall");const p=this._transport.getRenderingIntent(s,i,h,f),{renderingIntent:m,cacheKey:g}=p;te(this,xh,!1),c||(c=this._transport.getOptionalContentConfig(m));let y=this._intentStates.get(g);y||(y=Object.create(null),this._intentStates.set(g,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const x=!!(m&Xo.PRINT);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(N=this._stats)==null||N.time("Page Request"),this._pumpOperatorList(p));const v=C=>{var A;y.renderTasks.delete(b),x&&te(this,xh,!0),de(this,iy,r_).call(this),C?(b.capability.reject(C),this._abortOperatorList({intentState:y,reason:C instanceof Error?C:new Error(C)})):b.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(A=globalThis.Stats)!=null&&A.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},b=new aH({callback:v,params:{canvas:r,canvasContext:e,viewport:n,transform:a,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:u,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!x,pdfBug:this._pdfBug,pageColors:d,enableHWA:this._transport.enableHWA});(y.renderTasks||(y.renderTasks=new Set)).add(b);const w=b.task;return Promise.all([y.displayReadyCapability.promise,c]).then(([C,A])=>{var E;if(this.destroyed){v();return}if((E=this._stats)==null||E.time("Rendering"),!(A.renderingIntent&m))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");b.initializeGraphics({transparency:C,optionalContentConfig:A}),b.operatorListChanged()}).catch(v),w}getOperatorList({intent:e="display",annotationMode:r=fp.ENABLE,printAnnotationStorage:n=null,isEditing:s=!1}={}){var u;function i(){l.operatorList.lastChunk&&(l.opListReadCapability.resolve(l.operatorList),l.renderTasks.delete(c))}const a=this._transport.getRenderingIntent(e,r,n,s,!0);let l=this._intentStates.get(a.cacheKey);l||(l=Object.create(null),this._intentStates.set(a.cacheKey,l));let c;return l.opListReadCapability||(c=Object.create(null),c.operatorListChanged=i,l.opListReadCapability=Promise.withResolvers(),(l.renderTasks||(l.renderTasks=new Set)).add(c),l.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(u=this._stats)==null||u.time("Page Request"),this._pumpOperatorList(a)),l.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=>Sk.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(l);return}l.lang??(l.lang=c.lang),Object.assign(l.styles,c.styles),l.items.push(...c.items),i()},s)}const a=r.getReader(),l={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,xh,!1),Promise.all(e)}cleanup(e=!1){te(this,xh,!0);const r=de(this,iy,r_).call(this);return e&&r&&this._stats&&(this._stats=new hse),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&&de(this,iy,r_).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();de(this,iy,r_).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 pG){let s=KEt;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 Gm(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}}xh=new WeakMap,iy=new WeakSet,r_=function(){if(!_(this,xh)||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,xh,!1),!0};var Gp,Pc,yh,ay,mM,oy,ly,Ka,xP,C_e,E_e,n_,yw,yP;const Un=class Un{constructor({name:e=null,port:r=null,verbosity:n=DCt()}={}){le(this,Ka);le(this,Gp,Promise.withResolvers());le(this,Pc,null);le(this,yh,null);le(this,ay,null);if(this.name=e,this.destroyed=!1,this.verbosity=n,r){if(_(Un,ly).has(r))throw new Error("Cannot use more than one PDFWorker per port.");_(Un,ly).set(r,this),de(this,Ka,C_e).call(this,r)}else de(this,Ka,E_e).call(this)}get promise(){return _(this,Gp).promise}get port(){return _(this,yh)}get messageHandler(){return _(this,Pc)}destroy(){var e,r;this.destroyed=!0,(e=_(this,ay))==null||e.terminate(),te(this,ay,null),_(Un,ly).delete(_(this,yh)),te(this,yh,null),(r=_(this,Pc))==null||r.destroy(),te(this,Pc,null)}static create(e){const r=_(this,ly).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 Un(e)}static get workerSrc(){if(Vl.workerSrc)return Vl.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return gr(this,"_setupFakeWorkerGlobal",(async()=>_(this,yw,yP)?_(this,yw,yP):(await import(this.workerSrc)).WorkerMessageHandler)())}};Gp=new WeakMap,Pc=new WeakMap,yh=new WeakMap,ay=new WeakMap,mM=new WeakMap,oy=new WeakMap,ly=new WeakMap,Ka=new WeakSet,xP=function(){_(this,Gp).resolve(),_(this,Pc).send("configure",{verbosity:this.verbosity})},C_e=function(e){te(this,yh,e),te(this,Pc,new QS("main","worker",e)),_(this,Pc).on("ready",()=>{}),de(this,Ka,xP).call(this)},E_e=function(){if(_(Un,oy)||_(Un,yw,yP)){de(this,Ka,n_).call(this);return}let{workerSrc:e}=Un;try{Un._isSameOrigin(window.location,e)||(e=Un._createCDNWrapper(new URL(e,window.location).href));const r=new Worker(e,{type:"module"}),n=new QS("main","worker",r),s=()=>{i.abort(),n.destroy(),r.terminate(),this.destroyed?_(this,Gp).reject(new Error("Worker was destroyed")):de(this,Ka,n_).call(this)},i=new AbortController;r.addEventListener("error",()=>{_(this,ay)||s()},{signal:i.signal}),n.on("test",l=>{if(i.abort(),this.destroyed||!l){s();return}te(this,Pc,n),te(this,yh,r),te(this,ay,r),de(this,Ka,xP).call(this)}),n.on("ready",l=>{if(i.abort(),this.destroyed){s();return}try{a()}catch{de(this,Ka,n_).call(this)}});const a=()=>{const l=new Uint8Array;n.send("test",l,[l.buffer])};a();return}catch{zL("The worker has been disabled.")}de(this,Ka,n_).call(this)},n_=function(){_(Un,oy)||(Zt("Setting up fake worker."),te(Un,oy,!0)),Un._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){_(this,Gp).reject(new Error("Worker was destroyed"));return}const r=new oEt;te(this,yh,r);const n=`fake${xi(Un,mM)._++}`,s=new QS(n+"_worker",n,r);e.setup(s,r),te(this,Pc,new QS(n,n+"_worker",r)),de(this,Ka,xP).call(this)}).catch(e=>{_(this,Gp).reject(new Error(`Setting up fake worker failed: "${e.message}".`))})},yw=new WeakSet,yP=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},le(Un,yw),le(Un,mM,0),le(Un,oy,!1),le(Un,ly,new WeakMap),Ba&&(te(Un,oy,!0),Vl.workerSrc||(Vl.workerSrc="./pdf.worker.mjs")),Un._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},Un._createCDNWrapper=e=>{const r=`await import("${e}");`;return URL.createObjectURL(new Blob([r],{type:"text/javascript"}))},Un.fromPort=e=>{if(KCt("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(e!=null&&e.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return Un.create(e)};let _k=Un;var vh,Bu,vw,bw,bh,cy,s_;class QEt{constructor(e,r,n,s,i,a){le(this,cy);le(this,vh,new Map);le(this,Bu,new Map);le(this,vw,new Map);le(this,bw,new Map);le(this,bh,null);this.messageHandler=e,this.loadingTask=r,this.commonObjs=new w_e,this.fontLoader=new tEt({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 gr(this,"annotationStorage",new gG)}getRenderingIntent(e,r=fp.ENABLE,n=null,s=!1,i=!1){let a=Xo.DISPLAY,l=qU;switch(e){case"any":a=Xo.ANY;break;case"display":break;case"print":a=Xo.PRINT;break;default:Zt(`getRenderingIntent - invalid intent: ${e}`)}const c=a&Xo.PRINT&&n instanceof i_e?n:this.annotationStorage;switch(r){case fp.DISABLE:a+=Xo.ANNOTATIONS_DISABLE;break;case fp.ENABLE:break;case fp.ENABLE_FORMS:a+=Xo.ANNOTATIONS_FORMS;break;case fp.ENABLE_STORAGE:a+=Xo.ANNOTATIONS_STORAGE,l=c.serializable;break;default:Zt(`getRenderingIntent - invalid annotationMode: ${r}`)}s&&(a+=Xo.IS_EDITING),i&&(a+=Xo.OPLIST);const{ids:u,hash:d}=c.modifiedIds,h=[a,l.hash,d];return{renderingIntent:a,cacheKey:h.join("_"),annotationStorageSerializable:l,modifiedIds:u}}destroy(){var n;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(n=_(this,bh))==null||n.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const s of _(this,Bu).values())e.push(s._destroy());_(this,Bu).clear(),_(this,vw).clear(),_(this,bw).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,vh).clear(),this.filterFactory.destroy(),L1.cleanup(),(s=this._networkStream)==null||s.cancelAllRequests(new Gm("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)=>{Fs(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}Fs(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 l;await this._fullReader.headersReady;const{isStreamingSupported:s,isRangeSupported:i,contentLength:a}=this._fullReader;return(!s||!i)&&(this._lastProgress&&((l=r.onProgress)==null||l.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)=>{Fs(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:l}){if(l){s.close();return}Fs(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(l=>{if(!this.destroyed)throw l})}}),e.on("GetDoc",({pdfInfo:n})=>{this._numPages=n.numPages,this._htmlForXfa=n.htmlForXfa,delete n.htmlForXfa,r._capability.resolve(new YEt(n,this))}),e.on("DocException",n=>{r._capability.reject(so(n))}),e.on("PasswordRequest",n=>{te(this,bh,Promise.withResolvers());try{if(!r.onPassword)throw so(n);const s=i=>{i instanceof Error?_(this,bh).reject(i):_(this,bh).resolve({password:i})};r.onPassword(s,n.code)}catch(s){_(this,bh).reject(s)}return _(this,bh).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,Bu).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;Zt(`Error during font loading: ${d}`),this.commonObjs.resolve(n,d);break}const l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(d,h)=>globalThis.FontInspector.fontAdded(d,h):null,c=new rEt(i,l);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;Fs(u,"The imageRef must be defined.");for(const d of _(this,Bu).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 l=_(this,Bu).get(s);if(!l.objs.has(n)){if(l._intentStates.size===0){(c=a==null?void 0:a.bitmap)==null||c.close();return}switch(i){case"Image":case"Pattern":l.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&&Zt("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,vw).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,bw).set(i.refStr,e);const a=new XEt(r,i,this,this._params.pdfBug);return _(this,Bu).set(r,a),a});return _(this,vw).set(r,s),s}getPageIndex(e){return GU(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 de(this,cy,s_).call(this,"GetFieldObjects")}hasJSActions(){return de(this,cy,s_).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 de(this,cy,s_).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 de(this,cy,s_).call(this,"GetOptionalContentConfig").then(r=>new AEt(r,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",r=_(this,vh).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 CEt(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,vh).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,Bu).values())if(!r.cleanup())throw new Error(`startCleanup: Page ${r.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),_(this,vh).clear(),this.filterFactory.destroy(!0),L1.cleanup()}}cachedPageNumber(e){if(!GU(e))return null;const r=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return _(this,bw).get(r)??null}}vh=new WeakMap,Bu=new WeakMap,vw=new WeakMap,bw=new WeakMap,bh=new WeakMap,cy=new WeakSet,s_=function(e,r=null){const n=_(this,vh).get(e);if(n)return n;const s=this.messageHandler.sendWithPromise(e,r);return _(this,vh).set(e,s),s};var Kp;class ZEt{constructor(e){le(this,Kp,null);Ge(this,"onContinue",null);Ge(this,"onError",null);te(this,Kp,e)}get promise(){return _(this,Kp).capability.promise}cancel(e=0){_(this,Kp).cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=_(this,Kp).operatorList;if(!e)return!1;const{annotationCanvasMap:r}=_(this,Kp);return e.form||e.canvas&&(r==null?void 0:r.size)>0}}Kp=new WeakMap;var Yp,uy;const tx=class tx{constructor({callback:e,params:r,objs:n,commonObjs:s,annotationCanvasMap:i,operatorList:a,pageIndex:l,canvasFactory:c,filterFactory:u,useRequestAnimationFrame:d=!1,pdfBug:h=!1,pageColors:f=null,enableHWA:p=!1}){le(this,Yp,null);this.callback=e,this.params=r,this.objs=n,this.commonObjs=s,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=l,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 ZEt(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 l,c;if(this.cancelled)return;if(this._canvas){if(_(tx,uy).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.");_(tx,uy).add(this._canvas)}this._pdfBug&&((l=globalThis.StepperManager)!=null&&l.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 _0(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,Yp)&&(window.cancelAnimationFrame(_(this,Yp)),te(this,Yp,null)),_(tx,uy).delete(this._canvas),e||(e=new pG(`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,Yp,window.requestAnimationFrame(()=>{te(this,Yp,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(),_(tx,uy).delete(this._canvas),this.callback())))}};Yp=new WeakMap,uy=new WeakMap,le(tx,uy,new WeakSet);let aH=tx;const qL="5.4.54",JEt="295fb3ec4";var Fo,dy,ww,Qs,zC,jw,wh,UC,Xp,Ic,HC,dn,oH,lH,cH,Vg,A_e,rp;const io=class io{constructor({editor:e=null,uiManager:r=null}){le(this,dn);le(this,Fo,null);le(this,dy,null);le(this,ww);le(this,Qs,null);le(this,zC,!1);le(this,jw,!1);le(this,wh,null);le(this,UC);le(this,Xp,null);le(this,Ic,null);var n,s;e?(te(this,jw,!1),te(this,wh,e)):te(this,jw,!0),te(this,Ic,(e==null?void 0:e._uiManager)||r),te(this,UC,_(this,Ic)._eventBus),te(this,ww,((n=e==null?void 0:e.color)==null?void 0:n.toUpperCase())||((s=_(this,Ic))==null?void 0:s.highlightColors.values().next().value)||"#FFFF98"),_(io,HC)||te(io,HC,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 gr(this,"_keyboardManager",new dA([[["Escape","mac+Escape"],io.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],io.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],io.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],io.prototype._moveToPrevious],[["Home","mac+Home"],io.prototype._moveToBeginning],[["End","mac+End"],io.prototype._moveToEnd]]))}renderButton(){const e=te(this,Fo,document.createElement("button"));e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.ariaHasPopup="true",_(this,wh)&&(e.ariaControls=`${_(this,wh).id}_colorpicker_dropdown`);const r=_(this,Ic)._signal;e.addEventListener("click",de(this,dn,Vg).bind(this),{signal:r}),e.addEventListener("keydown",de(this,dn,cH).bind(this),{signal:r});const n=te(this,dy,document.createElement("span"));return n.className="swatch",n.ariaHidden="true",n.style.backgroundColor=_(this,ww),e.append(n),e}renderMainDropdown(){const e=te(this,Qs,de(this,dn,oH).call(this));return e.ariaOrientation="horizontal",e.ariaLabelledBy="highlightColorPickerLabel",e}_colorSelectFromKeyboard(e){if(e.target===_(this,Fo)){de(this,dn,Vg).call(this,e);return}const r=e.target.getAttribute("data-color");r&&de(this,dn,lH).call(this,r,e)}_moveToNext(e){var r,n;if(!_(this,dn,rp)){de(this,dn,Vg).call(this,e);return}if(e.target===_(this,Fo)){(r=_(this,Qs).firstChild)==null||r.focus();return}(n=e.target.nextSibling)==null||n.focus()}_moveToPrevious(e){var r,n;if(e.target===((r=_(this,Qs))==null?void 0:r.firstChild)||e.target===_(this,Fo)){_(this,dn,rp)&&this._hideDropdownFromKeyboard();return}_(this,dn,rp)||de(this,dn,Vg).call(this,e),(n=e.target.previousSibling)==null||n.focus()}_moveToBeginning(e){var r;if(!_(this,dn,rp)){de(this,dn,Vg).call(this,e);return}(r=_(this,Qs).firstChild)==null||r.focus()}_moveToEnd(e){var r;if(!_(this,dn,rp)){de(this,dn,Vg).call(this,e);return}(r=_(this,Qs).lastChild)==null||r.focus()}hideDropdown(){var e,r;(e=_(this,Qs))==null||e.classList.add("hidden"),_(this,Fo).ariaExpanded="false",(r=_(this,Xp))==null||r.abort(),te(this,Xp,null)}_hideDropdownFromKeyboard(){var e;if(!_(this,jw)){if(!_(this,dn,rp)){(e=_(this,wh))==null||e.unselect();return}this.hideDropdown(),_(this,Fo).focus({preventScroll:!0,focusVisible:_(this,zC)})}}updateColor(e){if(_(this,dy)&&(_(this,dy).style.backgroundColor=e),!_(this,Qs))return;const r=_(this,Ic).highlightColors.values();for(const n of _(this,Qs).children)n.ariaSelected=r.next().value===e.toUpperCase()}destroy(){var e,r;(e=_(this,Fo))==null||e.remove(),te(this,Fo,null),te(this,dy,null),(r=_(this,Qs))==null||r.remove(),te(this,Qs,null)}};Fo=new WeakMap,dy=new WeakMap,ww=new WeakMap,Qs=new WeakMap,zC=new WeakMap,jw=new WeakMap,wh=new WeakMap,UC=new WeakMap,Xp=new WeakMap,Ic=new WeakMap,HC=new WeakMap,dn=new WeakSet,oH=function(){const e=document.createElement("div"),r=_(this,Ic)._signal;e.addEventListener("contextmenu",lc,{signal:r}),e.className="dropdown",e.role="listbox",e.ariaMultiSelectable="false",e.ariaOrientation="vertical",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),_(this,wh)&&(e.id=`${_(this,wh).id}_colorpicker_dropdown`);for(const[n,s]of _(this,Ic).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",_(io,HC)[n]);const a=document.createElement("span");i.append(a),a.className="swatch",a.style.backgroundColor=s,i.ariaSelected=s===_(this,ww),i.addEventListener("click",de(this,dn,lH).bind(this,s),{signal:r}),e.append(i)}return e.addEventListener("keydown",de(this,dn,cH).bind(this),{signal:r}),e},lH=function(e,r){r.stopPropagation(),_(this,UC).dispatch("switchannotationeditorparams",{source:this,type:Ir.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)},cH=function(e){io._keyboardManager.exec(this,e)},Vg=function(e){if(_(this,dn,rp)){this.hideDropdown();return}if(te(this,zC,e.detail===0),_(this,Xp)||(te(this,Xp,new AbortController),window.addEventListener("pointerdown",de(this,dn,A_e).bind(this),{signal:_(this,Ic).combinedSignal(_(this,Xp))})),_(this,Fo).ariaExpanded="true",_(this,Qs)){_(this,Qs).classList.remove("hidden");return}const r=te(this,Qs,de(this,dn,oH).call(this));_(this,Fo).append(r)},A_e=function(e){var r;(r=_(this,Qs))!=null&&r.contains(e.target)||this.hideDropdown()},rp=function(){return _(this,Qs)&&!_(this,Qs).classList.contains("hidden")},le(io,HC,null);let rO=io;var zu,WC,Sw,VC;const rx=class rx{constructor(e){le(this,zu,null);le(this,WC,null);le(this,Sw,null);te(this,WC,e),te(this,Sw,e._uiManager),_(rx,VC)||te(rx,VC,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(_(this,zu))return _(this,zu);const{editorType:e,colorType:r,colorValue:n}=_(this,WC),s=te(this,zu,document.createElement("input"));return s.type="color",s.value=n||"#000000",s.className="basicColorPicker",s.tabIndex=0,s.setAttribute("data-l10n-id",_(rx,VC)[e]),s.addEventListener("input",()=>{_(this,Sw).updateParams(r,s.value)},{signal:_(this,Sw)._signal}),s}update(e){_(this,zu)&&(_(this,zu).value=e)}destroy(){var e;(e=_(this,zu))==null||e.remove(),te(this,zu,null)}hideDropdown(){}};zu=new WeakMap,WC=new WeakMap,Sw=new WeakMap,VC=new WeakMap,le(rx,VC,null);let nO=rx;function Ese(t){return Math.floor(Math.max(0,Math.min(1,t))*255).toString(16).padStart(2,"0")}function gS(t){return Math.max(0,Math.min(255,255*t))}class Ase{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=gS(e),[e,e,e]}static G_HTML([e]){const r=Ese(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(gS)}static RGB_HTML(e){return`#${e.map(Ese).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[gS(1-Math.min(1,e+s)),gS(1-Math.min(1,n+s)),gS(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,l=Math.min(s,i,a);return["CMYK",s,i,a,l]}}class eAt{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){hn("Abstract method `_createSVG` called.")}}class sO extends eAt{_createSVG(e){return document.createElementNS(Bd,e)}}class T_e{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",l=>{s.setValue(r,{value:l.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",l=>{s.setValue(r,{value:l.target.checked?l.target.getAttribute("xfaOn"):l.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&e.setAttribute("value",a.value),i==="print")break;e.addEventListener("input",l=>{s.setValue(r,{value:l.target.value})})}break;case"select":if(a.value!==null){e.setAttribute("value",a.value);for(const l of n.children)l.attributes.value===a.value?l.attributes.selected=!0:l.attributes.hasOwnProperty("selected")&&delete l.attributes.selected}e.addEventListener("input",l=>{const c=l.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,l=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:(!l||c!=="href"&&c!=="newWindow")&&e.setAttribute(c,u)}l&&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 l=i!=="richText",c=e.div;if(c.append(a),e.viewport){const p=`matrix(${e.viewport.transform.join(",")})`;c.style.transform=p}l&&c.setAttribute("class","xfaLayer xfaFont");const u=[];if(s.children.length===0){if(s.value){const p=document.createTextNode(s.value);a.append(p),l&&Sk.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 y=p.children[++d.at(-1)[1]];if(y===null)continue;const{name:x}=y;if(x==="#text"){const b=document.createTextNode(y.value);u.push(b),g.append(b);continue}const v=(h=y==null?void 0:y.attributes)!=null&&h.xmlns?document.createElementNS(y.attributes.xmlns,x):document.createElement(x);if(g.append(v),y.attributes&&this.setAttributes({html:v,element:y,storage:r,intent:i,linkService:n}),((f=y.children)==null?void 0:f.length)>0)d.push([y,-1,v]);else if(y.value){const b=document.createTextNode(y.value);l&&Sk.shouldBuildText(x)&&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 tAt=9,gv=new WeakSet,rAt=new Date().getTimezoneOffset()*60*1e3;class Tse{static create(e){switch(e.data.annotationType){case Os.LINK:return new vG(e);case Os.TEXT:return new nAt(e);case Os.WIDGET:switch(e.data.fieldType){case"Tx":return new sAt(e);case"Btn":return e.data.radioButton?new R_e(e):e.data.checkBox?new aAt(e):new oAt(e);case"Ch":return new lAt(e);case"Sig":return new iAt(e)}return new Fv(e);case Os.POPUP:return new dH(e);case Os.FREETEXT:return new $_e(e);case Os.LINE:return new uAt(e);case Os.SQUARE:return new dAt(e);case Os.CIRCLE:return new hAt(e);case Os.POLYLINE:return new F_e(e);case Os.CARET:return new pAt(e);case Os.INK:return new bG(e);case Os.POLYGON:return new fAt(e);case Os.HIGHLIGHT:return new B_e(e);case Os.UNDERLINE:return new mAt(e);case Os.SQUIGGLY:return new gAt(e);case Os.STRIKEOUT:return new xAt(e);case Os.STAMP:return new z_e(e);case Os.FILEATTACHMENT:return new yAt(e);default:return new Ps(e)}}}var hy,_w,jh,qC,uH;const WK=class WK{constructor(e,{isRenderable:r=!1,ignoreBorder:n=!1,createQuadrilaterals:s=!1}={}){le(this,qC);le(this,hy,null);le(this,_w,!1);le(this,jh,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 WK._hasPopupData(this.data)}updateEdited(e){var i;if(!this.container)return;e.rect&&(_(this,hy)||te(this,hy,{rect:this.data.rect.slice(0)}));const{rect:r,popup:n}=e;r&&de(this,qC,uH).call(this,r);let s=((i=_(this,jh))==null?void 0:i.popup)||this.popup;!s&&(n!=null&&n.text)&&(this._createPopup(n),s=_(this,jh).popup),s&&(s.updateEdited(e),n!=null&&n.deleted&&(s.remove(),te(this,jh,null),this.popup=null))}resetEdited(){var e;_(this,hy)&&(de(this,qC,uH).call(this,_(this,hy).rect),(e=_(this,jh))==null||e.popup.resetEdited(),te(this,hy,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 Fv)&&!(this instanceof vG)&&(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 dH){const{rotation:g}=r;return!r.hasOwnCanvas&&g!==0&&this.setRotation(g,i),i}const{width:l,height:c}=this;if(!e&&r.borderStyle.width>0){a.borderWidth=`${r.borderStyle.width}px`;const g=r.borderStyle.horizontalCornerRadius,y=r.borderStyle.verticalCornerRadius;if(g>0||y>0){const v=`calc(${g}px * var(--total-scale-factor)) / calc(${y}px * var(--total-scale-factor))`;a.borderRadius=v}else if(this instanceof R_e){const v=`calc(${l}px * var(--total-scale-factor)) / calc(${c}px * var(--total-scale-factor))`;a.borderRadius=v}switch(r.borderStyle.style){case yb.SOLID:a.borderStyle="solid";break;case yb.DASHED:a.borderStyle="dashed";break;case yb.BEVELED:Zt("Unimplemented border style: beveled");break;case yb.INSET:Zt("Unimplemented border style: inset");break;case yb.UNDERLINE:a.borderBottomStyle="solid";break}const x=r.borderColor||null;x?(te(this,_w,!0),a.borderColor=Rt.makeHexColor(x[0]|0,x[1]|0,x[2]|0)):a.borderWidth=0}const u=Rt.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*l/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],l=i.slice(1);s.target.style[n]=Ase[`${a}_HTML`](l),this.annotationStorage.setValue(this.data.id,{[n]:Ase[`${a}_rgb`](l)})};return gr(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 l={detail:{[s]:i},target:e};a(l),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,y,x,v]=e.subarray(2,6);if(s===g&&i===y&&r===x&&n===v)return}const{style:a}=this.container;let l;if(_(this,_w)){const{borderColor:g,borderWidth:y}=a;a.borderWidth=0,l=["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="${y}">`],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,y=e.length;g<y;g+=8){const x=e[g],v=e[g+1],b=e[g+2],w=e[g+3],j=d.createElement("rect"),N=(b-r)/c,C=(i-v)/u,A=(x-b)/c,E=(v-w)/u;j.setAttribute("x",N),j.setAttribute("y",C),j.setAttribute("width",A),j.setAttribute("height",E),p.append(j),l==null||l.push(`<rect vector-effect="non-scaling-stroke" x="${N}" y="${C}" width="${A}" height="${E}"/>`)}_(this,_w)&&(l.push("</g></svg>')"),a.backgroundImage=l.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,jh,new dH({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,jh)||this.popup||this.data.popupRef)}render(){hn("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:l}of s){if(i===-1||a===r)continue;const c=typeof l=="string"?l:null,u=document.querySelector(`[data-element-id="${a}"]`);if(u&&!gv.has(u)){Zt(`_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&&gv.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]}};hy=new WeakMap,_w=new WeakMap,jh=new WeakMap,qC=new WeakSet,uH=function(e){const{container:{style:r},data:{rect:n,rotation:s},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:l,pageY:c}}}}=this;n==null||n.splice(0,4,...e),r.left=`${100*(e[0]-l)/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 Ps=WK;var tl,qg,P_e,I_e;class vG extends Ps{constructor(r,n=null){super(r,{isRenderable:!0,ignoreBorder:!!(n!=null&&n.ignoreBorder),createQuadrilaterals:!0});le(this,tl);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?(de(this,tl,P_e).call(this,s,r.attachment,r.overlaidText,r.attachmentDest),i=!0):r.setOCGState?(de(this,tl,I_e).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==="")&&de(this,tl,qg).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),de(this,tl,qg).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 l;return(l=this.linkService.eventBus)==null||l.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n.id,name:i}}),!1})}n.overlaidText&&(r.title=n.overlaidText),r.onclick||(r.onclick=()=>!1),de(this,tl,qg).call(this)}_bindResetFormAction(r,n){const s=r.onclick;if(s||(r.href=this.linkService.getAnchorUrl("")),de(this,tl,qg).call(this),!this._fieldObjects){Zt('_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:l}=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)===l&&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(!gv.has(m)){Zt(`_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}}}tl=new WeakSet,qg=function(){this.container.setAttribute("data-internal-link","")},P_e=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},de(this,tl,qg).call(this)},I_e=function(r,n,s=""){r.href=this.linkService.getAnchorUrl(""),r.onclick=()=>(this.linkService.executeSetOCGState(n),!1),s&&(r.title=s),de(this,tl,qg).call(this)};class nAt extends Ps{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 Fv extends Ps{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 oa.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,r,n,s,i){n.includes("mouse")?e.addEventListener(n,a=>{var l;(l=this.linkService.eventBus)==null||l.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 l;if(n==="blur"){if(!r.focused||!a.relatedTarget)return;r.focused=!1}else if(n==="focus"){if(r.focused)return;r.focused=!0}i&&((l=this.linkService.eventBus)==null||l.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:i(a)}}))})}_setEventListeners(e,r,n,s){var i,a,l;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"&&!((l=this.data.actions)!=null&&l.Focus)&&this._setEventListener(e,r,"focus","Focus",null))}_setBackgroundColor(e){const r=this.data.backgroundColor||null;e.style.backgroundColor=r===null?"transparent":Rt.makeHexColor(r[0],r[1],r[2])}_setTextStyle(e){const r=["left","center","right"],{fontColor:n}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||tAt,i=e.style;let a;const l=2,c=u=>Math.round(10*u)/10;if(this.data.multiLine){const u=Math.abs(this.data.rect[3]-this.data.rect[1]-l),d=Math.round(u/(H3*s))||1,h=u/d;a=Math.min(s,c(h/H3))}else{const u=Math.abs(this.data.rect[3]-this.data.rect[1]-l);a=Math.min(s,c(u/H3))}i.fontSize=`calc(${a}px * var(--total-scale-factor))`,i.color=Rt.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 sAt extends Fv{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 l=a.value||"";const c=e.getValue(r,{charLimit:this.data.maxLen}).charLimit;c&&l.length>c&&(l=l.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:l,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=u??l,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type=this.data.password?"password":"text",n.setAttribute("value",u??l),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),gv.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",y=>{e.setValue(r,{value:y.target.value}),this.setPropertyOnSiblings(n,"value",y.target.value,"value"),d.formattedValue=null}),n.addEventListener("resetform",y=>{const x=this.data.defaultFieldValue??"";n.value=d.userValue=x,d.formattedValue=null});let g=y=>{const{formattedValue:x}=d;x!=null&&(y.target.value=x),y.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",x=>{var b;if(d.focused)return;const{target:v}=x;if(m&&(v.type=f,p&&(v.step=p)),d.userValue){const w=d.userValue;if(m)if(f==="time"){const j=new Date(w),N=[j.getHours(),j.getMinutes(),j.getSeconds()];v.value=N.map(C=>C.toString().padStart(2,"0")).join(":")}else v.value=new Date(w-rAt).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",x=>{this.showElementAndHideCanvas(x.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 j={formattedValue:w};m&&(j.value=w),e.setValue(r,j)},selRange(b){b.target.setSelectionRange(...b.detail.selRange)},charLimit:b=>{var C;const{charLimit:w}=b.detail,{target:j}=b;if(w===0){j.removeAttribute("maxLength");return}j.setAttribute("maxLength",w);let N=d.userValue;!N||N.length<=w||(N=N.slice(0,w),j.value=d.userValue=N,e.setValue(r,{value:N}),(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:N,willCommit:!0,commitKey:1,selStart:j.selectionStart,selEnd:j.selectionEnd}}))}};this._dispatchEventFromSandbox(v,x)}),n.addEventListener("keydown",x=>{var w;d.commitKey=1;let v=-1;if(x.key==="Escape"?v=0:x.key==="Enter"&&!this.data.multiLine?v=2:x.key==="Tab"&&(d.commitKey=3),v===-1)return;const{value:b}=x.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:x.target.selectionStart,selEnd:x.target.selectionEnd}}))});const y=g;g=null,n.addEventListener("blur",x=>{var w,j;if(!d.focused||!x.relatedTarget)return;(w=this.data.actions)!=null&&w.Blur||(d.focused=!1);const{target:v}=x;let{value:b}=v;if(m){if(b&&f==="time"){const N=b.split(":").map(C=>parseInt(C,10));b=new Date(2e3,0,1,N[0],N[1],N[2]||0).valueOf(),v.step=""}else b=new Date(b).valueOf();v.type="text"}d.userValue=b,d.lastCommittedValue!==b&&((j=this.linkService.eventBus)==null||j.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:b,willCommit:!0,commitKey:d.commitKey,selStart:x.target.selectionStart,selEnd:x.target.selectionEnd}})),y(x)}),(i=this.data.actions)!=null&&i.Keystroke&&n.addEventListener("beforeinput",x=>{var E;d.lastCommittedValue=null;const{data:v,target:b}=x,{value:w,selectionStart:j,selectionEnd:N}=b;let C=j,A=N;switch(x.inputType){case"deleteWordBackward":{const O=w.substring(0,j).match(/\w*[^\w]*$/);O&&(C-=O[0].length);break}case"deleteWordForward":{const O=w.substring(j).match(/^[^\w]*\w*/);O&&(A+=O[0].length);break}case"deleteContentBackward":j===N&&(C-=1);break;case"deleteContentForward":j===N&&(A+=1);break}x.preventDefault(),(E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r,name:"Keystroke",value:w,change:v||"",willCommit:!1,selStart:C,selEnd:A}})}),this._setEventListeners(n,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],x=>x.target.value)}if(g&&n.addEventListener("blur",g),this.data.comb){const x=(this.data.rect[2]-this.data.rect[0])/c;n.classList.add("comb"),n.style.letterSpacing=`calc(${x}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 iAt extends Fv{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class aAt extends Fv{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 gv.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:l,checked:c}=a.target;for(const u of this._getElementsByName(l,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 l=r.defaultFieldValue||"Off";a.target.checked=l===r.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",a=>{const l={value(c){c.target.checked=c.detail.value!=="Off",e.setValue(n,{value:c.target.checked})}};this._dispatchEventFromSandbox(l,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 R_e extends Fv{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(gv.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:l,checked:c}=a.target;for(const u of this._getElementsByName(l,n))e.setValue(u.id,{value:!1});e.setValue(n,{value:c})}),i.addEventListener("resetform",a=>{const l=r.defaultFieldValue;a.target.checked=l!=null&&l===r.buttonValue}),this.enableScripting&&this.hasJSActions){const a=r.buttonValue;i.addEventListener("updatefromsandbox",l=>{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,l)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],l=>l.target.checked)}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class oAt extends vG{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 lAt extends Fv{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");gv.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 l=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=l(!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:l(!0)}),c=l(!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,y=>y.selected)===-1&&(p[0].selected=!0),e.setValue(r,{value:l(!0),items:u(f)}),c=l(!1)},clear(f){for(;s.length!==0;)s.remove(0);e.setValue(r,{value:null,items:[]}),c=l(!1)},insert(f){const{index:p,displayValue:m,exportValue:g}=f.detail.insert,y=s.children[p],x=document.createElement("option");x.textContent=m,x.value=g,y?y.before(x):s.append(x),e.setValue(r,{value:l(!0),items:u(f)}),c=l(!1)},items(f){const{items:p}=f.detail;for(;s.length!==0;)s.remove(0);for(const m of p){const{displayValue:g,exportValue:y}=m,x=document.createElement("option");x.textContent=g,x.value=y,s.append(x)}s.options.length>0&&(s.options[0].selected=!0),e.setValue(r,{value:l(!0),items:u(f)}),c=l(!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:l(!0)}),c=l(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(h,d)}),s.addEventListener("input",d=>{var p;const h=l(!0),f=l(!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:l(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class dH extends Ps{constructor(e){const{data:r,elements:n}=e;super(e,{isRenderable:Ps._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 cAt({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=>`${fG}${s}`).join(",")),this.container}}var Nw,gM,xM,kw,Cw,hs,Sh,Qp,Ew,GC,Aw,Uu,Bo,Zp,_h,KC,Nh,Tw,fy,Jp,Vr,vP,bP,hH,O_e,M_e,D_e,L_e,wP,jP,fH;class cAt{constructor({container:e,color:r,elements:n,titleObj:s,modificationDate:i,contentsObj:a,richText:l,parent:c,rect:u,parentRect:d,open:h}){le(this,Vr);le(this,Nw,de(this,Vr,D_e).bind(this));le(this,gM,de(this,Vr,fH).bind(this));le(this,xM,de(this,Vr,jP).bind(this));le(this,kw,de(this,Vr,wP).bind(this));le(this,Cw,null);le(this,hs,null);le(this,Sh,null);le(this,Qp,null);le(this,Ew,null);le(this,GC,null);le(this,Aw,null);le(this,Uu,!1);le(this,Bo,null);le(this,Zp,null);le(this,_h,null);le(this,KC,null);le(this,Nh,null);le(this,Tw,null);le(this,fy,null);le(this,Jp,!1);te(this,hs,e),te(this,Tw,s),te(this,Sh,a),te(this,Nh,l),te(this,GC,c),te(this,Cw,r),te(this,KC,u),te(this,Aw,d),te(this,Ew,n),te(this,Qp,JR.toDateObject(i)),this.trigger=n.flatMap(f=>f.getElementsToTriggerPopup()),de(this,Vr,vP).call(this),_(this,hs).hidden=!0,h&&de(this,Vr,wP).call(this)}render(){var s;if(_(this,Bo))return;const e=te(this,Bo,document.createElement("div"));if(e.className="popup",_(this,Cw)){const i=e.style.outlineColor=Rt.makeHexColor(..._(this,Cw));e.style.backgroundColor=`color-mix(in srgb, ${i} 30%, white)`}const r=document.createElement("span");if(r.className="header",(s=_(this,Tw))!=null&&s.str){const i=document.createElement("span");i.className="title",r.append(i),{dir:i.dir,str:i.textContent}=_(this,Tw)}if(e.append(r),_(this,Qp)){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,Qp).valueOf()})),i.dateTime=_(this,Qp).toISOString(),r.append(i)}const n=_(this,Vr,bP);if(n)T_e.render({xfaHtml:n,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const i=this._formatContents(_(this,Sh));e.append(i)}_(this,hs).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 l=s[i];n.append(document.createTextNode(l)),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}de(this,Vr,vP).call(this),_(this,fy)||te(this,fy,{contentsObj:_(this,Sh),richText:_(this,Nh)}),e&&te(this,_h,null),r&&(te(this,Nh,de(this,Vr,M_e).call(this,r.text)),te(this,Qp,JR.toDateObject(r.date)),te(this,Sh,null)),(s=_(this,Bo))==null||s.remove(),te(this,Bo,null)}resetEdited(){var e;_(this,fy)&&({contentsObj:xi(this,Sh)._,richText:xi(this,Nh)._}=_(this,fy),te(this,fy,null),(e=_(this,Bo))==null||e.remove(),te(this,Bo,null),te(this,_h,null))}remove(){var e,r;(e=_(this,Zp))==null||e.abort(),te(this,Zp,null),(r=_(this,Bo))==null||r.remove(),te(this,Bo,null),te(this,Jp,!1),te(this,Uu,!1);for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){te(this,Jp,this.isVisible),_(this,Jp)&&(_(this,hs).hidden=!0)}maybeShow(){de(this,Vr,vP).call(this),_(this,Jp)&&(_(this,Bo)||de(this,Vr,jP).call(this),te(this,Jp,!1),_(this,hs).hidden=!1)}get isVisible(){return _(this,hs).hidden===!1}}Nw=new WeakMap,gM=new WeakMap,xM=new WeakMap,kw=new WeakMap,Cw=new WeakMap,hs=new WeakMap,Sh=new WeakMap,Qp=new WeakMap,Ew=new WeakMap,GC=new WeakMap,Aw=new WeakMap,Uu=new WeakMap,Bo=new WeakMap,Zp=new WeakMap,_h=new WeakMap,KC=new WeakMap,Nh=new WeakMap,Tw=new WeakMap,fy=new WeakMap,Jp=new WeakMap,Vr=new WeakSet,vP=function(){var r;if(_(this,Zp))return;te(this,Zp,new AbortController);const{signal:e}=_(this,Zp);for(const n of this.trigger)n.addEventListener("click",_(this,kw),{signal:e}),n.addEventListener("mouseenter",_(this,xM),{signal:e}),n.addEventListener("mouseleave",_(this,gM),{signal:e}),n.classList.add("popupTriggerArea");for(const n of _(this,Ew))(r=n.container)==null||r.addEventListener("keydown",_(this,Nw),{signal:e})},bP=function(){const e=_(this,Nh),r=_(this,Sh);return e!=null&&e.str&&(!(r!=null&&r.str)||r.str===e.str)&&_(this,Nh).html||null},hH=function(){var e,r,n;return((n=(r=(e=_(this,Vr,bP))==null?void 0:e.attributes)==null?void 0:r.style)==null?void 0:n.fontSize)||0},O_e=function(){var e,r,n;return((n=(r=(e=_(this,Vr,bP))==null?void 0:e.attributes)==null?void 0:r.style)==null?void 0:n.color)||null},M_e=function(e){const r=[],n={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:r}]}},s={style:{color:_(this,Vr,O_e),fontSize:_(this,Vr,hH)?`calc(${_(this,Vr,hH)}px * var(--total-scale-factor))`:""}};for(const i of e.split(`
`))r.push({name:"span",value:i,attributes:s});return n},D_e=function(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key==="Enter"||e.key==="Escape"&&_(this,Uu))&&de(this,Vr,wP).call(this)},L_e=function(){if(_(this,_h)!==null)return;const{page:{view:e},viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:s,pageY:i}}}=_(this,GC);let a=!!_(this,Aw),l=a?_(this,Aw):_(this,KC);for(const m of _(this,Ew))if(!l||Rt.intersect(m.data.rect,l)!==null){l=m.data.rect,a=!0;break}const c=Rt.normalizeRect([l[0],e[3]-l[1]+e[1],l[2],e[3]-l[3]+e[1]]),d=a?l[2]-l[0]+5:0,h=c[0]+d,f=c[1];te(this,_h,[100*(h-s)/r,100*(f-i)/n]);const{style:p}=_(this,hs);p.left=`${_(this,_h)[0]}%`,p.top=`${_(this,_h)[1]}%`},wP=function(){te(this,Uu,!_(this,Uu)),_(this,Uu)?(de(this,Vr,jP).call(this),_(this,hs).addEventListener("click",_(this,kw)),_(this,hs).addEventListener("keydown",_(this,Nw))):(de(this,Vr,fH).call(this),_(this,hs).removeEventListener("click",_(this,kw)),_(this,hs).removeEventListener("keydown",_(this,Nw)))},jP=function(){_(this,Bo)||this.render(),this.isVisible?_(this,Uu)&&_(this,hs).classList.add("focused"):(de(this,Vr,L_e).call(this),_(this,hs).hidden=!1,_(this,hs).style.zIndex=parseInt(_(this,hs).style.zIndex)+1e3)},fH=function(){_(this,hs).classList.remove("focused"),!(_(this,Uu)||!this.isVisible)&&(_(this,hs).hidden=!0,_(this,hs).style.zIndex=parseInt(_(this,hs).style.zIndex)-1e3)};class $_e extends Ps{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=Qt.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 YC;class uAt extends Ps{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,YC,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,YC,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,YC)}addHighlightArea(){this.container.classList.add("highlightArea")}}YC=new WeakMap;var XC;class dAt extends Ps{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,XC,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,l=te(this,XC,this.svgFactory.createElement("svg:rect"));return l.setAttribute("x",a/2),l.setAttribute("y",a/2),l.setAttribute("width",n-a),l.setAttribute("height",s-a),l.setAttribute("stroke-width",a||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),i.append(l),this.container.append(i),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,XC)}addHighlightArea(){this.container.classList.add("highlightArea")}}XC=new WeakMap;var QC;class hAt extends Ps{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,QC,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,l=te(this,QC,this.svgFactory.createElement("svg:ellipse"));return l.setAttribute("cx",n/2),l.setAttribute("cy",s/2),l.setAttribute("rx",n/2-a/2),l.setAttribute("ry",s/2-a/2),l.setAttribute("stroke-width",a||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),i.append(l),this.container.append(i),!r.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,QC)}addHighlightArea(){this.container.classList.add("highlightArea")}}QC=new WeakMap;var ZC;class F_e extends Ps{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,ZC,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:l}=this;if(!n)return this.container;const c=this.svgFactory.create(a,l,!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,ZC,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,ZC)}addHighlightArea(){this.container.classList.add("highlightArea")}}ZC=new WeakMap;class fAt extends F_e{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class pAt extends Ps{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 JC,py,eE,pH;class bG extends Ps{constructor(r){super(r,{isRenderable:!0,ignoreBorder:!0});le(this,eE);le(this,JC,null);le(this,py,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Qt.HIGHLIGHT:Qt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:r,rotation:n,inkLists:s,borderStyle:i,popupRef:a}}=this,{transform:l,width:c,height:u}=de(this,eE,pH).call(this,n,r),d=this.svgFactory.create(c,u,!0),h=te(this,JC,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",l);for(let f=0,p=s.length;f<p;f++){const m=this.svgFactory.createElement(this.svgElementName);_(this,py).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,JC);if(n>=0&&a.setAttribute("stroke-width",n||1),s)for(let l=0,c=_(this,py).length;l<c;l++)_(this,py)[l].setAttribute("points",s[l].join(","));if(i){const{transform:l,width:c,height:u}=de(this,eE,pH).call(this,this.data.rotation,i);a.parentElement.setAttribute("viewBox",`0 0 ${c} ${u}`),a.setAttribute("transform",l)}}getElementsToTriggerPopup(){return _(this,py)}addHighlightArea(){this.container.classList.add("highlightArea")}}JC=new WeakMap,py=new WeakMap,eE=new WeakSet,pH=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 B_e extends Ps{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Qt.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 mAt extends Ps{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 gAt extends Ps{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 xAt extends Ps{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 z_e extends Ps{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Qt.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 tE,rE,mH;class yAt extends Ps{constructor(r){var s;super(r,{isRenderable:!0});le(this,rE);le(this,tE,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",de(this,rE,mH).bind(this)),te(this,tE,s);const{isMac:i}=oa.platform;return r.addEventListener("keydown",a=>{a.key==="Enter"&&(i?a.metaKey:a.ctrlKey)&&de(this,rE,mH).call(this)}),!n.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),r.append(s),r}getElementsToTriggerPopup(){return _(this,tE)}addHighlightArea(){this.container.classList.add("highlightArea")}}tE=new WeakMap,rE=new WeakSet,mH=function(){var r;(r=this.downloadManager)==null||r.openOrDownloadData(this.content,this.filename)};var nE,my,em,sE,eg,xH,yH;const VK=class VK{constructor({div:e,accessibilityManager:r,annotationCanvasMap:n,annotationEditorUIManager:s,page:i,viewport:a,structTreeLayer:l}){le(this,eg);le(this,nE,null);le(this,my,null);le(this,em,new Map);le(this,sE,null);this.div=e,te(this,nE,r),te(this,my,n),te(this,sE,l||null),this.page=i,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return _(this,em).size>0}async render(e){var a;const{annotations:r}=e,n=this.div;pv(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 sO,annotationStorage:e.annotationStorage||new gG,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const l of r){if(l.noHTML)continue;const c=l.annotationType===Os.POPUP;if(c){const h=s.get(l.id);if(!h)continue;i.elements=h}else if(l.rect[2]===l.rect[0]||l.rect[3]===l.rect[1])continue;i.data=l;const u=Tse.create(i);if(!u.isRenderable)continue;if(!c&&l.popupRef){const h=s.get(l.popupRef);h?h.push(u):s.set(l.popupRef,[u])}const d=u.render();l.hidden&&(d.style.visibility="hidden"),await de(this,eg,xH).call(this,d,l.id,i.elements),u._isEditable&&(_(this,em).set(u.data.id,u),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(u))}de(this,eg,yH).call(this)}async addLinkAnnotations(e,r){const n={data:null,layer:this.div,linkService:r,svgFactory:new sO,parent:this};for(const s of e){s.borderStyle||(s.borderStyle=VK._defaultBorderStyle),n.data=s;const i=Tse.create(n);if(!i.isRenderable)continue;const a=i.render();await de(this,eg,xH).call(this,a,s.id,null)}}update({viewport:e}){const r=this.div;this.viewport=e,pv(r,{rotation:e.rotation}),de(this,eg,yH).call(this),r.hidden=!1}getEditableAnnotations(){return Array.from(_(this,em).values())}getEditableAnnotation(e){return _(this,em).get(e)}static get _defaultBorderStyle(){return gr(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:yb.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};nE=new WeakMap,my=new WeakMap,em=new WeakMap,sE=new WeakMap,eg=new WeakSet,xH=async function(e,r,n){var l,c;const s=e.firstChild||e,i=s.id=`${fG}${r}`,a=await((l=_(this,sE))==null?void 0:l.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,nE))==null||c.moveElementInDOM(this.div,e,s,!1))},yH=function(){var r;if(!_(this,my))return;const e=this.div;for(const[n,s]of _(this,my)){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 l=_(this,em).get(n);l&&(l._hasNoCanvas?((r=this._annotationEditorUIManager)==null||r.setMissingCanvas(n,i.id,s),l._hasNoCanvas=!1):l.canvas=s)}_(this,my).clear()};let gH=VK;const $T=/\r\n?|\n/g;var Ol,zo,iE,gy,Uo,Hs,U_e,H_e,W_e,SP,ef,_P,NP,V_e,bH,q_e;const kn=class kn extends Pn{constructor(r){super({...r,name:"freeTextEditor"});le(this,Hs);le(this,Ol);le(this,zo,"");le(this,iE,`${this.id}-editor`);le(this,gy,null);le(this,Uo);Ge(this,"_colorPicker",null);te(this,Ol,r.color||kn._defaultColor||Pn._defaultLineColor),te(this,Uo,r.fontSize||kn._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const r=kn.prototype,n=a=>a.isEmpty(),s=mv.TRANSLATE_SMALL,i=mv.TRANSLATE_BIG;return gr(this,"_keyboardManager",new dA([[["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){Pn.initialize(r,n);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(r,n){switch(r){case Ir.FREETEXT_SIZE:kn._defaultFontSize=n;break;case Ir.FREETEXT_COLOR:kn._defaultColor=n;break}}updateParams(r,n){switch(r){case Ir.FREETEXT_SIZE:de(this,Hs,U_e).call(this,n);break;case Ir.FREETEXT_COLOR:de(this,Hs,H_e).call(this,n);break}}static get defaultPropertiesToUpdate(){return[[Ir.FREETEXT_SIZE,kn._defaultFontSize],[Ir.FREETEXT_COLOR,kn._defaultColor||Pn._defaultLineColor]]}get propertiesToUpdate(){return[[Ir.FREETEXT_SIZE,_(this,Uo)],[Ir.FREETEXT_COLOR,_(this,Ol)]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new nO(this)),[["colorPicker",this._colorPicker]]}get colorType(){return Ir.FREETEXT_COLOR}get colorValue(){return _(this,Ol)}_translateEmpty(r,n){this._uiManager.translateSelectedEditors(r,n,!0)}getInitialTranslation(){const r=this.parentScale;return[-kn._internalPadding*r,-(kn._internalPadding+_(this,Uo))*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,gy,new AbortController);const r=this._uiManager.combinedSignal(_(this,gy));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,iE)),this._isDraggable=!0,(r=_(this,gy))==null||r.abort(),te(this,gy,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,zo),n=te(this,zo,de(this,Hs,W_e).call(this).trimEnd());if(r===n)return;const s=i=>{if(te(this,zo,i),!i){this.remove();return}de(this,Hs,NP).call(this),this._uiManager.rebuild(this),de(this,Hs,SP).call(this)};this.addCommands({cmd:()=>{s(n)},undo:()=>{s(r)},mustExec:!1}),de(this,Hs,SP).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){kn._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,iE)),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,Uo)}px * var(--total-scale-factor))`,s.color=_(this,Ol),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:l}=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+(l[0]-f)/d,g=n+this.height-(l[1]-p)/h;break;case 90:m=r+(l[0]-f)/d,g=n-(l[1]-p)/h,[c,u]=[u,-c];break;case 180:m=r-this.width+(l[0]-f)/d,g=n-(l[1]-p)/h,[c,u]=[-c,-u];break;case 270:m=r+(l[0]-f-this.height*h)/d,g=n+(l[1]-p-this.width*d)/h,[c,u]=[-u,c];break}this.setAt(m*i,g*a,c,u)}else this._moveAfterPaste(r,n);de(this,Hs,NP).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,y;const n=r.clipboardData||window.clipboardData,{types:s}=n;if(s.length===1&&s[0]==="text/plain")return;r.preventDefault();const i=de(m=kn,ef,bH).call(m,n.getData("text")||"").replaceAll($T,`
`);if(!i)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const l=a.getRangeAt(0);if(!i.includes(`
`)){l.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:c,startOffset:u}=l,d=[],h=[];if(c.nodeType===Node.TEXT_NODE){const x=c.parentElement;if(h.push(c.nodeValue.slice(u).replaceAll($T,"")),x!==this.editorDiv){let v=d;for(const b of this.editorDiv.childNodes){if(b===x){v=h;continue}v.push(de(g=kn,ef,_P).call(g,b))}}d.push(c.nodeValue.slice(0,u).replaceAll($T,""))}else if(c===this.editorDiv){let x=d,v=0;for(const b of this.editorDiv.childNodes)v++===u&&(x=h),x.push(de(y=kn,ef,_P).call(y,b))}te(this,zo,`${d.join(`
`)}${i}${h.join(`
`)}`),de(this,Hs,NP).call(this);const f=new Range;let p=Math.sumPrecise(d.map(x=>x.length));for(const{firstChild:x}of this.editorDiv.childNodes)if(x.nodeType===Node.TEXT_NODE){const v=x.nodeValue.length;if(p<=v){f.setStart(x,p),f.setEnd(x,p);break}p-=v}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}static async deserialize(r,n,s){var l;let i=null;if(r instanceof $_e){const{data:{defaultAppearanceData:{fontSize:c,fontColor:u},rect:d,rotation:h,id:f,popupRef:p,contentsObj:m},textContent:g,textPosition:y,parent:{page:{pageNumber:x}}}=r;if(!g||g.length===0)return null;i=r={annotationType:Qt.FREETEXT,color:Array.from(u),fontSize:c,value:g.join(`
`),position:y,pageIndex:x-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,Uo,r.fontSize),te(a,Ol,Rt.makeHexColor(...r.color)),te(a,zo,de(l=kn,ef,bH).call(l,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=kn._internalPadding*this.parentScale,s=this.getRect(n,n),i=Pn._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:_(this,Ol)),a={annotationType:Qt.FREETEXT,color:i,fontSize:_(this,Uo),value:de(this,Hs,V_e).call(this),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(a),r?(a.isCopy=!0,a):this.annotationElementId&&!de(this,Hs,q_e).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(r){const n=super.renderAnnotationElement(r),{style:s}=n;s.fontSize=`calc(${_(this,Uo)}px * var(--total-scale-factor))`,s.color=_(this,Ol),n.replaceChildren();for(const l of _(this,zo).split(`
`)){const c=document.createElement("div");c.append(l?document.createTextNode(l):document.createElement("br")),n.append(c)}const i=kn._internalPadding*this.parentScale,a={rect:this.getRect(i,i)};return a.popup=this.hasEditedComment?this.comment:{text:_(this,zo)},r.updateEdited(a),n}resetAnnotationElement(r){super.resetAnnotationElement(r),r.resetEdited()}};Ol=new WeakMap,zo=new WeakMap,iE=new WeakMap,gy=new WeakMap,Uo=new WeakMap,Hs=new WeakSet,U_e=function(r){const n=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-_(this,Uo))*this.parentScale),te(this,Uo,i),de(this,Hs,SP).call(this)},s=_(this,Uo);this.addCommands({cmd:n.bind(this,r),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ir.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},H_e=function(r){const n=i=>{var a;te(this,Ol,this.editorDiv.style.color=i),(a=this._colorPicker)==null||a.update(i)},s=_(this,Ol);this.addCommands({cmd:n.bind(this,r),undo:n.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ir.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},W_e=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(de(s=kn,ef,_P).call(s,i)),n=i);return r.join(`
`)},SP=function(){const[r,n]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:i,div:a}=this,l=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=l,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()},ef=new WeakSet,_P=function(r){return(r.nodeType===Node.TEXT_NODE?r.nodeValue:r.innerText).replaceAll($T,"")},NP=function(){if(this.editorDiv.replaceChildren(),!!_(this,zo))for(const r of _(this,zo).split(`
`)){const n=document.createElement("div");n.append(r?document.createTextNode(r):document.createElement("br")),this.editorDiv.append(n)}},V_e=function(){return _(this,zo).replaceAll(" "," ")},bH=function(r){return r.replaceAll(" "," ")},q_e=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((l,c)=>l!==i[c])||r.pageIndex!==a},le(kn,ef),Ge(kn,"_freeTextDefaultContent",""),Ge(kn,"_internalPadding",0),Ge(kn,"_defaultColor",null),Ge(kn,"_defaultFontSize",10),Ge(kn,"_type","freetext"),Ge(kn,"_editorType",Qt.FREETEXT);let vH=kn;class vt{toSVGPath(){hn("Abstract method `toSVGPath` must be implemented.")}get box(){hn("Abstract getter `box` must be implemented.")}serialize(e,r){hn("Abstract method `serialize` must be implemented.")}static _rescale(e,r,n,s,i,a){a||(a=new Float32Array(e.length));for(let l=0,c=e.length;l<c;l+=2)a[l]=r+e[l]*s,a[l+1]=n+e[l+1]*i;return a}static _rescaleAndSwap(e,r,n,s,i,a){a||(a=new Float32Array(e.length));for(let l=0,c=e.length;l<c;l+=2)a[l]=r+e[l+1]*s,a[l+1]=n+e[l]*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]}}Ge(vt,"PRECISION",1e-4);var Ho,Rc,Pw,Iw,Hu,mr,xy,yy,aE,oE,Rw,Ow,tm,lE,yM,vM,ii,i_,G_e,K_e,Y_e,X_e,Q_e,Z_e;const Zd=class Zd{constructor({x:e,y:r},n,s,i,a,l=0){le(this,ii);le(this,Ho);le(this,Rc,[]);le(this,Pw);le(this,Iw);le(this,Hu,[]);le(this,mr,new Float32Array(18));le(this,xy);le(this,yy);le(this,aE);le(this,oE);le(this,Rw);le(this,Ow);le(this,tm,[]);te(this,Ho,n),te(this,Ow,i*s),te(this,Iw,a),_(this,mr).set([NaN,NaN,NaN,NaN,e,r],6),te(this,Pw,l),te(this,oE,_(Zd,lE)*s),te(this,aE,_(Zd,vM)*s),te(this,Rw,s),_(this,tm).push(e,r)}isEmpty(){return isNaN(_(this,mr)[8])}add({x:e,y:r}){var E;te(this,xy,e),te(this,yy,r);const[n,s,i,a]=_(this,Ho);let[l,c,u,d]=_(this,mr).subarray(8,12);const h=e-u,f=r-d,p=Math.hypot(h,f);if(p<_(this,aE))return!1;const m=p-_(this,oE),g=m/p,y=g*h,x=g*f;let v=l,b=c;l=u,c=d,u+=y,d+=x,(E=_(this,tm))==null||E.push(e,r);const w=-x/m,j=y/m,N=w*_(this,Ow),C=j*_(this,Ow);return _(this,mr).set(_(this,mr).subarray(2,8),0),_(this,mr).set([u+N,d+C],4),_(this,mr).set(_(this,mr).subarray(14,18),12),_(this,mr).set([u-N,d-C],16),isNaN(_(this,mr)[6])?(_(this,Hu).length===0&&(_(this,mr).set([l+N,c+C],2),_(this,Hu).push(NaN,NaN,NaN,NaN,(l+N-n)/i,(c+C-s)/a),_(this,mr).set([l-N,c-C],14),_(this,Rc).push(NaN,NaN,NaN,NaN,(l-N-n)/i,(c-C-s)/a)),_(this,mr).set([v,b,l,c,u,d],6),!this.isEmpty()):(_(this,mr).set([v,b,l,c,u,d],6),Math.abs(Math.atan2(b-c,v-l)-Math.atan2(x,y))<Math.PI/2?([l,c,u,d]=_(this,mr).subarray(2,6),_(this,Hu).push(NaN,NaN,NaN,NaN,((l+u)/2-n)/i,((c+d)/2-s)/a),[l,c,v,b]=_(this,mr).subarray(14,18),_(this,Rc).push(NaN,NaN,NaN,NaN,((v+l)/2-n)/i,((b+c)/2-s)/a),!0):([v,b,l,c,u,d]=_(this,mr).subarray(0,6),_(this,Hu).push(((v+5*l)/6-n)/i,((b+5*c)/6-s)/a,((5*l+u)/6-n)/i,((5*c+d)/6-s)/a,((l+u)/2-n)/i,((c+d)/2-s)/a),[u,d,l,c,v,b]=_(this,mr).subarray(12,18),_(this,Rc).push(((v+5*l)/6-n)/i,((b+5*c)/6-s)/a,((5*l+u)/6-n)/i,((5*c+d)/6-s)/a,((l+u)/2-n)/i,((c+d)/2-s)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const e=_(this,Hu),r=_(this,Rc);if(isNaN(_(this,mr)[6])&&!this.isEmpty())return de(this,ii,G_e).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]}`);de(this,ii,Y_e).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 de(this,ii,K_e).call(this,n),n.join(" ")}newFreeDrawOutline(e,r,n,s,i,a){return new J_e(e,r,n,s,i,a)}getOutlines(){var h;const e=_(this,Hu),r=_(this,Rc),n=_(this,mr),[s,i,a,l]=_(this,Ho),c=new Float32Array((((h=_(this,tm))==null?void 0:h.length)??0)+2);for(let f=0,p=c.length-2;f<p;f+=2)c[f]=(_(this,tm)[f]-s)/a,c[f+1]=(_(this,tm)[f+1]-i)/l;if(c[c.length-2]=(_(this,xy)-s)/a,c[c.length-1]=(_(this,yy)-i)/l,isNaN(n[6])&&!this.isEmpty())return de(this,ii,X_e).call(this,c);const u=new Float32Array(_(this,Hu).length+24+_(this,Rc).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=de(this,ii,Z_e).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 de(this,ii,Q_e).call(this,u,d),this.newFreeDrawOutline(u,c,_(this,Ho),_(this,Rw),_(this,Pw),_(this,Iw))}};Ho=new WeakMap,Rc=new WeakMap,Pw=new WeakMap,Iw=new WeakMap,Hu=new WeakMap,mr=new WeakMap,xy=new WeakMap,yy=new WeakMap,aE=new WeakMap,oE=new WeakMap,Rw=new WeakMap,Ow=new WeakMap,tm=new WeakMap,lE=new WeakMap,yM=new WeakMap,vM=new WeakMap,ii=new WeakSet,i_=function(){const e=_(this,mr).subarray(4,6),r=_(this,mr).subarray(16,18),[n,s,i,a]=_(this,Ho);return[(_(this,xy)+(e[0]-r[0])/2-n)/i,(_(this,yy)+(e[1]-r[1])/2-s)/a,(_(this,xy)+(r[0]-e[0])/2-n)/i,(_(this,yy)+(r[1]-e[1])/2-s)/a]},G_e=function(){const[e,r,n,s]=_(this,Ho),[i,a,l,c]=de(this,ii,i_).call(this);return`M${(_(this,mr)[2]-e)/n} ${(_(this,mr)[3]-r)/s} L${(_(this,mr)[4]-e)/n} ${(_(this,mr)[5]-r)/s} L${i} ${a} L${l} ${c} L${(_(this,mr)[16]-e)/n} ${(_(this,mr)[17]-r)/s} L${(_(this,mr)[14]-e)/n} ${(_(this,mr)[15]-r)/s} Z`},K_e=function(e){const r=_(this,Rc);e.push(`L${r[4]} ${r[5]} Z`)},Y_e=function(e){const[r,n,s,i]=_(this,Ho),a=_(this,mr).subarray(4,6),l=_(this,mr).subarray(16,18),[c,u,d,h]=de(this,ii,i_).call(this);e.push(`L${(a[0]-r)/s} ${(a[1]-n)/i} L${c} ${u} L${d} ${h} L${(l[0]-r)/s} ${(l[1]-n)/i}`)},X_e=function(e){const r=_(this,mr),[n,s,i,a]=_(this,Ho),[l,c,u,d]=de(this,ii,i_).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,l,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,Ho),_(this,Rw),_(this,Pw),_(this,Iw))},Q_e=function(e,r){const n=_(this,Rc);return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],r),r+=6},Z_e=function(e,r){const n=_(this,mr).subarray(4,6),s=_(this,mr).subarray(16,18),[i,a,l,c]=_(this,Ho),[u,d,h,f]=de(this,ii,i_).call(this);return e.set([NaN,NaN,NaN,NaN,(n[0]-i)/l,(n[1]-a)/c,NaN,NaN,NaN,NaN,u,d,NaN,NaN,NaN,NaN,h,f,NaN,NaN,NaN,NaN,(s[0]-i)/l,(s[1]-a)/c],r),r+=24},le(Zd,lE,8),le(Zd,yM,2),le(Zd,vM,_(Zd,lE)+_(Zd,yM));let iO=Zd;var Mw,vy,kh,cE,Wo,uE,_s,bM,eNe;class J_e extends vt{constructor(r,n,s,i,a,l){super();le(this,bM);le(this,Mw);le(this,vy,new Float32Array(4));le(this,kh);le(this,cE);le(this,Wo);le(this,uE);le(this,_s);te(this,_s,r),te(this,Wo,n),te(this,Mw,s),te(this,uE,i),te(this,kh,a),te(this,cE,l),this.lastPoint=[NaN,NaN],de(this,bM,eNe).call(this,l);const[c,u,d,h]=_(this,vy);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,_s)[4]} ${_(this,_s)[5]}`];for(let n=6,s=_(this,_s).length;n<s;n+=6){if(isNaN(_(this,_s)[n])){r.push(`L${_(this,_s)[n+4]} ${_(this,_s)[n+5]}`);continue}r.push(`C${_(this,_s)[n]} ${_(this,_s)[n+1]} ${_(this,_s)[n+2]} ${_(this,_s)[n+3]} ${_(this,_s)[n+4]} ${_(this,_s)[n+5]}`)}return r.push("Z"),r.join(" ")}serialize([r,n,s,i],a){const l=s-r,c=i-n;let u,d;switch(a){case 0:u=vt._rescale(_(this,_s),r,i,l,-c),d=vt._rescale(_(this,Wo),r,i,l,-c);break;case 90:u=vt._rescaleAndSwap(_(this,_s),r,n,l,c),d=vt._rescaleAndSwap(_(this,Wo),r,n,l,c);break;case 180:u=vt._rescale(_(this,_s),s,n,-l,c),d=vt._rescale(_(this,Wo),s,n,-l,c);break;case 270:u=vt._rescaleAndSwap(_(this,_s),s,i,-l,-c),d=vt._rescaleAndSwap(_(this,Wo),s,i,-l,-c);break}return{outline:Array.from(u),points:[Array.from(d)]}}get box(){return _(this,vy)}newOutliner(r,n,s,i,a,l=0){return new iO(r,n,s,i,a,l)}getNewOutline(r,n){const[s,i,a,l]=_(this,vy),[c,u,d,h]=_(this,Mw),f=a*d,p=l*h,m=s*d+c,g=i*h+u,y=this.newOutliner({x:_(this,Wo)[0]*f+m,y:_(this,Wo)[1]*p+g},_(this,Mw),_(this,uE),r,_(this,cE),n??_(this,kh));for(let x=2;x<_(this,Wo).length;x+=2)y.add({x:_(this,Wo)[x]*f+m,y:_(this,Wo)[x+1]*p+g});return y.getOutlines()}}Mw=new WeakMap,vy=new WeakMap,kh=new WeakMap,cE=new WeakMap,Wo=new WeakMap,uE=new WeakMap,_s=new WeakMap,bM=new WeakSet,eNe=function(r){const n=_(this,_s);let s=n[4],i=n[5];const a=[s,i,s,i];let l=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]))Rt.pointBoundingBox(p,m,a),c<m?(l=p,c=m):c===m&&(l=u(l,p));else{const g=[1/0,1/0,-1/0,-1/0];Rt.bezierBoundingBox(s,i,...n.slice(h,h+6),g),Rt.rectBoundingBox(...g,a),c<g[3]?(l=g[2],c=g[3]):c===g[3]&&(l=u(l,g[2]))}s=p,i=m}const d=_(this,vy);d[0]=a[0]-_(this,kh),d[1]=a[1]-_(this,kh),d[2]=a[2]-a[0]+2*_(this,kh),d[3]=a[3]-a[1]+2*_(this,kh),this.lastPoint=[l,c]};var dE,hE,rm,Oc,Xa,tNe,kP,rNe,nNe,jH;class wH{constructor(e,r=0,n=0,s=!0){le(this,Xa);le(this,dE);le(this,hE);le(this,rm,[]);le(this,Oc,[]);const i=[1/0,1/0,-1/0,-1/0],l=10**-4;for(const{x:m,y:g,width:y,height:x}of e){const v=Math.floor((m-r)/l)*l,b=Math.ceil((m+y+r)/l)*l,w=Math.floor((g-r)/l)*l,j=Math.ceil((g+x+r)/l)*l,N=[v,w,j,!0],C=[b,w,j,!1];_(this,rm).push(N,C),Rt.rectBoundingBox(v,w,b,j,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,rm).at(s?-1:-2),p=[f[0],f[2]];for(const m of _(this,rm)){const[g,y,x]=m;m[0]=(g-d)/c,m[1]=(y-h)/u,m[2]=(x-h)/u}te(this,dE,new Float32Array([d,h,c,u])),te(this,hE,p)}getOutlines(){_(this,rm).sort((r,n)=>r[0]-n[0]||r[1]-n[1]||r[2]-n[2]);const e=[];for(const r of _(this,rm))r[3]?(e.push(...de(this,Xa,jH).call(this,r)),de(this,Xa,rNe).call(this,r)):(de(this,Xa,nNe).call(this,r),e.push(...de(this,Xa,jH).call(this,r)));return de(this,Xa,tNe).call(this,e)}}dE=new WeakMap,hE=new WeakMap,rm=new WeakMap,Oc=new WeakMap,Xa=new WeakSet,tNe=function(e){const r=[],n=new Set;for(const a of e){const[l,c,u]=a;r.push([l,c,a],[l,u,a])}r.sort((a,l)=>a[1]-l[1]||a[0]-l[0]);for(let a=0,l=r.length;a<l;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[l,c,u,d,h]=a;n.delete(a);let f=l,p=c;for(i=[l,u],s.push(i);;){let m;if(n.has(d))m=d;else if(n.has(h))m=h;else break;n.delete(m),[l,c,u,d,h]=m,f!==l&&(i.push(f,p,l,p===c?c:u),f=l),p=p===c?u:c}i.push(f,p)}return new vAt(s,_(this,dE),_(this,hE))},kP=function(e){const r=_(this,Oc);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},rNe=function([,e,r]){const n=de(this,Xa,kP).call(this,e);_(this,Oc).splice(n,0,[e,r])},nNe=function([,e,r]){const n=de(this,Xa,kP).call(this,e);for(let s=n;s<_(this,Oc).length;s++){const[i,a]=_(this,Oc)[s];if(i!==e)break;if(i===e&&a===r){_(this,Oc).splice(s,1);return}}for(let s=n-1;s>=0;s--){const[i,a]=_(this,Oc)[s];if(i!==e)break;if(i===e&&a===r){_(this,Oc).splice(s,1);return}}},jH=function(e){const[r,n,s]=e,i=[[r,n,s]],a=de(this,Xa,kP).call(this,s);for(let l=0;l<a;l++){const[c,u]=_(this,Oc)[l];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 fE,Dw;class vAt extends vt{constructor(r,n,s){super();le(this,fE);le(this,Dw);te(this,Dw,r),te(this,fE,n),this.lastPoint=s}toSVGPath(){const r=[];for(const n of _(this,Dw)){let[s,i]=n;r.push(`M${s} ${i}`);for(let a=2;a<n.length;a+=2){const l=n[a],c=n[a+1];l===s?(r.push(`V${c}`),i=c):c===i&&(r.push(`H${l}`),s=l)}r.push("Z")}return r.join(" ")}serialize([r,n,s,i],a){const l=[],c=s-r,u=i-n;for(const d of _(this,Dw)){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;l.push(h)}return l}get box(){return _(this,fE)}get classNamesForOutlining(){return["highlightOutline"]}}fE=new WeakMap,Dw=new WeakMap;class SH extends iO{newFreeDrawOutline(e,r,n,s,i,a){return new bAt(e,r,n,s,i,a)}}class bAt extends J_e{newOutliner(e,r,n,s,i,a=0){return new SH(e,r,n,s,i,a)}}var Lw,pE,Ch,by,mE,uo,gE,xE,wy,Ml,Vo,Wi,$w,Eh,va,Fw,Dl,yE,er,_H,CP,sNe,iNe,aNe,NH,Gg,ql,_b,oNe,EP,a_,lNe,cNe,uNe,dNe,hNe;const Gr=class Gr extends Pn{constructor(r){super({...r,name:"highlightEditor"});le(this,er);le(this,Lw,null);le(this,pE,0);le(this,Ch);le(this,by,null);le(this,mE,null);le(this,uo,null);le(this,gE,null);le(this,xE,0);le(this,wy,null);le(this,Ml,null);le(this,Vo,null);le(this,Wi,!1);le(this,$w,null);le(this,Eh);le(this,va,null);le(this,Fw,"");le(this,Dl);le(this,yE,"");this.color=r.color||Gr._defaultColor,te(this,Dl,r.thickness||Gr._defaultThickness),te(this,Eh,r.opacity||Gr._defaultOpacity),te(this,Ch,r.boxes||null),te(this,yE,r.methodOfCreation||""),te(this,Fw,r.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",r.highlightId>-1?(te(this,Wi,!0),de(this,er,CP).call(this,r),de(this,er,Gg).call(this)):_(this,Ch)&&(te(this,Lw,r.anchorNode),te(this,pE,r.anchorOffset),te(this,gE,r.focusNode),te(this,xE,r.focusOffset),de(this,er,_H).call(this),de(this,er,Gg).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const r=Gr.prototype;return gr(this,"_keyboardManager",new dA([[["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,Wi)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:_(this,Dl),methodOfCreation:_(this,yE)}}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;Pn.initialize(r,n),Gr._defaultColor||(Gr._defaultColor=((s=n.highlightColors)==null?void 0:s.values().next().value)||"#fff066")}static updateDefaultParams(r,n){switch(r){case Ir.HIGHLIGHT_COLOR:Gr._defaultColor=n;break;case Ir.HIGHLIGHT_THICKNESS:Gr._defaultThickness=n;break}}translateInPage(r,n){}get toolbarPosition(){return _(this,$w)}updateParams(r,n){switch(r){case Ir.HIGHLIGHT_COLOR:de(this,er,sNe).call(this,n);break;case Ir.HIGHLIGHT_THICKNESS:de(this,er,iNe).call(this,n);break}}static get defaultPropertiesToUpdate(){return[[Ir.HIGHLIGHT_COLOR,Gr._defaultColor],[Ir.HIGHLIGHT_THICKNESS,Gr._defaultThickness]]}get propertiesToUpdate(){return[[Ir.HIGHLIGHT_COLOR,this.color||Gr._defaultColor],[Ir.HIGHLIGHT_THICKNESS,_(this,Dl)||Gr._defaultThickness],[Ir.HIGHLIGHT_FREE,_(this,Wi)]]}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",te(this,mE,new rO({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(de(this,er,a_).call(this))}getBaseTranslation(){return[0,0]}getRect(r,n){return super.getRect(r,n,de(this,er,a_).call(this))}onceAdded(r){this.annotationElementId||this.parent.addUndoableEditor(this),r&&this.div.focus()}remove(){de(this,er,NH).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(de(this,er,Gg).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(r){var s;let n=!1;this.parent&&!r?de(this,er,NH).call(this):r&&(de(this,er,Gg).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,l;const{drawLayer:n}=this.parent;let s;_(this,Wi)?(r=(r-this.rotation+360)%360,s=de(i=Gr,ql,_b).call(i,_(this,Ml).box,r)):s=de(a=Gr,ql,_b).call(a,[this.x,this.y,this.width,this.height],r),n.updateProperties(_(this,Vo),{bbox:s,root:{"data-main-rotation":r}}),n.updateProperties(_(this,va),{bbox:de(l=Gr,ql,_b).call(l,_(this,uo).box,r),root:{"data-main-rotation":r}})}render(){if(this.div)return this.div;const r=super.render();_(this,Fw)&&(r.setAttribute("aria-label",_(this,Fw)),r.setAttribute("role","mark")),_(this,Wi)?r.classList.add("free"):this.div.addEventListener("keydown",de(this,er,oNe).bind(this),{signal:this._uiManager._signal});const n=te(this,wy,document.createElement("div"));r.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",n.style.clipPath=_(this,by);const[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),RSe(this,_(this,wy),["pointerover","pointerleave"]),this.enableEditing(),r}pointerover(){var r;this.isSelected||(r=this.parent)==null||r.drawLayer.updateProperties(_(this,va),{rootClass:{hovered:!0}})}pointerleave(){var r;this.isSelected||(r=this.parent)==null||r.drawLayer.updateProperties(_(this,va),{rootClass:{hovered:!1}})}_moveCaret(r){switch(this.parent.unselect(this),r){case 0:case 2:de(this,er,EP).call(this,!0);break;case 1:case 3:de(this,er,EP).call(this,!1);break}}select(){var r;super.select(),_(this,va)&&((r=this.parent)==null||r.drawLayer.updateProperties(_(this,va),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var r;super.unselect(),_(this,va)&&((r=this.parent)==null||r.drawLayer.updateProperties(_(this,va),{rootClass:{selected:!1}}),_(this,Wi)||de(this,er,EP).call(this,!1))}get _mustFixPosition(){return!_(this,Wi)}show(r=this._isVisible){super.show(r),this.parent&&(this.parent.drawLayer.updateProperties(_(this,Vo),{rootClass:{hidden:!r}}),this.parent.drawLayer.updateProperties(_(this,va),{rootClass:{hidden:!r}}))}static startHighlighting(r,n,{target:s,x:i,y:a}){const{x:l,y:c,width:u,height:d}=s.getBoundingClientRect(),h=new AbortController,f=r.combinedSignal(h),p=m=>{h.abort(),de(this,ql,dNe).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",lc,{signal:f}),s.addEventListener("pointermove",de(this,ql,uNe).bind(this,r),{signal:f}),this._freeHighlight=new SH({x:i,y:a},[l,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,y,x,v;let i=null;if(r instanceof B_e){const{data:{quadPoints:b,rect:w,rotation:j,id:N,color:C,opacity:A,popupRef:E,contentsObj:O},parent:{page:{pageNumber:$}}}=r;i=r={annotationType:Qt.HIGHLIGHT,color:Array.from(C),opacity:A,quadPoints:b,boxes:null,pageIndex:$-1,rect:w.slice(0),rotation:j,annotationElementId:N,id:N,deleted:!1,popupRef:E,comment:(O==null?void 0:O.str)||null}}else if(r instanceof bG){const{data:{inkLists:b,rect:w,rotation:j,id:N,color:C,borderStyle:{rawWidth:A},popupRef:E,contentsObj:O},parent:{page:{pageNumber:$}}}=r;i=r={annotationType:Qt.HIGHLIGHT,color:Array.from(C),thickness:A,inkLists:b,boxes:null,pageIndex:$-1,rect:w.slice(0),rotation:j,annotationElementId:N,id:N,deleted:!1,popupRef:E,comment:(O==null?void 0:O.str)||null}}const{color:a,quadPoints:l,inkLists:c,opacity:u}=r,d=await super.deserialize(r,n,s);d.color=Rt.makeHexColor(...a),te(d,Eh,u||1),c&&te(d,Dl,r.thickness),d._initialData=i,r.comment&&d.setCommentData(r.comment);const[h,f]=d.pageDimensions,[p,m]=d.pageTranslation;if(l){const b=te(d,Ch,[]);for(let w=0;w<l.length;w+=8)b.push({x:(l[w]-p)/h,y:1-(l[w+1]-m)/f,width:(l[w+2]-l[w])/h,height:(l[w+1]-l[w+5])/f});de(g=d,er,_H).call(g),de(y=d,er,Gg).call(y),d.rotate(d.rotation)}else if(c){te(d,Wi,!0);const b=c[0],w={x:b[0]-p,y:f-(b[1]-m)},j=new SH(w,[0,0,h,f],1,_(d,Dl)/2,!0,.001);for(let A=0,E=b.length;A<E;A+=2)w.x=b[A]-p,w.y=f-(b[A+1]-m),j.add(w);const{id:N,clipPathId:C}=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:j.toSVGPath()}},!0,!0);de(x=d,er,CP).call(x,{highlightOutlines:j.getOutlines(),highlightId:N,clipPathId:C}),de(v=d,er,Gg).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=Pn._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i={annotationType:Qt.HIGHLIGHT,color:s,opacity:_(this,Eh),thickness:_(this,Dl),quadPoints:de(this,er,lNe).call(this),outlines:de(this,er,cNe).call(this,n),pageIndex:this.pageIndex,rect:n,rotation:de(this,er,a_).call(this),structTreeParentId:this._structTreeParentId};return this.addComment(i),this.annotationElementId&&!de(this,er,hNe).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}};Lw=new WeakMap,pE=new WeakMap,Ch=new WeakMap,by=new WeakMap,mE=new WeakMap,uo=new WeakMap,gE=new WeakMap,xE=new WeakMap,wy=new WeakMap,Ml=new WeakMap,Vo=new WeakMap,Wi=new WeakMap,$w=new WeakMap,Eh=new WeakMap,va=new WeakMap,Fw=new WeakMap,Dl=new WeakMap,yE=new WeakMap,er=new WeakSet,_H=function(){const r=new wH(_(this,Ch),.001);te(this,Ml,r.getOutlines()),[this.x,this.y,this.width,this.height]=_(this,Ml).box;const n=new wH(_(this,Ch),.0025,.001,this._uiManager.direction==="ltr");te(this,uo,n.getOutlines());const{lastPoint:s}=_(this,uo);te(this,$w,[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height])},CP=function({highlightOutlines:r,highlightId:n,clipPathId:s}){var h,f;if(te(this,Ml,r),te(this,uo,r.getNewOutline(_(this,Dl)/2+1.5,.0025)),n>=0)te(this,Vo,n),te(this,by,s),this.parent.drawLayer.finalizeDraw(n,{bbox:r.box,path:{d:r.toSVGPath()}}),te(this,va,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:_(this,uo).box,path:{d:_(this,uo).toSVGPath()}},!0));else if(this.parent){const p=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(_(this,Vo),{bbox:de(h=Gr,ql,_b).call(h,_(this,Ml).box,(p-this.rotation+360)%360),path:{d:r.toSVGPath()}}),this.parent.drawLayer.updateProperties(_(this,va),{bbox:de(f=Gr,ql,_b).call(f,_(this,uo).box,p),path:{d:_(this,uo).toSVGPath()}})}const[a,l,c,u]=r.box;switch(this.rotation){case 0:this.x=a,this.y=l,this.width=c,this.height=u;break;case 90:{const[p,m]=this.parentDimensions;this.x=l,this.y=1-a,this.width=c*m/p,this.height=u*p/m;break}case 180:this.x=1-a,this.y=1-l,this.width=c,this.height=u;break;case 270:{const[p,m]=this.parentDimensions;this.x=1-l,this.y=a,this.width=c*m/p,this.height=u*p/m;break}}const{lastPoint:d}=_(this,uo);te(this,$w,[(d[0]-a)/c,(d[1]-l)/u])},sNe=function(r){const n=(a,l)=>{var c,u;this.color=a,te(this,Eh,l),(c=this.parent)==null||c.drawLayer.updateProperties(_(this,Vo),{root:{fill:a,"fill-opacity":l}}),(u=_(this,mE))==null||u.updateColor(a)},s=this.color,i=_(this,Eh);this.addCommands({cmd:n.bind(this,r,Gr._defaultOpacity),undo:n.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Ir.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(r)},!0)},iNe=function(r){const n=_(this,Dl),s=i=>{te(this,Dl,i),de(this,er,aNe).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:Ir.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:r},!0)},aNe=function(r){if(!_(this,Wi))return;de(this,er,CP).call(this,{highlightOutlines:_(this,Ml).getNewOutline(r/2)}),this.fixAndSetPosition();const[n,s]=this.parentDimensions;this.setDims(this.width*n,this.height*s)},NH=function(){_(this,Vo)===null||!this.parent||(this.parent.drawLayer.remove(_(this,Vo)),te(this,Vo,null),this.parent.drawLayer.remove(_(this,va)),te(this,va,null))},Gg=function(r=this.parent){_(this,Vo)===null&&({id:xi(this,Vo)._,clipPathId:xi(this,by)._}=r.drawLayer.draw({bbox:_(this,Ml).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":_(this,Eh)},rootClass:{highlight:!0,free:_(this,Wi)},path:{d:_(this,Ml).toSVGPath()}},!1,!0),te(this,va,r.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:_(this,Wi)},bbox:_(this,uo).box,path:{d:_(this,uo).toSVGPath()}},_(this,Wi))),_(this,wy)&&(_(this,wy).style.clipPath=_(this,by)))},ql=new WeakSet,_b=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]},oNe=function(r){Gr._keyboardManager.exec(this,r)},EP=function(r){if(!_(this,Lw))return;const n=window.getSelection();r?n.setPosition(_(this,Lw),_(this,pE)):n.setPosition(_(this,gE),_(this,xE))},a_=function(){return _(this,Wi)?this.rotation:0},lNe=function(){if(_(this,Wi))return null;const[r,n]=this.pageDimensions,[s,i]=this.pageTranslation,a=_(this,Ch),l=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;l[c]=l[c+4]=p,l[c+1]=l[c+3]=m,l[c+2]=l[c+6]=p+h*r,l[c+5]=l[c+7]=m-f*n,c+=8}return l},cNe=function(r){return _(this,Ml).serialize(r,de(this,er,a_).call(this))},uNe=function(r,n){this._freeHighlight.add(n)&&r.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},dNe=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=""},hNe=function(r){const{color:n}=this._initialData;return this.hasEditedComment||r.color.some((s,i)=>s!==n[i])},le(Gr,ql),Ge(Gr,"_defaultColor",null),Ge(Gr,"_defaultOpacity",1),Ge(Gr,"_defaultThickness",12),Ge(Gr,"_type","highlight"),Ge(Gr,"_editorType",Qt.HIGHLIGHT),Ge(Gr,"_freeHighlightId",-1),Ge(Gr,"_freeHighlight",null),Ge(Gr,"_freeHighlightClipId","");let aO=Gr;var jy;class fNe{constructor(){le(this,jy,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,jy)[e]=r}toSVGProperties(){const e=_(this,jy);return te(this,jy,Object.create(null)),{root:e}}reset(){te(this,jy,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){hn("Not implemented")}}jy=new WeakMap;var qo,Bw,bi,Sy,_y,nm,sm,im,Ny,Ur,kH,CH,EH,o_,pNe,AP,l_,Nb;const _t=class _t extends Pn{constructor(r){super(r);le(this,Ur);le(this,qo,null);le(this,Bw);Ge(this,"_colorPicker",null);Ge(this,"_drawId",null);te(this,Bw,r.mustBeCommitted||!1),this._addOutlines(r)}_addOutlines(r){r.drawOutlines&&(de(this,Ur,kH).call(this,r),de(this,Ur,o_).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){hn("Not implemented")}static get typesMap(){hn("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&&(_(_t,bi).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],l=c=>{var d,h;i.updateProperty(n,c);const u=_(this,qo).updateProperty(n,c);u&&de(this,Ur,l_).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:l.bind(this,s),undo:l.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,_t._mergeSVGProperties(_(this,qo).getPathResizingSVGProperties(de(this,Ur,AP).call(this)),{bbox:de(this,Ur,Nb).call(this)}))}_onResized(){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,_t._mergeSVGProperties(_(this,qo).getPathResizedSVGProperties(de(this,Ur,AP).call(this)),{bbox:de(this,Ur,Nb).call(this)}))}_onTranslating(r,n){var s;(s=this.parent)==null||s.drawLayer.updateProperties(this._drawId,{bbox:de(this,Ur,Nb).call(this)})}_onTranslated(){var r;(r=this.parent)==null||r.drawLayer.updateProperties(this._drawId,_t._mergeSVGProperties(_(this,qo).getPathTranslatedSVGProperties(de(this,Ur,AP).call(this),this.parentDimensions),{bbox:de(this,Ur,Nb).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,Bw)&&(te(this,Bw,!1),this.commit(),this.parent.setSelected(this),r&&this.isOnScreen&&this.div.focus())}remove(){de(this,Ur,EH).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(de(this,Ur,o_).call(this),de(this,Ur,l_).call(this,_(this,qo).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(r){var s;let n=!1;this.parent&&!r?(this._uiManager.removeShouldRescale(this),de(this,Ur,EH).call(this)):r&&(this._uiManager.addShouldRescale(this),de(this,Ur,o_).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,_t._mergeSVGProperties({bbox:de(this,Ur,Nb).call(this)},_(this,qo).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&de(this,Ur,l_).call(this,_(this,qo).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,l]=this.parentDimensions;return this.setDims(this.width*a,this.height*l),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(r,n),s}static createDrawerInstance(r,n,s,i,a){hn("Not implemented")}static startDrawing(r,n,s,i){var y;const{target:a,offsetX:l,offsetY:c,pointerId:u,pointerType:d}=i;if(_(_t,sm)&&_(_t,sm)!==d)return;const{viewport:{rotation:h}}=r,{width:f,height:p}=a.getBoundingClientRect(),m=te(_t,Sy,new AbortController),g=r.combinedSignal(m);if(_(_t,nm)||te(_t,nm,u),_(_t,sm)??te(_t,sm,d),window.addEventListener("pointerup",x=>{var v;_(_t,nm)===x.pointerId?this._endDraw(x):(v=_(_t,im))==null||v.delete(x.pointerId)},{signal:g}),window.addEventListener("pointercancel",x=>{var v;_(_t,nm)===x.pointerId?this._currentParent.endDrawingSession():(v=_(_t,im))==null||v.delete(x.pointerId)},{signal:g}),window.addEventListener("pointerdown",x=>{_(_t,sm)===x.pointerType&&((_(_t,im)||te(_t,im,new Set)).add(x.pointerId),_(_t,bi).isCancellable()&&(_(_t,bi).removeLastElement(),_(_t,bi).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",lc,{signal:g}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:g}),a.addEventListener("touchmove",x=>{x.timeStamp===_(_t,Ny)&&Ls(x)},{signal:g}),r.toggleDrawing(),(y=n._editorUndoBar)==null||y.hide(),_(_t,bi)){r.drawLayer.updateProperties(this._currentDrawId,_(_t,bi).startNew(l,c,f,p,h));return}n.updateUIForDefaultProperties(this),te(_t,bi,this.createDrawerInstance(l,c,f,p,h)),te(_t,_y,this.getDefaultDrawingOptions()),this._currentParent=r,{id:this._currentDrawId}=r.drawLayer.draw(this._mergeSVGProperties(_(_t,_y).toSVGProperties(),_(_t,bi).defaultSVGProperties),!0,!1)}static _drawMove(r){var a;if(te(_t,Ny,-1),!_(_t,bi))return;const{offsetX:n,offsetY:s,pointerId:i}=r;if(_(_t,nm)===i){if(((a=_(_t,im))==null?void 0:a.size)>=1){this._endDraw(r);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,_(_t,bi).add(n,s)),te(_t,Ny,r.timeStamp),Ls(r)}}static _cleanup(r){r&&(this._currentDrawId=-1,this._currentParent=null,te(_t,bi,null),te(_t,_y,null),te(_t,sm,null),te(_t,Ny,NaN)),_(_t,Sy)&&(_(_t,Sy).abort(),te(_t,Sy,null),te(_t,nm,NaN),te(_t,im,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,_(_t,bi).end(r.offsetX,r.offsetY)),this.supportMultipleDrawings){const s=_(_t,bi),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:Ir.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(r){const n=this._currentParent;if(!n)return null;if(n.toggleDrawing(!0),n.cleanUndoStack(Ir.DRAW_STEP),!_(_t,bi).isEmpty()){const{pageDimensions:[s,i],scale:a}=n,l=n.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:_(_t,bi).getOutlines(s*a,i*a,a,this._INNER_MARGIN),drawingOptions:_(_t,_y),mustBeCommitted:!r});return this._cleanup(!0),l}return n.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(r){}static deserializeDraw(r,n,s,i,a,l){hn("Not implemented")}static async deserialize(r,n,s){var h,f;const{rawDims:{pageWidth:i,pageHeight:a,pageX:l,pageY:c}}=n.viewport,u=this.deserializeDraw(l,c,i,a,this._INNER_MARGIN,r),d=await super.deserialize(r,n,s);return d.createDrawingOptions(r),de(h=d,Ur,kH).call(h,{drawOutlines:u}),de(f=d,Ur,o_).call(f),d.onScaleChanging(),d.rotate(),d}serializeDraw(r){const[n,s]=this.pageTranslation,[i,a]=this.pageDimensions;return _(this,qo).serialize([n,s,i,a],r)}renderAnnotationElement(r){return r.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};qo=new WeakMap,Bw=new WeakMap,bi=new WeakMap,Sy=new WeakMap,_y=new WeakMap,nm=new WeakMap,sm=new WeakMap,im=new WeakMap,Ny=new WeakMap,Ur=new WeakSet,kH=function({drawOutlines:r,drawId:n,drawingOptions:s}){te(this,qo,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=de(this,Ur,CH).call(this,r,this.parent),de(this,Ur,l_).call(this,r.box)},CH=function(r,n){const{id:s}=n.drawLayer.draw(_t._mergeSVGProperties(this._drawingOptions.toSVGProperties(),r.defaultSVGProperties),!1,!1);return s},EH=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},o_=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=de(this,Ur,CH).call(this,_(this,qo),r)}},pNe=function([r,n,s,i]){const{parentDimensions:[a,l],rotation:c}=this;switch(c){case 90:return[n,1-r,s*(l/a),i*(a/l)];case 180:return[1-r,1-n,s,i];case 270:return[1-n,r,s*(l/a),i*(a/l)];default:return[r,n,s,i]}},AP=function(){const{x:r,y:n,width:s,height:i,parentDimensions:[a,l],rotation:c}=this;switch(c){case 90:return[1-n,r,s*(a/l),i*(l/a)];case 180:return[1-r,1-n,s,i];case 270:return[n,1-r,s*(a/l),i*(l/a)];default:return[r,n,s,i]}},l_=function(r){if([this.x,this.y,this.width,this.height]=de(this,Ur,pNe).call(this,r),this.div){this.fixAndSetPosition();const[n,s]=this.parentDimensions;this.setDims(this.width*n,this.height*s)}this._onResized()},Nb=function(){const{x:r,y:n,width:s,height:i,rotation:a,parentRotation:l,parentDimensions:[c,u]}=this;switch((a*4+l)/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]}},Ge(_t,"_currentDrawId",-1),Ge(_t,"_currentParent",null),le(_t,bi,null),le(_t,Sy,null),le(_t,_y,null),le(_t,nm,NaN),le(_t,sm,null),le(_t,im,null),le(_t,Ny,NaN),Ge(_t,"_INNER_MARGIN",3);let oO=_t;var Wu,wi,ji,ky,zw,La,Vi,Ll,Cy,Ey,Ay,Uw,TP;class wAt{constructor(e,r,n,s,i,a){le(this,Uw);le(this,Wu,new Float64Array(6));le(this,wi);le(this,ji);le(this,ky);le(this,zw);le(this,La);le(this,Vi,"");le(this,Ll,0);le(this,Cy,new fA);le(this,Ey);le(this,Ay);te(this,Ey,n),te(this,Ay,s),te(this,ky,i),te(this,zw,a),[e,r]=de(this,Uw,TP).call(this,e,r);const l=te(this,wi,[NaN,NaN,NaN,NaN,e,r]);te(this,La,[e,r]),te(this,ji,[{line:l,points:_(this,La)}]),_(this,Wu).set(l,0)}updateProperty(e,r){e==="stroke-width"&&te(this,zw,r)}isEmpty(){return!_(this,ji)||_(this,ji).length===0}isCancellable(){return _(this,La).length<=10}add(e,r){[e,r]=de(this,Uw,TP).call(this,e,r);const[n,s,i,a]=_(this,Wu).subarray(2,6),l=e-i,c=r-a;return Math.hypot(_(this,Ey)*l,_(this,Ay)*c)<=2?null:(_(this,La).push(e,r),isNaN(n)?(_(this,Wu).set([i,a,e,r],2),_(this,wi).push(NaN,NaN,NaN,NaN,e,r),{path:{d:this.toSVGPath()}}):(isNaN(_(this,Wu)[0])&&_(this,wi).splice(6,6),_(this,Wu).set([n,s,i,a,e,r],0),_(this,wi).push(...vt.createBezierPoints(n,s,i,a,e,r)),{path:{d:this.toSVGPath()}}))}end(e,r){const n=this.add(e,r);return n||(_(this,La).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,r,n,s,i){te(this,Ey,n),te(this,Ay,s),te(this,ky,i),[e,r]=de(this,Uw,TP).call(this,e,r);const a=te(this,wi,[NaN,NaN,NaN,NaN,e,r]);te(this,La,[e,r]);const l=_(this,ji).at(-1);return l&&(l.line=new Float32Array(l.line),l.points=new Float32Array(l.points)),_(this,ji).push({line:a,points:_(this,La)}),_(this,Wu).set(a,0),te(this,Ll,0),this.toSVGPath(),null}getLastElement(){return _(this,ji).at(-1)}setLastElement(e){return _(this,ji)?(_(this,ji).push(e),te(this,wi,e.line),te(this,La,e.points),te(this,Ll,0),{path:{d:this.toSVGPath()}}):_(this,Cy).setLastElement(e)}removeLastElement(){if(!_(this,ji))return _(this,Cy).removeLastElement();_(this,ji).pop(),te(this,Vi,"");for(let e=0,r=_(this,ji).length;e<r;e++){const{line:n,points:s}=_(this,ji)[e];te(this,wi,n),te(this,La,s),te(this,Ll,0),this.toSVGPath()}return{path:{d:_(this,Vi)}}}toSVGPath(){const e=vt.svgRound(_(this,wi)[4]),r=vt.svgRound(_(this,wi)[5]);if(_(this,La).length===2)return te(this,Vi,`${_(this,Vi)} M ${e} ${r} Z`),_(this,Vi);if(_(this,La).length<=6){const s=_(this,Vi).lastIndexOf("M");te(this,Vi,`${_(this,Vi).slice(0,s)} M ${e} ${r}`),te(this,Ll,6)}if(_(this,La).length===4){const s=vt.svgRound(_(this,wi)[10]),i=vt.svgRound(_(this,wi)[11]);return te(this,Vi,`${_(this,Vi)} L ${s} ${i}`),te(this,Ll,12),_(this,Vi)}const n=[];_(this,Ll)===0&&(n.push(`M ${e} ${r}`),te(this,Ll,6));for(let s=_(this,Ll),i=_(this,wi).length;s<i;s+=6){const[a,l,c,u,d,h]=_(this,wi).slice(s,s+6).map(vt.svgRound);n.push(`C${a} ${l} ${c} ${u} ${d} ${h}`)}return te(this,Vi,_(this,Vi)+n.join(" ")),te(this,Ll,_(this,wi).length),_(this,Vi)}getOutlines(e,r,n,s){const i=_(this,ji).at(-1);return i.line=new Float32Array(i.line),i.points=new Float32Array(i.points),_(this,Cy).build(_(this,ji),e,r,n,_(this,ky),_(this,zw),s),te(this,Wu,null),te(this,wi,null),te(this,ji,null),te(this,Vi,null),_(this,Cy)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Wu=new WeakMap,wi=new WeakMap,ji=new WeakMap,ky=new WeakMap,zw=new WeakMap,La=new WeakMap,Vi=new WeakMap,Ll=new WeakMap,Cy=new WeakMap,Ey=new WeakMap,Ay=new WeakMap,Uw=new WeakSet,TP=function(e,r){return vt._normalizePoint(e,r,_(this,Ey),_(this,Ay),_(this,ky))};var $a,vE,bE,Go,Vu,qu,Hw,Ww,Ty,Qi,Ud,mNe,gNe,xNe;class fA extends vt{constructor(){super(...arguments);le(this,Qi);le(this,$a);le(this,vE,0);le(this,bE);le(this,Go);le(this,Vu);le(this,qu);le(this,Hw);le(this,Ww);le(this,Ty)}build(r,n,s,i,a,l,c){te(this,Vu,n),te(this,qu,s),te(this,Hw,i),te(this,Ww,a),te(this,Ty,l),te(this,bE,c??0),te(this,Go,r),de(this,Qi,gNe).call(this)}get thickness(){return _(this,Ty)}setLastElement(r){return _(this,Go).push(r),{path:{d:this.toSVGPath()}}}removeLastElement(){return _(this,Go).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const r=[];for(const{line:n}of _(this,Go)){if(r.push(`M${vt.svgRound(n[4])} ${vt.svgRound(n[5])}`),n.length===6){r.push("Z");continue}if(n.length===12&&isNaN(n[6])){r.push(`L${vt.svgRound(n[10])} ${vt.svgRound(n[11])}`);continue}for(let s=6,i=n.length;s<i;s+=6){const[a,l,c,u,d,h]=n.subarray(s,s+6).map(vt.svgRound);r.push(`C${a} ${l} ${c} ${u} ${d} ${h}`)}}return r.join("")}serialize([r,n,s,i],a){const l=[],c=[],[u,d,h,f]=de(this,Qi,mNe).call(this);let p,m,g,y,x,v,b,w,j;switch(_(this,Ww)){case 0:j=vt._rescale,p=r,m=n+i,g=s,y=-i,x=r+u*s,v=n+(1-d-f)*i,b=r+(u+h)*s,w=n+(1-d)*i;break;case 90:j=vt._rescaleAndSwap,p=r,m=n,g=s,y=i,x=r+d*s,v=n+u*i,b=r+(d+f)*s,w=n+(u+h)*i;break;case 180:j=vt._rescale,p=r+s,m=n,g=-s,y=i,x=r+(1-u-h)*s,v=n+d*i,b=r+(1-u)*s,w=n+(d+f)*i;break;case 270:j=vt._rescaleAndSwap,p=r+s,m=n+i,g=-s,y=-i,x=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:N,points:C}of _(this,Go))l.push(j(N,p,m,g,y,a?new Array(N.length):null)),c.push(j(C,p,m,g,y,a?new Array(C.length):null));return{lines:l,points:c,rect:[x,v,b,w]}}static deserialize(r,n,s,i,a,{paths:{lines:l,points:c},rotation:u,thickness:d}){const h=[];let f,p,m,g,y;switch(u){case 0:y=vt._rescale,f=-r/s,p=n/i+1,m=1/s,g=-1/i;break;case 90:y=vt._rescaleAndSwap,f=-n/i,p=-r/s,m=1/i,g=1/s;break;case 180:y=vt._rescale,f=r/s+1,p=-n/i,m=-1/s,g=1/i;break;case 270:y=vt._rescaleAndSwap,f=n/i+1,p=r/s+1,m=-1/i,g=-1/s;break}if(!l){l=[];for(const v of c){const b=v.length;if(b===2){l.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]));continue}if(b===4){l.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));l.push(w);let[j,N,C,A]=v.subarray(0,4);w.set([NaN,NaN,NaN,NaN,j,N],0);for(let E=4;E<b;E+=2){const O=v[E],$=v[E+1];w.set(vt.createBezierPoints(j,N,C,A,O,$),(E-2)*3),[j,N,C,A]=[C,A,O,$]}}}for(let v=0,b=l.length;v<b;v++)h.push({line:y(l[v].map(w=>w??NaN),f,p,m,g),points:y(c[v].map(w=>w??NaN),f,p,m,g)});const x=new this.prototype.constructor;return x.build(h,s,i,1,u,d,a),x}get box(){return _(this,$a)}updateProperty(r,n){return r==="stroke-width"?de(this,Qi,xNe).call(this,n):null}updateParentDimensions([r,n],s){const[i,a]=de(this,Qi,Ud).call(this);te(this,Vu,r),te(this,qu,n),te(this,Hw,s);const[l,c]=de(this,Qi,Ud).call(this),u=l-i,d=c-a,h=_(this,$a);return h[0]-=u,h[1]-=d,h[2]+=2*u,h[3]+=2*d,h}updateRotation(r){return te(this,vE,r),{path:{transform:this.rotationTransform}}}get viewBox(){return _(this,$a).map(vt.svgRound).join(" ")}get defaultProperties(){const[r,n]=_(this,$a);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${vt.svgRound(r)} ${vt.svgRound(n)}`}}}get rotationTransform(){const[,,r,n]=_(this,$a);let s=0,i=0,a=0,l=0,c=0,u=0;switch(_(this,vE)){case 90:i=n/r,a=-r/n,c=r;break;case 180:s=-1,l=-1,c=r,u=n;break;case 270:i=-n/r,a=r/n,u=n;break;default:return""}return`matrix(${s} ${i} ${a} ${l} ${vt.svgRound(c)} ${vt.svgRound(u)})`}getPathResizingSVGProperties([r,n,s,i]){const[a,l]=de(this,Qi,Ud).call(this),[c,u,d,h]=_(this,$a);if(Math.abs(d-a)<=vt.PRECISION||Math.abs(h-l)<=vt.PRECISION){const y=r+s/2-(c+d/2),x=n+i/2-(u+h/2);return{path:{"transform-origin":`${vt.svgRound(r)} ${vt.svgRound(n)}`,transform:`${this.rotationTransform} translate(${y} ${x})`}}}const f=(s-2*a)/(d-2*a),p=(i-2*l)/(h-2*l),m=d/s,g=h/i;return{path:{"transform-origin":`${vt.svgRound(c)} ${vt.svgRound(u)}`,transform:`${this.rotationTransform} scale(${m} ${g}) translate(${vt.svgRound(a)} ${vt.svgRound(l)}) scale(${f} ${p}) translate(${vt.svgRound(-a)} ${vt.svgRound(-l)})`}}}getPathResizedSVGProperties([r,n,s,i]){const[a,l]=de(this,Qi,Ud).call(this),c=_(this,$a),[u,d,h,f]=c;if(c[0]=r,c[1]=n,c[2]=s,c[3]=i,Math.abs(h-a)<=vt.PRECISION||Math.abs(f-l)<=vt.PRECISION){const x=r+s/2-(u+h/2),v=n+i/2-(d+f/2);for(const{line:b,points:w}of _(this,Go))vt._translate(b,x,v,b),vt._translate(w,x,v,w);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${vt.svgRound(r)} ${vt.svgRound(n)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const p=(s-2*a)/(h-2*a),m=(i-2*l)/(f-2*l),g=-p*(u+a)+r+a,y=-m*(d+l)+n+l;if(p!==1||m!==1||g!==0||y!==0)for(const{line:x,points:v}of _(this,Go))vt._rescale(x,g,y,p,m,x),vt._rescale(v,g,y,p,m,v);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${vt.svgRound(r)} ${vt.svgRound(n)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([r,n],s){const[i,a]=s,l=_(this,$a),c=r-l[0],u=n-l[1];if(_(this,Vu)===i&&_(this,qu)===a)for(const{line:d,points:h}of _(this,Go))vt._translate(d,c,u,d),vt._translate(h,c,u,h);else{const d=_(this,Vu)/i,h=_(this,qu)/a;te(this,Vu,i),te(this,qu,a);for(const{line:f,points:p}of _(this,Go))vt._rescale(f,c,u,d,h,f),vt._rescale(p,c,u,d,h,p);l[2]*=d,l[3]*=h}return l[0]=r,l[1]=n,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${vt.svgRound(r)} ${vt.svgRound(n)}`}}}get defaultSVGProperties(){const r=_(this,$a);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${vt.svgRound(r[0])} ${vt.svgRound(r[1])}`,transform:this.rotationTransform||null},bbox:r}}}$a=new WeakMap,vE=new WeakMap,bE=new WeakMap,Go=new WeakMap,Vu=new WeakMap,qu=new WeakMap,Hw=new WeakMap,Ww=new WeakMap,Ty=new WeakMap,Qi=new WeakSet,Ud=function(r=_(this,Ty)){const n=_(this,bE)+r/2*_(this,Hw);return _(this,Ww)%180===0?[n/_(this,Vu),n/_(this,qu)]:[n/_(this,qu),n/_(this,Vu)]},mNe=function(){const[r,n,s,i]=_(this,$a),[a,l]=de(this,Qi,Ud).call(this,0);return[r+a,n+l,s-2*a,i-2*l]},gNe=function(){const r=te(this,$a,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:i}of _(this,Go)){if(i.length<=12){for(let c=4,u=i.length;c<u;c+=6)Rt.pointBoundingBox(i[c],i[c+1],r);continue}let a=i[4],l=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);Rt.bezierBoundingBox(a,l,d,h,f,p,m,g,r),a=m,l=g}}const[n,s]=de(this,Qi,Ud).call(this);r[0]=za(r[0]-n,0,1),r[1]=za(r[1]-s,0,1),r[2]=za(r[2]+n,0,1),r[3]=za(r[3]+s,0,1),r[2]-=r[0],r[3]-=r[1]},xNe=function(r){const[n,s]=de(this,Qi,Ud).call(this);te(this,Ty,r);const[i,a]=de(this,Qi,Ud).call(this),[l,c]=[i-n,a-s],u=_(this,$a);return u[0]-=l,u[1]-=c,u[2]+=2*l,u[3]+=2*c,u};class GL extends fNe{constructor(e){super(),this._viewParameters=e,super.updateProperties({fill:"none",stroke:Pn._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 GL(this._viewParameters);return e.updateAll(this),e}}var wM,yNe;const n0=class n0 extends oO{constructor(r){super({...r,name:"inkEditor"});le(this,wM);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(r,n){Pn.initialize(r,n),this._defaultDrawingOptions=new GL(n.viewParameters)}static getDefaultDrawingOptions(r){const n=this._defaultDrawingOptions.clone();return n.updateProperties(r),n}static get supportMultipleDrawings(){return!0}static get typesMap(){return gr(this,"typesMap",new Map([[Ir.INK_THICKNESS,"stroke-width"],[Ir.INK_COLOR,"stroke"],[Ir.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(r,n,s,i,a){return new wAt(r,n,s,i,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(r,n,s,i,a,l){return fA.deserialize(r,n,s,i,a,l)}static async deserialize(r,n,s){let i=null;if(r instanceof bG){const{data:{inkLists:l,rect:c,rotation:u,id:d,color:h,opacity:f,borderStyle:{rawWidth:p},popupRef:m,contentsObj:g},parent:{page:{pageNumber:y}}}=r;i=r={annotationType:Qt.INK,color:Array.from(h),thickness:p,opacity:f,paths:{points:l},boxes:null,pageIndex:y-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 nO(this)),[["colorPicker",this._colorPicker]]}get colorType(){return Ir.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=n0.getDefaultDrawingOptions({stroke:Rt.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":l,"stroke-width":c}}=this,u={annotationType:Qt.INK,color:Pn._colorManager.convert(a),opacity:l,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&&!de(this,wM,yNe).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}};wM=new WeakSet,yNe=function(r){const{color:n,thickness:s,opacity:i,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||r.color.some((l,c)=>l!==n[c])||r.thickness!==s||r.opacity!==i||r.pageIndex!==a},Ge(n0,"_type","ink"),Ge(n0,"_editorType",Qt.INK),Ge(n0,"_defaultDrawingOptions",null);let AH=n0;class TH extends fA{toSVGPath(){let e=super.toSVGPath();return e.endsWith("Z")||(e+="Z"),e}}const FT=8,xS=3;var Py,Zr,PH,Mc,vNe,bNe,IH,PP,wNe,jNe,SNe,RH,OH,_Ne;class Oh{static extractContoursFromText(e,{fontFamily:r,fontStyle:n,fontWeight:s},i,a,l,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:y,fontBoundingBoxAscent:x,fontBoundingBoxDescent:v,width:b}=d.measureText(e),w=1.5,j=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||0,b)*w),N=Math.ceil(Math.max(Math.abs(g)+Math.abs(y)||h,Math.abs(x)+Math.abs(v)||h)*w);u=new OffscreenCanvas(j,N),d=u.getContext("2d",{alpha:!0,willReadFrequently:!0}),d.font=f,d.filter="grayscale(1)",d.fillStyle="white",d.fillRect(0,0,j,N),d.fillStyle="black",d.fillText(e,j*(w-1)/2,N*(3-w)/2);const C=de(this,Zr,RH).call(this,d.getImageData(0,0,j,N).data),A=de(this,Zr,SNe).call(this,C),E=de(this,Zr,OH).call(this,A),O=de(this,Zr,IH).call(this,C,j,N,E);return this.processDrawnLines({lines:{curves:O,width:j,height:N},pageWidth:i,pageHeight:a,rotation:l,innerMargin:c,mustSmooth:!0,areContours:!0})}static process(e,r,n,s,i){const[a,l,c]=de(this,Zr,_Ne).call(this,e),[u,d]=de(this,Zr,jNe).call(this,a,l,c,Math.hypot(l,c)*_(this,Py).sigmaSFactor,_(this,Py).sigmaR,_(this,Py).kernelSize),h=de(this,Zr,OH).call(this,d),f=de(this,Zr,IH).call(this,u,l,c,h);return this.processDrawnLines({lines:{curves:f,width:l,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:l}){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,y=[];for(const{points:v}of c){const b=a?de(this,Zr,wNe).call(this,v):v;if(!b)continue;y.push(b);const w=b.length,j=new Float32Array(w),N=new Float32Array(3*(w===2?2:w-2));if(f.push({line:N,points:j}),w===2){j[0]=b[0]*m,j[1]=b[1]*g,N.set([NaN,NaN,NaN,NaN,j[0],j[1]],0);continue}let[C,A,E,O]=b;C*=m,A*=g,E*=m,O*=g,j.set([C,A,E,O],0),N.set([NaN,NaN,NaN,NaN,C,A],0);for(let $=4;$<w;$+=2){const T=j[$]=b[$]*m,M=j[$+1]=b[$+1]*g;N.set(vt.createBezierPoints(C,A,E,O,T,M),($-2)*3),[C,A,E,O]=[E,O,T,M]}}if(f.length===0)return null;const x=l?new TH:new fA;return x.build(f,r,n,1,s,l?0:h,i),{outline:x,newCurves:y,areContours:l,thickness:h,width:u,height:d}}static async compressSignature({outlines:e,areContours:r,thickness:n,width:s,height:i}){let a=1/0,l=-1/0,c=0;for(const b of e){c+=b.length;for(let w=2,j=b.length;w<j;w++){const N=b[w]-b[w-2];a=Math.min(a,N),l=Math.max(l,N)}}let u;a>=-128&&l<=127?u=Int8Array:a>=-32768&&l<=32767?u=Int16Array:u=Int32Array;const d=e.length,h=FT+xS*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 y=u.prototype.constructor;for(const b of e){const w=new y(b.length-2);for(let j=2,N=b.length;j<N;j++)w[j-2]=b[j]-b[j-2];g.write(w)}g.close();const x=await new Response(m.readable).arrayBuffer(),v=new Uint8Array(x);return kSe(v)}static async decompressSignature(e){try{const r=VCt(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,l=0;for await(const b of n)a||(a=new Uint8Array(new Uint32Array(b.buffer,0,4)[0])),a.set(b,l),l+=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],y=[],x=(FT+xS*m)*Uint32Array.BYTES_PER_ELEMENT;let v;switch(g){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(a.buffer,x);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(a.buffer,x);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(a.buffer,x);break}l=0;for(let b=0;b<m;b++){const w=c[xS*b+FT],j=new Float32Array(w+2);y.push(j);for(let N=0;N<xS-1;N++)j[N]=c[xS*b+FT+N+1];for(let N=0;N<w;N++)j[N+2]=j[N]+v[l++]}return{areContours:f,thickness:p,outlines:y,width:d,height:h}}catch(r){return Zt(`decompressSignature: ${r}`),null}}}Py=new WeakMap,Zr=new WeakSet,PH=function(e,r,n,s){return n-=e,s-=r,n===0?s>0?0:4:n===1?s+6:2-s},Mc=new WeakMap,vNe=function(e,r,n,s,i,a,l){const c=de(this,Zr,PH).call(this,n,s,i,a);for(let u=0;u<8;u++){const d=(-u+c-l+16)%8,h=_(this,Mc)[2*d],f=_(this,Mc)[2*d+1];if(e[(n+h)*r+(s+f)]!==0)return d}return-1},bNe=function(e,r,n,s,i,a,l){const c=de(this,Zr,PH).call(this,n,s,i,a);for(let u=0;u<8;u++){const d=(u+c+l+16)%8,h=_(this,Mc)[2*d],f=_(this,Mc)[2*d+1];if(e[(n+h)*r+(s+f)]!==0)return d}return-1},IH=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 l=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)l+=1,g-=1;else if(p>=1&&a[f+1]===0)l+=1,g+=1,p>1&&(c=p);else{p!==1&&(c=Math.abs(p));continue}const y=[h,d],x=g===h+1,v={isHole:x,points:y,id:l,parent:0};u.push(v);let b;for(const $ of u)if($.id===c){b=$;break}b?b.isHole?v.parent=x?b.parent:c:v.parent=x?c:b.parent:v.parent=x?c:0;const w=de(this,Zr,vNe).call(this,a,r,d,h,m,g,0);if(w===-1){a[f]=-l,a[f]!==1&&(c=Math.abs(a[f]));continue}let j=_(this,Mc)[2*w],N=_(this,Mc)[2*w+1];const C=d+j,A=h+N;m=C,g=A;let E=d,O=h;for(;;){const $=de(this,Zr,bNe).call(this,a,r,E,O,m,g,1);j=_(this,Mc)[2*$],N=_(this,Mc)[2*$+1];const T=E+j,M=O+N;y.push(M,T);const k=E*r+O;if(a[k+1]===0?a[k]=-l:a[k]===1&&(a[k]=l),T===d&&M===h&&E===C&&O===A){a[f]!==1&&(c=Math.abs(a[f]));break}else m=E,g=O,E=T,O=M}}}return u},PP=function(e,r,n,s){if(n-r<=4){for(let C=r;C<n-2;C+=2)s.push(e[C],e[C+1]);return}const i=e[r],a=e[r+1],l=e[n-4]-i,c=e[n-3]-a,u=Math.hypot(l,c),d=l/u,h=c/u,f=d*a-h*i,p=c/l,m=1/u,g=Math.atan(p),y=Math.cos(g),x=Math.sin(g),v=m*(Math.abs(y)+Math.abs(x)),b=m*(1-v+v**2),w=Math.max(Math.atan(Math.abs(x+y)*b),Math.atan(Math.abs(x-y)*b));let j=0,N=r;for(let C=r+2;C<n-2;C+=2){const A=Math.abs(f-d*e[C+1]+h*e[C]);A>j&&(N=C,j=A)}j>(u*w)**2?(de(this,Zr,PP).call(this,e,r,N+2,s),de(this,Zr,PP).call(this,e,N,n,s)):s.push(i,a)},wNe=function(e){const r=[],n=e.length;return de(this,Zr,PP).call(this,e,0,n,r),r.push(e[n-2],e[n-1]),r.length<=4?null:r},jNe=function(e,r,n,s,i,a){const l=new Float32Array(a**2),c=-2*s**2,u=a>>1;for(let g=0;g<a;g++){const y=(g-u)**2;for(let x=0;x<a;x++)l[g*a+x]=Math.exp((y+(x-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 y=0;y<r;y++){const x=g*r+y,v=e[x];let b=0,w=0;for(let N=0;N<a;N++){const C=g+N-u;if(!(C<0||C>=n))for(let A=0;A<a;A++){const E=y+A-u;if(E<0||E>=r)continue;const O=e[C*r+E],$=l[N*a+A]*d[Math.abs(O-v)];b+=O*$,w+=$}}const j=p[x]=Math.round(b/w);m[j]++}return[p,m]},SNe=function(e){const r=new Uint32Array(256);for(const n of e)r[n]++;return r},RH=function(e){const r=e.length,n=new Uint8ClampedArray(r>>2);let s=-1/0,i=1/0;for(let l=0,c=n.length;l<c;l++){const u=n[l]=e[l<<2];s=Math.max(s,u),i=Math.min(i,u)}const a=255/(s-i);for(let l=0,c=n.length;l<c;l++)n[l]=(n[l]-i)*a;return n},OH=function(e){let r,n=-1/0,s=-1/0;const i=e.findIndex(c=>c!==0);let a=i,l=i;for(r=i;r<256;r++){const c=e[r];c>n&&(r-a>s&&(s=r-a,l=r-1),n=c,a=r)}for(r=l-1;r>=0&&!(e[r]>e[r+1]);r--);return r},_Ne=function(e){const r=e,{width:n,height:s}=e,{maxDim:i}=_(this,Py);let a=n,l=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 x=0;x<m;x++){a=Math.ceil(f/2),l=Math.ceil(p/2);const v=new OffscreenCanvas(a,l);v.getContext("2d").drawImage(e,0,0,f,p,0,0,a,l),f=a,p=l,e!==r&&e.close(),e=v.transferToImageBitmap()}const y=Math.min(i/a,i/l);a=Math.round(a*y),l=Math.round(l*y)}const u=new OffscreenCanvas(a,l).getContext("2d",{willReadFrequently:!0});u.fillStyle="white",u.fillRect(0,0,a,l),u.filter="grayscale(1)",u.drawImage(e,0,0,e.width,e.height,0,0,a,l);const d=u.getImageData(0,0,a,l).data;return[de(this,Zr,RH).call(this,d),a,l]},le(Oh,Zr),le(Oh,Py,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),le(Oh,Mc,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class wG extends fNe{constructor(){super(),super.updateProperties({fill:Pn._defaultLineColor,"stroke-width":0})}clone(){const e=new wG;return e.updateAll(this),e}}class jG extends GL{constructor(e){super(e),super.updateProperties({stroke:Pn._defaultLineColor,"stroke-width":1})}clone(){const e=new jG(this._viewParameters);return e.updateAll(this),e}}var am,Gu,om,Iy;const Ro=class Ro extends oO{constructor(r){super({...r,mustBeCommitted:!0,name:"signatureEditor"});le(this,am,!1);le(this,Gu,null);le(this,om,null);le(this,Iy,null);this._willKeepAspectRatio=!0,te(this,om,r.signatureData||null),te(this,Gu,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(r,n){Pn.initialize(r,n),this._defaultDrawingOptions=new wG,this._defaultDrawnSignatureOptions=new jG(n.viewParameters)}static getDefaultDrawingOptions(r){const n=this._defaultDrawingOptions.clone();return n.updateProperties(r),n}static get supportMultipleDrawings(){return!1}static get typesMap(){return gr(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!_(this,Gu)}}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,om)){const{lines:i,mustSmooth:a,areContours:l,description:c,uuid:u,heightInPage:d}=_(this,om),{rawDims:{pageWidth:h,pageHeight:f},rotation:p}=this.parent.viewport,m=Oh.processDrawnLines({lines:i,pageWidth:h,pageHeight:f,rotation:p,innerMargin:Ro._INNER_MARGIN,mustSmooth:a,areContours:l});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,Gu)||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(r,n)),this.div}setUuid(r){te(this,Iy,r),this.addEditToolbar()}getUuid(){return _(this,Iy)}get description(){return _(this,Gu)}set description(r){te(this,Gu,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,om),l=Math.max(i,a),c=Oh.processDrawnLines({lines:{curves:r.map(u=>({points:u})),thickness:s,width:i,height:a},pageWidth:l,pageHeight:l,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:l}=this,{outline:c}=te(this,om,r);te(this,am,c instanceof TH),this.description=s;let u;_(this,am)?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=l,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 Oh.process(r,n,s,i,Ro._INNER_MARGIN)}getFromText(r,n){const{rawDims:{pageWidth:s,pageHeight:i},rotation:a}=this.parent.viewport;return Oh.extractContoursFromText(r,n,s,i,a,Ro._INNER_MARGIN)}getDrawnSignature(r){const{rawDims:{pageWidth:n,pageHeight:s},rotation:i}=this.parent.viewport;return Oh.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,l={annotationType:Qt.SIGNATURE,isSignature:!0,areContours:_(this,am),color:[0,0,0],thickness:_(this,am)?0:a,pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(l),r?(l.paths={lines:n,points:s},l.uuid=_(this,Iy),l.isCopy=!0):l.lines=n,_(this,Gu)&&(l.accessibilityData={type:"Figure",alt:_(this,Gu)}),l}static deserializeDraw(r,n,s,i,a,l){return l.areContours?TH.deserialize(r,n,s,i,a,l):fA.deserialize(r,n,s,i,a,l)}static async deserialize(r,n,s){var a;const i=await super.deserialize(r,n,s);return te(i,am,r.areContours),i.description=((a=r.accessibilityData)==null?void 0:a.alt)||"",te(i,Iy,r.uuid),i}};am=new WeakMap,Gu=new WeakMap,om=new WeakMap,Iy=new WeakMap,Ge(Ro,"_type","signature"),Ge(Ro,"_editorType",Qt.SIGNATURE),Ge(Ro,"_defaultDrawingOptions",null);let MH=Ro;var Wn,Si,lm,Ah,cm,Vw,Th,Ry,Ku,Ko,qw,Hr,c_,u_,IP,RP,OP,LH,MP,NNe;class DH extends Pn{constructor(r){super({...r,name:"stampEditor"});le(this,Hr);le(this,Wn,null);le(this,Si,null);le(this,lm,null);le(this,Ah,null);le(this,cm,null);le(this,Vw,"");le(this,Th,null);le(this,Ry,!1);le(this,Ku,null);le(this,Ko,!1);le(this,qw,!1);te(this,Ah,r.bitmapUrl),te(this,cm,r.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(r,n){Pn.initialize(r,n)}static isHandlingMimeForPasting(r){return AU.includes(r)}static paste(r,n){n.pasteEditor({mode:Qt.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:l}=r||this.copyCanvas(null,null,!0).imageData,c=await s.guess({name:"altText",request:{data:i,width:a,height:l,channels:i.length/(a*l)}});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,Si)&&(te(this,Wn,null),this._uiManager.imageManager.deleteId(_(this,Si)),(r=_(this,Th))==null||r.remove(),te(this,Th,null),_(this,Ku)&&(clearTimeout(_(this,Ku)),te(this,Ku,null))),super.remove()}rebuild(){if(!this.parent){_(this,Si)&&de(this,Hr,IP).call(this);return}super.rebuild(),this.div!==null&&(_(this,Si)&&_(this,Th)===null&&de(this,Hr,IP).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(r){this._isDraggable=!0,r&&this.div.focus()}isEmpty(){return!(_(this,lm)||_(this,Wn)||_(this,Ah)||_(this,cm)||_(this,Si)||_(this,Ry))}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,Ry)||(_(this,Wn)?de(this,Hr,RP).call(this):de(this,Hr,IP).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,Si,s),i&&te(this,Wn,i),te(this,Ry,!1),de(this,Hr,RP).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;_(this,Ku)!==null&&clearTimeout(_(this,Ku)),te(this,Ku,setTimeout(()=>{te(this,Ku,null),de(this,Hr,LH).call(this)},200))}copyCanvas(r,n,s=!1){var p;r||(r=224);const{width:i,height:a}=_(this,Wn),l=new md;let c=_(this,Wn),u=i,d=a,h=null;if(n){if(i>n||a>n){const A=Math.min(n/i,n/a);u=Math.floor(i*A),d=Math.floor(a*A)}h=document.createElement("canvas");const m=h.width=Math.ceil(u*l.sx),g=h.height=Math.ceil(d*l.sy);_(this,Ko)||(c=de(this,Hr,OP).call(this,m,g));const y=h.getContext("2d");y.filter=this._uiManager.hcmFilter;let x="white",v="#cfcfd8";this._uiManager.hcmFilter!=="none"?v="black":(p=window.matchMedia)!=null&&p.call(window,"(prefers-color-scheme: dark)").matches&&(x="#8f8f9d",v="#42414d");const b=15,w=b*l.sx,j=b*l.sy,N=new OffscreenCanvas(w*2,j*2),C=N.getContext("2d");C.fillStyle=x,C.fillRect(0,0,w*2,j*2),C.fillStyle=v,C.fillRect(0,0,w,j),C.fillRect(w,j,w,j),y.fillStyle=y.createPattern(N,"repeat"),y.fillRect(0,0,m,g),y.drawImage(c,0,0,c.width,c.height,0,0,m,g)}let f=null;if(s){let m,g;if(l.symmetric&&c.width<r&&c.height<r)m=c.width,g=c.height;else if(c=_(this,Wn),i>r||a>r){const v=Math.min(r/i,r/a);m=Math.floor(i*v),g=Math.floor(a*v),_(this,Ko)||(c=de(this,Hr,OP).call(this,m,g))}const x=new OffscreenCanvas(m,g).getContext("2d",{willReadFrequently:!0});x.drawImage(c,0,0,c.width,c.height,0,0,m,g),f={width:m,height:g,data:x.getImageData(0,0,m,g).data}}return{canvas:h,width:u,height:d,imageData:f}}static async deserialize(r,n,s){var y;let i=null,a=!1;if(r instanceof z_e){const{data:{rect:x,rotation:v,id:b,structParent:w,popupRef:j,contentsObj:N},container:C,parent:{page:{pageNumber:A}},canvas:E}=r;let O,$;E?(delete r.canvas,{id:O,bitmap:$}=s.imageManager.getFromCanvas(C.id,E),E.remove()):(a=!0,r._hasNoCanvas=!0);const T=((y=await n._structTree.getAriaAttributes(`${fG}${b}`))==null?void 0:y.get("aria-label"))||"";i=r={annotationType:Qt.STAMP,bitmapId:O,bitmap:$,pageIndex:A-1,rect:x.slice(0),rotation:v,annotationElementId:b,id:b,deleted:!1,accessibilityData:{decorative:!1,altText:T},isSvg:!1,structParent:w,popupRef:j,comment:(N==null?void 0:N.str)||null}}const l=await super.deserialize(r,n,s),{rect:c,bitmap:u,bitmapUrl:d,bitmapId:h,isSvg:f,accessibilityData:p}=r;a?(s.addMissingCanvas(r.id,l),te(l,Ry,!0)):h&&s.imageManager.isValidId(h)?(te(l,Si,h),u&&te(l,Wn,u)):te(l,Ah,d),te(l,Ko,f);const[m,g]=l.pageDimensions;return l.width=(c[2]-c[0])/m,l.height=(c[3]-c[1])/g,p&&(l.altTextData=p),l._initialData=i,r.comment&&l.setCommentData(r.comment),te(l,qw,!!i),l}serialize(r=!1,n=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s={annotationType:Qt.STAMP,bitmapId:_(this,Si),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:_(this,Ko),structTreeParentId:this._structTreeParentId};if(this.addComment(s),r)return s.bitmapUrl=de(this,Hr,MP).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=de(this,Hr,NNe).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 l=_(this,Ko)?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!n.stamps.has(_(this,Si)))n.stamps.set(_(this,Si),{area:l,serialized:s}),s.bitmap=de(this,Hr,MP).call(this,!1);else if(_(this,Ko)){const c=n.stamps.get(_(this,Si));l>c.area&&(c.area=l,c.serialized.bitmap.close(),c.serialized.bitmap=de(this,Hr,MP).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}}Wn=new WeakMap,Si=new WeakMap,lm=new WeakMap,Ah=new WeakMap,cm=new WeakMap,Vw=new WeakMap,Th=new WeakMap,Ry=new WeakMap,Ku=new WeakMap,Ko=new WeakMap,qw=new WeakMap,Hr=new WeakSet,c_=function(r,n=!1){if(!r){this.remove();return}te(this,Wn,r.bitmap),n||(te(this,Si,r.id),te(this,Ko,r.isSvg)),r.file&&te(this,Vw,r.file.name),de(this,Hr,RP).call(this)},u_=function(){if(te(this,lm,null),this._uiManager.enableWaiting(!1),!!_(this,Th)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_(this,Wn)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&_(this,Wn)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},IP=function(){if(_(this,Si)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(_(this,Si)).then(s=>de(this,Hr,c_).call(this,s,!0)).finally(()=>de(this,Hr,u_).call(this));return}if(_(this,Ah)){const s=_(this,Ah);te(this,Ah,null),this._uiManager.enableWaiting(!0),te(this,lm,this._uiManager.imageManager.getFromUrl(s).then(i=>de(this,Hr,c_).call(this,i)).finally(()=>de(this,Hr,u_).call(this)));return}if(_(this,cm)){const s=_(this,cm);te(this,cm,null),this._uiManager.enableWaiting(!0),te(this,lm,this._uiManager.imageManager.getFromFile(s).then(i=>de(this,Hr,c_).call(this,i)).finally(()=>de(this,Hr,u_).call(this)));return}const r=document.createElement("input");r.type="file",r.accept=AU.join(",");const n=this._uiManager._signal;te(this,lm,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}}),de(this,Hr,c_).call(this,i)}s()},{signal:n}),r.addEventListener("cancel",()=>{this.remove(),s()},{signal:n})}).finally(()=>de(this,Hr,u_).call(this))),r.click()},RP=function(){var h;const{div:r}=this;let{width:n,height:s}=_(this,Wn);const[i,a]=this.pageDimensions,l=.75;if(this.width)n=this.width*i,s=this.height*a;else if(n>l*i||s>l*a){const f=Math.min(l*i/n,l*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,Th,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),de(this,Hr,LH).call(this),_(this,qw)||(this.parent.addUndoableEditor(this),te(this,qw,!0)),this._reportTelemetry({action:"inserted_image"}),_(this,Vw)&&this.div.setAttribute("aria-description",_(this,Vw)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},OP=function(r,n){const{width:s,height:i}=_(this,Wn);let a=s,l=i,c=_(this,Wn);for(;a>2*r||l>2*n;){const u=a,d=l;a>2*r&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),l>2*n&&(l=l>=16384?Math.floor(l/2)-1:Math.ceil(l/2));const h=new OffscreenCanvas(a,l);h.getContext("2d").drawImage(c,0,0,u,d,0,0,a,l),c=h.transferToImageBitmap()}return c},LH=function(){const[r,n]=this.parentDimensions,{width:s,height:i}=this,a=new md,l=Math.ceil(s*r*a.sx),c=Math.ceil(i*n*a.sy),u=_(this,Th);if(!u||u.width===l&&u.height===c)return;u.width=l,u.height=c;const d=_(this,Ko)?_(this,Wn):de(this,Hr,OP).call(this,l,c),h=u.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(d,0,0,d.width,d.height,0,0,l,c)},MP=function(r){if(r){if(_(this,Ko)){const i=this._uiManager.imageManager.getSvgUrl(_(this,Si));if(i)return i}const n=document.createElement("canvas");return{width:n.width,height:n.height}=_(this,Wn),n.getContext("2d").drawImage(_(this,Wn),0,0),n.toDataURL()}if(_(this,Ko)){const[n,s]=this.pageDimensions,i=Math.round(this.width*n*Km.PDF_TO_CSS_UNITS),a=Math.round(this.height*s*Km.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(i,a);return l.getContext("2d").drawImage(_(this,Wn),0,0,_(this,Wn).width,_(this,Wn).height,0,0,i,a),l.transferToImageBitmap()}return structuredClone(_(this,Wn))},NNe=function(r){var l;const{pageIndex:n,accessibilityData:{altText:s}}=this._initialData,i=r.pageIndex===n,a=(((l=r.accessibilityData)==null?void 0:l.alt)||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&a,isSameAltText:a}},Ge(DH,"_type","stamp"),Ge(DH,"_editorType",Qt.STAMP);var Oy,Gw,Yu,um,Ph,Yo,dm,Kw,My,Dc,Ih,_i,Rh,hm,Yw,Et,fm,qn,kNe,vu,FH,BH,DP;const Sc=class Sc{constructor({uiManager:e,pageIndex:r,div:n,structTreeLayer:s,accessibilityManager:i,annotationLayer:a,drawLayer:l,textLayer:c,viewport:u,l10n:d}){le(this,qn);le(this,Oy);le(this,Gw,!1);le(this,Yu,null);le(this,um,null);le(this,Ph,null);le(this,Yo,new Map);le(this,dm,!1);le(this,Kw,!1);le(this,My,!1);le(this,Dc,null);le(this,Ih,null);le(this,_i,null);le(this,Rh,null);le(this,hm,null);le(this,Yw,-1);le(this,Et);const h=[..._(Sc,fm).values()];if(!Sc._initialized){Sc._initialized=!0;for(const f of h)f.initialize(d,e)}e.registerEditorTypes(h),te(this,Et,e),this.pageIndex=r,this.div=n,te(this,Oy,i),te(this,Yu,a),this.viewport=u,te(this,_i,c),this.drawLayer=l,this._structTree=s,_(this,Et).addLayer(this)}get isEmpty(){return _(this,Yo).size===0}get isInvisible(){return this.isEmpty&&_(this,Et).getMode()===Qt.NONE}updateToolbar(e){_(this,Et).updateToolbar(e)}updateMode(e=_(this,Et).getMode()){switch(de(this,qn,DP).call(this),e){case Qt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Qt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Qt.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 _(Sc,fm).values())r.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){var r;return e===((r=_(this,_i))==null?void 0:r.div)}setEditingState(e){_(this,Et).setEditingState(e)}addCommands(e){_(this,Et).addCommands(e)}cleanUndoStack(e){_(this,Et).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,Yu))==null||r.div.classList.toggle("disabled",!e)}async enable(){var n;te(this,My,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),(n=_(this,hm))==null||n.abort(),te(this,hm,null);const e=new Set;for(const s of _(this,Yo).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(_(this,Et).removeChangedExistingAnnotation(s),e.add(s.annotationElementId));if(!_(this,Yu)){te(this,My,!1);return}const r=_(this,Yu).getEditableAnnotations();for(const s of r){if(s.hide(),_(this,Et).isDeletedAnnotationElement(s.data.id)||e.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}te(this,My,!1)}disable(){var s;if(te(this,Kw,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),_(this,_i)&&!_(this,hm)){te(this,hm,new AbortController);const i=_(this,Et).combinedSignal(_(this,hm));_(this,_i).div.addEventListener("pointerdown",a=>{const{clientX:c,clientY:u,timeStamp:d}=a,h=_(this,Yw);if(d-h>500){te(this,Yw,d);return}te(this,Yw,-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(`^${wSe}[0-9]+$`);for(const x of p)if(g.test(x.id)){m=x.id;break}if(!m)return;const y=_(this,Yo).get(m);(y==null?void 0:y.annotationElementId)===null&&(a.stopPropagation(),a.preventDefault(),y.dblclick())},{signal:i,capture:!0})}const e=new Map,r=new Map;for(const i of _(this,Yo).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,Yu)){const i=_(this,Yu).getEditableAnnotations();for(const a of i){const{id:l}=a.data;if(_(this,Et).isDeletedAnnotationElement(l)){a.updateEdited({deleted:!0});continue}let c=r.get(l);if(c){c.resetAnnotationElement(a),c.show(!1),a.show();continue}c=e.get(l),c&&(_(this,Et).addChangedExistingAnnotation(c),c.renderAnnotationElement(a)&&c.show(!1)),a.show()}}de(this,qn,DP).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const i of _(Sc,fm).values())n.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),te(this,Kw,!1)}getEditableAnnotation(e){var r;return((r=_(this,Yu))==null?void 0:r.getEditableAnnotation(e))||null}setActiveEditor(e){_(this,Et).getActive()!==e&&_(this,Et).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=_(this,_i))!=null&&e.div&&!_(this,Rh)){te(this,Rh,new AbortController);const r=_(this,Et).combinedSignal(_(this,Rh));_(this,_i).div.addEventListener("pointerdown",de(this,qn,kNe).bind(this),{signal:r}),_(this,_i).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=_(this,_i))!=null&&e.div&&_(this,Rh)&&(_(this,Rh).abort(),te(this,Rh,null),_(this,_i).div.classList.remove("highlighting"))}enableClick(){if(_(this,um))return;te(this,um,new AbortController);const e=_(this,Et).combinedSignal(_(this,um));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,um))==null||e.abort(),te(this,um,null)}attach(e){_(this,Yo).set(e.id,e);const{annotationElementId:r}=e;r&&_(this,Et).isDeletedAnnotationElement(r)&&_(this,Et).removeDeletedAnnotationElement(e)}detach(e){var r;_(this,Yo).delete(e.id),(r=_(this,Oy))==null||r.removePointerInTextLayer(e.contentDiv),!_(this,Kw)&&e.annotationElementId&&_(this,Et).addDeletedAnnotationElement(e)}remove(e){this.detach(e),_(this,Et).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){var r;e.parent!==this&&(e.parent&&e.annotationElementId&&(_(this,Et).addDeletedAnnotationElement(e.annotationElementId),Pn.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,Et).addEditor(e),this.attach(e),!e.isAttachedToDOM){const r=e.render();this.div.append(r),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!_(this,My)),_(this,Et).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var n;if(!e.isAttachedToDOM)return;const{activeElement:r}=document;e.div.contains(r)&&!_(this,Ph)&&(e._focusEventsAllowed=!1,te(this,Ph,setTimeout(()=>{te(this,Ph,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:_(this,Et)._signal}),r.focus())},0))),e._structTreeParentId=(n=_(this,Oy))==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,Et).getId()}combinedSignal(e){return _(this,Et).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=_(this,qn,vu))==null?void 0:e.canCreateNewEmptyEditor()}async pasteEditor(e,r){this.updateToolbar(e),await _(this,Et).updateMode(e.mode);const{offsetX:n,offsetY:s}=de(this,qn,BH).call(this),i=this.getNextId(),a=de(this,qn,FH).call(this,{parent:this,id:i,x:n,y:s,uiManager:_(this,Et),isCentered:!0,...r});a&&this.add(a)}async deserialize(e){var r;return await((r=_(Sc,fm).get(e.annotationType??e.annotationEditorType))==null?void 0:r.deserialize(e,this,_(this,Et)))||null}createAndAddNewEditor(e,r,n={}){const s=this.getNextId(),i=de(this,qn,FH).call(this,{parent:this,id:s,x:e.offsetX,y:e.offsetY,uiManager:_(this,Et),isCentered:r,...n});return i&&this.add(i),i}addNewEditor(e={}){this.createAndAddNewEditor(de(this,qn,BH).call(this),!0,e)}setSelected(e){_(this,Et).setSelected(e)}toggleSelected(e){_(this,Et).toggleSelected(e)}unselect(e){_(this,Et).unselect(e)}pointerup(e){var s;const{isMac:r}=oa.platform;if(e.button!==0||e.ctrlKey&&r||e.target!==this.div||!_(this,dm)||(te(this,dm,!1),(s=_(this,qn,vu))!=null&&s.isDrawer&&_(this,qn,vu).supportMultipleDrawings))return;if(!_(this,Gw)){te(this,Gw,!0);return}const n=_(this,Et).getMode();if(n===Qt.STAMP||n===Qt.SIGNATURE){_(this,Et).unselectAll();return}this.createAndAddNewEditor(e,!1)}pointerdown(e){var s;if(_(this,Et).getMode()===Qt.HIGHLIGHT&&this.enableTextSelection(),_(this,dm)){te(this,dm,!1);return}const{isMac:r}=oa.platform;if(e.button!==0||e.ctrlKey&&r||e.target!==this.div)return;if(te(this,dm,!0),(s=_(this,qn,vu))!=null&&s.isDrawer){this.startDrawingSession(e);return}const n=_(this,Et).getActive();te(this,Gw,!n||n.isEmpty())}startDrawingSession(e){if(this.div.focus({preventScroll:!0}),_(this,Dc)){_(this,qn,vu).startDrawing(this,_(this,Et),!1,e);return}_(this,Et).setCurrentDrawingSession(this),te(this,Dc,new AbortController);const r=_(this,Et).combinedSignal(_(this,Dc));this.div.addEventListener("blur",({relatedTarget:n})=>{n&&!this.div.contains(n)&&(te(this,Ih,null),this.commitOrRemove())},{signal:r}),_(this,qn,vu).startDrawing(this,_(this,Et),!1,e)}pause(e){if(e){const{activeElement:r}=document;this.div.contains(r)&&te(this,Ih,r);return}_(this,Ih)&&setTimeout(()=>{var r;(r=_(this,Ih))==null||r.focus(),te(this,Ih,null)},0)}endDrawingSession(e=!1){return _(this,Dc)?(_(this,Et).setCurrentDrawingSession(null),_(this,Dc).abort(),te(this,Dc,null),te(this,Ih,null),_(this,qn,vu).endDrawing(e)):null}findNewParent(e,r,n){const s=_(this,Et).findParent(r,n);return s===null||s===this?!1:(s.changeParent(e),!0)}commitOrRemove(){return _(this,Dc)?(this.endDrawingSession(),!0):!1}onScaleChanging(){_(this,Dc)&&_(this,qn,vu).onScaleChangingWhenDrawing(this)}destroy(){var e,r;this.commitOrRemove(),((e=_(this,Et).getActive())==null?void 0:e.parent)===this&&(_(this,Et).commitOrRemove(),_(this,Et).setActiveEditor(null)),_(this,Ph)&&(clearTimeout(_(this,Ph)),te(this,Ph,null));for(const n of _(this,Yo).values())(r=_(this,Oy))==null||r.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,_(this,Yo).clear(),_(this,Et).removeLayer(this)}render({viewport:e}){this.viewport=e,pv(this.div,e);for(const r of _(this,Et).getEditors(this.pageIndex))this.add(r),r.rebuild();this.updateMode()}update({viewport:e}){_(this,Et).commitOrRemove(),de(this,qn,DP).call(this);const r=this.viewport.rotation,n=e.rotation;if(this.viewport=e,pv(this.div,{rotation:n}),r!==n)for(const s of _(this,Yo).values())s.rotate(n)}get pageDimensions(){const{pageWidth:e,pageHeight:r}=this.viewport.rawDims;return[e,r]}get scale(){return _(this,Et).viewParameters.realScale}};Oy=new WeakMap,Gw=new WeakMap,Yu=new WeakMap,um=new WeakMap,Ph=new WeakMap,Yo=new WeakMap,dm=new WeakMap,Kw=new WeakMap,My=new WeakMap,Dc=new WeakMap,Ih=new WeakMap,_i=new WeakMap,Rh=new WeakMap,hm=new WeakMap,Yw=new WeakMap,Et=new WeakMap,fm=new WeakMap,qn=new WeakSet,kNe=function(e){_(this,Et).unselectAll();const{target:r}=e;if(r===_(this,_i).div||(r.getAttribute("role")==="img"||r.classList.contains("endOfContent"))&&_(this,_i).div.contains(r)){const{isMac:n}=oa.platform;if(e.button!==0||e.ctrlKey&&n)return;_(this,Et).showAllEditors("highlight",!0,!0),_(this,_i).div.classList.add("free"),this.toggleDrawing(),aO.startHighlighting(this,_(this,Et).direction==="ltr",{target:_(this,_i).div,x:e.x,y:e.y}),_(this,_i).div.addEventListener("pointerup",()=>{_(this,_i).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:_(this,Et)._signal}),e.preventDefault()}},vu=function(){return _(Sc,fm).get(_(this,Et).getMode())},FH=function(e){const r=_(this,qn,vu);return r?new r.prototype.constructor(e):null},BH=function(){const{x:e,y:r,width:n,height:s}=this.div.getBoundingClientRect(),i=Math.max(0,e),a=Math.max(0,r),l=Math.min(window.innerWidth,e+n),c=Math.min(window.innerHeight,r+s),u=(i+l)/2-e,d=(a+c)/2-r,[h,f]=this.viewport.rotation%180===0?[u,d]:[d,u];return{offsetX:h,offsetY:f}},DP=function(){for(const e of _(this,Yo).values())e.isEmpty()&&e.remove()},Ge(Sc,"_initialized",!1),le(Sc,fm,new Map([vH,AH,DH,aO,MH].map(e=>[e._editorType,e])));let $H=Sc;var Lc,Fa,Dy,wE,jM,CNe,xd,UH,ENe,HH;const Ys=class Ys{constructor({pageIndex:e}){le(this,xd);le(this,Lc,null);le(this,Fa,new Map);le(this,Dy,new Map);this.pageIndex=e}setParent(e){if(!_(this,Lc)){te(this,Lc,e);return}if(_(this,Lc)!==e){if(_(this,Fa).size>0)for(const r of _(this,Fa).values())r.remove(),e.append(r);te(this,Lc,e)}}static get _svgFactory(){return gr(this,"_svgFactory",new sO)}draw(e,r=!1,n=!1){const s=xi(Ys,wE)._++,i=de(this,xd,UH).call(this),a=Ys._svgFactory.createElement("defs");i.append(a);const l=Ys._svgFactory.createElement("path");a.append(l);const c=`path_p${this.pageIndex}_${s}`;l.setAttribute("id",c),l.setAttribute("vector-effect","non-scaling-stroke"),r&&_(this,Dy).set(s,l);const u=n?de(this,xd,ENe).call(this,a,c):null,d=Ys._svgFactory.createElement("use");return i.append(d),d.setAttribute("href",`#${c}`),this.updateProperties(i,e),_(this,Fa).set(s,i),{id:s,clipPathId:`url(#${u})`}}drawOutline(e,r){const n=xi(Ys,wE)._++,s=de(this,xd,UH).call(this),i=Ys._svgFactory.createElement("defs");s.append(i);const a=Ys._svgFactory.createElement("path");i.append(a);const l=`path_p${this.pageIndex}_${n}`;a.setAttribute("id",l),a.setAttribute("vector-effect","non-scaling-stroke");let c;if(r){const h=Ys._svgFactory.createElement("mask");i.append(h),c=`mask_p${this.pageIndex}_${n}`,h.setAttribute("id",c),h.setAttribute("maskUnits","objectBoundingBox");const f=Ys._svgFactory.createElement("rect");h.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const p=Ys._svgFactory.createElement("use");h.append(p),p.setAttribute("href",`#${l}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const u=Ys._svgFactory.createElement("use");s.append(u),u.setAttribute("href",`#${l}`),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,Fa).set(n,s),n}finalizeDraw(e,r){_(this,Dy).delete(e),this.updateProperties(e,r)}updateProperties(e,r){var c;if(!r)return;const{root:n,bbox:s,rootClass:i,path:a}=r,l=typeof e=="number"?_(this,Fa).get(e):e;if(l){if(n&&de(this,xd,HH).call(this,l,n),s&&de(c=Ys,jM,CNe).call(c,l,s),i){const{classList:u}=l;for(const[d,h]of Object.entries(i))u.toggle(d,h)}if(a){const d=l.firstChild.firstChild;de(this,xd,HH).call(this,d,a)}}}updateParent(e,r){if(r===this)return;const n=_(this,Fa).get(e);n&&(_(r,Lc).append(n),_(this,Fa).delete(e),_(r,Fa).set(e,n))}remove(e){_(this,Dy).delete(e),_(this,Lc)!==null&&(_(this,Fa).get(e).remove(),_(this,Fa).delete(e))}destroy(){te(this,Lc,null);for(const e of _(this,Fa).values())e.remove();_(this,Fa).clear(),_(this,Dy).clear()}};Lc=new WeakMap,Fa=new WeakMap,Dy=new WeakMap,wE=new WeakMap,jM=new WeakSet,CNe=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}%`},xd=new WeakSet,UH=function(){const e=Ys._svgFactory.create(1,1,!0);return _(this,Lc).append(e),e.setAttribute("aria-hidden",!0),e},ENe=function(e,r){const n=Ys._svgFactory.createElement("clipPath");e.append(n);const s=`clip_${r}`;n.setAttribute("id",s),n.setAttribute("clipPathUnits","objectBoundingBox");const i=Ys._svgFactory.createElement("use");return n.append(i),i.setAttribute("href",`#${r}`),i.classList.add("clip"),s},HH=function(e,r){for(const[n,s]of Object.entries(r))s===null?e.removeAttribute(n):e.setAttribute(n,s)},le(Ys,jM),le(Ys,wE,0);let zH=Ys;globalThis._pdfjsTestingUtils={HighlightOutliner:wH};globalThis.pdfjsLib={AbortException:Gm,AnnotationEditorLayer:$H,AnnotationEditorParamsType:Ir,AnnotationEditorType:Qt,AnnotationEditorUIManager:mv,AnnotationLayer:gH,AnnotationMode:fp,AnnotationType:Os,build:JEt,ColorPicker:rO,createValidAbsoluteUrl:jSe,DOMSVGFactory:sO,DrawLayer:zH,FeatureTest:oa,fetchData:cA,getDocument:VL,getFilenameFromUrl:qCt,getPdfFilenameFromUrl:GCt,getRGB:HL,getUuid:NSe,getXfaPageViewport:YCt,GlobalWorkerOptions:Vl,ImageKind:aP,InvalidPDFException:CU,isDataScheme:UL,isPdfFile:mG,isValidExplicitDest:aEt,MathClamp:za,noContextMenu:lc,normalizeUnicode:HCt,OPS:QR,OutputScale:md,PasswordResponses:OCt,PDFDataRangeTransport:k_e,PDFDateString:JR,PDFWorker:_k,PermissionFlag:RCt,PixelsPerInch:Km,RenderingCancelledException:pG,ResponseException:ZR,setLayerDimensions:pv,shadow:gr,SignatureExtractor:Oh,stopEvent:Ls,SupportedImageMimeTypes:AU,TextLayer:L1,TouchManager:tO,updateUrlHash:SSe,Util:Rt,VerbosityLevel:FL,version:qL,XfaLayer:T_e};function pA(t){return t.normalize("NFKC").toLowerCase().replace(/[\u2018\u2019]/g,"'").replace(/[\u201C\u201D]/g,'"').replace(/-\s+/g,"").replace(/\s+/g," ").trim()}async function mA(t){const r=(await t.getTextContent()).items,n=[];let s="";return r.forEach((i,a)=>{const l=pA(i.str);if(!l){n.push({itemIdx:a,normStart:s.length,normEnd:s.length});return}const c=[...n].reverse().find(f=>f.normEnd>f.normStart),u=c?r[c.itemIdx]:void 0;/[-\u00ad]\s*$/.test(s)&&new RegExp("^\\p{Ll}","u").test(l)&&((u==null?void 0:u.hasEOL)===!0||/[-\u00ad]\s*$/.test((u==null?void 0:u.str)??""))?(s=s.replace(/[-\u00ad]\s*$/,""),c&&(c.normEnd=s.length)):s.length>0&&!s.endsWith(" ")&&(s+=" ");const h=s.length;s+=l,n.push({itemIdx:a,normStart:h,normEnd:s.length})}),{joined:s,spans:n,items:r}}function Pse(t){return!!t&&/[\p{L}\p{N}]/u.test(t)}function ANe(t,e,r){let n=r;for(;;){const s=t.indexOf(e,n);if(s<0)return-1;const i=s===0?void 0:t[s-1],a=s+e.length>=t.length?void 0:t[s+e.length];if(!Pse(i)&&!Pse(a))return s;n=s+1}}function jAt(t){const e=[];for(const r of t.matchAll(/\S+/g))r.index!=null&&e.push({value:r[0],start:r.index,end:r.index+r[0].length});return e}function SAt(t,e,r=KL,n=SG){const s=jAt(e),i=[];let a=0,l=0;for(;a+r<=s.length&&l<t.length;){let c=null;for(let u=a;u+r<=s.length;u++)for(let d=s.length;d>=u+r;d--){const h=s.slice(u,d).map(m=>m.value).join(" ");if(h.length<n)continue;const f=ANe(t,h,l);if(f<0)continue;const p=d-u;(!c||p>c.wordCount||p===c.wordCount&&f<c.pageStart)&&(c={quoteEnd:d,pageStart:f,pageEnd:f+h.length,wordCount:p});break}if(!c)break;i.push({start:c.pageStart,end:c.pageEnd}),a=c.quoteEnd,l=c.pageEnd}return i}function lO(t,e,r,n,s){const i=t.spans.filter(l=>l.normEnd>n&&l.normStart<s).map(l=>l.itemIdx),a=[];for(const l of i){const c=t.items[l];if(!c||!c.str)continue;const u=Rt.transform(e.transform,c.transform),d=Math.hypot(u[2],u[3]),h=c.width*r,f=u[4],p=u[5]-d;a.push({left:f,top:p,width:h,height:d})}return a}async function TNe(t,e,r,n){if(!n||!n.trim())return[];const s=await mA(t),i=pA(n),a=ANe(s.joined,i,0);return a>=0?lO(s,e,r,a,a+i.length):SAt(s.joined,i).flatMap(l=>lO(s,e,r,l.start,l.end))}async function _At(t){return(await mA(t)).joined}const KL=8,SG=32;function NAt(t){return t.split(/\[\s*(?:…|\.\.\.)\s*\]|…|\.\.\./).map(e=>pA(e.normalize("NFKC"))).filter(Boolean)}function kAt(t){return t.length>=SG&&t.split(" ").length>=KL}function Ise(t,e){let r=0;for(;;){const n=t.indexOf(e,r);if(n<0)return-1;const s=n===0?" ":t[n-1],i=n+e.length>=t.length?" ":t[n+e.length];if(!/[\p{L}\p{N}]/u.test(s)&&!/[\p{L}\p{N}]/u.test(i))return n;r=n+1}}function CAt(t,e){if(kAt(e)){const n=Ise(t,e);if(n>=0)return{start:n,end:n+e.length}}const r=e.split(" ");for(let n=r.length-1;n>=KL;n--)for(let s=0;s+n<=r.length;s++){const i=r.slice(s,s+n).join(" ");if(i.length<SG)continue;const a=Ise(t,i);if(a>=0)return{start:a,end:a+i.length}}return null}async function EAt(t,e){const r=NAt(e).filter(i=>i.split(" ").length>=KL);if(!r.length)return{matches:[],segments:0};const n=r.map(()=>null);for(let i=1;i<=t.numPages;i++){const a=await t.getPage(i),{joined:l}=await mA(a);r.forEach((c,u)=>{const d=n[u];if(d&&d.end-d.start===c.length)return;const h=CAt(l,c);h&&(!d||h.end-h.start>d.end-d.start)&&(n[u]={...h,page:i,segment:u})})}return{matches:n.filter(i=>!!i).sort((i,a)=>i.page-a.page||i.start-a.start),segments:r.length}}async function AAt(t,e,r,n){if(!n.length)return[];const s=await mA(t);return n.map(i=>lO(s,e,r,i.start,i.end))}async function TAt(t,e,r,n){const s=pA(n);if(!s)return[];const i=await mA(t),a=[];let l=0;for(;;){const c=i.joined.indexOf(s,l);if(c<0)break;a.push(lO(i,e,r,c,c+s.length)),l=c+s.length}return a}function PNe({pdf:t,pageNumber:e,width:r,quote:n,estimatedHeight:s,active:i,searchQuery:a,activeSearchIndex:l=null,partialRanges:c}){const u=S.useRef(null),d=S.useRef(null),h=S.useRef(null),[f,p]=S.useState(s?{w:r,h:s}:null),[m,g]=S.useState([]),[y,x]=S.useState([]),[v,b]=S.useState([]),[w,j]=S.useState(!1);return S.useEffect(()=>{if(!i||!c||!c.length){b([]);return}let N=!1;return(async()=>{try{const C=await t.getPage(e),A=C.getViewport({scale:1}),E=r/A.width,O=C.getViewport({scale:E}),$=await AAt(C,O,E,c);N||b($)}catch(C){console.warn("Partial highlight failed:",C)}})(),()=>{N=!0}},[t,e,r,c,i]),S.useEffect(()=>{if(!i)return;let N=!1,C=null;return(async()=>{try{const A=await t.getPage(e);if(N)return;const E=A.getViewport({scale:1}),O=r/E.width,$=A.getViewport({scale:O});p({w:$.width,h:$.height});const T=u.current;if(!T)return;const M=T.getContext("2d");if(!M||(T.width=$.width,T.height=$.height,C=A.render({canvasContext:M,viewport:$,canvas:T}),await C.promise,N))return;const k=d.current;if(k){k.innerHTML="",k.style.width=`${$.width}px`,k.style.height=`${$.height}px`;try{const D=L1;typeof D=="function"&&await new D({textContentSource:A.streamTextContent(),container:k,viewport:$}).render()}catch(D){console.warn("Text layer render failed:",D)}}if(n&&n.trim())try{const D=await TNe(A,$,O,n);N||g(D)}catch(D){console.warn("Highlight failed:",D)}else g([]);N||j(!0)}catch(A){console.error("Page render failed:",A)}})(),()=>{N=!0;try{C==null||C.cancel()}catch{}}},[t,e,r,n,i]),S.useEffect(()=>{if(!i||!a||!a.trim()){x([]);return}let N=!1;return(async()=>{try{const C=await t.getPage(e),A=C.getViewport({scale:1}),E=r/A.width,O=C.getViewport({scale:E}),$=await TAt(C,O,E,a);N||x($)}catch(C){console.warn("Search highlight failed:",C)}})(),()=>{N=!0}},[t,e,r,a,i]),S.useEffect(()=>{if(l==null)return;const N=h.current;N&&N.scrollIntoView({block:"center",behavior:"smooth"})},[l,y]),o.jsx("div",{className:"relative mx-auto rounded-md border border-border shadow-sm bg-white overflow-hidden",style:f?{width:f.w,height:f.h}:{width:r,height:400},"data-page-number":e,children:i?o.jsxs(o.Fragment,{children:[o.jsx("canvas",{ref:u,className:"block"}),o.jsx("div",{ref:d,className:"evidence-pdf-textlayer","aria-hidden":!1}),m.map((N,C)=>o.jsx("span",{className:"pdf-evidence-highlight",style:{left:N.left,top:N.top,width:N.width,height:N.height}},C)),v.map((N,C)=>N.map((A,E)=>o.jsx("span",{className:"pdf-evidence-highlight-partial",style:{left:A.left,top:A.top,width:A.width,height:A.height}},`p-${C}-${E}`))),y.map((N,C)=>N.map((A,E)=>o.jsx("span",{ref:C===l&&E===0?h:void 0,className:C===l?"pdf-search-highlight pdf-search-highlight-active":"pdf-search-highlight",style:{left:A.left,top:A.top,width:A.width,height:A.height}},`s-${C}-${E}`))),!w&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/60",children:o.jsx(Xe,{className:"w-5 h-5 animate-spin text-muted-foreground"})})]}):o.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-xs text-muted-foreground",children:["Page ",e]})})}function PAt(t,e){const[r,n]=S.useState(null),[s,i]=S.useState(!1),a=S.useRef(null);S.useEffect(()=>{if(!t){n(null),a.current=null;return}if(a.current===t)return;let p=!1;return a.current=t,n(null),i(!0),(async()=>{const m=[];try{for(let g=1;g<=t.numPages;g++){const y=await t.getPage(g);if(m.push(await _At(y)),p)return}}catch(g){console.warn("PDF search indexing failed:",g)}p||(n(m),i(!1))})(),()=>{p=!0}},[t]);const l=S.useMemo(()=>{const p=pA(e);if(!p||p.length<2||!r)return[];const m=[];return r.forEach((g,y)=>{let x=0,v=0;for(;;){const b=g.indexOf(p,x);if(b<0)break;m.push({page:y+1,indexInPage:v}),v++,x=b+p.length}}),m},[r,e]),[c,u]=S.useState(0);S.useEffect(()=>{u(0)},[e,r]);const d=S.useCallback(()=>{u(p=>l.length?(p+1)%l.length:0)},[l.length]),h=S.useCallback(()=>{u(p=>l.length?(p-1+l.length)%l.length:0)},[l.length]),f=l[c]??null;return{matches:l,activeIndex:c,activeMatch:f,next:d,prev:h,setActiveIndex:u,indexing:s}}const YL={de:{code:"de",label:"Deutsch",pagePrefix:"S."},en:{code:"en",label:"English",pagePrefix:"p."},fr:{code:"fr",label:"Français",pagePrefix:"p."},es:{code:"es",label:"Español",pagePrefix:"p."},it:{code:"it",label:"Italiano",pagePrefix:"p."}};function XL(t,e="en"){const r=typeof t=="string"?t.trim().toLowerCase():"";return r==="de"?"de":r==="en"?"en":r==="fr"?"fr":r==="es"?"es":r==="it"?"it":e}Vl.workerSrc=`https://unpkg.com/pdfjs-dist@${qL}/build/pdf.worker.min.mjs`;const Rse=.5,Ose=2,Mse=.1,INe=S.forwardRef(function({pdfUrl:e,highlights:r=[],partialMatches:n,initialPage:s=1,pageOffset:i=null,writingLanguage:a,width:l,renderWindow:c=6},u){var we;const d=S.useRef(null),h=S.useRef(new Map),[f,p]=S.useState(null),[m,g]=S.useState(!0),[y,x]=S.useState(null),[v,b]=S.useState({}),[w,j]=S.useState(new Set),[N,C]=S.useState(s),[A,E]=S.useState(String(s)),[O,$]=S.useState(1),[T,M]=S.useState(l??680),[k,D]=S.useState(!1),[K,H]=S.useState(""),[ee,V]=S.useState(""),B=S.useRef(null),z=((we=YL[a])==null?void 0:we.pagePrefix)??"p.",F=ce=>ce+(i??0),G=i!=null&&i!==0,Q=Math.max(200,Math.round(T*O));S.useEffect(()=>{const ce=setTimeout(()=>V(K.trim()),250);return()=>clearTimeout(ce)},[K]);const{matches:ie,activeIndex:se,activeMatch:q,next:L,prev:Z,indexing:J}=PAt(f,ee),W=S.useMemo(()=>{const ce=new Map;for(const ne of r)ne.page!=null&&ne.quote&&ce.set(ne.page,ne.quote);return ce},[r]),X=S.useMemo(()=>{const ce=new Map;for(const ne of n??[]){const fe=ce.get(ne.page)??[];fe.push({start:ne.start,end:ne.end}),ce.set(ne.page,fe)}return ce},[n]);S.useEffect(()=>{if(l){M(l);return}const ce=d.current;if(!ce)return;const ne=()=>{const be=ce.clientWidth;be>0&&M(Math.max(320,be-24))};ne();const fe=new ResizeObserver(ne);return fe.observe(ce),()=>fe.disconnect()},[l]),S.useEffect(()=>{let ce=!1;return g(!0),x(null),p(null),b({}),(async()=>{try{const ne=await VL(e).promise;if(ce){ne.destroy();return}p(ne),g(!1)}catch(ne){console.error("PDF load failed:",ne),ce||(x("Could not load PDF."),g(!1))}})(),()=>{ce=!0}},[e]),S.useEffect(()=>{if(!f)return;let ce=!1;return(async()=>{const ne=f.numPages,fe=8;for(let be=1;be<=ne;be+=fe){const xe=[];for(let ke=be;ke<be+fe&&ke<=ne;ke++)xe.push(ke);const _e=await Promise.all(xe.map(async ke=>{const Te=(await f.getPage(ke)).getViewport({scale:1});return[ke,Q/Te.width*Te.height]}));if(ce)return;b(ke=>{const $e={...ke};for(const[Te,ot]of _e)$e[Te]=ot;return $e})}})(),()=>{ce=!0}},[f,Q]),S.useEffect(()=>{if(!f)return;const ce=d.current;if(!ce)return;const ne=new IntersectionObserver(fe=>{j(be=>{const xe=new Set(be);for(const _e of fe){const ke=Number(_e.target.dataset.page);ke&&(_e.isIntersecting?xe.add(ke):xe.delete(ke))}return xe})},{root:ce,rootMargin:"200px 0px",threshold:.01});return h.current.forEach(fe=>ne.observe(fe)),()=>ne.disconnect()},[f]),S.useEffect(()=>{if(w.size===0)return;const ce=Math.min(...Array.from(w));C(ce),E(String(ce))},[w]);const he=S.useMemo(()=>{if(!f)return new Set;const ce=new Set,ne=Array.from(w).sort((xe,_e)=>xe-_e),fe=ne[0]??s,be=Math.floor(c/2);for(let xe=fe-be;xe<=fe+be;xe++)xe>=1&&xe<=f.numPages&&ce.add(xe);for(const xe of ne)ce.add(xe);return q&&ce.add(q.page),ce},[w,f,c,s,q]),P=S.useCallback(ce=>{const ne=h.current.get(ce);ne&&ne.scrollIntoView({behavior:"smooth",block:"start"})},[]);S.useEffect(()=>{if(!q)return;const ce=h.current.get(q.page);ce&&ce.scrollIntoView({behavior:"smooth",block:"start"})},[q]),S.useEffect(()=>{const ce=ne=>{if((ne.metaKey||ne.ctrlKey)&&ne.key.toLowerCase()==="f"){if(!d.current)return;ne.preventDefault(),D(!0),requestAnimationFrame(()=>{var be;return(be=B.current)==null?void 0:be.focus()})}};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[]);const oe=S.useRef(!1);S.useEffect(()=>{if(!(!f||oe.current))if(s>1){const ce=h.current.get(s);ce&&(ce.scrollIntoView({block:"start"}),oe.current=!0)}else oe.current=!0},[f,s,v]);const Y=S.useRef(O);if(S.useEffect(()=>{if(Y.current===O)return;Y.current=O;const ce=N;requestAnimationFrame(()=>{const ne=h.current.get(ce);ne&&ne.scrollIntoView({block:"start"})})},[O,N]),S.useImperativeHandle(u,()=>({scrollToPage:P}),[P]),m)return o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8",children:[o.jsx(Xe,{className:"w-4 h-4 animate-spin"})," Loading PDF…"]});if(y||!f)return o.jsx("div",{className:"text-sm text-destructive border border-destructive/30 rounded p-3",children:y??"PDF unavailable."});const R=f.numPages,I=Array.from({length:R},(ce,ne)=>ne+1),U=()=>P(Math.max(1,N-1)),re=()=>P(Math.min(R,N+1)),ue=()=>$(ce=>Math.max(Rse,Math.round((ce-Mse)*100)/100)),ae=()=>$(ce=>Math.min(Ose,Math.round((ce+Mse)*100)/100)),ge=()=>{const ce=parseInt(A,10);Number.isFinite(ce)&&ce>=1&&ce<=R?P(ce):E(String(N))};return o.jsxs("div",{className:"relative min-w-0",children:[o.jsx("div",{ref:d,className:"relative max-h-[70vh] overflow-y-auto overflow-x-hidden bg-muted/30 rounded-md border border-border min-w-0",children:o.jsx("div",{className:"py-3 space-y-3",children:I.map(ce=>{const ne=he.has(ce);return o.jsxs("div",{"data-page":ce,ref:fe=>{fe?h.current.set(ce,fe):h.current.delete(ce)},children:[o.jsx(PNe,{pdf:f,pageNumber:ce,width:Q,active:ne,quote:W.get(ce)??null,partialRanges:X.get(ce),estimatedHeight:v[ce],searchQuery:ee,activeSearchIndex:q&&q.page===ce?q.indexInPage:null}),o.jsx("div",{className:"text-center text-[10px] text-muted-foreground mt-1",children:G?o.jsxs(o.Fragment,{children:["PDF ",ce," / ",R," · ",z," ",F(ce)]}):o.jsxs(o.Fragment,{children:[z," ",ce," / ",R]})})]},ce)})})}),o.jsx("div",{className:"pointer-events-none absolute bottom-3 left-0 right-0 flex justify-center z-10",children:o.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:[k?o.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[o.jsx(Ti,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),o.jsx("input",{ref:B,value:K,onChange:ce=>H(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"?(ce.preventDefault(),ce.shiftKey?Z():L()):ce.key==="Escape"&&(ce.preventDefault(),H(""),D(!1))},placeholder:"Im PDF suchen…",className:"w-36 bg-transparent border border-border rounded px-2 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary","aria-label":"Search in PDF"}),o.jsx("span",{className:"text-[11px] tabular-nums text-muted-foreground min-w-[46px] text-center",children:J&&ee?"…":ee?`${ie.length?se+1:0} / ${ie.length}`:""}),o.jsx("button",{type:"button",onClick:Z,disabled:ie.length===0,className:"p-1 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Previous match",children:o.jsx(FW,{className:"w-3.5 h-3.5"})}),o.jsx("button",{type:"button",onClick:L,disabled:ie.length===0,className:"p-1 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Next match",children:o.jsx(ia,{className:"w-3.5 h-3.5"})}),o.jsx("button",{type:"button",onClick:()=>{H(""),D(!1)},className:"p-1 rounded-full hover:bg-muted","aria-label":"Close search",children:o.jsx(fn,{className:"w-3.5 h-3.5"})})]}):o.jsx("button",{type:"button",onClick:()=>{D(!0),requestAnimationFrame(()=>{var ce;return(ce=B.current)==null?void 0:ce.focus()})},className:"p-1.5 rounded-full hover:bg-muted","aria-label":"Search in PDF",children:o.jsx(Ti,{className:"w-4 h-4"})}),o.jsx("div",{className:"w-px h-5 bg-border mx-1"}),o.jsx("button",{type:"button",onClick:U,disabled:N<=1,className:"p-1.5 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Previous page",children:o.jsx(Ghe,{className:"w-4 h-4"})}),o.jsxs("div",{className:"flex items-center gap-1 text-xs px-1",children:[o.jsx("input",{value:A,onChange:ce=>E(ce.target.value.replace(/[^\d]/g,"")),onBlur:ge,onKeyDown:ce=>{ce.key==="Enter"&&(ce.preventDefault(),ge())},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 PDF page"}),o.jsxs("span",{className:"text-muted-foreground",children:["/ ",R]}),G&&o.jsxs("span",{className:"text-muted-foreground whitespace-nowrap",children:["· ",z," ",F(N)]})]}),o.jsx("button",{type:"button",onClick:re,disabled:N>=R,className:"p-1.5 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Next page",children:o.jsx(AE,{className:"w-4 h-4"})}),o.jsx("div",{className:"w-px h-5 bg-border mx-1"}),o.jsx("button",{type:"button",onClick:ue,disabled:O<=Rse+.001,className:"p-1.5 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Zoom out",children:o.jsx(efe,{className:"w-4 h-4"})}),o.jsxs("span",{className:"text-xs tabular-nums w-10 text-center",children:[Math.round(O*100),"%"]}),o.jsx("button",{type:"button",onClick:ae,disabled:O>=Ose-.001,className:"p-1.5 rounded-full hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed","aria-label":"Zoom in",children:o.jsx(Bs,{className:"w-4 h-4"})})]})})]})});function IAt({open:t,onClose:e,pdfUrl:r,title:n,pageOffset:s=null,writingLanguage:i}){return o.jsx(aA,{open:t,onOpenChange:a=>!a&&e(),children:o.jsxs(Rj,{side:"right",className:"w-full max-w-[720px] p-0 flex flex-col sm:!max-w-[720px]",children:[o.jsxs($L,{className:"px-5 py-4 border-b space-y-1",children:[o.jsx(oA,{className:"text-base truncate pr-8",children:n}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF viewer"})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-hidden p-3 [&>div]:h-full [&>div>div:first-child]:h-full [&>div>div:first-child]:max-h-none",children:r?o.jsx(INe,{pdfUrl:r,pageOffset:s,writingLanguage:i}):o.jsx("div",{className:"rounded border border-dashed border-border p-4 text-sm text-muted-foreground",children:"PDF not available for this document."})})]})})}const Dse={webpage:"Web page",wikipedia:"Wikipedia",youtube:"YouTube",report:"Report",book:"Book / Article"},RNe=["January","February","March","April","May","June","July","August","September","October","November","December"],ONe=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),lb=t=>/[.?!]$/.test(t.trim())?t.trim():`${t.trim()}.`;function _G(t,e){return t!=null&&t.trim()?e?[t.trim()]:t.split(";").map(r=>r.trim()).filter(Boolean):[]}function RAt(t){return t.length===0?"":t.length===1?t[0]:t.length===2?`${t[0]}, & ${t[1]}`:`${t.slice(0,-1).join(", ")}, & ${t[t.length-1]}`}function OAt(t){var s;const e=(s=t==null?void 0:t.year)==null?void 0:s.trim();if(!e)return"(n.d.)";const r=parseInt((t==null?void 0:t.month)||"",10);if(!r||r<1||r>12)return`(${e})`;const n=parseInt((t==null?void 0:t.day)||"",10);return`(${e}, ${RNe[r-1]}${n?` ${n}`:""})`}function Lse(t){if(!t)return"";const[e,r,n]=t.split("-").map(s=>parseInt(s,10));return!e||!r?"":`Retrieved ${RNe[r-1]} ${n||1}, ${e}, from `}function MAt(t){const e=t==null?void 0:t.trim().replace(/^https?:\/\/(dx\.)?doi\.org\//i,"").replace(/^doi:\s*/i,"");return e?`https://doi.org/${e}`:""}const Fi=t=>({text:t,html:ONe(t)}),Pg=t=>({text:t,html:`<em>${ONe(t)}</em>`});function DAt(t){var c,u,d,h;const e=RAt(_G(t.author,t.isOrganization)),r=OAt(t.date),n=t.title.trim(),s=((c=t.url)==null?void 0:c.trim())||"",i=[];switch(t.type){case"webpage":{e?i.push(Fi(`${lb(e)} ${r}. `),Pg(n),Fi(". ")):i.push(Pg(n),Fi(`. ${r}. `));const f=(u=t.siteName)==null?void 0:u.trim();f&&f!==e&&i.push(Fi(`${lb(f)} `)),i.push(Fi(`${Lse(t.accessedAt)}${s}`));break}case"wikipedia":{i.push(Fi(`${lb(n)} ${r}. In `),Pg("Wikipedia"),Fi(". ")),i.push(Fi(`${Lse(t.accessedAt)}${s}`));break}case"youtube":{e?i.push(Fi(`${lb(e)} ${r}. `),Pg(n),Fi(" [Video]. ")):i.push(Pg(n),Fi(` [Video]. ${r}. `)),i.push(Fi(`YouTube. ${s}`));break}case"report":{const f=(d=t.reportNumber)!=null&&d.trim()?` (Report No. ${t.reportNumber.trim()})`:"";e?i.push(Fi(`${lb(e)} ${r}. `),Pg(n),Fi(`${f}. `)):i.push(Pg(n),Fi(`${f}. ${r}. `));const p=(h=t.publisher)==null?void 0:h.trim();p&&p.toLowerCase()!==e.toLowerCase()&&i.push(Fi(`${lb(p)} `)),i.push(Fi(MAt(t.doi)||s));break}}const a=i.map(f=>f.text).join("").replace(/\s+/g," ").trim(),l=i.map(f=>f.html).join("").replace(/\s+/g," ").trim();return{text:a,html:l}}function LAt(t,e){return e?t:t.includes(",")?t.split(",")[0].trim():t.trim().split(/\s+/).pop()||t}function MNe(t){const r=_G(t.author,t.isOrganization).map(i=>LAt(i,t.isOrganization)),n=r.length===0?null:r.length===1?r[0]:r.length===2?`${r[0]} & ${r[1]}`:`${r[0]} et al.`,s=parseInt(t.year||"",10);return{authors_display:n,author_surname:r[0]||null,published_year:s&&s>0?s:null}}function $se(t){return t?t.trim().toLowerCase().replace(/^https?:\/\//,"").replace(/^www\./,"").replace(/[#?].*$/,"").replace(/\/+$/,""):""}function BT(t){return(t||"").toLowerCase().replace(/^https?:\/\/(dx\.)?doi\.org\//,"").replace(/[^0-9a-z./x]/g,"")}function zT(t){var e;return(t==null?void 0:t.source_type)==="standalone"||((e=t==null?void 0:t.bib_meta)==null?void 0:e.method)==="manual_citation"&&!(t!=null&&t.storage_path)}function $At({documentId:t}){const[e,r]=S.useState(null),[n,s]=S.useState(null),[i,a]=S.useState(0),[l,c]=S.useState(""),[u,d]=S.useState(!1),[h,f]=S.useState(!0),[p,m]=S.useState(!1);S.useEffect(()=>{g()},[t]);const g=async()=>{f(!0);const{data:O,error:$}=await pe.from("documents").select("page_count, page_offset, page_offset_source").eq("id",t).single();if($){console.error("Load page mapping failed:",$),Ke.error("Could not load page numbering."),f(!1);return}const T=(O==null?void 0:O.page_offset)??null,M=(O==null?void 0:O.page_offset_source)??null;r(T),s(M),a((O==null?void 0:O.page_count)??0);const k=1+(T??0);c(String(k)),f(!1)},y=parseInt(l,10),x=!Number.isNaN(y)&&y>=1&&l.trim()!=="",v=x?y-1:null,b=e??0,w=v!==null&&v!==b,j=1+b,N=i>0?j+i-1:j,C=x&&i>0?y+i-1:null,A=()=>{if(!(!x||v===null)){if(!w){Ke.info("No correction needed — the start page is already correct.");return}m(!0)}},E=async()=>{if(!(!x||v===null)){m(!1),d(!0);try{const{error:O}=await pe.from("documents").update({page_offset:v,page_offset_source:"manual"}).eq("id",t);if(O)throw O;const $=v>0?"+":"";Ke.success(`Page mapping updated (Offset: ${$}${v})`),await g()}catch(O){console.error("Page correction error:",O),Ke.error("Error correcting page numbers.")}finally{d(!1)}}};return h?o.jsxs(o.Fragment,{children:[o.jsx(Eo,{}),o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-2",children:[o.jsx(Ei,{className:"w-4 h-4 animate-spin"}),"Loading page data..."]})]}):i===0?null:o.jsxs(o.Fragment,{children:[o.jsx(Eo,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-semibold",children:"Correct Original Page Numbers"}),o.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."})]}),n&&o.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:[o.jsx(Jl,{className:"w-3.5 h-3.5 shrink-0"}),o.jsxs("span",{children:["Current page mapping: PDF page 1 → original page ",j," (",n==="manual"?"manual":`detected via ${n}`,")"]})]}),o.jsxs("div",{className:"flex items-end gap-3",children:[o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx(Se,{htmlFor:"page-start",className:"text-xs",children:"PDF page 1 corresponds to original page:"}),o.jsx(Ue,{id:"page-start",type:"number",min:1,value:l,onChange:O=>c(O.target.value),placeholder:"e.g. 413",className:"h-9"})]}),o.jsx(me,{size:"sm",onClick:A,disabled:!x||!w||u,className:"h-9",children:u?o.jsx(Ei,{className:"w-4 h-4 animate-spin"}):"Correct Pages"})]}),x&&w&&C!=null&&o.jsxs("p",{className:"text-xs text-muted-foreground",children:["PDF pages 1–",i," will remain unchanged internally. Citation pages will map from ",y," to"," ",C,"."]})]}),o.jsx(Mi,{open:p,onOpenChange:m,children:o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Correct Original Page Numbers?"}),o.jsxs(hi,{children:["PDF pages 1–",i," will remain unchanged. The citation mapping will change from original pages"," ",j,"–",N," to ",y,"–",C,". This manual mapping will override automatic OpenAlex or Crossref page detection for this document."]})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:E,children:"Correct Pages"})]})]})})]})}const FAt=/^\s*(?:\[\d{1,4}\]|\(\d{1,4}\)|\d{1,4}[.)])\s+/,BAt=new RegExp("^\\s*(?:\\[\\d{1,4}\\]|\\(\\d{1,4}\\)|\\d{1,4}[.)]\\s|\\p{Lu}[\\p{L}'’\\-]+,\\s|\\p{Lu}[\\p{L}'’\\-]+\\s+\\p{Lu}{1,3}[,.\\s]|\\p{Lu}[\\p{L}\\s&.'’\\-]{1,80}\\(\\d{4})","u");function Nk(t){return t.trim().replace(/^https?:\/\/(?:dx\.)?doi\.org\//i,"").replace(/^doi:\s*/i,"").replace(/[.,;:)\]]+$/,"").toLowerCase()}const QL=t=>t.replace(/[^0-9X]/gi,"").toUpperCase();function zAt(t){if(t.length===10){let e=0;for(let r=0;r<10;r++){const n=t[r],s=n==="X"?r===9?10:NaN:Number(n);if(Number.isNaN(s))return!1;e+=s*(10-r)}return e%11===0}if(t.length===13&&/^\d{13}$/.test(t)){let e=0;for(let r=0;r<13;r++)e+=Number(t[r])*(r%2?3:1);return e%10===0}return!1}function UAt(t){const e={},r=t.match(/\b(10\.\d{4,9}\/[^\s"<>]+)/i);r&&(e.doi=Nk(r[1]));const n=t.match(/pubmed\.ncbi\.nlm\.nih\.gov\/(\d{1,9})/i)??t.match(/\bPMID:?\s*(\d{1,9})\b/i);n&&(e.pmid=n[1]);const s=/\bISBN(?:-1[03])?:?\s*([0-9X][0-9X\s-]{8,16}[0-9X])/gi;let i;for(;i=s.exec(t);){const u=QL(i[1]);if(zAt(u)){e.isbn=u;break}}const l=(t.match(/https?:\/\/[^\s<>"]+/gi)??[]).find(u=>!/doi\.org|pubmed\.ncbi/i.test(u));l&&(e.url=l.replace(/[.,;)\]]+$/,""));const c=t.match(/\b(1[5-9]\d{2}|20\d{2})[a-z]?\b/);return c&&(e.year=Number(c[1])),e}function HAt(t){if(!(t!=null&&t.trim()))return[];const e=t.split(/\n{2,}/).map(n=>n.replace(/\s+/g," ").trim()).filter(Boolean),r=[];for(const n of e)r.length&&!BAt.test(n)&&n.length<200&&!/\(\d{4}/.test(n.slice(0,120))?r[r.length-1]+=` ${n}`:r.push(n);return r.map(n=>n.replace(FAt,"").trim()).filter(n=>n.length>=15&&new RegExp("\\p{L}","u").test(n)).map((n,s)=>({tempId:`ref-${s}`,rawText:n,...UAt(n)}))}function WAt(t){const e=t.filter(r=>r.doi||r.pmid||r.isbn);return{total:t.length,doi:t.filter(r=>r.doi).length,pmid:t.filter(r=>r.pmid).length,isbn:t.filter(r=>r.isbn).length,url:t.filter(r=>r.url).length,withoutStrongId:t.length-e.length}}function VAt(t){var n,s,i,a,l;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)||((l=t.google_books_data)==null?void 0:l.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 qAt(t){var n,s,i,a,l,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=(l=(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:l[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 Q3(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 DNe(t){var n,s,i,a,l,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=(l=e==null?void 0:e.crossref_payload)==null?void 0:l.title)==null?void 0:c[0]];for(const d of r){if(d&&typeof d=="string"&&d.trim()&&!Q3(d.trim()))return d.trim();if(Array.isArray(d)&&((u=d[0])!=null&&u.trim()))return d[0].trim()}return t.title&&!Q3(t.title)?t.title:t.original_filename&&!Q3(t.original_filename)?t.original_filename:t.title||t.original_filename||"Untitled"}function GAt(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 KAt(t){if(t.length===10){let e=0;for(let r=0;r<10;r++){const n=t[r],s=n==="X"?r===9?10:NaN:Number(n);if(Number.isNaN(s))return!1;e+=s*(10-r)}return e%11===0}if(t.length===13&&/^\d{13}$/.test(t)){let e=0;for(let r=0;r<13;r++)e+=Number(t[r])*(r%2?3:1);return e%10===0}return!1}function YAt(t){const e=t.trim();if(!e)return null;if(/^(https?:\/\/(dx\.)?doi\.org\/|doi:\s*)?10\.\d{4,9}\/\S+$/i.test(e))return{kind:"doi",value:Nk(e)};const r=QL(e.replace(/^ISBN(-1[03])?:?\s*/i,""));return KAt(r)?{kind:"isbn",value:r}:null}function XAt({document:t,userId:e,onUpdated:r}){const[n,s]=S.useState(""),[i,a]=S.useState(!1),[l,c]=S.useState(""),[u,d]=S.useState(null),[h,f]=S.useState(null),[p,m]=S.useState(null),[g,y]=S.useState(!1),x=async(w,j)=>{a(!0),c("");try{const{data:N,error:C}=await pe.from("documents").select("citation_apa, doi, isbn, bib_meta").eq("id",t.id).single();if(C)throw C;const A=N,{data:E,error:O}=await pe.functions.invoke("detect_bibliography",{body:{document_id:t.id,force:!0,manual_doi:w==="doi"?j:null,manual_isbn:w==="isbn"?j:null}});if(O)throw O;if(E!=null&&E.error)throw new Error(E.error);const{data:$,error:T}=await pe.from("documents").select("*").eq("id",t.id).single();if(T)throw T;const M=$.citation_apa!==A.citation_apa||JSON.stringify($.bib_meta)!==JSON.stringify(A.bib_meta)||(w==="doi"?$.doi:$.isbn);if(!$.citation_apa&&!$.bib_meta){c(`No metadata found for this ${w.toUpperCase()}.`);return}if(!M){c(`No metadata found for this ${w.toUpperCase()}.`);return}f(A),d($),Ke.success("Metadata applied"),r({citation_apa:$.citation_apa,doi:$.doi,isbn:$.isbn,bib_meta:$.bib_meta})}catch(N){console.error("[metadata lookup]",N);const C=String((N==null?void 0:N.message)||"");/doi|isbn|not found|no match/i.test(C)?c(`No metadata found for this ${w.toUpperCase()}.`):c("Lookup failed, try again.")}finally{a(!1)}},v=async()=>{c(""),d(null),f(null);const w=YAt(n);if(!w){c("Not a valid DOI or ISBN.");return}if(e){const{data:j}=await pe.from("documents").select("id, title, original_filename, bib_meta, doi, isbn").eq("user_id",e).neq("id",t.id).not(w.kind,"is",null).limit(5e3),N=(j??[]).find(C=>w.kind==="doi"?C.doi&&Nk(C.doi)===w.value:C.isbn&&QL(C.isbn)===w.value);if(N){m({title:DNe(N),id:w.kind,value:w.value});return}}await x(w.kind,w.value)},b=async()=>{if(h){y(!0);try{const{error:w}=await pe.from("documents").update(h).eq("id",t.id);if(w)throw w;f(null),d(null),Ke.success("Previous metadata restored"),r({citation_apa:h.citation_apa,doi:h.doi,isbn:h.isbn,bib_meta:h.bib_meta})}catch(w){console.error(w),Ke.error("Could not restore previous metadata")}finally{y(!1)}}};return o.jsxs("div",{className:"space-y-2",children:[o.jsx("h4",{className:"text-sm font-medium",children:"Source metadata"}),o.jsx("label",{className:"text-xs text-muted-foreground",htmlFor:`meta-${t.id}`,children:"DOI or ISBN"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Ue,{id:`meta-${t.id}`,value:n,onChange:w=>s(w.target.value),onKeyDown:w=>w.key==="Enter"&&!i&&v(),placeholder:"e.g. 10.1186/s12888-024-05920-y or 978-...",disabled:i}),o.jsxs(me,{size:"sm",onClick:v,disabled:i||!n.trim(),className:"shrink-0",children:[i?o.jsx(Ei,{className:"h-4 w-4 animate-spin"}):o.jsx(Ti,{className:"h-4 w-4"}),o.jsx("span",{className:"ml-1",children:"Find metadata"})]})]}),i&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Looking up metadata..."}),l&&o.jsxs("p",{className:"text-xs text-destructive flex items-center gap-1",children:[o.jsx(Jl,{className:"h-3 w-3"})," ",l]}),u&&o.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border bg-muted/40 p-3 text-sm",children:[o.jsxs("span",{className:"flex items-center gap-1 font-medium",children:[o.jsx(uc,{className:"h-4 w-4 text-primary"})," Metadata found — details updated above"]}),h&&o.jsxs(me,{size:"sm",variant:"ghost",onClick:b,disabled:g,children:[g?o.jsx(Ei,{className:"h-3 w-3 animate-spin"}):o.jsx(ife,{className:"h-3 w-3"}),o.jsx("span",{className:"ml-1",children:"Undo"})]})]}),o.jsx(Mi,{open:!!p,onOpenChange:w=>!w&&m(null),children:o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Identifier already in use"}),o.jsxs(hi,{children:["This DOI/ISBN is already used by another source in your Library.",o.jsx("span",{className:"block mt-2 font-medium text-foreground",children:p==null?void 0:p.title})]})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>{const w=p;m(null),w&&x(w.id,w.value)},children:"Use anyway"})]})]})})]})}function QAt({documents:t,documentPages:e,onDocumentDeleted:r,currentPage:n,itemsPerPage:s,totalItems:i,onPageChange:a}){const l=Or(),{userProfile:c,researchProfile:u}=Ht(),d=XL(u==null?void 0:u.preferred_language,"en"),[h,f]=S.useState(new Set),[p,m]=S.useState({}),[g,y]=S.useState(new Set),[x,v]=S.useState(new Set),[b,w]=S.useState(""),[j,N]=S.useState(!1),[C,A]=S.useState(null),[E,O]=S.useState({}),$=(Q,ie)=>{O(se=>({...se,[Q]:{...se[Q],...ie}})),r()};S.useEffect(()=>{H9(t,"documents").then(m)},[t]);const T=Q=>{var q,L,Z,J;const ie=Q.book_title;if(ie)return ie;const se=Q.bib_meta;if(!se)return null;if(se.title&&typeof se.title=="string")return se.title;if((q=se.google_books_data)!=null&&q.title)return se.google_books_data.title;if((Z=(L=se.crossref_data)==null?void 0:L.crossref_metadata)!=null&&Z.title){const W=se.crossref_data.crossref_metadata.title;return Array.isArray(W)?W[0]:W}if((J=se.crossref_payload)!=null&&J.title){const W=se.crossref_payload.title;return Array.isArray(W)?W[0]:W}return null},M=async Q=>{const ie=t.find(se=>se.id===Q);if(ie){f(se=>new Set(se).add(Q));try{const{error:se}=await pe.from("summaries").delete().eq("document_id",Q).eq("user_id",c==null?void 0:c.id);if(se)throw se;const{error:q}=await pe.from("documents").delete().eq("id",Q).eq("user_id",c==null?void 0:c.id);if(q)throw q;try{ie.storage_path&&await pe.storage.from("documents").remove([ie.storage_path])}catch(L){console.warn("Could not delete file from storage:",L)}Ke.success("Document deleted successfully"),r()}catch(se){console.error("Delete error:",se),Ke.error("Error deleting. Please try again.")}finally{f(se=>{const q=new Set(se);return q.delete(Q),q})}}},k=async(Q,ie)=>{try{await navigator.clipboard.writeText(Q),y(se=>new Set(se).add(ie)),Ke.success("Citation copied to clipboard"),setTimeout(()=>{y(se=>{const q=new Set(se);return q.delete(ie),q})},2e3)}catch{Ke.error("Error copying to clipboard")}},D=(Q,ie)=>{v(se=>new Set(se).add(Q)),w(ie)},K=async Q=>{try{const{error:ie}=await pe.from("documents").update({citation_apa:b}).eq("id",Q).eq("user_id",c==null?void 0:c.id);if(ie)throw ie;Ke.success("Citation updated successfully"),r(),v(se=>{const q=new Set(se);return q.delete(Q),q})}catch(ie){console.error("Save citation error:",ie),Ke.error("Error saving citation")}},H=Q=>{v(ie=>{const se=new Set(ie);return se.delete(Q),se}),w("")},ee=Q=>p[Q.id]||null,V=(Q,ie)=>ie&&zT(ie)&&!e[Q]?o.jsx(kt,{variant:"outline",className:"rounded-full px-2.5 py-0.5 text-[11px] font-medium",children:"Citation only"}):e[Q]||!1?o.jsx(kt,{className:"rounded-full border border-emerald-200 bg-emerald-50 px-2.5 py-0.5 text-[11px] font-medium text-emerald-700 hover:bg-emerald-50 dark:border-emerald-900/60 dark:bg-emerald-950/30 dark:text-emerald-300",children:"Indexed"}):o.jsx(kt,{variant:"secondary",className:"rounded-full px-2.5 py-0.5 text-[11px] font-medium",children:"Processing"}),B=Q=>new Date(Q).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),z=Math.ceil(i/s),F=(n-1)*s+1,G=Math.min(n*s,i);return o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"overflow-hidden rounded-xl border border-border/70 bg-card",children:o.jsxs(_d,{children:[o.jsx(Nd,{children:o.jsxs(fi,{className:"border-border/60 bg-muted/30 hover:bg-muted/30",children:[o.jsx(tr,{className:"h-10 px-4 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:"Document"}),o.jsx(tr,{className:"h-10 w-[120px] text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:"Status"}),o.jsx(tr,{className:"h-10 w-[150px] text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:"Added"}),o.jsx(tr,{className:"h-10 w-[260px] pr-4 text-right text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:"Actions"})]})}),o.jsx(kd,{children:t.map(Q=>{var Z,J;const ie=h.has(Q.id),se=g.has(Q.id),q=x.has(Q.id),L={...Q,...E[Q.id]||{}};return o.jsxs(fi,{className:"border-border/50 transition-colors hover:bg-muted/20",children:[o.jsx(rr,{className:"px-4 py-4",children:o.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[o.jsx("div",{className:"mt-0.5 flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-primary/10 bg-primary/[0.07]",children:o.jsx(jr,{className:"h-[18px] w-[18px] text-primary"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"max-w-[520px] truncate text-sm font-semibold text-foreground",title:Q.original_filename||Q.title,children:Q.original_filename||Q.title}),(()=>{const W=T(Q),X=Q.original_filename||Q.title||"";if(W&&W!==X){const he=W.length>70?W.substring(0,70)+"...":W;return o.jsxs("p",{className:"mt-1 flex items-center gap-1.5 text-xs text-muted-foreground",children:[o.jsx(xX,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"truncate",title:W,children:he})]})}return null})(),o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[o.jsx("span",{children:zT(Q)?Dse[(Z=Q.bib_meta)==null?void 0:Z.type]||"Book / Article":`${Q.page_count||"?"} pages`}),(Q.isbn||Q.doi)&&o.jsx("span",{className:"text-border",children:"•"}),Q.isbn?o.jsxs("span",{className:"max-w-[260px] truncate",title:`ISBN: ${Q.isbn}`,children:["ISBN ",Q.isbn]}):Q.doi?o.jsxs("span",{className:"max-w-[300px] truncate",title:`DOI: ${Q.doi}`,children:["DOI ",Q.doi]}):null]})]})]})}),o.jsx(rr,{className:"py-4 align-middle",children:V(Q.id,Q)}),o.jsx(rr,{className:"py-4 text-xs text-muted-foreground align-middle",children:B(Q.created_at)}),o.jsx(rr,{className:"py-4 pr-4 text-right align-middle",children:o.jsx(ri,{children:o.jsxs("div",{className:"flex justify-end gap-1",children:[zT(Q)?Q.external_url?o.jsx("a",{href:Q.external_url,target:"_blank",rel:"noopener noreferrer",title:"Open source link",className:"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-accent hover:text-accent-foreground",children:o.jsx(of,{className:"h-4 w-4"})}):null:o.jsxs(o.Fragment,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",onClick:()=>{ee(Q)?(A(Q),N(!0)):Ke.error("PDF URL not available")},children:o.jsx(pl,{className:"w-4 h-4"})})}),o.jsx(xr,{children:o.jsx("p",{children:"View PDF"})})]}),o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx("a",{href:ee(Q)||"#",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:W=>{ee(Q)||(W.preventDefault(),Ke.error("PDF URL not available"))},children:o.jsx(of,{className:"w-4 h-4"})})}),o.jsx(xr,{children:o.jsx("p",{children:"Open in New Tab"})})]})]}),o.jsxs(jn,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(fd,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",disabled:!e[Q.id],children:o.jsx(ua,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:e[Q.id]?"Source details":"Available after processing"})})]}),o.jsxs(pn,{className:"max-w-lg",children:[o.jsxs(mn,{children:[o.jsxs(gn,{className:"flex items-center gap-2",children:[o.jsx(xX,{className:"w-5 h-5"}),"Source Details"]}),o.jsx(og,{children:"Citation data and page numbers for this document"})]}),L.bib_meta&&(()=>{var Te,ot,wt,Ct,pr,Kt,Re,ye,Ne,Ce,Fe,yt,He;const W=L.bib_meta,X=W==null?void 0:W.google_books_data,he=W==null?void 0:W.crossref_payload,P=W==null?void 0:W.crossref_data,oe=he||P,Y=(W==null?void 0:W.method)==="manual_entry"||(W==null?void 0:W.method)==="parsed_paste",R=((Te=oe==null?void 0:oe.author)==null?void 0:Te.map(Ye=>`${Ye.given||""} ${Ye.family||""}`.trim()).join(", "))||((ot=P==null?void 0:P.authors)==null?void 0:ot.join(", ")),I=((pr=(Ct=(wt=oe==null?void 0:oe.issued)==null?void 0:wt["date-parts"])==null?void 0:Ct[0])==null?void 0:pr.join("-"))||((ye=(Re=(Kt=oe==null?void 0:oe.published)==null?void 0:Kt["date-parts"])==null?void 0:Re[0])==null?void 0:ye.join("-"))||(P==null?void 0:P.year),U=Array.isArray(oe==null?void 0:oe.title)?oe.title[0]:oe==null?void 0:oe.title,re=Array.isArray(oe==null?void 0:oe["container-title"])?oe["container-title"][0]:(oe==null?void 0:oe["container-title"])||(P==null?void 0:P.journal),ue=(oe==null?void 0:oe.page)||(P==null?void 0:P.pages),ae=((Ne=oe==null?void 0:oe.ISBN)==null?void 0:Ne[0])||((Fe=(Ce=P==null?void 0:P.crossref_metadata)==null?void 0:Ce.ISBN)==null?void 0:Fe[0]),ge=(oe==null?void 0:oe.type)||((yt=P==null?void 0:P.crossref_metadata)==null?void 0:yt.type),we=Y?W.title:(X==null?void 0:X.title)||U,ce=Y?Array.isArray(W.authors)?W.authors.join(", "):W.authors:((He=X==null?void 0:X.authors)==null?void 0:He.join(", "))||R,ne=Y?W.publisher:(X==null?void 0:X.publisher)||(oe==null?void 0:oe.publisher),fe=Y?W.published_year:(X==null?void 0:X.publishedDate)||I,be=Y?W.pages:ue||(X==null?void 0:X.pageCount),xe=Y?W.edition:null,_e=Y?W.language:null,ke=Y?W.series:null,$e=Y?W.type:ge;return o.jsxs("div",{className:"space-y-2 p-4 bg-muted/50 rounded-lg border",children:[we&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Title:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:we})]}),$e&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Type:"}),o.jsx("span",{className:"text-sm font-medium text-right capitalize",children:String($e).replace("-"," ")})]}),ce&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Author(s):"}),o.jsx("span",{className:"text-sm font-medium text-right",children:ce})]}),re&&!Y&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Journal:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:re})]}),ne&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Publisher:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:ne})]}),fe&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Published:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:fe})]}),xe&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Edition:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:xe})]}),((oe==null?void 0:oe.volume)||(oe==null?void 0:oe.issue))&&!Y&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Volume/Issue:"}),o.jsxs("span",{className:"text-sm font-medium text-right",children:[(oe==null?void 0:oe.volume)&&`Vol. ${oe.volume}`,(oe==null?void 0:oe.volume)&&(oe==null?void 0:oe.issue)&&", ",(oe==null?void 0:oe.issue)&&`Issue ${oe.issue}`]})]}),be&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Pages:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:be})]}),_e&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Language:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:_e})]}),ke&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Series:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:ke})]}),(ae||(X==null?void 0:X.isbn)||L.isbn)&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"ISBN:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:ae||(X==null?void 0:X.isbn)||L.isbn})]}),(L.doi||(oe==null?void 0:oe.DOI)||(oe==null?void 0:oe.doi))&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"DOI:"}),o.jsx("a",{href:`https://doi.org/${(L.doi||(oe==null?void 0:oe.DOI)||(oe==null?void 0:oe.doi)).replace("https://doi.org/","")}`,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-medium text-primary hover:underline text-right break-all",children:(L.doi||(oe==null?void 0:oe.DOI)||(oe==null?void 0:oe.doi)).replace("https://doi.org/","")})]}),(oe==null?void 0:oe.ISSN)&&!Y&&o.jsxs("div",{className:"flex justify-between gap-4",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"ISSN:"}),o.jsx("span",{className:"text-sm font-medium text-right",children:Array.isArray(oe.ISSN)?oe.ISSN[0]:oe.ISSN})]}),(W==null?void 0:W.method)&&o.jsxs("div",{className:"flex justify-between gap-4 pt-2 border-t border-border/50 mt-2",children:[o.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Source:"}),o.jsx(kt,{variant:"secondary",className:"text-xs",children:W.method==="manual_entry"?"Manual Entry":W.method==="parsed_paste"?"Parsed Paste":W.method==="crossref"?"CrossRef":W.method==="google_books"?"Google Books":W.method})]})]})})(),!L.bib_meta&&o.jsx("div",{className:"p-4 bg-muted/50 rounded-lg border text-center text-sm text-muted-foreground",children:"No metadata yet. Enter a DOI or ISBN below to look it up."}),o.jsx(XAt,{document:Q,userId:c==null?void 0:c.id,onUpdated:W=>$(Q.id,W)}),zT(Q)?Q.external_url&&o.jsxs("div",{className:"rounded-lg border p-3 text-sm",children:[o.jsxs("div",{className:"text-xs font-medium text-muted-foreground",children:[Dse[(J=Q.bib_meta)==null?void 0:J.type]||"Source"," link"]}),o.jsx("a",{href:Q.external_url,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline-offset-2 hover:underline",children:Q.external_url})]}):o.jsx($At,{documentId:Q.id}),o.jsx(Eo,{}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-semibold",children:"APA-7 Citation"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically detected citation for this document"})]}),q?o.jsxs("div",{className:"space-y-3",children:[o.jsx(lr,{value:b,onChange:W=>w(W.target.value),className:"min-h-[100px] text-sm",placeholder:"Edit APA citation..."}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(me,{onClick:()=>K(Q.id),size:"sm",className:"flex items-center gap-2",children:[o.jsx(A_,{className:"w-4 h-4"}),"Save"]}),o.jsxs(me,{onClick:()=>H(Q.id),size:"sm",variant:"outline",className:"flex items-center gap-2",children:[o.jsx(fn,{className:"w-4 h-4"}),"Cancel"]})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"p-4 bg-muted rounded-lg",children:o.jsx("p",{className:"text-sm leading-relaxed",children:L.citation_apa||"No citation detected yet. You can add it manually."})}),o.jsxs("div",{className:"flex gap-2",children:[L.citation_apa&&o.jsx(me,{onClick:()=>k(L.citation_apa,Q.id),variant:se?"default":"outline",className:"flex items-center gap-2",children:se?"Copied!":"Copy"}),o.jsxs(me,{onClick:()=>D(Q.id,L.citation_apa||""),variant:"outline",className:"flex items-center gap-2",children:[o.jsx(HW,{className:"w-4 h-4"}),L.citation_apa?"Edit":"Add citation"]})]})]})]})]})]}),o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",onClick:()=>l(`/reference-checker?document=${Q.id}`),children:o.jsx(uc,{className:"w-4 h-4"})})}),o.jsx(xr,{children:o.jsx("p",{children:"Open in Citation Manager"})})]}),o.jsxs(Mi,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:ie,children:ie?o.jsx(Ei,{className:"w-4 h-4 animate-spin"}):o.jsx(Pi,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"Delete"})})]}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Document"}),o.jsxs(hi,{children:['Are you sure you want to delete "',Q.original_filename||Q.title,'"? This action cannot be undone.']})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>M(Q.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},Q.id)})})]})}),z>1&&o.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border/60 bg-card px-4 py-3",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:[F,"-",G," of ",i," Documents"]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(me,{variant:"outline",size:"sm",onClick:()=>a(n-1),disabled:n===1,children:"Back"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>a(n+1),disabled:n===z,children:"Next"})]})]}),o.jsx(IAt,{open:j,onClose:()=>N(!1),pdfUrl:C&&p[C.id]||null,title:(C==null?void 0:C.title)||(C==null?void 0:C.original_filename)||"PDF Document",pageOffset:(C==null?void 0:C.page_offset)??null,writingLanguage:d})]})}function ZAt({methods:t,onMethodDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){const{userProfile:a}=Ht(),[l,c]=S.useState(new Set),[u,d]=S.useState({});S.useEffect(()=>{H9(t,"summaries").then(d)},[t]);const h=async w=>{c(j=>new Set(j).add(w));try{const{error:j}=await pe.from("methods").delete().eq("id",w).eq("user_id",a==null?void 0:a.id);if(j)throw j;Ke.success("Methodology deleted successfully"),e()}catch(j){console.error("Delete error:",j),Ke.error("Error deleting. Please try again.")}finally{c(j=>{const N=new Set(j);return N.delete(w),N})}},f=async w=>{try{await navigator.clipboard.writeText(w),Ke.success("Copied to clipboard")}catch{Ke.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 j,N;return((j=w.documents)==null?void 0:j.title)||((N=w.documents)==null?void 0:N.original_filename)||w.title||"Unknown Document"},y=w=>{switch(w){case"small":return"Short";case"medium":return"Medium";case"big":return"Long";default:return"Methods"}},x=Math.ceil(s/n),v=(r-1)*n+1,b=Math.min(r*n,s);return o.jsxs("div",{className:"space-y-4",children:[o.jsxs(_d,{children:[o.jsx(Nd,{children:o.jsxs(fi,{children:[o.jsx(tr,{children:"Title"}),o.jsx(tr,{children:"Document Sources"}),o.jsx(tr,{children:"Mode"}),o.jsx(tr,{children:"Date"}),o.jsx(tr,{className:"text-right",children:"Actions"})]})}),o.jsx(kd,{children:t.map(w=>{var C;const j=l.has(w.id),N=m(w);return o.jsxs(fi,{children:[o.jsx(rr,{children:o.jsxs("div",{className:"flex items-center space-x-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:o.jsx(jr,{className:"w-4 h-4 text-primary"})}),o.jsx("div",{children:o.jsx("p",{className:"font-medium text-sm",children:w.title||"Methods & Approach"})})]})}),o.jsx(rr,{className:"text-muted-foreground",children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-medium",children:g(w)}),o.jsxs("span",{className:"text-xs",children:[((C=w.documents)==null?void 0:C.page_count)||"?"," Pages"]})]})}),o.jsx(rr,{children:o.jsx(kt,{variant:"outline",children:y(w.mode||"")})}),o.jsx(rr,{className:"text-muted-foreground",children:p(w.created_at)}),o.jsx(rr,{className:"text-right",children:o.jsx(ri,{children:o.jsxs("div",{className:"flex justify-end space-x-2",children:[o.jsxs(jn,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(fd,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:o.jsx(pl,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"View Text"})})]}),o.jsxs(pn,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[o.jsx(mn,{children:o.jsx(gn,{children:"Methodology"})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[o.jsx("h3",{className:"font-semibold mb-2",children:w.title||"Methods & Approach"}),o.jsxs("p",{className:"text-sm text-muted-foreground",children:["Document: ",g(w)," | Mode: ",y(w.mode||"")," | Created: ",p(w.created_at)]})]}),o.jsx("div",{className:"prose max-w-none",children:o.jsx("div",{className:"whitespace-pre-wrap",children:w.method_text||""})}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(me,{onClick:()=>f(w.method_text||""),className:"flex items-center space-x-2",children:[o.jsx(ws,{className:"w-4 h-4"}),o.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),N&&o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",onClick:()=>window.open(N,"_blank"),children:o.jsx(of,{className:"w-4 h-4"})})}),o.jsx(xr,{children:o.jsx("p",{children:"Open PDF"})})]}),o.jsxs(Mi,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:j,children:j?o.jsx(Ei,{className:"w-4 h-4 animate-spin"}):o.jsx(Pi,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"Delete"})})]}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Methodology"}),o.jsx(hi,{children:"Are you sure you want to delete this methodology? This action cannot be undone."})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>h(w.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},w.id)})})]}),x>1&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:[v,"-",b," of ",s," Methodology Entries"]}),o.jsxs("div",{className:"flex space-x-2",children:[o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===x,children:"Next"})]})]})]})}function Fse(t){return!t||!t.length?"- –":t.map(e=>`- ${e}`).join(`
`)}function Bse(t){if(!t)return"";const e=t.intro?`${t.intro}

`:"",r=(t.questions??[]).map((n,s)=>{const i=(n.probes??[]).map(l=>`    - ${l}`).join(`
`),a=n.maps_to_rq?` *(zu ${n.maps_to_rq})*`:"";return`${s+1}. **${n.question}**${a}
${i?`
${i}
`:""}`}).join(`

`);return`${e}${r}`}function JAt(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(l=>`- ${l}`).join(`
`);return[`# ${i}`,"",`**Objective:** ${e.aim??"–"}`,`**Degree:** ${e.degree??"–"} | **Discipline:** ${e.discipline??"–"} | **Language:** ${e.language??"–"}`,"","## Research Questions",a||"- –","","## Guidelines: Participant Interviews",Bse(r)||"- –","","## Guidelines: Expert Interviews",Bse(n)||"- –","","## Sampling & Criteria",`**Sampling-Strategy**
${s.sampling??"–"}`,"",`**Inclusion Criteria**
${Fse(s.inclusion)}`,"",`**Exclusion Criteria**
${Fse(s.exclusion)}`,"","## Ethics",s.ethics??"–","","## Piloting",s.pilot??"–"].join(`
`)}function eTt(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 LNe(t,e){var r,n,s,i,a;if(e==="research_setup")try{if(t.trim().startsWith("#"))return t;const l=JSON.parse(t);return JAt(l)}catch(l){return console.error("Failed to parse research setup data:",l),t||"Error displaying research setup data"}if(e==="topic_explorer")try{if(t.trim().startsWith("#"))return t;const l=JSON.parse(t);let c=`# ${l.title}

`;return l.introduction&&(c+=`## Introduction
${l.introduction}

`),l.problem&&(c+=`## Problem Statement
${l.problem}

`),l.objectives&&(c+=`## Objectives
${l.objectives}

`),(n=(r=l.original_selection)==null?void 0:r.researchQuestions)!=null&&n.length&&(c+=`## Research Questions?
`,l.original_selection.researchQuestions.forEach((u,d)=>{c+=`${d+1}. ${u}
`}),c+=`
`),(s=l.original_selection)!=null&&s.method&&(c+=`## Methodology
${l.original_selection.method}

`),(a=(i=l.original_selection)==null?void 0:i.sources)!=null&&a.length&&(c+=`## Literature Recommendations
`,l.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(l){return console.error("Failed to parse topic explorer data:",l),t||"Error displaying topic explorer data"}if(e==="thesis_builder"||e==="theory"||e==="paragraph"||e==="outline")try{if(t.trim().startsWith("#"))return t;const l=JSON.parse(t);return eTt(l)}catch(l){return console.warn("Could not parse thesis builder data:",l),t||"No content available"}return t||"No text available"}const tTt=({theories:t,onTheoryDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i})=>{const{userProfile:a}=Ht(),[l,c]=S.useState(new Set),[u,d]=S.useState({});S.useEffect(()=>{H9(t,"summaries").then(d)},[t]);const h=async w=>{c(j=>new Set(j).add(w));try{const{error:j}=await pe.from("theory_backgrounds").delete().eq("id",w).eq("user_id",a==null?void 0:a.id);if(j)throw j;Ke.success("Theory/Background deleted successfully"),e()}catch(j){console.error("Delete error:",j),Ke.error("Error deleting. Please try again.")}finally{c(j=>{const N=new Set(j);return N.delete(w),N})}},f=async w=>{try{await navigator.clipboard.writeText(w),Ke.success("Copied to clipboard")}catch{Ke.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 j,N;return((j=w.documents)==null?void 0:j.title)||((N=w.documents)==null?void 0:N.original_filename)||"Unknown Document"},y=w=>{if(!w||w==="theory")return"Theory & Background";switch(w){case"paragraph":return"Paragraph";case"outline":return"Outline";default:return w}},x=Math.ceil(s/n),v=(r-1)*n+1,b=Math.min(r*n,s);return o.jsxs("div",{className:"space-y-4",children:[o.jsxs(_d,{children:[o.jsx(Nd,{children:o.jsxs(fi,{children:[o.jsx(tr,{children:"Name"}),o.jsx(tr,{children:"Document Sources"}),o.jsx(tr,{children:"Mode"}),o.jsx(tr,{children:"Date"}),o.jsx(tr,{className:"text-right",children:"Actions"})]})}),o.jsx(kd,{children:t.map(w=>{var C;const j=l.has(w.id),N=m(w);return o.jsxs(fi,{children:[o.jsx(rr,{children:o.jsxs("div",{className:"flex items-center space-x-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:o.jsx(jr,{className:"w-4 h-4 text-primary"})}),o.jsx("div",{children:o.jsx("p",{className:"font-medium text-sm",children:w.title||"Theory & Background"})})]})}),o.jsx(rr,{className:"text-muted-foreground",children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-medium",children:g(w)}),o.jsxs("span",{className:"text-xs",children:[((C=w.documents)==null?void 0:C.page_count)||"?"," Pages"]})]})}),o.jsx(rr,{children:o.jsx(kt,{variant:"outline",children:y(w.mode)})}),o.jsx(rr,{className:"text-muted-foreground",children:p(w.created_at)}),o.jsx(rr,{className:"text-right",children:o.jsx(ri,{children:o.jsxs("div",{className:"flex justify-end space-x-2",children:[o.jsxs(jn,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(fd,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:o.jsx(pl,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"View Text"})})]}),o.jsxs(pn,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[o.jsx(mn,{children:o.jsx(gn,{children:"Theory & Background"})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[o.jsx("h3",{className:"font-semibold mb-2",children:w.title||"Theory & Background"}),o.jsxs("p",{className:"text-sm text-muted-foreground",children:["Document: ",g(w)," | Mode: ",y(w.mode)," | Created: ",p(w.created_at)]})]}),o.jsx("div",{className:"prose max-w-none",children:o.jsx("div",{className:"whitespace-pre-wrap",children:LNe(w.theory_text||"",w.mode||"theory")})}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(me,{onClick:()=>f(w.theory_text||""),className:"flex items-center space-x-2",children:[o.jsx(ws,{className:"w-4 h-4"}),o.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),N&&o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",onClick:()=>window.open(N,"_blank"),children:o.jsx(of,{className:"w-4 h-4"})})}),o.jsx(xr,{children:o.jsx("p",{children:"Open PDF"})})]}),o.jsxs(Mi,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:j,children:j?o.jsx(Ei,{className:"w-4 h-4 animate-spin"}):o.jsx(Pi,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"Delete"})})]}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Theory/Background"}),o.jsx(hi,{children:"Are you sure you want to delete this Theory/Background? This action cannot be undone."})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>h(w.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},w.id)})})]}),x>1&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:[v,"-",b," of ",s," Theory & Background"]}),o.jsxs("div",{className:"flex space-x-2",children:[o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===x,children:"Next"})]})]})]})},rTt=({analyses:t,onAnalysisDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i})=>{const{userProfile:a}=Ht(),[l,c]=S.useState(new Set),u=async x=>{c(v=>new Set(v).add(x));try{const{error:v}=await pe.from("analysis_results").delete().eq("id",x).eq("user_id",a==null?void 0:a.id);if(v)throw v;Ke.success("Analysis deleted successfully"),e()}catch(v){console.error("Delete error:",v),Ke.error("Error deleting. Please try again.")}finally{c(v=>{const b=new Set(v);return b.delete(x),b})}},d=x=>new Date(x).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),h=x=>{switch(x){case"small":return"Short";case"medium":return"Medium";case"big":return"Long";default:return x||"–"}},f=x=>{var v;return((v=x.categories)==null?void 0:v.category_title)||"No Category"},p=x=>{var v;return((v=x.codebooks)==null?void 0:v.title)||"No Codebook"},m=Math.ceil(s/n),g=(r-1)*n+1,y=Math.min(r*n,s);return o.jsxs("div",{className:"space-y-4",children:[o.jsxs(_d,{children:[o.jsx(Nd,{children:o.jsxs(fi,{children:[o.jsx(tr,{children:"Name"}),o.jsx(tr,{children:"Codebook"}),o.jsx(tr,{children:"Mode"}),o.jsx(tr,{children:"Date"}),o.jsx(tr,{className:"text-right",children:"Actions"})]})}),o.jsx(kd,{children:t.map(x=>{var b;const v=l.has(x.id);return o.jsxs(fi,{children:[o.jsx(rr,{children:o.jsxs("div",{className:"flex items-center space-x-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:o.jsx(jr,{className:"w-4 h-4 text-primary"})}),o.jsx("div",{children:o.jsx("p",{className:"font-medium text-sm",children:f(x)})})]})}),o.jsx(rr,{className:"text-muted-foreground text-sm",children:p(x)}),o.jsx(rr,{children:o.jsx(kt,{variant:"outline",children:h(x.mode)})}),o.jsx(rr,{className:"text-muted-foreground",children:d(x.created_at)}),o.jsx(rr,{className:"text-right",children:o.jsx(ri,{children:o.jsxs("div",{className:"flex justify-end space-x-2",children:[o.jsxs(jn,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(fd,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:o.jsx(pl,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"View Analysis"})})]}),o.jsxs(pn,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[o.jsx(mn,{children:o.jsx(gn,{children:"Qualitative Analysis"})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[o.jsx("h3",{className:"font-semibold mb-2",children:f(x)}),o.jsxs("p",{className:"text-sm text-muted-foreground",children:["Codebook: ",p(x)," | Mode: ",h(x.mode)," | Created: ",d(x.created_at)]})]}),o.jsx("div",{className:"prose max-w-none",children:o.jsx("div",{className:"whitespace-pre-wrap",children:x.result_text||"No content available"})}),((b=x.categories)==null?void 0:b.category_conclusion)&&o.jsxs(o.Fragment,{children:[o.jsx("hr",{className:"my-6 border-border"}),o.jsxs("div",{className:"prose max-w-none",children:[o.jsxs("p",{className:"font-bold underline mb-2",children:["Fazit Kategorie: ",x.categories.category_title]}),o.jsx("p",{className:"whitespace-pre-wrap",children:x.categories.category_conclusion})]})]})]})]})]}),o.jsxs(Mi,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:v,children:v?o.jsx(Ei,{className:"w-4 h-4 animate-spin"}):o.jsx(Pi,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"Delete"})})]}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Analysis"}),o.jsx(hi,{children:"Are you sure you want to delete this analysis? This action cannot be undone."})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>u(x.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},x.id)})})]}),m>1&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:[g,"-",y," of ",s," Analyses"]}),o.jsxs("div",{className:"flex space-x-2",children:[o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===m,children:"Next"})]})]})]})};function nTt({topics:t,onTopicDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){Ht();const[a,l]=S.useState(new Set),c=async m=>{l(g=>new Set(g).add(m));try{const{error:g}=await pe.from("topic_explorations").delete().eq("id",m);if(g)throw g;Ke.success("Topic exploration deleted successfully"),e()}catch(g){console.error("Delete error:",g),Ke.error("Error deleting. Please try again.")}finally{l(g=>{const y=new Set(g);return y.delete(m),y})}},u=async m=>{var y,x,v,b,w,j,N,C;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}

`),(y=m.outline_json)!=null&&y.chapters&&(g+=`## Outline
`,m.outline_json.chapters.forEach(A=>{g+=`${A.number}. ${A.title}
`,A.subchapters&&A.subchapters.forEach(E=>{g+=`   ${E.number} ${E.title}
`})}),g+=`
`),(x=m.keywords_json)!=null&&x.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(A=>{g+=`- ${A.combination} (${A.purpose})
`}),g+=`
`),(j=m.keywords_json)!=null&&j.database_suggestions&&(g+=`## Recommended Databases
${m.keywords_json.database_suggestions.join(", ")}

`),(N=m.keywords_json)!=null&&N.known_authors&&(g+=`## Known Authors
`,m.keywords_json.known_authors.forEach(A=>{g+=`- ${A.name}: ${A.relevance}
`}),g+=`
`),(C=m.keywords_json)!=null&&C.known_works&&(g+=`## Known Works
`,m.keywords_json.known_works.forEach(A=>{g+=`- ${A.title} (${A.author}${A.year?`, ${A.year}`:""})
`}),g+=`
`);try{await navigator.clipboard.writeText(g.trim()),Ke.success("Copied to clipboard")}catch{Ke.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 o.jsxs("div",{className:"space-y-4",children:[o.jsxs(_d,{children:[o.jsx(Nd,{children:o.jsxs(fi,{children:[o.jsx(tr,{children:"Name"}),o.jsx(tr,{children:"Source"}),o.jsx(tr,{children:"Language"}),o.jsx(tr,{children:"Date"}),o.jsx(tr,{className:"text-right",children:"Actions"})]})}),o.jsx(kd,{children:t.map(m=>{var y,x,v,b,w,j,N,C,A,E;const g=a.has(m.id);return o.jsxs(fi,{children:[o.jsx(rr,{children:o.jsxs("div",{className:"flex items-center space-x-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:o.jsx(dd,{className:"w-4 h-4 text-primary"})}),o.jsx("div",{children:o.jsx("p",{className:"font-medium text-sm",children:m.title||"Untitled Topic"})})]})}),o.jsx(rr,{children:o.jsx(kt,{variant:"secondary",children:m.feature_type==="outline"?"Outline":m.feature_type==="keywords"?"Literature Keywords":"Topic Ideas"})}),o.jsx(rr,{children:o.jsx(kt,{variant:"outline",children:m.language||"DE"})}),o.jsx(rr,{className:"text-muted-foreground",children:d(m.created_at)}),o.jsx(rr,{className:"text-right",children:o.jsx(ri,{children:o.jsxs("div",{className:"flex justify-end space-x-2",children:[o.jsxs(jn,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(fd,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:o.jsx(pl,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"View"})})]}),o.jsxs(pn,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[o.jsx(mn,{children:o.jsx(gn,{children:m.title})}),o.jsxs("div",{className:"space-y-6",children:[m.feature_type&&o.jsx(kt,{variant:"secondary",className:"mb-2",children:m.feature_type==="outline"?"Thesis Outline":m.feature_type==="keywords"?"Literature Keywords":"Topic Ideas"}),m.introduction&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Introduction"}),o.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:m.introduction})]}),m.problem_statement&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Problem Statement"}),o.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:m.problem_statement})]}),m.objectives&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Objectives"}),o.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&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Research Questions"}),o.jsx("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground",children:m.research_questions.map((O,$)=>o.jsx("li",{children:O},$))})]}),m.method&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Methodology"}),o.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:m.method})]}),((y=m.outline_json)==null?void 0:y.chapters)&&m.outline_json.chapters.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Thesis Outline"}),m.outline_json.estimated_pages&&o.jsxs("p",{className:"text-sm text-muted-foreground mb-3",children:["Estimated pages: ",m.outline_json.estimated_pages]}),o.jsx("div",{className:"space-y-3",children:m.outline_json.chapters.map((O,$)=>o.jsxs("div",{className:"border rounded-lg p-3",children:[o.jsxs("span",{className:"font-medium",children:[O.number,". ",O.title]}),O.subchapters&&O.subchapters.length>0&&o.jsx("div",{className:"ml-4 mt-2 space-y-1 border-l-2 pl-3",children:O.subchapters.map((T,M)=>o.jsxs("div",{className:"text-sm text-muted-foreground",children:[T.number," ",T.title]},M))})]},$))}),m.outline_json.notes&&o.jsx("p",{className:"text-sm text-muted-foreground mt-3 italic",children:m.outline_json.notes})]}),((x=m.keywords_json)==null?void 0:x.primary_keywords)&&m.keywords_json.primary_keywords.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Primary Keywords"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.primary_keywords.map((O,$)=>o.jsx(kt,{variant:"secondary",children:O},$))})]}),((v=m.keywords_json)==null?void 0:v.german_equivalents)&&m.keywords_json.german_equivalents.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"German Keywords"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.german_equivalents.map((O,$)=>o.jsx(kt,{variant:"outline",children:O},$))})]}),((b=m.keywords_json)==null?void 0:b.english_equivalents)&&m.keywords_json.english_equivalents.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"English Keywords"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.english_equivalents.map((O,$)=>o.jsx(kt,{variant:"outline",children:O},$))})]}),((w=m.keywords_json)==null?void 0:w.alternative_terms)&&m.keywords_json.alternative_terms.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Alternative Terms"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.alternative_terms.map((O,$)=>o.jsx(kt,{variant:"outline",children:O},$))})]}),((j=m.keywords_json)==null?void 0:j.keyword_combinations)&&m.keywords_json.keyword_combinations.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Search Combinations"}),o.jsx("div",{className:"space-y-2",children:m.keywords_json.keyword_combinations.map((O,$)=>o.jsxs("div",{className:"border rounded p-2",children:[o.jsx("code",{className:"text-sm font-mono bg-muted px-1 rounded",children:O.combination}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:O.purpose})]},$))})]}),((N=m.keywords_json)==null?void 0:N.database_suggestions)&&m.keywords_json.database_suggestions.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Recommended Databases"}),o.jsx("div",{className:"flex flex-wrap gap-2",children:m.keywords_json.database_suggestions.map((O,$)=>o.jsx(kt,{variant:"outline",children:O},$))})]}),((C=m.keywords_json)==null?void 0:C.known_authors)&&m.keywords_json.known_authors.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Known Authors"}),o.jsx("div",{className:"space-y-2",children:m.keywords_json.known_authors.map((O,$)=>o.jsxs("div",{className:"text-sm",children:[o.jsx("span",{className:"font-medium",children:O.name}),o.jsxs("span",{className:"text-muted-foreground",children:[" - ",O.relevance]})]},$))})]}),((A=m.keywords_json)==null?void 0:A.known_works)&&m.keywords_json.known_works.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Known Works"}),o.jsx("div",{className:"space-y-2",children:m.keywords_json.known_works.map((O,$)=>o.jsxs("div",{className:"text-sm border rounded p-2",children:[o.jsx("span",{className:"font-medium",children:O.title}),O.year&&o.jsxs("span",{className:"text-muted-foreground",children:[" (",O.year,")"]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:O.author}),o.jsx("p",{className:"text-xs text-muted-foreground italic mt-1",children:O.relevance})]},$))})]}),((E=m.keywords_json)==null?void 0:E.search_tips)&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Search Tips"}),o.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&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Known Sources"}),o.jsx("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground",children:m.known_sources_json.map((O,$)=>o.jsx("li",{children:O.citation||O.title||JSON.stringify(O)},$))})]}),m.sources&&Array.isArray(m.sources)&&m.sources.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Sources"}),o.jsx("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground",children:m.sources.map((O,$)=>o.jsxs("li",{children:[O.title,O.doi&&o.jsxs("span",{className:"text-xs ml-2",children:["DOI: ",O.doi]}),O.isbn&&o.jsxs("span",{className:"text-xs ml-2",children:["ISBN: ",O.isbn]})]},$))})]}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(me,{onClick:()=>u(m),className:"flex items-center space-x-2",children:[o.jsx(ws,{className:"w-4 h-4"}),o.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),o.jsxs(Mi,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:g,children:g?o.jsx(Ei,{className:"w-4 h-4 animate-spin"}):o.jsx(Pi,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"Delete"})})]}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Topic Exploration"}),o.jsx(hi,{children:"Are you sure you want to delete this topic exploration? This action cannot be undone."})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>c(m.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},m.id)})})]}),h>1&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:[f,"-",p," of ",s," Topics"]}),o.jsxs("div",{className:"flex space-x-2",children:[o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===h,children:"Next"})]})]})]})}function sTt({setups:t,onSetupDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){Ht();const[a,l]=S.useState(new Set),c=async g=>{l(y=>new Set(y).add(g));try{const{error:y}=await pe.from("research_setups").delete().eq("id",g);if(y)throw y;Ke.success("Research setup deleted successfully"),e()}catch(y){console.error("Delete error:",y),Ke.error("Error deleting. Please try again.")}finally{l(y=>{const x=new Set(y);return x.delete(g),x})}},u=async g=>{const y=g.markdown_text||g.title;try{await navigator.clipboard.writeText(y),Ke.success("Copied to clipboard")}catch{Ke.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 o.jsxs("div",{className:"space-y-4",children:[o.jsxs(_d,{children:[o.jsx(Nd,{children:o.jsxs(fi,{children:[o.jsx(tr,{children:"Name"}),o.jsx(tr,{children:"Language"}),o.jsx(tr,{children:"Discipline"}),o.jsx(tr,{children:"Date"}),o.jsx(tr,{className:"text-right",children:"Actions"})]})}),o.jsx(kd,{children:t.map(g=>{var x;const y=a.has(g.id);return o.jsxs(fi,{children:[o.jsx(rr,{children:o.jsxs("div",{className:"flex items-center space-x-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:o.jsx(Yhe,{className:"w-4 h-4 text-primary"})}),o.jsx("div",{children:o.jsx("p",{className:"font-medium text-sm",children:g.title||"Untitled Setup"})})]})}),o.jsx(rr,{children:o.jsx(kt,{variant:"outline",children:((x=g.language)==null?void 0:x.toUpperCase())||"N/A"})}),o.jsx(rr,{className:"text-muted-foreground",children:g.discipline||"N/A"}),o.jsx(rr,{className:"text-muted-foreground",children:d(g.created_at)}),o.jsx(rr,{className:"text-right",children:o.jsx(ri,{children:o.jsxs("div",{className:"flex justify-end space-x-2",children:[o.jsxs(jn,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(fd,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:o.jsx(pl,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"View"})})]}),o.jsxs(pn,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[o.jsx(mn,{children:o.jsx(gn,{children:g.title})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex gap-2 flex-wrap",children:[o.jsx(kt,{variant:"secondary",children:h(g.degree)}),g.discipline&&o.jsx(kt,{variant:"outline",children:g.discipline}),g.language&&o.jsx(kt,{variant:"outline",children:g.language.toUpperCase()})]}),g.markdown_text?o.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:o.jsx(rc,{children:g.markdown_text})}):o.jsxs("div",{className:"space-y-4",children:[g.aim&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Research Aim"}),o.jsx("p",{className:"text-muted-foreground",children:g.aim})]}),g.derived_research_questions&&Array.isArray(g.derived_research_questions)&&o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold mb-2",children:"Research Questions"}),o.jsx("ul",{className:"list-disc list-inside space-y-1 text-muted-foreground",children:g.derived_research_questions.map((v,b)=>o.jsx("li",{children:v},b))})]})]}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(me,{onClick:()=>u(g),className:"flex items-center space-x-2",children:[o.jsx(ws,{className:"w-4 h-4"}),o.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),o.jsxs(Mi,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:y,children:y?o.jsx(Ei,{className:"w-4 h-4 animate-spin"}):o.jsx(Pi,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"Delete"})})]}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Research Setup"}),o.jsx(hi,{children:"Are you sure you want to delete this research setup? This action cannot be undone."})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>c(g.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},g.id)})})]}),f>1&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:[p,"-",m," of ",s," Setups"]}),o.jsxs("div",{className:"flex space-x-2",children:[o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===f,children:"Next"})]})]})]})}function iTt({discussions:t,onDiscussionDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){const{user:a}=Ht(),[l,c]=S.useState(new Set),u=async y=>{c(x=>new Set(x).add(y));try{const{error:x}=await pe.from("results_discussions").delete().eq("id",y).eq("user_id",a==null?void 0:a.id);if(x)throw x;Ke.success("Discussion deleted successfully"),e()}catch(x){console.error("Delete error:",x),Ke.error("Error deleting. Please try again.")}finally{c(x=>{const v=new Set(x);return v.delete(y),v})}},d=async y=>{try{await navigator.clipboard.writeText(y),Ke.success("Copied to clipboard")}catch{Ke.error("Error copying")}},h=y=>new Date(y).toLocaleDateString("en-US",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}),f=y=>{switch(y){case"de":return"DE";case"en":return"EN";default:return(y==null?void 0:y.toUpperCase())||"N/A"}},p=Math.ceil(s/n),m=(r-1)*n+1,g=Math.min(r*n,s);return o.jsxs("div",{className:"space-y-4",children:[o.jsxs(_d,{children:[o.jsx(Nd,{children:o.jsxs(fi,{children:[o.jsx(tr,{children:"Name"}),o.jsx(tr,{children:"Language"}),o.jsx(tr,{children:"Date"}),o.jsx(tr,{className:"text-right",children:"Actions"})]})}),o.jsx(kd,{children:t.map(y=>{const x=l.has(y.id);return o.jsxs(fi,{children:[o.jsx(rr,{children:o.jsxs("div",{className:"flex items-center space-x-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:o.jsx(HM,{className:"w-4 h-4 text-primary"})}),o.jsx("div",{children:o.jsx("p",{className:"font-medium text-sm",children:y.title||"Discussion"})})]})}),o.jsx(rr,{children:o.jsx(kt,{variant:"outline",children:f(y.language)})}),o.jsx(rr,{className:"text-muted-foreground",children:h(y.created_at)}),o.jsx(rr,{className:"text-right",children:o.jsx(ri,{children:o.jsxs("div",{className:"flex justify-end space-x-2",children:[o.jsxs(jn,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(fd,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:o.jsx(pl,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"View Text"})})]}),o.jsxs(pn,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[o.jsx(mn,{children:o.jsx(gn,{children:"Discussion"})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[o.jsx("h3",{className:"font-semibold mb-2",children:y.title||"Discussion"}),o.jsxs("p",{className:"text-sm text-muted-foreground",children:["Language: ",f(y.language)," | Created: ",h(y.created_at)]})]}),o.jsx("div",{className:"prose max-w-none",children:o.jsx(rc,{children:y.discussion_text||""})}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(me,{onClick:()=>d(y.discussion_text||""),className:"flex items-center space-x-2",children:[o.jsx(ws,{className:"w-4 h-4"}),o.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),o.jsxs(Mi,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:x,children:x?o.jsx(Ei,{className:"w-4 h-4 animate-spin"}):o.jsx(Pi,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"Delete"})})]}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Discussion"}),o.jsx(hi,{children:"Are you sure you want to delete this discussion? This action cannot be undone."})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>u(y.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},y.id)})})]}),p>1&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:[m,"-",g," of ",s," Discussions"]}),o.jsxs("div",{className:"flex space-x-2",children:[o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===p,children:"Next"})]})]})]})}function aTt({codings:t,onCodingDeleted:e,currentPage:r,itemsPerPage:n,totalItems:s,onPageChange:i}){const[a,l]=S.useState(new Set),c=async m=>{l(g=>new Set(g).add(m));try{const{error:g}=await pe.from("coding_results").delete().eq("id",m);if(g)throw g;Ke.success("Coding deleted successfully"),e()}catch(g){console.error("Delete error:",g),Ke.error("Error deleting. Please try again.")}finally{l(g=>{const y=new Set(g);return y.delete(m),y})}},u=async m=>{const g=m.result_text||m.title||"";try{await navigator.clipboard.writeText(g),Ke.success("Copied to clipboard")}catch{Ke.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 o.jsxs("div",{className:"space-y-4",children:[o.jsxs(_d,{children:[o.jsx(Nd,{children:o.jsxs(fi,{children:[o.jsx(tr,{children:"Name"}),o.jsx(tr,{children:"Interviews"}),o.jsx(tr,{children:"Date"}),o.jsx(tr,{className:"text-right",children:"Actions"})]})}),o.jsx(kd,{children:t.map(m=>{var y,x,v;const g=a.has(m.id);return o.jsxs(fi,{children:[o.jsx(rr,{children:o.jsxs("div",{className:"flex items-center space-x-3",children:[o.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center",children:o.jsx(Xhe,{className:"w-4 h-4 text-primary"})}),o.jsx("p",{className:"font-medium text-sm",children:m.title||"Untitled Coding"})]})}),o.jsx(rr,{className:"text-muted-foreground text-sm",children:((y=m.interviews)==null?void 0:y.title)||"–"}),o.jsx(rr,{className:"text-muted-foreground",children:d(m.created_at)}),o.jsx(rr,{className:"text-right",children:o.jsx(ri,{children:o.jsxs("div",{className:"flex justify-end space-x-2",children:[o.jsxs(jn,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(fd,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",className:"w-8 h-8 p-0",children:o.jsx(pl,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"View"})})]}),o.jsxs(pn,{className:"max-w-4xl max-h-[80vh] overflow-auto",children:[o.jsx(mn,{children:o.jsx(gn,{children:m.title||"Coding Result"})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex gap-2 flex-wrap",children:[((x=m.codebooks)==null?void 0:x.title)&&o.jsx(kt,{variant:"secondary",children:m.codebooks.title}),((v=m.interviews)==null?void 0:v.title)&&o.jsx(kt,{variant:"outline",children:m.interviews.title}),m.language&&o.jsx(kt,{variant:"outline",children:m.language.toUpperCase()}),o.jsxs(kt,{variant:"outline",children:[m.created_segments??0," Segments"]})]}),m.result_text?o.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:o.jsx(rc,{children:m.result_text})}):o.jsx("p",{className:"text-muted-foreground",children:"No content available."}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(me,{onClick:()=>u(m),className:"flex items-center space-x-2",children:[o.jsx(ws,{className:"w-4 h-4"}),o.jsx("span",{children:"Copy to Clipboard"})]})})]})]})]}),o.jsxs(Mi,{children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"w-8 h-8 p-0 text-destructive hover:text-destructive",disabled:g,children:g?o.jsx(Ei,{className:"w-4 h-4 animate-spin"}):o.jsx(Pi,{className:"w-4 h-4"})})})}),o.jsx(xr,{children:o.jsx("p",{children:"Delete"})})]}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Coding"}),o.jsx(hi,{children:"Are you sure you want to delete this coding result? This action cannot be undone."})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>c(m.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})})]},m.id)})})]}),h>1&&o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:[f,"-",p," of ",s," Codings"]}),o.jsxs("div",{className:"flex space-x-2",children:[o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r-1),disabled:r===1,children:"Back"}),o.jsx(me,{variant:"outline",size:"sm",onClick:()=>i(r+1),disabled:r===h,children:"Next"})]})]})]})}function oTt({onDocumentUploaded:t}){const{userProfile:e}=Ht(),[r,n]=S.useState(!1),[s,i]=S.useState("idle"),[a,l]=S.useState(null),[c,u]=S.useState(!1),d=S.useRef(null);function h(j){return j.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=j=>{if(j.type!=="application/pdf")return"Only PDF files are allowed.";const N=50*1024*1024;return j.size>N?"The file is too large. The maximum allowed size is 50MB.":j.size<1024?"The file is too small. At least 1KB is required.":null},p=S.useCallback(j=>{const N=f(j);if(N){Ke.error(N);return}l(j)},[]),m=S.useCallback(j=>{j.preventDefault(),j.stopPropagation()},[]),g=S.useCallback(j=>{j.preventDefault(),j.stopPropagation(),u(!0)},[]),y=S.useCallback(j=>{j.preventDefault(),j.stopPropagation(),u(!1)},[]),x=S.useCallback(j=>{j.preventDefault(),j.stopPropagation(),u(!1);const N=j.dataTransfer.files;N&&N[0]&&p(N[0])},[p]),v=j=>{var C;const N=(C=j.target.files)==null?void 0:C[0];N&&p(N)},b=()=>{l(null),d.current&&(d.current.value="")},w=async()=>{if(!(!a||!e||r)){n(!0),i("uploading");try{const j=a.name,N=h(j)||"dokument",C=`${Date.now()}-${N}.pdf`,A=`${e.id}/${C}`,{error:E}=await vn.storage.from("documents").upload(A,a,{cacheControl:"3600",upsert:!1});if(E)throw E;const{data:O,error:$}=await vn.from("documents").insert({user_id:e.id,title:N,original_filename:j,storage_path:A,page_count:null}).select().single();if($)throw await vn.storage.from("documents").remove([A]),$;i("extracting");const T=vn.functions.invoke("ingest_document",{body:{document_id:O.id}}).catch(D=>console.error("ingest_document call failed",D)),M=vn.functions.invoke("pdf_extract",{body:{document_id:O.id,overwrite:!0,also_block:!1}}).catch(D=>console.error("pdf_extract call failed",D)),k=vn.functions.invoke("detect_bibliography",{body:{document_id:O.id}}).catch(D=>console.error("detect_bibliography call failed",D));await Promise.all([T,M,k]),Ke.success("PDF successfully uploaded and extracted!"),l(null),d.current&&(d.current.value=""),t()}catch(j){console.error("Upload error:",j),Ke.error("Error uploading. Please try again.")}finally{n(!1),i("idle")}}};return o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:`
        relative flex min-h-[88px] items-center gap-4 rounded-xl border border-dashed px-4 py-3
        transition-all duration-200
        ${c?"border-primary bg-primary/[0.04]":a?"border-emerald-300 bg-emerald-50/50 dark:border-emerald-900 dark:bg-emerald-950/20":"border-border hover:border-primary/40 hover:bg-muted/20"}
        ${r?"pointer-events-none opacity-50":"cursor-pointer"}
      `,onDragEnter:g,onDragLeave:y,onDragOver:m,onDrop:x,onClick:()=>{var j;return!a&&((j=d.current)==null?void 0:j.click())},children:[a?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-emerald-500/10",children:o.jsx(uc,{className:"h-5 w-5 text-emerald-600"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-sm font-medium truncate",children:a.name}),o.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[Math.round(a.size/1024)," KB · Ready to upload"]})]}),o.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),b()},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive","aria-label":"Remove selected file",children:o.jsx(fn,{className:"h-4 w-4"})})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:o.jsx(cf,{className:"h-5 w-5 text-primary"})}),o.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[o.jsx("p",{className:"text-sm font-medium",children:"Drop a PDF here or click to browse"}),o.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"PDF only · Maximum 50 MB"})]}),o.jsx(me,{type:"button",variant:"outline",size:"sm",className:"hidden shrink-0 sm:inline-flex",onClick:j=>{var N;j.stopPropagation(),(N=d.current)==null||N.click()},children:"Browse"})]}),o.jsx(Ue,{ref:d,type:"file",accept:".pdf",onChange:v,className:"hidden"})]}),a&&o.jsx(me,{onClick:w,disabled:r,className:"w-full gap-2",children:r?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),s==="extracting"?"Extracting text...":"Uploading..."]}):o.jsxs(o.Fragment,{children:[o.jsx(cf,{className:"h-4 w-4"}),"Upload PDF"]})})]})}const lTt=t=>t.title||t.original_filename||t.book_title||"",cTt=t=>{var e,r;return t.title||((e=t.documents)==null?void 0:e.title)||((r=t.documents)==null?void 0:r.original_filename)||""},uTt=t=>{var e;return t.title||((e=t.documents)==null?void 0:e.title)||""},dTt=t=>{var e;return((e=t.codebooks)==null?void 0:e.title)||""},hTt=t=>t.title||"",fTt=t=>t.title||"",pTt=t=>t.title||"",mTt=t=>t.title||"";function Gf(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())}function Kf({title:t,description:e,count:r,children:n}){return o.jsxs("section",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-end justify-between gap-4 px-0.5",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold tracking-tight text-foreground",children:t}),o.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:e})]}),o.jsxs("span",{className:"shrink-0 rounded-full border border-border/70 bg-muted/40 px-2.5 py-1 text-xs font-medium text-muted-foreground",children:[r," ",r===1?"item":"items"]})]}),o.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-card shadow-sm",children:n})]})}const gTt=()=>{const{user:t,loading:e}=Ht(),r=Or(),[n,s]=S.useState([]),[i,a]=S.useState(!0),[l,c]=S.useState([]),[u,d]=S.useState([]),[h,f]=S.useState([]),[p,m]=S.useState([]),[g,y]=S.useState([]),[x,v]=S.useState([]),[b,w]=S.useState([]),[j,N]=S.useState({}),[C,A]=S.useState(""),[E,O]=S.useState("all"),[$,T]=S.useState("newest"),[M,k]=S.useState(1),[D,K]=S.useState(1),[H,ee]=S.useState(1),[V,B]=S.useState(1),[z,F]=S.useState(1),[G,Q]=S.useState(1),[ie,se]=S.useState(1),[q,L]=S.useState(1),[Z,J]=S.useState(0),[W,X]=S.useState(0),[he,P]=S.useState(0),[oe,Y]=S.useState(0),[R,I]=S.useState(0),[U,re]=S.useState(0),[ue,ae]=S.useState(0),[ge,we]=S.useState(0),ce=20;S.useEffect(()=>{!t&&!e&&r("/login")},[t,e,r]);const ne=async(ct=M)=>{if(!t)return;const{count:xn}=await pe.from("v_documents_with_status").select("*",{count:"exact",head:!0}).eq("user_id",t.id);J(xn||0);const{data:Qn,error:as}=await pe.from("v_documents_with_status").select("*").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ct-1)*ce,ct*ce-1);if(as){console.error("Error loading documents:",as);return}const Lf=Qn||[];if(s(Lf),Lf.length===0){N({});return}const $f=Lf.map(du=>du.id),{data:Wv,error:Vv}=await pe.from("pages").select("document_id").eq("page_number",1).in("document_id",$f);if(!Vv&&Wv){const du={},hu=new Set(Wv.map(gi=>gi.document_id)),Td=$f.filter(gi=>!hu.has(gi)),vl=await Promise.all(Td.map(async gi=>{const{data:Pd}=await pe.from("pages").select("id").eq("document_id",gi).limit(1);return[gi,!!Pd&&Pd.length>0]}));$f.forEach(gi=>{du[gi]=hu.has(gi)}),vl.forEach(([gi,Pd])=>{du[gi]=Pd}),N(du)}},fe=async(ct=D)=>{if(!t)return;const{count:xn}=await pe.from("methods").select("*",{count:"exact",head:!0}).eq("user_id",t.id);X(xn||0);const{data:Qn,error:as}=await pe.from("methods").select("*, documents(title, page_count, original_filename)").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ct-1)*ce,ct*ce-1);as||c(Qn||[])},be=async(ct=H)=>{if(!t)return;const{count:xn}=await pe.from("theory_backgrounds").select("*",{count:"exact",head:!0}).eq("user_id",t.id);P(xn||0);const{data:Qn,error:as}=await pe.from("theory_backgrounds").select("*, documents(title, page_count, original_filename)").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ct-1)*ce,ct*ce-1);as||d(Qn||[])},xe=async(ct=V)=>{if(!t)return;const{count:xn}=await pe.from("analysis_results").select("*",{count:"exact",head:!0}).eq("user_id",t.id);Y(xn||0);const{data:Qn,error:as}=await pe.from("analysis_results").select("*, codebooks(title)").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ct-1)*ce,ct*ce-1);as||f(Qn||[])},_e=async(ct=z)=>{if(!t)return;const{count:xn}=await pe.from("topic_explorations").select("*",{count:"exact",head:!0}).eq("user_id",t.id);I(xn||0);const{data:Qn,error:as}=await pe.from("topic_explorations").select("*").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ct-1)*ce,ct*ce-1);as||m(Qn||[])},ke=async(ct=G)=>{if(!t)return;const{count:xn}=await pe.from("research_setups").select("*",{count:"exact",head:!0}).eq("user_id",t.id);re(xn||0);const{data:Qn,error:as}=await pe.from("research_setups").select("*").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ct-1)*ce,ct*ce-1);as||y(Qn||[])},$e=async(ct=ie)=>{if(!t)return;const{count:xn}=await pe.from("results_discussions").select("*",{count:"exact",head:!0}).eq("user_id",t.id);ae(xn||0);const{data:Qn,error:as}=await pe.from("results_discussions").select("*").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ct-1)*ce,ct*ce-1);as||v(Qn||[])},Te=async(ct=q)=>{if(!t)return;const{count:xn}=await pe.from("coding_results").select("*",{count:"exact",head:!0}).eq("user_id",t.id);we(xn||0);const{data:Qn,error:as}=await pe.from("coding_results").select("*, codebooks(title), interviews(title)").eq("user_id",t.id).order("created_at",{ascending:!1}).range((ct-1)*ce,ct*ce-1);as||w(Qn||[])},ot=async()=>{if(t){a(!0);try{await Promise.all([ne(1),fe(1),be(1),xe(1),_e(1),ke(1),$e(1),Te(1)])}catch(ct){console.error("Error loading library:",ct)}finally{a(!1)}}};S.useEffect(()=>{t&&ot()},[t]);const wt=async ct=>{k(ct),await ne(ct)},Ct=async ct=>{K(ct),await fe(ct)},pr=async ct=>{ee(ct),await be(ct)},Kt=async ct=>{B(ct),await xe(ct)},Re=async ct=>{F(ct),await _e(ct)},ye=async ct=>{Q(ct),await ke(ct)},Ne=async ct=>{se(ct),await $e(ct)},Ce=async ct=>{L(ct),await Te(ct)},Fe=S.useMemo(()=>Gf(n,C,$,lTt),[n,C,$]),yt=S.useMemo(()=>Gf(l,C,$,cTt),[l,C,$]),He=S.useMemo(()=>Gf(u,C,$,uTt),[u,C,$]),Ye=S.useMemo(()=>Gf(h,C,$,dTt),[h,C,$]),it=S.useMemo(()=>Gf(p,C,$,hTt),[p,C,$]),zt=S.useMemo(()=>Gf(g,C,$,fTt),[g,C,$]),Xt=S.useMemo(()=>Gf(x,C,$,pTt),[x,C,$]),Mr=S.useMemo(()=>Gf(b,C,$,mTt),[b,C,$]),ur=ct=>E==="all"||E===ct,Fr=W+he+oe+R+U+ue+ge,Kr=[{value:"all",label:"All"},{value:"documents",label:"Documents",count:Z},{value:"methods",label:"Methods",count:W},{value:"theories",label:"Theory",count:he},{value:"analyses",label:"Analysis",count:oe},{value:"topics",label:"Topics",count:R},{value:"setups",label:"Setups",count:U},{value:"discussions",label:"Discussions",count:ue},{value:"codings",label:"Codings",count:ge}];return e||i?o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"flex min-h-[60vh] items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-b-2 border-primary"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading library..."})]})})}):t?o.jsx(Cr,{showSidebar:!0,children:o.jsxs("div",{className:"space-y-7 pb-10",children:[o.jsxs("div",{className:"flex flex-col gap-5 lg:flex-row lg:items-start lg:justify-between",children:[o.jsxs("div",{className:"flex min-w-0 items-start gap-4",children:[o.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-primary/10 text-primary ring-1 ring-primary/10",children:o.jsx(nr,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"My Library"}),o.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-6 text-muted-foreground",children:"Your uploaded sources and generated research outputs in one workspace."})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2 sm:min-w-[360px]",children:[o.jsxs("div",{className:"rounded-xl border border-border/70 bg-card px-3.5 py-3 shadow-sm",children:[o.jsx("div",{className:"text-xl font-semibold tabular-nums",children:Z}),o.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:"Sources"})]}),o.jsxs("div",{className:"rounded-xl border border-border/70 bg-card px-3.5 py-3 shadow-sm",children:[o.jsx("div",{className:"text-xl font-semibold tabular-nums",children:Fr}),o.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:"Outputs"})]}),o.jsxs("div",{className:"rounded-xl border border-border/70 bg-card px-3.5 py-3 shadow-sm",children:[o.jsx("div",{className:"text-xl font-semibold tabular-nums",children:"8"}),o.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:"Categories"})]})]})]}),o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card shadow-sm",children:[o.jsxs("div",{className:"flex items-center gap-3 border-b border-border/60 px-5 py-4",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(cf,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-semibold",children:"Add a source"}),o.jsx("div",{className:"text-xs text-muted-foreground",children:"Upload a PDF to your research library."})]})]}),o.jsx("div",{className:"px-5 py-4",children:o.jsx(oTt,{onDocumentUploaded:()=>ne(M)})})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-center",children:[o.jsxs("div",{className:"relative min-w-0 flex-1",children:[o.jsx(Ti,{className:"absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),o.jsx(Ue,{placeholder:"Search your library...",value:C,onChange:ct=>A(ct.target.value),className:"h-11 rounded-xl border-border/70 bg-card pl-10 shadow-sm"})]}),o.jsxs(pt,{value:$,onValueChange:ct=>T(ct),children:[o.jsx(ut,{className:"h-11 w-full rounded-xl border-border/70 bg-card shadow-sm xl:w-[180px]",children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"newest",children:"Newest first"}),o.jsx(Le,{value:"alphabetical",children:"A → Z"})]})]})]}),o.jsx("div",{className:"flex gap-1.5 overflow-x-auto rounded-xl border border-border/70 bg-muted/25 p-1.5",children:Kr.map(ct=>{const xn=E===ct.value;return o.jsxs("button",{type:"button",onClick:()=>O(ct.value),className:`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-xs font-medium transition ${xn?"bg-background text-foreground shadow-sm ring-1 ring-border/60":"text-muted-foreground hover:bg-background/70 hover:text-foreground"}`,children:[o.jsx("span",{children:ct.label}),ct.count!==void 0&&o.jsx("span",{className:`tabular-nums ${xn?"text-foreground/70":"text-muted-foreground/70"}`,children:ct.count})]},ct.value)})})]}),o.jsxs("div",{className:"space-y-8",children:[ur("documents")&&o.jsx(Kf,{title:"Documents",description:"Uploaded PDFs and source material",count:Z,children:Fe.length===0?o.jsx("p",{className:"px-6 py-12 text-center text-sm text-muted-foreground",children:"No documents found"}):o.jsx(QAt,{documents:Fe,documentPages:j,onDocumentDeleted:()=>ne(M),currentPage:M,itemsPerPage:ce,totalItems:Z,onPageChange:wt})}),ur("methods")&&o.jsx(Kf,{title:"Methods",description:"Saved methodology outputs",count:W,children:yt.length===0?o.jsx("p",{className:"px-6 py-12 text-center text-sm text-muted-foreground",children:"No methods found"}):o.jsx(ZAt,{methods:yt,onMethodDeleted:()=>fe(D),currentPage:D,itemsPerPage:ce,totalItems:W,onPageChange:Ct})}),ur("theories")&&o.jsx(Kf,{title:"Theory & Background",description:"Generated theoretical and background work",count:he,children:He.length===0?o.jsx("p",{className:"px-6 py-12 text-center text-sm text-muted-foreground",children:"No theories found"}):o.jsx(tTt,{theories:He,onTheoryDeleted:()=>be(H),currentPage:H,itemsPerPage:ce,totalItems:he,onPageChange:pr})}),ur("analyses")&&o.jsx(Kf,{title:"Analysis",description:"Saved analysis results",count:oe,children:Ye.length===0?o.jsx("p",{className:"px-6 py-12 text-center text-sm text-muted-foreground",children:"No analyses found"}):o.jsx(rTt,{analyses:Ye,onAnalysisDeleted:()=>xe(V),currentPage:V,itemsPerPage:ce,totalItems:oe,onPageChange:Kt})}),ur("topics")&&o.jsx(Kf,{title:"Topic Explorations",description:"Saved topic exploration results",count:R,children:it.length===0?o.jsx("p",{className:"px-6 py-12 text-center text-sm text-muted-foreground",children:"No topic explorations found"}):o.jsx(nTt,{topics:it,onTopicDeleted:()=>_e(z),currentPage:z,itemsPerPage:ce,totalItems:R,onPageChange:Re})}),ur("setups")&&o.jsx(Kf,{title:"Research Setups",description:"Saved research design and setup work",count:U,children:zt.length===0?o.jsx("p",{className:"px-6 py-12 text-center text-sm text-muted-foreground",children:"No research setups found"}):o.jsx(sTt,{setups:zt,onSetupDeleted:()=>ke(G),currentPage:G,itemsPerPage:ce,totalItems:U,onPageChange:ye})}),ur("discussions")&&o.jsx(Kf,{title:"Discussions",description:"Saved discussion outputs",count:ue,children:Xt.length===0?o.jsx("p",{className:"px-6 py-12 text-center text-sm text-muted-foreground",children:"No discussions found"}):o.jsx(iTt,{discussions:Xt,onDiscussionDeleted:()=>$e(ie),currentPage:ie,itemsPerPage:ce,totalItems:ue,onPageChange:Ne})}),ur("codings")&&o.jsx(Kf,{title:"Codings",description:"Saved qualitative coding results",count:ge,children:Mr.length===0?o.jsx("p",{className:"px-6 py-12 text-center text-sm text-muted-foreground",children:"No codings found"}):o.jsx(aTt,{codings:Mr,onCodingDeleted:()=>Te(q),currentPage:q,itemsPerPage:ce,totalItems:ge,onPageChange:Ce})})]})]})}):null};function cu({open:t,onClose:e,remainingPoints:r}){const n=Or();return o.jsx(jn,{open:t,onOpenChange:e,children:o.jsxs(pn,{className:"sm:max-w-md",children:[o.jsxs(mn,{className:"items-center text-center",children:[o.jsx("div",{className:"mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10",children:o.jsx(Jl,{className:"h-6 w-6 text-destructive"})}),o.jsx(gn,{children:"Student Points exhausted"}),o.jsxs(og,{children:["You currently have ",o.jsx("span",{className:"font-semibold text-foreground",children:Math.round(r)})," ","Student Points. You need more points to use this feature."]})]}),o.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[o.jsx(me,{onClick:()=>{e(),n("/pricing")},children:"View Plans"}),o.jsx(me,{variant:"outline",onClick:e,children:"Close"})]})]})})}const zse={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"}},xTt={small:1,medium:1,big:1.25,deep15:1.5};function yTt({documents:t,onSummaryCreated:e}){const{userProfile:r,user:n,checkStudentPoints:s,studentPoints:i}=Ht(),[a,l]=S.useState(!1),[c,u]=S.useState(""),[d,h]=S.useState(""),[f,p]=S.useState(""),[m,g]=S.useState(!1),[y,x]=S.useState(null),[v,b]=S.useState(null),[w,j]=S.useState(null),[N,C]=S.useState(null),A=F=>F.replace(/[^\d,\-–\s]/g,"").trim(),E=F=>{const G=A(F);if(!G)return[];const Q=[],ie=G.split(",").map(se=>se.trim());for(const se of ie)if(se.includes("–")||se.includes("-")){const[q,L]=se.split(/[–-]/).map(Z=>parseInt(Z.trim()));if(!isNaN(q)&&!isNaN(L)&&q>0&&L>0&&q<=L&&L<=1e3)for(let Z=q;Z<=L;Z++)Q.includes(Z)||Q.push(Z)}else{const q=parseInt(se);!isNaN(q)&&q>0&&q<=1e3&&!Q.includes(q)&&Q.push(q)}return Q.sort((se,q)=>se-q)},O=F=>{if(!F.trim())return"Please select at least one page.";const G=E(F);if(G.length===0)return"Invalid format. Use e.g. 1-5, 8, 12";const Q=t.find(ie=>ie.id===c);if(Q&&Q.page_count){const ie=G.filter(se=>se>Q.page_count);if(ie.length>0)return`Document only has ${Q.page_count} pages. Invalid pages: ${ie.join(", ")}`}return G.length>50?"Maximum 50 pages per summary.":null},$=F=>{h(F);const G=O(F);b(G)},T=t.find(F=>F.id===c),M=E(d),k=M.length,D=f?xTt[f]:1,K=Math.ceil(k*D),H=T&&k>0&&f&&r&&!v,ee=r?r.current_token_balance>=K:!1,V=async()=>{if(!s()){l(!0);return}if(!(!H||!r||!n)){g(!0),x(null),j(null),C(null);try{const{data:{session:F}}=await vn.auth.getSession();if(!(F!=null&&F.access_token))throw new Error("No valid login found");const G=crypto.randomUUID(),{data:Q,error:ie}=await vn.functions.invoke("summarize",{body:{client_request_id:G,document_id:c,selected_pages:M,mode:f}});if(console.log("summarize response",{data:Q,error:ie}),ie){C({text:ie.message||"Invoke error",isError:!0});return}if(Q!=null&&Q.error){const q=Q.message||"Error";C({text:q,isError:!0}),Ke.error(q);return}const se=Q==null?void 0:Q.summary_text;if(!se){Ke.error("No summary returned");return}C({text:se,isError:!1}),x(se),j({mode:(Q==null?void 0:Q.summary_mode)||f,pagesCharged:(Q==null?void 0:Q.pages_selected)||K,remainingAfter:r.current_token_balance}),console.log("summary_id",Q==null?void 0:Q.summary_id),Ke.success(`Summary created successfully! ${(Q==null?void 0:Q.pages_selected)||K} pages processed.`),u(""),h(""),p(""),b(null),e()}catch(F){console.error("Summary generation error:",F),C({text:F.message||"Error creating summary. Please try again.",isError:!0}),F.message.includes("Plan upgraden")?Ke.error("Page limit reached – please upgrade plan.",{action:{label:"View Pricing",onClick:()=>window.open("/pricing","_blank")}}):Ke.error(F.message||"Error creating summary. Please try again.")}finally{g(!1)}}},B=async()=>{if(y)try{await navigator.clipboard.writeText(y),Ke.success("Copied to clipboard")}catch{Ke.error("Copy failed")}},z=f?zse[f]:null;return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-4",children:[t.length===0?o.jsxs(yf,{children:[o.jsx(Jl,{className:"h-4 w-4"}),o.jsx(vf,{children:"No documents available. Upload a PDF in Step 1 first."})]}):o.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"document-select",children:"Select Document"}),o.jsxs(pt,{value:c,onValueChange:u,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Choose document..."})}),o.jsx(dt,{children:t.map(F=>o.jsxs(Le,{value:F.id,children:[F.title," (",F.page_count||"?"," pages)"]},F.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"summary-mode",children:"Summary Mode"}),o.jsxs(pt,{value:f,onValueChange:p,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Choose mode..."})}),o.jsx(dt,{children:Object.entries(zse).map(([F,G])=>o.jsx(Le,{value:F,children:G.label},F))})]}),z&&o.jsx("p",{className:"text-xs text-muted-foreground",children:z.description})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"page-selection",children:"Page Selection"}),o.jsx(Ue,{id:"page-selection",value:d,onChange:F=>$(F.target.value),placeholder:"e.g. 2-5, 7, 12",maxLength:100,className:v?"border-destructive":""}),v?o.jsx("p",{className:"text-sm text-destructive",children:v}):o.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."}),M.length>0&&!v&&o.jsxs("div",{className:"space-y-1",children:[o.jsxs("p",{className:"text-sm text-primary",children:["Selected pages: ",M.join(", ")," (",k," pages)"]}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["This selection will use approximately ",K," pages from your monthly limit (pages ×"," ",D," multiplier = ",K,")."]})]})]}),!ee&&k>0&&o.jsxs(yf,{className:"border-destructive/50 bg-destructive/5",children:[o.jsx(Jl,{className:"h-4 w-4 text-destructive"}),o.jsxs(vf,{children:["Not enough pages available! You need ",K," pages, but only have"," ",r==null?void 0:r.current_token_balance," remaining."]})]}),o.jsx(me,{onClick:V,disabled:!H||m,className:"w-full",children:m?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Creating summary..."]}):"➤ Summarize Now"}),(N==null?void 0:N.isError)&&o.jsx("div",{className:"border rounded-lg p-4 border-destructive/50 bg-destructive/5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Jl,{className:"w-5 h-5 text-destructive mt-0.5 flex-shrink-0"}),o.jsxs("div",{className:"space-y-2 flex-1",children:[o.jsx("h4",{className:"font-medium text-destructive",children:"Summary Error"}),o.jsx("p",{className:"text-sm text-destructive/80",children:N.text})]})]})})]}),y&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h4",{className:"text-lg font-semibold",children:"Summary"}),o.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[o.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[o.jsx(uc,{className:"w-4 h-4"}),o.jsx("span",{children:"Saved"})]}),w&&o.jsxs("div",{className:"text-muted-foreground",children:[w.pagesCharged," pages used • ",w.remainingAfter," remaining"]})]})]}),o.jsx("div",{className:"border rounded-lg p-4 bg-muted/20",children:o.jsx(lr,{value:y,readOnly:!0,className:"border-none bg-transparent resize-none focus:ring-0 p-0 w-full",style:{height:"auto",minHeight:"200px",overflow:"hidden"},rows:y?y.split(`
`).length+5:10})}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsxs(me,{onClick:B,variant:"outline",size:"sm",children:[o.jsx(ws,{className:"w-4 h-4 mr-2"}),"Copy to Clipboard"]}),o.jsxs(me,{variant:"outline",size:"sm",disabled:!0,children:[o.jsx(bX,{className:"w-4 h-4 mr-2"}),"Export as PDF"]}),o.jsxs(me,{variant:"outline",size:"sm",disabled:!0,children:[o.jsx(bX,{className:"w-4 h-4 mr-2"}),"Export as DOCX"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>window.location.href="/documents",children:[o.jsx(of,{className:"w-4 h-4 mr-2"}),"Open in Library"]})]})]}),o.jsx(cu,{open:a,onClose:()=>l(!1),remainingPoints:(i==null?void 0:i.remaining)??0})]})}const vTt=()=>{const{user:t,loading:e}=Ht(),r=Or(),[n,s]=S.useState([]),[i,a]=S.useState(!1);S.useEffect(()=>{!t&&!e&&r("/login")},[t,e,r]);const l=async()=>{if(t){a(!0);try{const{data:u,error:d}=await vn.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)}}};S.useEffect(()=>{t&&l()},[t]);const c=()=>{l()};return e?o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?o.jsx(Cr,{showSidebar:!0,children:o.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold",children:"Summaries"}),o.jsx("p",{className:"text-muted-foreground",children:"Create summaries based on your uploaded documents"})]}),o.jsxs(Ze,{className:"panze-content-card",children:[o.jsxs(Ot,{children:[o.jsx(Ft,{className:"flex items-center gap-3",children:"Create Summary"}),o.jsx(Es,{children:"Select a document and configure your summary options"})]}),o.jsx(st,{children:o.jsx(yTt,{documents:n,onSummaryCreated:c})})]})]})}):null},bTt=t=>{switch(t){case"theory":return 30;case"methods":return 30;case"discussion":return 20;case"conclusion":return 20;case"summary":return 20;case"supervisor":return 15;case"ghost_suggestion":return 2;case"topic_exp":return 5;case"platform_assistant":return 2;case"analysis_r":return 10;case"codeapply":return 15;case"r_setup":return 10;case"demo_keywords":case"demo_topic_ideas":return 0;case"theory-fox40":case"methods-fox40":return 0;default:return 0}},wTt=()=>{const{user:t,loading:e,studentPoints:r}=Ht(),n=Or(),[s,i]=S.useState([]),[a,l]=S.useState([]),[c,u]=S.useState(!0),[d,h]=S.useState("all");S.useEffect(()=>{!t&&!e?n("/login"):t&&f()},[t,e,n]);const f=async()=>{try{const[v,b,w,j,N,C,A,E]=await Promise.all([pe.from("summaries").select("id, summary_text, citation_style, created_at, summary_mode, documents(title)").order("created_at",{ascending:!1}),pe.from("theory_backgrounds").select("id, title, theory_text, citation_style, created_at, mode").order("created_at",{ascending:!1}),pe.from("methods").select("id, title, method_text, citation_style, created_at, mode").order("created_at",{ascending:!1}),pe.from("analysis_results").select("id, result_text, citation_style, created_at, mode").order("created_at",{ascending:!1}),pe.from("qualitative_summaries").select("id, title, summary_text, created_at").order("created_at",{ascending:!1}),pe.from("topic_explorations").select("id, title, introduction, created_at, language").order("created_at",{ascending:!1}),pe.from("research_setups").select("id, title, aim, degree, discipline, created_at").order("created_at",{ascending:!1}),pe.from("usage_log").select("id, tokens_used, prompt_tokens, completion_tokens, model, source, timestamp").order("timestamp",{ascending:!1}).limit(100)]),O=[];v.data&&v.data.forEach($=>{var T;O.push({id:$.id,type:"summary",title:((T=$.documents)==null?void 0:T.title)||"Summary",content:$.summary_text||"",created_at:$.created_at||"",citation_style:$.citation_style||void 0,mode:$.summary_mode||void 0})}),b.data&&b.data.forEach($=>{O.push({id:$.id,type:"theory",title:$.title||"Theory Background",content:$.theory_text||"",created_at:$.created_at,citation_style:$.citation_style||void 0,mode:$.mode||void 0})}),w.data&&w.data.forEach($=>{O.push({id:$.id,type:"method",title:$.title||"Methodology",content:$.method_text||"",created_at:$.created_at,citation_style:$.citation_style||void 0,mode:$.mode||void 0})}),j.data&&j.data.forEach($=>{O.push({id:$.id,type:"analysis",title:"Analysis Result",content:$.result_text||"",created_at:$.created_at,citation_style:$.citation_style||void 0,mode:$.mode||void 0})}),N.data&&N.data.forEach($=>{O.push({id:$.id,type:"qualitative",title:$.title||"Qualitative Summary",content:$.summary_text||"",created_at:$.created_at})}),C.data&&C.data.forEach($=>{O.push({id:$.id,type:"topic_explorer",title:$.title||"Topic Exploration",content:$.introduction||"",created_at:$.created_at,mode:$.language||void 0})}),A.data&&A.data.forEach($=>{O.push({id:$.id,type:"research_setup",title:$.title||"Research Setup",content:$.aim||"",created_at:$.created_at,mode:$.degree||void 0})}),O.sort(($,T)=>new Date(T.created_at).getTime()-new Date($.created_at).getTime()),i(O),l(E.data||[])}catch(v){console.error("Error fetching history:",v),Ke.error("Error loading history")}finally{u(!1)}},p=async(v,b)=>{Ke.info(`Preparing ${b.toUpperCase()} export...`)},m=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"}},g=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}},y=v=>new Date(v).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0});if(e||c)return o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})});if(!t)return null;const x=a.filter(v=>new Date(v.timestamp).toDateString()===new Date().toDateString()).length;return o.jsx(Cr,{showSidebar:!0,children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold",children:"History & Exports"}),o.jsx("p",{className:"text-muted-foreground",children:"Overview of all your activities and download options"})]}),o.jsx("div",{className:"flex items-center gap-4",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(QOe,{className:"h-4 w-4"}),o.jsxs(pt,{value:d,onValueChange:v=>h(v),children:[o.jsx(ut,{className:"w-44",children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"all",children:"All Activities"}),o.jsx(Le,{value:"generations",children:"AI Generations"}),o.jsx(Le,{value:"usage",children:"Usage History"})]})]})]})})]}),o.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[o.jsxs(Ze,{children:[o.jsx(Ot,{className:"pb-3",children:o.jsxs(Ft,{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(Sr,{className:"h-4 w-4 text-primary"}),"Total AI Generations"]})}),o.jsx(st,{children:o.jsx("div",{className:"text-3xl font-bold",children:s.length})})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{className:"pb-3",children:o.jsxs(Ft,{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(gX,{className:"h-4 w-4 text-primary"}),"Student Points Used"]})}),o.jsx(st,{children:o.jsxs("div",{className:"text-3xl font-bold",children:[((r==null?void 0:r.used)??0).toFixed(2)," SP"]})})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{className:"pb-3",children:o.jsxs(Ft,{className:"text-sm font-medium flex items-center gap-2",children:[o.jsx(yI,{className:"h-4 w-4 text-primary"}),"Activities Today"]})}),o.jsx(st,{children:o.jsx("div",{className:"text-3xl font-bold",children:x})})]})]}),(d==="all"||d==="generations")&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-xl font-semibold",children:"AI Generations"}),s.length===0?o.jsx(Ze,{children:o.jsxs(st,{className:"text-center py-12",children:[o.jsx(jr,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-medium mb-2",children:"No AI generations yet"}),o.jsx("p",{className:"text-muted-foreground",children:"Start creating summaries, theories, or methodologies to see them here"})]})}):o.jsx("div",{className:"grid gap-4",children:s.map(v=>o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx("div",{className:"flex items-start justify-between",children:o.jsxs("div",{children:[o.jsx(Ft,{className:"text-lg",children:v.title}),o.jsxs(Es,{className:"flex items-center gap-3 mt-2 flex-wrap",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(yI,{className:"h-4 w-4"}),y(v.created_at)]}),o.jsx(kt,{variant:m(v.type),children:g(v.type)}),v.citation_style&&o.jsx(kt,{variant:"outline",children:v.citation_style})]})]})})}),o.jsxs(st,{className:"space-y-4",children:[o.jsx("div",{className:"bg-muted/30 rounded-lg p-4",children:o.jsx("p",{className:"text-sm leading-relaxed line-clamp-3",children:v.content?LNe(v.content,v.mode):"No content available"})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>p(v,"pdf"),children:[o.jsx(ko,{className:"h-4 w-4 mr-2"}),"PDF"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>p(v,"docx"),children:[o.jsx(ko,{className:"h-4 w-4 mr-2"}),"DOCX"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>p(v,"txt"),children:[o.jsx(ko,{className:"h-4 w-4 mr-2"}),"TXT"]})]})]})]},`${v.type}-${v.id}`))})]}),(d==="all"||d==="usage")&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-xl font-semibold",children:"Usage History"}),a.length===0?o.jsx(Ze,{children:o.jsxs(st,{className:"text-center py-12",children:[o.jsx(gX,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),o.jsx("h3",{className:"text-lg font-medium mb-2",children:"No activity recorded yet"}),o.jsx("p",{className:"text-muted-foreground",children:"Your usage history will appear here"})]})}):o.jsx(Ze,{children:o.jsx(st,{className:"p-0",children:o.jsx("div",{className:"max-h-96 overflow-y-auto",children:a.map(v=>{const b=bTt(v.source);return o.jsxs("div",{className:"flex items-center justify-between p-4 border-b last:border-b-0",children:[o.jsxs("div",{children:[o.jsx("div",{className:"font-medium",children:v.source||"Unknown"}),o.jsx("div",{className:"text-sm text-muted-foreground",children:y(v.timestamp)})]}),o.jsxs(kt,{variant:"secondary",className:"font-mono",children:[b.toFixed(3)," SP"]})]},v.id)})})})})]})]})})};function UT(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 $Ne={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 UT=="function"&&UT;if(!d&&h)return h(u,!0);if(l)return l(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 l=typeof UT=="function"&&UT,c=0;c<i.length;c++)a(i[c]);return a}({1:[function(r,n,s){var i=r("./utils"),a=r("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(c){for(var u,d,h,f,p,m,g,y=[],x=0,v=c.length,b=v,w=i.getTypeOf(c)!=="string";x<c.length;)b=v-x,h=w?(u=c[x++],d=x<v?c[x++]:0,x<v?c[x++]:0):(u=c.charCodeAt(x++),d=x<v?c.charCodeAt(x++):0,x<v?c.charCodeAt(x++):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,y.push(l.charAt(f)+l.charAt(p)+l.charAt(m)+l.charAt(g));return y.join("")},s.decode=function(c){var u,d,h,f,p,m,g=0,y=0,x="data:";if(c.substr(0,x.length)===x)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)===l.charAt(64)&&b--,c.charAt(c.length-2)===l.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=l.indexOf(c.charAt(g++))<<2|(f=l.indexOf(c.charAt(g++)))>>4,d=(15&f)<<4|(p=l.indexOf(c.charAt(g++)))>>2,h=(3&p)<<6|(m=l.indexOf(c.charAt(g++))),v[y++]=u,p!==64&&(v[y++]=d),m!==64&&(v[y++]=h);return v}},{"./support":30,"./utils":32}],2:[function(r,n,s){var i=r("./external"),a=r("./stream/DataWorker"),l=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 l).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 l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c}();n.exports=function(l,c){return l!==void 0&&l.length?i.getTypeOf(l)!=="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,l,l.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,l,l.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"),l=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",l.inherits(d,c),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(l.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,y="";for(g=0;g<m;g++)y+=String.fromCharCode(255&p),p>>>=8;return y}function a(p,m,g,y,x,v){var b,w,j=p.file,N=p.compression,C=v!==u.utf8encode,A=l.transformTo("string",v(j.name)),E=l.transformTo("string",u.utf8encode(j.name)),O=j.comment,$=l.transformTo("string",v(O)),T=l.transformTo("string",u.utf8encode(O)),M=E.length!==j.name.length,k=T.length!==O.length,D="",K="",H="",ee=j.dir,V=j.date,B={crc32:0,compressedSize:0,uncompressedSize:0};m&&!g||(B.crc32=p.crc32,B.compressedSize=p.compressedSize,B.uncompressedSize=p.uncompressedSize);var z=0;m&&(z|=8),C||!M&&!k||(z|=2048);var F=0,G=0;ee&&(F|=16),x==="UNIX"?(G=798,F|=function(ie,se){var q=ie;return ie||(q=se?16893:33204),(65535&q)<<16}(j.unixPermissions,ee)):(G=20,F|=function(ie){return 63&(ie||0)}(j.dosPermissions)),b=V.getUTCHours(),b<<=6,b|=V.getUTCMinutes(),b<<=5,b|=V.getUTCSeconds()/2,w=V.getUTCFullYear()-1980,w<<=4,w|=V.getUTCMonth()+1,w<<=5,w|=V.getUTCDate(),M&&(K=i(1,1)+i(d(A),4)+E,D+="up"+i(K.length,2)+K),k&&(H=i(1,1)+i(d($),4)+T,D+="uc"+i(H.length,2)+H);var Q="";return Q+=`
\0`,Q+=i(z,2),Q+=N.magic,Q+=i(b,2),Q+=i(w,2),Q+=i(B.crc32,4),Q+=i(B.compressedSize,4),Q+=i(B.uncompressedSize,4),Q+=i(A.length,2),Q+=i(D.length,2),{fileRecord:h.LOCAL_FILE_HEADER+Q+A+D,dirRecord:h.CENTRAL_FILE_HEADER+i(G,2)+Q+i($.length,2)+"\0\0\0\0"+i(F,4)+i(y,4)+A+D+$}}var l=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),d=r("../crc32"),h=r("../signature");function f(p,m,g,y){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=g,this.encodeFileName=y,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(f,c),f.prototype.push=function(p){var m=p.meta.percent||0,g=this.entriesCount,y=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-y-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(y){return h.DATA_DESCRIPTOR+i(y.crc32,4)+i(y.compressedSize,4)+i(y.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,y=function(x,v,b,w,j){var N=l.transformTo("string",j(w));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(x,2)+i(x,2)+i(v,4)+i(b,4)+i(N.length,2)+N}(this.dirRecords.length,g,p,this.zipComment,this.encodeFileName);this.push({data:y,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(l,c,u){var d=new a(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{l.forEach(function(f,p){h++;var m=function(v,b){var w=v||b,j=i[w];if(!j)throw new Error(w+" is not a valid compression method !");return j}(p.options.compression,c.compression),g=p.options.compressionOptions||c.compressionOptions||{},y=p.dir,x=p.date;p._compressWorker(m,g).withStreamInfo("file",{name:f,dir:y,date:x,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 l in this)typeof this[l]!="function"&&(a[l]=this[l]);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,l){return new i().loadAsync(a,l)},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"),l=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(y){m(y)}).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:l.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 y=new c(p);return y.load(g),y}).then(function(g){var y=[a.Promise.resolve(g)],x=g.files;if(p.checkCRC32)for(var v=0;v<x.length;v++)y.push(h(x[v]));return a.Promise.all(y)}).then(function(g){for(var y=g.shift(),x=y.files,v=0;v<x.length;v++){var b=x[v],w=b.fileNameStr,j=i.resolve(b.fileNameStr);m.file(j,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(j).unsafeOriginalName=w)}return y.zipComment.length&&(m.comment=y.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 l(c,u){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}i.inherits(l,a),l.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()})},l.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(r,n,s){var i=r("readable-stream").Readable;function a(l,c,u){i.call(this,c),this._helper=l;var d=this;l.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(j,N,C){var A,E=l.getTypeOf(N),O=l.extend(C||{},d);O.date=O.date||new Date,O.compression!==null&&(O.compression=O.compression.toUpperCase()),typeof O.unixPermissions=="string"&&(O.unixPermissions=parseInt(O.unixPermissions,8)),O.unixPermissions&&16384&O.unixPermissions&&(O.dir=!0),O.dosPermissions&&16&O.dosPermissions&&(O.dir=!0),O.dir&&(j=x(j)),O.createFolders&&(A=y(j))&&v.call(this,A,!0);var $=E==="string"&&O.binary===!1&&O.base64===!1;C&&C.binary!==void 0||(O.binary=!$),(N instanceof h&&N.uncompressedSize===0||O.dir||!N||N.length===0)&&(O.base64=!1,O.binary=!0,N="",O.compression="STORE",E="string");var T=null;T=N instanceof h||N instanceof c?N:m.isNode&&m.isStream(N)?new g(j,N):l.prepareContent(j,N,O.binary,O.optimizedBinaryString,O.base64);var M=new f(j,T,O);this.files[j]=M}var a=r("./utf8"),l=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"),y=function(j){j.slice(-1)==="/"&&(j=j.substring(0,j.length-1));var N=j.lastIndexOf("/");return 0<N?j.substring(0,N):""},x=function(j){return j.slice(-1)!=="/"&&(j+="/"),j},v=function(j,N){return N=N!==void 0?N:d.createFolders,j=x(j),this.files[j]||i.call(this,j,null,{dir:!0,createFolders:N}),this.files[j]};function b(j){return Object.prototype.toString.call(j)==="[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(j){var N,C,A;for(N in this.files)A=this.files[N],(C=N.slice(this.root.length,N.length))&&N.slice(0,this.root.length)===this.root&&j(C,A)},filter:function(j){var N=[];return this.forEach(function(C,A){j(C,A)&&N.push(A)}),N},file:function(j,N,C){if(arguments.length!==1)return j=this.root+j,i.call(this,j,N,C),this;if(b(j)){var A=j;return this.filter(function(O,$){return!$.dir&&A.test(O)})}var E=this.files[this.root+j];return E&&!E.dir?E:null},folder:function(j){if(!j)return this;if(b(j))return this.filter(function(E,O){return O.dir&&j.test(E)});var N=this.root+j,C=v.call(this,N),A=this.clone();return A.root=C.name,A},remove:function(j){j=this.root+j;var N=this.files[j];if(N||(j.slice(-1)!=="/"&&(j+="/"),N=this.files[j]),N&&!N.dir)delete this.files[j];else for(var C=this.filter(function(E,O){return O.name.slice(0,j.length)===j}),A=0;A<C.length;A++)delete this.files[C[A].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(j){var N,C={};try{if((C=l.extend(j||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var A=C.comment||this.comment||"";N=p.generateWorker(this,C,A)}catch(E){(N=new c("error")).error(E)}return new u(N,C.type||"string",C.mimeType)},generateAsync:function(j,N){return this.generateInternalStream(j).accumulate(N)},generateNodeStream:function(j,N){return(j=j||{}).type||(j.type="nodebuffer"),this.generateInternalStream(j).toNodejsStream(N)}};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(l){i.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}r("../utils").inherits(a,i),a.prototype.byteAt=function(l){return this.data[this.zero+l]},a.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=l.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(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=l.charCodeAt(3),f=this.readData(4);return c===f[0]&&u===f[1]&&d===f[2]&&h===f[3]},a.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},n.exports=a},{"../utils":32,"./DataReader":18}],18:[function(r,n,s){var i=r("../utils");function a(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return i.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},n.exports=a},{"../utils":32}],19:[function(r,n,s){var i=r("./Uint8ArrayReader");function a(l){i.call(this,l)}r("../utils").inherits(a,i),a.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},n.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,s){var i=r("./DataReader");function a(l){i.call(this,l)}r("../utils").inherits(a,i),a.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},a.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},a.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},a.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},n.exports=a},{"../utils":32,"./DataReader":18}],21:[function(r,n,s){var i=r("./ArrayReader");function a(l){i.call(this,l)}r("../utils").inherits(a,i),a.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},n.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,s){var i=r("../utils"),a=r("../support"),l=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 l(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 l(c){i.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(l,i),l.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},n.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,s){var i=r("./GenericWorker"),a=r("../crc32");function l(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(l,i),l.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},n.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,s){var i=r("../utils"),a=r("./GenericWorker");function l(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}i.inherits(l,a),l.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=l},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,s){var i=r("../utils"),a=r("./GenericWorker");function l(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(l,a),l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.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=l},{"../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,l){return this._listeners[a].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,l){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,l)},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 l=this;return a.on("data",function(c){l.processChunk(c)}),a.on("end",function(){l.end()}),a.on("error",function(c){l.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,l){return this.extraStreamInfo[a]=l,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"),l=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(y,x){var v=[],b=m._internalType,w=m._outputType,j=m._mimeType;m.on("data",function(N,C){v.push(N),g&&g(C)}).on("error",function(N){v=[],x(N)}).on("end",function(){try{var N=function(C,A,E){switch(C){case"blob":return i.newBlob(i.transformTo("arraybuffer",A),E);case"base64":return c.encode(A);default:return i.transformTo(C,A)}}(w,function(C,A){var E,O=0,$=null,T=0;for(E=0;E<A.length;E++)T+=A[E].length;switch(C){case"string":return A.join("");case"array":return Array.prototype.concat.apply([],A);case"uint8array":for($=new Uint8Array(T),E=0;E<A.length;E++)$.set(A[E],O),O+=A[E].length;return $;case"nodebuffer":return Buffer.concat(A);default:throw new Error("concat : unsupported type '"+C+"'")}}(b,v),j);y(N)}catch(C){x(C)}v=[]}).resume()})}function p(m,g,y){var x=g;switch(g){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=g,this._mimeType=y,i.checkSupport(x),this._worker=m.pipe(new a(x)),m.lock()}catch(v){this._worker=new l("error"),this._worker.error(v)}}p.prototype={accumulate:function(m){return f(this,m)},on:function(m,g){var y=this;return m==="data"?this._worker.on(m,function(x){g.call(y,x.data,x.meta)}):this._worker.on(m,function(){i.delay(g,arguments,y)}),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"),l=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?l.newBufferFrom(p,"utf-8"):function(m){var g,y,x,v,b,w=m.length,j=0;for(v=0;v<w;v++)(64512&(y=m.charCodeAt(v)))==55296&&v+1<w&&(64512&(x=m.charCodeAt(v+1)))==56320&&(y=65536+(y-55296<<10)+(x-56320),v++),j+=y<128?1:y<2048?2:y<65536?3:4;for(g=a.uint8array?new Uint8Array(j):new Array(j),v=b=0;b<j;v++)(64512&(y=m.charCodeAt(v)))==55296&&v+1<w&&(64512&(x=m.charCodeAt(v+1)))==56320&&(y=65536+(y-55296<<10)+(x-56320),v++),y<128?g[b++]=y:(y<2048?g[b++]=192|y>>>6:(y<65536?g[b++]=224|y>>>12:(g[b++]=240|y>>>18,g[b++]=128|y>>>12&63),g[b++]=128|y>>>6&63),g[b++]=128|63&y);return g}(p)},s.utf8decode=function(p){return a.nodebuffer?i.transformTo("nodebuffer",p).toString("utf-8"):function(m){var g,y,x,v,b=m.length,w=new Array(2*b);for(g=y=0;g<b;)if((x=m[g++])<128)w[y++]=x;else if(4<(v=u[x]))w[y++]=65533,g+=v-1;else{for(x&=v===2?31:v===3?15:7;1<v&&g<b;)x=x<<6|63&m[g++],v--;1<v?w[y++]=65533:x<65536?w[y++]=x:(x-=65536,w[y++]=55296|x>>10&1023,w[y++]=56320|1023&x)}return w.length!==y&&(w.subarray?w=w.subarray(0,y):w.length=y),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 y=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),x=m;y!==m.length&&(a.uint8array?(x=m.subarray(0,y),this.leftOver=m.subarray(y,m.length)):(x=m.slice(0,y),this.leftOver=m.slice(y,m.length))),this.push({data:s.utf8decode(x),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"),l=r("./nodejsUtils"),c=r("./external");function u(g){return g}function d(g,y){for(var x=0;x<g.length;++x)y[x]=255&g.charCodeAt(x);return y}r("setimmediate"),s.newBlob=function(g,y){s.checkSupport("blob");try{return new Blob([g],{type:y})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(g),x.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,y,x){var v=[],b=0,w=g.length;if(w<=x)return String.fromCharCode.apply(null,g);for(;b<w;)y==="array"||y==="nodebuffer"?v.push(String.fromCharCode.apply(null,g.slice(b,Math.min(b+x,w)))):v.push(String.fromCharCode.apply(null,g.subarray(b,Math.min(b+x,w)))),b+=x;return v.join("")},stringifyByChar:function(g){for(var y="",x=0;x<g.length;x++)y+=String.fromCharCode(g[x]);return y},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,l.allocBuffer(1)).length===1}catch{return!1}}()}};function f(g){var y=65536,x=s.getTypeOf(g),v=!0;if(x==="uint8array"?v=h.applyCanBeUsed.uint8array:x==="nodebuffer"&&(v=h.applyCanBeUsed.nodebuffer),v)for(;1<y;)try{return h.stringifyByChunk(g,x,y)}catch{y=Math.floor(y/2)}return h.stringifyByChar(g)}function p(g,y){for(var x=0;x<g.length;x++)y[x]=g[x];return y}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,l.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 l.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 l.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 l.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,y){if(y=y||"",!g)return y;s.checkSupport(g);var x=s.getTypeOf(y);return m[x][g](y)},s.resolve=function(g){for(var y=g.split("/"),x=[],v=0;v<y.length;v++){var b=y[v];b==="."||b===""&&v!==0&&v!==y.length-1||(b===".."?x.pop():x.push(b))}return x.join("/")},s.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":i.nodebuffer&&l.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 y,x,v="";for(x=0;x<(g||"").length;x++)v+="\\x"+((y=g.charCodeAt(x))<16?"0":"")+y.toString(16).toUpperCase();return v},s.delay=function(g,y,x){setImmediate(function(){g.apply(x||null,y||[])})},s.inherits=function(g,y){function x(){}x.prototype=y.prototype,g.prototype=new x},s.extend=function(){var g,y,x={};for(g=0;g<arguments.length;g++)for(y in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],y)&&x[y]===void 0&&(x[y]=arguments[g][y]);return x},s.prepareContent=function(g,y,x,v,b){return c.Promise.resolve(y).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(j,N){var C=new FileReader;C.onload=function(A){j(A.target.result)},C.onerror=function(A){N(A.target.error)},C.readAsArrayBuffer(w)}):w}).then(function(w){var j=s.getTypeOf(w);return j?(j==="arraybuffer"?w=s.transformTo("uint8array",w):j==="string"&&(b?w=a.decode(w):x&&v!==!0&&(w=function(N){return d(N,i.uint8array?new Uint8Array(N.length):new Array(N.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"),l=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(l.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.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(l.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,l.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(l.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(l.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(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.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(l.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,l.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"),l=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(y){for(var x in d)if(Object.prototype.hasOwnProperty.call(d,x)&&d[x].magic===y)return d[x];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 l(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,y,x=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<x;)m=p.readInt(2),g=p.readInt(2),y=p.readData(g),this.extraFields[m]={id:m,length:g,value:y};p.setIndex(x)},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 y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var x=a.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},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,y){this.name=m,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=g,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var a=r("./stream/StreamHelper"),l=r("./stream/DataWorker"),c=r("./utf8"),u=r("./compressedObject"),d=r("./stream/GenericWorker");i.prototype={internalStream:function(m){var g=null,y="string";try{if(!m)throw new Error("No output type specified.");var x=(y=m.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),g=this._decompressWorker();var v=!this._dataBinary;v&&!x&&(g=g.pipe(new c.Utf8EncodeWorker)),!v&&x&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(b){(g=new d("error")).error(b)}return new a(g,y,"")},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 y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(y,m,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(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,l,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,y;l=!0;for(var x=p.length;x;){for(y=p,p=[],g=-1;++g<x;)y[g]();x=p.length}l=!1}n.exports=function(g){p.push(g)!==1||l||a()}}).call(this,typeof $n<"u"?$n:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(r,n,s){var i=r("immediate");function a(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,x!==a&&g(this,x)}function f(x,v,b){this.promise=x,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function p(x,v,b){i(function(){var w;try{w=v(b)}catch(j){return l.reject(x,j)}w===x?l.reject(x,new TypeError("Cannot resolve promise with itself")):l.resolve(x,w)})}function m(x){var v=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof v=="function")return function(){v.apply(x,arguments)}}function g(x,v){var b=!1;function w(C){b||(b=!0,l.reject(x,C))}function j(C){b||(b=!0,l.resolve(x,C))}var N=y(function(){v(j,w)});N.status==="error"&&w(N.value)}function y(x,v){var b={};try{b.value=x(v),b.status="success"}catch(w){b.status="error",b.value=w}return b}(n.exports=h).prototype.finally=function(x){if(typeof x!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(x()).then(function(){return b})},function(b){return v.resolve(x()).then(function(){throw b})})},h.prototype.catch=function(x){return this.then(null,x)},h.prototype.then=function(x,v){if(typeof x!="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?x:v,this.outcome):this.queue.push(new f(b,x,v)),b},f.prototype.callFulfilled=function(x){l.resolve(this.promise,x)},f.prototype.otherCallFulfilled=function(x){p(this.promise,this.onFulfilled,x)},f.prototype.callRejected=function(x){l.reject(this.promise,x)},f.prototype.otherCallRejected=function(x){p(this.promise,this.onRejected,x)},l.resolve=function(x,v){var b=y(m,v);if(b.status==="error")return l.reject(x,b.value);var w=b.value;if(w)g(x,w);else{x.state=u,x.outcome=v;for(var j=-1,N=x.queue.length;++j<N;)x.queue[j].callFulfilled(v)}return x},l.reject=function(x,v){x.state=c,x.outcome=v;for(var b=-1,w=x.queue.length;++b<w;)x.queue[b].callRejected(v);return x},h.resolve=function(x){return x instanceof this?x:l.resolve(new this(a),x)},h.reject=function(x){var v=new this(a);return l.reject(v,x)},h.all=function(x){var v=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=x.length,w=!1;if(!b)return this.resolve([]);for(var j=new Array(b),N=0,C=-1,A=new this(a);++C<b;)E(x[C],C);return A;function E(O,$){v.resolve(O).then(function(T){j[$]=T,++N!==b||w||(w=!0,l.resolve(A,j))},function(T){w||(w=!0,l.reject(A,T))})}},h.race=function(x){var v=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=x.length,w=!1;if(!b)return this.resolve([]);for(var j=-1,N=new this(a);++j<b;)C=x[j],v.resolve(C).then(function(A){w||(w=!0,l.resolve(N,A))},function(A){w||(w=!0,l.reject(N,A))});var C;return N}},{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"),l=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(x){if(!(this instanceof g))return new g(x);this.options=a.assign({level:f,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},x||{});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"?l.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 y(x,v){var b=new g(v);if(b.push(x,!0),b.err)throw b.msg||c[b.err];return b.result}g.prototype.push=function(x,v){var b,w,j=this.strm,N=this.options.chunkSize;if(this.ended)return!1;w=v===~~v?v:v===!0?4:0,typeof x=="string"?j.input=l.string2buf(x):d.call(x)==="[object ArrayBuffer]"?j.input=new Uint8Array(x):j.input=x,j.next_in=0,j.avail_in=j.input.length;do{if(j.avail_out===0&&(j.output=new a.Buf8(N),j.next_out=0,j.avail_out=N),(b=i.deflate(j,w))!==1&&b!==h)return this.onEnd(b),!(this.ended=!0);j.avail_out!==0&&(j.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(a.shrinkBuf(j.output,j.next_out))):this.onData(a.shrinkBuf(j.output,j.next_out)))}while((0<j.avail_in||j.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),!(j.avail_out=0))},g.prototype.onData=function(x){this.chunks.push(x)},g.prototype.onEnd=function(x){x===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},s.Deflate=g,s.deflate=y,s.deflateRaw=function(x,v){return(v=v||{}).raw=!0,y(x,v)},s.gzip=function(x,v){return(v=v||{}).gzip=!0,y(x,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"),l=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 y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||g&&g.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&!(15&y.windowBits)&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var x=i.inflateInit2(this.strm,y.windowBits);if(x!==c.Z_OK)throw new Error(u[x]);this.header=new h,i.inflateGetHeader(this.strm,this.header)}function m(g,y){var x=new p(y);if(x.push(g,!0),x.err)throw x.msg||u[x.err];return x.result}p.prototype.push=function(g,y){var x,v,b,w,j,N,C=this.strm,A=this.options.chunkSize,E=this.options.dictionary,O=!1;if(this.ended)return!1;v=y===~~y?y:y===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?C.input=l.binstring2buf(g):f.call(g)==="[object ArrayBuffer]"?C.input=new Uint8Array(g):C.input=g,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(A),C.next_out=0,C.avail_out=A),(x=i.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&E&&(N=typeof E=="string"?l.string2buf(E):f.call(E)==="[object ArrayBuffer]"?new Uint8Array(E):E,x=i.inflateSetDictionary(this.strm,N)),x===c.Z_BUF_ERROR&&O===!0&&(x=c.Z_OK,O=!1),x!==c.Z_STREAM_END&&x!==c.Z_OK)return this.onEnd(x),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&x!==c.Z_STREAM_END&&(C.avail_in!==0||v!==c.Z_FINISH&&v!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=l.utf8border(C.output,C.next_out),w=C.next_out-b,j=l.buf2string(C.output,b),C.next_out=w,C.avail_out=A-w,w&&a.arraySet(C.output,C.output,b,w,0),this.onData(j)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(O=!0)}while((0<C.avail_in||C.avail_out===0)&&x!==c.Z_STREAM_END);return x===c.Z_STREAM_END&&(v=c.Z_FINISH),v===c.Z_FINISH?(x=i.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===c.Z_OK):v!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.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,y){return(y=y||{}).raw=!0,m(g,y)},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}},l={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,l))},s.setTyped(i)},{}],42:[function(r,n,s){var i=r("./common"),a=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!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&&l||!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,y,x=h.length,v=0;for(g=0;g<x;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<x&&(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=y=0;y<v;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<x&&(64512&(m=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),g++),p<128?f[y++]=p:(p<2048?f[y++]=192|p>>>6:(p<65536?f[y++]=224|p>>>12:(f[y++]=240|p>>>18,f[y++]=128|p>>>12&63),f[y++]=128|p>>>6&63),f[y++]=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,y,x=f||h.length,v=new Array(2*x);for(p=m=0;p<x;)if((g=h[p++])<128)v[m++]=g;else if(4<(y=c[g]))v[m++]=65533,p+=y-1;else{for(g&=y===2?31:y===3?15:7;1<y&&p<x;)g=g<<6|63&h[p++],y--;1<y?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,l,c){for(var u=65535&i|0,d=i>>>16&65535|0,h=0;l!==0;){for(l-=h=2e3<l?2e3:l;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,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();n.exports=function(a,l,c,u){var d=i,h=u+c;a^=-1;for(var f=u;f<h;f++)a=a>>>8^d[255&(a^l[f])];return-1^a}},{}],46:[function(r,n,s){var i,a=r("../utils/common"),l=r("./trees"),c=r("./adler32"),u=r("./crc32"),d=r("./messages"),h=0,f=4,p=0,m=-2,g=-1,y=4,x=2,v=8,b=9,w=286,j=30,N=19,C=2*w+1,A=15,E=3,O=258,$=O+E+1,T=42,M=113,k=1,D=2,K=3,H=4;function ee(P,oe){return P.msg=d[oe],oe}function V(P){return(P<<1)-(4<P?9:0)}function B(P){for(var oe=P.length;0<=--oe;)P[oe]=0}function z(P){var oe=P.state,Y=oe.pending;Y>P.avail_out&&(Y=P.avail_out),Y!==0&&(a.arraySet(P.output,oe.pending_buf,oe.pending_out,Y,P.next_out),P.next_out+=Y,oe.pending_out+=Y,P.total_out+=Y,P.avail_out-=Y,oe.pending-=Y,oe.pending===0&&(oe.pending_out=0))}function F(P,oe){l._tr_flush_block(P,0<=P.block_start?P.block_start:-1,P.strstart-P.block_start,oe),P.block_start=P.strstart,z(P.strm)}function G(P,oe){P.pending_buf[P.pending++]=oe}function Q(P,oe){P.pending_buf[P.pending++]=oe>>>8&255,P.pending_buf[P.pending++]=255&oe}function ie(P,oe){var Y,R,I=P.max_chain_length,U=P.strstart,re=P.prev_length,ue=P.nice_match,ae=P.strstart>P.w_size-$?P.strstart-(P.w_size-$):0,ge=P.window,we=P.w_mask,ce=P.prev,ne=P.strstart+O,fe=ge[U+re-1],be=ge[U+re];P.prev_length>=P.good_match&&(I>>=2),ue>P.lookahead&&(ue=P.lookahead);do if(ge[(Y=oe)+re]===be&&ge[Y+re-1]===fe&&ge[Y]===ge[U]&&ge[++Y]===ge[U+1]){U+=2,Y++;do;while(ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&U<ne);if(R=O-(ne-U),U=ne-O,re<R){if(P.match_start=oe,ue<=(re=R))break;fe=ge[U+re-1],be=ge[U+re]}}while((oe=ce[oe&we])>ae&&--I!=0);return re<=P.lookahead?re:P.lookahead}function se(P){var oe,Y,R,I,U,re,ue,ae,ge,we,ce=P.w_size;do{if(I=P.window_size-P.lookahead-P.strstart,P.strstart>=ce+(ce-$)){for(a.arraySet(P.window,P.window,ce,ce,0),P.match_start-=ce,P.strstart-=ce,P.block_start-=ce,oe=Y=P.hash_size;R=P.head[--oe],P.head[oe]=ce<=R?R-ce:0,--Y;);for(oe=Y=ce;R=P.prev[--oe],P.prev[oe]=ce<=R?R-ce:0,--Y;);I+=ce}if(P.strm.avail_in===0)break;if(re=P.strm,ue=P.window,ae=P.strstart+P.lookahead,ge=I,we=void 0,we=re.avail_in,ge<we&&(we=ge),Y=we===0?0:(re.avail_in-=we,a.arraySet(ue,re.input,re.next_in,we,ae),re.state.wrap===1?re.adler=c(re.adler,ue,we,ae):re.state.wrap===2&&(re.adler=u(re.adler,ue,we,ae)),re.next_in+=we,re.total_in+=we,we),P.lookahead+=Y,P.lookahead+P.insert>=E)for(U=P.strstart-P.insert,P.ins_h=P.window[U],P.ins_h=(P.ins_h<<P.hash_shift^P.window[U+1])&P.hash_mask;P.insert&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[U+E-1])&P.hash_mask,P.prev[U&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=U,U++,P.insert--,!(P.lookahead+P.insert<E)););}while(P.lookahead<$&&P.strm.avail_in!==0)}function q(P,oe){for(var Y,R;;){if(P.lookahead<$){if(se(P),P.lookahead<$&&oe===h)return k;if(P.lookahead===0)break}if(Y=0,P.lookahead>=E&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+E-1])&P.hash_mask,Y=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),Y!==0&&P.strstart-Y<=P.w_size-$&&(P.match_length=ie(P,Y)),P.match_length>=E)if(R=l._tr_tally(P,P.strstart-P.match_start,P.match_length-E),P.lookahead-=P.match_length,P.match_length<=P.max_lazy_match&&P.lookahead>=E){for(P.match_length--;P.strstart++,P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+E-1])&P.hash_mask,Y=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart,--P.match_length!=0;);P.strstart++}else P.strstart+=P.match_length,P.match_length=0,P.ins_h=P.window[P.strstart],P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+1])&P.hash_mask;else R=l._tr_tally(P,0,P.window[P.strstart]),P.lookahead--,P.strstart++;if(R&&(F(P,!1),P.strm.avail_out===0))return k}return P.insert=P.strstart<E-1?P.strstart:E-1,oe===f?(F(P,!0),P.strm.avail_out===0?K:H):P.last_lit&&(F(P,!1),P.strm.avail_out===0)?k:D}function L(P,oe){for(var Y,R,I;;){if(P.lookahead<$){if(se(P),P.lookahead<$&&oe===h)return k;if(P.lookahead===0)break}if(Y=0,P.lookahead>=E&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+E-1])&P.hash_mask,Y=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),P.prev_length=P.match_length,P.prev_match=P.match_start,P.match_length=E-1,Y!==0&&P.prev_length<P.max_lazy_match&&P.strstart-Y<=P.w_size-$&&(P.match_length=ie(P,Y),P.match_length<=5&&(P.strategy===1||P.match_length===E&&4096<P.strstart-P.match_start)&&(P.match_length=E-1)),P.prev_length>=E&&P.match_length<=P.prev_length){for(I=P.strstart+P.lookahead-E,R=l._tr_tally(P,P.strstart-1-P.prev_match,P.prev_length-E),P.lookahead-=P.prev_length-1,P.prev_length-=2;++P.strstart<=I&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+E-1])&P.hash_mask,Y=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),--P.prev_length!=0;);if(P.match_available=0,P.match_length=E-1,P.strstart++,R&&(F(P,!1),P.strm.avail_out===0))return k}else if(P.match_available){if((R=l._tr_tally(P,0,P.window[P.strstart-1]))&&F(P,!1),P.strstart++,P.lookahead--,P.strm.avail_out===0)return k}else P.match_available=1,P.strstart++,P.lookahead--}return P.match_available&&(R=l._tr_tally(P,0,P.window[P.strstart-1]),P.match_available=0),P.insert=P.strstart<E-1?P.strstart:E-1,oe===f?(F(P,!0),P.strm.avail_out===0?K:H):P.last_lit&&(F(P,!1),P.strm.avail_out===0)?k:D}function Z(P,oe,Y,R,I){this.good_length=P,this.max_lazy=oe,this.nice_length=Y,this.max_chain=R,this.func=I}function J(){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*C),this.dyn_dtree=new a.Buf16(2*(2*j+1)),this.bl_tree=new a.Buf16(2*(2*N+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(A+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 W(P){var oe;return P&&P.state?(P.total_in=P.total_out=0,P.data_type=x,(oe=P.state).pending=0,oe.pending_out=0,oe.wrap<0&&(oe.wrap=-oe.wrap),oe.status=oe.wrap?T:M,P.adler=oe.wrap===2?0:1,oe.last_flush=h,l._tr_init(oe),p):ee(P,m)}function X(P){var oe=W(P);return oe===p&&function(Y){Y.window_size=2*Y.w_size,B(Y.head),Y.max_lazy_match=i[Y.level].max_lazy,Y.good_match=i[Y.level].good_length,Y.nice_match=i[Y.level].nice_length,Y.max_chain_length=i[Y.level].max_chain,Y.strstart=0,Y.block_start=0,Y.lookahead=0,Y.insert=0,Y.match_length=Y.prev_length=E-1,Y.match_available=0,Y.ins_h=0}(P.state),oe}function he(P,oe,Y,R,I,U){if(!P)return m;var re=1;if(oe===g&&(oe=6),R<0?(re=0,R=-R):15<R&&(re=2,R-=16),I<1||b<I||Y!==v||R<8||15<R||oe<0||9<oe||U<0||y<U)return ee(P,m);R===8&&(R=9);var ue=new J;return(P.state=ue).strm=P,ue.wrap=re,ue.gzhead=null,ue.w_bits=R,ue.w_size=1<<ue.w_bits,ue.w_mask=ue.w_size-1,ue.hash_bits=I+7,ue.hash_size=1<<ue.hash_bits,ue.hash_mask=ue.hash_size-1,ue.hash_shift=~~((ue.hash_bits+E-1)/E),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<<I+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=oe,ue.strategy=U,ue.method=Y,X(P)}i=[new Z(0,0,0,0,function(P,oe){var Y=65535;for(Y>P.pending_buf_size-5&&(Y=P.pending_buf_size-5);;){if(P.lookahead<=1){if(se(P),P.lookahead===0&&oe===h)return k;if(P.lookahead===0)break}P.strstart+=P.lookahead,P.lookahead=0;var R=P.block_start+Y;if((P.strstart===0||P.strstart>=R)&&(P.lookahead=P.strstart-R,P.strstart=R,F(P,!1),P.strm.avail_out===0)||P.strstart-P.block_start>=P.w_size-$&&(F(P,!1),P.strm.avail_out===0))return k}return P.insert=0,oe===f?(F(P,!0),P.strm.avail_out===0?K:H):(P.strstart>P.block_start&&(F(P,!1),P.strm.avail_out),k)}),new Z(4,4,8,4,q),new Z(4,5,16,8,q),new Z(4,6,32,32,q),new Z(4,4,16,16,L),new Z(8,16,32,32,L),new Z(8,16,128,128,L),new Z(8,32,128,256,L),new Z(32,128,258,1024,L),new Z(32,258,258,4096,L)],s.deflateInit=function(P,oe){return he(P,oe,v,15,8,0)},s.deflateInit2=he,s.deflateReset=X,s.deflateResetKeep=W,s.deflateSetHeader=function(P,oe){return P&&P.state?P.state.wrap!==2?m:(P.state.gzhead=oe,p):m},s.deflate=function(P,oe){var Y,R,I,U;if(!P||!P.state||5<oe||oe<0)return P?ee(P,m):m;if(R=P.state,!P.output||!P.input&&P.avail_in!==0||R.status===666&&oe!==f)return ee(P,P.avail_out===0?-5:m);if(R.strm=P,Y=R.last_flush,R.last_flush=oe,R.status===T)if(R.wrap===2)P.adler=0,G(R,31),G(R,139),G(R,8),R.gzhead?(G(R,(R.gzhead.text?1:0)+(R.gzhead.hcrc?2:0)+(R.gzhead.extra?4:0)+(R.gzhead.name?8:0)+(R.gzhead.comment?16:0)),G(R,255&R.gzhead.time),G(R,R.gzhead.time>>8&255),G(R,R.gzhead.time>>16&255),G(R,R.gzhead.time>>24&255),G(R,R.level===9?2:2<=R.strategy||R.level<2?4:0),G(R,255&R.gzhead.os),R.gzhead.extra&&R.gzhead.extra.length&&(G(R,255&R.gzhead.extra.length),G(R,R.gzhead.extra.length>>8&255)),R.gzhead.hcrc&&(P.adler=u(P.adler,R.pending_buf,R.pending,0)),R.gzindex=0,R.status=69):(G(R,0),G(R,0),G(R,0),G(R,0),G(R,0),G(R,R.level===9?2:2<=R.strategy||R.level<2?4:0),G(R,3),R.status=M);else{var re=v+(R.w_bits-8<<4)<<8;re|=(2<=R.strategy||R.level<2?0:R.level<6?1:R.level===6?2:3)<<6,R.strstart!==0&&(re|=32),re+=31-re%31,R.status=M,Q(R,re),R.strstart!==0&&(Q(R,P.adler>>>16),Q(R,65535&P.adler)),P.adler=1}if(R.status===69)if(R.gzhead.extra){for(I=R.pending;R.gzindex<(65535&R.gzhead.extra.length)&&(R.pending!==R.pending_buf_size||(R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),z(P),I=R.pending,R.pending!==R.pending_buf_size));)G(R,255&R.gzhead.extra[R.gzindex]),R.gzindex++;R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),R.gzindex===R.gzhead.extra.length&&(R.gzindex=0,R.status=73)}else R.status=73;if(R.status===73)if(R.gzhead.name){I=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),z(P),I=R.pending,R.pending===R.pending_buf_size)){U=1;break}U=R.gzindex<R.gzhead.name.length?255&R.gzhead.name.charCodeAt(R.gzindex++):0,G(R,U)}while(U!==0);R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),U===0&&(R.gzindex=0,R.status=91)}else R.status=91;if(R.status===91)if(R.gzhead.comment){I=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),z(P),I=R.pending,R.pending===R.pending_buf_size)){U=1;break}U=R.gzindex<R.gzhead.comment.length?255&R.gzhead.comment.charCodeAt(R.gzindex++):0,G(R,U)}while(U!==0);R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),U===0&&(R.status=103)}else R.status=103;if(R.status===103&&(R.gzhead.hcrc?(R.pending+2>R.pending_buf_size&&z(P),R.pending+2<=R.pending_buf_size&&(G(R,255&P.adler),G(R,P.adler>>8&255),P.adler=0,R.status=M)):R.status=M),R.pending!==0){if(z(P),P.avail_out===0)return R.last_flush=-1,p}else if(P.avail_in===0&&V(oe)<=V(Y)&&oe!==f)return ee(P,-5);if(R.status===666&&P.avail_in!==0)return ee(P,-5);if(P.avail_in!==0||R.lookahead!==0||oe!==h&&R.status!==666){var ue=R.strategy===2?function(ae,ge){for(var we;;){if(ae.lookahead===0&&(se(ae),ae.lookahead===0)){if(ge===h)return k;break}if(ae.match_length=0,we=l._tr_tally(ae,0,ae.window[ae.strstart]),ae.lookahead--,ae.strstart++,we&&(F(ae,!1),ae.strm.avail_out===0))return k}return ae.insert=0,ge===f?(F(ae,!0),ae.strm.avail_out===0?K:H):ae.last_lit&&(F(ae,!1),ae.strm.avail_out===0)?k:D}(R,oe):R.strategy===3?function(ae,ge){for(var we,ce,ne,fe,be=ae.window;;){if(ae.lookahead<=O){if(se(ae),ae.lookahead<=O&&ge===h)return k;if(ae.lookahead===0)break}if(ae.match_length=0,ae.lookahead>=E&&0<ae.strstart&&(ce=be[ne=ae.strstart-1])===be[++ne]&&ce===be[++ne]&&ce===be[++ne]){fe=ae.strstart+O;do;while(ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ne<fe);ae.match_length=O-(fe-ne),ae.match_length>ae.lookahead&&(ae.match_length=ae.lookahead)}if(ae.match_length>=E?(we=l._tr_tally(ae,1,ae.match_length-E),ae.lookahead-=ae.match_length,ae.strstart+=ae.match_length,ae.match_length=0):(we=l._tr_tally(ae,0,ae.window[ae.strstart]),ae.lookahead--,ae.strstart++),we&&(F(ae,!1),ae.strm.avail_out===0))return k}return ae.insert=0,ge===f?(F(ae,!0),ae.strm.avail_out===0?K:H):ae.last_lit&&(F(ae,!1),ae.strm.avail_out===0)?k:D}(R,oe):i[R.level].func(R,oe);if(ue!==K&&ue!==H||(R.status=666),ue===k||ue===K)return P.avail_out===0&&(R.last_flush=-1),p;if(ue===D&&(oe===1?l._tr_align(R):oe!==5&&(l._tr_stored_block(R,0,0,!1),oe===3&&(B(R.head),R.lookahead===0&&(R.strstart=0,R.block_start=0,R.insert=0))),z(P),P.avail_out===0))return R.last_flush=-1,p}return oe!==f?p:R.wrap<=0?1:(R.wrap===2?(G(R,255&P.adler),G(R,P.adler>>8&255),G(R,P.adler>>16&255),G(R,P.adler>>24&255),G(R,255&P.total_in),G(R,P.total_in>>8&255),G(R,P.total_in>>16&255),G(R,P.total_in>>24&255)):(Q(R,P.adler>>>16),Q(R,65535&P.adler)),z(P),0<R.wrap&&(R.wrap=-R.wrap),R.pending!==0?p:1)},s.deflateEnd=function(P){var oe;return P&&P.state?(oe=P.state.status)!==T&&oe!==69&&oe!==73&&oe!==91&&oe!==103&&oe!==M&&oe!==666?ee(P,m):(P.state=null,oe===M?ee(P,-3):p):m},s.deflateSetDictionary=function(P,oe){var Y,R,I,U,re,ue,ae,ge,we=oe.length;if(!P||!P.state||(U=(Y=P.state).wrap)===2||U===1&&Y.status!==T||Y.lookahead)return m;for(U===1&&(P.adler=c(P.adler,oe,we,0)),Y.wrap=0,we>=Y.w_size&&(U===0&&(B(Y.head),Y.strstart=0,Y.block_start=0,Y.insert=0),ge=new a.Buf8(Y.w_size),a.arraySet(ge,oe,we-Y.w_size,Y.w_size,0),oe=ge,we=Y.w_size),re=P.avail_in,ue=P.next_in,ae=P.input,P.avail_in=we,P.next_in=0,P.input=oe,se(Y);Y.lookahead>=E;){for(R=Y.strstart,I=Y.lookahead-(E-1);Y.ins_h=(Y.ins_h<<Y.hash_shift^Y.window[R+E-1])&Y.hash_mask,Y.prev[R&Y.w_mask]=Y.head[Y.ins_h],Y.head[Y.ins_h]=R,R++,--I;);Y.strstart=R,Y.lookahead=E-1,se(Y)}return Y.strstart+=Y.lookahead,Y.block_start=Y.strstart,Y.insert=Y.lookahead,Y.lookahead=0,Y.match_length=Y.prev_length=E-1,Y.match_available=0,P.next_in=ue,P.input=ae,P.avail_in=re,Y.wrap=U,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 l,c,u,d,h,f,p,m,g,y,x,v,b,w,j,N,C,A,E,O,$,T,M,k,D;l=i.state,c=i.next_in,k=i.input,u=c+(i.avail_in-5),d=i.next_out,D=i.output,h=d-(a-i.avail_out),f=d+(i.avail_out-257),p=l.dmax,m=l.wsize,g=l.whave,y=l.wnext,x=l.window,v=l.hold,b=l.bits,w=l.lencode,j=l.distcode,N=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{b<15&&(v+=k[c++]<<b,b+=8,v+=k[c++]<<b,b+=8),A=w[v&N];t:for(;;){if(v>>>=E=A>>>24,b-=E,(E=A>>>16&255)===0)D[d++]=65535&A;else{if(!(16&E)){if(!(64&E)){A=w[(65535&A)+(v&(1<<E)-1)];continue t}if(32&E){l.mode=12;break e}i.msg="invalid literal/length code",l.mode=30;break e}O=65535&A,(E&=15)&&(b<E&&(v+=k[c++]<<b,b+=8),O+=v&(1<<E)-1,v>>>=E,b-=E),b<15&&(v+=k[c++]<<b,b+=8,v+=k[c++]<<b,b+=8),A=j[v&C];r:for(;;){if(v>>>=E=A>>>24,b-=E,!(16&(E=A>>>16&255))){if(!(64&E)){A=j[(65535&A)+(v&(1<<E)-1)];continue r}i.msg="invalid distance code",l.mode=30;break e}if($=65535&A,b<(E&=15)&&(v+=k[c++]<<b,(b+=8)<E&&(v+=k[c++]<<b,b+=8)),p<($+=v&(1<<E)-1)){i.msg="invalid distance too far back",l.mode=30;break e}if(v>>>=E,b-=E,(E=d-h)<$){if(g<(E=$-E)&&l.sane){i.msg="invalid distance too far back",l.mode=30;break e}if(M=x,(T=0)===y){if(T+=m-E,E<O){for(O-=E;D[d++]=x[T++],--E;);T=d-$,M=D}}else if(y<E){if(T+=m+y-E,(E-=y)<O){for(O-=E;D[d++]=x[T++],--E;);if(T=0,y<O){for(O-=E=y;D[d++]=x[T++],--E;);T=d-$,M=D}}}else if(T+=y-E,E<O){for(O-=E;D[d++]=x[T++],--E;);T=d-$,M=D}for(;2<O;)D[d++]=M[T++],D[d++]=M[T++],D[d++]=M[T++],O-=3;O&&(D[d++]=M[T++],1<O&&(D[d++]=M[T++]))}else{for(T=d-$;D[d++]=D[T++],D[d++]=D[T++],D[d++]=D[T++],2<(O-=3););O&&(D[d++]=D[T++],1<O&&(D[d++]=D[T++]))}break}}break}}while(c<u&&d<f);c-=O=b>>3,v&=(1<<(b-=O<<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),l.hold=v,l.bits=b}},{}],49:[function(r,n,s){var i=r("../utils/common"),a=r("./adler32"),l=r("./crc32"),c=r("./inffast"),u=r("./inftrees"),d=1,h=2,f=0,p=-2,m=1,g=852,y=592;function x(T){return(T>>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<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(T){var M;return T&&T.state?(M=T.state,T.total_in=T.total_out=M.total=0,T.msg="",M.wrap&&(T.adler=1&M.wrap),M.mode=m,M.last=0,M.havedict=0,M.dmax=32768,M.head=null,M.hold=0,M.bits=0,M.lencode=M.lendyn=new i.Buf32(g),M.distcode=M.distdyn=new i.Buf32(y),M.sane=1,M.back=-1,f):p}function w(T){var M;return T&&T.state?((M=T.state).wsize=0,M.whave=0,M.wnext=0,b(T)):p}function j(T,M){var k,D;return T&&T.state?(D=T.state,M<0?(k=0,M=-M):(k=1+(M>>4),M<48&&(M&=15)),M&&(M<8||15<M)?p:(D.window!==null&&D.wbits!==M&&(D.window=null),D.wrap=k,D.wbits=M,w(T))):p}function N(T,M){var k,D;return T?(D=new v,(T.state=D).window=null,(k=j(T,M))!==f&&(T.state=null),k):p}var C,A,E=!0;function O(T){if(E){var M;for(C=new i.Buf32(512),A=new i.Buf32(32),M=0;M<144;)T.lens[M++]=8;for(;M<256;)T.lens[M++]=9;for(;M<280;)T.lens[M++]=7;for(;M<288;)T.lens[M++]=8;for(u(d,T.lens,0,288,C,0,T.work,{bits:9}),M=0;M<32;)T.lens[M++]=5;u(h,T.lens,0,32,A,0,T.work,{bits:5}),E=!1}T.lencode=C,T.lenbits=9,T.distcode=A,T.distbits=5}function $(T,M,k,D){var K,H=T.state;return H.window===null&&(H.wsize=1<<H.wbits,H.wnext=0,H.whave=0,H.window=new i.Buf8(H.wsize)),D>=H.wsize?(i.arraySet(H.window,M,k-H.wsize,H.wsize,0),H.wnext=0,H.whave=H.wsize):(D<(K=H.wsize-H.wnext)&&(K=D),i.arraySet(H.window,M,k-D,K,H.wnext),(D-=K)?(i.arraySet(H.window,M,k-D,D,0),H.wnext=D,H.whave=H.wsize):(H.wnext+=K,H.wnext===H.wsize&&(H.wnext=0),H.whave<H.wsize&&(H.whave+=K))),0}s.inflateReset=w,s.inflateReset2=j,s.inflateResetKeep=b,s.inflateInit=function(T){return N(T,15)},s.inflateInit2=N,s.inflate=function(T,M){var k,D,K,H,ee,V,B,z,F,G,Q,ie,se,q,L,Z,J,W,X,he,P,oe,Y,R,I=0,U=new i.Buf8(4),re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return p;(k=T.state).mode===12&&(k.mode=13),ee=T.next_out,K=T.output,B=T.avail_out,H=T.next_in,D=T.input,V=T.avail_in,z=k.hold,F=k.bits,G=V,Q=B,oe=f;e:for(;;)switch(k.mode){case m:if(k.wrap===0){k.mode=13;break}for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(2&k.wrap&&z===35615){U[k.check=0]=255&z,U[1]=z>>>8&255,k.check=l(k.check,U,2,0),F=z=0,k.mode=2;break}if(k.flags=0,k.head&&(k.head.done=!1),!(1&k.wrap)||(((255&z)<<8)+(z>>8))%31){T.msg="incorrect header check",k.mode=30;break}if((15&z)!=8){T.msg="unknown compression method",k.mode=30;break}if(F-=4,P=8+(15&(z>>>=4)),k.wbits===0)k.wbits=P;else if(P>k.wbits){T.msg="invalid window size",k.mode=30;break}k.dmax=1<<P,T.adler=k.check=1,k.mode=512&z?10:12,F=z=0;break;case 2:for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(k.flags=z,(255&k.flags)!=8){T.msg="unknown compression method",k.mode=30;break}if(57344&k.flags){T.msg="unknown header flags set",k.mode=30;break}k.head&&(k.head.text=z>>8&1),512&k.flags&&(U[0]=255&z,U[1]=z>>>8&255,k.check=l(k.check,U,2,0)),F=z=0,k.mode=3;case 3:for(;F<32;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.head&&(k.head.time=z),512&k.flags&&(U[0]=255&z,U[1]=z>>>8&255,U[2]=z>>>16&255,U[3]=z>>>24&255,k.check=l(k.check,U,4,0)),F=z=0,k.mode=4;case 4:for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.head&&(k.head.xflags=255&z,k.head.os=z>>8),512&k.flags&&(U[0]=255&z,U[1]=z>>>8&255,k.check=l(k.check,U,2,0)),F=z=0,k.mode=5;case 5:if(1024&k.flags){for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.length=z,k.head&&(k.head.extra_len=z),512&k.flags&&(U[0]=255&z,U[1]=z>>>8&255,k.check=l(k.check,U,2,0)),F=z=0}else k.head&&(k.head.extra=null);k.mode=6;case 6:if(1024&k.flags&&(V<(ie=k.length)&&(ie=V),ie&&(k.head&&(P=k.head.extra_len-k.length,k.head.extra||(k.head.extra=new Array(k.head.extra_len)),i.arraySet(k.head.extra,D,H,ie,P)),512&k.flags&&(k.check=l(k.check,D,ie,H)),V-=ie,H+=ie,k.length-=ie),k.length))break e;k.length=0,k.mode=7;case 7:if(2048&k.flags){if(V===0)break e;for(ie=0;P=D[H+ie++],k.head&&P&&k.length<65536&&(k.head.name+=String.fromCharCode(P)),P&&ie<V;);if(512&k.flags&&(k.check=l(k.check,D,ie,H)),V-=ie,H+=ie,P)break e}else k.head&&(k.head.name=null);k.length=0,k.mode=8;case 8:if(4096&k.flags){if(V===0)break e;for(ie=0;P=D[H+ie++],k.head&&P&&k.length<65536&&(k.head.comment+=String.fromCharCode(P)),P&&ie<V;);if(512&k.flags&&(k.check=l(k.check,D,ie,H)),V-=ie,H+=ie,P)break e}else k.head&&(k.head.comment=null);k.mode=9;case 9:if(512&k.flags){for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(z!==(65535&k.check)){T.msg="header crc mismatch",k.mode=30;break}F=z=0}k.head&&(k.head.hcrc=k.flags>>9&1,k.head.done=!0),T.adler=k.check=0,k.mode=12;break;case 10:for(;F<32;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}T.adler=k.check=x(z),F=z=0,k.mode=11;case 11:if(k.havedict===0)return T.next_out=ee,T.avail_out=B,T.next_in=H,T.avail_in=V,k.hold=z,k.bits=F,2;T.adler=k.check=1,k.mode=12;case 12:if(M===5||M===6)break e;case 13:if(k.last){z>>>=7&F,F-=7&F,k.mode=27;break}for(;F<3;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}switch(k.last=1&z,F-=1,3&(z>>>=1)){case 0:k.mode=14;break;case 1:if(O(k),k.mode=20,M!==6)break;z>>>=2,F-=2;break e;case 2:k.mode=17;break;case 3:T.msg="invalid block type",k.mode=30}z>>>=2,F-=2;break;case 14:for(z>>>=7&F,F-=7&F;F<32;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if((65535&z)!=(z>>>16^65535)){T.msg="invalid stored block lengths",k.mode=30;break}if(k.length=65535&z,F=z=0,k.mode=15,M===6)break e;case 15:k.mode=16;case 16:if(ie=k.length){if(V<ie&&(ie=V),B<ie&&(ie=B),ie===0)break e;i.arraySet(K,D,H,ie,ee),V-=ie,H+=ie,B-=ie,ee+=ie,k.length-=ie;break}k.mode=12;break;case 17:for(;F<14;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(k.nlen=257+(31&z),z>>>=5,F-=5,k.ndist=1+(31&z),z>>>=5,F-=5,k.ncode=4+(15&z),z>>>=4,F-=4,286<k.nlen||30<k.ndist){T.msg="too many length or distance symbols",k.mode=30;break}k.have=0,k.mode=18;case 18:for(;k.have<k.ncode;){for(;F<3;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.lens[re[k.have++]]=7&z,z>>>=3,F-=3}for(;k.have<19;)k.lens[re[k.have++]]=0;if(k.lencode=k.lendyn,k.lenbits=7,Y={bits:k.lenbits},oe=u(0,k.lens,0,19,k.lencode,0,k.work,Y),k.lenbits=Y.bits,oe){T.msg="invalid code lengths set",k.mode=30;break}k.have=0,k.mode=19;case 19:for(;k.have<k.nlen+k.ndist;){for(;Z=(I=k.lencode[z&(1<<k.lenbits)-1])>>>16&255,J=65535&I,!((L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(J<16)z>>>=L,F-=L,k.lens[k.have++]=J;else{if(J===16){for(R=L+2;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(z>>>=L,F-=L,k.have===0){T.msg="invalid bit length repeat",k.mode=30;break}P=k.lens[k.have-1],ie=3+(3&z),z>>>=2,F-=2}else if(J===17){for(R=L+3;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}F-=L,P=0,ie=3+(7&(z>>>=L)),z>>>=3,F-=3}else{for(R=L+7;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}F-=L,P=0,ie=11+(127&(z>>>=L)),z>>>=7,F-=7}if(k.have+ie>k.nlen+k.ndist){T.msg="invalid bit length repeat",k.mode=30;break}for(;ie--;)k.lens[k.have++]=P}}if(k.mode===30)break;if(k.lens[256]===0){T.msg="invalid code -- missing end-of-block",k.mode=30;break}if(k.lenbits=9,Y={bits:k.lenbits},oe=u(d,k.lens,0,k.nlen,k.lencode,0,k.work,Y),k.lenbits=Y.bits,oe){T.msg="invalid literal/lengths set",k.mode=30;break}if(k.distbits=6,k.distcode=k.distdyn,Y={bits:k.distbits},oe=u(h,k.lens,k.nlen,k.ndist,k.distcode,0,k.work,Y),k.distbits=Y.bits,oe){T.msg="invalid distances set",k.mode=30;break}if(k.mode=20,M===6)break e;case 20:k.mode=21;case 21:if(6<=V&&258<=B){T.next_out=ee,T.avail_out=B,T.next_in=H,T.avail_in=V,k.hold=z,k.bits=F,c(T,Q),ee=T.next_out,K=T.output,B=T.avail_out,H=T.next_in,D=T.input,V=T.avail_in,z=k.hold,F=k.bits,k.mode===12&&(k.back=-1);break}for(k.back=0;Z=(I=k.lencode[z&(1<<k.lenbits)-1])>>>16&255,J=65535&I,!((L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(Z&&!(240&Z)){for(W=L,X=Z,he=J;Z=(I=k.lencode[he+((z&(1<<W+X)-1)>>W)])>>>16&255,J=65535&I,!(W+(L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}z>>>=W,F-=W,k.back+=W}if(z>>>=L,F-=L,k.back+=L,k.length=J,Z===0){k.mode=26;break}if(32&Z){k.back=-1,k.mode=12;break}if(64&Z){T.msg="invalid literal/length code",k.mode=30;break}k.extra=15&Z,k.mode=22;case 22:if(k.extra){for(R=k.extra;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.length+=z&(1<<k.extra)-1,z>>>=k.extra,F-=k.extra,k.back+=k.extra}k.was=k.length,k.mode=23;case 23:for(;Z=(I=k.distcode[z&(1<<k.distbits)-1])>>>16&255,J=65535&I,!((L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(!(240&Z)){for(W=L,X=Z,he=J;Z=(I=k.distcode[he+((z&(1<<W+X)-1)>>W)])>>>16&255,J=65535&I,!(W+(L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}z>>>=W,F-=W,k.back+=W}if(z>>>=L,F-=L,k.back+=L,64&Z){T.msg="invalid distance code",k.mode=30;break}k.offset=J,k.extra=15&Z,k.mode=24;case 24:if(k.extra){for(R=k.extra;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.offset+=z&(1<<k.extra)-1,z>>>=k.extra,F-=k.extra,k.back+=k.extra}if(k.offset>k.dmax){T.msg="invalid distance too far back",k.mode=30;break}k.mode=25;case 25:if(B===0)break e;if(ie=Q-B,k.offset>ie){if((ie=k.offset-ie)>k.whave&&k.sane){T.msg="invalid distance too far back",k.mode=30;break}se=ie>k.wnext?(ie-=k.wnext,k.wsize-ie):k.wnext-ie,ie>k.length&&(ie=k.length),q=k.window}else q=K,se=ee-k.offset,ie=k.length;for(B<ie&&(ie=B),B-=ie,k.length-=ie;K[ee++]=q[se++],--ie;);k.length===0&&(k.mode=21);break;case 26:if(B===0)break e;K[ee++]=k.length,B--,k.mode=21;break;case 27:if(k.wrap){for(;F<32;){if(V===0)break e;V--,z|=D[H++]<<F,F+=8}if(Q-=B,T.total_out+=Q,k.total+=Q,Q&&(T.adler=k.check=k.flags?l(k.check,K,Q,ee-Q):a(k.check,K,Q,ee-Q)),Q=B,(k.flags?z:x(z))!==k.check){T.msg="incorrect data check",k.mode=30;break}F=z=0}k.mode=28;case 28:if(k.wrap&&k.flags){for(;F<32;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(z!==(4294967295&k.total)){T.msg="incorrect length check",k.mode=30;break}F=z=0}k.mode=29;case 29:oe=1;break e;case 30:oe=-3;break e;case 31:return-4;case 32:default:return p}return T.next_out=ee,T.avail_out=B,T.next_in=H,T.avail_in=V,k.hold=z,k.bits=F,(k.wsize||Q!==T.avail_out&&k.mode<30&&(k.mode<27||M!==4))&&$(T,T.output,T.next_out,Q-T.avail_out)?(k.mode=31,-4):(G-=T.avail_in,Q-=T.avail_out,T.total_in+=G,T.total_out+=Q,k.total+=Q,k.wrap&&Q&&(T.adler=k.check=k.flags?l(k.check,K,Q,T.next_out-Q):a(k.check,K,Q,T.next_out-Q)),T.data_type=k.bits+(k.last?64:0)+(k.mode===12?128:0)+(k.mode===20||k.mode===15?256:0),(G==0&&Q===0||M===4)&&oe===f&&(oe=-5),oe)},s.inflateEnd=function(T){if(!T||!T.state)return p;var M=T.state;return M.window&&(M.window=null),T.state=null,f},s.inflateGetHeader=function(T,M){var k;return T&&T.state&&2&(k=T.state).wrap?((k.head=M).done=!1,f):p},s.inflateSetDictionary=function(T,M){var k,D=M.length;return T&&T.state?(k=T.state).wrap!==0&&k.mode!==11?p:k.mode===11&&a(1,M,D,0)!==k.check?-3:$(T,M,D,D)?(k.mode=31,-4):(k.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],l=[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,y,x){var v,b,w,j,N,C,A,E,O,$=x.bits,T=0,M=0,k=0,D=0,K=0,H=0,ee=0,V=0,B=0,z=0,F=null,G=0,Q=new i.Buf16(16),ie=new i.Buf16(16),se=null,q=0;for(T=0;T<=15;T++)Q[T]=0;for(M=0;M<p;M++)Q[h[f+M]]++;for(K=$,D=15;1<=D&&Q[D]===0;D--);if(D<K&&(K=D),D===0)return m[g++]=20971520,m[g++]=20971520,x.bits=1,0;for(k=1;k<D&&Q[k]===0;k++);for(K<k&&(K=k),T=V=1;T<=15;T++)if(V<<=1,(V-=Q[T])<0)return-1;if(0<V&&(d===0||D!==1))return-1;for(ie[1]=0,T=1;T<15;T++)ie[T+1]=ie[T]+Q[T];for(M=0;M<p;M++)h[f+M]!==0&&(y[ie[h[f+M]]++]=M);if(C=d===0?(F=se=y,19):d===1?(F=a,G-=257,se=l,q-=257,256):(F=c,se=u,-1),T=k,N=g,ee=M=z=0,w=-1,j=(B=1<<(H=K))-1,d===1&&852<B||d===2&&592<B)return 1;for(;;){for(A=T-ee,O=y[M]<C?(E=0,y[M]):y[M]>C?(E=se[q+y[M]],F[G+y[M]]):(E=96,0),v=1<<T-ee,k=b=1<<H;m[N+(z>>ee)+(b-=v)]=A<<24|E<<16|O|0,b!==0;);for(v=1<<T-1;z&v;)v>>=1;if(v!==0?(z&=v-1,z+=v):z=0,M++,--Q[T]==0){if(T===D)break;T=h[f+y[M]]}if(K<T&&(z&j)!==w){for(ee===0&&(ee=K),N+=k,V=1<<(H=T-ee);H+ee<D&&!((V-=Q[H+ee])<=0);)H++,V<<=1;if(B+=1<<H,d===1&&852<B||d===2&&592<B)return 1;m[w=z&j]=K<<24|H<<16|N-g|0}}return z!==0&&(m[N+z]=T-ee<<24|64<<16|0),x.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,l=1;function c(I){for(var U=I.length;0<=--U;)I[U]=0}var u=0,d=29,h=256,f=h+1+d,p=30,m=19,g=2*f+1,y=15,x=16,v=7,b=256,w=16,j=17,N=18,C=[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],A=[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],E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],$=new Array(2*(f+2));c($);var T=new Array(2*p);c(T);var M=new Array(512);c(M);var k=new Array(256);c(k);var D=new Array(d);c(D);var K,H,ee,V=new Array(p);function B(I,U,re,ue,ae){this.static_tree=I,this.extra_bits=U,this.extra_base=re,this.elems=ue,this.max_length=ae,this.has_stree=I&&I.length}function z(I,U){this.dyn_tree=I,this.max_code=0,this.stat_desc=U}function F(I){return I<256?M[I]:M[256+(I>>>7)]}function G(I,U){I.pending_buf[I.pending++]=255&U,I.pending_buf[I.pending++]=U>>>8&255}function Q(I,U,re){I.bi_valid>x-re?(I.bi_buf|=U<<I.bi_valid&65535,G(I,I.bi_buf),I.bi_buf=U>>x-I.bi_valid,I.bi_valid+=re-x):(I.bi_buf|=U<<I.bi_valid&65535,I.bi_valid+=re)}function ie(I,U,re){Q(I,re[2*U],re[2*U+1])}function se(I,U){for(var re=0;re|=1&I,I>>>=1,re<<=1,0<--U;);return re>>>1}function q(I,U,re){var ue,ae,ge=new Array(y+1),we=0;for(ue=1;ue<=y;ue++)ge[ue]=we=we+re[ue-1]<<1;for(ae=0;ae<=U;ae++){var ce=I[2*ae+1];ce!==0&&(I[2*ae]=se(ge[ce]++,ce))}}function L(I){var U;for(U=0;U<f;U++)I.dyn_ltree[2*U]=0;for(U=0;U<p;U++)I.dyn_dtree[2*U]=0;for(U=0;U<m;U++)I.bl_tree[2*U]=0;I.dyn_ltree[2*b]=1,I.opt_len=I.static_len=0,I.last_lit=I.matches=0}function Z(I){8<I.bi_valid?G(I,I.bi_buf):0<I.bi_valid&&(I.pending_buf[I.pending++]=I.bi_buf),I.bi_buf=0,I.bi_valid=0}function J(I,U,re,ue){var ae=2*U,ge=2*re;return I[ae]<I[ge]||I[ae]===I[ge]&&ue[U]<=ue[re]}function W(I,U,re){for(var ue=I.heap[re],ae=re<<1;ae<=I.heap_len&&(ae<I.heap_len&&J(U,I.heap[ae+1],I.heap[ae],I.depth)&&ae++,!J(U,ue,I.heap[ae],I.depth));)I.heap[re]=I.heap[ae],re=ae,ae<<=1;I.heap[re]=ue}function X(I,U,re){var ue,ae,ge,we,ce=0;if(I.last_lit!==0)for(;ue=I.pending_buf[I.d_buf+2*ce]<<8|I.pending_buf[I.d_buf+2*ce+1],ae=I.pending_buf[I.l_buf+ce],ce++,ue===0?ie(I,ae,U):(ie(I,(ge=k[ae])+h+1,U),(we=C[ge])!==0&&Q(I,ae-=D[ge],we),ie(I,ge=F(--ue),re),(we=A[ge])!==0&&Q(I,ue-=V[ge],we)),ce<I.last_lit;);ie(I,b,U)}function he(I,U){var re,ue,ae,ge=U.dyn_tree,we=U.stat_desc.static_tree,ce=U.stat_desc.has_stree,ne=U.stat_desc.elems,fe=-1;for(I.heap_len=0,I.heap_max=g,re=0;re<ne;re++)ge[2*re]!==0?(I.heap[++I.heap_len]=fe=re,I.depth[re]=0):ge[2*re+1]=0;for(;I.heap_len<2;)ge[2*(ae=I.heap[++I.heap_len]=fe<2?++fe:0)]=1,I.depth[ae]=0,I.opt_len--,ce&&(I.static_len-=we[2*ae+1]);for(U.max_code=fe,re=I.heap_len>>1;1<=re;re--)W(I,ge,re);for(ae=ne;re=I.heap[1],I.heap[1]=I.heap[I.heap_len--],W(I,ge,1),ue=I.heap[1],I.heap[--I.heap_max]=re,I.heap[--I.heap_max]=ue,ge[2*ae]=ge[2*re]+ge[2*ue],I.depth[ae]=(I.depth[re]>=I.depth[ue]?I.depth[re]:I.depth[ue])+1,ge[2*re+1]=ge[2*ue+1]=ae,I.heap[1]=ae++,W(I,ge,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],function(be,xe){var _e,ke,$e,Te,ot,wt,Ct=xe.dyn_tree,pr=xe.max_code,Kt=xe.stat_desc.static_tree,Re=xe.stat_desc.has_stree,ye=xe.stat_desc.extra_bits,Ne=xe.stat_desc.extra_base,Ce=xe.stat_desc.max_length,Fe=0;for(Te=0;Te<=y;Te++)be.bl_count[Te]=0;for(Ct[2*be.heap[be.heap_max]+1]=0,_e=be.heap_max+1;_e<g;_e++)Ce<(Te=Ct[2*Ct[2*(ke=be.heap[_e])+1]+1]+1)&&(Te=Ce,Fe++),Ct[2*ke+1]=Te,pr<ke||(be.bl_count[Te]++,ot=0,Ne<=ke&&(ot=ye[ke-Ne]),wt=Ct[2*ke],be.opt_len+=wt*(Te+ot),Re&&(be.static_len+=wt*(Kt[2*ke+1]+ot)));if(Fe!==0){do{for(Te=Ce-1;be.bl_count[Te]===0;)Te--;be.bl_count[Te]--,be.bl_count[Te+1]+=2,be.bl_count[Ce]--,Fe-=2}while(0<Fe);for(Te=Ce;Te!==0;Te--)for(ke=be.bl_count[Te];ke!==0;)pr<($e=be.heap[--_e])||(Ct[2*$e+1]!==Te&&(be.opt_len+=(Te-Ct[2*$e+1])*Ct[2*$e],Ct[2*$e+1]=Te),ke--)}}(I,U),q(ge,fe,I.bl_count)}function P(I,U,re){var ue,ae,ge=-1,we=U[1],ce=0,ne=7,fe=4;for(we===0&&(ne=138,fe=3),U[2*(re+1)+1]=65535,ue=0;ue<=re;ue++)ae=we,we=U[2*(ue+1)+1],++ce<ne&&ae===we||(ce<fe?I.bl_tree[2*ae]+=ce:ae!==0?(ae!==ge&&I.bl_tree[2*ae]++,I.bl_tree[2*w]++):ce<=10?I.bl_tree[2*j]++:I.bl_tree[2*N]++,ge=ae,fe=(ce=0)===we?(ne=138,3):ae===we?(ne=6,3):(ne=7,4))}function oe(I,U,re){var ue,ae,ge=-1,we=U[1],ce=0,ne=7,fe=4;for(we===0&&(ne=138,fe=3),ue=0;ue<=re;ue++)if(ae=we,we=U[2*(ue+1)+1],!(++ce<ne&&ae===we)){if(ce<fe)for(;ie(I,ae,I.bl_tree),--ce!=0;);else ae!==0?(ae!==ge&&(ie(I,ae,I.bl_tree),ce--),ie(I,w,I.bl_tree),Q(I,ce-3,2)):ce<=10?(ie(I,j,I.bl_tree),Q(I,ce-3,3)):(ie(I,N,I.bl_tree),Q(I,ce-11,7));ge=ae,fe=(ce=0)===we?(ne=138,3):ae===we?(ne=6,3):(ne=7,4)}}c(V);var Y=!1;function R(I,U,re,ue){Q(I,(u<<1)+(ue?1:0),3),function(ae,ge,we,ce){Z(ae),G(ae,we),G(ae,~we),i.arraySet(ae.pending_buf,ae.window,ge,we,ae.pending),ae.pending+=we}(I,U,re)}s._tr_init=function(I){Y||(function(){var U,re,ue,ae,ge,we=new Array(y+1);for(ae=ue=0;ae<d-1;ae++)for(D[ae]=ue,U=0;U<1<<C[ae];U++)k[ue++]=ae;for(k[ue-1]=ae,ae=ge=0;ae<16;ae++)for(V[ae]=ge,U=0;U<1<<A[ae];U++)M[ge++]=ae;for(ge>>=7;ae<p;ae++)for(V[ae]=ge<<7,U=0;U<1<<A[ae]-7;U++)M[256+ge++]=ae;for(re=0;re<=y;re++)we[re]=0;for(U=0;U<=143;)$[2*U+1]=8,U++,we[8]++;for(;U<=255;)$[2*U+1]=9,U++,we[9]++;for(;U<=279;)$[2*U+1]=7,U++,we[7]++;for(;U<=287;)$[2*U+1]=8,U++,we[8]++;for(q($,f+1,we),U=0;U<p;U++)T[2*U+1]=5,T[2*U]=se(U,5);K=new B($,C,h+1,f,y),H=new B(T,A,0,p,y),ee=new B(new Array(0),E,0,m,v)}(),Y=!0),I.l_desc=new z(I.dyn_ltree,K),I.d_desc=new z(I.dyn_dtree,H),I.bl_desc=new z(I.bl_tree,ee),I.bi_buf=0,I.bi_valid=0,L(I)},s._tr_stored_block=R,s._tr_flush_block=function(I,U,re,ue){var ae,ge,we=0;0<I.level?(I.strm.data_type===2&&(I.strm.data_type=function(ce){var ne,fe=4093624447;for(ne=0;ne<=31;ne++,fe>>>=1)if(1&fe&&ce.dyn_ltree[2*ne]!==0)return a;if(ce.dyn_ltree[18]!==0||ce.dyn_ltree[20]!==0||ce.dyn_ltree[26]!==0)return l;for(ne=32;ne<h;ne++)if(ce.dyn_ltree[2*ne]!==0)return l;return a}(I)),he(I,I.l_desc),he(I,I.d_desc),we=function(ce){var ne;for(P(ce,ce.dyn_ltree,ce.l_desc.max_code),P(ce,ce.dyn_dtree,ce.d_desc.max_code),he(ce,ce.bl_desc),ne=m-1;3<=ne&&ce.bl_tree[2*O[ne]+1]===0;ne--);return ce.opt_len+=3*(ne+1)+5+5+4,ne}(I),ae=I.opt_len+3+7>>>3,(ge=I.static_len+3+7>>>3)<=ae&&(ae=ge)):ae=ge=re+5,re+4<=ae&&U!==-1?R(I,U,re,ue):I.strategy===4||ge===ae?(Q(I,2+(ue?1:0),3),X(I,$,T)):(Q(I,4+(ue?1:0),3),function(ce,ne,fe,be){var xe;for(Q(ce,ne-257,5),Q(ce,fe-1,5),Q(ce,be-4,4),xe=0;xe<be;xe++)Q(ce,ce.bl_tree[2*O[xe]+1],3);oe(ce,ce.dyn_ltree,ne-1),oe(ce,ce.dyn_dtree,fe-1)}(I,I.l_desc.max_code+1,I.d_desc.max_code+1,we+1),X(I,I.dyn_ltree,I.dyn_dtree)),L(I),ue&&Z(I)},s._tr_tally=function(I,U,re){return I.pending_buf[I.d_buf+2*I.last_lit]=U>>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&U,I.pending_buf[I.l_buf+I.last_lit]=255&re,I.last_lit++,U===0?I.dyn_ltree[2*re]++:(I.matches++,U--,I.dyn_ltree[2*(k[re]+h+1)]++,I.dyn_dtree[2*F(U)]++),I.last_lit===I.lit_bufsize-1},s._tr_align=function(I){Q(I,2,3),ie(I,b,$),function(U){U.bi_valid===16?(G(U,U.bi_buf),U.bi_buf=0,U.bi_valid=0):8<=U.bi_valid&&(U.pending_buf[U.pending++]=255&U.bi_buf,U.bi_buf>>=8,U.bi_valid-=8)}(I)}},{"../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,l){if(!a.setImmediate){var c,u,d,h,f=1,p={},m=!1,g=a.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(a);y=y&&y.setTimeout?y:a,c={}.toString.call(a.process)==="[object process]"?function(w){process.nextTick(function(){v(w)})}:function(){if(a.postMessage&&!a.importScripts){var w=!0,j=a.onmessage;return a.onmessage=function(){w=!1},a.postMessage("","*"),a.onmessage=j,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 j=g.createElement("script");j.onreadystatechange=function(){v(w),j.onreadystatechange=null,u.removeChild(j),j=null},u.appendChild(j)}):function(w){setTimeout(v,0,w)},y.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var j=new Array(arguments.length-1),N=0;N<j.length;N++)j[N]=arguments[N+1];var C={callback:w,args:j};return p[f]=C,c(f),f++},y.clearImmediate=x}function x(w){delete p[w]}function v(w){if(m)setTimeout(v,0,w);else{var j=p[w];if(j){m=!0;try{(function(N){var C=N.callback,A=N.args;switch(A.length){case 0:C();break;case 1:C(A[0]);break;case 2:C(A[0],A[1]);break;case 3:C(A[0],A[1],A[2]);break;default:C.apply(l,A)}})(j)}finally{x(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 $n<"u"?$n:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})($Ne);var jTt=$Ne.exports;const NG=Er(jTt);var FNe={exports:{}};/* @license
Papa Parse
v5.5.3
https://github.com/mholt/PapaParse
License: MIT
*/(function(t,e){((r,n)=>{t.exports=n()})($n,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,l={},c=0,u={};function d(A){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(E){var O=j(E);O.chunkSize=parseInt(O.chunkSize),E.step||E.chunk||(O.chunkSize=null),this._handle=new g(O),(this._handle.streamer=this)._config=O}).call(this,A),this.parseChunk=function(E,O){var $=parseInt(this._config.skipFirstNLines)||0;if(this.isFirstChunk&&0<$){let M=this._config.newline;M||(T=this._config.quoteChar||'"',M=this._handle.guessLineEndings(E,T)),E=[...E.split(M).slice($)].join(M)}this.isFirstChunk&&C(this._config.beforeFirstChunk)&&(T=this._config.beforeFirstChunk(E))!==void 0&&(E=T),this.isFirstChunk=!1,this._halted=!1;var $=this._partialLine+E,T=(this._partialLine="",this._handle.parse($,this._baseIndex,!this._finished));if(!this._handle.paused()&&!this._handle.aborted()){if(E=T.meta.cursor,$=(this._finished||(this._partialLine=$.substring(E-this._baseIndex),this._baseIndex=E),T&&T.data&&(this._rowCount+=T.data.length),this._finished||this._config.preview&&this._rowCount>=this._config.preview),a)n.postMessage({results:T,workerId:u.WORKER_ID,finished:$});else if(C(this._config.chunk)&&!O){if(this._config.chunk(T,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);this._completeResults=T=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(T.data),this._completeResults.errors=this._completeResults.errors.concat(T.errors),this._completeResults.meta=T.meta),this._completed||!$||!C(this._config.complete)||T&&T.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),$||T&&T.meta.paused||this._nextChunk(),T}this._halted=!0},this._sendError=function(E){C(this._config.error)?this._config.error(E):a&&this._config.error&&n.postMessage({workerId:u.WORKER_ID,error:E,finished:!1})}}function h(A){var E;(A=A||{}).chunkSize||(A.chunkSize=u.RemoteChunkSize),d.call(this,A),this._nextChunk=i?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(O){this._input=O,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(E=new XMLHttpRequest,this._config.withCredentials&&(E.withCredentials=this._config.withCredentials),i||(E.onload=N(this._chunkLoaded,this),E.onerror=N(this._chunkError,this)),E.open(this._config.downloadRequestBody?"POST":"GET",this._input,!i),this._config.downloadRequestHeaders){var O,$=this._config.downloadRequestHeaders;for(O in $)E.setRequestHeader(O,$[O])}var T;this._config.chunkSize&&(T=this._start+this._config.chunkSize-1,E.setRequestHeader("Range","bytes="+this._start+"-"+T));try{E.send(this._config.downloadRequestBody)}catch(M){this._chunkError(M.message)}i&&E.status===0&&this._chunkError()}},this._chunkLoaded=function(){E.readyState===4&&(E.status<200||400<=E.status?this._chunkError():(this._start+=this._config.chunkSize||E.responseText.length,this._finished=!this._config.chunkSize||this._start>=(O=>(O=O.getResponseHeader("Content-Range"))!==null?parseInt(O.substring(O.lastIndexOf("/")+1)):-1)(E),this.parseChunk(E.responseText)))},this._chunkError=function(O){O=E.statusText||O,this._sendError(new Error(O))}}function f(A){(A=A||{}).chunkSize||(A.chunkSize=u.LocalChunkSize),d.call(this,A);var E,O,$=typeof FileReader<"u";this.stream=function(T){this._input=T,O=T.slice||T.webkitSlice||T.mozSlice,$?((E=new FileReader).onload=N(this._chunkLoaded,this),E.onerror=N(this._chunkError,this)):E=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var T=this._input,M=(this._config.chunkSize&&(M=Math.min(this._start+this._config.chunkSize,this._input.size),T=O.call(T,this._start,M)),E.readAsText(T,this._config.encoding));$||this._chunkLoaded({target:{result:M}})},this._chunkLoaded=function(T){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(T.target.result)},this._chunkError=function(){this._sendError(E.error)}}function p(A){var E;d.call(this,A=A||{}),this.stream=function(O){return E=O,this._nextChunk()},this._nextChunk=function(){var O,$;if(!this._finished)return O=this._config.chunkSize,E=O?($=E.substring(0,O),E.substring(O)):($=E,""),this._finished=!E,this.parseChunk($)}}function m(A){d.call(this,A=A||{});var E=[],O=!0,$=!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(T){this._input=T,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){$&&E.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),E.length?this.parseChunk(E.shift()):O=!0},this._streamData=N(function(T){try{E.push(typeof T=="string"?T:T.toString(this._config.encoding)),O&&(O=!1,this._checkIsFinished(),this.parseChunk(E.shift()))}catch(M){this._streamError(M)}},this),this._streamError=N(function(T){this._streamCleanUp(),this._sendError(T)},this),this._streamEnd=N(function(){this._streamCleanUp(),$=!0,this._streamData("")},this),this._streamCleanUp=N(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function g(A){var E,O,$,T,M=Math.pow(2,53),k=-M,D=/^\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)))$/,H=this,ee=0,V=0,B=!1,z=!1,F=[],G={data:[],errors:[],meta:{}};function Q(L){return A.skipEmptyLines==="greedy"?L.join("").trim()==="":L.length===1&&L[0].length===0}function ie(){if(G&&$&&(q("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+u.DefaultDelimiter+"'"),$=!1),A.skipEmptyLines&&(G.data=G.data.filter(function(W){return!Q(W)})),se()){let W=function(X,he){C(A.transformHeader)&&(X=A.transformHeader(X,he)),F.push(X)};if(G)if(Array.isArray(G.data[0])){for(var L=0;se()&&L<G.data.length;L++)G.data[L].forEach(W);G.data.splice(0,1)}else G.data.forEach(W)}function Z(W,X){for(var he=A.header?{}:[],P=0;P<W.length;P++){var oe=P,Y=W[P],Y=((R,I)=>(U=>(A.dynamicTypingFunction&&A.dynamicTyping[U]===void 0&&(A.dynamicTyping[U]=A.dynamicTypingFunction(U)),(A.dynamicTyping[U]||A.dynamicTyping)===!0))(R)?I==="true"||I==="TRUE"||I!=="false"&&I!=="FALSE"&&((U=>{if(D.test(U)&&(U=parseFloat(U),k<U&&U<M))return 1})(I)?parseFloat(I):K.test(I)?new Date(I):I===""?null:I):I)(oe=A.header?P>=F.length?"__parsed_extra":F[P]:oe,Y=A.transform?A.transform(Y,oe):Y);oe==="__parsed_extra"?(he[oe]=he[oe]||[],he[oe].push(Y)):he[oe]=Y}return A.header&&(P>F.length?q("FieldMismatch","TooManyFields","Too many fields: expected "+F.length+" fields but parsed "+P,V+X):P<F.length&&q("FieldMismatch","TooFewFields","Too few fields: expected "+F.length+" fields but parsed "+P,V+X)),he}var J;G&&(A.header||A.dynamicTyping||A.transform)&&(J=1,!G.data.length||Array.isArray(G.data[0])?(G.data=G.data.map(Z),J=G.data.length):G.data=Z(G.data,0),A.header&&G.meta&&(G.meta.fields=F),V+=J)}function se(){return A.header&&F.length===0}function q(L,Z,J,W){L={type:L,code:Z,message:J},W!==void 0&&(L.row=W),G.errors.push(L)}C(A.step)&&(T=A.step,A.step=function(L){G=L,se()?ie():(ie(),G.data.length!==0&&(ee+=L.data.length,A.preview&&ee>A.preview?O.abort():(G.data=G.data[0],T(G,H))))}),this.parse=function(L,Z,J){var W=A.quoteChar||'"',W=(A.newline||(A.newline=this.guessLineEndings(L,W)),$=!1,A.delimiter?C(A.delimiter)&&(A.delimiter=A.delimiter(L),G.meta.delimiter=A.delimiter):((W=((X,he,P,oe,Y)=>{var R,I,U,re;Y=Y||[",","	","|",";",u.RECORD_SEP,u.UNIT_SEP];for(var ue=0;ue<Y.length;ue++){for(var ae,ge=Y[ue],we=0,ce=0,ne=0,fe=(U=void 0,new x({comments:oe,delimiter:ge,newline:he,preview:10}).parse(X)),be=0;be<fe.data.length;be++)P&&Q(fe.data[be])?ne++:(ae=fe.data[be].length,ce+=ae,U===void 0?U=ae:0<ae&&(we+=Math.abs(ae-U),U=ae));0<fe.data.length&&(ce/=fe.data.length-ne),(I===void 0||we<=I)&&(re===void 0||re<ce)&&1.99<ce&&(I=we,R=ge,re=ce)}return{successful:!!(A.delimiter=R),bestDelimiter:R}})(L,A.newline,A.skipEmptyLines,A.comments,A.delimitersToGuess)).successful?A.delimiter=W.bestDelimiter:($=!0,A.delimiter=u.DefaultDelimiter),G.meta.delimiter=A.delimiter),j(A));return A.preview&&A.header&&W.preview++,E=L,O=new x(W),G=O.parse(E,Z,J),ie(),B?{meta:{paused:!0}}:G||{meta:{paused:!1}}},this.paused=function(){return B},this.pause=function(){B=!0,O.abort(),E=C(A.chunk)?"":E.substring(O.getCharIndex())},this.resume=function(){H.streamer._halted?(B=!1,H.streamer.parseChunk(E,!0)):setTimeout(H.resume,3)},this.aborted=function(){return z},this.abort=function(){z=!0,O.abort(),G.meta.aborted=!0,C(A.complete)&&A.complete(G),E=""},this.guessLineEndings=function(X,W){X=X.substring(0,1048576);var W=new RegExp(y(W)+"([^]*?)"+y(W),"gm"),J=(X=X.replace(W,"")).split("\r"),W=X.split(`
`),X=1<W.length&&W[0].length<J[0].length;if(J.length===1||X)return`
`;for(var he=0,P=0;P<J.length;P++)J[P][0]===`
`&&he++;return he>=J.length/2?`\r
`:"\r"}}function y(A){return A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function x(A){var E=(A=A||{}).delimiter,O=A.newline,$=A.comments,T=A.step,M=A.preview,k=A.fastMode,D=null,K=!1,H=A.quoteChar==null?'"':A.quoteChar,ee=H;if(A.escapeChar!==void 0&&(ee=A.escapeChar),(typeof E!="string"||-1<u.BAD_DELIMITERS.indexOf(E))&&(E=","),$===E)throw new Error("Comment character same as delimiter");$===!0?$="#":(typeof $!="string"||-1<u.BAD_DELIMITERS.indexOf($))&&($=!1),O!==`
`&&O!=="\r"&&O!==`\r
`&&(O=`
`);var V=0,B=!1;this.parse=function(z,F,G){if(typeof z!="string")throw new Error("Input must be a string");var Q=z.length,ie=E.length,se=O.length,q=$.length,L=C(T),Z=[],J=[],W=[],X=V=0;if(!z)return we();if(k||k!==!1&&z.indexOf(H)===-1){for(var he=z.split(O),P=0;P<he.length;P++){if(W=he[P],V+=W.length,P!==he.length-1)V+=O.length;else if(G)return we();if(!$||W.substring(0,q)!==$){if(L){if(Z=[],re(W.split(E)),ce(),B)return we()}else re(W.split(E));if(M&&M<=P)return Z=Z.slice(0,M),we(!0)}}return we()}for(var oe=z.indexOf(E,V),Y=z.indexOf(O,V),R=new RegExp(y(ee)+y(H),"g"),I=z.indexOf(H,V);;)if(z[V]===H)for(I=V,V++;;){if((I=z.indexOf(H,I+1))===-1)return G||J.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:Z.length,index:V}),ae();if(I===Q-1)return ae(z.substring(V,I).replace(R,H));if(H===ee&&z[I+1]===ee)I++;else if(H===ee||I===0||z[I-1]!==ee){oe!==-1&&oe<I+1&&(oe=z.indexOf(E,I+1));var U=ue((Y=Y!==-1&&Y<I+1?z.indexOf(O,I+1):Y)===-1?oe:Math.min(oe,Y));if(z.substr(I+1+U,ie)===E){W.push(z.substring(V,I).replace(R,H)),z[V=I+1+U+ie]!==H&&(I=z.indexOf(H,V)),oe=z.indexOf(E,V),Y=z.indexOf(O,V);break}if(U=ue(Y),z.substring(I+1+U,I+1+U+se)===O){if(W.push(z.substring(V,I).replace(R,H)),ge(I+1+U+se),oe=z.indexOf(E,V),I=z.indexOf(H,V),L&&(ce(),B))return we();if(M&&Z.length>=M)return we(!0);break}J.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:Z.length,index:V}),I++}}else if($&&W.length===0&&z.substring(V,V+q)===$){if(Y===-1)return we();V=Y+se,Y=z.indexOf(O,V),oe=z.indexOf(E,V)}else if(oe!==-1&&(oe<Y||Y===-1))W.push(z.substring(V,oe)),V=oe+ie,oe=z.indexOf(E,V);else{if(Y===-1)break;if(W.push(z.substring(V,Y)),ge(Y+se),L&&(ce(),B))return we();if(M&&Z.length>=M)return we(!0)}return ae();function re(ne){Z.push(ne),X=V}function ue(ne){var fe=0;return fe=ne!==-1&&(ne=z.substring(I+1,ne))&&ne.trim()===""?ne.length:fe}function ae(ne){return G||(ne===void 0&&(ne=z.substring(V)),W.push(ne),V=Q,re(W),L&&ce()),we()}function ge(ne){V=ne,re(W),W=[],Y=z.indexOf(O,V)}function we(ne){if(A.header&&!F&&Z.length&&!K){var fe=Z[0],be=Object.create(null),xe=new Set(fe);let _e=!1;for(let ke=0;ke<fe.length;ke++){let $e=fe[ke];if(be[$e=C(A.transformHeader)?A.transformHeader($e,ke):$e]){let Te,ot=be[$e];for(;Te=$e+"_"+ot,ot++,xe.has(Te););xe.add(Te),fe[ke]=Te,be[$e]++,_e=!0,(D=D===null?{}:D)[Te]=$e}else be[$e]=1,fe[ke]=$e;xe.add($e)}_e&&console.warn("Duplicate headers found and renamed."),K=!0}return{data:Z,errors:J,meta:{delimiter:E,linebreak:O,aborted:B,truncated:!!ne,cursor:X+(F||0),renamedHeaders:D}}}function ce(){T(we()),Z=[],J=[]}},this.abort=function(){B=!0},this.getCharIndex=function(){return V}}function v(A){var E=A.data,O=l[E.workerId],$=!1;if(E.error)O.userError(E.error,E.file);else if(E.results&&E.results.data){var T={abort:function(){$=!0,b(E.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:w,resume:w};if(C(O.userStep)){for(var M=0;M<E.results.data.length&&(O.userStep({data:E.results.data[M],errors:E.results.errors,meta:E.results.meta},T),!$);M++);delete E.results}else C(O.userChunk)&&(O.userChunk(E.results,T,E.file),delete E.results)}E.finished&&!$&&b(E.workerId,E.results)}function b(A,E){var O=l[A];C(O.userComplete)&&O.userComplete(E),O.terminate(),delete l[A]}function w(){throw new Error("Not implemented.")}function j(A){if(typeof A!="object"||A===null)return A;var E,O=Array.isArray(A)?[]:{};for(E in A)O[E]=j(A[E]);return O}function N(A,E){return function(){A.apply(E,arguments)}}function C(A){return typeof A=="function"}return u.parse=function(A,E){var O=(E=E||{}).dynamicTyping||!1;if(C(O)&&(E.dynamicTypingFunction=O,O={}),E.dynamicTyping=O,E.transform=!!C(E.transform)&&E.transform,!E.worker||!u.WORKERS_SUPPORTED)return O=null,u.NODE_STREAM_INPUT,typeof A=="string"?(A=($=>$.charCodeAt(0)!==65279?$:$.slice(1))(A),O=new(E.download?h:p)(E)):A.readable===!0&&C(A.read)&&C(A.on)?O=new m(E):(n.File&&A instanceof File||A instanceof Object)&&(O=new f(E)),O.stream(A);(O=(()=>{var $;return!!u.WORKERS_SUPPORTED&&($=(()=>{var T=n.URL||n.webkitURL||null,M=r.toString();return u.BLOB_URL||(u.BLOB_URL=T.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; ","(",M,")();"],{type:"text/javascript"})))})(),($=new n.Worker($)).onmessage=v,$.id=c++,l[$.id]=$)})()).userStep=E.step,O.userChunk=E.chunk,O.userComplete=E.complete,O.userError=E.error,E.step=C(E.step),E.chunk=C(E.chunk),E.complete=C(E.complete),E.error=C(E.error),delete E.worker,O.postMessage({input:A,config:E,workerId:O.id})},u.unparse=function(A,E){var O=!1,$=!0,T=",",M=`\r
`,k='"',D=k+k,K=!1,H=null,ee=!1,V=((()=>{if(typeof E=="object"){if(typeof E.delimiter!="string"||u.BAD_DELIMITERS.filter(function(F){return E.delimiter.indexOf(F)!==-1}).length||(T=E.delimiter),typeof E.quotes!="boolean"&&typeof E.quotes!="function"&&!Array.isArray(E.quotes)||(O=E.quotes),typeof E.skipEmptyLines!="boolean"&&typeof E.skipEmptyLines!="string"||(K=E.skipEmptyLines),typeof E.newline=="string"&&(M=E.newline),typeof E.quoteChar=="string"&&(k=E.quoteChar),typeof E.header=="boolean"&&($=E.header),Array.isArray(E.columns)){if(E.columns.length===0)throw new Error("Option columns is empty");H=E.columns}E.escapeChar!==void 0&&(D=E.escapeChar+k),E.escapeFormulae instanceof RegExp?ee=E.escapeFormulae:typeof E.escapeFormulae=="boolean"&&E.escapeFormulae&&(ee=/^[=+\-@\t\r].*$/)}})(),new RegExp(y(k),"g"));if(typeof A=="string"&&(A=JSON.parse(A)),Array.isArray(A)){if(!A.length||Array.isArray(A[0]))return B(null,A,K);if(typeof A[0]=="object")return B(H||Object.keys(A[0]),A,K)}else if(typeof A=="object")return typeof A.data=="string"&&(A.data=JSON.parse(A.data)),Array.isArray(A.data)&&(A.fields||(A.fields=A.meta&&A.meta.fields||H),A.fields||(A.fields=Array.isArray(A.data[0])?A.fields:typeof A.data[0]=="object"?Object.keys(A.data[0]):[]),Array.isArray(A.data[0])||typeof A.data[0]=="object"||(A.data=[A.data])),B(A.fields||[],A.data||[],K);throw new Error("Unable to serialize unrecognized input");function B(F,G,Q){var ie="",se=(typeof F=="string"&&(F=JSON.parse(F)),typeof G=="string"&&(G=JSON.parse(G)),Array.isArray(F)&&0<F.length),q=!Array.isArray(G[0]);if(se&&$){for(var L=0;L<F.length;L++)0<L&&(ie+=T),ie+=z(F[L],L);0<G.length&&(ie+=M)}for(var Z=0;Z<G.length;Z++){var J=(se?F:G[Z]).length,W=!1,X=se?Object.keys(G[Z]).length===0:G[Z].length===0;if(Q&&!se&&(W=Q==="greedy"?G[Z].join("").trim()==="":G[Z].length===1&&G[Z][0].length===0),Q==="greedy"&&se){for(var he=[],P=0;P<J;P++){var oe=q?F[P]:P;he.push(G[Z][oe])}W=he.join("").trim()===""}if(!W){for(var Y=0;Y<J;Y++){0<Y&&!X&&(ie+=T);var R=se&&q?F[Y]:Y;ie+=z(G[Z][R],Y)}Z<G.length-1&&(!Q||0<J&&!X)&&(ie+=M)}}return ie}function z(F,G){var Q,ie;return F==null?"":F.constructor===Date?JSON.stringify(F).slice(1,25):(ie=!1,ee&&typeof F=="string"&&ee.test(F)&&(F="'"+F,ie=!0),Q=F.toString().replace(V,D),(ie=ie||O===!0||typeof O=="function"&&O(F,G)||Array.isArray(O)&&O[G]||((se,q)=>{for(var L=0;L<q.length;L++)if(-1<se.indexOf(q[L]))return!0;return!1})(Q,u.BAD_DELIMITERS)||-1<Q.indexOf(T)||Q.charAt(0)===" "||Q.charAt(Q.length-1)===" ")?k+Q+k:Q)}},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=x,u.ParserHandle=g,u.NetworkStreamer=h,u.FileStreamer=f,u.StringStreamer=p,u.ReadableStreamStreamer=m,n.jQuery&&((s=n.jQuery).fn.parse=function(A){var E=A.config||{},O=[];return this.each(function(M){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 k=0;k<this.files.length;k++)O.push({file:this.files[k],inputElem:this,instanceConfig:s.extend({},E)})}),$(),this;function $(){if(O.length===0)C(A.complete)&&A.complete();else{var M,k,D,K,H=O[0];if(C(A.before)){var ee=A.before(H.file,H.inputElem);if(typeof ee=="object"){if(ee.action==="abort")return M="AbortError",k=H.file,D=H.inputElem,K=ee.reason,void(C(A.error)&&A.error({name:M},k,D,K));if(ee.action==="skip")return void T();typeof ee.config=="object"&&(H.instanceConfig=s.extend(H.instanceConfig,ee.config))}else if(ee==="skip")return void T()}var V=H.instanceConfig.complete;H.instanceConfig.complete=function(B){C(V)&&V(B,H.file,H.inputElem),T()},u.parse(H.file,H.instanceConfig)}}function T(){O.splice(0,1),$()}}),a&&(n.onmessage=function(A){A=A.data,u.WORKER_ID===void 0&&A&&(u.WORKER_ID=A.workerId),typeof A.input=="string"?n.postMessage({workerId:u.WORKER_ID,results:u.parse(A.input,A.config),finished:!0}):(n.File&&A.input instanceof File||A.input instanceof Object)&&(A=u.parse(A.input,A.config))&&n.postMessage({workerId:u.WORKER_ID,results:A,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})})(FNe);var STt=FNe.exports;const kk=Er(STt);function wo(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 _Tt(t,e,r){var C,A,E,O,$;const[n,s,i,a,l,c,u,d,h,f,p,m,g,y]=await Promise.all([pe.from("theses").select("*").eq("user_id",t),pe.from("chapters").select("*"),pe.from("sections").select("*"),pe.from("documents").select("id, title, original_filename, doi, isbn, citation_apa, page_count, created_at").eq("user_id",t),pe.from("summaries").select("id, document_id, summary_text, summary_mode, citation_style, created_at").eq("user_id",t),pe.from("theory_backgrounds").select("id, document_id, title, theory_text, mode, citation_style, created_at").eq("user_id",t),pe.from("methods").select("id, document_id, title, method_text, mode, citation_style, created_at").eq("user_id",t),pe.from("research_setups").select("*").eq("user_id",t),pe.from("topic_explorations").select("*").eq("user_id",t),pe.from("codebooks").select("*").eq("user_id",t),pe.from("codebook_categories").select("*"),pe.from("interviews").select("*").eq("user_id",t),pe.from("coded_segments").select("*").eq("user_id",t),pe.from("qualitative_summaries").select("*").eq("user_id",t)]),x=((C=n.data)==null?void 0:C.map(T=>T.id))||[],v=((A=s.data)==null?void 0:A.filter(T=>x.includes(T.thesis_id)))||[],b=v.map(T=>T.id),w=((E=i.data)==null?void 0:E.filter(T=>b.includes(T.chapter_id)))||[],j=((O=f.data)==null?void 0:O.map(T=>T.id))||[],N=(($=p.data)==null?void 0:$.filter(T=>j.includes(T.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:l.data||[],theoryBackgrounds:c.data||[],methods:u.data||[]},research:{researchSetups:d.data||[],topicExplorations:h.data||[]},qualitative:{codebooks:f.data||[],codebookCategories:N,interviews:m.data||[],codedSegments:g.data||[],qualitativeSummaries:y.data||[]}}}function NTt(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(`
${wo(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(l=>l.chapter_id===i.id).sort((l,c)=>l.order_index-c.order_index);for(let l=0;l<a.length;l++){const c=a[l],u=c.title||c.type;e.push(`${s+1}.${l+1} ${u}
`),e.push(wo(c.content)||"[No content]"),e.push(`
`)}}e.push(`
---
`)}return e.join(`
`)}function kTt(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(wo(r.summary_text)||"[No summary text]"),e.push(`
---
`)}return e.join(`
`)}function CTt(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(wo(r.theory_text)||"[No text]"),e.push(`
---
`);return e.join(`
`)}function ETt(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(wo(r.method_text)||"[No text]"),e.push(`
---
`);return e.join(`
`)}function ATt(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(wo(r.raw_text)||"[No text]"),e.push(`
---
`);return e.join(`
`)}function TTt(t){const e=[`RESEARCH SETUPS
`];for(const r of t.research.researchSetups)e.push(`${r.title}`),r.aim&&e.push(`Aim: ${wo(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}. ${wo(s)}`)}),e.push("")),r.markdown_text&&(e.push("Full Content"),e.push(wo(r.markdown_text))),e.push(`
---
`);return e.join(`
`)}function PTt(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(wo(r.problem_statement)),e.push("")),r.objectives&&(e.push("Objectives"),e.push(wo(r.objectives)),e.push("")),r.introduction&&(e.push("Introduction"),e.push(wo(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}. ${wo(s)}`)}),e.push("")),e.push(`
---
`);return e.join(`
`)}function ITt(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(wo(r.summary_text)||"[No text]"),e.push(`
---
`)}return e.join(`
`)}async function RTt(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(y=>y.category_id===h.id&&y.interview_id===p.id).map(y=>y.snippet).join(" | ").replace(/"/g,'""').replace(/\r?\n/g," ").trim();f.push(g)}c.push(f)}const u=kk.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 OTt(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 MTt(t){const e=new NG;e.file("README.txt","\uFEFF"+OTt(t));const r=e.folder("thesis");t.thesis.theses.length>0&&(r==null||r.file("thesis_content.txt","\uFEFF"+NTt(t)));const n=e.folder("library");t.library.summaries.length>0&&(n==null||n.file("summaries.txt","\uFEFF"+kTt(t))),t.library.theoryBackgrounds.length>0&&(n==null||n.file("theory_backgrounds.txt","\uFEFF"+CTt(t))),t.library.methods.length>0&&(n==null||n.file("methods.txt","\uFEFF"+ETt(t)));const s=e.folder("research");t.research.researchSetups.length>0&&(s==null||s.file("research_setups.txt","\uFEFF"+TTt(t))),t.research.topicExplorations.length>0&&(s==null||s.file("topic_explorations.txt","\uFEFF"+PTt(t)));const i=e.folder("qualitative");t.qualitative.interviews.length>0&&(i==null||i.file("interviews.txt","\uFEFF"+ATt(t))),t.qualitative.qualitativeSummaries.length>0&&(i==null||i.file("coding_summaries.txt","\uFEFF"+ITt(t)));for(const a of t.qualitative.codebooks){const l=await RTt(a.id,a.title,t);i==null||i.file(l.filename,l.content)}return await e.generateAsync({type:"blob",compression:"DEFLATE"})}const DTt=({currentAvatarUrl:t,onSelectPublic:e,onUploadCustom:r,disabled:n})=>{const[s,i]=S.useState(!1),[a,l]=S.useState(!1),[c,u]=S.useState(null),[d,h]=S.useState([]),[f,p]=S.useState(!0),m=S.useRef(null),{toast:g}=Bn();S.useEffect(()=>{(async()=>{const w=await x0(t);u(w)})()},[t]),S.useEffect(()=>{(async()=>{p(!0);try{const{data:w,error:j}=await pe.storage.from("avatars-public").list("",{limit:20});if(j){console.error("Error loading public avatars:",j);return}if(w){const N=w.filter(C=>C.name.match(/\.(png|jpg|jpeg|webp|svg)$/i)).map(C=>({name:C.name,url:`https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/avatars-public/${C.name}`}));h(N)}}catch(w){console.error("Error loading public avatars:",w)}finally{p(!1)}})()},[]);const y=async b=>{var N;const w=(N=b.target.files)==null?void 0:N[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 j=new FileReader;j.onloadend=()=>{u(j.result)},j.readAsDataURL(w),i(!0);try{await r(w),g({title:"Success",description:"Avatar uploaded successfully"})}catch(C){console.error("Avatar upload error:",C),g({title:"Error",description:"Failed to upload avatar",variant:"destructive"});const A=await x0(t);u(A)}finally{i(!1)}},x=async b=>{if(!(n||a)){l(!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 j=await x0(t);u(j)}finally{l(!1)}}},v=b=>t===b||c===b;return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center gap-6",children:[o.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?o.jsx("img",{src:c,alt:"Avatar",className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center",children:o.jsx(nj,{className:"w-20 h-20 text-muted-foreground"})}),!n&&o.jsx("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:s?o.jsx(Xe,{className:"w-8 h-8 text-white animate-spin"}):o.jsx(cf,{className:"w-8 h-8 text-white"})})]}),o.jsx("input",{ref:m,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:y,className:"hidden",disabled:n||s}),o.jsxs("div",{className:"flex-1",children:[o.jsx("p",{className:"text-sm font-medium",children:"Profile Picture"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose a default avatar or upload your own (max 2MB)"})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Or choose a default avatar"}),f?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Xe,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):d.length>0?o.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-5",children:d.map(b=>o.jsxs("button",{onClick:()=>x(b),disabled:n||a||s,className:Pe("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:[o.jsx("img",{src:b.url,alt:b.name,className:"w-full h-full object-cover"}),v(b.url)&&o.jsx("div",{className:"absolute inset-0 bg-primary/20 flex items-center justify-center",children:o.jsx(kr,{className:"w-8 h-8 text-primary"})})]},b.name))}):o.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No default avatars available"})]})]})},LTt=({initialData:t,onUpdate:e,disabled:r})=>{var f;const[n,s]=S.useState(t),[i,a]=S.useState(""),l=(p,m)=>{const g={...n,[p]:m};s(g),e({[p]:m})},c=()=>{if(!i.trim())return;const p=[...n.research_interests||[],i.trim()];l("research_interests",p),a("")},u=p=>{const m=[...n.research_interests||[]];m.splice(p,1),l("research_interests",m)},d=n.preferred_language||"de",h=p=>p[d]||p.de;return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Country of Study"}),o.jsxs(pt,{value:n.study_country||"",onValueChange:p=>l("study_country",p),disabled:r,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select country"})}),o.jsx(dt,{children:ivt.map(p=>o.jsx(Le,{value:p.value,children:p.label},p.value))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Degree Type"}),o.jsxs(pt,{value:n.degree_type||"",onValueChange:p=>l("degree_type",p),disabled:r,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select degree"})}),o.jsx(dt,{children:avt.map(p=>o.jsx(Le,{value:p.value,children:h(p.label)},p.value))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Discipline"}),o.jsxs(pt,{value:n.discipline||"",onValueChange:p=>l("discipline",p),disabled:r,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Discipline auswählen"})}),o.jsx(dt,{children:svt.map(p=>o.jsx(Le,{value:p.value,children:h(p.label)},p.value))})]})]})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"University (optional)"}),o.jsx(Ue,{value:n.university||"",onChange:p=>l("university",p.target.value),placeholder:"z.B. University Stanford",disabled:r})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Primary Methodology"}),o.jsxs(pt,{value:n.methodology||"",onValueChange:p=>l("methodology",p),disabled:r,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select methodology"})}),o.jsx(dt,{children:ovt.map(p=>o.jsx(Le,{value:p.value,children:h(p.label)},p.value))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Preferred Language"}),o.jsxs(pt,{value:n.preferred_language||"en",onValueChange:p=>l("preferred_language",p),disabled:r,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select language"})}),o.jsx(dt,{children:Qwe.map(p=>o.jsx(Le,{value:p.value,children:p.label},p.value))})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Research Interests"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Ue,{value:i,onChange:p=>a(p.target.value),onKeyDown:p=>p.key==="Enter"&&(p.preventDefault(),c()),placeholder:"z.B. Künstliche Intelligenz",disabled:r}),o.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:"+"})]}),o.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:(f=n.research_interests)==null?void 0:f.map((p,m)=>o.jsxs(kt,{variant:"secondary",className:"gap-1",children:[p,!r&&o.jsx(fn,{className:"w-3 h-3 cursor-pointer",onClick:()=>u(m)})]},m))})]})]})},$Tt={free:"Free",pro:"Pro",author:"Author",lifetime:"Lifetime"},FTt={monthly:"Monthly",annual:"Annual"},BTt=()=>{const{user:t,userProfile:e,researchProfile:r,studentPoints:n,loading:s,signOut:i,updateResearchProfile:a,uploadAvatar:l,selectPublicAvatar:c}=Ht(),{openCustomerPortal:u,loading:d}=e1e(),h=Or(),[f,p]=S.useState(""),[m,g]=S.useState(""),[y,x]=S.useState(!1),[v,b]=S.useState(""),[w,j]=S.useState(""),[N,C]=S.useState(""),[A,E]=S.useState(!1),[O,$]=S.useState(null),[T,M]=S.useState(!1),[k,D]=S.useState(""),[K,H]=S.useState(!1),[ee,V]=S.useState(""),[B,z]=S.useState(!1),[F,G]=S.useState(!1),[Q,ie]=S.useState(null);S.useEffect(()=>{const U=localStorage.getItem("lastBackupDate");U&&$(U)},[]),S.useEffect(()=>{(async()=>{if(!(r!=null&&r.avatar_url)){ie(null);return}const re=await x0(r.avatar_url);ie(re)})()},[r==null?void 0:r.avatar_url]),S.useEffect(()=>{!t&&!s?h("/login"):t&&p(t.email||""),r!=null&&r.nickname&&g(r.nickname)},[t,r,s,h]);const se=async()=>{if(w!==N){Ke.error("Passwords do not match");return}if(w.length<6){Ke.error("Password must be at least 6 characters");return}Ke.success("Password updated successfully"),b(""),j(""),C("")},q=async()=>{if(!t||ee!==t.email){Ke.error("Please enter your email address correctly to confirm deletion");return}M(!0);try{D("Canceling subscription...");const{data:U,error:re}=await pe.functions.invoke("delete-account");if(re)throw console.error("Delete account error:",re),new Error(re.message||"Failed to delete account");if(U!=null&&U.error)throw new Error(U.error);Ke.success("Account successfully deleted. Goodbye!"),await i(),h("/")}catch(U){console.error("Delete account error:",U),Ke.error("Failed to delete account: "+(U.message||"Unknown error")),M(!1),D("")}},L=()=>{H(!1),V(""),z(!1)},Z=async()=>{if(m.trim()){x(!0);try{await a({nickname:m.trim()}),Ke.success("Nickname updated")}catch{Ke.error("Failed to update nickname")}finally{x(!1)}}},J=async U=>await l(U),W=async U=>{await c(U)},X=async U=>{try{await a(U)}catch{Ke.error("Failed to update profile")}},he=async()=>{if(t){E(!0);try{const U=await _Tt(t.id,t.email||"",(r==null?void 0:r.nickname)||void 0),re=await MTt(U),ue=new Date().toISOString().split("T")[0],ae=r!=null&&r.nickname?`${r.nickname}_Backup_${ue}.zip`:`User_Backup_${ue}.zip`,ge=URL.createObjectURL(re),we=document.createElement("a");we.href=ge,we.download=ae,document.body.appendChild(we),we.click(),document.body.removeChild(we),URL.revokeObjectURL(ge);const ce=new Date().toISOString();localStorage.setItem("lastBackupDate",ce),$(ce),Ke.success("Backup created successfully!")}catch(U){console.error("Backup error:",U),Ke.error("Failed to create backup.")}finally{E(!1)}}};if(s)return o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})});if(!t||!e)return null;const P=(n==null?void 0:n.total)||0,oe=(n==null?void 0:n.used)||0,Y=(n==null?void 0:n.remaining)||0,R=P>0?Math.round(oe/P*100):0,I=new Date(e.created_at).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});return o.jsx(Cr,{showSidebar:!0,children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold",children:"Manage Account"}),o.jsx("p",{className:"text-muted-foreground",children:"Manage your account settings and profile"})]}),o.jsx(Ze,{children:o.jsx(st,{className:"pt-6",children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex flex-col items-center gap-4",children:[o.jsxs("div",{onClick:()=>G(!0),className:"cursor-pointer group",children:[o.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:Q?o.jsx("img",{src:Q,alt:"Profile",className:"w-full h-full object-cover"}):o.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted",children:o.jsx(nj,{className:"w-12 h-12 text-muted-foreground"})})}),o.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center group-hover:text-primary transition-colors",children:"Click to change"})]}),o.jsxs("div",{className:"text-center",children:[o.jsx("p",{className:"text-sm font-medium",children:"Profile Picture"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose a default avatar or upload your own (max 2MB)"})]})]}),o.jsx(jn,{open:F,onOpenChange:G,children:o.jsxs(pn,{className:"sm:max-w-[840px]",children:[o.jsxs(mn,{children:[o.jsx(gn,{children:"Choose Your Avatar"}),o.jsx(og,{children:"Select a default avatar or upload your own"})]}),o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:o.jsx(DTt,{currentAvatarUrl:(r==null?void 0:r.avatar_url)||null,onSelectPublic:W,onUploadCustom:J})})]})}),o.jsx(Eo,{}),o.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center gap-4",children:[o.jsxs("div",{className:"flex gap-2 flex-1",children:[o.jsx(Ue,{placeholder:"Nickname (optional)",value:m,onChange:U=>g(U.target.value),className:"max-w-xs"}),o.jsx(me,{onClick:Z,disabled:y||!m.trim(),children:"Save"})]}),o.jsxs("div",{className:"text-sm text-muted-foreground",children:[f," • Member since ",I]})]})]})})}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsx(Ft,{children:"Research Profile"}),o.jsx(Es,{children:"Optional information for personalization and analytics (GDPR compliant)"})]}),o.jsx(st,{children:o.jsx(LTt,{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:X})})]}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(VOe,{className:"h-5 w-5"}),"Subscription & Credits"]}),o.jsx(Es,{children:"Your plan and Student Points"})]}),o.jsx(st,{children:o.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[o.jsx("div",{className:"space-y-4",children:o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium mb-2",children:"Current Plan"}),o.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[o.jsx("span",{className:"text-2xl font-bold capitalize",children:`Academly ${$Tt[e.plan]??"Free"}`}),e.subscription_status==="active"&&o.jsx(kt,{variant:"default",className:"bg-green-500/10 text-green-600 border-green-500/20",children:"Active"}),e.subscription_status==="canceled"&&o.jsx(kt,{variant:"secondary",className:"bg-amber-500/10 text-amber-600 border-amber-500/20",children:"Canceled"}),e.subscription_status==="past_due"&&o.jsx(kt,{variant:"destructive",children:"Past Due"})]}),e.plan==="lifetime"?o.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"One-time purchase"}):(e.plan==="pro"||e.plan==="author")&&e.subscription_interval&&o.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:FTt[e.subscription_interval]??""}),e.plan!=="lifetime"&&e.subscription_ends_at&&o.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")}`}),o.jsx("div",{className:"flex gap-2",children:e.stripe_subscription_id?o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>u(),disabled:d,children:[d?o.jsx(Xe,{className:"h-4 w-4 animate-spin mr-2"}):null,"Manage Subscription"]}):o.jsx(me,{variant:"outline",size:"sm",onClick:()=>h("/pricing"),children:"Upgrade Plan"})})]})}),o.jsxs("div",{className:"space-y-4",children:[o.jsx("p",{className:"text-sm font-medium",children:"Student Points"}),o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Purchased"}),o.jsxs("p",{className:"text-lg font-bold",children:[P.toLocaleString("en-US")," SP"]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Used"}),o.jsxs("p",{className:"text-lg font-bold",children:[oe.toLocaleString("en-US",{maximumFractionDigits:1})," SP"]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Remaining"}),o.jsxs("p",{className:"text-lg font-bold text-primary",children:[Y.toLocaleString("en-US",{maximumFractionDigits:1})," SP"]})]})]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx(yj,{value:R}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[R,"% used • 1 SP = $0.001"]})]})]})]})})]}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(sfe,{className:"h-5 w-5"}),"Change Password"]}),o.jsx(Es,{children:"Update your password for security"})]}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"current-password",children:"Current Password"}),o.jsx(Ue,{id:"current-password",type:"password",value:v,onChange:U=>b(U.target.value)})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"new-password",children:"New Password"}),o.jsx(Ue,{id:"new-password",type:"password",value:w,onChange:U=>j(U.target.value)})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"confirm-password",children:"Confirm Password"}),o.jsx(Ue,{id:"confirm-password",type:"password",value:N,onChange:U=>C(U.target.value)})]})]}),o.jsx(me,{onClick:se,children:"Update Password"})]})]}),e.stripe_subscription_id&&o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsx(Ft,{children:"Billing & Invoices"}),o.jsx(Es,{children:"Manage your payment methods and view invoices"})]}),o.jsx(st,{className:"space-y-4",children:o.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[o.jsx("div",{className:"text-sm text-muted-foreground",children:o.jsx("p",{children:"Access your complete billing history and manage payment methods through the Stripe Customer Portal."})}),o.jsxs(me,{variant:"outline",onClick:()=>u(),disabled:d,children:[d?o.jsx(Xe,{className:"h-4 w-4 animate-spin mr-2"}):null,"Open Billing Portal"]})]})})]}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(eMe,{className:"h-5 w-5"}),"Data Backup"]}),o.jsx(Es,{children:"Download a complete backup of all your data. Your data belongs to you."})]}),o.jsx(st,{className:"space-y-4",children:o.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.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."}),O&&o.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[o.jsx(sg,{className:"h-3 w-3"}),"Last backup:"," ",new Date(O).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),o.jsx(me,{onClick:he,disabled:A,children:A?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"h-4 w-4 animate-spin mr-2"}),"Creating Backup..."]}):o.jsxs(o.Fragment,{children:[o.jsx(ko,{className:"h-4 w-4 mr-2"}),"Download Backup"]})})]})})]}),o.jsxs(Ze,{className:"border-destructive",children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2 text-destructive",children:[o.jsx(Pi,{className:"h-5 w-5"}),"Danger Zone"]}),o.jsx(Es,{children:"These actions are irreversible. Please be careful."})]}),o.jsx(st,{children:o.jsxs(Mi,{open:B,onOpenChange:U=>{T||(z(U),U||L())},children:[o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"destructive",children:"Delete Account"})}),o.jsxs(li,{className:"max-w-lg",children:[o.jsxs(ci,{children:[o.jsxs(di,{className:"flex items-center gap-2 text-destructive",children:[o.jsx(Jl,{className:"h-5 w-5"}),"Delete Account Permanently"]}),o.jsx(hi,{asChild:!0,children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("p",{children:["This action is ",o.jsx("strong",{className:"text-foreground",children:"irreversible"}),". The following will be permanently deleted:"]}),o.jsxs("ul",{className:"list-disc list-inside text-sm space-y-1",children:[o.jsx("li",{children:"All documents and PDFs"}),o.jsx("li",{children:"All summaries and analyses"}),o.jsx("li",{children:"All thesis drafts and chapters"}),o.jsx("li",{children:"Research setups and topic explorations"}),o.jsx("li",{children:"Qualitative coding data (interviews, codebooks)"}),o.jsx("li",{children:"Your profile and account data"})]}),o.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/50 p-3 rounded-md border border-amber-200 dark:border-amber-800",children:o.jsxs("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:[o.jsx("strong",{children:"Tip:"})," Download a backup of your data before deleting your account."]})}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(aa,{id:"confirm-delete",checked:K,onCheckedChange:U=>H(U===!0),disabled:T}),o.jsx(Se,{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"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"confirm-email",children:"Type your email to confirm:"}),o.jsx(Ue,{id:"confirm-email",placeholder:(t==null?void 0:t.email)||"",value:ee,onChange:U=>V(U.target.value),disabled:T,className:"font-mono text-sm"})]})]})})]}),o.jsxs(ui,{children:[o.jsx(Ws,{disabled:T,children:"Cancel"}),o.jsx(me,{variant:"destructive",onClick:q,disabled:!K||ee!==(t==null?void 0:t.email)||T,children:T?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"h-4 w-4 animate-spin mr-2"}),k||"Deleting..."]}):"Delete Account Permanently"})]})]})]})})]})]})})};async function BNe(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 l=JSON.parse(i),c=l.error||l.details||l.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}function zTt({sources:t,loading:e,disabled:r,onFetch:n,onRemove:s,emptyLabel:i="Suggested from your library — remove any you don't want to use.",fetchLabel:a="Find relevant sources",refetchLabel:l="Re-run suggestion"}){return t?t.length===0?o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"No matching sources found. Refine the topic or add more documents to your library."}),o.jsxs(me,{variant:"ghost",size:"sm",onClick:n,disabled:e||r,className:"text-xs gap-1.5",children:[e?o.jsx(Xe,{className:"w-3 h-3 animate-spin"}):o.jsx(Yc,{className:"w-3 h-3"}),l]})]}):o.jsxs("div",{className:"space-y-2",children:[o.jsx("div",{className:"text-xs text-muted-foreground",children:i}),o.jsx("ul",{className:"space-y-2",children:t.map(c=>{var u;return o.jsx("li",{className:"rounded-lg border border-border bg-background px-3 py-2",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(nr,{className:"w-3.5 h-3.5 mt-1 text-muted-foreground shrink-0"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm font-medium truncate",children:c.document_title}),o.jsxs("div",{className:"text-[11px] text-muted-foreground mt-0.5",children:["Pages ",c.page_ranges.map(d=>d.from===d.to?`${d.from}`:`${d.from}–${d.to}`).join(", ")]}),((u=c.pages[0])==null?void 0:u.snippet)&&o.jsxs("div",{className:"text-[11px] text-muted-foreground/80 mt-1 line-clamp-2 italic",children:['"',c.pages[0].snippet,'"']})]}),o.jsx("button",{type:"button",onClick:()=>s(c.document_id),disabled:r,className:"text-muted-foreground hover:text-foreground","aria-label":"Remove source",children:o.jsx(fn,{className:"w-3.5 h-3.5"})})]})},c.document_id)})}),o.jsxs(me,{variant:"ghost",size:"sm",onClick:n,disabled:e||r,className:"text-xs gap-1.5",children:[e?o.jsx(Xe,{className:"w-3 h-3 animate-spin"}):o.jsx(Yc,{className:"w-3 h-3"}),l]})]}):o.jsxs(me,{variant:"outline",size:"sm",onClick:n,disabled:e||r,className:"gap-2",children:[e?o.jsx(Xe,{className:"w-3.5 h-3.5 animate-spin"}):o.jsx(Yc,{className:"w-3.5 h-3.5"}),a]})}async function UTt(t,e={}){const r=e.limit??60,n=e.maxDocs??5,s=e.maxSpan??15,i=t.trim();if(!i)return[];const{data:a,error:l}=await pe.rpc("search_user_pages",{p_query:i,p_limit:r,p_topic:i});if(l)throw l;const c=a??[],u=new Map;for(const f of c){if(!f.document_id)continue;const p=u.get(f.document_id)??{document_id:f.document_id,document_title:f.document_title??"Untitled",totalScore:0,pages:[]};p.totalScore+=f.score??0,p.pages.push({page_number:f.page_number,snippet:f.snippet??"",score:f.score??0}),u.set(f.document_id,p)}return Array.from(u.values()).sort((f,p)=>p.totalScore-f.totalScore).slice(0,n).map(f=>{const p=[...f.pages].sort((w,j)=>j.score-w.score),m=p[0].page_number;let g=m,y=m;for(const w of p.slice(1)){const j=Math.min(g,w.page_number),N=Math.max(y,w.page_number);N-j+1<=s&&(g=j,y=N)}const x=y-g+1,v=Math.max(0,Math.floor((s-x)/2));g=Math.max(1,g-v),y=y+Math.max(0,s-(y-g+1));const b=f.pages.filter(w=>w.page_number>=g&&w.page_number<=y).sort((w,j)=>w.page_number-j.page_number);return{document_id:f.document_id,document_title:f.document_title,score:f.totalScore,page_ranges:[{from:g,to:y}],pages:b}})}const HTt=()=>{const{user:t,loading:e,checkStudentPoints:r,studentPoints:n,fetchStudentPoints:s}=Ht(),[i,a]=S.useState(!1),l=Or(),{toast:c}=Bn(),[u,d]=S.useState([]),[h,f]=S.useState(""),[p,m]=S.useState("small"),[g,y]=S.useState("en"),[x,v]=S.useState(null),[b,w]=S.useState("APA7"),[j,N]=S.useState(!1),[C,A]=S.useState(null),[E,O]=S.useState(null),[$,T]=S.useState(!1),[M,k]=S.useState(null),[D,K]=S.useState(!1),H=S.useRef(""),[ee,V]=S.useState([]),[B,z]=S.useState(""),[F,G]=S.useState([]),[Q,ie]=S.useState(!1),[se,q]=S.useState(""),[L,Z]=S.useState(""),[J,W]=S.useState(!1);S.useEffect(()=>{!t&&!e&&l("/login")},[t,e,l]),S.useEffect(()=>{t&&(oe(),X())},[t]),S.useEffect(()=>{B?he():(G([]),q(""))},[B]),S.useEffect(()=>{M&&h.trim()!==H.current&&k(null)},[h,M]);const X=async()=>{const{data:ce}=await pe.from("theses").select("id, title").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});V(ce||[])},he=async()=>{const{data:ce}=await pe.from("chapters").select("id, title, order_index").eq("thesis_id",B).order("order_index");G(ce||[])},P=async()=>{if(!(!se||!C)){W(!0);try{const{data:ce}=await pe.from("sections").select("order_index").eq("chapter_id",se).order("order_index",{ascending:!1}).limit(1),ne=ce!=null&&ce.length?ce[0].order_index+1:0;await pe.from("sections").insert({chapter_id:se,content:C.content,title:L.trim()||null,type:"other",order_index:ne,status:"open"}),c({title:"Successfully imported",description:"Saved as section in chapter."}),ie(!1),Z(""),q("")}catch{c({title:"Error with Import",variant:"destructive"})}finally{W(!1)}}},oe=async()=>{try{const{data:ce,error:ne}=await pe.from("v_documents_with_status").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(ne)throw ne;d(ce||[])}catch(ce){console.error("Error loading documents:",ce),c({title:"Error",description:"Could not load documents.",variant:"destructive"})}},Y=async()=>{if(h.trim().length<5){c({title:"Add a topic first",description:"Please describe your topic (min. 5 characters) so we can find relevant sources.",variant:"destructive"});return}K(!0);try{const ce=await UTt(h);H.current=h.trim(),k(ce),ce.length===0&&c({title:"No matching sources",description:"Try refining the topic or add more documents to your library."})}catch(ce){c({title:"Could not suggest sources",description:(ce==null?void 0:ce.message)??"Unknown error",variant:"destructive"})}finally{K(!1)}},R=ce=>{k(ne=>ne&&ne.filter(fe=>fe.document_id!==ce))},I=S.useMemo(()=>(M??[]).map(ce=>ce.document_id),[M]),U=S.useMemo(()=>{const ce={};for(const ne of M??[]){const fe=ne.page_ranges[0];fe&&(ce[ne.document_id]=fe)}return ce},[M]),re=()=>I.reduce((ce,ne)=>{const fe=U[ne];return fe?ce+(fe.to-fe.from+1):ce},0),ue=async()=>{var ce,ne,fe;if(!r()){a(!0);return}if(I.length===0){c({title:"No sources selected",description:'Click "Find relevant sources" to auto-select pages from your library.',variant:"destructive"});return}if(h.length<5){c({title:"Error",description:"Topic must be at least 5 characters.",variant:"destructive"});return}N(!0);try{const{data:be,error:xe}=await pe.functions.invoke("thesis_builder",{body:{document_ids:I,page_ranges:U,topic:h,mode:p,language:g,citation_style:b,save_pdf:!1}});if(xe)throw xe;if((be==null?void 0:be.error)==="rate_limit"){const _e=be.retry_after||10;v(_e);let ke=_e;const $e=setInterval(()=>{ke-=1,v(ke),ke<=0&&(clearInterval($e),v(null),N(!1),ue())},1e3);return}A(be),T(!0),c({title:"Success",description:"Theory & Background generated!"}),t&&(await new Promise(_e=>setTimeout(_e,4e3)),await s(t.id)),O({prompt:((ce=be==null?void 0:be.usage)==null?void 0:ce.prompt_tokens)??void 0,completion:((ne=be==null?void 0:be.usage)==null?void 0:ne.completion_tokens)??void 0,total:((fe=be==null?void 0:be.usage)==null?void 0:fe.total_tokens)??void 0})}catch(be){console.error("Error generating thesis:",be);const xe=await BNe(be);xe.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"}):xe.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)}},ae=async ce=>{try{await navigator.clipboard.writeText(ce),c({title:"Copied",description:"Text copied to clipboard."})}catch{c({title:"Error",description:"Could not copy text.",variant:"destructive"})}},ge=()=>l("/documents");if(e)return o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})});if(!t)return null;const we=re();return o.jsxs(Cr,{showSidebar:!0,children:[o.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold",children:"Theory & Background"}),o.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate academic paragraphs from your documents with automatic citations."})]})}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Paragraph Configuration"})}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"topic",children:"Research Topic *"}),o.jsx(lr,{id:"topic",value:h,onChange:ce=>f(ce.target.value),className:"min-h-[100px]",placeholder:"Describe your topic or research question..."}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[h.length,"/5 characters (minimum 5 required)"]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Se,{children:"Relevant Sources"}),I.length>0&&o.jsxs("span",{className:`text-xs ${we>15?"text-red-500 font-medium":"text-muted-foreground"}`,children:[we," pages selected"]})]}),o.jsx(zTt,{sources:M,loading:D,disabled:j,onFetch:Y,onRemove:R}),we>15&&o.jsxs(yf,{className:"border-red-500/50 bg-red-500/10",children:[o.jsx(Jl,{className:"h-4 w-4 text-red-600"}),o.jsx(vf,{className:"text-red-700 dark:text-red-400 text-xs",children:"Maximum 15 pages total across all sources. Please remove one of the suggestions."})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Length"}),o.jsxs(pt,{value:p,onValueChange:m,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"small",children:"Short (300 Tokens)"}),o.jsx(Le,{value:"medium",children:"Medium (600 Tokens)"}),o.jsx(Le,{value:"big",children:"Long (1200 Tokens)"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Language"}),o.jsxs(pt,{value:g,onValueChange:y,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"de",children:"Deutsch"}),o.jsx(Le,{value:"en",children:"English"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Citation Style"}),o.jsxs(pt,{value:b,onValueChange:w,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"APA7",children:"APA7"}),o.jsx(Le,{value:"Harvard",children:"Harvard"}),o.jsx(Le,{value:"Chicago",children:"Chicago"}),o.jsx(Le,{value:"MLA",children:"MLA"})]})]})]}),o.jsx(me,{onClick:ue,disabled:j||I.length===0||h.length<5||we>15,className:"w-full",children:x!==null?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Retrying in ",x,"s..."]}):j?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):"Generate Paragraph"})]})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Result"})}),o.jsx(st,{children:C?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"font-semibold text-lg mb-2",children:C.title}),o.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:I.map(ce=>{const ne=u.find(fe=>fe.id===ce);return ne?o.jsx(kt,{variant:"secondary",className:"text-xs",children:ne.title||ne.original_filename},ce):null})}),o.jsxs(kt,{variant:"outline",className:"text-xs",children:[p.charAt(0).toUpperCase()+p.slice(1)," | ",b," |"," ",new Date().toLocaleDateString("en-US")]})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-semibold mb-2",children:"Generated Text"}),o.jsx("div",{className:"prose prose-sm max-w-none whitespace-pre-wrap",children:C.content.split(/Originaltextstellen:|Proof of Material:|Original quotes:/)[0].split("---")[0].trim()})]}),(C.content.includes("Originaltextstellen")||C.content.includes("Proof of Material")||C.content.includes("Original quotes"))&&o.jsxs(o.Fragment,{children:[o.jsx(Eo,{}),o.jsxs("div",{children:[o.jsxs("h4",{className:"font-semibold mb-3 flex items-center gap-2",children:[o.jsx(ua,{className:"h-4 w-4"}),"Original Quotes",o.jsx(kt,{variant:"outline",className:"text-xs font-normal",children:"Original Language"})]}),o.jsx("div",{className:"space-y-2",children:(()=>{var be,xe,_e,ke;let ce=C.content.split("Originaltextstellen:")[1];ce||(ce=C.content.split("Original quotes:")[1]),ce||(ce=C.content.split("Proof of Material:")[1]);const ne=(ke=(_e=(xe=(be=ce==null?void 0:ce.split("---")[0])==null?void 0:be.split("=== APA7 Literatur ===")[0])==null?void 0:xe.split("## Literaturverzeichnis")[0])==null?void 0:_e.split("## References")[0])==null?void 0:ke.trim();if(!ne)return o.jsx("p",{className:"text-sm text-muted-foreground",children:"No original quotes available"});const fe=ne.split(/\n(?=["„]|[A-Z][a-zäöü]+,?\s+\d{4})/).filter($e=>$e.trim());return fe.length>0?fe.map(($e,Te)=>o.jsx("div",{className:"bg-muted/50 border-l-4 border-primary/30 p-3 rounded-r-md",children:o.jsx("p",{className:"text-sm italic whitespace-pre-wrap",children:$e.trim()})},Te)):o.jsx("div",{className:"bg-muted/50 border-l-4 border-primary/30 p-3 rounded-r-md",children:o.jsx("p",{className:"text-sm italic whitespace-pre-wrap",children:ne})})})()})]})]}),(C.content.includes("Literaturverzeichnis")||C.content.includes("=== APA7 Literatur ===")||C.content.includes("References"))&&o.jsxs(o.Fragment,{children:[o.jsx(Eo,{}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-semibold mb-2",children:"References"}),o.jsx("div",{className:"prose prose-sm max-w-none whitespace-pre-wrap bg-muted p-3 rounded-md text-sm",children:(()=>{let ce=C.content.split("=== APA7 Literatur ===")[1];return ce||(ce=C.content.split("## Literaturverzeichnis")[1]),ce||(ce=C.content.split("## References")[1]),(ce==null?void 0:ce.trim())||(Array.isArray(C.literature)?C.literature.join(`
`):C.literature)})()})]})]}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>ae(C.content),children:[o.jsx(ws,{className:"mr-2 h-4 w-4"}),"Copy"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>ie(!0),disabled:!C,children:[o.jsx(s1,{className:"mr-2 h-4 w-4"}),"Import to Chapter"]}),o.jsxs(me,{variant:"outline",size:"sm",disabled:!0,className:"opacity-50 cursor-not-allowed",children:[o.jsx(jr,{className:"mr-2 h-4 w-4"}),"Create PDF (disabled)"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:ge,children:[o.jsx(jr,{className:"mr-2 h-4 w-4"}),"View in Library"]})]})]}):o.jsxs("div",{className:"text-center py-12",children:[o.jsx(jr,{className:"mx-auto h-12 w-12 text-muted-foreground mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:'Configure the parameters on the left and click "Generate Paragraph".'})]})})]})]})]}),o.jsx(jn,{open:Q,onOpenChange:ie,children:o.jsxs(pn,{children:[o.jsx(mn,{children:o.jsx(gn,{children:"Als Section importieren"})}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Thesis"}),o.jsxs(pt,{value:B,onValueChange:z,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select thesis..."})}),o.jsx(dt,{children:ee.map(ce=>o.jsx(Le,{value:ce.id,children:ce.title},ce.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Target Chapter"}),o.jsxs(pt,{value:se,onValueChange:q,disabled:!B,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:B?"Select chapter...":"Select thesis first"})}),o.jsx(dt,{children:F.map(ce=>o.jsx(Le,{value:ce.id,children:ce.title},ce.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Section-Titel (optional)"}),o.jsx(Ue,{value:L,onChange:ce=>Z(ce.target.value),placeholder:"z.B. Theoretischer Hintergrund"})]})]}),o.jsxs(kf,{children:[o.jsx(me,{variant:"outline",onClick:()=>ie(!1),children:"Abbrechen"}),o.jsx(me,{onClick:P,disabled:!se||J,children:J?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Importiere..."]}):o.jsxs(o.Fragment,{children:[o.jsx(No,{className:"mr-2 h-4 w-4"}),"Importieren"]})})]})]})}),o.jsx(cu,{open:i,onClose:()=>a(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]})},Use=t=>t.is_extracted===!0?!0:t.page_count==null||t.extracted_pages==null?!1:t.page_count-t.extracted_pages<3;function WTt({documents:t,selectedDocuments:e,onToggle:r,onUploadClick:n,emptyMessage:s="No documents available.",uploadLabel:i="Upload Document",className:a}){const l=Or(),[c,u]=S.useState(null),d=()=>{t.forEach(m=>{e.includes(m.id)||r(m.id)})},h=()=>{e.forEach(m=>r(m))},f=m=>{!Use(m)&&!e.includes(m.id)?u(m):r(m.id)},p=()=>{c&&l(`/pdf-extract?document=${c.id}`),u(null)};return t.length===0?o.jsx("div",{className:Pe("rounded-xl border border-border/50 bg-muted/30 p-6",a),children:o.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[o.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center",children:o.jsx(jr,{className:"h-6 w-6 text-muted-foreground"})}),o.jsx("p",{className:"text-sm text-muted-foreground",children:s}),n&&o.jsx(me,{variant:"outline",size:"sm",onClick:n,children:i})]})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:Pe("space-y-3",a),children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.length," of ",t.length," selected"]}),o.jsxs("div",{className:"flex gap-1",children:[o.jsxs(me,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:d,disabled:e.length===t.length,children:[o.jsx(kr,{className:"h-3 w-3 mr-1"}),"All"]}),o.jsxs(me,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:h,disabled:e.length===0,children:[o.jsx(fn,{className:"h-3 w-3 mr-1"}),"None"]})]})]}),o.jsx(Am,{className:"h-[280px] rounded-xl border border-border/50 bg-gradient-to-b from-background to-muted/20",children:o.jsx("div",{className:"p-2 space-y-0.5",children:t.map(m=>{const g=e.includes(m.id),y=Use(m);return o.jsxs("label",{htmlFor:`doc-${m.id}`,className:Pe("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:x=>{x.preventDefault(),f(m)},children:[o.jsx(aa,{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:x=>x.stopPropagation()}),o.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5",children:[o.jsx(jr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),o.jsx("p",{className:Pe("text-xs font-medium truncate transition-colors",g?"text-foreground":"text-muted-foreground group-hover:text-foreground"),children:m.title||m.original_filename}),o.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:["(",m.page_count||"?"," pages)"]}),!y&&o.jsx(ri,{children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(Jl,{className:"w-3 h-3 text-destructive shrink-0"})}),o.jsx(xr,{children:o.jsxs("p",{children:["Document needs extraction (",m.extracted_pages||0,"/",m.page_count||"?",")"]})})]})})]})]},m.id)})})})]}),o.jsx(Mi,{open:!!c,onOpenChange:m=>!m&&u(null),children:o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsxs(di,{className:"flex items-center gap-2",children:[o.jsx(Jl,{className:"h-5 w-5 text-destructive"}),"Document Not Extracted"]}),o.jsxs(hi,{className:"space-y-2",children:[o.jsxs("p",{children:["The document ",o.jsxs("strong",{children:['"',(c==null?void 0:c.title)||(c==null?void 0:c.original_filename),'"']})," has not been fully extracted yet."]}),o.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."]}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Please extract the document first to ensure all pages are available."})]})]}),o.jsxs(ui,{className:"flex-col sm:flex-row gap-2",children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(me,{variant:"outline",onClick:()=>{c&&r(c.id),u(null)},children:"Use Anyway"}),o.jsx(ai,{onClick:p,children:"Extract Now"})]})]})})]})}const VTt=()=>{const{user:t,loading:e,checkStudentPoints:r,studentPoints:n,fetchStudentPoints:s}=Ht(),[i,a]=S.useState(!1),l=Or(),{toast:c}=Bn(),[u,d]=S.useState([]),[h,f]=S.useState([]),[p,m]=S.useState({}),[g,y]=S.useState({}),[x,v]=S.useState("fox41"),[b,w]=S.useState(null),[j,N]=S.useState(""),[C,A]=S.useState("de"),[E,O]=S.useState("APA7"),[$,T]=S.useState(""),[M,k]=S.useState("small"),[D,K]=S.useState(0),[H,ee]=S.useState(null),[V,B]=S.useState(!1),[z,F]=S.useState(!1),[G,Q]=S.useState(null),[ie,se]=S.useState([]),[q,L]=S.useState(""),[Z,J]=S.useState([]),[W,X]=S.useState(!1),[he,P]=S.useState(""),[oe,Y]=S.useState(""),[R,I]=S.useState(!1);S.useEffect(()=>{!t&&!e&&l("/login")},[t,e,l]),S.useEffect(()=>{t&&(xe(),U())},[t]),S.useEffect(()=>{q?re():(J([]),P(""))},[q]);const U=async()=>{const{data:Re}=await pe.from("theses").select("id, title").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});se(Re||[])},re=async()=>{const{data:Re}=await pe.from("chapters").select("id, title, order_index").eq("thesis_id",q).order("order_index");J(Re||[])},ue=async()=>{if(!(!he||!G)){I(!0);try{const{data:Re}=await pe.from("sections").select("order_index").eq("chapter_id",he).order("order_index",{ascending:!1}).limit(1),ye=Re!=null&&Re.length?Re[0].order_index+1:0;await pe.from("sections").insert({chapter_id:he,content:G.content,title:oe.trim()||null,type:"other",order_index:ye,status:"open"}),c({title:"Successfully imported",description:"Saved as section in chapter."}),X(!1),Y(""),P("")}catch{c({title:"Fehler beim Import",variant:"destructive"})}finally{I(!1)}}},ae={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}},ge=Re=>Math.round(Re*1.4),we=Re=>Math.round(Re/4),ce=1e3;function ne(Re,ye,Ne){const Ce=ae[Re]??ae.small,Fe=ge((Ce.wordMin+Ce.wordMax)/2),He=Math.max(1,ye*Math.max(1,Ne))*ce,Ye=we(He),it=Ce.overheadTokens+Ye;return{prompt:it,completion:Fe,total:it+Fe}}const fe=()=>{if(h.length===0)return{tokens:{prompt:0,completion:0,total:0}};const Re=h.map(Ce=>{var Fe;return((Fe=u.find(yt=>yt.id===Ce))==null?void 0:Fe.page_count)||0}),ye=Math.max(1,Math.round(Re.reduce((Ce,Fe)=>Ce+Fe,0)/(Re.length||1))||5);return{tokens:ne(M,h.length,ye)}},be=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,Re=>{const ye=(crypto.getRandomValues(new Uint8Array(1))[0]&15)>>0;return(Re==="x"?ye:ye&3|8).toString(16)});S.useEffect(()=>{const Re=fe();K(Re.tokens.total)},[M,h,u]);const xe=async()=>{try{const{data:Re,error:ye}=await pe.from("v_documents_with_status").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(ye)throw ye;d(Re||[])}catch(Re){console.error("Error loading documents:",Re),c({title:"Error",description:"Documents could not be loaded.",variant:"destructive"})}},_e=async Re=>{var Ce,Fe;const{data:ye}=await pe.from("pages").select("page_number").eq("document_id",Re).order("page_number",{ascending:!0}).limit(1),{data:Ne}=await pe.from("pages").select("page_number").eq("document_id",Re).order("page_number",{ascending:!1}).limit(1);return{min:((Ce=ye==null?void 0:ye[0])==null?void 0:Ce.page_number)??1,max:((Fe=Ne==null?void 0:Ne[0])==null?void 0:Fe.page_number)??1}},ke=async Re=>{if(h.includes(Re))f(Ne=>Ne.filter(Ce=>Ce!==Re)),m(Ne=>{const Ce={...Ne};return delete Ce[Re],Ce}),y(Ne=>{const Ce={...Ne};return delete Ce[Re],Ce});else{const Ne=await _e(Re);y(Ce=>({...Ce,[Re]:Ne})),f(Ce=>[...Ce,Re]),m(Ce=>({...Ce,[Re]:{from:Ne.min,to:Math.min(Ne.max,Ne.min+14)}}))}},$e=()=>h.reduce((Re,ye)=>{const Ne=p[ye];return Ne?Re+(Ne.to-Ne.from+1):Re},0),Te=(Re,ye=40)=>Re.length>ye?Re.substring(0,ye)+"...":Re,ot=(Re,ye,Ne)=>{const Ce=g[Re]||{min:1,max:999},Fe=p[Re]||{from:Ce.min,to:Math.min(Ce.max,Ce.min+14)};let yt=ye==="from"?Ne:Fe.from,He=ye==="to"?Ne:Fe.to;yt=Math.max(Ce.min,Math.min(yt,Ce.max)),He=Math.max(Ce.min,Math.min(He,Ce.max)),ye==="from"&&yt>He&&(He=yt),ye==="to"&&He<yt&&(yt=He),m(Ye=>({...Ye,[Re]:{from:yt,to:He}}))},wt=async()=>{var Re,ye,Ne;if(!r()){a(!0);return}if(!j.trim()){c({title:"Error",description:"Please enter a topic.",variant:"destructive"});return}B(!0);try{const Ce=x==="fox40"?"methodology_builder_fox40":"methodology_builder",{data:Fe,error:yt}=await pe.functions.invoke(Ce,{body:{document_ids:h,page_ranges:p,topic:j.trim(),language:C,citation_style:E,own_words:$.trim(),mode:M,client_request_id:be()}});if(yt)throw yt;if((Fe==null?void 0:Fe.error)==="rate_limit"){const He=Fe.retry_after||10;w(He);let Ye=He;const it=setInterval(()=>{Ye-=1,w(Ye),Ye<=0&&(clearInterval(it),w(null),B(!1),wt())},1e3);return}Q(Fe),ee({prompt:((Re=Fe==null?void 0:Fe.usage)==null?void 0:Re.prompt_tokens)??void 0,completion:((ye=Fe==null?void 0:Fe.usage)==null?void 0:ye.completion_tokens)??void 0,total:((Ne=Fe==null?void 0:Fe.usage)==null?void 0:Ne.total_tokens)??void 0}),t&&(await new Promise(He=>setTimeout(He,4e3)),await s(t.id)),c({title:"Success",description:Fe.saved_to_library?"Methods & Approach generated and saved to library!":"Methods & Approach was generated!"})}catch(Ce){console.error("Error generating methodology:",Ce);const Fe=await BNe(Ce);Fe.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"}):Fe.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)}},Ct=async()=>{if(!(!G||!$.trim())){F(!0);try{const{data:Re,error:ye}=await pe.functions.invoke("methodology_builder",{body:{action:"refine",draft:G,own_words:$.trim(),language:C}});if(ye)throw ye;Q(Re),c({title:"Success",description:"Draft has been refined and merged!"})}catch(Re){console.error("Error refining methodology:",Re),c({title:"Error",description:Re.message||"Error refining the draft.",variant:"destructive"})}finally{F(!1)}}},pr=async Re=>{try{await navigator.clipboard.writeText(Re),c({title:"Copied",description:"Text has been copied to clipboard."})}catch{c({title:"Error",description:"Text could not be copied.",variant:"destructive"})}},Kt=()=>{l("/documents")};return e?o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?o.jsxs(Cr,{showSidebar:!0,children:[o.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold",children:"Methods & Approach"}),o.jsx("p",{className:"text-muted-foreground mt-2",children:"Develop a structured methodology based on your literature and your own approach."})]})}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Paragraph Configuration"})}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Sources (optional)"}),o.jsx(WTt,{documents:u,selectedDocuments:h,onToggle:ke,onUploadClick:()=>l("/summary"),emptyMessage:"No documents available.",uploadLabel:"Upload Document"})]}),h.length>0&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Se,{className:"text-sm font-medium",children:"Page Selection"}),o.jsxs("span",{className:`text-xs ${$e()>15?"text-red-500 font-medium":"text-muted-foreground"}`,children:[$e()," / 15 pages selected"]})]}),o.jsx("div",{className:"space-y-2",children:h.map(Re=>{const ye=u.find(He=>He.id===Re);if(!ye)return null;const Ne=g[Re]||{min:1,max:ye.page_count||1},Ce=p[Re]||{from:Ne.min,to:Math.min(Ne.max,Ne.min+14)},Fe=Te(ye.title||ye.original_filename||"Document"),yt=Ce.to-Ce.from+1;return o.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md",children:[o.jsx("span",{className:"text-xs text-muted-foreground flex-1 truncate",children:Fe}),o.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"p."}),o.jsx(Ue,{type:"number",min:Ne.min,max:Ne.max,value:Ce.from,onChange:He=>{const Ye=parseInt(He.target.value);isNaN(Ye)||m(it=>({...it,[Re]:{...it[Re],from:Ye}}))},onBlur:He=>ot(Re,"from",parseInt(He.target.value)||Ne.min),className:"w-14 h-7 text-xs text-center px-1"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"–"}),o.jsx(Ue,{type:"number",min:Ne.min,max:Ne.max,value:Ce.to,onChange:He=>{const Ye=parseInt(He.target.value);isNaN(Ye)||m(it=>({...it,[Re]:{...it[Re],to:Ye}}))},onBlur:He=>ot(Re,"to",parseInt(He.target.value)||Ne.min),className:"w-14 h-7 text-xs text-center px-1"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["/ ",Ne.max]}),o.jsxs(kt,{variant:yt>15?"destructive":"secondary",className:"text-xs ml-1",children:[yt,"p"]})]})]},Re)})}),$e()>15&&o.jsxs(yf,{className:"border-red-500/50 bg-red-500/10",children:[o.jsx(Jl,{className:"h-4 w-4 text-red-600"}),o.jsx(vf,{className:"text-red-700 dark:text-red-400 text-xs",children:"Maximum 15 pages total across all documents."})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"topic",children:"Topic / Focus *"}),o.jsx(Ue,{id:"topic",placeholder:"e.g. Mixed-methods evaluation of burnout prevention in nursing",value:j,onChange:Re=>N(Re.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Language"}),o.jsxs(pt,{value:C,onValueChange:A,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"de",children:"DE"}),o.jsx(Le,{value:"en",children:"EN"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Citation Style"}),o.jsxs(pt,{value:E,onValueChange:O,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsx(dt,{children:o.jsx(Le,{value:"APA7",children:"APA7"})})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Mode"}),o.jsxs(pt,{value:M,onValueChange:k,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"small",children:"Short"}),o.jsx(Le,{value:"medium",children:"Medium"}),o.jsx(Le,{value:"big",children:"Long"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"ownProcedure",children:"Your Approach (optional)"}),o.jsx(lr,{id:"ownProcedure",value:$,onChange:Re=>T(Re.target.value),className:"min-h-[120px]",placeholder:"Describe your own steps (sampling, tools, timeline, limitations, etc.)"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Se,{children:"AI Model"}),o.jsx(ri,{children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(lf,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"})}),o.jsxs(xr,{side:"top",className:"max-w-xs text-xs space-y-1",children:[o.jsxs("p",{children:[o.jsx("strong",{children:"Fox 4.0:"})," Faster, lower SP consumption"]}),o.jsxs("p",{children:[o.jsx("strong",{children:"Fox 4.1:"})," Higher quality, more SP consumption"]})]})]})})]}),o.jsxs(pt,{value:x,onValueChange:v,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"fox41",children:"Fox 4.1 — Advanced"}),o.jsx(Le,{value:"fox40",children:"Fox 4.0 — Fast"})]})]})]}),o.jsx(me,{onClick:wt,disabled:V||!j.trim()||$e()>15,className:"w-full",children:b!==null?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Retrying in ",b,"s..."]}):V?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating Draft..."]}):"Generate Draft"})]})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Results"})}),o.jsx(st,{children:G?o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{children:o.jsx("h3",{className:"font-semibold text-lg mb-2",children:G.title})}),o.jsx("div",{className:"prose prose-sm max-w-none text-sm",children:o.jsx(rc,{components:{h1:({children:Re})=>o.jsx("h1",{className:"text-lg font-semibold mt-6 mb-3 first:mt-0",children:Re}),h2:({children:Re})=>o.jsx("h2",{className:"text-base font-semibold mt-5 mb-2",children:Re}),p:({children:Re})=>o.jsx("p",{className:"mb-3 leading-relaxed",children:Re}),ul:({children:Re})=>o.jsx("ul",{className:"mb-3 ml-4 list-disc",children:Re}),ol:({children:Re})=>o.jsx("ol",{className:"mb-3 ml-4 list-decimal",children:Re}),li:({children:Re})=>o.jsx("li",{className:"mb-1",children:Re})},children:G.content.split(/Originaltextstellen:|Proof of Material:|Original quotes:/)[0].split("---")[0].trim()})}),(G.content.includes("Originaltextstellen")||G.content.includes("Proof of Material")||G.content.includes("Original quotes"))&&o.jsxs(o.Fragment,{children:[o.jsx(Eo,{}),o.jsxs("div",{children:[o.jsxs("h4",{className:"font-semibold mb-3 flex items-center gap-2",children:[o.jsx(ua,{className:"h-4 w-4"}),"Original Quotes",o.jsx(kt,{variant:"outline",className:"text-xs font-normal",children:"Original Language"})]}),o.jsx("div",{className:"space-y-2",children:(()=>{var Ce,Fe,yt,He;let Re=G.content.split("Originaltextstellen:")[1];Re||(Re=G.content.split("Original quotes:")[1]),Re||(Re=G.content.split("Proof of Material:")[1]);const ye=(He=(yt=(Fe=(Ce=Re==null?void 0:Re.split("---")[0])==null?void 0:Ce.split("=== APA7 Literatur ===")[0])==null?void 0:Fe.split("## Literaturverzeichnis")[0])==null?void 0:yt.split("## References")[0])==null?void 0:He.trim();if(!ye)return o.jsx("p",{className:"text-sm text-muted-foreground",children:"No original quotes available"});const Ne=ye.split(/\n(?=["„]|[A-Z][a-zäöü]+,?\s+\d{4})/).filter(Ye=>Ye.trim());return Ne.length>0?Ne.map((Ye,it)=>o.jsx("div",{className:"bg-muted/50 border-l-4 border-primary/30 p-3 rounded-r-md",children:o.jsx("p",{className:"text-sm italic whitespace-pre-wrap",children:Ye.trim()})},it)):o.jsx("div",{className:"bg-muted/50 border-l-4 border-primary/30 p-3 rounded-r-md",children:o.jsx("p",{className:"text-sm italic whitespace-pre-wrap",children:ye})})})()})]})]}),o.jsx(Eo,{}),G.literature&&G.literature.length>0&&o.jsxs("div",{children:[o.jsx("h4",{className:"font-semibold mb-2",children:"References"}),o.jsx("div",{className:"text-sm space-y-1",children:G.literature.map((Re,ye)=>o.jsx("div",{className:"text-sm text-muted-foreground",children:Re},ye))})]}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[$.trim()&&o.jsxs(me,{variant:"outline",size:"sm",onClick:Ct,disabled:z,children:[z?o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}):o.jsx(rfe,{className:"mr-2 h-4 w-4"}),"Refine & Merge"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>{var Re;return pr(`${G.title}

${G.content}

References:
${((Re=G.literature)==null?void 0:Re.join(`
`))||""}`)},children:[o.jsx(ws,{className:"mr-2 h-4 w-4"}),"Copy All"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>X(!0),disabled:!G,children:[o.jsx(s1,{className:"mr-2 h-4 w-4"}),"Import to Chapter"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:Kt,children:[o.jsx(jr,{className:"mr-2 h-4 w-4"}),"Go to Library"]})]})]}):o.jsxs("div",{className:"text-center py-12",children:[o.jsx(jr,{className:"mx-auto h-12 w-12 text-muted-foreground mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:'Fill in the parameters on the left and click "Generate Draft".'})]})})]})]})]}),o.jsx(jn,{open:W,onOpenChange:X,children:o.jsxs(pn,{children:[o.jsx(mn,{children:o.jsx(gn,{children:"Als Section importieren"})}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Thesis"}),o.jsxs(pt,{value:q,onValueChange:L,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select thesis..."})}),o.jsx(dt,{children:ie.map(Re=>o.jsx(Le,{value:Re.id,children:Re.title},Re.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Target Chapter"}),o.jsxs(pt,{value:he,onValueChange:P,disabled:!q,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:q?"Select Chapter...":"Select thesis first"})}),o.jsx(dt,{children:Z.map(Re=>o.jsx(Le,{value:Re.id,children:Re.title},Re.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Section Title (optional)"}),o.jsx(Ue,{value:oe,onChange:Re=>Y(Re.target.value),placeholder:"e.g. Methodology & Approach"})]})]}),o.jsxs(kf,{children:[o.jsx(me,{variant:"outline",onClick:()=>X(!1),children:"Abbrechen"}),o.jsx(me,{onClick:ue,disabled:!he||R,children:R?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Importiere..."]}):o.jsxs(o.Fragment,{children:[o.jsx(No,{className:"mr-2 h-4 w-4"}),"Importieren"]})})]})]})}),o.jsx(cu,{open:i,onClose:()=>a(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]}):null},qTt=["introduction","einleitung","methodology","methodik","methods","methoden","findings","ergebnisse","results","auswertung","analyse","analysis","interviews","discussion","diskussion","stand des wissens","theoretischer hintergrund","literature","literatur","theory","theorie"],GTt=()=>{const{user:t,loading:e,checkStudentPoints:r,studentPoints:n}=Ht(),[s,i]=S.useState(!1),a=Or(),{toast:l}=Bn(),[c,u]=S.useState([]),[d,h]=S.useState([]),[f,p]=S.useState(""),[m,g]=S.useState([]),[y,x]=S.useState("en"),[v,b]=S.useState("medium"),[w,j]=S.useState(!1),[N,C]=S.useState(null),[A,E]=S.useState(!1),[O,$]=S.useState(""),[T,M]=S.useState(""),[k,D]=S.useState(!1);S.useEffect(()=>{!t&&!e&&a("/login")},[t,e,a]),S.useEffect(()=>{t&&K()},[t]),S.useEffect(()=>{f&&(H(f),g([]),C(null))},[f]);const K=async()=>{try{const{data:Q,error:ie}=await pe.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(Q||[]),Q&&Q.length>0&&!f&&p(Q[0].id)}catch(Q){console.error("Error loading theses:",Q),l({title:"Error",description:"Could not load theses.",variant:"destructive"})}},H=async Q=>{try{const{data:ie,error:se}=await pe.from("chapters").select("id, title, order_index").eq("thesis_id",Q).is("parent_id",null).order("order_index",{ascending:!0});if(se)throw se;const{data:q,error:L}=await pe.from("sections").select("chapter_id, word_count").in("chapter_id",(ie||[]).map(W=>W.id));if(L)throw L;const Z={};(q||[]).forEach(W=>{Z[W.chapter_id]=(Z[W.chapter_id]||0)+W.word_count});const J=(ie||[]).map(W=>({...W,word_count:Z[W.id]||0,isRecommended:qTt.some(X=>W.title.toLowerCase().includes(X))}));h(J)}catch(ie){console.error("Error loading chapters:",ie),l({title:"Error",description:"Could not load chapters.",variant:"destructive"})}},ee=Q=>{g(ie=>ie.includes(Q)?ie.filter(se=>se!==Q):[...ie,Q])},V=S.useMemo(()=>d.filter(Q=>Q.word_count>0),[d]),B=async()=>{var Q;if(!r()){i(!0);return}if(m.length===0){l({title:"Error",description:"Please select at least one chapter.",variant:"destructive"});return}j(!0);try{const{data:ie,error:se}=await pe.functions.invoke("discussion_builder",{body:{thesis_id:f,chapter_ids:m,language:y,mode:v}});if(se)throw se;const q=(ie==null?void 0:ie.content)||(ie==null?void 0:ie.discussion_text)||((Q=ie==null?void 0:ie.data)==null?void 0:Q.content);if(console.log("Discussion response:",ie),typeof q=="string")C(q);else if(q!=null&&q.discussion_text)C(q.discussion_text);else throw new Error("Invalid response format");l({title:"Success",description:"Discussion generated successfully!"})}catch(ie){console.error("Error generating discussion:",ie),l({title:"Error",description:ie.message||"Error generating discussion.",variant:"destructive"})}finally{j(!1)}},z=async()=>{if(N)try{await navigator.clipboard.writeText(N),l({title:"Copied",description:"Text copied to clipboard."})}catch{l({title:"Error",description:"Could not copy text.",variant:"destructive"})}},F=async()=>{if(!(!N||!O)){D(!0);try{const{data:Q,error:ie}=await pe.from("sections").select("order_index").eq("chapter_id",O).order("order_index",{ascending:!1}).limit(1);if(ie)throw ie;const se=Q&&Q.length>0?Q[0].order_index+1:0,{error:q}=await pe.from("sections").insert({chapter_id:O,content:N,title:T.trim()||null,type:"other",order_index:se,status:"open"});if(q)throw q;l({title:"Imported",description:"Discussion imported as section."}),E(!1),M(""),$("")}catch(Q){console.error("Error importing section:",Q),l({title:"Error",description:Q.message||"Error importing.",variant:"destructive"})}finally{D(!1)}}},G={small:"Short (~500 words)",medium:"Medium (~1000 words)",big:"Long (~2000 words)"};return e?o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?o.jsxs(Cr,{showSidebar:!0,children:[o.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold",children:"Discussion Generator"}),o.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate a discussion based on your thesis chapters."})]})}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Settings"})}),o.jsxs(st,{className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Select Thesis"}),o.jsxs(pt,{value:f,onValueChange:p,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select thesis..."})}),o.jsx(dt,{children:c.map(Q=>o.jsx(Le,{value:Q.id,children:Q.title},Q.id))})]})]}),f&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Select Chapters"}),d.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"No chapters available."}):V.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"No chapters with content available."}):o.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto border rounded-lg p-3",children:d.map(Q=>{const ie=Q.word_count>0;return o.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg transition-colors ${ie?"hover:bg-muted/50":"opacity-50"}`,children:[o.jsx(aa,{id:Q.id,checked:m.includes(Q.id),onCheckedChange:()=>ee(Q.id),disabled:!ie}),o.jsx("label",{htmlFor:Q.id,className:`flex-1 text-sm ${ie?"cursor-pointer":"cursor-not-allowed"}`,children:Q.title}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[Q.word_count," words"]}),Q.isRecommended&&ie&&o.jsx(kt,{variant:"secondary",className:"text-xs",children:"Recommended"})]},Q.id)})}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[m.length," chapter(s) selected"]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Language"}),o.jsxs(pt,{value:y,onValueChange:Q=>x(Q),children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"de",children:"Deutsch"}),o.jsx(Le,{value:"en",children:"English"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Length"}),o.jsxs(pt,{value:v,onValueChange:Q=>b(Q),children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"small",children:G.small}),o.jsx(Le,{value:"medium",children:G.medium}),o.jsx(Le,{value:"big",children:G.big})]})]})]}),o.jsx(me,{onClick:B,disabled:w||m.length===0,className:"w-full",children:w?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating Discussion..."]}):"Generate Discussion"})]})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Result"})}),o.jsx(st,{children:N?o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"prose prose-sm max-w-none text-sm max-h-[500px] overflow-y-auto",children:o.jsx(rc,{components:{h1:({children:Q})=>o.jsx("h1",{className:"text-lg font-semibold mt-6 mb-3 first:mt-0",children:Q}),h2:({children:Q})=>o.jsx("h2",{className:"text-base font-semibold mt-5 mb-2",children:Q}),h3:({children:Q})=>o.jsx("h3",{className:"text-sm font-semibold mt-4 mb-2",children:Q}),p:({children:Q})=>o.jsx("p",{className:"mb-3 leading-relaxed",children:Q}),ul:({children:Q})=>o.jsx("ul",{className:"mb-3 ml-4 list-disc",children:Q}),ol:({children:Q})=>o.jsx("ol",{className:"mb-3 ml-4 list-decimal",children:Q}),li:({children:Q})=>o.jsx("li",{className:"mb-1",children:Q})},children:N})}),o.jsxs("div",{className:"flex flex-wrap gap-2 pt-4 border-t",children:[o.jsxs(me,{variant:"outline",size:"sm",onClick:z,children:[o.jsx(ws,{className:"mr-2 h-4 w-4"}),"Copy"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>E(!0),children:[o.jsx(s1,{className:"mr-2 h-4 w-4"}),"Import to Chapter"]})]})]}):o.jsxs("div",{className:"text-center py-12",children:[o.jsx(jr,{className:"mx-auto h-12 w-12 text-muted-foreground mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:'Select a thesis and chapters, then click "Generate Discussion".'})]})})]})]})]}),o.jsx(jn,{open:A,onOpenChange:E,children:o.jsxs(pn,{children:[o.jsx(mn,{children:o.jsx(gn,{children:"Import as Section"})}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Target Chapter"}),o.jsxs(pt,{value:O,onValueChange:$,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select chapter..."})}),o.jsx(dt,{children:d.map(Q=>o.jsx(Le,{value:Q.id,children:Q.title},Q.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Section Title (optional)"}),o.jsx(Ue,{value:T,onChange:Q=>M(Q.target.value),placeholder:"e.g. Discussion of Results"})]})]}),o.jsxs(kf,{children:[o.jsx(me,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),o.jsx(me,{onClick:F,disabled:!O||k,children:k?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(No,{className:"mr-2 h-4 w-4"}),"Import"]})})]})]})}),o.jsx(cu,{open:s,onClose:()=>i(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]}):null},KTt=["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"],YTt=()=>{const{user:t,loading:e,checkStudentPoints:r,studentPoints:n}=Ht(),[s,i]=S.useState(!1),a=Or(),{toast:l}=Bn(),[c,u]=S.useState([]),[d,h]=S.useState([]),[f,p]=S.useState(""),[m,g]=S.useState([]),[y,x]=S.useState("en"),[v,b]=S.useState("medium"),[w,j]=S.useState(!0),[N,C]=S.useState(!0),[A,E]=S.useState(!1),[O,$]=S.useState(null),[T,M]=S.useState(!1),[k,D]=S.useState(""),[K,H]=S.useState(""),[ee,V]=S.useState(!1);S.useEffect(()=>{!t&&!e&&a("/login")},[t,e,a]),S.useEffect(()=>{t&&B()},[t]),S.useEffect(()=>{f&&(z(f),g([]),$(null))},[f]);const B=async()=>{try{const{data:L,error:Z}=await pe.from("theses").select("id, title, degree").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});if(Z)throw Z;u(L||[]),L&&L.length>0&&!f&&p(L[0].id)}catch(L){console.error("Error loading theses:",L),l({title:"Error",description:"Could not load theses.",variant:"destructive"})}},z=async L=>{try{const{data:Z,error:J}=await pe.from("chapters").select("id, title, order_index").eq("thesis_id",L).is("parent_id",null).order("order_index",{ascending:!0});if(J)throw J;const{data:W,error:X}=await pe.from("sections").select("chapter_id, word_count").in("chapter_id",(Z||[]).map(oe=>oe.id));if(X)throw X;const he={};(W||[]).forEach(oe=>{he[oe.chapter_id]=(he[oe.chapter_id]||0)+oe.word_count});const P=(Z||[]).map(oe=>({...oe,word_count:he[oe.id]||0,isRecommended:KTt.some(Y=>oe.title.toLowerCase().includes(Y))}));h(P)}catch(Z){console.error("Error loading chapters:",Z),l({title:"Error",description:"Could not load chapters.",variant:"destructive"})}},F=L=>{g(Z=>Z.includes(L)?Z.filter(J=>J!==L):[...Z,L])},G=S.useMemo(()=>d.filter(L=>L.word_count>0),[d]),Q=async()=>{if(!r()){i(!0);return}if(m.length===0){l({title:"Error",description:"Please select at least one chapter.",variant:"destructive"});return}E(!0);try{const{data:L,error:Z}=await pe.functions.invoke("conclusion_builder",{body:{thesis_id:f,chapter_ids:m,language:y,mode:v,include_limitations:w,include_outlook:N}});if(Z)throw Z;const J=(L==null?void 0:L.conclusion_text)||(L==null?void 0:L.content);if(console.log("Conclusion response:",L),typeof J=="string")$(J);else throw new Error("Invalid response format");l({title:"Success",description:"Conclusion generated successfully!"})}catch(L){console.error("Error generating conclusion:",L),l({title:"Error",description:L.message||"Error generating conclusion.",variant:"destructive"})}finally{E(!1)}},ie=async()=>{if(O)try{await navigator.clipboard.writeText(O),l({title:"Copied",description:"Text copied to clipboard."})}catch{l({title:"Error",description:"Could not copy text.",variant:"destructive"})}},se=async()=>{if(!(!O||!k)){V(!0);try{const{data:L,error:Z}=await pe.from("sections").select("order_index").eq("chapter_id",k).order("order_index",{ascending:!1}).limit(1);if(Z)throw Z;const J=L&&L.length>0?L[0].order_index+1:0,{error:W}=await pe.from("sections").insert({chapter_id:k,content:O,title:K.trim()||null,type:"other",order_index:J,status:"open"});if(W)throw W;l({title:"Imported",description:"Conclusion imported as section."}),M(!1),H(""),D("")}catch(L){console.error("Error importing section:",L),l({title:"Error",description:L.message||"Error importing.",variant:"destructive"})}finally{V(!1)}}},q={small:"Short (~500 words)",medium:"Medium (~1000 words)",big:"Long (~2000 words)"};return e?o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?o.jsxs(Cr,{showSidebar:!0,children:[o.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold",children:"Conclusion Generator"}),o.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate a conclusion based on your thesis chapters including limitations and outlook."})]})}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Settings"})}),o.jsxs(st,{className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Select Thesis"}),o.jsxs(pt,{value:f,onValueChange:p,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select thesis..."})}),o.jsx(dt,{children:c.map(L=>o.jsx(Le,{value:L.id,children:L.title},L.id))})]})]}),f&&o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Select Chapters"}),d.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"No chapters available."}):G.length===0?o.jsx("p",{className:"text-sm text-muted-foreground",children:"No chapters with content available."}):o.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto border rounded-lg p-3",children:d.map(L=>{const Z=L.word_count>0;return o.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg transition-colors ${Z?"hover:bg-muted/50":"opacity-50"}`,children:[o.jsx(aa,{id:L.id,checked:m.includes(L.id),onCheckedChange:()=>F(L.id),disabled:!Z}),o.jsx("label",{htmlFor:L.id,className:`flex-1 text-sm ${Z?"cursor-pointer":"cursor-not-allowed"}`,children:L.title}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[L.word_count," words"]}),L.isRecommended&&Z&&o.jsx(kt,{variant:"secondary",className:"text-xs",children:"Recommended"})]},L.id)})}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[m.length," chapter(s) selected"]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Language"}),o.jsxs(pt,{value:y,onValueChange:L=>x(L),children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"de",children:"Deutsch"}),o.jsx(Le,{value:"en",children:"English"})]})]})]}),o.jsxs("div",{className:"space-y-3",children:[o.jsx(Se,{children:"Include Sections"}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(aa,{id:"include-limitations",checked:w,onCheckedChange:L=>j(!!L)}),o.jsx("label",{htmlFor:"include-limitations",className:"text-sm cursor-pointer",children:"Limitations (Einschränkungen der Studie)"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(aa,{id:"include-outlook",checked:N,onCheckedChange:L=>C(!!L)}),o.jsx("label",{htmlFor:"include-outlook",className:"text-sm cursor-pointer",children:"Ausblick / Future Research"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Length"}),o.jsxs(pt,{value:v,onValueChange:L=>b(L),children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"small",children:q.small}),o.jsx(Le,{value:"medium",children:q.medium}),o.jsx(Le,{value:"big",children:q.big})]})]})]}),o.jsx(me,{onClick:Q,disabled:A||m.length===0,className:"w-full",children:A?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating Conclusion..."]}):"Generate Conclusion"})]})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Result"})}),o.jsx(st,{children:O?o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"prose prose-sm max-w-none text-sm max-h-[500px] overflow-y-auto",children:o.jsx(rc,{components:{h1:({children:L})=>o.jsx("h1",{className:"text-lg font-semibold mt-6 mb-3 first:mt-0",children:L}),h2:({children:L})=>o.jsx("h2",{className:"text-base font-semibold mt-5 mb-2",children:L}),h3:({children:L})=>o.jsx("h3",{className:"text-sm font-semibold mt-4 mb-2",children:L}),p:({children:L})=>o.jsx("p",{className:"mb-3 leading-relaxed",children:L}),ul:({children:L})=>o.jsx("ul",{className:"mb-3 ml-4 list-disc",children:L}),ol:({children:L})=>o.jsx("ol",{className:"mb-3 ml-4 list-decimal",children:L}),li:({children:L})=>o.jsx("li",{className:"mb-1",children:L})},children:O})}),o.jsxs("div",{className:"flex flex-wrap gap-2 pt-4 border-t",children:[o.jsxs(me,{variant:"outline",size:"sm",onClick:ie,children:[o.jsx(ws,{className:"mr-2 h-4 w-4"}),"Copy"]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:()=>M(!0),children:[o.jsx(s1,{className:"mr-2 h-4 w-4"}),"Import to Chapter"]})]})]}):o.jsxs("div",{className:"text-center py-12",children:[o.jsx(jr,{className:"mx-auto h-12 w-12 text-muted-foreground mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:'Select a thesis and chapters, then click "Generate Conclusion".'})]})})]})]})]}),o.jsx(jn,{open:T,onOpenChange:M,children:o.jsxs(pn,{children:[o.jsx(mn,{children:o.jsx(gn,{children:"Import Conclusion as Section"})}),o.jsxs("div",{className:"space-y-4 py-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Target Chapter"}),o.jsxs(pt,{value:k,onValueChange:D,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select chapter..."})}),o.jsx(dt,{children:d.map(L=>o.jsx(Le,{value:L.id,children:L.title},L.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Section Title (optional)"}),o.jsx(Ue,{value:K,onChange:L=>H(L.target.value),placeholder:"e.g. Conclusion"})]})]}),o.jsxs(kf,{children:[o.jsx(me,{variant:"outline",onClick:()=>M(!1),children:"Cancel"}),o.jsx(me,{onClick:se,disabled:!k||ee,children:ee?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(No,{className:"mr-2 h-4 w-4"}),"Import"]})})]})]})}),o.jsx(cu,{open:s,onClose:()=>i(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]}):null};var XTt=Object.defineProperty,QTt=Object.defineProperties,ZTt=Object.getOwnPropertyDescriptors,Hse=Object.getOwnPropertySymbols,JTt=Object.prototype.hasOwnProperty,e2t=Object.prototype.propertyIsEnumerable,WH=(t,e,r)=>e in t?XTt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,or=(t,e)=>{for(var r in e||(e={}))JTt.call(e,r)&&WH(t,r,e[r]);if(Hse)for(var r of Hse(e))e2t.call(e,r)&&WH(t,r,e[r]);return t},bf=(t,e)=>QTt(t,ZTt(e)),Ee=(t,e,r)=>WH(t,typeof e!="symbol"?e+"":e,r),t2t=(t,e,r)=>new Promise((n,s)=>{var i=c=>{try{l(r.next(c))}catch(u){s(u)}},a=c=>{try{l(r.throw(c))}catch(u){s(u)}},l=c=>c.done?n(c.value):Promise.resolve(c.value).then(i,a);l((r=r.apply(t,e)).next())});class cO{constructor(e){Ee(this,"rootKey"),this.rootKey=e}}const r2t=Object.seal({});class Ae extends cO{constructor(e){super(e),Ee(this,"root"),this.root=new Array}prepForXml(e){var r;e.stack.push(this);const n=this.root.map(s=>s instanceof cO?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:r2t}}addChildElement(e){return this.root.push(e),this}}class Rf extends Ae{prepForXml(e){const r=super.prepForXml(e);if(r&&(typeof r[this.rootKey]!="object"||Object.keys(r[this.rootKey]).length))return r}}class bt extends cO{constructor(e){super("_attr"),Ee(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 Of extends cO{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})=>bf(or({},n),{[s]:i}),{})}}}class is extends bt{constructor(){super(...arguments),Ee(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 td=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function kG(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Z3={},HT={exports:{}},Wse;function CG(){if(Wse)return HT.exports;Wse=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(j,N,C){return Function.prototype.apply.call(j,N,C)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(j){return Object.getOwnPropertyNames(j).concat(Object.getOwnPropertySymbols(j))}:r=function(j){return Object.getOwnPropertyNames(j)};function n(w){console&&console.warn&&console.warn(w)}var s=Number.isNaN||function(j){return j!==j};function i(){i.init.call(this)}HT.exports=i,HT.exports.once=x,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var a=10;function l(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(j){if(typeof j!="number"||j<0||s(j))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+j+".");return this._maxListeners=j,this};function c(w){return w._maxListeners===void 0?i.defaultMaxListeners:w._maxListeners}i.prototype.getMaxListeners=function(){return c(this)},i.prototype.emit=function(j){for(var N=[],C=1;C<arguments.length;C++)N.push(arguments[C]);var A=j==="error",E=this._events;if(E!==void 0)A=A&&E.error===void 0;else if(!A)return!1;if(A){var O;if(N.length>0&&(O=N[0]),O instanceof Error)throw O;var $=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw $.context=O,$}var T=E[j];if(T===void 0)return!1;if(typeof T=="function")e(T,this,N);else for(var M=T.length,k=m(T,M),C=0;C<M;++C)e(k[C],this,N);return!0};function u(w,j,N,C){var A,E,O;if(l(N),E=w._events,E===void 0?(E=w._events=Object.create(null),w._eventsCount=0):(E.newListener!==void 0&&(w.emit("newListener",j,N.listener?N.listener:N),E=w._events),O=E[j]),O===void 0)O=E[j]=N,++w._eventsCount;else if(typeof O=="function"?O=E[j]=C?[N,O]:[O,N]:C?O.unshift(N):O.push(N),A=c(w),A>0&&O.length>A&&!O.warned){O.warned=!0;var $=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(j)+" listeners added. Use emitter.setMaxListeners() to increase limit");$.name="MaxListenersExceededWarning",$.emitter=w,$.type=j,$.count=O.length,n($)}return w}i.prototype.addListener=function(j,N){return u(this,j,N,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(j,N){return u(this,j,N,!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,j,N){var C={fired:!1,wrapFn:void 0,target:w,type:j,listener:N},A=d.bind(C);return A.listener=N,C.wrapFn=A,A}i.prototype.once=function(j,N){return l(N),this.on(j,h(this,j,N)),this},i.prototype.prependOnceListener=function(j,N){return l(N),this.prependListener(j,h(this,j,N)),this},i.prototype.removeListener=function(j,N){var C,A,E,O,$;if(l(N),A=this._events,A===void 0)return this;if(C=A[j],C===void 0)return this;if(C===N||C.listener===N)--this._eventsCount===0?this._events=Object.create(null):(delete A[j],A.removeListener&&this.emit("removeListener",j,C.listener||N));else if(typeof C!="function"){for(E=-1,O=C.length-1;O>=0;O--)if(C[O]===N||C[O].listener===N){$=C[O].listener,E=O;break}if(E<0)return this;E===0?C.shift():g(C,E),C.length===1&&(A[j]=C[0]),A.removeListener!==void 0&&this.emit("removeListener",j,$||N)}return this},i.prototype.off=i.prototype.removeListener,i.prototype.removeAllListeners=function(j){var N,C,A;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[j]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[j]),this;if(arguments.length===0){var E=Object.keys(C),O;for(A=0;A<E.length;++A)O=E[A],O!=="removeListener"&&this.removeAllListeners(O);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(N=C[j],typeof N=="function")this.removeListener(j,N);else if(N!==void 0)for(A=N.length-1;A>=0;A--)this.removeListener(j,N[A]);return this};function f(w,j,N){var C=w._events;if(C===void 0)return[];var A=C[j];return A===void 0?[]:typeof A=="function"?N?[A.listener||A]:[A]:N?y(A):m(A,A.length)}i.prototype.listeners=function(j){return f(this,j,!0)},i.prototype.rawListeners=function(j){return f(this,j,!1)},i.listenerCount=function(w,j){return typeof w.listenerCount=="function"?w.listenerCount(j):p.call(w,j)},i.prototype.listenerCount=p;function p(w){var j=this._events;if(j!==void 0){var N=j[w];if(typeof N=="function")return 1;if(N!==void 0)return N.length}return 0}i.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function m(w,j){for(var N=new Array(j),C=0;C<j;++C)N[C]=w[C];return N}function g(w,j){for(;j+1<w.length;j++)w[j]=w[j+1];w.pop()}function y(w){for(var j=new Array(w.length),N=0;N<j.length;++N)j[N]=w[N].listener||w[N];return j}function x(w,j){return new Promise(function(N,C){function A(O){w.removeListener(j,E),C(O)}function E(){typeof w.removeListener=="function"&&w.removeListener("error",A),N([].slice.call(arguments))}b(w,j,E,{once:!0}),j!=="error"&&v(w,A,{once:!0})})}function v(w,j,N){typeof w.on=="function"&&b(w,"error",j,N)}function b(w,j,N,C){if(typeof w.on=="function")C.once?w.once(j,N):w.on(j,N);else if(typeof w.addEventListener=="function")w.addEventListener(j,function A(E){C.once&&w.removeEventListener(j,A),N(E)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof w)}return HT.exports}var WT={exports:{}},Vse;function yg(){return Vse||(Vse=1,typeof Object.create=="function"?WT.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:WT.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}),WT.exports}function n2t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zNe={exports:{}},Is=zNe.exports={},Nu,ku;function VH(){throw new Error("setTimeout has not been defined")}function qH(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Nu=setTimeout:Nu=VH}catch{Nu=VH}try{typeof clearTimeout=="function"?ku=clearTimeout:ku=qH}catch{ku=qH}})();function UNe(t){if(Nu===setTimeout)return setTimeout(t,0);if((Nu===VH||!Nu)&&setTimeout)return Nu=setTimeout,setTimeout(t,0);try{return Nu(t,0)}catch{try{return Nu.call(null,t,0)}catch{return Nu.call(this,t,0)}}}function s2t(t){if(ku===clearTimeout)return clearTimeout(t);if((ku===qH||!ku)&&clearTimeout)return ku=clearTimeout,clearTimeout(t);try{return ku(t)}catch{try{return ku.call(null,t)}catch{return ku.call(this,t)}}}var Bh=[],N0=!1,hx,LP=-1;function i2t(){!N0||!hx||(N0=!1,hx.length?Bh=hx.concat(Bh):LP=-1,Bh.length&&HNe())}function HNe(){if(!N0){var t=UNe(i2t);N0=!0;for(var e=Bh.length;e;){for(hx=Bh,Bh=[];++LP<e;)hx&&hx[LP].run();LP=-1,e=Bh.length}hx=null,N0=!1,s2t(t)}}Is.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];Bh.push(new WNe(t,e)),Bh.length===1&&!N0&&UNe(HNe)};function WNe(t,e){this.fun=t,this.array=e}WNe.prototype.run=function(){this.fun.apply(null,this.array)};Is.title="browser";Is.browser=!0;Is.env={};Is.argv=[];Is.version="";Is.versions={};function Mf(){}Is.on=Mf;Is.addListener=Mf;Is.once=Mf;Is.off=Mf;Is.removeListener=Mf;Is.removeAllListeners=Mf;Is.emit=Mf;Is.prependListener=Mf;Is.prependOnceListener=Mf;Is.listeners=function(t){return[]};Is.binding=function(t){throw new Error("process.binding is not supported")};Is.cwd=function(){return"/"};Is.chdir=function(t){throw new Error("process.chdir is not supported")};Is.umask=function(){return 0};var a2t=zNe.exports;const fr=n2t(a2t);var J3,qse;function VNe(){return qse||(qse=1,J3=CG().EventEmitter),J3}var e$={},yS={},Gse;function o2t(){if(Gse)return yS;Gse=1,yS.byteLength=l,yS.toByteArray=u,yS.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 y=g===m?0:4-g%4;return[g,y]}function l(p){var m=a(p),g=m[0],y=m[1];return(g+y)*3/4-y}function c(p,m,g){return(m+g)*3/4-g}function u(p){var m,g=a(p),y=g[0],x=g[1],v=new r(c(p,y,x)),b=0,w=x>0?y-4:y,j;for(j=0;j<w;j+=4)m=e[p.charCodeAt(j)]<<18|e[p.charCodeAt(j+1)]<<12|e[p.charCodeAt(j+2)]<<6|e[p.charCodeAt(j+3)],v[b++]=m>>16&255,v[b++]=m>>8&255,v[b++]=m&255;return x===2&&(m=e[p.charCodeAt(j)]<<2|e[p.charCodeAt(j+1)]>>4,v[b++]=m&255),x===1&&(m=e[p.charCodeAt(j)]<<10|e[p.charCodeAt(j+1)]<<4|e[p.charCodeAt(j+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 y,x=[],v=m;v<g;v+=3)y=(p[v]<<16&16711680)+(p[v+1]<<8&65280)+(p[v+2]&255),x.push(d(y));return x.join("")}function f(p){for(var m,g=p.length,y=g%3,x=[],v=16383,b=0,w=g-y;b<w;b+=v)x.push(h(p,b,b+v>w?w:b+v));return y===1?(m=p[g-1],x.push(t[m>>2]+t[m<<4&63]+"==")):y===2&&(m=(p[g-2]<<8)+p[g-1],x.push(t[m>>10]+t[m>>4&63]+t[m<<2&63]+"=")),x.join("")}return yS}var VT={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var Kse;function l2t(){return Kse||(Kse=1,VT.read=function(t,e,r,n,s){var i,a,l=s*8-n-1,c=(1<<l)-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+=l;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)},VT.write=function(t,e,r,n,s,i){var a,l,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?(l=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?(l=0,a=d):a+h>=1?(l=(e*c-1)*Math.pow(2,s),a=a+h):(l=e*Math.pow(2,h-1)*Math.pow(2,s),a=0));s>=8;t[r+p]=l&255,p+=m,l/=256,s-=8);for(a=a<<s|l,u+=s;u>0;t[r+p]=a&255,p+=m,a/=256,u-=8);t[r+p-m]|=g*128}),VT}/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <https://feross.org>
 * @license  MIT
 */var Yse;function ZL(){return Yse||(Yse=1,function(t){var e=o2t(),r=l2t(),n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=l,t.SlowBuffer=v,t.INSPECT_MAX_BYTES=50;var s=2147483647;t.kMaxLength=s,l.TYPED_ARRAY_SUPPORT=i(),!l.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 Y=new Uint8Array(1),R={foo:function(){return 42}};return Object.setPrototypeOf(R,Uint8Array.prototype),Object.setPrototypeOf(Y,R),Y.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function a(Y){if(Y>s)throw new RangeError('The value "'+Y+'" is invalid for option "size"');var R=new Uint8Array(Y);return Object.setPrototypeOf(R,l.prototype),R}function l(Y,R,I){if(typeof Y=="number"){if(typeof R=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return h(Y)}return c(Y,R,I)}l.poolSize=8192;function c(Y,R,I){if(typeof Y=="string")return f(Y,R);if(ArrayBuffer.isView(Y))return m(Y);if(Y==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Y);if(he(Y,ArrayBuffer)||Y&&he(Y.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(he(Y,SharedArrayBuffer)||Y&&he(Y.buffer,SharedArrayBuffer)))return g(Y,R,I);if(typeof Y=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var U=Y.valueOf&&Y.valueOf();if(U!=null&&U!==Y)return l.from(U,R,I);var re=y(Y);if(re)return re;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof Y[Symbol.toPrimitive]=="function")return l.from(Y[Symbol.toPrimitive]("string"),R,I);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof Y)}l.from=function(Y,R,I){return c(Y,R,I)},Object.setPrototypeOf(l.prototype,Uint8Array.prototype),Object.setPrototypeOf(l,Uint8Array);function u(Y){if(typeof Y!="number")throw new TypeError('"size" argument must be of type number');if(Y<0)throw new RangeError('The value "'+Y+'" is invalid for option "size"')}function d(Y,R,I){return u(Y),Y<=0?a(Y):R!==void 0?typeof I=="string"?a(Y).fill(R,I):a(Y).fill(R):a(Y)}l.alloc=function(Y,R,I){return d(Y,R,I)};function h(Y){return u(Y),a(Y<0?0:x(Y)|0)}l.allocUnsafe=function(Y){return h(Y)},l.allocUnsafeSlow=function(Y){return h(Y)};function f(Y,R){if((typeof R!="string"||R==="")&&(R="utf8"),!l.isEncoding(R))throw new TypeError("Unknown encoding: "+R);var I=b(Y,R)|0,U=a(I),re=U.write(Y,R);return re!==I&&(U=U.slice(0,re)),U}function p(Y){for(var R=Y.length<0?0:x(Y.length)|0,I=a(R),U=0;U<R;U+=1)I[U]=Y[U]&255;return I}function m(Y){if(he(Y,Uint8Array)){var R=new Uint8Array(Y);return g(R.buffer,R.byteOffset,R.byteLength)}return p(Y)}function g(Y,R,I){if(R<0||Y.byteLength<R)throw new RangeError('"offset" is outside of buffer bounds');if(Y.byteLength<R+(I||0))throw new RangeError('"length" is outside of buffer bounds');var U;return R===void 0&&I===void 0?U=new Uint8Array(Y):I===void 0?U=new Uint8Array(Y,R):U=new Uint8Array(Y,R,I),Object.setPrototypeOf(U,l.prototype),U}function y(Y){if(l.isBuffer(Y)){var R=x(Y.length)|0,I=a(R);return I.length===0||Y.copy(I,0,0,R),I}if(Y.length!==void 0)return typeof Y.length!="number"||P(Y.length)?a(0):p(Y);if(Y.type==="Buffer"&&Array.isArray(Y.data))return p(Y.data)}function x(Y){if(Y>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return Y|0}function v(Y){return+Y!=Y&&(Y=0),l.alloc(+Y)}l.isBuffer=function(R){return R!=null&&R._isBuffer===!0&&R!==l.prototype},l.compare=function(R,I){if(he(R,Uint8Array)&&(R=l.from(R,R.offset,R.byteLength)),he(I,Uint8Array)&&(I=l.from(I,I.offset,I.byteLength)),!l.isBuffer(R)||!l.isBuffer(I))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(R===I)return 0;for(var U=R.length,re=I.length,ue=0,ae=Math.min(U,re);ue<ae;++ue)if(R[ue]!==I[ue]){U=R[ue],re=I[ue];break}return U<re?-1:re<U?1:0},l.isEncoding=function(R){switch(String(R).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}},l.concat=function(R,I){if(!Array.isArray(R))throw new TypeError('"list" argument must be an Array of Buffers');if(R.length===0)return l.alloc(0);var U;if(I===void 0)for(I=0,U=0;U<R.length;++U)I+=R[U].length;var re=l.allocUnsafe(I),ue=0;for(U=0;U<R.length;++U){var ae=R[U];if(he(ae,Uint8Array))ue+ae.length>re.length?l.from(ae).copy(re,ue):Uint8Array.prototype.set.call(re,ae,ue);else if(l.isBuffer(ae))ae.copy(re,ue);else throw new TypeError('"list" argument must be an Array of Buffers');ue+=ae.length}return re};function b(Y,R){if(l.isBuffer(Y))return Y.length;if(ArrayBuffer.isView(Y)||he(Y,ArrayBuffer))return Y.byteLength;if(typeof Y!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof Y);var I=Y.length,U=arguments.length>2&&arguments[2]===!0;if(!U&&I===0)return 0;for(var re=!1;;)switch(R){case"ascii":case"latin1":case"binary":return I;case"utf8":case"utf-8":return L(Y).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I*2;case"hex":return I>>>1;case"base64":return W(Y).length;default:if(re)return U?-1:L(Y).length;R=(""+R).toLowerCase(),re=!0}}l.byteLength=b;function w(Y,R,I){var U=!1;if((R===void 0||R<0)&&(R=0),R>this.length||((I===void 0||I>this.length)&&(I=this.length),I<=0)||(I>>>=0,R>>>=0,I<=R))return"";for(Y||(Y="utf8");;)switch(Y){case"hex":return V(this,R,I);case"utf8":case"utf-8":return k(this,R,I);case"ascii":return H(this,R,I);case"latin1":case"binary":return ee(this,R,I);case"base64":return M(this,R,I);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,R,I);default:if(U)throw new TypeError("Unknown encoding: "+Y);Y=(Y+"").toLowerCase(),U=!0}}l.prototype._isBuffer=!0;function j(Y,R,I){var U=Y[R];Y[R]=Y[I],Y[I]=U}l.prototype.swap16=function(){var R=this.length;if(R%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var I=0;I<R;I+=2)j(this,I,I+1);return this},l.prototype.swap32=function(){var R=this.length;if(R%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var I=0;I<R;I+=4)j(this,I,I+3),j(this,I+1,I+2);return this},l.prototype.swap64=function(){var R=this.length;if(R%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var I=0;I<R;I+=8)j(this,I,I+7),j(this,I+1,I+6),j(this,I+2,I+5),j(this,I+3,I+4);return this},l.prototype.toString=function(){var R=this.length;return R===0?"":arguments.length===0?k(this,0,R):w.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(R){if(!l.isBuffer(R))throw new TypeError("Argument must be a Buffer");return this===R?!0:l.compare(this,R)===0},l.prototype.inspect=function(){var R="",I=t.INSPECT_MAX_BYTES;return R=this.toString("hex",0,I).replace(/(.{2})/g,"$1 ").trim(),this.length>I&&(R+=" ... "),"<Buffer "+R+">"},n&&(l.prototype[n]=l.prototype.inspect),l.prototype.compare=function(R,I,U,re,ue){if(he(R,Uint8Array)&&(R=l.from(R,R.offset,R.byteLength)),!l.isBuffer(R))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof R);if(I===void 0&&(I=0),U===void 0&&(U=R?R.length:0),re===void 0&&(re=0),ue===void 0&&(ue=this.length),I<0||U>R.length||re<0||ue>this.length)throw new RangeError("out of range index");if(re>=ue&&I>=U)return 0;if(re>=ue)return-1;if(I>=U)return 1;if(I>>>=0,U>>>=0,re>>>=0,ue>>>=0,this===R)return 0;for(var ae=ue-re,ge=U-I,we=Math.min(ae,ge),ce=this.slice(re,ue),ne=R.slice(I,U),fe=0;fe<we;++fe)if(ce[fe]!==ne[fe]){ae=ce[fe],ge=ne[fe];break}return ae<ge?-1:ge<ae?1:0};function N(Y,R,I,U,re){if(Y.length===0)return-1;if(typeof I=="string"?(U=I,I=0):I>2147483647?I=2147483647:I<-2147483648&&(I=-2147483648),I=+I,P(I)&&(I=re?0:Y.length-1),I<0&&(I=Y.length+I),I>=Y.length){if(re)return-1;I=Y.length-1}else if(I<0)if(re)I=0;else return-1;if(typeof R=="string"&&(R=l.from(R,U)),l.isBuffer(R))return R.length===0?-1:C(Y,R,I,U,re);if(typeof R=="number")return R=R&255,typeof Uint8Array.prototype.indexOf=="function"?re?Uint8Array.prototype.indexOf.call(Y,R,I):Uint8Array.prototype.lastIndexOf.call(Y,R,I):C(Y,[R],I,U,re);throw new TypeError("val must be string, number or Buffer")}function C(Y,R,I,U,re){var ue=1,ae=Y.length,ge=R.length;if(U!==void 0&&(U=String(U).toLowerCase(),U==="ucs2"||U==="ucs-2"||U==="utf16le"||U==="utf-16le")){if(Y.length<2||R.length<2)return-1;ue=2,ae/=2,ge/=2,I/=2}function we(xe,_e){return ue===1?xe[_e]:xe.readUInt16BE(_e*ue)}var ce;if(re){var ne=-1;for(ce=I;ce<ae;ce++)if(we(Y,ce)===we(R,ne===-1?0:ce-ne)){if(ne===-1&&(ne=ce),ce-ne+1===ge)return ne*ue}else ne!==-1&&(ce-=ce-ne),ne=-1}else for(I+ge>ae&&(I=ae-ge),ce=I;ce>=0;ce--){for(var fe=!0,be=0;be<ge;be++)if(we(Y,ce+be)!==we(R,be)){fe=!1;break}if(fe)return ce}return-1}l.prototype.includes=function(R,I,U){return this.indexOf(R,I,U)!==-1},l.prototype.indexOf=function(R,I,U){return N(this,R,I,U,!0)},l.prototype.lastIndexOf=function(R,I,U){return N(this,R,I,U,!1)};function A(Y,R,I,U){I=Number(I)||0;var re=Y.length-I;U?(U=Number(U),U>re&&(U=re)):U=re;var ue=R.length;U>ue/2&&(U=ue/2);for(var ae=0;ae<U;++ae){var ge=parseInt(R.substr(ae*2,2),16);if(P(ge))return ae;Y[I+ae]=ge}return ae}function E(Y,R,I,U){return X(L(R,Y.length-I),Y,I,U)}function O(Y,R,I,U){return X(Z(R),Y,I,U)}function $(Y,R,I,U){return X(W(R),Y,I,U)}function T(Y,R,I,U){return X(J(R,Y.length-I),Y,I,U)}l.prototype.write=function(R,I,U,re){if(I===void 0)re="utf8",U=this.length,I=0;else if(U===void 0&&typeof I=="string")re=I,U=this.length,I=0;else if(isFinite(I))I=I>>>0,isFinite(U)?(U=U>>>0,re===void 0&&(re="utf8")):(re=U,U=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var ue=this.length-I;if((U===void 0||U>ue)&&(U=ue),R.length>0&&(U<0||I<0)||I>this.length)throw new RangeError("Attempt to write outside buffer bounds");re||(re="utf8");for(var ae=!1;;)switch(re){case"hex":return A(this,R,I,U);case"utf8":case"utf-8":return E(this,R,I,U);case"ascii":case"latin1":case"binary":return O(this,R,I,U);case"base64":return $(this,R,I,U);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,R,I,U);default:if(ae)throw new TypeError("Unknown encoding: "+re);re=(""+re).toLowerCase(),ae=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function M(Y,R,I){return R===0&&I===Y.length?e.fromByteArray(Y):e.fromByteArray(Y.slice(R,I))}function k(Y,R,I){I=Math.min(Y.length,I);for(var U=[],re=R;re<I;){var ue=Y[re],ae=null,ge=ue>239?4:ue>223?3:ue>191?2:1;if(re+ge<=I){var we,ce,ne,fe;switch(ge){case 1:ue<128&&(ae=ue);break;case 2:we=Y[re+1],(we&192)===128&&(fe=(ue&31)<<6|we&63,fe>127&&(ae=fe));break;case 3:we=Y[re+1],ce=Y[re+2],(we&192)===128&&(ce&192)===128&&(fe=(ue&15)<<12|(we&63)<<6|ce&63,fe>2047&&(fe<55296||fe>57343)&&(ae=fe));break;case 4:we=Y[re+1],ce=Y[re+2],ne=Y[re+3],(we&192)===128&&(ce&192)===128&&(ne&192)===128&&(fe=(ue&15)<<18|(we&63)<<12|(ce&63)<<6|ne&63,fe>65535&&fe<1114112&&(ae=fe))}}ae===null?(ae=65533,ge=1):ae>65535&&(ae-=65536,U.push(ae>>>10&1023|55296),ae=56320|ae&1023),U.push(ae),re+=ge}return K(U)}var D=4096;function K(Y){var R=Y.length;if(R<=D)return String.fromCharCode.apply(String,Y);for(var I="",U=0;U<R;)I+=String.fromCharCode.apply(String,Y.slice(U,U+=D));return I}function H(Y,R,I){var U="";I=Math.min(Y.length,I);for(var re=R;re<I;++re)U+=String.fromCharCode(Y[re]&127);return U}function ee(Y,R,I){var U="";I=Math.min(Y.length,I);for(var re=R;re<I;++re)U+=String.fromCharCode(Y[re]);return U}function V(Y,R,I){var U=Y.length;(!R||R<0)&&(R=0),(!I||I<0||I>U)&&(I=U);for(var re="",ue=R;ue<I;++ue)re+=oe[Y[ue]];return re}function B(Y,R,I){for(var U=Y.slice(R,I),re="",ue=0;ue<U.length-1;ue+=2)re+=String.fromCharCode(U[ue]+U[ue+1]*256);return re}l.prototype.slice=function(R,I){var U=this.length;R=~~R,I=I===void 0?U:~~I,R<0?(R+=U,R<0&&(R=0)):R>U&&(R=U),I<0?(I+=U,I<0&&(I=0)):I>U&&(I=U),I<R&&(I=R);var re=this.subarray(R,I);return Object.setPrototypeOf(re,l.prototype),re};function z(Y,R,I){if(Y%1!==0||Y<0)throw new RangeError("offset is not uint");if(Y+R>I)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(R,I,U){R=R>>>0,I=I>>>0,U||z(R,I,this.length);for(var re=this[R],ue=1,ae=0;++ae<I&&(ue*=256);)re+=this[R+ae]*ue;return re},l.prototype.readUintBE=l.prototype.readUIntBE=function(R,I,U){R=R>>>0,I=I>>>0,U||z(R,I,this.length);for(var re=this[R+--I],ue=1;I>0&&(ue*=256);)re+=this[R+--I]*ue;return re},l.prototype.readUint8=l.prototype.readUInt8=function(R,I){return R=R>>>0,I||z(R,1,this.length),this[R]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(R,I){return R=R>>>0,I||z(R,2,this.length),this[R]|this[R+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(R,I){return R=R>>>0,I||z(R,2,this.length),this[R]<<8|this[R+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(R,I){return R=R>>>0,I||z(R,4,this.length),(this[R]|this[R+1]<<8|this[R+2]<<16)+this[R+3]*16777216},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(R,I){return R=R>>>0,I||z(R,4,this.length),this[R]*16777216+(this[R+1]<<16|this[R+2]<<8|this[R+3])},l.prototype.readIntLE=function(R,I,U){R=R>>>0,I=I>>>0,U||z(R,I,this.length);for(var re=this[R],ue=1,ae=0;++ae<I&&(ue*=256);)re+=this[R+ae]*ue;return ue*=128,re>=ue&&(re-=Math.pow(2,8*I)),re},l.prototype.readIntBE=function(R,I,U){R=R>>>0,I=I>>>0,U||z(R,I,this.length);for(var re=I,ue=1,ae=this[R+--re];re>0&&(ue*=256);)ae+=this[R+--re]*ue;return ue*=128,ae>=ue&&(ae-=Math.pow(2,8*I)),ae},l.prototype.readInt8=function(R,I){return R=R>>>0,I||z(R,1,this.length),this[R]&128?(255-this[R]+1)*-1:this[R]},l.prototype.readInt16LE=function(R,I){R=R>>>0,I||z(R,2,this.length);var U=this[R]|this[R+1]<<8;return U&32768?U|4294901760:U},l.prototype.readInt16BE=function(R,I){R=R>>>0,I||z(R,2,this.length);var U=this[R+1]|this[R]<<8;return U&32768?U|4294901760:U},l.prototype.readInt32LE=function(R,I){return R=R>>>0,I||z(R,4,this.length),this[R]|this[R+1]<<8|this[R+2]<<16|this[R+3]<<24},l.prototype.readInt32BE=function(R,I){return R=R>>>0,I||z(R,4,this.length),this[R]<<24|this[R+1]<<16|this[R+2]<<8|this[R+3]},l.prototype.readFloatLE=function(R,I){return R=R>>>0,I||z(R,4,this.length),r.read(this,R,!0,23,4)},l.prototype.readFloatBE=function(R,I){return R=R>>>0,I||z(R,4,this.length),r.read(this,R,!1,23,4)},l.prototype.readDoubleLE=function(R,I){return R=R>>>0,I||z(R,8,this.length),r.read(this,R,!0,52,8)},l.prototype.readDoubleBE=function(R,I){return R=R>>>0,I||z(R,8,this.length),r.read(this,R,!1,52,8)};function F(Y,R,I,U,re,ue){if(!l.isBuffer(Y))throw new TypeError('"buffer" argument must be a Buffer instance');if(R>re||R<ue)throw new RangeError('"value" argument is out of bounds');if(I+U>Y.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(R,I,U,re){if(R=+R,I=I>>>0,U=U>>>0,!re){var ue=Math.pow(2,8*U)-1;F(this,R,I,U,ue,0)}var ae=1,ge=0;for(this[I]=R&255;++ge<U&&(ae*=256);)this[I+ge]=R/ae&255;return I+U},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(R,I,U,re){if(R=+R,I=I>>>0,U=U>>>0,!re){var ue=Math.pow(2,8*U)-1;F(this,R,I,U,ue,0)}var ae=U-1,ge=1;for(this[I+ae]=R&255;--ae>=0&&(ge*=256);)this[I+ae]=R/ge&255;return I+U},l.prototype.writeUint8=l.prototype.writeUInt8=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,1,255,0),this[I]=R&255,I+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,2,65535,0),this[I]=R&255,this[I+1]=R>>>8,I+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,2,65535,0),this[I]=R>>>8,this[I+1]=R&255,I+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,4,4294967295,0),this[I+3]=R>>>24,this[I+2]=R>>>16,this[I+1]=R>>>8,this[I]=R&255,I+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,4,4294967295,0),this[I]=R>>>24,this[I+1]=R>>>16,this[I+2]=R>>>8,this[I+3]=R&255,I+4},l.prototype.writeIntLE=function(R,I,U,re){if(R=+R,I=I>>>0,!re){var ue=Math.pow(2,8*U-1);F(this,R,I,U,ue-1,-ue)}var ae=0,ge=1,we=0;for(this[I]=R&255;++ae<U&&(ge*=256);)R<0&&we===0&&this[I+ae-1]!==0&&(we=1),this[I+ae]=(R/ge>>0)-we&255;return I+U},l.prototype.writeIntBE=function(R,I,U,re){if(R=+R,I=I>>>0,!re){var ue=Math.pow(2,8*U-1);F(this,R,I,U,ue-1,-ue)}var ae=U-1,ge=1,we=0;for(this[I+ae]=R&255;--ae>=0&&(ge*=256);)R<0&&we===0&&this[I+ae+1]!==0&&(we=1),this[I+ae]=(R/ge>>0)-we&255;return I+U},l.prototype.writeInt8=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,1,127,-128),R<0&&(R=255+R+1),this[I]=R&255,I+1},l.prototype.writeInt16LE=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,2,32767,-32768),this[I]=R&255,this[I+1]=R>>>8,I+2},l.prototype.writeInt16BE=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,2,32767,-32768),this[I]=R>>>8,this[I+1]=R&255,I+2},l.prototype.writeInt32LE=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,4,2147483647,-2147483648),this[I]=R&255,this[I+1]=R>>>8,this[I+2]=R>>>16,this[I+3]=R>>>24,I+4},l.prototype.writeInt32BE=function(R,I,U){return R=+R,I=I>>>0,U||F(this,R,I,4,2147483647,-2147483648),R<0&&(R=4294967295+R+1),this[I]=R>>>24,this[I+1]=R>>>16,this[I+2]=R>>>8,this[I+3]=R&255,I+4};function G(Y,R,I,U,re,ue){if(I+U>Y.length)throw new RangeError("Index out of range");if(I<0)throw new RangeError("Index out of range")}function Q(Y,R,I,U,re){return R=+R,I=I>>>0,re||G(Y,R,I,4),r.write(Y,R,I,U,23,4),I+4}l.prototype.writeFloatLE=function(R,I,U){return Q(this,R,I,!0,U)},l.prototype.writeFloatBE=function(R,I,U){return Q(this,R,I,!1,U)};function ie(Y,R,I,U,re){return R=+R,I=I>>>0,re||G(Y,R,I,8),r.write(Y,R,I,U,52,8),I+8}l.prototype.writeDoubleLE=function(R,I,U){return ie(this,R,I,!0,U)},l.prototype.writeDoubleBE=function(R,I,U){return ie(this,R,I,!1,U)},l.prototype.copy=function(R,I,U,re){if(!l.isBuffer(R))throw new TypeError("argument should be a Buffer");if(U||(U=0),!re&&re!==0&&(re=this.length),I>=R.length&&(I=R.length),I||(I=0),re>0&&re<U&&(re=U),re===U||R.length===0||this.length===0)return 0;if(I<0)throw new RangeError("targetStart out of bounds");if(U<0||U>=this.length)throw new RangeError("Index out of range");if(re<0)throw new RangeError("sourceEnd out of bounds");re>this.length&&(re=this.length),R.length-I<re-U&&(re=R.length-I+U);var ue=re-U;return this===R&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(I,U,re):Uint8Array.prototype.set.call(R,this.subarray(U,re),I),ue},l.prototype.fill=function(R,I,U,re){if(typeof R=="string"){if(typeof I=="string"?(re=I,I=0,U=this.length):typeof U=="string"&&(re=U,U=this.length),re!==void 0&&typeof re!="string")throw new TypeError("encoding must be a string");if(typeof re=="string"&&!l.isEncoding(re))throw new TypeError("Unknown encoding: "+re);if(R.length===1){var ue=R.charCodeAt(0);(re==="utf8"&&ue<128||re==="latin1")&&(R=ue)}}else typeof R=="number"?R=R&255:typeof R=="boolean"&&(R=Number(R));if(I<0||this.length<I||this.length<U)throw new RangeError("Out of range index");if(U<=I)return this;I=I>>>0,U=U===void 0?this.length:U>>>0,R||(R=0);var ae;if(typeof R=="number")for(ae=I;ae<U;++ae)this[ae]=R;else{var ge=l.isBuffer(R)?R:l.from(R,re),we=ge.length;if(we===0)throw new TypeError('The value "'+R+'" is invalid for argument "value"');for(ae=0;ae<U-I;++ae)this[ae+I]=ge[ae%we]}return this};var se=/[^+/0-9A-Za-z-_]/g;function q(Y){if(Y=Y.split("=")[0],Y=Y.trim().replace(se,""),Y.length<2)return"";for(;Y.length%4!==0;)Y=Y+"=";return Y}function L(Y,R){R=R||1/0;for(var I,U=Y.length,re=null,ue=[],ae=0;ae<U;++ae){if(I=Y.charCodeAt(ae),I>55295&&I<57344){if(!re){if(I>56319){(R-=3)>-1&&ue.push(239,191,189);continue}else if(ae+1===U){(R-=3)>-1&&ue.push(239,191,189);continue}re=I;continue}if(I<56320){(R-=3)>-1&&ue.push(239,191,189),re=I;continue}I=(re-55296<<10|I-56320)+65536}else re&&(R-=3)>-1&&ue.push(239,191,189);if(re=null,I<128){if((R-=1)<0)break;ue.push(I)}else if(I<2048){if((R-=2)<0)break;ue.push(I>>6|192,I&63|128)}else if(I<65536){if((R-=3)<0)break;ue.push(I>>12|224,I>>6&63|128,I&63|128)}else if(I<1114112){if((R-=4)<0)break;ue.push(I>>18|240,I>>12&63|128,I>>6&63|128,I&63|128)}else throw new Error("Invalid code point")}return ue}function Z(Y){for(var R=[],I=0;I<Y.length;++I)R.push(Y.charCodeAt(I)&255);return R}function J(Y,R){for(var I,U,re,ue=[],ae=0;ae<Y.length&&!((R-=2)<0);++ae)I=Y.charCodeAt(ae),U=I>>8,re=I%256,ue.push(re),ue.push(U);return ue}function W(Y){return e.toByteArray(q(Y))}function X(Y,R,I,U){for(var re=0;re<U&&!(re+I>=R.length||re>=Y.length);++re)R[re+I]=Y[re];return re}function he(Y,R){return Y instanceof R||Y!=null&&Y.constructor!=null&&Y.constructor.name!=null&&Y.constructor.name===R.name}function P(Y){return Y!==Y}var oe=function(){for(var Y="0123456789abcdef",R=new Array(256),I=0;I<16;++I)for(var U=I*16,re=0;re<16;++re)R[U+re]=Y[I]+Y[re];return R}()}(e$)),e$}var t$={},r$={},n$,Xse;function qNe(){return Xse||(Xse=1,n$=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 l=Object.getOwnPropertyDescriptor(e,r);if(l.value!==s||l.enumerable!==!0)return!1}return!0}),n$}var s$,Qse;function EG(){if(Qse)return s$;Qse=1;var t=qNe();return s$=function(){return t()&&!!Symbol.toStringTag},s$}var i$,Zse;function GNe(){return Zse||(Zse=1,i$=Object),i$}var a$,Jse;function c2t(){return Jse||(Jse=1,a$=Error),a$}var o$,eie;function u2t(){return eie||(eie=1,o$=EvalError),o$}var l$,tie;function d2t(){return tie||(tie=1,l$=RangeError),l$}var c$,rie;function h2t(){return rie||(rie=1,c$=ReferenceError),c$}var u$,nie;function KNe(){return nie||(nie=1,u$=SyntaxError),u$}var d$,sie;function gA(){return sie||(sie=1,d$=TypeError),d$}var h$,iie;function f2t(){return iie||(iie=1,h$=URIError),h$}var f$,aie;function p2t(){return aie||(aie=1,f$=Math.abs),f$}var p$,oie;function m2t(){return oie||(oie=1,p$=Math.floor),p$}var m$,lie;function g2t(){return lie||(lie=1,m$=Math.max),m$}var g$,cie;function x2t(){return cie||(cie=1,g$=Math.min),g$}var x$,uie;function y2t(){return uie||(uie=1,x$=Math.pow),x$}var y$,die;function v2t(){return die||(die=1,y$=Math.round),y$}var v$,hie;function b2t(){return hie||(hie=1,v$=Number.isNaN||function(e){return e!==e}),v$}var b$,fie;function w2t(){if(fie)return b$;fie=1;var t=b2t();return b$=function(r){return t(r)||r===0?r:r<0?-1:1},b$}var w$,pie;function j2t(){return pie||(pie=1,w$=Object.getOwnPropertyDescriptor),w$}var j$,mie;function xA(){if(mie)return j$;mie=1;var t=j2t();if(t)try{t([],"length")}catch{t=null}return j$=t,j$}var S$,gie;function JL(){if(gie)return S$;gie=1;var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return S$=t,S$}var _$,xie;function S2t(){if(xie)return _$;xie=1;var t=typeof Symbol<"u"&&Symbol,e=qNe();return _$=function(){return typeof t!="function"||typeof Symbol!="function"||typeof t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},_$}var N$,yie;function YNe(){return yie||(yie=1,N$=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),N$}var k$,vie;function XNe(){if(vie)return k$;vie=1;var t=GNe();return k$=t.getPrototypeOf||null,k$}var C$,bie;function _2t(){if(bie)return C$;bie=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(l,c){for(var u="",d=0;d<l.length;d+=1)u+=l[d],d+1<l.length&&(u+=c);return u};return C$=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 x=u.apply(this,s(d,arguments));return Object(x)===x?x: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 y=function(){};y.prototype=u.prototype,h.prototype=new y,y.prototype=null}return h},C$}var E$,wie;function yA(){if(wie)return E$;wie=1;var t=_2t();return E$=Function.prototype.bind||t,E$}var A$,jie;function AG(){return jie||(jie=1,A$=Function.prototype.call),A$}var T$,Sie;function QNe(){return Sie||(Sie=1,T$=Function.prototype.apply),T$}var P$,_ie;function N2t(){return _ie||(_ie=1,P$=typeof Reflect<"u"&&Reflect&&Reflect.apply),P$}var I$,Nie;function k2t(){if(Nie)return I$;Nie=1;var t=yA(),e=QNe(),r=AG(),n=N2t();return I$=n||t.call(r,e),I$}var R$,kie;function C2t(){if(kie)return R$;kie=1;var t=yA(),e=gA(),r=AG(),n=k2t();return R$=function(i){if(i.length<1||typeof i[0]!="function")throw new e("a function is required");return n(t,r,i)},R$}var O$,Cie;function E2t(){if(Cie)return O$;Cie=1;var t=C2t(),e=xA(),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 O$=n&&typeof n.get=="function"?t([n.get]):typeof i=="function"?function(l){return i(l==null?l:s(l))}:!1,O$}var M$,Eie;function A2t(){if(Eie)return M$;Eie=1;var t=YNe(),e=XNe(),r=E2t();return M$=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,M$}var D$,Aie;function T2t(){if(Aie)return D$;Aie=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,r=yA();return D$=r.call(t,e),D$}var L$,Tie;function TG(){if(Tie)return L$;Tie=1;var t,e=GNe(),r=c2t(),n=u2t(),s=d2t(),i=h2t(),a=KNe(),l=gA(),c=f2t(),u=p2t(),d=m2t(),h=g2t(),f=x2t(),p=y2t(),m=v2t(),g=w2t(),y=Function,x=function(Z){try{return y('"use strict"; return ('+Z+").constructor;")()}catch{}},v=xA(),b=JL(),w=function(){throw new l},j=v?function(){try{return arguments.callee,w}catch{try{return v(arguments,"callee").get}catch{return w}}}():w,N=S2t()(),C=A2t(),A=XNe(),E=YNe(),O=QNe(),$=AG(),T={},M=typeof Uint8Array>"u"||!C?t:C(Uint8Array),k={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?t:ArrayBuffer,"%ArrayIteratorPrototype%":N&&C?C([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":T,"%AsyncGenerator%":T,"%AsyncGeneratorFunction%":T,"%AsyncIteratorPrototype%":T,"%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%":y,"%GeneratorFunction%":T,"%Int8Array%":typeof Int8Array>"u"?t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":N&&C?C(C([][Symbol.iterator]())):t,"%JSON%":typeof JSON=="object"?JSON:t,"%Map%":typeof Map>"u"?t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!N||!C?t:C(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"||!N||!C?t:C(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":N&&C?C(""[Symbol.iterator]()):t,"%Symbol%":N?Symbol:t,"%SyntaxError%":a,"%ThrowTypeError%":j,"%TypedArray%":M,"%TypeError%":l,"%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%":$,"%Function.prototype.apply%":O,"%Object.defineProperty%":b,"%Object.getPrototypeOf%":A,"%Math.abs%":u,"%Math.floor%":d,"%Math.max%":h,"%Math.min%":f,"%Math.pow%":p,"%Math.round%":m,"%Math.sign%":g,"%Reflect.getPrototypeOf%":E};if(C)try{null.error}catch(Z){var D=C(C(Z));k["%Error.prototype%"]=D}var K=function Z(J){var W;if(J==="%AsyncFunction%")W=x("async function () {}");else if(J==="%GeneratorFunction%")W=x("function* () {}");else if(J==="%AsyncGeneratorFunction%")W=x("async function* () {}");else if(J==="%AsyncGenerator%"){var X=Z("%AsyncGeneratorFunction%");X&&(W=X.prototype)}else if(J==="%AsyncIteratorPrototype%"){var he=Z("%AsyncGenerator%");he&&C&&(W=C(he.prototype))}return k[J]=W,W},H={__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"]},ee=yA(),V=T2t(),B=ee.call($,Array.prototype.concat),z=ee.call(O,Array.prototype.splice),F=ee.call($,String.prototype.replace),G=ee.call($,String.prototype.slice),Q=ee.call($,RegExp.prototype.exec),ie=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,se=/\\(\\)?/g,q=function(J){var W=G(J,0,1),X=G(J,-1);if(W==="%"&&X!=="%")throw new a("invalid intrinsic syntax, expected closing `%`");if(X==="%"&&W!=="%")throw new a("invalid intrinsic syntax, expected opening `%`");var he=[];return F(J,ie,function(P,oe,Y,R){he[he.length]=Y?F(R,se,"$1"):oe||P}),he},L=function(J,W){var X=J,he;if(V(H,X)&&(he=H[X],X="%"+he[0]+"%"),V(k,X)){var P=k[X];if(P===T&&(P=K(X)),typeof P>"u"&&!W)throw new l("intrinsic "+J+" exists, but is not available. Please file an issue!");return{alias:he,name:X,value:P}}throw new a("intrinsic "+J+" does not exist!")};return L$=function(J,W){if(typeof J!="string"||J.length===0)throw new l("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof W!="boolean")throw new l('"allowMissing" argument must be a boolean');if(Q(/^%?[^%]*%?$/,J)===null)throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var X=q(J),he=X.length>0?X[0]:"",P=L("%"+he+"%",W),oe=P.name,Y=P.value,R=!1,I=P.alias;I&&(he=I[0],z(X,B([0,1],I)));for(var U=1,re=!0;U<X.length;U+=1){var ue=X[U],ae=G(ue,0,1),ge=G(ue,-1);if((ae==='"'||ae==="'"||ae==="`"||ge==='"'||ge==="'"||ge==="`")&&ae!==ge)throw new a("property names with quotes must have matching quotes");if((ue==="constructor"||!re)&&(R=!0),he+="."+ue,oe="%"+he+"%",V(k,oe))Y=k[oe];else if(Y!=null){if(!(ue in Y)){if(!W)throw new l("base intrinsic for "+J+" exists, but the property is not available.");return}if(v&&U+1>=X.length){var we=v(Y,ue);re=!!we,re&&"get"in we&&!("originalValue"in we.get)?Y=we.get:Y=Y[ue]}else re=V(Y,ue),Y=Y[ue];re&&!R&&(k[oe]=Y)}}return Y},L$}var $$={exports:{}},F$,Pie;function P2t(){if(Pie)return F$;Pie=1;var t=JL(),e=KNe(),r=gA(),n=xA();return F$=function(i,a,l){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:l,writable:u===null&&f?f.writable:!u});else if(h||!c&&!u&&!d)i[a]=l;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},F$}var B$,Iie;function I2t(){if(Iie)return B$;Iie=1;var t=JL(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return t([],"length",{value:1}).length!==1}catch{return!0}},B$=e,B$}var z$,Rie;function R2t(){if(Rie)return z$;Rie=1;var t=TG(),e=P2t(),r=I2t()(),n=xA(),s=gA(),i=t("%Math.floor%");return z$=function(l,c){if(typeof l!="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 l&&n){var f=n(l,"length");f&&!f.configurable&&(d=!1),f&&!f.writable&&(h=!1)}return(d||h||!u)&&(r?e(l,"length",c,!0,!0):e(l,"length",c)),l},z$}var Oie;function ZNe(){return Oie||(Oie=1,function(t){var e=yA(),r=TG(),n=R2t(),s=gA(),i=r("%Function.prototype.apply%"),a=r("%Function.prototype.call%"),l=r("%Reflect.apply%",!0)||e.call(a,i),c=JL(),u=r("%Math.max%");t.exports=function(f){if(typeof f!="function")throw new s("a function is required");var p=l(e,a,arguments);return n(p,1+u(0,f.length-(arguments.length-1)),!0)};var d=function(){return l(e,i,arguments)};c?c(t.exports,"apply",{value:d}):t.exports.apply=d}($$)),$$.exports}var U$,Mie;function JNe(){if(Mie)return U$;Mie=1;var t=TG(),e=ZNe(),r=e(t("String.prototype.indexOf"));return U$=function(s,i){var a=t(s,!!i);return typeof a=="function"&&r(s,".prototype.")>-1?e(a):a},U$}var H$,Die;function O2t(){if(Die)return H$;Die=1;var t=EG()(),e=JNe(),r=e("Object.prototype.toString"),n=function(l){return t&&l&&typeof l=="object"&&Symbol.toStringTag in l?!1:r(l)==="[object Arguments]"},s=function(l){return n(l)?!0:l!==null&&typeof l=="object"&&typeof l.length=="number"&&l.length>=0&&r(l)!=="[object Array]"&&r(l.callee)==="[object Function]"},i=function(){return n(arguments)}();return n.isLegacyArguments=s,H$=i?n:s,H$}var W$,Lie;function M2t(){if(Lie)return W$;Lie=1;var t=Object.prototype.toString,e=Function.prototype.toString,r=/^\s*(?:function)?\*/,n=EG()(),s=Object.getPrototypeOf,i=function(){if(!n)return!1;try{return Function("return function*() {}")()}catch{}},a;return W$=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},W$}var V$,$ie;function D2t(){if($ie)return V$;$ie=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}},l=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[,]),y=function(){return!1};if(typeof document=="object"){var x=document.all;l.call(x)===l.call(document.all)&&(y=function(b){if((g||!b)&&(typeof b>"u"||typeof b=="object"))try{var w=l.call(b);return(w===h||w===f||w===p||w===c)&&b("")==null}catch{}return!1})}return V$=e?function(b){if(y(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(y(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=l.call(b);return w!==u&&w!==d&&!/^\[object HTML/.test(w)?!1:a(b)},V$}var q$,Fie;function L2t(){if(Fie)return q$;Fie=1;var t=D2t(),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 q$=a,q$}var G$,Bie;function $2t(){return Bie||(Bie=1,G$=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),G$}var K$,zie;function F2t(){if(zie)return K$;zie=1;var t=$2t(),e=typeof globalThis>"u"?td:globalThis;return K$=function(){for(var n=[],s=0;s<t.length;s++)typeof e[t[s]]=="function"&&(n[n.length]=t[s]);return n},K$}var Y$,Uie;function eke(){if(Uie)return Y$;Uie=1;var t=L2t(),e=F2t(),r=ZNe(),n=JNe(),s=xA(),i=n("Object.prototype.toString"),a=EG()(),l=typeof globalThis>"u"?td:globalThis,c=e(),u=n("String.prototype.slice"),d=Object.getPrototypeOf,h=n("Array.prototype.indexOf",!0)||function(y,x){for(var v=0;v<y.length;v+=1)if(y[v]===x)return v;return-1},f={__proto__:null};a&&s&&d?t(c,function(g){var y=new l[g];if(Symbol.toStringTag in y){var x=d(y),v=s(x,Symbol.toStringTag);if(!v){var b=d(x);v=s(b,Symbol.toStringTag)}f["$"+g]=r(v.get)}}):t(c,function(g){var y=new l[g],x=y.slice||y.set;x&&(f["$"+g]=r(x))});var p=function(y){var x=!1;return t(f,function(v,b){if(!x)try{"$"+v(y)===b&&(x=u(b,1))}catch{}}),x},m=function(y){var x=!1;return t(f,function(v,b){if(!x)try{v(y),x=u(b,1)}catch{}}),x};return Y$=function(y){if(!y||typeof y!="object")return!1;if(!a){var x=u(i(y),8,-1);return h(c,x)>-1?x:x!=="Object"?!1:m(y)}return s?p(y):null},Y$}var X$,Hie;function B2t(){if(Hie)return X$;Hie=1;var t=eke();return X$=function(r){return!!t(r)},X$}var Wie;function z2t(){return Wie||(Wie=1,function(t){var e=O2t(),r=M2t(),n=eke(),s=B2t();function i(U){return U.call.bind(U)}var a=typeof BigInt<"u",l=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(l)var p=i(Symbol.prototype.valueOf);function m(U,re){if(typeof U!="object")return!1;try{return re(U),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=s;function g(U){return typeof Promise<"u"&&U instanceof Promise||U!==null&&typeof U=="object"&&typeof U.then=="function"&&typeof U.catch=="function"}t.isPromise=g;function y(U){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(U):s(U)||G(U)}t.isArrayBufferView=y;function x(U){return n(U)==="Uint8Array"}t.isUint8Array=x;function v(U){return n(U)==="Uint8ClampedArray"}t.isUint8ClampedArray=v;function b(U){return n(U)==="Uint16Array"}t.isUint16Array=b;function w(U){return n(U)==="Uint32Array"}t.isUint32Array=w;function j(U){return n(U)==="Int8Array"}t.isInt8Array=j;function N(U){return n(U)==="Int16Array"}t.isInt16Array=N;function C(U){return n(U)==="Int32Array"}t.isInt32Array=C;function A(U){return n(U)==="Float32Array"}t.isFloat32Array=A;function E(U){return n(U)==="Float64Array"}t.isFloat64Array=E;function O(U){return n(U)==="BigInt64Array"}t.isBigInt64Array=O;function $(U){return n(U)==="BigUint64Array"}t.isBigUint64Array=$;function T(U){return c(U)==="[object Map]"}T.working=typeof Map<"u"&&T(new Map);function M(U){return typeof Map>"u"?!1:T.working?T(U):U instanceof Map}t.isMap=M;function k(U){return c(U)==="[object Set]"}k.working=typeof Set<"u"&&k(new Set);function D(U){return typeof Set>"u"?!1:k.working?k(U):U instanceof Set}t.isSet=D;function K(U){return c(U)==="[object WeakMap]"}K.working=typeof WeakMap<"u"&&K(new WeakMap);function H(U){return typeof WeakMap>"u"?!1:K.working?K(U):U instanceof WeakMap}t.isWeakMap=H;function ee(U){return c(U)==="[object WeakSet]"}ee.working=typeof WeakSet<"u"&&ee(new WeakSet);function V(U){return ee(U)}t.isWeakSet=V;function B(U){return c(U)==="[object ArrayBuffer]"}B.working=typeof ArrayBuffer<"u"&&B(new ArrayBuffer);function z(U){return typeof ArrayBuffer>"u"?!1:B.working?B(U):U instanceof ArrayBuffer}t.isArrayBuffer=z;function F(U){return c(U)==="[object DataView]"}F.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&F(new DataView(new ArrayBuffer(1),0,1));function G(U){return typeof DataView>"u"?!1:F.working?F(U):U instanceof DataView}t.isDataView=G;var Q=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function ie(U){return c(U)==="[object SharedArrayBuffer]"}function se(U){return typeof Q>"u"?!1:(typeof ie.working>"u"&&(ie.working=ie(new Q)),ie.working?ie(U):U instanceof Q)}t.isSharedArrayBuffer=se;function q(U){return c(U)==="[object AsyncFunction]"}t.isAsyncFunction=q;function L(U){return c(U)==="[object Map Iterator]"}t.isMapIterator=L;function Z(U){return c(U)==="[object Set Iterator]"}t.isSetIterator=Z;function J(U){return c(U)==="[object Generator]"}t.isGeneratorObject=J;function W(U){return c(U)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=W;function X(U){return m(U,u)}t.isNumberObject=X;function he(U){return m(U,d)}t.isStringObject=he;function P(U){return m(U,h)}t.isBooleanObject=P;function oe(U){return a&&m(U,f)}t.isBigIntObject=oe;function Y(U){return l&&m(U,p)}t.isSymbolObject=Y;function R(U){return X(U)||he(U)||P(U)||oe(U)||Y(U)}t.isBoxedPrimitive=R;function I(U){return typeof Uint8Array<"u"&&(z(U)||se(U))}t.isAnyArrayBuffer=I,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(U){Object.defineProperty(t,U,{enumerable:!1,value:function(){throw new Error(U+" is not supported in userland")}})})}(r$)),r$}var Q$,Vie;function U2t(){return Vie||(Vie=1,Q$=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),Q$}var qie;function tke(){return qie||(qie=1,function(t){var e=Object.getOwnPropertyDescriptors||function(G){for(var Q=Object.keys(G),ie={},se=0;se<Q.length;se++)ie[Q[se]]=Object.getOwnPropertyDescriptor(G,Q[se]);return ie},r=/%[sdj%]/g;t.format=function(F){if(!j(F)){for(var G=[],Q=0;Q<arguments.length;Q++)G.push(a(arguments[Q]));return G.join(" ")}for(var Q=1,ie=arguments,se=ie.length,q=String(F).replace(r,function(Z){if(Z==="%%")return"%";if(Q>=se)return Z;switch(Z){case"%s":return String(ie[Q++]);case"%d":return Number(ie[Q++]);case"%j":try{return JSON.stringify(ie[Q++])}catch{return"[Circular]"}default:return Z}}),L=ie[Q];Q<se;L=ie[++Q])v(L)||!E(L)?q+=" "+L:q+=" "+a(L);return q},t.deprecate=function(F,G){if(typeof fr<"u"&&fr.noDeprecation===!0)return F;if(typeof fr>"u")return function(){return t.deprecate(F,G).apply(this,arguments)};var Q=!1;function ie(){if(!Q){if(fr.throwDeprecation)throw new Error(G);fr.traceDeprecation?console.trace(G):console.error(G),Q=!0}return F.apply(this,arguments)}return ie};var n={},s=/^$/;if(fr.env.NODE_DEBUG){var i=fr.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 G=fr.pid;n[F]=function(){var Q=t.format.apply(t,arguments);console.error("%s %d: %s",F,G,Q)}}else n[F]=function(){};return n[F]};function a(F,G){var Q={seen:[],stylize:c};return arguments.length>=3&&(Q.depth=arguments[2]),arguments.length>=4&&(Q.colors=arguments[3]),x(G)?Q.showHidden=G:G&&t._extend(Q,G),C(Q.showHidden)&&(Q.showHidden=!1),C(Q.depth)&&(Q.depth=2),C(Q.colors)&&(Q.colors=!1),C(Q.customInspect)&&(Q.customInspect=!0),Q.colors&&(Q.stylize=l),d(Q,F,Q.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 l(F,G){var Q=a.styles[G];return Q?"\x1B["+a.colors[Q][0]+"m"+F+"\x1B["+a.colors[Q][1]+"m":F}function c(F,G){return F}function u(F){var G={};return F.forEach(function(Q,ie){G[Q]=!0}),G}function d(F,G,Q){if(F.customInspect&&G&&T(G.inspect)&&G.inspect!==t.inspect&&!(G.constructor&&G.constructor.prototype===G)){var ie=G.inspect(Q,F);return j(ie)||(ie=d(F,ie,Q)),ie}var se=h(F,G);if(se)return se;var q=Object.keys(G),L=u(q);if(F.showHidden&&(q=Object.getOwnPropertyNames(G)),$(G)&&(q.indexOf("message")>=0||q.indexOf("description")>=0))return f(G);if(q.length===0){if(T(G)){var Z=G.name?": "+G.name:"";return F.stylize("[Function"+Z+"]","special")}if(A(G))return F.stylize(RegExp.prototype.toString.call(G),"regexp");if(O(G))return F.stylize(Date.prototype.toString.call(G),"date");if($(G))return f(G)}var J="",W=!1,X=["{","}"];if(y(G)&&(W=!0,X=["[","]"]),T(G)){var he=G.name?": "+G.name:"";J=" [Function"+he+"]"}if(A(G)&&(J=" "+RegExp.prototype.toString.call(G)),O(G)&&(J=" "+Date.prototype.toUTCString.call(G)),$(G)&&(J=" "+f(G)),q.length===0&&(!W||G.length==0))return X[0]+J+X[1];if(Q<0)return A(G)?F.stylize(RegExp.prototype.toString.call(G),"regexp"):F.stylize("[Object]","special");F.seen.push(G);var P;return W?P=p(F,G,Q,L,q):P=q.map(function(oe){return m(F,G,Q,L,oe,W)}),F.seen.pop(),g(P,J,X)}function h(F,G){if(C(G))return F.stylize("undefined","undefined");if(j(G)){var Q="'"+JSON.stringify(G).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return F.stylize(Q,"string")}if(w(G))return F.stylize(""+G,"number");if(x(G))return F.stylize(""+G,"boolean");if(v(G))return F.stylize("null","null")}function f(F){return"["+Error.prototype.toString.call(F)+"]"}function p(F,G,Q,ie,se){for(var q=[],L=0,Z=G.length;L<Z;++L)ee(G,String(L))?q.push(m(F,G,Q,ie,String(L),!0)):q.push("");return se.forEach(function(J){J.match(/^\d+$/)||q.push(m(F,G,Q,ie,J,!0))}),q}function m(F,G,Q,ie,se,q){var L,Z,J;if(J=Object.getOwnPropertyDescriptor(G,se)||{value:G[se]},J.get?J.set?Z=F.stylize("[Getter/Setter]","special"):Z=F.stylize("[Getter]","special"):J.set&&(Z=F.stylize("[Setter]","special")),ee(ie,se)||(L="["+se+"]"),Z||(F.seen.indexOf(J.value)<0?(v(Q)?Z=d(F,J.value,null):Z=d(F,J.value,Q-1),Z.indexOf(`
`)>-1&&(q?Z=Z.split(`
`).map(function(W){return"  "+W}).join(`
`).slice(2):Z=`
`+Z.split(`
`).map(function(W){return"   "+W}).join(`
`))):Z=F.stylize("[Circular]","special")),C(L)){if(q&&se.match(/^\d+$/))return Z;L=JSON.stringify(""+se),L.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(L=L.slice(1,-1),L=F.stylize(L,"name")):(L=L.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),L=F.stylize(L,"string"))}return L+": "+Z}function g(F,G,Q){var ie=F.reduce(function(se,q){return q.indexOf(`
`)>=0,se+q.replace(/\u001b\[\d\d?m/g,"").length+1},0);return ie>60?Q[0]+(G===""?"":G+`
 `)+" "+F.join(`,
  `)+" "+Q[1]:Q[0]+G+" "+F.join(", ")+" "+Q[1]}t.types=z2t();function y(F){return Array.isArray(F)}t.isArray=y;function x(F){return typeof F=="boolean"}t.isBoolean=x;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 j(F){return typeof F=="string"}t.isString=j;function N(F){return typeof F=="symbol"}t.isSymbol=N;function C(F){return F===void 0}t.isUndefined=C;function A(F){return E(F)&&k(F)==="[object RegExp]"}t.isRegExp=A,t.types.isRegExp=A;function E(F){return typeof F=="object"&&F!==null}t.isObject=E;function O(F){return E(F)&&k(F)==="[object Date]"}t.isDate=O,t.types.isDate=O;function $(F){return E(F)&&(k(F)==="[object Error]"||F instanceof Error)}t.isError=$,t.types.isNativeError=$;function T(F){return typeof F=="function"}t.isFunction=T;function M(F){return F===null||typeof F=="boolean"||typeof F=="number"||typeof F=="string"||typeof F=="symbol"||typeof F>"u"}t.isPrimitive=M,t.isBuffer=U2t();function k(F){return Object.prototype.toString.call(F)}function D(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 H(){var F=new Date,G=[D(F.getHours()),D(F.getMinutes()),D(F.getSeconds())].join(":");return[F.getDate(),K[F.getMonth()],G].join(" ")}t.log=function(){console.log("%s - %s",H(),t.format.apply(t,arguments))},t.inherits=yg(),t._extend=function(F,G){if(!G||!E(G))return F;for(var Q=Object.keys(G),ie=Q.length;ie--;)F[Q[ie]]=G[Q[ie]];return F};function ee(F,G){return Object.prototype.hasOwnProperty.call(F,G)}var V=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(G){if(typeof G!="function")throw new TypeError('The "original" argument must be of type Function');if(V&&G[V]){var Q=G[V];if(typeof Q!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(Q,V,{value:Q,enumerable:!1,writable:!1,configurable:!0}),Q}function Q(){for(var ie,se,q=new Promise(function(J,W){ie=J,se=W}),L=[],Z=0;Z<arguments.length;Z++)L.push(arguments[Z]);L.push(function(J,W){J?se(J):ie(W)});try{G.apply(this,L)}catch(J){se(J)}return q}return Object.setPrototypeOf(Q,Object.getPrototypeOf(G)),V&&Object.defineProperty(Q,V,{value:Q,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(Q,e(G))},t.promisify.custom=V;function B(F,G){if(!F){var Q=new Error("Promise was rejected with a falsy value");Q.reason=F,F=Q}return G(F)}function z(F){if(typeof F!="function")throw new TypeError('The "original" argument must be of type Function');function G(){for(var Q=[],ie=0;ie<arguments.length;ie++)Q.push(arguments[ie]);var se=Q.pop();if(typeof se!="function")throw new TypeError("The last argument must be of type Function");var q=this,L=function(){return se.apply(q,arguments)};F.apply(this,Q).then(function(Z){fr.nextTick(L.bind(null,null,Z))},function(Z){fr.nextTick(B.bind(null,Z,L))})}return Object.setPrototypeOf(G,Object.getPrototypeOf(F)),Object.defineProperties(G,e(F)),G}t.callbackify=z}(t$)),t$}var Z$,Gie;function H2t(){if(Gie)return Z$;Gie=1;function t(f,p){var m=Object.keys(f);if(Object.getOwnPropertySymbols){var g=Object.getOwnPropertySymbols(f);p&&(g=g.filter(function(y){return Object.getOwnPropertyDescriptor(f,y).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=ZL(),l=a.Buffer,c=tke(),u=c.inspect,d=u&&u.custom||"inspect";function h(f,p,m){l.prototype.copy.call(f,p,m)}return Z$=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,y=""+g.data;g=g.next;)y+=m+g.data;return y}},{key:"concat",value:function(m){if(this.length===0)return l.alloc(0);for(var g=l.allocUnsafe(m>>>0),y=this.head,x=0;y;)h(y.data,g,x),x+=y.data.length,y=y.next;return g}},{key:"consume",value:function(m,g){var y;return m<this.head.data.length?(y=this.head.data.slice(0,m),this.head.data=this.head.data.slice(m)):m===this.head.data.length?y=this.shift():y=g?this._getString(m):this._getBuffer(m),y}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(m){var g=this.head,y=1,x=g.data;for(m-=x.length;g=g.next;){var v=g.data,b=m>v.length?v.length:m;if(b===v.length?x+=v:x+=v.slice(0,m),m-=b,m===0){b===v.length?(++y,g.next?this.head=g.next:this.head=this.tail=null):(this.head=g,g.data=v.slice(b));break}++y}return this.length-=y,x}},{key:"_getBuffer",value:function(m){var g=l.allocUnsafe(m),y=this.head,x=1;for(y.data.copy(g),m-=y.data.length;y=y.next;){var v=y.data,b=m>v.length?v.length:m;if(v.copy(g,g.length-m,0,b),m-=b,m===0){b===v.length?(++x,y.next?this.head=y.next:this.head=this.tail=null):(this.head=y,y.data=v.slice(b));break}++x}return this.length-=x,g}},{key:d,value:function(m,g){return u(this,e({},g,{depth:0,customInspect:!1}))}}]),f}(),Z$}var J$,Kie;function rke(){if(Kie)return J$;Kie=1;function t(a,l){var c=this,u=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return u||d?(l?l(a):a&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,fr.nextTick(s,this,a)):fr.nextTick(s,this,a)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(a||null,function(h){!l&&h?c._writableState?c._writableState.errorEmitted?fr.nextTick(r,c):(c._writableState.errorEmitted=!0,fr.nextTick(e,c,h)):fr.nextTick(e,c,h):l?(fr.nextTick(r,c),l(h)):fr.nextTick(r,c)}),this)}function e(a,l){s(a,l),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,l){a.emit("error",l)}function i(a,l){var c=a._readableState,u=a._writableState;c&&c.autoDestroy||u&&u.autoDestroy?a.destroy(l):a.emit("error",l)}return J$={destroy:t,undestroy:n,errorOrDestroy:i},J$}var eF={},Yie;function Oj(){if(Yie)return eF;Yie=1;function t(l,c){l.prototype=Object.create(c.prototype),l.prototype.constructor=l,l.__proto__=c}var e={};function r(l,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,y){return f.call(this,d(m,g,y))||this}return p}(u);h.prototype.name=u.name,h.prototype.code=l,e[l]=h}function n(l,c){if(Array.isArray(l)){var u=l.length;return l=l.map(function(d){return String(d)}),u>2?"one of ".concat(c," ").concat(l.slice(0,u-1).join(", "),", or ")+l[u-1]:u===2?"one of ".concat(c," ").concat(l[0]," or ").concat(l[1]):"of ".concat(c," ").concat(l[0])}else return"of ".concat(c," ").concat(String(l))}function s(l,c,u){return l.substr(0,c.length)===c}function i(l,c,u){return(u===void 0||u>l.length)&&(u=l.length),l.substring(u-c.length,u)===c}function a(l,c,u){return typeof u!="number"&&(u=0),u+c.length>l.length?!1:l.indexOf(c,u)!==-1}return r("ERR_INVALID_OPT_VALUE",function(l,c){return'The value "'+c+'" is invalid for option "'+l+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(l,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(l," argument"))h="The ".concat(l," ").concat(d," ").concat(n(c,"type"));else{var f=a(l,".")?"property":"argument";h='The "'.concat(l,'" ').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(l){return"The "+l+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(l){return"Cannot call "+l+" 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(l){return"Unknown encoding: "+l},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),eF.codes=e,eF}var tF,Xie;function nke(){if(Xie)return tF;Xie=1;var t=Oj().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 l=e(s,a,i);if(l!=null){if(!(isFinite(l)&&Math.floor(l)===l)||l<0){var c=a?i:"highWaterMark";throw new t(c,l)}return Math.floor(l)}return n.objectMode?16:16*1024}return tF={getHighWaterMark:r},tF}var rF,Qie;function W2t(){if(Qie)return rF;Qie=1,rF=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(!td.localStorage)return!1}catch{return!1}var n=td.localStorage[r];return n==null?!1:String(n).toLowerCase()==="true"}return rF}var nF,Zie;function ske(){if(Zie)return nF;Zie=1,nF=A;function t(se){var q=this;this.next=null,this.entry=null,this.finish=function(){ie(q,se)}}var e;A.WritableState=N;var r={deprecate:W2t()},n=VNe(),s=ZL().Buffer,i=td.Uint8Array||function(){};function a(se){return s.from(se)}function l(se){return s.isBuffer(se)||se instanceof i}var c=rke(),u=nke(),d=u.getHighWaterMark,h=Oj().codes,f=h.ERR_INVALID_ARG_TYPE,p=h.ERR_METHOD_NOT_IMPLEMENTED,m=h.ERR_MULTIPLE_CALLBACK,g=h.ERR_STREAM_CANNOT_PIPE,y=h.ERR_STREAM_DESTROYED,x=h.ERR_STREAM_NULL_VALUES,v=h.ERR_STREAM_WRITE_AFTER_END,b=h.ERR_UNKNOWN_ENCODING,w=c.errorOrDestroy;yg()(A,n);function j(){}function N(se,q,L){e=e||$1(),se=se||{},typeof L!="boolean"&&(L=q instanceof e),this.objectMode=!!se.objectMode,L&&(this.objectMode=this.objectMode||!!se.writableObjectMode),this.highWaterMark=d(this,se,"writableHighWaterMark",L),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var Z=se.decodeStrings===!1;this.decodeStrings=!Z,this.defaultEncoding=se.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(J){K(q,J)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=se.emitClose!==!1,this.autoDestroy=!!se.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}N.prototype.getBuffer=function(){for(var q=this.bufferedRequest,L=[];q;)L.push(q),q=q.next;return L},function(){try{Object.defineProperty(N.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var C;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(C=Function.prototype[Symbol.hasInstance],Object.defineProperty(A,Symbol.hasInstance,{value:function(q){return C.call(this,q)?!0:this!==A?!1:q&&q._writableState instanceof N}})):C=function(q){return q instanceof this};function A(se){e=e||$1();var q=this instanceof e;if(!q&&!C.call(A,this))return new A(se);this._writableState=new N(se,this,q),this.writable=!0,se&&(typeof se.write=="function"&&(this._write=se.write),typeof se.writev=="function"&&(this._writev=se.writev),typeof se.destroy=="function"&&(this._destroy=se.destroy),typeof se.final=="function"&&(this._final=se.final)),n.call(this)}A.prototype.pipe=function(){w(this,new g)};function E(se,q){var L=new v;w(se,L),fr.nextTick(q,L)}function O(se,q,L,Z){var J;return L===null?J=new x:typeof L!="string"&&!q.objectMode&&(J=new f("chunk",["string","Buffer"],L)),J?(w(se,J),fr.nextTick(Z,J),!1):!0}A.prototype.write=function(se,q,L){var Z=this._writableState,J=!1,W=!Z.objectMode&&l(se);return W&&!s.isBuffer(se)&&(se=a(se)),typeof q=="function"&&(L=q,q=null),W?q="buffer":q||(q=Z.defaultEncoding),typeof L!="function"&&(L=j),Z.ending?E(this,L):(W||O(this,Z,se,L))&&(Z.pendingcb++,J=T(this,Z,W,se,q,L)),J},A.prototype.cork=function(){this._writableState.corked++},A.prototype.uncork=function(){var se=this._writableState;se.corked&&(se.corked--,!se.writing&&!se.corked&&!se.bufferProcessing&&se.bufferedRequest&&V(this,se))},A.prototype.setDefaultEncoding=function(q){if(typeof q=="string"&&(q=q.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((q+"").toLowerCase())>-1))throw new b(q);return this._writableState.defaultEncoding=q,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function $(se,q,L){return!se.objectMode&&se.decodeStrings!==!1&&typeof q=="string"&&(q=s.from(q,L)),q}Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function T(se,q,L,Z,J,W){if(!L){var X=$(q,Z,J);Z!==X&&(L=!0,J="buffer",Z=X)}var he=q.objectMode?1:Z.length;q.length+=he;var P=q.length<q.highWaterMark;if(P||(q.needDrain=!0),q.writing||q.corked){var oe=q.lastBufferedRequest;q.lastBufferedRequest={chunk:Z,encoding:J,isBuf:L,callback:W,next:null},oe?oe.next=q.lastBufferedRequest:q.bufferedRequest=q.lastBufferedRequest,q.bufferedRequestCount+=1}else M(se,q,!1,he,Z,J,W);return P}function M(se,q,L,Z,J,W,X){q.writelen=Z,q.writecb=X,q.writing=!0,q.sync=!0,q.destroyed?q.onwrite(new y("write")):L?se._writev(J,q.onwrite):se._write(J,W,q.onwrite),q.sync=!1}function k(se,q,L,Z,J){--q.pendingcb,L?(fr.nextTick(J,Z),fr.nextTick(G,se,q),se._writableState.errorEmitted=!0,w(se,Z)):(J(Z),se._writableState.errorEmitted=!0,w(se,Z),G(se,q))}function D(se){se.writing=!1,se.writecb=null,se.length-=se.writelen,se.writelen=0}function K(se,q){var L=se._writableState,Z=L.sync,J=L.writecb;if(typeof J!="function")throw new m;if(D(L),q)k(se,L,Z,q,J);else{var W=B(L)||se.destroyed;!W&&!L.corked&&!L.bufferProcessing&&L.bufferedRequest&&V(se,L),Z?fr.nextTick(H,se,L,W,J):H(se,L,W,J)}}function H(se,q,L,Z){L||ee(se,q),q.pendingcb--,Z(),G(se,q)}function ee(se,q){q.length===0&&q.needDrain&&(q.needDrain=!1,se.emit("drain"))}function V(se,q){q.bufferProcessing=!0;var L=q.bufferedRequest;if(se._writev&&L&&L.next){var Z=q.bufferedRequestCount,J=new Array(Z),W=q.corkedRequestsFree;W.entry=L;for(var X=0,he=!0;L;)J[X]=L,L.isBuf||(he=!1),L=L.next,X+=1;J.allBuffers=he,M(se,q,!0,q.length,J,"",W.finish),q.pendingcb++,q.lastBufferedRequest=null,W.next?(q.corkedRequestsFree=W.next,W.next=null):q.corkedRequestsFree=new t(q),q.bufferedRequestCount=0}else{for(;L;){var P=L.chunk,oe=L.encoding,Y=L.callback,R=q.objectMode?1:P.length;if(M(se,q,!1,R,P,oe,Y),L=L.next,q.bufferedRequestCount--,q.writing)break}L===null&&(q.lastBufferedRequest=null)}q.bufferedRequest=L,q.bufferProcessing=!1}A.prototype._write=function(se,q,L){L(new p("_write()"))},A.prototype._writev=null,A.prototype.end=function(se,q,L){var Z=this._writableState;return typeof se=="function"?(L=se,se=null,q=null):typeof q=="function"&&(L=q,q=null),se!=null&&this.write(se,q),Z.corked&&(Z.corked=1,this.uncork()),Z.ending||Q(this,Z,L),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function B(se){return se.ending&&se.length===0&&se.bufferedRequest===null&&!se.finished&&!se.writing}function z(se,q){se._final(function(L){q.pendingcb--,L&&w(se,L),q.prefinished=!0,se.emit("prefinish"),G(se,q)})}function F(se,q){!q.prefinished&&!q.finalCalled&&(typeof se._final=="function"&&!q.destroyed?(q.pendingcb++,q.finalCalled=!0,fr.nextTick(z,se,q)):(q.prefinished=!0,se.emit("prefinish")))}function G(se,q){var L=B(q);if(L&&(F(se,q),q.pendingcb===0&&(q.finished=!0,se.emit("finish"),q.autoDestroy))){var Z=se._readableState;(!Z||Z.autoDestroy&&Z.endEmitted)&&se.destroy()}return L}function Q(se,q,L){q.ending=!0,G(se,q),L&&(q.finished?fr.nextTick(L):se.once("finish",L)),q.ended=!0,se.writable=!1}function ie(se,q,L){var Z=se.entry;for(se.entry=null;Z;){var J=Z.callback;q.pendingcb--,J(L),Z=Z.next}q.corkedRequestsFree.next=se}return Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(q){this._writableState&&(this._writableState.destroyed=q)}}),A.prototype.destroy=c.destroy,A.prototype._undestroy=c.undestroy,A.prototype._destroy=function(se,q){q(se)},nF}var sF,Jie;function $1(){if(Jie)return sF;Jie=1;var t=Object.keys||function(u){var d=[];for(var h in u)d.push(h);return d};sF=a;var e=ike(),r=ske();yg()(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",l)))}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 l(){this._writableState.ended||fr.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)}}),sF}var iF={},qT={exports:{}},eae;function V2t(){return eae||(eae=1,function(t,e){var r=ZL(),n=r.Buffer;function s(a,l){for(var c in a)l[c]=a[c]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=r:(s(r,e),e.Buffer=i);function i(a,l,c){return n(a,l,c)}s(n,i),i.from=function(a,l,c){if(typeof a=="number")throw new TypeError("Argument must not be a number");return n(a,l,c)},i.alloc=function(a,l,c){if(typeof a!="number")throw new TypeError("Argument must be a number");var u=n(a);return l!==void 0?typeof c=="string"?u.fill(l,c):u.fill(l):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)}}(qT,qT.exports)),qT.exports}var tae;function GH(){if(tae)return iF;tae=1;var t=V2t().Buffer,e=t.isEncoding||function(x){switch(x=""+x,x&&x.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(x){if(!x)return"utf8";for(var v;;)switch(x){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 x;default:if(v)return;x=(""+x).toLowerCase(),v=!0}}function n(x){var v=r(x);if(typeof v!="string"&&(t.isEncoding===e||!e(x)))throw new Error("Unknown encoding: "+x);return v||x}iF.StringDecoder=s;function s(x){this.encoding=n(x);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=y;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(v)}s.prototype.write=function(x){if(x.length===0)return"";var v,b;if(this.lastNeed){if(v=this.fillLast(x),v===void 0)return"";b=this.lastNeed,this.lastNeed=0}else b=0;return b<x.length?v?v+this.text(x,b):this.text(x,b):v||""},s.prototype.end=d,s.prototype.text=u,s.prototype.fillLast=function(x){if(this.lastNeed<=x.length)return x.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);x.copy(this.lastChar,this.lastTotal-this.lastNeed,0,x.length),this.lastNeed-=x.length};function i(x){return x<=127?0:x>>5===6?2:x>>4===14?3:x>>3===30?4:x>>6===2?-1:-2}function a(x,v,b){var w=v.length-1;if(w<b)return 0;var j=i(v[w]);return j>=0?(j>0&&(x.lastNeed=j-1),j):--w<b||j===-2?0:(j=i(v[w]),j>=0?(j>0&&(x.lastNeed=j-2),j):--w<b||j===-2?0:(j=i(v[w]),j>=0?(j>0&&(j===2?j=0:x.lastNeed=j-3),j):0))}function l(x,v,b){if((v[0]&192)!==128)return x.lastNeed=0,"�";if(x.lastNeed>1&&v.length>1){if((v[1]&192)!==128)return x.lastNeed=1,"�";if(x.lastNeed>2&&v.length>2&&(v[2]&192)!==128)return x.lastNeed=2,"�"}}function c(x){var v=this.lastTotal-this.lastNeed,b=l(this,x);if(b!==void 0)return b;if(this.lastNeed<=x.length)return x.copy(this.lastChar,v,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);x.copy(this.lastChar,v,0,x.length),this.lastNeed-=x.length}function u(x,v){var b=a(this,x,v);if(!this.lastNeed)return x.toString("utf8",v);this.lastTotal=b;var w=x.length-(b-this.lastNeed);return x.copy(this.lastChar,0,w),x.toString("utf8",v,w)}function d(x){var v=x&&x.length?this.write(x):"";return this.lastNeed?v+"�":v}function h(x,v){if((x.length-v)%2===0){var b=x.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]=x[x.length-2],this.lastChar[1]=x[x.length-1],b.slice(0,-1)}return b}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=x[x.length-1],x.toString("utf16le",v,x.length-1)}function f(x){var v=x&&x.length?this.write(x):"";if(this.lastNeed){var b=this.lastTotal-this.lastNeed;return v+this.lastChar.toString("utf16le",0,b)}return v}function p(x,v){var b=(x.length-v)%3;return b===0?x.toString("base64",v):(this.lastNeed=3-b,this.lastTotal=3,b===1?this.lastChar[0]=x[x.length-1]:(this.lastChar[0]=x[x.length-2],this.lastChar[1]=x[x.length-1]),x.toString("base64",v,x.length-b))}function m(x){var v=x&&x.length?this.write(x):"";return this.lastNeed?v+this.lastChar.toString("base64",0,3-this.lastNeed):v}function g(x){return x.toString(this.encoding)}function y(x){return x&&x.length?this.write(x):""}return iF}var aF,rae;function PG(){if(rae)return aF;rae=1;var t=Oj().codes.ERR_STREAM_PREMATURE_CLOSE;function e(i){var a=!1;return function(){if(!a){a=!0;for(var l=arguments.length,c=new Array(l),u=0;u<l;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,l){if(typeof a=="function")return s(i,null,a);a||(a={}),l=e(l||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||l.call(i)},p=i._readableState&&i._readableState.endEmitted,m=function(){c=!1,p=!0,u||l.call(i)},g=function(b){l.call(i,b)},y=function(){var b;if(c&&!p)return(!i._readableState||!i._readableState.ended)&&(b=new t),l.call(i,b);if(u&&!h)return(!i._writableState||!i._writableState.ended)&&(b=new t),l.call(i,b)},x=function(){i.req.on("finish",f)};return n(i)?(i.on("complete",f),i.on("abort",y),i.req?x():i.on("request",x)):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",y),function(){i.removeListener("complete",f),i.removeListener("abort",y),i.removeListener("request",x),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",y)}}return aF=s,aF}var oF,nae;function q2t(){if(nae)return oF;nae=1;var t;function e(x,v,b){return v in x?Object.defineProperty(x,v,{value:b,enumerable:!0,configurable:!0,writable:!0}):x[v]=b,x}var r=PG(),n=Symbol("lastResolve"),s=Symbol("lastReject"),i=Symbol("error"),a=Symbol("ended"),l=Symbol("lastPromise"),c=Symbol("handlePromise"),u=Symbol("stream");function d(x,v){return{value:x,done:v}}function h(x){var v=x[n];if(v!==null){var b=x[u].read();b!==null&&(x[l]=null,x[n]=null,x[s]=null,v(d(b,!1)))}}function f(x){fr.nextTick(h,x)}function p(x,v){return function(b,w){x.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(C,A){fr.nextTick(function(){v[i]?A(v[i]):C(d(void 0,!0))})});var w=this[l],j;if(w)j=new Promise(p(w,this));else{var N=this[u].read();if(N!==null)return Promise.resolve(d(N,!1));j=new Promise(this[c])}return this[l]=j,j}},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(j){if(j){w(j);return}b(d(void 0,!0))})})}),t),m),y=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(N,C){var A=w[u].read();A?(w[l]=null,w[n]=null,w[s]=null,N(d(A,!1))):(w[n]=N,w[s]=C)},writable:!0}),b));return w[l]=null,r(v,function(j){if(j&&j.code!=="ERR_STREAM_PREMATURE_CLOSE"){var N=w[s];N!==null&&(w[l]=null,w[n]=null,w[s]=null,N(j)),w[i]=j;return}var C=w[n];C!==null&&(w[l]=null,w[n]=null,w[s]=null,C(d(void 0,!0))),w[a]=!0}),v.on("readable",f.bind(null,w)),w};return oF=y,oF}var lF,sae;function G2t(){return sae||(sae=1,lF=function(){throw new Error("Readable.from is not available in the browser")}),lF}var cF,iae;function ike(){if(iae)return cF;iae=1,cF=E;var t;E.ReadableState=A,CG().EventEmitter;var e=function(X,he){return X.listeners(he).length},r=VNe(),n=ZL().Buffer,s=td.Uint8Array||function(){};function i(W){return n.from(W)}function a(W){return n.isBuffer(W)||W instanceof s}var l=tke(),c;l&&l.debuglog?c=l.debuglog("stream"):c=function(){};var u=H2t(),d=rke(),h=nke(),f=h.getHighWaterMark,p=Oj().codes,m=p.ERR_INVALID_ARG_TYPE,g=p.ERR_STREAM_PUSH_AFTER_EOF,y=p.ERR_METHOD_NOT_IMPLEMENTED,x=p.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,v,b,w;yg()(E,r);var j=d.errorOrDestroy,N=["error","close","destroy","pause","resume"];function C(W,X,he){if(typeof W.prependListener=="function")return W.prependListener(X,he);!W._events||!W._events[X]?W.on(X,he):Array.isArray(W._events[X])?W._events[X].unshift(he):W._events[X]=[he,W._events[X]]}function A(W,X,he){t=t||$1(),W=W||{},typeof he!="boolean"&&(he=X instanceof t),this.objectMode=!!W.objectMode,he&&(this.objectMode=this.objectMode||!!W.readableObjectMode),this.highWaterMark=f(this,W,"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=W.emitClose!==!1,this.autoDestroy=!!W.autoDestroy,this.destroyed=!1,this.defaultEncoding=W.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,W.encoding&&(v||(v=GH().StringDecoder),this.decoder=new v(W.encoding),this.encoding=W.encoding)}function E(W){if(t=t||$1(),!(this instanceof E))return new E(W);var X=this instanceof t;this._readableState=new A(W,this,X),this.readable=!0,W&&(typeof W.read=="function"&&(this._read=W.read),typeof W.destroy=="function"&&(this._destroy=W.destroy)),r.call(this)}Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(X){this._readableState&&(this._readableState.destroyed=X)}}),E.prototype.destroy=d.destroy,E.prototype._undestroy=d.undestroy,E.prototype._destroy=function(W,X){X(W)},E.prototype.push=function(W,X){var he=this._readableState,P;return he.objectMode?P=!0:typeof W=="string"&&(X=X||he.defaultEncoding,X!==he.encoding&&(W=n.from(W,X),X=""),P=!0),O(this,W,X,!1,P)},E.prototype.unshift=function(W){return O(this,W,null,!0,!1)};function O(W,X,he,P,oe){c("readableAddChunk",X);var Y=W._readableState;if(X===null)Y.reading=!1,K(W,Y);else{var R;if(oe||(R=T(Y,X)),R)j(W,R);else if(Y.objectMode||X&&X.length>0)if(typeof X!="string"&&!Y.objectMode&&Object.getPrototypeOf(X)!==n.prototype&&(X=i(X)),P)Y.endEmitted?j(W,new x):$(W,Y,X,!0);else if(Y.ended)j(W,new g);else{if(Y.destroyed)return!1;Y.reading=!1,Y.decoder&&!he?(X=Y.decoder.write(X),Y.objectMode||X.length!==0?$(W,Y,X,!1):V(W,Y)):$(W,Y,X,!1)}else P||(Y.reading=!1,V(W,Y))}return!Y.ended&&(Y.length<Y.highWaterMark||Y.length===0)}function $(W,X,he,P){X.flowing&&X.length===0&&!X.sync?(X.awaitDrain=0,W.emit("data",he)):(X.length+=X.objectMode?1:he.length,P?X.buffer.unshift(he):X.buffer.push(he),X.needReadable&&H(W)),V(W,X)}function T(W,X){var he;return!a(X)&&typeof X!="string"&&X!==void 0&&!W.objectMode&&(he=new m("chunk",["string","Buffer","Uint8Array"],X)),he}E.prototype.isPaused=function(){return this._readableState.flowing===!1},E.prototype.setEncoding=function(W){v||(v=GH().StringDecoder);var X=new v(W);this._readableState.decoder=X,this._readableState.encoding=this._readableState.decoder.encoding;for(var he=this._readableState.buffer.head,P="";he!==null;)P+=X.write(he.data),he=he.next;return this._readableState.buffer.clear(),P!==""&&this._readableState.buffer.push(P),this._readableState.length=P.length,this};var M=1073741824;function k(W){return W>=M?W=M:(W--,W|=W>>>1,W|=W>>>2,W|=W>>>4,W|=W>>>8,W|=W>>>16,W++),W}function D(W,X){return W<=0||X.length===0&&X.ended?0:X.objectMode?1:W!==W?X.flowing&&X.length?X.buffer.head.data.length:X.length:(W>X.highWaterMark&&(X.highWaterMark=k(W)),W<=X.length?W:X.ended?X.length:(X.needReadable=!0,0))}E.prototype.read=function(W){c("read",W),W=parseInt(W,10);var X=this._readableState,he=W;if(W!==0&&(X.emittedReadable=!1),W===0&&X.needReadable&&((X.highWaterMark!==0?X.length>=X.highWaterMark:X.length>0)||X.ended))return c("read: emitReadable",X.length,X.ended),X.length===0&&X.ended?L(this):H(this),null;if(W=D(W,X),W===0&&X.ended)return X.length===0&&L(this),null;var P=X.needReadable;c("need readable",P),(X.length===0||X.length-W<X.highWaterMark)&&(P=!0,c("length less than watermark",P)),X.ended||X.reading?(P=!1,c("reading or ended",P)):P&&(c("do read"),X.reading=!0,X.sync=!0,X.length===0&&(X.needReadable=!0),this._read(X.highWaterMark),X.sync=!1,X.reading||(W=D(he,X)));var oe;return W>0?oe=q(W,X):oe=null,oe===null?(X.needReadable=X.length<=X.highWaterMark,W=0):(X.length-=W,X.awaitDrain=0),X.length===0&&(X.ended||(X.needReadable=!0),he!==W&&X.ended&&L(this)),oe!==null&&this.emit("data",oe),oe};function K(W,X){if(c("onEofChunk"),!X.ended){if(X.decoder){var he=X.decoder.end();he&&he.length&&(X.buffer.push(he),X.length+=X.objectMode?1:he.length)}X.ended=!0,X.sync?H(W):(X.needReadable=!1,X.emittedReadable||(X.emittedReadable=!0,ee(W)))}}function H(W){var X=W._readableState;c("emitReadable",X.needReadable,X.emittedReadable),X.needReadable=!1,X.emittedReadable||(c("emitReadable",X.flowing),X.emittedReadable=!0,fr.nextTick(ee,W))}function ee(W){var X=W._readableState;c("emitReadable_",X.destroyed,X.length,X.ended),!X.destroyed&&(X.length||X.ended)&&(W.emit("readable"),X.emittedReadable=!1),X.needReadable=!X.flowing&&!X.ended&&X.length<=X.highWaterMark,se(W)}function V(W,X){X.readingMore||(X.readingMore=!0,fr.nextTick(B,W,X))}function B(W,X){for(;!X.reading&&!X.ended&&(X.length<X.highWaterMark||X.flowing&&X.length===0);){var he=X.length;if(c("maybeReadMore read 0"),W.read(0),he===X.length)break}X.readingMore=!1}E.prototype._read=function(W){j(this,new y("_read()"))},E.prototype.pipe=function(W,X){var he=this,P=this._readableState;switch(P.pipesCount){case 0:P.pipes=W;break;case 1:P.pipes=[P.pipes,W];break;default:P.pipes.push(W);break}P.pipesCount+=1,c("pipe count=%d opts=%j",P.pipesCount,X);var oe=(!X||X.end!==!1)&&W!==fr.stdout&&W!==fr.stderr,Y=oe?I:ne;P.endEmitted?fr.nextTick(Y):he.once("end",Y),W.on("unpipe",R);function R(fe,be){c("onunpipe"),fe===he&&be&&be.hasUnpiped===!1&&(be.hasUnpiped=!0,ue())}function I(){c("onend"),W.end()}var U=z(he);W.on("drain",U);var re=!1;function ue(){c("cleanup"),W.removeListener("close",we),W.removeListener("finish",ce),W.removeListener("drain",U),W.removeListener("error",ge),W.removeListener("unpipe",R),he.removeListener("end",I),he.removeListener("end",ne),he.removeListener("data",ae),re=!0,P.awaitDrain&&(!W._writableState||W._writableState.needDrain)&&U()}he.on("data",ae);function ae(fe){c("ondata");var be=W.write(fe);c("dest.write",be),be===!1&&((P.pipesCount===1&&P.pipes===W||P.pipesCount>1&&J(P.pipes,W)!==-1)&&!re&&(c("false write response, pause",P.awaitDrain),P.awaitDrain++),he.pause())}function ge(fe){c("onerror",fe),ne(),W.removeListener("error",ge),e(W,"error")===0&&j(W,fe)}C(W,"error",ge);function we(){W.removeListener("finish",ce),ne()}W.once("close",we);function ce(){c("onfinish"),W.removeListener("close",we),ne()}W.once("finish",ce);function ne(){c("unpipe"),he.unpipe(W)}return W.emit("pipe",he),P.flowing||(c("pipe resume"),he.resume()),W};function z(W){return function(){var he=W._readableState;c("pipeOnDrain",he.awaitDrain),he.awaitDrain&&he.awaitDrain--,he.awaitDrain===0&&e(W,"data")&&(he.flowing=!0,se(W))}}E.prototype.unpipe=function(W){var X=this._readableState,he={hasUnpiped:!1};if(X.pipesCount===0)return this;if(X.pipesCount===1)return W&&W!==X.pipes?this:(W||(W=X.pipes),X.pipes=null,X.pipesCount=0,X.flowing=!1,W&&W.emit("unpipe",this,he),this);if(!W){var P=X.pipes,oe=X.pipesCount;X.pipes=null,X.pipesCount=0,X.flowing=!1;for(var Y=0;Y<oe;Y++)P[Y].emit("unpipe",this,{hasUnpiped:!1});return this}var R=J(X.pipes,W);return R===-1?this:(X.pipes.splice(R,1),X.pipesCount-=1,X.pipesCount===1&&(X.pipes=X.pipes[0]),W.emit("unpipe",this,he),this)},E.prototype.on=function(W,X){var he=r.prototype.on.call(this,W,X),P=this._readableState;return W==="data"?(P.readableListening=this.listenerCount("readable")>0,P.flowing!==!1&&this.resume()):W==="readable"&&!P.endEmitted&&!P.readableListening&&(P.readableListening=P.needReadable=!0,P.flowing=!1,P.emittedReadable=!1,c("on readable",P.length,P.reading),P.length?H(this):P.reading||fr.nextTick(G,this)),he},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(W,X){var he=r.prototype.removeListener.call(this,W,X);return W==="readable"&&fr.nextTick(F,this),he},E.prototype.removeAllListeners=function(W){var X=r.prototype.removeAllListeners.apply(this,arguments);return(W==="readable"||W===void 0)&&fr.nextTick(F,this),X};function F(W){var X=W._readableState;X.readableListening=W.listenerCount("readable")>0,X.resumeScheduled&&!X.paused?X.flowing=!0:W.listenerCount("data")>0&&W.resume()}function G(W){c("readable nexttick read 0"),W.read(0)}E.prototype.resume=function(){var W=this._readableState;return W.flowing||(c("resume"),W.flowing=!W.readableListening,Q(this,W)),W.paused=!1,this};function Q(W,X){X.resumeScheduled||(X.resumeScheduled=!0,fr.nextTick(ie,W,X))}function ie(W,X){c("resume",X.reading),X.reading||W.read(0),X.resumeScheduled=!1,W.emit("resume"),se(W),X.flowing&&!X.reading&&W.read(0)}E.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 se(W){var X=W._readableState;for(c("flow",X.flowing);X.flowing&&W.read()!==null;);}E.prototype.wrap=function(W){var X=this,he=this._readableState,P=!1;W.on("end",function(){if(c("wrapped end"),he.decoder&&!he.ended){var R=he.decoder.end();R&&R.length&&X.push(R)}X.push(null)}),W.on("data",function(R){if(c("wrapped data"),he.decoder&&(R=he.decoder.write(R)),!(he.objectMode&&R==null)&&!(!he.objectMode&&(!R||!R.length))){var I=X.push(R);I||(P=!0,W.pause())}});for(var oe in W)this[oe]===void 0&&typeof W[oe]=="function"&&(this[oe]=function(I){return function(){return W[I].apply(W,arguments)}}(oe));for(var Y=0;Y<N.length;Y++)W.on(N[Y],this.emit.bind(this,N[Y]));return this._read=function(R){c("wrapped _read",R),P&&(P=!1,W.resume())},this},typeof Symbol=="function"&&(E.prototype[Symbol.asyncIterator]=function(){return b===void 0&&(b=q2t()),b(this)}),Object.defineProperty(E.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(E.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(E.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(X){this._readableState&&(this._readableState.flowing=X)}}),E._fromList=q,Object.defineProperty(E.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function q(W,X){if(X.length===0)return null;var he;return X.objectMode?he=X.buffer.shift():!W||W>=X.length?(X.decoder?he=X.buffer.join(""):X.buffer.length===1?he=X.buffer.first():he=X.buffer.concat(X.length),X.buffer.clear()):he=X.buffer.consume(W,X.decoder),he}function L(W){var X=W._readableState;c("endReadable",X.endEmitted),X.endEmitted||(X.ended=!0,fr.nextTick(Z,X,W))}function Z(W,X){if(c("endReadableNT",W.endEmitted,W.length),!W.endEmitted&&W.length===0&&(W.endEmitted=!0,X.readable=!1,X.emit("end"),W.autoDestroy)){var he=X._writableState;(!he||he.autoDestroy&&he.finished)&&X.destroy()}}typeof Symbol=="function"&&(E.from=function(W,X){return w===void 0&&(w=G2t()),w(E,W,X)});function J(W,X){for(var he=0,P=W.length;he<P;he++)if(W[he]===X)return he;return-1}return cF}var uF,aae;function ake(){if(aae)return uF;aae=1,uF=l;var t=Oj().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=$1();yg()(l,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 l(d){if(!(this instanceof l))return new l(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)}l.prototype.push=function(d,h){return this._transformState.needTransform=!1,i.prototype.push.call(this,d,h)},l.prototype._transform=function(d,h,f){f(new e("_transform()"))},l.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)}},l.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},l.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 uF}var dF,oae;function K2t(){if(oae)return dF;oae=1,dF=e;var t=ake();yg()(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)},dF}var hF,lae;function Y2t(){if(lae)return hF;lae=1;var t;function e(f){var p=!1;return function(){p||(p=!0,f.apply(void 0,arguments))}}var r=Oj().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 l(f,p,m,g){g=e(g);var y=!1;f.on("close",function(){y=!0}),t===void 0&&(t=PG()),t(f,{readable:p,writable:m},function(v){if(v)return g(v);y=!0,g()});var x=!1;return function(v){if(!y&&!x){if(x=!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 y,x=p.map(function(v,b){var w=b<p.length-1,j=b>0;return l(v,w,j,function(N){y||(y=N),N&&x.forEach(c),!w&&(x.forEach(c),g(y))})});return p.reduce(u)}return hF=h,hF}var fF,cae;function IG(){if(cae)return fF;cae=1,fF=r;var t=CG().EventEmitter,e=yg();e(r,t),r.Readable=ike(),r.Writable=ske(),r.Duplex=$1(),r.Transform=ake(),r.PassThrough=K2t(),r.finished=PG(),r.pipeline=Y2t(),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 l(){i.readable&&i.resume&&i.resume()}n.on("drain",l),!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",l),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},fF}var uae;function X2t(){return uae||(uae=1,function(t){(function(e){e.parser=function(q,L){return new n(q,L)},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(q,L){if(!(this instanceof n))return new n(q,L);var Z=this;i(Z),Z.q=Z.c="",Z.bufferCheckPosition=e.MAX_BUFFER_LENGTH,Z.opt=L||{},Z.opt.lowercase=Z.opt.lowercase||Z.opt.lowercasetags,Z.looseCase=Z.opt.lowercase?"toLowerCase":"toUpperCase",Z.tags=[],Z.closed=Z.closedRoot=Z.sawRoot=!1,Z.tag=Z.error=null,Z.strict=!!q,Z.noscript=!!(q||Z.opt.noscript),Z.state=E.BEGIN,Z.strictEntities=Z.opt.strictEntities,Z.ENTITIES=Z.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),Z.attribList=[],Z.opt.xmlns&&(Z.ns=Object.create(g)),Z.trackPosition=Z.opt.position!==!1,Z.trackPosition&&(Z.position=Z.line=Z.column=0),$(Z,"onready")}Object.create||(Object.create=function(q){function L(){}L.prototype=q;var Z=new L;return Z}),Object.keys||(Object.keys=function(q){var L=[];for(var Z in q)q.hasOwnProperty(Z)&&L.push(Z);return L});function s(q){for(var L=Math.max(e.MAX_BUFFER_LENGTH,10),Z=0,J=0,W=r.length;J<W;J++){var X=q[r[J]].length;if(X>L)switch(r[J]){case"textNode":M(q);break;case"cdata":T(q,"oncdata",q.cdata),q.cdata="";break;case"script":T(q,"onscript",q.script),q.script="";break;default:D(q,"Max buffer length exceeded: "+r[J])}Z=Math.max(Z,X)}var he=e.MAX_BUFFER_LENGTH-Z;q.bufferCheckPosition=he+q.position}function i(q){for(var L=0,Z=r.length;L<Z;L++)q[r[L]]=""}function a(q){M(q),q.cdata!==""&&(T(q,"oncdata",q.cdata),q.cdata=""),q.script!==""&&(T(q,"onscript",q.script),q.script="")}n.prototype={end:function(){K(this)},write:se,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){a(this)}};var l;try{l=IG().Stream}catch{l=function(){}}var c=e.EVENTS.filter(function(q){return q!=="error"&&q!=="end"});function u(q,L){return new d(q,L)}function d(q,L){if(!(this instanceof d))return new d(q,L);l.apply(this),this._parser=new n(q,L),this.writable=!0,this.readable=!0;var Z=this;this._parser.onend=function(){Z.emit("end")},this._parser.onerror=function(J){Z.emit("error",J),Z._parser.error=null},this._decoder=null,c.forEach(function(J){Object.defineProperty(Z,"on"+J,{get:function(){return Z._parser["on"+J]},set:function(W){if(!W)return Z.removeAllListeners(J),Z._parser["on"+J]=W,W;Z.on(J,W)},enumerable:!0,configurable:!1})})}d.prototype=Object.create(l.prototype,{constructor:{value:d}}),d.prototype.write=function(q){if(typeof Buffer=="function"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(q)){if(!this._decoder){var L=GH().StringDecoder;this._decoder=new L("utf8")}q=this._decoder.write(q)}return this._parser.write(q.toString()),this.emit("data",q),!0},d.prototype.end=function(q){return q&&q.length&&this.write(q),this._parser.end(),!0},d.prototype.on=function(q,L){var Z=this;return!Z._parser["on"+q]&&c.indexOf(q)!==-1&&(Z._parser["on"+q]=function(){var J=arguments.length===1?[arguments[0]]:Array.apply(null,arguments);J.splice(0,0,q),Z.emit.apply(Z,J)}),l.prototype.on.call(Z,q,L)};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},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]/,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\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(q){return q===" "||q===`
`||q==="\r"||q==="	"}function j(q){return q==='"'||q==="'"}function N(q){return q===">"||w(q)}function C(q,L){return q.test(L)}function A(q,L){return!C(q,L)}var E=0;e.STATE={BEGIN:E++,BEGIN_WHITESPACE:E++,TEXT:E++,TEXT_ENTITY:E++,OPEN_WAKA:E++,SGML_DECL:E++,SGML_DECL_QUOTED:E++,DOCTYPE:E++,DOCTYPE_QUOTED:E++,DOCTYPE_DTD:E++,DOCTYPE_DTD_QUOTED:E++,COMMENT_STARTING:E++,COMMENT:E++,COMMENT_ENDING:E++,COMMENT_ENDED:E++,CDATA:E++,CDATA_ENDING:E++,CDATA_ENDING_2:E++,PROC_INST:E++,PROC_INST_BODY:E++,PROC_INST_ENDING:E++,OPEN_TAG:E++,OPEN_TAG_SLASH:E++,ATTRIB:E++,ATTRIB_NAME:E++,ATTRIB_NAME_SAW_WHITE:E++,ATTRIB_VALUE:E++,ATTRIB_VALUE_QUOTED:E++,ATTRIB_VALUE_CLOSED:E++,ATTRIB_VALUE_UNQUOTED:E++,ATTRIB_VALUE_ENTITY_Q:E++,ATTRIB_VALUE_ENTITY_U:E++,CLOSE_TAG:E++,CLOSE_TAG_SAW_WHITE:E++,SCRIPT:E++,SCRIPT_ENDING:E++},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(q){var L=e.ENTITIES[q],Z=typeof L=="number"?String.fromCharCode(L):L;e.ENTITIES[q]=Z});for(var O in e.STATE)e.STATE[e.STATE[O]]=O;E=e.STATE;function $(q,L,Z){q[L]&&q[L](Z)}function T(q,L,Z){q.textNode&&M(q),$(q,L,Z)}function M(q){q.textNode=k(q.opt,q.textNode),q.textNode&&$(q,"ontext",q.textNode),q.textNode=""}function k(q,L){return q.trim&&(L=L.trim()),q.normalize&&(L=L.replace(/\s+/g," ")),L}function D(q,L){return M(q),q.trackPosition&&(L+=`
Line: `+q.line+`
Column: `+q.column+`
Char: `+q.c),L=new Error(L),q.error=L,$(q,"onerror",L),q}function K(q){return q.sawRoot&&!q.closedRoot&&H(q,"Unclosed root tag"),q.state!==E.BEGIN&&q.state!==E.BEGIN_WHITESPACE&&q.state!==E.TEXT&&D(q,"Unexpected end"),M(q),q.c="",q.closed=!0,$(q,"onend"),n.call(q,q.strict,q.opt),q}function H(q,L){if(typeof q!="object"||!(q instanceof n))throw new Error("bad call to strictFail");q.strict&&D(q,L)}function ee(q){q.strict||(q.tagName=q.tagName[q.looseCase]());var L=q.tags[q.tags.length-1]||q,Z=q.tag={name:q.tagName,attributes:{}};q.opt.xmlns&&(Z.ns=L.ns),q.attribList.length=0,T(q,"onopentagstart",Z)}function V(q,L){var Z=q.indexOf(":"),J=Z<0?["",q]:q.split(":"),W=J[0],X=J[1];return L&&q==="xmlns"&&(W="xmlns",X=""),{prefix:W,local:X}}function B(q){if(q.strict||(q.attribName=q.attribName[q.looseCase]()),q.attribList.indexOf(q.attribName)!==-1||q.tag.attributes.hasOwnProperty(q.attribName)){q.attribName=q.attribValue="";return}if(q.opt.xmlns){var L=V(q.attribName,!0),Z=L.prefix,J=L.local;if(Z==="xmlns")if(J==="xml"&&q.attribValue!==p)H(q,"xml: prefix must be bound to "+p+`
Actual: `+q.attribValue);else if(J==="xmlns"&&q.attribValue!==m)H(q,"xmlns: prefix must be bound to "+m+`
Actual: `+q.attribValue);else{var W=q.tag,X=q.tags[q.tags.length-1]||q;W.ns===X.ns&&(W.ns=Object.create(X.ns)),W.ns[J]=q.attribValue}q.attribList.push([q.attribName,q.attribValue])}else q.tag.attributes[q.attribName]=q.attribValue,T(q,"onattribute",{name:q.attribName,value:q.attribValue});q.attribName=q.attribValue=""}function z(q,L){if(q.opt.xmlns){var Z=q.tag,J=V(q.tagName);Z.prefix=J.prefix,Z.local=J.local,Z.uri=Z.ns[J.prefix]||"",Z.prefix&&!Z.uri&&(H(q,"Unbound namespace prefix: "+JSON.stringify(q.tagName)),Z.uri=J.prefix);var W=q.tags[q.tags.length-1]||q;Z.ns&&W.ns!==Z.ns&&Object.keys(Z.ns).forEach(function(ae){T(q,"onopennamespace",{prefix:ae,uri:Z.ns[ae]})});for(var X=0,he=q.attribList.length;X<he;X++){var P=q.attribList[X],oe=P[0],Y=P[1],R=V(oe,!0),I=R.prefix,U=R.local,re=I===""?"":Z.ns[I]||"",ue={name:oe,value:Y,prefix:I,local:U,uri:re};I&&I!=="xmlns"&&!re&&(H(q,"Unbound namespace prefix: "+JSON.stringify(I)),ue.uri=I),q.tag.attributes[oe]=ue,T(q,"onattribute",ue)}q.attribList.length=0}q.tag.isSelfClosing=!!L,q.sawRoot=!0,q.tags.push(q.tag),T(q,"onopentag",q.tag),L||(!q.noscript&&q.tagName.toLowerCase()==="script"?q.state=E.SCRIPT:q.state=E.TEXT,q.tag=null,q.tagName=""),q.attribName=q.attribValue="",q.attribList.length=0}function F(q){if(!q.tagName){H(q,"Weird empty close tag."),q.textNode+="</>",q.state=E.TEXT;return}if(q.script){if(q.tagName!=="script"){q.script+="</"+q.tagName+">",q.tagName="",q.state=E.SCRIPT;return}T(q,"onscript",q.script),q.script=""}var L=q.tags.length,Z=q.tagName;q.strict||(Z=Z[q.looseCase]());for(var J=Z;L--;){var W=q.tags[L];if(W.name!==J)H(q,"Unexpected close tag");else break}if(L<0){H(q,"Unmatched closing tag: "+q.tagName),q.textNode+="</"+q.tagName+">",q.state=E.TEXT;return}q.tagName=Z;for(var X=q.tags.length;X-- >L;){var he=q.tag=q.tags.pop();q.tagName=q.tag.name,T(q,"onclosetag",q.tagName);var P={};for(var oe in he.ns)P[oe]=he.ns[oe];var Y=q.tags[q.tags.length-1]||q;q.opt.xmlns&&he.ns!==Y.ns&&Object.keys(he.ns).forEach(function(R){var I=he.ns[R];T(q,"onclosenamespace",{prefix:R,uri:I})})}L===0&&(q.closedRoot=!0),q.tagName=q.attribValue=q.attribName="",q.attribList.length=0,q.state=E.TEXT}function G(q){var L=q.entity,Z=L.toLowerCase(),J,W="";return q.ENTITIES[L]?q.ENTITIES[L]:q.ENTITIES[Z]?q.ENTITIES[Z]:(L=Z,L.charAt(0)==="#"&&(L.charAt(1)==="x"?(L=L.slice(2),J=parseInt(L,16),W=J.toString(16)):(L=L.slice(1),J=parseInt(L,10),W=J.toString(10))),L=L.replace(/^0+/,""),isNaN(J)||W.toLowerCase()!==L?(H(q,"Invalid character entity"),"&"+q.entity+";"):String.fromCodePoint(J))}function Q(q,L){L==="<"?(q.state=E.OPEN_WAKA,q.startTagPosition=q.position):w(L)||(H(q,"Non-whitespace before first tag."),q.textNode=L,q.state=E.TEXT)}function ie(q,L){var Z="";return L<q.length&&(Z=q.charAt(L)),Z}function se(q){var L=this;if(this.error)throw this.error;if(L.closed)return D(L,"Cannot write after close. Assign an onready handler.");if(q===null)return K(L);typeof q=="object"&&(q=q.toString());for(var Z=0,J="";J=ie(q,Z++),L.c=J,!!J;)switch(L.trackPosition&&(L.position++,J===`
`?(L.line++,L.column=0):L.column++),L.state){case E.BEGIN:if(L.state=E.BEGIN_WHITESPACE,J==="\uFEFF")continue;Q(L,J);continue;case E.BEGIN_WHITESPACE:Q(L,J);continue;case E.TEXT:if(L.sawRoot&&!L.closedRoot){for(var W=Z-1;J&&J!=="<"&&J!=="&";)J=ie(q,Z++),J&&L.trackPosition&&(L.position++,J===`
`?(L.line++,L.column=0):L.column++);L.textNode+=q.substring(W,Z-1)}J==="<"&&!(L.sawRoot&&L.closedRoot&&!L.strict)?(L.state=E.OPEN_WAKA,L.startTagPosition=L.position):(!w(J)&&(!L.sawRoot||L.closedRoot)&&H(L,"Text data outside of root node."),J==="&"?L.state=E.TEXT_ENTITY:L.textNode+=J);continue;case E.SCRIPT:J==="<"?L.state=E.SCRIPT_ENDING:L.script+=J;continue;case E.SCRIPT_ENDING:J==="/"?L.state=E.CLOSE_TAG:(L.script+="<"+J,L.state=E.SCRIPT);continue;case E.OPEN_WAKA:if(J==="!")L.state=E.SGML_DECL,L.sgmlDecl="";else if(!w(J))if(C(y,J))L.state=E.OPEN_TAG,L.tagName=J;else if(J==="/")L.state=E.CLOSE_TAG,L.tagName="";else if(J==="?")L.state=E.PROC_INST,L.procInstName=L.procInstBody="";else{if(H(L,"Unencoded <"),L.startTagPosition+1<L.position){var X=L.position-L.startTagPosition;J=new Array(X).join(" ")+J}L.textNode+="<"+J,L.state=E.TEXT}continue;case E.SGML_DECL:(L.sgmlDecl+J).toUpperCase()===h?(T(L,"onopencdata"),L.state=E.CDATA,L.sgmlDecl="",L.cdata=""):L.sgmlDecl+J==="--"?(L.state=E.COMMENT,L.comment="",L.sgmlDecl=""):(L.sgmlDecl+J).toUpperCase()===f?(L.state=E.DOCTYPE,(L.doctype||L.sawRoot)&&H(L,"Inappropriately located doctype declaration"),L.doctype="",L.sgmlDecl=""):J===">"?(T(L,"onsgmldeclaration",L.sgmlDecl),L.sgmlDecl="",L.state=E.TEXT):(j(J)&&(L.state=E.SGML_DECL_QUOTED),L.sgmlDecl+=J);continue;case E.SGML_DECL_QUOTED:J===L.q&&(L.state=E.SGML_DECL,L.q=""),L.sgmlDecl+=J;continue;case E.DOCTYPE:J===">"?(L.state=E.TEXT,T(L,"ondoctype",L.doctype),L.doctype=!0):(L.doctype+=J,J==="["?L.state=E.DOCTYPE_DTD:j(J)&&(L.state=E.DOCTYPE_QUOTED,L.q=J));continue;case E.DOCTYPE_QUOTED:L.doctype+=J,J===L.q&&(L.q="",L.state=E.DOCTYPE);continue;case E.DOCTYPE_DTD:L.doctype+=J,J==="]"?L.state=E.DOCTYPE:j(J)&&(L.state=E.DOCTYPE_DTD_QUOTED,L.q=J);continue;case E.DOCTYPE_DTD_QUOTED:L.doctype+=J,J===L.q&&(L.state=E.DOCTYPE_DTD,L.q="");continue;case E.COMMENT:J==="-"?L.state=E.COMMENT_ENDING:L.comment+=J;continue;case E.COMMENT_ENDING:J==="-"?(L.state=E.COMMENT_ENDED,L.comment=k(L.opt,L.comment),L.comment&&T(L,"oncomment",L.comment),L.comment=""):(L.comment+="-"+J,L.state=E.COMMENT);continue;case E.COMMENT_ENDED:J!==">"?(H(L,"Malformed comment"),L.comment+="--"+J,L.state=E.COMMENT):L.state=E.TEXT;continue;case E.CDATA:J==="]"?L.state=E.CDATA_ENDING:L.cdata+=J;continue;case E.CDATA_ENDING:J==="]"?L.state=E.CDATA_ENDING_2:(L.cdata+="]"+J,L.state=E.CDATA);continue;case E.CDATA_ENDING_2:J===">"?(L.cdata&&T(L,"oncdata",L.cdata),T(L,"onclosecdata"),L.cdata="",L.state=E.TEXT):J==="]"?L.cdata+="]":(L.cdata+="]]"+J,L.state=E.CDATA);continue;case E.PROC_INST:J==="?"?L.state=E.PROC_INST_ENDING:w(J)?L.state=E.PROC_INST_BODY:L.procInstName+=J;continue;case E.PROC_INST_BODY:if(!L.procInstBody&&w(J))continue;J==="?"?L.state=E.PROC_INST_ENDING:L.procInstBody+=J;continue;case E.PROC_INST_ENDING:J===">"?(T(L,"onprocessinginstruction",{name:L.procInstName,body:L.procInstBody}),L.procInstName=L.procInstBody="",L.state=E.TEXT):(L.procInstBody+="?"+J,L.state=E.PROC_INST_BODY);continue;case E.OPEN_TAG:C(x,J)?L.tagName+=J:(ee(L),J===">"?z(L):J==="/"?L.state=E.OPEN_TAG_SLASH:(w(J)||H(L,"Invalid character in tag name"),L.state=E.ATTRIB));continue;case E.OPEN_TAG_SLASH:J===">"?(z(L,!0),F(L)):(H(L,"Forward-slash in opening tag not followed by >"),L.state=E.ATTRIB);continue;case E.ATTRIB:if(w(J))continue;J===">"?z(L):J==="/"?L.state=E.OPEN_TAG_SLASH:C(y,J)?(L.attribName=J,L.attribValue="",L.state=E.ATTRIB_NAME):H(L,"Invalid attribute name");continue;case E.ATTRIB_NAME:J==="="?L.state=E.ATTRIB_VALUE:J===">"?(H(L,"Attribute without value"),L.attribValue=L.attribName,B(L),z(L)):w(J)?L.state=E.ATTRIB_NAME_SAW_WHITE:C(x,J)?L.attribName+=J:H(L,"Invalid attribute name");continue;case E.ATTRIB_NAME_SAW_WHITE:if(J==="=")L.state=E.ATTRIB_VALUE;else{if(w(J))continue;H(L,"Attribute without value"),L.tag.attributes[L.attribName]="",L.attribValue="",T(L,"onattribute",{name:L.attribName,value:""}),L.attribName="",J===">"?z(L):C(y,J)?(L.attribName=J,L.state=E.ATTRIB_NAME):(H(L,"Invalid attribute name"),L.state=E.ATTRIB)}continue;case E.ATTRIB_VALUE:if(w(J))continue;j(J)?(L.q=J,L.state=E.ATTRIB_VALUE_QUOTED):(H(L,"Unquoted attribute value"),L.state=E.ATTRIB_VALUE_UNQUOTED,L.attribValue=J);continue;case E.ATTRIB_VALUE_QUOTED:if(J!==L.q){J==="&"?L.state=E.ATTRIB_VALUE_ENTITY_Q:L.attribValue+=J;continue}B(L),L.q="",L.state=E.ATTRIB_VALUE_CLOSED;continue;case E.ATTRIB_VALUE_CLOSED:w(J)?L.state=E.ATTRIB:J===">"?z(L):J==="/"?L.state=E.OPEN_TAG_SLASH:C(y,J)?(H(L,"No whitespace between attributes"),L.attribName=J,L.attribValue="",L.state=E.ATTRIB_NAME):H(L,"Invalid attribute name");continue;case E.ATTRIB_VALUE_UNQUOTED:if(!N(J)){J==="&"?L.state=E.ATTRIB_VALUE_ENTITY_U:L.attribValue+=J;continue}B(L),J===">"?z(L):L.state=E.ATTRIB;continue;case E.CLOSE_TAG:if(L.tagName)J===">"?F(L):C(x,J)?L.tagName+=J:L.script?(L.script+="</"+L.tagName,L.tagName="",L.state=E.SCRIPT):(w(J)||H(L,"Invalid tagname in closing tag"),L.state=E.CLOSE_TAG_SAW_WHITE);else{if(w(J))continue;A(y,J)?L.script?(L.script+="</"+J,L.state=E.SCRIPT):H(L,"Invalid tagname in closing tag."):L.tagName=J}continue;case E.CLOSE_TAG_SAW_WHITE:if(w(J))continue;J===">"?F(L):H(L,"Invalid characters in closing tag");continue;case E.TEXT_ENTITY:case E.ATTRIB_VALUE_ENTITY_Q:case E.ATTRIB_VALUE_ENTITY_U:var he,P;switch(L.state){case E.TEXT_ENTITY:he=E.TEXT,P="textNode";break;case E.ATTRIB_VALUE_ENTITY_Q:he=E.ATTRIB_VALUE_QUOTED,P="attribValue";break;case E.ATTRIB_VALUE_ENTITY_U:he=E.ATTRIB_VALUE_UNQUOTED,P="attribValue";break}J===";"?(L[P]+=G(L),L.entity="",L.state=he):C(L.entity.length?b:v,J)?L.entity+=J:(H(L,"Invalid character in entity name"),L[P]+="&"+L.entity+J,L.entity="",L.state=he);continue;default:throw new Error(L,"Unknown state: "+L.state)}return L.position>=L.bufferCheckPosition&&s(L),L}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var q=String.fromCharCode,L=Math.floor,Z=function(){var J=16384,W=[],X,he,P=-1,oe=arguments.length;if(!oe)return"";for(var Y="";++P<oe;){var R=Number(arguments[P]);if(!isFinite(R)||R<0||R>1114111||L(R)!==R)throw RangeError("Invalid code point: "+R);R<=65535?W.push(R):(R-=65536,X=(R>>10)+55296,he=R%1024+56320,W.push(X,he)),(P+1===oe||W.length>J)&&(Y+=q.apply(null,W),W.length=0)}return Y};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:Z,configurable:!0,writable:!0}):String.fromCodePoint=Z}()})(t)}(Z3)),Z3}var pF,dae;function RG(){return dae||(dae=1,pF={isArray:function(t){return Array.isArray?Array.isArray(t):Object.prototype.toString.call(t)==="[object Array]"}}),pF}var mF,hae;function OG(){if(hae)return mF;hae=1;var t=RG().isArray;return mF={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}},mF}var gF,fae;function oke(){if(fae)return gF;fae=1;var t=X2t(),e=OG(),r=RG().isArray,n,s;function i(x){return n=e.copyOptions(x),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(x){var v=Number(x);if(!isNaN(v))return v;var b=x.toLowerCase();return b==="true"?!0:b==="false"?!1:x}function l(x,v){var b;if(n.compact){if(!s[n[x+"Key"]]&&(r(n.alwaysArray)?n.alwaysArray.indexOf(n[x+"Key"])!==-1:n.alwaysArray)&&(s[n[x+"Key"]]=[]),s[n[x+"Key"]]&&!r(s[n[x+"Key"]])&&(s[n[x+"Key"]]=[s[n[x+"Key"]]]),x+"Fn"in n&&typeof v=="string"&&(v=n[x+"Fn"](v,s)),x==="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[x+"Key"]])?s[n[x+"Key"]].push(v):s[n[x+"Key"]]=v}else{s[n.elementsKey]||(s[n.elementsKey]=[]);var j={};if(j[n.typeKey]=x,x==="instruction"){for(b in v)if(v.hasOwnProperty(b))break;j[n.nameKey]="instructionNameFn"in n?n.instructionNameFn(b,v,s):b,n.instructionHasAttributes?(j[n.attributesKey]=v[b][n.attributesKey],"instructionFn"in n&&(j[n.attributesKey]=n.instructionFn(j[n.attributesKey],b,s))):("instructionFn"in n&&(v[b]=n.instructionFn(v[b],b,s)),j[n.instructionKey]=v[b])}else x+"Fn"in n&&(v=n[x+"Fn"](v,s)),j[n[x+"Key"]]=v;n.addParent&&(j[n.parentKey]=s),s[n.elementsKey].push(j)}}function c(x){if("attributesFn"in n&&x&&(x=n.attributesFn(x,s)),(n.trim||"attributeValueFn"in n||"attributeNameFn"in n||n.nativeTypeAttributes)&&x){var v;for(v in x)if(x.hasOwnProperty(v)&&(n.trim&&(x[v]=x[v].trim()),n.nativeTypeAttributes&&(x[v]=a(x[v])),"attributeValueFn"in n&&(x[v]=n.attributeValueFn(x[v],v,s)),"attributeNameFn"in n)){var b=x[v];delete x[v],x[n.attributeNameFn(v,x[v],s)]=b}}return x}function u(x){var v={};if(x.body&&(x.name.toLowerCase()==="xml"||n.instructionHasAttributes)){for(var b=/([\w:-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\w+))\s*/g,w;(w=b.exec(x.body))!==null;)v[w[1]]=w[2]||w[3]||w[4];v=c(v)}if(x.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&&(x.body=x.body.trim());var j={};n.instructionHasAttributes&&Object.keys(v).length?(j[x.name]={},j[x.name][n.attributesKey]=v):j[x.name]=x.body,l("instruction",j)}}function d(x,v){var b;if(typeof x=="object"&&(v=x.attributes,x=x.name),v=c(v),"elementNameFn"in n&&(x=n.elementNameFn(x,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])}!(x in s)&&(r(n.alwaysArray)?n.alwaysArray.indexOf(x)!==-1:n.alwaysArray)&&(s[x]=[]),s[x]&&!r(s[x])&&(s[x]=[s[x]]),r(s[x])?s[x].push(b):s[x]=b}else s[n.elementsKey]||(s[n.elementsKey]=[]),b={},b[n.typeKey]="element",b[n.nameKey]=x,!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(x){n.ignoreText||!x.trim()&&!n.captureSpacesBetweenElements||(n.trim&&(x=x.trim()),n.nativeType&&(x=a(x)),n.sanitize&&(x=x.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")),l("text",x))}function f(x){n.ignoreComment||(n.trim&&(x=x.trim()),l("comment",x))}function p(x){var v=s[n.parentKey];n.addParent||delete s[n.parentKey],s=v}function m(x){n.ignoreCdata||(n.trim&&(x=x.trim()),l("cdata",x))}function g(x){n.ignoreDoctype||(x=x.replace(/^ /,""),n.trim&&(x=x.trim()),l("doctype",x))}function y(x){x.note=x}return gF=function(x,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=y,b.oncdata=m,b.ondoctype=g,b.onprocessinginstruction=u,b.write(x).close(),w[n.elementsKey]){var j=w[n.elementsKey];delete w[n.elementsKey],w[n.elementsKey]=j,delete w.text}return w},gF}var xF,pae;function Q2t(){if(pae)return xF;pae=1;var t=OG(),e=oke();function r(n){var s=t.copyOptions(n);return t.ensureSpacesExists(s),s}return xF=function(n,s){var i,a,l,c;return i=r(s),a=e(n,i),c="compact"in i&&i.compact?"_parent":"parent","addParent"in i&&i.addParent?l=JSON.stringify(a,function(u,d){return u===c?"_":d},i.spaces):l=JSON.stringify(a,null,i.spaces),l.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")},xF}var yF,mae;function lke(){if(mae)return yF;mae=1;var t=OG(),e=RG().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,j){return(!j&&b.spaces?`
`:"")+Array(w+1).join(b.spaces)}function a(b,w,j){if(w.ignoreAttributes)return"";"attributesFn"in w&&(b=w.attributesFn(b,n,r));var N,C,A,E,O=[];for(N in b)b.hasOwnProperty(N)&&b[N]!==null&&b[N]!==void 0&&(E=w.noQuotesForNativeAttributes&&typeof b[N]!="string"?"":'"',C=""+b[N],C=C.replace(/"/g,"&quot;"),A="attributeNameFn"in w?w.attributeNameFn(N,C,n,r):N,O.push(w.spaces&&w.indentAttributes?i(w,j+1,!1):" "),O.push(A+"="+E+("attributeValueFn"in w?w.attributeValueFn(C,N,n,r):C)+E));return b&&Object.keys(b).length&&w.spaces&&w.indentAttributes&&O.push(i(w,j,!1)),O.join("")}function l(b,w,j){return r=b,n="xml",w.ignoreDeclaration?"":"<?xml"+a(b[w.attributesKey],w,j)+"?>"}function c(b,w,j){if(w.ignoreInstruction)return"";var N;for(N in b)if(b.hasOwnProperty(N))break;var C="instructionNameFn"in w?w.instructionNameFn(N,b[N],n,r):N;if(typeof b[N]=="object")return r=b,n=C,"<?"+C+a(b[N][w.attributesKey],w,j)+"?>";var A=b[N]?b[N]:"";return"instructionFn"in w&&(A=w.instructionFn(A,N,n,r)),"<?"+C+(A?" "+A:"")+"?>"}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(/&amp;/g,"&"),b=b.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"textFn"in w?w.textFn(b,n,r):b)}function p(b,w){var j;if(b.elements&&b.elements.length)for(j=0;j<b.elements.length;++j)switch(b.elements[j][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,j){r=b,n=b.name;var N=[],C="elementNameFn"in w?w.elementNameFn(b.name,b):b.name;N.push("<"+C),b[w.attributesKey]&&N.push(a(b[w.attributesKey],w,j));var A=b[w.elementsKey]&&b[w.elementsKey].length||b[w.attributesKey]&&b[w.attributesKey]["xml:space"]==="preserve";return A||("fullTagEmptyElementFn"in w?A=w.fullTagEmptyElementFn(b.name,b):A=w.fullTagEmptyElement),A?(N.push(">"),b[w.elementsKey]&&b[w.elementsKey].length&&(N.push(g(b[w.elementsKey],w,j+1)),r=b,n=b.name),N.push(w.spaces&&p(b,w)?`
`+Array(j+1).join(w.spaces):""),N.push("</"+C+">")):N.push("/>"),N.join("")}function g(b,w,j,N){return b.reduce(function(C,A){var E=i(w,j,N&&!C);switch(A.type){case"element":return C+E+m(A,w,j);case"comment":return C+E+u(A[w.commentKey],w);case"doctype":return C+E+h(A[w.doctypeKey],w);case"cdata":return C+(w.indentCdata?E:"")+d(A[w.cdataKey],w);case"text":return C+(w.indentText?E:"")+f(A[w.textKey],w);case"instruction":var O={};return O[A[w.nameKey]]=A[w.attributesKey]?A:A[w.instructionKey],C+(w.indentInstruction?E:"")+c(O,w,j)}},"")}function y(b,w,j){var N;for(N in b)if(b.hasOwnProperty(N))switch(N){case w.parentKey:case w.attributesKey:break;case w.textKey:if(w.indentText||j)return!0;break;case w.cdataKey:if(w.indentCdata||j)return!0;break;case w.instructionKey:if(w.indentInstruction||j)return!0;break;case w.doctypeKey:case w.commentKey:return!0;default:return!0}return!1}function x(b,w,j,N,C){r=b,n=w;var A="elementNameFn"in j?j.elementNameFn(w,b):w;if(typeof b>"u"||b===null||b==="")return"fullTagEmptyElementFn"in j&&j.fullTagEmptyElementFn(w,b)||j.fullTagEmptyElement?"<"+A+"></"+A+">":"<"+A+"/>";var E=[];if(w){if(E.push("<"+A),typeof b!="object")return E.push(">"+f(b,j)+"</"+A+">"),E.join("");b[j.attributesKey]&&E.push(a(b[j.attributesKey],j,N));var O=y(b,j,!0)||b[j.attributesKey]&&b[j.attributesKey]["xml:space"]==="preserve";if(O||("fullTagEmptyElementFn"in j?O=j.fullTagEmptyElementFn(w,b):O=j.fullTagEmptyElement),O)E.push(">");else return E.push("/>"),E.join("")}return E.push(v(b,j,N+1,!1)),r=b,n=w,w&&E.push((C?i(j,N,!1):"")+"</"+A+">"),E.join("")}function v(b,w,j,N){var C,A,E,O=[];for(A in b)if(b.hasOwnProperty(A))for(E=e(b[A])?b[A]:[b[A]],C=0;C<E.length;++C){switch(A){case w.declarationKey:O.push(l(E[C],w,j));break;case w.instructionKey:O.push((w.indentInstruction?i(w,j,N):"")+c(E[C],w,j));break;case w.attributesKey:case w.parentKey:break;case w.textKey:O.push((w.indentText?i(w,j,N):"")+f(E[C],w));break;case w.cdataKey:O.push((w.indentCdata?i(w,j,N):"")+d(E[C],w));break;case w.doctypeKey:O.push(i(w,j,N)+h(E[C],w));break;case w.commentKey:O.push(i(w,j,N)+u(E[C],w));break;default:O.push(i(w,j,N)+x(E[C],A,w,j,y(E[C],w)))}N=N&&!O.length}return O.join("")}return yF=function(b,w){w=s(w);var j=[];return r=b,n="_root_",w.compact?j.push(v(b,w,0,!0)):(b[w.declarationKey]&&j.push(l(b[w.declarationKey],w,0)),b[w.elementsKey]&&b[w.elementsKey].length&&j.push(g(b[w.elementsKey],w,0,!j.length))),j.join("")},yF}var vF,gae;function Z2t(){if(gae)return vF;gae=1;var t=lke();return vF=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)},vF}var bF,xae;function J2t(){if(xae)return bF;xae=1;var t=oke(),e=Q2t(),r=lke(),n=Z2t();return bF={xml2js:t,xml2json:e,js2xml:r,json2xml:n},bF}var cke=J2t();const MG=t=>{switch(t.type){case void 0:case"element":const e=new tPt(t.name,t.attributes),r=t.elements||[];for(const n of r){const s=MG(n);s!==void 0&&e.push(s)}return e;case"text":return t.text;default:return}};class ePt extends bt{}class tPt extends Ae{static fromXmlString(e){const r=cke.xml2js(e,{compact:!1});return MG(r)}constructor(e,r){super(e),r&&this.root.push(new ePt(r))}push(e){this.root.push(e)}}class rPt extends Ae{constructor(e){super(""),this._attr=e}prepForXml(e){return{_attr:this._attr}}}class uke extends Ae{constructor(e,r){super(e),r&&(this.root=r.root)}}const Ca=t=>{if(isNaN(t))throw new Error(`Invalid value '${t}' specified. Must be an integer.`);return Math.floor(t)},e5=t=>{const e=Ca(t);if(e<0)throw new Error(`Invalid value '${t}' specified. Must be a positive integer.`);return e},dke=(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},yae=t=>dke(t,1),DG=t=>{const e=t.slice(-2),r=t.substring(0,t.length-2);return`${Number(r)}${e}`},hke=t=>{const e=DG(t);if(parseFloat(e)<0)throw new Error(`Invalid value '${e}' specified. Expected a positive number.`);return e},F1=t=>{if(t==="auto")return t;const e=t.charAt(0)==="#"?t.substring(1):t;return dke(e,3)},zh=t=>typeof t=="string"?DG(t):Ca(t),nPt=t=>typeof t=="string"?hke(t):e5(t),ta=t=>typeof t=="string"?hke(t):e5(t),sPt=t=>{const e=t.substring(0,t.length-1);return`${Number(e)}%`},fke=t=>typeof t=="number"?Ca(t):t.slice(-1)==="%"?sPt(t):DG(t),iPt=e5,aPt=e5,oPt=t=>t.toISOString();class We extends Ae{constructor(e,r=!0){super(e),r!==!0&&this.root.push(new is({val:r}))}}class wF extends Ae{constructor(e,r){super(e),this.root.push(new is({val:nPt(r)}))}}class Im extends Ae{constructor(e,r){super(e),this.root.push(new is({val:r}))}}const vS=(t,e)=>new nn({name:t,attributes:{value:{key:"w:val",value:e}}});class q_ extends Ae{constructor(e,r){super(e),this.root.push(new is({val:r}))}}class lPt extends Ae{constructor(e,r){super(e),this.root.push(new is({val:r}))}}class Ig extends Ae{constructor(e,r){super(e),this.root.push(r)}}class nn extends Ae{constructor({name:e,attributes:r,children:n}){super(e),r&&this.root.push(new Of(r)),n&&this.root.push(...n)}}const Vn={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 cPt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val"})}}class pke extends Ae{constructor(e){super("w:jc"),this.root.push(new cPt({val:e}))}}class cn extends Ae{constructor(e,{color:r,size:n,space:s,style:i}){super(e),this.root.push(new uPt({style:i,color:r===void 0?void 0:F1(r),size:n===void 0?void 0:iPt(n),space:s===void 0?void 0:aPt(s)}))}}class uPt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{style:"w:val",color:"w:color",size:"w:sz",space:"w:space"})}}const Uh={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 dPt extends Rf{constructor(e){super("w:pBdr"),e.top&&this.root.push(new cn("w:top",e.top)),e.bottom&&this.root.push(new cn("w:bottom",e.bottom)),e.left&&this.root.push(new cn("w:left",e.left)),e.right&&this.root.push(new cn("w:right",e.right))}}class hPt extends Ae{constructor(){super("w:pBdr");const e=new cn("w:bottom",{color:"auto",space:1,style:Uh.SINGLE,size:6});this.root.push(e)}}class fPt extends Ae{constructor({start:e,end:r,left:n,right:s,hanging:i,firstLine:a}){super("w:ind"),this.root.push(new Of({start:{key:"w:start",value:e===void 0?void 0:zh(e)},end:{key:"w:end",value:r===void 0?void 0:zh(r)},left:{key:"w:left",value:n===void 0?void 0:zh(n)},right:{key:"w:right",value:s===void 0?void 0:zh(s)},hanging:{key:"w:hanging",value:i===void 0?void 0:ta(i)},firstLine:{key:"w:firstLine",value:a===void 0?void 0:ta(a)}}))}}let pPt=class extends Ae{constructor(){super("w:br")}};const LG={BEGIN:"begin",END:"end",SEPARATE:"separate"};class $G extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{type:"w:fldCharType",dirty:"w:dirty"})}}class d_ extends Ae{constructor(e){super("w:fldChar"),this.root.push(new $G({type:LG.BEGIN,dirty:e}))}}class h_ extends Ae{constructor(e){super("w:fldChar"),this.root.push(new $G({type:LG.SEPARATE,dirty:e}))}}class f_ extends Ae{constructor(e){super("w:fldChar"),this.root.push(new $G({type:LG.END,dirty:e}))}}const mPt={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"},xv={DEFAULT:"default",PRESERVE:"preserve"};class yv extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{space:"xml:space"})}}class gPt extends Ae{constructor(){super("w:instrText"),this.root.push(new yv({space:xv.PRESERVE})),this.root.push("PAGE")}}class xPt extends Ae{constructor(){super("w:instrText"),this.root.push(new yv({space:xv.PRESERVE})),this.root.push("NUMPAGES")}}class yPt extends Ae{constructor(){super("w:instrText"),this.root.push(new yv({space:xv.PRESERVE})),this.root.push("SECTIONPAGES")}}class vPt extends Ae{constructor(){super("w:instrText"),this.root.push(new yv({space:xv.PRESERVE})),this.root.push("SECTION")}}class bPt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{fill:"w:fill",color:"w:color",type:"w:val"})}}class t5 extends Ae{constructor({fill:e,color:r,type:n}){super("w:shd"),this.root.push(new bPt({fill:e===void 0?void 0:F1(e),color:r===void 0?void 0:F1(r),type:n}))}}const mke={CLEAR:"clear",DIAGONAL_CROSS:"diagCross",DIAGONAL_STRIPE:"diagStripe",HORIZONTAL_CROSS:"horzCross",HORIZONTAL_STRIPE:"horzStripe",NIL:"nil",PERCENT_5:"pct5",PERCENT_10:"pct10",PERCENT_12:"pct12",PERCENT_15:"pct15",PERCENT_20:"pct20",PERCENT_25:"pct25",PERCENT_30:"pct30",PERCENT_35:"pct35",PERCENT_37:"pct37",PERCENT_40:"pct40",PERCENT_45:"pct45",PERCENT_50:"pct50",PERCENT_55:"pct55",PERCENT_60:"pct60",PERCENT_62:"pct62",PERCENT_65:"pct65",PERCENT_70:"pct70",PERCENT_75:"pct75",PERCENT_80:"pct80",PERCENT_85:"pct85",PERCENT_87:"pct87",PERCENT_90:"pct90",PERCENT_95:"pct95",REVERSE_DIAGONAL_STRIPE:"reverseDiagStripe",SOLID:"solid",THIN_DIAGONAL_CROSS:"thinDiagCross",THIN_DIAGONAL_STRIPE:"thinDiagStripe",THIN_HORIZONTAL_CROSS:"thinHorzCross",THIN_REVERSE_DIAGONAL_STRIPE:"thinReverseDiagStripe",THIN_VERTICAL_STRIPE:"thinVertStripe",VERTICAL_STRIPE:"vertStripe"};class wPt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{id:"w:id",author:"w:author",date:"w:date"})}}const jPt={DOT:"dot"};class SPt extends Ae{constructor(e){super("w:em"),this.root.push(new is({val:e}))}}class _Pt extends SPt{constructor(e=jPt.DOT){super(e)}}class NPt extends Ae{constructor(e){super("w:spacing"),this.root.push(new is({val:zh(e)}))}}class kPt extends Ae{constructor(e){super("w:color"),this.root.push(new is({val:F1(e)}))}}class CPt extends Ae{constructor(e){super("w:highlight"),this.root.push(new is({val:e}))}}class EPt extends Ae{constructor(e){super("w:highlightCs"),this.root.push(new is({val:e}))}}const APt=t=>new nn({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 vae extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{ascii:"w:ascii",cs:"w:cs",eastAsia:"w:eastAsia",hAnsi:"w:hAnsi",hint:"w:hint"})}}class jF extends Ae{constructor(e,r){if(super("w:rFonts"),typeof e=="string"){const n=e;this.root.push(new vae({ascii:n,cs:n,eastAsia:n,hAnsi:n,hint:r}))}else{const n=e;this.root.push(new vae(n))}}}let gke=class extends Ae{constructor(e){super("w:vertAlign"),this.root.push(new is({val:e}))}};class TPt extends gke{constructor(){super("superscript")}}class PPt extends gke{constructor(){super("subscript")}}const xke={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 IPt=class extends Ae{constructor(e=xke.SINGLE,r){super("w:u"),this.root.push(new is({val:e,color:r===void 0?void 0:F1(r)}))}};class Bv extends Rf{constructor(e){var r,n;if(super("w:rPr"),!e)return;e.style&&this.push(new Im("w:rStyle",e.style)),e.font&&(typeof e.font=="string"?this.push(new jF(e.font)):"name"in e.font?this.push(new jF(e.font.name,e.font.hint)):this.push(new jF(e.font))),e.bold!==void 0&&this.push(new We("w:b",e.bold)),(e.boldComplexScript===void 0&&e.bold!==void 0||e.boldComplexScript)&&this.push(new We("w:bCs",(r=e.boldComplexScript)!=null?r:e.bold)),e.italics!==void 0&&this.push(new We("w:i",e.italics)),(e.italicsComplexScript===void 0&&e.italics!==void 0||e.italicsComplexScript)&&this.push(new We("w:iCs",(n=e.italicsComplexScript)!=null?n:e.italics)),e.smallCaps!==void 0?this.push(new We("w:smallCaps",e.smallCaps)):e.allCaps!==void 0&&this.push(new We("w:caps",e.allCaps)),e.strike!==void 0&&this.push(new We("w:strike",e.strike)),e.doubleStrike!==void 0&&this.push(new We("w:dstrike",e.doubleStrike)),e.emboss!==void 0&&this.push(new We("w:emboss",e.emboss)),e.imprint!==void 0&&this.push(new We("w:imprint",e.imprint)),e.noProof!==void 0&&this.push(new We("w:noProof",e.noProof)),e.snapToGrid!==void 0&&this.push(new We("w:snapToGrid",e.snapToGrid)),e.vanish&&this.push(new We("w:vanish",e.vanish)),e.color&&this.push(new kPt(e.color)),e.characterSpacing&&this.push(new NPt(e.characterSpacing)),e.scale!==void 0&&this.push(new q_("w:w",e.scale)),e.kern&&this.push(new wF("w:kern",e.kern)),e.position&&this.push(new Im("w:position",e.position)),e.size!==void 0&&this.push(new wF("w:sz",e.size));const s=e.sizeComplexScript===void 0||e.sizeComplexScript===!0?e.size:e.sizeComplexScript;s&&this.push(new wF("w:szCs",s)),e.highlight&&this.push(new CPt(e.highlight));const i=e.highlightComplexScript===void 0||e.highlightComplexScript===!0?e.highlight:e.highlightComplexScript;i&&this.push(new EPt(i)),e.underline&&this.push(new IPt(e.underline.type,e.underline.color)),e.effect&&this.push(new Im("w:effect",e.effect)),e.border&&this.push(new cn("w:bdr",e.border)),e.shading&&this.push(new t5(e.shading)),e.subScript&&this.push(new PPt),e.superScript&&this.push(new TPt),e.rightToLeft!==void 0&&this.push(new We("w:rtl",e.rightToLeft)),e.emphasisMark&&this.push(new _Pt(e.emphasisMark.type)),e.language&&this.push(APt(e.language)),e.specVanish&&this.push(new We("w:specVanish",e.vanish)),e.math&&this.push(new We("w:oMath",e.math)),e.revision&&this.push(new RPt(e.revision))}push(e){this.root.push(e)}}class RPt extends Ae{constructor(e){super("w:rPrChange"),this.root.push(new wPt({id:e.id,author:e.author,date:e.date})),this.addChildElement(new Bv(e))}}let bae=class extends Ae{constructor(e){var r;super("w:t"),typeof e=="string"?(this.root.push(new yv({space:xv.PRESERVE})),this.root.push(e)):(this.root.push(new yv({space:(r=e.space)!=null?r:xv.DEFAULT})),this.root.push(e.text))}};const Jb={CURRENT:"CURRENT",TOTAL_PAGES:"TOTAL_PAGES",TOTAL_PAGES_IN_SECTION:"TOTAL_PAGES_IN_SECTION",CURRENT_SECTION:"SECTION"};class Ym extends Ae{constructor(e){if(super("w:r"),Ee(this,"properties"),this.properties=new Bv(e),this.root.push(this.properties),e.break)for(let r=0;r<e.break;r++)this.root.push(new pPt);if(e.children)for(const r of e.children){if(typeof r=="string"){switch(r){case Jb.CURRENT:this.root.push(new d_),this.root.push(new gPt),this.root.push(new h_),this.root.push(new f_);break;case Jb.TOTAL_PAGES:this.root.push(new d_),this.root.push(new xPt),this.root.push(new h_),this.root.push(new f_);break;case Jb.TOTAL_PAGES_IN_SECTION:this.root.push(new d_),this.root.push(new yPt),this.root.push(new h_),this.root.push(new f_);break;case Jb.CURRENT_SECTION:this.root.push(new d_),this.root.push(new vPt),this.root.push(new h_),this.root.push(new f_);break;default:this.root.push(new bae(r));break}continue}this.root.push(r)}else e.text!==void 0&&this.root.push(new bae(e.text))}}class Ns extends Ym{constructor(e){super(typeof e=="string"?{text:e}:e)}}var SF={},on={},_F,wae;function vA(){if(wae)return _F;wae=1,_F=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)},_F}var jae;function Cd(){if(jae)return on;jae=1;var t=vA(),e=yg();on.inherits=e;function r(T,M){return(T.charCodeAt(M)&64512)!==55296||M<0||M+1>=T.length?!1:(T.charCodeAt(M+1)&64512)===56320}function n(T,M){if(Array.isArray(T))return T.slice();if(!T)return[];var k=[];if(typeof T=="string")if(M){if(M==="hex")for(T=T.replace(/[^a-z0-9]+/ig,""),T.length%2!==0&&(T="0"+T),K=0;K<T.length;K+=2)k.push(parseInt(T[K]+T[K+1],16))}else for(var D=0,K=0;K<T.length;K++){var H=T.charCodeAt(K);H<128?k[D++]=H:H<2048?(k[D++]=H>>6|192,k[D++]=H&63|128):r(T,K)?(H=65536+((H&1023)<<10)+(T.charCodeAt(++K)&1023),k[D++]=H>>18|240,k[D++]=H>>12&63|128,k[D++]=H>>6&63|128,k[D++]=H&63|128):(k[D++]=H>>12|224,k[D++]=H>>6&63|128,k[D++]=H&63|128)}else for(K=0;K<T.length;K++)k[K]=T[K]|0;return k}on.toArray=n;function s(T){for(var M="",k=0;k<T.length;k++)M+=l(T[k].toString(16));return M}on.toHex=s;function i(T){var M=T>>>24|T>>>8&65280|T<<8&16711680|(T&255)<<24;return M>>>0}on.htonl=i;function a(T,M){for(var k="",D=0;D<T.length;D++){var K=T[D];M==="little"&&(K=i(K)),k+=c(K.toString(16))}return k}on.toHex32=a;function l(T){return T.length===1?"0"+T:T}on.zero2=l;function c(T){return T.length===7?"0"+T:T.length===6?"00"+T:T.length===5?"000"+T:T.length===4?"0000"+T:T.length===3?"00000"+T:T.length===2?"000000"+T:T.length===1?"0000000"+T:T}on.zero8=c;function u(T,M,k,D){var K=k-M;t(K%4===0);for(var H=new Array(K/4),ee=0,V=M;ee<H.length;ee++,V+=4){var B;D==="big"?B=T[V]<<24|T[V+1]<<16|T[V+2]<<8|T[V+3]:B=T[V+3]<<24|T[V+2]<<16|T[V+1]<<8|T[V],H[ee]=B>>>0}return H}on.join32=u;function d(T,M){for(var k=new Array(T.length*4),D=0,K=0;D<T.length;D++,K+=4){var H=T[D];M==="big"?(k[K]=H>>>24,k[K+1]=H>>>16&255,k[K+2]=H>>>8&255,k[K+3]=H&255):(k[K+3]=H>>>24,k[K+2]=H>>>16&255,k[K+1]=H>>>8&255,k[K]=H&255)}return k}on.split32=d;function h(T,M){return T>>>M|T<<32-M}on.rotr32=h;function f(T,M){return T<<M|T>>>32-M}on.rotl32=f;function p(T,M){return T+M>>>0}on.sum32=p;function m(T,M,k){return T+M+k>>>0}on.sum32_3=m;function g(T,M,k,D){return T+M+k+D>>>0}on.sum32_4=g;function y(T,M,k,D,K){return T+M+k+D+K>>>0}on.sum32_5=y;function x(T,M,k,D){var K=T[M],H=T[M+1],ee=D+H>>>0,V=(ee<D?1:0)+k+K;T[M]=V>>>0,T[M+1]=ee}on.sum64=x;function v(T,M,k,D){var K=M+D>>>0,H=(K<M?1:0)+T+k;return H>>>0}on.sum64_hi=v;function b(T,M,k,D){var K=M+D;return K>>>0}on.sum64_lo=b;function w(T,M,k,D,K,H,ee,V){var B=0,z=M;z=z+D>>>0,B+=z<M?1:0,z=z+H>>>0,B+=z<H?1:0,z=z+V>>>0,B+=z<V?1:0;var F=T+k+K+ee+B;return F>>>0}on.sum64_4_hi=w;function j(T,M,k,D,K,H,ee,V){var B=M+D+H+V;return B>>>0}on.sum64_4_lo=j;function N(T,M,k,D,K,H,ee,V,B,z){var F=0,G=M;G=G+D>>>0,F+=G<M?1:0,G=G+H>>>0,F+=G<H?1:0,G=G+V>>>0,F+=G<V?1:0,G=G+z>>>0,F+=G<z?1:0;var Q=T+k+K+ee+B+F;return Q>>>0}on.sum64_5_hi=N;function C(T,M,k,D,K,H,ee,V,B,z){var F=M+D+H+V+z;return F>>>0}on.sum64_5_lo=C;function A(T,M,k){var D=M<<32-k|T>>>k;return D>>>0}on.rotr64_hi=A;function E(T,M,k){var D=T<<32-k|M>>>k;return D>>>0}on.rotr64_lo=E;function O(T,M,k){return T>>>k}on.shr64_hi=O;function $(T,M,k){var D=T<<32-k|M>>>k;return D>>>0}return on.shr64_lo=$,on}var NF={},Sae;function bA(){if(Sae)return NF;Sae=1;var t=Cd(),e=vA();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 NF.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 l=0;l<s.length;l+=this._delta32)this._update(s,l,l+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,l=new Array(a+this.padLength);l[0]=128;for(var c=1;c<a;c++)l[c]=0;if(s<<=3,this.endian==="big"){for(var u=8;u<this.padLength;u++)l[c++]=0;l[c++]=0,l[c++]=0,l[c++]=0,l[c++]=0,l[c++]=s>>>24&255,l[c++]=s>>>16&255,l[c++]=s>>>8&255,l[c++]=s&255}else for(l[c++]=s&255,l[c++]=s>>>8&255,l[c++]=s>>>16&255,l[c++]=s>>>24&255,l[c++]=0,l[c++]=0,l[c++]=0,l[c++]=0,u=8;u<this.padLength;u++)l[c++]=0;return l},NF}var Rg={},yu={},_ae;function yke(){if(_ae)return yu;_ae=1;var t=Cd(),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)}yu.ft_1=r;function n(d,h,f){return d&h^~d&f}yu.ch32=n;function s(d,h,f){return d&h^d&f^h&f}yu.maj32=s;function i(d,h,f){return d^h^f}yu.p32=i;function a(d){return e(d,2)^e(d,13)^e(d,22)}yu.s0_256=a;function l(d){return e(d,6)^e(d,11)^e(d,25)}yu.s1_256=l;function c(d){return e(d,7)^e(d,18)^d>>>3}yu.g0_256=c;function u(d){return e(d,17)^e(d,19)^d>>>10}return yu.g1_256=u,yu}var kF,Nae;function OPt(){if(Nae)return kF;Nae=1;var t=Cd(),e=bA(),r=yke(),n=t.rotl32,s=t.sum32,i=t.sum32_5,a=r.ft_1,l=e.BlockHash,c=[1518500249,1859775393,2400959708,3395469782];function u(){if(!(this instanceof u))return new u;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}return t.inherits(u,l),kF=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],y=this.h[1],x=this.h[2],v=this.h[3],b=this.h[4];for(m=0;m<p.length;m++){var w=~~(m/20),j=i(n(g,5),a(w,y,x,v),b,p[m],c[w]);b=v,v=x,x=n(y,30),y=g,g=j}this.h[0]=s(this.h[0],g),this.h[1]=s(this.h[1],y),this.h[2]=s(this.h[2],x),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")},kF}var CF,kae;function vke(){if(kae)return CF;kae=1;var t=Cd(),e=bA(),r=yke(),n=vA(),s=t.sum32,i=t.sum32_4,a=t.sum32_5,l=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),CF=g,g.blockSize=512,g.outSize=256,g.hmacStrength=192,g.padLength=64,g.prototype._update=function(x,v){for(var b=this.W,w=0;w<16;w++)b[w]=x[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 j=this.h[0],N=this.h[1],C=this.h[2],A=this.h[3],E=this.h[4],O=this.h[5],$=this.h[6],T=this.h[7];for(n(this.k.length===b.length),w=0;w<b.length;w++){var M=a(T,d(E),l(E,O,$),this.k[w],b[w]),k=s(u(j),c(j,N,C));T=$,$=O,O=E,E=s(A,M),A=C,C=N,N=j,j=s(M,k)}this.h[0]=s(this.h[0],j),this.h[1]=s(this.h[1],N),this.h[2]=s(this.h[2],C),this.h[3]=s(this.h[3],A),this.h[4]=s(this.h[4],E),this.h[5]=s(this.h[5],O),this.h[6]=s(this.h[6],$),this.h[7]=s(this.h[7],T)},g.prototype._digest=function(x){return x==="hex"?t.toHex32(this.h,"big"):t.split32(this.h,"big")},CF}var EF,Cae;function MPt(){if(Cae)return EF;Cae=1;var t=Cd(),e=vke();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),EF=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")},EF}var AF,Eae;function bke(){if(Eae)return AF;Eae=1;var t=Cd(),e=bA(),r=vA(),n=t.rotr64_hi,s=t.rotr64_lo,i=t.shr64_hi,a=t.shr64_lo,l=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 y(){if(!(this instanceof y))return new y;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(y,m),AF=y,y.blockSize=1024,y.outSize=512,y.hmacStrength=192,y.padLength=128,y.prototype._prepareBlock=function(k,D){for(var K=this.W,H=0;H<32;H++)K[H]=k[D+H];for(;H<K.length;H+=2){var ee=$(K[H-4],K[H-3]),V=T(K[H-4],K[H-3]),B=K[H-14],z=K[H-13],F=E(K[H-30],K[H-29]),G=O(K[H-30],K[H-29]),Q=K[H-32],ie=K[H-31];K[H]=d(ee,V,B,z,F,G,Q,ie),K[H+1]=h(ee,V,B,z,F,G,Q,ie)}},y.prototype._update=function(k,D){this._prepareBlock(k,D);var K=this.W,H=this.h[0],ee=this.h[1],V=this.h[2],B=this.h[3],z=this.h[4],F=this.h[5],G=this.h[6],Q=this.h[7],ie=this.h[8],se=this.h[9],q=this.h[10],L=this.h[11],Z=this.h[12],J=this.h[13],W=this.h[14],X=this.h[15];r(this.k.length===K.length);for(var he=0;he<K.length;he+=2){var P=W,oe=X,Y=C(ie,se),R=A(ie,se),I=x(ie,se,q,L,Z),U=v(ie,se,q,L,Z,J),re=this.k[he],ue=this.k[he+1],ae=K[he],ge=K[he+1],we=f(P,oe,Y,R,I,U,re,ue,ae,ge),ce=p(P,oe,Y,R,I,U,re,ue,ae,ge);P=j(H,ee),oe=N(H,ee),Y=b(H,ee,V,B,z),R=w(H,ee,V,B,z,F);var ne=c(P,oe,Y,R),fe=u(P,oe,Y,R);W=Z,X=J,Z=q,J=L,q=ie,L=se,ie=c(G,Q,we,ce),se=u(Q,Q,we,ce),G=z,Q=F,z=V,F=B,V=H,B=ee,H=c(we,ce,ne,fe),ee=u(we,ce,ne,fe)}l(this.h,0,H,ee),l(this.h,2,V,B),l(this.h,4,z,F),l(this.h,6,G,Q),l(this.h,8,ie,se),l(this.h,10,q,L),l(this.h,12,Z,J),l(this.h,14,W,X)},y.prototype._digest=function(k){return k==="hex"?t.toHex32(this.h,"big"):t.split32(this.h,"big")};function x(M,k,D,K,H){var ee=M&D^~M&H;return ee<0&&(ee+=4294967296),ee}function v(M,k,D,K,H,ee){var V=k&K^~k&ee;return V<0&&(V+=4294967296),V}function b(M,k,D,K,H){var ee=M&D^M&H^D&H;return ee<0&&(ee+=4294967296),ee}function w(M,k,D,K,H,ee){var V=k&K^k&ee^K&ee;return V<0&&(V+=4294967296),V}function j(M,k){var D=n(M,k,28),K=n(k,M,2),H=n(k,M,7),ee=D^K^H;return ee<0&&(ee+=4294967296),ee}function N(M,k){var D=s(M,k,28),K=s(k,M,2),H=s(k,M,7),ee=D^K^H;return ee<0&&(ee+=4294967296),ee}function C(M,k){var D=n(M,k,14),K=n(M,k,18),H=n(k,M,9),ee=D^K^H;return ee<0&&(ee+=4294967296),ee}function A(M,k){var D=s(M,k,14),K=s(M,k,18),H=s(k,M,9),ee=D^K^H;return ee<0&&(ee+=4294967296),ee}function E(M,k){var D=n(M,k,1),K=n(M,k,8),H=i(M,k,7),ee=D^K^H;return ee<0&&(ee+=4294967296),ee}function O(M,k){var D=s(M,k,1),K=s(M,k,8),H=a(M,k,7),ee=D^K^H;return ee<0&&(ee+=4294967296),ee}function $(M,k){var D=n(M,k,19),K=n(k,M,29),H=i(M,k,6),ee=D^K^H;return ee<0&&(ee+=4294967296),ee}function T(M,k){var D=s(M,k,19),K=s(k,M,29),H=a(M,k,6),ee=D^K^H;return ee<0&&(ee+=4294967296),ee}return AF}var TF,Aae;function DPt(){if(Aae)return TF;Aae=1;var t=Cd(),e=bke();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),TF=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")},TF}var Tae;function LPt(){return Tae||(Tae=1,Rg.sha1=OPt(),Rg.sha224=MPt(),Rg.sha256=vke(),Rg.sha384=DPt(),Rg.sha512=bke()),Rg}var PF={},Pae;function $Pt(){if(Pae)return PF;Pae=1;var t=Cd(),e=bA(),r=t.rotl32,n=t.sum32,s=t.sum32_3,i=t.sum32_4,a=e.BlockHash;function l(){if(!(this instanceof l))return new l;a.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}t.inherits(l,a),PF.ripemd160=l,l.blockSize=512,l.outSize=160,l.hmacStrength=192,l.padLength=64,l.prototype._update=function(y,x){for(var v=this.h[0],b=this.h[1],w=this.h[2],j=this.h[3],N=this.h[4],C=v,A=b,E=w,O=j,$=N,T=0;T<80;T++){var M=n(r(i(v,c(T,b,w,j),y[h[T]+x],u(T)),p[T]),N);v=N,N=j,j=r(w,10),w=b,b=M,M=n(r(i(C,c(79-T,A,E,O),y[f[T]+x],d(T)),m[T]),$),C=$,$=O,O=r(E,10),E=A,A=M}M=s(this.h[1],w,O),this.h[1]=s(this.h[2],j,$),this.h[2]=s(this.h[3],N,C),this.h[3]=s(this.h[4],v,A),this.h[4]=s(this.h[0],b,E),this.h[0]=M},l.prototype._digest=function(y){return y==="hex"?t.toHex32(this.h,"little"):t.split32(this.h,"little")};function c(g,y,x,v){return g<=15?y^x^v:g<=31?y&x|~y&v:g<=47?(y|~x)^v:g<=63?y&v|x&~v:y^(x|~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 PF}var IF,Iae;function FPt(){if(Iae)return IF;Iae=1;var t=Cd(),e=vA();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 IF=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)},IF}var Rae;function BPt(){return Rae||(Rae=1,function(t){var e=t;e.utils=Cd(),e.common=bA(),e.sha=LPt(),e.ripemd=$Pt(),e.hmac=FPt(),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}(SF)),SF}var zPt=BPt();const UPt=kG(zPt);let HPt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",WPt=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n},VPt=(t=21)=>{let e="",r=t|0;for(;r--;)e+=HPt[Math.random()*64|0];return e};const vc=t=>Math.floor(t*72*20),r5=(t=0)=>{let e=t;return()=>++e},qPt=()=>r5(),GPt=()=>r5(1),KPt=()=>r5(),YPt=()=>r5(),XPt=()=>VPt().toLowerCase(),Oae=t=>UPt.sha1().update(t instanceof ArrayBuffer?new Uint8Array(t):t).digest("hex"),bS=t=>WPt("1234567890abcdef",t)(),QPt=()=>`${bS(8)}-${bS(4)}-${bS(4)}-${bS(4)}-${bS(12)}`,ZPt={CHARACTER:"character",COLUMN:"column",INSIDE_MARGIN:"insideMargin",LEFT_MARGIN:"leftMargin",MARGIN:"margin",OUTSIDE_MARGIN:"outsideMargin",PAGE:"page",RIGHT_MARGIN:"rightMargin"},JPt={BOTTOM_MARGIN:"bottomMargin",INSIDE_MARGIN:"insideMargin",LINE:"line",MARGIN:"margin",OUTSIDE_MARGIN:"outsideMargin",PAGE:"page",PARAGRAPH:"paragraph",TOP_MARGIN:"topMargin"},eIt=()=>new nn({name:"wp:simplePos",attributes:{x:{key:"x",value:0},y:{key:"y",value:0}}}),wke=t=>new nn({name:"wp:align",children:[t]}),jke=t=>new nn({name:"wp:posOffset",children:[t.toString()]}),tIt=({relative:t,align:e,offset:r})=>new nn({name:"wp:positionH",attributes:{relativeFrom:{key:"relativeFrom",value:t??ZPt.PAGE}},children:[(()=>{if(e)return wke(e);if(r!==void 0)return jke(r);throw new Error("There is no configuration provided for floating position (Align or offset)")})()]}),rIt=({relative:t,align:e,offset:r})=>new nn({name:"wp:positionV",attributes:{relativeFrom:{key:"relativeFrom",value:t??JPt.PAGE}},children:[(()=>{if(e)return wke(e);if(r!==void 0)return jke(r);throw new Error("There is no configuration provided for floating position (Align or offset)")})()]});class nIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{uri:"uri"})}}const sIt=t=>new nn({name:"asvg:svgBlip",attributes:{asvg:{key:"xmlns:asvg",value:"http://schemas.microsoft.com/office/drawing/2016/SVG/main"},embed:{key:"r:embed",value:`rId{${t.fileName}}`}}}),iIt=t=>new nn({name:"a:ext",attributes:{uri:{key:"uri",value:"{96DAC541-7B7A-43D3-8B79-37D633B846F1}"}},children:[sIt(t)]}),aIt=t=>new nn({name:"a:extLst",children:[iIt(t)]}),oIt=t=>new nn({name:"a:blip",attributes:{embed:{key:"r:embed",value:`rId{${t.type==="svg"?t.fallback.fileName:t.fileName}}`},cstate:{key:"cstate",value:"none"}},children:t.type==="svg"?[aIt(t)]:[]});class lIt extends Ae{constructor(){super("a:srcRect")}}class cIt extends Ae{constructor(){super("a:fillRect")}}class uIt extends Ae{constructor(){super("a:stretch"),this.root.push(new cIt)}}class dIt extends Ae{constructor(e){super("pic:blipFill"),this.root.push(oIt(e)),this.root.push(new lIt),this.root.push(new uIt)}}class hIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{noChangeAspect:"noChangeAspect",noChangeArrowheads:"noChangeArrowheads"})}}class fIt extends Ae{constructor(){super("a:picLocks"),this.root.push(new hIt({noChangeAspect:1,noChangeArrowheads:1}))}}class pIt extends Ae{constructor(){super("pic:cNvPicPr"),this.root.push(new fIt)}}const Ske=(t,e)=>new nn({name:"a:hlinkClick",attributes:bf(or({},e?{xmlns:{key:"xmlns:a",value:"http://schemas.openxmlformats.org/drawingml/2006/main"}}:{}),{id:{key:"r:id",value:`rId${t}`}})});class mIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{id:"id",name:"name",descr:"descr"})}}class gIt extends Ae{constructor(){super("pic:cNvPr"),this.root.push(new mIt({id:0,name:"",descr:""}))}prepForXml(e){for(let r=e.stack.length-1;r>=0;r--){const n=e.stack[r];if(n instanceof BG){this.root.push(Ske(n.linkId,!1));break}}return super.prepForXml(e)}}class xIt extends Ae{constructor(){super("pic:nvPicPr"),this.root.push(new gIt),this.root.push(new pIt)}}class yIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{xmlns:"xmlns:pic"})}}class vIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{cx:"cx",cy:"cy"})}}class bIt extends Ae{constructor(e,r){super("a:ext"),Ee(this,"attributes"),this.attributes=new vIt({cx:e,cy:r}),this.root.push(this.attributes)}}class wIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{x:"x",y:"y"})}}class jIt extends Ae{constructor(){super("a:off"),this.root.push(new wIt({x:0,y:0}))}}class SIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{flipVertical:"flipV",flipHorizontal:"flipH",rotation:"rot"})}}class _It extends Ae{constructor(e){var r,n;super("a:xfrm"),Ee(this,"extents"),this.root.push(new SIt({flipVertical:(r=e.flip)==null?void 0:r.vertical,flipHorizontal:(n=e.flip)==null?void 0:n.horizontal,rotation:e.rotation})),this.extents=new bIt(e.emus.x,e.emus.y),this.root.push(new jIt),this.root.push(this.extents)}}const _ke=()=>new nn({name:"a:noFill"}),NIt=t=>new nn({name:"a:srgbClr",attributes:{value:{key:"val",value:t.value}}}),kIt=t=>new nn({name:"a:schemeClr",attributes:{value:{key:"val",value:t.value}}}),Mae=t=>new nn({name:"a:solidFill",children:[t.type==="rgb"?NIt(t):kIt(t)]}),CIt=t=>new nn({name:"a:ln",attributes:{width:{key:"w",value:t.width},cap:{key:"cap",value:t.cap},compoundLine:{key:"cmpd",value:t.compoundLine},align:{key:"algn",value:t.align}},children:[t.type==="noFill"?_ke():t.solidFillType==="rgb"?Mae({type:"rgb",value:t.value}):Mae({type:"scheme",value:t.value})]});class EIt extends Ae{constructor(){super("a:avLst")}}class AIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{prst:"prst"})}}class TIt extends Ae{constructor(){super("a:prstGeom"),this.root.push(new AIt({prst:"rect"})),this.root.push(new EIt)}}class PIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{bwMode:"bwMode"})}}class IIt extends Ae{constructor({outline:e,transform:r}){super("pic:spPr"),Ee(this,"form"),this.root.push(new PIt({bwMode:"auto"})),this.form=new _It(r),this.root.push(this.form),this.root.push(new TIt),e&&(this.root.push(_ke()),this.root.push(CIt(e)))}}class RIt extends Ae{constructor({mediaData:e,transform:r,outline:n}){super("pic:pic"),this.root.push(new yIt({xmlns:"http://schemas.openxmlformats.org/drawingml/2006/picture"})),this.root.push(new xIt),this.root.push(new dIt(e)),this.root.push(new IIt({transform:r,outline:n}))}}class OIt extends Ae{constructor({mediaData:e,transform:r,outline:n}){super("a:graphicData"),Ee(this,"pic"),this.root.push(new nIt({uri:"http://schemas.openxmlformats.org/drawingml/2006/picture"})),this.pic=new RIt({mediaData:e,transform:r,outline:n}),this.root.push(this.pic)}}class MIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{a:"xmlns:a"})}}class Nke extends Ae{constructor({mediaData:e,transform:r,outline:n}){super("a:graphic"),Ee(this,"data"),this.root.push(new MIt({a:"http://schemas.openxmlformats.org/drawingml/2006/main"})),this.data=new OIt({mediaData:e,transform:r,outline:n}),this.root.push(this.data)}}const GT={NONE:0,SQUARE:1,TIGHT:2,TOP_AND_BOTTOM:3},DIt={BOTH_SIDES:"bothSides",LEFT:"left",RIGHT:"right",LARGEST:"largest"};class Dae extends Ae{constructor(){super("wp:wrapNone")}}class LIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{distT:"distT",distB:"distB",distL:"distL",distR:"distR",wrapText:"wrapText"})}}class $It extends Ae{constructor(e,r={top:0,bottom:0,left:0,right:0}){super("wp:wrapSquare"),this.root.push(new LIt({wrapText:e.side||DIt.BOTH_SIDES,distT:r.top,distB:r.bottom,distL:r.left,distR:r.right}))}}class FIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{distT:"distT",distB:"distB"})}}class BIt extends Ae{constructor(e={top:0,bottom:0}){super("wp:wrapTight"),this.root.push(new FIt({distT:e.top,distB:e.bottom}))}}class zIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{distT:"distT",distB:"distB"})}}class UIt extends Ae{constructor(e={top:0,bottom:0}){super("wp:wrapTopAndBottom"),this.root.push(new zIt({distT:e.top,distB:e.bottom}))}}class kke extends Ae{constructor({name:e,description:r,title:n}={name:"",description:"",title:""}){super("wp:docPr"),Ee(this,"docPropertiesUniqueNumericId",KPt());const s={id:{key:"id",value:this.docPropertiesUniqueNumericId()},name:{key:"name",value:e}};r!=null&&(s.description={key:"descr",value:r}),n!=null&&(s.title={key:"title",value:n}),this.root.push(new Of(s))}prepForXml(e){for(let r=e.stack.length-1;r>=0;r--){const n=e.stack[r];if(n instanceof BG){this.root.push(Ske(n.linkId,!0));break}}return super.prepForXml(e)}}const Cke=({top:t,right:e,bottom:r,left:n})=>new nn({name:"wp:effectExtent",attributes:{top:{key:"t",value:t},right:{key:"r",value:e},bottom:{key:"b",value:r},left:{key:"l",value:n}}}),Eke=({x:t,y:e})=>new nn({name:"wp:extent",attributes:{x:{key:"cx",value:t},y:{key:"cy",value:e}}});class HIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{xmlns:"xmlns:a",noChangeAspect:"noChangeAspect"})}}class WIt extends Ae{constructor(){super("a:graphicFrameLocks"),this.root.push(new HIt({xmlns:"http://schemas.openxmlformats.org/drawingml/2006/main",noChangeAspect:1}))}}const Ake=()=>new nn({name:"wp:cNvGraphicFramePr",children:[new WIt]});class VIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{distT:"distT",distB:"distB",distL:"distL",distR:"distR",allowOverlap:"allowOverlap",behindDoc:"behindDoc",layoutInCell:"layoutInCell",locked:"locked",relativeHeight:"relativeHeight",simplePos:"simplePos"})}}class qIt extends Ae{constructor({mediaData:e,transform:r,drawingOptions:n}){super("wp:anchor");const s=or({allowOverlap:!0,behindDocument:!1,lockAnchor:!1,layoutInCell:!0,verticalPosition:{},horizontalPosition:{}},n.floating);if(this.root.push(new VIt({distT:s.margins&&s.margins.top||0,distB:s.margins&&s.margins.bottom||0,distL:s.margins&&s.margins.left||0,distR:s.margins&&s.margins.right||0,simplePos:"0",allowOverlap:s.allowOverlap===!0?"1":"0",behindDoc:s.behindDocument===!0?"1":"0",locked:s.lockAnchor===!0?"1":"0",layoutInCell:s.layoutInCell===!0?"1":"0",relativeHeight:s.zIndex?s.zIndex:r.emus.y})),this.root.push(eIt()),this.root.push(tIt(s.horizontalPosition)),this.root.push(rIt(s.verticalPosition)),this.root.push(Eke({x:r.emus.x,y:r.emus.y})),this.root.push(Cke({top:0,right:0,bottom:0,left:0})),n.floating!==void 0&&n.floating.wrap!==void 0)switch(n.floating.wrap.type){case GT.SQUARE:this.root.push(new $It(n.floating.wrap,n.floating.margins));break;case GT.TIGHT:this.root.push(new BIt(n.floating.margins));break;case GT.TOP_AND_BOTTOM:this.root.push(new UIt(n.floating.margins));break;case GT.NONE:default:this.root.push(new Dae)}else this.root.push(new Dae);this.root.push(new kke(n.docProperties)),this.root.push(Ake()),this.root.push(new Nke({mediaData:e,transform:r,outline:n.outline}))}}const GIt=({mediaData:t,transform:e,docProperties:r,outline:n})=>{var s,i,a,l;return new nn({name:"wp:inline",attributes:{distanceTop:{key:"distT",value:0},distanceBottom:{key:"distB",value:0},distanceLeft:{key:"distL",value:0},distanceRight:{key:"distR",value:0}},children:[Eke({x:e.emus.x,y:e.emus.y}),Cke(n?{top:((s=n.width)!=null?s:9525)*2,right:((i=n.width)!=null?i:9525)*2,bottom:((a=n.width)!=null?a:9525)*2,left:((l=n.width)!=null?l:9525)*2}:{top:0,right:0,bottom:0,left:0}),new kke(r),Ake(),new Nke({mediaData:t,transform:e,outline:n})]})};class KIt extends Ae{constructor(e,r={}){super("w:drawing"),r.floating?this.root.push(new qIt({mediaData:e,transform:e.transformation,drawingOptions:r})):this.root.push(GIt({mediaData:e,transform:e.transformation,docProperties:r.docProperties,outline:r.outline}))}}const YIt=t=>{if(typeof atob=="function"){const e=";base64,",r=t.indexOf(e),n=r===-1?0:r+e.length;return new Uint8Array(atob(t.substring(n)).split("").map(s=>s.charCodeAt(0)))}else{const e=require("buffer");return new e.Buffer(t,"base64")}},XIt=t=>typeof t=="string"?YIt(t):t,RF=(t,e)=>({data:XIt(t.data),fileName:e,transformation:{pixels:{x:Math.round(t.transformation.width),y:Math.round(t.transformation.height)},emus:{x:Math.round(t.transformation.width*9525),y:Math.round(t.transformation.height*9525)},flip:t.transformation.flip,rotation:t.transformation.rotation?t.transformation.rotation*6e4:void 0}});class QIt extends Ym{constructor(e){super({}),Ee(this,"imageData");const n=`${Oae(e.data)}.${e.type}`;this.imageData=e.type==="svg"?bf(or({type:e.type},RF(e,n)),{fallback:or({type:e.fallback.type},RF(bf(or({},e.fallback),{transformation:e.transformation}),`${Oae(e.fallback.data)}.${e.fallback.type}`))}):or({type:e.type},RF(e,n));const s=new KIt(this.imageData,{floating:e.floating,docProperties:e.altText,outline:e.outline});this.root.push(s)}prepForXml(e){return e.file.Media.addImage(this.imageData.fileName,this.imageData),this.imageData.type==="svg"&&e.file.Media.addImage(this.imageData.fallback.fileName,this.imageData.fallback),super.prepForXml(e)}}class ZIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{xmlns:"xmlns"})}}class JIt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{id:"Id",type:"Type",target:"Target",targetMode:"TargetMode"})}}const eRt={EXTERNAL:"External"};class tRt extends Ae{constructor(e,r,n,s){super("Relationship"),this.root.push(new JIt({id:e,type:r,target:n,targetMode:s}))}}class zv extends Ae{constructor(){super("Relationships"),this.root.push(new ZIt({xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"}))}createRelationship(e,r,n,s){const i=new tRt(`rId${e}`,r,n,s);return this.root.push(i),i}get RelationshipCount(){return this.root.length-1}}class rRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{id:"w:id",initials:"w:initials",author:"w:author",date:"w:date"})}}class nRt extends bt{constructor(){super(...arguments),Ee(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 sRt extends Ae{constructor({id:e,initials:r,author:n,date:s=new Date,children:i}){super("w:comment"),this.root.push(new rRt({id:e,initials:r,author:n,date:s.toISOString()}));for(const a of i)this.root.push(a)}}class iRt extends Ae{constructor({children:e}){super("w:comments"),Ee(this,"relationships"),this.root.push(new nRt({"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 sRt(r));this.relationships=new zv}get Relationships(){return this.relationships}}const aRt={COLUMN:"column",PAGE:"page"};class oRt extends Ae{constructor(e){super("w:br"),this.root.push(new is({type:e}))}}class Lae extends Ym{constructor(){super({}),this.root.push(new oRt(aRt.PAGE))}}class lRt extends Ae{constructor(){super("w:pageBreakBefore")}}const KH={AT_LEAST:"atLeast",EXACTLY:"exactly",EXACT:"exact",AUTO:"auto"};class cRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{after:"w:after",before:"w:before",line:"w:line",lineRule:"w:lineRule",beforeAutoSpacing:"w:beforeAutospacing",afterAutoSpacing:"w:afterAutospacing"})}}class uRt extends Ae{constructor(e){super("w:spacing"),this.root.push(new cRt(e))}}const KT={HEADING_1:"Heading1",HEADING_2:"Heading2",HEADING_3:"Heading3",HEADING_4:"Heading4",HEADING_5:"Heading5",HEADING_6:"Heading6",TITLE:"Title"};let YT=class extends Ae{constructor(e){super("w:pStyle"),this.root.push(new is({val:e}))}};class dRt extends Ae{constructor(e){super("w:tabs");for(const r of e)this.root.push(new fRt(r))}}const $ae={LEFT:"left",RIGHT:"right",CENTER:"center",BAR:"bar",CLEAR:"clear",DECIMAL:"decimal",END:"end",NUM:"num",START:"start"};class hRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val",pos:"w:pos",leader:"w:leader"})}}class fRt extends Ae{constructor({type:e,position:r,leader:n}){super("w:tab"),this.root.push(new hRt({val:e,pos:r,leader:n}))}}class OF extends Ae{constructor(e,r){super("w:numPr"),this.root.push(new pRt(r)),this.root.push(new mRt(e))}}class pRt extends Ae{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 is({val:e}))}}class mRt extends Ae{constructor(e){super("w:numId"),this.root.push(new is({val:typeof e=="string"?`{${e}}`:e}))}}class FG extends Ae{constructor(){super(...arguments),Ee(this,"fileChild",Symbol())}}class gRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{id:"r:id",history:"w:history",anchor:"w:anchor"})}}class BG extends Ae{constructor(e,r,n){super("w:hyperlink"),Ee(this,"linkId"),this.linkId=r;const s={history:1,anchor:n||void 0,id:n?void 0:`rId${this.linkId}`},i=new gRt(s);this.root.push(i),e.forEach(a=>{this.root.push(a)})}}class xRt extends Ae{constructor(e){super("w:externalHyperlink"),this.options=e}}class yRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{id:"w:id",name:"w:name"})}}class vRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{id:"w:id"})}}class bRt{constructor(e){Ee(this,"bookmarkUniqueNumericId",YPt()),Ee(this,"start"),Ee(this,"children"),Ee(this,"end");const r=this.bookmarkUniqueNumericId();this.start=new wRt(e.id,r),this.children=e.children,this.end=new jRt(r)}}class wRt extends Ae{constructor(e,r){super("w:bookmarkStart");const n=new yRt({name:e,id:r});this.root.push(n)}}class jRt extends Ae{constructor(e){super("w:bookmarkEnd");const r=new vRt({id:e});this.root.push(r)}}class SRt extends Ae{constructor(e){super("w:outlineLvl"),this.level=e,this.root.push(new is({val:e}))}}const _Rt={TOP:"top",CENTER:"center",BOTTOM:"bottom"};bf(or({},_Rt),{BOTH:"both"});class NRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{verticalAlign:"w:val"})}}class Tke extends Ae{constructor(e){super("w:vAlign"),this.root.push(new NRt({verticalAlign:e}))}}class kRt extends Ae{constructor({space:e,count:r,separate:n,equalWidth:s,children:i}){super("w:cols"),this.root.push(new Of({space:{key:"w:space",value:e===void 0?void 0:ta(e)},count:{key:"w:num",value:r===void 0?void 0:Ca(r)},separate:{key:"w:sep",value:n},equalWidth:{key:"w:equalWidth",value:s}})),!s&&i&&i.forEach(a=>this.addChildElement(a))}}const CRt=({type:t,linePitch:e,charSpace:r})=>new nn({name:"w:docGrid",attributes:{type:{key:"w:type",value:t},linePitch:{key:"w:linePitch",value:Ca(e)},charSpace:{key:"w:charSpace",value:r?Ca(r):void 0}}}),k0={DEFAULT:"default",FIRST:"first",EVEN:"even"};class ERt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{type:"w:type",id:"r:id"})}}const Fae={HEADER:"w:headerReference",FOOTER:"w:footerReference"};class MF extends Ae{constructor(e,r){super(e),this.root.push(new ERt({type:r.type||k0.DEFAULT,id:`rId${r.id}`}))}}const ARt=({countBy:t,start:e,restart:r,distance:n})=>new nn({name:"w:lnNumType",attributes:{countBy:{key:"w:countBy",value:t===void 0?void 0:Ca(t)},start:{key:"w:start",value:e===void 0?void 0:Ca(e)},restart:{key:"w:restart",value:r},distance:{key:"w:distance",value:n===void 0?void 0:ta(n)}}});class Bae extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{display:"w:display",offsetFrom:"w:offsetFrom",zOrder:"w:zOrder"})}}class TRt extends Rf{constructor(e){if(super("w:pgBorders"),!e)return this;e.pageBorders?this.root.push(new Bae({display:e.pageBorders.display,offsetFrom:e.pageBorders.offsetFrom,zOrder:e.pageBorders.zOrder})):this.root.push(new Bae({})),e.pageBorderTop&&this.root.push(new cn("w:top",e.pageBorderTop)),e.pageBorderLeft&&this.root.push(new cn("w:left",e.pageBorderLeft)),e.pageBorderBottom&&this.root.push(new cn("w:bottom",e.pageBorderBottom)),e.pageBorderRight&&this.root.push(new cn("w:right",e.pageBorderRight))}}class PRt extends Ae{constructor(e,r,n,s,i,a,l){super("w:pgMar"),this.root.push(new Of({top:{key:"w:top",value:zh(e)},right:{key:"w:right",value:ta(r)},bottom:{key:"w:bottom",value:zh(n)},left:{key:"w:left",value:ta(s)},header:{key:"w:header",value:ta(i)},footer:{key:"w:footer",value:ta(a)},gutter:{key:"w:gutter",value:ta(l)}}))}}class IRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{start:"w:start",formatType:"w:fmt",separator:"w:chapSep"})}}class RRt extends Ae{constructor({start:e,formatType:r,separator:n}){super("w:pgNumType"),this.root.push(new IRt({start:e===void 0?void 0:Ca(e),formatType:r,separator:n}))}}const YH={PORTRAIT:"portrait",LANDSCAPE:"landscape"},ORt=({width:t,height:e,orientation:r,code:n})=>{const s=ta(t),i=ta(e);return new nn({name:"w:pgSz",attributes:{width:{key:"w:w",value:r===YH.LANDSCAPE?i:s},height:{key:"w:h",value:r===YH.LANDSCAPE?s:i},orientation:{key:"w:orient",value:r},code:{key:"w:code",value:n}}})};class MRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val"})}}class DRt extends Ae{constructor(e){super("w:textDirection"),this.root.push(new MRt({val:e}))}}class LRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val"})}}class $Rt extends Ae{constructor(e){super("w:type"),this.root.push(new LRt({val:e}))}}const Og={TOP:1440,RIGHT:1440,BOTTOM:1440,LEFT:1440,HEADER:708,FOOTER:708,GUTTER:0},DF={WIDTH:11906,HEIGHT:16838,ORIENTATION:YH.PORTRAIT};class FRt extends Ae{constructor({page:{size:{width:e=DF.WIDTH,height:r=DF.HEIGHT,orientation:n=DF.ORIENTATION}={},margin:{top:s=Og.TOP,right:i=Og.RIGHT,bottom:a=Og.BOTTOM,left:l=Og.LEFT,header:c=Og.HEADER,footer:u=Og.FOOTER,gutter:d=Og.GUTTER}={},pageNumbers:h={},borders:f,textDirection:p}={},grid:{linePitch:m=360,charSpace:g,type:y}={},headerWrapperGroup:x={},footerWrapperGroup:v={},lineNumbers:b,titlePage:w,verticalAlign:j,column:N,type:C}={}){super("w:sectPr"),this.addHeaderFooterGroup(Fae.HEADER,x),this.addHeaderFooterGroup(Fae.FOOTER,v),C&&this.root.push(new $Rt(C)),this.root.push(ORt({width:e,height:r,orientation:n})),this.root.push(new PRt(s,i,a,l,c,u,d)),f&&this.root.push(new TRt(f)),b&&this.root.push(ARt(b)),this.root.push(new RRt(h)),N&&this.root.push(new kRt(N)),j&&this.root.push(new Tke(j)),w!==void 0&&this.root.push(new We("w:titlePg",w)),p&&this.root.push(new DRt(p)),this.root.push(CRt({linePitch:m,charSpace:g,type:y}))}addHeaderFooterGroup(e,r){r.default&&this.root.push(new MF(e,{type:k0.DEFAULT,id:r.default.View.ReferenceId})),r.first&&this.root.push(new MF(e,{type:k0.FIRST,id:r.first.View.ReferenceId})),r.even&&this.root.push(new MF(e,{type:k0.EVEN,id:r.even.View.ReferenceId}))}}class BRt extends Ae{constructor(){super("w:body"),Ee(this,"sections",[])}addSection(e){const r=this.sections.pop();this.root.push(this.createSectionParagraph(r)),this.sections.push(new FRt(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 Nr({}),n=new B1({});return n.push(e),r.addChildElement(n),r}}const zae={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 n5 extends bt{constructor(e,r){super(or({Ignorable:r},Object.fromEntries(e.map(n=>[n,zae[n]])))),Ee(this,"xmlKeys",or({Ignorable:"mc:Ignorable"},Object.fromEntries(Object.keys(zae).map(n=>[n,`xmlns:${n}`]))))}}class zRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{color:"w:color",themeColor:"w:themeColor",themeShade:"w:themeShade",themeTint:"w:themeTint"})}}class URt extends Ae{constructor(e){super("w:background"),this.root.push(new zRt({color:e.color===void 0?void 0:F1(e.color),themeColor:e.themeColor,themeShade:e.themeShade===void 0?void 0:yae(e.themeShade),themeTint:e.themeTint===void 0?void 0:yae(e.themeTint)}))}}let HRt=class extends Ae{constructor(e){super("w:document"),Ee(this,"body"),this.root.push(new n5(["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 BRt,e.background&&this.root.push(new URt(e.background)),this.root.push(this.body)}add(e){return this.body.push(e),this}get Body(){return this.body}};class Pke{constructor(e){Ee(this,"document"),Ee(this,"relationships"),this.document=new HRt(e),this.relationships=new zv}get View(){return this.document}get Relationships(){return this.relationships}}class WRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val"})}}class VRt extends Ae{constructor(){super("w:wordWrap"),this.root.push(new WRt({val:0}))}}const qRt=t=>{var e,r;return new nn({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 B1 extends Rf{constructor(e){var r,n;if(super("w:pPr"),Ee(this,"numberingReferences",[]),!e)return this;e.heading&&this.push(new YT(e.heading)),e.bullet&&this.push(new YT("ListParagraph")),e.numbering&&!e.style&&!e.heading&&(e.numbering.custom||this.push(new YT("ListParagraph"))),e.style&&this.push(new YT(e.style)),e.keepNext!==void 0&&this.push(new We("w:keepNext",e.keepNext)),e.keepLines!==void 0&&this.push(new We("w:keepLines",e.keepLines)),e.pageBreakBefore&&this.push(new lRt),e.frame&&this.push(qRt(e.frame)),e.widowControl!==void 0&&this.push(new We("w:widowControl",e.widowControl)),e.bullet&&this.push(new OF(1,e.bullet.level)),e.numbering?(this.numberingReferences.push({reference:e.numbering.reference,instance:(r=e.numbering.instance)!=null?r:0}),this.push(new OF(`${e.numbering.reference}-${(n=e.numbering.instance)!=null?n:0}`,e.numbering.level))):e.numbering===!1&&this.push(new OF(0,0)),e.border&&this.push(new dPt(e.border)),e.thematicBreak&&this.push(new hPt),e.shading&&this.push(new t5(e.shading)),e.wordWrap&&this.push(new VRt),e.overflowPunctuation&&this.push(new We("w:overflowPunct",e.overflowPunctuation));const s=[...e.rightTabStop!==void 0?[{type:$ae.RIGHT,position:e.rightTabStop}]:[],...e.tabStops?e.tabStops:[],...e.leftTabStop!==void 0?[{type:$ae.LEFT,position:e.leftTabStop}]:[]];s.length>0&&this.push(new dRt(s)),e.bidirectional!==void 0&&this.push(new We("w:bidi",e.bidirectional)),e.spacing&&this.push(new uRt(e.spacing)),e.indent&&this.push(new fPt(e.indent)),e.contextualSpacing!==void 0&&this.push(new We("w:contextualSpacing",e.contextualSpacing)),e.alignment&&this.push(new pke(e.alignment)),e.outlineLevel!==void 0&&this.push(new SRt(e.outlineLevel)),e.suppressLineNumbers!==void 0&&this.push(new We("w:suppressLineNumbers",e.suppressLineNumbers)),e.autoSpaceEastAsianText!==void 0&&this.push(new We("w:autoSpaceDN",e.autoSpaceEastAsianText)),e.run&&this.push(new Bv(e.run))}push(e){this.root.push(e)}prepForXml(e){if(e.viewWrapper instanceof Pke)for(const r of this.numberingReferences)e.file.Numbering.createConcreteNumberingInstance(r.reference,r.instance);return super.prepForXml(e)}}let Nr=class extends FG{constructor(e){if(super("w:p"),Ee(this,"properties"),typeof e=="string")return this.properties=new B1({}),this.root.push(this.properties),this.root.push(new Ns(e)),this;if(this.properties=new B1(e),this.root.push(this.properties),e.text&&this.root.push(new Ns(e.text)),e.children)for(const r of e.children){if(r instanceof bRt){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 xRt){const n=this.root.indexOf(r),s=new BG(r.options.children,XPt());e.viewWrapper.Relationships.createRelationship(s.linkId,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",r.options.link,eRt.EXTERNAL),this.root[n]=s}return super.prepForXml(e)}addRunToFront(e){return this.root.splice(1,0,e),this}};class GRt extends Ae{constructor(e){super("w:tblGrid");for(const r of e)this.root.push(new KRt(r))}}class KRt extends Ae{constructor(e){super("w:gridCol"),e!==void 0&&this.root.push(new Of({width:{key:"w:w",value:ta(e)}}))}}const Ike={TABLE:"w:tblCellMar",TABLE_CELL:"w:tcMar"};class Rke extends Rf{constructor(e,{marginUnitType:r=C0.DXA,top:n,left:s,bottom:i,right:a}){super(e),n!==void 0&&this.root.push(new fx("w:top",{type:r,size:n})),s!==void 0&&this.root.push(new fx("w:left",{type:r,size:s})),i!==void 0&&this.root.push(new fx("w:bottom",{type:r,size:i})),a!==void 0&&this.root.push(new fx("w:right",{type:r,size:a}))}}const C0={AUTO:"auto",DXA:"dxa",NIL:"nil",PERCENTAGE:"pct"};class fx extends Ae{constructor(e,{type:r=C0.AUTO,size:n}){super(e);let s=n;r===C0.PERCENTAGE&&typeof n=="number"&&(s=`${n}%`),this.root.push(new Of({type:{key:"w:type",value:r},size:{key:"w:w",value:fke(s)}}))}}class YRt extends Rf{constructor(e){super("w:tcBorders"),e.top&&this.root.push(new cn("w:top",e.top)),e.start&&this.root.push(new cn("w:start",e.start)),e.left&&this.root.push(new cn("w:left",e.left)),e.bottom&&this.root.push(new cn("w:bottom",e.bottom)),e.end&&this.root.push(new cn("w:end",e.end)),e.right&&this.root.push(new cn("w:right",e.right))}}class XRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val"})}}class QRt extends Ae{constructor(e){super("w:gridSpan"),this.root.push(new XRt({val:Ca(e)}))}}const Oke={CONTINUE:"continue",RESTART:"restart"};class ZRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val"})}}class Uae extends Ae{constructor(e){super("w:vMerge"),this.root.push(new ZRt({val:e}))}}class JRt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val"})}}class eOt extends Ae{constructor(e){super("w:textDirection"),this.root.push(new JRt({val:e}))}}class tOt extends Rf{constructor(e){super("w:tcPr"),e.width&&this.root.push(new fx("w:tcW",e.width)),e.columnSpan&&this.root.push(new QRt(e.columnSpan)),e.verticalMerge?this.root.push(new Uae(e.verticalMerge)):e.rowSpan&&e.rowSpan>1&&this.root.push(new Uae(Oke.RESTART)),e.borders&&this.root.push(new YRt(e.borders)),e.shading&&this.root.push(new t5(e.shading)),e.margins&&this.root.push(new Rke(Ike.TABLE_CELL,e.margins)),e.textDirection&&this.root.push(new eOt(e.textDirection)),e.verticalAlign&&this.root.push(new Tke(e.verticalAlign))}}let uO=class extends Ae{constructor(e){super("w:tc"),this.options=e,this.root.push(new tOt(e));for(const r of e.children)this.root.push(r)}prepForXml(e){return this.root[this.root.length-1]instanceof Nr||this.root.push(new Nr({})),super.prepForXml(e)}};const cb={style:Uh.NONE,size:0,color:"auto"},ub={style:Uh.SINGLE,size:4,color:"auto"};class Mke extends Ae{constructor(e){super("w:tblBorders"),e.top?this.root.push(new cn("w:top",e.top)):this.root.push(new cn("w:top",ub)),e.left?this.root.push(new cn("w:left",e.left)):this.root.push(new cn("w:left",ub)),e.bottom?this.root.push(new cn("w:bottom",e.bottom)):this.root.push(new cn("w:bottom",ub)),e.right?this.root.push(new cn("w:right",e.right)):this.root.push(new cn("w:right",ub)),e.insideHorizontal?this.root.push(new cn("w:insideH",e.insideHorizontal)):this.root.push(new cn("w:insideH",ub)),e.insideVertical?this.root.push(new cn("w:insideV",e.insideVertical)):this.root.push(new cn("w:insideV",ub))}}Ee(Mke,"NONE",{top:cb,bottom:cb,left:cb,right:cb,insideHorizontal:cb,insideVertical:cb});class rOt extends Ae{constructor({horizontalAnchor:e,verticalAnchor:r,absoluteHorizontalPosition:n,relativeHorizontalPosition:s,absoluteVerticalPosition:i,relativeVerticalPosition:a,bottomFromText:l,topFromText:c,leftFromText:u,rightFromText:d,overlap:h}){super("w:tblpPr"),this.root.push(new Of({leftFromText:{key:"w:leftFromText",value:u===void 0?void 0:ta(u)},rightFromText:{key:"w:rightFromText",value:d===void 0?void 0:ta(d)},topFromText:{key:"w:topFromText",value:c===void 0?void 0:ta(c)},bottomFromText:{key:"w:bottomFromText",value:l===void 0?void 0:ta(l)},absoluteHorizontalPosition:{key:"w:tblpX",value:n===void 0?void 0:zh(n)},absoluteVerticalPosition:{key:"w:tblpY",value:i===void 0?void 0:zh(i)},horizontalAnchor:{key:"w:horzAnchor",value:e===void 0?void 0:e},relativeHorizontalPosition:{key:"w:tblpXSpec",value:s},relativeVerticalPosition:{key:"w:tblpYSpec",value:a},verticalAnchor:{key:"w:vertAnchor",value:r}})),h&&this.root.push(new lPt("w:tblOverlap",h))}}class nOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{type:"w:type"})}}class sOt extends Ae{constructor(e){super("w:tblLayout"),this.root.push(new nOt({type:e}))}}const iOt={DXA:"dxa"};class Dke extends Ae{constructor({type:e=iOt.DXA,value:r}){super("w:tblCellSpacing"),this.root.push(new Of({type:{key:"w:type",value:e},value:{key:"w:w",value:fke(r)}}))}}class aOt extends Rf{constructor(e){super("w:tblPr"),e.style&&this.root.push(new Im("w:tblStyle",e.style)),e.float&&this.root.push(new rOt(e.float)),e.visuallyRightToLeft!==void 0&&this.root.push(new We("w:bidiVisual",e.visuallyRightToLeft)),e.width&&this.root.push(new fx("w:tblW",e.width)),e.alignment&&this.root.push(new pke(e.alignment)),e.indent&&this.root.push(new fx("w:tblInd",e.indent)),e.borders&&this.root.push(new Mke(e.borders)),e.shading&&this.root.push(new t5(e.shading)),e.layout&&this.root.push(new sOt(e.layout)),e.cellMargin&&this.root.push(new Rke(Ike.TABLE,e.cellMargin)),e.cellSpacing&&this.root.push(new Dke(e.cellSpacing))}}let oOt=class extends FG{constructor({rows:e,width:r,columnWidths:n=Array(Math.max(...e.map(p=>p.CellCount))).fill(100),margins:s,indent:i,float:a,layout:l,style:c,borders:u,alignment:d,visuallyRightToLeft:h,cellSpacing:f}){super("w:tbl"),this.root.push(new aOt({borders:u??{},width:r??{size:100},indent:i,float:a,layout:l,style:c,alignment:d,cellMargin:s,visuallyRightToLeft:h,cellSpacing:f})),this.root.push(new GRt(n));for(const p of e)this.root.push(p);e.forEach((p,m)=>{if(m===e.length-1)return;let g=0;p.cells.forEach(y=>{if(y.options.rowSpan&&y.options.rowSpan>1){const x=new uO({rowSpan:y.options.rowSpan-1,columnSpan:y.options.columnSpan,borders:y.options.borders,children:[],verticalMerge:Oke.CONTINUE});e[m+1].addCellToColumnIndex(x,g)}g+=y.options.columnSpan||1})})}};class lOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{value:"w:val",rule:"w:hRule"})}}class cOt extends Ae{constructor(e,r){super("w:trHeight"),this.root.push(new lOt({value:ta(e),rule:r}))}}class uOt extends Rf{constructor(e){super("w:trPr"),e.cantSplit!==void 0&&this.root.push(new We("w:cantSplit",e.cantSplit)),e.tableHeader!==void 0&&this.root.push(new We("w:tblHeader",e.tableHeader)),e.height&&this.root.push(new cOt(e.height.value,e.height.rule)),e.cellSpacing&&this.root.push(new Dke(e.cellSpacing))}}let dOt=class extends Ae{constructor(e){super("w:tr"),this.options=e,this.root.push(new uOt(e));for(const r of e.children)this.root.push(r)}get CellCount(){return this.options.children.length}get cells(){return this.root.filter(e=>e instanceof uO)}addCellToIndex(e,r){this.root.splice(r+1,0,e)}addCellToColumnIndex(e,r){const n=this.columnIndexToRootIndex(r,!0);this.addCellToIndex(e,n-1)}rootIndexToColumnIndex(e){if(e<1||e>=this.root.length)throw new Error(`cell 'rootIndex' should between 1 to ${this.root.length-1}`);let r=0;for(let n=1;n<e;n++){const s=this.root[n];r+=s.options.columnSpan||1}return r}columnIndexToRootIndex(e,r=!1){if(e<0)throw new Error("cell 'columnIndex' should not less than zero");let n=0,s=1;for(;n<=e;){if(s>=this.root.length){if(r)return this.root.length;throw new Error(`cell 'columnIndex' should not great than ${n-1}`)}const i=this.root[s];s+=1,n+=i&&i.options.columnSpan||1}return s-1}};class hOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{xmlns:"xmlns",vt:"xmlns:vt"})}}class fOt extends Ae{constructor(){super("Properties"),this.root.push(new hOt({xmlns:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",vt:"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"}))}}class pOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{xmlns:"xmlns"})}}class mOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{contentType:"ContentType",extension:"Extension"})}}class Od extends Ae{constructor(e,r){super("Default"),this.root.push(new mOt({contentType:e,extension:r}))}}class gOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{contentType:"ContentType",partName:"PartName"})}}class _l extends Ae{constructor(e,r){super("Override"),this.root.push(new gOt({contentType:e,partName:r}))}}class xOt extends Ae{constructor(){super("Types"),this.root.push(new pOt({xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"})),this.root.push(new Od("image/png","png")),this.root.push(new Od("image/jpeg","jpeg")),this.root.push(new Od("image/jpeg","jpg")),this.root.push(new Od("image/bmp","bmp")),this.root.push(new Od("image/gif","gif")),this.root.push(new Od("image/svg+xml","svg")),this.root.push(new Od("application/vnd.openxmlformats-package.relationships+xml","rels")),this.root.push(new Od("application/xml","xml")),this.root.push(new Od("application/vnd.openxmlformats-officedocument.obfuscatedFont","odttf")),this.root.push(new _l("application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml","/word/document.xml")),this.root.push(new _l("application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml","/word/styles.xml")),this.root.push(new _l("application/vnd.openxmlformats-package.core-properties+xml","/docProps/core.xml")),this.root.push(new _l("application/vnd.openxmlformats-officedocument.custom-properties+xml","/docProps/custom.xml")),this.root.push(new _l("application/vnd.openxmlformats-officedocument.extended-properties+xml","/docProps/app.xml")),this.root.push(new _l("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml","/word/numbering.xml")),this.root.push(new _l("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml","/word/footnotes.xml")),this.root.push(new _l("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml","/word/settings.xml")),this.root.push(new _l("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml","/word/comments.xml")),this.root.push(new _l("application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml","/word/fontTable.xml"))}addFooter(e){this.root.push(new _l("application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml",`/word/footer${e}.xml`))}addHeader(e){this.root.push(new _l("application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml",`/word/header${e}.xml`))}}class yOt extends Ae{constructor(e){super("cp:coreProperties"),this.root.push(new n5(["cp","dc","dcterms","dcmitype","xsi"])),e.title&&this.root.push(new Ig("dc:title",e.title)),e.subject&&this.root.push(new Ig("dc:subject",e.subject)),e.creator&&this.root.push(new Ig("dc:creator",e.creator)),e.keywords&&this.root.push(new Ig("cp:keywords",e.keywords)),e.description&&this.root.push(new Ig("dc:description",e.description)),e.lastModifiedBy&&this.root.push(new Ig("cp:lastModifiedBy",e.lastModifiedBy)),e.revision&&this.root.push(new Ig("cp:revision",String(e.revision))),this.root.push(new Hae("dcterms:created")),this.root.push(new Hae("dcterms:modified"))}}class vOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{type:"xsi:type"})}}class Hae extends Ae{constructor(e){super(e),this.root.push(new vOt({type:"dcterms:W3CDTF"})),this.root.push(oPt(new Date))}}class bOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{xmlns:"xmlns",vt:"xmlns:vt"})}}class wOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{fmtid:"fmtid",pid:"pid",name:"name"})}}class jOt extends Ae{constructor(e,r){super("property"),this.root.push(new wOt({fmtid:"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",pid:e.toString(),name:r.name})),this.root.push(new SOt(r.value))}}class SOt extends Ae{constructor(e){super("vt:lpwstr"),this.root.push(e)}}class _Ot extends Ae{constructor(e){super("Properties"),Ee(this,"nextId"),Ee(this,"properties",[]),this.root.push(new bOt({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 jOt(this.nextId++,e))}}const XT=({id:t,fontKey:e,subsetted:r},n)=>new nn({name:n,attributes:or({id:{key:"r:id",value:t}},e?{fontKey:{key:"w:fontKey",value:`{${e}}`}}:{}),children:[...r?[new We("w:subsetted",r)]:[]]}),NOt=({name:t,altName:e,panose1:r,charset:n,family:s,notTrueType:i,pitch:a,sig:l,embedRegular:c,embedBold:u,embedItalic:d,embedBoldItalic:h})=>new nn({name:"w:font",attributes:{name:{key:"w:name",value:t}},children:[...e?[vS("w:altName",e)]:[],...r?[vS("w:panose1",r)]:[],...n?[vS("w:charset",n)]:[],vS("w:family",s),...i?[new We("w:notTrueType",i)]:[],vS("w:pitch",a),...l?[new nn({name:"w:sig",attributes:{usb0:{key:"w:usb0",value:l.usb0},usb1:{key:"w:usb1",value:l.usb1},usb2:{key:"w:usb2",value:l.usb2},usb3:{key:"w:usb3",value:l.usb3},csb0:{key:"w:csb0",value:l.csb0},csb1:{key:"w:csb1",value:l.csb1}}})]:[],...c?[XT(c,"w:embedRegular")]:[],...u?[XT(u,"w:embedBold")]:[],...d?[XT(d,"w:embedItalic")]:[],...h?[XT(h,"w:embedBoldItalic")]:[]]}),kOt=({name:t,index:e,fontKey:r,characterSet:n})=>NOt({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}`}}),COt=t=>new nn({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)=>kOt({name:e.name,index:r+1,fontKey:e.fontKey}))});class EOt{constructor(e){Ee(this,"fontTable"),Ee(this,"relationships"),Ee(this,"fontOptionsWithKey",[]),this.options=e,this.fontOptionsWithKey=e.map(r=>bf(or({},r),{fontKey:QPt()})),this.fontTable=COt(this.fontOptionsWithKey),this.relationships=new zv;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 AOt extends bt{constructor(){super(...arguments),Ee(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 TOt=class extends uke{constructor(e,r){super("w:ftr",r),Ee(this,"refId"),this.refId=e,r||this.root.push(new AOt({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 POt{constructor(e,r,n){Ee(this,"footer"),Ee(this,"relationships"),this.media=e,this.footer=new TOt(r,n),this.relationships=new zv}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 IOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{type:"w:type",id:"w:id"})}}class ROt extends Ae{constructor(){super("w:footnoteRef")}}class OOt extends Ym{constructor(){super({style:"FootnoteReference"}),this.root.push(new ROt)}}const Wae={SEPERATOR:"separator",CONTINUATION_SEPERATOR:"continuationSeparator"};class LF extends Ae{constructor(e){super("w:footnote"),this.root.push(new IOt({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 OOt),this.root.push(n)}}}class MOt extends Ae{constructor(){super("w:continuationSeparator")}}class DOt extends Ym{constructor(){super({}),this.root.push(new MOt)}}class LOt extends Ae{constructor(){super("w:separator")}}class $Ot extends Ym{constructor(){super({}),this.root.push(new LOt)}}class FOt extends bt{constructor(){super(...arguments),Ee(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 BOt extends Ae{constructor(){super("w:footnotes"),this.root.push(new FOt({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 LF({id:-1,type:Wae.SEPERATOR,children:[new Nr({spacing:{after:0,line:240,lineRule:KH.AUTO},children:[new $Ot]})]});this.root.push(e);const r=new LF({id:0,type:Wae.CONTINUATION_SEPERATOR,children:[new Nr({spacing:{after:0,line:240,lineRule:KH.AUTO},children:[new DOt]})]});this.root.push(r)}createFootNote(e,r){const n=new LF({id:e,children:r});this.root.push(n)}}class zOt{constructor(){Ee(this,"footnotess"),Ee(this,"relationships"),this.footnotess=new BOt,this.relationships=new zv}get View(){return this.footnotess}get Relationships(){return this.relationships}}class UOt extends bt{constructor(){super(...arguments),Ee(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 HOt=class extends uke{constructor(e,r){super("w:hdr",r),Ee(this,"refId"),this.refId=e,r||this.root.push(new UOt({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 WOt{constructor(e,r,n){Ee(this,"header"),Ee(this,"relationships"),this.media=e,this.header=new HOt(r,n),this.relationships=new zv}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 VOt{constructor(){Ee(this,"map"),this.map=new Map}addImage(e,r){this.map.set(e,r)}get Array(){return Array.from(this.map.values())}}const Qo={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 qOt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{ilvl:"w:ilvl",tentative:"w15:tentative"})}}class GOt extends Ae{constructor(e){super("w:numFmt"),this.root.push(new is({val:e}))}}class KOt extends Ae{constructor(e){super("w:lvlText"),this.root.push(new is({val:e}))}}class YOt extends Ae{constructor(e){super("w:lvlJc"),this.root.push(new is({val:e}))}}class XOt extends Ae{constructor(e){super("w:suff"),this.root.push(new is({val:e}))}}class QOt extends Ae{constructor(){super("w:isLgl")}}class ZOt extends Ae{constructor({level:e,format:r,text:n,alignment:s=Vn.START,start:i=1,style:a,suffix:l,isLegalNumberingStyle:c}){if(super("w:lvl"),Ee(this,"paragraphProperties"),Ee(this,"runProperties"),this.root.push(new q_("w:start",Ca(i))),r&&this.root.push(new GOt(r)),l&&this.root.push(new XOt(l)),c&&this.root.push(new QOt),n&&this.root.push(new KOt(n)),this.root.push(new YOt(s)),this.paragraphProperties=new B1(a&&a.paragraph),this.runProperties=new Bv(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 qOt({ilvl:Ca(e),tentative:1}))}}class JOt extends ZOt{}class eMt extends Ae{constructor(e){super("w:multiLevelType"),this.root.push(new is({val:e}))}}class tMt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{abstractNumId:"w:abstractNumId",restartNumberingAfterBreak:"w15:restartNumberingAfterBreak"})}}class Vae extends Ae{constructor(e,r){super("w:abstractNum"),Ee(this,"id"),this.root.push(new tMt({abstractNumId:Ca(e),restartNumberingAfterBreak:0})),this.root.push(new eMt("hybridMultilevel")),this.id=e;for(const n of r)this.root.push(new JOt(n))}}class rMt extends Ae{constructor(e){super("w:abstractNumId"),this.root.push(new is({val:e}))}}class nMt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{numId:"w:numId"})}}class qae extends Ae{constructor(e){if(super("w:num"),Ee(this,"numId"),Ee(this,"reference"),Ee(this,"instance"),this.numId=e.numId,this.reference=e.reference,this.instance=e.instance,this.root.push(new nMt({numId:Ca(e.numId)})),this.root.push(new rMt(Ca(e.abstractNumId))),e.overrideLevels&&e.overrideLevels.length)for(const r of e.overrideLevels)this.root.push(new iMt(r.num,r.start))}}class sMt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{ilvl:"w:ilvl"})}}class iMt extends Ae{constructor(e,r){super("w:lvlOverride"),this.root.push(new sMt({ilvl:e})),r!==void 0&&this.root.push(new oMt(r))}}class aMt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val"})}}class oMt extends Ae{constructor(e){super("w:startOverride"),this.root.push(new aMt({val:e}))}}class lMt extends Ae{constructor(e){super("w:numbering"),Ee(this,"abstractNumberingMap",new Map),Ee(this,"concreteNumberingMap",new Map),Ee(this,"referenceConfigMap",new Map),Ee(this,"abstractNumUniqueNumericId",qPt()),Ee(this,"concreteNumUniqueNumericId",GPt()),this.root.push(new n5(["wpc","mc","o","r","m","v","wp14","wp","w10","w","w14","w15","wpg","wpi","wne","wps"],"w14 w15 wp14"));const r=new Vae(this.abstractNumUniqueNumericId(),[{level:0,format:Qo.BULLET,text:"●",alignment:Vn.LEFT,style:{paragraph:{indent:{left:vc(.5),hanging:vc(.25)}}}},{level:1,format:Qo.BULLET,text:"○",alignment:Vn.LEFT,style:{paragraph:{indent:{left:vc(1),hanging:vc(.25)}}}},{level:2,format:Qo.BULLET,text:"■",alignment:Vn.LEFT,style:{paragraph:{indent:{left:2160,hanging:vc(.25)}}}},{level:3,format:Qo.BULLET,text:"●",alignment:Vn.LEFT,style:{paragraph:{indent:{left:2880,hanging:vc(.25)}}}},{level:4,format:Qo.BULLET,text:"○",alignment:Vn.LEFT,style:{paragraph:{indent:{left:3600,hanging:vc(.25)}}}},{level:5,format:Qo.BULLET,text:"■",alignment:Vn.LEFT,style:{paragraph:{indent:{left:4320,hanging:vc(.25)}}}},{level:6,format:Qo.BULLET,text:"●",alignment:Vn.LEFT,style:{paragraph:{indent:{left:5040,hanging:vc(.25)}}}},{level:7,format:Qo.BULLET,text:"●",alignment:Vn.LEFT,style:{paragraph:{indent:{left:5760,hanging:vc(.25)}}}},{level:8,format:Qo.BULLET,text:"●",alignment:Vn.LEFT,style:{paragraph:{indent:{left:6480,hanging:vc(.25)}}}}]);this.concreteNumberingMap.set("default-bullet-numbering",new qae({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 Vae(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,l={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 qae(l))}get ConcreteNumbering(){return Array.from(this.concreteNumberingMap.values())}get ReferenceConfig(){return Array.from(this.referenceConfigMap.values())}}class cMt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{version:"w:val",name:"w:name",uri:"w:uri"})}}class uMt extends Ae{constructor(e){super("w:compatSetting"),this.root.push(new cMt({version:e,uri:"http://schemas.microsoft.com/office/word",name:"compatibilityMode"}))}}class dMt extends Ae{constructor(e){super("w:compat"),e.version&&this.root.push(new uMt(e.version)),e.useSingleBorderforContiguousCells&&this.root.push(new We("w:useSingleBorderforContiguousCells",e.useSingleBorderforContiguousCells)),e.wordPerfectJustification&&this.root.push(new We("w:wpJustification",e.wordPerfectJustification)),e.noTabStopForHangingIndent&&this.root.push(new We("w:noTabHangInd",e.noTabStopForHangingIndent)),e.noLeading&&this.root.push(new We("w:noLeading",e.noLeading)),e.spaceForUnderline&&this.root.push(new We("w:spaceForUL",e.spaceForUnderline)),e.noColumnBalance&&this.root.push(new We("w:noColumnBalance",e.noColumnBalance)),e.balanceSingleByteDoubleByteWidth&&this.root.push(new We("w:balanceSingleByteDoubleByteWidth",e.balanceSingleByteDoubleByteWidth)),e.noExtraLineSpacing&&this.root.push(new We("w:noExtraLineSpacing",e.noExtraLineSpacing)),e.doNotLeaveBackslashAlone&&this.root.push(new We("w:doNotLeaveBackslashAlone",e.doNotLeaveBackslashAlone)),e.underlineTrailingSpaces&&this.root.push(new We("w:ulTrailSpace",e.underlineTrailingSpaces)),e.doNotExpandShiftReturn&&this.root.push(new We("w:doNotExpandShiftReturn",e.doNotExpandShiftReturn)),e.spacingInWholePoints&&this.root.push(new We("w:spacingInWholePoints",e.spacingInWholePoints)),e.lineWrapLikeWord6&&this.root.push(new We("w:lineWrapLikeWord6",e.lineWrapLikeWord6)),e.printBodyTextBeforeHeader&&this.root.push(new We("w:printBodyTextBeforeHeader",e.printBodyTextBeforeHeader)),e.printColorsBlack&&this.root.push(new We("w:printColBlack",e.printColorsBlack)),e.spaceWidth&&this.root.push(new We("w:wpSpaceWidth",e.spaceWidth)),e.showBreaksInFrames&&this.root.push(new We("w:showBreaksInFrames",e.showBreaksInFrames)),e.subFontBySize&&this.root.push(new We("w:subFontBySize",e.subFontBySize)),e.suppressBottomSpacing&&this.root.push(new We("w:suppressBottomSpacing",e.suppressBottomSpacing)),e.suppressTopSpacing&&this.root.push(new We("w:suppressTopSpacing",e.suppressTopSpacing)),e.suppressSpacingAtTopOfPage&&this.root.push(new We("w:suppressSpacingAtTopOfPage",e.suppressSpacingAtTopOfPage)),e.suppressTopSpacingWP&&this.root.push(new We("w:suppressTopSpacingWP",e.suppressTopSpacingWP)),e.suppressSpBfAfterPgBrk&&this.root.push(new We("w:suppressSpBfAfterPgBrk",e.suppressSpBfAfterPgBrk)),e.swapBordersFacingPages&&this.root.push(new We("w:swapBordersFacingPages",e.swapBordersFacingPages)),e.convertMailMergeEsc&&this.root.push(new We("w:convMailMergeEsc",e.convertMailMergeEsc)),e.truncateFontHeightsLikeWP6&&this.root.push(new We("w:truncateFontHeightsLikeWP6",e.truncateFontHeightsLikeWP6)),e.macWordSmallCaps&&this.root.push(new We("w:mwSmallCaps",e.macWordSmallCaps)),e.usePrinterMetrics&&this.root.push(new We("w:usePrinterMetrics",e.usePrinterMetrics)),e.doNotSuppressParagraphBorders&&this.root.push(new We("w:doNotSuppressParagraphBorders",e.doNotSuppressParagraphBorders)),e.wrapTrailSpaces&&this.root.push(new We("w:wrapTrailSpaces",e.wrapTrailSpaces)),e.footnoteLayoutLikeWW8&&this.root.push(new We("w:footnoteLayoutLikeWW8",e.footnoteLayoutLikeWW8)),e.shapeLayoutLikeWW8&&this.root.push(new We("w:shapeLayoutLikeWW8",e.shapeLayoutLikeWW8)),e.alignTablesRowByRow&&this.root.push(new We("w:alignTablesRowByRow",e.alignTablesRowByRow)),e.forgetLastTabAlignment&&this.root.push(new We("w:forgetLastTabAlignment",e.forgetLastTabAlignment)),e.adjustLineHeightInTable&&this.root.push(new We("w:adjustLineHeightInTable",e.adjustLineHeightInTable)),e.autoSpaceLikeWord95&&this.root.push(new We("w:autoSpaceLikeWord95",e.autoSpaceLikeWord95)),e.noSpaceRaiseLower&&this.root.push(new We("w:noSpaceRaiseLower",e.noSpaceRaiseLower)),e.doNotUseHTMLParagraphAutoSpacing&&this.root.push(new We("w:doNotUseHTMLParagraphAutoSpacing",e.doNotUseHTMLParagraphAutoSpacing)),e.layoutRawTableWidth&&this.root.push(new We("w:layoutRawTableWidth",e.layoutRawTableWidth)),e.layoutTableRowsApart&&this.root.push(new We("w:layoutTableRowsApart",e.layoutTableRowsApart)),e.useWord97LineBreakRules&&this.root.push(new We("w:useWord97LineBreakRules",e.useWord97LineBreakRules)),e.doNotBreakWrappedTables&&this.root.push(new We("w:doNotBreakWrappedTables",e.doNotBreakWrappedTables)),e.doNotSnapToGridInCell&&this.root.push(new We("w:doNotSnapToGridInCell",e.doNotSnapToGridInCell)),e.selectFieldWithFirstOrLastCharacter&&this.root.push(new We("w:selectFldWithFirstOrLastChar",e.selectFieldWithFirstOrLastCharacter)),e.applyBreakingRules&&this.root.push(new We("w:applyBreakingRules",e.applyBreakingRules)),e.doNotWrapTextWithPunctuation&&this.root.push(new We("w:doNotWrapTextWithPunct",e.doNotWrapTextWithPunctuation)),e.doNotUseEastAsianBreakRules&&this.root.push(new We("w:doNotUseEastAsianBreakRules",e.doNotUseEastAsianBreakRules)),e.useWord2002TableStyleRules&&this.root.push(new We("w:useWord2002TableStyleRules",e.useWord2002TableStyleRules)),e.growAutofit&&this.root.push(new We("w:growAutofit",e.growAutofit)),e.useFELayout&&this.root.push(new We("w:useFELayout",e.useFELayout)),e.useNormalStyleForList&&this.root.push(new We("w:useNormalStyleForList",e.useNormalStyleForList)),e.doNotUseIndentAsNumberingTabStop&&this.root.push(new We("w:doNotUseIndentAsNumberingTabStop",e.doNotUseIndentAsNumberingTabStop)),e.useAlternateEastAsianLineBreakRules&&this.root.push(new We("w:useAltKinsokuLineBreakRules",e.useAlternateEastAsianLineBreakRules)),e.allowSpaceOfSameStyleInTable&&this.root.push(new We("w:allowSpaceOfSameStyleInTable",e.allowSpaceOfSameStyleInTable)),e.doNotSuppressIndentation&&this.root.push(new We("w:doNotSuppressIndentation",e.doNotSuppressIndentation)),e.doNotAutofitConstrainedTables&&this.root.push(new We("w:doNotAutofitConstrainedTables",e.doNotAutofitConstrainedTables)),e.autofitToFirstFixedWidthCell&&this.root.push(new We("w:autofitToFirstFixedWidthCell",e.autofitToFirstFixedWidthCell)),e.underlineTabInNumberingList&&this.root.push(new We("w:underlineTabInNumList",e.underlineTabInNumberingList)),e.displayHangulFixedWidth&&this.root.push(new We("w:displayHangulFixedWidth",e.displayHangulFixedWidth)),e.splitPgBreakAndParaMark&&this.root.push(new We("w:splitPgBreakAndParaMark",e.splitPgBreakAndParaMark)),e.doNotVerticallyAlignCellWithSp&&this.root.push(new We("w:doNotVertAlignCellWithSp",e.doNotVerticallyAlignCellWithSp)),e.doNotBreakConstrainedForcedTable&&this.root.push(new We("w:doNotBreakConstrainedForcedTable",e.doNotBreakConstrainedForcedTable)),e.ignoreVerticalAlignmentInTextboxes&&this.root.push(new We("w:doNotVertAlignInTxbx",e.ignoreVerticalAlignmentInTextboxes)),e.useAnsiKerningPairs&&this.root.push(new We("w:useAnsiKerningPairs",e.useAnsiKerningPairs)),e.cachedColumnBalance&&this.root.push(new We("w:cachedColBalance",e.cachedColumnBalance))}}class hMt extends bt{constructor(){super(...arguments),Ee(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 fMt extends Ae{constructor(e){var r,n,s,i,a,l,c,u;super("w:settings"),this.root.push(new hMt({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 We("w:displayBackgroundShape",!0)),e.trackRevisions!==void 0&&this.root.push(new We("w:trackRevisions",e.trackRevisions)),e.evenAndOddHeaders!==void 0&&this.root.push(new We("w:evenAndOddHeaders",e.evenAndOddHeaders)),e.updateFields!==void 0&&this.root.push(new We("w:updateFields",e.updateFields)),e.defaultTabStop!==void 0&&this.root.push(new q_("w:defaultTabStop",e.defaultTabStop)),((r=e.hyphenation)==null?void 0:r.autoHyphenation)!==void 0&&this.root.push(new We("w:autoHyphenation",e.hyphenation.autoHyphenation)),((n=e.hyphenation)==null?void 0:n.hyphenationZone)!==void 0&&this.root.push(new q_("w:hyphenationZone",e.hyphenation.hyphenationZone)),((s=e.hyphenation)==null?void 0:s.consecutiveHyphenLimit)!==void 0&&this.root.push(new q_("w:consecutiveHyphenLimit",e.hyphenation.consecutiveHyphenLimit)),((i=e.hyphenation)==null?void 0:i.doNotHyphenateCaps)!==void 0&&this.root.push(new We("w:doNotHyphenateCaps",e.hyphenation.doNotHyphenateCaps)),this.root.push(new dMt(bf(or({},(a=e.compatibility)!=null?a:{}),{version:(u=(c=(l=e.compatibility)==null?void 0:l.version)!=null?c:e.compatibilityModeVersion)!=null?u:15})))}}class Lke extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{val:"w:val"})}}class pMt extends Ae{constructor(e){super("w:name"),this.root.push(new Lke({val:e}))}}class mMt extends Ae{constructor(e){super("w:uiPriority"),this.root.push(new Lke({val:Ca(e)}))}}class gMt extends bt{constructor(){super(...arguments),Ee(this,"xmlKeys",{type:"w:type",styleId:"w:styleId",default:"w:default",customStyle:"w:customStyle"})}}class $ke extends Ae{constructor(e,r){super("w:style"),this.root.push(new gMt(e)),r.name&&this.root.push(new pMt(r.name)),r.basedOn&&this.root.push(new Im("w:basedOn",r.basedOn)),r.next&&this.root.push(new Im("w:next",r.next)),r.link&&this.root.push(new Im("w:link",r.link)),r.uiPriority!==void 0&&this.root.push(new mMt(r.uiPriority)),r.semiHidden!==void 0&&this.root.push(new We("w:semiHidden",r.semiHidden)),r.unhideWhenUsed!==void 0&&this.root.push(new We("w:unhideWhenUsed",r.unhideWhenUsed)),r.quickFormat!==void 0&&this.root.push(new We("w:qFormat",r.quickFormat))}}class s5 extends $ke{constructor(e){super({type:"paragraph",styleId:e.id},e),Ee(this,"paragraphProperties"),Ee(this,"runProperties"),this.paragraphProperties=new B1(e.paragraph),this.runProperties=new Bv(e.run),this.root.push(this.paragraphProperties),this.root.push(this.runProperties)}}class i5 extends $ke{constructor(e){super({type:"character",styleId:e.id},or({uiPriority:99,unhideWhenUsed:!0},e)),Ee(this,"runProperties"),this.runProperties=new Bv(e.run),this.root.push(this.runProperties)}}class vg extends s5{constructor(e){super(or({basedOn:"Normal",next:"Normal",quickFormat:!0},e))}}class xMt extends vg{constructor(e){super(or({id:"Title",name:"Title"},e))}}class yMt extends vg{constructor(e){super(or({id:"Heading1",name:"Heading 1"},e))}}class vMt extends vg{constructor(e){super(or({id:"Heading2",name:"Heading 2"},e))}}class bMt extends vg{constructor(e){super(or({id:"Heading3",name:"Heading 3"},e))}}class wMt extends vg{constructor(e){super(or({id:"Heading4",name:"Heading 4"},e))}}class jMt extends vg{constructor(e){super(or({id:"Heading5",name:"Heading 5"},e))}}class SMt extends vg{constructor(e){super(or({id:"Heading6",name:"Heading 6"},e))}}class _Mt extends vg{constructor(e){super(or({id:"Strong",name:"Strong"},e))}}class NMt extends s5{constructor(e){super(or({id:"ListParagraph",name:"List Paragraph",basedOn:"Normal",quickFormat:!0},e))}}class kMt extends s5{constructor(e){super(or({id:"FootnoteText",name:"footnote text",link:"FootnoteTextChar",basedOn:"Normal",uiPriority:99,semiHidden:!0,unhideWhenUsed:!0,paragraph:{spacing:{after:0,line:240,lineRule:KH.AUTO}},run:{size:20}},e))}}class CMt extends i5{constructor(e){super(or({id:"FootnoteReference",name:"footnote reference",basedOn:"DefaultParagraphFont",semiHidden:!0,run:{superScript:!0}},e))}}class EMt extends i5{constructor(e){super(or({id:"FootnoteTextChar",name:"Footnote Text Char",basedOn:"DefaultParagraphFont",link:"FootnoteText",semiHidden:!0,run:{size:20}},e))}}class AMt extends i5{constructor(e){super(or({id:"Hyperlink",name:"Hyperlink",basedOn:"DefaultParagraphFont",run:{color:"0563C1",underline:{type:xke.SINGLE}}},e))}}class XH extends Ae{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 s5(r));if(e.characterStyles)for(const r of e.characterStyles)this.root.push(new i5(r))}}class TMt extends Ae{constructor(e){super("w:pPrDefault"),this.root.push(new B1(e))}}class PMt extends Ae{constructor(e){super("w:rPrDefault"),this.root.push(new Bv(e))}}class IMt extends Ae{constructor(e){super("w:docDefaults"),Ee(this,"runPropertiesDefaults"),Ee(this,"paragraphPropertiesDefaults"),this.runPropertiesDefaults=new PMt(e.run),this.paragraphPropertiesDefaults=new TMt(e.paragraph),this.root.push(this.runPropertiesDefaults),this.root.push(this.paragraphPropertiesDefaults)}}class RMt{newInstance(e){const r=cke.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 XH({initialStyles:new rPt(n.attributes),importedStyles:s.map(a=>MG(a))})}}class Gae{newInstance(e={}){var r;return{initialStyles:new n5(["mc","r","w","w14","w15"],"w14 w15"),importedStyles:[new IMt((r=e.document)!=null?r:{}),new xMt(or({run:{size:56}},e.title)),new yMt(or({run:{color:"2E74B5",size:32}},e.heading1)),new vMt(or({run:{color:"2E74B5",size:26}},e.heading2)),new bMt(or({run:{color:"1F4D78",size:24}},e.heading3)),new wMt(or({run:{color:"2E74B5",italics:!0}},e.heading4)),new jMt(or({run:{color:"2E74B5"}},e.heading5)),new SMt(or({run:{color:"1F4D78"}},e.heading6)),new _Mt(or({run:{bold:!0}},e.strong)),new NMt(e.listParagraph||{}),new AMt(e.hyperlink||{}),new CMt(e.footnoteReference||{}),new kMt(e.footnoteText||{}),new EMt(e.footnoteTextChar||{})]}}}let OMt=class{constructor(e){Ee(this,"currentRelationshipId",1),Ee(this,"documentWrapper"),Ee(this,"headers",[]),Ee(this,"footers",[]),Ee(this,"coreProperties"),Ee(this,"numbering"),Ee(this,"media"),Ee(this,"fileRelationships"),Ee(this,"footnotesWrapper"),Ee(this,"settings"),Ee(this,"contentTypes"),Ee(this,"customProperties"),Ee(this,"appProperties"),Ee(this,"styles"),Ee(this,"comments"),Ee(this,"fontWrapper");var r,n,s,i,a,l,c,u,d,h,f,p;if(this.coreProperties=new yOt(bf(or({},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 lMt(e.numbering?e.numbering:{config:[]}),this.comments=new iRt((i=e.comments)!=null?i:{children:[]}),this.fileRelationships=new zv,this.customProperties=new _Ot((a=e.customProperties)!=null?a:[]),this.appProperties=new fOt,this.footnotesWrapper=new zOt,this.contentTypes=new xOt,this.documentWrapper=new Pke({background:e.background}),this.settings=new fMt({compatibilityModeVersion:e.compatabilityModeVersion,compatibility:e.compatibility,evenAndOddHeaders:!!e.evenAndOddHeaderAndFooters,trackRevisions:(l=e.features)==null?void 0:l.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 VOt,e.externalStyles!==void 0){const m=new RMt;this.styles=m.newInstance(e.externalStyles)}else if(e.styles){const g=new Gae().newInstance(e.styles.default);this.styles=new XH(or(or({},g),e.styles))}else{const m=new Gae;this.styles=new XH(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 EOt((p=e.fonts)!=null?p:[])}addSection({headers:e={},footers:r={},children:n,properties:s}){this.documentWrapper.View.Body.addSection(bf(or({},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 WOt(this.media,this.currentRelationshipId++);for(const n of e.options.children)r.add(n);return this.addHeaderToDocument(r),r}createFooter(e){const r=new POt(this.media,this.currentRelationshipId++);for(const n of e.options.children)r.add(n);return this.addFooterToDocument(r),r}addHeaderToDocument(e,r=k0.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=k0.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 MMt extends Ae{constructor(e={}){super("w:instrText"),Ee(this,"properties"),this.properties=e,this.root.push(new yv({space:xv.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 DMt extends Ae{constructor(){super("w:sdtContent")}}class LMt extends Ae{constructor(e){super("w:sdtPr"),e&&this.root.push(new Im("w:alias",e))}}class $Mt extends FG{constructor(e="Table of Contents",r){super("w:sdt"),this.root.push(new LMt(e));const n=new DMt,s=new Nr({children:[new Ym({children:[new d_(!0),new MMt(r),new h_]})]});n.addChildElement(s);const i=new Nr({children:[new Ym({children:[new f_]})]});n.addChildElement(i),this.root.push(n)}}class FMt{constructor(e={children:[]}){Ee(this,"options"),this.options=e}}class BMt{constructor(e={children:[]}){Ee(this,"options"),this.options=e}}var zMt=IG();function QT(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 $F={exports:{}},Kae;function UMt(){return Kae||(Kae=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 QT=="function"&&QT;if(!d&&h)return h(u,!0);if(l)return l(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 l=typeof QT=="function"&&QT,c=0;c<i.length;c++)a(i[c]);return a}({1:[function(r,n,s){var i=r("./utils"),a=r("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(c){for(var u,d,h,f,p,m,g,y=[],x=0,v=c.length,b=v,w=i.getTypeOf(c)!=="string";x<c.length;)b=v-x,h=w?(u=c[x++],d=x<v?c[x++]:0,x<v?c[x++]:0):(u=c.charCodeAt(x++),d=x<v?c.charCodeAt(x++):0,x<v?c.charCodeAt(x++):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,y.push(l.charAt(f)+l.charAt(p)+l.charAt(m)+l.charAt(g));return y.join("")},s.decode=function(c){var u,d,h,f,p,m,g=0,y=0,x="data:";if(c.substr(0,x.length)===x)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)===l.charAt(64)&&b--,c.charAt(c.length-2)===l.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=l.indexOf(c.charAt(g++))<<2|(f=l.indexOf(c.charAt(g++)))>>4,d=(15&f)<<4|(p=l.indexOf(c.charAt(g++)))>>2,h=(3&p)<<6|(m=l.indexOf(c.charAt(g++))),v[y++]=u,p!==64&&(v[y++]=d),m!==64&&(v[y++]=h);return v}},{"./support":30,"./utils":32}],2:[function(r,n,s){var i=r("./external"),a=r("./stream/DataWorker"),l=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 l).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 l,c=[],u=0;u<256;u++){l=u;for(var d=0;d<8;d++)l=1&l?3988292384^l>>>1:l>>>1;c[u]=l}return c}();n.exports=function(l,c){return l!==void 0&&l.length?i.getTypeOf(l)!=="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,l,l.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,l,l.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"),l=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",l.inherits(d,c),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(l.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,y="";for(g=0;g<m;g++)y+=String.fromCharCode(255&p),p>>>=8;return y}function a(p,m,g,y,x,v){var b,w,j=p.file,N=p.compression,C=v!==u.utf8encode,A=l.transformTo("string",v(j.name)),E=l.transformTo("string",u.utf8encode(j.name)),O=j.comment,$=l.transformTo("string",v(O)),T=l.transformTo("string",u.utf8encode(O)),M=E.length!==j.name.length,k=T.length!==O.length,D="",K="",H="",ee=j.dir,V=j.date,B={crc32:0,compressedSize:0,uncompressedSize:0};m&&!g||(B.crc32=p.crc32,B.compressedSize=p.compressedSize,B.uncompressedSize=p.uncompressedSize);var z=0;m&&(z|=8),C||!M&&!k||(z|=2048);var F=0,G=0;ee&&(F|=16),x==="UNIX"?(G=798,F|=function(ie,se){var q=ie;return ie||(q=se?16893:33204),(65535&q)<<16}(j.unixPermissions,ee)):(G=20,F|=function(ie){return 63&(ie||0)}(j.dosPermissions)),b=V.getUTCHours(),b<<=6,b|=V.getUTCMinutes(),b<<=5,b|=V.getUTCSeconds()/2,w=V.getUTCFullYear()-1980,w<<=4,w|=V.getUTCMonth()+1,w<<=5,w|=V.getUTCDate(),M&&(K=i(1,1)+i(d(A),4)+E,D+="up"+i(K.length,2)+K),k&&(H=i(1,1)+i(d($),4)+T,D+="uc"+i(H.length,2)+H);var Q="";return Q+=`
\0`,Q+=i(z,2),Q+=N.magic,Q+=i(b,2),Q+=i(w,2),Q+=i(B.crc32,4),Q+=i(B.compressedSize,4),Q+=i(B.uncompressedSize,4),Q+=i(A.length,2),Q+=i(D.length,2),{fileRecord:h.LOCAL_FILE_HEADER+Q+A+D,dirRecord:h.CENTRAL_FILE_HEADER+i(G,2)+Q+i($.length,2)+"\0\0\0\0"+i(F,4)+i(y,4)+A+D+$}}var l=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),d=r("../crc32"),h=r("../signature");function f(p,m,g,y){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=g,this.encodeFileName=y,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(f,c),f.prototype.push=function(p){var m=p.meta.percent||0,g=this.entriesCount,y=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-y-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(y){return h.DATA_DESCRIPTOR+i(y.crc32,4)+i(y.compressedSize,4)+i(y.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,y=function(x,v,b,w,j){var N=l.transformTo("string",j(w));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(x,2)+i(x,2)+i(v,4)+i(b,4)+i(N.length,2)+N}(this.dirRecords.length,g,p,this.zipComment,this.encodeFileName);this.push({data:y,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(l,c,u){var d=new a(c.streamFiles,u,c.platform,c.encodeFileName),h=0;try{l.forEach(function(f,p){h++;var m=function(v,b){var w=v||b,j=i[w];if(!j)throw new Error(w+" is not a valid compression method !");return j}(p.options.compression,c.compression),g=p.options.compressionOptions||c.compressionOptions||{},y=p.dir,x=p.date;p._compressWorker(m,g).withStreamInfo("file",{name:f,dir:y,date:x,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 l in this)typeof this[l]!="function"&&(a[l]=this[l]);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,l){return new i().loadAsync(a,l)},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"),l=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(y){m(y)}).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:l.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 y=new c(p);return y.load(g),y}).then(function(g){var y=[a.Promise.resolve(g)],x=g.files;if(p.checkCRC32)for(var v=0;v<x.length;v++)y.push(h(x[v]));return a.Promise.all(y)}).then(function(g){for(var y=g.shift(),x=y.files,v=0;v<x.length;v++){var b=x[v],w=b.fileNameStr,j=i.resolve(b.fileNameStr);m.file(j,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(j).unsafeOriginalName=w)}return y.zipComment.length&&(m.comment=y.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 l(c,u){a.call(this,"Nodejs stream input adapter for "+c),this._upstreamEnded=!1,this._bindStream(u)}i.inherits(l,a),l.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()})},l.prototype.pause=function(){return!!a.prototype.pause.call(this)&&(this._stream.pause(),!0)},l.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=l},{"../stream/GenericWorker":28,"../utils":32}],13:[function(r,n,s){var i=r("readable-stream").Readable;function a(l,c,u){i.call(this,c),this._helper=l;var d=this;l.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(j,N,C){var A,E=l.getTypeOf(N),O=l.extend(C||{},d);O.date=O.date||new Date,O.compression!==null&&(O.compression=O.compression.toUpperCase()),typeof O.unixPermissions=="string"&&(O.unixPermissions=parseInt(O.unixPermissions,8)),O.unixPermissions&&16384&O.unixPermissions&&(O.dir=!0),O.dosPermissions&&16&O.dosPermissions&&(O.dir=!0),O.dir&&(j=x(j)),O.createFolders&&(A=y(j))&&v.call(this,A,!0);var $=E==="string"&&O.binary===!1&&O.base64===!1;C&&C.binary!==void 0||(O.binary=!$),(N instanceof h&&N.uncompressedSize===0||O.dir||!N||N.length===0)&&(O.base64=!1,O.binary=!0,N="",O.compression="STORE",E="string");var T=null;T=N instanceof h||N instanceof c?N:m.isNode&&m.isStream(N)?new g(j,N):l.prepareContent(j,N,O.binary,O.optimizedBinaryString,O.base64);var M=new f(j,T,O);this.files[j]=M}var a=r("./utf8"),l=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"),y=function(j){j.slice(-1)==="/"&&(j=j.substring(0,j.length-1));var N=j.lastIndexOf("/");return 0<N?j.substring(0,N):""},x=function(j){return j.slice(-1)!=="/"&&(j+="/"),j},v=function(j,N){return N=N!==void 0?N:d.createFolders,j=x(j),this.files[j]||i.call(this,j,null,{dir:!0,createFolders:N}),this.files[j]};function b(j){return Object.prototype.toString.call(j)==="[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(j){var N,C,A;for(N in this.files)A=this.files[N],(C=N.slice(this.root.length,N.length))&&N.slice(0,this.root.length)===this.root&&j(C,A)},filter:function(j){var N=[];return this.forEach(function(C,A){j(C,A)&&N.push(A)}),N},file:function(j,N,C){if(arguments.length!==1)return j=this.root+j,i.call(this,j,N,C),this;if(b(j)){var A=j;return this.filter(function(O,$){return!$.dir&&A.test(O)})}var E=this.files[this.root+j];return E&&!E.dir?E:null},folder:function(j){if(!j)return this;if(b(j))return this.filter(function(E,O){return O.dir&&j.test(E)});var N=this.root+j,C=v.call(this,N),A=this.clone();return A.root=C.name,A},remove:function(j){j=this.root+j;var N=this.files[j];if(N||(j.slice(-1)!=="/"&&(j+="/"),N=this.files[j]),N&&!N.dir)delete this.files[j];else for(var C=this.filter(function(E,O){return O.name.slice(0,j.length)===j}),A=0;A<C.length;A++)delete this.files[C[A].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(j){var N,C={};try{if((C=l.extend(j||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:a.utf8encode})).type=C.type.toLowerCase(),C.compression=C.compression.toUpperCase(),C.type==="binarystring"&&(C.type="string"),!C.type)throw new Error("No output type specified.");l.checkSupport(C.type),C.platform!=="darwin"&&C.platform!=="freebsd"&&C.platform!=="linux"&&C.platform!=="sunos"||(C.platform="UNIX"),C.platform==="win32"&&(C.platform="DOS");var A=C.comment||this.comment||"";N=p.generateWorker(this,C,A)}catch(E){(N=new c("error")).error(E)}return new u(N,C.type||"string",C.mimeType)},generateAsync:function(j,N){return this.generateInternalStream(j).accumulate(N)},generateNodeStream:function(j,N){return(j=j||{}).type||(j.type="nodebuffer"),this.generateInternalStream(j).toNodejsStream(N)}};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(l){i.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}r("../utils").inherits(a,i),a.prototype.byteAt=function(l){return this.data[this.zero+l]},a.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=l.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(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=l.charCodeAt(3),f=this.readData(4);return c===f[0]&&u===f[1]&&d===f[2]&&h===f[3]},a.prototype.readData=function(l){if(this.checkOffset(l),l===0)return[];var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},n.exports=a},{"../utils":32,"./DataReader":18}],18:[function(r,n,s){var i=r("../utils");function a(l){this.data=l,this.length=l.length,this.index=0,this.zero=0}a.prototype={checkOffset:function(l){this.checkIndex(this.index+l)},checkIndex:function(l){if(this.length<this.zero+l||l<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+l+"). Corrupted zip ?")},setIndex:function(l){this.checkIndex(l),this.index=l},skip:function(l){this.setIndex(this.index+l)},byteAt:function(){},readInt:function(l){var c,u=0;for(this.checkOffset(l),c=this.index+l-1;c>=this.index;c--)u=(u<<8)+this.byteAt(c);return this.index+=l,u},readString:function(l){return i.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},n.exports=a},{"../utils":32}],19:[function(r,n,s){var i=r("./Uint8ArrayReader");function a(l){i.call(this,l)}r("../utils").inherits(a,i),a.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},n.exports=a},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,n,s){var i=r("./DataReader");function a(l){i.call(this,l)}r("../utils").inherits(a,i),a.prototype.byteAt=function(l){return this.data.charCodeAt(this.zero+l)},a.prototype.lastIndexOfSignature=function(l){return this.data.lastIndexOf(l)-this.zero},a.prototype.readAndCheckSignature=function(l){return l===this.readData(4)},a.prototype.readData=function(l){this.checkOffset(l);var c=this.data.slice(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},n.exports=a},{"../utils":32,"./DataReader":18}],21:[function(r,n,s){var i=r("./ArrayReader");function a(l){i.call(this,l)}r("../utils").inherits(a,i),a.prototype.readData=function(l){if(this.checkOffset(l),l===0)return new Uint8Array(0);var c=this.data.subarray(this.zero+this.index,this.zero+this.index+l);return this.index+=l,c},n.exports=a},{"../utils":32,"./ArrayReader":17}],22:[function(r,n,s){var i=r("../utils"),a=r("../support"),l=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 l(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 l(c){i.call(this,"ConvertWorker to "+c),this.destType=c}a.inherits(l,i),l.prototype.processChunk=function(c){this.push({data:a.transformTo(this.destType,c.data),meta:c.meta})},n.exports=l},{"../utils":32,"./GenericWorker":28}],25:[function(r,n,s){var i=r("./GenericWorker"),a=r("../crc32");function l(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(l,i),l.prototype.processChunk=function(c){this.streamInfo.crc32=a(c.data,this.streamInfo.crc32||0),this.push(c)},n.exports=l},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,n,s){var i=r("../utils"),a=r("./GenericWorker");function l(c){a.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}i.inherits(l,a),l.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=l},{"../utils":32,"./GenericWorker":28}],27:[function(r,n,s){var i=r("../utils"),a=r("./GenericWorker");function l(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(l,a),l.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this.data=null},l.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.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=l},{"../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,l){return this._listeners[a].push(l),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,l){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,l)},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 l=this;return a.on("data",function(c){l.processChunk(c)}),a.on("end",function(){l.end()}),a.on("error",function(c){l.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,l){return this.extraStreamInfo[a]=l,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"),l=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(y,x){var v=[],b=m._internalType,w=m._outputType,j=m._mimeType;m.on("data",function(N,C){v.push(N),g&&g(C)}).on("error",function(N){v=[],x(N)}).on("end",function(){try{var N=function(C,A,E){switch(C){case"blob":return i.newBlob(i.transformTo("arraybuffer",A),E);case"base64":return c.encode(A);default:return i.transformTo(C,A)}}(w,function(C,A){var E,O=0,$=null,T=0;for(E=0;E<A.length;E++)T+=A[E].length;switch(C){case"string":return A.join("");case"array":return Array.prototype.concat.apply([],A);case"uint8array":for($=new Uint8Array(T),E=0;E<A.length;E++)$.set(A[E],O),O+=A[E].length;return $;case"nodebuffer":return Buffer.concat(A);default:throw new Error("concat : unsupported type '"+C+"'")}}(b,v),j);y(N)}catch(C){x(C)}v=[]}).resume()})}function p(m,g,y){var x=g;switch(g){case"blob":case"arraybuffer":x="uint8array";break;case"base64":x="string"}try{this._internalType=x,this._outputType=g,this._mimeType=y,i.checkSupport(x),this._worker=m.pipe(new a(x)),m.lock()}catch(v){this._worker=new l("error"),this._worker.error(v)}}p.prototype={accumulate:function(m){return f(this,m)},on:function(m,g){var y=this;return m==="data"?this._worker.on(m,function(x){g.call(y,x.data,x.meta)}):this._worker.on(m,function(){i.delay(g,arguments,y)}),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"),l=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?l.newBufferFrom(p,"utf-8"):function(m){var g,y,x,v,b,w=m.length,j=0;for(v=0;v<w;v++)(64512&(y=m.charCodeAt(v)))==55296&&v+1<w&&(64512&(x=m.charCodeAt(v+1)))==56320&&(y=65536+(y-55296<<10)+(x-56320),v++),j+=y<128?1:y<2048?2:y<65536?3:4;for(g=a.uint8array?new Uint8Array(j):new Array(j),v=b=0;b<j;v++)(64512&(y=m.charCodeAt(v)))==55296&&v+1<w&&(64512&(x=m.charCodeAt(v+1)))==56320&&(y=65536+(y-55296<<10)+(x-56320),v++),y<128?g[b++]=y:(y<2048?g[b++]=192|y>>>6:(y<65536?g[b++]=224|y>>>12:(g[b++]=240|y>>>18,g[b++]=128|y>>>12&63),g[b++]=128|y>>>6&63),g[b++]=128|63&y);return g}(p)},s.utf8decode=function(p){return a.nodebuffer?i.transformTo("nodebuffer",p).toString("utf-8"):function(m){var g,y,x,v,b=m.length,w=new Array(2*b);for(g=y=0;g<b;)if((x=m[g++])<128)w[y++]=x;else if(4<(v=u[x]))w[y++]=65533,g+=v-1;else{for(x&=v===2?31:v===3?15:7;1<v&&g<b;)x=x<<6|63&m[g++],v--;1<v?w[y++]=65533:x<65536?w[y++]=x:(x-=65536,w[y++]=55296|x>>10&1023,w[y++]=56320|1023&x)}return w.length!==y&&(w.subarray?w=w.subarray(0,y):w.length=y),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 y=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),x=m;y!==m.length&&(a.uint8array?(x=m.subarray(0,y),this.leftOver=m.subarray(y,m.length)):(x=m.slice(0,y),this.leftOver=m.slice(y,m.length))),this.push({data:s.utf8decode(x),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"),l=r("./nodejsUtils"),c=r("./external");function u(g){return g}function d(g,y){for(var x=0;x<g.length;++x)y[x]=255&g.charCodeAt(x);return y}r("setimmediate"),s.newBlob=function(g,y){s.checkSupport("blob");try{return new Blob([g],{type:y})}catch{try{var x=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return x.append(g),x.getBlob(y)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,y,x){var v=[],b=0,w=g.length;if(w<=x)return String.fromCharCode.apply(null,g);for(;b<w;)y==="array"||y==="nodebuffer"?v.push(String.fromCharCode.apply(null,g.slice(b,Math.min(b+x,w)))):v.push(String.fromCharCode.apply(null,g.subarray(b,Math.min(b+x,w)))),b+=x;return v.join("")},stringifyByChar:function(g){for(var y="",x=0;x<g.length;x++)y+=String.fromCharCode(g[x]);return y},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,l.allocBuffer(1)).length===1}catch{return!1}}()}};function f(g){var y=65536,x=s.getTypeOf(g),v=!0;if(x==="uint8array"?v=h.applyCanBeUsed.uint8array:x==="nodebuffer"&&(v=h.applyCanBeUsed.nodebuffer),v)for(;1<y;)try{return h.stringifyByChunk(g,x,y)}catch{y=Math.floor(y/2)}return h.stringifyByChar(g)}function p(g,y){for(var x=0;x<g.length;x++)y[x]=g[x];return y}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,l.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 l.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 l.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 l.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,y){if(y=y||"",!g)return y;s.checkSupport(g);var x=s.getTypeOf(y);return m[x][g](y)},s.resolve=function(g){for(var y=g.split("/"),x=[],v=0;v<y.length;v++){var b=y[v];b==="."||b===""&&v!==0&&v!==y.length-1||(b===".."?x.pop():x.push(b))}return x.join("/")},s.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":i.nodebuffer&&l.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 y,x,v="";for(x=0;x<(g||"").length;x++)v+="\\x"+((y=g.charCodeAt(x))<16?"0":"")+y.toString(16).toUpperCase();return v},s.delay=function(g,y,x){setImmediate(function(){g.apply(x||null,y||[])})},s.inherits=function(g,y){function x(){}x.prototype=y.prototype,g.prototype=new x},s.extend=function(){var g,y,x={};for(g=0;g<arguments.length;g++)for(y in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],y)&&x[y]===void 0&&(x[y]=arguments[g][y]);return x},s.prepareContent=function(g,y,x,v,b){return c.Promise.resolve(y).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(j,N){var C=new FileReader;C.onload=function(A){j(A.target.result)},C.onerror=function(A){N(A.target.error)},C.readAsArrayBuffer(w)}):w}).then(function(w){var j=s.getTypeOf(w);return j?(j==="arraybuffer"?w=s.transformTo("uint8array",w):j==="string"&&(b?w=a.decode(w):x&&v!==!0&&(w=function(N){return d(N,i.uint8array?new Uint8Array(N.length):new Array(N.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"),l=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(l.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.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(l.CENTRAL_DIRECTORY_END);if(h<0)throw this.isSignature(0,l.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(l.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(l.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(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.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(l.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,l.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"),l=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(y){for(var x in d)if(Object.prototype.hasOwnProperty.call(d,x)&&d[x].magic===y)return d[x];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 l(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,y,x=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<x;)m=p.readInt(2),g=p.readInt(2),y=p.readData(g),this.extraFields[m]={id:m,length:g,value:y};p.setIndex(x)},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 y=this.findExtraFieldUnicodeComment();if(y!==null)this.fileCommentStr=y;else{var x=a.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(x)}}},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,y){this.name=m,this.dir=y.dir,this.date=y.date,this.comment=y.comment,this.unixPermissions=y.unixPermissions,this.dosPermissions=y.dosPermissions,this._data=g,this._dataBinary=y.binary,this.options={compression:y.compression,compressionOptions:y.compressionOptions}}var a=r("./stream/StreamHelper"),l=r("./stream/DataWorker"),c=r("./utf8"),u=r("./compressedObject"),d=r("./stream/GenericWorker");i.prototype={internalStream:function(m){var g=null,y="string";try{if(!m)throw new Error("No output type specified.");var x=(y=m.toLowerCase())==="string"||y==="text";y!=="binarystring"&&y!=="text"||(y="string"),g=this._decompressWorker();var v=!this._dataBinary;v&&!x&&(g=g.pipe(new c.Utf8EncodeWorker)),!v&&x&&(g=g.pipe(new c.Utf8DecodeWorker))}catch(b){(g=new d("error")).error(b)}return new a(g,y,"")},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 y=this._decompressWorker();return this._dataBinary||(y=y.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(y,m,g)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(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,l,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,y;l=!0;for(var x=p.length;x;){for(y=p,p=[],g=-1;++g<x;)y[g]();x=p.length}l=!1}n.exports=function(g){p.push(g)!==1||l||a()}}).call(this,typeof td<"u"?td:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(r,n,s){var i=r("immediate");function a(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function h(x){if(typeof x!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,x!==a&&g(this,x)}function f(x,v,b){this.promise=x,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function p(x,v,b){i(function(){var w;try{w=v(b)}catch(j){return l.reject(x,j)}w===x?l.reject(x,new TypeError("Cannot resolve promise with itself")):l.resolve(x,w)})}function m(x){var v=x&&x.then;if(x&&(typeof x=="object"||typeof x=="function")&&typeof v=="function")return function(){v.apply(x,arguments)}}function g(x,v){var b=!1;function w(C){b||(b=!0,l.reject(x,C))}function j(C){b||(b=!0,l.resolve(x,C))}var N=y(function(){v(j,w)});N.status==="error"&&w(N.value)}function y(x,v){var b={};try{b.value=x(v),b.status="success"}catch(w){b.status="error",b.value=w}return b}(n.exports=h).prototype.finally=function(x){if(typeof x!="function")return this;var v=this.constructor;return this.then(function(b){return v.resolve(x()).then(function(){return b})},function(b){return v.resolve(x()).then(function(){throw b})})},h.prototype.catch=function(x){return this.then(null,x)},h.prototype.then=function(x,v){if(typeof x!="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?x:v,this.outcome):this.queue.push(new f(b,x,v)),b},f.prototype.callFulfilled=function(x){l.resolve(this.promise,x)},f.prototype.otherCallFulfilled=function(x){p(this.promise,this.onFulfilled,x)},f.prototype.callRejected=function(x){l.reject(this.promise,x)},f.prototype.otherCallRejected=function(x){p(this.promise,this.onRejected,x)},l.resolve=function(x,v){var b=y(m,v);if(b.status==="error")return l.reject(x,b.value);var w=b.value;if(w)g(x,w);else{x.state=u,x.outcome=v;for(var j=-1,N=x.queue.length;++j<N;)x.queue[j].callFulfilled(v)}return x},l.reject=function(x,v){x.state=c,x.outcome=v;for(var b=-1,w=x.queue.length;++b<w;)x.queue[b].callRejected(v);return x},h.resolve=function(x){return x instanceof this?x:l.resolve(new this(a),x)},h.reject=function(x){var v=new this(a);return l.reject(v,x)},h.all=function(x){var v=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=x.length,w=!1;if(!b)return this.resolve([]);for(var j=new Array(b),N=0,C=-1,A=new this(a);++C<b;)E(x[C],C);return A;function E(O,$){v.resolve(O).then(function(T){j[$]=T,++N!==b||w||(w=!0,l.resolve(A,j))},function(T){w||(w=!0,l.reject(A,T))})}},h.race=function(x){var v=this;if(Object.prototype.toString.call(x)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=x.length,w=!1;if(!b)return this.resolve([]);for(var j=-1,N=new this(a);++j<b;)C=x[j],v.resolve(C).then(function(A){w||(w=!0,l.resolve(N,A))},function(A){w||(w=!0,l.reject(N,A))});var C;return N}},{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"),l=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(x){if(!(this instanceof g))return new g(x);this.options=a.assign({level:f,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},x||{});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"?l.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 y(x,v){var b=new g(v);if(b.push(x,!0),b.err)throw b.msg||c[b.err];return b.result}g.prototype.push=function(x,v){var b,w,j=this.strm,N=this.options.chunkSize;if(this.ended)return!1;w=v===~~v?v:v===!0?4:0,typeof x=="string"?j.input=l.string2buf(x):d.call(x)==="[object ArrayBuffer]"?j.input=new Uint8Array(x):j.input=x,j.next_in=0,j.avail_in=j.input.length;do{if(j.avail_out===0&&(j.output=new a.Buf8(N),j.next_out=0,j.avail_out=N),(b=i.deflate(j,w))!==1&&b!==h)return this.onEnd(b),!(this.ended=!0);j.avail_out!==0&&(j.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(a.shrinkBuf(j.output,j.next_out))):this.onData(a.shrinkBuf(j.output,j.next_out)))}while((0<j.avail_in||j.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),!(j.avail_out=0))},g.prototype.onData=function(x){this.chunks.push(x)},g.prototype.onEnd=function(x){x===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=a.flattenChunks(this.chunks)),this.chunks=[],this.err=x,this.msg=this.strm.msg},s.Deflate=g,s.deflate=y,s.deflateRaw=function(x,v){return(v=v||{}).raw=!0,y(x,v)},s.gzip=function(x,v){return(v=v||{}).gzip=!0,y(x,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"),l=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 y=this.options;y.raw&&0<=y.windowBits&&y.windowBits<16&&(y.windowBits=-y.windowBits,y.windowBits===0&&(y.windowBits=-15)),!(0<=y.windowBits&&y.windowBits<16)||g&&g.windowBits||(y.windowBits+=32),15<y.windowBits&&y.windowBits<48&&!(15&y.windowBits)&&(y.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var x=i.inflateInit2(this.strm,y.windowBits);if(x!==c.Z_OK)throw new Error(u[x]);this.header=new h,i.inflateGetHeader(this.strm,this.header)}function m(g,y){var x=new p(y);if(x.push(g,!0),x.err)throw x.msg||u[x.err];return x.result}p.prototype.push=function(g,y){var x,v,b,w,j,N,C=this.strm,A=this.options.chunkSize,E=this.options.dictionary,O=!1;if(this.ended)return!1;v=y===~~y?y:y===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof g=="string"?C.input=l.binstring2buf(g):f.call(g)==="[object ArrayBuffer]"?C.input=new Uint8Array(g):C.input=g,C.next_in=0,C.avail_in=C.input.length;do{if(C.avail_out===0&&(C.output=new a.Buf8(A),C.next_out=0,C.avail_out=A),(x=i.inflate(C,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&E&&(N=typeof E=="string"?l.string2buf(E):f.call(E)==="[object ArrayBuffer]"?new Uint8Array(E):E,x=i.inflateSetDictionary(this.strm,N)),x===c.Z_BUF_ERROR&&O===!0&&(x=c.Z_OK,O=!1),x!==c.Z_STREAM_END&&x!==c.Z_OK)return this.onEnd(x),!(this.ended=!0);C.next_out&&(C.avail_out!==0&&x!==c.Z_STREAM_END&&(C.avail_in!==0||v!==c.Z_FINISH&&v!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=l.utf8border(C.output,C.next_out),w=C.next_out-b,j=l.buf2string(C.output,b),C.next_out=w,C.avail_out=A-w,w&&a.arraySet(C.output,C.output,b,w,0),this.onData(j)):this.onData(a.shrinkBuf(C.output,C.next_out)))),C.avail_in===0&&C.avail_out===0&&(O=!0)}while((0<C.avail_in||C.avail_out===0)&&x!==c.Z_STREAM_END);return x===c.Z_STREAM_END&&(v=c.Z_FINISH),v===c.Z_FINISH?(x=i.inflateEnd(this.strm),this.onEnd(x),this.ended=!0,x===c.Z_OK):v!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(C.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,y){return(y=y||{}).raw=!0,m(g,y)},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}},l={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,l))},s.setTyped(i)},{}],42:[function(r,n,s){var i=r("./common"),a=!0,l=!0;try{String.fromCharCode.apply(null,[0])}catch{a=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{l=!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&&l||!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,y,x=h.length,v=0;for(g=0;g<x;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<x&&(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=y=0;y<v;g++)(64512&(p=h.charCodeAt(g)))==55296&&g+1<x&&(64512&(m=h.charCodeAt(g+1)))==56320&&(p=65536+(p-55296<<10)+(m-56320),g++),p<128?f[y++]=p:(p<2048?f[y++]=192|p>>>6:(p<65536?f[y++]=224|p>>>12:(f[y++]=240|p>>>18,f[y++]=128|p>>>12&63),f[y++]=128|p>>>6&63),f[y++]=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,y,x=f||h.length,v=new Array(2*x);for(p=m=0;p<x;)if((g=h[p++])<128)v[m++]=g;else if(4<(y=c[g]))v[m++]=65533,p+=y-1;else{for(g&=y===2?31:y===3?15:7;1<y&&p<x;)g=g<<6|63&h[p++],y--;1<y?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,l,c){for(var u=65535&i|0,d=i>>>16&65535|0,h=0;l!==0;){for(l-=h=2e3<l?2e3:l;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,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();n.exports=function(a,l,c,u){var d=i,h=u+c;a^=-1;for(var f=u;f<h;f++)a=a>>>8^d[255&(a^l[f])];return-1^a}},{}],46:[function(r,n,s){var i,a=r("../utils/common"),l=r("./trees"),c=r("./adler32"),u=r("./crc32"),d=r("./messages"),h=0,f=4,p=0,m=-2,g=-1,y=4,x=2,v=8,b=9,w=286,j=30,N=19,C=2*w+1,A=15,E=3,O=258,$=O+E+1,T=42,M=113,k=1,D=2,K=3,H=4;function ee(P,oe){return P.msg=d[oe],oe}function V(P){return(P<<1)-(4<P?9:0)}function B(P){for(var oe=P.length;0<=--oe;)P[oe]=0}function z(P){var oe=P.state,Y=oe.pending;Y>P.avail_out&&(Y=P.avail_out),Y!==0&&(a.arraySet(P.output,oe.pending_buf,oe.pending_out,Y,P.next_out),P.next_out+=Y,oe.pending_out+=Y,P.total_out+=Y,P.avail_out-=Y,oe.pending-=Y,oe.pending===0&&(oe.pending_out=0))}function F(P,oe){l._tr_flush_block(P,0<=P.block_start?P.block_start:-1,P.strstart-P.block_start,oe),P.block_start=P.strstart,z(P.strm)}function G(P,oe){P.pending_buf[P.pending++]=oe}function Q(P,oe){P.pending_buf[P.pending++]=oe>>>8&255,P.pending_buf[P.pending++]=255&oe}function ie(P,oe){var Y,R,I=P.max_chain_length,U=P.strstart,re=P.prev_length,ue=P.nice_match,ae=P.strstart>P.w_size-$?P.strstart-(P.w_size-$):0,ge=P.window,we=P.w_mask,ce=P.prev,ne=P.strstart+O,fe=ge[U+re-1],be=ge[U+re];P.prev_length>=P.good_match&&(I>>=2),ue>P.lookahead&&(ue=P.lookahead);do if(ge[(Y=oe)+re]===be&&ge[Y+re-1]===fe&&ge[Y]===ge[U]&&ge[++Y]===ge[U+1]){U+=2,Y++;do;while(ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&ge[++U]===ge[++Y]&&U<ne);if(R=O-(ne-U),U=ne-O,re<R){if(P.match_start=oe,ue<=(re=R))break;fe=ge[U+re-1],be=ge[U+re]}}while((oe=ce[oe&we])>ae&&--I!=0);return re<=P.lookahead?re:P.lookahead}function se(P){var oe,Y,R,I,U,re,ue,ae,ge,we,ce=P.w_size;do{if(I=P.window_size-P.lookahead-P.strstart,P.strstart>=ce+(ce-$)){for(a.arraySet(P.window,P.window,ce,ce,0),P.match_start-=ce,P.strstart-=ce,P.block_start-=ce,oe=Y=P.hash_size;R=P.head[--oe],P.head[oe]=ce<=R?R-ce:0,--Y;);for(oe=Y=ce;R=P.prev[--oe],P.prev[oe]=ce<=R?R-ce:0,--Y;);I+=ce}if(P.strm.avail_in===0)break;if(re=P.strm,ue=P.window,ae=P.strstart+P.lookahead,ge=I,we=void 0,we=re.avail_in,ge<we&&(we=ge),Y=we===0?0:(re.avail_in-=we,a.arraySet(ue,re.input,re.next_in,we,ae),re.state.wrap===1?re.adler=c(re.adler,ue,we,ae):re.state.wrap===2&&(re.adler=u(re.adler,ue,we,ae)),re.next_in+=we,re.total_in+=we,we),P.lookahead+=Y,P.lookahead+P.insert>=E)for(U=P.strstart-P.insert,P.ins_h=P.window[U],P.ins_h=(P.ins_h<<P.hash_shift^P.window[U+1])&P.hash_mask;P.insert&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[U+E-1])&P.hash_mask,P.prev[U&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=U,U++,P.insert--,!(P.lookahead+P.insert<E)););}while(P.lookahead<$&&P.strm.avail_in!==0)}function q(P,oe){for(var Y,R;;){if(P.lookahead<$){if(se(P),P.lookahead<$&&oe===h)return k;if(P.lookahead===0)break}if(Y=0,P.lookahead>=E&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+E-1])&P.hash_mask,Y=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),Y!==0&&P.strstart-Y<=P.w_size-$&&(P.match_length=ie(P,Y)),P.match_length>=E)if(R=l._tr_tally(P,P.strstart-P.match_start,P.match_length-E),P.lookahead-=P.match_length,P.match_length<=P.max_lazy_match&&P.lookahead>=E){for(P.match_length--;P.strstart++,P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+E-1])&P.hash_mask,Y=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart,--P.match_length!=0;);P.strstart++}else P.strstart+=P.match_length,P.match_length=0,P.ins_h=P.window[P.strstart],P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+1])&P.hash_mask;else R=l._tr_tally(P,0,P.window[P.strstart]),P.lookahead--,P.strstart++;if(R&&(F(P,!1),P.strm.avail_out===0))return k}return P.insert=P.strstart<E-1?P.strstart:E-1,oe===f?(F(P,!0),P.strm.avail_out===0?K:H):P.last_lit&&(F(P,!1),P.strm.avail_out===0)?k:D}function L(P,oe){for(var Y,R,I;;){if(P.lookahead<$){if(se(P),P.lookahead<$&&oe===h)return k;if(P.lookahead===0)break}if(Y=0,P.lookahead>=E&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+E-1])&P.hash_mask,Y=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),P.prev_length=P.match_length,P.prev_match=P.match_start,P.match_length=E-1,Y!==0&&P.prev_length<P.max_lazy_match&&P.strstart-Y<=P.w_size-$&&(P.match_length=ie(P,Y),P.match_length<=5&&(P.strategy===1||P.match_length===E&&4096<P.strstart-P.match_start)&&(P.match_length=E-1)),P.prev_length>=E&&P.match_length<=P.prev_length){for(I=P.strstart+P.lookahead-E,R=l._tr_tally(P,P.strstart-1-P.prev_match,P.prev_length-E),P.lookahead-=P.prev_length-1,P.prev_length-=2;++P.strstart<=I&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+E-1])&P.hash_mask,Y=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),--P.prev_length!=0;);if(P.match_available=0,P.match_length=E-1,P.strstart++,R&&(F(P,!1),P.strm.avail_out===0))return k}else if(P.match_available){if((R=l._tr_tally(P,0,P.window[P.strstart-1]))&&F(P,!1),P.strstart++,P.lookahead--,P.strm.avail_out===0)return k}else P.match_available=1,P.strstart++,P.lookahead--}return P.match_available&&(R=l._tr_tally(P,0,P.window[P.strstart-1]),P.match_available=0),P.insert=P.strstart<E-1?P.strstart:E-1,oe===f?(F(P,!0),P.strm.avail_out===0?K:H):P.last_lit&&(F(P,!1),P.strm.avail_out===0)?k:D}function Z(P,oe,Y,R,I){this.good_length=P,this.max_lazy=oe,this.nice_length=Y,this.max_chain=R,this.func=I}function J(){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*C),this.dyn_dtree=new a.Buf16(2*(2*j+1)),this.bl_tree=new a.Buf16(2*(2*N+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(A+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 W(P){var oe;return P&&P.state?(P.total_in=P.total_out=0,P.data_type=x,(oe=P.state).pending=0,oe.pending_out=0,oe.wrap<0&&(oe.wrap=-oe.wrap),oe.status=oe.wrap?T:M,P.adler=oe.wrap===2?0:1,oe.last_flush=h,l._tr_init(oe),p):ee(P,m)}function X(P){var oe=W(P);return oe===p&&function(Y){Y.window_size=2*Y.w_size,B(Y.head),Y.max_lazy_match=i[Y.level].max_lazy,Y.good_match=i[Y.level].good_length,Y.nice_match=i[Y.level].nice_length,Y.max_chain_length=i[Y.level].max_chain,Y.strstart=0,Y.block_start=0,Y.lookahead=0,Y.insert=0,Y.match_length=Y.prev_length=E-1,Y.match_available=0,Y.ins_h=0}(P.state),oe}function he(P,oe,Y,R,I,U){if(!P)return m;var re=1;if(oe===g&&(oe=6),R<0?(re=0,R=-R):15<R&&(re=2,R-=16),I<1||b<I||Y!==v||R<8||15<R||oe<0||9<oe||U<0||y<U)return ee(P,m);R===8&&(R=9);var ue=new J;return(P.state=ue).strm=P,ue.wrap=re,ue.gzhead=null,ue.w_bits=R,ue.w_size=1<<ue.w_bits,ue.w_mask=ue.w_size-1,ue.hash_bits=I+7,ue.hash_size=1<<ue.hash_bits,ue.hash_mask=ue.hash_size-1,ue.hash_shift=~~((ue.hash_bits+E-1)/E),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<<I+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=oe,ue.strategy=U,ue.method=Y,X(P)}i=[new Z(0,0,0,0,function(P,oe){var Y=65535;for(Y>P.pending_buf_size-5&&(Y=P.pending_buf_size-5);;){if(P.lookahead<=1){if(se(P),P.lookahead===0&&oe===h)return k;if(P.lookahead===0)break}P.strstart+=P.lookahead,P.lookahead=0;var R=P.block_start+Y;if((P.strstart===0||P.strstart>=R)&&(P.lookahead=P.strstart-R,P.strstart=R,F(P,!1),P.strm.avail_out===0)||P.strstart-P.block_start>=P.w_size-$&&(F(P,!1),P.strm.avail_out===0))return k}return P.insert=0,oe===f?(F(P,!0),P.strm.avail_out===0?K:H):(P.strstart>P.block_start&&(F(P,!1),P.strm.avail_out),k)}),new Z(4,4,8,4,q),new Z(4,5,16,8,q),new Z(4,6,32,32,q),new Z(4,4,16,16,L),new Z(8,16,32,32,L),new Z(8,16,128,128,L),new Z(8,32,128,256,L),new Z(32,128,258,1024,L),new Z(32,258,258,4096,L)],s.deflateInit=function(P,oe){return he(P,oe,v,15,8,0)},s.deflateInit2=he,s.deflateReset=X,s.deflateResetKeep=W,s.deflateSetHeader=function(P,oe){return P&&P.state?P.state.wrap!==2?m:(P.state.gzhead=oe,p):m},s.deflate=function(P,oe){var Y,R,I,U;if(!P||!P.state||5<oe||oe<0)return P?ee(P,m):m;if(R=P.state,!P.output||!P.input&&P.avail_in!==0||R.status===666&&oe!==f)return ee(P,P.avail_out===0?-5:m);if(R.strm=P,Y=R.last_flush,R.last_flush=oe,R.status===T)if(R.wrap===2)P.adler=0,G(R,31),G(R,139),G(R,8),R.gzhead?(G(R,(R.gzhead.text?1:0)+(R.gzhead.hcrc?2:0)+(R.gzhead.extra?4:0)+(R.gzhead.name?8:0)+(R.gzhead.comment?16:0)),G(R,255&R.gzhead.time),G(R,R.gzhead.time>>8&255),G(R,R.gzhead.time>>16&255),G(R,R.gzhead.time>>24&255),G(R,R.level===9?2:2<=R.strategy||R.level<2?4:0),G(R,255&R.gzhead.os),R.gzhead.extra&&R.gzhead.extra.length&&(G(R,255&R.gzhead.extra.length),G(R,R.gzhead.extra.length>>8&255)),R.gzhead.hcrc&&(P.adler=u(P.adler,R.pending_buf,R.pending,0)),R.gzindex=0,R.status=69):(G(R,0),G(R,0),G(R,0),G(R,0),G(R,0),G(R,R.level===9?2:2<=R.strategy||R.level<2?4:0),G(R,3),R.status=M);else{var re=v+(R.w_bits-8<<4)<<8;re|=(2<=R.strategy||R.level<2?0:R.level<6?1:R.level===6?2:3)<<6,R.strstart!==0&&(re|=32),re+=31-re%31,R.status=M,Q(R,re),R.strstart!==0&&(Q(R,P.adler>>>16),Q(R,65535&P.adler)),P.adler=1}if(R.status===69)if(R.gzhead.extra){for(I=R.pending;R.gzindex<(65535&R.gzhead.extra.length)&&(R.pending!==R.pending_buf_size||(R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),z(P),I=R.pending,R.pending!==R.pending_buf_size));)G(R,255&R.gzhead.extra[R.gzindex]),R.gzindex++;R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),R.gzindex===R.gzhead.extra.length&&(R.gzindex=0,R.status=73)}else R.status=73;if(R.status===73)if(R.gzhead.name){I=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),z(P),I=R.pending,R.pending===R.pending_buf_size)){U=1;break}U=R.gzindex<R.gzhead.name.length?255&R.gzhead.name.charCodeAt(R.gzindex++):0,G(R,U)}while(U!==0);R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),U===0&&(R.gzindex=0,R.status=91)}else R.status=91;if(R.status===91)if(R.gzhead.comment){I=R.pending;do{if(R.pending===R.pending_buf_size&&(R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),z(P),I=R.pending,R.pending===R.pending_buf_size)){U=1;break}U=R.gzindex<R.gzhead.comment.length?255&R.gzhead.comment.charCodeAt(R.gzindex++):0,G(R,U)}while(U!==0);R.gzhead.hcrc&&R.pending>I&&(P.adler=u(P.adler,R.pending_buf,R.pending-I,I)),U===0&&(R.status=103)}else R.status=103;if(R.status===103&&(R.gzhead.hcrc?(R.pending+2>R.pending_buf_size&&z(P),R.pending+2<=R.pending_buf_size&&(G(R,255&P.adler),G(R,P.adler>>8&255),P.adler=0,R.status=M)):R.status=M),R.pending!==0){if(z(P),P.avail_out===0)return R.last_flush=-1,p}else if(P.avail_in===0&&V(oe)<=V(Y)&&oe!==f)return ee(P,-5);if(R.status===666&&P.avail_in!==0)return ee(P,-5);if(P.avail_in!==0||R.lookahead!==0||oe!==h&&R.status!==666){var ue=R.strategy===2?function(ae,ge){for(var we;;){if(ae.lookahead===0&&(se(ae),ae.lookahead===0)){if(ge===h)return k;break}if(ae.match_length=0,we=l._tr_tally(ae,0,ae.window[ae.strstart]),ae.lookahead--,ae.strstart++,we&&(F(ae,!1),ae.strm.avail_out===0))return k}return ae.insert=0,ge===f?(F(ae,!0),ae.strm.avail_out===0?K:H):ae.last_lit&&(F(ae,!1),ae.strm.avail_out===0)?k:D}(R,oe):R.strategy===3?function(ae,ge){for(var we,ce,ne,fe,be=ae.window;;){if(ae.lookahead<=O){if(se(ae),ae.lookahead<=O&&ge===h)return k;if(ae.lookahead===0)break}if(ae.match_length=0,ae.lookahead>=E&&0<ae.strstart&&(ce=be[ne=ae.strstart-1])===be[++ne]&&ce===be[++ne]&&ce===be[++ne]){fe=ae.strstart+O;do;while(ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ce===be[++ne]&&ne<fe);ae.match_length=O-(fe-ne),ae.match_length>ae.lookahead&&(ae.match_length=ae.lookahead)}if(ae.match_length>=E?(we=l._tr_tally(ae,1,ae.match_length-E),ae.lookahead-=ae.match_length,ae.strstart+=ae.match_length,ae.match_length=0):(we=l._tr_tally(ae,0,ae.window[ae.strstart]),ae.lookahead--,ae.strstart++),we&&(F(ae,!1),ae.strm.avail_out===0))return k}return ae.insert=0,ge===f?(F(ae,!0),ae.strm.avail_out===0?K:H):ae.last_lit&&(F(ae,!1),ae.strm.avail_out===0)?k:D}(R,oe):i[R.level].func(R,oe);if(ue!==K&&ue!==H||(R.status=666),ue===k||ue===K)return P.avail_out===0&&(R.last_flush=-1),p;if(ue===D&&(oe===1?l._tr_align(R):oe!==5&&(l._tr_stored_block(R,0,0,!1),oe===3&&(B(R.head),R.lookahead===0&&(R.strstart=0,R.block_start=0,R.insert=0))),z(P),P.avail_out===0))return R.last_flush=-1,p}return oe!==f?p:R.wrap<=0?1:(R.wrap===2?(G(R,255&P.adler),G(R,P.adler>>8&255),G(R,P.adler>>16&255),G(R,P.adler>>24&255),G(R,255&P.total_in),G(R,P.total_in>>8&255),G(R,P.total_in>>16&255),G(R,P.total_in>>24&255)):(Q(R,P.adler>>>16),Q(R,65535&P.adler)),z(P),0<R.wrap&&(R.wrap=-R.wrap),R.pending!==0?p:1)},s.deflateEnd=function(P){var oe;return P&&P.state?(oe=P.state.status)!==T&&oe!==69&&oe!==73&&oe!==91&&oe!==103&&oe!==M&&oe!==666?ee(P,m):(P.state=null,oe===M?ee(P,-3):p):m},s.deflateSetDictionary=function(P,oe){var Y,R,I,U,re,ue,ae,ge,we=oe.length;if(!P||!P.state||(U=(Y=P.state).wrap)===2||U===1&&Y.status!==T||Y.lookahead)return m;for(U===1&&(P.adler=c(P.adler,oe,we,0)),Y.wrap=0,we>=Y.w_size&&(U===0&&(B(Y.head),Y.strstart=0,Y.block_start=0,Y.insert=0),ge=new a.Buf8(Y.w_size),a.arraySet(ge,oe,we-Y.w_size,Y.w_size,0),oe=ge,we=Y.w_size),re=P.avail_in,ue=P.next_in,ae=P.input,P.avail_in=we,P.next_in=0,P.input=oe,se(Y);Y.lookahead>=E;){for(R=Y.strstart,I=Y.lookahead-(E-1);Y.ins_h=(Y.ins_h<<Y.hash_shift^Y.window[R+E-1])&Y.hash_mask,Y.prev[R&Y.w_mask]=Y.head[Y.ins_h],Y.head[Y.ins_h]=R,R++,--I;);Y.strstart=R,Y.lookahead=E-1,se(Y)}return Y.strstart+=Y.lookahead,Y.block_start=Y.strstart,Y.insert=Y.lookahead,Y.lookahead=0,Y.match_length=Y.prev_length=E-1,Y.match_available=0,P.next_in=ue,P.input=ae,P.avail_in=re,Y.wrap=U,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 l,c,u,d,h,f,p,m,g,y,x,v,b,w,j,N,C,A,E,O,$,T,M,k,D;l=i.state,c=i.next_in,k=i.input,u=c+(i.avail_in-5),d=i.next_out,D=i.output,h=d-(a-i.avail_out),f=d+(i.avail_out-257),p=l.dmax,m=l.wsize,g=l.whave,y=l.wnext,x=l.window,v=l.hold,b=l.bits,w=l.lencode,j=l.distcode,N=(1<<l.lenbits)-1,C=(1<<l.distbits)-1;e:do{b<15&&(v+=k[c++]<<b,b+=8,v+=k[c++]<<b,b+=8),A=w[v&N];t:for(;;){if(v>>>=E=A>>>24,b-=E,(E=A>>>16&255)===0)D[d++]=65535&A;else{if(!(16&E)){if(!(64&E)){A=w[(65535&A)+(v&(1<<E)-1)];continue t}if(32&E){l.mode=12;break e}i.msg="invalid literal/length code",l.mode=30;break e}O=65535&A,(E&=15)&&(b<E&&(v+=k[c++]<<b,b+=8),O+=v&(1<<E)-1,v>>>=E,b-=E),b<15&&(v+=k[c++]<<b,b+=8,v+=k[c++]<<b,b+=8),A=j[v&C];r:for(;;){if(v>>>=E=A>>>24,b-=E,!(16&(E=A>>>16&255))){if(!(64&E)){A=j[(65535&A)+(v&(1<<E)-1)];continue r}i.msg="invalid distance code",l.mode=30;break e}if($=65535&A,b<(E&=15)&&(v+=k[c++]<<b,(b+=8)<E&&(v+=k[c++]<<b,b+=8)),p<($+=v&(1<<E)-1)){i.msg="invalid distance too far back",l.mode=30;break e}if(v>>>=E,b-=E,(E=d-h)<$){if(g<(E=$-E)&&l.sane){i.msg="invalid distance too far back",l.mode=30;break e}if(M=x,(T=0)===y){if(T+=m-E,E<O){for(O-=E;D[d++]=x[T++],--E;);T=d-$,M=D}}else if(y<E){if(T+=m+y-E,(E-=y)<O){for(O-=E;D[d++]=x[T++],--E;);if(T=0,y<O){for(O-=E=y;D[d++]=x[T++],--E;);T=d-$,M=D}}}else if(T+=y-E,E<O){for(O-=E;D[d++]=x[T++],--E;);T=d-$,M=D}for(;2<O;)D[d++]=M[T++],D[d++]=M[T++],D[d++]=M[T++],O-=3;O&&(D[d++]=M[T++],1<O&&(D[d++]=M[T++]))}else{for(T=d-$;D[d++]=D[T++],D[d++]=D[T++],D[d++]=D[T++],2<(O-=3););O&&(D[d++]=D[T++],1<O&&(D[d++]=D[T++]))}break}}break}}while(c<u&&d<f);c-=O=b>>3,v&=(1<<(b-=O<<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),l.hold=v,l.bits=b}},{}],49:[function(r,n,s){var i=r("../utils/common"),a=r("./adler32"),l=r("./crc32"),c=r("./inffast"),u=r("./inftrees"),d=1,h=2,f=0,p=-2,m=1,g=852,y=592;function x(T){return(T>>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<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(T){var M;return T&&T.state?(M=T.state,T.total_in=T.total_out=M.total=0,T.msg="",M.wrap&&(T.adler=1&M.wrap),M.mode=m,M.last=0,M.havedict=0,M.dmax=32768,M.head=null,M.hold=0,M.bits=0,M.lencode=M.lendyn=new i.Buf32(g),M.distcode=M.distdyn=new i.Buf32(y),M.sane=1,M.back=-1,f):p}function w(T){var M;return T&&T.state?((M=T.state).wsize=0,M.whave=0,M.wnext=0,b(T)):p}function j(T,M){var k,D;return T&&T.state?(D=T.state,M<0?(k=0,M=-M):(k=1+(M>>4),M<48&&(M&=15)),M&&(M<8||15<M)?p:(D.window!==null&&D.wbits!==M&&(D.window=null),D.wrap=k,D.wbits=M,w(T))):p}function N(T,M){var k,D;return T?(D=new v,(T.state=D).window=null,(k=j(T,M))!==f&&(T.state=null),k):p}var C,A,E=!0;function O(T){if(E){var M;for(C=new i.Buf32(512),A=new i.Buf32(32),M=0;M<144;)T.lens[M++]=8;for(;M<256;)T.lens[M++]=9;for(;M<280;)T.lens[M++]=7;for(;M<288;)T.lens[M++]=8;for(u(d,T.lens,0,288,C,0,T.work,{bits:9}),M=0;M<32;)T.lens[M++]=5;u(h,T.lens,0,32,A,0,T.work,{bits:5}),E=!1}T.lencode=C,T.lenbits=9,T.distcode=A,T.distbits=5}function $(T,M,k,D){var K,H=T.state;return H.window===null&&(H.wsize=1<<H.wbits,H.wnext=0,H.whave=0,H.window=new i.Buf8(H.wsize)),D>=H.wsize?(i.arraySet(H.window,M,k-H.wsize,H.wsize,0),H.wnext=0,H.whave=H.wsize):(D<(K=H.wsize-H.wnext)&&(K=D),i.arraySet(H.window,M,k-D,K,H.wnext),(D-=K)?(i.arraySet(H.window,M,k-D,D,0),H.wnext=D,H.whave=H.wsize):(H.wnext+=K,H.wnext===H.wsize&&(H.wnext=0),H.whave<H.wsize&&(H.whave+=K))),0}s.inflateReset=w,s.inflateReset2=j,s.inflateResetKeep=b,s.inflateInit=function(T){return N(T,15)},s.inflateInit2=N,s.inflate=function(T,M){var k,D,K,H,ee,V,B,z,F,G,Q,ie,se,q,L,Z,J,W,X,he,P,oe,Y,R,I=0,U=new i.Buf8(4),re=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return p;(k=T.state).mode===12&&(k.mode=13),ee=T.next_out,K=T.output,B=T.avail_out,H=T.next_in,D=T.input,V=T.avail_in,z=k.hold,F=k.bits,G=V,Q=B,oe=f;e:for(;;)switch(k.mode){case m:if(k.wrap===0){k.mode=13;break}for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(2&k.wrap&&z===35615){U[k.check=0]=255&z,U[1]=z>>>8&255,k.check=l(k.check,U,2,0),F=z=0,k.mode=2;break}if(k.flags=0,k.head&&(k.head.done=!1),!(1&k.wrap)||(((255&z)<<8)+(z>>8))%31){T.msg="incorrect header check",k.mode=30;break}if((15&z)!=8){T.msg="unknown compression method",k.mode=30;break}if(F-=4,P=8+(15&(z>>>=4)),k.wbits===0)k.wbits=P;else if(P>k.wbits){T.msg="invalid window size",k.mode=30;break}k.dmax=1<<P,T.adler=k.check=1,k.mode=512&z?10:12,F=z=0;break;case 2:for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(k.flags=z,(255&k.flags)!=8){T.msg="unknown compression method",k.mode=30;break}if(57344&k.flags){T.msg="unknown header flags set",k.mode=30;break}k.head&&(k.head.text=z>>8&1),512&k.flags&&(U[0]=255&z,U[1]=z>>>8&255,k.check=l(k.check,U,2,0)),F=z=0,k.mode=3;case 3:for(;F<32;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.head&&(k.head.time=z),512&k.flags&&(U[0]=255&z,U[1]=z>>>8&255,U[2]=z>>>16&255,U[3]=z>>>24&255,k.check=l(k.check,U,4,0)),F=z=0,k.mode=4;case 4:for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.head&&(k.head.xflags=255&z,k.head.os=z>>8),512&k.flags&&(U[0]=255&z,U[1]=z>>>8&255,k.check=l(k.check,U,2,0)),F=z=0,k.mode=5;case 5:if(1024&k.flags){for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.length=z,k.head&&(k.head.extra_len=z),512&k.flags&&(U[0]=255&z,U[1]=z>>>8&255,k.check=l(k.check,U,2,0)),F=z=0}else k.head&&(k.head.extra=null);k.mode=6;case 6:if(1024&k.flags&&(V<(ie=k.length)&&(ie=V),ie&&(k.head&&(P=k.head.extra_len-k.length,k.head.extra||(k.head.extra=new Array(k.head.extra_len)),i.arraySet(k.head.extra,D,H,ie,P)),512&k.flags&&(k.check=l(k.check,D,ie,H)),V-=ie,H+=ie,k.length-=ie),k.length))break e;k.length=0,k.mode=7;case 7:if(2048&k.flags){if(V===0)break e;for(ie=0;P=D[H+ie++],k.head&&P&&k.length<65536&&(k.head.name+=String.fromCharCode(P)),P&&ie<V;);if(512&k.flags&&(k.check=l(k.check,D,ie,H)),V-=ie,H+=ie,P)break e}else k.head&&(k.head.name=null);k.length=0,k.mode=8;case 8:if(4096&k.flags){if(V===0)break e;for(ie=0;P=D[H+ie++],k.head&&P&&k.length<65536&&(k.head.comment+=String.fromCharCode(P)),P&&ie<V;);if(512&k.flags&&(k.check=l(k.check,D,ie,H)),V-=ie,H+=ie,P)break e}else k.head&&(k.head.comment=null);k.mode=9;case 9:if(512&k.flags){for(;F<16;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(z!==(65535&k.check)){T.msg="header crc mismatch",k.mode=30;break}F=z=0}k.head&&(k.head.hcrc=k.flags>>9&1,k.head.done=!0),T.adler=k.check=0,k.mode=12;break;case 10:for(;F<32;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}T.adler=k.check=x(z),F=z=0,k.mode=11;case 11:if(k.havedict===0)return T.next_out=ee,T.avail_out=B,T.next_in=H,T.avail_in=V,k.hold=z,k.bits=F,2;T.adler=k.check=1,k.mode=12;case 12:if(M===5||M===6)break e;case 13:if(k.last){z>>>=7&F,F-=7&F,k.mode=27;break}for(;F<3;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}switch(k.last=1&z,F-=1,3&(z>>>=1)){case 0:k.mode=14;break;case 1:if(O(k),k.mode=20,M!==6)break;z>>>=2,F-=2;break e;case 2:k.mode=17;break;case 3:T.msg="invalid block type",k.mode=30}z>>>=2,F-=2;break;case 14:for(z>>>=7&F,F-=7&F;F<32;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if((65535&z)!=(z>>>16^65535)){T.msg="invalid stored block lengths",k.mode=30;break}if(k.length=65535&z,F=z=0,k.mode=15,M===6)break e;case 15:k.mode=16;case 16:if(ie=k.length){if(V<ie&&(ie=V),B<ie&&(ie=B),ie===0)break e;i.arraySet(K,D,H,ie,ee),V-=ie,H+=ie,B-=ie,ee+=ie,k.length-=ie;break}k.mode=12;break;case 17:for(;F<14;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(k.nlen=257+(31&z),z>>>=5,F-=5,k.ndist=1+(31&z),z>>>=5,F-=5,k.ncode=4+(15&z),z>>>=4,F-=4,286<k.nlen||30<k.ndist){T.msg="too many length or distance symbols",k.mode=30;break}k.have=0,k.mode=18;case 18:for(;k.have<k.ncode;){for(;F<3;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.lens[re[k.have++]]=7&z,z>>>=3,F-=3}for(;k.have<19;)k.lens[re[k.have++]]=0;if(k.lencode=k.lendyn,k.lenbits=7,Y={bits:k.lenbits},oe=u(0,k.lens,0,19,k.lencode,0,k.work,Y),k.lenbits=Y.bits,oe){T.msg="invalid code lengths set",k.mode=30;break}k.have=0,k.mode=19;case 19:for(;k.have<k.nlen+k.ndist;){for(;Z=(I=k.lencode[z&(1<<k.lenbits)-1])>>>16&255,J=65535&I,!((L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(J<16)z>>>=L,F-=L,k.lens[k.have++]=J;else{if(J===16){for(R=L+2;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(z>>>=L,F-=L,k.have===0){T.msg="invalid bit length repeat",k.mode=30;break}P=k.lens[k.have-1],ie=3+(3&z),z>>>=2,F-=2}else if(J===17){for(R=L+3;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}F-=L,P=0,ie=3+(7&(z>>>=L)),z>>>=3,F-=3}else{for(R=L+7;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}F-=L,P=0,ie=11+(127&(z>>>=L)),z>>>=7,F-=7}if(k.have+ie>k.nlen+k.ndist){T.msg="invalid bit length repeat",k.mode=30;break}for(;ie--;)k.lens[k.have++]=P}}if(k.mode===30)break;if(k.lens[256]===0){T.msg="invalid code -- missing end-of-block",k.mode=30;break}if(k.lenbits=9,Y={bits:k.lenbits},oe=u(d,k.lens,0,k.nlen,k.lencode,0,k.work,Y),k.lenbits=Y.bits,oe){T.msg="invalid literal/lengths set",k.mode=30;break}if(k.distbits=6,k.distcode=k.distdyn,Y={bits:k.distbits},oe=u(h,k.lens,k.nlen,k.ndist,k.distcode,0,k.work,Y),k.distbits=Y.bits,oe){T.msg="invalid distances set",k.mode=30;break}if(k.mode=20,M===6)break e;case 20:k.mode=21;case 21:if(6<=V&&258<=B){T.next_out=ee,T.avail_out=B,T.next_in=H,T.avail_in=V,k.hold=z,k.bits=F,c(T,Q),ee=T.next_out,K=T.output,B=T.avail_out,H=T.next_in,D=T.input,V=T.avail_in,z=k.hold,F=k.bits,k.mode===12&&(k.back=-1);break}for(k.back=0;Z=(I=k.lencode[z&(1<<k.lenbits)-1])>>>16&255,J=65535&I,!((L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(Z&&!(240&Z)){for(W=L,X=Z,he=J;Z=(I=k.lencode[he+((z&(1<<W+X)-1)>>W)])>>>16&255,J=65535&I,!(W+(L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}z>>>=W,F-=W,k.back+=W}if(z>>>=L,F-=L,k.back+=L,k.length=J,Z===0){k.mode=26;break}if(32&Z){k.back=-1,k.mode=12;break}if(64&Z){T.msg="invalid literal/length code",k.mode=30;break}k.extra=15&Z,k.mode=22;case 22:if(k.extra){for(R=k.extra;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.length+=z&(1<<k.extra)-1,z>>>=k.extra,F-=k.extra,k.back+=k.extra}k.was=k.length,k.mode=23;case 23:for(;Z=(I=k.distcode[z&(1<<k.distbits)-1])>>>16&255,J=65535&I,!((L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(!(240&Z)){for(W=L,X=Z,he=J;Z=(I=k.distcode[he+((z&(1<<W+X)-1)>>W)])>>>16&255,J=65535&I,!(W+(L=I>>>24)<=F);){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}z>>>=W,F-=W,k.back+=W}if(z>>>=L,F-=L,k.back+=L,64&Z){T.msg="invalid distance code",k.mode=30;break}k.offset=J,k.extra=15&Z,k.mode=24;case 24:if(k.extra){for(R=k.extra;F<R;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}k.offset+=z&(1<<k.extra)-1,z>>>=k.extra,F-=k.extra,k.back+=k.extra}if(k.offset>k.dmax){T.msg="invalid distance too far back",k.mode=30;break}k.mode=25;case 25:if(B===0)break e;if(ie=Q-B,k.offset>ie){if((ie=k.offset-ie)>k.whave&&k.sane){T.msg="invalid distance too far back",k.mode=30;break}se=ie>k.wnext?(ie-=k.wnext,k.wsize-ie):k.wnext-ie,ie>k.length&&(ie=k.length),q=k.window}else q=K,se=ee-k.offset,ie=k.length;for(B<ie&&(ie=B),B-=ie,k.length-=ie;K[ee++]=q[se++],--ie;);k.length===0&&(k.mode=21);break;case 26:if(B===0)break e;K[ee++]=k.length,B--,k.mode=21;break;case 27:if(k.wrap){for(;F<32;){if(V===0)break e;V--,z|=D[H++]<<F,F+=8}if(Q-=B,T.total_out+=Q,k.total+=Q,Q&&(T.adler=k.check=k.flags?l(k.check,K,Q,ee-Q):a(k.check,K,Q,ee-Q)),Q=B,(k.flags?z:x(z))!==k.check){T.msg="incorrect data check",k.mode=30;break}F=z=0}k.mode=28;case 28:if(k.wrap&&k.flags){for(;F<32;){if(V===0)break e;V--,z+=D[H++]<<F,F+=8}if(z!==(4294967295&k.total)){T.msg="incorrect length check",k.mode=30;break}F=z=0}k.mode=29;case 29:oe=1;break e;case 30:oe=-3;break e;case 31:return-4;case 32:default:return p}return T.next_out=ee,T.avail_out=B,T.next_in=H,T.avail_in=V,k.hold=z,k.bits=F,(k.wsize||Q!==T.avail_out&&k.mode<30&&(k.mode<27||M!==4))&&$(T,T.output,T.next_out,Q-T.avail_out)?(k.mode=31,-4):(G-=T.avail_in,Q-=T.avail_out,T.total_in+=G,T.total_out+=Q,k.total+=Q,k.wrap&&Q&&(T.adler=k.check=k.flags?l(k.check,K,Q,T.next_out-Q):a(k.check,K,Q,T.next_out-Q)),T.data_type=k.bits+(k.last?64:0)+(k.mode===12?128:0)+(k.mode===20||k.mode===15?256:0),(G==0&&Q===0||M===4)&&oe===f&&(oe=-5),oe)},s.inflateEnd=function(T){if(!T||!T.state)return p;var M=T.state;return M.window&&(M.window=null),T.state=null,f},s.inflateGetHeader=function(T,M){var k;return T&&T.state&&2&(k=T.state).wrap?((k.head=M).done=!1,f):p},s.inflateSetDictionary=function(T,M){var k,D=M.length;return T&&T.state?(k=T.state).wrap!==0&&k.mode!==11?p:k.mode===11&&a(1,M,D,0)!==k.check?-3:$(T,M,D,D)?(k.mode=31,-4):(k.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],l=[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,y,x){var v,b,w,j,N,C,A,E,O,$=x.bits,T=0,M=0,k=0,D=0,K=0,H=0,ee=0,V=0,B=0,z=0,F=null,G=0,Q=new i.Buf16(16),ie=new i.Buf16(16),se=null,q=0;for(T=0;T<=15;T++)Q[T]=0;for(M=0;M<p;M++)Q[h[f+M]]++;for(K=$,D=15;1<=D&&Q[D]===0;D--);if(D<K&&(K=D),D===0)return m[g++]=20971520,m[g++]=20971520,x.bits=1,0;for(k=1;k<D&&Q[k]===0;k++);for(K<k&&(K=k),T=V=1;T<=15;T++)if(V<<=1,(V-=Q[T])<0)return-1;if(0<V&&(d===0||D!==1))return-1;for(ie[1]=0,T=1;T<15;T++)ie[T+1]=ie[T]+Q[T];for(M=0;M<p;M++)h[f+M]!==0&&(y[ie[h[f+M]]++]=M);if(C=d===0?(F=se=y,19):d===1?(F=a,G-=257,se=l,q-=257,256):(F=c,se=u,-1),T=k,N=g,ee=M=z=0,w=-1,j=(B=1<<(H=K))-1,d===1&&852<B||d===2&&592<B)return 1;for(;;){for(A=T-ee,O=y[M]<C?(E=0,y[M]):y[M]>C?(E=se[q+y[M]],F[G+y[M]]):(E=96,0),v=1<<T-ee,k=b=1<<H;m[N+(z>>ee)+(b-=v)]=A<<24|E<<16|O|0,b!==0;);for(v=1<<T-1;z&v;)v>>=1;if(v!==0?(z&=v-1,z+=v):z=0,M++,--Q[T]==0){if(T===D)break;T=h[f+y[M]]}if(K<T&&(z&j)!==w){for(ee===0&&(ee=K),N+=k,V=1<<(H=T-ee);H+ee<D&&!((V-=Q[H+ee])<=0);)H++,V<<=1;if(B+=1<<H,d===1&&852<B||d===2&&592<B)return 1;m[w=z&j]=K<<24|H<<16|N-g|0}}return z!==0&&(m[N+z]=T-ee<<24|64<<16|0),x.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,l=1;function c(I){for(var U=I.length;0<=--U;)I[U]=0}var u=0,d=29,h=256,f=h+1+d,p=30,m=19,g=2*f+1,y=15,x=16,v=7,b=256,w=16,j=17,N=18,C=[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],A=[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],E=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],$=new Array(2*(f+2));c($);var T=new Array(2*p);c(T);var M=new Array(512);c(M);var k=new Array(256);c(k);var D=new Array(d);c(D);var K,H,ee,V=new Array(p);function B(I,U,re,ue,ae){this.static_tree=I,this.extra_bits=U,this.extra_base=re,this.elems=ue,this.max_length=ae,this.has_stree=I&&I.length}function z(I,U){this.dyn_tree=I,this.max_code=0,this.stat_desc=U}function F(I){return I<256?M[I]:M[256+(I>>>7)]}function G(I,U){I.pending_buf[I.pending++]=255&U,I.pending_buf[I.pending++]=U>>>8&255}function Q(I,U,re){I.bi_valid>x-re?(I.bi_buf|=U<<I.bi_valid&65535,G(I,I.bi_buf),I.bi_buf=U>>x-I.bi_valid,I.bi_valid+=re-x):(I.bi_buf|=U<<I.bi_valid&65535,I.bi_valid+=re)}function ie(I,U,re){Q(I,re[2*U],re[2*U+1])}function se(I,U){for(var re=0;re|=1&I,I>>>=1,re<<=1,0<--U;);return re>>>1}function q(I,U,re){var ue,ae,ge=new Array(y+1),we=0;for(ue=1;ue<=y;ue++)ge[ue]=we=we+re[ue-1]<<1;for(ae=0;ae<=U;ae++){var ce=I[2*ae+1];ce!==0&&(I[2*ae]=se(ge[ce]++,ce))}}function L(I){var U;for(U=0;U<f;U++)I.dyn_ltree[2*U]=0;for(U=0;U<p;U++)I.dyn_dtree[2*U]=0;for(U=0;U<m;U++)I.bl_tree[2*U]=0;I.dyn_ltree[2*b]=1,I.opt_len=I.static_len=0,I.last_lit=I.matches=0}function Z(I){8<I.bi_valid?G(I,I.bi_buf):0<I.bi_valid&&(I.pending_buf[I.pending++]=I.bi_buf),I.bi_buf=0,I.bi_valid=0}function J(I,U,re,ue){var ae=2*U,ge=2*re;return I[ae]<I[ge]||I[ae]===I[ge]&&ue[U]<=ue[re]}function W(I,U,re){for(var ue=I.heap[re],ae=re<<1;ae<=I.heap_len&&(ae<I.heap_len&&J(U,I.heap[ae+1],I.heap[ae],I.depth)&&ae++,!J(U,ue,I.heap[ae],I.depth));)I.heap[re]=I.heap[ae],re=ae,ae<<=1;I.heap[re]=ue}function X(I,U,re){var ue,ae,ge,we,ce=0;if(I.last_lit!==0)for(;ue=I.pending_buf[I.d_buf+2*ce]<<8|I.pending_buf[I.d_buf+2*ce+1],ae=I.pending_buf[I.l_buf+ce],ce++,ue===0?ie(I,ae,U):(ie(I,(ge=k[ae])+h+1,U),(we=C[ge])!==0&&Q(I,ae-=D[ge],we),ie(I,ge=F(--ue),re),(we=A[ge])!==0&&Q(I,ue-=V[ge],we)),ce<I.last_lit;);ie(I,b,U)}function he(I,U){var re,ue,ae,ge=U.dyn_tree,we=U.stat_desc.static_tree,ce=U.stat_desc.has_stree,ne=U.stat_desc.elems,fe=-1;for(I.heap_len=0,I.heap_max=g,re=0;re<ne;re++)ge[2*re]!==0?(I.heap[++I.heap_len]=fe=re,I.depth[re]=0):ge[2*re+1]=0;for(;I.heap_len<2;)ge[2*(ae=I.heap[++I.heap_len]=fe<2?++fe:0)]=1,I.depth[ae]=0,I.opt_len--,ce&&(I.static_len-=we[2*ae+1]);for(U.max_code=fe,re=I.heap_len>>1;1<=re;re--)W(I,ge,re);for(ae=ne;re=I.heap[1],I.heap[1]=I.heap[I.heap_len--],W(I,ge,1),ue=I.heap[1],I.heap[--I.heap_max]=re,I.heap[--I.heap_max]=ue,ge[2*ae]=ge[2*re]+ge[2*ue],I.depth[ae]=(I.depth[re]>=I.depth[ue]?I.depth[re]:I.depth[ue])+1,ge[2*re+1]=ge[2*ue+1]=ae,I.heap[1]=ae++,W(I,ge,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],function(be,xe){var _e,ke,$e,Te,ot,wt,Ct=xe.dyn_tree,pr=xe.max_code,Kt=xe.stat_desc.static_tree,Re=xe.stat_desc.has_stree,ye=xe.stat_desc.extra_bits,Ne=xe.stat_desc.extra_base,Ce=xe.stat_desc.max_length,Fe=0;for(Te=0;Te<=y;Te++)be.bl_count[Te]=0;for(Ct[2*be.heap[be.heap_max]+1]=0,_e=be.heap_max+1;_e<g;_e++)Ce<(Te=Ct[2*Ct[2*(ke=be.heap[_e])+1]+1]+1)&&(Te=Ce,Fe++),Ct[2*ke+1]=Te,pr<ke||(be.bl_count[Te]++,ot=0,Ne<=ke&&(ot=ye[ke-Ne]),wt=Ct[2*ke],be.opt_len+=wt*(Te+ot),Re&&(be.static_len+=wt*(Kt[2*ke+1]+ot)));if(Fe!==0){do{for(Te=Ce-1;be.bl_count[Te]===0;)Te--;be.bl_count[Te]--,be.bl_count[Te+1]+=2,be.bl_count[Ce]--,Fe-=2}while(0<Fe);for(Te=Ce;Te!==0;Te--)for(ke=be.bl_count[Te];ke!==0;)pr<($e=be.heap[--_e])||(Ct[2*$e+1]!==Te&&(be.opt_len+=(Te-Ct[2*$e+1])*Ct[2*$e],Ct[2*$e+1]=Te),ke--)}}(I,U),q(ge,fe,I.bl_count)}function P(I,U,re){var ue,ae,ge=-1,we=U[1],ce=0,ne=7,fe=4;for(we===0&&(ne=138,fe=3),U[2*(re+1)+1]=65535,ue=0;ue<=re;ue++)ae=we,we=U[2*(ue+1)+1],++ce<ne&&ae===we||(ce<fe?I.bl_tree[2*ae]+=ce:ae!==0?(ae!==ge&&I.bl_tree[2*ae]++,I.bl_tree[2*w]++):ce<=10?I.bl_tree[2*j]++:I.bl_tree[2*N]++,ge=ae,fe=(ce=0)===we?(ne=138,3):ae===we?(ne=6,3):(ne=7,4))}function oe(I,U,re){var ue,ae,ge=-1,we=U[1],ce=0,ne=7,fe=4;for(we===0&&(ne=138,fe=3),ue=0;ue<=re;ue++)if(ae=we,we=U[2*(ue+1)+1],!(++ce<ne&&ae===we)){if(ce<fe)for(;ie(I,ae,I.bl_tree),--ce!=0;);else ae!==0?(ae!==ge&&(ie(I,ae,I.bl_tree),ce--),ie(I,w,I.bl_tree),Q(I,ce-3,2)):ce<=10?(ie(I,j,I.bl_tree),Q(I,ce-3,3)):(ie(I,N,I.bl_tree),Q(I,ce-11,7));ge=ae,fe=(ce=0)===we?(ne=138,3):ae===we?(ne=6,3):(ne=7,4)}}c(V);var Y=!1;function R(I,U,re,ue){Q(I,(u<<1)+(ue?1:0),3),function(ae,ge,we,ce){Z(ae),G(ae,we),G(ae,~we),i.arraySet(ae.pending_buf,ae.window,ge,we,ae.pending),ae.pending+=we}(I,U,re)}s._tr_init=function(I){Y||(function(){var U,re,ue,ae,ge,we=new Array(y+1);for(ae=ue=0;ae<d-1;ae++)for(D[ae]=ue,U=0;U<1<<C[ae];U++)k[ue++]=ae;for(k[ue-1]=ae,ae=ge=0;ae<16;ae++)for(V[ae]=ge,U=0;U<1<<A[ae];U++)M[ge++]=ae;for(ge>>=7;ae<p;ae++)for(V[ae]=ge<<7,U=0;U<1<<A[ae]-7;U++)M[256+ge++]=ae;for(re=0;re<=y;re++)we[re]=0;for(U=0;U<=143;)$[2*U+1]=8,U++,we[8]++;for(;U<=255;)$[2*U+1]=9,U++,we[9]++;for(;U<=279;)$[2*U+1]=7,U++,we[7]++;for(;U<=287;)$[2*U+1]=8,U++,we[8]++;for(q($,f+1,we),U=0;U<p;U++)T[2*U+1]=5,T[2*U]=se(U,5);K=new B($,C,h+1,f,y),H=new B(T,A,0,p,y),ee=new B(new Array(0),E,0,m,v)}(),Y=!0),I.l_desc=new z(I.dyn_ltree,K),I.d_desc=new z(I.dyn_dtree,H),I.bl_desc=new z(I.bl_tree,ee),I.bi_buf=0,I.bi_valid=0,L(I)},s._tr_stored_block=R,s._tr_flush_block=function(I,U,re,ue){var ae,ge,we=0;0<I.level?(I.strm.data_type===2&&(I.strm.data_type=function(ce){var ne,fe=4093624447;for(ne=0;ne<=31;ne++,fe>>>=1)if(1&fe&&ce.dyn_ltree[2*ne]!==0)return a;if(ce.dyn_ltree[18]!==0||ce.dyn_ltree[20]!==0||ce.dyn_ltree[26]!==0)return l;for(ne=32;ne<h;ne++)if(ce.dyn_ltree[2*ne]!==0)return l;return a}(I)),he(I,I.l_desc),he(I,I.d_desc),we=function(ce){var ne;for(P(ce,ce.dyn_ltree,ce.l_desc.max_code),P(ce,ce.dyn_dtree,ce.d_desc.max_code),he(ce,ce.bl_desc),ne=m-1;3<=ne&&ce.bl_tree[2*O[ne]+1]===0;ne--);return ce.opt_len+=3*(ne+1)+5+5+4,ne}(I),ae=I.opt_len+3+7>>>3,(ge=I.static_len+3+7>>>3)<=ae&&(ae=ge)):ae=ge=re+5,re+4<=ae&&U!==-1?R(I,U,re,ue):I.strategy===4||ge===ae?(Q(I,2+(ue?1:0),3),X(I,$,T)):(Q(I,4+(ue?1:0),3),function(ce,ne,fe,be){var xe;for(Q(ce,ne-257,5),Q(ce,fe-1,5),Q(ce,be-4,4),xe=0;xe<be;xe++)Q(ce,ce.bl_tree[2*O[xe]+1],3);oe(ce,ce.dyn_ltree,ne-1),oe(ce,ce.dyn_dtree,fe-1)}(I,I.l_desc.max_code+1,I.d_desc.max_code+1,we+1),X(I,I.dyn_ltree,I.dyn_dtree)),L(I),ue&&Z(I)},s._tr_tally=function(I,U,re){return I.pending_buf[I.d_buf+2*I.last_lit]=U>>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&U,I.pending_buf[I.l_buf+I.last_lit]=255&re,I.last_lit++,U===0?I.dyn_ltree[2*re]++:(I.matches++,U--,I.dyn_ltree[2*(k[re]+h+1)]++,I.dyn_dtree[2*F(U)]++),I.last_lit===I.lit_bufsize-1},s._tr_align=function(I){Q(I,2,3),ie(I,b,$),function(U){U.bi_valid===16?(G(U,U.bi_buf),U.bi_buf=0,U.bi_valid=0):8<=U.bi_valid&&(U.pending_buf[U.pending++]=255&U.bi_buf,U.bi_buf>>=8,U.bi_valid-=8)}(I)}},{"../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,l){if(!a.setImmediate){var c,u,d,h,f=1,p={},m=!1,g=a.document,y=Object.getPrototypeOf&&Object.getPrototypeOf(a);y=y&&y.setTimeout?y:a,c={}.toString.call(a.process)==="[object process]"?function(w){fr.nextTick(function(){v(w)})}:function(){if(a.postMessage&&!a.importScripts){var w=!0,j=a.onmessage;return a.onmessage=function(){w=!1},a.postMessage("","*"),a.onmessage=j,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 j=g.createElement("script");j.onreadystatechange=function(){v(w),j.onreadystatechange=null,u.removeChild(j),j=null},u.appendChild(j)}):function(w){setTimeout(v,0,w)},y.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var j=new Array(arguments.length-1),N=0;N<j.length;N++)j[N]=arguments[N+1];var C={callback:w,args:j};return p[f]=C,c(f),f++},y.clearImmediate=x}function x(w){delete p[w]}function v(w){if(m)setTimeout(v,0,w);else{var j=p[w];if(j){m=!0;try{(function(N){var C=N.callback,A=N.args;switch(A.length){case 0:C();break;case 1:C(A[0]);break;case 2:C(A[0],A[1]);break;case 3:C(A[0],A[1],A[2]);break;default:C.apply(l,A)}})(j)}finally{x(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 td<"u"?td:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}($F)),$F.exports}var HMt=UMt();const WMt=kG(HMt);var wS={exports:{}},FF,Yae;function VMt(){if(Yae)return FF;Yae=1;var t={"&":"&amp;",'"':"&quot;","'":"&apos;","<":"&lt;",">":"&gt;"};function e(r){return r&&r.replace?r.replace(/([&"<>'])/g,function(n,s){return t[s]}):r}return FF=e,FF}var Xae;function qMt(){if(Xae)return wS.exports;Xae=1;var t=VMt(),e=IG().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 y(j){g?fr.nextTick(j):j()}function x(j,N){if(N!==void 0&&(f+=N),j&&!p&&(h=h||new e,p=!0),j&&p){var C=f;y(function(){h.emit("data",C)}),f=""}}function v(j,N){l(x,a(j,m,m?1:0),N)}function b(){if(h){var j=f;y(function(){h.emit("data",j),h.emit("end"),h.readable=!1,h.emit("close")})}}function w(j){var N=j.encoding||"UTF-8",C={version:"1.0",encoding:N};j.standalone&&(C.standalone=j.standalone),v({"?xml":{_attr:C}}),f=f.replace("/>","?>")}return y(function(){g=!1}),d.declaration&&w(d.declaration),u&&u.forEach?u.forEach(function(j,N){var C;N+1===u.length&&(C=b),v(j,C)}):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;l(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 y=Object.keys(u);if(p=y[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 x=[],v=[],b;function w(j){var N=Object.keys(j);N.forEach(function(C){x.push(c(C,j[C]))})}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(j){if(typeof j=="object"){var N=Object.keys(j)[0];N=="_attr"?w(j._attr):v.push(a(j,d,h+1))}else v.pop(),b=!0,v.push(t(j))}),b||v.push(""));break;default:v.push(t(m))}return{name:p,interrupt:g,attributes:x,content:v,icount:h,indents:f,indent:d}}function l(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;l(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 wS.exports=n,wS.exports.element=wS.exports.Element=s,wS.exports}var GMt=qMt();const cs=kG(GMt),jS=0,BF=32,KMt=32,YMt=(t,e)=>{const r=e.replace(/-/g,"");if(r.length!==KMt)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(jS,BF).map((c,u)=>c^s[u%s.length]),l=new Uint8Array(jS+a.length+Math.max(0,t.length-BF));return l.set(t.slice(0,jS)),l.set(a,jS),l.set(t.slice(BF),jS+a.length),l};class XMt{format(e,r={stack:[]}){const n=e.prepForXml(r);if(n)return n;throw Error("XMLComponent did not format correctly")}}class QMt{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 ZMt{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 JMt{constructor(){Ee(this,"formatter"),Ee(this,"imageReplacer"),Ee(this,"numberingReplacer"),this.formatter=new XMt,this.imageReplacer=new QMt,this.numberingReplacer=new ZMt}compile(e,r,n=[]){const s=new WMt,i=this.xmlifyFile(e,r),a=new Map(Object.entries(i));for(const[,l]of a)if(Array.isArray(l))for(const c of l)s.file(c.path,c.data);else s.file(l.path,l.data);for(const l of n)s.file(l.path,l.data);for(const l of e.Media.Array)l.type!=="svg"?s.file(`word/media/${l.fileName}`,l.data):(s.file(`word/media/${l.fileName}`,l.data),s.file(`word/media/${l.fallback.fileName}`,l.fallback.data));for(const{data:l,name:c,fontKey:u}of e.FontTable.fontOptionsWithKey){const[d]=c.split(".");s.file(`word/fonts/${d}.odttf`,YMt(l,u))}return s}xmlifyFile(e,r){const n=e.Document.Relationships.RelationshipCount+1,s=cs(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=cs(this.formatter.format(e.Comments,{viewWrapper:{View:e.Comments,Relationships:e.Comments.Relationships},file:e,stack:[]}),{indent:r,declaration:{standalone:"yes",encoding:"UTF-8"}}),l=this.imageReplacer.getMediaData(s,e.Media),c=this.imageReplacer.getMediaData(a,e.Media);return{Relationships:{data:(l.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"),cs(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,l,n);return this.numberingReplacer.replace(u,e.Numbering.ConcreteNumbering)})(),path:"word/document.xml"},Styles:{data:(()=>{const u=cs(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:cs(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:cs(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:cs(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=cs(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:cs(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=cs(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:cs(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=cs(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=cs(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:cs(this.formatter.format(e.ContentTypes,{viewWrapper:e.Document,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),path:"[Content_Types].xml"},CustomProperties:{data:cs(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:cs(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:cs(this.formatter.format(e.FootNotes.View,{viewWrapper:e.FootNotes,file:e,stack:[]}),{indent:r,declaration:{encoding:"UTF-8"}}),path:"word/footnotes.xml"},FootNotesRelationships:{data:cs(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:cs(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}`)}),cs(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:cs(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:cs(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 eDt={NONE:"",WITH_2_BLANKS:"  ",WITH_4_BLANKS:"    ",WITH_TAB:"	"},Qae=t=>t===!0?eDt.WITH_2_BLANKS:t===!1?void 0:t,Fke=class kb{static pack(e,r,n){return t2t(this,arguments,function*(s,i,a,l=[]){return this.compiler.compile(s,Qae(a),l).generateAsync({type:i,mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",compression:"DEFLATE"})})}static toString(e,r,n=[]){return kb.pack(e,"string",r,n)}static toBuffer(e,r,n=[]){return kb.pack(e,"nodebuffer",r,n)}static toBase64String(e,r,n=[]){return kb.pack(e,"base64",r,n)}static toBlob(e,r,n=[]){return kb.pack(e,"blob",r,n)}static toArrayBuffer(e,r,n=[]){return kb.pack(e,"arraybuffer",r,n)}static toStream(e,r,n=[]){const s=new zMt.Stream;return this.compiler.compile(e,Qae(r),n).generateAsync({type:"nodebuffer",mimeType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",compression:"DEFLATE"}).then(a=>{s.emit("data",a),s.emit("end")}),s}};Ee(Fke,"compiler",new JMt);let tDt=Fke;function Bke(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(),l=parseInt(s[2]),c=`${a.toLowerCase()}|${l}`;n.has(c)||(n.add(c),r.push({authors:a,year:l,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(),l=parseInt(s[2]),c=`${a.toLowerCase()}|${l}`;n.has(c)||(n.add(c),r.push({authors:a,year:l,raw:s[0]}))}return r}function rDt(t){return t.replace(/\s+et\s+al\.?/i,"").replace(/\s*&\s*.+$/,"").trim().split(/[\s,]/)[0].toLowerCase()}function nDt(t,e){if(!e||!Array.isArray(e)||e.length===0)return!1;const r=rDt(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 zke(t,e){var s,i,a,l,c,u,d,h,f,p,m,g;const r=[],n=[];for(const y of t){let x=!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=(l=(a=(i=b.crossref_data)==null?void 0:i.crossref_metadata)==null?void 0:a.issued)==null?void 0:l["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))!==y.year)continue;const j=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(nDt(y.authors,j)){r.push({citation:y,documentId:v.id,citationApa:v.citation_apa||`${y.authors} (${y.year}). ${v.title||"Untitled"}.`,title:v.title||void 0}),x=!0;break}}x||n.push(y)}return{matched:r,unmatched:n}}function Uke(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 zG(t,e){const r=t.flatMap(s=>s.sections.map(i=>i.content)).join(`
`),n=Bke(r);return zke(n,e)}function sDt(t,e){const r=Bke(t);return zke(r,e)}const Hke={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 Wke(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 iDt(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,l)=>a.order_index-l.order_index);if(s.forEach((a,l)=>{r.push(`${l+1}. ${a.title.toUpperCase()}`),r.push(""),a.sections&&a.sections.length>0?(a.sections.some(u=>u.number)?[...a.sections]:[...a.sections].sort((u,d)=>u.order_index-d.order_index)).forEach((u,d)=>{const h=u.title||Hke[u.type]||u.type,f=u.number??`${l+1}.${d+1}`,p=u.level===2?"      ":"   ";if(r.push(`${p}${f} ${h}`),r.push(""),u.content&&u.content.trim()){const g=Wke(u.content).split(`
`).map(y=>`   ${p}${y}`).join(`
`);r.push(g),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=zG(t.chapters,t.documents),l=Uke(a);if(l.length>0){const c=s.length+1;r.push(`${c}. REFERENCES`),r.push(""),l.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 aDt(t,e){const r=[];if(await pDt(t),r.push(new Nr({children:[],spacing:{after:2400}})),r.push(new Nr({children:[new Ns({text:e.thesisTitle,bold:!0,size:56})],alignment:Vn.CENTER,spacing:{after:400}})),e.degreeProgram&&r.push(new Nr({children:[new Ns({text:e.degreeProgram,size:28,italics:!0})],alignment:Vn.CENTER,spacing:{after:800}})),e.authorName&&(r.push(new Nr({children:[new Ns({text:"Submitted by",size:24})],alignment:Vn.CENTER,spacing:{after:100}})),r.push(new Nr({children:[new Ns({text:e.authorName,bold:!0,size:28})],alignment:Vn.CENTER,spacing:{after:400}}))),e.institution&&r.push(new Nr({children:[new Ns({text:e.institution,size:24})],alignment:Vn.CENTER,spacing:{after:200}})),e.supervisor&&r.push(new Nr({children:[new Ns({text:`Supervisor: ${e.supervisor}`,size:24})],alignment:Vn.CENTER,spacing:{after:200}})),e.submissionDate){const i=new Date(e.submissionDate).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"});r.push(new Nr({children:[new Ns({text:i,size:24})],alignment:Vn.CENTER,spacing:{after:400}}))}r.push(new Nr({children:[new Lae]})),e.includeTableOfContents&&(r.push(new Nr({children:[new Ns({text:"TABLE OF CONTENTS",bold:!0,size:28})],alignment:Vn.CENTER,spacing:{after:400}})),r.push(new Nr({children:[new Ns({text:"[Update this Table of Contents in Word: Right-click → Update Field]",italics:!0,size:20,color:"888888"})],alignment:Vn.CENTER,spacing:{after:200}})),r.push(new $Mt("Table of Contents",{hyperlink:!0,headingStyleRange:"1-3"})),r.push(new Nr({children:[new Lae]})));const n=[...t.chapters].sort((i,a)=>i.order_index-a.order_index);if(n.forEach((i,a)=>{r.push(new Nr({text:`${a+1}. ${i.title}`,heading:KT.HEADING_1,spacing:{before:400,after:200}})),i.sections&&i.sections.length>0&&(i.sections.some(c=>c.number)?[...i.sections]:[...i.sections].sort((c,u)=>c.order_index-u.order_index)).forEach((c,u)=>{const d=c.title||Hke[c.type]||c.type,h=c.number??`${a+1}.${u+1}`;r.push(new Nr({text:`${h} ${d}`,heading:c.level===2?KT.HEADING_3:KT.HEADING_2,spacing:{before:300,after:150}}));const f=c.content_rich?uDt(c.content_rich):null;f&&f.length>0?r.push(...f):c.content&&c.content.trim()?Wke(c.content).split(`

`).forEach(g=>{g.trim()&&r.push(new Nr({children:[new Ns({text:g.trim(),size:24})],spacing:{after:200}}))}):r.push(new Nr({children:[new Ns({text:"[No content yet]",italics:!0,color:"888888",size:24})],spacing:{after:200}}))})}),e.includeLiterature&&t.documents&&t.documents.length>0){const i=zG(t.chapters,t.documents),a=Uke(i);a.length>0&&(r.push(new Nr({text:`${n.length+1}. References`,heading:KT.HEADING_1,spacing:{before:400,after:200}})),a.forEach(l=>{r.push(new Nr({children:[new Ns({text:l,size:24})],spacing:{after:120},indent:{left:720,hanging:720}}))}))}const s=new OMt({features:{updateFields:!0},numbering:lDt,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:mPt.DECIMAL}:void 0}},headers:{default:new FMt({children:[new Nr({alignment:Vn.LEFT,children:[new Ns({text:"Academly.ai",size:18,color:"666666",italics:!0})]})]})},footers:e.includePageNumbers?{default:new BMt({children:[new Nr({alignment:Vn.CENTER,children:[new Ns({children:["Page ",Jb.CURRENT," of ",Jb.TOTAL_PAGES],size:20})]})]})}:void 0,children:r}]});return await tDt.toBlob(s)}function Vke(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 oDt(t,e){const r="\uFEFF",n=new Blob([r+t],{type:"text/plain;charset=utf-8"});Vke(n,e)}const qke="rich-bullets",Gke="rich-ordered",lDt={config:[{reference:qke,levels:[0,1,2].map(t=>({level:t,format:Qo.BULLET,text:["•","◦","▪"][t],alignment:Vn.LEFT,style:{paragraph:{indent:{left:720*(t+1),hanging:360}}}}))},{reference:Gke,levels:[0,1,2].map(t=>({level:t,format:[Qo.DECIMAL,Qo.LOWER_LETTER,Qo.LOWER_ROMAN][t],text:`%${t+1}.`,alignment:Vn.LEFT,style:{paragraph:{indent:{left:720*(t+1),hanging:360}}}}))}]};let cDt=0;const zF=new Set(["p","blockquote","ul","ol","li","h1","h2","h3","h4","h5","h6","pre","div","hr","table","img","figure"]);function $P(t,e,r){if(t.nodeType===3){const a=(t.textContent||"").replace(/\s+/g," ");a&&r.push(new Ns({text:a,size:24,bold:e.bold,italics:e.italics,underline:e.underline?{}:void 0,strike:e.strike,font:e.code?"Courier New":void 0}));return}if(t.nodeType!==1)return;const n=t,s=n.tagName.toLowerCase();if(s==="br"){r.push(new Ns({break:1,size:24}));return}if(s==="img"){r.push(Kke(n));return}const i={...e};if((s==="strong"||s==="b")&&(i.bold=!0),(s==="em"||s==="i")&&(i.italics=!0),s==="u"&&(i.underline=!0),(s==="s"||s==="del"||s==="strike")&&(i.strike=!0),s==="code"&&(i.code=!0),n.childNodes.forEach(a=>$P(a,i,r)),s==="a"){const a=(n.getAttribute("href")||"").trim(),l=(n.textContent||"").trim();a&&a!==l&&!a.startsWith("#")&&r.push(new Ns({text:` (${a})`,size:24,bold:e.bold,italics:e.italics}))}}function Zae(t,e){return new Nr({children:t,spacing:{after:e.list?80:200},...e.list?{numbering:{reference:e.list.ref,level:Math.min(e.list.level,2),instance:e.list.instance}}:{},...e.quote&&!e.list?{indent:{left:720,right:360},border:{left:{style:Uh.SINGLE,size:12,color:"AAAAAA",space:12}}}:{}})}function Zg(t,e,r){let n=[];const s=()=>{var u;if(!n.length)return;const i=[],a=e.quote?{italics:!0}:{},l=n.some(d=>{var h;return d.nodeType===1&&(d.tagName.toLowerCase()==="img"||!!((h=d.querySelector)!=null&&h.call(d,"img")))});n.forEach(d=>$P(d,a,i)),n=[],i.length>0&&(((u=t.textContent)==null?void 0:u.trim())||l)&&r.push(Zae(i,e))};t.childNodes.forEach(i=>{var a;if(i.nodeType===1&&zF.has(i.tagName.toLowerCase())){s();const l=i,c=l.tagName.toLowerCase();if(c==="blockquote")Zg(l,{...e,quote:!0},r);else if(c==="ul"||c==="ol"){const u=e.list?e.list.level+1:0,d=c==="ol"?Gke:qke,h=c==="ol"?++cDt:0;Array.from(l.children).forEach(f=>{Zg(f,{...e,list:{ref:d,instance:h,level:u}},r)})}else if(c==="li")Zg(l,e,r);else if(/^h[1-6]$/.test(c)){const u=[];l.childNodes.forEach(d=>$P(d,{bold:!0},u)),u.length&&r.push(new Nr({children:u,spacing:{before:200,after:120},keepNext:!0}))}else if(c==="pre"){const u=(l.textContent||"").replace(/\n$/,"").split(`
`);r.push(new Nr({children:u.map((d,h)=>new Ns({text:d,font:"Courier New",size:20,break:h>0?1:void 0})),shading:{type:mke.CLEAR,fill:"F3F4F6",color:"auto"},border:{top:{style:Uh.SINGLE,size:4,color:"DDDDDD",space:4},bottom:{style:Uh.SINGLE,size:4,color:"DDDDDD",space:4},left:{style:Uh.SINGLE,size:4,color:"DDDDDD",space:4},right:{style:Uh.SINGLE,size:4,color:"DDDDDD",space:4}},spacing:{after:200}}))}else if(c==="table"){const u=hDt(l);u&&(r.push(u),r.push(new Nr({children:[],spacing:{after:120}})))}else if(c==="img")r.push(new Nr({children:[Kke(l)],alignment:Vn.CENTER,spacing:{after:200}}));else if(c==="figure")Zg(l,e,r);else if(c!=="hr"){const u=[];l.childNodes.forEach(h=>{h.nodeType===1&&zF.has(h.tagName.toLowerCase())||$P(h,e.quote?{italics:!0}:{},u)}),u.length&&((a=l.textContent)!=null&&a.trim()||l.querySelector("img"))&&r.push(Zae(u,e));const d=Array.from(l.childNodes).filter(h=>h.nodeType===1&&zF.has(h.tagName.toLowerCase()));if(d.length){const h=l.ownerDocument.createElement("div");d.forEach(f=>h.appendChild(f.cloneNode(!0))),Zg(h,e,r)}}}else n.push(i)}),s()}function uDt(t){try{if(!t||!t.trim()||typeof DOMParser>"u")return null;const e=new DOMParser().parseFromString(`<!DOCTYPE html><html><head></head><body>${t}</body></html>`,"text/html"),r=[];return Zg(e.body,{},r),r.length?r:null}catch(e){return console.warn("Rich export failed for section, using plain text",e),null}}const dDt=9026,Jae=600;function hDt(t){const e=Array.from(t.querySelectorAll("tr")).filter(l=>l.closest("table")===t);if(!e.length)return null;const r=Math.max(1,...e.map(l=>Array.from(l.children).filter(c=>/^(td|th)$/i.test(c.tagName)).length)),n=Math.floor(dDt/r),s=Array.from({length:r},()=>n),i={style:Uh.SINGLE,size:4,color:"999999"},a={top:i,bottom:i,left:i,right:i};return new oOt({width:{size:n*r,type:C0.DXA},columnWidths:s,rows:e.map(l=>{const c=Array.from(l.children).filter(f=>/^(td|th)$/i.test(f.tagName)),u=c.length>0&&c.every(f=>f.tagName.toLowerCase()==="th"),d=c.map(f=>{const p=Math.max(1,parseInt(f.getAttribute("colspan")||"1",10)||1),m=[];Zg(f,{},m);const g=m.filter(y=>y instanceof Nr);return f.tagName.toLowerCase()==="th"&&!g.length&&g.push(new Nr({children:[]})),new uO({borders:a,width:{size:n*p,type:C0.DXA},columnSpan:p>1?p:void 0,margins:{top:80,bottom:80,left:120,right:120},shading:f.tagName.toLowerCase()==="th"?{fill:"EEEEEE",type:mke.CLEAR,color:"auto"}:void 0,children:g.length?g:[new Nr({children:[]})]})});let h=c.reduce((f,p)=>f+Math.max(1,parseInt(p.getAttribute("colspan")||"1",10)||1),0);for(;h<r;)d.push(new uO({borders:a,width:{size:n,type:C0.DXA},children:[new Nr({children:[]})]})),h++;return new dOt({tableHeader:u,children:d})})})}const QH=new Map;function Kke(t){const e=t.getAttribute("data-storage-path")||"",r=t.getAttribute("alt")||"Image",n=e?QH.get(e):null;if(!n)return new Ns({text:`[Image unavailable: ${r}]`,italics:!0,size:20,color:"888888"});const s=parseInt(t.getAttribute("width")||"",10),i=Math.min(Jae,s>0?s:Jae),a=Math.min(1,i/n.width);return new QIt({type:n.type,data:n.data,transformation:{width:Math.round(n.width*a),height:Math.round(n.height*a)},altText:{title:r,description:r,name:r}})}async function fDt(t){var e,r,n;try{const s=await U9("documents",t,600);if(!s)return null;const i=await fetch(s);if(!i.ok)return null;const a=await i.blob(),l=await createImageBitmap(a),{width:c,height:u}=l,d=a.type.toLowerCase();if(d.includes("png")||d.includes("jpeg")||d.includes("jpg")||d.includes("gif")){(e=l.close)==null||e.call(l);const p=d.includes("png")?"png":d.includes("gif")?"gif":"jpg";return{data:new Uint8Array(await a.arrayBuffer()),type:p,width:c,height:u}}const h=document.createElement("canvas");h.width=c,h.height=u,(r=h.getContext("2d"))==null||r.drawImage(l,0,0),(n=l.close)==null||n.call(l);const f=await new Promise(p=>h.toBlob(p,"image/png"));return f?{data:new Uint8Array(await f.arrayBuffer()),type:"png",width:c,height:u}:null}catch(s){return console.warn("Export image could not be loaded",t,s),null}}async function pDt(t){QH.clear();const e=new Set,r=/data-storage-path="([^"]+)"/g;JSON.stringify(t,(n,s)=>{if(typeof s=="string"&&s.includes("data-storage-path")){let i;for(;i=r.exec(s);)e.add(i[1].replace(/&amp;/g,"&"))}return s}),await Promise.all(Array.from(e).map(async n=>QH.set(n,await fDt(n))))}function Yke({open:t,onOpenChange:e,thesisData:r,defaultAuthorName:n="",defaultInstitution:s="",defaultDegreeProgram:i="",documents:a=[]}){const[l,c]=S.useState("docx"),[u,d]=S.useState(!1),[h,f]=S.useState(""),[p,m]=S.useState(""),[g,y]=S.useState(""),[x,v]=S.useState(""),[b,w]=S.useState(""),[j,N]=S.useState(""),[C,A]=S.useState(!0),[E,O]=S.useState(!0),[$,T]=S.useState(!0);S.useEffect(()=>{if(t&&r){f(r.thesis.title||""),m(n),y(s);const K=r.thesis.degree==="bachelor"?"Bachelor":"Master";v(i||`${K} Thesis`),r.thesis.due_date?N(r.thesis.due_date.split("T")[0]):N(new Date().toISOString().split("T")[0])}},[t,r,n,s,i]);const M=async()=>{if(r){d(!0);try{const K={format:l,thesisTitle:h,authorName:p||void 0,institution:g||void 0,degreeProgram:x||void 0,supervisor:b||void 0,submissionDate:j||void 0,includePageNumbers:C,includeTableOfContents:E,includeLiterature:$},H=$&&a.length>0?{...r,documents:a}:r,ee=h.replace(/[^a-zA-Z0-9äöüÄÖÜß\s-]/g,"_").trim(),V=new Date().toISOString().split("T")[0];switch(l){case"txt":{const B=iDt(H,K);oDt(B,`${ee}_${V}.txt`);break}case"docx":{const B=await aDt(H,K);Vke(B,`${ee}_${V}.docx`);break}case"pdf":{console.warn("PDF export not yet implemented");break}}e(!1)}catch(K){console.error("Export error:",K)}finally{d(!1)}}},k=[{value:"txt",label:"TXT",icon:o.jsx(jr,{className:"h-5 w-5"}),description:"Plain text, no formatting",disabled:!1},{value:"docx",label:"DOCX",icon:o.jsx(YOe,{className:"h-5 w-5"}),description:"Word document with styles",disabled:!1},{value:"pdf",label:"PDF",icon:o.jsx(bMe,{className:"h-5 w-5"}),description:"Coming soon",disabled:!0}],D=l==="docx"||l==="pdf";return o.jsx(jn,{open:t,onOpenChange:e,children:o.jsxs(pn,{className:"sm:max-w-[500px] max-h-[90vh] overflow-y-auto",children:[o.jsxs(mn,{children:[o.jsx(gn,{children:"Export Thesis"}),o.jsx(og,{children:"Choose export format and customize the template"})]}),o.jsxs("div",{className:"space-y-6 py-4",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx(Se,{className:"text-sm font-medium",children:"Format"}),o.jsx("div",{className:"grid grid-cols-3 gap-2",children:k.map(K=>o.jsxs("button",{type:"button",onClick:()=>!K.disabled&&c(K.value),disabled:K.disabled,className:Pe("flex flex-col items-center gap-2 p-4 rounded-lg border-2 transition-all",K.disabled&&"opacity-50 cursor-not-allowed",!K.disabled&&l===K.value?"border-primary bg-primary/5":K.disabled?"border-border":"border-border hover:border-primary/50"),children:[o.jsx("div",{className:Pe("p-2 rounded-full",!K.disabled&&l===K.value?"bg-primary text-primary-foreground":"bg-muted"),children:K.icon}),o.jsx("span",{className:"font-medium text-sm",children:K.label}),o.jsx("span",{className:"text-xs text-muted-foreground text-center",children:K.description})]},K.value))})]}),D&&o.jsxs(o.Fragment,{children:[o.jsx(Eo,{}),o.jsxs("div",{className:"space-y-4",children:[o.jsx(Se,{className:"text-sm font-medium",children:"Template Settings"}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"thesis-title",className:"text-xs text-muted-foreground",children:"Thesis Title"}),o.jsx(Ue,{id:"thesis-title",value:h,onChange:K=>f(K.target.value),placeholder:"Enter thesis title"})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"author-name",className:"text-xs text-muted-foreground",children:"Author Name"}),o.jsx(Ue,{id:"author-name",value:p,onChange:K=>m(K.target.value),placeholder:"Your name"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"institution",className:"text-xs text-muted-foreground",children:"Institution"}),o.jsx(Ue,{id:"institution",value:g,onChange:K=>y(K.target.value),placeholder:"University name"})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"degree-program",className:"text-xs text-muted-foreground",children:"Degree / Program"}),o.jsx(Ue,{id:"degree-program",value:x,onChange:K=>v(K.target.value),placeholder:"e.g., Master of Science"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"supervisor",className:"text-xs text-muted-foreground",children:"Supervisor"}),o.jsx(Ue,{id:"supervisor",value:b,onChange:K=>w(K.target.value),placeholder:"Prof. Dr. Name"})]})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"submission-date",className:"text-xs text-muted-foreground",children:"Submission Date"}),o.jsx(Ue,{id:"submission-date",type:"date",value:j,onChange:K=>N(K.target.value)})]})]})]}),o.jsx(Eo,{}),o.jsxs("div",{className:"space-y-4",children:[o.jsx(Se,{className:"text-sm font-medium",children:"Layout Options"}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(aa,{id:"page-numbers",checked:C,onCheckedChange:K=>A(K===!0)}),o.jsx(Se,{htmlFor:"page-numbers",className:"text-sm font-normal cursor-pointer",children:"Include page numbers"})]}),o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(aa,{id:"toc",checked:E,onCheckedChange:K=>O(K===!0)}),o.jsx(Se,{htmlFor:"toc",className:"text-sm font-normal cursor-pointer",children:"Include table of contents"})]})]})]})]}),o.jsx(Eo,{}),o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(aa,{id:"literature",checked:$,onCheckedChange:K=>T(K===!0)}),o.jsx(Se,{htmlFor:"literature",className:"text-sm font-normal cursor-pointer",children:"Auto-generate Literature from citations"})]})]}),o.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[o.jsx(me,{variant:"outline",onClick:()=>e(!1),children:"Cancel"}),o.jsx(me,{onClick:M,disabled:u||!r,children:u?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"h-4 w-4 mr-2 animate-spin"}),"Exporting..."]}):o.jsxs(o.Fragment,{children:[o.jsx(ko,{className:"h-4 w-4 mr-2"}),"Download"]})})]})]})})}var a5="Popover",[Xke,JWt]=Vs(a5,[ig]),wA=ig(),[mDt,bg]=Xke(a5),Qke=t=>{const{__scopePopover:e,children:r,open:n,defaultOpen:s,onOpenChange:i,modal:a=!1}=t,l=wA(e),c=S.useRef(null),[u,d]=S.useState(!1),[h,f]=ca({prop:n,defaultProp:s??!1,onChange:i,caller:a5});return o.jsx(YM,{...l,children:o.jsx(mDt,{scope:e,contentId:Co(),triggerRef:c,open:h,onOpenChange:f,onOpenToggle:S.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:u,onCustomAnchorAdd:S.useCallback(()=>d(!0),[]),onCustomAnchorRemove:S.useCallback(()=>d(!1),[]),modal:a,children:r})})};Qke.displayName=a5;var Zke="PopoverAnchor",gDt=S.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,s=bg(Zke,r),i=wA(r),{onCustomAnchorAdd:a,onCustomAnchorRemove:l}=s;return S.useEffect(()=>(a(),()=>l()),[a,l]),o.jsx(IE,{...i,...n,ref:e})});gDt.displayName=Zke;var Jke="PopoverTrigger",eCe=S.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,s=bg(Jke,r),i=wA(r),a=qt(e,s.triggerRef),l=o.jsx(ft.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":iCe(s.open),...n,ref:a,onClick:Qe(t.onClick,s.onOpenToggle)});return s.hasCustomAnchor?l:o.jsx(IE,{asChild:!0,...i,children:l})});eCe.displayName=Jke;var UG="PopoverPortal",[xDt,yDt]=Xke(UG,{forceMount:void 0}),tCe=t=>{const{__scopePopover:e,forceMount:r,children:n,container:s}=t,i=bg(UG,e);return o.jsx(xDt,{scope:e,forceMount:r,children:o.jsx(pi,{present:r||i.open,children:o.jsx(tj,{asChild:!0,container:s,children:n})})})};tCe.displayName=UG;var z1="PopoverContent",rCe=S.forwardRef((t,e)=>{const r=yDt(z1,t.__scopePopover),{forceMount:n=r.forceMount,...s}=t,i=bg(z1,t.__scopePopover);return o.jsx(pi,{present:n||i.open,children:i.modal?o.jsx(bDt,{...s,ref:e}):o.jsx(wDt,{...s,ref:e})})});rCe.displayName=z1;var vDt=zm("PopoverContent.RemoveScroll"),bDt=S.forwardRef((t,e)=>{const r=bg(z1,t.__scopePopover),n=S.useRef(null),s=qt(e,n),i=S.useRef(!1);return S.useEffect(()=>{const a=n.current;if(a)return fD(a)},[]),o.jsx($E,{as:vDt,allowPinchZoom:!0,children:o.jsx(nCe,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Qe(t.onCloseAutoFocus,a=>{var l;a.preventDefault(),i.current||(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Qe(t.onPointerDownOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Qe(t.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),wDt=S.forwardRef((t,e)=>{const r=bg(z1,t.__scopePopover),n=S.useRef(!1),s=S.useRef(!1);return o.jsx(nCe,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var a,l;(a=t.onCloseAutoFocus)==null||a.call(t,i),i.defaultPrevented||(n.current||(l=r.triggerRef.current)==null||l.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()}})}),nCe=S.forwardRef((t,e)=>{const{__scopePopover:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onInteractOutside:d,...h}=t,f=bg(z1,r),p=wA(r);return hD(),o.jsx(DE,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:i,children:o.jsx(Ev,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:d,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),children:o.jsx(XM,{"data-state":iCe(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)"}})})})}),sCe="PopoverClose",jDt=S.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,s=bg(sCe,r);return o.jsx(ft.button,{type:"button",...n,ref:e,onClick:Qe(t.onClick,()=>s.onOpenChange(!1))})});jDt.displayName=sCe;var SDt="PopoverArrow",_Dt=S.forwardRef((t,e)=>{const{__scopePopover:r,...n}=t,s=wA(r);return o.jsx(QM,{...s,...n,ref:e})});_Dt.displayName=SDt;function iCe(t){return t?"open":"closed"}var NDt=Qke,kDt=eCe,CDt=tCe,aCe=rCe;const oCe=NDt,lCe=kDt,HG=S.forwardRef(({className:t,align:e="center",sideOffset:r=4,...n},s)=>o.jsx(CDt,{children:o.jsx(aCe,{ref:s,align:e,sideOffset:r,className:Pe("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})}));HG.displayName=aCe.displayName;function EDt({content:t,documents:e}){const r=S.useMemo(()=>!t||e.length===0?{matched:[],unmatched:[]}:sDt(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 o.jsxs(oCe,{children:[o.jsx(lCe,{asChild:!0,children:o.jsxs("button",{type:"button",onClick:a=>a.stopPropagation(),className:"flex items-center gap-1 shrink-0",title:`${r.matched.length}/${n} citations matched`,children:[o.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${i}`}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.matched.length,"/",n]})]})}),o.jsx(HG,{className:"w-80 p-3",align:"start",onClick:a=>a.stopPropagation(),children:o.jsxs("div",{className:"space-y-2",children:[o.jsx("p",{className:"text-sm font-medium",children:"Citations in this section"}),r.matched.length>0&&o.jsx("div",{className:"space-y-1",children:r.matched.map((a,l)=>o.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[o.jsx(kr,{className:"h-3.5 w-3.5 text-green-500 shrink-0 mt-0.5"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:a.citation.raw}),a.title&&o.jsx("p",{className:"text-muted-foreground truncate",children:a.title})]})]},l))}),r.unmatched.length>0&&o.jsx("div",{className:"space-y-1",children:r.unmatched.map((a,l)=>o.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[o.jsx(fn,{className:"h-3.5 w-3.5 text-red-500 shrink-0 mt-0.5"}),o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:a.raw}),o.jsx("p",{className:"text-muted-foreground",children:"Not found — add via Citation Manager"})]})]},l))})]})})]})}const eoe={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"},toe={open:"secondary",in_progress:"warning",done:"success"},roe={open:"Open",in_progress:"In Progress",done:"Done"},ADt=["Introduction","Literature Review","Methodology","Findings","Discussion","Conclusion","References"],TDt=()=>{const{user:t,loading:e,researchProfile:r}=Ht(),n=Or(),{toast:s}=Bn(),[i,a]=S.useState([]),[l,c]=S.useState(""),[u,d]=S.useState(null),[h,f]=S.useState(0),[p,m]=S.useState([]),[g,y]=S.useState({}),[x,v]=S.useState([]),[b,w]=S.useState(!1),[j,N]=S.useState(!1),[C,A]=S.useState(!1),[E,O]=S.useState(!1),[$,T]=S.useState(!1),[M,k]=S.useState([]),[D,K]=S.useState({title:"",degree:"bachelor",description:"",due_date:"",target_word_count:15e3}),[H,ee]=S.useState({title:"",degree:"bachelor",description:"",due_date:"",target_word_count:15e3}),[V,B]=S.useState(""),[z,F]=S.useState(!1),[G,Q]=S.useState(null),[ie,se]=S.useState([]);S.useEffect(()=>{!t&&!e&&n("/login")},[t,e,n]),S.useEffect(()=>{t&&(q(),L())},[t]),S.useEffect(()=>{if(l){Z();const ne=i.find(fe=>fe.id===l);d(ne||null),ne&&ee({title:ne.title,degree:ne.degree,description:ne.description||"",due_date:ne.due_date||"",target_word_count:ne.target_word_count||15e3})}},[l,i]);const q=async()=>{w(!0);try{const{data:ne,error:fe}=await pe.from("theses").select("id, title, degree, description, due_date, target_word_count, created_at").order("created_at",{ascending:!1});if(fe)throw fe;a(ne||[])}catch(ne){console.error("Error loading theses:",ne),s({title:"Error",description:"Failed to load theses.",variant:"destructive"})}finally{w(!1)}},L=async()=>{try{const{data:ne,error:fe}=await pe.from("documents").select("id, title, citation_apa, bib_meta").eq("user_id",t==null?void 0:t.id);if(fe)throw fe;se(ne||[])}catch(ne){console.error("Error loading documents for citation matching:",ne)}},Z=async()=>{if(l){N(!0);try{const{data:ne,error:fe}=await pe.from("v_thesis_progress").select("thesis_progress").eq("thesis_id",l).single();fe&&fe.code!=="PGRST116"?console.error("Error loading thesis progress:",fe):f((ne==null?void 0:ne.thesis_progress)||0);const{data:be,error:xe}=await pe.from("chapters").select("*").eq("thesis_id",l).is("parent_id",null).order("order_index",{ascending:!0}).order("created_at",{ascending:!0});if(xe)throw xe;const _e=(be==null?void 0:be.map(Te=>Te.id))||[];if(_e.length>0){const{data:Te,error:ot}=await pe.from("v_chapter_progress").select("chapter_id, computed_progress").in("chapter_id",_e);ot&&console.error("Error loading chapter progress:",ot);const wt=(be==null?void 0:be.map(Ct=>{var pr;return{...Ct,computed_progress:((pr=Te==null?void 0:Te.find(Kt=>Kt.chapter_id===Ct.id))==null?void 0:pr.computed_progress)||0}}))||[];m(wt)}else m([]);const{data:ke,error:$e}=await pe.from("progress_log").select("*").eq("thesis_id",l).order("timestamp",{ascending:!1}).limit(10);$e?console.error("Error loading progress log:",$e):v(ke||[])}catch(ne){console.error("Error loading thesis data:",ne),s({title:"Error",description:"Failed to load data.",variant:"destructive"})}finally{N(!1)}}},J=async ne=>{try{const{data:fe,error:be}=await pe.from("sections").select("*").eq("chapter_id",ne).order("order_index",{ascending:!0}).order("created_at",{ascending:!0});if(be)throw be;y(xe=>({...xe,[ne]:fe||[]}))}catch(fe){console.error("Error loading sections:",fe),s({title:"Error",description:"Failed to load sections.",variant:"destructive"})}},W=async ne=>{const{data:fe,error:be}=await pe.from("v_chapter_progress").select("chapter_id, computed_progress").eq("chapter_id",ne).single();!be&&fe&&m(xe=>xe.map(_e=>_e.id===ne?{..._e,computed_progress:fe.computed_progress}:_e))},X=async()=>{if(!D.title.trim()){s({title:"Error",description:"Title is required.",variant:"destructive"});return}try{const{data:ne,error:fe}=await pe.from("theses").insert({user_id:t==null?void 0:t.id,title:D.title,degree:D.degree,description:D.description||null,due_date:D.due_date||null,target_word_count:D.target_word_count}).select("id").single();if(fe)throw fe;const{error:be}=await pe.rpc("seed_default_chapters",{p_thesis:ne.id});if(be)throw be;s({title:"Success",description:"Thesis created with default chapters."}),K({title:"",degree:"bachelor",description:"",due_date:"",target_word_count:15e3}),A(!1),await q(),c(ne.id)}catch(ne){console.error("Error creating thesis:",ne),s({title:"Error",description:ne.message||"Failed to create thesis.",variant:"destructive"})}},he=async()=>{if(!H.title.trim()){s({title:"Error",description:"Title is required.",variant:"destructive"});return}try{const{error:ne}=await pe.from("theses").update({title:H.title,degree:H.degree,description:H.description||null,due_date:H.due_date||null,target_word_count:H.target_word_count}).eq("id",l);if(ne)throw ne;s({title:"Success",description:"Thesis updated successfully."}),O(!1),await q()}catch(ne){console.error("Error updating thesis:",ne),s({title:"Error",description:ne.message||"Failed to update thesis.",variant:"destructive"})}},P=async()=>{try{const{error:ne}=await pe.from("theses").delete().eq("id",l);if(ne)throw ne;s({title:"Success",description:"Thesis deleted successfully."}),c(""),d(null),await q()}catch(ne){console.error("Error deleting thesis:",ne),s({title:"Error",description:ne.message||"Failed to delete thesis.",variant:"destructive"})}},oe=async(ne,fe,be)=>{if(l)try{const xe=fe?p.find($e=>$e.id===fe):null,_e=be??((xe==null?void 0:xe.computed_progress)||0);await pe.from("progress_log").insert({thesis_id:l,chapter_id:fe||null,completed:_e,note:ne});const{data:ke}=await pe.from("progress_log").select("*").eq("thesis_id",l).order("timestamp",{ascending:!1}).limit(10);ke&&v(ke)}catch(xe){console.error("Error logging activity:",xe)}},Y=async ne=>{try{const fe=p.length>0?Math.max(...p.map(xe=>xe.order_index)):0,{error:be}=await pe.from("chapters").insert({thesis_id:l,title:ne,order_index:fe+10,status:"open"});if(be)throw be;s({title:"Success",description:"Chapter added successfully."}),await oe(`Chapter "${ne}" added`,void 0,0),B(""),T(!1),await Z()}catch(fe){console.error("Error adding chapter:",fe),s({title:"Error",description:fe.message||"Failed to add chapter.",variant:"destructive"})}},R=async ne=>{const fe=p.find(xe=>xe.id===ne),be=(fe==null?void 0:fe.title)||"Chapter";try{const{error:xe}=await pe.from("chapters").delete().eq("id",ne);if(xe)throw xe;s({title:"Success",description:"Chapter deleted successfully."}),await oe(`Chapter "${be}" removed`),await Z()}catch(xe){console.error("Error deleting chapter:",xe),s({title:"Error",description:xe.message||"Failed to delete chapter.",variant:"destructive"})}},I=async(ne,fe)=>{try{const{error:be}=await pe.from("chapters").update({title:fe}).eq("id",ne);if(be)throw be;m(xe=>xe.map(_e=>_e.id===ne?{..._e,title:fe}:_e))}catch(be){console.error("Error updating chapter title:",be),s({title:"Error",description:"Failed to update chapter title.",variant:"destructive"})}},U=async(ne,fe="other")=>{const be=p.find(_e=>_e.id===ne),xe=(be==null?void 0:be.title)||"Chapter";try{const _e=g[ne]||[],ke=_e.length>0?Math.max(..._e.map(Te=>Te.order_index)):0,{error:$e}=await pe.from("sections").insert({chapter_id:ne,type:fe,status:"open",content:"",order_index:ke+1});if($e)throw $e;s({title:"Success",description:"Section added."}),await J(ne),await W(ne),await oe(`Section added to "${xe}"`,ne)}catch(_e){console.error("Error creating section:",_e),s({title:"Error",description:"Failed to create section.",variant:"destructive"})}},re=async(ne,fe)=>{const be=Object.values(g).flat().find($e=>$e.id===ne),xe=be?p.find($e=>$e.id===be.chapter_id):null,_e=(be==null?void 0:be.title)||eoe[(be==null?void 0:be.type)||"other"],ke=(xe==null?void 0:xe.title)||"Chapter";try{const{error:$e}=await pe.from("sections").update(fe).eq("id",ne);if($e)throw $e;if(be&&(await J(be.chapter_id),await W(be.chapter_id),fe.status&&fe.status!==be.status)){const Te=fe.status==="done"?"completed":fe.status==="in_progress"?"in progress":"reopened";await oe(`"${_e}" ${Te} in "${ke}"`,be.chapter_id)}}catch($e){console.error("Error updating section:",$e),s({title:"Error",description:"Failed to update section.",variant:"destructive"})}},ue=async ne=>{const fe=Object.values(g).flat().find(ke=>ke.id===ne);if(!fe)return;const be=p.find(ke=>ke.id===fe.chapter_id),xe=fe.title||eoe[fe.type],_e=(be==null?void 0:be.title)||"Chapter";try{const{error:ke}=await pe.from("sections").delete().eq("id",ne);if(ke)throw ke;s({title:"Success",description:"Section deleted."}),await J(fe.chapter_id),await W(fe.chapter_id),await oe(`"${xe}" removed from "${_e}"`,fe.chapter_id)}catch(ke){console.error("Error deleting section:",ke),s({title:"Error",description:"Failed to delete section.",variant:"destructive"})}},ae=ne=>ne+1,ge=(ne,fe)=>`${ne+1}.${fe+1}`,we=()=>{const ne=p.map(fe=>fe.title.toLowerCase());return ADt.filter(fe=>!ne.includes(fe.toLowerCase()))},ce=ne=>ne?ne.includes("completed")?o.jsx(uc,{className:"h-4 w-4 text-green-500"}):ne.includes("in progress")?o.jsx(sg,{className:"h-4 w-4 text-yellow-500"}):ne.includes("added")?o.jsx(Khe,{className:"h-4 w-4 text-blue-500"}):ne.includes("removed")||ne.includes("reopened")?o.jsx(zOe,{className:"h-4 w-4 text-red-500"}):o.jsx(n1,{className:"h-4 w-4 text-muted-foreground"}):o.jsx(n1,{className:"h-4 w-4 text-muted-foreground"});return e||b?o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?o.jsx(Cr,{showSidebar:!0,children:o.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[o.jsx("div",{className:"flex items-center justify-between",children:o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold",children:"Thesis Builder"}),o.jsx("p",{className:"text-muted-foreground mt-2",children:"Manage your thesis with structured chapters and sections."})]})}),o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Select or Create Thesis"})}),o.jsx(st,{children:o.jsxs("div",{className:"flex gap-4 flex-wrap",children:[o.jsxs("div",{className:"flex-1 min-w-[200px]",children:[o.jsx(Se,{htmlFor:"thesis-select",children:"Existing Thesis"}),o.jsxs(pt,{value:l,onValueChange:c,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select thesis..."})}),o.jsx(dt,{children:i.map(ne=>o.jsxs(Le,{value:ne.id,children:[ne.title," (",ne.degree,")"]},ne.id))})]})]}),o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsxs(jn,{open:C,onOpenChange:A,children:[o.jsx(fd,{asChild:!0,children:o.jsxs(me,{children:[o.jsx(Bs,{className:"mr-2 h-4 w-4"}),"New Thesis"]})}),o.jsxs(pn,{children:[o.jsx(mn,{children:o.jsx(gn,{children:"Create New Thesis"})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"title",children:"Title *"}),o.jsx(Ue,{id:"title",value:D.title,onChange:ne=>K(fe=>({...fe,title:ne.target.value})),placeholder:"Thesis title"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"degree",children:"Degree"}),o.jsxs(pt,{value:D.degree,onValueChange:ne=>K(fe=>({...fe,degree:ne})),children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"bachelor",children:"Bachelor"}),o.jsx(Le,{value:"master",children:"Master"})]})]})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"description",children:"Description (optional)"}),o.jsx(lr,{id:"description",value:D.description,onChange:ne=>K(fe=>({...fe,description:ne.target.value})),placeholder:"Brief description of the thesis"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"due_date",children:"Due Date (optional)"}),o.jsx(Ue,{id:"due_date",type:"date",value:D.due_date,onChange:ne=>K(fe=>({...fe,due_date:ne.target.value}))})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Se,{htmlFor:"target_word_count",children:"Target Word Count"}),o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(lf,{className:"h-4 w-4 text-muted-foreground cursor-help"})}),o.jsxs(xr,{side:"right",className:"max-w-[260px] text-xs leading-relaxed",children:[o.jsx("p",{className:"font-medium mb-1",children:"Approximate page count (A4, 12pt, 1.5 spacing):"}),o.jsxs("ul",{className:"space-y-0.5",children:[o.jsx("li",{children:"~3,000 words ≈ 10–12 pages"}),o.jsx("li",{children:"~5,000 words ≈ 18–20 pages"}),o.jsx("li",{children:"~10,000 words ≈ 35–40 pages"}),o.jsx("li",{children:"~15,000 words ≈ 55–60 pages"})]})]})]})]}),o.jsx(Ue,{id:"target_word_count",type:"number",min:"1000",step:"500",value:D.target_word_count,onChange:ne=>K(fe=>({...fe,target_word_count:parseInt(ne.target.value)||15e3})),placeholder:"15000"})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(me,{variant:"outline",onClick:()=>A(!1),children:"Cancel"}),o.jsx(me,{onClick:X,children:"Create"})]})]})]})]}),l&&o.jsxs(o.Fragment,{children:[o.jsx(me,{variant:"outline",size:"icon",onClick:async()=>{if(!u)return;const ne={...g};for(const be of p)if(!ne[be.id]){const{data:xe}=await pe.from("sections").select("*").eq("chapter_id",be.id).order("order_index");ne[be.id]=xe||[]}const fe={thesis:u,chapters:p.map(be=>({title:be.title,order_index:be.order_index,status:be.status,sections:(ne[be.id]||[]).map(xe=>({title:xe.title,type:xe.type,content:xe.content,status:xe.status,word_count:xe.word_count,order_index:xe.order_index}))}))};Q(fe),F(!0)},title:"Export Thesis",children:o.jsx(ko,{className:"h-4 w-4"})}),o.jsxs(jn,{open:E,onOpenChange:O,children:[o.jsx(fd,{asChild:!0,children:o.jsx(me,{variant:"outline",size:"icon",children:o.jsx(HW,{className:"h-4 w-4"})})}),o.jsxs(pn,{children:[o.jsx(mn,{children:o.jsx(gn,{children:"Edit Thesis"})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"edit-title",children:"Title *"}),o.jsx(Ue,{id:"edit-title",value:H.title,onChange:ne=>ee(fe=>({...fe,title:ne.target.value})),placeholder:"Thesis title"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"edit-degree",children:"Degree"}),o.jsxs(pt,{value:H.degree,onValueChange:ne=>ee(fe=>({...fe,degree:ne})),children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"bachelor",children:"Bachelor"}),o.jsx(Le,{value:"master",children:"Master"})]})]})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"edit-description",children:"Description (optional)"}),o.jsx(lr,{id:"edit-description",value:H.description,onChange:ne=>ee(fe=>({...fe,description:ne.target.value})),placeholder:"Brief description of the thesis"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"edit-due_date",children:"Due Date (optional)"}),o.jsx(Ue,{id:"edit-due_date",type:"date",value:H.due_date,onChange:ne=>ee(fe=>({...fe,due_date:ne.target.value}))})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(Se,{htmlFor:"edit-target_word_count",children:"Target Word Count"}),o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(lf,{className:"h-4 w-4 text-muted-foreground cursor-help"})}),o.jsxs(xr,{side:"right",className:"max-w-[260px] text-xs leading-relaxed",children:[o.jsx("p",{className:"font-medium mb-1",children:"Approximate page count (A4, 12pt, 1.5 spacing):"}),o.jsxs("ul",{className:"space-y-0.5",children:[o.jsx("li",{children:"~3,000 words ≈ 10–12 pages"}),o.jsx("li",{children:"~5,000 words ≈ 18–20 pages"}),o.jsx("li",{children:"~10,000 words ≈ 35–40 pages"}),o.jsx("li",{children:"~15,000 words ≈ 55–60 pages"})]})]})]})]}),o.jsx(Ue,{id:"edit-target_word_count",type:"number",min:"1000",step:"500",value:H.target_word_count,onChange:ne=>ee(fe=>({...fe,target_word_count:parseInt(ne.target.value)||15e3})),placeholder:"15000"})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(me,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),o.jsx(me,{onClick:he,children:"Save Changes"})]})]})]})]}),o.jsxs(Mi,{children:[o.jsx(ru,{asChild:!0,children:o.jsx(me,{variant:"destructive",size:"icon",children:o.jsx(Pi,{className:"h-4 w-4"})})}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Thesis?"}),o.jsxs(hi,{children:['This will permanently delete the thesis "',u==null?void 0:u.title,'" and all its chapters and sections. This action cannot be undone.']})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})]})})]}),l&&o.jsxs(o.Fragment,{children:[o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(TE,{className:"h-5 w-5"}),"Overall Progress"]})}),o.jsx(st,{children:o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex justify-between text-sm",children:[o.jsx("span",{children:"Progress"}),o.jsxs("span",{children:[Math.round(h),"%"]})]}),o.jsx(yj,{value:h,className:"h-2"})]})})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[o.jsx("div",{className:"lg:col-span-2",children:o.jsxs(Ze,{children:[o.jsxs(Ot,{className:"flex flex-row items-center justify-between",children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(nr,{className:"h-5 w-5"}),"Chapters"]}),o.jsxs(_9,{children:[o.jsx(N9,{asChild:!0,children:o.jsxs(me,{variant:"outline",size:"sm",children:[o.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Add Chapter"]})}),o.jsxs(yD,{align:"end",children:[we().map(ne=>o.jsx(Ha,{onClick:()=>Y(ne),children:ne},ne)),we().length>0&&o.jsx(g0,{}),o.jsxs(Ha,{onClick:()=>T(!0),children:[o.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Custom Chapter..."]})]})]})]}),o.jsx(st,{children:j?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Xe,{className:"h-6 w-6 animate-spin"})}):p.length===0?o.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No chapters yet. Add your first chapter above."}):o.jsx(hG,{type:"multiple",value:M,onValueChange:k,className:"space-y-2",children:p.map((ne,fe)=>{var be;return o.jsxs(ML,{value:ne.id,className:"border rounded-lg px-4",children:[o.jsx(DL,{className:"hover:no-underline",onClick:()=>{g[ne.id]||J(ne.id)},children:o.jsxs("div",{className:"flex items-center justify-between w-full mr-4",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("span",{className:"text-muted-foreground font-mono text-sm",children:[ae(fe),"."]}),o.jsx(Ue,{value:ne.title,onChange:xe=>{m(_e=>_e.map(ke=>ke.id===ne.id?{...ke,title:xe.target.value}:ke))},onBlur:xe=>I(ne.id,xe.target.value),onClick:xe=>xe.stopPropagation(),className:"h-8 w-auto min-w-[150px] font-medium"}),o.jsx(kt,{variant:toe[ne.status],children:roe[ne.status]})]}),o.jsxs("div",{className:"flex items-center gap-2",onClick:xe=>xe.stopPropagation(),children:[o.jsxs("span",{className:"text-sm text-muted-foreground",children:[Math.round(ne.computed_progress||0),"%"]}),o.jsxs(Mi,{children:[o.jsx(ru,{asChild:!0,children:o.jsx(me,{size:"sm",variant:"ghost",children:o.jsx(Pi,{className:"h-4 w-4"})})}),o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Delete Chapter?"}),o.jsxs(hi,{children:['This will delete "',ne.title,'" and all its sections. This action cannot be undone.']})]}),o.jsxs(ui,{children:[o.jsx(Ws,{children:"Cancel"}),o.jsx(ai,{onClick:()=>R(ne.id),className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})]})]})]})}),o.jsx(LL,{children:o.jsxs("div",{className:"space-y-4 pt-4",children:[o.jsx("div",{className:"space-y-3",children:(be=g[ne.id])==null?void 0:be.map((xe,_e)=>o.jsxs("div",{className:"border rounded-lg p-4 space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[o.jsx("span",{className:"text-muted-foreground font-mono text-sm min-w-[40px]",children:ge(fe,_e)}),o.jsx(Ue,{value:xe.title||"",onChange:ke=>{y($e=>{var Te;return{...$e,[ne.id]:((Te=$e[ne.id])==null?void 0:Te.map(ot=>ot.id===xe.id?{...ot,title:ke.target.value}:ot))||[]}})},onBlur:ke=>re(xe.id,{title:ke.target.value||null}),placeholder:"Section title (optional)",className:"h-8 flex-1"}),o.jsx(EDt,{content:xe.content,documents:ie})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(kt,{variant:toe[xe.status],children:roe[xe.status]}),o.jsxs("span",{className:"text-sm text-muted-foreground",children:[xe.word_count," words"]}),o.jsx("div",{onClick:ke=>ke.stopPropagation(),children:o.jsxs(pt,{value:xe.status,onValueChange:ke=>re(xe.id,{status:ke}),children:[o.jsx(ut,{className:"w-32 h-8",children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"open",children:"Open"}),o.jsx(Le,{value:"in_progress",children:"In Progress"}),o.jsx(Le,{value:"done",children:"Done"})]})]})}),o.jsx(me,{size:"sm",variant:"ghost",onClick:ke=>{ke.stopPropagation(),ue(xe.id)},children:o.jsx(Pi,{className:"h-4 w-4"})})]})]}),o.jsx(lr,{value:xe.content,onChange:ke=>{const $e=ke.target.value;y(Te=>{var ot;return{...Te,[ne.id]:((ot=Te[ne.id])==null?void 0:ot.map(wt=>wt.id===xe.id?{...wt,content:$e}:wt))||[]}})},onBlur:ke=>re(xe.id,{content:ke.currentTarget.value}),placeholder:"Section content...",className:"min-h-[120px]"})]},xe.id))}),o.jsxs(me,{variant:"outline",onClick:()=>U(ne.id),className:"w-full",children:[o.jsx(Bs,{className:"mr-2 h-4 w-4"}),"Add Section"]})]})})]},ne.id)})})})]})}),o.jsx("div",{children:o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(jr,{className:"h-5 w-5"}),"Recent Activities"]})}),o.jsx(st,{children:o.jsx("div",{className:"space-y-3",children:x.length===0?o.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activities yet"}):x.map(ne=>o.jsxs("div",{className:"flex items-start gap-3 py-2",children:[ce(ne.note),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("p",{className:"text-sm font-medium truncate",children:ne.note||`${Math.round(ne.completed)}% completed`}),o.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(ne.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]})]},ne.id))})})]})})]})]}),o.jsx(jn,{open:$,onOpenChange:T,children:o.jsxs(pn,{children:[o.jsx(mn,{children:o.jsx(gn,{children:"Add Custom Chapter"})}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"chapter-title",children:"Chapter Title *"}),o.jsx(Ue,{id:"chapter-title",value:V,onChange:ne=>B(ne.target.value),placeholder:"e.g., Appendix, Acknowledgements"})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(me,{variant:"outline",onClick:()=>{B(""),T(!1)},children:"Cancel"}),o.jsx(me,{onClick:()=>{V.trim()&&Y(V.trim())},disabled:!V.trim(),children:"Add Chapter"})]})]})]})}),o.jsx(Yke,{open:z,onOpenChange:F,thesisData:G,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 UF({value:t,onSave:e,className:r,placeholder:n="Untitled",as:s="h2"}){const[i,a]=S.useState(!1),[l,c]=S.useState(t),u=S.useRef(null);S.useEffect(()=>{c(t)},[t]),S.useEffect(()=>{var g,y;i&&((g=u.current)==null||g.focus(),(y=u.current)==null||y.select())},[i]);const d=()=>{const g=l.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?o.jsx("input",{ref:u,value:l,onChange:g=>c(g.target.value),onBlur:p,onKeyDown:f,placeholder:n,className:Pe("w-full bg-transparent outline-none border-b border-primary/40 focus:border-primary",r)}):o.jsx(m,{onClick:()=>a(!0),title:"Click to rename",className:Pe("cursor-text rounded-sm hover:bg-muted/40 transition-colors",r),children:t||o.jsx("span",{className:"text-muted-foreground/60",children:n})})}function Ki(t){this.content=t}Ki.prototype={constructor:Ki,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 Ki(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 Ki(r)},addToStart:function(t,e){return new Ki([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var r=this.remove(t).content.slice();return r.push(t,e),new Ki(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 Ki(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=Ki.from(t),t.size?new Ki(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Ki.from(t),t.size?new Ki(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Ki.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}};Ki.from=function(t){if(t instanceof Ki)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new Ki(e)};function cCe(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,l=i.text,c=0;for(;a[c]==l[c];c++)r++;return c&&c<a.length&&c<l.length&&hCe(a.charCodeAt(c-1))&&dCe(a.charCodeAt(c))&&r--,r}if(s.content.size||i.content.size){let a=cCe(s.content,i.content,r+1);if(a!=null)return a}r+=s.nodeSize}}function uCe(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),l=e.child(--i),c=a.nodeSize;if(a==l){r-=c,n-=c;continue}if(!a.sameMarkup(l))return{a:r,b:n};if(a.isText&&a.text!=l.text){let u=a.text,d=l.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&&hCe(u.charCodeAt(h-1))&&dCe(u.charCodeAt(h))&&(r++,n++),{a:r,b:n}}if(a.content.size||l.content.size){let u=uCe(a.content,l.content,r-1,n-1);if(u)return u}r-=c,n-=c}}function dCe(t){return t>=56320&&t<57344}function hCe(t){return t>=55296&&t<56320}class Me{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,l=0;l<r;a++){let c=this.content[a],u=l+c.nodeSize;if(u>e&&n(c,s+l,i||null,a)!==!1&&c.content.size){let d=l+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,r-d),n,s+d)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,r,n,s){let i="",a=!0;return this.nodesBetween(e,r,(l,c)=>{let u=l.isText?l.text.slice(Math.max(e,c)-c,r-c):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.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 Me(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 l=this.content[i],c=a+l.nodeSize;c>e&&((a<e||c>r)&&(l.isText?l=l.cut(Math.max(0,e-a),Math.min(l.text.length,r-a)):l=l.cut(Math.max(0,e-a-1),Math.min(l.content.size,r-a-1))),n.push(l),s+=l.nodeSize),a=c}return new Me(n,s)}cutByIndex(e,r){return e==r?Me.empty:e==0&&r==this.content.length?this:new Me(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 Me(s,i)}addToStart(e){return new Me([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Me(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 cCe(this,e,r)}findDiffEnd(e,r=this.size,n=e.size){return uCe(this,e,r,n)}findIndex(e){if(e==0)return ZT(0,e);if(e==this.size)return ZT(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?ZT(r+1,i):ZT(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 Me.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return Me.fromArray(r.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Me.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 Me(r||e,n)}static from(e){if(!e)return Me.empty;if(e instanceof Me)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Me([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Me.empty=new Me([],0);const HF={index:0,offset:0};function ZT(t,e){return HF.index=t,HF.offset=e,HF}function dO(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(!dO(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!dO(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}let bn=class ZH{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&&dO(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`);return n.create(r.attrs)}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 ZH.none;if(e instanceof ZH)return[e];let r=e.slice();return r.sort((n,s)=>n.type.rank-s.type.rank),r}};bn.none=[];class Ck extends Error{}class at{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=pCe(this.content,e+this.openStart,r,this.openStart+1,this.openEnd+1);return n&&new at(n,this.openStart,this.openEnd)}removeBetween(e,r){return new at(fCe(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 at.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 at(Me.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 at(e,n,s)}}at.empty=new at(Me.empty,0,0);function fCe(t,e,r){let{index:n,offset:s}=t.findIndex(e),i=t.maybeChild(n),{index:a,offset:l}=t.findIndex(r);if(s==e||i.isText){if(l!=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(fCe(i.content,e-s-1,r-s-1)))}function pCe(t,e,r,n,s,i){let{index:a,offset:l}=t.findIndex(e),c=t.maybeChild(a);if(l==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=pCe(c.content,e-l-1,r,a==0?n-1:0,a==t.childCount-1?s-1:0,c);return u&&t.replaceChild(a,c.copy(u))}function PDt(t,e,r){if(r.openStart>t.depth)throw new Ck("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new Ck("Inconsistent open depths");return mCe(t,e,r,0)}function mCe(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=mCe(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,l=a.content;return qy(a,l.cut(0,t.parentOffset).append(r.content).append(l.cut(e.parentOffset)))}else{let{start:a,end:l}=IDt(r,t);return qy(i,xCe(t,a,l,e,n))}else return qy(i,hO(t,e,n))}function gCe(t,e){if(!e.type.compatibleContent(t.type))throw new Ck("Cannot join "+e.type.name+" onto "+t.type.name)}function JH(t,e,r){let n=t.node(r);return gCe(n,e.node(r)),n}function Vy(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 G_(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&&(Vy(t.nodeAfter,n),i++));for(let l=i;l<a;l++)Vy(s.child(l),n);e&&e.depth==r&&e.textOffset&&Vy(e.nodeBefore,n)}function qy(t,e){if(!t.type.validContent(e))throw new Ck("Invalid content for node "+t.type.name);return t.copy(e)}function xCe(t,e,r,n,s){let i=t.depth>s&&JH(t,e,s+1),a=n.depth>s&&JH(r,n,s+1),l=[];return G_(null,t,s,l),i&&a&&e.index(s)==r.index(s)?(gCe(i,a),Vy(qy(i,xCe(t,e,r,n,s+1)),l)):(i&&Vy(qy(i,hO(t,e,s+1)),l),G_(e,r,s,l),a&&Vy(qy(a,hO(r,n,s+1)),l)),G_(n,null,s,l),new Me(l)}function hO(t,e,r){let n=[];if(G_(null,t,r,n),t.depth>r){let s=JH(t,e,r+1);Vy(qy(s,hO(t,e,r+1)),n)}return G_(e,null,r,n),new Me(n)}function IDt(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(Me.from(s));return{start:s.resolveNoCache(t.openStart+r),end:s.resolveNoCache(s.content.size-t.openEnd-r)}}class Ek{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 bn.none;if(this.textOffset)return e.child(r).marks;let n=e.maybeChild(r-1),s=e.maybeChild(r);if(!n){let l=n;n=s,s=l}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 fO(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:l,offset:c}=a.content.findIndex(i),u=i-c;if(n.push(a,l,s+c),!u||(a=a.child(l),a.isText))break;i=u-1,s+=c+1}return new Ek(r,n,i)}static resolveCached(e,r){let n=noe.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 noe.set(e,n=new RDt);let s=n.elts[n.i]=Ek.resolve(e,r);return n.i=(n.i+1)%ODt,s}}class RDt{constructor(){this.elts=[],this.i=0}}const ODt=12,noe=new WeakMap;class fO{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 MDt=Object.create(null);let Rm=class e7{constructor(e,r,n,s=bn.none){this.type=e,this.attrs=r,this.marks=s,this.content=n||Me.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&&dO(this.attrs,r||e.defaultAttrs||MDt)&&bn.sameSet(this.marks,n||bn.none)}copy(e=null){return e==this.content?this:new e7(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new e7(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 at.empty;let s=this.resolve(e),i=this.resolve(r),a=n?0:s.sharedDepth(r),l=s.start(a),u=s.node(a).content.cut(s.pos-l,i.pos-l);return new at(u,s.depth-a,i.depth-a)}replace(e,r,n){return PDt(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 Ek.resolveCached(this,e)}resolveNoCache(e){return Ek.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()+")"),yCe(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=Me.empty,s=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,s,i),l=a&&a.matchFragment(this.content,r);if(!l||!l.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),soe(this.type.attrs,this.attrs,"node",this.type.name);let e=bn.none;for(let r=0;r<this.marks.length;r++){let n=this.marks[r];soe(n.type.attrs,n.attrs,"mark",n.type.name),e=n.addToSet(e)}if(!bn.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=Me.fromJSON(e,r.content);return e.nodeType(r.type).create(r.attrs,s,n)}};Rm.prototype.text=void 0;class pO extends Rm{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):yCe(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 pO(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pO(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 yCe(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}function soe(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])}class vv{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,r){let n=new DDt(e,r);if(n.next==null)return vv.empty;let s=vCe(n);n.next&&n.err("Unexpected trailing text");let i=HDt(UDt(s));return WDt(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,l){let c=a.matchFragment(e,n);if(c&&(!r||c.validEnd))return Me.from(l.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,l.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 l=s;l.type;l=l.via)a.push(l.type);return a.reverse()}for(let a=0;a<i.next.length;a++){let{type:l,next:c}=i.next[a];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in r)&&(!s.type||c.validEnd)&&(n.push({match:l.contentMatch,type:l,via:s}),r[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function 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(`
`)}}vv.empty=new vv(!0);class DDt{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 vCe(t){let e=[];do e.push(LDt(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function LDt(t){let e=[];do e.push($Dt(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function $Dt(t){let e=zDt(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=FDt(t,e);else break;return e}function ioe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function FDt(t,e){let r=ioe(t),n=r;return t.eat(",")&&(t.next!="}"?n=ioe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:e}}function BDt(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 zDt(t){if(t.eat("(")){let e=vCe(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=BDt(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 UDt(t){let e=[[]];return s(i(t,0),r()),e;function r(){return e.push([])-1}function n(a,l,c){let u={term:c,to:l};return e[a].push(u),u}function s(a,l){a.forEach(c=>c.to=l)}function i(a,l){if(a.type=="choice")return a.exprs.reduce((c,u)=>c.concat(i(u,l)),[]);if(a.type=="seq")for(let c=0;;c++){let u=i(a.exprs[c],l);if(c==a.exprs.length-1)return u;s(u,l=r())}else if(a.type=="star"){let c=r();return n(l,c),s(i(a.expr,c),c),[n(c)]}else if(a.type=="plus"){let c=r();return s(i(a.expr,l),c),s(i(a.expr,c),c),[n(c)]}else{if(a.type=="opt")return[n(l)].concat(i(a.expr,l));if(a.type=="range"){let c=l;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(l,void 0,a.value)];throw new Error("Unknown expr type")}}}}function bCe(t,e){return e-t}function aoe(t,e){let r=[];return n(e),r.sort(bCe);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:l,to:c}=i[a];!l&&r.indexOf(c)==-1&&n(c)}}}function HDt(t){let e=Object.create(null);return r(aoe(t,0));function r(n){let s=[];n.forEach(a=>{t[a].forEach(({term:l,to:c})=>{if(!l)return;let u;for(let d=0;d<s.length;d++)s[d][0]==l&&(u=s[d][1]);aoe(t,c).forEach(d=>{u||s.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let i=e[n.join(",")]=new vv(n.indexOf(t.length-1)>-1);for(let a=0;a<s.length;a++){let l=s[a][1].sort(bCe);i.next.push({type:s[a][0],next:e[l.join(",")]||r(l)})}return i}}function WDt(t,e){for(let r=0,n=[t];r<n.length;r++){let s=n[r],i=!s.validEnd,a=[];for(let l=0;l<s.next.length;l++){let{type:c,next:u}=s.next[l];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 wCe(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 jCe(t,e){let r=Object.create(null);for(let n in t){let s=t[n],i=e&&e[n];if(i===void 0)if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+n);else s.validate&&s.validate(i);r[n]=i}return r}function SCe(t,e){let r=Object.create(null);if(e)for(let n in e)r[n]=new qDt(t,n,e[n]);return r}let ooe=class _Ce{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=SCe(e,n.attrs),this.defaultAttrs=wCe(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==vv.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:jCe(this.attrs,e)}create(e=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Rm(this,this.computeAttrs(e),Me.from(r),bn.setFrom(n))}createChecked(e=null,r,n){return r=Me.from(r),this.checkContent(r),new Rm(this,this.computeAttrs(e),r,bn.setFrom(n))}createAndFill(e=null,r,n){if(e=this.computeAttrs(e),r=Me.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(Me.empty,!0);return i?new Rm(this,e,r.append(i),bn.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){}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:bn.none:e}static compile(e,r){let n=Object.create(null);e.forEach((i,a)=>n[i]=new _Ce(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 VDt(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 qDt{constructor(e,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?VDt(e,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class o5{constructor(e,r,n,s){this.name=e,this.rank=r,this.schema=n,this.spec=s,this.attrs=SCe(e,s.attrs),this.excluded=null;let i=wCe(this.attrs);this.instance=i?new bn(this,i):null}create(e=null){return!e&&this.instance?this.instance:new bn(this,jCe(this.attrs,e))}static compile(e,r){let n=Object.create(null),s=0;return e.forEach((i,a)=>n[i]=new o5(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]}excludes(e){return this.excluded.indexOf(e)>-1}}class WG{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=Ki.from(e.nodes),r.marks=Ki.from(e.marks||{}),this.nodes=ooe.compile(this.spec.nodes,this),this.marks=o5.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||"",l=i.spec.marks;if(i.contentMatch=n[a]||(n[a]=vv.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=l=="_"?null:l?loe(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],a=i.spec.excludes;i.excluded=a==null?[i]:a==""?[]:loe(this,a.split(" "))}this.nodeFromJSON=s=>Rm.fromJSON(this,s),this.markFromJSON=s=>bn.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 ooe){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 pO(n,n.defaultAttrs,e,bn.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 loe(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 l in t.marks){let c=t.marks[l];(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 GDt(t){return t.tag!=null}function KDt(t){return t.style!=null}let Om=class t7{constructor(e,r){this.schema=e,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(s=>{if(GDt(s))this.tags.push(s);else if(KDt(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 uoe(this,r,!1);return n.addAll(e,bn.none,r.from,r.to),n.finish()}parseSlice(e,r={}){let n=new uoe(this,r,!0);return n.addAll(e,bn.none,r.from,r.to),at.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(QDt(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],l=a.style;if(!(l.indexOf(e)!=0||a.context&&!n.matchesContext(a.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.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 l=r[a];if((l.priority==null?50:l.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=doe(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=doe(a)),a.node||a.ignore||a.mark||(a.node=s)})}return r}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new t7(e,t7.schemaRules(e)))}};const NCe={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},YDt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},kCe={ol:!0,ul:!0},Ak=1,r7=2,K_=4;function coe(t,e,r){return e!=null?(e?Ak:0)|(e==="full"?r7:0):t&&t.whitespace=="pre"?Ak|r7:r&~K_}class JT{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=bn.none,this.match=i||(a&K_?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Me.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&Ak)){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=Me.from(this.content);return!e&&this.match&&(r=r.append(this.match.fillBefore(Me.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&&!NCe.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class uoe{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=coe(null,r.preserveWhitespace,0)|(n?K_:0);s?i=new JT(s.type,s.attrs,bn.none,!0,r.topMatch||s.type.contentMatch,a):n?i=new JT(null,null,bn.none,!0,null,a):i=new JT(e.schema.topNodeType,null,bn.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&r7?"full":this.localPreserveWS||(s.options&Ak)>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 l=n.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(a.linebreakReplacement.create(),r,!0),l[c]&&this.insertNode(a.text(l[c]),r,!/\S/.test(l[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 l=s.content[s.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.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(),l;kCe.hasOwnProperty(a)&&this.parser.normalizeLists&&XDt(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(c?c.ignore:YDt.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(NCe.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?l: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 l=void 0;;){let c=this.parser.matchStyle(i,a,this,l);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)l=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 l=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(l)&&this.open--}addAll(e,r,n,s){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,l=s==null?null:e.childNodes[s];a!=l;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,l=0;a>=0;a--){let c=this.nodes[a],u=c.findWrapping(e);if(u&&(!s||s.length>u.length+l)&&(s=u,i=c,!u.length))break;if(c.solid){if(n)break;l+=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=bn.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):hoe(l.type,e.type))&&(a=l.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 l=coe(e,i,a.options);a.options&K_&&a.content.length==0&&(l|=K_);let c=bn.none;return n=n.filter(u=>(a.type?a.type.allowsMarkType(u.type):hoe(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new JT(e,r,c,s,null,l)),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|=Ak)}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=(l,c)=>{for(;l>=0;l--){let u=r[l];if(u==""){if(l==r.length-1||l==0)continue;for(;c>=i;c--)if(a(l-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 XDt(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&kCe.hasOwnProperty(n)&&r?(r.appendChild(e),e=r):n=="li"?r=e:n&&(r=null)}}function QDt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function doe(t){let e={};for(let r in t)e[r]=t[r];return e}function hoe(t,e){let r=e.schema.nodes;for(let n in r){let s=r[n];if(!s.allowsMarkType(t))continue;let i=[],a=l=>{i.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||i.indexOf(d)<0&&a(d))return!0}};if(a(s.contentMatch))return!0}}class Uv{constructor(e,r){this.nodes=e,this.marks=r}serializeFragment(e,r={},n){n||(n=e2(r).createDocumentFragment());let s=n,i=[];return e.forEach(a=>{if(i.length||a.marks.length){let l=0,c=0;for(;l<i.length&&c<a.marks.length;){let u=a.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(i[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<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 e2(r).createTextNode(e.text);let{dom:n,contentDOM:s}=FP(e2(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&&FP(e2(n),s(e,r),null,e.attrs)}static renderSpec(e,r,n=null,s){return typeof r=="string"?{dom:e.createTextNode(r)}:FP(e,r,n,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Uv(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let r=foe(e.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(e){return foe(e.marks)}}function foe(t){let e={};for(let r in t){let n=t[r].spec.toDOM;n&&(e[r]=n)}return e}function e2(t){return t.document||window.document}const poe=new WeakMap;function ZDt(t){let e=poe.get(t);return e===void 0&&poe.set(t,e=JDt(t)),e}function JDt(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 FP(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=ZDt(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 l,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}=FP(t,f,r,n);if(c.appendChild(p),m){if(l)throw new RangeError("Multiple content holes");l=m}}}return{dom:c,contentDOM:l}}const CCe=65535,ECe=Math.pow(2,16);function eLt(t,e){return t+e*ECe}function moe(t){return t&CCe}function tLt(t){return(t-(t&CCe))/ECe}const ACe=1,TCe=2,BP=4,PCe=8;class n7{constructor(e,r,n){this.pos=e,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&PCe)>0}get deletedBefore(){return(this.delInfo&(ACe|BP))>0}get deletedAfter(){return(this.delInfo&(TCe|BP))>0}get deletedAcross(){return(this.delInfo&BP)>0}}class sl{constructor(e,r=!1){if(this.ranges=e,this.inverted=r,!e.length&&sl.empty)return sl.empty}recover(e){let r=0,n=moe(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+tLt(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 l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?s:0);if(c>e)break;let u=this.ranges[l+i],d=this.ranges[l+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:eLt(l/3,e-c),g=0;return u&&(g|=e==c?TCe:e==h?ACe:BP,(r<0?e!=c:e!=h)&&(g|=PCe)),new n7(p,g,m)}s+=d-u}return n?e+s:new n7(e+s,0,null)}touches(e,r){let n=0,s=moe(r),i=this.inverted?2:1,a=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let c=this.ranges[l]-(this.inverted?n:0);if(c>e)break;let u=this.ranges[l+i],d=c+u;if(e<=d&&l==s*3)return!0;n+=this.ranges[l+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],l=a-(this.inverted?i:0),c=a+(this.inverted?0:i),u=this.ranges[s+r],d=this.ranges[s+n];e(l,l+u,c,c+d),i+=d-u}}invert(){return new sl(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?sl.empty:new sl(e<0?[0,-e,0]:[0,0,e])}}sl.empty=new sl([]);class Tk{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 Tk(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 Tk;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],l=a.mapResult(e,r);if(l.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,e=this._maps[c].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return n?e:new n7(e,s,null)}}const WF=Object.create(null);class Pa{getMap(){return sl.empty}merge(e){return null}static fromJSON(e,r){if(!r||!r.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=WF[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 WF)throw new RangeError("Duplicate use of step JSON ID "+e);return WF[e]=r,r.prototype.jsonID=e,r}}class zs{constructor(e,r){this.doc=e,this.failed=r}static ok(e){return new zs(e,null)}static fail(e){return new zs(null,e)}static fromReplace(e,r,n,s){try{return zs.ok(e.replace(r,n,s))}catch(i){if(i instanceof Ck)return zs.fail(i.message);throw i}}}function VG(t,e,r){let n=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(VG(i.content,e,i))),i.isInline&&(i=e(i,r,s)),n.push(i)}return Me.fromArray(n)}class xm extends Pa{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 at(VG(r.content,(a,l)=>!a.isAtom||!l.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),s),r.openStart,r.openEnd);return zs.fromReplace(e,this.from,this.to,i)}invert(){return new Ql(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 xm(r.pos,n.pos,this.mark)}merge(e){return e instanceof xm&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new xm(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 xm(r.from,r.to,e.markFromJSON(r.mark))}}Pa.jsonID("addMark",xm);class Ql extends Pa{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 at(VG(r.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),r.openStart,r.openEnd);return zs.fromReplace(e,this.from,this.to,n)}invert(){return new xm(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 Ql(r.pos,n.pos,this.mark)}merge(e){return e instanceof Ql&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ql(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 Ql(r.from,r.to,e.markFromJSON(r.mark))}}Pa.jsonID("removeMark",Ql);class ym extends Pa{constructor(e,r){super(),this.pos=e,this.mark=r}apply(e){let r=e.nodeAt(this.pos);if(!r)return zs.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return zs.fromReplace(e,this.pos,this.pos+1,new at(Me.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 ym(this.pos,r.marks[s]);return new ym(this.pos,this.mark)}}return new bv(this.pos,this.mark)}map(e){let r=e.mapResult(this.pos,1);return r.deletedAfter?null:new ym(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 ym(r.pos,e.markFromJSON(r.mark))}}Pa.jsonID("addNodeMark",ym);class bv extends Pa{constructor(e,r){super(),this.pos=e,this.mark=r}apply(e){let r=e.nodeAt(this.pos);if(!r)return zs.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.removeFromSet(r.marks));return zs.fromReplace(e,this.pos,this.pos+1,new at(Me.from(n),0,r.isLeaf?0:1))}invert(e){let r=e.nodeAt(this.pos);return!r||!this.mark.isInSet(r.marks)?this:new ym(this.pos,this.mark)}map(e){let r=e.mapResult(this.pos,1);return r.deletedAfter?null:new bv(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 bv(r.pos,e.markFromJSON(r.mark))}}Pa.jsonID("removeNodeMark",bv);class ks extends Pa{constructor(e,r,n,s=!1){super(),this.from=e,this.to=r,this.slice=n,this.structure=s}apply(e){return this.structure&&s7(e,this.from,this.to)?zs.fail("Structure replace would overwrite content"):zs.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new sl([this.from,this.to-this.from,this.slice.size])}invert(e){return new ks(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&&ks.MAP_BIAS<0?r:e.mapResult(this.from,1);return n.deletedAcross&&r.deletedAcross?null:new ks(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ks)||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?at.empty:new at(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ks(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?at.empty:new at(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ks(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 ks(r.from,r.to,at.fromJSON(e,r.slice),!!r.structure)}}ks.MAP_BIAS=1;Pa.jsonID("replace",ks);class oi extends Pa{constructor(e,r,n,s,i,a,l=!1){super(),this.from=e,this.to=r,this.gapFrom=n,this.gapTo=s,this.slice=i,this.insert=a,this.structure=l}apply(e){if(this.structure&&(s7(e,this.from,this.gapFrom)||s7(e,this.gapTo,this.to)))return zs.fail("Structure gap-replace would overwrite content");let r=e.slice(this.gapFrom,this.gapTo);if(r.openStart||r.openEnd)return zs.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,r.content);return n?zs.fromReplace(e,this.from,this.to,n):zs.fail("Content does not fit in gap")}getMap(){return new sl([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 oi(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 oi(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 oi(r.from,r.to,r.gapFrom,r.gapTo,at.fromJSON(e,r.slice),r.insert,!!r.structure)}}Pa.jsonID("replaceAround",oi);function s7(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 rLt(t,e,r,n){let s=[],i=[],a,l;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 Ql(f,p,h[g])));l&&l.to==f?l.to=p:i.push(l=new xm(f,p,n))}}),s.forEach(c=>t.step(c)),i.forEach(c=>t.step(c))}function nLt(t,e,r,n){let s=[],i=0;t.doc.nodesBetween(e,r,(a,l)=>{if(!a.isInline)return;i++;let c=null;if(n instanceof o5){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(l+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(l,e),to:u,step:i})}}}),s.forEach(a=>t.step(new Ql(a.from,a.to,a.style)))}function qG(t,e,r,n=r.contentMatch,s=!0){let i=t.doc.nodeAt(e),a=[],l=e+1;for(let c=0;c<i.childCount;c++){let u=i.child(c),d=l+u.nodeSize,h=n.matchType(u.type);if(!h)a.push(new ks(l,d,at.empty));else{n=h;for(let f=0;f<u.marks.length;f++)r.allowsMarkType(u.marks[f].type)||t.step(new Ql(l,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 at(Me.from(r.schema.text(" ",r.allowedMarks(u.marks))),0,0)),a.push(new ks(l+f.index,l+f.index+f[0].length,m))}}l=d}if(!n.validEnd){let c=n.fillBefore(Me.empty,!0);t.replace(l,l,new at(c,0,0))}for(let c=a.length-1;c>=0;c--)t.step(a[c])}function sLt(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function Hv(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),l=t.$from.index(n)+s,c=t.$to.indexAfter(n)-i;if(n<t.depth&&a.canReplace(l,c,r))return n;if(n==0||a.type.spec.isolating||!sLt(a,l,c))break;l&&(s=1),c<a.childCount&&(i=1)}return null}function iLt(t,e,r){let{$from:n,$to:s,depth:i}=e,a=n.before(i+1),l=s.after(i+1),c=a,u=l,d=Me.empty,h=0;for(let m=i,g=!1;m>r;m--)g||n.index(m)>0?(g=!0,d=Me.from(n.node(m).copy(d)),h++):c--;let f=Me.empty,p=0;for(let m=i,g=!1;m>r;m--)g||s.after(m+1)<s.end(m)?(g=!0,f=Me.from(s.node(m).copy(f)),p++):u++;t.step(new oi(c,u,a,l,new at(d.append(f),h,p),d.size-h,!0))}function GG(t,e,r=null,n=t){let s=aLt(t,e),i=s&&oLt(n,e);return i?s.map(goe).concat({type:e,attrs:r}).concat(i.map(goe)):null}function goe(t){return{type:t,attrs:null}}function aLt(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 oLt(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 lLt(t,e,r){let n=Me.empty;for(let a=r.length-1;a>=0;a--){if(n.size){let l=r[a].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=Me.from(r[a].type.create(r[a].attrs,n))}let s=e.start,i=e.end;t.step(new oi(s,i,s,i,new at(n,0,0),r.length,!0))}function cLt(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,l)=>{let c=typeof s=="function"?s(a):s;if(a.isTextblock&&!a.hasMarkup(n,c)&&uLt(t.doc,t.mapping.slice(i).map(l),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&&RCe(t,a,l,i),qG(t,t.mapping.slice(i).map(l,1),n,void 0,u===null);let d=t.mapping.slice(i),h=d.map(l,1),f=d.map(l+a.nodeSize,1);return t.step(new oi(h,f,h+1,f-1,new at(Me.from(n.create(c,null,a.marks)),0,0),1,!0)),u===!0&&ICe(t,a,l,i),!1}})}function ICe(t,e,r,n){e.forEach((s,i)=>{if(s.isText){let a,l=/\r?\n|\r/g;for(;a=l.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 RCe(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 uLt(t,e,r){let n=t.resolve(e),s=n.index();return n.parent.canReplaceWith(s,s+1,r)}function dLt(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 oi(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new at(Me.from(a),0,0),1,!0))}function ud(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 l=s.indexAfter(i),c=n&&n[0];return s.node(i).canReplaceWith(l,l,c?c.type:s.node(i+1).type)}function hLt(t,e,r=1,n){let s=t.doc.resolve(e),i=Me.empty,a=Me.empty;for(let l=s.depth,c=s.depth-r,u=r-1;l>c;l--,u--){i=Me.from(s.node(l).copy(i));let d=n&&n[u];a=Me.from(d?d.type.create(d.attrs,a):s.node(l).copy(a))}t.step(new ks(e,e,new at(i.append(a),r,r),!0))}function Ed(t,e){let r=t.resolve(e),n=r.index();return OCe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function fLt(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 OCe(t,e){return!!(t&&e&&!t.isLeaf&&fLt(t,e))}function Mj(t,e,r=-1){let n=t.resolve(e);for(let s=n.depth;;s--){let i,a,l=n.index(s);if(s==n.depth?(i=n.nodeBefore,a=n.nodeAfter):r>0?(i=n.node(s+1),l++,a=n.node(s).maybeChild(l)):(i=n.node(s).maybeChild(l-1),a=n.node(s+1)),i&&!i.isTextblock&&OCe(i,a)&&n.node(s).canReplace(l,l+1))return e;if(s==0)break;e=r<0?n.before(s):n.after(s)}}function pLt(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 l=t.steps.length;if(n===!1){let d=t.doc.resolve(e+r);RCe(t,d.node(),d.before(),l)}a.inlineContent&&qG(t,e+r-1,a,i.node().contentMatchAt(i.index()),n==null);let c=t.mapping.slice(l),u=c.map(e-r);if(t.step(new ks(u,c.map(e+r,-1),at.empty,!0)),n===!0){let d=t.doc.resolve(u);ICe(t,d.node(),d.before(),t.steps.length)}return t}function mLt(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 MCe(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 l=a==n.depth?0:n.pos<=(n.start(a+1)+n.end(a+1))/2?-1:1,c=n.index(a)+(l>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 l==0?n.pos:l<0?n.before(a+1):n.after(a+1)}return null}function l5(t,e,r=e,n=at.empty){if(e==r&&!n.size)return null;let s=t.resolve(e),i=t.resolve(r);return DCe(s,i,n)?new ks(e,r,n):new gLt(s,i,n).fit()}function DCe(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class gLt{constructor(e,r,n){this.$from=e,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Me.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=Me.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,l=s.depth;for(;a&&l&&i.childCount==1;)i=i.firstChild.content,a--,l--;let c=new at(i,a,l);return e>-1?new oi(n.pos,e,this.$to.pos,this.$to.end(),c,r):c.size||n.pos!=this.$to.pos?new ks(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=xoe(this.unplaced.content,n-1).firstChild,s=i.content):s=this.unplaced.content;let a=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,h=null;if(r==1&&(a?u.matchType(a.type)||(h=u.fillBefore(Me.from(a),!1)):i&&c.compatibleContent(i.type)))return{sliceDepth:n,frontierDepth:l,parent:i,inject:h};if(r==2&&a&&(d=u.findWrapping(a.type)))return{sliceDepth:n,frontierDepth:l,parent:i,wrap:d};if(i&&u.matchType(i.type))break}}}openMore(){let{content:e,openStart:r,openEnd:n}=this.unplaced;return yoe(e,-1)<=r?!1:(this.unplaced.size>1&&yoe(e,1)>n&&n++,this.unplaced=new at(e,r+1,n),!0)}dropNode(){let{content:e,openStart:r,openEnd:n}=this.unplaced,s=xoe(e,r);if(s.childCount<=1&&r>0){let i=e.size-r<=r+s.size;this.unplaced=new at(p_(e,r-1,1),r-1,i?r-1:n)}else this.unplaced=new at(p_(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,l=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=l.size+e-(a.content.size-a.openEnd);for(;u<l.childCount;){let g=l.child(u),y=h.matchType(g.type);if(!y)break;u++,(u>1||c==0||g.content.size)&&(h=y,d.push(LCe(g.mark(f.allowedMarks(g.marks)),u==1?c:0,u==l.childCount?p:-1)))}let m=u==l.childCount;m||(p=-1),this.placed=m_(this.placed,r,Me.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,y=l;g<p;g++){let x=y.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),y=x.content}this.unplaced=m?e==0?at.empty:new at(p_(a.content,e-1,1),e-1,p<0?a.openEnd:e-1):new at(p_(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||!VF(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=VF(e,r,s,n,i);if(a){for(let l=r-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=VF(e,l,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=m_(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=m_(this.placed,this.depth,Me.from(e.create(r,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Me.empty,!0);r.childCount&&(this.placed=m_(this.placed,this.frontier.length,r))}}function p_(t,e,r){return e==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(p_(t.firstChild.content,e-1,r)))}function m_(t,e,r){return e==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(m_(t.lastChild.content,e-1,r)))}function xoe(t,e){for(let r=0;r<e;r++)t=t.firstChild.content;return t}function LCe(t,e,r){if(e<=0)return t;let n=t.content;return e>1&&(n=n.replaceChild(0,LCe(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(Me.empty,!0)))),t.copy(n)}function VF(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 l=n.fillBefore(i.content,!0,a);return l&&!xLt(r,i.content,a)?l:null}function xLt(t,e,r){for(let n=r;n<e.childCount;n++)if(!t.allowsMarks(e.child(n).marks))return!0;return!1}function yLt(t){return t.spec.defining||t.spec.definingForContent}function yoe(t,e){for(let r=0;;r++){let n=e<0?t.firstChild:t.lastChild;if(!n||n.isAtom)return r;t=n.content}}function vLt(t,e,r,n){if(!n.size)return t.deleteRange(e,r);let s=t.doc.resolve(e),i=t.doc.resolve(r);if(DCe(s,i,n))return t.step(new ks(e,r,n));let a=FCe(s,i);a[a.length-1]==0&&a.pop();let l=-(s.depth+1);a.unshift(l);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?l=f:s.before(f)==p&&a.splice(1,0,-f)}let c=a.indexOf(l),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=yLt(p.type);if(m&&!p.sameMarkup(s.node(Math.abs(l)-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 y=a[(g+c)%a.length],x=!0;y<0&&(x=!1,y=-y);let v=s.node(y-1),b=s.index(y-1);if(v.canReplaceWith(b,b,m.type,m.marks))return t.replace(s.before(y),x?i.after(y):r,new at($Ce(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 $Ce(t,e,r,n,s){if(e<r){let i=t.firstChild;t=t.replaceChild(0,i.copy($Ce(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(Me.empty,!0))}return t}function bLt(t,e,r,n){if(!n.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let s=mLt(t.doc,e,n.type);s!=null&&(e=r=s)}t.replaceRange(e,r,new at(Me.from(n),0,0))}function wLt(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),l=!1;for(let c=n.depth;c>a;c--)n.node(c).type.spec.isolating&&(l=!0);for(let c=s.depth;c>a;c--)s.node(c).type.spec.isolating&&(l=!0);if(!l){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=FCe(n,s);for(let a=0;a<i.length;a++){let l=i[a],c=a==i.length-1;if(c&&l==0||n.node(l).type.contentMatch.validEnd)return t.delete(n.start(l),s.end(l));if(l>0&&(c||n.node(l-1).canReplace(n.index(l-1),s.indexAfter(l-1))))return t.delete(n.before(l),s.after(l))}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 FCe(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}class E0 extends Pa{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 zs.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 zs.fromReplace(e,this.pos,this.pos+1,new at(Me.from(s),0,r.isLeaf?0:1))}getMap(){return sl.empty}invert(e){return new E0(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 E0(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 E0(r.pos,r.attr,r.value)}}Pa.jsonID("attr",E0);class Pk extends Pa{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 zs.ok(n)}getMap(){return sl.empty}invert(e){return new Pk(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 Pk(r.attr,r.value)}}Pa.jsonID("docAttr",Pk);let U1=class extends Error{};U1=function t(e){let r=Error.call(this,e);return r.__proto__=t.prototype,r};U1.prototype=Object.create(Error.prototype);U1.prototype.constructor=U1;U1.prototype.name="TransformError";class c5{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Tk}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let r=this.maybeStep(e);if(r.failed)throw new U1(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,l,c)=>{e=Math.min(e,l),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=at.empty){let s=l5(this.doc,e,r,n);return s&&this.step(s),this}replaceWith(e,r,n){return this.replace(e,r,new at(Me.from(n),0,0))}delete(e,r){return this.replace(e,r,at.empty)}insert(e,r){return this.replaceWith(e,e,r)}replaceRange(e,r,n){return vLt(this,e,r,n),this}replaceRangeWith(e,r,n){return bLt(this,e,r,n),this}deleteRange(e,r){return wLt(this,e,r),this}lift(e,r){return iLt(this,e,r),this}join(e,r=1){return pLt(this,e,r),this}wrap(e,r){return lLt(this,e,r),this}setBlockType(e,r=e,n,s=null){return cLt(this,e,r,n,s),this}setNodeMarkup(e,r,n=null,s){return dLt(this,e,r,n,s),this}setNodeAttribute(e,r,n){return this.step(new E0(e,r,n)),this}setDocAttribute(e,r){return this.step(new Pk(e,r)),this}addNodeMark(e,r){return this.step(new ym(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 bn)r.isInSet(n.marks)&&this.step(new bv(e,r));else{let s=n.marks,i,a=[];for(;i=r.isInSet(s);)a.push(new bv(e,i)),s=i.removeFromSet(s);for(let l=a.length-1;l>=0;l--)this.step(a[l])}return this}split(e,r=1,n){return hLt(this,e,r,n),this}addMark(e,r,n){return rLt(this,e,r,n),this}removeMark(e,r,n){return nLt(this,e,r,n),this}clearIncompatible(e,r,n){return qG(this,e,r,n),this}}const qF=Object.create(null);class Mt{constructor(e,r,n){this.$anchor=e,this.$head=r,this.ranges=n||[new BCe(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=at.empty){let n=r.content.lastChild,s=null;for(let l=0;l<r.openEnd;l++)s=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let l=0;l<a.length;l++){let{$from:c,$to:u}=a[l],d=e.mapping.slice(i);e.replaceRange(d.map(c.pos),d.map(u.pos),l?at.empty:r),l==0&&woe(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:l}=s[i],c=e.mapping.slice(n),u=c.map(a.pos),d=c.map(l.pos);i?e.deleteRange(u,d):(e.replaceRangeWith(u,d,r),woe(e,n,r.isInline?-1:1))}}static findFrom(e,r,n=!1){let s=e.parent.inlineContent?new ht(e):Cb(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?Cb(e.node(0),e.node(i),e.before(i+1),e.index(i),r,n):Cb(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 ul(e.node(0))}static atStart(e){return Cb(e,e,0,0,1)||new ul(e)}static atEnd(e){return Cb(e,e,e.content.size,e.childCount,-1)||new ul(e)}static fromJSON(e,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=qF[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 qF)throw new RangeError("Duplicate use of selection JSON ID "+e);return qF[e]=r,r.prototype.jsonID=e,r}getBookmark(){return ht.between(this.$anchor,this.$head).getBookmark()}}Mt.prototype.visible=!0;class BCe{constructor(e,r){this.$from=e,this.$to=r}}let voe=!1;function boe(t){!voe&&!t.parent.inlineContent&&(voe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ht extends Mt{constructor(e,r=e){boe(e),boe(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 Mt.near(n);let s=e.resolve(r.map(this.anchor));return new ht(s.parent.inlineContent?s:n,n)}replace(e,r=at.empty){if(super.replace(e,r),r==at.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof ht&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new u5(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 ht(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=Mt.findFrom(r,n,!0)||Mt.findFrom(r,-n,!0);if(i)r=i.$head;else return Mt.near(r,n)}return e.parent.inlineContent||(s==0?e=r:(e=(Mt.findFrom(e,-n,!0)||Mt.findFrom(e,n,!0)).$anchor,e.pos<r.pos!=s<0&&(e=r))),new ht(e,r)}}Mt.jsonID("text",ht);class u5{constructor(e,r){this.anchor=e,this.head=r}map(e){return new u5(e.map(this.anchor),e.map(this.head))}resolve(e){return ht.between(e.resolve(this.anchor),e.resolve(this.head))}}class Pt extends Mt{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?Mt.near(i):new Pt(i)}content(){return new at(Me.from(this.node),0,0)}eq(e){return e instanceof Pt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new KG(this.anchor)}static fromJSON(e,r){if(typeof r.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Pt(e.resolve(r.anchor))}static create(e,r){return new Pt(e.resolve(r))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Pt.prototype.visible=!1;Mt.jsonID("node",Pt);class KG{constructor(e){this.anchor=e}map(e){let{deleted:r,pos:n}=e.mapResult(this.anchor);return r?new u5(n,n):new KG(n)}resolve(e){let r=e.resolve(this.anchor),n=r.nodeAfter;return n&&Pt.isSelectable(n)?new Pt(r):Mt.near(r)}}class ul extends Mt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,r=at.empty){if(r==at.empty){e.delete(0,e.doc.content.size);let n=Mt.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,r)}toJSON(){return{type:"all"}}static fromJSON(e){return new ul(e)}map(e){return new ul(e)}eq(e){return e instanceof ul}getBookmark(){return jLt}}Mt.jsonID("all",ul);const jLt={map(){return this},resolve(t){return new ul(t)}};function Cb(t,e,r,n,s,i=!1){if(e.inlineContent)return ht.create(t,r);for(let a=n-(s>0?0:1);s>0?a<e.childCount:a>=0;a+=s){let l=e.child(a);if(l.isAtom){if(!i&&Pt.isSelectable(l))return Pt.create(t,r-(s<0?l.nodeSize:0))}else{let c=Cb(t,l,r+s,s<0?l.childCount:0,s,i);if(c)return c}r+=l.nodeSize*s}return null}function woe(t,e,r){let n=t.steps.length-1;if(n<e)return;let s=t.steps[n];if(!(s instanceof ks||s instanceof oi))return;let i=t.mapping.maps[n],a;i.forEach((l,c,u,d)=>{a==null&&(a=d)}),t.setSelection(Mt.near(t.doc.resolve(a),r))}const joe=1,t2=2,Soe=4;class SLt extends c5{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|joe)&~t2,this.storedMarks=null,this}get selectionSet(){return(this.updated&joe)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=t2,this}ensureMarks(e){return bn.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&t2)>0}addStep(e,r){super.addStep(e,r),this.updated=this.updated&~t2,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)||bn.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(Mt.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|=Soe,this}get scrolledIntoView(){return(this.updated&Soe)>0}}function _oe(t,e){return!e||!t?t:t.bind(e)}class g_{constructor(e,r,n){this.name=e,this.init=_oe(r.init,n),this.apply=_oe(r.apply,n)}}const _Lt=[new g_("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new g_("selection",{init(t,e){return t.selection||Mt.atStart(e.doc)},apply(t){return t.selection}}),new g_("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,n){return n.selection.$cursor?t.storedMarks:null}}),new g_("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class GF{constructor(e,r){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=_Lt.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 g_(n.key,n.spec.state,n))})}}class px{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 l=this.config.plugins[a];if(l.spec.appendTransaction){let c=s?s[a].n:0,u=s?s[a].state:this,d=c<r.length&&l.spec.appendTransaction.call(l,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 px(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 SLt(this)}static create(e){let r=new GF(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new px(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 GF(this.schema,e.plugins),n=r.fields,s=new px(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 GF(e.schema,e.plugins),i=new px(s);return s.fields.forEach(a=>{if(a.name=="doc")i.doc=Rm.fromJSON(e.schema,r.doc);else if(a.name=="selection")i.selection=Mt.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 l in n){let c=n[l],u=c.spec.state;if(c.key==a.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(r,l)){i[a.name]=u.fromJSON.call(c,e,r[l],i);return}}i[a.name]=a.init(e,i)}}),i}}function zCe(t,e,r){for(let n in t){let s=t[n];s instanceof Function?s=s.bind(e):n=="handleDOMEvents"&&(s=zCe(s,e,{})),r[n]=s}return r}class Ar{constructor(e){this.spec=e,this.props={},e.props&&zCe(e.props,this,this.props),this.key=e.key?e.key.key:UCe("plugin")}getState(e){return e[this.key]}}const KF=Object.create(null);function UCe(t){return t in KF?t+"$"+ ++KF[t]:(KF[t]=0,t+"$")}class Wr{constructor(e="key"){this.key=UCe(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}function HCe(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const WCe=(t,e,r)=>{let n=HCe(t,r);if(!n)return!1;let s=YG(n);if(!s){let a=n.blockRange(),l=a&&Hv(a);return l==null?!1:(e&&e(t.tr.lift(a,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(oEe(t,s,e,-1))return!0;if(n.parent.content.size==0&&(H1(i,"end")||Pt.isSelectable(i)))for(let a=n.depth;;a--){let l=l5(t.doc,n.before(a),n.after(a),at.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(H1(i,"end")?Mt.findFrom(c.doc.resolve(c.mapping.map(s.pos,-1)),-1):Pt.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},VCe=(t,e,r)=>{let n=HCe(t,r);if(!n)return!1;let s=YG(n);return s?GCe(t,s,e):!1},qCe=(t,e,r)=>{let n=YCe(t,r);if(!n)return!1;let s=XG(n);return s?GCe(t,s,e):!1};function GCe(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,l=a,c=e.pos+1;for(;!l.isTextblock;c++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let u=l5(t.doc,i,c,at.empty);if(!u||u.from!=i||u instanceof ks&&u.slice.size>=c-i)return!1;if(r){let d=t.tr.step(u);d.setSelection(ht.create(d.doc,i)),r(d.scrollIntoView())}return!0}function H1(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 KCe=(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=YG(n)}let a=i&&i.nodeBefore;return!a||!Pt.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Pt.create(t.doc,i.pos-a.nodeSize)).scrollIntoView()),!0)};function YG(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 YCe(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)?null:r}const XCe=(t,e,r)=>{let n=YCe(t,r);if(!n)return!1;let s=XG(n);if(!s)return!1;let i=s.nodeAfter;if(oEe(t,s,e,1))return!0;if(n.parent.content.size==0&&(H1(i,"start")||Pt.isSelectable(i))){let a=l5(t.doc,n.before(),n.after(),at.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(H1(i,"start")?Mt.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):Pt.create(l.doc,l.mapping.map(s.pos))),e(l.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},QCe=(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=XG(n)}let a=i&&i.nodeAfter;return!a||!Pt.isSelectable(a)?!1:(e&&e(t.tr.setSelection(Pt.create(t.doc,i.pos)).scrollIntoView()),!0)};function XG(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 ZCe=(t,e)=>{let r=t.selection,n=r instanceof Pt,s;if(n){if(r.node.isTextblock||!Ed(t.doc,r.from))return!1;s=r.from}else if(s=Mj(t.doc,r.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);n&&i.setSelection(Pt.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},JCe=(t,e)=>{let r=t.selection,n;if(r instanceof Pt){if(r.node.isTextblock||!Ed(t.doc,r.to))return!1;n=r.to}else if(n=Mj(t.doc,r.to,1),n==null)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0},eEe=(t,e)=>{let{$from:r,$to:n}=t.selection,s=r.blockRange(n),i=s&&Hv(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},tEe=(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 rEe(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 nEe=(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=rEe(s.contentMatchAt(i));if(!a||!s.canReplaceWith(i,i,a))return!1;if(e){let l=r.after(),c=t.tr.replaceWith(l,l,a.createAndFill());c.setSelection(Mt.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},sEe=(t,e)=>{let r=t.selection,{$from:n,$to:s}=r;if(r instanceof ul||n.parent.inlineContent||s.parent.inlineContent)return!1;let i=rEe(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,l=t.tr.insert(a,i.createAndFill());l.setSelection(ht.create(l.doc,a+1)),e(l.scrollIntoView())}return!0},iEe=(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(ud(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let n=r.blockRange(),s=n&&Hv(n);return s==null?!1:(e&&e(t.tr.lift(n,s).scrollIntoView()),!0)},aEe=(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(Pt.create(t.doc,s))),!0)};function NLt(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||Ed(t.doc,e.pos))?!1:(r&&r(t.tr.join(e.pos).scrollIntoView()),!0)}function oEe(t,e,r,n){let s=e.nodeBefore,i=e.nodeAfter,a,l,c=s.type.spec.isolating||i.type.spec.isolating;if(!c&&NLt(t,e,r))return!0;let u=!c&&e.parent.canReplace(e.index(),e.index()+1);if(u&&(a=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(a[0]||i.type).validEnd){if(r){let p=e.pos+i.nodeSize,m=Me.empty;for(let x=a.length-1;x>=0;x--)m=Me.from(a[x].create(null,m));m=Me.from(s.copy(m));let g=t.tr.step(new oi(e.pos-1,p,e.pos,p,new at(m,1,0),a.length,!0)),y=g.doc.resolve(p+2*a.length);y.nodeAfter&&y.nodeAfter.type==s.type&&Ed(g.doc,y.pos)&&g.join(y.pos),r(g.scrollIntoView())}return!0}let d=i.type.spec.isolating||n>0&&c?null:Mt.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),f=h&&Hv(h);if(f!=null&&f>=e.depth)return r&&r(t.tr.lift(h,f).scrollIntoView()),!0;if(u&&H1(i,"start",!0)&&H1(s,"end")){let p=s,m=[];for(;m.push(p),!p.isTextblock;)p=p.lastChild;let g=i,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(r){let x=Me.empty;for(let b=m.length-1;b>=0;b--)x=Me.from(m[b].copy(x));let v=t.tr.step(new oi(e.pos-m.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new at(x,m.length,0),0,!0));r(v.scrollIntoView())}return!0}}return!1}function lEe(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(ht.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const cEe=lEe(-1),uEe=lEe(1);function dEe(t,e=null){return function(r,n){let{$from:s,$to:i}=r.selection,a=s.blockRange(i),l=a&&GG(a,t,e);return l?(n&&n(r.tr.wrap(a,l).scrollIntoView()),!0):!1}}function mO(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:l}}=r.selection.ranges[i];r.doc.nodesBetween(a,l,(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:l},$to:{pos:c}}=r.selection.ranges[a];i.setBlockType(l,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 hEe(t,e=null){return function(r,n){let{$from:s,$to:i}=r.selection,a=s.blockRange(i);if(!a)return!1;let l=n?r.tr:null;return kLt(l,a,t,e)?(n&&n(l.scrollIntoView()),!0):!1}}function kLt(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 fO(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new fO(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=GG(i,r,n,e);return l?(t&&CLt(t,e,l,s,r),!0):!1}function CLt(t,e,r,n,s){let i=Me.empty;for(let d=r.length-1;d>=0;d--)i=Me.from(r[d].type.create(r[d].attrs,i));t.step(new oi(e.start-(n?2:0),e.end,e.start,e.end,new at(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 l=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&&ud(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function fEe(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?ELt(e,r,t,i):ALt(e,r,i):!0:!1}}function ELt(t,e,r,n){let s=t.tr,i=n.end,a=n.$to.end(n.depth);i<a&&(s.step(new oi(i-1,a,i,a,new at(Me.from(r.create(null,n.parent.copy())),1,0),1,!0)),n=new fO(s.doc.resolve(n.$from.pos),s.doc.resolve(a),n.depth));const l=Hv(n);if(l==null)return!1;s.lift(n,l);let c=s.doc.resolve(s.mapping.map(i,-1)-1);return Ed(s.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&s.join(c.pos),e(s.scrollIntoView()),!0}function ALt(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 l=r.startIndex==0,c=r.endIndex==s.childCount,u=i.node(-1),d=i.index(-1);if(!u.canReplace(d+(l?0:1),d+1,a.content.append(c?Me.empty:Me.from(s))))return!1;let h=i.pos,f=h+a.nodeSize;return n.step(new oi(h-(l?1:0),f+(c?1:0),h+1,f-1,new at((l?Me.empty:Me.from(s.copy(Me.empty))).append(c?Me.empty:Me.from(s.copy(Me.empty))),l?0:1,c?0:1),l?0:1)),e(n.scrollIntoView()),!0}function pEe(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 l=i.parent,c=l.child(a-1);if(c.type!=t)return!1;if(r){let u=c.lastChild&&c.lastChild.type==l.type,d=Me.from(u?t.create():null),h=new at(Me.from(t.create(null,Me.from(l.type.create(null,d)))),u?3:1,0),f=i.start,p=i.end;r(e.tr.step(new oi(f-(u?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0}}const Ji=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},W1=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let i7=null;const Xd=function(t,e,r){let n=i7||(i7=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,e||0),n},TLt=function(){i7=null},wv=function(t,e,r,n){return r&&(Noe(t,e,r,n,-1)||Noe(t,e,r,n,1))},PLt=/^(img|br|input|textarea|hr)$/i;function Noe(t,e,r,n,s){for(var i;;){if(t==r&&e==n)return!0;if(e==(s<0?0:ja(t))){let a=t.parentNode;if(!a||!Dt(a)||jA(t)||PLt.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ji(t)+(s<0?0:1),t=a}else if(Dt(t)){let a=t.childNodes[e+(s<0?-1:0)];if(Dt(a)&&a.contentEditable=="false")if(!((i=a.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=a,e=s<0?ja(t):0}else return!1}}function ja(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Dt(t){return t.nodeType==1}function si(t){return t.nodeType==3}function jv(t,e){return e?t.contains(Dt(e)?e:e.parentNode):!1}function ILt(t,e){for(;;){if(si(t)&&e)return t;if(Dt(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=ja(t)}else if(t.parentNode&&!jA(t))e=Ji(t),t=t.parentNode;else return null}}function RLt(t,e){for(;;){if(si(t)&&e<t.nodeValue.length)return t;if(Dt(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!jA(t))e=Ji(t)+1,t=t.parentNode;else return null}}function OLt(t,e,r){for(let n=e==0,s=e==ja(t);n||s;){if(t==r)return!0;let i=Ji(t);if(t=t.parentNode,!t)return!1;n=n&&i==0,s=s&&i==ja(t)}}function jA(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 d5=function(t){return t.focusNode&&wv(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Jg(t,e){let r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=t,r.key=r.code=e,r}function MLt(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function DLt(t,e,r){if(t.caretPositionFromPoint)try{let n=t.caretPositionFromPoint(e,r);if(n)return{node:n.offsetNode,offset:Math.min(ja(n.offsetNode),n.offset)}}catch{}if(t.caretRangeFromPoint){let n=t.caretRangeFromPoint(e,r);if(n)return{node:n.startContainer,offset:Math.min(ja(n.startContainer),n.startOffset)}}}const gd=typeof navigator<"u"?navigator:null,koe=typeof document<"u"?document:null,wg=gd&&gd.userAgent||"",a7=/Edge\/(\d+)/.exec(wg),mEe=/MSIE \d/.exec(wg),o7=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wg),Ao=!!(mEe||o7||a7),Mm=mEe?document.documentMode:o7?+o7[1]:a7?+a7[1]:0,dl=!Ao&&/gecko\/(\d+)/i.test(wg);dl&&+(/Firefox\/(\d+)/.exec(wg)||[0,0])[1];const l7=!Ao&&/Chrome\/(\d+)/.exec(wg),na=!!l7,gEe=l7?+l7[1]:0,Ea=!Ao&&!!gd&&/Apple Computer/.test(gd.vendor),V1=Ea&&(/Mobile\/\w+/.test(wg)||!!gd&&gd.maxTouchPoints>2),Bl=V1||(gd?/Mac/.test(gd.platform):!1),xEe=gd?/Win/.test(gd.platform):!1,Hh=/Android \d/.test(wg),h5=!!koe&&"webkitFontSmoothing"in koe.documentElement.style,LLt=h5?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function $Lt(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 Md(t,e){return typeof t=="number"?t:t[e]}function FLt(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 Coe(t,e,r){if(!c7(e)&&e.left==0)return;let n=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let a=r||t.dom;a;){if(!Dt(a)){a=W1(a);continue}let l=a==i.body,c=l?$Lt(i):FLt(a),u=0,d=0;if(e.top<c.top+Md(n,"top")?d=-(c.top-e.top+Md(s,"top")):e.bottom>c.bottom-Md(n,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Md(s,"top")-c.top:e.bottom-c.bottom+Md(s,"bottom")),e.left<c.left+Md(n,"left")?u=-(c.left-e.left+Md(s,"left")):e.right>c.right-Md(n,"right")&&(u=e.right-c.right+Md(s,"right")),u||d)if(l)i.defaultView.scrollBy(u,d);else{let f=a.scrollLeft,p=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let m=a.scrollLeft-f,g=a.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let h=l?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(h))break;a=h=="absolute"?a.offsetParent:W1(a)}}function BLt(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 l=t.root.elementFromPoint(i,a);if(!l||l==t.dom||!t.dom.contains(l))continue;let c=l.getBoundingClientRect();if(c.top>=r-20){n=l,s=c.top;break}}return{refDOM:n,refTop:s,stack:yEe(t.dom)}}function yEe(t){let e=[],r=t.ownerDocument;for(let n=t;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=W1(n));return e}function zLt({refDOM:t,refTop:e,stack:r}){let n=t?t.getBoundingClientRect().top:0;vEe(r,n==0?0:n-e)}function vEe(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 db=null;function ULt(t){if(t.setActive)return t.setActive();if(db)return t.focus(db);let e=yEe(t);t.focus(db==null?{get preventScroll(){return db={preventScroll:!0},!0}}:void 0),db||(db=!1,vEe(e,0))}function bEe(t,e){let r,n=2e8,s,i=0,a=e.top,l=e.top,c,u;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let f;if(Dt(d))f=d.getClientRects();else if(si(d))f=Xd(d).getClientRects();else continue;for(let p=0;p<f.length;p++){let m=f[p];if(m.top<=a&&m.bottom>=l){a=Math.max(m.bottom,a),l=Math.min(m.top,l);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&&si(r)?{left:m.right<e.left?m.right:m.left,top:e.top}:e,Dt(d)&&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&&si(r)?HLt(r,s):!r||n?{node:t,offset:i}:bEe(r,s)}function HLt(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=np(n,1);if(a.top!=a.bottom&&QG(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 QG(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function WLt(t,e){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&e.left<t.getBoundingClientRect().left?r:t}function VLt(t,e,r){let{node:n,offset:s}=bEe(e,r),i=-1;if(Dt(n)&&!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 qLt(t,e,r,n){let s=-1;for(let i=e,a=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),c;if(!l)return null;if(Dt(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!a&&c.left>n.left||c.top>n.top?s=l.posBefore:(!a&&c.right<n.left||c.bottom<n.top)&&(s=l.posAfter),a=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?n.top<(c.top+c.bottom)/2:n.left<(c.left+c.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,r,-1)}function wEe(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(Dt(a)){let l=a.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(QG(e,u))return wEe(a,e,u)}}if((i=(i+1)%n)==s)break}return t}function GLt(t,e){let r=t.dom.ownerDocument,n,s=0,i=DLt(r,e.left,e.top);i&&({node:n,offset:s}=i);let a=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top),l;if(!a||!t.dom.contains(a)){let u=t.dom.getBoundingClientRect();if(!QG(e,u)||(a=wEe(t.dom,e,u),!a))return null}if(Ea)for(let u=a;n&&u;u=W1(u))u.draggable&&(n=void 0);if(a=WLt(a,e),n){if(dl&&Dt(n)&&(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;h5&&s&&Dt(n)&&Dt(u=n.childNodes[s-1])&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&s--,n==t.dom&&s==n.childNodes.length-1&&Dt(n.lastChild)&&e.top>n.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||!Dt(n)||n.childNodes[s-1].nodeName!="BR")&&(l=qLt(t,n,s,e))}l==null&&(l=VLt(t,a,e));let c=t.docView.nearestDesc(a,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function c7(t){return t.top<t.bottom||t.left<t.right}function np(t,e){let r=t.getClientRects();if(r.length){let n=r[e<0?0:r.length-1];if(c7(n))return n}return Array.prototype.find.call(r,c7)||t.getBoundingClientRect()}const KLt=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function jEe(t,e,r){let{node:n,offset:s,atom:i}=t.docView.domFromPos(e,r<0?-1:1),a=h5||dl;if(si(n))if(a&&(KLt.test(n.nodeValue)||(r<0?!s:s==n.nodeValue.length))){let c=np(Xd(n,s,s),r);if(dl&&s&&/\s/.test(n.nodeValue[s-1])&&s<n.nodeValue.length){let u=np(Xd(n,s-1,s-1),-1);if(u.top==c.top){let d=np(Xd(n,s,s+1),-1);if(d.top!=c.top)return SS(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++,SS(np(Xd(n,c,u),d),d<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(r<0||s==ja(n))){let c=n.childNodes[s-1];if(Dt(c))return YF(c.getBoundingClientRect(),!1)}if(i==null&&s<ja(n)){let c=n.childNodes[s];if(Dt(c))return YF(c.getBoundingClientRect(),!0)}return YF(n.getBoundingClientRect(),r>=0)}if(i==null&&s&&(r<0||s==ja(n))){let c=n.childNodes[s-1],u=si(c)?Xd(c,ja(c)-(a?0:1)):Dt(c)&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return SS(np(u,1),!1)}if(i==null&&s<ja(n)){let c=n.childNodes[s];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?si(c)?Xd(c,0,a?0:1):Dt(c)?c:null:null;if(u)return SS(np(u,-1),!0)}return SS(np(si(n)?Xd(n):n,-r),r>=0)}function SS(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 YF(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 SEe(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 YLt(t,e,r){let n=e.selection,s=r=="up"?n.$from:n.$to;return SEe(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,r=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let a=jEe(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let c;if(Dt(l))c=l.getClientRects();else if(si(l))c=Xd(l,0,l.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 XLt=/[\u0590-\u08ac]/;function QLt(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,l=t.domSelection();return l?!XLt.test(n.parent.textContent)||!l.modify?r=="left"||r=="backward"?i:a:SEe(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:h}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",r,"character");let p=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:m,focusOffset:g}=t.domSelectionRange(),y=m&&!jv(p,m)||c==m&&u==g;try{l.collapse(d,h),c&&(c!=d||u!=h)&&l.extend&&l.extend(c,u)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):n.pos==n.start()||n.pos==n.end()}let Eoe=null,Aoe=null,Toe=!1;function ZLt(t,e,r){return Eoe==e&&Aoe==r?Toe:(Eoe=e,Aoe=r,Toe=r=="up"||r=="down"?YLt(t,e,r):QLt(t,e,r))}const nc=0,Poe=1,mx=2,Zc=3;class SA{constructor(e,r,n,s){this.parent=e,this.children=r,this.dom=n,this.contentDOM=s,this.dirty=nc,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,r,n){return!1}matchesHack(e){return!1}parseRule(e){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&&jv(this.contentDOM,e))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>Ji(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=!!(e.compareDocumentPosition(this.contentDOM)&4);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)&&!(Dt(a)?jv(a,e):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 l=s.children[a];if(l.size){s=l;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],l=i+a.size;if(l>e){s=e-i;break}i=l}if(s)return this.children[n].domFromPos(s-this.children[n].border,r);for(;n>0;n--){let i=this.children[n-1];if(i.size||!(i instanceof NEe||i instanceof _Ee&&i.side>=0))break}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?Ji(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?Ji(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,l=0;;l++){let c=this.children[l],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=l;h>0;h--){let f=this.children[h-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=Ji(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(u>r||l==this.children.length-1)){r=u;for(let d=l+1;d<this.children.length;d++){let h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){i=Ji(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(!Dt(r)||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],y=m+g.size;if(i>m&&a<y)return g.setSelection(e-m-g.border,r-m-g.border,n,s);m=y}let l=this.domFromPos(e,e?-1:1),c=r==e?l:this.domFromPos(r,r?-1:1),u=n.root.getSelection(),d=n.domSelectionRange(),h=!1;if((dl||Ea)&&e==r){let{node:p,offset:m}=l;if(si(p)){if(h=!!(m&&p.nodeValue[m-1]==`
`),h&&m==p.nodeValue.length)for(let g=p,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=c={node:y.parentNode,offset:Ji(y)+1});break}let x=g.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let g=p.childNodes[m-1];h=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(dl&&d.focusNode&&d.focusNode!=c.node&&Dt(d.focusNode)){let p=d.focusNode.childNodes[d.focusOffset];p&&p.contentEditable=="false"&&(s=!0)}if(!(s||h&&Ea)&&wv(l.node,l.offset,d.anchorNode,d.anchorOffset)&&wv(c.node,c.offset,d.focusNode,d.focusOffset))return;let f=!1;if((u.extend||e==r)&&!(h&&dl)){u.collapse(l.node,l.offset);try{e!=r&&u.extend(c.node,c.offset),f=!0}catch{}}if(!f){if(e>r){let m=l;l=c,c=m}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(l.node,l.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 l=n+i.border,c=a-i.border;if(e>=l&&r<=c){this.dirty=e==n||r==a?mx:Poe,e==l&&r==c&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Zc:i.markDirty(e-l,r-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?mx:Zc}n=a}this.dirty=mx}markParentsDirty(){let e=1;for(let r=this.parent;r;r=r.parent,e++){let n=e==1?mx:Poe;r.dirty<n&&(r.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class _Ee extends SA{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){let l=Dt(a)?a:document.createElement("span");l!=a&&l.appendChild(a),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],a,null),this.widget=r,this.widget=r,i=this}matchesWidget(e){return this.dirty==nc&&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 JLt extends SA{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 Dm extends SA{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=Uv.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new Dm(e,r,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&Zc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Zc&&this.mark.eq(e)}markDirty(e,r){if(super.markDirty(e,r),this.dirty!=nc){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=nc}}slice(e,r,n){let s=Dm.create(this.parent,this.mark,!0,n),i=this.children,a=this.size;r<a&&(i=d7(i,r,a,n)),e>0&&(i=d7(i,0,e,n));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Lm extends SA{constructor(e,r,n,s,i,a,l){super(e,[],i,a),this.node=r,this.outerDeco=n,this.innerDeco=s,this.nodeDOM=l}static create(e,r,n,s,i,a){let l=i.nodeViews[r.type.name],c,u=l&&l(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(!si(d))throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:h}=Uv.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=EEe(d,n,r),u?c=new e5t(e,r,n,s,d,h||null,f,u):r.isText?new f5(e,r,n,s,d,f):new Lm(e,r,n,s,d,h||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let r={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(r.preserveWhitespace="full"),!this.contentDOM)r.getContent=()=>this.node.content;else if(!this.contentLost)r.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let s=this.children[n];if(this.dom.contains(s.dom.parentNode)){r.contentElement=s.dom.parentNode;break}}if(!r.contentElement){let n=e&&e.find(s=>Dt(s)&&e.indexOf(s.parentNode)<0&&this.dom.contains(s));n?r.contentElement=n:r.getContent=()=>Me.empty}}return r}matchesNode(e,r,n){return this.dirty==nc&&e.eq(this.node)&&gO(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,l=i&&i.pos<0,c=new r5t(this,a&&a.node,e),u=this.node.inlineContent,d=u&&this.node.isBlock;i5t(this.node,this.innerDeco,(h,f,p)=>{h.spec.marks?c.syncToMarks(h.spec.marks,n,e,f):h.type.side>=0&&!p&&c.syncToMarks(f==this.node.childCount?bn.none:this.node.child(f).marks,n,e,f),c.placeWidget(h,e,s)},(h,f,p,m)=>{c.syncToMarks(h.marks,n,e,m),d&&h.isAtom&&!h.isText&&c.addHackNode("IMG",c.top);let g;c.findNodeMatch(h,f,p,m)||l&&e.state.selection.from>s&&e.state.selection.to<s+h.nodeSize&&(g=c.findIndexWithChild(i.node))>-1&&c.updateNodeAt(h,f,p,g,e)||c.updateNextNode(h,f,p,e,m,s)||c.addNode(h,f,p,e,s),s+=h.nodeSize,u&&(d=h.isAtom&&!h.isText)}),c.syncToMarks([],n,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==mx)&&(a&&this.protectLocalComposition(e,a),kEe(this.contentDOM,this.children,e),V1&&a5t(this.dom))}localCompositionInfo(e,r){let{from:n,to:s}=e.state.selection;if(!(e.state.selection instanceof ht)||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,l=o5t(this.node.content,a,n-r,s-r);return l<0?null:{node:i,pos:l,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 JLt(this,i,r,s);e.input.compositionNodes.push(a),this.children=d7(this.children,n,n+s.length,e,a)}update(e,r,n,s){return this.dirty==Zc||!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=nc}updateOuterDeco(e){if(gO(e,this.outerDeco))return;let r=!Dt(this.nodeDOM),n=this.dom;this.dom=CEe(this.dom,this.nodeDOM,u7(this.outerDeco,this.node,r),u7(e,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){Dt(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){Dt(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Ioe(t,e,r,n,s){EEe(n,e,t);let i=new Lm(void 0,t,e,r,n,n,n);return i.contentDOM&&i.updateChildren(s,0),i}class f5 extends Lm{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==Zc||this.dirty!=nc&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=nc||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=nc,!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 f5(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=Zc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class NEe extends SA{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==nc&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class e5t extends Lm{constructor(e,r,n,s,i,a,l,c){super(e,r,n,s,i,a,l),this.spec=c}update(e,r,n,s){if(this.dirty==Zc)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 kEe(t,e,r){let n=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let a=e[i],l=a.dom;if(l.parentNode==t){for(;l!=n;)n=Roe(n),s=!0;n=n.nextSibling}else s=!0,t.insertBefore(l,n);if(a instanceof Dm){let c=n?n.previousSibling:t.lastChild;kEe(a.contentDOM,a.children,r),n=c?c.nextSibling:t.firstChild}}for(;n;)n=Roe(n),s=!0;s&&r.trackWrites==t&&(r.trackWrites=null)}const Y_=function(t){t&&(this.nodeName=t)};Y_.prototype=Object.create(null);const gx=[new Y_];function u7(t,e,r){if(t.length==0)return gx;let n=r?gx[0]:new Y_,s=[n];for(let i=0;i<t.length;i++){let a=t[i].type.attrs;if(a){a.nodeName&&s.push(n=new Y_(a.nodeName));for(let l in a){let c=a[l];c!=null&&(r&&s.length==1&&s.push(n=new Y_(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+c:l=="style"?n.style=(n.style?n.style+";":"")+c:l!="nodeName"&&(n[l]=c))}}}return s}function CEe(t,e,r,n){if(r==gx&&n==gx)return e;let s=e;for(let i=0;i<n.length;i++){let a=n[i],l=r[i];if(i){let c;l&&l.nodeName==a.nodeName&&s!=t&&(c=s.parentNode)&&c.nodeName.toLowerCase()==a.nodeName||(c=document.createElement(a.nodeName),c.pmIsDeco=!0,c.appendChild(s),l=gx[0]),s=c}t5t(s,l||gx[0],a)}return s}function t5t(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 EEe(t,e,r){return CEe(t,t,gx,u7(e,r,!Dt(t)))}function gO(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 Roe(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class r5t{constructor(e,r,n){this.lock=r,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=n5t(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,l=Math.min(a,e.length);for(;i<l&&(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=nc,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 Dm&&d.dirty!=Zc&&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=Dm.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 l=this.index,c=Math.min(this.top.children.length,l+5);l<c;l++){let u=this.top.children[l];if(u.matchesNode(e,r,n)&&!this.preMatch.matched.has(u)){i=l;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==Zc&&a.dom==a.contentDOM&&(a.dirty=mx),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 l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof Lm){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!=Zc&&gO(r,c.outerDeco));if(!f&&c.update(e,r,n,s))return this.destroyBetween(this.index,l),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,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=mx,h.updateChildren(s,a+1),h.dirty=nc),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)||!gO(n,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=Lm.create(this.top,r,n,s,i,a);if(l.contentDOM){l.children=e.children,e.children=[];for(let c of l.children)c.parent=l}return e.destroy(),l}addNode(e,r,n,s,i){let a=Lm.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 _Ee(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 Dm;)r=e,e=r.children[r.children.length-1];(!e||!(e instanceof f5)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ea||na)&&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 NEe(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||Dt(e)&&e.contains(this.lock.parentNode))}}function n5t(t,e){let r=e,n=r.children.length,s=t.childCount,i=new Map,a=[];e:for(;s>0;){let l;for(;;)if(n){let u=r.children[n-1];if(u instanceof Dm)r=u,n=u.children.length;else{l=u,n--;break}}else{if(r==e)break e;n=r.parent.children.indexOf(r),r=r.parent}let c=l.node;if(c){if(c!=t.child(s-1))break;--s,i.set(l,s),a.push(l)}}return{index:s,matched:i,matches:a.reverse()}}function s5t(t,e){return t.type.side-e.type.side}function i5t(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,l=[],c=null;for(let u=0;;){let d,h;for(;a<s.length&&s[a].to==i;){let y=s[a++];y.widget&&(d?(h||(h=[d])).push(y):d=y)}if(d)if(h){h.sort(s5t);for(let y=0;y<h.length;y++)r(h[y],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 y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;a<s.length&&s[a].from<=i&&s[a].to>i;)l.push(s[a++]);let m=i+f.nodeSize;if(f.isText){let y=m;a<s.length&&s[a].from<y&&(y=s[a].from);for(let x=0;x<l.length;x++)l[x].to<y&&(y=l[x].to);y<m&&(c=f.cut(y-i),f=f.cut(0,y-i),m=y,p=-1)}else for(;a<s.length&&s[a].to<m;)a++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();n(f,g,e.forChild(i,f),p),i=m}}function a5t(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 o5t(t,e,r,n){for(let s=0,i=0;s<t.childCount&&i<=n;){let a=t.child(s++),l=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-l,n-l)==e)return n-e.length;let u=l<n?c.lastIndexOf(e,n-l-1):-1;if(u>=0&&u+e.length+l>=r)return l+u;if(r==n&&c.length>=n+e.length-l&&c.slice(n-l,n-l+e.length)==e)return n}}return-1}function d7(t,e,r,n,s){let i=[];for(let a=0,l=0;a<t.length;a++){let c=t[a],u=l,d=l+=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 ZG(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 l=n.resolve(a),c,u;if(d5(r)){for(c=a;s&&!s.node;)s=s.parent;if(s&&s.node.isAtom&&Pt.isSelectable(s.node)&&s.parent&&!(s.node.isInline&&OLt(r.focusNode,r.focusOffset,s.dom))){let h=s.posBefore;u=new Pt(a==h?l:n.resolve(h))}else if(dl&&e=="key"&&a>t.state.selection.to&&Dt(r.focusNode)&&r.focusOffset==r.focusNode.childNodes.length&&s&&s.posAtStart>t.state.selection.to)for(let h=r.focusNode;;h=h.parentNode){if(getComputedStyle(h).overflow!="visible"){u=Mt.findFrom(n.resolve(s.posAtStart),1);break}if(h==s.dom||h.nextSibling||!h.parentNode||!Dt(h.parentNode))break}}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],l=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<l.pos&&!i?1:-1;u=JG(t,d,l,h)}return u}function AEe(t){return t.editable?t.hasFocus():PEe(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Qh(t,e=!1){let r=t.state.selection;if(TEe(t,r),!AEe(t))return;let n=t.input.mouseDown;if(!e&&na&&n){let s=t.domSelectionRange(),i=t.domObserver.currentSelection;if(s.anchorNode&&i.anchorNode&&wv(s.anchorNode,s.anchorOffset,i.anchorNode,i.anchorOffset)&&n.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)c5t(t);else{let{anchor:s,head:i}=r,a,l;Ooe&&!(r instanceof ht)&&(r.$from.parent.inlineContent||(a=Moe(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=Moe(t,r.to))),t.docView.setSelection(s,i,t,e),Ooe&&(a&&Doe(a),l&&Doe(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&l5t(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const Ooe=Ea||na&&gEe<63;function Moe(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(Ea&&s&&s.contentEditable=="false")return XF(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return XF(s);if(i)return XF(i)}}function XF(t){return t.contentEditable="true",Ea&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Doe(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function l5t(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(()=>{(!AEe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function c5t(t){let e=t.domSelection();if(!e)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?e.collapse(r.parentNode,Ji(r)+1):e.collapse(r,0),!n&&!t.state.selection.visible&&Ao&&Mm<=11&&(r.disabled=!0,r.disabled=!1)}function TEe(t,e){if(e instanceof Pt){let r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(Loe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else Loe(t)}function Loe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function JG(t,e,r,n){return t.someProp("createSelectionBetween",s=>s(t,e,r))||ht.between(e,r,n)}function $oe(t){return t.editable&&!t.hasFocus()?!1:PEe(t)}function PEe(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return jv(t.dom,e.anchorNode)&&(t.editable||jv(t.dom,e.focusNode))}catch{return!1}}function u5t(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return wv(e.node,e.offset,r.anchorNode,r.anchorOffset)}function h7(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&&Mt.findFrom(i,e)}function op(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Foe(t,e,r){let n=t.state.selection;if(n instanceof ht)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 op(t,new ht(n.$anchor,a))}else if(n.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=h7(t.state,e);return s&&s instanceof Pt?op(t,s):!1}else if(!(Bl&&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 l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(a=t.docView.descAt(l))&&!a.contentDOM?Pt.isSelectable(i)?op(t,new Pt(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):op(t,new ht(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(n instanceof Pt&&n.node.isInline)return op(t,new ht(e>0?n.$to:n.$from));{let s=h7(t.state,e);return s?op(t,s):!1}}}function X_(t,e){let r=t.pmViewDesc;return r?r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):Dt(t)&&t.contentEditable=="false"}function hb(t,e){return e<0?d5t(t):h5t(t)}function d5t(t){let e=t.domSelectionRange(),r=e.focusNode,n=e.focusOffset;if(!r)return;let s,i,a=!1;for(dl&&Dt(r)&&n<ja(r)&&X_(r.childNodes[n],-1)&&(a=!0);;)if(n>0){if(!Dt(r))break;let l=r.childNodes[n-1];if(X_(l,-1))s=r,i=--n;else if(si(l))r=l,n=r.nodeValue.length;else break}else{if(IEe(r))break;{let l=r.previousSibling;for(;l&&X_(l,-1);)s=r.parentNode,i=Ji(l),l=l.previousSibling;if(l)r=l,n=ja(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}a?f7(t,r,n):s&&f7(t,s,i)}function h5t(t){let e=t.domSelectionRange(),r=e.focusNode,n=e.focusOffset;if(!r)return;let s=ja(r),i,a;for(;;)if(n<s){if(!Dt(r))break;let l=r.childNodes[n];if(X_(l,1))i=r,a=++n;else break}else{if(IEe(r))break;{let l=r.nextSibling;for(;l&&X_(l,1);)i=l.parentNode,a=Ji(l)+1,l=l.nextSibling;if(l)r=l,n=0,s=ja(r);else{if(r=r.parentNode,r==t.dom)break;n=s=0}}}i&&f7(t,i,a)}function IEe(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function f5t(t,e){for(;t&&e==t.childNodes.length&&!jA(t);)e=Ji(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let r=t.childNodes[e];if(si(r))return r;if(Dt(r)&&r.contentEditable=="false")break;t=r,e=0}}function p5t(t,e){for(;t&&!e&&!jA(t);)e=Ji(t),t=t.parentNode;for(;t&&e;){let r=t.childNodes[e-1];if(si(r))return r;if(Dt(r)&&r.contentEditable=="false")break;t=r,e=t.childNodes.length}}function f7(t,e,r){if(!si(e)){let i,a;(a=f5t(e,r))?(e=a,r=0):(i=p5t(e,r))&&(e=i,r=i.nodeValue.length)}let n=t.domSelection();if(!n)return;if(d5(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&&Qh(t)},50)}function Boe(t,e){let r=t.state.doc.resolve(e);if(!(na||xEe)&&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 zoe(t,e,r){let n=t.state.selection;if(n instanceof ht&&!n.empty||r.indexOf("s")>-1||Bl&&r.indexOf("m")>-1)return!1;let{$from:s,$to:i}=n;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let a=h7(t.state,e);if(a&&a instanceof Pt)return op(t,a)}if(!s.parent.inlineContent){let a=e<0?s:i,l=n instanceof ul?Mt.near(a,e):Mt.findFrom(a,e);return l?op(t,l):!1}return!1}function Uoe(t,e){if(!(t.state.selection instanceof ht))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 Hoe(t,e,r){t.domObserver.stop(),e.contentEditable=r,t.domObserver.start()}function m5t(t){if(!Ea||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&Dt(e)&&r==0&&e.firstChild&&Dt(e.firstChild)&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Hoe(t,n,"true"),setTimeout(()=>Hoe(t,n,"false"),20)}return!1}function g5t(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function x5t(t,e){let r=e.keyCode,n=g5t(e);if(r==8||Bl&&r==72&&n=="c")return Uoe(t,-1)||hb(t,-1);if(r==46&&!e.shiftKey||Bl&&r==68&&n=="c")return Uoe(t,1)||hb(t,1);if(r==13||r==27)return!0;if(r==37||Bl&&r==66&&n=="c"){let s=r==37?Boe(t,t.state.selection.from)=="ltr"?-1:1:-1;return Foe(t,s,n)||hb(t,s)}else if(r==39||Bl&&r==70&&n=="c"){let s=r==39?Boe(t,t.state.selection.from)=="ltr"?1:-1:1;return Foe(t,s,n)||hb(t,s)}else{if(r==38||Bl&&r==80&&n=="c")return zoe(t,-1,n)||hb(t,-1);if(r==40||Bl&&r==78&&n=="c")return m5t(t)||zoe(t,1,n)||hb(t,1);if(n==(Bl?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function eK(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")||Uv.fromSchema(t.state.schema),l=$Ee(),c=l.createElement("div");c.appendChild(a.serializeFragment(n,{document:l}));let u=c.firstChild,d,h=0;for(;u&&Dt(u)&&(d=LEe[u.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let m=l.createElement(d[p]);for(;c.firstChild;)m.appendChild(c.firstChild);c.appendChild(m),h++}u=c.firstChild}u&&Dt(u)&&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 REe(t,e,r,n,s){let i=s.parent.type.spec.code,a,l;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 l=new at(Me.from(t.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),t.someProp("transformPasted",f=>{l=f(l,t,!0)}),l;let h=t.someProp("clipboardTextParser",f=>f(e,s,n,t));if(h)l=h;else{let f=s.marks(),{schema:p}=t.state,m=Uv.fromSchema(p);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=a.appendChild(document.createElement("p"));g&&y.appendChild(m.serializeNode(p.text(g,f)))})}}else t.someProp("transformPastedHTML",h=>{r=h(r,t)}),a=w5t(r),h5&&j5t(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&&!Dt(f);)f=f.nextSibling;if(!f)break;a=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Om.fromSchema(t.state.schema)).parseSlice(a,{preserveWhitespace:!!(c||d),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!y5t.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=S5t(Woe(l,+d[1],+d[2]),d[4]);else if(l=at.maxOpen(v5t(l.content,s),!0),l.openStart||l.openEnd){let h=0,f=0;for(let p=l.content.firstChild;h<l.openStart&&!p.type.spec.isolating;h++,p=p.firstChild);for(let p=l.content.lastChild;f<l.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);l=Woe(l,h,f)}return t.someProp("transformPasted",h=>{l=h(l,t,c)}),l}const y5t=/^(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 v5t(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(l=>{if(!a)return;let c=s.findWrapping(l.type),u;if(!c)return a=null;if(u=a.length&&i.length&&MEe(c,i,l,a[a.length-1],0))a[a.length-1]=u;else{a.length&&(a[a.length-1]=DEe(a[a.length-1],i.length));let d=OEe(l,c);a.push(d),s=s.matchType(d.type),i=c}}),a)return Me.from(a)}return t}function OEe(t,e,r=0){for(let n=e.length-1;n>=r;n--)t=e[n].create(null,Me.from(t));return t}function MEe(t,e,r,n,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=MEe(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(Me.from(OEe(r,t,s+1))))}}function DEe(t,e){if(e==0)return t;let r=t.content.replaceChild(t.childCount-1,DEe(t.lastChild,e-1)),n=t.contentMatchAt(t.childCount).fillBefore(Me.empty,!0);return t.copy(r.append(n))}function p7(t,e,r,n,s,i){let a=e<0?t.firstChild:t.lastChild,l=a.content;return t.childCount>1&&(i=0),s<n-1&&(l=p7(l,e,r,n,s+1,i)),s>=r&&(l=e<0?a.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(Me.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,a.copy(l))}function Woe(t,e,r){return e<t.openStart&&(t=new at(p7(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),r<t.openEnd&&(t=new at(p7(t.content,1,r,t.openEnd,0,0),t.openStart,r)),t}const LEe={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 $Ee(){return document.implementation.createHTMLDocument("title")}let _S=null;function b5t(t){let e=window.trustedTypes;if(!e)return t;if(!_S){if(_S=e.defaultPolicy)try{return _S.createHTML(t)}catch{}_S=e.createPolicy("ProseMirrorClipboard",{createHTML:r=>r})}return _S.createHTML(t)}function w5t(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let r=$Ee(),n=r.body,s=/<([a-z][^>\s]+)/i.exec(t),i;if((i=s&&LEe[s[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=b5t(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 l=r.styleSheets[a];for(let c=0;c<l.rules.length;c++){let u=l.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 j5t(t){let e=t.querySelectorAll(na?"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 S5t(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 l=n.length-2;l>=0;l-=2){let c=r.nodes[n[l]];if(!c||c.hasRequiredAttrs())break;try{s=Me.from(c.create(n[l+1],s))}catch{break}i++,a++}return new at(s,i,a)}const Qa={},Za={},_5t={touchstart:!0,touchmove:!0};class N5t{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 k5t(t){for(let e in Qa){let r=Qa[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=n=>{E5t(t,n)&&!tK(t,n)&&(t.editable||!(n.type in Za))&&r(t,n)},_5t[e]?{passive:!0}:void 0)}Ea&&t.dom.addEventListener("input",()=>null),m7(t)}function Wh(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function C5t(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 m7(t){t.someProp("handleDOMEvents",e=>{for(let r in e)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>tK(t,n))})}function tK(t,e){return t.someProp("handleDOMEvents",r=>{let n=r[e.type];return n?n(t,e)||e.defaultPrevented:!1})}function E5t(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 A5t(t,e){!tK(t,e)&&Qa[e.type]&&(t.editable||!(e.type in Za))&&Qa[e.type](t,e)}Za.keydown=(t,e)=>{let r=e;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!UEe(t)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Hh&&na&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),V1&&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,Jg(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||x5t(t,r)?r.preventDefault():Wh(t,"key")};Za.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Za.keypress=(t,e)=>{let r=e;if(UEe(t)||!r.charCode||r.ctrlKey&&!r.altKey||Bl&&r.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof ht)||!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 _A(t){return{left:t.clientX,top:t.clientY}}function T5t(t,e){let r=e.x-t.clientX,n=e.y-t.clientY;return r*r+n*n<100}function rK(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,l=>a>i.depth?l(t,r,i.nodeAfter,i.before(a),s,!0):l(t,r,i.node(a),i.before(a),s,!1)))return!0;return!1}function NA(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 P5t(t,e){if(e==-1)return!1;let r=t.state.doc.resolve(e),n=r.nodeAfter;return n&&n.isAtom&&Pt.isSelectable(n)?(NA(t,new Pt(r)),!0):!1}function I5t(t,e){if(e==-1)return!1;let r=t.state.selection,n,s;r instanceof Pt&&(n=r.node);let i=t.state.doc.resolve(e);for(let a=i.depth+1;a>0;a--){let l=a>i.depth?i.nodeAfter:i.node(a);if(Pt.isSelectable(l)){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?(NA(t,Pt.create(t.state.doc,s)),!0):!1}function R5t(t,e,r,n,s){return rK(t,"handleClickOn",e,r,n)||t.someProp("handleClick",i=>i(t,e,n))||(s?I5t(t,r):P5t(t,r))}function O5t(t,e,r,n){return rK(t,"handleDoubleClickOn",e,r,n)||t.someProp("handleDoubleClick",s=>s(t,e,n))}function M5t(t,e,r,n){return rK(t,"handleTripleClickOn",e,r,n)||t.someProp("handleTripleClick",s=>s(t,e,n))||D5t(t,r,n)}function D5t(t,e,r){if(r.button!=0)return!1;let n=FEe(t,e,!0),s=t.state.doc;return n?(NA(t,n),n instanceof ht&&s.eq(t.state.doc)&&(t.input.mouseDown=new $5t(t,n)),!0):!1}function FEe(t,e,r){let n=t.state.doc;if(e==-1)return n.inlineContent?ht.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),l=s.before(i);if(a.inlineContent)return ht.create(n,l+1,l+1+a.content.size);if(r&&Pt.isSelectable(a))return Pt.create(n,l)}return null}function nK(t){return xO(t)}const BEe=Bl?"metaKey":"ctrlKey";Qa.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let n=nK(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&T5t(r,t.input.lastClick)&&!r[BEe]&&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(_A(r));a&&(i=="singleClick"?t.input.mouseDown=new L5t(t,a,r,!!n):(i=="doubleClick"?O5t:M5t)(t,a.pos,a.inside,r)?r.preventDefault():Wh(t,"pointer"))};class zEe{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 L5t extends zEe{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[BEe],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 l=s?null:n.target,c=l?e.docView.nearestDesc(l,!0):null;this.target=c&&Dt(c.nodeDOM)?c.nodeDOM:null;let{selection:u}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||u instanceof Pt&&u.from<=a&&u.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&dl&&!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()),Wh(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||Qh(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(_A(e))),this.updateAllowDefault(e),this.allowDefault||!r?Wh(this.view,"pointer"):R5t(this.view,r.pos,r.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ea&&this.mightDrag&&!this.mightDrag.node.isAtom||na&&!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)?(NA(this.view,Mt.near(this.view.state.doc.resolve(r.pos))),e.preventDefault()):Wh(this.view,"pointer")}move(e){this.updateAllowDefault(e),Wh(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 $5t extends zEe{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(),Wh(this.view,"pointer");let r=this.view.posAtCoords(_A(e)),n=r&&FEe(this.view,r.inside,!1);if(!n)return;let{doc:s}=this.view.state,i=this.startSelection,[a,l]=n.from<i.from?[i.to,n.from]:[i.from,n.to];NA(this.view,ht.create(s,a,l))}}Qa.touchstart=t=>{t.input.lastTouch=Date.now(),nK(t),Wh(t,"pointer")};Qa.touchmove=t=>{t.input.lastTouch=Date.now(),Wh(t,"pointer")};Qa.contextmenu=t=>nK(t);function UEe(t,e){return t.composing?!0:Ea&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const F5t=Hh?5e3:-1;Za.compositionstart=Za.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof ht&&e.selection.empty&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||na&&xEe&&B5t(t)))t.markCursor=t.state.storedMarks||r.marks(),xO(t,!0),t.markCursor=null;else if(xO(t,!e.selection.empty),dl&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let n=t.domSelectionRange();for(let s=n.focusNode,i=n.focusOffset;s&&Dt(s)&&i!=0;){let a=i<0?s.lastChild:s.childNodes[i-1];if(!a)break;if(si(a)){let l=t.domSelection();l&&l.collapse(a,a.nodeValue.length);break}else s=a,i=-1}}t.input.composing=!0}HEe(t,F5t)};function B5t(t){let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(!e||!Dt(e)||r>=e.childNodes.length)return!1;let n=e.childNodes[r];return Dt(n)&&n.contentEditable=="false"}Za.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++,HEe(t,20))};function HEe(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>xO(t),e))}function WEe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function z5t(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=ILt(e.focusNode,e.focusOffset),n=RLt(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 xO(t,e=!1){if(!(Hh&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),WEe(t),e||t.docView&&t.docView.dirty){let r=ZG(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 U5t(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 Ik=Ao&&Mm<15||V1&&LLt<604;Qa.copy=Za.cut=(t,e)=>{let r=e,n=t.state.selection,s=r.type=="cut";if(n.empty)return;let i=Ik?null:r.clipboardData,a=n.content(),{dom:l,text:c}=eK(t,a);i?(r.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",c)):U5t(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function H5t(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function W5t(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?Rk(t,n.value,null,s,e):Rk(t,n.textContent,n.innerHTML,s,e)},50)}function Rk(t,e,r,n,s){let i=REe(t,e,r,n,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,s,i||at.empty)))return!0;if(!i)return!1;let a=H5t(i),l=a?t.state.tr.replaceSelectionWith(a,n):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function VEe(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," "):""}Za.paste=(t,e)=>{let r=e;if(t.composing&&!Hh)return;let n=Ik?null:r.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&Rk(t,VEe(n),n.getData("text/html"),s,r)?r.preventDefault():W5t(t,r)};class qEe{constructor(e,r,n){this.slice=e,this.move=r,this.node=n}}const V5t=Bl?"altKey":"ctrlKey";function GEe(t,e){let r;return t.someProp("dragCopies",n=>{r=r||n(e)}),r!=null?!r:!e[V5t]}Qa.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(_A(r)),a;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Pt?s.to-1:s.to))){if(n&&n.mightDrag)a=Pt.create(t.state.doc,n.mightDrag.pos);else if(r.target&&Dt(r.target)){let h=t.docView.nearestDesc(r.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(a=Pt.create(t.state.doc,h.posBefore))}}let l=(a||t.state.selection).content(),{dom:c,text:u,slice:d}=eK(t,l);(!r.dataTransfer.files.length||!na||gEe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(Ik?"Text":"text/html",c.innerHTML),r.dataTransfer.effectAllowed="copyMove",Ik||r.dataTransfer.setData("text/plain",u),t.dragging=new qEe(d,GEe(t,r),a)};Qa.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Za.dragover=Za.dragenter=(t,e)=>e.preventDefault();Za.drop=(t,e)=>{try{q5t(t,e,t.dragging)}finally{t.dragging=null}};function q5t(t,e,r){if(!e.dataTransfer)return;let n=t.posAtCoords(_A(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=REe(t,VEe(e.dataTransfer),Ik?null:e.dataTransfer.getData("text/html"),!1,s);let a=!!(r&&GEe(t,e));if(t.someProp("handleDrop",p=>p(t,e,i||at.empty,a))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?MCe(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let c=t.state.tr;if(a){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(l),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&&Pt.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new Pt(f));else{let p=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,x)=>p=x),c.setSelection(JG(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}Qa.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())&&Qh(t)},20))};Qa.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)};Qa.beforeinput=(t,e)=>{if(Hh&&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,Jg(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 Za)Qa[t]=Za[t];function Ok(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 yO{constructor(e,r){this.toDOM=e,this.spec=r||Gy,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 Ts(i-n,i-n,this)}valid(){return!0}eq(e){return this==e||e instanceof yO&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ok(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class $m{constructor(e,r){this.attrs=e,this.spec=r||Gy}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 Ts(i,a,this)}valid(e,r){return r.from<r.to}eq(e){return this==e||e instanceof $m&&Ok(this.attrs,e.attrs)&&Ok(this.spec,e.spec)}static is(e){return e.type instanceof $m}destroy(){}}class sK{constructor(e,r){this.attrs=e,this.spec=r||Gy}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 Ts(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 sK&&Ok(this.attrs,e.attrs)&&Ok(this.spec,e.spec)}destroy(){}}class Ts{constructor(e,r,n){this.from=e,this.to=r,this.type=n}copy(e,r){return new Ts(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 Ts(e,e,new yO(r,n))}static inline(e,r,n,s){return new Ts(e,r,new $m(n,s))}static node(e,r,n,s){return new Ts(e,r,new sK(n,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof $m}get widget(){return this.type instanceof yO}}const Eb=[],Gy={};class Dr{constructor(e,r){this.local=e.length?e:Eb,this.children=r.length?r:Eb}static create(e,r){return r.length?vO(r,e,0,Gy):ba}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 l=this.local[a];l.from<=r&&l.to>=e&&(!i||i(l.spec))&&n.push(l.copy(l.from+s,l.to+s))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<r&&this.children[a+1]>e){let l=this.children[a]+1;this.children[a+2].findInner(e-l,r-l,n,s+l,i)}}map(e,r,n){return this==ba||e.maps.length==0?this:this.mapInner(e,r,0,0,n||Gy)}mapInner(e,r,n,s,i){let a;for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,n,s);c&&c.type.valid(r,c)?(a||(a=[])).push(c):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?G5t(this.children,a||[],e,r,n,s,i):a?new Dr(a.sort(Ky),Eb):ba}add(e,r){return r.length?this==ba?Dr.create(e,r):this.addInner(e,r,0):this}addInner(e,r,n){let s,i=0;e.forEach((l,c)=>{let u=c+n,d;if(d=YEe(r,l,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(l,d,u+1):s.splice(i,0,c,c+l.nodeSize,vO(d,l,u+1,Gy)),i+=3}});let a=KEe(i?XEe(r):r,-n);for(let l=0;l<a.length;l++)a[l].type.valid(e,a[l])||a.splice(l--,1);return new Dr(a.length?this.local.concat(a).sort(Ky):this.local,s||this.children)}remove(e){return e.length==0||this==ba?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,l=n[i]+r,c=n[i+1]+r;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>l&&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,l+1);u!=ba?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 l=0;l<s.length;l++)s[l].eq(a,r)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return n==this.children&&s==this.local?this:s.length||n.length?new Dr(s,n):ba}forChild(e,r){if(this==ba)return this;if(r.isLeaf)return Dr.empty;let n,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let i=e+1,a=i+r.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<a&&c.to>i&&c.type instanceof $m){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 l=new Dr(s.sort(Ky),Eb);return n?new pp([l,n]):l}return n||ba}eq(e){if(this==e)return!0;if(!(e instanceof Dr)||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 iK(this.localsInner(e))}localsInner(e){if(this==ba)return Eb;if(e.inlineContent||!this.local.some($m.is))return this.local;let r=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof $m||r.push(this.local[n]);return r}forEachSet(e){e(this)}}Dr.empty=new Dr([],[]);Dr.removeOverlap=iK;const ba=Dr.empty;class pp{constructor(e){this.members=e}map(e,r){const n=this.members.map(s=>s.map(e,r,Gy));return pp.from(n)}forChild(e,r){if(r.isLeaf)return Dr.empty;let n=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,r);i!=ba&&(i instanceof pp?n=n.concat(i.members):n.push(i))}return pp.from(n)}eq(e){if(!(e instanceof pp)||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?iK(n?r:r.sort(Ky)):Eb}static from(e){switch(e.length){case 0:return ba;case 1:return e[0];default:return new pp(e.every(r=>r instanceof Dr)?e:e.reduce((r,n)=>r.concat(n instanceof Dr?n:n.members),[]))}}forEachSet(e){for(let r=0;r<this.members.length;r++)this.members[r].forEachSet(e)}}function G5t(t,e,r,n,s,i,a){let l=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 y=g-m-(p-f);for(let x=0;x<l.length;x+=3){let v=l[x+1];if(v<0||f>v+d-h)continue;let b=l[x]+d-h;p>=b?l[x+1]=f<=b?-2:-1:f>=d&&y&&(l[x]+=y,l[x+1]+=y)}h+=y}),d=r.maps[u].map(d,-1)}let c=!1;for(let u=0;u<l.length;u+=3)if(l[u+1]<0){if(l[u+1]==-2){c=!0,l[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),y=n.maybeChild(m);if(y&&g==h&&g+y.nodeSize==p){let x=l[u+2].mapInner(r,y,d+1,t[u]+i+1,a);x!=ba?(l[u]=h,l[u+1]=p,l[u+2]=x):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=K5t(l,t,e,r,s,i,a),d=vO(u,n,0,a);e=d.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,f=0;h<d.children.length;h+=3){let p=d.children[h];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,d.children[h],d.children[h+1],d.children[h+2])}}return new Dr(e.sort(Ky),l)}function KEe(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 Ts(s.from+e,s.to+e,s.type))}return r}function K5t(t,e,r,n,s,i,a){function l(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)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+i+1);return r}function YEe(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 XEe(t){let e=[];for(let r=0;r<t.length;r++)t[r]!=null&&e.push(t[r]);return e}function vO(t,e,r,n){let s=[],i=!1;e.forEach((l,c)=>{let u=YEe(t,l,c+r);if(u){i=!0;let d=vO(u,l,r+c+1,n);d!=ba&&s.push(c,c+l.nodeSize,d)}});let a=KEe(i?XEe(t):t,-r).sort(Ky);for(let l=0;l<a.length;l++)a[l].type.valid(e,a[l])||(n.onRemove&&n.onRemove(a[l].spec),a.splice(l--,1));return a.length||s.length?new Dr(a,s):ba}function Ky(t,e){return t.from-e.from||t.to-e.to}function iK(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),Voe(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),Voe(e,s,n.copy(i.from,n.to)));break}}}return e}function Voe(t,e,r){for(;e<t.length&&Ky(r,t[e])>0;)e++;t.splice(e,0,r)}function QF(t){let e=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=ba&&e.push(n)}),t.cursorWrapper&&e.push(Dr.create(t.state.doc,[t.cursorWrapper.deco])),pp.from(e)}const Y5t={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},X5t=Ao&&Mm<=11;class Q5t{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 Z5t{constructor(e,r){this.view=e,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Q5t,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]);Ao&&Mm<=11&&n.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Ea&&e.composing&&n.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),X5t&&(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,Y5t)),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($oe(this.view)){if(this.suppressingSelectionUpdates)return Qh(this.view);if(Ao&&Mm<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&wv(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=W1(i))r.add(i);for(let i=e.anchorNode;i;i=W1(i))if(r.has(i)){n=i;break}let s=n&&this.view.docView.nearestDesc(n);if(s&&s.ignoreMutation({type:"selection",target:si(n)?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)&&$oe(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,l=!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&&(l=!0))}if(c.some(d=>d.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||na&&(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&&Dt(h);){if(h.contentEditable=="false"){d.parentNode.removeChild(d);break}h=h.firstChild}}}else if(dl&&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||t4t(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&&d5(n)&&(u=ZG(e))&&u.eq(Mt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qh(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,a),J5t(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,r4t(e,c)),this.handleDOMChange(i,a,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Qh(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),si(h)&&(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(Ao&&Mm<=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?Ji(s)+1:0,l=n.localPosFromDOM(e.target,a,-1),c=i&&i.parentNode==e.target?Ji(i):e.target.childNodes.length,u=n.localPosFromDOM(e.target,c,1);return{from:l,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 qoe=new WeakMap,Goe=!1;function J5t(t){if(!qoe.has(t)&&(qoe.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=dl,Goe)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."),Goe=!0}}function Koe(t,e){let r=e.startContainer,n=e.startOffset,s=e.endContainer,i=e.endOffset,a=t.domAtPos(t.state.selection.anchor);return wv(a.node,a.offset,s,i)&&([r,n,s,i]=[s,i,r,n]),{anchorNode:r,anchorOffset:n,focusNode:s,focusOffset:i}}function e4t(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Koe(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?Koe(t,r):null}function t4t(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 r4t(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 l=a;for(;;){let c=l.firstChild;if(!c||!Dt(c)||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;l=c}l.insertBefore(i,l.firstChild),n==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function n4t(t,e,r,n){let{node:s,fromOffset:i,toOffset:a,from:l,to:c}=t.docView.parseRange(e,r),u=t.domSelectionRange(),d,h=u.anchorNode;if(h&&jv(t.dom,h)&&(d=[{node:h,offset:u.anchorOffset}],d5(u)||d.push({node:u.focusNode,offset:u.focusOffset})),na&&t.input.lastKeyCode===8)for(let x=a;x>i;x--){let v=s.childNodes[x-1],b=v.pmViewDesc;if(v.nodeName=="BR"&&!b){a=x;break}if(!b||b.size)break}let f=t.state.doc,p=t.someProp("domParser")||Om.fromSchema(t.state.schema),m=f.resolve(l),g=null,y=p.parse(s,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:s4t(n),context:m});if(d&&d[0].pos!=null){let x=d[0].pos,v=d[1]&&d[1].pos;v==null&&(v=x),g={anchor:x+l,head:v+l}}return{doc:y,sel:g,from:l,to:c}}const s4t=t=>e=>{let r=e.pmViewDesc;if(r)return r.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(Ea&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(e.parentNode.lastChild==e||Ea&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},i4t=/^(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 a4t(t,e,r,n,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,A=ZG(t,C);if(A&&!t.state.selection.eq(A)){if(na&&Hh&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",O=>O(t,Jg(13,"Enter"))))return;let E=t.state.tr.setSelection(A);C=="pointer"?E.setMeta("pointer",!0):C=="key"&&E.scrollIntoView(),i&&E.setMeta("composition",i),t.dispatch(E)}return}let a=t.state.doc.resolve(e),l=a.sharedDepth(r);e=a.before(l+1),r=t.state.doc.resolve(r).after(l+1);let c=t.state.selection,u=n4t(t,e,r,s),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=u4t(h.content,u.doc.content,u.from,f,p);if(m&&t.input.domChangeCount++,(V1&&t.input.lastIOSEnter>Date.now()-225||Hh)&&s.some(C=>Dt(C)&&!i4t.test(C.nodeName))&&(!m||m.endA>=m.endB)&&t.someProp("handleKeyDown",C=>C(t,Jg(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!m)if(n&&c instanceof ht&&!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 C=Yoe(t,t.state.doc,u.sel);if(C&&!C.eq(t.state.selection)){let A=t.state.tr.setSelection(C);i&&A.setMeta("composition",i),t.dispatch(A)}}return}t.state.selection.from<t.state.selection.to&&m.start==m.endB&&t.state.selection instanceof ht&&(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)),Ao&&Mm<=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),y=u.doc.resolveNoCache(m.endB-u.from),x=d.resolve(m.start),v=g.sameParent(y)&&g.parent.inlineContent&&x.end()>=m.endA;if((V1&&t.input.lastIOSEnter>Date.now()-225&&(!v||s.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!v&&c4t(u.doc,g.pos,y.pos))&&t.someProp("handleKeyDown",C=>C(t,Jg(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>m.start&&l4t(d,m.start,m.endA,g,y)&&t.someProp("handleKeyDown",C=>C(t,Jg(8,"Backspace")))){Hh&&na&&t.domObserver.suppressSelectionUpdates();return}na&&m.endB==m.start&&(t.input.lastChromeDelete=Date.now()),Hh&&!v&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,y=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,Jg(13,"Enter"))})},20));let b=m.start,w=m.endA,j=C=>{let A=C||t.state.tr.replace(b,w,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let E=Yoe(t,A.doc,u.sel);E&&!(na&&t.composing&&E.empty&&(m.start!=m.endB||t.input.lastChromeDelete<Date.now()-100)&&(E.head==b||E.head==A.mapping.map(w)-1)||Ao&&E.empty&&E.head==b)&&A.setSelection(E)}return i&&A.setMeta("composition",i),A.scrollIntoView()},N;if(v)if(g.pos==y.pos){Ao&&Mm<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Qh(t),20));let C=j(t.state.tr.delete(b,w)),A=d.resolve(m.start).marksAcross(d.resolve(m.endA));A&&C.ensureMarks(A),t.dispatch(C)}else if(m.endA==m.endB&&(N=o4t(g.parent.content.cut(g.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let C=j(t.state.tr);N.type=="add"?C.addMark(b,w,N.mark):C.removeMark(b,w,N.mark),t.dispatch(C)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let C=g.parent.textBetween(g.parentOffset,y.parentOffset),A=()=>j(t.state.tr.insertText(C,b,w));t.someProp("handleTextInput",E=>E(t,b,w,C,A))||t.dispatch(A())}else t.dispatch(j());else t.dispatch(j())}function Yoe(t,e,r){return Math.max(r.anchor,r.head)>e.content.size?null:JG(t,e.resolve(r.anchor),e.resolve(r.head))}function o4t(t,e){let r=t.firstChild.marks,n=e.firstChild.marks,s=r,i=n,a,l,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)l=s[0],a="add",c=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],a="remove",c=d=>d.mark(l.removeFromSet(d.marks));else return null;let u=[];for(let d=0;d<e.childCount;d++)u.push(c(e.child(d)));if(Me.from(u).eq(t))return{mark:l,type:a}}function l4t(t,e,r,n,s){if(r-e<=s.pos-n.pos||ZF(n,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!n.parent.isTextblock){let l=i.nodeAfter;return l!=null&&r==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let a=t.resolve(ZF(i,!0,!0));return!a.parent.isTextblock||a.pos>r||ZF(a,!0,!1)<r?!1:n.parent.content.cut(n.parentOffset).eq(a.parent.content)}function c4t(t,e,r){let n=0,s=0;return t.nodesBetween(e,r,(i,a)=>{i.isTextblock&&a>=e&&a<r?n++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-a),Math.min(i.nodeSize,r-a))):i.isLeaf)&&s++}),s==0&&n==1}function ZF(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 u4t(t,e,r,n,s){let i=t.findDiffStart(e,r),a=r+t.size,l=r+e.size;if(i==null)return null;let{a:c,b:u}=t.findDiffEnd(e,a,l);if(s=="end"){let d=Math.max(0,i-Math.min(c,u));n-=c+d-i}if(c<i&&a<l){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 QEe{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 N5t,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(ele),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=Zoe(this),Qoe(this),this.nodeViews=Joe(this),this.docView=Ioe(this.state.doc,Xoe(this),QF(this),this.dom,this),this.domObserver=new Z5t(this,(n,s,i,a)=>a4t(this,n,s,i,a)),this.domObserver.start(),k5t(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&&m7(this);let r=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ele),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&&(WEe(this),a=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=r.plugins;if(l||this._props.plugins!=r.plugins||this._props.nodeViews!=r.nodeViews){let p=Joe(this);h4t(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||r.handleDOMEvents!=this._props.handleDOMEvents)&&m7(this),this.editable=Zoe(this),Qoe(this);let c=QF(this),u=Xoe(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&&BLt(this);if(a){this.domObserver.stop();let p=h&&(Ao||na)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&d4t(s.selection,e.selection);if(h){let g=na?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=z5t(this)),(i||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=Ioe(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())&&u5t(this)&&m.delaySelUpdate())?Qh(this,p):(TEe(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&&zLt(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!jv(this.dom,e))){if(!this.someProp("handleScrollToSelection",r=>r(this)))if(this.state.selection instanceof Pt){let r=this.docView.domAfterPos(this.state.selection.from);Dt(r)&&Coe(this,r.getBoundingClientRect(),e)}else Coe(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 qEe(e.slice,e.move,s<0?void 0:Pt.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 l=this.directPlugins[a].props[e];if(l!=null&&(s=r?r(l):l))return s}let i=this.state.plugins;if(i)for(let a=0;a<i.length;a++){let l=i[a].props[e];if(l!=null&&(s=r?r(l):l))return s}}hasFocus(){if(Ao){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&&ULt(this.dom),Qh(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 GLt(this,e)}coordsAtPos(e,r=1){return jEe(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 ZLt(this,r||this.state,e)}pasteHTML(e,r){return Rk(this,"",e,!1,r||new ClipboardEvent("paste"))}pasteText(e,r){return Rk(this,e,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(e){return eK(this,e)}destroy(){this.docView&&(C5t(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],QF(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,TLt())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return A5t(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?Ea&&this.root.nodeType===11&&MLt(this.dom.ownerDocument)==this.dom&&e4t(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}QEe.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Xoe(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"),[Ts.node(0,t.state.doc.content.size,e)]}function Qoe(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:Ts.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Zoe(t){return!t.someProp("editable",e=>e(t.state)===!1)}function d4t(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 Joe(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 h4t(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 ele(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 Xm={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:"'"},bO={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},f4t=typeof navigator<"u"&&/Mac/.test(navigator.platform),p4t=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ea=0;ea<10;ea++)Xm[48+ea]=Xm[96+ea]=String(ea);for(var ea=1;ea<=24;ea++)Xm[ea+111]="F"+ea;for(var ea=65;ea<=90;ea++)Xm[ea]=String.fromCharCode(ea+32),bO[ea]=String.fromCharCode(ea);for(var JF in Xm)bO.hasOwnProperty(JF)||(bO[JF]=Xm[JF]);function m4t(t){var e=f4t&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||p4t&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!e&&t.key||(t.shiftKey?bO:Xm)[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 g4t=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),x4t=typeof navigator<"u"&&/Win/.test(navigator.platform);function y4t(t){let e=t.split(/-(?!$)/),r=e[e.length-1];r=="Space"&&(r=" ");let n,s,i,a;for(let l=0;l<e.length-1;l++){let c=e[l];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))g4t?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 v4t(t){let e=Object.create(null);for(let r in t)e[y4t(r)]=t[r];return e}function e6(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 b4t(t){return new Ar({props:{handleKeyDown:aK(t)}})}function aK(t){let e=v4t(t);return function(r,n){let s=m4t(n),i,a=e[e6(s,n)];if(a&&a(r.state,r.dispatch,r))return!0;if(s.length==1&&s!=" "){if(n.shiftKey){let l=e[e6(s,n,!1)];if(l&&l(r.state,r.dispatch,r))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(x4t&&n.ctrlKey&&n.altKey)&&(i=Xm[n.keyCode])&&i!=s){let l=e[e6(i,n)];if(l&&l(r.state,r.dispatch,r))return!0}}return!1}}var w4t=Object.defineProperty,oK=(t,e)=>{for(var r in e)w4t(t,r,{get:e[r],enumerable:!0})};function p5(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 m5=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:r,state:n}=this,{view:s}=r,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...d)=>{const h=c(...d)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,r=!0){const{rawCommands:n,editor:s,state:i}=this,{view:a}=s,l=[],c=!!e,u=e||i.tr,d=()=>(!c&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(u),l.every(f=>f===!0)),h={...Object.fromEntries(Object.entries(n).map(([f,p])=>[f,(...g)=>{const y=this.buildProps(u,r),x=p(...g)(y);return l.push(x),h}])),run:d};return h}createCan(e){const{rawCommands:r,state:n}=this,s=!1,i=e||n.tr,a=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(r).map(([c,u])=>[c,(...d)=>u(...d)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}buildProps(e,r=!0){const{rawCommands:n,editor:s,state:i}=this,{view:a}=s,l={tr:e,editor:s,view:a,state:p5({state:i,transaction:e}),dispatch:r?()=>{}:void 0,chain:()=>this.createChain(e,r),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...d)=>u(...d)(l)]))}};return l}},ZEe={};oK(ZEe,{blur:()=>j4t,clearContent:()=>S4t,clearNodes:()=>_4t,command:()=>N4t,createParagraphNear:()=>k4t,cut:()=>C4t,deleteCurrentNode:()=>E4t,deleteNode:()=>A4t,deleteRange:()=>T4t,deleteSelection:()=>R4t,enter:()=>O4t,exitCode:()=>M4t,extendMarkRange:()=>D4t,first:()=>L4t,focus:()=>F4t,forEach:()=>B4t,insertContent:()=>z4t,insertContentAt:()=>W4t,joinBackward:()=>G4t,joinDown:()=>q4t,joinForward:()=>K4t,joinItemBackward:()=>Y4t,joinItemForward:()=>X4t,joinTextblockBackward:()=>Q4t,joinTextblockForward:()=>Z4t,joinUp:()=>V4t,keyboardShortcut:()=>e3t,lift:()=>t3t,liftEmptyBlock:()=>r3t,liftListItem:()=>n3t,newlineInCode:()=>s3t,resetAttributes:()=>i3t,scrollIntoView:()=>a3t,selectAll:()=>o3t,selectNodeBackward:()=>l3t,selectNodeForward:()=>c3t,selectParentNode:()=>u3t,selectTextblockEnd:()=>d3t,selectTextblockStart:()=>h3t,setContent:()=>f3t,setMark:()=>P3t,setMeta:()=>I3t,setNode:()=>R3t,setNodeSelection:()=>O3t,setTextDirection:()=>M3t,setTextSelection:()=>D3t,sinkListItem:()=>L3t,splitBlock:()=>$3t,splitListItem:()=>F3t,toggleList:()=>z3t,toggleMark:()=>U3t,toggleNode:()=>H3t,toggleWrap:()=>W3t,undoInputRule:()=>V3t,unsetAllMarks:()=>q3t,unsetMark:()=>G3t,unsetTextDirection:()=>K3t,updateAttributes:()=>Y3t,wrapIn:()=>X3t,wrapInList:()=>Q3t});var j4t=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var r;t.isDestroyed||(e.dom.blur(),(r=window==null?void 0:window.getSelection())==null||r.removeAllRanges())}),!0),S4t=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),_4t=()=>({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,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,h=u.resolve(d.map(c)),f=u.resolve(d.map(c+l.nodeSize)),p=h.blockRange(f);if(!p)return;const m=Hv(p);if(l.type.isTextblock){const{defaultType:g}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(p.start,g)}(m||m===0)&&e.lift(p,m)})}),!0},N4t=t=>e=>t(e),k4t=()=>({state:t,dispatch:e})=>sEe(t,e),C4t=(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 ht(n.doc.resolve(Math.max(a-1,0)))),!0},E4t=()=>({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 l=s.before(i),c=s.after(i);t.delete(l,c).scrollIntoView()}return!0}return!1};function Li(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 A4t=t=>({tr:e,state:r,dispatch:n})=>{const s=Li(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},T4t=t=>({tr:e,dispatch:r})=>{const{from:n,to:s}=t;return r&&e.delete(n,s),!0},P4t=t=>t.content?/^text(\*|\+)/.test(t.content):!1,tle=(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 P4t(n)?r==="left"?t.start()-1:t.end()+1:t.pos},I4t=(t,e,r)=>{const n=tle(t,r,"left"),s=tle(e,r,"right");return{from:n,to:s}},R4t=()=>({state:t,dispatch:e})=>{const{$from:r,$to:n}=t.selection;if(t.selection.empty)return!1;const{from:s,to:i}=I4t(r,n,t.schema);return e&&(t.tr.deleteRange(s,i).scrollIntoView(),e(t.tr)),!0},O4t=()=>({commands:t})=>t.keyboardShortcut("Enter"),M4t=()=>({state:t,dispatch:e})=>nEe(t,e);function lK(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function wO(t,e,r={strict:!0}){const n=Object.keys(e);return n.length?n.every(s=>r.strict?e[s]===t[s]:lK(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function JEe(t,e,r={}){return t.find(n=>n.type===e&&wO(Object.fromEntries(Object.keys(r).map(s=>[s,n.attrs[s]])),r))}function rle(t,e,r={}){return!!JEe(t,e,r)}function cK(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(!JEe([...n.node.marks],e,r))return;let i=n.index,a=t.start()+n.offset,l=i+1,c=a+n.node.nodeSize;for(;i>0&&rle([...t.parent.child(i-1).marks],e,r);)i-=1,a-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&rle([...t.parent.child(l).marks],e,r);)c+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function Df(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 D4t=(t,e)=>({tr:r,state:n,dispatch:s})=>{const i=Df(t,n.schema),{doc:a,selection:l}=r,{$from:c,from:u,to:d}=l;if(s){const h=cK(c,i,e);if(h&&h.from<=u&&h.to>=d){const f=ht.create(a,h.from,h.to);r.setSelection(f)}}return!0},L4t=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 uK(t){return t instanceof ht}function xx(t=0,e=0,r=0){return Math.min(Math.max(t,e),r)}function eAe(t,e=null){if(!e)return null;const r=Mt.atStart(t),n=Mt.atEnd(t);if(e==="start"||e===!0)return r;if(e==="end")return n;const s=r.from,i=n.to;return e==="all"?ht.create(t,xx(0,s,i),xx(t.content.size,s,i)):ht.create(t,xx(e,s,i),xx(e,s,i))}function g7(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Mk(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function $4t(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var F4t=(t=null,e={})=>({editor:r,view:n,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const a=()=>{(Mk()||g7())&&n.dom.focus(),$4t()&&!Mk()&&!g7()&&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&&!uK(r.state.selection))return a(),!0;const l=eAe(s.doc,t)||r.state.selection,c=r.state.selection.eq(l);return i&&(c||s.setSelection(l),c&&s.storedMarks&&s.setStoredMarks(s.storedMarks),a()),!0},B4t=(t,e)=>r=>t.every((n,s)=>e(n,{...r,index:s})),z4t=(t,e)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,e),tAe=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&&tAe(n)}return t};function r2(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 tAe(r)}function Dk(t,e,r){if(t instanceof Rm||t instanceof Me)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 Me.fromArray(t.map(l=>e.nodeFromJSON(l)));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),Dk("",e,r)}if(s){if(r.errorOnInvalidContent){let a=!1,l="";const c=new WG({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,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(r.slice?Om.fromSchema(c).parseSlice(r2(t),r.parseOptions):Om.fromSchema(c).parse(r2(t),r.parseOptions),r.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Om.fromSchema(e);return r.slice?i.parseSlice(r2(t),r.parseOptions).content:i.parse(r2(t),r.parseOptions)}return Dk("",e,r)}function U4t(t,e,r){const n=t.steps.length-1;if(n<e)return;const s=t.steps[n];if(!(s instanceof ks||s instanceof oi))return;const i=t.mapping.maps[n];let a=0;i.forEach((l,c,u,d)=>{a===0&&(a=d)}),t.setSelection(Mt.near(t.doc.resolve(a),r))}var H4t=t=>!("type"in t),W4t=(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 l;const c=y=>{i.emit("contentError",{editor:i,error:y,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{Dk(e,i.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{l=Dk(e,i.schema,{parseOptions:u,errorOnInvalidContent:(a=r.errorOnInvalidContent)!=null?a:i.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,p=!0;if((H4t(l)?l:[l]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,p=p?y.isBlock:!1}),d===h&&p){const{parent:y}=n.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,h+=1)}let g;if(f){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof Me){let y="";e.forEach(x=>{x.text&&(y+=x.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;n.insertText(g,d,h)}else{g=l;const y=n.doc.resolve(d),x=y.node(),v=y.parentOffset===0,b=x.isText||x.isTextblock,w=x.content.size>0;v&&b&&w&&p&&(d=Math.max(0,d-1)),n.replaceWith(d,h,g)}r.updateSelection&&U4t(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},V4t=()=>({state:t,dispatch:e})=>ZCe(t,e),q4t=()=>({state:t,dispatch:e})=>JCe(t,e),G4t=()=>({state:t,dispatch:e})=>WCe(t,e),K4t=()=>({state:t,dispatch:e})=>XCe(t,e),Y4t=()=>({state:t,dispatch:e,tr:r})=>{try{const n=Mj(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),e&&e(r),!0)}catch{return!1}},X4t=()=>({state:t,dispatch:e,tr:r})=>{try{const n=Mj(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),e&&e(r),!0)}catch{return!1}},Q4t=()=>({state:t,dispatch:e})=>VCe(t,e),Z4t=()=>({state:t,dispatch:e})=>qCe(t,e);function rAe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function J4t(t){const e=t.split(/-(?!$)/);let r=e[e.length-1];r==="Space"&&(r=" ");let n,s,i,a;for(let l=0;l<e.length-1;l+=1){const c=e[l];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))Mk()||rAe()?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 e3t=t=>({editor:e,view:r,tr:n,dispatch:s})=>{const i=J4t(t).split(/-(?!$)/),a=i.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=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,l))});return c==null||c.steps.forEach(u=>{const d=u.map(n.mapping);d&&s&&n.maybeStep(d)}),!0};function Lk(t,e,r={}){const{from:n,to:s,empty:i}=t.selection,a=e?Li(e,t.schema):null,l=[];t.doc.nodesBetween(n,s,(h,f)=>{if(h.isText)return;const p=Math.max(n,f),m=Math.min(s,f+h.nodeSize);l.push({node:h,from:p,to:m})});const c=s-n,u=l.filter(h=>a?a.name===h.node.type.name:!0).filter(h=>wO(h.node.attrs,r,{strict:!1}));return i?!!u.length:u.reduce((h,f)=>h+f.to-f.from,0)>=c}var t3t=(t,e={})=>({state:r,dispatch:n})=>{const s=Li(t,r.schema);return Lk(r,s,e)?eEe(r,n):!1},r3t=()=>({state:t,dispatch:e})=>iEe(t,e),n3t=t=>({state:e,dispatch:r})=>{const n=Li(t,e.schema);return fEe(n)(e,r)},s3t=()=>({state:t,dispatch:e})=>tEe(t,e);function g5(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function nle(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 i3t=(t,e)=>({tr:r,state:n,dispatch:s})=>{let i=null,a=null;const l=g5(typeof t=="string"?t:t.name,n.schema);if(!l)return!1;l==="node"&&(i=Li(t,n.schema)),l==="mark"&&(a=Df(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,nle(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(nle(f.attrs,e))))})})}),c},a3t=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),o3t=()=>({tr:t,dispatch:e})=>{if(e){const r=new ul(t.doc);t.setSelection(r)}return!0},l3t=()=>({state:t,dispatch:e})=>KCe(t,e),c3t=()=>({state:t,dispatch:e})=>QCe(t,e),u3t=()=>({state:t,dispatch:e})=>aEe(t,e),d3t=()=>({state:t,dispatch:e})=>uEe(t,e),h3t=()=>({state:t,dispatch:e})=>cEe(t,e);function x7(t,e,r={},n={}){return Dk(t,e,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}var f3t=(t,{errorOnInvalidContent:e,emitUpdate:r=!0,parseOptions:n={}}={})=>({editor:s,tr:i,dispatch:a,commands:l})=>{const{doc:c}=i;if(n.preserveWhitespace!=="full"){const u=x7(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),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:n,errorOnInvalidContent:e??s.options.enableContentCheck})};function nAe(t,e){const r=Df(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 l=a.find(c=>c.type.name===r.name);return l?{...l.attrs}:{}}function sAe(t,e){const r=new c5(t);return e.forEach(n=>{n.steps.forEach(s=>{r.step(s)})}),r}function p3t(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 m3t(t,e,r){const n=[];return t.nodesBetween(e.from,e.to,(s,i)=>{r(s)&&n.push({node:s,pos:i})}),n}function iAe(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 dK(t){return e=>iAe(e.$from,t)}function Tt(t,e,r){return t.config[e]===void 0&&t.parent?Tt(t.parent,e,r):typeof t.config[e]=="function"?t.config[e].bind({...r,parent:t.parent?Tt(t.parent,e,r):null}):t.config[e]}function hK(t){return t.map(e=>{const r={name:e.name,options:e.options,storage:e.storage},n=Tt(e,"addExtensions",r);return n?[e,...hK(n())]:e}).flat(10)}function fK(t,e){const r=Uv.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(r),s.innerHTML}function aAe(t){return typeof t=="function"}function yn(t,e=void 0,...r){return aAe(t)?e?t.bind(e)(...r):t(...r):t}function g3t(t={}){return Object.keys(t).length===0&&t.constructor===Object}function q1(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 oAe(t){const e=[],{nodeExtensions:r,markExtensions:n}=q1(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),l=n.map(u=>u.name),c=[...a,...l];return t.forEach(u=>{const d={name:u.name,options:u.options,storage:u.storage,extensions:s},h=Tt(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=l:m=[],m.forEach(g=>{Object.entries(p.attributes).forEach(([y,x])=>{e.push({type:g,name:y,attribute:{...i,...x}})})})})}),s.forEach(u=>{const d={name:u.name,options:u.options,storage:u.storage},h=Tt(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 x3t(t){const e=[];let r="",n=!1,s=!1,i=0;const a=t.length;for(let l=0;l<a;l+=1){const c=t[l];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 sle(t){const e=[],r=x3t(t||""),n=r.length;for(let s=0;s<n;s+=1){const i=r[s],a=i.indexOf(":");if(a===-1)continue;const l=i.slice(0,a).trim(),c=i.slice(a+1).trim();l&&c&&e.push([l,c])}return e}function su(...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 l=i?String(i).split(" "):[],c=n[s]?n[s].split(" "):[],u=l.filter(d=>!c.includes(d));n[s]=[...c,...u].join(" ")}else if(s==="style"){const l=new Map([...sle(n[s]),...sle(i)]);n[s]=Array.from(l.entries()).map(([c,u])=>`${c}: ${u}`).join("; ")}else n[s]=i}),n},{})}function $k(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)=>su(r,n),{})}function y3t(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function ile(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 l=a.attribute.parseHTML?a.attribute.parseHTML(r):y3t(r.getAttribute(a.name));return l==null?i:{...i,[a.name]:l}},{});return{...n,...s}}}}function ale(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>e==="attrs"&&g3t(r)?!1:r!=null))}function ole(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 v3t(t,e){var r;const n=oAe(t),{nodeExtensions:s,markExtensions:i}=q1(t),a=(r=s.find(u=>Tt(u,"topNode")))==null?void 0:r.name,l=Object.fromEntries(s.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,v)=>{const b=Tt(v,"extendNodeSchema",h);return{...x,...b?b(u):{}}},{}),p=ale({...f,content:yn(Tt(u,"content",h)),marks:yn(Tt(u,"marks",h)),group:yn(Tt(u,"group",h)),inline:yn(Tt(u,"inline",h)),atom:yn(Tt(u,"atom",h)),selectable:yn(Tt(u,"selectable",h)),draggable:yn(Tt(u,"draggable",h)),code:yn(Tt(u,"code",h)),whitespace:yn(Tt(u,"whitespace",h)),linebreakReplacement:yn(Tt(u,"linebreakReplacement",h)),defining:yn(Tt(u,"defining",h)),isolating:yn(Tt(u,"isolating",h)),attrs:Object.fromEntries(d.map(ole))}),m=yn(Tt(u,"parseHTML",h));m&&(p.parseDOM=m.map(x=>ile(x,d)));const g=Tt(u,"renderHTML",h);g&&(p.toDOM=x=>g({node:x,HTMLAttributes:$k(x,d)}));const y=Tt(u,"renderText",h);return y&&(p.toText=y),[u.name,p]})),c=Object.fromEntries(i.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,x)=>{const v=Tt(x,"extendMarkSchema",h);return{...y,...v?v(u):{}}},{}),p=ale({...f,inclusive:yn(Tt(u,"inclusive",h)),excludes:yn(Tt(u,"excludes",h)),group:yn(Tt(u,"group",h)),spanning:yn(Tt(u,"spanning",h)),code:yn(Tt(u,"code",h)),attrs:Object.fromEntries(d.map(ole))}),m=yn(Tt(u,"parseHTML",h));m&&(p.parseDOM=m.map(y=>ile(y,d)));const g=Tt(u,"renderHTML",h);return g&&(p.toDOM=y=>g({mark:y,HTMLAttributes:$k(y,d)})),[u.name,p]}));return new WG({topNode:a,nodes:l,marks:c})}function b3t(t){const e=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(e))}function Q_(t){return t.sort((r,n)=>{const s=Tt(r,"priority")||100,i=Tt(n,"priority")||100;return s>i?-1:s<i?1:0})}function lAe(t){const e=Q_(hK(t)),r=b3t(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 cAe(t,e,r){const{from:n,to:s}=e,{blockSeparator:i=`

`,textSerializers:a={}}=r||{};let l="";return t.nodesBetween(n,s,(c,u,d,h)=>{var f;c.isBlock&&u>n&&(l+=i);const p=a==null?void 0:a[c.type.name];if(p)return d&&(l+=p({node:c,pos:u,parent:d,index:h,range:e})),!1;c.isText&&(l+=(f=c==null?void 0:c.text)==null?void 0:f.slice(Math.max(n,u)-u,s-u))}),l}function w3t(t,e){const r={from:0,to:t.content.size};return cAe(t,r,e)}function uAe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,r])=>[e,r.spec.toText]))}function j3t(t,e){const r=Li(e,t.schema),{from:n,to:s}=t.selection,i=[];t.doc.nodesBetween(n,s,l=>{i.push(l)});const a=i.reverse().find(l=>l.type.name===r.name);return a?{...a.attrs}:{}}function dAe(t,e){const r=g5(typeof e=="string"?e:e.name,t.schema);return r==="node"?j3t(t,e):r==="mark"?nAe(t,e):{}}function S3t(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 _3t(t){const e=S3t(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 hAe(t){const{mapping:e,steps:r}=t,n=[];return e.maps.forEach((s,i)=>{const a=[];if(s.ranges.length)s.forEach((l,c)=>{a.push({from:l,to:c})});else{const{from:l,to:c}=r[i];if(l===void 0||c===void 0)return;a.push({from:l,to:c})}a.forEach(({from:l,to:c})=>{const u=e.slice(i).map(l,-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}})})}),_3t(n)}function fAe(t,e,r){const n=[];return t===e?r.resolve(t).marks().forEach(s=>{const i=r.resolve(t),a=cK(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}function NS(t,e){return e.nodes[t]||e.marks[t]||null}function zP(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 N3t=(t,e=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-e),n,(s,i,a,l)=>{var c,u;const d=((u=(c=s.type.spec).toText)==null?void 0:u.call(c,{node:s,pos:i,parent:a,index:l}))||s.textContent||"%leaf%";r+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,n-i))}),r};function y7(t,e,r={}){const{empty:n,ranges:s}=t.selection,i=e?Df(e,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>i?i.name===h.type.name:!0).find(h=>wO(h.attrs,r,{strict:!1}));let a=0;const l=[];if(s.forEach(({$from:h,$to:f})=>{const p=h.pos,m=f.pos;t.doc.nodesBetween(p,m,(g,y)=>{if(i&&g.inlineContent&&!g.type.allowsMarkType(i))return!1;if(!g.isText&&!g.marks.length)return;const x=Math.max(p,y),v=Math.min(m,y+g.nodeSize),b=v-x;a+=b,l.push(...g.marks.map(w=>({mark:w,from:x,to:v})))})}),a===0)return!1;const c=l.filter(h=>i?i.name===h.mark.type.name:!0).filter(h=>wO(h.mark.attrs,r,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),u=l.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 k3t(t,e,r={}){if(!e)return Lk(t,null,r)||y7(t,null,r);const n=g5(e,t.schema);return n==="node"?Lk(t,e,r):n==="mark"?y7(t,e,r):!1}function lle(t,e){return Array.isArray(e)?e.some(r=>(typeof r=="string"?r:r.name)===t.name):e}function t6(t,e){const{nodeExtensions:r}=q1(e),n=r.find(a=>a.name===t);if(!n)return!1;const s={name:n.name,options:n.options,storage:n.storage},i=yn(Tt(n,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function pK(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&&(pK(i,{ignoreWhitespace:r,checkChildren:e})||(s=!1))}),s}return!1}function C3t({selection:t,pos:e,nodeSize:r,selectedOnTextSelection:n=!1}){const{from:s,to:i}=t;return!!(s<=e&&i>=e+r||n&&uK(t)&&s>e&&i<e+r)}var pAe=class mAe{constructor(e){this.position=e}static fromJSON(e){return new mAe(e.position)}toJSON(){return{position:this.position}}};function E3t(t,e){const r=e.mapping.mapResult(t.position);return{position:new pAe(r.pos),mapResult:r}}function A3t(t){return new pAe(t)}function T3t(t,e,r){var n;const{selection:s}=e;let i=null;if(uK(s)&&(i=s.$cursor),i){const l=(n=t.storedMarks)!=null?n:i.marks();return i.parent.type.allowsMarkType(r)&&(!!r.isInSet(l)||!l.some(u=>u.type.excludes(r)))}const{ranges:a}=s;return a.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(l.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 P3t=(t,e={})=>({tr:r,state:n,dispatch:s})=>{const{selection:i}=r,{empty:a,ranges:l}=i,c=Df(t,n.schema);if(s)if(a){const u=nAe(n,c);r.addStoredMark(c.create({...u,...e}))}else l.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(x=>x.type===c)?f.marks.forEach(x=>{c===x.type&&r.addMark(m,g,c.create({...x.attrs,...e}))}):r.addMark(m,g,c.create(e))})});return T3t(n,r,c)},I3t=(t,e)=>({tr:r})=>(r.setMeta(t,e),!0),R3t=(t,e={})=>({state:r,dispatch:n,chain:s})=>{const i=Li(t,r.schema);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>mO(i,{...a,...e})(r)?!0:l.clearNodes()).command(({state:l})=>mO(i,{...a,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},O3t=t=>({tr:e,dispatch:r})=>{if(r){const{doc:n}=e,s=xx(t,0,n.content.size),i=Pt.create(n,s);e.setSelection(i)}return!0},M3t=(t,e)=>({tr:r,state:n,dispatch:s})=>{const{selection:i}=n;let a,l;return typeof e=="number"?(a=e,l=e):e&&"from"in e&&"to"in e?(a=e.from,l=e.to):(a=i.from,l=i.to),s&&r.doc.nodesBetween(a,l,(c,u)=>{c.isText||r.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},D3t=t=>({tr:e,dispatch:r})=>{if(r){const{doc:n}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,a=ht.atStart(n).from,l=ht.atEnd(n).to,c=xx(s,a,l),u=xx(i,a,l),d=ht.create(n,c,u);e.setSelection(d)}return!0},L3t=t=>({state:e,dispatch:r})=>{const n=Li(t,e.schema);return pEe(n)(e,r)};function cle(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 $3t=({keepMarks:t=!0}={})=>({tr:e,state:r,dispatch:n,editor:s})=>{const{selection:i,doc:a}=e,{$from:l,$to:c}=i,u=s.extensionManager.attributes,d=zP(u,l.node().type.name,l.node().attrs);if(i instanceof Pt&&i.node.isBlock)return!l.parentOffset||!ud(a,l.pos)?!1:(n&&(t&&cle(r,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,f=l.depth===0?void 0:p3t(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=h&&f?[{type:f,attrs:d}]:void 0,m=ud(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!m&&ud(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:d}]:void 0),n){if(m&&(i instanceof ht&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),f&&!h&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&cle(r,s.extensionManager.splittableMarks),e.scrollIntoView()}return m},F3t=(t,e={})=>({tr:r,state:n,dispatch:s,editor:i})=>{var a;const l=Li(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!==l)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!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let x=Me.empty;const v=c.index(-1)?1:c.index(-2)?2:3;for(let A=c.depth-v;A>=c.depth-3;A-=1)x=Me.from(c.node(A).copy(x));const b=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,w={...zP(f,c.node().type.name,c.node().attrs),...e},j=((a=l.contentMatch.defaultType)==null?void 0:a.createAndFill(w))||void 0;x=x.append(Me.from(l.createAndFill(null,j)||void 0));const N=c.before(c.depth-(v-1));r.replace(N,c.after(-b),new at(x,4-v,0));let C=-1;r.doc.nodesBetween(N,r.doc.content.size,(A,E)=>{if(C>-1)return!1;A.isTextblock&&A.content.size===0&&(C=E+1)}),C>-1&&r.setSelection(ht.near(r.doc.resolve(C))),r.scrollIntoView()}return!0}const p=u.pos===c.end()?h.contentMatchAt(0).defaultType:null,m={...zP(f,h.type.name,h.attrs),...e},g={...zP(f,c.node().type.name,c.node().attrs),...e};r.delete(c.pos,u.pos);const y=p?[{type:l,attrs:m},{type:p,attrs:g}]:[{type:l,attrs:m}];if(!ud(r.doc,c.pos,2))return!1;if(s){const{selection:x,storedMarks:v}=n,{splittableMarks:b}=i.extensionManager,w=v||x.$to.parentOffset&&x.$from.marks();if(r.split(c.pos,2,y).scrollIntoView(),!w||!s)return!0;const j=w.filter(N=>b.includes(N.type.name));r.ensureMarks(j)}return!0},r6=(t,e)=>{const r=dK(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)&&Ed(t.doc,r.pos)&&t.join(r.pos),!0},n6=(t,e)=>{const r=dK(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)&&Ed(t.doc,n)&&t.join(n),!0};function B3t(t){const e=t.doc,r=e.firstChild;if(!r)return null;const n=e.resolve(1),s=e.resolve(r.nodeSize-1);return ht.between(n,s)}var z3t=(t,e,r,n={})=>({editor:s,tr:i,state:a,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:h,splittableMarks:f}=s.extensionManager,p=Li(t,a.schema),m=Li(e,a.schema),{selection:g,storedMarks:y}=a,{$from:x,$to:v}=g,b=x.blockRange(v),w=y||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;const j=dK(M=>t6(M.type.name,h))(g),N=g.from===0&&g.to===a.doc.content.size,C=a.doc.content.content,A=C.length===1?C[0]:null,E=N&&A&&t6(A.type.name,h)?{node:A,pos:0,depth:0}:null,O=j??E,$=!!j&&b.depth>=1&&b.depth-j.depth<=1,T=!!E;if(($||T)&&O){if(O.node.type===p)return N&&T?c().command(({tr:M,dispatch:k})=>{const D=B3t(M);return D?(M.setSelection(D),k&&k(M),!0):!1}).liftListItem(m).run():u.liftListItem(m);if(t6(O.node.type.name,h)&&p.validContent(O.node.content))return c().command(()=>(i.setNodeMarkup(O.pos,p),!0)).command(()=>r6(i,p)).command(()=>n6(i,p)).run()}return!r||!w||!l?c().command(()=>d().wrapInList(p,n)?!0:u.clearNodes()).wrapInList(p,n).command(()=>r6(i,p)).command(()=>n6(i,p)).run():c().command(()=>{const M=d().wrapInList(p,n),k=w.filter(D=>f.includes(D.type.name));return i.ensureMarks(k),M?!0:u.clearNodes()}).wrapInList(p,n).command(()=>r6(i,p)).command(()=>n6(i,p)).run()},U3t=(t,e={},r={})=>({state:n,commands:s})=>{const{extendEmptyMarkRange:i=!1}=r,a=Df(t,n.schema);return y7(n,a,e)?s.unsetMark(a,{extendEmptyMarkRange:i}):s.setMark(a,e)},H3t=(t,e,r={})=>({state:n,commands:s})=>{const i=Li(t,n.schema),a=Li(e,n.schema),l=Lk(n,i,r);let c;return n.selection.$anchor.sameParent(n.selection.$head)&&(c=n.selection.$anchor.parent.attrs),l?s.setNode(a,c):s.setNode(i,{...c,...r})},W3t=(t,e={})=>({state:r,commands:n})=>{const s=Li(t,r.schema);return Lk(r,s,e)?n.lift(s):n.wrapIn(s,e)},V3t=()=>({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,l=i.transform;for(let c=l.steps.length-1;c>=0;c-=1)a.step(l.steps[c].invert(l.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},q3t=(t={})=>({tr:e,dispatch:r,editor:n})=>{const{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:a,ranges:l}=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));l.forEach(d=>{for(const h of u)e.removeMark(d.$from.pos,d.$to.pos,h)})}return!0},G3t=(t,e={})=>({tr:r,state:n,dispatch:s})=>{var i;const{extendEmptyMarkRange:a=!1}=e,{selection:l}=r,c=Df(t,n.schema),{$from:u,empty:d,ranges:h}=l;if(!s)return!0;if(d&&a){let{from:f,to:p}=l;const m=(i=u.marks().find(y=>y.type===c))==null?void 0:i.attrs,g=cK(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},K3t=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,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},Y3t=(t,e={})=>({tr:r,state:n,dispatch:s})=>{let i=null,a=null;const l=g5(typeof t=="string"?t:t.name,n.schema);if(!l)return!1;l==="node"&&(i=Li(t,n.schema)),l==="mark"&&(a=Df(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,(y,x)=>{i&&i===y.type&&(c=!0,m=Math.max(x,d),g=Math.min(x+y.nodeSize,h),f=x,p=y)}):n.doc.nodesBetween(d,h,(y,x)=>{x<d&&i&&i===y.type&&(c=!0,m=Math.max(x,d),g=Math.min(x+y.nodeSize,h),f=x,p=y),x>=d&&x<=h&&(i&&i===y.type&&(c=!0,s&&r.setNodeMarkup(x,void 0,{...y.attrs,...e})),a&&y.marks.length&&y.marks.forEach(v=>{if(a===v.type&&(c=!0,s)){const b=Math.max(x,d),w=Math.min(x+y.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(y=>{a===y.type&&s&&r.addMark(m,g,a.create({...y.attrs,...e}))}))}),c},X3t=(t,e={})=>({state:r,dispatch:n})=>{const s=Li(t,r.schema);return dEe(s,e)(r,n)},Q3t=(t,e={})=>({state:r,dispatch:n})=>{const s=Li(t,r.schema);return hEe(s,e)(r,n)},Z3t=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={}}},J3t=class{constructor(e){var r;this.find=e.find,this.handler=e.handler,this.undoable=(r=e.undoable)!=null?r:!0}},e$t=(t,e)=>{if(lK(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 n2(t){var e;const{editor:r,from:n,to:s,text:i,rules:a,plugin:l}=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=N3t(u)+i;return a.forEach(f=>{if(d)return;const p=e$t(h,f.find);if(!p)return;const m=c.state.tr,g=p5({state:c.state,transaction:m}),y={from:n-(p[0].length-i.length),to:s},{commands:x,chain:v,can:b}=new m5({editor:r,state:g});f.handler({state:g,range:y,match:p,commands:x,chain:v,can:b})===null||!m.steps.length||(f.undoable&&m.setMeta(l,{transform:m,from:n,to:s,text:i}),c.dispatch(m),d=!0)}),d}function t$t(t){const{editor:e,rules:r}=t,n=new Ar({state:{init(){return null},apply(s,i,a){const l=s.getMeta(n);if(l)return l;const c=s.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:d}=c;typeof d=="string"?d=d:d=fK(Me.from(d),a.schema);const{from:h}=c,f=h+d.length;n2({editor:e,from:h,to:f,text:d,rules:r,plugin:n})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,a,l){return n2({editor:e,from:i,to:a,text:l,rules:r,plugin:n})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&n2({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?n2({editor:e,from:a.pos,to:a.pos,text:`
`,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function r$t(t){return Object.prototype.toString.call(t).slice(8,-1)}function s2(t){return r$t(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function gAe(t,e){const r={...t};return s2(t)&&s2(e)&&Object.keys(e).forEach(n=>{s2(e[n])&&s2(t[n])?r[n]=gAe(t[n],e[n]):r[n]=e[n]}),r}var mK=class{constructor(e={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...yn(Tt(this,"addOptions",{name:this.name}))}}get storage(){return{...yn(Tt(this,"addStorage",{name:this.name,options:this.options}))}}configure(e={}){const r=this.extend({...this.config,addOptions:()=>gAe(this.options,e)});return r.name=this.name,r.parent=this.parent,this.child=null,r}extend(e={}){const r=new this.constructor({...this.config,...e});return r.parent=this,this.child=r,r.name="name"in e?e.name:r.parent.name,r}},gK=class xAe extends mK{constructor(){super(...arguments),this.type="mark"}static create(e={}){const r=typeof e=="function"?e():e;return new xAe(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)}};function n$t(t){return typeof t=="number"}var s$t=class{constructor(e){this.find=e.find,this.handler=e.handler}},i$t=(t,e,r)=>{if(lK(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 a$t(t){const{editor:e,state:r,from:n,to:s,rule:i,pasteEvent:a,dropEvent:l}=t,{commands:c,chain:u,can:d}=new m5({editor:e,state:r}),h=[];return r.doc.nodesBetween(n,s,(p,m)=>{var g,y,x,v,b;if((y=(g=p.type)==null?void 0:g.spec)!=null&&y.code||!(p.isText||p.isTextblock||p.isInline))return;const w=(b=(v=(x=p.content)==null?void 0:x.size)!=null?v:p.nodeSize)!=null?b:0,j=Math.max(n,m),N=Math.min(s,m+w);if(j>=N)return;const C=p.isText?p.text||"":p.textBetween(j-m,N-m,void 0,"");i$t(C,i.find,a).forEach(E=>{if(E.index===void 0)return;const O=j+E.index+1,$=O+E[0].length,T={from:r.tr.mapping.map(O),to:r.tr.mapping.map($)},M=i.handler({state:r,range:T,match:E,commands:c,chain:u,can:d,pasteEvent:a,dropEvent:l});h.push(M)})}),h.every(p=>p!==null)}var i2=null,o$t=t=>{var e;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=r.clipboardData)==null||e.setData("text/html",t),r};function l$t(t){const{editor:e,rules:r}=t;let n=null,s=!1,i=!1,a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:h,to:f,rule:p,pasteEvt:m})=>{const g=d.tr,y=p5({state:d,transaction:g});if(!(!a$t({editor:e,state:y,from:Math.max(h-1,0),to:f.b-1,rule:p,pasteEvent:m,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return r.map(d=>new Ar({view(h){const f=m=>{var g;n=(g=h.dom.parentElement)!=null&&g.contains(m.target)?h.dom.parentElement:null,n&&(i2=e)},p=()=>{i2&&(i2=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,l=f,!i){const p=i2;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,y=m.getMeta("uiEvent")==="drop"&&!i,x=m.getMeta("applyPasteRules"),v=!!x;if(!g&&!y&&!v)return;if(v){let{text:j}=x;typeof j=="string"?j=j:j=fK(Me.from(j),p.schema);const{from:N}=x,C=N+j.length,A=o$t(j);return c({rule:d,state:p,from:N,to:{b:C},pasteEvt:A})}const b=f.doc.content.findDiffStart(p.doc.content),w=f.doc.content.findDiffEnd(p.doc.content);if(!(!n$t(b)||!w||b===w.b))return c({rule:d,state:p,from:b,to:w,pasteEvt:a})}}))}var x5=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=lAe(t),this.schema=v3t(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:NS(e.name,this.schema)},n=Tt(e,"addCommands",r);return n?{...t,...n()}:t},{})}get plugins(){const{editor:t}=this;return Q_([...this.extensions].reverse()).flatMap(n=>{const s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:NS(n.name,this.schema)},i=[],a=Tt(n,"addKeyboardShortcuts",s);let l={};if(n.type==="mark"&&Tt(n,"exitable",s)&&(l.ArrowRight=()=>gK.handleExit({editor:t,mark:n})),a){const f=Object.fromEntries(Object.entries(a()).map(([p,m])=>[p,()=>m({editor:t})]));l={...l,...f}}const c=b4t(l);i.push(c);const u=Tt(n,"addInputRules",s);if(lle(n,t.options.enableInputRules)&&u){const f=u();if(f&&f.length){const p=t$t({editor:t,rules:f}),m=Array.isArray(p)?p:[p];i.push(...m)}}const d=Tt(n,"addPasteRules",s);if(lle(n,t.options.enablePasteRules)&&d){const f=d();if(f&&f.length){const p=l$t({editor:t,rules:f});i.push(...p)}}const h=Tt(n,"addProseMirrorPlugins",s);if(h){const f=h();i.push(...f)}return i})}get attributes(){return oAe(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=q1(this.extensions);return Object.fromEntries(e.filter(r=>!!Tt(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:Li(r.name,this.schema)},i=Tt(r,"addNodeView",s);if(!i)return[];const a=i();if(!a)return[];const l=(c,u,d,h,f)=>{const p=$k(c,n);return a({node:c,view:u,getPos:d,decorations:h,innerDecorations:f,editor:t,extension:r,HTMLAttributes:p})};return[r.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return Q_([...this.extensions].reverse()).reduceRight((n,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:NS(s.name,this.schema)},a=Tt(s,"dispatchTransaction",i);return a?l=>{a.call(i,{transaction:l,next:n})}:n},t)}transformPastedHTML(t){const{editor:e}=this;return Q_([...this.extensions]).reduce((n,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:NS(s.name,this.schema)},a=Tt(s,"transformPastedHTML",i);return a?(l,c)=>{const u=n(l,c);return a.call(i,u)}:n},t||(n=>n))}get markViews(){const{editor:t}=this,{markExtensions:e}=q1(this.extensions);return Object.fromEntries(e.filter(r=>!!Tt(r,"addMarkView")).map(r=>{const n=this.attributes.filter(l=>l.type===r.name),s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Df(r.name,this.schema)},i=Tt(r,"addMarkView",s);if(!i)return[];const a=(l,c,u)=>{const d=$k(l,n);return i()({mark:l,view:c,inline:u,editor:t,extension:r,HTMLAttributes:d,updateAttributes:h=>{N$t(l,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:NS(e.name,this.schema)};e.type==="mark"&&(((r=yn(Tt(e,"keepOnSplit",s)))==null||r)&&this.splittableMarks.push(e.name),(n=yn(Tt(e,"clearable",s)))==null||n||this.nonClearableMarks.push(e.name));const i=Tt(e,"onBeforeCreate",s),a=Tt(e,"onCreate",s),l=Tt(e,"onUpdate",s),c=Tt(e,"onSelectionUpdate",s),u=Tt(e,"onTransaction",s),d=Tt(e,"onFocus",s),h=Tt(e,"onBlur",s),f=Tt(e,"onDestroy",s);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),l&&this.editor.on("update",l),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)})}};x5.resolve=lAe;x5.sort=Q_;x5.flatten=hK;var c$t={};oK(c$t,{ClipboardTextSerializer:()=>vAe,Commands:()=>bAe,Delete:()=>wAe,Drop:()=>jAe,Editable:()=>SAe,FocusEvents:()=>NAe,Keymap:()=>kAe,Paste:()=>CAe,Tabindex:()=>EAe,TextDirection:()=>AAe,focusEventsPluginKey:()=>_Ae});var xl=class yAe extends mK{constructor(){super(...arguments),this.type="extension"}static create(e={}){const r=typeof e=="function"?e():e;return new yAe(r)}configure(e){return super.configure(e)}extend(e){const r=typeof e=="function"?e():e;return super.extend(r)}},vAe=xl.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ar({key:new Wr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:r}=t,{doc:n,selection:s}=e,i=uAe(r),{blockSeparator:a}=this.options,l={...a!==void 0?{blockSeparator:a}:{},textSerializers:i};return[...s.ranges].sort((u,d)=>u.$from.pos-d.$from.pos).map(({$from:u,$to:d})=>cAe(n,{from:u.pos,to:d.pos},l)).join(a??`

`)}}})]}}),bAe=xl.create({name:"commands",addCommands(){return{...ZEe}}}),wAe=xl.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var r,n,s;const i=()=>{var a,l,c,u;if((u=(c=(l=(a=this.editor.options.coreExtensionOptions)==null?void 0:a.delete)==null?void 0:l.filterTransaction)==null?void 0:c.call(l,t))!=null?u:t.getMeta("y-sync$"))return;const d=sAe(t.before,[t,...e]);hAe(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 y=g+m.nodeSize-2,x=p.oldRange.from<=g&&y<=p.oldRange.to;this.editor.emit("delete",{type:"node",node:m,from:g,to:y,newFrom:d.mapping.map(g),newTo:d.mapping.map(y),deletedRange:p.oldRange,newRange:p.newRange,partial:!x,editor:this.editor,transaction:t,combinedTransform:d})})});const f=d.mapping;d.steps.forEach((p,m)=>{var g,y;if(p instanceof Ql){const x=f.slice(m).map(p.from,-1),v=f.slice(m).map(p.to),b=f.invert().map(x,-1),w=f.invert().map(v),j=x>0?(g=d.doc.nodeAt(x-1))==null?void 0:g.marks.some(C=>C.eq(p.mark)):!1,N=(y=d.doc.nodeAt(v))==null?void 0:y.marks.some(C=>C.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:x,to:v},partial:!!(N||j),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()}}),jAe=xl.create({name:"drop",addProseMirrorPlugins(){return[new Ar({key:new Wr("tiptapDrop"),props:{handleDrop:(t,e,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:r,moved:n})}}})]}}),SAe=xl.create({name:"editable",addProseMirrorPlugins(){return[new Ar({key:new Wr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),_Ae=new Wr("focusEvents"),NAe=xl.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ar({key:_Ae,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}}}})]}}),kAe=xl.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:h}=c,{pos:f,parent:p}=h,m=h.parent.isTextblock&&f>0?l.doc.resolve(f-1):h,g=m.parent.type.spec.isolating,y=h.pos-h.parentOffset,x=g&&m.parent.childCount===1?y===h.pos:Mt.atStart(u).from===f;return!d||!p.type.isTextblock||p.textContent.length||!x||x&&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 Mk()||rAe()?i:s},addProseMirrorPlugins(){return[new Ar({key:new Wr("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:l}=e.selection,c=Mt.atStart(e.doc).from,u=Mt.atEnd(e.doc).to;if(i||!(a===c&&l===u)||!pK(r.doc))return;const f=r.tr,p=p5({state:r,transaction:f}),{commands:m}=new m5({editor:this.editor,state:p});if(m.clearNodes(),!!f.steps.length)return f}})]}}),CAe=xl.create({name:"paste",addProseMirrorPlugins(){return[new Ar({key:new Wr("tiptapPaste"),props:{handlePaste:(t,e,r)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:r})}}})]}}),EAe=xl.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new Ar({key:new Wr("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),AAe=xl.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=q1(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 Ar({key:new Wr("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),u$t=class x_{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 x_(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 x_(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 x_(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,l=this.pos+n+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(l);if(!s&&!a&&c.depth<=this.depth)return;const u=new x_(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 l=0;l<a.length;l+=1){const c=a[l];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)}},d$t=`.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;
}`;function h$t(t,e,r){const n=document.querySelector("style[data-tiptap-style]");if(n!==null)return n;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var f$t=class extends Z3t{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:E3t,createMappablePosition:A3t},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=eAe(e,this.options.autofocus);this.editorState=px.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=h$t(d$t,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=aAe(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?[SAe,vAe.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),bAe,NAe,kAe,EAe.configure({value:(n=(r=this.options.coreExtensionOptions)==null?void 0:r.tabindex)==null?void 0:n.value}),jAe,CAe,wAe,AAe.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 x5(i,this)}createCommandManager(){this.commandManager=new m5({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=x7(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=x7(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 QEe(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 l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),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")),l=a==null?void 0:a.getMeta("focus"),c=a==null?void 0:a.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.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 dAe(this.state,t)}isActive(t,e){const r=typeof t=="string"?t:null,n=typeof t=="string"?e:t;return k3t(this.state,r,n)}getJSON(){return this.state.doc.toJSON()}getHTML(){return fK(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`

`,textSerializers:r={}}=t||{};return w3t(this.state.doc,{blockSeparator:e,textSerializers:{...uAe(this.schema),...r}})}get isEmpty(){return pK(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 u$t(e,this,!1,r)}get $doc(){return this.$pos(0)}};function p$t(t){return new J3t({find:t.find,handler:({state:e,range:r,match:n})=>{const s=yn(t.getAttributes,void 0,n)||{},{tr:i}=e,a=r.from;let l=r.to;const c=t.type.create(s);if(n[1]){const u=n[0].lastIndexOf(n[1]);let d=a+u;d>l?d=l:l=d+n[1].length;const h=n[0][n[0].length-1];i.insertText(h,a+n[0].length-1),i.replaceWith(d,l,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(l))}i.scrollIntoView()},undoable:t.undoable})}var m$t=t=>"touches"in t,g$t=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const c=l.clientX-this.startX,u=l.clientY-this.startY;this.handleResize(c,u)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const c=l.touches[0];if(!c)return;const u=c.clientX-this.startX,d=c.clientY-this.startY;this.handleResize(u,d)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,c=this.element.offsetHeight;this.onCommit(l,c),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,r,n,s,i,a;this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(r=t.options)!=null&&r.max&&(this.maxSize=t.options.max),(n=t==null?void 0:t.options)!=null&&n.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(a=t.options)!=null&&a.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,r){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,r):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const r=e.includes("top"),n=e.includes("bottom"),s=e.includes("left"),i=e.includes("right");r&&(t.style.top="0"),n&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",r=>this.handleResizeStart(r,t)),e.addEventListener("touchstart",r=>this.handleResizeStart(r,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,m$t(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const r=this.preserveAspectRatio||this.isShiftKeyPressed,{width:n,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(n,s,r);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,r){let n=this.startWidth,s=this.startHeight;const i=t.includes("right"),a=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return i?n=this.startWidth+e:a&&(n=this.startWidth-e),l?s=this.startHeight+r:c&&(s=this.startHeight-r),(t==="right"||t==="left")&&(n=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(l?r:-r)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(n,s,t):{width:n,height:s}}applyConstraints(t,e,r){var n,s,i,a;if(!r){let u=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(n=this.maxSize)!=null&&n.width&&(u=Math.min(this.maxSize.width,u)),(s=this.maxSize)!=null&&s.height&&(d=Math.min(this.maxSize.height,d)),{width:u,height:d}}let l=t,c=e;return l<this.minSize.width&&(l=this.minSize.width,c=l/this.aspectRatio),c<this.minSize.height&&(c=this.minSize.height,l=c*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&l>this.maxSize.width&&(l=this.maxSize.width,c=l/this.aspectRatio),(a=this.maxSize)!=null&&a.height&&c>this.maxSize.height&&(c=this.maxSize.height,l=c*this.aspectRatio),{width:l,height:c}}applyAspectRatio(t,e,r){const n=r==="left"||r==="right",s=r==="top"||r==="bottom";return n?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}},x$t={};oK(x$t,{createAtomBlockMarkdownSpec:()=>y$t,createBlockMarkdownSpec:()=>v$t,createInlineMarkdownSpec:()=>j$t,parseAttributes:()=>xK,parseIndentedBlocks:()=>S$t,renderNestedMarkdownContent:()=>_$t,serializeAttributes:()=>yK});function xK(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)\.([a-zA-Z][\w-]*)/g);if(s){const u=s.map(d=>d.trim().slice(1));e.class=u.join(" ")}const i=n.match(/(?:^|\s)#([a-zA-Z][\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)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\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 yK(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 y$t(t){const{nodeName:e,name:r,parseAttributes:n=xK,serializeAttributes:s=yK,defaultAttributes:i={},requiredAttributes:a=[],allowedAttributes:l}=t,c=r||e,u=d=>{if(!l)return d;const h={};return l.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]||"",y=n(g);if(!a.find(v=>!(v in y)))return{type:e,raw:m[0],attributes:y}}},renderMarkdown:d=>{const h=u(d.attrs||{}),f=s(h),p=f?` {${f}}`:"";return`:::${c}${p} :::`}}}function v$t(t){const{nodeName:e,name:r,getContent:n,parseAttributes:s=xK,serializeAttributes:i=yK,defaultAttributes:a={},content:l="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 l==="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`),y=h.match(g);if(!y)return;const[x,v=""]=y,b=s(v);let w=1;const j=x.length;let N="";const C=/^:::([\w-]*)(\s.*)?/gm,A=h.slice(j);for(C.lastIndex=0;;){const E=C.exec(A);if(E===null)break;const O=E.index,$=E[1];if(!((m=E[2])!=null&&m.endsWith(":::"))){if($)w+=1;else if(w-=1,w===0){const T=A.slice(0,O);N=T.trim();const M=h.slice(0,j+O+E[0].length);let k=[];if(N)if(l==="block")for(k=p.blockTokens(T),k.forEach(D=>{D.text&&(!D.tokens||D.tokens.length===0)&&(D.tokens=p.inlineTokens(D.text))});k.length>0;){const D=k[k.length-1];if(D.type==="paragraph"&&(!D.text||D.text.trim()===""))k.pop();else break}else k=p.inlineTokens(N);return{type:e,raw:M,attributes:b,content:N,tokens:k}}}}}},renderMarkdown:(h,f)=>{const p=d(h.attrs||{}),m=i(p),g=m?` {${m}}`:"",y=f.renderChildren(h.content||[],`

`);return`:::${u}${g}

${y}

:::`}}}function b$t(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 w$t(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,r])=>`${e}="${r}"`).join(" ")}function j$t(t){const{nodeName:e,name:r,getContent:n,parseAttributes:s=b$t,serializeAttributes:i=w$t,defaultAttributes:a={},selfClosing:l=!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,y=typeof m=="string"?void 0:m.skipIfDefault;if(g in f){const x=f[g];if(y!==void 0&&x===y)return;p[g]=x}}),p},h=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,p)=>{const m={...a,...f.attributes};if(l)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=l?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=l?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),y=f.match(g);if(!y)return;let x="",v="";if(l){const[,w]=y;v=w}else{const[,w,j]=y;v=w,x=j||""}const b=s(v.trim());return{type:e,raw:y[0],content:x.trim(),attributes:b}}},renderMarkdown:f=>{let p="";n?p=n(f):f.content&&f.content.length>0&&(p=f.content.filter(x=>x.type==="text").map(x=>x.text).join(""));const m=d(f.attrs||{}),g=i(m),y=g?` ${g}`:"";return l?`[${u}${y}]`:`[${u}${y}]${p}[/${u}]`}}}function S$t(t,e,r){var n,s,i,a;const l=t.split(`
`),c=[];let u="",d=0;const h=e.baseIndentSize||2;for(;d<l.length;){const f=l[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:y}=m;u=`${u}${f}
`;const x=[y];for(d+=1;d<l.length;){const j=l[d];if(j.trim()===""){const C=l.slice(d+1).findIndex(O=>O.trim()!=="");if(C===-1)break;if((((s=(n=l[d+1+C].match(/^(\s*)/))==null?void 0:n[1])==null?void 0:s.length)||0)>g){x.push(j),u=`${u}${j}
`,d+=1;continue}else break}if((((a=(i=j.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:a.length)||0)>g)x.push(j),u=`${u}${j}
`,d+=1;else break}let v;const b=x.slice(1);if(b.length>0){const j=b.map(N=>N.slice(g+h)).join(`
`);j.trim()&&(e.customNestedParser?v=e.customNestedParser(j):v=r.blockTokens(j))}const w=e.createToken(m,v);c.push(w)}if(c.length!==0)return{items:c,raw:u}}function _$t(t,e,r,n){if(!t||!Array.isArray(t.content))return"";const s=typeof r=="function"?r(n):r,[i,...a]=t.content,l=e.renderChildren([i]);let c=`${s}${l}`;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 N$t(t,e,r={}){const{state:n}=e,{doc:s,tr:i}=n,a=t;s.descendants((l,c)=>{const u=i.mapping.map(c),d=i.mapping.map(c)+l.nodeSize;let h=null;if(l.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 kA=class TAe extends mK{constructor(){super(...arguments),this.type="node"}static create(e={}){const r=typeof e=="function"?e():e;return new TAe(r)}configure(e){return super.configure(e)}extend(e){const r=typeof e=="function"?e():e;return super.extend(r)}},k$t=class{constructor(t,e,r){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,r,n,s,i,a,l;const{view:c}=this.editor,u=t.target,d=u.nodeType===3?(e=u.parentElement)==null?void 0:e.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||(r=this.contentDOM)!=null&&r.contains(u)||!d)return;let h=0,f=0;if(this.dom!==d){const v=this.dom.getBoundingClientRect(),b=d.getBoundingClientRect(),w=(s=t.offsetX)!=null?s:(n=t.nativeEvent)==null?void 0:n.offsetX,j=(a=t.offsetY)!=null?a:(i=t.nativeEvent)==null?void 0:i.offsetY;h=b.x-v.x+w,f=b.y-v.y+j}const p=this.dom.cloneNode(!0);try{const v=this.dom.getBoundingClientRect();p.style.width=`${Math.round(v.width)}px`,p.style.height=`${Math.round(v.height)}px`,p.style.boxSizing="border-box",p.style.pointerEvents="none"}catch{}let m=null;try{m=document.createElement("div"),m.style.position="absolute",m.style.top="-9999px",m.style.left="-9999px",m.style.pointerEvents="none",m.appendChild(p),document.body.appendChild(m),(l=t.dataTransfer)==null||l.setDragImage(p,h,f)}finally{m&&setTimeout(()=>{try{m==null||m.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=Pt.create(c.state.doc,g),x=c.state.tr.setSelection(y);c.dispatch(x)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const r=t.target;if(!(this.dom.contains(r)&&!((e=this.contentDOM)!=null&&e.contains(r))))return!1;const s=t.type.startsWith("drag"),i=t.type==="dragover"||t.type==="dragenter",a=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!a&&!s)return!0;const{isEditable:c}=this.editor,{isDragging:u}=this,d=!!this.node.type.spec.draggable,h=Pt.isSelectable(this.node),f=t.type==="copy",p=t.type==="paste",m=t.type==="cut",g=t.type==="mousedown";if(!d&&h&&s&&t.target===this.dom&&t.preventDefault(),d&&s&&!u&&t.target===this.dom)return t.preventDefault(),!1;if(d&&c&&!u&&g){const y=r.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(u||i||a||f||p||m||g&&h)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Mk()||g7())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const r=this.getPos();return typeof r!="number"?!1:(e.setNodeMarkup(r,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function C$t(t){return new s$t({find:t.find,handler:({state:e,range:r,match:n,pasteEvent:s})=>{const i=yn(t.getAttributes,void 0,n,s);if(i===!1||i===null)return null;const{tr:a}=e,l=n[n.length-1],c=n[0];let u=r.to;if(l){const d=c.search(/\S/),h=r.from+c.indexOf(l),f=h+l.length;if(fAe(r.from,r.to,e.doc).filter(g=>g.mark.type.excluded.find(x=>x===t.type&&x!==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+l.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 PAe={exports:{}},IAe={};/**
 * @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 y5=S,E$t=vD;function A$t(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var T$t=typeof Object.is=="function"?Object.is:A$t,P$t=E$t.useSyncExternalStore,I$t=y5.useRef,R$t=y5.useEffect,O$t=y5.useMemo,M$t=y5.useDebugValue;IAe.useSyncExternalStoreWithSelector=function(t,e,r,n,s){var i=I$t(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=O$t(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,T$t(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 l=P$t(t,i[0],i[1]);return R$t(function(){a.hasValue=!0,a.value=l},[l]),M$t(l),l};PAe.exports=IAe;var D$t=PAe.exports,L$t=(...t)=>e=>{t.forEach(r=>{typeof r=="function"?r(e):r&&(r.current=e)})},$$t=({contentComponent:t})=>{const e=vD.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return o.jsx(o.Fragment,{children:Object.values(e)})};function F$t(){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]:RW.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 B$t=class extends ve.Component{constructor(t){super(t),this.editorContentRef=ve.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=F$t(),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 o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:L$t(e,this.editorContentRef),...r}),(t==null?void 0:t.contentComponent)&&o.jsx($$t,{contentComponent:t.contentComponent})]})}},z$t=S.forwardRef((t,e)=>{const r=ve.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ve.createElement(B$t,{key:r,innerRef:e,...t})}),RAe=ve.memo(z$t),U$t=typeof window<"u"?S.useLayoutEffect:S.useEffect,H$t=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 W$t(t){var e;const[r]=S.useState(()=>new H$t(t.editor)),n=D$t.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:fwe);return U$t(()=>r.watch(t.editor),[t.editor,r]),S.useDebugValue(n),n}var V$t=!1,OAe=typeof window>"u",q$t=OAe||!!(typeof window<"u"&&window.next),G$t=class MAe{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 OAe?(r&&V$t&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),r=!1):q$t&&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 f$t(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?MAe.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 K$t(t={},e=[]){const r=S.useRef(t);r.current=t;const[n]=S.useState(()=>new G$t(r)),s=vD.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return S.useDebugValue(s),S.useEffect(n.onRender(e)),W$t({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var DAe=S.createContext({editor:null});DAe.Consumer;var LAe=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),Y$t=()=>S.useContext(LAe),X$t=ve.forwardRef((t,e)=>{const{onDragStart:r}=Y$t(),n=t.as||"div";return o.jsx(n,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});function ule(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function dle(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function Q$t(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function Z$t(t){if(ule(t)||dle(t))return!0;if(Q$t(t)){const e=t.type;if(e)return ule(e)||dle(e)}return!1}function J$t(){try{if(S.version)return parseInt(S.version.split(".")[0],10)>=19}catch{}return!1}var eFt=class{constructor(t,{editor:e,props:r={},as:n="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=r,this.element=document.createElement(n),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isEditorContentInitialized?cc.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,r=this.props,n=this.editor,s=J$t(),i=Z$t(e),a={...r};a.ref&&!(s||i)&&delete a.ref,!a.ref&&(s||i)&&(a.ref=l=>{this.ref=l}),this.reactElement=o.jsx(e,{...a}),(t=n==null?void 0:n.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){if(this.destroyed)return;let e=!1;const r=Object.keys(t);for(let n=0;n<r.length;n+=1){const s=r[n];if(t[s]!==this.props[s]){e=!0;break}}e&&(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e==null?void 0:e.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};ve.createContext({markViewContentRef:()=>{}});var tFt=class extends k$t{constructor(t,e,r){if(super(t,e,r),this.selectionRafId=null,this.handlePositionUpdate=()=>{const n=this.getPos();typeof n!="number"||n===this.currentPos||(this.currentPos=n,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const n=this.dom.querySelector("[data-node-view-content]");if(!n)return;n.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(r,n,s){var i;return n==="storage"?(i=t.storage[e.name])!=null?i:{}:Reflect.get(r,n,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(u={})=>this.updateAttributes(u),deleteNode:()=>this.deleteNode(),ref:S.createRef()};if(!this.component.displayName){const u=d=>d.charAt(0).toUpperCase()+d.substring(1);this.component.displayName=u(this.extension.name)}const s={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:u=>{u&&this.contentDOMElement&&u.firstChild!==this.contentDOMElement&&(u.hasAttribute("data-node-view-wrapper")&&u.removeAttribute("data-node-view-wrapper"),u.appendChild(this.contentDOMElement))}},i=this.component,a=S.memo(u=>o.jsx(LAe.Provider,{value:s,children:S.createElement(i,u)}));a.displayName="ReactNodeView";let l=this.node.isInline?"span":"div";this.options.as&&(l=this.options.as);const{className:c=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new eFt(a,{editor:this.editor,props:e,as:l,className:`node-${this.node.type.name} ${c}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const t=this.currentPos;if(typeof t!="number")return;if(C3t({selection:this.editor.state.selection,pos:t,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,r){const n=l=>{this.renderer.updateProps(l),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const l=this.node,c=this.decorations,u=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=r,this.currentPos=this.getPos(),this.options.update({oldNode:l,oldDecorations:c,newNode:t,newDecorations:e,oldInnerDecorations:u,innerDecorations:r,updateProps:()=>n({node:t,decorations:e,innerDecorations:r,extension:this.extensionWithSyncedStorage})})}if(!(t!==this.node))return this.node=t,this.decorations=e,this.innerDecorations=r,!0;const i=this.getPos();this.node=t,this.decorations=e,this.innerDecorations=r,this.currentPos=i;const a={node:t,decorations:e,innerDecorations:r,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(a.getPos=()=>this.getPos()),n(a),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,r=$k(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:r})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function rFt(t,e){return r=>r.editor.contentComponent?new tFt(t,r,e):{}}var vK=S.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});vK.displayName="TiptapContext";var nFt=()=>S.useContext(vK);function $Ae({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=S.useMemo(()=>({editor:n}),[n]),i=S.useMemo(()=>({editor:n}),[n]);return o.jsx(DAe.Provider,{value:i,children:o.jsx(vK.Provider,{value:s,children:r})})}$Ae.displayName="Tiptap";function FAe({...t}){const{editor:e}=nFt();return o.jsx(RAe,{editor:e,...t})}FAe.displayName="Tiptap.Content";Object.assign($Ae,{Content:FAe});var hle=Object.defineProperty,sFt=(t,e)=>{let r={};for(var n in t)hle(r,n,{get:t[n],enumerable:!0});return hle(r,Symbol.toStringTag,{value:"Module"}),r},jO=200,Oi=function(){};Oi.prototype.append=function(e){return e.length?(e=Oi.from(e),!this.length&&e||e.length<jO&&this.leafAppend(e)||this.length<jO&&e.leafPrepend(this)||this.appendInner(e)):this};Oi.prototype.prepend=function(e){return e.length?Oi.from(e).append(this):this};Oi.prototype.appendInner=function(e){return new iFt(this,e)};Oi.prototype.slice=function(e,r){return e===void 0&&(e=0),r===void 0&&(r=this.length),e>=r?Oi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,r))};Oi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Oi.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)};Oi.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};Oi.from=function(e){return e instanceof Oi?e:e&&e.length?new BAe(e):Oi.empty};var BAe=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,l){for(var c=i;c<a;c++)if(s(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,a,l){for(var c=i-1;c>=a;c--)if(s(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=jO)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=jO)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}(Oi);Oi.empty=new BAe([]);var iFt=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 l=this.left.length;if(s<l&&this.left.forEachInner(n,s,Math.min(i,l),a)===!1||i>l&&this.right.forEachInner(n,Math.max(s-l,0),Math.min(this.length,i)-l,a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,s,i,a){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(n,s-l,Math.max(i,l)-l,a+l)===!1||i<l&&this.left.forEachInvertedInner(n,Math.min(s,l),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}(Oi);const aFt=500;class Uc{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,l,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 ju(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 ju(m,void 0,void 0,u.length+d.length))),i--,m&&s.appendMap(m,i)}else a.maybeStep(h.step);if(h.selection)return l=s?h.selection.map(s.slice(i)):h.selection,c=new Uc(this.items.slice(0,n).append(d.reverse().concat(u)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:a,selection:l}}addTransform(e,r,n,s){let i=[],a=this.eventCount,l=this.items,c=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let h=e.steps[d].invert(e.docs[d]),f=new ju(e.mapping.maps[d],h,r),p;(p=c&&c.merge(f))&&(f=p,d?i.pop():l=l.slice(0,l.length-1)),i.push(f),r&&(a++,r=void 0),s||(c=f)}let u=a-n.depth;return u>lFt&&(l=oFt(l,u),a-=u),new Uc(l.append(i),a)}remapping(e,r){let n=new Tk;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 Uc(this.items.append(e.map(r=>new ju(r))),this.eventCount)}rebased(e,r){if(!this.eventCount)return this;r=Math.min(this.items.length,r);let n=[],s=this.items.length-r,i=e.mapping,a=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},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]),y=f.selection&&f.selection.map(i.slice(c+1,p));y&&l++,n.push(new ju(m,g,y))}else n.push(new ju(m))},s);let u=[];for(let f=r;f<a;f++)u.push(new ju(i.maps[f]));let d=this.items.slice(0,s).append(u).append(n),h=new Uc(d,l);return h.emptyItemCount()>aFt&&(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,l)=>{if(l>=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 ju(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 Uc(Oi.from(s.reverse()),i)}}Uc.empty=new Uc(Oi.empty,0);function oFt(t,e){let r;return t.forEach((n,s)=>{if(n.selection&&e--==0)return r=s,!1}),t.slice(r)}class ju{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 ju(r.getMap().invert(),r,this.selection)}}}class lp{constructor(e,r,n,s,i){this.done=e,this.undone=r,this.prevRanges=n,this.prevTime=s,this.prevComposition=i}}const lFt=20;function cFt(t,e,r,n){let s=r.getMeta(Yy),i;if(s)return s.historyState;r.getMeta(hFt)&&(t=new lp(t.done,t.undone,null,0,-1));let a=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(a&&a.getMeta(Yy))return a.getMeta(Yy).redo?new lp(t.done.addTransform(r,void 0,n,UP(e)),t.undone,fle(r.mapping.maps),t.prevTime,t.prevComposition):new lp(t.done,t.undone.addTransform(r,void 0,n,UP(e)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let l=r.getMeta("composition"),c=t.prevTime==0||!a&&t.prevComposition!=l&&(t.prevTime<(r.time||0)-n.newGroupDelay||!uFt(r,t.prevRanges)),u=a?s6(t.prevRanges,r.mapping):fle(r.mapping.maps);return new lp(t.done.addTransform(r,c?e.selection.getBookmark():void 0,n,UP(e)),Uc.empty,u,r.time,l??t.prevComposition)}else return(i=r.getMeta("rebased"))?new lp(t.done.rebased(r,i),t.undone.rebased(r,i),s6(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new lp(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),s6(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function uFt(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 fle(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 s6(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 dFt(t,e,r){let n=UP(e),s=Yy.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),l=(r?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,n),c=new lp(r?l:i.remaining,r?i.remaining:l,null,0,-1);return i.transform.setSelection(a).setMeta(Yy,{redo:r,historyState:c})}let i6=!1,ple=null;function UP(t){let e=t.plugins;if(ple!=e){i6=!1,ple=e;for(let r=0;r<e.length;r++)if(e[r].spec.historyPreserveItems){i6=!0;break}}return i6}const Yy=new Wr("history"),hFt=new Wr("closeHistory");function fFt(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ar({key:Yy,state:{init(){return new lp(Uc.empty,Uc.empty,null,0,-1)},apply(e,r,n){return cFt(r,n,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,r){let n=r.inputType,s=n=="historyUndo"?UAe:n=="historyRedo"?HAe:null;return!s||!e.editable?!1:(r.preventDefault(),s(e.state,e.dispatch))}}}})}function zAe(t,e){return(r,n)=>{let s=Yy.getState(r);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(n){let i=dFt(s,r,t);i&&n(e?i.scrollIntoView():i)}return!0}}const UAe=zAe(!1,!0),HAe=zAe(!0,!0);function WAe(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 pFt=class VAe{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:r,state:n}=this,{view:s}=r,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...d)=>{const h=c(...d)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(i),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,r=!0){const{rawCommands:n,editor:s,state:i}=this,{view:a}=s,l=[],c=!!e,u=e||i.tr,d=()=>(!c&&r&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(u),l.every(f=>f===!0)),h={...Object.fromEntries(Object.entries(n).map(([f,p])=>[f,(...g)=>{const y=this.buildProps(u,r),x=p(...g)(y);return l.push(x),h}])),run:d};return h}static createFakeChain(){const e=new Proxy({},{get:(r,n)=>{if(n!=="then")return n==="run"?()=>!1:()=>e}});return e}createCan(e){const{rawCommands:r,state:n}=this,s=!1,i=e||n.tr,a=this.buildProps(i,s);return{...Object.fromEntries(Object.entries(r).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,s)}}static createFallbackCan(){const e=VAe.createFakeChain();return new Proxy({chain:()=>e},{get:(r,n)=>{if(n!=="then")return n==="chain"?r.chain:()=>!1}})}buildProps(e,r=!0){const{rawCommands:n,editor:s,state:i}=this,{view:a}=s,l={tr:e,editor:s,view:a,state:WAe({state:i,transaction:e}),dispatch:r?()=>{}:void 0,chain:()=>this.createChain(e,r),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...d)=>u(...d)(l)]))}};return l}};const mFt=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{if(!t.isDestroyed){var r;e.dom.blur(),(r=window)===null||r===void 0||(r=r.getSelection())===null||r===void 0||r.removeAllRanges()}}),!0),gFt=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),xFt=()=>({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,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,h=u.resolve(d.map(c)),f=u.resolve(d.map(c+l.nodeSize)),p=h.blockRange(f);if(!p)return;const m=Hv(p);if(l.type.isTextblock){const{defaultType:g}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(p.start,g)}(m||m===0)&&e.lift(p,m)})}),!0},yFt=t=>e=>t(e),vFt=()=>({state:t,dispatch:e})=>sEe(t,e),bFt=(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 ht(n.doc.resolve(Math.max(a-1,0)))),!0},wFt=()=>({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 a=s.before(i),l=s.after(i);t.delete(a,l).scrollIntoView()}return!0}return!1};function da(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}const jFt=t=>({tr:e,state:r,dispatch:n})=>{const s=da(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 l=i.before(a),c=i.after(a);e.delete(l,c).scrollIntoView()}return!0}return!1},SFt=t=>({tr:e,dispatch:r})=>{const{from:n,to:s}=t;return r&&e.delete(n,s),!0},_Ft=t=>t.content?/^text(\*|\+)/.test(t.content):!1,mle=(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 _Ft(n)?r==="left"?t.start()-1:t.end()+1:t.pos},NFt=(t,e,r)=>({from:mle(t,r,"left"),to:mle(e,r,"right")}),kFt=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){const r=t.tr,{ranges:n}=t.selection,s=r.steps.length;n.forEach(i=>{const a=r.mapping.slice(s),l=r.doc.resolve(a.map(i.$from.pos)),c=r.doc.resolve(a.map(i.$to.pos)),{from:u,to:d}=NFt(l,c,t.schema);r.deleteRange(u,d)}),r.selection.empty||r.setSelection(ht.near(r.doc.resolve(r.selection.from))),r.scrollIntoView(),e(r)}return!0},CFt=()=>({commands:t})=>t.keyboardShortcut("Enter"),EFt=()=>({state:t,dispatch:e})=>nEe(t,e);function AFt(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function SO(t,e,r={strict:!0}){const n=Object.keys(e);return n.length?n.every(s=>r.strict?e[s]===t[s]:AFt(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function qAe(t,e,r={}){return t.find(n=>n.type===e&&SO(Object.fromEntries(Object.keys(r).map(s=>[s,n.attrs[s]])),r))}function gle(t,e,r={}){return!!qAe(t,e,r)}function bK(t,e,r){if(!t||!e)return;let n=t.parent.childAfter(t.parentOffset);if((!n.node||!n.node.marks.some(c=>c.type===e))&&(n=t.parent.childBefore(t.parentOffset)),!n.node||!n.node.marks.some(c=>c.type===e))return;if(!r){const c=n.node.marks.find(u=>u.type===e);c&&(r=c.attrs)}if(!qAe([...n.node.marks],e,r))return;let s=n.index,i=t.start()+n.offset,a=s+1,l=i+n.node.nodeSize;for(;s>0&&gle([...t.parent.child(s-1).marks],e,r);)s-=1,i-=t.parent.child(s).nodeSize;for(;a<t.parent.childCount&&gle([...t.parent.child(a).marks],e,r);)l+=t.parent.child(a).nodeSize,a+=1;return{from:i,to:l}}function jg(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}const TFt=(t,e)=>({tr:r,state:n,dispatch:s})=>{const i=jg(t,n.schema),{doc:a,selection:l}=r,{$from:c,from:u,to:d}=l;if(s){const h=bK(c,i,e);if(h&&h.from<=u&&h.to>=d){const f=ht.create(a,h.from,h.to);r.setSelection(f)}}return!0},PFt=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 GAe(t){return t instanceof ht}function yx(t=0,e=0,r=0){return Math.min(Math.max(t,e),r)}function IFt(t,e=null){if(!e)return null;const r=Mt.atStart(t),n=Mt.atEnd(t);if(e==="start"||e===!0)return r;if(e==="end")return n;const s=r.from,i=n.to;return e==="all"?ht.create(t,yx(0,s,i),yx(t.content.size,s,i)):ht.create(t,yx(e,s,i),yx(e,s,i))}function xle(){return["Android"].includes(navigator.platform)||/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 RFt(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}const OFt=(t=null,e={})=>({editor:r,view:n,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const a=()=>{(_O()||xle())&&n.dom.focus(),RFt()&&!_O()&&!xle()&&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&&!GAe(r.state.selection))return a(),!0;const l=IFt(s.doc,t)||r.state.selection,c=r.state.selection.eq(l);return i&&(c||s.setSelection(l),c&&s.storedMarks&&s.setStoredMarks(s.storedMarks),a()),!0},MFt=(t,e)=>r=>t.every((n,s)=>e(n,{...r,index:s})),DFt=(t,e)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,e),KAe=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&&KAe(n)}return t};function a2(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 KAe(r)}function YAe(t){return typeof(t==null?void 0:t.nodesBetween)=="function"}function G1(t,e,r){if(YAe(t))return t;const n=typeof t=="object"&&t!==null;r={slice:!0,parseOptions:{},...r};const s=typeof t=="string";if(n)try{if(Array.isArray(t)&&t.length>0)return Me.fromArray(t.map(a=>e.nodeFromJSON(a)));const i=e.nodeFromJSON(t);return r.errorOnInvalidContent&&i.check(),i}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),G1("",e,r)}if(s){if(r.errorOnInvalidContent){let a=!1,l="";const c=new WG({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,l=typeof u=="string"?u:u.outerHTML,null)}]}})});if(r.slice?Om.fromSchema(c).parseSlice(a2(t),r.parseOptions):Om.fromSchema(c).parse(a2(t),r.parseOptions),r.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Om.fromSchema(e);return r.slice?i.parseSlice(a2(t),r.parseOptions).content:i.parse(a2(t),r.parseOptions)}return G1("",e,r)}function XAe(t){return!("type"in t)}function QAe(t,e,r){const n=t.steps.length-1;if(n<e)return;const s=t.steps[n];if(!(s instanceof ks||s instanceof oi))return;const i=t.mapping.maps[n];let a=0;i.forEach((l,c,u,d)=>{a===0&&(a=d)}),t.setSelection(Mt.near(t.doc.resolve(a),r))}const LFt=(t,e,r)=>({tr:n,dispatch:s,editor:i})=>{if(s){r={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let l;const c=y=>{i.emit("contentError",{editor:i,error:y,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{G1(e,i.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(y){c(y)}try{var a;l=G1(e,i.schema,{parseOptions:u,errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck})}catch(y){return c(y),!1}let{from:d,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,p=!0;const m=XAe(l)?l.content:[l];if(m.forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,p=p?y.isBlock:!1}),d===h&&p){const{parent:y}=n.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,h+=1)}let g;if(f)Array.isArray(e)?g=e.map(y=>y.text||"").join(""):YAe(e)?g=m.map(y=>{var x;return(x=y.text)!==null&&x!==void 0?x:""}).join(""):typeof e=="object"&&e&&e.text?g=e.text:g=e,n.insertText(g,d,h);else{g=Me.from(m);const y=n.doc.resolve(d),x=y.node(),v=y.parentOffset===0,b=x.isText||x.isTextblock,w=x.content.size>0;v&&b&&w&&p&&(d=Math.max(0,d-1)),n.replaceWith(d,h,m)}r.updateSelection&&QAe(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};function ZAe(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}const $Ft=(t={})=>({tr:e,dispatch:r,editor:n})=>{const{pos:s,attrs:i,content:a,updateSelection:l=!0}=t;let c;typeof s=="number"?c=e.doc.resolve(s):s?c=s:c=e.selection.$from;const u=ZAe(c.parent.contentMatchAt(c.index()));if(!u)return!1;const d=Object.keys(u.spec.attrs||{}),h=i?Object.fromEntries(Object.entries(i).filter(([p])=>d.includes(p))):{};let f;if(a){const p=G1(a,n.schema);f=u.createAndFill(h,p)}else f=u.createAndFill(h);return f?(r&&(e.insert(c.pos,f),l&&QAe(e,e.steps.length-1,-1)),!0):!1},FFt=()=>({state:t,dispatch:e})=>ZCe(t,e),BFt=()=>({state:t,dispatch:e})=>JCe(t,e),zFt=()=>({state:t,dispatch:e})=>WCe(t,e),UFt=()=>({state:t,dispatch:e})=>XCe(t,e),JAe=(t,e)=>{const r=t.resolve(e),n=r.nodeBefore,s=r.nodeAfter;return!n||!s?!1:!n.type.spec.isolating&&!s.type.spec.isolating},HFt=()=>({state:t,dispatch:e,tr:r})=>{try{const n=Mj(t.doc,t.selection.$from.pos,-1);return n==null||!JAe(t.doc,n)?!1:(r.join(n,2),e&&e(r),!0)}catch{return!1}},WFt=()=>({state:t,dispatch:e,tr:r})=>{try{const n=Mj(t.doc,t.selection.$from.pos,1);return n==null||!JAe(t.doc,n)?!1:(r.join(n,2),e&&e(r),!0)}catch{return!1}},VFt=()=>({state:t,dispatch:e})=>VCe(t,e),qFt=()=>({state:t,dispatch:e})=>qCe(t,e);function eTe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function GFt(t){const e=t.split(/-(?!$)/);let r=e[e.length-1];r==="Space"&&(r=" ");let n,s,i,a;for(let l=0;l<e.length-1;l+=1){const c=e[l];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()||eTe()?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}const KFt=t=>({editor:e,view:r,tr:n,dispatch:s})=>{const i=GFt(t).split(/-(?!$)/),a=i.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=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,l))});return c==null||c.steps.forEach(u=>{const d=u.map(n.mapping);d&&s&&n.maybeStep(d)}),!0};function Sv(t,e,r={}){const{from:n,to:s,empty:i}=t.selection,a=e?da(e,t.schema):null,l=[];t.doc.nodesBetween(n,s,(d,h)=>{if(d.isText)return;const f=Math.max(n,h),p=Math.min(s,h+d.nodeSize);l.push({node:d,from:f,to:p})});const c=s-n,u=l.filter(d=>a?a.name===d.node.type.name:!0).filter(d=>SO(d.node.attrs,r,{strict:!1}));return i?!!u.length:u.reduce((d,h)=>d+h.to-h.from,0)>=c}const YFt=(t,e={})=>({state:r,dispatch:n})=>Sv(r,da(t,r.schema),e)?eEe(r,n):!1,XFt=()=>({state:t,dispatch:e})=>iEe(t,e),QFt=t=>({state:e,dispatch:r})=>{const n=da(t,e.schema);return fEe(n)(e,r)},ZFt=()=>({state:t,dispatch:e})=>tEe(t,e);function tTe(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function yle(t,e){const r=typeof e=="string"?[e]:e;return Object.keys(t).reduce((n,s)=>(r.includes(s)||(n[s]=t[s]),n),{})}const JFt=(t,e)=>({tr:r,state:n,dispatch:s})=>{let i=null,a=null;const l=tTe(typeof t=="string"?t:t.name,n.schema);if(!l)return!1;l==="node"&&(i=da(t,n.schema)),l==="mark"&&(a=jg(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,yle(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(yle(f.attrs,e))))})})}),c},e6t=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),t6t=()=>({tr:t,dispatch:e})=>{if(e){const r=new ul(t.doc);t.setSelection(r)}return!0},r6t=()=>({state:t,dispatch:e})=>KCe(t,e),n6t=()=>({state:t,dispatch:e})=>QCe(t,e),s6t=()=>({state:t,dispatch:e})=>aEe(t,e),i6t=()=>({state:t,dispatch:e})=>uEe(t,e),a6t=()=>({state:t,dispatch:e})=>cEe(t,e);function o6t(t,e,r={},n={}){return G1(t,e,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const l6t=(t,{errorOnInvalidContent:e,emitUpdate:r=!0,parseOptions:n={}}={})=>({editor:s,tr:i,dispatch:a,commands:l})=>{const{doc:c}=i;if(n.preserveWhitespace!=="full"){const u=o6t(t,s.schema,n,{errorOnInvalidContent:e??s.options.enableContentCheck});if(a){const d=XAe(u)?u.content:[u];i.replaceWith(0,c.content.size,d).setMeta("preventUpdate",!r)}return!0}return a&&i.setMeta("preventUpdate",!r),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:n,errorOnInvalidContent:e??s.options.enableContentCheck})};function c6t(t,e){const r=jg(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 l=a.find(c=>c.type.name===r.name);return l?{...l.attrs}:{}}function u6t(t,e){const r=new c5(t);return e.forEach(n=>{n.steps.forEach(s=>{r.step(s)})}),r}function d6t(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 v5(t){return e=>d6t(e.$from,t)}function K1(t,e,r){return t.config[e]===void 0&&t.parent?K1(t.parent,e,r):typeof t.config[e]=="function"?t.config[e].bind({...r,parent:t.parent?K1(t.parent,e,r):null}):t.config[e]}function rTe(t){return{baseExtensions:t.filter(e=>e.type==="extension"),nodeExtensions:t.filter(e=>e.type==="node"),markExtensions:t.filter(e=>e.type==="mark")}}function h6t(t){return typeof t=="function"}function wf(t,e=void 0,...r){return h6t(t)?e?t.bind(e)(...r):t(...r):t}function f6t(t){const e=[];let r="",n=!1,s=!1,i=0;const a=t.length;for(let l=0;l<a;l+=1){const c=t[l];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 vle(t){const e=[],r=f6t(t||""),n=r.length;for(let s=0;s<n;s+=1){const i=r[s],a=i.indexOf(":");if(a===-1)continue;const l=i.slice(0,a).trim(),c=i.slice(a+1).trim();l&&c&&e.push([l,c])}return e}function Ia(...t){return t.filter(e=>!!e).reduce((e,r)=>{const n={...e};return Object.entries(r).forEach(([s,i])=>{if(s==="__proto__"){Object.defineProperty(n,s,{configurable:!0,enumerable:!0,value:i,writable:!0});return}if(!n[s]){n[s]=i;return}if(s==="class"){const a=i?String(i).split(" "):[],l=n[s]?n[s].split(" "):[],c=a.filter(u=>!l.includes(u));n[s]=[...l,...c].join(" ")}else if(s==="style"){const a=new Map([...vle(n[s]),...vle(i)]);n[s]=Array.from(a.entries()).map(([l,c])=>`${l}: ${c}`).join("; ")}else n[s]=i}),n},{})}function p6t(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)=>Ia(r,n),{})}function m6t(t,e,r){const{from:n,to:s}=e,{blockSeparator:i=`

`,textSerializers:a={}}=r||{};let l="";return t.nodesBetween(n,s,(c,u,d,h)=>{c.isBlock&&u>n&&(l+=i);const f=a==null?void 0:a[c.type.name];if(f)return d&&(l+=f({node:c,pos:u,parent:d,index:h,range:e})),!1;if(c.isText){var p;l+=c==null||(p=c.text)===null||p===void 0?void 0:p.slice(Math.max(n,u)-u,s-u)}}),l}function g6t(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,r])=>[e,r.spec.toText]))}function x6t(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 y6t(t){const e=x6t(t);return e.length===1?e:e.filter((r,n)=>!e.filter((s,i)=>i!==n).some(s=>r.oldRange.from>=s.oldRange.from&&r.oldRange.to<=s.oldRange.to&&r.newRange.from>=s.newRange.from&&r.newRange.to<=s.newRange.to))}function nTe(t){const{mapping:e,steps:r}=t,n=[];return e.maps.forEach((s,i)=>{const a=[];if(s.ranges.length)s.forEach((l,c)=>{a.push({from:l,to:c})});else{const{from:l,to:c}=r[i];if(l===void 0||c===void 0)return;a.push({from:l,to:c})}a.forEach(({from:l,to:c})=>{const u=e.slice(i).map(l,-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}})})}),y6t(n)}function sTe(t,e,r){const n=[];return t===e?r.resolve(t).marks().forEach(s=>{const i=bK(r.resolve(t),s.type);i&&n.push({mark:s,...i})}):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}const v6t=(t,e,r,n=20)=>{const s=t.doc.resolve(r);let i=n,a=null;for(;i>0&&a===null;){const l=s.node(i);(l==null?void 0:l.type.name)===e?a=l:i-=1}return[a,i]},b6t=t=>{const e=t.depth-1;if(e<0)return null;const r=t.index(e);return r===0?null:t.node(e).child(r-1)};function HP(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}))}function w6t(t,e,r={}){const{empty:n,ranges:s}=t.selection,i=e?jg(e,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>SO(d.attrs,r,{strict:!1}));let a=0;const l=[];if(s.forEach(({$from:d,$to:h})=>{const f=d.pos,p=h.pos;t.doc.nodesBetween(f,p,(m,g)=>{if(i&&m.inlineContent&&!m.type.allowsMarkType(i))return!1;if(!m.isText&&!m.marks.length)return;const y=Math.max(f,g),x=Math.min(p,g+m.nodeSize),v=x-y;a+=v,l.push(...m.marks.map(b=>({mark:b,from:y,to:x})))})}),a===0)return!1;const c=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>SO(d.mark.attrs,r,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),u=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,h)=>d+h.to-h.from,0);return(c>0?c+u:c)>=a}const j6t=(t,e)=>{const{$from:r,$to:n,$anchor:s}=t.selection;if(e){const i=v5(l=>l.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)},S6t=t=>{const{$from:e,$to:r}=t.selection;return!(e.parentOffset>0||e.pos!==r.pos)};function kS(t,e){const{nodeExtensions:r}=rTe(e),n=r.find(i=>i.name===t);if(!n)return!1;const s=wf(K1(n,"group",{name:n.name,options:n.options,storage:n.storage}));return typeof s!="string"?!1:s.split(" ").includes("list")}function b5(t,{checkChildren:e=!0,ignoreWhitespace:r=!1}={}){if(r){if(t.type.name==="hardBreak")return!0;if(t.isText){var n;return!/\S/.test((n=t.text)!==null&&n!==void 0?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&&(b5(i,{ignoreWhitespace:r,checkChildren:e})||(s=!1))}),s}return!1}function iTe(t){return t instanceof Pt}function _6t(t,e,r){const{selection:n}=e;let s=null;if(GAe(n)&&(s=n.$cursor),s){var i;const l=(i=t.storedMarks)!==null&&i!==void 0?i:s.marks();return s.parent.type.allowsMarkType(r)&&(!!r.isInSet(l)||!l.some(c=>c.type.excludes(r)))}const{ranges:a}=n;return a.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(l.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})}const N6t=(t,e={})=>({tr:r,state:n,dispatch:s})=>{const{selection:i}=r,{empty:a,ranges:l}=i,c=jg(t,n.schema);if(s)if(a){const u=c6t(n,c);r.addStoredMark(c.create({...u,...e}))}else l.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 _6t(n,r,c)},k6t=(t,e)=>({tr:r})=>(r.setMeta(t,e),!0),C6t=(t,e={})=>({state:r,dispatch:n,chain:s})=>{const i=da(t,r.schema);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>mO(i,{...a,...e})(r)?!0:l.clearNodes()).command(({state:l})=>mO(i,{...a,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},E6t=t=>({tr:e,dispatch:r})=>{if(r){const{doc:n}=e,s=yx(t,0,n.content.size),i=Pt.create(n,s);e.setSelection(i)}return!0},A6t=(t,e)=>({tr:r,state:n,dispatch:s})=>{const{selection:i}=n;let a,l;return typeof e=="number"?(a=e,l=e):e&&"from"in e&&"to"in e?(a=e.from,l=e.to):(a=i.from,l=i.to),s&&r.doc.nodesBetween(a,l,(c,u)=>{c.isText||r.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},T6t=t=>({tr:e,dispatch:r})=>{if(r){const{doc:n}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,a=ht.atStart(n).from,l=ht.atEnd(n).to,c=yx(s,a,l),u=yx(i,a,l),d=ht.create(n,c,u);e.setSelection(d)}return!0},P6t=t=>({state:e,dispatch:r})=>{const n=da(t,e.schema);return pEe(n)(e,r)};function ble(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)}}const I6t=({keepMarks:t=!0}={})=>({tr:e,state:r,dispatch:n,editor:s})=>{const{selection:i,doc:a}=e,{$from:l,$to:c}=i,u=s.extensionManager.attributes,d=HP(u,l.node().type.name,l.node().attrs);if(i instanceof Pt&&i.node.isBlock)return!l.parentOffset||!ud(a,l.pos)?!1:(n&&(t&&ble(r,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,f=l.depth===0?void 0:ZAe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let p=h&&f?[{type:f,attrs:d}]:void 0;const m=i instanceof ht&&!i.empty?px.create({doc:e.doc,selection:i}).tr.deleteSelection():null,g=m?m.doc:e.doc,y=m?m.mapping.map(l.pos):l.pos;let x=ud(g,y,1,p);if(!p&&!x&&ud(g,y,1,f?[{type:f}]:void 0)&&(x=!0,p=f?[{type:f,attrs:d}]:void 0),n){if(x){const v=e.steps.length;if(i instanceof ht&&e.deleteSelection(),e.split(e.mapping.slice(v).map(l.pos),1,p),f&&!h&&!l.parentOffset&&l.parent.type!==f){const b=e.mapping.slice(v).map(l.before()),w=e.doc.resolve(b);l.node(-1).canReplaceWith(w.index(),w.index()+1,f)&&e.setNodeMarkup(e.mapping.slice(v).map(l.before()),f)}}t&&ble(r,s.extensionManager.splittableMarks),e.scrollIntoView()}return x},R6t=(t,e={})=>({tr:r,state:n,dispatch:s,editor:i})=>{const a=da(t,n.schema),{$from:l,$to:c}=n.selection,u=n.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const d=l.node(-1);if(d.type!==a)return!1;const h=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){var f;let w=Me.empty;const j=l.index(-1)?1:l.index(-2)?2:3;for(let $=l.depth-j;$>=l.depth-3;$-=1)w=Me.from(l.node($).copy(w));const N=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,C={...HP(h,l.node().type.name,l.node().attrs),...e},A=((f=a.contentMatch.defaultType)===null||f===void 0?void 0:f.createAndFill(C))||void 0;w=w.append(Me.from(a.createAndFill(null,A)||void 0));const E=l.before(l.depth-(j-1));r.replace(E,l.after(-N),new at(w,4-j,0));let O=-1;r.doc.nodesBetween(E,r.doc.content.size,($,T)=>{if(O>-1)return!1;$.isTextblock&&$.content.size===0&&(O=T+1)}),O>-1&&r.setSelection(ht.near(r.doc.resolve(O))),r.scrollIntoView()}return!0}const p=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,m={...HP(h,d.type.name,d.attrs),...e},g={...HP(h,l.node().type.name,l.node().attrs),...e},y=l.parentOffset===0&&l.index(-1)===0,x=l.before(-1);r.delete(l.pos,c.pos);const v=y?d.attrs:m,b=p?[{type:a,attrs:v},{type:p,attrs:g}]:[{type:a,attrs:v}];if(!ud(r.doc,l.pos,2))return!1;if(s){const{selection:w,storedMarks:j}=n,{splittableMarks:N}=i.extensionManager,C=j||w.$to.parentOffset&&w.$from.marks();if(r.split(l.pos,2,b).scrollIntoView(),y&&r.setNodeMarkup(x,void 0,m),!C||!s)return!0;const A=C.filter(E=>N.includes(E.type.name));r.ensureMarks(A)}return!0};function aTe(t,e,r){if(!t.validContent(e))return null;try{return t.create(r,e)}catch{return null}}function wK(t,e){if(t.pendingContent.length===0)return!0;const r=aTe(e,Me.from(t.pendingContent));return r?(t.items.push(r),t.pendingContent=[],!0):!1}function O6t(t,e,r){return r.validContent(Me.from([...e.pendingContent,t]))?(e.pendingContent.push(t),!0):!wK(e,r)||!r.validContent(Me.from(t))?!1:(e.pendingContent.push(t),!0)}function M6t(t,e,r,n){const s=n(t,r);if(!s)return!1;const i=aTe(r.listType,Me.from(s),t.attrs);return i?r.itemType.validContent(Me.from([...e.pendingContent,i]))?(e.pendingContent.push(i),!0):wK(e,r.itemType)?(e.items.push(...s),!0):!1:!1}function D6t(t,e,r){const n={items:[],pendingContent:[]};for(let s=0;s<t.childCount;s+=1){const i=t.child(s);if(!(e.isListNode(i)?M6t(i,n,e,r):O6t(i,n,e.itemType)))return null}return wK(n,e.itemType)?n.items:null}function oTe(t,e){const r=[];for(let n=0;n<t.childCount;n+=1){const s=D6t(t.child(n),e,oTe);if(!s)return null;r.push(...s)}return r}function wle(t,e){let r=null;return t.descendants((n,s)=>n!==e?!0:(r=s,!1)),r}function jle(t){return!t||t==="1"?null:t}function lTe(t,e){return jle(t)===jle(e)}const o2=(t,e)=>{const r=v5(i=>i.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)&&Ed(t.doc,r.pos))||!lTe(r.node.attrs.type,s==null?void 0:s.attrs.type)||t.join(r.pos),!0},l2=(t,e)=>{const r=v5(i=>i.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)&&Ed(t.doc,n))||!lTe(r.node.attrs.type,s==null?void 0:s.attrs.type)||t.join(n),!0};function L6t(t){const e=t.doc,r=e.firstChild;if(!r)return null;const n=e.resolve(1),s=e.resolve(r.nodeSize-1);return ht.between(n,s)}const $6t=(t,e,r,n={})=>({editor:s,tr:i,state:a,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:h,splittableMarks:f}=s.extensionManager,p=da(t,a.schema),m=da(e,a.schema),{selection:g,storedMarks:y}=a,{$from:x,$to:v}=g,b=x.blockRange(v),w=y||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;const j=v5(k=>kS(k.type.name,h))(g),N=g.from===0&&g.to===a.doc.content.size,C=a.doc.content.content,A=C.length===1?C[0]:null,E=N&&A&&kS(A.type.name,h)?{node:A,pos:0,depth:0}:null,O=j??E,$=!!j&&b.depth>=1&&b.depth-j.depth<=1,T=!!E;if(($||T)&&O){if(O.node.type===p)return N&&T?c().command(({tr:k,dispatch:D})=>{const K=L6t(k);return K?(k.setSelection(K),D&&D(k),!0):!1}).liftListItem(m).run():u.liftListItem(m);if(kS(O.node.type.name,h)&&p.validContent(O.node.content))return c().command(()=>(i.setNodeMarkup(O.pos,p),!0)).command(()=>o2(i,p)).command(()=>l2(i,p)).run();if(kS(O.node.type.name,h)){var M;const k=(M=O.node.firstChild)===null||M===void 0?void 0:M.type;if(k&&k!==m){const D=oTe(O.node,{listType:p,itemType:m,isListNode:H=>kS(H.type.name,h)}),K=D?Me.from(D):null;return!K||!p.validContent(K)?!1:c().command(()=>{const{$anchor:H,$head:ee}=i.selection,V=H.parent,B=ee.parent,z=H.parentOffset,F=ee.parentOffset;let G;try{G=p.create(n,K)}catch{return!1}if(i.replaceWith(O.pos,O.pos+O.node.nodeSize,G),V.inlineContent&&B.inlineContent){const Q=wle(G,V),ie=wle(G,B);if(Q!==null&&ie!==null){const se=O.pos+Q+2+z,q=O.pos+ie+2+F;i.setSelection(ht.create(i.doc,se,q))}}return!0}).command(()=>o2(i,p)).command(()=>l2(i,p)).run()}}}return!r||!w||!l?c().command(()=>d().wrapInList(p,n)?!0:u.clearNodes()).wrapInList(p,n).command(()=>o2(i,p)).command(()=>l2(i,p)).run():c().command(()=>{const k=d().wrapInList(p,n),D=w.filter(K=>f.includes(K.type.name));return i.ensureMarks(D),k?!0:u.clearNodes()}).wrapInList(p,n).command(()=>o2(i,p)).command(()=>l2(i,p)).run()},F6t=(t,e={},r={})=>({state:n,commands:s})=>{const{extendEmptyMarkRange:i=!1}=r,a=jg(t,n.schema);return w6t(n,a,e)?s.unsetMark(a,{extendEmptyMarkRange:i}):s.setMark(a,e)},B6t=(t,e,r={})=>({state:n,commands:s})=>{const i=da(t,n.schema),a=da(e,n.schema),l=Sv(n,i,r);let c;return n.selection.$anchor.sameParent(n.selection.$head)&&(c=n.selection.$anchor.parent.attrs),l?s.setNode(a,c):s.setNode(i,{...c,...r})},z6t=(t,e={})=>({state:r,commands:n})=>{const s=da(t,r.schema);return Sv(r,s,e)?n.lift(s):n.wrapIn(s,e)},U6t=()=>({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,l=i.transform;for(let c=l.steps.length-1;c>=0;c-=1)a.step(l.steps[c].invert(l.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},H6t=(t={})=>({tr:e,dispatch:r,editor:n})=>{const{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:a,ranges:l}=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));l.forEach(d=>{for(const h of u)e.removeMark(d.$from.pos,d.$to.pos,h)})}return!0},W6t=(t,e={})=>({tr:r,state:n,dispatch:s})=>{const{extendEmptyMarkRange:i=!1}=e,{selection:a}=r,l=jg(t,n.schema),{$from:c,empty:u,ranges:d}=a;if(!s)return!0;if(u&&i){var h;let{from:f,to:p}=a;const m=bK(c,l,(h=c.marks().find(g=>g.type===l))===null||h===void 0?void 0:h.attrs);m&&(f=m.from,p=m.to),r.removeMark(f,p,l)}else d.forEach(f=>{r.removeMark(f.$from.pos,f.$to.pos,l)});return r.removeStoredMark(l),!0},V6t=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,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},q6t=(t,e={})=>({tr:r,state:n,dispatch:s})=>{let i=null,a=null;const l=tTe(typeof t=="string"?t:t.name,n.schema);if(!l)return!1;l==="node"&&(i=da(t,n.schema)),l==="mark"&&(a=jg(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,(y,x)=>{i&&i===y.type&&(c=!0,m=Math.max(x,d),g=Math.min(x+y.nodeSize,h),f=x,p=y)}):n.doc.nodesBetween(d,h,(y,x)=>{x<d&&i&&i===y.type&&(c=!0,m=Math.max(x,d),g=Math.min(x+y.nodeSize,h),f=x,p=y),x>=d&&x<=h&&(i&&i===y.type&&(c=!0,s&&r.setNodeMarkup(x,void 0,{...y.attrs,...e})),a&&y.marks.length&&y.marks.forEach(v=>{if(a===v.type&&(c=!0,s)){const b=Math.max(x,d),w=Math.min(x+y.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(y=>{a===y.type&&s&&r.addMark(m,g,a.create({...y.attrs,...e}))}))}),c},G6t=new Wr("__tiptap_decorations__"),K6t=t=>({tr:e,dispatch:r})=>(r&&e.setMeta(G6t,{type:"force",name:t}),!0),Y6t=(t,e={})=>({state:r,dispatch:n})=>{const s=da(t,r.schema);return dEe(s,e)(r,n)},X6t=(t,e={})=>({state:r,dispatch:n})=>{const s=da(t,r.schema);return hEe(s,e)(r,n)};var Q6t=sFt({blur:()=>mFt,clearContent:()=>gFt,clearNodes:()=>xFt,command:()=>yFt,createParagraphNear:()=>vFt,cut:()=>bFt,deleteCurrentNode:()=>wFt,deleteNode:()=>jFt,deleteRange:()=>SFt,deleteSelection:()=>kFt,enter:()=>CFt,exitCode:()=>EFt,extendMarkRange:()=>TFt,first:()=>PFt,focus:()=>OFt,forEach:()=>MFt,insertContent:()=>DFt,insertContentAt:()=>LFt,insertDefaultBlock:()=>$Ft,joinBackward:()=>zFt,joinDown:()=>BFt,joinForward:()=>UFt,joinItemBackward:()=>HFt,joinItemForward:()=>WFt,joinTextblockBackward:()=>VFt,joinTextblockForward:()=>qFt,joinUp:()=>FFt,keyboardShortcut:()=>KFt,lift:()=>YFt,liftEmptyBlock:()=>XFt,liftListItem:()=>QFt,newlineInCode:()=>ZFt,resetAttributes:()=>JFt,scrollIntoView:()=>e6t,selectAll:()=>t6t,selectNodeBackward:()=>r6t,selectNodeForward:()=>n6t,selectParentNode:()=>s6t,selectTextblockEnd:()=>i6t,selectTextblockStart:()=>a6t,setContent:()=>l6t,setMark:()=>N6t,setMeta:()=>k6t,setNode:()=>C6t,setNodeSelection:()=>E6t,setTextDirection:()=>A6t,setTextSelection:()=>T6t,sinkListItem:()=>P6t,splitBlock:()=>I6t,splitListItem:()=>R6t,toggleList:()=>$6t,toggleMark:()=>F6t,toggleNode:()=>B6t,toggleWrap:()=>z6t,undoInputRule:()=>U6t,unsetAllMarks:()=>H6t,unsetMark:()=>W6t,unsetTextDirection:()=>V6t,updateAttributes:()=>q6t,updateDecorations:()=>K6t,wrapIn:()=>Y6t,wrapInList:()=>X6t});function Z6t(t,e){const{selection:r}=t,{$from:n}=r;if(r instanceof Pt){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 J6t(t){return Object.prototype.toString.call(t).slice(8,-1)}function c2(t){return J6t(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Sle(t,e,r){const n=t.split(`
`),s=[];let i="",a=0;const l=e.baseIndentSize||2;for(;a<n.length;){const d=n[a],h=d.match(e.itemPattern);if(!h){if(s.length>0)break;if(d.trim()===""){a+=1,i=`${i}${d}
`;continue}else return}const f=e.extractItemData(h),{indentLevel:p,mainContent:m}=f;i=`${i}${d}
`;const g=[m];for(a+=1;a<n.length;){var c;const b=n[a];if(b.trim()===""){var u;const w=n.slice(a+1).findIndex(j=>j.trim()!=="");if(w===-1)break;if((((u=n[a+1+w].match(/^(\s*)/))===null||u===void 0||(u=u[1])===null||u===void 0?void 0:u.length)||0)>p){g.push(b),i=`${i}${b}
`,a+=1;continue}else break}if((((c=b.match(/^(\s*)/))===null||c===void 0||(c=c[1])===null||c===void 0?void 0:c.length)||0)>p)g.push(b),i=`${i}${b}
`,a+=1;else break}let y;const x=g.slice(1);if(x.length>0){const b=x.map(w=>w.slice(p+l)).join(`
`);b.trim()&&(e.customNestedParser?y=e.customNestedParser(b):y=r.blockTokens(b))}const v=e.createToken(f,y);s.push(v)}if(s.length!==0)return{items:s,raw:i}}const _le=4;function Nle(t){let e=0;for(const r of t)e=r==="	"?e+_le-e%_le:e+1;return e}function cTe(t,e,r,n,s){if(!t||!Array.isArray(t.content))return"";const i=typeof r=="function"?r(n):r,[a,...l]=t.content;let c=`${i}${e.renderChildren([a])}`;return l&&l.length>0&&l.forEach((u,d)=>{var h,f;const p=(h=(f=e.renderChild)===null||f===void 0?void 0:f.call(e,u,d+1))!==null&&h!==void 0?h:e.renderChildren([u]);if(p!=null){const m=y=>{if(!(s!=null&&s.alignNestedToPrefix))return e.indent(y);const x=e.indent(""),v=Nle(i);return(Nle(x)>=v?x:" ".repeat(v))+y},g=p.split(`
`).map(y=>m(y||"")).join(`
`);c+=u.type==="paragraph"?`

${g}`:`
${g}`}}),c}function uTe(t,e){const r={...t};return c2(t)&&c2(e)&&Object.keys(e).forEach(n=>{c2(e[n])&&c2(t[n])?r[n]=uTe(t[n],e[n]):r[n]=e[n]}),r}var w5=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!==null&&e!==void 0?e:!0}},jK=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{...wf(K1(this,"addOptions",{name:this.name}))}}get storage(){return{...wf(K1(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>uTe(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}},j5=class dTe extends jK{constructor(...e){super(...e),this.type="mark"}static create(e={}){const r=typeof e=="function"?e():e;return new dTe(r)}static handleExit({editor:e,mark:r}){const{tr:n}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!i.find(l=>(l==null?void 0:l.type.name)===r.name))return!1;const a=i.find(l=>(l==null?void 0:l.type.name)===r.name);return a&&n.removeStoredMark(a),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)}},eBt=class{constructor(t){this.find=t.find,this.handler=t.handler}},js=class hTe extends jK{constructor(...e){super(...e),this.type="extension"}static create(e={}){const r=typeof e=="function"?e():e;return new hTe(r)}configure(e){return super.configure(e)}extend(e){const r=typeof e=="function"?e():e;return super.extend(r)}};js.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ar({key:new Wr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:r}=t,{doc:n,selection:s}=e,i=g6t(r),{blockSeparator:a}=this.options,l={...a!==void 0?{blockSeparator:a}:{},textSerializers:i};return[...s.ranges].sort((c,u)=>c.$from.pos-u.$from.pos).map(({$from:c,$to:u})=>m6t(n,{from:c.pos,to:u.pos},l)).join(a??`

`)}}})]}});js.create({name:"commands",addCommands(){return{...Q6t}}});js.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var r,n;const s=()=>{var i,a,l;if((i=(a=this.editor.options.coreExtensionOptions)===null||a===void 0||(a=a.delete)===null||a===void 0||(l=a.filterTransaction)===null||l===void 0?void 0:l.call(a,t))!==null&&i!==void 0?i:t.getMeta("y-sync$"))return;const c=u6t(t.before,[t,...e]);nTe(c).forEach(d=>{c.mapping.mapResult(d.oldRange.from).deletedAfter&&c.mapping.mapResult(d.oldRange.to).deletedBefore&&c.before.nodesBetween(d.oldRange.from,d.oldRange.to,(h,f)=>{const p=f+h.nodeSize-2,m=d.oldRange.from<=f&&p<=d.oldRange.to;this.editor.emit("delete",{type:"node",node:h,from:f,to:p,newFrom:c.mapping.map(f),newTo:c.mapping.map(p),deletedRange:d.oldRange,newRange:d.newRange,partial:!m,editor:this.editor,transaction:t,combinedTransform:c})})});const u=c.mapping;c.steps.forEach((d,h)=>{if(d instanceof Ql){var f,p;const m=u.slice(h).map(d.from,-1),g=u.slice(h).map(d.to),y=u.invert().map(m,-1),x=u.invert().map(g),v=m>0?(f=c.doc.nodeAt(m-1))===null||f===void 0?void 0:f.marks.some(w=>w.eq(d.mark)):!1,b=(p=c.doc.nodeAt(g))===null||p===void 0?void 0:p.marks.some(w=>w.eq(d.mark));this.editor.emit("delete",{type:"mark",mark:d.mark,from:d.from,to:d.to,deletedRange:{from:y,to:x},newRange:{from:m,to:g},partial:!!(b||v),editor:this.editor,transaction:t,combinedTransform:c})}})};!((r=(n=this.editor.options.coreExtensionOptions)===null||n===void 0||(n=n.delete)===null||n===void 0?void 0:n.async)!==null&&r!==void 0)||r?setTimeout(s,0):s()}});js.create({name:"drop",addProseMirrorPlugins(){return[new Ar({key:new Wr("tiptapDrop"),props:{handleDrop:(t,e,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:r,moved:n})}}})]}});js.create({name:"editable",addProseMirrorPlugins(){return[new Ar({key:new Wr("editable"),props:{editable:()=>this.editor.options.editable}})]}});const tBt=new Wr("focusEvents");js.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ar({key:tBt,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}}}})]}});js.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:h}=c,{pos:f,parent:p}=h,m=h.parent.isTextblock&&f>0?l.doc.resolve(f-1):h,g=m.parent.type.spec.isolating,y=h.pos-h.parentOffset,x=g&&m.parent.childCount===1?y===h.pos:Mt.atStart(u).from===f;return!d||!p.type.isTextblock||p.textContent.length||!x||x&&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()||eTe()?i:s},addProseMirrorPlugins(){return[new Ar({key:new Wr("clearDocument"),appendTransaction:(t,e,r)=>{if(t.some(p=>p.getMeta("composition")))return;const n=t.some(p=>p.docChanged)&&!e.doc.eq(r.doc),s=t.some(p=>p.getMeta("preventClearDocument"));if(!n||s)return;const{empty:i,from:a,to:l}=e.selection,c=Mt.atStart(e.doc).from,u=Mt.atEnd(e.doc).to;if(i||!(a===c&&l===u)||!b5(r.doc))return;const d=r.tr,h=WAe({state:r,transaction:d}),{commands:f}=new pFt({editor:this.editor,state:h});if(f.clearNodes(),!!d.steps.length)return d}})]}});js.create({name:"paste",addProseMirrorPlugins(){return[new Ar({key:new Wr("tiptapPaste"),props:{handlePaste:(t,e,r)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:r})}}})]}});js.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new Ar({key:new Wr("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!==null&&t!==void 0?t:"0"}}}})]}});js.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=rTe(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 Ar({key:new Wr("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}});function Y1(t){return new w5({find:t.find,handler:({state:e,range:r,match:n})=>{const s=wf(t.getAttributes,void 0,n);if(s===!1||s===null)return null;const{tr:i}=e,a=n[n.length-1],l=n[0];if(a){const c=l.search(/\S/),u=r.from+l.indexOf(a),d=u+a.length;if(sTe(r.from,r.to,e.doc).filter(f=>f.mark.type.excluded.find(p=>p===t.type&&p!==f.mark.type)).filter(f=>f.to>u).length)return null;d<r.to&&i.delete(d,r.to),u>r.from&&i.delete(r.from+c,u);const h=r.from+c+a.length;i.addMark(r.from+c,h,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function rBt(t){return new w5({find:t.find,handler:({state:e,range:r,match:n})=>{const s=wf(t.getAttributes,void 0,n)||{},{tr:i}=e,a=r.from;let l=r.to;const c=t.type.create(s);if(n[1]){let u=a+n[0].lastIndexOf(n[1]);u>l?u=l:l=u+n[1].length;const d=n[0][n[0].length-1];i.insertText(d,a+n[0].length-1),i.replaceWith(u,l,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(l))}i.scrollIntoView()},undoable:t.undoable})}function v7(t){return new w5({find:t.find,handler:({state:e,range:r,match:n})=>{const s=e.doc.resolve(r.from),i=wf(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 X1(t){return new w5({find:t.find,handler:({state:e,range:r,match:n,chain:s})=>{const i=wf(t.getAttributes,void 0,n)||{},a=e.tr.delete(r.from,r.to),l=a.doc.resolve(r.from).blockRange(),c=l&&GG(l,t.type,i);if(!c)return null;if(a.wrap(l,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>f.includes(g.type.name));a.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,i).run()}const u=a.doc.resolve(r.from-1).nodeBefore;u&&u.type===t.type&&Ed(a.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,u))&&a.join(r.from-1)},undoable:t.undoable})}var yl=class fTe extends jK{constructor(...e){super(...e),this.type="node"}static create(e={}){const r=typeof e=="function"?e():e;return new fTe(r)}configure(e){return super.configure(e)}extend(e){const r=typeof e=="function"?e():e;return super.extend(r)}};function Q1(t){return new eBt({find:t.find,handler:({state:e,range:r,match:n,pasteEvent:s})=>{const i=wf(t.getAttributes,void 0,n,s);if(i===!1||i===null)return null;const{tr:a}=e,l=n[n.length-1],c=n[0];let u=r.to;if(l){const d=c.search(/\S/),h=r.from+c.indexOf(l),f=h+l.length;if(sTe(r.from,r.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===t.type&&m!==p.mark.type)).filter(p=>p.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+l.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)}}})}const pTe=new WeakSet,mTe=new WeakSet;function Mg(t){const e=t;return pTe.add(e),e}function b7(t){return Array.isArray(t)&&pTe.has(t)}function gTe(t){return t.flatMap(e=>e==null?[]:Array.isArray(e)&&mTe.has(e)&&!b7(e)?gTe(e):[e])}function nBt(t,e){if(t==="slot")return 0;if(t instanceof Function){const s=t(e);return Array.isArray(s)&&!b7(s)&&!mTe.has(s)?Mg(s):s}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");if(Array.isArray(r)){if(b7(r))return Mg([t,n,r]);if(r.length===0)return Mg([t,n]);const s=gTe(r);return s.length===0?Mg([t,n]):Mg([t,n,...s])}return r!=null?Mg([t,n,r]):Mg([t,n])}const NO=(t,e)=>nBt(t,e),sBt=(t,e)=>{var r;const{state:n}=t,{selection:s}=n;if(!s.empty)return!1;const{$from:i}=s;if(i.parentOffset!==0)return!1;const a=i.depth-1;if(a<0)return!1;const l=i.node(a),c=i.index(a);if(c===0)return!1;if(l.type===e)return t.commands.lift(e.name);const u=l.child(c-1);if(u.type!==e||!(!((r=u.lastChild)===null||r===void 0)&&r.isTextblock))return!1;const d=i.before()-1-1;return t.commands.command(({tr:h,dispatch:f})=>{if(!f)return!0;const p=i.parent.content,m=new at(p,0,0);return h.replace(d,i.after(),m),h.setSelection(ht.create(h.doc,d+p.size)),h.scrollIntoView(),f(h),!0})},iBt=/^\s*>\s$/,aBt=yl.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return NO("blockquote",{...Ia(this.options.HTMLAttributes,t),children:NO("slot",{})})},parseMarkdown:(t,e)=>{var r;const n=(r=e.parseBlockChildren)!==null&&r!==void 0?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,l;const c=((a=(l=e.renderChild)===null||l===void 0?void 0:l.call(e,s,i))!==null&&a!==void 0?a:e.renderChildren([s])).split(`
`).map(u=>u.trim()===""?r:`${r} ${u}`);n.push(c.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:()=>sBt(this.editor,this.type)}},addInputRules(){return[X1({find:iBt,type:this.type})]}}),oBt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,lBt=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,cBt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,uBt=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,dBt=j5.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 NO("strong",{...Ia(this.options.HTMLAttributes,t),children:NO("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[Y1({find:oBt,type:this.type}),Y1({find:cBt,type:this.type})]},addPasteRules(){return[Q1({find:lBt,type:this.type}),Q1({find:uBt,type:this.type})]}}),hBt=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},fBt=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};function pBt(t){const e=new Set((t.match(/`+/g)||[]).map(n=>n.length));let r=1;for(;e.has(r);)r+=1;return r}const mBt=j5.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Ia(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e,r)=>{var n;if(!t.content)return"";const s=typeof(r==null||(n=r.meta)===null||n===void 0?void 0:n.markText)=="string"?r.meta.markText:"",i="`".repeat(pBt(s)),a=s.startsWith("`")||s.endsWith("`")?" ":"";return`${i}${a}${e.renderChildren(t.content)}${a}${i}`},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[Y1({find:hBt,type:this.type})]},addPasteRules(){return[Q1({find:fBt,type:this.type})]}}),a6=4,gBt=/^```([a-z]+)?[\s\n]$/,xBt=/^~~~([a-z]+)?[\s\n]$/,yBt=yl.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:a6,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 n=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(r)).map(s=>s.replace(r,""))[0];return n||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Ia(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||r===void 0?void 0:r.startsWith("```"))===!1&&((n=t.raw)===null||n===void 0?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||r===void 0?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!==void 0?e:a6,{state:n}=t,{selection:s}=n,{$from:i,empty:a}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(r);return a?t.commands.insertContent(l):t.commands.command(({tr:c})=>{const{from:u,to:d}=s,h=n.doc.textBetween(u,d,`
`,`
`).split(`
`).map(f=>l+f).join(`
`);return c.replaceWith(u,d,n.schema.text(h)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const r=(e=this.options.tabSize)!==null&&e!==void 0?e:a6,{state:n}=t,{selection:s}=n,{$from:i,empty:a}=s;return i.parent.type!==this.type?!1:a?t.commands.command(({tr:l})=>{var c;const{pos:u}=i,d=i.start(),h=i.end(),f=n.doc.textBetween(d,h,`
`,`
`).split(`
`);let p=0,m=0;const g=u-d;for(let b=0;b<f.length;b+=1){if(m+f[b].length>=g){p=b;break}m+=f[b].length+1}const y=((c=f[p].match(/^ */))===null||c===void 0?void 0:c[0])||"",x=Math.min(y.length,r);if(x===0)return!0;let v=d;for(let b=0;b<p;b+=1)v+=f[b].length+1;return l.delete(v,v+x),u-v<=x&&l.setSelection(ht.create(l.doc,v)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=s,d=n.doc.textBetween(c,u,`
`,`
`).split(`
`).map(h=>{var f;const p=((f=h.match(/^ */))===null||f===void 0?void 0:f[0])||"",m=Math.min(p.length,r);return h.slice(m)}).join(`
`);return l.replaceWith(c,u,n.schema.text(d)),!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:l})=>(l.delete(n.pos-2,n.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=t,{selection:r}=e,{$from:n,empty:s}=r;if(!s||n.parent.type!==this.type||n.parentOffset!==0)return!1;const i=n.before();return i>0?!1:t.commands.insertDefaultBlock({pos:i})},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 a=s.after();return a===void 0?!1:n.nodeAt(a)?t.commands.command(({tr:l})=>(l.setSelection(Mt.near(n.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[v7({find:gBt,type:this.type,getAttributes:t=>({language:t[1]})}),v7({find:xBt,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ar({key:new Wr("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:l}=t.state,c=l.text(r.replace(/\r\n?/g,`
`));return a.replaceSelectionWith(this.type.create({language:i},c)),a.selection.$from.parent.type!==this.type&&a.setSelection(ht.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),t.dispatch(a),!0}}})]}}),vBt=yl.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`

`):""}),bBt=yl.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",Ia(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:l}=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=>l.includes(f.type.name));u.ensureMarks(h)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),wBt=yl.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]}`,Ia(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===void 0)&&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=>v7({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),jBt=yl.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Ia(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!Z6t(e,e.schema.nodes[this.name]))return!1;const{selection:r}=e,{$to:n}=r,s=t();return iTe(r)?s.insertContentAt(n.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:a,dispatch:l})=>{if(l){const{$to:c}=a.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?a.setSelection(ht.create(a.doc,c.pos+1)):c.nodeAfter.isBlock?a.setSelection(Pt.create(a.doc,c.pos)):a.setSelection(ht.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(ht.create(a.doc,u+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[rBt({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),SBt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,_Bt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,NBt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,kBt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,CBt=j5.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",Ia(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[Y1({find:SBt,type:this.type}),Y1({find:NBt,type:this.type})]},addPasteRules(){return[Q1({find:_Bt,type:this.type}),Q1({find:kBt,type:this.type})]}}),EBt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",ABt="ελ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",w7="numeric",j7="ascii",S7="alpha",Z_="asciinumeric",y_="alphanumeric",_7="domain",xTe="emoji",TBt="scheme",PBt="slashscheme",o6="whitespace";function IBt(t,e){return t in e||(e[t]=[]),e[t]}function vx(t,e,r){e[w7]&&(e[Z_]=!0,e[y_]=!0),e[j7]&&(e[Z_]=!0,e[S7]=!0),e[Z_]&&(e[y_]=!0),e[S7]&&(e[y_]=!0),e[y_]&&(e[_7]=!0),e[xTe]&&(e[_7]=!0);for(const n in e){const s=IBt(n,r);s.indexOf(t)<0&&s.push(t)}}function RBt(t,e){const r={};for(const n in e)e[n].indexOf(t)>=0&&(r[n]=!0);return r}function go(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}go.groups={};go.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||go.groups;let s;return e&&e.j?s=e:(s=new go(e),r&&n&&vx(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||go.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let a,l=s.go(t);if(l?(a=new go,Object.assign(a.j,l.j),a.jr.push.apply(a.jr,l.jr),a.jd=l.jd,a.t=l.t):a=new go,i){if(n)if(a.t&&typeof a.t=="string"){const c=Object.assign(RBt(a.t,n),r);vx(i,c,n)}else r&&vx(i,r,n);a.t=i}return s.j[t]=a,a}};const dr=(t,e,r,n,s)=>t.ta(e,r,n,s),us=(t,e,r,n,s)=>t.tr(e,r,n,s),kle=(t,e,r,n,s)=>t.ts(e,r,n,s),et=(t,e,r,n,s)=>t.tt(e,r,n,s),Hd="WORD",N7="UWORD",yTe="ASCIINUMERICAL",vTe="ALPHANUMERICAL",Fk="LOCALHOST",k7="TLD",C7="UTLD",WP="SCHEME",Ab="SLASH_SCHEME",SK="NUM",E7="WS",_K="NL",J_="OPENBRACE",eN="CLOSEBRACE",kO="OPENBRACKET",CO="CLOSEBRACKET",EO="OPENPAREN",AO="CLOSEPAREN",TO="OPENANGLEBRACKET",PO="CLOSEANGLEBRACKET",IO="FULLWIDTHLEFTPAREN",RO="FULLWIDTHRIGHTPAREN",OO="LEFTCORNERBRACKET",MO="RIGHTCORNERBRACKET",DO="LEFTWHITECORNERBRACKET",LO="RIGHTWHITECORNERBRACKET",$O="FULLWIDTHLESSTHAN",FO="FULLWIDTHGREATERTHAN",BO="AMPERSAND",zO="APOSTROPHE",UO="ASTERISK",cp="AT",HO="BACKSLASH",WO="BACKTICK",VO="CARET",bx="COLON",NK="COMMA",qO="DOLLAR",Su="DOT",GO="EQUALS",kK="EXCLAMATION",Cl="HYPHEN",tN="PERCENT",KO="PIPE",YO="PLUS",XO="POUND",rN="QUERY",CK="QUOTE",bTe="FULLWIDTHMIDDLEDOT",EK="SEMI",_u="SLASH",nN="TILDE",QO="UNDERSCORE",wTe="EMOJI",ZO="SYM";var jTe=Object.freeze({__proto__:null,ALPHANUMERICAL:vTe,AMPERSAND:BO,APOSTROPHE:zO,ASCIINUMERICAL:yTe,ASTERISK:UO,AT:cp,BACKSLASH:HO,BACKTICK:WO,CARET:VO,CLOSEANGLEBRACKET:PO,CLOSEBRACE:eN,CLOSEBRACKET:CO,CLOSEPAREN:AO,COLON:bx,COMMA:NK,DOLLAR:qO,DOT:Su,EMOJI:wTe,EQUALS:GO,EXCLAMATION:kK,FULLWIDTHGREATERTHAN:FO,FULLWIDTHLEFTPAREN:IO,FULLWIDTHLESSTHAN:$O,FULLWIDTHMIDDLEDOT:bTe,FULLWIDTHRIGHTPAREN:RO,HYPHEN:Cl,LEFTCORNERBRACKET:OO,LEFTWHITECORNERBRACKET:DO,LOCALHOST:Fk,NL:_K,NUM:SK,OPENANGLEBRACKET:TO,OPENBRACE:J_,OPENBRACKET:kO,OPENPAREN:EO,PERCENT:tN,PIPE:KO,PLUS:YO,POUND:XO,QUERY:rN,QUOTE:CK,RIGHTCORNERBRACKET:MO,RIGHTWHITECORNERBRACKET:LO,SCHEME:WP,SEMI:EK,SLASH:_u,SLASH_SCHEME:Ab,SYM:ZO,TILDE:nN,TLD:k7,UNDERSCORE:QO,UTLD:C7,UWORD:N7,WORD:Hd,WS:E7});const Dd=/[a-z]/,CS=new RegExp("\\p{L}","u"),l6=new RegExp("\\p{Emoji}","u"),Ld=/\d/,c6=/\s/,Cle="\r",u6=`
`,OBt="️",MBt="‍",d6="";let u2=null,d2=null;function DBt(t=[]){const e={};go.groups=e;const r=new go;u2==null&&(u2=Ele(EBt)),d2==null&&(d2=Ele(ABt)),et(r,"'",zO),et(r,"{",J_),et(r,"}",eN),et(r,"[",kO),et(r,"]",CO),et(r,"(",EO),et(r,")",AO),et(r,"<",TO),et(r,">",PO),et(r,"(",IO),et(r,")",RO),et(r,"「",OO),et(r,"」",MO),et(r,"『",DO),et(r,"』",LO),et(r,"<",$O),et(r,">",FO),et(r,"&",BO),et(r,"*",UO),et(r,"@",cp),et(r,"`",WO),et(r,"^",VO),et(r,":",bx),et(r,",",NK),et(r,"$",qO),et(r,".",Su),et(r,"=",GO),et(r,"!",kK),et(r,"-",Cl),et(r,"%",tN),et(r,"|",KO),et(r,"+",YO),et(r,"#",XO),et(r,"?",rN),et(r,'"',CK),et(r,"/",_u),et(r,";",EK),et(r,"~",nN),et(r,"_",QO),et(r,"\\",HO),et(r,"・",bTe);const n=us(r,Ld,SK,{[w7]:!0});us(n,Ld,n);const s=us(n,Dd,yTe,{[Z_]:!0}),i=us(n,CS,vTe,{[y_]:!0}),a=us(r,Dd,Hd,{[j7]:!0});us(a,Ld,s),us(a,Dd,a),us(s,Ld,s),us(s,Dd,s);const l=us(r,CS,N7,{[S7]:!0});us(l,Dd),us(l,Ld,i),us(l,CS,l),us(i,Ld,i),us(i,Dd),us(i,CS,i);const c=et(r,u6,_K,{[o6]:!0}),u=et(r,Cle,E7,{[o6]:!0}),d=us(r,c6,E7,{[o6]:!0});et(r,d6,d),et(u,u6,c),et(u,d6,d),us(u,c6,d),et(d,Cle),et(d,u6),us(d,c6,d),et(d,d6,d);const h=us(r,l6,wTe,{[xTe]:!0});et(h,"#"),us(h,l6,h),et(h,OBt,h);const f=et(h,MBt);et(f,"#"),us(f,l6,h);const p=[[Dd,a],[Ld,s]],m=[[Dd,null],[CS,l],[Ld,i]];for(let g=0;g<u2.length;g++)Yf(r,u2[g],k7,Hd,p);for(let g=0;g<d2.length;g++)Yf(r,d2[g],C7,N7,m);vx(k7,{tld:!0,ascii:!0},e),vx(C7,{utld:!0,alpha:!0},e),Yf(r,"file",WP,Hd,p),Yf(r,"mailto",WP,Hd,p),Yf(r,"http",Ab,Hd,p),Yf(r,"https",Ab,Hd,p),Yf(r,"ftp",Ab,Hd,p),Yf(r,"ftps",Ab,Hd,p),vx(WP,{scheme:!0,ascii:!0},e),vx(Ab,{slashscheme:!0,ascii:!0},e),t=t.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<t.length;g++){const y=t[g][0],v=t[g][1]?{[TBt]:!0}:{[PBt]:!0};y.indexOf("-")>=0?v[_7]=!0:Dd.test(y)?Ld.test(y)?v[Z_]=!0:v[j7]=!0:v[w7]=!0,kle(r,y,y,v)}return kle(r,"localhost",Fk,{ascii:!0}),r.jd=new go(ZO),{start:r,tokens:Object.assign({groups:e},jTe)}}function STe(t,e){const r=LBt(e.replace(/[A-Z]/g,l=>l.toLowerCase())),n=r.length,s=[];let i=0,a=0;for(;a<n;){let l=t,c=null,u=0,d=null,h=-1,f=-1;for(;a<n&&(c=l.go(r[a]));)l=c,l.accepts()?(h=0,f=0,d=l):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 LBt(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 Yf(t,e,r,n,s){let i;const a=e.length;for(let l=0;l<a-1;l++){const c=e[l];t.j[c]?i=t.j[c]:(i=new go(n),i.jr=s.slice(),t.j[c]=i),t=i}return i=new go(r),i.jr=s.slice(),t.j[e[a-1]]=i,i}function Ele(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 Bk={defaultProtocol:"http",events:null,format:Ale,formatHref:Ale,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function AK(t,e=null){let r=Object.assign({},Bk);t&&(r=Object.assign(r,t instanceof AK?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}AK.prototype={o:Bk,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]:Bk[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 Ale(t){return t}function _Te(t,e){this.t="token",this.v=t,this.tk=e}_Te.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=Bk.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={},l=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,l&&(a.class=l),c&&(a.target=c),u&&(a.rel=u),d&&Object.assign(a,d),{tagName:s,attributes:a,content:i,eventListeners:h}}};function S5(t,e){class r extends _Te{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 $Bt=S5("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Tle=S5("text"),FBt=S5("nl"),h2=S5("url",{isLink:!0,toHref(t=Bk.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Fk&&t[1].t===bx}}),Nl=t=>new go(t);function BBt({groups:t}){const e=t.domain.concat([BO,UO,cp,HO,WO,VO,qO,GO,Cl,SK,tN,KO,YO,XO,_u,ZO,nN,QO]),r=[zO,bx,NK,Su,kK,tN,rN,CK,EK,TO,PO,J_,eN,CO,kO,EO,AO,IO,RO,OO,MO,DO,LO,$O,FO],n=[BO,zO,UO,HO,WO,VO,qO,GO,Cl,J_,eN,tN,KO,YO,XO,rN,_u,ZO,nN,QO],s=Nl(),i=et(s,nN);dr(i,n,i),dr(i,t.domain,i);const a=Nl(),l=Nl(),c=Nl();dr(s,t.domain,a),dr(s,t.scheme,l),dr(s,t.slashscheme,c),dr(a,n,i),dr(a,t.domain,a);const u=et(a,cp);et(i,cp,u),et(l,cp,u),et(c,cp,u);const d=et(i,Su);dr(d,n,i),dr(d,t.domain,i);const h=Nl();dr(u,t.domain,h),dr(h,t.domain,h);const f=et(h,Su);dr(f,t.domain,h);const p=Nl($Bt);dr(f,t.tld,p),dr(f,t.utld,p),et(u,Fk,p);const m=et(h,Cl);et(m,Cl,m),dr(m,t.domain,h),dr(p,t.domain,h),et(p,Su,f),et(p,Cl,m);const g=et(a,Cl),y=et(a,Su);et(g,Cl,g),dr(g,t.domain,a),dr(y,n,i),dr(y,t.domain,a);const x=Nl(h2);dr(y,t.tld,x),dr(y,t.utld,x),dr(x,t.domain,a),dr(x,n,i),et(x,Su,y),et(x,Cl,g),et(x,cp,u);const v=et(x,bx),b=Nl(h2);dr(v,t.numeric,b);const w=Nl(h2),j=Nl();dr(w,e,w),dr(w,r,j),dr(j,e,w),dr(j,r,j),et(x,_u,w),et(b,_u,w);const N=et(l,bx),C=et(c,bx),A=et(C,_u),E=et(A,_u);dr(l,t.domain,a),et(l,Su,y),et(l,Cl,g),dr(c,t.domain,a),et(c,Su,y),et(c,Cl,g),dr(N,t.domain,w),et(N,_u,w),et(N,rN,w),dr(E,t.domain,w),dr(E,e,w),et(E,_u,w);const O=[[J_,eN],[kO,CO],[EO,AO],[TO,PO],[IO,RO],[OO,MO],[DO,LO],[$O,FO]];for(let $=0;$<O.length;$++){const[T,M]=O[$],k=et(w,T);et(j,T,k);const D=Nl(h2);dr(k,e,D);const K=Nl();dr(k,r,K),et(k,M,w),dr(D,e,D),dr(D,r,K),dr(K,e,D),dr(K,r,K),et(D,M,w),et(K,M,w)}return et(s,Fk,x),et(s,_K,FBt),{start:s,tokens:jTe}}function zBt(t,e,r){let n=r.length,s=0,i=[],a=[];for(;s<n;){let l=t,c=null,u=null,d=0,h=null,f=-1;for(;s<n&&!(c=l.go(r[s].t));)a.push(r[s++]);for(;s<n&&(u=c||l.go(r[s].t));)c=null,l=u,l.accepts()?(f=0,h=l):f>=0&&f++,s++,d++;if(f<0)s-=d,s<n&&(a.push(r[s]),s++);else{a.length>0&&(i.push(h6(Tle,e,a)),a=[]),s-=f,d-=f;const p=h.t,m=r.slice(s-d,s);i.push(h6(p,e,m))}}return a.length>0&&i.push(h6(Tle,e,a)),i}function h6(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 UBt=typeof console<"u"&&console&&console.warn||(()=>{}),HBt="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Dn={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function WBt(){return go.groups={},Dn.scanner=null,Dn.parser=null,Dn.tokenQueue=[],Dn.pluginQueue=[],Dn.customSchemes=[],Dn.initialized=!1,Dn}function Ple(t,e=!1){if(Dn.initialized&&UBt(`linkifyjs: already initialized - will not register custom scheme "${t}" ${HBt}`),!/^[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`);Dn.customSchemes.push([t,e])}function VBt(){Dn.scanner=DBt(Dn.customSchemes);for(let t=0;t<Dn.tokenQueue.length;t++)Dn.tokenQueue[t][1]({scanner:Dn.scanner});Dn.parser=BBt(Dn.scanner.tokens);for(let t=0;t<Dn.pluginQueue.length;t++)Dn.pluginQueue[t][1]({scanner:Dn.scanner,parser:Dn.parser});return Dn.initialized=!0,Dn}function TK(t){return Dn.initialized||VBt(),zBt(Dn.parser.start,t,STe(Dn.scanner.start,t))}TK.scan=STe;function NTe(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 AK(r),s=TK(t),i=[];for(let a=0;a<s.length;a++){const l=s[a];l.isLink&&(!e||l.t===e)&&n.check(l)&&i.push(l.toFormattedObject(n))}return i}var PK="[\0-   ᠎ -\u2029  ]",qBt=new RegExp(PK),GBt=new RegExp(`${PK}$`),KBt=new RegExp(PK,"g");function YBt(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function XBt(t){return new Ar({key:new Wr("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,l=sAe(r.doc,[...e]);if(hAe(l).forEach(({newRange:u})=>{const d=m3t(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(!GBt.test(p))return;h=d[0],f=n.doc.textBetween(h.pos,u.to,void 0," ")}if(h&&f){const p=f.split(qBt).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 y=TK(m).map(x=>x.toObject(t.defaultProtocol));if(!YBt(y))return!1;y.filter(x=>x.isLink).map(x=>({...x,from:g+x.start+1,to:g+x.end+1})).filter(x=>n.schema.marks.code?!n.doc.rangeHasMark(x.from,x.to,n.schema.marks.code):!0).filter(x=>t.validate(x.value)).filter(x=>t.shouldAutoLink(x.value)).forEach(x=>{fAe(x.from,x.to,n.doc).some(v=>v.mark.type===t.type)||a.addMark(x.from,x.to,t.type.create({href:x.href}))})}}),!!a.steps.length)return a}})}function QBt(t){return new Ar({key:new Wr("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 l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const c=dAe(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),l=!0)}return l}}})}function ZBt(t){return new Ar({key:new Wr("handlePasteLink"),props:{handlePaste:(e,r,n)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:a}=i,{empty:l}=a;if(l)return!1;let c="";n.content.forEach(d=>{c+=d.textContent});const u=NTe(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 Dg(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(KBt,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var kTe=gK.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"){Ple(t);return}Ple(t.scheme,t.optionalSlashes)})},onDestroy(){WBt()},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)=>!!Dg(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=>!!Dg(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=>!!Dg(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",su(this.options.HTMLAttributes,t),0]:["a",su(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:"",l=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",c=e.renderChildren(t);return l?`[${c}](${a} "${l}")`:`[${c}](${a})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!Dg(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=>!!Dg(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[C$t({find:t=>{const e=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,s=NTe(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:a=>!!Dg(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(XBt({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:s=>!!Dg(s,e),protocols:e,defaultProtocol:r}),shouldAutoLink:this.options.shouldAutoLink})),t.push(QBt({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(ZBt({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),JBt=kTe;const e8t="listItem",Ile="textStyle",Rle=/^\s*([-+*])\s$/,CTe=yl.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",Ia(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(e8t,this.editor.getAttributes(Ile)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=X1({find:Rle,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=X1({find:Rle,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ile),editor:this.editor})),[t]}}),t8t=(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),l=s.index(i);if(l+1>=a.childCount)return null;const c=a.child(l+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}},r8t=(t,e,r,n)=>{const s=t8t(t,r,n);if(!s)return!1;const{selection:i}=t,{nestedList:a,nestedListPos:l,insertPos:c,items:u}=s,d=t.tr;d.delete(l,l+a.nodeSize);const h=d.mapping.map(c);return d.insert(h,Me.from(u)),d.setSelection(i.map(d.doc,d.mapping)),e&&e(d),!0},n8t=(t,e,r)=>r8t(t.state,t.view.dispatch,e,r),ETe=(t,e)=>js.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const r=()=>n8t(this.editor,t,e);return{Delete:r,"Mod-Delete":r}}}),ATe=[[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"]],f2="abcdefghijklmnopqrstuvwxyz",TTe=String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`;function _5(t){let e=t,r="";for(const[n,s]of ATe)for(;e>=n;)r+=s,e-=n;return r}function IK(t){return _5(t).toUpperCase()}function PTe(t){const e=t.toLowerCase();let r=0,n=0;for(;r<e.length;){let s=!1;for(const[i,a]of ATe)if(e.startsWith(a,r)){n+=i,r+=a.length,s=!0;break}if(!s)return 0}return n}function s8t(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=PTe(t);return e<=0?!1:(t===t.toLowerCase()?_5(e):IK(e))===t}function i8t(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 JO(t){if(t<=26)return f2[t-1];const e=Math.floor((t-1)/26)-1,r=(t-1)%26;return e<0?f2[r]:f2[e]+f2[r]}function N5(t){if(!(!t||/^\d+$/.test(t))){if(s8t(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 RK(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=N5(t);if(e==="i"||e==="I")return PTe(t);if(e==="a"||e==="A"){const n=i8t(t);return n>0?n:1}const r=parseInt(t,10);return Number.isNaN(r)?1:r}function a8t(t,e){if(t==="numeric")return String(e);switch(t){case"a":return JO(e);case"A":return JO(e).toUpperCase();case"i":return _5(e);case"I":return IK(e);default:return String(e)}}function o8t(t){var e;if(t.length===0)return!1;const r=(e=N5(t[0]))!==null&&e!==void 0?e:"numeric",n=RK(t[0]);if(n<1)return!1;for(let s=0;s<t.length;s++){const i=a8t(r,n+s);if(t[s]!==i)return!1}return!0}function l8t(t){return{type:N5(t),start:RK(t)}}function c8t(t){const{type:e,start:r}=l8t(t),n={};return e&&(n.type=e),r!==1&&(n.start=r),n}function u8t(t,e,r=". "){const n=e+1;if(!t||t==="1")return`${n}${r}`;switch(t){case"a":return`${JO(n)}${r}`;case"A":return`${JO(n).toUpperCase()}${r}`;case"i":return`${_5(n)}${r}`;case"I":return`${IK(n)}${r}`;default:return`${n}${r}`}}function d8t(t){var e,r;const n=(e=t.tokens)===null||e===void 0?void 0:e[0];return!!(t.text&&((r=t.tokens)===null||r===void 0?void 0:r.length)===1&&(n==null?void 0:n.type)==="list"&&n.ordered&&n.raw===t.text)}function h8t(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}const ITe=yl.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ia(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!==void 0?r:e.parseChildren;let s=[];if(t.tokens&&t.tokens.length>0){if(d8t(t))return{type:"listItem",content:[{type:"paragraph",content:h8t(t.text||"",e)}]};if(t.tokens.some(i=>i.type==="paragraph"))s=n(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(i.tokens)}],t.tokens.length>1){const a=n(t.tokens.slice(1));s.push(...a)}}else s=n(t.tokens)}}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(t,e,r)=>cTe(t,e,n=>{if(n.parentType==="bulletList")return"- ";if(n.parentType==="orderedList"){var s,i;const a=((s=n.meta)===null||s===void 0||(s=s.parentAttrs)===null||s===void 0?void 0:s.start)||1;return u8t((i=n.meta)===null||i===void 0||(i=i.parentAttrs)===null||i===void 0?void 0:i.type,a-1+(n.index||0),". ")}return"- "},r,{alignNestedToPrefix:(r==null?void 0:r.parentType)==="orderedList"}),addExtensions(){return[ETe(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)}}}),OK=(t,e)=>{const{$from:r}=e.selection,n=da(t,e.schema);let s=null,i=r.depth,a=r.pos,l=null;for(;i>0&&l===null;)s=r.node(i),s.type===n?l=i:(i-=1,a-=1);return l===null?null:{$pos:e.doc.resolve(a),depth:l}},RTe=(t,e)=>{const r=OK(t,e);if(!r)return!1;const[,n]=v6t(e,t,r.$pos.pos+4);return n},f8t=(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))},Ole=(t,e,r)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Sv(t.state,e)&&f8t(t.state,e,r)){const{$anchor:i}=t.state.selection,a=t.state.doc.resolve(i.before()-1),l=[];a.node().descendants((d,h)=>{d.type.name===e&&l.push({node:d,pos:h})});const c=l.at(-1);if(!c)return!1;const u=t.state.doc.resolve(a.start()+c.pos+1);return t.chain().cut({from:i.start()-1,to:i.end()+1},u.end()).joinForward().run()}if(!Sv(t.state,e)||!S6t(t.state))return!1;const{$from:n}=t.state.selection,s=n.depth-1;return n.node(s).type!==t.schema.nodes[e]||n.index(s)!==0?!1:t.chain().liftListItem(e).run()},p8t=(t,e)=>{const r=RTe(t,e),n=OK(t,e);return!n||!r?!1:r>n.depth},m8t=(t,e)=>{const r=RTe(t,e),n=OK(t,e);return!n||!r?!1:r<n.depth},Mle=(t,e)=>{if(!Sv(t.state,e)||!j6t(t.state,e))return!1;const{selection:r}=t.state,{$from:n,$to:s}=r;return!r.empty&&n.sameParent(s)?!1:p8t(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():m8t(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},g8t=(t,e,r)=>{const{state:n}=t,{selection:s}=n;if(!s.empty)return!1;const{$from:i}=s;if(i.parentOffset!==0||!i.parent.isTextblock||Sv(n,e))return!1;const a=b6t(i);if(!a||!r.includes(a.type.name))return!1;const l=a.lastChild;if(!l||l.type.name!==e)return!1;const c=i.parent;if(!l.canReplace(l.childCount,l.childCount,Me.from(c)))return!1;const u=i.before(),d=i.after(),h=u-2;return t.commands.command(({tr:f,dispatch:p})=>(p&&(f.delete(u,d).insert(h,Me.from(c)),f.setSelection(ht.create(f.doc,h+1)),f.scrollIntoView()),!0))},OTe=js.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&&Mle(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&&Mle(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&&Ole(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&&Ole(t,r,n)&&(e=!0)}),e},Tab:({editor:t})=>{for(const{itemName:e,wrapperNames:r}of this.options.listTypes)if(t.state.schema.nodes[e]!==void 0&&g8t(t,e,r))return!0;return!1}}}}),eM=new RegExp(`^(\\s*)(${TTe})([.)])\\s+(.*)$`),x8t=/^\s/,Tb={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function y8t(t){return eM.test(t.trimStart())}function v8t(t){const e=t.trimStart();return Tb.bulletItem.test(e)||y8t(e)||Tb.heading.test(e)||Tb.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Tb.codeFence.test(e)||Tb.blockMath.test(e)}function b8t(t){return Object.values(Tb).some(e=>e.test(t))}function w8t(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&&v8t(s)){n=!0,r.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:r}}function Dle(t){const e=[];let r=0,n=0;for(;r<t.length;){const s=t[r],i=s.match(eM);if(!i)break;const[,a,l,c,u]=i,d=a.length,h=parseInt(l,10),f=isNaN(h)?N5(l):void 0,p=isNaN(h)?RK(l):h,m=[u];let g=r+1;const y=[s];let x=!1;for(;g<t.length;){const v=t[g];if(v.match(eM))break;if(v.trim()==="")y.push(v),m.push(""),x=!0,g+=1;else if(v.match(x8t)){const b=v.length-v.trimStart().length,w=d+l.length+1;y.push(v),m.push(v.slice(Math.min(b,w))),g+=1}else{if(x||b8t(v))break;y.push(v),m.push(v),g+=1}}e.push({indent:d,number:p,type:f,content:m.join(`
`).trim(),contentLines:m,raw:y.join(`
`)}),n=g,r=g}return[e,n]}const j8t=new RegExp(`^(${TTe})([.)])\\s+(.+)$`);function S8t(t){const e=t.split(`
`).filter(n=>n.trim().length>0);if(e.length===0)return null;const r=[];for(const n of e){const s=n.trim().match(j8t);if(!s)return null;r.push({marker:s[1],content:s[3]})}return o8t(r.map(n=>n.marker))?{type:"orderedList",attrs:c8t(r[0].marker),content:r.map(n=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:n.content}]}]}))}:null}function MTe(t,e,r){const n=[];let s=0;for(;s<t.length;){const i=t[s];if(i.indent===e){const{paragraphLines:a,blockLines:l}=w8t(i.contentLines),c=a.join(`
`).trim(),u=[];c&&u.push({type:"paragraph",raw:c,tokens:r.inlineTokens(c)});const d=l.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=MTe(f,Math.min(...f.map(m=>m.indent)),r);u.push({type:"list",ordered:!0,start:f[0].number,typeMarker:f[0].type,items:p,raw:f.map(m=>m.raw).join(`
`)})}n.push({type:"list_item",raw:i.raw,tokens:u}),s=h}else s+=1}return n}function _8t(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}})}const N8t=64;function Lle(t,e){const r=[];let n=0;for(;r.length<e;){const s=t.indexOf(`
`,n);if(s===-1)return r.push(t.slice(n)),r;r.push(t.slice(n,s)),n=s+1}return r}function k8t(t){const e=t.indexOf(`
`),r=e===-1?t:t.slice(0,e);if(!eM.test(r))return[[],0,[]];let n=N8t,s=Lle(t,n),i=Dle(s);for(;i[1]===s.length&&s.length===n;)n*=2,s=Lle(t,n),i=Dle(s);return[i[0],i[1],s]}const C8t="listItem",$le="textStyle",Fle=/^(\d+)\.\s$/;function Ble(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}}const DTe=yl.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=Ble(r);if(s)return s}const n=t.querySelector("li");if(n){const s=n.getAttribute("style");if(s){const i=Ble(s);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,type:r,...n}=t,s=Ia(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?_8t(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:()=>-1,tokenize:(t,e,r)=>{var n,s;const[i,a,l]=k8t(t);if(i.length===0)return;const c=MTe(i,i[0].indent,r);if(c.length!==0)return{type:"list",ordered:!0,start:((n=i[0])===null||n===void 0?void 0:n.number)||1,typeMarker:(s=i[0])===null||s===void 0?void 0:s.type,items:c,raw:l.slice(0,a).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(C8t,this.editor.getAttributes($le)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new Ar({props:{handlePaste:(t,e)=>{var r,n;const s=(r=e.clipboardData)===null||r===void 0?void 0:r.getData("text/html");if(s!=null&&s.trim())return!1;const i=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/plain");if(!i)return!1;const a=S8t(i);if(!a)return!1;try{const l=t.state.schema.nodeFromJSON(a),c=t.state.tr.replaceSelectionWith(l);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=X1({find:Fle,type:this.type,getAttributes:r=>({start:+r[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=X1({find:Fle,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:r=>({start:+r[1],...this.editor.getAttributes($le)}),joinPredicate:t,editor:this.editor})),[e]}}),E8t=/^\s*(\[([( |x])?\])\s$/,A8t="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0",T8t=(t,e,r)=>{var n;return(r==null||(n=r.checkboxLabel)===null||n===void 0?void 0:n.call(r,t,e))||`Task item checkbox for ${t.textContent||"empty task item"}`},P8t=yl.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,contentElement:t=>{var e;return(e=t.querySelector("div"))!==null&&e!==void 0?e:t}}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Ia(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 n=`- [${!((r=t.attrs)===null||r===void 0)&&r.checked?"x":" "}] `;return cTe(t,e,n)},addExtensions(){return this.options.nested?[ETe(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"),l=document.createElement("input"),c=document.createElement("div");a.style.cssText=A8t;const u=h=>{const f=T8t(h,h.attrs.checked,this.options.a11y);l.setAttribute("aria-label",f),a.textContent=f};u(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",h=>h.preventDefault()),l.addEventListener("change",h=>{if(!n.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.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)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,f])=>{s.setAttribute(h,f)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,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,l.checked=h.attrs.checked,u(h);const f=n.extensionManager.attributes,p=p6t(h,f),m=new Set(Object.keys(p)),g=this.options.HTMLAttributes;return d.forEach(y=>{m.has(y)||(y in g?s.setAttribute(y,g[y]):s.removeAttribute(y))}),Object.entries(p).forEach(([y,x])=>{x==null?y in g?s.setAttribute(y,g[y]):s.removeAttribute(y):s.setAttribute(y,x)}),d=m,!0}}}},addInputRules(){return[X1({find:E8t,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),I8t=yl.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",Ia(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||e===void 0?void 0:e.index;return r!==void 0?r:-1},tokenize(t,e,r){const n=i=>{const a=Sle(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:r.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:n},r);if(a){const l={type:"taskList",raw:a.raw,items:a.items},c=i.slice(a.raw.length);return c.trim()?[l,...r.blockTokens(c)]:[l]}return r.blockTokens(i)},s=Sle(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()}}});js.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(CTe.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(ITe.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(OTe.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(DTe.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(P8t.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(I8t.configure(this.options.taskList)),t}});const p2="&nbsp;",f6=" ",R8t=yl.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Ia(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===p2||r[0].text===p2||r[0].raw===f6||r[0].text===f6)&&n.length===1&&n[0].type==="text"&&(n[0].text===p2||n[0].text===f6)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,n)},renderMarkdown:(t,e,r)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];if(n.length===0){var s,i;const a=Array.isArray(r==null||(s=r.previousNode)===null||s===void 0?void 0:s.content)?r.previousNode.content:[];return(r==null||(i=r.previousNode)===null||i===void 0?void 0:i.type)==="paragraph"&&a.length===0?p2:""}return e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),O8t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,M8t=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,D8t=j5.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",Ia(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[Y1({find:O8t,type:this.type})]},addPasteRules(){return[Q1({find:M8t,type:this.type})]}}),L8t=yl.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""});var LTe=gK.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",su(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()}}}),$8t=LTe;function F8t(t={}){return new Ar({view(e){return new B8t(e,t)}})}class B8t{constructor(e,r){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,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.setCursor(null),this.handlers.forEach(({name:e,handler:r})=>this.editorView.dom.removeEventListener(e,r))}update(e,r){if(this.cursorPos!=null&&r.doc!=e.state.doc)if(this.lastDragEvent){let n=this.computeTarget(this.lastDragEvent);n==this.cursorPos?this.updateOverlay():this.setCursor(n)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),r=!e.parent.inlineContent,n,s=this.editorView.dom,i=s.getBoundingClientRect(),a=i.width/s.offsetWidth,l=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 y=this.width/2*l;n={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}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)/l+"px",this.element.style.width=(n.right-n.left)/a+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){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)return null;let a=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=MCe(this.editorView.state.doc,a,this.editorView.dragging.slice);l!=null&&(a=l)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let r=this.computeTarget(e);r!=null&&(this.setCursor(r),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class gs extends Mt{constructor(e){super(e,e)}map(e,r){let n=e.resolve(r.map(this.head));return gs.valid(n)?new gs(n):Mt.near(n)}content(){return at.empty}eq(e){return e instanceof gs&&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 gs(e.resolve(r.pos))}getBookmark(){return new MK(this.anchor)}static valid(e){let r=e.parent;if(r.inlineContent||!z8t(e)||!U8t(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&&gs.valid(e))return e;let s=e.pos,i=null;for(let a=e.depth;;a--){let l=e.node(a);if(r>0?e.indexAfter(a)<l.childCount:e.index(a)>0){i=l.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(gs.valid(c))return c}for(;;){let a=r>0?i.firstChild:i.lastChild;if(!a){if(i.isAtom&&!i.isText&&!Pt.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*r),n=!1;continue e}break}i=a,s+=r;let l=e.doc.resolve(s);if(gs.valid(l))return l}return null}}}gs.prototype.visible=!1;gs.findFrom=gs.findGapCursorFrom;Mt.jsonID("gapcursor",gs);class MK{constructor(e){this.pos=e}map(e){return new MK(e.map(this.pos))}resolve(e){let r=e.resolve(this.pos);return gs.valid(r)?new gs(r):Mt.near(r)}}function $Te(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function z8t(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||$Te(s.type))return!0;if(s.inlineContent)return!1}}return!0}function U8t(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||$Te(s.type))return!0;if(s.inlineContent)return!1}}return!0}function H8t(){return new Ar({props:{decorations:G8t,createSelectionBetween(t,e,r){return e.pos==r.pos&&gs.valid(r)?new gs(r):null},handleClick:V8t,handleKeyDown:W8t,handleDOMEvents:{beforeinput:q8t}}})}const W8t=aK({ArrowLeft:m2("horiz",-1),ArrowRight:m2("horiz",1),ArrowUp:m2("vert",-1),ArrowDown:m2("vert",1)});function m2(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,s,i){let a=n.selection,l=e>0?a.$to:a.$from,c=a.empty;if(a instanceof ht){if(!i.endOfTextblock(r)||l.depth==0)return!1;c=!1,l=n.doc.resolve(e>0?l.after():l.before())}let u=gs.findGapCursorFrom(l,e,c);return u?(s&&s(n.tr.setSelection(new gs(u))),!0):!1}}function V8t(t,e,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(e);if(!gs.valid(n))return!1;let s=t.posAtCoords({left:r.clientX,top:r.clientY});return s&&s.inside>-1&&Pt.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new gs(n))),!0)}function q8t(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof gs))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=Me.empty;for(let a=n.length-1;a>=0;a--)s=Me.from(n[a].createAndFill(null,s));let i=t.state.tr.replace(r.pos,r.pos,new at(s,0,0));return i.setSelection(ht.near(i.doc.resolve(r.pos+1))),t.dispatch(i),!1}function G8t(t){if(!(t.selection instanceof gs))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Dr.create(t.doc,[Ts.widget(t.selection.head,e,{key:"gapcursor"})])}js.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 r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,r=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(r)}},addProseMirrorPlugins(){let t=!1;return[new Ar({key:new Wr("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 l=a-s,c=0,u=l;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 a=e.selection.$head.pos,l=a-(i-n),c=a;return e.deleteRange(l,c),!(this.storage.characters({node:e.doc})>n)}})]}});const K8t=js.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[F8t(this.options)]}});js.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ar({key:new Wr("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:r,isFocused:n}=this.editor,{anchor:s}=e,i=[];if(!r||!n)return Dr.create(t,[]);let a=0;this.options.mode==="deepest"&&t.descendants((c,u)=>{if(!c.isText){if(!(s>=u&&s<=u+c.nodeSize-1))return!1;a+=1}});let l=0;return t.descendants((c,u)=>{if(c.isText||!(s>=u&&s<=u+c.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&a-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Ts.node(u,u+c.nodeSize,{class:this.options.className}))}),Dr.create(t,i)}}})]}});const Y8t=js.create({name:"gapCursor",addProseMirrorPlugins(){return[H8t()]},extendNodeSchema(t){var e;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=wf(K1(t,"allowGapCursor",r)))!==null&&e!==void 0?e:null}}}),FTe="placeholder",zle=new Wr("tiptap__placeholder");function BTe(t){const{editor:e,placeholder:r,dataAttribute:n,pos:s,node:i,isEmptyDoc:a,hasAnchor:l,classes:{emptyNode:c,emptyEditor:u}}=t,d=[c];return a&&d.push(u),Ts.node(s,s+i.nodeSize,{class:d.join(" "),[n]:typeof r=="function"?r({editor:e,node:i,pos:s,hasAnchor:l}):r})}function zTe(t,e){return typeof t=="function"?t(e):t}function UTe({editor:t,options:e,dataAttribute:r,doc:n,selection:s,from:i,to:a}){const{anchor:l}=s,c=[],u=t.isEmpty;return n.nodesBetween(i,a,(d,h)=>{const f=l>=h&&l<=h+d.nodeSize,p=!d.isLeaf&&b5(d);return d.type.isTextblock&&(f||!e.showOnlyCurrent)&&p&&c.push(BTe({editor:t,isEmptyDoc:u,dataAttribute:r,hasAnchor:f,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:zTe(e.emptyNodeClass,{editor:t,node:d,pos:h,hasAnchor:f})},node:d,pos:h})),e.includeChildren}),c}function HTe({editor:t,options:e,dataAttribute:r,doc:n,selection:s}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:i}=s,a=[],l=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const c=n.resolve(i),u=c.depth>0?c.node(1):c.nodeAfter,d=c.depth>0?c.before(1):i;if(u&&u.type.isTextblock&&b5(u)){const h=i>=d&&i<=d+u.nodeSize;a.push(BTe({editor:t,isEmptyDoc:l,dataAttribute:r,hasAnchor:h,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:zTe(e.emptyNodeClass,{editor:t,node:u,pos:d,hasAnchor:h})},node:u,pos:d}))}}else a.push(...UTe({editor:t,options:e,dataAttribute:r,doc:n,selection:s,from:0,to:n.content.size}));return Dr.create(n,a)}function sN(t,e){const r=t.resolve(e);if(r.depth===0){var n;const i=(n=r.nodeAfter)!==null&&n!==void 0?n:r.nodeBefore;if(!i)return{from:e,to:e};const a=r.nodeAfter?e:e-i.nodeSize;return{from:a,to:a+i.nodeSize}}const s=r.before(1);return{from:s,to:s+r.node(1).nodeSize}}function iN(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function X8t(t,e,r){const n=[];return t.forEach((s,i)=>{const a=i,l=a+s.nodeSize,c=a+1,u=l+1;c<r&&u>e&&n.push({from:a,to:l})}),n}function Q8t(t){if(t.length===0)return[];const e=[...t].sort((n,s)=>n.from-s.from),r=[{...e[0]}];for(let n=1;n<e.length;n+=1){const s=r[r.length-1],i=e[n];i.from<=s.to?s.to=Math.max(s.to,i.to):r.push({...i})}return r}function Z8t(t,e){const r=X8t(t,e.from,e.to);return r.push(iN(t,sN(t,e.from))),e.to>e.from?r.push(iN(t,sN(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&r.push(iN(t,sN(t,Math.min(e.from+1,t.content.size)))),r}function J8t(t,e,r){const n=[];if(t.docChanged){const s=nTe(t);for(const i of s)n.push(...Z8t(r.doc,i.newRange))}return t.selectionSet&&(n.push(iN(r.doc,sN(r.doc,t.mapping.map(e.selection.anchor)))),n.push(iN(r.doc,sN(r.doc,r.selection.anchor)))),Q8t(n)}function ezt(t,e,r){const n=Math.max(0,Math.min(t,r.content.size));return{from:n,to:Math.max(n,Math.min(e,r.content.size))}}function tzt({decorations:t,ranges:e,editor:r,options:n,dataAttribute:s,doc:i,selection:a}){let l=t;for(const c of e){const{from:u,to:d}=ezt(c.from,c.to,i),h=l.find(u,d).filter(p=>p.from>=u&&p.to<=d);h.length&&(l=l.remove(h));const f=UTe({editor:r,options:n,dataAttribute:s,doc:i,selection:a,from:u,to:d});f.length&&(l=l.add(i,f))}return l}function rzt({editor:t,options:e,dataAttribute:r}){return{init(n,s){const i=HTe({editor:t,options:e,dataAttribute:r,doc:s.doc,selection:s.selection});return i??Dr.empty},apply(n,s,i,a){return!n.docChanged&&!n.selectionSet?s:tzt({decorations:s.map(n.mapping,n.doc),ranges:J8t(n,i,a),editor:t,options:e,dataAttribute:r,doc:a.doc,selection:a.selection})}}}function nzt(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function szt({editor:t,options:e}){const r=e.dataAttribute?`data-${nzt(e.dataAttribute)}`:`data-${FTe}`,n=e.showOnlyCurrent&&!e.includeChildren;return new Ar({key:zle,...n?{}:{state:rzt({editor:t,options:e,dataAttribute:r})},props:{decorations:n?({doc:s,selection:i})=>HTe({editor:t,options:e,dataAttribute:r,doc:s,selection:i}):s=>{var i;return e.showOnlyWhenEditable&&!t.isEditable?Dr.empty:(i=zle.getState(s))!==null&&i!==void 0?i:Dr.empty}}})}js.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:FTe,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[szt({editor:this.editor,options:this.options})]}});function A7(t,e){return!t.selection.empty&&!iTe(t.selection)&&e.isEditable}function izt(t,e){return A7(t,e)&&!e.isFocused&&!e.view.dragging}function azt(){var t;(t=window.getSelection())===null||t===void 0||t.removeAllRanges()}function ozt(t){t.focus()}js.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ar({key:new Wr("selection"),props:{decorations(r){return izt(r,t)?Dr.create(r.doc,[Ts.inline(r.selection.from,r.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(r){return A7(r.state,t)&&azt(),!1},focus(r){return A7(r.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&r.hasFocus()&&ozt(r)}),!1}}}})]}});function Ule({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}const lzt=js.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Wr(this.name),r=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)===null||t===void 0?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 Ar({key:e,appendTransaction:(s,i,a)=>{const{doc:l,tr:c,schema:u}=a,d=e.getState(a),h=l.content.size,f=u.nodes[r];if(!s.some(p=>p.getMeta("skipTrailingNode"))&&d)return c.insert(h,f.create())},state:{init:(s,i)=>{const a=i.tr.doc.lastChild;return!Ule({node:a,types:n})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const a=s.doc.lastChild;return!Ule({node:a,types:n})}}})]}}),czt=js.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>UAe(t,e),redo:()=>({state:t,dispatch:e})=>HAe(t,e)}},addProseMirrorPlugins(){return[fFt(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()}}});var uzt=js.create({name:"starterKit",addExtensions(){var t,e,r,n;const s=[];return this.options.bold!==!1&&s.push(dBt.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(aBt.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(CTe.configure(this.options.bulletList)),this.options.code!==!1&&s.push(mBt.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(yBt.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(vBt.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(K8t.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Y8t.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(bBt.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(wBt.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(czt.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(jBt.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(CBt.configure(this.options.italic)),this.options.listItem!==!1&&s.push(ITe.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(OTe.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(kTe.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(DTe.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(R8t.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(D8t.configure(this.options.strike)),this.options.text!==!1&&s.push(L8t.configure(this.options.text)),this.options.underline!==!1&&s.push(LTe.configure((r=this.options)==null?void 0:r.underline)),this.options.trailingNode!==!1&&s.push(lzt.configure((n=this.options)==null?void 0:n.trailingNode)),s}}),dzt=uzt;let T7,P7;if(typeof WeakMap<"u"){let t=new WeakMap;T7=e=>t.get(e),P7=(e,r)=>(t.set(e,r),r)}else{const t=[];let r=0;T7=n=>{for(let s=0;s<t.length;s+=2)if(t[s]==n)return t[s+1]},P7=(n,s)=>(r==10&&(r=0),t[r++]=n,t[r++]=s)}var xs=class{constructor(t,e,r,n){this.width=t,this.height=e,this.map=r,this.problems=n}findCell(t){for(let e=0;e<this.map.length;e++){const r=this.map[e];if(r!=t)continue;const n=e%this.width,s=e/this.width|0;let i=n+1,a=s+1;for(let l=1;i<this.width&&this.map[e+l]==r;l++)i++;for(let l=1;a<this.height&&this.map[e+this.width*l]==r;l++)a++;return{left:n,top:s,right:i,bottom:a}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,r){const{left:n,right:s,top:i,bottom:a}=this.findCell(t);return e=="horiz"?(r<0?n==0:s==this.width)?null:this.map[i*this.width+(r<0?n-1:s)]:(r<0?i==0:a==this.height)?null:this.map[n+this.width*(r<0?i-1:a)]}rectBetween(t,e){const{left:r,right:n,top:s,bottom:i}=this.findCell(t),{left:a,right:l,top:c,bottom:u}=this.findCell(e);return{left:Math.min(r,a),top:Math.min(s,c),right:Math.max(n,l),bottom:Math.max(i,u)}}cellsInRect(t){const e=[],r={};for(let n=t.top;n<t.bottom;n++)for(let s=t.left;s<t.right;s++){const i=n*this.width+s,a=this.map[i];r[a]||(r[a]=!0,!(s==t.left&&s&&this.map[i-1]==a||n==t.top&&n&&this.map[i-this.width]==a)&&e.push(a))}return e}positionAt(t,e,r){for(let n=0,s=0;;n++){const i=s+r.child(n).nodeSize;if(n==t){let a=e+t*this.width;const l=(t+1)*this.width;for(;a<l&&this.map[a]<s;)a++;return a==l?i-1:this.map[a]}s=i}}static get(t){return T7(t)||P7(t,hzt(t))}};function hzt(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=fzt(t),r=t.childCount,n=[];let s=0,i=null;const a=[];for(let u=0,d=e*r;u<d;u++)n[u]=0;for(let u=0,d=0;u<r;u++){const h=t.child(u);d++;for(let m=0;;m++){for(;s<n.length&&n[s]!=0;)s++;if(m==h.childCount)break;const g=h.child(m),{colspan:y,rowspan:x,colwidth:v}=g.attrs;for(let b=0;b<x;b++){if(b+u>=r){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:x-b});break}const w=s+b*e;for(let j=0;j<y;j++){n[w+j]==0?n[w+j]=d:(i||(i=[])).push({type:"collision",row:u,pos:d,n:y-j});const N=v&&v[j];if(N){const C=(w+j)%e*2,A=a[C];A==null||A!=N&&a[C+1]==1?(a[C]=N,a[C+1]=1):A==N&&a[C+1]++}}}s+=y,d+=g.nodeSize}const f=(u+1)*e;let p=0;for(;s<f;)n[s++]==0&&p++;p&&(i||(i=[])).push({type:"missing",row:u,n:p}),d++}(e===0||r===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new xs(e,r,n,i);let c=!1;for(let u=0;!c&&u<a.length;u+=2)a[u]!=null&&a[u+1]<r&&(c=!0);return c&&pzt(l,a,t),l}function fzt(t){let e=-1,r=!1;for(let n=0;n<t.childCount;n++){const s=t.child(n);let i=0;if(r)for(let a=0;a<n;a++){const l=t.child(a);for(let c=0;c<l.childCount;c++){const u=l.child(c);a+u.attrs.rowspan>n&&(i+=u.attrs.colspan)}}for(let a=0;a<s.childCount;a++){const l=s.child(a);i+=l.attrs.colspan,l.attrs.rowspan>1&&(r=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function pzt(t,e,r){t.problems||(t.problems=[]);const n={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(n[i])continue;n[i]=!0;const a=r.nodeAt(i);if(!a)throw new RangeError(`No cell with offset ${i} found`);let l=null;const c=a.attrs;for(let u=0;u<c.colspan;u++){const d=e[(s+u)%t.width*2];d!=null&&(!c.colwidth||c.colwidth[u]!=d)&&((l||(l=mzt(c)))[u]=d)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function mzt(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let r=0;r<t.colspan;r++)e.push(0);return e}function Aa(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const r in t.nodes){const n=t.nodes[r],s=n.spec.tableRole;s&&(e[s]=n)}}return e}const mp=new Wr("selectingCells");function _v(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function gzt(t){for(let e=t.depth;e>0;e--){const r=t.node(e).type.spec.tableRole;if(r==="cell"||r==="header_cell")return t.node(e)}return null}function uu(t){const e=t.selection.$head;for(let r=e.depth;r>0;r--)if(e.node(r).type.spec.tableRole=="row")return!0;return!1}function k5(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const r=_v(e.$head)||xzt(e.$head);if(r)return r;throw new RangeError(`No cell found around position ${e.head}`)}function xzt(t){for(let e=t.nodeAfter,r=t.pos;e;e=e.firstChild,r++){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return t.doc.resolve(r)}for(let e=t.nodeBefore,r=t.pos;e;e=e.lastChild,r--){const n=e.type.spec.tableRole;if(n=="cell"||n=="header_cell")return t.doc.resolve(r-e.nodeSize)}}function I7(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function yzt(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function DK(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function WTe(t,e,r){const n=t.node(-1),s=xs.get(n),i=t.start(-1),a=s.nextCell(t.pos-i,e,r);return a==null?null:t.node(0).resolve(i+a)}function Nv(t,e,r=1){const n={...t,colspan:t.colspan-r};return n.colwidth&&(n.colwidth=n.colwidth.slice(),n.colwidth.splice(e,r),n.colwidth.some(s=>s>0)||(n.colwidth=null)),n}function VTe(t,e,r=1){const n={...t,colspan:t.colspan+r};if(n.colwidth){n.colwidth=n.colwidth.slice();for(let s=0;s<r;s++)n.colwidth.splice(e,0,0)}return n}function vzt(t,e,r){const n=Aa(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[r+s*t.width]).type!=n)return!1;return!0}var _n=class Wd extends Mt{constructor(e,r=e){const n=e.node(-1),s=xs.get(n),i=e.start(-1),a=s.rectBetween(e.pos-i,r.pos-i),l=e.node(0),c=s.cellsInRect(a).filter(d=>d!=r.pos-i);c.unshift(r.pos-i);const u=c.map(d=>{const h=n.nodeAt(d);if(!h)throw new RangeError(`No cell with offset ${d} found`);const f=i+d+1;return new BCe(l.resolve(f),l.resolve(f+h.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=r}map(e,r){const n=e.resolve(r.map(this.$anchorCell.pos)),s=e.resolve(r.map(this.$headCell.pos));if(I7(n)&&I7(s)&&DK(n,s)){const i=this.$anchorCell.node(-1)!=n.node(-1);return i&&this.isRowSelection()?Wd.rowSelection(n,s):i&&this.isColSelection()?Wd.colSelection(n,s):new Wd(n,s)}return ht.between(n,s)}content(){const e=this.$anchorCell.node(-1),r=xs.get(e),n=this.$anchorCell.start(-1),s=r.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let c=s.top;c<s.bottom;c++){const u=[];for(let d=c*r.width+s.left,h=s.left;h<s.right;h++,d++){const f=r.map[d];if(i[f])continue;i[f]=!0;const p=r.findCell(f);let m=e.nodeAt(f);if(!m)throw new RangeError(`No cell with offset ${f} found`);const g=s.left-p.left,y=p.right-s.right;if(g>0||y>0){let x=m.attrs;if(g>0&&(x=Nv(x,0,g)),y>0&&(x=Nv(x,x.colspan-y,y)),p.left<s.left){if(m=m.type.createAndFill(x),!m)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else m=m.type.create(x,m.content)}if(p.top<s.top||p.bottom>s.bottom){const x={...m.attrs,rowspan:Math.min(p.bottom,s.bottom)-Math.max(p.top,s.top)};p.top<s.top?m=m.type.createAndFill(x):m=m.type.create(x,m.content)}u.push(m)}a.push(e.child(c).copy(Me.from(u)))}const l=this.isColSelection()&&this.isRowSelection()?e:a;return new at(Me.from(l),1,1)}replace(e,r=at.empty){const n=e.steps.length,s=this.ranges;for(let a=0;a<s.length;a++){const{$from:l,$to:c}=s[a],u=e.mapping.slice(n);e.replace(u.map(l.pos),u.map(c.pos),a?at.empty:r)}const i=Mt.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,r){this.replace(e,new at(Me.from(r),0,0))}forEachCell(e){const r=this.$anchorCell.node(-1),n=xs.get(r),s=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let a=0;a<i.length;a++)e(r.nodeAt(i[a]),s+i[a])}isColSelection(){const e=this.$anchorCell.index(-1),r=this.$headCell.index(-1);if(Math.min(e,r)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=r+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,s)==this.$headCell.node(-1).childCount}static colSelection(e,r=e){const n=e.node(-1),s=xs.get(n),i=e.start(-1),a=s.findCell(e.pos-i),l=s.findCell(r.pos-i),c=e.node(0);return a.top<=l.top?(a.top>0&&(e=c.resolve(i+s.map[a.left])),l.bottom<s.height&&(r=c.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(r=c.resolve(i+s.map[l.left])),a.bottom<s.height&&(e=c.resolve(i+s.map[s.width*(s.height-1)+a.right-1]))),new Wd(e,r)}isRowSelection(){const e=this.$anchorCell.node(-1),r=xs.get(e),n=this.$anchorCell.start(-1),s=r.colCount(this.$anchorCell.pos-n),i=r.colCount(this.$headCell.pos-n);if(Math.min(s,i)>0)return!1;const a=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,l)==r.width}eq(e){return e instanceof Wd&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,r=e){const n=e.node(-1),s=xs.get(n),i=e.start(-1),a=s.findCell(e.pos-i),l=s.findCell(r.pos-i),c=e.node(0);return a.left<=l.left?(a.left>0&&(e=c.resolve(i+s.map[a.top*s.width])),l.right<s.width&&(r=c.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(r=c.resolve(i+s.map[l.top*s.width])),a.right<s.width&&(e=c.resolve(i+s.map[s.width*(a.top+1)-1]))),new Wd(e,r)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,r){return new Wd(e.resolve(r.anchor),e.resolve(r.head))}static create(e,r,n=r){return new Wd(e.resolve(r),e.resolve(n))}getBookmark(){return new bzt(this.$anchorCell.pos,this.$headCell.pos)}};_n.prototype.visible=!1;Mt.jsonID("cell",_n);var bzt=class qTe{constructor(e,r){this.anchor=e,this.head=r}map(e){return new qTe(e.map(this.anchor),e.map(this.head))}resolve(e){const r=e.resolve(this.anchor),n=e.resolve(this.head);return r.parent.type.spec.tableRole=="row"&&n.parent.type.spec.tableRole=="row"&&r.index()<r.parent.childCount&&n.index()<n.parent.childCount&&DK(r,n)?new _n(r,n):Mt.near(n,1)}};function wzt(t){if(!(t.selection instanceof _n))return null;const e=[];return t.selection.forEachCell((r,n)=>{e.push(Ts.node(n,n+r.nodeSize,{class:"selectedCell"}))}),Dr.create(t.doc,e)}function jzt({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let r=t.pos,n=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,r++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,n--);return r==n&&/row|table/.test(t.node(s).type.spec.tableRole)}function Szt({$from:t,$to:e}){let r,n;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}return r!==n&&e.parentOffset===0}function _zt(t,e,r){const n=(e||t).selection,s=(e||t).doc;let i,a;if(n instanceof Pt&&(a=n.node.type.spec.tableRole)){if(a=="cell"||a=="header_cell")i=_n.create(s,n.from);else if(a=="row"){const l=s.resolve(n.from+1);i=_n.rowSelection(l,l)}else if(!r){const l=xs.get(n.node),c=n.from+1,u=c+l.map[l.width*l.height-1];i=_n.create(s,c+1,u)}}else n instanceof ht&&jzt(n)?i=ht.create(s,n.from):n instanceof ht&&Szt(n)&&(i=ht.create(s,n.$from.start(),n.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const Nzt=new Wr("fix-tables");function GTe(t,e,r,n){const s=t.childCount,i=e.childCount;e:for(let a=0,l=0;a<i;a++){const c=e.child(a);for(let u=l,d=Math.min(s,a+3);u<d;u++)if(t.child(u)==c){l=u+1,r+=c.nodeSize;continue e}n(c,r),l<s&&t.child(l).sameMarkup(c)?GTe(t.child(l),c,r+1,n):c.nodesBetween(0,c.content.size,n,r+1),r+=c.nodeSize}}function KTe(t,e){let r;const n=(s,i)=>{s.type.spec.tableRole=="table"&&(r=kzt(t,s,i,r))};return e?e.doc!=t.doc&&GTe(e.doc,t.doc,0,n):t.doc.descendants(n),r}function kzt(t,e,r,n){const s=xs.get(e);if(!s.problems)return n;n||(n=t.tr);const i=[];for(let c=0;c<s.height;c++)i.push(0);for(let c=0;c<s.problems.length;c++){const u=s.problems[c];if(u.type=="collision"){const d=e.nodeAt(u.pos);if(!d)continue;const h=d.attrs;for(let f=0;f<h.rowspan;f++)i[u.row+f]+=u.n;n.setNodeMarkup(n.mapping.map(r+1+u.pos),null,Nv(h,h.colspan-u.n,u.n))}else if(u.type=="missing")i[u.row]+=u.n;else if(u.type=="overlong_rowspan"){const d=e.nodeAt(u.pos);if(!d)continue;n.setNodeMarkup(n.mapping.map(r+1+u.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-u.n})}else if(u.type=="colwidth mismatch"){const d=e.nodeAt(u.pos);if(!d)continue;n.setNodeMarkup(n.mapping.map(r+1+u.pos),null,{...d.attrs,colwidth:u.colwidth})}else if(u.type=="zero_sized"){const d=n.mapping.map(r);n.delete(d,d+e.nodeSize)}}let a,l;for(let c=0;c<i.length;c++)i[c]&&(a==null&&(a=c),l=c);for(let c=0,u=r+1;c<s.height;c++){const d=e.child(c),h=u+d.nodeSize,f=i[c];if(f>0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);const m=[];for(let y=0;y<f;y++){const x=Aa(t.schema)[p].createAndFill();x&&m.push(x)}const g=(c==0||a==c-1)&&l==c?u+1:h-1;n.insert(n.mapping.map(g),m)}u=h}return n.setMeta(Nzt,{fixTables:!0})}function Ad(t){const e=t.selection,r=k5(t),n=r.node(-1),s=r.start(-1),i=xs.get(n);return{...e instanceof _n?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(r.pos-s),tableStart:s,map:i,table:n}}function YTe(t,{map:e,tableStart:r,table:n},s){let i=s>0?-1:0;vzt(e,n,s+i)&&(i=s==0||s==e.width?null:0);for(let a=0;a<e.height;a++){const l=a*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const c=e.map[l],u=n.nodeAt(c);t.setNodeMarkup(t.mapping.map(r+c),null,VTe(u.attrs,s-e.colCount(c))),a+=u.attrs.rowspan-1}else{const c=i==null?Aa(n.type.schema).cell:n.nodeAt(e.map[l+i]).type,u=e.positionAt(a,s,n);t.insert(t.mapping.map(r+u),c.createAndFill())}}return t}function Czt(t,e){if(!uu(t))return!1;if(e){const r=Ad(t);e(YTe(t.tr,r,r.left))}return!0}function Ezt(t,e){if(!uu(t))return!1;if(e){const r=Ad(t);e(YTe(t.tr,r,r.right))}return!0}function Azt(t,{map:e,table:r,tableStart:n},s){const i=t.mapping.maps.length;for(let a=0;a<e.height;){const l=a*e.width+s,c=e.map[l],u=r.nodeAt(c),d=u.attrs;if(s>0&&e.map[l-1]==c||s<e.width-1&&e.map[l+1]==c)t.setNodeMarkup(t.mapping.slice(i).map(n+c),null,Nv(d,s-e.colCount(c)));else{const h=t.mapping.slice(i).map(n+c);t.delete(h,h+u.nodeSize)}a+=d.rowspan}}function XTe(t,e){if(!uu(t))return!1;if(e){const r=Ad(t),n=t.tr;if(r.left==0&&r.right==r.map.width)return!1;for(let s=r.right-1;Azt(n,r,s),s!=r.left;s--){const i=r.tableStart?n.doc.nodeAt(r.tableStart-1):n.doc;if(!i)throw new RangeError("No table found");r.table=i,r.map=xs.get(i)}e(n)}return!0}function Tzt(t,e,r){var n;const s=Aa(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((n=e.nodeAt(t.map[i+r*t.width]))===null||n===void 0?void 0:n.type)!=s)return!1;return!0}function QTe(t,{map:e,tableStart:r,table:n},s){let i=r;for(let u=0;u<s;u++)i+=n.child(u).nodeSize;const a=[];let l=s>0?-1:0;Tzt(e,n,s+l)&&(l=s==0||s==e.height?null:0);for(let u=0,d=e.width*s;u<e.width;u++,d++)if(s>0&&s<e.height&&e.map[d]==e.map[d-e.width]){const h=e.map[d],f=n.nodeAt(h).attrs;t.setNodeMarkup(r+h,null,{...f,rowspan:f.rowspan+1}),u+=f.colspan-1}else{var c;const h=l==null?Aa(n.type.schema).cell:(c=n.nodeAt(e.map[d+l*e.width]))===null||c===void 0?void 0:c.type,f=h==null?void 0:h.createAndFill();f&&a.push(f)}return t.insert(i,Aa(n.type.schema).row.create(null,a)),t}function Pzt(t,e){if(!uu(t))return!1;if(e){const r=Ad(t);e(QTe(t.tr,r,r.top))}return!0}function Izt(t,e){if(!uu(t))return!1;if(e){const r=Ad(t);e(QTe(t.tr,r,r.bottom))}return!0}function Rzt(t,{map:e,table:r,tableStart:n},s){let i=0;for(let u=0;u<s;u++)i+=r.child(u).nodeSize;const a=i+r.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+n,a+n);const c=new Set;for(let u=0,d=s*e.width;u<e.width;u++,d++){const h=e.map[d];if(!c.has(h)){if(c.add(h),s>0&&h==e.map[d-e.width]){const f=r.nodeAt(h).attrs;t.setNodeMarkup(t.mapping.slice(l).map(h+n),null,{...f,rowspan:f.rowspan-1}),u+=f.colspan-1}else if(s<e.height&&h==e.map[d+e.width]){const f=r.nodeAt(h),p=f.attrs,m=f.type.create({...p,rowspan:f.attrs.rowspan-1},f.content),g=e.positionAt(s+1,u,r);t.insert(t.mapping.slice(l).map(n+g),m),u+=p.colspan-1}}}}function ZTe(t,e){if(!uu(t))return!1;if(e){const r=Ad(t),n=t.tr;if(r.top==0&&r.bottom==r.map.height)return!1;for(let s=r.bottom-1;Rzt(n,r,s),s!=r.top;s--){const i=r.tableStart?n.doc.nodeAt(r.tableStart-1):n.doc;if(!i)throw new RangeError("No table found");r.table=i,r.map=xs.get(r.table)}e(n)}return!0}function Hle(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Ozt({width:t,height:e,map:r},n){let s=n.top*t+n.left,i=s,a=(n.bottom-1)*t+n.left,l=s+(n.right-n.left-1);for(let c=n.top;c<n.bottom;c++){if(n.left>0&&r[i]==r[i-1]||n.right<t&&r[l]==r[l+1])return!0;i+=t,l+=t}for(let c=n.left;c<n.right;c++){if(n.top>0&&r[s]==r[s-t]||n.bottom<e&&r[a]==r[a+t])return!0;s++,a++}return!1}function Wle(t,e){const r=t.selection;if(!(r instanceof _n)||r.$anchorCell.pos==r.$headCell.pos)return!1;const n=Ad(t),{map:s}=n;if(Ozt(s,n))return!1;if(e){const i=t.tr,a={};let l=Me.empty,c,u;for(let d=n.top;d<n.bottom;d++)for(let h=n.left;h<n.right;h++){const f=s.map[d*s.width+h],p=n.table.nodeAt(f);if(!(a[f]||!p))if(a[f]=!0,c==null)c=f,u=p;else{Hle(p)||(l=l.append(p.content));const m=i.mapping.map(f+n.tableStart);i.delete(m,m+p.nodeSize)}}if(c==null||u==null)return!0;if(i.setNodeMarkup(c+n.tableStart,null,{...VTe(u.attrs,u.attrs.colspan,n.right-n.left-u.attrs.colspan),rowspan:n.bottom-n.top}),l.size>0){const d=c+1+u.content.size,h=Hle(u)?c+1:d;i.replaceWith(h+n.tableStart,d+n.tableStart,l)}i.setSelection(new _n(i.doc.resolve(c+n.tableStart))),e(i)}return!0}function Vle(t,e){const r=Aa(t.schema);return Mzt(({node:n})=>r[n.type.spec.tableRole])(t,e)}function Mzt(t){return(e,r)=>{const n=e.selection;let s,i;if(n instanceof _n){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;s=n.$anchorCell.nodeAfter,i=n.$anchorCell.pos}else{var a;if(s=gzt(n.$from),!s)return!1;i=(a=_v(n.$from))===null||a===void 0?void 0:a.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(r){let l=s.attrs;const c=[],u=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=Ad(e),h=e.tr;for(let p=0;p<d.right-d.left;p++)c.push(u?{...l,colwidth:u&&u[p]?[u[p]]:null}:l);let f;for(let p=d.top;p<d.bottom;p++){let m=d.map.positionAt(p,d.left,d.table);p==d.top&&(m+=s.nodeSize);for(let g=d.left,y=0;g<d.right;g++,y++)g==d.left&&p==d.top||h.insert(f=h.mapping.map(m+d.tableStart,1),t({node:s,row:p,col:g}).createAndFill(c[y]))}h.setNodeMarkup(i,t({node:s,row:d.top,col:d.left}),c[0]),n instanceof _n&&h.setSelection(new _n(h.doc.resolve(n.$anchorCell.pos),f?h.doc.resolve(f):void 0)),r(h)}return!0}}function Dzt(t,e){return function(r,n){if(!uu(r))return!1;const s=k5(r);if(s.nodeAfter.attrs[t]===e)return!1;if(n){const i=r.tr;r.selection instanceof _n?r.selection.forEachCell((a,l)=>{a.attrs[t]!==e&&i.setNodeMarkup(l,null,{...a.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),n(i)}return!0}}function Lzt(t){return function(e,r){if(!uu(e))return!1;if(r){const n=Aa(e.schema),s=Ad(e),i=e.tr,a=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=a.map(c=>s.table.nodeAt(c));for(let c=0;c<a.length;c++)l[c].type==n.header_cell&&i.setNodeMarkup(s.tableStart+a[c],n.cell,l[c].attrs);if(i.steps.length===0)for(let c=0;c<a.length;c++)i.setNodeMarkup(s.tableStart+a[c],n.header_cell,l[c].attrs);r(i)}return!0}}function qle(t,e,r){const n=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<n.length;s++){const i=e.table.nodeAt(n[s]);if(i&&i.type!==r.header_cell)return!1}return!0}function zk(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Lzt(t):function(r,n){if(!uu(r))return!1;if(n){const s=Aa(r.schema),i=Ad(r),a=r.tr,l=qle("row",i,s),c=qle("column",i,s),u=(t==="column"?l:t==="row"&&c)?1:0,d=t=="column"?{left:0,top:u,right:1,bottom:i.map.height}:t=="row"?{left:u,top:0,right:i.map.width,bottom:1}:i,h=t=="column"?c?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(d).forEach(f=>{const p=f+i.tableStart,m=a.doc.nodeAt(p);m&&a.setNodeMarkup(p,h,m.attrs)}),n(a)}return!0}}zk("row",{useDeprecatedLogic:!0});zk("column",{useDeprecatedLogic:!0});const $zt=zk("cell",{useDeprecatedLogic:!0});function Fzt(t,e){if(e<0){const r=t.nodeBefore;if(r)return t.pos-r.nodeSize;for(let n=t.index(-1)-1,s=t.before();n>=0;n--){const i=t.node(-1).child(n),a=i.lastChild;if(a)return s-1-a.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const r=t.node(-1);for(let n=t.indexAfter(-1),s=t.after();n<r.childCount;n++){const i=r.child(n);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Gle(t){return function(e,r){if(!uu(e))return!1;const n=Fzt(k5(e),t);if(n==null)return!1;if(r){const s=e.doc.resolve(n);r(e.tr.setSelection(ht.between(s,yzt(s))).scrollIntoView())}return!0}}function Bzt(t,e){const r=t.selection.$anchor;for(let n=r.depth;n>0;n--)if(r.node(n).type.spec.tableRole=="table")return e&&e(t.tr.delete(r.before(n),r.after(n)).scrollIntoView()),!0;return!1}function e0(t,e){const r=t.selection;if(!(r instanceof _n))return!1;if(e){const n=t.tr,s=Aa(t.schema).cell.createAndFill().content;r.forEachCell((i,a)=>{i.content.eq(s)||n.replace(n.mapping.map(a+1),n.mapping.map(a+i.nodeSize-1),new at(s,0,0))}),n.docChanged&&e(n)}return!0}function zzt(t){if(t.size===0)return null;let{content:e,openStart:r,openEnd:n}=t;for(;e.childCount==1&&(r>0&&n>0||e.child(0).type.spec.tableRole=="table");)r--,n--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,a=s.type.schema,l=[];if(i=="row")for(let c=0;c<e.childCount;c++){let u=e.child(c).content;const d=c?0:Math.max(0,r-1),h=c<e.childCount-1?0:Math.max(0,n-1);(d||h)&&(u=R7(Aa(a).row,new at(u,d,h)).content),l.push(u)}else if(i=="cell"||i=="header_cell")l.push(r||n?R7(Aa(a).row,new at(e,r,n)).content:e);else return null;return Uzt(a,l)}function Uzt(t,e){const r=[];for(let s=0;s<e.length;s++){const i=e[s];for(let a=i.childCount-1;a>=0;a--){const{rowspan:l,colspan:c}=i.child(a).attrs;for(let u=s;u<s+l;u++)r[u]=(r[u]||0)+c}}let n=0;for(let s=0;s<r.length;s++)n=Math.max(n,r[s]);for(let s=0;s<r.length;s++)if(s>=e.length&&e.push(Me.empty),r[s]<n){const i=Aa(t).cell.createAndFill(),a=[];for(let l=r[s];l<n;l++)a.push(i);e[s]=e[s].append(Me.from(a))}return{height:e.length,width:n,rows:e}}function R7(t,e){const r=t.createAndFill();return new c5(r).replace(0,r.content.size,e).doc}function Hzt({width:t,height:e,rows:r},n,s){if(t!=n){const i=[],a=[];for(let l=0;l<r.length;l++){const c=r[l],u=[];for(let d=i[l]||0,h=0;d<n;h++){let f=c.child(h%c.childCount);d+f.attrs.colspan>n&&(f=f.type.createChecked(Nv(f.attrs,f.attrs.colspan,d+f.attrs.colspan-n),f.content)),u.push(f),d+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)i[l+p]=(i[l+p]||0)+f.attrs.colspan}a.push(Me.from(u))}r=a,t=n}if(e!=s){const i=[];for(let a=0,l=0;a<s;a++,l++){const c=[],u=r[l%e];for(let d=0;d<u.childCount;d++){let h=u.child(d);a+h.attrs.rowspan>s&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,s-h.attrs.rowspan)},h.content)),c.push(h)}i.push(Me.from(c))}r=i,e=s}return{width:t,height:e,rows:r}}function Wzt(t,e,r,n,s,i,a){const l=t.doc.type.schema,c=Aa(l);let u,d;if(s>e.width)for(let h=0,f=0;h<e.height;h++){const p=r.child(h);f+=p.nodeSize;const m=[];let g;p.lastChild==null||p.lastChild.type==c.cell?g=u||(u=c.cell.createAndFill()):g=d||(d=c.header_cell.createAndFill());for(let y=e.width;y<s;y++)m.push(g);t.insert(t.mapping.slice(a).map(f-1+n),m)}if(i>e.height){const h=[];for(let m=0,g=(e.height-1)*e.width;m<Math.max(e.width,s);m++){const y=m>=e.width?!1:r.nodeAt(e.map[g+m]).type==c.header_cell;h.push(y?d||(d=c.header_cell.createAndFill()):u||(u=c.cell.createAndFill()))}const f=c.row.create(null,Me.from(h)),p=[];for(let m=e.height;m<i;m++)p.push(f);t.insert(t.mapping.slice(a).map(n+r.nodeSize-2),p)}return!!(u||d)}function Kle(t,e,r,n,s,i,a,l){if(a==0||a==e.height)return!1;let c=!1;for(let u=s;u<i;u++){const d=a*e.width+u,h=e.map[d];if(e.map[d-e.width]==h){c=!0;const f=r.nodeAt(h),{top:p,left:m}=e.findCell(h);t.setNodeMarkup(t.mapping.slice(l).map(h+n),null,{...f.attrs,rowspan:a-p}),t.insert(t.mapping.slice(l).map(e.positionAt(a,m,r)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-a})),u+=f.attrs.colspan-1}}return c}function Yle(t,e,r,n,s,i,a,l){if(a==0||a==e.width)return!1;let c=!1;for(let u=s;u<i;u++){const d=u*e.width+a,h=e.map[d];if(e.map[d-1]==h){c=!0;const f=r.nodeAt(h),p=e.colCount(h),m=t.mapping.slice(l).map(h+n);t.setNodeMarkup(m,null,Nv(f.attrs,a-p,f.attrs.colspan-(a-p))),t.insert(m+f.nodeSize,f.type.createAndFill(Nv(f.attrs,0,a-p))),u+=f.attrs.rowspan-1}}return c}function Xle(t,e,r,n,s){let i=r?t.doc.nodeAt(r-1):t.doc;if(!i)throw new Error("No table found");let a=xs.get(i);const{top:l,left:c}=n,u=c+s.width,d=l+s.height,h=t.tr;let f=0;function p(){if(i=r?h.doc.nodeAt(r-1):h.doc,!i)throw new Error("No table found");a=xs.get(i),f=h.mapping.maps.length}Wzt(h,a,i,r,u,d,f)&&p(),Kle(h,a,i,r,c,u,l,f)&&p(),Kle(h,a,i,r,c,u,d,f)&&p(),Yle(h,a,i,r,l,d,c,f)&&p(),Yle(h,a,i,r,l,d,u,f)&&p();for(let m=l;m<d;m++){const g=a.positionAt(m,c,i),y=a.positionAt(m,u,i);h.replace(h.mapping.slice(f).map(g+r),h.mapping.slice(f).map(y+r),new at(s.rows[m-l],0,0))}p(),h.setSelection(new _n(h.doc.resolve(r+a.positionAt(l,c,i)),h.doc.resolve(r+a.positionAt(d-1,u-1,i)))),e(h)}const Vzt=aK({ArrowLeft:g2("horiz",-1),ArrowRight:g2("horiz",1),ArrowUp:g2("vert",-1),ArrowDown:g2("vert",1),"Shift-ArrowLeft":x2("horiz",-1),"Shift-ArrowRight":x2("horiz",1),"Shift-ArrowUp":x2("vert",-1),"Shift-ArrowDown":x2("vert",1),Backspace:e0,"Mod-Backspace":e0,Delete:e0,"Mod-Delete":e0});function VP(t,e,r){return r.eq(t.selection)?!1:(e&&e(t.tr.setSelection(r).scrollIntoView()),!0)}function g2(t,e){return(r,n,s)=>{if(!s)return!1;const i=r.selection;if(i instanceof _n)return VP(r,n,Mt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const a=JTe(s,t,e);if(a==null)return!1;if(t=="horiz")return VP(r,n,Mt.near(r.doc.resolve(i.head+e),e));{const l=r.doc.resolve(a),c=WTe(l,t,e);let u;return c?u=Mt.near(c,1):e<0?u=Mt.near(r.doc.resolve(l.before(-1)),-1):u=Mt.near(r.doc.resolve(l.after(-1)),1),VP(r,n,u)}}}function x2(t,e){return(r,n,s)=>{if(!s)return!1;const i=r.selection;let a;if(i instanceof _n)a=i;else{const c=JTe(s,t,e);if(c==null)return!1;a=new _n(r.doc.resolve(c))}const l=WTe(a.$headCell,t,e);return l?VP(r,n,new _n(a.$anchorCell,l)):!1}}function qzt(t,e){const r=t.state.doc,n=_v(r.resolve(e));return n?(t.dispatch(t.state.tr.setSelection(new _n(n))),!0):!1}function Gzt(t,e,r){if(!uu(t.state))return!1;let n=zzt(r);const s=t.state.selection;if(s instanceof _n){n||(n={width:1,height:1,rows:[Me.from(R7(Aa(t.state.schema).cell,r))]});const i=s.$anchorCell.node(-1),a=s.$anchorCell.start(-1),l=xs.get(i).rectBetween(s.$anchorCell.pos-a,s.$headCell.pos-a);return n=Hzt(n,l.right-l.left,l.bottom-l.top),Xle(t.state,t.dispatch,a,l,n),!0}else if(n){const i=k5(t.state),a=i.start(-1);return Xle(t.state,t.dispatch,a,xs.get(i.node(-1)).findCell(i.pos-a),n),!0}else return!1}function Kzt(t,e){var r;if(e.button!=0||e.ctrlKey||e.metaKey)return;const n=Qle(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof _n)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&(s=_v(t.state.selection.$anchor))!=null&&((r=p6(t,e))===null||r===void 0?void 0:r.pos)!=s.pos)i(s,e),e.preventDefault();else if(!n)return;function i(c,u){let d=p6(t,u);const h=mp.getState(t.state)==null;if(!d||!DK(c,d))if(h)d=c;else return;const f=new _n(c,d);if(h||!t.state.selection.eq(f)){const p=t.state.tr.setSelection(f);h&&p.setMeta(mp,c.pos),t.dispatch(p)}}function a(){t.root.removeEventListener("mouseup",a),t.root.removeEventListener("dragstart",a),t.root.removeEventListener("mousemove",l),mp.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(mp,-1))}function l(c){const u=c,d=mp.getState(t.state);let h;if(d!=null)h=t.state.doc.resolve(d);else if(Qle(t,u.target)!=n&&(h=p6(t,e),!h))return a();h&&i(h,u)}t.root.addEventListener("mouseup",a),t.root.addEventListener("dragstart",a),t.root.addEventListener("mousemove",l)}function JTe(t,e,r){if(!(t.state.selection instanceof ht))return null;const{$head:n}=t.state.selection;for(let s=n.depth-1;s>=0;s--){const i=n.node(s);if((r<0?n.index(s):n.indexAfter(s))!=(r<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const a=n.before(s),l=e=="vert"?r>0?"down":"up":r>0?"right":"left";return t.endOfTextblock(l)?a:null}}return null}function Qle(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function p6(t,e){const r=t.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return null;let{inside:n,pos:s}=r;return n>=0&&_v(t.state.doc.resolve(n))||_v(t.state.doc.resolve(s))}var Yzt=class{constructor(e,r){this.node=e,this.defaultCellMinWidth=r,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${r}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),O7(e,this.colgroup,this.table,r),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,O7(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function O7(t,e,r,n,s,i){let a=0,l=!0,c=e.firstChild;const u=t.firstChild;if(u){for(let h=0,f=0;h<u.childCount;h++){const{colspan:p,colwidth:m}=u.child(h).attrs;for(let g=0;g<p;g++,f++){const y=s==f?i:m&&m[g],x=y?y+"px":"";if(a+=y||n,y||(l=!1),c)c.style.width!=x&&(c.style.width=x),c=c.nextSibling;else{const v=document.createElement("col");v.style.width=x,e.appendChild(v)}}}for(;c;){var d;const h=c.nextSibling;(d=c.parentNode)===null||d===void 0||d.removeChild(c),c=h}l?(r.style.width=a+"px",r.style.minWidth=""):(r.style.width="",r.style.minWidth=a+"px")}}const il=new Wr("tableColumnResizing");function Xzt({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:r=100,View:n=Yzt,lastColumnResizable:s=!0}={}){const i=new Ar({key:il,state:{init(a,l){var c;const u=(c=i.spec)===null||c===void 0||(c=c.props)===null||c===void 0?void 0:c.nodeViews,d=Aa(l.schema).table.name;return n&&u&&(u[d]=(h,f)=>new n(h,r,f)),new Qzt(-1,!1)},apply(a,l){return l.apply(a)}},props:{attributes:a=>{const l=il.getState(a);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(a,l)=>{Zzt(a,l,t,s)},mouseleave:a=>{Jzt(a)},mousedown:(a,l)=>{eUt(a,l,e,r)}},decorations:a=>{const l=il.getState(a);if(l&&l.activeHandle>-1)return iUt(a,l.activeHandle)},nodeViews:{}}});return i}var Qzt=class qP{constructor(e,r){this.activeHandle=e,this.dragging=r}apply(e){const r=this,n=e.getMeta(il);if(n&&n.setHandle!=null)return new qP(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new qP(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&e.docChanged){let s=e.mapping.map(r.activeHandle,-1);return I7(e.doc.resolve(s))||(s=-1),new qP(s,r.dragging)}return r}};function Zzt(t,e,r,n){if(!t.editable)return;const s=il.getState(t.state);if(s&&!s.dragging){const i=rUt(e.target);let a=-1;if(i){const{left:l,right:c}=i.getBoundingClientRect();e.clientX-l<=r?a=Zle(t,e,"left",r):c-e.clientX<=r&&(a=Zle(t,e,"right",r))}if(a!=s.activeHandle){if(!n&&a!==-1){const l=t.state.doc.resolve(a),c=l.node(-1),u=xs.get(c),d=l.start(-1);if(u.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==u.width-1)return}e2e(t,a)}}}function Jzt(t){if(!t.editable)return;const e=il.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&e2e(t,-1)}function eUt(t,e,r,n){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,a=il.getState(t.state);if(!a||a.activeHandle==-1||a.dragging)return!1;const l=t.state.doc.nodeAt(a.activeHandle),c=tUt(t,a.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(il,{setDragging:{startX:e.clientX,startWidth:c}}));function u(h){i.removeEventListener("mouseup",u),i.removeEventListener("mousemove",d);const f=il.getState(t.state);f!=null&&f.dragging&&(nUt(t,f.activeHandle,Jle(f.dragging,h,r)),t.dispatch(t.state.tr.setMeta(il,{setDragging:null})))}function d(h){if(!h.which)return u(h);const f=il.getState(t.state);if(f&&f.dragging){const p=Jle(f.dragging,h,r);ece(t,f.activeHandle,p,n)}}return ece(t,a.activeHandle,c,n),i.addEventListener("mouseup",u),i.addEventListener("mousemove",d),e.preventDefault(),!0}function tUt(t,e,{colspan:r,colwidth:n}){const s=n&&n[n.length-1];if(s)return s;const i=t.domAtPos(e);let a=i.node.childNodes[i.offset].offsetWidth,l=r;if(n)for(let c=0;c<r;c++)n[c]&&(a-=n[c],l--);return a/l}function rUt(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Zle(t,e,r,n){const s=r=="right"?-n:n,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:a}=i,l=_v(t.state.doc.resolve(a));if(!l)return-1;if(r=="right")return l.pos;const c=xs.get(l.node(-1)),u=l.start(-1),d=c.map.indexOf(l.pos-u);return d%c.width==0?-1:u+c.map[d-1]}function Jle(t,e,r){const n=e.clientX-t.startX;return Math.max(r,t.startWidth+n)}function e2e(t,e){t.dispatch(t.state.tr.setMeta(il,{setHandle:e}))}function nUt(t,e,r){const n=t.state.doc.resolve(e),s=n.node(-1),i=xs.get(s),a=n.start(-1),l=i.colCount(n.pos-a)+n.nodeAfter.attrs.colspan-1,c=t.state.tr;for(let u=0;u<i.height;u++){const d=u*i.width+l;if(u&&i.map[d]==i.map[d-i.width])continue;const h=i.map[d],f=s.nodeAt(h).attrs,p=f.colspan==1?0:l-i.colCount(h);if(f.colwidth&&f.colwidth[p]==r)continue;const m=f.colwidth?f.colwidth.slice():sUt(f.colspan);m[p]=r,c.setNodeMarkup(a+h,null,{...f,colwidth:m})}c.docChanged&&t.dispatch(c)}function ece(t,e,r,n){const s=t.state.doc.resolve(e),i=s.node(-1),a=s.start(-1),l=xs.get(i).colCount(s.pos-a)+s.nodeAfter.attrs.colspan-1;let c=t.domAtPos(s.start(-1)).node;for(;c&&c.nodeName!="TABLE";)c=c.parentNode;c&&O7(i,c.firstChild,c,n,l,r)}function sUt(t){return Array(t).fill(0)}function iUt(t,e){const r=[],n=t.doc.resolve(e),s=n.node(-1);if(!s)return Dr.empty;const i=xs.get(s),a=n.start(-1),l=i.colCount(n.pos-a)+n.nodeAfter.attrs.colspan-1;for(let u=0;u<i.height;u++){const d=l+u*i.width;if((l==i.width-1||i.map[d]!=i.map[d+1])&&(u==0||i.map[d]!=i.map[d-i.width])){var c;const h=i.map[d],f=a+h+s.nodeAt(h).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((c=il.getState(t))===null||c===void 0)&&c.dragging&&r.push(Ts.node(a+h,a+h+s.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),r.push(Ts.widget(f,p))}}return Dr.create(t.doc,r)}function aUt({allowTableNodeSelection:t=!1}={}){return new Ar({key:mp,state:{init(){return null},apply(e,r){const n=e.getMeta(mp);if(n!=null)return n==-1?null:n;if(r==null||!e.docChanged)return r;const{deleted:s,pos:i}=e.mapping.mapResult(r);return s?null:i}},props:{decorations:wzt,handleDOMEvents:{mousedown:Kzt},createSelectionBetween(e){return mp.getState(e.state)!=null?e.state.selection:null},handleTripleClick:qzt,handleKeyDown:Vzt,handlePaste:Gzt},appendTransaction(e,r,n){return _zt(n,KTe(n,r),t)}})}function tM(t){return t==="left"||t==="right"||t==="center"?t:null}function oUt(t){const e=(t.style.textAlign||"").trim().toLowerCase(),r=(t.getAttribute("align")||"").trim().toLowerCase();return tM(e||r)}function lUt(t){return tM(t==null?void 0:t.align)}function t2e(){return{default:null,parseHTML:t=>oUt(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var r2e=kA.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,r;const n=t.getAttribute("colwidth"),s=n?n.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),a=Array.from(((r=t.parentElement)==null?void 0:r.children)||[]).indexOf(t);if(a&&a>-1&&i&&i[a]){const l=i[a].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}},align:t2e()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",su(this.options.HTMLAttributes,t),0]}}),n2e=kA.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):null}},align:t2e()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",su(this.options.HTMLAttributes,t),0]}}),s2e=kA.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",su(this.options.HTMLAttributes,t),0]}});function M7(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function tce(t,e,r,n,s,i){var a;let l=0,c=!0,u=e.firstChild;const d=t.firstChild;if(d!==null)for(let f=0,p=0;f<d.childCount;f+=1){const{colspan:m,colwidth:g}=d.child(f).attrs;for(let y=0;y<m;y+=1,p+=1){const x=s===p?i:g&&g[y],v=x?`${x}px`:"";if(l+=x||n,x||(c=!1),u){if(u.style.width!==v){const[b,w]=M7(n,x);u.style.setProperty(b,w)}u=u.nextSibling}else{const b=document.createElement("col"),[w,j]=M7(n,x);b.style.setProperty(w,j),e.appendChild(b)}}}for(;u;){const f=u.nextSibling;(a=u.parentNode)==null||a.removeChild(u),u=f}const h=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);c&&!h?(r.style.width=`${l}px`,r.style.minWidth=""):(r.style.width="",r.style.minWidth=`${l}px`)}var cUt=class{constructor(t,e,r,n={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[s,i]of Object.entries(n))i!=null&&(s==="style"?this.table.style.cssText=String(i):this.table.setAttribute(s,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),tce(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,tce(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,r=this.dom.contains(e),n=this.contentDOM.contains(e);return!!(r&&!n&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function uUt(t,e,r,n){let s=0,i=!0;const a=[],l=t.firstChild;if(!l)return{};for(let h=0,f=0;h<l.childCount;h+=1){const{colspan:p,colwidth:m}=l.child(h).attrs;for(let g=0;g<p;g+=1,f+=1){const y=r===f?n:m&&m[g];s+=y||e,y||(i=!1);const[x,v]=M7(e,y);a.push(["col",{style:`${x}: ${v}`}])}}const c=i?`${s}px`:"",u=i?"":`${s}px`;return{colgroup:["colgroup",{},...a],tableWidth:c,tableMinWidth:u}}function rce(t,e){return t.createAndFill()}function dUt(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(r=>{const n=t.nodes[r];n.spec.tableRole&&(e[n.spec.tableRole]=n)}),t.cached.tableNodeTypes=e,e}function hUt(t,e,r,n,s){const i=dUt(t),a=[],l=[];for(let u=0;u<r;u+=1){const d=rce(i.cell);if(d&&l.push(d),n){const h=rce(i.header_cell);h&&a.push(h)}}const c=[];for(let u=0;u<e;u+=1)c.push(i.row.createChecked(null,n&&u===0?a:l));return i.table.createChecked(null,c)}function fUt(t){return t instanceof _n}var y2=({editor:t})=>{const{selection:e}=t.state;if(!fUt(e))return!1;let r=0;const n=iAe(e.ranges[0].$from,i=>i.type.name==="table");return n==null||n.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(r+=1)}),r===e.ranges.length?(t.commands.deleteTable(),!0):!1},pUt="";function mUt(t){return(t||"").replace(/\s+/g," ").trim()}function gUt(t,e,r={}){var n;const s=(n=r.cellLineSeparator)!=null?n:pUt;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(g=>{const y=[];g.content&&g.content.forEach(x=>{let v="";x.content&&Array.isArray(x.content)&&x.content.length>1?v=x.content.map(C=>e.renderChildren(C)).join(s):v=x.content?e.renderChildren(x.content):"";const b=mUt(v),w=x.type==="tableHeader",j=lUt(x.attrs);y.push({text:b,isHeader:w,align:j})}),i.push(y)});const a=i.reduce((g,y)=>Math.max(g,y.length),0);if(a===0)return"";const l=Array.from({length:a}).fill(0);i.forEach(g=>{var y;for(let x=0;x<a;x+=1){const b=(((y=g[x])==null?void 0:y.text)||"").length;b>l[x]&&(l[x]=b),l[x]<3&&(l[x]=3)}});const c=(g,y)=>g+" ".repeat(Math.max(0,y-g.length)),u=i[0],d=u.some(g=>g.isHeader),h=Array.from({length:a}).fill(null);i.forEach(g=>{var y;for(let x=0;x<a;x+=1)!h[x]&&((y=g[x])!=null&&y.align)&&(h[x]=g[x].align)});let f=`
`;const p=Array.from({length:a}).map((g,y)=>d&&u[y]&&u[y].text||"");return f+=`| ${p.map((g,y)=>c(g,l[y])).join(" | ")} |
`,f+=`| ${l.map((g,y)=>{const x=Math.max(3,g),v=h[y];return v==="left"?`:${"-".repeat(x)}`:v==="right"?`${"-".repeat(x)}:`:v==="center"?`:${"-".repeat(x)}:`:"-".repeat(x)}).join(" | ")} |
`,(d?i.slice(1):i).forEach(g=>{f+=`| ${Array.from({length:a}).fill(0).map((y,x)=>c(g[x]&&g[x].text||"",l[x])).join(" | ")} |
`}),f}var xUt=gUt,i2e=kA.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:cUt,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:r,tableWidth:n,tableMinWidth:s}=uUt(t,this.options.cellMinWidth),i=e.style;function a(){return i||(n?`width: ${n}`:`min-width: ${s}`)}const l=["table",su(this.options.HTMLAttributes,e,{style:a()}),r,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const r=[],n=Array.isArray(t.align)?t.align:[];if(t.header){const s=[];t.header.forEach((i,a)=>{var l;const c=tM((l=n[a])!=null?l:i.align),u=c?{align:c}:{};s.push(e.createNode("tableHeader",u,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),r.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const i=[];s.forEach((a,l)=>{var c;const u=tM((c=n[l])!=null?c:a.align),d=u?{align:u}:{};i.push(e.createNode("tableCell",d,[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),r.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,r)},renderMarkdown:(t,e)=>xUt(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:r=!0}={})=>({tr:n,dispatch:s,editor:i})=>{const a=hUt(i.schema,t,e,r);if(s){const l=n.selection.from+1;n.replaceSelectionWith(a).scrollIntoView().setSelection(ht.near(n.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Czt(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Ezt(t,e),deleteColumn:()=>({state:t,dispatch:e})=>XTe(t,e),addRowBefore:()=>({state:t,dispatch:e})=>Pzt(t,e),addRowAfter:()=>({state:t,dispatch:e})=>Izt(t,e),deleteRow:()=>({state:t,dispatch:e})=>ZTe(t,e),deleteTable:()=>({state:t,dispatch:e})=>Bzt(t,e),mergeCells:()=>({state:t,dispatch:e})=>Wle(t,e),splitCell:()=>({state:t,dispatch:e})=>Vle(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>zk("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>zk("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>$zt(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Wle(t,e)?!0:Vle(t,e),setCellAttribute:(t,e)=>({state:r,dispatch:n})=>Dzt(t,e)(r,n),goToNextCell:()=>({state:t,dispatch:e})=>Gle(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Gle(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&KTe(t),!0),setCellSelection:t=>({tr:e,dispatch:r})=>{if(r){const n=_n.create(e.doc,t.anchorCell,t.headCell);e.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:y2,"Mod-Backspace":y2,Delete:y2,"Mod-Delete":y2}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Xzt({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],aUt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:r,view:n,HTMLAttributes:s})=>{const i=su(this.options.HTMLAttributes,s);return new e(r,this.options.cellMinWidth,n,i)}},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:yn(Tt(t,"tableRole",e))}}});xl.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(i2e.configure(this.options.table)),this.options.tableCell!==!1&&t.push(r2e.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(n2e.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(s2e.configure(this.options.tableRow)),t}});const yUt=i2e.extend({addKeyboardShortcuts(){var t;return{...(t=this.parent)==null?void 0:t.call(this),Delete:()=>{const{state:e,view:r}=this.editor,{selection:n}=e;if(!(n instanceof _n))return!1;const s=n.isRowSelection(),i=n.isColSelection();return s&&i?e0(e,r.dispatch):s?ZTe(e,r.dispatch):i?XTe(e,r.dispatch):e0(e,r.dispatch)}}}});var vUt=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,bUt=kA.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",su(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,r,n,s,i,a;const l=(r=(e=t.attrs)==null?void 0:e.src)!=null?r:"",c=(s=(n=t.attrs)==null?void 0:n.alt)!=null?s:"",u=(a=(i=t.attrs)==null?void 0:i.title)!=null?a:"";return u?`![${c}](${l} "${u}")`:`![${c}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:r,alwaysPreserveAspectRatio:n}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:a,editor:l})=>{const c=document.createElement("img");c.draggable=!1;const u=su(this.options.HTMLAttributes,a);Object.entries(u).forEach(([f,p])=>{if(p!=null)switch(f){case"width":case"height":break;default:c.setAttribute(f,p);break}}),u.src!==null&&(c.src=u.src);const d=new g$t({element:c,editor:l,node:s,getPos:i,onResize:(f,p)=>{c.style.width=`${f}px`,c.style.height=`${p}px`},onCommit:(f,p)=>{const m=i();m!==void 0&&this.editor.chain().setNodeSelection(m).updateAttributes(this.name,{width:f,height:p}).run()},onUpdate:(f,p,m)=>f.type===s.type,options:{directions:t,min:{width:e,height:r},preserveAspectRatio:n===!0}}),h=d.dom;return h.style.visibility="hidden",h.style.pointerEvents="none",c.onload=()=>{h.style.visibility="",h.style.pointerEvents=""},d}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[p$t({find:vUt,type:this.type,getAttributes:t=>{const[,,e,r,n]=t;return{src:r,alt:e,title:n}}})]}}),wUt=bUt;const nce=new Map,sce=3600,jUt=6e4;async function rM(t){if(!t)return null;const e=Date.now(),r=nce.get(t);if(r&&r.expiresAt-jUt>e)return r.url;const n=await U9("documents",t,sce);return n&&nce.set(t,{url:n,expiresAt:e+sce*1e3}),n}function SUt({node:t,selected:e}){const r=t.attrs.storagePath,[n,s]=S.useState(r?null:t.attrs.src),[i,a]=S.useState(!1);return S.useEffect(()=>{let l=!0;if(r)return rM(r).then(c=>{l&&(c?s(c):a(!0))}),()=>{l=!1}},[r]),o.jsx(X$t,{className:"thesis-image","data-drag-handle":!0,children:n&&!i?o.jsx("img",{src:n,alt:t.attrs.alt??"",width:t.attrs.width??void 0,className:e?"ring-2 ring-primary":void 0,draggable:!1}):o.jsx("div",{className:"thesis-image__placeholder",children:i?"Image could not be loaded":"Loading image…"})})}const _Ut=wUt.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),storagePath:{default:null,parseHTML:e=>e.getAttribute("data-storage-path"),renderHTML:e=>e.storagePath?{"data-storage-path":e.storagePath}:{}},caption:{default:null,parseHTML:e=>e.getAttribute("data-caption"),renderHTML:e=>e.caption?{"data-caption":e.caption}:{}}}},addNodeView(){return rFt(SUt)}}).configure({inline:!1,allowBase64:!1}),a2e="academly.foxAutocomplete",m6="academly-fox-autocomplete-change";function ice(){try{return localStorage.getItem(a2e)!=="off"}catch{return!0}}function o2e(){const[t,e]=S.useState(ice);S.useEffect(()=>{const n=()=>e(ice());return window.addEventListener(m6,n),window.addEventListener("storage",n),()=>{window.removeEventListener(m6,n),window.removeEventListener("storage",n)}},[]);const r=S.useCallback(n=>{try{localStorage.setItem(a2e,n?"on":"off")}catch{}e(n),window.dispatchEvent(new Event(m6))},[]);return[t,r]}const l2e=S.createContext(null);function NUt({children:t}){const e=S.useRef(new Map),[r,n]=S.useState(null),[s,i]=S.useState(null),[a,l]=S.useState(0),c=S.useCallback(f=>{i(f?e.current.get(f)??null:null)},[]),u=S.useCallback(f=>{n(f),c(f)},[c]),d=S.useCallback((f,p)=>{e.current.set(f,p),n(m=>(m===f&&i(p),m===null?(i(p),f):m))},[]),h=S.useCallback(f=>{e.current.delete(f),n(p=>p===f?(i(null),null):p)},[]);return S.useEffect(()=>{if(!s)return;const f=()=>l(p=>p+1);return s.on("transaction",f),s.on("selectionUpdate",f),()=>{s.off("transaction",f),s.off("selectionUpdate",f)}},[s]),o.jsx(l2e.Provider,{value:{register:d,unregister:h,setActiveId:u,activeId:r,activeEditor:s,tick:a},children:t})}function LK(){const t=S.useContext(l2e);if(!t)throw new Error("useEditorRegistry must be used inside EditorRegistryProvider");return t}const c2e=String.raw`[\p{L}][\p{L}'\-\.]*(?:\s+(?:&|und|and)\s+[\p{L}][\p{L}'\-\.]*|\s+et\s+al\.?(?:\s+[\p{L}][\p{L}'\-\.]*)?)*`,$K=String.raw`(?:pp?|S{1,2})\.?`,ace=new RegExp(String.raw`\((`+c2e+String.raw`)\s*,\s*(\d{4})(?:[a-z])?(?:\s*,\s*`+$K+String.raw`\s*(\d+)(?:\s*[-–—]\s*\d+)?)?\)`,"gu"),oce=new RegExp(String.raw`\b(`+c2e+String.raw`)\s*\((\d{4})(?:[a-z])?\)`,"gu"),lce=new RegExp(String.raw`\(([^()]{1,120}?),\s*(\d{4})(?:[a-z])?(?:\s*,\s*`+$K+String.raw`\s*(\d+)(?:\s*[-–—]\s*\d+)?)?\)`,"gu"),cce=new RegExp(String.raw`\(([^()]{1,120}?),\s*`+$K+String.raw`\s*(\d+)(?:\s*[-–—]\s*\d+)?\)`,"gu");function kUt(t){return t.split(/\s+(?:&|und|and|et\s+al\.?)\s*/i)[0].split(/\s+/)[0].replace(/[.,]+$/,"").trim().toLowerCase()}function CUt(t){return t.replace(/\s+/g," ").replace(/[.,]+$/,"").trim().toLowerCase()}function EUt(t,e,r){return`${t.toLowerCase()}|${e??""}|${r??""}`}function AUt(t,e,r){return t.some(n=>!(r<=n.start||e>=n.end))}function TUt(t){if(!t)return[];const e=[],r=[],n=new Set,s=(a,l,c,u)=>{if(AUt(r,a.index,a.index+a[0].length))return;const d=kUt(l);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:CUt(l),year:c,page:u,key:EUt(d,c,u),start:a.index,end:a.index+a[0].length}))};let i;for(ace.lastIndex=0;(i=ace.exec(t))!==null;)s(i,i[1],parseInt(i[2],10),i[3]?parseInt(i[3],10):null);for(oce.lastIndex=0;(i=oce.exec(t))!==null;)s(i,i[1],parseInt(i[2],10),null);for(lce.lastIndex=0;(i=lce.exec(t))!==null;)s(i,i[1],parseInt(i[2],10),i[3]?parseInt(i[3],10):null);for(cce.lastIndex=0;(i=cce.exec(t))!==null;)s(i,i[1],null,parseInt(i[2],10));return e.sort((a,l)=>a.start-l.start)}const uce=new Wr("citation-decorations");function dce(t){const e=[];return t.descendants((r,n)=>{if(!r.isText||!r.text)return;const s=TUt(r.text);for(const i of s)e.push(Ts.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"}))}),Dr.create(t,e)}const PUt=xl.create({name:"citationDecorations",addProseMirrorPlugins(){return[new Ar({key:uce,state:{init:(t,{doc:e})=>dce(e),apply(t,e){return t.docChanged?dce(t.doc):e}},props:{decorations(t){return uce.getState(t)}}})]}}),Xy=new Wr("ghost-suggestion");function IUt(t,e){var n;(((n=Xy.getState(t.state))==null?void 0:n.text)??null)!==e&&t.dispatch(t.state.tr.setMeta(Xy,{text:e}))}function RUt(t,e){var n;(((n=Xy.getState(t.state))==null?void 0:n.loading)??!1)!==e&&t.dispatch(t.state.tr.setMeta(Xy,{loading:e}))}function OUt(t,e){const{text:r,loading:n}=e;if(!r&&!n)return Dr.empty;const{selection:s}=t;if(!s.empty)return Dr.empty;if(!r){const a=Ts.widget(s.from,()=>{const l=document.createElement("span");l.className="ghost-fox-badge ghost-fox-badge--inline",l.setAttribute("contenteditable","false");const c=document.createElement("span");return c.className="ghost-pulse",l.appendChild(c),l.appendChild(document.createTextNode("Fox AI")),l},{side:1,marks:[],ignoreSelection:!0,key:`ghost-loading-${s.from}`});return Dr.create(t.doc,[a])}const i=Ts.widget(s.from,()=>{const a=document.createElement("span");return a.className="ghost-inline-text",a.setAttribute("contenteditable","false"),a.setAttribute("data-ghost-suggestion","true"),a.textContent=r,a},{side:1,marks:[],ignoreSelection:!0,key:`ghost-${s.from}-${r.length}`});return Dr.create(t.doc,[i])}const MUt=xl.create({name:"ghostSuggestionDecoration",addProseMirrorPlugins(){return[new Ar({key:Xy,state:{init:()=>({text:null,loading:!1}),apply(t,e){const r=t.getMeta(Xy);return r?{...e,...r}:t.docChanged||t.selectionSet?{text:null,loading:!1}:e}},props:{decorations(t){const e=Xy.getState(t);return OUt(t,e??{text:null,loading:!1})}}})]}}),u2e=S.createContext(null);function DUt({children:t}){const[e,r]=S.useState(null),n=S.useCallback(a=>r(a),[]),s=S.useCallback(()=>r(null),[]),i=S.useMemo(()=>({current:e,open:n,close:s}),[e,n,s]);return o.jsx(u2e.Provider,{value:i,children:t})}function FK(){const t=S.useContext(u2e);if(!t)throw new Error("useEvidence must be used inside <EvidenceProvider>");return t}const LUt=3e3,hce=3e3;function t0(t){return t.toLowerCase().replace(/\s+/g," ").replace(/[^\p{L}\p{N} ]/gu,"").trim()}function fce(t,e){const r=t0(t),n=t0(e);if(!r||!n)return 0;if(r===n)return 1;const s=c=>{const u=c.split(" "),d=new Set;for(let h=0;h<u.length-1;h++)d.add(u[h]+" "+u[h+1]);return u.length===1&&d.add(u[0]),d},i=s(r),a=s(n);let l=0;return i.forEach(c=>{a.has(c)&&l++}),2*l/(i.size+a.size)}function $Ut(t){const[e,r]=S.useState(null),[n,s]=S.useState(null),[i,a]=S.useState(null),[l,c]=S.useState(!1),u=S.useRef(null),d=S.useRef(0),h=S.useRef(0),f=S.useRef(null),p=S.useRef(null),m=S.useRef(null),g=S.useRef(!1),y=S.useCallback(()=>{r($=>($&&!g.current&&(m.current=$,h.current=Date.now()+hce),g.current=!1,null)),s(null),a(null),f.current=null},[]),x=S.useCallback($=>{p.current=$,m.current=null,g.current=!0},[]),{paragraphText:v,chapterKind:b,chapterTitle:w,language:j,enabled:N,excludeQuotes:C,excludePages:A,existingCitations:E}=t,O=(C??[]).join("␟");return S.useEffect(()=>{if(u.current&&(clearTimeout(u.current),u.current=null),!N||v.length<=80){c(!1);return}return f.current!==null&&Math.abs(v.length-f.current.length)>20&&(r(null),s(null),a(null),f.current=null),c(!0),u.current=setTimeout(async()=>{const $=Date.now();if($-d.current<LUt||$<h.current){c(!1);return}try{d.current=Date.now();const{data:T,error:M}=await pe.functions.invoke("ghost_suggestion",{body:{paragraph_text:v,chapter_kind:b,chapter_title:w,language:j,exclude_quotes:C??[],exclude_pages:A??[],existing_citations:E??[]}});if(M)throw M;const k=(T==null?void 0:T.suggestion)??null,D=(T==null?void 0:T.evidence)??null;if(!k){r(null),s(null),a(null);return}const K=(C??[]).map(t0),H=!!(D!=null&&D.quote_text)&&K.includes(t0(D.quote_text)),ee=!!p.current&&fce(k,p.current)>.85,V=!!m.current&&fce(k,m.current)>.85,B=t0(v).includes(t0(k));if(H||ee||V||B){m.current=k,h.current=Date.now()+hce,r(null),s(null),a(null);return}r(k),s((T==null?void 0:T.citation)??null),a(D),f.current=v}catch(T){console.error("Ghost suggestion failed:",T),r(null),s(null),a(null)}finally{c(!1)}},1500),()=>{u.current&&clearTimeout(u.current)}},[v,b,w,j,N,O]),{suggestion:e,citation:n,evidence:i,isLoading:l,clearSuggestion:y,markAccepted:x}}const pce=1500;function mce(t){return t?t.split(/\n{2,}/).map(e=>`<p>${e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br/>")}</p>`).join(""):""}function g6(t,e){if(!t)return t;const r=YL[e].pagePrefix;return r==="p."?t:t.replace(/\bpp?\.\s*/g,`${r} `)}function x6(t,e){const r=t.trim();if(!e)return r;const n=r.match(/([.!?])$/);return n?`${r.slice(0,-1).trimEnd()} ${e}${n[1]}`:`${r} ${e}`}function gce({sectionId:t,html:e,plainText:r,onChange:n,placeholder:s,chapterKind:i="theory",chapterTitle:a="",language:l="en"}){const{register:c,unregister:u,setActiveId:d}=LK(),{open:h}=FK(),{user:f}=Ht(),[p]=o2e(),m=e!=null&&e.trim()?e:r?mce(r):"",g=S.useRef(m),[y,x]=S.useState([]),v=S.useRef([]);S.useEffect(()=>{v.current=y},[y]);const b=S.useRef({suggestion:null,citation:null,evidence:null,clearSuggestion:()=>{},markAccepted:B=>{}}),w=K$t({extensions:[dzt.configure({heading:{levels:[1,2,3]}}),$8t,JBt.configure({openOnClick:!1,autolink:!0,HTMLAttributes:{class:"underline text-primary"}}),yUt.configure({resizable:!1}),s2e,n2e,r2e,_Ut,PUt,MUt],content:m,editorProps:{attributes:{class:"prose prose-sm dark:prose-invert max-w-none focus:outline-none min-h-[80px] text-[15px] leading-relaxed"},handleClickOn(B,z,F,G,Q){const ie=Q.target,se=ie==null?void 0:ie.closest("[data-citation-key]");if(!se)return!1;Q.preventDefault();const q=se.getAttribute("data-citation-key")??"",L=se.getAttribute("data-citation-raw")??"",Z=se.getAttribute("data-citation-surname")??"",J=se.getAttribute("data-citation-author-phrase")??"",W=se.getAttribute("data-citation-year")??"",X=se.getAttribute("data-citation-page")??"";return h({sectionId:t,citationKey:q,raw:L,surname:Z,authorPhrase:J,year:W?parseInt(W,10):null,page:X?parseInt(X,10):null}),!0},handleKeyDown(B,z){const{suggestion:F,citation:G,evidence:Q,clearSuggestion:ie,markAccepted:se}=b.current;if(z.key==="Tab"&&F){z.preventDefault();const q=g6(G,l),L=x6(F,q),{from:Z}=B.state.selection,J=Z>0?B.state.doc.textBetween(Z-1,Z,"",""):"",X=(!!J&&!/\s/.test(J)?" ":"")+L;return B.dispatch(B.state.tr.insertText(X)),se(F),N(Q),ie(),!0}return z.key==="Escape"?(ie(),!0):!1}},onFocus(){d(t)},onUpdate({editor:B}){const z=B.getHTML();z!==g.current&&(g.current=z,n({html:z,text:B.getText()}))}}),j=S.useCallback(async()=>{if(!t||!f){x([]);return}const{data:B,error:z}=await pe.from("section_evidence").select("document_id, page_number, quote_text, citation_text").eq("section_id",t);if(z){console.error("Failed to load section evidence:",z);return}x(B??[])},[t,f]);S.useEffect(()=>{j()},[j]),S.useEffect(()=>{const B=z=>{const F=z.detail;(!(F!=null&&F.section_id)||F.section_id===t)&&j()};return window.addEventListener("ghost-evidence-accepted",B),()=>window.removeEventListener("ghost-evidence-accepted",B)},[t,j]);const N=S.useCallback(async B=>{if(!B||!t||!f||v.current.some(G=>G.document_id===B.document_id&&(G.page_number??null)===(B.page_number??null)&&(G.quote_text??"").trim()===(B.quote_text??"").trim()))return;const{error:F}=await pe.from("section_evidence").insert({user_id:f.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});if(F){console.error("Failed to persist evidence:",F);return}window.dispatchEvent(new CustomEvent("ghost-evidence-accepted",{detail:{section_id:t}}))},[t,f]),C=S.useMemo(()=>{if(!(w!=null&&w.state))return"";const{doc:B,selection:z}=w.state,F=B.textBetween(0,z.$from.pos,`

`," ");return F.length>pce?F.slice(F.length-pce):F},[w==null?void 0:w.state]),A=S.useMemo(()=>y.map(B=>B.quote_text).filter(Boolean),[y]),E=S.useMemo(()=>y.map(B=>({document_id:B.document_id,page_number:B.page_number})),[y]),O=S.useMemo(()=>y.map(B=>B.citation_text).filter(B=>!!B),[y]),{suggestion:$,citation:T,evidence:M,isLoading:k,clearSuggestion:D,markAccepted:K}=$Ut({paragraphText:C,chapterKind:i??"theory",chapterTitle:a??"",language:l,enabled:p&&!!f&&!!(w!=null&&w.isFocused),excludeQuotes:A,excludePages:E,existingCitations:O});S.useEffect(()=>{b.current={suggestion:$,citation:T,evidence:M,clearSuggestion:D,markAccepted:K}},[$,T,M,D,K]),S.useEffect(()=>{p||D()},[p,D]),S.useEffect(()=>{if(!w)return;const B=g6(T,l);IUt(w.view,$?x6($,B):null)},[w,$,T,l]),S.useEffect(()=>{w&&RUt(w.view,k&&!$)},[w,k,$]);const[H,ee]=S.useState(null);if(S.useEffect(()=>{if(!w||!$){ee(G=>G===null?G:null);return}let B=null;const z=()=>{const G=w.view.dom.querySelector("[data-ghost-suggestion='true']");if(!G)return;const Q=G.getClientRects(),ie=Q.length>0?Q[Q.length-1]:G.getBoundingClientRect(),se={top:ie.bottom+6,left:ie.left};ee(q=>q&&Math.abs(q.top-se.top)<1&&Math.abs(q.left-se.left)<1?q:se)},F=()=>{B!==null&&cancelAnimationFrame(B),B=requestAnimationFrame(()=>{B=null,z()})};return F(),window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{B!==null&&cancelAnimationFrame(B),window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[w,$]),S.useEffect(()=>{if(!w)return;const B=()=>{b.current.suggestion&&b.current.clearSuggestion()};return w.on("update",B),w.on("selectionUpdate",B),()=>{w.off("update",B),w.off("selectionUpdate",B)}},[w]),S.useEffect(()=>{if(w)return c(t,w),()=>u(t)},[w,t,c,u]),S.useEffect(()=>{if(!w)return;const B=e!=null&&e.trim()?e:r?mce(r):"";B&&B!==g.current&&(g.current=B,w.commands.setContent(B,{emitUpdate:!1}))},[e,r]),!w)return null;const V=g6(T,l);return o.jsxs(o.Fragment,{children:[o.jsx(RAe,{editor:w,placeholder:s}),$&&H&&cc.createPortal(o.jsxs("div",{className:"ghost-action-bar ghost-action-bar--floating",style:{top:H.top,left:H.left},children:[o.jsxs("button",{className:"ghost-accept-btn",onClick:()=>{const B=x6($,V),{from:z}=w.state.selection,F=z>0?w.state.doc.textBetween(z-1,z,"",""):"",G=!!F&&!/\s/.test(F);w.commands.insertContent((G?" ":"")+B),K($),N(M),D()},children:["Akzeptieren ",o.jsx("span",{"aria-hidden":!0,children:"→"})]}),o.jsx("button",{className:"ghost-dismiss-btn",onClick:()=>D(),children:"Verwerfen"})]}),document.body)]})}const xce={introduction:"Introduction",theory:"Theory",methodology:"Methodology",results:"Results",discussion:"Discussion",conclusion:"Conclusion",references:"References",custom:"Custom"};function yce({kind:t,isActive:e,hasDraft:r,onImport:n,onChangeKind:s,aiAvailability:i="hidden",aiTooltip:a,onCreateWithAI:l,onAddSection:c,canAddSubsection:u,onAddSubsection:d,onDeleteSection:h,activeSectionTitle:f,onOpenSupervisor:p}){const m=t==="theory"?"Theory":t==="methodology"?"Methodology":null,g="w-10 h-10 inline-flex items-center justify-center rounded-md transition-colors";return o.jsxs("div",{className:Pe("absolute -left-12 top-0 z-10 flex flex-col items-center gap-0.5 opacity-100"),children:[c&&o.jsx(ri,{delayDuration:150,children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx("button",{type:"button",onClick:c,className:Pe(g,"text-muted-foreground hover:text-primary hover:bg-primary/10"),"aria-label":"Add section",children:o.jsx(Bs,{className:"w-6 h-6"})})}),o.jsx(xr,{side:"right",className:"text-xs",children:"Add section"})]})}),u&&d&&o.jsx(ri,{delayDuration:150,children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx("button",{type:"button",onClick:d,className:Pe(g,"h-8 text-muted-foreground hover:text-primary hover:bg-primary/10"),"aria-label":"Add subsection",children:o.jsx(Khe,{className:"w-5 h-5"})})}),o.jsx(xr,{side:"right",className:"text-xs",children:"Add subsection"})]})}),p&&o.jsx(ri,{delayDuration:150,children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,className:Pe(g,"text-muted-foreground hover:text-primary hover:bg-primary/10"),"aria-label":"Thesis Supervisor",children:o.jsx(_N,{className:"w-6 h-6"})})}),o.jsx(xr,{side:"right",className:"text-xs",children:"Thesis Supervisor"})]})}),i!=="hidden"&&o.jsx(ri,{delayDuration:150,children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx("button",{type:"button",onClick:i==="ready"?()=>l==null?void 0:l(f):void 0,disabled:i==="soon",className:Pe(g,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:o.jsx(Sr,{className:"w-6 h-6"})})}),o.jsx(xr,{side:"right",className:"text-xs",children:a??(i==="ready"?"Create with AI":"Coming soon")})]})}),o.jsx("button",{type:"button",title:"Drag to reorder (coming soon)",className:Pe(g,"text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted cursor-grab"),tabIndex:-1,children:o.jsx(JOe,{className:"w-6 h-6"})}),o.jsxs(oCe,{children:[o.jsx(lCe,{asChild:!0,children:o.jsx("button",{type:"button",title:"Chapter actions",className:Pe(g,"text-muted-foreground hover:text-foreground hover:bg-muted"),children:o.jsx(qOe,{className:"w-6 h-6"})})}),o.jsxs(HG,{side:"right",align:"start",className:"w-60 p-1.5",children:[m&&r&&o.jsxs(o.Fragment,{children:[o.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 ",m," Draft"]}),o.jsx("div",{className:"h-px bg-border my-1"})]}),h&&o.jsx("button",{type:"button",onClick:h,className:"w-full text-left px-2.5 py-1.5 rounded text-sm text-destructive hover:bg-destructive/10",children:"Delete section"}),h&&o.jsx("div",{className:"h-px bg-border my-1"}),o.jsx("div",{className:"px-2.5 py-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:"Chapter kind"}),Object.keys(xce).map(y=>o.jsx("button",{type:"button",onClick:()=>s(y),className:Pe("w-full text-left px-2.5 py-1 rounded text-sm hover:bg-muted",y===t&&"text-primary font-medium"),children:xce[y]},y))]})]})]})}var C5="Switch",[FUt,i9t]=Vs(C5),[BUt,zUt]=FUt(C5),d2e=S.forwardRef((t,e)=>{const{__scopeSwitch:r,name:n,checked:s,defaultChecked:i,required:a,disabled:l,value:c="on",onCheckedChange:u,form:d,...h}=t,[f,p]=S.useState(null),m=qt(e,b=>p(b)),g=S.useRef(!1),y=f?d||!!f.closest("form"):!0,[x,v]=ca({prop:s,defaultProp:i??!1,onChange:u,caller:C5});return o.jsxs(BUt,{scope:r,checked:x,disabled:l,children:[o.jsx(ft.button,{type:"button",role:"switch","aria-checked":x,"aria-required":a,"data-state":m2e(x),"data-disabled":l?"":void 0,disabled:l,value:c,...h,ref:m,onClick:Qe(t.onClick,b=>{v(w=>!w),y&&(g.current=b.isPropagationStopped(),g.current||b.stopPropagation())})}),y&&o.jsx(p2e,{control:f,bubbles:!g.current,name:n,value:c,checked:x,required:a,disabled:l,form:d,style:{transform:"translateX(-100%)"}})]})});d2e.displayName=C5;var h2e="SwitchThumb",f2e=S.forwardRef((t,e)=>{const{__scopeSwitch:r,...n}=t,s=zUt(h2e,r);return o.jsx(ft.span,{"data-state":m2e(s.checked),"data-disabled":s.disabled?"":void 0,...n,ref:e})});f2e.displayName=h2e;var UUt="SwitchBubbleInput",p2e=S.forwardRef(({__scopeSwitch:t,control:e,checked:r,bubbles:n=!0,...s},i)=>{const a=S.useRef(null),l=qt(a,i),c=W9(r),u=ZW(e);return S.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]),o.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:l,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});p2e.displayName=UUt;function m2e(t){return t?"checked":"unchecked"}var g2e=d2e,HUt=f2e;const Qm=S.forwardRef(({className:t,...e},r)=>o.jsx(g2e,{className:Pe("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:o.jsx(HUt,{className:Pe("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")})}));Qm.displayName=g2e.displayName;const WUt=["image/png","image/jpeg","image/gif","image/webp"],VUt=5*1024*1024;async function qUt(t,e,r){if(!WUt.includes(t.type))throw new Error("Please choose a PNG, JPG, GIF or WebP image.");if(t.size>VUt)throw new Error("Images can be at most 5 MB.");const n=(t.name.split(".").pop()||t.type.split("/")[1]||"png").toLowerCase(),s=`${e}/thesis-images/${r??"unassigned"}/${crypto.randomUUID()}.${n}`,{error:i}=await pe.storage.from("documents").upload(s,t,{contentType:t.type,upsert:!1});if(i)throw i;const a=await rM(s);return{storagePath:s,src:a??"",alt:t.name.replace(/\.[^.]+$/,"")}}function GUt({onEditThesis:t,onExport:e,exportLoading:r,allTheses:n,activeThesisId:s,onThesisSwitch:i}){const{activeEditor:a}=LK(),l=a,c=!l,[u,d]=o2e(),{user:h}=Ht(),f=S.useRef(null),[p,m]=S.useState(!1),g=!!(l!=null&&l.isActive("table")),y=async w=>{var N;const j=(N=w.target.files)==null?void 0:N[0];if(w.target.value="",!(!j||!l||!h)){m(!0);try{const C=await qUt(j,h.id,s??null);l.chain().focus().setImage({src:C.src,alt:C.alt,storagePath:C.storagePath}).run()}catch(C){It({title:"Image upload failed",description:(C==null?void 0:C.message)??"Please try again.",variant:"destructive"})}finally{m(!1)}}},x=w=>Pe("h-8 w-8 shrink-0 p-1 rounded hover:bg-muted text-muted-foreground transition-colors disabled:opacity-40 disabled:cursor-not-allowed [&_svg]:size-[16px]",w&&"bg-muted text-foreground"),v=w=>w.preventDefault(),b=w=>()=>{l&&w()};return o.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:[o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!1),onClick:b(()=>l==null?void 0:l.chain().focus().undo().run()),disabled:c||!(l!=null&&l.can().undo()),title:"Undo",children:o.jsx(ife,{className:"w-[16px] h-[16px]"})}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!1),onClick:b(()=>l==null?void 0:l.chain().focus().redo().run()),disabled:c||!(l!=null&&l.can().redo()),title:"Redo",children:o.jsx(jMe,{className:"w-[16px] h-[16px]"})}),o.jsx("span",{className:"w-px h-5 shrink-0 bg-border mx-1.5"}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("heading",{level:1}))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleHeading({level:1}).run()),disabled:c,title:"Heading 1",children:o.jsx(tMe,{className:"w-[16px] h-[16px]"})}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("heading",{level:2}))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleHeading({level:2}).run()),disabled:c,title:"Heading 2",children:o.jsx(rMe,{className:"w-[16px] h-[16px]"})}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("heading",{level:3}))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleHeading({level:3}).run()),disabled:c,title:"Heading 3",children:o.jsx(nMe,{className:"w-[16px] h-[16px]"})}),o.jsx("span",{className:"w-px h-5 shrink-0 bg-border mx-1.5"}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("bold"))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleBold().run()),disabled:c,title:"Bold",children:o.jsx(LOe,{className:"w-[16px] h-[16px]"})}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("italic"))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleItalic().run()),disabled:c,title:"Italic",children:o.jsx(aMe,{className:"w-[16px] h-[16px]"})}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("underline"))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleUnderline().run()),disabled:c,title:"Underline",children:o.jsx(IMe,{className:"w-[16px] h-[16px]"})}),o.jsx("span",{className:"w-px h-5 shrink-0 bg-border mx-1.5"}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("bulletList"))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleBulletList().run()),disabled:c,title:"Bullet list",children:o.jsx(dMe,{className:"w-[16px] h-[16px]"})}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("orderedList"))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleOrderedList().run()),disabled:c,title:"Numbered list",children:o.jsx(uMe,{className:"w-[16px] h-[16px]"})}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("blockquote"))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleBlockquote().run()),disabled:c,title:"Quote",children:o.jsx(ua,{className:"w-[16px] h-[16px]"})}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!!(l!=null&&l.isActive("codeBlock"))),onClick:b(()=>l==null?void 0:l.chain().focus().toggleCodeBlock().run()),disabled:c,title:"Code block",children:o.jsx(Xhe,{className:"w-[16px] h-[16px]"})}),o.jsxs(_9,{children:[o.jsx(N9,{asChild:!0,disabled:c,children:o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(g),disabled:c,title:"Table",children:o.jsx(AMe,{className:"w-[16px] h-[16px]"})})}),o.jsxs(yD,{align:"start",onCloseAutoFocus:w=>w.preventDefault(),children:[o.jsx(Ha,{onSelect:b(()=>l==null?void 0:l.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()),children:"Insert table (3×3)"}),o.jsx(g0,{}),o.jsx(Ha,{disabled:!g,onSelect:b(()=>l==null?void 0:l.chain().focus().addRowBefore().run()),children:"Add row above"}),o.jsx(Ha,{disabled:!g,onSelect:b(()=>l==null?void 0:l.chain().focus().addRowAfter().run()),children:"Add row below"}),o.jsx(Ha,{disabled:!g,onSelect:b(()=>l==null?void 0:l.chain().focus().deleteRow().run()),children:"Delete row"}),o.jsx(g0,{}),o.jsx(Ha,{disabled:!g,onSelect:b(()=>l==null?void 0:l.chain().focus().addColumnBefore().run()),children:"Add column left"}),o.jsx(Ha,{disabled:!g,onSelect:b(()=>l==null?void 0:l.chain().focus().addColumnAfter().run()),children:"Add column right"}),o.jsx(Ha,{disabled:!g,onSelect:b(()=>l==null?void 0:l.chain().focus().deleteColumn().run()),children:"Delete column"}),o.jsx(g0,{}),o.jsx(Ha,{disabled:!g,onSelect:b(()=>l==null?void 0:l.chain().focus().toggleHeaderRow().run()),children:"Toggle header row"}),o.jsx(Ha,{disabled:!g,className:"text-destructive",onSelect:b(()=>l==null?void 0:l.chain().focus().deleteTable().run()),children:"Delete table"})]})]}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!1),onClick:()=>{var w;return(w=f.current)==null?void 0:w.click()},disabled:c||p||!h,title:"Insert image",children:p?o.jsx(Xe,{className:"w-[16px] h-[16px] animate-spin"}):o.jsx(iMe,{className:"w-[16px] h-[16px]"})}),o.jsx("input",{ref:f,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:y}),o.jsx("div",{className:"flex-1"}),o.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground whitespace-nowrap mr-1 cursor-pointer",children:["Fox AI autocomplete",o.jsx(Qm,{checked:u,onCheckedChange:d,"aria-label":"Fox AI autocomplete"})]}),o.jsx("span",{className:"w-px h-5 shrink-0 bg-border mx-1.5"}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!1),onClick:t,disabled:!t,title:"Edit Thesis",children:o.jsx(HW,{className:"w-[16px] h-[16px]"})}),o.jsx(me,{variant:"ghost",size:"icon",type:"button",onMouseDown:v,className:x(!1),onClick:e,disabled:r||!e,title:"Export",children:r?o.jsx(Xe,{className:"w-[16px] h-[16px] animate-spin"}):o.jsx(ko,{className:"w-[16px] h-[16px]"})}),n&&n.length>1&&i&&o.jsxs("div",{className:"relative flex items-center ml-2",children:[o.jsx("select",{value:s??"",onChange:w=>i(w.target.value),className:"text-xs bg-transparent border rounded-md px-2 py-1 pr-6 cursor-pointer focus:outline-none max-w-[180px] text-foreground appearance-none",style:{borderColor:"hsl(var(--border))"},children:n.map(w=>o.jsx("option",{value:w.id,children:w.title.length>35?w.title.slice(0,35)+"…":w.title},w.id))}),o.jsx(ia,{className:"absolute right-1.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground pointer-events-none"})]})]})}function KUt({thesisId:t,chapterId:e,chapterTitle:r,writingLanguage:n,isGenerating:s,onGenerate:i,onCancel:a,variant:l="inline",initialTopic:c,targetSectionId:u}){const[d,h]=S.useState(c??"");S.useEffect(()=>{h(c??"")},[c]);const[f,p]=S.useState("auto"),[m,g]=S.useState(!1),[y,x]=S.useState(null),[v,b]=S.useState([]),[w,j]=S.useState({}),[N,C]=S.useState(""),[A,E]=S.useState(!1),[O,$]=S.useState(null),[T,M]=S.useState({}),k=Z=>Z.doi?`doi:${Z.doi.toLowerCase()}`:Z.id?`oa:${Z.id}`:`title:${(Z.title||Z.display_name||"").toLowerCase().replace(/\s+/g," ").trim()}`,D=Z=>Z.pdf_verified===!0&&!!Z.verified_pdf_url,K=async()=>{const Z=(N||d).trim();if(!Z){It({title:"Enter a search query or topic",variant:"destructive"});return}E(!0),$(null);try{const{data:J,error:W}=await pe.functions.invoke("literature_discovery",{body:{action:"search",query:Z}});if(W)throw W;const X=(J==null?void 0:J.results)??(J==null?void 0:J.works)??(J==null?void 0:J.items)??[];$(X),X.length===0&&It({title:"No results",description:"Try a different query."})}catch(J){It({title:"OpenAlex search failed",description:(J==null?void 0:J.message)??"Unknown error",variant:"destructive"})}finally{E(!1)}},H=async Z=>{const J=k(Z);M(W=>({...W,[J]:{status:"loading"}}));try{const{data:W,error:X}=await pe.functions.invoke("literature_discovery",{body:{action:"claim",work:Z}});if(X)throw X;const he=W==null?void 0:W.import_status;M(P=>({...P,[J]:{status:"done",import_status:he}})),It({title:"Added to My Library"})}catch(W){M(X=>{const he={...X};return delete he[J],he}),It({title:"Could not add to library",description:(W==null?void 0:W.message)??"Unknown error",variant:"destructive"})}},ee=Z=>{const J=Z.authors;return!J||Array.isArray(J)&&J.length===0?"":typeof J[0]=="string"?J.join(", "):J.map(W=>W.display_name||W.name||"").filter(Boolean).join(", ")},V=Z=>typeof Z.is_oa=="boolean"?Z.is_oa:typeof Z.open_access=="boolean"?Z.open_access:Z.open_access&&typeof Z.open_access=="object"?!!Z.open_access.is_oa:!1,B=async()=>{var Z;g(!0);try{const J={thesis_id:t,chapter_id:e,topic:d};console.log("[suggest_sources_for_chapter] REQUEST →",J);const{data:W,error:X}=await pe.functions.invoke("suggest_sources_for_chapter",{body:J});if(console.log("[suggest_sources_for_chapter] RESPONSE ←",{data:W,error:X}),console.log("[suggest_sources_for_chapter] query field:",W==null?void 0:W.query),console.log("[suggest_sources_for_chapter] sources count:",((Z=W==null?void 0:W.sources)==null?void 0:Z.length)??0),console.log("[suggest_sources_for_chapter] sources:",W==null?void 0:W.sources),X)throw X;const he=(W==null?void 0:W.sources)??[];x(he),he.length===0&&It({title:"No matching sources",description:"Add more documents to your library or refine the topic, or switch to manual selection."})}catch(J){It({title:"Could not suggest sources",description:(J==null?void 0:J.message)??"Unknown error",variant:"destructive"})}finally{g(!1)}},z=async()=>{const{data:Z}=await pe.from("documents").select("id,title,original_filename,page_count,source_type").order("created_at",{ascending:!1}).limit(100);b((Z??[]).map(J=>({id:J.id,title:J.title||J.original_filename||"Untitled",page_count:J.page_count,citationOnly:J.source_type==="standalone"||!J.page_count})))},F=async Z=>{p(Z),x(null),Z==="manual"&&v.length===0&&await z()},G=Z=>{x(J=>J&&J.filter(W=>W.document_id!==Z))},Q=(Z,J)=>{j(W=>{const X={...W};return X[Z]?delete X[Z]:X[Z]={from:1,to:Math.min(J??15,15)},X})},ie=async()=>{if(f==="auto"){if(!y||y.length===0){It({title:"Find sources first",description:'Click "Find relevant sources" to auto-select pages.',variant:"destructive"});return}const Z={};for(const J of y){const W=J.page_ranges[0];W&&(Z[J.document_id]=W)}await i({text:d,selected:y,pageRanges:Z})}else{const Z=Object.keys(w);if(Z.length===0){It({title:"Select at least one source",variant:"destructive"});return}const J=Z.map(W=>{const X=v.find(he=>he.id===W);return{document_id:W,document_title:X.title,score:0,page_ranges:[w[W]],pages:[]}});await i({text:d,selected:J,pageRanges:w})}},se=l==="sheet",q=se?"flex min-h-0 flex-col bg-background":"mt-4 overflow-hidden rounded-2xl border border-border bg-background shadow-sm",L=f==="auto"?(y==null?void 0:y.length)??0:f==="manual"?Object.keys(w).length:0;return o.jsxs("div",{className:q,children:[o.jsx("div",{className:`border-b border-border/70 ${se?"px-5 pb-4 pt-5":"px-5 py-4"}`,children:o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(Sr,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"truncate text-sm font-semibold text-foreground",children:se?"Create with AI":`Generate Theory for “${r}”`}),se&&o.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Theory"})]}),se&&o.jsx("div",{className:"mt-0.5 text-xs font-medium text-muted-foreground",children:"Theory Builder"})]})]}),o.jsxs("p",{className:"mt-3 max-w-md text-xs leading-relaxed text-muted-foreground",children:["Draft a source-grounded theoretical section from your literature. Quotes remain linked to the original sources. APA7, ",n.toUpperCase(),"."]})]}),a&&o.jsx(me,{variant:"ghost",size:"icon",onClick:a,disabled:s,className:"h-8 w-8 shrink-0 rounded-lg text-muted-foreground","aria-label":"Close",children:o.jsx(fn,{className:"h-4 w-4"})})]})}),o.jsxs("div",{className:"px-5 py-5 space-y-6",children:[o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"1"}),o.jsx(Se,{htmlFor:"theory-topic",className:"text-sm font-semibold",children:"Define the focus"})]}),o.jsx("p",{className:"ml-7 mt-1 text-[11px] leading-relaxed text-muted-foreground",children:"Tell Academly what this section should cover."})]}),o.jsx(Ue,{id:"theory-topic",value:d,onChange:Z=>h(Z.target.value),placeholder:`e.g. "${r}: key concepts and recent research"`,className:"h-11 rounded-xl border-border bg-background px-3 shadow-none",disabled:s})]}),o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"2"}),o.jsx(Se,{className:"text-sm font-semibold",children:"Choose sources"})]}),f!=="openalex"&&L>0&&o.jsxs("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-semibold text-primary",children:[L," ",L===1?"source":"sources"]})]}),o.jsx("p",{className:"ml-7 mt-1 text-[11px] leading-relaxed text-muted-foreground",children:"Use recommended literature, choose from your library, or discover new research."})]}),o.jsxs("div",{className:"grid grid-cols-3 rounded-xl bg-muted/60 p-1",children:[o.jsx("button",{type:"button",onClick:()=>F("auto"),disabled:s,className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${f==="auto"?"bg-background text-foreground shadow-sm ring-1 ring-border/70":"text-muted-foreground hover:text-foreground"}`,children:"Auto-select"}),o.jsx("button",{type:"button",onClick:()=>F("manual"),disabled:s,className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${f==="manual"?"bg-background text-foreground shadow-sm ring-1 ring-border/70":"text-muted-foreground hover:text-foreground"}`,children:"Manual"}),o.jsx("button",{type:"button",onClick:()=>F("openalex"),disabled:s,className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${f==="openalex"?"bg-background text-foreground shadow-sm ring-1 ring-border/70":"text-muted-foreground hover:text-foreground"}`,children:"OpenAlex"})]})]}),f==="auto"&&o.jsxs("section",{className:"space-y-3",children:[!y&&o.jsx("div",{className:"rounded-xl border border-primary/15 bg-primary/[0.035] p-4",children:o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-foreground",children:"Recommended sources"}),o.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:"Academly will search your library and select the most relevant pages for this section."})]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:B,disabled:m||s,className:"shrink-0 gap-1.5 rounded-lg bg-background",children:[m?o.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(Yc,{className:"h-3.5 w-3.5"}),"Find sources"]})]})}),y&&y.length>0&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Selected for generation"}),o.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Remove any source you do not want Academly to use."})]}),o.jsxs(me,{variant:"ghost",size:"sm",onClick:B,disabled:m||s,className:"h-8 shrink-0 gap-1.5 px-2 text-[11px] text-muted-foreground",children:[m?o.jsx(Xe,{className:"h-3 w-3 animate-spin"}):o.jsx(Yc,{className:"h-3 w-3"}),"Re-run"]})]}),o.jsx("ul",{className:"space-y-2",children:y.map(Z=>{var J;return o.jsx("li",{className:"group rounded-xl border border-border/80 bg-background p-3 transition-colors hover:border-border",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/8 text-primary",children:o.jsx(nr,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-sm font-medium leading-snug text-foreground",children:Z.document_title}),o.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:o.jsxs("span",{className:"rounded-md bg-muted px-1.5 py-0.5",children:["Pages"," ",Z.page_ranges.map(W=>W.from===W.to?`${W.from}`:`${W.from}–${W.to}`).join(", ")]})}),((J=Z.pages[0])==null?void 0:J.snippet)&&o.jsxs("p",{className:"mt-2 line-clamp-2 text-[11px] italic leading-relaxed text-muted-foreground/85",children:["“",Z.pages[0].snippet,"”"]})]}),o.jsx("button",{type:"button",onClick:()=>G(Z.document_id),disabled:s,className:"rounded-md p-1 text-muted-foreground transition hover:bg-muted hover:text-foreground","aria-label":"Remove source",children:o.jsx(fn,{className:"h-3.5 w-3.5"})})]})},Z.document_id)})})]})]}),f==="manual"&&o.jsxs("section",{className:"space-y-2",children:[o.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Your library"}),o.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-border/80 bg-background",children:v.length===0?o.jsx("div",{className:"p-4 text-xs text-muted-foreground",children:"No documents found."}):o.jsx("div",{className:"divide-y divide-border/70",children:v.map(Z=>{const J=!!w[Z.id];return o.jsxs("label",{className:`flex items-center gap-3 px-3 py-3 transition-colors ${Z.citationOnly?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-muted/35"} ${J?"bg-primary/[0.025]":""}`,children:[o.jsx("input",{type:"checkbox",checked:J,onChange:()=>!Z.citationOnly&&Q(Z.id,Z.page_count),disabled:s||Z.citationOnly,className:"h-4 w-4 rounded border-border accent-primary"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:Z.title}),o.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:Z.citationOnly?"No text — citation only":J?`Pages ${w[Z.id].from}–${w[Z.id].to} selected`:"Select source"})]}),o.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground",children:[Z.page_count??"—","p"]})]},Z.id)})})})]}),f==="openalex"&&o.jsxs("section",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Discover literature"}),o.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:"Search OpenAlex and add relevant publications to your library. They are not added to the thesis automatically."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative min-w-0 flex-1",children:[o.jsx(Ti,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),o.jsx(Ue,{value:N,onChange:Z=>C(Z.target.value),onKeyDown:Z=>{Z.key==="Enter"&&(Z.preventDefault(),K())},placeholder:"Search literature...",className:"h-10 rounded-xl bg-background pl-9",disabled:A})]}),o.jsxs(me,{size:"sm",onClick:K,disabled:A,className:"h-10 shrink-0 gap-1.5 rounded-xl px-3",children:[A?o.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(Qhe,{className:"h-3.5 w-3.5"}),"Search"]})]}),o.jsx("p",{className:"text-[10px] leading-relaxed text-muted-foreground",children:"If empty, Topic / focus is used as the search query."}),O&&O.length>0&&o.jsx("ul",{className:"max-h-[420px] space-y-2 overflow-y-auto pr-1",children:O.map(Z=>{const J=Z.title||Z.display_name||"Untitled",W=ee(Z),X=Z.year??Z.publication_year??"",he=Z.journal||Z.host_venue||Z.venue||"",P=V(Z),oe=T[k(Z)],Y=D(Z),R=(oe==null?void 0:oe.status)==="loading",I=(oe==null?void 0:oe.status)==="done",U=(oe==null?void 0:oe.status)==="done"?oe.import_status==="fulltext_imported"?"Added · Fulltext":oe.import_status==="pdf_stored"?"Added · PDF stored":oe.import_status==="pdf_extract_failed"?"Added · Extract failed":"Added · Metadata":null;return o.jsx("li",{className:"rounded-xl border border-border/80 bg-background p-3",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:o.jsx(nr,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm font-medium leading-snug text-foreground",children:J}),W&&o.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:W}),o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:[X&&o.jsx("span",{children:X}),he&&o.jsx("span",{className:"max-w-[180px] truncate italic",children:he}),P&&o.jsx("span",{className:"rounded-md bg-emerald-500/10 px-1.5 py-0.5 font-semibold text-emerald-600 dark:text-emerald-400",children:"Open Access"}),o.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 font-medium text-muted-foreground",children:Y?"PDF available":"Metadata only"})]})]}),o.jsxs(me,{size:"sm",variant:I?"secondary":"outline",onClick:()=>H(Z),disabled:!!oe,className:"h-8 shrink-0 gap-1.5 rounded-lg px-2.5 text-[11px]",children:[R?o.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin"}):I?o.jsx(kr,{className:"h-3.5 w-3.5"}):null,I?U:"Add to Library"]})]})},Z.id)})})]}),f!=="openalex"&&o.jsx("div",{className:"rounded-xl border border-border/70 bg-muted/25 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2.5",children:[o.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-lg bg-background text-primary ring-1 ring-border/60",children:o.jsx(kr,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:"Evidence-aware generation"}),o.jsx("p",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:"Academly links generated evidence back to your original source passages for review."})]})]})})]}),f!=="openalex"&&o.jsx("div",{className:`border-t border-border/70 bg-background/95 px-5 py-4 ${se?"sticky bottom-0 z-10 backdrop-blur":""}`,children:o.jsxs(me,{onClick:ie,disabled:s,className:"h-11 w-full gap-2 rounded-xl font-semibold shadow-sm",children:[s?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(Sr,{className:"h-4 w-4"}),s?"Generating theory...":"Generate Theory"]})})]})}function YUt({thesisId:t,chapterId:e,chapterTitle:r,writingLanguage:n,isGenerating:s,onGenerate:i,onCancel:a,variant:l="inline",initialTopic:c,targetSectionId:u}){const[d,h]=S.useState(c??"");S.useEffect(()=>{h(c??"")},[c]);const[f,p]=S.useState(""),[m,g]=S.useState("auto"),[y,x]=S.useState(!1),[v,b]=S.useState(null),[w,j]=S.useState([]),[N,C]=S.useState({}),[A,E]=S.useState(""),[O,$]=S.useState(!1),[T,M]=S.useState(null),[k,D]=S.useState({}),K=W=>W.doi?`doi:${W.doi.toLowerCase()}`:W.id?`oa:${W.id}`:`title:${(W.title||W.display_name||"").toLowerCase().replace(/\s+/g," ").trim()}`,H=W=>W.pdf_verified===!0&&!!W.verified_pdf_url,ee=async()=>{const W=(A||d).trim();if(!W){It({title:"Enter a search query or topic",variant:"destructive"});return}$(!0),M(null);try{const{data:X,error:he}=await pe.functions.invoke("literature_discovery",{body:{action:"search",query:W}});if(he)throw he;const P=(X==null?void 0:X.results)??(X==null?void 0:X.works)??(X==null?void 0:X.items)??[];M(P),P.length===0&&It({title:"No results",description:"Try a different query."})}catch(X){It({title:"OpenAlex search failed",description:(X==null?void 0:X.message)??"Unknown error",variant:"destructive"})}finally{$(!1)}},V=async W=>{const X=K(W);D(he=>({...he,[X]:{status:"loading"}}));try{const{data:he,error:P}=await pe.functions.invoke("literature_discovery",{body:{action:"claim",work:W}});if(P)throw P;const oe=he==null?void 0:he.import_status;D(Y=>({...Y,[X]:{status:"done",import_status:oe}})),It({title:"Added to My Library"})}catch(he){D(P=>{const oe={...P};return delete oe[X],oe}),It({title:"Could not add to library",description:(he==null?void 0:he.message)??"Unknown error",variant:"destructive"})}},B=W=>{const X=W.authors;return!X||Array.isArray(X)&&X.length===0?"":typeof X[0]=="string"?X.join(", "):X.map(he=>he.display_name||he.name||"").filter(Boolean).join(", ")},z=W=>typeof W.is_oa=="boolean"?W.is_oa:typeof W.open_access=="boolean"?W.open_access:W.open_access&&typeof W.open_access=="object"?!!W.open_access.is_oa:!1,F=async()=>{var W;x(!0);try{const X={thesis_id:t,chapter_id:e,topic:d};console.log("[suggest_sources_for_chapter] REQUEST →",X);const{data:he,error:P}=await pe.functions.invoke("suggest_sources_for_chapter",{body:X});if(console.log("[suggest_sources_for_chapter] RESPONSE ←",{data:he,error:P}),console.log("[suggest_sources_for_chapter] query field:",he==null?void 0:he.query),console.log("[suggest_sources_for_chapter] sources count:",((W=he==null?void 0:he.sources)==null?void 0:W.length)??0),console.log("[suggest_sources_for_chapter] sources:",he==null?void 0:he.sources),P)throw P;const oe=(he==null?void 0:he.sources)??[];b(oe),oe.length===0&&It({title:"No matching sources",description:"Add more documents to your library or refine the topic, or switch to manual selection."})}catch(X){It({title:"Could not suggest sources",description:(X==null?void 0:X.message)??"Unknown error",variant:"destructive"})}finally{x(!1)}},G=async()=>{const{data:W}=await pe.from("documents").select("id,title,original_filename,page_count,source_type").order("created_at",{ascending:!1}).limit(100);j((W??[]).map(X=>({id:X.id,title:X.title||X.original_filename||"Untitled",page_count:X.page_count,citationOnly:X.source_type==="standalone"||!X.page_count})))},Q=async W=>{g(W),b(null),W==="manual"&&w.length===0&&await G()},ie=W=>{b(X=>X&&X.filter(he=>he.document_id!==W))},se=(W,X)=>{C(he=>{const P={...he};return P[W]?delete P[W]:P[W]={from:1,to:Math.min(X??15,15)},P})},q=async()=>{if(m==="auto"){if(!v||v.length===0){It({title:"Find sources first",description:'Click "Find relevant sources" to auto-select pages.',variant:"destructive"});return}const W={};for(const X of v){const he=X.page_ranges[0];he&&(W[X.document_id]=he)}await i({text:d,selected:v,pageRanges:W,ownWords:f})}else{const W=Object.keys(N);if(W.length===0){It({title:"Select at least one source",variant:"destructive"});return}const X=W.map(he=>{const P=w.find(oe=>oe.id===he);return{document_id:he,document_title:P.title,score:0,page_ranges:[N[he]],pages:[]}});await i({text:d,selected:X,pageRanges:N,ownWords:f})}},L=l==="sheet",Z=L?"flex min-h-0 flex-col bg-background":"mt-4 overflow-hidden rounded-2xl border border-border bg-background shadow-sm",J=m==="auto"?(v==null?void 0:v.length)??0:m==="manual"?Object.keys(N).length:0;return o.jsxs("div",{className:Z,children:[o.jsx("div",{className:`border-b border-border/70 ${L?"px-5 pb-4 pt-5":"px-5 py-4"}`,children:o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(Sr,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("h3",{className:"truncate text-sm font-semibold text-foreground",children:L?"Create with AI":`Generate Methodology for “${r}”`}),L&&o.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Methods"})]}),L&&o.jsx("div",{className:"mt-0.5 text-xs font-medium text-muted-foreground",children:"Methodology Builder"})]})]}),o.jsxs("p",{className:"mt-3 max-w-md text-xs leading-relaxed text-muted-foreground",children:["Draft a source-grounded methodology section using your literature and your own research approach. APA7,"," ",n.toUpperCase(),"."]})]}),a&&o.jsx(me,{variant:"ghost",size:"icon",onClick:a,disabled:s,className:"h-8 w-8 shrink-0 rounded-lg text-muted-foreground","aria-label":"Close",children:o.jsx(fn,{className:"h-4 w-4"})})]})}),o.jsxs("div",{className:"px-5 py-5 space-y-6",children:[o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"1"}),o.jsx(Se,{htmlFor:"methodology-topic",className:"text-sm font-semibold",children:"Define the focus"})]}),o.jsx("p",{className:"ml-7 mt-1 text-[11px] leading-relaxed text-muted-foreground",children:"Tell Academly which research design, procedure, or methodological focus this section should cover."})]}),o.jsx(Ue,{id:"methodology-topic",value:d,onChange:W=>h(W.target.value),placeholder:`e.g. "${r}: research design and procedure"`,className:"h-11 rounded-xl border-border bg-background px-3 shadow-none",disabled:s})]}),o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"2"}),o.jsxs(Se,{htmlFor:"methodology-own-words",className:"text-sm font-semibold",children:["Your Approach ",o.jsx("span",{className:"font-normal text-muted-foreground",children:"(optional)"})]})]}),o.jsx("p",{className:"ml-7 mt-1 text-[11px] leading-relaxed text-muted-foreground",children:"Add details about your actual research setup so the draft reflects what you plan to do."})]}),o.jsx("textarea",{id:"methodology-own-words",value:f,onChange:W=>p(W.target.value),placeholder:"Describe your own steps (sampling, tools, timeline, limitations, etc.).",className:"min-h-[100px] w-full rounded-xl border border-input bg-background px-3 py-3 text-sm shadow-none 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})]}),o.jsxs("section",{children:[o.jsxs("div",{className:"mb-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"3"}),o.jsx(Se,{className:"text-sm font-semibold",children:"Choose sources"})]}),m!=="openalex"&&J>0&&o.jsxs("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[10px] font-semibold text-primary",children:[J," ",J===1?"source":"sources"]})]}),o.jsx("p",{className:"ml-7 mt-1 text-[11px] leading-relaxed text-muted-foreground",children:"Use recommended literature, choose from your library, or discover new research."})]}),o.jsxs("div",{className:"grid grid-cols-3 rounded-xl bg-muted/60 p-1",children:[o.jsx("button",{type:"button",onClick:()=>Q("auto"),disabled:s,className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${m==="auto"?"bg-background text-foreground shadow-sm ring-1 ring-border/70":"text-muted-foreground hover:text-foreground"}`,children:"Auto-select"}),o.jsx("button",{type:"button",onClick:()=>Q("manual"),disabled:s,className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${m==="manual"?"bg-background text-foreground shadow-sm ring-1 ring-border/70":"text-muted-foreground hover:text-foreground"}`,children:"Manual"}),o.jsx("button",{type:"button",onClick:()=>Q("openalex"),disabled:s,className:`rounded-lg px-2 py-2 text-[11px] font-medium transition-all ${m==="openalex"?"bg-background text-foreground shadow-sm ring-1 ring-border/70":"text-muted-foreground hover:text-foreground"}`,children:"OpenAlex"})]})]}),m==="auto"&&o.jsxs("section",{className:"space-y-3",children:[!v&&o.jsx("div",{className:"rounded-xl border border-primary/15 bg-primary/[0.035] p-4",children:o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-foreground",children:"Recommended sources"}),o.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",children:"Academly will search your library and select the most relevant pages for this methodology section."})]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:F,disabled:y||s,className:"shrink-0 gap-1.5 rounded-lg bg-background",children:[y?o.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(Yc,{className:"h-3.5 w-3.5"}),"Find sources"]})]})}),v&&v.length>0&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Selected for generation"}),o.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:"Remove any source you do not want Academly to use."})]}),o.jsxs(me,{variant:"ghost",size:"sm",onClick:F,disabled:y||s,className:"h-8 shrink-0 gap-1.5 px-2 text-[11px] text-muted-foreground",children:[y?o.jsx(Xe,{className:"h-3 w-3 animate-spin"}):o.jsx(Yc,{className:"h-3 w-3"}),"Re-run"]})]}),o.jsx("ul",{className:"space-y-2",children:v.map(W=>{var X;return o.jsx("li",{className:"group rounded-xl border border-border/80 bg-background p-3 transition-colors hover:border-border",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/8 text-primary",children:o.jsx(nr,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-sm font-medium leading-snug text-foreground",children:W.document_title}),o.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:o.jsxs("span",{className:"rounded-md bg-muted px-1.5 py-0.5",children:["Pages"," ",W.page_ranges.map(he=>he.from===he.to?`${he.from}`:`${he.from}–${he.to}`).join(", ")]})}),((X=W.pages[0])==null?void 0:X.snippet)&&o.jsxs("p",{className:"mt-2 line-clamp-2 text-[11px] italic leading-relaxed text-muted-foreground/85",children:["“",W.pages[0].snippet,"”"]})]}),o.jsx("button",{type:"button",onClick:()=>ie(W.document_id),disabled:s,className:"rounded-md p-1 text-muted-foreground transition hover:bg-muted hover:text-foreground","aria-label":"Remove source",children:o.jsx(fn,{className:"h-3.5 w-3.5"})})]})},W.document_id)})})]})]}),m==="manual"&&o.jsxs("section",{className:"space-y-2",children:[o.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Your library"}),o.jsx("div",{className:"max-h-64 overflow-y-auto rounded-xl border border-border/80 bg-background",children:w.length===0?o.jsx("div",{className:"p-4 text-xs text-muted-foreground",children:"No documents found."}):o.jsx("div",{className:"divide-y divide-border/70",children:w.map(W=>{const X=!!N[W.id];return o.jsxs("label",{className:`flex items-center gap-3 px-3 py-3 transition-colors ${W.citationOnly?"cursor-not-allowed opacity-60":"cursor-pointer hover:bg-muted/35"} ${X?"bg-primary/[0.025]":""}`,children:[o.jsx("input",{type:"checkbox",checked:X,onChange:()=>!W.citationOnly&&se(W.id,W.page_count),disabled:s||W.citationOnly,className:"h-4 w-4 rounded border-border accent-primary"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:W.title}),o.jsx("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:W.citationOnly?"No text — citation only":X?`Pages ${N[W.id].from}–${N[W.id].to} selected`:"Select source"})]}),o.jsxs("span",{className:"shrink-0 text-[10px] tabular-nums text-muted-foreground",children:[W.page_count??"—","p"]})]},W.id)})})})]}),m==="openalex"&&o.jsxs("section",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Discover literature"}),o.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:"Search OpenAlex and add relevant publications to your library. They are not added to the thesis automatically."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("div",{className:"relative min-w-0 flex-1",children:[o.jsx(Ti,{className:"absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),o.jsx(Ue,{value:A,onChange:W=>E(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),ee())},placeholder:"Search literature...",className:"h-10 rounded-xl bg-background pl-9",disabled:O})]}),o.jsxs(me,{size:"sm",onClick:ee,disabled:O,className:"h-10 shrink-0 gap-1.5 rounded-xl px-3",children:[O?o.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(Qhe,{className:"h-3.5 w-3.5"}),"Search"]})]}),o.jsx("p",{className:"text-[10px] leading-relaxed text-muted-foreground",children:"If empty, Topic / focus is used as the search query."}),T&&T.length>0&&o.jsx("ul",{className:"max-h-[420px] space-y-2 overflow-y-auto pr-1",children:T.map(W=>{const X=W.title||W.display_name||"Untitled",he=B(W),P=W.year??W.publication_year??"",oe=W.journal||W.host_venue||W.venue||"",Y=z(W),R=k[K(W)],I=H(W),U=(R==null?void 0:R.status)==="loading",re=(R==null?void 0:R.status)==="done",ue=(R==null?void 0:R.status)==="done"?R.import_status==="fulltext_imported"?"Added · Fulltext":R.import_status==="pdf_stored"?"Added · PDF stored":R.import_status==="pdf_extract_failed"?"Added · Extract failed":"Added · Metadata":null;return o.jsx("li",{className:"rounded-xl border border-border/80 bg-background p-3",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:o.jsx(nr,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm font-medium leading-snug text-foreground",children:X}),he&&o.jsx("div",{className:"mt-1 truncate text-[11px] text-muted-foreground",children:he}),o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:[P&&o.jsx("span",{children:P}),oe&&o.jsx("span",{className:"max-w-[180px] truncate italic",children:oe}),Y&&o.jsx("span",{className:"rounded-md bg-emerald-500/10 px-1.5 py-0.5 font-semibold text-emerald-600 dark:text-emerald-400",children:"Open Access"}),o.jsx("span",{className:"rounded-md bg-muted px-1.5 py-0.5 font-medium text-muted-foreground",children:I?"PDF available":"Metadata only"})]})]}),o.jsxs(me,{size:"sm",variant:re?"secondary":"outline",onClick:()=>V(W),disabled:!!R,className:"h-8 shrink-0 gap-1.5 rounded-lg px-2.5 text-[11px]",children:[U?o.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin"}):re?o.jsx(kr,{className:"h-3.5 w-3.5"}):null,re?ue:"Add to Library"]})]})},W.id)})})]}),m!=="openalex"&&o.jsx("div",{className:"rounded-xl border border-border/70 bg-muted/25 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2.5",children:[o.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-lg bg-background text-primary ring-1 ring-border/60",children:o.jsx(kr,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{children:[o.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:"Evidence-aware generation"}),o.jsx("p",{className:"mt-0.5 text-[10px] leading-relaxed text-muted-foreground",children:"Academly links generated evidence back to your original source passages for review."})]})]})})]}),m!=="openalex"&&o.jsx("div",{className:`border-t border-border/70 bg-background/95 px-5 py-4 ${L?"sticky bottom-0 z-10 backdrop-blur":""}`,children:o.jsxs(me,{onClick:q,disabled:s,className:"h-11 w-full gap-2 rounded-xl font-semibold shadow-sm",children:[s?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(Sr,{className:"h-4 w-4"}),s?"Generating methodology...":"Generate Methodology"]})})]})}const XUt=new Set(["introduction","theory","methodology","results","findings"]),QUt=["introduction","einleitung","methodology","methodik","methods","methoden","findings","ergebnisse","results","auswertung","analyse","analysis","interviews","stand des wissens","theoretischer hintergrund","literature","literatur","theory","theorie"];function vce(t){if(t.kind&&XUt.has(t.kind))return!0;const e=t.title.toLowerCase();return QUt.some(r=>e.includes(r))}const v2={small:"Short (~500 words)",medium:"Medium (~1000 words)",big:"Long (~2000 words)"};function ZUt({targetChapterId:t,chapterTitle:e,chapters:r,writingLanguage:n,isGenerating:s,onGenerate:i,onCancel:a,variant:l="inline"}){const c=S.useMemo(()=>r.filter(v=>v.id!==t),[r,t]),u=S.useMemo(()=>c.filter(v=>v.word_count>0&&vce(v)).map(v=>v.id),[c]),[d,h]=S.useState(u),f=n,[p,m]=S.useState("medium");S.useEffect(()=>{h(u)},[u]);const g=v=>{h(b=>b.includes(v)?b.filter(w=>w!==v):[...b,v])},y=d.length>0&&!s,x=l==="sheet";return o.jsxs("div",{className:Pe("flex min-h-0 flex-col",x?"h-full bg-background":"rounded-xl border border-border bg-background shadow-sm"),children:[o.jsx("div",{className:Pe("border-b border-border/70",x?"px-5 py-5":"px-5 py-4"),children:o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(Sr,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Create with AI"}),o.jsx(kt,{variant:"secondary",className:"rounded-full px-2 py-0 text-[10px] font-semibold uppercase tracking-wide",children:"Discussion"})]}),o.jsx("p",{className:"mt-1 text-xs font-medium text-foreground/80",children:"Discussion Builder"}),o.jsxs("p",{className:"mt-1 max-w-md text-xs leading-relaxed text-muted-foreground",children:["Synthesize your existing thesis chapters into a structured discussion for “",e,"”."]})]})]}),a&&o.jsx(me,{type:"button",variant:"ghost",size:"icon",onClick:a,disabled:s,className:"h-8 w-8 shrink-0 rounded-full text-muted-foreground","aria-label":"Close",children:o.jsx(fn,{className:"h-4 w-4"})})]})}),o.jsx("div",{className:Pe("min-h-0 flex-1 overflow-y-auto",x?"px-5 py-5":"p-5"),children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("section",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"1"}),o.jsx(Se,{className:"text-sm font-semibold",children:"Choose source chapters"})]}),o.jsx("p",{className:"mt-1 pl-7 text-xs leading-relaxed text-muted-foreground",children:"Select the chapters Academly should synthesize and compare in the discussion."})]}),c.length===0?o.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 px-4 py-5 text-center",children:[o.jsx(nr,{className:"mx-auto h-5 w-5 text-muted-foreground"}),o.jsx("p",{className:"mt-2 text-sm font-medium text-foreground",children:"No other chapters available"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Add content to other thesis chapters before generating a discussion."})]}):o.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-background",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-border/70 bg-muted/20 px-3.5 py-2.5",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-foreground",children:"Available chapters"}),o.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Recommended chapters are preselected automatically."})]}),o.jsxs(kt,{variant:"secondary",className:"rounded-full text-[10px]",children:[d.length," selected"]})]}),o.jsx("div",{className:"max-h-72 overflow-y-auto p-2",children:o.jsx("div",{className:"space-y-1.5",children:c.map(v=>{const b=v.word_count>0,w=d.includes(v.id),j=b&&vce(v);return o.jsxs("label",{htmlFor:`disc-${v.id}`,className:Pe("group flex items-start gap-3 rounded-lg border px-3 py-2.5 transition-colors",w?"border-primary/25 bg-primary/[0.035]":"border-transparent hover:bg-muted/40",b?"cursor-pointer":"cursor-not-allowed opacity-45"),children:[o.jsx(aa,{id:`disc-${v.id}`,checked:w,onCheckedChange:()=>g(v.id),disabled:!b||s,className:"mt-0.5"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:v.title}),o.jsxs("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:[v.word_count," words"]})]}),o.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[j&&o.jsxs(kt,{variant:"secondary",className:"h-5 rounded-full px-2 text-[10px] font-medium",children:[o.jsx(No,{className:"mr-1 h-3 w-3"}),"Recommended"]}),!b&&o.jsx("span",{className:"text-[11px] text-muted-foreground",children:"No content available"})]})]})]},v.id)})})})]})]}),o.jsxs("section",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"2"}),o.jsx(Se,{className:"text-sm font-semibold",children:"Set discussion length"})]}),o.jsx("p",{className:"mt-1 pl-7 text-xs leading-relaxed text-muted-foreground",children:"Choose how detailed the discussion draft should be."})]}),o.jsxs("div",{className:"rounded-xl border border-border bg-background p-3.5",children:[o.jsx(Se,{className:"text-xs font-medium text-foreground",children:"Length"}),o.jsxs(pt,{value:p,onValueChange:v=>m(v),disabled:s,children:[o.jsx(ut,{className:"mt-2 h-10 bg-background",children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"small",children:v2.small}),o.jsx(Le,{value:"medium",children:v2.medium}),o.jsx(Le,{value:"big",children:v2.big})]})]})]})]}),o.jsx("div",{className:"rounded-xl border border-border bg-muted/20 px-3.5 py-3",children:o.jsxs("div",{className:"flex items-start gap-2.5",children:[o.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-lg bg-background text-muted-foreground shadow-sm ring-1 ring-border/60",children:o.jsx(nr,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-foreground",children:"Chapter-grounded synthesis"}),o.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:"The discussion is generated from the chapters you select and follows your thesis writing language."})]})]})})]})}),o.jsx("div",{className:Pe("border-t border-border/70 bg-background","px-5 py-4"),children:o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-[11px] font-medium text-foreground",children:d.length>0?`${d.length} chapter${d.length===1?"":"s"} selected`:"Select at least one chapter"}),o.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:v2[p]})]}),o.jsxs(me,{type:"button",disabled:!y,onClick:()=>i({sourceChapterIds:d,language:f,mode:p}),className:"h-10 min-w-[172px] gap-2 rounded-xl px-4 shadow-sm",children:[s?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(Yc,{className:"h-4 w-4"}),s?"Generating…":"Generate Discussion"]})]})})]})}const JUt=new Set(["introduction","theory","literature","methodology","results","findings","discussion","analysis"]),eHt=["introduction","einleitung","theory","theorie","theoretischer hintergrund","stand des wissens","literature","literatur","methodology","methodik","methods","methoden","findings","ergebnisse","results","auswertung","analyse","analysis","discussion","diskussion"],tHt=new Set(["references","conclusion"]);function rHt(t){if(t.kind&&tHt.has(t.kind))return!0;const e=t.title.toLowerCase();return/(referenc|bibliograp|literaturverz)/i.test(e)}function bce(t){if(t.kind&&JUt.has(t.kind))return!0;const e=t.title.toLowerCase();return eHt.some(r=>e.includes(r))}const b2={small:"Short (~500 words)",medium:"Medium (~1000 words)",big:"Long (~2000 words)"};function nHt({targetChapterId:t,chapterTitle:e,chapters:r,writingLanguage:n,isGenerating:s,onGenerate:i,onCancel:a,variant:l="inline"}){const c=S.useMemo(()=>r.filter(N=>N.id!==t&&!rHt(N)),[r,t]),u=S.useMemo(()=>c.filter(N=>N.word_count>0&&bce(N)).map(N=>N.id),[c]),[d,h]=S.useState(u),f=n,[p,m]=S.useState("medium"),[g,y]=S.useState(!0),[x,v]=S.useState(!0);S.useEffect(()=>{h(u)},[u]);const b=N=>{h(C=>C.includes(N)?C.filter(A=>A!==N):[...C,N])},w=d.length>0&&!s,j=l==="sheet";return o.jsxs("div",{className:Pe("flex min-h-0 flex-col",j?"h-full bg-background":"rounded-xl border border-border bg-background shadow-sm"),children:[o.jsx("div",{className:Pe("border-b border-border/70",j?"px-5 py-5":"px-5 py-4"),children:o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(Sr,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("h2",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Create with AI"}),o.jsx(kt,{variant:"secondary",className:"rounded-full px-2 py-0 text-[10px] font-semibold uppercase tracking-wide",children:"Conclusion"})]}),o.jsx("p",{className:"mt-1 text-xs font-medium text-foreground/80",children:"Conclusion Builder"}),o.jsxs("p",{className:"mt-1 max-w-md text-xs leading-relaxed text-muted-foreground",children:["Synthesize your thesis into a focused conclusion for “",e,"”."]})]})]}),a&&o.jsx(me,{type:"button",variant:"ghost",size:"icon",onClick:a,disabled:s,className:"h-8 w-8 shrink-0 rounded-full text-muted-foreground","aria-label":"Close",children:o.jsx(fn,{className:"h-4 w-4"})})]})}),o.jsx("div",{className:Pe("min-h-0 flex-1 overflow-y-auto",j?"px-5 py-5":"p-5"),children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("section",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"1"}),o.jsx(Se,{className:"text-sm font-semibold",children:"Choose source chapters"})]}),o.jsx("p",{className:"mt-1 pl-7 text-xs leading-relaxed text-muted-foreground",children:"Select the chapters Academly should synthesize into the final conclusion."})]}),c.length===0?o.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 px-4 py-5 text-center",children:[o.jsx(nr,{className:"mx-auto h-5 w-5 text-muted-foreground"}),o.jsx("p",{className:"mt-2 text-sm font-medium text-foreground",children:"No other chapters available"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Add content to other thesis chapters before generating a conclusion."})]}):o.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-background",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-border/70 bg-muted/20 px-3.5 py-2.5",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-foreground",children:"Available chapters"}),o.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Recommended chapters are preselected automatically."})]}),o.jsxs(kt,{variant:"secondary",className:"rounded-full text-[10px]",children:[d.length," selected"]})]}),o.jsx("div",{className:"max-h-72 overflow-y-auto p-2",children:o.jsx("div",{className:"space-y-1.5",children:c.map(N=>{const C=N.word_count>0,A=d.includes(N.id),E=C&&bce(N);return o.jsxs("label",{htmlFor:`concl-${N.id}`,className:Pe("group flex items-start gap-3 rounded-lg border px-3 py-2.5 transition-colors",A?"border-primary/25 bg-primary/[0.035]":"border-transparent hover:bg-muted/40",C?"cursor-pointer":"cursor-not-allowed opacity-45"),children:[o.jsx(aa,{id:`concl-${N.id}`,checked:A,onCheckedChange:()=>b(N.id),disabled:!C||s,className:"mt-0.5"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:N.title}),o.jsxs("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:[N.word_count," words"]})]}),o.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[E&&o.jsxs(kt,{variant:"secondary",className:"h-5 rounded-full px-2 text-[10px] font-medium",children:[o.jsx(No,{className:"mr-1 h-3 w-3"}),"Recommended"]}),!C&&o.jsx("span",{className:"text-[11px] text-muted-foreground",children:"No content available"})]})]})]},N.id)})})})]})]}),o.jsxs("section",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"2"}),o.jsx(Se,{className:"text-sm font-semibold",children:"Include sections"})]}),o.jsx("p",{className:"mt-1 pl-7 text-xs leading-relaxed text-muted-foreground",children:"Choose which closing elements should be included in the draft."})]}),o.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-background",children:[o.jsxs("label",{htmlFor:"concl-limitations",className:"flex cursor-pointer items-start gap-3 border-b border-border/70 px-3.5 py-3 hover:bg-muted/30",children:[o.jsx(aa,{id:"concl-limitations",checked:g,onCheckedChange:N=>y(!!N),disabled:s,className:"mt-0.5"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-foreground",children:"Limitations"}),o.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:"Address the main limitations of the study and interpretation."})]})]}),o.jsxs("label",{htmlFor:"concl-outlook",className:"flex cursor-pointer items-start gap-3 px-3.5 py-3 hover:bg-muted/30",children:[o.jsx(aa,{id:"concl-outlook",checked:x,onCheckedChange:N=>v(!!N),disabled:s,className:"mt-0.5"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-foreground",children:"Outlook / Future Research"}),o.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:"Close with implications and directions for future research."})]})]})]})]}),o.jsxs("section",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-[10px] font-semibold text-primary",children:"3"}),o.jsx(Se,{className:"text-sm font-semibold",children:"Set conclusion length"})]}),o.jsx("p",{className:"mt-1 pl-7 text-xs leading-relaxed text-muted-foreground",children:"Choose how detailed the final conclusion should be."})]}),o.jsxs("div",{className:"rounded-xl border border-border bg-background p-3.5",children:[o.jsx(Se,{className:"text-xs font-medium text-foreground",children:"Length"}),o.jsxs(pt,{value:p,onValueChange:N=>m(N),disabled:s,children:[o.jsx(ut,{className:"mt-2 h-10 bg-background",children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"small",children:b2.small}),o.jsx(Le,{value:"medium",children:b2.medium}),o.jsx(Le,{value:"big",children:b2.big})]})]})]})]}),o.jsx("div",{className:"rounded-xl border border-border bg-muted/20 px-3.5 py-3",children:o.jsxs("div",{className:"flex items-start gap-2.5",children:[o.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-lg bg-background text-muted-foreground shadow-sm ring-1 ring-border/60",children:o.jsx(nr,{className:"h-3.5 w-3.5"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium text-foreground",children:"Chapter-grounded synthesis"}),o.jsx("p",{className:"mt-0.5 text-[11px] leading-relaxed text-muted-foreground",children:"The conclusion is generated from the chapters you select and follows your thesis writing language."})]})]})})]})}),o.jsx("div",{className:"border-t border-border/70 bg-background px-5 py-4",children:o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-[11px] font-medium text-foreground",children:d.length>0?`${d.length} chapter${d.length===1?"":"s"} selected`:"Select at least one chapter"}),o.jsx("p",{className:"mt-0.5 text-[10px] text-muted-foreground",children:b2[p]})]}),o.jsxs(me,{type:"button",disabled:!w,onClick:()=>i({sourceChapterIds:d,language:f,mode:p,includeLimitations:g,includeOutlook:x}),className:"h-10 min-w-[172px] gap-2 rounded-xl px-4 shadow-sm",children:[s?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(Yc,{className:"h-4 w-4"}),s?"Generating…":"Generate Conclusion"]})]})})]})}const sHt={introduction:"Introduction",theory:"Theory",methodology:"Methodology",results:"Results",discussion:"Discussion",conclusion:"Conclusion",references:"References",custom:"Custom"};function iHt({open:t,onOpenChange:e,thesisId:r,chapterId:n,chapterTitle:s,chapterKind:i,isGenerating:a,onGenerate:l,initialTopic:c,targetSectionId:u,discussionChapters:d,writingLanguage:h}){return S.useEffect(()=>{if(!t)return;const f=p=>{p.key==="Escape"&&e(!1)};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[t,e]),o.jsx("aside",{role:"complementary","aria-label":"Create with AI","aria-hidden":!t,className:Pe("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:o.jsxs("div",{className:"p-6",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"inline-flex items-center justify-center w-7 h-7 rounded-md bg-primary/10 text-primary",children:o.jsx(Sr,{className:"w-4 h-4"})}),o.jsx("h2",{className:"text-base font-semibold text-foreground",children:"Create with AI"}),o.jsx("span",{className:"ml-auto text-[10px] uppercase tracking-wider px-2 py-0.5 rounded-full bg-muted text-muted-foreground",children:sHt[i]}),o.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:o.jsx(fn,{className:"h-4 w-4"})})]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i==="conclusion"?o.jsxs(o.Fragment,{children:["Draft a conclusion for"," ",o.jsx("span",{className:"text-foreground font-medium",children:s})," by synthesizing your existing chapters."]}):i==="discussion"?o.jsxs(o.Fragment,{children:["Draft a discussion for"," ",o.jsx("span",{className:"text-foreground font-medium",children:s})," by synthesizing your existing chapters."]}):i==="methodology"?o.jsxs(o.Fragment,{children:["Draft a methodology for"," ",o.jsx("span",{className:"text-foreground font-medium",children:s})," using your own uploaded sources."]}):o.jsxs(o.Fragment,{children:["Draft a theoretical background for"," ",o.jsx("span",{className:"text-foreground font-medium",children:s})," using your own uploaded sources."]})}),o.jsxs("div",{className:"mt-5",children:[n&&i==="methodology"&&o.jsx(YUt,{variant:"sheet",writingLanguage:h,thesisId:r,chapterId:n,chapterTitle:s,isGenerating:a,onGenerate:l,onCancel:()=>e(!1),initialTopic:c,targetSectionId:u}),n&&i==="discussion"&&o.jsx(ZUt,{variant:"sheet",targetChapterId:n,chapterTitle:s,chapters:d??[],writingLanguage:h,isGenerating:a,onGenerate:l,onCancel:()=>e(!1),initialTopic:c,targetSectionId:u}),n&&i==="conclusion"&&o.jsx(nHt,{variant:"sheet",targetChapterId:n,chapterTitle:s,chapters:d??[],writingLanguage:h,isGenerating:a,onGenerate:l,onCancel:()=>e(!1),initialTopic:c,targetSectionId:u}),n&&i==="theory"&&o.jsx(KUt,{variant:"sheet",writingLanguage:h,thesisId:r,chapterId:n,chapterTitle:s,isGenerating:a,onGenerate:l,onCancel:()=>e(!1),initialTopic:c,targetSectionId:u})]})]})})}Vl.workerSrc=`https://unpkg.com/pdfjs-dist@${qL}/build/pdf.worker.min.mjs`;function aHt({pdfUrl:t,pageNumber:e,quote:r,width:n=720}){const s=S.useRef(null),i=S.useRef(null),[a,l]=S.useState(!0),[c,u]=S.useState(null),[d,h]=S.useState([]),[f,p]=S.useState(null),[m,g]=S.useState(!1);return S.useEffect(()=>{let y=!1;return l(!0),u(null),h([]),g(!1),(async()=>{try{const x=await VL(t).promise;if(y)return;const v=Math.min(Math.max(1,e),x.numPages),b=await x.getPage(v);if(y)return;const w=b.getViewport({scale:1}),j=n/w.width,N=b.getViewport({scale:j}),C=s.current;if(!C)return;const A=C.getContext("2d");if(!A||(C.width=N.width,C.height=N.height,p({w:N.width,h:N.height}),await b.render({canvasContext:A,viewport:N,canvas:C}).promise,y))return;if(r&&r.trim().length>0)try{const E=await TNe(b,N,j,r);y||(h(E),g(E.length>0))}catch(E){console.warn("Quote highlight failed:",E)}l(!1)}catch(x){console.error("PDF page render failed:",x),y||(u("Could not load PDF page."),l(!1))}})(),()=>{y=!0}},[t,e,r,n]),o.jsxs("div",{className:"space-y-2",children:[!a&&r&&!m&&o.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,"."]}),o.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:[o.jsx("canvas",{ref:s,className:"block"}),d.map((y,x)=>o.jsx("span",{className:"pdf-evidence-highlight",style:{left:y.left,top:y.top,width:y.width,height:y.height}},x)),a&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-white/60",children:o.jsx(Xe,{className:"w-5 h-5 animate-spin text-muted-foreground"})}),c&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-destructive",children:c})]})]})}Vl.workerSrc=`https://unpkg.com/pdfjs-dist@${qL}/build/pdf.worker.min.mjs`;function oHt({pdfUrl:t,quote:e,pageOffset:r,writingLanguage:n}){const[s,i]=S.useState("scanning"),[a,l]=S.useState([]),[c,u]=S.useState(null);if(S.useEffect(()=>{let p=!1,m=null;return i("scanning"),l([]),u(null),(async()=>{try{if(m=await VL(t).promise,p)return;const g=await EAt(m,e);p||(l(g.matches),u(m))}catch(g){console.warn("Partial source scan failed:",g)}finally{p||i("done")}})(),()=>{p=!0,m==null||m.destroy().catch(()=>{})}},[t,e]),s==="scanning")return o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-2",children:[o.jsx(Xe,{className:"w-3.5 h-3.5 animate-spin"})," Searching the original PDF…"]});if(!a.length)return null;const d=a[0].page,h=a.filter(p=>p.page===d).map(p=>({start:p.start,end:p.end})),f=Array.from(new Set(a.map(p=>p.page)));return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-3 text-xs",children:[o.jsx("div",{className:"font-semibold text-foreground mb-0.5",children:"Partial source match"}),o.jsx("div",{className:"text-muted-foreground",children:"Parts of this passage were found in the original PDF. The complete quote could not be verified."}),o.jsxs("div",{className:"text-muted-foreground mt-1",children:[a.length," matching passage",a.length===1?"":"s"," found · found on PDF p."," ",f.join(", ")]})]}),c&&o.jsx(PNe,{pdf:c,pageNumber:d,width:720,active:!0,partialRanges:h})]})}const ES=t=>t.verification_status==="needs_review",y6=3;function Xf(t){return t.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim()}function x2e(t,e){return t==null?null:t+(e??0)}function v6(t,e,r){var i;const n=x2e(t,e),s=((i=YL[r])==null?void 0:i.pagePrefix)??"p.";return n==null?"":`${s} ${n}`}function Qf(t,e,r){var c;if(!t)return null;const n=t.authors_display||t.author_surname,s=t.published_year;if(!n||!s)return null;const i=x2e(e,t.page_offset),a=((c=YL[r])==null?void 0:c.pagePrefix)??"p.",l=i!=null?`, ${a} ${i}`:"";return`(${n}, ${s}${l})`}function lHt(t,e){var h,f,p,m,g,y,x,v,b,w,j,N;let r=0;const n=Xf(e.surname??""),s=Xf(e.authorPhrase??e.surname??""),i=s.length>20||/\s/.test(s),a=Xf(((h=t.documents)==null?void 0:h.title)??""),l=Xf(((f=t.documents)==null?void 0:f.original_filename)??""),c=Xf(((p=t.documents)==null?void 0:p.author_surname)??"");Xf(((m=t.documents)==null?void 0:m.authors_display)??"");const u=Xf(((g=t.documents)==null?void 0:g.citation_apa)??""),d=[t.citation_text??"",((y=t.documents)==null?void 0:y.title)??"",((x=t.documents)==null?void 0:x.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(C=>Xf(C)).join(" ");return e.raw&&t.citation_text&&t.citation_text.trim()===e.raw.trim()&&(r+=10),e.year!=null&&((j=t.documents)==null?void 0:j.published_year)===e.year&&(r+=3),n.length>=y6&&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:l&&l.includes(s.slice(0,20))&&(r+=3)),!i&&n.length>=y6&&new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(d)&&(r+=4),n.length>0&&n.length<y6&&(a===n||l.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&&((N=t.documents)==null?void 0:N.published_year)!=null&&Math.abs(t.documents.published_year-e.year)>1&&(r-=1),r}const wce="evidence-panel-width",cHt=520,jce=760;function Sce(t){const e=typeof window<"u"?window.innerWidth*.9:1600;return Math.max(cHt,Math.min(e,t))}function uHt({writingLanguage:t}){var V,B,z,F,G,Q,ie,se,q,L,Z;const{current:e,close:r}=FK(),[n,s]=S.useState([]),[i,a]=S.useState(!1),[l,c]=S.useState(null),[u,d]=S.useState("quotes"),[h,f]=S.useState(null),[p,m]=S.useState(!1),[g,y]=S.useState(null),[x,v]=S.useState(null),[b,w]=S.useState(!1),j=S.useRef(null),[N,C]=S.useState(()=>{if(typeof window>"u")return jce;const J=Number(localStorage.getItem(wce));return Sce(Number.isFinite(J)&&J>0?J:jce)}),A=S.useRef(!1),E=J=>{J.preventDefault(),A.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const W=he=>{if(!A.current)return;const P=Sce(window.innerWidth-he.clientX);C(P)},X=()=>{A.current=!1,document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(wce,String(O.current))}catch{}window.removeEventListener("mousemove",W),window.removeEventListener("mouseup",X)};window.addEventListener("mousemove",W),window.addEventListener("mouseup",X)},O=S.useRef(N);S.useEffect(()=>{O.current=N},[N]);const $=S.useCallback(async J=>{a(!0);const{data:W,error:X}=await pe.from("section_evidence").select("id, section_id, document_id, page_number, quote_text, citation_text, created_at, verification_status, verification_reason, documents(id, title, original_filename, storage_path, bib_meta, author_surname, authors_display, published_year, citation_apa, page_offset)").eq("section_id",J).order("created_at",{ascending:!0});X?(console.error("Load section_evidence failed:",X),s([])):s(W??[]),a(!1)},[]);S.useEffect(()=>{if(!e){s([]),c(null),f(null),d("quotes");return}$(e.sectionId)},[e==null?void 0:e.sectionId,$]),S.useEffect(()=>{const J=W=>{e!=null&&e.sectionId&&$(e.sectionId)};return window.addEventListener("ghost-evidence-accepted",J),()=>window.removeEventListener("ghost-evidence-accepted",J)},[e==null?void 0:e.sectionId,$]);const T=S.useMemo(()=>e?n.map((J,W)=>({row:J,score:lHt(J,e),idx:W})).sort((J,W)=>W.score-J.score||J.idx-W.idx).map(({row:J,score:W})=>({row:J,score:W})):[],[n,e]);S.useEffect(()=>{if(!e||T.length===0){c(null);return}const J=!!e.citationKey,W=T[0],X=T[1],he=!X||W.score-X.score>=3||T.length===1;J&&W.score>0&&he?c(W.row.id):c(null)},[e==null?void 0:e.citationKey,e==null?void 0:e.raw,T]);const M=((V=T.find(J=>J.row.id===l))==null?void 0:V.row)??null,k=S.useMemo(()=>{const J=new Map;for(const W of n){const X=W.document_id;J.has(X)||J.set(X,[]),J.get(X).push(W)}return Array.from(J.entries()).map(([W,X])=>({documentId:W,rows:X.sort((he,P)=>(he.page_number??0)-(P.page_number??0)),doc:X[0].documents}))},[n]);S.useEffect(()=>{var W;if(!((W=M==null?void 0:M.documents)!=null&&W.storage_path)){f(null);return}let J=!1;return m(!0),f(null),(async()=>{const X=await rM(M.documents.storage_path);J||(f(X),m(!1))})(),()=>{J=!0}},[M==null?void 0:M.id,(B=M==null?void 0:M.documents)==null?void 0:B.storage_path]),S.useEffect(()=>{if(k.length===0){y(null);return}(!g||!k.some(J=>J.documentId===g))&&y(k[0].documentId)},[k,g]);const D=S.useMemo(()=>k.find(J=>J.documentId===g)??null,[k,g]);S.useEffect(()=>{var X;const J=(X=D==null?void 0:D.doc)==null?void 0:X.storage_path;if(!J){v(null);return}let W=!1;return w(!0),v(null),(async()=>{const he=await rM(J);W||(v(he),w(!1))})(),()=>{W=!0}},[(z=D==null?void 0:D.doc)==null?void 0:z.storage_path]);const K=((F=M==null?void 0:M.documents)==null?void 0:F.title)||((G=M==null?void 0:M.documents)==null?void 0:G.original_filename)||"Untitled source",H=n.length,ee=k.length;return o.jsx(aA,{open:!!e,onOpenChange:J=>!J&&r(),children:o.jsxs(Rj,{side:"right",className:"w-full p-0 flex flex-col sm:!max-w-none",style:{width:typeof window<"u"&&window.innerWidth>=640?N:void 0},children:[o.jsx("div",{role:"separator","aria-orientation":"vertical",onMouseDown:E,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"}),o.jsxs($L,{className:"px-5 py-4 border-b bg-background/95 backdrop-blur space-y-3",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"mt-0.5 flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(jr,{className:"w-4 h-4"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx(oA,{className:"text-base leading-tight",children:"Citation evidence"}),o.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:"Verify source passages and open the cited PDFs."}),e&&(e.raw||e.surname)&&o.jsx("div",{className:"mt-2 rounded-lg border border-border/70 bg-muted/25 px-3 py-2 text-xs text-muted-foreground truncate",children:e.raw||`${e.surname} (${e.year??"?"}${e.page?`, p. ${e.page}`:""})`})]})]}),o.jsxs("div",{className:"inline-flex w-fit items-center rounded-lg border border-border/70 bg-muted/30 p-1",children:[o.jsxs("button",{onClick:()=>d("quotes"),className:`text-xs px-3 py-1.5 rounded-md inline-flex items-center gap-1.5 transition ${u==="quotes"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[o.jsx(ua,{className:"w-3 h-3"})," Quotes (",H,")"]}),o.jsxs("button",{onClick:()=>d("pdfs"),className:`text-xs px-3 py-1.5 rounded-md inline-flex items-center gap-1.5 transition ${u==="pdfs"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[o.jsx(nr,{className:"w-3 h-3"})," PDFs (",ee,")"]})]})]}),o.jsx(Am,{className:"flex-1 bg-background",children:o.jsxs("div",{className:"p-5 space-y-5",children:[i&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Xe,{className:"w-4 h-4 animate-spin"})," Loading evidence…"]}),!i&&n.length===0&&o.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."}),!i&&u==="quotes"&&n.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"space-y-2.5",children:[o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Evidence"}),o.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[n.length," stored passage",n.length===1?"":"s"]})]}),(()=>{const J=n.filter(ES).length,W=n.length-J;return o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[o.jsxs("span",{className:"rounded-full border border-emerald-200 bg-emerald-50 px-2 py-0.5 font-medium text-emerald-700 dark:border-emerald-900/60 dark:bg-emerald-950/30 dark:text-emerald-300",children:[W," verified"]}),J>0&&o.jsxs("span",{className:"rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 font-medium text-amber-700 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-300",children:[J," review"]})]})})()]}),T.map(({row:J,score:W})=>{var Y,R,I;const X=J.id===l,he=ES(J),P=he?null:v6(J.page_number,(Y=J.documents)==null?void 0:Y.page_offset,t),oe=((R=J.documents)==null?void 0:R.title)||((I=J.documents)==null?void 0:I.original_filename)||"Untitled source";return o.jsxs("button",{onClick:()=>c(J.id),"aria-selected":X,className:`w-full text-left rounded-xl border p-3.5 transition min-w-0 overflow-hidden ${X?"border-primary/40 bg-primary/[0.04] shadow-sm ring-1 ring-primary/10":"border-border/70 bg-card hover:border-border hover:bg-muted/20"}`,children:[o.jsxs("div",{className:"flex items-start justify-between gap-3 min-w-0",children:[o.jsx("div",{className:"text-xs font-medium break-words min-w-0 flex-1",children:oe}),o.jsxs("div",{className:"text-[10px] text-muted-foreground shrink-0 flex items-center gap-2",children:[he?o.jsx("span",{className:"px-1.5 py-0.5 rounded border border-amber-200 bg-amber-50 text-amber-800 dark:bg-amber-950/30 dark:border-amber-900/60 dark:text-amber-300 whitespace-nowrap",children:"Needs review"}):Qf(J.documents,J.page_number,t)&&o.jsx("span",{className:"break-words max-w-[180px]",children:Qf(J.documents,J.page_number,t)}),P&&o.jsx("span",{className:"px-1.5 py-0.5 rounded bg-muted/60 whitespace-nowrap",children:P})]})]}),o.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2 break-words",children:["“",J.quote_text,"”"]}),W>0&&(e==null?void 0:e.citationKey)&&o.jsxs("div",{className:"text-[9px] uppercase tracking-wider text-primary/70 mt-1",children:["match score ",W]})]},J.id)})]}),M?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"pt-1",children:o.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Selected evidence"})}),o.jsxs("div",{className:"rounded-xl border border-border/70 bg-card p-4 min-w-0 overflow-hidden",children:[o.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground mb-1",children:"Source"}),o.jsx("div",{className:"text-sm font-medium leading-snug break-words",children:K}),o.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:[!ES(M)&&Qf(M.documents,M.page_number,t)&&o.jsx("span",{className:"break-words min-w-0",children:Qf(M.documents,M.page_number,t)}),!ES(M)&&M.page_number!=null&&o.jsx("span",{className:"shrink-0",children:v6(M.page_number,(Q=M.documents)==null?void 0:Q.page_offset,t)}),h&&o.jsxs("a",{href:h,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-primary hover:underline ml-auto shrink-0",children:["Open full PDF ",o.jsx(of,{className:"w-3 h-3"})]})]})]}),ES(M)?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rounded-xl border border-amber-200 bg-amber-50 dark:bg-amber-950/30 dark:border-amber-900/60 p-3 text-xs text-amber-800 dark:text-amber-300",children:[o.jsx("div",{className:"font-semibold mb-0.5",children:"Needs review"}),"Academly could not verify this passage against the source text. Check the original source before using this citation."]}),(M.citation_text||Qf(M.documents,null,t))&&o.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/25 p-3.5",children:[o.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-0.5",children:"Generated citation"}),o.jsx("code",{className:"text-xs font-mono text-foreground block break-all",children:M.citation_text||Qf(M.documents,null,t)})]}),o.jsxs("div",{className:"rounded-xl border border-border/70 bg-card p-4 min-w-0 overflow-hidden",children:[o.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground mb-1",children:"Source passage to review"}),o.jsxs("blockquote",{className:"text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words",children:["“",M.quote_text,"”"]})]}),h&&M.quote_text&&o.jsx(oHt,{pdfUrl:h,quote:M.quote_text,pageOffset:(ie=M.documents)==null?void 0:ie.page_offset,writingLanguage:t},M.id)]}):o.jsxs(o.Fragment,{children:[(()=>{const J=Qf(M.documents,M.page_number,t);if(!J)return null;const W=!!M.citation_text&&M.citation_text.trim()!==J;return o.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/25 p-3.5 flex items-center gap-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-0.5",children:"Canonical in-text citation"}),o.jsx("code",{className:"text-xs font-mono text-foreground block break-all",children:J}),W&&o.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."})]}),o.jsx(me,{size:"sm",variant:"ghost",className:"shrink-0 h-7 px-2",onClick:()=>{navigator.clipboard.writeText(J).then(()=>{It({title:"Citation copied"})})},children:o.jsx(ws,{className:"w-3.5 h-3.5"})})]})})(),o.jsxs("div",{className:"rounded-xl 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:[o.jsx("div",{className:"text-xs uppercase tracking-wider text-yellow-700 dark:text-yellow-400 mb-1",children:"Original quote"}),o.jsxs("blockquote",{className:"text-sm leading-relaxed text-foreground whitespace-pre-wrap break-words",children:["“",M.quote_text,"”"]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-2",children:"Cited page"}),p&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8",children:[o.jsx(Xe,{className:"w-4 h-4 animate-spin"})," Loading PDF…"]}),!p&&!h&&o.jsxs("div",{className:"text-sm text-muted-foreground border border-dashed border-border/70 rounded-xl p-4",children:["PDF not available for this source. Copy the citation:"," ",o.jsx("code",{className:"text-xs",children:Qf(M.documents,M.page_number,t)||(e==null?void 0:e.raw)})]}),h&&M.page_number!=null&&o.jsx(aHt,{pdfUrl:h,pageNumber:M.page_number,quote:M.quote_text})]})]})]}):o.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border/70 rounded-xl p-4",children:"Select an evidence row above to preview the source PDF and original quote."})]}),!i&&u==="pdfs"&&n.length>0&&o.jsxs("div",{className:"space-y-4",children:[k.length>1&&o.jsx("div",{className:"flex flex-wrap gap-1.5",children:k.map(J=>{var he,P;const W=((he=J.doc)==null?void 0:he.title)||((P=J.doc)==null?void 0:P.original_filename)||"Untitled",X=J.documentId===g;return o.jsx("button",{onClick:()=>y(J.documentId),className:`text-xs px-2.5 py-1 rounded-md border transition truncate max-w-[260px] ${X?"border-primary/40 bg-primary/[0.04] shadow-sm text-foreground":"border-border bg-card hover:bg-muted"}`,title:W,children:W},J.documentId)})}),D?o.jsxs("div",{className:"rounded-xl border border-border/70 bg-card p-3.5 space-y-3 min-w-0 overflow-hidden",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3 min-w-0",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm font-medium break-words line-clamp-2",children:((se=D.doc)==null?void 0:se.title)||((q=D.doc)==null?void 0:q.original_filename)||"Untitled source"}),o.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[D.rows.length," quote",D.rows.length===1?"":"s"," ·"," ",new Set(D.rows.map(J=>J.page_number)).size," cited page",new Set(D.rows.map(J=>J.page_number)).size===1?"":"s"]})]}),x&&o.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 ",o.jsx(of,{className:"w-3 h-3"})]})]}),o.jsx("div",{className:"flex flex-wrap gap-1.5",children:Array.from(new Set(D.rows.map(J=>J.page_number).filter(J=>J!=null))).sort((J,W)=>J-W).map(J=>{var W;return o.jsx("button",{onClick:()=>{var X;return(X=j.current)==null?void 0:X.scrollToPage(J)},className:"text-xs px-2 py-0.5 rounded border border-border bg-muted/30 hover:bg-muted transition",children:v6(J,(W=D.doc)==null?void 0:W.page_offset,t)},J)})}),b&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6",children:[o.jsx(Xe,{className:"w-4 h-4 animate-spin"})," Loading PDF…"]}),!b&&!x&&o.jsx("div",{className:"text-sm text-muted-foreground border border-dashed border-border/70 rounded-xl p-4",children:"PDF not available for this source."}),!b&&x&&o.jsx(INe,{ref:j,pdfUrl:x,highlights:D.rows.filter(J=>J.page_number!=null).map(J=>({page:J.page_number,quote:J.quote_text})),initialPage:((L=D.rows[0])==null?void 0:L.page_number)??1,pageOffset:((Z=D.doc)==null?void 0:Z.page_offset)??null,writingLanguage:t})]}):o.jsx("div",{className:"text-xs text-muted-foreground border border-dashed border-border/70 rounded-xl p-4",children:"No source selected."})]})]})})]})})}function _ce({sectionId:t}){const{open:e}=FK(),[r,n]=S.useState(null);return S.useEffect(()=>{let s=!1;const i=async()=>{const{count:l}=await pe.from("section_evidence").select("id",{count:"exact",head:!0}).eq("section_id",t);s||n(typeof l=="number"?l:0)};i();const a=l=>{const c=l.detail;(c==null?void 0:c.section_id)===t&&i()};return window.addEventListener("ghost-evidence-accepted",a),()=>{s=!0,window.removeEventListener("ghost-evidence-accepted",a)}},[t]),!r||r<=0?null:o.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:[o.jsx(ua,{className:"w-3 h-3"}),"Evidence (",r,")"]})}const Nce=(t,e)=>(t.order_index??0)-(e.order_index??0);function dHt(t,e){const r=[...t??[]],n=new Set(r.map(a=>a.id)),s=r.filter(a=>!a.parent_section_id||!n.has(a.parent_section_id)).sort(Nce),i=new Map;return r.forEach(a=>{const l=a.parent_section_id;if(!l||!n.has(l))return;const c=i.get(l)??[];c.push(a),i.set(l,c)}),s.map((a,l)=>{const c=`${e}.${l+1}`,u=(i.get(a.id)??[]).sort(Nce);return{section:a,number:c,depth:0,children:u.map((d,h)=>({section:d,number:`${c}.${h+1}`,depth:1,children:[]}))}})}function AS(t,e){const r=[];return dHt(t,e).forEach(n=>{r.push(n),n.children.forEach(s=>r.push(s))}),r}function TS(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function PS(t){let e=t;return e=e.replace(/\*\*(?=\S)([\s\S]*?\S)\*\*/g,"<strong>$1</strong>"),e=e.replace(/__(?=\S)([\s\S]*?\S)__/g,"<strong>$1</strong>"),e=e.replace(/(^|[^\w*])\*(?=\S)([^*\n]*?\S)\*(?!\*)/g,"$1<em>$2</em>"),e=e.replace(/(^|[^\w_])_(?=\S)([^_\n]*?\S)_(?!_)/g,"$1<em>$2</em>"),e}function IS(t){let e=t;return e=e.replace(/\*\*(?=\S)([\s\S]*?\S)\*\*/g,"$1"),e=e.replace(/__(?=\S)([\s\S]*?\S)__/g,"$1"),e=e.replace(/(^|[^\w*])\*(?=\S)([^*\n]*?\S)\*(?!\*)/g,"$1$2"),e=e.replace(/(^|[^\w_])_(?=\S)([^_\n]*?\S)_(?!_)/g,"$1$2"),e}const kce=/^\s{0,3}(#{1,6})\s+(.*)$/,w2=/^\s{0,3}[-*+]\s+(.*)$/,j2=/^\s{0,3}\d+[.)]\s+(.*)$/,S2=/^\s{0,3}>\s?(.*)$/,Cce=/^\s{0,3}(?:(?:-\s*){3,}|(?:\*\s*){3,}|(?:_\s*){3,})$/;function y2e(t){const e=(t??"").replace(/\r\n?/g,`
`).split(`
`),r=[];let n=0;for(;n<e.length;){const s=e[n];if(!s.trim()){n+=1;continue}if(Cce.test(s)){r.push({type:"hr"}),n+=1;continue}const i=kce.exec(s);if(i){const l=i[1].length,c=l>3?3:l;r.push({type:"heading",level:c,text:i[2].trim()}),n+=1;continue}if(w2.test(s)){const l=[];for(;n<e.length&&w2.test(e[n]);)l.push(w2.exec(e[n])[1].trim()),n+=1;r.push({type:"ul",items:l});continue}if(j2.test(s)){const l=[];for(;n<e.length&&j2.test(e[n]);)l.push(j2.exec(e[n])[1].trim()),n+=1;r.push({type:"ol",items:l});continue}if(S2.test(s)){const l=[];for(;n<e.length&&S2.test(e[n]);)l.push(S2.exec(e[n])[1]),n+=1;r.push({type:"blockquote",lines:l});continue}const a=[];for(;n<e.length;){const l=e[n];if(!l.trim()||Cce.test(l)||kce.test(l)||w2.test(l)||j2.test(l)||S2.test(l))break;a.push(l.trim()),n+=1}a.length&&r.push({type:"paragraph",lines:a})}return r}function hHt(t,e=!1){switch(t.type){case"hr":return"<hr>";case"heading":{const r=PS(TS(t.text));return e?`<p><strong>${r}</strong></p>`:`<h${t.level}>${r}</h${t.level}>`}case"ul":return`<ul>${t.items.map(r=>`<li><p>${PS(TS(r))}</p></li>`).join("")}</ul>`;case"ol":return`<ol>${t.items.map(r=>`<li><p>${PS(TS(r))}</p></li>`).join("")}</ol>`;case"blockquote":return`<blockquote>${t.lines.join(`
`).split(/\n{2,}/).map(n=>`<p>${PS(TS(n)).replace(/\n/g,"<br>")}</p>`).join("")||"<p></p>"}</blockquote>`;case"paragraph":return`<p>${PS(TS(t.lines.join(`
`))).replace(/\n/g,"<br>")}</p>`;default:return""}}function fHt(t){switch(t.type){case"hr":return"";case"heading":return IS(t.text);case"ul":return t.items.map(e=>`• ${IS(e)}`).join(`
`);case"ol":return t.items.map((e,r)=>`${r+1}. ${IS(e)}`).join(`
`);case"blockquote":return IS(t.lines.join(`
`));case"paragraph":return IS(t.lines.join(`
`));default:return""}}function Ece(t){return y2e(t).map(e=>hHt(e,!0)).join("")}function Ace(t){return y2e(t).map(fHt).filter(e=>e.length>0).join(`

`).trim()}const v2e=S.createContext(null);function pHt({children:t}){const[e,r]=S.useState(!1),n=S.useCallback(()=>r(!0),[]),s=S.useCallback(()=>r(!1),[]),i=S.useMemo(()=>({isOpen:e,openSupervisor:n,closeSupervisor:s}),[e,n,s]);return o.jsx(v2e.Provider,{value:i,children:t})}function b2e(){const t=S.useContext(v2e);if(!t)throw new Error("useSupervisor must be used inside <SupervisorProvider>");return t}function mHt(){return o.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:"text-foreground",children:[o.jsx("circle",{cx:"4",cy:"12",r:"2",fill:"currentColor",children:o.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"})}),o.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor",children:o.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"})}),o.jsx("circle",{cx:"20",cy:"12",r:"2",fill:"currentColor",children:o.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 Tce({variant:t="received",layout:e="default",className:r,children:n}){return o.jsx("div",{className:Pe("flex gap-2 max-w-[80%]",t==="sent"?"ml-auto flex-row-reverse":"",e==="ai"?"items-start":"items-end",r),children:n})}function Pce({variant:t="received",isLoading:e,className:r,children:n}){return o.jsx("div",{className:Pe("rounded-xl px-3 py-2 text-sm",t==="sent"?"bg-primary text-primary-foreground":"bg-muted text-foreground",r),children:e?o.jsx("div",{className:"flex items-center space-x-2",children:o.jsx(mHt,{})}):n})}function gHt(t={}){const{offset:e=20,smooth:r=!1,content:n}=t,s=S.useRef(null),i=S.useRef(0),a=S.useRef(!1),[l,c]=S.useState({isAtBottom:!0,autoScrollEnabled:!0}),u=S.useCallback(p=>{const{scrollTop:m,scrollHeight:g,clientHeight:y}=p;return Math.abs(g-m-y)<=e},[e]),d=S.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=S.useCallback(()=>{if(!s.current)return;const p=u(s.current);c(m=>({isAtBottom:p,autoScrollEnabled:p?!0:m.autoScrollEnabled}))},[u]);S.useEffect(()=>{const p=s.current;if(p)return p.addEventListener("scroll",h,{passive:!0}),()=>p.removeEventListener("scroll",h)},[h]),S.useEffect(()=>{const p=s.current;if(!p)return;const m=p.scrollHeight;m!==i.current&&(l.autoScrollEnabled&&requestAnimationFrame(()=>{d(i.current===0)}),i.current=m)},[n,l.autoScrollEnabled,d]),S.useEffect(()=>{const p=s.current;if(!p)return;const m=new ResizeObserver(()=>{l.autoScrollEnabled&&d(!0)});return m.observe(p),()=>m.disconnect()},[l.autoScrollEnabled,d]);const f=S.useCallback(()=>{(s.current?u(s.current):!1)||(a.current=!0,c(m=>({...m,autoScrollEnabled:!1})))},[u]);return{scrollRef:s,isAtBottom:l.isAtBottom,autoScrollEnabled:l.autoScrollEnabled,scrollToBottom:()=>d(!1),disableAutoScroll:f}}const w2e=S.forwardRef(({className:t,children:e,smooth:r=!1,...n},s)=>{const{scrollRef:i,isAtBottom:a,autoScrollEnabled:l,scrollToBottom:c,disableAutoScroll:u}=gHt({smooth:r,content:e});return o.jsxs("div",{className:Pe("relative w-full h-full",t),...n,children:[o.jsx("div",{className:"h-full overflow-y-auto p-4",ref:i,onWheel:u,onTouchMove:u,children:o.jsx("div",{className:"flex flex-col gap-4",children:e})}),!a&&o.jsx(me,{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:o.jsx(MOe,{className:"h-4 w-4"})})]})});w2e.displayName="ChatMessageList";const j2e=S.forwardRef(({className:t,...e},r)=>o.jsx(lr,{autoComplete:"off",ref:r,name:"message",className:Pe("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}));j2e.displayName="ChatInput";function wx({isLoading:t=!1,size:e=40}){return o.jsxs("div",{className:"relative flex-shrink-0",style:{width:e,height:e},children:[t&&o.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-purple-500 animate-spin",style:{width:e,height:e}}),o.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 _2=t=>[...t].sort((e,r)=>{const n=new Date(e.created_at).getTime()-new Date(r.created_at).getTime();return n!==0?n:e.order_index-r.order_index});function xHt({thesisId:t,chapterId:e,sectionId:r}){const{user:n}=Ht(),[s,i]=S.useState(null),[a,l]=S.useState([]),[c,u]=S.useState(!0),[d,h]=S.useState(!1),[f,p]=S.useState(null),[m,g]=S.useState(()=>new Set),y=S.useRef(e??null),x=S.useRef(r??null);y.current=e??null,x.current=r??null;const v=S.useRef(null),b=S.useRef(!1),w=S.useCallback((E,O=!1)=>{l($=>{const T=$.findIndex(k=>k.id===E.id);if(T===-1)return _2([...$,E]);const M=[...$];return M[T]={...M[T],...E},_2(M)}),O&&g($=>{if($.has(E.id))return $;const T=new Set($);return T.add(E.id),T})},[]),j=S.useCallback(async E=>{const{data:O,error:$}=await pe.from("supervisor_messages").select("*").eq("chat_id",E).order("created_at",{ascending:!0}).order("order_index",{ascending:!0});if($)throw $;return _2(O??[])},[]),N=S.useCallback(async()=>{const E=v.current;if(E)try{const O=await j(E);l($=>{const T=new Map(O.map(M=>[M.id,M]));for(const M of $)T.has(M.id)||T.set(M.id,M);return _2([...T.values()])})}catch(O){console.error("[useSupervisorChat] refresh failed",O)}},[j]),C=S.useCallback(E=>{v.current=E,i(E)},[]);S.useEffect(()=>{if(!t||!n)return;let E=!1;return(async()=>{var k;u(!0),p(null),l([]),C(null),b.current=!1;const{data:$,error:T}=await pe.from("supervisor_chats").select("id").eq("thesis_id",t).order("updated_at",{ascending:!1}).limit(1);if(E)return;if(T){p(T.message),u(!1);return}const M=((k=$==null?void 0:$[0])==null?void 0:k.id)??null;if(C(M),M)try{const D=await j(M);if(E)return;l(D)}catch(D){E||p((D==null?void 0:D.message)??"Load failed")}b.current=!0,E||u(!1)})(),()=>{E=!0}},[t,n,j,C]),S.useEffect(()=>{if(!s)return;const E=`chat_id=eq.${s}`,O=pe.channel(`supervisor-messages-${s}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"supervisor_messages",filter:E},$=>w($.new,!0)).on("postgres_changes",{event:"UPDATE",schema:"public",table:"supervisor_messages",filter:E},$=>w($.new)).on("postgres_changes",{event:"DELETE",schema:"public",table:"supervisor_messages",filter:E},$=>{const T=$.old.id;T&&l(M=>M.filter(k=>k.id!==T))}).subscribe($=>{$==="SUBSCRIBED"&&N()});return()=>{pe.removeChannel(O)}},[s,w,N]);const A=S.useCallback(async(E,O)=>{const $=E.trim();if(!$||!t||!n||d)return;const T=O&&"base64"in O?{attachment:O}:O??{};h(!0),p(null);try{let M=v.current;if(!M){const{data:B,error:z}=await pe.from("supervisor_chats").insert({user_id:n.id,thesis_id:t,title:"Thesis Supervisor"}).select("id").single();if(z)throw z;M=B.id,C(M)}const k=a.reduce((B,z)=>Math.max(B,z.order_index),0),{data:D,error:K}=await pe.from("supervisor_messages").insert({chat_id:M,role:"user",message_type:"message",content:$,status:"done",order_index:k+1}).select().single();if(K)throw K;w(D);const{data:H,error:ee}=await pe.functions.invoke("supervisor_chat",{body:{thesis_id:t,chat_id:M,user_message_id:D.id,message:$,chapter_id:y.current,section_id:x.current,attachment:T.attachment??null,draft_message_id:T.draftMessageId??null}});if(ee)throw ee;const V=H==null?void 0:H.chat_id;V&&V!==v.current&&C(V),await pe.from("supervisor_chats").update({chapter_id:y.current,section_id:x.current,updated_at:new Date().toISOString()}).eq("id",v.current??M)}catch(M){p((M==null?void 0:M.message)||"Unbekannter Fehler")}finally{h(!1),await N()}},[a,t,n,d,w,N,C]);return{chatId:s,messages:a,isLoading:c,isSending:d,error:f,sendMessage:A,refreshMessages:N,liveMessageIds:m}}function yHt({steps:t,hideWhenDone:e}){if(t.length===0)return null;const r=t.find(u=>u.status==="running"),n=t.find(u=>u.status==="waiting"),s=t.find(u=>u.status==="error"),i=t.filter(u=>u.status==="done"),a=r??n??s??i[i.length-1]??t[t.length-1],l=!r&&!n&&!s;if(l&&e)return null;const c=l?"Fertig":a.content||a.tool_name||"Arbeitet…";return o.jsxs("div",{className:"mt-2 inline-flex items-center gap-2 rounded-full border border-border bg-card px-3 py-1.5 text-xs animate-fade-in",children:[o.jsx(vHt,{status:l?"done":a.status}),o.jsx("span",{className:Pe("leading-none",a.status==="error"?"text-destructive":"text-muted-foreground"),children:c})]})}function vHt({status:t}){switch(t){case"running":return o.jsx(Xe,{className:"w-3.5 h-3.5 text-primary animate-spin flex-shrink-0","aria-hidden":!0});case"done":return o.jsx(kr,{className:"w-3.5 h-3.5 text-emerald-500 flex-shrink-0",strokeWidth:3,"aria-hidden":!0});case"waiting":return o.jsx(af,{className:"w-3.5 h-3.5 text-amber-500 flex-shrink-0","aria-hidden":!0});case"error":return o.jsx(fn,{className:"w-3.5 h-3.5 text-destructive flex-shrink-0","aria-hidden":!0});default:return o.jsx(Xe,{className:"w-3.5 h-3.5 text-muted-foreground animate-spin flex-shrink-0","aria-hidden":!0})}}const bHt=t=>(t.trim().match(/\S+/g)||[]).length;function wHt({message:t,sectionOptions:e,onSaveAsNew:r,onReplace:n,onContinueInChat:s,isEditingInChat:i}){const a=t.tool_payload??{},l=a.content??"",c=l?bHt(l):0,u=Array.isArray(a.evidence)?a.evidence.length:0,d=l.length>420?`${l.slice(0,420)}…`:l,h=a.title||"Section draft",[f,p]=S.useState(null),[m,g]=S.useState(null),[y,x]=S.useState(!1),[v,b]=S.useState(a.target_section_id??""),w=S.useMemo(()=>e??[],[e]),j=async()=>{p("save");try{await r(a),g("new")}finally{p(null)}},N=async()=>{if(v){p("replace");try{await n(a,v),g("replaced"),x(!1)}finally{p(null)}}};return o.jsxs("div",{className:"mt-2 rounded-lg border border-border bg-card px-4 py-3 space-y-2.5",children:[o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(jr,{className:"w-4 h-4 text-primary mt-0.5 flex-shrink-0","aria-hidden":!0}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold text-foreground leading-snug",children:h}),o.jsxs("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:[c," Wörter · ",u," ",u===1?"Beleg":"Belege"]})]})]}),d&&o.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground whitespace-pre-wrap border-l-2 border-border pl-3",children:d}),m?o.jsxs("p",{className:"inline-flex items-center gap-1.5 text-[11px] text-emerald-600 dark:text-emerald-400",children:[o.jsx(kr,{className:"w-3.5 h-3.5",strokeWidth:3,"aria-hidden":!0}),m==="new"?"Als Section gespeichert":"Bestehende Section ersetzt"]}):o.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[o.jsxs(me,{size:"sm",variant:"outline",className:"gap-1.5 text-xs",disabled:f!==null,onClick:j,children:[f==="save"?o.jsx(Xe,{className:"w-3.5 h-3.5 animate-spin","aria-hidden":!0}):o.jsx(A_,{className:"w-3.5 h-3.5","aria-hidden":!0}),"Als neue Section speichern"]}),o.jsxs(me,{size:"sm",variant:"outline",className:"gap-1.5 text-xs",disabled:f!==null||w.length===0,onClick:()=>x(!0),children:[o.jsx(_Me,{className:"w-3.5 h-3.5","aria-hidden":!0}),"Bestehende Section ersetzen"]}),o.jsxs(me,{size:"sm",variant:"ghost",className:"gap-1.5 text-xs text-muted-foreground",onClick:()=>s(t,h),children:[o.jsx(pMe,{className:"w-3.5 h-3.5","aria-hidden":!0}),i?"Wird bearbeitet":"Im Chat weiter bearbeiten"]})]}),o.jsx(Mi,{open:y,onOpenChange:x,children:o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Bestehende Section ersetzen?"}),o.jsx(hi,{children:"Der bestehende Inhalt dieser Section wird ersetzt. Bestehende Evidence-Zuordnungen werden durch die neuen verifizierten Belege ersetzt."})]}),o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Ziel-Section"}),o.jsxs(pt,{value:v,onValueChange:b,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Section wählen"})}),o.jsx(dt,{children:w.map(C=>o.jsx(Le,{value:C.id,children:C.title},C.id))})]})]}),o.jsxs(ui,{children:[o.jsx(Ws,{disabled:f==="replace",children:"Abbrechen"}),o.jsx(ai,{disabled:!v||f==="replace",onClick:C=>{C.preventDefault(),N()},children:f==="replace"?o.jsx(Xe,{className:"w-4 h-4 animate-spin","aria-hidden":!0}):"Ersetzen"})]})]})})]})}const jHt=900,SHt=2500;function _Ht(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function NHt(t,e={}){const{enabled:r=!0,mode:n="word",duration:s}=e,[i,a]=S.useState(()=>r?"":t),[l,c]=S.useState(!1),u=S.useRef(null);return S.useEffect(()=>{if(!r||!t||_Ht()){a(t),c(!1);return}const d=n==="char"?t.split(""):t.match(/\S+\s*|\s+/g)??[t],h=d.length,f=s??Math.min(SHt,Math.max(jHt,h*14)),p=performance.now();c(!0);const m=g=>{const y=Math.min(1,(g-p)/f),x=Math.max(1,Math.ceil(y*h));a(d.slice(0,x).join("")),y<1?u.current=requestAnimationFrame(m):c(!1)};return u.current=requestAnimationFrame(m),()=>{u.current&&cancelAnimationFrame(u.current)}},[t,r,n,s]),{text:i,isAnimating:l}}function kHt(){return o.jsx("span",{className:"ml-0.5 inline-block w-[2px] h-[1em] align-[-0.15em] bg-primary/70 animate-pulse"})}const S2e="id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at";async function _2e(t,e,r){const n=(r??[]).filter(i=>(i==null?void 0:i.document_id)&&(i==null?void 0:i.quote_text)).map(i=>({user_id:t,section_id:e,document_id:i.document_id,page_number:i.page_number??null,quote_text:i.quote_text,citation_text:i.citation_text??null}));if(n.length===0)return;const{error:s}=await pe.from("section_evidence").insert(n);if(s)throw s}async function CHt(t){const{userId:e,draft:r,chapterId:n,existingSections:s}=t,i=(s.reduce((c,u)=>Math.max(c,u.order_index??0),0)||0)+10,{data:a,error:l}=await pe.from("sections").insert({chapter_id:n,title:r.title||"Untitled section",content:r.content??"",content_rich:r.content_rich??null,order_index:i}).select(S2e).single();if(l)throw l;return await _2e(e,a.id,r.evidence),a}async function EHt(t){const{userId:e,draft:r,sectionId:n}=t,{data:s,error:i}=await pe.from("sections").update({title:r.title||void 0,content:r.content??"",content_rich:r.content_rich??null}).eq("id",n).select(S2e).single();if(i)throw i;return await pe.from("section_evidence").delete().eq("section_id",n),await _2e(e,n,r.evidence),s}const AHt=10*1024*1024;function THt({thesisId:t,chapterId:e,sectionId:r,chapterLabel:n,sectionLabel:s,sectionsByChapter:i={},onSectionsChanged:a}){const{isOpen:l,closeSupervisor:c}=b2e(),{user:u}=Ht(),{messages:d,isLoading:h,isSending:f,error:p,sendMessage:m,refreshMessages:g,liveMessageIds:y}=xHt({thesisId:t,chapterId:e,sectionId:r}),[x,v]=S.useState(""),[b,w]=S.useState(null),[j,N]=S.useState(null),C=S.useRef(null);S.useEffect(()=>{if(!l)return;g();const D=K=>{K.key==="Escape"&&c()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[l,c,g]);const A=S.useMemo(()=>{const D=[];for(const K of d)if(K.message_type==="workflow_step"){const H=D[D.length-1];H!=null&&H.steps?H.steps.push(K):D.push({key:K.id,node:K,steps:[K]})}else D.push({key:K.id,node:K});return D},[d]),E=S.useCallback(async D=>{var ee;const K=(ee=D.target.files)==null?void 0:ee[0];if(D.target.value="",!K||K.size>AHt)return;const H=await new Promise((V,B)=>{const z=new FileReader;z.onload=()=>V(z.result.split(",")[1]??""),z.onerror=B,z.readAsDataURL(K)});w({name:K.name,base64:H,type:K.type})},[]),O=S.useCallback(async D=>{D==null||D.preventDefault();const K=x.trim();if(!K||f)return;v("");const H=b,ee=(j==null?void 0:j.id)??null;w(null),N(null),await m(K,{attachment:H,draftMessageId:ee})},[x,b,f,m,j]),$=S.useCallback(D=>{const K=D.target_chapter_id??e??null;return(K?i[K]??[]:[]).map(ee=>({id:ee.id,title:ee.title||"Untitled section"}))},[i,e]),T=S.useCallback(async D=>{if(!u)return;const K=D.target_chapter_id??e??null;if(!K){It({title:"Kein Zielkapitel",description:"Bitte zuerst ein Kapitel öffnen.",variant:"destructive"});return}try{await CHt({userId:u.id,draft:D,chapterId:K,existingSections:i[K]??[]}),await(a==null?void 0:a()),It({title:"Section gespeichert",description:"Der Entwurf wurde als neue Section angelegt."})}catch(H){throw It({title:"Speichern fehlgeschlagen",description:H==null?void 0:H.message,variant:"destructive"}),H}},[u,e,i,a]),M=S.useCallback(async(D,K)=>{if(u)try{await EHt({userId:u.id,draft:D,sectionId:K}),await(a==null?void 0:a()),It({title:"Section ersetzt",description:"Inhalt und Belege wurden aktualisiert."})}catch(H){throw It({title:"Ersetzen fehlgeschlagen",description:H==null?void 0:H.message,variant:"destructive"}),H}},[u,a]),k=S.useCallback((D,K)=>{var H;N({id:D.id,title:K}),(H=C.current)==null||H.focus()},[]);return l?o.jsxs("div",{className:"fixed inset-y-0 right-0 z-50 w-[min(600px,100vw)] max-w-none flex flex-col border-l border-border bg-background shadow-2xl animate-in slide-in-from-right duration-300",role:"complementary","aria-label":"Thesis Supervisor",children:[o.jsxs("div",{className:"shrink-0 flex items-start justify-between gap-3 border-b border-border px-4 py-3",children:[o.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[o.jsx(wx,{isLoading:f,size:36}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-sm font-semibold text-foreground flex items-center gap-1.5",children:"Thesis Supervisor"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"AI research & writing assistant"})]})]}),o.jsx("button",{type:"button",onClick:c,className:"rounded-md p-1.5 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors","aria-label":"Close supervisor panel",children:o.jsx(fn,{className:"w-4 h-4"})})]}),o.jsxs("div",{className:"shrink-0 border-b border-border px-4 py-1.5 text-[11px] text-muted-foreground truncate",children:["Kapitel ",n," / Section ",s]}),o.jsxs(w2e,{className:"flex-1 min-h-0 !h-auto px-4 py-3",children:[h?o.jsx("div",{className:"h-full flex items-center justify-center",children:o.jsx(Xe,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):d.length===0?o.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center gap-3 px-6",children:[o.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center",children:o.jsx(_N,{className:"w-6 h-6 text-primary"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-medium text-foreground",children:"Dein Thesis Supervisor"}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1 leading-relaxed",children:"Stelle Fragen zu deiner Thesis, lass dir Feedback geben oder diskutiere deine Argumentation."})]})]}):A.map((D,K)=>{if(D.steps){const V=K<A.length-1;return o.jsx("div",{className:"pl-11",children:o.jsx(yHt,{steps:D.steps,hideWhenDone:V})},D.key)}const H=D.node;if(H.message_type==="section_draft"){const V=H.tool_payload??{};return o.jsx("div",{className:"pl-11",children:o.jsx(wHt,{message:H,sectionOptions:$(V),onSaveAsNew:T,onReplace:M,onContinueInChat:k,isEditingInChat:(j==null?void 0:j.id)===H.id})},H.id)}const ee=H.role==="user";return o.jsx(S.Fragment,{children:o.jsxs(Tce,{variant:ee?"sent":"received",children:[!ee&&o.jsx(wx,{size:28}),o.jsx(Pce,{variant:ee?"sent":"received",className:Pe(ee&&"bg-primary text-primary-foreground"),children:ee?o.jsx("p",{className:"text-sm whitespace-pre-wrap",children:H.content}):o.jsx(PHt,{content:H.content??"",animate:y.has(H.id)})})]})},H.id)}),f&&o.jsxs(Tce,{variant:"received",children:[o.jsx(wx,{isLoading:!0,size:28}),o.jsx(Pce,{variant:"received",isLoading:!0})]})]}),o.jsxs("form",{onSubmit:O,className:"shrink-0 border-t border-border bg-background px-4 py-3",children:[j&&o.jsxs("div",{className:"mb-2 inline-flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-[11px] text-muted-foreground",children:[o.jsxs("span",{className:"max-w-[280px] truncate",children:["Bearbeitet: ",j.title]}),o.jsx("button",{type:"button",onClick:()=>N(null),className:"hover:text-foreground","aria-label":"Draft-Bezug entfernen",children:o.jsx(fn,{className:"w-3 h-3"})})]}),b&&o.jsxs("div",{className:"mb-2 inline-flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-[11px] text-muted-foreground",children:[o.jsx(CB,{className:"w-3 h-3"}),o.jsx("span",{className:"max-w-[240px] truncate",children:b.name}),o.jsx("button",{type:"button",onClick:()=>w(null),className:"hover:text-foreground","aria-label":"Remove attachment",children:o.jsx(fn,{className:"w-3 h-3"})})]}),p&&o.jsx("p",{className:"mb-2 text-xs text-destructive",children:p}),o.jsxs("div",{className:"relative flex items-end gap-2 rounded-lg border border-input bg-background focus-within:ring-1 focus-within:ring-ring",children:[o.jsx(j2e,{ref:C,value:x,onChange:D=>v(D.target.value),onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),O())},placeholder:"Frag deinen Thesis Supervisor...",className:"min-h-[52px] flex-1 border-0 bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 resize-none"}),o.jsxs("div",{className:"flex items-center gap-1 pr-2 pb-2",children:[o.jsxs("label",{className:"cursor-pointer rounded-full p-2 text-muted-foreground hover:bg-muted hover:text-foreground transition-colors",children:[o.jsx(CB,{className:"w-4 h-4"}),o.jsx("input",{type:"file",className:"hidden",accept:"image/*,.pdf,.doc,.docx,.txt,.md",onChange:E})]}),o.jsx(me,{type:"submit",size:"icon",variant:"ghost",disabled:!x.trim()||f,className:"h-8 w-8 rounded-full","aria-label":"Send message",children:f?o.jsx(Xe,{className:"w-4 h-4 animate-spin"}):o.jsx(WW,{className:"w-4 h-4"})})]})]})]})]}):null}const PHt=S.memo(function({content:e,animate:r}){const{text:n,isAnimating:s}=NHt(e,{enabled:r,mode:"word"});return o.jsxs("div",{className:"prose prose-sm dark:prose-invert max-w-none text-sm",children:[o.jsx(rc,{remarkPlugins:[tSe],children:n}),s&&o.jsx(kHt,{})]})}),Ice={theory:["theor","background","hinterg","literatur","literature review","stand des wissens","allgemeine definition","grundlag"],methodology:["method","methodik","vorgeh","approach"]};function IHt(t){if(!t)return"custom";const e=t.toLowerCase();return Ice.theory.some(r=>e.includes(r))?"theory":Ice.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 b6(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 N2(t){return(t.trim().match(/\S+/g)||[]).length}function RHt(){return o.jsx(pHt,{children:o.jsx(OHt,{})})}function OHt(){var pc,qK,GK;const{user:t,loading:e,researchProfile:r,checkStudentPoints:n,studentPoints:s}=Ht(),{openSupervisor:i}=b2e(),[a,l]=S.useState(!1),c=Or(),[u,d]=S.useState(!0),[h,f]=S.useState(null),[p,m]=S.useState([]),[g,y]=S.useState([]),[x,v]=S.useState({}),[b,w]=S.useState(null),[j,N]=S.useState(null),[C,A]=S.useState(null),[E,O]=S.useState(0),[$,T]=S.useState(null),[M,k]=S.useState([]),[D,K]=S.useState(new Set),[H,ee]=S.useState(!1),[V,B]=S.useState(!1),[z,F]=S.useState(null),[G,Q]=S.useState(!1),[ie,se]=S.useState(null),[q,L]=S.useState(null),[Z,J]=S.useState(null),[W,X]=S.useState(!1),[he,P]=S.useState(null),[oe,Y]=S.useState(""),[R,I]=S.useState(null),[U,re]=S.useState(null),ue=S.useRef({}),ae=S.useRef({}),ge=S.useRef({}),we=S.useRef({}),ce=S.useRef({}),ne=S.useRef(0),fe=S.useRef(null);S.useEffect(()=>{!e&&!t&&c("/login")},[e,t,c]);const be=async(je,De)=>{var nt,Lt;d(!0);const{data:qe}=await pe.from("theses").select("id,title,due_date,target_word_count,updated_at,degree,description,language").eq("user_id",je).order("updated_at",{ascending:!1}),Be=qe??[];m(Be);const rt=(De?Be.find(Yt=>Yt.id===De):Be[0])??null;if(f(rt),rt){const{data:Yt}=await pe.from("chapters").select("id,title,order_index,progress,updated_at,kind,target_share").eq("thesis_id",rt.id).is("parent_id",null).order("order_index"),Tr=Yt??[];if(y(Tr),Tr.length&&w(Tr[0].id),Tr.length){const{data:Br}=await pe.from("sections").select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").in("chapter_id",Tr.map(ls=>ls.id)).order("order_index"),At={};Br==null||Br.forEach(ls=>{var pu;(At[pu=ls.chapter_id]||(At[pu]=[])).push(ls)}),v(At);const Gt=Tr.map(ls=>{var pu;return(pu=At[ls.id])==null?void 0:pu[0]}).find(ls=>!!ls);Gt&&N(Gt.id)}const{count:an}=await pe.from("documents").select("id",{count:"exact",head:!0}).eq("user_id",je);O(an??0);const{data:zn}=await pe.from("documents").select("id, title, citation_apa, bib_meta, author_surname, published_year, authors_display").eq("user_id",je);if(k(zn||[]),Tr.length){const{data:Br}=await pe.from("sections").select("id").in("chapter_id",Tr.map(Gt=>Gt.id)),At=(Br||[]).map(Gt=>Gt.id);if(At.length){const{data:Gt}=await pe.from("section_evidence").select("document_id").in("section_id",At).not("document_id","is",null);K(new Set((Gt||[]).map(ls=>ls.document_id).filter(Boolean)))}else K(new Set)}}const[ze,Ve]=await Promise.all([pe.from("theory_backgrounds").select("title,theory_text,created_at").eq("user_id",je).not("theory_text","is",null).order("created_at",{ascending:!1}).limit(1).maybeSingle(),pe.from("methods").select("title,method_text,created_at").eq("user_id",je).not("method_text","is",null).order("created_at",{ascending:!1}).limit(1).maybeSingle()]);(nt=ze.data)!=null&&nt.theory_text&&se({title:ze.data.title||"Theory Draft",text:ze.data.theory_text,created_at:ze.data.created_at}),(Lt=Ve.data)!=null&&Lt.method_text&&L({title:Ve.data.title||"Methodology Draft",text:Ve.data.method_text,created_at:Ve.data.created_at}),d(!1)};S.useEffect(()=>{t&&be(t.id)},[t]),S.useEffect(()=>{if(!g.length)return;const je=(rt,ze)=>{const Ve=Object.entries(rt).map(([Lt,Yt])=>Yt?{id:Lt,top:Yt.getBoundingClientRect().top}:null).filter(Lt=>Lt!==null).sort((Lt,Yt)=>Lt.top-Yt.top);if(!Ve.length)return null;const nt=Ve.filter(Lt=>Lt.top<=ze);return nt.length>0?nt[nt.length-1].id:Ve[0].id},De=()=>{if(fe.current=null,Date.now()<ne.current)return;const rt=160,ze=je(ue.current,rt);je(ae.current,rt),ze&&w(Ve=>Ve===ze?Ve:ze)},qe=()=>{fe.current===null&&(fe.current=window.requestAnimationFrame(De))};window.addEventListener("scroll",qe,{passive:!0}),window.addEventListener("resize",qe);const Be=window.requestAnimationFrame(De);return()=>{window.removeEventListener("scroll",qe),window.removeEventListener("resize",qe),window.cancelAnimationFrame(Be),fe.current!==null&&(window.cancelAnimationFrame(fe.current),fe.current=null)}},[g,x]),S.useEffect(()=>{if(!b)return;const je=ge.current[b];je==null||je.scrollIntoView({block:"nearest",behavior:"smooth"})},[b]),S.useEffect(()=>{console.log("[Navigator] activeChapterId =",b)},[b]),S.useEffect(()=>{console.log("[Navigator] activeSectionId =",j)},[j]);const xe=je=>je.kind||IHt(je.title),_e=XL(r==null?void 0:r.preferred_language,"en"),ke=S.useMemo(()=>g.find(je=>xe(je)==="theory"),[g]),$e=S.useMemo(()=>g.find(je=>xe(je)==="methodology"),[g]),Te=(GK=(qK=x[((pc=g==null?void 0:g[0])==null?void 0:pc.id)??""])==null?void 0:qK[0])==null?void 0:GK.id,ot=S.useMemo(()=>{const je=g.map(Ve=>({sections:(x[Ve.id]??[]).map(nt=>({content:`${nt.content||""}
${b6(nt.content_rich||"")}`}))})),De=zG(je,M),qe=new Set(D);De.matched.forEach(Ve=>qe.add(Ve.documentId));const Be=new Map(M.map(Ve=>[Ve.id,Ve])),rt=Array.from(qe).map(Ve=>Be.get(Ve)).filter(Boolean),ze=Ve=>{var nt;return(Ve.author_surname||Ve.authors_display||((nt=Ve.citation_apa)==null?void 0:nt.split(/[,(]/)[0])||Ve.title||"").toString().trim().toLowerCase()};return rt.sort((Ve,nt)=>ze(Ve).localeCompare(ze(nt))),rt},[g,x,M,D]),wt=je=>(ke==null?void 0:ke.id)===je&&ie?{kind:"theory",title:ie.title,text:ie.text,createdAt:ie.created_at,chapterId:je}:($e==null?void 0:$e.id)===je&&q?{kind:"methodology",title:q.title,text:q.text,createdAt:q.created_at,chapterId:je}:null,Ct=je=>je.content_rich?N2(b6(je.content_rich)):je.word_count??N2(je.content||""),pr=S.useMemo(()=>Object.values(x).flat().reduce((je,De)=>je+Ct(De),0),[x]);S.useMemo(()=>Object.values(x).flat().length,[x]);const Kt=Number(h==null?void 0:h.target_word_count)||0,Re=S.useMemo(()=>Kt>0?Math.min(100,Math.round(pr/Kt*100)):g.length?Math.round(g.reduce((je,De)=>je+(Number(De.progress)||0),0)/g.length):0,[Kt,pr,g]),ye=S.useMemo(()=>{const je={};return g.forEach(De=>{const qe=Number(De.target_share)||0,Be=Kt>0&&qe>0?Kt*qe:0;if(Be<=0){je[De.id]=qe===0&&De.target_share!==null?0:Number(De.progress)||0;return}const ze=(x[De.id]??[]).reduce((Ve,nt)=>Ve+Ct(nt),0);je[De.id]=Math.min(100,Math.round(ze/Be*100))}),je},[g,x,Kt]),Ne=Re,Ce=S.useMemo(()=>g.filter(je=>xe(je)!=="references"),[g]),Fe=S.useMemo(()=>Ce.filter(je=>(ye[je.id]??0)>=100).length,[Ce,ye]),yt=(je,De,qe)=>{v(Be=>({...Be,[je]:(Be[je]??[]).map(rt=>rt.id===De?{...rt,content_rich:qe.html,content:qe.text,word_count:N2(qe.text)}:rt)})),we.current[De]&&clearTimeout(we.current[De]),we.current[De]=setTimeout(async()=>{T(De),await pe.from("sections").update({content:qe.text,content_rich:qe.html}).eq("id",De),T(null),He(De,qe.text)},700)},He=async(je,De)=>{var qe;try{(qe=ce.current[je])==null||qe.abort();const Be=new AbortController;ce.current[je]=Be;const{data:rt}=await pe.from("section_evidence").select("id, citation_text").eq("section_id",je);if(Be.signal.aborted)return;const ze=(rt??[]).filter(Ve=>{var an,zn;if(!Ve.citation_text||De.includes(Ve.citation_text))return!1;const nt=Ve.citation_text.match(/\(([^,]+),\s*(\d{4})/),Lt=(an=nt==null?void 0:nt[1])==null?void 0:an.trim(),Yt=(zn=nt==null?void 0:nt[2])==null?void 0:zn.trim();return!!!(Lt&&Yt&&De.includes(Lt)&&De.includes(Yt))}).map(Ve=>Ve.id);if(ze.length>0){if(await pe.from("section_evidence").delete().in("id",ze),Be.signal.aborted)return;console.log("[evidence-cleanup] deleted stale rows:",ze.length),window.dispatchEvent(new CustomEvent("ghost-evidence-accepted",{detail:{section_id:je}}))}ce.current[je]===Be&&delete ce.current[je]}catch(Be){console.error("[evidence-cleanup] failed:",Be)}},Ye=async(je,De)=>{y(qe=>qe.map(Be=>Be.id===je?{...Be,title:De}:Be)),await pe.from("chapters").update({title:De}).eq("id",je)},it=async(je,De,qe)=>{v(Be=>({...Be,[je]:(Be[je]??[]).map(rt=>rt.id===De?{...rt,title:qe}:rt)})),await pe.from("sections").update({title:qe}).eq("id",De)},zt=async je=>{if(!t)return;const qe=((x[je]??[]).reduce((Ve,nt)=>Math.max(Ve,nt.order_index??0),0)||0)+10,{data:Be,error:rt}=await pe.from("sections").insert({chapter_id:je,title:"",content:"",order_index:qe}).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(rt){It({title:"Could not add section",description:rt.message,variant:"destructive"});return}const ze=Be;v(Ve=>({...Ve,[je]:[...Ve[je]??[],ze]})),setTimeout(()=>{const Ve=ae.current[ze.id];Ve==null||Ve.scrollIntoView({behavior:"smooth",block:"center"});const nt=Ve==null?void 0:Ve.querySelector('.ProseMirror[contenteditable="true"]');nt==null||nt.focus()},150)},Xt=async(je,De)=>{if(!t)return;const qe=x[je]??[],Be=qe.find(Yt=>Yt.id===De);if(!Be||Be.parent_section_id){It({title:"Cannot add subsection",description:"Subsections cannot contain further subsections.",variant:"destructive"});return}const ze=(qe.filter(Yt=>Yt.parent_section_id===De).reduce((Yt,Tr)=>Math.max(Yt,Tr.order_index??0),0)||0)+10,{data:Ve,error:nt}=await pe.from("sections").insert({chapter_id:je,parent_section_id:De,title:"",content:"",order_index:ze}).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(nt){It({title:"Could not add subsection",description:nt.message,variant:"destructive"});return}const Lt=Ve;v(Yt=>({...Yt,[je]:[...Yt[je]??[],Lt]})),setTimeout(()=>{const Yt=ae.current[Lt.id];Yt==null||Yt.scrollIntoView({behavior:"smooth",block:"center"});const Tr=Yt==null?void 0:Yt.querySelector('.ProseMirror[contenteditable="true"]');Tr==null||Tr.focus()},150)},Mr=async(je,De)=>{if((x[je]??[]).some(ze=>ze.parent_section_id===De)){It({title:"This section contains subsections",description:"Delete or move the subsections first.",variant:"destructive"});return}const{error:rt}=await pe.from("sections").delete().eq("id",De);if(rt){It({title:"Could not delete section",description:/foreign key|violates/i.test(rt.message)?"This section contains subsections. Delete or move the subsections first.":rt.message,variant:"destructive"});return}v(ze=>({...ze,[je]:(ze[je]??[]).filter(Ve=>Ve.id!==De)}))},ur=async(je,De)=>{if(y(Be=>Be.map(rt=>rt.id===je?{...rt,kind:De}:rt)),await pe.from("chapters").update({kind:De}).eq("id",je),!(h!=null&&h.id))return;await pe.rpc("normalize_chapter_shares",{p_thesis:h.id});const{data:qe}=await pe.from("chapters").select("id,kind,target_share").eq("thesis_id",h.id).is("parent_id",null);if(qe){const Be=new Map(qe.map(rt=>[rt.id,rt]));y(rt=>rt.map(ze=>{const Ve=Be.get(ze.id);return Ve?{...ze,kind:Ve.kind,target_share:Ve.target_share}:ze}))}},Fr=je=>{var De;ne.current=Date.now()+900,(De=ue.current[je])==null||De.scrollIntoView({behavior:"smooth",block:"start"})},Kr=je=>{var De;ne.current=Date.now()+900,(De=ae.current[je])==null||De.scrollIntoView({behavior:"smooth",block:"start"})},ct=async()=>{if(h){Q(!0);try{const je={thesis:{title:h.title,degree:h.degree||"bachelor",description:h.description||void 0,due_date:h.due_date,target_word_count:h.target_word_count},chapters:g.map((De,qe)=>({title:De.title,order_index:De.order_index,status:"open",sections:AS(x[De.id]??[],qe+1).map(({section:Be,number:rt,depth:ze})=>({title:Be.title||"",type:"text",content:Be.content_rich?b6(Be.content_rich.replace(/<\/(p|li|blockquote|h[1-6])>/gi,`$&

`).replace(/<br\s*\/?>/gi,`
`)).replace(/\n{3,}/g,`

`):Be.content||"",content_rich:Be.content_rich||void 0,status:"open",word_count:Be.word_count??N2(Be.content||""),order_index:Be.order_index,number:rt,level:ze+1}))}))};F(je),B(!0)}finally{Q(!1)}}},xn=async()=>{if(!(!Z||!t)){X(!0);try{const je=x[Z.chapterId]??[],De=Z.kind==="theory"?"Theory Draft":"Methodology Draft",qe=je.find(Be=>Be.title===De)??je[0];if(qe){const Be=qe.content?`${qe.content}

${Z.text}`:Z.text,{error:rt}=await pe.from("sections").update({content:Be,content_rich:null}).eq("id",qe.id);if(rt)throw rt;v(ze=>({...ze,[Z.chapterId]:ze[Z.chapterId].map(Ve=>Ve.id===qe.id?{...Ve,content:Be,content_rich:null}:Ve)}))}else{const{data:Be,error:rt}=await pe.from("sections").insert({chapter_id:Z.chapterId,title:De,content:Z.text,order_index:10}).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(rt)throw rt;v(ze=>({...ze,[Z.chapterId]:[...ze[Z.chapterId]??[],Be]}))}It({title:"Draft imported",description:`${Z.title} added to chapter.`}),J(null),setTimeout(()=>Fr(Z.chapterId),50)}catch(je){It({title:"Import failed",description:je.message??"Could not import draft.",variant:"destructive"})}finally{X(!1)}}},Qn=je=>{if(!je)return je;const De=/^[ \t]*(?:#{1,6}[ \t]*)?(?:\*\*)?(?:Original\s+Quotes|Originaltextstellen|Proof\s+of\s+Material|Wörtliche\s+Zitate|Originalzitate)\b.*$/im;let qe=je.replace(new RegExp(De.source+"[\\s\\S]*$","im"),"");return qe=qe.replace(/(?:\n[ \t]*>.*)+\s*$/m,""),qe.trimEnd()},as=(je,De,qe)=>{const Be=(je||"").trim();if(Be)return Be.slice(0,80);const rt=(De||"").trim();return rt.length>=3?rt.slice(0,80):(qe||"Section").slice(0,80)},Lf=async(je,De,qe)=>{if(!(!h||!t)){re(je);try{const Be=g.find(Br=>Br.id===je),rt=De.selected.map(Br=>Br.document_id),ze=(De.text||"").trim().length>=5?De.text.trim():`${(Be==null?void 0:Be.title)??"Theory"} — ${h.title}`,{data:Ve,error:nt}=await pe.functions.invoke("thesis_builder",{body:{document_ids:rt,page_ranges:De.pageRanges,topic:ze,mode:"academic",language:_e,citation_style:"APA7",save_pdf:!1,thesis_id:h.id,chapter_id:je}});if(nt)throw nt;if((Ve==null?void 0:Ve.error)==="rate_limit"){It({title:"Please retry",description:`Rate limited. Retry in ~${Ve.retry_after??10}s.`,variant:"destructive"});return}const Lt=(Ve==null?void 0:Ve.content)??(Ve==null?void 0:Ve.theory_text)??(Ve==null?void 0:Ve.text)??(Ve==null?void 0:Ve.result)??"";if(!Lt)throw new Error("Empty response from generator.");const Yt=Qn(Lt),Tr=as(Ve==null?void 0:Ve.title,De.text,Be==null?void 0:Be.title);let an=null,zn=null;if(qe){const{data:Br,error:At}=await pe.from("sections").update({title:Tr,content:Yt}).eq("id",qe).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(At)throw At;an=(Br==null?void 0:Br.id)??qe,zn=Br,await pe.from("section_evidence").delete().eq("section_id",qe)}else{const At=((x[je]??[]).reduce((pu,E5)=>Math.max(pu,E5.order_index??0),0)||0)+10,{data:Gt,error:ls}=await pe.from("sections").insert({chapter_id:je,title:Tr,content:Yt,order_index:At}).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(ls)throw ls;an=(Gt==null?void 0:Gt.id)??null,zn=Gt}if(an&&Array.isArray(Ve==null?void 0:Ve.evidence)&&Ve.evidence.length>0){const Br=Ve.evidence.filter(At=>(At==null?void 0:At.document_id)&&(At==null?void 0:At.quote_text)).map(At=>({user_id:t.id,section_id:an,document_id:At.document_id,page_number:At.page_number??null,quote_text:At.quote_text,citation_text:At.citation_text??null,verification_status:At.verification_status==="needs_review"?"needs_review":"verified",verification_reason:At.verification_reason??null}));if(Br.length>0){const{error:At}=await pe.from("section_evidence").insert(Br);At&&(console.error("[MyThesis2] Evidence insert failed:",At),It({title:"Evidence not saved",description:At.message,variant:"destructive"}))}}v(Br=>{const At=Br[je]??[];return qe?{...Br,[je]:At.map(Gt=>Gt.id===qe?{...Gt,...zn}:Gt)}:{...Br,[je]:[...At,zn]}}),an&&window.dispatchEvent(new CustomEvent("ghost-evidence-accepted",{detail:{section_id:an}})),It({title:qe?"Section updated":"Draft created",description:qe?"Existing section updated with AI draft.":"Inserted into your chapter."}),P(null),I(null),setTimeout(()=>Fr(je),80)}catch(Be){console.error("runTheoryGeneration error",Be),It({title:"Generation failed",description:(Be==null?void 0:Be.message)??"Unknown error",variant:"destructive"})}finally{re(null)}}},$f=async(je,De,qe)=>{var Be;if(!(!h||!t)){re(je);try{const rt=g.find(At=>At.id===je),ze=De.selected.map(At=>At.document_id),Ve=(De.text||"").trim().length>=5?De.text.trim():`${(rt==null?void 0:rt.title)??"Methodology"} — ${h.title}`,{data:nt,error:Lt}=await pe.functions.invoke("methodology_builder",{body:{document_ids:ze,page_ranges:De.pageRanges,topic:Ve,language:_e,citation_style:"APA7",mode:"academic",own_words:De.ownWords??"",client_request_id:crypto.randomUUID()}});if(Lt)throw Lt;if(console.log("[methodology-evidence] data received:",{hasEvidence:Array.isArray(nt==null?void 0:nt.evidence),evidenceCount:((Be=nt==null?void 0:nt.evidence)==null?void 0:Be.length)??0,hasContent:!!(nt!=null&&nt.content)}),(nt==null?void 0:nt.error)==="rate_limit"){It({title:"Please retry",description:`Rate limited. Retry in ~${nt.retry_after??10}s.`,variant:"destructive"});return}const Yt=(nt==null?void 0:nt.content)??(nt==null?void 0:nt.methodology_text)??(nt==null?void 0:nt.text)??(nt==null?void 0:nt.result)??"";if(!Yt)throw new Error("Empty response from generator.");const Tr=Qn(Yt),an=as(nt==null?void 0:nt.title,De.text,rt==null?void 0:rt.title);let zn=null,Br=null;if(qe){const{data:At,error:Gt}=await pe.from("sections").update({title:an,content:Tr}).eq("id",qe).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(Gt)throw Gt;zn=(At==null?void 0:At.id)??qe,Br=At,await pe.from("section_evidence").delete().eq("section_id",qe)}else{const Gt=((x[je]??[]).reduce((E5,R2e)=>Math.max(E5,R2e.order_index??0),0)||0)+10,{data:ls,error:pu}=await pe.from("sections").insert({chapter_id:je,title:an,content:Tr,order_index:Gt}).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(pu)throw pu;zn=(ls==null?void 0:ls.id)??null,Br=ls}if(zn&&Array.isArray(nt==null?void 0:nt.evidence)&&nt.evidence.length>0){const At=nt.evidence.filter(Gt=>(Gt==null?void 0:Gt.document_id)&&(Gt==null?void 0:Gt.quote_text)).map(Gt=>({user_id:t.id,section_id:zn,document_id:Gt.document_id,page_id:Gt.page_id??null,page_number:Gt.page_number??null,quote_text:Gt.quote_text,citation_text:Gt.citation_text??null}));if(At.length>0){const{error:Gt}=await pe.from("section_evidence").insert(At);Gt&&(console.error("[methodology-evidence] save failed:",Gt,At),It({title:"Evidence not saved",description:Gt.message,variant:"destructive"}))}}v(At=>{const Gt=At[je]??[];return qe?{...At,[je]:Gt.map(ls=>ls.id===qe?{...ls,...Br}:ls)}:{...At,[je]:[...Gt,Br]}}),zn&&window.dispatchEvent(new CustomEvent("ghost-evidence-accepted",{detail:{section_id:zn}})),It({title:qe?"Section updated":"Draft created",description:qe?"Existing section updated with AI draft.":"Inserted into your chapter."}),P(null),I(null),setTimeout(()=>Fr(je),80)}catch(rt){console.error("runMethodologyGeneration error",rt),It({title:"Generation failed",description:(rt==null?void 0:rt.message)??"Unknown error",variant:"destructive"})}finally{re(null)}}},Wv=async(je,De,qe)=>{if(!(!h||!t)){if(!n()){l(!0);return}if(!De.sourceChapterIds||De.sourceChapterIds.length===0){It({title:"Select source chapters",description:"Choose at least one chapter to synthesize.",variant:"destructive"});return}re(je);try{const{data:Be,error:rt}=await pe.functions.invoke("discussion_builder",{body:{thesis_id:h.id,chapter_ids:De.sourceChapterIds,language:De.language,mode:De.mode}});if(rt)throw rt;if(Be!=null&&Be.error)throw new Error(Be.error);const ze=(Be==null?void 0:Be.content)??"",Ve=(Be==null?void 0:Be.title)??"Discussion";if(!ze.trim())throw new Error("Empty response from discussion builder.");const nt=Ace(ze),Lt=Ece(ze);let Yt=null;if(qe){const{data:Tr,error:an}=await pe.from("sections").update({title:Ve,content:nt,content_rich:Lt}).eq("id",qe).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(an)throw an;Yt=Tr}else{const an=((x[je]??[]).reduce((At,Gt)=>Math.max(At,Gt.order_index??0),0)||0)+10,{data:zn,error:Br}=await pe.from("sections").insert({chapter_id:je,parent_section_id:null,title:Ve,content:nt,content_rich:Lt,order_index:an}).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(Br)throw Br;Yt=zn}v(Tr=>{const an=Tr[je]??[];return qe?{...Tr,[je]:an.map(zn=>zn.id===qe?{...zn,...Yt}:zn)}:{...Tr,[je]:[...an,Yt]}}),It({title:qe?"Section updated":"Discussion created",description:qe?"Existing section updated with AI draft.":"Inserted into your chapter."}),P(null),I(null),setTimeout(()=>Fr(je),80)}catch(Be){console.error("runDiscussionGeneration error",Be),It({title:"Discussion generation failed",description:(Be==null?void 0:Be.message)??"Unknown error",variant:"destructive"})}finally{re(null)}}},Vv=async(je,De,qe)=>{if(!(!h||!t)){if(!n()){l(!0);return}if(!De.sourceChapterIds||De.sourceChapterIds.length===0){It({title:"Select source chapters",description:"Choose at least one chapter to synthesize.",variant:"destructive"});return}re(je);try{const{data:Be,error:rt}=await pe.functions.invoke("conclusion_builder",{body:{thesis_id:h.id,chapter_ids:De.sourceChapterIds,language:De.language,mode:De.mode,include_limitations:De.includeLimitations,include_outlook:De.includeOutlook}});if(rt)throw rt;if(Be!=null&&Be.error)throw new Error(Be.error);const ze=(Be==null?void 0:Be.conclusion_text)??"";if(!ze)throw new Error("Empty response from conclusion builder.");const Ve=Ace(ze),nt=Ece(ze);let Lt=null;if(qe){const{data:Yt,error:Tr}=await pe.from("sections").update({content:Ve,content_rich:nt}).eq("id",qe).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(Tr)throw Tr;Lt=Yt}else{const an=((x[je]??[]).filter(At=>!At.parent_section_id).reduce((At,Gt)=>Math.max(At,Gt.order_index??0),0)||0)+10,{data:zn,error:Br}=await pe.from("sections").insert({chapter_id:je,title:(Be==null?void 0:Be.title)??"Conclusion",content:Ve,content_rich:nt,parent_section_id:null,order_index:an}).select("id,chapter_id,parent_section_id,title,order_index,content,content_rich,word_count,updated_at").single();if(Br)throw Br;Lt=zn}v(Yt=>{const Tr=Yt[je]??[];return qe?{...Yt,[je]:Tr.map(an=>an.id===qe?{...an,...Lt}:an)}:{...Yt,[je]:[...Tr,Lt]}}),It({title:qe?"Section updated":"Conclusion created",description:qe?"Existing section updated with AI draft.":"Inserted into your chapter."}),P(null),I(null),setTimeout(()=>Fr(je),80)}catch(Be){console.error("runConclusionGeneration error",Be),It({title:"Conclusion generation failed",description:(Be==null?void 0:Be.message)??"Unknown error",variant:"destructive"})}finally{re(null)}}},du=(je,De,qe)=>je>=100?o.jsx(kr,{className:"w-3.5 h-3.5 text-emerald-500",strokeWidth:3}):je>0?o.jsx(BOe,{className:"w-3.5 h-3.5 text-amber-500"}):o.jsx(n1,{className:`w-3.5 h-3.5 ${De?"text-primary":"text-muted-foreground/40"}`});if(e||u)return o.jsx(Cr,{showSidebar:!0,pageTitle:"My Thesis 2",fullWidth:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsx(Xe,{className:"w-6 h-6 animate-spin text-muted-foreground"})})});if(!h)return o.jsx(Cr,{showSidebar:!0,pageTitle:"My Thesis 2",fullWidth:!0,children:o.jsxs("div",{className:"min-h-[60vh] flex flex-col items-center justify-center gap-4",children:[o.jsx("p",{className:"text-muted-foreground",children:"No thesis yet."}),o.jsx(me,{onClick:()=>window.dispatchEvent(new CustomEvent("academly-open-new-thesis")),children:"Create your first thesis"})]})});g.find(je=>je.id===b);const hu=C??Te,Td=hu?g.findIndex(je=>(x[je.id]??[]).some(De=>De.id===hu)):-1,vl=Td>=0?g[Td]:null,gi=vl?AS(x[vl.id]??[],Td+1).find(je=>je.section.id===hu):void 0,Pd=vl?`${Td+1} ${vl.title}`:"—",EA=gi?`${gi.number} ${gi.section.title??""}`:"—",Dj=je=>{switch(je){case"theory":case"methodology":case"discussion":case"conclusion":return"ready";case"results":return"soon";default:return"hidden"}},AA=async je=>{const De=p.find(qe=>qe.id===je);!De||De.id===(h==null?void 0:h.id)||(f(De),t&&await be(t.id,je))},Lj=(je,De,qe,Be)=>{(De==="theory"||De==="methodology"||De==="discussion"||De==="conclusion")&&(Y((qe==null?void 0:qe.trim())??""),I(Be??null),P(je))},fu=g.find(je=>je.id===he)??null;return o.jsx(DUt,{children:o.jsx(NUt,{children:o.jsxs(Cr,{showSidebar:!0,pageTitle:"My Thesis 2",fullWidth:!0,children:[o.jsx(GUt,{onEditThesis:()=>ee(!0),onExport:ct,exportLoading:G,allTheses:p,activeThesisId:h==null?void 0:h.id,onThesisSwitch:AA}),o.jsx(uHt,{writingLanguage:_e}),o.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_240px] gap-5 px-2 lg:px-4 py-2",children:[o.jsx("main",{className:"min-w-0",children:o.jsxs("article",{className:"bg-card text-card-foreground p-6 lg:p-8 pl-8 lg:pl-12 max-w-[78ch] mx-auto",children:[g.map((je,De)=>{const qe=x[je.id]??[],Be=wt(je.id),rt=xe(je);return je.id,o.jsxs("section",{"data-chapter-id":je.id,ref:ze=>{ue.current[je.id]=ze},className:`group/chapter relative scroll-mt-[calc(var(--app-header-height)+var(--thesis-toolbar-height)+var(--thesis-sticky-gap))] ${De>0?"mt-16 pt-10 border-t border-border":""}`,children:[o.jsxs("header",{className:"mb-6",children:[o.jsxs("div",{className:"flex items-baseline gap-2",children:[o.jsxs("span",{className:"text-2xl font-semibold tracking-tight",children:[De+1,".0"]}),o.jsx(UF,{as:"h2",value:je.title,onSave:ze=>Ye(je.id,ze),className:"text-2xl font-semibold tracking-tight"})]}),Be&&o.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-primary/10 text-primary",children:[o.jsx(TB,{className:"w-3 h-3"}),"Draft available"]}),o.jsxs("span",{children:["Generated ",LQ(new Date(Be.createdAt))," ago"]})]})]}),rt==="references"?o.jsxs("div",{className:"space-y-4",children:[ot.length===0?o.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."}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"text-xs text-muted-foreground",children:[ot.length," source",ot.length===1?"":"s"," cited"]}),o.jsx("ol",{className:"space-y-3",children:ot.map(ze=>{const Ve=ze.citation_apa||`${ze.authors_display||ze.author_surname||"Unknown"}${ze.published_year?` (${ze.published_year})`:""}. ${ze.title||"Untitled"}.`;return o.jsx("li",{className:"text-sm leading-relaxed text-foreground pl-6 -indent-6",children:Ve},ze.id)})})]}),qe.length>0&&o.jsx("div",{className:"mt-8 space-y-10 border-t border-border pt-6",children:AS(qe,De+1).map(({section:ze,number:Ve,depth:nt})=>o.jsxs("div",{"data-section-id":ze.id,ref:Lt=>{ae.current[ze.id]=Lt},className:`scroll-mt-[160px] relative ${nt===1?"pl-6 border-l border-border/60":""}`,children:[ze.id===(C??Te)&&o.jsx(yce,{kind:rt,chapterKind:je.kind??"",isActive:!0,hasDraft:!!Be,onImport:Be?()=>J(Be):void 0,onChangeKind:Lt=>ur(je.id,Lt),aiAvailability:Dj(rt),aiTooltip:rt==="theory"?"Create with AI - draft theoretical background":rt==="methodology"?"Create with AI - draft methodology":rt==="discussion"?"Create with AI - draft discussion":rt==="conclusion"?"Create with AI - draft conclusion":"Coming soon",activeSectionTitle:ze.title??"",onCreateWithAI:Lt=>Lj(je.id,rt,Lt,ze.id),onAddSection:()=>zt(je.id),canAddSubsection:nt===0,onAddSubsection:nt===0?()=>Xt(je.id,ze.id):void 0,onDeleteSection:()=>Mr(je.id,ze.id),onOpenSupervisor:i}),ze.title!==null&&ze.title!==void 0&&o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("span",{className:`font-semibold text-muted-foreground/70 ${nt===1?"text-base":"text-lg"}`,children:Ve}),o.jsx(UF,{as:"h3",value:ze.title||"",placeholder:"Untitled section",onSave:Lt=>it(je.id,ze.id,Lt),className:"text-lg font-semibold flex-1"}),o.jsx(_ce,{sectionId:ze.id})]}),o.jsx(gce,{sectionId:ze.id,html:ze.content_rich,plainText:ze.content,onChange:Lt=>yt(je.id,ze.id,Lt),placeholder:"Start writing this section...",chapterKind:je.kind??void 0,chapterTitle:je.title??void 0,language:_e})]},ze.id))})]}):qe.length===0?o.jsx("div",{className:"text-sm text-muted-foreground py-8",children:"No sections yet for this chapter."}):o.jsx("div",{className:"space-y-10",children:AS(qe,De+1).map(({section:ze,number:Ve,depth:nt})=>o.jsxs("div",{"data-section-id":ze.id,ref:Lt=>{ae.current[ze.id]=Lt},className:`scroll-mt-[160px] relative ${nt===1?"pl-6 border-l border-border/60":""}`,children:[ze.id===(C??Te)&&o.jsx(yce,{kind:rt,chapterKind:je.kind??"",isActive:!0,hasDraft:!!Be,onImport:Be?()=>J(Be):void 0,onChangeKind:Lt=>ur(je.id,Lt),aiAvailability:Dj(rt),aiTooltip:rt==="theory"?"Create with AI — draft theoretical background":rt==="methodology"?"Create with AI — draft methodology":rt==="discussion"?"Create with AI — draft discussion":rt==="conclusion"?"Create with AI — draft conclusion":"Coming soon",activeSectionTitle:ze.title??"",onCreateWithAI:Lt=>Lj(je.id,rt,Lt,ze.id),onAddSection:()=>zt(je.id),canAddSubsection:nt===0,onAddSubsection:nt===0?()=>Xt(je.id,ze.id):void 0,onDeleteSection:()=>Mr(je.id,ze.id),onOpenSupervisor:i}),ze.title!==null&&ze.title!==void 0&&o.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[o.jsx("span",{className:`font-semibold text-muted-foreground/70 ${nt===1?"text-base":"text-lg"}`,children:Ve}),o.jsx(UF,{as:"h3",value:ze.title||"",placeholder:"Untitled section",onSave:Lt=>it(je.id,ze.id,Lt),className:"text-lg font-semibold flex-1"}),o.jsx(_ce,{sectionId:ze.id})]}),o.jsx(gce,{sectionId:ze.id,html:ze.content_rich,plainText:ze.content,onChange:Lt=>yt(je.id,ze.id,Lt),placeholder:"Start writing this section...",chapterKind:je.kind??void 0,chapterTitle:je.title??void 0,language:_e})]},ze.id))})]},je.id)}),o.jsxs("footer",{className:"mt-12 pt-5 border-t border-border flex items-center justify-between text-xs text-muted-foreground",children:[o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("span",{className:"tabular-nums",children:[pr," words"]}),o.jsx("span",{className:"flex items-center gap-1.5",children:$?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"w-3 h-3 animate-spin"})," Saving…"]}):o.jsxs(o.Fragment,{children:[o.jsx(kr,{className:"w-3 h-3 text-emerald-500"})," All changes saved"]})})]}),o.jsxs("span",{className:"tabular-nums",children:[E," sources"]})]})]})}),o.jsx("aside",{className:"hidden xl:block",children:o.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:[o.jsxs("div",{className:"shrink-0 space-y-4 pr-1 pb-3 border-b border-border",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-muted-foreground mb-3",children:"Thesis Navigator"}),o.jsx("div",{className:"text-sm font-medium leading-snug",children:h.title}),h.due_date&&o.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Due ",new Date(h.due_date).toLocaleDateString()]}),o.jsxs("div",{className:"mt-4",children:[o.jsxs("div",{className:"flex items-center justify-between text-xs mb-1.5",children:[o.jsx("span",{className:"text-muted-foreground",children:"Progress"}),o.jsxs("span",{className:"tabular-nums font-medium",children:[Ne,"%"]})]}),o.jsx("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Ne}%`}})})]})]}),o.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-muted-foreground",children:"Words"}),o.jsx("div",{className:"mt-0.5 text-sm font-semibold tabular-nums",children:pr.toLocaleString()})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-muted-foreground",children:"Sources"}),o.jsx("div",{className:"mt-0.5 text-sm font-semibold tabular-nums",children:E})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-muted-foreground",children:"Chapters"}),o.jsxs("div",{className:"mt-0.5 text-sm font-semibold tabular-nums",children:[Fe," / ",Ce.length]})]})]})]}),o.jsx("nav",{className:"flex-1 min-h-0 overflow-y-auto pr-1 pt-4 space-y-0.5",children:g.map((je,De)=>{const qe=je.id===b,Be=x[je.id]??[],rt=ye[je.id]??0;return wt(je.id),o.jsxs("div",{children:[o.jsxs("button",{ref:ze=>{ge.current[je.id]=ze},onClick:()=>{var Ve;w(je.id);const ze=(Ve=x[je.id])==null?void 0:Ve[0];ze&&N(ze.id),Fr(je.id)},className:`w-full text-left flex items-center gap-2.5 px-1.5 py-1.5 rounded text-sm transition ${qe?"text-primary font-medium bg-primary/5":"text-foreground/80 font-normal hover:text-foreground"}`,children:[o.jsx("span",{className:"text-xs tabular-nums w-4 shrink-0 text-muted-foreground/70",children:De+1}),o.jsx("span",{className:"truncate flex-1",children:je.title}),o.jsx("span",{className:"shrink-0",children:du(rt,qe)})]}),qe&&Be.length>0&&o.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:AS(Be,De+1).map(({section:ze,number:Ve,depth:nt})=>{if(!ze.title)return null;const Lt=ze.id===j;return o.jsxs("button",{onClick:()=>{N(ze.id),w(je.id),Kr(ze.id)},className:`w-full text-left text-sm py-1 px-1.5 rounded transition truncate ${nt===1?"pl-4 text-[13px]":""} ${Lt?"text-primary font-medium":"text-foreground/80 font-normal hover:text-foreground"}`,children:[Ve," ",ze.title]},ze.id)})})]},je.id)})})]})})]}),o.jsx(iHt,{open:!!he,onOpenChange:je=>{je||(P(null),I(null))},thesisId:h.id,chapterId:he,chapterTitle:(fu==null?void 0:fu.title)??"",chapterKind:fu?xe(fu):"custom",initialTopic:oe,targetSectionId:R,isGenerating:!!he&&U===he,discussionChapters:g.map(je=>({id:je.id,title:je.title,kind:je.kind??null,word_count:(x[je.id]??[]).reduce((De,qe)=>De+(qe.word_count??0),0)})),writingLanguage:_e,onGenerate:je=>{if(!he||!fu)return;const De=xe(fu);return De==="methodology"?$f(he,je,R):De==="discussion"?Wv(he,je,R):De==="conclusion"?Vv(he,je,R):Lf(he,je,R)}}),o.jsx(cu,{open:a,onClose:()=>l(!1),remainingPoints:(s==null?void 0:s.remaining)??0}),o.jsx(jn,{open:!!Z,onOpenChange:je=>!je&&J(null),children:o.jsxs(pn,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[o.jsxs(mn,{children:[o.jsxs(gn,{className:"flex items-center gap-2",children:[o.jsx(TB,{className:"w-4 h-4 text-primary"}),(Z==null?void 0:Z.kind)==="theory"?"Import Theory Draft":"Import Methodology Draft"]}),o.jsxs(og,{children:[Z==null?void 0:Z.title,Z&&o.jsxs("span",{className:"ml-2 text-xs text-muted-foreground",children:["· Generated ",LQ(new Date(Z.createdAt))," ago"]})]})]}),o.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:Z==null?void 0:Z.text}),o.jsxs(kf,{className:"gap-2",children:[o.jsx(me,{variant:"outline",onClick:()=>J(null),disabled:W,children:"Cancel"}),o.jsxs(me,{onClick:xn,disabled:W,className:"gap-2",children:[W?o.jsx(Xe,{className:"w-4 h-4 animate-spin"}):o.jsx(ko,{className:"w-4 h-4"}),"Import into chapter"]})]})]})}),o.jsx(Dve,{open:H,onOpenChange:ee,thesis:h,onUpdated:je=>f(De=>De&&{...De,...je}),onDeleted:()=>{y([]),t&&be(t.id)}}),o.jsx(Yke,{open:V,onOpenChange:B,thesisData:z,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:M}),o.jsx(MHt,{onFocusSection:A}),o.jsx(THt,{thesisId:h.id,chapterId:(vl==null?void 0:vl.id)??null,sectionId:hu??null,chapterLabel:Pd,sectionLabel:EA,sectionsByChapter:x,onSectionsChanged:async()=>{t&&await be(t.id,h.id)}})]})})})}function MHt({onFocusSection:t}){const{activeId:e}=LK();return S.useEffect(()=>{e&&t(e)},[e,t]),null}const nM=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),CA=t=>{const e=new DOMParser().parseFromString(t,"application/xml");if(e.getElementsByTagName("parsererror").length>0)throw new Error("The document contains invalid XML.");return e},Hc=t=>Array.from(t.childNodes).filter(e=>e.nodeType===1),Vc=(t,e)=>t?Hc(t).find(r=>r.localName===e)??null:null,Sa=(t,e)=>{if(!t)return null;for(const r of Array.from(t.attributes))if(r.localName===e)return r.value;return null},DHt=(t,e)=>Array.from(t.getElementsByTagName("*")).filter(r=>r.localName===e),N2e=t=>{var e,r;if(!t)return null;try{const n=CA(t);return((r=(e=DHt(n,"title")[0])==null?void 0:e.textContent)==null?void 0:r.trim())||null}catch{return null}},LHt=/^(?:heading|überschrift|titre|titolo|título|encabezado)\s*(\d)$/i;function $Ht(t){const e=new Map;if(!t)return e;const r=CA(t),n=Hc(r.documentElement).filter(a=>a.localName==="style"),s=new Map;n.forEach(a=>{const l=Sa(a,"styleId");if(!l)return;const c=Sa(Vc(a,"name"),"val")??"",u=Sa(Vc(Vc(a,"pPr"),"outlineLvl"),"val");s.set(l,{name:c,outline:u!=null&&!Number.isNaN(Number(u))?Number(u):null,basedOn:Sa(Vc(a,"basedOn"),"val")})});const i=(a,l=0)=>{const c=s.get(a);if(!c||l>8)return{level:null,isTitle:!1};const u=c.name.trim().match(LHt)??a.match(/^(?:heading|berschrift)(\d)$/i);return u?{level:Number(u[1]),isTitle:!1}:/^title$/i.test(c.name.trim())||/^title$/i.test(a)?{level:null,isTitle:!0}:c.outline!=null&&c.outline<9?{level:c.outline+1,isTitle:!1}:c.basedOn?i(c.basedOn,l+1):{level:null,isTitle:!1}};return s.forEach((a,l)=>e.set(l,i(l))),e}const Rce=t=>{if(!t)return!1;const e=Sa(t,"val");return e==null||!["0","false","none"].includes(e)};function Oce(t,e){let r="",n="";const s=i=>{for(const a of Hc(i)){const l=a.localName;if(!(l==="del"||l==="pPr"||l==="instrText"||l==="moveFrom"))if(l==="r"){const c=Vc(a,"rPr"),u=Rce(Vc(c,"b")),d=Rce(Vc(c,"i"));let h="",f="";for(const p of Hc(a))p.localName==="t"?(h+=p.textContent??"",f+=nM(p.textContent??"")):p.localName==="tab"?(h+="	",f+=" "):p.localName==="br"||p.localName==="cr"?(h+=`
`,f+="<br>"):p.localName==="drawing"||p.localName==="pict"?e.images++:(p.localName==="footnoteReference"||p.localName==="endnoteReference")&&e.footnotes++;f&&(d&&(f=`<em>${f}</em>`),u&&(f=`<strong>${f}</strong>`)),r+=h,n+=f}else s(a)}};return s(t),{text:r.replace(/[ \t]+/g," ").trim(),html:n.trim()}}async function FHt(t){var p,m,g;let e;try{e=await NG.loadAsync(t)}catch{throw new Error("This file could not be opened. It may be damaged or password-protected.")}const r=await((p=e.file("word/document.xml"))==null?void 0:p.async("string"));if(!r)throw new Error("This does not look like a valid Word document (word/document.xml missing).");const n=$Ht(await((m=e.file("word/styles.xml"))==null?void 0:m.async("string"))??null),s=N2e(await((g=e.file("docProps/core.xml"))==null?void 0:g.async("string"))??null),i=CA(r),a=Hc(i.documentElement).find(y=>y.localName==="body");if(!a)throw new Error("The Word document has no body.");const l={images:0,footnotes:0,tables:0},c=[],u=y=>{const x=Vc(y,"pPr"),v=Sa(Vc(x,"pStyle"),"val"),b=v?n.get(v):void 0,w=Sa(Vc(x,"outlineLvl"),"val");let j=(b==null?void 0:b.level)??null;j==null&&w!=null&&Number(w)<9&&(j=Number(w)+1);const{text:N,html:C}=Oce(y,l);N&&(b!=null&&b.isTitle?c.push({kind:"title",text:N}):j!=null?c.push({kind:"heading",level:j,text:N,source:"style"}):c.push({kind:"paragraph",text:N,html:`<p>${C}</p>`}))},d=y=>{l.tables++;const x=Hc(y).filter(j=>j.localName==="tr"),v=[],b=x.map(j=>{const N=Hc(j).filter(C=>C.localName==="tc").map(C=>{const A=Hc(C).filter(E=>E.localName==="p").map(E=>Oce(E,l));return{text:A.map(E=>E.text).join(" "),html:A.map(E=>E.html).join("<br>")}});return v.push(N.map(C=>C.text).join(" | ")),`<tr>${N.map(C=>`<td>${C.html}</td>`).join("")}</tr>`}),w=v.join(`
`).trim();w&&c.push({kind:"paragraph",text:w,html:`<table><tbody>${b.join("")}</tbody></table>`})},h=y=>{for(const x of Hc(y))if(x.localName==="p")u(x);else if(x.localName==="tbl")d(x);else if(x.localName==="sdt"){const v=x.getElementsByTagName("*");if(Array.from(v).some(j=>j.localName==="docPartGallery"&&/table of contents/i.test(Sa(j,"val")??"")))continue;const w=Vc(x,"sdtContent");w&&h(w)}else(x.localName==="ins"||x.localName==="customXml")&&h(x)};h(a);const f=[];return l.images&&f.push(`${l.images} image(s) were skipped.`),l.footnotes&&f.push(`${l.footnotes} footnote reference(s) were skipped.`),l.tables&&f.push(`${l.tables} table(s) were imported as simple tables.`),{blocks:c,metaTitle:s,warnings:f}}function w6(t,e){let r="",n="";const s=i=>{i.childNodes.forEach(a=>{if(a.nodeType===3){r+=a.textContent??"",n+=nM(a.textContent??"");return}if(a.nodeType!==1)return;const l=a;switch(l.localName){case"s":{const c=Number(Sa(l,"c")??"1");r+=" ".repeat(c),n+=" ";break}case"tab":r+="	",n+=" ";break;case"line-break":r+=`
`,n+="<br>";break;case"note":e.footnotes++;break;case"frame":case"image":e.images++;break;case"tracked-changes":case"bookmark":case"soft-page-break":break;default:s(l)}})};return s(t),{text:r.replace(/[ \t]+/g," ").trim(),html:n.trim()}}const BHt=/^(?:heading|überschrift|titre|titolo|título|encabezado)[ _]*(?:_20_)?(\d)$/i;function zHt(t){const e=new Map;t.forEach(n=>{const s=CA(n);Array.from(s.getElementsByTagName("*")).filter(i=>i.localName==="style"&&Sa(i,"family")==="paragraph").forEach(i=>{const a=Sa(i,"name");if(!a)return;const l=Sa(i,"default-outline-level");e.set(a,{display:Sa(i,"display-name")??a.replace(/_20_/g," "),parent:Sa(i,"parent-style-name"),outline:l&&Number(l)>0?Number(l):null})})});const r=(n,s=0)=>{const i=e.get(n),a=((i==null?void 0:i.display)??n.replace(/_20_/g," ")).trim(),l=a.match(BHt);return l?{level:Number(l[1]),isTitle:!1}:/^title$/i.test(a)?{level:null,isTitle:!0}:i!=null&&i.outline?{level:i.outline,isTitle:!1}:i!=null&&i.parent&&s<8?r(i.parent,s+1):{level:null,isTitle:!1}};return r}async function UHt(t){var p,m,g;let e;try{e=await NG.loadAsync(t)}catch{throw new Error("This file could not be opened. It may be damaged or password-protected.")}if(e.file("META-INF/manifest.xml")&&(await e.file("META-INF/manifest.xml").async("string")).includes("encryption-data"))throw new Error("This document is password-protected. Please remove the password and try again.");const r=await((p=e.file("content.xml"))==null?void 0:p.async("string"));if(!r)throw new Error("This does not look like a valid ODT document (content.xml missing).");const n=N2e(await((m=e.file("meta.xml"))==null?void 0:m.async("string"))??null),s=await((g=e.file("styles.xml"))==null?void 0:g.async("string"))??null,i=zHt([s,r].filter(Boolean)),a=CA(r),c=Array.from(a.getElementsByTagName("*")).find(y=>{var x;return y.localName==="text"&&((x=y.parentElement)==null?void 0:x.localName)==="body"});if(!c)throw new Error("The ODT document has no text body.");const u={images:0,footnotes:0,tables:0},d=[],h=y=>{for(const x of Hc(y)){const v=x.localName;if(v==="h"){const b=Number(Sa(x,"outline-level")??"1")||1,{text:w}=w6(x,u);w&&d.push({kind:"heading",level:b,text:w,source:"style"})}else if(v==="p"){const b=Sa(x,"style-name")??"",{text:w,html:j}=w6(x,u);if(!w)continue;const N=b?i(b):{level:null,isTitle:!1};N.isTitle?d.push({kind:"title",text:w}):N.level!=null?d.push({kind:"heading",level:N.level,text:w,source:"style"}):d.push({kind:"paragraph",text:w,html:`<p>${j}</p>`})}else if(v==="table"){u.tables++;const b=Array.from(x.getElementsByTagName("*")).filter(C=>C.localName==="table-row"),w=[],j=b.map(C=>{const A=Hc(C).filter(E=>E.localName==="table-cell").map(E=>w6(E,u));return w.push(A.map(E=>E.text).join(" | ")),`<tr>${A.map(E=>`<td>${E.html}</td>`).join("")}</tr>`}),N=w.join(`
`).trim();N&&d.push({kind:"paragraph",text:N,html:`<table><tbody>${j.join("")}</tbody></table>`})}else{if(v==="table-of-content"||v==="sequence-decls"||v==="tracked-changes")continue;h(x)}}};h(c);const f=[];return u.images&&f.push(`${u.images} image(s) were skipped.`),u.footnotes&&f.push(`${u.footnotes} footnote(s) were skipped.`),u.tables&&f.push(`${u.tables} table(s) were imported as simple tables.`),{blocks:d,metaTitle:n,warnings:f}}const HHt=/^(\d{1,2})((?:\.\d{1,2}){0,2})\.?\s+(\S.*)$/,WHt=/^(references?|reference list|bibliography|works cited|literatur(?:verzeichnis)?|quellen(?:verzeichnis)?|literatur- und quellenverzeichnis|quellen- und literaturverzeichnis|bibliographie|referencias|bibliograf[ií]a)$/i,k2e=t=>t.replace(/^(?:chapter|kapitel)?\s*\d{1,2}(?:\.\d{1,2})*\.?\s+/i,"").trim()||t.trim(),C2e=t=>WHt.test(k2e(t).toLowerCase());let VHt=0;const qHt=()=>`imp-${Date.now().toString(36)}-${(VHt++).toString(36)}`;function GHt(t){let e=0;return{blocks:t.map(n=>{if(n.kind!=="paragraph"||n.html.startsWith("<table"))return n;const s=n.text.trim();if(s.length>120||/[.:;,]$/.test(s)||s.includes(`
`))return n;if(C2e(s))return{kind:"heading",level:1,text:s,source:"numbering"};const i=s.match(HHt);if(!i||!new RegExp("^\\p{L}","u").test(i[3]))return n;const a=1+(i[2]?i[2].split(".").length-1:0);return e++,{kind:"heading",level:a,text:s,source:"numbering"}}),found:e}}function KHt(t,e){let r=t.blocks;const n=[...t.warnings];let s="styles";if(r.filter(v=>v.kind==="heading").length===0){const v=GHt(r);v.found>=2?(r=v.blocks,s="numbering",n.push("No Word heading styles found — chapters were detected from numbered headings.")):s="none"}const a=r.filter(v=>v.kind==="heading").map(v=>v.level),l=a.length?Math.min(...a):1,c=r.find(v=>v.kind==="title"),u=[],d={html:"",text:""};let h=null,f=null,p=0,m=null;const g=(v,b,w)=>{v.html+=b,v.text=v.text?`${v.text}

${w}`:w};for(const v of r){if(v.kind==="title")continue;if(v.kind==="heading"){const w=v.level-l+1;if(f!=null&&w>f){g(h,`<p><strong>${nM(v.text)}</strong></p>`,v.text);continue}if(f=null,C2e(v.text)){h=h??{html:"",text:""},f=w;continue}if(w>3){const j=u[u.length-1]??d;g(j,`<p><strong>${nM(v.text)}</strong></p>`,v.text),p++;continue}u.push({tempId:qHt(),level:w,title:k2e(v.text),html:"",text:""});continue}if(f!=null){g(h,v.html,v.text);continue}const b=u[u.length-1];b?g(b,v.html,v.text):(!m&&v.text.length<200&&(m=v.text),g(d,v.html,v.text))}p&&n.push(`${p} heading(s) below level 3 were merged into their parent as bold text.`),u.length&&!u.some(v=>v.level===1)&&(u[0].level=1),u.filter(v=>v.level===1).length>40&&n.push("More than 40 chapters were detected — please review the structure.");const y=e.fileName.replace(/\.(docx|odt)$/i,"").replace(/[_-]+/g," ").trim(),x=(t.metaTitle||(c==null?void 0:c.text)||m||y||"Imported thesis").slice(0,300);return{...e,title:x,items:u,unassignedContent:d.text&&d.text.trim()!==x.trim()?d:null,references:h,detection:s,warnings:n}}const YHt=20*1024*1024;function E2e(t){const e=t.toLowerCase().split(".").pop();return e==="docx"?"docx":e==="odt"?"odt":null}function XHt(t){const e=t.name.toLowerCase().split(".").pop();return e==="doc"?"Legacy .doc files are not supported. Please save the file as .docx and try again.":e==="pdf"?"PDF import is not available yet. Please upload a .docx or .odt file.":E2e(t.name)?t.size===0?"This file is empty.":t.size>YHt?"The file is larger than 20 MB.":null:"Please upload a .docx or .odt file."}async function QHt(t,e){const r=E2e(e.fileName);if(!r)throw new Error("Unsupported file type.");const n=r==="docx"?await FHt(t):await UHt(t);if(n.blocks.length===0)throw new Error("No text was found in this document.");return KHt(n,{...e,format:r})}const ZHt=t=>{const e=t.toLowerCase();return/introduction|einleitung/.test(e)?"introduction":/method|research design|forschungsdesign/.test(e)?"methodology":/results|findings|ergebnisse|befunde/.test(e)?"results":/discussion|diskussion/.test(e)?"discussion":/conclusion|fazit|schluss|ausblick/.test(e)?"conclusion":/theor|background|literature review|grundlagen|forschungsstand|hintergrund/.test(e)?"theory":"other"};function JHt(t,e){var s;const r=[];e&&((s=t.unassignedContent)!=null&&s.text)&&r.push({title:"Preliminary content",kind:"other",sections:[{title:"Preliminary content",...t.unassignedContent,children:[]}]});const n=()=>(r.length||r.push({title:"Untitled chapter",kind:"other",sections:[]}),r[r.length-1]);return t.items.forEach(i=>{const a=i.title.trim()||"Untitled";if(i.level===1){const l={title:a,kind:ZHt(a),sections:[]};i.text.trim()&&l.sections.push({title:a,html:i.html,text:i.text,children:[]}),r.push(l)}else if(i.level===2)n().sections.push({title:a,html:i.html,text:i.text,children:[]});else{const l=n(),c=l.sections[l.sections.length-1];c?c.children.push({title:a,html:i.html,text:i.text}):l.sections.push({title:a,html:i.html,text:i.text,children:[]})}}),r}async function e7t(t){var d;const{userId:e,draft:r,includeUnassigned:n,language:s,degree:i}=t,a=JHt(r,n);if(!a.length&&!r.references)throw new Error("Nothing to import.");const{data:l,error:c}=await pe.from("theses").insert([{user_id:e,title:r.title.trim()||"Imported thesis",citation_style:"APA7",show_page_numbers:!0,language:s,degree:i}]).select("id").single();if(c||!l)throw c??new Error("Thesis creation failed");const u=l.id;try{const{error:h}=await pe.rpc("seed_default_chapters",{p_thesis:u});if(h)throw h;const{data:f,error:p}=await pe.from("chapters").select("id, title, order_index").eq("thesis_id",u).order("order_index",{ascending:!0});if(p||!f)throw p??new Error("Failed to load chapters");const m=f.find(w=>/^(references|literaturverzeichnis|bibliography)$/i.test(w.title.trim()))??f.find(w=>w.order_index===70)??f[f.length-1],g=f.filter(w=>w.id!==(m==null?void 0:m.id)),{error:y}=await pe.from("sections").delete().in("chapter_id",f.map(w=>w.id));if(y)throw y;const x=[];for(let w=0;w<a.length;w++){const j=a[w],N=(w+1)*10;if(w<g.length){const{error:C}=await pe.from("chapters").update({title:j.title,kind:j.kind,order_index:N}).eq("id",g[w].id);if(C)throw C;x.push(g[w].id)}else{const{data:C,error:A}=await pe.from("chapters").insert({thesis_id:u,title:j.title,kind:j.kind,status:"open",progress:0,order_index:N}).select("id").single();if(A||!C)throw A??new Error("Failed to insert chapter");x.push(C.id)}}const v=g.slice(a.length).map(w=>w.id);if(v.length){const{error:w}=await pe.from("chapters").delete().in("id",v);if(w)throw w}if(m){const{error:w}=await pe.from("chapters").update({title:"References",kind:"references",order_index:(a.length+1)*10}).eq("id",m.id);if(w)throw w}for(let w=0;w<a.length;w++){const j=a[w];if(!j.sections.length)continue;const N=j.sections.map(($,T)=>({chapter_id:x[w],title:$.title,content:$.text,content_rich:$.html,order_index:(T+1)*10,status:"open",type:"other"})),{data:C,error:A}=await pe.from("sections").insert(N).select("id, order_index");if(A||!C)throw A??new Error("Failed to insert sections");const E=new Map(C.map($=>[$.order_index,$.id])),O=j.sections.flatMap(($,T)=>$.children.map((M,k)=>({chapter_id:x[w],parent_section_id:E.get((T+1)*10),title:M.title,content:M.text,content_rich:M.html,order_index:(k+1)*10,status:"open",type:"other"})));if(O.length){const{error:$}=await pe.from("sections").insert(O);if($)throw $}}if(m&&((d=r.references)!=null&&d.text)){const{error:w}=await pe.from("sections").insert({chapter_id:m.id,title:"References",content:r.references.text,content_rich:r.references.html,order_index:10,status:"open",type:"other"});if(w)throw w}const{error:b}=await pe.rpc("normalize_chapter_shares",{p_thesis:u});if(b)throw b;return u}catch(h){throw await pe.from("theses").delete().eq("id",u),h}}const GP=t=>t.trim()?t.trim().split(/\s+/).length:0,Mce={1:"Chapter",2:"Section",3:"Subsection"};function t7t({items:t,onChange:e}){const r=[];let n=0,s=0,i=0;t.forEach(u=>{u.level===1?(n++,s=0,i=0,r.push(`${n}`)):u.level===2?(s++,i=0,r.push(`${Math.max(n,1)}.${s}`)):(i++,r.push(`${Math.max(n,1)}.${Math.max(s,1)}.${i}`))});const a=(u,d)=>e(t.map((h,f)=>f===u?{...h,...d}:h)),l=u=>{const d=t[u-1],h=t[u],f={...d,html:`${d.html}<p><strong>${h.title}</strong></p>${h.html}`,text:[d.text,h.title,h.text].filter(Boolean).join(`

`)};e(t.flatMap((p,m)=>m===u-1?[f]:m===u?[]:[p]))},c=u=>e(t.filter((d,h)=>h!==u));return t.length?o.jsx("ul",{className:"divide-y divide-border/70 rounded-xl border border-border/70",children:t.map((u,d)=>{const h=GP(u.text);return o.jsxs("li",{className:Pe("flex flex-wrap items-center gap-2 px-3 py-2.5",u.level===1&&"bg-muted/40"),style:{paddingLeft:`${.75+(u.level-1)*1.5}rem`},children:[o.jsx("span",{className:"w-12 shrink-0 text-xs font-semibold tabular-nums text-primary",children:r[d]}),o.jsx(Ue,{value:u.title,onChange:f=>a(d,{title:f.target.value}),"aria-label":`${Mce[u.level]} title`,className:Pe("h-8 min-w-[180px] flex-1",u.level===1&&"font-semibold")}),o.jsxs("span",{className:"w-24 shrink-0 text-right text-xs text-muted-foreground",children:[Mce[u.level]," · ",h," w"]}),o.jsxs("div",{className:"flex shrink-0 items-center",children:[o.jsx(me,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8",disabled:u.level===1,onClick:()=>a(d,{level:u.level-1}),title:"Move one level up","aria-label":"Move one level up",children:o.jsx(Ghe,{className:"h-4 w-4"})}),o.jsx(me,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8",disabled:u.level===3||d===0,onClick:()=>a(d,{level:u.level+1}),title:"Move one level down","aria-label":"Move one level down",children:o.jsx(AE,{className:"h-4 w-4"})}),o.jsx(me,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8",disabled:d===0,onClick:()=>l(d),title:"Merge into previous entry","aria-label":"Merge into previous entry",children:o.jsx(OOe,{className:"h-4 w-4 rotate-180"})}),o.jsx(me,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>c(d),title:"Remove entry and its text","aria-label":"Remove entry and its text",children:o.jsx(Pi,{className:"h-4 w-4"})})]})]},u.tempId)})}):o.jsx("p",{className:"rounded-xl border border-dashed border-border p-6 text-sm text-muted-foreground",children:"No chapters left."})}async function r7t(t,e){const r={added:0,alreadyInLibrary:0,skipped:0,failed:0};if(!e.length)return r;const n=new Set,s=new Set;try{const{data:i}=await pe.from("documents").select("doi, isbn").eq("user_id",t).limit(5e3);(i??[]).forEach(a=>{a.doi&&n.add(Nk(a.doi)),a.isbn&&s.add(QL(a.isbn))})}catch(i){return console.warn("[thesis-import] library lookup failed, skipping enrichment",i),r.skipped=e.length,r}for(const i of e){if(i.doi&&n.has(i.doi)||i.isbn&&s.has(i.isbn)){r.alreadyInLibrary++;continue}if(!i.doi){r.skipped++;continue}try{const{data:a,error:l}=await pe.functions.invoke("literature_discovery",{body:{action:"search",query:i.doi}});if(l)throw l;const u=((a==null?void 0:a.results)??(a==null?void 0:a.works)??(a==null?void 0:a.items)??[]).find(h=>(h==null?void 0:h.doi)&&Nk(String(h.doi))===i.doi);if(!u){r.skipped++;continue}const{error:d}=await pe.functions.invoke("literature_discovery",{body:{action:"claim",work:u}});if(d)throw d;n.add(i.doi),r.added++}catch(a){console.warn("[thesis-import] reference enrichment failed for",i.doi,a),r.failed++}}return r}const n7t=t=>t.replace(/\.[^.]+$/,"").normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase().slice(0,80)||"thesis";function s7t({onBack:t}){var O,$;const{user:e,researchProfile:r}=Ht(),{toast:n}=Bn(),s=Or(),i=S.useRef(null),[a,l]=S.useState("upload"),[c,u]=S.useState(null),[d,h]=S.useState(!1),[f,p]=S.useState(null),[m,g]=S.useState(!1),y=async T=>{T&&await pe.storage.from("documents").remove([T])},x=async T=>{if(!e)return;u(null);const M=XHt(T);if(M){u(M);return}l("analyzing");const k=T.name.toLowerCase().endsWith(".odt")?"odt":"docx",D=`${e.id}/thesis-imports/${Date.now()}-${n7t(T.name)}.${k}`;try{const{error:K}=await pe.storage.from("documents").upload(D,T,{cacheControl:"3600",upsert:!1,contentType:T.type||void 0});if(K)throw new Error(`Upload failed: ${K.message}`);try{const H=await QHt(await T.arrayBuffer(),{fileName:T.name,sourcePath:D});p(H),g(!1),l("review")}catch(H){throw await y(D),H}}catch(K){console.error("[thesis-import] analyze failed:",K),u(K instanceof Error?K.message:"The document could not be analyzed."),l("upload")}},v=async()=>{await y(f==null?void 0:f.sourcePath),p(null),l("upload")},b=()=>{f!=null&&f.unassignedContent&&p({...f,items:[{tempId:`imp-single-${Date.now()}`,level:1,title:f.title||"Imported text",...f.unassignedContent},...f.items],unassignedContent:null})},w=async()=>{if(!e||!f)return;l("creating");try{await e7t({userId:e.id,draft:f,includeUnassigned:m,language:XL(r==null?void 0:r.preferred_language,"en"),degree:(r==null?void 0:r.degree_type)==="master"?"master":"bachelor"})}catch(M){console.error("[thesis-import] commit failed:",M),n({title:"Import failed",description:"The thesis could not be created. Nothing was saved.",variant:"destructive"}),l("review");return}let T=0;j.length&&(T=(await r7t(e.id,j)).added),n({title:"Thesis imported",description:T?`Your thesis structure is ready. ${T} reference${T===1?"":"s"} added to My Library.`:"Your thesis structure is ready to edit."}),s("/my-thesis-2")},j=S.useMemo(()=>{var T;return HAt(((T=f==null?void 0:f.references)==null?void 0:T.text)??"")},[(O=f==null?void 0:f.references)==null?void 0:O.text]),N=j.length?WAt(j):null,C=(f==null?void 0:f.items.filter(T=>T.level===1).length)??0,A=(f==null?void 0:f.items.filter(T=>T.level>1).length)??0,E=((f==null?void 0:f.items.reduce((T,M)=>T+GP(M.text),0))??0)+(m?GP((($=f==null?void 0:f.unassignedContent)==null?void 0:$.text)??""):0);return o.jsx("section",{className:"py-4 md:py-8",children:o.jsxs("div",{className:"mx-auto max-w-4xl",children:[o.jsxs("button",{type:"button",onClick:a==="review"?v:t,disabled:a==="analyzing"||a==="creating",className:"mb-6 inline-flex items-center gap-2 text-sm font-medium text-muted-foreground transition hover:text-foreground disabled:opacity-50",children:[o.jsx(Kg,{className:"h-4 w-4"}),a==="review"?"Upload a different file":"Choose another start"]}),o.jsx("div",{className:"mb-6 grid grid-cols-4 gap-3",children:["Upload","Analyze","Review","Create"].map((T,M)=>{const k={upload:0,analyzing:1,review:2,creating:3}[a];return o.jsxs("div",{className:Pe("rounded-xl border p-3 text-sm",M===k?"border-primary/40 bg-primary/[0.06]":"border-border/70 bg-card",M<k&&"text-muted-foreground"),children:[o.jsxs("div",{className:"text-xs font-semibold text-primary",children:["0",M+1]}),o.jsx("div",{className:"mt-1 font-medium text-foreground",children:T})]},T)})}),(a==="upload"||a==="analyzing")&&o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-7 shadow-sm md:p-9",children:[o.jsx("h1",{className:"text-2xl font-bold tracking-tight text-foreground md:text-3xl",children:"Import an existing thesis"}),o.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-muted-foreground",children:"Upload a Word (.docx) or OpenDocument (.odt) file. Academly detects chapters and sections from your headings. You review everything before the thesis is created."}),o.jsx("div",{onDragOver:T=>{T.preventDefault(),h(!0)},onDragLeave:()=>h(!1),onDrop:T=>{var k;T.preventDefault(),h(!1);const M=(k=T.dataTransfer.files)==null?void 0:k[0];M&&a==="upload"&&x(M)},className:Pe("mt-7 flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-12 text-center transition",d?"border-primary bg-primary/[0.04]":"border-border"),children:a==="analyzing"?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"h-8 w-8 animate-spin text-primary"}),o.jsx("p",{className:"mt-4 text-sm font-medium text-foreground",children:"Uploading and analyzing your document..."})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(BW,{className:"h-6 w-6"})}),o.jsx("p",{className:"mt-4 text-sm font-medium text-foreground",children:"Drag your file here"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"DOCX or ODT, up to 20 MB"}),o.jsxs(me,{type:"button",className:"mt-5",onClick:()=>{var T;return(T=i.current)==null?void 0:T.click()},children:[o.jsx(cf,{className:"mr-2 h-4 w-4"}),"Browse"]}),o.jsx("input",{ref:i,type:"file",accept:".docx,.odt,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.oasis.opendocument.text",className:"hidden",onChange:T=>{var k;const M=(k=T.target.files)==null?void 0:k[0];T.target.value="",M&&x(M)}})]})}),c&&o.jsxs("div",{className:"mt-5 flex items-start gap-2 rounded-xl border border-destructive/30 bg-destructive/5 p-4 text-sm text-destructive",children:[o.jsx(af,{className:"mt-0.5 h-4 w-4 shrink-0"}),c]})]}),(a==="review"||a==="creating")&&f&&o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-6 shadow-sm md:p-8",children:[o.jsx("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:"Review the detected structure"}),o.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["From ",o.jsx("span",{className:"font-medium text-foreground",children:f.fileName})," · ",C," chapters ·"," ",A," sections · ",E.toLocaleString()," words · Citation style APA 7"]}),o.jsxs("div",{className:"mt-6 space-y-2",children:[o.jsx(Se,{htmlFor:"import-title",children:"Thesis title"}),o.jsx(Ue,{id:"import-title",value:f.title,onChange:T=>p({...f,title:T.target.value})})]}),f.warnings.length>0&&o.jsx("ul",{className:"mt-5 space-y-1 rounded-xl border border-border/70 bg-muted/40 p-4 text-xs text-muted-foreground",children:f.warnings.map(T=>o.jsxs("li",{children:["• ",T]},T))})]}),f.unassignedContent&&o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-6 shadow-sm",children:[o.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"font-semibold text-foreground",children:"Text before the first chapter"}),o.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[GP(f.unassignedContent.text).toLocaleString()," words, e.g. abstract or preface."]})]}),f.items.length>0?o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Qm,{id:"include-unassigned",checked:m,onCheckedChange:g}),o.jsx(Se,{htmlFor:"include-unassigned",children:"Include as first chapter"})]}):o.jsx(me,{type:"button",variant:"outline",onClick:b,children:"Import as one chapter"})]}),o.jsx("p",{className:"mt-3 line-clamp-4 whitespace-pre-line rounded-lg bg-muted/40 p-3 text-xs leading-5 text-muted-foreground",children:f.unassignedContent.text})]}),o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-6 shadow-sm",children:[o.jsx("h2",{className:"font-semibold text-foreground",children:"Chapters and sections"}),f.detection==="none"&&f.items.length===0?o.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"No headings were found in this document. You can import the whole text as one chapter above, or add heading styles (Heading 1, Heading 2) in Word and upload again."}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"mb-4 mt-1 text-sm text-muted-foreground",children:"Rename entries, change their level, merge them or remove them. Numbering is added automatically."}),o.jsx(t7t,{items:f.items,onChange:T=>p({...f,items:T})})]})]}),o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card p-6 shadow-sm",children:[o.jsx("h2",{className:"font-semibold text-foreground",children:"References"}),f.references?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Imported as text into the References chapter. These entries are not added to My Library and are not verified sources."}),o.jsx("p",{className:"mt-3 line-clamp-6 whitespace-pre-line rounded-lg bg-muted/40 p-3 text-xs leading-5 text-muted-foreground",children:f.references.text}),N&&N.total>0&&o.jsxs("div",{className:"mt-4 grid gap-2 text-sm sm:grid-cols-3",children:[o.jsxs("div",{className:"rounded-lg border border-border/70 p-3",children:[o.jsx("div",{className:"text-lg font-semibold text-foreground",children:N.total}),o.jsx("div",{className:"text-xs text-muted-foreground",children:"references detected"})]}),o.jsxs("div",{className:"rounded-lg border border-border/70 p-3",children:[o.jsx("div",{className:"text-lg font-semibold text-foreground",children:N.total-N.withoutStrongId}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:["with identifier (DOI ",N.doi," · PMID ",N.pmid," · ISBN ",N.isbn,")"]})]}),o.jsxs("div",{className:"rounded-lg border border-border/70 p-3",children:[o.jsx("div",{className:"text-lg font-semibold text-foreground",children:N.withoutStrongId}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:["without strong identifier",N.url?` · ${N.url} with URL`:""]})]}),o.jsx("p",{className:"text-xs text-muted-foreground sm:col-span-3",children:"After creating the thesis, references with a DOI that Academly can confirm are added to My Library. All other entries stay as text in the References chapter."})]})]}):o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"No reference list was detected."})]}),o.jsxs("div",{className:"flex justify-end gap-3",children:[o.jsx(me,{type:"button",variant:"outline",onClick:v,disabled:a==="creating",children:"Back"}),o.jsxs(me,{type:"button",onClick:w,disabled:a==="creating"||!f.title.trim()||f.items.length===0&&!(m&&f.unassignedContent),children:[a==="creating"&&o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Create thesis"]})]})]})]})})}const i7t=new Set(["fulltext_imported","metadata_only"]),j6=new Set(["pdf_extract_failed","failed"]),a7t={selected:"Selected",claiming:"Preparing import",downloading:"Downloading PDF",pdf_stored:"PDF downloaded",extracting:"Extracting full text",fulltext_imported:"Ready",metadata_only:"Metadata imported",pdf_extract_failed:"PDF extraction failed",failed:"Import failed"},k2={pending:{title:"Preparing literature search..."},planning:{title:"Preparing literature search..."},searching:{title:"Searching academic literature...",description:"Looking for relevant open-access sources in German and English."},selecting:{title:"Selecting the most relevant sources..."},importing:{title:"Importing literature..."},completed:{title:"Literature ready"},failed:{title:"Literature import failed"}},o7t=t=>a7t[t]??t,A2e=t=>t.trim().toLowerCase().replace(/^\d+(?:\.\d+)*\.?\s*/,"").replace(/\s+/g," "),D7=t=>{const e=A2e(t);return["references","reference list","bibliography","literaturverzeichnis","quellenverzeichnis"].includes(e)},l7t=t=>{const e=A2e(t);return e.includes("introduction")||e.includes("einleitung")?"introduction":e.includes("methodology")||e.includes("methodik")||e.includes("methods")||e.includes("methoden")||e.includes("research design")||e.includes("forschungsdesign")?"methodology":e.includes("results")||e.includes("findings")||e.includes("ergebnisse")||e.includes("befunde")?"results":e.includes("discussion")||e.includes("diskussion")?"discussion":e.includes("conclusion")||e.includes("summary")||e.includes("final remarks")||e.includes("fazit")||e.includes("schlussfolger")?"conclusion":D7(t)?"references":e.includes("literature review")||e.includes("literaturüberblick")||e.includes("theoretical")||e.includes("theory")||e.includes("theoretisch")||e.includes("conceptual")||e.includes("framework")||e.includes("grundlagen")||e.includes("barrier")||e.includes("understanding")?"theory":"other"},c7t=t=>["introduction","theory","methodology","results","discussion","conclusion","other"].includes(t);function u7t({onClose:t}){const{user:e,researchProfile:r}=Ht(),{toast:n}=Bn(),s=Or(),i=XL(r==null?void 0:r.preferred_language,"en"),[a,l]=S.useState(null),[c,u]=S.useState(1),[d,h]=S.useState({p1:!1,p2:!1,p3:!1}),[f,p]=S.useState(""),[m,g]=S.useState(""),[y,x]=S.useState(!1),[v,b]=S.useState([]),[w,j]=S.useState(null),[N,C]=S.useState(!1),[A,E]=S.useState(null),[O,$]=S.useState("ai"),[T,M]=S.useState(null),[k,D]=S.useState(!1),[K,H]=S.useState(!1),[ee,V]=S.useState(null),[B,z]=S.useState([]),[F,G]=S.useState(null),[Q,ie]=S.useState(null),se=S.useRef(!1),[q,L]=S.useState("APA7"),[Z,J]=S.useState(!0),[W,X]=S.useState(!1),[he,P]=S.useState(""),oe=async()=>{if(f.trim()){x(!0),b([]),j(null);try{const{data:xe,error:_e}=await pe.functions.invoke("topic_explorer",{body:{action:"suggest",topic:f.trim(),context:m.trim()||void 0,language:i}});if(_e)throw _e;const ke=((xe==null?void 0:xe.suggestions)??[]).slice(0,3);b(ke)}catch(xe){console.error("[wizard] suggest failed:",xe),n({title:"Error",description:"Suggestions could not be loaded.",variant:"destructive"})}finally{x(!1)}}},Y=async()=>{if(w===null)return;const xe=v[w];C(!0);try{const{data:_e,error:ke}=await pe.functions.invoke("topic_explorer",{body:{action:"structure",selection:xe,topic:xe.title,context:m.trim()||void 0,save:!0,language:i}});if(ke)throw ke;const $e=(_e==null?void 0:_e.structure)??_e??{},Te={title:$e.title??xe.title,introduction:$e.introduction??"",problem:$e.problem??$e.problem_statement??"",objectives:$e.objectives??"",research_questions:$e.research_questions??xe.research_questions,method:$e.method??xe.method};E(Te),h(ot=>({...ot,p1:!0})),u(2)}catch(_e){console.error("[wizard] structure failed:",_e),n({title:"Error",description:"The structure could not be created.",variant:"destructive"})}finally{C(!1)}},R=async()=>{if(A){D(!0),M(null);try{const{data:{session:xe}}=await pe.auth.getSession(),ke=await(await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/topic_research_tools",{method:"POST",headers:{"Content-Type":"application/json",...xe!=null&&xe.access_token?{Authorization:`Bearer ${xe.access_token}`}:{}},body:JSON.stringify({action:"outline",title:A.title,research_questions:A.research_questions,language:i,topic_context:{introduction:A.introduction||void 0,problem_statement:A.problem||void 0,objectives:A.objectives||void 0}})})).json();if(ke!=null&&ke.error)throw new Error(ke.error);M(ke.outline??null)}catch(xe){console.error("[wizard] outline failed:",xe),n({title:"Fehler",description:"Outline konnte nicht generiert werden.",variant:"destructive"})}finally{D(!1)}}};S.useEffect(()=>{c===2&&O==="ai"&&A&&!T&&!k&&R()},[c,O,A]);const I=xe=>{$(xe),xe==="empty"&&M(null)},U=()=>{h(xe=>({...xe,p2:!0})),u(3)},re=S.useMemo(()=>Q?Q.completed_count+Q.failed_count:B.filter(xe=>i7t.has(xe.status)||j6.has(xe.status)).length,[Q,B]),ue=(Q==null?void 0:Q.target_count)??B.length,ae=S.useMemo(()=>ue>0?Math.round(re/ue*100):0,[re,ue]),ge=async()=>{if(!(!A||K)){V(null),z([]),ie(null),G(null),H(!0);try{const{data:xe,error:_e}=await pe.functions.invoke("literature_bootstrap",{body:{title:A.title,introduction:A.introduction,problem:A.problem,objectives:A.objectives,research_questions:A.research_questions,methodology:A.method,outline:T,language:i,target_count:3}});if(_e)throw _e;const ke=xe==null?void 0:xe.bootstrap_id;if(!ke)throw new Error("No bootstrap_id returned");G(String(ke))}catch(xe){console.error("[wizard] literature_bootstrap failed:",xe),V("Literature search failed. You can continue anyway or try again.")}finally{H(!1)}}};S.useEffect(()=>{c===3&&A&&!se.current&&(se.current=!0,ge())},[c,A]),S.useEffect(()=>{if(!F)return;let xe=!1,_e;const ke=async()=>{const[$e,Te]=await Promise.all([pe.from("literature_bootstrap_jobs").select("id,status,current_stage,target_count,found_count,completed_count,failed_count,error_message").eq("id",F).maybeSingle(),pe.from("literature_bootstrap_items").select("id,bootstrap_id,document_id,title,status,sort_order,error_message").eq("bootstrap_id",F).order("sort_order",{ascending:!0})]);if(!xe){if($e.data){const ot=$e.data;ie(ot),(ot.status==="completed"||ot.status==="failed")&&_e&&clearInterval(_e)}Te.data&&z(Te.data.map(ot=>({id:String(ot.id),document_id:ot.document_id??null,title:ot.title??"Untitled source",status:ot.status??"selected",sort_order:ot.sort_order??0,error_message:ot.error_message??null})))}};return ke(),_e=setInterval(ke,2e3),()=>{xe=!0,_e&&clearInterval(_e)}},[F]);const we=()=>{h(xe=>({...xe,p3:!0})),u(4)},ce=async()=>{var xe,_e;if(!(!e||!A)){X(!0);try{P("Thesis is being created...");const ke=(r==null?void 0:r.degree_type)==="master"?"master":"bachelor",{data:$e,error:Te}=await pe.from("theses").insert([{user_id:e.id,title:A.title,citation_style:q,show_page_numbers:Z,language:i,degree:ke}]).select("id").single();if(Te||!$e)throw Te??new Error("Thesis creation failed");const ot=$e.id;P("Kapitel werden angelegt...");const{error:wt}=await pe.rpc("seed_default_chapters",{p_thesis:ot});if(wt)throw wt;const{data:Ct,error:pr}=await pe.from("chapters").select("id, title, kind, order_index").eq("thesis_id",ot).order("order_index",{ascending:!0});if(pr||!Ct)throw pr??new Error("Failed to load seeded chapters");const Kt=Ct.find(Ye=>D7(Ye.title))??Ct.find(Ye=>Ye.order_index===70);if(!Kt)throw new Error("Seeded References chapter not found");const{error:Re}=await pe.from("chapters").update({title:"References",kind:"references"}).eq("id",Kt.id);if(Re)throw Re;const ye=Ct.filter(Ye=>Ye.id!==Kt.id);let Ne=[];if(O==="ai"&&((xe=T==null?void 0:T.chapters)!=null&&xe.length)){P("Outline wird übernommen...");const Ye=T.chapters.filter(zt=>!D7(zt.title));for(let zt=0;zt<Ye.length;zt++){const Xt=Ye[zt],Mr=c7t(Xt.kind)?Xt.kind:l7t(Xt.title);let ur;if(zt<ye.length){ur=ye[zt].id;const{error:Kr}=await pe.from("chapters").update({title:Xt.title,kind:Mr,order_index:(zt+1)*10}).eq("id",ur);if(Kr)throw Kr}else{const{data:Kr,error:ct}=await pe.from("chapters").insert({thesis_id:ot,title:Xt.title,kind:Mr,status:"open",progress:0,order_index:(zt+1)*10}).select("id").single();if(ct||!Kr)throw ct??new Error("Failed to insert chapter");ur=Kr.id}Ne.push({id:ur,title:Xt.title,kind:Mr});const Fr=Xt.subchapters??[];if(Fr.length>0){const Kr=Fr.map((xn,Qn)=>({chapter_id:ur,title:xn.title,content:"",content_rich:"",order_index:(Qn+1)*10,status:"open",type:"other"})),{error:ct}=await pe.from("sections").insert(Kr);if(ct)throw ct}}const it=ye.slice(Ye.length);if(it.length>0){const{error:zt}=await pe.from("chapters").delete().in("id",it.map(Xt=>Xt.id));if(zt)throw zt}}else{const Ye={10:"introduction",20:"theory",30:"methodology",40:"results",50:"discussion",60:"conclusion"};for(const it of ye){const zt=Ye[it.order_index]??"other",{error:Xt}=await pe.from("chapters").update({kind:zt}).eq("id",it.id);if(Xt)throw Xt;Ne.push({id:it.id,title:it.title,kind:zt})}}const Ce=(Ne.length+1)*10,{error:Fe}=await pe.from("chapters").update({title:"References",kind:"references",order_index:Ce}).eq("id",Kt.id);if(Fe)throw Fe;P("Inhalte werden eingefügt...");const{error:yt}=await pe.rpc("normalize_chapter_shares",{p_thesis:ot});if(yt)throw yt;const He=Ne.find(Ye=>Ye.kind==="introduction")??Ne[0];if(He){const{data:Ye,error:it}=await pe.from("sections").select("id, order_index").eq("chapter_id",He.id).order("order_index",{ascending:!0});if(it)throw it;const zt=(_e=A.research_questions)!=null&&_e.length?`Research Questions

${A.research_questions.map((ur,Fr)=>`${Fr+1}. ${ur}`).join(`
`)}`:"",Xt=[A.objectives,zt].filter(Boolean).join(`

`),Mr=[[A.introduction,A.problem].filter(Boolean).join(`

`),Xt,""];for(let ur=0;ur<Math.min(3,(Ye==null?void 0:Ye.length)??0);ur++){const Fr=Ye[ur],Kr=Mr[ur]??"";if(!Kr)continue;const{error:ct}=await pe.from("sections").update({content:Kr,content_rich:`<p>${Kr}</p>`}).eq("id",Fr.id);if(ct)throw ct}}P("Fertig! ✓"),await new Promise(Ye=>setTimeout(Ye,500)),t==null||t(),s("/my-thesis-2")}catch(ke){console.error("[wizard] create failed:",ke),n({title:"Fehler",description:"Thesis konnte nicht erstellt werden.",variant:"destructive"}),X(!1),P("")}}},ne=[{n:1,label:"Topic"},{n:2,label:"Structure"},{n:3,label:"Literature"},{n:4,label:"Settings"}],fe=xe=>xe===1?!0:xe===2?d.p1:xe===3?d.p2:d.p3,be=()=>{t?t():s("/my-thesis-2")};return o.jsxs("div",{className:"relative pb-10",children:[a?a==="import"?o.jsx(s7t,{onBack:()=>l(null)}):o.jsxs("section",{className:"py-4 md:py-8",children:[o.jsxs("div",{className:"mb-6 flex items-start justify-between gap-4",children:[o.jsxs("button",{type:"button",onClick:()=>l(null),className:"inline-flex items-center gap-2 text-sm font-medium text-muted-foreground transition hover:text-foreground",children:[o.jsx(Kg,{className:"h-4 w-4"}),"Choose another start"]}),o.jsx("button",{type:"button",onClick:be,className:"text-sm font-medium text-muted-foreground transition hover:text-foreground",children:"Cancel"})]}),o.jsxs("div",{className:"rounded-2xl border border-border/70 bg-card shadow-sm",children:[o.jsx("div",{className:"border-b border-border/60 px-5 py-5 md:px-7",children:o.jsx("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-3",children:ne.map((xe,_e)=>{const ke=xe.n===1?d.p1:xe.n===2?d.p2:xe.n===3?d.p3:!1,$e=c===xe.n,Te=fe(xe.n);return o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",disabled:!Te,onClick:()=>Te&&u(xe.n),className:Pe("flex items-center gap-2 rounded-xl px-3 py-2 text-sm font-medium transition",$e&&"bg-primary/10 text-primary",!$e&&Te&&"text-muted-foreground hover:bg-muted/40 hover:text-foreground",!Te&&"cursor-not-allowed text-muted-foreground/40"),children:[o.jsx("span",{className:Pe("flex h-6 w-6 items-center justify-center rounded-full text-[11px] font-semibold",ke||$e?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"),children:ke?o.jsx(kr,{className:"h-3.5 w-3.5"}):xe.n}),xe.label]}),_e<ne.length-1&&o.jsx("div",{className:"mx-1 hidden h-px w-6 bg-border md:block"})]},xe.n)})})}),o.jsxs("div",{className:"p-5 md:p-7",children:[c===1&&o.jsxs("div",{children:[o.jsxs("div",{className:"max-w-2xl",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-primary",children:"Step 1"}),o.jsx("h2",{className:"mt-2 text-2xl font-bold tracking-tight text-foreground",children:"Topic & research direction"}),o.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Start with your idea. Academly will turn it into three more concrete research directions."})]}),o.jsxs("div",{className:"mt-7 grid gap-5 lg:grid-cols-[0.78fr_1.22fr]",children:[o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"nt-title",children:["Title / Topic ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ue,{id:"nt-title",value:f,onChange:xe=>p(xe.target.value),placeholder:"e.g. AI in education",className:"h-11 rounded-xl"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"nt-context",children:"Context (optional)"}),o.jsx(lr,{id:"nt-context",value:m,onChange:xe=>g(xe.target.value),rows:6,placeholder:"Describe your research topic, context, target group or intended method.",className:"resize-none rounded-xl"})]}),o.jsx(me,{onClick:oe,disabled:!f.trim()||y,className:"h-11 w-full rounded-xl",children:y?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Sr,{className:"mr-2 h-4 w-4"}),"Generate suggestions"]})})]}),o.jsx("div",{children:y?o.jsx("div",{className:"space-y-3",children:[0,1,2].map(xe=>o.jsx(en,{className:"h-44 w-full rounded-2xl"},xe))}):v.length>0?o.jsx("div",{className:"space-y-3",children:v.map((xe,_e)=>{var ke;return o.jsxs("button",{type:"button",onClick:()=>j(_e),className:Pe("w-full rounded-2xl border p-5 text-left transition",w===_e?"border-primary bg-primary/[0.045] shadow-sm":"border-border/70 bg-background hover:border-primary/20"),children:[o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-[0.14em] text-primary",children:["Direction 0",_e+1]}),o.jsx("div",{className:"mt-2 text-base font-semibold leading-6 text-foreground",children:xe.title})]}),o.jsx("span",{className:Pe("mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full border",w===_e?"border-primary bg-primary text-primary-foreground":"border-border bg-background"),children:w===_e&&o.jsx(kr,{className:"h-3.5 w-3.5"})})]}),o.jsxs("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[(ke=xe.research_questions)!=null&&ke.length?o.jsxs("div",{className:"sm:col-span-2",children:[o.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Research questions"}),o.jsx("ul",{className:"mt-2 space-y-1.5",children:xe.research_questions.slice(0,3).map(($e,Te)=>o.jsxs("li",{className:"flex gap-2 text-xs leading-5 text-muted-foreground",children:[o.jsx("span",{className:"text-primary",children:"•"}),o.jsx("span",{children:$e})]},Te))})]}):null,xe.method&&o.jsxs("div",{children:[o.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Method"}),o.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:xe.method})]}),xe.relevance&&o.jsxs("div",{children:[o.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Why it matters"}),o.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:xe.relevance})]})]})]},_e)})}):o.jsx("div",{className:"flex min-h-[350px] items-center justify-center rounded-2xl border border-dashed border-border/80 bg-muted/[0.12] p-8 text-center",children:o.jsxs("div",{className:"max-w-sm",children:[o.jsx(nr,{className:"mx-auto h-6 w-6 text-primary"}),o.jsx("p",{className:"mt-3 text-sm font-medium text-foreground",children:"Your research directions will appear here."}),o.jsx("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Each suggestion can include research questions, a method and why the topic is relevant."})]})})})]}),o.jsx("div",{className:"mt-7 flex justify-end",children:o.jsxs(me,{onClick:Y,disabled:w===null||N,className:"h-11 rounded-xl px-6",children:[N&&o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Continue to structure",!N&&o.jsx(As,{className:"ml-2 h-4 w-4"})]})})]}),c===2&&o.jsxs("div",{children:[o.jsxs("div",{className:"max-w-2xl",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-primary",children:"Step 2"}),o.jsx("h2",{className:"mt-2 text-2xl font-bold tracking-tight text-foreground",children:"Structure & outline"}),o.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Choose whether Academly should prepare a chapter structure or start from the default blank thesis."})]}),o.jsx("div",{className:"mt-7 grid gap-4 md:grid-cols-2",children:[{key:"ai",title:"Generate outline with AI",sub:"Create chapters and subchapters based on your selected research direction."},{key:"empty",title:"Start a blank thesis",sub:"Use the standard thesis workspace without a generated outline."}].map(xe=>o.jsx("button",{type:"button",onClick:()=>I(xe.key),className:Pe("rounded-2xl border p-5 text-left transition",O===xe.key?"border-primary bg-primary/[0.045]":"border-border/70 bg-background hover:border-primary/20"),children:o.jsxs("div",{className:"flex items-start justify-between gap-4",children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-semibold text-foreground",children:xe.title}),o.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:xe.sub})]}),O===xe.key&&o.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-primary text-primary-foreground",children:o.jsx(kr,{className:"h-3.5 w-3.5"})})]})},xe.key))}),O==="ai"&&o.jsx("div",{className:"mt-6 rounded-2xl border border-border/70 bg-background p-5",children:k?o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Xe,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-foreground",children:"Generating your thesis outline..."}),o.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Creating chapters and subchapters based on your topic."})]})]}),o.jsx("div",{className:"space-y-2",children:[0,1,2,3,4,5].map(xe=>o.jsx(en,{className:"h-5 w-full rounded-lg"},xe))})]}):T?o.jsx("div",{className:"space-y-4",children:T.chapters.map((xe,_e)=>{var ke;return o.jsxs("div",{className:"border-b border-border/60 pb-4 last:border-0 last:pb-0",children:[o.jsxs("div",{className:"text-sm font-semibold text-foreground",children:[xe.number?`${xe.number} `:`${_e+1} `,xe.title]}),(ke=xe.subchapters)!=null&&ke.length?o.jsx("div",{className:"mt-2 space-y-1.5 pl-5",children:xe.subchapters.map(($e,Te)=>o.jsxs("div",{className:"text-xs leading-5 text-muted-foreground",children:[$e.number?`${$e.number} `:`${_e+1}.${Te+1} `,$e.title]},Te))}):null]},_e)})}):null}),o.jsxs("div",{className:"mt-7 flex items-center justify-between",children:[o.jsxs(me,{variant:"outline",onClick:()=>u(1),className:"rounded-xl",children:[o.jsx(Kg,{className:"mr-2 h-4 w-4"}),"Back"]}),o.jsxs(me,{onClick:U,className:"rounded-xl",children:["Continue to literature",o.jsx(As,{className:"ml-2 h-4 w-4"})]})]})]}),c===3&&o.jsxs("div",{children:[o.jsxs("div",{className:"max-w-2xl",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-primary",children:"Step 3"}),o.jsx("h2",{className:"mt-2 text-2xl font-bold tracking-tight text-foreground",children:"Starting literature"}),o.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Academly searches for a small set of suitable open-access sources and imports what it can into your library."})]}),o.jsxs("div",{className:"mt-7 rounded-2xl border border-border/70 bg-background p-5 md:p-6",children:[ee&&o.jsx("div",{className:"mb-5 rounded-xl border border-destructive/30 bg-destructive/[0.04] p-4 text-sm text-destructive",children:ee}),!F&&K&&o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx(Xe,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),o.jsx("div",{className:"text-sm font-medium text-foreground",children:"Starting literature search..."})]}),F&&o.jsxs("div",{className:"flex items-start gap-3",children:[(Q==null?void 0:Q.status)==="completed"?o.jsx(kr,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-500"}):(Q==null?void 0:Q.status)==="failed"?o.jsx(af,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}):o.jsx(Xe,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-primary"}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium text-foreground",children:(k2[(Q==null?void 0:Q.current_stage)??"pending"]??k2.pending).title}),(k2[(Q==null?void 0:Q.current_stage)??"pending"]??{}).description&&o.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:k2[Q.current_stage].description})]})]}),Q&&o.jsxs("div",{className:"mt-5 space-y-2",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-medium text-foreground",children:"Importing literature"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[re," of ",ue," processed"]})]}),o.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:o.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-500",style:{width:`${ae}%`}})})]}),B.length>0&&o.jsx("div",{className:"mt-5 divide-y divide-border/60",children:B.map(xe=>o.jsxs("div",{className:"flex items-start gap-3 py-3 first:pt-0 last:pb-0",children:[xe.status==="fulltext_imported"||xe.status==="metadata_only"?o.jsx(kr,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-500"}):j6.has(xe.status)?o.jsx(af,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}):xe.status==="selected"?o.jsx(sg,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}):o.jsx(Xe,{className:"mt-0.5 h-4 w-4 shrink-0 animate-spin text-muted-foreground"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:xe.title}),o.jsx("div",{className:Pe("mt-0.5 text-[11px]",j6.has(xe.status)?"text-destructive":"text-muted-foreground"),children:o7t(xe.status)})]})]},xe.id))}),(Q==null?void 0:Q.status)==="completed"&&B.length===0&&!ee&&o.jsx("p",{className:"mt-5 text-sm text-muted-foreground",children:"No suitable open-access sources could be imported automatically. You can continue and add literature later."})]}),o.jsxs("div",{className:"mt-7 flex flex-wrap items-center justify-between gap-3",children:[o.jsxs(me,{variant:"outline",onClick:()=>u(2),className:"rounded-xl",children:[o.jsx(Kg,{className:"mr-2 h-4 w-4"}),"Back"]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(me,{variant:"outline",onClick:()=>ge(),disabled:K,className:"rounded-xl",children:[K&&o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Search again"]}),o.jsxs(me,{onClick:we,className:"rounded-xl",children:["Continue to settings",o.jsx(As,{className:"ml-2 h-4 w-4"})]})]})]})]}),c===4&&o.jsxs("div",{children:[o.jsxs("div",{className:"max-w-2xl",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-primary",children:"Step 4"}),o.jsx("h2",{className:"mt-2 text-2xl font-bold tracking-tight text-foreground",children:"Thesis settings"}),o.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Review the citation behavior before creating your workspace."})]}),o.jsxs("div",{className:"mt-7 space-y-6",children:[o.jsxs("div",{children:[o.jsx(Se,{className:"text-sm font-semibold",children:"Citation style"}),o.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[o.jsx("button",{type:"button",onClick:()=>L("APA7"),className:"rounded-xl border border-primary bg-primary/[0.05] p-4 text-left",children:o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx("span",{className:"text-sm font-semibold text-foreground",children:"APA 7"}),o.jsx("span",{className:"rounded-lg bg-emerald-500/10 px-2 py-1 text-[10px] font-semibold text-emerald-600",children:"Available"})]})}),["Harvard","MLA","Chicago","IEEE"].map(xe=>o.jsx("div",{className:"rounded-xl border border-border/70 bg-muted/[0.16] p-4 opacity-70",children:o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:xe}),o.jsx("span",{className:"rounded-lg border border-border bg-background px-2 py-1 text-[10px] font-medium text-muted-foreground",children:"Coming soon"})]})},xe))]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl border border-border/70 bg-background p-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"nt-pages",className:"text-sm font-medium",children:"Display page numbers in citations"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Include page references where Academly has page-level evidence."})]}),o.jsx(Qm,{id:"nt-pages",checked:Z,onCheckedChange:J})]})]}),o.jsxs("div",{className:"mt-8 flex items-center justify-between",children:[o.jsxs(me,{variant:"outline",onClick:()=>u(3),className:"rounded-xl",children:[o.jsx(Kg,{className:"mr-2 h-4 w-4"}),"Back"]}),o.jsxs(me,{onClick:ce,disabled:W,className:"h-11 rounded-xl px-6",children:[W&&o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Thesis"]})]})]})]})]})]}):o.jsx("section",{className:"py-4 md:py-8",children:o.jsxs("div",{className:"mx-auto max-w-4xl",children:[o.jsxs("button",{type:"button",onClick:be,className:"mb-6 inline-flex items-center gap-2 text-sm font-medium text-muted-foreground transition hover:text-foreground",children:[o.jsx(Kg,{className:"h-4 w-4"}),"Back to My Thesis"]}),o.jsxs("div",{className:"max-w-2xl",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-primary",children:"New workspace"}),o.jsx("h1",{className:"mt-3 text-3xl font-bold tracking-tight text-foreground md:text-4xl",children:"How would you like to start?"}),o.jsx("p",{className:"mt-3 text-sm leading-6 text-muted-foreground md:text-base",children:"Build a thesis from a research idea or bring an existing document into Academly."})]}),o.jsxs("div",{className:"mt-8 grid gap-5 md:grid-cols-2",children:[o.jsxs("button",{type:"button",onClick:()=>{l("topic"),u(1)},className:"group rounded-2xl border border-border/70 bg-card p-6 text-left shadow-sm transition hover:-translate-y-0.5 hover:border-primary/25 hover:shadow-md md:p-7",children:[o.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(Sr,{className:"h-5 w-5"})}),o.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground",children:"Start with a topic"}),o.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Develop your topic, research questions, structure and starting literature with Academly."}),o.jsxs("span",{className:"mt-6 inline-flex items-center gap-2 text-sm font-semibold text-primary",children:["Start guided setup",o.jsx(As,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]}),o.jsxs("button",{type:"button",onClick:()=>l("import"),className:"group rounded-2xl border border-border/70 bg-card p-6 text-left shadow-sm transition hover:-translate-y-0.5 hover:border-primary/25 hover:shadow-md md:p-7",children:[o.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(BW,{className:"h-5 w-5"})}),o.jsx("h2",{className:"mt-5 text-xl font-semibold tracking-tight text-foreground",children:"Import existing thesis"}),o.jsx("p",{className:"mt-2 text-sm leading-6 text-muted-foreground",children:"Upload a DOCX or ODT file and turn the existing structure into an Academly thesis workspace."}),o.jsxs("span",{className:"mt-6 inline-flex items-center gap-2 text-sm font-semibold text-primary",children:["Import document",o.jsx(As,{className:"h-4 w-4 transition-transform group-hover:translate-x-0.5"})]})]})]})]})}),W&&o.jsxs("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center gap-3 rounded-2xl bg-background/90 backdrop-blur-sm",children:[o.jsx(Xe,{className:"h-8 w-8 animate-spin text-primary"}),o.jsx("div",{className:"text-sm font-medium text-foreground",children:he})]})]})}const d7t=()=>{const{user:t,loading:e}=Ht(),r=Or();return S.useEffect(()=>{!e&&!t&&r("/login",{replace:!0})},[e,t,r]),e?o.jsx(Cr,{showSidebar:!0,pageTitle:"New Thesis",fullWidth:!0,children:o.jsx("div",{className:"flex min-h-[60vh] items-center justify-center",children:o.jsx(Xe,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):t?o.jsx(Cr,{showSidebar:!0,pageTitle:"New Thesis",fullWidth:!0,children:o.jsx("div",{className:"mx-auto w-full max-w-[1120px]",children:o.jsx(u7t,{})})}):null};function h7t(){return o.jsx(p0,{to:"/topic-explorer/ideas",replace:!0})}function f7t(){const{toast:t}=Bn(),e=Or(),{checkStudentPoints:r,studentPoints:n}=Ht(),[s,i]=S.useState(!1),[a,l]=S.useState("EN"),[c,u]=S.useState(""),[d,h]=S.useState(""),[f,p]=S.useState(!1),[m,g]=S.useState([]),[y,x]=S.useState(null),[v,b]=S.useState({title:"",introduction:"",problemStatement:"",objectives:""}),w=async()=>{if(!r()){i(!0);return}p(!0);try{const{data:{session:C}}=await pe.auth.getSession();if(!(C!=null&&C.access_token))throw new Error("No authentication token found");const E=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({action:"suggest",topic:c,context:d,language:a})})).json();if(E.error)throw new Error(E.error);const O=(E.suggestions||[]).map(($,T)=>{var M;return{id:((M=crypto.randomUUID)==null?void 0:M.call(crypto))||String(T),title:$.title,researchQuestions:$.research_questions??$.researchQuestions??[],method:$.method,relevance:$.relevance,sources:Array.isArray($.sources)?$.sources:[]}});g(O)}catch(C){console.error("Error generating suggestions:",C),t({title:"Generation Error",description:"The suggestions could not be generated.",variant:"destructive"})}finally{p(!1)}},j=async C=>{x(C);try{const{data:{session:A}}=await pe.auth.getSession();if(!(A!=null&&A.access_token))throw new Error("No authentication token found");const E={action:"structure",selection:C,language:a,original_topic:c,original_context:d,save:!0},$=await(await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/topic_explorer",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${A.access_token}`},body:JSON.stringify(E)})).json();if($.error)throw new Error($.error);const T=$.structure||$;b({title:T.title||C.title,introduction:T.introduction||"",problemStatement:T.problem||"",objectives:T.objectives||""}),$.summary_id&&t({title:"Saved",description:"Saved to My Library under My Topic Explorations."})}catch(A){console.error("Error generating structure:",A),t({title:"Structure Error",description:"The structure could not be generated.",variant:"destructive"})}},N=C=>{navigator.clipboard.writeText(C).then(()=>{t({title:"Copied!",description:"Text has been copied to clipboard."})})};return o.jsxs(Cr,{showSidebar:!0,pageTitle:"Topic Ideas",children:[o.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Topic Ideas"}),o.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate structured topic suggestions for your research"})]}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(dd,{className:"h-5 w-5 text-primary"}),"Generate Topic Suggestions"]}),o.jsx(Es,{children:"Enter your basic idea and receive structured suggestions"})]}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Working Title / Topic Idea"}),o.jsx(Ue,{placeholder:"e.g., AI in Education",value:c,onChange:C=>u(C.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Language"}),o.jsxs(Tj,{type:"single",value:a,onValueChange:C=>C&&l(C),children:[o.jsx(nu,{value:"DE",children:"DE"}),o.jsx(nu,{value:"EN",children:"EN"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Description / Context"}),o.jsx(lr,{placeholder:"Describe program, scope, methodology, context...",value:d,onChange:C=>h(C.target.value),rows:3})]}),o.jsx(me,{onClick:w,disabled:!c.trim()||f,className:"w-full",children:f?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating Suggestions..."]}):"Generate Suggestions"})]})]}),m.length>0&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("h2",{className:"text-xl font-semibold text-foreground",children:"Topic Suggestions"}),o.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:m.map(C=>o.jsxs(Ze,{className:"hover:border-primary/50 transition-colors",children:[o.jsx(Ot,{children:o.jsx(Ft,{className:"text-lg",children:C.title})}),o.jsxs(st,{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-sm text-foreground mb-1",children:"Research Questions:"}),o.jsx("ul",{className:"text-sm text-muted-foreground space-y-1",children:(C.researchQuestions||[]).map((A,E)=>o.jsxs("li",{children:["• ",A]},E))})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-sm text-foreground mb-1",children:"Method:"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:C.method})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-sm text-foreground mb-1",children:"Relevance:"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:C.relevance})]}),o.jsxs("div",{children:[o.jsx("h4",{className:"font-medium text-sm text-foreground mb-1",children:"Initial Sources:"}),o.jsx("div",{className:"space-y-1",children:(C.sources||[]).map((A,E)=>o.jsxs("div",{className:"text-xs text-muted-foreground",children:[o.jsx("span",{className:"font-medium",children:A.title}),A.doi&&o.jsxs("span",{className:"block",children:["DOI: ",A.doi]}),A.isbn&&o.jsxs("span",{className:"block",children:["ISBN: ",A.isbn]})]},E))})]}),o.jsxs("div",{className:"flex gap-2 pt-2",children:[o.jsx(me,{size:"sm",onClick:()=>j(C),className:"flex-1",children:"Select"}),o.jsx(me,{size:"sm",variant:"outline",onClick:()=>N(JSON.stringify(C,null,2)),children:o.jsx(ws,{className:"h-4 w-4"})})]})]})]},C.id))})]}),y&&o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(nr,{className:"h-5 w-5 text-primary"}),"Basic Structure"]}),o.jsx(Es,{children:"Your topic idea has been saved to My Library under My Topic Explorations."})]}),o.jsx(st,{children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs(yf,{children:[o.jsx(uc,{className:"h-4 w-4"}),o.jsx(Lq,{children:"Saved successfully"}),o.jsxs(vf,{className:"flex items-center justify-between",children:[o.jsx("span",{children:"Your topic idea is available in My Library. You can continue by creating an outline."}),o.jsxs(me,{size:"sm",variant:"outline",className:"ml-4 shrink-0",onClick:()=>e("/topic-explorer/outline"),children:["Go to Outline Generator",o.jsx(As,{className:"h-4 w-4 ml-1"})]})]})]}),o.jsx("div",{className:"bg-muted/30 p-6 rounded-lg",children:o.jsxs("div",{className:"space-y-4 text-foreground",children:[o.jsx("div",{children:o.jsx("h2",{className:"text-xl font-bold mb-2",children:v.title})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Introduction:"}),o.jsx("p",{className:"whitespace-pre-wrap mb-4",children:v.introduction})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Problem Statement:"}),o.jsx("p",{className:"whitespace-pre-wrap mb-4",children:v.problemStatement})]}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Objectives:"}),o.jsx("p",{className:"whitespace-pre-wrap",children:v.objectives})]}),(y==null?void 0:y.researchQuestions)&&y.researchQuestions.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Research Questions:"}),o.jsx("ul",{className:"space-y-1",children:y.researchQuestions.map((C,A)=>o.jsxs("li",{className:"whitespace-pre-wrap",children:["• ",C]},A))})]}),(y==null?void 0:y.method)&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Methodology:"}),o.jsx("p",{className:"whitespace-pre-wrap",children:y.method})]}),(y==null?void 0:y.sources)&&y.sources.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Literature Tips:"}),o.jsx("ol",{className:"list-decimal list-inside space-y-2",children:y.sources.map((C,A)=>o.jsxs("li",{className:"text-sm",children:[o.jsx("span",{children:C.title}),C.doi&&o.jsxs("span",{className:"block text-muted-foreground ml-5",children:["DOI: ",C.doi]}),C.isbn&&o.jsxs("span",{className:"block text-muted-foreground ml-5",children:["ISBN: ",C.isbn]})]},A))})]})]})}),o.jsx("div",{className:"flex justify-end",children:o.jsxs(me,{variant:"outline",onClick:()=>{let C=`${v.title}

Introduction:
${v.introduction}

Problem Statement:
${v.problemStatement}

Objectives:
${v.objectives}`;y!=null&&y.researchQuestions&&y.researchQuestions.length>0&&(C+=`

Research Questions:
${y.researchQuestions.map((A,E)=>`${E+1}. ${A}`).join(`
`)}`),y!=null&&y.method&&(C+=`

Methodology:
${y.method}`),y!=null&&y.sources&&y.sources.length>0&&(C+=`

Literature Tips:
${y.sources.map((A,E)=>`${E+1}. ${A.title}${A.doi?` (DOI: ${A.doi})`:""}${A.isbn?` (ISBN: ${A.isbn})`:""}`).join(`
`)}`),N(C)},children:[o.jsx(ws,{className:"h-4 w-4 mr-2"}),"Copy"]})})]})})]})]}),o.jsx(cu,{open:s,onClose:()=>i(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]})}const Vh=iSe,Qy=iG,qh=oG;function p7t(){const{toast:t}=Bn(),[e,r]=S.useState("EN"),[n,s]=S.useState(""),[i,a]=S.useState(""),[l,c]=S.useState("bachelor"),[u,d]=S.useState(""),[h,f]=S.useState(!1),[p,m]=S.useState(null),[g,y]=S.useState(""),[x,v]=S.useState(""),[b,w]=S.useState(""),[j,N]=S.useState(""),[C,A]=S.useState(!1),[E,O]=S.useState([]),[$,T]=S.useState(""),[M,k]=S.useState(!0);S.useEffect(()=>{D()},[]);const D=async()=>{try{const{data:{session:V}}=await pe.auth.getSession();if(!V)return;const{data:B,error:z}=await pe.from("topic_explorations").select("id, title, research_questions, introduction, problem_statement, objectives, method, created_at").eq("user_id",V.user.id).eq("feature_type","topic_ideas").order("created_at",{ascending:!1});if(z)throw z;O(B||[])}catch(V){console.error("Error loading explorations:",V)}finally{k(!1)}},K=()=>{if(!$)return;const V=E.find(B=>B.id===$);if(V){if(s(V.title||""),V.research_questions){const B=Array.isArray(V.research_questions)?V.research_questions:[];a(B.join(`
`))}V.introduction&&y(V.introduction),V.problem_statement&&v(V.problem_statement),V.objectives&&w(V.objectives),V.method&&N(V.method),(V.introduction||V.problem_statement||V.objectives||V.method)&&A(!0),t({title:"Imported",description:"Data has been imported"})}},H=async()=>{if(n.trim()){f(!0);try{const{data:{session:V}}=await pe.auth.getSession();if(!(V!=null&&V.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 ${V.access_token}`},body:JSON.stringify({action:"outline",title:n.trim(),research_questions:i.split(`
`).filter(F=>F.trim()),language:e,degree_type:l,target_word_count:u?parseInt(u):void 0,topic_context:{introduction:g.trim()||void 0,problem_statement:x.trim()||void 0,objectives:b.trim()||void 0,methodology:j.trim()||void 0}})})).json();if(z.error)throw new Error(z.error);m(z.outline),t({title:"Outline Generated",description:"Your outline has been saved to My Library under My Topic Explorations."})}catch(V){console.error("Error generating outline:",V),t({title:"Error",description:"The outline could not be generated.",variant:"destructive"})}finally{f(!1)}}},ee=()=>{if(!p)return;let V=`${p.title}

`;V+=`TABLE OF CONTENTS

`,p.chapters.forEach(B=>{V+=`${B.number} ${B.title}`,B.estimated_pages&&(V+=` (~${B.estimated_pages} pages)`),V+=`
`,B.subchapters&&B.subchapters.forEach(z=>{V+=`  ${z.number} ${z.title}`,z.estimated_pages&&(V+=` (~${z.estimated_pages} pages)`),V+=`
`})}),V+=`
Estimated Total Pages: ~${p.total_estimated_pages}`,p.notes&&(V+=`

Notes:
${p.notes}`),navigator.clipboard.writeText(V),t({title:"Copied!",description:"Outline has been copied to clipboard."})};return o.jsx(Cr,{showSidebar:!0,pageTitle:"Outline Generator",children:o.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Outline Generator"}),o.jsx("p",{className:"text-muted-foreground mt-2",children:"Create a detailed outline for your scientific work"})]}),o.jsx(Ze,{children:o.jsx(st,{className:"pt-6",children:o.jsxs("div",{className:"space-y-3",children:[o.jsx(Se,{className:"text-sm font-semibold",children:"Take from Topic Explorer"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(pt,{value:$,onValueChange:T,children:[o.jsx(ut,{className:"flex-1",children:o.jsx(mt,{placeholder:M?"Loading...":"Select a topic..."})}),o.jsx(dt,{children:E.map(V=>o.jsx(Le,{value:V.id,children:V.title},V.id))})]}),o.jsx(me,{onClick:K,disabled:!$,variant:"secondary",children:"Import Topic"})]})]})})}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(jr,{className:"h-5 w-5 text-primary"}),"Generate Outline"]}),o.jsx(Es,{children:"Create a detailed outline for your scientific work"})]}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Title / Topic *"}),o.jsx(Ue,{placeholder:"e.g., AI in Education",value:n,onChange:V=>s(V.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Language"}),o.jsxs(Tj,{type:"single",value:e,onValueChange:V=>V&&r(V),children:[o.jsx(nu,{value:"DE",children:"DE"}),o.jsx(nu,{value:"EN",children:"EN"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Research Questions (optional)"}),o.jsx(lr,{placeholder:"One question per line...",value:i,onChange:V=>a(V.target.value),rows:3})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Degree Type"}),o.jsxs(pt,{value:l,onValueChange:c,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"bachelor",children:"Bachelor"}),o.jsx(Le,{value:"master",children:"Master"}),o.jsx(Le,{value:"phd",children:"PhD / Dissertation"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Target Word Count (optional)"}),o.jsx(ri,{children:o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(lf,{className:"h-3.5 w-3.5 text-muted-foreground cursor-help"})}),o.jsxs(xr,{side:"top",className:"max-w-xs text-xs space-y-1",children:[o.jsx("p",{className:"font-semibold",children:"Approximate page equivalents:"}),o.jsx("p",{children:"~3,000 words ≈ 10–12 pages"}),o.jsx("p",{children:"~5,000 words ≈ 18–20 pages"}),o.jsx("p",{children:"~10,000 words ≈ 35–40 pages"}),o.jsx("p",{children:"~15,000 words ≈ 55–60 pages"}),o.jsx("p",{className:"text-muted-foreground pt-1",children:"Based on ~275 words/page (A4, 12pt, 1.5 spacing)"})]})]})})]}),o.jsx(Ue,{type:"number",placeholder:"e.g., 15000",value:u,onChange:V=>d(V.target.value)})]})]}),o.jsxs(Vh,{open:C,onOpenChange:A,children:[o.jsx(Qy,{asChild:!0,children:o.jsxs(me,{variant:"ghost",className:"w-full justify-between p-3 h-auto border border-dashed border-border hover:bg-muted/50",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Sr,{className:"h-4 w-4 text-primary"}),o.jsx("span",{className:"text-sm font-medium",children:e==="DE"?"Erweiterter Kontext (optional)":"Advanced Context (optional)"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:e==="DE"?"Für bessere Ergebnisse":"For better results"}),o.jsx(ia,{className:`h-4 w-4 transition-transform ${C?"rotate-180":""}`})]})]})}),o.jsxs(qh,{className:"pt-4 space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Einleitung":"Introduction"}),o.jsx(lr,{placeholder:e==="DE"?"Kurze Einführung in das Thema...":"Brief introduction to the topic...",value:g,onChange:V=>y(V.target.value),rows:3})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Problemstellung":"Problem Statement"}),o.jsx(lr,{placeholder:e==="DE"?"Das Forschungsproblem...":"The research problem...",value:x,onChange:V=>v(V.target.value),rows:3})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Ziele (ein Ziel pro Zeile)":"Objectives (one per line)"}),o.jsx(lr,{placeholder:e==="DE"?`Ziel 1
Ziel 2
Ziel 3`:`Objective 1
Objective 2
Objective 3`,value:b,onChange:V=>w(V.target.value),rows:3})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Methodischer Ansatz":"Methodology"}),o.jsx(lr,{placeholder:e==="DE"?"z.B. RCT, Qualitative Interviews, Systematic Review...":"e.g., RCT, Qualitative Interviews, Systematic Review...",value:j,onChange:V=>N(V.target.value),rows:2})]})]})]}),o.jsx(me,{onClick:H,disabled:!n.trim()||h,className:"w-full",children:h?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating Outline..."]}):"Generate Outline"})]})]}),p&&o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx(Ft,{children:p.title}),o.jsxs(me,{variant:"outline",size:"sm",onClick:ee,children:[o.jsx(ws,{className:"h-4 w-4 mr-2"}),"Copy"]})]}),o.jsxs(Es,{children:["Estimated pages: ~",p.total_estimated_pages]})]}),o.jsxs(st,{children:[o.jsx(hG,{type:"multiple",className:"w-full",children:p.chapters.map((V,B)=>o.jsxs(ML,{value:`chapter-${B}`,children:[o.jsx(DL,{className:"hover:no-underline",children:o.jsxs("div",{className:"flex items-center gap-3 text-left",children:[o.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:V.number}),o.jsx("span",{className:"font-medium",children:V.title}),V.estimated_pages&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["(~",V.estimated_pages," p.)"]})]})}),o.jsx(LL,{children:o.jsxs("div",{className:"pl-8 space-y-3",children:[V.description&&o.jsx("p",{className:"text-sm text-muted-foreground",children:V.description}),V.subchapters&&V.subchapters.length>0&&o.jsx("div",{className:"space-y-2",children:V.subchapters.map((z,F)=>o.jsxs("div",{className:"flex items-start gap-3 py-1",children:[o.jsx("span",{className:"font-mono text-sm text-muted-foreground",children:z.number}),o.jsxs("div",{children:[o.jsx("span",{className:"text-sm font-medium",children:z.title}),z.estimated_pages&&o.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:["(~",z.estimated_pages," p.)"]}),z.description&&o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:z.description})]})]},F))})]})})]},B))}),p.notes&&o.jsxs("div",{className:"mt-4 p-4 bg-muted/50 rounded-lg",children:[o.jsx("h4",{className:"font-medium text-sm mb-2",children:"Notes"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:p.notes})]})]})]})]})})}function m7t(){const{toast:t}=Bn(),[e,r]=S.useState("EN"),[n,s]=S.useState(""),[i,a]=S.useState(""),[l,c]=S.useState(""),[u,d]=S.useState(!1),[h,f]=S.useState(null),[p,m]=S.useState(""),[g,y]=S.useState(""),[x,v]=S.useState(""),[b,w]=S.useState(""),[j,N]=S.useState(!1),[C,A]=S.useState(""),[E,O]=S.useState(!1),[$,T]=S.useState([]),[M,k]=S.useState(new Set),[D,K]=S.useState([]),[H,ee]=S.useState(""),[V,B]=S.useState(!0);S.useEffect(()=>{z()},[]);const z=async()=>{try{const{data:{session:L}}=await pe.auth.getSession();if(!L)return;const{data:Z,error:J}=await pe.from("topic_explorations").select("id, title, research_questions, outline_json, introduction, problem_statement, objectives, method, created_at").eq("user_id",L.user.id).eq("feature_type","topic_ideas").order("created_at",{ascending:!1});if(J)throw J;K(Z||[])}catch(L){console.error("Error loading explorations:",L)}finally{B(!1)}},F=()=>{if(!H)return;const L=D.find(Z=>Z.id===H);if(L){if(s(L.title||""),L.research_questions){const Z=Array.isArray(L.research_questions)?L.research_questions:[];a(Z.join(`
`))}if(L.outline_json){const Z=L.outline_json;if(Z.chapters){const J=Z.chapters.map(W=>`${W.number} ${W.title}`).join(`
`);c(J)}}L.introduction&&m(L.introduction),L.problem_statement&&y(L.problem_statement),L.objectives&&v(L.objectives),L.method&&w(L.method),(L.introduction||L.problem_statement||L.objectives||L.method)&&N(!0),t({title:"Imported",description:"Data has been imported"})}},G=async()=>{var L,Z;if(n.trim()){d(!0);try{const{data:{session:J}}=await pe.auth.getSession();if(!(J!=null&&J.access_token))throw new Error("No authentication token found");const X=await(await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/topic_research_tools",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${J.access_token}`},body:JSON.stringify({action:"keywords",title:n.trim(),research_questions:i.split(`
`).filter(he=>he.trim()),outline:l.trim()||void 0,language:e,topic_context:{introduction:p.trim()||void 0,problem_statement:g.trim()||void 0,objectives:x.trim()||void 0,methodology:b.trim()||void 0}})})).json();if(X.error)throw new Error(X.error);f(X.keywords),((Z=(L=X.keywords)==null?void 0:L.keyword_combinations)==null?void 0:Z.length)>0&&A(X.keywords.keyword_combinations[0].combination),t({title:"Keywords Generated",description:"The literature keywords have been successfully generated."})}catch(J){console.error("Error generating keywords:",J),t({title:"Error",description:"The keywords could not be generated.",variant:"destructive"})}finally{d(!1)}}},Q=L=>{navigator.clipboard.writeText(L),t({title:"Copied!",description:"Text has been copied to clipboard."})},ie=()=>{if(!h)return;const L=h.keyword_combinations||[],Z=h.known_authors||[],J=h.known_works||[],W=h.database_suggestions||[];let X=`LITERATURE KEYWORDS

`;X+=`Search Combinations:
`,L.forEach(he=>{X+=`- ${he.combination} (${he.purpose})
`}),X+=`
Known Authors:
`,Z.forEach(he=>{X+=`- ${he.name}: ${he.relevance}
`}),X+=`
Known Works:
`,J.forEach(he=>{X+=`- ${he.title}`,he.author&&(X+=` (${he.author}`),he.year&&(X+=`, ${he.year}`),he.author&&(X+=")"),X+=`
`}),X+=`
Database Suggestions:
`,X+=W.join(", ")+`

`,X+=`Search Tips:
`,X+=h.search_tips||"",Q(X)},se=async()=>{if(C.trim()){O(!0),T([]);try{const{data:{session:L}}=await pe.auth.getSession();if(!(L!=null&&L.access_token))throw new Error("No authentication token found");const J=await(await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/topic_research_tools",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${L.access_token}`},body:JSON.stringify({action:"search_literature",keywords:C.trim()})})).json();if(J.error)throw new Error(J.error);T(J.results||[]),(J.results||[]).length===0&&t({title:"No results found",description:"Try different keywords."})}catch(L){console.error("Error searching literature:",L),t({title:"Error",description:"Literature search failed.",variant:"destructive"})}finally{O(!1)}}},q=L=>{k(Z=>{const J=new Set(Z);return J.has(L)?J.delete(L):J.add(L),J})};return o.jsx(Cr,{showSidebar:!0,pageTitle:"Literature Keywords",children:o.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-6",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Literature Keywords"}),o.jsx("p",{className:"text-muted-foreground mt-2",children:"Generate search terms and find relevant literature for your topic"})]}),o.jsx(Ze,{children:o.jsx(st,{className:"pt-6",children:o.jsxs("div",{className:"space-y-3",children:[o.jsx(Se,{className:"text-sm font-semibold",children:"Take from Topic Explorer"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(pt,{value:H,onValueChange:ee,children:[o.jsx(ut,{className:"flex-1",children:o.jsx(mt,{placeholder:V?"Loading...":"Select a topic..."})}),o.jsx(dt,{children:D.map(L=>o.jsx(Le,{value:L.id,children:L.title},L.id))})]}),o.jsx(me,{onClick:F,disabled:!H,variant:"secondary",children:"Import Topic"})]})]})})}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(Ti,{className:"h-5 w-5 text-primary"}),"Find Literature Keywords"]}),o.jsx(Es,{children:"Generate search terms and find relevant literature for your topic"})]}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Title / Topic *"}),o.jsx(Ue,{placeholder:"e.g., AI in Education",value:n,onChange:L=>s(L.target.value)})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Output Language"}),o.jsxs(Tj,{type:"single",value:e,onValueChange:L=>L&&r(L),children:[o.jsx(nu,{value:"DE",children:"DE"}),o.jsx(nu,{value:"EN",children:"EN"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Research Questions (optional)"}),o.jsx(lr,{placeholder:"One question per line...",value:i,onChange:L=>a(L.target.value),rows:3})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:"Outline (optional)"}),o.jsx(lr,{placeholder:"Chapter structure or topic overview...",value:l,onChange:L=>c(L.target.value),rows:4})]}),o.jsxs(Vh,{open:j,onOpenChange:N,children:[o.jsx(Qy,{asChild:!0,children:o.jsxs(me,{variant:"ghost",className:"w-full justify-between p-3 h-auto border border-dashed border-border hover:bg-muted/50",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Sr,{className:"h-4 w-4 text-primary"}),o.jsx("span",{className:"text-sm font-medium",children:e==="DE"?"Erweiterter Kontext (optional)":"Advanced Context (optional)"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:e==="DE"?"Für bessere Ergebnisse":"For better results"}),o.jsx(ia,{className:`h-4 w-4 transition-transform ${j?"rotate-180":""}`})]})]})}),o.jsxs(qh,{className:"pt-4 space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Einleitung":"Introduction"}),o.jsx(lr,{placeholder:e==="DE"?"Kurze Einführung in das Thema...":"Brief introduction to the topic...",value:p,onChange:L=>m(L.target.value),rows:3})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Problemstellung":"Problem Statement"}),o.jsx(lr,{placeholder:e==="DE"?"Das Forschungsproblem...":"The research problem...",value:g,onChange:L=>y(L.target.value),rows:3})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Ziele (ein Ziel pro Zeile)":"Objectives (one per line)"}),o.jsx(lr,{placeholder:e==="DE"?`Ziel 1
Ziel 2
Ziel 3`:`Objective 1
Objective 2
Objective 3`,value:x,onChange:L=>v(L.target.value),rows:3})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{className:"text-sm font-medium text-foreground",children:e==="DE"?"Methodischer Ansatz":"Methodology"}),o.jsx(lr,{placeholder:e==="DE"?"z.B. RCT, Qualitative Interviews, Systematic Review...":"e.g., RCT, Qualitative Interviews, Systematic Review...",value:b,onChange:L=>w(L.target.value),rows:2})]})]})]}),o.jsx(me,{onClick:G,disabled:!n.trim()||u,className:"w-full",children:u?o.jsxs(o.Fragment,{children:[o.jsx(Xe,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating Keywords..."]}):"Generate Keywords"})]})]}),h&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("h3",{className:"text-lg font-semibold",children:"Results"}),o.jsxs(me,{variant:"outline",size:"sm",onClick:ie,children:[o.jsx(ws,{className:"h-4 w-4 mr-2"}),"Copy All"]})]}),o.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[o.jsxs(Ze,{children:[o.jsx(Ot,{className:"pb-3",children:o.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[o.jsx(dd,{className:"h-4 w-4"}),"Search Combinations"]})}),o.jsx(st,{children:o.jsx("div",{className:"space-y-2",children:(h.keyword_combinations||[]).map((L,Z)=>o.jsxs("div",{className:"flex items-start justify-between gap-2 p-2 bg-muted/50 rounded-md cursor-pointer hover:bg-muted",onClick:()=>Q(L.combination),children:[o.jsxs("div",{children:[o.jsx("code",{className:"text-sm font-medium",children:L.combination}),o.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:L.purpose})]}),o.jsx(kt,{variant:"outline",className:"text-xs shrink-0",children:L.language})]},Z))})})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{className:"pb-3",children:o.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[o.jsx(nj,{className:"h-4 w-4"}),"Known Authors"]})}),o.jsx(st,{children:o.jsx("div",{className:"space-y-2",children:(h.known_authors||[]).map((L,Z)=>o.jsxs("div",{className:"p-2 bg-muted/50 rounded-md cursor-pointer hover:bg-muted",onClick:()=>Q(L.name),children:[o.jsx("span",{className:"font-medium text-sm",children:L.name}),o.jsx("p",{className:"text-xs text-muted-foreground",children:L.relevance})]},Z))})})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{className:"pb-3",children:o.jsxs(Ft,{className:"text-base flex items-center gap-2",children:[o.jsx(nr,{className:"h-4 w-4"}),"Known Works"]})}),o.jsx(st,{children:o.jsx("div",{className:"space-y-2",children:(h.known_works||[]).map((L,Z)=>o.jsxs("div",{className:"p-2 bg-muted/50 rounded-md cursor-pointer hover:bg-muted",onClick:()=>Q(L.title),children:[o.jsx("span",{className:"font-medium text-sm",children:L.title}),(L.author||L.year)&&o.jsxs("p",{className:"text-xs text-muted-foreground",children:[L.author,L.year&&` (${L.year})`]}),L.relevance&&o.jsx("p",{className:"text-xs text-muted-foreground italic mt-1",children:L.relevance})]},Z))})})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{className:"pb-3",children:o.jsx(Ft,{className:"text-base",children:"Recommended Databases"})}),o.jsx(st,{children:o.jsx("div",{className:"flex flex-wrap gap-2",children:(h.database_suggestions||[]).map((L,Z)=>o.jsx(kt,{variant:"secondary",children:L},Z))})})]})]}),h.search_tips&&o.jsxs(Ze,{children:[o.jsx(Ot,{className:"pb-3",children:o.jsx(Ft,{className:"text-base",children:"Search Tips"})}),o.jsx(st,{children:o.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:h.search_tips})})]})]}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(nr,{className:"h-5 w-5 text-primary"}),"Search Real Literature"]}),o.jsx(Es,{children:"Search CrossRef and OpenAlex for real academic papers"})]}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx(Ue,{placeholder:"e.g., ITIL service transition challenges",value:C,onChange:L=>A(L.target.value),onKeyDown:L=>L.key==="Enter"&&se(),className:"flex-1"}),o.jsx(me,{onClick:se,disabled:!C.trim()||E,children:E?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(Ti,{className:"h-4 w-4"})})]}),$.length>0&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("p",{className:"text-sm text-muted-foreground",children:[$.length," results found"]}),$.map((L,Z)=>{var J;return o.jsxs("div",{className:"border border-border rounded-lg p-4 space-y-2 hover:bg-muted/30 transition-colors",children:[o.jsxs("div",{className:"flex items-start justify-between gap-2",children:[o.jsx("h4",{className:"font-medium text-sm leading-snug flex-1",children:L.title}),o.jsxs("div",{className:"flex gap-1 shrink-0 flex-wrap justify-end",children:[L.is_open_access&&o.jsx(kt,{className:"text-xs bg-green-100 text-green-800 border-green-200",children:"Open Access"}),o.jsx(kt,{variant:"outline",className:"text-xs",children:L.source==="crossref"?"CrossRef":"OpenAlex"})]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[((J=L.authors)==null?void 0:J.length)>0&&o.jsxs("span",{children:[L.authors.slice(0,3).join(", "),L.authors.length>3?" et al.":""]}),L.year&&o.jsx("span",{children:L.year}),L.journal&&o.jsx("span",{className:"italic",children:L.journal})]}),L.abstract&&o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:M.has(Z)?L.abstract:L.abstract.substring(0,150)+"..."}),o.jsx("button",{onClick:()=>q(Z),className:"text-xs text-primary hover:underline mt-1",children:M.has(Z)?"Show less":"Show more"})]}),o.jsxs("div",{className:"flex gap-2 pt-1 flex-wrap",children:[L.doi&&o.jsxs(me,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>Q(L.doi),children:[o.jsx(ws,{className:"h-3 w-3 mr-1"}),"Copy DOI"]}),L.url&&o.jsx(me,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>window.open(L.url,"_blank"),children:"View"})]})]},Z)})]})]})]})]})})}function g7t(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(l=>parseInt(l.trim()));if(isNaN(i)||isNaN(a)||i<1||a>e||i>a)return{pages:[],error:`Invalid range: ${s}`};for(let l=i;l<=a;l++)r.add(l)}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 x7t(){const{user:t,loading:e,checkStudentPoints:r,studentPoints:n}=Ht(),[s,i]=S.useState(!1),a=Or(),[l,c]=S.useState([]),[u,d]=S.useState(!0),[h,f]=S.useState(null),[p,m]=S.useState(""),[g,y]=S.useState([]),[x,v]=S.useState(""),[b,w]=S.useState(""),[j,N]=S.useState(!0),[C,A]=S.useState(!0),[E,O]=S.useState(!1),[$,T]=S.useState(null);S.useEffect(()=>{!t&&!e&&a("/login")},[t,e,a]),S.useEffect(()=>{t&&M()},[t]),S.useEffect(()=>{if(h){const ee=g7t(p,h.page_count||0);if(y(ee.pages||[]),v(ee.error||""),ee.pages&&ee.pages.length>0){const V=k(ee.pages);w(`${h.title} – Excerpt (${V})`)}}},[p,h]);const M=async()=>{if(t){d(!0);try{const{data:ee,error:V}=await pe.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(V){console.error("Error loading documents:",V),It({title:"Error",description:"Documents could not be loaded",variant:"destructive"});return}c(ee||[])}catch(ee){console.error("Error in loadDocuments:",ee)}finally{d(!1)}}},k=ee=>{if(ee.length===0)return"";const V=[];let B=ee[0],z=ee[0];for(let F=1;F<ee.length;F++)ee[F]===z+1?z=ee[F]:(B===z?V.push(B.toString()):V.push(`${B}-${z}`),B=z=ee[F]);return B===z?V.push(B.toString()):V.push(`${B}-${z}`),V.join(", ")},D=async()=>{if(!r()){i(!0);return}if(!(!h||g.length===0||x)){O(!0),It({title:"Extract is being generated...",description:"Please wait a moment"});try{const{data:ee,error:V}=await pe.functions.invoke("pdf_slicer",{body:{document_id:h.id,pages:g,new_title:b,keep_citation:j,copy_metadata:C}});if(V)throw V;if(ee.success)It({title:"Successfully created",description:"Your PDF extract has been successfully created"}),T(ee.document),await M();else throw new Error(ee.error||"Uknown Error")}catch(ee){console.error("Error creating excerpt:",ee),It({title:"Fehler",description:ee.message||"Excerpt could not be created",variant:"destructive"})}finally{O(!1)}}},K=()=>{f(null),m(""),y([]),v(""),w(""),N(!0),A(!0),T(null)},H=()=>{m(""),y([]),v(""),w(""),T(null)};return e||u?o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})}):t?o.jsxs(Cr,{showSidebar:!0,children:[o.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(kMe,{className:"h-8 w-8 text-primary"}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold",children:"Page Selector"}),o.jsx("p",{className:"text-muted-foreground",children:"Create extracts from your PDF documents"})]})]}),o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Source"})}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"source-document",children:"Quelldokument"}),o.jsxs(pt,{value:(h==null?void 0:h.id)||"",onValueChange:ee=>{const V=l.find(B=>B.id===ee)||null;f(V),m(""),y([]),v("")},disabled:u||l.length===0,children:[o.jsx(ut,{id:"source-document",children:o.jsx(mt,{placeholder:"Select document..."})}),o.jsx(dt,{children:l.map(ee=>o.jsxs(Le,{value:ee.id,children:[ee.title," (",ee.page_count||0," pages)"]},ee.id))})]})]}),h&&o.jsxs("div",{className:"text-sm text-muted-foreground",children:["pages: ",h.page_count||0," | Title: ",h.title]}),h&&o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"pages",children:"pages"}),o.jsx(Ue,{id:"pages",value:p,onChange:ee=>m(ee.target.value),placeholder:"e.G. 1-3, 5, 9-11"}),o.jsxs("div",{className:"mt-2 text-sm text-muted-foreground",children:["Examples: 3-6, 8, 10-12 → ",g.length>0&&`${g.length} pages selected`]}),x&&o.jsx("div",{className:"mt-2 text-sm text-destructive",children:x})]})]})]}),h&&o.jsxs(Ze,{children:[o.jsx(Ot,{children:o.jsx(Ft,{children:"Goal & Optionsn"})}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"new-title",children:"New Title"}),o.jsx(Ue,{id:"new-title",value:b,onChange:ee=>w(ee.target.value)})]}),o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(Qm,{id:"keep-citation",checked:j,onCheckedChange:N}),o.jsx(Se,{htmlFor:"keep-citation",children:"Retain APA citation"})]}),o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(Qm,{id:"copy-metadata",checked:C,onCheckedChange:A}),o.jsx(Se,{htmlFor:"copy-metadata",children:"Copy DOI/ISBN"})]})]})]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx(me,{onClick:D,disabled:!h||g.length===0||!!x||E,className:"flex-1",children:E?"Being created...":"Create extract"}),o.jsxs(me,{variant:"outline",onClick:K,children:[o.jsx(nfe,{className:"h-4 w-4 mr-2"}),"Reset"]})]}),$&&o.jsxs(Ze,{className:"border-green-200 bg-green-50/50 dark:border-green-800 dark:bg-green-950/50",children:[o.jsx(Ot,{children:o.jsxs(Ft,{className:"text-green-800 dark:text-green-200",children:[o.jsx(jr,{className:"h-5 w-5 inline mr-2"}),"Auszug erfolgreich erstellt"]})}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("div",{className:"font-medium",children:$.title}),o.jsxs("div",{className:"text-sm text-muted-foreground",children:[$.page_count||0," pages"]}),o.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Saved at: ",$.storage_path]})]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsxs(me,{onClick:()=>a("/documents"),children:[o.jsx(of,{className:"h-4 w-4 mr-2"}),"Go to the library"]}),o.jsx(me,{variant:"outline",onClick:H,children:"Create more"})]})]})]})]}),o.jsx(cu,{open:s,onClose:()=>i(!1),remainingPoints:(n==null?void 0:n.remaining)??0})]}):null}function y7t(){const t=Or(),[e]=uj(),{toast:r}=Bn(),{user:n,loading:s}=Ht(),[i,a]=S.useState([]),[l,c]=S.useState(!1),[u,d]=S.useState(""),[h,f]=S.useState(!0),[p,m]=S.useState(!1),[g,y]=S.useState(!1),[x,v]=S.useState(null),[b,w]=S.useState(""),j=e.get("document");S.useEffect(()=>{if(!s&&!n){t("/login");return}n&&N()},[n,s,t]),S.useEffect(()=>{j&&i.length>0&&!u&&i.some(O=>O.id===j)&&d(j)},[j,i,u]);const N=async()=>{c(!0);try{const{data:E,error:O}=await pe.from("documents").select("id, title, page_count, storage_path, created_at").order("created_at",{ascending:!1});if(O)throw O;a(E||[])}catch(E){console.error("Error loading documents:",E),r({title:"Error",description:"Failed to load documents.",variant:"destructive"})}finally{c(!1)}},C=async()=>{if(u){y(!0),w(""),v(null);try{const{data:{session:E}}=await pe.auth.getSession();if(!E)throw new Error("AUTH");const O=await fetch("https://nqibmbtqcjucktqcreob.supabase.co/functions/v1/pdf_extract",{method:"POST",headers:{Authorization:`Bearer ${E.access_token}`,"Content-Type":"application/json"},body:JSON.stringify({document_id:u,overwrite:h,also_block:p})}),$=await O.json();if(!O.ok||$.error)throw new Error($.error||"UNKNOWN");console.log("Extract result:",$),v($),r({title:"Sucessfully extracted",description:`${$.inserted_pages} Seiten extrahiert. page_count = ${$.page_count}.`}),await N()}catch(E){console.error("Extract error:",E);const O=E.message||"UNKNOWN";w(O);let $="Uknown Error.";switch(O){case"AUTH":$="Please Login.";break;case"DOC_NOT_FOUND":$="Document not found or permission denied.";break;case"STORAGE":$="Error accessing the file.";break;case"PDF_PARSE":$="PDF could not be processed.";break;case"DB_WRITE":$="Error saving to the database.";break}r({title:"Error",description:$,variant:"destructive"})}finally{y(!1)}}},A=i.find(E=>E.id===u);return s?o.jsx(Cr,{showSidebar:!0,children:o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(Xe,{className:"h-8 w-8 animate-spin"})})}):o.jsx(Cr,{showSidebar:!0,children:o.jsxs("div",{className:"container mx-auto py-8 space-y-6",children:[o.jsxs("div",{className:"mb-6",children:[o.jsx("h1",{className:"text-3xl font-bold",children:"PDF-Extract"}),o.jsx("p",{className:"text-muted-foreground",children:"Extract page-by-page text from previously uploaded documents"})]}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsx(Ft,{children:"Choose Document"}),o.jsx(Es,{children:"Extract page-by-page text from previously uploaded documents"})]}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs(pt,{value:u,onValueChange:d,disabled:l||g,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Choose document..."})}),o.jsx(dt,{children:i.map(E=>o.jsxs(Le,{value:E.id,children:[E.title," (",E.page_count?`${E.page_count} Pages`:"unbekannt",")"]},E.id))})]}),A&&o.jsx("div",{className:"text-sm text-muted-foreground",children:A.page_count?"Extracted pages already exist.":"No page text has been extracted yet."}),l&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Xe,{className:"h-4 w-4 animate-spin"}),"Loading Document..."]})]})]}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsx(Ft,{children:"Optionen"}),o.jsx(Es,{children:"Configure the extraction settings"})]}),o.jsxs(st,{className:"space-y-6",children:[o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(Qm,{id:"overwrite",checked:h,onCheckedChange:f,disabled:g}),o.jsx(Se,{htmlFor:"overwrite",children:"Overwrite existing page text"})]}),o.jsxs("div",{className:"flex items-center space-x-2",children:[o.jsx(Qm,{id:"alsoBlock",checked:p,onCheckedChange:m,disabled:g}),o.jsx(Se,{htmlFor:"alsoBlock",children:"Additionally, save the entire Markdown block"})]}),o.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."})]})]}),o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsx(Ft,{children:"Execution and result"}),o.jsx(Es,{children:"Start the text extraction and view the results."})]}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs(me,{onClick:C,disabled:!u||g,className:"w-full",size:"lg",children:[g&&o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),g?"Extract...":"Extract"]}),x&&o.jsxs("div",{className:"p-4 bg-green-50 dark:bg-green-950 rounded-lg border border-green-200 dark:border-green-800",children:[o.jsx("h4",{className:"font-semibold text-green-800 dark:text-green-200 mb-2",children:"Extraction successful"}),o.jsxs("div",{className:"space-y-1 text-sm text-green-700 dark:text-green-300",children:[o.jsxs("div",{children:["New page_count: ",o.jsx("strong",{children:x.page_count})]}),o.jsxs("div",{children:["Overwritten: ",o.jsx("strong",{children:x.overwrote?"Yes":"No"})]}),x.block_id&&o.jsxs("div",{children:["Block-ID: ",o.jsx("strong",{children:x.block_id})]})]})]}),b&&o.jsxs("div",{className:"p-4 bg-red-50 dark:bg-red-950 rounded-lg border border-red-200 dark:border-red-800",children:[o.jsx("h4",{className:"font-semibold text-red-800 dark:text-red-200 mb-2",children:"Fehler aufgetreten"}),o.jsxs("div",{className:"text-sm text-red-700 dark:text-red-300",children:["Error Code: ",b]})]}),o.jsxs(me,{variant:"outline",onClick:N,disabled:l||g,className:"w-full",children:[l&&o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}),o.jsx(rfe,{className:"mr-2 h-4 w-4"}),"Update document list"]})]})]})]})})}function v7t(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 b7t(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(l=>typeof l=="string"?l:l!=null&&l.family?`${l.family}, ${l.given||""}`.trim():"").filter(Boolean):[]}function w7t(t){var n,s,i,a,l,c,u,d,h,f,p,m,g,y,x;if(!t)return null;const e=t.published_year||t.year||((n=t.crossref_data)==null?void 0:n.year)||((c=(l=(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:l[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])||((y=(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:y[0]);if(e)return String(e);const r=(x=t.google_books_data)==null?void 0:x.publishedDate;return r?String(r).substring(0,4):null}function j7t(t){var r,n,s,i,a,l;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])||((l=(a=(i=e==null?void 0:e.crossref_data)==null?void 0:i.crossref_metadata)==null?void 0:a.title)==null?void 0:l[0])||t.title||"Untitled"}function S7t(t){var l,c,u,d,h,f;const e=t.bib_meta,r=e==null?void 0:e.crossref_payload,n=(l=e==null?void 0:e.crossref_data)==null?void 0:l.crossref_metadata,s=[],i=(p,m)=>{m&&s.push(`${p}  - ${m}`)};i("TY",v7t(e)),i("TI",j7t(t));for(const p of b7t(e))i("AU",p);i("PY",w7t(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 L7(t,e="citations.ris"){const r=t.map(S7t).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 _7t({doc:t,selected:e,onSelectionChange:r}){const[n,s]=S.useState(!1),i=Or(),a=t.bib_meta,l=DNe(t),c=VAt(a),u=qAt(a),d=GAt(a),h=t.doi||t.isbn||null,f=t.doi?"DOI":t.isbn?"ISBN":null,p=t.original_filename||null,m=p&&p!==l,g=async()=>{if(!t.citation_apa){Ke.error("No APA citation available");return}await navigator.clipboard.writeText(t.citation_apa),s(!0),Ke.success("APA citation copied"),setTimeout(()=>s(!1),2e3)},y=()=>{L7([t],`${l.replace(/[^a-zA-Z0-9]/g,"_").substring(0,40)}.ris`),Ke.success("RIS file downloaded")};return o.jsxs(fi,{className:"group border-border/60 transition-colors hover:bg-muted/20",children:[o.jsx(rr,{className:"w-8 py-4 align-top",children:o.jsx(aa,{checked:e,onCheckedChange:x=>r(t.id,!!x)})}),o.jsx(rr,{className:"min-w-0 py-4 align-top",children:o.jsxs("div",{className:"min-w-0 pr-4",children:[o.jsx("p",{className:"truncate text-sm font-semibold text-foreground",title:l,children:l}),o.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[o.jsx("span",{className:"truncate",children:c||"Unknown author"}),o.jsx("span",{"aria-hidden":"true",children:"·"}),o.jsx("span",{children:u||"n.d."})]}),m&&o.jsxs("p",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs text-muted-foreground/80",children:[o.jsx(jr,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"truncate",title:p,children:p})]})]})}),o.jsx(rr,{className:"py-4 align-top text-xs text-muted-foreground",children:o.jsxs("div",{className:"space-y-1.5",children:[o.jsx("div",{children:d?`${d} pages`:"Pages —"}),o.jsx("div",{className:"max-w-full truncate",title:h||void 0,children:h?`${f}: ${h}`:"DOI / ISBN —"})]})}),o.jsx(rr,{className:"py-4 align-top text-right",children:o.jsxs("div",{className:"flex justify-end gap-1",children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:g,disabled:!t.citation_apa,children:n?o.jsx(kr,{className:"h-4 w-4"}):o.jsx(ws,{className:"h-4 w-4"})})}),o.jsx(xr,{children:"Copy APA citation"})]}),o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:y,children:o.jsx(ko,{className:"h-4 w-4"})})}),o.jsx(xr,{children:"Export RIS"})]}),o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>i(`/reference-checker?document=${t.id}`),children:o.jsx(uc,{className:"h-4 w-4"})})}),o.jsx(xr,{children:"Open in Citation Manager"})]})]})})]})}async function T2e(t,e){var a,l,c;const{data:r}=await pe.from("documents").select("id,title,doi,isbn,external_url,landing_page_url,bib_meta").eq("user_id",t).limit(1e3),n=$se(e.url),s=BT(e.doi),i=BT(e.isbn).replace(/[^0-9x]/g,"");for(const u of r||[])if(n&&[u.external_url,u.landing_page_url,(a=u.bib_meta)==null?void 0:a.url].some(d=>$se(d)===n)||s&&[u.doi,(l=u.bib_meta)==null?void 0:l.doi].some(d=>BT(d)===s)||i&&[u.isbn,(c=u.bib_meta)==null?void 0:c.isbn].some(d=>BT(d).replace(/[^0-9x]/g,"")===i))return u;return null}function P2e({duplicate:t,onCancel:e,onConfirm:r}){return o.jsx(Mi,{open:!!t,onOpenChange:n=>!n&&e(),children:o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsx(di,{children:"Already in your library"}),o.jsxs(hi,{children:["A source with the same URL, DOI or ISBN already exists: “",(t==null?void 0:t.title)||"Untitled","”."]})]}),o.jsxs(ui,{children:[o.jsx(Ws,{onClick:e,children:"Cancel"}),o.jsx(ai,{onClick:r,children:"Create anyway"})]})]})})}const Dce={title:"",author:"",isOrganization:!1,year:"",month:"",day:"",siteName:"",url:"",accessedAt:"",reportNumber:"",publisher:"",doi:""},N7t={webpage:"web",wikipedia:"wikipedia",youtube:"youtube",report:null};function k7t({type:t,userId:e,onCreated:r}){const[n,s]=S.useState(Dce),[i,a]=S.useState(!1),[l,c]=S.useState(null),u=(v,b)=>s(w=>({...w,[v]:b})),d=S.useMemo(()=>({type:t,title:n.title,author:t==="wikipedia"?"":n.author,isOrganization:t==="youtube"?!0:n.isOrganization,date:{year:n.year,month:n.month,day:n.day},siteName:n.siteName,reportNumber:n.reportNumber,publisher:n.publisher,url:n.url,doi:t==="report"?n.doi:"",accessedAt:n.accessedAt}),[n,t]),h=S.useMemo(()=>DAt(d),[d]),f=!!n.title.trim()&&(t==="report"?!!n.author.trim()&&(!!n.url.trim()||!!n.doi.trim()):!!n.url.trim())&&(t!=="youtube"||!!n.author.trim()),p=async()=>{if(e){a(!0);try{const v=MNe({author:d.author,isOrganization:d.isOrganization,year:n.year}),b=t==="wikipedia"?"Wikipedia":t==="youtube"?"YouTube":n.siteName||null,w={type:t,method:"manual_citation",title:n.title.trim(),authors:_G(d.author,d.isOrganization),is_organization:!!d.isOrganization,date:{year:n.year||null,month:n.month||null,day:n.day||null},published_year:v.published_year,site_name:b,platform:t==="youtube"?"YouTube":t==="wikipedia"?"Wikipedia":null,report_number:t==="report"&&n.reportNumber||null,publisher:t==="report"&&n.publisher||null,url:n.url.trim()||null,doi:t==="report"&&n.doi.trim()||null,accessed_at:n.accessedAt||null},{error:j}=await pe.from("documents").insert({user_id:e,title:n.title.trim(),citation_apa:h.text,...v,external_url:n.url.trim()||null,landing_page_url:n.url.trim()||null,doi:w.doi,page_count:0,source_type:"standalone",external_source:N7t[t],bib_meta:w});if(j)throw j;Ke.success("Citation source created successfully!"),s(Dce),r()}catch(v){console.error("Standalone create error:",v),Ke.error("Failed to create citation source")}finally{a(!1)}}},m=async()=>{if(!e||!f)return;const v=await T2e(e,{url:n.url,doi:t==="report"?n.doi:""});v?c(v):p()},g=(v,b,w="",j={})=>o.jsxs("div",{className:j.full?"md:col-span-2":"",children:[o.jsx(Se,{children:b}),o.jsx(Ue,{value:n[v],onChange:N=>u(v,N.target.value),placeholder:w,type:j.type||"text",className:"mt-1"})]}),y=v=>o.jsxs("div",{className:"md:col-span-2",children:[o.jsx(Se,{children:v}),o.jsxs("div",{className:"mt-1 grid grid-cols-3 gap-2",children:[o.jsx(Ue,{value:n.year,onChange:b=>u("year",b.target.value),placeholder:"Year",type:"number"}),o.jsx(Ue,{value:n.month,onChange:b=>u("month",b.target.value),placeholder:"Month (1-12)",type:"number"}),o.jsx(Ue,{value:n.day,onChange:b=>u("day",b.target.value),placeholder:"Day",type:"number"})]})]}),x=(v,b=!0)=>o.jsxs("div",{className:"md:col-span-2",children:[o.jsx(Se,{children:v}),o.jsx(Ue,{value:n.author,onChange:w=>u("author",w.target.value),placeholder:n.isOrganization||!b?"Organization or channel name":"Last, F.; Last, F.",className:"mt-1"}),b&&o.jsxs("label",{className:"mt-2 flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx(aa,{checked:n.isOrganization,onCheckedChange:w=>u("isOrganization",!!w)}),"Author is an organization"]})]});return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[t==="webpage"&&o.jsxs(o.Fragment,{children:[x("Author or organization"),y("Publication date"),g("title","Page title *","Page title...",{full:!0}),g("siteName","Website name","e.g. BBC News"),g("url","URL *","https://..."),g("accessedAt","Retrieved date (optional)","",{type:"date"})]}),t==="wikipedia"&&o.jsxs(o.Fragment,{children:[g("title","Article title *","e.g. Burnout (psychology)",{full:!0}),y("Version / update date"),g("url","URL * (permanent version link recommended)","https://en.wikipedia.org/w/index.php?oldid=...",{full:!0}),g("accessedAt","Retrieved date (optional)","",{type:"date"})]}),t==="youtube"&&o.jsxs(o.Fragment,{children:[x("Channel / uploader *",!1),y("Publication date"),g("title","Video title *","Video title...",{full:!0}),g("url","URL *","https://www.youtube.com/watch?v=...",{full:!0})]}),t==="report"&&o.jsxs(o.Fragment,{children:[x("Author or organization *"),y("Publication date"),g("title","Report title *","Report title...",{full:!0}),g("reportNumber","Report number (optional)","e.g. 2024-03"),g("publisher","Publisher / institution","Institution name..."),g("url","URL","https://..."),g("doi","DOI","10.1000/example")]})]}),o.jsxs("div",{className:"rounded-lg border bg-muted/40 p-3",children:[o.jsx("div",{className:"mb-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"APA-7 preview"}),n.title.trim()?o.jsx("p",{className:"text-sm",dangerouslySetInnerHTML:{__html:h.html}}):o.jsx("p",{className:"text-sm text-muted-foreground",children:"Fill in the fields to see the citation."})]}),o.jsxs(me,{onClick:m,disabled:i||!f,className:"w-full",size:"lg",children:[i?o.jsx(Ei,{className:"mr-2 h-4 w-4 animate-spin"}):o.jsx(W2,{className:"mr-2 h-4 w-4"}),i?"Creating...":"Create Source Entry"]}),o.jsx(P2e,{duplicate:l,onCancel:()=>c(null),onConfirm:()=>{c(null),p()}})]})}const C2={title:"",authors:"",publisher:"",published_year:"",isbn:"",doi:"",edition:"",pages:"",language:"",series:"",type:"book"},C7t=()=>{const{user:t,userProfile:e,loading:r}=Ht(),n=Or(),[s]=uj(),i=s.get("document"),[a,l]=S.useState([]),[c,u]=S.useState(!0),[d,h]=S.useState(""),[f,p]=S.useState("all"),[m,g]=S.useState("newest"),[y,x]=S.useState(new Set),[v,b]=S.useState(!1),[w,j]=S.useState([]),[N,C]=S.useState(""),[A,E]=S.useState(""),[O,$]=S.useState(""),[T,M]=S.useState(!1),[k,D]=S.useState(null),[K,H]=S.useState(""),[ee,V]=S.useState(!1),[B,z]=S.useState(""),[F,G]=S.useState(!1),[Q,ie]=S.useState(""),[se,q]=S.useState(C2),[L,Z]=S.useState("manual_entry"),[J,W]=S.useState(!1),[X,he]=S.useState(C2),[P,oe]=S.useState(!1),[Y,R]=S.useState("book"),[I,U]=S.useState(null);S.useEffect(()=>{!t&&!r&&n("/login")},[t,r,n]),S.useEffect(()=>{t&&re()},[t]),S.useEffect(()=>{e!=null&&e.id&&ue()},[e==null?void 0:e.id]),S.useEffect(()=>{if(i&&w.length>0){const ye=w.find(Ne=>Ne.id===i);ye&&(C(i),E(ye.doi||""),$(ye.isbn||""))}},[i,w]);const re=async()=>{if(t){u(!0);try{const{data:ye,error:Ne}=await pe.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(Ne){console.error("Error fetching citations:",Ne);return}l(ye||[])}finally{u(!1)}}},ue=async()=>{try{const{data:ye,error:Ne}=await pe.from("documents").select("*").eq("user_id",e==null?void 0:e.id).order("created_at",{ascending:!1});if(Ne)throw Ne;j(ye||[])}catch(ye){console.error("Error loading documents:",ye),Ke.error("Error loading documents")}},ae=async()=>{var ye;if(!N){H("Please select a document");return}M(!0),H(""),D(null);try{const{data:Ne,error:Ce}=await pe.functions.invoke("detect_bibliography",{body:{document_id:N,force:!0,manual_doi:A.trim()||null,manual_isbn:O.trim()||null}});if(Ce)throw Ce;if(Ne!=null&&Ne.error)throw new Error(Ne.error);const{data:Fe,error:yt}=await pe.from("documents").select("*").eq("id",N).single();if(yt)throw yt;const He=Fe;D({citation_apa:He.citation_apa,doi:He.doi,isbn:He.isbn,bib_meta:He.bib_meta,source:((ye=He.bib_meta)==null?void 0:ye.method)||"unknown"}),Ke.success("Citation updated successfully"),j(Ye=>Ye.map(it=>it.id===N?He:it)),re()}catch(Ne){console.error("Reference check error:",Ne);const Ce=Ne.message||"Unknown error";Ce.includes("ISBN")||Ce.includes("isbn")?H("Invalid ISBN or no match found"):Ce.includes("DOI")||Ce.includes("doi")?H("Invalid DOI or no match found"):H(`Error: ${Ce}`)}finally{M(!1)}},ge=async()=>{var ye,Ne;if(!B.trim()){ie("Please paste some text first");return}G(!0),ie("");try{const{data:Ce,error:Fe}=await pe.functions.invoke("parse_bibliography_text",{body:{rawText:B.trim()}});if(Fe)throw Fe;if(Ce!=null&&Ce.error)throw new Error(Ce.error);const yt=Ce==null?void 0:Ce.data;yt&&(q({title:yt.title||"",authors:((ye=yt.authors)==null?void 0:ye.join(", "))||"",publisher:yt.publisher||"",published_year:((Ne=yt.published_year)==null?void 0:Ne.toString())||"",isbn:yt.isbn||"",doi:yt.doi||"",edition:yt.edition||"",pages:yt.pages||"",language:yt.language||"",series:yt.series||"",type:yt.type||"book"}),Z("parsed_paste"),Ke.success("Text successfully parsed!"))}catch(Ce){console.error("Parse error:",Ce),ie(Ce.message||"Failed to parse text")}finally{G(!1)}},we=async()=>{if(!N){Ke.error("Please select a document first");return}if(!se.title.trim()){Ke.error("Title is required");return}W(!0);try{const ye=se.authors.split(",").map(zt=>zt.trim()).filter(Boolean),Ne={title:se.title,authors:ye,publisher:se.publisher||null,published_year:parseInt(se.published_year)||null,edition:se.edition||null,pages:se.pages||null,language:se.language||null,series:se.series||null,type:se.type||"book",method:L},Ce=ye.length?ye.join(", "):"Unknown Author",Fe=se.published_year?`(${se.published_year})`:"(n.d.)",yt=se.publisher?`. ${se.publisher}`:"",He=`${Ce} ${Fe}. ${se.title}${yt}.`,{error:Ye}=await pe.from("documents").update({bib_meta:Ne,citation_apa:He,isbn:se.isbn||null,doi:se.doi||null,title:se.title}).eq("id",N);if(Ye)throw Ye;const{data:it}=await pe.from("documents").select("*").eq("id",N).single();it&&(j(zt=>zt.map(Xt=>Xt.id===N?it:Xt)),D({citation_apa:He,doi:se.doi,isbn:se.isbn,bib_meta:Ne,source:L})),Ke.success("Metadata applied successfully!"),q(C2),z(""),re()}catch(ye){console.error("Apply error:",ye),Ke.error("Failed to apply metadata")}finally{W(!1)}},ce=(ye,Ne)=>{q(Ce=>({...Ce,[ye]:Ne})),Z("manual_entry")},ne=(ye,Ne)=>{he(Ce=>({...Ce,[ye]:Ne}))},fe=async(ye=!1)=>{if(!X.title.trim()){Ke.error("Title is required");return}if(t){if(!ye&&(X.doi.trim()||X.isbn.trim())){const Ne=await T2e(t.id,{doi:X.doi,isbn:X.isbn});if(Ne){U(Ne);return}}oe(!0);try{const Ne=X.authors.split(",").map(zt=>zt.trim()).filter(Boolean),Ce={title:X.title,authors:Ne,publisher:X.publisher||null,published_year:parseInt(X.published_year)||null,edition:X.edition||null,pages:X.pages||null,language:X.language||null,series:X.series||null,type:X.type||"book",method:"manual_citation"},Fe=Ne.length?Ne.join(", "):"Unknown Author",yt=X.published_year?`(${X.published_year})`:"(n.d.)",He=X.publisher?`. ${X.publisher}`:"",Ye=`${Fe} ${yt}. ${X.title}${He}.`,{error:it}=await pe.from("documents").insert({user_id:t.id,title:X.title,bib_meta:Ce,citation_apa:Ye,isbn:X.isbn||null,doi:X.doi||null,page_count:0,source_type:"standalone",...MNe({author:Ne.join("; "),year:X.published_year})});if(it)throw it;Ke.success("Citation source created successfully!"),he(C2),await ue(),re()}catch(Ne){console.error("Error creating citation-only entry:",Ne),Ke.error("Failed to create citation source")}finally{oe(!1)}}},be=async()=>{if(k!=null&&k.citation_apa)try{await navigator.clipboard.writeText(k.citation_apa),V(!0),Ke.success("Citation copied to clipboard"),setTimeout(()=>V(!1),2e3)}catch{Ke.error("Failed to copy")}},xe=w.find(ye=>ye.id===N),_e=ye=>{var Ce,Fe,yt,He,Ye;const Ne=(ye==null?void 0:ye.authors)||((Ce=ye==null?void 0:ye.crossref_data)==null?void 0:Ce.authors)||((Fe=ye==null?void 0:ye.crossref_payload)==null?void 0:Fe.author)||((He=(yt=ye==null?void 0:ye.crossref_data)==null?void 0:yt.crossref_metadata)==null?void 0:He.author)||((Ye=ye==null?void 0:ye.google_books_data)==null?void 0:Ye.authors)||[];return Array.isArray(Ne)?Ne.map(it=>typeof it=="string"?it:`${(it==null?void 0:it.family)||""} ${(it==null?void 0:it.given)||""}`.trim()).join(" "):""},ke=ye=>{var Fe,yt,He,Ye,it,zt,Xt;const Ne=ye.bib_meta,Ce=[Ne==null?void 0:Ne.title,(Fe=Ne==null?void 0:Ne.crossref_data)==null?void 0:Fe.title,(He=(yt=Ne==null?void 0:Ne.crossref_data)==null?void 0:yt.crossref_metadata)==null?void 0:He.title,(Ye=Ne==null?void 0:Ne.google_books_data)==null?void 0:Ye.title,(zt=(it=Ne==null?void 0:Ne.crossref_payload)==null?void 0:it.title)==null?void 0:zt[0]];for(const Mr of Ce){if(Mr&&typeof Mr=="string"&&Mr.trim())return Mr.trim().toLowerCase();if(Array.isArray(Mr)&&((Xt=Mr[0])!=null&&Xt.trim()))return Mr[0].trim().toLowerCase()}return(ye.title||ye.original_filename||"").toLowerCase()},$e=ye=>{var Fe,yt,He,Ye,it,zt,Xt,Mr,ur,Fr,Kr;if(!ye)return null;const Ne=ye.published_year||ye.year||((Fe=ye.crossref_data)==null?void 0:Fe.year)||((zt=(it=(Ye=(He=(yt=ye.crossref_data)==null?void 0:yt.crossref_metadata)==null?void 0:He.issued)==null?void 0:Ye["date-parts"])==null?void 0:it[0])==null?void 0:zt[0])||((Fr=(ur=(Mr=(Xt=ye.crossref_payload)==null?void 0:Xt.issued)==null?void 0:Mr["date-parts"])==null?void 0:ur[0])==null?void 0:Fr[0]);if(Ne)return Number(Ne);const Ce=(Kr=ye.google_books_data)==null?void 0:Kr.publishedDate;return Ce?parseInt(String(Ce).substring(0,4)):null},Te=ye=>{var Ne,Ce;return((ye==null?void 0:ye.type)||((Ne=ye==null?void 0:ye.crossref_data)==null?void 0:Ne.type)||((Ce=ye==null?void 0:ye.crossref_payload)==null?void 0:Ce.type)||"").toLowerCase().replace(/-/g," ")},ot=S.useMemo(()=>{const ye=new Set;return a.forEach(Ne=>{const Ce=Te(Ne.bib_meta);Ce&&ye.add(Ce)}),Array.from(ye).sort()},[a]),wt=S.useMemo(()=>{let ye=a;if(d){const Ne=d.toLowerCase();ye=ye.filter(Ce=>{const Fe=ke(Ce),yt=_e(Ce.bib_meta).toLowerCase(),He=(Ce.doi||"").toLowerCase(),Ye=(Ce.isbn||"").toLowerCase();return Fe.includes(Ne)||yt.includes(Ne)||He.includes(Ne)||Ye.includes(Ne)})}return f!=="all"&&(ye=ye.filter(Ne=>Te(Ne.bib_meta)===f)),ye=[...ye].sort((Ne,Ce)=>{if(m==="newest")return new Date(Ce.created_at).getTime()-new Date(Ne.created_at).getTime();if(m==="alphabetical")return ke(Ne).localeCompare(ke(Ce));const Fe=$e(Ne.bib_meta)||0;return($e(Ce.bib_meta)||0)-Fe}),ye},[a,d,f,m]),Ct=(ye,Ne)=>{x(Ce=>{const Fe=new Set(Ce);return Ne?Fe.add(ye):Fe.delete(ye),Fe})},pr=()=>{wt.length!==0&&(L7(wt,"all-citations.ris"),Ke.success(`Exported ${wt.length} citations`))},Kt=()=>{const ye=wt.filter(Ne=>y.has(Ne.id));if(ye.length===0){Ke.error("No citations selected");return}L7(ye,"selected-citations.ris"),Ke.success(`Exported ${ye.length} citations`)};if(r||c)return o.jsx(Cr,{showSidebar:!0,pageTitle:"My Citations",children:o.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-4"}),o.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})})});if(!t)return null;const Re=(ye,Ne)=>o.jsxs(pt,{value:ye,onValueChange:Ne,children:[o.jsx(ut,{className:"mt-1",children:o.jsx(mt,{placeholder:"Select language..."})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"German",children:"German"}),o.jsx(Le,{value:"English",children:"English"}),o.jsx(Le,{value:"French",children:"French"}),o.jsx(Le,{value:"Spanish",children:"Spanish"}),o.jsx(Le,{value:"Italian",children:"Italian"}),o.jsx(Le,{value:"Other",children:"Other"})]})]});return o.jsx(Cr,{showSidebar:!0,pageTitle:"My Citations",children:o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[o.jsx("div",{children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl border bg-primary/5 text-primary",children:o.jsx(nr,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"My Citations"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage, improve, and export your bibliographic sources."})]})]})}),o.jsxs(me,{onClick:()=>b(ye=>!ye),className:"gap-2 sm:mt-1",children:[o.jsx(W2,{className:"h-4 w-4"}),v?"Close citation tools":"Add / fix citation"]})]}),o.jsx(Vh,{open:v,onOpenChange:b,children:o.jsx(qh,{children:o.jsxs(Ze,{className:"overflow-hidden border-border/70 shadow-sm",children:[o.jsx(Ot,{className:"border-b bg-muted/20 pb-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(nr,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx(Ft,{className:"text-base",children:"Citation tools"}),o.jsx(Es,{children:"Start with automatic detection. Use paste or manual entry only when needed."})]})]})}),o.jsxs(st,{className:"space-y-5 p-5",children:[o.jsxs("section",{className:"space-y-4 rounded-xl border border-border/70 bg-background p-4",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold",children:"1. Check an existing document"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Recommended: let Academly detect and refresh the bibliographic metadata."})]}),o.jsx(kt,{variant:"secondary",className:"shrink-0",children:"Recommended"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"document-select",children:"Document"}),o.jsxs(pt,{value:N,onValueChange:C,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select a document..."})}),o.jsx(dt,{children:w.map(ye=>o.jsx(Le,{value:ye.id,children:o.jsx("span",{className:"font-medium",children:ye.title||ye.original_filename||"Untitled"})},ye.id))})]})]}),xe&&(()=>{var Vv,du,hu,Td,vl,gi,Pd,EA,Dj,AA,Lj,fu;const ye=xe.bib_meta,Ne=ye==null?void 0:ye.google_books_data,Ce=(ye==null?void 0:ye.crossref_payload)||((Vv=ye==null?void 0:ye.crossref_data)==null?void 0:Vv.crossref_metadata),Fe=ye==null?void 0:ye.crossref_data,yt=(ye==null?void 0:ye.title)||(Fe==null?void 0:Fe.title)||xe.title||xe.original_filename||"No title",He=(ye==null?void 0:ye.type)||(Ce==null?void 0:Ce.type),Ye=((du=ye==null?void 0:ye.authors)==null?void 0:du.join(", "))||((hu=Fe==null?void 0:Fe.authors)==null?void 0:hu.join(", "))||((Td=Ne==null?void 0:Ne.authors)==null?void 0:Td.join(", "))||((vl=Ce==null?void 0:Ce.author)==null?void 0:vl.map(pc=>`${pc.family}, ${pc.given}`).join("; ")),it=(ye==null?void 0:ye.publisher)||(Fe==null?void 0:Fe.publisher)||(Ne==null?void 0:Ne.publisher)||(Ce==null?void 0:Ce.publisher),zt=(ye==null?void 0:ye.published_year)||(Fe==null?void 0:Fe.year)||((gi=Ne==null?void 0:Ne.publishedDate)==null?void 0:gi.substring(0,4))||((Dj=(EA=(Pd=Ce==null?void 0:Ce.issued)==null?void 0:Pd["date-parts"])==null?void 0:EA[0])==null?void 0:Dj[0]),Xt=ye==null?void 0:ye.edition,Mr=(ye==null?void 0:ye.pages)||(Fe==null?void 0:Fe.pages)||(Ne==null?void 0:Ne.pageCount)||(Ce==null?void 0:Ce.page),ur=(ye==null?void 0:ye.language)||(Ne==null?void 0:Ne.language),Fr=ye==null?void 0:ye.series,Kr=xe.isbn||(ye==null?void 0:ye.isbn)||((Lj=(AA=Ne==null?void 0:Ne.industryIdentifiers)==null?void 0:AA.find(pc=>pc.type==="ISBN_13"))==null?void 0:Lj.identifier),ct=xe.doi||(ye==null?void 0:ye.doi)||(Fe==null?void 0:Fe.doi),xn=ye==null?void 0:ye.method,Qn=xn==="manual_entry"?"Manual Entry":xn==="parsed_paste"?"Parsed Paste":xn==="manual_input"?"Manual Input":xn||null,as=(Fe==null?void 0:Fe.journal)||((fu=Ce==null?void 0:Ce["container-title"])==null?void 0:fu[0]),Lf=(Fe==null?void 0:Fe.volume)||(Ce==null?void 0:Ce.volume),$f=(Fe==null?void 0:Fe.issue)||(Ce==null?void 0:Ce.issue),Wv=[{label:"Title",value:yt},He&&{label:"Type",value:He.charAt(0).toUpperCase()+He.slice(1)},Ye&&{label:"Author(s)",value:Ye},it&&{label:"Publisher",value:it},zt&&{label:"Published",value:String(zt)},Xt&&{label:"Edition",value:Xt},as&&{label:"Journal",value:as},Lf&&{label:"Volume",value:`${Lf}${$f?` (${$f})`:""}`},Mr&&{label:"Pages",value:String(Mr)},ur&&{label:"Language",value:ur.charAt(0).toUpperCase()+ur.slice(1)},Fr&&{label:"Series",value:Fr},Kr&&{label:"ISBN",value:Kr},ct&&{label:"DOI",value:ct},Qn&&{label:"Source",value:Qn}].filter(Boolean);return o.jsxs("div",{className:"p-4 bg-muted/50 rounded-xl border border-border/50",children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("span",{className:"text-sm font-semibold",children:"Current Status"}),o.jsx("div",{children:xe.citation_apa?o.jsxs(kt,{className:"bg-success/20 text-success hover:bg-success/30",children:[o.jsx(kr,{className:"w-3 h-3 mr-1"}),"Citation Available"]}):o.jsxs(kt,{variant:"destructive",className:"bg-destructive/20 text-destructive hover:bg-destructive/30",children:[o.jsx(fn,{className:"w-3 h-3 mr-1"}),"Citation Missing"]})})]}),o.jsx("div",{className:"grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5",children:Wv.map(pc=>o.jsxs("div",{className:"contents",children:[o.jsxs("span",{className:"text-xs text-muted-foreground py-0.5",children:[pc.label,":"]}),o.jsx("span",{className:"text-sm font-medium py-0.5 break-words",children:pc.value})]},pc.label))})]})})(),o.jsxs("div",{className:"pt-4 border-t border-border/50",children:[o.jsx(Se,{className:"text-sm font-medium mb-3 block",children:"Manual Override (Optional)"}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"doi",className:"text-xs text-muted-foreground",children:"DOI"}),o.jsx(Ue,{id:"doi",value:A,onChange:ye=>E(ye.target.value),placeholder:"10.1000/example",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"isbn",className:"text-xs text-muted-foreground",children:"ISBN"}),o.jsx(Ue,{id:"isbn",value:O,onChange:ye=>$(ye.target.value),placeholder:"978-3-16-148410-0",className:"mt-1"})]})]})]}),o.jsx(me,{onClick:ae,disabled:T||!N,className:"w-full",size:"lg",children:T?o.jsxs(o.Fragment,{children:[o.jsx(Ei,{className:"w-4 h-4 mr-2 animate-spin"}),"Checking document..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Ti,{className:"w-4 h-4 mr-2"}),"Check Document"]})}),K&&o.jsxs("div",{className:"flex items-center gap-2 p-4 bg-destructive/10 border border-destructive/20 rounded-lg",children:[o.jsx(af,{className:"w-4 h-4 text-destructive shrink-0"}),o.jsx("span",{className:"text-sm text-destructive",children:K})]})]}),o.jsx(Vh,{children:o.jsxs("div",{className:"rounded-xl border border-border/70 bg-background",children:[o.jsx(Qy,{asChild:!0,children:o.jsxs(me,{variant:"ghost",className:"h-auto w-full justify-between rounded-xl px-4 py-3 text-left",children:[o.jsxs("span",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-muted",children:o.jsx(l4,{className:"h-4 w-4"})}),o.jsxs("span",{children:[o.jsx("span",{className:"block text-sm font-semibold",children:"2. Paste or enter metadata"}),o.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:"Use this when automatic detection is incomplete."})]})]}),o.jsx(ia,{className:"h-4 w-4 text-muted-foreground"})]})}),o.jsxs(qh,{className:"border-t px-4 pb-4 pt-4",children:[o.jsxs("div",{children:[o.jsx(Se,{htmlFor:"manual-document-select",children:"Target Document"}),o.jsxs(pt,{value:N,onValueChange:C,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select a document to apply data..."})}),o.jsx(dt,{children:w.map(ye=>o.jsx(Le,{value:ye.id,children:o.jsx("span",{className:"font-medium",children:ye.title||ye.original_filename||"Untitled"})},ye.id))})]}),!N&&o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Select a document to apply bibliographic data"})]}),o.jsxs(VR,{defaultValue:"quick-paste",className:"w-full",children:[o.jsxs(bk,{className:"grid w-full grid-cols-2",children:[o.jsxs(Fh,{value:"quick-paste",className:"flex items-center gap-2",children:[o.jsx(l4,{className:"w-4 h-4"}),"Quick Paste"]}),o.jsxs(Fh,{value:"manual-fields",className:"flex items-center gap-2",children:[o.jsx(wMe,{className:"w-4 h-4"}),"Manual Fields"]})]}),o.jsxs(hv,{value:"quick-paste",className:"space-y-4 mt-4",children:[o.jsxs("div",{children:[o.jsx(Se,{children:"Paste Raw Text"}),o.jsx(lr,{value:B,onChange:ye=>z(ye.target.value),placeholder:"Paste bibliographic data from Amazon, Google Books, library catalogs, etc...",className:"min-h-[120px] mt-1"}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Example: ISBN978-3-411-87151-3VerlagDuden..."})]}),o.jsx(me,{onClick:ge,disabled:F||!B.trim(),className:"w-full",children:F?o.jsxs(o.Fragment,{children:[o.jsx(Ei,{className:"w-4 h-4 mr-2 animate-spin"}),"Parsing..."]}):o.jsxs(o.Fragment,{children:[o.jsx(l4,{className:"w-4 h-4 mr-2"}),"Parse Text"]})}),Q&&o.jsxs("div",{className:"flex items-center gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-lg",children:[o.jsx(af,{className:"w-4 h-4 text-destructive shrink-0"}),o.jsx("span",{className:"text-sm text-destructive",children:Q})]}),(se.title||se.authors||se.publisher)&&o.jsxs("div",{className:"p-4 bg-muted/50 rounded-xl border border-border/50 space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx(kr,{className:"w-4 h-4 text-success"}),o.jsx("span",{className:"text-sm font-medium",children:"Parsed Result (editable)"})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"Title *"}),o.jsx(Ue,{value:se.title,onChange:ye=>ce("title",ye.target.value),placeholder:"Enter title...",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"Authors (comma-separated)"}),o.jsx(Ue,{value:se.authors,onChange:ye=>ce("authors",ye.target.value),placeholder:"Author 1, Author 2...",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"Publisher"}),o.jsx(Ue,{value:se.publisher,onChange:ye=>ce("publisher",ye.target.value),className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"Year"}),o.jsx(Ue,{value:se.published_year,onChange:ye=>ce("published_year",ye.target.value),placeholder:"2023",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"ISBN"}),o.jsx(Ue,{value:se.isbn,onChange:ye=>ce("isbn",ye.target.value),className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"DOI"}),o.jsx(Ue,{value:se.doi,onChange:ye=>ce("doi",ye.target.value),className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"Edition"}),o.jsx(Ue,{value:se.edition,onChange:ye=>ce("edition",ye.target.value),className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"Pages"}),o.jsx(Ue,{value:se.pages,onChange:ye=>ce("pages",ye.target.value),className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"Language"}),Re(se.language,ye=>ce("language",ye))]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-xs",children:"Series"}),o.jsx(Ue,{value:se.series,onChange:ye=>ce("series",ye.target.value),className:"mt-1"})]})]}),o.jsx(me,{onClick:we,disabled:J||!N||!se.title.trim(),className:"w-full mt-4",children:J?o.jsxs(o.Fragment,{children:[o.jsx(Ei,{className:"w-4 h-4 mr-2 animate-spin"}),"Applying..."]}):o.jsxs(o.Fragment,{children:[o.jsx(kr,{className:"w-4 h-4 mr-2"}),"Apply to Document"]})})]})]}),o.jsxs(hv,{value:"manual-fields",className:"space-y-4 mt-4",children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"md:col-span-2",children:[o.jsx(Se,{children:"Title *"}),o.jsx(Ue,{value:se.title,onChange:ye=>ce("title",ye.target.value),placeholder:"Book or article title...",className:"mt-1"})]}),o.jsxs("div",{className:"md:col-span-2",children:[o.jsx(Se,{children:"Authors (comma-separated)"}),o.jsx(Ue,{value:se.authors,onChange:ye=>ce("authors",ye.target.value),placeholder:"Last, First; Last, First...",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Publisher"}),o.jsx(Ue,{value:se.publisher,onChange:ye=>ce("publisher",ye.target.value),placeholder:"Publisher name...",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Year"}),o.jsx(Ue,{value:se.published_year,onChange:ye=>ce("published_year",ye.target.value),placeholder:"2023",type:"number",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"ISBN"}),o.jsx(Ue,{value:se.isbn,onChange:ye=>ce("isbn",ye.target.value),placeholder:"978-3-16-148410-0",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"DOI"}),o.jsx(Ue,{value:se.doi,onChange:ye=>ce("doi",ye.target.value),placeholder:"10.1000/example",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Edition"}),o.jsx(Ue,{value:se.edition,onChange:ye=>ce("edition",ye.target.value),placeholder:"4th edition",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Pages"}),o.jsx(Ue,{value:se.pages,onChange:ye=>ce("pages",ye.target.value),placeholder:"136",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Language"}),Re(se.language,ye=>ce("language",ye))]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Series"}),o.jsx(Ue,{value:se.series,onChange:ye=>ce("series",ye.target.value),placeholder:"Book series name...",className:"mt-1"})]})]}),o.jsx(me,{onClick:we,disabled:J||!N||!se.title.trim(),className:"w-full",size:"lg",children:J?o.jsxs(o.Fragment,{children:[o.jsx(Ei,{className:"w-4 h-4 mr-2 animate-spin"}),"Applying..."]}):o.jsxs(o.Fragment,{children:[o.jsx(kr,{className:"w-4 h-4 mr-2"}),"Apply to Document"]})})]})]})]})]})}),o.jsx(Vh,{children:o.jsxs("div",{className:"rounded-xl border border-border/70 bg-background",children:[o.jsx(Qy,{asChild:!0,children:o.jsxs(me,{variant:"ghost",className:"h-auto w-full justify-between rounded-xl px-4 py-3 text-left",children:[o.jsxs("span",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-muted",children:o.jsx(W2,{className:"h-4 w-4"})}),o.jsxs("span",{children:[o.jsx("span",{className:"block text-sm font-semibold",children:"3. Create a standalone source"}),o.jsx("span",{className:"block text-xs font-normal text-muted-foreground",children:"For books, articles, or sources without a PDF in your library."})]})]}),o.jsx(ia,{className:"h-4 w-4 text-muted-foreground"})]})}),o.jsxs(qh,{className:"border-t px-4 pb-4 pt-4",children:[o.jsxs("div",{className:"mb-4",children:[o.jsx(Se,{children:"Source type"}),o.jsxs(pt,{value:Y,onValueChange:ye=>R(ye),children:[o.jsx(ut,{className:"mt-1",children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"book",children:"Book / Article"}),o.jsx(Le,{value:"webpage",children:"Web page"}),o.jsx(Le,{value:"wikipedia",children:"Wikipedia"}),o.jsx(Le,{value:"youtube",children:"YouTube video"}),o.jsx(Le,{value:"report",children:"Report"})]})]})]}),Y!=="book"?o.jsx(k7t,{type:Y,userId:t==null?void 0:t.id,onCreated:async()=>{await ue(),re()}},Y):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[o.jsxs("div",{className:"md:col-span-2",children:[o.jsx(Se,{children:"Title *"}),o.jsx(Ue,{value:X.title,onChange:ye=>ne("title",ye.target.value),placeholder:"Book or article title...",className:"mt-1"})]}),o.jsxs("div",{className:"md:col-span-2",children:[o.jsx(Se,{children:"Authors (comma-separated)"}),o.jsx(Ue,{value:X.authors,onChange:ye=>ne("authors",ye.target.value),placeholder:"Last, First; Last, First...",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Publisher"}),o.jsx(Ue,{value:X.publisher,onChange:ye=>ne("publisher",ye.target.value),placeholder:"Publisher name...",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Year"}),o.jsx(Ue,{value:X.published_year,onChange:ye=>ne("published_year",ye.target.value),placeholder:"2023",type:"number",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"ISBN"}),o.jsx(Ue,{value:X.isbn,onChange:ye=>ne("isbn",ye.target.value),placeholder:"978-3-16-148410-0",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"DOI"}),o.jsx(Ue,{value:X.doi,onChange:ye=>ne("doi",ye.target.value),placeholder:"10.1000/example",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Edition"}),o.jsx(Ue,{value:X.edition,onChange:ye=>ne("edition",ye.target.value),placeholder:"4th edition",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Pages"}),o.jsx(Ue,{value:X.pages,onChange:ye=>ne("pages",ye.target.value),placeholder:"136",className:"mt-1"})]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Language"}),Re(X.language,ye=>ne("language",ye))]}),o.jsxs("div",{children:[o.jsx(Se,{children:"Series"}),o.jsx(Ue,{value:X.series,onChange:ye=>ne("series",ye.target.value),placeholder:"Book series name...",className:"mt-1"})]})]}),o.jsx(me,{onClick:()=>fe(),disabled:P||!X.title.trim(),className:"w-full",size:"lg",children:P?o.jsxs(o.Fragment,{children:[o.jsx(Ei,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(W2,{className:"w-4 h-4 mr-2"}),"Create Source Entry"]})})]}),o.jsx(P2e,{duplicate:I,onCancel:()=>U(null),onConfirm:()=>{U(null),fe(!0)}})]})]})})]})]})})}),k&&o.jsxs(Ze,{children:[o.jsxs(Ot,{children:[o.jsxs(Ft,{className:"flex items-center gap-2",children:[o.jsx(kr,{className:"w-5 h-5 text-success"}),"Result"]}),o.jsx(Es,{children:"Citation has been successfully updated"})]}),o.jsxs(st,{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx(Se,{className:"text-base font-semibold",children:"APA Citation"}),o.jsxs(me,{variant:"outline",size:"sm",onClick:be,disabled:!k.citation_apa,children:[o.jsx(ws,{className:"w-4 h-4 mr-2"}),ee?"Copied!":"Copy"]})]}),o.jsx("div",{className:"p-4 bg-muted rounded-lg",children:o.jsx("p",{className:"text-sm leading-relaxed font-medium",children:k.citation_apa||"No citation available"})})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[o.jsxs("div",{children:[o.jsx(Se,{className:"text-sm",children:"Source"}),o.jsx("div",{className:"mt-1",children:o.jsx(kt,{variant:"secondary",children:k.source==="pdf_metadata_and_text_analysis"?"PDF Analysis":k.source==="google_books"?"Google Books":k.source==="open_library"?"Open Library":k.source==="crossref"?"CrossRef":k.source==="parsed_paste"?"Parsed Paste":k.source==="manual_entry"?"Manual Entry":k.source||"Unknown"})})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-sm",children:"DOI"}),o.jsx("p",{className:"text-sm mt-1",children:k.doi||"–"})]}),o.jsxs("div",{children:[o.jsx(Se,{className:"text-sm",children:"ISBN"}),o.jsx("p",{className:"text-sm mt-1",children:k.isbn||"–"})]})]}),k.bib_meta&&o.jsxs(Vh,{children:[o.jsx(Qy,{asChild:!0,children:o.jsxs(me,{variant:"ghost",size:"sm",className:"w-full justify-between",children:[o.jsx("span",{children:"Show Raw JSON Metadata"}),o.jsx(ia,{className:"w-4 h-4"})]})}),o.jsx(qh,{children:o.jsx("div",{className:"mt-2 p-4 bg-muted rounded-lg",children:o.jsx("pre",{className:"text-xs overflow-auto max-h-64",children:JSON.stringify(k.bib_meta,null,2)})})})]})]})]}),o.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border/70 bg-card p-3 sm:flex-row sm:flex-wrap",children:[o.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[o.jsx(Ti,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),o.jsx(Ue,{placeholder:"Search title, author, DOI, ISBN…",value:d,onChange:ye=>h(ye.target.value),className:"pl-9"})]}),o.jsxs(pt,{value:f,onValueChange:p,children:[o.jsx(ut,{className:"w-[160px]",children:o.jsx(mt,{placeholder:"All types"})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"all",children:"All types"}),ot.map(ye=>o.jsx(Le,{value:ye,className:"capitalize",children:ye},ye))]})]}),o.jsxs(pt,{value:m,onValueChange:ye=>g(ye),children:[o.jsx(ut,{className:"w-[150px]",children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"newest",children:"Newest first"}),o.jsx(Le,{value:"alphabetical",children:"A → Z"}),o.jsx(Le,{value:"year",children:"Year (desc)"})]})]}),o.jsxs("div",{className:"flex gap-2 ml-auto",children:[o.jsxs(br,{children:[o.jsx(wr,{asChild:!0,children:o.jsxs(me,{variant:"outline",size:"sm",onClick:pr,disabled:wt.length===0,children:[o.jsx(ko,{className:"w-4 h-4 mr-1"}),"Export all"]})}),o.jsxs(xr,{className:"flex items-start gap-1.5 max-w-[220px]",children:[o.jsx(lf,{className:"w-3.5 h-3.5 mt-0.5 flex-shrink-0"}),o.jsx("span",{children:"In Zotero: File → Import → select the .ris file"})]})]}),o.jsxs(me,{variant:"outline",size:"sm",onClick:Kt,disabled:y.size===0,children:[o.jsx(ko,{className:"w-4 h-4 mr-1"}),"Export selected (",y.size,")"]})]})]}),wt.length===0?o.jsxs("div",{className:"min-h-[40vh] flex flex-col items-center justify-center text-center",children:[o.jsx(jr,{className:"w-12 h-12 text-muted-foreground/40 mb-4"}),o.jsx("h3",{className:"text-lg font-medium text-foreground mb-1",children:"No citations yet"}),o.jsx("p",{className:"text-muted-foreground text-sm max-w-md",children:"Upload documents to your library first. Bibliographic metadata will be extracted automatically."})]}):o.jsx("div",{className:"overflow-hidden rounded-xl border border-border/70 bg-card",children:o.jsxs(_d,{className:"table-fixed",children:[o.jsx(Nd,{className:"bg-muted/30",children:o.jsxs(fi,{children:[o.jsx(tr,{className:"w-8"}),o.jsx(tr,{className:"w-[58%] text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Citation"}),o.jsx(tr,{className:"w-[22%] text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Details"}),o.jsx(tr,{className:"w-[20%] text-right text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Actions"})]})}),o.jsx(kd,{children:wt.map(ye=>o.jsx(_7t,{doc:ye,selected:y.has(ye.id),onSelectionChange:Ct},ye.id))})]})})]})})},S6=768;function E7t(){const[t,e]=S.useState(void 0);return S.useEffect(()=>{const r=window.matchMedia(`(max-width: ${S6-1}px)`),n=()=>{e(window.innerWidth<S6)};return r.addEventListener("change",n),e(window.innerWidth<S6),()=>r.removeEventListener("change",n)},[]),!!t}const A7t=["How well am I answering my research questions?","What is still missing in my thesis?","Can you review my discussion?"];function T7t(){var M;const{user:t}=Ht(),e=E7t(),[r,n]=S.useState([]),[s,i]=S.useState(""),[a,l]=S.useState([]),[c,u]=S.useState(null),[d,h]=S.useState([]),[f,p]=S.useState(""),[m,g]=S.useState(!1),[y,x]=S.useState(!1),v=S.useRef(null),[b,w]=S.useState(null),j=S.useRef(null);S.useEffect(()=>{if(!t)return;(async()=>{const{data:D}=await pe.from("theses").select("id, title").order("created_at",{ascending:!1});D&&D.length>0&&(n(D),i(D[0].id))})()},[t]),S.useEffect(()=>{if(!s)return;(async()=>{const{data:D}=await pe.from("supervisor_chats").select("id, title, messages, created_at, updated_at").eq("thesis_id",s).order("updated_at",{ascending:!1});l(D||[]),u(null),h([])})()},[s]),S.useEffect(()=>{var k;(k=v.current)==null||k.scrollIntoView({behavior:"smooth"})},[d]);const N=k=>{u(k.id),h(k.messages||[]),x(!1)},C=()=>{u(null),h([]),p(""),x(!1)},A=S.useCallback(async k=>{if(!k.trim()||!s||!t||m)return;const D={role:"user",content:k.trim(),timestamp:new Date().toISOString()},K=[...d,D];h(K),p(""),g(!0);try{const{data:H,error:ee}=await pe.functions.invoke("supervisor_chat",{body:{thesis_id:s,message:D.content,chat_history:d.map(z=>({role:z.role,content:z.content})),language:"en",attachment:b??null}});if(ee)throw ee;w(null);const V={role:"assistant",content:(H==null?void 0:H.message)||"Keine Antwort erhalten.",timestamp:new Date().toISOString()},B=[...K,V];if(h(B),c)await pe.from("supervisor_chats").update({messages:B,updated_at:new Date().toISOString()}).eq("id",c),l(z=>z.map(F=>F.id===c?{...F,messages:B,updated_at:new Date().toISOString()}:F));else{const z=D.content.substring(0,50),{data:F}=await pe.from("supervisor_chats").insert({user_id:t.id,thesis_id:s,title:z,messages:B}).select("id").single();F&&(u(F.id),l(G=>[{id:F.id,title:z,messages:B,created_at:new Date().toISOString(),updated_at:new Date().toISOString()},...G]))}}catch(H){Ke.error("Fehler: "+(H.message||"Unbekannter Fehler"))}finally{g(!1)}},[d,s,t,m,c]),E=k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),A(f))},O=async k=>{var H;const D=(H=k.target.files)==null?void 0:H[0];if(!D)return;if(D.size>10*1024*1024){Ke.error("Datei zu groß – maximum 10MB");return}const K=new FileReader;K.onload=()=>{const ee=K.result.split(",")[1];w({name:D.name,base64:ee,type:D.type}),Ke.success(`${D.name} attached`)},K.readAsDataURL(D)},$=o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:"text-sm font-medium text-muted-foreground mb-1.5 block",children:"Thesis"}),o.jsxs(pt,{value:s,onValueChange:i,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select thesis…"})}),o.jsx(dt,{children:r.map(k=>o.jsx(Le,{value:k.id,children:k.title},k.id))})]})]}),o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Vergangene Chats"}),o.jsx(Am,{className:"flex-1",children:o.jsxs("div",{className:"space-y-1",children:[a.map(k=>o.jsxs("button",{onClick:()=>N(k),className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors flex items-center gap-2 ${c===k.id?"bg-primary/10 text-primary":"hover:bg-muted text-foreground"}`,children:[o.jsx(HM,{className:"w-3.5 h-3.5 flex-shrink-0 opacity-50"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"truncate text-xs font-medium leading-tight",children:k.title||"Untitled"}),o.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:d1(new Date(k.updated_at),"dd.MM. HH:mm")})]})]},k.id)),a.length===0&&s&&o.jsx("p",{className:"text-sm text-muted-foreground px-3 py-4",children:"Noch keine Chats."})]})})]}),o.jsxs(me,{variant:"outline",className:"w-full",onClick:C,children:[o.jsx(Bs,{className:"w-4 h-4 mr-2"})," New Chat"]})]}),T=k=>{if(!(k.includes("✓")||k.includes("✗")||k.includes("→")))return o.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:o.jsx(rc,{components:{p:({children:F,...G})=>{var se;const Q=Array.isArray(F)?F:[F];return Q.length===1&&typeof Q[0]=="object"&&((se=Q[0])==null?void 0:se.type)==="strong"?o.jsx("p",{className:"font-semibold text-sm mt-5 mb-1.5",...G,children:F}):o.jsx("p",{className:"mb-2.5 leading-relaxed",...G,children:F})},a:({href:F,children:G})=>o.jsx("a",{target:"_blank",rel:"noopener noreferrer",className:"text-primary underline underline-offset-2 hover:opacity-80 transition-opacity",children:G}),hr:()=>null},children:k})});const K=[],H=k.split(`
`);let ee={type:"",lines:[]};const V=[];let B=!1;for(const F of H)F.startsWith("✓")||F.includes("Was gut ist")?(ee.lines.length&&K.push(ee),ee={type:"good",lines:[F.replace(/^✓\s*\*?\*?Was gut ist\*?\*?:?\s*/i,"").replace(/^✓\s*/,"")]},B=!0):F.startsWith("✗")||F.includes("Was verbessert")?(ee.lines.length&&K.push(ee),ee={type:"improve",lines:[F.replace(/^✗\s*\*?\*?Was verbessert werden muss\*?\*?:?\s*/i,"").replace(/^✗\s*/,"")]},B=!0):F.startsWith("→")||F.includes("Nächster")?(ee.lines.length&&K.push(ee),ee={type:"next",lines:[F.replace(/^→\s*\*?\*?Nächster konkreter Schritt\*?\*?:?\s*/i,"").replace(/^→\s*/,"")]},B=!0):B?ee.lines.push(F):V.push(F);ee.lines.length&&K.push(ee);const z={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 o.jsxs("div",{className:"space-y-1",children:[V.join(`
`).trim()&&o.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none mb-3 [&>p]:mb-2 [&>p]:leading-relaxed",children:o.jsx(rc,{children:V.join(`
`)})}),K.map((F,G)=>{const Q=z[F.type];return Q?o.jsxs("div",{className:`rounded-xl border px-4 py-3 ${Q.bg} ${Q.border}`,children:[o.jsxs("div",{className:`flex items-center gap-1.5 font-semibold text-xs mb-2 ${Q.labelColor}`,children:[o.jsx("span",{className:Q.iconColor,children:Q.icon}),Q.label]}),o.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:o.jsx(rc,{children:F.lines.join(`
`).trim()})})]},G):null})]})};return o.jsx(Cr,{showSidebar:!0,pageTitle:"Supervisor",fullWidth:!0,hidePlatformAssistant:!0,children:o.jsxs("div",{className:"flex h-[calc(100vh-4rem)] -m-4 md:-m-6 xl:-m-8",children:[o.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:$}),o.jsxs("div",{className:"flex-1 flex flex-col min-w-0 px-4 md:px-6 pt-4 md:pt-6",children:[o.jsxs("div",{className:"flex items-center gap-3 pb-4 border-b border-border mb-4",children:[e&&o.jsxs(aA,{open:y,onOpenChange:x,children:[o.jsx(vSe,{asChild:!0,children:o.jsx(me,{variant:"ghost",size:"icon",className:"flex-shrink-0",children:o.jsx(rj,{className:"w-5 h-5"})})}),o.jsxs(Rj,{side:"left",className:"w-[280px] p-4 flex flex-col gap-4",children:[o.jsx(oA,{className:"sr-only",children:"Chat History"}),$]})]}),o.jsx(wx,{isLoading:!1}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"Thesis Supervisor"}),o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e&&s?((M=r.find(k=>k.id===s))==null?void 0:M.title)||"AI-powered feedback":"AI-powered feedback on your work"})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto space-y-4 pb-4",children:[d.length===0&&!m&&o.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-6",children:[o.jsx(wx,{size:64}),o.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.."}),o.jsx("div",{className:"flex flex-wrap justify-center gap-2",children:A7t.map(k=>o.jsx("button",{onClick:()=>A(k),className:"px-4 py-2 rounded-full border border-border text-sm text-foreground hover:bg-muted transition-colors",children:k},k))})]}),d.map((k,D)=>o.jsxs("div",{className:`flex gap-3 ${k.role==="user"?"justify-end":"justify-start"}`,children:[k.role==="assistant"&&o.jsx(wx,{size:32}),o.jsx("div",{className:`max-w-[85%] md:max-w-[75%] rounded-2xl px-4 text-sm ${k.role==="user"?"bg-purple-600 text-white rounded-br-md py-3":"bg-muted text-foreground rounded-bl-md shadow-sm py-4"}`,children:k.role==="assistant"?T(k.content):o.jsx("p",{className:"whitespace-pre-wrap",children:k.content})})]},D)),m&&o.jsxs("div",{className:"flex gap-3 justify-start",children:[o.jsx(wx,{size:32,isLoading:!0}),o.jsx("div",{className:"bg-muted rounded-2xl rounded-bl-md px-4 py-3",children:o.jsxs("div",{className:"flex gap-1",children:[o.jsx("span",{className:"w-2 h-2 bg-muted-foreground/40 rounded-full animate-bounce [animation-delay:0ms]"}),o.jsx("span",{className:"w-2 h-2 bg-muted-foreground/40 rounded-full animate-bounce [animation-delay:150ms]"}),o.jsx("span",{className:"w-2 h-2 bg-muted-foreground/40 rounded-full animate-bounce [animation-delay:300ms]"})]})})]}),o.jsx("div",{ref:v})]}),o.jsxs("div",{className:"border-t border-border pt-4 pb-4 flex flex-col gap-2",children:[b&&o.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:[o.jsxs("span",{children:["📎 ",b.name]}),o.jsx("button",{onClick:()=>w(null),className:"hover:text-foreground",children:"✕"})]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("input",{ref:j,type:"file",accept:".pdf,.txt,.docx",className:"hidden",onChange:O}),o.jsx(me,{variant:"outline",size:"icon",className:"h-[60px] w-[60px] flex-shrink-0",onClick:()=>{var k;return(k=j.current)==null?void 0:k.click()},disabled:m,children:o.jsx(CB,{className:"w-5 h-5"})}),o.jsx(lr,{value:f,onChange:k=>p(k.target.value),onKeyDown:E,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}),o.jsx(me,{onClick:()=>A(f),disabled:m||!f.trim()||!s,size:"icon",className:"h-[60px] w-[60px] flex-shrink-0",children:o.jsx(WW,{className:"w-5 h-5"})})]})]})]})]})})}function P7t(){const e=bd().pathname==="/qualitative/kodierbogen-grid";return o.jsx(Cr,{showSidebar:!0,fullWidth:e,children:o.jsx("div",{className:e?"w-full min-w-0":"container mx-auto p-6 max-w-7xl",children:o.jsx(e3e,{})})})}function I7t(){const{user:t,checkStudentPoints:e,studentPoints:r}=Ht(),[n,s]=S.useState(!1),{toast:i}=Bn(),[a,l]=S.useState(""),[c,u]=S.useState(""),[d,h]=S.useState(""),[f,p]=S.useState("bachelor"),[m,g]=S.useState(""),[y,x]=S.useState("de"),[v,b]=S.useState(null),[w,j]=S.useState(null),[N,C]=S.useState(!1),[A,E]=S.useState(!0),[O,$]=S.useState("both"),[T,M]=S.useState([]),[k,D]=S.useState("");S.useEffect(()=>{(async()=>{if(!(t!=null&&t.id))return;const[B,z]=await Promise.all([pe.from("topic_explorations").select("id, title, objectives, research_questions, created_at").eq("user_id",t.id).eq("feature_type","topic_ideas").order("created_at",{ascending:!1}),pe.from("summaries").select("id, summary_text").eq("user_id",t.id).eq("summary_mode","topic_explorer").order("created_at",{ascending:!1})]);B.error&&console.error("Error loading topic explorations:",B.error),z.error&&console.error("Error loading legacy topic entries:",z.error);const F=ie=>Array.isArray(ie)?ie.map(se=>String(se)).filter(Boolean):typeof ie=="string"?ie.split(`
`).map(se=>se.trim()).filter(Boolean):[],G=(B.data||[]).map(ie=>({id:ie.id,title:ie.title||"Untitled",data:{title:ie.title,objectives:ie.objectives,researchQuestions:F(ie.research_questions)}})),Q=(z.data||[]).map(ie=>{var se;try{const q=JSON.parse(ie.summary_text||"{}");return{id:ie.id,title:q.title||"Untitled",data:{title:q.title,objectives:q.objectives,researchQuestions:F((se=q.original_selection)==null?void 0:se.researchQuestions)}}}catch{return null}}).filter(Boolean);M([...G,...Q])})()},[t==null?void 0:t.id]);const K=()=>{const V=T.find(z=>z.id===k);if(!V)return;const{data:B}=V;l(B.title||""),u(B.objectives||""),h((B.researchQuestions||[]).join(`
`)),i({title:"Topic adopted",description:"Working title, objectives, and research questions have been completed"})},H=async()=>{if(!e()){s(!0);return}const V=a.trim(),B=m.trim(),z=c.trim();if(!V){i({title:"Enter Work Title",description:"A working title is required to generate the research setup.",variant:"destructive"});return}if(!B){i({title:"Enter Discipline",description:"Please specify your academic discipline before generating the research setup.",variant:"destructive"});return}C(!0),j(null);const F=new Date(Date.now()-5e3).toISOString();try{const G=d.split(`
`).map(q=>q.trim()).filter(Boolean),{data:Q,error:ie}=await pe.functions.invoke("research_setup_builder",{body:{title:V,aim:z,questions:G,degree:f,discipline:B,language:y}});if(ie)throw ie;b(Q);let se=(Q==null?void 0:Q.research_setup_id)??(Q==null?void 0:Q.setup_id)??(Q==null?void 0:Q.id)??null;if(!se&&(t!=null&&t.id)){const{data:q}=await pe.from("research_setups").select("id").eq("user_id",t.id).gte("created_at",F).order("created_at",{ascending:!1}).limit(1).maybeSingle();se=(q==null?void 0:q.id)??null}j(se),E(!1),i({title:"Research setup successfully generated",description:Q.summary_id?"Saved to library":void 0})}catch(G){console.error("Research setup error:",G),i({title:"Error during transfer",variant:"destructive"})}C(!1)},ee=async V=>{if(!v)return;const B=v.codebook,z=v.meta??{};if(!B||!B.categories||!B.categories.length){i({title:"No coding sheet generated",variant:"destructive"});return}let F=B.categories;if(V!=="both"&&(F=F.filter(G=>G.source===V)),!F.length){i({title:`No categories found for source "${V}"`,variant:"destructive"});return}try{const{data:G,error:Q}=await pe.from("codebooks").insert({title:z.title?`Coding sheet – ${z.title}`:"Coding sheet",description:z.aim??null,degree:z.degree??null,discipline:z.discipline??null,language:z.language??null,user_id:t==null?void 0:t.id,research_setup_id:w}).select().single();if(Q)throw Q;const ie=F.map((q,L)=>({codebook_id:G.id,name:q.name||"Category",definition:q.definition||"",coding_rule:q.coding_rule||"",anchor_example:q.anchor_example||"",order_index:Number.isFinite(q.order_index)?q.order_index:L})),{error:se}=await pe.from("codebook_categories").insert(ie);if(se)throw se;i({title:`Coding sheet (${V}) adopted`})}catch(G){console.error(G),i({title:"Error during transfer",variant:"destructive"})}};return o.jsxs("div",{className:"container mx-auto max-w-6xl space-y-6 p-4 sm:p-6",children:[o.jsx("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(dd,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Research Setup"}),o.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:"Define your research context and let Academly turn it into a structured qualitative research setup."})]})]})}),T.length>0&&o.jsx("div",{className:"rounded-xl border border-border/70 bg-muted/20 p-4",children:o.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-background text-primary ring-1 ring-border/70",children:o.jsx(GOe,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-semibold",children:"Continue from Topic Explorer"}),o.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Reuse an existing topic, objectives, and research questions."})]})]}),o.jsxs("div",{className:"flex w-full flex-col gap-2 sm:flex-row lg:w-auto",children:[o.jsxs(pt,{value:k,onValueChange:D,children:[o.jsx(ut,{className:"w-full sm:w-[280px]",children:o.jsx(mt,{placeholder:"Select a topic..."})}),o.jsx(dt,{children:T.map(V=>o.jsx(Le,{value:V.id,children:V.title},V.id))})]}),o.jsx(me,{onClick:K,disabled:!k,variant:"outline",children:"Import"})]})]})}),o.jsxs(Vh,{open:A,onOpenChange:E,children:[v&&o.jsx("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-4 py-3",children:o.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(Yc,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold",children:"Research setup inputs"}),o.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:"Generates research questions, interview guides, and a codebook draft."})]})]}),o.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[o.jsx(Qy,{asChild:!0,children:o.jsxs(me,{variant:"outline",className:"gap-2",children:[A?"Hide inputs":"Edit inputs",o.jsx(ia,{className:`h-4 w-4 transition-transform ${A?"rotate-180":""}`})]})}),o.jsxs(me,{onClick:H,disabled:N,className:"gap-2",children:[N?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(Sr,{className:"h-4 w-4"}),N?"Generating...":"Regenerate Setup"]})]})]})}),o.jsx(qh,{className:"mt-4",children:o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs(st,{className:"p-0",children:[o.jsxs("div",{className:"grid divide-y divide-border/70 lg:grid-cols-[220px_minmax(0,1fr)] lg:divide-x lg:divide-y-0",children:[o.jsxs("div",{className:"p-5 sm:p-6",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(_N,{className:"h-4 w-4"})}),o.jsx("h2",{className:"mt-4 text-sm font-semibold",children:"Research context"}),o.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:"Give Academly the academic context it needs before generating interview guides and a codebook structure."})]}),o.jsxs("div",{className:"space-y-5 p-5 sm:p-6",children:[o.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"title",children:["Working title ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ue,{id:"title",value:a,onChange:V=>l(V.target.value),placeholder:"Title of the research paper"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"discipline",children:["Discipline ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ue,{id:"discipline",value:m,onChange:V=>g(V.target.value),placeholder:"e.g., Sociology, Psychology"})]})]}),o.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Degree"}),o.jsxs(pt,{value:f,onValueChange:p,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"bachelor",children:"Bachelor"}),o.jsx(Le,{value:"master",children:"Master"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Language"}),o.jsxs(pt,{value:y,onValueChange:x,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"de",children:"Deutsch"}),o.jsx(Le,{value:"en",children:"English"})]})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:"aim",children:"Research objective"}),o.jsx(lr,{id:"aim",value:c,onChange:V=>u(V.target.value),rows:4,placeholder:"What do you want to understand, explore, or explain?",className:"resize-y"})]})]})]}),o.jsx("div",{className:"border-t border-border/70",children:o.jsxs("div",{className:"grid lg:grid-cols-[220px_minmax(0,1fr)]",children:[o.jsxs("div",{className:"border-b border-border/70 p-5 sm:p-6 lg:border-b-0 lg:border-r",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(sv,{className:"h-4 w-4"})}),o.jsx("h2",{className:"mt-4 text-sm font-semibold",children:"Research questions"}),o.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:"Add existing questions if you already have them. One question per line is enough."})]}),o.jsx("div",{className:"p-5 sm:p-6",children:o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"questions",children:["Existing research questions",o.jsx("span",{className:"ml-1 font-normal text-muted-foreground",children:"optional"})]}),o.jsx(lr,{id:"questions",value:d,onChange:V=>h(V.target.value),rows:6,placeholder:`How do participants experience ...?
Which factors influence ...?`,className:"resize-y"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Academly can also derive suitable research questions from your title and objective."})]})})]})}),o.jsxs("div",{className:"flex flex-col gap-3 border-t border-border/70 bg-muted/20 px-5 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-6",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx(Yc,{className:"h-4 w-4 text-primary"}),o.jsx("span",{children:"Generates research questions, interview guides, and a codebook draft."})]}),o.jsxs(me,{onClick:H,disabled:N,className:"gap-2 sm:min-w-[220px]",children:[N?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(Sr,{className:"h-4 w-4"}),N?"Generating...":"Generate Research Setup"]})]})]})})})]}),v&&o.jsxs("div",{className:"space-y-4",children:[o.jsx("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-primary",children:[o.jsx(No,{className:"h-4 w-4"}),"Generated successfully"]}),o.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-tight",children:"Your qualitative research setup"}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Review the generated structure before continuing with coding."})]})}),o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs(st,{className:"p-5 sm:p-6",children:[o.jsxs("div",{className:"mb-5 flex items-center gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(TE,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold",children:"Research context"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"The foundation used for the generated interview guides."})]})]}),o.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Title"}),o.jsx("p",{className:"mt-1 text-sm font-medium leading-relaxed",children:v.meta.title})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Objective"}),o.jsx("p",{className:"mt-1 text-sm leading-relaxed text-foreground",children:v.meta.aim})]})]}),o.jsxs("div",{className:"mt-5 border-t border-border/70 pt-5",children:[o.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Derived research questions"}),o.jsx("div",{className:"mt-3 space-y-2",children:v.meta.derived_research_questions.map((V,B)=>o.jsxs("div",{className:"flex items-start gap-3 rounded-lg bg-muted/30 px-3 py-2.5",children:[o.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-background text-xs font-semibold text-muted-foreground ring-1 ring-border/70",children:B+1}),o.jsx("p",{className:"pt-0.5 text-sm leading-relaxed",children:V})]},B))})]})]})}),o.jsxs("div",{className:"grid gap-4 xl:grid-cols-2",children:[o.jsx(Ze,{className:"border-border/70 border-t-2 border-t-primary/40 bg-primary/[0.02] shadow-sm",children:o.jsxs(st,{className:"p-5 sm:p-6",children:[o.jsxs("div",{className:"mb-5 flex items-center gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(NN,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold",children:"Participant interview"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Interview guide for participant perspectives"})]})]}),o.jsxs("div",{className:"rounded-lg bg-muted/25 p-4",children:[o.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Introduction"}),o.jsx("p",{className:"mt-2 whitespace-pre-line text-sm leading-relaxed",children:v.participant_interview.intro})]}),o.jsx("div",{className:"mt-5 space-y-3",children:v.participant_interview.questions.map((V,B)=>o.jsxs("div",{className:"rounded-xl border border-border/70 p-4",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:B+1}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-medium leading-relaxed",children:V.question}),o.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Maps to: ",V.maps_to_rq]})]})]}),V.probes.length>0&&o.jsxs("div",{className:"mt-3 border-t border-border/70 pt-3",children:[o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Follow-up prompts"}),o.jsx("ul",{className:"mt-2 space-y-1.5 text-xs leading-relaxed text-muted-foreground",children:V.probes.map((z,F)=>o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(As,{className:"mt-0.5 h-3 w-3 shrink-0"}),o.jsx("span",{children:z})]},F))})]})]},B))})]})}),o.jsx(Ze,{className:"border-border/70 border-t-2 border-t-violet-400/40 bg-violet-500/[0.02] shadow-sm",children:o.jsxs(st,{className:"p-5 sm:p-6",children:[o.jsxs("div",{className:"mb-5 flex items-center gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-violet-500/10 text-violet-600 dark:text-violet-400",children:o.jsx(_N,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold",children:"Expert interview"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Interview guide for expert perspectives"})]})]}),o.jsxs("div",{className:"rounded-lg bg-muted/25 p-4",children:[o.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Introduction"}),o.jsx("p",{className:"mt-2 whitespace-pre-line text-sm leading-relaxed",children:v.expert_interview.intro})]}),o.jsx("div",{className:"mt-5 space-y-3",children:v.expert_interview.questions.map((V,B)=>o.jsxs("div",{className:"rounded-xl border border-border/70 p-4",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:B+1}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"text-sm font-medium leading-relaxed",children:V.question}),o.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Maps to: ",V.maps_to_rq]})]})]}),V.probes.length>0&&o.jsxs("div",{className:"mt-3 border-t border-border/70 pt-3",children:[o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Follow-up prompts"}),o.jsx("ul",{className:"mt-2 space-y-1.5 text-xs leading-relaxed text-muted-foreground",children:V.probes.map((z,F)=>o.jsxs("li",{className:"flex items-start gap-2",children:[o.jsx(As,{className:"mt-0.5 h-3 w-3 shrink-0"}),o.jsx("span",{children:z})]},F))})]})]},B))})]})})]}),o.jsx(Ze,{className:"border-border/70 border-t-2 border-t-emerald-400/40 bg-emerald-500/[0.02] shadow-sm",children:o.jsx(st,{className:"p-5 sm:p-6",children:o.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",children:o.jsx(nr,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold",children:"Continue with your codebook"}),o.jsx("p",{className:"mt-0.5 max-w-2xl text-xs leading-relaxed text-muted-foreground",children:"Turn the generated categories into a reusable codebook for participant interviews, expert interviews, or both."})]})]}),o.jsxs("div",{className:"flex w-full flex-col gap-2 sm:flex-row lg:w-auto",children:[o.jsxs(pt,{value:O,onValueChange:V=>$(V),children:[o.jsx(ut,{className:"w-full sm:w-[220px]",children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"participant",children:"Participant Interviews"}),o.jsx(Le,{value:"expert",children:"Expert Interviews"}),o.jsx(Le,{value:"both",children:"Both (merged)"})]})]}),o.jsx(me,{onClick:()=>ee(O),variant:"outline",children:"Add as Codebook"})]})]})})})]}),o.jsx(cu,{open:n,onClose:()=>s(!1),remainingPoints:(r==null?void 0:r.remaining)??0})]})}const Uk=t=>t&&Array.isArray(t.questions)?t.questions.filter(e=>e&&e.question):[];function _6({guide:t}){const e=Uk(t);return o.jsxs("div",{className:"space-y-6",children:[t.intro&&o.jsxs("section",{className:"rounded-xl border border-border/70 bg-muted/20 px-4 py-3.5",children:[o.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[o.jsx(fMe,{className:"h-3.5 w-3.5 text-primary"}),o.jsx("p",{className:"text-xs font-medium text-foreground",children:"Interview introduction"})]}),o.jsx("p",{className:"whitespace-pre-line text-sm leading-relaxed text-muted-foreground",children:t.intro})]}),o.jsx("ol",{className:"divide-y divide-border/70",children:e.map((r,n)=>o.jsxs("li",{className:"grid grid-cols-[36px_minmax(0,1fr)] gap-3.5 py-5 first:pt-0 last:pb-0",children:[o.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-primary/10 text-xs font-semibold text-primary",children:String(n+1).padStart(2,"0")}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsx("p",{className:"text-sm font-medium leading-relaxed text-foreground",children:r.question}),r.maps_to_rq&&o.jsx(kt,{variant:"outline",className:"mt-0.5 shrink-0 border-border/70 bg-background px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:r.maps_to_rq})]}),r.probes&&r.probes.length>0&&o.jsxs("div",{className:"mt-3",children:[o.jsx("p",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Follow-up prompts"}),o.jsx("ul",{className:"space-y-1.5",children:r.probes.map((s,i)=>o.jsxs("li",{className:"flex gap-2 text-sm leading-relaxed text-muted-foreground",children:[o.jsx("span",{className:"mt-[0.15em] shrink-0 text-primary/70",children:"•"}),o.jsx("span",{children:s})]},i))})]})]})]},n))})]})}function R7t({open:t,onOpenChange:e,title:r,participant:n,expert:s}){const i=Uk(n).length,a=Uk(s).length,l=i>0,c=a>0,[u,d]=S.useState("participant"),h=l?n:s,f=l?"Participant":"Expert",p=l?i:a;return o.jsx(aA,{open:t,onOpenChange:e,children:o.jsxs(Rj,{side:"right",className:"flex w-full flex-col p-0 sm:max-w-[720px]",children:[o.jsxs($L,{className:"space-y-3 border-b px-5 py-4 text-left",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsxs(oA,{className:"flex items-center gap-2 text-base",children:[o.jsx(nr,{className:"h-4 w-4 text-primary"}),"Interview Guide"]}),r&&o.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:["Research Setup · ",r]})]}),l&&c&&o.jsx(VR,{value:u,onValueChange:m=>d(m),className:"w-full",children:o.jsxs(bk,{className:"h-8 w-fit bg-muted/40 p-0.5",children:[o.jsxs(Fh,{value:"participant",className:"h-7 gap-1.5 px-2.5 text-xs data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:[o.jsx(NN,{className:"h-3 w-3"}),"Participant",o.jsxs("span",{className:"opacity-80",children:["· ",i]})]}),o.jsxs(Fh,{value:"expert",className:"h-7 gap-1.5 px-2.5 text-xs data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:[o.jsx(yX,{className:"h-3 w-3"}),"Expert",o.jsxs("span",{className:"opacity-80",children:["· ",a]})]})]})}),l!==c&&(l||c)&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs(kt,{variant:"secondary",className:"gap-1.5 bg-muted/50 text-xs font-medium text-foreground",children:[l?o.jsx(NN,{className:"h-3 w-3 text-primary"}):o.jsx(yX,{className:"h-3 w-3 text-primary"}),f]}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:[p," ",p===1?"question":"questions"]})]})]}),!l&&!c?o.jsx("div",{className:"flex flex-1 items-start px-5 py-6",children:o.jsx("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-4 py-3",children:o.jsx("p",{className:"text-sm text-muted-foreground",children:"No interview questions available for this research setup."})})}):l&&c?o.jsxs(VR,{value:u,onValueChange:m=>d(m),className:"flex min-h-0 flex-1 flex-col",children:[o.jsx("div",{className:"sr-only",children:o.jsxs(bk,{children:[o.jsx(Fh,{value:"participant",children:"Participant"}),o.jsx(Fh,{value:"expert",children:"Expert"})]})}),o.jsx(hv,{value:"participant",className:"m-0 min-h-0 flex-1",children:o.jsx(Am,{className:"h-full",children:o.jsx("div",{className:"p-5",children:o.jsx(_6,{guide:n})})})}),o.jsx(hv,{value:"expert",className:"m-0 min-h-0 flex-1",children:o.jsx(Am,{className:"h-full",children:o.jsx("div",{className:"p-5",children:o.jsx(_6,{guide:s})})})})]}):o.jsx(Am,{className:"flex-1",children:o.jsx("div",{className:"p-5",children:o.jsx(_6,{guide:h})})})]})})}function O7t({codebookId:t,userId:e,researchSetupId:r,onLinked:n}){const{toast:s}=Bn(),[i,a]=S.useState(null),[l,c]=S.useState(!1),[u,d]=S.useState(!1),[h,f]=S.useState(!1),[p,m]=S.useState(!1),[g,y]=S.useState([]),[x,v]=S.useState(!1);S.useEffect(()=>{a(null),r&&(c(!0),pe.from("research_setups").select("*").eq("id",r).maybeSingle().then(({data:E})=>{a(E),c(!1)}))},[r]);const b=async()=>{m(!0);const{data:E}=await pe.from("research_setups").select("id,title,created_at").eq("user_id",e).order("created_at",{ascending:!1});y(E||[])},w=async E=>{v(!0);const{error:O}=await pe.from("codebooks").update({research_setup_id:E}).eq("id",t);if(v(!1),O){s({title:"Could not link research setup",variant:"destructive"});return}m(!1),s({title:"Research setup linked"}),n()};if(!r||!l&&!i)return o.jsx("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:p?g.length===0?o.jsx("span",{children:"No research setups found."}):o.jsxs(pt,{onValueChange:w,disabled:x,children:[o.jsx(ut,{className:"h-8 w-[320px]",children:o.jsx(mt,{placeholder:"Choose a research setup"})}),o.jsx(dt,{children:g.map(E=>o.jsxs(Le,{value:E.id,children:[E.title," · ",new Date(E.created_at).toLocaleString()]},E.id))})]}):o.jsxs(me,{variant:"ghost",size:"sm",className:"h-8 gap-1.5 px-2",onClick:b,children:[o.jsx(cMe,{className:"h-4 w-4"}),"Link research setup"]})});if(l)return o.jsx(Xe,{className:"h-4 w-4 animate-spin text-muted-foreground"});const j=Array.isArray(i.derived_research_questions)?i.derived_research_questions:[],N=Uk(i.participant_interview).length,C=Uk(i.expert_interview).length,A=[N&&`${N} Participant`,C&&`${C} Expert`].filter(Boolean);return o.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 p-4",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:[o.jsx(Yhe,{className:"h-4 w-4 text-primary"}),"Research Context"]}),o.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Research Question"}),o.jsx("p",{className:"mt-0.5 text-sm",children:j[0]||i.aim||"—"}),j.length>1&&o.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:["+",j.length-1," more"]})]}),o.jsxs("div",{children:[o.jsx("p",{className:"text-xs text-muted-foreground",children:"Interview Guide"}),o.jsx("p",{className:"mt-0.5 text-sm",children:A.length?`${A.join(" · ")} questions`:"No questions"})]})]}),o.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[o.jsx(me,{size:"sm",variant:"outline",onClick:()=>f(!0),children:"View Research Setup"}),o.jsx(me,{size:"sm",variant:"outline",onClick:()=>d(!0),disabled:!N&&!C,children:"View Interview Guide"})]}),o.jsx(R7t,{open:u,onOpenChange:d,title:i.title,participant:i.participant_interview,expert:i.expert_interview}),o.jsx(jn,{open:h,onOpenChange:f,children:o.jsxs(pn,{className:"max-h-[80vh] max-w-4xl overflow-auto",children:[o.jsx(mn,{children:o.jsx(gn,{children:i.title})}),i.markdown_text?o.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:o.jsx(rc,{children:i.markdown_text})}):o.jsxs("div",{className:"space-y-4",children:[i.aim&&o.jsxs("div",{children:[o.jsx("h3",{className:"mb-2 font-semibold",children:"Research Aim"}),o.jsx("p",{className:"text-muted-foreground",children:i.aim})]}),j.length>0&&o.jsxs("div",{children:[o.jsx("h3",{className:"mb-2 font-semibold",children:"Research Questions"}),o.jsx("ul",{className:"list-inside list-disc space-y-1 text-muted-foreground",children:j.map((E,O)=>o.jsx("li",{children:E},O))})]})]})]})})]})}function M7t(){var T;const{user:t}=Ht(),{toast:e}=Bn(),[r,n]=S.useState([]),[s,i]=S.useState(""),[a,l]=S.useState([]),[c,u]=S.useState(!1),[d,h]=S.useState(""),[f,p]=S.useState(null),[m,g]=S.useState(null);S.useEffect(()=>{t&&y()},[t]),S.useEffect(()=>{s&&x()},[s]);const y=async()=>{const{data:M,error:k}=await pe.from("codebooks").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});k?e({title:"Error loading codebooks",variant:"destructive"}):n(M||[])},x=async()=>{if(!s)return;const{data:M,error:k}=await pe.from("codebook_categories").select("*").eq("codebook_id",s).order("order_index",{ascending:!0});k?e({title:"Error loading categories",variant:"destructive"}):l(M||[])},v=async()=>{const M=d.trim();if(!M){e({title:"Please enter title",variant:"destructive"});return}if(!(t!=null&&t.id)){e({title:"Not signed in",variant:"destructive"});return}const k={title:M,user_id:t.id},{data:D,error:K}=await pe.from("codebooks").insert(k).select().single();if(K){e({title:"Error creating",variant:"destructive"});return}h(""),await y(),i(D.id),e({title:"Codebook created"})},b=async()=>{if(!s){e({title:"No codebook selected",variant:"destructive"});return}try{const{error:M}=await pe.from("codebooks").delete().eq("id",s);if(M)throw M;e({title:"Codebook deleted successfully"}),i(""),l([]),await y()}catch(M){console.error("Delete error:",M),e({title:"Error deleting",variant:"destructive"})}},w=()=>{const M=a.find(D=>String(D.id).startsWith("new-"));if(M){g(M.id);return}const k={id:`new-${Date.now()}`,codebook_id:s,name:"",definition:"",coding_rule:"",anchor_example:"",order_index:a.filter(D=>!String(D.id).startsWith("new-")).length};l([...a,k]),g(k.id),p(null)},j=(M,k,D)=>{l(a.map(K=>K.id===M?{...K,[k]:D}:K))},N=async M=>{if(String(M).startsWith("new-")){l(a.filter(k=>k.id!==M));return}try{const{error:k}=await pe.from("codebook_categories").delete().eq("id",M);if(k)throw k;l(a.filter(D=>D.id!==M)),e({title:"Category deleted successfully"})}catch{e({title:"Error deleting",variant:"destructive"})}},C=async()=>{if(s){u(!0);try{const M=a.filter(D=>!D.id.startsWith("new-")),k=a.filter(D=>D.id.startsWith("new-")).map(D=>({codebook_id:s,name:D.name,definition:D.definition,coding_rule:D.coding_rule,anchor_example:D.anchor_example,order_index:D.order_index}));if(M.length>0)for(const D of M){const{error:K}=await pe.from("codebook_categories").update({name:D.name,definition:D.definition,coding_rule:D.coding_rule,anchor_example:D.anchor_example,order_index:D.order_index}).eq("id",D.id);if(K)throw K}if(k.length>0){const{error:D}=await pe.from("codebook_categories").insert(k);if(D)throw D}e({title:"Categories saved successfully"}),x()}catch{e({title:"Error saving",variant:"destructive"})}u(!1)}},A=()=>{if(!s){e({title:"Select codebook",variant:"destructive"});return}const M=[["Category","Definition","Coding Rule","Anchor Example"]];for(const V of a)M.push([(V.name??"").replace(/\r?\n/g," ").trim(),(V.definition??"").replace(/\r?\n/g," ").trim(),(V.coding_rule??"").replace(/\r?\n/g," ").trim(),(V.anchor_example??"").replace(/\r?\n/g," ").trim()]);const k=kk.unparse(M,{delimiter:",",quotes:!0,newline:`\r
`}),D="\uFEFF",K=new Blob([D+k],{type:"text/csv;charset=utf-8"}),H=URL.createObjectURL(K),ee=document.createElement("a");ee.href=H,ee.download=`codebook_${s}.csv`,ee.click(),URL.revokeObjectURL(H)},E=async M=>{if(!s){e({title:"Select codebook",variant:"destructive"});return}try{const k=(H,ee)=>new Promise((V,B)=>{const z=new FileReader;z.onload=()=>V(z.result),z.onerror=B,z.readAsText(H,ee)});let D;try{D=await k(M,"UTF-8"),D.includes("�")&&(D=await k(M,"Windows-1252"))}catch{D=await k(M,"Windows-1252")}const K=D.charCodeAt(0)===65279?D.slice(1):D;if(!K.trim()){e({title:"Error",description:"CSV file is empty",variant:"destructive"});return}kk.parse(K,{header:!0,skipEmptyLines:!0,encoding:"UTF-8",delimiter:"",transformHeader:H=>(H||"").trim(),complete:async H=>{var ee;try{if(!((ee=H.data)!=null&&ee.length)){e({title:"Error",description:"CSV contains no data",variant:"destructive"});return}const V=H.data[0];if(!(V&&V.hasOwnProperty("Category")&&V.hasOwnProperty("Definition")&&V.hasOwnProperty("Coding Rule")&&V.hasOwnProperty("Anchor Example"))){e({title:"Error",description:"CSV must contain headers 'Category', 'Definition', 'Coding Rule', 'Anchor Example'",variant:"destructive"});return}const z=H.data.map(Q=>({name:(Q.Category||"").trim(),definition:(Q.Definition||"").trim(),coding_rule:(Q["Coding Rule"]||"").trim(),anchor_example:(Q["Anchor Example"]||"").trim()})).filter(Q=>Q.name);if(z.length===0){e({title:"No valid rows found",description:"No rows with category names",variant:"destructive"});return}let F=0,G=0;for(const Q of z)try{const{data:ie,error:se}=await pe.from("codebook_categories").select("id").eq("codebook_id",s).eq("name",Q.name).maybeSingle();if(se){console.error("Query error:",se);continue}if(ie&&ie.id){const{error:q}=await pe.from("codebook_categories").update({definition:Q.definition,coding_rule:Q.coding_rule,anchor_example:Q.anchor_example}).eq("id",ie.id);q||F++}else{const{error:q}=await pe.from("codebook_categories").insert({...Q,codebook_id:s,order_index:z.indexOf(Q)});q||G++}}catch(ie){console.error("Error processing category:",Q.name,ie)}e({title:"Import complete",description:`${F} updated, ${G} newly added`}),await x()}catch(V){console.error("Import processing error:",V),e({title:"Error processing data",variant:"destructive"})}},error:H=>{console.error("CSV parsing error:",H),e({title:"Could not read CSV",description:"Please check file format",variant:"destructive"})}})}catch(k){console.error("File reading error:",k),e({title:"Could not read file",variant:"destructive"})}},O=async M=>{try{const{error:k}=await pe.from("codebook_categories").update({name:M.name,definition:M.definition,coding_rule:M.coding_rule,anchor_example:M.anchor_example,order_index:M.order_index}).eq("id",M.id);if(k)throw k;e({title:"Category saved"}),g(null)}catch(k){console.error(k),e({title:"Error saving",variant:"destructive"})}},$=r.find(M=>M.id===s);return o.jsxs("div",{className:"container mx-auto max-w-7xl space-y-6 p-4 sm:p-6",children:[o.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(nr,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Codebook"}),o.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:"Build and maintain the categories, definitions, rules, and anchor examples used in your qualitative coding."})]})]}),s&&o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx("input",{id:"csv-import",type:"file",accept:".csv,text/csv",className:"hidden",onChange:M=>{var D;const k=(D=M.target.files)==null?void 0:D[0];k&&E(k),M.currentTarget.value=""}}),o.jsxs(me,{variant:"outline",onClick:A,className:"gap-2",children:[o.jsx(ko,{className:"h-4 w-4"}),"Export CSV"]}),o.jsxs(Se,{htmlFor:"csv-import",className:"inline-flex h-10 cursor-pointer items-center gap-2 rounded-md border border-input bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground",children:[o.jsx(BW,{className:"h-4 w-4"}),"Import CSV"]})]})]}),o.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(320px,0.62fr)]",children:[o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs(st,{className:"p-5",children:[o.jsxs("div",{className:"mb-4 flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(ZOe,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold",children:"Open a codebook"}),o.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Select the codebook you want to review or edit."})]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsxs(pt,{value:s,onValueChange:i,children:[o.jsx(ut,{className:"min-w-0 flex-1",children:o.jsx(mt,{placeholder:r.length?"Select codebook...":"No codebook available yet"})}),o.jsx(dt,{children:r.map(M=>o.jsx(Le,{value:M.id,children:M.title},M.id))})]}),s&&o.jsx(me,{variant:"outline",size:"icon",onClick:b,title:"Delete codebook",className:"shrink-0 text-destructive hover:bg-destructive/10 hover:text-destructive",children:o.jsx(Pi,{className:"h-4 w-4"})})]}),$&&o.jsxs("div",{className:"mt-4 flex items-center gap-2 rounded-lg bg-muted/30 px-3 py-2.5",children:[o.jsx(T_,{className:"h-4 w-4 shrink-0 text-primary"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"truncate text-sm font-medium",children:$.title}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.length," ",a.length===1?"category":"categories"]})]})]})]})}),o.jsx(Ze,{className:"border-border/70 bg-primary/[0.02] shadow-sm",children:o.jsxs(st,{className:"p-5",children:[o.jsxs("div",{className:"mb-4 flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(Bs,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold",children:"Create new codebook"}),o.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Start from scratch or create a separate coding framework."})]})]}),o.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row lg:flex-col xl:flex-row",children:[o.jsx(Ue,{value:d,onChange:M=>h(M.target.value),placeholder:"e.g. ITIL Challenges",onKeyDown:M=>{M.key==="Enter"&&v()}}),o.jsxs(me,{onClick:v,className:"gap-2 shrink-0",children:[o.jsx(Bs,{className:"h-4 w-4"}),"Create"]})]})]})})]}),!r.length&&o.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 px-5 py-8 text-center",children:[o.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(nr,{className:"h-5 w-5"})}),o.jsx("p",{className:"mt-3 text-sm font-medium",children:"No codebook yet"}),o.jsx("p",{className:"mx-auto mt-1 max-w-lg text-xs leading-relaxed text-muted-foreground",children:"Create a codebook above or adopt a generated one from Research Setup."})]}),s&&(t==null?void 0:t.id)&&o.jsx(O7t,{codebookId:s,userId:t.id,researchSetupId:(T=r.find(M=>M.id===s))==null?void 0:T.research_setup_id,onLinked:y}),s&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex flex-col gap-3 border-b border-border/70 pb-4 sm:flex-row sm:items-end sm:justify-between",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Categories"}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Define exactly what belongs in each code and how it should be applied."})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsxs(me,{onClick:w,className:"gap-2",children:[o.jsx(Bs,{className:"h-4 w-4"}),"Add Category"]}),o.jsxs(me,{onClick:C,disabled:c,variant:"outline",className:"gap-2",children:[c?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(A_,{className:"h-4 w-4"}),"Save All"]})]})]}),a.filter(M=>String(M.id).startsWith("new-")).map(M=>o.jsx(Ze,{className:"overflow-hidden border-border/70 border-t-2 border-t-primary/50 bg-primary/[0.025] shadow-sm",children:o.jsxs(st,{className:"p-0",children:[o.jsxs("div",{className:"flex flex-col gap-3 border-b border-border/70 bg-primary/[0.035] px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-xs font-semibold text-primary",children:"+"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold",children:"New category"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"It will be added to the end of the codebook after saving."})]})]}),o.jsxs(me,{onClick:()=>N(M.id),size:"sm",variant:"ghost",className:"self-start text-destructive hover:bg-destructive/10 hover:text-destructive sm:self-auto",children:[o.jsx(Pi,{className:"h-4 w-4"}),"Cancel"]})]}),o.jsxs("div",{className:"grid gap-4 p-4 sm:p-5 lg:grid-cols-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:`category-name-${M.id}`,children:"Category name"}),o.jsx(Ue,{id:`category-name-${M.id}`,value:M.name,onChange:k=>j(M.id,"name",k.target.value),placeholder:"Category name",autoFocus:!0})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:`category-definition-${M.id}`,children:"Definition"}),o.jsx(lr,{id:`category-definition-${M.id}`,value:M.definition||"",onChange:k=>j(M.id,"definition",k.target.value),placeholder:"What belongs in this category?",rows:3,className:"resize-y"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:`category-rule-${M.id}`,children:"Coding rule"}),o.jsx(lr,{id:`category-rule-${M.id}`,value:M.coding_rule||"",onChange:k=>j(M.id,"coding_rule",k.target.value),placeholder:"When should this code be applied?",rows:3,className:"resize-y"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:`category-anchor-${M.id}`,children:"Anchor example"}),o.jsx(lr,{id:`category-anchor-${M.id}`,value:M.anchor_example||"",onChange:k=>j(M.id,"anchor_example",k.target.value),placeholder:'e.g. "As an IT Service Manager I am..."',rows:3,className:"resize-y"})]})]}),o.jsx("div",{className:"flex justify-end border-t border-border/70 bg-background/70 px-4 py-3 sm:px-5",children:o.jsxs(me,{onClick:C,disabled:c,className:"gap-2",children:[c?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(A_,{className:"h-4 w-4"}),"Save category"]})})]})},M.id)),a.filter(M=>!String(M.id).startsWith("new-")).length===0&&!a.some(M=>String(M.id).startsWith("new-"))?o.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 px-5 py-10 text-center",children:[o.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(T_,{className:"h-5 w-5"})}),o.jsx("p",{className:"mt-3 text-sm font-medium",children:"No categories yet"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Add your first category or import an existing CSV codebook."}),o.jsxs(me,{onClick:w,className:"mt-4 gap-2",children:[o.jsx(Bs,{className:"h-4 w-4"}),"Add Category"]})]}):o.jsx("div",{className:"space-y-2",children:a.filter(M=>!String(M.id).startsWith("new-")).map((M,k)=>{var ee,V,B,z,F;const D=f===M.id,K=m===M.id,H=((ee=M.definition)==null?void 0:ee.trim())||"No definition added yet.";return o.jsx(Vh,{open:D||K,onOpenChange:G=>{K||p(G?M.id:null)},children:o.jsx(Ze,{className:"overflow-hidden border-border/70 shadow-sm transition-colors hover:border-primary/25",children:o.jsxs(st,{className:"p-0",children:[o.jsxs("div",{className:"flex flex-col gap-3 px-4 py-3.5 sm:flex-row sm:items-center sm:justify-between",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[o.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 text-xs font-semibold text-primary",children:k+1}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"truncate text-sm font-semibold",children:((V=M.name)==null?void 0:V.trim())||`Untitled category ${k+1}`}),o.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-relaxed text-muted-foreground",children:H})]})]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 pl-11 sm:pl-0",children:[o.jsxs(me,{onClick:()=>{g(K?null:M.id),p(M.id)},size:"sm",variant:"outline",className:"gap-2",children:[o.jsx(WM,{className:"h-3.5 w-3.5"}),K?"Cancel edit":"Edit"]}),o.jsxs(me,{onClick:()=>N(M.id),size:"sm",variant:"ghost",className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:[o.jsx(Pi,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden md:inline",children:"Delete"})]}),o.jsx(Qy,{asChild:!0,children:o.jsx(me,{size:"icon",variant:"ghost",className:"h-8 w-8",disabled:K,title:D?"Collapse":"Show details",children:o.jsx(ia,{className:`h-4 w-4 transition-transform ${D||K?"rotate-180":""}`})})})]})]}),o.jsx(qh,{children:K?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"grid gap-4 border-t border-border/70 bg-muted/[0.12] p-4 sm:p-5 lg:grid-cols-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:`category-name-${M.id}`,children:"Category name"}),o.jsx(Ue,{id:`category-name-${M.id}`,value:M.name,onChange:G=>j(M.id,"name",G.target.value),placeholder:"Category name"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:`category-definition-${M.id}`,children:"Definition"}),o.jsx(lr,{id:`category-definition-${M.id}`,value:M.definition||"",onChange:G=>j(M.id,"definition",G.target.value),placeholder:"What belongs in this category?",rows:3,className:"resize-y"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:`category-rule-${M.id}`,children:"Coding rule"}),o.jsx(lr,{id:`category-rule-${M.id}`,value:M.coding_rule||"",onChange:G=>j(M.id,"coding_rule",G.target.value),placeholder:"When should this code be applied?",rows:3,className:"resize-y"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{htmlFor:`category-anchor-${M.id}`,children:"Anchor example"}),o.jsx(lr,{id:`category-anchor-${M.id}`,value:M.anchor_example||"",onChange:G=>j(M.id,"anchor_example",G.target.value),placeholder:'e.g. "As an IT Service Manager I am..."',rows:3,className:"resize-y"})]})]}),o.jsx("div",{className:"flex justify-end border-t border-border/70 px-4 py-3 sm:px-5",children:o.jsxs(me,{onClick:()=>O(M),className:"gap-2",children:[o.jsx(A_,{className:"h-4 w-4"}),"Save changes"]})})]}):o.jsxs("div",{className:"border-t border-border/70 bg-muted/[0.08] p-4 sm:p-5",children:[o.jsxs("div",{className:"grid gap-5 lg:grid-cols-2",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[o.jsx(nr,{className:"h-3.5 w-3.5"}),"Definition"]}),o.jsx("p",{className:"text-sm leading-relaxed",children:((B=M.definition)==null?void 0:B.trim())||"No definition added yet."})]}),o.jsxs("div",{children:[o.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[o.jsx(T_,{className:"h-3.5 w-3.5"}),"Coding rule"]}),o.jsx("p",{className:"text-sm leading-relaxed",children:((z=M.coding_rule)==null?void 0:z.trim())||"No coding rule added yet."})]})]}),o.jsxs("div",{className:"mt-5 border-t border-border/70 pt-4",children:[o.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Anchor example"}),o.jsx("p",{className:"rounded-lg bg-background px-3 py-2.5 text-sm italic leading-relaxed ring-1 ring-border/60",children:((F=M.anchor_example)==null?void 0:F.trim())||"No anchor example added yet."})]})]})})]})})},M.id)})})]})]})}function D7t({open:t,onOpenChange:e,categoryId:r,categoryName:n,interviewId:s,interviewTitle:i,codebookId:a,onSuccess:l}){const[c,u]=S.useState([]),[d,h]=S.useState(!1),[f,p]=S.useState(!1),{toast:m}=Bn();S.useEffect(()=>{t&&r&&s&&g()},[t,r,s]);const g=async()=>{h(!0);try{const{data:w,error:j}=await pe.from("coded_segments").select("id, snippet").eq("category_id",r).eq("interview_id",s).order("created_at",{ascending:!0});if(j)throw j;w&&w.length>0?u(w.map(N=>({id:N.id,snippet:N.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)}},y=()=>{u([...c,{id:crypto.randomUUID(),snippet:"",isNew:!0}])},x=w=>{if(c.length===1){m({title:"Cannot delete",description:"At least one snippet must remain",variant:"destructive"});return}u(c.filter(j=>j.id!==w))},v=(w,j)=>{u(c.map(N=>N.id===w?{...N,snippet:j}:N))},b=async()=>{p(!0);try{const{data:{user:w}}=await pe.auth.getUser();if(!w)throw new Error("Not authenticated");const j=c.filter($=>!$.isNew),N=c.filter($=>$.isNew),{data:C}=await pe.from("coded_segments").select("id").eq("category_id",r).eq("interview_id",s),A=(C==null?void 0:C.map($=>$.id))||[],E=j.map($=>$.id),O=A.filter($=>!E.includes($));if(O.length>0){const{error:$}=await pe.from("coded_segments").delete().in("id",O);if($)throw $}for(const $ of j){const{error:T}=await pe.from("coded_segments").update({snippet:$.snippet}).eq("id",$.id);if(T)throw T}if(N.length>0){const{error:$}=await pe.from("coded_segments").insert(N.map(T=>({user_id:w.id,interview_id:s,codebook_id:a,category_id:r,snippet:T.snippet,start_char:0,end_char:T.snippet.length})));if($)throw $}m({title:"Success",description:"Snippets saved successfully"}),l(),e(!1)}catch(w){m({title:"Error saving snippets",description:w.message,variant:"destructive"})}finally{p(!1)}};return o.jsx(jn,{open:t,onOpenChange:e,children:o.jsxs(pn,{className:"flex max-h-[85vh] max-w-3xl flex-col overflow-hidden p-0",children:[o.jsxs("div",{className:"border-b border-border/70 px-5 py-5 sm:px-6",children:[o.jsx(mn,{className:"space-y-0 text-left",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(jr,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx(gn,{className:"text-lg font-semibold tracking-tight",children:"Coded snippets"}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Review and edit the coded passages for this category and interview."})]})]})}),o.jsxs("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[o.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(T_,{className:"h-4 w-4 shrink-0 text-primary"}),o.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Category"})]}),o.jsx("p",{className:"mt-1 truncate text-sm font-medium text-foreground",children:n})]}),o.jsxs("div",{className:"rounded-xl border border-border/70 bg-muted/20 px-3 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(afe,{className:"h-4 w-4 shrink-0 text-primary"}),o.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Interview"})]}),o.jsx("p",{className:"mt-1 truncate text-sm font-medium text-foreground",children:i})]})]})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-5 sm:px-6",children:d?o.jsx("div",{className:"flex min-h-[220px] items-center justify-center",children:o.jsxs("div",{className:"flex flex-col items-center gap-3 text-muted-foreground",children:[o.jsx(Xe,{className:"h-6 w-6 animate-spin text-primary"}),o.jsx("span",{className:"text-sm",children:"Loading snippets..."})]})}):o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{children:[o.jsxs("h3",{className:"text-sm font-semibold",children:[c.length," ",c.length===1?"coded passage":"coded passages"]}),o.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Edit the text directly or add another passage."})]}),o.jsxs(me,{type:"button",variant:"outline",size:"sm",onClick:y,className:"gap-2",children:[o.jsx(Bs,{className:"h-4 w-4"}),"Add snippet"]})]}),o.jsx("div",{className:"space-y-3",children:c.map((w,j)=>o.jsxs("div",{className:`rounded-xl border border-border/70 p-4 ${w.isNew?"border-t-2 border-t-primary/40 bg-primary/[0.02]":"bg-card"}`,children:[o.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-muted text-xs font-semibold text-muted-foreground",children:String(j+1).padStart(2,"0")}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Se,{htmlFor:`snippet-${w.id}`,className:"text-sm font-semibold",children:"Snippet"}),w.isNew&&o.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-medium text-primary",children:"New"})]})]}),o.jsx(me,{type:"button",variant:"ghost",size:"icon",onClick:()=>x(w.id),disabled:c.length===1,className:"h-8 w-8 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",title:"Delete snippet",children:o.jsx(Pi,{className:"h-4 w-4"})})]}),o.jsx(lr,{id:`snippet-${w.id}`,value:w.snippet,onChange:N=>v(w.id,N.target.value),placeholder:"Enter snippet text...",className:"min-h-[120px] resize-y leading-relaxed"})]},w.id))}),o.jsxs(me,{type:"button",variant:"outline",onClick:y,className:"gap-2",children:[o.jsx(Bs,{className:"h-4 w-4"}),"Add another snippet"]})]})}),o.jsxs(kf,{className:"border-t border-border/70 bg-muted/20 px-5 py-4 sm:px-6",children:[o.jsx(me,{type:"button",variant:"outline",onClick:()=>e(!1),disabled:f,children:"Cancel"}),o.jsxs(me,{type:"button",onClick:b,disabled:f||d,className:"gap-2",children:[f&&o.jsx(Xe,{className:"h-4 w-4 animate-spin"}),f?"Saving...":"Save changes"]})]})]})})}function L7t(){const[t,e]=S.useState([]),[r,n]=S.useState(""),[s,i]=S.useState([]),[a,l]=S.useState([]),[c,u]=S.useState({}),[d,h]=S.useState(!1),[f,p]=S.useState(!0),[m,g]=S.useState(""),[y,x]=S.useState("full"),[v,b]=S.useState(null),[w,j]=S.useState(!1),[N,C]=S.useState(null),A=S.useRef(null),[E,O]=S.useState(!1),[$,T]=S.useState("error"),[M,k]=S.useState(""),[D,K]=S.useState(""),[H,ee]=S.useState([]),[V,B]=S.useState(null),[z,F]=S.useState(!1),{toast:G}=Bn(),Q=async()=>{p(!0);try{const{data:re,error:ue}=await pe.from("codebooks").select("id, title").order("created_at",{ascending:!1});if(ue)throw ue;re&&re.length>0&&(e(re),n(re[0].id))}catch(re){G({title:"Error loading codebooks",description:re.message,variant:"destructive"})}finally{p(!1)}},ie=async re=>{if(!re){i([]),l([]);return}h(!0);try{const{data:ue,error:ae}=await pe.from("v_category_interview_matrix").select("*").eq("codebook_id",re);if(ae)throw ae;const ge={},we=new Set,ce={};ue==null||ue.forEach(fe=>{var be;ge[fe.category_id]||(ge[fe.category_id]={category_id:fe.category_id,category_name:fe.category_name,order_index:fe.order_index||0,definition:fe.definition,coding_rule:fe.coding_rule,anchor_example:fe.anchor_example},ce[fe.category_id]={}),fe.interview_title&&(we.add(fe.interview_title),ge[fe.category_id][fe.interview_title]=((be=fe.snippets)==null?void 0:be.join(`
— `))||"",ce[fe.category_id][fe.interview_title]={interview_id:fe.interview_id,snippets:fe.snippets||[]})});const ne=Object.values(ge).sort((fe,be)=>fe.order_index-be.order_index);i(ne),l(Array.from(we)),u(ce)}catch(ue){G({title:"Error loading data",description:ue.message,variant:"destructive"})}finally{h(!1)}};S.useEffect(()=>{Q()},[]),S.useEffect(()=>{r&&ie(r)},[r]);const se=async(re,ue,ae)=>{try{const ge={};ue==="definition"&&(ge.definition=ae),ue==="coding_rule"&&(ge.coding_rule=ae),ue==="anchor_example"&&(ge.anchor_example=ae);const{error:we}=await pe.from("codebook_categories").update(ge).eq("id",re);if(we)throw we;G({title:"Success",description:"Category updated successfully"}),r&&await ie(r)}catch(ge){G({title:"Error updating category",description:ge.message,variant:"destructive"})}},q=(re,ue,ae)=>{var we;const ge=(we=c[re])==null?void 0:we[ae];if(!ge){G({title:"Error",description:"Interview data not found",variant:"destructive"});return}C({categoryId:re,categoryName:ue,interviewId:ge.interview_id,interviewTitle:ae}),j(!0)},L=()=>{r&&ie(r)},Z=()=>{const re=[["Category","Definition","Coding Rule","Anchor Example",...a]];Y.forEach(ne=>{re.push([(ne.category_name??"").toString().replace(/\r?\n/g," ").replace(/"/g,'""').trim(),(ne.definition??"").toString().replace(/\r?\n/g," ").replace(/"/g,'""').trim(),(ne.coding_rule??"").toString().replace(/\r?\n/g," ").replace(/"/g,'""').trim(),(ne.anchor_example??"").toString().replace(/\r?\n/g," ").replace(/"/g,'""').trim(),...a.map(fe=>{const be=ne[fe];return(typeof be=="string"?be:(be??"").toString()).replace(/"/g,'""').replace(/\r?\n/g," ").trim()})])});const ue=kk.unparse(re,{delimiter:";",quotes:!0,escapeFormulae:!0,newline:`\r
`}),ae="\uFEFF",ge=new Blob([ae+ue],{type:"text/csv;charset=utf-8"}),we=URL.createObjectURL(ge),ce=document.createElement("a");ce.href=we,ce.download="codebook_grid.csv",ce.click(),URL.revokeObjectURL(we)},J=()=>{var re;(re=A.current)==null||re.click()},W=async re=>{var ae;const ue=(ae=re.target.files)==null?void 0:ae[0];if(ue){if(re.target.value="",!r){G({title:"Error",description:"Please select a codebook first",variant:"destructive"});return}F(!0),kk.parse(ue,{delimiter:";",header:!0,skipEmptyLines:!0,encoding:"UTF-8",complete:async ge=>{try{await X(ge.data)}catch(we){G({title:"Import-Error",description:we.message,variant:"destructive"})}finally{F(!1)}},error:ge=>{F(!1),G({title:"Error reading CSV file",description:ge.message,variant:"destructive"})}})}},X=async re=>{var ot;if(!re||re.length===0)throw new Error("CSV file is empty");const ue=re[0],ae=["Category","Definition","Coding Rule","Anchor Example"],ge=ae.filter(wt=>!(wt in ue));if(ge.length>0)throw new Error(`Missing columns: ${ge.join(", ")}`);const we=Object.keys(ue).filter(wt=>!ae.includes(wt)),{data:ce,error:ne}=await pe.from("codebook_categories").select("id, name").eq("codebook_id",r);if(ne)throw ne;const fe=new Map((ce==null?void 0:ce.map(wt=>[wt.name,wt.id]))||[]),xe=re.map(wt=>wt.Category).filter(Boolean).filter(wt=>!fe.has(wt));if(xe.length>0){T("error"),k("Missing Categories"),K(`The following categories do not exist in the codebook. :

${xe.join(`
`)}

Please add these categories to the codebook first.`),O(!0);return}const{data:_e,error:ke}=await pe.from("interviews").select("id, title").eq("user_id",(ot=(await pe.auth.getUser()).data.user)==null?void 0:ot.id);if(ke)throw ke;const $e=new Map((_e==null?void 0:_e.map(wt=>[wt.title,wt.id]))||[]),Te=we.filter(wt=>!$e.has(wt));if(Te.length>0){T("warning"),k("Missing Interviews"),K(`The following interviews do not exist:

${Te.join(`
`)}

How would you like to proceed??`),ee(Te),B({csvData:re,categoryMap:fe,interviewMap:$e,csvInterviewColumns:we}),O(!0);return}he(re,fe,$e,we)},he=(re,ue,ae,ge)=>{const we=new Set(re.map(ne=>ne.Category)).size,ce=ge.filter(ne=>ae.has(ne)).length;T("confirm"),k("Confirm Import"),K(`You are about to overwrite the codebook:

• ${we} categories will be updated
• ${ce} interviews will be overwritten
• Existing codings will be replaced

Do you want to continue?`),B({csvData:re,categoryMap:ue,interviewMap:ae,csvInterviewColumns:ge}),O(!0)},P=async(re=!1)=>{var ne;if(!V)return;const{csvData:ue,categoryMap:ae,interviewMap:ge,csvInterviewColumns:we}=V,ce=(ne=(await pe.auth.getUser()).data.user)==null?void 0:ne.id;if(!ce){G({title:"Error",description:"User not authenticated",variant:"destructive"});return}F(!0),O(!1);try{let fe=new Map(ge);if(re&&H.length>0)for(const xe of H){const{data:_e,error:ke}=await pe.from("interviews").insert({user_id:ce,title:xe,raw_text:"[Placeholder - Please add interview text]",source:"CSV Import"}).select("id").single();if(ke)throw ke;fe.set(xe,_e.id)}let be=0;for(const xe of ue){const _e=xe.Category,ke=ae.get(_e);if(ke)for(const $e of we){const Te=fe.get($e);if(!Te)continue;const ot=xe[$e]||"",{error:wt}=await pe.from("coded_segments").delete().eq("category_id",ke).eq("interview_id",Te).eq("codebook_id",r);if(wt)throw wt;if(ot.trim()){const pr=ot.split(/\s*\|\s*/).filter(Kt=>Kt.trim()).map(Kt=>({user_id:ce,interview_id:Te,codebook_id:r,category_id:ke,snippet:Kt.trim(),start_char:-1,end_char:-1}));if(pr.length>0){const{error:Kt}=await pe.from("coded_segments").insert(pr);if(Kt)throw Kt;be+=pr.length}}}}G({title:"✅ Import successful",description:`${ue.length} categories updated, ${be} snippets imported`}),await ie(r)}catch(fe){G({title:"Import failed",description:fe.message,variant:"destructive"})}finally{F(!1),B(null),ee([])}},oe=re=>{if(O(!1),re==="cancel"){B(null),ee([]);return}if(re==="skip"&&V){const{csvData:ue,categoryMap:ae,interviewMap:ge}=V,we=Object.keys(ue[0]).filter(ce=>!["Category","Definition","Coding Rule","Anchor Example"].includes(ce)&&ge.has(ce));he(ue,ae,ge,we);return}if(re==="placeholder"&&V){const{csvData:ue,categoryMap:ae,interviewMap:ge,csvInterviewColumns:we}=V;he(ue,ae,ge,we);return}re==="confirm"&&P(H.length>0)},Y=s.filter(re=>re.category_name.toLowerCase().includes(m.toLowerCase())),R=t.find(re=>re.id===r),I=Object.values(c).reduce((re,ue)=>re+Object.values(ue).reduce((ae,ge)=>{var we;return ae+(((we=ge.snippets)==null?void 0:we.length)??0)},0),0),U=(re,ue)=>{const ae=re[ue]||"";return(v==null?void 0:v.rowId)===re.category_id&&(v==null?void 0:v.field)===ue?o.jsx("textarea",{autoFocus:!0,defaultValue:ae,onBlur:we=>{se(re.category_id,ue,we.target.value),b(null)},onKeyDown:we=>{we.key==="Escape"&&b(null),we.key==="Enter"&&we.ctrlKey&&(se(re.category_id,ue,we.currentTarget.value),b(null))},className:"min-h-[88px] w-full resize-none rounded-lg border border-primary/50 bg-background p-2.5 text-sm outline-none ring-2 ring-primary/10 focus:border-primary"}):o.jsx("div",{className:"min-h-[44px] cursor-pointer whitespace-pre-wrap rounded-md px-1 py-0.5 text-sm leading-relaxed hover:bg-muted/50",onClick:()=>b({rowId:re.category_id,field:ue}),children:ae||"—"})};return f?o.jsx("div",{className:"flex min-h-[400px] items-center justify-center",children:o.jsx(Xe,{className:"h-8 w-8 animate-spin text-primary"})}):o.jsxs("div",{className:"space-y-5",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(kB,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"Codebook Grid"}),o.jsx("p",{className:"mt-1 max-w-3xl text-sm leading-relaxed text-muted-foreground",children:"Compare your complete codebook across interviews while keeping definitions, coding rules, examples, and coded text visible in one workspace."})]})]}),o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs("div",{className:"space-y-4 p-4 sm:p-5",children:[o.jsxs("div",{className:"flex flex-col gap-3 xl:flex-row xl:items-end xl:justify-between",children:[o.jsxs("div",{className:"w-full xl:max-w-md",children:[o.jsx(Se,{htmlFor:"codebook-select",className:"mb-2 block text-sm font-medium",children:"Codebook"}),o.jsxs(pt,{value:r,onValueChange:n,children:[o.jsx(ut,{id:"codebook-select",className:"w-full",children:o.jsx(mt,{placeholder:"Please select a codebook"})}),o.jsx(dt,{children:t.map(re=>o.jsx(Le,{value:re.id,children:re.title},re.id))})]})]}),r&&o.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[o.jsxs("span",{children:[o.jsx("strong",{className:"font-semibold text-foreground",children:s.length})," categories"]}),o.jsxs("span",{children:[o.jsx("strong",{className:"font-semibold text-foreground",children:a.length})," interviews"]}),o.jsxs("span",{children:[o.jsx("strong",{className:"font-semibold text-foreground",children:I})," coded segments"]})]})]}),r&&o.jsxs("div",{className:"flex flex-col gap-3 border-t border-border/70 pt-4 xl:flex-row xl:items-center xl:justify-between",children:[o.jsxs("div",{className:"relative w-full xl:max-w-sm",children:[o.jsx(Ti,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),o.jsx(Ue,{placeholder:"Search categories...",value:m,onChange:re=>g(re.target.value),className:"pl-9"})]}),o.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[o.jsxs("div",{className:"inline-flex h-10 rounded-lg border border-border/70 bg-muted/30 p-1",children:[o.jsxs(me,{type:"button",size:"sm",variant:y==="full"?"secondary":"ghost",onClick:()=>x("full"),className:"h-8 gap-2 px-3",children:[o.jsx(kB,{className:"h-4 w-4"}),"Full grid"]}),o.jsxs(me,{type:"button",size:"sm",variant:y==="compact"?"secondary":"ghost",onClick:()=>x("compact"),className:"h-8 gap-2 px-3",children:[o.jsx(NMe,{className:"h-4 w-4"}),"Compact grid"]})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("input",{ref:A,type:"file",accept:".csv",onChange:W,className:"hidden"}),o.jsxs(me,{onClick:J,variant:"outline",disabled:z,children:[z?o.jsx(Xe,{className:"mr-2 h-4 w-4 animate-spin"}):o.jsx(cf,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),o.jsxs(me,{onClick:Z,variant:"outline",children:[o.jsx(ko,{className:"mr-2 h-4 w-4"}),"Export CSV"]})]})]})]})]})}),r?d?o.jsx(Ze,{className:"border-border/70 p-12 shadow-sm",children:o.jsx("div",{className:"flex items-center justify-center",children:o.jsx(Xe,{className:"h-8 w-8 animate-spin text-primary"})})}):o.jsxs(Ze,{className:"overflow-hidden border-border/70 shadow-sm",children:[o.jsx("div",{className:"border-b border-border/70 bg-muted/20 px-4 py-3",children:o.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between",children:[o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold",children:(R==null?void 0:R.title)||"Codebook matrix"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:y==="full"?"Full grid shows every codebook field in its own column.":"Compact grid groups definition, coding rule, and anchor example into one column."})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Scroll horizontally to compare all interviews"})]})}),o.jsx("div",{className:"max-h-[72vh] overflow-auto",children:y==="full"?o.jsxs("table",{className:"w-full border-collapse",children:[o.jsx("thead",{className:"sticky top-0 z-30 bg-muted",children:o.jsxs("tr",{children:[o.jsx("th",{className:"sticky left-0 z-40 min-w-[150px] border border-border bg-muted p-3 text-left text-sm font-semibold",children:"Category"}),o.jsx("th",{className:"min-w-[200px] border border-border p-3 text-left text-sm font-semibold",children:"Definition"}),o.jsx("th",{className:"min-w-[200px] border border-border p-3 text-left text-sm font-semibold",children:"Coding Rule"}),o.jsx("th",{className:"min-w-[200px] border border-border p-3 text-left text-sm font-semibold",children:"Anchor Example"}),a.map(re=>o.jsx("th",{className:"min-w-[250px] border border-border p-3 text-left text-sm font-semibold",children:re},re))]})}),o.jsx("tbody",{children:Y.map((re,ue)=>o.jsxs("tr",{className:ue%2===0?"bg-background":"bg-muted/[0.16]",children:[o.jsx("td",{className:"sticky left-0 z-20 min-w-[150px] border border-border bg-inherit p-3 align-top",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-primary/10 text-xs font-semibold text-primary",children:ue+1}),o.jsx("span",{className:"text-sm font-semibold leading-relaxed",children:re.category_name})]})}),o.jsx("td",{className:"min-w-[200px] border border-border p-3 align-top",children:U(re,"definition")}),o.jsx("td",{className:"min-w-[200px] border border-border p-3 align-top",children:U(re,"coding_rule")}),o.jsx("td",{className:"min-w-[200px] border border-border p-3 align-top",children:U(re,"anchor_example")}),a.map(ae=>o.jsx("td",{className:"min-w-[250px] cursor-pointer border border-border p-3 align-top hover:bg-primary/[0.025]",onClick:()=>q(re.category_id,re.category_name,ae),children:o.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed text-muted-foreground",children:re[ae]||"—"})},ae))]},re.category_id))})]}):o.jsxs("table",{className:"w-full border-collapse",children:[o.jsx("thead",{className:"sticky top-0 z-30 bg-muted",children:o.jsxs("tr",{children:[o.jsx("th",{className:"sticky left-0 z-40 min-w-[150px] border border-border bg-muted p-3 text-left text-sm font-semibold",children:"Category"}),o.jsx("th",{className:"min-w-[300px] border border-border p-3 text-left text-sm font-semibold",children:"Codebook details"}),a.map(re=>o.jsx("th",{className:"min-w-[250px] border border-border p-3 text-left text-sm font-semibold",children:re},re))]})}),o.jsx("tbody",{children:Y.map((re,ue)=>o.jsxs("tr",{className:ue%2===0?"bg-background":"bg-muted/[0.16]",children:[o.jsx("td",{className:"sticky left-0 z-20 min-w-[150px] border border-border bg-inherit p-3 align-top",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-primary/10 text-xs font-semibold text-primary",children:ue+1}),o.jsx("span",{className:"text-sm font-semibold leading-relaxed",children:re.category_name})]})}),o.jsx("td",{className:"min-w-[300px] border border-border p-3 align-top",children:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Definition"}),U(re,"definition")]}),o.jsxs("div",{className:"border-t border-border/60 pt-3",children:[o.jsx("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Coding rule"}),U(re,"coding_rule")]}),o.jsxs("div",{className:"border-t border-border/60 pt-3",children:[o.jsx("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Anchor example"}),U(re,"anchor_example")]})]})}),a.map(ae=>o.jsx("td",{className:"min-w-[250px] cursor-pointer border border-border p-3 align-top hover:bg-primary/[0.025]",onClick:()=>q(re.category_id,re.category_name,ae),children:o.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed text-muted-foreground",children:re[ae]||"—"})},ae))]},re.category_id))})]})}),Y.length===0&&o.jsxs("div",{className:"py-12 text-center text-muted-foreground",children:[o.jsx("p",{className:"text-sm font-medium",children:"No categories found"}),o.jsx("p",{className:"mt-1 text-xs",children:"Try a different search term."})]})]}):o.jsx(Ze,{className:"border-border/70 p-10 shadow-sm",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(nr,{className:"h-5 w-5"})}),o.jsx("p",{className:"mt-3 text-sm font-medium",children:"Select a codebook"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Choose a codebook above to open the interview matrix."})]})}),w&&N&&r&&o.jsx(D7t,{open:w,onOpenChange:j,categoryId:N.categoryId,categoryName:N.categoryName,interviewId:N.interviewId,interviewTitle:N.interviewTitle,codebookId:r,onSuccess:L}),o.jsx(Mi,{open:E,onOpenChange:O,children:o.jsxs(li,{children:[o.jsxs(ci,{children:[o.jsxs(di,{className:"flex items-center gap-2",children:[$==="error"&&o.jsx(af,{className:"h-5 w-5 text-destructive"}),M]}),o.jsx(hi,{className:"whitespace-pre-line",children:D})]}),o.jsxs(ui,{children:[$==="error"&&o.jsx(ai,{onClick:()=>oe("cancel"),children:"OK"}),$==="warning"&&o.jsxs(o.Fragment,{children:[o.jsx(Ws,{onClick:()=>oe("cancel"),children:"Abbrechen"}),o.jsx(me,{onClick:()=>oe("skip"),variant:"outline",children:"Nur existierende importieren"}),o.jsx(ai,{onClick:()=>oe("placeholder"),children:"Mit Platzhaltern fortfahren"})]}),$==="confirm"&&o.jsxs(o.Fragment,{children:[o.jsx(Ws,{onClick:()=>oe("cancel"),children:"Abbrechen"}),o.jsx(ai,{onClick:()=>oe("confirm"),children:"Import durchführen"})]})]})]})})]})}function $7t(){const{user:t}=Ht(),{toast:e}=Bn(),[r,n]=S.useState([]),[s,i]=S.useState({title:"",source:"",raw_text:""}),[a,l]=S.useState(null),[c,u]=S.useState(!1),[d,h]=S.useState(null),[f,p]=S.useState({title:"",source:"",raw_text:""}),[m,g]=S.useState(!1);S.useEffect(()=>{t&&y()},[t]);const y=async()=>{const{data:w,error:j}=await pe.from("interviews").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});j?e({title:"Error loading interviews",variant:"destructive"}):n(w||[])},x=async()=>{if(!s.title.trim()||!s.raw_text.trim()){e({title:"Title and text are required",variant:"destructive"});return}try{const{error:w}=await pe.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(w)throw w;e({title:"Interview added successfully"}),i({title:"",source:"",raw_text:""}),u(!1),y()}catch{e({title:"Error adding",variant:"destructive"})}},v=w=>{h(w),p({title:w.title,source:w.source||"",raw_text:w.raw_text})},b=async()=>{if(!d||!f.title.trim()||!f.raw_text.trim()){e({title:"Title and text are required",variant:"destructive"});return}g(!0);try{const{error:w}=await pe.from("interviews").update({title:f.title.trim(),source:f.source.trim(),raw_text:f.raw_text.trim()}).eq("id",d.id);if(w)throw w;e({title:"Interview updated successfully"}),h(null),y()}catch{e({title:"Error updating interview",variant:"destructive"})}finally{g(!1)}};return o.jsxs("div",{className:"container mx-auto max-w-6xl space-y-6 p-4 sm:p-6",children:[o.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(sv,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Interviews"}),o.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:"Add, review, and maintain the interview material used in your qualitative analysis."})]})]}),o.jsxs(me,{onClick:()=>u(w=>!w),className:"gap-2 self-start",children:[o.jsx(Bs,{className:"h-4 w-4"}),"Add interview",o.jsx(ia,{className:`h-4 w-4 transition-transform ${c?"rotate-180":""}`})]})]}),o.jsx(Vh,{open:c,onOpenChange:u,children:o.jsx(qh,{children:o.jsx(Ze,{className:"border-border/70 bg-primary/[0.02] shadow-sm",children:o.jsxs(st,{className:"p-5 sm:p-6",children:[o.jsxs("div",{className:"mb-5 flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(Bs,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold",children:"Add interview"}),o.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:"Give the interview a clear title and paste the complete transcript or source text below."})]})]}),o.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"new-interview-title",children:["Title ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ue,{id:"new-interview-title",value:s.title,onChange:w=>i({...s,title:w.target.value}),placeholder:"e.g. Expert Interview 01"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"new-interview-source",children:["Source",o.jsx("span",{className:"ml-1 font-normal text-muted-foreground",children:"optional"})]}),o.jsx(Ue,{id:"new-interview-source",value:s.source,onChange:w=>i({...s,source:w.target.value}),placeholder:"e.g. Person A, Organization, Document XYZ"})]})]}),o.jsxs("div",{className:"mt-4 space-y-2",children:[o.jsxs(Se,{htmlFor:"new-interview-text",children:["Interview text ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(lr,{id:"new-interview-text",value:s.raw_text,onChange:w=>i({...s,raw_text:w.target.value}),placeholder:"Paste the complete interview text here...",rows:10,className:"resize-y leading-relaxed"})]}),o.jsxs("div",{className:"mt-5 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[o.jsx(me,{variant:"outline",onClick:()=>u(!1),children:"Cancel"}),o.jsxs(me,{onClick:x,className:"gap-2",children:[o.jsx(Bs,{className:"h-4 w-4"}),"Add interview"]})]})]})})})}),o.jsx("div",{className:"flex items-end justify-between gap-4 border-b border-border/70 pb-4",children:o.jsxs("div",{children:[o.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Interview library"}),o.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:[r.length," ",r.length===1?"interview":"interviews"," available for coding and analysis."]})]})}),r.length===0?o.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 px-5 py-10 text-center",children:[o.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(sv,{className:"h-5 w-5"})}),o.jsx("p",{className:"mt-3 text-sm font-medium",children:"No interviews yet"}),o.jsx("p",{className:"mx-auto mt-1 max-w-lg text-xs leading-relaxed text-muted-foreground",children:"Add your first interview to make it available for coding and qualitative analysis."}),o.jsxs(me,{onClick:()=>u(!0),variant:"outline",className:"mt-4 gap-2",children:[o.jsx(Bs,{className:"h-4 w-4"}),"Add interview"]})]}):o.jsx("div",{className:"space-y-3",children:r.map((w,j)=>{const N=a===w.id;return o.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/70 bg-card shadow-sm",children:[o.jsxs("div",{className:"flex flex-col gap-4 px-4 py-4 sm:px-5 lg:flex-row lg:items-center lg:justify-between",children:[o.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[o.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-xs font-semibold text-primary",children:String(j+1).padStart(2,"0")}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h3",{className:"truncate text-sm font-semibold",children:w.title}),o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[w.source&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(afe,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"max-w-[280px] truncate",children:w.source})]}),o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(V2,{className:"h-3.5 w-3.5"}),new Date(w.created_at).toLocaleDateString()]}),o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx(jr,{className:"h-3.5 w-3.5"}),w.raw_text.length.toLocaleString()," characters"]})]})]})]}),o.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[o.jsxs(me,{onClick:()=>l(N?null:w.id),size:"sm",variant:"outline",className:"gap-2",children:[o.jsx(pl,{className:"h-4 w-4"}),N?"Hide text":"View text"]}),o.jsxs(me,{onClick:()=>v(w),size:"sm",variant:"outline",className:"gap-2",children:[o.jsx(EB,{className:"h-4 w-4"}),"Edit"]})]})]}),N&&o.jsx("div",{className:"border-t border-border/70 bg-muted/20 px-4 py-4 sm:px-5",children:o.jsx("div",{className:"max-h-[320px] overflow-y-auto rounded-lg border border-border/70 bg-background p-4",children:o.jsx("pre",{className:"whitespace-pre-wrap break-words font-sans text-sm leading-relaxed text-foreground",children:w.raw_text})})})]},w.id)})}),o.jsx(jn,{open:!!d,onOpenChange:w=>!w&&h(null),children:o.jsxs(pn,{className:"max-w-2xl p-0",children:[o.jsx("div",{className:"border-b border-border/70 px-5 py-5 sm:px-6",children:o.jsx(mn,{className:"space-y-0 text-left",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(EB,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx(gn,{className:"text-lg font-semibold tracking-tight",children:"Edit interview"}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Update the interview metadata or transcript."})]})]})})}),o.jsxs("div",{className:"space-y-4 px-5 py-5 sm:px-6",children:[o.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"edit-interview-title",children:["Title ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(Ue,{id:"edit-interview-title",value:f.title,onChange:w=>p({...f,title:w.target.value}),placeholder:"Interview Title"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"edit-interview-source",children:["Source",o.jsx("span",{className:"ml-1 font-normal text-muted-foreground",children:"optional"})]}),o.jsx(Ue,{id:"edit-interview-source",value:f.source,onChange:w=>p({...f,source:w.target.value}),placeholder:"e.g. Person A, Document XYZ"})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{htmlFor:"edit-interview-text",children:["Interview text ",o.jsx("span",{className:"text-destructive",children:"*"})]}),o.jsx(lr,{id:"edit-interview-text",value:f.raw_text,onChange:w=>p({...f,raw_text:w.target.value}),placeholder:"Complete interview text...",rows:14,className:"resize-y leading-relaxed"})]})]}),o.jsxs(kf,{className:"border-t border-border/70 bg-muted/20 px-5 py-4 sm:px-6",children:[o.jsx(me,{variant:"outline",onClick:()=>h(null),disabled:m,children:"Cancel"}),o.jsxs(me,{onClick:b,disabled:m,className:"gap-2",children:[m&&o.jsx(Xe,{className:"h-4 w-4 animate-spin"}),m?"Saving...":"Save changes"]})]})]})})]})}function F7t({selectedCodebook:t,selectedInterviews:e,selectedCategory:r,categories:n,interviews:s,userId:i,onCodingComplete:a}){const{toast:l}=Bn(),[c,u]=S.useState([]),[d,h]=S.useState(!1),[f,p]=S.useState(!1),[m,g]=S.useState("all"),[y,x]=S.useState(new Set),[v,b]=S.useState(new Set);S.useEffect(()=>{t&&e.length>0?w():u([])},[t,e]);const w=async()=>{h(!0);try{const{data:M,error:k}=await pe.from("coded_segments").select("*").eq("user_id",i).eq("codebook_id",t).in("interview_id",e).order("created_at",{ascending:!1});if(k)throw k;u(M||[])}catch(M){console.error("Error loading segments:",M),l({title:"Error loading segments",variant:"destructive"})}finally{h(!1)}},j=async(M,k)=>{p(!0);try{const D={codebook_id:t,interview_id:M,category_id:r==="all"?null:r};k&&(D.overwrite_existing=!0);const{data:K,error:H}=await pe.functions.invoke("codebooks_apply",{body:D});if(H)throw H;l({title:`${K.created_segments} coded segments created`,description:k?"Existing coding was replaced":"New coding was added"}),await w(),a==null||a()}catch(D){console.error("Recode error:",D),l({title:"Error during coding",variant:"destructive"})}finally{p(!1)}},N=()=>{const M={};return c.forEach(k=>{M[k.interview_id]||(M[k.interview_id]={}),M[k.interview_id][k.category_id]||(M[k.interview_id][k.category_id]=[]),M[k.interview_id][k.category_id].push(k)}),M},C=M=>{const k=new Set(y);k.has(M)?k.delete(M):k.add(M),x(k)},A=M=>{const k=new Set(v);k.has(M)?k.delete(M):k.add(M),b(k)},E=(M,k=280)=>M.length<=k?{truncated:M,isTruncated:!1}:{truncated:`${M.substring(0,k)}...`,isTruncated:!0};if(!t||e.length===0)return null;const O=N(),$=m==="all"?null:new Set([m]),T=m==="all"?c.length:c.filter(M=>M.category_id===m).length;return d?o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsx(st,{className:"flex min-h-[220px] items-center justify-center",children:o.jsxs("div",{className:"flex flex-col items-center gap-3 text-muted-foreground",children:[o.jsx(Xe,{className:"h-6 w-6 animate-spin text-primary"}),o.jsx("span",{className:"text-sm",children:"Loading coded segments..."})]})})}):c.length===0?o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs(st,{className:"py-10 text-center",children:[o.jsx("div",{className:"mx-auto flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(T_,{className:"h-5 w-5"})}),o.jsx("p",{className:"mt-3 text-sm font-medium",children:"No coded segments yet"}),o.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Run automatic coding above to generate your first results."})]})}):o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs(st,{className:"p-0",children:[o.jsxs("div",{className:"flex flex-col gap-3 border-b border-border/70 px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[o.jsxs("div",{children:[o.jsxs("p",{className:"text-sm font-semibold",children:[T," ",T===1?"coded segment":"coded segments"]}),o.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Grouped by interview and category"})]}),o.jsxs(pt,{value:m,onValueChange:g,children:[o.jsx(ut,{className:"w-full sm:w-[220px]",children:o.jsx(mt,{placeholder:"Filter by category..."})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"all",children:"All categories"}),n.map(M=>o.jsx(Le,{value:M.id,children:M.name},M.id))]})]})]}),o.jsx("div",{className:"space-y-6 p-4 sm:p-5",children:e.map(M=>{const k=s.find(ee=>ee.id===M),D=O[M];if(!k||!D)return null;const K=Object.entries(D).filter(([ee])=>!$||$.has(ee)),H=K.reduce((ee,[,V])=>ee+V.length,0);return H===0?null:o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex flex-col gap-3 rounded-xl bg-muted/20 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold",children:k.title}),o.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[H," ",H===1?"segment":"segments"]})]}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsxs(me,{onClick:()=>j(M,!0),disabled:f,variant:"outline",size:"sm",className:"gap-2",children:[f?o.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(nfe,{className:"h-3.5 w-3.5"}),"Replace coding"]}),o.jsxs(me,{onClick:()=>j(M,!1),disabled:f,variant:"outline",size:"sm",className:"gap-2",children:[f?o.jsx(Xe,{className:"h-3.5 w-3.5 animate-spin"}):o.jsx(SMe,{className:"h-3.5 w-3.5"}),"Add coding"]})]})]}),o.jsx("div",{className:"space-y-3",children:K.map(([ee,V])=>{const B=n.find(ie=>ie.id===ee),z=`${M}-${ee}`,F=y.has(z),G=F?V:V.slice(0,3),Q=V.length>3;return o.jsxs("div",{className:"overflow-hidden rounded-xl border border-border/70",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border/70 bg-muted/20 px-4 py-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("h4",{className:"truncate text-sm font-semibold",children:(B==null?void 0:B.name)||"Unknown category"}),o.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[V.length," ",V.length===1?"segment":"segments"]})]}),Q&&o.jsx(me,{onClick:()=>C(z),variant:"ghost",size:"sm",className:"gap-1.5",children:F?o.jsxs(o.Fragment,{children:[o.jsx(FW,{className:"h-4 w-4"}),"Show less"]}):o.jsxs(o.Fragment,{children:[o.jsx(ia,{className:"h-4 w-4"}),"Show all"]})})]}),o.jsx("div",{className:"divide-y divide-border/70",children:G.map((ie,se)=>{var W;const{truncated:q,isTruncated:L}=E(ie.snippet),Z=v.has(ie.id),J=Z?ie.snippet:q;return o.jsx("div",{className:"px-4 py-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-primary/10 text-xs font-semibold text-primary",children:se+1}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:J}),L&&o.jsx(me,{onClick:()=>A(ie.id),variant:"ghost",size:"sm",className:"mt-1 h-7 px-0 text-xs text-primary hover:bg-transparent",children:Z?"Show less":"Show full text"}),o.jsxs("div",{className:"mt-3 flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[o.jsxs("span",{children:["Confidence: ",((W=ie.confidence)==null?void 0:W.toFixed(2))||"N/A"]}),o.jsxs("span",{children:["Position: ",ie.start_char,"–",ie.end_char]}),o.jsxs("span",{children:["Created:"," ",new Date(ie.created_at).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})]})]})]})]})},ie.id)})})]},z)})})]},M)})})]})})}function B7t(){const{user:t,checkStudentPoints:e,studentPoints:r}=Ht(),[n,s]=S.useState(!1),{toast:i}=Bn(),[a,l]=S.useState([]),[c,u]=S.useState(""),[d,h]=S.useState([]),[f,p]=S.useState("all"),[m,g]=S.useState([]),[y,x]=S.useState([]),[v,b]=S.useState(!1),[w,j]=S.useState(0);S.useEffect(()=>{t&&(N(),A())},[t]),S.useEffect(()=>{p("all"),c?C():h([])},[c]);const N=async()=>{const{data:k,error:D}=await pe.from("codebooks").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});D?i({title:"Error loading codebooks",variant:"destructive"}):l(k||[])},C=async()=>{if(!c)return;const{data:k,error:D}=await pe.from("codebook_categories").select("*").eq("codebook_id",c).order("order_index",{ascending:!0});D?i({title:"Error loading categories",variant:"destructive"}):h(k||[])},A=async()=>{const{data:k,error:D}=await pe.from("interviews").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});D?i({title:"Error loading interviews",variant:"destructive"}):g(k||[])},E=async()=>{if(!e()){s(!0);return}if(!c||y.length===0){i({title:"Select codebook and interview",variant:"destructive"});return}b(!0);try{for(const k of y){const{data:D,error:K}=await pe.functions.invoke("codebooks_apply",{body:{codebook_id:c,interview_id:k,category_id:f==="all"?null:f}});if(K)throw K;i({title:"Automatic coding complete",description:`${D.created_segments} coded segments created`})}j(k=>k+1)}catch{i({title:"Error during automatic coding",variant:"destructive"})}finally{b(!1)}},O=m.find(k=>k.id===y[0]),$=a.find(k=>k.id===c),T=f==="all"?null:d.find(k=>k.id===f),M=!!O&&!!$&&d.length>0;return o.jsxs("div",{className:"container mx-auto max-w-6xl space-y-6 p-4 sm:p-6",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(FOe,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Coding"}),o.jsx("p",{className:"mt-1 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:"Select an interview and a codebook, then let Academly identify and assign relevant coded passages."})]})]}),o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs(st,{className:"p-0",children:[o.jsx("div",{className:"border-b border-border/70 px-5 py-4 sm:px-6",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(Sr,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold",children:"Automatic coding"}),o.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:"Complete the three steps below. Existing coding results remain available underneath."})]})]})}),o.jsxs("div",{className:"grid lg:grid-cols-3",children:[o.jsxs("div",{className:"border-b border-border/70 p-5 sm:p-6 lg:border-b-0 lg:border-r",children:[o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-semibold ${O?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"}`,children:O?o.jsx(kr,{className:"h-3.5 w-3.5"}):"1"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold",children:"Choose interview"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Select the text you want to code."})]})]}),o.jsx(Se,{className:"mb-2 block text-xs text-muted-foreground",children:"Interview"}),o.jsxs(pt,{value:y[0]||"",onValueChange:k=>x(k?[k]:[]),children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select interview..."})}),o.jsx(dt,{children:m.map(k=>o.jsx(Le,{value:k.id,children:k.title},k.id))})]}),O&&o.jsx("div",{className:"mt-3 rounded-lg bg-muted/30 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(sv,{className:"h-4 w-4 shrink-0 text-primary"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"truncate text-sm font-medium",children:O.title}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:[O.raw_text.length.toLocaleString()," characters"]})]})]})})]}),o.jsxs("div",{className:"border-b border-border/70 p-5 sm:p-6 lg:border-b-0 lg:border-r",children:[o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-semibold ${$?"bg-primary text-primary-foreground":"bg-primary/10 text-primary"}`,children:$?o.jsx(kr,{className:"h-3.5 w-3.5"}):"2"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold",children:"Choose codebook"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Select the categories Academly should apply."})]})]}),o.jsx(Se,{className:"mb-2 block text-xs text-muted-foreground",children:"Codebook"}),o.jsxs(pt,{value:c,onValueChange:u,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select codebook..."})}),o.jsx(dt,{children:a.map(k=>o.jsx(Le,{value:k.id,children:k.title},k.id))})]}),c&&d.length>0&&o.jsxs("div",{className:"mt-4",children:[o.jsx(Se,{className:"mb-2 block text-xs text-muted-foreground",children:"Categories to apply"}),o.jsxs(pt,{value:f,onValueChange:p,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"all",children:"All categories"}),d.map(k=>o.jsx(Le,{value:k.id,children:k.name},k.id))]})]}),o.jsx("p",{className:"mt-2 text-xs leading-relaxed text-muted-foreground",children:f==="all"?`All ${d.length} categories will be evaluated.`:"Only the selected category will be sent for automatic coding."})]}),$&&o.jsx("div",{className:"mt-3 rounded-lg bg-muted/30 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(nr,{className:"h-4 w-4 shrink-0 text-primary"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("p",{className:"truncate text-sm font-medium",children:$.title}),o.jsx("p",{className:"text-xs text-muted-foreground",children:f==="all"?`${d.length} ${d.length===1?"category":"categories"}`:`Only: ${(T==null?void 0:T.name)??"Selected category"}`})]})]})})]}),o.jsxs("div",{className:"p-5 sm:p-6",children:[o.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[o.jsx("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-semibold ${M?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:"3"}),o.jsxs("div",{children:[o.jsx("p",{className:"text-sm font-semibold",children:"Run coding"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate coded segments automatically."})]})]}),o.jsx("div",{className:"rounded-xl border border-border/70 bg-muted/20 p-3",children:M?o.jsxs("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Academly will analyse"," ",o.jsx("span",{className:"font-medium text-foreground",children:O==null?void 0:O.title})," using"," ",o.jsx("span",{className:"font-medium text-foreground",children:$==null?void 0:$.title}),f==="all"?o.jsxs(o.Fragment,{children:[" and evaluate all ",d.length," categories."]}):o.jsxs(o.Fragment,{children:[" ","and only apply ",o.jsx("span",{className:"font-medium text-foreground",children:T==null?void 0:T.name}),"."]})]}):o.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Select an interview and a codebook with at least one category to continue."})}),o.jsxs(me,{onClick:E,disabled:v||!M,className:"mt-4 w-full gap-2",children:[v?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(Sr,{className:"h-4 w-4"}),v?"Coding interview...":"Start automatic coding"]})]})]})]})}),c&&y.length>0&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{className:"border-b border-border/70 pb-4",children:[o.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Coding results"}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Review all stored coded passages for this interview. Category-specific coding adds or replaces only the selected category."})]}),o.jsx(F7t,{selectedCodebook:c,selectedInterviews:y,selectedCategory:f,categories:d,interviews:m,userId:t==null?void 0:t.id},`${c}-${y.join(",")}-${w}`)]}),o.jsx(cu,{open:n,onClose:()=>s(!1),remainingPoints:(r==null?void 0:r.remaining)??0})]})}const Lce={small:{wordMin:150,wordMax:300,overheadTokens:600},medium:{wordMin:300,wordMax:600,overheadTokens:700},big:{wordMin:500,wordMax:900,overheadTokens:800}},z7t=t=>Math.round(t*1.4),U7t=t=>Math.round(t/4);function H7t(){const{user:t,checkStudentPoints:e,studentPoints:r}=Ht(),[n,s]=S.useState(!1),{toast:i}=Bn(),[a,l]=S.useState([]),[c,u]=S.useState(""),[d,h]=S.useState([]),[f,p]=S.useState(""),[m,g]=S.useState("medium"),[y,x]=S.useState("de"),[v,b]=S.useState(null),[w,j]=S.useState(!1),[N,C]=S.useState([]),[A,E]=S.useState(""),[O,$]=S.useState([]),[T,M]=S.useState(""),[k,D]=S.useState({prompt:0,completion:0,total:0}),[K,H]=S.useState(null),[ee,V]=S.useState([]),[B,z]=S.useState(!1),[F,G]=S.useState(""),[Q,ie]=S.useState(""),[se,q]=S.useState(!1);S.useEffect(()=>{t&&(J(),X())},[t]),S.useEffect(()=>{c&&W()},[c]),S.useEffect(()=>{A?(he(),L()):($([]),M(""),V([]),G(""))},[A]);const L=async()=>{const{data:I}=await pe.from("chapters").select("id, title, order_index").eq("thesis_id",A).order("order_index");V(I||[])},Z=async()=>{if(!(!F||!v)){q(!0);try{const{data:I}=await pe.from("sections").select("order_index").eq("chapter_id",F).order("order_index",{ascending:!1}).limit(1),U=I!=null&&I.length?I[0].order_index+1:0,re=v.category_conclusion?`

Fazit Kategorie: ${v.title}
${v.category_conclusion}`:"",ue=v.summary_text+re;await pe.from("sections").insert({chapter_id:F,content:ue,title:Q.trim()||null,type:"other",order_index:U,status:"open"}),i({title:"Successfully imported",description:"Saved as section in chapter."}),z(!1),ie(""),G("")}catch{i({title:"Fehler beim Import",variant:"destructive"})}finally{q(!1)}}};S.useEffect(()=>{oe()},[f,T,c,d,O,m]);const J=async()=>{const{data:I,error:U}=await pe.from("codebooks").select("*").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});U?i({title:"Error loading codebooks",variant:"destructive"}):l(I||[])},W=async()=>{if(!c)return;const{data:I,error:U}=await pe.from("codebook_categories").select("*").eq("codebook_id",c).order("order_index",{ascending:!0});U?i({title:"Error loading categories",variant:"destructive"}):h(I||[])},X=async()=>{const{data:I,error:U}=await pe.from("theses").select("id, title, description").eq("user_id",t==null?void 0:t.id).order("created_at",{ascending:!1});U?i({title:"Error loading the theses",variant:"destructive"}):C(I||[])},he=async()=>{const{data:I,error:U}=await pe.from("sections").select(`
        id,
        title,
        content,
        order_index,
        chapters!inner(title, thesis_id, order_index)
      `).eq("chapters.thesis_id",A);if(U)console.error("Section load error:",U),i({title:"Error loading the Section",description:U.message,variant:"destructive"});else{const re=(I||[]).sort((ue,ae)=>{var ge,we;return(((ge=ue.chapters)==null?void 0:ge.order_index)||0)-(((we=ae.chapters)==null?void 0:we.order_index)||0)});$(re)}},P=I=>I?I.trim().split(/\s+/).slice(0,8).join(" ")+(I.split(/\s+/).length>8?"...":""):"",oe=async()=>{var ne,fe,be,xe;if(!c||!f){D({prompt:0,completion:0,total:0});return}const I=Lce[m]??Lce.medium,U=z7t((I.wordMin+I.wordMax)/2);let re=0;const ue=d.find(_e=>_e.id===f);ue&&(re+=((ne=ue.name)==null?void 0:ne.length)||0,re+=((fe=ue.definition)==null?void 0:fe.length)||0,re+=((be=ue.anchor_example)==null?void 0:be.length)||0,re+=((xe=ue.coding_rule)==null?void 0:xe.length)||0);const ae=O.find(_e=>_e.id===T);if(ae!=null&&ae.content&&(re+=ae.content.length),f&&c)try{const{data:_e}=await pe.from("coded_segments").select("snippet, interviews!inner(title)").eq("category_id",f).eq("codebook_id",c);if(_e&&_e.length>0){_e.forEach($e=>{var Te,ot,wt;re+=((Te=$e.snippet)==null?void 0:Te.length)||0,re+=((wt=(ot=$e.interviews)==null?void 0:ot.title)==null?void 0:wt.length)||0});const ke=[...new Set(_e.map($e=>{var Te;return((Te=$e.interviews)==null?void 0:Te.title)||""}))];re+=ke.join(", ").length}}catch(_e){console.error("Error loading snippets for estimation:",_e)}const we=I.overheadTokens+200+U7t(re),ce=we+U;D({prompt:we,completion:U,total:ce})},Y=async()=>{var I,U,re;if(!e()){s(!0);return}if(!c||!f){i({title:"Select coding sheet and category",variant:"destructive"});return}j(!0),H(null);try{const{data:ue}=await pe.from("codebook_categories").select("name, definition, anchor_example, coding_rule").eq("id",f).single(),{data:ae}=await pe.from("coded_segments").select(`
          snippet,
          interviews!inner(title)
        `).eq("category_id",f).eq("codebook_id",c),ge=[...new Set((ae==null?void 0:ae.map(be=>be.interviews.title))||[])],we=(ae==null?void 0:ae.map(be=>({snippet:be.snippet,interview_title:be.interviews.title})))||[];let ce="";if(T){const{data:be}=await pe.from("sections").select("content").eq("id",T).single();ce=(be==null?void 0:be.content)||""}const{data:ne,error:fe}=await pe.functions.invoke("analysis_results",{body:{codebook_id:c,category_id:f,mode:m,language:y,thesis_id:A||null,section_id:T||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:ge,snippet_count:we.length,all_snippets:we},section_content:ce}});if(fe)throw fe;b(ne),H({prompt:(I=ne==null?void 0:ne.usage)==null?void 0:I.prompt_tokens,completion:(U=ne==null?void 0:ne.usage)==null?void 0:U.completion_tokens,total:(re=ne==null?void 0:ne.usage)==null?void 0:re.total_tokens}),i({title:"Analysis generated successfully!"})}catch(ue){console.error("Error:",ue),i({title:"Error during generation",description:ue.message,variant:"destructive"})}finally{j(!1)}},R=async()=>{if(!(!v||!c))try{const{error:I}=await pe.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(I)throw I;i({title:"Summary saved to library"})}catch{i({title:"Error saving",variant:"destructive"})}};return o.jsxs("div",{className:"container mx-auto max-w-6xl space-y-6 p-4 sm:p-6",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(nv,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Analysis"}),o.jsx("p",{className:"mt-1 max-w-3xl text-sm leading-relaxed text-muted-foreground",children:"Turn coded interview material into a structured qualitative analysis and connect the findings with your thesis context."})]})]}),o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs(st,{className:"p-0",children:[o.jsx("div",{className:"border-b border-border/70 px-5 py-4 sm:px-6",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(TE,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"text-sm font-semibold",children:"Analysis basis"}),o.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:"Choose the codebook category Academly should analyse and define the desired output length and language."})]})]})}),o.jsxs("div",{className:"grid gap-5 p-5 sm:p-6 lg:grid-cols-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Coding sheet *"}),o.jsxs(pt,{value:c,onValueChange:u,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select coding sheet..."})}),o.jsx(dt,{children:a.map(I=>o.jsx(Le,{value:I.id,children:I.title},I.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Category *"}),o.jsxs(pt,{value:f,onValueChange:p,disabled:!c,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:c?"Select category...":"Select coding sheet first"})}),o.jsx(dt,{children:d.map(I=>o.jsx(Le,{value:I.id,children:I.name},I.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Analysis depth"}),o.jsxs(pt,{value:m,onValueChange:g,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"small",children:"Short · 150–300 words"}),o.jsx(Le,{value:"medium",children:"Medium · 300–600 words"}),o.jsx(Le,{value:"big",children:"Detailed · 500–900 words"})]})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Language"}),o.jsxs(pt,{value:y,onValueChange:x,children:[o.jsx(ut,{children:o.jsx(mt,{})}),o.jsxs(dt,{children:[o.jsx(Le,{value:"de",children:"German"}),o.jsx(Le,{value:"en",children:"English"})]})]})]})]}),o.jsx("div",{className:"border-t border-border/70",children:o.jsxs("div",{className:"grid lg:grid-cols-[220px_minmax(0,1fr)]",children:[o.jsxs("div",{className:"border-b border-border/70 p-5 sm:p-6 lg:border-b-0 lg:border-r",children:[o.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(nr,{className:"h-4 w-4"})}),o.jsx("h3",{className:"mt-4 text-sm font-semibold",children:"Thesis context"}),o.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:"Connect the coded material with your thesis. A theory section is optional and can provide additional context."})]}),o.jsxs("div",{className:"space-y-4 p-5 sm:p-6",children:[N.length===0&&o.jsxs(yf,{children:[o.jsx(af,{className:"h-4 w-4"}),o.jsx(Lq,{children:"No thesis available"}),o.jsxs(vf,{children:["Please create a thesis first in"," ",o.jsx(Nt,{to:"/thesis-builder",className:"font-medium underline",children:"Thesis Builder"}),", before you can perform an analysis."]})]}),o.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Thesis *"}),o.jsxs(pt,{value:A,onValueChange:I=>{E(I),M("")},children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Choose thesis..."})}),o.jsx(dt,{children:N.map(I=>o.jsx(Le,{value:I.id,children:I.title},I.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{children:["Theory section",o.jsx("span",{className:"ml-1 font-normal text-muted-foreground",children:"optional"})]}),o.jsxs(pt,{value:T,onValueChange:M,disabled:!A,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:A?"Select section...":"Select thesis first"})}),o.jsx(dt,{children:O.map(I=>o.jsx(Le,{value:I.id,children:I.title?`${I.title} (${I.chapters.title})`:`${I.chapters.title} – ${P(I.content)}`},I.id))})]})]})]})]})]})}),o.jsxs("div",{className:"flex flex-col gap-3 border-t border-border/70 bg-muted/20 px-5 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-6",children:[o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx(Sr,{className:"h-4 w-4 text-primary"}),o.jsx("span",{children:"Uses coded segments, category metadata, and optional thesis context."})]}),o.jsxs(me,{onClick:Y,disabled:w||!c||!f||!A,className:"gap-2 sm:min-w-[180px]",children:[w?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(Sr,{className:"h-4 w-4"}),w?"Generating...":"Start analysis"]})]})]})}),v&&o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex flex-col gap-3 border-b border-border/70 pb-4 sm:flex-row sm:items-end sm:justify-between",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-primary",children:[o.jsx(No,{className:"h-4 w-4"}),"Analysis complete"]}),o.jsx("h2",{className:"mt-1 text-xl font-semibold tracking-tight",children:"Research report"}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Review the generated interpretation and supporting interview evidence."})]}),o.jsxs("div",{className:"flex flex-wrap gap-2",children:[o.jsxs(me,{onClick:()=>z(!0),variant:"outline",size:"sm",disabled:!A,className:"gap-2",children:[o.jsx(s1,{className:"h-4 w-4"}),"Import to chapter"]}),o.jsxs(me,{onClick:R,variant:"outline",size:"sm",className:"gap-2",children:[o.jsx(lMe,{className:"h-4 w-4"}),"Save to library"]})]})]}),o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs(st,{className:"p-5 sm:p-6",children:[o.jsxs("div",{className:"mb-5 flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(jr,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-base font-semibold",children:v.title}),o.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"AI-generated qualitative interpretation"})]})]}),o.jsx("div",{className:"whitespace-pre-wrap text-sm leading-7 text-foreground",children:v.summary_text}),v.category_conclusion&&o.jsx("div",{className:"mt-6 border-t border-border/70 pt-5",children:o.jsxs("div",{className:"rounded-xl border border-primary/20 bg-primary/[0.025] p-4",children:[o.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-primary",children:"Category conclusion"}),o.jsx("p",{className:"mt-2 whitespace-pre-wrap text-sm leading-7",children:v.category_conclusion})]})})]})}),v.proof_json&&v.proof_json.length>0&&o.jsx(Ze,{className:"border-border/70 shadow-sm",children:o.jsxs(st,{className:"p-5 sm:p-6",children:[o.jsxs("div",{className:"mb-5 flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:o.jsx(ua,{className:"h-4 w-4"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold",children:"Supporting material"}),o.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Interview excerpts used to support the generated analysis."})]})]}),o.jsx("div",{className:"space-y-3",children:v.proof_json.map((I,U)=>o.jsx("div",{className:"rounded-xl border border-border/70 bg-muted/20 p-4",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-background text-xs font-semibold text-muted-foreground ring-1 ring-border/70",children:String(U+1).padStart(2,"0")}),o.jsxs("div",{className:"min-w-0",children:[o.jsxs("blockquote",{className:"text-sm italic leading-relaxed",children:["“",I.quote,"”"]}),o.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:I.interview_title})]})]})},U))})]})})]}),o.jsx(jn,{open:B,onOpenChange:z,children:o.jsxs(pn,{className:"max-w-lg p-0",children:[o.jsx("div",{className:"border-b border-border/70 px-5 py-5 sm:px-6",children:o.jsx(mn,{className:"space-y-0 text-left",children:o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:o.jsx(s1,{className:"h-5 w-5"})}),o.jsxs("div",{children:[o.jsx(gn,{className:"text-lg font-semibold tracking-tight",children:"Import as section"}),o.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Add this analysis directly to one of your thesis chapters."})]})]})})}),o.jsxs("div",{className:"space-y-4 px-5 py-5 sm:px-6",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Se,{children:"Target chapter"}),o.jsxs(pt,{value:F,onValueChange:G,children:[o.jsx(ut,{children:o.jsx(mt,{placeholder:"Select chapter..."})}),o.jsx(dt,{children:ee.map(I=>o.jsx(Le,{value:I.id,children:I.title},I.id))})]})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsxs(Se,{children:["Section title",o.jsx("span",{className:"ml-1 font-normal text-muted-foreground",children:"optional"})]}),o.jsx(Ue,{value:Q,onChange:I=>ie(I.target.value),placeholder:"e.g. Interview Analysis"})]})]}),o.jsxs(kf,{className:"border-t border-border/70 bg-muted/20 px-5 py-4 sm:px-6",children:[o.jsx(me,{variant:"outline",onClick:()=>z(!1),disabled:se,children:"Cancel"}),o.jsxs(me,{onClick:Z,disabled:!F||se,className:"gap-2",children:[se?o.jsx(Xe,{className:"h-4 w-4 animate-spin"}):o.jsx(No,{className:"h-4 w-4"}),se?"Importing...":"Import"]})]})]})}),o.jsx(cu,{open:n,onClose:()=>s(!1),remainingPoints:(r==null?void 0:r.remaining)??0})]})}const W7t=()=>{const t=bd();return S.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),o.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:[o.jsx(Di,{title:"Page Not Found | Academly.ai",description:"Private page on Academly.ai.",canonical:"https://academly.ai/404",noIndex:!0}),o.jsxs("div",{className:"text-center",children:[o.jsx("h1",{className:"text-4xl font-bold mb-4",children:"404"}),o.jsx("p",{className:"text-xl text-gray-600 mb-4",children:"Oops! Page not found"}),o.jsx("a",{href:"/",className:"text-blue-500 hover:text-blue-700 underline",children:"Return to Home"})]})]})};function V7t(t){return Array.isArray(t)?t.filter(e=>typeof e=="object"&&e!==null&&typeof e.type=="string"):[]}function BK(){const[t,e]=S.useState([]),[r,n]=S.useState(!0),[s,i]=S.useState(null);return S.useEffect(()=>{let l=!1;return(async()=>{const{data:c,error:u}=await pe.from("docs_pages").select("id, slug, category_slug, title, category, category_order, page_order").order("category_order",{ascending:!0}).order("page_order",{ascending:!0});l||(u?i(u.message):e(c??[]),n(!1))})(),()=>{l=!0}},[]),{categories:S.useMemo(()=>{const l=new Map;for(const c of t){const u=l.get(c.category_slug);u?u.pages.push(c):l.set(c.category_slug,{category:c.category,category_slug:c.category_slug,category_order:c.category_order,pages:[c]})}return Array.from(l.values()).sort((c,u)=>c.category_order-u.category_order).map(c=>({...c,pages:[...c.pages].sort((u,d)=>u.page_order-d.page_order)}))},[t]),pages:t,loading:r,error:s}}function q7t(t,e){const[r,n]=S.useState(null),[s,i]=S.useState(!0),[a,l]=S.useState(!1);return S.useEffect(()=>{if(!t||!e){i(!1),l(!0);return}let c=!1;return i(!0),l(!1),(async()=>{const{data:u,error:d}=await pe.from("docs_pages").select("id, slug, category_slug, title, description, category, category_order, page_order, content_json, seo_title, seo_description, canonical_url").eq("category_slug",t).eq("slug",e).maybeSingle();c||(d||!u?(l(!0),n(null)):n({...u,content_json:V7t(u.content_json)}),i(!1))})(),()=>{c=!0}},[t,e]),{page:r,loading:s,notFound:a}}function $ce({categories:t,onNavigate:e}){return o.jsx("nav",{"aria-label":"Docs navigation",className:"space-y-7",children:t.map(r=>o.jsxs("div",{children:[o.jsx("p",{className:"px-3 mb-2 text-[13px] font-medium uppercase tracking-wide text-foreground",children:r.category}),o.jsx("ul",{className:"space-y-1",children:r.pages.map(n=>o.jsx("li",{children:o.jsx(p3e,{to:`/docs/${n.category_slug}/${n.slug}`,onClick:e,className:({isActive:s})=>["block rounded-full px-3 py-1.5 text-[15px] transition-colors",s?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:text-foreground hover:bg-muted/60"].join(" "),children:n.title})},n.id))})]},r.category_slug))})}const G7t="https://nqibmbtqcjucktqcreob.supabase.co/storage/v1/object/public/src/logo_new.png";function I2e({children:t}){const{categories:e}=BK(),[r,n]=S.useState(!1);return o.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[o.jsx("header",{className:"sticky top-0 z-40 border-b bg-background/95 backdrop-blur",children:o.jsxs("div",{className:"mx-auto flex h-14 md:h-[58px] max-w-[1400px] items-center gap-3 px-4 md:px-8",children:[o.jsxs(aA,{open:r,onOpenChange:n,children:[o.jsx(vSe,{asChild:!0,children:o.jsx("button",{className:"lg:hidden inline-flex h-9 w-9 items-center justify-center rounded-md hover:bg-muted","aria-label":"Open docs navigation",children:o.jsx(rj,{className:"h-5 w-5"})})}),o.jsx(Rj,{side:"left",className:"w-80 overflow-y-auto pt-10",children:o.jsx($ce,{categories:e,onNavigate:()=>n(!1)})})]}),o.jsxs(Nt,{to:"/",className:"flex items-center gap-2 lg:w-[300px] shrink-0",children:[o.jsx("img",{src:G7t,alt:"Academly.ai",className:"h-9 w-auto"}),o.jsx("span",{className:"hidden sm:inline text-base font-medium text-muted-foreground",children:"Docs"})]}),o.jsxs("div",{className:"hidden md:flex flex-1 items-center gap-2 max-w-[520px]",children:[o.jsxs("button",{disabled:!0,title:"Search is coming soon",className:"flex flex-1 items-center gap-2 rounded-full border bg-background px-3.5 h-10 text-[15px] text-muted-foreground cursor-not-allowed",children:[o.jsx(Ti,{className:"h-4 w-4"}),o.jsx("span",{className:"flex-1 text-left",children:"Search..."}),o.jsx("kbd",{className:"rounded border bg-muted/50 px-1.5 text-xs font-mono",children:"Ctrl"}),o.jsx("kbd",{className:"rounded border bg-muted/50 px-1.5 text-xs font-mono",children:"K"})]}),o.jsxs("button",{disabled:!0,title:"Coming soon",className:"flex items-center gap-1.5 rounded-full border px-4 h-10 text-[15px] text-muted-foreground cursor-not-allowed",children:[o.jsx(Sr,{className:"h-4 w-4"}),"Ask"]})]}),o.jsx("div",{className:"flex-1"}),o.jsx("button",{disabled:!0,"aria-label":"Search",className:"md:hidden inline-flex h-9 w-9 items-center justify-center rounded-full border text-muted-foreground",children:o.jsx(Ti,{className:"h-4 w-4"})}),o.jsx(me,{asChild:!0,className:"h-12 rounded-full px-8 text-base font-semibold shadow-none transition-transform duration-300 hover:scale-105 hover:bg-primary active:duration-75 active:scale-95 md:px-8",children:o.jsx(Nt,{to:"/login?mode=signup",children:"Start for Free"})}),o.jsx(me,{asChild:!0,variant:"secondary",className:"hidden h-12 rounded-full bg-primary/10 px-8 text-base font-semibold text-primary shadow-none transition-transform duration-300 hover:scale-105 hover:bg-primary/15 active:duration-75 active:scale-95 sm:inline-flex",children:o.jsx(Nt,{to:"/login",children:"Login"})})]})}),o.jsxs("div",{className:"mx-auto flex w-full max-w-[1400px] flex-1 px-4 md:px-8",children:[o.jsx("aside",{className:"hidden lg:block w-[300px] shrink-0",children:o.jsx("div",{className:"sticky top-[58px] h-[calc(100vh-58px)] overflow-y-auto py-8 pr-6",children:o.jsx($ce,{categories:e})})}),o.jsx("main",{className:"flex-1 min-w-0 py-8 lg:pl-14 lg:py-9",children:o.jsx("div",{className:"w-full max-w-[770px]",children:t})})]})]})}function K7t(){const{pages:t,loading:e}=BK();return!e&&t.length>0?o.jsx(p0,{to:`/docs/${t[0].category_slug}/${t[0].slug}`,replace:!0}):o.jsxs(I2e,{children:[o.jsx(Di,{title:"Academly Docs",description:"Guides and documentation for Academly.",canonical:"https://academly.ai/docs"}),e?o.jsxs("div",{className:"space-y-4 animate-pulse",children:[o.jsx("div",{className:"h-9 w-1/2 rounded bg-muted"}),o.jsx("div",{className:"h-4 w-full rounded bg-muted"}),o.jsx("div",{className:"h-4 w-3/4 rounded bg-muted"})]}):o.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[o.jsx(jr,{className:"h-10 w-10 text-muted-foreground mb-4"}),o.jsx("h1",{className:"text-2xl font-semibold text-foreground mb-2",children:"Documentation coming soon"}),o.jsx("p",{className:"text-muted-foreground max-w-md",children:"We're preparing the Academly documentation. Please check back shortly."})]})]})}const Fce={info:{icon:lf,container:"bg-primary/5 border-primary/15",iconColor:"text-primary"},tip:{icon:dd,container:"bg-emerald-500/5 border-emerald-500/20",iconColor:"text-emerald-600 dark:text-emerald-400"},warning:{icon:Jl,container:"bg-amber-500/5 border-amber-500/25",iconColor:"text-amber-600 dark:text-amber-400"}};function Y7t({block:t}){const e=Fce[t.variant??"info"]??Fce.info,r=e.icon;return o.jsxs("div",{className:`rounded-xl border px-5 py-4 flex gap-3 ${e.container}`,children:[o.jsx(r,{className:`h-5 w-5 mt-0.5 shrink-0 ${e.iconColor}`}),o.jsxs("div",{className:"space-y-1",children:[t.title&&o.jsx("p",{className:"font-medium text-foreground",children:t.title}),o.jsx("p",{className:"text-[16px] leading-relaxed text-foreground/80",children:t.text})]})]})}function X7t({block:t}){return o.jsx("div",{children:t.items.map((e,r)=>{const n=r===t.items.length-1;return o.jsxs("div",{className:"flex gap-5",children:[o.jsxs("div",{className:"flex flex-col items-center",children:[o.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground",children:r+1}),!n&&o.jsx("div",{className:"w-px flex-1 bg-border my-2"})]}),o.jsxs("div",{className:n?"pb-2":"pb-8",children:[o.jsx("p",{className:"text-xl font-medium text-foreground leading-7",children:e.title}),o.jsx("p",{className:"mt-3 text-[17px] leading-[1.7] text-foreground/85",children:e.text})]})]},r)})})}function Q7t({block:t}){switch(t.type){case"heading":{const e=t.level??2;return e===3?o.jsx("h3",{className:"pt-4 text-xl font-medium text-foreground scroll-mt-24",children:t.text}):e===4?o.jsx("h4",{className:"pt-2 text-lg font-medium text-foreground scroll-mt-24",children:t.text}):o.jsx("h2",{className:"pt-8 text-[26px] font-medium tracking-tight text-foreground scroll-mt-24",children:t.text})}case"paragraph":return o.jsx("p",{className:"text-[17px] leading-[1.7] text-foreground/85",children:t.text});case"image":{const e=t.src??t.url;return e?o.jsxs("figure",{className:"space-y-2",children:[o.jsx("img",{src:e,alt:t.alt??"",loading:"lazy",className:"w-full rounded-xl border"}),t.caption&&o.jsx("figcaption",{className:"text-sm text-muted-foreground",children:t.caption})]}):null}case"bullet_list":return o.jsx("ul",{className:"list-disc space-y-2 pl-6 text-[17px] text-foreground/85 marker:text-muted-foreground",children:t.items.map((e,r)=>o.jsx("li",{className:"leading-[1.7] pl-1",children:e},r))});case"step_list":return o.jsx(X7t,{block:t});case"callout":return o.jsx(Y7t,{block:t});default:return null}}function Z7t({blocks:t}){return o.jsx("div",{className:"space-y-5",children:t.map((e,r)=>o.jsx(Q7t,{block:e},r))})}function J7t(){const{category:t,slug:e}=hpe(),{page:r,loading:n,notFound:s}=q7t(t,e),{pages:i,loading:a}=BK();if(!n&&!a&&s&&i.length>0)return o.jsx(p0,{to:`/docs/${i[0].category_slug}/${i[0].slug}`,replace:!0});const l="https://academly.ai",c=r==null?void 0:r.canonical_url,u=c&&c.startsWith(`${l}/`)?c:t&&e?`${l}/docs/${t}/${e}`:`${l}/docs`,d=r?r.seo_title??r.title:"",h=r?d.includes("Academly Docs")?d:`${d} | Academly Docs`:"Academly Docs";return o.jsxs(I2e,{children:[o.jsx(Di,{title:h,description:(r==null?void 0:r.seo_description)??(r==null?void 0:r.description)??"Academly documentation",canonical:u}),n?o.jsxs("div",{className:"space-y-4 animate-pulse",children:[o.jsx("div",{className:"h-4 w-48 rounded bg-muted"}),o.jsx("div",{className:"h-9 w-2/3 rounded bg-muted"}),o.jsx("div",{className:"h-4 w-full rounded bg-muted"}),o.jsx("div",{className:"h-4 w-5/6 rounded bg-muted"}),o.jsx("div",{className:"h-4 w-4/6 rounded bg-muted"})]}):r?o.jsxs("article",{children:[o.jsx("nav",{"aria-label":"Breadcrumb",className:"mb-3 text-sm",children:o.jsx(Nt,{to:"/docs",className:"text-primary hover:underline",children:r.category})}),o.jsx("h1",{className:"text-[34px] md:text-[40px] font-semibold tracking-tight leading-tight text-foreground mb-4",children:r.title}),r.description&&o.jsx("p",{className:"text-lg md:text-xl text-muted-foreground mb-9 leading-relaxed",children:r.description}),o.jsx(Z7t,{blocks:r.content_json})]}):o.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[o.jsx(jr,{className:"h-10 w-10 text-muted-foreground mb-4"}),o.jsx("h1",{className:"text-2xl font-semibold text-foreground mb-2",children:"Documentation coming soon"}),o.jsx("p",{className:"text-muted-foreground max-w-md",children:"We're preparing the Academly documentation. Please check back shortly."})]})]})}const eWt=new Y5e;function tWt(){return o.jsx(e4e,{client:eWt,children:o.jsxs(ri,{children:[o.jsx(gDe,{}),o.jsx(KDe,{}),o.jsx(d3e,{children:o.jsxs(r3e,{children:[o.jsx(Wt,{path:"/",element:o.jsx(nbt,{})}),o.jsx(Wt,{path:"/pricing",element:o.jsx(hbt,{})}),o.jsx(Wt,{path:"/subscription/success",element:o.jsx(pbt,{})}),o.jsx(Wt,{path:"/subscription/cancel",element:o.jsx(mbt,{})}),o.jsx(Wt,{path:"/how-it-works",element:o.jsx(vbt,{})}),o.jsx(Wt,{path:"/topic-ideas",element:o.jsx(Cbt,{})}),o.jsx(Wt,{path:"/literature-search",element:o.jsx(Abt,{})}),o.jsx(Wt,{path:"/team",element:o.jsx(Ibt,{})}),o.jsx(Wt,{path:"/waitlist",element:o.jsx(V0t,{})}),o.jsx(Wt,{path:"/legal",element:o.jsx(Y0t,{})}),o.jsx(Wt,{path:"/login",element:o.jsx(ewt,{})}),o.jsx(Wt,{path:"/reset-password",element:o.jsx(twt,{})}),o.jsx(Wt,{path:"/vs/*",element:o.jsx(p0,{to:"/blog/was-kann-academly",replace:!0})}),o.jsx(Wt,{path:"/blog",element:o.jsx(uwt,{})}),o.jsx(Wt,{path:"/blog/:slug",element:o.jsx(CCt,{})}),o.jsx(Wt,{path:"/docs",element:o.jsx(K7t,{})}),o.jsx(Wt,{path:"/docs/:category/:slug",element:o.jsx(J7t,{})}),o.jsx(Wt,{path:"/dashboard",element:o.jsx(fvt,{})}),o.jsx(Wt,{path:"/documents",element:o.jsx(gTt,{})}),o.jsx(Wt,{path:"/summary",element:o.jsx(vTt,{})}),o.jsx(Wt,{path:"/pdf-extract",element:o.jsx(y7t,{})}),o.jsx(Wt,{path:"/pdf-slicer",element:o.jsx(x7t,{})}),o.jsx(Wt,{path:"/topic-explorer",element:o.jsx(h7t,{})}),o.jsx(Wt,{path:"/topic-explorer/ideas",element:o.jsx(f7t,{})}),o.jsx(Wt,{path:"/topic-explorer/outline",element:o.jsx(p7t,{})}),o.jsx(Wt,{path:"/topic-explorer/keywords",element:o.jsx(m7t,{})}),o.jsx(Wt,{path:"/thesis-builder",element:o.jsx(HTt,{})}),o.jsx(Wt,{path:"/methods-approach",element:o.jsx(VTt,{})}),o.jsx(Wt,{path:"/discussion",element:o.jsx(GTt,{})}),o.jsx(Wt,{path:"/conclusion",element:o.jsx(YTt,{})}),o.jsx(Wt,{path:"/thesis-manager",element:o.jsx(TDt,{})}),o.jsx(Wt,{path:"/my-thesis-2/new",element:o.jsx(d7t,{})}),o.jsx(Wt,{path:"/my-thesis-2",element:o.jsx(RHt,{})}),o.jsxs(Wt,{path:"/qualitative",element:o.jsx(P7t,{}),children:[o.jsx(Wt,{index:!0,element:o.jsx(p0,{to:"/qualitative/research-setup",replace:!0})}),o.jsx(Wt,{path:"research-setup",element:o.jsx(I7t,{})}),o.jsx(Wt,{path:"kodierbogen",element:o.jsx(M7t,{})}),o.jsx(Wt,{path:"kodierbogen-grid",element:o.jsx(L7t,{})}),o.jsx(Wt,{path:"interviews",element:o.jsx($7t,{})}),o.jsx(Wt,{path:"kodieren",element:o.jsx(B7t,{})}),o.jsx(Wt,{path:"auswertung",element:o.jsx(H7t,{})})]}),o.jsx(Wt,{path:"/reference-checker",element:o.jsx(C7t,{})}),o.jsx(Wt,{path:"/supervisor",element:o.jsx(T7t,{})}),o.jsx(Wt,{path:"/citations",element:o.jsx(p0,{to:"/reference-checker",replace:!0})}),o.jsx(Wt,{path:"/history",element:o.jsx(wTt,{})}),o.jsx(Wt,{path:"/account",element:o.jsx(BTt,{})}),o.jsx(Wt,{path:"*",element:o.jsx(W7t,{})})]})})]})})}dhe(document.getElementById("root")).render(o.jsx(yhe,{children:o.jsx(f8e,{children:o.jsx(MFe,{children:o.jsx(tWt,{})})})}));