opencrm/frontend/dist/assets/index-BLUL0czD.js

978 lines
1.1 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var Mv=t=>{throw TypeError(t)};var em=(t,e,n)=>e.has(t)||Mv("Cannot "+n);var P=(t,e,n)=>(em(t,e,"read from private field"),n?n.call(t):e.get(t)),ge=(t,e,n)=>e.has(t)?Mv("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),re=(t,e,n,s)=>(em(t,e,"write to private field"),s?s.call(t,n):e.set(t,n),n),Ce=(t,e,n)=>(em(t,e,"access private method"),n);var Dd=(t,e,n,s)=>({set _(r){re(t,e,r,n)},get _(){return P(t,e,s)}});function T4(t,e){for(var n=0;n<e.length;n++){const s=e[n];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in t)){const a=Object.getOwnPropertyDescriptor(s,r);a&&Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>s[r]})}}}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 r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}})();function UN(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qN={exports:{}},af={},HN={exports:{}},Le={};/**
* @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 cd=Symbol.for("react.element"),P4=Symbol.for("react.portal"),I4=Symbol.for("react.fragment"),R4=Symbol.for("react.strict_mode"),O4=Symbol.for("react.profiler"),L4=Symbol.for("react.provider"),F4=Symbol.for("react.context"),z4=Symbol.for("react.forward_ref"),$4=Symbol.for("react.suspense"),B4=Symbol.for("react.memo"),_4=Symbol.for("react.lazy"),Tv=Symbol.iterator;function V4(t){return t===null||typeof t!="object"?null:(t=Tv&&t[Tv]||t["@@iterator"],typeof t=="function"?t:null)}var WN={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},QN=Object.assign,GN={};function uo(t,e,n){this.props=t,this.context=e,this.refs=GN,this.updater=n||WN}uo.prototype.isReactComponent={};uo.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")};uo.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function JN(){}JN.prototype=uo.prototype;function kx(t,e,n){this.props=t,this.context=e,this.refs=GN,this.updater=n||WN}var Sx=kx.prototype=new JN;Sx.constructor=kx;QN(Sx,uo.prototype);Sx.isPureReactComponent=!0;var Pv=Array.isArray,ZN=Object.prototype.hasOwnProperty,Cx={current:null},YN={key:!0,ref:!0,__self:!0,__source:!0};function XN(t,e,n){var s,r={},a=null,l=null;if(e!=null)for(s in e.ref!==void 0&&(l=e.ref),e.key!==void 0&&(a=""+e.key),e)ZN.call(e,s)&&!YN.hasOwnProperty(s)&&(r[s]=e[s]);var o=arguments.length-2;if(o===1)r.children=n;else if(1<o){for(var c=Array(o),d=0;d<o;d++)c[d]=arguments[d+2];r.children=c}if(t&&t.defaultProps)for(s in o=t.defaultProps,o)r[s]===void 0&&(r[s]=o[s]);return{$$typeof:cd,type:t,key:a,ref:l,props:r,_owner:Cx.current}}function K4(t,e){return{$$typeof:cd,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function Ex(t){return typeof t=="object"&&t!==null&&t.$$typeof===cd}function U4(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var Iv=/\/+/g;function tm(t,e){return typeof t=="object"&&t!==null&&t.key!=null?U4(""+t.key):e.toString(36)}function du(t,e,n,s,r){var a=typeof t;(a==="undefined"||a==="boolean")&&(t=null);var l=!1;if(t===null)l=!0;else switch(a){case"string":case"number":l=!0;break;case"object":switch(t.$$typeof){case cd:case P4:l=!0}}if(l)return l=t,r=r(l),t=s===""?"."+tm(l,0):s,Pv(r)?(n="",t!=null&&(n=t.replace(Iv,"$&/")+"/"),du(r,e,n,"",function(d){return d})):r!=null&&(Ex(r)&&(r=K4(r,n+(!r.key||l&&l.key===r.key?"":(""+r.key).replace(Iv,"$&/")+"/")+t)),e.push(r)),1;if(l=0,s=s===""?".":s+":",Pv(t))for(var o=0;o<t.length;o++){a=t[o];var c=s+tm(a,o);l+=du(a,e,n,c,r)}else if(c=V4(t),typeof c=="function")for(t=c.call(t),o=0;!(a=t.next()).done;)a=a.value,c=s+tm(a,o++),l+=du(a,e,n,c,r);else if(a==="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 l}function Md(t,e,n){if(t==null)return t;var s=[],r=0;return du(t,s,"","",function(a){return e.call(n,a,r++)}),s}function q4(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var In={current:null},uu={transition:null},H4={ReactCurrentDispatcher:In,ReactCurrentBatchConfig:uu,ReactCurrentOwner:Cx};function ew(){throw Error("act(...) is not supported in production builds of React.")}Le.Children={map:Md,forEach:function(t,e,n){Md(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return Md(t,function(){e++}),e},toArray:function(t){return Md(t,function(e){return e})||[]},only:function(t){if(!Ex(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};Le.Component=uo;Le.Fragment=I4;Le.Profiler=O4;Le.PureComponent=kx;Le.StrictMode=R4;Le.Suspense=$4;Le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H4;Le.act=ew;Le.cloneElement=function(t,e,n){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var s=QN({},t.props),r=t.key,a=t.ref,l=t._owner;if(e!=null){if(e.ref!==void 0&&(a=e.ref,l=Cx.current),e.key!==void 0&&(r=""+e.key),t.type&&t.type.defaultProps)var o=t.type.defaultProps;for(c in e)ZN.call(e,c)&&!YN.hasOwnProperty(c)&&(s[c]=e[c]===void 0&&o!==void 0?o[c]:e[c])}var c=arguments.length-2;if(c===1)s.children=n;else if(1<c){o=Array(c);for(var d=0;d<c;d++)o[d]=arguments[d+2];s.children=o}return{$$typeof:cd,type:t.type,key:r,ref:a,props:s,_owner:l}};Le.createContext=function(t){return t={$$typeof:F4,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:L4,_context:t},t.Consumer=t};Le.createElement=XN;Le.createFactory=function(t){var e=XN.bind(null,t);return e.type=t,e};Le.createRef=function(){return{current:null}};Le.forwardRef=function(t){return{$$typeof:z4,render:t}};Le.isValidElement=Ex;Le.lazy=function(t){return{$$typeof:_4,_payload:{_status:-1,_result:t},_init:q4}};Le.memo=function(t,e){return{$$typeof:B4,type:t,compare:e===void 0?null:e}};Le.startTransition=function(t){var e=uu.transition;uu.transition={};try{t()}finally{uu.transition=e}};Le.unstable_act=ew;Le.useCallback=function(t,e){return In.current.useCallback(t,e)};Le.useContext=function(t){return In.current.useContext(t)};Le.useDebugValue=function(){};Le.useDeferredValue=function(t){return In.current.useDeferredValue(t)};Le.useEffect=function(t,e){return In.current.useEffect(t,e)};Le.useId=function(){return In.current.useId()};Le.useImperativeHandle=function(t,e,n){return In.current.useImperativeHandle(t,e,n)};Le.useInsertionEffect=function(t,e){return In.current.useInsertionEffect(t,e)};Le.useLayoutEffect=function(t,e){return In.current.useLayoutEffect(t,e)};Le.useMemo=function(t,e){return In.current.useMemo(t,e)};Le.useReducer=function(t,e,n){return In.current.useReducer(t,e,n)};Le.useRef=function(t){return In.current.useRef(t)};Le.useState=function(t){return In.current.useState(t)};Le.useSyncExternalStore=function(t,e,n){return In.current.useSyncExternalStore(t,e,n)};Le.useTransition=function(){return In.current.useTransition()};Le.version="18.3.1";HN.exports=Le;var N=HN.exports;const ut=UN(N),W4=T4({__proto__:null,default:ut},[N]);/**
* @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 Q4=N,G4=Symbol.for("react.element"),J4=Symbol.for("react.fragment"),Z4=Object.prototype.hasOwnProperty,Y4=Q4.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,X4={key:!0,ref:!0,__self:!0,__source:!0};function tw(t,e,n){var s,r={},a=null,l=null;n!==void 0&&(a=""+n),e.key!==void 0&&(a=""+e.key),e.ref!==void 0&&(l=e.ref);for(s in e)Z4.call(e,s)&&!X4.hasOwnProperty(s)&&(r[s]=e[s]);if(t&&t.defaultProps)for(s in e=t.defaultProps,e)r[s]===void 0&&(r[s]=e[s]);return{$$typeof:G4,type:t,key:a,ref:l,props:r,_owner:Y4.current}}af.Fragment=J4;af.jsx=tw;af.jsxs=tw;qN.exports=af;var i=qN.exports,pp={},nw={exports:{}},ds={},sw={exports:{}},rw={};/**
* @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(K,B){var W=K.length;K.push(B);e:for(;0<W;){var ce=W-1>>>1,he=K[ce];if(0<r(he,B))K[ce]=B,K[W]=he,W=ce;else break e}}function n(K){return K.length===0?null:K[0]}function s(K){if(K.length===0)return null;var B=K[0],W=K.pop();if(W!==B){K[0]=W;e:for(var ce=0,he=K.length,Je=he>>>1;ce<Je;){var et=2*(ce+1)-1,mt=K[et],A=et+1,pt=K[A];if(0>r(mt,W))A<he&&0>r(pt,mt)?(K[ce]=pt,K[A]=W,ce=A):(K[ce]=mt,K[et]=W,ce=et);else if(A<he&&0>r(pt,W))K[ce]=pt,K[A]=W,ce=A;else break e}}return B}function r(K,B){var W=K.sortIndex-B.sortIndex;return W!==0?W:K.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();t.unstable_now=function(){return l.now()-o}}var c=[],d=[],u=1,h=null,m=3,f=!1,p=!1,g=!1,x=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(K){for(var B=n(d);B!==null;){if(B.callback===null)s(d);else if(B.startTime<=K)s(d),B.sortIndex=B.expirationTime,e(c,B);else break;B=n(d)}}function j(K){if(g=!1,b(K),!p)if(n(c)!==null)p=!0,C(k);else{var B=n(d);B!==null&&_(j,B.startTime-K)}}function k(K,B){p=!1,g&&(g=!1,y(w),w=-1),f=!0;var W=m;try{for(b(B),h=n(c);h!==null&&(!(h.expirationTime>B)||K&&!F());){var ce=h.callback;if(typeof ce=="function"){h.callback=null,m=h.priorityLevel;var he=ce(h.expirationTime<=B);B=t.unstable_now(),typeof he=="function"?h.callback=he:h===n(c)&&s(c),b(B)}else s(c);h=n(c)}if(h!==null)var Je=!0;else{var et=n(d);et!==null&&_(j,et.startTime-B),Je=!1}return Je}finally{h=null,m=W,f=!1}}var E=!1,T=null,w=-1,S=5,M=-1;function F(){return!(t.unstable_now()-M<S)}function R(){if(T!==null){var K=t.unstable_now();M=K;var B=!0;try{B=T(!0,K)}finally{B?V():(E=!1,T=null)}}else E=!1}var V;if(typeof v=="function")V=function(){v(R)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,z=D.port2;D.port1.onmessage=R,V=function(){z.postMessage(null)}}else V=function(){x(R,0)};function C(K){T=K,E||(E=!0,V())}function _(K,B){w=x(function(){K(t.unstable_now())},B)}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(K){K.callback=null},t.unstable_continueExecution=function(){p||f||(p=!0,C(k))},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):S=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return m},t.unstable_getFirstCallbackNode=function(){return n(c)},t.unstable_next=function(K){switch(m){case 1:case 2:case 3:var B=3;break;default:B=m}var W=m;m=B;try{return K()}finally{m=W}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(K,B){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var W=m;m=K;try{return B()}finally{m=W}},t.unstable_scheduleCallback=function(K,B,W){var ce=t.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?ce+W:ce):W=ce,K){case 1:var he=-1;break;case 2:he=250;break;case 5:he=1073741823;break;case 4:he=1e4;break;default:he=5e3}return he=W+he,K={id:u++,callback:B,priorityLevel:K,startTime:W,expirationTime:he,sortIndex:-1},W>ce?(K.sortIndex=W,e(d,K),n(c)===null&&K===n(d)&&(g?(y(w),w=-1):g=!0,_(j,W-ce))):(K.sortIndex=he,e(c,K),p||f||(p=!0,C(k))),K},t.unstable_shouldYield=F,t.unstable_wrapCallback=function(K){var B=m;return function(){var W=m;m=B;try{return K.apply(this,arguments)}finally{m=W}}}})(rw);sw.exports=rw;var eA=sw.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 tA=N,ls=eA;function ne(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);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 iw=new Set,gc={};function Ha(t,e){Hl(t,e),Hl(t+"Capture",e)}function Hl(t,e){for(gc[t]=e,t=0;t<e.length;t++)iw.add(e[t])}var Fr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),gp=Object.prototype.hasOwnProperty,nA=/^[: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]*$/,Rv={},Ov={};function sA(t){return gp.call(Ov,t)?!0:gp.call(Rv,t)?!1:nA.test(t)?Ov[t]=!0:(Rv[t]=!0,!1)}function rA(t,e,n,s){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return s?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function iA(t,e,n,s){if(e===null||typeof e>"u"||rA(t,e,n,s))return!0;if(s)return!1;if(n!==null)switch(n.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 Rn(t,e,n,s,r,a,l){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=s,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=a,this.removeEmptyString=l}var un={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){un[t]=new Rn(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];un[e]=new Rn(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){un[t]=new Rn(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){un[t]=new Rn(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){un[t]=new Rn(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){un[t]=new Rn(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){un[t]=new Rn(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){un[t]=new Rn(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){un[t]=new Rn(t,5,!1,t.toLowerCase(),null,!1,!1)});var Ax=/[\-:]([a-z])/g;function Dx(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(Ax,Dx);un[e]=new Rn(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(Ax,Dx);un[e]=new Rn(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(Ax,Dx);un[e]=new Rn(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){un[t]=new Rn(t,1,!1,t.toLowerCase(),null,!1,!1)});un.xlinkHref=new Rn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){un[t]=new Rn(t,1,!1,t.toLowerCase(),null,!0,!0)});function Mx(t,e,n,s){var r=un.hasOwnProperty(e)?un[e]:null;(r!==null?r.type!==0:s||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(iA(e,n,r,s)&&(n=null),s||r===null?sA(e)&&(n===null?t.removeAttribute(e):t.setAttribute(e,""+n)):r.mustUseProperty?t[r.propertyName]=n===null?r.type===3?!1:"":n:(e=r.attributeName,s=r.attributeNamespace,n===null?t.removeAttribute(e):(r=r.type,n=r===3||r===4&&n===!0?"":""+n,s?t.setAttributeNS(s,e,n):t.setAttribute(e,n))))}var Kr=tA.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Td=Symbol.for("react.element"),ol=Symbol.for("react.portal"),cl=Symbol.for("react.fragment"),Tx=Symbol.for("react.strict_mode"),xp=Symbol.for("react.profiler"),aw=Symbol.for("react.provider"),lw=Symbol.for("react.context"),Px=Symbol.for("react.forward_ref"),yp=Symbol.for("react.suspense"),vp=Symbol.for("react.suspense_list"),Ix=Symbol.for("react.memo"),Yr=Symbol.for("react.lazy"),ow=Symbol.for("react.offscreen"),Lv=Symbol.iterator;function ko(t){return t===null||typeof t!="object"?null:(t=Lv&&t[Lv]||t["@@iterator"],typeof t=="function"?t:null)}var jt=Object.assign,nm;function Fo(t){if(nm===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);nm=e&&e[1]||""}return`
`+nm+t}var sm=!1;function rm(t,e){if(!t||sm)return"";sm=!0;var n=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(d){var s=d}Reflect.construct(t,[],e)}else{try{e.call()}catch(d){s=d}t.call(e.prototype)}else{try{throw Error()}catch(d){s=d}t()}}catch(d){if(d&&s&&typeof d.stack=="string"){for(var r=d.stack.split(`
`),a=s.stack.split(`
`),l=r.length-1,o=a.length-1;1<=l&&0<=o&&r[l]!==a[o];)o--;for(;1<=l&&0<=o;l--,o--)if(r[l]!==a[o]){if(l!==1||o!==1)do if(l--,o--,0>o||r[l]!==a[o]){var c=`
`+r[l].replace(" at new "," at ");return t.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",t.displayName)),c}while(1<=l&&0<=o);break}}}finally{sm=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Fo(t):""}function aA(t){switch(t.tag){case 5:return Fo(t.type);case 16:return Fo("Lazy");case 13:return Fo("Suspense");case 19:return Fo("SuspenseList");case 0:case 2:case 15:return t=rm(t.type,!1),t;case 11:return t=rm(t.type.render,!1),t;case 1:return t=rm(t.type,!0),t;default:return""}}function bp(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 cl:return"Fragment";case ol:return"Portal";case xp:return"Profiler";case Tx:return"StrictMode";case yp:return"Suspense";case vp:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case lw:return(t.displayName||"Context")+".Consumer";case aw:return(t._context.displayName||"Context")+".Provider";case Px:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Ix:return e=t.displayName||null,e!==null?e:bp(t.type)||"Memo";case Yr:e=t._payload,t=t._init;try{return bp(t(e))}catch{}}return null}function lA(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 bp(e);case 8:return e===Tx?"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 Bi(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function cw(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function oA(t){var e=cw(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),s=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,a=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return r.call(this)},set:function(l){s=""+l,a.call(this,l)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return s},setValue:function(l){s=""+l},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Pd(t){t._valueTracker||(t._valueTracker=oA(t))}function dw(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),s="";return t&&(s=cw(t)?t.checked?"true":"false":t.value),t=s,t!==n?(e.setValue(t),!0):!1}function Iu(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 jp(t,e){var n=e.checked;return jt({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Fv(t,e){var n=e.defaultValue==null?"":e.defaultValue,s=e.checked!=null?e.checked:e.defaultChecked;n=Bi(e.value!=null?e.value:n),t._wrapperState={initialChecked:s,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function uw(t,e){e=e.checked,e!=null&&Mx(t,"checked",e,!1)}function Np(t,e){uw(t,e);var n=Bi(e.value),s=e.type;if(n!=null)s==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(s==="submit"||s==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?wp(t,e.type,n):e.hasOwnProperty("defaultValue")&&wp(t,e.type,Bi(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function zv(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var s=e.type;if(!(s!=="submit"&&s!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function wp(t,e,n){(e!=="number"||Iu(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var zo=Array.isArray;function Nl(t,e,n,s){if(t=t.options,e){e={};for(var r=0;r<n.length;r++)e["$"+n[r]]=!0;for(n=0;n<t.length;n++)r=e.hasOwnProperty("$"+t[n].value),t[n].selected!==r&&(t[n].selected=r),r&&s&&(t[n].defaultSelected=!0)}else{for(n=""+Bi(n),e=null,r=0;r<t.length;r++){if(t[r].value===n){t[r].selected=!0,s&&(t[r].defaultSelected=!0);return}e!==null||t[r].disabled||(e=t[r])}e!==null&&(e.selected=!0)}}function kp(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(ne(91));return jt({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function $v(t,e){var n=e.value;if(n==null){if(n=e.children,e=e.defaultValue,n!=null){if(e!=null)throw Error(ne(92));if(zo(n)){if(1<n.length)throw Error(ne(93));n=n[0]}e=n}e==null&&(e=""),n=e}t._wrapperState={initialValue:Bi(n)}}function hw(t,e){var n=Bi(e.value),s=Bi(e.defaultValue);n!=null&&(n=""+n,n!==t.value&&(t.value=n),e.defaultValue==null&&t.defaultValue!==n&&(t.defaultValue=n)),s!=null&&(t.defaultValue=""+s)}function Bv(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function fw(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 Sp(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?fw(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Id,mw=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,s,r){MSApp.execUnsafeLocalFunction(function(){return t(e,n,s,r)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Id=Id||document.createElement("div"),Id.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Id.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function xc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Qo={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},cA=["Webkit","ms","Moz","O"];Object.keys(Qo).forEach(function(t){cA.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Qo[e]=Qo[t]})});function pw(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Qo.hasOwnProperty(t)&&Qo[t]?(""+e).trim():e+"px"}function gw(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var s=n.indexOf("--")===0,r=pw(n,e[n],s);n==="float"&&(n="cssFloat"),s?t.setProperty(n,r):t[n]=r}}var dA=jt({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 Cp(t,e){if(e){if(dA[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(ne(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(ne(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(ne(61))}if(e.style!=null&&typeof e.style!="object")throw Error(ne(62))}}function Ep(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 Ap=null;function Rx(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Dp=null,wl=null,kl=null;function _v(t){if(t=hd(t)){if(typeof Dp!="function")throw Error(ne(280));var e=t.stateNode;e&&(e=uf(e),Dp(t.stateNode,t.type,e))}}function xw(t){wl?kl?kl.push(t):kl=[t]:wl=t}function yw(){if(wl){var t=wl,e=kl;if(kl=wl=null,_v(t),e)for(t=0;t<e.length;t++)_v(e[t])}}function vw(t,e){return t(e)}function bw(){}var im=!1;function jw(t,e,n){if(im)return t(e,n);im=!0;try{return vw(t,e,n)}finally{im=!1,(wl!==null||kl!==null)&&(bw(),yw())}}function yc(t,e){var n=t.stateNode;if(n===null)return null;var s=uf(n);if(s===null)return null;n=s[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":(s=!s.disabled)||(t=t.type,s=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!s;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(ne(231,e,typeof n));return n}var Mp=!1;if(Fr)try{var So={};Object.defineProperty(So,"passive",{get:function(){Mp=!0}}),window.addEventListener("test",So,So),window.removeEventListener("test",So,So)}catch{Mp=!1}function uA(t,e,n,s,r,a,l,o,c){var d=Array.prototype.slice.call(arguments,3);try{e.apply(n,d)}catch(u){this.onError(u)}}var Go=!1,Ru=null,Ou=!1,Tp=null,hA={onError:function(t){Go=!0,Ru=t}};function fA(t,e,n,s,r,a,l,o,c){Go=!1,Ru=null,uA.apply(hA,arguments)}function mA(t,e,n,s,r,a,l,o,c){if(fA.apply(this,arguments),Go){if(Go){var d=Ru;Go=!1,Ru=null}else throw Error(ne(198));Ou||(Ou=!0,Tp=d)}}function Wa(t){var e=t,n=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(n=e.return),t=e.return;while(t)}return e.tag===3?n:null}function Nw(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 Vv(t){if(Wa(t)!==t)throw Error(ne(188))}function pA(t){var e=t.alternate;if(!e){if(e=Wa(t),e===null)throw Error(ne(188));return e!==t?null:t}for(var n=t,s=e;;){var r=n.return;if(r===null)break;var a=r.alternate;if(a===null){if(s=r.return,s!==null){n=s;continue}break}if(r.child===a.child){for(a=r.child;a;){if(a===n)return Vv(r),t;if(a===s)return Vv(r),e;a=a.sibling}throw Error(ne(188))}if(n.return!==s.return)n=r,s=a;else{for(var l=!1,o=r.child;o;){if(o===n){l=!0,n=r,s=a;break}if(o===s){l=!0,s=r,n=a;break}o=o.sibling}if(!l){for(o=a.child;o;){if(o===n){l=!0,n=a,s=r;break}if(o===s){l=!0,s=a,n=r;break}o=o.sibling}if(!l)throw Error(ne(189))}}if(n.alternate!==s)throw Error(ne(190))}if(n.tag!==3)throw Error(ne(188));return n.stateNode.current===n?t:e}function ww(t){return t=pA(t),t!==null?kw(t):null}function kw(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=kw(t);if(e!==null)return e;t=t.sibling}return null}var Sw=ls.unstable_scheduleCallback,Kv=ls.unstable_cancelCallback,gA=ls.unstable_shouldYield,xA=ls.unstable_requestPaint,Pt=ls.unstable_now,yA=ls.unstable_getCurrentPriorityLevel,Ox=ls.unstable_ImmediatePriority,Cw=ls.unstable_UserBlockingPriority,Lu=ls.unstable_NormalPriority,vA=ls.unstable_LowPriority,Ew=ls.unstable_IdlePriority,lf=null,rr=null;function bA(t){if(rr&&typeof rr.onCommitFiberRoot=="function")try{rr.onCommitFiberRoot(lf,t,void 0,(t.current.flags&128)===128)}catch{}}var $s=Math.clz32?Math.clz32:wA,jA=Math.log,NA=Math.LN2;function wA(t){return t>>>=0,t===0?32:31-(jA(t)/NA|0)|0}var Rd=64,Od=4194304;function $o(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 Fu(t,e){var n=t.pendingLanes;if(n===0)return 0;var s=0,r=t.suspendedLanes,a=t.pingedLanes,l=n&268435455;if(l!==0){var o=l&~r;o!==0?s=$o(o):(a&=l,a!==0&&(s=$o(a)))}else l=n&~r,l!==0?s=$o(l):a!==0&&(s=$o(a));if(s===0)return 0;if(e!==0&&e!==s&&!(e&r)&&(r=s&-s,a=e&-e,r>=a||r===16&&(a&4194240)!==0))return e;if(s&4&&(s|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=s;0<e;)n=31-$s(e),r=1<<n,s|=t[n],e&=~r;return s}function kA(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 SA(t,e){for(var n=t.suspendedLanes,s=t.pingedLanes,r=t.expirationTimes,a=t.pendingLanes;0<a;){var l=31-$s(a),o=1<<l,c=r[l];c===-1?(!(o&n)||o&s)&&(r[l]=kA(o,e)):c<=e&&(t.expiredLanes|=o),a&=~o}}function Pp(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function Aw(){var t=Rd;return Rd<<=1,!(Rd&4194240)&&(Rd=64),t}function am(t){for(var e=[],n=0;31>n;n++)e.push(t);return e}function dd(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-$s(e),t[e]=n}function CA(t,e){var n=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 s=t.eventTimes;for(t=t.expirationTimes;0<n;){var r=31-$s(n),a=1<<r;e[r]=0,s[r]=-1,t[r]=-1,n&=~a}}function Lx(t,e){var n=t.entangledLanes|=e;for(t=t.entanglements;n;){var s=31-$s(n),r=1<<s;r&e|t[s]&e&&(t[s]|=e),n&=~r}}var Ye=0;function Dw(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var Mw,Fx,Tw,Pw,Iw,Ip=!1,Ld=[],Ci=null,Ei=null,Ai=null,vc=new Map,bc=new Map,si=[],EA="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 Uv(t,e){switch(t){case"focusin":case"focusout":Ci=null;break;case"dragenter":case"dragleave":Ei=null;break;case"mouseover":case"mouseout":Ai=null;break;case"pointerover":case"pointerout":vc.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":bc.delete(e.pointerId)}}function Co(t,e,n,s,r,a){return t===null||t.nativeEvent!==a?(t={blockedOn:e,domEventName:n,eventSystemFlags:s,nativeEvent:a,targetContainers:[r]},e!==null&&(e=hd(e),e!==null&&Fx(e)),t):(t.eventSystemFlags|=s,e=t.targetContainers,r!==null&&e.indexOf(r)===-1&&e.push(r),t)}function AA(t,e,n,s,r){switch(e){case"focusin":return Ci=Co(Ci,t,e,n,s,r),!0;case"dragenter":return Ei=Co(Ei,t,e,n,s,r),!0;case"mouseover":return Ai=Co(Ai,t,e,n,s,r),!0;case"pointerover":var a=r.pointerId;return vc.set(a,Co(vc.get(a)||null,t,e,n,s,r)),!0;case"gotpointercapture":return a=r.pointerId,bc.set(a,Co(bc.get(a)||null,t,e,n,s,r)),!0}return!1}function Rw(t){var e=na(t.target);if(e!==null){var n=Wa(e);if(n!==null){if(e=n.tag,e===13){if(e=Nw(n),e!==null){t.blockedOn=e,Iw(t.priority,function(){Tw(n)});return}}else if(e===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function hu(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var n=Rp(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(n===null){n=t.nativeEvent;var s=new n.constructor(n.type,n);Ap=s,n.target.dispatchEvent(s),Ap=null}else return e=hd(n),e!==null&&Fx(e),t.blockedOn=n,!1;e.shift()}return!0}function qv(t,e,n){hu(t)&&n.delete(e)}function DA(){Ip=!1,Ci!==null&&hu(Ci)&&(Ci=null),Ei!==null&&hu(Ei)&&(Ei=null),Ai!==null&&hu(Ai)&&(Ai=null),vc.forEach(qv),bc.forEach(qv)}function Eo(t,e){t.blockedOn===e&&(t.blockedOn=null,Ip||(Ip=!0,ls.unstable_scheduleCallback(ls.unstable_NormalPriority,DA)))}function jc(t){function e(r){return Eo(r,t)}if(0<Ld.length){Eo(Ld[0],t);for(var n=1;n<Ld.length;n++){var s=Ld[n];s.blockedOn===t&&(s.blockedOn=null)}}for(Ci!==null&&Eo(Ci,t),Ei!==null&&Eo(Ei,t),Ai!==null&&Eo(Ai,t),vc.forEach(e),bc.forEach(e),n=0;n<si.length;n++)s=si[n],s.blockedOn===t&&(s.blockedOn=null);for(;0<si.length&&(n=si[0],n.blockedOn===null);)Rw(n),n.blockedOn===null&&si.shift()}var Sl=Kr.ReactCurrentBatchConfig,zu=!0;function MA(t,e,n,s){var r=Ye,a=Sl.transition;Sl.transition=null;try{Ye=1,zx(t,e,n,s)}finally{Ye=r,Sl.transition=a}}function TA(t,e,n,s){var r=Ye,a=Sl.transition;Sl.transition=null;try{Ye=4,zx(t,e,n,s)}finally{Ye=r,Sl.transition=a}}function zx(t,e,n,s){if(zu){var r=Rp(t,e,n,s);if(r===null)gm(t,e,s,$u,n),Uv(t,s);else if(AA(r,t,e,n,s))s.stopPropagation();else if(Uv(t,s),e&4&&-1<EA.indexOf(t)){for(;r!==null;){var a=hd(r);if(a!==null&&Mw(a),a=Rp(t,e,n,s),a===null&&gm(t,e,s,$u,n),a===r)break;r=a}r!==null&&s.stopPropagation()}else gm(t,e,s,null,n)}}var $u=null;function Rp(t,e,n,s){if($u=null,t=Rx(s),t=na(t),t!==null)if(e=Wa(t),e===null)t=null;else if(n=e.tag,n===13){if(t=Nw(e),t!==null)return t;t=null}else if(n===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return $u=t,null}function Ow(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(yA()){case Ox:return 1;case Cw:return 4;case Lu:case vA:return 16;case Ew:return 536870912;default:return 16}default:return 16}}var bi=null,$x=null,fu=null;function Lw(){if(fu)return fu;var t,e=$x,n=e.length,s,r="value"in bi?bi.value:bi.textContent,a=r.length;for(t=0;t<n&&e[t]===r[t];t++);var l=n-t;for(s=1;s<=l&&e[n-s]===r[a-s];s++);return fu=r.slice(t,1<s?1-s:void 0)}function mu(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 Fd(){return!0}function Hv(){return!1}function us(t){function e(n,s,r,a,l){this._reactName=n,this._targetInst=r,this.type=s,this.nativeEvent=a,this.target=l,this.currentTarget=null;for(var o in t)t.hasOwnProperty(o)&&(n=t[o],this[o]=n?n(a):a[o]);return this.isDefaultPrevented=(a.defaultPrevented!=null?a.defaultPrevented:a.returnValue===!1)?Fd:Hv,this.isPropagationStopped=Hv,this}return jt(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Fd)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Fd)},persist:function(){},isPersistent:Fd}),e}var ho={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Bx=us(ho),ud=jt({},ho,{view:0,detail:0}),PA=us(ud),lm,om,Ao,of=jt({},ud,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_x,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!==Ao&&(Ao&&t.type==="mousemove"?(lm=t.screenX-Ao.screenX,om=t.screenY-Ao.screenY):om=lm=0,Ao=t),lm)},movementY:function(t){return"movementY"in t?t.movementY:om}}),Wv=us(of),IA=jt({},of,{dataTransfer:0}),RA=us(IA),OA=jt({},ud,{relatedTarget:0}),cm=us(OA),LA=jt({},ho,{animationName:0,elapsedTime:0,pseudoElement:0}),FA=us(LA),zA=jt({},ho,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),$A=us(zA),BA=jt({},ho,{data:0}),Qv=us(BA),_A={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},VA={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"},KA={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function UA(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=KA[t])?!!e[t]:!1}function _x(){return UA}var qA=jt({},ud,{key:function(t){if(t.key){var e=_A[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=mu(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?VA[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_x,charCode:function(t){return t.type==="keypress"?mu(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?mu(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),HA=us(qA),WA=jt({},of,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gv=us(WA),QA=jt({},ud,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_x}),GA=us(QA),JA=jt({},ho,{propertyName:0,elapsedTime:0,pseudoElement:0}),ZA=us(JA),YA=jt({},of,{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}),XA=us(YA),eD=[9,13,27,32],Vx=Fr&&"CompositionEvent"in window,Jo=null;Fr&&"documentMode"in document&&(Jo=document.documentMode);var tD=Fr&&"TextEvent"in window&&!Jo,Fw=Fr&&(!Vx||Jo&&8<Jo&&11>=Jo),Jv=" ",Zv=!1;function zw(t,e){switch(t){case"keyup":return eD.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $w(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var dl=!1;function nD(t,e){switch(t){case"compositionend":return $w(e);case"keypress":return e.which!==32?null:(Zv=!0,Jv);case"textInput":return t=e.data,t===Jv&&Zv?null:t;default:return null}}function sD(t,e){if(dl)return t==="compositionend"||!Vx&&zw(t,e)?(t=Lw(),fu=$x=bi=null,dl=!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 Fw&&e.locale!=="ko"?null:e.data;default:return null}}var rD={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 Yv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!rD[t.type]:e==="textarea"}function Bw(t,e,n,s){xw(s),e=Bu(e,"onChange"),0<e.length&&(n=new Bx("onChange","change",null,n,s),t.push({event:n,listeners:e}))}var Zo=null,Nc=null;function iD(t){Zw(t,0)}function cf(t){var e=fl(t);if(dw(e))return t}function aD(t,e){if(t==="change")return e}var _w=!1;if(Fr){var dm;if(Fr){var um="oninput"in document;if(!um){var Xv=document.createElement("div");Xv.setAttribute("oninput","return;"),um=typeof Xv.oninput=="function"}dm=um}else dm=!1;_w=dm&&(!document.documentMode||9<document.documentMode)}function eb(){Zo&&(Zo.detachEvent("onpropertychange",Vw),Nc=Zo=null)}function Vw(t){if(t.propertyName==="value"&&cf(Nc)){var e=[];Bw(e,Nc,t,Rx(t)),jw(iD,e)}}function lD(t,e,n){t==="focusin"?(eb(),Zo=e,Nc=n,Zo.attachEvent("onpropertychange",Vw)):t==="focusout"&&eb()}function oD(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return cf(Nc)}function cD(t,e){if(t==="click")return cf(e)}function dD(t,e){if(t==="input"||t==="change")return cf(e)}function uD(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var Vs=typeof Object.is=="function"?Object.is:uD;function wc(t,e){if(Vs(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;for(s=0;s<n.length;s++){var r=n[s];if(!gp.call(e,r)||!Vs(t[r],e[r]))return!1}return!0}function tb(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function nb(t,e){var n=tb(t);t=0;for(var s;n;){if(n.nodeType===3){if(s=t+n.textContent.length,t<=e&&s>=e)return{node:n,offset:e-t};t=s}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=tb(n)}}function Kw(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Kw(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Uw(){for(var t=window,e=Iu();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Iu(t.document)}return e}function Kx(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 hD(t){var e=Uw(),n=t.focusedElem,s=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&Kw(n.ownerDocument.documentElement,n)){if(s!==null&&Kx(n)){if(e=s.start,t=s.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var r=n.textContent.length,a=Math.min(s.start,r);s=s.end===void 0?a:Math.min(s.end,r),!t.extend&&a>s&&(r=s,s=a,a=r),r=nb(n,a);var l=nb(n,s);r&&l&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==l.node||t.focusOffset!==l.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),t.removeAllRanges(),a>s?(t.addRange(e),t.extend(l.node,l.offset)):(e.setEnd(l.node,l.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<e.length;n++)t=e[n],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var fD=Fr&&"documentMode"in document&&11>=document.documentMode,ul=null,Op=null,Yo=null,Lp=!1;function sb(t,e,n){var s=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Lp||ul==null||ul!==Iu(s)||(s=ul,"selectionStart"in s&&Kx(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),Yo&&wc(Yo,s)||(Yo=s,s=Bu(Op,"onSelect"),0<s.length&&(e=new Bx("onSelect","select",null,e,n),t.push({event:e,listeners:s}),e.target=ul)))}function zd(t,e){var n={};return n[t.toLowerCase()]=e.toLowerCase(),n["Webkit"+t]="webkit"+e,n["Moz"+t]="moz"+e,n}var hl={animationend:zd("Animation","AnimationEnd"),animationiteration:zd("Animation","AnimationIteration"),animationstart:zd("Animation","AnimationStart"),transitionend:zd("Transition","TransitionEnd")},hm={},qw={};Fr&&(qw=document.createElement("div").style,"AnimationEvent"in window||(delete hl.animationend.animation,delete hl.animationiteration.animation,delete hl.animationstart.animation),"TransitionEvent"in window||delete hl.transitionend.transition);function df(t){if(hm[t])return hm[t];if(!hl[t])return t;var e=hl[t],n;for(n in e)if(e.hasOwnProperty(n)&&n in qw)return hm[t]=e[n];return t}var Hw=df("animationend"),Ww=df("animationiteration"),Qw=df("animationstart"),Gw=df("transitionend"),Jw=new Map,rb="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 Ui(t,e){Jw.set(t,e),Ha(e,[t])}for(var fm=0;fm<rb.length;fm++){var mm=rb[fm],mD=mm.toLowerCase(),pD=mm[0].toUpperCase()+mm.slice(1);Ui(mD,"on"+pD)}Ui(Hw,"onAnimationEnd");Ui(Ww,"onAnimationIteration");Ui(Qw,"onAnimationStart");Ui("dblclick","onDoubleClick");Ui("focusin","onFocus");Ui("focusout","onBlur");Ui(Gw,"onTransitionEnd");Hl("onMouseEnter",["mouseout","mouseover"]);Hl("onMouseLeave",["mouseout","mouseover"]);Hl("onPointerEnter",["pointerout","pointerover"]);Hl("onPointerLeave",["pointerout","pointerover"]);Ha("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ha("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ha("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ha("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ha("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ha("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Bo="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(" "),gD=new Set("cancel close invalid load scroll toggle".split(" ").concat(Bo));function ib(t,e,n){var s=t.type||"unknown-event";t.currentTarget=n,mA(s,e,void 0,t),t.currentTarget=null}function Zw(t,e){e=(e&4)!==0;for(var n=0;n<t.length;n++){var s=t[n],r=s.event;s=s.listeners;e:{var a=void 0;if(e)for(var l=s.length-1;0<=l;l--){var o=s[l],c=o.instance,d=o.currentTarget;if(o=o.listener,c!==a&&r.isPropagationStopped())break e;ib(r,o,d),a=c}else for(l=0;l<s.length;l++){if(o=s[l],c=o.instance,d=o.currentTarget,o=o.listener,c!==a&&r.isPropagationStopped())break e;ib(r,o,d),a=c}}}if(Ou)throw t=Tp,Ou=!1,Tp=null,t}function at(t,e){var n=e[_p];n===void 0&&(n=e[_p]=new Set);var s=t+"__bubble";n.has(s)||(Yw(e,t,2,!1),n.add(s))}function pm(t,e,n){var s=0;e&&(s|=4),Yw(n,t,s,e)}var $d="_reactListening"+Math.random().toString(36).slice(2);function kc(t){if(!t[$d]){t[$d]=!0,iw.forEach(function(n){n!=="selectionchange"&&(gD.has(n)||pm(n,!1,t),pm(n,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[$d]||(e[$d]=!0,pm("selectionchange",!1,e))}}function Yw(t,e,n,s){switch(Ow(e)){case 1:var r=MA;break;case 4:r=TA;break;default:r=zx}n=r.bind(null,e,n,t),r=void 0,!Mp||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(r=!0),s?r!==void 0?t.addEventListener(e,n,{capture:!0,passive:r}):t.addEventListener(e,n,!0):r!==void 0?t.addEventListener(e,n,{passive:r}):t.addEventListener(e,n,!1)}function gm(t,e,n,s,r){var a=s;if(!(e&1)&&!(e&2)&&s!==null)e:for(;;){if(s===null)return;var l=s.tag;if(l===3||l===4){var o=s.stateNode.containerInfo;if(o===r||o.nodeType===8&&o.parentNode===r)break;if(l===4)for(l=s.return;l!==null;){var c=l.tag;if((c===3||c===4)&&(c=l.stateNode.containerInfo,c===r||c.nodeType===8&&c.parentNode===r))return;l=l.return}for(;o!==null;){if(l=na(o),l===null)return;if(c=l.tag,c===5||c===6){s=a=l;continue e}o=o.parentNode}}s=s.return}jw(function(){var d=a,u=Rx(n),h=[];e:{var m=Jw.get(t);if(m!==void 0){var f=Bx,p=t;switch(t){case"keypress":if(mu(n)===0)break e;case"keydown":case"keyup":f=HA;break;case"focusin":p="focus",f=cm;break;case"focusout":p="blur",f=cm;break;case"beforeblur":case"afterblur":f=cm;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=Wv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=RA;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=GA;break;case Hw:case Ww:case Qw:f=FA;break;case Gw:f=ZA;break;case"scroll":f=PA;break;case"wheel":f=XA;break;case"copy":case"cut":case"paste":f=$A;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=Gv}var g=(e&4)!==0,x=!g&&t==="scroll",y=g?m!==null?m+"Capture":null:m;g=[];for(var v=d,b;v!==null;){b=v;var j=b.stateNode;if(b.tag===5&&j!==null&&(b=j,y!==null&&(j=yc(v,y),j!=null&&g.push(Sc(v,j,b)))),x)break;v=v.return}0<g.length&&(m=new f(m,p,null,n,u),h.push({event:m,listeners:g}))}}if(!(e&7)){e:{if(m=t==="mouseover"||t==="pointerover",f=t==="mouseout"||t==="pointerout",m&&n!==Ap&&(p=n.relatedTarget||n.fromElement)&&(na(p)||p[zr]))break e;if((f||m)&&(m=u.window===u?u:(m=u.ownerDocument)?m.defaultView||m.parentWindow:window,f?(p=n.relatedTarget||n.toElement,f=d,p=p?na(p):null,p!==null&&(x=Wa(p),p!==x||p.tag!==5&&p.tag!==6)&&(p=null)):(f=null,p=d),f!==p)){if(g=Wv,j="onMouseLeave",y="onMouseEnter",v="mouse",(t==="pointerout"||t==="pointerover")&&(g=Gv,j="onPointerLeave",y="onPointerEnter",v="pointer"),x=f==null?m:fl(f),b=p==null?m:fl(p),m=new g(j,v+"leave",f,n,u),m.target=x,m.relatedTarget=b,j=null,na(u)===d&&(g=new g(y,v+"enter",p,n,u),g.target=b,g.relatedTarget=x,j=g),x=j,f&&p)t:{for(g=f,y=p,v=0,b=g;b;b=Xa(b))v++;for(b=0,j=y;j;j=Xa(j))b++;for(;0<v-b;)g=Xa(g),v--;for(;0<b-v;)y=Xa(y),b--;for(;v--;){if(g===y||y!==null&&g===y.alternate)break t;g=Xa(g),y=Xa(y)}g=null}else g=null;f!==null&&ab(h,m,f,g,!1),p!==null&&x!==null&&ab(h,x,p,g,!0)}}e:{if(m=d?fl(d):window,f=m.nodeName&&m.nodeName.toLowerCase(),f==="select"||f==="input"&&m.type==="file")var k=aD;else if(Yv(m))if(_w)k=dD;else{k=oD;var E=lD}else(f=m.nodeName)&&f.toLowerCase()==="input"&&(m.type==="checkbox"||m.type==="radio")&&(k=cD);if(k&&(k=k(t,d))){Bw(h,k,n,u);break e}E&&E(t,m,d),t==="focusout"&&(E=m._wrapperState)&&E.controlled&&m.type==="number"&&wp(m,"number",m.value)}switch(E=d?fl(d):window,t){case"focusin":(Yv(E)||E.contentEditable==="true")&&(ul=E,Op=d,Yo=null);break;case"focusout":Yo=Op=ul=null;break;case"mousedown":Lp=!0;break;case"contextmenu":case"mouseup":case"dragend":Lp=!1,sb(h,n,u);break;case"selectionchange":if(fD)break;case"keydown":case"keyup":sb(h,n,u)}var T;if(Vx)e:{switch(t){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else dl?zw(t,n)&&(w="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(w="onCompositionStart");w&&(Fw&&n.locale!=="ko"&&(dl||w!=="onCompositionStart"?w==="onCompositionEnd"&&dl&&(T=Lw()):(bi=u,$x="value"in bi?bi.value:bi.textContent,dl=!0)),E=Bu(d,w),0<E.length&&(w=new Qv(w,t,null,n,u),h.push({event:w,listeners:E}),T?w.data=T:(T=$w(n),T!==null&&(w.data=T)))),(T=tD?nD(t,n):sD(t,n))&&(d=Bu(d,"onBeforeInput"),0<d.length&&(u=new Qv("onBeforeInput","beforeinput",null,n,u),h.push({event:u,listeners:d}),u.data=T))}Zw(h,e)})}function Sc(t,e,n){return{instance:t,listener:e,currentTarget:n}}function Bu(t,e){for(var n=e+"Capture",s=[];t!==null;){var r=t,a=r.stateNode;r.tag===5&&a!==null&&(r=a,a=yc(t,n),a!=null&&s.unshift(Sc(t,a,r)),a=yc(t,e),a!=null&&s.push(Sc(t,a,r))),t=t.return}return s}function Xa(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function ab(t,e,n,s,r){for(var a=e._reactName,l=[];n!==null&&n!==s;){var o=n,c=o.alternate,d=o.stateNode;if(c!==null&&c===s)break;o.tag===5&&d!==null&&(o=d,r?(c=yc(n,a),c!=null&&l.unshift(Sc(n,c,o))):r||(c=yc(n,a),c!=null&&l.push(Sc(n,c,o)))),n=n.return}l.length!==0&&t.push({event:e,listeners:l})}var xD=/\r\n?/g,yD=/\u0000|\uFFFD/g;function lb(t){return(typeof t=="string"?t:""+t).replace(xD,`
`).replace(yD,"")}function Bd(t,e,n){if(e=lb(e),lb(t)!==e&&n)throw Error(ne(425))}function _u(){}var Fp=null,zp=null;function $p(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 Bp=typeof setTimeout=="function"?setTimeout:void 0,vD=typeof clearTimeout=="function"?clearTimeout:void 0,ob=typeof Promise=="function"?Promise:void 0,bD=typeof queueMicrotask=="function"?queueMicrotask:typeof ob<"u"?function(t){return ob.resolve(null).then(t).catch(jD)}:Bp;function jD(t){setTimeout(function(){throw t})}function xm(t,e){var n=e,s=0;do{var r=n.nextSibling;if(t.removeChild(n),r&&r.nodeType===8)if(n=r.data,n==="/$"){if(s===0){t.removeChild(r),jc(e);return}s--}else n!=="$"&&n!=="$?"&&n!=="$!"||s++;n=r}while(n);jc(e)}function Di(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 cb(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(e===0)return t;e--}else n==="/$"&&e++}t=t.previousSibling}return null}var fo=Math.random().toString(36).slice(2),nr="__reactFiber$"+fo,Cc="__reactProps$"+fo,zr="__reactContainer$"+fo,_p="__reactEvents$"+fo,ND="__reactListeners$"+fo,wD="__reactHandles$"+fo;function na(t){var e=t[nr];if(e)return e;for(var n=t.parentNode;n;){if(e=n[zr]||n[nr]){if(n=e.alternate,e.child!==null||n!==null&&n.child!==null)for(t=cb(t);t!==null;){if(n=t[nr])return n;t=cb(t)}return e}t=n,n=t.parentNode}return null}function hd(t){return t=t[nr]||t[zr],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function fl(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(ne(33))}function uf(t){return t[Cc]||null}var Vp=[],ml=-1;function qi(t){return{current:t}}function ot(t){0>ml||(t.current=Vp[ml],Vp[ml]=null,ml--)}function st(t,e){ml++,Vp[ml]=t.current,t.current=e}var _i={},bn=qi(_i),Hn=qi(!1),Pa=_i;function Wl(t,e){var n=t.type.contextTypes;if(!n)return _i;var s=t.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===e)return s.__reactInternalMemoizedMaskedChildContext;var r={},a;for(a in n)r[a]=e[a];return s&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=r),r}function Wn(t){return t=t.childContextTypes,t!=null}function Vu(){ot(Hn),ot(bn)}function db(t,e,n){if(bn.current!==_i)throw Error(ne(168));st(bn,e),st(Hn,n)}function Xw(t,e,n){var s=t.stateNode;if(e=e.childContextTypes,typeof s.getChildContext!="function")return n;s=s.getChildContext();for(var r in s)if(!(r in e))throw Error(ne(108,lA(t)||"Unknown",r));return jt({},n,s)}function Ku(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||_i,Pa=bn.current,st(bn,t),st(Hn,Hn.current),!0}function ub(t,e,n){var s=t.stateNode;if(!s)throw Error(ne(169));n?(t=Xw(t,e,Pa),s.__reactInternalMemoizedMergedChildContext=t,ot(Hn),ot(bn),st(bn,t)):ot(Hn),st(Hn,n)}var Nr=null,hf=!1,ym=!1;function ek(t){Nr===null?Nr=[t]:Nr.push(t)}function kD(t){hf=!0,ek(t)}function Hi(){if(!ym&&Nr!==null){ym=!0;var t=0,e=Ye;try{var n=Nr;for(Ye=1;t<n.length;t++){var s=n[t];do s=s(!0);while(s!==null)}Nr=null,hf=!1}catch(r){throw Nr!==null&&(Nr=Nr.slice(t+1)),Sw(Ox,Hi),r}finally{Ye=e,ym=!1}}return null}var pl=[],gl=0,Uu=null,qu=0,vs=[],bs=0,Ia=null,Ar=1,Dr="";function Xi(t,e){pl[gl++]=qu,pl[gl++]=Uu,Uu=t,qu=e}function tk(t,e,n){vs[bs++]=Ar,vs[bs++]=Dr,vs[bs++]=Ia,Ia=t;var s=Ar;t=Dr;var r=32-$s(s)-1;s&=~(1<<r),n+=1;var a=32-$s(e)+r;if(30<a){var l=r-r%5;a=(s&(1<<l)-1).toString(32),s>>=l,r-=l,Ar=1<<32-$s(e)+r|n<<r|s,Dr=a+t}else Ar=1<<a|n<<r|s,Dr=t}function Ux(t){t.return!==null&&(Xi(t,1),tk(t,1,0))}function qx(t){for(;t===Uu;)Uu=pl[--gl],pl[gl]=null,qu=pl[--gl],pl[gl]=null;for(;t===Ia;)Ia=vs[--bs],vs[bs]=null,Dr=vs[--bs],vs[bs]=null,Ar=vs[--bs],vs[bs]=null}var is=null,rs=null,ft=!1,Is=null;function nk(t,e){var n=Ns(5,null,null,0);n.elementType="DELETED",n.stateNode=e,n.return=t,e=t.deletions,e===null?(t.deletions=[n],t.flags|=16):e.push(n)}function hb(t,e){switch(t.tag){case 5:var n=t.type;return e=e.nodeType!==1||n.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,is=t,rs=Di(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,is=t,rs=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(n=Ia!==null?{id:Ar,overflow:Dr}:null,t.memoizedState={dehydrated:e,treeContext:n,retryLane:1073741824},n=Ns(18,null,null,0),n.stateNode=e,n.return=t,t.child=n,is=t,rs=null,!0):!1;default:return!1}}function Kp(t){return(t.mode&1)!==0&&(t.flags&128)===0}function Up(t){if(ft){var e=rs;if(e){var n=e;if(!hb(t,e)){if(Kp(t))throw Error(ne(418));e=Di(n.nextSibling);var s=is;e&&hb(t,e)?nk(s,n):(t.flags=t.flags&-4097|2,ft=!1,is=t)}}else{if(Kp(t))throw Error(ne(418));t.flags=t.flags&-4097|2,ft=!1,is=t}}}function fb(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;is=t}function _d(t){if(t!==is)return!1;if(!ft)return fb(t),ft=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!$p(t.type,t.memoizedProps)),e&&(e=rs)){if(Kp(t))throw sk(),Error(ne(418));for(;e;)nk(t,e),e=Di(e.nextSibling)}if(fb(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(ne(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"){if(e===0){rs=Di(t.nextSibling);break e}e--}else n!=="$"&&n!=="$!"&&n!=="$?"||e++}t=t.nextSibling}rs=null}}else rs=is?Di(t.stateNode.nextSibling):null;return!0}function sk(){for(var t=rs;t;)t=Di(t.nextSibling)}function Ql(){rs=is=null,ft=!1}function Hx(t){Is===null?Is=[t]:Is.push(t)}var SD=Kr.ReactCurrentBatchConfig;function Do(t,e,n){if(t=n.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(ne(309));var s=n.stateNode}if(!s)throw Error(ne(147,t));var r=s,a=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===a?e.ref:(e=function(l){var o=r.refs;l===null?delete o[a]:o[a]=l},e._stringRef=a,e)}if(typeof t!="string")throw Error(ne(284));if(!n._owner)throw Error(ne(290,t))}return t}function Vd(t,e){throw t=Object.prototype.toString.call(e),Error(ne(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function mb(t){var e=t._init;return e(t._payload)}function rk(t){function e(y,v){if(t){var b=y.deletions;b===null?(y.deletions=[v],y.flags|=16):b.push(v)}}function n(y,v){if(!t)return null;for(;v!==null;)e(y,v),v=v.sibling;return null}function s(y,v){for(y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function r(y,v){return y=Ii(y,v),y.index=0,y.sibling=null,y}function a(y,v,b){return y.index=b,t?(b=y.alternate,b!==null?(b=b.index,b<v?(y.flags|=2,v):b):(y.flags|=2,v)):(y.flags|=1048576,v)}function l(y){return t&&y.alternate===null&&(y.flags|=2),y}function o(y,v,b,j){return v===null||v.tag!==6?(v=Sm(b,y.mode,j),v.return=y,v):(v=r(v,b),v.return=y,v)}function c(y,v,b,j){var k=b.type;return k===cl?u(y,v,b.props.children,j,b.key):v!==null&&(v.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===Yr&&mb(k)===v.type)?(j=r(v,b.props),j.ref=Do(y,v,b),j.return=y,j):(j=ju(b.type,b.key,b.props,null,y.mode,j),j.ref=Do(y,v,b),j.return=y,j)}function d(y,v,b,j){return v===null||v.tag!==4||v.stateNode.containerInfo!==b.containerInfo||v.stateNode.implementation!==b.implementation?(v=Cm(b,y.mode,j),v.return=y,v):(v=r(v,b.children||[]),v.return=y,v)}function u(y,v,b,j,k){return v===null||v.tag!==7?(v=wa(b,y.mode,j,k),v.return=y,v):(v=r(v,b),v.return=y,v)}function h(y,v,b){if(typeof v=="string"&&v!==""||typeof v=="number")return v=Sm(""+v,y.mode,b),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Td:return b=ju(v.type,v.key,v.props,null,y.mode,b),b.ref=Do(y,null,v),b.return=y,b;case ol:return v=Cm(v,y.mode,b),v.return=y,v;case Yr:var j=v._init;return h(y,j(v._payload),b)}if(zo(v)||ko(v))return v=wa(v,y.mode,b,null),v.return=y,v;Vd(y,v)}return null}function m(y,v,b,j){var k=v!==null?v.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return k!==null?null:o(y,v,""+b,j);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Td:return b.key===k?c(y,v,b,j):null;case ol:return b.key===k?d(y,v,b,j):null;case Yr:return k=b._init,m(y,v,k(b._payload),j)}if(zo(b)||ko(b))return k!==null?null:u(y,v,b,j,null);Vd(y,b)}return null}function f(y,v,b,j,k){if(typeof j=="string"&&j!==""||typeof j=="number")return y=y.get(b)||null,o(v,y,""+j,k);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Td:return y=y.get(j.key===null?b:j.key)||null,c(v,y,j,k);case ol:return y=y.get(j.key===null?b:j.key)||null,d(v,y,j,k);case Yr:var E=j._init;return f(y,v,b,E(j._payload),k)}if(zo(j)||ko(j))return y=y.get(b)||null,u(v,y,j,k,null);Vd(v,j)}return null}function p(y,v,b,j){for(var k=null,E=null,T=v,w=v=0,S=null;T!==null&&w<b.length;w++){T.index>w?(S=T,T=null):S=T.sibling;var M=m(y,T,b[w],j);if(M===null){T===null&&(T=S);break}t&&T&&M.alternate===null&&e(y,T),v=a(M,v,w),E===null?k=M:E.sibling=M,E=M,T=S}if(w===b.length)return n(y,T),ft&&Xi(y,w),k;if(T===null){for(;w<b.length;w++)T=h(y,b[w],j),T!==null&&(v=a(T,v,w),E===null?k=T:E.sibling=T,E=T);return ft&&Xi(y,w),k}for(T=s(y,T);w<b.length;w++)S=f(T,y,w,b[w],j),S!==null&&(t&&S.alternate!==null&&T.delete(S.key===null?w:S.key),v=a(S,v,w),E===null?k=S:E.sibling=S,E=S);return t&&T.forEach(function(F){return e(y,F)}),ft&&Xi(y,w),k}function g(y,v,b,j){var k=ko(b);if(typeof k!="function")throw Error(ne(150));if(b=k.call(b),b==null)throw Error(ne(151));for(var E=k=null,T=v,w=v=0,S=null,M=b.next();T!==null&&!M.done;w++,M=b.next()){T.index>w?(S=T,T=null):S=T.sibling;var F=m(y,T,M.value,j);if(F===null){T===null&&(T=S);break}t&&T&&F.alternate===null&&e(y,T),v=a(F,v,w),E===null?k=F:E.sibling=F,E=F,T=S}if(M.done)return n(y,T),ft&&Xi(y,w),k;if(T===null){for(;!M.done;w++,M=b.next())M=h(y,M.value,j),M!==null&&(v=a(M,v,w),E===null?k=M:E.sibling=M,E=M);return ft&&Xi(y,w),k}for(T=s(y,T);!M.done;w++,M=b.next())M=f(T,y,w,M.value,j),M!==null&&(t&&M.alternate!==null&&T.delete(M.key===null?w:M.key),v=a(M,v,w),E===null?k=M:E.sibling=M,E=M);return t&&T.forEach(function(R){return e(y,R)}),ft&&Xi(y,w),k}function x(y,v,b,j){if(typeof b=="object"&&b!==null&&b.type===cl&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case Td:e:{for(var k=b.key,E=v;E!==null;){if(E.key===k){if(k=b.type,k===cl){if(E.tag===7){n(y,E.sibling),v=r(E,b.props.children),v.return=y,y=v;break e}}else if(E.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===Yr&&mb(k)===E.type){n(y,E.sibling),v=r(E,b.props),v.ref=Do(y,E,b),v.return=y,y=v;break e}n(y,E);break}else e(y,E);E=E.sibling}b.type===cl?(v=wa(b.props.children,y.mode,j,b.key),v.return=y,y=v):(j=ju(b.type,b.key,b.props,null,y.mode,j),j.ref=Do(y,v,b),j.return=y,y=j)}return l(y);case ol:e:{for(E=b.key;v!==null;){if(v.key===E)if(v.tag===4&&v.stateNode.containerInfo===b.containerInfo&&v.stateNode.implementation===b.implementation){n(y,v.sibling),v=r(v,b.children||[]),v.return=y,y=v;break e}else{n(y,v);break}else e(y,v);v=v.sibling}v=Cm(b,y.mode,j),v.return=y,y=v}return l(y);case Yr:return E=b._init,x(y,v,E(b._payload),j)}if(zo(b))return p(y,v,b,j);if(ko(b))return g(y,v,b,j);Vd(y,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,v!==null&&v.tag===6?(n(y,v.sibling),v=r(v,b),v.return=y,y=v):(n(y,v),v=Sm(b,y.mode,j),v.return=y,y=v),l(y)):n(y,v)}return x}var Gl=rk(!0),ik=rk(!1),Hu=qi(null),Wu=null,xl=null,Wx=null;function Qx(){Wx=xl=Wu=null}function Gx(t){var e=Hu.current;ot(Hu),t._currentValue=e}function qp(t,e,n){for(;t!==null;){var s=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,s!==null&&(s.childLanes|=e)):s!==null&&(s.childLanes&e)!==e&&(s.childLanes|=e),t===n)break;t=t.return}}function Cl(t,e){Wu=t,Wx=xl=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Kn=!0),t.firstContext=null)}function Cs(t){var e=t._currentValue;if(Wx!==t)if(t={context:t,memoizedValue:e,next:null},xl===null){if(Wu===null)throw Error(ne(308));xl=t,Wu.dependencies={lanes:0,firstContext:t}}else xl=xl.next=t;return e}var sa=null;function Jx(t){sa===null?sa=[t]:sa.push(t)}function ak(t,e,n,s){var r=e.interleaved;return r===null?(n.next=n,Jx(e)):(n.next=r.next,r.next=n),e.interleaved=n,$r(t,s)}function $r(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var Xr=!1;function Zx(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function lk(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 Ir(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Mi(t,e,n){var s=t.updateQueue;if(s===null)return null;if(s=s.shared,Ve&2){var r=s.pending;return r===null?e.next=e:(e.next=r.next,r.next=e),s.pending=e,$r(t,n)}return r=s.interleaved,r===null?(e.next=e,Jx(s)):(e.next=r.next,r.next=e),s.interleaved=e,$r(t,n)}function pu(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var s=e.lanes;s&=t.pendingLanes,n|=s,e.lanes=n,Lx(t,n)}}function pb(t,e){var n=t.updateQueue,s=t.alternate;if(s!==null&&(s=s.updateQueue,n===s)){var r=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?r=a=l:a=a.next=l,n=n.next}while(n!==null);a===null?r=a=e:a=a.next=e}else r=a=e;n={baseState:s.baseState,firstBaseUpdate:r,lastBaseUpdate:a,shared:s.shared,effects:s.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function Qu(t,e,n,s){var r=t.updateQueue;Xr=!1;var a=r.firstBaseUpdate,l=r.lastBaseUpdate,o=r.shared.pending;if(o!==null){r.shared.pending=null;var c=o,d=c.next;c.next=null,l===null?a=d:l.next=d,l=c;var u=t.alternate;u!==null&&(u=u.updateQueue,o=u.lastBaseUpdate,o!==l&&(o===null?u.firstBaseUpdate=d:o.next=d,u.lastBaseUpdate=c))}if(a!==null){var h=r.baseState;l=0,u=d=c=null,o=a;do{var m=o.lane,f=o.eventTime;if((s&m)===m){u!==null&&(u=u.next={eventTime:f,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var p=t,g=o;switch(m=e,f=n,g.tag){case 1:if(p=g.payload,typeof p=="function"){h=p.call(f,h,m);break e}h=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=g.payload,m=typeof p=="function"?p.call(f,h,m):p,m==null)break e;h=jt({},h,m);break e;case 2:Xr=!0}}o.callback!==null&&o.lane!==0&&(t.flags|=64,m=r.effects,m===null?r.effects=[o]:m.push(o))}else f={eventTime:f,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},u===null?(d=u=f,c=h):u=u.next=f,l|=m;if(o=o.next,o===null){if(o=r.shared.pending,o===null)break;m=o,o=m.next,m.next=null,r.lastBaseUpdate=m,r.shared.pending=null}}while(!0);if(u===null&&(c=h),r.baseState=c,r.firstBaseUpdate=d,r.lastBaseUpdate=u,e=r.shared.interleaved,e!==null){r=e;do l|=r.lane,r=r.next;while(r!==e)}else a===null&&(r.shared.lanes=0);Oa|=l,t.lanes=l,t.memoizedState=h}}function gb(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var s=t[e],r=s.callback;if(r!==null){if(s.callback=null,s=n,typeof r!="function")throw Error(ne(191,r));r.call(s)}}}var fd={},ir=qi(fd),Ec=qi(fd),Ac=qi(fd);function ra(t){if(t===fd)throw Error(ne(174));return t}function Yx(t,e){switch(st(Ac,e),st(Ec,t),st(ir,fd),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Sp(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=Sp(e,t)}ot(ir),st(ir,e)}function Jl(){ot(ir),ot(Ec),ot(Ac)}function ok(t){ra(Ac.current);var e=ra(ir.current),n=Sp(e,t.type);e!==n&&(st(Ec,t),st(ir,n))}function Xx(t){Ec.current===t&&(ot(ir),ot(Ec))}var xt=qi(0);function Gu(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.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 vm=[];function ey(){for(var t=0;t<vm.length;t++)vm[t]._workInProgressVersionPrimary=null;vm.length=0}var gu=Kr.ReactCurrentDispatcher,bm=Kr.ReactCurrentBatchConfig,Ra=0,vt=null,Kt=null,Gt=null,Ju=!1,Xo=!1,Dc=0,CD=0;function mn(){throw Error(ne(321))}function ty(t,e){if(e===null)return!1;for(var n=0;n<e.length&&n<t.length;n++)if(!Vs(t[n],e[n]))return!1;return!0}function ny(t,e,n,s,r,a){if(Ra=a,vt=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,gu.current=t===null||t.memoizedState===null?MD:TD,t=n(s,r),Xo){a=0;do{if(Xo=!1,Dc=0,25<=a)throw Error(ne(301));a+=1,Gt=Kt=null,e.updateQueue=null,gu.current=PD,t=n(s,r)}while(Xo)}if(gu.current=Zu,e=Kt!==null&&Kt.next!==null,Ra=0,Gt=Kt=vt=null,Ju=!1,e)throw Error(ne(300));return t}function sy(){var t=Dc!==0;return Dc=0,t}function Qs(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Gt===null?vt.memoizedState=Gt=t:Gt=Gt.next=t,Gt}function Es(){if(Kt===null){var t=vt.alternate;t=t!==null?t.memoizedState:null}else t=Kt.next;var e=Gt===null?vt.memoizedState:Gt.next;if(e!==null)Gt=e,Kt=t;else{if(t===null)throw Error(ne(310));Kt=t,t={memoizedState:Kt.memoizedState,baseState:Kt.baseState,baseQueue:Kt.baseQueue,queue:Kt.queue,next:null},Gt===null?vt.memoizedState=Gt=t:Gt=Gt.next=t}return Gt}function Mc(t,e){return typeof e=="function"?e(t):e}function jm(t){var e=Es(),n=e.queue;if(n===null)throw Error(ne(311));n.lastRenderedReducer=t;var s=Kt,r=s.baseQueue,a=n.pending;if(a!==null){if(r!==null){var l=r.next;r.next=a.next,a.next=l}s.baseQueue=r=a,n.pending=null}if(r!==null){a=r.next,s=s.baseState;var o=l=null,c=null,d=a;do{var u=d.lane;if((Ra&u)===u)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),s=d.hasEagerState?d.eagerState:t(s,d.action);else{var h={lane:u,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(o=c=h,l=s):c=c.next=h,vt.lanes|=u,Oa|=u}d=d.next}while(d!==null&&d!==a);c===null?l=s:c.next=o,Vs(s,e.memoizedState)||(Kn=!0),e.memoizedState=s,e.baseState=l,e.baseQueue=c,n.lastRenderedState=s}if(t=n.interleaved,t!==null){r=t;do a=r.lane,vt.lanes|=a,Oa|=a,r=r.next;while(r!==t)}else r===null&&(n.lanes=0);return[e.memoizedState,n.dispatch]}function Nm(t){var e=Es(),n=e.queue;if(n===null)throw Error(ne(311));n.lastRenderedReducer=t;var s=n.dispatch,r=n.pending,a=e.memoizedState;if(r!==null){n.pending=null;var l=r=r.next;do a=t(a,l.action),l=l.next;while(l!==r);Vs(a,e.memoizedState)||(Kn=!0),e.memoizedState=a,e.baseQueue===null&&(e.baseState=a),n.lastRenderedState=a}return[a,s]}function ck(){}function dk(t,e){var n=vt,s=Es(),r=e(),a=!Vs(s.memoizedState,r);if(a&&(s.memoizedState=r,Kn=!0),s=s.queue,ry(fk.bind(null,n,s,t),[t]),s.getSnapshot!==e||a||Gt!==null&&Gt.memoizedState.tag&1){if(n.flags|=2048,Tc(9,hk.bind(null,n,s,r,e),void 0,null),Xt===null)throw Error(ne(349));Ra&30||uk(n,e,r)}return r}function uk(t,e,n){t.flags|=16384,t={getSnapshot:e,value:n},e=vt.updateQueue,e===null?(e={lastEffect:null,stores:null},vt.updateQueue=e,e.stores=[t]):(n=e.stores,n===null?e.stores=[t]:n.push(t))}function hk(t,e,n,s){e.value=n,e.getSnapshot=s,mk(e)&&pk(t)}function fk(t,e,n){return n(function(){mk(e)&&pk(t)})}function mk(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!Vs(t,n)}catch{return!0}}function pk(t){var e=$r(t,1);e!==null&&Bs(e,t,1,-1)}function xb(t){var e=Qs();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Mc,lastRenderedState:t},e.queue=t,t=t.dispatch=DD.bind(null,vt,t),[e.memoizedState,t]}function Tc(t,e,n,s){return t={tag:t,create:e,destroy:n,deps:s,next:null},e=vt.updateQueue,e===null?(e={lastEffect:null,stores:null},vt.updateQueue=e,e.lastEffect=t.next=t):(n=e.lastEffect,n===null?e.lastEffect=t.next=t:(s=n.next,n.next=t,t.next=s,e.lastEffect=t)),t}function gk(){return Es().memoizedState}function xu(t,e,n,s){var r=Qs();vt.flags|=t,r.memoizedState=Tc(1|e,n,void 0,s===void 0?null:s)}function ff(t,e,n,s){var r=Es();s=s===void 0?null:s;var a=void 0;if(Kt!==null){var l=Kt.memoizedState;if(a=l.destroy,s!==null&&ty(s,l.deps)){r.memoizedState=Tc(e,n,a,s);return}}vt.flags|=t,r.memoizedState=Tc(1|e,n,a,s)}function yb(t,e){return xu(8390656,8,t,e)}function ry(t,e){return ff(2048,8,t,e)}function xk(t,e){return ff(4,2,t,e)}function yk(t,e){return ff(4,4,t,e)}function vk(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 bk(t,e,n){return n=n!=null?n.concat([t]):null,ff(4,4,vk.bind(null,e,t),n)}function iy(){}function jk(t,e){var n=Es();e=e===void 0?null:e;var s=n.memoizedState;return s!==null&&e!==null&&ty(e,s[1])?s[0]:(n.memoizedState=[t,e],t)}function Nk(t,e){var n=Es();e=e===void 0?null:e;var s=n.memoizedState;return s!==null&&e!==null&&ty(e,s[1])?s[0]:(t=t(),n.memoizedState=[t,e],t)}function wk(t,e,n){return Ra&21?(Vs(n,e)||(n=Aw(),vt.lanes|=n,Oa|=n,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,Kn=!0),t.memoizedState=n)}function ED(t,e){var n=Ye;Ye=n!==0&&4>n?n:4,t(!0);var s=bm.transition;bm.transition={};try{t(!1),e()}finally{Ye=n,bm.transition=s}}function kk(){return Es().memoizedState}function AD(t,e,n){var s=Pi(t);if(n={lane:s,action:n,hasEagerState:!1,eagerState:null,next:null},Sk(t))Ck(e,n);else if(n=ak(t,e,n,s),n!==null){var r=Dn();Bs(n,t,s,r),Ek(n,e,s)}}function DD(t,e,n){var s=Pi(t),r={lane:s,action:n,hasEagerState:!1,eagerState:null,next:null};if(Sk(t))Ck(e,r);else{var a=t.alternate;if(t.lanes===0&&(a===null||a.lanes===0)&&(a=e.lastRenderedReducer,a!==null))try{var l=e.lastRenderedState,o=a(l,n);if(r.hasEagerState=!0,r.eagerState=o,Vs(o,l)){var c=e.interleaved;c===null?(r.next=r,Jx(e)):(r.next=c.next,c.next=r),e.interleaved=r;return}}catch{}finally{}n=ak(t,e,r,s),n!==null&&(r=Dn(),Bs(n,t,s,r),Ek(n,e,s))}}function Sk(t){var e=t.alternate;return t===vt||e!==null&&e===vt}function Ck(t,e){Xo=Ju=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function Ek(t,e,n){if(n&4194240){var s=e.lanes;s&=t.pendingLanes,n|=s,e.lanes=n,Lx(t,n)}}var Zu={readContext:Cs,useCallback:mn,useContext:mn,useEffect:mn,useImperativeHandle:mn,useInsertionEffect:mn,useLayoutEffect:mn,useMemo:mn,useReducer:mn,useRef:mn,useState:mn,useDebugValue:mn,useDeferredValue:mn,useTransition:mn,useMutableSource:mn,useSyncExternalStore:mn,useId:mn,unstable_isNewReconciler:!1},MD={readContext:Cs,useCallback:function(t,e){return Qs().memoizedState=[t,e===void 0?null:e],t},useContext:Cs,useEffect:yb,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,xu(4194308,4,vk.bind(null,e,t),n)},useLayoutEffect:function(t,e){return xu(4194308,4,t,e)},useInsertionEffect:function(t,e){return xu(4,2,t,e)},useMemo:function(t,e){var n=Qs();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var s=Qs();return e=n!==void 0?n(e):e,s.memoizedState=s.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},s.queue=t,t=t.dispatch=AD.bind(null,vt,t),[s.memoizedState,t]},useRef:function(t){var e=Qs();return t={current:t},e.memoizedState=t},useState:xb,useDebugValue:iy,useDeferredValue:function(t){return Qs().memoizedState=t},useTransition:function(){var t=xb(!1),e=t[0];return t=ED.bind(null,t[1]),Qs().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var s=vt,r=Qs();if(ft){if(n===void 0)throw Error(ne(407));n=n()}else{if(n=e(),Xt===null)throw Error(ne(349));Ra&30||uk(s,e,n)}r.memoizedState=n;var a={value:n,getSnapshot:e};return r.queue=a,yb(fk.bind(null,s,a,t),[t]),s.flags|=2048,Tc(9,hk.bind(null,s,a,n,e),void 0,null),n},useId:function(){var t=Qs(),e=Xt.identifierPrefix;if(ft){var n=Dr,s=Ar;n=(s&~(1<<32-$s(s)-1)).toString(32)+n,e=":"+e+"R"+n,n=Dc++,0<n&&(e+="H"+n.toString(32)),e+=":"}else n=CD++,e=":"+e+"r"+n.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},TD={readContext:Cs,useCallback:jk,useContext:Cs,useEffect:ry,useImperativeHandle:bk,useInsertionEffect:xk,useLayoutEffect:yk,useMemo:Nk,useReducer:jm,useRef:gk,useState:function(){return jm(Mc)},useDebugValue:iy,useDeferredValue:function(t){var e=Es();return wk(e,Kt.memoizedState,t)},useTransition:function(){var t=jm(Mc)[0],e=Es().memoizedState;return[t,e]},useMutableSource:ck,useSyncExternalStore:dk,useId:kk,unstable_isNewReconciler:!1},PD={readContext:Cs,useCallback:jk,useContext:Cs,useEffect:ry,useImperativeHandle:bk,useInsertionEffect:xk,useLayoutEffect:yk,useMemo:Nk,useReducer:Nm,useRef:gk,useState:function(){return Nm(Mc)},useDebugValue:iy,useDeferredValue:function(t){var e=Es();return Kt===null?e.memoizedState=t:wk(e,Kt.memoizedState,t)},useTransition:function(){var t=Nm(Mc)[0],e=Es().memoizedState;return[t,e]},useMutableSource:ck,useSyncExternalStore:dk,useId:kk,unstable_isNewReconciler:!1};function Ds(t,e){if(t&&t.defaultProps){e=jt({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function Hp(t,e,n,s){e=t.memoizedState,n=n(s,e),n=n==null?e:jt({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var mf={isMounted:function(t){return(t=t._reactInternals)?Wa(t)===t:!1},enqueueSetState:function(t,e,n){t=t._reactInternals;var s=Dn(),r=Pi(t),a=Ir(s,r);a.payload=e,n!=null&&(a.callback=n),e=Mi(t,a,r),e!==null&&(Bs(e,t,r,s),pu(e,t,r))},enqueueReplaceState:function(t,e,n){t=t._reactInternals;var s=Dn(),r=Pi(t),a=Ir(s,r);a.tag=1,a.payload=e,n!=null&&(a.callback=n),e=Mi(t,a,r),e!==null&&(Bs(e,t,r,s),pu(e,t,r))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var n=Dn(),s=Pi(t),r=Ir(n,s);r.tag=2,e!=null&&(r.callback=e),e=Mi(t,r,s),e!==null&&(Bs(e,t,s,n),pu(e,t,s))}};function vb(t,e,n,s,r,a,l){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(s,a,l):e.prototype&&e.prototype.isPureReactComponent?!wc(n,s)||!wc(r,a):!0}function Ak(t,e,n){var s=!1,r=_i,a=e.contextType;return typeof a=="object"&&a!==null?a=Cs(a):(r=Wn(e)?Pa:bn.current,s=e.contextTypes,a=(s=s!=null)?Wl(t,r):_i),e=new e(n,a),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=mf,t.stateNode=e,e._reactInternals=t,s&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=r,t.__reactInternalMemoizedMaskedChildContext=a),e}function bb(t,e,n,s){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,s),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,s),e.state!==t&&mf.enqueueReplaceState(e,e.state,null)}function Wp(t,e,n,s){var r=t.stateNode;r.props=n,r.state=t.memoizedState,r.refs={},Zx(t);var a=e.contextType;typeof a=="object"&&a!==null?r.context=Cs(a):(a=Wn(e)?Pa:bn.current,r.context=Wl(t,a)),r.state=t.memoizedState,a=e.getDerivedStateFromProps,typeof a=="function"&&(Hp(t,e,a,n),r.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof r.getSnapshotBeforeUpdate=="function"||typeof r.UNSAFE_componentWillMount!="function"&&typeof r.componentWillMount!="function"||(e=r.state,typeof r.componentWillMount=="function"&&r.componentWillMount(),typeof r.UNSAFE_componentWillMount=="function"&&r.UNSAFE_componentWillMount(),e!==r.state&&mf.enqueueReplaceState(r,r.state,null),Qu(t,n,r,s),r.state=t.memoizedState),typeof r.componentDidMount=="function"&&(t.flags|=4194308)}function Zl(t,e){try{var n="",s=e;do n+=aA(s),s=s.return;while(s);var r=n}catch(a){r=`
Error generating stack: `+a.message+`
`+a.stack}return{value:t,source:e,stack:r,digest:null}}function wm(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function Qp(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var ID=typeof WeakMap=="function"?WeakMap:Map;function Dk(t,e,n){n=Ir(-1,n),n.tag=3,n.payload={element:null};var s=e.value;return n.callback=function(){Xu||(Xu=!0,rg=s),Qp(t,e)},n}function Mk(t,e,n){n=Ir(-1,n),n.tag=3;var s=t.type.getDerivedStateFromError;if(typeof s=="function"){var r=e.value;n.payload=function(){return s(r)},n.callback=function(){Qp(t,e)}}var a=t.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(n.callback=function(){Qp(t,e),typeof s!="function"&&(Ti===null?Ti=new Set([this]):Ti.add(this));var l=e.stack;this.componentDidCatch(e.value,{componentStack:l!==null?l:""})}),n}function jb(t,e,n){var s=t.pingCache;if(s===null){s=t.pingCache=new ID;var r=new Set;s.set(e,r)}else r=s.get(e),r===void 0&&(r=new Set,s.set(e,r));r.has(n)||(r.add(n),t=WD.bind(null,t,e,n),e.then(t,t))}function Nb(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 wb(t,e,n,s,r){return t.mode&1?(t.flags|=65536,t.lanes=r,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Ir(-1,1),e.tag=2,Mi(n,e,1))),n.lanes|=1),t)}var RD=Kr.ReactCurrentOwner,Kn=!1;function En(t,e,n,s){e.child=t===null?ik(e,null,n,s):Gl(e,t.child,n,s)}function kb(t,e,n,s,r){n=n.render;var a=e.ref;return Cl(e,r),s=ny(t,e,n,s,a,r),n=sy(),t!==null&&!Kn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~r,Br(t,e,r)):(ft&&n&&Ux(e),e.flags|=1,En(t,e,s,r),e.child)}function Sb(t,e,n,s,r){if(t===null){var a=n.type;return typeof a=="function"&&!fy(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=a,Tk(t,e,a,s,r)):(t=ju(n.type,null,s,e,e.mode,r),t.ref=e.ref,t.return=e,e.child=t)}if(a=t.child,!(t.lanes&r)){var l=a.memoizedProps;if(n=n.compare,n=n!==null?n:wc,n(l,s)&&t.ref===e.ref)return Br(t,e,r)}return e.flags|=1,t=Ii(a,s),t.ref=e.ref,t.return=e,e.child=t}function Tk(t,e,n,s,r){if(t!==null){var a=t.memoizedProps;if(wc(a,s)&&t.ref===e.ref)if(Kn=!1,e.pendingProps=s=a,(t.lanes&r)!==0)t.flags&131072&&(Kn=!0);else return e.lanes=t.lanes,Br(t,e,r)}return Gp(t,e,n,s,r)}function Pk(t,e,n){var s=e.pendingProps,r=s.children,a=t!==null?t.memoizedState:null;if(s.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},st(vl,es),es|=n;else{if(!(n&1073741824))return t=a!==null?a.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,st(vl,es),es|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},s=a!==null?a.baseLanes:n,st(vl,es),es|=s}else a!==null?(s=a.baseLanes|n,e.memoizedState=null):s=n,st(vl,es),es|=s;return En(t,e,r,n),e.child}function Ik(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Gp(t,e,n,s,r){var a=Wn(n)?Pa:bn.current;return a=Wl(e,a),Cl(e,r),n=ny(t,e,n,s,a,r),s=sy(),t!==null&&!Kn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~r,Br(t,e,r)):(ft&&s&&Ux(e),e.flags|=1,En(t,e,n,r),e.child)}function Cb(t,e,n,s,r){if(Wn(n)){var a=!0;Ku(e)}else a=!1;if(Cl(e,r),e.stateNode===null)yu(t,e),Ak(e,n,s),Wp(e,n,s,r),s=!0;else if(t===null){var l=e.stateNode,o=e.memoizedProps;l.props=o;var c=l.context,d=n.contextType;typeof d=="object"&&d!==null?d=Cs(d):(d=Wn(n)?Pa:bn.current,d=Wl(e,d));var u=n.getDerivedStateFromProps,h=typeof u=="function"||typeof l.getSnapshotBeforeUpdate=="function";h||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==s||c!==d)&&bb(e,l,s,d),Xr=!1;var m=e.memoizedState;l.state=m,Qu(e,s,l,r),c=e.memoizedState,o!==s||m!==c||Hn.current||Xr?(typeof u=="function"&&(Hp(e,n,u,s),c=e.memoizedState),(o=Xr||vb(e,n,o,s,m,c,d))?(h||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(e.flags|=4194308)):(typeof l.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=s,e.memoizedState=c),l.props=s,l.state=c,l.context=d,s=o):(typeof l.componentDidMount=="function"&&(e.flags|=4194308),s=!1)}else{l=e.stateNode,lk(t,e),o=e.memoizedProps,d=e.type===e.elementType?o:Ds(e.type,o),l.props=d,h=e.pendingProps,m=l.context,c=n.contextType,typeof c=="object"&&c!==null?c=Cs(c):(c=Wn(n)?Pa:bn.current,c=Wl(e,c));var f=n.getDerivedStateFromProps;(u=typeof f=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==h||m!==c)&&bb(e,l,s,c),Xr=!1,m=e.memoizedState,l.state=m,Qu(e,s,l,r);var p=e.memoizedState;o!==h||m!==p||Hn.current||Xr?(typeof f=="function"&&(Hp(e,n,f,s),p=e.memoizedState),(d=Xr||vb(e,n,d,s,m,p,c)||!1)?(u||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(s,p,c),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(s,p,c)),typeof l.componentDidUpdate=="function"&&(e.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof l.componentDidUpdate!="function"||o===t.memoizedProps&&m===t.memoizedState||(e.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===t.memoizedProps&&m===t.memoizedState||(e.flags|=1024),e.memoizedProps=s,e.memoizedState=p),l.props=s,l.state=p,l.context=c,s=d):(typeof l.componentDidUpdate!="function"||o===t.memoizedProps&&m===t.memoizedState||(e.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===t.memoizedProps&&m===t.memoizedState||(e.flags|=1024),s=!1)}return Jp(t,e,n,s,a,r)}function Jp(t,e,n,s,r,a){Ik(t,e);var l=(e.flags&128)!==0;if(!s&&!l)return r&&ub(e,n,!1),Br(t,e,a);s=e.stateNode,RD.current=e;var o=l&&typeof n.getDerivedStateFromError!="function"?null:s.render();return e.flags|=1,t!==null&&l?(e.child=Gl(e,t.child,null,a),e.child=Gl(e,null,o,a)):En(t,e,o,a),e.memoizedState=s.state,r&&ub(e,n,!0),e.child}function Rk(t){var e=t.stateNode;e.pendingContext?db(t,e.pendingContext,e.pendingContext!==e.context):e.context&&db(t,e.context,!1),Yx(t,e.containerInfo)}function Eb(t,e,n,s,r){return Ql(),Hx(r),e.flags|=256,En(t,e,n,s),e.child}var Zp={dehydrated:null,treeContext:null,retryLane:0};function Yp(t){return{baseLanes:t,cachePool:null,transitions:null}}function Ok(t,e,n){var s=e.pendingProps,r=xt.current,a=!1,l=(e.flags&128)!==0,o;if((o=l)||(o=t!==null&&t.memoizedState===null?!1:(r&2)!==0),o?(a=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(r|=1),st(xt,r&1),t===null)return Up(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):(l=s.children,t=s.fallback,a?(s=e.mode,a=e.child,l={mode:"hidden",children:l},!(s&1)&&a!==null?(a.childLanes=0,a.pendingProps=l):a=xf(l,s,0,null),t=wa(t,s,n,null),a.return=e,t.return=e,a.sibling=t,e.child=a,e.child.memoizedState=Yp(n),e.memoizedState=Zp,t):ay(e,l));if(r=t.memoizedState,r!==null&&(o=r.dehydrated,o!==null))return OD(t,e,l,s,o,r,n);if(a){a=s.fallback,l=e.mode,r=t.child,o=r.sibling;var c={mode:"hidden",children:s.children};return!(l&1)&&e.child!==r?(s=e.child,s.childLanes=0,s.pendingProps=c,e.deletions=null):(s=Ii(r,c),s.subtreeFlags=r.subtreeFlags&14680064),o!==null?a=Ii(o,a):(a=wa(a,l,n,null),a.flags|=2),a.return=e,s.return=e,s.sibling=a,e.child=s,s=a,a=e.child,l=t.child.memoizedState,l=l===null?Yp(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},a.memoizedState=l,a.childLanes=t.childLanes&~n,e.memoizedState=Zp,s}return a=t.child,t=a.sibling,s=Ii(a,{mode:"visible",children:s.children}),!(e.mode&1)&&(s.lanes=n),s.return=e,s.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=s,e.memoizedState=null,s}function ay(t,e){return e=xf({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Kd(t,e,n,s){return s!==null&&Hx(s),Gl(e,t.child,null,n),t=ay(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function OD(t,e,n,s,r,a,l){if(n)return e.flags&256?(e.flags&=-257,s=wm(Error(ne(422))),Kd(t,e,l,s)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(a=s.fallback,r=e.mode,s=xf({mode:"visible",children:s.children},r,0,null),a=wa(a,r,l,null),a.flags|=2,s.return=e,a.return=e,s.sibling=a,e.child=s,e.mode&1&&Gl(e,t.child,null,l),e.child.memoizedState=Yp(l),e.memoizedState=Zp,a);if(!(e.mode&1))return Kd(t,e,l,null);if(r.data==="$!"){if(s=r.nextSibling&&r.nextSibling.dataset,s)var o=s.dgst;return s=o,a=Error(ne(419)),s=wm(a,s,void 0),Kd(t,e,l,s)}if(o=(l&t.childLanes)!==0,Kn||o){if(s=Xt,s!==null){switch(l&-l){case 4:r=2;break;case 16:r=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:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(s.suspendedLanes|l)?0:r,r!==0&&r!==a.retryLane&&(a.retryLane=r,$r(t,r),Bs(s,t,r,-1))}return hy(),s=wm(Error(ne(421))),Kd(t,e,l,s)}return r.data==="$?"?(e.flags|=128,e.child=t.child,e=QD.bind(null,t),r._reactRetry=e,null):(t=a.treeContext,rs=Di(r.nextSibling),is=e,ft=!0,Is=null,t!==null&&(vs[bs++]=Ar,vs[bs++]=Dr,vs[bs++]=Ia,Ar=t.id,Dr=t.overflow,Ia=e),e=ay(e,s.children),e.flags|=4096,e)}function Ab(t,e,n){t.lanes|=e;var s=t.alternate;s!==null&&(s.lanes|=e),qp(t.return,e,n)}function km(t,e,n,s,r){var a=t.memoizedState;a===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:s,tail:n,tailMode:r}:(a.isBackwards=e,a.rendering=null,a.renderingStartTime=0,a.last=s,a.tail=n,a.tailMode=r)}function Lk(t,e,n){var s=e.pendingProps,r=s.revealOrder,a=s.tail;if(En(t,e,s.children,n),s=xt.current,s&2)s=s&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&&Ab(t,n,e);else if(t.tag===19)Ab(t,n,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}s&=1}if(st(xt,s),!(e.mode&1))e.memoizedState=null;else switch(r){case"forwards":for(n=e.child,r=null;n!==null;)t=n.alternate,t!==null&&Gu(t)===null&&(r=n),n=n.sibling;n=r,n===null?(r=e.child,e.child=null):(r=n.sibling,n.sibling=null),km(e,!1,r,n,a);break;case"backwards":for(n=null,r=e.child,e.child=null;r!==null;){if(t=r.alternate,t!==null&&Gu(t)===null){e.child=r;break}t=r.sibling,r.sibling=n,n=r,r=t}km(e,!0,n,null,a);break;case"together":km(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function yu(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Br(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),Oa|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(ne(153));if(e.child!==null){for(t=e.child,n=Ii(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=Ii(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function LD(t,e,n){switch(e.tag){case 3:Rk(e),Ql();break;case 5:ok(e);break;case 1:Wn(e.type)&&Ku(e);break;case 4:Yx(e,e.stateNode.containerInfo);break;case 10:var s=e.type._context,r=e.memoizedProps.value;st(Hu,s._currentValue),s._currentValue=r;break;case 13:if(s=e.memoizedState,s!==null)return s.dehydrated!==null?(st(xt,xt.current&1),e.flags|=128,null):n&e.child.childLanes?Ok(t,e,n):(st(xt,xt.current&1),t=Br(t,e,n),t!==null?t.sibling:null);st(xt,xt.current&1);break;case 19:if(s=(n&e.childLanes)!==0,t.flags&128){if(s)return Lk(t,e,n);e.flags|=128}if(r=e.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),st(xt,xt.current),s)break;return null;case 22:case 23:return e.lanes=0,Pk(t,e,n)}return Br(t,e,n)}var Fk,Xp,zk,$k;Fk=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Xp=function(){};zk=function(t,e,n,s){var r=t.memoizedProps;if(r!==s){t=e.stateNode,ra(ir.current);var a=null;switch(n){case"input":r=jp(t,r),s=jp(t,s),a=[];break;case"select":r=jt({},r,{value:void 0}),s=jt({},s,{value:void 0}),a=[];break;case"textarea":r=kp(t,r),s=kp(t,s),a=[];break;default:typeof r.onClick!="function"&&typeof s.onClick=="function"&&(t.onclick=_u)}Cp(n,s);var l;n=null;for(d in r)if(!s.hasOwnProperty(d)&&r.hasOwnProperty(d)&&r[d]!=null)if(d==="style"){var o=r[d];for(l in o)o.hasOwnProperty(l)&&(n||(n={}),n[l]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(gc.hasOwnProperty(d)?a||(a=[]):(a=a||[]).push(d,null));for(d in s){var c=s[d];if(o=r!=null?r[d]:void 0,s.hasOwnProperty(d)&&c!==o&&(c!=null||o!=null))if(d==="style")if(o){for(l in o)!o.hasOwnProperty(l)||c&&c.hasOwnProperty(l)||(n||(n={}),n[l]="");for(l in c)c.hasOwnProperty(l)&&o[l]!==c[l]&&(n||(n={}),n[l]=c[l])}else n||(a||(a=[]),a.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,o=o?o.__html:void 0,c!=null&&o!==c&&(a=a||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(a=a||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(gc.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&at("scroll",t),a||o===c||(a=[])):(a=a||[]).push(d,c))}n&&(a=a||[]).push("style",n);var d=a;(e.updateQueue=d)&&(e.flags|=4)}};$k=function(t,e,n,s){n!==s&&(e.flags|=4)};function Mo(t,e){if(!ft)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var s=null;n!==null;)n.alternate!==null&&(s=n),n=n.sibling;s===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:s.sibling=null}}function pn(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,s=0;if(e)for(var r=t.child;r!==null;)n|=r.lanes|r.childLanes,s|=r.subtreeFlags&14680064,s|=r.flags&14680064,r.return=t,r=r.sibling;else for(r=t.child;r!==null;)n|=r.lanes|r.childLanes,s|=r.subtreeFlags,s|=r.flags,r.return=t,r=r.sibling;return t.subtreeFlags|=s,t.childLanes=n,e}function FD(t,e,n){var s=e.pendingProps;switch(qx(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return pn(e),null;case 1:return Wn(e.type)&&Vu(),pn(e),null;case 3:return s=e.stateNode,Jl(),ot(Hn),ot(bn),ey(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(t===null||t.child===null)&&(_d(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Is!==null&&(lg(Is),Is=null))),Xp(t,e),pn(e),null;case 5:Xx(e);var r=ra(Ac.current);if(n=e.type,t!==null&&e.stateNode!=null)zk(t,e,n,s,r),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!s){if(e.stateNode===null)throw Error(ne(166));return pn(e),null}if(t=ra(ir.current),_d(e)){s=e.stateNode,n=e.type;var a=e.memoizedProps;switch(s[nr]=e,s[Cc]=a,t=(e.mode&1)!==0,n){case"dialog":at("cancel",s),at("close",s);break;case"iframe":case"object":case"embed":at("load",s);break;case"video":case"audio":for(r=0;r<Bo.length;r++)at(Bo[r],s);break;case"source":at("error",s);break;case"img":case"image":case"link":at("error",s),at("load",s);break;case"details":at("toggle",s);break;case"input":Fv(s,a),at("invalid",s);break;case"select":s._wrapperState={wasMultiple:!!a.multiple},at("invalid",s);break;case"textarea":$v(s,a),at("invalid",s)}Cp(n,a),r=null;for(var l in a)if(a.hasOwnProperty(l)){var o=a[l];l==="children"?typeof o=="string"?s.textContent!==o&&(a.suppressHydrationWarning!==!0&&Bd(s.textContent,o,t),r=["children",o]):typeof o=="number"&&s.textContent!==""+o&&(a.suppressHydrationWarning!==!0&&Bd(s.textContent,o,t),r=["children",""+o]):gc.hasOwnProperty(l)&&o!=null&&l==="onScroll"&&at("scroll",s)}switch(n){case"input":Pd(s),zv(s,a,!0);break;case"textarea":Pd(s),Bv(s);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(s.onclick=_u)}s=r,e.updateQueue=s,s!==null&&(e.flags|=4)}else{l=r.nodeType===9?r:r.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=fw(n)),t==="http://www.w3.org/1999/xhtml"?n==="script"?(t=l.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof s.is=="string"?t=l.createElement(n,{is:s.is}):(t=l.createElement(n),n==="select"&&(l=t,s.multiple?l.multiple=!0:s.size&&(l.size=s.size))):t=l.createElementNS(t,n),t[nr]=e,t[Cc]=s,Fk(t,e,!1,!1),e.stateNode=t;e:{switch(l=Ep(n,s),n){case"dialog":at("cancel",t),at("close",t),r=s;break;case"iframe":case"object":case"embed":at("load",t),r=s;break;case"video":case"audio":for(r=0;r<Bo.length;r++)at(Bo[r],t);r=s;break;case"source":at("error",t),r=s;break;case"img":case"image":case"link":at("error",t),at("load",t),r=s;break;case"details":at("toggle",t),r=s;break;case"input":Fv(t,s),r=jp(t,s),at("invalid",t);break;case"option":r=s;break;case"select":t._wrapperState={wasMultiple:!!s.multiple},r=jt({},s,{value:void 0}),at("invalid",t);break;case"textarea":$v(t,s),r=kp(t,s),at("invalid",t);break;default:r=s}Cp(n,r),o=r;for(a in o)if(o.hasOwnProperty(a)){var c=o[a];a==="style"?gw(t,c):a==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&mw(t,c)):a==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&xc(t,c):typeof c=="number"&&xc(t,""+c):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(gc.hasOwnProperty(a)?c!=null&&a==="onScroll"&&at("scroll",t):c!=null&&Mx(t,a,c,l))}switch(n){case"input":Pd(t),zv(t,s,!1);break;case"textarea":Pd(t),Bv(t);break;case"option":s.value!=null&&t.setAttribute("value",""+Bi(s.value));break;case"select":t.multiple=!!s.multiple,a=s.value,a!=null?Nl(t,!!s.multiple,a,!1):s.defaultValue!=null&&Nl(t,!!s.multiple,s.defaultValue,!0);break;default:typeof r.onClick=="function"&&(t.onclick=_u)}switch(n){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}}s&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return pn(e),null;case 6:if(t&&e.stateNode!=null)$k(t,e,t.memoizedProps,s);else{if(typeof s!="string"&&e.stateNode===null)throw Error(ne(166));if(n=ra(Ac.current),ra(ir.current),_d(e)){if(s=e.stateNode,n=e.memoizedProps,s[nr]=e,(a=s.nodeValue!==n)&&(t=is,t!==null))switch(t.tag){case 3:Bd(s.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&Bd(s.nodeValue,n,(t.mode&1)!==0)}a&&(e.flags|=4)}else s=(n.nodeType===9?n:n.ownerDocument).createTextNode(s),s[nr]=e,e.stateNode=s}return pn(e),null;case 13:if(ot(xt),s=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(ft&&rs!==null&&e.mode&1&&!(e.flags&128))sk(),Ql(),e.flags|=98560,a=!1;else if(a=_d(e),s!==null&&s.dehydrated!==null){if(t===null){if(!a)throw Error(ne(318));if(a=e.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(ne(317));a[nr]=e}else Ql(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;pn(e),a=!1}else Is!==null&&(lg(Is),Is=null),a=!0;if(!a)return e.flags&65536?e:null}return e.flags&128?(e.lanes=n,e):(s=s!==null,s!==(t!==null&&t.memoizedState!==null)&&s&&(e.child.flags|=8192,e.mode&1&&(t===null||xt.current&1?qt===0&&(qt=3):hy())),e.updateQueue!==null&&(e.flags|=4),pn(e),null);case 4:return Jl(),Xp(t,e),t===null&&kc(e.stateNode.containerInfo),pn(e),null;case 10:return Gx(e.type._context),pn(e),null;case 17:return Wn(e.type)&&Vu(),pn(e),null;case 19:if(ot(xt),a=e.memoizedState,a===null)return pn(e),null;if(s=(e.flags&128)!==0,l=a.rendering,l===null)if(s)Mo(a,!1);else{if(qt!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(l=Gu(t),l!==null){for(e.flags|=128,Mo(a,!1),s=l.updateQueue,s!==null&&(e.updateQueue=s,e.flags|=4),e.subtreeFlags=0,s=n,n=e.child;n!==null;)a=n,t=s,a.flags&=14680066,l=a.alternate,l===null?(a.childLanes=0,a.lanes=t,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=l.childLanes,a.lanes=l.lanes,a.child=l.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=l.memoizedProps,a.memoizedState=l.memoizedState,a.updateQueue=l.updateQueue,a.type=l.type,t=l.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return st(xt,xt.current&1|2),e.child}t=t.sibling}a.tail!==null&&Pt()>Yl&&(e.flags|=128,s=!0,Mo(a,!1),e.lanes=4194304)}else{if(!s)if(t=Gu(l),t!==null){if(e.flags|=128,s=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Mo(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!ft)return pn(e),null}else 2*Pt()-a.renderingStartTime>Yl&&n!==1073741824&&(e.flags|=128,s=!0,Mo(a,!1),e.lanes=4194304);a.isBackwards?(l.sibling=e.child,e.child=l):(n=a.last,n!==null?n.sibling=l:e.child=l,a.last=l)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=Pt(),e.sibling=null,n=xt.current,st(xt,s?n&1|2:n&1),e):(pn(e),null);case 22:case 23:return uy(),s=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==s&&(e.flags|=8192),s&&e.mode&1?es&1073741824&&(pn(e),e.subtreeFlags&6&&(e.flags|=8192)):pn(e),null;case 24:return null;case 25:return null}throw Error(ne(156,e.tag))}function zD(t,e){switch(qx(e),e.tag){case 1:return Wn(e.type)&&Vu(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Jl(),ot(Hn),ot(bn),ey(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Xx(e),null;case 13:if(ot(xt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(ne(340));Ql()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return ot(xt),null;case 4:return Jl(),null;case 10:return Gx(e.type._context),null;case 22:case 23:return uy(),null;case 24:return null;default:return null}}var Ud=!1,yn=!1,$D=typeof WeakSet=="function"?WeakSet:Set,xe=null;function yl(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(s){Et(t,e,s)}else n.current=null}function eg(t,e,n){try{n()}catch(s){Et(t,e,s)}}var Db=!1;function BD(t,e){if(Fp=zu,t=Uw(),Kx(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var s=n.getSelection&&n.getSelection();if(s&&s.rangeCount!==0){n=s.anchorNode;var r=s.anchorOffset,a=s.focusNode;s=s.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,d=0,u=0,h=t,m=null;t:for(;;){for(var f;h!==n||r!==0&&h.nodeType!==3||(o=l+r),h!==a||s!==0&&h.nodeType!==3||(c=l+s),h.nodeType===3&&(l+=h.nodeValue.length),(f=h.firstChild)!==null;)m=h,h=f;for(;;){if(h===t)break t;if(m===n&&++d===r&&(o=l),m===a&&++u===s&&(c=l),(f=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=f}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(zp={focusedElem:t,selectionRange:n},zu=!1,xe=e;xe!==null;)if(e=xe,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,xe=t;else for(;xe!==null;){e=xe;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var g=p.memoizedProps,x=p.memoizedState,y=e.stateNode,v=y.getSnapshotBeforeUpdate(e.elementType===e.type?g:Ds(e.type,g),x);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var b=e.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ne(163))}}catch(j){Et(e,e.return,j)}if(t=e.sibling,t!==null){t.return=e.return,xe=t;break}xe=e.return}return p=Db,Db=!1,p}function ec(t,e,n){var s=e.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var r=s=s.next;do{if((r.tag&t)===t){var a=r.destroy;r.destroy=void 0,a!==void 0&&eg(e,n,a)}r=r.next}while(r!==s)}}function pf(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var s=n.create;n.destroy=s()}n=n.next}while(n!==e)}}function tg(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function Bk(t){var e=t.alternate;e!==null&&(t.alternate=null,Bk(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[nr],delete e[Cc],delete e[_p],delete e[ND],delete e[wD])),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 _k(t){return t.tag===5||t.tag===3||t.tag===4}function Mb(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||_k(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 ng(t,e,n){var s=t.tag;if(s===5||s===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=_u));else if(s!==4&&(t=t.child,t!==null))for(ng(t,e,n),t=t.sibling;t!==null;)ng(t,e,n),t=t.sibling}function sg(t,e,n){var s=t.tag;if(s===5||s===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(s!==4&&(t=t.child,t!==null))for(sg(t,e,n),t=t.sibling;t!==null;)sg(t,e,n),t=t.sibling}var sn=null,Ps=!1;function Qr(t,e,n){for(n=n.child;n!==null;)Vk(t,e,n),n=n.sibling}function Vk(t,e,n){if(rr&&typeof rr.onCommitFiberUnmount=="function")try{rr.onCommitFiberUnmount(lf,n)}catch{}switch(n.tag){case 5:yn||yl(n,e);case 6:var s=sn,r=Ps;sn=null,Qr(t,e,n),sn=s,Ps=r,sn!==null&&(Ps?(t=sn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):sn.removeChild(n.stateNode));break;case 18:sn!==null&&(Ps?(t=sn,n=n.stateNode,t.nodeType===8?xm(t.parentNode,n):t.nodeType===1&&xm(t,n),jc(t)):xm(sn,n.stateNode));break;case 4:s=sn,r=Ps,sn=n.stateNode.containerInfo,Ps=!0,Qr(t,e,n),sn=s,Ps=r;break;case 0:case 11:case 14:case 15:if(!yn&&(s=n.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){r=s=s.next;do{var a=r,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&eg(n,e,l),r=r.next}while(r!==s)}Qr(t,e,n);break;case 1:if(!yn&&(yl(n,e),s=n.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=n.memoizedProps,s.state=n.memoizedState,s.componentWillUnmount()}catch(o){Et(n,e,o)}Qr(t,e,n);break;case 21:Qr(t,e,n);break;case 22:n.mode&1?(yn=(s=yn)||n.memoizedState!==null,Qr(t,e,n),yn=s):Qr(t,e,n);break;default:Qr(t,e,n)}}function Tb(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new $D),e.forEach(function(s){var r=GD.bind(null,t,s);n.has(s)||(n.add(s),s.then(r,r))})}}function As(t,e){var n=e.deletions;if(n!==null)for(var s=0;s<n.length;s++){var r=n[s];try{var a=t,l=e,o=l;e:for(;o!==null;){switch(o.tag){case 5:sn=o.stateNode,Ps=!1;break e;case 3:sn=o.stateNode.containerInfo,Ps=!0;break e;case 4:sn=o.stateNode.containerInfo,Ps=!0;break e}o=o.return}if(sn===null)throw Error(ne(160));Vk(a,l,r),sn=null,Ps=!1;var c=r.alternate;c!==null&&(c.return=null),r.return=null}catch(d){Et(r,e,d)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)Kk(e,t),e=e.sibling}function Kk(t,e){var n=t.alternate,s=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(As(e,t),Hs(t),s&4){try{ec(3,t,t.return),pf(3,t)}catch(g){Et(t,t.return,g)}try{ec(5,t,t.return)}catch(g){Et(t,t.return,g)}}break;case 1:As(e,t),Hs(t),s&512&&n!==null&&yl(n,n.return);break;case 5:if(As(e,t),Hs(t),s&512&&n!==null&&yl(n,n.return),t.flags&32){var r=t.stateNode;try{xc(r,"")}catch(g){Et(t,t.return,g)}}if(s&4&&(r=t.stateNode,r!=null)){var a=t.memoizedProps,l=n!==null?n.memoizedProps:a,o=t.type,c=t.updateQueue;if(t.updateQueue=null,c!==null)try{o==="input"&&a.type==="radio"&&a.name!=null&&uw(r,a),Ep(o,l);var d=Ep(o,a);for(l=0;l<c.length;l+=2){var u=c[l],h=c[l+1];u==="style"?gw(r,h):u==="dangerouslySetInnerHTML"?mw(r,h):u==="children"?xc(r,h):Mx(r,u,h,d)}switch(o){case"input":Np(r,a);break;case"textarea":hw(r,a);break;case"select":var m=r._wrapperState.wasMultiple;r._wrapperState.wasMultiple=!!a.multiple;var f=a.value;f!=null?Nl(r,!!a.multiple,f,!1):m!==!!a.multiple&&(a.defaultValue!=null?Nl(r,!!a.multiple,a.defaultValue,!0):Nl(r,!!a.multiple,a.multiple?[]:"",!1))}r[Cc]=a}catch(g){Et(t,t.return,g)}}break;case 6:if(As(e,t),Hs(t),s&4){if(t.stateNode===null)throw Error(ne(162));r=t.stateNode,a=t.memoizedProps;try{r.nodeValue=a}catch(g){Et(t,t.return,g)}}break;case 3:if(As(e,t),Hs(t),s&4&&n!==null&&n.memoizedState.isDehydrated)try{jc(e.containerInfo)}catch(g){Et(t,t.return,g)}break;case 4:As(e,t),Hs(t);break;case 13:As(e,t),Hs(t),r=t.child,r.flags&8192&&(a=r.memoizedState!==null,r.stateNode.isHidden=a,!a||r.alternate!==null&&r.alternate.memoizedState!==null||(cy=Pt())),s&4&&Tb(t);break;case 22:if(u=n!==null&&n.memoizedState!==null,t.mode&1?(yn=(d=yn)||u,As(e,t),yn=d):As(e,t),Hs(t),s&8192){if(d=t.memoizedState!==null,(t.stateNode.isHidden=d)&&!u&&t.mode&1)for(xe=t,u=t.child;u!==null;){for(h=xe=u;xe!==null;){switch(m=xe,f=m.child,m.tag){case 0:case 11:case 14:case 15:ec(4,m,m.return);break;case 1:yl(m,m.return);var p=m.stateNode;if(typeof p.componentWillUnmount=="function"){s=m,n=m.return;try{e=s,p.props=e.memoizedProps,p.state=e.memoizedState,p.componentWillUnmount()}catch(g){Et(s,n,g)}}break;case 5:yl(m,m.return);break;case 22:if(m.memoizedState!==null){Ib(h);continue}}f!==null?(f.return=m,xe=f):Ib(h)}u=u.sibling}e:for(u=null,h=t;;){if(h.tag===5){if(u===null){u=h;try{r=h.stateNode,d?(a=r.style,typeof a.setProperty=="function"?a.setProperty("display","none","important"):a.display="none"):(o=h.stateNode,c=h.memoizedProps.style,l=c!=null&&c.hasOwnProperty("display")?c.display:null,o.style.display=pw("display",l))}catch(g){Et(t,t.return,g)}}}else if(h.tag===6){if(u===null)try{h.stateNode.nodeValue=d?"":h.memoizedProps}catch(g){Et(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;u===h&&(u=null),h=h.return}u===h&&(u=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:As(e,t),Hs(t),s&4&&Tb(t);break;case 21:break;default:As(e,t),Hs(t)}}function Hs(t){var e=t.flags;if(e&2){try{e:{for(var n=t.return;n!==null;){if(_k(n)){var s=n;break e}n=n.return}throw Error(ne(160))}switch(s.tag){case 5:var r=s.stateNode;s.flags&32&&(xc(r,""),s.flags&=-33);var a=Mb(t);sg(t,a,r);break;case 3:case 4:var l=s.stateNode.containerInfo,o=Mb(t);ng(t,o,l);break;default:throw Error(ne(161))}}catch(c){Et(t,t.return,c)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function _D(t,e,n){xe=t,Uk(t)}function Uk(t,e,n){for(var s=(t.mode&1)!==0;xe!==null;){var r=xe,a=r.child;if(r.tag===22&&s){var l=r.memoizedState!==null||Ud;if(!l){var o=r.alternate,c=o!==null&&o.memoizedState!==null||yn;o=Ud;var d=yn;if(Ud=l,(yn=c)&&!d)for(xe=r;xe!==null;)l=xe,c=l.child,l.tag===22&&l.memoizedState!==null?Rb(r):c!==null?(c.return=l,xe=c):Rb(r);for(;a!==null;)xe=a,Uk(a),a=a.sibling;xe=r,Ud=o,yn=d}Pb(t)}else r.subtreeFlags&8772&&a!==null?(a.return=r,xe=a):Pb(t)}}function Pb(t){for(;xe!==null;){var e=xe;if(e.flags&8772){var n=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:yn||pf(5,e);break;case 1:var s=e.stateNode;if(e.flags&4&&!yn)if(n===null)s.componentDidMount();else{var r=e.elementType===e.type?n.memoizedProps:Ds(e.type,n.memoizedProps);s.componentDidUpdate(r,n.memoizedState,s.__reactInternalSnapshotBeforeUpdate)}var a=e.updateQueue;a!==null&&gb(e,a,s);break;case 3:var l=e.updateQueue;if(l!==null){if(n=null,e.child!==null)switch(e.child.tag){case 5:n=e.child.stateNode;break;case 1:n=e.child.stateNode}gb(e,l,n)}break;case 5:var o=e.stateNode;if(n===null&&e.flags&4){n=o;var c=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var d=e.alternate;if(d!==null){var u=d.memoizedState;if(u!==null){var h=u.dehydrated;h!==null&&jc(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(ne(163))}yn||e.flags&512&&tg(e)}catch(m){Et(e,e.return,m)}}if(e===t){xe=null;break}if(n=e.sibling,n!==null){n.return=e.return,xe=n;break}xe=e.return}}function Ib(t){for(;xe!==null;){var e=xe;if(e===t){xe=null;break}var n=e.sibling;if(n!==null){n.return=e.return,xe=n;break}xe=e.return}}function Rb(t){for(;xe!==null;){var e=xe;try{switch(e.tag){case 0:case 11:case 15:var n=e.return;try{pf(4,e)}catch(c){Et(e,n,c)}break;case 1:var s=e.stateNode;if(typeof s.componentDidMount=="function"){var r=e.return;try{s.componentDidMount()}catch(c){Et(e,r,c)}}var a=e.return;try{tg(e)}catch(c){Et(e,a,c)}break;case 5:var l=e.return;try{tg(e)}catch(c){Et(e,l,c)}}}catch(c){Et(e,e.return,c)}if(e===t){xe=null;break}var o=e.sibling;if(o!==null){o.return=e.return,xe=o;break}xe=e.return}}var VD=Math.ceil,Yu=Kr.ReactCurrentDispatcher,ly=Kr.ReactCurrentOwner,ws=Kr.ReactCurrentBatchConfig,Ve=0,Xt=null,Ft=null,dn=0,es=0,vl=qi(0),qt=0,Pc=null,Oa=0,gf=0,oy=0,tc=null,_n=null,cy=0,Yl=1/0,br=null,Xu=!1,rg=null,Ti=null,qd=!1,ji=null,eh=0,nc=0,ig=null,vu=-1,bu=0;function Dn(){return Ve&6?Pt():vu!==-1?vu:vu=Pt()}function Pi(t){return t.mode&1?Ve&2&&dn!==0?dn&-dn:SD.transition!==null?(bu===0&&(bu=Aw()),bu):(t=Ye,t!==0||(t=window.event,t=t===void 0?16:Ow(t.type)),t):1}function Bs(t,e,n,s){if(50<nc)throw nc=0,ig=null,Error(ne(185));dd(t,n,s),(!(Ve&2)||t!==Xt)&&(t===Xt&&(!(Ve&2)&&(gf|=n),qt===4&&ri(t,dn)),Qn(t,s),n===1&&Ve===0&&!(e.mode&1)&&(Yl=Pt()+500,hf&&Hi()))}function Qn(t,e){var n=t.callbackNode;SA(t,e);var s=Fu(t,t===Xt?dn:0);if(s===0)n!==null&&Kv(n),t.callbackNode=null,t.callbackPriority=0;else if(e=s&-s,t.callbackPriority!==e){if(n!=null&&Kv(n),e===1)t.tag===0?kD(Ob.bind(null,t)):ek(Ob.bind(null,t)),bD(function(){!(Ve&6)&&Hi()}),n=null;else{switch(Dw(s)){case 1:n=Ox;break;case 4:n=Cw;break;case 16:n=Lu;break;case 536870912:n=Ew;break;default:n=Lu}n=Yk(n,qk.bind(null,t))}t.callbackPriority=e,t.callbackNode=n}}function qk(t,e){if(vu=-1,bu=0,Ve&6)throw Error(ne(327));var n=t.callbackNode;if(El()&&t.callbackNode!==n)return null;var s=Fu(t,t===Xt?dn:0);if(s===0)return null;if(s&30||s&t.expiredLanes||e)e=th(t,s);else{e=s;var r=Ve;Ve|=2;var a=Wk();(Xt!==t||dn!==e)&&(br=null,Yl=Pt()+500,Na(t,e));do try{qD();break}catch(o){Hk(t,o)}while(!0);Qx(),Yu.current=a,Ve=r,Ft!==null?e=0:(Xt=null,dn=0,e=qt)}if(e!==0){if(e===2&&(r=Pp(t),r!==0&&(s=r,e=ag(t,r))),e===1)throw n=Pc,Na(t,0),ri(t,s),Qn(t,Pt()),n;if(e===6)ri(t,s);else{if(r=t.current.alternate,!(s&30)&&!KD(r)&&(e=th(t,s),e===2&&(a=Pp(t),a!==0&&(s=a,e=ag(t,a))),e===1))throw n=Pc,Na(t,0),ri(t,s),Qn(t,Pt()),n;switch(t.finishedWork=r,t.finishedLanes=s,e){case 0:case 1:throw Error(ne(345));case 2:ea(t,_n,br);break;case 3:if(ri(t,s),(s&130023424)===s&&(e=cy+500-Pt(),10<e)){if(Fu(t,0)!==0)break;if(r=t.suspendedLanes,(r&s)!==s){Dn(),t.pingedLanes|=t.suspendedLanes&r;break}t.timeoutHandle=Bp(ea.bind(null,t,_n,br),e);break}ea(t,_n,br);break;case 4:if(ri(t,s),(s&4194240)===s)break;for(e=t.eventTimes,r=-1;0<s;){var l=31-$s(s);a=1<<l,l=e[l],l>r&&(r=l),s&=~a}if(s=r,s=Pt()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*VD(s/1960))-s,10<s){t.timeoutHandle=Bp(ea.bind(null,t,_n,br),s);break}ea(t,_n,br);break;case 5:ea(t,_n,br);break;default:throw Error(ne(329))}}}return Qn(t,Pt()),t.callbackNode===n?qk.bind(null,t):null}function ag(t,e){var n=tc;return t.current.memoizedState.isDehydrated&&(Na(t,e).flags|=256),t=th(t,e),t!==2&&(e=_n,_n=n,e!==null&&lg(e)),t}function lg(t){_n===null?_n=t:_n.push.apply(_n,t)}function KD(t){for(var e=t;;){if(e.flags&16384){var n=e.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var s=0;s<n.length;s++){var r=n[s],a=r.getSnapshot;r=r.value;try{if(!Vs(a(),r))return!1}catch{return!1}}}if(n=e.child,e.subtreeFlags&16384&&n!==null)n.return=e,e=n;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 ri(t,e){for(e&=~oy,e&=~gf,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var n=31-$s(e),s=1<<n;t[n]=-1,e&=~s}}function Ob(t){if(Ve&6)throw Error(ne(327));El();var e=Fu(t,0);if(!(e&1))return Qn(t,Pt()),null;var n=th(t,e);if(t.tag!==0&&n===2){var s=Pp(t);s!==0&&(e=s,n=ag(t,s))}if(n===1)throw n=Pc,Na(t,0),ri(t,e),Qn(t,Pt()),n;if(n===6)throw Error(ne(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,ea(t,_n,br),Qn(t,Pt()),null}function dy(t,e){var n=Ve;Ve|=1;try{return t(e)}finally{Ve=n,Ve===0&&(Yl=Pt()+500,hf&&Hi())}}function La(t){ji!==null&&ji.tag===0&&!(Ve&6)&&El();var e=Ve;Ve|=1;var n=ws.transition,s=Ye;try{if(ws.transition=null,Ye=1,t)return t()}finally{Ye=s,ws.transition=n,Ve=e,!(Ve&6)&&Hi()}}function uy(){es=vl.current,ot(vl)}function Na(t,e){t.finishedWork=null,t.finishedLanes=0;var n=t.timeoutHandle;if(n!==-1&&(t.timeoutHandle=-1,vD(n)),Ft!==null)for(n=Ft.return;n!==null;){var s=n;switch(qx(s),s.tag){case 1:s=s.type.childContextTypes,s!=null&&Vu();break;case 3:Jl(),ot(Hn),ot(bn),ey();break;case 5:Xx(s);break;case 4:Jl();break;case 13:ot(xt);break;case 19:ot(xt);break;case 10:Gx(s.type._context);break;case 22:case 23:uy()}n=n.return}if(Xt=t,Ft=t=Ii(t.current,null),dn=es=e,qt=0,Pc=null,oy=gf=Oa=0,_n=tc=null,sa!==null){for(e=0;e<sa.length;e++)if(n=sa[e],s=n.interleaved,s!==null){n.interleaved=null;var r=s.next,a=n.pending;if(a!==null){var l=a.next;a.next=r,s.next=l}n.pending=s}sa=null}return t}function Hk(t,e){do{var n=Ft;try{if(Qx(),gu.current=Zu,Ju){for(var s=vt.memoizedState;s!==null;){var r=s.queue;r!==null&&(r.pending=null),s=s.next}Ju=!1}if(Ra=0,Gt=Kt=vt=null,Xo=!1,Dc=0,ly.current=null,n===null||n.return===null){qt=1,Pc=e,Ft=null;break}e:{var a=t,l=n.return,o=n,c=e;if(e=dn,o.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,u=o,h=u.tag;if(!(u.mode&1)&&(h===0||h===11||h===15)){var m=u.alternate;m?(u.updateQueue=m.updateQueue,u.memoizedState=m.memoizedState,u.lanes=m.lanes):(u.updateQueue=null,u.memoizedState=null)}var f=Nb(l);if(f!==null){f.flags&=-257,wb(f,l,o,a,e),f.mode&1&&jb(a,d,e),e=f,c=d;var p=e.updateQueue;if(p===null){var g=new Set;g.add(c),e.updateQueue=g}else p.add(c);break e}else{if(!(e&1)){jb(a,d,e),hy();break e}c=Error(ne(426))}}else if(ft&&o.mode&1){var x=Nb(l);if(x!==null){!(x.flags&65536)&&(x.flags|=256),wb(x,l,o,a,e),Hx(Zl(c,o));break e}}a=c=Zl(c,o),qt!==4&&(qt=2),tc===null?tc=[a]:tc.push(a),a=l;do{switch(a.tag){case 3:a.flags|=65536,e&=-e,a.lanes|=e;var y=Dk(a,c,e);pb(a,y);break e;case 1:o=c;var v=a.type,b=a.stateNode;if(!(a.flags&128)&&(typeof v.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(Ti===null||!Ti.has(b)))){a.flags|=65536,e&=-e,a.lanes|=e;var j=Mk(a,o,e);pb(a,j);break e}}a=a.return}while(a!==null)}Gk(n)}catch(k){e=k,Ft===n&&n!==null&&(Ft=n=n.return);continue}break}while(!0)}function Wk(){var t=Yu.current;return Yu.current=Zu,t===null?Zu:t}function hy(){(qt===0||qt===3||qt===2)&&(qt=4),Xt===null||!(Oa&268435455)&&!(gf&268435455)||ri(Xt,dn)}function th(t,e){var n=Ve;Ve|=2;var s=Wk();(Xt!==t||dn!==e)&&(br=null,Na(t,e));do try{UD();break}catch(r){Hk(t,r)}while(!0);if(Qx(),Ve=n,Yu.current=s,Ft!==null)throw Error(ne(261));return Xt=null,dn=0,qt}function UD(){for(;Ft!==null;)Qk(Ft)}function qD(){for(;Ft!==null&&!gA();)Qk(Ft)}function Qk(t){var e=Zk(t.alternate,t,es);t.memoizedProps=t.pendingProps,e===null?Gk(t):Ft=e,ly.current=null}function Gk(t){var e=t;do{var n=e.alternate;if(t=e.return,e.flags&32768){if(n=zD(n,e),n!==null){n.flags&=32767,Ft=n;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{qt=6,Ft=null;return}}else if(n=FD(n,e,es),n!==null){Ft=n;return}if(e=e.sibling,e!==null){Ft=e;return}Ft=e=t}while(e!==null);qt===0&&(qt=5)}function ea(t,e,n){var s=Ye,r=ws.transition;try{ws.transition=null,Ye=1,HD(t,e,n,s)}finally{ws.transition=r,Ye=s}return null}function HD(t,e,n,s){do El();while(ji!==null);if(Ve&6)throw Error(ne(327));n=t.finishedWork;var r=t.finishedLanes;if(n===null)return null;if(t.finishedWork=null,t.finishedLanes=0,n===t.current)throw Error(ne(177));t.callbackNode=null,t.callbackPriority=0;var a=n.lanes|n.childLanes;if(CA(t,a),t===Xt&&(Ft=Xt=null,dn=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||qd||(qd=!0,Yk(Lu,function(){return El(),null})),a=(n.flags&15990)!==0,n.subtreeFlags&15990||a){a=ws.transition,ws.transition=null;var l=Ye;Ye=1;var o=Ve;Ve|=4,ly.current=null,BD(t,n),Kk(n,t),hD(zp),zu=!!Fp,zp=Fp=null,t.current=n,_D(n),xA(),Ve=o,Ye=l,ws.transition=a}else t.current=n;if(qd&&(qd=!1,ji=t,eh=r),a=t.pendingLanes,a===0&&(Ti=null),bA(n.stateNode),Qn(t,Pt()),e!==null)for(s=t.onRecoverableError,n=0;n<e.length;n++)r=e[n],s(r.value,{componentStack:r.stack,digest:r.digest});if(Xu)throw Xu=!1,t=rg,rg=null,t;return eh&1&&t.tag!==0&&El(),a=t.pendingLanes,a&1?t===ig?nc++:(nc=0,ig=t):nc=0,Hi(),null}function El(){if(ji!==null){var t=Dw(eh),e=ws.transition,n=Ye;try{if(ws.transition=null,Ye=16>t?16:t,ji===null)var s=!1;else{if(t=ji,ji=null,eh=0,Ve&6)throw Error(ne(331));var r=Ve;for(Ve|=4,xe=t.current;xe!==null;){var a=xe,l=a.child;if(xe.flags&16){var o=a.deletions;if(o!==null){for(var c=0;c<o.length;c++){var d=o[c];for(xe=d;xe!==null;){var u=xe;switch(u.tag){case 0:case 11:case 15:ec(8,u,a)}var h=u.child;if(h!==null)h.return=u,xe=h;else for(;xe!==null;){u=xe;var m=u.sibling,f=u.return;if(Bk(u),u===d){xe=null;break}if(m!==null){m.return=f,xe=m;break}xe=f}}}var p=a.alternate;if(p!==null){var g=p.child;if(g!==null){p.child=null;do{var x=g.sibling;g.sibling=null,g=x}while(g!==null)}}xe=a}}if(a.subtreeFlags&2064&&l!==null)l.return=a,xe=l;else e:for(;xe!==null;){if(a=xe,a.flags&2048)switch(a.tag){case 0:case 11:case 15:ec(9,a,a.return)}var y=a.sibling;if(y!==null){y.return=a.return,xe=y;break e}xe=a.return}}var v=t.current;for(xe=v;xe!==null;){l=xe;var b=l.child;if(l.subtreeFlags&2064&&b!==null)b.return=l,xe=b;else e:for(l=v;xe!==null;){if(o=xe,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:pf(9,o)}}catch(k){Et(o,o.return,k)}if(o===l){xe=null;break e}var j=o.sibling;if(j!==null){j.return=o.return,xe=j;break e}xe=o.return}}if(Ve=r,Hi(),rr&&typeof rr.onPostCommitFiberRoot=="function")try{rr.onPostCommitFiberRoot(lf,t)}catch{}s=!0}return s}finally{Ye=n,ws.transition=e}}return!1}function Lb(t,e,n){e=Zl(n,e),e=Dk(t,e,1),t=Mi(t,e,1),e=Dn(),t!==null&&(dd(t,1,e),Qn(t,e))}function Et(t,e,n){if(t.tag===3)Lb(t,t,n);else for(;e!==null;){if(e.tag===3){Lb(e,t,n);break}else if(e.tag===1){var s=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(Ti===null||!Ti.has(s))){t=Zl(n,t),t=Mk(e,t,1),e=Mi(e,t,1),t=Dn(),e!==null&&(dd(e,1,t),Qn(e,t));break}}e=e.return}}function WD(t,e,n){var s=t.pingCache;s!==null&&s.delete(e),e=Dn(),t.pingedLanes|=t.suspendedLanes&n,Xt===t&&(dn&n)===n&&(qt===4||qt===3&&(dn&130023424)===dn&&500>Pt()-cy?Na(t,0):oy|=n),Qn(t,e)}function Jk(t,e){e===0&&(t.mode&1?(e=Od,Od<<=1,!(Od&130023424)&&(Od=4194304)):e=1);var n=Dn();t=$r(t,e),t!==null&&(dd(t,e,n),Qn(t,n))}function QD(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),Jk(t,n)}function GD(t,e){var n=0;switch(t.tag){case 13:var s=t.stateNode,r=t.memoizedState;r!==null&&(n=r.retryLane);break;case 19:s=t.stateNode;break;default:throw Error(ne(314))}s!==null&&s.delete(e),Jk(t,n)}var Zk;Zk=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Hn.current)Kn=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Kn=!1,LD(t,e,n);Kn=!!(t.flags&131072)}else Kn=!1,ft&&e.flags&1048576&&tk(e,qu,e.index);switch(e.lanes=0,e.tag){case 2:var s=e.type;yu(t,e),t=e.pendingProps;var r=Wl(e,bn.current);Cl(e,n),r=ny(null,e,s,t,r,n);var a=sy();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Wn(s)?(a=!0,Ku(e)):a=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,Zx(e),r.updater=mf,e.stateNode=r,r._reactInternals=e,Wp(e,s,t,n),e=Jp(null,e,s,!0,a,n)):(e.tag=0,ft&&a&&Ux(e),En(null,e,r,n),e=e.child),e;case 16:s=e.elementType;e:{switch(yu(t,e),t=e.pendingProps,r=s._init,s=r(s._payload),e.type=s,r=e.tag=ZD(s),t=Ds(s,t),r){case 0:e=Gp(null,e,s,t,n);break e;case 1:e=Cb(null,e,s,t,n);break e;case 11:e=kb(null,e,s,t,n);break e;case 14:e=Sb(null,e,s,Ds(s.type,t),n);break e}throw Error(ne(306,s,""))}return e;case 0:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ds(s,r),Gp(t,e,s,r,n);case 1:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ds(s,r),Cb(t,e,s,r,n);case 3:e:{if(Rk(e),t===null)throw Error(ne(387));s=e.pendingProps,a=e.memoizedState,r=a.element,lk(t,e),Qu(e,s,null,n);var l=e.memoizedState;if(s=l.element,a.isDehydrated)if(a={element:s,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},e.updateQueue.baseState=a,e.memoizedState=a,e.flags&256){r=Zl(Error(ne(423)),e),e=Eb(t,e,s,n,r);break e}else if(s!==r){r=Zl(Error(ne(424)),e),e=Eb(t,e,s,n,r);break e}else for(rs=Di(e.stateNode.containerInfo.firstChild),is=e,ft=!0,Is=null,n=ik(e,null,s,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ql(),s===r){e=Br(t,e,n);break e}En(t,e,s,n)}e=e.child}return e;case 5:return ok(e),t===null&&Up(e),s=e.type,r=e.pendingProps,a=t!==null?t.memoizedProps:null,l=r.children,$p(s,r)?l=null:a!==null&&$p(s,a)&&(e.flags|=32),Ik(t,e),En(t,e,l,n),e.child;case 6:return t===null&&Up(e),null;case 13:return Ok(t,e,n);case 4:return Yx(e,e.stateNode.containerInfo),s=e.pendingProps,t===null?e.child=Gl(e,null,s,n):En(t,e,s,n),e.child;case 11:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ds(s,r),kb(t,e,s,r,n);case 7:return En(t,e,e.pendingProps,n),e.child;case 8:return En(t,e,e.pendingProps.children,n),e.child;case 12:return En(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(s=e.type._context,r=e.pendingProps,a=e.memoizedProps,l=r.value,st(Hu,s._currentValue),s._currentValue=l,a!==null)if(Vs(a.value,l)){if(a.children===r.children&&!Hn.current){e=Br(t,e,n);break e}}else for(a=e.child,a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var c=o.firstContext;c!==null;){if(c.context===s){if(a.tag===1){c=Ir(-1,n&-n),c.tag=2;var d=a.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),qp(a.return,n,e),o.lanes|=n;break}c=c.next}}else if(a.tag===10)l=a.type===e.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(ne(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),qp(l,n,e),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===e){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}En(t,e,r.children,n),e=e.child}return e;case 9:return r=e.type,s=e.pendingProps.children,Cl(e,n),r=Cs(r),s=s(r),e.flags|=1,En(t,e,s,n),e.child;case 14:return s=e.type,r=Ds(s,e.pendingProps),r=Ds(s.type,r),Sb(t,e,s,r,n);case 15:return Tk(t,e,e.type,e.pendingProps,n);case 17:return s=e.type,r=e.pendingProps,r=e.elementType===s?r:Ds(s,r),yu(t,e),e.tag=1,Wn(s)?(t=!0,Ku(e)):t=!1,Cl(e,n),Ak(e,s,r),Wp(e,s,r,n),Jp(null,e,s,!0,t,n);case 19:return Lk(t,e,n);case 22:return Pk(t,e,n)}throw Error(ne(156,e.tag))};function Yk(t,e){return Sw(t,e)}function JD(t,e,n,s){this.tag=t,this.key=n,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=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ns(t,e,n,s){return new JD(t,e,n,s)}function fy(t){return t=t.prototype,!(!t||!t.isReactComponent)}function ZD(t){if(typeof t=="function")return fy(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Px)return 11;if(t===Ix)return 14}return 2}function Ii(t,e){var n=t.alternate;return n===null?(n=Ns(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function ju(t,e,n,s,r,a){var l=2;if(s=t,typeof t=="function")fy(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case cl:return wa(n.children,r,a,e);case Tx:l=8,r|=8;break;case xp:return t=Ns(12,n,e,r|2),t.elementType=xp,t.lanes=a,t;case yp:return t=Ns(13,n,e,r),t.elementType=yp,t.lanes=a,t;case vp:return t=Ns(19,n,e,r),t.elementType=vp,t.lanes=a,t;case ow:return xf(n,r,a,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case aw:l=10;break e;case lw:l=9;break e;case Px:l=11;break e;case Ix:l=14;break e;case Yr:l=16,s=null;break e}throw Error(ne(130,t==null?t:typeof t,""))}return e=Ns(l,n,e,r),e.elementType=t,e.type=s,e.lanes=a,e}function wa(t,e,n,s){return t=Ns(7,t,s,e),t.lanes=n,t}function xf(t,e,n,s){return t=Ns(22,t,s,e),t.elementType=ow,t.lanes=n,t.stateNode={isHidden:!1},t}function Sm(t,e,n){return t=Ns(6,t,null,e),t.lanes=n,t}function Cm(t,e,n){return e=Ns(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function YD(t,e,n,s,r){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=am(0),this.expirationTimes=am(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=am(0),this.identifierPrefix=s,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function my(t,e,n,s,r,a,l,o,c){return t=new YD(t,e,n,o,c),e===1?(e=1,a===!0&&(e|=8)):e=0,a=Ns(3,null,null,e),t.current=a,a.stateNode=t,a.memoizedState={element:s,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zx(a),t}function XD(t,e,n){var s=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ol,key:s==null?null:""+s,children:t,containerInfo:e,implementation:n}}function Xk(t){if(!t)return _i;t=t._reactInternals;e:{if(Wa(t)!==t||t.tag!==1)throw Error(ne(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(Wn(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(ne(171))}if(t.tag===1){var n=t.type;if(Wn(n))return Xw(t,n,e)}return e}function eS(t,e,n,s,r,a,l,o,c){return t=my(n,s,!0,t,r,a,l,o,c),t.context=Xk(null),n=t.current,s=Dn(),r=Pi(n),a=Ir(s,r),a.callback=e??null,Mi(n,a,r),t.current.lanes=r,dd(t,r,s),Qn(t,s),t}function yf(t,e,n,s){var r=e.current,a=Dn(),l=Pi(r);return n=Xk(n),e.context===null?e.context=n:e.pendingContext=n,e=Ir(a,l),e.payload={element:t},s=s===void 0?null:s,s!==null&&(e.callback=s),t=Mi(r,e,l),t!==null&&(Bs(t,r,l,a),pu(t,r,l)),l}function nh(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 Fb(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<e?n:e}}function py(t,e){Fb(t,e),(t=t.alternate)&&Fb(t,e)}function eM(){return null}var tS=typeof reportError=="function"?reportError:function(t){console.error(t)};function gy(t){this._internalRoot=t}vf.prototype.render=gy.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(ne(409));yf(t,e,null,null)};vf.prototype.unmount=gy.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;La(function(){yf(null,t,null,null)}),e[zr]=null}};function vf(t){this._internalRoot=t}vf.prototype.unstable_scheduleHydration=function(t){if(t){var e=Pw();t={blockedOn:null,target:t,priority:e};for(var n=0;n<si.length&&e!==0&&e<si[n].priority;n++);si.splice(n,0,t),n===0&&Rw(t)}};function xy(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function bf(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function zb(){}function tM(t,e,n,s,r){if(r){if(typeof s=="function"){var a=s;s=function(){var d=nh(l);a.call(d)}}var l=eS(e,s,t,0,null,!1,!1,"",zb);return t._reactRootContainer=l,t[zr]=l.current,kc(t.nodeType===8?t.parentNode:t),La(),l}for(;r=t.lastChild;)t.removeChild(r);if(typeof s=="function"){var o=s;s=function(){var d=nh(c);o.call(d)}}var c=my(t,0,!1,null,null,!1,!1,"",zb);return t._reactRootContainer=c,t[zr]=c.current,kc(t.nodeType===8?t.parentNode:t),La(function(){yf(e,c,n,s)}),c}function jf(t,e,n,s,r){var a=n._reactRootContainer;if(a){var l=a;if(typeof r=="function"){var o=r;r=function(){var c=nh(l);o.call(c)}}yf(e,l,t,r)}else l=tM(n,e,t,r,s);return nh(l)}Mw=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var n=$o(e.pendingLanes);n!==0&&(Lx(e,n|1),Qn(e,Pt()),!(Ve&6)&&(Yl=Pt()+500,Hi()))}break;case 13:La(function(){var s=$r(t,1);if(s!==null){var r=Dn();Bs(s,t,1,r)}}),py(t,1)}};Fx=function(t){if(t.tag===13){var e=$r(t,134217728);if(e!==null){var n=Dn();Bs(e,t,134217728,n)}py(t,134217728)}};Tw=function(t){if(t.tag===13){var e=Pi(t),n=$r(t,e);if(n!==null){var s=Dn();Bs(n,t,e,s)}py(t,e)}};Pw=function(){return Ye};Iw=function(t,e){var n=Ye;try{return Ye=t,e()}finally{Ye=n}};Dp=function(t,e,n){switch(e){case"input":if(Np(t,n),e=n.name,n.type==="radio"&&e!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<n.length;e++){var s=n[e];if(s!==t&&s.form===t.form){var r=uf(s);if(!r)throw Error(ne(90));dw(s),Np(s,r)}}}break;case"textarea":hw(t,n);break;case"select":e=n.value,e!=null&&Nl(t,!!n.multiple,e,!1)}};vw=dy;bw=La;var nM={usingClientEntryPoint:!1,Events:[hd,fl,uf,xw,yw,dy]},To={findFiberByHostInstance:na,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},sM={bundleType:To.bundleType,version:To.version,rendererPackageName:To.rendererPackageName,rendererConfig:To.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Kr.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=ww(t),t===null?null:t.stateNode},findFiberByHostInstance:To.findFiberByHostInstance||eM,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 Hd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hd.isDisabled&&Hd.supportsFiber)try{lf=Hd.inject(sM),rr=Hd}catch{}}ds.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=nM;ds.createPortal=function(t,e){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!xy(e))throw Error(ne(200));return XD(t,e,null,n)};ds.createRoot=function(t,e){if(!xy(t))throw Error(ne(299));var n=!1,s="",r=tS;return e!=null&&(e.unstable_strictMode===!0&&(n=!0),e.identifierPrefix!==void 0&&(s=e.identifierPrefix),e.onRecoverableError!==void 0&&(r=e.onRecoverableError)),e=my(t,1,!1,null,null,n,!1,s,r),t[zr]=e.current,kc(t.nodeType===8?t.parentNode:t),new gy(e)};ds.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(ne(188)):(t=Object.keys(t).join(","),Error(ne(268,t)));return t=ww(e),t=t===null?null:t.stateNode,t};ds.flushSync=function(t){return La(t)};ds.hydrate=function(t,e,n){if(!bf(e))throw Error(ne(200));return jf(null,t,e,!0,n)};ds.hydrateRoot=function(t,e,n){if(!xy(t))throw Error(ne(405));var s=n!=null&&n.hydratedSources||null,r=!1,a="",l=tS;if(n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(a=n.identifierPrefix),n.onRecoverableError!==void 0&&(l=n.onRecoverableError)),e=eS(e,null,t,1,n??null,r,!1,a,l),t[zr]=e.current,kc(t),s)for(t=0;t<s.length;t++)n=s[t],r=n._getVersion,r=r(n._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[n,r]:e.mutableSourceEagerHydrationData.push(n,r);return new vf(e)};ds.render=function(t,e,n){if(!bf(e))throw Error(ne(200));return jf(null,t,e,!1,n)};ds.unmountComponentAtNode=function(t){if(!bf(t))throw Error(ne(40));return t._reactRootContainer?(La(function(){jf(null,null,t,!1,function(){t._reactRootContainer=null,t[zr]=null})}),!0):!1};ds.unstable_batchedUpdates=dy;ds.unstable_renderSubtreeIntoContainer=function(t,e,n,s){if(!bf(n))throw Error(ne(200));if(t==null||t._reactInternals===void 0)throw Error(ne(38));return jf(t,e,n,!1,s)};ds.version="18.3.1-next-f1338f8080-20240426";function nS(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(nS)}catch(t){console.error(t)}}nS(),nw.exports=ds;var sS=nw.exports;const rM=UN(sS);var $b=sS;pp.createRoot=$b.createRoot,pp.hydrateRoot=$b.hydrateRoot;/**
* @remix-run/router v1.23.2
*
* 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 Ic(){return Ic=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Ic.apply(this,arguments)}var Ni;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(Ni||(Ni={}));const Bb="popstate";function iM(t){t===void 0&&(t={});function e(s,r){let{pathname:a,search:l,hash:o}=s.location;return og("",{pathname:a,search:l,hash:o},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(s,r){return typeof r=="string"?r:sh(r)}return lM(e,n,null,t)}function bt(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function yy(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function aM(){return Math.random().toString(36).substr(2,8)}function _b(t,e){return{usr:t.state,key:t.key,idx:e}}function og(t,e,n,s){return n===void 0&&(n=null),Ic({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?mo(e):e,{state:n,key:e&&e.key||s||aM()})}function sh(t){let{pathname:e="/",search:n="",hash:s=""}=t;return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),s&&s!=="#"&&(e+=s.charAt(0)==="#"?s:"#"+s),e}function mo(t){let e={};if(t){let n=t.indexOf("#");n>=0&&(e.hash=t.substr(n),t=t.substr(0,n));let s=t.indexOf("?");s>=0&&(e.search=t.substr(s),t=t.substr(0,s)),t&&(e.pathname=t)}return e}function lM(t,e,n,s){s===void 0&&(s={});let{window:r=document.defaultView,v5Compat:a=!1}=s,l=r.history,o=Ni.Pop,c=null,d=u();d==null&&(d=0,l.replaceState(Ic({},l.state,{idx:d}),""));function u(){return(l.state||{idx:null}).idx}function h(){o=Ni.Pop;let x=u(),y=x==null?null:x-d;d=x,c&&c({action:o,location:g.location,delta:y})}function m(x,y){o=Ni.Push;let v=og(g.location,x,y);d=u()+1;let b=_b(v,d),j=g.createHref(v);try{l.pushState(b,"",j)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;r.location.assign(j)}a&&c&&c({action:o,location:g.location,delta:1})}function f(x,y){o=Ni.Replace;let v=og(g.location,x,y);d=u();let b=_b(v,d),j=g.createHref(v);l.replaceState(b,"",j),a&&c&&c({action:o,location:g.location,delta:0})}function p(x){let y=r.location.origin!=="null"?r.location.origin:r.location.href,v=typeof x=="string"?x:sh(x);return v=v.replace(/ $/,"%20"),bt(y,"No window.location.(origin|href) available to create URL for href: "+v),new URL(v,y)}let g={get action(){return o},get location(){return t(r,l)},listen(x){if(c)throw new Error("A history only accepts one active listener");return r.addEventListener(Bb,h),c=x,()=>{r.removeEventListener(Bb,h),c=null}},createHref(x){return e(r,x)},createURL:p,encodeLocation(x){let y=p(x);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:m,replace:f,go(x){return l.go(x)}};return g}var Vb;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Vb||(Vb={}));function oM(t,e,n){return n===void 0&&(n="/"),cM(t,e,n)}function cM(t,e,n,s){let r=typeof e=="string"?mo(e):e,a=Xl(r.pathname||"/",n);if(a==null)return null;let l=rS(t);dM(l);let o=null;for(let c=0;o==null&&c<l.length;++c){let d=jM(a);o=vM(l[c],d)}return o}function rS(t,e,n,s){e===void 0&&(e=[]),n===void 0&&(n=[]),s===void 0&&(s="");let r=(a,l,o)=>{let c={relativePath:o===void 0?a.path||"":o,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};c.relativePath.startsWith("/")&&(bt(c.relativePath.startsWith(s),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(s.length));let d=Ri([s,c.relativePath]),u=n.concat(c);a.children&&a.children.length>0&&(bt(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),rS(a.children,e,u,d)),!(a.path==null&&!a.index)&&e.push({path:d,score:xM(d,a.index),routesMeta:u})};return t.forEach((a,l)=>{var o;if(a.path===""||!((o=a.path)!=null&&o.includes("?")))r(a,l);else for(let c of iS(a.path))r(a,l,c)}),e}function iS(t){let e=t.split("/");if(e.length===0)return[];let[n,...s]=e,r=n.endsWith("?"),a=n.replace(/\?$/,"");if(s.length===0)return r?[a,""]:[a];let l=iS(s.join("/")),o=[];return o.push(...l.map(c=>c===""?a:[a,c].join("/"))),r&&o.push(...l),o.map(c=>t.startsWith("/")&&c===""?"/":c)}function dM(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:yM(e.routesMeta.map(s=>s.childrenIndex),n.routesMeta.map(s=>s.childrenIndex)))}const uM=/^:[\w-]+$/,hM=3,fM=2,mM=1,pM=10,gM=-2,Kb=t=>t==="*";function xM(t,e){let n=t.split("/"),s=n.length;return n.some(Kb)&&(s+=gM),e&&(s+=fM),n.filter(r=>!Kb(r)).reduce((r,a)=>r+(uM.test(a)?hM:a===""?mM:pM),s)}function yM(t,e){return t.length===e.length&&t.slice(0,-1).every((s,r)=>s===e[r])?t[t.length-1]-e[e.length-1]:0}function vM(t,e,n){let{routesMeta:s}=t,r={},a="/",l=[];for(let o=0;o<s.length;++o){let c=s[o],d=o===s.length-1,u=a==="/"?e:e.slice(a.length)||"/",h=cg({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),m=c.route;if(!h)return null;Object.assign(r,h.params),l.push({params:r,pathname:Ri([a,h.pathname]),pathnameBase:CM(Ri([a,h.pathnameBase])),route:m}),h.pathnameBase!=="/"&&(a=Ri([a,h.pathnameBase]))}return l}function cg(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,s]=bM(t.path,t.caseSensitive,t.end),r=e.match(n);if(!r)return null;let a=r[0],l=a.replace(/(.)\/+$/,"$1"),o=r.slice(1);return{params:s.reduce((d,u,h)=>{let{paramName:m,isOptional:f}=u;if(m==="*"){let g=o[h]||"";l=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const p=o[h];return f&&!p?d[m]=void 0:d[m]=(p||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:l,pattern:t}}function bM(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),yy(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 s=[],r="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(s.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(s.push({paramName:"*"}),r+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":t!==""&&t!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,e?void 0:"i"),s]}function jM(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return yy(!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 Xl(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let n=e.endsWith("/")?e.length-1:e.length,s=t.charAt(n);return s&&s!=="/"?null:t.slice(n)||"/"}const NM=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,wM=t=>NM.test(t);function kM(t,e){e===void 0&&(e="/");let{pathname:n,search:s="",hash:r=""}=typeof t=="string"?mo(t):t,a;if(n)if(wM(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),yy(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?a=Ub(n.substring(1),"/"):a=Ub(n,e)}else a=e;return{pathname:a,search:EM(s),hash:AM(r)}}function Ub(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function Em(t,e,n,s){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(s)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function SM(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function vy(t,e){let n=SM(t);return e?n.map((s,r)=>r===n.length-1?s.pathname:s.pathnameBase):n.map(s=>s.pathnameBase)}function by(t,e,n,s){s===void 0&&(s=!1);let r;typeof t=="string"?r=mo(t):(r=Ic({},t),bt(!r.pathname||!r.pathname.includes("?"),Em("?","pathname","search",r)),bt(!r.pathname||!r.pathname.includes("#"),Em("#","pathname","hash",r)),bt(!r.search||!r.search.includes("#"),Em("#","search","hash",r)));let a=t===""||r.pathname==="",l=a?"/":r.pathname,o;if(l==null)o=n;else{let h=e.length-1;if(!s&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),h-=1;r.pathname=m.join("/")}o=h>=0?e[h]:"/"}let c=kM(r,o),d=l&&l!=="/"&&l.endsWith("/"),u=(a||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}const Ri=t=>t.join("/").replace(/\/\/+/g,"/"),CM=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),EM=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,AM=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function DM(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const aS=["post","put","patch","delete"];new Set(aS);const MM=["get",...aS];new Set(MM);/**
* React Router v6.30.3
*
* 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 Rc(){return Rc=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Rc.apply(this,arguments)}const Nf=N.createContext(null),lS=N.createContext(null),Ur=N.createContext(null),wf=N.createContext(null),dr=N.createContext({outlet:null,matches:[],isDataRoute:!1}),oS=N.createContext(null);function TM(t,e){let{relative:n}=e===void 0?{}:e;po()||bt(!1);let{basename:s,navigator:r}=N.useContext(Ur),{hash:a,pathname:l,search:o}=kf(t,{relative:n}),c=l;return s!=="/"&&(c=l==="/"?s:Ri([s,l])),r.createHref({pathname:c,search:o,hash:a})}function po(){return N.useContext(wf)!=null}function qr(){return po()||bt(!1),N.useContext(wf).location}function cS(t){N.useContext(Ur).static||N.useLayoutEffect(t)}function fn(){let{isDataRoute:t}=N.useContext(dr);return t?HM():PM()}function PM(){po()||bt(!1);let t=N.useContext(Nf),{basename:e,future:n,navigator:s}=N.useContext(Ur),{matches:r}=N.useContext(dr),{pathname:a}=qr(),l=JSON.stringify(vy(r,n.v7_relativeSplatPath)),o=N.useRef(!1);return cS(()=>{o.current=!0}),N.useCallback(function(d,u){if(u===void 0&&(u={}),!o.current)return;if(typeof d=="number"){s.go(d);return}let h=by(d,JSON.parse(l),a,u.relative==="path");t==null&&e!=="/"&&(h.pathname=h.pathname==="/"?e:Ri([e,h.pathname])),(u.replace?s.replace:s.push)(h,u.state,u)},[e,s,l,a,t])}const IM=N.createContext(null);function RM(t){let e=N.useContext(dr).outlet;return e&&N.createElement(IM.Provider,{value:t},e)}function md(){let{matches:t}=N.useContext(dr),e=t[t.length-1];return e?e.params:{}}function kf(t,e){let{relative:n}=e===void 0?{}:e,{future:s}=N.useContext(Ur),{matches:r}=N.useContext(dr),{pathname:a}=qr(),l=JSON.stringify(vy(r,s.v7_relativeSplatPath));return N.useMemo(()=>by(t,JSON.parse(l),a,n==="path"),[t,l,a,n])}function OM(t,e){return LM(t,e)}function LM(t,e,n,s){po()||bt(!1);let{navigator:r}=N.useContext(Ur),{matches:a}=N.useContext(dr),l=a[a.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let d=qr(),u;if(e){var h;let x=typeof e=="string"?mo(e):e;c==="/"||(h=x.pathname)!=null&&h.startsWith(c)||bt(!1),u=x}else u=d;let m=u.pathname||"/",f=m;if(c!=="/"){let x=c.replace(/^\//,"").split("/");f="/"+m.replace(/^\//,"").split("/").slice(x.length).join("/")}let p=oM(t,{pathname:f}),g=_M(p&&p.map(x=>Object.assign({},x,{params:Object.assign({},o,x.params),pathname:Ri([c,r.encodeLocation?r.encodeLocation(x.pathname).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:Ri([c,r.encodeLocation?r.encodeLocation(x.pathnameBase).pathname:x.pathnameBase])})),a,n,s);return e&&g?N.createElement(wf.Provider,{value:{location:Rc({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:Ni.Pop}},g):g}function FM(){let t=qM(),e=DM(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return N.createElement(N.Fragment,null,N.createElement("h2",null,"Unexpected Application Error!"),N.createElement("h3",{style:{fontStyle:"italic"}},e),n?N.createElement("pre",{style:r},n):null,null)}const zM=N.createElement(FM,null);class $M extends N.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,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){console.error("React Router caught the following error during render",e,n)}render(){return this.state.error!==void 0?N.createElement(dr.Provider,{value:this.props.routeContext},N.createElement(oS.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function BM(t){let{routeContext:e,match:n,children:s}=t,r=N.useContext(Nf);return r&&r.static&&r.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=n.route.id),N.createElement(dr.Provider,{value:e},s)}function _M(t,e,n,s){var r;if(e===void 0&&(e=[]),n===void 0&&(n=null),s===void 0&&(s=null),t==null){var a;if(!n)return null;if(n.errors)t=n.matches;else if((a=s)!=null&&a.v7_partialHydration&&e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let l=t,o=(r=n)==null?void 0:r.errors;if(o!=null){let u=l.findIndex(h=>h.route.id&&(o==null?void 0:o[h.route.id])!==void 0);u>=0||bt(!1),l=l.slice(0,Math.min(l.length,u+1))}let c=!1,d=-1;if(n&&s&&s.v7_partialHydration)for(let u=0;u<l.length;u++){let h=l[u];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(d=u),h.route.id){let{loaderData:m,errors:f}=n,p=h.route.loader&&m[h.route.id]===void 0&&(!f||f[h.route.id]===void 0);if(h.route.lazy||p){c=!0,d>=0?l=l.slice(0,d+1):l=[l[0]];break}}}return l.reduceRight((u,h,m)=>{let f,p=!1,g=null,x=null;n&&(f=o&&h.route.id?o[h.route.id]:void 0,g=h.route.errorElement||zM,c&&(d<0&&m===0?(WM("route-fallback"),p=!0,x=null):d===m&&(p=!0,x=h.route.hydrateFallbackElement||null)));let y=e.concat(l.slice(0,m+1)),v=()=>{let b;return f?b=g:p?b=x:h.route.Component?b=N.createElement(h.route.Component,null):h.route.element?b=h.route.element:b=u,N.createElement(BM,{match:h,routeContext:{outlet:u,matches:y,isDataRoute:n!=null},children:b})};return n&&(h.route.ErrorBoundary||h.route.errorElement||m===0)?N.createElement($M,{location:n.location,revalidation:n.revalidation,component:g,error:f,children:v(),routeContext:{outlet:null,matches:y,isDataRoute:!0}}):v()},null)}var dS=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(dS||{}),uS=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}(uS||{});function VM(t){let e=N.useContext(Nf);return e||bt(!1),e}function KM(t){let e=N.useContext(lS);return e||bt(!1),e}function UM(t){let e=N.useContext(dr);return e||bt(!1),e}function hS(t){let e=UM(),n=e.matches[e.matches.length-1];return n.route.id||bt(!1),n.route.id}function qM(){var t;let e=N.useContext(oS),n=KM(),s=hS();return e!==void 0?e:(t=n.errors)==null?void 0:t[s]}function HM(){let{router:t}=VM(dS.UseNavigateStable),e=hS(uS.UseNavigateStable),n=N.useRef(!1);return cS(()=>{n.current=!0}),N.useCallback(function(r,a){a===void 0&&(a={}),n.current&&(typeof r=="number"?t.navigate(r):t.navigate(r,Rc({fromRouteId:e},a)))},[t,e])}const qb={};function WM(t,e,n){qb[t]||(qb[t]=!0)}function QM(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function bl(t){let{to:e,replace:n,state:s,relative:r}=t;po()||bt(!1);let{future:a,static:l}=N.useContext(Ur),{matches:o}=N.useContext(dr),{pathname:c}=qr(),d=fn(),u=by(e,vy(o,a.v7_relativeSplatPath),c,r==="path"),h=JSON.stringify(u);return N.useEffect(()=>d(JSON.parse(h),{replace:n,state:s,relative:r}),[d,h,r,n,s]),null}function GM(t){return RM(t.context)}function $e(t){bt(!1)}function JM(t){let{basename:e="/",children:n=null,location:s,navigationType:r=Ni.Pop,navigator:a,static:l=!1,future:o}=t;po()&&bt(!1);let c=e.replace(/^\/*/,"/"),d=N.useMemo(()=>({basename:c,navigator:a,static:l,future:Rc({v7_relativeSplatPath:!1},o)}),[c,o,a,l]);typeof s=="string"&&(s=mo(s));let{pathname:u="/",search:h="",hash:m="",state:f=null,key:p="default"}=s,g=N.useMemo(()=>{let x=Xl(u,c);return x==null?null:{location:{pathname:x,search:h,hash:m,state:f,key:p},navigationType:r}},[c,u,h,m,f,p,r]);return g==null?null:N.createElement(Ur.Provider,{value:d},N.createElement(wf.Provider,{children:n,value:g}))}function ZM(t){let{children:e,location:n}=t;return OM(dg(e),n)}new Promise(()=>{});function dg(t,e){e===void 0&&(e=[]);let n=[];return N.Children.forEach(t,(s,r)=>{if(!N.isValidElement(s))return;let a=[...e,r];if(s.type===N.Fragment){n.push.apply(n,dg(s.props.children,a));return}s.type!==$e&&bt(!1),!s.props.index||!s.props.children||bt(!1);let l={id:s.props.id||a.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(l.children=dg(s.props.children,a)),n.push(l)}),n}/**
* React Router DOM v6.30.3
*
* 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 rh(){return rh=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},rh.apply(this,arguments)}function fS(t,e){if(t==null)return{};var n={},s=Object.keys(t),r,a;for(a=0;a<s.length;a++)r=s[a],!(e.indexOf(r)>=0)&&(n[r]=t[r]);return n}function YM(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function XM(t,e){return t.button===0&&(!e||e==="_self")&&!YM(t)}function ug(t){return t===void 0&&(t=""),new URLSearchParams(typeof t=="string"||Array.isArray(t)||t instanceof URLSearchParams?t:Object.keys(t).reduce((e,n)=>{let s=t[n];return e.concat(Array.isArray(s)?s.map(r=>[n,r]):[[n,s]])},[]))}function eT(t,e){let n=ug(t);return e&&e.forEach((s,r)=>{n.has(r)||e.getAll(r).forEach(a=>{n.append(r,a)})}),n}const tT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],nT=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],sT="6";try{window.__reactRouterVersion=sT}catch{}const rT=N.createContext({isTransitioning:!1}),iT="startTransition",Hb=W4[iT];function aT(t){let{basename:e,children:n,future:s,window:r}=t,a=N.useRef();a.current==null&&(a.current=iM({window:r,v5Compat:!0}));let l=a.current,[o,c]=N.useState({action:l.action,location:l.location}),{v7_startTransition:d}=s||{},u=N.useCallback(h=>{d&&Hb?Hb(()=>c(h)):c(h)},[c,d]);return N.useLayoutEffect(()=>l.listen(u),[l,u]),N.useEffect(()=>QM(s),[s]),N.createElement(JM,{basename:e,children:n,location:o.location,navigationType:o.action,navigator:l,future:s})}const lT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",oT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Me=N.forwardRef(function(e,n){let{onClick:s,relative:r,reloadDocument:a,replace:l,state:o,target:c,to:d,preventScrollReset:u,viewTransition:h}=e,m=fS(e,tT),{basename:f}=N.useContext(Ur),p,g=!1;if(typeof d=="string"&&oT.test(d)&&(p=d,lT))try{let b=new URL(window.location.href),j=d.startsWith("//")?new URL(b.protocol+d):new URL(d),k=Xl(j.pathname,f);j.origin===b.origin&&k!=null?d=k+j.search+j.hash:g=!0}catch{}let x=TM(d,{relative:r}),y=dT(d,{replace:l,state:o,target:c,preventScrollReset:u,relative:r,viewTransition:h});function v(b){s&&s(b),b.defaultPrevented||y(b)}return N.createElement("a",rh({},m,{href:p||x,onClick:g||a?s:v,ref:n,target:c}))}),Am=N.forwardRef(function(e,n){let{"aria-current":s="page",caseSensitive:r=!1,className:a="",end:l=!1,style:o,to:c,viewTransition:d,children:u}=e,h=fS(e,nT),m=kf(c,{relative:h.relative}),f=qr(),p=N.useContext(lS),{navigator:g,basename:x}=N.useContext(Ur),y=p!=null&&uT(m)&&d===!0,v=g.encodeLocation?g.encodeLocation(m).pathname:m.pathname,b=f.pathname,j=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;r||(b=b.toLowerCase(),j=j?j.toLowerCase():null,v=v.toLowerCase()),j&&x&&(j=Xl(j,x)||j);const k=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let E=b===v||!l&&b.startsWith(v)&&b.charAt(k)==="/",T=j!=null&&(j===v||!l&&j.startsWith(v)&&j.charAt(v.length)==="/"),w={isActive:E,isPending:T,isTransitioning:y},S=E?s:void 0,M;typeof a=="function"?M=a(w):M=[a,E?"active":null,T?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let F=typeof o=="function"?o(w):o;return N.createElement(Me,rh({},h,{"aria-current":S,className:M,ref:n,style:F,to:c,viewTransition:d}),typeof u=="function"?u(w):u)});var hg;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(hg||(hg={}));var Wb;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(Wb||(Wb={}));function cT(t){let e=N.useContext(Nf);return e||bt(!1),e}function dT(t,e){let{target:n,replace:s,state:r,preventScrollReset:a,relative:l,viewTransition:o}=e===void 0?{}:e,c=fn(),d=qr(),u=kf(t,{relative:l});return N.useCallback(h=>{if(XM(h,n)){h.preventDefault();let m=s!==void 0?s:sh(d)===sh(u);c(t,{replace:m,state:r,preventScrollReset:a,relative:l,viewTransition:o})}},[d,c,u,s,r,n,t,a,l,o])}function Sf(t){let e=N.useRef(ug(t)),n=N.useRef(!1),s=qr(),r=N.useMemo(()=>eT(s.search,n.current?null:e.current),[s.search]),a=fn(),l=N.useCallback((o,c)=>{const d=ug(typeof o=="function"?o(r):o);n.current=!0,a("?"+d,c)},[a,r]);return[r,l]}function uT(t,e){e===void 0&&(e={});let n=N.useContext(rT);n==null&&bt(!1);let{basename:s}=cT(hg.useViewTransitionState),r=kf(t,{relative:e.relative});if(!n.isTransitioning)return!1;let a=Xl(n.currentLocation.pathname,s)||n.currentLocation.pathname,l=Xl(n.nextLocation.pathname,s)||n.nextLocation.pathname;return cg(r.pathname,l)!=null||cg(r.pathname,a)!=null}var Qa=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(){}},hT={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},di,wx,PN,fT=(PN=class{constructor(){ge(this,di,hT);ge(this,wx,!1)}setTimeoutProvider(t){re(this,di,t)}setTimeout(t,e){return P(this,di).setTimeout(t,e)}clearTimeout(t){P(this,di).clearTimeout(t)}setInterval(t,e){return P(this,di).setInterval(t,e)}clearInterval(t){P(this,di).clearInterval(t)}},di=new WeakMap,wx=new WeakMap,PN),ia=new fT;function mT(t){setTimeout(t,0)}var Fa=typeof window>"u"||"Deno"in globalThis;function xn(){}function pT(t,e){return typeof t=="function"?t(e):t}function fg(t){return typeof t=="number"&&t>=0&&t!==1/0}function mS(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Oi(t,e){return typeof t=="function"?t(e):t}function xs(t,e){return typeof t=="function"?t(e):t}function Qb(t,e){const{type:n="all",exact:s,fetchStatus:r,predicate:a,queryKey:l,stale:o}=t;if(l){if(s){if(e.queryHash!==jy(l,e.options))return!1}else if(!Oc(e.queryKey,l))return!1}if(n!=="all"){const c=e.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&e.isStale()!==o||r&&r!==e.state.fetchStatus||a&&!a(e))}function Gb(t,e){const{exact:n,status:s,predicate:r,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(za(e.options.mutationKey)!==za(a))return!1}else if(!Oc(e.options.mutationKey,a))return!1}return!(s&&e.state.status!==s||r&&!r(e))}function jy(t,e){return((e==null?void 0:e.queryKeyHashFn)||za)(t)}function za(t){return JSON.stringify(t,(e,n)=>mg(n)?Object.keys(n).sort().reduce((s,r)=>(s[r]=n[r],s),{}):n)}function Oc(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Oc(t[n],e[n])):!1}var gT=Object.prototype.hasOwnProperty;function Ny(t,e,n=0){if(t===e)return t;if(n>500)return e;const s=Jb(t)&&Jb(e);if(!s&&!(mg(t)&&mg(e)))return e;const a=(s?t:Object.keys(t)).length,l=s?e:Object.keys(e),o=l.length,c=s?new Array(o):{};let d=0;for(let u=0;u<o;u++){const h=s?u:l[u],m=t[h],f=e[h];if(m===f){c[h]=m,(s?u<a:gT.call(t,h))&&d++;continue}if(m===null||f===null||typeof m!="object"||typeof f!="object"){c[h]=f;continue}const p=Ny(m,f,n+1);c[h]=p,p===m&&d++}return a===o&&d===a?t:c}function Lc(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const n in t)if(t[n]!==e[n])return!1;return!0}function Jb(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function mg(t){if(!Zb(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Zb(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Zb(t){return Object.prototype.toString.call(t)==="[object Object]"}function xT(t){return new Promise(e=>{ia.setTimeout(e,t)})}function pg(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?Ny(t,e):e}function yT(t,e,n=0){const s=[...t,e];return n&&s.length>n?s.slice(1):s}function vT(t,e,n=0){const s=[e,...t];return n&&s.length>n?s.slice(0,-1):s}var wy=Symbol();function pS(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===wy?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function ky(t,e){return typeof t=="function"?t(...e):!!t}function bT(t,e,n){let s=!1,r;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(r??(r=e()),s||(s=!0,r.aborted?n():r.addEventListener("abort",n,{once:!0})),r)}),t}var fa,ui,Tl,IN,jT=(IN=class extends Qa{constructor(){super();ge(this,fa);ge(this,ui);ge(this,Tl);re(this,Tl,e=>{if(!Fa&&window.addEventListener){const n=()=>e();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){P(this,ui)||this.setEventListener(P(this,Tl))}onUnsubscribe(){var e;this.hasListeners()||((e=P(this,ui))==null||e.call(this),re(this,ui,void 0))}setEventListener(e){var n;re(this,Tl,e),(n=P(this,ui))==null||n.call(this),re(this,ui,e(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(e){P(this,fa)!==e&&(re(this,fa,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(n=>{n(e)})}isFocused(){var e;return typeof P(this,fa)=="boolean"?P(this,fa):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},fa=new WeakMap,ui=new WeakMap,Tl=new WeakMap,IN),Sy=new jT;function gg(){let t,e;const n=new Promise((r,a)=>{t=r,e=a});n.status="pending",n.catch(()=>{});function s(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{s({status:"fulfilled",value:r}),t(r)},n.reject=r=>{s({status:"rejected",reason:r}),e(r)},n}var NT=mT;function wT(){let t=[],e=0,n=o=>{o()},s=o=>{o()},r=NT;const a=o=>{e?t.push(o):r(()=>{n(o)})},l=()=>{const o=t;t=[],o.length&&r(()=>{s(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;e++;try{c=o()}finally{e--,e||l()}return c},batchCalls:o=>(...c)=>{a(()=>{o(...c)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{s=o},setScheduler:o=>{r=o}}}var Mt=wT(),Pl,hi,Il,RN,kT=(RN=class extends Qa{constructor(){super();ge(this,Pl,!0);ge(this,hi);ge(this,Il);re(this,Il,e=>{if(!Fa&&window.addEventListener){const n=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",s)}}})}onSubscribe(){P(this,hi)||this.setEventListener(P(this,Il))}onUnsubscribe(){var e;this.hasListeners()||((e=P(this,hi))==null||e.call(this),re(this,hi,void 0))}setEventListener(e){var n;re(this,Il,e),(n=P(this,hi))==null||n.call(this),re(this,hi,e(this.setOnline.bind(this)))}setOnline(e){P(this,Pl)!==e&&(re(this,Pl,e),this.listeners.forEach(s=>{s(e)}))}isOnline(){return P(this,Pl)}},Pl=new WeakMap,hi=new WeakMap,Il=new WeakMap,RN),ih=new kT;function ST(t){return Math.min(1e3*2**t,3e4)}function gS(t){return(t??"online")==="online"?ih.isOnline():!0}var xg=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function xS(t){let e=!1,n=0,s;const r=gg(),a=()=>r.status!=="pending",l=g=>{var x;if(!a()){const y=new xg(g);m(y),(x=t.onCancel)==null||x.call(t,y)}},o=()=>{e=!0},c=()=>{e=!1},d=()=>Sy.isFocused()&&(t.networkMode==="always"||ih.isOnline())&&t.canRun(),u=()=>gS(t.networkMode)&&t.canRun(),h=g=>{a()||(s==null||s(),r.resolve(g))},m=g=>{a()||(s==null||s(),r.reject(g))},f=()=>new Promise(g=>{var x;s=y=>{(a()||d())&&g(y)},(x=t.onPause)==null||x.call(t)}).then(()=>{var g;s=void 0,a()||(g=t.onContinue)==null||g.call(t)}),p=()=>{if(a())return;let g;const x=n===0?t.initialPromise:void 0;try{g=x??t.fn()}catch(y){g=Promise.reject(y)}Promise.resolve(g).then(h).catch(y=>{var E;if(a())return;const v=t.retry??(Fa?0:3),b=t.retryDelay??ST,j=typeof b=="function"?b(n,y):b,k=v===!0||typeof v=="number"&&n<v||typeof v=="function"&&v(n,y);if(e||!k){m(y);return}n++,(E=t.onFail)==null||E.call(t,n,y),xT(j).then(()=>d()?void 0:f()).then(()=>{e?m(y):p()})})};return{promise:r,status:()=>r.status,cancel:l,continue:()=>(s==null||s(),r),cancelRetry:o,continueRetry:c,canStart:u,start:()=>(u()?p():f().then(p),r)}}var ma,ON,yS=(ON=class{constructor(){ge(this,ma)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),fg(this.gcTime)&&re(this,ma,ia.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Fa?1/0:5*60*1e3))}clearGcTimeout(){P(this,ma)&&(ia.clearTimeout(P(this,ma)),re(this,ma,void 0))}},ma=new WeakMap,ON),pa,Rl,ps,ga,Qt,ed,xa,Ms,yr,LN,CT=(LN=class extends yS{constructor(e){super();ge(this,Ms);ge(this,pa);ge(this,Rl);ge(this,ps);ge(this,ga);ge(this,Qt);ge(this,ed);ge(this,xa);re(this,xa,!1),re(this,ed,e.defaultOptions),this.setOptions(e.options),this.observers=[],re(this,ga,e.client),re(this,ps,P(this,ga).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,re(this,pa,Xb(this.options)),this.state=e.state??P(this,pa),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=P(this,Qt))==null?void 0:e.promise}setOptions(e){if(this.options={...P(this,ed),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Xb(this.options);n.data!==void 0&&(this.setState(Yb(n.data,n.dataUpdatedAt)),re(this,pa,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&P(this,ps).remove(this)}setData(e,n){const s=pg(this.state.data,e,this.options);return Ce(this,Ms,yr).call(this,{data:s,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),s}setState(e,n){Ce(this,Ms,yr).call(this,{type:"setState",state:e,setStateOptions:n})}cancel(e){var s,r;const n=(s=P(this,Qt))==null?void 0:s.promise;return(r=P(this,Qt))==null||r.cancel(e),n?n.then(xn).catch(xn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(P(this,pa))}isActive(){return this.observers.some(e=>xs(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===wy||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Oi(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:!mS(this.state.dataUpdatedAt,e)}onFocus(){var n;const e=this.observers.find(s=>s.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(n=P(this,Qt))==null||n.continue()}onOnline(){var n;const e=this.observers.find(s=>s.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(n=P(this,Qt))==null||n.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),P(this,ps).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(n=>n!==e),this.observers.length||(P(this,Qt)&&(P(this,xa)?P(this,Qt).cancel({revert:!0}):P(this,Qt).cancelRetry()),this.scheduleGc()),P(this,ps).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ce(this,Ms,yr).call(this,{type:"invalidate"})}async fetch(e,n){var c,d,u,h,m,f,p,g,x,y,v,b;if(this.state.fetchStatus!=="idle"&&((c=P(this,Qt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(P(this,Qt))return P(this,Qt).continueRetry(),P(this,Qt).promise}if(e&&this.setOptions(e),!this.options.queryFn){const j=this.observers.find(k=>k.options.queryFn);j&&this.setOptions(j.options)}const s=new AbortController,r=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(re(this,xa,!0),s.signal)})},a=()=>{const j=pS(this.options,n),E=(()=>{const T={client:P(this,ga),queryKey:this.queryKey,meta:this.meta};return r(T),T})();return re(this,xa,!1),this.options.persister?this.options.persister(j,E,this):j(E)},o=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:P(this,ga),state:this.state,fetchFn:a};return r(j),j})();(d=this.options.behavior)==null||d.onFetch(o,this),re(this,Rl,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=o.fetchOptions)==null?void 0:u.meta))&&Ce(this,Ms,yr).call(this,{type:"fetch",meta:(h=o.fetchOptions)==null?void 0:h.meta}),re(this,Qt,xS({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:j=>{j instanceof xg&&j.revert&&this.setState({...P(this,Rl),fetchStatus:"idle"}),s.abort()},onFail:(j,k)=>{Ce(this,Ms,yr).call(this,{type:"failed",failureCount:j,error:k})},onPause:()=>{Ce(this,Ms,yr).call(this,{type:"pause"})},onContinue:()=>{Ce(this,Ms,yr).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const j=await P(this,Qt).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(f=(m=P(this,ps).config).onSuccess)==null||f.call(m,j,this),(g=(p=P(this,ps).config).onSettled)==null||g.call(p,j,this.state.error,this),j}catch(j){if(j instanceof xg){if(j.silent)return P(this,Qt).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw Ce(this,Ms,yr).call(this,{type:"error",error:j}),(y=(x=P(this,ps).config).onError)==null||y.call(x,j,this),(b=(v=P(this,ps).config).onSettled)==null||b.call(v,this.state.data,j,this),j}finally{this.scheduleGc()}}},pa=new WeakMap,Rl=new WeakMap,ps=new WeakMap,ga=new WeakMap,Qt=new WeakMap,ed=new WeakMap,xa=new WeakMap,Ms=new WeakSet,yr=function(e){const n=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...vS(s.data,this.options),fetchMeta:e.meta??null};case"success":const r={...s,...Yb(e.data,e.dataUpdatedAt),dataUpdateCount:s.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return re(this,Rl,e.manual?r:void 0),r;case"error":const a=e.error;return{...s,error:a,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=n(this.state),Mt.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),P(this,ps).notify({query:this,type:"updated",action:e})})},LN);function vS(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:gS(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Yb(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Xb(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,s=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var zn,ze,td,kn,ya,Ol,kr,fi,nd,Ll,Fl,va,ba,mi,zl,Qe,_o,yg,vg,bg,jg,Ng,wg,kg,bS,FN,Cy=(FN=class extends Qa{constructor(e,n){super();ge(this,Qe);ge(this,zn);ge(this,ze);ge(this,td);ge(this,kn);ge(this,ya);ge(this,Ol);ge(this,kr);ge(this,fi);ge(this,nd);ge(this,Ll);ge(this,Fl);ge(this,va);ge(this,ba);ge(this,mi);ge(this,zl,new Set);this.options=n,re(this,zn,e),re(this,fi,null),re(this,kr,gg()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(P(this,ze).addObserver(this),e1(P(this,ze),this.options)?Ce(this,Qe,_o).call(this):this.updateResult(),Ce(this,Qe,jg).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Sg(P(this,ze),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Sg(P(this,ze),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ce(this,Qe,Ng).call(this),Ce(this,Qe,wg).call(this),P(this,ze).removeObserver(this)}setOptions(e){const n=this.options,s=P(this,ze);if(this.options=P(this,zn).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof xs(this.options.enabled,P(this,ze))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ce(this,Qe,kg).call(this),P(this,ze).setOptions(this.options),n._defaulted&&!Lc(this.options,n)&&P(this,zn).getQueryCache().notify({type:"observerOptionsUpdated",query:P(this,ze),observer:this});const r=this.hasListeners();r&&t1(P(this,ze),s,this.options,n)&&Ce(this,Qe,_o).call(this),this.updateResult(),r&&(P(this,ze)!==s||xs(this.options.enabled,P(this,ze))!==xs(n.enabled,P(this,ze))||Oi(this.options.staleTime,P(this,ze))!==Oi(n.staleTime,P(this,ze)))&&Ce(this,Qe,yg).call(this);const a=Ce(this,Qe,vg).call(this);r&&(P(this,ze)!==s||xs(this.options.enabled,P(this,ze))!==xs(n.enabled,P(this,ze))||a!==P(this,mi))&&Ce(this,Qe,bg).call(this,a)}getOptimisticResult(e){const n=P(this,zn).getQueryCache().build(P(this,zn),e),s=this.createResult(n,e);return AT(this,s)&&(re(this,kn,s),re(this,Ol,this.options),re(this,ya,P(this,ze).state)),s}getCurrentResult(){return P(this,kn)}trackResult(e,n){return new Proxy(e,{get:(s,r)=>(this.trackProp(r),n==null||n(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&P(this,kr).status==="pending"&&P(this,kr).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,r))})}trackProp(e){P(this,zl).add(e)}getCurrentQuery(){return P(this,ze)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const n=P(this,zn).defaultQueryOptions(e),s=P(this,zn).getQueryCache().build(P(this,zn),n);return s.fetch().then(()=>this.createResult(s,n))}fetch(e){return Ce(this,Qe,_o).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),P(this,kn)))}createResult(e,n){var S;const s=P(this,ze),r=this.options,a=P(this,kn),l=P(this,ya),o=P(this,Ol),d=e!==s?e.state:P(this,td),{state:u}=e;let h={...u},m=!1,f;if(n._optimisticResults){const M=this.hasListeners(),F=!M&&e1(e,n),R=M&&t1(e,s,n,r);(F||R)&&(h={...h,...vS(u.data,e.options)}),n._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:x}=h;f=h.data;let y=!1;if(n.placeholderData!==void 0&&f===void 0&&x==="pending"){let M;a!=null&&a.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(M=a.data,y=!0):M=typeof n.placeholderData=="function"?n.placeholderData((S=P(this,Fl))==null?void 0:S.state.data,P(this,Fl)):n.placeholderData,M!==void 0&&(x="success",f=pg(a==null?void 0:a.data,M,n),m=!0)}if(n.select&&f!==void 0&&!y)if(a&&f===(l==null?void 0:l.data)&&n.select===P(this,nd))f=P(this,Ll);else try{re(this,nd,n.select),f=n.select(f),f=pg(a==null?void 0:a.data,f,n),re(this,Ll,f),re(this,fi,null)}catch(M){re(this,fi,M)}P(this,fi)&&(p=P(this,fi),f=P(this,Ll),g=Date.now(),x="error");const v=h.fetchStatus==="fetching",b=x==="pending",j=x==="error",k=b&&v,E=f!==void 0,w={status:x,fetchStatus:h.fetchStatus,isPending:b,isSuccess:x==="success",isError:j,isInitialLoading:k,isLoading:k,data:f,dataUpdatedAt:h.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>d.dataUpdateCount||h.errorUpdateCount>d.errorUpdateCount,isFetching:v,isRefetching:v&&!b,isLoadingError:j&&!E,isPaused:h.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&E,isStale:Ey(e,n),refetch:this.refetch,promise:P(this,kr),isEnabled:xs(n.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const M=w.data!==void 0,F=w.status==="error"&&!M,R=z=>{F?z.reject(w.error):M&&z.resolve(w.data)},V=()=>{const z=re(this,kr,w.promise=gg());R(z)},D=P(this,kr);switch(D.status){case"pending":e.queryHash===s.queryHash&&R(D);break;case"fulfilled":(F||w.data!==D.value)&&V();break;case"rejected":(!F||w.error!==D.reason)&&V();break}}return w}updateResult(){const e=P(this,kn),n=this.createResult(P(this,ze),this.options);if(re(this,ya,P(this,ze).state),re(this,Ol,this.options),P(this,ya).data!==void 0&&re(this,Fl,P(this,ze)),Lc(n,e))return;re(this,kn,n);const s=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,a=typeof r=="function"?r():r;if(a==="all"||!a&&!P(this,zl).size)return!0;const l=new Set(a??P(this,zl));return this.options.throwOnError&&l.add("error"),Object.keys(P(this,kn)).some(o=>{const c=o;return P(this,kn)[c]!==e[c]&&l.has(c)})};Ce(this,Qe,bS).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ce(this,Qe,jg).call(this)}},zn=new WeakMap,ze=new WeakMap,td=new WeakMap,kn=new WeakMap,ya=new WeakMap,Ol=new WeakMap,kr=new WeakMap,fi=new WeakMap,nd=new WeakMap,Ll=new WeakMap,Fl=new WeakMap,va=new WeakMap,ba=new WeakMap,mi=new WeakMap,zl=new WeakMap,Qe=new WeakSet,_o=function(e){Ce(this,Qe,kg).call(this);let n=P(this,ze).fetch(this.options,e);return e!=null&&e.throwOnError||(n=n.catch(xn)),n},yg=function(){Ce(this,Qe,Ng).call(this);const e=Oi(this.options.staleTime,P(this,ze));if(Fa||P(this,kn).isStale||!fg(e))return;const s=mS(P(this,kn).dataUpdatedAt,e)+1;re(this,va,ia.setTimeout(()=>{P(this,kn).isStale||this.updateResult()},s))},vg=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(P(this,ze)):this.options.refetchInterval)??!1},bg=function(e){Ce(this,Qe,wg).call(this),re(this,mi,e),!(Fa||xs(this.options.enabled,P(this,ze))===!1||!fg(P(this,mi))||P(this,mi)===0)&&re(this,ba,ia.setInterval(()=>{(this.options.refetchIntervalInBackground||Sy.isFocused())&&Ce(this,Qe,_o).call(this)},P(this,mi)))},jg=function(){Ce(this,Qe,yg).call(this),Ce(this,Qe,bg).call(this,Ce(this,Qe,vg).call(this))},Ng=function(){P(this,va)&&(ia.clearTimeout(P(this,va)),re(this,va,void 0))},wg=function(){P(this,ba)&&(ia.clearInterval(P(this,ba)),re(this,ba,void 0))},kg=function(){const e=P(this,zn).getQueryCache().build(P(this,zn),this.options);if(e===P(this,ze))return;const n=P(this,ze);re(this,ze,e),re(this,td,e.state),this.hasListeners()&&(n==null||n.removeObserver(this),e.addObserver(this))},bS=function(e){Mt.batch(()=>{e.listeners&&this.listeners.forEach(n=>{n(P(this,kn))}),P(this,zn).getQueryCache().notify({query:P(this,ze),type:"observerResultsUpdated"})})},FN);function ET(t,e){return xs(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function e1(t,e){return ET(t,e)||t.state.data!==void 0&&Sg(t,e,e.refetchOnMount)}function Sg(t,e,n){if(xs(e.enabled,t)!==!1&&Oi(e.staleTime,t)!=="static"){const s=typeof n=="function"?n(t):n;return s==="always"||s!==!1&&Ey(t,e)}return!1}function t1(t,e,n,s){return(t!==e||xs(s.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&Ey(t,n)}function Ey(t,e){return xs(e.enabled,t)!==!1&&t.isStaleByTime(Oi(e.staleTime,t))}function AT(t,e){return!Lc(t.getCurrentResult(),e)}function n1(t){return{onFetch:(e,n)=>{var u,h,m,f,p;const s=e.options,r=(m=(h=(u=e.fetchOptions)==null?void 0:u.meta)==null?void 0:h.fetchMore)==null?void 0:m.direction,a=((f=e.state.data)==null?void 0:f.pages)||[],l=((p=e.state.data)==null?void 0:p.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const d=async()=>{let g=!1;const x=b=>{bT(b,()=>e.signal,()=>g=!0)},y=pS(e.options,e.fetchOptions),v=async(b,j,k)=>{if(g)return Promise.reject();if(j==null&&b.pages.length)return Promise.resolve(b);const T=(()=>{const F={client:e.client,queryKey:e.queryKey,pageParam:j,direction:k?"backward":"forward",meta:e.options.meta};return x(F),F})(),w=await y(T),{maxPages:S}=e.options,M=k?vT:yT;return{pages:M(b.pages,w,S),pageParams:M(b.pageParams,j,S)}};if(r&&a.length){const b=r==="backward",j=b?DT:s1,k={pages:a,pageParams:l},E=j(s,k);o=await v(k,E,b)}else{const b=t??a.length;do{const j=c===0?l[0]??s.initialPageParam:s1(s,o);if(c>0&&j==null)break;o=await v(o,j),c++}while(c<b)}return o};e.options.persister?e.fetchFn=()=>{var g,x;return(x=(g=e.options).persister)==null?void 0:x.call(g,d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n)}:e.fetchFn=d}}}function s1(t,{pages:e,pageParams:n}){const s=e.length-1;return e.length>0?t.getNextPageParam(e[s],e,n[s],n):void 0}function DT(t,{pages:e,pageParams:n}){var s;return e.length>0?(s=t.getPreviousPageParam)==null?void 0:s.call(t,e[0],e,n[0],n):void 0}var sd,Xs,Sn,ja,er,Jr,zN,MT=(zN=class extends yS{constructor(e){super();ge(this,er);ge(this,sd);ge(this,Xs);ge(this,Sn);ge(this,ja);re(this,sd,e.client),this.mutationId=e.mutationId,re(this,Sn,e.mutationCache),re(this,Xs,[]),this.state=e.state||jS(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){P(this,Xs).includes(e)||(P(this,Xs).push(e),this.clearGcTimeout(),P(this,Sn).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){re(this,Xs,P(this,Xs).filter(n=>n!==e)),this.scheduleGc(),P(this,Sn).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){P(this,Xs).length||(this.state.status==="pending"?this.scheduleGc():P(this,Sn).remove(this))}continue(){var e;return((e=P(this,ja))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var l,o,c,d,u,h,m,f,p,g,x,y,v,b,j,k,E,T,w,S;const n=()=>{Ce(this,er,Jr).call(this,{type:"continue"})},s={client:P(this,sd),meta:this.options.meta,mutationKey:this.options.mutationKey};re(this,ja,xS({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(M,F)=>{Ce(this,er,Jr).call(this,{type:"failed",failureCount:M,error:F})},onPause:()=>{Ce(this,er,Jr).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>P(this,Sn).canRun(this)}));const r=this.state.status==="pending",a=!P(this,ja).canStart();try{if(r)n();else{Ce(this,er,Jr).call(this,{type:"pending",variables:e,isPaused:a}),await((o=(l=P(this,Sn).config).onMutate)==null?void 0:o.call(l,e,this,s));const F=await((d=(c=this.options).onMutate)==null?void 0:d.call(c,e,s));F!==this.state.context&&Ce(this,er,Jr).call(this,{type:"pending",context:F,variables:e,isPaused:a})}const M=await P(this,ja).start();return await((h=(u=P(this,Sn).config).onSuccess)==null?void 0:h.call(u,M,e,this.state.context,this,s)),await((f=(m=this.options).onSuccess)==null?void 0:f.call(m,M,e,this.state.context,s)),await((g=(p=P(this,Sn).config).onSettled)==null?void 0:g.call(p,M,null,this.state.variables,this.state.context,this,s)),await((y=(x=this.options).onSettled)==null?void 0:y.call(x,M,null,e,this.state.context,s)),Ce(this,er,Jr).call(this,{type:"success",data:M}),M}catch(M){try{await((b=(v=P(this,Sn).config).onError)==null?void 0:b.call(v,M,e,this.state.context,this,s))}catch(F){Promise.reject(F)}try{await((k=(j=this.options).onError)==null?void 0:k.call(j,M,e,this.state.context,s))}catch(F){Promise.reject(F)}try{await((T=(E=P(this,Sn).config).onSettled)==null?void 0:T.call(E,void 0,M,this.state.variables,this.state.context,this,s))}catch(F){Promise.reject(F)}try{await((S=(w=this.options).onSettled)==null?void 0:S.call(w,void 0,M,e,this.state.context,s))}catch(F){Promise.reject(F)}throw Ce(this,er,Jr).call(this,{type:"error",error:M}),M}finally{P(this,Sn).runNext(this)}}},sd=new WeakMap,Xs=new WeakMap,Sn=new WeakMap,ja=new WeakMap,er=new WeakSet,Jr=function(e){const n=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,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{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Mt.batch(()=>{P(this,Xs).forEach(s=>{s.onMutationUpdate(e)}),P(this,Sn).notify({mutation:this,type:"updated",action:e})})},zN);function jS(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Sr,Ts,rd,$N,TT=($N=class extends Qa{constructor(e={}){super();ge(this,Sr);ge(this,Ts);ge(this,rd);this.config=e,re(this,Sr,new Set),re(this,Ts,new Map),re(this,rd,0)}build(e,n,s){const r=new MT({client:e,mutationCache:this,mutationId:++Dd(this,rd)._,options:e.defaultMutationOptions(n),state:s});return this.add(r),r}add(e){P(this,Sr).add(e);const n=Wd(e);if(typeof n=="string"){const s=P(this,Ts).get(n);s?s.push(e):P(this,Ts).set(n,[e])}this.notify({type:"added",mutation:e})}remove(e){if(P(this,Sr).delete(e)){const n=Wd(e);if(typeof n=="string"){const s=P(this,Ts).get(n);if(s)if(s.length>1){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}else s[0]===e&&P(this,Ts).delete(n)}}this.notify({type:"removed",mutation:e})}canRun(e){const n=Wd(e);if(typeof n=="string"){const s=P(this,Ts).get(n),r=s==null?void 0:s.find(a=>a.state.status==="pending");return!r||r===e}else return!0}runNext(e){var s;const n=Wd(e);if(typeof n=="string"){const r=(s=P(this,Ts).get(n))==null?void 0:s.find(a=>a!==e&&a.state.isPaused);return(r==null?void 0:r.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Mt.batch(()=>{P(this,Sr).forEach(e=>{this.notify({type:"removed",mutation:e})}),P(this,Sr).clear(),P(this,Ts).clear()})}getAll(){return Array.from(P(this,Sr))}find(e){const n={exact:!0,...e};return this.getAll().find(s=>Gb(n,s))}findAll(e={}){return this.getAll().filter(n=>Gb(e,n))}notify(e){Mt.batch(()=>{this.listeners.forEach(n=>{n(e)})})}resumePausedMutations(){const e=this.getAll().filter(n=>n.state.isPaused);return Mt.batch(()=>Promise.all(e.map(n=>n.continue().catch(xn))))}},Sr=new WeakMap,Ts=new WeakMap,rd=new WeakMap,$N);function Wd(t){var e;return(e=t.options.scope)==null?void 0:e.id}var Cr,pi,$n,Er,Lr,Nu,Cg,BN,PT=(BN=class extends Qa{constructor(n,s){super();ge(this,Lr);ge(this,Cr);ge(this,pi);ge(this,$n);ge(this,Er);re(this,Cr,n),this.setOptions(s),this.bindMethods(),Ce(this,Lr,Nu).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var r;const s=this.options;this.options=P(this,Cr).defaultMutationOptions(n),Lc(this.options,s)||P(this,Cr).getMutationCache().notify({type:"observerOptionsUpdated",mutation:P(this,$n),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&za(s.mutationKey)!==za(this.options.mutationKey)?this.reset():((r=P(this,$n))==null?void 0:r.state.status)==="pending"&&P(this,$n).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=P(this,$n))==null||n.removeObserver(this)}onMutationUpdate(n){Ce(this,Lr,Nu).call(this),Ce(this,Lr,Cg).call(this,n)}getCurrentResult(){return P(this,pi)}reset(){var n;(n=P(this,$n))==null||n.removeObserver(this),re(this,$n,void 0),Ce(this,Lr,Nu).call(this),Ce(this,Lr,Cg).call(this)}mutate(n,s){var r;return re(this,Er,s),(r=P(this,$n))==null||r.removeObserver(this),re(this,$n,P(this,Cr).getMutationCache().build(P(this,Cr),this.options)),P(this,$n).addObserver(this),P(this,$n).execute(n)}},Cr=new WeakMap,pi=new WeakMap,$n=new WeakMap,Er=new WeakMap,Lr=new WeakSet,Nu=function(){var s;const n=((s=P(this,$n))==null?void 0:s.state)??jS();re(this,pi,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Cg=function(n){Mt.batch(()=>{var s,r,a,l,o,c,d,u;if(P(this,Er)&&this.hasListeners()){const h=P(this,pi).variables,m=P(this,pi).context,f={client:P(this,Cr),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(r=(s=P(this,Er)).onSuccess)==null||r.call(s,n.data,h,m,f)}catch(p){Promise.reject(p)}try{(l=(a=P(this,Er)).onSettled)==null||l.call(a,n.data,null,h,m,f)}catch(p){Promise.reject(p)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=P(this,Er)).onError)==null||c.call(o,n.error,h,m,f)}catch(p){Promise.reject(p)}try{(u=(d=P(this,Er)).onSettled)==null||u.call(d,void 0,n.error,h,m,f)}catch(p){Promise.reject(p)}}}this.listeners.forEach(h=>{h(P(this,pi))})})},BN);function r1(t,e){const n=new Set(e);return t.filter(s=>!n.has(s))}function IT(t,e,n){const s=t.slice(0);return s[e]=n,s}var $l,Xn,Bl,_l,gs,gi,id,ad,ld,od,hn,Eg,Ag,Dg,Mg,Tg,_N,RT=(_N=class extends Qa{constructor(e,n,s){super();ge(this,hn);ge(this,$l);ge(this,Xn);ge(this,Bl);ge(this,_l);ge(this,gs);ge(this,gi);ge(this,id);ge(this,ad);ge(this,ld);ge(this,od,[]);re(this,$l,e),re(this,_l,s),re(this,Bl,[]),re(this,gs,[]),re(this,Xn,[]),this.setQueries(n)}onSubscribe(){this.listeners.size===1&&P(this,gs).forEach(e=>{e.subscribe(n=>{Ce(this,hn,Mg).call(this,e,n)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,P(this,gs).forEach(e=>{e.destroy()})}setQueries(e,n){re(this,Bl,e),re(this,_l,n),Mt.batch(()=>{const s=P(this,gs),r=Ce(this,hn,Dg).call(this,P(this,Bl));r.forEach(h=>h.observer.setOptions(h.defaultedQueryOptions));const a=r.map(h=>h.observer),l=a.map(h=>h.getCurrentResult()),o=s.length!==a.length,c=a.some((h,m)=>h!==s[m]),d=o||c,u=d?!0:l.some((h,m)=>{const f=P(this,Xn)[m];return!f||!Lc(h,f)});!d&&!u||(d&&(re(this,od,r),re(this,gs,a)),re(this,Xn,l),this.hasListeners()&&(d&&(r1(s,a).forEach(h=>{h.destroy()}),r1(a,s).forEach(h=>{h.subscribe(m=>{Ce(this,hn,Mg).call(this,h,m)})})),Ce(this,hn,Tg).call(this)))})}getCurrentResult(){return P(this,Xn)}getQueries(){return P(this,gs).map(e=>e.getCurrentQuery())}getObservers(){return P(this,gs)}getOptimisticResult(e,n){const s=Ce(this,hn,Dg).call(this,e),r=s.map(l=>l.observer.getOptimisticResult(l.defaultedQueryOptions)),a=s.map(l=>l.defaultedQueryOptions.queryHash);return[r,l=>Ce(this,hn,Ag).call(this,l??r,n,a),()=>Ce(this,hn,Eg).call(this,r,s)]}},$l=new WeakMap,Xn=new WeakMap,Bl=new WeakMap,_l=new WeakMap,gs=new WeakMap,gi=new WeakMap,id=new WeakMap,ad=new WeakMap,ld=new WeakMap,od=new WeakMap,hn=new WeakSet,Eg=function(e,n){return n.map((s,r)=>{const a=e[r];return s.defaultedQueryOptions.notifyOnChangeProps?a:s.observer.trackResult(a,l=>{n.forEach(o=>{o.observer.trackProp(l)})})})},Ag=function(e,n,s){if(n){const r=P(this,ld),a=s!==void 0&&r!==void 0&&(r.length!==s.length||s.some((l,o)=>l!==r[o]));return(!P(this,gi)||P(this,Xn)!==P(this,ad)||a||n!==P(this,id))&&(re(this,id,n),re(this,ad,P(this,Xn)),s!==void 0&&re(this,ld,s),re(this,gi,Ny(P(this,gi),n(e)))),P(this,gi)}return e},Dg=function(e){const n=new Map;P(this,gs).forEach(r=>{const a=r.options.queryHash;if(!a)return;const l=n.get(a);l?l.push(r):n.set(a,[r])});const s=[];return e.forEach(r=>{var c;const a=P(this,$l).defaultQueryOptions(r),o=((c=n.get(a.queryHash))==null?void 0:c.shift())??new Cy(P(this,$l),a);s.push({defaultedQueryOptions:a,observer:o})}),s},Mg=function(e,n){const s=P(this,gs).indexOf(e);s!==-1&&(re(this,Xn,IT(P(this,Xn),s,n)),Ce(this,hn,Tg).call(this))},Tg=function(){var e;if(this.hasListeners()){const n=P(this,gi),s=Ce(this,hn,Eg).call(this,P(this,Xn),P(this,od)),r=Ce(this,hn,Ag).call(this,s,(e=P(this,_l))==null?void 0:e.combine);n!==r&&Mt.batch(()=>{this.listeners.forEach(a=>{a(P(this,Xn))})})}},_N),tr,VN,OT=(VN=class extends Qa{constructor(e={}){super();ge(this,tr);this.config=e,re(this,tr,new Map)}build(e,n,s){const r=n.queryKey,a=n.queryHash??jy(r,n);let l=this.get(a);return l||(l=new CT({client:e,queryKey:r,queryHash:a,options:e.defaultQueryOptions(n),state:s,defaultOptions:e.getQueryDefaults(r)}),this.add(l)),l}add(e){P(this,tr).has(e.queryHash)||(P(this,tr).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const n=P(this,tr).get(e.queryHash);n&&(e.destroy(),n===e&&P(this,tr).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Mt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return P(this,tr).get(e)}getAll(){return[...P(this,tr).values()]}find(e){const n={exact:!0,...e};return this.getAll().find(s=>Qb(n,s))}findAll(e={}){const n=this.getAll();return Object.keys(e).length>0?n.filter(s=>Qb(e,s)):n}notify(e){Mt.batch(()=>{this.listeners.forEach(n=>{n(e)})})}onFocus(){Mt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Mt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},tr=new WeakMap,VN),St,xi,yi,Vl,Kl,vi,Ul,ql,KN,LT=(KN=class{constructor(t={}){ge(this,St);ge(this,xi);ge(this,yi);ge(this,Vl);ge(this,Kl);ge(this,vi);ge(this,Ul);ge(this,ql);re(this,St,t.queryCache||new OT),re(this,xi,t.mutationCache||new TT),re(this,yi,t.defaultOptions||{}),re(this,Vl,new Map),re(this,Kl,new Map),re(this,vi,0)}mount(){Dd(this,vi)._++,P(this,vi)===1&&(re(this,Ul,Sy.subscribe(async t=>{t&&(await this.resumePausedMutations(),P(this,St).onFocus())})),re(this,ql,ih.subscribe(async t=>{t&&(await this.resumePausedMutations(),P(this,St).onOnline())})))}unmount(){var t,e;Dd(this,vi)._--,P(this,vi)===0&&((t=P(this,Ul))==null||t.call(this),re(this,Ul,void 0),(e=P(this,ql))==null||e.call(this),re(this,ql,void 0))}isFetching(t){return P(this,St).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return P(this,xi).findAll({...t,status:"pending"}).length}getQueryData(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=P(this,St).get(e.queryHash))==null?void 0:n.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=P(this,St).build(this,e),s=n.state.data;return s===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(Oi(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(s))}getQueriesData(t){return P(this,St).findAll(t).map(({queryKey:e,state:n})=>{const s=n.data;return[e,s]})}setQueryData(t,e,n){const s=this.defaultQueryOptions({queryKey:t}),r=P(this,St).get(s.queryHash),a=r==null?void 0:r.state.data,l=pT(e,a);if(l!==void 0)return P(this,St).build(this,s).setData(l,{...n,manual:!0})}setQueriesData(t,e,n){return Mt.batch(()=>P(this,St).findAll(t).map(({queryKey:s})=>[s,this.setQueryData(s,e,n)]))}getQueryState(t){var n;const e=this.defaultQueryOptions({queryKey:t});return(n=P(this,St).get(e.queryHash))==null?void 0:n.state}removeQueries(t){const e=P(this,St);Mt.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=P(this,St);return Mt.batch(()=>(n.findAll(t).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},s=Mt.batch(()=>P(this,St).findAll(t).map(r=>r.cancel(n)));return Promise.all(s).then(xn).catch(xn)}invalidateQueries(t,e={}){return Mt.batch(()=>(P(this,St).findAll(t).forEach(n=>{n.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 n={...e,cancelRefetch:e.cancelRefetch??!0},s=Mt.batch(()=>P(this,St).findAll(t).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let a=r.fetch(void 0,n);return n.throwOnError||(a=a.catch(xn)),r.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(s).then(xn)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=P(this,St).build(this,e);return n.isStaleByTime(Oi(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(xn).catch(xn)}fetchInfiniteQuery(t){return t.behavior=n1(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(xn).catch(xn)}ensureInfiniteQueryData(t){return t.behavior=n1(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return ih.isOnline()?P(this,xi).resumePausedMutations():Promise.resolve()}getQueryCache(){return P(this,St)}getMutationCache(){return P(this,xi)}getDefaultOptions(){return P(this,yi)}setDefaultOptions(t){re(this,yi,t)}setQueryDefaults(t,e){P(this,Vl).set(za(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...P(this,Vl).values()],n={};return e.forEach(s=>{Oc(t,s.queryKey)&&Object.assign(n,s.defaultOptions)}),n}setMutationDefaults(t,e){P(this,Kl).set(za(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...P(this,Kl).values()],n={};return e.forEach(s=>{Oc(t,s.mutationKey)&&Object.assign(n,s.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...P(this,yi).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=jy(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===wy&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...P(this,yi).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){P(this,St).clear(),P(this,xi).clear()}},St=new WeakMap,xi=new WeakMap,yi=new WeakMap,Vl=new WeakMap,Kl=new WeakMap,vi=new WeakMap,Ul=new WeakMap,ql=new WeakMap,KN),NS=N.createContext(void 0),ye=t=>{const e=N.useContext(NS);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},FT=({client:t,children:e})=>(N.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),i.jsx(NS.Provider,{value:t,children:e})),wS=N.createContext(!1),kS=()=>N.useContext(wS);wS.Provider;function zT(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var $T=N.createContext(zT()),SS=()=>N.useContext($T),CS=(t,e,n)=>{const s=n!=null&&n.state.error&&typeof t.throwOnError=="function"?ky(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||s)&&(e.isReset()||(t.retryOnMount=!1))},ES=t=>{N.useEffect(()=>{t.clearReset()},[t])},AS=({result:t,errorResetBoundary:e,throwOnError:n,query:s,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&s&&(r&&t.data===void 0||ky(n,[t.error,s])),DS=t=>{if(t.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),s=t.staleTime;t.staleTime=typeof s=="function"?(...r)=>n(s(...r)):n(s),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},MS=(t,e)=>t.isLoading&&t.isFetching&&!e,Pg=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,ah=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function BT({queries:t,...e},n){const s=ye(),r=kS(),a=SS(),l=N.useMemo(()=>t.map(g=>{const x=s.defaultQueryOptions(g);return x._optimisticResults=r?"isRestoring":"optimistic",x}),[t,s,r]);l.forEach(g=>{DS(g);const x=s.getQueryCache().get(g.queryHash);CS(g,a,x)}),ES(a);const[o]=N.useState(()=>new RT(s,l,e)),[c,d,u]=o.getOptimisticResult(l,e.combine),h=!r&&e.subscribed!==!1;N.useSyncExternalStore(N.useCallback(g=>h?o.subscribe(Mt.batchCalls(g)):xn,[o,h]),()=>o.getCurrentResult(),()=>o.getCurrentResult()),N.useEffect(()=>{o.setQueries(l,e)},[l,e,o]);const f=c.some((g,x)=>Pg(l[x],g))?c.flatMap((g,x)=>{const y=l[x];if(y){const v=new Cy(s,y);if(Pg(y,g))return ah(y,v,a);MS(g,r)&&ah(y,v,a)}return[]}):[];if(f.length>0)throw Promise.all(f);const p=c.find((g,x)=>{const y=l[x];return y&&AS({result:g,errorResetBoundary:a,throwOnError:y.throwOnError,query:s.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(p!=null&&p.error)throw p.error;return d(u())}function _T(t,e,n){var m,f,p,g;const s=kS(),r=SS(),a=ye(),l=a.defaultQueryOptions(t);(f=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||f.call(m,l);const o=a.getQueryCache().get(l.queryHash);l._optimisticResults=s?"isRestoring":"optimistic",DS(l),CS(l,r,o),ES(r);const c=!a.getQueryCache().get(l.queryHash),[d]=N.useState(()=>new e(a,l)),u=d.getOptimisticResult(l),h=!s&&t.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(x=>{const y=h?d.subscribe(Mt.batchCalls(x)):xn;return d.updateResult(),y},[d,h]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),N.useEffect(()=>{d.setOptions(l)},[l,d]),Pg(l,u))throw ah(l,d,r);if(AS({result:u,errorResetBoundary:r,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw u.error;if((g=(p=a.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||g.call(p,l,u),l.experimental_prefetchInRender&&!Fa&&MS(u,s)){const x=c?ah(l,d,r):o==null?void 0:o.promise;x==null||x.catch(xn).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?u:d.trackResult(u)}function fe(t,e){return _T(t,Cy)}function G(t,e){const n=ye(),[s]=N.useState(()=>new PT(n,t));N.useEffect(()=>{s.setOptions(t)},[s,t]);const r=N.useSyncExternalStore(N.useCallback(l=>s.subscribe(Mt.batchCalls(l)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),a=N.useCallback((l,o)=>{s.mutate(l,o).catch(xn)},[s]);if(r.error&&ky(s.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:a,mutateAsync:r.mutate}}let VT={data:""},KT=t=>{if(typeof window=="object"){let e=(t?t.querySelector("#_goober"):window._goober)||Object.assign(document.createElement("style"),{innerHTML:" ",id:"_goober"});return e.nonce=window.__nonce__,e.parentNode||(t||document.head).appendChild(e),e.firstChild}return t||VT},UT=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,qT=/\/\*[^]*?\*\/| +/g,i1=/\n+/g,ii=(t,e)=>{let n="",s="",r="";for(let a in t){let l=t[a];a[0]=="@"?a[1]=="i"?n=a+" "+l+";":s+=a[1]=="f"?ii(l,a):a+"{"+ii(l,a[1]=="k"?"":e)+"}":typeof l=="object"?s+=ii(l,e?e.replace(/([^,])+/g,o=>a.replace(/([^,]*:\S+\([^)]*\))|([^,])+/g,c=>/&/.test(c)?c.replace(/&/g,o):o?o+" "+c:c)):a):l!=null&&(a=/^--/.test(a)?a:a.replace(/[A-Z]/g,"-$&").toLowerCase(),r+=ii.p?ii.p(a,l):a+":"+l+";")}return n+(e&&r?e+"{"+r+"}":r)+s},fr={},TS=t=>{if(typeof t=="object"){let e="";for(let n in t)e+=n+TS(t[n]);return e}return t},HT=(t,e,n,s,r)=>{let a=TS(t),l=fr[a]||(fr[a]=(c=>{let d=0,u=11;for(;d<c.length;)u=101*u+c.charCodeAt(d++)>>>0;return"go"+u})(a));if(!fr[l]){let c=a!==t?t:(d=>{let u,h,m=[{}];for(;u=UT.exec(d.replace(qT,""));)u[4]?m.shift():u[3]?(h=u[3].replace(i1," ").trim(),m.unshift(m[0][h]=m[0][h]||{})):m[0][u[1]]=u[2].replace(i1," ").trim();return m[0]})(t);fr[l]=ii(r?{["@keyframes "+l]:c}:c,n?"":"."+l)}let o=n&&fr.g?fr.g:null;return n&&(fr.g=fr[l]),((c,d,u,h)=>{h?d.data=d.data.replace(h,c):d.data.indexOf(c)===-1&&(d.data=u?c+d.data:d.data+c)})(fr[l],e,s,o),l},WT=(t,e,n)=>t.reduce((s,r,a)=>{let l=e[a];if(l&&l.call){let o=l(n),c=o&&o.props&&o.props.className||/^go/.test(o)&&o;l=c?"."+c:o&&typeof o=="object"?o.props?"":ii(o,""):o===!1?"":o}return s+r+(l??"")},"");function Cf(t){let e=this||{},n=t.call?t(e.p):t;return HT(n.unshift?n.raw?WT(n,[].slice.call(arguments,1),e.p):n.reduce((s,r)=>Object.assign(s,r&&r.call?r(e.p):r),{}):n,KT(e.target),e.g,e.o,e.k)}let PS,Ig,Rg;Cf.bind({g:1});let _r=Cf.bind({k:1});function QT(t,e,n,s){ii.p=e,PS=t,Ig=n,Rg=s}function Wi(t,e){let n=this||{};return function(){let s=arguments;function r(a,l){let o=Object.assign({},a),c=o.className||r.className;n.p=Object.assign({theme:Ig&&Ig()},o),n.o=/ *go\d+/.test(c),o.className=Cf.apply(n,s)+(c?" "+c:"");let d=t;return t[0]&&(d=o.as||t,delete o.as),Rg&&d[0]&&Rg(o),PS(d,o)}return r}}var GT=t=>typeof t=="function",lh=(t,e)=>GT(t)?t(e):t,JT=(()=>{let t=0;return()=>(++t).toString()})(),IS=(()=>{let t;return()=>{if(t===void 0&&typeof window<"u"){let e=matchMedia("(prefers-reduced-motion: reduce)");t=!e||e.matches}return t}})(),ZT=20,Ay="default",RS=(t,e)=>{let{toastLimit:n}=t.settings;switch(e.type){case 0:return{...t,toasts:[e.toast,...t.toasts].slice(0,n)};case 1:return{...t,toasts:t.toasts.map(l=>l.id===e.toast.id?{...l,...e.toast}:l)};case 2:let{toast:s}=e;return RS(t,{type:t.toasts.find(l=>l.id===s.id)?1:0,toast:s});case 3:let{toastId:r}=e;return{...t,toasts:t.toasts.map(l=>l.id===r||r===void 0?{...l,dismissed:!0,visible:!1}:l)};case 4:return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(l=>l.id!==e.toastId)};case 5:return{...t,pausedAt:e.time};case 6:let a=e.time-(t.pausedAt||0);return{...t,pausedAt:void 0,toasts:t.toasts.map(l=>({...l,pauseDuration:l.pauseDuration+a}))}}},wu=[],OS={toasts:[],pausedAt:void 0,settings:{toastLimit:ZT}},sr={},LS=(t,e=Ay)=>{sr[e]=RS(sr[e]||OS,t),wu.forEach(([n,s])=>{n===e&&s(sr[e])})},FS=t=>Object.keys(sr).forEach(e=>LS(t,e)),YT=t=>Object.keys(sr).find(e=>sr[e].toasts.some(n=>n.id===t)),Ef=(t=Ay)=>e=>{LS(e,t)},XT={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},eP=(t={},e=Ay)=>{let[n,s]=N.useState(sr[e]||OS),r=N.useRef(sr[e]);N.useEffect(()=>(r.current!==sr[e]&&s(sr[e]),wu.push([e,s]),()=>{let l=wu.findIndex(([o])=>o===e);l>-1&&wu.splice(l,1)}),[e]);let a=n.toasts.map(l=>{var o,c,d;return{...t,...t[l.type],...l,removeDelay:l.removeDelay||((o=t[l.type])==null?void 0:o.removeDelay)||(t==null?void 0:t.removeDelay),duration:l.duration||((c=t[l.type])==null?void 0:c.duration)||(t==null?void 0:t.duration)||XT[l.type],style:{...t.style,...(d=t[l.type])==null?void 0:d.style,...l.style}}});return{...n,toasts:a}},tP=(t,e="blank",n)=>({createdAt:Date.now(),visible:!0,dismissed:!1,type:e,ariaProps:{role:"status","aria-live":"polite"},message:t,pauseDuration:0,...n,id:(n==null?void 0:n.id)||JT()}),pd=t=>(e,n)=>{let s=tP(e,t,n);return Ef(s.toasterId||YT(s.id))({type:2,toast:s}),s.id},Ut=(t,e)=>pd("blank")(t,e);Ut.error=pd("error");Ut.success=pd("success");Ut.loading=pd("loading");Ut.custom=pd("custom");Ut.dismiss=(t,e)=>{let n={type:3,toastId:t};e?Ef(e)(n):FS(n)};Ut.dismissAll=t=>Ut.dismiss(void 0,t);Ut.remove=(t,e)=>{let n={type:4,toastId:t};e?Ef(e)(n):FS(n)};Ut.removeAll=t=>Ut.remove(void 0,t);Ut.promise=(t,e,n)=>{let s=Ut.loading(e.loading,{...n,...n==null?void 0:n.loading});return typeof t=="function"&&(t=t()),t.then(r=>{let a=e.success?lh(e.success,r):void 0;return a?Ut.success(a,{id:s,...n,...n==null?void 0:n.success}):Ut.dismiss(s),r}).catch(r=>{let a=e.error?lh(e.error,r):void 0;a?Ut.error(a,{id:s,...n,...n==null?void 0:n.error}):Ut.dismiss(s)}),t};var nP=1e3,sP=(t,e="default")=>{let{toasts:n,pausedAt:s}=eP(t,e),r=N.useRef(new Map).current,a=N.useCallback((h,m=nP)=>{if(r.has(h))return;let f=setTimeout(()=>{r.delete(h),l({type:4,toastId:h})},m);r.set(h,f)},[]);N.useEffect(()=>{if(s)return;let h=Date.now(),m=n.map(f=>{if(f.duration===1/0)return;let p=(f.duration||0)+f.pauseDuration-(h-f.createdAt);if(p<0){f.visible&&Ut.dismiss(f.id);return}return setTimeout(()=>Ut.dismiss(f.id,e),p)});return()=>{m.forEach(f=>f&&clearTimeout(f))}},[n,s,e]);let l=N.useCallback(Ef(e),[e]),o=N.useCallback(()=>{l({type:5,time:Date.now()})},[l]),c=N.useCallback((h,m)=>{l({type:1,toast:{id:h,height:m}})},[l]),d=N.useCallback(()=>{s&&l({type:6,time:Date.now()})},[s,l]),u=N.useCallback((h,m)=>{let{reverseOrder:f=!1,gutter:p=8,defaultPosition:g}=m||{},x=n.filter(b=>(b.position||g)===(h.position||g)&&b.height),y=x.findIndex(b=>b.id===h.id),v=x.filter((b,j)=>j<y&&b.visible).length;return x.filter(b=>b.visible).slice(...f?[v+1]:[0,v]).reduce((b,j)=>b+(j.height||0)+p,0)},[n]);return N.useEffect(()=>{n.forEach(h=>{if(h.dismissed)a(h.id,h.removeDelay);else{let m=r.get(h.id);m&&(clearTimeout(m),r.delete(h.id))}})},[n,a]),{toasts:n,handlers:{updateHeight:c,startPause:o,endPause:d,calculateOffset:u}}},rP=_r`
from {
transform: scale(0) rotate(45deg);
opacity: 0;
}
to {
transform: scale(1) rotate(45deg);
opacity: 1;
}`,iP=_r`
from {
transform: scale(0);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}`,aP=_r`
from {
transform: scale(0) rotate(90deg);
opacity: 0;
}
to {
transform: scale(1) rotate(90deg);
opacity: 1;
}`,lP=Wi("div")`
width: 20px;
opacity: 0;
height: 20px;
border-radius: 10px;
background: ${t=>t.primary||"#ff4b4b"};
position: relative;
transform: rotate(45deg);
animation: ${rP} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
forwards;
animation-delay: 100ms;
&:after,
&:before {
content: '';
animation: ${iP} 0.15s ease-out forwards;
animation-delay: 150ms;
position: absolute;
border-radius: 3px;
opacity: 0;
background: ${t=>t.secondary||"#fff"};
bottom: 9px;
left: 4px;
height: 2px;
width: 12px;
}
&:before {
animation: ${aP} 0.15s ease-out forwards;
animation-delay: 180ms;
transform: rotate(90deg);
}
`,oP=_r`
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
`,cP=Wi("div")`
width: 12px;
height: 12px;
box-sizing: border-box;
border: 2px solid;
border-radius: 100%;
border-color: ${t=>t.secondary||"#e0e0e0"};
border-right-color: ${t=>t.primary||"#616161"};
animation: ${oP} 1s linear infinite;
`,dP=_r`
from {
transform: scale(0) rotate(45deg);
opacity: 0;
}
to {
transform: scale(1) rotate(45deg);
opacity: 1;
}`,uP=_r`
0% {
height: 0;
width: 0;
opacity: 0;
}
40% {
height: 0;
width: 6px;
opacity: 1;
}
100% {
opacity: 1;
height: 10px;
}`,hP=Wi("div")`
width: 20px;
opacity: 0;
height: 20px;
border-radius: 10px;
background: ${t=>t.primary||"#61d345"};
position: relative;
transform: rotate(45deg);
animation: ${dP} 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275)
forwards;
animation-delay: 100ms;
&:after {
content: '';
box-sizing: border-box;
animation: ${uP} 0.2s ease-out forwards;
opacity: 0;
animation-delay: 200ms;
position: absolute;
border-right: 2px solid;
border-bottom: 2px solid;
border-color: ${t=>t.secondary||"#fff"};
bottom: 6px;
left: 6px;
height: 10px;
width: 6px;
}
`,fP=Wi("div")`
position: absolute;
`,mP=Wi("div")`
position: relative;
display: flex;
justify-content: center;
align-items: center;
min-width: 20px;
min-height: 20px;
`,pP=_r`
from {
transform: scale(0.6);
opacity: 0.4;
}
to {
transform: scale(1);
opacity: 1;
}`,gP=Wi("div")`
position: relative;
transform: scale(0.6);
opacity: 0.4;
min-width: 20px;
animation: ${pP} 0.3s 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275)
forwards;
`,xP=({toast:t})=>{let{icon:e,type:n,iconTheme:s}=t;return e!==void 0?typeof e=="string"?N.createElement(gP,null,e):e:n==="blank"?null:N.createElement(mP,null,N.createElement(cP,{...s}),n!=="loading"&&N.createElement(fP,null,n==="error"?N.createElement(lP,{...s}):N.createElement(hP,{...s})))},yP=t=>`
0% {transform: translate3d(0,${t*-200}%,0) scale(.6); opacity:.5;}
100% {transform: translate3d(0,0,0) scale(1); opacity:1;}
`,vP=t=>`
0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}
100% {transform: translate3d(0,${t*-150}%,-1px) scale(.6); opacity:0;}
`,bP="0%{opacity:0;} 100%{opacity:1;}",jP="0%{opacity:1;} 100%{opacity:0;}",NP=Wi("div")`
display: flex;
align-items: center;
background: #fff;
color: #363636;
line-height: 1.3;
will-change: transform;
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05);
max-width: 350px;
pointer-events: auto;
padding: 8px 10px;
border-radius: 8px;
`,wP=Wi("div")`
display: flex;
justify-content: center;
margin: 4px 10px;
color: inherit;
flex: 1 1 auto;
white-space: pre-line;
`,kP=(t,e)=>{let n=t.includes("top")?1:-1,[s,r]=IS()?[bP,jP]:[yP(n),vP(n)];return{animation:e?`${_r(s)} 0.35s cubic-bezier(.21,1.02,.73,1) forwards`:`${_r(r)} 0.4s forwards cubic-bezier(.06,.71,.55,1)`}},SP=N.memo(({toast:t,position:e,style:n,children:s})=>{let r=t.height?kP(t.position||e||"top-center",t.visible):{opacity:0},a=N.createElement(xP,{toast:t}),l=N.createElement(wP,{...t.ariaProps},lh(t.message,t));return N.createElement(NP,{className:t.className,style:{...r,...n,...t.style}},typeof s=="function"?s({icon:a,message:l}):N.createElement(N.Fragment,null,a,l))});QT(N.createElement);var CP=({id:t,className:e,style:n,onHeightUpdate:s,children:r})=>{let a=N.useCallback(l=>{if(l){let o=()=>{let c=l.getBoundingClientRect().height;s(t,c)};o(),new MutationObserver(o).observe(l,{subtree:!0,childList:!0,characterData:!0})}},[t,s]);return N.createElement("div",{ref:a,className:e,style:n},r)},EP=(t,e)=>{let n=t.includes("top"),s=n?{top:0}:{bottom:0},r=t.includes("center")?{justifyContent:"center"}:t.includes("right")?{justifyContent:"flex-end"}:{};return{left:0,right:0,display:"flex",position:"absolute",transition:IS()?void 0:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:`translateY(${e*(n?1:-1)}px)`,...s,...r}},AP=Cf`
z-index: 9999;
> * {
pointer-events: auto;
}
`,Qd=16,DP=({reverseOrder:t,position:e="top-center",toastOptions:n,gutter:s,children:r,toasterId:a,containerStyle:l,containerClassName:o})=>{let{toasts:c,handlers:d}=sP(n,a);return N.createElement("div",{"data-rht-toaster":a||"",style:{position:"fixed",zIndex:9999,top:Qd,left:Qd,right:Qd,bottom:Qd,pointerEvents:"none",...l},className:o,onMouseEnter:d.startPause,onMouseLeave:d.endPause},c.map(u=>{let h=u.position||e,m=d.calculateOffset(u,{reverseOrder:t,gutter:s,defaultPosition:e}),f=EP(h,m);return N.createElement(CP,{id:u.id,key:u.id,onHeightUpdate:d.updateHeight,className:u.visible?AP:"",style:f},u.type==="custom"?lh(u.message,u):r?r(u):N.createElement(SP,{toast:u,position:h}))}))},Ue=Ut;function zS(t,e){return function(){return t.apply(e,arguments)}}const{toString:MP}=Object.prototype,{getPrototypeOf:Dy}=Object,{iterator:Af,toStringTag:$S}=Symbol,Df=(t=>e=>{const n=MP.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Ks=t=>(t=t.toLowerCase(),e=>Df(e)===t),Mf=t=>e=>typeof e===t,{isArray:go}=Array,eo=Mf("undefined");function gd(t){return t!==null&&!eo(t)&&t.constructor!==null&&!eo(t.constructor)&&Gn(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const BS=Ks("ArrayBuffer");function TP(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&BS(t.buffer),e}const PP=Mf("string"),Gn=Mf("function"),_S=Mf("number"),xd=t=>t!==null&&typeof t=="object",IP=t=>t===!0||t===!1,ku=t=>{if(Df(t)!=="object")return!1;const e=Dy(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!($S in t)&&!(Af in t)},RP=t=>{if(!xd(t)||gd(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},OP=Ks("Date"),LP=Ks("File"),FP=Ks("Blob"),zP=Ks("FileList"),$P=t=>xd(t)&&Gn(t.pipe),BP=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||Gn(t.append)&&((e=Df(t))==="formdata"||e==="object"&&Gn(t.toString)&&t.toString()==="[object FormData]"))},_P=Ks("URLSearchParams"),[VP,KP,UP,qP]=["ReadableStream","Request","Response","Headers"].map(Ks),HP=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function yd(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let s,r;if(typeof t!="object"&&(t=[t]),go(t))for(s=0,r=t.length;s<r;s++)e.call(null,t[s],s,t);else{if(gd(t))return;const a=n?Object.getOwnPropertyNames(t):Object.keys(t),l=a.length;let o;for(s=0;s<l;s++)o=a[s],e.call(null,t[o],o,t)}}function VS(t,e){if(gd(t))return null;e=e.toLowerCase();const n=Object.keys(t);let s=n.length,r;for(;s-- >0;)if(r=n[s],e===r.toLowerCase())return r;return null}const aa=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,KS=t=>!eo(t)&&t!==aa;function Og(){const{caseless:t,skipUndefined:e}=KS(this)&&this||{},n={},s=(r,a)=>{const l=t&&VS(n,a)||a;ku(n[l])&&ku(r)?n[l]=Og(n[l],r):ku(r)?n[l]=Og({},r):go(r)?n[l]=r.slice():(!e||!eo(r))&&(n[l]=r)};for(let r=0,a=arguments.length;r<a;r++)arguments[r]&&yd(arguments[r],s);return n}const WP=(t,e,n,{allOwnKeys:s}={})=>(yd(e,(r,a)=>{n&&Gn(r)?t[a]=zS(r,n):t[a]=r},{allOwnKeys:s}),t),QP=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),GP=(t,e,n,s)=>{t.prototype=Object.create(e.prototype,s),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},JP=(t,e,n,s)=>{let r,a,l;const o={};if(e=e||{},t==null)return e;do{for(r=Object.getOwnPropertyNames(t),a=r.length;a-- >0;)l=r[a],(!s||s(l,t,e))&&!o[l]&&(e[l]=t[l],o[l]=!0);t=n!==!1&&Dy(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},ZP=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const s=t.indexOf(e,n);return s!==-1&&s===n},YP=t=>{if(!t)return null;if(go(t))return t;let e=t.length;if(!_S(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},XP=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&Dy(Uint8Array)),eI=(t,e)=>{const s=(t&&t[Af]).call(t);let r;for(;(r=s.next())&&!r.done;){const a=r.value;e.call(t,a[0],a[1])}},tI=(t,e)=>{let n;const s=[];for(;(n=t.exec(e))!==null;)s.push(n);return s},nI=Ks("HTMLFormElement"),sI=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,s,r){return s.toUpperCase()+r}),a1=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),rI=Ks("RegExp"),US=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),s={};yd(n,(r,a)=>{let l;(l=e(r,a,t))!==!1&&(s[a]=l||r)}),Object.defineProperties(t,s)},iI=t=>{US(t,(e,n)=>{if(Gn(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const s=t[n];if(Gn(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},aI=(t,e)=>{const n={},s=r=>{r.forEach(a=>{n[a]=!0})};return go(t)?s(t):s(String(t).split(e)),n},lI=()=>{},oI=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function cI(t){return!!(t&&Gn(t.append)&&t[$S]==="FormData"&&t[Af])}const dI=t=>{const e=new Array(10),n=(s,r)=>{if(xd(s)){if(e.indexOf(s)>=0)return;if(gd(s))return s;if(!("toJSON"in s)){e[r]=s;const a=go(s)?[]:{};return yd(s,(l,o)=>{const c=n(l,r+1);!eo(c)&&(a[o]=c)}),e[r]=void 0,a}}return s};return n(t,0)},uI=Ks("AsyncFunction"),hI=t=>t&&(xd(t)||Gn(t))&&Gn(t.then)&&Gn(t.catch),qS=((t,e)=>t?setImmediate:e?((n,s)=>(aa.addEventListener("message",({source:r,data:a})=>{r===aa&&a===n&&s.length&&s.shift()()},!1),r=>{s.push(r),aa.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",Gn(aa.postMessage)),fI=typeof queueMicrotask<"u"?queueMicrotask.bind(aa):typeof process<"u"&&process.nextTick||qS,mI=t=>t!=null&&Gn(t[Af]),H={isArray:go,isArrayBuffer:BS,isBuffer:gd,isFormData:BP,isArrayBufferView:TP,isString:PP,isNumber:_S,isBoolean:IP,isObject:xd,isPlainObject:ku,isEmptyObject:RP,isReadableStream:VP,isRequest:KP,isResponse:UP,isHeaders:qP,isUndefined:eo,isDate:OP,isFile:LP,isBlob:FP,isRegExp:rI,isFunction:Gn,isStream:$P,isURLSearchParams:_P,isTypedArray:XP,isFileList:zP,forEach:yd,merge:Og,extend:WP,trim:HP,stripBOM:QP,inherits:GP,toFlatObject:JP,kindOf:Df,kindOfTest:Ks,endsWith:ZP,toArray:YP,forEachEntry:eI,matchAll:tI,isHTMLForm:nI,hasOwnProperty:a1,hasOwnProp:a1,reduceDescriptors:US,freezeMethods:iI,toObjectSet:aI,toCamelCase:sI,noop:lI,toFiniteNumber:oI,findKey:VS,global:aa,isContextDefined:KS,isSpecCompliantForm:cI,toJSONObject:dI,isAsyncFn:uI,isThenable:hI,setImmediate:qS,asap:fI,isIterable:mI};function Te(t,e,n,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),s&&(this.request=s),r&&(this.response=r,this.status=r.status?r.status:null)}H.inherits(Te,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:H.toJSONObject(this.config),code:this.code,status:this.status}}});const HS=Te.prototype,WS={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{WS[t]={value:t}});Object.defineProperties(Te,WS);Object.defineProperty(HS,"isAxiosError",{value:!0});Te.from=(t,e,n,s,r,a)=>{const l=Object.create(HS);H.toFlatObject(t,l,function(u){return u!==Error.prototype},d=>d!=="isAxiosError");const o=t&&t.message?t.message:"Error",c=e==null&&t?t.code:e;return Te.call(l,o,c,n,s,r),t&&l.cause==null&&Object.defineProperty(l,"cause",{value:t,configurable:!0}),l.name=t&&t.name||"Error",a&&Object.assign(l,a),l};const pI=null;function Lg(t){return H.isPlainObject(t)||H.isArray(t)}function QS(t){return H.endsWith(t,"[]")?t.slice(0,-2):t}function l1(t,e,n){return t?t.concat(e).map(function(r,a){return r=QS(r),!n&&a?"["+r+"]":r}).join(n?".":""):e}function gI(t){return H.isArray(t)&&!t.some(Lg)}const xI=H.toFlatObject(H,{},null,function(e){return/^is[A-Z]/.test(e)});function Tf(t,e,n){if(!H.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=H.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,x){return!H.isUndefined(x[g])});const s=n.metaTokens,r=n.visitor||u,a=n.dots,l=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&H.isSpecCompliantForm(e);if(!H.isFunction(r))throw new TypeError("visitor must be a function");function d(p){if(p===null)return"";if(H.isDate(p))return p.toISOString();if(H.isBoolean(p))return p.toString();if(!c&&H.isBlob(p))throw new Te("Blob is not supported. Use a Buffer instead.");return H.isArrayBuffer(p)||H.isTypedArray(p)?c&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function u(p,g,x){let y=p;if(p&&!x&&typeof p=="object"){if(H.endsWith(g,"{}"))g=s?g:g.slice(0,-2),p=JSON.stringify(p);else if(H.isArray(p)&&gI(p)||(H.isFileList(p)||H.endsWith(g,"[]"))&&(y=H.toArray(p)))return g=QS(g),y.forEach(function(b,j){!(H.isUndefined(b)||b===null)&&e.append(l===!0?l1([g],j,a):l===null?g:g+"[]",d(b))}),!1}return Lg(p)?!0:(e.append(l1(x,g,a),d(p)),!1)}const h=[],m=Object.assign(xI,{defaultVisitor:u,convertValue:d,isVisitable:Lg});function f(p,g){if(!H.isUndefined(p)){if(h.indexOf(p)!==-1)throw Error("Circular reference detected in "+g.join("."));h.push(p),H.forEach(p,function(y,v){(!(H.isUndefined(y)||y===null)&&r.call(e,y,H.isString(v)?v.trim():v,g,m))===!0&&f(y,g?g.concat(v):[v])}),h.pop()}}if(!H.isObject(t))throw new TypeError("data must be an object");return f(t),e}function o1(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function My(t,e){this._pairs=[],t&&Tf(t,this,e)}const GS=My.prototype;GS.append=function(e,n){this._pairs.push([e,n])};GS.toString=function(e){const n=e?function(s){return e.call(this,s,o1)}:o1;return this._pairs.map(function(r){return n(r[0])+"="+n(r[1])},"").join("&")};function yI(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function JS(t,e,n){if(!e)return t;const s=n&&n.encode||yI;H.isFunction(n)&&(n={serialize:n});const r=n&&n.serialize;let a;if(r?a=r(e,n):a=H.isURLSearchParams(e)?e.toString():new My(e,n).toString(s),a){const l=t.indexOf("#");l!==-1&&(t=t.slice(0,l)),t+=(t.indexOf("?")===-1?"?":"&")+a}return t}class c1{constructor(){this.handlers=[]}use(e,n,s){return this.handlers.push({fulfilled:e,rejected:n,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){H.forEach(this.handlers,function(s){s!==null&&e(s)})}}const ZS={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},vI=typeof URLSearchParams<"u"?URLSearchParams:My,bI=typeof FormData<"u"?FormData:null,jI=typeof Blob<"u"?Blob:null,NI={isBrowser:!0,classes:{URLSearchParams:vI,FormData:bI,Blob:jI},protocols:["http","https","file","blob","url","data"]},Ty=typeof window<"u"&&typeof document<"u",Fg=typeof navigator=="object"&&navigator||void 0,wI=Ty&&(!Fg||["ReactNative","NativeScript","NS"].indexOf(Fg.product)<0),kI=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",SI=Ty&&window.location.href||"http://localhost",CI=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ty,hasStandardBrowserEnv:wI,hasStandardBrowserWebWorkerEnv:kI,navigator:Fg,origin:SI},Symbol.toStringTag,{value:"Module"})),vn={...CI,...NI};function EI(t,e){return Tf(t,new vn.classes.URLSearchParams,{visitor:function(n,s,r,a){return vn.isNode&&H.isBuffer(n)?(this.append(s,n.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...e})}function AI(t){return H.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function DI(t){const e={},n=Object.keys(t);let s;const r=n.length;let a;for(s=0;s<r;s++)a=n[s],e[a]=t[a];return e}function YS(t){function e(n,s,r,a){let l=n[a++];if(l==="__proto__")return!0;const o=Number.isFinite(+l),c=a>=n.length;return l=!l&&H.isArray(r)?r.length:l,c?(H.hasOwnProp(r,l)?r[l]=[r[l],s]:r[l]=s,!o):((!r[l]||!H.isObject(r[l]))&&(r[l]=[]),e(n,s,r[l],a)&&H.isArray(r[l])&&(r[l]=DI(r[l])),!o)}if(H.isFormData(t)&&H.isFunction(t.entries)){const n={};return H.forEachEntry(t,(s,r)=>{e(AI(s),r,n,0)}),n}return null}function MI(t,e,n){if(H.isString(t))try{return(e||JSON.parse)(t),H.trim(t)}catch(s){if(s.name!=="SyntaxError")throw s}return(n||JSON.stringify)(t)}const vd={transitional:ZS,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const s=n.getContentType()||"",r=s.indexOf("application/json")>-1,a=H.isObject(e);if(a&&H.isHTMLForm(e)&&(e=new FormData(e)),H.isFormData(e))return r?JSON.stringify(YS(e)):e;if(H.isArrayBuffer(e)||H.isBuffer(e)||H.isStream(e)||H.isFile(e)||H.isBlob(e)||H.isReadableStream(e))return e;if(H.isArrayBufferView(e))return e.buffer;if(H.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(a){if(s.indexOf("application/x-www-form-urlencoded")>-1)return EI(e,this.formSerializer).toString();if((o=H.isFileList(e))||s.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Tf(o?{"files[]":e}:e,c&&new c,this.formSerializer)}}return a||r?(n.setContentType("application/json",!1),MI(e)):e}],transformResponse:[function(e){const n=this.transitional||vd.transitional,s=n&&n.forcedJSONParsing,r=this.responseType==="json";if(H.isResponse(e)||H.isReadableStream(e))return e;if(e&&H.isString(e)&&(s&&!this.responseType||r)){const l=!(n&&n.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(o){if(l)throw o.name==="SyntaxError"?Te.from(o,Te.ERR_BAD_RESPONSE,this,null,this.response):o}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:vn.classes.FormData,Blob:vn.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};H.forEach(["delete","get","head","post","put","patch"],t=>{vd.headers[t]={}});const TI=H.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),PI=t=>{const e={};let n,s,r;return t&&t.split(`
`).forEach(function(l){r=l.indexOf(":"),n=l.substring(0,r).trim().toLowerCase(),s=l.substring(r+1).trim(),!(!n||e[n]&&TI[n])&&(n==="set-cookie"?e[n]?e[n].push(s):e[n]=[s]:e[n]=e[n]?e[n]+", "+s:s)}),e},d1=Symbol("internals");function Po(t){return t&&String(t).trim().toLowerCase()}function Su(t){return t===!1||t==null?t:H.isArray(t)?t.map(Su):String(t)}function II(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=n.exec(t);)e[s[1]]=s[2];return e}const RI=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Dm(t,e,n,s,r){if(H.isFunction(s))return s.call(this,e,n);if(r&&(e=n),!!H.isString(e)){if(H.isString(s))return e.indexOf(s)!==-1;if(H.isRegExp(s))return s.test(e)}}function OI(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,s)=>n.toUpperCase()+s)}function LI(t,e){const n=H.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(t,s+n,{value:function(r,a,l){return this[s].call(this,e,r,a,l)},configurable:!0})})}let Jn=class{constructor(e){e&&this.set(e)}set(e,n,s){const r=this;function a(o,c,d){const u=Po(c);if(!u)throw new Error("header name must be a non-empty string");const h=H.findKey(r,u);(!h||r[h]===void 0||d===!0||d===void 0&&r[h]!==!1)&&(r[h||c]=Su(o))}const l=(o,c)=>H.forEach(o,(d,u)=>a(d,u,c));if(H.isPlainObject(e)||e instanceof this.constructor)l(e,n);else if(H.isString(e)&&(e=e.trim())&&!RI(e))l(PI(e),n);else if(H.isObject(e)&&H.isIterable(e)){let o={},c,d;for(const u of e){if(!H.isArray(u))throw TypeError("Object iterator must return a key-value pair");o[d=u[0]]=(c=o[d])?H.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}l(o,n)}else e!=null&&a(n,e,s);return this}get(e,n){if(e=Po(e),e){const s=H.findKey(this,e);if(s){const r=this[s];if(!n)return r;if(n===!0)return II(r);if(H.isFunction(n))return n.call(this,r,s);if(H.isRegExp(n))return n.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=Po(e),e){const s=H.findKey(this,e);return!!(s&&this[s]!==void 0&&(!n||Dm(this,this[s],s,n)))}return!1}delete(e,n){const s=this;let r=!1;function a(l){if(l=Po(l),l){const o=H.findKey(s,l);o&&(!n||Dm(s,s[o],o,n))&&(delete s[o],r=!0)}}return H.isArray(e)?e.forEach(a):a(e),r}clear(e){const n=Object.keys(this);let s=n.length,r=!1;for(;s--;){const a=n[s];(!e||Dm(this,this[a],a,e,!0))&&(delete this[a],r=!0)}return r}normalize(e){const n=this,s={};return H.forEach(this,(r,a)=>{const l=H.findKey(s,a);if(l){n[l]=Su(r),delete n[a];return}const o=e?OI(a):String(a).trim();o!==a&&delete n[a],n[o]=Su(r),s[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return H.forEach(this,(s,r)=>{s!=null&&s!==!1&&(n[r]=e&&H.isArray(s)?s.join(", "):s)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const s=new this(e);return n.forEach(r=>s.set(r)),s}static accessor(e){const s=(this[d1]=this[d1]={accessors:{}}).accessors,r=this.prototype;function a(l){const o=Po(l);s[o]||(LI(r,l),s[o]=!0)}return H.isArray(e)?e.forEach(a):a(e),this}};Jn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);H.reduceDescriptors(Jn.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(s){this[n]=s}}});H.freezeMethods(Jn);function Mm(t,e){const n=this||vd,s=e||n,r=Jn.from(s.headers);let a=s.data;return H.forEach(t,function(o){a=o.call(n,a,r.normalize(),e?e.status:void 0)}),r.normalize(),a}function XS(t){return!!(t&&t.__CANCEL__)}function xo(t,e,n){Te.call(this,t??"canceled",Te.ERR_CANCELED,e,n),this.name="CanceledError"}H.inherits(xo,Te,{__CANCEL__:!0});function eC(t,e,n){const s=n.config.validateStatus;!n.status||!s||s(n.status)?t(n):e(new Te("Request failed with status code "+n.status,[Te.ERR_BAD_REQUEST,Te.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function FI(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function zI(t,e){t=t||10;const n=new Array(t),s=new Array(t);let r=0,a=0,l;return e=e!==void 0?e:1e3,function(c){const d=Date.now(),u=s[a];l||(l=d),n[r]=c,s[r]=d;let h=a,m=0;for(;h!==r;)m+=n[h++],h=h%t;if(r=(r+1)%t,r===a&&(a=(a+1)%t),d-l<e)return;const f=u&&d-u;return f?Math.round(m*1e3/f):void 0}}function $I(t,e){let n=0,s=1e3/e,r,a;const l=(d,u=Date.now())=>{n=u,r=null,a&&(clearTimeout(a),a=null),t(...d)};return[(...d)=>{const u=Date.now(),h=u-n;h>=s?l(d,u):(r=d,a||(a=setTimeout(()=>{a=null,l(r)},s-h)))},()=>r&&l(r)]}const oh=(t,e,n=3)=>{let s=0;const r=zI(50,250);return $I(a=>{const l=a.loaded,o=a.lengthComputable?a.total:void 0,c=l-s,d=r(c),u=l<=o;s=l;const h={loaded:l,total:o,progress:o?l/o:void 0,bytes:c,rate:d||void 0,estimated:d&&o&&u?(o-l)/d:void 0,event:a,lengthComputable:o!=null,[e?"download":"upload"]:!0};t(h)},n)},u1=(t,e)=>{const n=t!=null;return[s=>e[0]({lengthComputable:n,total:t,loaded:s}),e[1]]},h1=t=>(...e)=>H.asap(()=>t(...e)),BI=vn.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,vn.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(vn.origin),vn.navigator&&/(msie|trident)/i.test(vn.navigator.userAgent)):()=>!0,_I=vn.hasStandardBrowserEnv?{write(t,e,n,s,r,a,l){if(typeof document>"u")return;const o=[`${t}=${encodeURIComponent(e)}`];H.isNumber(n)&&o.push(`expires=${new Date(n).toUTCString()}`),H.isString(s)&&o.push(`path=${s}`),H.isString(r)&&o.push(`domain=${r}`),a===!0&&o.push("secure"),H.isString(l)&&o.push(`SameSite=${l}`),document.cookie=o.join("; ")},read(t){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function VI(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function KI(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function tC(t,e,n){let s=!VI(e);return t&&(s||n==!1)?KI(t,e):e}const f1=t=>t instanceof Jn?{...t}:t;function $a(t,e){e=e||{};const n={};function s(d,u,h,m){return H.isPlainObject(d)&&H.isPlainObject(u)?H.merge.call({caseless:m},d,u):H.isPlainObject(u)?H.merge({},u):H.isArray(u)?u.slice():u}function r(d,u,h,m){if(H.isUndefined(u)){if(!H.isUndefined(d))return s(void 0,d,h,m)}else return s(d,u,h,m)}function a(d,u){if(!H.isUndefined(u))return s(void 0,u)}function l(d,u){if(H.isUndefined(u)){if(!H.isUndefined(d))return s(void 0,d)}else return s(void 0,u)}function o(d,u,h){if(h in e)return s(d,u);if(h in t)return s(void 0,d)}const c={url:a,method:a,data:a,baseURL:l,transformRequest:l,transformResponse:l,paramsSerializer:l,timeout:l,timeoutMessage:l,withCredentials:l,withXSRFToken:l,adapter:l,responseType:l,xsrfCookieName:l,xsrfHeaderName:l,onUploadProgress:l,onDownloadProgress:l,decompress:l,maxContentLength:l,maxBodyLength:l,beforeRedirect:l,transport:l,httpAgent:l,httpsAgent:l,cancelToken:l,socketPath:l,responseEncoding:l,validateStatus:o,headers:(d,u,h)=>r(f1(d),f1(u),h,!0)};return H.forEach(Object.keys({...t,...e}),function(u){const h=c[u]||r,m=h(t[u],e[u],u);H.isUndefined(m)&&h!==o||(n[u]=m)}),n}const nC=t=>{const e=$a({},t);let{data:n,withXSRFToken:s,xsrfHeaderName:r,xsrfCookieName:a,headers:l,auth:o}=e;if(e.headers=l=Jn.from(l),e.url=JS(tC(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),o&&l.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),H.isFormData(n)){if(vn.hasStandardBrowserEnv||vn.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(H.isFunction(n.getHeaders)){const c=n.getHeaders(),d=["content-type","content-length"];Object.entries(c).forEach(([u,h])=>{d.includes(u.toLowerCase())&&l.set(u,h)})}}if(vn.hasStandardBrowserEnv&&(s&&H.isFunction(s)&&(s=s(e)),s||s!==!1&&BI(e.url))){const c=r&&a&&_I.read(a);c&&l.set(r,c)}return e},UI=typeof XMLHttpRequest<"u",qI=UI&&function(t){return new Promise(function(n,s){const r=nC(t);let a=r.data;const l=Jn.from(r.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:d}=r,u,h,m,f,p;function g(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let x=new XMLHttpRequest;x.open(r.method.toUpperCase(),r.url,!0),x.timeout=r.timeout;function y(){if(!x)return;const b=Jn.from("getAllResponseHeaders"in x&&x.getAllResponseHeaders()),k={data:!o||o==="text"||o==="json"?x.responseText:x.response,status:x.status,statusText:x.statusText,headers:b,config:t,request:x};eC(function(T){n(T),g()},function(T){s(T),g()},k),x=null}"onloadend"in x?x.onloadend=y:x.onreadystatechange=function(){!x||x.readyState!==4||x.status===0&&!(x.responseURL&&x.responseURL.indexOf("file:")===0)||setTimeout(y)},x.onabort=function(){x&&(s(new Te("Request aborted",Te.ECONNABORTED,t,x)),x=null)},x.onerror=function(j){const k=j&&j.message?j.message:"Network Error",E=new Te(k,Te.ERR_NETWORK,t,x);E.event=j||null,s(E),x=null},x.ontimeout=function(){let j=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const k=r.transitional||ZS;r.timeoutErrorMessage&&(j=r.timeoutErrorMessage),s(new Te(j,k.clarifyTimeoutError?Te.ETIMEDOUT:Te.ECONNABORTED,t,x)),x=null},a===void 0&&l.setContentType(null),"setRequestHeader"in x&&H.forEach(l.toJSON(),function(j,k){x.setRequestHeader(k,j)}),H.isUndefined(r.withCredentials)||(x.withCredentials=!!r.withCredentials),o&&o!=="json"&&(x.responseType=r.responseType),d&&([m,p]=oh(d,!0),x.addEventListener("progress",m)),c&&x.upload&&([h,f]=oh(c),x.upload.addEventListener("progress",h),x.upload.addEventListener("loadend",f)),(r.cancelToken||r.signal)&&(u=b=>{x&&(s(!b||b.type?new xo(null,t,x):b),x.abort(),x=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const v=FI(r.url);if(v&&vn.protocols.indexOf(v)===-1){s(new Te("Unsupported protocol "+v+":",Te.ERR_BAD_REQUEST,t));return}x.send(a||null)})},HI=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let s=new AbortController,r;const a=function(d){if(!r){r=!0,o();const u=d instanceof Error?d:this.reason;s.abort(u instanceof Te?u:new xo(u instanceof Error?u.message:u))}};let l=e&&setTimeout(()=>{l=null,a(new Te(`timeout ${e} of ms exceeded`,Te.ETIMEDOUT))},e);const o=()=>{t&&(l&&clearTimeout(l),l=null,t.forEach(d=>{d.unsubscribe?d.unsubscribe(a):d.removeEventListener("abort",a)}),t=null)};t.forEach(d=>d.addEventListener("abort",a));const{signal:c}=s;return c.unsubscribe=()=>H.asap(o),c}},WI=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let s=0,r;for(;s<n;)r=s+e,yield t.slice(s,r),s=r},QI=async function*(t,e){for await(const n of GI(t))yield*WI(n,e)},GI=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:s}=await e.read();if(n)break;yield s}}finally{await e.cancel()}},m1=(t,e,n,s)=>{const r=QI(t,e);let a=0,l,o=c=>{l||(l=!0,s&&s(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await r.next();if(d){o(),c.close();return}let h=u.byteLength;if(n){let m=a+=h;n(m)}c.enqueue(new Uint8Array(u))}catch(d){throw o(d),d}},cancel(c){return o(c),r.return()}},{highWaterMark:2})},p1=64*1024,{isFunction:Gd}=H,JI=(({Request:t,Response:e})=>({Request:t,Response:e}))(H.global),{ReadableStream:g1,TextEncoder:x1}=H.global,y1=(t,...e)=>{try{return!!t(...e)}catch{return!1}},ZI=t=>{t=H.merge.call({skipUndefined:!0},JI,t);const{fetch:e,Request:n,Response:s}=t,r=e?Gd(e):typeof fetch=="function",a=Gd(n),l=Gd(s);if(!r)return!1;const o=r&&Gd(g1),c=r&&(typeof x1=="function"?(p=>g=>p.encode(g))(new x1):async p=>new Uint8Array(await new n(p).arrayBuffer())),d=a&&o&&y1(()=>{let p=!1;const g=new n(vn.origin,{body:new g1,method:"POST",get duplex(){return p=!0,"half"}}).headers.has("Content-Type");return p&&!g}),u=l&&o&&y1(()=>H.isReadableStream(new s("").body)),h={stream:u&&(p=>p.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!h[p]&&(h[p]=(g,x)=>{let y=g&&g[p];if(y)return y.call(g);throw new Te(`Response type '${p}' is not supported`,Te.ERR_NOT_SUPPORT,x)})});const m=async p=>{if(p==null)return 0;if(H.isBlob(p))return p.size;if(H.isSpecCompliantForm(p))return(await new n(vn.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(H.isArrayBufferView(p)||H.isArrayBuffer(p))return p.byteLength;if(H.isURLSearchParams(p)&&(p=p+""),H.isString(p))return(await c(p)).byteLength},f=async(p,g)=>{const x=H.toFiniteNumber(p.getContentLength());return x??m(g)};return async p=>{let{url:g,method:x,data:y,signal:v,cancelToken:b,timeout:j,onDownloadProgress:k,onUploadProgress:E,responseType:T,headers:w,withCredentials:S="same-origin",fetchOptions:M}=nC(p),F=e||fetch;T=T?(T+"").toLowerCase():"text";let R=HI([v,b&&b.toAbortSignal()],j),V=null;const D=R&&R.unsubscribe&&(()=>{R.unsubscribe()});let z;try{if(E&&d&&x!=="get"&&x!=="head"&&(z=await f(w,y))!==0){let ce=new n(g,{method:"POST",body:y,duplex:"half"}),he;if(H.isFormData(y)&&(he=ce.headers.get("content-type"))&&w.setContentType(he),ce.body){const[Je,et]=u1(z,oh(h1(E)));y=m1(ce.body,p1,Je,et)}}H.isString(S)||(S=S?"include":"omit");const C=a&&"credentials"in n.prototype,_={...M,signal:R,method:x.toUpperCase(),headers:w.normalize().toJSON(),body:y,duplex:"half",credentials:C?S:void 0};V=a&&new n(g,_);let K=await(a?F(V,M):F(g,_));const B=u&&(T==="stream"||T==="response");if(u&&(k||B&&D)){const ce={};["status","statusText","headers"].forEach(mt=>{ce[mt]=K[mt]});const he=H.toFiniteNumber(K.headers.get("content-length")),[Je,et]=k&&u1(he,oh(h1(k),!0))||[];K=new s(m1(K.body,p1,Je,()=>{et&&et(),D&&D()}),ce)}T=T||"text";let W=await h[H.findKey(h,T)||"text"](K,p);return!B&&D&&D(),await new Promise((ce,he)=>{eC(ce,he,{data:W,headers:Jn.from(K.headers),status:K.status,statusText:K.statusText,config:p,request:V})})}catch(C){throw D&&D(),C&&C.name==="TypeError"&&/Load failed|fetch/i.test(C.message)?Object.assign(new Te("Network Error",Te.ERR_NETWORK,p,V),{cause:C.cause||C}):Te.from(C,C&&C.code,p,V)}}},YI=new Map,sC=t=>{let e=t&&t.env||{};const{fetch:n,Request:s,Response:r}=e,a=[s,r,n];let l=a.length,o=l,c,d,u=YI;for(;o--;)c=a[o],d=u.get(c),d===void 0&&u.set(c,d=o?new Map:ZI(e)),u=d;return d};sC();const Py={http:pI,xhr:qI,fetch:{get:sC}};H.forEach(Py,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const v1=t=>`- ${t}`,XI=t=>H.isFunction(t)||t===null||t===!1;function e5(t,e){t=H.isArray(t)?t:[t];const{length:n}=t;let s,r;const a={};for(let l=0;l<n;l++){s=t[l];let o;if(r=s,!XI(s)&&(r=Py[(o=String(s)).toLowerCase()],r===void 0))throw new Te(`Unknown adapter '${o}'`);if(r&&(H.isFunction(r)||(r=r.get(e))))break;a[o||"#"+l]=r}if(!r){const l=Object.entries(a).map(([c,d])=>`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build"));let o=n?l.length>1?`since :
`+l.map(v1).join(`
`):" "+v1(l[0]):"as no adapter specified";throw new Te("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r}const rC={getAdapter:e5,adapters:Py};function Tm(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new xo(null,t)}function b1(t){return Tm(t),t.headers=Jn.from(t.headers),t.data=Mm.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),rC.getAdapter(t.adapter||vd.adapter,t)(t).then(function(s){return Tm(t),s.data=Mm.call(t,t.transformResponse,s),s.headers=Jn.from(s.headers),s},function(s){return XS(s)||(Tm(t),s&&s.response&&(s.response.data=Mm.call(t,t.transformResponse,s.response),s.response.headers=Jn.from(s.response.headers))),Promise.reject(s)})}const iC="1.13.2",Pf={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Pf[t]=function(s){return typeof s===t||"a"+(e<1?"n ":" ")+t}});const j1={};Pf.transitional=function(e,n,s){function r(a,l){return"[Axios v"+iC+"] Transitional option '"+a+"'"+l+(s?". "+s:"")}return(a,l,o)=>{if(e===!1)throw new Te(r(l," has been removed"+(n?" in "+n:"")),Te.ERR_DEPRECATED);return n&&!j1[l]&&(j1[l]=!0,console.warn(r(l," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(a,l,o):!0}};Pf.spelling=function(e){return(n,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};function t5(t,e,n){if(typeof t!="object")throw new Te("options must be an object",Te.ERR_BAD_OPTION_VALUE);const s=Object.keys(t);let r=s.length;for(;r-- >0;){const a=s[r],l=e[a];if(l){const o=t[a],c=o===void 0||l(o,a,t);if(c!==!0)throw new Te("option "+a+" must be "+c,Te.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Te("Unknown option "+a,Te.ERR_BAD_OPTION)}}const Cu={assertOptions:t5,validators:Pf},Ws=Cu.validators;let ka=class{constructor(e){this.defaults=e||{},this.interceptors={request:new c1,response:new c1}}async request(e,n){try{return await this._request(e,n)}catch(s){if(s instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const a=r.stack?r.stack.replace(/^.+\n/,""):"";try{s.stack?a&&!String(s.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(s.stack+=`
`+a):s.stack=a}catch{}}throw s}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=$a(this.defaults,n);const{transitional:s,paramsSerializer:r,headers:a}=n;s!==void 0&&Cu.assertOptions(s,{silentJSONParsing:Ws.transitional(Ws.boolean),forcedJSONParsing:Ws.transitional(Ws.boolean),clarifyTimeoutError:Ws.transitional(Ws.boolean)},!1),r!=null&&(H.isFunction(r)?n.paramsSerializer={serialize:r}:Cu.assertOptions(r,{encode:Ws.function,serialize:Ws.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Cu.assertOptions(n,{baseUrl:Ws.spelling("baseURL"),withXsrfToken:Ws.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let l=a&&H.merge(a.common,a[n.method]);a&&H.forEach(["delete","get","head","post","put","patch","common"],p=>{delete a[p]}),n.headers=Jn.concat(l,a);const o=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(n)===!1||(c=c&&g.synchronous,o.unshift(g.fulfilled,g.rejected))});const d=[];this.interceptors.response.forEach(function(g){d.push(g.fulfilled,g.rejected)});let u,h=0,m;if(!c){const p=[b1.bind(this),void 0];for(p.unshift(...o),p.push(...d),m=p.length,u=Promise.resolve(n);h<m;)u=u.then(p[h++],p[h++]);return u}m=o.length;let f=n;for(;h<m;){const p=o[h++],g=o[h++];try{f=p(f)}catch(x){g.call(this,x);break}}try{u=b1.call(this,f)}catch(p){return Promise.reject(p)}for(h=0,m=d.length;h<m;)u=u.then(d[h++],d[h++]);return u}getUri(e){e=$a(this.defaults,e);const n=tC(e.baseURL,e.url,e.allowAbsoluteUrls);return JS(n,e.params,e.paramsSerializer)}};H.forEach(["delete","get","head","options"],function(e){ka.prototype[e]=function(n,s){return this.request($a(s||{},{method:e,url:n,data:(s||{}).data}))}});H.forEach(["post","put","patch"],function(e){function n(s){return function(a,l,o){return this.request($a(o||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:a,data:l}))}}ka.prototype[e]=n(),ka.prototype[e+"Form"]=n(!0)});let n5=class aC{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const s=this;this.promise.then(r=>{if(!s._listeners)return;let a=s._listeners.length;for(;a-- >0;)s._listeners[a](r);s._listeners=null}),this.promise.then=r=>{let a;const l=new Promise(o=>{s.subscribe(o),a=o}).then(r);return l.cancel=function(){s.unsubscribe(a)},l},e(function(a,l,o){s.reason||(s.reason=new xo(a,l,o),n(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=s=>{e.abort(s)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new aC(function(r){e=r}),cancel:e}}};function s5(t){return function(n){return t.apply(null,n)}}function r5(t){return H.isObject(t)&&t.isAxiosError===!0}const zg={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(zg).forEach(([t,e])=>{zg[e]=t});function lC(t){const e=new ka(t),n=zS(ka.prototype.request,e);return H.extend(n,ka.prototype,e,{allOwnKeys:!0}),H.extend(n,e,null,{allOwnKeys:!0}),n.create=function(r){return lC($a(t,r))},n}const Tt=lC(vd);Tt.Axios=ka;Tt.CanceledError=xo;Tt.CancelToken=n5;Tt.isCancel=XS;Tt.VERSION=iC;Tt.toFormData=Tf;Tt.AxiosError=Te;Tt.Cancel=Tt.CanceledError;Tt.all=function(e){return Promise.all(e)};Tt.spread=s5;Tt.isAxiosError=r5;Tt.mergeConfig=$a;Tt.AxiosHeaders=Jn;Tt.formToJSON=t=>YS(H.isHTMLForm(t)?new FormData(t):t);Tt.getAdapter=rC.getAdapter;Tt.HttpStatusCode=zg;Tt.default=Tt;const{Axios:IV,AxiosError:RV,CanceledError:OV,isCancel:LV,CancelToken:FV,VERSION:zV,all:$V,Cancel:BV,isAxiosError:_V,spread:VV,toFormData:KV,AxiosHeaders:UV,HttpStatusCode:qV,formToJSON:HV,getAdapter:WV,mergeConfig:QV}=Tt,$=Tt.create({baseURL:"/api",headers:{"Content-Type":"application/json"}});$.interceptors.request.use(t=>{const e=localStorage.getItem("token");return e&&(t.headers.Authorization=`Bearer ${e}`),t});$.interceptors.response.use(t=>t,t=>{var r,a,l,o,c,d,u;const e=((a=(r=t.config)==null?void 0:r.url)==null?void 0:a.includes("/auth/login"))||((o=(l=t.config)==null?void 0:l.url)==null?void 0:o.includes("/auth/customer-login"));((c=t.response)==null?void 0:c.status)===401&&!e&&(localStorage.removeItem("token"),localStorage.removeItem("user"),window.location.href="/login");const n=((u=(d=t.response)==null?void 0:d.data)==null?void 0:u.error)||t.message||"Ein Fehler ist aufgetreten",s=new Error(n);return Promise.reject(s)});const Jd={login:async(t,e)=>(await $.post("/auth/login",{email:t,password:e})).data,customerLogin:async(t,e)=>(await $.post("/auth/customer-login",{email:t,password:e})).data,me:async()=>(await $.get("/auth/me")).data},Zt={getAll:async t=>(await $.get("/customers",{params:t})).data,getById:async t=>(await $.get(`/customers/${t}`)).data,create:async t=>(await $.post("/customers",t)).data,update:async(t,e)=>(await $.put(`/customers/${t}`,e)).data,delete:async t=>(await $.delete(`/customers/${t}`)).data,getPortalSettings:async t=>(await $.get(`/customers/${t}/portal`)).data,updatePortalSettings:async(t,e)=>(await $.put(`/customers/${t}/portal`,e)).data,setPortalPassword:async(t,e)=>(await $.post(`/customers/${t}/portal/password`,{password:e})).data,getPortalPassword:async t=>(await $.get(`/customers/${t}/portal/password`)).data,getRepresentatives:async t=>(await $.get(`/customers/${t}/representatives`)).data,addRepresentative:async(t,e,n)=>(await $.post(`/customers/${t}/representatives`,{representativeId:e,notes:n})).data,removeRepresentative:async(t,e)=>(await $.delete(`/customers/${t}/representatives/${e}`)).data,searchForRepresentative:async(t,e)=>(await $.get(`/customers/${t}/representatives/search`,{params:{search:e}})).data},$g={getByCustomer:async t=>(await $.get(`/customers/${t}/addresses`)).data,create:async(t,e)=>(await $.post(`/customers/${t}/addresses`,e)).data,update:async(t,e)=>(await $.put(`/addresses/${t}`,e)).data,delete:async t=>(await $.delete(`/addresses/${t}`)).data},ch={getByCustomer:async(t,e=!1)=>(await $.get(`/customers/${t}/bank-cards`,{params:{showInactive:e}})).data,create:async(t,e)=>(await $.post(`/customers/${t}/bank-cards`,e)).data,update:async(t,e)=>(await $.put(`/bank-cards/${t}`,e)).data,delete:async t=>(await $.delete(`/bank-cards/${t}`)).data},dh={getByCustomer:async(t,e=!1)=>(await $.get(`/customers/${t}/documents`,{params:{showInactive:e}})).data,create:async(t,e)=>(await $.post(`/customers/${t}/documents`,e)).data,update:async(t,e)=>(await $.put(`/documents/${t}`,e)).data,delete:async t=>(await $.delete(`/documents/${t}`)).data},ar={getByCustomer:async(t,e=!1)=>(await $.get(`/customers/${t}/meters`,{params:{showInactive:e}})).data,create:async(t,e)=>(await $.post(`/customers/${t}/meters`,e)).data,update:async(t,e)=>(await $.put(`/meters/${t}`,e)).data,delete:async t=>(await $.delete(`/meters/${t}`)).data,getReadings:async t=>(await $.get(`/meters/${t}/readings`)).data,addReading:async(t,e)=>(await $.post(`/meters/${t}/readings`,e)).data,updateReading:async(t,e,n)=>(await $.put(`/meters/${t}/readings/${e}`,n)).data,deleteReading:async(t,e)=>(await $.delete(`/meters/${t}/readings/${e}`)).data},sl={getInvoices:async t=>(await $.get(`/energy-details/${t}/invoices`)).data,addInvoice:async(t,e)=>(await $.post(`/energy-details/${t}/invoices`,e)).data,updateInvoice:async(t,e,n)=>(await $.put(`/energy-details/${t}/invoices/${e}`,n)).data,deleteInvoice:async(t,e)=>(await $.delete(`/energy-details/${t}/invoices/${e}`)).data,uploadDocument:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/invoices/${t}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteDocument:async t=>(await $.delete(`/upload/invoices/${t}`)).data},ts={getByCustomer:async(t,e=!1)=>(await $.get(`/customers/${t}/stressfrei-emails`,{params:{includeInactive:e}})).data,create:async(t,e)=>(await $.post(`/customers/${t}/stressfrei-emails`,e)).data,update:async(t,e)=>(await $.put(`/stressfrei-emails/${t}`,e)).data,delete:async t=>(await $.delete(`/stressfrei-emails/${t}`)).data,enableMailbox:async t=>(await $.post(`/stressfrei-emails/${t}/enable-mailbox`)).data,syncMailboxStatus:async t=>(await $.post(`/stressfrei-emails/${t}/sync-mailbox-status`)).data,getMailboxCredentials:async t=>(await $.get(`/stressfrei-emails/${t}/credentials`)).data,resetPassword:async t=>(await $.post(`/stressfrei-emails/${t}/reset-password`)).data,syncEmails:async(t,e=!1)=>(await $.post(`/stressfrei-emails/${t}/sync`,{},{params:{full:e}})).data,sendEmail:async(t,e)=>(await $.post(`/stressfrei-emails/${t}/send`,e)).data,getFolderCounts:async t=>(await $.get(`/stressfrei-emails/${t}/folder-counts`)).data},Be={getForCustomer:async(t,e)=>(await $.get(`/customers/${t}/emails`,{params:e})).data,getForContract:async(t,e)=>(await $.get(`/contracts/${t}/emails`,{params:e})).data,getContractFolderCounts:async t=>(await $.get(`/contracts/${t}/emails/folder-counts`)).data,getMailboxAccounts:async t=>(await $.get(`/customers/${t}/mailbox-accounts`)).data,getById:async t=>(await $.get(`/emails/${t}`)).data,getThread:async t=>(await $.get(`/emails/${t}/thread`)).data,markAsRead:async(t,e)=>(await $.patch(`/emails/${t}/read`,{isRead:e})).data,toggleStar:async t=>(await $.post(`/emails/${t}/star`)).data,assignToContract:async(t,e)=>(await $.post(`/emails/${t}/assign`,{contractId:e})).data,unassignFromContract:async t=>(await $.delete(`/emails/${t}/assign`)).data,delete:async t=>(await $.delete(`/emails/${t}`)).data,getAttachmentUrl:(t,e,n)=>{const s=localStorage.getItem("token"),r=encodeURIComponent(e),a=n?"&view=true":"";return`${$.defaults.baseURL}/emails/${t}/attachments/${r}?token=${s}${a}`},getUnreadCount:async t=>(await $.get("/emails/unread-count",{params:t})).data,getTrash:async t=>(await $.get(`/customers/${t}/emails/trash`)).data,getTrashCount:async t=>(await $.get(`/customers/${t}/emails/trash/count`)).data,restore:async t=>(await $.post(`/emails/${t}/restore`)).data,permanentDelete:async t=>(await $.delete(`/emails/${t}/permanent`)).data,getAttachmentTargets:async t=>(await $.get(`/emails/${t}/attachment-targets`)).data,saveAttachmentTo:async(t,e,n)=>{const s=encodeURIComponent(e);return(await $.post(`/emails/${t}/attachments/${s}/save-to`,n)).data},saveEmailAsPdf:async(t,e)=>(await $.post(`/emails/${t}/save-as-pdf`,e)).data,saveEmailAsInvoice:async(t,e)=>(await $.post(`/emails/${t}/save-as-invoice`,e)).data,saveAttachmentAsInvoice:async(t,e,n)=>{const s=encodeURIComponent(e);return(await $.post(`/emails/${t}/attachments/${s}/save-as-invoice`,n)).data}},He={getAll:async t=>(await $.get("/contracts",{params:t})).data,getTreeForCustomer:async t=>(await $.get("/contracts",{params:{customerId:t,tree:"true"}})).data,getById:async t=>(await $.get(`/contracts/${t}`)).data,create:async t=>(await $.post("/contracts",t)).data,update:async(t,e)=>(await $.put(`/contracts/${t}`,e)).data,delete:async t=>(await $.delete(`/contracts/${t}`)).data,createFollowUp:async t=>(await $.post(`/contracts/${t}/follow-up`)).data,getPassword:async t=>(await $.get(`/contracts/${t}/password`)).data,getSimCardCredentials:async t=>(await $.get(`/contracts/simcard/${t}/credentials`)).data,getInternetCredentials:async t=>(await $.get(`/contracts/${t}/internet-credentials`)).data,getSipCredentials:async t=>(await $.get(`/contracts/phonenumber/${t}/sip-credentials`)).data,getCockpit:async()=>(await $.get("/contracts/cockpit")).data,snooze:async(t,e)=>(await $.patch(`/contracts/${t}/snooze`,e)).data},uh={getByContract:async t=>(await $.get(`/contracts/${t}/history`)).data,create:async(t,e)=>(await $.post(`/contracts/${t}/history`,e)).data,update:async(t,e,n)=>(await $.put(`/contracts/${t}/history/${e}`,n)).data,delete:async(t,e)=>(await $.delete(`/contracts/${t}/history/${e}`)).data},ht={getAll:async t=>(await $.get("/tasks",{params:t})).data,getStats:async()=>(await $.get("/tasks/stats")).data,getByContract:async(t,e)=>(await $.get(`/contracts/${t}/tasks`,{params:{status:e}})).data,create:async(t,e)=>(await $.post(`/contracts/${t}/tasks`,e)).data,update:async(t,e)=>(await $.put(`/tasks/${t}`,e)).data,complete:async t=>(await $.post(`/tasks/${t}/complete`)).data,reopen:async t=>(await $.post(`/tasks/${t}/reopen`)).data,delete:async t=>(await $.delete(`/tasks/${t}`)).data,createSubtask:async(t,e)=>(await $.post(`/tasks/${t}/subtasks`,{title:e})).data,createReply:async(t,e)=>(await $.post(`/tasks/${t}/reply`,{title:e})).data,updateSubtask:async(t,e)=>(await $.put(`/subtasks/${t}`,{title:e})).data,completeSubtask:async t=>(await $.post(`/subtasks/${t}/complete`)).data,reopenSubtask:async t=>(await $.post(`/subtasks/${t}/reopen`)).data,deleteSubtask:async t=>(await $.delete(`/subtasks/${t}`)).data,createSupportTicket:async(t,e)=>(await $.post(`/contracts/${t}/support-ticket`,e)).data},Ba={getPublic:async()=>(await $.get("/settings/public")).data,getAll:async()=>(await $.get("/settings")).data,update:async t=>(await $.put("/settings",t)).data,updateOne:async(t,e)=>(await $.put(`/settings/${t}`,{value:e})).data},Zi={list:async()=>(await $.get("/settings/backups")).data,create:async()=>(await $.post("/settings/backup")).data,restore:async t=>(await $.post(`/settings/backup/${t}/restore`)).data,delete:async t=>(await $.delete(`/settings/backup/${t}`)).data,getDownloadUrl:t=>`/api/settings/backup/${t}/download`,upload:async t=>{const e=new FormData;return e.append("backup",t),(await $.post("/settings/backup/upload",e,{headers:{"Content-Type":"multipart/form-data"}})).data},factoryReset:async()=>(await $.post("/settings/factory-reset")).data},Fc={getAll:async(t=!1)=>(await $.get("/platforms",{params:{includeInactive:t}})).data,getById:async t=>(await $.get(`/platforms/${t}`)).data,create:async t=>(await $.post("/platforms",t)).data,update:async(t,e)=>(await $.put(`/platforms/${t}`,e)).data,delete:async t=>(await $.delete(`/platforms/${t}`)).data},zc={getAll:async(t=!1)=>(await $.get("/cancellation-periods",{params:{includeInactive:t}})).data,getById:async t=>(await $.get(`/cancellation-periods/${t}`)).data,create:async t=>(await $.post("/cancellation-periods",t)).data,update:async(t,e)=>(await $.put(`/cancellation-periods/${t}`,e)).data,delete:async t=>(await $.delete(`/cancellation-periods/${t}`)).data},$c={getAll:async(t=!1)=>(await $.get("/contract-durations",{params:{includeInactive:t}})).data,getById:async t=>(await $.get(`/contract-durations/${t}`)).data,create:async t=>(await $.post("/contract-durations",t)).data,update:async(t,e)=>(await $.put(`/contract-durations/${t}`,e)).data,delete:async t=>(await $.delete(`/contract-durations/${t}`)).data},Bc={getAll:async(t=!1)=>(await $.get("/contract-categories",{params:{includeInactive:t}})).data,getById:async t=>(await $.get(`/contract-categories/${t}`)).data,create:async t=>(await $.post("/contract-categories",t)).data,update:async(t,e)=>(await $.put(`/contract-categories/${t}`,e)).data,delete:async t=>(await $.delete(`/contract-categories/${t}`)).data},to={getAll:async(t=!1)=>(await $.get("/providers",{params:{includeInactive:t}})).data,getById:async t=>(await $.get(`/providers/${t}`)).data,create:async t=>(await $.post("/providers",t)).data,update:async(t,e)=>(await $.put(`/providers/${t}`,e)).data,delete:async t=>(await $.delete(`/providers/${t}`)).data,getTariffs:async(t,e=!1)=>(await $.get(`/providers/${t}/tariffs`,{params:{includeInactive:e}})).data,createTariff:async(t,e)=>(await $.post(`/providers/${t}/tariffs`,e)).data},oC={getById:async t=>(await $.get(`/tariffs/${t}`)).data,update:async(t,e)=>(await $.put(`/tariffs/${t}`,e)).data,delete:async t=>(await $.delete(`/tariffs/${t}`)).data},Ct={uploadBankCardDocument:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/bank-cards/${t}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},uploadIdentityDocument:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/documents/${t}`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBankCardDocument:async t=>(await $.delete(`/upload/bank-cards/${t}`)).data,deleteIdentityDocument:async t=>(await $.delete(`/upload/documents/${t}`)).data,uploadBusinessRegistration:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/customers/${t}/business-registration`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBusinessRegistration:async t=>(await $.delete(`/upload/customers/${t}/business-registration`)).data,uploadCommercialRegister:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/customers/${t}/commercial-register`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCommercialRegister:async t=>(await $.delete(`/upload/customers/${t}/commercial-register`)).data,uploadPrivacyPolicy:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/customers/${t}/privacy-policy`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deletePrivacyPolicy:async t=>(await $.delete(`/upload/customers/${t}/privacy-policy`)).data,uploadCancellationLetter:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/contracts/${t}/cancellation-letter`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetter:async t=>(await $.delete(`/upload/contracts/${t}/cancellation-letter`)).data,uploadCancellationConfirmation:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/contracts/${t}/cancellation-confirmation`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmation:async t=>(await $.delete(`/upload/contracts/${t}/cancellation-confirmation`)).data,uploadCancellationLetterOptions:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/contracts/${t}/cancellation-letter-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetterOptions:async t=>(await $.delete(`/upload/contracts/${t}/cancellation-letter-options`)).data,uploadCancellationConfirmationOptions:async(t,e)=>{const n=new FormData;return n.append("document",e),(await $.post(`/upload/contracts/${t}/cancellation-confirmation-options`,n,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmationOptions:async t=>(await $.delete(`/upload/contracts/${t}/cancellation-confirmation-options`)).data},sc={getAll:async t=>(await $.get("/users",{params:t})).data,getById:async t=>(await $.get(`/users/${t}`)).data,create:async t=>(await $.post("/users",t)).data,update:async(t,e)=>(await $.put(`/users/${t}`,e)).data,delete:async t=>(await $.delete(`/users/${t}`)).data,getRoles:async()=>(await $.get("/users/roles/list")).data},Vo={getSchema:async()=>(await $.get("/developer/schema")).data,getTableData:async(t,e=1,n=50)=>(await $.get(`/developer/table/${t}`,{params:{page:e,limit:n}})).data,updateRow:async(t,e,n)=>(await $.put(`/developer/table/${t}/${e}`,n)).data,deleteRow:async(t,e)=>(await $.delete(`/developer/table/${t}/${e}`)).data,getReference:async t=>(await $.get(`/developer/reference/${t}`)).data},wr={getConfigs:async()=>(await $.get("/email-providers/configs")).data,getConfig:async t=>(await $.get(`/email-providers/configs/${t}`)).data,createConfig:async t=>(await $.post("/email-providers/configs",t)).data,updateConfig:async(t,e)=>(await $.put(`/email-providers/configs/${t}`,e)).data,deleteConfig:async t=>(await $.delete(`/email-providers/configs/${t}`)).data,testConnection:async t=>{const e=t!=null&&t.testData?{...t.testData}:t!=null&&t.id?{id:t.id}:{};return(await $.post("/email-providers/test-connection",e)).data},getDomain:async()=>(await $.get("/email-providers/domain")).data,checkEmailExists:async t=>(await $.get(`/email-providers/check/${t}`)).data,provisionEmail:async(t,e)=>(await $.post("/email-providers/provision",{localPart:t,customerEmail:e})).data,deprovisionEmail:async t=>(await $.delete(`/email-providers/deprovision/${t}`)).data},Pm={search:async t=>(await $.get("/audit-logs",{params:t})).data,getById:async t=>(await $.get(`/audit-logs/${t}`)).data,getByCustomer:async t=>(await $.get(`/audit-logs/customer/${t}`)).data,export:async t=>(await $.get("/audit-logs/export",{params:t})).data,verifyIntegrity:async()=>(await $.post("/audit-logs/verify")).data,getRetentionPolicies:async()=>(await $.get("/audit-logs/retention-policies")).data,updateRetentionPolicy:async(t,e)=>(await $.put(`/audit-logs/retention-policies/${t}`,e)).data,runRetentionCleanup:async()=>(await $.post("/audit-logs/cleanup")).data},Mr={getDashboardStats:async()=>(await $.get("/gdpr/dashboard")).data,exportCustomerData:async t=>(await $.get(`/gdpr/customer/${t}/export`)).data,getDeletionRequests:async t=>(await $.get("/gdpr/deletions",{params:t})).data,getDeletionRequest:async t=>(await $.get(`/gdpr/deletions/${t}`)).data,createDeletionRequest:async t=>(await $.post("/gdpr/deletions",t)).data,processDeletionRequest:async(t,e)=>(await $.put(`/gdpr/deletions/${t}/process`,e)).data,getCustomerConsents:async t=>(await $.get(`/gdpr/customer/${t}/consents`)).data,updateConsent:async(t,e,n)=>(await $.put(`/gdpr/customer/${t}/consents/${e}`,n)).data,getConsentOverview:async()=>(await $.get("/gdpr/consents/overview")).data,getPrivacyPolicy:async()=>(await $.get("/gdpr/privacy-policy")).data,updatePrivacyPolicy:async t=>(await $.put("/gdpr/privacy-policy",{html:t})).data,sendConsentLink:async(t,e)=>(await $.post(`/gdpr/customer/${t}/send-consent-link`,{channel:e})).data},N1=Tt.create({baseURL:"/api/public",headers:{"Content-Type":"application/json"}}),Im={getConsentPage:async t=>(await N1.get(`/consent/${t}`)).data,grantAllConsents:async t=>(await N1.post(`/consent/${t}/grant`)).data,getConsentPdfUrl:t=>`/api/public/consent/${t}/pdf`},cC=N.createContext(null);function i5({children:t}){const[e,n]=N.useState(null),[s,r]=N.useState(!0),[a,l]=N.useState(()=>localStorage.getItem("developerMode")==="true"),o=g=>{l(g),localStorage.setItem("developerMode",String(g))};N.useEffect(()=>{var g;console.log("useEffect check - user:",e==null?void 0:e.email,"developerMode:",a,"has developer:access:",(g=e==null?void 0:e.permissions)==null?void 0:g.includes("developer:access")),e&&a&&!e.permissions.includes("developer:access")&&(console.log("Disabling developer mode because user lacks developer:access permission"),o(!1))},[e,a]),N.useEffect(()=>{localStorage.getItem("token")?Jd.me().then(x=>{x.success&&x.data?n(x.data):localStorage.removeItem("token")}).catch(()=>{localStorage.removeItem("token")}).finally(()=>{r(!1)}):r(!1)},[]);const c=async(g,x)=>{const y=await Jd.login(g,x);if(y.success&&y.data)localStorage.setItem("token",y.data.token),n(y.data.user);else throw new Error(y.error||"Login fehlgeschlagen")},d=async(g,x)=>{const y=await Jd.customerLogin(g,x);if(y.success&&y.data)localStorage.setItem("token",y.data.token),n(y.data.user);else throw new Error(y.error||"Login fehlgeschlagen")},u=()=>{localStorage.removeItem("token"),n(null)},h=async()=>{var x;if(localStorage.getItem("token"))try{const y=await Jd.me();console.log("refreshUser response:",y),console.log("permissions:",(x=y.data)==null?void 0:x.permissions),y.success&&y.data&&n(y.data)}catch(y){console.error("refreshUser error:",y)}},m=g=>e?e.permissions.includes(g):!1,f=!!(e!=null&&e.customerId),p=!!(e!=null&&e.isCustomerPortal);return i.jsx(cC.Provider,{value:{user:e,isLoading:s,isAuthenticated:!!e,login:c,customerLogin:d,logout:u,hasPermission:m,isCustomer:f,isCustomerPortal:p,developerMode:a,setDeveloperMode:o,refreshUser:h},children:t})}function nt(){const t=N.useContext(cC);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t}const Rm={scrollToTopThreshold:.7},dC=N.createContext(void 0),w1="opencrm_app_settings";function a5({children:t}){const[e,n]=N.useState(()=>{const r=localStorage.getItem(w1);if(r)try{return{...Rm,...JSON.parse(r)}}catch{return Rm}return Rm});N.useEffect(()=>{localStorage.setItem(w1,JSON.stringify(e))},[e]);const s=r=>{n(a=>({...a,...r}))};return i.jsx(dC.Provider,{value:{settings:e,updateSettings:s},children:t})}function uC(){const t=N.useContext(dC);if(!t)throw new Error("useAppSettings must be used within AppSettingsProvider");return t}function l5(){const{pathname:t}=qr();return N.useEffect(()=>{window.scrollTo(0,0)},[t]),null}/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const o5=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),hC=(...t)=>t.filter((e,n,s)=>!!e&&e.trim()!==""&&s.indexOf(e)===n).join(" ").trim();/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/var c5={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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const d5=N.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:s,className:r="",children:a,iconNode:l,...o},c)=>N.createElement("svg",{ref:c,...c5,width:e,height:e,stroke:t,strokeWidth:s?Number(n)*24/Number(e):n,className:hC("lucide",r),...o},[...l.map(([d,u])=>N.createElement(d,u)),...Array.isArray(a)?a:[a]]));/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Y=(t,e)=>{const n=N.forwardRef(({className:s,...r},a)=>N.createElement(d5,{ref:a,iconNode:e,className:hC(`lucide-${o5(t)}`,s),...r}));return n.displayName=`${t}`,n};/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const u5=Y("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Yn=Y("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const fC=Y("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const mC=Y("BellOff",[["path",{d:"M8.7 3A6 6 0 0 1 18 8a21.3 21.3 0 0 0 .6 5",key:"o7mx20"}],["path",{d:"M17 17H3s3-2 3-9a4.67 4.67 0 0 1 .3-1.7",key:"16f1lm"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const h5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const f5=Y("Bomb",[["circle",{cx:"11",cy:"13",r:"9",key:"hd149"}],["path",{d:"M14.35 4.65 16.3 2.7a2.41 2.41 0 0 1 3.4 0l1.6 1.6a2.4 2.4 0 0 1 0 3.4l-1.95 1.95",key:"jp4j1b"}],["path",{d:"m22 2-1.5 1.5",key:"ay92ug"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const m5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const p5=Y("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const g5=Y("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const x5=Y("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const pC=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const gC=Y("Car",[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Vr=Y("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Us=Y("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const xC=Y("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const At=Y("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const If=Y("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Tr=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Un=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Om=Y("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Bg=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Eu=Y("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _c=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const cs=Y("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const la=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Iy=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ry=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Rf=Y("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const qn=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Oy=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const on=Y("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.454.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=Y("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.454.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=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const y5=Y("FilePen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const We=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const v5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const vC=Y("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const b5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bC=Y("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const k1=Y("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ly=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const j5=Y("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.454.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=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const N5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const w5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const k5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const S5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const jC=Y("IdCard",[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Sa=Y("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["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"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const bd=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const C5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const E5=Y("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const A5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const C1=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const D5=Y("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const M5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const T5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const E1=Y("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const P5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const NC=Y("MailOpen",[["path",{d:"M21.2 8.4c.5.38.8.97.8 1.6v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V10a2 2 0 0 1 .8-1.6l8-6a2 2 0 0 1 2.4 0l8 6Z",key:"1jhwl8"}],["path",{d:"m22 10-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 10",key:"1qfld7"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Fs=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const I5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const R5=Y("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Vc=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const O5=Y("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const L5=Y("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
* @license lucide-react v0.454.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=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ge=Y("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Fy=Y("Receipt",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 17.5v-11",key:"1jc1ny"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const F5=Y("Redo",[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const ai=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const z5=Y("Reply",[["polyline",{points:"9 17 4 12 9 7",key:"hvgpf2"}],["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const wC=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const zy=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const jd=Y("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Nd=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const kC=Y("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const hh=Y("ShieldAlert",[["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:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const SC=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const CC=Y("ShieldX",[["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:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const lr=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $y=Y("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const rt=Y("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const By=Y("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const $5=Y("Store",[["path",{d:"m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7",key:"ztvudi"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}],["path",{d:"M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4",key:"2ebpfo"}],["path",{d:"M2 7h20",key:"1fcdvo"}],["path",{d:"M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7",key:"6c3vgh"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const B5=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ee=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Mn=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const EC=Y("Tv",[["rect",{width:"20",height:"15",x:"2",y:"7",rx:"2",ry:"2",key:"10ag99"}],["polyline",{points:"17 2 12 7 7 2",key:"11pgbg"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _5=Y("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const AC=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const V5=Y("Undo",[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _g=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const K5=Y("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const U5=Y("UserPlus",[["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"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const yo=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Ca=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const A1=Y("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const Al=Y("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/**
* @license lucide-react v0.454.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=Y("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const _y=Y("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.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const q5=Y("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);/**
* @license lucide-react v0.454.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const H5=Y("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function W5(){const{user:t,logout:e,hasPermission:n,isCustomer:s,developerMode:r}=nt(),a=[{to:"/",icon:A5,label:"Dashboard",show:!0,end:!0},{to:"/customers",icon:Ca,label:"Kunden",show:n("customers:read")&&!s},{to:"/contracts",icon:We,label:"Verträge",show:n("contracts:read"),end:!0},{to:"/contracts/cockpit",icon:Tr,label:"Vertrags-Cockpit",show:n("contracts:read")&&!s},{to:"/tasks",icon:s?Vc:_c,label:s?"Support-Anfragen":"Aufgaben",show:n("contracts:read")}],l=[{to:"/developer/database",icon:Rf,label:"Datenbankstruktur"}];return i.jsxs("aside",{className:"w-64 bg-gray-900 text-white min-h-screen flex flex-col",children:[i.jsx("div",{className:"p-4 border-b border-gray-800",children:i.jsx("h1",{className:"text-xl font-bold",children:"OpenCRM"})}),i.jsxs("nav",{className:"flex-1 p-4 overflow-y-auto",children:[i.jsx("ul",{className:"space-y-2",children:a.filter(o=>o.show).map(o=>i.jsx("li",{children:i.jsxs(Am,{to:o.to,end:o.end,className:({isActive:c})=>`flex items-center gap-3 px-4 py-2 rounded-lg transition-colors ${c?"bg-blue-600 text-white":"text-gray-300 hover:bg-gray-800"}`,children:[i.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))}),r&&n("developer:access")&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mt-6 mb-2 px-4",children:i.jsxs("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider flex items-center gap-2",children:[i.jsx(la,{className:"w-3 h-3"}),"Entwickler"]})}),i.jsx("ul",{className:"space-y-2",children:l.map(o=>i.jsx("li",{children:i.jsxs(Am,{to:o.to,className:({isActive:c})=>`flex items-center gap-3 px-4 py-2 rounded-lg transition-colors ${c?"bg-purple-600 text-white":"text-purple-300 hover:bg-gray-800"}`,children:[i.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))})]}),i.jsx("div",{className:"mt-6 pt-6 border-t border-gray-800",children:i.jsxs(Am,{to:"/settings",className:({isActive:o})=>`flex items-center gap-3 px-4 py-2 rounded-lg transition-colors ${o?"bg-blue-600 text-white":"text-gray-300 hover:bg-gray-800"}`,children:[i.jsx(kC,{className:"w-5 h-5"}),"Einstellungen"]})})]}),i.jsxs("div",{className:"p-4 border-t border-gray-800",children:[i.jsxs("div",{className:"mb-4 text-sm",children:[i.jsx("p",{className:"text-gray-400",children:"Angemeldet als"}),i.jsxs("p",{className:"font-medium",children:[t==null?void 0:t.firstName," ",t==null?void 0:t.lastName]})]}),i.jsxs("button",{onClick:e,className:"flex items-center gap-3 w-full px-4 py-2 text-gray-300 hover:bg-gray-800 rounded-lg transition-colors",children:[i.jsx(P5,{className:"w-5 h-5"}),"Abmelden"]})]})]})}function Q5(){const{settings:t}=uC(),[e,n]=N.useState(!1);N.useEffect(()=>{const r=()=>{window.scrollY>window.innerHeight*t.scrollToTopThreshold?n(!0):n(!1)};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[t.scrollToTopThreshold]);const s=()=>{window.scrollTo({top:0,behavior:"smooth"})};return e?i.jsx("button",{onClick:s,className:"fixed bottom-6 right-6 p-3 bg-gray-200 hover:bg-gray-300 text-gray-600 rounded-full shadow-md transition-all duration-300 opacity-70 hover:opacity-100 z-50","aria-label":"Nach oben scrollen",title:"Nach oben",children:i.jsx(If,{className:"w-5 h-5"})}):null}function G5(){return i.jsxs("div",{className:"flex min-h-screen",children:[i.jsx(W5,{}),i.jsx("main",{className:"flex-1 p-8 overflow-auto",children:i.jsx(GM,{})}),i.jsx(Q5,{})]})}const I=N.forwardRef(({className:t="",variant:e="primary",size:n="md",children:s,disabled:r,...a},l)=>{const o="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",c={primary:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-500",danger:"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500",ghost:"bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-500"},d={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"};return i.jsx("button",{ref:l,className:`${o} ${c[e]} ${d[n]} ${t}`,disabled:r,...a,children:s})});I.displayName="Button";const q=N.forwardRef(({className:t="",label:e,error:n,id:s,onClear:r,...a},l)=>{const o=s||a.name,c=a.type==="date",d=a.value!==void 0&&a.value!==null&&a.value!=="",u=c&&r&&d;return i.jsxs("div",{className:"w-full",children:[e&&i.jsx("label",{htmlFor:o,className:"block text-sm font-medium text-gray-700 mb-1",children:e}),i.jsxs("div",{className:u?"flex gap-2":"",children:[i.jsx("input",{ref:l,id:o,className:`block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${n?"border-red-500":"border-gray-300"} ${t}`,...a}),u&&i.jsx("button",{type:"button",onClick:r,className:"px-3 py-2 text-gray-400 hover:text-red-500 hover:bg-red-50 border border-gray-300 rounded-lg transition-colors",title:"Datum löschen",children:i.jsx(Ee,{className:"w-4 h-4"})})]}),n&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});q.displayName="Input";function Z({children:t,className:e="",title:n,actions:s}){return i.jsxs("div",{className:`bg-white rounded-lg shadow ${e}`,children:[(n||s)&&i.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 flex items-center justify-between",children:[n&&i.jsx("div",{className:"text-lg font-medium text-gray-900",children:n}),s&&i.jsx("div",{className:"flex items-center gap-2",children:s})]}),i.jsx("div",{className:"p-6",children:t})]})}function J5(){const[t,e]=N.useState(""),[n,s]=N.useState(""),[r,a]=N.useState(""),[l,o]=N.useState(!1),{login:c,customerLogin:d}=nt(),u=fn(),h=async m=>{m.preventDefault(),a(""),o(!0);try{await c(t,n),u("/");return}catch{}try{await d(t,n),u("/")}catch{a("Ungültige Anmeldedaten"),o(!1)}};return i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:i.jsxs(Z,{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"OpenCRM"}),i.jsx("p",{className:"text-gray-600 mt-2",children:"Melden Sie sich an"})]}),r&&i.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:r}),i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsx(q,{label:"E-Mail",type:"email",value:t,onChange:m=>e(m.target.value),required:!0,autoComplete:"email"}),i.jsx(q,{label:"Passwort",type:"password",value:n,onChange:m=>s(m.target.value),required:!0,autoComplete:"current-password"}),i.jsx(I,{type:"submit",className:"w-full",disabled:l,children:l?"Anmeldung...":"Anmelden"})]})]})})}function Xe({isOpen:t,onClose:e,title:n,children:s,size:r="md"}){if(N.useEffect(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),!t)return null;const a={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};return i.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:i.jsxs("div",{className:"flex min-h-full items-center justify-center p-4",children:[i.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:e}),i.jsxs("div",{className:`relative bg-white rounded-lg shadow-xl w-full ${a[r]}`,children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[i.jsx("h2",{className:"text-lg font-semibold",children:n}),i.jsx(I,{variant:"ghost",size:"sm",onClick:e,children:i.jsx(nn,{className:"w-5 h-5"})})]}),i.jsx("div",{className:"p-6",children:s})]})]})})}function Z5(){var w,S,M,F,R,V;const{user:t,isCustomer:e,isCustomerPortal:n}=nt(),[s,r]=N.useState(!1),{data:a,isLoading:l}=fe({queryKey:["app-settings-public"],queryFn:()=>Ba.getPublic(),enabled:n,staleTime:0}),o=!l&&((w=a==null?void 0:a.data)==null?void 0:w.customerSupportTicketsEnabled)==="true",{data:c}=fe({queryKey:["customers-count"],queryFn:()=>Zt.getAll({limit:1}),enabled:!e}),{data:d}=fe({queryKey:["contracts",e?t==null?void 0:t.customerId:void 0],queryFn:()=>He.getAll(e?{customerId:t==null?void 0:t.customerId}:{limit:1})}),{data:u}=fe({queryKey:["contracts-active",e?t==null?void 0:t.customerId:void 0],queryFn:()=>He.getAll({status:"ACTIVE",...e?{customerId:t==null?void 0:t.customerId}:{limit:1}})}),{data:h}=fe({queryKey:["contracts-pending",e?t==null?void 0:t.customerId:void 0],queryFn:()=>He.getAll({status:"PENDING",...e?{customerId:t==null?void 0:t.customerId}:{limit:1}})}),{data:m}=fe({queryKey:["task-stats"],queryFn:()=>ht.getStats()}),{data:f}=fe({queryKey:["contract-cockpit"],queryFn:()=>He.getCockpit(),enabled:!e,staleTime:0}),{ownContracts:p,representedContracts:g}=N.useMemo(()=>{if(!n||!(d!=null&&d.data))return{ownContracts:[],representedContracts:[]};const D=[],z={};for(const C of d.data)if(C.customerId===(t==null?void 0:t.customerId))D.push(C);else{const _=C.customerId;if(!z[_]){const K=C.customer?C.customer.companyName||`${C.customer.firstName} ${C.customer.lastName}`:`Kunde ${_}`;z[_]={customerName:K,contracts:[]}}z[_].contracts.push(C)}return{ownContracts:D,representedContracts:Object.values(z).sort((C,_)=>C.customerName.localeCompare(_.customerName))}},[d==null?void 0:d.data,n,t==null?void 0:t.customerId]),x=N.useMemo(()=>p.filter(D=>D.status==="ACTIVE").length,[p]),y=N.useMemo(()=>p.filter(D=>D.status==="PENDING").length,[p]),v=N.useMemo(()=>p.filter(D=>D.status==="EXPIRED").length,[p]),b=N.useMemo(()=>g.reduce((D,z)=>D+z.contracts.length,0),[g]),j=N.useMemo(()=>g.reduce((D,z)=>D+z.contracts.filter(C=>C.status==="ACTIVE").length,0),[g]),k=N.useMemo(()=>g.reduce((D,z)=>D+z.contracts.filter(C=>C.status==="EXPIRED").length,0),[g]),E=((S=m==null?void 0:m.data)==null?void 0:S.openCount)||0,T=D=>i.jsx(Z,{className:D.link?"cursor-pointer hover:shadow-md transition-shadow":"",children:D.link?i.jsx(Me,{to:D.link,className:"block",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:`p-3 rounded-lg ${D.color}`,children:i.jsx(D.icon,{className:"w-6 h-6 text-white"})}),i.jsxs("div",{className:"ml-4",children:[i.jsx("p",{className:"text-sm text-gray-500",children:D.label}),i.jsx("p",{className:"text-2xl font-bold",children:D.value})]})]})}):i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:`p-3 rounded-lg ${D.color}`,children:i.jsx(D.icon,{className:"w-6 h-6 text-white"})}),i.jsxs("div",{className:"ml-4",children:[i.jsx("p",{className:"text-sm text-gray-500",children:D.label}),i.jsx("p",{className:"text-2xl font-bold",children:D.value})]})]})},D.label);return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("h1",{className:"text-2xl font-bold",children:["Willkommen, ",t==null?void 0:t.firstName,"!"]}),n&&o&&i.jsxs(I,{onClick:()=>r(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Support-Anfrage"]})]}),n?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(yo,{className:"w-5 h-5 text-blue-600"}),i.jsx("h2",{className:"text-lg font-semibold",children:"Meine Verträge"})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[T({label:"Eigene Verträge",value:p.length,icon:We,color:"bg-blue-500",link:"/contracts"}),T({label:"Davon aktiv",value:x,icon:Un,color:"bg-green-500"}),T({label:"Davon ausstehend",value:y,icon:cs,color:"bg-yellow-500"}),T({label:"Davon abgelaufen",value:v,icon:Bg,color:"bg-red-500"})]})]}),b>0&&i.jsxs("div",{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Ca,{className:"w-5 h-5 text-purple-600"}),i.jsx("h2",{className:"text-lg font-semibold",children:"Fremdverträge"})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[T({label:"Fremdverträge",value:b,icon:Ca,color:"bg-purple-500",link:"/contracts"}),T({label:"Davon aktiv",value:j,icon:Un,color:"bg-green-500"}),i.jsx("div",{className:"hidden lg:block"}),T({label:"Davon abgelaufen",value:k,icon:Bg,color:"bg-red-500"})]})]}),i.jsxs("div",{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Vc,{className:"w-5 h-5 text-orange-600"}),i.jsx("h2",{className:"text-lg font-semibold",children:"Support-Anfragen"})]}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:T({label:"Offene Anfragen",value:E,icon:Vc,color:"bg-orange-500",link:"/tasks"})})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6",children:[T({label:"Kunden",value:((M=c==null?void 0:c.pagination)==null?void 0:M.total)||0,icon:Ca,color:"bg-blue-500",link:"/customers"}),T({label:"Verträge gesamt",value:((F=d==null?void 0:d.pagination)==null?void 0:F.total)||0,icon:We,color:"bg-purple-500",link:"/contracts"}),T({label:"Aktive Verträge",value:((R=u==null?void 0:u.pagination)==null?void 0:R.total)||0,icon:Un,color:"bg-green-500"}),T({label:"Ausstehende Verträge",value:((V=h==null?void 0:h.pagination)==null?void 0:V.total)||0,icon:Tr,color:"bg-yellow-500"})]}),(f==null?void 0:f.data)&&i.jsxs("div",{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Tr,{className:"w-5 h-5 text-red-500"}),i.jsx("h2",{className:"text-lg font-semibold",children:"Vertrags-Cockpit"})]}),i.jsx(Me,{to:"/contracts/cockpit",className:"text-sm text-blue-600 hover:underline",children:"Alle anzeigen"})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[i.jsx(Z,{className:"cursor-pointer hover:shadow-md transition-shadow",children:i.jsx(Me,{to:"/contracts/cockpit?filter=critical",className:"block",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"p-3 rounded-lg bg-red-100",children:i.jsx(Tr,{className:"w-6 h-6 text-red-500"})}),i.jsxs("div",{className:"ml-4",children:[i.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",f.data.thresholds.criticalDays," Tage)"]}),i.jsx("p",{className:"text-2xl font-bold text-red-600",children:f.data.summary.criticalCount})]})]})})}),i.jsx(Z,{className:"cursor-pointer hover:shadow-md transition-shadow",children:i.jsx(Me,{to:"/contracts/cockpit?filter=warning",className:"block",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"p-3 rounded-lg bg-yellow-100",children:i.jsx(Mn,{className:"w-6 h-6 text-yellow-500"})}),i.jsxs("div",{className:"ml-4",children:[i.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",f.data.thresholds.warningDays," Tage)"]}),i.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:f.data.summary.warningCount})]})]})})}),i.jsx(Z,{className:"cursor-pointer hover:shadow-md transition-shadow",children:i.jsx(Me,{to:"/contracts/cockpit?filter=ok",className:"block",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"p-3 rounded-lg bg-green-100",children:i.jsx(Un,{className:"w-6 h-6 text-green-500"})}),i.jsxs("div",{className:"ml-4",children:[i.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",f.data.thresholds.okDays," Tage)"]}),i.jsx("p",{className:"text-2xl font-bold text-green-600",children:f.data.summary.okCount})]})]})})}),i.jsx(Z,{className:"cursor-pointer hover:shadow-md transition-shadow",children:i.jsx(Me,{to:"/contracts/cockpit",className:"block",children:i.jsxs("div",{className:"flex items-center",children:[i.jsx("div",{className:"p-3 rounded-lg bg-gray-100",children:i.jsx(We,{className:"w-6 h-6 text-gray-500"})}),i.jsxs("div",{className:"ml-4",children:[i.jsx("p",{className:"text-sm text-gray-500",children:"Handlungsbedarf"}),i.jsx("p",{className:"text-2xl font-bold text-gray-600",children:f.data.summary.totalContracts})]})]})})})]})]}),i.jsxs("div",{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(_c,{className:"w-5 h-5 text-orange-600"}),i.jsx("h2",{className:"text-lg font-semibold",children:"Aufgaben"})]}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:T({label:"Offene Aufgaben",value:E,icon:_c,color:"bg-orange-500",link:"/tasks"})})]})]}),n&&i.jsx(Y5,{isOpen:s,onClose:()=>r(!1)})]})}function Y5({isOpen:t,onClose:e}){const{user:n}=nt(),s=fn(),r=ye(),[a,l]=N.useState("own"),[o,c]=N.useState(null),[d,u]=N.useState(""),[h,m]=N.useState(""),[f,p]=N.useState(!1),[g,x]=N.useState(""),{data:y}=fe({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>He.getAll({customerId:n==null?void 0:n.customerId}),enabled:t}),v=N.useMemo(()=>{if(!(y!=null&&y.data))return{own:[],represented:{}};const w=[],S={};for(const M of y.data)if(M.customerId===(n==null?void 0:n.customerId))w.push(M);else{if(!S[M.customerId]){const F=M.customer?M.customer.companyName||`${M.customer.firstName} ${M.customer.lastName}`:`Kunde ${M.customerId}`;S[M.customerId]={name:F,contracts:[]}}S[M.customerId].contracts.push(M)}return{own:w,represented:S}},[y==null?void 0:y.data,n==null?void 0:n.customerId]),b=Object.keys(v.represented).length>0,j=N.useMemo(()=>{var w;return a==="own"?v.own:((w=v.represented[a])==null?void 0:w.contracts)||[]},[a,v]),k=N.useMemo(()=>{if(!g)return j;const w=g.toLowerCase();return j.filter(S=>S.contractNumber.toLowerCase().includes(w)||(S.providerName||"").toLowerCase().includes(w)||(S.tariffName||"").toLowerCase().includes(w))},[j,g]),E=async()=>{if(!(!o||!d.trim())){p(!0);try{await ht.createSupportTicket(o,{title:d.trim(),description:h.trim()||void 0}),r.invalidateQueries({queryKey:["task-stats"]}),r.invalidateQueries({queryKey:["all-tasks"]}),e(),u(""),m(""),c(null),l("own"),s(`/contracts/${o}`)}catch(w){console.error("Fehler beim Erstellen der Support-Anfrage:",w),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{p(!1)}}},T=()=>{u(""),m(""),c(null),l("own"),x(""),e()};return i.jsx(Xe,{isOpen:t,onClose:T,title:"Neue Support-Anfrage",children:i.jsxs("div",{className:"space-y-4",children:[b&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),i.jsxs("select",{value:a,onChange:w=>{const S=w.target.value;l(S==="own"?"own":parseInt(S)),c(null),x("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[i.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(v.represented).map(([w,{name:S}])=>i.jsx("option",{value:w,children:S},w))]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),i.jsx(q,{placeholder:"Vertrag suchen...",value:g,onChange:w=>x(w.target.value),className:"mb-2"}),i.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(w=>i.jsxs("div",{onClick:()=>c(w.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===w.id?"bg-blue-50 border-blue-200":""}`,children:[i.jsx("div",{className:"font-medium",children:w.contractNumber}),i.jsxs("div",{className:"text-sm text-gray-500",children:[w.providerName||"Kein Anbieter",w.tariffName&&` - ${w.tariffName}`]})]},w.id)):i.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),i.jsx(q,{value:d,onChange:w=>u(w.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),i.jsx("textarea",{value:h,onChange:w=>m(w.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:4,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(I,{variant:"secondary",onClick:T,children:"Abbrechen"}),i.jsx(I,{onClick:E,disabled:!o||!d.trim()||f,children:f?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function je({children:t,variant:e="default",className:n="",onClick:s}){const r={default:"bg-gray-100 text-gray-800",success:"bg-green-100 text-green-800",warning:"bg-yellow-100 text-yellow-800",danger:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800"};return i.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${r[e]} ${n}`,onClick:s,children:t})}function X5(){const[t,e]=N.useState(""),[n,s]=N.useState(""),[r,a]=N.useState(1),{hasPermission:l}=nt(),{data:o,isLoading:c}=fe({queryKey:["customers",t,n,r],queryFn:()=>Zt.getAll({search:t,type:n||void 0,page:r,limit:20})});return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsx("h1",{className:"text-2xl font-bold",children:"Kunden"}),l("customers:create")&&i.jsx(Me,{to:"/customers/new",children:i.jsxs(I,{children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Neuer Kunde"]})})]}),i.jsx(Z,{className:"mb-6",children:i.jsxs("div",{className:"flex gap-2 items-center",children:[i.jsx(q,{placeholder:"Suchen...",value:t,onChange:d=>e(d.target.value),className:"flex-1"}),i.jsxs("select",{value:n,onChange:d=>s(d.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg w-28 flex-shrink-0",children:[i.jsx("option",{value:"",children:"Alle"}),i.jsx("option",{value:"PRIVATE",children:"Privat"}),i.jsx("option",{value:"BUSINESS",children:"Firma"})]}),i.jsx(I,{variant:"secondary",className:"flex-shrink-0",children:i.jsx(jd,{className:"w-4 h-4"})})]})}),i.jsx(Z,{children:c?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):o!=null&&o.data&&o.data.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kundennr."}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Verträge"}),i.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),i.jsx("tbody",{children:o.data.map(d=>{var u;return i.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[i.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:d.customerNumber}),i.jsx("td",{className:"py-3 px-4",children:d.type==="BUSINESS"&&d.companyName?d.companyName:`${d.firstName} ${d.lastName}`}),i.jsx("td",{className:"py-3 px-4",children:i.jsx(je,{variant:d.type==="BUSINESS"?"info":"default",children:d.type==="BUSINESS"?"Firma":"Privat"})}),i.jsx("td",{className:"py-3 px-4",children:d.email||"-"}),i.jsx("td",{className:"py-3 px-4",children:((u=d._count)==null?void 0:u.contracts)||0}),i.jsx("td",{className:"py-3 px-4 text-right",children:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Me,{to:`/customers/${d.id}`,children:i.jsx(I,{variant:"ghost",size:"sm",children:i.jsx(Oe,{className:"w-4 h-4"})})}),l("customers:update")&&i.jsx(Me,{to:`/customers/${d.id}/edit`,children:i.jsx(I,{variant:"ghost",size:"sm",children:i.jsx(rt,{className:"w-4 h-4"})})})]})})]},d.id)})})]})}),o.pagination&&o.pagination.totalPages>1&&i.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[i.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",o.pagination.page," von ",o.pagination.totalPages," (",o.pagination.total," Einträge)"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>a(d=>Math.max(1,d-1)),disabled:r===1,children:"Zurück"}),i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>a(d=>d+1),disabled:r>=o.pagination.totalPages,children:"Weiter"})]})]})]}):i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kunden gefunden."})})]})}function eR({emails:t,selectedEmailId:e,onSelectEmail:n,onEmailDeleted:s,isLoading:r,folder:a="INBOX",accountId:l}){const o=a==="SENT",[c,d]=N.useState(null),{hasPermission:u}=nt(),h=S=>{if(o)try{const M=JSON.parse(S.toAddresses);if(M.length>0)return`An: ${M[0]}${M.length>1?` (+${M.length-1})`:""}`}catch{return"An: (Unbekannt)"}return S.fromName||S.fromAddress},m=ye(),f=G({mutationFn:S=>Be.toggleStar(S),onSuccess:(S,M)=>{m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["email",M]})}}),p=G({mutationFn:({emailId:S,isRead:M})=>Be.markAsRead(S,M),onSuccess:(S,M)=>{m.invalidateQueries({queryKey:["emails"]}),m.invalidateQueries({queryKey:["email",M.emailId]}),l&&m.invalidateQueries({queryKey:["folder-counts",l]})}}),g=G({mutationFn:S=>Be.delete(S),onSuccess:(S,M)=>{m.invalidateQueries({queryKey:["emails"]}),l&&m.invalidateQueries({queryKey:["folder-counts",l]}),Ue.success("E-Mail in Papierkorb verschoben"),d(null),s==null||s(M)},onError:S=>{console.error("Delete error:",S),Ue.error(S.message||"Fehler beim Löschen der E-Mail"),d(null)}}),x=G({mutationFn:S=>Be.unassignFromContract(S),onSuccess:()=>{m.invalidateQueries({queryKey:["emails"]}),Ue.success("Vertragszuordnung aufgehoben")},onError:S=>{console.error("Unassign error:",S),Ue.error(S.message||"Fehler beim Aufheben der Zuordnung")}}),y=(S,M)=>{S.stopPropagation(),x.mutate(M)},v=(S,M)=>{S.stopPropagation(),d(M)},b=S=>{S.stopPropagation(),c&&g.mutate(c)},j=S=>{S.stopPropagation(),d(null)},k=S=>{const M=new Date(S),F=new Date;return M.toDateString()===F.toDateString()?M.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):M.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},E=(S,M)=>{S.stopPropagation(),f.mutate(M)},T=(S,M)=>{S.stopPropagation(),p.mutate({emailId:M.id,isRead:!M.isRead})},w=S=>{S.isRead||p.mutate({emailId:S.id,isRead:!0}),n(S)};return r?i.jsx("div",{className:"flex items-center justify-center h-64",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):t.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[i.jsx(Fs,{className:"w-12 h-12 mb-2 opacity-50"}),i.jsx("p",{children:"Keine E-Mails vorhanden"})]}):i.jsxs("div",{className:"divide-y divide-gray-200",children:[t.map(S=>i.jsxs("div",{onClick:()=>w(S),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",e===S.id?"bg-blue-100":["hover:bg-gray-100",S.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:e===S.id?"4px solid #2563eb":"4px solid transparent"},children:[i.jsx("button",{onClick:M=>T(M,S),className:`
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
${S.isRead?"text-gray-400":"text-blue-600"}
`,title:S.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:S.isRead?i.jsx(NC,{className:"w-4 h-4"}):i.jsx(Fs,{className:"w-4 h-4"})}),i.jsx("button",{onClick:M=>E(M,S.id),className:`
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
${S.isStarred?"text-yellow-500":"text-gray-400"}
`,title:S.isStarred?"Stern entfernen":"Als wichtig markieren",children:i.jsx(By,{className:`w-4 h-4 ${S.isStarred?"fill-current":""}`})}),u("emails:delete")&&i.jsx("button",{onClick:M=>v(M,S.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"E-Mail löschen",children:i.jsx(Ee,{className:"w-4 h-4"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[i.jsx("span",{className:`text-sm truncate ${S.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:h(S)}),i.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:k(S.receivedAt)})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`text-sm truncate ${S.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:S.subject||"(Kein Betreff)"}),S.hasAttachments&&i.jsx(Of,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),S.contract&&i.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[i.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:S.contract.contractNumber}),(a==="INBOX"||a==="SENT"&&!S.isAutoAssigned)&&i.jsx("button",{onClick:M=>y(M,S.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:x.isPending,children:i.jsx(nn,{className:"w-3.5 h-3.5"})})]})]}),i.jsx(At,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},S.id)),c&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),i.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(I,{variant:"secondary",onClick:j,disabled:g.isPending,children:"Abbrechen"}),i.jsx(I,{variant:"danger",onClick:b,disabled:g.isPending,children:g.isPending?"Löschen...":"Löschen"})]})]})})]})}const Fe=N.forwardRef(({className:t="",label:e,error:n,options:s,id:r,placeholder:a="Bitte wählen...",...l},o)=>{const c=r||l.name,d=/\bw-\d+\b|\bw-\[|\bflex-/.test(t);return i.jsxs("div",{className:d?t:"w-full",children:[e&&i.jsx("label",{htmlFor:c,className:"block text-sm font-medium text-gray-700 mb-1",children:e}),i.jsxs("select",{ref:o,id:c,className:`block w-full px-3 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${n?"border-red-500":"border-gray-300"}`,...l,children:[i.jsx("option",{value:"",children:a}),s.map(u=>i.jsx("option",{value:u.value,children:u.label},u.value))]}),n&&i.jsx("p",{className:"mt-1 text-sm text-red-600",children:n})]})});Fe.displayName="Select";function tR({isOpen:t,onClose:e,emailId:n,attachmentFilename:s,onSuccess:r}){var F,R,V;const[a,l]=N.useState(null),[o,c]=N.useState(new Set(["customer"])),[d,u]=N.useState("document"),[h,m]=N.useState({invoiceDate:new Date().toISOString().split("T")[0],invoiceType:"INTERIM",notes:""}),f=ye(),{data:p,isLoading:g,error:x}=fe({queryKey:["attachment-targets",n],queryFn:()=>Be.getAttachmentTargets(n),enabled:t}),y=p==null?void 0:p.data,v=((F=y==null?void 0:y.contract)==null?void 0:F.type)==="ELECTRICITY"||((R=y==null?void 0:y.contract)==null?void 0:R.type)==="GAS",b=G({mutationFn:()=>{if(!a)throw new Error("Kein Ziel ausgewählt");return Be.saveAttachmentTo(n,s,{entityType:a.entityType,entityId:a.entityId,targetKey:a.targetKey})},onSuccess:()=>{var D,z;Ue.success("Anhang gespeichert"),f.invalidateQueries({queryKey:["attachment-targets",n]}),f.invalidateQueries({queryKey:["customers"]}),f.invalidateQueries({queryKey:["contracts"]}),(D=y==null?void 0:y.customer)!=null&&D.id&&f.invalidateQueries({queryKey:["customer",y.customer.id.toString()]}),(z=y==null?void 0:y.contract)!=null&&z.id&&f.invalidateQueries({queryKey:["contract",y.contract.id.toString()]}),r==null||r(),k()},onError:D=>{Ue.error(D.message||"Fehler beim Speichern")}}),j=G({mutationFn:()=>Be.saveAttachmentAsInvoice(n,s,{invoiceDate:h.invoiceDate,invoiceType:h.invoiceType,notes:h.notes||void 0}),onSuccess:()=>{var D;Ue.success("Anhang als Rechnung gespeichert"),f.invalidateQueries({queryKey:["attachment-targets",n]}),f.invalidateQueries({queryKey:["customers"]}),f.invalidateQueries({queryKey:["contracts"]}),(D=y==null?void 0:y.contract)!=null&&D.id&&f.invalidateQueries({queryKey:["contract",y.contract.id.toString()]}),r==null||r(),k()},onError:D=>{Ue.error(D.message||"Fehler beim Speichern der Rechnung")}}),k=()=>{l(null),u("document"),m({invoiceDate:new Date().toISOString().split("T")[0],invoiceType:"INTERIM",notes:""}),e()},E=D=>{const z=new Set(o);z.has(D)?z.delete(D):z.add(D),c(z)},T=(D,z,C,_)=>{l({entityType:D,entityId:C,targetKey:z.key,hasDocument:z.hasDocument,label:_?`${_} → ${z.label}`:z.label})},w=(D,z,C,_)=>D.map(K=>{const B=(a==null?void 0:a.entityType)===z&&(a==null?void 0:a.entityId)===C&&(a==null?void 0:a.targetKey)===K.key;return i.jsxs("div",{onClick:()=>T(z,K,C,_),className:`
flex items-center gap-3 p-3 cursor-pointer transition-colors rounded-lg ml-4
${B?"bg-blue-100 ring-2 ring-blue-500":"hover:bg-gray-100"}
`,children:[i.jsx("div",{className:"flex-1 min-w-0",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-medium text-gray-900",children:K.label}),K.hasDocument&&i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-yellow-100 text-yellow-800",children:[i.jsx(Mn,{className:"w-3 h-3"}),"Vorhanden"]})]})}),B&&i.jsx(Vr,{className:"w-5 h-5 text-blue-600"})]},K.key)}),S=(D,z)=>i.jsxs("div",{className:"mb-2",children:[i.jsx("div",{className:"text-sm font-medium text-gray-700 px-3 py-1 bg-gray-50 rounded",children:D.label}),w(D.slots,z,D.id,D.label)]},D.id),M=(D,z,C,_,K=!1)=>{const B=o.has(z);return i.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[i.jsxs("button",{onClick:()=>E(z),className:"w-full flex items-center gap-2 p-3 bg-gray-50 hover:bg-gray-100 transition-colors",children:[B?i.jsx(Us,{className:"w-4 h-4 text-gray-500"}):i.jsx(At,{className:"w-4 h-4 text-gray-500"}),C,i.jsx("span",{className:"font-medium text-gray-900",children:D})]}),B&&i.jsx("div",{className:"p-2",children:K?i.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"Keine Einträge vorhanden"}):_})]})};return i.jsx(Xe,{isOpen:t,onClose:k,title:"Anhang speichern unter",size:"lg",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"p-3 bg-gray-50 rounded-lg",children:i.jsxs("p",{className:"text-sm text-gray-600",children:[i.jsx("span",{className:"font-medium",children:"Datei:"})," ",s]})}),g&&i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}),x&&i.jsx("div",{className:"p-4 bg-red-50 text-red-700 rounded-lg",children:"Fehler beim Laden der Dokumentziele"}),y&&i.jsxs(i.Fragment,{children:[v&&i.jsxs("div",{className:"flex gap-2 p-1 bg-gray-100 rounded-lg",children:[i.jsxs("button",{onClick:()=>u("document"),className:`flex-1 flex items-center justify-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors ${d==="document"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(We,{className:"w-4 h-4"}),"Als Dokument"]}),i.jsxs("button",{onClick:()=>u("invoice"),className:`flex-1 flex items-center justify-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors ${d==="invoice"?"bg-white text-green-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(Fy,{className:"w-4 h-4"}),"Als Rechnung"]})]}),d==="document"&&i.jsxs("div",{className:"space-y-3 max-h-96 overflow-auto",children:[M(`Kunde: ${y.customer.name}`,"customer",i.jsx(yo,{className:"w-4 h-4 text-blue-600"}),w(y.customer.slots,"customer"),y.customer.slots.length===0),M("Ausweisdokumente","identityDocuments",i.jsx(jC,{className:"w-4 h-4 text-green-600"}),y.identityDocuments.map(D=>S(D,"identityDocument")),y.identityDocuments.length===0),M("Bankkarten","bankCards",i.jsx(Ry,{className:"w-4 h-4 text-purple-600"}),y.bankCards.map(D=>S(D,"bankCard")),y.bankCards.length===0),y.contract&&M(`Vertrag: ${y.contract.contractNumber}`,"contract",i.jsx(We,{className:"w-4 h-4 text-orange-600"}),w(y.contract.slots,"contract"),y.contract.slots.length===0),!y.contract&&i.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg text-sm text-gray-600",children:[i.jsx(We,{className:"w-4 h-4 inline-block mr-2 text-gray-400"}),"E-Mail ist keinem Vertrag zugeordnet. Ordnen Sie die E-Mail einem Vertrag zu, um Vertragsdokumente als Ziel auswählen zu können."]})]}),d==="invoice"&&v&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"p-3 bg-green-50 rounded-lg",children:i.jsxs("p",{className:"text-sm text-green-700",children:["Der Anhang wird als Rechnung für den Vertrag ",i.jsx("strong",{children:(V=y.contract)==null?void 0:V.contractNumber})," gespeichert."]})}),i.jsx(q,{label:"Rechnungsdatum",type:"date",value:h.invoiceDate,onChange:D=>m({...h,invoiceDate:D.target.value}),required:!0}),i.jsx(Fe,{label:"Rechnungstyp",value:h.invoiceType,onChange:D=>m({...h,invoiceType:D.target.value}),options:[{value:"INTERIM",label:"Zwischenrechnung"},{value:"FINAL",label:"Schlussrechnung"}]}),i.jsx(q,{label:"Notizen (optional)",value:h.notes,onChange:D=>m({...h,notes:D.target.value}),placeholder:"Optionale Anmerkungen..."})]})]}),d==="document"&&(a==null?void 0:a.hasDocument)&&i.jsxs("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg flex items-start gap-2",children:[i.jsx(Mn,{className:"w-5 h-5 text-yellow-600 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-sm text-yellow-800",children:[i.jsx("strong",{children:"Achtung:"})," An diesem Feld ist bereits ein Dokument hinterlegt. Das vorhandene Dokument wird durch den neuen Anhang ersetzt."]})]}),i.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[i.jsx(I,{variant:"secondary",onClick:k,children:"Abbrechen"}),d==="document"?i.jsx(I,{onClick:()=>b.mutate(),disabled:!a||b.isPending||j.isPending,children:b.isPending?"Wird gespeichert...":"Speichern"}):i.jsx(I,{onClick:()=>j.mutate(),disabled:!h.invoiceDate||b.isPending||j.isPending,children:j.isPending?"Wird gespeichert...":"Als Rechnung speichern"})]})]})})}function nR({isOpen:t,onClose:e,emailId:n,onSuccess:s}){var F,R,V;const[r,a]=N.useState(null),[l,o]=N.useState(new Set(["customer"])),[c,d]=N.useState("document"),[u,h]=N.useState({invoiceDate:new Date().toISOString().split("T")[0],invoiceType:"INTERIM",notes:""}),m=ye(),{data:f,isLoading:p,error:g}=fe({queryKey:["attachment-targets",n],queryFn:()=>Be.getAttachmentTargets(n),enabled:t}),x=f==null?void 0:f.data,y=((F=x==null?void 0:x.contract)==null?void 0:F.type)==="ELECTRICITY"||((R=x==null?void 0:x.contract)==null?void 0:R.type)==="GAS",v=G({mutationFn:()=>{if(!r)throw new Error("Kein Ziel ausgewählt");return Be.saveEmailAsPdf(n,{entityType:r.entityType,entityId:r.entityId,targetKey:r.targetKey})},onSuccess:()=>{var D,z;Ue.success("E-Mail als PDF gespeichert"),m.invalidateQueries({queryKey:["attachment-targets",n]}),m.invalidateQueries({queryKey:["customers"]}),m.invalidateQueries({queryKey:["contracts"]}),(D=x==null?void 0:x.customer)!=null&&D.id&&m.invalidateQueries({queryKey:["customer",x.customer.id.toString()]}),(z=x==null?void 0:x.contract)!=null&&z.id&&m.invalidateQueries({queryKey:["contract",x.contract.id.toString()]}),s==null||s(),j()},onError:D=>{Ue.error(D.message||"Fehler beim Speichern")}}),b=G({mutationFn:()=>Be.saveEmailAsInvoice(n,{invoiceDate:u.invoiceDate,invoiceType:u.invoiceType,notes:u.notes||void 0}),onSuccess:()=>{var D;Ue.success("E-Mail als Rechnung gespeichert"),m.invalidateQueries({queryKey:["attachment-targets",n]}),m.invalidateQueries({queryKey:["customers"]}),m.invalidateQueries({queryKey:["contracts"]}),(D=x==null?void 0:x.contract)!=null&&D.id&&m.invalidateQueries({queryKey:["contract",x.contract.id.toString()]}),s==null||s(),j()},onError:D=>{Ue.error(D.message||"Fehler beim Speichern der Rechnung")}}),j=()=>{a(null),d("document"),h({invoiceDate:new Date().toISOString().split("T")[0],invoiceType:"INTERIM",notes:""}),e()},k=D=>{const z=new Set(l);z.has(D)?z.delete(D):z.add(D),o(z)},E=(D,z,C,_)=>{a({entityType:D,entityId:C,targetKey:z.key,hasDocument:z.hasDocument,label:_?`${_} → ${z.label}`:z.label})},T=(D,z,C,_)=>D.map(K=>{const B=(r==null?void 0:r.entityType)===z&&(r==null?void 0:r.entityId)===C&&(r==null?void 0:r.targetKey)===K.key;return i.jsxs("div",{onClick:()=>E(z,K,C,_),className:`
flex items-center gap-3 p-3 cursor-pointer transition-colors rounded-lg ml-4
${B?"bg-blue-100 ring-2 ring-blue-500":"hover:bg-gray-100"}
`,children:[i.jsx("div",{className:"flex-1 min-w-0",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-medium text-gray-900",children:K.label}),K.hasDocument&&i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-yellow-100 text-yellow-800",children:[i.jsx(Mn,{className:"w-3 h-3"}),"Vorhanden"]})]})}),B&&i.jsx(Vr,{className:"w-5 h-5 text-blue-600"})]},K.key)}),w=(D,z)=>i.jsxs("div",{className:"mb-2",children:[i.jsx("div",{className:"text-sm font-medium text-gray-700 px-3 py-1 bg-gray-50 rounded",children:D.label}),T(D.slots,z,D.id,D.label)]},D.id),S=(D,z,C,_,K=!1)=>{const B=l.has(z);return i.jsxs("div",{className:"border border-gray-200 rounded-lg overflow-hidden",children:[i.jsxs("button",{onClick:()=>k(z),className:"w-full flex items-center gap-2 p-3 bg-gray-50 hover:bg-gray-100 transition-colors",children:[B?i.jsx(Us,{className:"w-4 h-4 text-gray-500"}):i.jsx(At,{className:"w-4 h-4 text-gray-500"}),C,i.jsx("span",{className:"font-medium text-gray-900",children:D})]}),B&&i.jsx("div",{className:"p-2",children:K?i.jsx("p",{className:"text-sm text-gray-500 text-center py-4",children:"Keine Einträge vorhanden"}):_})]})},M=v.isPending||b.isPending;return i.jsx(Xe,{isOpen:t,onClose:j,title:"E-Mail als PDF speichern",size:"lg",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"p-3 bg-blue-50 rounded-lg",children:i.jsx("p",{className:"text-sm text-blue-700",children:"Die E-Mail wird als PDF exportiert (inkl. Absender, Empfänger, Datum und Inhalt) und im gewählten Dokumentenfeld gespeichert."})}),p&&i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}),g&&i.jsx("div",{className:"p-4 bg-red-50 text-red-700 rounded-lg",children:"Fehler beim Laden der Dokumentziele"}),x&&i.jsxs(i.Fragment,{children:[y&&i.jsxs("div",{className:"flex gap-2 p-1 bg-gray-100 rounded-lg",children:[i.jsxs("button",{onClick:()=>d("document"),className:`flex-1 flex items-center justify-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors ${c==="document"?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(We,{className:"w-4 h-4"}),"Als Dokument"]}),i.jsxs("button",{onClick:()=>d("invoice"),className:`flex-1 flex items-center justify-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-colors ${c==="invoice"?"bg-white text-green-600 shadow-sm":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(Fy,{className:"w-4 h-4"}),"Als Rechnung"]})]}),c==="document"&&i.jsxs("div",{className:"space-y-3 max-h-96 overflow-auto",children:[S(`Kunde: ${x.customer.name}`,"customer",i.jsx(yo,{className:"w-4 h-4 text-blue-600"}),T(x.customer.slots,"customer"),x.customer.slots.length===0),S("Ausweisdokumente","identityDocuments",i.jsx(jC,{className:"w-4 h-4 text-green-600"}),x.identityDocuments.map(D=>w(D,"identityDocument")),x.identityDocuments.length===0),S("Bankkarten","bankCards",i.jsx(Ry,{className:"w-4 h-4 text-purple-600"}),x.bankCards.map(D=>w(D,"bankCard")),x.bankCards.length===0),x.contract&&S(`Vertrag: ${x.contract.contractNumber}`,"contract",i.jsx(We,{className:"w-4 h-4 text-orange-600"}),T(x.contract.slots,"contract"),x.contract.slots.length===0),!x.contract&&i.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg text-sm text-gray-600",children:[i.jsx(We,{className:"w-4 h-4 inline-block mr-2 text-gray-400"}),"E-Mail ist keinem Vertrag zugeordnet. Ordnen Sie die E-Mail einem Vertrag zu, um Vertragsdokumente als Ziel auswählen zu können."]})]}),c==="invoice"&&y&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"p-3 bg-green-50 rounded-lg",children:i.jsxs("p",{className:"text-sm text-green-700",children:["Die E-Mail wird als Rechnung für den Vertrag ",i.jsx("strong",{children:(V=x.contract)==null?void 0:V.contractNumber})," gespeichert."]})}),i.jsx(q,{label:"Rechnungsdatum",type:"date",value:u.invoiceDate,onChange:D=>h({...u,invoiceDate:D.target.value}),required:!0}),i.jsx(Fe,{label:"Rechnungstyp",value:u.invoiceType,onChange:D=>h({...u,invoiceType:D.target.value}),options:[{value:"INTERIM",label:"Zwischenrechnung"},{value:"FINAL",label:"Schlussrechnung"}]}),i.jsx(q,{label:"Notizen (optional)",value:u.notes,onChange:D=>h({...u,notes:D.target.value}),placeholder:"Optionale Anmerkungen..."})]})]}),c==="document"&&(r==null?void 0:r.hasDocument)&&i.jsxs("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg flex items-start gap-2",children:[i.jsx(Mn,{className:"w-5 h-5 text-yellow-600 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-sm text-yellow-800",children:[i.jsx("strong",{children:"Achtung:"})," An diesem Feld ist bereits ein Dokument hinterlegt. Das vorhandene Dokument wird durch die PDF ersetzt."]})]}),i.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[i.jsx(I,{variant:"secondary",onClick:j,children:"Abbrechen"}),c==="document"?i.jsx(I,{onClick:()=>v.mutate(),disabled:!r||M,children:M?"Wird erstellt...":"Als PDF speichern"}):i.jsx(I,{onClick:()=>b.mutate(),disabled:!u.invoiceDate||M,children:M?"Wird erstellt...":"Als Rechnung speichern"})]})]})})}function DC({email:t,onReply:e,onAssignContract:n,onDeleted:s,isSentFolder:r=!1,isContractView:a=!1,isTrashView:l=!1,onRestored:o,accountId:c}){const[d,u]=N.useState(!0),[h,m]=N.useState(t.isStarred),[f,p]=N.useState(!1),[g,x]=N.useState(!1),[y,v]=N.useState(!1),[b,j]=N.useState(null),[k,E]=N.useState(!1),T=ye(),{hasPermission:w}=nt();N.useEffect(()=>{m(t.isStarred)},[t.id,t.isStarred]);const S=G({mutationFn:()=>Be.toggleStar(t.id),onMutate:()=>{m(W=>!W)},onSuccess:()=>{T.invalidateQueries({queryKey:["emails"]}),T.invalidateQueries({queryKey:["email",t.id]})},onError:()=>{m(t.isStarred)}}),M=G({mutationFn:()=>Be.unassignFromContract(t.id),onSuccess:()=>{T.invalidateQueries({queryKey:["emails"]}),T.invalidateQueries({queryKey:["email",t.id]}),t.contractId&&T.invalidateQueries({queryKey:["contract-folder-counts",t.contractId]}),Ue.success("Vertragszuordnung aufgehoben")},onError:W=>{console.error("Unassign error:",W),Ue.error(W.message||"Fehler beim Aufheben der Zuordnung")}}),F=G({mutationFn:()=>Be.delete(t.id),onSuccess:()=>{T.invalidateQueries({queryKey:["emails"]}),c&&T.invalidateQueries({queryKey:["folder-counts",c]}),t.contractId&&T.invalidateQueries({queryKey:["contract-folder-counts",t.contractId]}),Ue.success("E-Mail in Papierkorb verschoben"),p(!1),s==null||s()},onError:W=>{console.error("Delete error:",W),Ue.error(W.message||"Fehler beim Löschen der E-Mail"),p(!1)}}),R=G({mutationFn:()=>Be.restore(t.id),onSuccess:()=>{T.invalidateQueries({queryKey:["emails"]}),c&&T.invalidateQueries({queryKey:["folder-counts",c]}),t.contractId&&T.invalidateQueries({queryKey:["contract-folder-counts",t.contractId]}),Ue.success("E-Mail wiederhergestellt"),x(!1),o==null||o()},onError:W=>{console.error("Restore error:",W),Ue.error(W.message||"Fehler beim Wiederherstellen der E-Mail"),x(!1)}}),V=G({mutationFn:()=>Be.permanentDelete(t.id),onSuccess:()=>{T.invalidateQueries({queryKey:["emails"]}),c&&T.invalidateQueries({queryKey:["folder-counts",c]}),Ue.success("E-Mail endgültig gelöscht"),v(!1),s==null||s()},onError:W=>{console.error("Permanent delete error:",W),Ue.error(W.message||"Fehler beim endgültigen Löschen der E-Mail"),v(!1)}}),D=W=>new Date(W).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),z=W=>{try{return JSON.parse(W)}catch{return[]}},C=W=>{if(!W)return[];try{return JSON.parse(W)}catch{return[]}},_=z(t.toAddresses),K=t.ccAddresses?z(t.ccAddresses):[],B=C(t.attachmentNames);return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"p-4 border-b border-gray-200 space-y-3",children:[i.jsxs("div",{className:"flex items-start justify-between gap-4",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:t.subject||"(Kein Betreff)"}),i.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:l?i.jsxs(i.Fragment,{children:[i.jsxs(I,{variant:"secondary",size:"sm",onClick:()=>x(!0),title:"Wiederherstellen",children:[i.jsx(AC,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),i.jsxs(I,{variant:"danger",size:"sm",onClick:()=>v(!0),title:"Endgültig löschen",children:[i.jsx(Ee,{className:"w-4 h-4 mr-1"}),"Endgültig löschen"]})]}):i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>S.mutate(),className:`p-2 rounded-lg hover:bg-gray-100 ${h?"text-yellow-500":"text-gray-400"}`,title:h?"Stern entfernen":"Als wichtig markieren",children:i.jsx(By,{className:`w-5 h-5 ${h?"fill-current":""}`})}),i.jsxs(I,{variant:"secondary",size:"sm",onClick:e,children:[i.jsx(z5,{className:"w-4 h-4 mr-1"}),"Antworten"]}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>E(!0),title:"E-Mail als PDF speichern",children:i.jsx(yC,{className:"w-4 h-4"})}),w("emails:delete")&&i.jsx(I,{variant:"danger",size:"sm",onClick:()=>p(!0),title:"E-Mail löschen",children:i.jsx(Ee,{className:"w-4 h-4"})})]})})]}),i.jsxs("div",{className:"text-sm space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-gray-500 w-12",children:"Von:"}),i.jsxs("span",{className:"font-medium text-gray-900",children:[t.fromName&&`${t.fromName} `,i.jsxs("span",{className:"text-gray-600",children:["<",t.fromAddress,">"]})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-gray-500 w-12",children:"An:"}),i.jsx("span",{className:"text-gray-700",children:_.join(", ")})]}),K.length>0&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-gray-500 w-12",children:"CC:"}),i.jsx("span",{className:"text-gray-700",children:K.join(", ")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-gray-500 w-12",children:"Am:"}),i.jsx("span",{className:"text-gray-700",children:D(t.receivedAt)})]})]}),i.jsx("div",{className:"flex items-center gap-2 pt-2",children:t.contract?i.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-50 border border-green-200 rounded-lg",children:[i.jsx(C1,{className:"w-4 h-4 text-green-600"}),i.jsxs("span",{className:"text-sm text-green-800",children:["Zugeordnet zu:"," ",i.jsx(Me,{to:`/contracts/${t.contract.id}`,className:"font-medium hover:underline",children:t.contract.contractNumber})]}),!t.isAutoAssigned&&i.jsx("button",{onClick:()=>M.mutate(),className:"ml-2 p-1 hover:bg-green-100 rounded",title:"Zuordnung aufheben",children:i.jsx(nn,{className:"w-4 h-4 text-green-600"})})]}):!a&&i.jsxs(I,{variant:"secondary",size:"sm",onClick:n,children:[i.jsx(C1,{className:"w-4 h-4 mr-1"}),"Vertrag zuordnen"]})}),B.length>0&&i.jsxs("div",{className:"pt-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(Of,{className:"w-4 h-4 text-gray-400"}),i.jsxs("span",{className:"text-sm text-gray-500",children:[B.length," Anhang",B.length>1?"e":""]})]}),i.jsx("div",{className:"flex flex-wrap gap-2",children:B.map((W,ce)=>i.jsxs("div",{className:"inline-flex items-center gap-1 px-3 py-2 bg-gray-100 rounded-lg text-sm text-gray-700",children:[i.jsx("span",{className:"max-w-[200px] truncate mr-1",children:W}),i.jsx("a",{href:Be.getAttachmentUrl(t.id,W,!0),target:"_blank",rel:"noopener noreferrer",className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${W} öffnen`,children:i.jsx(Oy,{className:"w-4 h-4 text-gray-500"})}),i.jsx("a",{href:Be.getAttachmentUrl(t.id,W),download:W,className:"p-1 hover:bg-gray-200 rounded transition-colors",title:`${W} herunterladen`,children:i.jsx(qn,{className:"w-4 h-4 text-gray-500"})}),!l&&i.jsx("button",{onClick:()=>j(W),className:"p-1 hover:bg-blue-100 rounded transition-colors",title:`${W} speichern unter...`,children:i.jsx(zy,{className:"w-4 h-4 text-blue-500"})})]},ce))})]})]}),t.htmlBody&&t.textBody&&i.jsxs("div",{className:"px-4 py-2 border-b border-gray-200 flex items-center gap-2",children:[i.jsx("button",{onClick:()=>u(!0),className:`px-3 py-1 text-sm rounded ${d?"bg-blue-100 text-blue-700":"text-gray-600 hover:bg-gray-100"}`,children:"HTML"}),i.jsx("button",{onClick:()=>u(!1),className:`px-3 py-1 text-sm rounded ${d?"text-gray-600 hover:bg-gray-100":"bg-blue-100 text-blue-700"}`,children:"Text"})]}),i.jsx("div",{className:"flex-1 overflow-auto p-4",children:d&&t.htmlBody?i.jsx("div",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:t.htmlBody}}):i.jsx("pre",{className:"whitespace-pre-wrap text-sm text-gray-700 font-sans",children:t.textBody||"Kein Inhalt"})}),f&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),i.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(I,{variant:"secondary",onClick:()=>p(!1),disabled:F.isPending,children:"Abbrechen"}),i.jsx(I,{variant:"danger",onClick:()=>F.mutate(),disabled:F.isPending,children:F.isPending?"Löschen...":"Löschen"})]})]})}),g&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail wiederherstellen?"}),i.jsxs("p",{className:"text-gray-600 mb-4",children:["Die E-Mail wird wieder in den ursprünglichen Ordner (",t.folder==="SENT"?"Gesendet":"Posteingang",") verschoben."]}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(I,{variant:"secondary",onClick:()=>x(!1),disabled:R.isPending,children:"Abbrechen"}),i.jsx(I,{variant:"primary",onClick:()=>R.mutate(),disabled:R.isPending,children:R.isPending?"Wird wiederhergestellt...":"Wiederherstellen"})]})]})}),y&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail endgültig löschen?"}),i.jsx("p",{className:"text-gray-600 mb-4",children:"Diese Aktion kann nicht rückgängig gemacht werden. Die E-Mail wird unwiderruflich gelöscht."}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(I,{variant:"secondary",onClick:()=>v(!1),disabled:V.isPending,children:"Abbrechen"}),i.jsx(I,{variant:"danger",onClick:()=>V.mutate(),disabled:V.isPending,children:V.isPending?"Wird gelöscht...":"Endgültig löschen"})]})]})}),b&&i.jsx(tR,{isOpen:!0,onClose:()=>j(null),emailId:t.id,attachmentFilename:b}),k&&i.jsx(nR,{isOpen:!0,onClose:()=>E(!1),emailId:t.id})]})}function MC({isOpen:t,onClose:e,account:n,replyTo:s,onSuccess:r,contractId:a}){const[l,o]=N.useState(""),[c,d]=N.useState(""),[u,h]=N.useState(""),[m,f]=N.useState(""),[p,g]=N.useState([]),[x,y]=N.useState(null),v=N.useRef(null);N.useEffect(()=>{if(t){if(s){o(s.fromAddress||"");const R=s.subject||"",V=/^(Re|Aw|Fwd|Wg):\s*/i.test(R);h(V?R:`Re: ${R}`);const D=new Date(s.receivedAt).toLocaleString("de-DE"),z=s.textBody?`
--- Ursprüngliche Nachricht ---
Von: ${s.fromName||s.fromAddress}
Am: ${D}
${s.textBody}`:"";f(z)}else o(""),h(""),f("");d(""),g([]),y(null)}},[t,s]);const b=10*1024*1024,j=25*1024*1024,k=R=>new Promise((V,D)=>{const z=new FileReader;z.readAsDataURL(R),z.onload=()=>{const _=z.result.split(",")[1];V(_)},z.onerror=D}),E=async R=>{const V=R.target.files;if(!V)return;const D=[];let z=p.reduce((C,_)=>C+_.content.length*.75,0);for(const C of Array.from(V)){if(C.size>b){y(`Datei "${C.name}" ist zu groß (max. 10 MB)`);continue}if(z+C.size>j){y("Maximale Gesamtgröße der Anhänge erreicht (25 MB)");break}try{const _=await k(C);D.push({filename:C.name,content:_,contentType:C.type||"application/octet-stream"}),z+=C.size}catch{y(`Fehler beim Lesen von "${C.name}"`)}}D.length>0&&g(C=>[...C,...D]),v.current&&(v.current.value="")},T=R=>{g(V=>V.filter((D,z)=>z!==R))},w=R=>{const V=R.length*.75;return V<1024?`${Math.round(V)} B`:V<1024*1024?`${(V/1024).toFixed(1)} KB`:`${(V/(1024*1024)).toFixed(1)} MB`},S=G({mutationFn:()=>ts.sendEmail(n.id,{to:l.split(",").map(R=>R.trim()).filter(Boolean),cc:c?c.split(",").map(R=>R.trim()).filter(Boolean):void 0,subject:u,text:m,inReplyTo:s==null?void 0:s.messageId,references:s!=null&&s.messageId?[s.messageId]:void 0,attachments:p.length>0?p:void 0,contractId:a}),onSuccess:()=>{r==null||r(),M()},onError:R=>{y(R instanceof Error?R.message:"Fehler beim Senden")}}),M=()=>{e()},F=()=>{if(!l.trim()){y("Bitte Empfänger angeben");return}if(!u.trim()){y("Bitte Betreff angeben");return}y(null),S.mutate()};return i.jsx(Xe,{isOpen:t,onClose:M,title:s?"Antworten":"Neue E-Mail",size:"lg",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Von"}),i.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg text-sm text-gray-700",children:n.email})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["An ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",value:l,onChange:R=>o(R.target.value),placeholder:"empfaenger@example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),i.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Mehrere Empfänger mit Komma trennen"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"CC"}),i.jsx("input",{type:"text",value:c,onChange:R=>d(R.target.value),placeholder:"cc@example.com",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Betreff ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",value:u,onChange:R=>h(R.target.value),placeholder:"Betreff eingeben",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Nachricht"}),i.jsx("textarea",{value:m,onChange:R=>f(R.target.value),rows:10,placeholder:"Ihre Nachricht...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent resize-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Anhänge"}),i.jsx("input",{type:"file",ref:v,onChange:E,multiple:!0,className:"hidden"}),i.jsxs("button",{type:"button",onClick:()=>{var R;return(R=v.current)==null?void 0:R.click()},className:"inline-flex items-center px-3 py-2 text-sm border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors",children:[i.jsx(Of,{className:"w-4 h-4 mr-2"}),"Datei anhängen"]}),p.length>0&&i.jsx("div",{className:"mt-2 space-y-2",children:p.map((R,V)=>i.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 rounded-lg",children:[i.jsxs("div",{className:"flex items-center min-w-0",children:[i.jsx(We,{className:"w-4 h-4 text-gray-500 mr-2 flex-shrink-0"}),i.jsx("span",{className:"text-sm text-gray-700 truncate",children:R.filename}),i.jsxs("span",{className:"ml-2 text-xs text-gray-500 flex-shrink-0",children:["(",w(R.content),")"]})]}),i.jsx("button",{type:"button",onClick:()=>T(V),className:"ml-2 p-1 text-gray-400 hover:text-red-500 transition-colors",title:"Anhang entfernen",children:i.jsx(nn,{className:"w-4 h-4"})})]},V))}),i.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Max. 10 MB pro Datei, 25 MB gesamt"})]}),x&&i.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:x}),i.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[i.jsx(I,{variant:"secondary",onClick:M,children:"Abbrechen"}),i.jsxs(I,{onClick:F,disabled:S.isPending,children:[i.jsx(Nd,{className:"w-4 h-4 mr-2"}),S.isPending?"Wird gesendet...":"Senden"]})]})]})})}function sR({isOpen:t,onClose:e,email:n,customerId:s,onSuccess:r}){const[a,l]=N.useState(""),[o,c]=N.useState(null),d=ye(),{data:u,isLoading:h}=fe({queryKey:["contracts","customer",s],queryFn:()=>He.getAll({customerId:s}),enabled:t}),f=((u==null?void 0:u.data)||[]).filter(v=>{var j,k,E,T;if(!a)return!0;const b=a.toLowerCase();return v.contractNumber.toLowerCase().includes(b)||((k=(j=v.contractCategory)==null?void 0:j.name)==null?void 0:k.toLowerCase().includes(b))||((T=(E=v.provider)==null?void 0:E.name)==null?void 0:T.toLowerCase().includes(b))}),p=G({mutationFn:v=>Be.assignToContract(n.id,v),onSuccess:(v,b)=>{d.invalidateQueries({queryKey:["emails"]}),d.invalidateQueries({queryKey:["email",n.id]}),d.invalidateQueries({queryKey:["contract-folder-counts",b]}),r==null||r(),g()}}),g=()=>{l(""),c(null),e()},x=()=>{o&&p.mutate(o)},y=v=>v?new Date(v).toLocaleDateString("de-DE"):"-";return i.jsx(Xe,{isOpen:t,onClose:g,title:"E-Mail Vertrag zuordnen",size:"lg",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[i.jsxs("p",{className:"text-sm text-gray-600",children:[i.jsx("span",{className:"font-medium",children:"Betreff:"})," ",n.subject||"(Kein Betreff)"]}),i.jsxs("p",{className:"text-sm text-gray-600",children:[i.jsx("span",{className:"font-medium",children:"Von:"})," ",n.fromAddress]})]}),i.jsxs("div",{className:"relative",children:[i.jsx(jd,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),i.jsx("input",{type:"text",value:a,onChange:v=>l(v.target.value),placeholder:"Vertrag suchen...",className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),i.jsx("div",{className:"border border-gray-200 rounded-lg max-h-80 overflow-auto",children:h?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):f.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[i.jsx(We,{className:"w-8 h-8 mb-2 opacity-50"}),i.jsx("p",{className:"text-sm",children:"Keine Verträge gefunden"})]}):i.jsx("div",{className:"divide-y divide-gray-200",children:f.map(v=>{var b;return i.jsx("div",{onClick:()=>c(v.id),className:`
flex items-center gap-3 p-3 cursor-pointer transition-colors
${o===v.id?"bg-blue-50 border-l-2 border-l-blue-500":"hover:bg-gray-50"}
`,children:i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium text-gray-900",children:v.contractNumber}),i.jsx("span",{className:`
px-2 py-0.5 text-xs rounded-full
${v.status==="ACTIVE"?"bg-green-100 text-green-800":v.status==="PENDING"?"bg-yellow-100 text-yellow-800":v.status==="CANCELLED"?"bg-red-100 text-red-800":"bg-gray-100 text-gray-800"}
`,children:v.status})]}),i.jsxs("div",{className:"text-sm text-gray-600 truncate",children:[(b=v.contractCategory)==null?void 0:b.name,v.provider&&` - ${v.provider.name}`]}),i.jsxs("div",{className:"text-xs text-gray-500",children:["Start: ",y(v.startDate)]})]})},v.id)})})}),i.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[i.jsx(I,{variant:"secondary",onClick:g,children:"Abbrechen"}),i.jsx(I,{onClick:x,disabled:!o||p.isPending,children:p.isPending?"Wird zugeordnet...":"Zuordnen"})]})]})})}function TC({emails:t,selectedEmailId:e,onSelectEmail:n,onEmailRestored:s,onEmailDeleted:r,isLoading:a}){const[l,o]=N.useState(null),[c,d]=N.useState(null),u=ye(),h=E=>{if(E.folder==="SENT")try{const T=JSON.parse(E.toAddresses);if(T.length>0)return`An: ${T[0]}${T.length>1?` (+${T.length-1})`:""}`}catch{return"An: (Unbekannt)"}return E.fromName||E.fromAddress},m=G({mutationFn:E=>Be.restore(E),onSuccess:(E,T)=>{u.invalidateQueries({queryKey:["emails"]}),Ue.success("E-Mail wiederhergestellt"),o(null),d(null),s==null||s(T)},onError:E=>{console.error("Restore error:",E),Ue.error(E.message||"Fehler beim Wiederherstellen"),o(null),d(null)}}),f=G({mutationFn:E=>Be.permanentDelete(E),onSuccess:(E,T)=>{u.invalidateQueries({queryKey:["emails"]}),Ue.success("E-Mail endgültig gelöscht"),o(null),d(null),r==null||r(T)},onError:E=>{console.error("Permanent delete error:",E),Ue.error(E.message||"Fehler beim endgültigen Löschen"),o(null),d(null)}}),p=G({mutationFn:E=>Be.unassignFromContract(E),onSuccess:()=>{u.invalidateQueries({queryKey:["emails"]}),Ue.success("Vertragszuordnung aufgehoben")},onError:E=>{console.error("Unassign error:",E),Ue.error(E.message||"Fehler beim Aufheben der Zuordnung")}}),g=(E,T)=>{E.stopPropagation(),p.mutate(T)},x=(E,T)=>{E.stopPropagation(),o(T),d("restore")},y=(E,T)=>{E.stopPropagation(),o(T),d("delete")},v=E=>{E.stopPropagation(),l&&c&&(c==="restore"?m.mutate(l):f.mutate(l))},b=E=>{E.stopPropagation(),o(null),d(null)},j=E=>new Date(E).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"}),k=E=>{if(!E)return"";const T=new Date(E),w=new Date;return T.toDateString()===w.toDateString()?`Gelöscht um ${T.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})}`:`Gelöscht am ${T.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})}`};return a?i.jsx("div",{className:"flex items-center justify-center h-64",children:i.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-red-600"})}):t.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center h-64 text-gray-500",children:[i.jsx(Ee,{className:"w-12 h-12 mb-2 opacity-50"}),i.jsx("p",{children:"Papierkorb ist leer"})]}):i.jsxs("div",{className:"divide-y divide-gray-200",children:[t.map(E=>i.jsxs("div",{onClick:()=>n(E),className:["flex items-start gap-3 p-3 cursor-pointer transition-colors",e===E.id?"bg-red-100":"hover:bg-gray-100 bg-gray-50/50"].join(" "),style:{borderLeft:e===E.id?"4px solid #dc2626":"4px solid transparent"},children:[i.jsx("div",{className:"flex-shrink-0 mt-1 p-1 -ml-1 text-gray-400",title:E.folder==="SENT"?"Aus Gesendet":"Aus Posteingang",children:E.folder==="SENT"?i.jsx(Nd,{className:"w-4 h-4"}):i.jsx(Sa,{className:"w-4 h-4"})}),i.jsx("button",{onClick:T=>x(T,E.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-green-100 text-gray-400 hover:text-green-600",title:"Wiederherstellen",children:i.jsx(AC,{className:"w-4 h-4"})}),i.jsx("button",{onClick:T=>y(T,E.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"Endgültig löschen",children:i.jsx(Ee,{className:"w-4 h-4"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[i.jsx("span",{className:"text-sm truncate text-gray-700",children:h(E)}),i.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:j(E.receivedAt)})]}),i.jsx("div",{className:"text-sm truncate text-gray-600",children:E.subject||"(Kein Betreff)"}),i.jsx("div",{className:"text-xs text-red-500 mt-1",children:k(E.deletedAt)}),E.contract&&i.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[i.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:E.contract.contractNumber}),(E.folder==="INBOX"||E.folder==="SENT"&&!E.isAutoAssigned)&&i.jsx("button",{onClick:T=>g(T,E.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:p.isPending,children:i.jsx(nn,{className:"w-3.5 h-3.5"})})]})]}),i.jsx(At,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},E.id)),l&&c&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:c==="restore"?"E-Mail wiederherstellen?":"E-Mail endgültig löschen?"}),i.jsx("p",{className:"text-gray-600 mb-4",children:c==="restore"?"Die E-Mail wird wieder in den ursprünglichen Ordner verschoben.":"Die E-Mail wird unwiderruflich gelöscht. Diese Aktion kann nicht rückgängig gemacht werden."}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(I,{variant:"secondary",onClick:b,disabled:m.isPending||f.isPending,children:"Abbrechen"}),i.jsx(I,{variant:c==="restore"?"primary":"danger",onClick:v,disabled:m.isPending||f.isPending,children:m.isPending||f.isPending?"Wird ausgeführt...":c==="restore"?"Wiederherstellen":"Endgültig löschen"})]})]})})]})}function rR({customerId:t}){const[e,n]=N.useState(null),[s,r]=N.useState("INBOX"),[a,l]=N.useState(null),[o,c]=N.useState(!1),[d,u]=N.useState(!1),[h,m]=N.useState(null),f=ye(),{hasPermission:p}=nt(),g=p("emails:delete"),{data:x,isLoading:y}=fe({queryKey:["mailbox-accounts",t],queryFn:()=>Be.getMailboxAccounts(t)}),v=(x==null?void 0:x.data)||[];N.useEffect(()=>{v.length>0&&!e&&n(v[0].id)},[v,e]);const b=v.find(he=>he.id===e),{data:j,isLoading:k,refetch:E}=fe({queryKey:["emails","customer",t,e,s],queryFn:()=>Be.getForCustomer(t,{accountId:e||void 0,folder:s}),enabled:!!e&&s!=="TRASH"}),T=(j==null?void 0:j.data)||[],{data:w,isLoading:S}=fe({queryKey:["emails","trash",t],queryFn:()=>Be.getTrash(t),enabled:s==="TRASH"&&g}),M=(w==null?void 0:w.data)||[],{data:F}=fe({queryKey:["folder-counts",e],queryFn:()=>ts.getFolderCounts(e),enabled:!!e}),R=(F==null?void 0:F.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0,trash:0,trashUnread:0},{data:V}=fe({queryKey:["email",a==null?void 0:a.id],queryFn:()=>Be.getById(a.id),enabled:!!(a!=null&&a.id)}),D=(V==null?void 0:V.data)||a,z=G({mutationFn:he=>ts.syncEmails(he),onSuccess:()=>{f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["folder-counts",e]}),f.invalidateQueries({queryKey:["mailbox-accounts",t]})}}),C=()=>{e&&z.mutate(e)},_=he=>{l(he)},K=()=>{m(D||null),c(!0)},B=()=>{m(null),c(!0)},W=()=>{u(!0)};if(!y&&v.length===0)return i.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[i.jsx(Fs,{className:"w-16 h-16 mb-4 opacity-30"}),i.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Keine E-Mail-Konten vorhanden"}),i.jsx("p",{className:"text-sm text-center max-w-md",children:"Erstellen Sie eine Stressfrei-Wechseln E-Mail-Adresse mit aktivierter Mailbox, um E-Mails hier empfangen und versenden zu können."})]});const ce=he=>{r(he),l(null)};return i.jsxs("div",{className:"flex flex-col h-full",style:{minHeight:"600px"},children:[i.jsxs("div",{className:"flex items-center justify-between gap-4 p-4 border-b border-gray-200 bg-gray-50",children:[v.length>1?i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Sa,{className:"w-5 h-5 text-gray-500"}),i.jsx("select",{value:e||"",onChange:he=>{n(Number(he.target.value)),l(null)},className:"px-3 py-2 border border-gray-300 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm",children:v.map(he=>i.jsx("option",{value:he.id,children:he.email},he.id))})]}):i.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-600",children:[i.jsx(Sa,{className:"w-5 h-5 text-gray-500"}),i.jsx("span",{children:b==null?void 0:b.email})]}),i.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[i.jsxs("button",{onClick:()=>ce("INBOX"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${s==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(Sa,{className:"w-4 h-4"}),"Posteingang",R.inbox>0&&i.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${R.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${R.inboxUnread} ungelesen / ${R.inbox} gesamt`,children:R.inboxUnread>0?`${R.inboxUnread}/${R.inbox}`:R.inbox})]}),i.jsxs("button",{onClick:()=>ce("SENT"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${s==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(Nd,{className:"w-4 h-4"}),"Gesendet",R.sent>0&&i.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${R.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${R.sentUnread} ungelesen / ${R.sent} gesamt`,children:R.sentUnread>0?`${R.sentUnread}/${R.sent}`:R.sent})]}),g&&i.jsxs("button",{onClick:()=>ce("TRASH"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${s==="TRASH"?"bg-white text-red-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(Ee,{className:"w-4 h-4"}),"Papierkorb",R.trash>0&&i.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${R.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${R.trashUnread} ungelesen / ${R.trash} gesamt`,children:R.trashUnread>0?`${R.trashUnread}/${R.trash}`:R.trash})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[s!=="TRASH"&&i.jsxs(I,{variant:"secondary",size:"sm",onClick:C,disabled:z.isPending||!e,children:[i.jsx(ai,{className:`w-4 h-4 mr-1 ${z.isPending?"animate-spin":""}`}),z.isPending?"Sync...":"Synchronisieren"]}),i.jsxs(I,{size:"sm",onClick:B,disabled:!b,children:[i.jsx(Ge,{className:"w-4 h-4 mr-1"}),"Neue E-Mail"]})]})]}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[i.jsx("div",{className:"w-1/3 border-r border-gray-200 overflow-auto",children:s==="TRASH"?i.jsx(TC,{emails:M,selectedEmailId:a==null?void 0:a.id,onSelectEmail:_,onEmailRestored:he=>{(a==null?void 0:a.id)===he&&l(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["folder-counts",e]})},onEmailDeleted:he=>{(a==null?void 0:a.id)===he&&l(null),f.invalidateQueries({queryKey:["emails","trash"]}),f.invalidateQueries({queryKey:["folder-counts",e]})},isLoading:S}):i.jsx(eR,{emails:T,selectedEmailId:a==null?void 0:a.id,onSelectEmail:_,onEmailDeleted:he=>{(a==null?void 0:a.id)===he&&l(null),f.invalidateQueries({queryKey:["folder-counts",e]})},isLoading:k,folder:s,accountId:e})}),i.jsx("div",{className:"flex-1 overflow-auto",children:D?i.jsx(DC,{email:D,onReply:K,onAssignContract:W,onDeleted:()=>{l(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["folder-counts",e]})},isSentFolder:s==="SENT",isTrashView:s==="TRASH",onRestored:()=>{l(null),f.invalidateQueries({queryKey:["emails"]}),f.invalidateQueries({queryKey:["folder-counts",e]})},accountId:e||void 0}):i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[i.jsx(Fs,{className:"w-12 h-12 mb-2 opacity-30"}),i.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),b&&i.jsx(MC,{isOpen:o,onClose:()=>{c(!1),m(null)},account:b,replyTo:h||void 0,onSuccess:()=>{f.invalidateQueries({queryKey:["emails","customer",t,e,"SENT"]}),f.invalidateQueries({queryKey:["folder-counts",e]}),s==="SENT"&&E()}}),D&&i.jsx(sR,{isOpen:d,onClose:()=>u(!1),email:D,customerId:t,onSuccess:()=>{E()}})]})}function iR({contractId:t,customerId:e}){const[n,s]=N.useState(null),[r,a]=N.useState("INBOX"),[l,o]=N.useState(null),[c,d]=N.useState(!1),[u,h]=N.useState(null),[m,f]=N.useState(null),p=ye(),{hasPermission:g}=nt(),x=g("emails:delete"),{data:y,isLoading:v}=fe({queryKey:["mailbox-accounts",e],queryFn:()=>Be.getMailboxAccounts(e)}),b=(y==null?void 0:y.data)||[];N.useEffect(()=>{b.length>0&&!n&&s(b[0].id)},[b,n]);const j=b.find(ee=>ee.id===n),{data:k,isLoading:E,refetch:T}=fe({queryKey:["emails","contract",t,r],queryFn:()=>Be.getForContract(t,{folder:r}),enabled:r!=="TRASH"}),w=(k==null?void 0:k.data)||[],{data:S,isLoading:M}=fe({queryKey:["emails","trash",e],queryFn:()=>Be.getTrash(e),enabled:r==="TRASH"&&x}),F=(S==null?void 0:S.data)||[],{data:R}=fe({queryKey:["contract-folder-counts",t],queryFn:()=>Be.getContractFolderCounts(t)}),V=(R==null?void 0:R.data)||{inbox:0,inboxUnread:0,sent:0,sentUnread:0},{data:D}=fe({queryKey:["folder-counts",n],queryFn:()=>ts.getFolderCounts(n),enabled:!!n&&x}),z=(D==null?void 0:D.data)||{trash:0,trashUnread:0},{data:C}=fe({queryKey:["email",l==null?void 0:l.id],queryFn:()=>Be.getById(l.id),enabled:!!(l!=null&&l.id)}),_=(C==null?void 0:C.data)||l,K=G({mutationFn:ee=>ts.syncEmails(ee),onSuccess:()=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["contract-folder-counts",t]}),n&&p.invalidateQueries({queryKey:["folder-counts",n]}),Ue.success("Synchronisation abgeschlossen")},onError:ee=>{Ue.error(ee.message||"Synchronisation fehlgeschlagen")}}),B=G({mutationFn:ee=>Be.toggleStar(ee),onSuccess:(ee,pe)=>{p.invalidateQueries({queryKey:["emails","contract",t]}),p.invalidateQueries({queryKey:["email",pe]})}}),W=G({mutationFn:({emailId:ee,isRead:pe})=>Be.markAsRead(ee,pe),onSuccess:(ee,pe)=>{p.invalidateQueries({queryKey:["emails","contract",t]}),p.invalidateQueries({queryKey:["email",pe.emailId]}),p.invalidateQueries({queryKey:["contract-folder-counts",t]}),n&&p.invalidateQueries({queryKey:["folder-counts",n]})}}),ce=G({mutationFn:ee=>Be.unassignFromContract(ee),onSuccess:()=>{p.invalidateQueries({queryKey:["emails","contract",t]}),p.invalidateQueries({queryKey:["contract-folder-counts",t]}),o(null),Ue.success("Zuordnung aufgehoben")},onError:ee=>{Ue.error(ee.message||"Fehler beim Aufheben der Zuordnung")}}),he=G({mutationFn:ee=>Be.delete(ee),onSuccess:(ee,pe)=>{p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["contract-folder-counts",t]}),n&&p.invalidateQueries({queryKey:["folder-counts",n]}),Ue.success("E-Mail in Papierkorb verschoben"),f(null),(l==null?void 0:l.id)===pe&&o(null)},onError:ee=>{Ue.error(ee.message||"Fehler beim Löschen der E-Mail"),f(null)}}),Je=()=>{n&&K.mutate(n)},et=ee=>{const pe=new Date(ee),Ln=new Date;return pe.toDateString()===Ln.toDateString()?pe.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}):pe.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"})},mt=(ee,pe)=>{ee.stopPropagation(),B.mutate(pe)},A=(ee,pe)=>{ee.stopPropagation(),W.mutate({emailId:pe.id,isRead:!pe.isRead})},pt=ee=>{ee.isRead||W.mutate({emailId:ee.id,isRead:!0}),o(ee)},On=()=>{h(_||null),d(!0)},wn=()=>{h(null),d(!0)},le=(ee,pe)=>{ee.stopPropagation(),(l==null?void 0:l.id)===pe&&o(null),ce.mutate(pe)},it=(ee,pe)=>{ee.stopPropagation(),f(pe)},Rt=ee=>{ee.stopPropagation(),m&&he.mutate(m)},J=ee=>{ee.stopPropagation(),f(null)},Ke=ee=>{a(ee),o(null)},ct=ee=>{if(r==="SENT")try{const pe=JSON.parse(ee.toAddresses);if(pe.length>0)return`An: ${pe[0]}${pe.length>1?` (+${pe.length-1})`:""}`}catch{return"An: (Unbekannt)"}return ee.fromName||ee.fromAddress};return!v&&b.length===0?i.jsx(Z,{title:"E-Mails",children:i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[i.jsx(Fs,{className:"w-10 h-10 mb-2 opacity-30"}),i.jsx("p",{className:"text-sm",children:"Keine E-Mail-Konten vorhanden"}),i.jsx("p",{className:"text-xs mt-1",children:"Erstellen Sie eine E-Mail-Adresse beim Kunden mit aktivierter Mailbox"})]})}):i.jsxs(Z,{title:i.jsx("div",{className:"flex items-center gap-4",children:i.jsx("span",{children:"E-Mails"})}),actions:i.jsxs("div",{className:"flex items-center gap-2",children:[r!=="TRASH"&&i.jsxs(I,{variant:"secondary",size:"sm",onClick:Je,disabled:K.isPending||!n,children:[i.jsx(ai,{className:`w-4 h-4 mr-1 ${K.isPending?"animate-spin":""}`}),K.isPending?"Sync...":"Sync"]}),j&&i.jsxs(I,{size:"sm",onClick:wn,children:[i.jsx(Ge,{className:"w-4 h-4 mr-1"}),"Neue E-Mail"]})]}),children:[i.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4 border-b border-gray-200 -mt-2",children:[b.length>1?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Sa,{className:"w-4 h-4 text-gray-500"}),i.jsx("select",{value:n||"",onChange:ee=>{s(Number(ee.target.value)),o(null)},className:"px-2 py-1.5 border border-gray-300 rounded-lg bg-white focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm",children:b.map(ee=>i.jsx("option",{value:ee.id,children:ee.email},ee.id))})]}):i.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[i.jsx(Sa,{className:"w-4 h-4 text-gray-500"}),i.jsx("span",{children:j==null?void 0:j.email})]}),i.jsxs("div",{className:"flex items-center gap-1 bg-gray-200 rounded-lg p-1",children:[i.jsxs("button",{onClick:()=>Ke("INBOX"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="INBOX"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(Sa,{className:"w-4 h-4"}),"Posteingang",V.inbox>0&&i.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${V.inboxUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${V.inboxUnread} ungelesen / ${V.inbox} gesamt`,children:V.inboxUnread>0?`${V.inboxUnread}/${V.inbox}`:V.inbox})]}),i.jsxs("button",{onClick:()=>Ke("SENT"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="SENT"?"bg-white text-blue-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(Nd,{className:"w-4 h-4"}),"Gesendet",V.sent>0&&i.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${V.sentUnread>0?"bg-blue-100 text-blue-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${V.sentUnread} ungelesen / ${V.sent} gesamt`,children:V.sentUnread>0?`${V.sentUnread}/${V.sent}`:V.sent})]}),x&&i.jsxs("button",{onClick:()=>Ke("TRASH"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors ${r==="TRASH"?"bg-white text-red-600 shadow-sm font-medium":"text-gray-600 hover:text-gray-900"}`,children:[i.jsx(Ee,{className:"w-4 h-4"}),"Papierkorb",z.trash>0&&i.jsx("span",{className:`ml-1 px-1.5 py-0.5 text-xs rounded-full cursor-help ${z.trashUnread>0?"bg-red-100 text-red-600 font-medium":"bg-gray-100 text-gray-500"}`,title:`${z.trashUnread} ungelesen / ${z.trash} gesamt`,children:z.trashUnread>0?`${z.trashUnread}/${z.trash}`:z.trash})]})]})]}),(r==="TRASH"?M:E)?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):(r==="TRASH"?F.length===0:w.length===0)?i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-gray-500",children:[i.jsx(Fs,{className:"w-10 h-10 mb-2 opacity-30"}),i.jsx("p",{className:"text-sm",children:r==="INBOX"?"Keine E-Mails zugeordnet":r==="SENT"?"Keine E-Mails über diesen Vertrag gesendet":"Papierkorb ist leer"}),r==="INBOX"&&i.jsx("p",{className:"text-xs mt-1",children:"E-Mails können im E-Mail-Tab des Kunden zugeordnet werden"})]}):i.jsxs("div",{className:"flex -mx-6 -mb-6",style:{minHeight:"400px"},children:[i.jsx("div",{className:"w-1/3 border-r border-gray-200 overflow-auto",children:r==="TRASH"?i.jsx(TC,{emails:F,selectedEmailId:l==null?void 0:l.id,onSelectEmail:pt,onEmailRestored:ee=>{(l==null?void 0:l.id)===ee&&o(null),p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["folder-counts",n]}),p.invalidateQueries({queryKey:["contract-folder-counts",t]})},onEmailDeleted:ee=>{(l==null?void 0:l.id)===ee&&o(null),p.invalidateQueries({queryKey:["emails","trash"]}),p.invalidateQueries({queryKey:["folder-counts",n]})},isLoading:M}):i.jsx("div",{className:"divide-y divide-gray-200",children:w.map(ee=>i.jsxs("div",{onClick:()=>pt(ee),className:["flex items-start gap-2 p-3 cursor-pointer transition-colors",(l==null?void 0:l.id)===ee.id?"bg-blue-100":["hover:bg-gray-100",ee.isRead?"bg-gray-50/50":"bg-white"].join(" ")].join(" "),style:{borderLeft:(l==null?void 0:l.id)===ee.id?"4px solid #2563eb":"4px solid transparent"},children:[i.jsx("button",{onClick:pe=>A(pe,ee),className:`
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
${ee.isRead?"text-gray-400":"text-blue-600"}
`,title:ee.isRead?"Als ungelesen markieren":"Als gelesen markieren",children:ee.isRead?i.jsx(NC,{className:"w-4 h-4"}):i.jsx(Fs,{className:"w-4 h-4"})}),i.jsx("button",{onClick:pe=>mt(pe,ee.id),className:`
flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-gray-200
${ee.isStarred?"text-yellow-500":"text-gray-400"}
`,title:ee.isStarred?"Stern entfernen":"Als wichtig markieren",children:i.jsx(By,{className:`w-4 h-4 ${ee.isStarred?"fill-current":""}`})}),g("emails:delete")&&i.jsx("button",{onClick:pe=>it(pe,ee.id),className:"flex-shrink-0 mt-1 p-1 -ml-1 rounded hover:bg-red-100 text-gray-400 hover:text-red-600",title:"E-Mail löschen",children:i.jsx(Ee,{className:"w-4 h-4"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[i.jsx("span",{className:`text-sm truncate ${ee.isRead?"text-gray-700":"font-semibold text-gray-900"}`,children:ct(ee)}),i.jsx("span",{className:"text-xs text-gray-500 flex-shrink-0",children:et(ee.receivedAt)})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`text-sm truncate ${ee.isRead?"text-gray-600":"font-medium text-gray-900"}`,children:ee.subject||"(Kein Betreff)"}),ee.hasAttachments&&i.jsx(Of,{className:"w-3 h-3 text-gray-400 flex-shrink-0"})]}),ee.contract&&i.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[i.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800",children:ee.contract.contractNumber}),(r==="INBOX"||r==="SENT"&&!ee.isAutoAssigned)&&i.jsx("button",{onClick:pe=>le(pe,ee.id),className:"p-0.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded",title:"Zuordnung aufheben",disabled:ce.isPending,children:i.jsx(nn,{className:"w-3.5 h-3.5"})})]})]}),i.jsx(At,{className:"w-4 h-4 text-gray-400 flex-shrink-0 mt-2"})]},ee.id))})}),i.jsx("div",{className:"flex-1 overflow-auto",children:_&&l?i.jsx(DC,{email:_,onReply:On,onAssignContract:()=>{},onDeleted:()=>{o(null),p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["contract-folder-counts",t]}),n&&p.invalidateQueries({queryKey:["folder-counts",n]})},isSentFolder:r==="SENT",isContractView:r!=="TRASH",isTrashView:r==="TRASH",onRestored:()=>{o(null),p.invalidateQueries({queryKey:["emails"]}),p.invalidateQueries({queryKey:["contract-folder-counts",t]}),n&&p.invalidateQueries({queryKey:["folder-counts",n]})},accountId:_==null?void 0:_.stressfreiEmailId}):i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-500",children:[i.jsx(Fs,{className:"w-12 h-12 mb-2 opacity-30"}),i.jsx("p",{children:"Wählen Sie eine E-Mail aus"})]})})]}),m&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"E-Mail löschen?"}),i.jsx("p",{className:"text-gray-600 mb-4",children:"Die E-Mail wird in den Papierkorb verschoben."}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(I,{variant:"secondary",onClick:J,disabled:he.isPending,children:"Abbrechen"}),i.jsx(I,{variant:"danger",onClick:Rt,disabled:he.isPending,children:he.isPending?"Löschen...":"Löschen"})]})]})}),j&&i.jsx(MC,{isOpen:c,onClose:()=>{d(!1),h(null)},account:j,replyTo:u||void 0,contractId:t,onSuccess:()=>{p.invalidateQueries({queryKey:["emails","contract",t,"SENT"]}),p.invalidateQueries({queryKey:["contract-folder-counts",t]}),r==="SENT"&&T()}})]})}function aR({tabs:t,defaultTab:e}){var r,a;const[n,s]=N.useState(e||((r=t[0])==null?void 0:r.id));return i.jsxs("div",{children:[i.jsx("div",{className:"border-b border-gray-200",children:i.jsx("nav",{className:"flex -mb-px space-x-8",children:t.map(l=>i.jsx("button",{onClick:()=>s(l.id),className:`py-4 px-1 border-b-2 font-medium text-sm whitespace-nowrap ${n===l.id?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:l.label},l.id))})}),i.jsx("div",{className:"mt-4",children:(a=t.find(l=>l.id===n))==null?void 0:a.content})]})}function Jt({onUpload:t,existingFile:e,accept:n=".pdf,.jpg,.jpeg,.png",label:s="Dokument hochladen",disabled:r=!1}){const a=N.useRef(null),[l,o]=N.useState(!1),[c,d]=N.useState(!1),u=async g=>{if(g){o(!0);try{await t(g)}catch(x){console.error("Upload failed:",x),alert("Upload fehlgeschlagen")}finally{o(!1)}}},h=g=>{var y;const x=(y=g.target.files)==null?void 0:y[0];x&&u(x)},m=g=>{var y;g.preventDefault(),d(!1);const x=(y=g.dataTransfer.files)==null?void 0:y[0];x&&u(x)},f=g=>{g.preventDefault(),d(!0)},p=()=>{d(!1)};return i.jsxs("div",{className:"space-y-2",children:[e?!r&&i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>{var g;return(g=a.current)==null?void 0:g.click()},disabled:l,children:l?"Wird hochgeladen...":"Ersetzen"}):i.jsx("div",{className:`border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors ${c?"border-blue-500 bg-blue-50":"border-gray-300 hover:border-gray-400"} ${r?"opacity-50 cursor-not-allowed":""}`,onClick:()=>{var g;return!r&&((g=a.current)==null?void 0:g.click())},onDrop:r?void 0:m,onDragOver:r?void 0:f,onDragLeave:r?void 0:p,children:l?i.jsxs("div",{className:"text-gray-500",children:[i.jsx("div",{className:"animate-spin w-6 h-6 border-2 border-blue-500 border-t-transparent rounded-full mx-auto mb-2"}),"Wird hochgeladen..."]}):i.jsxs(i.Fragment,{children:[i.jsx(_g,{className:"w-6 h-6 text-gray-400 mx-auto mb-2"}),i.jsx("p",{className:"text-sm text-gray-600",children:s}),i.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"PDF, JPG oder PNG (max. 10MB)"})]})}),i.jsx("input",{ref:a,type:"file",accept:n,onChange:h,className:"hidden",disabled:r||l})]})}function de({value:t,className:e="",size:n="sm",title:s="In Zwischenablage kopieren"}){const[r,a]=N.useState(!1),l=async c=>{c.preventDefault(),c.stopPropagation();try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),1500)}catch(d){console.error("Failed to copy:",d)}},o=n==="sm"?"w-3.5 h-3.5":"w-4 h-4";return i.jsx("button",{type:"button",onClick:l,className:`inline-flex items-center justify-center p-1 rounded transition-colors ${r?"text-green-600 bg-green-50":"text-gray-400 hover:text-blue-600 hover:bg-blue-50"} ${e}`,title:r?"Kopiert!":s,children:r?i.jsx(Vr,{className:o}):i.jsx(Iy,{className:o})})}function Vg({values:t,separator:e=`
`,children:n,className:s=""}){const r=t.filter(a=>a!=null&&a!=="").map(String).join(e);return r?i.jsxs("div",{className:`relative group ${s}`,children:[n,i.jsx(de,{value:r,className:"absolute top-0 right-0 opacity-60 group-hover:opacity-100",title:"Alles kopieren"})]}):i.jsx(i.Fragment,{children:n})}function lR(){var K,B;const{id:t}=md(),e=fn(),n=ye(),{hasPermission:s}=nt(),[r]=Sf(),a=parseInt(t),l=r.get("tab")||"addresses",[o,c]=N.useState(!1),[d,u]=N.useState(!1),[h,m]=N.useState(!1),[f,p]=N.useState(!1),[g,x]=N.useState(!1),[y,v]=N.useState(!1),[b,j]=N.useState(null),[k,E]=N.useState(null),[T,w]=N.useState(null),[S,M]=N.useState(null),[F,R]=N.useState(null),{data:V,isLoading:D}=fe({queryKey:["customer",t],queryFn:()=>Zt.getById(a)}),z=G({mutationFn:()=>Zt.delete(a),onSuccess:()=>{e("/customers")}});if(D)return i.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(V!=null&&V.data))return i.jsx("div",{className:"text-center py-8 text-red-600",children:"Kunde nicht gefunden"});const C=V.data,_=[{id:"addresses",label:"Adressen",content:i.jsx(dR,{customerId:a,addresses:C.addresses||[],canEdit:s("customers:update"),onAdd:()=>c(!0),onEdit:W=>w(W)})},{id:"bankcards",label:"Bankkarten",content:i.jsx(uR,{customerId:a,bankCards:C.bankCards||[],canEdit:s("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>u(!0),onEdit:W=>j(W)})},{id:"documents",label:"Ausweise",content:i.jsx(hR,{customerId:a,documents:C.identityDocuments||[],canEdit:s("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>m(!0),onEdit:W=>E(W)})},{id:"meters",label:"Zähler",content:i.jsx(fR,{customerId:a,meters:C.meters||[],canEdit:s("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>p(!0),onEdit:W=>M(W)})},{id:"stressfrei",label:"Stressfrei-Wechseln",content:i.jsx(xR,{customerId:a,emails:C.stressfreiEmails||[],canEdit:s("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>x(!0),onEdit:W=>R(W)})},{id:"emails",label:"E-Mail-Postfach",content:i.jsx(rR,{customerId:a})},{id:"contracts",label:"Verträge",content:i.jsx(mR,{customerId:a})},...s("customers:update")?[{id:"portal",label:"Portal",content:i.jsx(gR,{customerId:a,canEdit:s("customers:update")})}]:[],...s("customers:read")?[{id:"consents",label:"Einwilligungen",content:i.jsx(bR,{customerId:a,canEdit:!1,customerEmail:C.email||void 0})}]:[]];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold",children:C.type==="BUSINESS"&&C.companyName?C.companyName:`${C.firstName} ${C.lastName}`}),i.jsxs("p",{className:"text-gray-500 font-mono flex items-center gap-1",children:[C.customerNumber,i.jsx(de,{value:C.customerNumber})]})]}),i.jsxs("div",{className:"flex gap-2",children:[s("customers:update")&&i.jsx(Me,{to:`/customers/${t}/edit`,children:i.jsxs(I,{variant:"secondary",children:[i.jsx(rt,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),s("customers:delete")&&i.jsxs(I,{variant:"danger",onClick:()=>{confirm("Kunde wirklich löschen?")&&z.mutate()},children:[i.jsx(Ee,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[i.jsx(Z,{title:"Stammdaten",className:"lg:col-span-2",children:i.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Typ"}),i.jsx("dd",{children:i.jsx(je,{variant:C.type==="BUSINESS"?"info":"default",children:C.type==="BUSINESS"?"Geschäftskunde":"Privatkunde"})})]}),C.salutation&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Anrede"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[C.salutation,i.jsx(de,{value:C.salutation})]})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vorname"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[C.firstName,i.jsx(de,{value:C.firstName})]})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Nachname"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[C.lastName,i.jsx(de,{value:C.lastName})]})]}),C.companyName&&i.jsxs("div",{className:"col-span-2",children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Firma"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[C.companyName,i.jsx(de,{value:C.companyName})]})]}),C.foundingDate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Gründungsdatum"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(C.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),i.jsx(de,{value:new Date(C.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),C.birthDate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsdatum"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(C.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),i.jsx(de,{value:new Date(C.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),C.birthPlace&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsort"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[C.birthPlace,i.jsx(de,{value:C.birthPlace})]})]})]})}),i.jsx(Z,{title:"Kontakt",children:i.jsxs("dl",{className:"space-y-3",children:[C.email&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"E-Mail"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[i.jsx("a",{href:`mailto:${C.email}`,className:"text-blue-600 hover:underline",children:C.email}),i.jsx(de,{value:C.email})]})]}),C.phone&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Telefon"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[i.jsx("a",{href:`tel:${C.phone}`,className:"text-blue-600 hover:underline",children:C.phone}),i.jsx(de,{value:C.phone})]})]}),C.mobile&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Mobil"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[i.jsx("a",{href:`tel:${C.mobile}`,className:"text-blue-600 hover:underline",children:C.mobile}),i.jsx(de,{value:C.mobile})]})]})]})})]}),C.type==="BUSINESS"&&i.jsx(oR,{customer:C,canEdit:s("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",t]})}),i.jsx(cR,{customer:C,canEdit:s("customers:update"),onUpdate:()=>n.invalidateQueries({queryKey:["customer",t]})}),C.notes&&i.jsx(Z,{title:"Notizen",className:"mb-6",children:i.jsx("p",{className:"whitespace-pre-wrap",children:C.notes})}),i.jsx(Z,{children:i.jsx(aR,{tabs:_,defaultTab:l})}),i.jsx(D1,{isOpen:o,onClose:()=>c(!1),customerId:a}),i.jsx(D1,{isOpen:!!T,onClose:()=>w(null),customerId:a,address:T}),i.jsx(M1,{isOpen:d,onClose:()=>u(!1),customerId:a}),i.jsx(M1,{isOpen:!!b,onClose:()=>j(null),customerId:a,bankCard:b}),i.jsx(T1,{isOpen:h,onClose:()=>m(!1),customerId:a}),i.jsx(T1,{isOpen:!!k,onClose:()=>E(null),customerId:a,document:k}),i.jsx(P1,{isOpen:f,onClose:()=>p(!1),customerId:a}),i.jsx(P1,{isOpen:!!S,onClose:()=>M(null),customerId:a,meter:S}),i.jsx(R1,{isOpen:g,onClose:()=>x(!1),customerId:a,customerEmail:(K=V==null?void 0:V.data)==null?void 0:K.email}),i.jsx(R1,{isOpen:!!F,onClose:()=>R(null),customerId:a,email:F,customerEmail:(B=V==null?void 0:V.data)==null?void 0:B.email})]})}function oR({customer:t,canEdit:e,onUpdate:n}){const s=async c=>{try{await Ct.uploadBusinessRegistration(t.id,c),n()}catch(d){console.error("Upload fehlgeschlagen:",d),alert("Upload fehlgeschlagen")}},r=async()=>{if(confirm("Gewerbeanmeldung wirklich löschen?"))try{await Ct.deleteBusinessRegistration(t.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}},a=async c=>{try{await Ct.uploadCommercialRegister(t.id,c),n()}catch(d){console.error("Upload fehlgeschlagen:",d),alert("Upload fehlgeschlagen")}},l=async()=>{if(confirm("Handelsregisterauszug wirklich löschen?"))try{await Ct.deleteCommercialRegister(t.id),n()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}};return!(t.taxNumber||t.commercialRegisterNumber||t.businessRegistrationPath||t.commercialRegisterPath)&&!e?null:i.jsxs(Z,{title:"Geschäftsdaten",className:"mb-6",children:[i.jsxs("dl",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[t.taxNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Steuernummer"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[t.taxNumber,i.jsx(de,{value:t.taxNumber})]})]}),t.commercialRegisterNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Handelsregisternummer"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[t.commercialRegisterNumber,i.jsx(de,{value:t.commercialRegisterNumber})]})]})]}),i.jsxs("div",{className:"mt-4 pt-4 border-t grid grid-cols-1 md:grid-cols-2 gap-6",children:[i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Gewerbeanmeldung"}),t.businessRegistrationPath?i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("a",{href:`/api${t.businessRegistrationPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Oe,{className:"w-4 h-4"}),"Anzeigen"]}),i.jsxs("a",{href:`/api${t.businessRegistrationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(qn,{className:"w-4 h-4"}),"Download"]}),e&&i.jsxs(i.Fragment,{children:[i.jsx(Jt,{onUpload:s,existingFile:t.businessRegistrationPath,accept:".pdf",label:"Ersetzen"}),i.jsxs("button",{onClick:r,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Ee,{className:"w-4 h-4"}),"Löschen"]})]})]}):e?i.jsx(Jt,{onUpload:s,accept:".pdf",label:"PDF hochladen"}):i.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Handelsregisterauszug"}),t.commercialRegisterPath?i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("a",{href:`/api${t.commercialRegisterPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Oe,{className:"w-4 h-4"}),"Anzeigen"]}),i.jsxs("a",{href:`/api${t.commercialRegisterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(qn,{className:"w-4 h-4"}),"Download"]}),e&&i.jsxs(i.Fragment,{children:[i.jsx(Jt,{onUpload:a,existingFile:t.commercialRegisterPath,accept:".pdf",label:"Ersetzen"}),i.jsxs("button",{onClick:l,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Ee,{className:"w-4 h-4"}),"Löschen"]})]})]}):e?i.jsx(Jt,{onUpload:a,accept:".pdf",label:"PDF hochladen"}):i.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})]})]})}function cR({customer:t,canEdit:e,onUpdate:n}){const s=async a=>{try{await Ct.uploadPrivacyPolicy(t.id,a),n()}catch(l){console.error("Upload fehlgeschlagen:",l),alert("Upload fehlgeschlagen")}},r=async()=>{if(confirm("Datenschutzerklärung wirklich löschen?"))try{await Ct.deletePrivacyPolicy(t.id),n()}catch(a){console.error("Löschen fehlgeschlagen:",a),alert("Löschen fehlgeschlagen")}};return!t.privacyPolicyPath&&!e?null:i.jsx(Z,{title:"Dokumente",className:"mb-6",children:i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Datenschutzerklärung"}),t.privacyPolicyPath?i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("a",{href:`/api${t.privacyPolicyPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Oe,{className:"w-4 h-4"}),"Anzeigen"]}),i.jsxs("a",{href:`/api${t.privacyPolicyPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(qn,{className:"w-4 h-4"}),"Download"]}),e&&i.jsxs(i.Fragment,{children:[i.jsx(Jt,{onUpload:s,existingFile:t.privacyPolicyPath,accept:".pdf",label:"Ersetzen"}),i.jsxs("button",{onClick:r,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Ee,{className:"w-4 h-4"}),"Löschen"]})]})]}):e?i.jsx(Jt,{onUpload:s,accept:".pdf",label:"PDF hochladen"}):i.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})})}function dR({customerId:t,addresses:e,canEdit:n,onAdd:s,onEdit:r}){const a=ye(),l=G({mutationFn:$g.delete,onSuccess:()=>a.invalidateQueries({queryKey:["customer",t.toString()]})});return i.jsxs("div",{children:[n&&i.jsx("div",{className:"mb-4",children:i.jsxs(I,{size:"sm",onClick:s,children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]})}),e.length>0?i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:e.map(o=>i.jsxs("div",{className:"border rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(I5,{className:"w-4 h-4 text-gray-400"}),i.jsx(je,{variant:o.type==="BILLING"?"info":"default",children:o.type==="BILLING"?"Rechnung":"Liefer-/Meldeadresse"}),o.isDefault&&i.jsx(je,{variant:"success",children:"Standard"})]}),n&&i.jsxs("div",{className:"flex gap-1",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>r(o),title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&l.mutate(o.id)},title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})]}),i.jsxs(Vg,{values:[`${o.street} ${o.houseNumber}`,`${o.postalCode} ${o.city}`,o.country],children:[i.jsxs("p",{children:[o.street," ",o.houseNumber]}),i.jsxs("p",{children:[o.postalCode," ",o.city]}),i.jsx("p",{className:"text-gray-500",children:o.country})]})]},o.id))}):i.jsx("p",{className:"text-gray-500",children:"Keine Adressen vorhanden."})]})}function uR({customerId:t,bankCards:e,canEdit:n,showInactive:s,onToggleInactive:r,onAdd:a,onEdit:l}){const o=ye(),c=G({mutationFn:({id:f,data:p})=>ch.update(f,p),onSuccess:()=>o.invalidateQueries({queryKey:["customer",t.toString()]})}),d=G({mutationFn:ch.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",t.toString()]})}),u=async(f,p)=>{try{await Ct.uploadBankCardDocument(f,p),o.invalidateQueries({queryKey:["customer",t.toString()]})}catch(g){console.error("Upload fehlgeschlagen:",g),alert("Upload fehlgeschlagen")}},h=async f=>{if(confirm("Dokument wirklich löschen?"))try{await Ct.deleteBankCardDocument(f),o.invalidateQueries({queryKey:["customer",t.toString()]})}catch(p){console.error("Löschen fehlgeschlagen:",p),alert("Löschen fehlgeschlagen")}},m=s?e:e.filter(f=>f.isActive);return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&i.jsxs(I,{size:"sm",onClick:a,children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Bankkarte hinzufügen"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:s,onChange:r,className:"rounded"}),"Inaktive anzeigen"]})]}),m.length>0?i.jsx("div",{className:"space-y-4",children:m.map(f=>i.jsxs("div",{className:`border rounded-lg p-4 ${f.isActive?"":"opacity-50 bg-gray-50"}`,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(Ry,{className:"w-4 h-4 text-gray-400"}),!f.isActive&&i.jsx(je,{variant:"danger",children:"Inaktiv"}),f.expiryDate&&new Date(f.expiryDate)<new Date&&i.jsx(je,{variant:"warning",children:"Abgelaufen"})]}),n&&i.jsxs("div",{className:"flex gap-1",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(f),title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),f.isActive?i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte deaktivieren?")&&c.mutate({id:f.id,data:{isActive:!1}})},title:"Deaktivieren",children:i.jsx(on,{className:"w-4 h-4"})}):i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wieder aktivieren?")&&c.mutate({id:f.id,data:{isActive:!0}})},title:"Aktivieren",children:i.jsx(Oe,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wirklich löschen?")&&d.mutate(f.id)},title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})]}),i.jsxs("p",{className:"font-medium flex items-center gap-1",children:[f.accountHolder,i.jsx(de,{value:f.accountHolder})]}),i.jsxs("p",{className:"font-mono flex items-center gap-1",children:[f.iban,i.jsx(de,{value:f.iban})]}),f.bic&&i.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["BIC: ",f.bic,i.jsx(de,{value:f.bic})]}),f.bankName&&i.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:[f.bankName,i.jsx(de,{value:f.bankName})]}),f.expiryDate&&i.jsxs("p",{className:"text-sm text-gray-500",children:["Gültig bis: ",new Date(f.expiryDate).toLocaleDateString("de-DE")]}),i.jsx("div",{className:"mt-3 pt-3 border-t",children:f.documentPath?i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("a",{href:`/api${f.documentPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Oe,{className:"w-4 h-4"}),"Anzeigen"]}),i.jsxs("a",{href:`/api${f.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(qn,{className:"w-4 h-4"}),"Download"]}),n&&i.jsxs(i.Fragment,{children:[i.jsx(Jt,{onUpload:p=>u(f.id,p),existingFile:f.documentPath,accept:".pdf",label:"Ersetzen",disabled:!f.isActive}),i.jsxs("button",{onClick:()=>h(f.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[i.jsx(Ee,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&f.isActive&&i.jsx(Jt,{onUpload:p=>u(f.id,p),accept:".pdf",label:"PDF hochladen"})})]},f.id))}):i.jsx("p",{className:"text-gray-500",children:"Keine Bankkarten vorhanden."})]})}function hR({customerId:t,documents:e,canEdit:n,showInactive:s,onToggleInactive:r,onAdd:a,onEdit:l}){const o=ye(),c=G({mutationFn:({id:p,data:g})=>dh.update(p,g),onSuccess:()=>o.invalidateQueries({queryKey:["customer",t.toString()]})}),d=G({mutationFn:dh.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",t.toString()]})}),u=async(p,g)=>{try{await Ct.uploadIdentityDocument(p,g),o.invalidateQueries({queryKey:["customer",t.toString()]})}catch(x){console.error("Upload fehlgeschlagen:",x),alert("Upload fehlgeschlagen")}},h=async p=>{if(confirm("Dokument wirklich löschen?"))try{await Ct.deleteIdentityDocument(p),o.invalidateQueries({queryKey:["customer",t.toString()]})}catch(g){console.error("Löschen fehlgeschlagen:",g),alert("Löschen fehlgeschlagen")}},m=s?e:e.filter(p=>p.isActive),f={ID_CARD:"Personalausweis",PASSPORT:"Reisepass",DRIVERS_LICENSE:"Führerschein",OTHER:"Sonstiges"};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&i.jsxs(I,{size:"sm",onClick:a,children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Ausweis hinzufügen"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:s,onChange:r,className:"rounded"}),"Inaktive anzeigen"]})]}),m.length>0?i.jsx("div",{className:"space-y-4",children:m.map(p=>i.jsxs("div",{className:`border rounded-lg p-4 ${p.isActive?"":"opacity-50 bg-gray-50"}`,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(We,{className:"w-4 h-4 text-gray-400"}),i.jsx(je,{children:f[p.type]}),!p.isActive&&i.jsx(je,{variant:"danger",children:"Inaktiv"}),p.expiryDate&&new Date(p.expiryDate)<new Date&&i.jsx(je,{variant:"warning",children:"Abgelaufen"})]}),n&&i.jsxs("div",{className:"flex gap-1",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(p),title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),p.isActive?i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis deaktivieren?")&&c.mutate({id:p.id,data:{isActive:!1}})},title:"Deaktivieren",children:i.jsx(on,{className:"w-4 h-4"})}):i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wieder aktivieren?")&&c.mutate({id:p.id,data:{isActive:!0}})},title:"Aktivieren",children:i.jsx(Oe,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wirklich löschen?")&&d.mutate(p.id)},title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})]}),i.jsxs("p",{className:"font-mono flex items-center gap-1",children:[p.documentNumber,i.jsx(de,{value:p.documentNumber})]}),p.issuingAuthority&&i.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Ausgestellt von: ",p.issuingAuthority,i.jsx(de,{value:p.issuingAuthority})]}),p.expiryDate&&i.jsxs("p",{className:"text-sm text-gray-500",children:["Gültig bis: ",new Date(p.expiryDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})]}),p.type==="DRIVERS_LICENSE"&&p.licenseClasses&&i.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Klassen: ",p.licenseClasses,i.jsx(de,{value:p.licenseClasses})]}),p.type==="DRIVERS_LICENSE"&&p.licenseIssueDate&&i.jsxs("p",{className:"text-sm text-gray-500",children:["Klasse B seit: ",new Date(p.licenseIssueDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})]}),i.jsx("div",{className:"mt-3 pt-3 border-t",children:p.documentPath?i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsxs("a",{href:`/api${p.documentPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Oe,{className:"w-4 h-4"}),"Anzeigen"]}),i.jsxs("a",{href:`/api${p.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(qn,{className:"w-4 h-4"}),"Download"]}),n&&i.jsxs(i.Fragment,{children:[i.jsx(Jt,{onUpload:g=>u(p.id,g),existingFile:p.documentPath,accept:".pdf",label:"Ersetzen",disabled:!p.isActive}),i.jsxs("button",{onClick:()=>h(p.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[i.jsx(Ee,{className:"w-4 h-4"}),"Löschen"]})]})]}):n&&p.isActive&&i.jsx(Jt,{onUpload:g=>u(p.id,g),accept:".pdf",label:"PDF hochladen"})})]},p.id))}):i.jsx("p",{className:"text-gray-500",children:"Keine Ausweise vorhanden."})]})}function fR({customerId:t,meters:e,canEdit:n,showInactive:s,onToggleInactive:r,onAdd:a,onEdit:l}){const[o,c]=N.useState(null),[d,u]=N.useState(null),[h,m]=N.useState(null),f=ye(),p=G({mutationFn:({id:b,data:j})=>ar.update(b,j),onSuccess:()=>f.invalidateQueries({queryKey:["customer",t.toString()]})}),g=G({mutationFn:ar.delete,onSuccess:()=>f.invalidateQueries({queryKey:["customer",t.toString()]})}),x=G({mutationFn:({meterId:b,readingId:j})=>ar.deleteReading(b,j),onSuccess:()=>f.invalidateQueries({queryKey:["customer",t.toString()]})}),y=s?e:e.filter(b=>b.isActive),v=b=>b?[...b].sort((j,k)=>new Date(k.readingDate).getTime()-new Date(j.readingDate).getTime()):[];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&i.jsxs(I,{size:"sm",onClick:a,children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Zähler hinzufügen"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:s,onChange:r,className:"rounded"}),"Inaktive anzeigen"]})]}),y.length>0?i.jsx("div",{className:"space-y-4",children:y.map(b=>{const j=v(b.readings),k=d===b.id;return i.jsxs("div",{className:`border rounded-lg p-4 ${b.isActive?"":"opacity-50 bg-gray-50"}`,children:[i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(bC,{className:"w-4 h-4 text-gray-400"}),i.jsx(je,{variant:b.type==="ELECTRICITY"?"warning":"info",children:b.type==="ELECTRICITY"?"Strom":"Gas"}),!b.isActive&&i.jsx(je,{variant:"danger",children:"Inaktiv"})]}),n&&i.jsxs("div",{className:"flex gap-1",children:[b.isActive&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>c({meterId:b.id,meterType:b.type}),title:"Zählerstand hinzufügen",children:i.jsx(Ge,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(b),title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),b.isActive?i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler deaktivieren?")&&p.mutate({id:b.id,data:{isActive:!1}})},title:"Deaktivieren",children:i.jsx(on,{className:"w-4 h-4"})}):i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wieder aktivieren?")&&p.mutate({id:b.id,data:{isActive:!0}})},title:"Aktivieren",children:i.jsx(Oe,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wirklich löschen? Alle Zählerstände werden ebenfalls gelöscht.")&&g.mutate(b.id)},title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})]}),i.jsxs("p",{className:"font-mono text-lg flex items-center gap-1",children:[b.meterNumber,i.jsx(de,{value:b.meterNumber})]}),b.location&&i.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Standort: ",b.location,i.jsx(de,{value:b.location})]}),j.length>0&&i.jsxs("div",{className:"mt-3 pt-3 border-t",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("p",{className:"text-sm font-medium",children:"Zählerstände:"}),j.length>3&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>u(k?null:b.id),children:k?"Weniger anzeigen":`Alle ${j.length} anzeigen`})]}),i.jsx("div",{className:"space-y-1",children:(k?j:j.slice(0,3)).map(E=>i.jsxs("div",{className:"flex justify-between items-center text-sm group",children:[i.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(E.readingDate).toLocaleDateString("de-DE"),i.jsx(de,{value:new Date(E.readingDate).toLocaleDateString("de-DE")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"font-mono flex items-center gap-1",children:[E.value.toLocaleString("de-DE")," ",E.unit,i.jsx(de,{value:E.value.toString(),title:"Nur Wert kopieren"}),i.jsx(de,{value:`${E.value.toLocaleString("de-DE")} ${E.unit}`,title:"Mit Einheit kopieren"})]}),n&&i.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[i.jsx("button",{onClick:()=>m({meterId:b.id,meterType:b.type,reading:E}),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:i.jsx(rt,{className:"w-3 h-3"})}),i.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&x.mutate({meterId:b.id,readingId:E.id})},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:i.jsx(Ee,{className:"w-3 h-3"})})]})]})]},E.id))})]})]},b.id)})}):i.jsx("p",{className:"text-gray-500",children:"Keine Zähler vorhanden."}),o&&i.jsx(I1,{isOpen:!0,onClose:()=>c(null),meterId:o.meterId,meterType:o.meterType,customerId:t}),h&&i.jsx(I1,{isOpen:!0,onClose:()=>m(null),meterId:h.meterId,meterType:h.meterType,customerId:t,reading:h.reading})]})}function mR({customerId:t}){const{hasPermission:e}=nt(),n=fn(),s=ye(),[r,a]=N.useState(new Set),[l,o]=N.useState(!1),{data:c,isLoading:d}=fe({queryKey:["contract-tree",t],queryFn:()=>He.getTreeForCustomer(t)}),u=(c==null?void 0:c.data)||[],h=G({mutationFn:He.delete,onSuccess:()=>{s.invalidateQueries({queryKey:["customer",t.toString()]}),s.invalidateQueries({queryKey:["customers"]}),s.invalidateQueries({queryKey:["contracts"]}),s.invalidateQueries({queryKey:["contract-tree",t]})},onError:v=>{alert((v==null?void 0:v.message)||"Fehler beim Löschen des Vertrags")}}),m={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},f={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"},p=[{status:"DRAFT",label:"Entwurf",description:"Vertrag wird noch vorbereitet",color:"text-gray-600"},{status:"PENDING",label:"Ausstehend",description:"Wartet auf Aktivierung",color:"text-yellow-600"},{status:"ACTIVE",label:"Aktiv",description:"Vertrag läuft normal",color:"text-green-600"},{status:"EXPIRED",label:"Abgelaufen",description:"Laufzeit vorbei, läuft aber ohne Kündigung weiter",color:"text-orange-600"},{status:"CANCELLED",label:"Gekündigt",description:"Aktive Kündigung eingereicht, Vertrag endet",color:"text-red-600"},{status:"DEACTIVATED",label:"Deaktiviert",description:"Manuell beendet/archiviert",color:"text-gray-500"}],g=v=>{a(b=>{const j=new Set(b);return j.has(v)?j.delete(v):j.add(v),j})},x=(v,b)=>v.map(j=>i.jsx("div",{children:y(j,b)},j.contract.id)),y=(v,b=0)=>{var S,M,F,R,V,D,z;const{contract:j,predecessors:k,hasHistory:E}=v,T=r.has(j.id),w=b>0;return i.jsxs("div",{children:[i.jsxs("div",{className:`
border rounded-lg p-4 transition-colors
${w?"ml-6 border-l-4 border-l-gray-300 bg-gray-50":"hover:bg-gray-50"}
`,children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[!w&&E?i.jsx("button",{onClick:()=>g(j.id),className:"p-1 hover:bg-gray-200 rounded transition-colors",title:T?"Einklappen":"Vorgänger anzeigen",children:T?i.jsx(Us,{className:"w-4 h-4 text-gray-500"}):i.jsx(At,{className:"w-4 h-4 text-gray-500"})}):w?null:i.jsx("div",{className:"w-6"}),i.jsxs("span",{className:"font-mono flex items-center gap-1",children:[j.contractNumber,i.jsx(de,{value:j.contractNumber})]}),i.jsx(je,{children:m[j.type]||j.type}),i.jsx(je,{variant:f[j.status]||"default",children:j.status}),b===0&&!w&&i.jsx("button",{onClick:C=>{C.stopPropagation(),o(!0)},className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Status-Erklärung",children:i.jsx(bd,{className:"w-4 h-4"})}),w&&i.jsx("span",{className:"text-xs text-gray-500 ml-2",children:"(Vorgänger)"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${j.id}`,{state:{from:"customer",customerId:t.toString()}}),title:"Ansehen",children:i.jsx(Oe,{className:"w-4 h-4"})}),e("contracts:update")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${j.id}/edit`),title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),e("contracts:delete")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&h.mutate(j.id)},title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})]}),(j.providerName||((S=j.provider)==null?void 0:S.name))&&i.jsxs("p",{className:`flex items-center gap-1 ${w?"ml-6":""}`,children:[j.providerName||((M=j.provider)==null?void 0:M.name),(j.tariffName||((F=j.tariff)==null?void 0:F.name))&&` - ${j.tariffName||((R=j.tariff)==null?void 0:R.name)}`,i.jsx(de,{value:(j.providerName||((V=j.provider)==null?void 0:V.name)||"")+(j.tariffName||(D=j.tariff)!=null&&D.name?` - ${j.tariffName||((z=j.tariff)==null?void 0:z.name)}`:"")})]}),j.startDate&&i.jsxs("p",{className:`text-sm text-gray-500 ${w?"ml-6":""}`,children:["Beginn: ",new Date(j.startDate).toLocaleDateString("de-DE"),j.endDate&&` | Ende: ${new Date(j.endDate).toLocaleDateString("de-DE")}`]})]}),(b===0&&T||b>0)&&k.length>0&&i.jsx("div",{className:"mt-2",children:x(k,b+1)})]},j.id)};return d?i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):i.jsxs("div",{children:[e("contracts:create")&&i.jsx("div",{className:"mb-4",children:i.jsx(Me,{to:`/contracts/new?customerId=${t}`,children:i.jsxs(I,{size:"sm",children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Vertrag anlegen"]})})}),u.length>0?i.jsx("div",{className:"space-y-4",children:u.map(v=>y(v,0))}):i.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."}),l&&i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"fixed inset-0 bg-black/20",onClick:()=>o(!1)}),i.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"Vertragsstatus-Übersicht"}),i.jsx("button",{onClick:()=>o(!1),className:"text-gray-400 hover:text-gray-600",children:i.jsx(nn,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"space-y-2",children:p.map(({status:v,label:b,description:j,color:k})=>i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("span",{className:`font-medium text-sm min-w-[90px] ${k}`,children:b}),i.jsx("span",{className:"text-sm text-gray-600",children:j})]},v))})]})]})]})}function pR({customerId:t}){const[e,n]=N.useState(!1),[s,r]=N.useState(null),[a,l]=N.useState(!1),o=async()=>{var c;if(e){n(!1);return}l(!0);try{const d=await Zt.getPortalPassword(t);r(((c=d.data)==null?void 0:c.password)||null),n(!0)}catch(d){console.error("Fehler beim Laden des Passworts:",d),alert("Fehler beim Laden des Passworts")}finally{l(!1)}};return i.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[i.jsx("p",{className:"text-xs text-green-600",children:"Passwort ist gesetzt"}),i.jsx("button",{type:"button",onClick:o,className:"text-xs text-blue-600 hover:underline flex items-center gap-1",disabled:a,children:a?"Laden...":e?i.jsxs(i.Fragment,{children:[i.jsx(on,{className:"w-3 h-3"}),"Verbergen"]}):i.jsxs(i.Fragment,{children:[i.jsx(Oe,{className:"w-3 h-3"}),"Anzeigen"]})}),e&&s&&i.jsxs("span",{className:"text-xs font-mono bg-gray-100 px-2 py-1 rounded flex items-center gap-1",children:[s,i.jsx(de,{value:s})]}),e&&!s&&i.jsx("span",{className:"text-xs text-gray-500",children:"(Passwort nicht verfügbar)"})]})}function gR({customerId:t,canEdit:e}){const n=ye(),[s,r]=N.useState(!1),[a,l]=N.useState(""),[o,c]=N.useState(""),[d,u]=N.useState([]),[h,m]=N.useState(!1),{data:f,isLoading:p}=fe({queryKey:["customer-portal",t],queryFn:()=>Zt.getPortalSettings(t)}),{data:g,isLoading:x}=fe({queryKey:["customer-representatives",t],queryFn:()=>Zt.getRepresentatives(t)}),y=G({mutationFn:w=>Zt.updatePortalSettings(t,w),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-portal",t]})}}),v=G({mutationFn:w=>Zt.setPortalPassword(t,w),onSuccess:()=>{l(""),n.invalidateQueries({queryKey:["customer-portal",t]}),alert("Passwort wurde gesetzt")},onError:w=>{alert(w.message)}}),b=G({mutationFn:w=>Zt.addRepresentative(t,w),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",t]}),c(""),u([])},onError:w=>{alert(w.message)}}),j=G({mutationFn:w=>Zt.removeRepresentative(t,w),onSuccess:()=>{n.invalidateQueries({queryKey:["customer-representatives",t]})}}),k=async()=>{if(!(o.length<2)){m(!0);try{const w=await Zt.searchForRepresentative(t,o);u(w.data||[])}catch(w){console.error("Suche fehlgeschlagen:",w)}finally{m(!1)}}};if(p||x)return i.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."});const E=f==null?void 0:f.data,T=(g==null?void 0:g.data)||[];return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"border rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[i.jsx(Ly,{className:"w-5 h-5 text-gray-400"}),i.jsx("h3",{className:"font-medium",children:"Portal-Zugang"})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("label",{className:"flex items-center gap-3",children:[i.jsx("input",{type:"checkbox",checked:(E==null?void 0:E.portalEnabled)||!1,onChange:w=>y.mutate({portalEnabled:w.target.checked}),className:"rounded w-5 h-5",disabled:!e}),i.jsx("span",{children:"Portal aktiviert"}),(E==null?void 0:E.portalEnabled)&&i.jsx(je,{variant:"success",children:"Aktiv"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Portal E-Mail"}),i.jsx("div",{className:"flex gap-2",children:i.jsx(q,{value:(E==null?void 0:E.portalEmail)||"",onChange:w=>y.mutate({portalEmail:w.target.value||null}),placeholder:"portal@example.com",disabled:!e||!(E!=null&&E.portalEnabled),className:"flex-1"})}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Diese E-Mail wird für den Login ins Kundenportal verwendet."})]}),(E==null?void 0:E.portalEnabled)&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:E!=null&&E.hasPassword?"Neues Passwort setzen":"Passwort setzen"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(q,{type:s?"text":"password",value:a,onChange:w=>l(w.target.value),placeholder:"Mindestens 6 Zeichen",disabled:!e}),i.jsx("button",{type:"button",onClick:()=>r(!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400",children:s?i.jsx(on,{className:"w-4 h-4"}):i.jsx(Oe,{className:"w-4 h-4"})})]}),i.jsx(I,{onClick:()=>v.mutate(a),disabled:!e||a.length<6||v.isPending,children:v.isPending?"Speichern...":"Setzen"})]}),(E==null?void 0:E.hasPassword)&&i.jsx(pR,{customerId:t})]}),(E==null?void 0:E.portalLastLogin)&&i.jsxs("p",{className:"text-sm text-gray-500",children:["Letzte Anmeldung: ",new Date(E.portalLastLogin).toLocaleString("de-DE")]})]})]}),i.jsxs("div",{className:"border rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[i.jsx(U5,{className:"w-5 h-5 text-gray-400"}),i.jsx("h3",{className:"font-medium",children:"Vertreter (können Verträge einsehen)"})]}),i.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie anderen Kunden erlauben, die Verträge dieses Kunden einzusehen. Beispiel: Der Sohn kann die Verträge seiner Mutter einsehen."}),e&&i.jsxs("div",{className:"mb-4",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx(q,{value:o,onChange:w=>c(w.target.value),placeholder:"Kunden suchen (Name, Kundennummer)...",onKeyDown:w=>w.key==="Enter"&&k(),className:"flex-1"}),i.jsx(I,{variant:"secondary",onClick:k,disabled:o.length<2||h,children:i.jsx(jd,{className:"w-4 h-4"})})]}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Nur Kunden mit aktiviertem Portal können als Vertreter hinzugefügt werden."}),d.length>0&&i.jsx("div",{className:"mt-2 border rounded-lg divide-y",children:d.map(w=>i.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-gray-50",children:[i.jsxs("div",{children:[i.jsx("p",{className:"font-medium",children:w.companyName||`${w.firstName} ${w.lastName}`}),i.jsx("p",{className:"text-sm text-gray-500",children:w.customerNumber})]}),i.jsxs(I,{size:"sm",onClick:()=>b.mutate(w.id),disabled:b.isPending,children:[i.jsx(Ge,{className:"w-4 h-4 mr-1"}),"Hinzufügen"]})]},w.id))})]}),T.length>0?i.jsx("div",{className:"space-y-2",children:T.map(w=>{var S,M,F,R;return i.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg",children:[i.jsxs("div",{children:[i.jsx("p",{className:"font-medium",children:((S=w.representative)==null?void 0:S.companyName)||`${(M=w.representative)==null?void 0:M.firstName} ${(F=w.representative)==null?void 0:F.lastName}`}),i.jsx("p",{className:"text-sm text-gray-500",children:(R=w.representative)==null?void 0:R.customerNumber})]}),e&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertreter wirklich entfernen?")&&j.mutate(w.representativeId)},children:i.jsx(nn,{className:"w-4 h-4 text-red-500"})})]},w.id)})}):i.jsx("p",{className:"text-gray-500 text-sm",children:"Keine Vertreter konfiguriert."})]})]})}function D1({isOpen:t,onClose:e,customerId:n,address:s}){const r=ye(),a=!!s,l=()=>({type:(s==null?void 0:s.type)||"DELIVERY_RESIDENCE",street:(s==null?void 0:s.street)||"",houseNumber:(s==null?void 0:s.houseNumber)||"",postalCode:(s==null?void 0:s.postalCode)||"",city:(s==null?void 0:s.city)||"",country:(s==null?void 0:s.country)||"Deutschland",isDefault:(s==null?void 0:s.isDefault)||!1}),[o,c]=N.useState(l),d=G({mutationFn:f=>$g.create(n,f),onSuccess:()=>{r.invalidateQueries({queryKey:["customer",n.toString()]}),e(),c({type:"DELIVERY_RESIDENCE",street:"",houseNumber:"",postalCode:"",city:"",country:"Deutschland",isDefault:!1})}}),u=G({mutationFn:f=>$g.update(s.id,f),onSuccess:()=>{r.invalidateQueries({queryKey:["customer",n.toString()]}),e()}}),h=f=>{f.preventDefault(),a?u.mutate(o):d.mutate(o)},m=d.isPending||u.isPending;return a&&o.street!==s.street&&c(l()),i.jsx(Xe,{isOpen:t,onClose:e,title:a?"Adresse bearbeiten":"Adresse hinzufügen",children:i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsx(Fe,{label:"Adresstyp",value:o.type,onChange:f=>c({...o,type:f.target.value}),options:[{value:"DELIVERY_RESIDENCE",label:"Liefer-/Meldeadresse"},{value:"BILLING",label:"Rechnungsadresse"}]}),i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsx("div",{className:"col-span-2",children:i.jsx(q,{label:"Straße",value:o.street,onChange:f=>c({...o,street:f.target.value}),required:!0})}),i.jsx(q,{label:"Hausnr.",value:o.houseNumber,onChange:f=>c({...o,houseNumber:f.target.value}),required:!0})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsx(q,{label:"PLZ",value:o.postalCode,onChange:f=>c({...o,postalCode:f.target.value}),required:!0}),i.jsx("div",{className:"col-span-2",children:i.jsx(q,{label:"Ort",value:o.city,onChange:f=>c({...o,city:f.target.value}),required:!0})})]}),i.jsx(q,{label:"Land",value:o.country,onChange:f=>c({...o,country:f.target.value})}),i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:o.isDefault,onChange:f=>c({...o,isDefault:f.target.checked}),className:"rounded"}),"Als Standard setzen"]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:m,children:m?"Speichern...":"Speichern"})]})]})})}function M1({isOpen:t,onClose:e,customerId:n,bankCard:s}){const r=ye(),a=!!s,l=()=>({accountHolder:(s==null?void 0:s.accountHolder)||"",iban:(s==null?void 0:s.iban)||"",bic:(s==null?void 0:s.bic)||"",bankName:(s==null?void 0:s.bankName)||"",expiryDate:s!=null&&s.expiryDate?new Date(s.expiryDate).toISOString().split("T")[0]:"",isActive:(s==null?void 0:s.isActive)??!0}),[o,c]=N.useState(l);N.useState(()=>{c(l())});const d=G({mutationFn:f=>ch.create(n,f),onSuccess:()=>{r.invalidateQueries({queryKey:["customer",n.toString()]}),e(),c({accountHolder:"",iban:"",bic:"",bankName:"",expiryDate:"",isActive:!0})}}),u=G({mutationFn:f=>ch.update(s.id,f),onSuccess:()=>{r.invalidateQueries({queryKey:["customer",n.toString()]}),e()}}),h=f=>{f.preventDefault();const p={...o,expiryDate:o.expiryDate?new Date(o.expiryDate):void 0};a?u.mutate(p):d.mutate(p)},m=d.isPending||u.isPending;return a&&o.iban!==s.iban&&c(l()),i.jsx(Xe,{isOpen:t,onClose:e,title:a?"Bankkarte bearbeiten":"Bankkarte hinzufügen",children:i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsx(q,{label:"Kontoinhaber",value:o.accountHolder,onChange:f=>c({...o,accountHolder:f.target.value}),required:!0}),i.jsx(q,{label:"IBAN",value:o.iban,onChange:f=>c({...o,iban:f.target.value}),required:!0}),i.jsx(q,{label:"BIC",value:o.bic,onChange:f=>c({...o,bic:f.target.value})}),i.jsx(q,{label:"Bank",value:o.bankName,onChange:f=>c({...o,bankName:f.target.value})}),i.jsx(q,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:f=>c({...o,expiryDate:f.target.value}),onClear:()=>c({...o,expiryDate:""})}),a&&i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:o.isActive,onChange:f=>c({...o,isActive:f.target.checked}),className:"rounded"}),"Aktiv"]}),!a&&i.jsx("p",{className:"text-sm text-gray-500 bg-gray-50 p-3 rounded",children:"Dokument-Upload ist nach dem Speichern in der Übersicht möglich."}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:m,children:m?"Speichern...":"Speichern"})]})]})})}function T1({isOpen:t,onClose:e,customerId:n,document:s}){const r=ye(),a=!!s,l=()=>({type:(s==null?void 0:s.type)||"ID_CARD",documentNumber:(s==null?void 0:s.documentNumber)||"",issuingAuthority:(s==null?void 0:s.issuingAuthority)||"",issueDate:s!=null&&s.issueDate?new Date(s.issueDate).toISOString().split("T")[0]:"",expiryDate:s!=null&&s.expiryDate?new Date(s.expiryDate).toISOString().split("T")[0]:"",isActive:(s==null?void 0:s.isActive)??!0,licenseClasses:(s==null?void 0:s.licenseClasses)||"",licenseIssueDate:s!=null&&s.licenseIssueDate?new Date(s.licenseIssueDate).toISOString().split("T")[0]:""}),[o,c]=N.useState(l),d=G({mutationFn:f=>dh.create(n,f),onSuccess:()=>{r.invalidateQueries({queryKey:["customer",n.toString()]}),e(),c({type:"ID_CARD",documentNumber:"",issuingAuthority:"",issueDate:"",expiryDate:"",isActive:!0,licenseClasses:"",licenseIssueDate:""})}}),u=G({mutationFn:f=>dh.update(s.id,f),onSuccess:()=>{r.invalidateQueries({queryKey:["customer",n.toString()]}),e()}}),h=f=>{f.preventDefault();const p={...o,issueDate:o.issueDate?new Date(o.issueDate):void 0,expiryDate:o.expiryDate?new Date(o.expiryDate):void 0};o.type==="DRIVERS_LICENSE"?(p.licenseClasses=o.licenseClasses||void 0,p.licenseIssueDate=o.licenseIssueDate?new Date(o.licenseIssueDate):void 0):(delete p.licenseClasses,delete p.licenseIssueDate),a?u.mutate(p):d.mutate(p)},m=d.isPending||u.isPending;return a&&o.documentNumber!==s.documentNumber&&c(l()),i.jsx(Xe,{isOpen:t,onClose:e,title:a?"Ausweis bearbeiten":"Ausweis hinzufügen",children:i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsx(Fe,{label:"Ausweistyp",value:o.type,onChange:f=>c({...o,type:f.target.value}),options:[{value:"ID_CARD",label:"Personalausweis"},{value:"PASSPORT",label:"Reisepass"},{value:"DRIVERS_LICENSE",label:"Führerschein"},{value:"OTHER",label:"Sonstiges"}]}),i.jsx(q,{label:"Ausweisnummer",value:o.documentNumber,onChange:f=>c({...o,documentNumber:f.target.value}),required:!0}),i.jsx(q,{label:"Ausstellende Behörde",value:o.issuingAuthority,onChange:f=>c({...o,issuingAuthority:f.target.value})}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(q,{label:"Ausstellungsdatum",type:"date",value:o.issueDate,onChange:f=>c({...o,issueDate:f.target.value}),onClear:()=>c({...o,issueDate:""})}),i.jsx(q,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:f=>c({...o,expiryDate:f.target.value}),onClear:()=>c({...o,expiryDate:""})})]}),o.type==="DRIVERS_LICENSE"&&i.jsxs(i.Fragment,{children:[i.jsx(q,{label:"Führerscheinklassen",value:o.licenseClasses,onChange:f=>c({...o,licenseClasses:f.target.value}),placeholder:"z.B. B, BE, AM, L"}),i.jsx(q,{label:"Erwerb Klasse B (Pkw)",type:"date",value:o.licenseIssueDate,onChange:f=>c({...o,licenseIssueDate:f.target.value}),onClear:()=>c({...o,licenseIssueDate:""})})]}),a&&i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:o.isActive,onChange:f=>c({...o,isActive:f.target.checked}),className:"rounded"}),"Aktiv"]}),!a&&i.jsx("p",{className:"text-sm text-gray-500 bg-gray-50 p-3 rounded",children:"Dokument-Upload ist nach dem Speichern in der Übersicht möglich."}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:m,children:m?"Speichern...":"Speichern"})]})]})})}function P1({isOpen:t,onClose:e,customerId:n,meter:s}){const r=ye(),a=!!s,l=()=>({meterNumber:(s==null?void 0:s.meterNumber)||"",type:(s==null?void 0:s.type)||"ELECTRICITY",location:(s==null?void 0:s.location)||"",isActive:(s==null?void 0:s.isActive)??!0}),[o,c]=N.useState(l),d=G({mutationFn:f=>ar.create(n,f),onSuccess:()=>{r.invalidateQueries({queryKey:["customer",n.toString()]}),e(),c({meterNumber:"",type:"ELECTRICITY",location:"",isActive:!0})}}),u=G({mutationFn:f=>ar.update(s.id,f),onSuccess:()=>{r.invalidateQueries({queryKey:["customer",n.toString()]}),e()}}),h=f=>{f.preventDefault(),a?u.mutate(o):d.mutate(o)},m=d.isPending||u.isPending;return a&&o.meterNumber!==s.meterNumber&&c(l()),i.jsx(Xe,{isOpen:t,onClose:e,title:a?"Zähler bearbeiten":"Zähler hinzufügen",children:i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsx(q,{label:"Zählernummer",value:o.meterNumber,onChange:f=>c({...o,meterNumber:f.target.value}),required:!0}),i.jsx(Fe,{label:"Zählertyp",value:o.type,onChange:f=>c({...o,type:f.target.value}),options:[{value:"ELECTRICITY",label:"Strom"},{value:"GAS",label:"Gas"}]}),i.jsx(q,{label:"Standort",value:o.location,onChange:f=>c({...o,location:f.target.value}),placeholder:"z.B. Keller, Wohnung"}),a&&i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:o.isActive,onChange:f=>c({...o,isActive:f.target.checked}),className:"rounded"}),"Aktiv"]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:m,children:m?"Speichern...":"Speichern"})]})]})})}function I1({isOpen:t,onClose:e,meterId:n,meterType:s,customerId:r,reading:a}){const l=ye(),o=!!a,c=s==="ELECTRICITY"?"kWh":"m³",d=()=>{var x;return{readingDate:a!=null&&a.readingDate?new Date(a.readingDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],value:((x=a==null?void 0:a.value)==null?void 0:x.toString())||"",notes:(a==null?void 0:a.notes)||""}},[u,h]=N.useState(d),m=G({mutationFn:x=>ar.addReading(n,x),onSuccess:()=>{l.invalidateQueries({queryKey:["customer",r.toString()]}),e()}}),f=G({mutationFn:x=>ar.updateReading(n,a.id,x),onSuccess:()=>{l.invalidateQueries({queryKey:["customer",r.toString()]}),e()}}),p=x=>{x.preventDefault();const y={readingDate:new Date(u.readingDate),value:parseFloat(u.value),unit:c,notes:u.notes||void 0};o?f.mutate(y):m.mutate(y)},g=m.isPending||f.isPending;return o&&u.value!==a.value.toString()&&h(d()),i.jsx(Xe,{isOpen:t,onClose:e,title:o?"Zählerstand bearbeiten":"Zählerstand erfassen",children:i.jsxs("form",{onSubmit:p,className:"space-y-4",children:[i.jsx(q,{label:"Ablesedatum",type:"date",value:u.readingDate,onChange:x=>h({...u,readingDate:x.target.value}),required:!0}),i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsx("div",{className:"col-span-2",children:i.jsx(q,{label:"Zählerstand",type:"number",step:"0.01",value:u.value,onChange:x=>h({...u,value:x.target.value}),required:!0})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Einheit"}),i.jsx("div",{className:"h-10 flex items-center px-3 bg-gray-100 border border-gray-300 rounded-md text-gray-700",children:c})]})]}),i.jsx(q,{label:"Notizen",value:u.notes,onChange:x=>h({...u,notes:x.target.value}),placeholder:"Optionale Notizen..."}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:g,children:g?"Speichern...":"Speichern"})]})]})})}const Lm="@stressfrei-wechseln.de";function xR({customerId:t,emails:e,canEdit:n,showInactive:s,onToggleInactive:r,onAdd:a,onEdit:l}){const o=ye(),c=G({mutationFn:({id:h,data:m})=>ts.update(h,m),onSuccess:()=>o.invalidateQueries({queryKey:["customer",t.toString()]})}),d=G({mutationFn:ts.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",t.toString()]})}),u=s?e:e.filter(h=>h.isActive);return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[n&&i.jsxs(I,{size:"sm",onClick:a,children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]}),i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:s,onChange:r,className:"rounded"}),"Inaktive anzeigen"]})]}),i.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[i.jsx("strong",{children:"Hinweis:"})," Hier werden E-Mail-Weiterleitungsadressen verwaltet, die für die Registrierung bei Anbietern verwendet werden. E-Mails an diese Adressen werden sowohl an den Kunden als auch an Sie weitergeleitet."]}),u.length>0?i.jsx("div",{className:"space-y-3",children:u.map(h=>i.jsx("div",{className:`border rounded-lg p-4 ${h.isActive?"":"opacity-50 bg-gray-50"}`,children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Fs,{className:"w-4 h-4 text-gray-400"}),i.jsx("span",{className:"font-mono text-sm",children:h.email}),i.jsx(de,{value:h.email}),!h.isActive&&i.jsx(je,{variant:"danger",children:"Inaktiv"})]}),h.notes&&i.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-gray-500",children:[i.jsx(We,{className:"w-4 h-4 flex-shrink-0"}),i.jsx("span",{children:h.notes})]})]}),n&&i.jsxs("div",{className:"flex gap-1",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(h),title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),h.isActive?i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse deaktivieren?")&&c.mutate({id:h.id,data:{isActive:!1}})},title:"Deaktivieren",children:i.jsx(on,{className:"w-4 h-4"})}):i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wieder aktivieren?")&&c.mutate({id:h.id,data:{isActive:!0}})},title:"Aktivieren",children:i.jsx(Oe,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&d.mutate(h.id)},title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})]})},h.id))}):i.jsx("p",{className:"text-gray-500",children:"Keine Stressfrei-Wechseln Adressen vorhanden."})]})}function yR({credentials:t,onHide:e,onResetPassword:n,isResettingPassword:s}){const[r,a]=N.useState(null),l=async(u,h)=>{try{await navigator.clipboard.writeText(u),a(h),setTimeout(()=>a(null),2e3)}catch{const m=document.createElement("textarea");m.value=u,document.body.appendChild(m),m.select(),document.execCommand("copy"),document.body.removeChild(m),a(h),setTimeout(()=>a(null),2e3)}},o=({text:u,fieldName:h})=>i.jsx("button",{type:"button",onClick:()=>l(u,h),className:"p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors",title:"In Zwischenablage kopieren",children:r===h?i.jsx(Vr,{className:"w-4 h-4 text-green-600"}):i.jsx(Iy,{className:"w-4 h-4"})}),c=t.imap?`${t.imap.server}:${t.imap.port}`:"",d=t.smtp?`${t.smtp.server}:${t.smtp.port}`:"";return i.jsxs("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4 space-y-3",children:[i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsx("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wide",children:"Zugangsdaten"}),i.jsx("button",{type:"button",onClick:e,className:"text-gray-400 hover:text-gray-600 p-1 hover:bg-gray-200 rounded",title:"Zugangsdaten ausblenden",children:i.jsx(on,{className:"w-4 h-4"})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[i.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Benutzername"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1 break-all",children:t.email}),i.jsx(o,{text:t.email,fieldName:"email"})]})]}),i.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[i.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Passwort"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1 break-all",children:t.password}),i.jsx(o,{text:t.password,fieldName:"password"})]}),i.jsx("button",{type:"button",onClick:n,disabled:s,className:"mt-2 text-xs text-blue-600 hover:text-blue-800 disabled:opacity-50",children:s?"Generiere...":"Neu generieren"})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.imap&&i.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[i.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"IMAP (Empfang)"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1",children:c}),i.jsx(o,{text:c,fieldName:"imap"})]}),i.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:t.imap.encryption})]}),t.smtp&&i.jsxs("div",{className:"bg-white rounded-lg p-3 border border-gray-100",children:[i.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"SMTP (Versand)"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"text-sm text-gray-900 font-mono flex-1",children:d}),i.jsx(o,{text:d,fieldName:"smtp"})]}),i.jsx("span",{className:"text-xs text-gray-400 mt-1 block",children:t.smtp.encryption})]})]})]})}function R1({isOpen:t,onClose:e,customerId:n,email:s,customerEmail:r}){const[a,l]=N.useState(""),[o,c]=N.useState(""),[d,u]=N.useState(!1),[h,m]=N.useState(!1),[f,p]=N.useState(null),[g,x]=N.useState("idle"),[y,v]=N.useState(!1),[b,j]=N.useState(!1),[k,E]=N.useState(!1),[T,w]=N.useState(!1),[S,M]=N.useState(null),[F,R]=N.useState(!1),[V,D]=N.useState(!1),z=ye(),C=!!s,{data:_}=fe({queryKey:["email-provider-configs"],queryFn:()=>wr.getConfigs(),enabled:t}),K=((_==null?void 0:_.data)||[]).some(le=>le.isActive&&le.isDefault),B=le=>{if(!le)return"";const it=le.indexOf("@");return it>0?le.substring(0,it):le},W=async le=>{var it;if(!(!K||!le)){x("checking");try{const Rt=await wr.checkEmailExists(le);x((it=Rt.data)!=null&&it.exists?"exists":"not_exists")}catch{x("error")}}},ce=async()=>{var le,it;if(!(!r||!a)){v(!0),p(null);try{const Rt=await wr.provisionEmail(a,r);(le=Rt.data)!=null&&le.success?x("exists"):p(((it=Rt.data)==null?void 0:it.error)||"Provisionierung fehlgeschlagen")}catch(Rt){p(Rt instanceof Error?Rt.message:"Fehler bei der Provisionierung")}finally{v(!1)}}},he=async()=>{if(s){j(!0),p(null);try{const le=await ts.enableMailbox(s.id);le.success?(E(!0),z.invalidateQueries({queryKey:["customer",n.toString()]}),z.invalidateQueries({queryKey:["mailbox-accounts",n]})):p(le.error||"Mailbox-Aktivierung fehlgeschlagen")}catch(le){p(le instanceof Error?le.message:"Fehler bei der Mailbox-Aktivierung")}finally{j(!1)}}},Je=async()=>{if(s)try{const le=await ts.syncMailboxStatus(s.id);le.success&&le.data&&(E(le.data.hasMailbox),le.data.wasUpdated&&z.invalidateQueries({queryKey:["customer",n.toString()]}))}catch(le){console.error("Fehler beim Synchronisieren des Mailbox-Status:",le)}},et=async()=>{if(s){R(!0);try{const le=await ts.getMailboxCredentials(s.id);le.success&&le.data&&(M(le.data),w(!0))}catch(le){console.error("Fehler beim Laden der Zugangsdaten:",le)}finally{R(!1)}}},mt=async()=>{if(s&&confirm("Neues Passwort generieren? Das alte Passwort wird ungültig.")){D(!0);try{const le=await ts.resetPassword(s.id);le.success&&le.data?(S&&M({...S,password:le.data.password}),alert("Passwort wurde erfolgreich zurückgesetzt.")):alert(le.error||"Fehler beim Zurücksetzen des Passworts")}catch(le){console.error("Fehler beim Zurücksetzen des Passworts:",le),alert(le instanceof Error?le.message:"Fehler beim Zurücksetzen des Passworts")}finally{D(!1)}}};N.useEffect(()=>{if(t){if(s){const le=B(s.email);l(le),c(s.notes||""),x("idle"),E(s.hasMailbox||!1),K&&(W(le),Je())}else l(""),c(""),u(!1),m(!1),x("idle"),E(!1);p(null),w(!1),M(null)}},[t,s,K]);const A=G({mutationFn:async le=>ts.create(n,{email:le.email,notes:le.notes,provisionAtProvider:le.provision,createMailbox:le.createMailbox}),onSuccess:()=>{z.invalidateQueries({queryKey:["customer",n.toString()]}),z.invalidateQueries({queryKey:["mailbox-accounts",n]}),l(""),c(""),u(!1),m(!1),e()},onError:le=>{p(le instanceof Error?le.message:"Fehler bei der Provisionierung")}}),pt=G({mutationFn:le=>ts.update(s.id,le),onSuccess:()=>{z.invalidateQueries({queryKey:["customer",n.toString()]}),e()}}),On=le=>{le.preventDefault(),p(null);const it=a+Lm;C?pt.mutate({email:it,notes:o||void 0}):A.mutate({email:it,notes:o||void 0,provision:d,createMailbox:d&&h})},wn=A.isPending||pt.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:C?"Adresse bearbeiten":"Adresse hinzufügen",children:i.jsxs("form",{onSubmit:On,className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"E-Mail-Adresse"}),i.jsxs("div",{className:"flex",children:[i.jsx("input",{type:"text",value:a,onChange:le=>l(le.target.value.toLowerCase().replace(/[^a-z0-9._-]/g,"")),placeholder:"kunde-freenet",required:!0,className:"block w-full px-3 py-2 border border-gray-300 rounded-l-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),i.jsx("span",{className:"inline-flex items-center px-3 py-2 border border-l-0 border-gray-300 bg-gray-100 text-gray-600 rounded-r-lg text-sm",children:Lm})]}),i.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Vollständige Adresse: ",i.jsxs("span",{className:"font-mono",children:[a||"...",Lm]})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Notizen (optional)"}),i.jsx("textarea",{value:o,onChange:le=>c(le.target.value),rows:3,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"z.B. für Freenet-Konten, für Klarmobil..."})]}),K&&r&&i.jsx("div",{className:"bg-blue-50 p-3 rounded-lg",children:C?i.jsxs("div",{className:"space-y-2",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm font-medium text-gray-700",children:"E-Mail-Provider Status"}),g==="checking"&&i.jsx("span",{className:"text-xs text-gray-500",children:"Prüfe..."}),g==="exists"&&i.jsxs("span",{className:"text-xs text-green-600 flex items-center gap-1",children:[i.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:i.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),"Beim Provider vorhanden"]}),g==="not_exists"&&i.jsx("span",{className:"text-xs text-orange-600",children:"Nicht beim Provider angelegt"}),g==="error"&&i.jsx("span",{className:"text-xs text-red-600",children:"Status konnte nicht geprüft werden"})]}),g==="not_exists"&&i.jsxs("div",{className:"pt-2 border-t border-blue-100",children:[i.jsxs("p",{className:"text-xs text-gray-500 mb-2",children:["Die E-Mail-Weiterleitung ist noch nicht auf dem Server eingerichtet. Weiterleitungsziel: ",r]}),i.jsx(I,{type:"button",size:"sm",onClick:ce,disabled:y,children:y?"Wird angelegt...":"Jetzt beim Provider anlegen"})]}),g==="error"&&i.jsx(I,{type:"button",size:"sm",variant:"secondary",onClick:()=>W(a),children:"Erneut prüfen"}),g==="exists"&&i.jsxs("div",{className:"pt-3 mt-3 border-t border-blue-100",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Mailbox (IMAP/SMTP)"}),k?i.jsxs("span",{className:"text-xs text-green-600 flex items-center gap-1",children:[i.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:i.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),"Mailbox aktiv"]}):i.jsx("span",{className:"text-xs text-orange-600",children:"Keine Mailbox"})]}),!k&&i.jsxs("div",{className:"mt-2",children:[i.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Aktiviere eine echte Mailbox um E-Mails direkt im CRM zu empfangen und zu versenden."}),i.jsx(I,{type:"button",size:"sm",onClick:he,disabled:b,children:b?"Wird aktiviert...":"Mailbox aktivieren"})]}),k&&i.jsx("div",{className:"mt-3",children:T?S&&i.jsx(yR,{credentials:S,onHide:()=>w(!1),onResetPassword:mt,isResettingPassword:V}):i.jsx(I,{type:"button",size:"sm",variant:"secondary",onClick:et,disabled:F,children:F?"Laden...":i.jsxs(i.Fragment,{children:[i.jsx(Oe,{className:"w-4 h-4 mr-1"}),"Zugangsdaten anzeigen"]})})})]})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:d,onChange:le=>{u(le.target.checked),le.target.checked||m(!1)},className:"mt-1 rounded border-gray-300"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Beim E-Mail-Provider anlegen"}),i.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Die E-Mail-Weiterleitung wird automatisch auf dem konfigurierten Server erstellt. Weiterleitungsziel: ",r]})]})]}),d&&i.jsxs("label",{className:"flex items-start gap-2 cursor-pointer ml-6",children:[i.jsx("input",{type:"checkbox",checked:h,onChange:le=>m(le.target.checked),className:"mt-1 rounded border-gray-300"}),i.jsxs("div",{children:[i.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Echte Mailbox erstellen (IMAP/SMTP-Zugang)"}),i.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Ermöglicht E-Mails direkt im CRM zu empfangen und zu versenden."})]})]})]})}),f&&i.jsx("div",{className:"bg-red-50 p-3 rounded-lg text-red-700 text-sm",children:f}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:wn||!a,children:wn?"Speichern...":"Speichern"})]})]})})}const vR={DATA_PROCESSING:{label:"Datenverarbeitung",description:"Grundlegende Verarbeitung personenbezogener Daten zur Vertragserfüllung"},MARKETING_EMAIL:{label:"E-Mail-Marketing",description:"Zusendung von Werbung und Angeboten per E-Mail"},MARKETING_PHONE:{label:"Telefonmarketing",description:"Kontaktaufnahme zu Werbezwecken per Telefon"},DATA_SHARING_PARTNER:{label:"Datenweitergabe",description:"Weitergabe von Daten an Partnerunternehmen"}};function bR({customerId:t,canEdit:e,customerEmail:n}){const s=ye(),{user:r}=nt(),[a,l]=N.useState(!1),[o,c]=N.useState(!1),{data:d,isLoading:u}=fe({queryKey:["customer-consents",t],queryFn:()=>Mr.getCustomerConsents(t)}),h=G({mutationFn:j=>Mr.sendConsentLink(t,j),onSuccess:(j,k)=>{var T;const E=(T=j.data)==null?void 0:T.url;if(E){if(k==="copy")navigator.clipboard.writeText(E),c(!0),setTimeout(()=>c(!1),2e3);else if(k==="email")alert("Consent-Link wurde per E-Mail gesendet.");else if(k==="whatsapp"){const w=encodeURIComponent(`Bitte stimmen Sie unserer Datenschutzerklärung zu: ${E}`);window.open(`https://wa.me/?text=${w}`,"_blank")}else if(k==="telegram"){const w=encodeURIComponent(`Bitte stimmen Sie unserer Datenschutzerklärung zu: ${E}`);window.open(`https://t.me/share/url?url=${encodeURIComponent(E)}&text=${w}`,"_blank")}else if(k==="signal"){const w=encodeURIComponent(`Bitte stimmen Sie unserer Datenschutzerklärung zu: ${E}`);window.open(`signal://send?text=${w}`,"_blank")}l(!1)}}}),m=G({mutationFn:({consentType:j,status:k,source:E})=>Mr.updateConsent(t,j,{status:k,source:E}),onSuccess:()=>{s.invalidateQueries({queryKey:["customer-consents",t]})}}),f=j=>{const k=j.status==="GRANTED"?"WITHDRAWN":"GRANTED";m.mutate({consentType:j.consentType,status:k,source:"crm-backend"})},p=j=>{switch(j){case"GRANTED":return i.jsx(SC,{className:"w-5 h-5 text-green-500"});case"WITHDRAWN":return i.jsx(CC,{className:"w-5 h-5 text-red-500"});case"PENDING":return i.jsx(hh,{className:"w-5 h-5 text-yellow-500"});default:return i.jsx(lr,{className:"w-5 h-5 text-gray-400"})}},g=j=>{switch(j){case"GRANTED":return i.jsx(je,{variant:"success",children:"Erteilt"});case"WITHDRAWN":return i.jsx(je,{variant:"danger",children:"Widerrufen"});case"PENDING":return i.jsx(je,{variant:"warning",children:"Ausstehend"});default:return i.jsx(je,{children:j})}},x=j=>j?new Date(j).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):"-";if(u)return i.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."});const y=(d==null?void 0:d.data)||[],v=r,b=[{key:"email",label:"Per E-Mail",icon:"✉️",available:!!n},{key:"whatsapp",label:"Per WhatsApp",icon:"💬",available:!!(v!=null&&v.whatsappNumber)},{key:"telegram",label:"Per Telegram",icon:"📨",available:!!(v!=null&&v.telegramUsername)},{key:"signal",label:"Per Signal",icon:"📱",available:!!(v!=null&&v.signalNumber)},{key:"copy",label:"Link kopieren",icon:"🔗",available:!0}];return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(lr,{className:"w-5 h-5 text-gray-400"}),i.jsx("h3",{className:"font-medium",children:"DSGVO-Einwilligungen"})]}),i.jsxs("div",{className:"relative",children:[i.jsxs(I,{variant:"secondary",size:"sm",onClick:()=>l(!a),children:[i.jsx(Fs,{className:"w-4 h-4 mr-2"}),"Datenschutz senden",i.jsx(Us,{className:"w-3 h-3 ml-1"})]}),a&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>l(!1)}),i.jsxs("div",{className:"absolute right-0 mt-1 w-56 bg-white border rounded-lg shadow-lg z-20 py-1",children:[b.filter(j=>j.available).map(j=>i.jsxs("button",{className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-50 flex items-center gap-2",onClick:()=>h.mutate(j.key),disabled:h.isPending,children:[i.jsx("span",{children:j.icon}),i.jsx("span",{children:j.label}),j.key==="copy"&&o&&i.jsx(Vr,{className:"w-4 h-4 text-green-500 ml-auto"})]},j.key)),b.filter(j=>j.available).length===1&&i.jsx("p",{className:"px-4 py-2 text-xs text-gray-400",children:"Weitere Kanäle in Benutzereinstellungen konfigurieren"})]})]})]})]}),i.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Einwilligungen können nur vom Kunden selbst erteilt oder widerrufen werden (Kundenportal oder Datenschutz-Link)."}),i.jsx("div",{className:"space-y-4",children:y.map(j=>{const k=vR[j.consentType]||{label:j.consentType,description:""};return i.jsx("div",{className:"border rounded-lg p-4",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex items-start gap-3",children:[p(j.status),i.jsxs("div",{children:[i.jsx("h4",{className:"font-medium",children:k.label}),i.jsx("p",{className:"text-sm text-gray-500",children:k.description}),i.jsxs("div",{className:"mt-2 flex items-center gap-4 text-xs text-gray-500",children:[j.grantedAt&&i.jsxs("span",{children:["Erteilt am: ",x(j.grantedAt)]}),j.withdrawnAt&&i.jsxs("span",{children:["Widerrufen am: ",x(j.withdrawnAt)]}),j.source&&i.jsxs("span",{children:["Quelle: ",j.source]})]})]})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[g(j.status),e&&i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:j.status==="GRANTED",onChange:()=>f(j),disabled:m.isPending,className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-green-600"})]})]})]})},j.consentType)})}),y.length===0&&i.jsx("p",{className:"text-gray-500 text-center py-4",children:"Keine Einwilligungen konfiguriert."})]})}var wd=t=>t.type==="checkbox",oa=t=>t instanceof Date,Bn=t=>t==null;const PC=t=>typeof t=="object";var $t=t=>!Bn(t)&&!Array.isArray(t)&&PC(t)&&!oa(t),jR=t=>$t(t)&&t.target?wd(t.target)?t.target.checked:t.target.value:t,NR=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,wR=(t,e)=>t.has(NR(e)),kR=t=>{const e=t.constructor&&t.constructor.prototype;return $t(e)&&e.hasOwnProperty("isPrototypeOf")},Vy=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Vt(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(Vy&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!($t(t)&&kR(t)))return t;const s=n?[]:Object.create(Object.getPrototypeOf(t));for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=Vt(t[r]));return s}var Lf=t=>/^\w*$/.test(t),gt=t=>t===void 0,Ky=t=>Array.isArray(t)?t.filter(Boolean):[],Uy=t=>Ky(t.replace(/["|']|\]/g,"").split(/\.|\[/)),be=(t,e,n)=>{if(!e||!$t(t))return n;const s=(Lf(e)?[e]:Uy(e)).reduce((r,a)=>Bn(r)?r:r[a],t);return gt(s)||s===t?gt(t[e])?n:t[e]:s},Ys=t=>typeof t=="boolean",Rs=t=>typeof t=="function",dt=(t,e,n)=>{let s=-1;const r=Lf(e)?[e]:Uy(e),a=r.length,l=a-1;for(;++s<a;){const o=r[s];let c=n;if(s!==l){const d=t[o];c=$t(d)||Array.isArray(d)?d:isNaN(+r[s+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;t[o]=c,t=t[o]}};const O1={BLUR:"blur",FOCUS_OUT:"focusout"},Os={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},mr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},SR=ut.createContext(null);SR.displayName="HookFormControlContext";var CR=(t,e,n,s=!0)=>{const r={defaultValues:e._defaultValues};for(const a in t)Object.defineProperty(r,a,{get:()=>{const l=a;return e._proxyFormState[l]!==Os.all&&(e._proxyFormState[l]=!s||Os.all),t[l]}});return r};const ER=typeof window<"u"?ut.useLayoutEffect:ut.useEffect;var ns=t=>typeof t=="string",AR=(t,e,n,s,r)=>ns(t)?(s&&e.watch.add(t),be(n,t,r)):Array.isArray(t)?t.map(a=>(s&&e.watch.add(a),be(n,a))):(s&&(e.watchAll=!0),n),Kg=t=>Bn(t)||!PC(t);function li(t,e,n=new WeakSet){if(Kg(t)||Kg(e))return Object.is(t,e);if(oa(t)&&oa(e))return Object.is(t.getTime(),e.getTime());const s=Object.keys(t),r=Object.keys(e);if(s.length!==r.length)return!1;if(n.has(t)||n.has(e))return!0;n.add(t),n.add(e);for(const a of s){const l=t[a];if(!r.includes(a))return!1;if(a!=="ref"){const o=e[a];if(oa(l)&&oa(o)||$t(l)&&$t(o)||Array.isArray(l)&&Array.isArray(o)?!li(l,o,n):!Object.is(l,o))return!1}}return!0}const DR=ut.createContext(null);DR.displayName="HookFormContext";var MR=(t,e,n,s,r)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[s]:r||!0}}:{},rc=t=>Array.isArray(t)?t:[t],L1=()=>{let t=[];return{get observers(){return t},next:r=>{for(const a of t)a.next&&a.next(r)},subscribe:r=>(t.push(r),{unsubscribe:()=>{t=t.filter(a=>a!==r)}}),unsubscribe:()=>{t=[]}}};function IC(t,e){const n={};for(const s in t)if(t.hasOwnProperty(s)){const r=t[s],a=e[s];if(r&&$t(r)&&a){const l=IC(r,a);$t(l)&&(n[s]=l)}else t[s]&&(n[s]=a)}return n}var Cn=t=>$t(t)&&!Object.keys(t).length,qy=t=>t.type==="file",fh=t=>{if(!Vy)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},RC=t=>t.type==="select-multiple",Hy=t=>t.type==="radio",TR=t=>Hy(t)||wd(t),Fm=t=>fh(t)&&t.isConnected;function PR(t,e){const n=e.slice(0,-1).length;let s=0;for(;s<n;)t=gt(t)?s++:t[e[s++]];return t}function IR(t){for(const e in t)if(t.hasOwnProperty(e)&&!gt(t[e]))return!1;return!0}function Lt(t,e){const n=Array.isArray(e)?e:Lf(e)?[e]:Uy(e),s=n.length===1?t:PR(t,n),r=n.length-1,a=n[r];return s&&delete s[a],r!==0&&($t(s)&&Cn(s)||Array.isArray(s)&&IR(s))&&Lt(t,n.slice(0,-1)),t}var RR=t=>{for(const e in t)if(Rs(t[e]))return!0;return!1};function OC(t){return Array.isArray(t)||$t(t)&&!RR(t)}function Ug(t,e={}){for(const n in t){const s=t[n];OC(s)?(e[n]=Array.isArray(s)?[]:{},Ug(s,e[n])):gt(s)||(e[n]=!0)}return e}function rl(t,e,n){n||(n=Ug(e));for(const s in t){const r=t[s];if(OC(r))gt(e)||Kg(n[s])?n[s]=Ug(r,Array.isArray(r)?[]:{}):rl(r,Bn(e)?{}:e[s],n[s]);else{const a=e[s];n[s]=!li(r,a)}}return n}const F1={value:!1,isValid:!1},z1={value:!0,isValid:!0};var LC=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!gt(t[0].attributes.value)?gt(t[0].value)||t[0].value===""?z1:{value:t[0].value,isValid:!0}:z1:F1}return F1},FC=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:s})=>gt(t)?t:e?t===""?NaN:t&&+t:n&&ns(t)?new Date(t):s?s(t):t;const $1={isValid:!1,value:null};var zC=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,$1):$1;function B1(t){const e=t.ref;return qy(e)?e.files:Hy(e)?zC(t.refs).value:RC(e)?[...e.selectedOptions].map(({value:n})=>n):wd(e)?LC(t.refs).value:FC(gt(e.value)?t.ref.value:e.value,t)}var OR=(t,e,n,s)=>{const r={};for(const a of t){const l=be(e,a);l&&dt(r,a,l._f)}return{criteriaMode:n,names:[...t],fields:r,shouldUseNativeValidation:s}},mh=t=>t instanceof RegExp,Io=t=>gt(t)?t:mh(t)?t.source:$t(t)?mh(t.value)?t.value.source:t.value:t,_1=t=>({isOnSubmit:!t||t===Os.onSubmit,isOnBlur:t===Os.onBlur,isOnChange:t===Os.onChange,isOnAll:t===Os.all,isOnTouch:t===Os.onTouched});const V1="AsyncFunction";var LR=t=>!!t&&!!t.validate&&!!(Rs(t.validate)&&t.validate.constructor.name===V1||$t(t.validate)&&Object.values(t.validate).find(e=>e.constructor.name===V1)),FR=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),K1=(t,e,n)=>!n&&(e.watchAll||e.watch.has(t)||[...e.watch].some(s=>t.startsWith(s)&&/^\.\w+/.test(t.slice(s.length))));const ic=(t,e,n,s)=>{for(const r of n||Object.keys(t)){const a=be(t,r);if(a){const{_f:l,...o}=a;if(l){if(l.refs&&l.refs[0]&&e(l.refs[0],r)&&!s)return!0;if(l.ref&&e(l.ref,l.name)&&!s)return!0;if(ic(o,e))break}else if($t(o)&&ic(o,e))break}}};function U1(t,e,n){const s=be(t,n);if(s||Lf(n))return{error:s,name:n};const r=n.split(".");for(;r.length;){const a=r.join("."),l=be(e,a),o=be(t,a);if(l&&!Array.isArray(l)&&n!==a)return{name:n};if(o&&o.type)return{name:a,error:o};if(o&&o.root&&o.root.type)return{name:`${a}.root`,error:o.root};r.pop()}return{name:n}}var zR=(t,e,n,s)=>{n(t);const{name:r,...a}=t;return Cn(a)||Object.keys(a).length>=Object.keys(e).length||Object.keys(a).find(l=>e[l]===(!s||Os.all))},$R=(t,e,n)=>!t||!e||t===e||rc(t).some(s=>s&&(n?s===e:s.startsWith(e)||e.startsWith(s))),BR=(t,e,n,s,r)=>r.isOnAll?!1:!n&&r.isOnTouch?!(e||t):(n?s.isOnBlur:r.isOnBlur)?!t:(n?s.isOnChange:r.isOnChange)?t:!0,_R=(t,e)=>!Ky(be(t,e)).length&&Lt(t,e),VR=(t,e,n)=>{const s=rc(be(t,n));return dt(s,"root",e[n]),dt(t,n,s),t};function q1(t,e,n="validate"){if(ns(t)||Array.isArray(t)&&t.every(ns)||Ys(t)&&!t)return{type:n,message:ns(t)?t:"",ref:e}}var el=t=>$t(t)&&!mh(t)?t:{value:t,message:""},H1=async(t,e,n,s,r,a)=>{const{ref:l,refs:o,required:c,maxLength:d,minLength:u,min:h,max:m,pattern:f,validate:p,name:g,valueAsNumber:x,mount:y}=t._f,v=be(n,g);if(!y||e.has(g))return{};const b=o?o[0]:l,j=R=>{r&&b.reportValidity&&(b.setCustomValidity(Ys(R)?"":R||""),b.reportValidity())},k={},E=Hy(l),T=wd(l),w=E||T,S=(x||qy(l))&&gt(l.value)&&gt(v)||fh(l)&&l.value===""||v===""||Array.isArray(v)&&!v.length,M=MR.bind(null,g,s,k),F=(R,V,D,z=mr.maxLength,C=mr.minLength)=>{const _=R?V:D;k[g]={type:R?z:C,message:_,ref:l,...M(R?z:C,_)}};if(a?!Array.isArray(v)||!v.length:c&&(!w&&(S||Bn(v))||Ys(v)&&!v||T&&!LC(o).isValid||E&&!zC(o).isValid)){const{value:R,message:V}=ns(c)?{value:!!c,message:c}:el(c);if(R&&(k[g]={type:mr.required,message:V,ref:b,...M(mr.required,V)},!s))return j(V),k}if(!S&&(!Bn(h)||!Bn(m))){let R,V;const D=el(m),z=el(h);if(!Bn(v)&&!isNaN(v)){const C=l.valueAsNumber||v&&+v;Bn(D.value)||(R=C>D.value),Bn(z.value)||(V=C<z.value)}else{const C=l.valueAsDate||new Date(v),_=W=>new Date(new Date().toDateString()+" "+W),K=l.type=="time",B=l.type=="week";ns(D.value)&&v&&(R=K?_(v)>_(D.value):B?v>D.value:C>new Date(D.value)),ns(z.value)&&v&&(V=K?_(v)<_(z.value):B?v<z.value:C<new Date(z.value))}if((R||V)&&(F(!!R,D.message,z.message,mr.max,mr.min),!s))return j(k[g].message),k}if((d||u)&&!S&&(ns(v)||a&&Array.isArray(v))){const R=el(d),V=el(u),D=!Bn(R.value)&&v.length>+R.value,z=!Bn(V.value)&&v.length<+V.value;if((D||z)&&(F(D,R.message,V.message),!s))return j(k[g].message),k}if(f&&!S&&ns(v)){const{value:R,message:V}=el(f);if(mh(R)&&!v.match(R)&&(k[g]={type:mr.pattern,message:V,ref:l,...M(mr.pattern,V)},!s))return j(V),k}if(p){if(Rs(p)){const R=await p(v,n),V=q1(R,b);if(V&&(k[g]={...V,...M(mr.validate,V.message)},!s))return j(V.message),k}else if($t(p)){let R={};for(const V in p){if(!Cn(R)&&!s)break;const D=q1(await p[V](v,n),b,V);D&&(R={...D,...M(V,D.message)},j(D.message),s&&(k[g]=R))}if(!Cn(R)&&(k[g]={ref:b,...R},!s))return k}}return j(!0),k};const KR={mode:Os.onSubmit,reValidateMode:Os.onChange,shouldFocusError:!0};function UR(t={}){let e={...KR,...t},n={submitCount:0,isDirty:!1,isReady:!1,isLoading:Rs(e.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1},s={},r=$t(e.defaultValues)||$t(e.values)?Vt(e.defaultValues||e.values)||{}:{},a=e.shouldUnregister?{}:Vt(r),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},o={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},h={...u};let m={...h};const f={array:L1(),state:L1()},p=e.criteriaMode===Os.all,g=L=>U=>{clearTimeout(d),d=setTimeout(L,U)},x=async L=>{if(!l.keepIsValid&&!e.disabled&&(h.isValid||m.isValid||L)){let U;e.resolver?(U=Cn((await w()).errors),y()):U=await M(s,!0),U!==n.isValid&&f.state.next({isValid:U})}},y=(L,U)=>{!e.disabled&&(h.isValidating||h.validatingFields||m.isValidating||m.validatingFields)&&((L||Array.from(o.mount)).forEach(Q=>{Q&&(U?dt(n.validatingFields,Q,U):Lt(n.validatingFields,Q))}),f.state.next({validatingFields:n.validatingFields,isValidating:!Cn(n.validatingFields)}))},v=(L,U=[],Q,ue,ie=!0,se=!0)=>{if(ue&&Q&&!e.disabled){if(l.action=!0,se&&Array.isArray(be(s,L))){const Ne=Q(be(s,L),ue.argA,ue.argB);ie&&dt(s,L,Ne)}if(se&&Array.isArray(be(n.errors,L))){const Ne=Q(be(n.errors,L),ue.argA,ue.argB);ie&&dt(n.errors,L,Ne),_R(n.errors,L)}if((h.touchedFields||m.touchedFields)&&se&&Array.isArray(be(n.touchedFields,L))){const Ne=Q(be(n.touchedFields,L),ue.argA,ue.argB);ie&&dt(n.touchedFields,L,Ne)}(h.dirtyFields||m.dirtyFields)&&(n.dirtyFields=rl(r,a)),f.state.next({name:L,isDirty:R(L,U),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else dt(a,L,U)},b=(L,U)=>{dt(n.errors,L,U),f.state.next({errors:n.errors})},j=L=>{n.errors=L,f.state.next({errors:n.errors,isValid:!1})},k=(L,U,Q,ue)=>{const ie=be(s,L);if(ie){const se=be(a,L,gt(Q)?be(r,L):Q);gt(se)||ue&&ue.defaultChecked||U?dt(a,L,U?se:B1(ie._f)):z(L,se),l.mount&&!l.action&&x()}},E=(L,U,Q,ue,ie)=>{let se=!1,Ne=!1;const qe={name:L};if(!e.disabled){if(!Q||ue){(h.isDirty||m.isDirty)&&(Ne=n.isDirty,n.isDirty=qe.isDirty=R(),se=Ne!==qe.isDirty);const _e=li(be(r,L),U);Ne=!!be(n.dirtyFields,L),_e?Lt(n.dirtyFields,L):dt(n.dirtyFields,L,!0),qe.dirtyFields=n.dirtyFields,se=se||(h.dirtyFields||m.dirtyFields)&&Ne!==!_e}if(Q){const _e=be(n.touchedFields,L);_e||(dt(n.touchedFields,L,Q),qe.touchedFields=n.touchedFields,se=se||(h.touchedFields||m.touchedFields)&&_e!==Q)}se&&ie&&f.state.next(qe)}return se?qe:{}},T=(L,U,Q,ue)=>{const ie=be(n.errors,L),se=(h.isValid||m.isValid)&&Ys(U)&&n.isValid!==U;if(e.delayError&&Q?(c=g(()=>b(L,Q)),c(e.delayError)):(clearTimeout(d),c=null,Q?dt(n.errors,L,Q):Lt(n.errors,L)),(Q?!li(ie,Q):ie)||!Cn(ue)||se){const Ne={...ue,...se&&Ys(U)?{isValid:U}:{},errors:n.errors,name:L};n={...n,...Ne},f.state.next(Ne)}},w=async L=>(y(L,!0),await e.resolver(a,e.context,OR(L||o.mount,s,e.criteriaMode,e.shouldUseNativeValidation))),S=async L=>{const{errors:U}=await w(L);if(y(L),L)for(const Q of L){const ue=be(U,Q);ue?dt(n.errors,Q,ue):Lt(n.errors,Q)}else n.errors=U;return U},M=async(L,U,Q={valid:!0})=>{for(const ue in L){const ie=L[ue];if(ie){const{_f:se,...Ne}=ie;if(se){const qe=o.array.has(se.name),_e=ie._f&&LR(ie._f);_e&&h.validatingFields&&y([se.name],!0);const Wt=await H1(ie,o.disabled,a,p,e.shouldUseNativeValidation&&!U,qe);if(_e&&h.validatingFields&&y([se.name]),Wt[se.name]&&(Q.valid=!1,U||t.shouldUseNativeValidation))break;!U&&(be(Wt,se.name)?qe?VR(n.errors,Wt,se.name):dt(n.errors,se.name,Wt[se.name]):Lt(n.errors,se.name))}!Cn(Ne)&&await M(Ne,U,Q)}}return Q.valid},F=()=>{for(const L of o.unMount){const U=be(s,L);U&&(U._f.refs?U._f.refs.every(Q=>!Fm(Q)):!Fm(U._f.ref))&&On(L)}o.unMount=new Set},R=(L,U)=>!e.disabled&&(L&&U&&dt(a,L,U),!li(ce(),r)),V=(L,U,Q)=>AR(L,o,{...l.mount?a:gt(U)?r:ns(L)?{[L]:U}:U},Q,U),D=L=>Ky(be(l.mount?a:r,L,e.shouldUnregister?be(r,L,[]):[])),z=(L,U,Q={})=>{const ue=be(s,L);let ie=U;if(ue){const se=ue._f;se&&(!se.disabled&&dt(a,L,FC(U,se)),ie=fh(se.ref)&&Bn(U)?"":U,RC(se.ref)?[...se.ref.options].forEach(Ne=>Ne.selected=ie.includes(Ne.value)):se.refs?wd(se.ref)?se.refs.forEach(Ne=>{(!Ne.defaultChecked||!Ne.disabled)&&(Array.isArray(ie)?Ne.checked=!!ie.find(qe=>qe===Ne.value):Ne.checked=ie===Ne.value||!!ie)}):se.refs.forEach(Ne=>Ne.checked=Ne.value===ie):qy(se.ref)?se.ref.value="":(se.ref.value=ie,se.ref.type||f.state.next({name:L,values:Vt(a)})))}(Q.shouldDirty||Q.shouldTouch)&&E(L,ie,Q.shouldTouch,Q.shouldDirty,!0),Q.shouldValidate&&W(L)},C=(L,U,Q)=>{for(const ue in U){if(!U.hasOwnProperty(ue))return;const ie=U[ue],se=L+"."+ue,Ne=be(s,se);(o.array.has(L)||$t(ie)||Ne&&!Ne._f)&&!oa(ie)?C(se,ie,Q):z(se,ie,Q)}},_=(L,U,Q={})=>{const ue=be(s,L),ie=o.array.has(L),se=Vt(U);dt(a,L,se),ie?(f.array.next({name:L,values:Vt(a)}),(h.isDirty||h.dirtyFields||m.isDirty||m.dirtyFields)&&Q.shouldDirty&&f.state.next({name:L,dirtyFields:rl(r,a),isDirty:R(L,se)})):ue&&!ue._f&&!Bn(se)?C(L,se,Q):z(L,se,Q),K1(L,o)?f.state.next({...n,name:L,values:Vt(a)}):f.state.next({name:l.mount?L:void 0,values:Vt(a)})},K=async L=>{l.mount=!0;const U=L.target;let Q=U.name,ue=!0;const ie=be(s,Q),se=_e=>{ue=Number.isNaN(_e)||oa(_e)&&isNaN(_e.getTime())||li(_e,be(a,Q,_e))},Ne=_1(e.mode),qe=_1(e.reValidateMode);if(ie){let _e,Wt;const hr=U.type?B1(ie._f):jR(L),qs=L.type===O1.BLUR||L.type===O1.FOCUS_OUT,Wr=!FR(ie._f)&&!e.resolver&&!be(n.errors,Q)&&!ie._f.deps||BR(qs,be(n.touchedFields,Q),n.isSubmitted,qe,Ne),bo=K1(Q,o,qs);dt(a,Q,hr),qs?(!U||!U.readOnly)&&(ie._f.onBlur&&ie._f.onBlur(L),c&&c(0)):ie._f.onChange&&ie._f.onChange(L);const Ya=E(Q,hr,qs),Xf=!Cn(Ya)||bo;if(!qs&&f.state.next({name:Q,type:L.type,values:Vt(a)}),Wr)return(h.isValid||m.isValid)&&(e.mode==="onBlur"?qs&&x():qs||x()),Xf&&f.state.next({name:Q,...bo?{}:Ya});if(!qs&&bo&&f.state.next({...n}),e.resolver){const{errors:jo}=await w([Q]);if(y([Q]),se(hr),ue){const Ad=U1(n.errors,s,Q),No=U1(jo,s,Ad.name||Q);_e=No.error,Q=No.name,Wt=Cn(jo)}}else y([Q],!0),_e=(await H1(ie,o.disabled,a,p,e.shouldUseNativeValidation))[Q],y([Q]),se(hr),ue&&(_e?Wt=!1:(h.isValid||m.isValid)&&(Wt=await M(s,!0)));ue&&(ie._f.deps&&(!Array.isArray(ie._f.deps)||ie._f.deps.length>0)&&W(ie._f.deps),T(Q,Wt,_e,Ya))}},B=(L,U)=>{if(be(n.errors,U)&&L.focus)return L.focus(),1},W=async(L,U={})=>{let Q,ue;const ie=rc(L);if(e.resolver){const se=await S(gt(L)?L:ie);Q=Cn(se),ue=L?!ie.some(Ne=>be(se,Ne)):Q}else L?(ue=(await Promise.all(ie.map(async se=>{const Ne=be(s,se);return await M(Ne&&Ne._f?{[se]:Ne}:Ne)}))).every(Boolean),!(!ue&&!n.isValid)&&x()):ue=Q=await M(s);return f.state.next({...!ns(L)||(h.isValid||m.isValid)&&Q!==n.isValid?{}:{name:L},...e.resolver||!L?{isValid:Q}:{},errors:n.errors}),U.shouldFocus&&!ue&&ic(s,B,L?ie:o.mount),ue},ce=(L,U)=>{let Q={...l.mount?a:r};return U&&(Q=IC(U.dirtyFields?n.dirtyFields:n.touchedFields,Q)),gt(L)?Q:ns(L)?be(Q,L):L.map(ue=>be(Q,ue))},he=(L,U)=>({invalid:!!be((U||n).errors,L),isDirty:!!be((U||n).dirtyFields,L),error:be((U||n).errors,L),isValidating:!!be(n.validatingFields,L),isTouched:!!be((U||n).touchedFields,L)}),Je=L=>{L&&rc(L).forEach(U=>Lt(n.errors,U)),f.state.next({errors:L?n.errors:{}})},et=(L,U,Q)=>{const ue=(be(s,L,{_f:{}})._f||{}).ref,ie=be(n.errors,L)||{},{ref:se,message:Ne,type:qe,..._e}=ie;dt(n.errors,L,{..._e,...U,ref:ue}),f.state.next({name:L,errors:n.errors,isValid:!1}),Q&&Q.shouldFocus&&ue&&ue.focus&&ue.focus()},mt=(L,U)=>Rs(L)?f.state.subscribe({next:Q=>"values"in Q&&L(V(void 0,U),Q)}):V(L,U,!0),A=L=>f.state.subscribe({next:U=>{$R(L.name,U.name,L.exact)&&zR(U,L.formState||h,Ln,L.reRenderRoot)&&L.callback({values:{...a},...n,...U,defaultValues:r})}}).unsubscribe,pt=L=>(l.mount=!0,m={...m,...L.formState},A({...L,formState:{...u,...L.formState}})),On=(L,U={})=>{for(const Q of L?rc(L):o.mount)o.mount.delete(Q),o.array.delete(Q),U.keepValue||(Lt(s,Q),Lt(a,Q)),!U.keepError&&Lt(n.errors,Q),!U.keepDirty&&Lt(n.dirtyFields,Q),!U.keepTouched&&Lt(n.touchedFields,Q),!U.keepIsValidating&&Lt(n.validatingFields,Q),!e.shouldUnregister&&!U.keepDefaultValue&&Lt(r,Q);f.state.next({values:Vt(a)}),f.state.next({...n,...U.keepDirty?{isDirty:R()}:{}}),!U.keepIsValid&&x()},wn=({disabled:L,name:U})=>{if(Ys(L)&&l.mount||L||o.disabled.has(U)){const ie=o.disabled.has(U)!==!!L;L?o.disabled.add(U):o.disabled.delete(U),ie&&l.mount&&!l.action&&x()}},le=(L,U={})=>{let Q=be(s,L);const ue=Ys(U.disabled)||Ys(e.disabled);return dt(s,L,{...Q||{},_f:{...Q&&Q._f?Q._f:{ref:{name:L}},name:L,mount:!0,...U}}),o.mount.add(L),Q?wn({disabled:Ys(U.disabled)?U.disabled:e.disabled,name:L}):k(L,!0,U.value),{...ue?{disabled:U.disabled||e.disabled}:{},...e.progressive?{required:!!U.required,min:Io(U.min),max:Io(U.max),minLength:Io(U.minLength),maxLength:Io(U.maxLength),pattern:Io(U.pattern)}:{},name:L,onChange:K,onBlur:K,ref:ie=>{if(ie){le(L,U),Q=be(s,L);const se=gt(ie.value)&&ie.querySelectorAll&&ie.querySelectorAll("input,select,textarea")[0]||ie,Ne=TR(se),qe=Q._f.refs||[];if(Ne?qe.find(_e=>_e===se):se===Q._f.ref)return;dt(s,L,{_f:{...Q._f,...Ne?{refs:[...qe.filter(Fm),se,...Array.isArray(be(r,L))?[{}]:[]],ref:{type:se.type,name:L}}:{ref:se}}}),k(L,!1,void 0,se)}else Q=be(s,L,{}),Q._f&&(Q._f.mount=!1),(e.shouldUnregister||U.shouldUnregister)&&!(wR(o.array,L)&&l.action)&&o.unMount.add(L)}}},it=()=>e.shouldFocusError&&ic(s,B,o.mount),Rt=L=>{Ys(L)&&(f.state.next({disabled:L}),ic(s,(U,Q)=>{const ue=be(s,Q);ue&&(U.disabled=ue._f.disabled||L,Array.isArray(ue._f.refs)&&ue._f.refs.forEach(ie=>{ie.disabled=ue._f.disabled||L}))},0,!1))},J=(L,U)=>async Q=>{let ue;Q&&(Q.preventDefault&&Q.preventDefault(),Q.persist&&Q.persist());let ie=Vt(a);if(f.state.next({isSubmitting:!0}),e.resolver){const{errors:se,values:Ne}=await w();y(),n.errors=se,ie=Vt(Ne)}else await M(s);if(o.disabled.size)for(const se of o.disabled)Lt(ie,se);if(Lt(n.errors,"root"),Cn(n.errors)){f.state.next({errors:{}});try{await L(ie,Q)}catch(se){ue=se}}else U&&await U({...n.errors},Q),it(),setTimeout(it);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Cn(n.errors)&&!ue,submitCount:n.submitCount+1,errors:n.errors}),ue)throw ue},Ke=(L,U={})=>{be(s,L)&&(gt(U.defaultValue)?_(L,Vt(be(r,L))):(_(L,U.defaultValue),dt(r,L,Vt(U.defaultValue))),U.keepTouched||Lt(n.touchedFields,L),U.keepDirty||(Lt(n.dirtyFields,L),n.isDirty=U.defaultValue?R(L,Vt(be(r,L))):R()),U.keepError||(Lt(n.errors,L),h.isValid&&x()),f.state.next({...n}))},ct=(L,U={})=>{const Q=L?Vt(L):r,ue=Vt(Q),ie=Cn(L),se=ie?r:ue;if(U.keepDefaultValues||(r=Q),!U.keepValues){if(U.keepDirtyValues){const Ne=new Set([...o.mount,...Object.keys(rl(r,a))]);for(const qe of Array.from(Ne)){const _e=be(n.dirtyFields,qe),Wt=be(a,qe),hr=be(se,qe);_e&&!gt(Wt)?dt(se,qe,Wt):!_e&&!gt(hr)&&_(qe,hr)}}else{if(Vy&&gt(L))for(const Ne of o.mount){const qe=be(s,Ne);if(qe&&qe._f){const _e=Array.isArray(qe._f.refs)?qe._f.refs[0]:qe._f.ref;if(fh(_e)){const Wt=_e.closest("form");if(Wt){Wt.reset();break}}}}if(U.keepFieldsRef)for(const Ne of o.mount)_(Ne,be(se,Ne));else s={}}a=e.shouldUnregister?U.keepDefaultValues?Vt(r):{}:Vt(se),f.array.next({values:{...se}}),f.state.next({values:{...se}})}o={mount:U.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!h.isValid||!!U.keepIsValid||!!U.keepDirtyValues||!e.shouldUnregister&&!Cn(se),l.watch=!!e.shouldUnregister,l.keepIsValid=!!U.keepIsValid,l.action=!1,U.keepErrors||(n.errors={}),f.state.next({submitCount:U.keepSubmitCount?n.submitCount:0,isDirty:ie?!1:U.keepDirty?n.isDirty:!!(U.keepDefaultValues&&!li(L,r)),isSubmitted:U.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:ie?{}:U.keepDirtyValues?U.keepDefaultValues&&a?rl(r,a):n.dirtyFields:U.keepDefaultValues&&L?rl(r,L):U.keepDirty?n.dirtyFields:{},touchedFields:U.keepTouched?n.touchedFields:{},errors:U.keepErrors?n.errors:{},isSubmitSuccessful:U.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:r})},ee=(L,U)=>ct(Rs(L)?L(a):L,{...e.resetOptions,...U}),pe=(L,U={})=>{const Q=be(s,L),ue=Q&&Q._f;if(ue){const ie=ue.refs?ue.refs[0]:ue.ref;ie.focus&&setTimeout(()=>{ie.focus(),U.shouldSelect&&Rs(ie.select)&&ie.select()})}},Ln=L=>{n={...n,...L}},Ot={control:{register:le,unregister:On,getFieldState:he,handleSubmit:J,setError:et,_subscribe:A,_runSchema:w,_updateIsValidating:y,_focusError:it,_getWatch:V,_getDirty:R,_setValid:x,_setFieldArray:v,_setDisabledField:wn,_setErrors:j,_getFieldArray:D,_reset:ct,_resetDefaultValues:()=>Rs(e.defaultValues)&&e.defaultValues().then(L=>{ee(L,e.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:F,_disableForm:Rt,_subjects:f,_proxyFormState:h,get _fields(){return s},get _formValues(){return a},get _state(){return l},set _state(L){l=L},get _defaultValues(){return r},get _names(){return o},set _names(L){o=L},get _formState(){return n},get _options(){return e},set _options(L){e={...e,...L}}},subscribe:pt,trigger:W,register:le,handleSubmit:J,watch:mt,setValue:_,getValues:ce,reset:ee,resetField:Ke,clearErrors:Je,unregister:On,setError:et,setFocus:pe,getFieldState:he};return{...Ot,formControl:Ot}}function $C(t={}){const e=ut.useRef(void 0),n=ut.useRef(void 0),[s,r]=ut.useState({isDirty:!1,isValidating:!1,isLoading:Rs(t.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1,isReady:!1,defaultValues:Rs(t.defaultValues)?void 0:t.defaultValues});if(!e.current)if(t.formControl)e.current={...t.formControl,formState:s},t.defaultValues&&!Rs(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...o}=UR(t);e.current={...o,formState:s}}const a=e.current.control;return a._options=t,ER(()=>{const l=a._subscribe({formState:a._proxyFormState,callback:()=>r({...a._formState}),reRenderRoot:!0});return r(o=>({...o,isReady:!0})),a._formState.isReady=!0,l},[a]),ut.useEffect(()=>a._disableForm(t.disabled),[a,t.disabled]),ut.useEffect(()=>{t.mode&&(a._options.mode=t.mode),t.reValidateMode&&(a._options.reValidateMode=t.reValidateMode)},[a,t.mode,t.reValidateMode]),ut.useEffect(()=>{t.errors&&(a._setErrors(t.errors),a._focusError())},[a,t.errors]),ut.useEffect(()=>{t.shouldUnregister&&a._subjects.state.next({values:a._getWatch()})},[a,t.shouldUnregister]),ut.useEffect(()=>{if(a._proxyFormState.isDirty){const l=a._getDirty();l!==s.isDirty&&a._subjects.state.next({isDirty:l})}},[a,s.isDirty]),ut.useEffect(()=>{var l;t.values&&!li(t.values,n.current)?(a._reset(t.values,{keepFieldsRef:!0,...a._options.resetOptions}),!((l=a._options.resetOptions)===null||l===void 0)&&l.keepIsValid||a._setValid(),n.current=t.values,r(o=>({...o}))):a._resetDefaultValues()},[a,t.values]),ut.useEffect(()=>{a._state.mount||(a._setValid(),a._state.mount=!0),a._state.watch&&(a._state.watch=!1,a._subjects.state.next({...a._formState})),a._removeUnmounted()}),e.current.formState=ut.useMemo(()=>CR(s,a),[a,s]),e.current}function W1(){var y,v;const{id:t}=md(),e=fn(),n=ye(),s=!!t,{register:r,handleSubmit:a,reset:l,watch:o,setValue:c,formState:{errors:d}}=$C(),u=o("type"),{data:h}=fe({queryKey:["customer",t],queryFn:()=>Zt.getById(parseInt(t)),enabled:s});N.useEffect(()=>{if(h!=null&&h.data){const b={...h.data};b.birthDate&&(b.birthDate=b.birthDate.split("T")[0]),b.foundingDate&&(b.foundingDate=b.foundingDate.split("T")[0]),l(b)}},[h,l]);const m=G({mutationFn:Zt.create,onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),e("/customers")}}),f=G({mutationFn:b=>Zt.update(parseInt(t),b),onSuccess:()=>{n.invalidateQueries({queryKey:["customers"]}),n.invalidateQueries({queryKey:["customer",t]}),e(`/customers/${t}`)}}),p=b=>{const j={type:b.type,salutation:b.salutation||void 0,firstName:b.firstName,lastName:b.lastName,companyName:b.companyName||void 0,email:b.email||void 0,phone:b.phone||void 0,mobile:b.mobile||void 0,taxNumber:b.taxNumber||void 0,commercialRegisterNumber:b.commercialRegisterNumber||void 0,notes:b.notes||void 0,birthPlace:b.birthPlace||void 0};b.birthDate&&typeof b.birthDate=="string"&&b.birthDate.trim()!==""?j.birthDate=new Date(b.birthDate).toISOString():j.birthDate=null,b.foundingDate&&typeof b.foundingDate=="string"&&b.foundingDate.trim()!==""?j.foundingDate=new Date(b.foundingDate).toISOString():j.foundingDate=null,s?f.mutate(j):m.mutate(j)},g=m.isPending||f.isPending,x=m.error||f.error;return i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold mb-6",children:s?"Kunde bearbeiten":"Neuer Kunde"}),x&&i.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:x instanceof Error?x.message:"Ein Fehler ist aufgetreten"}),i.jsxs("form",{onSubmit:a(p),children:[i.jsx(Z,{className:"mb-6",title:"Stammdaten",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(Fe,{label:"Kundentyp",...r("type"),options:[{value:"PRIVATE",label:"Privatkunde"},{value:"BUSINESS",label:"Geschäftskunde"}]}),i.jsx(Fe,{label:"Anrede",...r("salutation"),options:[{value:"Herr",label:"Herr"},{value:"Frau",label:"Frau"},{value:"Divers",label:"Divers"}]}),i.jsx(q,{label:"Vorname",...r("firstName",{required:"Vorname erforderlich"}),error:(y=d.firstName)==null?void 0:y.message}),i.jsx(q,{label:"Nachname",...r("lastName",{required:"Nachname erforderlich"}),error:(v=d.lastName)==null?void 0:v.message}),u==="BUSINESS"&&i.jsxs(i.Fragment,{children:[i.jsx(q,{label:"Firmenname",...r("companyName"),className:"md:col-span-2"}),i.jsx(q,{label:"Gründungsdatum",type:"date",...r("foundingDate"),value:o("foundingDate")||"",onClear:()=>c("foundingDate","")})]}),u!=="BUSINESS"&&i.jsxs(i.Fragment,{children:[i.jsx(q,{label:"Geburtsdatum",type:"date",...r("birthDate"),value:o("birthDate")||"",onClear:()=>c("birthDate","")}),i.jsx(q,{label:"Geburtsort",...r("birthPlace")})]})]})}),i.jsx(Z,{className:"mb-6",title:"Kontaktdaten",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(q,{label:"E-Mail",type:"email",...r("email")}),i.jsx(q,{label:"Telefon",...r("phone")}),i.jsx(q,{label:"Mobil",...r("mobile")})]})}),u==="BUSINESS"&&i.jsxs(Z,{className:"mb-6",title:"Geschäftsdaten",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(q,{label:"Steuernummer",...r("taxNumber")}),i.jsx(q,{label:"Handelsregisternummer",...r("commercialRegisterNumber"),placeholder:"z.B. HRB 12345"})]}),s&&i.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Dokumente (Gewerbeanmeldung, Handelsregisterauszug) können nach dem Speichern in der Kundendetailansicht hochgeladen werden."})]}),i.jsx(Z,{className:"mb-6",title:"Notizen",children:i.jsx("textarea",{...r("notes"),rows:4,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"Interne Notizen..."})}),i.jsxs("div",{className:"flex justify-end gap-4",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:()=>e(-1),children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:g,children:g?"Speichern...":"Speichern"})]})]})]})}const zm={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},$m={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},Q1={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"},qR=[{status:"DRAFT",label:"Entwurf",description:"Vertrag wird noch vorbereitet",color:"text-gray-600"},{status:"PENDING",label:"Ausstehend",description:"Wartet auf Aktivierung",color:"text-yellow-600"},{status:"ACTIVE",label:"Aktiv",description:"Vertrag läuft normal",color:"text-green-600"},{status:"EXPIRED",label:"Abgelaufen",description:"Laufzeit vorbei, läuft aber ohne Kündigung weiter",color:"text-orange-600"},{status:"CANCELLED",label:"Gekündigt",description:"Aktive Kündigung eingereicht, Vertrag endet",color:"text-red-600"},{status:"DEACTIVATED",label:"Deaktiviert",description:"Manuell beendet/archiviert",color:"text-gray-500"}];function HR({isOpen:t,onClose:e}){return t?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"fixed inset-0 bg-black/20",onClick:e}),i.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"Vertragsstatus-Übersicht"}),i.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:i.jsx(nn,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"space-y-2",children:qR.map(({status:n,label:s,description:r,color:a})=>i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("span",{className:`font-medium text-sm min-w-[90px] ${a}`,children:s}),i.jsx("span",{className:"text-sm text-gray-600",children:r})]},n))})]})]}):null}function WR(){const[t,e]=Sf(),n=fn(),[s,r]=N.useState(t.get("search")||""),[a,l]=N.useState(t.get("type")||""),[o,c]=N.useState(t.get("status")||""),[d,u]=N.useState(parseInt(t.get("page")||"1",10)),[h,m]=N.useState(new Set),[f,p]=N.useState(!1),{hasPermission:g,isCustomer:x,isCustomerPortal:y,user:v}=nt(),b=ye();N.useEffect(()=>{const D=new URLSearchParams;s&&D.set("search",s),a&&D.set("type",a),o&&D.set("status",o),d>1&&D.set("page",d.toString()),e(D,{replace:!0})},[s,a,o,d,e]);const j=G({mutationFn:He.delete,onSuccess:()=>{b.invalidateQueries({queryKey:["contracts"]})}}),{data:k,isLoading:E}=fe({queryKey:["contracts",s,a,o,d,x?v==null?void 0:v.customerId:null],queryFn:()=>He.getAll({search:s||void 0,type:a||void 0,status:o||void 0,page:d,limit:20,customerId:x?v==null?void 0:v.customerId:void 0})}),T=N.useMemo(()=>{if(!y||!(k!=null&&k.data))return[];const D=new Set;return v!=null&&v.customerId&&D.add(v.customerId),k.data.forEach(z=>D.add(z.customerId)),[...D]},[k==null?void 0:k.data,y,v==null?void 0:v.customerId]),w=BT({queries:T.map(D=>({queryKey:["contract-tree",D],queryFn:()=>He.getTreeForCustomer(D),enabled:y}))}),S=N.useMemo(()=>{const D=new Map;return T.forEach((z,C)=>{var K;const _=w[C];(K=_==null?void 0:_.data)!=null&&K.data&&D.set(z,_.data.data)}),D},[T,w]),M=N.useMemo(()=>{if(!y||!(k!=null&&k.data))return null;const D={};for(const z of k.data){const C=z.customerId;if(!D[C]){const _=z.customer?z.customer.companyName||`${z.customer.firstName} ${z.customer.lastName}`:`Kunde ${C}`;D[C]={customerId:C,customerName:_,isOwn:C===(v==null?void 0:v.customerId),contracts:[],tree:S.get(C)||[]}}D[C].contracts.push(z)}return Object.values(D).sort((z,C)=>z.isOwn&&!C.isOwn?-1:!z.isOwn&&C.isOwn?1:z.customerName.localeCompare(C.customerName))},[k==null?void 0:k.data,y,v==null?void 0:v.customerId,S]),F=D=>{m(z=>{const C=new Set(z);return C.has(D)?C.delete(D):C.add(D),C})},R=(D,z)=>D.map(C=>i.jsx("div",{children:V(C,z)},C.contract.id)),V=(D,z=0)=>{var ce,he,Je,et,mt,A,pt;const{contract:C,predecessors:_,hasHistory:K}=D,B=h.has(C.id),W=z>0;return i.jsxs("div",{children:[i.jsxs("div",{className:`
border rounded-lg p-4 transition-colors
${W?"ml-6 border-l-4 border-l-gray-300 bg-gray-50":"hover:bg-gray-50"}
`,children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[!W&&K?i.jsx("button",{onClick:()=>F(C.id),className:"p-1 hover:bg-gray-200 rounded transition-colors",title:B?"Einklappen":"Vorgänger anzeigen",children:B?i.jsx(Us,{className:"w-4 h-4 text-gray-500"}):i.jsx(At,{className:"w-4 h-4 text-gray-500"})}):W?null:i.jsx("div",{className:"w-6"}),i.jsxs("span",{className:"font-mono flex items-center gap-1",children:[C.contractNumber,i.jsx(de,{value:C.contractNumber})]}),i.jsx(je,{children:zm[C.type]||C.type}),i.jsx(je,{variant:Q1[C.status]||"default",children:$m[C.status]||C.status}),W&&i.jsx("span",{className:"text-xs text-gray-500 ml-2",children:"(Vorgänger)"})]}),i.jsx("div",{className:"flex gap-2",children:i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${C.id}`,{state:{from:"contracts"}}),title:"Ansehen",children:i.jsx(Oe,{className:"w-4 h-4"})})})]}),(C.providerName||((ce=C.provider)==null?void 0:ce.name))&&i.jsxs("p",{className:`flex items-center gap-1 ${W?"ml-6":""}`,children:[C.providerName||((he=C.provider)==null?void 0:he.name),(C.tariffName||((Je=C.tariff)==null?void 0:Je.name))&&` - ${C.tariffName||((et=C.tariff)==null?void 0:et.name)}`,i.jsx(de,{value:(C.providerName||((mt=C.provider)==null?void 0:mt.name)||"")+(C.tariffName||(A=C.tariff)!=null&&A.name?` - ${C.tariffName||((pt=C.tariff)==null?void 0:pt.name)}`:"")})]}),C.startDate&&i.jsxs("p",{className:`text-sm text-gray-500 ${W?"ml-6":""}`,children:["Beginn: ",new Date(C.startDate).toLocaleDateString("de-DE"),C.endDate&&` | Ende: ${new Date(C.endDate).toLocaleDateString("de-DE")}`]})]}),(z===0&&B||z>0)&&_.length>0&&i.jsx("div",{className:"mt-2",children:R(_,z+1)})]},C.id)};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsx("h1",{className:"text-2xl font-bold",children:"Verträge"}),g("contracts:create")&&!x&&i.jsx(Me,{to:"/contracts/new",children:i.jsxs(I,{children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Neuer Vertrag"]})})]}),i.jsx(Z,{className:"mb-6",children:i.jsxs("div",{className:"flex gap-4 flex-wrap",children:[i.jsx("div",{className:"flex-1 min-w-[200px]",children:i.jsx(q,{placeholder:"Suchen...",value:s,onChange:D=>r(D.target.value)})}),i.jsx(Fe,{value:a,onChange:D=>l(D.target.value),options:Object.entries(zm).map(([D,z])=>({value:D,label:z})),className:"w-48"}),i.jsx(Fe,{value:o,onChange:D=>c(D.target.value),options:Object.entries($m).map(([D,z])=>({value:D,label:z})),className:"w-48"}),i.jsx(I,{variant:"secondary",children:i.jsx(jd,{className:"w-4 h-4"})})]})}),E?i.jsx(Z,{children:i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):k!=null&&k.data&&k.data.length>0?i.jsx(i.Fragment,{children:y&&M?i.jsx("div",{className:"space-y-6",children:M.map(D=>i.jsxs(Z,{children:[i.jsx("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:D.isOwn?i.jsxs(i.Fragment,{children:[i.jsx(yo,{className:"w-5 h-5 text-blue-600"}),i.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Meine Verträge"}),i.jsx(je,{variant:"default",children:D.contracts.length})]}):i.jsxs(i.Fragment,{children:[i.jsx(Ca,{className:"w-5 h-5 text-purple-600"}),i.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Verträge von ",D.customerName]}),i.jsx(je,{variant:"default",children:D.contracts.length})]})}),D.tree.length>0?i.jsx("div",{className:"space-y-4",children:D.tree.map(z=>V(z,0))}):i.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."})]},D.isOwn?"own":D.customerName))}):i.jsxs(Z,{children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Vertragsnr."}),!x&&i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kunde"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Anbieter / Tarif"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:i.jsxs("span",{className:"flex items-center gap-1",children:["Status",i.jsx("button",{onClick:()=>p(!0),className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Status-Erklärung",children:i.jsx(bd,{className:"w-4 h-4"})})]})}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beginn"}),i.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),i.jsx("tbody",{children:k.data.map(D=>i.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[i.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:D.contractNumber}),!x&&i.jsx("td",{className:"py-3 px-4",children:D.customer&&i.jsx(Me,{to:`/customers/${D.customer.id}`,className:"text-blue-600 hover:underline",children:D.customer.companyName||`${D.customer.firstName} ${D.customer.lastName}`})}),i.jsx("td",{className:"py-3 px-4",children:i.jsx(je,{children:zm[D.type]})}),i.jsxs("td",{className:"py-3 px-4",children:[D.providerName||"-",D.tariffName&&i.jsxs("span",{className:"text-gray-500",children:[" / ",D.tariffName]})]}),i.jsx("td",{className:"py-3 px-4",children:i.jsx(je,{variant:Q1[D.status],children:$m[D.status]})}),i.jsx("td",{className:"py-3 px-4",children:D.startDate?new Date(D.startDate).toLocaleDateString("de-DE"):"-"}),i.jsx("td",{className:"py-3 px-4 text-right",children:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>n(`/contracts/${D.id}`,{state:{from:"contracts"}}),children:i.jsx(Oe,{className:"w-4 h-4"})}),g("contracts:update")&&!x&&i.jsx(Me,{to:`/contracts/${D.id}/edit`,children:i.jsx(I,{variant:"ghost",size:"sm",children:i.jsx(rt,{className:"w-4 h-4"})})}),g("contracts:delete")&&!x&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&j.mutate(D.id)},children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})})]},D.id))})]})}),k.pagination&&k.pagination.totalPages>1&&i.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[i.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",k.pagination.page," von ",k.pagination.totalPages," (",k.pagination.total," Einträge)"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>u(D=>Math.max(1,D-1)),disabled:d===1,children:"Zurück"}),i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>u(D=>D+1),disabled:d>=k.pagination.totalPages,children:"Weiter"})]})]})]})}):i.jsx(Z,{children:i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Verträge gefunden."})}),i.jsx(HR,{isOpen:f,onClose:()=>p(!1)})]})}const QR={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},GR={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},JR={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"};function ZR({contractId:t,isOpen:e,onClose:n}){var o,c,d,u,h,m,f,p,g,x,y;const{data:s,isLoading:r,error:a}=fe({queryKey:["contract",t],queryFn:()=>He.getById(t),enabled:e}),l=s==null?void 0:s.data;return i.jsxs(Xe,{isOpen:e,onClose:n,title:"Vertragsdetails",size:"xl",children:[r&&i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}),a&&i.jsx("div",{className:"text-center py-8 text-red-600",children:"Fehler beim Laden des Vertrags"}),l&&i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center gap-3 pb-4 border-b",children:[i.jsxs("span",{className:"text-xl font-bold font-mono flex items-center gap-2",children:[l.contractNumber,i.jsx(de,{value:l.contractNumber})]}),i.jsx(je,{children:QR[l.type]||l.type}),i.jsx(je,{variant:JR[l.status]||"default",children:GR[l.status]||l.status})]}),(l.providerName||((o=l.provider)==null?void 0:o.name)||l.tariffName||((c=l.tariff)==null?void 0:c.name))&&i.jsx(Z,{title:"Anbieter & Tarif",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[(l.providerName||((d=l.provider)==null?void 0:d.name))&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[l.providerName||((u=l.provider)==null?void 0:u.name),i.jsx(de,{value:l.providerName||((h=l.provider)==null?void 0:h.name)||""})]})]}),(l.tariffName||((m=l.tariff)==null?void 0:m.name))&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Tarif"}),i.jsxs("dd",{className:"flex items-center gap-1",children:[l.tariffName||((f=l.tariff)==null?void 0:f.name),i.jsx(de,{value:l.tariffName||((p=l.tariff)==null?void 0:p.name)||""})]})]}),l.customerNumberAtProvider&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer beim Anbieter"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.customerNumberAtProvider,i.jsx(de,{value:l.customerNumberAtProvider})]})]}),l.contractNumberAtProvider&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer beim Anbieter"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.contractNumberAtProvider,i.jsx(de,{value:l.contractNumberAtProvider})]})]})]})}),(l.type==="ELECTRICITY"||l.type==="GAS")&&((g=l.energyDetails)==null?void 0:g.meter)&&i.jsx(Z,{title:"Zähler",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Zählernummer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.energyDetails.meter.meterNumber,i.jsx(de,{value:l.energyDetails.meter.meterNumber})]})]}),l.energyDetails.maloId&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"MaLo-ID"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.energyDetails.maloId,i.jsx(de,{value:l.energyDetails.maloId})]})]})]})}),i.jsx(Z,{title:"Laufzeit",children:i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[l.startDate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsbeginn"}),i.jsx("dd",{children:new Date(l.startDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),l.endDate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsende"}),i.jsx("dd",{children:new Date(l.endDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),l.contractDuration&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Laufzeit"}),i.jsx("dd",{children:l.contractDuration.description})]}),l.cancellationPeriod&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsfrist"}),i.jsx("dd",{children:l.cancellationPeriod.description})]})]})}),(l.portalUsername||((x=l.provider)==null?void 0:x.portalUrl))&&i.jsx(Z,{title:"Portal-Zugangsdaten",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[((y=l.provider)==null?void 0:y.portalUrl)&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Portal-URL"}),i.jsx("dd",{children:i.jsx("a",{href:l.provider.portalUrl,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:l.provider.portalUrl})})]}),l.portalUsername&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Benutzername"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[l.portalUsername,i.jsx(de,{value:l.portalUsername})]})]})]})}),l.address&&i.jsxs(Z,{title:"Lieferadresse",children:[i.jsxs("p",{children:[l.address.street," ",l.address.houseNumber]}),i.jsxs("p",{children:[l.address.postalCode," ",l.address.city]})]}),l.notes&&i.jsx(Z,{title:"Notizen",children:i.jsx("p",{className:"whitespace-pre-wrap text-gray-700",children:l.notes})})]})]})}function YR({contractId:t,canEdit:e}){const[n,s]=N.useState(!1),[r,a]=N.useState(!1),[l,o]=N.useState(null),c=ye(),{data:d,isLoading:u}=fe({queryKey:["contract-history",t],queryFn:()=>uh.getByContract(t)}),h=G({mutationFn:p=>uh.delete(t,p),onSuccess:()=>{c.invalidateQueries({queryKey:["contract-history",t]})}}),m=(d==null?void 0:d.data)||[],f=[...m].sort((p,g)=>new Date(g.createdAt).getTime()-new Date(p.createdAt).getTime());return i.jsxs("div",{className:"bg-white rounded-lg border p-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(S5,{className:"w-4 h-4 text-gray-500"}),i.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Vertragshistorie"}),i.jsx(je,{variant:"default",children:m.length})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[e&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>a(!0),children:i.jsx(Ge,{className:"w-4 h-4"})}),m.length>0&&i.jsx("button",{onClick:()=>s(!n),className:"text-gray-500 hover:text-gray-700",children:n?i.jsx(If,{className:"w-4 h-4"}):i.jsx(Us,{className:"w-4 h-4"})})]})]}),u&&i.jsx("p",{className:"text-sm text-gray-500",children:"Laden..."}),!n&&!u&&f.length>0&&i.jsxs("div",{className:"text-sm text-gray-600",children:[i.jsx("span",{className:"font-medium",children:new Date(f[0].createdAt).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})})," - ",f[0].title]}),n&&!u&&f.length>0&&i.jsx("div",{className:"space-y-2",children:f.map(p=>i.jsxs("div",{className:"flex items-start justify-between p-3 bg-gray-50 rounded-lg group",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("span",{className:"text-sm font-medium text-gray-800",children:p.title}),p.isAutomatic?i.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 text-xs rounded bg-blue-100 text-blue-700",title:"Automatisch erstellt",children:[i.jsx(m5,{className:"w-3 h-3"}),"Auto"]}):i.jsxs("span",{className:"flex items-center gap-1 px-1.5 py-0.5 text-xs rounded bg-gray-100 text-gray-600",title:"Manuell erstellt",children:[i.jsx(yo,{className:"w-3 h-3"}),"Manuell"]})]}),p.description&&i.jsx("p",{className:"text-sm text-gray-600 whitespace-pre-wrap mb-1",children:p.description}),i.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-400",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(cs,{className:"w-3 h-3"}),new Date(p.createdAt).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})]}),i.jsxs("span",{children:["von ",p.createdBy]})]})]}),e&&!p.isAutomatic&&i.jsxs("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100 ml-3",children:[i.jsx("button",{onClick:()=>o(p),className:"text-gray-500 hover:text-blue-600",title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>{confirm("Eintrag wirklich löschen?")&&h.mutate(p.id)},className:"text-gray-500 hover:text-red-600",title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4"})})]})]},p.id))}),n&&!u&&f.length===0&&i.jsx("p",{className:"text-sm text-gray-500 italic",children:"Keine Historie vorhanden."}),(r||l)&&i.jsx(XR,{isOpen:!0,onClose:()=>{a(!1),o(null)},contractId:t,entry:l})]})}function XR({isOpen:t,onClose:e,contractId:n,entry:s}){const r=ye(),a=!!s,[l,o]=N.useState({title:(s==null?void 0:s.title)||"",description:(s==null?void 0:s.description)||""}),[c,d]=N.useState(null),u=G({mutationFn:()=>uh.create(n,{title:l.title,description:l.description||void 0}),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-history",n]}),e()},onError:p=>{d(p.message)}}),h=G({mutationFn:()=>uh.update(n,s.id,{title:l.title,description:l.description||void 0}),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-history",n]}),e()},onError:p=>{d(p.message)}}),m=p=>{if(p.preventDefault(),d(null),!l.title.trim()){d("Titel ist erforderlich");return}a?h.mutate():u.mutate()},f=u.isPending||h.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:a?"Eintrag bearbeiten":"Historie-Eintrag hinzufügen",children:i.jsxs("form",{onSubmit:m,className:"space-y-4",children:[c&&i.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm",children:c}),i.jsx(q,{label:"Titel *",value:l.title,onChange:p=>o({...l,title:p.target.value}),placeholder:"z.B. kWh auf 18000 erhöht",required:!0}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung (optional)"}),i.jsx("textarea",{value:l.description,onChange:p=>o({...l,description:p.target.value}),placeholder:"Weitere Details...",rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),i.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:f,children:f?"Wird gespeichert...":a?"Speichern":"Hinzufügen"})]})]})})}const G1={INTERIM:"Zwischenrechnung",FINAL:"Schlussrechnung",NOT_AVAILABLE:"Nicht verfügbar"};function e3({ecdId:t,invoices:e,contractId:n,canEdit:s}){const[r,a]=N.useState(!1),[l,o]=N.useState(!1),[c,d]=N.useState(null),u=ye(),h=G({mutationFn:g=>sl.deleteInvoice(t,g),onSuccess:()=>{u.invalidateQueries({queryKey:["contract",n.toString()]})}}),m=[...e].sort((g,x)=>new Date(x.invoiceDate).getTime()-new Date(g.invoiceDate).getTime()),f=e.some(g=>g.invoiceType==="FINAL"),p=e.some(g=>g.invoiceType==="NOT_AVAILABLE");return i.jsxs("div",{className:"mt-4 pt-4 border-t",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(We,{className:"w-4 h-4 text-gray-500"}),i.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Rechnungen"}),i.jsx(je,{variant:"default",children:e.length}),f?i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-green-100 text-green-800",children:[i.jsx(Vr,{className:"w-3 h-3"}),"Schlussrechnung"]}):p?i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-yellow-100 text-yellow-800",children:[i.jsx(Mn,{className:"w-3 h-3"}),"Nicht verfügbar"]}):e.length>0?i.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-xs rounded-full bg-orange-100 text-orange-800",children:[i.jsx(Mn,{className:"w-3 h-3"}),"Schlussrechnung fehlt"]}):null]}),i.jsxs("div",{className:"flex items-center gap-2",children:[s&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>o(!0),children:i.jsx(Ge,{className:"w-4 h-4"})}),e.length>0&&i.jsx("button",{onClick:()=>a(!r),className:"text-gray-500 hover:text-gray-700",children:r?i.jsx(If,{className:"w-4 h-4"}):i.jsx(Us,{className:"w-4 h-4"})})]})]}),!r&&m.length>0&&i.jsxs("div",{className:"text-sm text-gray-600",children:["Letzte: ",new Date(m[0].invoiceDate).toLocaleDateString("de-DE")," - ",G1[m[0].invoiceType]]}),r&&m.length>0&&i.jsx("div",{className:"space-y-2",children:m.map(g=>i.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg group",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium",children:new Date(g.invoiceDate).toLocaleDateString("de-DE")}),i.jsx("div",{className:"text-xs text-gray-500",children:G1[g.invoiceType]})]}),g.documentPath&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("a",{href:`/api${g.documentPath}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-blue-600 hover:text-blue-800 text-sm",title:"Anzeigen",children:i.jsx(Oe,{className:"w-4 h-4"})}),i.jsx("a",{href:`/api${g.documentPath}`,download:!0,className:"flex items-center gap-1 text-blue-600 hover:text-blue-800 text-sm",title:"Download",children:i.jsx(qn,{className:"w-4 h-4"})})]}),g.notes&&i.jsx("span",{className:"text-xs text-gray-400 italic",children:g.notes})]}),s&&i.jsxs("div",{className:"flex items-center gap-2 opacity-0 group-hover:opacity-100",children:[i.jsx("button",{onClick:()=>d(g),className:"text-gray-500 hover:text-blue-600",title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>{confirm("Rechnung wirklich löschen?")&&h.mutate(g.id)},className:"text-gray-500 hover:text-red-600",title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4"})})]})]},g.id))}),r&&m.length===0&&i.jsx("p",{className:"text-sm text-gray-500 italic",children:"Keine Rechnungen vorhanden."}),(l||c)&&i.jsx(t3,{isOpen:!0,onClose:()=>{o(!1),d(null)},ecdId:t,contractId:n,invoice:c})]})}function t3({isOpen:t,onClose:e,ecdId:n,contractId:s,invoice:r}){const a=ye(),l=!!r,o=N.useRef(null),[c,d]=N.useState({invoiceDate:r!=null&&r.invoiceDate?new Date(r.invoiceDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],invoiceType:(r==null?void 0:r.invoiceType)||"INTERIM",notes:(r==null?void 0:r.notes)||""}),[u,h]=N.useState(null),[m,f]=N.useState(null),p=G({mutationFn:async j=>{var E;const k=await sl.addInvoice(n,{invoiceDate:c.invoiceDate,invoiceType:c.invoiceType,notes:c.notes||void 0});return(E=k.data)!=null&&E.id&&await sl.uploadDocument(k.data.id,j),k},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",s.toString()]}),e()},onError:j=>{f(j.message)}}),g=G({mutationFn:async()=>await sl.addInvoice(n,{invoiceDate:c.invoiceDate,invoiceType:c.invoiceType,notes:c.notes||void 0}),onSuccess:()=>{a.invalidateQueries({queryKey:["contract",s.toString()]}),e()},onError:j=>{f(j.message)}}),x=G({mutationFn:async j=>{const k=await sl.updateInvoice(n,r.id,{invoiceDate:c.invoiceDate,invoiceType:c.invoiceType,notes:c.notes||void 0});return j&&await sl.uploadDocument(r.id,j),k},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",s.toString()]}),e()},onError:j=>{f(j.message)}}),y=j=>{if(j.preventDefault(),f(null),l){if(c.invoiceType!=="NOT_AVAILABLE"&&!(r!=null&&r.documentPath)&&!u){f("Bitte laden Sie ein Dokument hoch");return}x.mutate(u)}else if(c.invoiceType==="NOT_AVAILABLE")g.mutate();else if(u)p.mutate(u);else{f("Bitte laden Sie ein Dokument hoch");return}},v=j=>{var E;const k=(E=j.target.files)==null?void 0:E[0];if(k){if(k.type!=="application/pdf"){f("Nur PDF-Dateien sind erlaubt");return}if(k.size>10*1024*1024){f("Datei ist zu groß (max. 10 MB)");return}h(k),f(null)}},b=p.isPending||g.isPending||x.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:l?"Rechnung bearbeiten":"Rechnung hinzufügen",children:i.jsxs("form",{onSubmit:y,className:"space-y-4",children:[m&&i.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm",children:m}),i.jsx(q,{label:"Rechnungsdatum",type:"date",value:c.invoiceDate,onChange:j=>d({...c,invoiceDate:j.target.value}),required:!0}),i.jsx(Fe,{label:"Rechnungstyp",value:c.invoiceType,onChange:j=>d({...c,invoiceType:j.target.value}),options:[{value:"INTERIM",label:"Zwischenrechnung"},{value:"FINAL",label:"Schlussrechnung"},{value:"NOT_AVAILABLE",label:"Nicht verfügbar"}]}),c.invoiceType!=="NOT_AVAILABLE"&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Dokument (PDF) *"}),(r==null?void 0:r.documentPath)&&!u&&i.jsxs("div",{className:"mb-2 text-sm text-green-600 flex items-center gap-1",children:[i.jsx(Vr,{className:"w-4 h-4"}),"Dokument vorhanden"]}),u&&i.jsxs("div",{className:"mb-2 text-sm text-blue-600 flex items-center gap-1",children:[i.jsx(We,{className:"w-4 h-4"}),u.name]}),i.jsx("input",{type:"file",ref:o,accept:".pdf",onChange:v,className:"hidden"}),i.jsx(I,{type:"button",variant:"secondary",onClick:()=>{var j;return(j=o.current)==null?void 0:j.click()},children:r!=null&&r.documentPath||u?"Ersetzen":"PDF hochladen"})]}),c.invoiceType==="NOT_AVAILABLE"&&i.jsx("div",{className:"p-3 bg-yellow-50 border border-yellow-200 rounded-lg text-yellow-800 text-sm",children:'Bei diesem Typ wird kein Dokument benötigt. Die Rechnung wird als "nicht mehr zu bekommen" markiert.'}),i.jsx(q,{label:"Notizen (optional)",value:c.notes,onChange:j=>d({...c,notes:j.target.value}),placeholder:"Optionale Anmerkungen..."}),i.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:b,children:b?"Wird gespeichert...":l?"Speichern":"Hinzufügen"})]})]})})}const n3=10.5;function J1(t,e){const n=new Date(t),s=new Date(e);n.setHours(0,0,0,0),s.setHours(0,0,0,0);const r=s.getTime()-n.getTime();return Math.ceil(r/(1e3*60*60*24))}function s3(t,e,n){const s=new Date(e),r=new Date(n);return s.setHours(0,0,0,0),r.setHours(0,0,0,0),t.filter(a=>{const l=new Date(a.readingDate);return l.setHours(0,0,0,0),l>=s&&l<=r})}function r3(t,e,n,s){const r=s3(t,e,n);if(r.length===0)return{type:"none",consumptionKwh:0};if(r.length===1)return{type:"insufficient",consumptionKwh:0,message:"Berechnung auf Grund fehlender Stände nicht möglich"};const a=[...r].sort((p,g)=>new Date(p.readingDate).getTime()-new Date(g.readingDate).getTime()),l=a[0],o=a[a.length-1],c=new Date(o.readingDate),d=new Date(n);if(c.setHours(0,0,0,0),d.setHours(0,0,0,0),c>=d){const p=o.value-l.value;return Z1("exact",p,s,l,o)}const u=J1(l.readingDate,o.readingDate);if(u<1)return{type:"insufficient",consumptionKwh:0,message:"Zeitraum zwischen Zählerständen zu kurz für Berechnung"};const h=J1(e,n),f=(o.value-l.value)/u*h;return Z1("projected",f,s,l,o,n)}function Z1(t,e,n,s,r,a){return n==="GAS"?{type:t,consumptionM3:e,consumptionKwh:e*n3,startReading:s,endReading:r,projectedEndDate:a}:{type:t,consumptionKwh:e,startReading:s,endReading:r,projectedEndDate:a}}function i3(t,e,n,s){if(e==null&&n==null)return null;const r=(e??0)*12,a=t*(n??0),l=r+a,o=l-(s??0),c=o/12;return{annualBaseCost:r,annualConsumptionCost:a,annualTotalCost:l,monthlyPayment:c,bonus:s??void 0,effectiveAnnualCost:o}}const a3={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},l3={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen",DEACTIVATED:"Deaktiviert"},o3={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default",DEACTIVATED:"default"},c3=[{status:"DRAFT",label:"Entwurf",description:"Vertrag wird noch vorbereitet",color:"text-gray-600"},{status:"PENDING",label:"Ausstehend",description:"Wartet auf Aktivierung",color:"text-yellow-600"},{status:"ACTIVE",label:"Aktiv",description:"Vertrag läuft normal",color:"text-green-600"},{status:"EXPIRED",label:"Abgelaufen",description:"Laufzeit vorbei, läuft aber ohne Kündigung weiter",color:"text-orange-600"},{status:"CANCELLED",label:"Gekündigt",description:"Aktive Kündigung eingereicht, Vertrag endet",color:"text-red-600"},{status:"DEACTIVATED",label:"Deaktiviert",description:"Manuell beendet/archiviert",color:"text-gray-500"}];function d3({isOpen:t,onClose:e}){return t?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"fixed inset-0 bg-black/20",onClick:e}),i.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"Vertragsstatus-Übersicht"}),i.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:i.jsx(nn,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"space-y-2",children:c3.map(({status:n,label:s,description:r,color:a})=>i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("span",{className:`font-medium text-sm min-w-[90px] ${a}`,children:s}),i.jsx("span",{className:"text-sm text-gray-600",children:r})]},n))})]})]}):null}function u3(t){const e=t.match(/^(\d+)([TMWJ])$/);if(!e)return!1;const n=parseInt(e[1]),s=e[2];let r=0;return s==="T"?r=n:s==="W"?r=n*7:s==="M"?r=n*30:s==="J"&&(r=n*365),r<=30}function h3({simCard:t}){const[e,n]=N.useState(!1),[s,r]=N.useState(null),[a,l]=N.useState(!1),o=async()=>{if(e)n(!1),r(null);else{l(!0);try{const c=await He.getSimCardCredentials(t.id);c.data&&(r(c.data),n(!0))}catch{alert("PIN/PUK konnte nicht geladen werden")}finally{l(!1)}}};return i.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg border",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.isMain&&i.jsx(je,{variant:"success",children:"Hauptkarte"}),t.isMultisim&&i.jsx(je,{variant:"warning",children:"Multisim"})]}),i.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[t.phoneNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"Rufnummer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[t.phoneNumber,i.jsx(de,{value:t.phoneNumber})]})]}),t.simCardNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"SIM-Nr."}),i.jsxs("dd",{className:"font-mono text-xs flex items-center gap-1",children:[t.simCardNumber,i.jsx(de,{value:t.simCardNumber})]})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"PIN"}),i.jsx("dd",{className:"font-mono flex items-center gap-1",children:e&&(s!=null&&s.pin)?i.jsxs(i.Fragment,{children:[s.pin,i.jsx(de,{value:s.pin})]}):"••••"})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"PUK"}),i.jsx("dd",{className:"font-mono flex items-center gap-1",children:e&&(s!=null&&s.puk)?i.jsxs(i.Fragment,{children:[s.puk,i.jsx(de,{value:s.puk})]}):"••••••••"})]})]}),i.jsx("div",{className:"mt-2",children:i.jsx(I,{variant:"ghost",size:"sm",onClick:o,disabled:a,children:a?"Laden...":e?i.jsxs(i.Fragment,{children:[i.jsx(on,{className:"w-4 h-4 mr-1"})," PIN/PUK verbergen"]}):i.jsxs(i.Fragment,{children:[i.jsx(Oe,{className:"w-4 h-4 mr-1"})," PIN/PUK anzeigen"]})})})]})}function f3({meterId:t,meterType:e,readings:n,contractId:s,canEdit:r}){const[a,l]=N.useState(!1),[o,c]=N.useState(!1),[d,u]=N.useState(null),h=ye(),m=G({mutationFn:g=>ar.deleteReading(t,g),onSuccess:()=>{h.invalidateQueries({queryKey:["contract",s.toString()]})}}),f=[...n].sort((g,x)=>new Date(x.readingDate).getTime()-new Date(g.readingDate).getTime()),p=e==="ELECTRICITY"?"kWh":"m³";return i.jsxs("div",{className:"mt-4 pt-4 border-t",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(bC,{className:"w-4 h-4 text-gray-500"}),i.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Zählerstände"}),i.jsx(je,{variant:"default",children:n.length})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[r&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>c(!0),title:"Zählerstand erfassen",children:i.jsx(Ge,{className:"w-4 h-4"})}),n.length>0&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(!a),children:a?i.jsx(If,{className:"w-4 h-4"}):i.jsx(Us,{className:"w-4 h-4"})})]})]}),a&&n.length>0&&i.jsx("div",{className:"space-y-2 bg-gray-50 rounded-lg p-3",children:f.map(g=>i.jsxs("div",{className:"flex justify-between items-center text-sm group py-1 border-b border-gray-200 last:border-0",children:[i.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(g.readingDate).toLocaleDateString("de-DE"),i.jsx(de,{value:new Date(g.readingDate).toLocaleDateString("de-DE")})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("span",{className:"font-mono flex items-center gap-1",children:[g.value.toLocaleString("de-DE")," ",g.unit,i.jsx(de,{value:g.value.toString(),title:"Nur Wert kopieren"})]}),r&&i.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[i.jsx("button",{onClick:()=>u(g),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:i.jsx(rt,{className:"w-3 h-3"})}),i.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&m.mutate(g.id)},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:i.jsx(Ee,{className:"w-3 h-3"})})]})]})]},g.id))}),!a&&n.length>0&&i.jsxs("p",{className:"text-sm text-gray-500",children:["Letzter Stand: ",f[0].value.toLocaleString("de-DE")," ",f[0].unit," (",new Date(f[0].readingDate).toLocaleDateString("de-DE"),")"]}),n.length===0&&i.jsx("p",{className:"text-sm text-gray-500",children:"Keine Zählerstände vorhanden."}),(o||d)&&i.jsx(m3,{isOpen:!0,onClose:()=>{c(!1),u(null)},meterId:t,contractId:s,reading:d,defaultUnit:p})]})}function m3({isOpen:t,onClose:e,meterId:n,contractId:s,reading:r,defaultUnit:a}){var p;const l=ye(),o=!!r,[c,d]=N.useState({readingDate:r!=null&&r.readingDate?new Date(r.readingDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],value:((p=r==null?void 0:r.value)==null?void 0:p.toString())||"",notes:(r==null?void 0:r.notes)||""}),u=G({mutationFn:g=>ar.addReading(n,g),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",s.toString()]}),e()}}),h=G({mutationFn:g=>ar.updateReading(n,r.id,g),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",s.toString()]}),e()}}),m=g=>{g.preventDefault();const x={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:a,notes:c.notes||void 0};o?h.mutate(x):u.mutate(x)},f=u.isPending||h.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:o?"Zählerstand bearbeiten":"Zählerstand erfassen",children:i.jsxs("form",{onSubmit:m,className:"space-y-4",children:[i.jsx(q,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:g=>d({...c,readingDate:g.target.value}),required:!0}),i.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[i.jsx("div",{className:"col-span-2",children:i.jsx(q,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:g=>d({...c,value:g.target.value}),required:!0})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Einheit"}),i.jsx("div",{className:"h-10 flex items-center px-3 bg-gray-100 border border-gray-300 rounded-md text-gray-700",children:a})]})]}),i.jsx(q,{label:"Notizen (optional)",value:c.notes,onChange:g=>d({...c,notes:g.target.value})}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:f||!c.value,children:f?"Speichern...":o?"Speichern":"Erfassen"})]})]})})}function p3({contractType:t,readings:e,startDate:n,endDate:s,basePrice:r,unitPrice:a,bonus:l}){const o=r3(e,n,s,t),c=o.consumptionKwh>0?i3(o.consumptionKwh,r,a,l):null;if(o.type==="none")return null;const d=(h,m=2)=>h.toLocaleString("de-DE",{minimumFractionDigits:m,maximumFractionDigits:m}),u=h=>new Date(h).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"});return i.jsxs("div",{className:"mt-4 pt-4 border-t",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(x5,{className:"w-4 h-4 text-gray-500"}),i.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Verbrauch & Kosten"}),o.type==="exact"&&i.jsx(je,{variant:"success",children:"Exakt"}),o.type==="projected"&&i.jsx(je,{variant:"warning",children:"Hochrechnung"})]}),o.type==="insufficient"?i.jsx("p",{className:"text-sm text-gray-500 italic",children:o.message}):i.jsxs("div",{className:"bg-gray-50 rounded-lg p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsxs("h5",{className:"text-sm font-medium text-gray-600 mb-2",children:["Berechneter Verbrauch",o.type==="projected"&&" (hochgerechnet)"]}),i.jsx("div",{className:"text-lg font-semibold text-gray-900",children:t==="GAS"?i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"font-mono",children:[d(o.consumptionM3||0)," m³"]}),i.jsxs("span",{className:"text-gray-500 text-sm ml-2",children:["= ",d(o.consumptionKwh)," kWh"]})]}):i.jsxs("span",{className:"font-mono",children:[d(o.consumptionKwh)," kWh"]})}),o.startReading&&o.endReading&&i.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:["Basierend auf Zählerständen vom ",u(o.startReading.readingDate)," bis ",u(o.endReading.readingDate)]})]}),c&&i.jsxs("div",{className:"border-t border-gray-200 pt-4",children:[i.jsx("h5",{className:"text-sm font-medium text-gray-600 mb-3",children:"Kostenvorschau"}),i.jsxs("div",{className:"space-y-2 text-sm",children:[r!=null&&r>0&&i.jsxs("div",{className:"flex justify-between",children:[i.jsxs("span",{className:"text-gray-600",children:["Grundpreis: ",d(r)," €/Mon × 12"]}),i.jsxs("span",{className:"font-mono",children:[d(c.annualBaseCost)," €"]})]}),a!=null&&a>0&&i.jsxs("div",{className:"flex justify-between",children:[i.jsxs("span",{className:"text-gray-600",children:["Arbeitspreis: ",d(o.consumptionKwh)," kWh × ",d(a,4)," €"]}),i.jsxs("span",{className:"font-mono",children:[d(c.annualConsumptionCost)," €"]})]}),i.jsx("div",{className:"border-t border-gray-300 pt-2",children:i.jsxs("div",{className:"flex justify-between font-medium",children:[i.jsx("span",{className:"text-gray-700",children:"Jahreskosten"}),i.jsxs("span",{className:"font-mono",children:[d(c.annualTotalCost)," €"]})]})}),c.bonus!=null&&c.bonus>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex justify-between text-green-600",children:[i.jsx("span",{children:"Bonus"}),i.jsxs("span",{className:"font-mono",children:["- ",d(c.bonus)," €"]})]}),i.jsx("div",{className:"border-t border-gray-300 pt-2",children:i.jsxs("div",{className:"flex justify-between font-semibold",children:[i.jsx("span",{className:"text-gray-800",children:"Effektive Jahreskosten"}),i.jsxs("span",{className:"font-mono",children:[d(c.effectiveAnnualCost)," €"]})]})})]}),i.jsx("div",{className:"border-t border-gray-300 pt-2 mt-2",children:i.jsxs("div",{className:"flex justify-between text-blue-700 font-semibold",children:[i.jsx("span",{children:"Monatlicher Abschlag"}),i.jsxs("span",{className:"font-mono",children:[d(c.monthlyPayment)," €"]})]})})]})]})]})]})}function Y1({task:t,contractId:e,canEdit:n,isCustomerPortal:s,isCompleted:r,onEdit:a}){const[l,o]=N.useState(""),[c,d]=N.useState(!1),[u,h]=N.useState(null),[m,f]=N.useState(""),p=ye(),g=G({mutationFn:_=>ht.complete(_),onSuccess:async()=>{await p.refetchQueries({queryKey:["contract-tasks",e]})}}),x=G({mutationFn:_=>ht.reopen(_),onSuccess:async()=>{await p.refetchQueries({queryKey:["contract-tasks",e]})}}),y=G({mutationFn:_=>ht.delete(_),onSuccess:async()=>{await p.refetchQueries({queryKey:["contract-tasks",e]})}}),v=G({mutationFn:_=>ht.createSubtask(t.id,_),onSuccess:async()=>{await p.refetchQueries({queryKey:["contract-tasks",e]}),o(""),d(!1)},onError:_=>{console.error("Fehler beim Erstellen der Unteraufgabe:",_),alert("Fehler beim Erstellen der Unteraufgabe. Bitte versuchen Sie es erneut.")}}),b=G({mutationFn:_=>ht.createReply(t.id,_),onSuccess:async()=>{await p.refetchQueries({queryKey:["contract-tasks",e]}),o(""),d(!1)},onError:_=>{console.error("Fehler beim Erstellen der Antwort:",_),alert("Fehler beim Erstellen der Antwort. Bitte versuchen Sie es erneut.")}}),j=G({mutationFn:({id:_,title:K})=>ht.updateSubtask(_,K),onSuccess:async()=>{await p.refetchQueries({queryKey:["contract-tasks",e]}),h(null),f("")}}),k=G({mutationFn:_=>ht.completeSubtask(_),onSuccess:async()=>{await p.refetchQueries({queryKey:["contract-tasks",e]})}}),E=G({mutationFn:_=>ht.reopenSubtask(_),onSuccess:async()=>{await p.refetchQueries({queryKey:["contract-tasks",e]})}}),T=G({mutationFn:_=>ht.deleteSubtask(_),onSuccess:async()=>{await p.refetchQueries({queryKey:["contract-tasks",e]})}}),w=_=>{_.preventDefault(),l.trim()&&(s?b.mutate(l.trim()):v.mutate(l.trim()))},S=_=>{_.preventDefault(),m.trim()&&u&&j.mutate({id:u,title:m.trim()})},M=(_,K)=>{h(_),f(K)},F=()=>{h(null),f("")},R=t.subtasks||[],V=R.filter(_=>_.status==="OPEN"),D=R.filter(_=>_.status==="COMPLETED"),z=s?{singular:"Antwort",placeholder:"Antwort...",deleteConfirm:"Antwort löschen?"}:{singular:"Unteraufgabe",placeholder:"Unteraufgabe...",deleteConfirm:"Unteraufgabe löschen?"},C=(_,K)=>u===_.id?i.jsx("div",{className:"py-1",children:i.jsxs("form",{onSubmit:S,className:"flex items-center gap-2",children:[i.jsx(Eu,{className:"w-4 h-4 text-gray-300 flex-shrink-0"}),i.jsx("input",{type:"text",value:m,onChange:W=>f(W.target.value),className:"flex-1 text-sm px-2 py-1 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500",autoFocus:!0}),i.jsx(I,{type:"submit",size:"sm",disabled:!m.trim()||j.isPending,children:"✓"}),i.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:F,children:"×"})]})},_.id):i.jsx("div",{className:`py-1 group/subtask ${K?"opacity-60":""}`,children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("button",{onClick:()=>K?E.mutate(_.id):k.mutate(_.id),disabled:k.isPending||E.isPending||s,className:`flex-shrink-0 mt-0.5 ${s?"cursor-default":K?"hover:text-yellow-600":"hover:text-green-600"}`,children:K?i.jsx(Un,{className:"w-4 h-4 text-green-500"}):i.jsx(Eu,{className:"w-4 h-4 text-gray-400"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("span",{className:`text-sm ${K?"line-through text-gray-500":""}`,children:_.title}),n&&!s&&!K&&i.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover/subtask:opacity-100",children:[i.jsx("button",{onClick:()=>M(_.id,_.title),className:"text-gray-400 hover:text-blue-600 p-0.5",title:"Bearbeiten",children:i.jsx(rt,{className:"w-3 h-3"})}),i.jsx("button",{onClick:()=>{confirm(z.deleteConfirm)&&T.mutate(_.id)},className:"text-gray-400 hover:text-red-600 p-0.5",title:"Löschen",children:i.jsx(Ee,{className:"w-3 h-3"})})]}),n&&!s&&K&&i.jsx("button",{onClick:()=>{confirm(z.deleteConfirm)&&T.mutate(_.id)},className:"text-gray-400 hover:text-red-600 p-0.5 opacity-0 group-hover/subtask:opacity-100",title:"Löschen",children:i.jsx(Ee,{className:"w-3 h-3"})})]}),i.jsxs("p",{className:"text-xs text-gray-400",children:[_.createdBy&&`${_.createdBy} • `,K?`Erledigt am ${_.completedAt?new Date(_.completedAt).toLocaleDateString("de-DE"):new Date(_.updatedAt).toLocaleDateString("de-DE")}`:new Date(_.createdAt).toLocaleDateString("de-DE")]})]})]})},_.id);return i.jsx("div",{className:`p-3 bg-gray-50 rounded-lg group ${r?"bg-gray-50/50 opacity-70":""}`,children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("button",{onClick:()=>r?x.mutate(t.id):g.mutate(t.id),disabled:g.isPending||x.isPending||s,className:`mt-0.5 flex-shrink-0 ${s?"cursor-default":r?"hover:text-yellow-600":"hover:text-green-600"}`,title:s?void 0:r?"Wieder öffnen":"Als erledigt markieren",children:r?i.jsx(Un,{className:"w-5 h-5 text-green-500"}):i.jsx(Eu,{className:"w-5 h-5 text-gray-400"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`font-medium ${r?"line-through text-gray-500":""}`,children:t.title}),t.visibleInPortal&&i.jsx(je,{variant:"default",className:"text-xs",children:"Portal"}),R.length>0&&i.jsxs("span",{className:"text-xs text-gray-400",children:["(",D.length,"/",R.length,")"]})]}),t.description&&i.jsx("p",{className:`text-sm mt-1 whitespace-pre-wrap ${r?"text-gray-500":"text-gray-600"}`,children:t.description}),i.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[t.createdBy&&`${t.createdBy} • `,r?`Erledigt am ${t.completedAt?new Date(t.completedAt).toLocaleDateString("de-DE"):"-"}`:new Date(t.createdAt).toLocaleDateString("de-DE")]}),R.length>0&&i.jsxs("div",{className:"mt-3 ml-2 space-y-0 border-l-2 border-gray-200 pl-3",children:[V.map(_=>C(_,!1)),D.map(_=>C(_,!0))]}),!r&&(n&&!s||s)&&i.jsx("div",{className:"mt-2 ml-2",children:c?i.jsxs("form",{onSubmit:w,className:"flex items-center gap-2",children:[i.jsx("input",{type:"text",value:l,onChange:_=>o(_.target.value),placeholder:z.placeholder,className:"flex-1 text-sm px-2 py-1 border rounded focus:outline-none focus:ring-1 focus:ring-blue-500",autoFocus:!0}),i.jsx(I,{type:"submit",size:"sm",disabled:!l.trim()||v.isPending||b.isPending,children:i.jsx(Ge,{className:"w-3 h-3"})}),i.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(!1),o("")},children:"×"})]}):i.jsxs("button",{onClick:()=>d(!0),className:"text-xs text-gray-400 hover:text-blue-600 flex items-center gap-1",children:[i.jsx(Ge,{className:"w-3 h-3"}),z.singular]})})]}),n&&!s&&i.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100",children:[!r&&i.jsx("button",{onClick:a,className:"text-gray-400 hover:text-blue-600 p-1",title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>{confirm("Aufgabe wirklich löschen?")&&y.mutate(t.id)},className:"text-gray-400 hover:text-red-600 p-1",title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4"})})]})]})})}function g3({contractId:t,canEdit:e,isCustomerPortal:n}){var b;const[s,r]=N.useState(!1),[a,l]=N.useState(null),{data:o,isLoading:c}=fe({queryKey:["contract-tasks",t],queryFn:()=>ht.getByContract(t),staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:d,isLoading:u}=fe({queryKey:["app-settings-public"],queryFn:()=>Ba.getPublic(),enabled:n,staleTime:0}),h=!u&&((b=d==null?void 0:d.data)==null?void 0:b.customerSupportTicketsEnabled)==="true",m=(o==null?void 0:o.data)||[],f=m.filter(j=>j.status==="OPEN"),p=m.filter(j=>j.status==="COMPLETED"),g=n?{title:"Support-Anfragen",button:"Anfrage erstellen",empty:"Keine Support-Anfragen vorhanden."}:{title:"Aufgaben",button:"Aufgabe",empty:"Keine Aufgaben vorhanden."},x=n?Vc:_c;if(c||n&&u)return i.jsx(Z,{className:"mb-6",title:g.title,children:i.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."})});const v=e&&!n||n&&h;return i.jsxs(Z,{className:"mb-6",title:g.title,children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(x,{className:"w-5 h-5 text-gray-500"}),i.jsxs("span",{className:"text-sm text-gray-600",children:[f.length," offen, ",p.length," erledigt"]})]}),v&&i.jsxs(I,{size:"sm",onClick:()=>r(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-1"}),g.button]})]}),m.length===0?i.jsx("p",{className:"text-center py-4 text-gray-500",children:g.empty}):i.jsxs("div",{className:"space-y-2",children:[f.map(j=>i.jsx(Y1,{task:j,contractId:t,canEdit:e,isCustomerPortal:n,isCompleted:!1,onEdit:()=>l(j)},j.id)),p.length>0&&f.length>0&&i.jsx("div",{className:"border-t my-3"}),p.map(j=>i.jsx(Y1,{task:j,contractId:t,canEdit:e,isCustomerPortal:n,isCompleted:!0,onEdit:()=>{}},j.id))]}),(s||a)&&i.jsx(x3,{isOpen:!0,onClose:()=>{r(!1),l(null)},contractId:t,task:a,isCustomerPortal:n})]})}function x3({isOpen:t,onClose:e,contractId:n,task:s,isCustomerPortal:r=!1}){const a=ye(),l=!!s,[o,c]=N.useState({title:(s==null?void 0:s.title)||"",description:(s==null?void 0:s.description)||"",visibleInPortal:(s==null?void 0:s.visibleInPortal)||!1});N.useEffect(()=>{t&&c({title:(s==null?void 0:s.title)||"",description:(s==null?void 0:s.description)||"",visibleInPortal:(s==null?void 0:s.visibleInPortal)||!1})},[t,s]);const d=G({mutationFn:g=>ht.create(n,g),onSuccess:async()=>{await a.refetchQueries({queryKey:["contract-tasks",n]}),e()}}),u=G({mutationFn:g=>ht.createSupportTicket(n,g),onSuccess:async()=>{await a.refetchQueries({queryKey:["contract-tasks",n]}),e()}}),h=G({mutationFn:g=>ht.update(s.id,g),onSuccess:async()=>{await a.refetchQueries({queryKey:["contract-tasks",n]}),e()}}),m=g=>{g.preventDefault(),l?h.mutate({title:o.title,description:o.description||void 0,visibleInPortal:o.visibleInPortal}):r?u.mutate({title:o.title,description:o.description||void 0}):d.mutate({title:o.title,description:o.description||void 0,visibleInPortal:o.visibleInPortal})},f=d.isPending||u.isPending||h.isPending,p=r?{modalTitle:l?"Anfrage bearbeiten":"Neue Support-Anfrage",titleLabel:"Betreff",titlePlaceholder:"Kurze Beschreibung Ihrer Anfrage",descLabel:"Ihre Nachricht",descPlaceholder:"Beschreiben Sie Ihr Anliegen...",submitBtn:l?"Speichern":"Anfrage senden"}:{modalTitle:l?"Aufgabe bearbeiten":"Neue Aufgabe",titleLabel:"Titel",titlePlaceholder:"Kurze Beschreibung der Aufgabe",descLabel:"Beschreibung (optional)",descPlaceholder:"Details zur Aufgabe...",submitBtn:l?"Speichern":"Erstellen"};return i.jsx(Xe,{isOpen:t,onClose:e,title:p.modalTitle,children:i.jsxs("form",{onSubmit:m,className:"space-y-4",children:[i.jsx(q,{label:p.titleLabel,value:o.title,onChange:g=>c({...o,title:g.target.value}),required:!0,placeholder:p.titlePlaceholder}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:p.descLabel}),i.jsx("textarea",{value:o.description,onChange:g=>c({...o,description:g.target.value}),className:"w-full px-3 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",rows:r?5:3,placeholder:p.descPlaceholder})]}),!r&&i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:o.visibleInPortal,onChange:g=>c({...o,visibleInPortal:g.target.checked}),className:"w-4 h-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),i.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:f||!o.title.trim(),children:f?"Speichern...":p.submitBtn})]})]})})}function y3(){var pt,On,wn,le,it,Rt;const{id:t}=md(),e=fn(),s=qr().state,r=ye(),{hasPermission:a,isCustomer:l,isCustomerPortal:o}=nt(),c=parseInt(t),[d,u]=N.useState(!1),[h,m]=N.useState(null),[f,p]=N.useState(!1),[g,x]=N.useState(!1),[y,v]=N.useState(null),[b,j]=N.useState({}),[k,E]=N.useState({}),[T,w]=N.useState(!1),[S,M]=N.useState(!1),[F,R]=N.useState(!1),[V,D]=N.useState(!1),{data:z,isLoading:C}=fe({queryKey:["contract",t],queryFn:()=>He.getById(c)}),_=G({mutationFn:()=>He.delete(c),onSuccess:()=>{e("/contracts")}}),K=G({mutationFn:()=>He.createFollowUp(c),onSuccess:J=>{J.data?e(`/contracts/${J.data.id}/edit`):alert("Folgevertrag wurde erstellt, aber keine ID zurückgegeben")},onError:J=>{console.error("Folgevertrag Fehler:",J),alert(`Fehler beim Erstellen des Folgevertrags: ${J instanceof Error?J.message:"Unbekannter Fehler"}`)}}),B=G({mutationFn:()=>He.snooze(c,{}),onSuccess:()=>{r.invalidateQueries({queryKey:["contract",t]}),r.invalidateQueries({queryKey:["contract-cockpit"]}),D(!1)},onError:J=>{console.error("Un-Snooze Fehler:",J),alert(`Fehler beim Aufheben der Zurückstellung: ${J instanceof Error?J.message:"Unbekannter Fehler"}`)}}),W=G({mutationFn:J=>{const ct={cancellationConfirmationDate:J?new Date(J).toISOString():null};return He.update(c,ct)},onSuccess:()=>{r.invalidateQueries({queryKey:["contract",t]}),r.invalidateQueries({queryKey:["contract-cockpit"]})},onError:J=>{console.error("Fehler beim Speichern des Datums:",J),alert("Fehler beim Speichern des Datums")}}),ce=G({mutationFn:J=>{const ct={cancellationConfirmationOptionsDate:J?new Date(J).toISOString():null};return He.update(c,ct)},onSuccess:()=>{r.invalidateQueries({queryKey:["contract",t]}),r.invalidateQueries({queryKey:["contract-cockpit"]})},onError:J=>{console.error("Fehler beim Speichern des Datums:",J),alert("Fehler beim Speichern des Datums")}}),he=async()=>{var J;if(d)u(!1),m(null);else try{const Ke=await He.getPassword(c);(J=Ke.data)!=null&&J.password&&(m(Ke.data.password),u(!0))}catch{alert("Passwort konnte nicht entschlüsselt werden")}},Je=async()=>{var J;if(g)x(!1),v(null);else try{const Ke=await He.getInternetCredentials(c);(J=Ke.data)!=null&&J.password&&(v(Ke.data.password),x(!0))}catch{alert("Internet-Passwort konnte nicht entschlüsselt werden")}},et=async J=>{var Ke;if(b[J])j(ct=>({...ct,[J]:!1})),E(ct=>({...ct,[J]:null}));else try{const ee=(Ke=(await He.getSipCredentials(J)).data)==null?void 0:Ke.password;ee&&(E(pe=>({...pe,[J]:ee})),j(pe=>({...pe,[J]:!0})))}catch{alert("SIP-Passwort konnte nicht entschlüsselt werden")}},mt=async()=>{var ct,ee,pe;const J=z==null?void 0:z.data,Ke=((ct=J==null?void 0:J.stressfreiEmail)==null?void 0:ct.email)||(J==null?void 0:J.portalUsername);if(!((ee=J==null?void 0:J.provider)!=null&&ee.portalUrl)||!Ke){alert("Portal-URL oder Benutzername fehlt");return}p(!0);try{const Ln=await He.getPassword(c);if(!((pe=Ln.data)!=null&&pe.password)){alert("Passwort konnte nicht entschlüsselt werden");return}const ur=J.provider,Ot=ur.portalUrl,L=ur.usernameFieldName||"username",U=ur.passwordFieldName||"password",Q=new URL(Ot);Q.searchParams.set(L,Ke),Q.searchParams.set(U,Ln.data.password),window.open(Q.toString(),"_blank")}catch{alert("Fehler beim Auto-Login")}finally{p(!1)}};if(C)return i.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(z!=null&&z.data))return i.jsx("div",{className:"text-center py-8 text-red-600",children:"Vertrag nicht gefunden"});const A=z.data;return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{if((s==null?void 0:s.from)==="customer"&&(s!=null&&s.customerId))e(`/customers/${s.customerId}?tab=contracts`);else if((s==null?void 0:s.from)==="cockpit"){const J=s.filter?`?filter=${s.filter}`:"";e(`/contracts/cockpit${J}`)}else(s==null?void 0:s.from)==="contracts"?e("/contracts"):A.customer?e(`/customers/${A.customer.id}?tab=contracts`):e("/contracts")},children:i.jsx(Yn,{className:"w-4 h-4"})}),i.jsx("h1",{className:"text-2xl font-bold",children:A.contractNumber}),i.jsx(je,{children:a3[A.type]}),i.jsx(je,{variant:o3[A.status],children:l3[A.status]}),i.jsx("button",{onClick:()=>R(!0),className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Status-Erklärung",children:i.jsx(bd,{className:"w-4 h-4"})}),A.nextReviewDate&&new Date(A.nextReviewDate)>new Date&&i.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 bg-amber-100 text-amber-800 rounded-full text-xs",children:[i.jsx(mC,{className:"w-3 h-3"}),i.jsxs("span",{children:["Zurückgestellt bis ",new Date(A.nextReviewDate).toLocaleDateString("de-DE")]}),a("contracts:update")&&i.jsx("button",{onClick:()=>D(!0),className:"ml-1 p-0.5 hover:bg-amber-200 rounded",title:"Zurückstellung aufheben",children:i.jsx(nn,{className:"w-3 h-3"})})]})]}),A.customer&&i.jsxs("p",{className:"text-gray-500 ml-10",children:["Kunde:"," ",i.jsx(Me,{to:`/customers/${A.customer.id}`,className:"text-blue-600 hover:underline",children:A.customer.companyName||`${A.customer.firstName} ${A.customer.lastName}`})]})]}),!l&&i.jsxs("div",{className:"flex gap-2",children:[A.previousContract&&i.jsx(Me,{to:`/contracts/${A.previousContract.id}`,children:i.jsxs(I,{variant:"secondary",children:[i.jsx(Yn,{className:"w-4 h-4 mr-2"}),"Vorgängervertrag"]})}),a("contracts:create")&&!A.followUpContract&&i.jsxs(I,{variant:"secondary",onClick:()=>M(!0),disabled:K.isPending,children:[i.jsx(Iy,{className:"w-4 h-4 mr-2"}),K.isPending?"Erstelle...":"Folgevertrag anlegen"]}),A.followUpContract&&i.jsx(Me,{to:`/contracts/${A.followUpContract.id}`,children:i.jsxs(I,{variant:"secondary",children:[i.jsx(fC,{className:"w-4 h-4 mr-2"}),"Folgevertrag anzeigen"]})}),a("contracts:update")&&i.jsx(Me,{to:`/contracts/${t}/edit`,children:i.jsxs(I,{variant:"secondary",children:[i.jsx(rt,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),a("contracts:delete")&&i.jsxs(I,{variant:"danger",onClick:()=>{confirm("Vertrag wirklich löschen?")&&_.mutate()},children:[i.jsx(Ee,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),A.previousContract&&i.jsx(Z,{className:"mb-6 border-l-4 border-l-blue-500",title:"Vorgängervertrag",children:i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),i.jsx("dd",{children:i.jsx("button",{onClick:()=>w(!0),className:"text-blue-600 hover:underline",children:A.previousContract.contractNumber})})]}),A.previousContract.providerName&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),i.jsx("dd",{children:A.previousContract.providerName})]}),A.previousContract.customerNumberAtProvider&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),i.jsx("dd",{className:"font-mono",children:A.previousContract.customerNumberAtProvider})]}),A.previousContract.contractNumberAtProvider&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),i.jsx("dd",{className:"font-mono",children:A.previousContract.contractNumberAtProvider})]}),A.previousContract.portalUsername&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Zugangsdaten"}),i.jsx("dd",{children:A.previousContract.portalUsername})]})]})}),!A.previousContract&&(A.previousProvider||A.previousCustomerNumber||A.previousContractNumber)&&i.jsx(Z,{className:"mb-6 border-l-4 border-l-gray-400",title:"Altanbieter",children:i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[A.previousProvider&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),i.jsx("dd",{children:A.previousProvider.name})]}),A.previousCustomerNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.previousCustomerNumber,i.jsx(de,{value:A.previousCustomerNumber})]})]}),A.previousContractNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.previousContractNumber,i.jsx(de,{value:A.previousContractNumber})]})]})]})}),A.cancellationConfirmationDate&&i.jsxs("div",{className:"mb-6 p-4 bg-red-50 border-2 border-red-400 rounded-lg flex items-start gap-3",children:[i.jsx("span",{className:"text-red-600 text-xl font-bold",children:"!"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-semibold text-red-800",children:"Kündigungsbestätigung vorhanden"}),i.jsxs("p",{className:"text-sm text-red-700 mt-1",children:["Dieser Vertrag hat eine Kündigungsbestätigung vom"," ",i.jsx("strong",{children:new Date(A.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),".",A.cancellationConfirmationOptionsDate&&i.jsxs(i.Fragment,{children:[" Optionen-Bestätigung: ",i.jsx("strong",{children:new Date(A.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),"."]})]})]})]}),A.type==="MOBILE"&&((pt=A.mobileDetails)==null?void 0:pt.requiresMultisim)&&i.jsxs("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-300 rounded-lg flex items-start gap-3",children:[i.jsx("span",{className:"text-amber-600 text-xl font-bold",children:"!"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-semibold text-amber-800",children:"Multisim erforderlich"}),i.jsx("p",{className:"text-sm text-amber-700 mt-1",children:"Dieser Kunde benötigt eine Multisim-Karte. Multisim ist bei Klarmobil, Congstar und Otelo nicht buchbar. Bitte einen Anbieter wie Freenet oder vergleichbar wählen."})]})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[i.jsx(Z,{title:"Anbieter & Tarif",children:i.jsxs("dl",{className:"space-y-3",children:[(A.provider||A.providerName)&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),i.jsx("dd",{className:"font-medium",children:((On=A.provider)==null?void 0:On.name)||A.providerName})]}),(A.tariff||A.tariffName)&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Tarif"}),i.jsx("dd",{children:((wn=A.tariff)==null?void 0:wn.name)||A.tariffName})]}),A.customerNumberAtProvider&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.customerNumberAtProvider,i.jsx(de,{value:A.customerNumberAtProvider})]})]}),A.contractNumberAtProvider&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.contractNumberAtProvider,i.jsx(de,{value:A.contractNumberAtProvider})]})]}),A.salesPlatform&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertriebsplattform"}),i.jsx("dd",{children:A.salesPlatform.name})]}),A.commission!==null&&A.commission!==void 0&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Provision"}),i.jsx("dd",{children:A.commission.toLocaleString("de-DE",{style:"currency",currency:"EUR"})})]}),A.priceFirst12Months&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Preis erste 12 Monate"}),i.jsx("dd",{children:A.priceFirst12Months})]}),A.priceFrom13Months&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Preis ab 13. Monat"}),i.jsx("dd",{children:A.priceFrom13Months})]}),A.priceAfter24Months&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Preis nach 24 Monaten"}),i.jsx("dd",{children:A.priceAfter24Months})]})]})}),i.jsxs(Z,{title:"Laufzeit und Kündigung",className:A.cancellationConfirmationDate?"border-2 border-red-400":"",children:[A.contractDuration&&u3(A.contractDuration.code)&&i.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[i.jsx("strong",{children:"Hinweis:"})," Dieser Vertrag gilt als unbefristet mit der jeweiligen Kündigungsfrist."]}),i.jsxs("dl",{className:"space-y-3",children:[A.startDate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsbeginn"}),i.jsx("dd",{children:new Date(A.startDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),A.endDate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsende"}),i.jsx("dd",{children:new Date(A.endDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),A.contractDuration&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragslaufzeit"}),i.jsx("dd",{children:A.contractDuration.description})]}),A.cancellationPeriod&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsfrist"}),i.jsx("dd",{children:A.cancellationPeriod.description})]}),A.cancellationConfirmationDate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsdatum"}),i.jsx("dd",{children:new Date(A.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),A.cancellationConfirmationOptionsDate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsoptionendatum"}),i.jsx("dd",{children:new Date(A.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),A.wasSpecialCancellation&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Sonderkündigung"}),i.jsx("dd",{children:i.jsx(je,{variant:"warning",children:"Ja"})})]})]}),a("contracts:update")&&i.jsxs("div",{className:"mt-6 pt-6 border-t",children:[i.jsx("h4",{className:"font-medium mb-4",children:"Kündigungsdokumente"}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben"}),A.cancellationLetterPath?i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[i.jsxs("a",{href:`/api${A.cancellationLetterPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Oe,{className:"w-4 h-4"}),"Anzeigen"]}),i.jsxs("a",{href:`/api${A.cancellationLetterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(qn,{className:"w-4 h-4"}),"Download"]}),i.jsx(Jt,{onUpload:async J=>{await Ct.uploadCancellationLetter(c,J),r.invalidateQueries({queryKey:["contract",t]})},existingFile:A.cancellationLetterPath,accept:".pdf",label:"Ersetzen"}),i.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await Ct.deleteCancellationLetter(c),r.invalidateQueries({queryKey:["contract",t]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Ee,{className:"w-4 h-4"}),"Löschen"]})]}):i.jsx(Jt,{onUpload:async J=>{await Ct.uploadCancellationLetter(c,J),r.invalidateQueries({queryKey:["contract",t]})},accept:".pdf",label:"PDF hochladen"})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung"}),A.cancellationConfirmationPath?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[i.jsxs("a",{href:`/api${A.cancellationConfirmationPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Oe,{className:"w-4 h-4"}),"Anzeigen"]}),i.jsxs("a",{href:`/api${A.cancellationConfirmationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(qn,{className:"w-4 h-4"}),"Download"]}),i.jsx(Jt,{onUpload:async J=>{await Ct.uploadCancellationConfirmation(c,J),r.invalidateQueries({queryKey:["contract",t]})},existingFile:A.cancellationConfirmationPath,accept:".pdf",label:"Ersetzen"}),i.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await Ct.deleteCancellationConfirmation(c),r.invalidateQueries({queryKey:["contract",t]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Ee,{className:"w-4 h-4"}),"Löschen"]})]}),i.jsxs("div",{className:"mt-2",children:[i.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"date",value:A.cancellationConfirmationDate?A.cancellationConfirmationDate.split("T")[0]:"",onChange:J=>{const Ke=J.target.value||null;W.mutate(Ke)},className:"block w-full max-w-[180px] px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"}),A.cancellationConfirmationDate&&i.jsx("button",{onClick:()=>W.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:i.jsx(Ee,{className:"w-4 h-4"})})]})]})]}):i.jsx(Jt,{onUpload:async J=>{await Ct.uploadCancellationConfirmation(c,J),r.invalidateQueries({queryKey:["contract",t]})},accept:".pdf",label:"PDF hochladen"})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben Optionen"}),A.cancellationLetterOptionsPath?i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[i.jsxs("a",{href:`/api${A.cancellationLetterOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Oe,{className:"w-4 h-4"}),"Anzeigen"]}),i.jsxs("a",{href:`/api${A.cancellationLetterOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(qn,{className:"w-4 h-4"}),"Download"]}),i.jsx(Jt,{onUpload:async J=>{await Ct.uploadCancellationLetterOptions(c,J),r.invalidateQueries({queryKey:["contract",t]})},existingFile:A.cancellationLetterOptionsPath,accept:".pdf",label:"Ersetzen"}),i.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await Ct.deleteCancellationLetterOptions(c),r.invalidateQueries({queryKey:["contract",t]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Ee,{className:"w-4 h-4"}),"Löschen"]})]}):i.jsx(Jt,{onUpload:async J=>{await Ct.uploadCancellationLetterOptions(c,J),r.invalidateQueries({queryKey:["contract",t]})},accept:".pdf",label:"PDF hochladen"})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung Optionen"}),A.cancellationConfirmationOptionsPath?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[i.jsxs("a",{href:`/api${A.cancellationConfirmationOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Oe,{className:"w-4 h-4"}),"Anzeigen"]}),i.jsxs("a",{href:`/api${A.cancellationConfirmationOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(qn,{className:"w-4 h-4"}),"Download"]}),i.jsx(Jt,{onUpload:async J=>{await Ct.uploadCancellationConfirmationOptions(c,J),r.invalidateQueries({queryKey:["contract",t]})},existingFile:A.cancellationConfirmationOptionsPath,accept:".pdf",label:"Ersetzen"}),i.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await Ct.deleteCancellationConfirmationOptions(c),r.invalidateQueries({queryKey:["contract",t]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[i.jsx(Ee,{className:"w-4 h-4"}),"Löschen"]})]}),i.jsxs("div",{className:"mt-2",children:[i.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"date",value:A.cancellationConfirmationOptionsDate?A.cancellationConfirmationOptionsDate.split("T")[0]:"",onChange:J=>{const Ke=J.target.value||null;ce.mutate(Ke)},className:"block w-full max-w-[180px] px-2 py-1 text-sm border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500"}),A.cancellationConfirmationOptionsDate&&i.jsx("button",{onClick:()=>ce.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:i.jsx(Ee,{className:"w-4 h-4"})})]})]})]}):i.jsx(Jt,{onUpload:async J=>{await Ct.uploadCancellationConfirmationOptions(c,J),r.invalidateQueries({queryKey:["contract",t]})},accept:".pdf",label:"PDF hochladen"})]})]})]})]})]}),(A.portalUsername||A.stressfreiEmail||A.portalPasswordEncrypted)&&i.jsxs(Z,{className:"mb-6",title:"Zugangsdaten",children:[i.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[(A.portalUsername||A.stressfreiEmail)&&i.jsxs("div",{children:[i.jsxs("dt",{className:"text-sm text-gray-500",children:["Benutzername",A.stressfreiEmail&&i.jsx("span",{className:"ml-2 text-xs text-blue-600",children:"(Stressfrei-Wechseln)"})]}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[((le=A.stressfreiEmail)==null?void 0:le.email)||A.portalUsername,i.jsx(de,{value:((it=A.stressfreiEmail)==null?void 0:it.email)||A.portalUsername||""})]})]}),A.portalPasswordEncrypted&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),i.jsxs("dd",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-mono",children:d&&h?h:"••••••••"}),d&&h&&i.jsx(de,{value:h}),i.jsx(I,{variant:"ghost",size:"sm",onClick:he,children:d?i.jsx(on,{className:"w-4 h-4"}):i.jsx(Oe,{className:"w-4 h-4"})})]})]})]}),((Rt=A.provider)==null?void 0:Rt.portalUrl)&&(A.portalUsername||A.stressfreiEmail)&&A.portalPasswordEncrypted&&i.jsxs("div",{className:"mt-4 pt-4 border-t",children:[i.jsxs(I,{onClick:mt,disabled:f,className:"w-full sm:w-auto",children:[i.jsx(Oy,{className:"w-4 h-4 mr-2"}),f?"Wird geöffnet...":"Zum Kundenportal (Auto-Login)"]}),i.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Öffnet das Portal mit vorausgefüllten Zugangsdaten"})]})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6 mb-6",children:[A.address&&i.jsx(Z,{title:"Lieferadresse",children:i.jsxs(Vg,{values:[`${A.address.street} ${A.address.houseNumber}`,`${A.address.postalCode} ${A.address.city}`,A.address.country],children:[i.jsxs("p",{children:[A.address.street," ",A.address.houseNumber]}),i.jsxs("p",{children:[A.address.postalCode," ",A.address.city]}),i.jsx("p",{className:"text-gray-500",children:A.address.country})]})}),(A.billingAddress||A.address)&&i.jsx(Z,{title:"Rechnungsadresse",children:(()=>{const J=A.billingAddress||A.address;return J?i.jsxs(Vg,{values:[`${J.street} ${J.houseNumber}`,`${J.postalCode} ${J.city}`,J.country],children:[i.jsxs("p",{children:[J.street," ",J.houseNumber]}),i.jsxs("p",{children:[J.postalCode," ",J.city]}),i.jsx("p",{className:"text-gray-500",children:J.country}),!A.billingAddress&&A.address&&i.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"(wie Lieferadresse)"})]}):null})()}),A.bankCard&&i.jsxs(Z,{title:"Bankkarte",children:[i.jsx("p",{className:"font-medium",children:A.bankCard.accountHolder}),i.jsxs("p",{className:"font-mono flex items-center gap-1",children:[A.bankCard.iban,i.jsx(de,{value:A.bankCard.iban})]}),A.bankCard.bankName&&i.jsx("p",{className:"text-gray-500",children:A.bankCard.bankName})]}),A.identityDocument&&i.jsxs(Z,{title:"Ausweis",children:[i.jsxs("p",{className:"font-mono flex items-center gap-1",children:[A.identityDocument.documentNumber,i.jsx(de,{value:A.identityDocument.documentNumber})]}),i.jsx("p",{className:"text-gray-500",children:A.identityDocument.type})]})]}),A.energyDetails&&i.jsxs(Z,{className:"mb-6",title:A.type==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:[i.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[A.energyDetails.meter&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Zählernummer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.energyDetails.meter.meterNumber,i.jsx(de,{value:A.energyDetails.meter.meterNumber})]})]}),A.energyDetails.maloId&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"MaLo-ID"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.energyDetails.maloId,i.jsx(de,{value:A.energyDetails.maloId})]})]}),A.energyDetails.annualConsumption&&i.jsxs("div",{children:[i.jsxs("dt",{className:"text-sm text-gray-500",children:["Jahresverbrauch ",A.type==="ELECTRICITY"?"":"(m³)"]}),i.jsxs("dd",{children:[A.energyDetails.annualConsumption.toLocaleString("de-DE")," ",A.type==="ELECTRICITY"?"kWh":"m³"]})]}),A.type==="GAS"&&A.energyDetails.annualConsumptionKwh&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Jahresverbrauch (kWh)"}),i.jsxs("dd",{children:[A.energyDetails.annualConsumptionKwh.toLocaleString("de-DE")," kWh"]})]}),A.energyDetails.basePrice!=null&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Grundpreis"}),i.jsxs("dd",{children:[A.energyDetails.basePrice.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:10})," €/Monat"]})]}),A.energyDetails.unitPrice!=null&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Arbeitspreis"}),i.jsxs("dd",{children:[A.energyDetails.unitPrice.toLocaleString("de-DE",{minimumFractionDigits:2,maximumFractionDigits:10})," €/kWh"]})]}),A.energyDetails.bonus&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Bonus"}),i.jsxs("dd",{children:[A.energyDetails.bonus.toLocaleString("de-DE")," €"]})]}),A.energyDetails.previousProviderName&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversorger"}),i.jsx("dd",{children:A.energyDetails.previousProviderName})]}),A.energyDetails.previousCustomerNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vorherige Kundennr."}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.energyDetails.previousCustomerNumber,i.jsx(de,{value:A.energyDetails.previousCustomerNumber})]})]})]}),A.energyDetails.meter&&i.jsx(f3,{meterId:A.energyDetails.meter.id,meterType:A.energyDetails.meter.type,readings:A.energyDetails.meter.readings||[],contractId:c,canEdit:a("contracts:update")&&!l}),A.energyDetails.meter&&A.startDate&&A.endDate&&i.jsx(p3,{contractType:A.type,readings:A.energyDetails.meter.readings||[],startDate:A.startDate,endDate:A.endDate,basePrice:A.energyDetails.basePrice,unitPrice:A.energyDetails.unitPrice,bonus:A.energyDetails.bonus}),i.jsx(e3,{ecdId:A.energyDetails.id,invoices:A.energyDetails.invoices||[],contractId:c,canEdit:a("contracts:update")&&!l})]}),A.internetDetails&&i.jsxs(Z,{className:"mb-6",title:A.type==="DSL"?"DSL-Details":A.type==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:[i.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[A.internetDetails.downloadSpeed&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Download"}),i.jsxs("dd",{children:[A.internetDetails.downloadSpeed," Mbit/s"]})]}),A.internetDetails.uploadSpeed&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Upload"}),i.jsxs("dd",{children:[A.internetDetails.uploadSpeed," Mbit/s"]})]}),A.internetDetails.routerModel&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Router"}),i.jsx("dd",{children:A.internetDetails.routerModel})]}),A.internetDetails.routerSerialNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Router S/N"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.internetDetails.routerSerialNumber,i.jsx(de,{value:A.internetDetails.routerSerialNumber})]})]}),A.internetDetails.installationDate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Installation"}),i.jsx("dd",{children:new Date(A.internetDetails.installationDate).toLocaleDateString("de-DE")})]}),A.internetDetails.homeId&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Home-ID"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.internetDetails.homeId,i.jsx(de,{value:A.internetDetails.homeId})]})]}),A.internetDetails.activationCode&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Aktivierungscode"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.internetDetails.activationCode,i.jsx(de,{value:A.internetDetails.activationCode})]})]})]}),(A.internetDetails.internetUsername||A.internetDetails.internetPasswordEncrypted)&&i.jsxs("div",{className:"mt-4 pt-4 border-t",children:[i.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Internet-Zugangsdaten"}),i.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[A.internetDetails.internetUsername&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Benutzername"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.internetDetails.internetUsername,i.jsx(de,{value:A.internetDetails.internetUsername})]})]}),A.internetDetails.internetPasswordEncrypted&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),i.jsxs("dd",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-mono",children:g&&y?y:"••••••••"}),g&&y&&i.jsx(de,{value:y}),i.jsx(I,{variant:"ghost",size:"sm",onClick:Je,children:g?i.jsx(on,{className:"w-4 h-4"}):i.jsx(Oe,{className:"w-4 h-4"})})]})]})]})]}),A.internetDetails.phoneNumbers&&A.internetDetails.phoneNumbers.length>0&&i.jsxs("div",{className:"mt-4 pt-4 border-t",children:[i.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Rufnummern & SIP-Zugangsdaten"}),i.jsx("div",{className:"space-y-3",children:A.internetDetails.phoneNumbers.map(J=>i.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsxs("span",{className:"font-mono font-medium flex items-center gap-1",children:[J.phoneNumber,i.jsx(de,{value:J.phoneNumber})]}),J.isMain&&i.jsx(je,{variant:"success",children:"Hauptnummer"})]}),(J.sipUsername||J.sipPasswordEncrypted||J.sipServer)&&i.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[J.sipUsername&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"SIP-Benutzer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[J.sipUsername,i.jsx(de,{value:J.sipUsername})]})]}),J.sipPasswordEncrypted&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"SIP-Passwort"}),i.jsxs("dd",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-mono",children:b[J.id]&&k[J.id]?k[J.id]:"••••••••"}),b[J.id]&&k[J.id]&&i.jsx(de,{value:k[J.id]}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>et(J.id),children:b[J.id]?i.jsx(on,{className:"w-3 h-3"}):i.jsx(Oe,{className:"w-3 h-3"})})]})]}),J.sipServer&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"SIP-Server"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[J.sipServer,i.jsx(de,{value:J.sipServer})]})]})]})]},J.id))})]})]}),A.mobileDetails&&i.jsxs(Z,{className:"mb-6",title:"Mobilfunk-Details",children:[i.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[A.mobileDetails.dataVolume&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Datenvolumen"}),i.jsxs("dd",{children:[A.mobileDetails.dataVolume," GB"]})]}),A.mobileDetails.includedMinutes&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-Minuten"}),i.jsx("dd",{children:A.mobileDetails.includedMinutes})]}),A.mobileDetails.includedSMS&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-SMS"}),i.jsx("dd",{children:A.mobileDetails.includedSMS})]}),A.mobileDetails.deviceModel&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Gerät"}),i.jsx("dd",{children:A.mobileDetails.deviceModel})]}),A.mobileDetails.deviceImei&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"IMEI"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.mobileDetails.deviceImei,i.jsx(de,{value:A.mobileDetails.deviceImei})]})]}),A.mobileDetails.requiresMultisim&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Multisim"}),i.jsx("dd",{children:i.jsx(je,{variant:"warning",children:"Erforderlich"})})]})]}),A.mobileDetails.simCards&&A.mobileDetails.simCards.length>0&&i.jsxs("div",{className:"mt-6 pt-6 border-t",children:[i.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karten"}),i.jsx("div",{className:"space-y-3",children:A.mobileDetails.simCards.map(J=>i.jsx(h3,{simCard:J},J.id))})]}),(!A.mobileDetails.simCards||A.mobileDetails.simCards.length===0)&&(A.mobileDetails.phoneNumber||A.mobileDetails.simCardNumber)&&i.jsxs("div",{className:"mt-6 pt-6 border-t",children:[i.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karte (Legacy)"}),i.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[A.mobileDetails.phoneNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Rufnummer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.mobileDetails.phoneNumber,i.jsx(de,{value:A.mobileDetails.phoneNumber})]})]}),A.mobileDetails.simCardNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"SIM-Kartennummer"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.mobileDetails.simCardNumber,i.jsx(de,{value:A.mobileDetails.simCardNumber})]})]})]})]})]}),A.tvDetails&&i.jsx(Z,{className:"mb-6",title:"TV-Details",children:i.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[A.tvDetails.receiverModel&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Receiver"}),i.jsx("dd",{children:A.tvDetails.receiverModel})]}),A.tvDetails.smartcardNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Smartcard"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.tvDetails.smartcardNumber,i.jsx(de,{value:A.tvDetails.smartcardNumber})]})]}),A.tvDetails.package&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Paket"}),i.jsx("dd",{children:A.tvDetails.package})]})]})}),A.carInsuranceDetails&&i.jsx(Z,{className:"mb-6",title:"KFZ-Versicherung Details",children:i.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[A.carInsuranceDetails.licensePlate&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Kennzeichen"}),i.jsxs("dd",{className:"font-mono font-bold flex items-center gap-1",children:[A.carInsuranceDetails.licensePlate,i.jsx(de,{value:A.carInsuranceDetails.licensePlate})]})]}),A.carInsuranceDetails.vehicleType&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Fahrzeug"}),i.jsx("dd",{children:A.carInsuranceDetails.vehicleType})]}),A.carInsuranceDetails.hsn&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"HSN/TSN"}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.carInsuranceDetails.hsn,"/",A.carInsuranceDetails.tsn,i.jsx(de,{value:`${A.carInsuranceDetails.hsn}/${A.carInsuranceDetails.tsn}`})]})]}),A.carInsuranceDetails.vin&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"FIN"}),i.jsxs("dd",{className:"font-mono text-sm flex items-center gap-1",children:[A.carInsuranceDetails.vin,i.jsx(de,{value:A.carInsuranceDetails.vin})]})]}),A.carInsuranceDetails.firstRegistration&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Erstzulassung"}),i.jsx("dd",{children:new Date(A.carInsuranceDetails.firstRegistration).toLocaleDateString("de-DE")})]}),A.carInsuranceDetails.noClaimsClass&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"SF-Klasse"}),i.jsx("dd",{children:A.carInsuranceDetails.noClaimsClass})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsart"}),i.jsx("dd",{children:i.jsx(je,{variant:A.carInsuranceDetails.insuranceType==="FULL"?"success":A.carInsuranceDetails.insuranceType==="PARTIAL"?"warning":"default",children:A.carInsuranceDetails.insuranceType==="FULL"?"Vollkasko":A.carInsuranceDetails.insuranceType==="PARTIAL"?"Teilkasko":"Haftpflicht"})})]}),A.carInsuranceDetails.deductiblePartial&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"SB Teilkasko"}),i.jsxs("dd",{children:[A.carInsuranceDetails.deductiblePartial," €"]})]}),A.carInsuranceDetails.deductibleFull&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"SB Vollkasko"}),i.jsxs("dd",{children:[A.carInsuranceDetails.deductibleFull," €"]})]}),A.carInsuranceDetails.policyNumber&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsschein-Nr."}),i.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[A.carInsuranceDetails.policyNumber,i.jsx(de,{value:A.carInsuranceDetails.policyNumber})]})]}),A.carInsuranceDetails.previousInsurer&&i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversicherer"}),i.jsx("dd",{children:A.carInsuranceDetails.previousInsurer})]})]})}),i.jsx(g3,{contractId:c,canEdit:a("contracts:update"),isCustomerPortal:o}),!o&&a("contracts:read")&&A.customerId&&i.jsx(iR,{contractId:c,customerId:A.customerId}),A.notes&&i.jsx(Z,{title:"Notizen",children:i.jsx("p",{className:"whitespace-pre-wrap",children:A.notes})}),!o&&a("contracts:read")&&i.jsx(YR,{contractId:c,canEdit:a("contracts:update")}),T&&A.previousContract&&i.jsx(ZR,{contractId:A.previousContract.id,isOpen:!0,onClose:()=>w(!1)}),i.jsx(Xe,{isOpen:S,onClose:()=>M(!1),title:"Folgevertrag anlegen",size:"sm",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-gray-700",children:"Möchten Sie wirklich einen Folgevertrag für diesen Vertrag anlegen?"}),i.jsx("p",{className:"text-sm text-gray-500",children:"Die Daten des aktuellen Vertrags werden als Vorlage übernommen."}),i.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[i.jsx(I,{variant:"secondary",onClick:()=>M(!1),children:"Nein"}),i.jsx(I,{onClick:()=>{M(!1),K.mutate()},children:"Ja, anlegen"})]})]})}),i.jsx(d3,{isOpen:F,onClose:()=>R(!1)}),i.jsx(Xe,{isOpen:V,onClose:()=>D(!1),title:"Zurückstellung aufheben?",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-gray-700",children:"Möchten Sie die Zurückstellung für diesen Vertrag wirklich aufheben?"}),i.jsx("p",{className:"text-sm text-gray-500",children:"Der Vertrag wird danach wieder im Cockpit angezeigt, wenn Fristen anstehen oder abgelaufen sind."}),i.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[i.jsx(I,{variant:"secondary",onClick:()=>D(!1),children:"Abbrechen"}),i.jsx(I,{variant:"danger",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Wird aufgehoben...":"Ja, aufheben"})]})]})})]})}const v3=[{value:"DRAFT",label:"Entwurf"},{value:"PENDING",label:"Ausstehend"},{value:"ACTIVE",label:"Aktiv"},{value:"CANCELLED",label:"Gekündigt"},{value:"EXPIRED",label:"Abgelaufen"},{value:"DEACTIVATED",label:"Deaktiviert"}],b3=[{status:"DRAFT",label:"Entwurf",description:"Vertrag wird noch vorbereitet",color:"text-gray-600"},{status:"PENDING",label:"Ausstehend",description:"Wartet auf Aktivierung",color:"text-yellow-600"},{status:"ACTIVE",label:"Aktiv",description:"Vertrag läuft normal",color:"text-green-600"},{status:"EXPIRED",label:"Abgelaufen",description:"Laufzeit vorbei, läuft aber ohne Kündigung weiter",color:"text-orange-600"},{status:"CANCELLED",label:"Gekündigt",description:"Aktive Kündigung eingereicht, Vertrag endet",color:"text-red-600"},{status:"DEACTIVATED",label:"Deaktiviert",description:"Manuell beendet/archiviert",color:"text-gray-500"}];function j3({isOpen:t,onClose:e}){return t?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"fixed inset-0 bg-black/20",onClick:e}),i.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl p-4 max-w-sm w-full mx-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-sm font-semibold text-gray-900",children:"Vertragsstatus-Übersicht"}),i.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:i.jsx(nn,{className:"w-4 h-4"})})]}),i.jsx("div",{className:"space-y-2",children:b3.map(({status:n,label:s,description:r,color:a})=>i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("span",{className:`font-medium text-sm min-w-[90px] ${a}`,children:s}),i.jsx("span",{className:"text-sm text-gray-600",children:r})]},n))})]})]}):null}function X1(){var jo,Ad,No,R0,O0,L0,F0,z0,$0;const{id:t}=md(),[e]=Sf(),n=fn(),s=ye(),r=!!t,a=e.get("customerId"),{register:l,handleSubmit:o,reset:c,watch:d,setValue:u,formState:{errors:h}}=$C({defaultValues:{customerId:a||"",type:"ELECTRICITY",status:"DRAFT",previousContractId:""}}),m=d("type"),f=d("customerId"),p=d("previousContractId"),{data:g}=fe({queryKey:["contract",t],queryFn:()=>He.getById(parseInt(t)),enabled:r}),{data:x}=fe({queryKey:["customers-all"],queryFn:()=>Zt.getAll({limit:1e3})}),{data:y}=fe({queryKey:["customer",f],queryFn:()=>Zt.getById(parseInt(f)),enabled:!!f}),{data:v}=fe({queryKey:["customer-contracts-for-predecessor",f],queryFn:()=>He.getAll({customerId:parseInt(f),limit:1e3}),enabled:!!f}),{data:b}=fe({queryKey:["platforms"],queryFn:()=>Fc.getAll()}),{data:j}=fe({queryKey:["cancellation-periods"],queryFn:()=>zc.getAll()}),{data:k}=fe({queryKey:["contract-durations"],queryFn:()=>$c.getAll()}),{data:E}=fe({queryKey:["providers"],queryFn:()=>to.getAll()}),{data:T}=fe({queryKey:["contract-categories"],queryFn:()=>Bc.getAll()}),w=d("providerId"),[S,M]=N.useState(null),[F,R]=N.useState([]),[V,D]=N.useState([]),[z,C]=N.useState(!1),[_,K]=N.useState("manual"),[B,W]=N.useState(""),[ce,he]=N.useState(!1),[Je,et]=N.useState(!1),[mt,A]=N.useState({}),[pt,On]=N.useState({}),[wn,le]=N.useState({}),[it,Rt]=N.useState(!1);N.useEffect(()=>{r||C(!0)},[r]),N.useEffect(()=>{!r&&a&&(x!=null&&x.data)&&x.data.some(oe=>oe.id.toString()===a)&&u("customerId",a)},[r,a,x,u]),N.useEffect(()=>{z&&S&&w!==S&&u("tariffId",""),M(w)},[w,S,u,z]),N.useEffect(()=>{if(!r&&(T!=null&&T.data)&&T.data.length>0){const O=d("type"),oe=T.data.filter(ve=>ve.isActive),Ae=oe.some(ve=>ve.code===O);if(!O||!Ae){const ve=oe.sort((Se,wt)=>Se.sortOrder-wt.sortOrder)[0];ve&&u("type",ve.code)}}},[T,r,u,d]),N.useEffect(()=>{r&&(g!=null&&g.data)&&!f&&u("customerId",g.data.customerId.toString())},[r,g,f,u]),N.useEffect(()=>{var O,oe,Ae,ve,Se,wt,Re,wo,B0,_0,V0,K0,U0,q0,H0,W0,Q0,G0,J0,Z0,Y0,X0,ev,tv,nv,sv,rv,iv,av,lv,ov,cv,dv,uv,hv,fv,mv,pv,gv,xv,yv,vv,bv,jv,Nv,wv,kv,Sv,Cv,Ev,Av,Dv;if(g!=null&&g.data&&(b!=null&&b.data)&&(T!=null&&T.data)&&(E!=null&&E.data)&&(y!=null&&y.data)){const ae=g.data;c({customerId:ae.customerId.toString(),type:ae.type,status:ae.status,addressId:((O=ae.addressId)==null?void 0:O.toString())||"",billingAddressId:((oe=ae.billingAddressId)==null?void 0:oe.toString())||"",bankCardId:((Ae=ae.bankCardId)==null?void 0:Ae.toString())||"",identityDocumentId:((ve=ae.identityDocumentId)==null?void 0:ve.toString())||"",salesPlatformId:((Se=ae.salesPlatformId)==null?void 0:Se.toString())||"",providerId:((wt=ae.providerId)==null?void 0:wt.toString())||"",tariffId:((Re=ae.tariffId)==null?void 0:Re.toString())||"",providerName:ae.providerName||"",tariffName:ae.tariffName||"",customerNumberAtProvider:ae.customerNumberAtProvider||"",contractNumberAtProvider:ae.contractNumberAtProvider||"",priceFirst12Months:ae.priceFirst12Months||"",priceFrom13Months:ae.priceFrom13Months||"",priceAfter24Months:ae.priceAfter24Months||"",startDate:ae.startDate?ae.startDate.split("T")[0]:"",endDate:ae.endDate?ae.endDate.split("T")[0]:"",cancellationPeriodId:((wo=ae.cancellationPeriodId)==null?void 0:wo.toString())||"",contractDurationId:((B0=ae.contractDurationId)==null?void 0:B0.toString())||"",commission:ae.commission||"",portalUsername:ae.portalUsername||"",notes:ae.notes||"",meterId:((V0=(_0=ae.energyDetails)==null?void 0:_0.meterId)==null?void 0:V0.toString())||"",maloId:((K0=ae.energyDetails)==null?void 0:K0.maloId)||"",annualConsumption:((U0=ae.energyDetails)==null?void 0:U0.annualConsumption)||"",annualConsumptionKwh:((q0=ae.energyDetails)==null?void 0:q0.annualConsumptionKwh)||"",basePrice:((H0=ae.energyDetails)==null?void 0:H0.basePrice)||"",unitPrice:((W0=ae.energyDetails)==null?void 0:W0.unitPrice)||"",bonus:((Q0=ae.energyDetails)==null?void 0:Q0.bonus)||"",downloadSpeed:((G0=ae.internetDetails)==null?void 0:G0.downloadSpeed)||"",uploadSpeed:((J0=ae.internetDetails)==null?void 0:J0.uploadSpeed)||"",routerModel:((Z0=ae.internetDetails)==null?void 0:Z0.routerModel)||"",routerSerialNumber:((Y0=ae.internetDetails)==null?void 0:Y0.routerSerialNumber)||"",installationDate:(X0=ae.internetDetails)!=null&&X0.installationDate?ae.internetDetails.installationDate.split("T")[0]:"",internetUsername:((ev=ae.internetDetails)==null?void 0:ev.internetUsername)||"",homeId:((tv=ae.internetDetails)==null?void 0:tv.homeId)||"",activationCode:((nv=ae.internetDetails)==null?void 0:nv.activationCode)||"",requiresMultisim:((sv=ae.mobileDetails)==null?void 0:sv.requiresMultisim)||!1,dataVolume:((rv=ae.mobileDetails)==null?void 0:rv.dataVolume)||"",includedMinutes:((iv=ae.mobileDetails)==null?void 0:iv.includedMinutes)||"",includedSMS:((av=ae.mobileDetails)==null?void 0:av.includedSMS)||"",deviceModel:((lv=ae.mobileDetails)==null?void 0:lv.deviceModel)||"",deviceImei:((ov=ae.mobileDetails)==null?void 0:ov.deviceImei)||"",phoneNumber:((cv=ae.mobileDetails)==null?void 0:cv.phoneNumber)||"",simCardNumber:((dv=ae.mobileDetails)==null?void 0:dv.simCardNumber)||"",receiverModel:((uv=ae.tvDetails)==null?void 0:uv.receiverModel)||"",smartcardNumber:((hv=ae.tvDetails)==null?void 0:hv.smartcardNumber)||"",tvPackage:((fv=ae.tvDetails)==null?void 0:fv.package)||"",licensePlate:((mv=ae.carInsuranceDetails)==null?void 0:mv.licensePlate)||"",hsn:((pv=ae.carInsuranceDetails)==null?void 0:pv.hsn)||"",tsn:((gv=ae.carInsuranceDetails)==null?void 0:gv.tsn)||"",vin:((xv=ae.carInsuranceDetails)==null?void 0:xv.vin)||"",vehicleType:((yv=ae.carInsuranceDetails)==null?void 0:yv.vehicleType)||"",firstRegistration:(vv=ae.carInsuranceDetails)!=null&&vv.firstRegistration?ae.carInsuranceDetails.firstRegistration.split("T")[0]:"",noClaimsClass:((bv=ae.carInsuranceDetails)==null?void 0:bv.noClaimsClass)||"",insuranceType:((jv=ae.carInsuranceDetails)==null?void 0:jv.insuranceType)||"LIABILITY",deductiblePartial:((Nv=ae.carInsuranceDetails)==null?void 0:Nv.deductiblePartial)||"",deductibleFull:((wv=ae.carInsuranceDetails)==null?void 0:wv.deductibleFull)||"",policyNumber:((kv=ae.carInsuranceDetails)==null?void 0:kv.policyNumber)||"",previousInsurer:((Sv=ae.carInsuranceDetails)==null?void 0:Sv.previousInsurer)||"",cancellationConfirmationDate:ae.cancellationConfirmationDate?ae.cancellationConfirmationDate.split("T")[0]:"",cancellationConfirmationOptionsDate:ae.cancellationConfirmationOptionsDate?ae.cancellationConfirmationOptionsDate.split("T")[0]:"",wasSpecialCancellation:ae.wasSpecialCancellation||!1,previousContractId:((Cv=ae.previousContractId)==null?void 0:Cv.toString())||"",previousProviderId:((Ev=ae.previousProviderId)==null?void 0:Ev.toString())||"",previousCustomerNumber:ae.previousCustomerNumber||"",previousContractNumber:ae.previousContractNumber||""}),(Av=ae.mobileDetails)!=null&&Av.simCards&&ae.mobileDetails.simCards.length>0?R(ae.mobileDetails.simCards.map(Fn=>({id:Fn.id,phoneNumber:Fn.phoneNumber||"",simCardNumber:Fn.simCardNumber||"",pin:"",puk:"",hasExistingPin:!!Fn.pin,hasExistingPuk:!!Fn.puk,isMultisim:Fn.isMultisim,isMain:Fn.isMain}))):R([]),(Dv=ae.internetDetails)!=null&&Dv.phoneNumbers&&ae.internetDetails.phoneNumbers.length>0?D(ae.internetDetails.phoneNumbers.map(Fn=>({id:Fn.id,phoneNumber:Fn.phoneNumber||"",sipUsername:Fn.sipUsername||"",sipPassword:"",hasExistingSipPassword:!!Fn.sipPasswordEncrypted,sipServer:Fn.sipServer||"",isMain:Fn.isMain}))):D([]),ae.stressfreiEmailId?(K("stressfrei"),W(ae.stressfreiEmailId.toString())):(K("manual"),W("")),C(!0)}},[g,c,b,T,E,y]);const J=d("startDate"),Ke=d("contractDurationId");N.useEffect(()=>{if(J&&Ke&&(k!=null&&k.data)){const O=k.data.find(oe=>oe.id===parseInt(Ke));if(O){const oe=new Date(J),ve=O.code.match(/^(\d+)([MTJ])$/);if(ve){const Se=parseInt(ve[1]),wt=ve[2];let Re=new Date(oe);wt==="T"?Re.setDate(Re.getDate()+Se):wt==="M"?Re.setMonth(Re.getMonth()+Se):wt==="J"&&Re.setFullYear(Re.getFullYear()+Se),u("endDate",Re.toISOString().split("T")[0])}}}},[J,Ke,k,u]);const ct=G({mutationFn:He.create,onSuccess:(O,oe)=>{s.invalidateQueries({queryKey:["contracts"]}),oe.customerId&&s.invalidateQueries({queryKey:["customer",oe.customerId.toString()]}),s.invalidateQueries({queryKey:["customers"]}),n(a?`/customers/${a}?tab=contracts`:"/contracts")}}),ee=G({mutationFn:O=>He.update(parseInt(t),O),onSuccess:(O,oe)=>{s.invalidateQueries({queryKey:["contracts"]}),s.invalidateQueries({queryKey:["contract",t]}),oe.customerId&&s.invalidateQueries({queryKey:["customer",oe.customerId.toString()]}),s.invalidateQueries({queryKey:["customers"]}),n(`/contracts/${t}`)}}),pe=O=>{const oe=Re=>{if(Re==null||Re==="")return;const wo=parseInt(String(Re));return isNaN(wo)?void 0:wo},Ae=Wt.find(Re=>Re.code===O.type),ve=oe(O.customerId);if(!ve){alert("Bitte wählen Sie einen Kunden aus");return}if(!O.type||!Ae){alert("Bitte wählen Sie einen Vertragstyp aus");return}const Se=Re=>Re==null||Re===""?null:Re,wt={customerId:ve,type:O.type,contractCategoryId:Ae.id,status:O.status,addressId:oe(O.addressId)??null,billingAddressId:oe(O.billingAddressId)??null,bankCardId:oe(O.bankCardId)??null,identityDocumentId:oe(O.identityDocumentId)??null,salesPlatformId:oe(O.salesPlatformId)??null,providerId:oe(O.providerId)??null,tariffId:oe(O.tariffId)??null,providerName:Se(O.providerName),tariffName:Se(O.tariffName),customerNumberAtProvider:Se(O.customerNumberAtProvider),contractNumberAtProvider:Se(O.contractNumberAtProvider),priceFirst12Months:Se(O.priceFirst12Months),priceFrom13Months:Se(O.priceFrom13Months),priceAfter24Months:Se(O.priceAfter24Months),startDate:O.startDate?new Date(O.startDate):null,endDate:O.endDate?new Date(O.endDate):null,cancellationPeriodId:oe(O.cancellationPeriodId)??null,contractDurationId:oe(O.contractDurationId)??null,commission:O.commission?parseFloat(O.commission):null,portalUsername:_==="manual"?Se(O.portalUsername):null,stressfreiEmailId:_==="stressfrei"&&B?parseInt(B):null,portalPassword:O.portalPassword||void 0,notes:Se(O.notes),cancellationConfirmationDate:O.cancellationConfirmationDate?new Date(O.cancellationConfirmationDate):null,cancellationConfirmationOptionsDate:O.cancellationConfirmationOptionsDate?new Date(O.cancellationConfirmationOptionsDate):null,wasSpecialCancellation:O.wasSpecialCancellation||!1,previousContractId:oe(O.previousContractId)??null,previousProviderId:O.previousContractId?null:oe(O.previousProviderId)??null,previousCustomerNumber:O.previousContractId?null:Se(O.previousCustomerNumber),previousContractNumber:O.previousContractId?null:Se(O.previousContractNumber)};["ELECTRICITY","GAS"].includes(O.type)&&(wt.energyDetails={meterId:oe(O.meterId)??null,maloId:Se(O.maloId),annualConsumption:O.annualConsumption?parseFloat(O.annualConsumption):null,annualConsumptionKwh:O.annualConsumptionKwh?parseFloat(O.annualConsumptionKwh):null,basePrice:O.basePrice?parseFloat(O.basePrice):null,unitPrice:O.unitPrice?parseFloat(O.unitPrice):null,bonus:O.bonus?parseFloat(O.bonus):null}),["DSL","CABLE","FIBER"].includes(O.type)&&(wt.internetDetails={downloadSpeed:oe(O.downloadSpeed)??null,uploadSpeed:oe(O.uploadSpeed)??null,routerModel:Se(O.routerModel),routerSerialNumber:Se(O.routerSerialNumber),installationDate:O.installationDate?new Date(O.installationDate):null,internetUsername:Se(O.internetUsername),internetPassword:O.internetPassword||void 0,homeId:Se(O.homeId),activationCode:Se(O.activationCode),phoneNumbers:V.length>0?V.map(Re=>({id:Re.id,phoneNumber:Re.phoneNumber||"",isMain:Re.isMain??!1,sipUsername:Se(Re.sipUsername),sipPassword:Re.sipPassword||void 0,sipServer:Se(Re.sipServer)})):void 0}),O.type==="MOBILE"&&(wt.mobileDetails={requiresMultisim:O.requiresMultisim||!1,dataVolume:O.dataVolume?parseFloat(O.dataVolume):null,includedMinutes:oe(O.includedMinutes)??null,includedSMS:oe(O.includedSMS)??null,deviceModel:Se(O.deviceModel),deviceImei:Se(O.deviceImei),phoneNumber:Se(O.phoneNumber),simCardNumber:Se(O.simCardNumber),simCards:F.length>0?F.map(Re=>({id:Re.id,phoneNumber:Se(Re.phoneNumber),simCardNumber:Se(Re.simCardNumber),pin:Re.pin||void 0,puk:Re.puk||void 0,isMultisim:Re.isMultisim,isMain:Re.isMain})):void 0}),O.type==="TV"&&(wt.tvDetails={receiverModel:Se(O.receiverModel),smartcardNumber:Se(O.smartcardNumber),package:Se(O.tvPackage)}),O.type==="CAR_INSURANCE"&&(wt.carInsuranceDetails={licensePlate:Se(O.licensePlate),hsn:Se(O.hsn),tsn:Se(O.tsn),vin:Se(O.vin),vehicleType:Se(O.vehicleType),firstRegistration:O.firstRegistration?new Date(O.firstRegistration):null,noClaimsClass:Se(O.noClaimsClass),insuranceType:O.insuranceType,deductiblePartial:O.deductiblePartial?parseFloat(O.deductiblePartial):null,deductibleFull:O.deductibleFull?parseFloat(O.deductibleFull):null,policyNumber:Se(O.policyNumber),previousInsurer:Se(O.previousInsurer)}),r?ee.mutate(wt):ct.mutate(wt)},Ln=ct.isPending||ee.isPending,ur=ct.error||ee.error,Ot=y==null?void 0:y.data,L=(Ot==null?void 0:Ot.addresses)||[],U=((jo=Ot==null?void 0:Ot.bankCards)==null?void 0:jo.filter(O=>O.isActive))||[],Q=((Ad=Ot==null?void 0:Ot.identityDocuments)==null?void 0:Ad.filter(O=>O.isActive))||[],ue=((No=Ot==null?void 0:Ot.meters)==null?void 0:No.filter(O=>O.isActive))||[],ie=((R0=Ot==null?void 0:Ot.stressfreiEmails)==null?void 0:R0.filter(O=>O.isActive))||[],se=(b==null?void 0:b.data)||[],Ne=(j==null?void 0:j.data)||[],qe=(k==null?void 0:k.data)||[],_e=((O0=E==null?void 0:E.data)==null?void 0:O0.filter(O=>O.isActive))||[],Wt=((L0=T==null?void 0:T.data)==null?void 0:L0.filter(O=>O.isActive).sort((O,oe)=>O.sortOrder-oe.sortOrder))||[],hr=Wt.map(O=>({value:O.code,label:O.name})),qs=((v==null?void 0:v.data)||[]).filter(O=>!r||O.id!==parseInt(t)).sort((O,oe)=>new Date(oe.startDate||0).getTime()-new Date(O.startDate||0).getTime()),Wr=_e.find(O=>O.id===parseInt(w||"0")),bo=((F0=Wr==null?void 0:Wr.tariffs)==null?void 0:F0.filter(O=>O.isActive))||[],Ya=O=>{const oe=O.companyName||`${O.firstName} ${O.lastName}`,Ae=O.birthDate?` (geb. ${new Date(O.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})`:"";return`${O.customerNumber} - ${oe}${Ae}`},Xf=(()=>{var Ae;const oe=((x==null?void 0:x.data)||[]).map(ve=>({value:ve.id.toString(),label:Ya(ve)}));if(r&&((Ae=g==null?void 0:g.data)!=null&&Ae.customer)){const ve=g.data.customer;oe.some(wt=>wt.value===ve.id.toString())||oe.unshift({value:ve.id.toString(),label:Ya(ve)})}return oe})();return i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold mb-6",children:r?"Vertrag bearbeiten":"Neuer Vertrag"}),ur&&i.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:ur instanceof Error?ur.message:"Ein Fehler ist aufgetreten"}),i.jsxs("form",{onSubmit:o(pe),children:[i.jsx(Z,{className:"mb-6",title:"Vertragsdaten",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(Fe,{label:"Kunde *",...l("customerId",{required:"Kunde erforderlich"}),options:Xf,error:(z0=h.customerId)==null?void 0:z0.message}),i.jsx(Fe,{label:"Vertragstyp *",...l("type",{required:"Typ erforderlich"}),options:hr}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Status"}),i.jsx("button",{type:"button",onClick:()=>Rt(!0),className:"text-gray-400 hover:text-blue-600 transition-colors",title:"Status-Erklärung",children:i.jsx(bd,{className:"w-4 h-4"})})]}),i.jsx(Fe,{...l("status"),options:v3})]}),i.jsx(Fe,{label:"Vertriebsplattform",...l("salesPlatformId"),options:se.map(O=>({value:O.id,label:O.name}))}),f&&i.jsx(Fe,{label:"Vorgänger-Vertrag",...l("previousContractId"),options:qs.map(O=>({value:O.id,label:`${O.contractNumber} (${O.type}${O.startDate?` - ${new Date(O.startDate).toLocaleDateString("de-DE")}`:""})`})),placeholder:"Keinen Vorgänger auswählen"}),f&&!p&&i.jsxs("div",{className:"mt-4 p-4 bg-gray-50 rounded-lg border border-gray-200",children:[i.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Altanbieter-Daten"}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsx(Fe,{label:"Altanbieter",...l("previousProviderId"),options:_e.map(O=>({value:O.id,label:O.name})),placeholder:"Bitte wählen..."}),i.jsx(q,{label:"Kundennr. beim Altanbieter",...l("previousCustomerNumber")}),i.jsx(q,{label:"Vertragsnr. beim Altanbieter",...l("previousContractNumber")})]})]})]})}),f&&i.jsxs(Z,{className:"mb-6",title:"Kundendaten verknüpfen",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[i.jsx(Fe,{label:"Lieferadresse",...l("addressId"),options:L.filter(O=>O.type==="DELIVERY_RESIDENCE").map(O=>({value:O.id,label:`${O.street} ${O.houseNumber}, ${O.postalCode} ${O.city}`}))}),i.jsx(Fe,{label:"Rechnungsadresse",...l("billingAddressId"),options:L.filter(O=>O.type==="BILLING").map(O=>({value:O.id,label:`${O.street} ${O.houseNumber}, ${O.postalCode} ${O.city}`})),placeholder:"Wie Lieferadresse"})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(Fe,{label:"Bankkarte",...l("bankCardId"),options:U.map(O=>({value:O.id,label:`${O.iban} (${O.accountHolder})`}))}),i.jsx(Fe,{label:"Ausweis",...l("identityDocumentId"),options:Q.map(O=>({value:O.id,label:`${O.documentNumber} (${O.type})`}))})]})]}),i.jsx(Z,{className:"mb-6",title:"Anbieter & Tarif",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(Fe,{label:"Anbieter",...l("providerId"),options:_e.map(O=>({value:O.id,label:O.name}))}),i.jsx(Fe,{label:"Tarif",...l("tariffId"),options:bo.map(O=>({value:O.id,label:O.name})),disabled:!w}),i.jsx(q,{label:"Kundennummer beim Anbieter",...l("customerNumberAtProvider")}),i.jsx(q,{label:"Vertragsnummer beim Anbieter",...l("contractNumberAtProvider")}),i.jsx(q,{label:"Provision (€)",type:"number",step:"0.01",...l("commission")}),i.jsx(q,{label:"Preis erste 12 Monate",...l("priceFirst12Months"),placeholder:"z.B. 29,99 €/Monat"}),i.jsx(q,{label:"Preis ab 13. Monat",...l("priceFrom13Months"),placeholder:"z.B. 39,99 €/Monat"}),i.jsx(q,{label:"Preis nach 24 Monaten",...l("priceAfter24Months"),placeholder:"z.B. 49,99 €/Monat"})]})}),i.jsxs(Z,{className:"mb-6",title:"Laufzeit und Kündigung",children:[i.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[i.jsx("strong",{children:"Hinweis:"})," Ist die Laufzeit ≤ 4 Wochen, 1 Monat oder 30 Tage, gilt der Vertrag als unbefristet mit der jeweiligen Kündigungsfrist."]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(q,{label:"Vertragsbeginn",type:"date",...l("startDate"),value:d("startDate")||"",onClear:()=>u("startDate","")}),i.jsx(q,{label:"Vertragsende (berechnet)",type:"date",...l("endDate"),disabled:!0,className:"bg-gray-50"}),i.jsx(Fe,{label:"Vertragslaufzeit",...l("contractDurationId"),options:qe.map(O=>({value:O.id,label:O.description}))}),i.jsx(Fe,{label:"Kündigungsfrist",...l("cancellationPeriodId"),options:Ne.map(O=>({value:O.id,label:O.description}))}),i.jsx(q,{label:"Kündigungsbestätigungsdatum",type:"date",...l("cancellationConfirmationDate"),value:d("cancellationConfirmationDate")||"",onClear:()=>u("cancellationConfirmationDate","")}),i.jsx(q,{label:"Kündigungsbestätigungsoptionendatum",type:"date",...l("cancellationConfirmationOptionsDate"),value:d("cancellationConfirmationOptionsDate")||"",onClear:()=>u("cancellationConfirmationOptionsDate","")}),i.jsx("div",{className:"col-span-2",children:i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",...l("wasSpecialCancellation"),className:"rounded border-gray-300"}),i.jsx("span",{children:"Wurde sondergekündigt?"})]})})]})]}),i.jsx(Z,{className:"mb-6",title:"Zugangsdaten (verschlüsselt gespeichert)",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Portal Benutzername"}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"radio",name:"usernameType",checked:_==="manual",onChange:()=>{K("manual"),W("")},className:"text-blue-600"}),i.jsx("span",{className:"text-sm",children:"Manuell eingeben"})]}),_==="manual"&&i.jsx(q,{...l("portalUsername"),placeholder:"Benutzername eingeben..."}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"radio",name:"usernameType",checked:_==="stressfrei",onChange:()=>{K("stressfrei"),u("portalUsername","")},className:"text-blue-600"}),i.jsx("span",{className:"text-sm",children:"Stressfrei-Wechseln Adresse"})]}),_==="stressfrei"&&i.jsx(Fe,{value:B,onChange:O=>W(O.target.value),options:ie.map(O=>({value:O.id,label:O.email+(O.notes?` (${O.notes})`:"")})),placeholder:ie.length===0?"Keine Stressfrei-Adressen vorhanden":"Adresse auswählen..."}),_==="stressfrei"&&ie.length===0&&i.jsx("p",{className:"text-xs text-amber-600",children:"Keine Stressfrei-Wechseln Adressen für diesen Kunden vorhanden. Bitte zuerst beim Kunden anlegen."})]})]}),i.jsxs("div",{className:"mt-8",children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:r?"Neues Passwort (leer lassen = unverändert)":"Portal Passwort"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:ce?"text":"password",...l("portalPassword"),className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),i.jsx("button",{type:"button",onClick:()=>he(!ce),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:ce?i.jsx(on,{className:"w-4 h-4"}):i.jsx(Oe,{className:"w-4 h-4"})})]})]})]})}),["ELECTRICITY","GAS"].includes(m)&&i.jsxs(Z,{className:"mb-6",title:m==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(Fe,{label:"Zähler",...l("meterId"),options:ue.filter(O=>O.type===m).map(O=>({value:O.id,label:`${O.meterNumber}${O.location?` (${O.location})`:""}`}))}),i.jsx(q,{label:"MaLo-ID (Marktlokations-ID)",...l("maloId")}),i.jsx(q,{label:`Jahresverbrauch (${m==="ELECTRICITY"?"kWh":"m³"})`,type:"number",...l("annualConsumption")}),m==="GAS"&&i.jsx(q,{label:"Jahresverbrauch (kWh)",type:"number",...l("annualConsumptionKwh")}),i.jsx(q,{label:"Grundpreis (€/Monat)",type:"number",step:"any",...l("basePrice")}),i.jsx(q,{label:"Arbeitspreis (€/kWh)",type:"number",step:"any",...l("unitPrice")}),i.jsx(q,{label:"Bonus (€)",type:"number",step:"0.01",...l("bonus")})]}),r&&i.jsxs("div",{className:"mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg text-sm text-blue-700",children:[i.jsx("strong",{children:"Hinweis:"})," Zählerstände und Rechnungen werden in der"," ",i.jsx("span",{className:"font-medium",children:"Vertragsdetailansicht"})," verwaltet, nicht hier im Bearbeitungsformular."]})]}),["DSL","CABLE","FIBER"].includes(m)&&i.jsxs(i.Fragment,{children:[i.jsx(Z,{className:"mb-6",title:m==="DSL"?"DSL-Details":m==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(q,{label:"Download (Mbit/s)",type:"number",...l("downloadSpeed")}),i.jsx(q,{label:"Upload (Mbit/s)",type:"number",...l("uploadSpeed")}),i.jsx(q,{label:"Router Modell",...l("routerModel")}),i.jsx(q,{label:"Router Seriennummer",...l("routerSerialNumber")}),i.jsx(q,{label:"Installationsdatum",type:"date",...l("installationDate"),value:d("installationDate")||"",onClear:()=>u("installationDate","")}),m==="FIBER"&&i.jsx(q,{label:"Home-ID",...l("homeId")}),(($0=Wr==null?void 0:Wr.name)==null?void 0:$0.toLowerCase().includes("vodafone"))&&["DSL","CABLE"].includes(m)&&i.jsx(q,{label:"Aktivierungscode",...l("activationCode")})]})}),i.jsx(Z,{className:"mb-6",title:"Internet-Zugangsdaten (verschlüsselt)",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(q,{label:"Benutzername",...l("internetUsername")}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:r?"Neues Passwort (leer = beibehalten)":"Passwort"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:Je?"text":"password",...l("internetPassword"),className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),i.jsx("button",{type:"button",onClick:()=>et(!Je),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Je?i.jsx(on,{className:"w-4 h-4"}):i.jsx(Oe,{className:"w-4 h-4"})})]})]})]})}),i.jsxs(Z,{className:"mb-6",title:"Rufnummern & SIP-Zugangsdaten",children:[i.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie Festnetz-Rufnummern mit SIP-Zugangsdaten erfassen."}),V.length>0&&i.jsx("div",{className:"space-y-4 mb-4",children:V.map((O,oe)=>i.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[i.jsxs("div",{className:"flex justify-between items-center mb-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("span",{className:"font-medium",children:["Rufnummer ",oe+1]}),i.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[i.jsx("input",{type:"checkbox",checked:O.isMain,onChange:Ae=>{const ve=[...V];Ae.target.checked?ve.forEach((Se,wt)=>Se.isMain=wt===oe):ve[oe].isMain=!1,D(ve)},className:"rounded border-gray-300"}),"Hauptnummer"]})]}),i.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>{D(V.filter((Ae,ve)=>ve!==oe))},children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[i.jsx(q,{label:"Rufnummer",value:O.phoneNumber,onChange:Ae=>{const ve=[...V];ve[oe].phoneNumber=Ae.target.value,D(ve)},placeholder:"z.B. 030 123456"}),i.jsx(q,{label:"SIP-Benutzername",value:O.sipUsername,onChange:Ae=>{const ve=[...V];ve[oe].sipUsername=Ae.target.value,D(ve)}}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:O.hasExistingSipPassword?"SIP-Passwort (bereits hinterlegt)":"SIP-Passwort"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:mt[oe]?"text":"password",value:O.sipPassword,onChange:Ae=>{const ve=[...V];ve[oe].sipPassword=Ae.target.value,D(ve)},placeholder:O.hasExistingSipPassword?"Leer = beibehalten":"",className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),i.jsx("button",{type:"button",onClick:()=>A(Ae=>({...Ae,[oe]:!Ae[oe]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:mt[oe]?i.jsx(on,{className:"w-4 h-4"}):i.jsx(Oe,{className:"w-4 h-4"})})]})]}),i.jsx(q,{label:"SIP-Server",value:O.sipServer,onChange:Ae=>{const ve=[...V];ve[oe].sipServer=Ae.target.value,D(ve)},placeholder:"z.B. sip.provider.de"})]})]},oe))}),i.jsxs(I,{type:"button",variant:"secondary",onClick:()=>{D([...V,{phoneNumber:"",sipUsername:"",sipPassword:"",sipServer:"",isMain:V.length===0}])},children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Rufnummer hinzufügen"]})]})]}),m==="MOBILE"&&i.jsxs(i.Fragment,{children:[i.jsxs(Z,{className:"mb-6",title:"Mobilfunk-Details",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(q,{label:"Datenvolumen (GB)",type:"number",...l("dataVolume")}),i.jsx(q,{label:"Inklusiv-Minuten",type:"number",...l("includedMinutes")}),i.jsx(q,{label:"Inklusiv-SMS",type:"number",...l("includedSMS")}),i.jsx(q,{label:"Gerät (Modell)",...l("deviceModel")}),i.jsx(q,{label:"Gerät (IMEI)",...l("deviceImei")})]}),i.jsx("div",{className:"mt-4 pt-4 border-t",children:i.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[i.jsx("input",{type:"checkbox",...l("requiresMultisim"),className:"mt-1 rounded border-gray-300"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium",children:"Multisim erforderlich"}),i.jsx("p",{className:"text-sm text-amber-600 mt-1",children:"Hinweis: Multisim ist bei Klarmobil, Congstar und Otelo nicht buchbar. Muss Freenet oder vergleichbar sein."})]})]})})]}),i.jsxs(Z,{className:"mb-6",title:"SIM-Karten",children:[i.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie alle SIM-Karten zum Vertrag erfassen (Hauptkarte und Multisim-Karten)."}),F.length>0&&i.jsx("div",{className:"space-y-4 mb-4",children:F.map((O,oe)=>i.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[i.jsxs("div",{className:"flex justify-between items-center mb-3",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("span",{className:"font-medium",children:["SIM-Karte ",oe+1]}),i.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[i.jsx("input",{type:"checkbox",checked:O.isMain,onChange:Ae=>{const ve=[...F];Ae.target.checked?ve.forEach((Se,wt)=>Se.isMain=wt===oe):ve[oe].isMain=!1,R(ve)},className:"rounded border-gray-300"}),"Hauptkarte"]}),i.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[i.jsx("input",{type:"checkbox",checked:O.isMultisim,onChange:Ae=>{const ve=[...F];ve[oe].isMultisim=Ae.target.checked,R(ve)},className:"rounded border-gray-300"}),"Multisim"]})]}),i.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>{R(F.filter((Ae,ve)=>ve!==oe))},children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[i.jsx(q,{label:"Rufnummer",value:O.phoneNumber,onChange:Ae=>{const ve=[...F];ve[oe].phoneNumber=Ae.target.value,R(ve)},placeholder:"z.B. 0171 1234567"}),i.jsx(q,{label:"SIM-Kartennummer",value:O.simCardNumber,onChange:Ae=>{const ve=[...F];ve[oe].simCardNumber=Ae.target.value,R(ve)},placeholder:"ICCID"}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:O.hasExistingPin?"PIN (bereits hinterlegt)":"PIN"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:pt[oe]?"text":"password",value:O.pin,onChange:Ae=>{const ve=[...F];ve[oe].pin=Ae.target.value,R(ve)},placeholder:O.hasExistingPin?"Leer = beibehalten":"4-stellig",className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),i.jsx("button",{type:"button",onClick:()=>On(Ae=>({...Ae,[oe]:!Ae[oe]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:pt[oe]?i.jsx(on,{className:"w-4 h-4"}):i.jsx(Oe,{className:"w-4 h-4"})})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:O.hasExistingPuk?"PUK (bereits hinterlegt)":"PUK"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:wn[oe]?"text":"password",value:O.puk,onChange:Ae=>{const ve=[...F];ve[oe].puk=Ae.target.value,R(ve)},placeholder:O.hasExistingPuk?"Leer = beibehalten":"8-stellig",className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),i.jsx("button",{type:"button",onClick:()=>le(Ae=>({...Ae,[oe]:!Ae[oe]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:wn[oe]?i.jsx(on,{className:"w-4 h-4"}):i.jsx(Oe,{className:"w-4 h-4"})})]})]})]})]},oe))}),i.jsxs(I,{type:"button",variant:"secondary",onClick:()=>{R([...F,{phoneNumber:"",simCardNumber:"",pin:"",puk:"",isMultisim:!1,isMain:F.length===0}])},children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"SIM-Karte hinzufügen"]})]})]}),m==="TV"&&i.jsx(Z,{className:"mb-6",title:"TV-Details",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(q,{label:"Receiver Modell",...l("receiverModel")}),i.jsx(q,{label:"Smartcard-Nummer",...l("smartcardNumber")}),i.jsx(q,{label:"Paket",...l("tvPackage"),placeholder:"z.B. Basis, Premium, Sport"})]})}),m==="CAR_INSURANCE"&&i.jsx(Z,{className:"mb-6",title:"KFZ-Versicherung Details",children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsx(q,{label:"Kennzeichen",...l("licensePlate")}),i.jsx(q,{label:"HSN",...l("hsn")}),i.jsx(q,{label:"TSN",...l("tsn")}),i.jsx(q,{label:"FIN (VIN)",...l("vin")}),i.jsx(q,{label:"Fahrzeugtyp",...l("vehicleType")}),i.jsx(q,{label:"Erstzulassung",type:"date",...l("firstRegistration"),value:d("firstRegistration")||"",onClear:()=>u("firstRegistration","")}),i.jsx(q,{label:"SF-Klasse",...l("noClaimsClass")}),i.jsx(Fe,{label:"Versicherungsart",...l("insuranceType"),options:[{value:"LIABILITY",label:"Haftpflicht"},{value:"PARTIAL",label:"Teilkasko"},{value:"FULL",label:"Vollkasko"}]}),i.jsx(q,{label:"SB Teilkasko (€)",type:"number",...l("deductiblePartial")}),i.jsx(q,{label:"SB Vollkasko (€)",type:"number",...l("deductibleFull")}),i.jsx(q,{label:"Versicherungsscheinnummer",...l("policyNumber")}),i.jsx(q,{label:"Vorversicherer",...l("previousInsurer")})]})}),i.jsx(Z,{className:"mb-6",title:"Notizen",children:i.jsx("textarea",{...l("notes"),rows:4,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"Interne Notizen..."})}),i.jsxs("div",{className:"flex justify-end gap-4",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:()=>n(-1),children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:Ln,children:Ln?"Speichern...":"Speichern"})]})]}),i.jsx(j3,{isOpen:it,onClose:()=>Rt(!1)})]})}const N3={ELECTRICITY:_y,GAS:vC,DSL:Al,CABLE:Al,FIBER:Al,MOBILE:$y,TV:EC,CAR_INSURANCE:gC},w3={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabel",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ"},k3={critical:"bg-red-100 border-red-300 text-red-800",warning:"bg-yellow-100 border-yellow-300 text-yellow-800",ok:"bg-green-100 border-green-300 text-green-800",none:"bg-gray-100 border-gray-300 text-gray-800"},S3={critical:"danger",warning:"warning",ok:"success",none:"default"},C3={cancellation_deadline:pC,contract_ending:cs,missing_cancellation_letter:We,missing_cancellation_confirmation:We,missing_portal_credentials:E5,missing_customer_number:We,missing_provider:We,missing_address:We,missing_bank:We,missing_meter:_y,missing_sim:$y,open_tasks:_c,pending_status:cs,draft_status:We,review_due:wC,missing_invoice:Fy,missing_consents:hh,consent_withdrawn:CC},E3={cancellationDeadlines:"Kündigungsfristen",contractEnding:"Vertragsenden",missingCredentials:"Fehlende Zugangsdaten",missingData:"Fehlende Daten",openTasks:"Offene Aufgaben",pendingContracts:"Wartende Verträge",missingInvoices:"Fehlende Rechnungen",reviewDue:"Erneute Prüfung fällig",missingConsents:"Fehlende Einwilligungen"};function A3(){var w;const[t,e]=Sf(),[n,s]=N.useState(new Set),r=t.get("filter"),[a,l]=N.useState(r||"all");N.useEffect(()=>{a==="all"?t.delete("filter"):t.set("filter",a),e(t,{replace:!0})},[a,t,e]);const{data:o,isLoading:c,error:d}=fe({queryKey:["contract-cockpit"],queryFn:()=>He.getCockpit(),staleTime:0}),u=ye(),[h,m]=N.useState(null),[f,p]=N.useState(""),g=N.useRef(null);N.useEffect(()=>{const S=M=>{g.current&&!g.current.contains(M.target)&&(m(null),p(""))};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[]);const x=G({mutationFn:({contractId:S,data:M})=>He.snooze(S,M),onSuccess:()=>{u.invalidateQueries({queryKey:["contract-cockpit"]}),m(null),p("")}}),y=(S,M)=>{M?x.mutate({contractId:S,data:{months:M}}):f&&x.mutate({contractId:S,data:{nextReviewDate:f}})},v=S=>{x.mutate({contractId:S,data:{}})},b=S=>{s(M=>{const F=new Set(M);return F.has(S)?F.delete(S):F.add(S),F})},j=N.useMemo(()=>{var M;if(!((M=o==null?void 0:o.data)!=null&&M.contracts))return[];const S=o.data.contracts;switch(a){case"critical":return S.filter(F=>F.highestUrgency==="critical");case"warning":return S.filter(F=>F.highestUrgency==="warning");case"ok":return S.filter(F=>F.highestUrgency==="ok");case"deadlines":return S.filter(F=>F.issues.some(R=>["cancellation_deadline","contract_ending"].includes(R.type)));case"credentials":return S.filter(F=>F.issues.some(R=>R.type.includes("credentials")));case"data":return S.filter(F=>F.issues.some(R=>R.type.startsWith("missing_")&&!R.type.includes("credentials")));case"tasks":return S.filter(F=>F.issues.some(R=>["open_tasks","pending_status","draft_status"].includes(R.type)));case"review":return S.filter(F=>F.issues.some(R=>R.type==="review_due"));case"invoices":return S.filter(F=>F.issues.some(R=>R.type.includes("invoice")));case"consents":return S.filter(F=>F.issues.some(R=>["missing_consents","consent_withdrawn"].includes(R.type)));default:return S}},[(w=o==null?void 0:o.data)==null?void 0:w.contracts,a]);if(c)return i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx("div",{className:"text-gray-500",children:"Laden..."})});if(d||!(o!=null&&o.data))return i.jsx("div",{className:"text-center py-12",children:i.jsx("p",{className:"text-red-500",children:"Fehler beim Laden des Cockpits"})});const{summary:k,thresholds:E}=o.data,T=S=>{var R,V,D,z;const M=n.has(S.id),F=N3[S.type]||We;return i.jsxs("div",{className:`border rounded-lg mb-2 ${k3[S.highestUrgency]}`,children:[i.jsxs("div",{className:"flex items-center p-4 cursor-pointer hover:bg-opacity-50",onClick:()=>b(S.id),children:[i.jsx("div",{className:"w-6 mr-2",children:M?i.jsx(Us,{className:"w-5 h-5"}):i.jsx(At,{className:"w-5 h-5"})}),i.jsx(F,{className:"w-5 h-5 mr-3"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx(Me,{to:`/contracts/${S.id}`,state:{from:"cockpit",filter:a!=="all"?a:void 0},className:"font-medium hover:underline",onClick:C=>C.stopPropagation(),children:S.contractNumber}),i.jsxs(je,{variant:S3[S.highestUrgency],children:[S.issues.length," ",S.highestUrgency==="ok"?S.issues.length===1?"Hinweis":"Hinweise":S.issues.length===1?"Problem":"Probleme"]}),i.jsx("span",{className:"text-sm",children:w3[S.type]})]}),i.jsxs("div",{className:"text-sm mt-1",children:[i.jsxs(Me,{to:`/customers/${S.customer.id}`,className:"hover:underline",onClick:C=>C.stopPropagation(),children:[S.customer.customerNumber," - ",S.customer.name]}),(((R=S.provider)==null?void 0:R.name)||S.providerName)&&i.jsxs("span",{className:"ml-2",children:["| ",((V=S.provider)==null?void 0:V.name)||S.providerName,(((D=S.tariff)==null?void 0:D.name)||S.tariffName)&&` - ${((z=S.tariff)==null?void 0:z.name)||S.tariffName}`]})]})]}),i.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[i.jsxs("div",{className:"relative",ref:h===S.id?g:void 0,children:[i.jsx("button",{onClick:C=>{C.stopPropagation(),m(h===S.id?null:S.id),p("")},className:"p-2 hover:bg-white hover:bg-opacity-50 rounded",title:"Zurückstellen",children:i.jsx(mC,{className:"w-4 h-4"})}),h===S.id&&i.jsxs("div",{className:"absolute right-0 top-full mt-1 w-56 bg-white border rounded-lg shadow-lg z-50 p-3",onClick:C=>C.stopPropagation(),children:[i.jsx("div",{className:"text-sm font-medium mb-2",children:"Zurückstellen"}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("button",{onClick:()=>y(S.id,3),className:"w-full text-left px-3 py-2 text-sm hover:bg-gray-100 rounded",disabled:x.isPending,children:"+3 Monate"}),i.jsxs("button",{onClick:()=>y(S.id,6),className:"w-full text-left px-3 py-2 text-sm hover:bg-gray-100 rounded bg-blue-50 border-blue-200",disabled:x.isPending,children:["+6 Monate ",i.jsx("span",{className:"text-xs text-gray-500",children:"(Empfohlen)"})]}),i.jsx("button",{onClick:()=>y(S.id,12),className:"w-full text-left px-3 py-2 text-sm hover:bg-gray-100 rounded",disabled:x.isPending,children:"+12 Monate"})]}),i.jsxs("div",{className:"border-t mt-2 pt-2",children:[i.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Eigenes Datum:"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(q,{type:"date",value:f,onChange:C=>p(C.target.value),className:"flex-1 text-sm",min:new Date().toISOString().split("T")[0]}),i.jsx(I,{size:"sm",onClick:()=>y(S.id),disabled:!f||x.isPending,children:"OK"})]})]}),S.issues.some(C=>C.type==="review_due")&&i.jsx("div",{className:"border-t mt-2 pt-2",children:i.jsxs("button",{onClick:()=>v(S.id),className:"w-full text-left px-3 py-2 text-sm hover:bg-red-50 text-red-600 rounded flex items-center gap-2",disabled:x.isPending,children:[i.jsx(wC,{className:"w-4 h-4"}),"Snooze aufheben"]})})]})]}),i.jsx(Me,{to:`/contracts/${S.id}`,state:{from:"cockpit",filter:a!=="all"?a:void 0},className:"p-2 hover:bg-white hover:bg-opacity-50 rounded",onClick:C=>C.stopPropagation(),title:"Zum Vertrag",children:i.jsx(Oe,{className:"w-4 h-4"})})]})]}),M&&i.jsx("div",{className:"border-t px-4 py-3 bg-white bg-opacity-50",children:i.jsx("div",{className:"space-y-2",children:S.issues.map((C,_)=>{const K=C3[C.type]||Tr,B=C.urgency==="critical"?Tr:C.urgency==="warning"?Mn:C.urgency==="ok"?Un:cs;return i.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[i.jsx(B,{className:`w-4 h-4 mt-0.5 flex-shrink-0 ${C.urgency==="critical"?"text-red-500":C.urgency==="warning"?"text-yellow-500":C.urgency==="ok"?"text-green-500":"text-gray-500"}`}),i.jsx(K,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-gray-500"}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium",children:C.label}),C.details&&i.jsx("span",{className:"text-gray-600 ml-2",children:C.details})]})]},_)})})})]},S.id)};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Tr,{className:"w-6 h-6 text-red-500"}),i.jsx("h1",{className:"text-2xl font-bold",children:"Vertrags-Cockpit"})]}),i.jsx(Me,{to:"/settings/deadlines",className:"text-sm text-blue-600 hover:underline",children:"Fristenschwellen anpassen"})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[i.jsx(Z,{className:"!p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:i.jsx(Tr,{className:"w-6 h-6 text-red-500"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-2xl font-bold text-red-600",children:k.criticalCount}),i.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",E.criticalDays," Tage)"]})]})]})}),i.jsx(Z,{className:"!p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-yellow-100 rounded-lg",children:i.jsx(Mn,{className:"w-6 h-6 text-yellow-500"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:k.warningCount}),i.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",E.warningDays," Tage)"]})]})]})}),i.jsx(Z,{className:"!p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-green-100 rounded-lg",children:i.jsx(Un,{className:"w-6 h-6 text-green-500"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-2xl font-bold text-green-600",children:k.okCount}),i.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",E.okDays," Tage)"]})]})]})}),i.jsx(Z,{className:"!p-4",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 bg-gray-100 rounded-lg",children:i.jsx(We,{className:"w-6 h-6 text-gray-500"})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-2xl font-bold text-gray-600",children:k.totalContracts}),i.jsx("p",{className:"text-sm text-gray-500",children:"Verträge mit Handlungsbedarf"})]})]})})]}),i.jsx(Z,{className:"mb-6",children:i.jsx("div",{className:"flex flex-wrap gap-4",children:Object.entries(k.byCategory).map(([S,M])=>M>0&&i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsxs("span",{className:"font-medium",children:[E3[S]||S,":"]}),i.jsx(je,{variant:"default",children:M})]},S))})}),i.jsx(Z,{className:"mb-6",children:i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("span",{className:"text-sm text-gray-600",children:"Filter:"}),i.jsx(Fe,{value:a,onChange:S=>l(S.target.value),options:[{value:"all",label:`Alle (${o.data.contracts.length})`},{value:"critical",label:`Kritisch (${k.criticalCount})`},{value:"warning",label:`Warnung (${k.warningCount})`},{value:"ok",label:`OK (${k.okCount})`},{value:"deadlines",label:`Fristen (${k.byCategory.cancellationDeadlines+k.byCategory.contractEnding})`},{value:"credentials",label:`Zugangsdaten (${k.byCategory.missingCredentials})`},{value:"data",label:`Fehlende Daten (${k.byCategory.missingData})`},{value:"tasks",label:`Aufgaben/Status (${k.byCategory.openTasks+k.byCategory.pendingContracts})`},{value:"review",label:`Erneute Prüfung (${k.byCategory.reviewDue||0})`},{value:"invoices",label:`Fehlende Rechnungen (${k.byCategory.missingInvoices||0})`},{value:"consents",label:`Einwilligungen (${k.byCategory.missingConsents||0})`}],className:"w-64"}),i.jsxs("span",{className:"text-sm text-gray-500",children:[j.length," Verträge angezeigt"]})]})}),j.length===0?i.jsx(Z,{children:i.jsx("div",{className:"text-center py-8 text-gray-500",children:a==="all"?i.jsxs(i.Fragment,{children:[i.jsx(Un,{className:"w-12 h-12 mx-auto mb-4 text-green-500"}),i.jsx("p",{className:"text-lg font-medium",children:"Alles in Ordnung!"}),i.jsx("p",{children:"Keine Verträge mit Handlungsbedarf gefunden."})]}):i.jsx("p",{children:"Keine Verträge für diesen Filter gefunden."})})}):i.jsx("div",{children:j.map(T)})]})}const ej={OPEN:"Offen",COMPLETED:"Erledigt"},D3={OPEN:"warning",COMPLETED:"success"};function M3(){var K;const t=fn(),e=ye(),{isCustomerPortal:n,user:s,hasPermission:r}=nt(),[a,l]=N.useState("OPEN"),[o,c]=N.useState(new Set),[d,u]=N.useState(!1),[h,m]=N.useState({}),[f,p]=N.useState(null),g=n?"Support-Anfragen":"Aufgaben",x=n?"Anfrage":"Aufgabe",{data:y,isLoading:v}=fe({queryKey:["app-settings-public"],queryFn:()=>Ba.getPublic(),enabled:n,staleTime:0}),b=!v&&((K=y==null?void 0:y.data)==null?void 0:K.customerSupportTicketsEnabled)==="true",{data:j,isLoading:k}=fe({queryKey:["all-tasks",a],queryFn:()=>ht.getAll({status:a||void 0}),staleTime:0}),E=G({mutationFn:B=>ht.completeSubtask(B),onSuccess:()=>{e.invalidateQueries({queryKey:["all-tasks"]}),e.invalidateQueries({queryKey:["task-stats"]})}}),T=G({mutationFn:B=>ht.reopenSubtask(B),onSuccess:()=>{e.invalidateQueries({queryKey:["all-tasks"]}),e.invalidateQueries({queryKey:["task-stats"]})}}),w=G({mutationFn:({taskId:B,title:W})=>n?ht.createReply(B,W):ht.createSubtask(B,W),onSuccess:(B,{taskId:W})=>{e.invalidateQueries({queryKey:["all-tasks"]}),m(ce=>({...ce,[W]:""}))}}),S=G({mutationFn:B=>ht.delete(B),onSuccess:()=>{e.invalidateQueries({queryKey:["all-tasks"]}),e.invalidateQueries({queryKey:["task-stats"]})}}),M=G({mutationFn:({taskId:B,data:W})=>ht.update(B,W),onSuccess:()=>{e.invalidateQueries({queryKey:["all-tasks"]}),p(null)}}),F=N.useMemo(()=>{var he;if(!(j!=null&&j.data))return{ownTasks:[],representedTasks:[],allTasks:[]};const B=j.data;if(!n)return{allTasks:B,ownTasks:[],representedTasks:[]};const W=[],ce=[];for(const Je of B)((he=Je.contract)==null?void 0:he.customerId)===(s==null?void 0:s.customerId)?W.push(Je):ce.push(Je);return{ownTasks:W,representedTasks:ce,allTasks:[]}},[j==null?void 0:j.data,n,s==null?void 0:s.customerId]),R=B=>{c(W=>{const ce=new Set(W);return ce.has(B)?ce.delete(B):ce.add(B),ce})},V=B=>{E.isPending||T.isPending||(B.status==="COMPLETED"?T.mutate(B.id):E.mutate(B.id))},D=B=>{var ce;const W=(ce=h[B])==null?void 0:ce.trim();W&&w.mutate({taskId:B,title:W})},z=!n&&r("contracts:update"),C=(B,W=!1)=>{var it,Rt,J,Ke,ct,ee;const ce=o.has(B.id),he=B.subtasks&&B.subtasks.length>0,Je=((it=B.subtasks)==null?void 0:it.filter(pe=>pe.status==="COMPLETED").length)||0,et=((Rt=B.subtasks)==null?void 0:Rt.length)||0,mt=B.status==="COMPLETED",A=new Date(B.createdAt).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),pt=!n&&r("contracts:update"),On=!n&&r("contracts:update"),wn=B.contract?`${B.contract.contractNumber} - ${((J=B.contract.provider)==null?void 0:J.name)||B.contract.providerName||"Kein Anbieter"}`:`Vertrag #${B.contractId}`,le=(Ke=B.contract)!=null&&Ke.customer?B.contract.customer.companyName||`${B.contract.customer.firstName} ${B.contract.customer.lastName}`:"";return i.jsxs("div",{className:"border rounded-lg mb-2",children:[i.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50 cursor-pointer",onClick:()=>R(B.id),children:[i.jsx("div",{className:"w-6 mr-2",children:ce?i.jsx(Us,{className:"w-5 h-5 text-gray-400"}):i.jsx(At,{className:"w-5 h-5 text-gray-400"})}),i.jsx("div",{className:"mr-3",children:B.status==="COMPLETED"?i.jsx(Un,{className:"w-5 h-5 text-green-500"}):i.jsx(cs,{className:"w-5 h-5 text-yellow-500"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("span",{className:"font-medium",children:B.title}),i.jsx(je,{variant:D3[B.status],children:ej[B.status]}),he&&i.jsxs("span",{className:"text-xs text-gray-500",children:["(",Je,"/",et," erledigt)"]})]}),i.jsxs("div",{className:"text-sm text-gray-500 mt-1 flex items-center gap-2",children:[i.jsx(We,{className:"w-4 h-4"}),i.jsx(Me,{to:`/contracts/${B.contractId}`,className:"text-blue-600 hover:underline",onClick:pe=>pe.stopPropagation(),children:wn}),W&&le&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-gray-400",children:"|"}),i.jsx("span",{children:le})]})]}),B.description&&i.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:B.description}),i.jsxs("div",{className:"text-xs text-gray-400 mt-1",children:[B.createdBy," • ",A]})]}),i.jsxs("div",{className:"ml-4 flex gap-2",children:[pt&&i.jsx(I,{variant:"ghost",size:"sm",onClick:pe=>{pe.stopPropagation(),p(B)},title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),On&&i.jsx(I,{variant:"ghost",size:"sm",onClick:pe=>{pe.stopPropagation(),confirm("Aufgabe wirklich löschen?")&&S.mutate(B.id)},title:"Löschen",className:"text-red-500 hover:text-red-700",children:i.jsx(Ee,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:pe=>{pe.stopPropagation(),t(`/contracts/${B.contractId}`)},title:"Zum Vertrag",children:i.jsx(Oe,{className:"w-4 h-4"})})]})]}),ce&&i.jsxs("div",{className:"border-t bg-gray-50 px-4 py-3",children:[he&&i.jsx("div",{className:"space-y-2 mb-4",children:(ct=B.subtasks)==null?void 0:ct.map(pe=>{const Ln=new Date(pe.createdAt).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"});return i.jsxs("div",{className:`flex items-start gap-2 text-sm ml-6 ${z?"cursor-pointer hover:bg-gray-100 rounded px-2 py-1 -mx-2":""}`,onClick:z?()=>V(pe):void 0,children:[i.jsx("span",{className:"flex-shrink-0 mt-0.5",children:pe.status==="COMPLETED"?i.jsx(Un,{className:"w-4 h-4 text-green-500"}):i.jsx(Eu,{className:"w-4 h-4 text-gray-400"})}),i.jsxs("span",{className:pe.status==="COMPLETED"?"text-gray-500 line-through":"",children:[pe.title,i.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[pe.createdBy," • ",Ln]})]})]},pe.id)})}),!mt&&(z||n)&&i.jsxs("div",{className:"flex gap-2 ml-6",children:[i.jsx(q,{placeholder:n?"Antwort schreiben...":"Neue Unteraufgabe...",value:h[B.id]||"",onChange:pe=>m(Ln=>({...Ln,[B.id]:pe.target.value})),onKeyDown:pe=>{pe.key==="Enter"&&!pe.shiftKey&&(pe.preventDefault(),D(B.id))},className:"flex-1"}),i.jsx(I,{size:"sm",onClick:()=>D(B.id),disabled:!((ee=h[B.id])!=null&&ee.trim())||w.isPending,children:i.jsx(Nd,{className:"w-4 h-4"})})]}),!he&&mt&&i.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"Keine Unteraufgaben vorhanden."})]})]},B.id)},_=n?b:r("contracts:update");return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsx("h1",{className:"text-2xl font-bold",children:g}),_&&i.jsxs(I,{onClick:()=>u(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Neue ",x]})]}),i.jsx(Z,{className:"mb-6",children:i.jsx("div",{className:"flex gap-4 flex-wrap items-center",children:i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-gray-600",children:"Status:"}),i.jsx(Fe,{value:a,onChange:B=>l(B.target.value),options:[{value:"",label:"Alle"},...Object.entries(ej).map(([B,W])=>({value:B,label:W}))],className:"w-40"})]})})}),k?i.jsx(Z,{children:i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):i.jsx(i.Fragment,{children:n?i.jsxs("div",{className:"space-y-6",children:[i.jsxs(Z,{children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[i.jsx(yo,{className:"w-5 h-5 text-blue-600"}),i.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Meine ",g]}),i.jsx(je,{variant:"default",children:F.ownTasks.length})]}),F.ownTasks.length>0?i.jsx("div",{children:F.ownTasks.map(B=>C(B,!1))}):i.jsxs("p",{className:"text-gray-500 text-center py-4",children:["Keine eigenen ",g.toLowerCase()," vorhanden."]})]}),F.representedTasks.length>0&&i.jsxs(Z,{children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[i.jsx(Ca,{className:"w-5 h-5 text-purple-600"}),i.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:[g," freigegebener Kunden"]}),i.jsx(je,{variant:"default",children:F.representedTasks.length})]}),i.jsx("div",{children:F.representedTasks.map(B=>C(B,!0))})]})]}):i.jsx(Z,{children:F.allTasks&&F.allTasks.length>0?i.jsx("div",{children:F.allTasks.map(B=>C(B,!0))}):i.jsxs("div",{className:"text-center py-8 text-gray-500",children:["Keine ",g.toLowerCase()," gefunden."]})})}),n?i.jsx(T3,{isOpen:d,onClose:()=>u(!1)}):i.jsx(P3,{isOpen:d,onClose:()=>u(!1)}),f&&i.jsx(I3,{task:f,onClose:()=>p(null),onSave:B=>M.mutate({taskId:f.id,data:B}),isPending:M.isPending})]})}function T3({isOpen:t,onClose:e}){const{user:n}=nt(),s=fn(),r=ye(),[a,l]=N.useState("own"),[o,c]=N.useState(null),[d,u]=N.useState(""),[h,m]=N.useState(""),[f,p]=N.useState(!1),[g,x]=N.useState(""),{data:y}=fe({queryKey:["contracts",n==null?void 0:n.customerId],queryFn:()=>He.getAll({customerId:n==null?void 0:n.customerId}),enabled:t}),v=N.useMemo(()=>{if(!(y!=null&&y.data))return{own:[],represented:{}};const w=[],S={};for(const M of y.data)if(M.customerId===(n==null?void 0:n.customerId))w.push(M);else{if(!S[M.customerId]){const F=M.customer?M.customer.companyName||`${M.customer.firstName} ${M.customer.lastName}`:`Kunde ${M.customerId}`;S[M.customerId]={name:F,contracts:[]}}S[M.customerId].contracts.push(M)}return{own:w,represented:S}},[y==null?void 0:y.data,n==null?void 0:n.customerId]),b=Object.keys(v.represented).length>0,j=N.useMemo(()=>{var w;return a==="own"?v.own:((w=v.represented[a])==null?void 0:w.contracts)||[]},[a,v]),k=N.useMemo(()=>{if(!g)return j;const w=g.toLowerCase();return j.filter(S=>S.contractNumber.toLowerCase().includes(w)||(S.providerName||"").toLowerCase().includes(w)||(S.tariffName||"").toLowerCase().includes(w))},[j,g]),E=async()=>{if(!(!o||!d.trim())){p(!0);try{await ht.createSupportTicket(o,{title:d.trim(),description:h.trim()||void 0}),r.invalidateQueries({queryKey:["all-tasks"]}),r.invalidateQueries({queryKey:["task-stats"]}),e(),u(""),m(""),c(null),l("own"),s(`/contracts/${o}`)}catch(w){console.error("Fehler beim Erstellen der Support-Anfrage:",w),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{p(!1)}}},T=()=>{u(""),m(""),c(null),l("own"),x(""),e()};return i.jsx(Xe,{isOpen:t,onClose:T,title:"Neue Support-Anfrage",children:i.jsxs("div",{className:"space-y-4",children:[b&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),i.jsxs("select",{value:a,onChange:w=>{const S=w.target.value;l(S==="own"?"own":parseInt(S)),c(null),x("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[i.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(v.represented).map(([w,{name:S}])=>i.jsx("option",{value:w,children:S},w))]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),i.jsx(q,{placeholder:"Vertrag suchen...",value:g,onChange:w=>x(w.target.value),className:"mb-2"}),i.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(w=>i.jsxs("div",{onClick:()=>c(w.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===w.id?"bg-blue-50 border-blue-200":""}`,children:[i.jsx("div",{className:"font-medium",children:w.contractNumber}),i.jsxs("div",{className:"text-sm text-gray-500",children:[w.providerName||"Kein Anbieter",w.tariffName&&` - ${w.tariffName}`]})]},w.id)):i.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),i.jsx(q,{value:d,onChange:w=>u(w.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),i.jsx("textarea",{value:h,onChange:w=>m(w.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:4,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(I,{variant:"secondary",onClick:T,children:"Abbrechen"}),i.jsx(I,{onClick:E,disabled:!o||!d.trim()||f,children:f?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function P3({isOpen:t,onClose:e}){const n=fn(),s=ye(),[r,a]=N.useState(null),[l,o]=N.useState(null),[c,d]=N.useState(""),[u,h]=N.useState(""),[m,f]=N.useState(!1),[p,g]=N.useState(!1),[x,y]=N.useState(""),[v,b]=N.useState(""),{data:j}=fe({queryKey:["customers-for-task"],queryFn:()=>Zt.getAll({limit:100}),enabled:t}),{data:k}=fe({queryKey:["contracts-for-task",r],queryFn:()=>He.getAll({customerId:r}),enabled:t&&r!==null}),E=N.useMemo(()=>{if(!(j!=null&&j.data))return[];if(!x)return j.data;const F=x.toLowerCase();return j.data.filter(R=>R.customerNumber.toLowerCase().includes(F)||R.firstName.toLowerCase().includes(F)||R.lastName.toLowerCase().includes(F)||(R.companyName||"").toLowerCase().includes(F))},[j==null?void 0:j.data,x]),T=N.useMemo(()=>{if(!(k!=null&&k.data))return[];if(!v)return k.data;const F=v.toLowerCase();return k.data.filter(R=>R.contractNumber.toLowerCase().includes(F)||(R.providerName||"").toLowerCase().includes(F)||(R.tariffName||"").toLowerCase().includes(F))},[k==null?void 0:k.data,v]),w=async()=>{if(!(!l||!c.trim())){g(!0);try{await ht.create(l,{title:c.trim(),description:u.trim()||void 0,visibleInPortal:m}),s.invalidateQueries({queryKey:["all-tasks"]}),s.invalidateQueries({queryKey:["task-stats"]}),e(),d(""),h(""),f(!1),o(null),a(null),n(`/contracts/${l}`)}catch(F){console.error("Fehler beim Erstellen der Aufgabe:",F),alert("Fehler beim Erstellen der Aufgabe. Bitte versuchen Sie es erneut.")}finally{g(!1)}}},S=()=>{d(""),h(""),f(!1),o(null),a(null),y(""),b(""),e()},M=F=>{const R=F.companyName||`${F.firstName} ${F.lastName}`;return`${F.customerNumber} - ${R}`};return i.jsx(Xe,{isOpen:t,onClose:S,title:"Neue Aufgabe",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde *"}),i.jsx(q,{placeholder:"Kunde suchen...",value:x,onChange:F=>y(F.target.value),className:"mb-2"}),i.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:E.length>0?E.map(F=>i.jsx("div",{onClick:()=>{a(F.id),o(null),b("")},className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${r===F.id?"bg-blue-50 border-blue-200":""}`,children:i.jsx("div",{className:"font-medium",children:M(F)})},F.id)):i.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Kunden gefunden."})})]}),r&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),i.jsx(q,{placeholder:"Vertrag suchen...",value:v,onChange:F=>b(F.target.value),className:"mb-2"}),i.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:T.length>0?T.map(F=>i.jsxs("div",{onClick:()=>o(F.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${l===F.id?"bg-blue-50 border-blue-200":""}`,children:[i.jsx("div",{className:"font-medium",children:F.contractNumber}),i.jsxs("div",{className:"text-sm text-gray-500",children:[F.providerName||"Kein Anbieter",F.tariffName&&` - ${F.tariffName}`]})]},F.id)):i.jsx("div",{className:"p-3 text-gray-500 text-center",children:k?"Keine Verträge gefunden.":"Laden..."})})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),i.jsx(q,{value:c,onChange:F=>d(F.target.value),placeholder:"Aufgabentitel"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),i.jsx("textarea",{value:u,onChange:F=>h(F.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),i.jsx("div",{children:i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:m,onChange:F=>f(F.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),i.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]})}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(I,{variant:"secondary",onClick:S,children:"Abbrechen"}),i.jsx(I,{onClick:w,disabled:!l||!c.trim()||p,children:p?"Wird erstellt...":"Aufgabe erstellen"})]})]})})}function I3({task:t,onClose:e,onSave:n,isPending:s}){const[r,a]=N.useState(t.title),[l,o]=N.useState(t.description||""),[c,d]=N.useState(t.visibleInPortal||!1),u=()=>{r.trim()&&n({title:r.trim(),description:l.trim()||void 0,visibleInPortal:c})};return i.jsx(Xe,{isOpen:!0,onClose:e,title:"Aufgabe bearbeiten",children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),i.jsx(q,{value:r,onChange:h=>a(h.target.value),placeholder:"Aufgabentitel"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),i.jsx("textarea",{value:l,onChange:h=>o(h.target.value),placeholder:"Detaillierte Beschreibung (optional)",rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),i.jsx("div",{children:i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:c,onChange:h=>d(h.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),i.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]})}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(I,{variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{onClick:u,disabled:!r.trim()||s,children:s?"Wird gespeichert...":"Speichern"})]})]})})}function R3(){const[t,e]=N.useState(!1),[n,s]=N.useState(null),[r,a]=N.useState(!1),{hasPermission:l}=nt(),o=ye(),{data:c,isLoading:d}=fe({queryKey:["platforms",r],queryFn:()=>Fc.getAll(r)}),u=G({mutationFn:Fc.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["platforms"]})}}),h=f=>{s(f),e(!0)},m=()=>{e(!1),s(null)};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsx("h1",{className:"text-2xl font-bold",children:"Vertriebsplattformen"}),l("platforms:create")&&i.jsxs(I,{onClick:()=>e(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Neue Plattform"]})]}),i.jsxs(Z,{children:[i.jsx("div",{className:"mb-4",children:i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:r,onChange:f=>a(f.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),d?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kontakt"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),i.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),i.jsx("tbody",{children:c.data.map(f=>i.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[i.jsx("td",{className:"py-3 px-4 font-medium",children:f.name}),i.jsx("td",{className:"py-3 px-4 text-gray-500",children:f.contactInfo||"-"}),i.jsx("td",{className:"py-3 px-4",children:i.jsx(je,{variant:f.isActive?"success":"danger",children:f.isActive?"Aktiv":"Inaktiv"})}),i.jsx("td",{className:"py-3 px-4 text-right",children:i.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>h(f),children:i.jsx(rt,{className:"w-4 h-4"})}),l("platforms:delete")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Plattform wirklich löschen?")&&u.mutate(f.id)},children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})})]},f.id))})]})}):i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Plattformen vorhanden."})]}),i.jsx(O3,{isOpen:t,onClose:m,platform:n})]})}function O3({isOpen:t,onClose:e,platform:n}){const s=ye(),[r,a]=N.useState({name:"",contactInfo:"",isActive:!0});N.useState(()=>{a(n?{name:n.name,contactInfo:n.contactInfo||"",isActive:n.isActive}:{name:"",contactInfo:"",isActive:!0})}),n&&r.name!==n.name?a({name:n.name,contactInfo:n.contactInfo||"",isActive:n.isActive}):!n&&r.name;const l=G({mutationFn:Fc.create,onSuccess:()=>{s.invalidateQueries({queryKey:["platforms"]}),e(),a({name:"",contactInfo:"",isActive:!0})}}),o=G({mutationFn:u=>Fc.update(n.id,u),onSuccess:()=>{s.invalidateQueries({queryKey:["platforms"]}),e()}}),c=u=>{u.preventDefault(),n?o.mutate(r):l.mutate(r)},d=l.isPending||o.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:n?"Plattform bearbeiten":"Neue Plattform",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsx(q,{label:"Name *",value:r.name,onChange:u=>a({...r,name:u.target.value}),required:!0}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kontaktinformationen"}),i.jsx("textarea",{value:r.contactInfo,onChange:u=>a({...r,contactInfo:u.target.value}),rows:3,className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"E-Mail, Telefon, Ansprechpartner..."})]}),n&&i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:r.isActive,onChange:u=>a({...r,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function L3(){const[t,e]=N.useState(!1),[n,s]=N.useState(null),[r,a]=N.useState(!1),{hasPermission:l}=nt(),o=ye(),{data:c,isLoading:d}=fe({queryKey:["cancellation-periods",r],queryFn:()=>zc.getAll(r)}),u=G({mutationFn:zc.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["cancellation-periods"]})}}),h=f=>{s(f),e(!0)},m=()=>{e(!1),s(null)};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsx(Me,{to:"/settings",children:i.jsx(I,{variant:"ghost",size:"sm",children:i.jsx(Yn,{className:"w-4 h-4"})})}),i.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Kündigungsfristen"}),l("platforms:create")&&i.jsxs(I,{onClick:()=>e(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Neue Frist"]})]}),i.jsxs(Z,{children:[i.jsx("div",{className:"mb-4",children:i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:r,onChange:f=>a(f.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),i.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[i.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",i.jsx("br",{}),i.jsx("strong",{children:"Beispiele:"})," 14T = 14 Tage, 3M = 3 Monate, 1J = 1 Jahr"]}),d?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),i.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),i.jsx("tbody",{children:c.data.map(f=>i.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[i.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:f.code}),i.jsx("td",{className:"py-3 px-4",children:f.description}),i.jsx("td",{className:"py-3 px-4",children:i.jsx(je,{variant:f.isActive?"success":"danger",children:f.isActive?"Aktiv":"Inaktiv"})}),i.jsx("td",{className:"py-3 px-4 text-right",children:i.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>h(f),children:i.jsx(rt,{className:"w-4 h-4"})}),l("platforms:delete")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Kündigungsfrist wirklich löschen?")&&u.mutate(f.id)},children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})})]},f.id))})]})}):i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kündigungsfristen vorhanden."})]}),i.jsx(F3,{isOpen:t,onClose:m,period:n})]})}function F3({isOpen:t,onClose:e,period:n}){const s=ye(),[r,a]=N.useState({code:"",description:"",isActive:!0});N.useEffect(()=>{t&&a(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[t,n]);const l=G({mutationFn:zc.create,onSuccess:()=>{s.invalidateQueries({queryKey:["cancellation-periods"]}),e(),a({code:"",description:"",isActive:!0})}}),o=G({mutationFn:u=>zc.update(n.id,u),onSuccess:()=>{s.invalidateQueries({queryKey:["cancellation-periods"]}),e()}}),c=u=>{u.preventDefault(),n?o.mutate(r):l.mutate(r)},d=l.isPending||o.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:n?"Kündigungsfrist bearbeiten":"Neue Kündigungsfrist",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsx(q,{label:"Code *",value:r.code,onChange:u=>a({...r,code:u.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 14T, 3M, 1J"}),i.jsx(q,{label:"Beschreibung *",value:r.description,onChange:u=>a({...r,description:u.target.value}),required:!0,placeholder:"z.B. 14 Tage, 3 Monate, 1 Jahr"}),n&&i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:r.isActive,onChange:u=>a({...r,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function z3(){const[t,e]=N.useState(!1),[n,s]=N.useState(null),[r,a]=N.useState(!1),{hasPermission:l}=nt(),o=ye(),{data:c,isLoading:d}=fe({queryKey:["contract-durations",r],queryFn:()=>$c.getAll(r)}),u=G({mutationFn:$c.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-durations"]})}}),h=f=>{s(f),e(!0)},m=()=>{e(!1),s(null)};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsx(Me,{to:"/settings",children:i.jsx(I,{variant:"ghost",size:"sm",children:i.jsx(Yn,{className:"w-4 h-4"})})}),i.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragslaufzeiten"}),l("platforms:create")&&i.jsxs(I,{onClick:()=>e(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Neue Laufzeit"]})]}),i.jsxs(Z,{children:[i.jsx("div",{className:"mb-4",children:i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:r,onChange:f=>a(f.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),i.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[i.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",i.jsx("br",{}),i.jsx("strong",{children:"Beispiele:"})," 12M = 12 Monate, 24M = 24 Monate, 2J = 2 Jahre"]}),d?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),i.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),i.jsx("tbody",{children:c.data.map(f=>i.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[i.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:f.code}),i.jsx("td",{className:"py-3 px-4",children:f.description}),i.jsx("td",{className:"py-3 px-4",children:i.jsx(je,{variant:f.isActive?"success":"danger",children:f.isActive?"Aktiv":"Inaktiv"})}),i.jsx("td",{className:"py-3 px-4 text-right",children:i.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>h(f),children:i.jsx(rt,{className:"w-4 h-4"})}),l("platforms:delete")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Laufzeit wirklich löschen?")&&u.mutate(f.id)},children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})})]},f.id))})]})}):i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Laufzeiten vorhanden."})]}),i.jsx($3,{isOpen:t,onClose:m,duration:n})]})}function $3({isOpen:t,onClose:e,duration:n}){const s=ye(),[r,a]=N.useState({code:"",description:"",isActive:!0});N.useEffect(()=>{t&&a(n?{code:n.code,description:n.description,isActive:n.isActive}:{code:"",description:"",isActive:!0})},[t,n]);const l=G({mutationFn:$c.create,onSuccess:()=>{s.invalidateQueries({queryKey:["contract-durations"]}),e(),a({code:"",description:"",isActive:!0})}}),o=G({mutationFn:u=>$c.update(n.id,u),onSuccess:()=>{s.invalidateQueries({queryKey:["contract-durations"]}),e()}}),c=u=>{u.preventDefault(),n?o.mutate(r):l.mutate(r)},d=l.isPending||o.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:n?"Laufzeit bearbeiten":"Neue Laufzeit",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsx(q,{label:"Code *",value:r.code,onChange:u=>a({...r,code:u.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 12M, 24M, 2J"}),i.jsx(q,{label:"Beschreibung *",value:r.description,onChange:u=>a({...r,description:u.target.value}),required:!0,placeholder:"z.B. 12 Monate, 24 Monate, 2 Jahre"}),n&&i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:r.isActive,onChange:u=>a({...r,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function B3(){const[t,e]=N.useState(!1),[n,s]=N.useState(null),[r,a]=N.useState(!1),[l,o]=N.useState(new Set),{hasPermission:c}=nt(),d=ye(),{data:u,isLoading:h}=fe({queryKey:["providers",r],queryFn:()=>to.getAll(r)}),m=G({mutationFn:to.delete,onSuccess:()=>{d.invalidateQueries({queryKey:["providers"]})},onError:x=>{alert(x.message)}}),f=x=>{o(y=>{const v=new Set(y);return v.has(x)?v.delete(x):v.add(x),v})},p=x=>{s(x),e(!0)},g=()=>{e(!1),s(null)};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsx(Me,{to:"/settings",children:i.jsx(I,{variant:"ghost",size:"sm",children:i.jsx(Yn,{className:"w-4 h-4"})})}),i.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Anbieter & Tarife"}),c("providers:create")&&i.jsxs(I,{onClick:()=>e(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Neuer Anbieter"]})]}),i.jsxs(Z,{children:[i.jsx("div",{className:"mb-4",children:i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:r,onChange:x=>a(x.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),h?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):u!=null&&u.data&&u.data.length>0?i.jsx("div",{className:"space-y-2",children:u.data.map(x=>i.jsx(_3,{provider:x,isExpanded:l.has(x.id),onToggle:()=>f(x.id),onEdit:()=>p(x),onDelete:()=>{confirm("Anbieter wirklich löschen?")&&m.mutate(x.id)},hasPermission:c,showInactive:r},x.id))}):i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Anbieter vorhanden."})]}),i.jsx(V3,{isOpen:t,onClose:g,provider:n})]})}function _3({provider:t,isExpanded:e,onToggle:n,onEdit:s,onDelete:r,hasPermission:a,showInactive:l}){var p,g;const[o,c]=N.useState(!1),[d,u]=N.useState(null),h=ye(),m=G({mutationFn:oC.delete,onSuccess:()=>{h.invalidateQueries({queryKey:["providers"]})},onError:x=>{alert(x.message)}}),f=((p=t.tariffs)==null?void 0:p.filter(x=>l||x.isActive))||[];return i.jsxs("div",{className:"border rounded-lg",children:[i.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50",children:[i.jsx("button",{onClick:n,className:"mr-3 p-1 hover:bg-gray-200 rounded",children:e?i.jsx(Us,{className:"w-5 h-5 text-gray-400"}):i.jsx(At,{className:"w-5 h-5 text-gray-400"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("span",{className:"font-medium",children:t.name}),i.jsx(je,{variant:t.isActive?"success":"danger",children:t.isActive?"Aktiv":"Inaktiv"}),i.jsxs("span",{className:"text-sm text-gray-500",children:["(",f.length," Tarife, ",((g=t._count)==null?void 0:g.contracts)||0," Verträge)"]})]}),t.portalUrl&&i.jsxs("a",{href:t.portalUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:underline flex items-center gap-1 mt-1",children:[i.jsx(Oy,{className:"w-3 h-3"}),t.portalUrl]})]}),i.jsxs("div",{className:"flex gap-2 ml-4",children:[a("providers:update")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:s,title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),a("providers:delete")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:r,title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})]}),e&&i.jsxs("div",{className:"border-t bg-gray-50 p-4",children:[i.jsxs("div",{className:"flex justify-between items-center mb-3",children:[i.jsx("h4",{className:"font-medium text-gray-700",children:"Tarife"}),a("providers:create")&&i.jsxs(I,{size:"sm",onClick:()=>c(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-1"}),"Tarif hinzufügen"]})]}),f.length>0?i.jsx("div",{className:"space-y-2",children:f.map(x=>{var y;return i.jsxs("div",{className:"flex items-center justify-between bg-white p-3 rounded border",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{children:x.name}),i.jsx(je,{variant:x.isActive?"success":"danger",className:"text-xs",children:x.isActive?"Aktiv":"Inaktiv"}),((y=x._count)==null?void 0:y.contracts)!==void 0&&i.jsxs("span",{className:"text-xs text-gray-500",children:["(",x._count.contracts," Verträge)"]})]}),i.jsxs("div",{className:"flex gap-1",children:[a("providers:update")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{u(x),c(!0)},title:"Bearbeiten",children:i.jsx(rt,{className:"w-3 h-3"})}),a("providers:delete")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Tarif wirklich löschen?")&&m.mutate(x.id)},title:"Löschen",children:i.jsx(Ee,{className:"w-3 h-3 text-red-500"})})]})]},x.id)})}):i.jsx("p",{className:"text-sm text-gray-500",children:"Keine Tarife vorhanden."})]}),i.jsx(K3,{isOpen:o,onClose:()=>{c(!1),u(null)},providerId:t.id,tariff:d})]})}function V3({isOpen:t,onClose:e,provider:n}){const s=ye(),[r,a]=N.useState({name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0});N.useEffect(()=>{t&&a(n?{name:n.name,portalUrl:n.portalUrl||"",usernameFieldName:n.usernameFieldName||"",passwordFieldName:n.passwordFieldName||"",isActive:n.isActive}:{name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0})},[t,n]);const l=G({mutationFn:to.create,onSuccess:()=>{s.invalidateQueries({queryKey:["providers"]}),e()},onError:u=>{alert(u.message)}}),o=G({mutationFn:u=>to.update(n.id,u),onSuccess:()=>{s.invalidateQueries({queryKey:["providers"]}),e()},onError:u=>{alert(u.message)}}),c=u=>{u.preventDefault(),n?o.mutate(r):l.mutate(r)},d=l.isPending||o.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:n?"Anbieter bearbeiten":"Neuer Anbieter",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsx(q,{label:"Anbietername *",value:r.name,onChange:u=>a({...r,name:u.target.value}),required:!0,placeholder:"z.B. Vodafone, E.ON, Allianz"}),i.jsx(q,{label:"Portal-URL (Login-Seite)",value:r.portalUrl,onChange:u=>a({...r,portalUrl:u.target.value}),placeholder:"https://kundenportal.anbieter.de/login"}),i.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg space-y-3",children:[i.jsxs("p",{className:"text-sm text-gray-600",children:[i.jsx("strong",{children:"Auto-Login Felder"})," (optional)",i.jsx("br",{}),"Feldnamen für URL-Parameter beim Auto-Login:"]}),i.jsx(q,{label:"Benutzername-Feldname",value:r.usernameFieldName,onChange:u=>a({...r,usernameFieldName:u.target.value}),placeholder:"z.B. username, email, login"}),i.jsx(q,{label:"Passwort-Feldname",value:r.passwordFieldName,onChange:u=>a({...r,passwordFieldName:u.target.value}),placeholder:"z.B. password, pwd, kennwort"})]}),n&&i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:r.isActive,onChange:u=>a({...r,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}function K3({isOpen:t,onClose:e,providerId:n,tariff:s}){const r=ye(),[a,l]=N.useState({name:"",isActive:!0});N.useEffect(()=>{t&&l(s?{name:s.name,isActive:s.isActive}:{name:"",isActive:!0})},[t,s]);const o=G({mutationFn:h=>to.createTariff(n,h),onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),e()},onError:h=>{alert(h.message)}}),c=G({mutationFn:h=>oC.update(s.id,h),onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),e()},onError:h=>{alert(h.message)}}),d=h=>{h.preventDefault(),s?c.mutate(a):o.mutate(a)},u=o.isPending||c.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:s?"Tarif bearbeiten":"Neuer Tarif",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(q,{label:"Tarifname *",value:a.name,onChange:h=>l({...a,name:h.target.value}),required:!0,placeholder:"z.B. Comfort Plus, Basic 100"}),s&&i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:a.isActive,onChange:h=>l({...a,isActive:h.target.checked}),className:"rounded"}),"Aktiv"]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}const qg={Zap:i.jsx(_y,{className:"w-5 h-5"}),Flame:i.jsx(vC,{className:"w-5 h-5"}),Wifi:i.jsx(Al,{className:"w-5 h-5"}),Cable:i.jsx(g5,{className:"w-5 h-5"}),Network:i.jsx(L5,{className:"w-5 h-5"}),Smartphone:i.jsx($y,{className:"w-5 h-5"}),Tv:i.jsx(EC,{className:"w-5 h-5"}),Car:i.jsx(gC,{className:"w-5 h-5"}),FileText:i.jsx(We,{className:"w-5 h-5"})},U3=[{value:"Zap",label:"Blitz (Strom)"},{value:"Flame",label:"Flamme (Gas)"},{value:"Wifi",label:"WLAN (DSL)"},{value:"Cable",label:"Kabel"},{value:"Network",label:"Netzwerk (Glasfaser)"},{value:"Smartphone",label:"Smartphone (Mobilfunk)"},{value:"Tv",label:"TV"},{value:"Car",label:"Auto (KFZ)"},{value:"FileText",label:"Dokument (Sonstige)"}],q3=[{value:"#FFC107",label:"Gelb"},{value:"#FF5722",label:"Orange"},{value:"#2196F3",label:"Blau"},{value:"#9C27B0",label:"Lila"},{value:"#4CAF50",label:"Grün"},{value:"#E91E63",label:"Pink"},{value:"#607D8B",label:"Grau"},{value:"#795548",label:"Braun"},{value:"#00BCD4",label:"Cyan"},{value:"#F44336",label:"Rot"}];function H3(){const[t,e]=N.useState(!1),[n,s]=N.useState(null),[r,a]=N.useState(!1),{hasPermission:l}=nt(),o=ye(),{data:c,isLoading:d}=fe({queryKey:["contract-categories",r],queryFn:()=>Bc.getAll(r)}),u=G({mutationFn:Bc.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-categories"]})},onError:f=>{alert(f.message)}}),h=f=>{s(f),e(!0)},m=()=>{e(!1),s(null)};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsx(Me,{to:"/settings",children:i.jsx(I,{variant:"ghost",size:"sm",children:i.jsx(Yn,{className:"w-4 h-4"})})}),i.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragstypen"}),l("developer:access")&&i.jsxs(I,{onClick:()=>e(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Neuer Vertragstyp"]})]}),i.jsxs(Z,{children:[i.jsx("div",{className:"mb-4",children:i.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[i.jsx("input",{type:"checkbox",checked:r,onChange:f=>a(f.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),d?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?i.jsx("div",{className:"space-y-2",children:c.data.map(f=>{var p;return i.jsxs("div",{className:"flex items-center p-4 border rounded-lg hover:bg-gray-50",children:[i.jsx("div",{className:"mr-3 text-gray-400",children:i.jsx(j5,{className:"w-5 h-5"})}),i.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center mr-4",style:{backgroundColor:f.color||"#E5E7EB",color:"#fff"},children:f.icon&&qg[f.icon]?qg[f.icon]:i.jsx(We,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx("span",{className:"font-medium",children:f.name}),i.jsx(je,{variant:f.isActive?"success":"danger",children:f.isActive?"Aktiv":"Inaktiv"}),i.jsxs("span",{className:"text-sm text-gray-500",children:["(",((p=f._count)==null?void 0:p.contracts)||0," Verträge)"]})]}),i.jsxs("div",{className:"text-sm text-gray-500",children:["Code: ",i.jsx("span",{className:"font-mono",children:f.code})]})]}),i.jsxs("div",{className:"flex gap-2 ml-4",children:[l("developer:access")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>h(f),title:"Bearbeiten",children:i.jsx(rt,{className:"w-4 h-4"})}),l("developer:access")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertragstyp wirklich löschen?")&&u.mutate(f.id)},title:"Löschen",children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})]},f.id)})}):i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Vertragstypen vorhanden."})]}),i.jsx(W3,{isOpen:t,onClose:m,category:n})]})}function W3({isOpen:t,onClose:e,category:n}){const s=ye(),[r,a]=N.useState({code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0});N.useEffect(()=>{t&&a(n?{code:n.code,name:n.name,icon:n.icon||"FileText",color:n.color||"#607D8B",sortOrder:n.sortOrder,isActive:n.isActive}:{code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0})},[t,n]);const l=G({mutationFn:Bc.create,onSuccess:()=>{s.invalidateQueries({queryKey:["contract-categories"]}),e()},onError:u=>{alert(u.message)}}),o=G({mutationFn:u=>Bc.update(n.id,u),onSuccess:()=>{s.invalidateQueries({queryKey:["contract-categories"]}),e()},onError:u=>{alert(u.message)}}),c=u=>{u.preventDefault(),n?o.mutate(r):l.mutate(r)},d=l.isPending||o.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:n?"Vertragstyp bearbeiten":"Neuer Vertragstyp",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsx(q,{label:"Code (technisch) *",value:r.code,onChange:u=>a({...r,code:u.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")}),required:!0,placeholder:"z.B. ELECTRICITY, MOBILE_BUSINESS",disabled:!!n}),i.jsx(q,{label:"Anzeigename *",value:r.name,onChange:u=>a({...r,name:u.target.value}),required:!0,placeholder:"z.B. Strom, Mobilfunk Business"}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Icon"}),i.jsx("div",{className:"grid grid-cols-4 gap-2",children:U3.map(u=>i.jsxs("button",{type:"button",onClick:()=>a({...r,icon:u.value}),className:`p-3 border rounded-lg flex flex-col items-center gap-1 text-xs ${r.icon===u.value?"border-blue-500 bg-blue-50":"border-gray-200 hover:bg-gray-50"}`,children:[qg[u.value],i.jsx("span",{className:"truncate w-full text-center",children:u.label.split(" ")[0]})]},u.value))})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Farbe"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:q3.map(u=>i.jsx("button",{type:"button",onClick:()=>a({...r,color:u.value}),className:`w-8 h-8 rounded-full border-2 ${r.color===u.value?"border-gray-800 ring-2 ring-offset-2 ring-gray-400":"border-transparent"}`,style:{backgroundColor:u.value},title:u.label},u.value))})]}),i.jsx(q,{label:"Sortierung",type:"number",value:r.sortOrder,onChange:u=>a({...r,sortOrder:parseInt(u.target.value)||0}),placeholder:"0"}),n&&i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:r.isActive,onChange:u=>a({...r,isActive:u.target.checked}),className:"rounded"}),"Aktiv"]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}const Q3=[{value:"0.1",label:"10%"},{value:"0.2",label:"20%"},{value:"0.3",label:"30%"},{value:"0.4",label:"40%"},{value:"0.5",label:"50%"},{value:"0.6",label:"60%"},{value:"0.7",label:"70% (Standard)"},{value:"0.8",label:"80%"},{value:"0.9",label:"90%"},{value:"999",label:"Deaktiviert"}];function G3(){const{settings:t,updateSettings:e}=uC();return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsx(Me,{to:"/settings",className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:i.jsx(Yn,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Oe,{className:"w-6 h-6"}),i.jsx("h1",{className:"text-2xl font-bold",children:"Ansicht"})]})]}),i.jsx(Z,{title:"Scroll-Verhalten",children:i.jsx("div",{className:"space-y-6",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("p",{className:"font-medium",children:"Nach-oben-Button"}),i.jsx("p",{className:"text-sm text-gray-500",children:"Ab welcher Scroll-Position der Button unten rechts erscheinen soll"})]}),i.jsx("div",{className:"w-48",children:i.jsx(Fe,{options:Q3,value:t.scrollToTopThreshold.toString(),onChange:n=>e({scrollToTopThreshold:parseFloat(n.target.value)})})})]})})})]})}function J3(){const t=ye(),{data:e,isLoading:n}=fe({queryKey:["app-settings"],queryFn:()=>Ba.getAll()}),[s,r]=N.useState(!1);N.useEffect(()=>{e!=null&&e.data&&r(e.data.customerSupportTicketsEnabled==="true")},[e]);const a=G({mutationFn:o=>Ba.update(o),onSuccess:()=>{t.invalidateQueries({queryKey:["app-settings"]}),t.invalidateQueries({queryKey:["app-settings-public"]})}}),l=o=>{r(o),a.mutate({customerSupportTicketsEnabled:o?"true":"false"})};return n?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx("div",{className:"text-gray-500",children:"Laden..."})}):i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsx(Me,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:i.jsx(Yn,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ly,{className:"w-6 h-6"}),i.jsx("h1",{className:"text-2xl font-bold",children:"Kundenportal"})]})]}),i.jsxs(Z,{title:"Support-Anfragen",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Vc,{className:"w-5 h-5 text-gray-500"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium",children:"Kunden können Support-Anfragen erstellen"}),i.jsx("p",{className:"text-sm text-gray-500",children:"Wenn aktiviert, können Kunden im Portal Support-Anfragen zu ihren Verträgen erstellen. Diese erscheinen als Aufgaben in der Vertragsdetailansicht."})]})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:s,onChange:o=>l(o.target.checked),disabled:a.isPending,className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"})]})]}),s&&i.jsx("div",{className:"mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:i.jsxs("p",{className:"text-sm text-blue-800",children:[i.jsx("strong",{children:"Hinweis:"}),' Kunden sehen diese Anfragen als "Support-Anfragen" in ihrem Portal. Sie können die Anfrage mit einem Titel und einer Beschreibung erstellen. Ihre Mitarbeiter können dann mit Antworten (Unteraufgaben) reagieren.']})})]})]})}function Z3(){const t=ye(),{data:e,isLoading:n}=fe({queryKey:["app-settings"],queryFn:()=>Ba.getAll()}),[s,r]=N.useState("14"),[a,l]=N.useState("42"),[o,c]=N.useState("90"),[d,u]=N.useState(!1);N.useEffect(()=>{e!=null&&e.data&&(r(e.data.deadlineCriticalDays||"14"),l(e.data.deadlineWarningDays||"42"),c(e.data.deadlineOkDays||"90"),u(!1))},[e]);const h=G({mutationFn:p=>Ba.update(p),onSuccess:()=>{t.invalidateQueries({queryKey:["app-settings"]}),t.invalidateQueries({queryKey:["contract-cockpit"]}),u(!1)}}),m=()=>{const p=parseInt(s),g=parseInt(a),x=parseInt(o);if(isNaN(p)||isNaN(g)||isNaN(x)){alert("Bitte gültige Zahlen eingeben");return}if(p>=g||g>=x){alert("Die Werte müssen aufsteigend sein: Kritisch < Warnung < OK");return}h.mutate({deadlineCriticalDays:s,deadlineWarningDays:a,deadlineOkDays:o})},f=(p,g)=>{p(g),u(!0)};return n?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx("div",{className:"text-gray-500",children:"Laden..."})}):i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsx(Me,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:i.jsx(Yn,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(cs,{className:"w-6 h-6"}),i.jsx("h1",{className:"text-2xl font-bold",children:"Fristenschwellen"})]})]}),i.jsxs(Z,{title:"Farbkodierung für Fristen",children:[i.jsx("p",{className:"text-gray-600 mb-6",children:"Definiere, ab wann Vertragsfristen als kritisch (rot), Warnung (gelb) oder OK (grün) angezeigt werden sollen. Die Werte geben die Anzahl der Tage bis zur Frist an."}),i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center gap-4 p-4 bg-red-50 border border-red-200 rounded-lg",children:[i.jsx(Tr,{className:"w-8 h-8 text-red-500 flex-shrink-0"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"block font-medium text-red-800 mb-1",children:"Kritisch (Rot)"}),i.jsx("p",{className:"text-sm text-red-600 mb-2",children:"Fristen mit weniger als X Tagen werden rot markiert"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(q,{type:"number",min:"1",value:s,onChange:p=>f(r,p.target.value),className:"w-24"}),i.jsx("span",{className:"text-red-700",children:"Tage"})]})]})]}),i.jsxs("div",{className:"flex items-center gap-4 p-4 bg-yellow-50 border border-yellow-200 rounded-lg",children:[i.jsx(Mn,{className:"w-8 h-8 text-yellow-500 flex-shrink-0"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"block font-medium text-yellow-800 mb-1",children:"Warnung (Gelb)"}),i.jsx("p",{className:"text-sm text-yellow-600 mb-2",children:"Fristen mit weniger als X Tagen werden gelb markiert"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(q,{type:"number",min:"1",value:a,onChange:p=>f(l,p.target.value),className:"w-24"}),i.jsx("span",{className:"text-yellow-700",children:"Tage"})]})]})]}),i.jsxs("div",{className:"flex items-center gap-4 p-4 bg-green-50 border border-green-200 rounded-lg",children:[i.jsx(Un,{className:"w-8 h-8 text-green-500 flex-shrink-0"}),i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"block font-medium text-green-800 mb-1",children:"OK (Grün)"}),i.jsx("p",{className:"text-sm text-green-600 mb-2",children:"Fristen mit weniger als X Tagen werden grün markiert (darüber nicht angezeigt)"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(q,{type:"number",min:"1",value:o,onChange:p=>f(c,p.target.value),className:"w-24"}),i.jsx("span",{className:"text-green-700",children:"Tage"})]})]})]})]}),i.jsxs("div",{className:"mt-6 pt-4 border-t flex justify-between items-center",children:[i.jsx("p",{className:"text-sm text-gray-500",children:"Beispiel: Bei 14/42/90 Tagen wird eine Frist die in 10 Tagen abläuft rot, eine in 30 Tagen gelb, und eine in 60 Tagen grün markiert."}),i.jsx(I,{onClick:m,disabled:!d||h.isPending,children:h.isPending?"Speichere...":"Speichern"})]})]})]})}const Y3=[{value:"PLESK",label:"Plesk"},{value:"CPANEL",label:"cPanel"},{value:"DIRECTADMIN",label:"DirectAdmin"}],tj=[{value:"SSL",label:"SSL/TLS",description:"Verschlüsselung von Anfang an"},{value:"STARTTLS",label:"STARTTLS",description:"Startet unverschlüsselt, dann Upgrade"},{value:"NONE",label:"Keine",description:"Keine Verschlüsselung"}],Bm={name:"",type:"PLESK",apiUrl:"",apiKey:"",username:"",password:"",domain:"stressfrei-wechseln.de",defaultForwardEmail:"",imapEncryption:"SSL",smtpEncryption:"SSL",allowSelfSignedCerts:!1,isActive:!0,isDefault:!1};function X3(){const t=fn(),e=ye(),[n,s]=N.useState(!1),[r,a]=N.useState(null),[l,o]=N.useState(Bm),[c,d]=N.useState(!1),[u,h]=N.useState(null),[m,f]=N.useState(!1),[p,g]=N.useState({}),[x,y]=N.useState(null),{data:v,isLoading:b}=fe({queryKey:["email-provider-configs"],queryFn:()=>wr.getConfigs()}),j=G({mutationFn:C=>wr.createConfig(C),onSuccess:()=>{e.invalidateQueries({queryKey:["email-provider-configs"]}),M()}}),k=G({mutationFn:({id:C,data:_})=>wr.updateConfig(C,_),onSuccess:()=>{e.invalidateQueries({queryKey:["email-provider-configs"]}),M()}}),E=G({mutationFn:C=>wr.deleteConfig(C),onSuccess:()=>{e.invalidateQueries({queryKey:["email-provider-configs"]})}}),T=(v==null?void 0:v.data)||[],w=()=>{o(Bm),a(null),d(!1),h(null),s(!0)},S=C=>{o({name:C.name,type:C.type,apiUrl:C.apiUrl,apiKey:C.apiKey||"",username:C.username||"",password:"",domain:C.domain,defaultForwardEmail:C.defaultForwardEmail||"",imapEncryption:C.imapEncryption??"SSL",smtpEncryption:C.smtpEncryption??"SSL",allowSelfSignedCerts:C.allowSelfSignedCerts??!1,isActive:C.isActive,isDefault:C.isDefault}),a(C.id),d(!1),h(null),s(!0)},M=()=>{s(!1),a(null),o(Bm),d(!1),h(null)},F=async C=>{var _,K,B;y(C.id),g(W=>({...W,[C.id]:null}));try{const W=await wr.testConnection({id:C.id}),ce={success:((_=W.data)==null?void 0:_.success)||!1,message:(K=W.data)==null?void 0:K.message,error:(B=W.data)==null?void 0:B.error};g(he=>({...he,[C.id]:ce}))}catch(W){g(ce=>({...ce,[C.id]:{success:!1,error:W instanceof Error?W.message:"Unbekannter Fehler beim Testen"}}))}finally{y(null)}},R=async()=>{var C,_,K;if(!l.apiUrl||!l.domain){h({success:!1,error:"Bitte geben Sie API-URL und Domain ein."});return}f(!0),h(null);try{const B=await wr.testConnection({testData:{type:l.type,apiUrl:l.apiUrl,apiKey:l.apiKey||void 0,username:l.username||void 0,password:l.password||void 0,domain:l.domain}});h({success:((C=B.data)==null?void 0:C.success)||!1,message:(_=B.data)==null?void 0:_.message,error:(K=B.data)==null?void 0:K.error})}catch(B){h({success:!1,error:B instanceof Error?B.message:"Unbekannter Fehler beim Verbindungstest"})}finally{f(!1)}},V=C=>{C.preventDefault();const _={name:l.name,type:l.type,apiUrl:l.apiUrl,apiKey:l.apiKey,username:l.username,domain:l.domain,defaultForwardEmail:l.defaultForwardEmail,imapEncryption:l.imapEncryption,smtpEncryption:l.smtpEncryption,allowSelfSignedCerts:l.allowSelfSignedCerts,isActive:l.isActive,isDefault:l.isDefault};l.password&&(_.password=l.password),r?k.mutate({id:r,data:_}):j.mutate(_)},D=(C,_)=>{confirm(`Möchten Sie den Provider "${_}" wirklich löschen?`)&&E.mutate(C)},z=C=>C.error?C.error:C.message?C.message:"Verbindung fehlgeschlagen";return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsxs(I,{variant:"ghost",onClick:()=>t("/settings"),children:[i.jsx(Yn,{className:"w-4 h-4 mr-2"}),"Zurück"]}),i.jsx("h1",{className:"text-2xl font-bold",children:"Email-Provisionierung"})]}),i.jsxs(Z,{className:"mb-6",children:[i.jsx("p",{className:"text-gray-600 mb-4",children:'Hier konfigurieren Sie die automatische Erstellung von Stressfrei-Wechseln E-Mail-Adressen. Wenn beim Anlegen einer Stressfrei-Adresse die Option "Bei Provider anlegen" aktiviert ist, wird die E-Mail-Weiterleitung automatisch erstellt.'}),i.jsxs(I,{onClick:w,children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Provider hinzufügen"]})]}),b?i.jsx("div",{className:"text-center py-8",children:"Laden..."}):T.length===0?i.jsx(Z,{children:i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Noch keine Email-Provider konfiguriert."})}):i.jsx("div",{className:"space-y-4",children:T.map(C=>{const _=p[C.id],K=x===C.id;return i.jsx(Z,{children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h3",{className:"font-semibold text-lg",children:C.name}),i.jsx("span",{className:"px-2 py-1 text-xs rounded bg-blue-100 text-blue-800",children:C.type}),C.isDefault&&i.jsx("span",{className:"px-2 py-1 text-xs rounded bg-green-100 text-green-800",children:"Standard"}),!C.isActive&&i.jsx("span",{className:"px-2 py-1 text-xs rounded bg-gray-100 text-gray-600",children:"Inaktiv"})]}),i.jsxs("dl",{className:"mt-3 grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"API-URL"}),i.jsx("dd",{className:"font-mono text-xs truncate",children:C.apiUrl})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"Domain"}),i.jsx("dd",{children:C.domain})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"Benutzer"}),i.jsx("dd",{children:C.username||"-"})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-gray-500",children:"Standard-Weiterleitung"}),i.jsx("dd",{className:"truncate",children:C.defaultForwardEmail||"-"})]})]}),_&&i.jsx("div",{className:`mt-3 p-3 rounded-lg text-sm ${_.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:_.success?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Vr,{className:"w-4 h-4 flex-shrink-0"}),i.jsx("span",{children:"Verbindung erfolgreich!"})]}):i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(A1,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),i.jsx("span",{children:z(_)})]})})]}),i.jsxs("div",{className:"flex gap-2 ml-4",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>F(C),disabled:K,title:"Verbindung testen",children:K?i.jsx("span",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}):i.jsx(Al,{className:"w-4 h-4 text-blue-500"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>S(C),children:i.jsx(rt,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>D(C.id,C.name),children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})]})},C.id)})}),n&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:i.jsxs("div",{className:"p-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h2",{className:"text-xl font-semibold",children:r?"Provider bearbeiten":"Neuer Provider"}),i.jsx("button",{onClick:M,className:"text-gray-400 hover:text-gray-600",children:i.jsx(nn,{className:"w-5 h-5"})})]}),(j.error||k.error)&&i.jsx("div",{className:"mb-4 p-3 rounded-lg bg-red-50 text-red-800 text-sm",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(nn,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),i.jsx("span",{children:j.error instanceof Error?j.error.message:k.error instanceof Error?k.error.message:"Fehler beim Speichern"})]})}),i.jsxs("form",{onSubmit:V,className:"space-y-4",children:[i.jsx(q,{label:"Name *",value:l.name,onChange:C=>o({...l,name:C.target.value}),placeholder:"z.B. Plesk Hauptserver",required:!0}),i.jsx(Fe,{label:"Provider-Typ *",value:l.type,onChange:C=>o({...l,type:C.target.value}),options:Y3}),i.jsx(q,{label:"API-URL *",value:l.apiUrl,onChange:C=>o({...l,apiUrl:C.target.value}),placeholder:"https://server.de:8443",required:!0}),i.jsx(q,{label:"API-Key",value:l.apiKey,onChange:C=>o({...l,apiKey:C.target.value}),placeholder:"Optional - alternativ zu Benutzername/Passwort"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(q,{label:"Benutzername",value:l.username,onChange:C=>o({...l,username:C.target.value}),placeholder:"admin"}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:r?"Neues Passwort (leer = beibehalten)":"Passwort"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{type:c?"text":"password",value:l.password,onChange:C=>o({...l,password:C.target.value}),className:"block w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),i.jsx("button",{type:"button",onClick:()=>d(!c),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:c?i.jsx(on,{className:"w-4 h-4"}):i.jsx(Oe,{className:"w-4 h-4"})})]})]})]}),i.jsx(q,{label:"Domain *",value:l.domain,onChange:C=>o({...l,domain:C.target.value}),placeholder:"stressfrei-wechseln.de",required:!0}),i.jsx(q,{label:"Standard-Weiterleitungsadresse",value:l.defaultForwardEmail,onChange:C=>o({...l,defaultForwardEmail:C.target.value}),placeholder:"info@meinefirma.de",type:"email"}),i.jsx("p",{className:"text-xs text-gray-500 -mt-2",children:"Diese E-Mail-Adresse wird zusätzlich zur Kunden-E-Mail als Weiterleitungsziel hinzugefügt."}),i.jsxs("div",{className:"pt-4 border-t",children:[i.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"E-Mail-Verbindungseinstellungen"}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["IMAP Verschlüsselung",i.jsxs("span",{className:"text-gray-400 font-normal ml-1",children:["(Port ",l.imapEncryption==="SSL"?"993":"143",")"]})]}),i.jsx("select",{value:l.imapEncryption,onChange:C=>o({...l,imapEncryption:C.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:tj.map(C=>i.jsxs("option",{value:C.value,children:[C.label," - ",C.description]},C.value))})]}),i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["SMTP Verschlüsselung",i.jsxs("span",{className:"text-gray-400 font-normal ml-1",children:["(Port ",l.smtpEncryption==="SSL"?"465":l.smtpEncryption==="STARTTLS"?"587":"25",")"]})]}),i.jsx("select",{value:l.smtpEncryption,onChange:C=>o({...l,smtpEncryption:C.target.value}),className:"block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm",children:tj.map(C=>i.jsxs("option",{value:C.value,children:[C.label," - ",C.description]},C.value))})]})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:l.allowSelfSignedCerts,onChange:C=>o({...l,allowSelfSignedCerts:C.target.checked}),className:"rounded border-gray-300"}),i.jsx("span",{className:"text-sm",children:"Selbstsignierte Zertifikate erlauben"})]}),i.jsx("p",{className:"text-xs text-gray-500",children:"Aktivieren Sie diese Option für Testumgebungen mit selbstsignierten SSL-Zertifikaten."})]})]}),i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:l.isActive,onChange:C=>o({...l,isActive:C.target.checked}),className:"rounded border-gray-300"}),i.jsx("span",{className:"text-sm",children:"Aktiv"})]}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:l.isDefault,onChange:C=>o({...l,isDefault:C.target.checked}),className:"rounded border-gray-300"}),i.jsx("span",{className:"text-sm",children:"Als Standard verwenden"})]})]}),i.jsxs("div",{className:"pt-4 border-t",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:R,disabled:m,className:"w-full",children:m?"Teste Verbindung...":i.jsxs(i.Fragment,{children:[i.jsx(Al,{className:"w-4 h-4 mr-2"}),"Verbindung testen"]})}),u&&i.jsx("div",{className:`mt-2 p-3 rounded-lg text-sm ${u.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:u.success?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Vr,{className:"w-4 h-4 flex-shrink-0"}),i.jsx("span",{children:"Verbindung erfolgreich!"})]}):i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(A1,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),i.jsx("span",{children:z(u)})]})})]}),i.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:M,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:j.isPending||k.isPending,children:j.isPending||k.isPending?"Speichern...":"Speichern"})]})]})]})})})]})}function eO(){const[t,e]=N.useState(null),[n,s]=N.useState(null),[r,a]=N.useState(!1),[l,o]=N.useState(""),[c,d]=N.useState(null),u=N.useRef(null),h=ye(),{logout:m}=nt(),{data:f,isLoading:p}=fe({queryKey:["backups"],queryFn:()=>Zi.list()}),g=(f==null?void 0:f.data)||[],x=G({mutationFn:()=>Zi.create(),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]})}}),y=G({mutationFn:S=>Zi.restore(S),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),e(null)}}),v=G({mutationFn:S=>Zi.delete(S),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),s(null)}}),b=G({mutationFn:S=>Zi.upload(S),onSuccess:()=>{h.invalidateQueries({queryKey:["backups"]}),d(null),u.current&&(u.current.value="")},onError:S=>{d(S.message||"Upload fehlgeschlagen")}}),j=G({mutationFn:()=>Zi.factoryReset(),onSuccess:()=>{a(!1),o(""),m()}}),k=S=>{var F;const M=(F=S.target.files)==null?void 0:F[0];if(M){if(!M.name.endsWith(".zip")){d("Nur ZIP-Dateien sind erlaubt");return}d(null),b.mutate(M)}},E=async S=>{const M=localStorage.getItem("token"),F=Zi.getDownloadUrl(S);try{const R=await fetch(F,{headers:{Authorization:`Bearer ${M}`}});if(!R.ok)throw new Error("Download fehlgeschlagen");const V=await R.blob(),D=window.URL.createObjectURL(V),z=document.createElement("a");z.href=D,z.download=`opencrm-backup-${S}.zip`,document.body.appendChild(z),z.click(),document.body.removeChild(z),window.URL.revokeObjectURL(D)}catch(R){console.error("Download error:",R)}},T=S=>new Date(S).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),w=S=>S<1024?`${S} B`:S<1024*1024?`${(S/1024).toFixed(1)} KB`:`${(S/(1024*1024)).toFixed(1)} MB`;return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsxs("h2",{className:"text-lg font-semibold text-gray-900 flex items-center gap-2",children:[i.jsx(Rf,{className:"w-5 h-5"}),"Datenbank & Zurücksetzen"]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Backups erstellen, wiederherstellen oder auf Werkseinstellungen zurücksetzen."})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"file",ref:u,accept:".zip",onChange:k,className:"hidden"}),i.jsx(I,{variant:"secondary",onClick:()=>{var S;return(S=u.current)==null?void 0:S.click()},disabled:b.isPending,children:b.isPending?i.jsxs(i.Fragment,{children:[i.jsx(ai,{className:"w-4 h-4 mr-2 animate-spin"}),"Hochladen..."]}):i.jsxs(i.Fragment,{children:[i.jsx(_g,{className:"w-4 h-4 mr-2"}),"Backup hochladen"]})}),i.jsx(I,{onClick:()=>x.mutate(),disabled:x.isPending,children:x.isPending?i.jsxs(i.Fragment,{children:[i.jsx(ai,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird erstellt..."]}):i.jsxs(i.Fragment,{children:[i.jsx(qn,{className:"w-4 h-4 mr-2"}),"Neues Backup"]})})]})]}),c&&i.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4 text-red-700",children:c}),i.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[i.jsx("h4",{className:"text-sm font-medium text-blue-800 mb-2",children:"Hinweise zur Datensicherung"}),i.jsxs("ul",{className:"text-sm text-blue-700 space-y-1 list-disc list-inside",children:[i.jsx("li",{children:"Backups enthalten alle Datenbankdaten und hochgeladene Dokumente"}),i.jsx("li",{children:"Erstellen Sie vor Datenbankmigrationen immer ein Backup"}),i.jsx("li",{children:"Backups können als ZIP heruntergeladen und auf einem anderen System wiederhergestellt werden"}),i.jsx("li",{children:"Bei der Wiederherstellung werden bestehende Daten mit dem Backup-Stand überschrieben"})]})]}),i.jsxs("div",{className:"bg-white rounded-lg border border-gray-200 overflow-hidden",children:[i.jsx("div",{className:"px-4 py-3 bg-gray-50 border-b border-gray-200",children:i.jsx("h3",{className:"text-sm font-medium text-gray-700",children:"Verfügbare Backups"})}),p?i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx(ai,{className:"w-6 h-6 animate-spin text-gray-400"})}):g.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[i.jsx(S1,{className:"w-12 h-12 mb-2 opacity-30"}),i.jsx("p",{children:"Keine Backups vorhanden"}),i.jsx("p",{className:"text-sm mt-1",children:"Erstellen Sie Ihr erstes Backup"})]}):i.jsx("div",{className:"divide-y divide-gray-200",children:g.map(S=>i.jsx("div",{className:"p-4 hover:bg-gray-50",children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[i.jsx("span",{className:"font-mono text-sm bg-gray-100 px-2 py-1 rounded",children:S.name}),i.jsxs("span",{className:"text-sm text-gray-500 flex items-center gap-1",children:[i.jsx(cs,{className:"w-4 h-4"}),T(S.timestamp)]})]}),i.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(We,{className:"w-4 h-4"}),S.totalRecords.toLocaleString("de-DE")," Datensätze"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(S1,{className:"w-4 h-4"}),w(S.sizeBytes)]}),S.hasUploads&&i.jsxs("span",{className:"flex items-center gap-1 text-green-600",children:[i.jsx(b5,{className:"w-4 h-4"}),"Dokumente (",w(S.uploadSizeBytes),")"]})]}),i.jsxs("details",{className:"mt-2",children:[i.jsxs("summary",{className:"text-xs text-gray-500 cursor-pointer hover:text-gray-700",children:["Tabellen anzeigen (",S.tables.filter(M=>M.count>0).length," mit Daten)"]}),i.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:S.tables.filter(M=>M.count>0).map(M=>i.jsxs("span",{className:"text-xs bg-gray-100 px-2 py-0.5 rounded",children:[M.table,": ",M.count]},M.table))})]})]}),i.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>E(S.name),title:"Als ZIP herunterladen",children:i.jsx(u5,{className:"w-4 h-4"})}),i.jsxs(I,{variant:"secondary",size:"sm",onClick:()=>e(S.name),disabled:y.isPending,children:[i.jsx(_g,{className:"w-4 h-4 mr-1"}),"Wiederherstellen"]}),i.jsx(I,{variant:"danger",size:"sm",onClick:()=>s(S.name),disabled:v.isPending,children:i.jsx(Ee,{className:"w-4 h-4"})})]})]})},S.name))})]}),t&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup wiederherstellen?"}),i.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",i.jsx("strong",{children:t})," wirklich wiederherstellen?"]}),i.jsxs("p",{className:"text-amber-600 text-sm mb-4 bg-amber-50 p-3 rounded-lg",children:[i.jsx("strong",{children:"Achtung:"})," Bestehende Daten und Dokumente werden mit dem Backup-Stand überschrieben. Dies kann nicht rückgängig gemacht werden."]}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(I,{variant:"secondary",onClick:()=>e(null),disabled:y.isPending,children:"Abbrechen"}),i.jsx(I,{variant:"primary",onClick:()=>y.mutate(t),disabled:y.isPending,children:y.isPending?i.jsxs(i.Fragment,{children:[i.jsx(ai,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird wiederhergestellt..."]}):"Ja, wiederherstellen"})]})]})}),n&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[i.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"Backup löschen?"}),i.jsxs("p",{className:"text-gray-600 mb-4",children:["Möchten Sie das Backup ",i.jsx("strong",{children:n})," wirklich löschen? Dies kann nicht rückgängig gemacht werden."]}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(I,{variant:"secondary",onClick:()=>s(null),disabled:v.isPending,children:"Abbrechen"}),i.jsx(I,{variant:"danger",onClick:()=>v.mutate(n),disabled:v.isPending,children:v.isPending?"Wird gelöscht...":"Ja, löschen"})]})]})}),i.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-6 mt-8",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:i.jsx(Mn,{className:"w-6 h-6 text-red-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsx("h3",{className:"text-lg font-semibold text-red-800 mb-2",children:"Werkseinstellungen"}),i.jsxs("p",{className:"text-sm text-red-700 mb-4",children:["Setzt das System auf den Ausgangszustand zurück. ",i.jsx("strong",{children:"Alle Daten werden unwiderruflich gelöscht"})," - Kunden, Verträge, Benutzer, Dokumente und Einstellungen. Nur die hier gespeicherten Backups bleiben erhalten."]}),i.jsxs("ul",{className:"text-sm text-red-700 mb-4 list-disc list-inside space-y-1",children:[i.jsx("li",{children:"Alle Kunden und Verträge werden gelöscht"}),i.jsx("li",{children:"Alle Benutzer werden gelöscht"}),i.jsx("li",{children:"Alle hochgeladenen Dokumente werden gelöscht"}),i.jsx("li",{children:"Ein neuer Admin-Benutzer wird erstellt (admin@admin.com / admin)"}),i.jsxs("li",{children:[i.jsx("strong",{children:"Backups bleiben erhalten"})," und können danach wiederhergestellt werden"]})]}),i.jsxs(I,{variant:"danger",onClick:()=>a(!0),children:[i.jsx(f5,{className:"w-4 h-4 mr-2"}),"Werkseinstellungen"]})]})]})}),r&&i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-lg mx-4",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[i.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:i.jsx(Mn,{className:"w-6 h-6 text-red-600"})}),i.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Wirklich auf Werkseinstellungen zurücksetzen?"})]}),i.jsxs("p",{className:"text-gray-600 mb-4",children:["Diese Aktion löscht ",i.jsx("strong",{children:"alle Daten unwiderruflich"}),". Es gibt kein Zurück!"]}),i.jsxs("p",{className:"text-sm text-gray-600 mb-4",children:["Geben Sie zur Bestätigung ",i.jsx("strong",{className:"font-mono bg-gray-100 px-1",children:"LÖSCHEN"})," ein:"]}),i.jsx("input",{type:"text",value:l,onChange:S=>o(S.target.value),placeholder:"LÖSCHEN",className:"w-full px-3 py-2 border border-gray-300 rounded-lg mb-4 focus:ring-2 focus:ring-red-500 focus:border-red-500"}),i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(I,{variant:"secondary",onClick:()=>{a(!1),o("")},disabled:j.isPending,children:"Abbrechen"}),i.jsx(I,{variant:"danger",onClick:()=>j.mutate(),disabled:l!=="LÖSCHEN"||j.isPending,children:j.isPending?i.jsxs(i.Fragment,{children:[i.jsx(ai,{className:"w-4 h-4 mr-2 animate-spin"}),"Wird zurückgesetzt..."]}):"Ja, alles löschen"})]})]})})]})}const tO=[{value:"",label:"Alle Aktionen"},{value:"CREATE",label:"Erstellt"},{value:"READ",label:"Gelesen"},{value:"UPDATE",label:"Aktualisiert"},{value:"DELETE",label:"Gelöscht"},{value:"EXPORT",label:"Exportiert"},{value:"ANONYMIZE",label:"Anonymisiert"},{value:"LOGIN",label:"Login"},{value:"LOGOUT",label:"Logout"},{value:"LOGIN_FAILED",label:"Login fehlgeschlagen"}],nO=[{value:"",label:"Alle Stufen"},{value:"LOW",label:"Niedrig"},{value:"MEDIUM",label:"Mittel"},{value:"HIGH",label:"Hoch"},{value:"CRITICAL",label:"Kritisch"}],sO=[{value:"",label:"Alle Ressourcen"},{value:"Customer",label:"Kunden"},{value:"Contract",label:"Verträge"},{value:"User",label:"Benutzer"},{value:"BankCard",label:"Bankdaten"},{value:"IdentityDocument",label:"Ausweisdokumente"},{value:"Authentication",label:"Authentifizierung"},{value:"CustomerConsent",label:"Einwilligungen"},{value:"GDPR",label:"DSGVO"}];function BC(t){return new Date(t).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function _C(t){switch(t){case"CREATE":return"bg-green-100 text-green-800";case"READ":return"bg-blue-100 text-blue-800";case"UPDATE":return"bg-yellow-100 text-yellow-800";case"DELETE":return"bg-red-100 text-red-800";case"EXPORT":return"bg-purple-100 text-purple-800";case"ANONYMIZE":return"bg-orange-100 text-orange-800";case"LOGIN":return"bg-teal-100 text-teal-800";case"LOGOUT":return"bg-gray-100 text-gray-800";case"LOGIN_FAILED":return"bg-red-200 text-red-900";default:return"bg-gray-100 text-gray-800"}}function VC(t){switch(t){case"LOW":return i.jsx(lr,{className:"w-4 h-4 text-gray-400"});case"MEDIUM":return i.jsx(lr,{className:"w-4 h-4 text-blue-500"});case"HIGH":return i.jsx(hh,{className:"w-4 h-4 text-orange-500"});case"CRITICAL":return i.jsx(hh,{className:"w-4 h-4 text-red-500"});default:return i.jsx(lr,{className:"w-4 h-4 text-gray-400"})}}function rO({log:t,onClose:e}){const n=a=>{if(!a)return null;try{return JSON.parse(a)}catch{return null}},s=n(t.changesBefore),r=n(t.changesAfter);return i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-3xl mx-4 max-h-[90vh] overflow-y-auto",children:i.jsxs("div",{className:"p-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h2",{className:"text-xl font-semibold",children:"Audit-Log Details"}),i.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:i.jsx(nn,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-6",children:[i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Zeitpunkt"}),i.jsx("dd",{className:"font-medium",children:BC(t.createdAt)})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Benutzer"}),i.jsx("dd",{className:"font-medium",children:t.userEmail})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Aktion"}),i.jsx("dd",{children:i.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${_C(t.action)}`,children:t.action})})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Ressource"}),i.jsxs("dd",{className:"font-medium",children:[t.resourceType," ",t.resourceId&&`#${t.resourceId}`]})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Endpoint"}),i.jsxs("dd",{className:"font-mono text-sm",children:[t.httpMethod," ",t.endpoint]})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"IP-Adresse"}),i.jsx("dd",{className:"font-mono text-sm",children:t.ipAddress})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Sensitivität"}),i.jsxs("dd",{className:"flex items-center gap-2",children:[VC(t.sensitivity)," ",t.sensitivity]})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Dauer"}),i.jsx("dd",{children:t.durationMs?`${t.durationMs}ms`:"-"})]}),t.resourceLabel&&i.jsxs("div",{className:"col-span-2",children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Ressource-Bezeichnung"}),i.jsx("dd",{className:"font-medium",children:t.resourceLabel})]})]}),t.changesEncrypted&&i.jsx("div",{className:"mb-4 p-3 bg-yellow-50 text-yellow-800 rounded-lg text-sm",children:"Die Änderungsdaten sind verschlüsselt und können nur mit dem Encryption-Key eingesehen werden."}),(s||r)&&!t.changesEncrypted&&i.jsxs("div",{className:"border-t pt-4",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Änderungen"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s&&i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Vorher"}),i.jsx("pre",{className:"bg-gray-50 p-3 rounded text-xs overflow-auto max-h-64",children:JSON.stringify(s,null,2)})]}),r&&i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Nachher"}),i.jsx("pre",{className:"bg-gray-50 p-3 rounded text-xs overflow-auto max-h-64",children:JSON.stringify(r,null,2)})]})]})]}),t.hash&&i.jsxs("div",{className:"border-t pt-4 mt-4",children:[i.jsx("h3",{className:"font-medium mb-2",children:"Integrität"}),i.jsxs("div",{className:"text-xs font-mono bg-gray-50 p-2 rounded break-all",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"Hash:"})," ",t.hash]}),t.previousHash&&i.jsxs("div",{className:"mt-1",children:[i.jsx("span",{className:"text-gray-500",children:"Vorheriger:"})," ",t.previousHash]})]})]}),i.jsx("div",{className:"flex justify-end mt-6 pt-4 border-t",children:i.jsx(I,{variant:"secondary",onClick:e,children:"Schließen"})})]})})})}function iO(){const t=fn(),[e,n]=N.useState(1),[s,r]=N.useState({page:1,limit:50}),[a,l]=N.useState(null),{data:o,isLoading:c,refetch:d}=fe({queryKey:["audit-logs",{...s,page:e}],queryFn:()=>Pm.search({...s,page:e})}),u=G({mutationFn:()=>Pm.verifyIntegrity(),onSuccess:g=>{var x,y,v;(x=g.data)!=null&&x.valid?alert("Hash-Kette ist intakt. Keine Manipulationen festgestellt."):alert(`Integritätsfehler gefunden:
${(v=(y=g.data)==null?void 0:y.errors)==null?void 0:v.join(`
`)}`)},onError:g=>{alert(`Fehler bei der Integritätsprüfung: ${g instanceof Error?g.message:"Unbekannter Fehler"}`)}}),h=(o==null?void 0:o.data)||[],m=o==null?void 0:o.pagination,f=(g,x)=>{r(y=>({...y,[g]:x||void 0})),n(1)},p=async g=>{try{const y=(await Pm.export({...s,format:g})).data,v=new Blob([g==="json"?JSON.stringify(y,null,2):""],{type:g==="json"?"application/json":"text/csv"}),b=URL.createObjectURL(v),j=document.createElement("a");j.href=b,j.download=`audit-logs-${new Date().toISOString().split("T")[0]}.${g}`,j.click(),URL.revokeObjectURL(b)}catch(x){alert(`Export fehlgeschlagen: ${x instanceof Error?x.message:"Unbekannter Fehler"}`)}};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsxs(I,{variant:"ghost",onClick:()=>t("/settings"),children:[i.jsx(Yn,{className:"w-4 h-4 mr-2"}),"Zurück"]}),i.jsx("h1",{className:"text-2xl font-bold",children:"Audit-Protokoll"})]}),i.jsxs(Z,{className:"mb-6",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-4",children:[i.jsx(q,{placeholder:"Suche...",value:s.search||"",onChange:g=>f("search",g.target.value),className:"w-full"}),i.jsx(Fe,{value:s.action||"",onChange:g=>f("action",g.target.value),options:tO}),i.jsx(Fe,{value:s.resourceType||"",onChange:g=>f("resourceType",g.target.value),options:sO}),i.jsx(Fe,{value:s.sensitivity||"",onChange:g=>f("sensitivity",g.target.value),options:nO})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-4",children:[i.jsx(q,{type:"date",label:"Von",value:s.startDate||"",onChange:g=>f("startDate",g.target.value)}),i.jsx(q,{type:"date",label:"Bis",value:s.endDate||"",onChange:g=>f("endDate",g.target.value)}),i.jsx("div",{}),i.jsxs("div",{className:"flex gap-2 justify-end items-end",children:[i.jsxs(I,{variant:"secondary",onClick:()=>d(),children:[i.jsx(ai,{className:"w-4 h-4 mr-2"}),"Aktualisieren"]}),i.jsxs(I,{variant:"secondary",onClick:()=>p("json"),children:[i.jsx(qn,{className:"w-4 h-4 mr-2"}),"Export"]}),i.jsxs(I,{variant:"secondary",onClick:()=>u.mutate(),disabled:u.isPending,children:[i.jsx(SC,{className:"w-4 h-4 mr-2"}),u.isPending?"Prüfe...":"Integrität"]})]})]})]}),i.jsx(Z,{children:c?i.jsx("div",{className:"text-center py-8",children:"Laden..."}):h.length===0?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Audit-Logs gefunden."}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left py-3 px-4",children:"Zeitpunkt"}),i.jsx("th",{className:"text-left py-3 px-4",children:"Benutzer"}),i.jsx("th",{className:"text-left py-3 px-4",children:"Aktion"}),i.jsx("th",{className:"text-left py-3 px-4",children:"Ressource"}),i.jsx("th",{className:"text-left py-3 px-4",children:"IP"}),i.jsx("th",{className:"text-center py-3 px-4"}),i.jsx("th",{className:"text-center py-3 px-4"})]})}),i.jsx("tbody",{children:h.map(g=>i.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[i.jsx("td",{className:"py-3 px-4 whitespace-nowrap",children:BC(g.createdAt)}),i.jsxs("td",{className:"py-3 px-4",children:[i.jsx("div",{className:"truncate max-w-[200px]",title:g.userEmail,children:g.userEmail}),g.userRole&&i.jsx("div",{className:"text-xs text-gray-500",children:g.userRole})]}),i.jsx("td",{className:"py-3 px-4",children:i.jsx("span",{className:`px-2 py-1 rounded text-xs font-medium ${_C(g.action)}`,children:g.action})}),i.jsxs("td",{className:"py-3 px-4",children:[i.jsx("div",{children:g.resourceType}),g.resourceLabel&&i.jsx("div",{className:"text-xs text-gray-500 truncate max-w-[200px]",title:g.resourceLabel,children:g.resourceLabel})]}),i.jsx("td",{className:"py-3 px-4 font-mono text-xs",children:g.ipAddress}),i.jsx("td",{className:"py-3 px-4 text-center",children:VC(g.sensitivity)}),i.jsx("td",{className:"py-3 px-4 text-center",children:i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(g),children:i.jsx(Oe,{className:"w-4 h-4"})})})]},g.id))})]})}),m&&m.totalPages>1&&i.jsxs("div",{className:"flex items-center justify-between mt-4 pt-4 border-t",children:[i.jsxs("div",{className:"text-sm text-gray-500",children:["Seite ",m.page," von ",m.totalPages," (",m.total," Einträge)"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>n(g=>Math.max(1,g-1)),disabled:e===1,children:i.jsx(xC,{className:"w-4 h-4"})}),i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>n(g=>Math.min(m.totalPages,g+1)),disabled:e===m.totalPages,children:i.jsx(At,{className:"w-4 h-4"})})]})]})]})}),a&&i.jsx(rO,{log:a,onClose:()=>l(null)})]})}const aO=[{value:"",label:"Alle Status"},{value:"PENDING",label:"Ausstehend"},{value:"IN_PROGRESS",label:"In Bearbeitung"},{value:"COMPLETED",label:"Abgeschlossen"},{value:"PARTIALLY_COMPLETED",label:"Teilweise abgeschlossen"},{value:"REJECTED",label:"Abgelehnt"}];function lO(t){switch(t){case"PENDING":return i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-yellow-100 text-yellow-800",children:[i.jsx(cs,{className:"w-3 h-3"})," Ausstehend"]});case"IN_PROGRESS":return i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-blue-100 text-blue-800",children:[i.jsx(cs,{className:"w-3 h-3"})," In Bearbeitung"]});case"COMPLETED":return i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-green-100 text-green-800",children:[i.jsx(Un,{className:"w-3 h-3"})," Abgeschlossen"]});case"PARTIALLY_COMPLETED":return i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-orange-100 text-orange-800",children:[i.jsx(Mn,{className:"w-3 h-3"})," Teilweise"]});case"REJECTED":return i.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium bg-red-100 text-red-800",children:[i.jsx(Bg,{className:"w-3 h-3"})," Abgelehnt"]});default:return i.jsx("span",{className:"px-2 py-1 rounded text-xs bg-gray-100",children:t})}}function Hg(t){return new Date(t).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}function oO({request:t,onClose:e,onProcess:n,isPending:s}){var c,d,u;const[r,a]=N.useState("complete"),[l,o]=N.useState("");return i.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:i.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-lg mx-4",children:i.jsxs("div",{className:"p-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h2",{className:"text-xl font-semibold",children:"Löschanfrage bearbeiten"}),i.jsx("button",{onClick:e,className:"text-gray-400 hover:text-gray-600",children:i.jsx(nn,{className:"w-5 h-5"})})]}),i.jsxs("div",{className:"mb-4 p-4 bg-gray-50 rounded-lg",children:[i.jsx("p",{className:"text-sm text-gray-600",children:"Kunde:"}),i.jsxs("p",{className:"font-medium",children:[(c=t.customer)==null?void 0:c.firstName," ",(d=t.customer)==null?void 0:d.lastName," (",(u=t.customer)==null?void 0:u.customerNumber,")"]}),i.jsxs("p",{className:"text-sm text-gray-600 mt-2",children:["Quelle: ",t.requestSource]}),i.jsxs("p",{className:"text-sm text-gray-600",children:["Angefordert: ",Hg(t.requestedAt)]})]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Aktion"}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("label",{className:"flex items-center gap-3 p-3 border rounded-lg cursor-pointer hover:bg-gray-50",children:[i.jsx("input",{type:"radio",name:"action",checked:r==="complete",onChange:()=>a("complete"),className:"text-blue-600"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:"Vollständig löschen"}),i.jsx("div",{className:"text-sm text-gray-500",children:"Alle Kundendaten werden anonymisiert"})]})]}),i.jsxs("label",{className:"flex items-center gap-3 p-3 border rounded-lg cursor-pointer hover:bg-gray-50",children:[i.jsx("input",{type:"radio",name:"action",checked:r==="partial",onChange:()=>a("partial"),className:"text-blue-600"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:"Teilweise löschen"}),i.jsx("div",{className:"text-sm text-gray-500",children:"Nur optionale Daten werden gelöscht (aktive Verträge bleiben)"})]})]}),i.jsxs("label",{className:"flex items-center gap-3 p-3 border rounded-lg cursor-pointer hover:bg-gray-50",children:[i.jsx("input",{type:"radio",name:"action",checked:r==="reject",onChange:()=>a("reject"),className:"text-blue-600"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:"Ablehnen"}),i.jsx("div",{className:"text-sm text-gray-500",children:"Löschanfrage kann nicht durchgeführt werden"})]})]})]})]}),(r==="partial"||r==="reject")&&i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:["Begründung ",r==="reject"&&"*"]}),i.jsx("textarea",{value:l,onChange:h=>o(h.target.value),rows:3,className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",placeholder:"Grund für die teilweise Löschung/Ablehnung...",required:r==="reject"})]})]}),i.jsxs("div",{className:"flex justify-end gap-3 mt-6 pt-4 border-t",children:[i.jsx(I,{variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{onClick:()=>n(r,l||void 0),disabled:s||r==="reject"&&!l,children:s?"Verarbeite...":"Durchführen"})]})]})})})}function cO(){const t=fn(),e=ye(),[n,s]=N.useState(""),[r,a]=N.useState(null),{data:l}=fe({queryKey:["gdpr-stats"],queryFn:()=>Mr.getDashboardStats()}),{data:o,isLoading:c}=fe({queryKey:["deletion-requests",n],queryFn:()=>Mr.getDeletionRequests({status:n||void 0})}),{data:d}=fe({queryKey:["consent-overview"],queryFn:()=>Mr.getConsentOverview()}),u=G({mutationFn:({id:x,data:y})=>Mr.processDeletionRequest(x,y),onSuccess:()=>{e.invalidateQueries({queryKey:["deletion-requests"]}),e.invalidateQueries({queryKey:["gdpr-stats"]}),a(null)}}),h=l==null?void 0:l.data,m=(o==null?void 0:o.data)||[],f=(d==null?void 0:d.data)||{},p=(x,y)=>{if(!r)return;const v=JSON.parse(localStorage.getItem("user")||"{}");u.mutate({id:r.id,data:{processedBy:v.email||"System",action:x,retentionReason:y}})},g={DATA_PROCESSING:"Datenverarbeitung",MARKETING_EMAIL:"E-Mail-Marketing",MARKETING_PHONE:"Telefonmarketing",DATA_SHARING_PARTNER:"Datenweitergabe"};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsxs(I,{variant:"ghost",onClick:()=>t("/settings"),children:[i.jsx(Yn,{className:"w-4 h-4 mr-2"}),"Zurück"]}),i.jsx("h1",{className:"text-2xl font-bold",children:"DSGVO-Dashboard"})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[i.jsx(Z,{children:i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("div",{className:"p-3 bg-yellow-100 rounded-lg",children:i.jsx(cs,{className:"w-6 h-6 text-yellow-600"})}),i.jsxs("div",{children:[i.jsx("div",{className:"text-2xl font-bold",children:(h==null?void 0:h.deletionRequests.pending)??"-"}),i.jsx("div",{className:"text-sm text-gray-500",children:"Offene Löschanfragen"})]})]})}),i.jsx(Z,{children:i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("div",{className:"p-3 bg-green-100 rounded-lg",children:i.jsx(Un,{className:"w-6 h-6 text-green-600"})}),i.jsxs("div",{children:[i.jsx("div",{className:"text-2xl font-bold",children:(h==null?void 0:h.deletionRequests.completedLast30Days)??"-"}),i.jsx("div",{className:"text-sm text-gray-500",children:"Gelöscht (30 Tage)"})]})]})}),i.jsx(Z,{children:i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("div",{className:"p-3 bg-purple-100 rounded-lg",children:i.jsx(qn,{className:"w-6 h-6 text-purple-600"})}),i.jsxs("div",{children:[i.jsx("div",{className:"text-2xl font-bold",children:(h==null?void 0:h.dataExports.last30Days)??"-"}),i.jsx("div",{className:"text-sm text-gray-500",children:"Datenexporte (30 Tage)"})]})]})}),i.jsx(Z,{children:i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("div",{className:"p-3 bg-blue-100 rounded-lg",children:i.jsx(Ca,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{children:[i.jsx("div",{className:"text-2xl font-bold",children:(h==null?void 0:h.consents.granted)??"-"}),i.jsx("div",{className:"text-sm text-gray-500",children:"Aktive Einwilligungen"})]})]})})]}),Object.keys(f).length>0&&i.jsxs(Z,{className:"mb-6",children:[i.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Einwilligungen nach Typ"}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:Object.entries(f).map(([x,y])=>i.jsxs("div",{className:"p-4 bg-gray-50 rounded-lg",children:[i.jsx("div",{className:"font-medium mb-2",children:g[x]||x}),i.jsxs("div",{className:"flex gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-green-600 font-medium",children:y.granted}),i.jsx("span",{className:"text-gray-500 ml-1",children:"erteilt"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-red-600 font-medium",children:y.withdrawn}),i.jsx("span",{className:"text-gray-500 ml-1",children:"widerrufen"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-600 font-medium",children:y.pending}),i.jsx("span",{className:"text-gray-500 ml-1",children:"ausstehend"})]})]})]},x))})]}),i.jsxs(Z,{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h2",{className:"text-lg font-semibold",children:"Löschanfragen"}),i.jsx(Fe,{value:n,onChange:x=>s(x.target.value),options:aO,className:"w-48"})]}),c?i.jsx("div",{className:"text-center py-8",children:"Laden..."}):m.length===0?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Löschanfragen gefunden."}):i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left py-3 px-4",children:"Kunde"}),i.jsx("th",{className:"text-left py-3 px-4",children:"Status"}),i.jsx("th",{className:"text-left py-3 px-4",children:"Quelle"}),i.jsx("th",{className:"text-left py-3 px-4",children:"Angefordert"}),i.jsx("th",{className:"text-left py-3 px-4",children:"Bearbeitet"}),i.jsx("th",{className:"text-center py-3 px-4"})]})}),i.jsx("tbody",{children:m.map(x=>i.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[i.jsx("td",{className:"py-3 px-4",children:x.customer?i.jsxs("div",{children:[i.jsxs("div",{className:"font-medium",children:[x.customer.firstName," ",x.customer.lastName]}),i.jsx("div",{className:"text-xs text-gray-500",children:x.customer.customerNumber})]}):i.jsxs("span",{className:"text-gray-400",children:["Kunde #",x.customerId]})}),i.jsx("td",{className:"py-3 px-4",children:lO(x.status)}),i.jsx("td",{className:"py-3 px-4",children:x.requestSource}),i.jsxs("td",{className:"py-3 px-4",children:[i.jsx("div",{children:Hg(x.requestedAt)}),i.jsxs("div",{className:"text-xs text-gray-500",children:["von ",x.requestedBy]})]}),i.jsx("td",{className:"py-3 px-4",children:x.processedAt?i.jsxs("div",{children:[i.jsx("div",{children:Hg(x.processedAt)}),i.jsxs("div",{className:"text-xs text-gray-500",children:["von ",x.processedBy]})]}):i.jsx("span",{className:"text-gray-400",children:"-"})}),i.jsxs("td",{className:"py-3 px-4 text-center",children:[(x.status==="PENDING"||x.status==="IN_PROGRESS")&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>a(x),children:i.jsx(At,{className:"w-4 h-4"})}),x.proofDocument&&i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>window.open(`/api/uploads/${x.proofDocument}`,"_blank"),title:"Löschnachweis anzeigen",children:i.jsx(We,{className:"w-4 h-4 text-blue-500"})})]})]},x.id))})]})})]}),r&&i.jsx(oO,{request:r,onClose:()=>a(null),onProcess:p,isPending:u.isPending})]})}function dO(){var v;const[t,e]=N.useState(""),[n,s]=N.useState(1),[r,a]=N.useState(!1),[l,o]=N.useState(null),c=ye(),{refreshUser:d}=nt(),{data:u,isLoading:h}=fe({queryKey:["users",t,n],queryFn:()=>sc.getAll({search:t||void 0,page:n,limit:20})}),{data:m}=fe({queryKey:["roles"],queryFn:()=>sc.getRoles()}),f=G({mutationFn:sc.delete,onSuccess:()=>{c.invalidateQueries({queryKey:["users"]})},onError:b=>{alert((b==null?void 0:b.message)||"Fehler beim Löschen des Benutzers")}}),p=b=>{var j;return(j=b.roles)==null?void 0:j.some(k=>k.name==="Admin")},g=((v=u==null?void 0:u.data)==null?void 0:v.filter(b=>b.isActive&&p(b)).length)||0,x=b=>{o(b),a(!0)},y=()=>{a(!1),o(null)};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsx(Me,{to:"/settings",children:i.jsx(I,{variant:"ghost",size:"sm",children:i.jsx(Yn,{className:"w-4 h-4"})})}),i.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Benutzer"}),i.jsxs(I,{onClick:()=>a(!0),children:[i.jsx(Ge,{className:"w-4 h-4 mr-2"}),"Neuer Benutzer"]})]}),i.jsx(Z,{className:"mb-6",children:i.jsxs("div",{className:"flex gap-4",children:[i.jsx("div",{className:"flex-1",children:i.jsx(q,{placeholder:"Suchen...",value:t,onChange:b=>e(b.target.value)})}),i.jsx(I,{variant:"secondary",children:i.jsx(jd,{className:"w-4 h-4"})})]})}),i.jsxs("div",{className:"mb-6 bg-blue-50 border border-blue-200 rounded-lg p-4 flex items-start gap-3",children:[i.jsx(bd,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),i.jsxs("div",{className:"text-sm text-blue-800",children:[i.jsx("strong",{children:"Hinweis:"})," Bei Änderungen an Rollen oder Berechtigungen wird der betroffene Benutzer automatisch ausgeloggt und muss sich erneut anmelden."]})]}),i.jsx(Z,{children:h?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):u!=null&&u.data&&u.data.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b",children:[i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Rollen"}),i.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),i.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),i.jsx("tbody",{children:u.data.map(b=>{var j;return i.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[i.jsxs("td",{className:"py-3 px-4",children:[b.firstName," ",b.lastName]}),i.jsx("td",{className:"py-3 px-4",children:b.email}),i.jsx("td",{className:"py-3 px-4",children:i.jsx("div",{className:"flex gap-1 flex-wrap",children:(j=b.roles)==null?void 0:j.filter(k=>!["Developer","Kunde","DSGVO"].includes(k.name)).map(k=>i.jsx(je,{variant:"info",children:k.name},k.id||k.name))})}),i.jsx("td",{className:"py-3 px-4",children:i.jsxs("div",{className:"flex gap-2",children:[i.jsx(je,{variant:b.isActive?"success":"danger",children:b.isActive?"Aktiv":"Inaktiv"}),b.hasDeveloperAccess&&i.jsxs(je,{variant:"warning",className:"flex items-center gap-1",children:[i.jsx(la,{className:"w-3 h-3"}),"Dev"]}),b.hasGdprAccess&&i.jsxs(je,{variant:"info",className:"flex items-center gap-1",children:[i.jsx(lr,{className:"w-3 h-3"}),"DSGVO"]})]})}),i.jsx("td",{className:"py-3 px-4 text-right",children:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>x(b),children:i.jsx(rt,{className:"w-4 h-4"})}),(()=>{const k=p(b)&&b.isActive&&g<=1;return i.jsx(I,{variant:"ghost",size:"sm",disabled:k,title:k?"Letzter Administrator kann nicht gelöscht werden":void 0,onClick:()=>{confirm("Benutzer wirklich löschen?")&&f.mutate(b.id)},children:i.jsx(Ee,{className:`w-4 h-4 ${k?"text-gray-300":"text-red-500"}`})})})()]})})]},b.id)})})]})}),u.pagination&&u.pagination.totalPages>1&&i.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[i.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",u.pagination.page," von ",u.pagination.totalPages]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>s(b=>Math.max(1,b-1)),disabled:n===1,children:"Zurück"}),i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>s(b=>b+1),disabled:n>=u.pagination.totalPages,children:"Weiter"})]})]})]}):i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Benutzer gefunden."})}),i.jsx(uO,{isOpen:r,onClose:y,user:l,roles:(m==null?void 0:m.data)||[],onUserUpdated:d})]})}function uO({isOpen:t,onClose:e,user:n,roles:s,onUserUpdated:r}){const a=ye(),[l,o]=N.useState(null),[c,d]=N.useState({email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1,hasGdprAccess:!1,whatsappNumber:"",telegramUsername:"",signalNumber:""});N.useEffect(()=>{var g;t&&(o(null),d(n?{email:n.email,password:"",firstName:n.firstName,lastName:n.lastName,roleIds:((g=n.roles)==null?void 0:g.filter(x=>!["Developer","Kunde","DSGVO"].includes(x.name)).map(x=>x.id))||[],isActive:n.isActive??!0,hasDeveloperAccess:n.hasDeveloperAccess??!1,hasGdprAccess:n.hasGdprAccess??!1,whatsappNumber:n.whatsappNumber||"",telegramUsername:n.telegramUsername||"",signalNumber:n.signalNumber||""}:{email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1,hasGdprAccess:!1,whatsappNumber:"",telegramUsername:"",signalNumber:""}))},[t,n]);const u=G({mutationFn:sc.create,onSuccess:()=>{a.invalidateQueries({queryKey:["users"]}),e()},onError:g=>{o((g==null?void 0:g.message)||"Fehler beim Erstellen des Benutzers")}}),h=G({mutationFn:g=>sc.update(n.id,g),onSuccess:async()=>{a.invalidateQueries({queryKey:["users"]}),await r(),e()},onError:g=>{o((g==null?void 0:g.message)||"Fehler beim Aktualisieren des Benutzers")}}),m=g=>{if(g.preventDefault(),n){const x={email:c.email,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,isActive:c.isActive,hasDeveloperAccess:c.hasDeveloperAccess,hasGdprAccess:c.hasGdprAccess,whatsappNumber:c.whatsappNumber||void 0,telegramUsername:c.telegramUsername||void 0,signalNumber:c.signalNumber||void 0};c.password&&(x.password=c.password),h.mutate(x)}else u.mutate({email:c.email,password:c.password,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,hasDeveloperAccess:c.hasDeveloperAccess,hasGdprAccess:c.hasGdprAccess,whatsappNumber:c.whatsappNumber||void 0,telegramUsername:c.telegramUsername||void 0,signalNumber:c.signalNumber||void 0})},f=g=>{d(x=>({...x,roleIds:x.roleIds.includes(g)?x.roleIds.filter(y=>y!==g):[...x.roleIds,g]}))},p=u.isPending||h.isPending;return i.jsx(Xe,{isOpen:t,onClose:e,title:n?"Benutzer bearbeiten":"Neuer Benutzer",children:i.jsxs("form",{onSubmit:m,className:"space-y-4",children:[l&&i.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 flex items-start gap-2",children:[i.jsx(Mn,{className:"w-5 h-5 text-red-500 flex-shrink-0 mt-0.5"}),i.jsx("p",{className:"text-red-700 text-sm",children:l})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(q,{label:"Vorname *",value:c.firstName,onChange:g=>d({...c,firstName:g.target.value}),required:!0}),i.jsx(q,{label:"Nachname *",value:c.lastName,onChange:g=>d({...c,lastName:g.target.value}),required:!0})]}),i.jsx(q,{label:"E-Mail *",type:"email",value:c.email,onChange:g=>d({...c,email:g.target.value}),required:!0}),i.jsx(q,{label:n?"Neues Passwort (leer = unverändert)":"Passwort *",type:"password",value:c.password,onChange:g=>d({...c,password:g.target.value}),required:!n}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Messaging-Kanäle (für Datenschutz-Versand)"}),i.jsxs("div",{className:"space-y-3",children:[i.jsx(q,{label:"WhatsApp-Nummer",placeholder:"+49...",value:c.whatsappNumber,onChange:g=>d({...c,whatsappNumber:g.target.value})}),i.jsx(q,{label:"Telegram-Benutzername",placeholder:"@username",value:c.telegramUsername,onChange:g=>d({...c,telegramUsername:g.target.value})}),i.jsx(q,{label:"Signal-Nummer",placeholder:"+49...",value:c.signalNumber,onChange:g=>d({...c,signalNumber:g.target.value})})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Rollen"}),i.jsx("div",{className:"space-y-2",children:s.filter(g=>!["Developer","Kunde","DSGVO"].includes(g.name)).map(g=>i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:c.roleIds.includes(g.id),onChange:()=>f(g.id),className:"rounded"}),i.jsx("span",{children:g.name}),g.description&&i.jsxs("span",{className:"text-sm text-gray-500",children:["(",g.description,")"]})]},g.id))}),i.jsx("label",{className:"block text-sm font-medium text-gray-700 mt-4 mb-2",children:"Zusätzliche Berechtigungen"}),i.jsxs("div",{className:"space-y-2",children:[i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:c.hasGdprAccess,onChange:g=>d({...c,hasGdprAccess:g.target.checked}),className:"rounded border-blue-300 text-blue-600 focus:ring-blue-500"}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(lr,{className:"w-4 h-4 text-blue-600"}),"DSGVO-Zugriff"]}),i.jsx("span",{className:"text-sm text-gray-500",children:"(Audit-Logs, Datenschutz)"})]}),i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:c.hasDeveloperAccess,onChange:g=>d({...c,hasDeveloperAccess:g.target.checked}),className:"rounded border-purple-300 text-purple-600 focus:ring-purple-500"}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(la,{className:"w-4 h-4 text-purple-600"}),"Entwicklerzugriff"]}),i.jsx("span",{className:"text-sm text-gray-500",children:"(Datenbanktools)"})]})]}),n&&i.jsxs("p",{className:"mt-2 text-xs text-amber-600 flex items-center gap-1",children:[i.jsx(Mn,{className:"w-3 h-3"}),"Bei Rollenänderung wird der Benutzer automatisch ausgeloggt."]})]}),n&&i.jsx("div",{className:"space-y-3 pt-3 border-t",children:i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",checked:c.isActive,onChange:g=>d({...c,isActive:g.target.checked}),className:"rounded"}),"Aktiv"]})}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(I,{type:"button",variant:"secondary",onClick:e,children:"Abbrechen"}),i.jsx(I,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function hO(){const{hasPermission:t,developerMode:e,setDeveloperMode:n}=nt(),s=[{to:"/settings/users",icon:K5,title:"Benutzer",description:"Verwalten Sie Benutzerkonten, Rollen und Berechtigungen.",show:t("users:read")},{to:"/settings/platforms",icon:$5,title:"Vertriebsplattformen",description:"Verwalten Sie die Plattformen, über die Verträge abgeschlossen werden.",show:t("platforms:read")},{to:"/settings/cancellation-periods",icon:cs,title:"Kündigungsfristen",description:"Konfigurieren Sie die verfügbaren Kündigungsfristen für Verträge.",show:t("platforms:read")},{to:"/settings/contract-durations",icon:pC,title:"Vertragslaufzeiten",description:"Konfigurieren Sie die verfügbaren Laufzeiten für Verträge.",show:t("platforms:read")},{to:"/settings/providers",icon:p5,title:"Anbieter & Tarife",description:"Verwalten Sie Anbieter und deren Tarife für Verträge.",show:t("providers:read")||t("platforms:read")},{to:"/settings/contract-categories",icon:v5,title:"Vertragstypen",description:"Konfigurieren Sie die verfügbaren Vertragstypen (Strom, Gas, Mobilfunk, etc.).",show:t("platforms:read")}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[i.jsx(kC,{className:"w-6 h-6"}),i.jsx("h1",{className:"text-2xl font-bold",children:"Einstellungen"})]}),i.jsxs("div",{className:"mb-8",children:[i.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Stammdaten"}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:s.filter(r=>r.show).map(r=>i.jsx(Me,{to:r.to,className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:i.jsx(r.icon,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:[r.title,i.jsx(At,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:r.description})]})]})},r.to))})]}),t("settings:update")&&i.jsxs("div",{className:"mb-8",children:[i.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"System"}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsx(Me,{to:"/settings/portal",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:i.jsx(Ly,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Kundenportal",i.jsx(At,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie das Kundenportal und Support-Anfragen."})]})]})}),i.jsx(Me,{to:"/settings/deadlines",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:i.jsx(cs,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Fristenschwellen",i.jsx(At,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die Farbkodierung für Vertragsfristen im Cockpit."})]})]})}),i.jsx(Me,{to:"/settings/email-providers",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:i.jsx(Fs,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Email-Provisionierung",i.jsx(At,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die automatische E-Mail-Erstellung für Stressfrei-Wechseln Adressen."})]})]})}),i.jsx(Me,{to:"/settings/database-backup",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:i.jsx(Rf,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Datenbank & Zurücksetzen",i.jsx(At,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Backups erstellen, wiederherstellen oder auf Werkseinstellungen zurücksetzen."})]})]})}),t("audit:read")&&i.jsx(Me,{to:"/settings/audit-logs",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:i.jsx(We,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Audit-Protokoll",i.jsx(At,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Protokollierte API-Zugriffe und Änderungen einsehen."}),t("developer:access")&&i.jsxs("p",{className:"text-xs text-purple-500 mt-1 flex items-center gap-1",children:[i.jsx(la,{className:"w-3 h-3"}),"Sichtbar durch Entwicklerzugriff"]})]})]})}),t("gdpr:admin")&&i.jsx(Me,{to:"/settings/gdpr",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:i.jsx(lr,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["DSGVO-Dashboard",i.jsx(At,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Löschanfragen, Datenexporte und Einwilligungen verwalten."}),t("developer:access")&&i.jsxs("p",{className:"text-xs text-purple-500 mt-1 flex items-center gap-1",children:[i.jsx(la,{className:"w-3 h-3"}),"Sichtbar durch Entwicklerzugriff"]})]})]})}),t("gdpr:admin")&&i.jsx(Me,{to:"/settings/privacy-policy",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:i.jsx(y5,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Datenschutzerklärung",i.jsx(At,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Datenschutzerklärung bearbeiten mit Platzhaltern für Kundendaten."}),t("developer:access")&&i.jsxs("p",{className:"text-xs text-purple-500 mt-1 flex items-center gap-1",children:[i.jsx(la,{className:"w-3 h-3"}),"Sichtbar durch Entwicklerzugriff"]})]})]})})]})]}),i.jsxs("div",{className:"mb-8",children:[i.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Persönlich"}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:i.jsx(Me,{to:"/settings/view",className:"block p-4 bg-white border border-gray-200 rounded-lg shadow-sm hover:shadow-md hover:border-blue-300 transition-all group",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:i.jsx(Oe,{className:"w-6 h-6 text-blue-600"})}),i.jsxs("div",{className:"flex-1",children:[i.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Ansicht",i.jsx(At,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),i.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Passen Sie die Darstellung der Anwendung an."})]})]})})})]}),t("developer:access")&&i.jsxs(Z,{title:"Entwickleroptionen",className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(la,{className:"w-5 h-5 text-gray-500"}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium",children:"Entwicklermodus"}),i.jsx("p",{className:"text-sm text-gray-500",children:"Aktiviert erweiterte Funktionen wie direkten Datenbankzugriff"})]})]}),i.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:e,onChange:r=>n(r.target.checked),className:"sr-only peer"}),i.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"})]})]}),e&&i.jsx("div",{className:"mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:i.jsxs("p",{className:"text-sm text-yellow-800",children:[i.jsx("strong",{children:"Warnung:"})," Der Entwicklermodus ermöglicht direkten Zugriff auf die Datenbank. Unsachgemäße Änderungen können zu Datenverlust oder Inkonsistenzen führen."]})})]}),i.jsx(Z,{title:"Über",children:i.jsxs("dl",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"Version"}),i.jsx("dd",{children:"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{className:"text-sm text-gray-500",children:"System"}),i.jsx("dd",{children:"OpenCRM"})]})]})})]})}function fO({onSelectTable:t}){const e=N.useRef(null),[n,s]=N.useState(1),[r,a]=N.useState({x:0,y:0}),[l,o]=N.useState(!1),[c,d]=N.useState({x:0,y:0}),[u,h]=N.useState({}),[m,f]=N.useState(null),{data:p,isLoading:g}=fe({queryKey:["developer-schema"],queryFn:Vo.getSchema}),x=(p==null?void 0:p.data)||[];N.useEffect(()=>{if(x.length>0&&Object.keys(u).length===0){const w=Math.ceil(Math.sqrt(x.length)),S={x:280,y:200},M={};x.forEach((F,R)=>{const V=R%w,D=Math.floor(R/w);M[F.name]={x:50+V*S.x,y:50+D*S.y}}),h(M)}},[x,u]);const y=N.useCallback(w=>{(w.target===w.currentTarget||w.target.tagName==="svg")&&(o(!0),d({x:w.clientX-r.x,y:w.clientY-r.y}))},[r]),v=N.useCallback(w=>{var S;if(l&&!m)a({x:w.clientX-c.x,y:w.clientY-c.y});else if(m){const M=(S=e.current)==null?void 0:S.getBoundingClientRect();M&&h(F=>({...F,[m]:{x:(w.clientX-M.left-r.x)/n-100,y:(w.clientY-M.top-r.y)/n-20}}))}},[l,m,c,r,n]),b=N.useCallback(()=>{o(!1),f(null)},[]),j=w=>{s(S=>Math.min(2,Math.max(.3,S+w)))},k=()=>{s(1),a({x:0,y:0})},E=N.useCallback(()=>{const w=[];return x.forEach(S=>{const M=u[S.name];M&&S.foreignKeys.forEach(F=>{const R=u[F.targetTable];if(!R)return;const V=x.find(z=>z.name===F.targetTable),D=V==null?void 0:V.relations.find(z=>z.targetTable===S.name);w.push({from:{table:S.name,x:M.x+100,y:M.y+60},to:{table:F.targetTable,x:R.x+100,y:R.y+60},type:(D==null?void 0:D.type)||"one",label:F.field})})}),w},[x,u]);if(g)return i.jsx("div",{className:"flex items-center justify-center h-full",children:"Laden..."});const T=E();return i.jsxs("div",{className:"relative h-full w-full bg-gray-50 overflow-hidden",ref:e,children:[i.jsxs("div",{className:"absolute top-4 right-4 z-10 flex gap-2 bg-white rounded-lg shadow-md p-2",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>j(.1),title:"Vergrößern",children:i.jsx(q5,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>j(-.1),title:"Verkleinern",children:i.jsx(H5,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:k,title:"Zurücksetzen",children:i.jsx(R5,{className:"w-4 h-4"})}),i.jsxs("div",{className:"text-xs text-gray-500 flex items-center px-2",children:[Math.round(n*100),"%"]})]}),i.jsxs("div",{className:"absolute top-4 left-4 z-10 bg-white rounded-lg shadow-md p-2 text-xs text-gray-500",children:[i.jsx(O5,{className:"w-3 h-3 inline mr-1"}),"Tabellen ziehen zum Verschieben"]}),i.jsx("svg",{className:"w-full h-full cursor-grab",style:{cursor:l?"grabbing":"grab"},onMouseDown:y,onMouseMove:v,onMouseUp:b,onMouseLeave:b,children:i.jsxs("g",{transform:`translate(${r.x}, ${r.y}) scale(${n})`,children:[i.jsxs("defs",{children:[i.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:i.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6b7280"})}),i.jsx("marker",{id:"many-marker",markerWidth:"12",markerHeight:"12",refX:"6",refY:"6",orient:"auto",children:i.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"#6b7280"})})]}),T.map((w,S)=>{const M=w.to.x-w.from.x,F=w.to.y-w.from.y,R=w.from.x+M/2,V=w.from.y+F/2,D=w.from.x+M*.25,z=w.from.y,C=w.from.x+M*.75,_=w.to.y;return i.jsxs("g",{children:[i.jsx("path",{d:`M ${w.from.x} ${w.from.y} C ${D} ${z}, ${C} ${_}, ${w.to.x} ${w.to.y}`,fill:"none",stroke:"#9ca3af",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),i.jsx("text",{x:R,y:V-8,fontSize:"10",fill:"#6b7280",textAnchor:"middle",className:"select-none",children:w.type==="many"?"1:n":"1:1"})]},S)}),x.map(w=>{const S=u[w.name];if(!S)return null;const M=200,F=32,R=20,V=[...new Set([w.primaryKey,...w.foreignKeys.map(z=>z.field)])],D=F+Math.min(V.length,5)*R+8;return i.jsxs("g",{transform:`translate(${S.x}, ${S.y})`,style:{cursor:"move"},onMouseDown:z=>{z.stopPropagation(),f(w.name)},children:[i.jsx("rect",{x:"3",y:"3",width:M,height:D,rx:"6",fill:"rgba(0,0,0,0.1)"}),i.jsx("rect",{x:"0",y:"0",width:M,height:D,rx:"6",fill:"white",stroke:"#e5e7eb",strokeWidth:"1"}),i.jsx("rect",{x:"0",y:"0",width:M,height:F,rx:"6",fill:"#3b82f6",className:"cursor-pointer",onClick:()=>t==null?void 0:t(w.name)}),i.jsx("rect",{x:"0",y:F-6,width:M,height:"6",fill:"#3b82f6"}),i.jsx("text",{x:M/2,y:"21",fontSize:"13",fontWeight:"bold",fill:"white",textAnchor:"middle",className:"select-none pointer-events-none",children:w.name}),V.slice(0,5).map((z,C)=>{const _=z===w.primaryKey||w.primaryKey.includes(z),K=w.foreignKeys.some(B=>B.field===z);return i.jsx("g",{transform:`translate(8, ${F+4+C*R})`,children:i.jsxs("text",{x:"0",y:"14",fontSize:"11",fill:_?"#dc2626":K?"#2563eb":"#374151",fontFamily:"monospace",className:"select-none",children:[_&&"🔑 ",K&&!_&&"🔗 ",z]})},z)}),V.length>5&&i.jsxs("text",{x:M/2,y:D-4,fontSize:"10",fill:"#9ca3af",textAnchor:"middle",className:"select-none",children:["+",V.length-5," mehr..."]})]},w.name)})]})}),i.jsxs("div",{className:"absolute bottom-4 left-4 bg-white rounded-lg shadow-md p-3 text-xs",children:[i.jsx("div",{className:"font-medium mb-2",children:"Legende"}),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-red-600",children:"🔑"}),i.jsx("span",{children:"Primary Key"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-blue-600",children:"🔗"}),i.jsx("span",{children:"Foreign Key"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-0.5 bg-gray-400"}),i.jsx("span",{children:"Beziehung"})]})]})]})]})}function mO(){var T;const[t,e]=N.useState(null),[n,s]=N.useState(1),[r,a]=N.useState(null),[l,o]=N.useState(!1),c=ye(),{data:d,isLoading:u,error:h}=fe({queryKey:["developer-schema"],queryFn:Vo.getSchema});console.log("Schema data:",d),console.log("Schema error:",h);const{data:m,isLoading:f}=fe({queryKey:["developer-table",t,n],queryFn:()=>Vo.getTableData(t,n),enabled:!!t}),p=G({mutationFn:({tableName:w,id:S,data:M})=>Vo.updateRow(w,S,M),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",t]}),a(null)},onError:w=>{var S,M;alert(((M=(S=w.response)==null?void 0:S.data)==null?void 0:M.error)||"Fehler beim Speichern")}}),g=G({mutationFn:({tableName:w,id:S})=>Vo.deleteRow(w,S),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",t]})},onError:w=>{var S,M;alert(((M=(S=w.response)==null?void 0:S.data)==null?void 0:M.error)||"Fehler beim Löschen")}}),x=(d==null?void 0:d.data)||[],y=x.find(w=>w.name===t),v=(w,S)=>S.primaryKey.includes(",")?S.primaryKey.split(",").map(M=>w[M]).join("-"):String(w[S.primaryKey]),b=w=>w==null?"-":typeof w=="boolean"?w?"Ja":"Nein":typeof w=="object"?w instanceof Date||typeof w=="string"&&w.match(/^\d{4}-\d{2}-\d{2}/)?new Date(w).toLocaleString("de-DE"):JSON.stringify(w):String(w),j=()=>{!r||!t||p.mutate({tableName:t,id:r.id,data:r.data})},k=w=>{t&&confirm("Datensatz wirklich löschen?")&&g.mutate({tableName:t,id:w})};if(u)return i.jsx("div",{className:"text-center py-8",children:"Laden..."});const E=w=>{e(w),s(1),o(!1)};return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Rf,{className:"w-6 h-6"}),i.jsx("h1",{className:"text-2xl font-bold",children:"Datenbankstruktur"})]}),i.jsxs(I,{onClick:()=>o(!0),children:[i.jsx(k1,{className:"w-4 h-4 mr-2"}),"ER-Diagramm"]})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[i.jsx(Z,{title:"Tabellen",className:"lg:col-span-1",children:i.jsx("div",{className:"space-y-1 max-h-[600px] overflow-y-auto",children:x.map(w=>i.jsxs("button",{onClick:()=>{e(w.name),s(1)},className:`w-full text-left px-3 py-2 rounded-lg flex items-center gap-2 transition-colors ${t===w.name?"bg-blue-100 text-blue-700":"hover:bg-gray-100"}`,children:[i.jsx(B5,{className:"w-4 h-4"}),i.jsx("span",{className:"text-sm font-mono",children:w.name})]},w.name))})}),i.jsx("div",{className:"lg:col-span-3 space-y-6",children:t&&y?i.jsxs(i.Fragment,{children:[i.jsxs(Z,{title:`${t} - Beziehungen`,children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Fremdschlüssel (referenziert)"}),y.foreignKeys.length>0?i.jsx("div",{className:"space-y-1",children:y.foreignKeys.map(w=>i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"font-mono text-gray-600",children:w.field}),i.jsx(fC,{className:"w-4 h-4 text-gray-400"}),i.jsx(je,{variant:"info",className:"cursor-pointer",onClick:()=>{e(w.targetTable),s(1)},children:w.targetTable})]},w.field))}):i.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]}),i.jsxs("div",{children:[i.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Relationen (wird referenziert von)"}),y.relations.length>0?i.jsx("div",{className:"space-y-1",children:y.relations.map(w=>i.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[i.jsx("span",{className:"font-mono text-gray-600",children:w.field}),i.jsx(je,{variant:w.type==="many"?"warning":"default",children:w.type==="many"?"1:n":"1:1"}),i.jsx(je,{variant:"info",className:"cursor-pointer",onClick:()=>{e(w.targetTable),s(1)},children:w.targetTable})]},w.field))}):i.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]})]}),i.jsx("div",{className:"mt-4 pt-4 border-t",children:i.jsxs("div",{className:"flex gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"Primary Key:"})," ",i.jsx("span",{className:"font-mono",children:y.primaryKey})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"Readonly:"})," ",i.jsx("span",{className:"font-mono text-red-600",children:y.readonlyFields.join(", ")||"-"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-gray-500",children:"Required:"})," ",i.jsx("span",{className:"font-mono text-green-600",children:y.requiredFields.join(", ")||"-"})]})]})})]}),i.jsx(Z,{title:`${t} - Daten`,children:f?i.jsx("div",{className:"text-center py-4",children:"Laden..."}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b bg-gray-50",children:[(m==null?void 0:m.data)&&m.data.length>0&&Object.keys(m.data[0]).map(w=>i.jsxs("th",{className:"text-left py-2 px-3 font-medium text-gray-600 whitespace-nowrap",children:[w,y.readonlyFields.includes(w)&&i.jsx("span",{className:"ml-1 text-red-400 text-xs",children:"*"}),y.requiredFields.includes(w)&&i.jsx("span",{className:"ml-1 text-green-400 text-xs",children:"!"})]},w)),i.jsx("th",{className:"text-right py-2 px-3 font-medium text-gray-600",children:"Aktionen"})]})}),i.jsxs("tbody",{children:[(T=m==null?void 0:m.data)==null?void 0:T.map(w=>{const S=v(w,y);return i.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[Object.entries(w).map(([M,F])=>i.jsx("td",{className:"py-2 px-3 font-mono text-xs max-w-[200px] truncate",children:b(F)},M)),i.jsx("td",{className:"py-2 px-3 text-right whitespace-nowrap",children:i.jsxs("div",{className:"flex justify-end gap-1",children:[i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>a({id:S,data:{...w}}),children:i.jsx(rt,{className:"w-4 h-4"})}),i.jsx(I,{variant:"ghost",size:"sm",onClick:()=>k(S),children:i.jsx(Ee,{className:"w-4 h-4 text-red-500"})})]})})]},S)}),(!(m!=null&&m.data)||m.data.length===0)&&i.jsx("tr",{children:i.jsx("td",{colSpan:100,className:"py-4 text-center text-gray-500",children:"Keine Daten vorhanden"})})]})]})}),(m==null?void 0:m.pagination)&&m.pagination.totalPages>1&&i.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[i.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",m.pagination.page," von ",m.pagination.totalPages," (",m.pagination.total," Einträge)"]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>s(w=>Math.max(1,w-1)),disabled:n===1,children:i.jsx(xC,{className:"w-4 h-4"})}),i.jsx(I,{variant:"secondary",size:"sm",onClick:()=>s(w=>w+1),disabled:n>=m.pagination.totalPages,children:i.jsx(At,{className:"w-4 h-4"})})]})]})]})})]}):i.jsx(Z,{children:i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Wähle eine Tabelle aus der Liste aus"})})})]}),i.jsx(Xe,{isOpen:!!r,onClose:()=>a(null),title:`${t} bearbeiten`,children:r&&y&&i.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[Object.entries(r.data).map(([w,S])=>{const M=y.readonlyFields.includes(w),F=y.requiredFields.includes(w);return i.jsxs("div",{children:[i.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[w,M&&i.jsx("span",{className:"ml-1 text-red-400",children:"(readonly)"}),F&&i.jsx("span",{className:"ml-1 text-green-600",children:"*"})]}),M?i.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg font-mono text-sm",children:b(S)}):typeof S=="boolean"?i.jsxs("select",{value:String(r.data[w]),onChange:R=>a({...r,data:{...r.data,[w]:R.target.value==="true"}}),className:"w-full px-3 py-2 border rounded-lg",children:[i.jsx("option",{value:"true",children:"Ja"}),i.jsx("option",{value:"false",children:"Nein"})]}):i.jsx("input",{type:typeof S=="number"?"number":"text",value:r.data[w]??"",onChange:R=>a({...r,data:{...r.data,[w]:typeof S=="number"?R.target.value?Number(R.target.value):null:R.target.value||null}}),className:"w-full px-3 py-2 border rounded-lg font-mono text-sm",disabled:M})]},w)}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[i.jsxs(I,{variant:"secondary",onClick:()=>a(null),children:[i.jsx(nn,{className:"w-4 h-4 mr-2"}),"Abbrechen"]}),i.jsxs(I,{onClick:j,disabled:p.isPending,children:[i.jsx(zy,{className:"w-4 h-4 mr-2"}),p.isPending?"Speichern...":"Speichern"]})]})]})}),l&&i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>o(!1)}),i.jsxs("div",{className:"relative bg-white rounded-xl shadow-2xl w-[90vw] h-[85vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(k1,{className:"w-5 h-5 text-blue-600"}),i.jsx("h2",{className:"text-lg font-semibold",children:"ER-Diagramm - Datenbankbeziehungen"})]}),i.jsx("button",{onClick:()=>o(!1),className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:i.jsx(nn,{className:"w-5 h-5"})})]}),i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(fO,{onSelectTable:E})})]})]})]})}function pO(){const{hash:t}=md(),e=ye(),[n,s]=N.useState(!1),[r,a]=N.useState({}),{data:l,isLoading:o,error:c}=fe({queryKey:["public-consent",t],queryFn:()=>Im.getConsentPage(t),enabled:!!t}),d=G({mutationFn:()=>Im.grantAllConsents(t),onSuccess:()=>{e.invalidateQueries({queryKey:["public-consent",t]})}});if(o)return i.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:i.jsxs("div",{className:"flex items-center gap-3 text-gray-500",children:[i.jsx(E1,{className:"w-5 h-5 animate-spin"}),"Laden..."]})});if(c||!(l!=null&&l.data))return i.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:i.jsxs("div",{className:"bg-white p-8 rounded-lg shadow-sm border max-w-md text-center",children:[i.jsx(lr,{className:"w-12 h-12 text-red-400 mx-auto mb-4"}),i.jsx("h1",{className:"text-xl font-bold text-gray-900 mb-2",children:"Ungültiger Link"}),i.jsx("p",{className:"text-gray-500",children:"Dieser Datenschutz-Link ist ungültig oder abgelaufen. Bitte kontaktieren Sie Ihren Berater."})]})});const{customer:u,consents:h,privacyPolicyHtml:m}=l.data,f=h.every(b=>b.status==="GRANTED"),p=h.map(b=>b.consentType),g=p.every(b=>r[b]),x=b=>{a(j=>({...j,[b]:!j[b]}))},y=()=>{const b=!n;s(b);const j={};p.forEach(k=>{j[k]=b}),a(j)},v=()=>{g&&d.mutate()};return i.jsxs("div",{className:"min-h-screen bg-gray-50",children:[i.jsx("div",{className:"bg-white border-b",children:i.jsx("div",{className:"max-w-3xl mx-auto px-4 py-6",children:i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(lr,{className:"w-8 h-8 text-blue-600"}),i.jsxs("div",{children:[i.jsx("h1",{className:"text-xl font-bold text-gray-900",children:"Datenschutzerklärung"}),i.jsxs("p",{className:"text-sm text-gray-500",children:[u.firstName," ",u.lastName," (Nr. ",u.customerNumber,")"]})]})]})})}),i.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-8",children:[f?i.jsx("div",{className:"bg-green-50 border border-green-200 rounded-lg p-6 mb-6",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx(Om,{className:"w-8 h-8 text-green-600 flex-shrink-0"}),i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold text-green-800 mb-1",children:"Einwilligungen bereits erteilt"}),i.jsx("p",{className:"text-green-700 text-sm mb-3",children:"Sie haben allen Einwilligungen zugestimmt. Vielen Dank!"}),i.jsx("div",{className:"space-y-1",children:h.map(b=>i.jsxs("div",{className:"flex items-center gap-2 text-sm text-green-700",children:[i.jsx(Om,{className:"w-4 h-4"}),i.jsx("span",{children:b.label}),b.grantedAt&&i.jsxs("span",{className:"text-green-500",children:["(am ",new Date(b.grantedAt).toLocaleDateString("de-DE"),")"]})]},b.consentType))})]})]})}):d.isSuccess?i.jsx("div",{className:"bg-green-50 border border-green-200 rounded-lg p-6 mb-6",children:i.jsxs("div",{className:"flex items-start gap-4",children:[i.jsx(Om,{className:"w-8 h-8 text-green-600 flex-shrink-0"}),i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold text-green-800 mb-1",children:"Vielen Dank!"}),i.jsx("p",{className:"text-green-700 text-sm",children:"Ihre Einwilligungen wurden erfolgreich gespeichert."})]})]})}):null,i.jsxs("div",{className:"bg-white border rounded-lg shadow-sm mb-6",children:[i.jsxs("div",{className:"p-6 border-b flex items-center justify-between",children:[i.jsx("h2",{className:"font-semibold text-gray-900",children:"Datenschutzerklärung"}),i.jsxs("a",{href:Im.getConsentPdfUrl(t),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-sm text-blue-600 hover:text-blue-800",children:[i.jsx(yC,{className:"w-4 h-4"}),"Als PDF herunterladen"]})]}),i.jsx("div",{className:"p-6 prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:m}})]}),!f&&!d.isSuccess&&i.jsxs("div",{className:"bg-white border rounded-lg shadow-sm",children:[i.jsxs("div",{className:"p-6 border-b",children:[i.jsx("h2",{className:"font-semibold text-gray-900 mb-1",children:"Einwilligungen"}),i.jsx("p",{className:"text-sm text-gray-500",children:"Bitte stimmen Sie allen Punkten zu, damit wir Sie beraten können."})]}),i.jsxs("div",{className:"p-6 space-y-4",children:[i.jsxs("label",{className:"flex items-start gap-3 p-3 rounded-lg bg-blue-50 border border-blue-200 cursor-pointer hover:bg-blue-100 transition-colors",children:[i.jsx("input",{type:"checkbox",checked:n&&g,onChange:y,className:"mt-0.5 rounded border-blue-300 text-blue-600 focus:ring-blue-500"}),i.jsx("div",{children:i.jsx("span",{className:"font-medium text-blue-900",children:"Allen zustimmen"})})]}),i.jsx("div",{className:"border-t pt-4 space-y-3",children:h.map(b=>i.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r[b.consentType]?"bg-green-50 border-green-200":"bg-white border-gray-200 hover:bg-gray-50"}`,children:[i.jsx("input",{type:"checkbox",checked:r[b.consentType]||!1,onChange:()=>x(b.consentType),className:"mt-0.5 rounded border-gray-300 text-green-600 focus:ring-green-500"}),i.jsxs("div",{children:[i.jsxs("span",{className:"font-medium text-gray-900",children:[b.label," *"]}),i.jsx("p",{className:"text-sm text-gray-500 mt-0.5",children:b.description})]})]},b.consentType))}),i.jsx("p",{className:"text-xs text-gray-400",children:"* Pflichtfeld"}),d.isError&&i.jsx("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 text-sm text-red-700",children:"Fehler beim Speichern. Bitte versuchen Sie es erneut."}),i.jsx("button",{onClick:v,disabled:!g||d.isPending,className:`w-full py-3 px-4 rounded-lg font-medium text-white transition-colors ${g&&!d.isPending?"bg-blue-600 hover:bg-blue-700":"bg-gray-300 cursor-not-allowed"}`,children:d.isPending?i.jsxs("span",{className:"flex items-center justify-center gap-2",children:[i.jsx(E1,{className:"w-4 h-4 animate-spin"}),"Wird gespeichert..."]}):"Zustimmen"})]})]})]})]})}var KC={exports:{}},UC={};/**
* @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 no=N;function gO(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var xO=typeof Object.is=="function"?Object.is:gO,yO=no.useState,vO=no.useEffect,bO=no.useLayoutEffect,jO=no.useDebugValue;function NO(t,e){var n=e(),s=yO({inst:{value:n,getSnapshot:e}}),r=s[0].inst,a=s[1];return bO(function(){r.value=n,r.getSnapshot=e,_m(r)&&a({inst:r})},[t,n,e]),vO(function(){return _m(r)&&a({inst:r}),t(function(){_m(r)&&a({inst:r})})},[t]),jO(n),n}function _m(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!xO(t,n)}catch{return!0}}function wO(t,e){return e()}var kO=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?wO:NO;UC.useSyncExternalStore=no.useSyncExternalStore!==void 0?no.useSyncExternalStore:kO;KC.exports=UC;var Wy=KC.exports;function rn(t){this.content=t}rn.prototype={constructor:rn,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var s=n&&n!=t?this.remove(n):this,r=s.find(t),a=s.content.slice();return r==-1?a.push(n||t,e):(a[r+1]=e,n&&(a[r]=n)),new rn(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new rn(n)},addToStart:function(t,e){return new rn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new rn(n)},addBefore:function(t,e,n){var s=this.remove(e),r=s.content.slice(),a=s.find(t);return r.splice(a==-1?r.length:a,0,e,n),new rn(r)},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=rn.from(t),t.size?new rn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=rn.from(t),t.size?new rn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=rn.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};rn.from=function(t){if(t instanceof rn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new rn(e)};function qC(t,e,n){for(let s=0;;s++){if(s==t.childCount||s==e.childCount)return t.childCount==e.childCount?null:n;let r=t.child(s),a=e.child(s);if(r==a){n+=r.nodeSize;continue}if(!r.sameMarkup(a))return n;if(r.isText&&r.text!=a.text){for(let l=0;r.text[l]==a.text[l];l++)n++;return n}if(r.content.size||a.content.size){let l=qC(r.content,a.content,n+1);if(l!=null)return l}n+=r.nodeSize}}function HC(t,e,n,s){for(let r=t.childCount,a=e.childCount;;){if(r==0||a==0)return r==a?null:{a:n,b:s};let l=t.child(--r),o=e.child(--a),c=l.nodeSize;if(l==o){n-=c,s-=c;continue}if(!l.sameMarkup(o))return{a:n,b:s};if(l.isText&&l.text!=o.text){let d=0,u=Math.min(l.text.length,o.text.length);for(;d<u&&l.text[l.text.length-d-1]==o.text[o.text.length-d-1];)d++,n--,s--;return{a:n,b:s}}if(l.content.size||o.content.size){let d=HC(l.content,o.content,n-1,s-1);if(d)return d}n-=c,s-=c}}class X{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let s=0;s<e.length;s++)this.size+=e[s].nodeSize}nodesBetween(e,n,s,r=0,a){for(let l=0,o=0;o<n;l++){let c=this.content[l],d=o+c.nodeSize;if(d>e&&s(c,r+o,a||null,l)!==!1&&c.content.size){let u=o+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,n-u),s,r+u)}o=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,s,r){let a="",l=!0;return this.nodesBetween(e,n,(o,c)=>{let d=o.isText?o.text.slice(Math.max(e,c)-c,n-c):o.isLeaf?r?typeof r=="function"?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&d||o.isTextblock)&&s&&(l?l=!1:a+=s),a+=d},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,s=e.firstChild,r=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(s)&&(r[r.length-1]=n.withText(n.text+s.text),a=1);a<e.content.length;a++)r.push(e.content[a]);return new X(r,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let s=[],r=0;if(n>e)for(let a=0,l=0;l<n;a++){let o=this.content[a],c=l+o.nodeSize;c>e&&((l<e||c>n)&&(o.isText?o=o.cut(Math.max(0,e-l),Math.min(o.text.length,n-l)):o=o.cut(Math.max(0,e-l-1),Math.min(o.content.size,n-l-1))),s.push(o),r+=o.nodeSize),l=c}return new X(s,r)}cutByIndex(e,n){return e==n?X.empty:e==0&&n==this.content.length?this:new X(this.content.slice(e,n))}replaceChild(e,n){let s=this.content[e];if(s==n)return this;let r=this.content.slice(),a=this.size+n.nodeSize-s.nodeSize;return r[e]=n,new X(r,a)}addToStart(e){return new X([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new X(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,s=0;n<this.content.length;n++){let r=this.content[n];e(r,s,n),s+=r.nodeSize}}findDiffStart(e,n=0){return qC(this,e,n)}findDiffEnd(e,n=this.size,s=e.size){return HC(this,e,n,s)}findIndex(e){if(e==0)return Zd(0,e);if(e==this.size)return Zd(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,s=0;;n++){let r=this.child(n),a=s+r.nodeSize;if(a>=e)return a==e?Zd(n+1,a):Zd(n,s);s=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return X.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new X(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return X.empty;let n,s=0;for(let r=0;r<e.length;r++){let a=e[r];s+=a.nodeSize,r&&a.isText&&e[r-1].sameMarkup(a)?(n||(n=e.slice(0,r)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new X(n||e,s)}static from(e){if(!e)return X.empty;if(e instanceof X)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new X([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}X.empty=new X([],0);const Vm={index:0,offset:0};function Zd(t,e){return Vm.index=t,Vm.offset=e,Vm}function ph(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let s=0;s<t.length;s++)if(!ph(t[s],e[s]))return!1}else{for(let s in t)if(!(s in e)||!ph(t[s],e[s]))return!1;for(let s in e)if(!(s in t))return!1}return!0}let tt=class Wg{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,s=!1;for(let r=0;r<e.length;r++){let a=e[r];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,r));else{if(a.type.excludes(this.type))return e;!s&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,r)),n.push(this),s=!0),n&&n.push(a)}}return n||(n=e.slice()),s||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ph(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let s=e.marks[n.type];if(!s)throw new RangeError(`There is no mark type ${n.type} in this schema`);let r=s.create(n.attrs);return s.checkAttrs(r.attrs),r}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let s=0;s<e.length;s++)if(!e[s].eq(n[s]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Wg.none;if(e instanceof Wg)return[e];let n=e.slice();return n.sort((s,r)=>s.type.rank-r.type.rank),n}};tt.none=[];class gh extends Error{}class me{constructor(e,n,s){this.content=e,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let s=QC(this.content,e+this.openStart,n);return s&&new me(s,this.openStart,this.openEnd)}removeBetween(e,n){return new me(WC(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return me.empty;let s=n.openStart||0,r=n.openEnd||0;if(typeof s!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new me(X.fromJSON(e,n.content),s,r)}static maxOpen(e,n=!0){let s=0,r=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)s++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)r++;return new me(e,s,r)}}me.empty=new me(X.empty,0,0);function WC(t,e,n){let{index:s,offset:r}=t.findIndex(e),a=t.maybeChild(s),{index:l,offset:o}=t.findIndex(n);if(r==e||a.isText){if(o!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(s!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(s,a.copy(WC(a.content,e-r-1,n-r-1)))}function QC(t,e,n,s){let{index:r,offset:a}=t.findIndex(e),l=t.maybeChild(r);if(a==e||l.isText)return s&&!s.canReplace(r,r,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=QC(l.content,e-a-1,n,l);return o&&t.replaceChild(r,l.copy(o))}function SO(t,e,n){if(n.openStart>t.depth)throw new gh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new gh("Inconsistent open depths");return GC(t,e,n,0)}function GC(t,e,n,s){let r=t.index(s),a=t.node(s);if(r==e.index(s)&&s<t.depth-n.openStart){let l=GC(t,e,n,s+1);return a.copy(a.content.replaceChild(r,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==s&&e.depth==s){let l=t.parent,o=l.content;return Aa(l,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:l,end:o}=CO(n,t);return Aa(a,ZC(t,l,o,e,s))}else return Aa(a,xh(t,e,s))}function JC(t,e){if(!e.type.compatibleContent(t.type))throw new gh("Cannot join "+e.type.name+" onto "+t.type.name)}function Qg(t,e,n){let s=t.node(n);return JC(s,e.node(n)),s}function Ea(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function ac(t,e,n,s){let r=(e||t).node(n),a=0,l=e?e.index(n):r.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Ea(t.nodeAfter,s),a++));for(let o=a;o<l;o++)Ea(r.child(o),s);e&&e.depth==n&&e.textOffset&&Ea(e.nodeBefore,s)}function Aa(t,e){return t.type.checkContent(e),t.copy(e)}function ZC(t,e,n,s,r){let a=t.depth>r&&Qg(t,e,r+1),l=s.depth>r&&Qg(n,s,r+1),o=[];return ac(null,t,r,o),a&&l&&e.index(r)==n.index(r)?(JC(a,l),Ea(Aa(a,ZC(t,e,n,s,r+1)),o)):(a&&Ea(Aa(a,xh(t,e,r+1)),o),ac(e,n,r,o),l&&Ea(Aa(l,xh(n,s,r+1)),o)),ac(s,null,r,o),new X(o)}function xh(t,e,n){let s=[];if(ac(null,t,n,s),t.depth>n){let r=Qg(t,e,n+1);Ea(Aa(r,xh(t,e,n+1)),s)}return ac(e,null,n,s),new X(s)}function CO(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)r=e.node(a).copy(X.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}class Kc{constructor(e,n,s){this.pos=e,this.path=n,this.parentOffset=s,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],r=e.child(n);return s?e.child(n).cut(s):r}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let s=this.path[n*3],r=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)r+=s.child(a).nodeSize;return r}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return tt.none;if(this.textOffset)return e.child(n).marks;let s=e.maybeChild(n-1),r=e.maybeChild(n);if(!s){let o=s;s=r,r=o}let a=s.marks;for(var l=0;l<a.length;l++)a[l].type.spec.inclusive===!1&&(!r||!a[l].isInSet(r.marks))&&(a=a[l--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let s=n.marks,r=e.parent.maybeChild(e.index());for(var a=0;a<s.length;a++)s[a].type.spec.inclusive===!1&&(!r||!s[a].isInSet(r.marks))&&(s=s[a--].removeFromSet(s));return s}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);s>=0;s--)if(e.pos<=this.end(s)&&(!n||n(this.node(s))))return new yh(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let s=[],r=0,a=n;for(let l=e;;){let{index:o,offset:c}=l.content.findIndex(a),d=a-c;if(s.push(l,o,r+c),!d||(l=l.child(o),l.isText))break;a=d-1,r+=c+1}return new Kc(n,s,a)}static resolveCached(e,n){let s=nj.get(e);if(s)for(let a=0;a<s.elts.length;a++){let l=s.elts[a];if(l.pos==n)return l}else nj.set(e,s=new EO);let r=s.elts[s.i]=Kc.resolve(e,n);return s.i=(s.i+1)%AO,r}}class EO{constructor(){this.elts=[],this.i=0}}const AO=12,nj=new WeakMap;class yh{constructor(e,n,s){this.$from=e,this.$to=n,this.depth=s}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 DO=Object.create(null);class _s{constructor(e,n,s,r=tt.none){this.type=e,this.attrs=n,this.marks=r,this.content=s||X.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,s,r=0){this.content.nodesBetween(e,n,s,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,s,r){return this.content.textBetween(e,n,s,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,s){return this.type==e&&ph(this.attrs,n||e.defaultAttrs||DO)&&tt.sameSet(this.marks,s||tt.none)}copy(e=null){return e==this.content?this:new _s(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _s(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,s=!1){if(e==n)return me.empty;let r=this.resolve(e),a=this.resolve(n),l=s?0:r.sharedDepth(n),o=r.start(l),d=r.node(l).content.cut(r.pos-o,a.pos-o);return new me(d,r.depth-l,a.depth-l)}replace(e,n,s){return SO(this.resolve(e),this.resolve(n),s)}nodeAt(e){for(let n=this;;){let{index:s,offset:r}=n.content.findIndex(e);if(n=n.maybeChild(s),!n)return null;if(r==e||n.isText)return n;e-=r+1}}childAfter(e){let{index:n,offset:s}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:s}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:s}=this.content.findIndex(e);if(s<e)return{node:this.content.child(n),index:n,offset:s};let r=this.content.child(n-1);return{node:r,index:n-1,offset:s-r.nodeSize}}resolve(e){return Kc.resolveCached(this,e)}resolveNoCache(e){return Kc.resolve(this,e)}rangeHasMark(e,n,s){let r=!1;return n>e&&this.nodesBetween(e,n,a=>(s.isInSet(a.marks)&&(r=!0),!r)),r}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()+")"),YC(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,s=X.empty,r=0,a=s.childCount){let l=this.contentMatchAt(e).matchFragment(s,r,a),o=l&&l.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let c=r;c<a;c++)if(!this.type.allowsMarks(s.child(c).marks))return!1;return!0}canReplaceWith(e,n,s,r){if(r&&!this.type.allowsMarks(r))return!1;let a=this.contentMatchAt(e).matchType(s),l=a&&a.matchFragment(this.content,n);return l?l.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=tt.none;for(let n=0;n<this.marks.length;n++){let s=this.marks[n];s.type.checkAttrs(s.attrs),e=s.addToSet(e)}if(!tt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let s;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,s)}let r=X.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,r,s);return a.type.checkAttrs(a.attrs),a}}_s.prototype.text=void 0;class vh extends _s{constructor(e,n,s,r){if(super(e,n,null,r),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):YC(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new vh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new vh(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function YC(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class _a{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let s=new MO(e,n);if(s.next==null)return _a.empty;let r=XC(s);s.next&&s.err("Unexpected trailing text");let a=FO(LO(r));return zO(a,s),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,s=e.childCount){let r=this;for(let a=n;r&&a<s;a++)r=r.matchType(e.child(a).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let s=0;s<e.next.length;s++)if(this.next[n].type==e.next[s].type)return!0;return!1}fillBefore(e,n=!1,s=0){let r=[this];function a(l,o){let c=l.matchFragment(e,s);if(c&&(!n||c.validEnd))return X.from(o.map(d=>d.createAndFill()));for(let d=0;d<l.next.length;d++){let{type:u,next:h}=l.next[d];if(!(u.isText||u.hasRequiredAttrs())&&r.indexOf(h)==-1){r.push(h);let m=a(h,o.concat(u));if(m)return m}}return null}return a(this,[])}findWrapping(e){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==e)return this.wrapCache[s+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let r=s.shift(),a=r.match;if(a.matchType(e)){let l=[];for(let o=r;o.type;o=o.via)l.push(o.type);return l.reverse()}for(let l=0;l<a.next.length;l++){let{type:o,next:c}=a.next[l];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!r.type||c.validEnd)&&(s.push({match:o.contentMatch,type:o,via:r}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(s){e.push(s);for(let r=0;r<s.next.length;r++)e.indexOf(s.next[r].next)==-1&&n(s.next[r].next)}return n(this),e.map((s,r)=>{let a=r+(s.validEnd?"*":" ")+" ";for(let l=0;l<s.next.length;l++)a+=(l?", ":"")+s.next[l].type.name+"->"+e.indexOf(s.next[l].next);return a}).join(`
`)}}_a.empty=new _a(!0);class MO{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function XC(t){let e=[];do e.push(TO(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function TO(t){let e=[];do e.push(PO(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function PO(t){let e=OO(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=IO(t,e);else break;return e}function sj(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function IO(t,e){let n=sj(t),s=n;return t.eat(",")&&(t.next!="}"?s=sj(t):s=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:s,expr:e}}function RO(t,e){let n=t.nodeTypes,s=n[e];if(s)return[s];let r=[];for(let a in n){let l=n[a];l.isInGroup(e)&&r.push(l)}return r.length==0&&t.err("No node type or group '"+e+"' found"),r}function OO(t){if(t.eat("(")){let e=XC(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=RO(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function LO(t){let e=[[]];return r(a(t,0),n()),e;function n(){return e.push([])-1}function s(l,o,c){let d={term:c,to:o};return e[l].push(d),d}function r(l,o){l.forEach(c=>c.to=o)}function a(l,o){if(l.type=="choice")return l.exprs.reduce((c,d)=>c.concat(a(d,o)),[]);if(l.type=="seq")for(let c=0;;c++){let d=a(l.exprs[c],o);if(c==l.exprs.length-1)return d;r(d,o=n())}else if(l.type=="star"){let c=n();return s(o,c),r(a(l.expr,c),c),[s(c)]}else if(l.type=="plus"){let c=n();return r(a(l.expr,o),c),r(a(l.expr,c),c),[s(c)]}else{if(l.type=="opt")return[s(o)].concat(a(l.expr,o));if(l.type=="range"){let c=o;for(let d=0;d<l.min;d++){let u=n();r(a(l.expr,c),u),c=u}if(l.max==-1)r(a(l.expr,c),c);else for(let d=l.min;d<l.max;d++){let u=n();s(c,u),r(a(l.expr,c),u),c=u}return[s(c)]}else{if(l.type=="name")return[s(o,void 0,l.value)];throw new Error("Unknown expr type")}}}}function e2(t,e){return e-t}function rj(t,e){let n=[];return s(e),n.sort(e2);function s(r){let a=t[r];if(a.length==1&&!a[0].term)return s(a[0].to);n.push(r);for(let l=0;l<a.length;l++){let{term:o,to:c}=a[l];!o&&n.indexOf(c)==-1&&s(c)}}}function FO(t){let e=Object.create(null);return n(rj(t,0));function n(s){let r=[];s.forEach(l=>{t[l].forEach(({term:o,to:c})=>{if(!o)return;let d;for(let u=0;u<r.length;u++)r[u][0]==o&&(d=r[u][1]);rj(t,c).forEach(u=>{d||r.push([o,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let a=e[s.join(",")]=new _a(s.indexOf(t.length-1)>-1);for(let l=0;l<r.length;l++){let o=r[l][1].sort(e2);a.next.push({type:r[l][0],next:e[o.join(",")]||n(o)})}return a}}function zO(t,e){for(let n=0,s=[t];n<s.length;n++){let r=s[n],a=!r.validEnd,l=[];for(let o=0;o<r.next.length;o++){let{type:c,next:d}=r.next[o];l.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),s.indexOf(d)==-1&&s.push(d)}a&&e.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function t2(t){let e=Object.create(null);for(let n in t){let s=t[n];if(!s.hasDefault)return null;e[n]=s.default}return e}function n2(t,e){let n=Object.create(null);for(let s in t){let r=e&&e[s];if(r===void 0){let a=t[s];if(a.hasDefault)r=a.default;else throw new RangeError("No value supplied for attribute "+s)}n[s]=r}return n}function s2(t,e,n,s){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let r in t){let a=t[r];a.validate&&a.validate(e[r])}}function r2(t,e){let n=Object.create(null);if(e)for(let s in e)n[s]=new BO(t,s,e[s]);return n}let ij=class i2{constructor(e,n,s){this.name=e,this.schema=n,this.spec=s,this.markSet=null,this.groups=s.group?s.group.split(" "):[],this.attrs=r2(e,s.attrs),this.defaultAttrs=t2(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(s.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==_a.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:n2(this.attrs,e)}create(e=null,n,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new _s(this,this.computeAttrs(e),X.from(n),tt.setFrom(s))}createChecked(e=null,n,s){return n=X.from(n),this.checkContent(n),new _s(this,this.computeAttrs(e),n,tt.setFrom(s))}createAndFill(e=null,n,s){if(e=this.computeAttrs(e),n=X.from(n),n.size){let l=this.contentMatch.fillBefore(n);if(!l)return null;n=l.append(n)}let r=this.contentMatch.matchFragment(n),a=r&&r.fillBefore(X.empty,!0);return a?new _s(this,e,n.append(a),tt.setFrom(s)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let s=0;s<e.childCount;s++)if(!this.allowsMarks(e.child(s).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){s2(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let s=0;s<e.length;s++)this.allowsMarkType(e[s].type)?n&&n.push(e[s]):n||(n=e.slice(0,s));return n?n.length?n:tt.none:e}static compile(e,n){let s=Object.create(null);e.forEach((a,l)=>s[a]=new i2(a,n,l));let r=n.spec.topNode||"doc";if(!s[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let a in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function $O(t,e,n){let s=n.split("|");return r=>{let a=r===null?"null":typeof r;if(s.indexOf(a)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${t}, got ${a}`)}}class BO{constructor(e,n,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?$O(e,n,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Ff{constructor(e,n,s,r){this.name=e,this.rank=n,this.schema=s,this.spec=r,this.attrs=r2(e,r.attrs),this.excluded=null;let a=t2(this.attrs);this.instance=a?new tt(this,a):null}create(e=null){return!e&&this.instance?this.instance:new tt(this,n2(this.attrs,e))}static compile(e,n){let s=Object.create(null),r=0;return e.forEach((a,l)=>s[a]=new Ff(a,r++,n,l)),s}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){s2(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class a2{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let r in e)n[r]=e[r];n.nodes=rn.from(e.nodes),n.marks=rn.from(e.marks||{}),this.nodes=ij.compile(this.spec.nodes,this),this.marks=Ff.compile(this.spec.marks,this);let s=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let a=this.nodes[r],l=a.spec.content||"",o=a.spec.marks;if(a.contentMatch=s[l]||(s[l]=_a.parse(l,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=o=="_"?null:o?aj(this,o.split(" ")):o==""||!a.inlineContent?[]:null}for(let r in this.marks){let a=this.marks[r],l=a.spec.excludes;a.excluded=l==null?[a]:l==""?[]:aj(this,l.split(" "))}this.nodeFromJSON=r=>_s.fromJSON(this,r),this.markFromJSON=r=>tt.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,s,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ij){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,s,r)}text(e,n){let s=this.nodes.text;return new vh(s,s.defaultAttrs,e,tt.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function aj(t,e){let n=[];for(let s=0;s<e.length;s++){let r=e[s],a=t.marks[r],l=a;if(a)n.push(a);else for(let o in t.marks){let c=t.marks[o];(r=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(r)>-1)&&n.push(l=c)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return n}function _O(t){return t.tag!=null}function VO(t){return t.style!=null}class Li{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let s=this.matchedStyles=[];n.forEach(r=>{if(_O(r))this.tags.push(r);else if(VO(r)){let a=/[^=]*/.exec(r.style)[0];s.indexOf(a)<0&&s.push(a),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let a=e.nodes[r.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let s=new oj(this,n,!1);return s.addAll(e,tt.none,n.from,n.to),s.finish()}parseSlice(e,n={}){let s=new oj(this,n,!0);return s.addAll(e,tt.none,n.from,n.to),me.maxOpen(s.finish())}matchTag(e,n,s){for(let r=s?this.tags.indexOf(s)+1:0;r<this.tags.length;r++){let a=this.tags[r];if(qO(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let l=a.getAttrs(e);if(l===!1)continue;a.attrs=l||void 0}return a}}}matchStyle(e,n,s,r){for(let a=r?this.styles.indexOf(r)+1:0;a<this.styles.length;a++){let l=this.styles[a],o=l.style;if(!(o.indexOf(e)!=0||l.context&&!s.matchesContext(l.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(l.getAttrs){let c=l.getAttrs(n);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(e){let n=[];function s(r){let a=r.priority==null?50:r.priority,l=0;for(;l<n.length;l++){let o=n[l];if((o.priority==null?50:o.priority)<a)break}n.splice(l,0,r)}for(let r in e.marks){let a=e.marks[r].spec.parseDOM;a&&a.forEach(l=>{s(l=cj(l)),l.mark||l.ignore||l.clearMark||(l.mark=r)})}for(let r in e.nodes){let a=e.nodes[r].spec.parseDOM;a&&a.forEach(l=>{s(l=cj(l)),l.node||l.ignore||l.mark||(l.node=r)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Li(e,Li.schemaRules(e)))}}const l2={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},KO={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},o2={ol:!0,ul:!0},Uc=1,Gg=2,lc=4;function lj(t,e,n){return e!=null?(e?Uc:0)|(e==="full"?Gg:0):t&&t.whitespace=="pre"?Uc|Gg:n&~lc}class Yd{constructor(e,n,s,r,a,l){this.type=e,this.attrs=n,this.marks=s,this.solid=r,this.options=l,this.content=[],this.activeMarks=tt.none,this.match=a||(l&lc?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(X.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,r;return(r=s.findWrapping(e.type))?(this.match=s,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Uc)){let s=this.content[this.content.length-1],r;if(s&&s.isText&&(r=/[ \t\r\n\u000c]+$/.exec(s.text))){let a=s;s.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-r[0].length))}}let n=X.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(X.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!l2.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class oj{constructor(e,n,s){this.parser=e,this.options=n,this.isOpen=s,this.open=0,this.localPreserveWS=!1;let r=n.topNode,a,l=lj(null,n.preserveWhitespace,0)|(s?lc:0);r?a=new Yd(r.type,r.attrs,tt.none,!0,n.topMatch||r.type.contentMatch,l):s?a=new Yd(null,null,tt.none,!0,null,l):a=new Yd(e.schema.topNodeType,null,tt.none,!0,null,l),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let s=e.nodeValue,r=this.top,a=r.options&Gg?"full":this.localPreserveWS||(r.options&Uc)>0,{schema:l}=this.parser;if(a==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(a)if(a==="full")s=s.replace(/\r\n?/g,`
`);else if(l.linebreakReplacement&&/[\r\n]/.test(s)&&this.top.findWrapping(l.linebreakReplacement.create())){let o=s.split(/\r?\n|\r/);for(let c=0;c<o.length;c++)c&&this.insertNode(l.linebreakReplacement.create(),n,!0),o[c]&&this.insertNode(l.text(o[c]),n,!/\S/.test(o[c]));s=""}else s=s.replace(/\r?\n|\r/g," ");else if(s=s.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(s)&&this.open==this.nodes.length-1){let o=r.content[r.content.length-1],c=e.previousSibling;(!o||c&&c.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(s=s.slice(1))}s&&this.insertNode(l.text(s),n,!/\S/.test(s)),this.findInText(e)}else this.findInside(e)}addElement(e,n,s){let r=this.localPreserveWS,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let l=e.nodeName.toLowerCase(),o;o2.hasOwnProperty(l)&&this.parser.normalizeLists&&UO(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,s));e:if(c?c.ignore:KO.hasOwnProperty(l))this.findInside(e),this.ignoreFallback(e,n);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 d,u=this.needsBlock;if(l2.hasOwnProperty(l))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),d=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let h=c&&c.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),d&&this.sync(a),this.needsBlock=u}else{let d=this.readStyles(e,n);d&&this.addElementByRule(e,c,d,c.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let s=e.style;if(s&&s.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let a=this.parser.matchedStyles[r],l=s.getPropertyValue(a);if(l)for(let o=void 0;;){let c=this.parser.matchStyle(a,l,this,o);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(d=>!c.clearMark(d)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)o=c;else break}}return n}addElementByRule(e,n,s,r){let a,l;if(n.node)if(l=this.parser.schema.nodes[n.node],l.isLeaf)this.insertNode(l.create(n.attrs),s,e.nodeName=="BR")||this.leafFallback(e,s);else{let c=this.enter(l,n.attrs||null,s,n.preserveWhitespace);c&&(a=!0,s=c)}else{let c=this.parser.schema.marks[n.mark];s=s.concat(c.create(n.attrs))}let o=this.top;if(l&&l.isLeaf)this.findInside(e);else if(r)this.addElement(e,s,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,s,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,s),this.findAround(e,c,!1)}a&&this.sync(o)&&this.open--}addAll(e,n,s,r){let a=s||0;for(let l=s?e.childNodes[s]:e.firstChild,o=r==null?null:e.childNodes[r];l!=o;l=l.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(l,n);this.findAtPoint(e,a)}findPlace(e,n,s){let r,a;for(let l=this.open,o=0;l>=0;l--){let c=this.nodes[l],d=c.findWrapping(e);if(d&&(!r||r.length>d.length+o)&&(r=d,a=c,!d.length))break;if(c.solid){if(s)break;o+=2}}if(!r)return null;this.sync(a);for(let l=0;l<r.length;l++)n=this.enterInner(r[l],null,n,!1);return n}insertNode(e,n,s){if(e.isInline&&this.needsBlock&&!this.top.type){let a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let r=this.findPlace(e,n,s);if(r){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let l=tt.none;for(let o of r.concat(e.marks))(a.type?a.type.allowsMarkType(o.type):dj(o.type,e.type))&&(l=o.addToSet(l));return a.content.push(e.mark(l)),!0}return!1}enter(e,n,s,r){let a=this.findPlace(e.create(n),s,!1);return a&&(a=this.enterInner(e,n,s,!0,r)),a}enterInner(e,n,s,r=!1,a){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(e);let o=lj(e,a,l.options);l.options&lc&&l.content.length==0&&(o|=lc);let c=tt.none;return s=s.filter(d=>(l.type?l.type.allowsMarkType(d.type):dj(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Yd(e,n,c,r,null,o)),this.open++,s}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Uc)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let r=s.length-1;r>=0;r--)e+=s[r].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==e&&this.find[s].offset==n&&(this.find[s].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,s){if(e!=n&&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)&&n.compareDocumentPosition(this.find[r].node)&(s?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),s=this.options.context,r=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),a=-(s?s.depth+1:0)+(r?0:1),l=(o,c)=>{for(;o>=0;o--){let d=n[o];if(d==""){if(o==n.length-1||o==0)continue;for(;c>=a;c--)if(l(o-1,c))return!0;return!1}else{let u=c>0||c==0&&r?this.nodes[c].type:s&&c>=a?s.node(c-a).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}}function UO(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&o2.hasOwnProperty(s)&&n?(n.appendChild(e),e=n):s=="li"?n=e:s&&(n=null)}}function qO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function cj(t){let e={};for(let n in t)e[n]=t[n];return e}function dj(t,e){let n=e.schema.nodes;for(let s in n){let r=n[s];if(!r.allowsMarkType(t))continue;let a=[],l=o=>{a.push(o);for(let c=0;c<o.edgeCount;c++){let{type:d,next:u}=o.edge(c);if(d==e||a.indexOf(u)<0&&l(u))return!0}};if(l(r.contentMatch))return!0}}class Ga{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},s){s||(s=Km(n).createDocumentFragment());let r=s,a=[];return e.forEach(l=>{if(a.length||l.marks.length){let o=0,c=0;for(;o<a.length&&c<l.marks.length;){let d=l.marks[c];if(!this.marks[d.type.name]){c++;continue}if(!d.eq(a[o][0])||d.type.spec.spanning===!1)break;o++,c++}for(;o<a.length;)r=a.pop()[1];for(;c<l.marks.length;){let d=l.marks[c++],u=this.serializeMark(d,l.isInline,n);u&&(a.push([d,r]),r.appendChild(u.dom),r=u.contentDOM||u.dom)}}r.appendChild(this.serializeNodeInner(l,n))}),s}serializeNodeInner(e,n){let{dom:s,contentDOM:r}=Au(Km(n),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,r)}return s}serializeNode(e,n={}){let s=this.serializeNodeInner(e,n);for(let r=e.marks.length-1;r>=0;r--){let a=this.serializeMark(e.marks[r],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(s),s=a.dom)}return s}serializeMark(e,n,s={}){let r=this.marks[e.type.name];return r&&Au(Km(s),r(e,n),null,e.attrs)}static renderSpec(e,n,s=null,r){return Au(e,n,s,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ga(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=uj(e.nodes);return n.text||(n.text=s=>s.text),n}static marksFromSchema(e){return uj(e.marks)}}function uj(t){let e={};for(let n in t){let s=t[n].spec.toDOM;s&&(e[n]=s)}return e}function Km(t){return t.document||window.document}const hj=new WeakMap;function HO(t){let e=hj.get(t);return e===void 0&&hj.set(t,e=WO(t)),e}function WO(t){let e=null;function n(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let r=0;r<s.length;r++)n(s[r]);else for(let r in s)n(s[r])}return n(t),e}function Au(t,e,n,s){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],a;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(a=HO(s))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=r.indexOf(" ");l>0&&(n=r.slice(0,l),r=r.slice(l+1));let o,c=n?t.createElementNS(n,r):t.createElement(r),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let h in d)if(d[h]!=null){let m=h.indexOf(" ");m>0?c.setAttributeNS(h.slice(0,m),h.slice(m+1),d[h]):h=="style"&&c.style?c.style.cssText=d[h]:c.setAttribute(h,d[h])}}for(let h=u;h<e.length;h++){let m=e[h];if(m===0){if(h<e.length-1||h>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:f,contentDOM:p}=Au(t,m,n,s);if(c.appendChild(f),p){if(o)throw new RangeError("Multiple content holes");o=p}}}return{dom:c,contentDOM:o}}const c2=65535,d2=Math.pow(2,16);function QO(t,e){return t+e*d2}function fj(t){return t&c2}function GO(t){return(t-(t&c2))/d2}const u2=1,h2=2,Du=4,f2=8;class Jg{constructor(e,n,s){this.pos=e,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&f2)>0}get deletedBefore(){return(this.delInfo&(u2|Du))>0}get deletedAfter(){return(this.delInfo&(h2|Du))>0}get deletedAcross(){return(this.delInfo&Du)>0}}class ss{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ss.empty)return ss.empty}recover(e){let n=0,s=fj(e);if(!this.inverted)for(let r=0;r<s;r++)n+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[s*3]+n+GO(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,s){let r=0,a=this.inverted?2:1,l=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?r:0);if(c>e)break;let d=this.ranges[o+a],u=this.ranges[o+l],h=c+d;if(e<=h){let m=d?e==c?-1:e==h?1:n:n,f=c+r+(m<0?0:u);if(s)return f;let p=e==(n<0?c:h)?null:QO(o/3,e-c),g=e==c?h2:e==h?u2:Du;return(n<0?e!=c:e!=h)&&(g|=f2),new Jg(f,g,p)}r+=u-d}return s?e+r:new Jg(e+r,0,null)}touches(e,n){let s=0,r=fj(n),a=this.inverted?2:1,l=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let c=this.ranges[o]-(this.inverted?s:0);if(c>e)break;let d=this.ranges[o+a],u=c+d;if(e<=u&&o==r*3)return!0;s+=this.ranges[o+l]-d}return!1}forEach(e){let n=this.inverted?2:1,s=this.inverted?1:2;for(let r=0,a=0;r<this.ranges.length;r+=3){let l=this.ranges[r],o=l-(this.inverted?a:0),c=l+(this.inverted?0:a),d=this.ranges[r+n],u=this.ranges[r+s];e(o,o+d,c,c+u),a+=u-d}}invert(){return new ss(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ss.empty:new ss(e<0?[0,-e,0]:[0,0,e])}}ss.empty=new ss([]);class qc{constructor(e,n,s=0,r=e?e.length:0){this.mirror=n,this.from=s,this.to=r,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new qc(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,s=this._maps.length;n<e._maps.length;n++){let r=e.getMirror(n);this.appendMap(e._maps[n],r!=null&&r<n?s+r:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,s=this._maps.length+e._maps.length;n>=0;n--){let r=e.getMirror(n);this.appendMap(e._maps[n].invert(),r!=null&&r>n?s-r-1:void 0)}}invert(){let e=new qc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let s=this.from;s<this.to;s++)e=this._maps[s].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,s){let r=0;for(let a=this.from;a<this.to;a++){let l=this._maps[a],o=l.mapResult(e,n);if(o.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return s?e:new Jg(e,r,null)}}const Um=Object.create(null);class Nn{getMap(){return ss.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=Um[n.stepType];if(!s)throw new RangeError(`No step type ${n.stepType} defined`);return s.fromJSON(e,n)}static jsonID(e,n){if(e in Um)throw new RangeError("Duplicate use of step JSON ID "+e);return Um[e]=n,n.prototype.jsonID=e,n}}class zt{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new zt(e,null)}static fail(e){return new zt(null,e)}static fromReplace(e,n,s,r){try{return zt.ok(e.replace(n,s,r))}catch(a){if(a instanceof gh)return zt.fail(a.message);throw a}}}function Qy(t,e,n){let s=[];for(let r=0;r<t.childCount;r++){let a=t.child(r);a.content.size&&(a=a.copy(Qy(a.content,e,a))),a.isInline&&(a=e(a,n,r)),s.push(a)}return X.fromArray(s)}class wi extends Nn{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=e.resolve(this.from),r=s.node(s.sharedDepth(this.to)),a=new me(Qy(n.content,(l,o)=>!l.isAtom||!o.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),r),n.openStart,n.openEnd);return zt.fromReplace(e,this.from,this.to,a)}invert(){return new zs(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new wi(n.pos,s.pos,this.mark)}merge(e){return e instanceof wi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new wi(n.from,n.to,e.markFromJSON(n.mark))}}Nn.jsonID("addMark",wi);class zs extends Nn{constructor(e,n,s){super(),this.from=e,this.to=n,this.mark=s}apply(e){let n=e.slice(this.from,this.to),s=new me(Qy(n.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),n.openStart,n.openEnd);return zt.fromReplace(e,this.from,this.to,s)}invert(){return new wi(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new zs(n.pos,s.pos,this.mark)}merge(e){return e instanceof zs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new zs(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new zs(n.from,n.to,e.markFromJSON(n.mark))}}Nn.jsonID("removeMark",zs);class ki extends Nn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return zt.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return zt.fromReplace(e,this.pos,this.pos+1,new me(X.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(s))return new ki(this.pos,n.marks[r]);return new ki(this.pos,this.mark)}}return new Va(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ki(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ki(n.pos,e.markFromJSON(n.mark))}}Nn.jsonID("addNodeMark",ki);class Va extends Nn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return zt.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return zt.fromReplace(e,this.pos,this.pos+1,new me(X.from(s),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ki(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Va(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Va(n.pos,e.markFromJSON(n.mark))}}Nn.jsonID("removeNodeMark",Va);class Yt extends Nn{constructor(e,n,s,r=!1){super(),this.from=e,this.to=n,this.slice=s,this.structure=r}apply(e){return this.structure&&Zg(e,this.from,this.to)?zt.fail("Structure replace would overwrite content"):zt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ss([this.from,this.to-this.from,this.slice.size])}invert(e){return new Yt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return n.deletedAcross&&s.deletedAcross?null:new Yt(n.pos,Math.max(n.pos,s.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Yt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?me.empty:new me(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Yt(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?me.empty:new me(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Yt(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Yt(n.from,n.to,me.fromJSON(e,n.slice),!!n.structure)}}Nn.jsonID("replace",Yt);class en extends Nn{constructor(e,n,s,r,a,l,o=!1){super(),this.from=e,this.to=n,this.gapFrom=s,this.gapTo=r,this.slice=a,this.insert=l,this.structure=o}apply(e){if(this.structure&&(Zg(e,this.from,this.gapFrom)||Zg(e,this.gapTo,this.to)))return zt.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return zt.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,n.content);return s?zt.fromReplace(e,this.from,this.to,s):zt.fail("Content does not fit in gap")}getMap(){return new ss([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new en(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),s=e.mapResult(this.to,-1),r=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?s.pos:e.map(this.gapTo,1);return n.deletedAcross&&s.deletedAcross||r<n.pos||a>s.pos?null:new en(n.pos,s.pos,r,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new en(n.from,n.to,n.gapFrom,n.gapTo,me.fromJSON(e,n.slice),n.insert,!!n.structure)}}Nn.jsonID("replaceAround",en);function Zg(t,e,n){let s=t.resolve(e),r=n-e,a=s.depth;for(;r>0&&a>0&&s.indexAfter(a)==s.node(a).childCount;)a--,r--;if(r>0){let l=s.node(a).maybeChild(s.indexAfter(a));for(;r>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,r--}}return!1}function JO(t,e,n,s){let r=[],a=[],l,o;t.doc.nodesBetween(e,n,(c,d,u)=>{if(!c.isInline)return;let h=c.marks;if(!s.isInSet(h)&&u.type.allowsMarkType(s.type)){let m=Math.max(d,e),f=Math.min(d+c.nodeSize,n),p=s.addToSet(h);for(let g=0;g<h.length;g++)h[g].isInSet(p)||(l&&l.to==m&&l.mark.eq(h[g])?l.to=f:r.push(l=new zs(m,f,h[g])));o&&o.to==m?o.to=f:a.push(o=new wi(m,f,s))}}),r.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function ZO(t,e,n,s){let r=[],a=0;t.doc.nodesBetween(e,n,(l,o)=>{if(!l.isInline)return;a++;let c=null;if(s instanceof Ff){let d=l.marks,u;for(;u=s.isInSet(d);)(c||(c=[])).push(u),d=u.removeFromSet(d)}else s?s.isInSet(l.marks)&&(c=[s]):c=l.marks;if(c&&c.length){let d=Math.min(o+l.nodeSize,n);for(let u=0;u<c.length;u++){let h=c[u],m;for(let f=0;f<r.length;f++){let p=r[f];p.step==a-1&&h.eq(r[f].style)&&(m=p)}m?(m.to=d,m.step=a):r.push({style:h,from:Math.max(o,e),to:d,step:a})}}}),r.forEach(l=>t.step(new zs(l.from,l.to,l.style)))}function Gy(t,e,n,s=n.contentMatch,r=!0){let a=t.doc.nodeAt(e),l=[],o=e+1;for(let c=0;c<a.childCount;c++){let d=a.child(c),u=o+d.nodeSize,h=s.matchType(d.type);if(!h)l.push(new Yt(o,u,me.empty));else{s=h;for(let m=0;m<d.marks.length;m++)n.allowsMarkType(d.marks[m].type)||t.step(new zs(o,u,d.marks[m]));if(r&&d.isText&&n.whitespace!="pre"){let m,f=/\r?\n|\r/g,p;for(;m=f.exec(d.text);)p||(p=new me(X.from(n.schema.text(" ",n.allowedMarks(d.marks))),0,0)),l.push(new Yt(o+m.index,o+m.index+m[0].length,p))}}o=u}if(!s.validEnd){let c=s.fillBefore(X.empty,!0);t.replace(o,o,new me(c,0,0))}for(let c=l.length-1;c>=0;c--)t.step(l[c])}function YO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function vo(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let s=t.depth,r=0,a=0;;--s){let l=t.$from.node(s),o=t.$from.index(s)+r,c=t.$to.indexAfter(s)-a;if(s<t.depth&&l.canReplace(o,c,n))return s;if(s==0||l.type.spec.isolating||!YO(l,o,c))break;o&&(r=1),c<l.childCount&&(a=1)}return null}function XO(t,e,n){let{$from:s,$to:r,depth:a}=e,l=s.before(a+1),o=r.after(a+1),c=l,d=o,u=X.empty,h=0;for(let p=a,g=!1;p>n;p--)g||s.index(p)>0?(g=!0,u=X.from(s.node(p).copy(u)),h++):c--;let m=X.empty,f=0;for(let p=a,g=!1;p>n;p--)g||r.after(p+1)<r.end(p)?(g=!0,m=X.from(r.node(p).copy(m)),f++):d++;t.step(new en(c,d,l,o,new me(u.append(m),h,f),u.size-h,!0))}function Jy(t,e,n=null,s=t){let r=eL(t,e),a=r&&tL(s,e);return a?r.map(mj).concat({type:e,attrs:n}).concat(a.map(mj)):null}function mj(t){return{type:t,attrs:null}}function eL(t,e){let{parent:n,startIndex:s,endIndex:r}=t,a=n.contentMatchAt(s).findWrapping(e);if(!a)return null;let l=a.length?a[0]:e;return n.canReplaceWith(s,r,l)?a:null}function tL(t,e){let{parent:n,startIndex:s,endIndex:r}=t,a=n.child(s),l=e.contentMatch.findWrapping(a.type);if(!l)return null;let c=(l.length?l[l.length-1]:e).contentMatch;for(let d=s;c&&d<r;d++)c=c.matchType(n.child(d).type);return!c||!c.validEnd?null:l}function nL(t,e,n){let s=X.empty;for(let l=n.length-1;l>=0;l--){if(s.size){let o=n[l].type.contentMatch.matchFragment(s);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=X.from(n[l].type.create(n[l].attrs,s))}let r=e.start,a=e.end;t.step(new en(r,a,r,a,new me(s,0,0),n.length,!0))}function sL(t,e,n,s,r){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(l,o)=>{let c=typeof r=="function"?r(l):r;if(l.isTextblock&&!l.hasMarkup(s,c)&&rL(t.doc,t.mapping.slice(a).map(o),s)){let d=null;if(s.schema.linebreakReplacement){let f=s.whitespace=="pre",p=!!s.contentMatch.matchType(s.schema.linebreakReplacement);f&&!p?d=!1:!f&&p&&(d=!0)}d===!1&&p2(t,l,o,a),Gy(t,t.mapping.slice(a).map(o,1),s,void 0,d===null);let u=t.mapping.slice(a),h=u.map(o,1),m=u.map(o+l.nodeSize,1);return t.step(new en(h,m,h+1,m-1,new me(X.from(s.create(c,null,l.marks)),0,0),1,!0)),d===!0&&m2(t,l,o,a),!1}})}function m2(t,e,n,s){e.forEach((r,a)=>{if(r.isText){let l,o=/\r?\n|\r/g;for(;l=o.exec(r.text);){let c=t.mapping.slice(s).map(n+1+a+l.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function p2(t,e,n,s){e.forEach((r,a)=>{if(r.type==r.type.schema.linebreakReplacement){let l=t.mapping.slice(s).map(n+1+a);t.replaceWith(l,l+1,e.type.schema.text(`
`))}})}function rL(t,e,n){let s=t.resolve(e),r=s.index();return s.parent.canReplaceWith(r,r+1,n)}function iL(t,e,n,s,r){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let l=n.create(s,null,r||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,l);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new en(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new me(X.from(l),0,0),1,!0))}function Rr(t,e,n=1,s){let r=t.resolve(e),a=r.depth-n,l=s&&s[s.length-1]||r.parent;if(a<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!l.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let d=r.depth-1,u=n-2;d>a;d--,u--){let h=r.node(d),m=r.index(d);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(m,h.childCount),p=s&&s[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let g=s&&s[u]||h;if(!h.canReplace(m+1,h.childCount)||!g.type.validContent(f))return!1}let o=r.indexAfter(a),c=s&&s[0];return r.node(a).canReplaceWith(o,o,c?c.type:r.node(a+1).type)}function aL(t,e,n=1,s){let r=t.doc.resolve(e),a=X.empty,l=X.empty;for(let o=r.depth,c=r.depth-n,d=n-1;o>c;o--,d--){a=X.from(r.node(o).copy(a));let u=s&&s[d];l=X.from(u?u.type.create(u.attrs,l):r.node(o).copy(l))}t.step(new Yt(e,e,new me(a.append(l),n,n),!0))}function Qi(t,e){let n=t.resolve(e),s=n.index();return g2(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(s,s+1)}function lL(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:s}=t.type.schema;for(let r=0;r<e.childCount;r++){let a=e.child(r),l=a.type==s?t.type.schema.nodes.text:a.type;if(n=n.matchType(l),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function g2(t,e){return!!(t&&e&&!t.isLeaf&&lL(t,e))}function zf(t,e,n=-1){let s=t.resolve(e);for(let r=s.depth;;r--){let a,l,o=s.index(r);if(r==s.depth?(a=s.nodeBefore,l=s.nodeAfter):n>0?(a=s.node(r+1),o++,l=s.node(r).maybeChild(o)):(a=s.node(r).maybeChild(o-1),l=s.node(r+1)),a&&!a.isTextblock&&g2(a,l)&&s.node(r).canReplace(o,o+1))return e;if(r==0)break;e=n<0?s.before(r):s.after(r)}}function oL(t,e,n){let s=null,{linebreakReplacement:r}=t.doc.type.schema,a=t.doc.resolve(e-n),l=a.node().type;if(r&&l.inlineContent){let u=l.whitespace=="pre",h=!!l.contentMatch.matchType(r);u&&!h?s=!1:!u&&h&&(s=!0)}let o=t.steps.length;if(s===!1){let u=t.doc.resolve(e+n);p2(t,u.node(),u.before(),o)}l.inlineContent&&Gy(t,e+n-1,l,a.node().contentMatchAt(a.index()),s==null);let c=t.mapping.slice(o),d=c.map(e-n);if(t.step(new Yt(d,c.map(e+n,-1),me.empty,!0)),s===!0){let u=t.doc.resolve(d);m2(t,u.node(),u.before(),t.steps.length)}return t}function cL(t,e,n){let s=t.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),n))return e;if(s.parentOffset==0)for(let r=s.depth-1;r>=0;r--){let a=s.index(r);if(s.node(r).canReplaceWith(a,a,n))return s.before(r+1);if(a>0)return null}if(s.parentOffset==s.parent.content.size)for(let r=s.depth-1;r>=0;r--){let a=s.indexAfter(r);if(s.node(r).canReplaceWith(a,a,n))return s.after(r+1);if(a<s.node(r).childCount)return null}return null}function x2(t,e,n){let s=t.resolve(e);if(!n.content.size)return e;let r=n.content;for(let a=0;a<n.openStart;a++)r=r.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let l=s.depth;l>=0;l--){let o=l==s.depth?0:s.pos<=(s.start(l+1)+s.end(l+1))/2?-1:1,c=s.index(l)+(o>0?1:0),d=s.node(l),u=!1;if(a==1)u=d.canReplace(c,c,r);else{let h=d.contentMatchAt(c).findWrapping(r.firstChild.type);u=h&&d.canReplaceWith(c,c,h[0])}if(u)return o==0?s.pos:o<0?s.before(l+1):s.after(l+1)}return null}function $f(t,e,n=e,s=me.empty){if(e==n&&!s.size)return null;let r=t.resolve(e),a=t.resolve(n);return y2(r,a,s)?new Yt(e,n,s):new dL(r,a,s).fit()}function y2(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class dL{constructor(e,n,s){this.$from=e,this.$to=n,this.unplaced=s,this.frontier=[],this.placed=X.empty;for(let r=0;r<=e.depth;r++){let a=e.node(r);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=X.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,s=this.$from,r=this.close(e<0?this.$to:s.doc.resolve(e));if(!r)return null;let a=this.placed,l=s.depth,o=r.depth;for(;l&&o&&a.childCount==1;)a=a.firstChild.content,l--,o--;let c=new me(a,l,o);return e>-1?new en(s.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||s.pos!=this.$to.pos?new Yt(s.pos,r.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,s=0,r=this.unplaced.openEnd;s<e;s++){let a=n.firstChild;if(n.childCount>1&&(r=0),a.type.spec.isolating&&r<=s){e=s;break}n=a.content}for(let n=1;n<=2;n++)for(let s=n==1?e:this.unplaced.openStart;s>=0;s--){let r,a=null;s?(a=qm(this.unplaced.content,s-1).firstChild,r=a.content):r=this.unplaced.content;let l=r.firstChild;for(let o=this.depth;o>=0;o--){let{type:c,match:d}=this.frontier[o],u,h=null;if(n==1&&(l?d.matchType(l.type)||(h=d.fillBefore(X.from(l),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:s,frontierDepth:o,parent:a,inject:h};if(n==2&&l&&(u=d.findWrapping(l.type)))return{sliceDepth:s,frontierDepth:o,parent:a,wrap:u};if(a&&d.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:s}=this.unplaced,r=qm(e,n);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new me(e,n+1,Math.max(s,r.size+n>=e.size-s?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:s}=this.unplaced,r=qm(e,n);if(r.childCount<=1&&n>0){let a=e.size-n<=n+r.size;this.unplaced=new me(Ko(e,n-1,1),n-1,a?n-1:s)}else this.unplaced=new me(Ko(e,n,1),n,s)}placeNodes({sliceDepth:e,frontierDepth:n,parent:s,inject:r,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let g=0;g<a.length;g++)this.openFrontierNode(a[g]);let l=this.unplaced,o=s?s.content:l.content,c=l.openStart-e,d=0,u=[],{match:h,type:m}=this.frontier[n];if(r){for(let g=0;g<r.childCount;g++)u.push(r.child(g));h=h.matchFragment(r)}let f=o.size+e-(l.content.size-l.openEnd);for(;d<o.childCount;){let g=o.child(d),x=h.matchType(g.type);if(!x)break;d++,(d>1||c==0||g.content.size)&&(h=x,u.push(v2(g.mark(m.allowedMarks(g.marks)),d==1?c:0,d==o.childCount?f:-1)))}let p=d==o.childCount;p||(f=-1),this.placed=Uo(this.placed,n,X.from(u)),this.frontier[n].match=h,p&&f<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,x=o;g<f;g++){let y=x.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),x=y.content}this.unplaced=p?e==0?me.empty:new me(Ko(l.content,e-1,1),e-1,f<0?l.openEnd:e-1):new me(Ko(l.content,e,d),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Hm(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:s}=this.$to,r=this.$to.after(s);for(;s>1&&r==this.$to.end(--s);)++r;return r}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:s,type:r}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),l=Hm(e,n,r,s,a);if(l){for(let o=n-1;o>=0;o--){let{match:c,type:d}=this.frontier[o],u=Hm(e,o,d,c,!0);if(!u||u.childCount)continue e}return{depth:n,fit:l,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Uo(this.placed,n.depth,n.fit)),e=n.move;for(let s=n.depth+1;s<=e.depth;s++){let r=e.node(s),a=r.type.contentMatch.fillBefore(r.content,!0,e.index(s));this.openFrontierNode(r.type,r.attrs,a)}return e}openFrontierNode(e,n=null,s){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Uo(this.placed,this.depth,X.from(e.create(n,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(X.empty,!0);n.childCount&&(this.placed=Uo(this.placed,this.frontier.length,n))}}function Ko(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ko(t.firstChild.content,e-1,n)))}function Uo(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Uo(t.lastChild.content,e-1,n)))}function qm(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function v2(t,e,n){if(e<=0)return t;let s=t.content;return e>1&&(s=s.replaceChild(0,v2(s.firstChild,e-1,s.childCount==1?n-1:0))),e>0&&(s=t.type.contentMatch.fillBefore(s).append(s),n<=0&&(s=s.append(t.type.contentMatch.matchFragment(s).fillBefore(X.empty,!0)))),t.copy(s)}function Hm(t,e,n,s,r){let a=t.node(e),l=r?t.indexAfter(e):t.index(e);if(l==a.childCount&&!n.compatibleContent(a.type))return null;let o=s.fillBefore(a.content,!0,l);return o&&!uL(n,a.content,l)?o:null}function uL(t,e,n){for(let s=n;s<e.childCount;s++)if(!t.allowsMarks(e.child(s).marks))return!0;return!1}function hL(t){return t.spec.defining||t.spec.definingForContent}function fL(t,e,n,s){if(!s.size)return t.deleteRange(e,n);let r=t.doc.resolve(e),a=t.doc.resolve(n);if(y2(r,a,s))return t.step(new Yt(e,n,s));let l=j2(r,a);l[l.length-1]==0&&l.pop();let o=-(r.depth+1);l.unshift(o);for(let m=r.depth,f=r.pos-1;m>0;m--,f--){let p=r.node(m).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;l.indexOf(m)>-1?o=m:r.before(m)==f&&l.splice(1,0,-m)}let c=l.indexOf(o),d=[],u=s.openStart;for(let m=s.content,f=0;;f++){let p=m.firstChild;if(d.push(p),f==s.openStart)break;m=p.content}for(let m=u-1;m>=0;m--){let f=d[m],p=hL(f.type);if(p&&!f.sameMarkup(r.node(Math.abs(o)-1)))u=m;else if(p||!f.type.isTextblock)break}for(let m=s.openStart;m>=0;m--){let f=(m+u+1)%(s.openStart+1),p=d[f];if(p)for(let g=0;g<l.length;g++){let x=l[(g+c)%l.length],y=!0;x<0&&(y=!1,x=-x);let v=r.node(x-1),b=r.index(x-1);if(v.canReplaceWith(b,b,p.type,p.marks))return t.replace(r.before(x),y?a.after(x):n,new me(b2(s.content,0,s.openStart,f),f,s.openEnd))}}let h=t.steps.length;for(let m=l.length-1;m>=0&&(t.replace(e,n,s),!(t.steps.length>h));m--){let f=l[m];f<0||(e=r.before(f),n=a.after(f))}}function b2(t,e,n,s,r){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(b2(a.content,e+1,n,s,a)))}if(e>s){let a=r.contentMatchAt(0),l=a.fillBefore(t).append(t);t=l.append(a.matchFragment(l).fillBefore(X.empty,!0))}return t}function mL(t,e,n,s){if(!s.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let r=cL(t.doc,e,s.type);r!=null&&(e=n=r)}t.replaceRange(e,n,new me(X.from(s),0,0))}function pL(t,e,n){let s=t.doc.resolve(e),r=t.doc.resolve(n),a=j2(s,r);for(let l=0;l<a.length;l++){let o=a[l],c=l==a.length-1;if(c&&o==0||s.node(o).type.contentMatch.validEnd)return t.delete(s.start(o),r.end(o));if(o>0&&(c||s.node(o-1).canReplace(s.index(o-1),r.indexAfter(o-1))))return t.delete(s.before(o),r.after(o))}for(let l=1;l<=s.depth&&l<=r.depth;l++)if(e-s.start(l)==s.depth-l&&n>s.end(l)&&r.end(l)-n!=r.depth-l&&s.start(l-1)==r.start(l-1)&&s.node(l-1).canReplace(s.index(l-1),r.index(l-1)))return t.delete(s.before(l),n);t.delete(e,n)}function j2(t,e){let n=[],s=Math.min(t.depth,e.depth);for(let r=s;r>=0;r--){let a=t.start(r);if(a<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(a==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==a-1)&&n.push(r)}return n}class Dl extends Nn{constructor(e,n,s){super(),this.pos=e,this.attr=n,this.value=s}apply(e){let n=e.nodeAt(this.pos);if(!n)return zt.fail("No node at attribute step's position");let s=Object.create(null);for(let a in n.attrs)s[a]=n.attrs[a];s[this.attr]=this.value;let r=n.type.create(s,null,n.marks);return zt.fromReplace(e,this.pos,this.pos+1,new me(X.from(r),0,n.isLeaf?0:1))}getMap(){return ss.empty}invert(e){return new Dl(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Dl(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Dl(n.pos,n.attr,n.value)}}Nn.jsonID("attr",Dl);class Hc extends Nn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let r in e.attrs)n[r]=e.attrs[r];n[this.attr]=this.value;let s=e.type.create(n,e.content,e.marks);return zt.ok(s)}getMap(){return ss.empty}invert(e){return new Hc(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Hc(n.attr,n.value)}}Nn.jsonID("docAttr",Hc);let so=class extends Error{};so=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};so.prototype=Object.create(Error.prototype);so.prototype.constructor=so;so.prototype.name="TransformError";class N2{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new qc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new so(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let s=0;s<this.mapping.maps.length;s++){let r=this.mapping.maps[s];s&&(e=r.map(e,1),n=r.map(n,-1)),r.forEach((a,l,o,c)=>{e=Math.min(e,o),n=Math.max(n,c)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,s=me.empty){let r=$f(this.doc,e,n,s);return r&&this.step(r),this}replaceWith(e,n,s){return this.replace(e,n,new me(X.from(s),0,0))}delete(e,n){return this.replace(e,n,me.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,s){return fL(this,e,n,s),this}replaceRangeWith(e,n,s){return mL(this,e,n,s),this}deleteRange(e,n){return pL(this,e,n),this}lift(e,n){return XO(this,e,n),this}join(e,n=1){return oL(this,e,n),this}wrap(e,n){return nL(this,e,n),this}setBlockType(e,n=e,s,r=null){return sL(this,e,n,s,r),this}setNodeMarkup(e,n,s=null,r){return iL(this,e,n,s,r),this}setNodeAttribute(e,n,s){return this.step(new Dl(e,n,s)),this}setDocAttribute(e,n){return this.step(new Hc(e,n)),this}addNodeMark(e,n){return this.step(new ki(e,n)),this}removeNodeMark(e,n){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(n instanceof tt)n.isInSet(s.marks)&&this.step(new Va(e,n));else{let r=s.marks,a,l=[];for(;a=n.isInSet(r);)l.push(new Va(e,a)),r=a.removeFromSet(r);for(let o=l.length-1;o>=0;o--)this.step(l[o])}return this}split(e,n=1,s){return aL(this,e,n,s),this}addMark(e,n,s){return JO(this,e,n,s),this}removeMark(e,n,s){return ZO(this,e,n,s),this}clearIncompatible(e,n,s){return Gy(this,e,n,s),this}}const Wm=Object.create(null);class Ie{constructor(e,n,s){this.$anchor=e,this.$head=n,this.ranges=s||[new gL(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=me.empty){let s=n.content.lastChild,r=null;for(let o=0;o<n.openEnd;o++)r=s,s=s.lastChild;let a=e.steps.length,l=this.ranges;for(let o=0;o<l.length;o++){let{$from:c,$to:d}=l[o],u=e.mapping.slice(a);e.replaceRange(u.map(c.pos),u.map(d.pos),o?me.empty:n),o==0&&xj(e,a,(s?s.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,n){let s=e.steps.length,r=this.ranges;for(let a=0;a<r.length;a++){let{$from:l,$to:o}=r[a],c=e.mapping.slice(s),d=c.map(l.pos),u=c.map(o.pos);a?e.deleteRange(d,u):(e.replaceRangeWith(d,u,n),xj(e,s,n.isInline?-1:1))}}static findFrom(e,n,s=!1){let r=e.parent.inlineContent?new De(e):il(e.node(0),e.parent,e.pos,e.index(),n,s);if(r)return r;for(let a=e.depth-1;a>=0;a--){let l=n<0?il(e.node(0),e.node(a),e.before(a+1),e.index(a),n,s):il(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,s);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new as(e.node(0))}static atStart(e){return il(e,e,0,0,1)||new as(e)}static atEnd(e){return il(e,e,e.content.size,e.childCount,-1)||new as(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=Wm[n.type];if(!s)throw new RangeError(`No selection type ${n.type} defined`);return s.fromJSON(e,n)}static jsonID(e,n){if(e in Wm)throw new RangeError("Duplicate use of selection JSON ID "+e);return Wm[e]=n,n.prototype.jsonID=e,n}getBookmark(){return De.between(this.$anchor,this.$head).getBookmark()}}Ie.prototype.visible=!0;class gL{constructor(e,n){this.$from=e,this.$to=n}}let pj=!1;function gj(t){!pj&&!t.parent.inlineContent&&(pj=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class De extends Ie{constructor(e,n=e){gj(e),gj(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let s=e.resolve(n.map(this.head));if(!s.parent.inlineContent)return Ie.near(s);let r=e.resolve(n.map(this.anchor));return new De(r.parent.inlineContent?r:s,s)}replace(e,n=me.empty){if(super.replace(e,n),n==me.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof De&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Bf(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new De(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,s=n){let r=e.resolve(n);return new this(r,s==n?r:e.resolve(s))}static between(e,n,s){let r=e.pos-n.pos;if((!s||r)&&(s=r>=0?1:-1),!n.parent.inlineContent){let a=Ie.findFrom(n,s,!0)||Ie.findFrom(n,-s,!0);if(a)n=a.$head;else return Ie.near(n,s)}return e.parent.inlineContent||(r==0?e=n:(e=(Ie.findFrom(e,-s,!0)||Ie.findFrom(e,s,!0)).$anchor,e.pos<n.pos!=r<0&&(e=n))),new De(e,n)}}Ie.jsonID("text",De);class Bf{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Bf(e.map(this.anchor),e.map(this.head))}resolve(e){return De.between(e.resolve(this.anchor),e.resolve(this.head))}}class ke extends Ie{constructor(e){let n=e.nodeAfter,s=e.node(0).resolve(e.pos+n.nodeSize);super(e,s),this.node=n}map(e,n){let{deleted:s,pos:r}=n.mapResult(this.anchor),a=e.resolve(r);return s?Ie.near(a):new ke(a)}content(){return new me(X.from(this.node),0,0)}eq(e){return e instanceof ke&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Zy(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ke(e.resolve(n.anchor))}static create(e,n){return new ke(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ke.prototype.visible=!1;Ie.jsonID("node",ke);class Zy{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:s}=e.mapResult(this.anchor);return n?new Bf(s,s):new Zy(s)}resolve(e){let n=e.resolve(this.anchor),s=n.nodeAfter;return s&&ke.isSelectable(s)?new ke(n):Ie.near(n)}}class as extends Ie{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=me.empty){if(n==me.empty){e.delete(0,e.doc.content.size);let s=Ie.atStart(e.doc);s.eq(e.selection)||e.setSelection(s)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new as(e)}map(e){return new as(e)}eq(e){return e instanceof as}getBookmark(){return xL}}Ie.jsonID("all",as);const xL={map(){return this},resolve(t){return new as(t)}};function il(t,e,n,s,r,a=!1){if(e.inlineContent)return De.create(t,n);for(let l=s-(r>0?0:1);r>0?l<e.childCount:l>=0;l+=r){let o=e.child(l);if(o.isAtom){if(!a&&ke.isSelectable(o))return ke.create(t,n-(r<0?o.nodeSize:0))}else{let c=il(t,o,n+r,r<0?o.childCount:0,r,a);if(c)return c}n+=o.nodeSize*r}return null}function xj(t,e,n){let s=t.steps.length-1;if(s<e)return;let r=t.steps[s];if(!(r instanceof Yt||r instanceof en))return;let a=t.mapping.maps[s],l;a.forEach((o,c,d,u)=>{l==null&&(l=u)}),t.setSelection(Ie.near(t.doc.resolve(l),n))}const yj=1,Xd=2,vj=4;class yL extends N2{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|yj)&~Xd,this.storedMarks=null,this}get selectionSet(){return(this.updated&yj)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Xd,this}ensureMarks(e){return tt.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&Xd)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Xd,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let s=this.selection;return n&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||tt.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,s){let r=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(s==null&&(s=n),!e)return this.deleteRange(n,s);let a=this.storedMarks;if(!a){let l=this.doc.resolve(n);a=s==n?l.marks():l.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(n,s,r.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ie.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=vj,this}get scrolledIntoView(){return(this.updated&vj)>0}}function bj(t,e){return!e||!t?t:t.bind(e)}class qo{constructor(e,n,s){this.name=e,this.init=bj(n.init,s),this.apply=bj(n.apply,s)}}const vL=[new qo("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new qo("selection",{init(t,e){return t.selection||Ie.atStart(e.doc)},apply(t){return t.selection}}),new qo("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,s){return s.selection.$cursor?t.storedMarks:null}}),new qo("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qm{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=vL.slice(),n&&n.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new qo(s.key,s.spec.state,s))})}}class jl{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let s=0;s<this.config.plugins.length;s++)if(s!=n){let r=this.config.plugins[s];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],s=this.applyInner(e),r=null;for(;;){let a=!1;for(let l=0;l<this.config.plugins.length;l++){let o=this.config.plugins[l];if(o.spec.appendTransaction){let c=r?r[l].n:0,d=r?r[l].state:this,u=c<n.length&&o.spec.appendTransaction.call(o,c?n.slice(c):n,d,s);if(u&&s.filterTransaction(u,l)){if(u.setMeta("appendedTransaction",e),!r){r=[];for(let h=0;h<this.config.plugins.length;h++)r.push(h<l?{state:s,n:n.length}:{state:this,n:0})}n.push(u),s=s.applyInner(u),a=!0}r&&(r[l]={state:s,n:n.length})}}if(!a)return{state:s,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new jl(this.config),s=this.config.fields;for(let r=0;r<s.length;r++){let a=s[r];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new yL(this)}static create(e){let n=new Qm(e.doc?e.doc.type.schema:e.schema,e.plugins),s=new jl(n);for(let r=0;r<n.fields.length;r++)s[n.fields[r].name]=n.fields[r].init(e,s);return s}reconfigure(e){let n=new Qm(this.schema,e.plugins),s=n.fields,r=new jl(n);for(let a=0;a<s.length;a++){let l=s[a].name;r[l]=this.hasOwnProperty(l)?this[l]:s[a].init(e,r)}return r}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(s=>s.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[s],a=r.spec.state;a&&a.toJSON&&(n[s]=a.toJSON.call(r,this[r.key]))}return n}static fromJSON(e,n,s){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Qm(e.schema,e.plugins),a=new jl(r);return r.fields.forEach(l=>{if(l.name=="doc")a.doc=_s.fromJSON(e.schema,n.doc);else if(l.name=="selection")a.selection=Ie.fromJSON(a.doc,n.selection);else if(l.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let o in s){let c=s[o],d=c.spec.state;if(c.key==l.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(n,o)){a[l.name]=d.fromJSON.call(c,e,n[o],a);return}}a[l.name]=l.init(e,a)}}),a}}function w2(t,e,n){for(let s in t){let r=t[s];r instanceof Function?r=r.bind(e):s=="handleDOMEvents"&&(r=w2(r,e,{})),n[s]=r}return n}class Nt{constructor(e){this.spec=e,this.props={},e.props&&w2(e.props,this,this.props),this.key=e.key?e.key.key:k2("plugin")}getState(e){return e[this.key]}}const Gm=Object.create(null);function k2(t){return t in Gm?t+"$"+ ++Gm[t]:(Gm[t]=0,t+"$")}class Ht{constructor(e="key"){this.key=k2(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Yy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function S2(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const C2=(t,e,n)=>{let s=S2(t,n);if(!s)return!1;let r=Xy(s);if(!r){let l=s.blockRange(),o=l&&vo(l);return o==null?!1:(e&&e(t.tr.lift(l,o).scrollIntoView()),!0)}let a=r.nodeBefore;if(O2(t,r,e,-1))return!0;if(s.parent.content.size==0&&(ro(a,"end")||ke.isSelectable(a)))for(let l=s.depth;;l--){let o=$f(t.doc,s.before(l),s.after(l),me.empty);if(o&&o.slice.size<o.to-o.from){if(e){let c=t.tr.step(o);c.setSelection(ro(a,"end")?Ie.findFrom(c.doc.resolve(c.mapping.map(r.pos,-1)),-1):ke.create(c.doc,r.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(l==1||s.node(l-1).childCount>1)break}return a.isAtom&&r.depth==s.depth-1?(e&&e(t.tr.delete(r.pos-a.nodeSize,r.pos).scrollIntoView()),!0):!1},bL=(t,e,n)=>{let s=S2(t,n);if(!s)return!1;let r=Xy(s);return r?E2(t,r,e):!1},jL=(t,e,n)=>{let s=D2(t,n);if(!s)return!1;let r=e0(s);return r?E2(t,r,e):!1};function E2(t,e,n){let s=e.nodeBefore,r=s,a=e.pos-1;for(;!r.isTextblock;a--){if(r.type.spec.isolating)return!1;let u=r.lastChild;if(!u)return!1;r=u}let l=e.nodeAfter,o=l,c=e.pos+1;for(;!o.isTextblock;c++){if(o.type.spec.isolating)return!1;let u=o.firstChild;if(!u)return!1;o=u}let d=$f(t.doc,a,c,me.empty);if(!d||d.from!=a||d instanceof Yt&&d.slice.size>=c-a)return!1;if(n){let u=t.tr.step(d);u.setSelection(De.create(u.doc,a)),n(u.scrollIntoView())}return!0}function ro(t,e,n=!1){for(let s=t;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(n&&s.childCount!=1)return!1}return!1}const A2=(t,e,n)=>{let{$head:s,empty:r}=t.selection,a=s;if(!r)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):s.parentOffset>0)return!1;a=Xy(s)}let l=a&&a.nodeBefore;return!l||!ke.isSelectable(l)?!1:(e&&e(t.tr.setSelection(ke.create(t.doc,a.pos-l.nodeSize)).scrollIntoView()),!0)};function Xy(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 D2(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const M2=(t,e,n)=>{let s=D2(t,n);if(!s)return!1;let r=e0(s);if(!r)return!1;let a=r.nodeAfter;if(O2(t,r,e,1))return!0;if(s.parent.content.size==0&&(ro(a,"start")||ke.isSelectable(a))){let l=$f(t.doc,s.before(),s.after(),me.empty);if(l&&l.slice.size<l.to-l.from){if(e){let o=t.tr.step(l);o.setSelection(ro(a,"start")?Ie.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):ke.create(o.doc,o.mapping.map(r.pos))),e(o.scrollIntoView())}return!0}}return a.isAtom&&r.depth==s.depth-1?(e&&e(t.tr.delete(r.pos,r.pos+a.nodeSize).scrollIntoView()),!0):!1},T2=(t,e,n)=>{let{$head:s,empty:r}=t.selection,a=s;if(!r)return!1;if(s.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):s.parentOffset<s.parent.content.size)return!1;a=e0(s)}let l=a&&a.nodeAfter;return!l||!ke.isSelectable(l)?!1:(e&&e(t.tr.setSelection(ke.create(t.doc,a.pos)).scrollIntoView()),!0)};function e0(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const NL=(t,e)=>{let n=t.selection,s=n instanceof ke,r;if(s){if(n.node.isTextblock||!Qi(t.doc,n.from))return!1;r=n.from}else if(r=zf(t.doc,n.from,-1),r==null)return!1;if(e){let a=t.tr.join(r);s&&a.setSelection(ke.create(a.doc,r-t.doc.resolve(r).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},wL=(t,e)=>{let n=t.selection,s;if(n instanceof ke){if(n.node.isTextblock||!Qi(t.doc,n.to))return!1;s=n.to}else if(s=zf(t.doc,n.to,1),s==null)return!1;return e&&e(t.tr.join(s).scrollIntoView()),!0},kL=(t,e)=>{let{$from:n,$to:s}=t.selection,r=n.blockRange(s),a=r&&vo(r);return a==null?!1:(e&&e(t.tr.lift(r,a).scrollIntoView()),!0)},P2=(t,e)=>{let{$head:n,$anchor:s}=t.selection;return!n.parent.type.spec.code||!n.sameParent(s)?!1:(e&&e(t.tr.insertText(`
`).scrollIntoView()),!0)};function t0(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const SL=(t,e)=>{let{$head:n,$anchor:s}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(s))return!1;let r=n.node(-1),a=n.indexAfter(-1),l=t0(r.contentMatchAt(a));if(!l||!r.canReplaceWith(a,a,l))return!1;if(e){let o=n.after(),c=t.tr.replaceWith(o,o,l.createAndFill());c.setSelection(Ie.near(c.doc.resolve(o),1)),e(c.scrollIntoView())}return!0},I2=(t,e)=>{let n=t.selection,{$from:s,$to:r}=n;if(n instanceof as||s.parent.inlineContent||r.parent.inlineContent)return!1;let a=t0(r.parent.contentMatchAt(r.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let l=(!s.parentOffset&&r.index()<r.parent.childCount?s:r).pos,o=t.tr.insert(l,a.createAndFill());o.setSelection(De.create(o.doc,l+1)),e(o.scrollIntoView())}return!0},R2=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(Rr(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let s=n.blockRange(),r=s&&vo(s);return r==null?!1:(e&&e(t.tr.lift(s,r).scrollIntoView()),!0)};function CL(t){return(e,n)=>{let{$from:s,$to:r}=e.selection;if(e.selection instanceof ke&&e.selection.node.isBlock)return!s.parentOffset||!Rr(e.doc,s.pos)?!1:(n&&n(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let a=[],l,o,c=!1,d=!1;for(let f=s.depth;;f--)if(s.node(f).isBlock){c=s.end(f)==s.pos+(s.depth-f),d=s.start(f)==s.pos-(s.depth-f),o=t0(s.node(f-1).contentMatchAt(s.indexAfter(f-1))),a.unshift(c&&o?{type:o}:null),l=f;break}else{if(f==1)return!1;a.unshift(null)}let u=e.tr;(e.selection instanceof De||e.selection instanceof as)&&u.deleteSelection();let h=u.mapping.map(s.pos),m=Rr(u.doc,h,a.length,a);if(m||(a[0]=o?{type:o}:null,m=Rr(u.doc,h,a.length,a)),!m)return!1;if(u.split(h,a.length,a),!c&&d&&s.node(l).type!=o){let f=u.mapping.map(s.before(l)),p=u.doc.resolve(f);o&&s.node(l-1).canReplaceWith(p.index(),p.index()+1,o)&&u.setNodeMarkup(u.mapping.map(s.before(l)),o)}return n&&n(u.scrollIntoView()),!0}}const EL=CL(),AL=(t,e)=>{let{$from:n,to:s}=t.selection,r,a=n.sharedDepth(s);return a==0?!1:(r=n.before(a),e&&e(t.tr.setSelection(ke.create(t.doc,r))),!0)};function DL(t,e,n){let s=e.nodeBefore,r=e.nodeAfter,a=e.index();return!s||!r||!s.type.compatibleContent(r.type)?!1:!s.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(r.isTextblock||Qi(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function O2(t,e,n,s){let r=e.nodeBefore,a=e.nodeAfter,l,o,c=r.type.spec.isolating||a.type.spec.isolating;if(!c&&DL(t,e,n))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(l=(o=r.contentMatchAt(r.childCount)).findWrapping(a.type))&&o.matchType(l[0]||a.type).validEnd){if(n){let f=e.pos+a.nodeSize,p=X.empty;for(let y=l.length-1;y>=0;y--)p=X.from(l[y].create(null,p));p=X.from(r.copy(p));let g=t.tr.step(new en(e.pos-1,f,e.pos,f,new me(p,1,0),l.length,!0)),x=g.doc.resolve(f+2*l.length);x.nodeAfter&&x.nodeAfter.type==r.type&&Qi(g.doc,x.pos)&&g.join(x.pos),n(g.scrollIntoView())}return!0}let u=a.type.spec.isolating||s>0&&c?null:Ie.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),m=h&&vo(h);if(m!=null&&m>=e.depth)return n&&n(t.tr.lift(h,m).scrollIntoView()),!0;if(d&&ro(a,"start",!0)&&ro(r,"end")){let f=r,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let g=a,x=1;for(;!g.isTextblock;g=g.firstChild)x++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(n){let y=X.empty;for(let b=p.length-1;b>=0;b--)y=X.from(p[b].copy(y));let v=t.tr.step(new en(e.pos-p.length,e.pos+a.nodeSize,e.pos+x,e.pos+a.nodeSize-x,new me(y,p.length,0),0,!0));n(v.scrollIntoView())}return!0}}return!1}function L2(t){return function(e,n){let s=e.selection,r=t<0?s.$from:s.$to,a=r.depth;for(;r.node(a).isInline;){if(!a)return!1;a--}return r.node(a).isTextblock?(n&&n(e.tr.setSelection(De.create(e.doc,t<0?r.start(a):r.end(a)))),!0):!1}}const ML=L2(-1),TL=L2(1);function PL(t,e=null){return function(n,s){let{$from:r,$to:a}=n.selection,l=r.blockRange(a),o=l&&Jy(l,t,e);return o?(s&&s(n.tr.wrap(l,o).scrollIntoView()),!0):!1}}function jj(t,e=null){return function(n,s){let r=!1;for(let a=0;a<n.selection.ranges.length&&!r;a++){let{$from:{pos:l},$to:{pos:o}}=n.selection.ranges[a];n.doc.nodesBetween(l,o,(c,d)=>{if(r)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)r=!0;else{let u=n.doc.resolve(d),h=u.index();r=u.parent.canReplaceWith(h,h+1,t)}})}if(!r)return!1;if(s){let a=n.tr;for(let l=0;l<n.selection.ranges.length;l++){let{$from:{pos:o},$to:{pos:c}}=n.selection.ranges[l];a.setBlockType(o,c,t,e)}s(a.scrollIntoView())}return!0}}function n0(...t){return function(e,n,s){for(let r=0;r<t.length;r++)if(t[r](e,n,s))return!0;return!1}}n0(Yy,C2,A2);n0(Yy,M2,T2);n0(P2,I2,R2,EL);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function IL(t,e=null){return function(n,s){let{$from:r,$to:a}=n.selection,l=r.blockRange(a);if(!l)return!1;let o=s?n.tr:null;return RL(o,l,t,e)?(s&&s(o.scrollIntoView()),!0):!1}}function RL(t,e,n,s=null){let r=!1,a=e,l=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=l.resolve(e.start-2);a=new yh(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new yh(e.$from,l.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let o=Jy(a,n,s,e);return o?(t&&OL(t,e,o,r,n),!0):!1}function OL(t,e,n,s,r){let a=X.empty;for(let u=n.length-1;u>=0;u--)a=X.from(n[u].type.create(n[u].attrs,a));t.step(new en(e.start-(s?2:0),e.end,e.start,e.end,new me(a,0,0),n.length,!0));let l=0;for(let u=0;u<n.length;u++)n[u].type==r&&(l=u+1);let o=n.length-l,c=e.start+n.length-(s?2:0),d=e.parent;for(let u=e.startIndex,h=e.endIndex,m=!0;u<h;u++,m=!1)!m&&Rr(t.doc,c,o)&&(t.split(c,o),c+=2*o),c+=d.child(u).nodeSize;return t}function LL(t){return function(e,n){let{$from:s,$to:r}=e.selection,a=s.blockRange(r,l=>l.childCount>0&&l.firstChild.type==t);return a?n?s.node(a.depth-1).type==t?FL(e,n,t,a):zL(e,n,a):!0:!1}}function FL(t,e,n,s){let r=t.tr,a=s.end,l=s.$to.end(s.depth);a<l&&(r.step(new en(a-1,l,a,l,new me(X.from(n.create(null,s.parent.copy())),1,0),1,!0)),s=new yh(r.doc.resolve(s.$from.pos),r.doc.resolve(l),s.depth));const o=vo(s);if(o==null)return!1;r.lift(s,o);let c=r.doc.resolve(r.mapping.map(a,-1)-1);return Qi(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),e(r.scrollIntoView()),!0}function zL(t,e,n){let s=t.tr,r=n.parent;for(let f=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)f-=r.child(p).nodeSize,s.delete(f-1,f+1);let a=s.doc.resolve(n.start),l=a.nodeAfter;if(s.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let o=n.startIndex==0,c=n.endIndex==r.childCount,d=a.node(-1),u=a.index(-1);if(!d.canReplace(u+(o?0:1),u+1,l.content.append(c?X.empty:X.from(r))))return!1;let h=a.pos,m=h+l.nodeSize;return s.step(new en(h-(o?1:0),m+(c?1:0),h+1,m-1,new me((o?X.empty:X.from(r.copy(X.empty))).append(c?X.empty:X.from(r.copy(X.empty))),o?0:1,c?0:1),o?0:1)),e(s.scrollIntoView()),!0}function $L(t){return function(e,n){let{$from:s,$to:r}=e.selection,a=s.blockRange(r,d=>d.childCount>0&&d.firstChild.type==t);if(!a)return!1;let l=a.startIndex;if(l==0)return!1;let o=a.parent,c=o.child(l-1);if(c.type!=t)return!1;if(n){let d=c.lastChild&&c.lastChild.type==o.type,u=X.from(d?t.create():null),h=new me(X.from(t.create(null,X.from(o.type.create(null,u)))),d?3:1,0),m=a.start,f=a.end;n(e.tr.step(new en(m-(d?3:1),f,m,f,h,1,!0)).scrollIntoView())}return!0}}const an=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},io=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Yg=null;const jr=function(t,e,n){let s=Yg||(Yg=document.createRange());return s.setEnd(t,n??t.nodeValue.length),s.setStart(t,e||0),s},BL=function(){Yg=null},Ka=function(t,e,n,s){return n&&(Nj(t,e,n,s,-1)||Nj(t,e,n,s,1))},_L=/^(img|br|input|textarea|hr)$/i;function Nj(t,e,n,s,r){for(var a;;){if(t==n&&e==s)return!0;if(e==(r<0?0:js(t))){let l=t.parentNode;if(!l||l.nodeType!=1||kd(t)||_L.test(t.nodeName)||t.contentEditable=="false")return!1;e=an(t)+(r<0?0:1),t=l}else if(t.nodeType==1){let l=t.childNodes[e+(r<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((a=l.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=r;else return!1;else t=l,e=r<0?js(t):0}else return!1}}function js(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function VL(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=js(t)}else if(t.parentNode&&!kd(t))e=an(t),t=t.parentNode;else return null}}function KL(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!kd(t))e=an(t)+1,t=t.parentNode;else return null}}function UL(t,e,n){for(let s=e==0,r=e==js(t);s||r;){if(t==n)return!0;let a=an(t);if(t=t.parentNode,!t)return!1;s=s&&a==0,r=r&&a==js(t)}}function kd(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const _f=function(t){return t.focusNode&&Ka(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function ta(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function qL(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function HL(t,e,n){if(t.caretPositionFromPoint)try{let s=t.caretPositionFromPoint(e,n);if(s)return{node:s.offsetNode,offset:Math.min(js(s.offsetNode),s.offset)}}catch{}if(t.caretRangeFromPoint){let s=t.caretRangeFromPoint(e,n);if(s)return{node:s.startContainer,offset:Math.min(js(s.startContainer),s.startOffset)}}}const or=typeof navigator<"u"?navigator:null,wj=typeof document<"u"?document:null,Gi=or&&or.userAgent||"",Xg=/Edge\/(\d+)/.exec(Gi),F2=/MSIE \d/.exec(Gi),ex=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Gi),Zn=!!(F2||ex||Xg),Fi=F2?document.documentMode:ex?+ex[1]:Xg?+Xg[1]:0,ks=!Zn&&/gecko\/(\d+)/i.test(Gi);ks&&+(/Firefox\/(\d+)/.exec(Gi)||[0,0])[1];const tx=!Zn&&/Chrome\/(\d+)/.exec(Gi),cn=!!tx,z2=tx?+tx[1]:0,jn=!Zn&&!!or&&/Apple Computer/.test(or.vendor),ao=jn&&(/Mobile\/\w+/.test(Gi)||!!or&&or.maxTouchPoints>2),ys=ao||(or?/Mac/.test(or.platform):!1),$2=or?/Win/.test(or.platform):!1,Pr=/Android \d/.test(Gi),Sd=!!wj&&"webkitFontSmoothing"in wj.documentElement.style,WL=Sd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function QL(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 pr(t,e){return typeof t=="number"?t:t[e]}function GL(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,s=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*s}}function kj(t,e,n){let s=t.someProp("scrollThreshold")||0,r=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let l=n||t.dom;l;){if(l.nodeType!=1){l=io(l);continue}let o=l,c=o==a.body,d=c?QL(a):GL(o),u=0,h=0;if(e.top<d.top+pr(s,"top")?h=-(d.top-e.top+pr(r,"top")):e.bottom>d.bottom-pr(s,"bottom")&&(h=e.bottom-e.top>d.bottom-d.top?e.top+pr(r,"top")-d.top:e.bottom-d.bottom+pr(r,"bottom")),e.left<d.left+pr(s,"left")?u=-(d.left-e.left+pr(r,"left")):e.right>d.right-pr(s,"right")&&(u=e.right-d.right+pr(r,"right")),u||h)if(c)a.defaultView.scrollBy(u,h);else{let f=o.scrollLeft,p=o.scrollTop;h&&(o.scrollTop+=h),u&&(o.scrollLeft+=u);let g=o.scrollLeft-f,x=o.scrollTop-p;e={left:e.left-g,top:e.top-x,right:e.right-g,bottom:e.bottom-x}}let m=c?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(m))break;l=m=="absolute"?l.offsetParent:io(l)}}function JL(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),s,r;for(let a=(e.left+e.right)/2,l=n+1;l<Math.min(innerHeight,e.bottom);l+=5){let o=t.root.elementFromPoint(a,l);if(!o||o==t.dom||!t.dom.contains(o))continue;let c=o.getBoundingClientRect();if(c.top>=n-20){s=o,r=c.top;break}}return{refDOM:s,refTop:r,stack:B2(t.dom)}}function B2(t){let e=[],n=t.ownerDocument;for(let s=t;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),t!=n);s=io(s));return e}function ZL({refDOM:t,refTop:e,stack:n}){let s=t?t.getBoundingClientRect().top:0;_2(n,s==0?0:s-e)}function _2(t,e){for(let n=0;n<t.length;n++){let{dom:s,top:r,left:a}=t[n];s.scrollTop!=r+e&&(s.scrollTop=r+e),s.scrollLeft!=a&&(s.scrollLeft=a)}}let tl=null;function YL(t){if(t.setActive)return t.setActive();if(tl)return t.focus(tl);let e=B2(t);t.focus(tl==null?{get preventScroll(){return tl={preventScroll:!0},!0}}:void 0),tl||(tl=!1,_2(e,0))}function V2(t,e){let n,s=2e8,r,a=0,l=e.top,o=e.top,c,d;for(let u=t.firstChild,h=0;u;u=u.nextSibling,h++){let m;if(u.nodeType==1)m=u.getClientRects();else if(u.nodeType==3)m=jr(u).getClientRects();else continue;for(let f=0;f<m.length;f++){let p=m[f];if(p.top<=l&&p.bottom>=o){l=Math.max(p.bottom,l),o=Math.min(p.top,o);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<s){n=u,s=g,r=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(a=h+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!c&&p.left<=e.left&&p.right>=e.left&&(c=u,d={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(a=h+1)}}return!n&&c&&(n=c,r=d,s=0),n&&n.nodeType==3?XL(n,r):!n||s&&n.nodeType==1?{node:t,offset:a}:V2(n,r)}function XL(t,e){let n=t.nodeValue.length,s=document.createRange(),r;for(let a=0;a<n;a++){s.setEnd(t,a+1),s.setStart(t,a);let l=Zr(s,1);if(l.top!=l.bottom&&s0(e,l)){r={node:t,offset:a+(e.left>=(l.left+l.right)/2?1:0)};break}}return s.detach(),r||{node:t,offset:0}}function s0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function eF(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function tF(t,e,n){let{node:s,offset:r}=V2(e,n),a=-1;if(s.nodeType==1&&!s.firstChild){let l=s.getBoundingClientRect();a=l.left!=l.right&&n.left>(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(s,r,a)}function nF(t,e,n,s){let r=-1;for(let a=e,l=!1;a!=t.dom;){let o=t.docView.nearestDesc(a,!0),c;if(!o)return null;if(o.dom.nodeType==1&&(o.node.isBlock&&o.parent||!o.contentDOM)&&((c=o.dom.getBoundingClientRect()).width||c.height)&&(o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(!l&&c.left>s.left||c.top>s.top?r=o.posBefore:(!l&&c.right<s.left||c.bottom<s.top)&&(r=o.posAfter),l=!0),!o.contentDOM&&r<0&&!o.node.isText))return(o.node.isBlock?s.top<(c.top+c.bottom)/2:s.left<(c.left+c.right)/2)?o.posBefore:o.posAfter;a=o.dom.parentNode}return r>-1?r:t.docView.posFromDOM(e,n,-1)}function K2(t,e,n){let s=t.childNodes.length;if(s&&n.top<n.bottom)for(let r=Math.max(0,Math.min(s-1,Math.floor(s*(e.top-n.top)/(n.bottom-n.top))-2)),a=r;;){let l=t.childNodes[a];if(l.nodeType==1){let o=l.getClientRects();for(let c=0;c<o.length;c++){let d=o[c];if(s0(e,d))return K2(l,e,d)}}if((a=(a+1)%s)==r)break}return t}function sF(t,e){let n=t.dom.ownerDocument,s,r=0,a=HL(n,e.left,e.top);a&&({node:s,offset:r}=a);let l=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),o;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let d=t.dom.getBoundingClientRect();if(!s0(e,d)||(l=K2(t.dom,e,d),!l))return null}if(jn)for(let d=l;s&&d;d=io(d))d.draggable&&(s=void 0);if(l=eF(l,e),s){if(ks&&s.nodeType==1&&(r=Math.min(r,s.childNodes.length),r<s.childNodes.length)){let u=s.childNodes[r],h;u.nodeName=="IMG"&&(h=u.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&r++}let d;Sd&&r&&s.nodeType==1&&(d=s.childNodes[r-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&r--,s==t.dom&&r==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom?o=t.state.doc.content.size:(r==0||s.nodeType!=1||s.childNodes[r-1].nodeName!="BR")&&(o=nF(t,s,r,e))}o==null&&(o=tF(t,l,e));let c=t.docView.nearestDesc(l,!0);return{pos:o,inside:c?c.posAtStart-c.border:-1}}function Sj(t){return t.top<t.bottom||t.left<t.right}function Zr(t,e){let n=t.getClientRects();if(n.length){let s=n[e<0?0:n.length-1];if(Sj(s))return s}return Array.prototype.find.call(n,Sj)||t.getBoundingClientRect()}const rF=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function U2(t,e,n){let{node:s,offset:r,atom:a}=t.docView.domFromPos(e,n<0?-1:1),l=Sd||ks;if(s.nodeType==3)if(l&&(rF.test(s.nodeValue)||(n<0?!r:r==s.nodeValue.length))){let c=Zr(jr(s,r,r),n);if(ks&&r&&/\s/.test(s.nodeValue[r-1])&&r<s.nodeValue.length){let d=Zr(jr(s,r-1,r-1),-1);if(d.top==c.top){let u=Zr(jr(s,r,r+1),-1);if(u.top!=c.top)return Ro(u,u.left<d.left)}}return c}else{let c=r,d=r,u=n<0?1:-1;return n<0&&!r?(d++,u=-1):n>=0&&r==s.nodeValue.length?(c--,u=1):n<0?c--:d++,Ro(Zr(jr(s,c,d),u),u<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&r&&(n<0||r==js(s))){let c=s.childNodes[r-1];if(c.nodeType==1)return Jm(c.getBoundingClientRect(),!1)}if(a==null&&r<js(s)){let c=s.childNodes[r];if(c.nodeType==1)return Jm(c.getBoundingClientRect(),!0)}return Jm(s.getBoundingClientRect(),n>=0)}if(a==null&&r&&(n<0||r==js(s))){let c=s.childNodes[r-1],d=c.nodeType==3?jr(c,js(c)-(l?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return Ro(Zr(d,1),!1)}if(a==null&&r<js(s)){let c=s.childNodes[r];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let d=c?c.nodeType==3?jr(c,0,l?0:1):c.nodeType==1?c:null:null;if(d)return Ro(Zr(d,-1),!0)}return Ro(Zr(s.nodeType==3?jr(s):s,-n),n>=0)}function Ro(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Jm(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function q2(t,e,n){let s=t.state,r=t.root.activeElement;s!=e&&t.updateState(e),r!=t.dom&&t.focus();try{return n()}finally{s!=e&&t.updateState(s),r!=t.dom&&r&&r.focus()}}function iF(t,e,n){let s=e.selection,r=n=="up"?s.$from:s.$to;return q2(t,e,()=>{let{node:a}=t.docView.domFromPos(r.pos,n=="up"?-1:1);for(;;){let o=t.docView.nearestDesc(a,!0);if(!o)break;if(o.node.isBlock){a=o.contentDOM||o.dom;break}a=o.dom.parentNode}let l=U2(t,r.pos,1);for(let o=a.firstChild;o;o=o.nextSibling){let c;if(o.nodeType==1)c=o.getClientRects();else if(o.nodeType==3)c=jr(o,0,o.nodeValue.length).getClientRects();else continue;for(let d=0;d<c.length;d++){let u=c[d];if(u.bottom>u.top+1&&(n=="up"?l.top-u.top>(u.bottom-l.top)*2:u.bottom-l.bottom>(l.bottom-u.top)*2))return!1}}return!0})}const aF=/[\u0590-\u08ac]/;function lF(t,e,n){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let r=s.parentOffset,a=!r,l=r==s.parent.content.size,o=t.domSelection();return o?!aF.test(s.parent.textContent)||!o.modify?n=="left"||n=="backward"?a:l:q2(t,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:u,anchorOffset:h}=t.domSelectionRange(),m=o.caretBidiLevel;o.modify("move",n,"character");let f=s.depth?t.docView.domAfterPos(s.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),x=p&&!f.contains(p.nodeType==1?p:p.parentNode)||c==p&&d==g;try{o.collapse(u,h),c&&(c!=u||d!=h)&&o.extend&&o.extend(c,d)}catch{}return m!=null&&(o.caretBidiLevel=m),x}):s.pos==s.start()||s.pos==s.end()}let Cj=null,Ej=null,Aj=!1;function oF(t,e,n){return Cj==e&&Ej==n?Aj:(Cj=e,Ej=n,Aj=n=="up"||n=="down"?iF(t,e,n):lF(t,e,n))}const Ss=0,Dj=1,ca=2,cr=3;class Cd{constructor(e,n,s,r){this.parent=e,this.children=n,this.dom=s,this.contentDOM=r,this.dirty=Ss,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,s){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,s=this.posAtStart;;n++){let r=this.children[n];if(r==e)return s;s+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,s){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(s<0){let a,l;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((l=a.pmViewDesc)&&l.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(l)+l.size:this.posAtStart}else{let a,l;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((l=a.pmViewDesc)&&l.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(l):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=n>an(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){r=!1;break}if(a.previousSibling)break}if(r==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){r=!0;break}if(a.nextSibling)break}}return r??s>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let s=!0,r=e;r;r=r.parentNode){let a=this.getDesc(r),l;if(a&&(!n||a.node))if(s&&(l=a.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==e))s=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let s=n;s;s=s.parent)if(s==this)return n}posFromDOM(e,n,s){for(let r=e;r;r=r.parentNode){let a=this.getDesc(r);if(a)return a.localPosFromDOM(e,n,s)}return-1}descAt(e){for(let n=0,s=0;n<this.children.length;n++){let r=this.children[n],a=s+r.size;if(s==e&&a!=s){for(;!r.border&&r.children.length;)for(let l=0;l<r.children.length;l++){let o=r.children[l];if(o.size){r=o;break}}return r}if(e<a)return r.descAt(e-s-r.border);s=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let s=0,r=0;for(let a=0;s<this.children.length;s++){let l=this.children[s],o=a+l.size;if(o>e||l instanceof W2){r=e-a;break}a=o}if(r)return this.children[s].domFromPos(r-this.children[s].border,n);for(let a;s&&!(a=this.children[s-1]).size&&a instanceof H2&&a.side>=0;s--);if(n<=0){let a,l=!0;for(;a=s?this.children[s-1]:null,!(!a||a.dom.parentNode==this.contentDOM);s--,l=!1);return a&&n&&l&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?an(a.dom)+1:0}}else{let a,l=!0;for(;a=s<this.children.length?this.children[s]:null,!(!a||a.dom.parentNode==this.contentDOM);s++,l=!1);return a&&l&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?an(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,s=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,a=-1;for(let l=s,o=0;;o++){let c=this.children[o],d=l+c.size;if(r==-1&&e<=d){let u=l+c.border;if(e>=u&&n<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,u);e=l;for(let h=o;h>0;h--){let m=this.children[h-1];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(1)){r=an(m.dom)+1;break}e-=m.size}r==-1&&(r=0)}if(r>-1&&(d>n||o==this.children.length-1)){n=d;for(let u=o+1;u<this.children.length;u++){let h=this.children[u];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){a=an(h.dom);break}n+=h.size}a==-1&&(a=this.contentDOM.childNodes.length);break}l=d}return{node:this.contentDOM,from:e,to:n,fromOffset:r,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:s}=this.domFromPos(e,0);if(n.nodeType!=1||s==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[s]}setSelection(e,n,s,r=!1){let a=Math.min(e,n),l=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let g=this.children[f],x=p+g.size;if(a>p&&l<x)return g.setSelection(e-p-g.border,n-p-g.border,s,r);p=x}let o=this.domFromPos(e,e?-1:1),c=n==e?o:this.domFromPos(n,n?-1:1),d=s.root.getSelection(),u=s.domSelectionRange(),h=!1;if((ks||jn)&&e==n){let{node:f,offset:p}=o;if(f.nodeType==3){if(h=!!(p&&f.nodeValue[p-1]==`
`),h&&p==f.nodeValue.length)for(let g=f,x;g;g=g.parentNode){if(x=g.nextSibling){x.nodeName=="BR"&&(o=c={node:x.parentNode,offset:an(x)+1});break}let y=g.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let g=f.childNodes[p-1];h=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(ks&&u.focusNode&&u.focusNode!=c.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(r=!0)}if(!(r||h&&jn)&&Ka(o.node,o.offset,u.anchorNode,u.anchorOffset)&&Ka(c.node,c.offset,u.focusNode,u.focusOffset))return;let m=!1;if((d.extend||e==n)&&!(h&&ks)){d.collapse(o.node,o.offset);try{e!=n&&d.extend(c.node,c.offset),m=!0}catch{}}if(!m){if(e>n){let p=o;o=c,c=p}let f=document.createRange();f.setEnd(c.node,c.offset),f.setStart(o.node,o.offset),d.removeAllRanges(),d.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let s=0,r=0;r<this.children.length;r++){let a=this.children[r],l=s+a.size;if(s==l?e<=l&&n>=s:e<l&&n>s){let o=s+a.border,c=l-a.border;if(e>=o&&n<=c){this.dirty=e==s||n==l?ca:Dj,e==o&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=cr:a.markDirty(e-o,n-o);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?ca:cr}s=l}this.dirty=ca}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let s=e==1?ca:Dj;n.dirty<s&&(n.dirty=s)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class H2 extends Cd{constructor(e,n,s,r){let a,l=n.type.toDOM;if(typeof l=="function"&&(l=l(s,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(l.nodeType!=1){let o=document.createElement("span");o.appendChild(l),l=o}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(e,[],l,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==Ss&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class cF extends Cd{constructor(e,n,s,r){super(e,[],n,null),this.textDOM=s,this.text=r}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Ua extends Cd{constructor(e,n,s,r,a){super(e,[],s,r),this.mark=n,this.spec=a}static create(e,n,s,r){let a=r.nodeViews[n.type.name],l=a&&a(n,r,s);return(!l||!l.dom)&&(l=Ga.renderSpec(document,n.type.spec.toDOM(n,s),null,n.attrs)),new Ua(e,n,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&cr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=cr&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ss){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty<this.dirty&&(s.dirty=this.dirty),this.dirty=Ss}}slice(e,n,s){let r=Ua.create(this.parent,this.mark,!0,s),a=this.children,l=this.size;n<l&&(a=sx(a,n,l,s)),e>0&&(a=sx(a,0,e,s));for(let o=0;o<a.length;o++)a[o].parent=r;return r.children=a,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class zi extends Cd{constructor(e,n,s,r,a,l,o,c,d){super(e,[],a,l),this.node=n,this.outerDeco=s,this.innerDeco=r,this.nodeDOM=o}static create(e,n,s,r,a,l){let o=a.nodeViews[n.type.name],c,d=o&&o(n,a,()=>{if(!c)return l;if(c.parent)return c.parent.posBeforeChild(c)},s,r),u=d&&d.dom,h=d&&d.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=Ga.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let m=u;return u=J2(u,s,n),d?c=new dF(e,n,s,r,u,h||null,m,d,a,l+1):n.isText?new Vf(e,n,s,r,u,m,a):new zi(e,n,s,r,u,h||null,m,a,l+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let s=this.children[n];if(this.dom.contains(s.dom.parentNode)){e.contentElement=s.dom.parentNode;break}}e.contentElement||(e.getContent=()=>X.empty)}return e}matchesNode(e,n,s){return this.dirty==Ss&&e.eq(this.node)&&bh(n,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let s=this.node.inlineContent,r=n,a=e.composing?this.localCompositionInfo(e,n):null,l=a&&a.pos>-1?a:null,o=a&&a.pos<0,c=new hF(this,l&&l.node,e);pF(this.node,this.innerDeco,(d,u,h)=>{d.spec.marks?c.syncToMarks(d.spec.marks,s,e,u):d.type.side>=0&&!h&&c.syncToMarks(u==this.node.childCount?tt.none:this.node.child(u).marks,s,e,u),c.placeWidget(d,e,r)},(d,u,h,m)=>{c.syncToMarks(d.marks,s,e,m);let f;c.findNodeMatch(d,u,h,m)||o&&e.state.selection.from>r&&e.state.selection.to<r+d.nodeSize&&(f=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(d,u,h,f,e)||c.updateNextNode(d,u,h,e,m,r)||c.addNode(d,u,h,e,r),r+=d.nodeSize}),c.syncToMarks([],s,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==ca)&&(l&&this.protectLocalComposition(e,l),Q2(this.contentDOM,this.children,e),ao&&gF(this.dom))}localCompositionInfo(e,n){let{from:s,to:r}=e.state.selection;if(!(e.state.selection instanceof De)||s<n||r>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let l=a.nodeValue,o=xF(this.node.content,l,s-n,r-n);return o<0?null:{node:a,pos:o,text:l}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:s,text:r}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let l=new cF(this,a,n,r);e.input.compositionNodes.push(l),this.children=sx(this.children,s,s+r.length,e,l)}update(e,n,s,r){return this.dirty==cr||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,s,r),!0)}updateInner(e,n,s,r){this.updateOuterDeco(n),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Ss}updateOuterDeco(e){if(bh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,s=this.dom;this.dom=G2(this.dom,this.nodeDOM,nx(this.outerDeco,this.node,n),nx(e,this.node,n)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Mj(t,e,n,s,r){J2(s,e,t);let a=new zi(void 0,t,e,n,s,s,s,r,0);return a.contentDOM&&a.updateChildren(r,0),a}class Vf extends zi{constructor(e,n,s,r,a,l,o){super(e,n,s,r,a,null,l,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,s,r){return this.dirty==cr||this.dirty!=Ss&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ss||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Ss,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,s){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,s){let r=this.node.cut(e,n),a=document.createTextNode(r.text);return new Vf(this.parent,r,this.outerDeco,this.innerDeco,a,a,s)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=cr)}get domAtom(){return!1}isText(e){return this.node.text==e}}class W2 extends Cd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ss&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class dF extends zi{constructor(e,n,s,r,a,l,o,c,d,u){super(e,n,s,r,a,l,o,d,u),this.spec=c}update(e,n,s,r){if(this.dirty==cr)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,s);return a&&this.updateInner(e,n,s,r),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,s,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,s,r){this.spec.setSelection?this.spec.setSelection(e,n,s.root):super.setSelection(e,n,s,r)}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 Q2(t,e,n){let s=t.firstChild,r=!1;for(let a=0;a<e.length;a++){let l=e[a],o=l.dom;if(o.parentNode==t){for(;o!=s;)s=Tj(s),r=!0;s=s.nextSibling}else r=!0,t.insertBefore(o,s);if(l instanceof Ua){let c=s?s.previousSibling:t.lastChild;Q2(l.contentDOM,l.children,n),s=c?c.nextSibling:t.firstChild}}for(;s;)s=Tj(s),r=!0;r&&n.trackWrites==t&&(n.trackWrites=null)}const oc=function(t){t&&(this.nodeName=t)};oc.prototype=Object.create(null);const da=[new oc];function nx(t,e,n){if(t.length==0)return da;let s=n?da[0]:new oc,r=[s];for(let a=0;a<t.length;a++){let l=t[a].type.attrs;if(l){l.nodeName&&r.push(s=new oc(l.nodeName));for(let o in l){let c=l[o];c!=null&&(n&&r.length==1&&r.push(s=new oc(e.isInline?"span":"div")),o=="class"?s.class=(s.class?s.class+" ":"")+c:o=="style"?s.style=(s.style?s.style+";":"")+c:o!="nodeName"&&(s[o]=c))}}}return r}function G2(t,e,n,s){if(n==da&&s==da)return e;let r=e;for(let a=0;a<s.length;a++){let l=s[a],o=n[a];if(a){let c;o&&o.nodeName==l.nodeName&&r!=t&&(c=r.parentNode)&&c.nodeName.toLowerCase()==l.nodeName||(c=document.createElement(l.nodeName),c.pmIsDeco=!0,c.appendChild(r),o=da[0]),r=c}uF(r,o||da[0],l)}return r}function uF(t,e,n){for(let s in e)s!="class"&&s!="style"&&s!="nodeName"&&!(s in n)&&t.removeAttribute(s);for(let s in n)s!="class"&&s!="style"&&s!="nodeName"&&n[s]!=e[s]&&t.setAttribute(s,n[s]);if(e.class!=n.class){let s=e.class?e.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<s.length;a++)r.indexOf(s[a])==-1&&t.classList.remove(s[a]);for(let a=0;a<r.length;a++)s.indexOf(r[a])==-1&&t.classList.add(r[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let s=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=s.exec(e.style);)t.style.removeProperty(r[1])}n.style&&(t.style.cssText+=n.style)}}function J2(t,e,n){return G2(t,t,da,nx(e,n,t.nodeType!=1))}function bh(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Tj(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class hF{constructor(e,n,s){this.lock=n,this.view=s,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=fF(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let s=e;s<n;s++)this.top.children[s].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,s,r){let a=0,l=this.stack.length>>1,o=Math.min(l,e.length);for(;a<o&&(a==l-1?this.top:this.stack[a+1<<1]).matchesMark(e[a])&&e[a].type.spec.spanning!==!1;)a++;for(;a<l;)this.destroyRest(),this.top.dirty=Ss,this.index=this.stack.pop(),this.top=this.stack.pop(),l--;for(;l<e.length;){this.stack.push(this.top,this.index+1);let c=-1,d=this.top.children.length;r<this.preMatch.index&&(d=Math.min(this.index+3,d));for(let u=this.index;u<d;u++){let h=this.top.children[u];if(h.matchesMark(e[l])&&!this.isLocked(h.dom)){c=u;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=Ua.create(this.top,e[l],n,s);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,l++}}findNodeMatch(e,n,s,r){let a=-1,l;if(r>=this.preMatch.index&&(l=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&l.matchesNode(e,n,s))a=this.top.children.indexOf(l,this.index);else for(let o=this.index,c=Math.min(this.top.children.length,o+5);o<c;o++){let d=this.top.children[o];if(d.matchesNode(e,n,s)&&!this.preMatch.matched.has(d)){a=o;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,s,r,a){let l=this.top.children[r];return l.dirty==cr&&l.dom==l.contentDOM&&(l.dirty=ca),l.update(e,n,s,a)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let s=e.pmViewDesc;if(s){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==s)return r}return-1}e=n}}updateNextNode(e,n,s,r,a,l){for(let o=this.index;o<this.top.children.length;o++){let c=this.top.children[o];if(c instanceof zi){let d=this.preMatch.matched.get(c);if(d!=null&&d!=a)return!1;let u=c.dom,h,m=this.isLocked(u)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=cr&&bh(n,c.outerDeco));if(!m&&c.update(e,n,s,r))return this.destroyBetween(this.index,o),c.dom!=u&&(this.changed=!0),this.index++,!0;if(!m&&(h=this.recreateWrapper(c,e,n,s,r,l)))return this.destroyBetween(this.index,o),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=ca,h.updateChildren(r,l+1),h.dirty=Ss),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,s,r,a,l){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!bh(s,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=zi.create(this.top,n,s,r,a,l);if(o.contentDOM){o.children=e.children,e.children=[];for(let c of o.children)c.parent=o}return e.destroy(),o}addNode(e,n,s,r,a){let l=zi.create(this.top,e,n,s,r,a);l.contentDOM&&l.updateChildren(r,a+1),this.top.children.splice(this.index++,0,l),this.changed=!0}placeWidget(e,n,s){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let a=new H2(this.top,e,n,s);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Ua;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Vf)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((jn||cn)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let s=document.createElement(e);e=="IMG"&&(s.className="ProseMirror-separator",s.alt=""),e=="BR"&&(s.className="ProseMirror-trailingBreak");let r=new W2(this.top,[],s,null);n!=this.top?n.children.push(r):n.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function fF(t,e){let n=e,s=n.children.length,r=t.childCount,a=new Map,l=[];e:for(;r>0;){let o;for(;;)if(s){let d=n.children[s-1];if(d instanceof Ua)n=d,s=d.children.length;else{o=d,s--;break}}else{if(n==e)break e;s=n.parent.children.indexOf(n),n=n.parent}let c=o.node;if(c){if(c!=t.child(r-1))break;--r,a.set(o,r),l.push(o)}}return{index:r,matched:a,matches:l.reverse()}}function mF(t,e){return t.type.side-e.type.side}function pF(t,e,n,s){let r=e.locals(t),a=0;if(r.length==0){for(let d=0;d<t.childCount;d++){let u=t.child(d);s(u,r,e.forChild(a,u),d),a+=u.nodeSize}return}let l=0,o=[],c=null;for(let d=0;;){let u,h;for(;l<r.length&&r[l].to==a;){let x=r[l++];x.widget&&(u?(h||(h=[u])).push(x):u=x)}if(u)if(h){h.sort(mF);for(let x=0;x<h.length;x++)n(h[x],d,!!c)}else n(u,d,!!c);let m,f;if(c)f=-1,m=c,c=null;else if(d<t.childCount)f=d,m=t.child(d++);else break;for(let x=0;x<o.length;x++)o[x].to<=a&&o.splice(x--,1);for(;l<r.length&&r[l].from<=a&&r[l].to>a;)o.push(r[l++]);let p=a+m.nodeSize;if(m.isText){let x=p;l<r.length&&r[l].from<x&&(x=r[l].from);for(let y=0;y<o.length;y++)o[y].to<x&&(x=o[y].to);x<p&&(c=m.cut(x-a),m=m.cut(0,x-a),p=x,f=-1)}else for(;l<r.length&&r[l].to<p;)l++;let g=m.isInline&&!m.isLeaf?o.filter(x=>!x.inline):o.slice();s(m,g,e.forChild(a,m),f),a=p}}function gF(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 xF(t,e,n,s){for(let r=0,a=0;r<t.childCount&&a<=s;){let l=t.child(r++),o=a;if(a+=l.nodeSize,!l.isText)continue;let c=l.text;for(;r<t.childCount;){let d=t.child(r++);if(a+=d.nodeSize,!d.isText)break;c+=d.text}if(a>=n){if(a>=s&&c.slice(s-e.length-o,s-o)==e)return s-e.length;let d=o<s?c.lastIndexOf(e,s-o-1):-1;if(d>=0&&d+e.length+o>=n)return o+d;if(n==s&&c.length>=s+e.length-o&&c.slice(s-o,s-o+e.length)==e)return s}}return-1}function sx(t,e,n,s,r){let a=[];for(let l=0,o=0;l<t.length;l++){let c=t[l],d=o,u=o+=c.size;d>=n||u<=e?a.push(c):(d<e&&a.push(c.slice(0,e-d,s)),r&&(a.push(r),r=void 0),u>n&&a.push(c.slice(n-d,c.size,s)))}return a}function r0(t,e=null){let n=t.domSelectionRange(),s=t.state.doc;if(!n.focusNode)return null;let r=t.docView.nearestDesc(n.focusNode),a=r&&r.size==0,l=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(l<0)return null;let o=s.resolve(l),c,d;if(_f(n)){for(c=l;r&&!r.node;)r=r.parent;let h=r.node;if(r&&h.isAtom&&ke.isSelectable(h)&&r.parent&&!(h.isInline&&UL(n.focusNode,n.focusOffset,r.dom))){let m=r.posBefore;d=new ke(l==m?o:s.resolve(m))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=l,m=l;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);h=Math.min(h,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),m=Math.max(m,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[c,l]=m==t.state.selection.anchor?[m,h]:[h,m],o=s.resolve(l)}else c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=s.resolve(c);if(!d){let h=e=="pointer"||t.state.selection.head<o.pos&&!a?1:-1;d=i0(t,u,o,h)}return d}function Z2(t){return t.editable?t.hasFocus():X2(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Or(t,e=!1){let n=t.state.selection;if(Y2(t,n),!!Z2(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&cn){let s=t.domSelectionRange(),r=t.domObserver.currentSelection;if(s.anchorNode&&r.anchorNode&&Ka(s.anchorNode,s.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)vF(t);else{let{anchor:s,head:r}=n,a,l;Pj&&!(n instanceof De)&&(n.$from.parent.inlineContent||(a=Ij(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Ij(t,n.to))),t.docView.setSelection(s,r,t,e),Pj&&(a&&Rj(a),l&&Rj(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&yF(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Pj=jn||cn&&z2<63;function Ij(t,e){let{node:n,offset:s}=t.docView.domFromPos(e,0),r=s<n.childNodes.length?n.childNodes[s]:null,a=s?n.childNodes[s-1]:null;if(jn&&r&&r.contentEditable=="false")return Zm(r);if((!r||r.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(r)return Zm(r);if(a)return Zm(a)}}function Zm(t){return t.contentEditable="true",jn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Rj(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function yF(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),s=n.anchorNode,r=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=s||n.anchorOffset!=r)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Z2(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function vF(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,s=n.nodeName=="IMG";s?e.collapse(n.parentNode,an(n)+1):e.collapse(n,0),!s&&!t.state.selection.visible&&Zn&&Fi<=11&&(n.disabled=!0,n.disabled=!1)}function Y2(t,e){if(e instanceof ke){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Oj(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Oj(t)}function Oj(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function i0(t,e,n,s){return t.someProp("createSelectionBetween",r=>r(t,e,n))||De.between(e,n,s)}function Lj(t){return t.editable&&!t.hasFocus()?!1:X2(t)}function X2(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function bF(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ka(e.node,e.offset,n.anchorNode,n.anchorOffset)}function rx(t,e){let{$anchor:n,$head:s}=t.selection,r=e>0?n.max(s):n.min(s),a=r.parent.inlineContent?r.depth?t.doc.resolve(e>0?r.after():r.before()):null:r;return a&&Ie.findFrom(a,e)}function ei(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Fj(t,e,n){let s=t.state.selection;if(s instanceof De)if(n.indexOf("s")>-1){let{$head:r}=s,a=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let l=t.state.doc.resolve(r.pos+a.nodeSize*(e<0?-1:1));return ei(t,new De(s.$anchor,l))}else if(s.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let r=rx(t.state,e);return r&&r instanceof ke?ei(t,r):!1}else if(!(ys&&n.indexOf("m")>-1)){let r=s.$head,a=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,l;if(!a||a.isText)return!1;let o=e<0?r.pos-a.nodeSize:r.pos;return a.isAtom||(l=t.docView.descAt(o))&&!l.contentDOM?ke.isSelectable(a)?ei(t,new ke(e<0?t.state.doc.resolve(r.pos-a.nodeSize):r)):Sd?ei(t,new De(t.state.doc.resolve(e<0?o:o+a.nodeSize))):!1:!1}}else return!1;else{if(s instanceof ke&&s.node.isInline)return ei(t,new De(e>0?s.$to:s.$from));{let r=rx(t.state,e);return r?ei(t,r):!1}}}function jh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function cc(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function nl(t,e){return e<0?jF(t):NF(t)}function jF(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let r,a,l=!1;for(ks&&n.nodeType==1&&s<jh(n)&&cc(n.childNodes[s],-1)&&(l=!0);;)if(s>0){if(n.nodeType!=1)break;{let o=n.childNodes[s-1];if(cc(o,-1))r=n,a=--s;else if(o.nodeType==3)n=o,s=n.nodeValue.length;else break}}else{if(eE(n))break;{let o=n.previousSibling;for(;o&&cc(o,-1);)r=n.parentNode,a=an(o),o=o.previousSibling;if(o)n=o,s=jh(n);else{if(n=n.parentNode,n==t.dom)break;s=0}}}l?ix(t,n,s):r&&ix(t,r,a)}function NF(t){let e=t.domSelectionRange(),n=e.focusNode,s=e.focusOffset;if(!n)return;let r=jh(n),a,l;for(;;)if(s<r){if(n.nodeType!=1)break;let o=n.childNodes[s];if(cc(o,1))a=n,l=++s;else break}else{if(eE(n))break;{let o=n.nextSibling;for(;o&&cc(o,1);)a=o.parentNode,l=an(o)+1,o=o.nextSibling;if(o)n=o,s=0,r=jh(n);else{if(n=n.parentNode,n==t.dom)break;s=r=0}}}a&&ix(t,a,l)}function eE(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function wF(t,e){for(;t&&e==t.childNodes.length&&!kd(t);)e=an(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function kF(t,e){for(;t&&!e&&!kd(t);)e=an(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function ix(t,e,n){if(e.nodeType!=3){let a,l;(l=wF(e,n))?(e=l,n=0):(a=kF(e,n))&&(e=a,n=a.nodeValue.length)}let s=t.domSelection();if(!s)return;if(_f(s)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),s.removeAllRanges(),s.addRange(a)}else s.extend&&s.extend(e,n);t.domObserver.setCurSelection();let{state:r}=t;setTimeout(()=>{t.state==r&&Or(t)},50)}function zj(t,e){let n=t.state.doc.resolve(e);if(!(cn||$2)&&n.parent.inlineContent){let r=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),l=(a.top+a.bottom)/2;if(l>r.top&&l<r.bottom&&Math.abs(a.left-r.left)>1)return a.left<r.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),l=(a.top+a.bottom)/2;if(l>r.top&&l<r.bottom&&Math.abs(a.left-r.left)>1)return a.left>r.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function $j(t,e,n){let s=t.state.selection;if(s instanceof De&&!s.empty||n.indexOf("s")>-1||ys&&n.indexOf("m")>-1)return!1;let{$from:r,$to:a}=s;if(!r.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let l=rx(t.state,e);if(l&&l instanceof ke)return ei(t,l)}if(!r.parent.inlineContent){let l=e<0?r:a,o=s instanceof as?Ie.near(l,e):Ie.findFrom(l,e);return o?ei(t,o):!1}return!1}function Bj(t,e){if(!(t.state.selection instanceof De))return!0;let{$head:n,$anchor:s,empty:r}=t.state.selection;if(!n.sameParent(s))return!0;if(!r)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let l=t.state.tr;return e<0?l.delete(n.pos-a.nodeSize,n.pos):l.delete(n.pos,n.pos+a.nodeSize),t.dispatch(l),!0}return!1}function _j(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function SF(t){if(!jn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let s=e.firstChild;_j(t,s,"true"),setTimeout(()=>_j(t,s,"false"),20)}return!1}function CF(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function EF(t,e){let n=e.keyCode,s=CF(e);if(n==8||ys&&n==72&&s=="c")return Bj(t,-1)||nl(t,-1);if(n==46&&!e.shiftKey||ys&&n==68&&s=="c")return Bj(t,1)||nl(t,1);if(n==13||n==27)return!0;if(n==37||ys&&n==66&&s=="c"){let r=n==37?zj(t,t.state.selection.from)=="ltr"?-1:1:-1;return Fj(t,r,s)||nl(t,r)}else if(n==39||ys&&n==70&&s=="c"){let r=n==39?zj(t,t.state.selection.from)=="ltr"?1:-1:1;return Fj(t,r,s)||nl(t,r)}else{if(n==38||ys&&n==80&&s=="c")return $j(t,-1,s)||nl(t,-1);if(n==40||ys&&n==78&&s=="c")return SF(t)||$j(t,1,s)||nl(t,1);if(s==(ys?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function a0(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:s,openStart:r,openEnd:a}=e;for(;r>1&&a>1&&s.childCount==1&&s.firstChild.childCount==1;){r--,a--;let f=s.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),s=f.content}let l=t.someProp("clipboardSerializer")||Ga.fromSchema(t.state.schema),o=aE(),c=o.createElement("div");c.appendChild(l.serializeFragment(s,{document:o}));let d=c.firstChild,u,h=0;for(;d&&d.nodeType==1&&(u=iE[d.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=o.createElement(u[f]);for(;c.firstChild;)p.appendChild(c.firstChild);c.appendChild(p),h++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${r} ${a}${h?` -${h}`:""} ${JSON.stringify(n)}`);let m=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
`);return{dom:c,text:m,slice:e}}function tE(t,e,n,s,r){let a=r.parent.type.spec.code,l,o;if(!n&&!e)return null;let c=!!e&&(s||a||!n);if(c){if(t.someProp("transformPastedText",m=>{e=m(e,a||s,t)}),a)return o=new me(X.from(t.state.schema.text(e.replace(/\r\n?/g,`
`))),0,0),t.someProp("transformPasted",m=>{o=m(o,t,!0)}),o;let h=t.someProp("clipboardTextParser",m=>m(e,r,s,t));if(h)o=h;else{let m=r.marks(),{schema:f}=t.state,p=Ga.fromSchema(f);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let x=l.appendChild(document.createElement("p"));g&&x.appendChild(p.serializeNode(f.text(g,m)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),l=TF(n),Sd&&PF(l);let d=l&&l.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let m=l.firstChild;for(;m&&m.nodeType!=1;)m=m.nextSibling;if(!m)break;l=m}if(o||(o=(t.someProp("clipboardParser")||t.someProp("domParser")||Li.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(c||u),context:r,ruleFromNode(m){return m.nodeName=="BR"&&!m.nextSibling&&m.parentNode&&!AF.test(m.parentNode.nodeName)?{ignore:!0}:null}})),u)o=IF(Vj(o,+u[1],+u[2]),u[4]);else if(o=me.maxOpen(DF(o.content,r),!0),o.openStart||o.openEnd){let h=0,m=0;for(let f=o.content.firstChild;h<o.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=o.content.lastChild;m<o.openEnd&&!f.type.spec.isolating;m++,f=f.lastChild);o=Vj(o,h,m)}return t.someProp("transformPasted",h=>{o=h(o,t,c)}),o}const AF=/^(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 DF(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.index(n)),a,l=[];if(t.forEach(o=>{if(!l)return;let c=r.findWrapping(o.type),d;if(!c)return l=null;if(d=l.length&&a.length&&sE(c,a,o,l[l.length-1],0))l[l.length-1]=d;else{l.length&&(l[l.length-1]=rE(l[l.length-1],a.length));let u=nE(o,c);l.push(u),r=r.matchType(u.type),a=c}}),l)return X.from(l)}return t}function nE(t,e,n=0){for(let s=e.length-1;s>=n;s--)t=e[s].create(null,X.from(t));return t}function sE(t,e,n,s,r){if(r<t.length&&r<e.length&&t[r]==e[r]){let a=sE(t,e,n,s.lastChild,r+1);if(a)return s.copy(s.content.replaceChild(s.childCount-1,a));if(s.contentMatchAt(s.childCount).matchType(r==t.length-1?n.type:t[r+1]))return s.copy(s.content.append(X.from(nE(n,t,r+1))))}}function rE(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,rE(t.lastChild,e-1)),s=t.contentMatchAt(t.childCount).fillBefore(X.empty,!0);return t.copy(n.append(s))}function ax(t,e,n,s,r,a){let l=e<0?t.firstChild:t.lastChild,o=l.content;return t.childCount>1&&(a=0),r<s-1&&(o=ax(o,e,n,s,r+1,a)),r>=n&&(o=e<0?l.contentMatchAt(0).fillBefore(o,a<=r).append(o):o.append(l.contentMatchAt(l.childCount).fillBefore(X.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,l.copy(o))}function Vj(t,e,n){return e<t.openStart&&(t=new me(ax(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new me(ax(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const iE={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Kj=null;function aE(){return Kj||(Kj=document.implementation.createHTMLDocument("title"))}let Ym=null;function MF(t){let e=window.trustedTypes;return e?(Ym||(Ym=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Ym.createHTML(t)):t}function TF(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=aE().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(t),r;if((r=s&&iE[s[1].toLowerCase()])&&(t=r.map(a=>"<"+a+">").join("")+t+r.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=MF(t),r)for(let a=0;a<r.length;a++)n=n.querySelector(r[a])||n;return n}function PF(t){let e=t.querySelectorAll(cn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let s=e[n];s.childNodes.length==1&&s.textContent==" "&&s.parentNode&&s.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),s)}}function IF(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,s;try{s=JSON.parse(e)}catch{return t}let{content:r,openStart:a,openEnd:l}=t;for(let o=s.length-2;o>=0;o-=2){let c=n.nodes[s[o]];if(!c||c.hasRequiredAttrs())break;r=X.from(c.create(s[o+1],r)),a++,l++}return new me(r,a,l)}const Tn={},Pn={},RF={touchstart:!0,touchmove:!0};class OF{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 LF(t){for(let e in Tn){let n=Tn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=s=>{zF(t,s)&&!l0(t,s)&&(t.editable||!(s.type in Pn))&&n(t,s)},RF[e]?{passive:!0}:void 0)}jn&&t.dom.addEventListener("input",()=>null),lx(t)}function Si(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function FF(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function lx(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=s=>l0(t,s))})}function l0(t,e){return t.someProp("handleDOMEvents",n=>{let s=n[e.type];return s?s(t,e)||e.defaultPrevented:!1})}function zF(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function $F(t,e){!l0(t,e)&&Tn[e.type]&&(t.editable||!(e.type in Pn))&&Tn[e.type](t,e)}Pn.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!oE(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Pr&&cn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ao&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let s=Date.now();t.input.lastIOSEnter=s,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==s&&(t.someProp("handleKeyDown",r=>r(t,ta(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",s=>s(t,n))||EF(t,n)?n.preventDefault():Si(t,"key")};Pn.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Pn.keypress=(t,e)=>{let n=e;if(oE(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||ys&&n.metaKey)return;if(t.someProp("handleKeyPress",r=>r(t,n))){n.preventDefault();return}let s=t.state.selection;if(!(s instanceof De)||!s.$from.sameParent(s.$to)){let r=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!t.someProp("handleTextInput",l=>l(t,s.$from.pos,s.$to.pos,r,a))&&t.dispatch(a()),n.preventDefault()}};function Kf(t){return{left:t.clientX,top:t.clientY}}function BF(t,e){let n=e.x-t.clientX,s=e.y-t.clientY;return n*n+s*s<100}function o0(t,e,n,s,r){if(s==-1)return!1;let a=t.state.doc.resolve(s);for(let l=a.depth+1;l>0;l--)if(t.someProp(e,o=>l>a.depth?o(t,n,a.nodeAfter,a.before(l),r,!0):o(t,n,a.node(l),a.before(l),r,!1)))return!0;return!1}function Ml(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let s=t.state.tr.setSelection(e);s.setMeta("pointer",!0),t.dispatch(s)}function _F(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),s=n.nodeAfter;return s&&s.isAtom&&ke.isSelectable(s)?(Ml(t,new ke(n)),!0):!1}function VF(t,e){if(e==-1)return!1;let n=t.state.selection,s,r;n instanceof ke&&(s=n.node);let a=t.state.doc.resolve(e);for(let l=a.depth+1;l>0;l--){let o=l>a.depth?a.nodeAfter:a.node(l);if(ke.isSelectable(o)){s&&n.$from.depth>0&&l>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?r=a.before(n.$from.depth):r=a.before(l);break}}return r!=null?(Ml(t,ke.create(t.state.doc,r)),!0):!1}function KF(t,e,n,s,r){return o0(t,"handleClickOn",e,n,s)||t.someProp("handleClick",a=>a(t,e,s))||(r?VF(t,n):_F(t,n))}function UF(t,e,n,s){return o0(t,"handleDoubleClickOn",e,n,s)||t.someProp("handleDoubleClick",r=>r(t,e,s))}function qF(t,e,n,s){return o0(t,"handleTripleClickOn",e,n,s)||t.someProp("handleTripleClick",r=>r(t,e,s))||HF(t,n,s)}function HF(t,e,n){if(n.button!=0)return!1;let s=t.state.doc;if(e==-1)return s.inlineContent?(Ml(t,De.create(s,0,s.content.size)),!0):!1;let r=s.resolve(e);for(let a=r.depth+1;a>0;a--){let l=a>r.depth?r.nodeAfter:r.node(a),o=r.before(a);if(l.inlineContent)Ml(t,De.create(s,o+1,o+1+l.content.size));else if(ke.isSelectable(l))Ml(t,ke.create(s,o));else continue;return!0}}function c0(t){return Nh(t)}const lE=ys?"metaKey":"ctrlKey";Tn.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let s=c0(t),r=Date.now(),a="singleClick";r-t.input.lastClick.time<500&&BF(n,t.input.lastClick)&&!n[lE]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:a,button:n.button};let l=t.posAtCoords(Kf(n));l&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new WF(t,l,n,!!s)):(a=="doubleClick"?UF:qF)(t,l.pos,l.inside,n)?n.preventDefault():Si(t,"pointer"))};class WF{constructor(e,n,s,r){this.view=e,this.pos=n,this.event=s,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!s[lE],this.allowDefault=s.shiftKey;let a,l;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),l=n.inside;else{let u=e.state.doc.resolve(n.pos);a=u.parent,l=u.depth?u.before():0}const o=r?null:s.target,c=o?e.docView.nearestDesc(o,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=e.state;(s.button==0&&a.type.spec.draggable&&a.type.spec.selectable!==!1||d instanceof ke&&d.from<=l&&d.to>l)&&(this.mightDrag={node:a,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ks&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Si(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Or(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Kf(e))),this.updateAllowDefault(e),this.allowDefault||!n?Si(this.view,"pointer"):KF(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||jn&&this.mightDrag&&!this.mightDrag.node.isAtom||cn&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Ml(this.view,Ie.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Si(this.view,"pointer")}move(e){this.updateAllowDefault(e),Si(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Tn.touchstart=t=>{t.input.lastTouch=Date.now(),c0(t),Si(t,"pointer")};Tn.touchmove=t=>{t.input.lastTouch=Date.now(),Si(t,"pointer")};Tn.contextmenu=t=>c0(t);function oE(t,e){return t.composing?!0:jn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const QF=Pr?5e3:-1;Pn.compositionstart=Pn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof De&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)||cn&&$2&&GF(t)))t.markCursor=t.state.storedMarks||n.marks(),Nh(t,!0),t.markCursor=null;else if(Nh(t,!e.selection.empty),ks&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let s=t.domSelectionRange();for(let r=s.focusNode,a=s.focusOffset;r&&r.nodeType==1&&a!=0;){let l=a<0?r.lastChild:r.childNodes[a-1];if(!l)break;if(l.nodeType==3){let o=t.domSelection();o&&o.collapse(l,l.nodeValue.length);break}else r=l,a=-1}}t.input.composing=!0}cE(t,QF)};function GF(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let s=e.childNodes[n];return s.nodeType==1&&s.contentEditable=="false"}Pn.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,cE(t,20))};function cE(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Nh(t),e))}function dE(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=ZF());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function JF(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=VL(e.focusNode,e.focusOffset),s=KL(e.focusNode,e.focusOffset);if(n&&s&&n!=s){let r=s.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||s==a)return a;if(!r||!r.isText(s.nodeValue))return s;if(t.input.compositionNode==s){let l=n.pmViewDesc;if(!(!l||!l.isText(n.nodeValue)))return s}}return n||s}function ZF(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Nh(t,e=!1){if(!(Pr&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),dE(t),e||t.docView&&t.docView.dirty){let n=r0(t),s=t.state.selection;return n&&!n.eq(s)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!s.$from.node(s.$from.sharedDepth(s.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function YF(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),r=document.createRange();r.selectNodeContents(e),t.dom.blur(),s.removeAllRanges(),s.addRange(r),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Wc=Zn&&Fi<15||ao&&WL<604;Tn.copy=Pn.cut=(t,e)=>{let n=e,s=t.state.selection,r=n.type=="cut";if(s.empty)return;let a=Wc?null:n.clipboardData,l=s.content(),{dom:o,text:c}=a0(t,l);a?(n.preventDefault(),a.clearData(),a.setData("text/html",o.innerHTML),a.setData("text/plain",c)):YF(t,o),r&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function XF(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function e6(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,s=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let r=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),s.parentNode&&s.parentNode.removeChild(s),n?Qc(t,s.value,null,r,e):Qc(t,s.textContent,s.innerHTML,r,e)},50)}function Qc(t,e,n,s,r){let a=tE(t,e,n,s,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,r,a||me.empty)))return!0;if(!a)return!1;let l=XF(a),o=l?t.state.tr.replaceSelectionWith(l,s):t.state.tr.replaceSelection(a);return t.dispatch(o.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function uE(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Pn.paste=(t,e)=>{let n=e;if(t.composing&&!Pr)return;let s=Wc?null:n.clipboardData,r=t.input.shiftKey&&t.input.lastKeyCode!=45;s&&Qc(t,uE(s),s.getData("text/html"),r,n)?n.preventDefault():e6(t,n)};class hE{constructor(e,n,s){this.slice=e,this.move=n,this.node=s}}const t6=ys?"altKey":"ctrlKey";function fE(t,e){let n=t.someProp("dragCopies",s=>!s(e));return n??!e[t6]}Tn.dragstart=(t,e)=>{let n=e,s=t.input.mouseDown;if(s&&s.done(),!n.dataTransfer)return;let r=t.state.selection,a=r.empty?null:t.posAtCoords(Kf(n)),l;if(!(a&&a.pos>=r.from&&a.pos<=(r instanceof ke?r.to-1:r.to))){if(s&&s.mightDrag)l=ke.create(t.state.doc,s.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(l=ke.create(t.state.doc,h.posBefore))}}let o=(l||t.state.selection).content(),{dom:c,text:d,slice:u}=a0(t,o);(!n.dataTransfer.files.length||!cn||z2>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Wc?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Wc||n.dataTransfer.setData("text/plain",d),t.dragging=new hE(u,fE(t,n),l)};Tn.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Pn.dragover=Pn.dragenter=(t,e)=>e.preventDefault();Pn.drop=(t,e)=>{try{n6(t,e,t.dragging)}finally{t.dragging=null}};function n6(t,e,n){if(!e.dataTransfer)return;let s=t.posAtCoords(Kf(e));if(!s)return;let r=t.state.doc.resolve(s.pos),a=n&&n.slice;a?t.someProp("transformPasted",f=>{a=f(a,t,!1)}):a=tE(t,uE(e.dataTransfer),Wc?null:e.dataTransfer.getData("text/html"),!1,r);let l=!!(n&&fE(t,e));if(t.someProp("handleDrop",f=>f(t,e,a||me.empty,l))){e.preventDefault();return}if(!a)return;e.preventDefault();let o=a?x2(t.state.doc,r.pos,a):r.pos;o==null&&(o=r.pos);let c=t.state.tr;if(l){let{node:f}=n;f?f.replace(c):c.deleteSelection()}let d=c.mapping.map(o),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,a.content.firstChild):c.replaceRange(d,d,a),c.doc.eq(h))return;let m=c.doc.resolve(d);if(u&&ke.isSelectable(a.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new ke(m));else{let f=c.mapping.map(o);c.mapping.maps[c.mapping.maps.length-1].forEach((p,g,x,y)=>f=y),c.setSelection(i0(t,m,c.doc.resolve(f)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}Tn.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())&&Or(t)},20))};Tn.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Tn.beforeinput=(t,e)=>{if(cn&&Pr&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:s}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=s||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,ta(8,"Backspace")))))return;let{$cursor:r}=t.state.selection;r&&r.pos>0&&t.dispatch(t.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let t in Pn)Tn[t]=Pn[t];function Gc(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class wh{constructor(e,n){this.toDOM=e,this.spec=n||Da,this.side=this.spec.side||0}map(e,n,s,r){let{pos:a,deleted:l}=e.mapResult(n.from+r,this.side<0?-1:1);return l?null:new An(a-s,a-s,this)}valid(){return!0}eq(e){return this==e||e instanceof wh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Gc(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class $i{constructor(e,n){this.attrs=e,this.spec=n||Da}map(e,n,s,r){let a=e.map(n.from+r,this.spec.inclusiveStart?-1:1)-s,l=e.map(n.to+r,this.spec.inclusiveEnd?1:-1)-s;return a>=l?null:new An(a,l,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof $i&&Gc(this.attrs,e.attrs)&&Gc(this.spec,e.spec)}static is(e){return e.type instanceof $i}destroy(){}}class d0{constructor(e,n){this.attrs=e,this.spec=n||Da}map(e,n,s,r){let a=e.mapResult(n.from+r,1);if(a.deleted)return null;let l=e.mapResult(n.to+r,-1);return l.deleted||l.pos<=a.pos?null:new An(a.pos-s,l.pos-s,this)}valid(e,n){let{index:s,offset:r}=e.content.findIndex(n.from),a;return r==n.from&&!(a=e.child(s)).isText&&r+a.nodeSize==n.to}eq(e){return this==e||e instanceof d0&&Gc(this.attrs,e.attrs)&&Gc(this.spec,e.spec)}destroy(){}}class An{constructor(e,n,s){this.from=e,this.to=n,this.type=s}copy(e,n){return new An(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,s){return this.type.map(e,this,n,s)}static widget(e,n,s){return new An(e,e,new wh(n,s))}static inline(e,n,s,r){return new An(e,n,new $i(s,r))}static node(e,n,s,r){return new An(e,n,new d0(s,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof $i}get widget(){return this.type instanceof wh}}const al=[],Da={};class yt{constructor(e,n){this.local=e.length?e:al,this.children=n.length?n:al}static create(e,n){return n.length?kh(n,e,0,Da):gn}find(e,n,s){let r=[];return this.findInner(e??0,n??1e9,r,0,s),r}findInner(e,n,s,r,a){for(let l=0;l<this.local.length;l++){let o=this.local[l];o.from<=n&&o.to>=e&&(!a||a(o.spec))&&s.push(o.copy(o.from+r,o.to+r))}for(let l=0;l<this.children.length;l+=3)if(this.children[l]<n&&this.children[l+1]>e){let o=this.children[l]+1;this.children[l+2].findInner(e-o,n-o,s,r+o,a)}}map(e,n,s){return this==gn||e.maps.length==0?this:this.mapInner(e,n,0,0,s||Da)}mapInner(e,n,s,r,a){let l;for(let o=0;o<this.local.length;o++){let c=this.local[o].map(e,s,r);c&&c.type.valid(n,c)?(l||(l=[])).push(c):a.onRemove&&a.onRemove(this.local[o].spec)}return this.children.length?s6(this.children,l||[],e,n,s,r,a):l?new yt(l.sort(Ma),al):gn}add(e,n){return n.length?this==gn?yt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,s){let r,a=0;e.forEach((o,c)=>{let d=c+s,u;if(u=pE(n,o,d)){for(r||(r=this.children.slice());a<r.length&&r[a]<c;)a+=3;r[a]==c?r[a+2]=r[a+2].addInner(o,u,d+1):r.splice(a,0,c,c+o.nodeSize,kh(u,o,d+1,Da)),a+=3}});let l=mE(a?gE(n):n,-s);for(let o=0;o<l.length;o++)l[o].type.valid(e,l[o])||l.splice(o--,1);return new yt(l.length?this.local.concat(l).sort(Ma):this.local,r||this.children)}remove(e){return e.length==0||this==gn?this:this.removeInner(e,0)}removeInner(e,n){let s=this.children,r=this.local;for(let a=0;a<s.length;a+=3){let l,o=s[a]+n,c=s[a+1]+n;for(let u=0,h;u<e.length;u++)(h=e[u])&&h.from>o&&h.to<c&&(e[u]=null,(l||(l=[])).push(h));if(!l)continue;s==this.children&&(s=this.children.slice());let d=s[a+2].removeInner(l,o+1);d!=gn?s[a+2]=d:(s.splice(a,3),a-=3)}if(r.length){for(let a=0,l;a<e.length;a++)if(l=e[a])for(let o=0;o<r.length;o++)r[o].eq(l,n)&&(r==this.local&&(r=this.local.slice()),r.splice(o--,1))}return s==this.children&&r==this.local?this:r.length||s.length?new yt(r,s):gn}forChild(e,n){if(this==gn)return this;if(n.isLeaf)return yt.empty;let s,r;for(let o=0;o<this.children.length;o+=3)if(this.children[o]>=e){this.children[o]==e&&(s=this.children[o+2]);break}let a=e+1,l=a+n.content.size;for(let o=0;o<this.local.length;o++){let c=this.local[o];if(c.from<l&&c.to>a&&c.type instanceof $i){let d=Math.max(a,c.from)-a,u=Math.min(l,c.to)-a;d<u&&(r||(r=[])).push(c.copy(d,u))}}if(r){let o=new yt(r.sort(Ma),al);return s?new oi([o,s]):o}return s||gn}eq(e){if(this==e)return!0;if(!(e instanceof yt)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return u0(this.localsInner(e))}localsInner(e){if(this==gn)return al;if(e.inlineContent||!this.local.some($i.is))return this.local;let n=[];for(let s=0;s<this.local.length;s++)this.local[s].type instanceof $i||n.push(this.local[s]);return n}forEachSet(e){e(this)}}yt.empty=new yt([],[]);yt.removeOverlap=u0;const gn=yt.empty;class oi{constructor(e){this.members=e}map(e,n){const s=this.members.map(r=>r.map(e,n,Da));return oi.from(s)}forChild(e,n){if(n.isLeaf)return yt.empty;let s=[];for(let r=0;r<this.members.length;r++){let a=this.members[r].forChild(e,n);a!=gn&&(a instanceof oi?s=s.concat(a.members):s.push(a))}return oi.from(s)}eq(e){if(!(e instanceof oi)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,s=!0;for(let r=0;r<this.members.length;r++){let a=this.members[r].localsInner(e);if(a.length)if(!n)n=a;else{s&&(n=n.slice(),s=!1);for(let l=0;l<a.length;l++)n.push(a[l])}}return n?u0(s?n:n.sort(Ma)):al}static from(e){switch(e.length){case 0:return gn;case 1:return e[0];default:return new oi(e.every(n=>n instanceof yt)?e:e.reduce((n,s)=>n.concat(s instanceof yt?s:s.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function s6(t,e,n,s,r,a,l){let o=t.slice();for(let d=0,u=a;d<n.maps.length;d++){let h=0;n.maps[d].forEach((m,f,p,g)=>{let x=g-p-(f-m);for(let y=0;y<o.length;y+=3){let v=o[y+1];if(v<0||m>v+u-h)continue;let b=o[y]+u-h;f>=b?o[y+1]=m<=b?-2:-1:m>=u&&x&&(o[y]+=x,o[y+1]+=x)}h+=x}),u=n.maps[d].map(u,-1)}let c=!1;for(let d=0;d<o.length;d+=3)if(o[d+1]<0){if(o[d+1]==-2){c=!0,o[d+1]=-1;continue}let u=n.map(t[d]+a),h=u-r;if(h<0||h>=s.content.size){c=!0;continue}let m=n.map(t[d+1]+a,-1),f=m-r,{index:p,offset:g}=s.content.findIndex(h),x=s.maybeChild(p);if(x&&g==h&&g+x.nodeSize==f){let y=o[d+2].mapInner(n,x,u+1,t[d]+a+1,l);y!=gn?(o[d]=h,o[d+1]=f,o[d+2]=y):(o[d+1]=-2,c=!0)}else c=!0}if(c){let d=r6(o,t,e,n,r,a,l),u=kh(d,s,0,l);e=u.local;for(let h=0;h<o.length;h+=3)o[h+1]<0&&(o.splice(h,3),h-=3);for(let h=0,m=0;h<u.children.length;h+=3){let f=u.children[h];for(;m<o.length&&o[m]<f;)m+=3;o.splice(m,0,u.children[h],u.children[h+1],u.children[h+2])}}return new yt(e.sort(Ma),o)}function mE(t,e){if(!e||!t.length)return t;let n=[];for(let s=0;s<t.length;s++){let r=t[s];n.push(new An(r.from+e,r.to+e,r.type))}return n}function r6(t,e,n,s,r,a,l){function o(c,d){for(let u=0;u<c.local.length;u++){let h=c.local[u].map(s,r,d);h?n.push(h):l.onRemove&&l.onRemove(c.local[u].spec)}for(let u=0;u<c.children.length;u+=3)o(c.children[u+2],c.children[u]+d+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&o(t[c+2],e[c]+a+1);return n}function pE(t,e,n){if(e.isLeaf)return null;let s=n+e.nodeSize,r=null;for(let a=0,l;a<t.length;a++)(l=t[a])&&l.from>n&&l.to<s&&((r||(r=[])).push(l),t[a]=null);return r}function gE(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function kh(t,e,n,s){let r=[],a=!1;e.forEach((o,c)=>{let d=pE(t,o,c+n);if(d){a=!0;let u=kh(d,o,n+c+1,s);u!=gn&&r.push(c,c+o.nodeSize,u)}});let l=mE(a?gE(t):t,-n).sort(Ma);for(let o=0;o<l.length;o++)l[o].type.valid(e,l[o])||(s.onRemove&&s.onRemove(l[o].spec),l.splice(o--,1));return l.length||r.length?new yt(l,r):gn}function Ma(t,e){return t.from-e.from||t.to-e.to}function u0(t){let e=t;for(let n=0;n<e.length-1;n++){let s=e[n];if(s.from!=s.to)for(let r=n+1;r<e.length;r++){let a=e[r];if(a.from==s.from){a.to!=s.to&&(e==t&&(e=t.slice()),e[r]=a.copy(a.from,s.to),Uj(e,r+1,a.copy(s.to,a.to)));continue}else{a.from<s.to&&(e==t&&(e=t.slice()),e[n]=s.copy(s.from,a.from),Uj(e,r,s.copy(a.from,s.to)));break}}}return e}function Uj(t,e,n){for(;e<t.length&&Ma(n,t[e])>0;)e++;t.splice(e,0,n)}function Xm(t){let e=[];return t.someProp("decorations",n=>{let s=n(t.state);s&&s!=gn&&e.push(s)}),t.cursorWrapper&&e.push(yt.create(t.state.doc,[t.cursorWrapper.deco])),oi.from(e)}const i6={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},a6=Zn&&Fi<=11;class l6{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 o6{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new l6,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let r=0;r<s.length;r++)this.queue.push(s[r]);Zn&&Fi<=11&&s.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():jn&&e.composing&&s.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),a6&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.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,i6)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Lj(this.view)){if(this.suppressingSelectionUpdates)return Or(this.view);if(Zn&&Fi<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ka(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,s;for(let a=e.focusNode;a;a=io(a))n.add(a);for(let a=e.anchorNode;a;a=io(a))if(n.has(a)){s=a;break}let r=s&&this.view.docView.nearestDesc(s);if(r&&r.ignoreMutation({type:"selection",target:s.nodeType==3?s.parentNode:s}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let s=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&Lj(e)&&!this.ignoreSelectionChange(s),a=-1,l=-1,o=!1,c=[];if(e.editable)for(let u=0;u<n.length;u++){let h=this.registerMutation(n[u],c);h&&(a=a<0?h.from:Math.min(h.from,a),l=l<0?h.to:Math.max(h.to,l),h.typeOver&&(o=!0))}if(c.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of c)if(u.nodeName=="BR"&&u.parentNode){let h=u.nextSibling;h&&h.nodeType==1&&h.contentEditable=="false"&&u.parentNode.removeChild(u)}}else if(ks&&c.length){let u=c.filter(h=>h.nodeName=="BR");if(u.length==2){let[h,m]=u;h.parentNode&&h.parentNode.parentNode==m.parentNode?m.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let m of u){let f=m.parentNode;f&&f.nodeName=="LI"&&(!h||u6(e,h)!=f)&&m.remove()}}}let d=null;a<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&_f(s)&&(d=r0(e))&&d.eq(Ie.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Or(e),this.currentSelection.set(s),e.scrollToSelection()):(a>-1||r)&&(a>-1&&(e.docView.markDirty(a,l),c6(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,h6(e,c)),this.handleDOMChange(a,l,o,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||Or(e),this.currentSelection.set(s))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let h=e.addedNodes[u];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(s.contentDOM&&s.contentDOM!=s.dom&&!s.contentDOM.contains(e.target))return{from:s.posBefore,to:s.posAfter};let r=e.previousSibling,a=e.nextSibling;if(Zn&&Fi<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:h,nextSibling:m}=e.addedNodes[u];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(r=h),(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(a=m)}let l=r&&r.parentNode==e.target?an(r)+1:0,o=s.localPosFromDOM(e.target,l,-1),c=a&&a.parentNode==e.target?an(a):e.target.childNodes.length,d=s.localPosFromDOM(e.target,c,1);return{from:o,to:d}}else return e.type=="attributes"?{from:s.posAtStart-s.border,to:s.posAtEnd+s.border}:(this.lastChangedTextNode=e.target,{from:s.posAtStart,to:s.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let qj=new WeakMap,Hj=!1;function c6(t){if(!qj.has(t)&&(qj.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=ks,Hj)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."),Hj=!0}}function Wj(t,e){let n=e.startContainer,s=e.startOffset,r=e.endContainer,a=e.endOffset,l=t.domAtPos(t.state.selection.anchor);return Ka(l.node,l.offset,r,a)&&([n,s,r,a]=[r,a,n,s]),{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:a}}function d6(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return Wj(t,r)}let n;function s(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",s,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",s,!0),n?Wj(t,n):null}function u6(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let s=t.docView.nearestDesc(n,!0);if(s&&s.node.isBlock)return n}return null}function h6(t,e){var n;let{focusNode:s,focusOffset:r}=t.domSelectionRange();for(let a of e)if(((n=a.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let l=a.nextSibling;for(;l&&l.nodeName!="TD"&&l.nodeName!="TH";)l=l.nextSibling;if(l){let o=l;for(;;){let c=o.firstChild;if(!c||c.nodeType!=1||c.contentEditable=="false"||/^(BR|IMG)$/.test(c.nodeName))break;o=c}o.insertBefore(a,o.firstChild),s==a&&t.domSelection().collapse(a,r)}else a.parentNode.removeChild(a)}}function f6(t,e,n){let{node:s,fromOffset:r,toOffset:a,from:l,to:o}=t.docView.parseRange(e,n),c=t.domSelectionRange(),d,u=c.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(d=[{node:u,offset:c.anchorOffset}],_f(c)||d.push({node:c.focusNode,offset:c.focusOffset})),cn&&t.input.lastKeyCode===8)for(let x=a;x>r;x--){let y=s.childNodes[x-1],v=y.pmViewDesc;if(y.nodeName=="BR"&&!v){a=x;break}if(!v||v.size)break}let h=t.state.doc,m=t.someProp("domParser")||Li.fromSchema(t.state.schema),f=h.resolve(l),p=null,g=m.parse(s,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:r,to:a,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:m6,context:f});if(d&&d[0].pos!=null){let x=d[0].pos,y=d[1]&&d[1].pos;y==null&&(y=x),p={anchor:x+l,head:y+l}}return{doc:g,sel:p,from:l,to:o}}function m6(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(jn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||jn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const p6=/^(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 g6(t,e,n,s,r){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let T=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,w=r0(t,T);if(w&&!t.state.selection.eq(w)){if(cn&&Pr&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",M=>M(t,ta(13,"Enter"))))return;let S=t.state.tr.setSelection(w);T=="pointer"?S.setMeta("pointer",!0):T=="key"&&S.scrollIntoView(),a&&S.setMeta("composition",a),t.dispatch(S)}return}let l=t.state.doc.resolve(e),o=l.sharedDepth(n);e=l.before(o+1),n=t.state.doc.resolve(n).after(o+1);let c=t.state.selection,d=f6(t,e,n),u=t.state.doc,h=u.slice(d.from,d.to),m,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,f="end"):(m=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=v6(h.content,d.doc.content,d.from,m,f);if(p&&t.input.domChangeCount++,(ao&&t.input.lastIOSEnter>Date.now()-225||Pr)&&r.some(T=>T.nodeType==1&&!p6.test(T.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",T=>T(t,ta(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(s&&c instanceof De&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))p={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let T=Qj(t,t.state.doc,d.sel);if(T&&!T.eq(t.state.selection)){let w=t.state.tr.setSelection(T);a&&w.setMeta("composition",a),t.dispatch(w)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof De&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=d.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=d.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Zn&&Fi<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>d.from&&d.doc.textBetween(p.start-d.from-1,p.start-d.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let g=d.doc.resolveNoCache(p.start-d.from),x=d.doc.resolveNoCache(p.endB-d.from),y=u.resolve(p.start),v=g.sameParent(x)&&g.parent.inlineContent&&y.end()>=p.endA;if((ao&&t.input.lastIOSEnter>Date.now()-225&&(!v||r.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!v&&g.pos<d.doc.content.size&&(!g.sameParent(x)||!g.parent.inlineContent)&&g.pos<x.pos&&!/\S/.test(d.doc.textBetween(g.pos,x.pos,"","")))&&t.someProp("handleKeyDown",T=>T(t,ta(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&y6(u,p.start,p.endA,g,x)&&t.someProp("handleKeyDown",T=>T(t,ta(8,"Backspace")))){Pr&&cn&&t.domObserver.suppressSelectionUpdates();return}cn&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Pr&&!v&&g.start()!=x.start()&&x.parentOffset==0&&g.depth==x.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==p.endA&&(p.endB-=2,x=d.doc.resolveNoCache(p.endB-d.from),setTimeout(()=>{t.someProp("handleKeyDown",function(T){return T(t,ta(13,"Enter"))})},20));let b=p.start,j=p.endA,k=T=>{let w=T||t.state.tr.replace(b,j,d.doc.slice(p.start-d.from,p.endB-d.from));if(d.sel){let S=Qj(t,w.doc,d.sel);S&&!(cn&&t.composing&&S.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(S.head==b||S.head==w.mapping.map(j)-1)||Zn&&S.empty&&S.head==b)&&w.setSelection(S)}return a&&w.setMeta("composition",a),w.scrollIntoView()},E;if(v)if(g.pos==x.pos){Zn&&Fi<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Or(t),20));let T=k(t.state.tr.delete(b,j)),w=u.resolve(p.start).marksAcross(u.resolve(p.endA));w&&T.ensureMarks(w),t.dispatch(T)}else if(p.endA==p.endB&&(E=x6(g.parent.content.cut(g.parentOffset,x.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start())))){let T=k(t.state.tr);E.type=="add"?T.addMark(b,j,E.mark):T.removeMark(b,j,E.mark),t.dispatch(T)}else if(g.parent.child(g.index()).isText&&g.index()==x.index()-(x.textOffset?0:1)){let T=g.parent.textBetween(g.parentOffset,x.parentOffset),w=()=>k(t.state.tr.insertText(T,b,j));t.someProp("handleTextInput",S=>S(t,b,j,T,w))||t.dispatch(w())}else t.dispatch(k());else t.dispatch(k())}function Qj(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:i0(t,e.resolve(n.anchor),e.resolve(n.head))}function x6(t,e){let n=t.firstChild.marks,s=e.firstChild.marks,r=n,a=s,l,o,c;for(let u=0;u<s.length;u++)r=s[u].removeFromSet(r);for(let u=0;u<n.length;u++)a=n[u].removeFromSet(a);if(r.length==1&&a.length==0)o=r[0],l="add",c=u=>u.mark(o.addToSet(u.marks));else if(r.length==0&&a.length==1)o=a[0],l="remove",c=u=>u.mark(o.removeFromSet(u.marks));else return null;let d=[];for(let u=0;u<e.childCount;u++)d.push(c(e.child(u)));if(X.from(d).eq(t))return{mark:o,type:l}}function y6(t,e,n,s,r){if(n-e<=r.pos-s.pos||ep(s,!0,!1)<r.pos)return!1;let a=t.resolve(e);if(!s.parent.isTextblock){let o=a.nodeAfter;return o!=null&&n==e+o.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let l=t.resolve(ep(a,!0,!0));return!l.parent.isTextblock||l.pos>n||ep(l,!0,!1)<n?!1:s.parent.content.cut(s.parentOffset).eq(l.parent.content)}function ep(t,e,n){let s=t.depth,r=e?t.end():t.pos;for(;s>0&&(e||t.indexAfter(s)==t.node(s).childCount);)s--,r++,e=!1;if(n){let a=t.node(s).maybeChild(t.indexAfter(s));for(;a&&!a.isLeaf;)a=a.firstChild,r++}return r}function v6(t,e,n,s,r){let a=t.findDiffStart(e,n);if(a==null)return null;let{a:l,b:o}=t.findDiffEnd(e,n+t.size,n+e.size);if(r=="end"){let c=Math.max(0,a-Math.min(l,o));s-=l+c-a}if(l<a&&t.size<e.size){let c=s<=a&&s>=l?a-s:0;a-=c,a&&a<e.size&&Gj(e.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}else if(o<a){let c=s<=a&&s>=o?a-s:0;a-=c,a&&a<t.size&&Gj(t.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-o),o=a}return{start:a,endA:l,endB:o}}function Gj(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class xE{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new OF,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(eN),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=Yj(this),Zj(this),this.nodeViews=Xj(this),this.docView=Mj(this.state.doc,Jj(this),Xm(this),this.dom,this),this.domObserver=new o6(this,(s,r,a,l)=>g6(this,s,r,a,l)),this.domObserver.start(),LF(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&lx(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(eN),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let s in this._props)n[s]=this._props[s];n.state=this.state;for(let s in e)n[s]=e[s];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var s;let r=this.state,a=!1,l=!1;e.storedMarks&&this.composing&&(dE(this),l=!0),this.state=e;let o=r.plugins!=e.plugins||this._props.plugins!=n.plugins;if(o||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=Xj(this);j6(f,this.nodeViews)&&(this.nodeViews=f,a=!0)}(o||n.handleDOMEvents!=this._props.handleDOMEvents)&&lx(this),this.editable=Yj(this),Zj(this);let c=Xm(this),d=Jj(this),u=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",h=a||!this.docView.matchesNode(e.doc,d,c);(h||!e.selection.eq(r.selection))&&(l=!0);let m=u=="preserve"&&l&&this.dom.style.overflowAnchor==null&&JL(this);if(l){this.domObserver.stop();let f=h&&(Zn||cn)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&b6(r.selection,e.selection);if(h){let p=cn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=JF(this)),(a||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=Mj(e.doc,d,c,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&bF(this))?Or(this,f):(Y2(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!((s=this.dragging)===null||s===void 0)&&s.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():m&&ZL(m)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof ke){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&kj(this,n.getBoundingClientRect(),e)}else kj(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let s=this.directPlugins[n];s.spec.view&&this.pluginViews.push(s.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let s=this.state.plugins[n];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let s=this.pluginViews[n];s.update&&s.update(this,e)}}updateDraggedNode(e,n){let s=e.node,r=-1;if(this.state.doc.nodeAt(s.from)==s.node)r=s.from;else{let a=s.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==s.node&&(r=a)}this.dragging=new hE(e.slice,e.move,r<0?void 0:ke.create(this.state.doc,r))}someProp(e,n){let s=this._props&&this._props[e],r;if(s!=null&&(r=n?n(s):s))return r;for(let l=0;l<this.directPlugins.length;l++){let o=this.directPlugins[l].props[e];if(o!=null&&(r=n?n(o):o))return r}let a=this.state.plugins;if(a)for(let l=0;l<a.length;l++){let o=a[l].props[e];if(o!=null&&(r=n?n(o):o))return r}}hasFocus(){if(Zn){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&&YL(this.dom),Or(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return sF(this,e)}coordsAtPos(e,n=1){return U2(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,s=-1){let r=this.docView.posFromDOM(e,n,s);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,n){return oF(this,n||this.state,e)}pasteHTML(e,n){return Qc(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Qc(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return a0(this,e)}destroy(){this.docView&&(FF(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Xm(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,BL())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return $F(this,e)}domSelectionRange(){let e=this.domSelection();return e?jn&&this.root.nodeType===11&&qL(this.dom.ownerDocument)==this.dom&&d6(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}xE.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Jj(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let s in n)s=="class"?e.class+=" "+n[s]:s=="style"?e.style=(e.style?e.style+";":"")+n[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(n[s]))}),e.translate||(e.translate="no"),[An.node(0,t.state.doc.content.size,e)]}function Zj(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:An.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Yj(t){return!t.someProp("editable",e=>e(t.state)===!1)}function b6(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function Xj(t){let e=Object.create(null);function n(s){for(let r in s)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=s[r])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function j6(t,e){let n=0,s=0;for(let r in t){if(t[r]!=e[r])return!0;n++}for(let r in e)s++;return n!=s}function eN(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 Vi={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:"'"},Sh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},N6=typeof navigator<"u"&&/Mac/.test(navigator.platform),w6=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ln=0;ln<10;ln++)Vi[48+ln]=Vi[96+ln]=String(ln);for(var ln=1;ln<=24;ln++)Vi[ln+111]="F"+ln;for(var ln=65;ln<=90;ln++)Vi[ln]=String.fromCharCode(ln+32),Sh[ln]=String.fromCharCode(ln);for(var tp in Vi)Sh.hasOwnProperty(tp)||(Sh[tp]=Vi[tp]);function k6(t){var e=N6&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||w6&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sh:Vi)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const S6=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),C6=typeof navigator<"u"&&/Win/.test(navigator.platform);function E6(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let s,r,a,l;for(let o=0;o<e.length-1;o++){let c=e[o];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))s=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))S6?l=!0:r=!0;else throw new Error("Unrecognized modifier name: "+c)}return s&&(n="Alt-"+n),r&&(n="Ctrl-"+n),l&&(n="Meta-"+n),a&&(n="Shift-"+n),n}function A6(t){let e=Object.create(null);for(let n in t)e[E6(n)]=t[n];return e}function np(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function D6(t){return new Nt({props:{handleKeyDown:yE(t)}})}function yE(t){let e=A6(t);return function(n,s){let r=k6(s),a,l=e[np(r,s)];if(l&&l(n.state,n.dispatch,n))return!0;if(r.length==1&&r!=" "){if(s.shiftKey){let o=e[np(r,s,!1)];if(o&&o(n.state,n.dispatch,n))return!0}if((s.altKey||s.metaKey||s.ctrlKey)&&!(C6&&s.ctrlKey&&s.altKey)&&(a=Vi[s.keyCode])&&a!=r){let o=e[np(a,s)];if(o&&o(n.state,n.dispatch,n))return!0}}return!1}}var M6=Object.defineProperty,h0=(t,e)=>{for(var n in e)M6(t,n,{get:e[n],enumerable:!0})};function Uf(t){const{state:e,transaction:n}=t;let{selection:s}=n,{doc:r}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return s},get doc(){return r},get tr(){return s=n.selection,r=n.doc,a=n.storedMarks,n}}}var qf=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:s}=e,{tr:r}=n,a=this.buildProps(r);return Object.fromEntries(Object.entries(t).map(([l,o])=>[l,(...d)=>{const u=o(...d)(a);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(r),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:s,state:r}=this,{view:a}=s,l=[],o=!!t,c=t||r.tr,d=()=>(!o&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),l.every(h=>h===!0)),u={...Object.fromEntries(Object.entries(n).map(([h,m])=>[h,(...p)=>{const g=this.buildProps(c,e),x=m(...p)(g);return l.push(x),u}])),run:d};return u}createCan(t){const{rawCommands:e,state:n}=this,s=!1,r=t||n.tr,a=this.buildProps(r,s);return{...Object.fromEntries(Object.entries(e).map(([o,c])=>[o,(...d)=>c(...d)({...a,dispatch:void 0})])),chain:()=>this.createChain(r,s)}}buildProps(t,e=!0){const{rawCommands:n,editor:s,state:r}=this,{view:a}=s,l={tr:t,editor:s,view:a,state:Uf({state:r,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([o,c])=>[o,(...d)=>c(...d)(l)]))}};return l}},vE={};h0(vE,{blur:()=>T6,clearContent:()=>P6,clearNodes:()=>I6,command:()=>R6,createParagraphNear:()=>O6,cut:()=>L6,deleteCurrentNode:()=>F6,deleteNode:()=>z6,deleteRange:()=>$6,deleteSelection:()=>B6,enter:()=>_6,exitCode:()=>V6,extendMarkRange:()=>K6,first:()=>U6,focus:()=>H6,forEach:()=>W6,insertContent:()=>Q6,insertContentAt:()=>Z6,joinBackward:()=>ez,joinDown:()=>X6,joinForward:()=>tz,joinItemBackward:()=>nz,joinItemForward:()=>sz,joinTextblockBackward:()=>rz,joinTextblockForward:()=>iz,joinUp:()=>Y6,keyboardShortcut:()=>lz,lift:()=>oz,liftEmptyBlock:()=>cz,liftListItem:()=>dz,newlineInCode:()=>uz,resetAttributes:()=>hz,scrollIntoView:()=>fz,selectAll:()=>mz,selectNodeBackward:()=>pz,selectNodeForward:()=>gz,selectParentNode:()=>xz,selectTextblockEnd:()=>yz,selectTextblockStart:()=>vz,setContent:()=>bz,setMark:()=>Bz,setMeta:()=>_z,setNode:()=>Vz,setNodeSelection:()=>Kz,setTextDirection:()=>Uz,setTextSelection:()=>qz,sinkListItem:()=>Hz,splitBlock:()=>Wz,splitListItem:()=>Qz,toggleList:()=>Gz,toggleMark:()=>Jz,toggleNode:()=>Zz,toggleWrap:()=>Yz,undoInputRule:()=>Xz,unsetAllMarks:()=>e$,unsetMark:()=>t$,unsetTextDirection:()=>n$,updateAttributes:()=>s$,wrapIn:()=>r$,wrapInList:()=>i$});var T6=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),P6=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),I6=()=>({state:t,tr:e,dispatch:n})=>{const{selection:s}=e,{ranges:r}=s;return n&&r.forEach(({$from:a,$to:l})=>{t.doc.nodesBetween(a.pos,l.pos,(o,c)=>{if(o.type.isText)return;const{doc:d,mapping:u}=e,h=d.resolve(u.map(c)),m=d.resolve(u.map(c+o.nodeSize)),f=h.blockRange(m);if(!f)return;const p=vo(f);if(o.type.isTextblock){const{defaultType:g}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(f.start,g)}(p||p===0)&&e.lift(f,p)})}),!0},R6=t=>e=>t(e),O6=()=>({state:t,dispatch:e})=>I2(t,e),L6=(t,e)=>({editor:n,tr:s})=>{const{state:r}=n,a=r.doc.slice(t.from,t.to);s.deleteRange(t.from,t.to);const l=s.mapping.map(e);return s.insert(l,a.content),s.setSelection(new De(s.doc.resolve(Math.max(l-1,0)))),!0},F6=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,s=n.$anchor.node();if(s.content.size>0)return!1;const r=t.selection.$anchor;for(let a=r.depth;a>0;a-=1)if(r.node(a).type===s.type){if(e){const o=r.before(a),c=r.after(a);t.delete(o,c).scrollIntoView()}return!0}return!1};function Bt(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 z6=t=>({tr:e,state:n,dispatch:s})=>{const r=Bt(t,n.schema),a=e.selection.$anchor;for(let l=a.depth;l>0;l-=1)if(a.node(l).type===r){if(s){const c=a.before(l),d=a.after(l);e.delete(c,d).scrollIntoView()}return!0}return!1},$6=t=>({tr:e,dispatch:n})=>{const{from:s,to:r}=t;return n&&e.delete(s,r),!0},B6=()=>({state:t,dispatch:e})=>Yy(t,e),_6=()=>({commands:t})=>t.keyboardShortcut("Enter"),V6=()=>({state:t,dispatch:e})=>SL(t,e);function f0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Ch(t,e,n={strict:!0}){const s=Object.keys(e);return s.length?s.every(r=>n.strict?e[r]===t[r]:f0(e[r])?e[r].test(t[r]):e[r]===t[r]):!0}function bE(t,e,n={}){return t.find(s=>s.type===e&&Ch(Object.fromEntries(Object.keys(n).map(r=>[r,s.attrs[r]])),n))}function tN(t,e,n={}){return!!bE(t,e,n)}function m0(t,e,n){var s;if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(u=>u.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(u=>u.type===e)||(n=n||((s=r.node.marks[0])==null?void 0:s.attrs),!bE([...r.node.marks],e,n)))return;let l=r.index,o=t.start()+r.offset,c=l+1,d=o+r.node.nodeSize;for(;l>0&&tN([...t.parent.child(l-1).marks],e,n);)l-=1,o-=t.parent.child(l).nodeSize;for(;c<t.parent.childCount&&tN([...t.parent.child(c).marks],e,n);)d+=t.parent.child(c).nodeSize,c+=1;return{from:o,to:d}}function Hr(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 K6=(t,e={})=>({tr:n,state:s,dispatch:r})=>{const a=Hr(t,s.schema),{doc:l,selection:o}=n,{$from:c,from:d,to:u}=o;if(r){const h=m0(c,a,e);if(h&&h.from<=d&&h.to>=u){const m=De.create(l,h.from,h.to);n.setSelection(m)}}return!0},U6=t=>e=>{const n=typeof t=="function"?t(e):t;for(let s=0;s<n.length;s+=1)if(n[s](e))return!0;return!1};function jE(t){return t instanceof De}function ua(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function NE(t,e=null){if(!e)return null;const n=Ie.atStart(t),s=Ie.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return s;const r=n.from,a=s.to;return e==="all"?De.create(t,ua(0,r,a),ua(t.content.size,r,a)):De.create(t,ua(e,r,a),ua(e,r,a))}function nN(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Eh(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function q6(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var H6=(t=null,e={})=>({editor:n,view:s,tr:r,dispatch:a})=>{e={scrollIntoView:!0,...e};const l=()=>{(Eh()||nN())&&s.dom.focus(),q6()&&!Eh()&&!nN()&&s.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(s.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(a&&t===null&&!jE(n.state.selection))return l(),!0;const o=NE(r.doc,t)||n.state.selection,c=n.state.selection.eq(o);return a&&(c||r.setSelection(o),c&&r.storedMarks&&r.setStoredMarks(r.storedMarks),l()),!0},W6=(t,e)=>n=>t.every((s,r)=>e(s,{...n,index:r})),Q6=(t,e)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),wE=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const s=e[n];s.nodeType===3&&s.nodeValue&&/^(\n\s\s|\n)$/.test(s.nodeValue)?t.removeChild(s):s.nodeType===1&&wE(s)}return t};function eu(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return wE(n)}function Jc(t,e,n){if(t instanceof _s||t instanceof X)return t;n={slice:!0,parseOptions:{},...n};const s=typeof t=="object"&&t!==null,r=typeof t=="string";if(s)try{if(Array.isArray(t)&&t.length>0)return X.fromArray(t.map(o=>e.nodeFromJSON(o)));const l=e.nodeFromJSON(t);return n.errorOnInvalidContent&&l.check(),l}catch(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),Jc("",e,n)}if(r){if(n.errorOnInvalidContent){let l=!1,o="";const c=new a2({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(l=!0,o=typeof d=="string"?d:d.outerHTML,null)}]}})});if(n.slice?Li.fromSchema(c).parseSlice(eu(t),n.parseOptions):Li.fromSchema(c).parse(eu(t),n.parseOptions),n.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const a=Li.fromSchema(e);return n.slice?a.parseSlice(eu(t),n.parseOptions).content:a.parse(eu(t),n.parseOptions)}return Jc("",e,n)}function G6(t,e,n){const s=t.steps.length-1;if(s<e)return;const r=t.steps[s];if(!(r instanceof Yt||r instanceof en))return;const a=t.mapping.maps[s];let l=0;a.forEach((o,c,d,u)=>{l===0&&(l=u)}),t.setSelection(Ie.near(t.doc.resolve(l),n))}var J6=t=>!("type"in t),Z6=(t,e,n)=>({tr:s,dispatch:r,editor:a})=>{var l;if(r){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let o;const c=x=>{a.emit("contentError",{editor:a,error:x,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Jc(e,a.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(x){c(x)}try{o=Jc(e,a.schema,{parseOptions:d,errorOnInvalidContent:(l=n.errorOnInvalidContent)!=null?l:a.options.enableContentCheck})}catch(x){return c(x),!1}let{from:u,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},m=!0,f=!0;if((J6(o)?o:[o]).forEach(x=>{x.check(),m=m?x.isText&&x.marks.length===0:!1,f=f?x.isBlock:!1}),u===h&&f){const{parent:x}=s.doc.resolve(u);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(u-=1,h+=1)}let g;if(m){if(Array.isArray(e))g=e.map(x=>x.text||"").join("");else if(e instanceof X){let x="";e.forEach(y=>{y.text&&(x+=y.text)}),g=x}else typeof e=="object"&&e&&e.text?g=e.text:g=e;s.insertText(g,u,h)}else{g=o;const x=s.doc.resolve(u),y=x.node(),v=x.parentOffset===0,b=y.isText||y.isTextblock,j=y.content.size>0;v&&b&&j&&(u=Math.max(0,u-1)),s.replaceWith(u,h,g)}n.updateSelection&&G6(s,s.steps.length-1,-1),n.applyInputRules&&s.setMeta("applyInputRules",{from:u,text:g}),n.applyPasteRules&&s.setMeta("applyPasteRules",{from:u,text:g})}return!0},Y6=()=>({state:t,dispatch:e})=>NL(t,e),X6=()=>({state:t,dispatch:e})=>wL(t,e),ez=()=>({state:t,dispatch:e})=>C2(t,e),tz=()=>({state:t,dispatch:e})=>M2(t,e),nz=()=>({state:t,dispatch:e,tr:n})=>{try{const s=zf(t.doc,t.selection.$from.pos,-1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},sz=()=>({state:t,dispatch:e,tr:n})=>{try{const s=zf(t.doc,t.selection.$from.pos,1);return s==null?!1:(n.join(s,2),e&&e(n),!0)}catch{return!1}},rz=()=>({state:t,dispatch:e})=>bL(t,e),iz=()=>({state:t,dispatch:e})=>jL(t,e);function kE(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function az(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let s,r,a,l;for(let o=0;o<e.length-1;o+=1){const c=e[o];if(/^(cmd|meta|m)$/i.test(c))l=!0;else if(/^a(lt)?$/i.test(c))s=!0;else if(/^(c|ctrl|control)$/i.test(c))r=!0;else if(/^s(hift)?$/i.test(c))a=!0;else if(/^mod$/i.test(c))Eh()||kE()?l=!0:r=!0;else throw new Error(`Unrecognized modifier name: ${c}`)}return s&&(n=`Alt-${n}`),r&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}var lz=t=>({editor:e,view:n,tr:s,dispatch:r})=>{const a=az(t).split(/-(?!$)/),l=a.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),o=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,o))});return c==null||c.steps.forEach(d=>{const u=d.map(s.mapping);u&&r&&s.maybeStep(u)}),!0};function Ki(t,e,n={}){const{from:s,to:r,empty:a}=t.selection,l=e?Bt(e,t.schema):null,o=[];t.doc.nodesBetween(s,r,(h,m)=>{if(h.isText)return;const f=Math.max(s,m),p=Math.min(r,m+h.nodeSize);o.push({node:h,from:f,to:p})});const c=r-s,d=o.filter(h=>l?l.name===h.node.type.name:!0).filter(h=>Ch(h.node.attrs,n,{strict:!1}));return a?!!d.length:d.reduce((h,m)=>h+m.to-m.from,0)>=c}var oz=(t,e={})=>({state:n,dispatch:s})=>{const r=Bt(t,n.schema);return Ki(n,r,e)?kL(n,s):!1},cz=()=>({state:t,dispatch:e})=>R2(t,e),dz=t=>({state:e,dispatch:n})=>{const s=Bt(t,e.schema);return LL(s)(e,n)},uz=()=>({state:t,dispatch:e})=>P2(t,e);function Hf(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function sN(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((s,r)=>(n.includes(r)||(s[r]=t[r]),s),{})}var hz=(t,e)=>({tr:n,state:s,dispatch:r})=>{let a=null,l=null;const o=Hf(typeof t=="string"?t:t.name,s.schema);if(!o)return!1;o==="node"&&(a=Bt(t,s.schema)),o==="mark"&&(l=Hr(t,s.schema));let c=!1;return n.selection.ranges.forEach(d=>{s.doc.nodesBetween(d.$from.pos,d.$to.pos,(u,h)=>{a&&a===u.type&&(c=!0,r&&n.setNodeMarkup(h,void 0,sN(u.attrs,e))),l&&u.marks.length&&u.marks.forEach(m=>{l===m.type&&(c=!0,r&&n.addMark(h,h+u.nodeSize,l.create(sN(m.attrs,e))))})})}),c},fz=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),mz=()=>({tr:t,dispatch:e})=>{if(e){const n=new as(t.doc);t.setSelection(n)}return!0},pz=()=>({state:t,dispatch:e})=>A2(t,e),gz=()=>({state:t,dispatch:e})=>T2(t,e),xz=()=>({state:t,dispatch:e})=>AL(t,e),yz=()=>({state:t,dispatch:e})=>TL(t,e),vz=()=>({state:t,dispatch:e})=>ML(t,e);function ox(t,e,n={},s={}){return Jc(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:s.errorOnInvalidContent})}var bz=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:s={}}={})=>({editor:r,tr:a,dispatch:l,commands:o})=>{const{doc:c}=a;if(s.preserveWhitespace!=="full"){const d=ox(t,r.schema,s,{errorOnInvalidContent:e??r.options.enableContentCheck});return l&&a.replaceWith(0,c.content.size,d).setMeta("preventUpdate",!n),!0}return l&&a.setMeta("preventUpdate",!n),o.insertContentAt({from:0,to:c.content.size},t,{parseOptions:s,errorOnInvalidContent:e??r.options.enableContentCheck})};function SE(t,e){const n=Hr(e,t.schema),{from:s,to:r,empty:a}=t.selection,l=[];a?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(s,r,c=>{l.push(...c.marks)});const o=l.find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function CE(t,e){const n=new N2(t);return e.forEach(s=>{s.steps.forEach(r=>{n.step(r)})}),n}function jz(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Nz(t,e,n){const s=[];return t.nodesBetween(e.from,e.to,(r,a)=>{n(r)&&s.push({node:r,pos:a})}),s}function wz(t,e){for(let n=t.depth;n>0;n-=1){const s=t.node(n);if(e(s))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:s}}}function Wf(t){return e=>wz(e.$from,t)}function we(t,e,n){return t.config[e]===void 0&&t.parent?we(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?we(t.parent,e,n):null}):t.config[e]}function p0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},s=we(e,"addExtensions",n);return s?[e,...p0(s())]:e}).flat(10)}function g0(t,e){const n=Ga.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}function EE(t){return typeof t=="function"}function Ze(t,e=void 0,...n){return EE(t)?e?t.bind(e)(...n):t(...n):t}function kz(t={}){return Object.keys(t).length===0&&t.constructor===Object}function lo(t){const e=t.filter(r=>r.type==="extension"),n=t.filter(r=>r.type==="node"),s=t.filter(r=>r.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:s}}function AE(t){const e=[],{nodeExtensions:n,markExtensions:s}=lo(t),r=[...n,...s],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const o={name:l.name,options:l.options,storage:l.storage,extensions:r},c=we(l,"addGlobalAttributes",o);if(!c)return;c().forEach(u=>{u.types.forEach(h=>{Object.entries(u.attributes).forEach(([m,f])=>{e.push({type:h,name:m,attribute:{...a,...f}})})})})}),r.forEach(l=>{const o={name:l.name,options:l.options,storage:l.storage},c=we(l,"addAttributes",o);if(!c)return;const d=c();Object.entries(d).forEach(([u,h])=>{const m={...a,...h};typeof(m==null?void 0:m.default)=="function"&&(m.default=m.default()),m!=null&&m.isRequired&&(m==null?void 0:m.default)===void 0&&delete m.default,e.push({type:l.name,name:u,attribute:m})})}),e}function _t(...t){return t.filter(e=>!!e).reduce((e,n)=>{const s={...e};return Object.entries(n).forEach(([r,a])=>{if(!s[r]){s[r]=a;return}if(r==="class"){const o=a?String(a).split(" "):[],c=s[r]?s[r].split(" "):[],d=o.filter(u=>!c.includes(u));s[r]=[...c,...d].join(" ")}else if(r==="style"){const o=a?a.split(";").map(u=>u.trim()).filter(Boolean):[],c=s[r]?s[r].split(";").map(u=>u.trim()).filter(Boolean):[],d=new Map;c.forEach(u=>{const[h,m]=u.split(":").map(f=>f.trim());d.set(h,m)}),o.forEach(u=>{const[h,m]=u.split(":").map(f=>f.trim());d.set(h,m)}),s[r]=Array.from(d.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else s[r]=a}),s},{})}function Zc(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,s)=>_t(n,s),{})}function Sz(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function rN(t,e){return"style"in t?t:{...t,getAttrs:n=>{const s=t.getAttrs?t.getAttrs(n):t.attrs;if(s===!1)return!1;const r=e.reduce((a,l)=>{const o=l.attribute.parseHTML?l.attribute.parseHTML(n):Sz(n.getAttribute(l.name));return o==null?a:{...a,[l.name]:o}},{});return{...s,...r}}}}function iN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&kz(n)?!1:n!=null))}function aN(t){var e,n;const s={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(s.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(s.validate=t.attribute.validate),[t.name,s]}function Cz(t,e){var n;const s=AE(t),{nodeExtensions:r,markExtensions:a}=lo(t),l=(n=r.find(d=>we(d,"topNode")))==null?void 0:n.name,o=Object.fromEntries(r.map(d=>{const u=s.filter(y=>y.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},m=t.reduce((y,v)=>{const b=we(v,"extendNodeSchema",h);return{...y,...b?b(d):{}}},{}),f=iN({...m,content:Ze(we(d,"content",h)),marks:Ze(we(d,"marks",h)),group:Ze(we(d,"group",h)),inline:Ze(we(d,"inline",h)),atom:Ze(we(d,"atom",h)),selectable:Ze(we(d,"selectable",h)),draggable:Ze(we(d,"draggable",h)),code:Ze(we(d,"code",h)),whitespace:Ze(we(d,"whitespace",h)),linebreakReplacement:Ze(we(d,"linebreakReplacement",h)),defining:Ze(we(d,"defining",h)),isolating:Ze(we(d,"isolating",h)),attrs:Object.fromEntries(u.map(aN))}),p=Ze(we(d,"parseHTML",h));p&&(f.parseDOM=p.map(y=>rN(y,u)));const g=we(d,"renderHTML",h);g&&(f.toDOM=y=>g({node:y,HTMLAttributes:Zc(y,u)}));const x=we(d,"renderText",h);return x&&(f.toText=x),[d.name,f]})),c=Object.fromEntries(a.map(d=>{const u=s.filter(x=>x.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},m=t.reduce((x,y)=>{const v=we(y,"extendMarkSchema",h);return{...x,...v?v(d):{}}},{}),f=iN({...m,inclusive:Ze(we(d,"inclusive",h)),excludes:Ze(we(d,"excludes",h)),group:Ze(we(d,"group",h)),spanning:Ze(we(d,"spanning",h)),code:Ze(we(d,"code",h)),attrs:Object.fromEntries(u.map(aN))}),p=Ze(we(d,"parseHTML",h));p&&(f.parseDOM=p.map(x=>rN(x,u)));const g=we(d,"renderHTML",h);return g&&(f.toDOM=x=>g({mark:x,HTMLAttributes:Zc(x,u)})),[d.name,f]}));return new a2({topNode:l,nodes:o,marks:c})}function Ez(t){const e=t.filter((n,s)=>t.indexOf(n)!==s);return Array.from(new Set(e))}function Ah(t){return t.sort((n,s)=>{const r=we(n,"priority")||100,a=we(s,"priority")||100;return r>a?-1:r<a?1:0})}function DE(t){const e=Ah(p0(t)),n=Ez(e.map(s=>s.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),e}function ME(t,e,n){const{from:s,to:r}=e,{blockSeparator:a=`
`,textSerializers:l={}}=n||{};let o="";return t.nodesBetween(s,r,(c,d,u,h)=>{var m;c.isBlock&&d>s&&(o+=a);const f=l==null?void 0:l[c.type.name];if(f)return u&&(o+=f({node:c,pos:d,parent:u,index:h,range:e})),!1;c.isText&&(o+=(m=c==null?void 0:c.text)==null?void 0:m.slice(Math.max(s,d)-d,r-d))}),o}function Az(t,e){const n={from:0,to:t.content.size};return ME(t,n,e)}function TE(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Dz(t,e){const n=Bt(e,t.schema),{from:s,to:r}=t.selection,a=[];t.doc.nodesBetween(s,r,o=>{a.push(o)});const l=a.reverse().find(o=>o.type.name===n.name);return l?{...l.attrs}:{}}function PE(t,e){const n=Hf(typeof e=="string"?e:e.name,t.schema);return n==="node"?Dz(t,e):n==="mark"?SE(t,e):{}}function Mz(t,e=JSON.stringify){const n={};return t.filter(s=>{const r=e(s);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Tz(t){const e=Mz(t);return e.length===1?e:e.filter((n,s)=>!e.filter((a,l)=>l!==s).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function IE(t){const{mapping:e,steps:n}=t,s=[];return e.maps.forEach((r,a)=>{const l=[];if(r.ranges.length)r.forEach((o,c)=>{l.push({from:o,to:c})});else{const{from:o,to:c}=n[a];if(o===void 0||c===void 0)return;l.push({from:o,to:c})}l.forEach(({from:o,to:c})=>{const d=e.slice(a).map(o,-1),u=e.slice(a).map(c),h=e.invert().map(d,-1),m=e.invert().map(u);s.push({oldRange:{from:h,to:m},newRange:{from:d,to:u}})})}),Tz(s)}function x0(t,e,n){const s=[];return t===e?n.resolve(t).marks().forEach(r=>{const a=n.resolve(t),l=m0(a,r.type);l&&s.push({mark:r,...l})}):n.nodesBetween(t,e,(r,a)=>{!r||(r==null?void 0:r.nodeSize)===void 0||s.push(...r.marks.map(l=>({from:a,to:a+r.nodeSize,mark:l})))}),s}var Pz=(t,e,n,s=20)=>{const r=t.doc.resolve(n);let a=s,l=null;for(;a>0&&l===null;){const o=r.node(a);(o==null?void 0:o.type.name)===e?l=o:a-=1}return[l,a]};function tu(t,e){return e.nodes[t]||e.marks[t]||null}function Mu(t,e,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const r=t.find(a=>a.type===e&&a.name===s);return r?r.attribute.keepOnSplit:!1}))}var Iz=(t,e=500)=>{let n="";const s=t.parentOffset;return t.parent.nodesBetween(Math.max(0,s-e),s,(r,a,l,o)=>{var c,d;const u=((d=(c=r.type.spec).toText)==null?void 0:d.call(c,{node:r,pos:a,parent:l,index:o}))||r.textContent||"%leaf%";n+=r.isAtom&&!r.isText?u:u.slice(0,Math.max(0,s-a))}),n};function cx(t,e,n={}){const{empty:s,ranges:r}=t.selection,a=e?Hr(e,t.schema):null;if(s)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>a?a.name===h.type.name:!0).find(h=>Ch(h.attrs,n,{strict:!1}));let l=0;const o=[];if(r.forEach(({$from:h,$to:m})=>{const f=h.pos,p=m.pos;t.doc.nodesBetween(f,p,(g,x)=>{if(!g.isText&&!g.marks.length)return;const y=Math.max(f,x),v=Math.min(p,x+g.nodeSize),b=v-y;l+=b,o.push(...g.marks.map(j=>({mark:j,from:y,to:v})))})}),l===0)return!1;const c=o.filter(h=>a?a.name===h.mark.type.name:!0).filter(h=>Ch(h.mark.attrs,n,{strict:!1})).reduce((h,m)=>h+m.to-m.from,0),d=o.filter(h=>a?h.mark.type!==a&&h.mark.type.excludes(a):!0).reduce((h,m)=>h+m.to-m.from,0);return(c>0?c+d:c)>=l}function Rz(t,e,n={}){if(!e)return Ki(t,null,n)||cx(t,null,n);const s=Hf(e,t.schema);return s==="node"?Ki(t,e,n):s==="mark"?cx(t,e,n):!1}var Oz=(t,e)=>{const{$from:n,$to:s,$anchor:r}=t.selection;if(e){const a=Wf(o=>o.type.name===e)(t.selection);if(!a)return!1;const l=t.doc.resolve(a.pos+1);return r.pos+1===l.end()}return!(s.parentOffset<s.parent.nodeSize-2||n.pos!==s.pos)},Lz=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function lN(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function oN(t,e){const{nodeExtensions:n}=lo(e),s=n.find(l=>l.name===t);if(!s)return!1;const r={name:s.name,options:s.options,storage:s.storage},a=Ze(we(s,"group",r));return typeof a!="string"?!1:a.split(" ").includes("list")}function Qf(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var s;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((s=t.text)!=null?s:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let r=!0;return t.content.forEach(a=>{r!==!1&&(Qf(a,{ignoreWhitespace:n,checkChildren:e})||(r=!1))}),r}return!1}function RE(t){return t instanceof ke}var OE=class LE{constructor(e){this.position=e}static fromJSON(e){return new LE(e.position)}toJSON(){return{position:this.position}}};function Fz(t,e){const n=e.mapping.mapResult(t.position);return{position:new OE(n.pos),mapResult:n}}function zz(t){return new OE(t)}function $z(t,e,n){var s;const{selection:r}=e;let a=null;if(jE(r)&&(a=r.$cursor),a){const o=(s=t.storedMarks)!=null?s:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(o)||!o.some(d=>d.type.excludes(n)))}const{ranges:l}=r;return l.some(({$from:o,$to:c})=>{let d=o.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(o.pos,c.pos,(u,h,m)=>{if(d)return!1;if(u.isInline){const f=!m||m.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));d=f&&p}return!d}),d})}var Bz=(t,e={})=>({tr:n,state:s,dispatch:r})=>{const{selection:a}=n,{empty:l,ranges:o}=a,c=Hr(t,s.schema);if(r)if(l){const d=SE(s,c);n.addStoredMark(c.create({...d,...e}))}else o.forEach(d=>{const u=d.$from.pos,h=d.$to.pos;s.doc.nodesBetween(u,h,(m,f)=>{const p=Math.max(f,u),g=Math.min(f+m.nodeSize,h);m.marks.find(y=>y.type===c)?m.marks.forEach(y=>{c===y.type&&n.addMark(p,g,c.create({...y.attrs,...e}))}):n.addMark(p,g,c.create(e))})});return $z(s,n,c)},_z=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Vz=(t,e={})=>({state:n,dispatch:s,chain:r})=>{const a=Bt(t,n.schema);let l;return n.selection.$anchor.sameParent(n.selection.$head)&&(l=n.selection.$anchor.parent.attrs),a.isTextblock?r().command(({commands:o})=>jj(a,{...l,...e})(n)?!0:o.clearNodes()).command(({state:o})=>jj(a,{...l,...e})(o,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Kz=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,r=ua(t,0,s.content.size),a=ke.create(s,r);e.setSelection(a)}return!0},Uz=(t,e)=>({tr:n,state:s,dispatch:r})=>{const{selection:a}=s;let l,o;return typeof e=="number"?(l=e,o=e):e&&"from"in e&&"to"in e?(l=e.from,o=e.to):(l=a.from,o=a.to),r&&n.doc.nodesBetween(l,o,(c,d)=>{c.isText||n.setNodeMarkup(d,void 0,{...c.attrs,dir:t})}),!0},qz=t=>({tr:e,dispatch:n})=>{if(n){const{doc:s}=e,{from:r,to:a}=typeof t=="number"?{from:t,to:t}:t,l=De.atStart(s).from,o=De.atEnd(s).to,c=ua(r,l,o),d=ua(a,l,o),u=De.create(s,c,d);e.setSelection(u)}return!0},Hz=t=>({state:e,dispatch:n})=>{const s=Bt(t,e.schema);return $L(s)(e,n)};function cN(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const s=n.filter(r=>e==null?void 0:e.includes(r.type.name));t.tr.ensureMarks(s)}}var Wz=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:s,editor:r})=>{const{selection:a,doc:l}=e,{$from:o,$to:c}=a,d=r.extensionManager.attributes,u=Mu(d,o.node().type.name,o.node().attrs);if(a instanceof ke&&a.node.isBlock)return!o.parentOffset||!Rr(l,o.pos)?!1:(s&&(t&&cN(n,r.extensionManager.splittableMarks),e.split(o.pos).scrollIntoView()),!0);if(!o.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,m=o.depth===0?void 0:jz(o.node(-1).contentMatchAt(o.indexAfter(-1)));let f=h&&m?[{type:m,attrs:u}]:void 0,p=Rr(e.doc,e.mapping.map(o.pos),1,f);if(!f&&!p&&Rr(e.doc,e.mapping.map(o.pos),1,m?[{type:m}]:void 0)&&(p=!0,f=m?[{type:m,attrs:u}]:void 0),s){if(p&&(a instanceof De&&e.deleteSelection(),e.split(e.mapping.map(o.pos),1,f),m&&!h&&!o.parentOffset&&o.parent.type!==m)){const g=e.mapping.map(o.before()),x=e.doc.resolve(g);o.node(-1).canReplaceWith(x.index(),x.index()+1,m)&&e.setNodeMarkup(e.mapping.map(o.before()),m)}t&&cN(n,r.extensionManager.splittableMarks),e.scrollIntoView()}return p},Qz=(t,e={})=>({tr:n,state:s,dispatch:r,editor:a})=>{var l;const o=Bt(t,s.schema),{$from:c,$to:d}=s.selection,u=s.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(d))return!1;const h=c.node(-1);if(h.type!==o)return!1;const m=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==o||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let y=X.empty;const v=c.index(-1)?1:c.index(-2)?2:3;for(let w=c.depth-v;w>=c.depth-3;w-=1)y=X.from(c.node(w).copy(y));const b=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,j={...Mu(m,c.node().type.name,c.node().attrs),...e},k=((l=o.contentMatch.defaultType)==null?void 0:l.createAndFill(j))||void 0;y=y.append(X.from(o.createAndFill(null,k)||void 0));const E=c.before(c.depth-(v-1));n.replace(E,c.after(-b),new me(y,4-v,0));let T=-1;n.doc.nodesBetween(E,n.doc.content.size,(w,S)=>{if(T>-1)return!1;w.isTextblock&&w.content.size===0&&(T=S+1)}),T>-1&&n.setSelection(De.near(n.doc.resolve(T))),n.scrollIntoView()}return!0}const f=d.pos===c.end()?h.contentMatchAt(0).defaultType:null,p={...Mu(m,h.type.name,h.attrs),...e},g={...Mu(m,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,d.pos);const x=f?[{type:o,attrs:p},{type:f,attrs:g}]:[{type:o,attrs:p}];if(!Rr(n.doc,c.pos,2))return!1;if(r){const{selection:y,storedMarks:v}=s,{splittableMarks:b}=a.extensionManager,j=v||y.$to.parentOffset&&y.$from.marks();if(n.split(c.pos,2,x).scrollIntoView(),!j||!r)return!0;const k=j.filter(E=>b.includes(E.type.name));n.ensureMarks(k)}return!0},sp=(t,e)=>{const n=Wf(l=>l.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const r=t.doc.nodeAt(s);return n.node.type===(r==null?void 0:r.type)&&Qi(t.doc,n.pos)&&t.join(n.pos),!0},rp=(t,e)=>{const n=Wf(l=>l.type===e)(t.selection);if(!n)return!0;const s=t.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const r=t.doc.nodeAt(s);return n.node.type===(r==null?void 0:r.type)&&Qi(t.doc,s)&&t.join(s),!0},Gz=(t,e,n,s={})=>({editor:r,tr:a,state:l,dispatch:o,chain:c,commands:d,can:u})=>{const{extensions:h,splittableMarks:m}=r.extensionManager,f=Bt(t,l.schema),p=Bt(e,l.schema),{selection:g,storedMarks:x}=l,{$from:y,$to:v}=g,b=y.blockRange(v),j=x||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;const k=Wf(E=>oN(E.type.name,h))(g);if(b.depth>=1&&k&&b.depth-k.depth<=1){if(k.node.type===f)return d.liftListItem(p);if(oN(k.node.type.name,h)&&f.validContent(k.node.content)&&o)return c().command(()=>(a.setNodeMarkup(k.pos,f),!0)).command(()=>sp(a,f)).command(()=>rp(a,f)).run()}return!n||!j||!o?c().command(()=>u().wrapInList(f,s)?!0:d.clearNodes()).wrapInList(f,s).command(()=>sp(a,f)).command(()=>rp(a,f)).run():c().command(()=>{const E=u().wrapInList(f,s),T=j.filter(w=>m.includes(w.type.name));return a.ensureMarks(T),E?!0:d.clearNodes()}).wrapInList(f,s).command(()=>sp(a,f)).command(()=>rp(a,f)).run()},Jz=(t,e={},n={})=>({state:s,commands:r})=>{const{extendEmptyMarkRange:a=!1}=n,l=Hr(t,s.schema);return cx(s,l,e)?r.unsetMark(l,{extendEmptyMarkRange:a}):r.setMark(l,e)},Zz=(t,e,n={})=>({state:s,commands:r})=>{const a=Bt(t,s.schema),l=Bt(e,s.schema),o=Ki(s,a,n);let c;return s.selection.$anchor.sameParent(s.selection.$head)&&(c=s.selection.$anchor.parent.attrs),o?r.setNode(l,c):r.setNode(a,{...c,...n})},Yz=(t,e={})=>({state:n,commands:s})=>{const r=Bt(t,n.schema);return Ki(n,r,e)?s.lift(r):s.wrapIn(r,e)},Xz=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let s=0;s<n.length;s+=1){const r=n[s];let a;if(r.spec.isInputRules&&(a=r.getState(t))){if(e){const l=t.tr,o=a.transform;for(let c=o.steps.length-1;c>=0;c-=1)l.step(o.steps[c].invert(o.docs[c]));if(a.text){const c=l.doc.resolve(a.from).marks();l.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else l.delete(a.from,a.to)}return!0}}return!1},e$=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:s,ranges:r}=n;return s||e&&r.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},t$=(t,e={})=>({tr:n,state:s,dispatch:r})=>{var a;const{extendEmptyMarkRange:l=!1}=e,{selection:o}=n,c=Hr(t,s.schema),{$from:d,empty:u,ranges:h}=o;if(!r)return!0;if(u&&l){let{from:m,to:f}=o;const p=(a=d.marks().find(x=>x.type===c))==null?void 0:a.attrs,g=m0(d,c,p);g&&(m=g.from,f=g.to),n.removeMark(m,f,c)}else h.forEach(m=>{n.removeMark(m.$from.pos,m.$to.pos,c)});return n.removeStoredMark(c),!0},n$=t=>({tr:e,state:n,dispatch:s})=>{const{selection:r}=n;let a,l;return typeof t=="number"?(a=t,l=t):t&&"from"in t&&"to"in t?(a=t.from,l=t.to):(a=r.from,l=r.to),s&&e.doc.nodesBetween(a,l,(o,c)=>{if(o.isText)return;const d={...o.attrs};delete d.dir,e.setNodeMarkup(c,void 0,d)}),!0},s$=(t,e={})=>({tr:n,state:s,dispatch:r})=>{let a=null,l=null;const o=Hf(typeof t=="string"?t:t.name,s.schema);if(!o)return!1;o==="node"&&(a=Bt(t,s.schema)),o==="mark"&&(l=Hr(t,s.schema));let c=!1;return n.selection.ranges.forEach(d=>{const u=d.$from.pos,h=d.$to.pos;let m,f,p,g;n.selection.empty?s.doc.nodesBetween(u,h,(x,y)=>{a&&a===x.type&&(c=!0,p=Math.max(y,u),g=Math.min(y+x.nodeSize,h),m=y,f=x)}):s.doc.nodesBetween(u,h,(x,y)=>{y<u&&a&&a===x.type&&(c=!0,p=Math.max(y,u),g=Math.min(y+x.nodeSize,h),m=y,f=x),y>=u&&y<=h&&(a&&a===x.type&&(c=!0,r&&n.setNodeMarkup(y,void 0,{...x.attrs,...e})),l&&x.marks.length&&x.marks.forEach(v=>{if(l===v.type&&(c=!0,r)){const b=Math.max(y,u),j=Math.min(y+x.nodeSize,h);n.addMark(b,j,l.create({...v.attrs,...e}))}}))}),f&&(m!==void 0&&r&&n.setNodeMarkup(m,void 0,{...f.attrs,...e}),l&&f.marks.length&&f.marks.forEach(x=>{l===x.type&&r&&n.addMark(p,g,l.create({...x.attrs,...e}))}))}),c},r$=(t,e={})=>({state:n,dispatch:s})=>{const r=Bt(t,n.schema);return PL(r,e)(n,s)},i$=(t,e={})=>({state:n,dispatch:s})=>{const r=Bt(t,n.schema);return IL(r,e)(n,s)},a$=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(s=>s.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(s=>s!==e):delete this.callbacks[t]),this}once(t,e){const n=(...s)=>{this.off(t,n),e.apply(this,s)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Gf=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},l$=(t,e)=>{if(f0(e))return e.exec(t);const n=e(t);if(!n)return null;const s=[n.text];return s.index=n.index,s.input=t,s.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),s.push(n.replaceWith)),s};function nu(t){var e;const{editor:n,from:s,to:r,text:a,rules:l,plugin:o}=t,{view:c}=n;if(c.composing)return!1;const d=c.state.doc.resolve(s);if(d.parent.type.spec.code||(e=d.nodeBefore||d.nodeAfter)!=null&&e.marks.find(m=>m.type.spec.code))return!1;let u=!1;const h=Iz(d)+a;return l.forEach(m=>{if(u)return;const f=l$(h,m.find);if(!f)return;const p=c.state.tr,g=Uf({state:c.state,transaction:p}),x={from:s-(f[0].length-a.length),to:r},{commands:y,chain:v,can:b}=new qf({editor:n,state:g});m.handler({state:g,range:x,match:f,commands:y,chain:v,can:b})===null||!p.steps.length||(m.undoable&&p.setMeta(o,{transform:p,from:s,to:r,text:a}),c.dispatch(p),u=!0)}),u}function o$(t){const{editor:e,rules:n}=t,s=new Nt({state:{init(){return null},apply(r,a,l){const o=r.getMeta(s);if(o)return o;const c=r.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=g0(X.from(u),l.schema);const{from:h}=c,m=h+u.length;nu({editor:e,from:h,to:m,text:u,rules:n,plugin:s})}),r.selectionSet||r.docChanged?null:a}},props:{handleTextInput(r,a,l,o){return nu({editor:e,from:a,to:l,text:o,rules:n,plugin:s})},handleDOMEvents:{compositionend:r=>(setTimeout(()=>{const{$cursor:a}=r.state.selection;a&&nu({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:s})}),!1)},handleKeyDown(r,a){if(a.key!=="Enter")return!1;const{$cursor:l}=r.state.selection;return l?nu({editor:e,from:l.pos,to:l.pos,text:`
`,rules:n,plugin:s}):!1}},isInputRules:!0});return s}function c$(t){return Object.prototype.toString.call(t).slice(8,-1)}function su(t){return c$(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function FE(t,e){const n={...t};return su(t)&&su(e)&&Object.keys(e).forEach(s=>{su(e[s])&&su(t[s])?n[s]=FE(t[s],e[s]):n[s]=e[s]}),n}var y0=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{...Ze(we(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ze(we(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>FE(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Ja=class zE extends y0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new zE(n)}static handleExit({editor:e,mark:n}){const{tr:s}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){const l=r.marks();if(!!!l.find(d=>(d==null?void 0:d.type.name)===n.name))return!1;const c=l.find(d=>(d==null?void 0:d.type.name)===n.name);return c&&s.removeStoredMark(c),s.insertText(" ",r.pos),e.view.dispatch(s),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function d$(t){return typeof t=="number"}var u$=class{constructor(t){this.find=t.find,this.handler=t.handler}},h$=(t,e,n)=>{if(f0(e))return[...t.matchAll(e)];const s=e(t,n);return s?s.map(r=>{const a=[r.text];return a.index=r.index,a.input=t,a.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(r.replaceWith)),a}):[]};function f$(t){const{editor:e,state:n,from:s,to:r,rule:a,pasteEvent:l,dropEvent:o}=t,{commands:c,chain:d,can:u}=new qf({editor:e,state:n}),h=[];return n.doc.nodesBetween(s,r,(f,p)=>{var g,x,y,v,b;if((x=(g=f.type)==null?void 0:g.spec)!=null&&x.code||!(f.isText||f.isTextblock||f.isInline))return;const j=(b=(v=(y=f.content)==null?void 0:y.size)!=null?v:f.nodeSize)!=null?b:0,k=Math.max(s,p),E=Math.min(r,p+j);if(k>=E)return;const T=f.isText?f.text||"":f.textBetween(k-p,E-p,void 0,"");h$(T,a.find,l).forEach(S=>{if(S.index===void 0)return;const M=k+S.index+1,F=M+S[0].length,R={from:n.tr.mapping.map(M),to:n.tr.mapping.map(F)},V=a.handler({state:n,range:R,match:S,commands:c,chain:d,can:u,pasteEvent:l,dropEvent:o});h.push(V)})}),h.every(f=>f!==null)}var ru=null,m$=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function p$(t){const{editor:e,rules:n}=t;let s=null,r=!1,a=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,o;try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}const c=({state:u,from:h,to:m,rule:f,pasteEvt:p})=>{const g=u.tr,x=Uf({state:u,transaction:g});if(!(!f$({editor:e,state:x,from:Math.max(h-1,0),to:m.b-1,rule:f,pasteEvent:p,dropEvent:o})||!g.steps.length)){try{o=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{o=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(u=>new Nt({view(h){const m=p=>{var g;s=(g=h.dom.parentElement)!=null&&g.contains(p.target)?h.dom.parentElement:null,s&&(ru=e)},f=()=>{ru&&(ru=null)};return window.addEventListener("dragstart",m),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",m),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(h,m)=>{if(a=s===h.dom.parentElement,o=m,!a){const f=ru;f!=null&&f.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(h,m)=>{var f;const p=(f=m.clipboardData)==null?void 0:f.getData("text/html");return l=m,r=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(h,m,f)=>{const p=h[0],g=p.getMeta("uiEvent")==="paste"&&!r,x=p.getMeta("uiEvent")==="drop"&&!a,y=p.getMeta("applyPasteRules"),v=!!y;if(!g&&!x&&!v)return;if(v){let{text:k}=y;typeof k=="string"?k=k:k=g0(X.from(k),f.schema);const{from:E}=y,T=E+k.length,w=m$(k);return c({rule:u,state:f,from:E,to:{b:T},pasteEvt:w})}const b=m.doc.content.findDiffStart(f.doc.content),j=m.doc.content.findDiffEnd(f.doc.content);if(!(!d$(b)||!j||b===j.b))return c({rule:u,state:f,from:b,to:j,pasteEvt:l})}}))}var Jf=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=DE(t),this.schema=Cz(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:tu(e.name,this.schema)},s=we(e,"addCommands",n);return s?{...t,...s()}:t},{})}get plugins(){const{editor:t}=this;return Ah([...this.extensions].reverse()).flatMap(s=>{const r={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:t,type:tu(s.name,this.schema)},a=[],l=we(s,"addKeyboardShortcuts",r);let o={};if(s.type==="mark"&&we(s,"exitable",r)&&(o.ArrowRight=()=>Ja.handleExit({editor:t,mark:s})),l){const m=Object.fromEntries(Object.entries(l()).map(([f,p])=>[f,()=>p({editor:t})]));o={...o,...m}}const c=D6(o);a.push(c);const d=we(s,"addInputRules",r);if(lN(s,t.options.enableInputRules)&&d){const m=d();if(m&&m.length){const f=o$({editor:t,rules:m}),p=Array.isArray(f)?f:[f];a.push(...p)}}const u=we(s,"addPasteRules",r);if(lN(s,t.options.enablePasteRules)&&u){const m=u();if(m&&m.length){const f=p$({editor:t,rules:m});a.push(...f)}}const h=we(s,"addProseMirrorPlugins",r);if(h){const m=h();a.push(...m)}return a})}get attributes(){return AE(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=lo(this.extensions);return Object.fromEntries(e.filter(n=>!!we(n,"addNodeView")).map(n=>{const s=this.attributes.filter(c=>c.type===n.name),r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Bt(n.name,this.schema)},a=we(n,"addNodeView",r);if(!a)return[];const l=a();if(!l)return[];const o=(c,d,u,h,m)=>{const f=Zc(c,s);return l({node:c,view:d,getPos:u,decorations:h,innerDecorations:m,editor:t,extension:n,HTMLAttributes:f})};return[n.name,o]}))}dispatchTransaction(t){const{editor:e}=this;return Ah([...this.extensions].reverse()).reduceRight((s,r)=>{const a={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:e,type:tu(r.name,this.schema)},l=we(r,"dispatchTransaction",a);return l?o=>{l.call(a,{transaction:o,next:s})}:s},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=lo(this.extensions);return Object.fromEntries(e.filter(n=>!!we(n,"addMarkView")).map(n=>{const s=this.attributes.filter(o=>o.type===n.name),r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Hr(n.name,this.schema)},a=we(n,"addMarkView",r);if(!a)return[];const l=(o,c,d)=>{const u=Zc(o,s);return a()({mark:o,view:c,inline:d,editor:t,extension:n,HTMLAttributes:u,updateAttributes:h=>{D$(o,t,h)}})};return[n.name,l]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:tu(e.name,this.schema)};e.type==="mark"&&((n=Ze(we(e,"keepOnSplit",s)))==null||n)&&this.splittableMarks.push(e.name);const r=we(e,"onBeforeCreate",s),a=we(e,"onCreate",s),l=we(e,"onUpdate",s),o=we(e,"onSelectionUpdate",s),c=we(e,"onTransaction",s),d=we(e,"onFocus",s),u=we(e,"onBlur",s),h=we(e,"onDestroy",s);r&&this.editor.on("beforeCreate",r),a&&this.editor.on("create",a),l&&this.editor.on("update",l),o&&this.editor.on("selectionUpdate",o),c&&this.editor.on("transaction",c),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}};Jf.resolve=DE;Jf.sort=Ah;Jf.flatten=p0;var g$={};h0(g$,{ClipboardTextSerializer:()=>BE,Commands:()=>_E,Delete:()=>VE,Drop:()=>KE,Editable:()=>UE,FocusEvents:()=>HE,Keymap:()=>WE,Paste:()=>QE,Tabindex:()=>GE,TextDirection:()=>JE,focusEventsPluginKey:()=>qE});var It=class $E extends y0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new $E(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},BE=It.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Nt({key:new Ht("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:s,selection:r}=e,{ranges:a}=r,l=Math.min(...a.map(u=>u.$from.pos)),o=Math.max(...a.map(u=>u.$to.pos)),c=TE(n);return ME(s,{from:l,to:o},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),_E=It.create({name:"commands",addCommands(){return{...vE}}}),VE=It.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,s,r;const a=()=>{var l,o,c,d;if((d=(c=(o=(l=this.editor.options.coreExtensionOptions)==null?void 0:l.delete)==null?void 0:o.filterTransaction)==null?void 0:c.call(o,t))!=null?d:t.getMeta("y-sync$"))return;const u=CE(t.before,[t,...e]);IE(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,g)=>{const x=g+p.nodeSize-2,y=f.oldRange.from<=g&&x<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:x,newFrom:u.mapping.map(g),newTo:u.mapping.map(x),deletedRange:f.oldRange,newRange:f.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:u})})});const m=u.mapping;u.steps.forEach((f,p)=>{var g,x;if(f instanceof zs){const y=m.slice(p).map(f.from,-1),v=m.slice(p).map(f.to),b=m.invert().map(y,-1),j=m.invert().map(v),k=(g=u.doc.nodeAt(y-1))==null?void 0:g.marks.some(T=>T.eq(f.mark)),E=(x=u.doc.nodeAt(v))==null?void 0:x.marks.some(T=>T.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:b,to:j},newRange:{from:y,to:v},partial:!!(E||k),editor:this.editor,transaction:t,combinedTransform:u})}})};(r=(s=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:s.async)==null||r?setTimeout(a,0):a()}}),KE=It.create({name:"drop",addProseMirrorPlugins(){return[new Nt({key:new Ht("tiptapDrop"),props:{handleDrop:(t,e,n,s)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:s})}}})]}}),UE=It.create({name:"editable",addProseMirrorPlugins(){return[new Nt({key:new Ht("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qE=new Ht("focusEvents"),HE=It.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Nt({key:qE,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const s=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1},blur:(e,n)=>{t.isFocused=!1;const s=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(s),!1}}}})]}}),WE=It.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:o})=>{const{selection:c,doc:d}=o,{empty:u,$anchor:h}=c,{pos:m,parent:f}=h,p=h.parent.isTextblock&&m>0?o.doc.resolve(m-1):h,g=p.parent.type.spec.isolating,x=h.pos-h.parentOffset,y=g&&p.parent.childCount===1?x===h.pos:Ie.atStart(d).from===m;return!u||!f.type.isTextblock||f.textContent.length||!y||y&&h.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...s},a={...s,"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 Eh()||kE()?a:r},addProseMirrorPlugins(){return[new Nt({key:new Ht("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const s=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),r=t.some(g=>g.getMeta("preventClearDocument"));if(!s||r)return;const{empty:a,from:l,to:o}=e.selection,c=Ie.atStart(e.doc).from,d=Ie.atEnd(e.doc).to;if(a||!(l===c&&o===d)||!Qf(n.doc))return;const m=n.tr,f=Uf({state:n,transaction:m}),{commands:p}=new qf({editor:this.editor,state:f});if(p.clearNodes(),!!m.steps.length)return m}})]}}),QE=It.create({name:"paste",addProseMirrorPlugins(){return[new Nt({key:new Ht("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),GE=It.create({name:"tabindex",addProseMirrorPlugins(){return[new Nt({key:new Ht("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),JE=It.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=lo(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Nt({key:new Ht("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),x$=class Ho{constructor(e,n,s=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=s,this.resolvedPos=e,this.editor=n,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,s=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You cant set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,s=this.to-1}this.editor.commands.insertContentAt({from:n,to:s},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Ho(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Ho(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 Ho(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,s)=>{const r=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,l=n.isInline,o=this.pos+s+(a?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const c=this.resolvedPos.doc.resolve(o);if(!r&&!l&&c.depth<=this.depth)return;const d=new Ho(c,this.editor,r,r||l?n:null);r&&(d.actualDepth=this.depth+1),e.push(d)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let s=null,r=this.parent;for(;r&&!s;){if(r.node.type.name===e)if(Object.keys(n).length>0){const a=r.node.attrs,l=Object.keys(n);for(let o=0;o<l.length;o+=1){const c=l[o];if(a[c]!==n[c])break}}else s=r;r=r.parent}return s}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},s=!1){let r=[];if(!this.children||this.children.length===0)return r;const a=Object.keys(n);return this.children.forEach(l=>{s&&r.length>0||(l.node.type.name===e&&a.every(c=>n[c]===l.node.attrs[c])&&r.push(l),!(s&&r.length>0)&&(r=r.concat(l.querySelectorAll(e,n,s))))}),r}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},y$=`.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 v$(t,e,n){const s=document.querySelector("style[data-tiptap-style]");if(s!==null)return s;const r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.setAttribute("data-tiptap-style",""),r.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(r),r}var b$=class extends a${constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:s})=>{throw s},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Fz,createMappablePosition:zz},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:s,slice:r,moved:a})=>this.options.onDrop(s,r,a)),this.on("paste",({event:s,slice:r})=>this.options.onPaste(s,r)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=NE(e,this.options.autofocus);this.editorState=jl.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=v$(y$,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=EE(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(r=>{const a=typeof r=="string"?`${r}$`:r.key;n=n.filter(l=>!l.key.startsWith(a))}),e.length===n.length)return;const s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}createExtensionManager(){var t,e;const s=[...this.options.enableCoreExtensions?[UE,BE.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),_E,HE,WE,GE,KE,QE,VE,JE.configure({direction:this.options.textDirection})].filter(r=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[r.name]!==!1:!0):[],...this.options.extensions].filter(r=>["extension","node","mark"].includes(r==null?void 0:r.type));this.extensionManager=new Jf(s,this)}createCommandManager(){this.commandManager=new qf({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=ox(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=ox(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,s=e.dispatchTransaction||this.dispatchTransaction.bind(this),r=n?this.extensionManager.dispatchTransaction(s):s;this.editorView=new xE(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:r,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const l=this.view.dom;l.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(d=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(d)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),s=!this.state.selection.eq(e.selection),r=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!r)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),s&&this.emit("selectionUpdate",{editor:this,transaction:t});const l=n.findLast(d=>d.getMeta("focus")||d.getMeta("blur")),o=l==null?void 0:l.getMeta("focus"),c=l==null?void 0:l.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:l}),c&&this.emit("blur",{editor:this,event:c.event,transaction:l}),!(t.getMeta("preventUpdate")||!n.some(d=>d.docChanged)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return PE(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,s=typeof t=="string"?e:t;return Rz(this.state,n,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return g0(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
`,textSerializers:n={}}=t||{};return Az(this.state.doc,{blockSeparator:e,textSerializers:{...TE(this.schema),...n}})}get isEmpty(){return Qf(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new x$(e,this)}get $doc(){return this.$pos(0)}};function oo(t){return new Gf({find:t.find,handler:({state:e,range:n,match:s})=>{const r=Ze(t.getAttributes,void 0,s);if(r===!1||r===null)return null;const{tr:a}=e,l=s[s.length-1],o=s[0];if(l){const c=o.search(/\S/),d=n.from+o.indexOf(l),u=d+l.length;if(x0(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(g=>g===t.type&&g!==f.mark.type)).filter(f=>f.to>d).length)return null;u<n.to&&a.delete(u,n.to),d>n.from&&a.delete(n.from+c,d);const m=n.from+c+l.length;a.addMark(n.from+c,m,t.type.create(r||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function j$(t){return new Gf({find:t.find,handler:({state:e,range:n,match:s})=>{const r=Ze(t.getAttributes,void 0,s)||{},{tr:a}=e,l=n.from;let o=n.to;const c=t.type.create(r);if(s[1]){const d=s[0].lastIndexOf(s[1]);let u=l+d;u>o?u=o:o=u+s[1].length;const h=s[0][s[0].length-1];a.insertText(h,l+s[0].length-1),a.replaceWith(u,o,c)}else if(s[0]){const d=t.type.isInline?l:l-1;a.insert(d,t.type.create(r)).delete(a.mapping.map(l),a.mapping.map(o))}a.scrollIntoView()},undoable:t.undoable})}function dx(t){return new Gf({find:t.find,handler:({state:e,range:n,match:s})=>{const r=e.doc.resolve(n.from),a=Ze(t.getAttributes,void 0,s)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,a)},undoable:t.undoable})}function co(t){return new Gf({find:t.find,handler:({state:e,range:n,match:s,chain:r})=>{const a=Ze(t.getAttributes,void 0,s)||{},l=e.tr.delete(n.from,n.to),c=l.doc.resolve(n.from).blockRange(),d=c&&Jy(c,t.type,a);if(!d)return null;if(l.wrap(c,d),t.keepMarks&&t.editor){const{selection:h,storedMarks:m}=e,{splittableMarks:f}=t.editor.extensionManager,p=m||h.$to.parentOffset&&h.$from.marks();if(p){const g=p.filter(x=>f.includes(x.type.name));l.ensureMarks(g)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";r().updateAttributes(h,a).run()}const u=l.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&Qi(l.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(s,u))&&l.join(n.from-1)},undoable:t.undoable})}function N$(t,e){const{selection:n}=t,{$from:s}=n;if(n instanceof ke){const a=s.index();return s.parent.canReplaceWith(a,a+1,e)}let r=s.depth;for(;r>=0;){const a=s.index(r);if(s.node(r).contentMatchAt(a).matchType(e))return!0;r-=1}return!1}var w$={};h0(w$,{createAtomBlockMarkdownSpec:()=>k$,createBlockMarkdownSpec:()=>S$,createInlineMarkdownSpec:()=>A$,parseAttributes:()=>v0,parseIndentedBlocks:()=>ux,renderNestedMarkdownContent:()=>j0,serializeAttributes:()=>b0});function v0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],s=t.replace(/["']([^"']*)["']/g,d=>(n.push(d),`__QUOTED_${n.length-1}__`)),r=s.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(r){const d=r.map(u=>u.trim().slice(1));e.class=d.join(" ")}const a=s.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const l=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(s.matchAll(l)).forEach(([,d,u])=>{var h;const m=parseInt(((h=u.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),f=n[m];f&&(e[d]=f.slice(1,-1))});const c=s.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(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function b0(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(s=>e.push(`.${s}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,s])=>{n==="class"||n==="id"||(s===!0?e.push(n):s!==!1&&s!=null&&e.push(`${n}="${String(s)}"`))}),e.join(" ")}function k$(t){const{nodeName:e,name:n,parseAttributes:s=v0,serializeAttributes:r=b0,defaultAttributes:a={},requiredAttributes:l=[],allowedAttributes:o}=t,c=n||e,d=u=>{if(!o)return u;const h={};return o.forEach(m=>{m in u&&(h[m]=u[m])}),h};return{parseMarkdown:(u,h)=>{const m={...a,...u.attributes};return h.createNode(e,m,[])},markdownTokenizer:{name:e,level:"block",start(u){var h;const m=new RegExp(`^:::${c}(?:\\s|$)`,"m"),f=(h=u.match(m))==null?void 0:h.index;return f!==void 0?f:-1},tokenize(u,h,m){const f=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(f);if(!p)return;const g=p[1]||"",x=s(g);if(!l.find(v=>!(v in x)))return{type:e,raw:p[0],attributes:x}}},renderMarkdown:u=>{const h=d(u.attrs||{}),m=r(h),f=m?` {${m}}`:"";return`:::${c}${f} :::`}}}function S$(t){const{nodeName:e,name:n,getContent:s,parseAttributes:r=v0,serializeAttributes:a=b0,defaultAttributes:l={},content:o="block",allowedAttributes:c}=t,d=n||e,u=h=>{if(!c)return h;const m={};return c.forEach(f=>{f in h&&(m[f]=h[f])}),m};return{parseMarkdown:(h,m)=>{let f;if(s){const g=s(h);f=typeof g=="string"?[{type:"text",text:g}]:g}else o==="block"?f=m.parseChildren(h.tokens||[]):f=m.parseInline(h.tokens||[]);const p={...l,...h.attributes};return m.createNode(e,p,f)},markdownTokenizer:{name:e,level:"block",start(h){var m;const f=new RegExp(`^:::${d}`,"m"),p=(m=h.match(f))==null?void 0:m.index;return p!==void 0?p:-1},tokenize(h,m,f){var p;const g=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=h.match(g);if(!x)return;const[y,v=""]=x,b=r(v);let j=1;const k=y.length;let E="";const T=/^:::([\w-]*)(\s.*)?/gm,w=h.slice(k);for(T.lastIndex=0;;){const S=T.exec(w);if(S===null)break;const M=S.index,F=S[1];if(!((p=S[2])!=null&&p.endsWith(":::"))){if(F)j+=1;else if(j-=1,j===0){const R=w.slice(0,M);E=R.trim();const V=h.slice(0,k+M+S[0].length);let D=[];if(E)if(o==="block")for(D=f.blockTokens(R),D.forEach(z=>{z.text&&(!z.tokens||z.tokens.length===0)&&(z.tokens=f.inlineTokens(z.text))});D.length>0;){const z=D[D.length-1];if(z.type==="paragraph"&&(!z.text||z.text.trim()===""))D.pop();else break}else D=f.inlineTokens(E);return{type:e,raw:V,attributes:b,content:E,tokens:D}}}}}},renderMarkdown:(h,m)=>{const f=u(h.attrs||{}),p=a(f),g=p?` {${p}}`:"",x=m.renderChildren(h.content||[],`
`);return`:::${d}${g}
${x}
:::`}}}function C$(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let s=n.exec(t);for(;s!==null;){const[,r,a,l]=s;e[r]=a||l,s=n.exec(t)}return e}function E$(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function A$(t){const{nodeName:e,name:n,getContent:s,parseAttributes:r=C$,serializeAttributes:a=E$,defaultAttributes:l={},selfClosing:o=!1,allowedAttributes:c}=t,d=n||e,u=m=>{if(!c)return m;const f={};return c.forEach(p=>{const g=typeof p=="string"?p:p.name,x=typeof p=="string"?void 0:p.skipIfDefault;if(g in m){const y=m[g];if(x!==void 0&&y===x)return;f[g]=y}}),f},h=d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(m,f)=>{const p={...l,...m.attributes};if(o)return f.createNode(e,p);const g=s?s(m):m.content||"";return g?f.createNode(e,p,[f.createTextNode(g)]):f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(m){const f=o?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),p=m.match(f),g=p==null?void 0:p.index;return g!==void 0?g:-1},tokenize(m,f,p){const g=o?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),x=m.match(g);if(!x)return;let y="",v="";if(o){const[,j]=x;v=j}else{const[,j,k]=x;v=j,y=k||""}const b=r(v.trim());return{type:e,raw:x[0],content:y.trim(),attributes:b}}},renderMarkdown:m=>{let f="";s?f=s(m):m.content&&m.content.length>0&&(f=m.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const p=u(m.attrs||{}),g=a(p),x=g?` ${g}`:"";return o?`[${d}${x}]`:`[${d}${x}]${f}[/${d}]`}}}function ux(t,e,n){var s,r,a,l;const o=t.split(`
`),c=[];let d="",u=0;const h=e.baseIndentSize||2;for(;u<o.length;){const m=o[u],f=m.match(e.itemPattern);if(!f){if(c.length>0)break;if(m.trim()===""){u+=1,d=`${d}${m}
`;continue}else return}const p=e.extractItemData(f),{indentLevel:g,mainContent:x}=p;d=`${d}${m}
`;const y=[x];for(u+=1;u<o.length;){const k=o[u];if(k.trim()===""){const T=o.slice(u+1).findIndex(M=>M.trim()!=="");if(T===-1)break;if((((r=(s=o[u+1+T].match(/^(\s*)/))==null?void 0:s[1])==null?void 0:r.length)||0)>g){y.push(k),d=`${d}${k}
`,u+=1;continue}else break}if((((l=(a=k.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:l.length)||0)>g)y.push(k),d=`${d}${k}
`,u+=1;else break}let v;const b=y.slice(1);if(b.length>0){const k=b.map(E=>E.slice(g+h)).join(`
`);k.trim()&&(e.customNestedParser?v=e.customNestedParser(k):v=n.blockTokens(k))}const j=e.createToken(p,v);c.push(j)}if(c.length!==0)return{items:c,raw:d}}function j0(t,e,n,s){if(!t||!Array.isArray(t.content))return"";const r=typeof n=="function"?n(s):n,[a,...l]=t.content,o=e.renderChildren([a]),c=[`${r}${o}`];return l&&l.length>0&&l.forEach(d=>{const u=e.renderChildren([d]);if(u){const h=u.split(`
`).map(m=>m?e.indent(m):"").join(`
`);c.push(h)}}),c.join(`
`)}function D$(t,e,n={}){const{state:s}=e,{doc:r,tr:a}=s,l=t;r.descendants((o,c)=>{const d=a.mapping.map(c),u=a.mapping.map(c)+o.nodeSize;let h=null;if(o.marks.forEach(f=>{if(f!==l)return!1;h=f}),!h)return;let m=!1;if(Object.keys(n).forEach(f=>{n[f]!==h.attrs[f]&&(m=!0)}),m){const f=t.type.create({...t.attrs,...n});a.removeMark(d,u,t.type),a.addMark(d,u,f)}}),a.docChanged&&e.view.dispatch(a)}var hs=class ZE extends y0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new ZE(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function qa(t){return new u$({find:t.find,handler:({state:e,range:n,match:s,pasteEvent:r})=>{const a=Ze(t.getAttributes,void 0,s,r);if(a===!1||a===null)return null;const{tr:l}=e,o=s[s.length-1],c=s[0];let d=n.to;if(o){const u=c.search(/\S/),h=n.from+c.indexOf(o),m=h+o.length;if(x0(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(x=>x===t.type&&x!==p.mark.type)).filter(p=>p.to>h).length)return null;m<n.to&&l.delete(m,n.to),h>n.from&&l.delete(n.from+u,h),d=n.from+u+o.length,l.addMark(n.from+u,d,t.type.create(a||{})),l.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:M$,getOwnPropertySymbols:T$}=Object,{hasOwnProperty:P$}=Object.prototype;function ip(t,e){return function(s,r,a){return t(s,r,a)&&e(s,r,a)}}function iu(t){return function(n,s,r){if(!n||!s||typeof n!="object"||typeof s!="object")return t(n,s,r);const{cache:a}=r,l=a.get(n),o=a.get(s);if(l&&o)return l===s&&o===n;a.set(n,s),a.set(s,n);const c=t(n,s,r);return a.delete(n),a.delete(s),c}}function I$(t){return t!=null?t[Symbol.toStringTag]:void 0}function dN(t){return M$(t).concat(T$(t))}const R$=Object.hasOwn||((t,e)=>P$.call(t,e));function Za(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const O$="__v",L$="__o",F$="_owner",{getOwnPropertyDescriptor:uN,keys:hN}=Object;function z$(t,e){return t.byteLength===e.byteLength&&Dh(new Uint8Array(t),new Uint8Array(e))}function $$(t,e,n){let s=t.length;if(e.length!==s)return!1;for(;s-- >0;)if(!n.equals(t[s],e[s],s,s,t,e,n))return!1;return!0}function B$(t,e){return t.byteLength===e.byteLength&&Dh(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function _$(t,e){return Za(t.getTime(),e.getTime())}function V$(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function K$(t,e){return t===e}function fN(t,e,n){const s=t.size;if(s!==e.size)return!1;if(!s)return!0;const r=new Array(s),a=t.entries();let l,o,c=0;for(;(l=a.next())&&!l.done;){const d=e.entries();let u=!1,h=0;for(;(o=d.next())&&!o.done;){if(r[h]){h++;continue}const m=l.value,f=o.value;if(n.equals(m[0],f[0],c,h,t,e,n)&&n.equals(m[1],f[1],m[0],f[0],t,e,n)){u=r[h]=!0;break}h++}if(!u)return!1;c++}return!0}const U$=Za;function q$(t,e,n){const s=hN(t);let r=s.length;if(hN(e).length!==r)return!1;for(;r-- >0;)if(!YE(t,e,n,s[r]))return!1;return!0}function Oo(t,e,n){const s=dN(t);let r=s.length;if(dN(e).length!==r)return!1;let a,l,o;for(;r-- >0;)if(a=s[r],!YE(t,e,n,a)||(l=uN(t,a),o=uN(e,a),(l||o)&&(!l||!o||l.configurable!==o.configurable||l.enumerable!==o.enumerable||l.writable!==o.writable)))return!1;return!0}function H$(t,e){return Za(t.valueOf(),e.valueOf())}function W$(t,e){return t.source===e.source&&t.flags===e.flags}function mN(t,e,n){const s=t.size;if(s!==e.size)return!1;if(!s)return!0;const r=new Array(s),a=t.values();let l,o;for(;(l=a.next())&&!l.done;){const c=e.values();let d=!1,u=0;for(;(o=c.next())&&!o.done;){if(!r[u]&&n.equals(l.value,o.value,l.value,o.value,t,e,n)){d=r[u]=!0;break}u++}if(!d)return!1}return!0}function Dh(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function Q$(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function YE(t,e,n,s){return(s===F$||s===L$||s===O$)&&(t.$$typeof||e.$$typeof)?!0:R$(e,s)&&n.equals(t[s],e[s],s,s,t,e,n)}const G$="[object ArrayBuffer]",J$="[object Arguments]",Z$="[object Boolean]",Y$="[object DataView]",X$="[object Date]",eB="[object Error]",tB="[object Map]",nB="[object Number]",sB="[object Object]",rB="[object RegExp]",iB="[object Set]",aB="[object String]",lB={"[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},oB="[object URL]",cB=Object.prototype.toString;function dB({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:s,areErrorsEqual:r,areFunctionsEqual:a,areMapsEqual:l,areNumbersEqual:o,areObjectsEqual:c,arePrimitiveWrappersEqual:d,areRegExpsEqual:u,areSetsEqual:h,areTypedArraysEqual:m,areUrlsEqual:f,unknownTagComparators:p}){return function(x,y,v){if(x===y)return!0;if(x==null||y==null)return!1;const b=typeof x;if(b!==typeof y)return!1;if(b!=="object")return b==="number"?o(x,y,v):b==="function"?a(x,y,v):!1;const j=x.constructor;if(j!==y.constructor)return!1;if(j===Object)return c(x,y,v);if(Array.isArray(x))return e(x,y,v);if(j===Date)return s(x,y,v);if(j===RegExp)return u(x,y,v);if(j===Map)return l(x,y,v);if(j===Set)return h(x,y,v);const k=cB.call(x);if(k===X$)return s(x,y,v);if(k===rB)return u(x,y,v);if(k===tB)return l(x,y,v);if(k===iB)return h(x,y,v);if(k===sB)return typeof x.then!="function"&&typeof y.then!="function"&&c(x,y,v);if(k===oB)return f(x,y,v);if(k===eB)return r(x,y,v);if(k===J$)return c(x,y,v);if(lB[k])return m(x,y,v);if(k===G$)return t(x,y,v);if(k===Y$)return n(x,y,v);if(k===Z$||k===nB||k===aB)return d(x,y,v);if(p){let E=p[k];if(!E){const T=I$(x);T&&(E=p[T])}if(E)return E(x,y,v)}return!1}}function uB({circular:t,createCustomConfig:e,strict:n}){let s={areArrayBuffersEqual:z$,areArraysEqual:n?Oo:$$,areDataViewsEqual:B$,areDatesEqual:_$,areErrorsEqual:V$,areFunctionsEqual:K$,areMapsEqual:n?ip(fN,Oo):fN,areNumbersEqual:U$,areObjectsEqual:n?Oo:q$,arePrimitiveWrappersEqual:H$,areRegExpsEqual:W$,areSetsEqual:n?ip(mN,Oo):mN,areTypedArraysEqual:n?ip(Dh,Oo):Dh,areUrlsEqual:Q$,unknownTagComparators:void 0};if(e&&(s=Object.assign({},s,e(s))),t){const r=iu(s.areArraysEqual),a=iu(s.areMapsEqual),l=iu(s.areObjectsEqual),o=iu(s.areSetsEqual);s=Object.assign({},s,{areArraysEqual:r,areMapsEqual:a,areObjectsEqual:l,areSetsEqual:o})}return s}function hB(t){return function(e,n,s,r,a,l,o){return t(e,n,o)}}function fB({circular:t,comparator:e,createState:n,equals:s,strict:r}){if(n)return function(o,c){const{cache:d=t?new WeakMap:void 0,meta:u}=n();return e(o,c,{cache:d,equals:s,meta:u,strict:r})};if(t)return function(o,c){return e(o,c,{cache:new WeakMap,equals:s,meta:void 0,strict:r})};const a={cache:void 0,equals:s,meta:void 0,strict:r};return function(o,c){return e(o,c,a)}}const mB=Ji();Ji({strict:!0});Ji({circular:!0});Ji({circular:!0,strict:!0});Ji({createInternalComparator:()=>Za});Ji({strict:!0,createInternalComparator:()=>Za});Ji({circular:!0,createInternalComparator:()=>Za});Ji({circular:!0,createInternalComparator:()=>Za,strict:!0});function Ji(t={}){const{circular:e=!1,createInternalComparator:n,createState:s,strict:r=!1}=t,a=uB(t),l=dB(a),o=n?n(l):hB(l);return fB({circular:e,comparator:l,createState:s,equals:o,strict:r})}var XE={exports:{}},e4={};/**
* @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 Zf=N,pB=Wy;function gB(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var xB=typeof Object.is=="function"?Object.is:gB,yB=pB.useSyncExternalStore,vB=Zf.useRef,bB=Zf.useEffect,jB=Zf.useMemo,NB=Zf.useDebugValue;e4.useSyncExternalStoreWithSelector=function(t,e,n,s,r){var a=vB(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=jB(function(){function c(f){if(!d){if(d=!0,u=f,f=s(f),r!==void 0&&l.hasValue){var p=l.value;if(r(p,f))return h=p}return h=f}if(p=h,xB(u,f))return p;var g=s(f);return r!==void 0&&r(p,g)?(u=f,p):(u=f,h=g)}var d=!1,u,h,m=n===void 0?null:n;return[function(){return c(e())},m===null?void 0:function(){return c(m())}]},[e,n,s,r]);var o=yB(t,a[0],a[1]);return bB(function(){l.hasValue=!0,l.value=o},[o]),NB(o),o};XE.exports=e4;var wB=XE.exports,kB=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},SB=({contentComponent:t})=>{const e=Wy.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return i.jsx(i.Fragment,{children:Object.values(e)})};function CB(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,s){e={...e,[n]:rM.createPortal(s.reactElement,s.element,n)},t.forEach(r=>r())},removeRenderer(n){const s={...e};delete s[n],e=s,t.forEach(r=>r())}}}var EB=class extends ut.Component{constructor(t){var e;super(t),this.editorContentRef=ut.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=CB(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(s=>s.hasContentComponentInitialized?s:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:kB(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&i.jsx(SB,{contentComponent:t.contentComponent})]})}},AB=N.forwardRef((t,e)=>{const n=ut.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ut.createElement(EB,{key:n,innerRef:e,...t})}),t4=ut.memo(AB),DB=typeof window<"u"?N.useLayoutEffect:N.useEffect,MB=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(s=>s())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function TB(t){var e;const[n]=N.useState(()=>new MB(t.editor)),s=wB.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:mB);return DB(()=>n.watch(t.editor),[t.editor,n]),N.useDebugValue(s),s}var PB=!1,hx=typeof window>"u",IB=hx||!!(typeof window<"u"&&window.next),RB=class n4{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?hx||IB?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...s)=>{var r,a;return(a=(r=this.options.current).onBeforeCreate)==null?void 0:a.call(r,...s)},onBlur:(...s)=>{var r,a;return(a=(r=this.options.current).onBlur)==null?void 0:a.call(r,...s)},onCreate:(...s)=>{var r,a;return(a=(r=this.options.current).onCreate)==null?void 0:a.call(r,...s)},onDestroy:(...s)=>{var r,a;return(a=(r=this.options.current).onDestroy)==null?void 0:a.call(r,...s)},onFocus:(...s)=>{var r,a;return(a=(r=this.options.current).onFocus)==null?void 0:a.call(r,...s)},onSelectionUpdate:(...s)=>{var r,a;return(a=(r=this.options.current).onSelectionUpdate)==null?void 0:a.call(r,...s)},onTransaction:(...s)=>{var r,a;return(a=(r=this.options.current).onTransaction)==null?void 0:a.call(r,...s)},onUpdate:(...s)=>{var r,a;return(a=(r=this.options.current).onUpdate)==null?void 0:a.call(r,...s)},onContentError:(...s)=>{var r,a;return(a=(r=this.options.current).onContentError)==null?void 0:a.call(r,...s)},onDrop:(...s)=>{var r,a;return(a=(r=this.options.current).onDrop)==null?void 0:a.call(r,...s)},onPaste:(...s)=>{var r,a;return(a=(r=this.options.current).onPaste)==null?void 0:a.call(r,...s)},onDelete:(...s)=>{var r,a;return(a=(r=this.options.current).onDelete)==null?void 0:a.call(r,...s)}};return new b$(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(s=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(s)?!0:s==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((r,a)=>{var l;return r===((l=n.extensions)==null?void 0:l[a])}):e[s]===n[s])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?n4.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((s,r)=>s===e[r]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function OB(t={},e=[]){const n=N.useRef(t);n.current=t;const[s]=N.useState(()=>new RB(n)),r=Wy.useSyncExternalStore(s.subscribe,s.getEditor,s.getServerSnapshot);return N.useDebugValue(r),N.useEffect(s.onRender(e)),TB({editor:r,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),r}var s4=N.createContext({editor:null});s4.Consumer;var LB=N.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),FB=()=>N.useContext(LB);ut.forwardRef((t,e)=>{const{onDragStart:n}=FB(),s=t.as||"div";return i.jsx(s,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ut.createContext({markViewContentRef:()=>{}});var N0=N.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});N0.displayName="TiptapContext";var zB=()=>N.useContext(N0);function r4({editor:t,instance:e,children:n}){const s=t??e;if(!s)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const r=N.useMemo(()=>({editor:s}),[s]),a=N.useMemo(()=>({editor:s}),[s]);return i.jsx(s4.Provider,{value:a,children:i.jsx(N0.Provider,{value:r,children:n})})}r4.displayName="Tiptap";function i4({...t}){const{editor:e}=zB();return i.jsx(t4,{editor:e,...t})}i4.displayName="Tiptap.Content";Object.assign(r4,{Content:i4});var Mh=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...s}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,s,n]},$B=/^\s*>\s$/,BB=hs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Mh("blockquote",{..._t(this.options.HTMLAttributes,t),children:Mh("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",s=[];return t.content.forEach(r=>{const o=e.renderChildren([r]).split(`
`).map(c=>c.trim()===""?n:`${n} ${c}`);s.push(o.join(`
`))}),s.join(`
${n}
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[co({find:$B,type:this.type})]}}),_B=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,VB=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,KB=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,UB=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,qB=Ja.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Mh("strong",{..._t(this.options.HTMLAttributes,t),children:Mh("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[oo({find:_B,type:this.type}),oo({find:KB,type:this.type})]},addPasteRules(){return[qa({find:VB,type:this.type}),qa({find:UB,type:this.type})]}}),HB=/(^|[^`])`([^`]+)`(?!`)$/,WB=/(^|[^`])`([^`]+)`(?!`)/g,QB=Ja.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",_t(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[oo({find:HB,type:this.type})]},addPasteRules(){return[qa({find:WB,type:this.type})]}}),ap=4,GB=/^```([a-z]+)?[\s\n]$/,JB=/^~~~([a-z]+)?[\s\n]$/,ZB=hs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ap,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(l=>l.startsWith(n)).map(l=>l.replace(n,""))[0];return a||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",_t(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let s="";const r=((n=t.attrs)==null?void 0:n.language)||"";return t.content?s=[`\`\`\`${r}`,e.renderChildren(t.content),"```"].join(`
`):s=`\`\`\`${r}
\`\`\``,s},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:ap,{state:s}=t,{selection:r}=s,{$from:a,empty:l}=r;if(a.parent.type!==this.type)return!1;const o=" ".repeat(n);return l?t.commands.insertContent(o):t.commands.command(({tr:c})=>{const{from:d,to:u}=r,f=s.doc.textBetween(d,u,`
`,`
`).split(`
`).map(p=>o+p).join(`
`);return c.replaceWith(d,u,s.schema.text(f)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:ap,{state:s}=t,{selection:r}=s,{$from:a,empty:l}=r;return a.parent.type!==this.type?!1:l?t.commands.command(({tr:o})=>{var c;const{pos:d}=a,u=a.start(),h=a.end(),f=s.doc.textBetween(u,h,`
`,`
`).split(`
`);let p=0,g=0;const x=d-u;for(let E=0;E<f.length;E+=1){if(g+f[E].length>=x){p=E;break}g+=f[E].length+1}const v=((c=f[p].match(/^ */))==null?void 0:c[0])||"",b=Math.min(v.length,n);if(b===0)return!0;let j=u;for(let E=0;E<p;E+=1)j+=f[E].length+1;return o.delete(j,j+b),d-j<=b&&o.setSelection(De.create(o.doc,j)),!0}):t.commands.command(({tr:o})=>{const{from:c,to:d}=r,m=s.doc.textBetween(c,d,`
`,`
`).split(`
`).map(f=>{var p;const g=((p=f.match(/^ */))==null?void 0:p[0])||"",x=Math.min(g.length,n);return f.slice(x)}).join(`
`);return o.replaceWith(c,d,s.schema.text(m)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:s,empty:r}=n;if(!r||s.parent.type!==this.type)return!1;const a=s.parentOffset===s.parent.nodeSize-2,l=s.parent.textContent.endsWith(`
`);return!a||!l?!1:t.chain().command(({tr:o})=>(o.delete(s.pos-2,s.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:s}=e,{$from:r,empty:a}=n;if(!a||r.parent.type!==this.type||!(r.parentOffset===r.parent.nodeSize-2))return!1;const o=r.after();return o===void 0?!1:s.nodeAt(o)?t.commands.command(({tr:d})=>(d.setSelection(Ie.near(s.resolve(o))),!0)):t.commands.exitCode()}}},addInputRules(){return[dx({find:GB,type:this.type,getAttributes:t=>({language:t[1]})}),dx({find:JB,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Nt({key:new Ht("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),s=e.clipboardData.getData("vscode-editor-data"),r=s?JSON.parse(s):void 0,a=r==null?void 0:r.mode;if(!n||!a)return!1;const{tr:l,schema:o}=t.state,c=o.text(n.replace(/\r\n?/g,`
`));return l.replaceSelectionWith(this.type.create({language:a},c)),l.selection.$from.parent.type!==this.type&&l.setSelection(De.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),YB=hs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):""}),XB=hs.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",_t(this.options.HTMLAttributes,t)]},renderText(){return`
`},renderMarkdown:()=>`
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:s})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:r,storedMarks:a}=n;if(r.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:o}=s.extensionManager,c=a||r.$to.parentOffset&&r.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&l){const h=c.filter(m=>o.includes(m.type.name));d.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),e_=hs.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,_t(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const s=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,r="#".repeat(s);return t.content?`${r} ${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=>dx({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),t_=hs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",_t(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!N$(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:s}=n,r=t();return RE(n)?r.insertContentAt(s.pos,{type:this.name}):r.insertContent({type:this.name}),r.command(({state:a,tr:l,dispatch:o})=>{if(o){const{$to:c}=l.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?l.setSelection(De.create(l.doc,c.pos+1)):c.nodeAfter.isBlock?l.setSelection(ke.create(l.doc,c.pos)):l.setSelection(De.create(l.doc,c.pos));else{const u=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,h=u==null?void 0:u.create();h&&(l.insert(d,h),l.setSelection(De.create(l.doc,d+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[j$({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),n_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,s_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,r_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,i_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,a_=Ja.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",_t(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[oo({find:n_,type:this.type}),oo({find:r_,type:this.type})]},addPasteRules(){return[qa({find:s_,type:this.type}),qa({find:i_,type:this.type})]}});const l_="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",o_="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт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همراهاکستان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",fx="numeric",mx="ascii",px="alpha",dc="asciinumeric",Wo="alphanumeric",gx="domain",a4="emoji",c_="scheme",d_="slashscheme",lp="whitespace";function u_(t,e){return t in e||(e[t]=[]),e[t]}function ha(t,e,n){e[fx]&&(e[dc]=!0,e[Wo]=!0),e[mx]&&(e[dc]=!0,e[px]=!0),e[dc]&&(e[Wo]=!0),e[px]&&(e[Wo]=!0),e[Wo]&&(e[gx]=!0),e[a4]&&(e[gx]=!0);for(const s in e){const r=u_(s,n);r.indexOf(t)<0&&r.push(t)}}function h_(t,e){const n={};for(const s in e)e[s].indexOf(t)>=0&&(n[s]=!0);return n}function Vn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Vn.groups={};Vn.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let s=0;s<e.jr.length;s++){const r=e.jr[s][0],a=e.jr[s][1];if(a&&r.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,s){for(let r=0;r<t.length;r++)this.tt(t[r],e,n,s)},tr(t,e,n,s){s=s||Vn.groups;let r;return e&&e.j?r=e:(r=new Vn(e),n&&s&&ha(e,n,s)),this.jr.push([t,r]),r},ts(t,e,n,s){let r=this;const a=t.length;if(!a)return r;for(let l=0;l<a-1;l++)r=r.tt(t[l]);return r.tt(t[a-1],e,n,s)},tt(t,e,n,s){s=s||Vn.groups;const r=this;if(e&&e.j)return r.j[t]=e,e;const a=e;let l,o=r.go(t);if(o?(l=new Vn,Object.assign(l.j,o.j),l.jr.push.apply(l.jr,o.jr),l.jd=o.jd,l.t=o.t):l=new Vn,a){if(s)if(l.t&&typeof l.t=="string"){const c=Object.assign(h_(l.t,s),n);ha(a,c,s)}else n&&ha(a,n,s);l.t=a}return r.j[t]=l,l}};const Pe=(t,e,n,s,r)=>t.ta(e,n,s,r),kt=(t,e,n,s,r)=>t.tr(e,n,s,r),pN=(t,e,n,s,r)=>t.ts(e,n,s,r),te=(t,e,n,s,r)=>t.tt(e,n,s,r),vr="WORD",xx="UWORD",l4="ASCIINUMERICAL",o4="ALPHANUMERICAL",Yc="LOCALHOST",yx="TLD",vx="UTLD",Tu="SCHEME",ll="SLASH_SCHEME",w0="NUM",bx="WS",k0="NL",uc="OPENBRACE",hc="CLOSEBRACE",Th="OPENBRACKET",Ph="CLOSEBRACKET",Ih="OPENPAREN",Rh="CLOSEPAREN",Oh="OPENANGLEBRACKET",Lh="CLOSEANGLEBRACKET",Fh="FULLWIDTHLEFTPAREN",zh="FULLWIDTHRIGHTPAREN",$h="LEFTCORNERBRACKET",Bh="RIGHTCORNERBRACKET",_h="LEFTWHITECORNERBRACKET",Vh="RIGHTWHITECORNERBRACKET",Kh="FULLWIDTHLESSTHAN",Uh="FULLWIDTHGREATERTHAN",qh="AMPERSAND",Hh="APOSTROPHE",Wh="ASTERISK",ti="AT",Qh="BACKSLASH",Gh="BACKTICK",Jh="CARET",ci="COLON",S0="COMMA",Zh="DOLLAR",Gs="DOT",Yh="EQUALS",C0="EXCLAMATION",ms="HYPHEN",fc="PERCENT",Xh="PIPE",ef="PLUS",tf="POUND",mc="QUERY",E0="QUOTE",c4="FULLWIDTHMIDDLEDOT",A0="SEMI",Js="SLASH",pc="TILDE",nf="UNDERSCORE",d4="EMOJI",sf="SYM";var u4=Object.freeze({__proto__:null,ALPHANUMERICAL:o4,AMPERSAND:qh,APOSTROPHE:Hh,ASCIINUMERICAL:l4,ASTERISK:Wh,AT:ti,BACKSLASH:Qh,BACKTICK:Gh,CARET:Jh,CLOSEANGLEBRACKET:Lh,CLOSEBRACE:hc,CLOSEBRACKET:Ph,CLOSEPAREN:Rh,COLON:ci,COMMA:S0,DOLLAR:Zh,DOT:Gs,EMOJI:d4,EQUALS:Yh,EXCLAMATION:C0,FULLWIDTHGREATERTHAN:Uh,FULLWIDTHLEFTPAREN:Fh,FULLWIDTHLESSTHAN:Kh,FULLWIDTHMIDDLEDOT:c4,FULLWIDTHRIGHTPAREN:zh,HYPHEN:ms,LEFTCORNERBRACKET:$h,LEFTWHITECORNERBRACKET:_h,LOCALHOST:Yc,NL:k0,NUM:w0,OPENANGLEBRACKET:Oh,OPENBRACE:uc,OPENBRACKET:Th,OPENPAREN:Ih,PERCENT:fc,PIPE:Xh,PLUS:ef,POUND:tf,QUERY:mc,QUOTE:E0,RIGHTCORNERBRACKET:Bh,RIGHTWHITECORNERBRACKET:Vh,SCHEME:Tu,SEMI:A0,SLASH:Js,SLASH_SCHEME:ll,SYM:sf,TILDE:pc,TLD:yx,UNDERSCORE:nf,UTLD:vx,UWORD:xx,WORD:vr,WS:bx});const gr=/[a-z]/,Lo=new RegExp("\\p{L}","u"),op=new RegExp("\\p{Emoji}","u"),xr=/\d/,cp=/\s/,gN="\r",dp=`
`,f_="",m_="",up="";let au=null,lu=null;function p_(t=[]){const e={};Vn.groups=e;const n=new Vn;au==null&&(au=xN(l_)),lu==null&&(lu=xN(o_)),te(n,"'",Hh),te(n,"{",uc),te(n,"}",hc),te(n,"[",Th),te(n,"]",Ph),te(n,"(",Ih),te(n,")",Rh),te(n,"<",Oh),te(n,">",Lh),te(n,"",Fh),te(n,"",zh),te(n,"「",$h),te(n,"」",Bh),te(n,"『",_h),te(n,"』",Vh),te(n,"",Kh),te(n,"",Uh),te(n,"&",qh),te(n,"*",Wh),te(n,"@",ti),te(n,"`",Gh),te(n,"^",Jh),te(n,":",ci),te(n,",",S0),te(n,"$",Zh),te(n,".",Gs),te(n,"=",Yh),te(n,"!",C0),te(n,"-",ms),te(n,"%",fc),te(n,"|",Xh),te(n,"+",ef),te(n,"#",tf),te(n,"?",mc),te(n,'"',E0),te(n,"/",Js),te(n,";",A0),te(n,"~",pc),te(n,"_",nf),te(n,"\\",Qh),te(n,"・",c4);const s=kt(n,xr,w0,{[fx]:!0});kt(s,xr,s);const r=kt(s,gr,l4,{[dc]:!0}),a=kt(s,Lo,o4,{[Wo]:!0}),l=kt(n,gr,vr,{[mx]:!0});kt(l,xr,r),kt(l,gr,l),kt(r,xr,r),kt(r,gr,r);const o=kt(n,Lo,xx,{[px]:!0});kt(o,gr),kt(o,xr,a),kt(o,Lo,o),kt(a,xr,a),kt(a,gr),kt(a,Lo,a);const c=te(n,dp,k0,{[lp]:!0}),d=te(n,gN,bx,{[lp]:!0}),u=kt(n,cp,bx,{[lp]:!0});te(n,up,u),te(d,dp,c),te(d,up,u),kt(d,cp,u),te(u,gN),te(u,dp),kt(u,cp,u),te(u,up,u);const h=kt(n,op,d4,{[a4]:!0});te(h,"#"),kt(h,op,h),te(h,f_,h);const m=te(h,m_);te(m,"#"),kt(m,op,h);const f=[[gr,l],[xr,r]],p=[[gr,null],[Lo,o],[xr,a]];for(let g=0;g<au.length;g++)Gr(n,au[g],yx,vr,f);for(let g=0;g<lu.length;g++)Gr(n,lu[g],vx,xx,p);ha(yx,{tld:!0,ascii:!0},e),ha(vx,{utld:!0,alpha:!0},e),Gr(n,"file",Tu,vr,f),Gr(n,"mailto",Tu,vr,f),Gr(n,"http",ll,vr,f),Gr(n,"https",ll,vr,f),Gr(n,"ftp",ll,vr,f),Gr(n,"ftps",ll,vr,f),ha(Tu,{scheme:!0,ascii:!0},e),ha(ll,{slashscheme:!0,ascii:!0},e),t=t.sort((g,x)=>g[0]>x[0]?1:-1);for(let g=0;g<t.length;g++){const x=t[g][0],v=t[g][1]?{[c_]:!0}:{[d_]:!0};x.indexOf("-")>=0?v[gx]=!0:gr.test(x)?xr.test(x)?v[dc]=!0:v[mx]=!0:v[fx]=!0,pN(n,x,x,v)}return pN(n,"localhost",Yc,{ascii:!0}),n.jd=new Vn(sf),{start:n,tokens:Object.assign({groups:e},u4)}}function h4(t,e){const n=g_(e.replace(/[A-Z]/g,o=>o.toLowerCase())),s=n.length,r=[];let a=0,l=0;for(;l<s;){let o=t,c=null,d=0,u=null,h=-1,m=-1;for(;l<s&&(c=o.go(n[l]));)o=c,o.accepts()?(h=0,m=0,u=o):h>=0&&(h+=n[l].length,m++),d+=n[l].length,a+=n[l].length,l++;a-=h,l-=m,d-=h,r.push({t:u.t,v:e.slice(a-d,a),s:a-d,e:a})}return r}function g_(t){const e=[],n=t.length;let s=0;for(;s<n;){let r=t.charCodeAt(s),a,l=r<55296||r>56319||s+1===n||(a=t.charCodeAt(s+1))<56320||a>57343?t[s]:t.slice(s,s+2);e.push(l),s+=l.length}return e}function Gr(t,e,n,s,r){let a;const l=e.length;for(let o=0;o<l-1;o++){const c=e[o];t.j[c]?a=t.j[c]:(a=new Vn(s),a.jr=r.slice(),t.j[c]=a),t=a}return a=new Vn(n),a.jr=r.slice(),t.j[e[l-1]]=a,a}function xN(t){const e=[],n=[];let s=0,r="0123456789";for(;s<t.length;){let a=0;for(;r.indexOf(t[s+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let l=parseInt(t.substring(s,s+a),10);l>0;l--)n.pop();s+=a}else n.push(t[s]),s++}return e}const Xc={defaultProtocol:"http",events:null,format:yN,formatHref:yN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function D0(t,e=null){let n=Object.assign({},Xc);t&&(n=Object.assign(n,t instanceof D0?t.o:t));const s=n.ignoreTags,r=[];for(let a=0;a<s.length;a++)r.push(s[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=r}D0.prototype={o:Xc,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const s=e!=null;let r=this.o[t];return r&&(typeof r=="object"?(r=n.t in r?r[n.t]:Xc[t],typeof r=="function"&&s&&(r=r(e,n))):typeof r=="function"&&s&&(r=r(e,n.t,n)),r)},getObj(t,e,n){let s=this.o[t];return typeof s=="function"&&e!=null&&(s=s(e,n.t,n)),s},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function yN(t){return t}function f4(t,e){this.t="token",this.v=t,this.tk=e}f4.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),s=t.get("format",e,this);return n&&s.length>n?s.substring(0,n)+"…":s},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=Xc.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),s=t.get("formatHref",n,this),r=t.get("tagName",n,e),a=this.toFormattedString(t),l={},o=t.get("className",n,e),c=t.get("target",n,e),d=t.get("rel",n,e),u=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return l.href=s,o&&(l.class=o),c&&(l.target=c),d&&(l.rel=d),u&&Object.assign(l,u),{tagName:r,attributes:l,content:a,eventListeners:h}}};function Yf(t,e){class n extends f4{constructor(r,a){super(r,a),this.t=t}}for(const s in e)n.prototype[s]=e[s];return n.t=t,n}const vN=Yf("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),bN=Yf("text"),x_=Yf("nl"),ou=Yf("url",{isLink:!0,toHref(t=Xc.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Yc&&t[1].t===ci}}),fs=t=>new Vn(t);function y_({groups:t}){const e=t.domain.concat([qh,Wh,ti,Qh,Gh,Jh,Zh,Yh,ms,w0,fc,Xh,ef,tf,Js,sf,pc,nf]),n=[Hh,ci,S0,Gs,C0,fc,mc,E0,A0,Oh,Lh,uc,hc,Ph,Th,Ih,Rh,Fh,zh,$h,Bh,_h,Vh,Kh,Uh],s=[qh,Hh,Wh,Qh,Gh,Jh,Zh,Yh,ms,uc,hc,fc,Xh,ef,tf,mc,Js,sf,pc,nf],r=fs(),a=te(r,pc);Pe(a,s,a),Pe(a,t.domain,a);const l=fs(),o=fs(),c=fs();Pe(r,t.domain,l),Pe(r,t.scheme,o),Pe(r,t.slashscheme,c),Pe(l,s,a),Pe(l,t.domain,l);const d=te(l,ti);te(a,ti,d),te(o,ti,d),te(c,ti,d);const u=te(a,Gs);Pe(u,s,a),Pe(u,t.domain,a);const h=fs();Pe(d,t.domain,h),Pe(h,t.domain,h);const m=te(h,Gs);Pe(m,t.domain,h);const f=fs(vN);Pe(m,t.tld,f),Pe(m,t.utld,f),te(d,Yc,f);const p=te(h,ms);te(p,ms,p),Pe(p,t.domain,h),Pe(f,t.domain,h),te(f,Gs,m),te(f,ms,p);const g=te(f,ci);Pe(g,t.numeric,vN);const x=te(l,ms),y=te(l,Gs);te(x,ms,x),Pe(x,t.domain,l),Pe(y,s,a),Pe(y,t.domain,l);const v=fs(ou);Pe(y,t.tld,v),Pe(y,t.utld,v),Pe(v,t.domain,l),Pe(v,s,a),te(v,Gs,y),te(v,ms,x),te(v,ti,d);const b=te(v,ci),j=fs(ou);Pe(b,t.numeric,j);const k=fs(ou),E=fs();Pe(k,e,k),Pe(k,n,E),Pe(E,e,k),Pe(E,n,E),te(v,Js,k),te(j,Js,k);const T=te(o,ci),w=te(c,ci),S=te(w,Js),M=te(S,Js);Pe(o,t.domain,l),te(o,Gs,y),te(o,ms,x),Pe(c,t.domain,l),te(c,Gs,y),te(c,ms,x),Pe(T,t.domain,k),te(T,Js,k),te(T,mc,k),Pe(M,t.domain,k),Pe(M,e,k),te(M,Js,k);const F=[[uc,hc],[Th,Ph],[Ih,Rh],[Oh,Lh],[Fh,zh],[$h,Bh],[_h,Vh],[Kh,Uh]];for(let R=0;R<F.length;R++){const[V,D]=F[R],z=te(k,V);te(E,V,z),te(z,D,k);const C=fs(ou);Pe(z,e,C);const _=fs();Pe(z,n),Pe(C,e,C),Pe(C,n,_),Pe(_,e,C),Pe(_,n,_),te(C,D,k),te(_,D,k)}return te(r,Yc,v),te(r,k0,x_),{start:r,tokens:u4}}function v_(t,e,n){let s=n.length,r=0,a=[],l=[];for(;r<s;){let o=t,c=null,d=null,u=0,h=null,m=-1;for(;r<s&&!(c=o.go(n[r].t));)l.push(n[r++]);for(;r<s&&(d=c||o.go(n[r].t));)c=null,o=d,o.accepts()?(m=0,h=o):m>=0&&m++,r++,u++;if(m<0)r-=u,r<s&&(l.push(n[r]),r++);else{l.length>0&&(a.push(hp(bN,e,l)),l=[]),r-=m,u-=m;const f=h.t,p=n.slice(r-u,r);a.push(hp(f,e,p))}}return l.length>0&&a.push(hp(bN,e,l)),a}function hp(t,e,n){const s=n[0].s,r=n[n.length-1].e,a=e.slice(s,r);return new t(a,n)}const b_=typeof console<"u"&&console&&console.warn||(()=>{}),j_="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",lt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function N_(){return Vn.groups={},lt.scanner=null,lt.parser=null,lt.tokenQueue=[],lt.pluginQueue=[],lt.customSchemes=[],lt.initialized=!1,lt}function jN(t,e=!1){if(lt.initialized&&b_(`linkifyjs: already initialized - will not register custom scheme "${t}" ${j_}`),!/^[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`);lt.customSchemes.push([t,e])}function w_(){lt.scanner=p_(lt.customSchemes);for(let t=0;t<lt.tokenQueue.length;t++)lt.tokenQueue[t][1]({scanner:lt.scanner});lt.parser=y_(lt.scanner.tokens);for(let t=0;t<lt.pluginQueue.length;t++)lt.pluginQueue[t][1]({scanner:lt.scanner,parser:lt.parser});return lt.initialized=!0,lt}function M0(t){return lt.initialized||w_(),v_(lt.parser.start,t,h4(lt.scanner.start,t))}M0.scan=h4;function m4(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const s=new D0(n),r=M0(t),a=[];for(let l=0;l<r.length;l++){const o=r[l];o.isLink&&(!e||o.t===e)&&s.check(o)&&a.push(o.toFormattedObject(s))}return a}var T0="[\0-   -\u2029 ]",k_=new RegExp(T0),S_=new RegExp(`${T0}$`),C_=new RegExp(T0,"g");function E_(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function A_(t){return new Nt({key:new Ht("autolink"),appendTransaction:(e,n,s)=>{const r=e.some(d=>d.docChanged)&&!n.doc.eq(s.doc),a=e.some(d=>d.getMeta("preventAutolink"));if(!r||a)return;const{tr:l}=s,o=CE(n.doc,[...e]);if(IE(o).forEach(({newRange:d})=>{const u=Nz(s.doc,d,f=>f.isTextblock);let h,m;if(u.length>1)h=u[0],m=s.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(u.length){const f=s.doc.textBetween(d.from,d.to," "," ");if(!S_.test(f))return;h=u[0],m=s.doc.textBetween(h.pos,d.to,void 0," ")}if(h&&m){const f=m.split(k_).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],g=h.pos+m.lastIndexOf(p);if(!p)return!1;const x=M0(p).map(y=>y.toObject(t.defaultProtocol));if(!E_(x))return!1;x.filter(y=>y.isLink).map(y=>({...y,from:g+y.start+1,to:g+y.end+1})).filter(y=>s.schema.marks.code?!s.doc.rangeHasMark(y.from,y.to,s.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{x0(y.from,y.to,s.doc).some(v=>v.mark.type===t.type)||l.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!l.steps.length)return l}})}function D_(t){return new Nt({key:new Ht("handleClickLink"),props:{handleClick:(e,n,s)=>{var r,a;if(s.button!==0||!e.editable)return!1;let l=null;if(s.target instanceof HTMLAnchorElement)l=s.target;else{const c=s.target;if(!c)return!1;const d=t.editor.view.dom;l=c.closest("a"),l&&!d.contains(l)&&(l=null)}if(!l)return!1;let o=!1;if(t.enableClickSelection&&(o=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const c=PE(e.state,t.type.name),d=(r=l.href)!=null?r:c.href,u=(a=l.target)!=null?a:c.target;d&&(window.open(d,u),o=!0)}return o}}})}function M_(t){return new Nt({key:new Ht("handlePasteLink"),props:{handlePaste:(e,n,s)=>{const{shouldAutoLink:r}=t,{state:a}=e,{selection:l}=a,{empty:o}=l;if(o)return!1;let c="";s.content.forEach(u=>{c+=u.textContent});const d=m4(c,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===c);return!c||!d||r!==void 0&&!r(d.value)?!1:t.editor.commands.setMark(t.type,{href:d.href})}}})}function Yi(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(s=>{const r=typeof s=="string"?s:s.scheme;r&&n.push(r)}),!t||t.replace(C_,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var p4=Ja.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){jN(t);return}jN(t.scheme,t.optionalSlashes)})},onDestroy(){N_()},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)=>!!Yi(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const r=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Yi(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Yi(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",_t(this.options.HTMLAttributes,t),0]:["a",_t(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,s,r,a;const l=(s=(n=t.attrs)==null?void 0:n.href)!=null?s:"",o=(a=(r=t.attrs)==null?void 0:r.title)!=null?a:"",c=e.renderChildren(t);return o?`[${c}](${l} "${o}")`:`[${c}](${l})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:s=>!!Yi(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:s=>!!Yi(s,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[qa({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:s}=this.options,r=m4(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:l=>!!Yi(l,n),protocols:n,defaultProtocol:s}));r.length&&r.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(A_({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:s=>this.options.isAllowedUri(s,{defaultValidate:r=>!!Yi(r,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(D_({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(M_({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),T_=p4,P_=Object.defineProperty,I_=(t,e)=>{for(var n in e)P_(t,n,{get:e[n],enumerable:!0})},R_="listItem",NN="textStyle",wN=/^\s*([-+*])\s$/,g4=hs.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",_t(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(R_,this.editor.getAttributes(NN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=co({find:wN,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=co({find:wN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(NN),editor:this.editor})),[t]}}),x4=hs.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",_t(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(r=>r.type==="paragraph"))n=e.parseChildren(t.tokens);else{const r=t.tokens[0];if(r&&r.type==="text"&&r.tokens&&r.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(r.tokens)}],t.tokens.length>1){const l=t.tokens.slice(1),o=e.parseChildren(l);n.push(...o)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>j0(t,e,s=>{var r,a;return s.parentType==="bulletList"?"- ":s.parentType==="orderedList"?`${(((a=(r=s.meta)==null?void 0:r.parentAttrs)==null?void 0:a.start)||1)+s.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),O_={};I_(O_,{findListItemPos:()=>Ed,getNextListDepth:()=>P0,handleBackspace:()=>jx,handleDelete:()=>Nx,hasListBefore:()=>y4,hasListItemAfter:()=>L_,hasListItemBefore:()=>v4,listItemHasSubList:()=>b4,nextListIsDeeper:()=>j4,nextListIsHigher:()=>N4});var Ed=(t,e)=>{const{$from:n}=e.selection,s=Bt(t,e.schema);let r=null,a=n.depth,l=n.pos,o=null;for(;a>0&&o===null;)r=n.node(a),r.type===s?o=a:(a-=1,l-=1);return o===null?null:{$pos:e.doc.resolve(l),depth:o}},P0=(t,e)=>{const n=Ed(t,e);if(!n)return!1;const[,s]=Pz(e,t,n.$pos.pos+4);return s},y4=(t,e,n)=>{const{$anchor:s}=t.selection,r=Math.max(0,s.pos-2),a=t.doc.resolve(r).node();return!(!a||!n.includes(a.type.name))},v4=(t,e)=>{var n;const{$anchor:s}=e.selection,r=e.doc.resolve(s.pos-2);return!(r.index()===0||((n=r.nodeBefore)==null?void 0:n.type.name)!==t)},b4=(t,e,n)=>{if(!n)return!1;const s=Bt(t,e.schema);let r=!1;return n.descendants(a=>{a.type===s&&(r=!0)}),r},jx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ki(t.state,e)&&y4(t.state,e,n)){const{$anchor:o}=t.state.selection,c=t.state.doc.resolve(o.before()-1),d=[];c.node().descendants((m,f)=>{m.type.name===e&&d.push({node:m,pos:f})});const u=d.at(-1);if(!u)return!1;const h=t.state.doc.resolve(c.start()+u.pos+1);return t.chain().cut({from:o.start()-1,to:o.end()+1},h.end()).joinForward().run()}if(!Ki(t.state,e)||!Lz(t.state))return!1;const s=Ed(e,t.state);if(!s)return!1;const a=t.state.doc.resolve(s.$pos.pos-2).node(s.depth),l=b4(e,t.state,a);return v4(e,t.state)&&!l?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},j4=(t,e)=>{const n=P0(t,e),s=Ed(t,e);return!s||!n?!1:n>s.depth},N4=(t,e)=>{const n=P0(t,e),s=Ed(t,e);return!s||!n?!1:n<s.depth},Nx=(t,e)=>{if(!Ki(t.state,e)||!Oz(t.state,e))return!1;const{selection:n}=t.state,{$from:s,$to:r}=n;return!n.empty&&s.sameParent(r)?!1:j4(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():N4(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},L_=(t,e)=>{var n;const{$anchor:s}=e.selection,r=e.doc.resolve(s.pos-s.parentOffset-2);return!(r.index()===r.parent.childCount-1||((n=r.nodeAfter)==null?void 0:n.type.name)!==t)},w4=It.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Nx(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Nx(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&jx(t,n,s)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&jx(t,n,s)&&(e=!0)}),e}}}}),kN=/^(\s*)(\d+)\.\s+(.*)$/,F_=/^\s/;function z_(t){const e=[];let n=0,s=0;for(;n<t.length;){const r=t[n],a=r.match(kN);if(!a)break;const[,l,o,c]=a,d=l.length;let u=c,h=n+1;const m=[r];for(;h<t.length;){const f=t[h];if(f.match(kN))break;if(f.trim()==="")m.push(f),u+=`
`,h+=1;else if(f.match(F_))m.push(f),u+=`
${f.slice(d+2)}`,h+=1;else break}e.push({indent:d,number:parseInt(o,10),content:u.trim(),raw:m.join(`
`)}),s=h,n=h}return[e,s]}function k4(t,e,n){var s;const r=[];let a=0;for(;a<t.length;){const l=t[a];if(l.indent===e){const o=l.content.split(`
`),c=((s=o[0])==null?void 0:s.trim())||"",d=[];c&&d.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const u=o.slice(1).join(`
`).trim();if(u){const f=n.blockTokens(u);d.push(...f)}let h=a+1;const m=[];for(;h<t.length&&t[h].indent>e;)m.push(t[h]),h+=1;if(m.length>0){const f=Math.min(...m.map(g=>g.indent)),p=k4(m,f,n);d.push({type:"list",ordered:!0,start:m[0].number,items:p,raw:m.map(g=>g.raw).join(`
`)})}r.push({type:"list_item",raw:l.raw,tokens:d}),a=h}else a+=1}return r}function $_(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const s=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(r=>{if(r.type==="paragraph"||r.type==="list"||r.type==="blockquote"||r.type==="code")s.push(...e.parseChildren([r]));else if(r.type==="text"&&r.tokens){const a=e.parseChildren([r]);s.push({type:"paragraph",content:a})}else{const a=e.parseChildren([r]);a.length>0&&s.push(...a)}}),{type:"listItem",content:s}})}var B_="listItem",SN="textStyle",CN=/^(\d+)\.\s$/,S4=hs.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",_t(this.options.HTMLAttributes,n),0]:["ol",_t(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,s=t.items?$_(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:s}:{type:"orderedList",content:s}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var s;const r=t.split(`
`),[a,l]=z_(r);if(a.length===0)return;const o=k4(a,0,n);return o.length===0?void 0:{type:"list",ordered:!0,start:((s=a[0])==null?void 0:s.number)||1,items:o,raw:r.slice(0,l).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(B_,this.editor.getAttributes(SN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=co({find:CN,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=co({find:CN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(SN)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),__=/^\s*(\[([( |x])?\])\s$/,V_=hs.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",_t(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const s=e.parseChildren(t.nestedTokens);n.push(...s)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const r=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return j0(t,e,r)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:s})=>{const r=document.createElement("li"),a=document.createElement("label"),l=document.createElement("span"),o=document.createElement("input"),c=document.createElement("div"),d=h=>{var m,f;o.ariaLabel=((f=(m=this.options.a11y)==null?void 0:m.checkboxLabel)==null?void 0:f.call(m,h,o.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};d(t),a.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",h=>h.preventDefault()),o.addEventListener("change",h=>{if(!s.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:m}=h.target;s.isEditable&&typeof n=="function"&&s.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const p=n();if(typeof p!="number")return!1;const g=f.doc.nodeAt(p);return f.setNodeMarkup(p,void 0,{...g==null?void 0:g.attrs,checked:m}),!0}).run(),!s.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,m)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([h,m])=>{r.setAttribute(h,m)}),r.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,a.append(o,l),r.append(a,c),Object.entries(e).forEach(([h,m])=>{r.setAttribute(h,m)});let u=new Set(Object.keys(e));return{dom:r,contentDOM:c,update:h=>{if(h.type!==this.type)return!1;r.dataset.checked=h.attrs.checked,o.checked=h.attrs.checked,d(h);const m=s.extensionManager.attributes,f=Zc(h,m),p=new Set(Object.keys(f)),g=this.options.HTMLAttributes;return u.forEach(x=>{p.has(x)||(x in g?r.setAttribute(x,g[x]):r.removeAttribute(x))}),Object.entries(f).forEach(([x,y])=>{y==null?x in g?r.setAttribute(x,g[x]):r.removeAttribute(x):r.setAttribute(x,y)}),u=p,!0}}}},addInputRules(){return[co({find:__,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),K_=hs.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",_t(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const s=a=>{const l=ux(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,c)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:c}),customNestedParser:s},n);return l?[{type:"taskList",raw:l.raw,items:l.items}]:n.blockTokens(a)},r=ux(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:s},n);if(r)return{type:"taskList",raw:r.raw,items:r.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()}}});It.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(g4.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(x4.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(w4.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(S4.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(V_.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(K_.configure(this.options.taskList)),t}});var EN="&nbsp;",U_=" ",q_=hs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",_t(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const s=e.parseInline(n);return s.length===1&&s[0].type==="text"&&(s[0].text===EN||s[0].text===U_)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,s)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?EN:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),H_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,W_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Q_=Ja.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",_t(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[oo({find:H_,type:this.type})]},addPasteRules(){return[qa({find:W_,type:this.type})]}}),G_=hs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),J_=Ja.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",_t(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!r)return;const a=r[2].trim();return{type:"underline",raw:r[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function Z_(t={}){return new Nt({view(e){return new Y_(e,t)}})}class Y_{constructor(e,n){var s;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(s=n.width)!==null&&s!==void 0?s:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let a=l=>{this[r](l)};return e.dom.addEventListener(r,a),{name:r,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,s,r=this.editorView.dom,a=r.getBoundingClientRect(),l=a.width/r.offsetWidth,o=a.height/r.offsetHeight;if(n){let h=e.nodeBefore,m=e.nodeAfter;if(h||m){let f=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(f){let p=f.getBoundingClientRect(),g=h?p.bottom:p.top;h&&m&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let x=this.width/2*o;s={left:p.left,right:p.right,top:g-x,bottom:g+x}}}}if(!s){let h=this.editorView.coordsAtPos(this.cursorPos),m=this.width/2*l;s={left:h.left-m,right:h.left+m,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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let h=c.getBoundingClientRect(),m=h.width/c.offsetWidth,f=h.height/c.offsetHeight;d=h.left-c.scrollLeft*m,u=h.top-c.scrollTop*f}this.element.style.left=(s.left-d)/l+"px",this.element.style.top=(s.top-u)/o+"px",this.element.style.width=(s.right-s.left)/l+"px",this.element.style.height=(s.bottom-s.top)/o+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),s=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),r=s&&s.type.spec.disableDropCursor,a=typeof r=="function"?r(this.editorView,n,e):r;if(n&&!a){let l=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let o=x2(this.editorView.state.doc,l,this.editorView.dragging.slice);o!=null&&(l=o)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Dt extends Ie{constructor(e){super(e,e)}map(e,n){let s=e.resolve(n.map(this.head));return Dt.valid(s)?new Dt(s):Ie.near(s)}content(){return me.empty}eq(e){return e instanceof Dt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Dt(e.resolve(n.pos))}getBookmark(){return new I0(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!X_(e)||!eV(e))return!1;let s=n.type.spec.allowGapCursor;if(s!=null)return s;let r=n.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,n,s=!1){e:for(;;){if(!s&&Dt.valid(e))return e;let r=e.pos,a=null;for(let l=e.depth;;l--){let o=e.node(l);if(n>0?e.indexAfter(l)<o.childCount:e.index(l)>0){a=o.child(n>0?e.indexAfter(l):e.index(l)-1);break}else if(l==0)return null;r+=n;let c=e.doc.resolve(r);if(Dt.valid(c))return c}for(;;){let l=n>0?a.firstChild:a.lastChild;if(!l){if(a.isAtom&&!a.isText&&!ke.isSelectable(a)){e=e.doc.resolve(r+a.nodeSize*n),s=!1;continue e}break}a=l,r+=n;let o=e.doc.resolve(r);if(Dt.valid(o))return o}return null}}}Dt.prototype.visible=!1;Dt.findFrom=Dt.findGapCursorFrom;Ie.jsonID("gapcursor",Dt);class I0{constructor(e){this.pos=e}map(e){return new I0(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Dt.valid(n)?new Dt(n):Ie.near(n)}}function C4(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function X_(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),s=t.node(e);if(n==0){if(s.type.spec.isolating)return!0;continue}for(let r=s.child(n-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||C4(r.type))return!0;if(r.inlineContent)return!1}}return!0}function eV(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),s=t.node(e);if(n==s.childCount){if(s.type.spec.isolating)return!0;continue}for(let r=s.child(n);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||C4(r.type))return!0;if(r.inlineContent)return!1}}return!0}function tV(){return new Nt({props:{decorations:iV,createSelectionBetween(t,e,n){return e.pos==n.pos&&Dt.valid(n)?new Dt(n):null},handleClick:sV,handleKeyDown:nV,handleDOMEvents:{beforeinput:rV}}})}const nV=yE({ArrowLeft:cu("horiz",-1),ArrowRight:cu("horiz",1),ArrowUp:cu("vert",-1),ArrowDown:cu("vert",1)});function cu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(s,r,a){let l=s.selection,o=e>0?l.$to:l.$from,c=l.empty;if(l instanceof De){if(!a.endOfTextblock(n)||o.depth==0)return!1;c=!1,o=s.doc.resolve(e>0?o.after():o.before())}let d=Dt.findGapCursorFrom(o,e,c);return d?(r&&r(s.tr.setSelection(new Dt(d))),!0):!1}}function sV(t,e,n){if(!t||!t.editable)return!1;let s=t.state.doc.resolve(e);if(!Dt.valid(s))return!1;let r=t.posAtCoords({left:n.clientX,top:n.clientY});return r&&r.inside>-1&&ke.isSelectable(t.state.doc.nodeAt(r.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Dt(s))),!0)}function rV(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Dt))return!1;let{$from:n}=t.state.selection,s=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!s)return!1;let r=X.empty;for(let l=s.length-1;l>=0;l--)r=X.from(s[l].createAndFill(null,r));let a=t.state.tr.replace(n.pos,n.pos,new me(r,0,0));return a.setSelection(De.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function iV(t){if(!(t.selection instanceof Dt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",yt.create(t.doc,[An.widget(t.selection.head,e,{key:"gapcursor"})])}var rf=200,tn=function(){};tn.prototype.append=function(e){return e.length?(e=tn.from(e),!this.length&&e||e.length<rf&&this.leafAppend(e)||this.length<rf&&e.leafPrepend(this)||this.appendInner(e)):this};tn.prototype.prepend=function(e){return e.length?tn.from(e).append(this):this};tn.prototype.appendInner=function(e){return new aV(this,e)};tn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?tn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};tn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};tn.prototype.forEach=function(e,n,s){n===void 0&&(n=0),s===void 0&&(s=this.length),n<=s?this.forEachInner(e,n,s,0):this.forEachInvertedInner(e,n,s,0)};tn.prototype.map=function(e,n,s){n===void 0&&(n=0),s===void 0&&(s=this.length);var r=[];return this.forEach(function(a,l){return r.push(e(a,l))},n,s),r};tn.from=function(e){return e instanceof tn?e:e&&e.length?new E4(e):tn.empty};var E4=function(t){function e(s){t.call(this),this.values=s}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,a){return r==0&&a==this.length?this:new e(this.values.slice(r,a))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,a,l,o){for(var c=a;c<l;c++)if(r(this.values[c],o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,a,l,o){for(var c=a-1;c>=l;c--)if(r(this.values[c],o+c)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=rf)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=rf)return new e(r.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(tn);tn.empty=new E4([]);var aV=function(t){function e(n,s){t.call(this),this.left=n,this.right=s,this.length=n.length+s.length,this.depth=Math.max(n.depth,s.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(s){return s<this.left.length?this.left.get(s):this.right.get(s-this.left.length)},e.prototype.forEachInner=function(s,r,a,l){var o=this.left.length;if(r<o&&this.left.forEachInner(s,r,Math.min(a,o),l)===!1||a>o&&this.right.forEachInner(s,Math.max(r-o,0),Math.min(this.length,a)-o,l+o)===!1)return!1},e.prototype.forEachInvertedInner=function(s,r,a,l){var o=this.left.length;if(r>o&&this.right.forEachInvertedInner(s,r-o,Math.max(a,o)-o,l+o)===!1||a<o&&this.left.forEachInvertedInner(s,Math.min(r,o),a,l)===!1)return!1},e.prototype.sliceInner=function(s,r){if(s==0&&r==this.length)return this;var a=this.left.length;return r<=a?this.left.slice(s,r):s>=a?this.right.slice(s-a,r-a):this.left.slice(s,a).append(this.right.slice(0,r-a))},e.prototype.leafAppend=function(s){var r=this.right.leafAppend(s);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(s){var r=this.left.leafPrepend(s);if(r)return new e(r,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e}(tn);const lV=500;class Ls{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let r,a;n&&(r=this.remapping(s,this.items.length),a=r.maps.length);let l=e.tr,o,c,d=[],u=[];return this.items.forEach((h,m)=>{if(!h.step){r||(r=this.remapping(s,m+1),a=r.maps.length),a--,u.push(h);return}if(r){u.push(new Zs(h.map));let f=h.step.map(r.slice(a)),p;f&&l.maybeStep(f).doc&&(p=l.mapping.maps[l.mapping.maps.length-1],d.push(new Zs(p,void 0,void 0,d.length+u.length))),a--,p&&r.appendMap(p,a)}else l.maybeStep(h.step);if(h.selection)return o=r?h.selection.map(r.slice(a)):h.selection,c=new Ls(this.items.slice(0,s).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:l,selection:o}}addTransform(e,n,s,r){let a=[],l=this.eventCount,o=this.items,c=!r&&o.length?o.get(o.length-1):null;for(let u=0;u<e.steps.length;u++){let h=e.steps[u].invert(e.docs[u]),m=new Zs(e.mapping.maps[u],h,n),f;(f=c&&c.merge(m))&&(m=f,u?a.pop():o=o.slice(0,o.length-1)),a.push(m),n&&(l++,n=void 0),r||(c=m)}let d=l-s.depth;return d>cV&&(o=oV(o,d),l-=d),new Ls(o.append(a),l)}remapping(e,n){let s=new qc;return this.items.forEach((r,a)=>{let l=r.mirrorOffset!=null&&a-r.mirrorOffset>=e?s.maps.length-r.mirrorOffset:void 0;s.appendMap(r.map,l)},e,n),s}addMaps(e){return this.eventCount==0?this:new Ls(this.items.append(e.map(n=>new Zs(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let s=[],r=Math.max(0,this.items.length-n),a=e.mapping,l=e.steps.length,o=this.eventCount;this.items.forEach(m=>{m.selection&&o--},r);let c=n;this.items.forEach(m=>{let f=a.getMirror(--c);if(f==null)return;l=Math.min(l,f);let p=a.maps[f];if(m.step){let g=e.steps[f].invert(e.docs[f]),x=m.selection&&m.selection.map(a.slice(c+1,f));x&&o++,s.push(new Zs(p,g,x))}else s.push(new Zs(p))},r);let d=[];for(let m=n;m<l;m++)d.push(new Zs(a.maps[m]));let u=this.items.slice(0,r).append(d).append(s),h=new Ls(u,o);return h.emptyItemCount()>lV&&(h=h.compress(this.items.length-s.length)),h}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),s=n.maps.length,r=[],a=0;return this.items.forEach((l,o)=>{if(o>=e)r.push(l),l.selection&&a++;else if(l.step){let c=l.step.map(n.slice(s)),d=c&&c.getMap();if(s--,d&&n.appendMap(d,s),c){let u=l.selection&&l.selection.map(n.slice(s));u&&a++;let h=new Zs(d.invert(),c,u),m,f=r.length-1;(m=r.length&&r[f].merge(h))?r[f]=m:r.push(h)}}else l.map&&s--},this.items.length,0),new Ls(tn.from(r.reverse()),a)}}Ls.empty=new Ls(tn.empty,0);function oV(t,e){let n;return t.forEach((s,r)=>{if(s.selection&&e--==0)return n=r,!1}),t.slice(n)}class Zs{constructor(e,n,s,r){this.map=e,this.step=n,this.selection=s,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Zs(n.getMap().invert(),n,this.selection)}}}class ni{constructor(e,n,s,r,a){this.done=e,this.undone=n,this.prevRanges=s,this.prevTime=r,this.prevComposition=a}}const cV=20;function dV(t,e,n,s){let r=n.getMeta(Ta),a;if(r)return r.historyState;n.getMeta(fV)&&(t=new ni(t.done,t.undone,null,0,-1));let l=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(l&&l.getMeta(Ta))return l.getMeta(Ta).redo?new ni(t.done.addTransform(n,void 0,s,Pu(e)),t.undone,AN(n.mapping.maps),t.prevTime,t.prevComposition):new ni(t.done,t.undone.addTransform(n,void 0,s,Pu(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let o=n.getMeta("composition"),c=t.prevTime==0||!l&&t.prevComposition!=o&&(t.prevTime<(n.time||0)-s.newGroupDelay||!uV(n,t.prevRanges)),d=l?fp(t.prevRanges,n.mapping):AN(n.mapping.maps);return new ni(t.done.addTransform(n,c?e.selection.getBookmark():void 0,s,Pu(e)),Ls.empty,d,n.time,o??t.prevComposition)}else return(a=n.getMeta("rebased"))?new ni(t.done.rebased(n,a),t.undone.rebased(n,a),fp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ni(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),fp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function uV(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((s,r)=>{for(let a=0;a<e.length;a+=2)s<=e[a+1]&&r>=e[a]&&(n=!0)}),n}function AN(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((s,r,a,l)=>e.push(a,l));return e}function fp(t,e){if(!t)return null;let n=[];for(let s=0;s<t.length;s+=2){let r=e.map(t[s],1),a=e.map(t[s+1],-1);r<=a&&n.push(r,a)}return n}function hV(t,e,n){let s=Pu(e),r=Ta.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,s);if(!a)return null;let l=a.selection.resolve(a.transform.doc),o=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),r,s),c=new ni(n?o:a.remaining,n?a.remaining:o,null,0,-1);return a.transform.setSelection(l).setMeta(Ta,{redo:n,historyState:c})}let mp=!1,DN=null;function Pu(t){let e=t.plugins;if(DN!=e){mp=!1,DN=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){mp=!0;break}}return mp}const Ta=new Ht("history"),fV=new Ht("closeHistory");function mV(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Nt({key:Ta,state:{init(){return new ni(Ls.empty,Ls.empty,null,0,-1)},apply(e,n,s){return dV(n,s,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let s=n.inputType,r=s=="historyUndo"?D4:s=="historyRedo"?M4:null;return!r||!e.editable?!1:(n.preventDefault(),r(e.state,e.dispatch))}}}})}function A4(t,e){return(n,s)=>{let r=Ta.getState(n);if(!r||(t?r.undone:r.done).eventCount==0)return!1;if(s){let a=hV(r,n,t);a&&s(e?a.scrollIntoView():a)}return!0}}const D4=A4(!1,!0),M4=A4(!0,!0);It.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const s=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(s)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Nt({key:new Ht("characterCount"),appendTransaction:(e,n,s)=>{if(t)return;const r=this.options.limit;if(r==null||r===0){t=!0;return}const a=this.storage.characters({node:s.doc});if(a>r){const l=a-r,o=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`);const d=s.tr.deleteRange(o,c);return t=!0,d}t=!0},filterTransaction:(e,n)=>{const s=this.options.limit;if(!e.docChanged||s===0||s===null||s===void 0)return!0;const r=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=s||r>s&&a>s&&a<=r)return!0;if(r>s&&a>s&&a>r||!e.getMeta("paste"))return!1;const o=e.selection.$head.pos,c=a-s,d=o-c,u=o;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>s)}})]}});var pV=It.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Z_(this.options)]}});It.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Nt({key:new Ht("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:s}=this.editor,{anchor:r}=e,a=[];if(!n||!s)return yt.create(t,[]);let l=0;this.options.mode==="deepest"&&t.descendants((c,d)=>{if(c.isText)return;if(!(r>=d&&r<=d+c.nodeSize-1))return!1;l+=1});let o=0;return t.descendants((c,d)=>{if(c.isText||!(r>=d&&r<=d+c.nodeSize-1))return!1;if(o+=1,this.options.mode==="deepest"&&l-o>0||this.options.mode==="shallowest"&&o>1)return this.options.mode==="deepest";a.push(An.node(d,d+c.nodeSize,{class:this.options.className}))}),yt.create(t,a)}}})]}});var gV=It.create({name:"gapCursor",addProseMirrorPlugins(){return[tV()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ze(we(t,"allowGapCursor",n)))!=null?e:null}}}),MN="placeholder";function xV(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}It.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:MN,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${xV(this.options.dataAttribute)}`:`data-${MN}`;return[new Nt({key:new Ht("placeholder"),props:{decorations:({doc:e,selection:n})=>{const s=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=n,a=[];if(!s)return null;const l=this.editor.isEmpty;return e.descendants((o,c)=>{const d=r>=c&&r<=c+o.nodeSize,u=!o.isLeaf&&Qf(o);if((d||!this.options.showOnlyCurrent)&&u){const h=[this.options.emptyNodeClass];l&&h.push(this.options.emptyEditorClass);const m=An.node(c,c+o.nodeSize,{class:h.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:c,hasAnchor:d}):this.options.placeholder});a.push(m)}return this.options.includeChildren}),yt.create(e,a)}}})]}});It.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Nt({key:new Ht("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||RE(n.selection)||t.view.dragging?null:yt.create(n.doc,[An.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function TN({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var yV=It.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ht(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",s=Object.entries(this.editor.schema.nodes).map(([,r])=>r).filter(r=>(this.options.notAfter||[]).concat(n).includes(r.name));return[new Nt({key:e,appendTransaction:(r,a,l)=>{const{doc:o,tr:c,schema:d}=l,u=e.getState(l),h=o.content.size,m=d.nodes[n];if(u)return c.insert(h,m.create())},state:{init:(r,a)=>{const l=a.tr.doc.lastChild;return!TN({node:l,types:s})},apply:(r,a)=>{if(!r.docChanged||r.getMeta("__uniqueIDTransaction"))return a;const l=r.doc.lastChild;return!TN({node:l,types:s})}}})]}}),vV=It.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>D4(t,e),redo:()=>({state:t,dispatch:e})=>M4(t,e)}},addProseMirrorPlugins(){return[mV(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()}}}),bV=It.create({name:"starterKit",addExtensions(){var t,e,n,s;const r=[];return this.options.bold!==!1&&r.push(qB.configure(this.options.bold)),this.options.blockquote!==!1&&r.push(BB.configure(this.options.blockquote)),this.options.bulletList!==!1&&r.push(g4.configure(this.options.bulletList)),this.options.code!==!1&&r.push(QB.configure(this.options.code)),this.options.codeBlock!==!1&&r.push(ZB.configure(this.options.codeBlock)),this.options.document!==!1&&r.push(YB.configure(this.options.document)),this.options.dropcursor!==!1&&r.push(pV.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&r.push(gV.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&r.push(XB.configure(this.options.hardBreak)),this.options.heading!==!1&&r.push(e_.configure(this.options.heading)),this.options.undoRedo!==!1&&r.push(vV.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&r.push(t_.configure(this.options.horizontalRule)),this.options.italic!==!1&&r.push(a_.configure(this.options.italic)),this.options.listItem!==!1&&r.push(x4.configure(this.options.listItem)),this.options.listKeymap!==!1&&r.push(w4.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&r.push(p4.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&r.push(S4.configure(this.options.orderedList)),this.options.paragraph!==!1&&r.push(q_.configure(this.options.paragraph)),this.options.strike!==!1&&r.push(Q_.configure(this.options.strike)),this.options.text!==!1&&r.push(G_.configure(this.options.text)),this.options.underline!==!1&&r.push(J_.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&r.push(yV.configure((s=this.options)==null?void 0:s.trailingNode)),r}}),jV=bV;const NV=[{key:"{{vorname}}",label:"Vorname"},{key:"{{nachname}}",label:"Nachname"},{key:"{{kundennummer}}",label:"Kundennummer"},{key:"{{anrede}}",label:"Anrede"},{key:"{{email}}",label:"E-Mail"},{key:"{{datum}}",label:"Aktuelles Datum"}];function wV({editor:t}){if(!t)return null;const e=N.useCallback(()=>{const s=t.getAttributes("link").href,r=window.prompt("URL eingeben:",s);if(r!==null){if(r===""){t.chain().focus().extendMarkRange("link").unsetLink().run();return}t.chain().focus().extendMarkRange("link").setLink({href:r}).run()}},[t]),n=s=>`p-1.5 rounded hover:bg-gray-200 transition-colors ${s?"bg-gray-200 text-blue-600":"text-gray-600"}`;return i.jsxs("div",{className:"flex flex-wrap items-center gap-1 p-2 border-b bg-gray-50",children:[i.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),className:n(t.isActive("bold")),title:"Fett",children:i.jsx(h5,{className:"w-4 h-4"})}),i.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),className:n(t.isActive("italic")),title:"Kursiv",children:i.jsx(C5,{className:"w-4 h-4"})}),i.jsx("div",{className:"w-px h-5 bg-gray-300 mx-1"}),i.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),className:n(t.isActive("heading",{level:1})),title:"Überschrift 1",children:i.jsx(N5,{className:"w-4 h-4"})}),i.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),className:n(t.isActive("heading",{level:2})),title:"Überschrift 2",children:i.jsx(w5,{className:"w-4 h-4"})}),i.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),className:n(t.isActive("heading",{level:3})),title:"Überschrift 3",children:i.jsx(k5,{className:"w-4 h-4"})}),i.jsx("button",{type:"button",onClick:()=>t.chain().focus().setParagraph().run(),className:n(t.isActive("paragraph")),title:"Absatz",children:i.jsx(_5,{className:"w-4 h-4"})}),i.jsx("div",{className:"w-px h-5 bg-gray-300 mx-1"}),i.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBulletList().run(),className:n(t.isActive("bulletList")),title:"Aufzählung",children:i.jsx(T5,{className:"w-4 h-4"})}),i.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleOrderedList().run(),className:n(t.isActive("orderedList")),title:"Nummerierung",children:i.jsx(M5,{className:"w-4 h-4"})}),i.jsx("div",{className:"w-px h-5 bg-gray-300 mx-1"}),i.jsx("button",{type:"button",onClick:e,className:n(t.isActive("link")),title:"Link",children:i.jsx(D5,{className:"w-4 h-4"})}),i.jsx("div",{className:"w-px h-5 bg-gray-300 mx-1"}),i.jsx("button",{type:"button",onClick:()=>t.chain().focus().undo().run(),disabled:!t.can().undo(),className:"p-1.5 rounded hover:bg-gray-200 text-gray-600 disabled:opacity-30",title:"Rückgängig",children:i.jsx(V5,{className:"w-4 h-4"})}),i.jsx("button",{type:"button",onClick:()=>t.chain().focus().redo().run(),disabled:!t.can().redo(),className:"p-1.5 rounded hover:bg-gray-200 text-gray-600 disabled:opacity-30",title:"Wiederherstellen",children:i.jsx(F5,{className:"w-4 h-4"})})]})}function kV(){var h,m;const t=ye(),[e,n]=N.useState(!1),[s,r]=N.useState(!1),{data:a,isLoading:l}=fe({queryKey:["privacy-policy"],queryFn:()=>Mr.getPrivacyPolicy()}),o=G({mutationFn:f=>Mr.updatePrivacyPolicy(f),onSuccess:()=>{t.invalidateQueries({queryKey:["privacy-policy"]}),r(!0),setTimeout(()=>r(!1),2e3)}}),c=OB({extensions:[jV,T_.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}})],content:((h=a==null?void 0:a.data)==null?void 0:h.html)||"",editorProps:{attributes:{class:"prose prose-sm max-w-none p-4 min-h-[400px] focus:outline-none"}}},[(m=a==null?void 0:a.data)==null?void 0:m.html]),d=f=>{c&&c.chain().focus().insertContent(f).run()},u=()=>{c&&o.mutate(c.getHTML())};return l?i.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[i.jsx(Me,{to:"/settings",children:i.jsx(I,{variant:"ghost",size:"sm",children:i.jsx(Yn,{className:"w-4 h-4"})})}),i.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Datenschutzerklärung bearbeiten"}),i.jsxs(I,{variant:"secondary",onClick:()=>n(!e),children:[i.jsx(Oe,{className:"w-4 h-4 mr-2"}),e?"Editor":"Vorschau"]}),i.jsxs(I,{onClick:u,disabled:o.isPending,children:[i.jsx(zy,{className:"w-4 h-4 mr-2"}),s?"Gespeichert!":o.isPending?"Speichern...":"Speichern"]})]}),i.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[i.jsx("div",{className:"lg:col-span-3",children:e?i.jsx(Z,{children:i.jsx("div",{className:"prose prose-sm max-w-none p-4",dangerouslySetInnerHTML:{__html:(c==null?void 0:c.getHTML())||""}})}):i.jsxs("div",{className:"border rounded-lg bg-white overflow-hidden",children:[i.jsx(wV,{editor:c}),i.jsx(t4,{editor:c})]})}),i.jsxs("div",{className:"lg:col-span-1",children:[i.jsxs(Z,{title:"Platzhalter",children:[i.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"Klicken Sie auf einen Platzhalter, um ihn an der Cursorposition einzufügen."}),i.jsx("div",{className:"space-y-2",children:NV.map(f=>i.jsxs("button",{onClick:()=>d(f.key),className:"w-full text-left px-3 py-2 text-sm bg-gray-50 border rounded hover:bg-blue-50 hover:border-blue-300 transition-colors",children:[i.jsx("span",{className:"font-mono text-blue-600 text-xs",children:f.key}),i.jsx("br",{}),i.jsx("span",{className:"text-gray-600",children:f.label})]},f.key))})]}),o.isError&&i.jsx("div",{className:"mt-4 p-3 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:"Fehler beim Speichern. Bitte versuchen Sie es erneut."})]})]})]})}function SV({children:t}){const{isAuthenticated:e,isLoading:n}=nt();return n?i.jsx("div",{className:"min-h-screen flex items-center justify-center",children:i.jsx("div",{className:"text-gray-500",children:"Laden..."})}):e?i.jsx(i.Fragment,{children:t}):i.jsx(bl,{to:"/login",replace:!0})}function CV({children:t}){const{hasPermission:e,developerMode:n}=nt();return!e("developer:access")||!n?i.jsx(bl,{to:"/",replace:!0}):i.jsx(i.Fragment,{children:t})}function EV(){const{isAuthenticated:t,isLoading:e}=nt();return e?i.jsx("div",{className:"min-h-screen flex items-center justify-center",children:i.jsx("div",{className:"text-gray-500",children:"Laden..."})}):i.jsxs(i.Fragment,{children:[i.jsx(l5,{}),i.jsxs(ZM,{children:[i.jsx($e,{path:"/datenschutz/:hash",element:i.jsx(pO,{})}),i.jsx($e,{path:"/login",element:t?i.jsx(bl,{to:"/",replace:!0}):i.jsx(J5,{})}),i.jsxs($e,{path:"/",element:i.jsx(SV,{children:i.jsx(G5,{})}),children:[i.jsx($e,{index:!0,element:i.jsx(Z5,{})}),i.jsx($e,{path:"customers",element:i.jsx(X5,{})}),i.jsx($e,{path:"customers/new",element:i.jsx(W1,{})}),i.jsx($e,{path:"customers/:id",element:i.jsx(lR,{})}),i.jsx($e,{path:"customers/:id/edit",element:i.jsx(W1,{})}),i.jsx($e,{path:"contracts",element:i.jsx(WR,{})}),i.jsx($e,{path:"contracts/cockpit",element:i.jsx(A3,{})}),i.jsx($e,{path:"contracts/new",element:i.jsx(X1,{})}),i.jsx($e,{path:"contracts/:id",element:i.jsx(y3,{})}),i.jsx($e,{path:"contracts/:id/edit",element:i.jsx(X1,{})}),i.jsx($e,{path:"tasks",element:i.jsx(M3,{})}),i.jsx($e,{path:"settings",element:i.jsx(hO,{})}),i.jsx($e,{path:"settings/users",element:i.jsx(dO,{})}),i.jsx($e,{path:"settings/platforms",element:i.jsx(R3,{})}),i.jsx($e,{path:"settings/cancellation-periods",element:i.jsx(L3,{})}),i.jsx($e,{path:"settings/contract-durations",element:i.jsx(z3,{})}),i.jsx($e,{path:"settings/providers",element:i.jsx(B3,{})}),i.jsx($e,{path:"settings/contract-categories",element:i.jsx(H3,{})}),i.jsx($e,{path:"settings/view",element:i.jsx(G3,{})}),i.jsx($e,{path:"settings/portal",element:i.jsx(J3,{})}),i.jsx($e,{path:"settings/deadlines",element:i.jsx(Z3,{})}),i.jsx($e,{path:"settings/email-providers",element:i.jsx(X3,{})}),i.jsx($e,{path:"settings/database-backup",element:i.jsx(eO,{})}),i.jsx($e,{path:"settings/audit-logs",element:i.jsx(iO,{})}),i.jsx($e,{path:"settings/gdpr",element:i.jsx(cO,{})}),i.jsx($e,{path:"settings/privacy-policy",element:i.jsx(kV,{})}),i.jsx($e,{path:"users",element:i.jsx(bl,{to:"/settings/users",replace:!0})}),i.jsx($e,{path:"platforms",element:i.jsx(bl,{to:"/settings/platforms",replace:!0})}),i.jsx($e,{path:"developer/database",element:i.jsx(CV,{children:i.jsx(mO,{})})})]}),i.jsx($e,{path:"*",element:i.jsx(bl,{to:"/",replace:!0})})]})]})}const AV=new LT({defaultOptions:{queries:{retry:1,staleTime:0,gcTime:0,refetchOnMount:"always"}}});pp.createRoot(document.getElementById("root")).render(i.jsx(ut.StrictMode,{children:i.jsx(FT,{client:AV,children:i.jsx(aT,{children:i.jsx(a5,{children:i.jsxs(i5,{children:[i.jsx(EV,{}),i.jsx(DP,{position:"top-right",toastOptions:{duration:4e3,style:{background:"#363636",color:"#fff"},success:{iconTheme:{primary:"#10b981",secondary:"#fff"}},error:{iconTheme:{primary:"#ef4444",secondary:"#fff"}}}})]})})})})}));