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

409 lines
575 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

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 om=e=>{throw TypeError(e)};var Jo=(e,t,s)=>t.has(e)||om("Cannot "+s);var C=(e,t,s)=>(Jo(e,t,"read from private field"),s?s.call(e):t.get(e)),ue=(e,t,s)=>t.has(e)?om("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),te=(e,t,s,r)=>(Jo(e,t,"write to private field"),r?r.call(e,s):t.set(e,s),s),ye=(e,t,s)=>(Jo(e,t,"access private method"),s);var tl=(e,t,s,r)=>({set _(a){te(e,t,a,s)},get _(){return C(e,t,r)}});function hv(e,t){for(var s=0;s<t.length;s++){const r=t[s];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(r,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function s(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(a){if(a.ep)return;a.ep=!0;const i=s(a);fetch(a.href,i)}})();function mv(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _p={exports:{}},jo={},zp={exports:{}},Ne={};/**
* @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 $i=Symbol.for("react.element"),fv=Symbol.for("react.portal"),pv=Symbol.for("react.fragment"),gv=Symbol.for("react.strict_mode"),xv=Symbol.for("react.profiler"),yv=Symbol.for("react.provider"),vv=Symbol.for("react.context"),jv=Symbol.for("react.forward_ref"),bv=Symbol.for("react.suspense"),Nv=Symbol.for("react.memo"),wv=Symbol.for("react.lazy"),cm=Symbol.iterator;function Sv(e){return e===null||typeof e!="object"?null:(e=cm&&e[cm]||e["@@iterator"],typeof e=="function"?e:null)}var Up={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},$p=Object.assign,Bp={};function Sa(e,t,s){this.props=e,this.context=t,this.refs=Bp,this.updater=s||Up}Sa.prototype.isReactComponent={};Sa.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=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,e,t,"setState")};Sa.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Kp(){}Kp.prototype=Sa.prototype;function rd(e,t,s){this.props=e,this.context=t,this.refs=Bp,this.updater=s||Up}var ad=rd.prototype=new Kp;ad.constructor=rd;$p(ad,Sa.prototype);ad.isPureReactComponent=!0;var um=Array.isArray,Vp=Object.prototype.hasOwnProperty,id={current:null},qp={key:!0,ref:!0,__self:!0,__source:!0};function Qp(e,t,s){var r,a={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)Vp.call(t,r)&&!qp.hasOwnProperty(r)&&(a[r]=t[r]);var o=arguments.length-2;if(o===1)a.children=s;else if(1<o){for(var c=Array(o),u=0;u<o;u++)c[u]=arguments[u+2];a.children=c}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)a[r]===void 0&&(a[r]=o[r]);return{$$typeof:$i,type:e,key:i,ref:l,props:a,_owner:id.current}}function kv(e,t){return{$$typeof:$i,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function ld(e){return typeof e=="object"&&e!==null&&e.$$typeof===$i}function Cv(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(s){return t[s]})}var dm=/\/+/g;function Xo(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Cv(""+e.key):t.toString(36)}function Nl(e,t,s,r,a){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var l=!1;if(e===null)l=!0;else switch(i){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case $i:case fv:l=!0}}if(l)return l=e,a=a(l),e=r===""?"."+Xo(l,0):r,um(a)?(s="",e!=null&&(s=e.replace(dm,"$&/")+"/"),Nl(a,t,s,"",function(u){return u})):a!=null&&(ld(a)&&(a=kv(a,s+(!a.key||l&&l.key===a.key?"":(""+a.key).replace(dm,"$&/")+"/")+e)),t.push(a)),1;if(l=0,r=r===""?".":r+":",um(e))for(var o=0;o<e.length;o++){i=e[o];var c=r+Xo(i,o);l+=Nl(i,t,s,c,a)}else if(c=Sv(e),typeof c=="function")for(e=c.call(e),o=0;!(i=e.next()).done;)i=i.value,c=r+Xo(i,o++),l+=Nl(i,t,s,c,a);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return l}function sl(e,t,s){if(e==null)return e;var r=[],a=0;return Nl(e,r,"","",function(i){return t.call(s,i,a++)}),r}function Ev(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(s){(e._status===0||e._status===-1)&&(e._status=1,e._result=s)},function(s){(e._status===0||e._status===-1)&&(e._status=2,e._result=s)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var _t={current:null},wl={transition:null},Dv={ReactCurrentDispatcher:_t,ReactCurrentBatchConfig:wl,ReactCurrentOwner:id};function Hp(){throw Error("act(...) is not supported in production builds of React.")}Ne.Children={map:sl,forEach:function(e,t,s){sl(e,function(){t.apply(this,arguments)},s)},count:function(e){var t=0;return sl(e,function(){t++}),t},toArray:function(e){return sl(e,function(t){return t})||[]},only:function(e){if(!ld(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Ne.Component=Sa;Ne.Fragment=pv;Ne.Profiler=xv;Ne.PureComponent=rd;Ne.StrictMode=gv;Ne.Suspense=bv;Ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Dv;Ne.act=Hp;Ne.cloneElement=function(e,t,s){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=$p({},e.props),a=e.key,i=e.ref,l=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,l=id.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var o=e.type.defaultProps;for(c in t)Vp.call(t,c)&&!qp.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&o!==void 0?o[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=s;else if(1<c){o=Array(c);for(var u=0;u<c;u++)o[u]=arguments[u+2];r.children=o}return{$$typeof:$i,type:e.type,key:a,ref:i,props:r,_owner:l}};Ne.createContext=function(e){return e={$$typeof:vv,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:yv,_context:e},e.Consumer=e};Ne.createElement=Qp;Ne.createFactory=function(e){var t=Qp.bind(null,e);return t.type=e,t};Ne.createRef=function(){return{current:null}};Ne.forwardRef=function(e){return{$$typeof:jv,render:e}};Ne.isValidElement=ld;Ne.lazy=function(e){return{$$typeof:wv,_payload:{_status:-1,_result:e},_init:Ev}};Ne.memo=function(e,t){return{$$typeof:Nv,type:e,compare:t===void 0?null:t}};Ne.startTransition=function(e){var t=wl.transition;wl.transition={};try{e()}finally{wl.transition=t}};Ne.unstable_act=Hp;Ne.useCallback=function(e,t){return _t.current.useCallback(e,t)};Ne.useContext=function(e){return _t.current.useContext(e)};Ne.useDebugValue=function(){};Ne.useDeferredValue=function(e){return _t.current.useDeferredValue(e)};Ne.useEffect=function(e,t){return _t.current.useEffect(e,t)};Ne.useId=function(){return _t.current.useId()};Ne.useImperativeHandle=function(e,t,s){return _t.current.useImperativeHandle(e,t,s)};Ne.useInsertionEffect=function(e,t){return _t.current.useInsertionEffect(e,t)};Ne.useLayoutEffect=function(e,t){return _t.current.useLayoutEffect(e,t)};Ne.useMemo=function(e,t){return _t.current.useMemo(e,t)};Ne.useReducer=function(e,t,s){return _t.current.useReducer(e,t,s)};Ne.useRef=function(e){return _t.current.useRef(e)};Ne.useState=function(e){return _t.current.useState(e)};Ne.useSyncExternalStore=function(e,t,s){return _t.current.useSyncExternalStore(e,t,s)};Ne.useTransition=function(){return _t.current.useTransition()};Ne.version="18.3.1";zp.exports=Ne;var w=zp.exports;const Nt=mv(w),Pv=hv({__proto__:null,default:Nt},[w]);/**
* @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 Av=w,Tv=Symbol.for("react.element"),Fv=Symbol.for("react.fragment"),Iv=Object.prototype.hasOwnProperty,Mv=Av.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Lv={key:!0,ref:!0,__self:!0,__source:!0};function Wp(e,t,s){var r,a={},i=null,l=null;s!==void 0&&(i=""+s),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(l=t.ref);for(r in t)Iv.call(t,r)&&!Lv.hasOwnProperty(r)&&(a[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)a[r]===void 0&&(a[r]=t[r]);return{$$typeof:Tv,type:e,key:i,ref:l,props:a,_owner:Mv.current}}jo.Fragment=Fv;jo.jsx=Wp;jo.jsxs=Wp;_p.exports=jo;var n=_p.exports,Rc={},Gp={exports:{}},as={},Zp={exports:{}},Yp={};/**
* @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(e){function t(B,J){var ee=B.length;B.push(J);e:for(;0<ee;){var me=ee-1>>>1,ve=B[me];if(0<a(ve,J))B[me]=J,B[ee]=ve,ee=me;else break e}}function s(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var J=B[0],ee=B.pop();if(ee!==J){B[0]=ee;e:for(var me=0,ve=B.length,it=ve>>>1;me<it;){var V=2*(me+1)-1,Ce=B[V],Me=V+1,ht=B[Me];if(0>a(Ce,ee))Me<ve&&0>a(ht,Ce)?(B[me]=ht,B[Me]=ee,me=Me):(B[me]=Ce,B[V]=ee,me=V);else if(Me<ve&&0>a(ht,ee))B[me]=ht,B[Me]=ee,me=Me;else break e}}return J}function a(B,J){var ee=B.sortIndex-J.sortIndex;return ee!==0?ee:B.id-J.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],d=1,m=null,p=3,h=!1,f=!1,g=!1,b=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 x(B){for(var J=s(u);J!==null;){if(J.callback===null)r(u);else if(J.startTime<=B)r(u),J.sortIndex=J.expirationTime,t(c,J);else break;J=s(u)}}function N(B){if(g=!1,x(B),!f)if(s(c)!==null)f=!0,P(k);else{var J=s(u);J!==null&&j(N,J.startTime-B)}}function k(B,J){f=!1,g&&(g=!1,y(S),S=-1),h=!0;var ee=p;try{for(x(J),m=s(c);m!==null&&(!(m.expirationTime>J)||B&&!_());){var me=m.callback;if(typeof me=="function"){m.callback=null,p=m.priorityLevel;var ve=me(m.expirationTime<=J);J=e.unstable_now(),typeof ve=="function"?m.callback=ve:m===s(c)&&r(c),x(J)}else r(c);m=s(c)}if(m!==null)var it=!0;else{var V=s(u);V!==null&&j(N,V.startTime-J),it=!1}return it}finally{m=null,p=ee,h=!1}}var D=!1,F=null,S=-1,L=5,T=-1;function _(){return!(e.unstable_now()-T<L)}function K(){if(F!==null){var B=e.unstable_now();T=B;var J=!0;try{J=F(!0,B)}finally{J?W():(D=!1,F=null)}}else D=!1}var W;if(typeof v=="function")W=function(){v(K)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,z=Q.port2;Q.port1.onmessage=K,W=function(){z.postMessage(null)}}else W=function(){b(K,0)};function P(B){F=B,D||(D=!0,W())}function j(B,J){S=b(function(){B(e.unstable_now())},J)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_continueExecution=function(){f||h||(f=!0,P(k))},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return s(c)},e.unstable_next=function(B){switch(p){case 1:case 2:case 3:var J=3;break;default:J=p}var ee=p;p=J;try{return B()}finally{p=ee}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(B,J){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var ee=p;p=B;try{return J()}finally{p=ee}},e.unstable_scheduleCallback=function(B,J,ee){var me=e.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?me+ee:me):ee=me,B){case 1:var ve=-1;break;case 2:ve=250;break;case 5:ve=1073741823;break;case 4:ve=1e4;break;default:ve=5e3}return ve=ee+ve,B={id:d++,callback:J,priorityLevel:B,startTime:ee,expirationTime:ve,sortIndex:-1},ee>me?(B.sortIndex=ee,t(u,B),s(c)===null&&B===s(u)&&(g?(y(S),S=-1):g=!0,j(N,ee-me))):(B.sortIndex=ve,t(c,B),f||h||(f=!0,P(k))),B},e.unstable_shouldYield=_,e.unstable_wrapCallback=function(B){var J=p;return function(){var ee=p;p=J;try{return B.apply(this,arguments)}finally{p=ee}}}})(Yp);Zp.exports=Yp;var Rv=Zp.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 Ov=w,rs=Rv;function q(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,s=1;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Jp=new Set,ci={};function kr(e,t){ma(e,t),ma(e+"Capture",t)}function ma(e,t){for(ci[e]=t,e=0;e<t.length;e++)Jp.add(t[e])}var rn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Oc=Object.prototype.hasOwnProperty,_v=/^[: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]*$/,hm={},mm={};function zv(e){return Oc.call(mm,e)?!0:Oc.call(hm,e)?!1:_v.test(e)?mm[e]=!0:(hm[e]=!0,!1)}function Uv(e,t,s,r){if(s!==null&&s.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:s!==null?!s.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function $v(e,t,s,r){if(t===null||typeof t>"u"||Uv(e,t,s,r))return!0;if(r)return!1;if(s!==null)switch(s.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function zt(e,t,s,r,a,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=a,this.mustUseProperty=s,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var St={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){St[e]=new zt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];St[t]=new zt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){St[e]=new zt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){St[e]=new zt(e,2,!1,e,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(e){St[e]=new zt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){St[e]=new zt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){St[e]=new zt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){St[e]=new zt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){St[e]=new zt(e,5,!1,e.toLowerCase(),null,!1,!1)});var od=/[\-:]([a-z])/g;function cd(e){return e[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(e){var t=e.replace(od,cd);St[t]=new zt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(od,cd);St[t]=new zt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(od,cd);St[t]=new zt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){St[e]=new zt(e,1,!1,e.toLowerCase(),null,!1,!1)});St.xlinkHref=new zt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){St[e]=new zt(e,1,!1,e.toLowerCase(),null,!0,!0)});function ud(e,t,s,r){var a=St.hasOwnProperty(t)?St[t]:null;(a!==null?a.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&($v(t,s,a,r)&&(s=null),r||a===null?zv(t)&&(s===null?e.removeAttribute(t):e.setAttribute(t,""+s)):a.mustUseProperty?e[a.propertyName]=s===null?a.type===3?!1:"":s:(t=a.attributeName,r=a.attributeNamespace,s===null?e.removeAttribute(t):(a=a.type,s=a===3||a===4&&s===!0?"":""+s,r?e.setAttributeNS(r,t,s):e.setAttribute(t,s))))}var cn=Ov.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,nl=Symbol.for("react.element"),Mr=Symbol.for("react.portal"),Lr=Symbol.for("react.fragment"),dd=Symbol.for("react.strict_mode"),_c=Symbol.for("react.profiler"),Xp=Symbol.for("react.provider"),eg=Symbol.for("react.context"),hd=Symbol.for("react.forward_ref"),zc=Symbol.for("react.suspense"),Uc=Symbol.for("react.suspense_list"),md=Symbol.for("react.memo"),pn=Symbol.for("react.lazy"),tg=Symbol.for("react.offscreen"),fm=Symbol.iterator;function La(e){return e===null||typeof e!="object"?null:(e=fm&&e[fm]||e["@@iterator"],typeof e=="function"?e:null)}var He=Object.assign,ec;function qa(e){if(ec===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);ec=t&&t[1]||""}return`
`+ec+e}var tc=!1;function sc(e,t){if(!e||tc)return"";tc=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var a=u.stack.split(`
`),i=r.stack.split(`
`),l=a.length-1,o=i.length-1;1<=l&&0<=o&&a[l]!==i[o];)o--;for(;1<=l&&0<=o;l--,o--)if(a[l]!==i[o]){if(l!==1||o!==1)do if(l--,o--,0>o||a[l]!==i[o]){var c=`
`+a[l].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{tc=!1,Error.prepareStackTrace=s}return(e=e?e.displayName||e.name:"")?qa(e):""}function Bv(e){switch(e.tag){case 5:return qa(e.type);case 16:return qa("Lazy");case 13:return qa("Suspense");case 19:return qa("SuspenseList");case 0:case 2:case 15:return e=sc(e.type,!1),e;case 11:return e=sc(e.type.render,!1),e;case 1:return e=sc(e.type,!0),e;default:return""}}function $c(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Lr:return"Fragment";case Mr:return"Portal";case _c:return"Profiler";case dd:return"StrictMode";case zc:return"Suspense";case Uc:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case eg:return(e.displayName||"Context")+".Consumer";case Xp:return(e._context.displayName||"Context")+".Provider";case hd:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case md:return t=e.displayName||null,t!==null?t:$c(e.type)||"Memo";case pn:t=e._payload,e=e._init;try{return $c(e(t))}catch{}}return null}function Kv(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return $c(t);case 8:return t===dd?"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 t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Kn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function sg(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Vv(e){var t=sg(e)?"checked":"value",s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var a=s.get,i=s.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:s.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function rl(e){e._valueTracker||(e._valueTracker=Vv(e))}function ng(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),r="";return e&&(r=sg(e)?e.checked?"true":"false":e.value),e=r,e!==s?(t.setValue(e),!0):!1}function zl(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Bc(e,t){var s=t.checked;return He({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:s??e._wrapperState.initialChecked})}function pm(e,t){var s=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;s=Kn(t.value!=null?t.value:s),e._wrapperState={initialChecked:r,initialValue:s,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function rg(e,t){t=t.checked,t!=null&&ud(e,"checked",t,!1)}function Kc(e,t){rg(e,t);var s=Kn(t.value),r=t.type;if(s!=null)r==="number"?(s===0&&e.value===""||e.value!=s)&&(e.value=""+s):e.value!==""+s&&(e.value=""+s);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Vc(e,t.type,s):t.hasOwnProperty("defaultValue")&&Vc(e,t.type,Kn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function gm(e,t,s){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,s||t===e.value||(e.value=t),e.defaultValue=t}s=e.name,s!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,s!==""&&(e.name=s)}function Vc(e,t,s){(t!=="number"||zl(e.ownerDocument)!==e)&&(s==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+s&&(e.defaultValue=""+s))}var Qa=Array.isArray;function Hr(e,t,s,r){if(e=e.options,t){t={};for(var a=0;a<s.length;a++)t["$"+s[a]]=!0;for(s=0;s<e.length;s++)a=t.hasOwnProperty("$"+e[s].value),e[s].selected!==a&&(e[s].selected=a),a&&r&&(e[s].defaultSelected=!0)}else{for(s=""+Kn(s),t=null,a=0;a<e.length;a++){if(e[a].value===s){e[a].selected=!0,r&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function qc(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(q(91));return He({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function xm(e,t){var s=t.value;if(s==null){if(s=t.children,t=t.defaultValue,s!=null){if(t!=null)throw Error(q(92));if(Qa(s)){if(1<s.length)throw Error(q(93));s=s[0]}t=s}t==null&&(t=""),s=t}e._wrapperState={initialValue:Kn(s)}}function ag(e,t){var s=Kn(t.value),r=Kn(t.defaultValue);s!=null&&(s=""+s,s!==e.value&&(e.value=s),t.defaultValue==null&&e.defaultValue!==s&&(e.defaultValue=s)),r!=null&&(e.defaultValue=""+r)}function ym(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function ig(e){switch(e){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 Qc(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?ig(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var al,lg=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,s,r,a){MSApp.execUnsafeLocalFunction(function(){return e(t,s,r,a)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(al=al||document.createElement("div"),al.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=al.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function ui(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Ya={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},qv=["Webkit","ms","Moz","O"];Object.keys(Ya).forEach(function(e){qv.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ya[t]=Ya[e]})});function og(e,t,s){return t==null||typeof t=="boolean"||t===""?"":s||typeof t!="number"||t===0||Ya.hasOwnProperty(e)&&Ya[e]?(""+t).trim():t+"px"}function cg(e,t){e=e.style;for(var s in t)if(t.hasOwnProperty(s)){var r=s.indexOf("--")===0,a=og(s,t[s],r);s==="float"&&(s="cssFloat"),r?e.setProperty(s,a):e[s]=a}}var Qv=He({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 Hc(e,t){if(t){if(Qv[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(q(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(q(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(q(61))}if(t.style!=null&&typeof t.style!="object")throw Error(q(62))}}function Wc(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){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 Gc=null;function fd(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zc=null,Wr=null,Gr=null;function vm(e){if(e=Vi(e)){if(typeof Zc!="function")throw Error(q(280));var t=e.stateNode;t&&(t=ko(t),Zc(e.stateNode,e.type,t))}}function ug(e){Wr?Gr?Gr.push(e):Gr=[e]:Wr=e}function dg(){if(Wr){var e=Wr,t=Gr;if(Gr=Wr=null,vm(e),t)for(e=0;e<t.length;e++)vm(t[e])}}function hg(e,t){return e(t)}function mg(){}var nc=!1;function fg(e,t,s){if(nc)return e(t,s);nc=!0;try{return hg(e,t,s)}finally{nc=!1,(Wr!==null||Gr!==null)&&(mg(),dg())}}function di(e,t){var s=e.stateNode;if(s===null)return null;var r=ko(s);if(r===null)return null;s=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(q(231,t,typeof s));return s}var Yc=!1;if(rn)try{var Ra={};Object.defineProperty(Ra,"passive",{get:function(){Yc=!0}}),window.addEventListener("test",Ra,Ra),window.removeEventListener("test",Ra,Ra)}catch{Yc=!1}function Hv(e,t,s,r,a,i,l,o,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(s,u)}catch(d){this.onError(d)}}var Ja=!1,Ul=null,$l=!1,Jc=null,Wv={onError:function(e){Ja=!0,Ul=e}};function Gv(e,t,s,r,a,i,l,o,c){Ja=!1,Ul=null,Hv.apply(Wv,arguments)}function Zv(e,t,s,r,a,i,l,o,c){if(Gv.apply(this,arguments),Ja){if(Ja){var u=Ul;Ja=!1,Ul=null}else throw Error(q(198));$l||($l=!0,Jc=u)}}function Cr(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function pg(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function jm(e){if(Cr(e)!==e)throw Error(q(188))}function Yv(e){var t=e.alternate;if(!t){if(t=Cr(e),t===null)throw Error(q(188));return t!==e?null:e}for(var s=e,r=t;;){var a=s.return;if(a===null)break;var i=a.alternate;if(i===null){if(r=a.return,r!==null){s=r;continue}break}if(a.child===i.child){for(i=a.child;i;){if(i===s)return jm(a),e;if(i===r)return jm(a),t;i=i.sibling}throw Error(q(188))}if(s.return!==r.return)s=a,r=i;else{for(var l=!1,o=a.child;o;){if(o===s){l=!0,s=a,r=i;break}if(o===r){l=!0,r=a,s=i;break}o=o.sibling}if(!l){for(o=i.child;o;){if(o===s){l=!0,s=i,r=a;break}if(o===r){l=!0,r=i,s=a;break}o=o.sibling}if(!l)throw Error(q(189))}}if(s.alternate!==r)throw Error(q(190))}if(s.tag!==3)throw Error(q(188));return s.stateNode.current===s?e:t}function gg(e){return e=Yv(e),e!==null?xg(e):null}function xg(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=xg(e);if(t!==null)return t;e=e.sibling}return null}var yg=rs.unstable_scheduleCallback,bm=rs.unstable_cancelCallback,Jv=rs.unstable_shouldYield,Xv=rs.unstable_requestPaint,et=rs.unstable_now,e0=rs.unstable_getCurrentPriorityLevel,pd=rs.unstable_ImmediatePriority,vg=rs.unstable_UserBlockingPriority,Bl=rs.unstable_NormalPriority,t0=rs.unstable_LowPriority,jg=rs.unstable_IdlePriority,bo=null,Os=null;function s0(e){if(Os&&typeof Os.onCommitFiberRoot=="function")try{Os.onCommitFiberRoot(bo,e,void 0,(e.current.flags&128)===128)}catch{}}var ks=Math.clz32?Math.clz32:a0,n0=Math.log,r0=Math.LN2;function a0(e){return e>>>=0,e===0?32:31-(n0(e)/r0|0)|0}var il=64,ll=4194304;function Ha(e){switch(e&-e){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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Kl(e,t){var s=e.pendingLanes;if(s===0)return 0;var r=0,a=e.suspendedLanes,i=e.pingedLanes,l=s&268435455;if(l!==0){var o=l&~a;o!==0?r=Ha(o):(i&=l,i!==0&&(r=Ha(i)))}else l=s&~a,l!==0?r=Ha(l):i!==0&&(r=Ha(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&a)&&(a=r&-r,i=t&-t,a>=i||a===16&&(i&4194240)!==0))return t;if(r&4&&(r|=s&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)s=31-ks(t),a=1<<s,r|=e[s],t&=~a;return r}function i0(e,t){switch(e){case 1:case 2:case 4:return t+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 t+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 l0(e,t){for(var s=e.suspendedLanes,r=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var l=31-ks(i),o=1<<l,c=a[l];c===-1?(!(o&s)||o&r)&&(a[l]=i0(o,t)):c<=t&&(e.expiredLanes|=o),i&=~o}}function Xc(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function bg(){var e=il;return il<<=1,!(il&4194240)&&(il=64),e}function rc(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function Bi(e,t,s){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ks(t),e[t]=s}function o0(e,t){var s=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<s;){var a=31-ks(s),i=1<<a;t[a]=0,r[a]=-1,e[a]=-1,s&=~i}}function gd(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var r=31-ks(s),a=1<<r;a&t|e[r]&t&&(e[r]|=t),s&=~a}}var Ie=0;function Ng(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var wg,xd,Sg,kg,Cg,eu=!1,ol=[],In=null,Mn=null,Ln=null,hi=new Map,mi=new Map,yn=[],c0="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 Nm(e,t){switch(e){case"focusin":case"focusout":In=null;break;case"dragenter":case"dragleave":Mn=null;break;case"mouseover":case"mouseout":Ln=null;break;case"pointerover":case"pointerout":hi.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":mi.delete(t.pointerId)}}function Oa(e,t,s,r,a,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:s,eventSystemFlags:r,nativeEvent:i,targetContainers:[a]},t!==null&&(t=Vi(t),t!==null&&xd(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function u0(e,t,s,r,a){switch(t){case"focusin":return In=Oa(In,e,t,s,r,a),!0;case"dragenter":return Mn=Oa(Mn,e,t,s,r,a),!0;case"mouseover":return Ln=Oa(Ln,e,t,s,r,a),!0;case"pointerover":var i=a.pointerId;return hi.set(i,Oa(hi.get(i)||null,e,t,s,r,a)),!0;case"gotpointercapture":return i=a.pointerId,mi.set(i,Oa(mi.get(i)||null,e,t,s,r,a)),!0}return!1}function Eg(e){var t=Jn(e.target);if(t!==null){var s=Cr(t);if(s!==null){if(t=s.tag,t===13){if(t=pg(s),t!==null){e.blockedOn=t,Cg(e.priority,function(){Sg(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Sl(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=tu(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(s===null){s=e.nativeEvent;var r=new s.constructor(s.type,s);Gc=r,s.target.dispatchEvent(r),Gc=null}else return t=Vi(s),t!==null&&xd(t),e.blockedOn=s,!1;t.shift()}return!0}function wm(e,t,s){Sl(e)&&s.delete(t)}function d0(){eu=!1,In!==null&&Sl(In)&&(In=null),Mn!==null&&Sl(Mn)&&(Mn=null),Ln!==null&&Sl(Ln)&&(Ln=null),hi.forEach(wm),mi.forEach(wm)}function _a(e,t){e.blockedOn===t&&(e.blockedOn=null,eu||(eu=!0,rs.unstable_scheduleCallback(rs.unstable_NormalPriority,d0)))}function fi(e){function t(a){return _a(a,e)}if(0<ol.length){_a(ol[0],e);for(var s=1;s<ol.length;s++){var r=ol[s];r.blockedOn===e&&(r.blockedOn=null)}}for(In!==null&&_a(In,e),Mn!==null&&_a(Mn,e),Ln!==null&&_a(Ln,e),hi.forEach(t),mi.forEach(t),s=0;s<yn.length;s++)r=yn[s],r.blockedOn===e&&(r.blockedOn=null);for(;0<yn.length&&(s=yn[0],s.blockedOn===null);)Eg(s),s.blockedOn===null&&yn.shift()}var Zr=cn.ReactCurrentBatchConfig,Vl=!0;function h0(e,t,s,r){var a=Ie,i=Zr.transition;Zr.transition=null;try{Ie=1,yd(e,t,s,r)}finally{Ie=a,Zr.transition=i}}function m0(e,t,s,r){var a=Ie,i=Zr.transition;Zr.transition=null;try{Ie=4,yd(e,t,s,r)}finally{Ie=a,Zr.transition=i}}function yd(e,t,s,r){if(Vl){var a=tu(e,t,s,r);if(a===null)fc(e,t,r,ql,s),Nm(e,r);else if(u0(a,e,t,s,r))r.stopPropagation();else if(Nm(e,r),t&4&&-1<c0.indexOf(e)){for(;a!==null;){var i=Vi(a);if(i!==null&&wg(i),i=tu(e,t,s,r),i===null&&fc(e,t,r,ql,s),i===a)break;a=i}a!==null&&r.stopPropagation()}else fc(e,t,r,null,s)}}var ql=null;function tu(e,t,s,r){if(ql=null,e=fd(r),e=Jn(e),e!==null)if(t=Cr(e),t===null)e=null;else if(s=t.tag,s===13){if(e=pg(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return ql=e,null}function Dg(e){switch(e){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(e0()){case pd:return 1;case vg:return 4;case Bl:case t0:return 16;case jg:return 536870912;default:return 16}default:return 16}}var An=null,vd=null,kl=null;function Pg(){if(kl)return kl;var e,t=vd,s=t.length,r,a="value"in An?An.value:An.textContent,i=a.length;for(e=0;e<s&&t[e]===a[e];e++);var l=s-e;for(r=1;r<=l&&t[s-r]===a[i-r];r++);return kl=a.slice(e,1<r?1-r:void 0)}function Cl(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function cl(){return!0}function Sm(){return!1}function is(e){function t(s,r,a,i,l){this._reactName=s,this._targetInst=a,this.type=r,this.nativeEvent=i,this.target=l,this.currentTarget=null;for(var o in e)e.hasOwnProperty(o)&&(s=e[o],this[o]=s?s(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?cl:Sm,this.isPropagationStopped=Sm,this}return He(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=cl)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=cl)},persist:function(){},isPersistent:cl}),t}var ka={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},jd=is(ka),Ki=He({},ka,{view:0,detail:0}),f0=is(Ki),ac,ic,za,No=He({},Ki,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:bd,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==za&&(za&&e.type==="mousemove"?(ac=e.screenX-za.screenX,ic=e.screenY-za.screenY):ic=ac=0,za=e),ac)},movementY:function(e){return"movementY"in e?e.movementY:ic}}),km=is(No),p0=He({},No,{dataTransfer:0}),g0=is(p0),x0=He({},Ki,{relatedTarget:0}),lc=is(x0),y0=He({},ka,{animationName:0,elapsedTime:0,pseudoElement:0}),v0=is(y0),j0=He({},ka,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),b0=is(j0),N0=He({},ka,{data:0}),Cm=is(N0),w0={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},S0={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"},k0={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function C0(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=k0[e])?!!t[e]:!1}function bd(){return C0}var E0=He({},Ki,{key:function(e){if(e.key){var t=w0[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Cl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?S0[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bd,charCode:function(e){return e.type==="keypress"?Cl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Cl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),D0=is(E0),P0=He({},No,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Em=is(P0),A0=He({},Ki,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bd}),T0=is(A0),F0=He({},ka,{propertyName:0,elapsedTime:0,pseudoElement:0}),I0=is(F0),M0=He({},No,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),L0=is(M0),R0=[9,13,27,32],Nd=rn&&"CompositionEvent"in window,Xa=null;rn&&"documentMode"in document&&(Xa=document.documentMode);var O0=rn&&"TextEvent"in window&&!Xa,Ag=rn&&(!Nd||Xa&&8<Xa&&11>=Xa),Dm=" ",Pm=!1;function Tg(e,t){switch(e){case"keyup":return R0.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fg(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Rr=!1;function _0(e,t){switch(e){case"compositionend":return Fg(t);case"keypress":return t.which!==32?null:(Pm=!0,Dm);case"textInput":return e=t.data,e===Dm&&Pm?null:e;default:return null}}function z0(e,t){if(Rr)return e==="compositionend"||!Nd&&Tg(e,t)?(e=Pg(),kl=vd=An=null,Rr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ag&&t.locale!=="ko"?null:t.data;default:return null}}var U0={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 Am(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!U0[e.type]:t==="textarea"}function Ig(e,t,s,r){ug(r),t=Ql(t,"onChange"),0<t.length&&(s=new jd("onChange","change",null,s,r),e.push({event:s,listeners:t}))}var ei=null,pi=null;function $0(e){Vg(e,0)}function wo(e){var t=zr(e);if(ng(t))return e}function B0(e,t){if(e==="change")return t}var Mg=!1;if(rn){var oc;if(rn){var cc="oninput"in document;if(!cc){var Tm=document.createElement("div");Tm.setAttribute("oninput","return;"),cc=typeof Tm.oninput=="function"}oc=cc}else oc=!1;Mg=oc&&(!document.documentMode||9<document.documentMode)}function Fm(){ei&&(ei.detachEvent("onpropertychange",Lg),pi=ei=null)}function Lg(e){if(e.propertyName==="value"&&wo(pi)){var t=[];Ig(t,pi,e,fd(e)),fg($0,t)}}function K0(e,t,s){e==="focusin"?(Fm(),ei=t,pi=s,ei.attachEvent("onpropertychange",Lg)):e==="focusout"&&Fm()}function V0(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return wo(pi)}function q0(e,t){if(e==="click")return wo(t)}function Q0(e,t){if(e==="input"||e==="change")return wo(t)}function H0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Es=typeof Object.is=="function"?Object.is:H0;function gi(e,t){if(Es(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),r=Object.keys(t);if(s.length!==r.length)return!1;for(r=0;r<s.length;r++){var a=s[r];if(!Oc.call(t,a)||!Es(e[a],t[a]))return!1}return!0}function Im(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Mm(e,t){var s=Im(e);e=0;for(var r;s;){if(s.nodeType===3){if(r=e+s.textContent.length,e<=t&&r>=t)return{node:s,offset:t-e};e=r}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Im(s)}}function Rg(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Rg(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Og(){for(var e=window,t=zl();t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=zl(e.document)}return t}function wd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function W0(e){var t=Og(),s=e.focusedElem,r=e.selectionRange;if(t!==s&&s&&s.ownerDocument&&Rg(s.ownerDocument.documentElement,s)){if(r!==null&&wd(s)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in s)s.selectionStart=t,s.selectionEnd=Math.min(e,s.value.length);else if(e=(t=s.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=s.textContent.length,i=Math.min(r.start,a);r=r.end===void 0?i:Math.min(r.end,a),!e.extend&&i>r&&(a=r,r=i,i=a),a=Mm(s,i);var l=Mm(s,r);a&&l&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=s;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s<t.length;s++)e=t[s],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var G0=rn&&"documentMode"in document&&11>=document.documentMode,Or=null,su=null,ti=null,nu=!1;function Lm(e,t,s){var r=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;nu||Or==null||Or!==zl(r)||(r=Or,"selectionStart"in r&&wd(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ti&&gi(ti,r)||(ti=r,r=Ql(su,"onSelect"),0<r.length&&(t=new jd("onSelect","select",null,t,s),e.push({event:t,listeners:r}),t.target=Or)))}function ul(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var _r={animationend:ul("Animation","AnimationEnd"),animationiteration:ul("Animation","AnimationIteration"),animationstart:ul("Animation","AnimationStart"),transitionend:ul("Transition","TransitionEnd")},uc={},_g={};rn&&(_g=document.createElement("div").style,"AnimationEvent"in window||(delete _r.animationend.animation,delete _r.animationiteration.animation,delete _r.animationstart.animation),"TransitionEvent"in window||delete _r.transitionend.transition);function So(e){if(uc[e])return uc[e];if(!_r[e])return e;var t=_r[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in _g)return uc[e]=t[s];return e}var zg=So("animationend"),Ug=So("animationiteration"),$g=So("animationstart"),Bg=So("transitionend"),Kg=new Map,Rm="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 Qn(e,t){Kg.set(e,t),kr(t,[e])}for(var dc=0;dc<Rm.length;dc++){var hc=Rm[dc],Z0=hc.toLowerCase(),Y0=hc[0].toUpperCase()+hc.slice(1);Qn(Z0,"on"+Y0)}Qn(zg,"onAnimationEnd");Qn(Ug,"onAnimationIteration");Qn($g,"onAnimationStart");Qn("dblclick","onDoubleClick");Qn("focusin","onFocus");Qn("focusout","onBlur");Qn(Bg,"onTransitionEnd");ma("onMouseEnter",["mouseout","mouseover"]);ma("onMouseLeave",["mouseout","mouseover"]);ma("onPointerEnter",["pointerout","pointerover"]);ma("onPointerLeave",["pointerout","pointerover"]);kr("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));kr("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));kr("onBeforeInput",["compositionend","keypress","textInput","paste"]);kr("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));kr("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));kr("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Wa="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(" "),J0=new Set("cancel close invalid load scroll toggle".split(" ").concat(Wa));function Om(e,t,s){var r=e.type||"unknown-event";e.currentTarget=s,Zv(r,t,void 0,e),e.currentTarget=null}function Vg(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var r=e[s],a=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var l=r.length-1;0<=l;l--){var o=r[l],c=o.instance,u=o.currentTarget;if(o=o.listener,c!==i&&a.isPropagationStopped())break e;Om(a,o,u),i=c}else for(l=0;l<r.length;l++){if(o=r[l],c=o.instance,u=o.currentTarget,o=o.listener,c!==i&&a.isPropagationStopped())break e;Om(a,o,u),i=c}}}if($l)throw e=Jc,$l=!1,Jc=null,e}function _e(e,t){var s=t[ou];s===void 0&&(s=t[ou]=new Set);var r=e+"__bubble";s.has(r)||(qg(t,e,2,!1),s.add(r))}function mc(e,t,s){var r=0;t&&(r|=4),qg(s,e,r,t)}var dl="_reactListening"+Math.random().toString(36).slice(2);function xi(e){if(!e[dl]){e[dl]=!0,Jp.forEach(function(s){s!=="selectionchange"&&(J0.has(s)||mc(s,!1,e),mc(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[dl]||(t[dl]=!0,mc("selectionchange",!1,t))}}function qg(e,t,s,r){switch(Dg(t)){case 1:var a=h0;break;case 4:a=m0;break;default:a=yd}s=a.bind(null,t,s,e),a=void 0,!Yc||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),r?a!==void 0?e.addEventListener(t,s,{capture:!0,passive:a}):e.addEventListener(t,s,!0):a!==void 0?e.addEventListener(t,s,{passive:a}):e.addEventListener(t,s,!1)}function fc(e,t,s,r,a){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var l=r.tag;if(l===3||l===4){var o=r.stateNode.containerInfo;if(o===a||o.nodeType===8&&o.parentNode===a)break;if(l===4)for(l=r.return;l!==null;){var c=l.tag;if((c===3||c===4)&&(c=l.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;l=l.return}for(;o!==null;){if(l=Jn(o),l===null)return;if(c=l.tag,c===5||c===6){r=i=l;continue e}o=o.parentNode}}r=r.return}fg(function(){var u=i,d=fd(s),m=[];e:{var p=Kg.get(e);if(p!==void 0){var h=jd,f=e;switch(e){case"keypress":if(Cl(s)===0)break e;case"keydown":case"keyup":h=D0;break;case"focusin":f="focus",h=lc;break;case"focusout":f="blur",h=lc;break;case"beforeblur":case"afterblur":h=lc;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=km;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=g0;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=T0;break;case zg:case Ug:case $g:h=v0;break;case Bg:h=I0;break;case"scroll":h=f0;break;case"wheel":h=L0;break;case"copy":case"cut":case"paste":h=b0;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=Em}var g=(t&4)!==0,b=!g&&e==="scroll",y=g?p!==null?p+"Capture":null:p;g=[];for(var v=u,x;v!==null;){x=v;var N=x.stateNode;if(x.tag===5&&N!==null&&(x=N,y!==null&&(N=di(v,y),N!=null&&g.push(yi(v,N,x)))),b)break;v=v.return}0<g.length&&(p=new h(p,f,null,s,d),m.push({event:p,listeners:g}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",h=e==="mouseout"||e==="pointerout",p&&s!==Gc&&(f=s.relatedTarget||s.fromElement)&&(Jn(f)||f[an]))break e;if((h||p)&&(p=d.window===d?d:(p=d.ownerDocument)?p.defaultView||p.parentWindow:window,h?(f=s.relatedTarget||s.toElement,h=u,f=f?Jn(f):null,f!==null&&(b=Cr(f),f!==b||f.tag!==5&&f.tag!==6)&&(f=null)):(h=null,f=u),h!==f)){if(g=km,N="onMouseLeave",y="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(g=Em,N="onPointerLeave",y="onPointerEnter",v="pointer"),b=h==null?p:zr(h),x=f==null?p:zr(f),p=new g(N,v+"leave",h,s,d),p.target=b,p.relatedTarget=x,N=null,Jn(d)===u&&(g=new g(y,v+"enter",f,s,d),g.target=x,g.relatedTarget=b,N=g),b=N,h&&f)t:{for(g=h,y=f,v=0,x=g;x;x=Tr(x))v++;for(x=0,N=y;N;N=Tr(N))x++;for(;0<v-x;)g=Tr(g),v--;for(;0<x-v;)y=Tr(y),x--;for(;v--;){if(g===y||y!==null&&g===y.alternate)break t;g=Tr(g),y=Tr(y)}g=null}else g=null;h!==null&&_m(m,p,h,g,!1),f!==null&&b!==null&&_m(m,b,f,g,!0)}}e:{if(p=u?zr(u):window,h=p.nodeName&&p.nodeName.toLowerCase(),h==="select"||h==="input"&&p.type==="file")var k=B0;else if(Am(p))if(Mg)k=Q0;else{k=V0;var D=K0}else(h=p.nodeName)&&h.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(k=q0);if(k&&(k=k(e,u))){Ig(m,k,s,d);break e}D&&D(e,p,u),e==="focusout"&&(D=p._wrapperState)&&D.controlled&&p.type==="number"&&Vc(p,"number",p.value)}switch(D=u?zr(u):window,e){case"focusin":(Am(D)||D.contentEditable==="true")&&(Or=D,su=u,ti=null);break;case"focusout":ti=su=Or=null;break;case"mousedown":nu=!0;break;case"contextmenu":case"mouseup":case"dragend":nu=!1,Lm(m,s,d);break;case"selectionchange":if(G0)break;case"keydown":case"keyup":Lm(m,s,d)}var F;if(Nd)e:{switch(e){case"compositionstart":var S="onCompositionStart";break e;case"compositionend":S="onCompositionEnd";break e;case"compositionupdate":S="onCompositionUpdate";break e}S=void 0}else Rr?Tg(e,s)&&(S="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(S="onCompositionStart");S&&(Ag&&s.locale!=="ko"&&(Rr||S!=="onCompositionStart"?S==="onCompositionEnd"&&Rr&&(F=Pg()):(An=d,vd="value"in An?An.value:An.textContent,Rr=!0)),D=Ql(u,S),0<D.length&&(S=new Cm(S,e,null,s,d),m.push({event:S,listeners:D}),F?S.data=F:(F=Fg(s),F!==null&&(S.data=F)))),(F=O0?_0(e,s):z0(e,s))&&(u=Ql(u,"onBeforeInput"),0<u.length&&(d=new Cm("onBeforeInput","beforeinput",null,s,d),m.push({event:d,listeners:u}),d.data=F))}Vg(m,t)})}function yi(e,t,s){return{instance:e,listener:t,currentTarget:s}}function Ql(e,t){for(var s=t+"Capture",r=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=di(e,s),i!=null&&r.unshift(yi(e,i,a)),i=di(e,t),i!=null&&r.push(yi(e,i,a))),e=e.return}return r}function Tr(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function _m(e,t,s,r,a){for(var i=t._reactName,l=[];s!==null&&s!==r;){var o=s,c=o.alternate,u=o.stateNode;if(c!==null&&c===r)break;o.tag===5&&u!==null&&(o=u,a?(c=di(s,i),c!=null&&l.unshift(yi(s,c,o))):a||(c=di(s,i),c!=null&&l.push(yi(s,c,o)))),s=s.return}l.length!==0&&e.push({event:t,listeners:l})}var X0=/\r\n?/g,ej=/\u0000|\uFFFD/g;function zm(e){return(typeof e=="string"?e:""+e).replace(X0,`
`).replace(ej,"")}function hl(e,t,s){if(t=zm(t),zm(e)!==t&&s)throw Error(q(425))}function Hl(){}var ru=null,au=null;function iu(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var lu=typeof setTimeout=="function"?setTimeout:void 0,tj=typeof clearTimeout=="function"?clearTimeout:void 0,Um=typeof Promise=="function"?Promise:void 0,sj=typeof queueMicrotask=="function"?queueMicrotask:typeof Um<"u"?function(e){return Um.resolve(null).then(e).catch(nj)}:lu;function nj(e){setTimeout(function(){throw e})}function pc(e,t){var s=t,r=0;do{var a=s.nextSibling;if(e.removeChild(s),a&&a.nodeType===8)if(s=a.data,s==="/$"){if(r===0){e.removeChild(a),fi(t);return}r--}else s!=="$"&&s!=="$?"&&s!=="$!"||r++;s=a}while(s);fi(t)}function Rn(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function $m(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"){if(t===0)return e;t--}else s==="/$"&&t++}e=e.previousSibling}return null}var Ca=Math.random().toString(36).slice(2),Rs="__reactFiber$"+Ca,vi="__reactProps$"+Ca,an="__reactContainer$"+Ca,ou="__reactEvents$"+Ca,rj="__reactListeners$"+Ca,aj="__reactHandles$"+Ca;function Jn(e){var t=e[Rs];if(t)return t;for(var s=e.parentNode;s;){if(t=s[an]||s[Rs]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=$m(e);e!==null;){if(s=e[Rs])return s;e=$m(e)}return t}e=s,s=e.parentNode}return null}function Vi(e){return e=e[Rs]||e[an],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function zr(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(q(33))}function ko(e){return e[vi]||null}var cu=[],Ur=-1;function Hn(e){return{current:e}}function ze(e){0>Ur||(e.current=cu[Ur],cu[Ur]=null,Ur--)}function Re(e,t){Ur++,cu[Ur]=e.current,e.current=t}var Vn={},At=Hn(Vn),Ht=Hn(!1),gr=Vn;function fa(e,t){var s=e.type.contextTypes;if(!s)return Vn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in s)a[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function Wt(e){return e=e.childContextTypes,e!=null}function Wl(){ze(Ht),ze(At)}function Bm(e,t,s){if(At.current!==Vn)throw Error(q(168));Re(At,t),Re(Ht,s)}function Qg(e,t,s){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return s;r=r.getChildContext();for(var a in r)if(!(a in t))throw Error(q(108,Kv(e)||"Unknown",a));return He({},s,r)}function Gl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Vn,gr=At.current,Re(At,e),Re(Ht,Ht.current),!0}function Km(e,t,s){var r=e.stateNode;if(!r)throw Error(q(169));s?(e=Qg(e,t,gr),r.__reactInternalMemoizedMergedChildContext=e,ze(Ht),ze(At),Re(At,e)):ze(Ht),Re(Ht,s)}var Qs=null,Co=!1,gc=!1;function Hg(e){Qs===null?Qs=[e]:Qs.push(e)}function ij(e){Co=!0,Hg(e)}function Wn(){if(!gc&&Qs!==null){gc=!0;var e=0,t=Ie;try{var s=Qs;for(Ie=1;e<s.length;e++){var r=s[e];do r=r(!0);while(r!==null)}Qs=null,Co=!1}catch(a){throw Qs!==null&&(Qs=Qs.slice(e+1)),yg(pd,Wn),a}finally{Ie=t,gc=!1}}return null}var $r=[],Br=0,Zl=null,Yl=0,cs=[],us=0,xr=null,Js=1,Xs="";function Zn(e,t){$r[Br++]=Yl,$r[Br++]=Zl,Zl=e,Yl=t}function Wg(e,t,s){cs[us++]=Js,cs[us++]=Xs,cs[us++]=xr,xr=e;var r=Js;e=Xs;var a=32-ks(r)-1;r&=~(1<<a),s+=1;var i=32-ks(t)+a;if(30<i){var l=a-a%5;i=(r&(1<<l)-1).toString(32),r>>=l,a-=l,Js=1<<32-ks(t)+a|s<<a|r,Xs=i+e}else Js=1<<i|s<<a|r,Xs=e}function Sd(e){e.return!==null&&(Zn(e,1),Wg(e,1,0))}function kd(e){for(;e===Zl;)Zl=$r[--Br],$r[Br]=null,Yl=$r[--Br],$r[Br]=null;for(;e===xr;)xr=cs[--us],cs[us]=null,Xs=cs[--us],cs[us]=null,Js=cs[--us],cs[us]=null}var ns=null,ss=null,Be=!1,Ns=null;function Gg(e,t){var s=ds(5,null,null,0);s.elementType="DELETED",s.stateNode=t,s.return=e,t=e.deletions,t===null?(e.deletions=[s],e.flags|=16):t.push(s)}function Vm(e,t){switch(e.tag){case 5:var s=e.type;return t=t.nodeType!==1||s.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,ns=e,ss=Rn(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ns=e,ss=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(s=xr!==null?{id:Js,overflow:Xs}:null,e.memoizedState={dehydrated:t,treeContext:s,retryLane:1073741824},s=ds(18,null,null,0),s.stateNode=t,s.return=e,e.child=s,ns=e,ss=null,!0):!1;default:return!1}}function uu(e){return(e.mode&1)!==0&&(e.flags&128)===0}function du(e){if(Be){var t=ss;if(t){var s=t;if(!Vm(e,t)){if(uu(e))throw Error(q(418));t=Rn(s.nextSibling);var r=ns;t&&Vm(e,t)?Gg(r,s):(e.flags=e.flags&-4097|2,Be=!1,ns=e)}}else{if(uu(e))throw Error(q(418));e.flags=e.flags&-4097|2,Be=!1,ns=e}}}function qm(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ns=e}function ml(e){if(e!==ns)return!1;if(!Be)return qm(e),Be=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!iu(e.type,e.memoizedProps)),t&&(t=ss)){if(uu(e))throw Zg(),Error(q(418));for(;t;)Gg(e,t),t=Rn(t.nextSibling)}if(qm(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(q(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"){if(t===0){ss=Rn(e.nextSibling);break e}t--}else s!=="$"&&s!=="$!"&&s!=="$?"||t++}e=e.nextSibling}ss=null}}else ss=ns?Rn(e.stateNode.nextSibling):null;return!0}function Zg(){for(var e=ss;e;)e=Rn(e.nextSibling)}function pa(){ss=ns=null,Be=!1}function Cd(e){Ns===null?Ns=[e]:Ns.push(e)}var lj=cn.ReactCurrentBatchConfig;function Ua(e,t,s){if(e=s.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(s._owner){if(s=s._owner,s){if(s.tag!==1)throw Error(q(309));var r=s.stateNode}if(!r)throw Error(q(147,e));var a=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(l){var o=a.refs;l===null?delete o[i]:o[i]=l},t._stringRef=i,t)}if(typeof e!="string")throw Error(q(284));if(!s._owner)throw Error(q(290,e))}return e}function fl(e,t){throw e=Object.prototype.toString.call(t),Error(q(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Qm(e){var t=e._init;return t(e._payload)}function Yg(e){function t(y,v){if(e){var x=y.deletions;x===null?(y.deletions=[v],y.flags|=16):x.push(v)}}function s(y,v){if(!e)return null;for(;v!==null;)t(y,v),v=v.sibling;return null}function r(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 a(y,v){return y=Un(y,v),y.index=0,y.sibling=null,y}function i(y,v,x){return y.index=x,e?(x=y.alternate,x!==null?(x=x.index,x<v?(y.flags|=2,v):x):(y.flags|=2,v)):(y.flags|=1048576,v)}function l(y){return e&&y.alternate===null&&(y.flags|=2),y}function o(y,v,x,N){return v===null||v.tag!==6?(v=wc(x,y.mode,N),v.return=y,v):(v=a(v,x),v.return=y,v)}function c(y,v,x,N){var k=x.type;return k===Lr?d(y,v,x.props.children,N,x.key):v!==null&&(v.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===pn&&Qm(k)===v.type)?(N=a(v,x.props),N.ref=Ua(y,v,x),N.return=y,N):(N=Il(x.type,x.key,x.props,null,y.mode,N),N.ref=Ua(y,v,x),N.return=y,N)}function u(y,v,x,N){return v===null||v.tag!==4||v.stateNode.containerInfo!==x.containerInfo||v.stateNode.implementation!==x.implementation?(v=Sc(x,y.mode,N),v.return=y,v):(v=a(v,x.children||[]),v.return=y,v)}function d(y,v,x,N,k){return v===null||v.tag!==7?(v=fr(x,y.mode,N,k),v.return=y,v):(v=a(v,x),v.return=y,v)}function m(y,v,x){if(typeof v=="string"&&v!==""||typeof v=="number")return v=wc(""+v,y.mode,x),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case nl:return x=Il(v.type,v.key,v.props,null,y.mode,x),x.ref=Ua(y,null,v),x.return=y,x;case Mr:return v=Sc(v,y.mode,x),v.return=y,v;case pn:var N=v._init;return m(y,N(v._payload),x)}if(Qa(v)||La(v))return v=fr(v,y.mode,x,null),v.return=y,v;fl(y,v)}return null}function p(y,v,x,N){var k=v!==null?v.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return k!==null?null:o(y,v,""+x,N);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case nl:return x.key===k?c(y,v,x,N):null;case Mr:return x.key===k?u(y,v,x,N):null;case pn:return k=x._init,p(y,v,k(x._payload),N)}if(Qa(x)||La(x))return k!==null?null:d(y,v,x,N,null);fl(y,x)}return null}function h(y,v,x,N,k){if(typeof N=="string"&&N!==""||typeof N=="number")return y=y.get(x)||null,o(v,y,""+N,k);if(typeof N=="object"&&N!==null){switch(N.$$typeof){case nl:return y=y.get(N.key===null?x:N.key)||null,c(v,y,N,k);case Mr:return y=y.get(N.key===null?x:N.key)||null,u(v,y,N,k);case pn:var D=N._init;return h(y,v,x,D(N._payload),k)}if(Qa(N)||La(N))return y=y.get(x)||null,d(v,y,N,k,null);fl(v,N)}return null}function f(y,v,x,N){for(var k=null,D=null,F=v,S=v=0,L=null;F!==null&&S<x.length;S++){F.index>S?(L=F,F=null):L=F.sibling;var T=p(y,F,x[S],N);if(T===null){F===null&&(F=L);break}e&&F&&T.alternate===null&&t(y,F),v=i(T,v,S),D===null?k=T:D.sibling=T,D=T,F=L}if(S===x.length)return s(y,F),Be&&Zn(y,S),k;if(F===null){for(;S<x.length;S++)F=m(y,x[S],N),F!==null&&(v=i(F,v,S),D===null?k=F:D.sibling=F,D=F);return Be&&Zn(y,S),k}for(F=r(y,F);S<x.length;S++)L=h(F,y,S,x[S],N),L!==null&&(e&&L.alternate!==null&&F.delete(L.key===null?S:L.key),v=i(L,v,S),D===null?k=L:D.sibling=L,D=L);return e&&F.forEach(function(_){return t(y,_)}),Be&&Zn(y,S),k}function g(y,v,x,N){var k=La(x);if(typeof k!="function")throw Error(q(150));if(x=k.call(x),x==null)throw Error(q(151));for(var D=k=null,F=v,S=v=0,L=null,T=x.next();F!==null&&!T.done;S++,T=x.next()){F.index>S?(L=F,F=null):L=F.sibling;var _=p(y,F,T.value,N);if(_===null){F===null&&(F=L);break}e&&F&&_.alternate===null&&t(y,F),v=i(_,v,S),D===null?k=_:D.sibling=_,D=_,F=L}if(T.done)return s(y,F),Be&&Zn(y,S),k;if(F===null){for(;!T.done;S++,T=x.next())T=m(y,T.value,N),T!==null&&(v=i(T,v,S),D===null?k=T:D.sibling=T,D=T);return Be&&Zn(y,S),k}for(F=r(y,F);!T.done;S++,T=x.next())T=h(F,y,S,T.value,N),T!==null&&(e&&T.alternate!==null&&F.delete(T.key===null?S:T.key),v=i(T,v,S),D===null?k=T:D.sibling=T,D=T);return e&&F.forEach(function(K){return t(y,K)}),Be&&Zn(y,S),k}function b(y,v,x,N){if(typeof x=="object"&&x!==null&&x.type===Lr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case nl:e:{for(var k=x.key,D=v;D!==null;){if(D.key===k){if(k=x.type,k===Lr){if(D.tag===7){s(y,D.sibling),v=a(D,x.props.children),v.return=y,y=v;break e}}else if(D.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===pn&&Qm(k)===D.type){s(y,D.sibling),v=a(D,x.props),v.ref=Ua(y,D,x),v.return=y,y=v;break e}s(y,D);break}else t(y,D);D=D.sibling}x.type===Lr?(v=fr(x.props.children,y.mode,N,x.key),v.return=y,y=v):(N=Il(x.type,x.key,x.props,null,y.mode,N),N.ref=Ua(y,v,x),N.return=y,y=N)}return l(y);case Mr:e:{for(D=x.key;v!==null;){if(v.key===D)if(v.tag===4&&v.stateNode.containerInfo===x.containerInfo&&v.stateNode.implementation===x.implementation){s(y,v.sibling),v=a(v,x.children||[]),v.return=y,y=v;break e}else{s(y,v);break}else t(y,v);v=v.sibling}v=Sc(x,y.mode,N),v.return=y,y=v}return l(y);case pn:return D=x._init,b(y,v,D(x._payload),N)}if(Qa(x))return f(y,v,x,N);if(La(x))return g(y,v,x,N);fl(y,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,v!==null&&v.tag===6?(s(y,v.sibling),v=a(v,x),v.return=y,y=v):(s(y,v),v=wc(x,y.mode,N),v.return=y,y=v),l(y)):s(y,v)}return b}var ga=Yg(!0),Jg=Yg(!1),Jl=Hn(null),Xl=null,Kr=null,Ed=null;function Dd(){Ed=Kr=Xl=null}function Pd(e){var t=Jl.current;ze(Jl),e._currentValue=t}function hu(e,t,s){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===s)break;e=e.return}}function Yr(e,t){Xl=e,Ed=Kr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Qt=!0),e.firstContext=null)}function fs(e){var t=e._currentValue;if(Ed!==e)if(e={context:e,memoizedValue:t,next:null},Kr===null){if(Xl===null)throw Error(q(308));Kr=e,Xl.dependencies={lanes:0,firstContext:e}}else Kr=Kr.next=e;return t}var Xn=null;function Ad(e){Xn===null?Xn=[e]:Xn.push(e)}function Xg(e,t,s,r){var a=t.interleaved;return a===null?(s.next=s,Ad(t)):(s.next=a.next,a.next=s),t.interleaved=s,ln(e,r)}function ln(e,t){e.lanes|=t;var s=e.alternate;for(s!==null&&(s.lanes|=t),s=e,e=e.return;e!==null;)e.childLanes|=t,s=e.alternate,s!==null&&(s.childLanes|=t),s=e,e=e.return;return s.tag===3?s.stateNode:null}var gn=!1;function Td(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ex(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function sn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function On(e,t,s){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,De&2){var a=r.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),r.pending=t,ln(e,s)}return a=r.interleaved,a===null?(t.next=t,Ad(r)):(t.next=a.next,a.next=t),r.interleaved=t,ln(e,s)}function El(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,gd(e,s)}}function Hm(e,t){var s=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,s===r)){var a=null,i=null;if(s=s.firstBaseUpdate,s!==null){do{var l={eventTime:s.eventTime,lane:s.lane,tag:s.tag,payload:s.payload,callback:s.callback,next:null};i===null?a=i=l:i=i.next=l,s=s.next}while(s!==null);i===null?a=i=t:i=i.next=t}else a=i=t;s={baseState:r.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}function eo(e,t,s,r){var a=e.updateQueue;gn=!1;var i=a.firstBaseUpdate,l=a.lastBaseUpdate,o=a.shared.pending;if(o!==null){a.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?i=u:l.next=u,l=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==l&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var m=a.baseState;l=0,d=u=c=null,o=i;do{var p=o.lane,h=o.eventTime;if((r&p)===p){d!==null&&(d=d.next={eventTime:h,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var f=e,g=o;switch(p=t,h=s,g.tag){case 1:if(f=g.payload,typeof f=="function"){m=f.call(h,m,p);break e}m=f;break e;case 3:f.flags=f.flags&-65537|128;case 0:if(f=g.payload,p=typeof f=="function"?f.call(h,m,p):f,p==null)break e;m=He({},m,p);break e;case 2:gn=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=a.effects,p===null?a.effects=[o]:p.push(o))}else h={eventTime:h,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=h,c=m):d=d.next=h,l|=p;if(o=o.next,o===null){if(o=a.shared.pending,o===null)break;p=o,o=p.next,p.next=null,a.lastBaseUpdate=p,a.shared.pending=null}}while(!0);if(d===null&&(c=m),a.baseState=c,a.firstBaseUpdate=u,a.lastBaseUpdate=d,t=a.shared.interleaved,t!==null){a=t;do l|=a.lane,a=a.next;while(a!==t)}else i===null&&(a.shared.lanes=0);vr|=l,e.lanes=l,e.memoizedState=m}}function Wm(e,t,s){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],a=r.callback;if(a!==null){if(r.callback=null,r=s,typeof a!="function")throw Error(q(191,a));a.call(r)}}}var qi={},_s=Hn(qi),ji=Hn(qi),bi=Hn(qi);function er(e){if(e===qi)throw Error(q(174));return e}function Fd(e,t){switch(Re(bi,t),Re(ji,e),Re(_s,qi),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Qc(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Qc(t,e)}ze(_s),Re(_s,t)}function xa(){ze(_s),ze(ji),ze(bi)}function tx(e){er(bi.current);var t=er(_s.current),s=Qc(t,e.type);t!==s&&(Re(ji,e),Re(_s,s))}function Id(e){ji.current===e&&(ze(_s),ze(ji))}var Ve=Hn(0);function to(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var xc=[];function Md(){for(var e=0;e<xc.length;e++)xc[e]._workInProgressVersionPrimary=null;xc.length=0}var Dl=cn.ReactCurrentDispatcher,yc=cn.ReactCurrentBatchConfig,yr=0,qe=null,ot=null,gt=null,so=!1,si=!1,Ni=0,oj=0;function kt(){throw Error(q(321))}function Ld(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!Es(e[s],t[s]))return!1;return!0}function Rd(e,t,s,r,a,i){if(yr=i,qe=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Dl.current=e===null||e.memoizedState===null?hj:mj,e=s(r,a),si){i=0;do{if(si=!1,Ni=0,25<=i)throw Error(q(301));i+=1,gt=ot=null,t.updateQueue=null,Dl.current=fj,e=s(r,a)}while(si)}if(Dl.current=no,t=ot!==null&&ot.next!==null,yr=0,gt=ot=qe=null,so=!1,t)throw Error(q(300));return e}function Od(){var e=Ni!==0;return Ni=0,e}function Ts(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return gt===null?qe.memoizedState=gt=e:gt=gt.next=e,gt}function ps(){if(ot===null){var e=qe.alternate;e=e!==null?e.memoizedState:null}else e=ot.next;var t=gt===null?qe.memoizedState:gt.next;if(t!==null)gt=t,ot=e;else{if(e===null)throw Error(q(310));ot=e,e={memoizedState:ot.memoizedState,baseState:ot.baseState,baseQueue:ot.baseQueue,queue:ot.queue,next:null},gt===null?qe.memoizedState=gt=e:gt=gt.next=e}return gt}function wi(e,t){return typeof t=="function"?t(e):t}function vc(e){var t=ps(),s=t.queue;if(s===null)throw Error(q(311));s.lastRenderedReducer=e;var r=ot,a=r.baseQueue,i=s.pending;if(i!==null){if(a!==null){var l=a.next;a.next=i.next,i.next=l}r.baseQueue=a=i,s.pending=null}if(a!==null){i=a.next,r=r.baseState;var o=l=null,c=null,u=i;do{var d=u.lane;if((yr&d)===d)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var m={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(o=c=m,l=r):c=c.next=m,qe.lanes|=d,vr|=d}u=u.next}while(u!==null&&u!==i);c===null?l=r:c.next=o,Es(r,t.memoizedState)||(Qt=!0),t.memoizedState=r,t.baseState=l,t.baseQueue=c,s.lastRenderedState=r}if(e=s.interleaved,e!==null){a=e;do i=a.lane,qe.lanes|=i,vr|=i,a=a.next;while(a!==e)}else a===null&&(s.lanes=0);return[t.memoizedState,s.dispatch]}function jc(e){var t=ps(),s=t.queue;if(s===null)throw Error(q(311));s.lastRenderedReducer=e;var r=s.dispatch,a=s.pending,i=t.memoizedState;if(a!==null){s.pending=null;var l=a=a.next;do i=e(i,l.action),l=l.next;while(l!==a);Es(i,t.memoizedState)||(Qt=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),s.lastRenderedState=i}return[i,r]}function sx(){}function nx(e,t){var s=qe,r=ps(),a=t(),i=!Es(r.memoizedState,a);if(i&&(r.memoizedState=a,Qt=!0),r=r.queue,_d(ix.bind(null,s,r,e),[e]),r.getSnapshot!==t||i||gt!==null&&gt.memoizedState.tag&1){if(s.flags|=2048,Si(9,ax.bind(null,s,r,a,t),void 0,null),jt===null)throw Error(q(349));yr&30||rx(s,t,a)}return a}function rx(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=qe.updateQueue,t===null?(t={lastEffect:null,stores:null},qe.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function ax(e,t,s,r){t.value=s,t.getSnapshot=r,lx(t)&&ox(e)}function ix(e,t,s){return s(function(){lx(t)&&ox(e)})}function lx(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!Es(e,s)}catch{return!0}}function ox(e){var t=ln(e,1);t!==null&&Cs(t,e,1,-1)}function Gm(e){var t=Ts();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:wi,lastRenderedState:e},t.queue=e,e=e.dispatch=dj.bind(null,qe,e),[t.memoizedState,e]}function Si(e,t,s,r){return e={tag:e,create:t,destroy:s,deps:r,next:null},t=qe.updateQueue,t===null?(t={lastEffect:null,stores:null},qe.updateQueue=t,t.lastEffect=e.next=e):(s=t.lastEffect,s===null?t.lastEffect=e.next=e:(r=s.next,s.next=e,e.next=r,t.lastEffect=e)),e}function cx(){return ps().memoizedState}function Pl(e,t,s,r){var a=Ts();qe.flags|=e,a.memoizedState=Si(1|t,s,void 0,r===void 0?null:r)}function Eo(e,t,s,r){var a=ps();r=r===void 0?null:r;var i=void 0;if(ot!==null){var l=ot.memoizedState;if(i=l.destroy,r!==null&&Ld(r,l.deps)){a.memoizedState=Si(t,s,i,r);return}}qe.flags|=e,a.memoizedState=Si(1|t,s,i,r)}function Zm(e,t){return Pl(8390656,8,e,t)}function _d(e,t){return Eo(2048,8,e,t)}function ux(e,t){return Eo(4,2,e,t)}function dx(e,t){return Eo(4,4,e,t)}function hx(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function mx(e,t,s){return s=s!=null?s.concat([e]):null,Eo(4,4,hx.bind(null,t,e),s)}function zd(){}function fx(e,t){var s=ps();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&Ld(t,r[1])?r[0]:(s.memoizedState=[e,t],e)}function px(e,t){var s=ps();t=t===void 0?null:t;var r=s.memoizedState;return r!==null&&t!==null&&Ld(t,r[1])?r[0]:(e=e(),s.memoizedState=[e,t],e)}function gx(e,t,s){return yr&21?(Es(s,t)||(s=bg(),qe.lanes|=s,vr|=s,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Qt=!0),e.memoizedState=s)}function cj(e,t){var s=Ie;Ie=s!==0&&4>s?s:4,e(!0);var r=yc.transition;yc.transition={};try{e(!1),t()}finally{Ie=s,yc.transition=r}}function xx(){return ps().memoizedState}function uj(e,t,s){var r=zn(e);if(s={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null},yx(e))vx(t,s);else if(s=Xg(e,t,s,r),s!==null){var a=Ot();Cs(s,e,r,a),jx(s,t,r)}}function dj(e,t,s){var r=zn(e),a={lane:r,action:s,hasEagerState:!1,eagerState:null,next:null};if(yx(e))vx(t,a);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,s);if(a.hasEagerState=!0,a.eagerState=o,Es(o,l)){var c=t.interleaved;c===null?(a.next=a,Ad(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}s=Xg(e,t,a,r),s!==null&&(a=Ot(),Cs(s,e,r,a),jx(s,t,r))}}function yx(e){var t=e.alternate;return e===qe||t!==null&&t===qe}function vx(e,t){si=so=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function jx(e,t,s){if(s&4194240){var r=t.lanes;r&=e.pendingLanes,s|=r,t.lanes=s,gd(e,s)}}var no={readContext:fs,useCallback:kt,useContext:kt,useEffect:kt,useImperativeHandle:kt,useInsertionEffect:kt,useLayoutEffect:kt,useMemo:kt,useReducer:kt,useRef:kt,useState:kt,useDebugValue:kt,useDeferredValue:kt,useTransition:kt,useMutableSource:kt,useSyncExternalStore:kt,useId:kt,unstable_isNewReconciler:!1},hj={readContext:fs,useCallback:function(e,t){return Ts().memoizedState=[e,t===void 0?null:t],e},useContext:fs,useEffect:Zm,useImperativeHandle:function(e,t,s){return s=s!=null?s.concat([e]):null,Pl(4194308,4,hx.bind(null,t,e),s)},useLayoutEffect:function(e,t){return Pl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Pl(4,2,e,t)},useMemo:function(e,t){var s=Ts();return t=t===void 0?null:t,e=e(),s.memoizedState=[e,t],e},useReducer:function(e,t,s){var r=Ts();return t=s!==void 0?s(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=uj.bind(null,qe,e),[r.memoizedState,e]},useRef:function(e){var t=Ts();return e={current:e},t.memoizedState=e},useState:Gm,useDebugValue:zd,useDeferredValue:function(e){return Ts().memoizedState=e},useTransition:function(){var e=Gm(!1),t=e[0];return e=cj.bind(null,e[1]),Ts().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,s){var r=qe,a=Ts();if(Be){if(s===void 0)throw Error(q(407));s=s()}else{if(s=t(),jt===null)throw Error(q(349));yr&30||rx(r,t,s)}a.memoizedState=s;var i={value:s,getSnapshot:t};return a.queue=i,Zm(ix.bind(null,r,i,e),[e]),r.flags|=2048,Si(9,ax.bind(null,r,i,s,t),void 0,null),s},useId:function(){var e=Ts(),t=jt.identifierPrefix;if(Be){var s=Xs,r=Js;s=(r&~(1<<32-ks(r)-1)).toString(32)+s,t=":"+t+"R"+s,s=Ni++,0<s&&(t+="H"+s.toString(32)),t+=":"}else s=oj++,t=":"+t+"r"+s.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},mj={readContext:fs,useCallback:fx,useContext:fs,useEffect:_d,useImperativeHandle:mx,useInsertionEffect:ux,useLayoutEffect:dx,useMemo:px,useReducer:vc,useRef:cx,useState:function(){return vc(wi)},useDebugValue:zd,useDeferredValue:function(e){var t=ps();return gx(t,ot.memoizedState,e)},useTransition:function(){var e=vc(wi)[0],t=ps().memoizedState;return[e,t]},useMutableSource:sx,useSyncExternalStore:nx,useId:xx,unstable_isNewReconciler:!1},fj={readContext:fs,useCallback:fx,useContext:fs,useEffect:_d,useImperativeHandle:mx,useInsertionEffect:ux,useLayoutEffect:dx,useMemo:px,useReducer:jc,useRef:cx,useState:function(){return jc(wi)},useDebugValue:zd,useDeferredValue:function(e){var t=ps();return ot===null?t.memoizedState=e:gx(t,ot.memoizedState,e)},useTransition:function(){var e=jc(wi)[0],t=ps().memoizedState;return[e,t]},useMutableSource:sx,useSyncExternalStore:nx,useId:xx,unstable_isNewReconciler:!1};function ys(e,t){if(e&&e.defaultProps){t=He({},t),e=e.defaultProps;for(var s in e)t[s]===void 0&&(t[s]=e[s]);return t}return t}function mu(e,t,s,r){t=e.memoizedState,s=s(r,t),s=s==null?t:He({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var Do={isMounted:function(e){return(e=e._reactInternals)?Cr(e)===e:!1},enqueueSetState:function(e,t,s){e=e._reactInternals;var r=Ot(),a=zn(e),i=sn(r,a);i.payload=t,s!=null&&(i.callback=s),t=On(e,i,a),t!==null&&(Cs(t,e,a,r),El(t,e,a))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var r=Ot(),a=zn(e),i=sn(r,a);i.tag=1,i.payload=t,s!=null&&(i.callback=s),t=On(e,i,a),t!==null&&(Cs(t,e,a,r),El(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Ot(),r=zn(e),a=sn(s,r);a.tag=2,t!=null&&(a.callback=t),t=On(e,a,r),t!==null&&(Cs(t,e,r,s),El(t,e,r))}};function Ym(e,t,s,r,a,i,l){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,l):t.prototype&&t.prototype.isPureReactComponent?!gi(s,r)||!gi(a,i):!0}function bx(e,t,s){var r=!1,a=Vn,i=t.contextType;return typeof i=="object"&&i!==null?i=fs(i):(a=Wt(t)?gr:At.current,r=t.contextTypes,i=(r=r!=null)?fa(e,a):Vn),t=new t(s,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Do,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function Jm(e,t,s,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,r),t.state!==e&&Do.enqueueReplaceState(t,t.state,null)}function fu(e,t,s,r){var a=e.stateNode;a.props=s,a.state=e.memoizedState,a.refs={},Td(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=fs(i):(i=Wt(t)?gr:At.current,a.context=fa(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(mu(e,t,i,s),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(t=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),t!==a.state&&Do.enqueueReplaceState(a,a.state,null),eo(e,s,a,r),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function ya(e,t){try{var s="",r=t;do s+=Bv(r),r=r.return;while(r);var a=s}catch(i){a=`
Error generating stack: `+i.message+`
`+i.stack}return{value:e,source:t,stack:a,digest:null}}function bc(e,t,s){return{value:e,source:null,stack:s??null,digest:t??null}}function pu(e,t){try{console.error(t.value)}catch(s){setTimeout(function(){throw s})}}var pj=typeof WeakMap=="function"?WeakMap:Map;function Nx(e,t,s){s=sn(-1,s),s.tag=3,s.payload={element:null};var r=t.value;return s.callback=function(){ao||(ao=!0,ku=r),pu(e,t)},s}function wx(e,t,s){s=sn(-1,s),s.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var a=t.value;s.payload=function(){return r(a)},s.callback=function(){pu(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(s.callback=function(){pu(e,t),typeof r!="function"&&(_n===null?_n=new Set([this]):_n.add(this));var l=t.stack;this.componentDidCatch(t.value,{componentStack:l!==null?l:""})}),s}function Xm(e,t,s){var r=e.pingCache;if(r===null){r=e.pingCache=new pj;var a=new Set;r.set(t,a)}else a=r.get(t),a===void 0&&(a=new Set,r.set(t,a));a.has(s)||(a.add(s),e=Pj.bind(null,e,t,s),t.then(e,e))}function ef(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function tf(e,t,s,r,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,s.flags|=131072,s.flags&=-52805,s.tag===1&&(s.alternate===null?s.tag=17:(t=sn(-1,1),t.tag=2,On(s,t,1))),s.lanes|=1),e)}var gj=cn.ReactCurrentOwner,Qt=!1;function Lt(e,t,s,r){t.child=e===null?Jg(t,null,s,r):ga(t,e.child,s,r)}function sf(e,t,s,r,a){s=s.render;var i=t.ref;return Yr(t,a),r=Rd(e,t,s,r,i,a),s=Od(),e!==null&&!Qt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,on(e,t,a)):(Be&&s&&Sd(t),t.flags|=1,Lt(e,t,r,a),t.child)}function nf(e,t,s,r,a){if(e===null){var i=s.type;return typeof i=="function"&&!Hd(i)&&i.defaultProps===void 0&&s.compare===null&&s.defaultProps===void 0?(t.tag=15,t.type=i,Sx(e,t,i,r,a)):(e=Il(s.type,null,r,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&a)){var l=i.memoizedProps;if(s=s.compare,s=s!==null?s:gi,s(l,r)&&e.ref===t.ref)return on(e,t,a)}return t.flags|=1,e=Un(i,r),e.ref=t.ref,e.return=t,t.child=e}function Sx(e,t,s,r,a){if(e!==null){var i=e.memoizedProps;if(gi(i,r)&&e.ref===t.ref)if(Qt=!1,t.pendingProps=r=i,(e.lanes&a)!==0)e.flags&131072&&(Qt=!0);else return t.lanes=e.lanes,on(e,t,a)}return gu(e,t,s,r,a)}function kx(e,t,s){var r=t.pendingProps,a=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Re(qr,es),es|=s;else{if(!(s&1073741824))return e=i!==null?i.baseLanes|s:s,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Re(qr,es),es|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:s,Re(qr,es),es|=r}else i!==null?(r=i.baseLanes|s,t.memoizedState=null):r=s,Re(qr,es),es|=r;return Lt(e,t,a,s),t.child}function Cx(e,t){var s=t.ref;(e===null&&s!==null||e!==null&&e.ref!==s)&&(t.flags|=512,t.flags|=2097152)}function gu(e,t,s,r,a){var i=Wt(s)?gr:At.current;return i=fa(t,i),Yr(t,a),s=Rd(e,t,s,r,i,a),r=Od(),e!==null&&!Qt?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,on(e,t,a)):(Be&&r&&Sd(t),t.flags|=1,Lt(e,t,s,a),t.child)}function rf(e,t,s,r,a){if(Wt(s)){var i=!0;Gl(t)}else i=!1;if(Yr(t,a),t.stateNode===null)Al(e,t),bx(t,s,r),fu(t,s,r,a),r=!0;else if(e===null){var l=t.stateNode,o=t.memoizedProps;l.props=o;var c=l.context,u=s.contextType;typeof u=="object"&&u!==null?u=fs(u):(u=Wt(s)?gr:At.current,u=fa(t,u));var d=s.getDerivedStateFromProps,m=typeof d=="function"||typeof l.getSnapshotBeforeUpdate=="function";m||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==r||c!==u)&&Jm(t,l,r,u),gn=!1;var p=t.memoizedState;l.state=p,eo(t,r,l,a),c=t.memoizedState,o!==r||p!==c||Ht.current||gn?(typeof d=="function"&&(mu(t,s,d,r),c=t.memoizedState),(o=gn||Ym(t,s,o,r,p,c,u))?(m||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"&&(t.flags|=4194308)):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),l.props=r,l.state=c,l.context=u,r=o):(typeof l.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{l=t.stateNode,ex(e,t),o=t.memoizedProps,u=t.type===t.elementType?o:ys(t.type,o),l.props=u,m=t.pendingProps,p=l.context,c=s.contextType,typeof c=="object"&&c!==null?c=fs(c):(c=Wt(s)?gr:At.current,c=fa(t,c));var h=s.getDerivedStateFromProps;(d=typeof h=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(o!==m||p!==c)&&Jm(t,l,r,c),gn=!1,p=t.memoizedState,l.state=p,eo(t,r,l,a);var f=t.memoizedState;o!==m||p!==f||Ht.current||gn?(typeof h=="function"&&(mu(t,s,h,r),f=t.memoizedState),(u=gn||Ym(t,s,u,r,p,f,c)||!1)?(d||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(r,f,c),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(r,f,c)),typeof l.componentDidUpdate=="function"&&(t.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=f),l.props=r,l.state=f,l.context=c,r=u):(typeof l.componentDidUpdate!="function"||o===e.memoizedProps&&p===e.memoizedState||(t.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||o===e.memoizedProps&&p===e.memoizedState||(t.flags|=1024),r=!1)}return xu(e,t,s,r,i,a)}function xu(e,t,s,r,a,i){Cx(e,t);var l=(t.flags&128)!==0;if(!r&&!l)return a&&Km(t,s,!1),on(e,t,i);r=t.stateNode,gj.current=t;var o=l&&typeof s.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&l?(t.child=ga(t,e.child,null,i),t.child=ga(t,null,o,i)):Lt(e,t,o,i),t.memoizedState=r.state,a&&Km(t,s,!0),t.child}function Ex(e){var t=e.stateNode;t.pendingContext?Bm(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Bm(e,t.context,!1),Fd(e,t.containerInfo)}function af(e,t,s,r,a){return pa(),Cd(a),t.flags|=256,Lt(e,t,s,r),t.child}var yu={dehydrated:null,treeContext:null,retryLane:0};function vu(e){return{baseLanes:e,cachePool:null,transitions:null}}function Dx(e,t,s){var r=t.pendingProps,a=Ve.current,i=!1,l=(t.flags&128)!==0,o;if((o=l)||(o=e!==null&&e.memoizedState===null?!1:(a&2)!==0),o?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),Re(Ve,a&1),e===null)return du(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(l=r.children,e=r.fallback,i?(r=t.mode,i=t.child,l={mode:"hidden",children:l},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=l):i=To(l,r,0,null),e=fr(e,r,s,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=vu(s),t.memoizedState=yu,e):Ud(t,l));if(a=e.memoizedState,a!==null&&(o=a.dehydrated,o!==null))return xj(e,t,l,r,o,a,s);if(i){i=r.fallback,l=t.mode,a=e.child,o=a.sibling;var c={mode:"hidden",children:r.children};return!(l&1)&&t.child!==a?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Un(a,c),r.subtreeFlags=a.subtreeFlags&14680064),o!==null?i=Un(o,i):(i=fr(i,l,s,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,l=e.child.memoizedState,l=l===null?vu(s):{baseLanes:l.baseLanes|s,cachePool:null,transitions:l.transitions},i.memoizedState=l,i.childLanes=e.childLanes&~s,t.memoizedState=yu,r}return i=e.child,e=i.sibling,r=Un(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=s),r.return=t,r.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=r,t.memoizedState=null,r}function Ud(e,t){return t=To({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function pl(e,t,s,r){return r!==null&&Cd(r),ga(t,e.child,null,s),e=Ud(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function xj(e,t,s,r,a,i,l){if(s)return t.flags&256?(t.flags&=-257,r=bc(Error(q(422))),pl(e,t,l,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,a=t.mode,r=To({mode:"visible",children:r.children},a,0,null),i=fr(i,a,l,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&ga(t,e.child,null,l),t.child.memoizedState=vu(l),t.memoizedState=yu,i);if(!(t.mode&1))return pl(e,t,l,null);if(a.data==="$!"){if(r=a.nextSibling&&a.nextSibling.dataset,r)var o=r.dgst;return r=o,i=Error(q(419)),r=bc(i,r,void 0),pl(e,t,l,r)}if(o=(l&e.childLanes)!==0,Qt||o){if(r=jt,r!==null){switch(l&-l){case 4:a=2;break;case 16:a=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:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(r.suspendedLanes|l)?0:a,a!==0&&a!==i.retryLane&&(i.retryLane=a,ln(e,a),Cs(r,e,a,-1))}return Qd(),r=bc(Error(q(421))),pl(e,t,l,r)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=Aj.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,ss=Rn(a.nextSibling),ns=t,Be=!0,Ns=null,e!==null&&(cs[us++]=Js,cs[us++]=Xs,cs[us++]=xr,Js=e.id,Xs=e.overflow,xr=t),t=Ud(t,r.children),t.flags|=4096,t)}function lf(e,t,s){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),hu(e.return,t,s)}function Nc(e,t,s,r,a){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:s,tailMode:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=s,i.tailMode=a)}function Px(e,t,s){var r=t.pendingProps,a=r.revealOrder,i=r.tail;if(Lt(e,t,r.children,s),r=Ve.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&lf(e,s,t);else if(e.tag===19)lf(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Re(Ve,r),!(t.mode&1))t.memoizedState=null;else switch(a){case"forwards":for(s=t.child,a=null;s!==null;)e=s.alternate,e!==null&&to(e)===null&&(a=s),s=s.sibling;s=a,s===null?(a=t.child,t.child=null):(a=s.sibling,s.sibling=null),Nc(t,!1,a,s,i);break;case"backwards":for(s=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&to(e)===null){t.child=a;break}e=a.sibling,a.sibling=s,s=a,a=e}Nc(t,!0,s,null,i);break;case"together":Nc(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Al(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function on(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),vr|=t.lanes,!(s&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(q(153));if(t.child!==null){for(e=t.child,s=Un(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=Un(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function yj(e,t,s){switch(t.tag){case 3:Ex(t),pa();break;case 5:tx(t);break;case 1:Wt(t.type)&&Gl(t);break;case 4:Fd(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,a=t.memoizedProps.value;Re(Jl,r._currentValue),r._currentValue=a;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Re(Ve,Ve.current&1),t.flags|=128,null):s&t.child.childLanes?Dx(e,t,s):(Re(Ve,Ve.current&1),e=on(e,t,s),e!==null?e.sibling:null);Re(Ve,Ve.current&1);break;case 19:if(r=(s&t.childLanes)!==0,e.flags&128){if(r)return Px(e,t,s);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),Re(Ve,Ve.current),r)break;return null;case 22:case 23:return t.lanes=0,kx(e,t,s)}return on(e,t,s)}var Ax,ju,Tx,Fx;Ax=function(e,t){for(var s=t.child;s!==null;){if(s.tag===5||s.tag===6)e.appendChild(s.stateNode);else if(s.tag!==4&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break;for(;s.sibling===null;){if(s.return===null||s.return===t)return;s=s.return}s.sibling.return=s.return,s=s.sibling}};ju=function(){};Tx=function(e,t,s,r){var a=e.memoizedProps;if(a!==r){e=t.stateNode,er(_s.current);var i=null;switch(s){case"input":a=Bc(e,a),r=Bc(e,r),i=[];break;case"select":a=He({},a,{value:void 0}),r=He({},r,{value:void 0}),i=[];break;case"textarea":a=qc(e,a),r=qc(e,r),i=[];break;default:typeof a.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Hl)}Hc(s,r);var l;s=null;for(u in a)if(!r.hasOwnProperty(u)&&a.hasOwnProperty(u)&&a[u]!=null)if(u==="style"){var o=a[u];for(l in o)o.hasOwnProperty(l)&&(s||(s={}),s[l]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(ci.hasOwnProperty(u)?i||(i=[]):(i=i||[]).push(u,null));for(u in r){var c=r[u];if(o=a!=null?a[u]:void 0,r.hasOwnProperty(u)&&c!==o&&(c!=null||o!=null))if(u==="style")if(o){for(l in o)!o.hasOwnProperty(l)||c&&c.hasOwnProperty(l)||(s||(s={}),s[l]="");for(l in c)c.hasOwnProperty(l)&&o[l]!==c[l]&&(s||(s={}),s[l]=c[l])}else s||(i||(i=[]),i.push(u,s)),s=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,o=o?o.__html:void 0,c!=null&&o!==c&&(i=i||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(ci.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&_e("scroll",e),i||o===c||(i=[])):(i=i||[]).push(u,c))}s&&(i=i||[]).push("style",s);var u=i;(t.updateQueue=u)&&(t.flags|=4)}};Fx=function(e,t,s,r){s!==r&&(t.flags|=4)};function $a(e,t){if(!Be)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var r=null;s!==null;)s.alternate!==null&&(r=s),s=s.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ct(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,r=0;if(t)for(var a=e.child;a!==null;)s|=a.lanes|a.childLanes,r|=a.subtreeFlags&14680064,r|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)s|=a.lanes|a.childLanes,r|=a.subtreeFlags,r|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=r,e.childLanes=s,t}function vj(e,t,s){var r=t.pendingProps;switch(kd(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ct(t),null;case 1:return Wt(t.type)&&Wl(),Ct(t),null;case 3:return r=t.stateNode,xa(),ze(Ht),ze(At),Md(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(ml(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ns!==null&&(Du(Ns),Ns=null))),ju(e,t),Ct(t),null;case 5:Id(t);var a=er(bi.current);if(s=t.type,e!==null&&t.stateNode!=null)Tx(e,t,s,r,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(q(166));return Ct(t),null}if(e=er(_s.current),ml(t)){r=t.stateNode,s=t.type;var i=t.memoizedProps;switch(r[Rs]=t,r[vi]=i,e=(t.mode&1)!==0,s){case"dialog":_e("cancel",r),_e("close",r);break;case"iframe":case"object":case"embed":_e("load",r);break;case"video":case"audio":for(a=0;a<Wa.length;a++)_e(Wa[a],r);break;case"source":_e("error",r);break;case"img":case"image":case"link":_e("error",r),_e("load",r);break;case"details":_e("toggle",r);break;case"input":pm(r,i),_e("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},_e("invalid",r);break;case"textarea":xm(r,i),_e("invalid",r)}Hc(s,i),a=null;for(var l in i)if(i.hasOwnProperty(l)){var o=i[l];l==="children"?typeof o=="string"?r.textContent!==o&&(i.suppressHydrationWarning!==!0&&hl(r.textContent,o,e),a=["children",o]):typeof o=="number"&&r.textContent!==""+o&&(i.suppressHydrationWarning!==!0&&hl(r.textContent,o,e),a=["children",""+o]):ci.hasOwnProperty(l)&&o!=null&&l==="onScroll"&&_e("scroll",r)}switch(s){case"input":rl(r),gm(r,i,!0);break;case"textarea":rl(r),ym(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Hl)}r=a,t.updateQueue=r,r!==null&&(t.flags|=4)}else{l=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=ig(s)),e==="http://www.w3.org/1999/xhtml"?s==="script"?(e=l.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(s,{is:r.is}):(e=l.createElement(s),s==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,s),e[Rs]=t,e[vi]=r,Ax(e,t,!1,!1),t.stateNode=e;e:{switch(l=Wc(s,r),s){case"dialog":_e("cancel",e),_e("close",e),a=r;break;case"iframe":case"object":case"embed":_e("load",e),a=r;break;case"video":case"audio":for(a=0;a<Wa.length;a++)_e(Wa[a],e);a=r;break;case"source":_e("error",e),a=r;break;case"img":case"image":case"link":_e("error",e),_e("load",e),a=r;break;case"details":_e("toggle",e),a=r;break;case"input":pm(e,r),a=Bc(e,r),_e("invalid",e);break;case"option":a=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},a=He({},r,{value:void 0}),_e("invalid",e);break;case"textarea":xm(e,r),a=qc(e,r),_e("invalid",e);break;default:a=r}Hc(s,a),o=a;for(i in o)if(o.hasOwnProperty(i)){var c=o[i];i==="style"?cg(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&lg(e,c)):i==="children"?typeof c=="string"?(s!=="textarea"||c!=="")&&ui(e,c):typeof c=="number"&&ui(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(ci.hasOwnProperty(i)?c!=null&&i==="onScroll"&&_e("scroll",e):c!=null&&ud(e,i,c,l))}switch(s){case"input":rl(e),gm(e,r,!1);break;case"textarea":rl(e),ym(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Kn(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?Hr(e,!!r.multiple,i,!1):r.defaultValue!=null&&Hr(e,!!r.multiple,r.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=Hl)}switch(s){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Ct(t),null;case 6:if(e&&t.stateNode!=null)Fx(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(q(166));if(s=er(bi.current),er(_s.current),ml(t)){if(r=t.stateNode,s=t.memoizedProps,r[Rs]=t,(i=r.nodeValue!==s)&&(e=ns,e!==null))switch(e.tag){case 3:hl(r.nodeValue,s,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&hl(r.nodeValue,s,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(s.nodeType===9?s:s.ownerDocument).createTextNode(r),r[Rs]=t,t.stateNode=r}return Ct(t),null;case 13:if(ze(Ve),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Be&&ss!==null&&t.mode&1&&!(t.flags&128))Zg(),pa(),t.flags|=98560,i=!1;else if(i=ml(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(q(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(q(317));i[Rs]=t}else pa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ct(t),i=!1}else Ns!==null&&(Du(Ns),Ns=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=s,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||Ve.current&1?ut===0&&(ut=3):Qd())),t.updateQueue!==null&&(t.flags|=4),Ct(t),null);case 4:return xa(),ju(e,t),e===null&&xi(t.stateNode.containerInfo),Ct(t),null;case 10:return Pd(t.type._context),Ct(t),null;case 17:return Wt(t.type)&&Wl(),Ct(t),null;case 19:if(ze(Ve),i=t.memoizedState,i===null)return Ct(t),null;if(r=(t.flags&128)!==0,l=i.rendering,l===null)if(r)$a(i,!1);else{if(ut!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(l=to(e),l!==null){for(t.flags|=128,$a(i,!1),r=l.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=s,s=t.child;s!==null;)i=s,e=r,i.flags&=14680066,l=i.alternate,l===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=l.childLanes,i.lanes=l.lanes,i.child=l.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=l.memoizedProps,i.memoizedState=l.memoizedState,i.updateQueue=l.updateQueue,i.type=l.type,e=l.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),s=s.sibling;return Re(Ve,Ve.current&1|2),t.child}e=e.sibling}i.tail!==null&&et()>va&&(t.flags|=128,r=!0,$a(i,!1),t.lanes=4194304)}else{if(!r)if(e=to(l),e!==null){if(t.flags|=128,r=!0,s=e.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),$a(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!Be)return Ct(t),null}else 2*et()-i.renderingStartTime>va&&s!==1073741824&&(t.flags|=128,r=!0,$a(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(s=i.last,s!==null?s.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=et(),t.sibling=null,s=Ve.current,Re(Ve,r?s&1|2:s&1),t):(Ct(t),null);case 22:case 23:return qd(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?es&1073741824&&(Ct(t),t.subtreeFlags&6&&(t.flags|=8192)):Ct(t),null;case 24:return null;case 25:return null}throw Error(q(156,t.tag))}function jj(e,t){switch(kd(t),t.tag){case 1:return Wt(t.type)&&Wl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xa(),ze(Ht),ze(At),Md(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Id(t),null;case 13:if(ze(Ve),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(q(340));pa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ze(Ve),null;case 4:return xa(),null;case 10:return Pd(t.type._context),null;case 22:case 23:return qd(),null;case 24:return null;default:return null}}var gl=!1,Et=!1,bj=typeof WeakSet=="function"?WeakSet:Set,re=null;function Vr(e,t){var s=e.ref;if(s!==null)if(typeof s=="function")try{s(null)}catch(r){Je(e,t,r)}else s.current=null}function bu(e,t,s){try{s()}catch(r){Je(e,t,r)}}var of=!1;function Nj(e,t){if(ru=Vl,e=Og(),wd(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var r=s.getSelection&&s.getSelection();if(r&&r.rangeCount!==0){s=r.anchorNode;var a=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{s.nodeType,i.nodeType}catch{s=null;break e}var l=0,o=-1,c=-1,u=0,d=0,m=e,p=null;t:for(;;){for(var h;m!==s||a!==0&&m.nodeType!==3||(o=l+a),m!==i||r!==0&&m.nodeType!==3||(c=l+r),m.nodeType===3&&(l+=m.nodeValue.length),(h=m.firstChild)!==null;)p=m,m=h;for(;;){if(m===e)break t;if(p===s&&++u===a&&(o=l),p===i&&++d===r&&(c=l),(h=m.nextSibling)!==null)break;m=p,p=m.parentNode}m=h}s=o===-1||c===-1?null:{start:o,end:c}}else s=null}s=s||{start:0,end:0}}else s=null;for(au={focusedElem:e,selectionRange:s},Vl=!1,re=t;re!==null;)if(t=re,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,re=e;else for(;re!==null;){t=re;try{var f=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(f!==null){var g=f.memoizedProps,b=f.memoizedState,y=t.stateNode,v=y.getSnapshotBeforeUpdate(t.elementType===t.type?g:ys(t.type,g),b);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(q(163))}}catch(N){Je(t,t.return,N)}if(e=t.sibling,e!==null){e.return=t.return,re=e;break}re=t.return}return f=of,of=!1,f}function ni(e,t,s){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var a=r=r.next;do{if((a.tag&e)===e){var i=a.destroy;a.destroy=void 0,i!==void 0&&bu(t,s,i)}a=a.next}while(a!==r)}}function Po(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var s=t=t.next;do{if((s.tag&e)===e){var r=s.create;s.destroy=r()}s=s.next}while(s!==t)}}function Nu(e){var t=e.ref;if(t!==null){var s=e.stateNode;switch(e.tag){case 5:e=s;break;default:e=s}typeof t=="function"?t(e):t.current=e}}function Ix(e){var t=e.alternate;t!==null&&(e.alternate=null,Ix(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Rs],delete t[vi],delete t[ou],delete t[rj],delete t[aj])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Mx(e){return e.tag===5||e.tag===3||e.tag===4}function cf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Mx(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function wu(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.nodeType===8?s.parentNode.insertBefore(e,t):s.insertBefore(e,t):(s.nodeType===8?(t=s.parentNode,t.insertBefore(e,s)):(t=s,t.appendChild(e)),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=Hl));else if(r!==4&&(e=e.child,e!==null))for(wu(e,t,s),e=e.sibling;e!==null;)wu(e,t,s),e=e.sibling}function Su(e,t,s){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Su(e,t,s),e=e.sibling;e!==null;)Su(e,t,s),e=e.sibling}var bt=null,bs=!1;function mn(e,t,s){for(s=s.child;s!==null;)Lx(e,t,s),s=s.sibling}function Lx(e,t,s){if(Os&&typeof Os.onCommitFiberUnmount=="function")try{Os.onCommitFiberUnmount(bo,s)}catch{}switch(s.tag){case 5:Et||Vr(s,t);case 6:var r=bt,a=bs;bt=null,mn(e,t,s),bt=r,bs=a,bt!==null&&(bs?(e=bt,s=s.stateNode,e.nodeType===8?e.parentNode.removeChild(s):e.removeChild(s)):bt.removeChild(s.stateNode));break;case 18:bt!==null&&(bs?(e=bt,s=s.stateNode,e.nodeType===8?pc(e.parentNode,s):e.nodeType===1&&pc(e,s),fi(e)):pc(bt,s.stateNode));break;case 4:r=bt,a=bs,bt=s.stateNode.containerInfo,bs=!0,mn(e,t,s),bt=r,bs=a;break;case 0:case 11:case 14:case 15:if(!Et&&(r=s.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){a=r=r.next;do{var i=a,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&bu(s,t,l),a=a.next}while(a!==r)}mn(e,t,s);break;case 1:if(!Et&&(Vr(s,t),r=s.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=s.memoizedProps,r.state=s.memoizedState,r.componentWillUnmount()}catch(o){Je(s,t,o)}mn(e,t,s);break;case 21:mn(e,t,s);break;case 22:s.mode&1?(Et=(r=Et)||s.memoizedState!==null,mn(e,t,s),Et=r):mn(e,t,s);break;default:mn(e,t,s)}}function uf(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var s=e.stateNode;s===null&&(s=e.stateNode=new bj),t.forEach(function(r){var a=Tj.bind(null,e,r);s.has(r)||(s.add(r),r.then(a,a))})}}function xs(e,t){var s=t.deletions;if(s!==null)for(var r=0;r<s.length;r++){var a=s[r];try{var i=e,l=t,o=l;e:for(;o!==null;){switch(o.tag){case 5:bt=o.stateNode,bs=!1;break e;case 3:bt=o.stateNode.containerInfo,bs=!0;break e;case 4:bt=o.stateNode.containerInfo,bs=!0;break e}o=o.return}if(bt===null)throw Error(q(160));Lx(i,l,a),bt=null,bs=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(u){Je(a,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)Rx(t,e),t=t.sibling}function Rx(e,t){var s=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(xs(t,e),Ps(e),r&4){try{ni(3,e,e.return),Po(3,e)}catch(g){Je(e,e.return,g)}try{ni(5,e,e.return)}catch(g){Je(e,e.return,g)}}break;case 1:xs(t,e),Ps(e),r&512&&s!==null&&Vr(s,s.return);break;case 5:if(xs(t,e),Ps(e),r&512&&s!==null&&Vr(s,s.return),e.flags&32){var a=e.stateNode;try{ui(a,"")}catch(g){Je(e,e.return,g)}}if(r&4&&(a=e.stateNode,a!=null)){var i=e.memoizedProps,l=s!==null?s.memoizedProps:i,o=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{o==="input"&&i.type==="radio"&&i.name!=null&&rg(a,i),Wc(o,l);var u=Wc(o,i);for(l=0;l<c.length;l+=2){var d=c[l],m=c[l+1];d==="style"?cg(a,m):d==="dangerouslySetInnerHTML"?lg(a,m):d==="children"?ui(a,m):ud(a,d,m,u)}switch(o){case"input":Kc(a,i);break;case"textarea":ag(a,i);break;case"select":var p=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var h=i.value;h!=null?Hr(a,!!i.multiple,h,!1):p!==!!i.multiple&&(i.defaultValue!=null?Hr(a,!!i.multiple,i.defaultValue,!0):Hr(a,!!i.multiple,i.multiple?[]:"",!1))}a[vi]=i}catch(g){Je(e,e.return,g)}}break;case 6:if(xs(t,e),Ps(e),r&4){if(e.stateNode===null)throw Error(q(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(g){Je(e,e.return,g)}}break;case 3:if(xs(t,e),Ps(e),r&4&&s!==null&&s.memoizedState.isDehydrated)try{fi(t.containerInfo)}catch(g){Je(e,e.return,g)}break;case 4:xs(t,e),Ps(e);break;case 13:xs(t,e),Ps(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(Kd=et())),r&4&&uf(e);break;case 22:if(d=s!==null&&s.memoizedState!==null,e.mode&1?(Et=(u=Et)||d,xs(t,e),Et=u):xs(t,e),Ps(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!d&&e.mode&1)for(re=e,d=e.child;d!==null;){for(m=re=d;re!==null;){switch(p=re,h=p.child,p.tag){case 0:case 11:case 14:case 15:ni(4,p,p.return);break;case 1:Vr(p,p.return);var f=p.stateNode;if(typeof f.componentWillUnmount=="function"){r=p,s=p.return;try{t=r,f.props=t.memoizedProps,f.state=t.memoizedState,f.componentWillUnmount()}catch(g){Je(r,s,g)}}break;case 5:Vr(p,p.return);break;case 22:if(p.memoizedState!==null){hf(m);continue}}h!==null?(h.return=p,re=h):hf(m)}d=d.sibling}e:for(d=null,m=e;;){if(m.tag===5){if(d===null){d=m;try{a=m.stateNode,u?(i=a.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(o=m.stateNode,c=m.memoizedProps.style,l=c!=null&&c.hasOwnProperty("display")?c.display:null,o.style.display=og("display",l))}catch(g){Je(e,e.return,g)}}}else if(m.tag===6){if(d===null)try{m.stateNode.nodeValue=u?"":m.memoizedProps}catch(g){Je(e,e.return,g)}}else if((m.tag!==22&&m.tag!==23||m.memoizedState===null||m===e)&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===e)break e;for(;m.sibling===null;){if(m.return===null||m.return===e)break e;d===m&&(d=null),m=m.return}d===m&&(d=null),m.sibling.return=m.return,m=m.sibling}}break;case 19:xs(t,e),Ps(e),r&4&&uf(e);break;case 21:break;default:xs(t,e),Ps(e)}}function Ps(e){var t=e.flags;if(t&2){try{e:{for(var s=e.return;s!==null;){if(Mx(s)){var r=s;break e}s=s.return}throw Error(q(160))}switch(r.tag){case 5:var a=r.stateNode;r.flags&32&&(ui(a,""),r.flags&=-33);var i=cf(e);Su(e,i,a);break;case 3:case 4:var l=r.stateNode.containerInfo,o=cf(e);wu(e,o,l);break;default:throw Error(q(161))}}catch(c){Je(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function wj(e,t,s){re=e,Ox(e)}function Ox(e,t,s){for(var r=(e.mode&1)!==0;re!==null;){var a=re,i=a.child;if(a.tag===22&&r){var l=a.memoizedState!==null||gl;if(!l){var o=a.alternate,c=o!==null&&o.memoizedState!==null||Et;o=gl;var u=Et;if(gl=l,(Et=c)&&!u)for(re=a;re!==null;)l=re,c=l.child,l.tag===22&&l.memoizedState!==null?mf(a):c!==null?(c.return=l,re=c):mf(a);for(;i!==null;)re=i,Ox(i),i=i.sibling;re=a,gl=o,Et=u}df(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,re=i):df(e)}}function df(e){for(;re!==null;){var t=re;if(t.flags&8772){var s=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Et||Po(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Et)if(s===null)r.componentDidMount();else{var a=t.elementType===t.type?s.memoizedProps:ys(t.type,s.memoizedProps);r.componentDidUpdate(a,s.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Wm(t,i,r);break;case 3:var l=t.updateQueue;if(l!==null){if(s=null,t.child!==null)switch(t.child.tag){case 5:s=t.child.stateNode;break;case 1:s=t.child.stateNode}Wm(t,l,s)}break;case 5:var o=t.stateNode;if(s===null&&t.flags&4){s=o;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&s.focus();break;case"img":c.src&&(s.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var d=u.memoizedState;if(d!==null){var m=d.dehydrated;m!==null&&fi(m)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(q(163))}Et||t.flags&512&&Nu(t)}catch(p){Je(t,t.return,p)}}if(t===e){re=null;break}if(s=t.sibling,s!==null){s.return=t.return,re=s;break}re=t.return}}function hf(e){for(;re!==null;){var t=re;if(t===e){re=null;break}var s=t.sibling;if(s!==null){s.return=t.return,re=s;break}re=t.return}}function mf(e){for(;re!==null;){var t=re;try{switch(t.tag){case 0:case 11:case 15:var s=t.return;try{Po(4,t)}catch(c){Je(t,s,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var a=t.return;try{r.componentDidMount()}catch(c){Je(t,a,c)}}var i=t.return;try{Nu(t)}catch(c){Je(t,i,c)}break;case 5:var l=t.return;try{Nu(t)}catch(c){Je(t,l,c)}}}catch(c){Je(t,t.return,c)}if(t===e){re=null;break}var o=t.sibling;if(o!==null){o.return=t.return,re=o;break}re=t.return}}var Sj=Math.ceil,ro=cn.ReactCurrentDispatcher,$d=cn.ReactCurrentOwner,ms=cn.ReactCurrentBatchConfig,De=0,jt=null,rt=null,wt=0,es=0,qr=Hn(0),ut=0,ki=null,vr=0,Ao=0,Bd=0,ri=null,qt=null,Kd=0,va=1/0,qs=null,ao=!1,ku=null,_n=null,xl=!1,Tn=null,io=0,ai=0,Cu=null,Tl=-1,Fl=0;function Ot(){return De&6?et():Tl!==-1?Tl:Tl=et()}function zn(e){return e.mode&1?De&2&&wt!==0?wt&-wt:lj.transition!==null?(Fl===0&&(Fl=bg()),Fl):(e=Ie,e!==0||(e=window.event,e=e===void 0?16:Dg(e.type)),e):1}function Cs(e,t,s,r){if(50<ai)throw ai=0,Cu=null,Error(q(185));Bi(e,s,r),(!(De&2)||e!==jt)&&(e===jt&&(!(De&2)&&(Ao|=s),ut===4&&vn(e,wt)),Gt(e,r),s===1&&De===0&&!(t.mode&1)&&(va=et()+500,Co&&Wn()))}function Gt(e,t){var s=e.callbackNode;l0(e,t);var r=Kl(e,e===jt?wt:0);if(r===0)s!==null&&bm(s),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(s!=null&&bm(s),t===1)e.tag===0?ij(ff.bind(null,e)):Hg(ff.bind(null,e)),sj(function(){!(De&6)&&Wn()}),s=null;else{switch(Ng(r)){case 1:s=pd;break;case 4:s=vg;break;case 16:s=Bl;break;case 536870912:s=jg;break;default:s=Bl}s=qx(s,_x.bind(null,e))}e.callbackPriority=t,e.callbackNode=s}}function _x(e,t){if(Tl=-1,Fl=0,De&6)throw Error(q(327));var s=e.callbackNode;if(Jr()&&e.callbackNode!==s)return null;var r=Kl(e,e===jt?wt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=lo(e,r);else{t=r;var a=De;De|=2;var i=Ux();(jt!==e||wt!==t)&&(qs=null,va=et()+500,mr(e,t));do try{Ej();break}catch(o){zx(e,o)}while(!0);Dd(),ro.current=i,De=a,rt!==null?t=0:(jt=null,wt=0,t=ut)}if(t!==0){if(t===2&&(a=Xc(e),a!==0&&(r=a,t=Eu(e,a))),t===1)throw s=ki,mr(e,0),vn(e,r),Gt(e,et()),s;if(t===6)vn(e,r);else{if(a=e.current.alternate,!(r&30)&&!kj(a)&&(t=lo(e,r),t===2&&(i=Xc(e),i!==0&&(r=i,t=Eu(e,i))),t===1))throw s=ki,mr(e,0),vn(e,r),Gt(e,et()),s;switch(e.finishedWork=a,e.finishedLanes=r,t){case 0:case 1:throw Error(q(345));case 2:Yn(e,qt,qs);break;case 3:if(vn(e,r),(r&130023424)===r&&(t=Kd+500-et(),10<t)){if(Kl(e,0)!==0)break;if(a=e.suspendedLanes,(a&r)!==r){Ot(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=lu(Yn.bind(null,e,qt,qs),t);break}Yn(e,qt,qs);break;case 4:if(vn(e,r),(r&4194240)===r)break;for(t=e.eventTimes,a=-1;0<r;){var l=31-ks(r);i=1<<l,l=t[l],l>a&&(a=l),r&=~i}if(r=a,r=et()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Sj(r/1960))-r,10<r){e.timeoutHandle=lu(Yn.bind(null,e,qt,qs),r);break}Yn(e,qt,qs);break;case 5:Yn(e,qt,qs);break;default:throw Error(q(329))}}}return Gt(e,et()),e.callbackNode===s?_x.bind(null,e):null}function Eu(e,t){var s=ri;return e.current.memoizedState.isDehydrated&&(mr(e,t).flags|=256),e=lo(e,t),e!==2&&(t=qt,qt=s,t!==null&&Du(t)),e}function Du(e){qt===null?qt=e:qt.push.apply(qt,e)}function kj(e){for(var t=e;;){if(t.flags&16384){var s=t.updateQueue;if(s!==null&&(s=s.stores,s!==null))for(var r=0;r<s.length;r++){var a=s[r],i=a.getSnapshot;a=a.value;try{if(!Es(i(),a))return!1}catch{return!1}}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function vn(e,t){for(t&=~Bd,t&=~Ao,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var s=31-ks(t),r=1<<s;e[s]=-1,t&=~r}}function ff(e){if(De&6)throw Error(q(327));Jr();var t=Kl(e,0);if(!(t&1))return Gt(e,et()),null;var s=lo(e,t);if(e.tag!==0&&s===2){var r=Xc(e);r!==0&&(t=r,s=Eu(e,r))}if(s===1)throw s=ki,mr(e,0),vn(e,t),Gt(e,et()),s;if(s===6)throw Error(q(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Yn(e,qt,qs),Gt(e,et()),null}function Vd(e,t){var s=De;De|=1;try{return e(t)}finally{De=s,De===0&&(va=et()+500,Co&&Wn())}}function jr(e){Tn!==null&&Tn.tag===0&&!(De&6)&&Jr();var t=De;De|=1;var s=ms.transition,r=Ie;try{if(ms.transition=null,Ie=1,e)return e()}finally{Ie=r,ms.transition=s,De=t,!(De&6)&&Wn()}}function qd(){es=qr.current,ze(qr)}function mr(e,t){e.finishedWork=null,e.finishedLanes=0;var s=e.timeoutHandle;if(s!==-1&&(e.timeoutHandle=-1,tj(s)),rt!==null)for(s=rt.return;s!==null;){var r=s;switch(kd(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Wl();break;case 3:xa(),ze(Ht),ze(At),Md();break;case 5:Id(r);break;case 4:xa();break;case 13:ze(Ve);break;case 19:ze(Ve);break;case 10:Pd(r.type._context);break;case 22:case 23:qd()}s=s.return}if(jt=e,rt=e=Un(e.current,null),wt=es=t,ut=0,ki=null,Bd=Ao=vr=0,qt=ri=null,Xn!==null){for(t=0;t<Xn.length;t++)if(s=Xn[t],r=s.interleaved,r!==null){s.interleaved=null;var a=r.next,i=s.pending;if(i!==null){var l=i.next;i.next=a,r.next=l}s.pending=r}Xn=null}return e}function zx(e,t){do{var s=rt;try{if(Dd(),Dl.current=no,so){for(var r=qe.memoizedState;r!==null;){var a=r.queue;a!==null&&(a.pending=null),r=r.next}so=!1}if(yr=0,gt=ot=qe=null,si=!1,Ni=0,$d.current=null,s===null||s.return===null){ut=1,ki=t,rt=null;break}e:{var i=e,l=s.return,o=s,c=t;if(t=wt,o.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,d=o,m=d.tag;if(!(d.mode&1)&&(m===0||m===11||m===15)){var p=d.alternate;p?(d.updateQueue=p.updateQueue,d.memoizedState=p.memoizedState,d.lanes=p.lanes):(d.updateQueue=null,d.memoizedState=null)}var h=ef(l);if(h!==null){h.flags&=-257,tf(h,l,o,i,t),h.mode&1&&Xm(i,u,t),t=h,c=u;var f=t.updateQueue;if(f===null){var g=new Set;g.add(c),t.updateQueue=g}else f.add(c);break e}else{if(!(t&1)){Xm(i,u,t),Qd();break e}c=Error(q(426))}}else if(Be&&o.mode&1){var b=ef(l);if(b!==null){!(b.flags&65536)&&(b.flags|=256),tf(b,l,o,i,t),Cd(ya(c,o));break e}}i=c=ya(c,o),ut!==4&&(ut=2),ri===null?ri=[i]:ri.push(i),i=l;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=Nx(i,c,t);Hm(i,y);break e;case 1:o=c;var v=i.type,x=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(_n===null||!_n.has(x)))){i.flags|=65536,t&=-t,i.lanes|=t;var N=wx(i,o,t);Hm(i,N);break e}}i=i.return}while(i!==null)}Bx(s)}catch(k){t=k,rt===s&&s!==null&&(rt=s=s.return);continue}break}while(!0)}function Ux(){var e=ro.current;return ro.current=no,e===null?no:e}function Qd(){(ut===0||ut===3||ut===2)&&(ut=4),jt===null||!(vr&268435455)&&!(Ao&268435455)||vn(jt,wt)}function lo(e,t){var s=De;De|=2;var r=Ux();(jt!==e||wt!==t)&&(qs=null,mr(e,t));do try{Cj();break}catch(a){zx(e,a)}while(!0);if(Dd(),De=s,ro.current=r,rt!==null)throw Error(q(261));return jt=null,wt=0,ut}function Cj(){for(;rt!==null;)$x(rt)}function Ej(){for(;rt!==null&&!Jv();)$x(rt)}function $x(e){var t=Vx(e.alternate,e,es);e.memoizedProps=e.pendingProps,t===null?Bx(e):rt=t,$d.current=null}function Bx(e){var t=e;do{var s=t.alternate;if(e=t.return,t.flags&32768){if(s=jj(s,t),s!==null){s.flags&=32767,rt=s;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{ut=6,rt=null;return}}else if(s=vj(s,t,es),s!==null){rt=s;return}if(t=t.sibling,t!==null){rt=t;return}rt=t=e}while(t!==null);ut===0&&(ut=5)}function Yn(e,t,s){var r=Ie,a=ms.transition;try{ms.transition=null,Ie=1,Dj(e,t,s,r)}finally{ms.transition=a,Ie=r}return null}function Dj(e,t,s,r){do Jr();while(Tn!==null);if(De&6)throw Error(q(327));s=e.finishedWork;var a=e.finishedLanes;if(s===null)return null;if(e.finishedWork=null,e.finishedLanes=0,s===e.current)throw Error(q(177));e.callbackNode=null,e.callbackPriority=0;var i=s.lanes|s.childLanes;if(o0(e,i),e===jt&&(rt=jt=null,wt=0),!(s.subtreeFlags&2064)&&!(s.flags&2064)||xl||(xl=!0,qx(Bl,function(){return Jr(),null})),i=(s.flags&15990)!==0,s.subtreeFlags&15990||i){i=ms.transition,ms.transition=null;var l=Ie;Ie=1;var o=De;De|=4,$d.current=null,Nj(e,s),Rx(s,e),W0(au),Vl=!!ru,au=ru=null,e.current=s,wj(s),Xv(),De=o,Ie=l,ms.transition=i}else e.current=s;if(xl&&(xl=!1,Tn=e,io=a),i=e.pendingLanes,i===0&&(_n=null),s0(s.stateNode),Gt(e,et()),t!==null)for(r=e.onRecoverableError,s=0;s<t.length;s++)a=t[s],r(a.value,{componentStack:a.stack,digest:a.digest});if(ao)throw ao=!1,e=ku,ku=null,e;return io&1&&e.tag!==0&&Jr(),i=e.pendingLanes,i&1?e===Cu?ai++:(ai=0,Cu=e):ai=0,Wn(),null}function Jr(){if(Tn!==null){var e=Ng(io),t=ms.transition,s=Ie;try{if(ms.transition=null,Ie=16>e?16:e,Tn===null)var r=!1;else{if(e=Tn,Tn=null,io=0,De&6)throw Error(q(331));var a=De;for(De|=4,re=e.current;re!==null;){var i=re,l=i.child;if(re.flags&16){var o=i.deletions;if(o!==null){for(var c=0;c<o.length;c++){var u=o[c];for(re=u;re!==null;){var d=re;switch(d.tag){case 0:case 11:case 15:ni(8,d,i)}var m=d.child;if(m!==null)m.return=d,re=m;else for(;re!==null;){d=re;var p=d.sibling,h=d.return;if(Ix(d),d===u){re=null;break}if(p!==null){p.return=h,re=p;break}re=h}}}var f=i.alternate;if(f!==null){var g=f.child;if(g!==null){f.child=null;do{var b=g.sibling;g.sibling=null,g=b}while(g!==null)}}re=i}}if(i.subtreeFlags&2064&&l!==null)l.return=i,re=l;else e:for(;re!==null;){if(i=re,i.flags&2048)switch(i.tag){case 0:case 11:case 15:ni(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,re=y;break e}re=i.return}}var v=e.current;for(re=v;re!==null;){l=re;var x=l.child;if(l.subtreeFlags&2064&&x!==null)x.return=l,re=x;else e:for(l=v;re!==null;){if(o=re,o.flags&2048)try{switch(o.tag){case 0:case 11:case 15:Po(9,o)}}catch(k){Je(o,o.return,k)}if(o===l){re=null;break e}var N=o.sibling;if(N!==null){N.return=o.return,re=N;break e}re=o.return}}if(De=a,Wn(),Os&&typeof Os.onPostCommitFiberRoot=="function")try{Os.onPostCommitFiberRoot(bo,e)}catch{}r=!0}return r}finally{Ie=s,ms.transition=t}}return!1}function pf(e,t,s){t=ya(s,t),t=Nx(e,t,1),e=On(e,t,1),t=Ot(),e!==null&&(Bi(e,1,t),Gt(e,t))}function Je(e,t,s){if(e.tag===3)pf(e,e,s);else for(;t!==null;){if(t.tag===3){pf(t,e,s);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(_n===null||!_n.has(r))){e=ya(s,e),e=wx(t,e,1),t=On(t,e,1),e=Ot(),t!==null&&(Bi(t,1,e),Gt(t,e));break}}t=t.return}}function Pj(e,t,s){var r=e.pingCache;r!==null&&r.delete(t),t=Ot(),e.pingedLanes|=e.suspendedLanes&s,jt===e&&(wt&s)===s&&(ut===4||ut===3&&(wt&130023424)===wt&&500>et()-Kd?mr(e,0):Bd|=s),Gt(e,t)}function Kx(e,t){t===0&&(e.mode&1?(t=ll,ll<<=1,!(ll&130023424)&&(ll=4194304)):t=1);var s=Ot();e=ln(e,t),e!==null&&(Bi(e,t,s),Gt(e,s))}function Aj(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),Kx(e,s)}function Tj(e,t){var s=0;switch(e.tag){case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(s=a.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(q(314))}r!==null&&r.delete(t),Kx(e,s)}var Vx;Vx=function(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ht.current)Qt=!0;else{if(!(e.lanes&s)&&!(t.flags&128))return Qt=!1,yj(e,t,s);Qt=!!(e.flags&131072)}else Qt=!1,Be&&t.flags&1048576&&Wg(t,Yl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Al(e,t),e=t.pendingProps;var a=fa(t,At.current);Yr(t,s),a=Rd(null,t,r,e,a,s);var i=Od();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Wt(r)?(i=!0,Gl(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,Td(t),a.updater=Do,t.stateNode=a,a._reactInternals=t,fu(t,r,e,s),t=xu(null,t,r,!0,i,s)):(t.tag=0,Be&&i&&Sd(t),Lt(null,t,a,s),t=t.child),t;case 16:r=t.elementType;e:{switch(Al(e,t),e=t.pendingProps,a=r._init,r=a(r._payload),t.type=r,a=t.tag=Ij(r),e=ys(r,e),a){case 0:t=gu(null,t,r,e,s);break e;case 1:t=rf(null,t,r,e,s);break e;case 11:t=sf(null,t,r,e,s);break e;case 14:t=nf(null,t,r,ys(r.type,e),s);break e}throw Error(q(306,r,""))}return t;case 0:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:ys(r,a),gu(e,t,r,a,s);case 1:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:ys(r,a),rf(e,t,r,a,s);case 3:e:{if(Ex(t),e===null)throw Error(q(387));r=t.pendingProps,i=t.memoizedState,a=i.element,ex(e,t),eo(t,r,null,s);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){a=ya(Error(q(423)),t),t=af(e,t,r,s,a);break e}else if(r!==a){a=ya(Error(q(424)),t),t=af(e,t,r,s,a);break e}else for(ss=Rn(t.stateNode.containerInfo.firstChild),ns=t,Be=!0,Ns=null,s=Jg(t,null,r,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(pa(),r===a){t=on(e,t,s);break e}Lt(e,t,r,s)}t=t.child}return t;case 5:return tx(t),e===null&&du(t),r=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,l=a.children,iu(r,a)?l=null:i!==null&&iu(r,i)&&(t.flags|=32),Cx(e,t),Lt(e,t,l,s),t.child;case 6:return e===null&&du(t),null;case 13:return Dx(e,t,s);case 4:return Fd(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ga(t,null,r,s):Lt(e,t,r,s),t.child;case 11:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:ys(r,a),sf(e,t,r,a,s);case 7:return Lt(e,t,t.pendingProps,s),t.child;case 8:return Lt(e,t,t.pendingProps.children,s),t.child;case 12:return Lt(e,t,t.pendingProps.children,s),t.child;case 10:e:{if(r=t.type._context,a=t.pendingProps,i=t.memoizedProps,l=a.value,Re(Jl,r._currentValue),r._currentValue=l,i!==null)if(Es(i.value,l)){if(i.children===a.children&&!Ht.current){t=on(e,t,s);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=sn(-1,s&-s),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=s,c=i.alternate,c!==null&&(c.lanes|=s),hu(i.return,s,t),o.lanes|=s;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(q(341));l.lanes|=s,o=l.alternate,o!==null&&(o.lanes|=s),hu(l,s,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}Lt(e,t,a.children,s),t=t.child}return t;case 9:return a=t.type,r=t.pendingProps.children,Yr(t,s),a=fs(a),r=r(a),t.flags|=1,Lt(e,t,r,s),t.child;case 14:return r=t.type,a=ys(r,t.pendingProps),a=ys(r.type,a),nf(e,t,r,a,s);case 15:return Sx(e,t,t.type,t.pendingProps,s);case 17:return r=t.type,a=t.pendingProps,a=t.elementType===r?a:ys(r,a),Al(e,t),t.tag=1,Wt(r)?(e=!0,Gl(t)):e=!1,Yr(t,s),bx(t,r,a),fu(t,r,a,s),xu(null,t,r,!0,e,s);case 19:return Px(e,t,s);case 22:return kx(e,t,s)}throw Error(q(156,t.tag))};function qx(e,t){return yg(e,t)}function Fj(e,t,s,r){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ds(e,t,s,r){return new Fj(e,t,s,r)}function Hd(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ij(e){if(typeof e=="function")return Hd(e)?1:0;if(e!=null){if(e=e.$$typeof,e===hd)return 11;if(e===md)return 14}return 2}function Un(e,t){var s=e.alternate;return s===null?(s=ds(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&14680064,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s}function Il(e,t,s,r,a,i){var l=2;if(r=e,typeof e=="function")Hd(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case Lr:return fr(s.children,a,i,t);case dd:l=8,a|=8;break;case _c:return e=ds(12,s,t,a|2),e.elementType=_c,e.lanes=i,e;case zc:return e=ds(13,s,t,a),e.elementType=zc,e.lanes=i,e;case Uc:return e=ds(19,s,t,a),e.elementType=Uc,e.lanes=i,e;case tg:return To(s,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Xp:l=10;break e;case eg:l=9;break e;case hd:l=11;break e;case md:l=14;break e;case pn:l=16,r=null;break e}throw Error(q(130,e==null?e:typeof e,""))}return t=ds(l,s,t,a),t.elementType=e,t.type=r,t.lanes=i,t}function fr(e,t,s,r){return e=ds(7,e,r,t),e.lanes=s,e}function To(e,t,s,r){return e=ds(22,e,r,t),e.elementType=tg,e.lanes=s,e.stateNode={isHidden:!1},e}function wc(e,t,s){return e=ds(6,e,null,t),e.lanes=s,e}function Sc(e,t,s){return t=ds(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Mj(e,t,s,r,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=rc(0),this.expirationTimes=rc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rc(0),this.identifierPrefix=r,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function Wd(e,t,s,r,a,i,l,o,c){return e=new Mj(e,t,s,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ds(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:s,cache:null,transitions:null,pendingSuspenseBoundaries:null},Td(i),e}function Lj(e,t,s){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Mr,key:r==null?null:""+r,children:e,containerInfo:t,implementation:s}}function Qx(e){if(!e)return Vn;e=e._reactInternals;e:{if(Cr(e)!==e||e.tag!==1)throw Error(q(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Wt(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(q(171))}if(e.tag===1){var s=e.type;if(Wt(s))return Qg(e,s,t)}return t}function Hx(e,t,s,r,a,i,l,o,c){return e=Wd(s,r,!0,e,a,i,l,o,c),e.context=Qx(null),s=e.current,r=Ot(),a=zn(s),i=sn(r,a),i.callback=t??null,On(s,i,a),e.current.lanes=a,Bi(e,a,r),Gt(e,r),e}function Fo(e,t,s,r){var a=t.current,i=Ot(),l=zn(a);return s=Qx(s),t.context===null?t.context=s:t.pendingContext=s,t=sn(i,l),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=On(a,t,l),e!==null&&(Cs(e,a,l,i),El(e,a,l)),l}function oo(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function gf(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function Gd(e,t){gf(e,t),(e=e.alternate)&&gf(e,t)}function Rj(){return null}var Wx=typeof reportError=="function"?reportError:function(e){console.error(e)};function Zd(e){this._internalRoot=e}Io.prototype.render=Zd.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(q(409));Fo(e,t,null,null)};Io.prototype.unmount=Zd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;jr(function(){Fo(null,e,null,null)}),t[an]=null}};function Io(e){this._internalRoot=e}Io.prototype.unstable_scheduleHydration=function(e){if(e){var t=kg();e={blockedOn:null,target:e,priority:t};for(var s=0;s<yn.length&&t!==0&&t<yn[s].priority;s++);yn.splice(s,0,e),s===0&&Eg(e)}};function Yd(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Mo(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function xf(){}function Oj(e,t,s,r,a){if(a){if(typeof r=="function"){var i=r;r=function(){var u=oo(l);i.call(u)}}var l=Hx(t,r,e,0,null,!1,!1,"",xf);return e._reactRootContainer=l,e[an]=l.current,xi(e.nodeType===8?e.parentNode:e),jr(),l}for(;a=e.lastChild;)e.removeChild(a);if(typeof r=="function"){var o=r;r=function(){var u=oo(c);o.call(u)}}var c=Wd(e,0,!1,null,null,!1,!1,"",xf);return e._reactRootContainer=c,e[an]=c.current,xi(e.nodeType===8?e.parentNode:e),jr(function(){Fo(t,c,s,r)}),c}function Lo(e,t,s,r,a){var i=s._reactRootContainer;if(i){var l=i;if(typeof a=="function"){var o=a;a=function(){var c=oo(l);o.call(c)}}Fo(t,l,e,a)}else l=Oj(s,t,e,a,r);return oo(l)}wg=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var s=Ha(t.pendingLanes);s!==0&&(gd(t,s|1),Gt(t,et()),!(De&6)&&(va=et()+500,Wn()))}break;case 13:jr(function(){var r=ln(e,1);if(r!==null){var a=Ot();Cs(r,e,1,a)}}),Gd(e,1)}};xd=function(e){if(e.tag===13){var t=ln(e,134217728);if(t!==null){var s=Ot();Cs(t,e,134217728,s)}Gd(e,134217728)}};Sg=function(e){if(e.tag===13){var t=zn(e),s=ln(e,t);if(s!==null){var r=Ot();Cs(s,e,t,r)}Gd(e,t)}};kg=function(){return Ie};Cg=function(e,t){var s=Ie;try{return Ie=e,t()}finally{Ie=s}};Zc=function(e,t,s){switch(t){case"input":if(Kc(e,s),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<s.length;t++){var r=s[t];if(r!==e&&r.form===e.form){var a=ko(r);if(!a)throw Error(q(90));ng(r),Kc(r,a)}}}break;case"textarea":ag(e,s);break;case"select":t=s.value,t!=null&&Hr(e,!!s.multiple,t,!1)}};hg=Vd;mg=jr;var _j={usingClientEntryPoint:!1,Events:[Vi,zr,ko,ug,dg,Vd]},Ba={findFiberByHostInstance:Jn,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},zj={bundleType:Ba.bundleType,version:Ba.version,rendererPackageName:Ba.rendererPackageName,rendererConfig:Ba.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:cn.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=gg(e),e===null?null:e.stateNode},findFiberByHostInstance:Ba.findFiberByHostInstance||Rj,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 yl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yl.isDisabled&&yl.supportsFiber)try{bo=yl.inject(zj),Os=yl}catch{}}as.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=_j;as.createPortal=function(e,t){var s=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Yd(t))throw Error(q(200));return Lj(e,t,null,s)};as.createRoot=function(e,t){if(!Yd(e))throw Error(q(299));var s=!1,r="",a=Wx;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=Wd(e,1,!1,null,null,s,!1,r,a),e[an]=t.current,xi(e.nodeType===8?e.parentNode:e),new Zd(t)};as.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(q(188)):(e=Object.keys(e).join(","),Error(q(268,e)));return e=gg(t),e=e===null?null:e.stateNode,e};as.flushSync=function(e){return jr(e)};as.hydrate=function(e,t,s){if(!Mo(t))throw Error(q(200));return Lo(null,e,t,!0,s)};as.hydrateRoot=function(e,t,s){if(!Yd(e))throw Error(q(405));var r=s!=null&&s.hydratedSources||null,a=!1,i="",l=Wx;if(s!=null&&(s.unstable_strictMode===!0&&(a=!0),s.identifierPrefix!==void 0&&(i=s.identifierPrefix),s.onRecoverableError!==void 0&&(l=s.onRecoverableError)),t=Hx(t,null,e,1,s??null,a,!1,i,l),e[an]=t.current,xi(e),r)for(e=0;e<r.length;e++)s=r[e],a=s._getVersion,a=a(s._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[s,a]:t.mutableSourceEagerHydrationData.push(s,a);return new Io(t)};as.render=function(e,t,s){if(!Mo(t))throw Error(q(200));return Lo(null,e,t,!1,s)};as.unmountComponentAtNode=function(e){if(!Mo(e))throw Error(q(40));return e._reactRootContainer?(jr(function(){Lo(null,null,e,!1,function(){e._reactRootContainer=null,e[an]=null})}),!0):!1};as.unstable_batchedUpdates=Vd;as.unstable_renderSubtreeIntoContainer=function(e,t,s,r){if(!Mo(s))throw Error(q(200));if(e==null||e._reactInternals===void 0)throw Error(q(38));return Lo(e,t,s,!1,r)};as.version="18.3.1-next-f1338f8080-20240426";function Gx(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Gx)}catch(e){console.error(e)}}Gx(),Gp.exports=as;var Uj=Gp.exports,yf=Uj;Rc.createRoot=yf.createRoot,Rc.hydrateRoot=yf.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 Ci(){return Ci=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])}return e},Ci.apply(this,arguments)}var Fn;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(Fn||(Fn={}));const vf="popstate";function $j(e){e===void 0&&(e={});function t(r,a){let{pathname:i,search:l,hash:o}=r.location;return Pu("",{pathname:i,search:l,hash:o},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function s(r,a){return typeof a=="string"?a:co(a)}return Kj(t,s,null,e)}function Qe(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Jd(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Bj(){return Math.random().toString(36).substr(2,8)}function jf(e,t){return{usr:e.state,key:e.key,idx:t}}function Pu(e,t,s,r){return s===void 0&&(s=null),Ci({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Ea(t):t,{state:s,key:t&&t.key||r||Bj()})}function co(e){let{pathname:t="/",search:s="",hash:r=""}=e;return s&&s!=="?"&&(t+=s.charAt(0)==="?"?s:"?"+s),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function Ea(e){let t={};if(e){let s=e.indexOf("#");s>=0&&(t.hash=e.substr(s),e=e.substr(0,s));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function Kj(e,t,s,r){r===void 0&&(r={});let{window:a=document.defaultView,v5Compat:i=!1}=r,l=a.history,o=Fn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Ci({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function m(){o=Fn.Pop;let b=d(),y=b==null?null:b-u;u=b,c&&c({action:o,location:g.location,delta:y})}function p(b,y){o=Fn.Push;let v=Pu(g.location,b,y);u=d()+1;let x=jf(v,u),N=g.createHref(v);try{l.pushState(x,"",N)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;a.location.assign(N)}i&&c&&c({action:o,location:g.location,delta:1})}function h(b,y){o=Fn.Replace;let v=Pu(g.location,b,y);u=d();let x=jf(v,u),N=g.createHref(v);l.replaceState(x,"",N),i&&c&&c({action:o,location:g.location,delta:0})}function f(b){let y=a.location.origin!=="null"?a.location.origin:a.location.href,v=typeof b=="string"?b:co(b);return v=v.replace(/ $/,"%20"),Qe(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 e(a,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(vf,m),c=b,()=>{a.removeEventListener(vf,m),c=null}},createHref(b){return t(a,b)},createURL:f,encodeLocation(b){let y=f(b);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:p,replace:h,go(b){return l.go(b)}};return g}var bf;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(bf||(bf={}));function Vj(e,t,s){return s===void 0&&(s="/"),qj(e,t,s)}function qj(e,t,s,r){let a=typeof t=="string"?Ea(t):t,i=ja(a.pathname||"/",s);if(i==null)return null;let l=Zx(e);Qj(l);let o=null;for(let c=0;o==null&&c<l.length;++c){let u=nb(i);o=tb(l[c],u)}return o}function Zx(e,t,s,r){t===void 0&&(t=[]),s===void 0&&(s=[]),r===void 0&&(r="");let a=(i,l,o)=>{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(Qe(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let u=$n([r,c.relativePath]),d=s.concat(c);i.children&&i.children.length>0&&(Qe(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),Zx(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:Xj(u,i.index),routesMeta:d})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))a(i,l);else for(let c of Yx(i.path))a(i,l,c)}),t}function Yx(e){let t=e.split("/");if(t.length===0)return[];let[s,...r]=t,a=s.endsWith("?"),i=s.replace(/\?$/,"");if(r.length===0)return a?[i,""]:[i];let l=Yx(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),a&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function Qj(e){e.sort((t,s)=>t.score!==s.score?s.score-t.score:eb(t.routesMeta.map(r=>r.childrenIndex),s.routesMeta.map(r=>r.childrenIndex)))}const Hj=/^:[\w-]+$/,Wj=3,Gj=2,Zj=1,Yj=10,Jj=-2,Nf=e=>e==="*";function Xj(e,t){let s=e.split("/"),r=s.length;return s.some(Nf)&&(r+=Jj),t&&(r+=Gj),s.filter(a=>!Nf(a)).reduce((a,i)=>a+(Hj.test(i)?Wj:i===""?Zj:Yj),r)}function eb(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function tb(e,t,s){let{routesMeta:r}=e,a={},i="/",l=[];for(let o=0;o<r.length;++o){let c=r[o],u=o===r.length-1,d=i==="/"?t:t.slice(i.length)||"/",m=Au({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!m)return null;Object.assign(a,m.params),l.push({params:a,pathname:$n([i,m.pathname]),pathnameBase:ob($n([i,m.pathnameBase])),route:p}),m.pathnameBase!=="/"&&(i=$n([i,m.pathnameBase]))}return l}function Au(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[s,r]=sb(e.path,e.caseSensitive,e.end),a=t.match(s);if(!a)return null;let i=a[0],l=i.replace(/(.)\/+$/,"$1"),o=a.slice(1);return{params:r.reduce((u,d,m)=>{let{paramName:p,isOptional:h}=d;if(p==="*"){let g=o[m]||"";l=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const f=o[m];return h&&!f?u[p]=void 0:u[p]=(f||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function sb(e,t,s){t===void 0&&(t=!1),s===void 0&&(s=!0),Jd(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function nb(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Jd(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function ja(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let s=t.endsWith("/")?t.length-1:t.length,r=e.charAt(s);return r&&r!=="/"?null:e.slice(s)||"/"}const rb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ab=e=>rb.test(e);function ib(e,t){t===void 0&&(t="/");let{pathname:s,search:r="",hash:a=""}=typeof e=="string"?Ea(e):e,i;if(s)if(ab(s))i=s;else{if(s.includes("//")){let l=s;s=s.replace(/\/\/+/g,"/"),Jd(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+s))}s.startsWith("/")?i=wf(s.substring(1),"/"):i=wf(s,t)}else i=t;return{pathname:i,search:cb(r),hash:ub(a)}}function wf(e,t){let s=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?s.length>1&&s.pop():a!=="."&&s.push(a)}),s.length>1?s.join("/"):"/"}function kc(e,t,s,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+s+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function lb(e){return e.filter((t,s)=>s===0||t.route.path&&t.route.path.length>0)}function Xd(e,t){let s=lb(e);return t?s.map((r,a)=>a===s.length-1?r.pathname:r.pathnameBase):s.map(r=>r.pathnameBase)}function eh(e,t,s,r){r===void 0&&(r=!1);let a;typeof e=="string"?a=Ea(e):(a=Ci({},e),Qe(!a.pathname||!a.pathname.includes("?"),kc("?","pathname","search",a)),Qe(!a.pathname||!a.pathname.includes("#"),kc("#","pathname","hash",a)),Qe(!a.search||!a.search.includes("#"),kc("#","search","hash",a)));let i=e===""||a.pathname==="",l=i?"/":a.pathname,o;if(l==null)o=s;else{let m=t.length-1;if(!r&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),m-=1;a.pathname=p.join("/")}o=m>=0?t[m]:"/"}let c=ib(a,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&s.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const $n=e=>e.join("/").replace(/\/\/+/g,"/"),ob=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),cb=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ub=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function db(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Jx=["post","put","patch","delete"];new Set(Jx);const hb=["get",...Jx];new Set(hb);/**
* 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 Ei(){return Ei=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])}return e},Ei.apply(this,arguments)}const Ro=w.createContext(null),Xx=w.createContext(null),un=w.createContext(null),Oo=w.createContext(null),Us=w.createContext({outlet:null,matches:[],isDataRoute:!1}),ey=w.createContext(null);function mb(e,t){let{relative:s}=t===void 0?{}:t;Da()||Qe(!1);let{basename:r,navigator:a}=w.useContext(un),{hash:i,pathname:l,search:o}=zo(e,{relative:s}),c=l;return r!=="/"&&(c=l==="/"?r:$n([r,l])),a.createHref({pathname:c,search:o,hash:i})}function Da(){return w.useContext(Oo)!=null}function dn(){return Da()||Qe(!1),w.useContext(Oo).location}function ty(e){w.useContext(un).static||w.useLayoutEffect(e)}function Ut(){let{isDataRoute:e}=w.useContext(Us);return e?Db():fb()}function fb(){Da()||Qe(!1);let e=w.useContext(Ro),{basename:t,future:s,navigator:r}=w.useContext(un),{matches:a}=w.useContext(Us),{pathname:i}=dn(),l=JSON.stringify(Xd(a,s.v7_relativeSplatPath)),o=w.useRef(!1);return ty(()=>{o.current=!0}),w.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let m=eh(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:$n([t,m.pathname])),(d.replace?r.replace:r.push)(m,d.state,d)},[t,r,l,i,e])}const pb=w.createContext(null);function gb(e){let t=w.useContext(Us).outlet;return t&&w.createElement(pb.Provider,{value:e},t)}function _o(){let{matches:e}=w.useContext(Us),t=e[e.length-1];return t?t.params:{}}function zo(e,t){let{relative:s}=t===void 0?{}:t,{future:r}=w.useContext(un),{matches:a}=w.useContext(Us),{pathname:i}=dn(),l=JSON.stringify(Xd(a,r.v7_relativeSplatPath));return w.useMemo(()=>eh(e,JSON.parse(l),i,s==="path"),[e,l,i,s])}function xb(e,t){return yb(e,t)}function yb(e,t,s,r){Da()||Qe(!1);let{navigator:a}=w.useContext(un),{matches:i}=w.useContext(Us),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=dn(),d;if(t){var m;let b=typeof t=="string"?Ea(t):t;c==="/"||(m=b.pathname)!=null&&m.startsWith(c)||Qe(!1),d=b}else d=u;let p=d.pathname||"/",h=p;if(c!=="/"){let b=c.replace(/^\//,"").split("/");h="/"+p.replace(/^\//,"").split("/").slice(b.length).join("/")}let f=Vj(e,{pathname:h}),g=wb(f&&f.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:$n([c,a.encodeLocation?a.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:$n([c,a.encodeLocation?a.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,s,r);return t&&g?w.createElement(Oo.Provider,{value:{location:Ei({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:Fn.Pop}},g):g}function vb(){let e=Eb(),t=db(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),s=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},t),s?w.createElement("pre",{style:a},s):null,null)}const jb=w.createElement(vb,null);class bb extends w.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,s){return s.location!==t.location||s.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:s.error,location:s.location,revalidation:t.revalidation||s.revalidation}}componentDidCatch(t,s){console.error("React Router caught the following error during render",t,s)}render(){return this.state.error!==void 0?w.createElement(Us.Provider,{value:this.props.routeContext},w.createElement(ey.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Nb(e){let{routeContext:t,match:s,children:r}=e,a=w.useContext(Ro);return a&&a.static&&a.staticContext&&(s.route.errorElement||s.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=s.route.id),w.createElement(Us.Provider,{value:t},r)}function wb(e,t,s,r){var a;if(t===void 0&&(t=[]),s===void 0&&(s=null),r===void 0&&(r=null),e==null){var i;if(!s)return null;if(s.errors)e=s.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!s.initialized&&s.matches.length>0)e=s.matches;else return null}let l=e,o=(a=s)==null?void 0:a.errors;if(o!=null){let d=l.findIndex(m=>m.route.id&&(o==null?void 0:o[m.route.id])!==void 0);d>=0||Qe(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(s&&r&&r.v7_partialHydration)for(let d=0;d<l.length;d++){let m=l[d];if((m.route.HydrateFallback||m.route.hydrateFallbackElement)&&(u=d),m.route.id){let{loaderData:p,errors:h}=s,f=m.route.loader&&p[m.route.id]===void 0&&(!h||h[m.route.id]===void 0);if(m.route.lazy||f){c=!0,u>=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,m,p)=>{let h,f=!1,g=null,b=null;s&&(h=o&&m.route.id?o[m.route.id]:void 0,g=m.route.errorElement||jb,c&&(u<0&&p===0?(Pb("route-fallback"),f=!0,b=null):u===p&&(f=!0,b=m.route.hydrateFallbackElement||null)));let y=t.concat(l.slice(0,p+1)),v=()=>{let x;return h?x=g:f?x=b:m.route.Component?x=w.createElement(m.route.Component,null):m.route.element?x=m.route.element:x=d,w.createElement(Nb,{match:m,routeContext:{outlet:d,matches:y,isDataRoute:s!=null},children:x})};return s&&(m.route.ErrorBoundary||m.route.errorElement||p===0)?w.createElement(bb,{location:s.location,revalidation:s.revalidation,component:g,error:h,children:v(),routeContext:{outlet:null,matches:y,isDataRoute:!0}}):v()},null)}var sy=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(sy||{}),ny=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(ny||{});function Sb(e){let t=w.useContext(Ro);return t||Qe(!1),t}function kb(e){let t=w.useContext(Xx);return t||Qe(!1),t}function Cb(e){let t=w.useContext(Us);return t||Qe(!1),t}function ry(e){let t=Cb(),s=t.matches[t.matches.length-1];return s.route.id||Qe(!1),s.route.id}function Eb(){var e;let t=w.useContext(ey),s=kb(),r=ry();return t!==void 0?t:(e=s.errors)==null?void 0:e[r]}function Db(){let{router:e}=Sb(sy.UseNavigateStable),t=ry(ny.UseNavigateStable),s=w.useRef(!1);return ty(()=>{s.current=!0}),w.useCallback(function(a,i){i===void 0&&(i={}),s.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,Ei({fromRouteId:t},i)))},[e,t])}const Sf={};function Pb(e,t,s){Sf[e]||(Sf[e]=!0)}function Ab(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Qr(e){let{to:t,replace:s,state:r,relative:a}=e;Da()||Qe(!1);let{future:i,static:l}=w.useContext(un),{matches:o}=w.useContext(Us),{pathname:c}=dn(),u=Ut(),d=eh(t,Xd(o,i.v7_relativeSplatPath),c,a==="path"),m=JSON.stringify(d);return w.useEffect(()=>u(JSON.parse(m),{replace:s,state:r,relative:a}),[u,m,a,s,r]),null}function Tb(e){return gb(e.context)}function Fe(e){Qe(!1)}function Fb(e){let{basename:t="/",children:s=null,location:r,navigationType:a=Fn.Pop,navigator:i,static:l=!1,future:o}=e;Da()&&Qe(!1);let c=t.replace(/^\/*/,"/"),u=w.useMemo(()=>({basename:c,navigator:i,static:l,future:Ei({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=Ea(r));let{pathname:d="/",search:m="",hash:p="",state:h=null,key:f="default"}=r,g=w.useMemo(()=>{let b=ja(d,c);return b==null?null:{location:{pathname:b,search:m,hash:p,state:h,key:f},navigationType:a}},[c,d,m,p,h,f,a]);return g==null?null:w.createElement(un.Provider,{value:u},w.createElement(Oo.Provider,{children:s,value:g}))}function Ib(e){let{children:t,location:s}=e;return xb(Tu(t),s)}new Promise(()=>{});function Tu(e,t){t===void 0&&(t=[]);let s=[];return w.Children.forEach(e,(r,a)=>{if(!w.isValidElement(r))return;let i=[...t,a];if(r.type===w.Fragment){s.push.apply(s,Tu(r.props.children,i));return}r.type!==Fe&&Qe(!1),!r.props.index||!r.props.children||Qe(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Tu(r.props.children,i)),s.push(l)}),s}/**
* 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 uo(){return uo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(e[r]=s[r])}return e},uo.apply(this,arguments)}function ay(e,t){if(e==null)return{};var s={},r=Object.keys(e),a,i;for(i=0;i<r.length;i++)a=r[i],!(t.indexOf(a)>=0)&&(s[a]=e[a]);return s}function Mb(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Lb(e,t){return e.button===0&&(!t||t==="_self")&&!Mb(e)}function Fu(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,s)=>{let r=e[s];return t.concat(Array.isArray(r)?r.map(a=>[s,a]):[[s,r]])},[]))}function Rb(e,t){let s=Fu(e);return t&&t.forEach((r,a)=>{s.has(a)||t.getAll(a).forEach(i=>{s.append(a,i)})}),s}const Ob=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],_b=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],zb="6";try{window.__reactRouterVersion=zb}catch{}const Ub=w.createContext({isTransitioning:!1}),$b="startTransition",kf=Pv[$b];function Bb(e){let{basename:t,children:s,future:r,window:a}=e,i=w.useRef();i.current==null&&(i.current=$j({window:a,v5Compat:!0}));let l=i.current,[o,c]=w.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=w.useCallback(m=>{u&&kf?kf(()=>c(m)):c(m)},[c,u]);return w.useLayoutEffect(()=>l.listen(d),[l,d]),w.useEffect(()=>Ab(r),[r]),w.createElement(Fb,{basename:t,children:s,location:o.location,navigationType:o.action,navigator:l,future:r})}const Kb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Vb=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Se=w.forwardRef(function(t,s){let{onClick:r,relative:a,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:m}=t,p=ay(t,Ob),{basename:h}=w.useContext(un),f,g=!1;if(typeof u=="string"&&Vb.test(u)&&(f=u,Kb))try{let x=new URL(window.location.href),N=u.startsWith("//")?new URL(x.protocol+u):new URL(u),k=ja(N.pathname,h);N.origin===x.origin&&k!=null?u=k+N.search+N.hash:g=!0}catch{}let b=mb(u,{relative:a}),y=Qb(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:a,viewTransition:m});function v(x){r&&r(x),x.defaultPrevented||y(x)}return w.createElement("a",uo({},p,{href:f||b,onClick:g||i?r:v,ref:s,target:c}))}),Cc=w.forwardRef(function(t,s){let{"aria-current":r="page",caseSensitive:a=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,m=ay(t,_b),p=zo(c,{relative:m.relative}),h=dn(),f=w.useContext(Xx),{navigator:g,basename:b}=w.useContext(un),y=f!=null&&Hb(p)&&u===!0,v=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,x=h.pathname,N=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;a||(x=x.toLowerCase(),N=N?N.toLowerCase():null,v=v.toLowerCase()),N&&b&&(N=ja(N,b)||N);const k=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let D=x===v||!l&&x.startsWith(v)&&x.charAt(k)==="/",F=N!=null&&(N===v||!l&&N.startsWith(v)&&N.charAt(v.length)==="/"),S={isActive:D,isPending:F,isTransitioning:y},L=D?r:void 0,T;typeof i=="function"?T=i(S):T=[i,D?"active":null,F?"pending":null,y?"transitioning":null].filter(Boolean).join(" ");let _=typeof o=="function"?o(S):o;return w.createElement(Se,uo({},m,{"aria-current":L,className:T,ref:s,style:_,to:c,viewTransition:u}),typeof d=="function"?d(S):d)});var Iu;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Iu||(Iu={}));var Cf;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Cf||(Cf={}));function qb(e){let t=w.useContext(Ro);return t||Qe(!1),t}function Qb(e,t){let{target:s,replace:r,state:a,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Ut(),u=dn(),d=zo(e,{relative:l});return w.useCallback(m=>{if(Lb(m,s)){m.preventDefault();let p=r!==void 0?r:co(u)===co(d);c(e,{replace:p,state:a,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,a,s,e,i,l,o])}function Uo(e){let t=w.useRef(Fu(e)),s=w.useRef(!1),r=dn(),a=w.useMemo(()=>Rb(r.search,s.current?null:t.current),[r.search]),i=Ut(),l=w.useCallback((o,c)=>{const u=Fu(typeof o=="function"?o(a):o);s.current=!0,i("?"+u,c)},[i,a]);return[a,l]}function Hb(e,t){t===void 0&&(t={});let s=w.useContext(Ub);s==null&&Qe(!1);let{basename:r}=qb(Iu.useViewTransitionState),a=zo(e,{relative:t.relative});if(!s.isTransitioning)return!1;let i=ja(s.currentLocation.pathname,r)||s.currentLocation.pathname,l=ja(s.nextLocation.pathname,r)||s.nextLocation.pathname;return Au(a.pathname,l)!=null||Au(a.pathname,i)!=null}var Pa=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Wb={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},bn,nd,Ep,Gb=(Ep=class{constructor(){ue(this,bn,Wb);ue(this,nd,!1)}setTimeoutProvider(e){te(this,bn,e)}setTimeout(e,t){return C(this,bn).setTimeout(e,t)}clearTimeout(e){C(this,bn).clearTimeout(e)}setInterval(e,t){return C(this,bn).setInterval(e,t)}clearInterval(e){C(this,bn).clearInterval(e)}},bn=new WeakMap,nd=new WeakMap,Ep),tr=new Gb;function Zb(e){setTimeout(e,0)}var br=typeof window>"u"||"Deno"in globalThis;function Rt(){}function Yb(e,t){return typeof e=="function"?e(t):e}function Mu(e){return typeof e=="number"&&e>=0&&e!==1/0}function iy(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Bn(e,t){return typeof e=="function"?e(t):e}function os(e,t){return typeof e=="function"?e(t):e}function Ef(e,t){const{type:s="all",exact:r,fetchStatus:a,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==th(l,t.options))return!1}else if(!Di(t.queryKey,l))return!1}if(s!=="all"){const c=t.isActive();if(s==="active"&&!c||s==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||a&&a!==t.state.fetchStatus||i&&!i(t))}function Df(e,t){const{exact:s,status:r,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(s){if(Nr(t.options.mutationKey)!==Nr(i))return!1}else if(!Di(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function th(e,t){return((t==null?void 0:t.queryKeyHashFn)||Nr)(e)}function Nr(e){return JSON.stringify(e,(t,s)=>Lu(s)?Object.keys(s).sort().reduce((r,a)=>(r[a]=s[a],r),{}):s)}function Di(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>Di(e[s],t[s])):!1}var Jb=Object.prototype.hasOwnProperty;function ly(e,t,s=0){if(e===t)return e;if(s>500)return t;const r=Pf(e)&&Pf(t);if(!r&&!(Lu(e)&&Lu(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let u=0;for(let d=0;d<o;d++){const m=r?d:l[d],p=e[m],h=t[m];if(p===h){c[m]=p,(r?d<i:Jb.call(e,m))&&u++;continue}if(p===null||h===null||typeof p!="object"||typeof h!="object"){c[m]=h;continue}const f=ly(p,h,s+1);c[m]=f,f===p&&u++}return i===o&&u===i?e:c}function ho(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Pf(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Lu(e){if(!Af(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Af(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Af(e){return Object.prototype.toString.call(e)==="[object Object]"}function Xb(e){return new Promise(t=>{tr.setTimeout(t,e)})}function Ru(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?ly(e,t):t}function eN(e,t,s=0){const r=[...e,t];return s&&r.length>s?r.slice(1):r}function tN(e,t,s=0){const r=[t,...e];return s&&r.length>s?r.slice(0,-1):r}var sh=Symbol();function oy(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===sh?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function nh(e,t){return typeof e=="function"?e(...t):!!e}function sN(e,t,s){let r=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),r||(r=!0,a.aborted?s():a.addEventListener("abort",s,{once:!0})),a)}),e}var rr,Nn,ta,Dp,nN=(Dp=class extends Pa{constructor(){super();ue(this,rr);ue(this,Nn);ue(this,ta);te(this,ta,t=>{if(!br&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){C(this,Nn)||this.setEventListener(C(this,ta))}onUnsubscribe(){var t;this.hasListeners()||((t=C(this,Nn))==null||t.call(this),te(this,Nn,void 0))}setEventListener(t){var s;te(this,ta,t),(s=C(this,Nn))==null||s.call(this),te(this,Nn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){C(this,rr)!==t&&(te(this,rr,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof C(this,rr)=="boolean"?C(this,rr):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},rr=new WeakMap,Nn=new WeakMap,ta=new WeakMap,Dp),rh=new nN;function Ou(){let e,t;const s=new Promise((a,i)=>{e=a,t=i});s.status="pending",s.catch(()=>{});function r(a){Object.assign(s,a),delete s.resolve,delete s.reject}return s.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},s.reject=a=>{r({status:"rejected",reason:a}),t(a)},s}var rN=Zb;function aN(){let e=[],t=0,s=o=>{o()},r=o=>{o()},a=rN;const i=o=>{t?e.push(o):a(()=>{s(o)})},l=()=>{const o=e;e=[],o.length&&a(()=>{r(()=>{o.forEach(c=>{s(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{s=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{a=o}}}var ct=aN(),sa,wn,na,Pp,iN=(Pp=class extends Pa{constructor(){super();ue(this,sa,!0);ue(this,wn);ue(this,na);te(this,na,t=>{if(!br&&window.addEventListener){const s=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",r)}}})}onSubscribe(){C(this,wn)||this.setEventListener(C(this,na))}onUnsubscribe(){var t;this.hasListeners()||((t=C(this,wn))==null||t.call(this),te(this,wn,void 0))}setEventListener(t){var s;te(this,na,t),(s=C(this,wn))==null||s.call(this),te(this,wn,t(this.setOnline.bind(this)))}setOnline(t){C(this,sa)!==t&&(te(this,sa,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return C(this,sa)}},sa=new WeakMap,wn=new WeakMap,na=new WeakMap,Pp),mo=new iN;function lN(e){return Math.min(1e3*2**e,3e4)}function cy(e){return(e??"online")==="online"?mo.isOnline():!0}var _u=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function uy(e){let t=!1,s=0,r;const a=Ou(),i=()=>a.status!=="pending",l=g=>{var b;if(!i()){const y=new _u(g);p(y),(b=e.onCancel)==null||b.call(e,y)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>rh.isFocused()&&(e.networkMode==="always"||mo.isOnline())&&e.canRun(),d=()=>cy(e.networkMode)&&e.canRun(),m=g=>{i()||(r==null||r(),a.resolve(g))},p=g=>{i()||(r==null||r(),a.reject(g))},h=()=>new Promise(g=>{var b;r=y=>{(i()||u())&&g(y)},(b=e.onPause)==null||b.call(e)}).then(()=>{var g;r=void 0,i()||(g=e.onContinue)==null||g.call(e)}),f=()=>{if(i())return;let g;const b=s===0?e.initialPromise:void 0;try{g=b??e.fn()}catch(y){g=Promise.reject(y)}Promise.resolve(g).then(m).catch(y=>{var D;if(i())return;const v=e.retry??(br?0:3),x=e.retryDelay??lN,N=typeof x=="function"?x(s,y):x,k=v===!0||typeof v=="number"&&s<v||typeof v=="function"&&v(s,y);if(t||!k){p(y);return}s++,(D=e.onFail)==null||D.call(e,s,y),Xb(N).then(()=>u()?void 0:h()).then(()=>{t?p(y):f()})})};return{promise:a,status:()=>a.status,cancel:l,continue:()=>(r==null||r(),a),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?f():h().then(f),a)}}var ar,Ap,dy=(Ap=class{constructor(){ue(this,ar)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Mu(this.gcTime)&&te(this,ar,tr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(br?1/0:5*60*1e3))}clearGcTimeout(){C(this,ar)&&(tr.clearTimeout(C(this,ar)),te(this,ar,void 0))}},ar=new WeakMap,Ap),ir,ra,ls,lr,pt,Ri,or,vs,Vs,Tp,oN=(Tp=class extends dy{constructor(t){super();ue(this,vs);ue(this,ir);ue(this,ra);ue(this,ls);ue(this,lr);ue(this,pt);ue(this,Ri);ue(this,or);te(this,or,!1),te(this,Ri,t.defaultOptions),this.setOptions(t.options),this.observers=[],te(this,lr,t.client),te(this,ls,C(this,lr).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,te(this,ir,Ff(this.options)),this.state=t.state??C(this,ir),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=C(this,pt))==null?void 0:t.promise}setOptions(t){if(this.options={...C(this,Ri),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const s=Ff(this.options);s.data!==void 0&&(this.setState(Tf(s.data,s.dataUpdatedAt)),te(this,ir,s))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&C(this,ls).remove(this)}setData(t,s){const r=Ru(this.state.data,t,this.options);return ye(this,vs,Vs).call(this,{data:r,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),r}setState(t,s){ye(this,vs,Vs).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var r,a;const s=(r=C(this,pt))==null?void 0:r.promise;return(a=C(this,pt))==null||a.cancel(t),s?s.then(Rt).catch(Rt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(C(this,ir))}isActive(){return this.observers.some(t=>os(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===sh||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Bn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!iy(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=C(this,pt))==null||s.continue()}onOnline(){var s;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=C(this,pt))==null||s.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),C(this,ls).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(s=>s!==t),this.observers.length||(C(this,pt)&&(C(this,or)?C(this,pt).cancel({revert:!0}):C(this,pt).cancelRetry()),this.scheduleGc()),C(this,ls).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ye(this,vs,Vs).call(this,{type:"invalidate"})}async fetch(t,s){var c,u,d,m,p,h,f,g,b,y,v,x;if(this.state.fetchStatus!=="idle"&&((c=C(this,pt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(C(this,pt))return C(this,pt).continueRetry(),C(this,pt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const N=this.observers.find(k=>k.options.queryFn);N&&this.setOptions(N.options)}const r=new AbortController,a=N=>{Object.defineProperty(N,"signal",{enumerable:!0,get:()=>(te(this,or,!0),r.signal)})},i=()=>{const N=oy(this.options,s),D=(()=>{const F={client:C(this,lr),queryKey:this.queryKey,meta:this.meta};return a(F),F})();return te(this,or,!1),this.options.persister?this.options.persister(N,D,this):N(D)},o=(()=>{const N={fetchOptions:s,options:this.options,queryKey:this.queryKey,client:C(this,lr),state:this.state,fetchFn:i};return a(N),N})();(u=this.options.behavior)==null||u.onFetch(o,this),te(this,ra,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&ye(this,vs,Vs).call(this,{type:"fetch",meta:(m=o.fetchOptions)==null?void 0:m.meta}),te(this,pt,uy({initialPromise:s==null?void 0:s.initialPromise,fn:o.fetchFn,onCancel:N=>{N instanceof _u&&N.revert&&this.setState({...C(this,ra),fetchStatus:"idle"}),r.abort()},onFail:(N,k)=>{ye(this,vs,Vs).call(this,{type:"failed",failureCount:N,error:k})},onPause:()=>{ye(this,vs,Vs).call(this,{type:"pause"})},onContinue:()=>{ye(this,vs,Vs).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const N=await C(this,pt).start();if(N===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(N),(h=(p=C(this,ls).config).onSuccess)==null||h.call(p,N,this),(g=(f=C(this,ls).config).onSettled)==null||g.call(f,N,this.state.error,this),N}catch(N){if(N instanceof _u){if(N.silent)return C(this,pt).promise;if(N.revert){if(this.state.data===void 0)throw N;return this.state.data}}throw ye(this,vs,Vs).call(this,{type:"error",error:N}),(y=(b=C(this,ls).config).onError)==null||y.call(b,N,this),(x=(v=C(this,ls).config).onSettled)==null||x.call(v,this.state.data,N,this),N}finally{this.scheduleGc()}}},ir=new WeakMap,ra=new WeakMap,ls=new WeakMap,lr=new WeakMap,pt=new WeakMap,Ri=new WeakMap,or=new WeakMap,vs=new WeakSet,Vs=function(t){const s=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...hy(r.data,this.options),fetchMeta:t.meta??null};case"success":const a={...r,...Tf(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return te(this,ra,t.manual?a:void 0),a;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=s(this.state),ct.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),C(this,ls).notify({query:this,type:"updated",action:t})})},Tp);function hy(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:cy(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Tf(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ff(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,r=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var Bt,ke,Oi,Ft,cr,aa,Hs,Sn,_i,ia,la,ur,dr,kn,oa,Te,Ga,zu,Uu,$u,Bu,Ku,Vu,qu,my,Fp,cN=(Fp=class extends Pa{constructor(t,s){super();ue(this,Te);ue(this,Bt);ue(this,ke);ue(this,Oi);ue(this,Ft);ue(this,cr);ue(this,aa);ue(this,Hs);ue(this,Sn);ue(this,_i);ue(this,ia);ue(this,la);ue(this,ur);ue(this,dr);ue(this,kn);ue(this,oa,new Set);this.options=s,te(this,Bt,t),te(this,Sn,null),te(this,Hs,Ou()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(C(this,ke).addObserver(this),If(C(this,ke),this.options)?ye(this,Te,Ga).call(this):this.updateResult(),ye(this,Te,Bu).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Qu(C(this,ke),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Qu(C(this,ke),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ye(this,Te,Ku).call(this),ye(this,Te,Vu).call(this),C(this,ke).removeObserver(this)}setOptions(t){const s=this.options,r=C(this,ke);if(this.options=C(this,Bt).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof os(this.options.enabled,C(this,ke))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ye(this,Te,qu).call(this),C(this,ke).setOptions(this.options),s._defaulted&&!ho(this.options,s)&&C(this,Bt).getQueryCache().notify({type:"observerOptionsUpdated",query:C(this,ke),observer:this});const a=this.hasListeners();a&&Mf(C(this,ke),r,this.options,s)&&ye(this,Te,Ga).call(this),this.updateResult(),a&&(C(this,ke)!==r||os(this.options.enabled,C(this,ke))!==os(s.enabled,C(this,ke))||Bn(this.options.staleTime,C(this,ke))!==Bn(s.staleTime,C(this,ke)))&&ye(this,Te,zu).call(this);const i=ye(this,Te,Uu).call(this);a&&(C(this,ke)!==r||os(this.options.enabled,C(this,ke))!==os(s.enabled,C(this,ke))||i!==C(this,kn))&&ye(this,Te,$u).call(this,i)}getOptimisticResult(t){const s=C(this,Bt).getQueryCache().build(C(this,Bt),t),r=this.createResult(s,t);return dN(this,r)&&(te(this,Ft,r),te(this,aa,this.options),te(this,cr,C(this,ke).state)),r}getCurrentResult(){return C(this,Ft)}trackResult(t,s){return new Proxy(t,{get:(r,a)=>(this.trackProp(a),s==null||s(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&C(this,Hs).status==="pending"&&C(this,Hs).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){C(this,oa).add(t)}getCurrentQuery(){return C(this,ke)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=C(this,Bt).defaultQueryOptions(t),r=C(this,Bt).getQueryCache().build(C(this,Bt),s);return r.fetch().then(()=>this.createResult(r,s))}fetch(t){return ye(this,Te,Ga).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),C(this,Ft)))}createResult(t,s){var L;const r=C(this,ke),a=this.options,i=C(this,Ft),l=C(this,cr),o=C(this,aa),u=t!==r?t.state:C(this,Oi),{state:d}=t;let m={...d},p=!1,h;if(s._optimisticResults){const T=this.hasListeners(),_=!T&&If(t,s),K=T&&Mf(t,r,s,a);(_||K)&&(m={...m,...hy(d.data,t.options)}),s._optimisticResults==="isRestoring"&&(m.fetchStatus="idle")}let{error:f,errorUpdatedAt:g,status:b}=m;h=m.data;let y=!1;if(s.placeholderData!==void 0&&h===void 0&&b==="pending"){let T;i!=null&&i.isPlaceholderData&&s.placeholderData===(o==null?void 0:o.placeholderData)?(T=i.data,y=!0):T=typeof s.placeholderData=="function"?s.placeholderData((L=C(this,la))==null?void 0:L.state.data,C(this,la)):s.placeholderData,T!==void 0&&(b="success",h=Ru(i==null?void 0:i.data,T,s),p=!0)}if(s.select&&h!==void 0&&!y)if(i&&h===(l==null?void 0:l.data)&&s.select===C(this,_i))h=C(this,ia);else try{te(this,_i,s.select),h=s.select(h),h=Ru(i==null?void 0:i.data,h,s),te(this,ia,h),te(this,Sn,null)}catch(T){te(this,Sn,T)}C(this,Sn)&&(f=C(this,Sn),h=C(this,ia),g=Date.now(),b="error");const v=m.fetchStatus==="fetching",x=b==="pending",N=b==="error",k=x&&v,D=h!==void 0,S={status:b,fetchStatus:m.fetchStatus,isPending:x,isSuccess:b==="success",isError:N,isInitialLoading:k,isLoading:k,data:h,dataUpdatedAt:m.dataUpdatedAt,error:f,errorUpdatedAt:g,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>u.dataUpdateCount||m.errorUpdateCount>u.errorUpdateCount,isFetching:v,isRefetching:v&&!x,isLoadingError:N&&!D,isPaused:m.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:N&&D,isStale:ah(t,s),refetch:this.refetch,promise:C(this,Hs),isEnabled:os(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const T=S.data!==void 0,_=S.status==="error"&&!T,K=z=>{_?z.reject(S.error):T&&z.resolve(S.data)},W=()=>{const z=te(this,Hs,S.promise=Ou());K(z)},Q=C(this,Hs);switch(Q.status){case"pending":t.queryHash===r.queryHash&&K(Q);break;case"fulfilled":(_||S.data!==Q.value)&&W();break;case"rejected":(!_||S.error!==Q.reason)&&W();break}}return S}updateResult(){const t=C(this,Ft),s=this.createResult(C(this,ke),this.options);if(te(this,cr,C(this,ke).state),te(this,aa,this.options),C(this,cr).data!==void 0&&te(this,la,C(this,ke)),ho(s,t))return;te(this,Ft,s);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!C(this,oa).size)return!0;const l=new Set(i??C(this,oa));return this.options.throwOnError&&l.add("error"),Object.keys(C(this,Ft)).some(o=>{const c=o;return C(this,Ft)[c]!==t[c]&&l.has(c)})};ye(this,Te,my).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ye(this,Te,Bu).call(this)}},Bt=new WeakMap,ke=new WeakMap,Oi=new WeakMap,Ft=new WeakMap,cr=new WeakMap,aa=new WeakMap,Hs=new WeakMap,Sn=new WeakMap,_i=new WeakMap,ia=new WeakMap,la=new WeakMap,ur=new WeakMap,dr=new WeakMap,kn=new WeakMap,oa=new WeakMap,Te=new WeakSet,Ga=function(t){ye(this,Te,qu).call(this);let s=C(this,ke).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(Rt)),s},zu=function(){ye(this,Te,Ku).call(this);const t=Bn(this.options.staleTime,C(this,ke));if(br||C(this,Ft).isStale||!Mu(t))return;const r=iy(C(this,Ft).dataUpdatedAt,t)+1;te(this,ur,tr.setTimeout(()=>{C(this,Ft).isStale||this.updateResult()},r))},Uu=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(C(this,ke)):this.options.refetchInterval)??!1},$u=function(t){ye(this,Te,Vu).call(this),te(this,kn,t),!(br||os(this.options.enabled,C(this,ke))===!1||!Mu(C(this,kn))||C(this,kn)===0)&&te(this,dr,tr.setInterval(()=>{(this.options.refetchIntervalInBackground||rh.isFocused())&&ye(this,Te,Ga).call(this)},C(this,kn)))},Bu=function(){ye(this,Te,zu).call(this),ye(this,Te,$u).call(this,ye(this,Te,Uu).call(this))},Ku=function(){C(this,ur)&&(tr.clearTimeout(C(this,ur)),te(this,ur,void 0))},Vu=function(){C(this,dr)&&(tr.clearInterval(C(this,dr)),te(this,dr,void 0))},qu=function(){const t=C(this,Bt).getQueryCache().build(C(this,Bt),this.options);if(t===C(this,ke))return;const s=C(this,ke);te(this,ke,t),te(this,Oi,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},my=function(t){ct.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(C(this,Ft))}),C(this,Bt).getQueryCache().notify({query:C(this,ke),type:"observerResultsUpdated"})})},Fp);function uN(e,t){return os(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function If(e,t){return uN(e,t)||e.state.data!==void 0&&Qu(e,t,t.refetchOnMount)}function Qu(e,t,s){if(os(t.enabled,e)!==!1&&Bn(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&ah(e,t)}return!1}function Mf(e,t,s,r){return(e!==t||os(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&ah(e,s)}function ah(e,t){return os(t.enabled,e)!==!1&&e.isStaleByTime(Bn(t.staleTime,e))}function dN(e,t){return!ho(e.getCurrentResult(),t)}function Lf(e){return{onFetch:(t,s)=>{var d,m,p,h,f;const r=t.options,a=(p=(m=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:m.fetchMore)==null?void 0:p.direction,i=((h=t.state.data)==null?void 0:h.pages)||[],l=((f=t.state.data)==null?void 0:f.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let g=!1;const b=x=>{sN(x,()=>t.signal,()=>g=!0)},y=oy(t.options,t.fetchOptions),v=async(x,N,k)=>{if(g)return Promise.reject();if(N==null&&x.pages.length)return Promise.resolve(x);const F=(()=>{const _={client:t.client,queryKey:t.queryKey,pageParam:N,direction:k?"backward":"forward",meta:t.options.meta};return b(_),_})(),S=await y(F),{maxPages:L}=t.options,T=k?tN:eN;return{pages:T(x.pages,S,L),pageParams:T(x.pageParams,N,L)}};if(a&&i.length){const x=a==="backward",N=x?hN:Rf,k={pages:i,pageParams:l},D=N(r,k);o=await v(k,D,x)}else{const x=e??i.length;do{const N=c===0?l[0]??r.initialPageParam:Rf(r,o);if(c>0&&N==null)break;o=await v(o,N),c++}while(c<x)}return o};t.options.persister?t.fetchFn=()=>{var g,b;return(b=(g=t.options).persister)==null?void 0:b.call(g,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=u}}}function Rf(e,{pages:t,pageParams:s}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,s[r],s):void 0}function hN(e,{pages:t,pageParams:s}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,s[0],s):void 0}var zi,Is,It,hr,Ms,fn,Ip,mN=(Ip=class extends dy{constructor(t){super();ue(this,Ms);ue(this,zi);ue(this,Is);ue(this,It);ue(this,hr);te(this,zi,t.client),this.mutationId=t.mutationId,te(this,It,t.mutationCache),te(this,Is,[]),this.state=t.state||fy(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){C(this,Is).includes(t)||(C(this,Is).push(t),this.clearGcTimeout(),C(this,It).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){te(this,Is,C(this,Is).filter(s=>s!==t)),this.scheduleGc(),C(this,It).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){C(this,Is).length||(this.state.status==="pending"?this.scheduleGc():C(this,It).remove(this))}continue(){var t;return((t=C(this,hr))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,m,p,h,f,g,b,y,v,x,N,k,D,F,S,L;const s=()=>{ye(this,Ms,fn).call(this,{type:"continue"})},r={client:C(this,zi),meta:this.options.meta,mutationKey:this.options.mutationKey};te(this,hr,uy({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(T,_)=>{ye(this,Ms,fn).call(this,{type:"failed",failureCount:T,error:_})},onPause:()=>{ye(this,Ms,fn).call(this,{type:"pause"})},onContinue:s,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>C(this,It).canRun(this)}));const a=this.state.status==="pending",i=!C(this,hr).canStart();try{if(a)s();else{ye(this,Ms,fn).call(this,{type:"pending",variables:t,isPaused:i}),await((o=(l=C(this,It).config).onMutate)==null?void 0:o.call(l,t,this,r));const _=await((u=(c=this.options).onMutate)==null?void 0:u.call(c,t,r));_!==this.state.context&&ye(this,Ms,fn).call(this,{type:"pending",context:_,variables:t,isPaused:i})}const T=await C(this,hr).start();return await((m=(d=C(this,It).config).onSuccess)==null?void 0:m.call(d,T,t,this.state.context,this,r)),await((h=(p=this.options).onSuccess)==null?void 0:h.call(p,T,t,this.state.context,r)),await((g=(f=C(this,It).config).onSettled)==null?void 0:g.call(f,T,null,this.state.variables,this.state.context,this,r)),await((y=(b=this.options).onSettled)==null?void 0:y.call(b,T,null,t,this.state.context,r)),ye(this,Ms,fn).call(this,{type:"success",data:T}),T}catch(T){try{await((x=(v=C(this,It).config).onError)==null?void 0:x.call(v,T,t,this.state.context,this,r))}catch(_){Promise.reject(_)}try{await((k=(N=this.options).onError)==null?void 0:k.call(N,T,t,this.state.context,r))}catch(_){Promise.reject(_)}try{await((F=(D=C(this,It).config).onSettled)==null?void 0:F.call(D,void 0,T,this.state.variables,this.state.context,this,r))}catch(_){Promise.reject(_)}try{await((L=(S=this.options).onSettled)==null?void 0:L.call(S,void 0,T,t,this.state.context,r))}catch(_){Promise.reject(_)}throw ye(this,Ms,fn).call(this,{type:"error",error:T}),T}finally{C(this,It).runNext(this)}}},zi=new WeakMap,Is=new WeakMap,It=new WeakMap,hr=new WeakMap,Ms=new WeakSet,fn=function(t){const s=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),ct.batch(()=>{C(this,Is).forEach(r=>{r.onMutationUpdate(t)}),C(this,It).notify({mutation:this,type:"updated",action:t})})},Ip);function fy(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ws,js,Ui,Mp,fN=(Mp=class extends Pa{constructor(t={}){super();ue(this,Ws);ue(this,js);ue(this,Ui);this.config=t,te(this,Ws,new Set),te(this,js,new Map),te(this,Ui,0)}build(t,s,r){const a=new mN({client:t,mutationCache:this,mutationId:++tl(this,Ui)._,options:t.defaultMutationOptions(s),state:r});return this.add(a),a}add(t){C(this,Ws).add(t);const s=vl(t);if(typeof s=="string"){const r=C(this,js).get(s);r?r.push(t):C(this,js).set(s,[t])}this.notify({type:"added",mutation:t})}remove(t){if(C(this,Ws).delete(t)){const s=vl(t);if(typeof s=="string"){const r=C(this,js).get(s);if(r)if(r.length>1){const a=r.indexOf(t);a!==-1&&r.splice(a,1)}else r[0]===t&&C(this,js).delete(s)}}this.notify({type:"removed",mutation:t})}canRun(t){const s=vl(t);if(typeof s=="string"){const r=C(this,js).get(s),a=r==null?void 0:r.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var r;const s=vl(t);if(typeof s=="string"){const a=(r=C(this,js).get(s))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ct.batch(()=>{C(this,Ws).forEach(t=>{this.notify({type:"removed",mutation:t})}),C(this,Ws).clear(),C(this,js).clear()})}getAll(){return Array.from(C(this,Ws))}find(t){const s={exact:!0,...t};return this.getAll().find(r=>Df(s,r))}findAll(t={}){return this.getAll().filter(s=>Df(t,s))}notify(t){ct.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return ct.batch(()=>Promise.all(t.map(s=>s.continue().catch(Rt))))}},Ws=new WeakMap,js=new WeakMap,Ui=new WeakMap,Mp);function vl(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Gs,Cn,Kt,Zs,nn,Ml,Hu,Lp,pN=(Lp=class extends Pa{constructor(s,r){super();ue(this,nn);ue(this,Gs);ue(this,Cn);ue(this,Kt);ue(this,Zs);te(this,Gs,s),this.setOptions(r),this.bindMethods(),ye(this,nn,Ml).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(s){var a;const r=this.options;this.options=C(this,Gs).defaultMutationOptions(s),ho(this.options,r)||C(this,Gs).getMutationCache().notify({type:"observerOptionsUpdated",mutation:C(this,Kt),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Nr(r.mutationKey)!==Nr(this.options.mutationKey)?this.reset():((a=C(this,Kt))==null?void 0:a.state.status)==="pending"&&C(this,Kt).setOptions(this.options)}onUnsubscribe(){var s;this.hasListeners()||(s=C(this,Kt))==null||s.removeObserver(this)}onMutationUpdate(s){ye(this,nn,Ml).call(this),ye(this,nn,Hu).call(this,s)}getCurrentResult(){return C(this,Cn)}reset(){var s;(s=C(this,Kt))==null||s.removeObserver(this),te(this,Kt,void 0),ye(this,nn,Ml).call(this),ye(this,nn,Hu).call(this)}mutate(s,r){var a;return te(this,Zs,r),(a=C(this,Kt))==null||a.removeObserver(this),te(this,Kt,C(this,Gs).getMutationCache().build(C(this,Gs),this.options)),C(this,Kt).addObserver(this),C(this,Kt).execute(s)}},Gs=new WeakMap,Cn=new WeakMap,Kt=new WeakMap,Zs=new WeakMap,nn=new WeakSet,Ml=function(){var r;const s=((r=C(this,Kt))==null?void 0:r.state)??fy();te(this,Cn,{...s,isPending:s.status==="pending",isSuccess:s.status==="success",isError:s.status==="error",isIdle:s.status==="idle",mutate:this.mutate,reset:this.reset})},Hu=function(s){ct.batch(()=>{var r,a,i,l,o,c,u,d;if(C(this,Zs)&&this.hasListeners()){const m=C(this,Cn).variables,p=C(this,Cn).context,h={client:C(this,Gs),meta:this.options.meta,mutationKey:this.options.mutationKey};if((s==null?void 0:s.type)==="success"){try{(a=(r=C(this,Zs)).onSuccess)==null||a.call(r,s.data,m,p,h)}catch(f){Promise.reject(f)}try{(l=(i=C(this,Zs)).onSettled)==null||l.call(i,s.data,null,m,p,h)}catch(f){Promise.reject(f)}}else if((s==null?void 0:s.type)==="error"){try{(c=(o=C(this,Zs)).onError)==null||c.call(o,s.error,m,p,h)}catch(f){Promise.reject(f)}try{(d=(u=C(this,Zs)).onSettled)==null||d.call(u,void 0,s.error,m,p,h)}catch(f){Promise.reject(f)}}}this.listeners.forEach(m=>{m(C(this,Cn))})})},Lp),Ls,Rp,gN=(Rp=class extends Pa{constructor(t={}){super();ue(this,Ls);this.config=t,te(this,Ls,new Map)}build(t,s,r){const a=s.queryKey,i=s.queryHash??th(a,s);let l=this.get(i);return l||(l=new oN({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(s),state:r,defaultOptions:t.getQueryDefaults(a)}),this.add(l)),l}add(t){C(this,Ls).has(t.queryHash)||(C(this,Ls).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=C(this,Ls).get(t.queryHash);s&&(t.destroy(),s===t&&C(this,Ls).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ct.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return C(this,Ls).get(t)}getAll(){return[...C(this,Ls).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(r=>Ef(s,r))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(r=>Ef(t,r)):s}notify(t){ct.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){ct.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ct.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ls=new WeakMap,Rp),Ze,En,Dn,ca,ua,Pn,da,ha,Op,xN=(Op=class{constructor(e={}){ue(this,Ze);ue(this,En);ue(this,Dn);ue(this,ca);ue(this,ua);ue(this,Pn);ue(this,da);ue(this,ha);te(this,Ze,e.queryCache||new gN),te(this,En,e.mutationCache||new fN),te(this,Dn,e.defaultOptions||{}),te(this,ca,new Map),te(this,ua,new Map),te(this,Pn,0)}mount(){tl(this,Pn)._++,C(this,Pn)===1&&(te(this,da,rh.subscribe(async e=>{e&&(await this.resumePausedMutations(),C(this,Ze).onFocus())})),te(this,ha,mo.subscribe(async e=>{e&&(await this.resumePausedMutations(),C(this,Ze).onOnline())})))}unmount(){var e,t;tl(this,Pn)._--,C(this,Pn)===0&&((e=C(this,da))==null||e.call(this),te(this,da,void 0),(t=C(this,ha))==null||t.call(this),te(this,ha,void 0))}isFetching(e){return C(this,Ze).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return C(this,En).findAll({...e,status:"pending"}).length}getQueryData(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=C(this,Ze).get(t.queryHash))==null?void 0:s.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=C(this,Ze).build(this,t),r=s.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(Bn(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return C(this,Ze).findAll(e).map(({queryKey:t,state:s})=>{const r=s.data;return[t,r]})}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),a=C(this,Ze).get(r.queryHash),i=a==null?void 0:a.state.data,l=Yb(t,i);if(l!==void 0)return C(this,Ze).build(this,r).setData(l,{...s,manual:!0})}setQueriesData(e,t,s){return ct.batch(()=>C(this,Ze).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,s)]))}getQueryState(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=C(this,Ze).get(t.queryHash))==null?void 0:s.state}removeQueries(e){const t=C(this,Ze);ct.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=C(this,Ze);return ct.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},r=ct.batch(()=>C(this,Ze).findAll(e).map(a=>a.cancel(s)));return Promise.all(r).then(Rt).catch(Rt)}invalidateQueries(e,t={}){return ct.batch(()=>(C(this,Ze).findAll(e).forEach(s=>{s.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},r=ct.batch(()=>C(this,Ze).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,s);return s.throwOnError||(i=i.catch(Rt)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Rt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=C(this,Ze).build(this,t);return s.isStaleByTime(Bn(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Rt).catch(Rt)}fetchInfiniteQuery(e){return e.behavior=Lf(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Rt).catch(Rt)}ensureInfiniteQueryData(e){return e.behavior=Lf(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return mo.isOnline()?C(this,En).resumePausedMutations():Promise.resolve()}getQueryCache(){return C(this,Ze)}getMutationCache(){return C(this,En)}getDefaultOptions(){return C(this,Dn)}setDefaultOptions(e){te(this,Dn,e)}setQueryDefaults(e,t){C(this,ca).set(Nr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...C(this,ca).values()],s={};return t.forEach(r=>{Di(e,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(e,t){C(this,ua).set(Nr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...C(this,ua).values()],s={};return t.forEach(r=>{Di(e,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...C(this,Dn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=th(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===sh&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...C(this,Dn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){C(this,Ze).clear(),C(this,En).clear()}},Ze=new WeakMap,En=new WeakMap,Dn=new WeakMap,ca=new WeakMap,ua=new WeakMap,Pn=new WeakMap,da=new WeakMap,ha=new WeakMap,Op),py=w.createContext(void 0),pe=e=>{const t=w.useContext(py);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},yN=({client:e,children:t})=>(w.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),n.jsx(py.Provider,{value:e,children:t})),gy=w.createContext(!1),vN=()=>w.useContext(gy);gy.Provider;function jN(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var bN=w.createContext(jN()),NN=()=>w.useContext(bN),wN=(e,t,s)=>{const r=s!=null&&s.state.error&&typeof e.throwOnError=="function"?nh(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},SN=e=>{w.useEffect(()=>{e.clearReset()},[e])},kN=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||nh(s,[e.error,r])),CN=e=>{if(e.suspense){const s=a=>a==="static"?a:Math.max(a??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...a)=>s(r(...a)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},EN=(e,t)=>e.isLoading&&e.isFetching&&!t,DN=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Of=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function PN(e,t,s){var p,h,f,g;const r=vN(),a=NN(),i=pe(),l=i.defaultQueryOptions(e);(h=(p=i.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||h.call(p,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",CN(l),wN(l,a,o),SN(a);const c=!i.getQueryCache().get(l.queryHash),[u]=w.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),m=!r&&e.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(b=>{const y=m?u.subscribe(ct.batchCalls(b)):Rt;return u.updateResult(),y},[u,m]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),w.useEffect(()=>{u.setOptions(l)},[l,u]),DN(l,d))throw Of(l,u,a);if(kN({result:d,errorResetBoundary:a,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((g=(f=i.getDefaultOptions().queries)==null?void 0:f._experimental_afterQuery)==null||g.call(f,l,d),l.experimental_prefetchInRender&&!br&&EN(d,r)){const b=c?Of(l,u,a):o==null?void 0:o.promise;b==null||b.catch(Rt).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function ge(e,t){return PN(e,cN)}function Y(e,t){const s=pe(),[r]=w.useState(()=>new pN(s,e));w.useEffect(()=>{r.setOptions(e)},[r,e]);const a=w.useSyncExternalStore(w.useCallback(l=>r.subscribe(ct.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=w.useCallback((l,o)=>{r.mutate(l,o).catch(Rt)},[r]);if(a.error&&nh(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}function xy(e,t){return function(){return e.apply(t,arguments)}}const{toString:AN}=Object.prototype,{getPrototypeOf:ih}=Object,{iterator:$o,toStringTag:yy}=Symbol,Bo=(e=>t=>{const s=AN.call(t);return e[s]||(e[s]=s.slice(8,-1).toLowerCase())})(Object.create(null)),Ds=e=>(e=e.toLowerCase(),t=>Bo(t)===e),Ko=e=>t=>typeof t===e,{isArray:Aa}=Array,ba=Ko("undefined");function Qi(e){return e!==null&&!ba(e)&&e.constructor!==null&&!ba(e.constructor)&&Zt(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const vy=Ds("ArrayBuffer");function TN(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&vy(e.buffer),t}const FN=Ko("string"),Zt=Ko("function"),jy=Ko("number"),Hi=e=>e!==null&&typeof e=="object",IN=e=>e===!0||e===!1,Ll=e=>{if(Bo(e)!=="object")return!1;const t=ih(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(yy in e)&&!($o in e)},MN=e=>{if(!Hi(e)||Qi(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},LN=Ds("Date"),RN=Ds("File"),ON=Ds("Blob"),_N=Ds("FileList"),zN=e=>Hi(e)&&Zt(e.pipe),UN=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||Zt(e.append)&&((t=Bo(e))==="formdata"||t==="object"&&Zt(e.toString)&&e.toString()==="[object FormData]"))},$N=Ds("URLSearchParams"),[BN,KN,VN,qN]=["ReadableStream","Request","Response","Headers"].map(Ds),QN=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Wi(e,t,{allOwnKeys:s=!1}={}){if(e===null||typeof e>"u")return;let r,a;if(typeof e!="object"&&(e=[e]),Aa(e))for(r=0,a=e.length;r<a;r++)t.call(null,e[r],r,e);else{if(Qi(e))return;const i=s?Object.getOwnPropertyNames(e):Object.keys(e),l=i.length;let o;for(r=0;r<l;r++)o=i[r],t.call(null,e[o],o,e)}}function by(e,t){if(Qi(e))return null;t=t.toLowerCase();const s=Object.keys(e);let r=s.length,a;for(;r-- >0;)if(a=s[r],t===a.toLowerCase())return a;return null}const sr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ny=e=>!ba(e)&&e!==sr;function Wu(){const{caseless:e,skipUndefined:t}=Ny(this)&&this||{},s={},r=(a,i)=>{const l=e&&by(s,i)||i;Ll(s[l])&&Ll(a)?s[l]=Wu(s[l],a):Ll(a)?s[l]=Wu({},a):Aa(a)?s[l]=a.slice():(!t||!ba(a))&&(s[l]=a)};for(let a=0,i=arguments.length;a<i;a++)arguments[a]&&Wi(arguments[a],r);return s}const HN=(e,t,s,{allOwnKeys:r}={})=>(Wi(t,(a,i)=>{s&&Zt(a)?e[i]=xy(a,s):e[i]=a},{allOwnKeys:r}),e),WN=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),GN=(e,t,s,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),s&&Object.assign(e.prototype,s)},ZN=(e,t,s,r)=>{let a,i,l;const o={};if(t=t||{},e==null)return t;do{for(a=Object.getOwnPropertyNames(e),i=a.length;i-- >0;)l=a[i],(!r||r(l,e,t))&&!o[l]&&(t[l]=e[l],o[l]=!0);e=s!==!1&&ih(e)}while(e&&(!s||s(e,t))&&e!==Object.prototype);return t},YN=(e,t,s)=>{e=String(e),(s===void 0||s>e.length)&&(s=e.length),s-=t.length;const r=e.indexOf(t,s);return r!==-1&&r===s},JN=e=>{if(!e)return null;if(Aa(e))return e;let t=e.length;if(!jy(t))return null;const s=new Array(t);for(;t-- >0;)s[t]=e[t];return s},XN=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ih(Uint8Array)),ew=(e,t)=>{const r=(e&&e[$o]).call(e);let a;for(;(a=r.next())&&!a.done;){const i=a.value;t.call(e,i[0],i[1])}},tw=(e,t)=>{let s;const r=[];for(;(s=e.exec(t))!==null;)r.push(s);return r},sw=Ds("HTMLFormElement"),nw=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(s,r,a){return r.toUpperCase()+a}),_f=(({hasOwnProperty:e})=>(t,s)=>e.call(t,s))(Object.prototype),rw=Ds("RegExp"),wy=(e,t)=>{const s=Object.getOwnPropertyDescriptors(e),r={};Wi(s,(a,i)=>{let l;(l=t(a,i,e))!==!1&&(r[i]=l||a)}),Object.defineProperties(e,r)},aw=e=>{wy(e,(t,s)=>{if(Zt(e)&&["arguments","caller","callee"].indexOf(s)!==-1)return!1;const r=e[s];if(Zt(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")})}})},iw=(e,t)=>{const s={},r=a=>{a.forEach(i=>{s[i]=!0})};return Aa(e)?r(e):r(String(e).split(t)),s},lw=()=>{},ow=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function cw(e){return!!(e&&Zt(e.append)&&e[yy]==="FormData"&&e[$o])}const uw=e=>{const t=new Array(10),s=(r,a)=>{if(Hi(r)){if(t.indexOf(r)>=0)return;if(Qi(r))return r;if(!("toJSON"in r)){t[a]=r;const i=Aa(r)?[]:{};return Wi(r,(l,o)=>{const c=s(l,a+1);!ba(c)&&(i[o]=c)}),t[a]=void 0,i}}return r};return s(e,0)},dw=Ds("AsyncFunction"),hw=e=>e&&(Hi(e)||Zt(e))&&Zt(e.then)&&Zt(e.catch),Sy=((e,t)=>e?setImmediate:t?((s,r)=>(sr.addEventListener("message",({source:a,data:i})=>{a===sr&&i===s&&r.length&&r.shift()()},!1),a=>{r.push(a),sr.postMessage(s,"*")}))(`axios@${Math.random()}`,[]):s=>setTimeout(s))(typeof setImmediate=="function",Zt(sr.postMessage)),mw=typeof queueMicrotask<"u"?queueMicrotask.bind(sr):typeof process<"u"&&process.nextTick||Sy,fw=e=>e!=null&&Zt(e[$o]),R={isArray:Aa,isArrayBuffer:vy,isBuffer:Qi,isFormData:UN,isArrayBufferView:TN,isString:FN,isNumber:jy,isBoolean:IN,isObject:Hi,isPlainObject:Ll,isEmptyObject:MN,isReadableStream:BN,isRequest:KN,isResponse:VN,isHeaders:qN,isUndefined:ba,isDate:LN,isFile:RN,isBlob:ON,isRegExp:rw,isFunction:Zt,isStream:zN,isURLSearchParams:$N,isTypedArray:XN,isFileList:_N,forEach:Wi,merge:Wu,extend:HN,trim:QN,stripBOM:WN,inherits:GN,toFlatObject:ZN,kindOf:Bo,kindOfTest:Ds,endsWith:YN,toArray:JN,forEachEntry:ew,matchAll:tw,isHTMLForm:sw,hasOwnProperty:_f,hasOwnProp:_f,reduceDescriptors:wy,freezeMethods:aw,toObjectSet:iw,toCamelCase:nw,noop:lw,toFiniteNumber:ow,findKey:by,global:sr,isContextDefined:Ny,isSpecCompliantForm:cw,toJSONObject:uw,isAsyncFn:dw,isThenable:hw,setImmediate:Sy,asap:mw,isIterable:fw};function xe(e,t,s,r,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),s&&(this.config=s),r&&(this.request=r),a&&(this.response=a,this.status=a.status?a.status:null)}R.inherits(xe,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:R.toJSONObject(this.config),code:this.code,status:this.status}}});const ky=xe.prototype,Cy={};["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(e=>{Cy[e]={value:e}});Object.defineProperties(xe,Cy);Object.defineProperty(ky,"isAxiosError",{value:!0});xe.from=(e,t,s,r,a,i)=>{const l=Object.create(ky);R.toFlatObject(e,l,function(d){return d!==Error.prototype},u=>u!=="isAxiosError");const o=e&&e.message?e.message:"Error",c=t==null&&e?e.code:t;return xe.call(l,o,c,s,r,a),e&&l.cause==null&&Object.defineProperty(l,"cause",{value:e,configurable:!0}),l.name=e&&e.name||"Error",i&&Object.assign(l,i),l};const pw=null;function Gu(e){return R.isPlainObject(e)||R.isArray(e)}function Ey(e){return R.endsWith(e,"[]")?e.slice(0,-2):e}function zf(e,t,s){return e?e.concat(t).map(function(a,i){return a=Ey(a),!s&&i?"["+a+"]":a}).join(s?".":""):t}function gw(e){return R.isArray(e)&&!e.some(Gu)}const xw=R.toFlatObject(R,{},null,function(t){return/^is[A-Z]/.test(t)});function Vo(e,t,s){if(!R.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,s=R.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(g,b){return!R.isUndefined(b[g])});const r=s.metaTokens,a=s.visitor||d,i=s.dots,l=s.indexes,c=(s.Blob||typeof Blob<"u"&&Blob)&&R.isSpecCompliantForm(t);if(!R.isFunction(a))throw new TypeError("visitor must be a function");function u(f){if(f===null)return"";if(R.isDate(f))return f.toISOString();if(R.isBoolean(f))return f.toString();if(!c&&R.isBlob(f))throw new xe("Blob is not supported. Use a Buffer instead.");return R.isArrayBuffer(f)||R.isTypedArray(f)?c&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function d(f,g,b){let y=f;if(f&&!b&&typeof f=="object"){if(R.endsWith(g,"{}"))g=r?g:g.slice(0,-2),f=JSON.stringify(f);else if(R.isArray(f)&&gw(f)||(R.isFileList(f)||R.endsWith(g,"[]"))&&(y=R.toArray(f)))return g=Ey(g),y.forEach(function(x,N){!(R.isUndefined(x)||x===null)&&t.append(l===!0?zf([g],N,i):l===null?g:g+"[]",u(x))}),!1}return Gu(f)?!0:(t.append(zf(b,g,i),u(f)),!1)}const m=[],p=Object.assign(xw,{defaultVisitor:d,convertValue:u,isVisitable:Gu});function h(f,g){if(!R.isUndefined(f)){if(m.indexOf(f)!==-1)throw Error("Circular reference detected in "+g.join("."));m.push(f),R.forEach(f,function(y,v){(!(R.isUndefined(y)||y===null)&&a.call(t,y,R.isString(v)?v.trim():v,g,p))===!0&&h(y,g?g.concat(v):[v])}),m.pop()}}if(!R.isObject(e))throw new TypeError("data must be an object");return h(e),t}function Uf(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function lh(e,t){this._pairs=[],e&&Vo(e,this,t)}const Dy=lh.prototype;Dy.append=function(t,s){this._pairs.push([t,s])};Dy.toString=function(t){const s=t?function(r){return t.call(this,r,Uf)}:Uf;return this._pairs.map(function(a){return s(a[0])+"="+s(a[1])},"").join("&")};function yw(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Py(e,t,s){if(!t)return e;const r=s&&s.encode||yw;R.isFunction(s)&&(s={serialize:s});const a=s&&s.serialize;let i;if(a?i=a(t,s):i=R.isURLSearchParams(t)?t.toString():new lh(t,s).toString(r),i){const l=e.indexOf("#");l!==-1&&(e=e.slice(0,l)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class $f{constructor(){this.handlers=[]}use(t,s,r){return this.handlers.push({fulfilled:t,rejected:s,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){R.forEach(this.handlers,function(r){r!==null&&t(r)})}}const Ay={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},vw=typeof URLSearchParams<"u"?URLSearchParams:lh,jw=typeof FormData<"u"?FormData:null,bw=typeof Blob<"u"?Blob:null,Nw={isBrowser:!0,classes:{URLSearchParams:vw,FormData:jw,Blob:bw},protocols:["http","https","file","blob","url","data"]},oh=typeof window<"u"&&typeof document<"u",Zu=typeof navigator=="object"&&navigator||void 0,ww=oh&&(!Zu||["ReactNative","NativeScript","NS"].indexOf(Zu.product)<0),Sw=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",kw=oh&&window.location.href||"http://localhost",Cw=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:oh,hasStandardBrowserEnv:ww,hasStandardBrowserWebWorkerEnv:Sw,navigator:Zu,origin:kw},Symbol.toStringTag,{value:"Module"})),Dt={...Cw,...Nw};function Ew(e,t){return Vo(e,new Dt.classes.URLSearchParams,{visitor:function(s,r,a,i){return Dt.isNode&&R.isBuffer(s)?(this.append(r,s.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)},...t})}function Dw(e){return R.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Pw(e){const t={},s=Object.keys(e);let r;const a=s.length;let i;for(r=0;r<a;r++)i=s[r],t[i]=e[i];return t}function Ty(e){function t(s,r,a,i){let l=s[i++];if(l==="__proto__")return!0;const o=Number.isFinite(+l),c=i>=s.length;return l=!l&&R.isArray(a)?a.length:l,c?(R.hasOwnProp(a,l)?a[l]=[a[l],r]:a[l]=r,!o):((!a[l]||!R.isObject(a[l]))&&(a[l]=[]),t(s,r,a[l],i)&&R.isArray(a[l])&&(a[l]=Pw(a[l])),!o)}if(R.isFormData(e)&&R.isFunction(e.entries)){const s={};return R.forEachEntry(e,(r,a)=>{t(Dw(r),a,s,0)}),s}return null}function Aw(e,t,s){if(R.isString(e))try{return(t||JSON.parse)(e),R.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(s||JSON.stringify)(e)}const Gi={transitional:Ay,adapter:["xhr","http","fetch"],transformRequest:[function(t,s){const r=s.getContentType()||"",a=r.indexOf("application/json")>-1,i=R.isObject(t);if(i&&R.isHTMLForm(t)&&(t=new FormData(t)),R.isFormData(t))return a?JSON.stringify(Ty(t)):t;if(R.isArrayBuffer(t)||R.isBuffer(t)||R.isStream(t)||R.isFile(t)||R.isBlob(t)||R.isReadableStream(t))return t;if(R.isArrayBufferView(t))return t.buffer;if(R.isURLSearchParams(t))return s.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Ew(t,this.formSerializer).toString();if((o=R.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Vo(o?{"files[]":t}:t,c&&new c,this.formSerializer)}}return i||a?(s.setContentType("application/json",!1),Aw(t)):t}],transformResponse:[function(t){const s=this.transitional||Gi.transitional,r=s&&s.forcedJSONParsing,a=this.responseType==="json";if(R.isResponse(t)||R.isReadableStream(t))return t;if(t&&R.isString(t)&&(r&&!this.responseType||a)){const l=!(s&&s.silentJSONParsing)&&a;try{return JSON.parse(t,this.parseReviver)}catch(o){if(l)throw o.name==="SyntaxError"?xe.from(o,xe.ERR_BAD_RESPONSE,this,null,this.response):o}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Dt.classes.FormData,Blob:Dt.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};R.forEach(["delete","get","head","post","put","patch"],e=>{Gi.headers[e]={}});const Tw=R.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"]),Fw=e=>{const t={};let s,r,a;return e&&e.split(`
`).forEach(function(l){a=l.indexOf(":"),s=l.substring(0,a).trim().toLowerCase(),r=l.substring(a+1).trim(),!(!s||t[s]&&Tw[s])&&(s==="set-cookie"?t[s]?t[s].push(r):t[s]=[r]:t[s]=t[s]?t[s]+", "+r:r)}),t},Bf=Symbol("internals");function Ka(e){return e&&String(e).trim().toLowerCase()}function Rl(e){return e===!1||e==null?e:R.isArray(e)?e.map(Rl):String(e)}function Iw(e){const t=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=s.exec(e);)t[r[1]]=r[2];return t}const Mw=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ec(e,t,s,r,a){if(R.isFunction(r))return r.call(this,t,s);if(a&&(t=s),!!R.isString(t)){if(R.isString(r))return t.indexOf(r)!==-1;if(R.isRegExp(r))return r.test(t)}}function Lw(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,s,r)=>s.toUpperCase()+r)}function Rw(e,t){const s=R.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+s,{value:function(a,i,l){return this[r].call(this,t,a,i,l)},configurable:!0})})}let Yt=class{constructor(t){t&&this.set(t)}set(t,s,r){const a=this;function i(o,c,u){const d=Ka(c);if(!d)throw new Error("header name must be a non-empty string");const m=R.findKey(a,d);(!m||a[m]===void 0||u===!0||u===void 0&&a[m]!==!1)&&(a[m||c]=Rl(o))}const l=(o,c)=>R.forEach(o,(u,d)=>i(u,d,c));if(R.isPlainObject(t)||t instanceof this.constructor)l(t,s);else if(R.isString(t)&&(t=t.trim())&&!Mw(t))l(Fw(t),s);else if(R.isObject(t)&&R.isIterable(t)){let o={},c,u;for(const d of t){if(!R.isArray(d))throw TypeError("Object iterator must return a key-value pair");o[u=d[0]]=(c=o[u])?R.isArray(c)?[...c,d[1]]:[c,d[1]]:d[1]}l(o,s)}else t!=null&&i(s,t,r);return this}get(t,s){if(t=Ka(t),t){const r=R.findKey(this,t);if(r){const a=this[r];if(!s)return a;if(s===!0)return Iw(a);if(R.isFunction(s))return s.call(this,a,r);if(R.isRegExp(s))return s.exec(a);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,s){if(t=Ka(t),t){const r=R.findKey(this,t);return!!(r&&this[r]!==void 0&&(!s||Ec(this,this[r],r,s)))}return!1}delete(t,s){const r=this;let a=!1;function i(l){if(l=Ka(l),l){const o=R.findKey(r,l);o&&(!s||Ec(r,r[o],o,s))&&(delete r[o],a=!0)}}return R.isArray(t)?t.forEach(i):i(t),a}clear(t){const s=Object.keys(this);let r=s.length,a=!1;for(;r--;){const i=s[r];(!t||Ec(this,this[i],i,t,!0))&&(delete this[i],a=!0)}return a}normalize(t){const s=this,r={};return R.forEach(this,(a,i)=>{const l=R.findKey(r,i);if(l){s[l]=Rl(a),delete s[i];return}const o=t?Lw(i):String(i).trim();o!==i&&delete s[i],s[o]=Rl(a),r[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const s=Object.create(null);return R.forEach(this,(r,a)=>{r!=null&&r!==!1&&(s[a]=t&&R.isArray(r)?r.join(", "):r)}),s}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,s])=>t+": "+s).join(`
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...s){const r=new this(t);return s.forEach(a=>r.set(a)),r}static accessor(t){const r=(this[Bf]=this[Bf]={accessors:{}}).accessors,a=this.prototype;function i(l){const o=Ka(l);r[o]||(Rw(a,l),r[o]=!0)}return R.isArray(t)?t.forEach(i):i(t),this}};Yt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);R.reduceDescriptors(Yt.prototype,({value:e},t)=>{let s=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[s]=r}}});R.freezeMethods(Yt);function Dc(e,t){const s=this||Gi,r=t||s,a=Yt.from(r.headers);let i=r.data;return R.forEach(e,function(o){i=o.call(s,i,a.normalize(),t?t.status:void 0)}),a.normalize(),i}function Fy(e){return!!(e&&e.__CANCEL__)}function Ta(e,t,s){xe.call(this,e??"canceled",xe.ERR_CANCELED,t,s),this.name="CanceledError"}R.inherits(Ta,xe,{__CANCEL__:!0});function Iy(e,t,s){const r=s.config.validateStatus;!s.status||!r||r(s.status)?e(s):t(new xe("Request failed with status code "+s.status,[xe.ERR_BAD_REQUEST,xe.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function Ow(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function _w(e,t){e=e||10;const s=new Array(e),r=new Array(e);let a=0,i=0,l;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),d=r[i];l||(l=u),s[a]=c,r[a]=u;let m=i,p=0;for(;m!==a;)p+=s[m++],m=m%e;if(a=(a+1)%e,a===i&&(i=(i+1)%e),u-l<t)return;const h=d&&u-d;return h?Math.round(p*1e3/h):void 0}}function zw(e,t){let s=0,r=1e3/t,a,i;const l=(u,d=Date.now())=>{s=d,a=null,i&&(clearTimeout(i),i=null),e(...u)};return[(...u)=>{const d=Date.now(),m=d-s;m>=r?l(u,d):(a=u,i||(i=setTimeout(()=>{i=null,l(a)},r-m)))},()=>a&&l(a)]}const fo=(e,t,s=3)=>{let r=0;const a=_w(50,250);return zw(i=>{const l=i.loaded,o=i.lengthComputable?i.total:void 0,c=l-r,u=a(c),d=l<=o;r=l;const m={loaded:l,total:o,progress:o?l/o:void 0,bytes:c,rate:u||void 0,estimated:u&&o&&d?(o-l)/u:void 0,event:i,lengthComputable:o!=null,[t?"download":"upload"]:!0};e(m)},s)},Kf=(e,t)=>{const s=e!=null;return[r=>t[0]({lengthComputable:s,total:e,loaded:r}),t[1]]},Vf=e=>(...t)=>R.asap(()=>e(...t)),Uw=Dt.hasStandardBrowserEnv?((e,t)=>s=>(s=new URL(s,Dt.origin),e.protocol===s.protocol&&e.host===s.host&&(t||e.port===s.port)))(new URL(Dt.origin),Dt.navigator&&/(msie|trident)/i.test(Dt.navigator.userAgent)):()=>!0,$w=Dt.hasStandardBrowserEnv?{write(e,t,s,r,a,i,l){if(typeof document>"u")return;const o=[`${e}=${encodeURIComponent(t)}`];R.isNumber(s)&&o.push(`expires=${new Date(s).toUTCString()}`),R.isString(r)&&o.push(`path=${r}`),R.isString(a)&&o.push(`domain=${a}`),i===!0&&o.push("secure"),R.isString(l)&&o.push(`SameSite=${l}`),document.cookie=o.join("; ")},read(e){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Bw(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Kw(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function My(e,t,s){let r=!Bw(t);return e&&(r||s==!1)?Kw(e,t):t}const qf=e=>e instanceof Yt?{...e}:e;function wr(e,t){t=t||{};const s={};function r(u,d,m,p){return R.isPlainObject(u)&&R.isPlainObject(d)?R.merge.call({caseless:p},u,d):R.isPlainObject(d)?R.merge({},d):R.isArray(d)?d.slice():d}function a(u,d,m,p){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u,m,p)}else return r(u,d,m,p)}function i(u,d){if(!R.isUndefined(d))return r(void 0,d)}function l(u,d){if(R.isUndefined(d)){if(!R.isUndefined(u))return r(void 0,u)}else return r(void 0,d)}function o(u,d,m){if(m in t)return r(u,d);if(m in e)return r(void 0,u)}const c={url:i,method:i,data:i,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:(u,d,m)=>a(qf(u),qf(d),m,!0)};return R.forEach(Object.keys({...e,...t}),function(d){const m=c[d]||a,p=m(e[d],t[d],d);R.isUndefined(p)&&m!==o||(s[d]=p)}),s}const Ly=e=>{const t=wr({},e);let{data:s,withXSRFToken:r,xsrfHeaderName:a,xsrfCookieName:i,headers:l,auth:o}=t;if(t.headers=l=Yt.from(l),t.url=Py(My(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&l.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),R.isFormData(s)){if(Dt.hasStandardBrowserEnv||Dt.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(R.isFunction(s.getHeaders)){const c=s.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([d,m])=>{u.includes(d.toLowerCase())&&l.set(d,m)})}}if(Dt.hasStandardBrowserEnv&&(r&&R.isFunction(r)&&(r=r(t)),r||r!==!1&&Uw(t.url))){const c=a&&i&&$w.read(i);c&&l.set(a,c)}return t},Vw=typeof XMLHttpRequest<"u",qw=Vw&&function(e){return new Promise(function(s,r){const a=Ly(e);let i=a.data;const l=Yt.from(a.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:u}=a,d,m,p,h,f;function g(){h&&h(),f&&f(),a.cancelToken&&a.cancelToken.unsubscribe(d),a.signal&&a.signal.removeEventListener("abort",d)}let b=new XMLHttpRequest;b.open(a.method.toUpperCase(),a.url,!0),b.timeout=a.timeout;function y(){if(!b)return;const x=Yt.from("getAllResponseHeaders"in b&&b.getAllResponseHeaders()),k={data:!o||o==="text"||o==="json"?b.responseText:b.response,status:b.status,statusText:b.statusText,headers:x,config:e,request:b};Iy(function(F){s(F),g()},function(F){r(F),g()},k),b=null}"onloadend"in b?b.onloadend=y:b.onreadystatechange=function(){!b||b.readyState!==4||b.status===0&&!(b.responseURL&&b.responseURL.indexOf("file:")===0)||setTimeout(y)},b.onabort=function(){b&&(r(new xe("Request aborted",xe.ECONNABORTED,e,b)),b=null)},b.onerror=function(N){const k=N&&N.message?N.message:"Network Error",D=new xe(k,xe.ERR_NETWORK,e,b);D.event=N||null,r(D),b=null},b.ontimeout=function(){let N=a.timeout?"timeout of "+a.timeout+"ms exceeded":"timeout exceeded";const k=a.transitional||Ay;a.timeoutErrorMessage&&(N=a.timeoutErrorMessage),r(new xe(N,k.clarifyTimeoutError?xe.ETIMEDOUT:xe.ECONNABORTED,e,b)),b=null},i===void 0&&l.setContentType(null),"setRequestHeader"in b&&R.forEach(l.toJSON(),function(N,k){b.setRequestHeader(k,N)}),R.isUndefined(a.withCredentials)||(b.withCredentials=!!a.withCredentials),o&&o!=="json"&&(b.responseType=a.responseType),u&&([p,f]=fo(u,!0),b.addEventListener("progress",p)),c&&b.upload&&([m,h]=fo(c),b.upload.addEventListener("progress",m),b.upload.addEventListener("loadend",h)),(a.cancelToken||a.signal)&&(d=x=>{b&&(r(!x||x.type?new Ta(null,e,b):x),b.abort(),b=null)},a.cancelToken&&a.cancelToken.subscribe(d),a.signal&&(a.signal.aborted?d():a.signal.addEventListener("abort",d)));const v=Ow(a.url);if(v&&Dt.protocols.indexOf(v)===-1){r(new xe("Unsupported protocol "+v+":",xe.ERR_BAD_REQUEST,e));return}b.send(i||null)})},Qw=(e,t)=>{const{length:s}=e=e?e.filter(Boolean):[];if(t||s){let r=new AbortController,a;const i=function(u){if(!a){a=!0,o();const d=u instanceof Error?u:this.reason;r.abort(d instanceof xe?d:new Ta(d instanceof Error?d.message:d))}};let l=t&&setTimeout(()=>{l=null,i(new xe(`timeout ${t} of ms exceeded`,xe.ETIMEDOUT))},t);const o=()=>{e&&(l&&clearTimeout(l),l=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:c}=r;return c.unsubscribe=()=>R.asap(o),c}},Hw=function*(e,t){let s=e.byteLength;if(s<t){yield e;return}let r=0,a;for(;r<s;)a=r+t,yield e.slice(r,a),r=a},Ww=async function*(e,t){for await(const s of Gw(e))yield*Hw(s,t)},Gw=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:s,value:r}=await t.read();if(s)break;yield r}}finally{await t.cancel()}},Qf=(e,t,s,r)=>{const a=Ww(e,t);let i=0,l,o=c=>{l||(l=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:u,value:d}=await a.next();if(u){o(),c.close();return}let m=d.byteLength;if(s){let p=i+=m;s(p)}c.enqueue(new Uint8Array(d))}catch(u){throw o(u),u}},cancel(c){return o(c),a.return()}},{highWaterMark:2})},Hf=64*1024,{isFunction:jl}=R,Zw=(({Request:e,Response:t})=>({Request:e,Response:t}))(R.global),{ReadableStream:Wf,TextEncoder:Gf}=R.global,Zf=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Yw=e=>{e=R.merge.call({skipUndefined:!0},Zw,e);const{fetch:t,Request:s,Response:r}=e,a=t?jl(t):typeof fetch=="function",i=jl(s),l=jl(r);if(!a)return!1;const o=a&&jl(Wf),c=a&&(typeof Gf=="function"?(f=>g=>f.encode(g))(new Gf):async f=>new Uint8Array(await new s(f).arrayBuffer())),u=i&&o&&Zf(()=>{let f=!1;const g=new s(Dt.origin,{body:new Wf,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!g}),d=l&&o&&Zf(()=>R.isReadableStream(new r("").body)),m={stream:d&&(f=>f.body)};a&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!m[f]&&(m[f]=(g,b)=>{let y=g&&g[f];if(y)return y.call(g);throw new xe(`Response type '${f}' is not supported`,xe.ERR_NOT_SUPPORT,b)})});const p=async f=>{if(f==null)return 0;if(R.isBlob(f))return f.size;if(R.isSpecCompliantForm(f))return(await new s(Dt.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(R.isArrayBufferView(f)||R.isArrayBuffer(f))return f.byteLength;if(R.isURLSearchParams(f)&&(f=f+""),R.isString(f))return(await c(f)).byteLength},h=async(f,g)=>{const b=R.toFiniteNumber(f.getContentLength());return b??p(g)};return async f=>{let{url:g,method:b,data:y,signal:v,cancelToken:x,timeout:N,onDownloadProgress:k,onUploadProgress:D,responseType:F,headers:S,withCredentials:L="same-origin",fetchOptions:T}=Ly(f),_=t||fetch;F=F?(F+"").toLowerCase():"text";let K=Qw([v,x&&x.toAbortSignal()],N),W=null;const Q=K&&K.unsubscribe&&(()=>{K.unsubscribe()});let z;try{if(D&&u&&b!=="get"&&b!=="head"&&(z=await h(S,y))!==0){let me=new s(g,{method:"POST",body:y,duplex:"half"}),ve;if(R.isFormData(y)&&(ve=me.headers.get("content-type"))&&S.setContentType(ve),me.body){const[it,V]=Kf(z,fo(Vf(D)));y=Qf(me.body,Hf,it,V)}}R.isString(L)||(L=L?"include":"omit");const P=i&&"credentials"in s.prototype,j={...T,signal:K,method:b.toUpperCase(),headers:S.normalize().toJSON(),body:y,duplex:"half",credentials:P?L:void 0};W=i&&new s(g,j);let B=await(i?_(W,T):_(g,j));const J=d&&(F==="stream"||F==="response");if(d&&(k||J&&Q)){const me={};["status","statusText","headers"].forEach(Ce=>{me[Ce]=B[Ce]});const ve=R.toFiniteNumber(B.headers.get("content-length")),[it,V]=k&&Kf(ve,fo(Vf(k),!0))||[];B=new r(Qf(B.body,Hf,it,()=>{V&&V(),Q&&Q()}),me)}F=F||"text";let ee=await m[R.findKey(m,F)||"text"](B,f);return!J&&Q&&Q(),await new Promise((me,ve)=>{Iy(me,ve,{data:ee,headers:Yt.from(B.headers),status:B.status,statusText:B.statusText,config:f,request:W})})}catch(P){throw Q&&Q(),P&&P.name==="TypeError"&&/Load failed|fetch/i.test(P.message)?Object.assign(new xe("Network Error",xe.ERR_NETWORK,f,W),{cause:P.cause||P}):xe.from(P,P&&P.code,f,W)}}},Jw=new Map,Ry=e=>{let t=e&&e.env||{};const{fetch:s,Request:r,Response:a}=t,i=[r,a,s];let l=i.length,o=l,c,u,d=Jw;for(;o--;)c=i[o],u=d.get(c),u===void 0&&d.set(c,u=o?new Map:Yw(t)),d=u;return u};Ry();const ch={http:pw,xhr:qw,fetch:{get:Ry}};R.forEach(ch,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Yf=e=>`- ${e}`,Xw=e=>R.isFunction(e)||e===null||e===!1;function e1(e,t){e=R.isArray(e)?e:[e];const{length:s}=e;let r,a;const i={};for(let l=0;l<s;l++){r=e[l];let o;if(a=r,!Xw(r)&&(a=ch[(o=String(r)).toLowerCase()],a===void 0))throw new xe(`Unknown adapter '${o}'`);if(a&&(R.isFunction(a)||(a=a.get(t))))break;i[o||"#"+l]=a}if(!a){const l=Object.entries(i).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build"));let o=s?l.length>1?`since :
`+l.map(Yf).join(`
`):" "+Yf(l[0]):"as no adapter specified";throw new xe("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return a}const Oy={getAdapter:e1,adapters:ch};function Pc(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Ta(null,e)}function Jf(e){return Pc(e),e.headers=Yt.from(e.headers),e.data=Dc.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Oy.getAdapter(e.adapter||Gi.adapter,e)(e).then(function(r){return Pc(e),r.data=Dc.call(e,e.transformResponse,r),r.headers=Yt.from(r.headers),r},function(r){return Fy(r)||(Pc(e),r&&r.response&&(r.response.data=Dc.call(e,e.transformResponse,r.response),r.response.headers=Yt.from(r.response.headers))),Promise.reject(r)})}const _y="1.13.2",qo={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{qo[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Xf={};qo.transitional=function(t,s,r){function a(i,l){return"[Axios v"+_y+"] Transitional option '"+i+"'"+l+(r?". "+r:"")}return(i,l,o)=>{if(t===!1)throw new xe(a(l," has been removed"+(s?" in "+s:"")),xe.ERR_DEPRECATED);return s&&!Xf[l]&&(Xf[l]=!0,console.warn(a(l," has been deprecated since v"+s+" and will be removed in the near future"))),t?t(i,l,o):!0}};qo.spelling=function(t){return(s,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function t1(e,t,s){if(typeof e!="object")throw new xe("options must be an object",xe.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let a=r.length;for(;a-- >0;){const i=r[a],l=t[i];if(l){const o=e[i],c=o===void 0||l(o,i,e);if(c!==!0)throw new xe("option "+i+" must be "+c,xe.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new xe("Unknown option "+i,xe.ERR_BAD_OPTION)}}const Ol={assertOptions:t1,validators:qo},As=Ol.validators;let pr=class{constructor(t){this.defaults=t||{},this.interceptors={request:new $f,response:new $f}}async request(t,s){try{return await this._request(t,s)}catch(r){if(r instanceof Error){let a={};Error.captureStackTrace?Error.captureStackTrace(a):a=new Error;const i=a.stack?a.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
`+i):r.stack=i}catch{}}throw r}}_request(t,s){typeof t=="string"?(s=s||{},s.url=t):s=t||{},s=wr(this.defaults,s);const{transitional:r,paramsSerializer:a,headers:i}=s;r!==void 0&&Ol.assertOptions(r,{silentJSONParsing:As.transitional(As.boolean),forcedJSONParsing:As.transitional(As.boolean),clarifyTimeoutError:As.transitional(As.boolean)},!1),a!=null&&(R.isFunction(a)?s.paramsSerializer={serialize:a}:Ol.assertOptions(a,{encode:As.function,serialize:As.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),Ol.assertOptions(s,{baseUrl:As.spelling("baseURL"),withXsrfToken:As.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let l=i&&R.merge(i.common,i[s.method]);i&&R.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),s.headers=Yt.concat(l,i);const o=[];let c=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(s)===!1||(c=c&&g.synchronous,o.unshift(g.fulfilled,g.rejected))});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let d,m=0,p;if(!c){const f=[Jf.bind(this),void 0];for(f.unshift(...o),f.push(...u),p=f.length,d=Promise.resolve(s);m<p;)d=d.then(f[m++],f[m++]);return d}p=o.length;let h=s;for(;m<p;){const f=o[m++],g=o[m++];try{h=f(h)}catch(b){g.call(this,b);break}}try{d=Jf.call(this,h)}catch(f){return Promise.reject(f)}for(m=0,p=u.length;m<p;)d=d.then(u[m++],u[m++]);return d}getUri(t){t=wr(this.defaults,t);const s=My(t.baseURL,t.url,t.allowAbsoluteUrls);return Py(s,t.params,t.paramsSerializer)}};R.forEach(["delete","get","head","options"],function(t){pr.prototype[t]=function(s,r){return this.request(wr(r||{},{method:t,url:s,data:(r||{}).data}))}});R.forEach(["post","put","patch"],function(t){function s(r){return function(i,l,o){return this.request(wr(o||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:l}))}}pr.prototype[t]=s(),pr.prototype[t+"Form"]=s(!0)});let s1=class zy{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(i){s=i});const r=this;this.promise.then(a=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](a);r._listeners=null}),this.promise.then=a=>{let i;const l=new Promise(o=>{r.subscribe(o),i=o}).then(a);return l.cancel=function(){r.unsubscribe(i)},l},t(function(i,l,o){r.reason||(r.reason=new Ta(i,l,o),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const s=this._listeners.indexOf(t);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const t=new AbortController,s=r=>{t.abort(r)};return this.subscribe(s),t.signal.unsubscribe=()=>this.unsubscribe(s),t.signal}static source(){let t;return{token:new zy(function(a){t=a}),cancel:t}}};function n1(e){return function(s){return e.apply(null,s)}}function r1(e){return R.isObject(e)&&e.isAxiosError===!0}const Yu={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(Yu).forEach(([e,t])=>{Yu[t]=e});function Uy(e){const t=new pr(e),s=xy(pr.prototype.request,t);return R.extend(s,pr.prototype,t,{allOwnKeys:!0}),R.extend(s,t,null,{allOwnKeys:!0}),s.create=function(a){return Uy(wr(e,a))},s}const tt=Uy(Gi);tt.Axios=pr;tt.CanceledError=Ta;tt.CancelToken=s1;tt.isCancel=Fy;tt.VERSION=_y;tt.toFormData=Vo;tt.AxiosError=xe;tt.Cancel=tt.CanceledError;tt.all=function(t){return Promise.all(t)};tt.spread=n1;tt.isAxiosError=r1;tt.mergeConfig=wr;tt.AxiosHeaders=Yt;tt.formToJSON=e=>Ty(R.isHTMLForm(e)?new FormData(e):e);tt.getAdapter=Oy.getAdapter;tt.HttpStatusCode=Yu;tt.default=tt;const{Axios:S2,AxiosError:k2,CanceledError:C2,isCancel:E2,CancelToken:D2,VERSION:P2,all:A2,Cancel:T2,isAxiosError:F2,spread:I2,toFormData:M2,AxiosHeaders:L2,HttpStatusCode:R2,formToJSON:O2,getAdapter:_2,mergeConfig:z2}=tt,O=tt.create({baseURL:"/api",headers:{"Content-Type":"application/json"}});O.interceptors.request.use(e=>{const t=localStorage.getItem("token");return t&&(e.headers.Authorization=`Bearer ${t}`),e});O.interceptors.response.use(e=>e,e=>{var a,i,l,o,c,u,d;const t=((i=(a=e.config)==null?void 0:a.url)==null?void 0:i.includes("/auth/login"))||((o=(l=e.config)==null?void 0:l.url)==null?void 0:o.includes("/auth/customer-login"));((c=e.response)==null?void 0:c.status)===401&&!t&&(localStorage.removeItem("token"),localStorage.removeItem("user"),window.location.href="/login");const s=((d=(u=e.response)==null?void 0:u.data)==null?void 0:d.error)||e.message||"Ein Fehler ist aufgetreten",r=new Error(s);return Promise.reject(r)});const bl={login:async(e,t)=>(await O.post("/auth/login",{email:e,password:t})).data,customerLogin:async(e,t)=>(await O.post("/auth/customer-login",{email:e,password:t})).data,me:async()=>(await O.get("/auth/me")).data},yt={getAll:async e=>(await O.get("/customers",{params:e})).data,getById:async e=>(await O.get(`/customers/${e}`)).data,create:async e=>(await O.post("/customers",e)).data,update:async(e,t)=>(await O.put(`/customers/${e}`,t)).data,delete:async e=>(await O.delete(`/customers/${e}`)).data,getPortalSettings:async e=>(await O.get(`/customers/${e}/portal`)).data,updatePortalSettings:async(e,t)=>(await O.put(`/customers/${e}/portal`,t)).data,setPortalPassword:async(e,t)=>(await O.post(`/customers/${e}/portal/password`,{password:t})).data,getPortalPassword:async e=>(await O.get(`/customers/${e}/portal/password`)).data,getRepresentatives:async e=>(await O.get(`/customers/${e}/representatives`)).data,addRepresentative:async(e,t,s)=>(await O.post(`/customers/${e}/representatives`,{representativeId:t,notes:s})).data,removeRepresentative:async(e,t)=>(await O.delete(`/customers/${e}/representatives/${t}`)).data,searchForRepresentative:async(e,t)=>(await O.get(`/customers/${e}/representatives/search`,{params:{search:t}})).data},Ju={getByCustomer:async e=>(await O.get(`/customers/${e}/addresses`)).data,create:async(e,t)=>(await O.post(`/customers/${e}/addresses`,t)).data,update:async(e,t)=>(await O.put(`/addresses/${e}`,t)).data,delete:async e=>(await O.delete(`/addresses/${e}`)).data},po={getByCustomer:async(e,t=!1)=>(await O.get(`/customers/${e}/bank-cards`,{params:{showInactive:t}})).data,create:async(e,t)=>(await O.post(`/customers/${e}/bank-cards`,t)).data,update:async(e,t)=>(await O.put(`/bank-cards/${e}`,t)).data,delete:async e=>(await O.delete(`/bank-cards/${e}`)).data},go={getByCustomer:async(e,t=!1)=>(await O.get(`/customers/${e}/documents`,{params:{showInactive:t}})).data,create:async(e,t)=>(await O.post(`/customers/${e}/documents`,t)).data,update:async(e,t)=>(await O.put(`/documents/${e}`,t)).data,delete:async e=>(await O.delete(`/documents/${e}`)).data},zs={getByCustomer:async(e,t=!1)=>(await O.get(`/customers/${e}/meters`,{params:{showInactive:t}})).data,create:async(e,t)=>(await O.post(`/customers/${e}/meters`,t)).data,update:async(e,t)=>(await O.put(`/meters/${e}`,t)).data,delete:async e=>(await O.delete(`/meters/${e}`)).data,getReadings:async e=>(await O.get(`/meters/${e}/readings`)).data,addReading:async(e,t)=>(await O.post(`/meters/${e}/readings`,t)).data,updateReading:async(e,t,s)=>(await O.put(`/meters/${e}/readings/${t}`,s)).data,deleteReading:async(e,t)=>(await O.delete(`/meters/${e}/readings/${t}`)).data},xo={getByCustomer:async(e,t=!1)=>(await O.get(`/customers/${e}/stressfrei-emails`,{params:{includeInactive:t}})).data,create:async(e,t)=>(await O.post(`/customers/${e}/stressfrei-emails`,t)).data,update:async(e,t)=>(await O.put(`/stressfrei-emails/${e}`,t)).data,delete:async e=>(await O.delete(`/stressfrei-emails/${e}`)).data},$e={getAll:async e=>(await O.get("/contracts",{params:e})).data,getById:async e=>(await O.get(`/contracts/${e}`)).data,create:async e=>(await O.post("/contracts",e)).data,update:async(e,t)=>(await O.put(`/contracts/${e}`,t)).data,delete:async e=>(await O.delete(`/contracts/${e}`)).data,createFollowUp:async e=>(await O.post(`/contracts/${e}/follow-up`)).data,getPassword:async e=>(await O.get(`/contracts/${e}/password`)).data,getSimCardCredentials:async e=>(await O.get(`/contracts/simcard/${e}/credentials`)).data,getInternetCredentials:async e=>(await O.get(`/contracts/${e}/internet-credentials`)).data,getSipCredentials:async e=>(await O.get(`/contracts/phonenumber/${e}/sip-credentials`)).data,getCockpit:async()=>(await O.get("/contracts/cockpit")).data},Xe={getAll:async e=>(await O.get("/tasks",{params:e})).data,getStats:async()=>(await O.get("/tasks/stats")).data,getByContract:async(e,t)=>(await O.get(`/contracts/${e}/tasks`,{params:{status:t}})).data,create:async(e,t)=>(await O.post(`/contracts/${e}/tasks`,t)).data,update:async(e,t)=>(await O.put(`/tasks/${e}`,t)).data,complete:async e=>(await O.post(`/tasks/${e}/complete`)).data,reopen:async e=>(await O.post(`/tasks/${e}/reopen`)).data,delete:async e=>(await O.delete(`/tasks/${e}`)).data,createSubtask:async(e,t)=>(await O.post(`/tasks/${e}/subtasks`,{title:t})).data,createReply:async(e,t)=>(await O.post(`/tasks/${e}/reply`,{title:t})).data,updateSubtask:async(e,t)=>(await O.put(`/subtasks/${e}`,{title:t})).data,completeSubtask:async e=>(await O.post(`/subtasks/${e}/complete`)).data,reopenSubtask:async e=>(await O.post(`/subtasks/${e}/reopen`)).data,deleteSubtask:async e=>(await O.delete(`/subtasks/${e}`)).data,createSupportTicket:async(e,t)=>(await O.post(`/contracts/${e}/support-ticket`,t)).data},Sr={getPublic:async()=>(await O.get("/settings/public")).data,getAll:async()=>(await O.get("/settings")).data,update:async e=>(await O.put("/settings",e)).data,updateOne:async(e,t)=>(await O.put(`/settings/${e}`,{value:t})).data},Pi={getAll:async(e=!1)=>(await O.get("/platforms",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/platforms/${e}`)).data,create:async e=>(await O.post("/platforms",e)).data,update:async(e,t)=>(await O.put(`/platforms/${e}`,t)).data,delete:async e=>(await O.delete(`/platforms/${e}`)).data},Ai={getAll:async(e=!1)=>(await O.get("/cancellation-periods",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/cancellation-periods/${e}`)).data,create:async e=>(await O.post("/cancellation-periods",e)).data,update:async(e,t)=>(await O.put(`/cancellation-periods/${e}`,t)).data,delete:async e=>(await O.delete(`/cancellation-periods/${e}`)).data},Ti={getAll:async(e=!1)=>(await O.get("/contract-durations",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/contract-durations/${e}`)).data,create:async e=>(await O.post("/contract-durations",e)).data,update:async(e,t)=>(await O.put(`/contract-durations/${e}`,t)).data,delete:async e=>(await O.delete(`/contract-durations/${e}`)).data},Fi={getAll:async(e=!1)=>(await O.get("/contract-categories",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/contract-categories/${e}`)).data,create:async e=>(await O.post("/contract-categories",e)).data,update:async(e,t)=>(await O.put(`/contract-categories/${e}`,t)).data,delete:async e=>(await O.delete(`/contract-categories/${e}`)).data},Na={getAll:async(e=!1)=>(await O.get("/providers",{params:{includeInactive:e}})).data,getById:async e=>(await O.get(`/providers/${e}`)).data,create:async e=>(await O.post("/providers",e)).data,update:async(e,t)=>(await O.put(`/providers/${e}`,t)).data,delete:async e=>(await O.delete(`/providers/${e}`)).data,getTariffs:async(e,t=!1)=>(await O.get(`/providers/${e}/tariffs`,{params:{includeInactive:t}})).data,createTariff:async(e,t)=>(await O.post(`/providers/${e}/tariffs`,t)).data},$y={getById:async e=>(await O.get(`/tariffs/${e}`)).data,update:async(e,t)=>(await O.put(`/tariffs/${e}`,t)).data,delete:async e=>(await O.delete(`/tariffs/${e}`)).data},Ye={uploadBankCardDocument:async(e,t)=>{const s=new FormData;return s.append("document",t),(await O.post(`/upload/bank-cards/${e}`,s,{headers:{"Content-Type":"multipart/form-data"}})).data},uploadIdentityDocument:async(e,t)=>{const s=new FormData;return s.append("document",t),(await O.post(`/upload/documents/${e}`,s,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBankCardDocument:async e=>(await O.delete(`/upload/bank-cards/${e}`)).data,deleteIdentityDocument:async e=>(await O.delete(`/upload/documents/${e}`)).data,uploadBusinessRegistration:async(e,t)=>{const s=new FormData;return s.append("document",t),(await O.post(`/upload/customers/${e}/business-registration`,s,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteBusinessRegistration:async e=>(await O.delete(`/upload/customers/${e}/business-registration`)).data,uploadCommercialRegister:async(e,t)=>{const s=new FormData;return s.append("document",t),(await O.post(`/upload/customers/${e}/commercial-register`,s,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCommercialRegister:async e=>(await O.delete(`/upload/customers/${e}/commercial-register`)).data,uploadPrivacyPolicy:async(e,t)=>{const s=new FormData;return s.append("document",t),(await O.post(`/upload/customers/${e}/privacy-policy`,s,{headers:{"Content-Type":"multipart/form-data"}})).data},deletePrivacyPolicy:async e=>(await O.delete(`/upload/customers/${e}/privacy-policy`)).data,uploadCancellationLetter:async(e,t)=>{const s=new FormData;return s.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-letter`,s,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetter:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-letter`)).data,uploadCancellationConfirmation:async(e,t)=>{const s=new FormData;return s.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-confirmation`,s,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmation:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-confirmation`)).data,uploadCancellationLetterOptions:async(e,t)=>{const s=new FormData;return s.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-letter-options`,s,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationLetterOptions:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-letter-options`)).data,uploadCancellationConfirmationOptions:async(e,t)=>{const s=new FormData;return s.append("document",t),(await O.post(`/upload/contracts/${e}/cancellation-confirmation-options`,s,{headers:{"Content-Type":"multipart/form-data"}})).data},deleteCancellationConfirmationOptions:async e=>(await O.delete(`/upload/contracts/${e}/cancellation-confirmation-options`)).data},ii={getAll:async e=>(await O.get("/users",{params:e})).data,getById:async e=>(await O.get(`/users/${e}`)).data,create:async e=>(await O.post("/users",e)).data,update:async(e,t)=>(await O.put(`/users/${e}`,t)).data,delete:async e=>(await O.delete(`/users/${e}`)).data,getRoles:async()=>(await O.get("/users/roles/list")).data},Za={getSchema:async()=>(await O.get("/developer/schema")).data,getTableData:async(e,t=1,s=50)=>(await O.get(`/developer/table/${e}`,{params:{page:t,limit:s}})).data,updateRow:async(e,t,s)=>(await O.put(`/developer/table/${e}/${t}`,s)).data,deleteRow:async(e,t)=>(await O.delete(`/developer/table/${e}/${t}`)).data,getReference:async e=>(await O.get(`/developer/reference/${e}`)).data},xn={getConfigs:async()=>(await O.get("/email-providers/configs")).data,getConfig:async e=>(await O.get(`/email-providers/configs/${e}`)).data,createConfig:async e=>(await O.post("/email-providers/configs",e)).data,updateConfig:async(e,t)=>(await O.put(`/email-providers/configs/${e}`,t)).data,deleteConfig:async e=>(await O.delete(`/email-providers/configs/${e}`)).data,testConnection:async e=>{const t=e!=null&&e.testData?{...e.testData}:e!=null&&e.id?{id:e.id}:{};return(await O.post("/email-providers/test-connection",t)).data},getDomain:async()=>(await O.get("/email-providers/domain")).data,checkEmailExists:async e=>(await O.get(`/email-providers/check/${e}`)).data,provisionEmail:async(e,t)=>(await O.post("/email-providers/provision",{localPart:e,customerEmail:t})).data,deprovisionEmail:async e=>(await O.delete(`/email-providers/deprovision/${e}`)).data},By=w.createContext(null);function a1({children:e}){const[t,s]=w.useState(null),[r,a]=w.useState(!0),[i,l]=w.useState(()=>localStorage.getItem("developerMode")==="true"),o=g=>{l(g),localStorage.setItem("developerMode",String(g))};w.useEffect(()=>{var g;console.log("useEffect check - user:",t==null?void 0:t.email,"developerMode:",i,"has developer:access:",(g=t==null?void 0:t.permissions)==null?void 0:g.includes("developer:access")),t&&i&&!t.permissions.includes("developer:access")&&(console.log("Disabling developer mode because user lacks developer:access permission"),o(!1))},[t,i]),w.useEffect(()=>{localStorage.getItem("token")?bl.me().then(b=>{b.success&&b.data?s(b.data):localStorage.removeItem("token")}).catch(()=>{localStorage.removeItem("token")}).finally(()=>{a(!1)}):a(!1)},[]);const c=async(g,b)=>{const y=await bl.login(g,b);if(y.success&&y.data)localStorage.setItem("token",y.data.token),s(y.data.user);else throw new Error(y.error||"Login fehlgeschlagen")},u=async(g,b)=>{const y=await bl.customerLogin(g,b);if(y.success&&y.data)localStorage.setItem("token",y.data.token),s(y.data.user);else throw new Error(y.error||"Login fehlgeschlagen")},d=()=>{localStorage.removeItem("token"),s(null)},m=async()=>{var b;if(localStorage.getItem("token"))try{const y=await bl.me();console.log("refreshUser response:",y),console.log("permissions:",(b=y.data)==null?void 0:b.permissions),y.success&&y.data&&s(y.data)}catch(y){console.error("refreshUser error:",y)}},p=g=>t?t.permissions.includes(g):!1,h=!!(t!=null&&t.customerId),f=!!(t!=null&&t.isCustomerPortal);return n.jsx(By.Provider,{value:{user:t,isLoading:r,isAuthenticated:!!t,login:c,customerLogin:u,logout:d,hasPermission:p,isCustomer:h,isCustomerPortal:f,developerMode:i,setDeveloperMode:o,refreshUser:m},children:e})}function st(){const e=w.useContext(By);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}const Ac={scrollToTopThreshold:.7},Ky=w.createContext(void 0),ep="opencrm_app_settings";function i1({children:e}){const[t,s]=w.useState(()=>{const a=localStorage.getItem(ep);if(a)try{return{...Ac,...JSON.parse(a)}}catch{return Ac}return Ac});w.useEffect(()=>{localStorage.setItem(ep,JSON.stringify(t))},[t]);const r=a=>{s(i=>({...i,...a}))};return n.jsx(Ky.Provider,{value:{settings:t,updateSettings:r},children:e})}function Vy(){const e=w.useContext(Ky);if(!e)throw new Error("useAppSettings must be used within AppSettingsProvider");return e}function l1(){const{pathname:e}=dn();return w.useEffect(()=>{window.scrollTo(0,0)},[e]),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 o1=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),qy=(...e)=>e.filter((t,s,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===s).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 c1={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 u1=w.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:s=2,absoluteStrokeWidth:r,className:a="",children:i,iconNode:l,...o},c)=>w.createElement("svg",{ref:c,...c1,width:t,height:t,stroke:e,strokeWidth:r?Number(s)*24/Number(t):s,className:qy("lucide",a),...o},[...l.map(([u,d])=>w.createElement(u,d)),...Array.isArray(i)?i:[i]]));/**
* @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 ae=(e,t)=>{const s=w.forwardRef(({className:r,...a},i)=>w.createElement(u1,{ref:i,iconNode:t,className:qy(`lucide-${o1(e)}`,r),...a}));return s.displayName=`${e}`,s};/**
* @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 $s=ae("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 d1=ae("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 h1=ae("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 m1=ae("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 Qy=ae("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 Hy=ae("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 Xu=ae("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 Qo=ae("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 f1=ae("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 Ys=ae("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 Wy=ae("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 en=ae("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 hs=ae("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 tp=ae("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 _l=ae("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 Ii=ae("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 qn=ae("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 Ho=ae("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 Gy=ae("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 p1=ae("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 Zy=ae("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 tn=ae("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 Yy=ae("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 Pt=ae("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 Ee=ae("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 vt=ae("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 g1=ae("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 Jy=ae("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 Xy=ae("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 sp=ae("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 uh=ae("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 x1=ae("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 y1=ae("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 v1=ae("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 j1=ae("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 ev=ae("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 b1=ae("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 N1=ae("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 Mi=ae("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 w1=ae("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 Oe=ae("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 S1=ae("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 Wo=ae("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 k1=ae("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 tv=ae("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 dh=ae("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 We=ae("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 C1=ae("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 E1=ae("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 be=ae("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 Li=ae("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 sv=ae("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 D1=ae("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 P1=ae("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 A1=ae("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 hh=ae("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 Xr=ae("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 np=ae("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 ea=ae("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 wa=ae("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 mh=ae("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 T1=ae("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 F1=ae("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 I1(){const{user:e,logout:t,hasPermission:s,isCustomer:r,developerMode:a}=st(),i=[{to:"/",icon:v1,label:"Dashboard",show:!0,end:!0},{to:"/customers",icon:Xr,label:"Kunden",show:s("customers:read")&&!r},{to:"/contracts",icon:vt,label:"Verträge",show:s("contracts:read"),end:!0},{to:"/contracts/cockpit",icon:en,label:"Vertrags-Cockpit",show:s("contracts:read")&&!r},{to:"/tasks",icon:r?Mi:Ii,label:r?"Support-Anfragen":"Aufgaben",show:s("contracts:read")}],l=[{to:"/developer/database",icon:Zy,label:"Datenbankstruktur"}];return n.jsxs("aside",{className:"w-64 bg-gray-900 text-white min-h-screen flex flex-col",children:[n.jsx("div",{className:"p-4 border-b border-gray-800",children:n.jsx("h1",{className:"text-xl font-bold",children:"OpenCRM"})}),n.jsxs("nav",{className:"flex-1 p-4 overflow-y-auto",children:[n.jsx("ul",{className:"space-y-2",children:i.filter(o=>o.show).map(o=>n.jsx("li",{children:n.jsxs(Cc,{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:[n.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))}),a&&s("developer:access")&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mt-6 mb-2 px-4",children:n.jsxs("p",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider flex items-center gap-2",children:[n.jsx(Ho,{className:"w-3 h-3"}),"Entwickler"]})}),n.jsx("ul",{className:"space-y-2",children:l.map(o=>n.jsx("li",{children:n.jsxs(Cc,{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:[n.jsx(o.icon,{className:"w-5 h-5"}),o.label]})},o.to))})]}),n.jsx("div",{className:"mt-6 pt-6 border-t border-gray-800",children:n.jsxs(Cc,{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:[n.jsx(tv,{className:"w-5 h-5"}),"Einstellungen"]})})]}),n.jsxs("div",{className:"p-4 border-t border-gray-800",children:[n.jsxs("div",{className:"mb-4 text-sm",children:[n.jsx("p",{className:"text-gray-400",children:"Angemeldet als"}),n.jsxs("p",{className:"font-medium",children:[e==null?void 0:e.firstName," ",e==null?void 0:e.lastName]})]}),n.jsxs("button",{onClick:t,className:"flex items-center gap-3 w-full px-4 py-2 text-gray-300 hover:bg-gray-800 rounded-lg transition-colors",children:[n.jsx(j1,{className:"w-5 h-5"}),"Abmelden"]})]})]})}function M1(){const{settings:e}=Vy(),[t,s]=w.useState(!1);w.useEffect(()=>{const a=()=>{window.scrollY>window.innerHeight*e.scrollToTopThreshold?s(!0):s(!1)};return window.addEventListener("scroll",a),()=>window.removeEventListener("scroll",a)},[e.scrollToTopThreshold]);const r=()=>{window.scrollTo({top:0,behavior:"smooth"})};return t?n.jsx("button",{onClick:r,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:n.jsx(Wy,{className:"w-5 h-5"})}):null}function L1(){return n.jsxs("div",{className:"flex min-h-screen",children:[n.jsx(I1,{}),n.jsx("main",{className:"flex-1 p-8 overflow-auto",children:n.jsx(Tb,{})}),n.jsx(M1,{})]})}const I=w.forwardRef(({className:e="",variant:t="primary",size:s="md",children:r,disabled:a,...i},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"},u={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"};return n.jsx("button",{ref:l,className:`${o} ${c[t]} ${u[s]} ${e}`,disabled:a,...i,children:r})});I.displayName="Button";const $=w.forwardRef(({className:e="",label:t,error:s,id:r,onClear:a,...i},l)=>{const o=r||i.name,c=i.type==="date",u=i.value!==void 0&&i.value!==null&&i.value!=="",d=c&&a&&u;return n.jsxs("div",{className:"w-full",children:[t&&n.jsx("label",{htmlFor:o,className:"block text-sm font-medium text-gray-700 mb-1",children:t}),n.jsxs("div",{className:d?"flex gap-2":"",children:[n.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 ${s?"border-red-500":"border-gray-300"} ${e}`,...i}),d&&n.jsx("button",{type:"button",onClick:a,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:n.jsx(be,{className:"w-4 h-4"})})]}),s&&n.jsx("p",{className:"mt-1 text-sm text-red-600",children:s})]})});$.displayName="Input";function Z({children:e,className:t="",title:s,actions:r}){return n.jsxs("div",{className:`bg-white rounded-lg shadow ${t}`,children:[(s||r)&&n.jsxs("div",{className:"px-6 py-4 border-b border-gray-200 flex items-center justify-between",children:[s&&n.jsx("h3",{className:"text-lg font-medium text-gray-900",children:s}),r&&n.jsx("div",{className:"flex items-center gap-2",children:r})]}),n.jsx("div",{className:"p-6",children:e})]})}function R1(){const[e,t]=w.useState(""),[s,r]=w.useState(""),[a,i]=w.useState(""),[l,o]=w.useState(!1),{login:c,customerLogin:u}=st(),d=Ut(),m=async p=>{p.preventDefault(),i(""),o(!0);try{await c(e,s),d("/");return}catch{}try{await u(e,s),d("/")}catch{i("Ungültige Anmeldedaten"),o(!1)}};return n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-100",children:n.jsxs(Z,{className:"w-full max-w-md",children:[n.jsxs("div",{className:"text-center mb-8",children:[n.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"OpenCRM"}),n.jsx("p",{className:"text-gray-600 mt-2",children:"Melden Sie sich an"})]}),a&&n.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:a}),n.jsxs("form",{onSubmit:m,className:"space-y-4",children:[n.jsx($,{label:"E-Mail",type:"email",value:e,onChange:p=>t(p.target.value),required:!0,autoComplete:"email"}),n.jsx($,{label:"Passwort",type:"password",value:s,onChange:p=>r(p.target.value),required:!0,autoComplete:"current-password"}),n.jsx(I,{type:"submit",className:"w-full",disabled:l,children:l?"Anmeldung...":"Anmelden"})]})]})})}function dt({isOpen:e,onClose:t,title:s,children:r,size:a="md"}){if(w.useEffect(()=>(e?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[e]),!e)return null;const i={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};return n.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:n.jsxs("div",{className:"flex min-h-full items-center justify-center p-4",children:[n.jsx("div",{className:"fixed inset-0 bg-black/50",onClick:t}),n.jsxs("div",{className:`relative bg-white rounded-lg shadow-xl w-full ${i[a]}`,children:[n.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[n.jsx("h2",{className:"text-lg font-semibold",children:s}),n.jsx(I,{variant:"ghost",size:"sm",onClick:t,children:n.jsx(wa,{className:"w-5 h-5"})})]}),n.jsx("div",{className:"p-6",children:r})]})]})})}function O1(){var S,L,T,_,K,W;const{user:e,isCustomer:t,isCustomerPortal:s}=st(),[r,a]=w.useState(!1),{data:i,isLoading:l}=ge({queryKey:["app-settings-public"],queryFn:()=>Sr.getPublic(),enabled:s,staleTime:0}),o=!l&&((S=i==null?void 0:i.data)==null?void 0:S.customerSupportTicketsEnabled)==="true",{data:c}=ge({queryKey:["customers-count"],queryFn:()=>yt.getAll({limit:1}),enabled:!t}),{data:u}=ge({queryKey:["contracts",t?e==null?void 0:e.customerId:void 0],queryFn:()=>$e.getAll(t?{customerId:e==null?void 0:e.customerId}:{limit:1})}),{data:d}=ge({queryKey:["contracts-active",t?e==null?void 0:e.customerId:void 0],queryFn:()=>$e.getAll({status:"ACTIVE",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:m}=ge({queryKey:["contracts-pending",t?e==null?void 0:e.customerId:void 0],queryFn:()=>$e.getAll({status:"PENDING",...t?{customerId:e==null?void 0:e.customerId}:{limit:1}})}),{data:p}=ge({queryKey:["task-stats"],queryFn:()=>Xe.getStats()}),{data:h}=ge({queryKey:["contract-cockpit"],queryFn:()=>$e.getCockpit(),enabled:!t,staleTime:0}),{ownContracts:f,representedContracts:g}=w.useMemo(()=>{if(!s||!(u!=null&&u.data))return{ownContracts:[],representedContracts:[]};const Q=[],z={};for(const P of u.data)if(P.customerId===(e==null?void 0:e.customerId))Q.push(P);else{const j=P.customerId;if(!z[j]){const B=P.customer?P.customer.companyName||`${P.customer.firstName} ${P.customer.lastName}`:`Kunde ${j}`;z[j]={customerName:B,contracts:[]}}z[j].contracts.push(P)}return{ownContracts:Q,representedContracts:Object.values(z).sort((P,j)=>P.customerName.localeCompare(j.customerName))}},[u==null?void 0:u.data,s,e==null?void 0:e.customerId]),b=w.useMemo(()=>f.filter(Q=>Q.status==="ACTIVE").length,[f]),y=w.useMemo(()=>f.filter(Q=>Q.status==="PENDING").length,[f]),v=w.useMemo(()=>f.filter(Q=>Q.status==="EXPIRED").length,[f]),x=w.useMemo(()=>g.reduce((Q,z)=>Q+z.contracts.length,0),[g]),N=w.useMemo(()=>g.reduce((Q,z)=>Q+z.contracts.filter(P=>P.status==="ACTIVE").length,0),[g]),k=w.useMemo(()=>g.reduce((Q,z)=>Q+z.contracts.filter(P=>P.status==="EXPIRED").length,0),[g]),D=((L=p==null?void 0:p.data)==null?void 0:L.openCount)||0,F=Q=>n.jsx(Z,{className:Q.link?"cursor-pointer hover:shadow-md transition-shadow":"",children:Q.link?n.jsx(Se,{to:Q.link,className:"block",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:`p-3 rounded-lg ${Q.color}`,children:n.jsx(Q.icon,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{className:"ml-4",children:[n.jsx("p",{className:"text-sm text-gray-500",children:Q.label}),n.jsx("p",{className:"text-2xl font-bold",children:Q.value})]})]})}):n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:`p-3 rounded-lg ${Q.color}`,children:n.jsx(Q.icon,{className:"w-6 h-6 text-white"})}),n.jsxs("div",{className:"ml-4",children:[n.jsx("p",{className:"text-sm text-gray-500",children:Q.label}),n.jsx("p",{className:"text-2xl font-bold",children:Q.value})]})]})},Q.label);return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("h1",{className:"text-2xl font-bold",children:["Willkommen, ",e==null?void 0:e.firstName,"!"]}),s&&o&&n.jsxs(I,{onClick:()=>a(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Support-Anfrage"]})]}),s?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mb-6",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(hh,{className:"w-5 h-5 text-blue-600"}),n.jsx("h2",{className:"text-lg font-semibold",children:"Meine Verträge"})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[F({label:"Eigene Verträge",value:f.length,icon:vt,color:"bg-blue-500",link:"/contracts"}),F({label:"Davon aktiv",value:b,icon:hs,color:"bg-green-500"}),F({label:"Davon ausstehend",value:y,icon:qn,color:"bg-yellow-500"}),F({label:"Davon abgelaufen",value:v,icon:tp,color:"bg-red-500"})]})]}),x>0&&n.jsxs("div",{className:"mb-6",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(Xr,{className:"w-5 h-5 text-purple-600"}),n.jsx("h2",{className:"text-lg font-semibold",children:"Fremdverträge"})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[F({label:"Fremdverträge",value:x,icon:Xr,color:"bg-purple-500",link:"/contracts"}),F({label:"Davon aktiv",value:N,icon:hs,color:"bg-green-500"}),n.jsx("div",{className:"hidden lg:block"}),F({label:"Davon abgelaufen",value:k,icon:tp,color:"bg-red-500"})]})]}),n.jsxs("div",{className:"mb-6",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(Mi,{className:"w-5 h-5 text-orange-600"}),n.jsx("h2",{className:"text-lg font-semibold",children:"Support-Anfragen"})]}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:F({label:"Offene Anfragen",value:D,icon:Mi,color:"bg-orange-500",link:"/tasks"})})]})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6",children:[F({label:"Kunden",value:((T=c==null?void 0:c.pagination)==null?void 0:T.total)||0,icon:Xr,color:"bg-blue-500",link:"/customers"}),F({label:"Verträge gesamt",value:((_=u==null?void 0:u.pagination)==null?void 0:_.total)||0,icon:vt,color:"bg-purple-500",link:"/contracts"}),F({label:"Aktive Verträge",value:((K=d==null?void 0:d.pagination)==null?void 0:K.total)||0,icon:hs,color:"bg-green-500"}),F({label:"Ausstehende Verträge",value:((W=m==null?void 0:m.pagination)==null?void 0:W.total)||0,icon:en,color:"bg-yellow-500"})]}),(h==null?void 0:h.data)&&n.jsxs("div",{className:"mb-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(en,{className:"w-5 h-5 text-red-500"}),n.jsx("h2",{className:"text-lg font-semibold",children:"Vertrags-Cockpit"})]}),n.jsx(Se,{to:"/contracts/cockpit",className:"text-sm text-blue-600 hover:underline",children:"Alle anzeigen"})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[n.jsx(Z,{className:"cursor-pointer hover:shadow-md transition-shadow",children:n.jsx(Se,{to:"/contracts/cockpit?filter=critical",className:"block",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:"p-3 rounded-lg bg-red-100",children:n.jsx(en,{className:"w-6 h-6 text-red-500"})}),n.jsxs("div",{className:"ml-4",children:[n.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",h.data.thresholds.criticalDays," Tage)"]}),n.jsx("p",{className:"text-2xl font-bold text-red-600",children:h.data.summary.criticalCount})]})]})})}),n.jsx(Z,{className:"cursor-pointer hover:shadow-md transition-shadow",children:n.jsx(Se,{to:"/contracts/cockpit?filter=warning",className:"block",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:"p-3 rounded-lg bg-yellow-100",children:n.jsx(Li,{className:"w-6 h-6 text-yellow-500"})}),n.jsxs("div",{className:"ml-4",children:[n.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",h.data.thresholds.warningDays," Tage)"]}),n.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:h.data.summary.warningCount})]})]})})}),n.jsx(Z,{className:"cursor-pointer hover:shadow-md transition-shadow",children:n.jsx(Se,{to:"/contracts/cockpit?filter=ok",className:"block",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:"p-3 rounded-lg bg-green-100",children:n.jsx(hs,{className:"w-6 h-6 text-green-500"})}),n.jsxs("div",{className:"ml-4",children:[n.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",h.data.thresholds.okDays," Tage)"]}),n.jsx("p",{className:"text-2xl font-bold text-green-600",children:h.data.summary.okCount})]})]})})}),n.jsx(Z,{className:"cursor-pointer hover:shadow-md transition-shadow",children:n.jsx(Se,{to:"/contracts/cockpit",className:"block",children:n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:"p-3 rounded-lg bg-gray-100",children:n.jsx(vt,{className:"w-6 h-6 text-gray-500"})}),n.jsxs("div",{className:"ml-4",children:[n.jsx("p",{className:"text-sm text-gray-500",children:"Handlungsbedarf"}),n.jsx("p",{className:"text-2xl font-bold text-gray-600",children:h.data.summary.totalContracts})]})]})})})]})]}),n.jsxs("div",{className:"mb-6",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[n.jsx(Ii,{className:"w-5 h-5 text-orange-600"}),n.jsx("h2",{className:"text-lg font-semibold",children:"Aufgaben"})]}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:F({label:"Offene Aufgaben",value:D,icon:Ii,color:"bg-orange-500",link:"/tasks"})})]})]}),s&&n.jsx(_1,{isOpen:r,onClose:()=>a(!1)})]})}function _1({isOpen:e,onClose:t}){const{user:s}=st(),r=Ut(),a=pe(),[i,l]=w.useState("own"),[o,c]=w.useState(null),[u,d]=w.useState(""),[m,p]=w.useState(""),[h,f]=w.useState(!1),[g,b]=w.useState(""),{data:y}=ge({queryKey:["contracts",s==null?void 0:s.customerId],queryFn:()=>$e.getAll({customerId:s==null?void 0:s.customerId}),enabled:e}),v=w.useMemo(()=>{if(!(y!=null&&y.data))return{own:[],represented:{}};const S=[],L={};for(const T of y.data)if(T.customerId===(s==null?void 0:s.customerId))S.push(T);else{if(!L[T.customerId]){const _=T.customer?T.customer.companyName||`${T.customer.firstName} ${T.customer.lastName}`:`Kunde ${T.customerId}`;L[T.customerId]={name:_,contracts:[]}}L[T.customerId].contracts.push(T)}return{own:S,represented:L}},[y==null?void 0:y.data,s==null?void 0:s.customerId]),x=Object.keys(v.represented).length>0,N=w.useMemo(()=>{var S;return i==="own"?v.own:((S=v.represented[i])==null?void 0:S.contracts)||[]},[i,v]),k=w.useMemo(()=>{if(!g)return N;const S=g.toLowerCase();return N.filter(L=>L.contractNumber.toLowerCase().includes(S)||(L.providerName||"").toLowerCase().includes(S)||(L.tariffName||"").toLowerCase().includes(S))},[N,g]),D=async()=>{if(!(!o||!u.trim())){f(!0);try{await Xe.createSupportTicket(o,{title:u.trim(),description:m.trim()||void 0}),a.invalidateQueries({queryKey:["task-stats"]}),a.invalidateQueries({queryKey:["all-tasks"]}),t(),d(""),p(""),c(null),l("own"),r(`/contracts/${o}`)}catch(S){console.error("Fehler beim Erstellen der Support-Anfrage:",S),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{f(!1)}}},F=()=>{d(""),p(""),c(null),l("own"),b(""),t()};return n.jsx(dt,{isOpen:e,onClose:F,title:"Neue Support-Anfrage",children:n.jsxs("div",{className:"space-y-4",children:[x&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),n.jsxs("select",{value:i,onChange:S=>{const L=S.target.value;l(L==="own"?"own":parseInt(L)),c(null),b("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[n.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(v.represented).map(([S,{name:L}])=>n.jsx("option",{value:S,children:L},S))]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),n.jsx($,{placeholder:"Vertrag suchen...",value:g,onChange:S=>b(S.target.value),className:"mb-2"}),n.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(S=>n.jsxs("div",{onClick:()=>c(S.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===S.id?"bg-blue-50 border-blue-200":""}`,children:[n.jsx("div",{className:"font-medium",children:S.contractNumber}),n.jsxs("div",{className:"text-sm text-gray-500",children:[S.providerName||"Kein Anbieter",S.tariffName&&` - ${S.tariffName}`]})]},S.id)):n.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),n.jsx($,{value:u,onChange:S=>d(S.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),n.jsx("textarea",{value:m,onChange:S=>p(S.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"})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[n.jsx(I,{variant:"secondary",onClick:F,children:"Abbrechen"}),n.jsx(I,{onClick:D,disabled:!o||!u.trim()||h,children:h?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function he({children:e,variant:t="default",className:s="",onClick:r}){const a={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 n.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${a[t]} ${s}`,onClick:r,children:e})}function z1(){const[e,t]=w.useState(""),[s,r]=w.useState(""),[a,i]=w.useState(1),{hasPermission:l}=st(),{data:o,isLoading:c}=ge({queryKey:["customers",e,s,a],queryFn:()=>yt.getAll({search:e,type:s||void 0,page:a,limit:20})});return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Kunden"}),l("customers:create")&&n.jsx(Se,{to:"/customers/new",children:n.jsxs(I,{children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Neuer Kunde"]})})]}),n.jsx(Z,{className:"mb-6",children:n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx($,{placeholder:"Suchen...",value:e,onChange:u=>t(u.target.value),className:"flex-1"}),n.jsxs("select",{value:s,onChange:u=>r(u.target.value),className:"px-3 py-2 border border-gray-300 rounded-lg w-28 flex-shrink-0",children:[n.jsx("option",{value:"",children:"Alle"}),n.jsx("option",{value:"PRIVATE",children:"Privat"}),n.jsx("option",{value:"BUSINESS",children:"Firma"})]}),n.jsx(I,{variant:"secondary",className:"flex-shrink-0",children:n.jsx(Wo,{className:"w-4 h-4"})})]})}),n.jsx(Z,{children:c?n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):o!=null&&o.data&&o.data.length>0?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b",children:[n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kundennr."}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Verträge"}),n.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),n.jsx("tbody",{children:o.data.map(u=>{var d;return n.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[n.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:u.customerNumber}),n.jsx("td",{className:"py-3 px-4",children:u.type==="BUSINESS"&&u.companyName?u.companyName:`${u.firstName} ${u.lastName}`}),n.jsx("td",{className:"py-3 px-4",children:n.jsx(he,{variant:u.type==="BUSINESS"?"info":"default",children:u.type==="BUSINESS"?"Firma":"Privat"})}),n.jsx("td",{className:"py-3 px-4",children:u.email||"-"}),n.jsx("td",{className:"py-3 px-4",children:((d=u._count)==null?void 0:d.contracts)||0}),n.jsx("td",{className:"py-3 px-4 text-right",children:n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(Se,{to:`/customers/${u.id}`,children:n.jsx(I,{variant:"ghost",size:"sm",children:n.jsx(Ee,{className:"w-4 h-4"})})}),l("customers:update")&&n.jsx(Se,{to:`/customers/${u.id}/edit`,children:n.jsx(I,{variant:"ghost",size:"sm",children:n.jsx(We,{className:"w-4 h-4"})})})]})})]},u.id)})})]})}),o.pagination&&o.pagination.totalPages>1&&n.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[n.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",o.pagination.page," von ",o.pagination.totalPages," (",o.pagination.total," Einträge)"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(I,{variant:"secondary",size:"sm",onClick:()=>i(u=>Math.max(1,u-1)),disabled:a===1,children:"Zurück"}),n.jsx(I,{variant:"secondary",size:"sm",onClick:()=>i(u=>u+1),disabled:a>=o.pagination.totalPages,children:"Weiter"})]})]})]}):n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kunden gefunden."})})]})}function U1({tabs:e,defaultTab:t}){var a,i;const[s,r]=w.useState(t||((a=e[0])==null?void 0:a.id));return n.jsxs("div",{children:[n.jsx("div",{className:"border-b border-gray-200",children:n.jsx("nav",{className:"flex -mb-px space-x-8",children:e.map(l=>n.jsx("button",{onClick:()=>r(l.id),className:`py-4 px-1 border-b-2 font-medium text-sm whitespace-nowrap ${s===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))})}),n.jsx("div",{className:"mt-4",children:(i=e.find(l=>l.id===s))==null?void 0:i.content})]})}const Le=w.forwardRef(({className:e="",label:t,error:s,options:r,id:a,placeholder:i="Bitte wählen...",...l},o)=>{const c=a||l.name,u=/\bw-\d+\b|\bw-\[|\bflex-/.test(e);return n.jsxs("div",{className:u?e:"w-full",children:[t&&n.jsx("label",{htmlFor:c,className:"block text-sm font-medium text-gray-700 mb-1",children:t}),n.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 ${s?"border-red-500":"border-gray-300"}`,...l,children:[n.jsx("option",{value:"",children:i}),r.map(d=>n.jsx("option",{value:d.value,children:d.label},d.value))]}),s&&n.jsx("p",{className:"mt-1 text-sm text-red-600",children:s})]})});Le.displayName="Select";function xt({onUpload:e,existingFile:t,accept:s=".pdf,.jpg,.jpeg,.png",label:r="Dokument hochladen",disabled:a=!1}){const i=w.useRef(null),[l,o]=w.useState(!1),[c,u]=w.useState(!1),d=async g=>{if(g){o(!0);try{await e(g)}catch(b){console.error("Upload failed:",b),alert("Upload fehlgeschlagen")}finally{o(!1)}}},m=g=>{var y;const b=(y=g.target.files)==null?void 0:y[0];b&&d(b)},p=g=>{var y;g.preventDefault(),u(!1);const b=(y=g.dataTransfer.files)==null?void 0:y[0];b&&d(b)},h=g=>{g.preventDefault(),u(!0)},f=()=>{u(!1)};return n.jsxs("div",{className:"space-y-2",children:[t?!a&&n.jsx(I,{variant:"secondary",size:"sm",onClick:()=>{var g;return(g=i.current)==null?void 0:g.click()},disabled:l,children:l?"Wird hochgeladen...":"Ersetzen"}):n.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"} ${a?"opacity-50 cursor-not-allowed":""}`,onClick:()=>{var g;return!a&&((g=i.current)==null?void 0:g.click())},onDrop:a?void 0:p,onDragOver:a?void 0:h,onDragLeave:a?void 0:f,children:l?n.jsxs("div",{className:"text-gray-500",children:[n.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..."]}):n.jsxs(n.Fragment,{children:[n.jsx(D1,{className:"w-6 h-6 text-gray-400 mx-auto mb-2"}),n.jsx("p",{className:"text-sm text-gray-600",children:r}),n.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"PDF, JPG oder PNG (max. 10MB)"})]})}),n.jsx("input",{ref:i,type:"file",accept:s,onChange:m,className:"hidden",disabled:a||l})]})}function oe({value:e,className:t="",size:s="sm",title:r="In Zwischenablage kopieren"}){const[a,i]=w.useState(!1),l=async c=>{c.preventDefault(),c.stopPropagation();try{await navigator.clipboard.writeText(e),i(!0),setTimeout(()=>i(!1),1500)}catch(u){console.error("Failed to copy:",u)}},o=s==="sm"?"w-3.5 h-3.5":"w-4 h-4";return n.jsx("button",{type:"button",onClick:l,className:`inline-flex items-center justify-center p-1 rounded transition-colors ${a?"text-green-600 bg-green-50":"text-gray-400 hover:text-blue-600 hover:bg-blue-50"} ${t}`,title:a?"Kopiert!":r,children:a?n.jsx(Xu,{className:o}):n.jsx(Gy,{className:o})})}function nv({values:e,separator:t=`
`,children:s,className:r=""}){const a=e.filter(i=>i!=null&&i!=="").map(String).join(t);return a?n.jsxs("div",{className:`relative group ${r}`,children:[s,n.jsx(oe,{value:a,className:"absolute top-0 right-0 opacity-60 group-hover:opacity-100",title:"Alles kopieren"})]}):n.jsx(n.Fragment,{children:s})}function $1(){var B,J;const{id:e}=_o(),t=Ut(),s=pe(),{hasPermission:r}=st(),[a]=Uo(),i=parseInt(e),l=a.get("tab")||"addresses",[o,c]=w.useState(!1),[u,d]=w.useState(!1),[m,p]=w.useState(!1),[h,f]=w.useState(!1),[g,b]=w.useState(!1),[y,v]=w.useState(!1),[x,N]=w.useState(null),[k,D]=w.useState(null),[F,S]=w.useState(null),[L,T]=w.useState(null),[_,K]=w.useState(null),{data:W,isLoading:Q}=ge({queryKey:["customer",e],queryFn:()=>yt.getById(i)}),z=Y({mutationFn:()=>yt.delete(i),onSuccess:()=>{t("/customers")}});if(Q)return n.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(W!=null&&W.data))return n.jsx("div",{className:"text-center py-8 text-red-600",children:"Kunde nicht gefunden"});const P=W.data,j=[{id:"addresses",label:"Adressen",content:n.jsx(V1,{customerId:i,addresses:P.addresses||[],canEdit:r("customers:update"),onAdd:()=>c(!0),onEdit:ee=>S(ee)})},{id:"bankcards",label:"Bankkarten",content:n.jsx(q1,{customerId:i,bankCards:P.bankCards||[],canEdit:r("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>d(!0),onEdit:ee=>N(ee)})},{id:"documents",label:"Ausweise",content:n.jsx(Q1,{customerId:i,documents:P.identityDocuments||[],canEdit:r("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>p(!0),onEdit:ee=>D(ee)})},{id:"meters",label:"Zähler",content:n.jsx(H1,{customerId:i,meters:P.meters||[],canEdit:r("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>f(!0),onEdit:ee=>T(ee)})},{id:"stressfrei",label:"Stressfrei-Wechseln",content:n.jsx(Y1,{customerId:i,emails:P.stressfreiEmails||[],canEdit:r("customers:update"),showInactive:y,onToggleInactive:()=>v(!y),onAdd:()=>b(!0),onEdit:ee=>K(ee)})},{id:"contracts",label:"Verträge",content:n.jsx(W1,{customerId:i,contracts:P.contracts||[]})},...r("customers:update")?[{id:"portal",label:"Portal",content:n.jsx(Z1,{customerId:i,canEdit:r("customers:update")})}]:[]];return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:P.type==="BUSINESS"&&P.companyName?P.companyName:`${P.firstName} ${P.lastName}`}),n.jsxs("p",{className:"text-gray-500 font-mono flex items-center gap-1",children:[P.customerNumber,n.jsx(oe,{value:P.customerNumber})]})]}),n.jsxs("div",{className:"flex gap-2",children:[r("customers:update")&&n.jsx(Se,{to:`/customers/${e}/edit`,children:n.jsxs(I,{variant:"secondary",children:[n.jsx(We,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),r("customers:delete")&&n.jsxs(I,{variant:"danger",onClick:()=>{confirm("Kunde wirklich löschen?")&&z.mutate()},children:[n.jsx(be,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[n.jsx(Z,{title:"Stammdaten",className:"lg:col-span-2",children:n.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Typ"}),n.jsx("dd",{children:n.jsx(he,{variant:P.type==="BUSINESS"?"info":"default",children:P.type==="BUSINESS"?"Geschäftskunde":"Privatkunde"})})]}),P.salutation&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Anrede"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[P.salutation,n.jsx(oe,{value:P.salutation})]})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Vorname"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[P.firstName,n.jsx(oe,{value:P.firstName})]})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Nachname"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[P.lastName,n.jsx(oe,{value:P.lastName})]})]}),P.companyName&&n.jsxs("div",{className:"col-span-2",children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Firma"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[P.companyName,n.jsx(oe,{value:P.companyName})]})]}),P.foundingDate&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Gründungsdatum"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(P.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),n.jsx(oe,{value:new Date(P.foundingDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),P.birthDate&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsdatum"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[new Date(P.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"}),n.jsx(oe,{value:new Date(P.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]})]}),P.birthPlace&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Geburtsort"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[P.birthPlace,n.jsx(oe,{value:P.birthPlace})]})]})]})}),n.jsx(Z,{title:"Kontakt",children:n.jsxs("dl",{className:"space-y-3",children:[P.email&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"E-Mail"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[n.jsx("a",{href:`mailto:${P.email}`,className:"text-blue-600 hover:underline",children:P.email}),n.jsx(oe,{value:P.email})]})]}),P.phone&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Telefon"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[n.jsx("a",{href:`tel:${P.phone}`,className:"text-blue-600 hover:underline",children:P.phone}),n.jsx(oe,{value:P.phone})]})]}),P.mobile&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Mobil"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[n.jsx("a",{href:`tel:${P.mobile}`,className:"text-blue-600 hover:underline",children:P.mobile}),n.jsx(oe,{value:P.mobile})]})]})]})})]}),P.type==="BUSINESS"&&n.jsx(B1,{customer:P,canEdit:r("customers:update"),onUpdate:()=>s.invalidateQueries({queryKey:["customer",e]})}),n.jsx(K1,{customer:P,canEdit:r("customers:update"),onUpdate:()=>s.invalidateQueries({queryKey:["customer",e]})}),P.notes&&n.jsx(Z,{title:"Notizen",className:"mb-6",children:n.jsx("p",{className:"whitespace-pre-wrap",children:P.notes})}),n.jsx(Z,{children:n.jsx(U1,{tabs:j,defaultTab:l})}),n.jsx(rp,{isOpen:o,onClose:()=>c(!1),customerId:i}),n.jsx(rp,{isOpen:!!F,onClose:()=>S(null),customerId:i,address:F}),n.jsx(ap,{isOpen:u,onClose:()=>d(!1),customerId:i}),n.jsx(ap,{isOpen:!!x,onClose:()=>N(null),customerId:i,bankCard:x}),n.jsx(ip,{isOpen:m,onClose:()=>p(!1),customerId:i}),n.jsx(ip,{isOpen:!!k,onClose:()=>D(null),customerId:i,document:k}),n.jsx(lp,{isOpen:h,onClose:()=>f(!1),customerId:i}),n.jsx(lp,{isOpen:!!L,onClose:()=>T(null),customerId:i,meter:L}),n.jsx(cp,{isOpen:g,onClose:()=>b(!1),customerId:i,customerEmail:(B=W==null?void 0:W.data)==null?void 0:B.email}),n.jsx(cp,{isOpen:!!_,onClose:()=>K(null),customerId:i,email:_,customerEmail:(J=W==null?void 0:W.data)==null?void 0:J.email})]})}function B1({customer:e,canEdit:t,onUpdate:s}){const r=async c=>{try{await Ye.uploadBusinessRegistration(e.id,c),s()}catch(u){console.error("Upload fehlgeschlagen:",u),alert("Upload fehlgeschlagen")}},a=async()=>{if(confirm("Gewerbeanmeldung wirklich löschen?"))try{await Ye.deleteBusinessRegistration(e.id),s()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}},i=async c=>{try{await Ye.uploadCommercialRegister(e.id,c),s()}catch(u){console.error("Upload fehlgeschlagen:",u),alert("Upload fehlgeschlagen")}},l=async()=>{if(confirm("Handelsregisterauszug wirklich löschen?"))try{await Ye.deleteCommercialRegister(e.id),s()}catch(c){console.error("Löschen fehlgeschlagen:",c),alert("Löschen fehlgeschlagen")}};return!(e.taxNumber||e.commercialRegisterNumber||e.businessRegistrationPath||e.commercialRegisterPath)&&!t?null:n.jsxs(Z,{title:"Geschäftsdaten",className:"mb-6",children:[n.jsxs("dl",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.taxNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Steuernummer"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[e.taxNumber,n.jsx(oe,{value:e.taxNumber})]})]}),e.commercialRegisterNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Handelsregisternummer"}),n.jsxs("dd",{className:"flex items-center gap-1",children:[e.commercialRegisterNumber,n.jsx(oe,{value:e.commercialRegisterNumber})]})]})]}),n.jsxs("div",{className:"mt-4 pt-4 border-t grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Gewerbeanmeldung"}),e.businessRegistrationPath?n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsxs("a",{href:`/api${e.businessRegistrationPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(Ee,{className:"w-4 h-4"}),"Anzeigen"]}),n.jsxs("a",{href:`/api${e.businessRegistrationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(tn,{className:"w-4 h-4"}),"Download"]}),t&&n.jsxs(n.Fragment,{children:[n.jsx(xt,{onUpload:r,existingFile:e.businessRegistrationPath,accept:".pdf",label:"Ersetzen"}),n.jsxs("button",{onClick:a,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?n.jsx(xt,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):n.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]}),n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Handelsregisterauszug"}),e.commercialRegisterPath?n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsxs("a",{href:`/api${e.commercialRegisterPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(Ee,{className:"w-4 h-4"}),"Anzeigen"]}),n.jsxs("a",{href:`/api${e.commercialRegisterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(tn,{className:"w-4 h-4"}),"Download"]}),t&&n.jsxs(n.Fragment,{children:[n.jsx(xt,{onUpload:i,existingFile:e.commercialRegisterPath,accept:".pdf",label:"Ersetzen"}),n.jsxs("button",{onClick:l,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?n.jsx(xt,{onUpload:i,accept:".pdf",label:"PDF hochladen"}):n.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})]})]})}function K1({customer:e,canEdit:t,onUpdate:s}){const r=async i=>{try{await Ye.uploadPrivacyPolicy(e.id,i),s()}catch(l){console.error("Upload fehlgeschlagen:",l),alert("Upload fehlgeschlagen")}},a=async()=>{if(confirm("Datenschutzerklärung wirklich löschen?"))try{await Ye.deletePrivacyPolicy(e.id),s()}catch(i){console.error("Löschen fehlgeschlagen:",i),alert("Löschen fehlgeschlagen")}};return!e.privacyPolicyPath&&!t?null:n.jsx(Z,{title:"Dokumente",className:"mb-6",children:n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Datenschutzerklärung"}),e.privacyPolicyPath?n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsxs("a",{href:`/api${e.privacyPolicyPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(Ee,{className:"w-4 h-4"}),"Anzeigen"]}),n.jsxs("a",{href:`/api${e.privacyPolicyPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(tn,{className:"w-4 h-4"}),"Download"]}),t&&n.jsxs(n.Fragment,{children:[n.jsx(xt,{onUpload:r,existingFile:e.privacyPolicyPath,accept:".pdf",label:"Ersetzen"}),n.jsxs("button",{onClick:a,className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):t?n.jsx(xt,{onUpload:r,accept:".pdf",label:"PDF hochladen"}):n.jsx("p",{className:"text-sm text-gray-400",children:"Nicht vorhanden"})]})})}function V1({customerId:e,addresses:t,canEdit:s,onAdd:r,onEdit:a}){const i=pe(),l=Y({mutationFn:Ju.delete,onSuccess:()=>i.invalidateQueries({queryKey:["customer",e.toString()]})});return n.jsxs("div",{children:[s&&n.jsx("div",{className:"mb-4",children:n.jsxs(I,{size:"sm",onClick:r,children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]})}),t.length>0?n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:t.map(o=>n.jsxs("div",{className:"border rounded-lg p-4",children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(b1,{className:"w-4 h-4 text-gray-400"}),n.jsx(he,{variant:o.type==="BILLING"?"info":"default",children:o.type==="BILLING"?"Rechnung":"Liefer-/Meldeadresse"}),o.isDefault&&n.jsx(he,{variant:"success",children:"Standard"})]}),s&&n.jsxs("div",{className:"flex gap-1",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>a(o),title:"Bearbeiten",children:n.jsx(We,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&l.mutate(o.id)},title:"Löschen",children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),n.jsxs(nv,{values:[`${o.street} ${o.houseNumber}`,`${o.postalCode} ${o.city}`,o.country],children:[n.jsxs("p",{children:[o.street," ",o.houseNumber]}),n.jsxs("p",{children:[o.postalCode," ",o.city]}),n.jsx("p",{className:"text-gray-500",children:o.country})]})]},o.id))}):n.jsx("p",{className:"text-gray-500",children:"Keine Adressen vorhanden."})]})}function q1({customerId:e,bankCards:t,canEdit:s,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=pe(),c=Y({mutationFn:({id:h,data:f})=>po.update(h,f),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=Y({mutationFn:po.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=async(h,f)=>{try{await Ye.uploadBankCardDocument(h,f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(g){console.error("Upload fehlgeschlagen:",g),alert("Upload fehlgeschlagen")}},m=async h=>{if(confirm("Dokument wirklich löschen?"))try{await Ye.deleteBankCardDocument(h),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(f){console.error("Löschen fehlgeschlagen:",f),alert("Löschen fehlgeschlagen")}},p=r?t:t.filter(h=>h.isActive);return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s&&n.jsxs(I,{size:"sm",onClick:i,children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Bankkarte hinzufügen"]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),p.length>0?n.jsx("div",{className:"space-y-4",children:p.map(h=>n.jsxs("div",{className:`border rounded-lg p-4 ${h.isActive?"":"opacity-50 bg-gray-50"}`,children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(p1,{className:"w-4 h-4 text-gray-400"}),!h.isActive&&n.jsx(he,{variant:"danger",children:"Inaktiv"}),h.expiryDate&&new Date(h.expiryDate)<new Date&&n.jsx(he,{variant:"warning",children:"Abgelaufen"})]}),s&&n.jsxs("div",{className:"flex gap-1",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(h),title:"Bearbeiten",children:n.jsx(We,{className:"w-4 h-4"})}),h.isActive?n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte deaktivieren?")&&c.mutate({id:h.id,data:{isActive:!1}})},title:"Deaktivieren",children:n.jsx(Pt,{className:"w-4 h-4"})}):n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wieder aktivieren?")&&c.mutate({id:h.id,data:{isActive:!0}})},title:"Aktivieren",children:n.jsx(Ee,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Bankkarte wirklich löschen?")&&u.mutate(h.id)},title:"Löschen",children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),n.jsxs("p",{className:"font-medium flex items-center gap-1",children:[h.accountHolder,n.jsx(oe,{value:h.accountHolder})]}),n.jsxs("p",{className:"font-mono flex items-center gap-1",children:[h.iban,n.jsx(oe,{value:h.iban})]}),h.bic&&n.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["BIC: ",h.bic,n.jsx(oe,{value:h.bic})]}),h.bankName&&n.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:[h.bankName,n.jsx(oe,{value:h.bankName})]}),h.expiryDate&&n.jsxs("p",{className:"text-sm text-gray-500",children:["Gültig bis: ",new Date(h.expiryDate).toLocaleDateString("de-DE")]}),n.jsx("div",{className:"mt-3 pt-3 border-t",children:h.documentPath?n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsxs("a",{href:`/api${h.documentPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(Ee,{className:"w-4 h-4"}),"Anzeigen"]}),n.jsxs("a",{href:`/api${h.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(tn,{className:"w-4 h-4"}),"Download"]}),s&&n.jsxs(n.Fragment,{children:[n.jsx(xt,{onUpload:f=>d(h.id,f),existingFile:h.documentPath,accept:".pdf",label:"Ersetzen",disabled:!h.isActive}),n.jsxs("button",{onClick:()=>m(h.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[n.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):s&&h.isActive&&n.jsx(xt,{onUpload:f=>d(h.id,f),accept:".pdf",label:"PDF hochladen"})})]},h.id))}):n.jsx("p",{className:"text-gray-500",children:"Keine Bankkarten vorhanden."})]})}function Q1({customerId:e,documents:t,canEdit:s,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=pe(),c=Y({mutationFn:({id:f,data:g})=>go.update(f,g),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=Y({mutationFn:go.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=async(f,g)=>{try{await Ye.uploadIdentityDocument(f,g),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(b){console.error("Upload fehlgeschlagen:",b),alert("Upload fehlgeschlagen")}},m=async f=>{if(confirm("Dokument wirklich löschen?"))try{await Ye.deleteIdentityDocument(f),o.invalidateQueries({queryKey:["customer",e.toString()]})}catch(g){console.error("Löschen fehlgeschlagen:",g),alert("Löschen fehlgeschlagen")}},p=r?t:t.filter(f=>f.isActive),h={ID_CARD:"Personalausweis",PASSPORT:"Reisepass",DRIVERS_LICENSE:"Führerschein",OTHER:"Sonstiges"};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s&&n.jsxs(I,{size:"sm",onClick:i,children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Ausweis hinzufügen"]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),p.length>0?n.jsx("div",{className:"space-y-4",children:p.map(f=>n.jsxs("div",{className:`border rounded-lg p-4 ${f.isActive?"":"opacity-50 bg-gray-50"}`,children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(vt,{className:"w-4 h-4 text-gray-400"}),n.jsx(he,{children:h[f.type]}),!f.isActive&&n.jsx(he,{variant:"danger",children:"Inaktiv"}),f.expiryDate&&new Date(f.expiryDate)<new Date&&n.jsx(he,{variant:"warning",children:"Abgelaufen"})]}),s&&n.jsxs("div",{className:"flex gap-1",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(f),title:"Bearbeiten",children:n.jsx(We,{className:"w-4 h-4"})}),f.isActive?n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis deaktivieren?")&&c.mutate({id:f.id,data:{isActive:!1}})},title:"Deaktivieren",children:n.jsx(Pt,{className:"w-4 h-4"})}):n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wieder aktivieren?")&&c.mutate({id:f.id,data:{isActive:!0}})},title:"Aktivieren",children:n.jsx(Ee,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Ausweis wirklich löschen?")&&u.mutate(f.id)},title:"Löschen",children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),n.jsxs("p",{className:"font-mono flex items-center gap-1",children:[f.documentNumber,n.jsx(oe,{value:f.documentNumber})]}),f.issuingAuthority&&n.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Ausgestellt von: ",f.issuingAuthority,n.jsx(oe,{value:f.issuingAuthority})]}),f.expiryDate&&n.jsxs("p",{className:"text-sm text-gray-500",children:["Gültig bis: ",new Date(f.expiryDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})]}),f.type==="DRIVERS_LICENSE"&&f.licenseClasses&&n.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Klassen: ",f.licenseClasses,n.jsx(oe,{value:f.licenseClasses})]}),f.type==="DRIVERS_LICENSE"&&f.licenseIssueDate&&n.jsxs("p",{className:"text-sm text-gray-500",children:["Klasse B seit: ",new Date(f.licenseIssueDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})]}),n.jsx("div",{className:"mt-3 pt-3 border-t",children:f.documentPath?n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.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:[n.jsx(Ee,{className:"w-4 h-4"}),"Anzeigen"]}),n.jsxs("a",{href:`/api${f.documentPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(tn,{className:"w-4 h-4"}),"Download"]}),s&&n.jsxs(n.Fragment,{children:[n.jsx(xt,{onUpload:g=>d(f.id,g),existingFile:f.documentPath,accept:".pdf",label:"Ersetzen",disabled:!f.isActive}),n.jsxs("button",{onClick:()=>m(f.id),className:"text-red-600 hover:underline text-sm flex items-center gap-1",title:"Dokument löschen",children:[n.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]})]}):s&&f.isActive&&n.jsx(xt,{onUpload:g=>d(f.id,g),accept:".pdf",label:"PDF hochladen"})})]},f.id))}):n.jsx("p",{className:"text-gray-500",children:"Keine Ausweise vorhanden."})]})}function H1({customerId:e,meters:t,canEdit:s,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const[o,c]=w.useState(null),[u,d]=w.useState(null),[m,p]=w.useState(null),h=pe(),f=Y({mutationFn:({id:x,data:N})=>zs.update(x,N),onSuccess:()=>h.invalidateQueries({queryKey:["customer",e.toString()]})}),g=Y({mutationFn:zs.delete,onSuccess:()=>h.invalidateQueries({queryKey:["customer",e.toString()]})}),b=Y({mutationFn:({meterId:x,readingId:N})=>zs.deleteReading(x,N),onSuccess:()=>h.invalidateQueries({queryKey:["customer",e.toString()]})}),y=r?t:t.filter(x=>x.isActive),v=x=>x?[...x].sort((N,k)=>new Date(k.readingDate).getTime()-new Date(N.readingDate).getTime()):[];return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s&&n.jsxs(I,{size:"sm",onClick:i,children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Zähler hinzufügen"]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),y.length>0?n.jsx("div",{className:"space-y-4",children:y.map(x=>{const N=v(x.readings),k=u===x.id;return n.jsxs("div",{className:`border rounded-lg p-4 ${x.isActive?"":"opacity-50 bg-gray-50"}`,children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(Xy,{className:"w-4 h-4 text-gray-400"}),n.jsx(he,{variant:x.type==="ELECTRICITY"?"warning":"info",children:x.type==="ELECTRICITY"?"Strom":"Gas"}),!x.isActive&&n.jsx(he,{variant:"danger",children:"Inaktiv"})]}),s&&n.jsxs("div",{className:"flex gap-1",children:[x.isActive&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>c(x.id),title:"Zählerstand hinzufügen",children:n.jsx(Oe,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(x),title:"Bearbeiten",children:n.jsx(We,{className:"w-4 h-4"})}),x.isActive?n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler deaktivieren?")&&f.mutate({id:x.id,data:{isActive:!1}})},title:"Deaktivieren",children:n.jsx(Pt,{className:"w-4 h-4"})}):n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wieder aktivieren?")&&f.mutate({id:x.id,data:{isActive:!0}})},title:"Aktivieren",children:n.jsx(Ee,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Zähler wirklich löschen? Alle Zählerstände werden ebenfalls gelöscht.")&&g.mutate(x.id)},title:"Löschen",children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),n.jsxs("p",{className:"font-mono text-lg flex items-center gap-1",children:[x.meterNumber,n.jsx(oe,{value:x.meterNumber})]}),x.location&&n.jsxs("p",{className:"text-sm text-gray-500 flex items-center gap-1",children:["Standort: ",x.location,n.jsx(oe,{value:x.location})]}),N.length>0&&n.jsxs("div",{className:"mt-3 pt-3 border-t",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsx("p",{className:"text-sm font-medium",children:"Zählerstände:"}),N.length>3&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>d(k?null:x.id),children:k?"Weniger anzeigen":`Alle ${N.length} anzeigen`})]}),n.jsx("div",{className:"space-y-1",children:(k?N:N.slice(0,3)).map(D=>n.jsxs("div",{className:"flex justify-between items-center text-sm group",children:[n.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(D.readingDate).toLocaleDateString("de-DE"),n.jsx(oe,{value:new Date(D.readingDate).toLocaleDateString("de-DE")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("span",{className:"font-mono flex items-center gap-1",children:[D.value.toLocaleString("de-DE")," ",D.unit,n.jsx(oe,{value:D.value.toString(),title:"Nur Wert kopieren"}),n.jsx(oe,{value:`${D.value.toLocaleString("de-DE")} ${D.unit}`,title:"Mit Einheit kopieren"})]}),s&&n.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[n.jsx("button",{onClick:()=>p({meterId:x.id,reading:D}),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:n.jsx(We,{className:"w-3 h-3"})}),n.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&b.mutate({meterId:x.id,readingId:D.id})},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:n.jsx(be,{className:"w-3 h-3"})})]})]})]},D.id))})]})]},x.id)})}):n.jsx("p",{className:"text-gray-500",children:"Keine Zähler vorhanden."}),o&&n.jsx(op,{isOpen:!0,onClose:()=>c(null),meterId:o,customerId:e}),m&&n.jsx(op,{isOpen:!0,onClose:()=>p(null),meterId:m.meterId,customerId:e,reading:m.reading})]})}function W1({customerId:e,contracts:t}){const{hasPermission:s}=st(),r=Ut(),a=pe(),i=Y({mutationFn:$e.delete,onSuccess:()=>{a.invalidateQueries({queryKey:["customer",e.toString()]}),a.invalidateQueries({queryKey:["customers"]}),a.invalidateQueries({queryKey:["contracts"]})},onError:c=>{alert((c==null?void 0:c.message)||"Fehler beim Löschen des Vertrags")}}),l={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},o={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default"};return n.jsxs("div",{children:[s("contracts:create")&&n.jsx("div",{className:"mb-4",children:n.jsx(Se,{to:`/contracts/new?customerId=${e}`,children:n.jsxs(I,{size:"sm",children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Vertrag anlegen"]})})}),t.length>0?n.jsx("div",{className:"space-y-4",children:t.map(c=>n.jsxs("div",{className:"border rounded-lg p-4 hover:bg-gray-50 transition-colors",children:[n.jsxs("div",{className:"flex items-center justify-between mb-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("span",{className:"font-mono flex items-center gap-1",children:[c.contractNumber,n.jsx(oe,{value:c.contractNumber})]}),n.jsx(he,{children:l[c.type]}),n.jsx(he,{variant:o[c.status],children:c.status})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>r(`/contracts/${c.id}`,{state:{from:"customer",customerId:e.toString()}}),title:"Ansehen",children:n.jsx(Ee,{className:"w-4 h-4"})}),s("contracts:update")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>r(`/contracts/${c.id}/edit`),title:"Bearbeiten",children:n.jsx(We,{className:"w-4 h-4"})}),s("contracts:delete")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&i.mutate(c.id)},title:"Löschen",children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),c.providerName&&n.jsxs("p",{className:"flex items-center gap-1",children:[c.providerName,c.tariffName&&` - ${c.tariffName}`,n.jsx(oe,{value:c.providerName+(c.tariffName?` - ${c.tariffName}`:"")})]}),c.startDate&&n.jsxs("p",{className:"text-sm text-gray-500",children:["Beginn: ",new Date(c.startDate).toLocaleDateString("de-DE"),c.endDate&&` | Ende: ${new Date(c.endDate).toLocaleDateString("de-DE")}`]})]},c.id))}):n.jsx("p",{className:"text-gray-500",children:"Keine Verträge vorhanden."})]})}function G1({customerId:e}){const[t,s]=w.useState(!1),[r,a]=w.useState(null),[i,l]=w.useState(!1),o=async()=>{var c;if(t){s(!1);return}l(!0);try{const u=await yt.getPortalPassword(e);a(((c=u.data)==null?void 0:c.password)||null),s(!0)}catch(u){console.error("Fehler beim Laden des Passworts:",u),alert("Fehler beim Laden des Passworts")}finally{l(!1)}};return n.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[n.jsx("p",{className:"text-xs text-green-600",children:"Passwort ist gesetzt"}),n.jsx("button",{type:"button",onClick:o,className:"text-xs text-blue-600 hover:underline flex items-center gap-1",disabled:i,children:i?"Laden...":t?n.jsxs(n.Fragment,{children:[n.jsx(Pt,{className:"w-3 h-3"}),"Verbergen"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ee,{className:"w-3 h-3"}),"Anzeigen"]})}),t&&r&&n.jsxs("span",{className:"text-xs font-mono bg-gray-100 px-2 py-1 rounded flex items-center gap-1",children:[r,n.jsx(oe,{value:r})]}),t&&!r&&n.jsx("span",{className:"text-xs text-gray-500",children:"(Passwort nicht verfügbar)"})]})}function Z1({customerId:e,canEdit:t}){const s=pe(),[r,a]=w.useState(!1),[i,l]=w.useState(""),[o,c]=w.useState(""),[u,d]=w.useState([]),[m,p]=w.useState(!1),{data:h,isLoading:f}=ge({queryKey:["customer-portal",e],queryFn:()=>yt.getPortalSettings(e)}),{data:g,isLoading:b}=ge({queryKey:["customer-representatives",e],queryFn:()=>yt.getRepresentatives(e)}),y=Y({mutationFn:S=>yt.updatePortalSettings(e,S),onSuccess:()=>{s.invalidateQueries({queryKey:["customer-portal",e]})}}),v=Y({mutationFn:S=>yt.setPortalPassword(e,S),onSuccess:()=>{l(""),s.invalidateQueries({queryKey:["customer-portal",e]}),alert("Passwort wurde gesetzt")},onError:S=>{alert(S.message)}}),x=Y({mutationFn:S=>yt.addRepresentative(e,S),onSuccess:()=>{s.invalidateQueries({queryKey:["customer-representatives",e]}),c(""),d([])},onError:S=>{alert(S.message)}}),N=Y({mutationFn:S=>yt.removeRepresentative(e,S),onSuccess:()=>{s.invalidateQueries({queryKey:["customer-representatives",e]})}}),k=async()=>{if(!(o.length<2)){p(!0);try{const S=await yt.searchForRepresentative(e,o);d(S.data||[])}catch(S){console.error("Suche fehlgeschlagen:",S)}finally{p(!1)}}};if(f||b)return n.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."});const D=h==null?void 0:h.data,F=(g==null?void 0:g.data)||[];return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"border rounded-lg p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[n.jsx(uh,{className:"w-5 h-5 text-gray-400"}),n.jsx("h3",{className:"font-medium",children:"Portal-Zugang"})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("label",{className:"flex items-center gap-3",children:[n.jsx("input",{type:"checkbox",checked:(D==null?void 0:D.portalEnabled)||!1,onChange:S=>y.mutate({portalEnabled:S.target.checked}),className:"rounded w-5 h-5",disabled:!t}),n.jsx("span",{children:"Portal aktiviert"}),(D==null?void 0:D.portalEnabled)&&n.jsx(he,{variant:"success",children:"Aktiv"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Portal E-Mail"}),n.jsx("div",{className:"flex gap-2",children:n.jsx($,{value:(D==null?void 0:D.portalEmail)||"",onChange:S=>y.mutate({portalEmail:S.target.value||null}),placeholder:"portal@example.com",disabled:!t||!(D!=null&&D.portalEnabled),className:"flex-1"})}),n.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Diese E-Mail wird für den Login ins Kundenportal verwendet."})]}),(D==null?void 0:D.portalEnabled)&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:D!=null&&D.hasPassword?"Neues Passwort setzen":"Passwort setzen"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx($,{type:r?"text":"password",value:i,onChange:S=>l(S.target.value),placeholder:"Mindestens 6 Zeichen",disabled:!t}),n.jsx("button",{type:"button",onClick:()=>a(!r),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400",children:r?n.jsx(Pt,{className:"w-4 h-4"}):n.jsx(Ee,{className:"w-4 h-4"})})]}),n.jsx(I,{onClick:()=>v.mutate(i),disabled:!t||i.length<6||v.isPending,children:v.isPending?"Speichern...":"Setzen"})]}),(D==null?void 0:D.hasPassword)&&n.jsx(G1,{customerId:e})]}),(D==null?void 0:D.portalLastLogin)&&n.jsxs("p",{className:"text-sm text-gray-500",children:["Letzte Anmeldung: ",new Date(D.portalLastLogin).toLocaleString("de-DE")]})]})]}),n.jsxs("div",{className:"border rounded-lg p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[n.jsx(A1,{className:"w-5 h-5 text-gray-400"}),n.jsx("h3",{className:"font-medium",children:"Vertreter (können Verträge einsehen)"})]}),n.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."}),t&&n.jsxs("div",{className:"mb-4",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsx($,{value:o,onChange:S=>c(S.target.value),placeholder:"Kunden suchen (Name, Kundennummer)...",onKeyDown:S=>S.key==="Enter"&&k(),className:"flex-1"}),n.jsx(I,{variant:"secondary",onClick:k,disabled:o.length<2||m,children:n.jsx(Wo,{className:"w-4 h-4"})})]}),n.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"Nur Kunden mit aktiviertem Portal können als Vertreter hinzugefügt werden."}),u.length>0&&n.jsx("div",{className:"mt-2 border rounded-lg divide-y",children:u.map(S=>n.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-gray-50",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-medium",children:S.companyName||`${S.firstName} ${S.lastName}`}),n.jsx("p",{className:"text-sm text-gray-500",children:S.customerNumber})]}),n.jsxs(I,{size:"sm",onClick:()=>x.mutate(S.id),disabled:x.isPending,children:[n.jsx(Oe,{className:"w-4 h-4 mr-1"}),"Hinzufügen"]})]},S.id))})]}),F.length>0?n.jsx("div",{className:"space-y-2",children:F.map(S=>{var L,T,_,K;return n.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 rounded-lg",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-medium",children:((L=S.representative)==null?void 0:L.companyName)||`${(T=S.representative)==null?void 0:T.firstName} ${(_=S.representative)==null?void 0:_.lastName}`}),n.jsx("p",{className:"text-sm text-gray-500",children:(K=S.representative)==null?void 0:K.customerNumber})]}),t&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertreter wirklich entfernen?")&&N.mutate(S.representativeId)},children:n.jsx(wa,{className:"w-4 h-4 text-red-500"})})]},S.id)})}):n.jsx("p",{className:"text-gray-500 text-sm",children:"Keine Vertreter konfiguriert."})]})]})}function rp({isOpen:e,onClose:t,customerId:s,address:r}){const a=pe(),i=!!r,l=()=>({type:(r==null?void 0:r.type)||"DELIVERY_RESIDENCE",street:(r==null?void 0:r.street)||"",houseNumber:(r==null?void 0:r.houseNumber)||"",postalCode:(r==null?void 0:r.postalCode)||"",city:(r==null?void 0:r.city)||"",country:(r==null?void 0:r.country)||"Deutschland",isDefault:(r==null?void 0:r.isDefault)||!1}),[o,c]=w.useState(l),u=Y({mutationFn:h=>Ju.create(s,h),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",s.toString()]}),t(),c({type:"DELIVERY_RESIDENCE",street:"",houseNumber:"",postalCode:"",city:"",country:"Deutschland",isDefault:!1})}}),d=Y({mutationFn:h=>Ju.update(r.id,h),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",s.toString()]}),t()}}),m=h=>{h.preventDefault(),i?d.mutate(o):u.mutate(o)},p=u.isPending||d.isPending;return i&&o.street!==r.street&&c(l()),n.jsx(dt,{isOpen:e,onClose:t,title:i?"Adresse bearbeiten":"Adresse hinzufügen",children:n.jsxs("form",{onSubmit:m,className:"space-y-4",children:[n.jsx(Le,{label:"Adresstyp",value:o.type,onChange:h=>c({...o,type:h.target.value}),options:[{value:"DELIVERY_RESIDENCE",label:"Liefer-/Meldeadresse"},{value:"BILLING",label:"Rechnungsadresse"}]}),n.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[n.jsx("div",{className:"col-span-2",children:n.jsx($,{label:"Straße",value:o.street,onChange:h=>c({...o,street:h.target.value}),required:!0})}),n.jsx($,{label:"Hausnr.",value:o.houseNumber,onChange:h=>c({...o,houseNumber:h.target.value}),required:!0})]}),n.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[n.jsx($,{label:"PLZ",value:o.postalCode,onChange:h=>c({...o,postalCode:h.target.value}),required:!0}),n.jsx("div",{className:"col-span-2",children:n.jsx($,{label:"Ort",value:o.city,onChange:h=>c({...o,city:h.target.value}),required:!0})})]}),n.jsx($,{label:"Land",value:o.country,onChange:h=>c({...o,country:h.target.value})}),n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:o.isDefault,onChange:h=>c({...o,isDefault:h.target.checked}),className:"rounded"}),"Als Standard setzen"]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function ap({isOpen:e,onClose:t,customerId:s,bankCard:r}){const a=pe(),i=!!r,l=()=>({accountHolder:(r==null?void 0:r.accountHolder)||"",iban:(r==null?void 0:r.iban)||"",bic:(r==null?void 0:r.bic)||"",bankName:(r==null?void 0:r.bankName)||"",expiryDate:r!=null&&r.expiryDate?new Date(r.expiryDate).toISOString().split("T")[0]:"",isActive:(r==null?void 0:r.isActive)??!0}),[o,c]=w.useState(l);w.useState(()=>{c(l())});const u=Y({mutationFn:h=>po.create(s,h),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",s.toString()]}),t(),c({accountHolder:"",iban:"",bic:"",bankName:"",expiryDate:"",isActive:!0})}}),d=Y({mutationFn:h=>po.update(r.id,h),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",s.toString()]}),t()}}),m=h=>{h.preventDefault();const f={...o,expiryDate:o.expiryDate?new Date(o.expiryDate):void 0};i?d.mutate(f):u.mutate(f)},p=u.isPending||d.isPending;return i&&o.iban!==r.iban&&c(l()),n.jsx(dt,{isOpen:e,onClose:t,title:i?"Bankkarte bearbeiten":"Bankkarte hinzufügen",children:n.jsxs("form",{onSubmit:m,className:"space-y-4",children:[n.jsx($,{label:"Kontoinhaber",value:o.accountHolder,onChange:h=>c({...o,accountHolder:h.target.value}),required:!0}),n.jsx($,{label:"IBAN",value:o.iban,onChange:h=>c({...o,iban:h.target.value}),required:!0}),n.jsx($,{label:"BIC",value:o.bic,onChange:h=>c({...o,bic:h.target.value})}),n.jsx($,{label:"Bank",value:o.bankName,onChange:h=>c({...o,bankName:h.target.value})}),n.jsx($,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:h=>c({...o,expiryDate:h.target.value}),onClear:()=>c({...o,expiryDate:""})}),i&&n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:o.isActive,onChange:h=>c({...o,isActive:h.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&n.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."}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function ip({isOpen:e,onClose:t,customerId:s,document:r}){const a=pe(),i=!!r,l=()=>({type:(r==null?void 0:r.type)||"ID_CARD",documentNumber:(r==null?void 0:r.documentNumber)||"",issuingAuthority:(r==null?void 0:r.issuingAuthority)||"",issueDate:r!=null&&r.issueDate?new Date(r.issueDate).toISOString().split("T")[0]:"",expiryDate:r!=null&&r.expiryDate?new Date(r.expiryDate).toISOString().split("T")[0]:"",isActive:(r==null?void 0:r.isActive)??!0,licenseClasses:(r==null?void 0:r.licenseClasses)||"",licenseIssueDate:r!=null&&r.licenseIssueDate?new Date(r.licenseIssueDate).toISOString().split("T")[0]:""}),[o,c]=w.useState(l),u=Y({mutationFn:h=>go.create(s,h),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",s.toString()]}),t(),c({type:"ID_CARD",documentNumber:"",issuingAuthority:"",issueDate:"",expiryDate:"",isActive:!0,licenseClasses:"",licenseIssueDate:""})}}),d=Y({mutationFn:h=>go.update(r.id,h),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",s.toString()]}),t()}}),m=h=>{h.preventDefault();const f={...o,issueDate:o.issueDate?new Date(o.issueDate):void 0,expiryDate:o.expiryDate?new Date(o.expiryDate):void 0};o.type==="DRIVERS_LICENSE"?(f.licenseClasses=o.licenseClasses||void 0,f.licenseIssueDate=o.licenseIssueDate?new Date(o.licenseIssueDate):void 0):(delete f.licenseClasses,delete f.licenseIssueDate),i?d.mutate(f):u.mutate(f)},p=u.isPending||d.isPending;return i&&o.documentNumber!==r.documentNumber&&c(l()),n.jsx(dt,{isOpen:e,onClose:t,title:i?"Ausweis bearbeiten":"Ausweis hinzufügen",children:n.jsxs("form",{onSubmit:m,className:"space-y-4",children:[n.jsx(Le,{label:"Ausweistyp",value:o.type,onChange:h=>c({...o,type:h.target.value}),options:[{value:"ID_CARD",label:"Personalausweis"},{value:"PASSPORT",label:"Reisepass"},{value:"DRIVERS_LICENSE",label:"Führerschein"},{value:"OTHER",label:"Sonstiges"}]}),n.jsx($,{label:"Ausweisnummer",value:o.documentNumber,onChange:h=>c({...o,documentNumber:h.target.value}),required:!0}),n.jsx($,{label:"Ausstellende Behörde",value:o.issuingAuthority,onChange:h=>c({...o,issuingAuthority:h.target.value})}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx($,{label:"Ausstellungsdatum",type:"date",value:o.issueDate,onChange:h=>c({...o,issueDate:h.target.value}),onClear:()=>c({...o,issueDate:""})}),n.jsx($,{label:"Ablaufdatum",type:"date",value:o.expiryDate,onChange:h=>c({...o,expiryDate:h.target.value}),onClear:()=>c({...o,expiryDate:""})})]}),o.type==="DRIVERS_LICENSE"&&n.jsxs(n.Fragment,{children:[n.jsx($,{label:"Führerscheinklassen",value:o.licenseClasses,onChange:h=>c({...o,licenseClasses:h.target.value}),placeholder:"z.B. B, BE, AM, L"}),n.jsx($,{label:"Erwerb Klasse B (Pkw)",type:"date",value:o.licenseIssueDate,onChange:h=>c({...o,licenseIssueDate:h.target.value}),onClear:()=>c({...o,licenseIssueDate:""})})]}),i&&n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:o.isActive,onChange:h=>c({...o,isActive:h.target.checked}),className:"rounded"}),"Aktiv"]}),!i&&n.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."}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function lp({isOpen:e,onClose:t,customerId:s,meter:r}){const a=pe(),i=!!r,l=()=>({meterNumber:(r==null?void 0:r.meterNumber)||"",type:(r==null?void 0:r.type)||"ELECTRICITY",location:(r==null?void 0:r.location)||"",isActive:(r==null?void 0:r.isActive)??!0}),[o,c]=w.useState(l),u=Y({mutationFn:h=>zs.create(s,h),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",s.toString()]}),t(),c({meterNumber:"",type:"ELECTRICITY",location:"",isActive:!0})}}),d=Y({mutationFn:h=>zs.update(r.id,h),onSuccess:()=>{a.invalidateQueries({queryKey:["customer",s.toString()]}),t()}}),m=h=>{h.preventDefault(),i?d.mutate(o):u.mutate(o)},p=u.isPending||d.isPending;return i&&o.meterNumber!==r.meterNumber&&c(l()),n.jsx(dt,{isOpen:e,onClose:t,title:i?"Zähler bearbeiten":"Zähler hinzufügen",children:n.jsxs("form",{onSubmit:m,className:"space-y-4",children:[n.jsx($,{label:"Zählernummer",value:o.meterNumber,onChange:h=>c({...o,meterNumber:h.target.value}),required:!0}),n.jsx(Le,{label:"Zählertyp",value:o.type,onChange:h=>c({...o,type:h.target.value}),options:[{value:"ELECTRICITY",label:"Strom"},{value:"GAS",label:"Gas"}]}),n.jsx($,{label:"Standort",value:o.location,onChange:h=>c({...o,location:h.target.value}),placeholder:"z.B. Keller, Wohnung"}),i&&n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:o.isActive,onChange:h=>c({...o,isActive:h.target.checked}),className:"rounded"}),"Aktiv"]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:p,children:p?"Speichern...":"Speichern"})]})]})})}function op({isOpen:e,onClose:t,meterId:s,customerId:r,reading:a}){const i=pe(),l=!!a,o=()=>{var f;return{readingDate:a!=null&&a.readingDate?new Date(a.readingDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],value:((f=a==null?void 0:a.value)==null?void 0:f.toString())||"",unit:(a==null?void 0:a.unit)||"kWh",notes:(a==null?void 0:a.notes)||""}},[c,u]=w.useState(o),d=Y({mutationFn:f=>zs.addReading(s,f),onSuccess:()=>{i.invalidateQueries({queryKey:["customer",r.toString()]}),t()}}),m=Y({mutationFn:f=>zs.updateReading(s,a.id,f),onSuccess:()=>{i.invalidateQueries({queryKey:["customer",r.toString()]}),t()}}),p=f=>{f.preventDefault();const g={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:c.unit,notes:c.notes||void 0};l?m.mutate(g):d.mutate(g)},h=d.isPending||m.isPending;return l&&c.value!==a.value.toString()&&u(o()),n.jsx(dt,{isOpen:e,onClose:t,title:l?"Zählerstand bearbeiten":"Zählerstand erfassen",children:n.jsxs("form",{onSubmit:p,className:"space-y-4",children:[n.jsx($,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:f=>u({...c,readingDate:f.target.value}),required:!0}),n.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[n.jsx("div",{className:"col-span-2",children:n.jsx($,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:f=>u({...c,value:f.target.value}),required:!0})}),n.jsx(Le,{label:"Einheit",value:c.unit,onChange:f=>u({...c,unit:f.target.value}),options:[{value:"kWh",label:"kWh"},{value:"m³",label:"m³"}]})]}),n.jsx($,{label:"Notizen",value:c.notes,onChange:f=>u({...c,notes:f.target.value}),placeholder:"Optionale Notizen..."}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:h,children:h?"Speichern...":"Speichern"})]})]})})}const Tc="@stressfrei-wechseln.de";function Y1({customerId:e,emails:t,canEdit:s,showInactive:r,onToggleInactive:a,onAdd:i,onEdit:l}){const o=pe(),c=Y({mutationFn:({id:m,data:p})=>xo.update(m,p),onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),u=Y({mutationFn:xo.delete,onSuccess:()=>o.invalidateQueries({queryKey:["customer",e.toString()]})}),d=r?t:t.filter(m=>m.isActive);return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s&&n.jsxs(I,{size:"sm",onClick:i,children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Adresse hinzufügen"]}),n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"checkbox",checked:r,onChange:a,className:"rounded"}),"Inaktive anzeigen"]})]}),n.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[n.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."]}),d.length>0?n.jsx("div",{className:"space-y-3",children:d.map(m=>n.jsx("div",{className:`border rounded-lg p-4 ${m.isActive?"":"opacity-50 bg-gray-50"}`,children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ev,{className:"w-4 h-4 text-gray-400"}),n.jsx("span",{className:"font-mono text-sm",children:m.email}),n.jsx(oe,{value:m.email}),!m.isActive&&n.jsx(he,{variant:"danger",children:"Inaktiv"})]}),m.notes&&n.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-gray-500",children:[n.jsx(vt,{className:"w-4 h-4 flex-shrink-0"}),n.jsx("span",{children:m.notes})]})]}),s&&n.jsxs("div",{className:"flex gap-1",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(m),title:"Bearbeiten",children:n.jsx(We,{className:"w-4 h-4"})}),m.isActive?n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse deaktivieren?")&&c.mutate({id:m.id,data:{isActive:!1}})},title:"Deaktivieren",children:n.jsx(Pt,{className:"w-4 h-4"})}):n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wieder aktivieren?")&&c.mutate({id:m.id,data:{isActive:!0}})},title:"Aktivieren",children:n.jsx(Ee,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Adresse wirklich löschen?")&&u.mutate(m.id)},title:"Löschen",children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]})},m.id))}):n.jsx("p",{className:"text-gray-500",children:"Keine Stressfrei-Wechseln Adressen vorhanden."})]})}function cp({isOpen:e,onClose:t,customerId:s,email:r,customerEmail:a}){const[i,l]=w.useState(""),[o,c]=w.useState(""),[u,d]=w.useState(!1),[m,p]=w.useState(null),h=pe(),f=!!r,{data:g}=ge({queryKey:["email-provider-configs"],queryFn:()=>xn.getConfigs(),enabled:e&&!f}),b=((g==null?void 0:g.data)||[]).some(D=>D.isActive&&D.isDefault),y=D=>{if(!D)return"";const F=D.indexOf("@");return F>0?D.substring(0,F):D};w.useEffect(()=>{e&&(r?(l(y(r.email)),c(r.notes||"")):(l(""),c(""),d(!1)),p(null))},[e,r]);const v=Y({mutationFn:async D=>{var F,S,L;if(D.provision&&a){const T=await xn.provisionEmail(i,a);if(!((F=T.data)!=null&&F.success))throw new Error(((S=T.data)==null?void 0:S.error)||((L=T.data)==null?void 0:L.message)||"Provisionierung fehlgeschlagen")}return xo.create(s,{email:D.email,notes:D.notes})},onSuccess:()=>{h.invalidateQueries({queryKey:["customer",s.toString()]}),l(""),c(""),d(!1),t()},onError:D=>{p(D instanceof Error?D.message:"Fehler bei der Provisionierung")}}),x=Y({mutationFn:D=>xo.update(r.id,D),onSuccess:()=>{h.invalidateQueries({queryKey:["customer",s.toString()]}),t()}}),N=D=>{D.preventDefault(),p(null);const F=i+Tc;f?x.mutate({email:F,notes:o||void 0}):v.mutate({email:F,notes:o||void 0,provision:u})},k=v.isPending||x.isPending;return n.jsx(dt,{isOpen:e,onClose:t,title:f?"Adresse bearbeiten":"Adresse hinzufügen",children:n.jsxs("form",{onSubmit:N,className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"E-Mail-Adresse"}),n.jsxs("div",{className:"flex",children:[n.jsx("input",{type:"text",value:i,onChange:D=>l(D.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"}),n.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:Tc})]}),n.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Vollständige Adresse: ",n.jsxs("span",{className:"font-mono",children:[i||"...",Tc]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Notizen (optional)"}),n.jsx("textarea",{value:o,onChange:D=>c(D.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..."})]}),!f&&b&&a&&n.jsx("div",{className:"bg-blue-50 p-3 rounded-lg",children:n.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:u,onChange:D=>d(D.target.checked),className:"mt-1 rounded border-gray-300"}),n.jsxs("div",{children:[n.jsx("span",{className:"text-sm font-medium text-gray-700",children:"Beim E-Mail-Provider anlegen"}),n.jsxs("p",{className:"text-xs text-gray-500 mt-1",children:["Die E-Mail-Weiterleitung wird automatisch auf dem konfigurierten Server erstellt. Weiterleitungsziel: ",a]})]})]})}),m&&n.jsx("div",{className:"bg-red-50 p-3 rounded-lg text-red-700 text-sm",children:m}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:k||!i,children:k?"Speichern...":"Speichern"})]})]})})}var Zi=e=>e.type==="checkbox",nr=e=>e instanceof Date,Vt=e=>e==null;const rv=e=>typeof e=="object";var at=e=>!Vt(e)&&!Array.isArray(e)&&rv(e)&&!nr(e),J1=e=>at(e)&&e.target?Zi(e.target)?e.target.checked:e.target.value:e,X1=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,eS=(e,t)=>e.has(X1(t)),tS=e=>{const t=e.constructor&&e.constructor.prototype;return at(t)&&t.hasOwnProperty("isPrototypeOf")},fh=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function lt(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(fh&&(e instanceof Blob||t))return e;const s=Array.isArray(e);if(!s&&!(at(e)&&tS(e)))return e;const r=s?[]:Object.create(Object.getPrototypeOf(e));for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=lt(e[a]));return r}var Go=e=>/^\w*$/.test(e),Ke=e=>e===void 0,ph=e=>Array.isArray(e)?e.filter(Boolean):[],gh=e=>ph(e.replace(/["|']|\]/g,"").split(/\.|\[/)),le=(e,t,s)=>{if(!t||!at(e))return s;const r=(Go(t)?[t]:gh(t)).reduce((a,i)=>Vt(a)?a:a[i],e);return Ke(r)||r===e?Ke(e[t])?s:e[t]:r},Fs=e=>typeof e=="boolean",ws=e=>typeof e=="function",Ue=(e,t,s)=>{let r=-1;const a=Go(t)?[t]:gh(t),i=a.length,l=i-1;for(;++r<i;){const o=a[r];let c=s;if(r!==l){const u=e[o];c=at(u)||Array.isArray(u)?u:isNaN(+a[r+1])?{}:[]}if(o==="__proto__"||o==="constructor"||o==="prototype")return;e[o]=c,e=e[o]}};const up={BLUR:"blur",FOCUS_OUT:"focusout"},Ss={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},Ks={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},sS=Nt.createContext(null);sS.displayName="HookFormControlContext";var nS=(e,t,s,r=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const l=i;return t._proxyFormState[l]!==Ss.all&&(t._proxyFormState[l]=!r||Ss.all),e[l]}});return a};const rS=typeof window<"u"?Nt.useLayoutEffect:Nt.useEffect;var ts=e=>typeof e=="string",aS=(e,t,s,r,a)=>ts(e)?(r&&t.watch.add(e),le(s,e,a)):Array.isArray(e)?e.map(i=>(r&&t.watch.add(i),le(s,i))):(r&&(t.watchAll=!0),s),ed=e=>Vt(e)||!rv(e);function jn(e,t,s=new WeakSet){if(ed(e)||ed(t))return Object.is(e,t);if(nr(e)&&nr(t))return Object.is(e.getTime(),t.getTime());const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;if(s.has(e)||s.has(t))return!0;s.add(e),s.add(t);for(const i of r){const l=e[i];if(!a.includes(i))return!1;if(i!=="ref"){const o=t[i];if(nr(l)&&nr(o)||at(l)&&at(o)||Array.isArray(l)&&Array.isArray(o)?!jn(l,o,s):!Object.is(l,o))return!1}}return!0}const iS=Nt.createContext(null);iS.displayName="HookFormContext";var lS=(e,t,s,r,a)=>t?{...s[e],types:{...s[e]&&s[e].types?s[e].types:{},[r]:a||!0}}:{},li=e=>Array.isArray(e)?e:[e],dp=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}};function av(e,t){const s={};for(const r in e)if(e.hasOwnProperty(r)){const a=e[r],i=t[r];if(a&&at(a)&&i){const l=av(a,i);at(l)&&(s[r]=l)}else e[r]&&(s[r]=i)}return s}var Mt=e=>at(e)&&!Object.keys(e).length,xh=e=>e.type==="file",yo=e=>{if(!fh)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},iv=e=>e.type==="select-multiple",yh=e=>e.type==="radio",oS=e=>yh(e)||Zi(e),Fc=e=>yo(e)&&e.isConnected;function cS(e,t){const s=t.slice(0,-1).length;let r=0;for(;r<s;)e=Ke(e)?r++:e[t[r++]];return e}function uS(e){for(const t in e)if(e.hasOwnProperty(t)&&!Ke(e[t]))return!1;return!0}function nt(e,t){const s=Array.isArray(t)?t:Go(t)?[t]:gh(t),r=s.length===1?e:cS(e,s),a=s.length-1,i=s[a];return r&&delete r[i],a!==0&&(at(r)&&Mt(r)||Array.isArray(r)&&uS(r))&&nt(e,s.slice(0,-1)),e}var dS=e=>{for(const t in e)if(ws(e[t]))return!0;return!1};function lv(e){return Array.isArray(e)||at(e)&&!dS(e)}function td(e,t={}){for(const s in e){const r=e[s];lv(r)?(t[s]=Array.isArray(r)?[]:{},td(r,t[s])):Ke(r)||(t[s]=!0)}return t}function Ir(e,t,s){s||(s=td(t));for(const r in e){const a=e[r];if(lv(a))Ke(t)||ed(s[r])?s[r]=td(a,Array.isArray(a)?[]:{}):Ir(a,Vt(t)?{}:t[r],s[r]);else{const i=t[r];s[r]=!jn(a,i)}}return s}const hp={value:!1,isValid:!1},mp={value:!0,isValid:!0};var ov=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(s=>s&&s.checked&&!s.disabled).map(s=>s.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Ke(e[0].attributes.value)?Ke(e[0].value)||e[0].value===""?mp:{value:e[0].value,isValid:!0}:mp:hp}return hp},cv=(e,{valueAsNumber:t,valueAsDate:s,setValueAs:r})=>Ke(e)?e:t?e===""?NaN:e&&+e:s&&ts(e)?new Date(e):r?r(e):e;const fp={isValid:!1,value:null};var uv=e=>Array.isArray(e)?e.reduce((t,s)=>s&&s.checked&&!s.disabled?{isValid:!0,value:s.value}:t,fp):fp;function pp(e){const t=e.ref;return xh(t)?t.files:yh(t)?uv(e.refs).value:iv(t)?[...t.selectedOptions].map(({value:s})=>s):Zi(t)?ov(e.refs).value:cv(Ke(t.value)?e.ref.value:t.value,e)}var hS=(e,t,s,r)=>{const a={};for(const i of e){const l=le(t,i);l&&Ue(a,i,l._f)}return{criteriaMode:s,names:[...e],fields:a,shouldUseNativeValidation:r}},vo=e=>e instanceof RegExp,Va=e=>Ke(e)?e:vo(e)?e.source:at(e)?vo(e.value)?e.value.source:e.value:e,gp=e=>({isOnSubmit:!e||e===Ss.onSubmit,isOnBlur:e===Ss.onBlur,isOnChange:e===Ss.onChange,isOnAll:e===Ss.all,isOnTouch:e===Ss.onTouched});const xp="AsyncFunction";var mS=e=>!!e&&!!e.validate&&!!(ws(e.validate)&&e.validate.constructor.name===xp||at(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===xp)),fS=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),yp=(e,t,s)=>!s&&(t.watchAll||t.watch.has(e)||[...t.watch].some(r=>e.startsWith(r)&&/^\.\w+/.test(e.slice(r.length))));const oi=(e,t,s,r)=>{for(const a of s||Object.keys(e)){const i=le(e,a);if(i){const{_f:l,...o}=i;if(l){if(l.refs&&l.refs[0]&&t(l.refs[0],a)&&!r)return!0;if(l.ref&&t(l.ref,l.name)&&!r)return!0;if(oi(o,t))break}else if(at(o)&&oi(o,t))break}}};function vp(e,t,s){const r=le(e,s);if(r||Go(s))return{error:r,name:s};const a=s.split(".");for(;a.length;){const i=a.join("."),l=le(t,i),o=le(e,i);if(l&&!Array.isArray(l)&&s!==i)return{name:s};if(o&&o.type)return{name:i,error:o};if(o&&o.root&&o.root.type)return{name:`${i}.root`,error:o.root};a.pop()}return{name:s}}var pS=(e,t,s,r)=>{s(e);const{name:a,...i}=e;return Mt(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(l=>t[l]===(!r||Ss.all))},gS=(e,t,s)=>!e||!t||e===t||li(e).some(r=>r&&(s?r===t:r.startsWith(t)||t.startsWith(r))),xS=(e,t,s,r,a)=>a.isOnAll?!1:!s&&a.isOnTouch?!(t||e):(s?r.isOnBlur:a.isOnBlur)?!e:(s?r.isOnChange:a.isOnChange)?e:!0,yS=(e,t)=>!ph(le(e,t)).length&&nt(e,t),vS=(e,t,s)=>{const r=li(le(e,s));return Ue(r,"root",t[s]),Ue(e,s,r),e};function jp(e,t,s="validate"){if(ts(e)||Array.isArray(e)&&e.every(ts)||Fs(e)&&!e)return{type:s,message:ts(e)?e:"",ref:t}}var Fr=e=>at(e)&&!vo(e)?e:{value:e,message:""},bp=async(e,t,s,r,a,i)=>{const{ref:l,refs:o,required:c,maxLength:u,minLength:d,min:m,max:p,pattern:h,validate:f,name:g,valueAsNumber:b,mount:y}=e._f,v=le(s,g);if(!y||t.has(g))return{};const x=o?o[0]:l,N=K=>{a&&x.reportValidity&&(x.setCustomValidity(Fs(K)?"":K||""),x.reportValidity())},k={},D=yh(l),F=Zi(l),S=D||F,L=(b||xh(l))&&Ke(l.value)&&Ke(v)||yo(l)&&l.value===""||v===""||Array.isArray(v)&&!v.length,T=lS.bind(null,g,r,k),_=(K,W,Q,z=Ks.maxLength,P=Ks.minLength)=>{const j=K?W:Q;k[g]={type:K?z:P,message:j,ref:l,...T(K?z:P,j)}};if(i?!Array.isArray(v)||!v.length:c&&(!S&&(L||Vt(v))||Fs(v)&&!v||F&&!ov(o).isValid||D&&!uv(o).isValid)){const{value:K,message:W}=ts(c)?{value:!!c,message:c}:Fr(c);if(K&&(k[g]={type:Ks.required,message:W,ref:x,...T(Ks.required,W)},!r))return N(W),k}if(!L&&(!Vt(m)||!Vt(p))){let K,W;const Q=Fr(p),z=Fr(m);if(!Vt(v)&&!isNaN(v)){const P=l.valueAsNumber||v&&+v;Vt(Q.value)||(K=P>Q.value),Vt(z.value)||(W=P<z.value)}else{const P=l.valueAsDate||new Date(v),j=ee=>new Date(new Date().toDateString()+" "+ee),B=l.type=="time",J=l.type=="week";ts(Q.value)&&v&&(K=B?j(v)>j(Q.value):J?v>Q.value:P>new Date(Q.value)),ts(z.value)&&v&&(W=B?j(v)<j(z.value):J?v<z.value:P<new Date(z.value))}if((K||W)&&(_(!!K,Q.message,z.message,Ks.max,Ks.min),!r))return N(k[g].message),k}if((u||d)&&!L&&(ts(v)||i&&Array.isArray(v))){const K=Fr(u),W=Fr(d),Q=!Vt(K.value)&&v.length>+K.value,z=!Vt(W.value)&&v.length<+W.value;if((Q||z)&&(_(Q,K.message,W.message),!r))return N(k[g].message),k}if(h&&!L&&ts(v)){const{value:K,message:W}=Fr(h);if(vo(K)&&!v.match(K)&&(k[g]={type:Ks.pattern,message:W,ref:l,...T(Ks.pattern,W)},!r))return N(W),k}if(f){if(ws(f)){const K=await f(v,s),W=jp(K,x);if(W&&(k[g]={...W,...T(Ks.validate,W.message)},!r))return N(W.message),k}else if(at(f)){let K={};for(const W in f){if(!Mt(K)&&!r)break;const Q=jp(await f[W](v,s),x,W);Q&&(K={...Q,...T(W,Q.message)},N(Q.message),r&&(k[g]=K))}if(!Mt(K)&&(k[g]={ref:x,...K},!r))return k}}return N(!0),k};const jS={mode:Ss.onSubmit,reValidateMode:Ss.onChange,shouldFocusError:!0};function bS(e={}){let t={...jS,...e},s={submitCount:0,isDirty:!1,isReady:!1,isLoading:ws(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},r={},a=at(t.defaultValues)||at(t.values)?lt(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:lt(a),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,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},m={...d};let p={...m};const h={array:dp(),state:dp()},f=t.criteriaMode===Ss.all,g=E=>M=>{clearTimeout(u),u=setTimeout(E,M)},b=async E=>{if(!l.keepIsValid&&!t.disabled&&(m.isValid||p.isValid||E)){let M;t.resolver?(M=Mt((await S()).errors),y()):M=await T(r,!0),M!==s.isValid&&h.state.next({isValid:M})}},y=(E,M)=>{!t.disabled&&(m.isValidating||m.validatingFields||p.isValidating||p.validatingFields)&&((E||Array.from(o.mount)).forEach(U=>{U&&(M?Ue(s.validatingFields,U,M):nt(s.validatingFields,U))}),h.state.next({validatingFields:s.validatingFields,isValidating:!Mt(s.validatingFields)}))},v=(E,M=[],U,se,G=!0,H=!0)=>{if(se&&U&&!t.disabled){if(l.action=!0,H&&Array.isArray(le(r,E))){const ce=U(le(r,E),se.argA,se.argB);G&&Ue(r,E,ce)}if(H&&Array.isArray(le(s.errors,E))){const ce=U(le(s.errors,E),se.argA,se.argB);G&&Ue(s.errors,E,ce),yS(s.errors,E)}if((m.touchedFields||p.touchedFields)&&H&&Array.isArray(le(s.touchedFields,E))){const ce=U(le(s.touchedFields,E),se.argA,se.argB);G&&Ue(s.touchedFields,E,ce)}(m.dirtyFields||p.dirtyFields)&&(s.dirtyFields=Ir(a,i)),h.state.next({name:E,isDirty:K(E,M),dirtyFields:s.dirtyFields,errors:s.errors,isValid:s.isValid})}else Ue(i,E,M)},x=(E,M)=>{Ue(s.errors,E,M),h.state.next({errors:s.errors})},N=E=>{s.errors=E,h.state.next({errors:s.errors,isValid:!1})},k=(E,M,U,se)=>{const G=le(r,E);if(G){const H=le(i,E,Ke(U)?le(a,E):U);Ke(H)||se&&se.defaultChecked||M?Ue(i,E,M?H:pp(G._f)):z(E,H),l.mount&&!l.action&&b()}},D=(E,M,U,se,G)=>{let H=!1,ce=!1;const we={name:E};if(!t.disabled){if(!U||se){(m.isDirty||p.isDirty)&&(ce=s.isDirty,s.isDirty=we.isDirty=K(),H=ce!==we.isDirty);const Ae=jn(le(a,E),M);ce=!!le(s.dirtyFields,E),Ae?nt(s.dirtyFields,E):Ue(s.dirtyFields,E,!0),we.dirtyFields=s.dirtyFields,H=H||(m.dirtyFields||p.dirtyFields)&&ce!==!Ae}if(U){const Ae=le(s.touchedFields,E);Ae||(Ue(s.touchedFields,E,U),we.touchedFields=s.touchedFields,H=H||(m.touchedFields||p.touchedFields)&&Ae!==U)}H&&G&&h.state.next(we)}return H?we:{}},F=(E,M,U,se)=>{const G=le(s.errors,E),H=(m.isValid||p.isValid)&&Fs(M)&&s.isValid!==M;if(t.delayError&&U?(c=g(()=>x(E,U)),c(t.delayError)):(clearTimeout(u),c=null,U?Ue(s.errors,E,U):nt(s.errors,E)),(U?!jn(G,U):G)||!Mt(se)||H){const ce={...se,...H&&Fs(M)?{isValid:M}:{},errors:s.errors,name:E};s={...s,...ce},h.state.next(ce)}},S=async E=>(y(E,!0),await t.resolver(i,t.context,hS(E||o.mount,r,t.criteriaMode,t.shouldUseNativeValidation))),L=async E=>{const{errors:M}=await S(E);if(y(E),E)for(const U of E){const se=le(M,U);se?Ue(s.errors,U,se):nt(s.errors,U)}else s.errors=M;return M},T=async(E,M,U={valid:!0})=>{for(const se in E){const G=E[se];if(G){const{_f:H,...ce}=G;if(H){const we=o.array.has(H.name),Ae=G._f&&mS(G._f);Ae&&m.validatingFields&&y([H.name],!0);const ft=await bp(G,o.disabled,i,f,t.shouldUseNativeValidation&&!M,we);if(Ae&&m.validatingFields&&y([H.name]),ft[H.name]&&(U.valid=!1,M||e.shouldUseNativeValidation))break;!M&&(le(ft,H.name)?we?vS(s.errors,ft,H.name):Ue(s.errors,H.name,ft[H.name]):nt(s.errors,H.name))}!Mt(ce)&&await T(ce,M,U)}}return U.valid},_=()=>{for(const E of o.unMount){const M=le(r,E);M&&(M._f.refs?M._f.refs.every(U=>!Fc(U)):!Fc(M._f.ref))&&Tt(E)}o.unMount=new Set},K=(E,M)=>!t.disabled&&(E&&M&&Ue(i,E,M),!jn(me(),a)),W=(E,M,U)=>aS(E,o,{...l.mount?i:Ke(M)?a:ts(E)?{[E]:M}:M},U,M),Q=E=>ph(le(l.mount?i:a,E,t.shouldUnregister?le(a,E,[]):[])),z=(E,M,U={})=>{const se=le(r,E);let G=M;if(se){const H=se._f;H&&(!H.disabled&&Ue(i,E,cv(M,H)),G=yo(H.ref)&&Vt(M)?"":M,iv(H.ref)?[...H.ref.options].forEach(ce=>ce.selected=G.includes(ce.value)):H.refs?Zi(H.ref)?H.refs.forEach(ce=>{(!ce.defaultChecked||!ce.disabled)&&(Array.isArray(G)?ce.checked=!!G.find(we=>we===ce.value):ce.checked=G===ce.value||!!G)}):H.refs.forEach(ce=>ce.checked=ce.value===G):xh(H.ref)?H.ref.value="":(H.ref.value=G,H.ref.type||h.state.next({name:E,values:lt(i)})))}(U.shouldDirty||U.shouldTouch)&&D(E,G,U.shouldTouch,U.shouldDirty,!0),U.shouldValidate&&ee(E)},P=(E,M,U)=>{for(const se in M){if(!M.hasOwnProperty(se))return;const G=M[se],H=E+"."+se,ce=le(r,H);(o.array.has(E)||at(G)||ce&&!ce._f)&&!nr(G)?P(H,G,U):z(H,G,U)}},j=(E,M,U={})=>{const se=le(r,E),G=o.array.has(E),H=lt(M);Ue(i,E,H),G?(h.array.next({name:E,values:lt(i)}),(m.isDirty||m.dirtyFields||p.isDirty||p.dirtyFields)&&U.shouldDirty&&h.state.next({name:E,dirtyFields:Ir(a,i),isDirty:K(E,H)})):se&&!se._f&&!Vt(H)?P(E,H,U):z(E,H,U),yp(E,o)?h.state.next({...s,name:E,values:lt(i)}):h.state.next({name:l.mount?E:void 0,values:lt(i)})},B=async E=>{l.mount=!0;const M=E.target;let U=M.name,se=!0;const G=le(r,U),H=Ae=>{se=Number.isNaN(Ae)||nr(Ae)&&isNaN(Ae.getTime())||jn(Ae,le(i,U,Ae))},ce=gp(t.mode),we=gp(t.reValidateMode);if(G){let Ae,ft;const Bs=M.type?pp(G._f):J1(E),gs=E.type===up.BLUR||E.type===up.FOCUS_OUT,Ji=!fS(G._f)&&!t.resolver&&!le(s.errors,U)&&!G._f.deps||xS(gs,le(s.touchedFields,U),s.isSubmitted,we,ce),Pr=yp(U,o,gs);Ue(i,U,Bs),gs?(!M||!M.readOnly)&&(G._f.onBlur&&G._f.onBlur(E),c&&c(0)):G._f.onChange&&G._f.onChange(E);const Ar=D(U,Bs,gs),Xi=!Mt(Ar)||Pr;if(!gs&&h.state.next({name:U,type:E.type,values:lt(i)}),Ji)return(m.isValid||p.isValid)&&(t.mode==="onBlur"?gs&&b():gs||b()),Xi&&h.state.next({name:U,...Pr?{}:Ar});if(!gs&&Pr&&h.state.next({...s}),t.resolver){const{errors:Fa}=await S([U]);if(y([U]),H(Bs),se){const el=vp(s.errors,r,U),Ia=vp(Fa,r,el.name||U);Ae=Ia.error,U=Ia.name,ft=Mt(Fa)}}else y([U],!0),Ae=(await bp(G,o.disabled,i,f,t.shouldUseNativeValidation))[U],y([U]),H(Bs),se&&(Ae?ft=!1:(m.isValid||p.isValid)&&(ft=await T(r,!0)));se&&(G._f.deps&&(!Array.isArray(G._f.deps)||G._f.deps.length>0)&&ee(G._f.deps),F(U,ft,Ae,Ar))}},J=(E,M)=>{if(le(s.errors,M)&&E.focus)return E.focus(),1},ee=async(E,M={})=>{let U,se;const G=li(E);if(t.resolver){const H=await L(Ke(E)?E:G);U=Mt(H),se=E?!G.some(ce=>le(H,ce)):U}else E?(se=(await Promise.all(G.map(async H=>{const ce=le(r,H);return await T(ce&&ce._f?{[H]:ce}:ce)}))).every(Boolean),!(!se&&!s.isValid)&&b()):se=U=await T(r);return h.state.next({...!ts(E)||(m.isValid||p.isValid)&&U!==s.isValid?{}:{name:E},...t.resolver||!E?{isValid:U}:{},errors:s.errors}),M.shouldFocus&&!se&&oi(r,J,E?G:o.mount),se},me=(E,M)=>{let U={...l.mount?i:a};return M&&(U=av(M.dirtyFields?s.dirtyFields:s.touchedFields,U)),Ke(E)?U:ts(E)?le(U,E):E.map(se=>le(U,se))},ve=(E,M)=>({invalid:!!le((M||s).errors,E),isDirty:!!le((M||s).dirtyFields,E),error:le((M||s).errors,E),isValidating:!!le(s.validatingFields,E),isTouched:!!le((M||s).touchedFields,E)}),it=E=>{E&&li(E).forEach(M=>nt(s.errors,M)),h.state.next({errors:E?s.errors:{}})},V=(E,M,U)=>{const se=(le(r,E,{_f:{}})._f||{}).ref,G=le(s.errors,E)||{},{ref:H,message:ce,type:we,...Ae}=G;Ue(s.errors,E,{...Ae,...M,ref:se}),h.state.next({name:E,errors:s.errors,isValid:!1}),U&&U.shouldFocus&&se&&se.focus&&se.focus()},Ce=(E,M)=>ws(E)?h.state.subscribe({next:U=>"values"in U&&E(W(void 0,M),U)}):W(E,M,!0),Me=E=>h.state.subscribe({next:M=>{gS(E.name,M.name,E.exact)&&pS(M,E.formState||m,Yo,E.reRenderRoot)&&E.callback({values:{...i},...s,...M,defaultValues:a})}}).unsubscribe,ht=E=>(l.mount=!0,p={...p,...E.formState},Me({...E,formState:{...d,...E.formState}})),Tt=(E,M={})=>{for(const U of E?li(E):o.mount)o.mount.delete(U),o.array.delete(U),M.keepValue||(nt(r,U),nt(i,U)),!M.keepError&&nt(s.errors,U),!M.keepDirty&&nt(s.dirtyFields,U),!M.keepTouched&&nt(s.touchedFields,U),!M.keepIsValidating&&nt(s.validatingFields,U),!t.shouldUnregister&&!M.keepDefaultValue&&nt(a,U);h.state.next({values:lt(i)}),h.state.next({...s,...M.keepDirty?{isDirty:K()}:{}}),!M.keepIsValid&&b()},Jt=({disabled:E,name:M})=>{if(Fs(E)&&l.mount||E||o.disabled.has(M)){const G=o.disabled.has(M)!==!!E;E?o.disabled.add(M):o.disabled.delete(M),G&&l.mount&&!l.action&&b()}},Pe=(E,M={})=>{let U=le(r,E);const se=Fs(M.disabled)||Fs(t.disabled);return Ue(r,E,{...U||{},_f:{...U&&U._f?U._f:{ref:{name:E}},name:E,mount:!0,...M}}),o.mount.add(E),U?Jt({disabled:Fs(M.disabled)?M.disabled:t.disabled,name:E}):k(E,!0,M.value),{...se?{disabled:M.disabled||t.disabled}:{},...t.progressive?{required:!!M.required,min:Va(M.min),max:Va(M.max),minLength:Va(M.minLength),maxLength:Va(M.maxLength),pattern:Va(M.pattern)}:{},name:E,onChange:B,onBlur:B,ref:G=>{if(G){Pe(E,M),U=le(r,E);const H=Ke(G.value)&&G.querySelectorAll&&G.querySelectorAll("input,select,textarea")[0]||G,ce=oS(H),we=U._f.refs||[];if(ce?we.find(Ae=>Ae===H):H===U._f.ref)return;Ue(r,E,{_f:{...U._f,...ce?{refs:[...we.filter(Fc),H,...Array.isArray(le(a,E))?[{}]:[]],ref:{type:H.type,name:E}}:{ref:H}}}),k(E,!1,void 0,H)}else U=le(r,E,{}),U._f&&(U._f.mount=!1),(t.shouldUnregister||M.shouldUnregister)&&!(eS(o.array,E)&&l.action)&&o.unMount.add(E)}}},Xt=()=>t.shouldFocusError&&oi(r,J,o.mount),Gn=E=>{Fs(E)&&(h.state.next({disabled:E}),oi(r,(M,U)=>{const se=le(r,U);se&&(M.disabled=se._f.disabled||E,Array.isArray(se._f.refs)&&se._f.refs.forEach(G=>{G.disabled=se._f.disabled||E}))},0,!1))},Er=(E,M)=>async U=>{let se;U&&(U.preventDefault&&U.preventDefault(),U.persist&&U.persist());let G=lt(i);if(h.state.next({isSubmitting:!0}),t.resolver){const{errors:H,values:ce}=await S();y(),s.errors=H,G=lt(ce)}else await T(r);if(o.disabled.size)for(const H of o.disabled)nt(G,H);if(nt(s.errors,"root"),Mt(s.errors)){h.state.next({errors:{}});try{await E(G,U)}catch(H){se=H}}else M&&await M({...s.errors},U),Xt(),setTimeout(Xt);if(h.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Mt(s.errors)&&!se,submitCount:s.submitCount+1,errors:s.errors}),se)throw se},hn=(E,M={})=>{le(r,E)&&(Ke(M.defaultValue)?j(E,lt(le(a,E))):(j(E,M.defaultValue),Ue(a,E,lt(M.defaultValue))),M.keepTouched||nt(s.touchedFields,E),M.keepDirty||(nt(s.dirtyFields,E),s.isDirty=M.defaultValue?K(E,lt(le(a,E))):K()),M.keepError||(nt(s.errors,E),m.isValid&&b()),h.state.next({...s}))},Dr=(E,M={})=>{const U=E?lt(E):a,se=lt(U),G=Mt(E),H=G?a:se;if(M.keepDefaultValues||(a=U),!M.keepValues){if(M.keepDirtyValues){const ce=new Set([...o.mount,...Object.keys(Ir(a,i))]);for(const we of Array.from(ce)){const Ae=le(s.dirtyFields,we),ft=le(i,we),Bs=le(H,we);Ae&&!Ke(ft)?Ue(H,we,ft):!Ae&&!Ke(Bs)&&j(we,Bs)}}else{if(fh&&Ke(E))for(const ce of o.mount){const we=le(r,ce);if(we&&we._f){const Ae=Array.isArray(we._f.refs)?we._f.refs[0]:we._f.ref;if(yo(Ae)){const ft=Ae.closest("form");if(ft){ft.reset();break}}}}if(M.keepFieldsRef)for(const ce of o.mount)j(ce,le(H,ce));else r={}}i=t.shouldUnregister?M.keepDefaultValues?lt(a):{}:lt(H),h.array.next({values:{...H}}),h.state.next({values:{...H}})}o={mount:M.keepDirtyValues?o.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!m.isValid||!!M.keepIsValid||!!M.keepDirtyValues||!t.shouldUnregister&&!Mt(H),l.watch=!!t.shouldUnregister,l.keepIsValid=!!M.keepIsValid,l.action=!1,M.keepErrors||(s.errors={}),h.state.next({submitCount:M.keepSubmitCount?s.submitCount:0,isDirty:G?!1:M.keepDirty?s.isDirty:!!(M.keepDefaultValues&&!jn(E,a)),isSubmitted:M.keepIsSubmitted?s.isSubmitted:!1,dirtyFields:G?{}:M.keepDirtyValues?M.keepDefaultValues&&i?Ir(a,i):s.dirtyFields:M.keepDefaultValues&&E?Ir(a,E):M.keepDirty?s.dirtyFields:{},touchedFields:M.keepTouched?s.touchedFields:{},errors:M.keepErrors?s.errors:{},isSubmitSuccessful:M.keepIsSubmitSuccessful?s.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:a})},mt=(E,M)=>Dr(ws(E)?E(i):E,{...t.resetOptions,...M}),Zo=(E,M={})=>{const U=le(r,E),se=U&&U._f;if(se){const G=se.refs?se.refs[0]:se.ref;G.focus&&setTimeout(()=>{G.focus(),M.shouldSelect&&ws(G.select)&&G.select()})}},Yo=E=>{s={...s,...E}},Yi={control:{register:Pe,unregister:Tt,getFieldState:ve,handleSubmit:Er,setError:V,_subscribe:Me,_runSchema:S,_updateIsValidating:y,_focusError:Xt,_getWatch:W,_getDirty:K,_setValid:b,_setFieldArray:v,_setDisabledField:Jt,_setErrors:N,_getFieldArray:Q,_reset:Dr,_resetDefaultValues:()=>ws(t.defaultValues)&&t.defaultValues().then(E=>{mt(E,t.resetOptions),h.state.next({isLoading:!1})}),_removeUnmounted:_,_disableForm:Gn,_subjects:h,_proxyFormState:m,get _fields(){return r},get _formValues(){return i},get _state(){return l},set _state(E){l=E},get _defaultValues(){return a},get _names(){return o},set _names(E){o=E},get _formState(){return s},get _options(){return t},set _options(E){t={...t,...E}}},subscribe:ht,trigger:ee,register:Pe,handleSubmit:Er,watch:Ce,setValue:j,getValues:me,reset:mt,resetField:hn,clearErrors:it,unregister:Tt,setError:V,setFocus:Zo,getFieldState:ve};return{...Yi,formControl:Yi}}function dv(e={}){const t=Nt.useRef(void 0),s=Nt.useRef(void 0),[r,a]=Nt.useState({isDirty:!1,isValidating:!1,isLoading:ws(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:ws(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!ws(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:l,...o}=bS(e);t.current={...o,formState:r}}const i=t.current.control;return i._options=e,rS(()=>{const l=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0});return a(o=>({...o,isReady:!0})),i._formState.isReady=!0,l},[i]),Nt.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),Nt.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),Nt.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),Nt.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),Nt.useEffect(()=>{if(i._proxyFormState.isDirty){const l=i._getDirty();l!==r.isDirty&&i._subjects.state.next({isDirty:l})}},[i,r.isDirty]),Nt.useEffect(()=>{var l;e.values&&!jn(e.values,s.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),!((l=i._options.resetOptions)===null||l===void 0)&&l.keepIsValid||i._setValid(),s.current=e.values,a(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),Nt.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=Nt.useMemo(()=>nS(r,i),[i,r]),t.current}function Np(){var y,v;const{id:e}=_o(),t=Ut(),s=pe(),r=!!e,{register:a,handleSubmit:i,reset:l,watch:o,setValue:c,formState:{errors:u}}=dv(),d=o("type"),{data:m}=ge({queryKey:["customer",e],queryFn:()=>yt.getById(parseInt(e)),enabled:r});w.useEffect(()=>{if(m!=null&&m.data){const x={...m.data};x.birthDate&&(x.birthDate=x.birthDate.split("T")[0]),x.foundingDate&&(x.foundingDate=x.foundingDate.split("T")[0]),l(x)}},[m,l]);const p=Y({mutationFn:yt.create,onSuccess:()=>{s.invalidateQueries({queryKey:["customers"]}),t("/customers")}}),h=Y({mutationFn:x=>yt.update(parseInt(e),x),onSuccess:()=>{s.invalidateQueries({queryKey:["customers"]}),s.invalidateQueries({queryKey:["customer",e]}),t(`/customers/${e}`)}}),f=x=>{const N={type:x.type,salutation:x.salutation||void 0,firstName:x.firstName,lastName:x.lastName,companyName:x.companyName||void 0,email:x.email||void 0,phone:x.phone||void 0,mobile:x.mobile||void 0,taxNumber:x.taxNumber||void 0,commercialRegisterNumber:x.commercialRegisterNumber||void 0,notes:x.notes||void 0,birthPlace:x.birthPlace||void 0};x.birthDate&&typeof x.birthDate=="string"&&x.birthDate.trim()!==""?N.birthDate=new Date(x.birthDate).toISOString():N.birthDate=null,x.foundingDate&&typeof x.foundingDate=="string"&&x.foundingDate.trim()!==""?N.foundingDate=new Date(x.foundingDate).toISOString():N.foundingDate=null,r?h.mutate(N):p.mutate(N)},g=p.isPending||h.isPending,b=p.error||h.error;return n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold mb-6",children:r?"Kunde bearbeiten":"Neuer Kunde"}),b&&n.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:b instanceof Error?b.message:"Ein Fehler ist aufgetreten"}),n.jsxs("form",{onSubmit:i(f),children:[n.jsx(Z,{className:"mb-6",title:"Stammdaten",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(Le,{label:"Kundentyp",...a("type"),options:[{value:"PRIVATE",label:"Privatkunde"},{value:"BUSINESS",label:"Geschäftskunde"}]}),n.jsx(Le,{label:"Anrede",...a("salutation"),options:[{value:"Herr",label:"Herr"},{value:"Frau",label:"Frau"},{value:"Divers",label:"Divers"}]}),n.jsx($,{label:"Vorname",...a("firstName",{required:"Vorname erforderlich"}),error:(y=u.firstName)==null?void 0:y.message}),n.jsx($,{label:"Nachname",...a("lastName",{required:"Nachname erforderlich"}),error:(v=u.lastName)==null?void 0:v.message}),d==="BUSINESS"&&n.jsxs(n.Fragment,{children:[n.jsx($,{label:"Firmenname",...a("companyName"),className:"md:col-span-2"}),n.jsx($,{label:"Gründungsdatum",type:"date",...a("foundingDate"),value:o("foundingDate")||"",onClear:()=>c("foundingDate","")})]}),d!=="BUSINESS"&&n.jsxs(n.Fragment,{children:[n.jsx($,{label:"Geburtsdatum",type:"date",...a("birthDate"),value:o("birthDate")||"",onClear:()=>c("birthDate","")}),n.jsx($,{label:"Geburtsort",...a("birthPlace")})]})]})}),n.jsx(Z,{className:"mb-6",title:"Kontaktdaten",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx($,{label:"E-Mail",type:"email",...a("email")}),n.jsx($,{label:"Telefon",...a("phone")}),n.jsx($,{label:"Mobil",...a("mobile")})]})}),d==="BUSINESS"&&n.jsxs(Z,{className:"mb-6",title:"Geschäftsdaten",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx($,{label:"Steuernummer",...a("taxNumber")}),n.jsx($,{label:"Handelsregisternummer",...a("commercialRegisterNumber"),placeholder:"z.B. HRB 12345"})]}),r&&n.jsx("p",{className:"mt-4 text-sm text-gray-500",children:"Dokumente (Gewerbeanmeldung, Handelsregisterauszug) können nach dem Speichern in der Kundendetailansicht hochgeladen werden."})]}),n.jsx(Z,{className:"mb-6",title:"Notizen",children:n.jsx("textarea",{...a("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..."})}),n.jsxs("div",{className:"flex justify-end gap-4",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:()=>t(-1),children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:g,children:g?"Speichern...":"Speichern"})]})]})]})}const Ic={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},Mc={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen"},wp={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default"};function NS(){const[e,t]=Uo(),s=Ut(),[r,a]=w.useState(e.get("search")||""),[i,l]=w.useState(e.get("type")||""),[o,c]=w.useState(e.get("status")||""),[u,d]=w.useState(parseInt(e.get("page")||"1",10)),{hasPermission:m,isCustomer:p,isCustomerPortal:h,user:f}=st(),g=pe();w.useEffect(()=>{const N=new URLSearchParams;r&&N.set("search",r),i&&N.set("type",i),o&&N.set("status",o),u>1&&N.set("page",u.toString()),t(N,{replace:!0})},[r,i,o,u,t]);const b=Y({mutationFn:$e.delete,onSuccess:()=>{g.invalidateQueries({queryKey:["contracts"]})}}),{data:y,isLoading:v}=ge({queryKey:["contracts",r,i,o,u,p?f==null?void 0:f.customerId:null],queryFn:()=>$e.getAll({search:r||void 0,type:i||void 0,status:o||void 0,page:u,limit:20,customerId:p?f==null?void 0:f.customerId:void 0})}),x=w.useMemo(()=>{if(!h||!(y!=null&&y.data))return null;const N={};for(const k of y.data){const D=k.customerId;if(!N[D]){const F=k.customer?k.customer.companyName||`${k.customer.firstName} ${k.customer.lastName}`:`Kunde ${D}`;N[D]={customerName:F,isOwn:D===(f==null?void 0:f.customerId),contracts:[]}}N[D].contracts.push(k)}return Object.values(N).sort((k,D)=>k.isOwn&&!D.isOwn?-1:!k.isOwn&&D.isOwn?1:k.customerName.localeCompare(D.customerName))},[y==null?void 0:y.data,h,f==null?void 0:f.customerId]);return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Verträge"}),m("contracts:create")&&!p&&n.jsx(Se,{to:"/contracts/new",children:n.jsxs(I,{children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Neuer Vertrag"]})})]}),n.jsx(Z,{className:"mb-6",children:n.jsxs("div",{className:"flex gap-4 flex-wrap",children:[n.jsx("div",{className:"flex-1 min-w-[200px]",children:n.jsx($,{placeholder:"Suchen...",value:r,onChange:N=>a(N.target.value)})}),n.jsx(Le,{value:i,onChange:N=>l(N.target.value),options:Object.entries(Ic).map(([N,k])=>({value:N,label:k})),className:"w-48"}),n.jsx(Le,{value:o,onChange:N=>c(N.target.value),options:Object.entries(Mc).map(([N,k])=>({value:N,label:k})),className:"w-48"}),n.jsx(I,{variant:"secondary",children:n.jsx(Wo,{className:"w-4 h-4"})})]})}),v?n.jsx(Z,{children:n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):y!=null&&y.data&&y.data.length>0?n.jsx(n.Fragment,{children:h&&x?n.jsx("div",{className:"space-y-6",children:x.map(N=>n.jsxs(Z,{children:[n.jsx("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:N.isOwn?n.jsxs(n.Fragment,{children:[n.jsx(hh,{className:"w-5 h-5 text-blue-600"}),n.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"Meine Verträge"}),n.jsx(he,{variant:"default",children:N.contracts.length})]}):n.jsxs(n.Fragment,{children:[n.jsx(Xr,{className:"w-5 h-5 text-purple-600"}),n.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Verträge von ",N.customerName]}),n.jsx(he,{variant:"default",children:N.contracts.length})]})}),n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b",children:[n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Vertragsnr."}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Anbieter / Tarif"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beginn"}),n.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),n.jsx("tbody",{children:N.contracts.map(k=>n.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[n.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:k.contractNumber}),n.jsx("td",{className:"py-3 px-4",children:n.jsx(he,{children:Ic[k.type]})}),n.jsxs("td",{className:"py-3 px-4",children:[k.providerName||"-",k.tariffName&&n.jsxs("span",{className:"text-gray-500",children:[" / ",k.tariffName]})]}),n.jsx("td",{className:"py-3 px-4",children:n.jsx(he,{variant:wp[k.status],children:Mc[k.status]})}),n.jsx("td",{className:"py-3 px-4",children:k.startDate?new Date(k.startDate).toLocaleDateString("de-DE"):"-"}),n.jsx("td",{className:"py-3 px-4 text-right",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>s(`/contracts/${k.id}`,{state:{from:"contracts"}}),children:n.jsx(Ee,{className:"w-4 h-4"})})})]},k.id))})]})})]},N.isOwn?"own":N.customerName))}):n.jsxs(Z,{children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b",children:[n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Vertragsnr."}),!p&&n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kunde"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Typ"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Anbieter / Tarif"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beginn"}),n.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),n.jsx("tbody",{children:y.data.map(N=>n.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[n.jsx("td",{className:"py-3 px-4 font-mono text-sm",children:N.contractNumber}),!p&&n.jsx("td",{className:"py-3 px-4",children:N.customer&&n.jsx(Se,{to:`/customers/${N.customer.id}`,className:"text-blue-600 hover:underline",children:N.customer.companyName||`${N.customer.firstName} ${N.customer.lastName}`})}),n.jsx("td",{className:"py-3 px-4",children:n.jsx(he,{children:Ic[N.type]})}),n.jsxs("td",{className:"py-3 px-4",children:[N.providerName||"-",N.tariffName&&n.jsxs("span",{className:"text-gray-500",children:[" / ",N.tariffName]})]}),n.jsx("td",{className:"py-3 px-4",children:n.jsx(he,{variant:wp[N.status],children:Mc[N.status]})}),n.jsx("td",{className:"py-3 px-4",children:N.startDate?new Date(N.startDate).toLocaleDateString("de-DE"):"-"}),n.jsx("td",{className:"py-3 px-4 text-right",children:n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>s(`/contracts/${N.id}`,{state:{from:"contracts"}}),children:n.jsx(Ee,{className:"w-4 h-4"})}),m("contracts:update")&&!p&&n.jsx(Se,{to:`/contracts/${N.id}/edit`,children:n.jsx(I,{variant:"ghost",size:"sm",children:n.jsx(We,{className:"w-4 h-4"})})}),m("contracts:delete")&&!p&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertrag wirklich löschen?")&&b.mutate(N.id)},children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},N.id))})]})}),y.pagination&&y.pagination.totalPages>1&&n.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[n.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",y.pagination.page," von ",y.pagination.totalPages," (",y.pagination.total," Einträge)"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(I,{variant:"secondary",size:"sm",onClick:()=>d(N=>Math.max(1,N-1)),disabled:u===1,children:"Zurück"}),n.jsx(I,{variant:"secondary",size:"sm",onClick:()=>d(N=>N+1),disabled:u>=y.pagination.totalPages,children:"Weiter"})]})]})]})}):n.jsx(Z,{children:n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Verträge gefunden."})})]})}const wS={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabelinternet",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ-Versicherung"},SS={DRAFT:"Entwurf",PENDING:"Ausstehend",ACTIVE:"Aktiv",CANCELLED:"Gekündigt",EXPIRED:"Abgelaufen"},kS={ACTIVE:"success",PENDING:"warning",CANCELLED:"danger",EXPIRED:"danger",DRAFT:"default"};function CS(e){const t=e.match(/^(\d+)([TMWJ])$/);if(!t)return!1;const s=parseInt(t[1]),r=t[2];let a=0;return r==="T"?a=s:r==="W"?a=s*7:r==="M"?a=s*30:r==="J"&&(a=s*365),a<=30}function ES({simCard:e}){const[t,s]=w.useState(!1),[r,a]=w.useState(null),[i,l]=w.useState(!1),o=async()=>{if(t)s(!1),a(null);else{l(!0);try{const c=await $e.getSimCardCredentials(e.id);c.data&&(a(c.data),s(!0))}catch{alert("PIN/PUK konnte nicht geladen werden")}finally{l(!1)}}};return n.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg border",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.isMain&&n.jsx(he,{variant:"success",children:"Hauptkarte"}),e.isMultisim&&n.jsx(he,{variant:"warning",children:"Multisim"})]}),n.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[e.phoneNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"Rufnummer"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[e.phoneNumber,n.jsx(oe,{value:e.phoneNumber})]})]}),e.simCardNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"SIM-Nr."}),n.jsxs("dd",{className:"font-mono text-xs flex items-center gap-1",children:[e.simCardNumber,n.jsx(oe,{value:e.simCardNumber})]})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"PIN"}),n.jsx("dd",{className:"font-mono flex items-center gap-1",children:t&&(r!=null&&r.pin)?n.jsxs(n.Fragment,{children:[r.pin,n.jsx(oe,{value:r.pin})]}):"••••"})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"PUK"}),n.jsx("dd",{className:"font-mono flex items-center gap-1",children:t&&(r!=null&&r.puk)?n.jsxs(n.Fragment,{children:[r.puk,n.jsx(oe,{value:r.puk})]}):"••••••••"})]})]}),n.jsx("div",{className:"mt-2",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:o,disabled:i,children:i?"Laden...":t?n.jsxs(n.Fragment,{children:[n.jsx(Pt,{className:"w-4 h-4 mr-1"})," PIN/PUK verbergen"]}):n.jsxs(n.Fragment,{children:[n.jsx(Ee,{className:"w-4 h-4 mr-1"})," PIN/PUK anzeigen"]})})})]})}function DS({meterId:e,meterType:t,readings:s,contractId:r,canEdit:a}){const[i,l]=w.useState(!1),[o,c]=w.useState(!1),[u,d]=w.useState(null),m=pe(),p=Y({mutationFn:g=>zs.deleteReading(e,g),onSuccess:()=>{m.invalidateQueries({queryKey:["contract",r.toString()]})}}),h=[...s].sort((g,b)=>new Date(b.readingDate).getTime()-new Date(g.readingDate).getTime()),f=t==="ELECTRICITY"?"kWh":"m³";return n.jsxs("div",{className:"mt-4 pt-4 border-t",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Xy,{className:"w-4 h-4 text-gray-500"}),n.jsx("h4",{className:"text-sm font-medium text-gray-700",children:"Zählerstände"}),n.jsx(he,{variant:"default",children:s.length})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[a&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>c(!0),title:"Zählerstand erfassen",children:n.jsx(Oe,{className:"w-4 h-4"})}),s.length>0&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>l(!i),children:i?n.jsx(Wy,{className:"w-4 h-4"}):n.jsx(Qo,{className:"w-4 h-4"})})]})]}),i&&s.length>0&&n.jsx("div",{className:"space-y-2 bg-gray-50 rounded-lg p-3",children:h.map(g=>n.jsxs("div",{className:"flex justify-between items-center text-sm group py-1 border-b border-gray-200 last:border-0",children:[n.jsxs("span",{className:"text-gray-500 flex items-center gap-1",children:[new Date(g.readingDate).toLocaleDateString("de-DE"),n.jsx(oe,{value:new Date(g.readingDate).toLocaleDateString("de-DE")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("span",{className:"font-mono flex items-center gap-1",children:[g.value.toLocaleString("de-DE")," ",g.unit,n.jsx(oe,{value:g.value.toString(),title:"Nur Wert kopieren"})]}),a&&n.jsxs("div",{className:"opacity-0 group-hover:opacity-100 flex gap-1",children:[n.jsx("button",{onClick:()=>d(g),className:"text-gray-400 hover:text-blue-600",title:"Bearbeiten",children:n.jsx(We,{className:"w-3 h-3"})}),n.jsx("button",{onClick:()=>{confirm("Zählerstand wirklich löschen?")&&p.mutate(g.id)},className:"text-gray-400 hover:text-red-600",title:"Löschen",children:n.jsx(be,{className:"w-3 h-3"})})]})]})]},g.id))}),!i&&s.length>0&&n.jsxs("p",{className:"text-sm text-gray-500",children:["Letzter Stand: ",h[0].value.toLocaleString("de-DE")," ",h[0].unit," (",new Date(h[0].readingDate).toLocaleDateString("de-DE"),")"]}),s.length===0&&n.jsx("p",{className:"text-sm text-gray-500",children:"Keine Zählerstände vorhanden."}),(o||u)&&n.jsx(PS,{isOpen:!0,onClose:()=>{c(!1),d(null)},meterId:e,contractId:r,reading:u,defaultUnit:f})]})}function PS({isOpen:e,onClose:t,meterId:s,contractId:r,reading:a,defaultUnit:i}){var f;const l=pe(),o=!!a,[c,u]=w.useState({readingDate:a!=null&&a.readingDate?new Date(a.readingDate).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],value:((f=a==null?void 0:a.value)==null?void 0:f.toString())||"",unit:(a==null?void 0:a.unit)||i,notes:(a==null?void 0:a.notes)||""}),d=Y({mutationFn:g=>zs.addReading(s,g),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),m=Y({mutationFn:g=>zs.updateReading(s,a.id,g),onSuccess:()=>{l.invalidateQueries({queryKey:["contract",r.toString()]}),t()}}),p=g=>{g.preventDefault();const b={readingDate:new Date(c.readingDate),value:parseFloat(c.value),unit:c.unit,notes:c.notes||void 0};o?m.mutate(b):d.mutate(b)},h=d.isPending||m.isPending;return n.jsx(dt,{isOpen:e,onClose:t,title:o?"Zählerstand bearbeiten":"Zählerstand erfassen",children:n.jsxs("form",{onSubmit:p,className:"space-y-4",children:[n.jsx($,{label:"Ablesedatum",type:"date",value:c.readingDate,onChange:g=>u({...c,readingDate:g.target.value}),required:!0}),n.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[n.jsx("div",{className:"col-span-2",children:n.jsx($,{label:"Zählerstand",type:"number",step:"0.01",value:c.value,onChange:g=>u({...c,value:g.target.value}),required:!0})}),n.jsx(Le,{label:"Einheit",value:c.unit,onChange:g=>u({...c,unit:g.target.value}),options:[{value:"kWh",label:"kWh"},{value:"m³",label:"m³"}]})]}),n.jsx($,{label:"Notizen (optional)",value:c.notes,onChange:g=>u({...c,notes:g.target.value})}),n.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:h||!c.value,children:h?"Speichern...":o?"Speichern":"Erfassen"})]})]})})}function Sp({task:e,contractId:t,canEdit:s,isCustomerPortal:r,isCompleted:a,onEdit:i}){const[l,o]=w.useState(""),[c,u]=w.useState(!1),[d,m]=w.useState(null),[p,h]=w.useState(""),f=pe(),g=Y({mutationFn:j=>Xe.complete(j),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),b=Y({mutationFn:j=>Xe.reopen(j),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),y=Y({mutationFn:j=>Xe.delete(j),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),v=Y({mutationFn:j=>Xe.createSubtask(e.id,j),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),u(!1)},onError:j=>{console.error("Fehler beim Erstellen der Unteraufgabe:",j),alert("Fehler beim Erstellen der Unteraufgabe. Bitte versuchen Sie es erneut.")}}),x=Y({mutationFn:j=>Xe.createReply(e.id,j),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),o(""),u(!1)},onError:j=>{console.error("Fehler beim Erstellen der Antwort:",j),alert("Fehler beim Erstellen der Antwort. Bitte versuchen Sie es erneut.")}}),N=Y({mutationFn:({id:j,title:B})=>Xe.updateSubtask(j,B),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]}),m(null),h("")}}),k=Y({mutationFn:j=>Xe.completeSubtask(j),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),D=Y({mutationFn:j=>Xe.reopenSubtask(j),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),F=Y({mutationFn:j=>Xe.deleteSubtask(j),onSuccess:async()=>{await f.refetchQueries({queryKey:["contract-tasks",t]})}}),S=j=>{j.preventDefault(),l.trim()&&(r?x.mutate(l.trim()):v.mutate(l.trim()))},L=j=>{j.preventDefault(),p.trim()&&d&&N.mutate({id:d,title:p.trim()})},T=(j,B)=>{m(j),h(B)},_=()=>{m(null),h("")},K=e.subtasks||[],W=K.filter(j=>j.status==="OPEN"),Q=K.filter(j=>j.status==="COMPLETED"),z=r?{singular:"Antwort",placeholder:"Antwort...",deleteConfirm:"Antwort löschen?"}:{singular:"Unteraufgabe",placeholder:"Unteraufgabe...",deleteConfirm:"Unteraufgabe löschen?"},P=(j,B)=>d===j.id?n.jsx("div",{className:"py-1",children:n.jsxs("form",{onSubmit:L,className:"flex items-center gap-2",children:[n.jsx(_l,{className:"w-4 h-4 text-gray-300 flex-shrink-0"}),n.jsx("input",{type:"text",value:p,onChange:ee=>h(ee.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}),n.jsx(I,{type:"submit",size:"sm",disabled:!p.trim()||N.isPending,children:"✓"}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:_,children:"×"})]})},j.id):n.jsx("div",{className:`py-1 group/subtask ${B?"opacity-60":""}`,children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx("button",{onClick:()=>B?D.mutate(j.id):k.mutate(j.id),disabled:k.isPending||D.isPending||r,className:`flex-shrink-0 mt-0.5 ${r?"cursor-default":B?"hover:text-yellow-600":"hover:text-green-600"}`,children:B?n.jsx(hs,{className:"w-4 h-4 text-green-500"}):n.jsx(_l,{className:"w-4 h-4 text-gray-400"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx("span",{className:`text-sm ${B?"line-through text-gray-500":""}`,children:j.title}),s&&!r&&!B&&n.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover/subtask:opacity-100",children:[n.jsx("button",{onClick:()=>T(j.id,j.title),className:"text-gray-400 hover:text-blue-600 p-0.5",title:"Bearbeiten",children:n.jsx(We,{className:"w-3 h-3"})}),n.jsx("button",{onClick:()=>{confirm(z.deleteConfirm)&&F.mutate(j.id)},className:"text-gray-400 hover:text-red-600 p-0.5",title:"Löschen",children:n.jsx(be,{className:"w-3 h-3"})})]}),s&&!r&&B&&n.jsx("button",{onClick:()=>{confirm(z.deleteConfirm)&&F.mutate(j.id)},className:"text-gray-400 hover:text-red-600 p-0.5 opacity-0 group-hover/subtask:opacity-100",title:"Löschen",children:n.jsx(be,{className:"w-3 h-3"})})]}),n.jsxs("p",{className:"text-xs text-gray-400",children:[j.createdBy&&`${j.createdBy} `,B?`Erledigt am ${j.completedAt?new Date(j.completedAt).toLocaleDateString("de-DE"):new Date(j.updatedAt).toLocaleDateString("de-DE")}`:new Date(j.createdAt).toLocaleDateString("de-DE")]})]})]})},j.id);return n.jsx("div",{className:`p-3 bg-gray-50 rounded-lg group ${a?"bg-gray-50/50 opacity-70":""}`,children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("button",{onClick:()=>a?b.mutate(e.id):g.mutate(e.id),disabled:g.isPending||b.isPending||r,className:`mt-0.5 flex-shrink-0 ${r?"cursor-default":a?"hover:text-yellow-600":"hover:text-green-600"}`,title:r?void 0:a?"Wieder öffnen":"Als erledigt markieren",children:a?n.jsx(hs,{className:"w-5 h-5 text-green-500"}):n.jsx(_l,{className:"w-5 h-5 text-gray-400"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:`font-medium ${a?"line-through text-gray-500":""}`,children:e.title}),e.visibleInPortal&&n.jsx(he,{variant:"default",className:"text-xs",children:"Portal"}),K.length>0&&n.jsxs("span",{className:"text-xs text-gray-400",children:["(",Q.length,"/",K.length,")"]})]}),e.description&&n.jsx("p",{className:`text-sm mt-1 whitespace-pre-wrap ${a?"text-gray-500":"text-gray-600"}`,children:e.description}),n.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[e.createdBy&&`${e.createdBy} `,a?`Erledigt am ${e.completedAt?new Date(e.completedAt).toLocaleDateString("de-DE"):"-"}`:new Date(e.createdAt).toLocaleDateString("de-DE")]}),K.length>0&&n.jsxs("div",{className:"mt-3 ml-2 space-y-0 border-l-2 border-gray-200 pl-3",children:[W.map(j=>P(j,!1)),Q.map(j=>P(j,!0))]}),!a&&(s&&!r||r)&&n.jsx("div",{className:"mt-2 ml-2",children:c?n.jsxs("form",{onSubmit:S,className:"flex items-center gap-2",children:[n.jsx("input",{type:"text",value:l,onChange:j=>o(j.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}),n.jsx(I,{type:"submit",size:"sm",disabled:!l.trim()||v.isPending||x.isPending,children:n.jsx(Oe,{className:"w-3 h-3"})}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>{u(!1),o("")},children:"×"})]}):n.jsxs("button",{onClick:()=>u(!0),className:"text-xs text-gray-400 hover:text-blue-600 flex items-center gap-1",children:[n.jsx(Oe,{className:"w-3 h-3"}),z.singular]})})]}),s&&!r&&n.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100",children:[!a&&n.jsx("button",{onClick:i,className:"text-gray-400 hover:text-blue-600 p-1",title:"Bearbeiten",children:n.jsx(We,{className:"w-4 h-4"})}),n.jsx("button",{onClick:()=>{confirm("Aufgabe wirklich löschen?")&&y.mutate(e.id)},className:"text-gray-400 hover:text-red-600 p-1",title:"Löschen",children:n.jsx(be,{className:"w-4 h-4"})})]})]})})}function AS({contractId:e,canEdit:t,isCustomerPortal:s}){var x;const[r,a]=w.useState(!1),[i,l]=w.useState(null),{data:o,isLoading:c}=ge({queryKey:["contract-tasks",e],queryFn:()=>Xe.getByContract(e),staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:u,isLoading:d}=ge({queryKey:["app-settings-public"],queryFn:()=>Sr.getPublic(),enabled:s,staleTime:0}),m=!d&&((x=u==null?void 0:u.data)==null?void 0:x.customerSupportTicketsEnabled)==="true",p=(o==null?void 0:o.data)||[],h=p.filter(N=>N.status==="OPEN"),f=p.filter(N=>N.status==="COMPLETED"),g=s?{title:"Support-Anfragen",button:"Anfrage erstellen",empty:"Keine Support-Anfragen vorhanden."}:{title:"Aufgaben",button:"Aufgabe",empty:"Keine Aufgaben vorhanden."},b=s?Mi:Ii;if(c||s&&d)return n.jsx(Z,{className:"mb-6",title:g.title,children:n.jsx("div",{className:"text-center py-4 text-gray-500",children:"Laden..."})});const v=t&&!s||s&&m;return n.jsxs(Z,{className:"mb-6",title:g.title,children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(b,{className:"w-5 h-5 text-gray-500"}),n.jsxs("span",{className:"text-sm text-gray-600",children:[h.length," offen, ",f.length," erledigt"]})]}),v&&n.jsxs(I,{size:"sm",onClick:()=>a(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-1"}),g.button]})]}),p.length===0?n.jsx("p",{className:"text-center py-4 text-gray-500",children:g.empty}):n.jsxs("div",{className:"space-y-2",children:[h.map(N=>n.jsx(Sp,{task:N,contractId:e,canEdit:t,isCustomerPortal:s,isCompleted:!1,onEdit:()=>l(N)},N.id)),f.length>0&&h.length>0&&n.jsx("div",{className:"border-t my-3"}),f.map(N=>n.jsx(Sp,{task:N,contractId:e,canEdit:t,isCustomerPortal:s,isCompleted:!0,onEdit:()=>{}},N.id))]}),(r||i)&&n.jsx(TS,{isOpen:!0,onClose:()=>{a(!1),l(null)},contractId:e,task:i,isCustomerPortal:s})]})}function TS({isOpen:e,onClose:t,contractId:s,task:r,isCustomerPortal:a=!1}){const i=pe(),l=!!r,[o,c]=w.useState({title:(r==null?void 0:r.title)||"",description:(r==null?void 0:r.description)||"",visibleInPortal:(r==null?void 0:r.visibleInPortal)||!1});w.useEffect(()=>{e&&c({title:(r==null?void 0:r.title)||"",description:(r==null?void 0:r.description)||"",visibleInPortal:(r==null?void 0:r.visibleInPortal)||!1})},[e,r]);const u=Y({mutationFn:g=>Xe.create(s,g),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",s]}),t()}}),d=Y({mutationFn:g=>Xe.createSupportTicket(s,g),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",s]}),t()}}),m=Y({mutationFn:g=>Xe.update(r.id,g),onSuccess:async()=>{await i.refetchQueries({queryKey:["contract-tasks",s]}),t()}}),p=g=>{g.preventDefault(),l?m.mutate({title:o.title,description:o.description||void 0,visibleInPortal:o.visibleInPortal}):a?d.mutate({title:o.title,description:o.description||void 0}):u.mutate({title:o.title,description:o.description||void 0,visibleInPortal:o.visibleInPortal})},h=u.isPending||d.isPending||m.isPending,f=a?{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 n.jsx(dt,{isOpen:e,onClose:t,title:f.modalTitle,children:n.jsxs("form",{onSubmit:p,className:"space-y-4",children:[n.jsx($,{label:f.titleLabel,value:o.title,onChange:g=>c({...o,title:g.target.value}),required:!0,placeholder:f.titlePlaceholder}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:f.descLabel}),n.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:a?5:3,placeholder:f.descPlaceholder})]}),!a&&n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.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"}),n.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:h||!o.title.trim(),children:h?"Speichern...":f.submitBtn})]})]})})}function FS(){var B,J,ee,me,ve,it;const{id:e}=_o(),t=Ut(),r=dn().state,a=pe(),{hasPermission:i,isCustomer:l,isCustomerPortal:o}=st(),c=parseInt(e),[u,d]=w.useState(!1),[m,p]=w.useState(null),[h,f]=w.useState(!1),[g,b]=w.useState(!1),[y,v]=w.useState(null),[x,N]=w.useState({}),[k,D]=w.useState({}),{data:F,isLoading:S}=ge({queryKey:["contract",e],queryFn:()=>$e.getById(c)}),L=Y({mutationFn:()=>$e.delete(c),onSuccess:()=>{a.invalidateQueries({queryKey:["contracts"]}),t("/contracts")}}),T=Y({mutationFn:()=>$e.createFollowUp(c),onSuccess:V=>{a.invalidateQueries({queryKey:["contracts"]}),V.data&&t(`/contracts/${V.data.id}/edit`)}}),_=Y({mutationFn:V=>{const Me={cancellationConfirmationDate:V?new Date(V).toISOString():null};return $e.update(c,Me)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:V=>{console.error("Fehler beim Speichern des Datums:",V),alert("Fehler beim Speichern des Datums")}}),K=Y({mutationFn:V=>{const Me={cancellationConfirmationOptionsDate:V?new Date(V).toISOString():null};return $e.update(c,Me)},onSuccess:()=>{a.invalidateQueries({queryKey:["contract",e]}),a.invalidateQueries({queryKey:["contract-cockpit"]})},onError:V=>{console.error("Fehler beim Speichern des Datums:",V),alert("Fehler beim Speichern des Datums")}}),W=async()=>{var V;if(u)d(!1),p(null);else try{const Ce=await $e.getPassword(c);(V=Ce.data)!=null&&V.password&&(p(Ce.data.password),d(!0))}catch{alert("Passwort konnte nicht entschlüsselt werden")}},Q=async()=>{var V;if(g)b(!1),v(null);else try{const Ce=await $e.getInternetCredentials(c);(V=Ce.data)!=null&&V.password&&(v(Ce.data.password),b(!0))}catch{alert("Internet-Passwort konnte nicht entschlüsselt werden")}},z=async V=>{var Ce;if(x[V])N(Me=>({...Me,[V]:!1})),D(Me=>({...Me,[V]:null}));else try{const ht=(Ce=(await $e.getSipCredentials(V)).data)==null?void 0:Ce.password;ht&&(D(Tt=>({...Tt,[V]:ht})),N(Tt=>({...Tt,[V]:!0})))}catch{alert("SIP-Passwort konnte nicht entschlüsselt werden")}},P=async()=>{var Me,ht,Tt;const V=F==null?void 0:F.data,Ce=((Me=V==null?void 0:V.stressfreiEmail)==null?void 0:Me.email)||(V==null?void 0:V.portalUsername);if(!((ht=V==null?void 0:V.provider)!=null&&ht.portalUrl)||!Ce){alert("Portal-URL oder Benutzername fehlt");return}f(!0);try{const Jt=await $e.getPassword(c);if(!((Tt=Jt.data)!=null&&Tt.password)){alert("Passwort konnte nicht entschlüsselt werden");return}const Pe=V.provider,Xt=Pe.portalUrl,Gn=Pe.usernameFieldName||"username",Er=Pe.passwordFieldName||"password",hn=new URL(Xt);hn.searchParams.set(Gn,Ce),hn.searchParams.set(Er,Jt.data.password),window.open(hn.toString(),"_blank")}catch{alert("Fehler beim Auto-Login")}finally{f(!1)}};if(S)return n.jsx("div",{className:"text-center py-8",children:"Laden..."});if(!(F!=null&&F.data))return n.jsx("div",{className:"text-center py-8 text-red-600",children:"Vertrag nicht gefunden"});const j=F.data;return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{if((r==null?void 0:r.from)==="customer"&&(r!=null&&r.customerId))t(`/customers/${r.customerId}?tab=contracts`);else if((r==null?void 0:r.from)==="cockpit"){const V=r.filter?`?filter=${r.filter}`:"";t(`/contracts/cockpit${V}`)}else(r==null?void 0:r.from)==="contracts"?t("/contracts"):j.customer?t(`/customers/${j.customer.id}?tab=contracts`):t("/contracts")},children:n.jsx($s,{className:"w-4 h-4"})}),n.jsx("h1",{className:"text-2xl font-bold",children:j.contractNumber}),n.jsx(he,{children:wS[j.type]}),n.jsx(he,{variant:kS[j.status],children:SS[j.status]})]}),j.customer&&n.jsxs("p",{className:"text-gray-500 ml-10",children:["Kunde:"," ",n.jsx(Se,{to:`/customers/${j.customer.id}`,className:"text-blue-600 hover:underline",children:j.customer.companyName||`${j.customer.firstName} ${j.customer.lastName}`})]})]}),!l&&n.jsxs("div",{className:"flex gap-2",children:[i("contracts:create")&&n.jsxs(I,{variant:"secondary",onClick:()=>T.mutate(),disabled:T.isPending,children:[n.jsx(Gy,{className:"w-4 h-4 mr-2"}),"Folgevertrag"]}),i("contracts:update")&&n.jsx(Se,{to:`/contracts/${e}/edit`,children:n.jsxs(I,{variant:"secondary",children:[n.jsx(We,{className:"w-4 h-4 mr-2"}),"Bearbeiten"]})}),i("contracts:delete")&&n.jsxs(I,{variant:"danger",onClick:()=>{confirm("Vertrag wirklich löschen?")&&L.mutate()},children:[n.jsx(be,{className:"w-4 h-4 mr-2"}),"Löschen"]})]})]}),j.previousContract&&n.jsx(Z,{className:"mb-6 border-l-4 border-l-blue-500",title:"Vorgängervertrag",children:n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsnummer"}),n.jsx("dd",{children:n.jsx(Se,{to:`/contracts/${j.previousContract.id}`,className:"text-blue-600 hover:underline",children:j.previousContract.contractNumber})})]}),j.previousContract.providerName&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),n.jsx("dd",{children:j.previousContract.providerName})]}),j.previousContract.customerNumberAtProvider&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),n.jsx("dd",{className:"font-mono",children:j.previousContract.customerNumberAtProvider})]}),j.previousContract.portalUsername&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Zugangsdaten"}),n.jsx("dd",{children:j.previousContract.portalUsername})]})]})}),j.cancellationConfirmationDate&&n.jsxs("div",{className:"mb-6 p-4 bg-red-50 border-2 border-red-400 rounded-lg flex items-start gap-3",children:[n.jsx("span",{className:"text-red-600 text-xl font-bold",children:"!"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-semibold text-red-800",children:"Kündigungsbestätigung vorhanden"}),n.jsxs("p",{className:"text-sm text-red-700 mt-1",children:["Dieser Vertrag hat eine Kündigungsbestätigung vom"," ",n.jsx("strong",{children:new Date(j.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),".",j.cancellationConfirmationOptionsDate&&n.jsxs(n.Fragment,{children:[" Optionen-Bestätigung: ",n.jsx("strong",{children:new Date(j.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})}),"."]})]})]})]}),j.type==="MOBILE"&&((B=j.mobileDetails)==null?void 0:B.requiresMultisim)&&n.jsxs("div",{className:"mb-6 p-4 bg-amber-50 border border-amber-300 rounded-lg flex items-start gap-3",children:[n.jsx("span",{className:"text-amber-600 text-xl font-bold",children:"!"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-semibold text-amber-800",children:"Multisim erforderlich"}),n.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."})]})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6",children:[n.jsx(Z,{title:"Anbieter & Tarif",children:n.jsxs("dl",{className:"space-y-3",children:[(j.provider||j.providerName)&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Anbieter"}),n.jsx("dd",{className:"font-medium",children:((J=j.provider)==null?void 0:J.name)||j.providerName})]}),(j.tariff||j.tariffName)&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Tarif"}),n.jsx("dd",{children:((ee=j.tariff)==null?void 0:ee.name)||j.tariffName})]}),j.customerNumberAtProvider&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Kundennummer"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.customerNumberAtProvider,n.jsx(oe,{value:j.customerNumberAtProvider})]})]}),j.salesPlatform&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Vertriebsplattform"}),n.jsx("dd",{children:j.salesPlatform.name})]}),j.commission!==null&&j.commission!==void 0&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Provision"}),n.jsx("dd",{children:j.commission.toLocaleString("de-DE",{style:"currency",currency:"EUR"})})]}),j.priceFirst12Months&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Preis erste 12 Monate"}),n.jsx("dd",{children:j.priceFirst12Months})]}),j.priceFrom13Months&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Preis ab 13. Monat"}),n.jsx("dd",{children:j.priceFrom13Months})]}),j.priceAfter24Months&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Preis nach 24 Monaten"}),n.jsx("dd",{children:j.priceAfter24Months})]})]})}),n.jsxs(Z,{title:"Laufzeit und Kündigung",className:j.cancellationConfirmationDate?"border-2 border-red-400":"",children:[j.contractDuration&&CS(j.contractDuration.code)&&n.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[n.jsx("strong",{children:"Hinweis:"})," Dieser Vertrag gilt als unbefristet mit der jeweiligen Kündigungsfrist."]}),n.jsxs("dl",{className:"space-y-3",children:[j.startDate&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsbeginn"}),n.jsx("dd",{children:new Date(j.startDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),j.endDate&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragsende"}),n.jsx("dd",{children:new Date(j.endDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),j.contractDuration&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Vertragslaufzeit"}),n.jsx("dd",{children:j.contractDuration.description})]}),j.cancellationPeriod&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsfrist"}),n.jsx("dd",{children:j.cancellationPeriod.description})]}),j.cancellationConfirmationDate&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsdatum"}),n.jsx("dd",{children:new Date(j.cancellationConfirmationDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),j.cancellationConfirmationOptionsDate&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Kündigungsbestätigungsoptionendatum"}),n.jsx("dd",{children:new Date(j.cancellationConfirmationOptionsDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})]}),j.wasSpecialCancellation&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Sonderkündigung"}),n.jsx("dd",{children:n.jsx(he,{variant:"warning",children:"Ja"})})]})]}),i("contracts:update")&&n.jsxs("div",{className:"mt-6 pt-6 border-t",children:[n.jsx("h4",{className:"font-medium mb-4",children:"Kündigungsdokumente"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben"}),j.cancellationLetterPath?n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n.jsxs("a",{href:`/api${j.cancellationLetterPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(Ee,{className:"w-4 h-4"}),"Anzeigen"]}),n.jsxs("a",{href:`/api${j.cancellationLetterPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(tn,{className:"w-4 h-4"}),"Download"]}),n.jsx(xt,{onUpload:async V=>{await Ye.uploadCancellationLetter(c,V),a.invalidateQueries({queryKey:["contract",e]})},existingFile:j.cancellationLetterPath,accept:".pdf",label:"Ersetzen"}),n.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await Ye.deleteCancellationLetter(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]}):n.jsx(xt,{onUpload:async V=>{await Ye.uploadCancellationLetter(c,V),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung"}),j.cancellationConfirmationPath?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n.jsxs("a",{href:`/api${j.cancellationConfirmationPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(Ee,{className:"w-4 h-4"}),"Anzeigen"]}),n.jsxs("a",{href:`/api${j.cancellationConfirmationPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(tn,{className:"w-4 h-4"}),"Download"]}),n.jsx(xt,{onUpload:async V=>{await Ye.uploadCancellationConfirmation(c,V),a.invalidateQueries({queryKey:["contract",e]})},existingFile:j.cancellationConfirmationPath,accept:".pdf",label:"Ersetzen"}),n.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await Ye.deleteCancellationConfirmation(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]}),n.jsxs("div",{className:"mt-2",children:[n.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"date",value:j.cancellationConfirmationDate?j.cancellationConfirmationDate.split("T")[0]:"",onChange:V=>{const Ce=V.target.value||null;_.mutate(Ce)},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"}),j.cancellationConfirmationDate&&n.jsx("button",{onClick:()=>_.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:n.jsx(be,{className:"w-4 h-4"})})]})]})]}):n.jsx(xt,{onUpload:async V=>{await Ye.uploadCancellationConfirmation(c,V),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsschreiben Optionen"}),j.cancellationLetterOptionsPath?n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n.jsxs("a",{href:`/api${j.cancellationLetterOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(Ee,{className:"w-4 h-4"}),"Anzeigen"]}),n.jsxs("a",{href:`/api${j.cancellationLetterOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(tn,{className:"w-4 h-4"}),"Download"]}),n.jsx(xt,{onUpload:async V=>{await Ye.uploadCancellationLetterOptions(c,V),a.invalidateQueries({queryKey:["contract",e]})},existingFile:j.cancellationLetterOptionsPath,accept:".pdf",label:"Ersetzen"}),n.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await Ye.deleteCancellationLetterOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]}):n.jsx(xt,{onUpload:async V=>{await Ye.uploadCancellationLetterOptions(c,V),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500 mb-1",children:"Kündigungsbestätigung Optionen"}),j.cancellationConfirmationOptionsPath?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n.jsxs("a",{href:`/api${j.cancellationConfirmationOptionsPath}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(Ee,{className:"w-4 h-4"}),"Anzeigen"]}),n.jsxs("a",{href:`/api${j.cancellationConfirmationOptionsPath}`,download:!0,className:"text-blue-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(tn,{className:"w-4 h-4"}),"Download"]}),n.jsx(xt,{onUpload:async V=>{await Ye.uploadCancellationConfirmationOptions(c,V),a.invalidateQueries({queryKey:["contract",e]})},existingFile:j.cancellationConfirmationOptionsPath,accept:".pdf",label:"Ersetzen"}),n.jsxs("button",{onClick:async()=>{confirm("Dokument wirklich löschen?")&&(await Ye.deleteCancellationConfirmationOptions(c),a.invalidateQueries({queryKey:["contract",e]}))},className:"text-red-600 hover:underline text-sm flex items-center gap-1",children:[n.jsx(be,{className:"w-4 h-4"}),"Löschen"]})]}),n.jsxs("div",{className:"mt-2",children:[n.jsx("label",{className:"text-xs text-gray-500 block mb-1",children:"Bestätigung erhalten am"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"date",value:j.cancellationConfirmationOptionsDate?j.cancellationConfirmationOptionsDate.split("T")[0]:"",onChange:V=>{const Ce=V.target.value||null;K.mutate(Ce)},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"}),j.cancellationConfirmationOptionsDate&&n.jsx("button",{onClick:()=>K.mutate(null),className:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded",title:"Datum löschen",children:n.jsx(be,{className:"w-4 h-4"})})]})]})]}):n.jsx(xt,{onUpload:async V=>{await Ye.uploadCancellationConfirmationOptions(c,V),a.invalidateQueries({queryKey:["contract",e]})},accept:".pdf",label:"PDF hochladen"})]})]})]})]})]}),(j.portalUsername||j.stressfreiEmail||j.portalPasswordEncrypted)&&n.jsxs(Z,{className:"mb-6",title:"Zugangsdaten",children:[n.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[(j.portalUsername||j.stressfreiEmail)&&n.jsxs("div",{children:[n.jsxs("dt",{className:"text-sm text-gray-500",children:["Benutzername",j.stressfreiEmail&&n.jsx("span",{className:"ml-2 text-xs text-blue-600",children:"(Stressfrei-Wechseln)"})]}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[((me=j.stressfreiEmail)==null?void 0:me.email)||j.portalUsername,n.jsx(oe,{value:((ve=j.stressfreiEmail)==null?void 0:ve.email)||j.portalUsername||""})]})]}),j.portalPasswordEncrypted&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),n.jsxs("dd",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-mono",children:u&&m?m:"••••••••"}),u&&m&&n.jsx(oe,{value:m}),n.jsx(I,{variant:"ghost",size:"sm",onClick:W,children:u?n.jsx(Pt,{className:"w-4 h-4"}):n.jsx(Ee,{className:"w-4 h-4"})})]})]})]}),((it=j.provider)==null?void 0:it.portalUrl)&&(j.portalUsername||j.stressfreiEmail)&&j.portalPasswordEncrypted&&n.jsxs("div",{className:"mt-4 pt-4 border-t",children:[n.jsxs(I,{onClick:P,disabled:h,className:"w-full sm:w-auto",children:[n.jsx(Yy,{className:"w-4 h-4 mr-2"}),h?"Wird geöffnet...":"Zum Kundenportal (Auto-Login)"]}),n.jsx("p",{className:"text-xs text-gray-500 mt-2",children:"Öffnet das Portal mit vorausgefüllten Zugangsdaten"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6",children:[j.address&&n.jsx(Z,{title:"Adresse",children:n.jsxs(nv,{values:[`${j.address.street} ${j.address.houseNumber}`,`${j.address.postalCode} ${j.address.city}`,j.address.country],children:[n.jsxs("p",{children:[j.address.street," ",j.address.houseNumber]}),n.jsxs("p",{children:[j.address.postalCode," ",j.address.city]}),n.jsx("p",{className:"text-gray-500",children:j.address.country})]})}),j.bankCard&&n.jsxs(Z,{title:"Bankkarte",children:[n.jsx("p",{className:"font-medium",children:j.bankCard.accountHolder}),n.jsxs("p",{className:"font-mono flex items-center gap-1",children:[j.bankCard.iban,n.jsx(oe,{value:j.bankCard.iban})]}),j.bankCard.bankName&&n.jsx("p",{className:"text-gray-500",children:j.bankCard.bankName})]}),j.identityDocument&&n.jsxs(Z,{title:"Ausweis",children:[n.jsxs("p",{className:"font-mono flex items-center gap-1",children:[j.identityDocument.documentNumber,n.jsx(oe,{value:j.identityDocument.documentNumber})]}),n.jsx("p",{className:"text-gray-500",children:j.identityDocument.type})]})]}),j.energyDetails&&n.jsxs(Z,{className:"mb-6",title:j.type==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:[n.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[j.energyDetails.meter&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Zählernummer"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.energyDetails.meter.meterNumber,n.jsx(oe,{value:j.energyDetails.meter.meterNumber})]})]}),j.energyDetails.annualConsumption&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Jahresverbrauch"}),n.jsxs("dd",{children:[j.energyDetails.annualConsumption.toLocaleString("de-DE")," ",j.type==="ELECTRICITY"?"kWh":"m³"]})]}),j.energyDetails.basePrice&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Grundpreis"}),n.jsxs("dd",{children:[j.energyDetails.basePrice.toLocaleString("de-DE")," €/Monat"]})]}),j.energyDetails.unitPrice&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Arbeitspreis"}),n.jsxs("dd",{children:[j.energyDetails.unitPrice.toLocaleString("de-DE")," ct/",j.type==="ELECTRICITY"?"kWh":"m³"]})]}),j.energyDetails.bonus&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Bonus"}),n.jsxs("dd",{children:[j.energyDetails.bonus.toLocaleString("de-DE")," €"]})]}),j.energyDetails.previousProviderName&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversorger"}),n.jsx("dd",{children:j.energyDetails.previousProviderName})]}),j.energyDetails.previousCustomerNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Vorherige Kundennr."}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.energyDetails.previousCustomerNumber,n.jsx(oe,{value:j.energyDetails.previousCustomerNumber})]})]})]}),j.energyDetails.meter&&n.jsx(DS,{meterId:j.energyDetails.meter.id,meterType:j.energyDetails.meter.type,readings:j.energyDetails.meter.readings||[],contractId:c,canEdit:i("contracts:update")&&!l})]}),j.internetDetails&&n.jsxs(Z,{className:"mb-6",title:j.type==="DSL"?"DSL-Details":j.type==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:[n.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[j.internetDetails.downloadSpeed&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Download"}),n.jsxs("dd",{children:[j.internetDetails.downloadSpeed," Mbit/s"]})]}),j.internetDetails.uploadSpeed&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Upload"}),n.jsxs("dd",{children:[j.internetDetails.uploadSpeed," Mbit/s"]})]}),j.internetDetails.routerModel&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Router"}),n.jsx("dd",{children:j.internetDetails.routerModel})]}),j.internetDetails.routerSerialNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Router S/N"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.internetDetails.routerSerialNumber,n.jsx(oe,{value:j.internetDetails.routerSerialNumber})]})]}),j.internetDetails.installationDate&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Installation"}),n.jsx("dd",{children:new Date(j.internetDetails.installationDate).toLocaleDateString("de-DE")})]}),j.internetDetails.homeId&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Home-ID"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.internetDetails.homeId,n.jsx(oe,{value:j.internetDetails.homeId})]})]}),j.internetDetails.activationCode&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Aktivierungscode"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.internetDetails.activationCode,n.jsx(oe,{value:j.internetDetails.activationCode})]})]})]}),(j.internetDetails.internetUsername||j.internetDetails.internetPasswordEncrypted)&&n.jsxs("div",{className:"mt-4 pt-4 border-t",children:[n.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Internet-Zugangsdaten"}),n.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[j.internetDetails.internetUsername&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Benutzername"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.internetDetails.internetUsername,n.jsx(oe,{value:j.internetDetails.internetUsername})]})]}),j.internetDetails.internetPasswordEncrypted&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Passwort"}),n.jsxs("dd",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-mono",children:g&&y?y:"••••••••"}),g&&y&&n.jsx(oe,{value:y}),n.jsx(I,{variant:"ghost",size:"sm",onClick:Q,children:g?n.jsx(Pt,{className:"w-4 h-4"}):n.jsx(Ee,{className:"w-4 h-4"})})]})]})]})]}),j.internetDetails.phoneNumbers&&j.internetDetails.phoneNumbers.length>0&&n.jsxs("div",{className:"mt-4 pt-4 border-t",children:[n.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Rufnummern & SIP-Zugangsdaten"}),n.jsx("div",{className:"space-y-3",children:j.internetDetails.phoneNumbers.map(V=>n.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsxs("span",{className:"font-mono font-medium flex items-center gap-1",children:[V.phoneNumber,n.jsx(oe,{value:V.phoneNumber})]}),V.isMain&&n.jsx(he,{variant:"success",children:"Hauptnummer"})]}),(V.sipUsername||V.sipPasswordEncrypted||V.sipServer)&&n.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[V.sipUsername&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"SIP-Benutzer"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[V.sipUsername,n.jsx(oe,{value:V.sipUsername})]})]}),V.sipPasswordEncrypted&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"SIP-Passwort"}),n.jsxs("dd",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-mono",children:x[V.id]&&k[V.id]?k[V.id]:"••••••••"}),x[V.id]&&k[V.id]&&n.jsx(oe,{value:k[V.id]}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>z(V.id),children:x[V.id]?n.jsx(Pt,{className:"w-3 h-3"}):n.jsx(Ee,{className:"w-3 h-3"})})]})]}),V.sipServer&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"SIP-Server"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[V.sipServer,n.jsx(oe,{value:V.sipServer})]})]})]})]},V.id))})]})]}),j.mobileDetails&&n.jsxs(Z,{className:"mb-6",title:"Mobilfunk-Details",children:[n.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[j.mobileDetails.dataVolume&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Datenvolumen"}),n.jsxs("dd",{children:[j.mobileDetails.dataVolume," GB"]})]}),j.mobileDetails.includedMinutes&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-Minuten"}),n.jsx("dd",{children:j.mobileDetails.includedMinutes})]}),j.mobileDetails.includedSMS&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Inklusiv-SMS"}),n.jsx("dd",{children:j.mobileDetails.includedSMS})]}),j.mobileDetails.deviceModel&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Gerät"}),n.jsx("dd",{children:j.mobileDetails.deviceModel})]}),j.mobileDetails.deviceImei&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"IMEI"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.mobileDetails.deviceImei,n.jsx(oe,{value:j.mobileDetails.deviceImei})]})]}),j.mobileDetails.requiresMultisim&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Multisim"}),n.jsx("dd",{children:n.jsx(he,{variant:"warning",children:"Erforderlich"})})]})]}),j.mobileDetails.simCards&&j.mobileDetails.simCards.length>0&&n.jsxs("div",{className:"mt-6 pt-6 border-t",children:[n.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karten"}),n.jsx("div",{className:"space-y-3",children:j.mobileDetails.simCards.map(V=>n.jsx(ES,{simCard:V},V.id))})]}),(!j.mobileDetails.simCards||j.mobileDetails.simCards.length===0)&&(j.mobileDetails.phoneNumber||j.mobileDetails.simCardNumber)&&n.jsxs("div",{className:"mt-6 pt-6 border-t",children:[n.jsx("h4",{className:"font-medium mb-4",children:"SIM-Karte (Legacy)"}),n.jsxs("dl",{className:"grid grid-cols-2 gap-4",children:[j.mobileDetails.phoneNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Rufnummer"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.mobileDetails.phoneNumber,n.jsx(oe,{value:j.mobileDetails.phoneNumber})]})]}),j.mobileDetails.simCardNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"SIM-Kartennummer"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.mobileDetails.simCardNumber,n.jsx(oe,{value:j.mobileDetails.simCardNumber})]})]})]})]})]}),j.tvDetails&&n.jsx(Z,{className:"mb-6",title:"TV-Details",children:n.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[j.tvDetails.receiverModel&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Receiver"}),n.jsx("dd",{children:j.tvDetails.receiverModel})]}),j.tvDetails.smartcardNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Smartcard"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.tvDetails.smartcardNumber,n.jsx(oe,{value:j.tvDetails.smartcardNumber})]})]}),j.tvDetails.package&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Paket"}),n.jsx("dd",{children:j.tvDetails.package})]})]})}),j.carInsuranceDetails&&n.jsx(Z,{className:"mb-6",title:"KFZ-Versicherung Details",children:n.jsxs("dl",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[j.carInsuranceDetails.licensePlate&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Kennzeichen"}),n.jsxs("dd",{className:"font-mono font-bold flex items-center gap-1",children:[j.carInsuranceDetails.licensePlate,n.jsx(oe,{value:j.carInsuranceDetails.licensePlate})]})]}),j.carInsuranceDetails.vehicleType&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Fahrzeug"}),n.jsx("dd",{children:j.carInsuranceDetails.vehicleType})]}),j.carInsuranceDetails.hsn&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"HSN/TSN"}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.carInsuranceDetails.hsn,"/",j.carInsuranceDetails.tsn,n.jsx(oe,{value:`${j.carInsuranceDetails.hsn}/${j.carInsuranceDetails.tsn}`})]})]}),j.carInsuranceDetails.vin&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"FIN"}),n.jsxs("dd",{className:"font-mono text-sm flex items-center gap-1",children:[j.carInsuranceDetails.vin,n.jsx(oe,{value:j.carInsuranceDetails.vin})]})]}),j.carInsuranceDetails.firstRegistration&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Erstzulassung"}),n.jsx("dd",{children:new Date(j.carInsuranceDetails.firstRegistration).toLocaleDateString("de-DE")})]}),j.carInsuranceDetails.noClaimsClass&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"SF-Klasse"}),n.jsx("dd",{children:j.carInsuranceDetails.noClaimsClass})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsart"}),n.jsx("dd",{children:n.jsx(he,{variant:j.carInsuranceDetails.insuranceType==="FULL"?"success":j.carInsuranceDetails.insuranceType==="PARTIAL"?"warning":"default",children:j.carInsuranceDetails.insuranceType==="FULL"?"Vollkasko":j.carInsuranceDetails.insuranceType==="PARTIAL"?"Teilkasko":"Haftpflicht"})})]}),j.carInsuranceDetails.deductiblePartial&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"SB Teilkasko"}),n.jsxs("dd",{children:[j.carInsuranceDetails.deductiblePartial," €"]})]}),j.carInsuranceDetails.deductibleFull&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"SB Vollkasko"}),n.jsxs("dd",{children:[j.carInsuranceDetails.deductibleFull," €"]})]}),j.carInsuranceDetails.policyNumber&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Versicherungsschein-Nr."}),n.jsxs("dd",{className:"font-mono flex items-center gap-1",children:[j.carInsuranceDetails.policyNumber,n.jsx(oe,{value:j.carInsuranceDetails.policyNumber})]})]}),j.carInsuranceDetails.previousInsurer&&n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Vorversicherer"}),n.jsx("dd",{children:j.carInsuranceDetails.previousInsurer})]})]})}),n.jsx(AS,{contractId:c,canEdit:i("contracts:update"),isCustomerPortal:o}),j.notes&&n.jsx(Z,{title:"Notizen",children:n.jsx("p",{className:"whitespace-pre-wrap",children:j.notes})})]})}const IS=[{value:"DRAFT",label:"Entwurf"},{value:"PENDING",label:"Ausstehend"},{value:"ACTIVE",label:"Aktiv"},{value:"CANCELLED",label:"Gekündigt"},{value:"EXPIRED",label:"Abgelaufen"}];function kp(){var gs,Ji,Pr,Ar,Xi,Fa,el,Ia,jh;const{id:e}=_o(),[t]=Uo(),s=Ut(),r=pe(),a=!!e,i=t.get("customerId"),{register:l,handleSubmit:o,reset:c,watch:u,setValue:d,formState:{errors:m}}=dv({defaultValues:{customerId:i||"",type:"ELECTRICITY",status:"DRAFT"}}),p=u("type"),h=u("customerId"),{data:f}=ge({queryKey:["contract",e],queryFn:()=>$e.getById(parseInt(e)),enabled:a}),{data:g}=ge({queryKey:["customers-all"],queryFn:()=>yt.getAll({limit:1e3})}),{data:b}=ge({queryKey:["customer",h],queryFn:()=>yt.getById(parseInt(h)),enabled:!!h}),{data:y}=ge({queryKey:["platforms"],queryFn:()=>Pi.getAll()}),{data:v}=ge({queryKey:["cancellation-periods"],queryFn:()=>Ai.getAll()}),{data:x}=ge({queryKey:["contract-durations"],queryFn:()=>Ti.getAll()}),{data:N}=ge({queryKey:["providers"],queryFn:()=>Na.getAll()}),{data:k}=ge({queryKey:["contract-categories"],queryFn:()=>Fi.getAll()}),D=u("providerId"),[F,S]=w.useState(null),[L,T]=w.useState([]),[_,K]=w.useState([]),[W,Q]=w.useState(!1),[z,P]=w.useState("manual"),[j,B]=w.useState(""),[J,ee]=w.useState(!1),[me,ve]=w.useState(!1),[it,V]=w.useState({}),[Ce,Me]=w.useState({}),[ht,Tt]=w.useState({});w.useEffect(()=>{a||Q(!0)},[a]),w.useEffect(()=>{W&&F!==null&&D!==F&&d("tariffId",""),S(D)},[D,F,d,W]),w.useEffect(()=>{if(!a&&(k!=null&&k.data)&&k.data.length>0){const A=u("type"),ne=k.data.filter(ie=>ie.isActive),fe=ne.some(ie=>ie.code===A);if(!A||!fe){const ie=ne.sort((de,Ge)=>de.sortOrder-Ge.sortOrder)[0];ie&&d("type",ie.code)}}},[k,a,d,u]),w.useEffect(()=>{var A,ne,fe,ie,de,Ge,je,Ma,bh,Nh,wh,Sh,kh,Ch,Eh,Dh,Ph,Ah,Th,Fh,Ih,Mh,Lh,Rh,Oh,_h,zh,Uh,$h,Bh,Kh,Vh,qh,Qh,Hh,Wh,Gh,Zh,Yh,Jh,Xh,em,tm,sm,nm,rm,am,im,lm;if(f!=null&&f.data){const X=f.data;c({customerId:X.customerId.toString(),type:X.type,status:X.status,addressId:((A=X.addressId)==null?void 0:A.toString())||"",bankCardId:((ne=X.bankCardId)==null?void 0:ne.toString())||"",identityDocumentId:((fe=X.identityDocumentId)==null?void 0:fe.toString())||"",salesPlatformId:((ie=X.salesPlatformId)==null?void 0:ie.toString())||"",providerId:((de=X.providerId)==null?void 0:de.toString())||"",tariffId:((Ge=X.tariffId)==null?void 0:Ge.toString())||"",providerName:X.providerName||"",tariffName:X.tariffName||"",customerNumberAtProvider:X.customerNumberAtProvider||"",priceFirst12Months:X.priceFirst12Months||"",priceFrom13Months:X.priceFrom13Months||"",priceAfter24Months:X.priceAfter24Months||"",startDate:X.startDate?X.startDate.split("T")[0]:"",endDate:X.endDate?X.endDate.split("T")[0]:"",cancellationPeriodId:((je=X.cancellationPeriodId)==null?void 0:je.toString())||"",contractDurationId:((Ma=X.contractDurationId)==null?void 0:Ma.toString())||"",commission:X.commission||"",portalUsername:X.portalUsername||"",notes:X.notes||"",meterId:((Nh=(bh=X.energyDetails)==null?void 0:bh.meterId)==null?void 0:Nh.toString())||"",annualConsumption:((wh=X.energyDetails)==null?void 0:wh.annualConsumption)||"",basePrice:((Sh=X.energyDetails)==null?void 0:Sh.basePrice)||"",unitPrice:((kh=X.energyDetails)==null?void 0:kh.unitPrice)||"",bonus:((Ch=X.energyDetails)==null?void 0:Ch.bonus)||"",previousProviderName:((Eh=X.energyDetails)==null?void 0:Eh.previousProviderName)||"",previousCustomerNumber:((Dh=X.energyDetails)==null?void 0:Dh.previousCustomerNumber)||"",downloadSpeed:((Ph=X.internetDetails)==null?void 0:Ph.downloadSpeed)||"",uploadSpeed:((Ah=X.internetDetails)==null?void 0:Ah.uploadSpeed)||"",routerModel:((Th=X.internetDetails)==null?void 0:Th.routerModel)||"",routerSerialNumber:((Fh=X.internetDetails)==null?void 0:Fh.routerSerialNumber)||"",installationDate:(Ih=X.internetDetails)!=null&&Ih.installationDate?X.internetDetails.installationDate.split("T")[0]:"",internetUsername:((Mh=X.internetDetails)==null?void 0:Mh.internetUsername)||"",homeId:((Lh=X.internetDetails)==null?void 0:Lh.homeId)||"",activationCode:((Rh=X.internetDetails)==null?void 0:Rh.activationCode)||"",requiresMultisim:((Oh=X.mobileDetails)==null?void 0:Oh.requiresMultisim)||!1,dataVolume:((_h=X.mobileDetails)==null?void 0:_h.dataVolume)||"",includedMinutes:((zh=X.mobileDetails)==null?void 0:zh.includedMinutes)||"",includedSMS:((Uh=X.mobileDetails)==null?void 0:Uh.includedSMS)||"",deviceModel:(($h=X.mobileDetails)==null?void 0:$h.deviceModel)||"",deviceImei:((Bh=X.mobileDetails)==null?void 0:Bh.deviceImei)||"",phoneNumber:((Kh=X.mobileDetails)==null?void 0:Kh.phoneNumber)||"",simCardNumber:((Vh=X.mobileDetails)==null?void 0:Vh.simCardNumber)||"",receiverModel:((qh=X.tvDetails)==null?void 0:qh.receiverModel)||"",smartcardNumber:((Qh=X.tvDetails)==null?void 0:Qh.smartcardNumber)||"",tvPackage:((Hh=X.tvDetails)==null?void 0:Hh.package)||"",licensePlate:((Wh=X.carInsuranceDetails)==null?void 0:Wh.licensePlate)||"",hsn:((Gh=X.carInsuranceDetails)==null?void 0:Gh.hsn)||"",tsn:((Zh=X.carInsuranceDetails)==null?void 0:Zh.tsn)||"",vin:((Yh=X.carInsuranceDetails)==null?void 0:Yh.vin)||"",vehicleType:((Jh=X.carInsuranceDetails)==null?void 0:Jh.vehicleType)||"",firstRegistration:(Xh=X.carInsuranceDetails)!=null&&Xh.firstRegistration?X.carInsuranceDetails.firstRegistration.split("T")[0]:"",noClaimsClass:((em=X.carInsuranceDetails)==null?void 0:em.noClaimsClass)||"",insuranceType:((tm=X.carInsuranceDetails)==null?void 0:tm.insuranceType)||"LIABILITY",deductiblePartial:((sm=X.carInsuranceDetails)==null?void 0:sm.deductiblePartial)||"",deductibleFull:((nm=X.carInsuranceDetails)==null?void 0:nm.deductibleFull)||"",policyNumber:((rm=X.carInsuranceDetails)==null?void 0:rm.policyNumber)||"",previousInsurer:((am=X.carInsuranceDetails)==null?void 0:am.previousInsurer)||"",cancellationConfirmationDate:X.cancellationConfirmationDate?X.cancellationConfirmationDate.split("T")[0]:"",cancellationConfirmationOptionsDate:X.cancellationConfirmationOptionsDate?X.cancellationConfirmationOptionsDate.split("T")[0]:"",wasSpecialCancellation:X.wasSpecialCancellation||!1}),(im=X.mobileDetails)!=null&&im.simCards&&X.mobileDetails.simCards.length>0?T(X.mobileDetails.simCards.map($t=>({id:$t.id,phoneNumber:$t.phoneNumber||"",simCardNumber:$t.simCardNumber||"",pin:"",puk:"",hasExistingPin:!!$t.pin,hasExistingPuk:!!$t.puk,isMultisim:$t.isMultisim,isMain:$t.isMain}))):T([]),(lm=X.internetDetails)!=null&&lm.phoneNumbers&&X.internetDetails.phoneNumbers.length>0?K(X.internetDetails.phoneNumbers.map($t=>({id:$t.id,phoneNumber:$t.phoneNumber||"",sipUsername:$t.sipUsername||"",sipPassword:"",hasExistingSipPassword:!!$t.sipPasswordEncrypted,sipServer:$t.sipServer||"",isMain:$t.isMain}))):K([]),X.stressfreiEmailId?(P("stressfrei"),B(X.stressfreiEmailId.toString())):(P("manual"),B("")),Q(!0)}},[f,c]);const Jt=u("startDate"),Pe=u("contractDurationId");w.useEffect(()=>{if(Jt&&Pe&&(x!=null&&x.data)){const A=x.data.find(ne=>ne.id===parseInt(Pe));if(A){const ne=new Date(Jt),ie=A.code.match(/^(\d+)([MTJ])$/);if(ie){const de=parseInt(ie[1]),Ge=ie[2];let je=new Date(ne);Ge==="T"?je.setDate(je.getDate()+de):Ge==="M"?je.setMonth(je.getMonth()+de):Ge==="J"&&je.setFullYear(je.getFullYear()+de),d("endDate",je.toISOString().split("T")[0])}}}},[Jt,Pe,x,d]);const Xt=Y({mutationFn:$e.create,onSuccess:(A,ne)=>{r.invalidateQueries({queryKey:["contracts"]}),ne.customerId&&r.invalidateQueries({queryKey:["customer",ne.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),s(i?`/customers/${i}?tab=contracts`:"/contracts")}}),Gn=Y({mutationFn:A=>$e.update(parseInt(e),A),onSuccess:(A,ne)=>{r.invalidateQueries({queryKey:["contracts"]}),r.invalidateQueries({queryKey:["contract",e]}),ne.customerId&&r.invalidateQueries({queryKey:["customer",ne.customerId.toString()]}),r.invalidateQueries({queryKey:["customers"]}),s(`/contracts/${e}`)}}),Er=A=>{const ne=je=>{if(je==null||je==="")return;const Ma=parseInt(String(je));return isNaN(Ma)?void 0:Ma},fe=H.find(je=>je.code===A.type),ie=ne(A.customerId);if(!ie){alert("Bitte wählen Sie einen Kunden aus");return}if(!A.type||!fe){alert("Bitte wählen Sie einen Vertragstyp aus");return}const de=je=>je==null||je===""?null:je,Ge={customerId:ie,type:A.type,contractCategoryId:fe.id,status:A.status,addressId:ne(A.addressId)??null,bankCardId:ne(A.bankCardId)??null,identityDocumentId:ne(A.identityDocumentId)??null,salesPlatformId:ne(A.salesPlatformId)??null,providerId:ne(A.providerId)??null,tariffId:ne(A.tariffId)??null,providerName:de(A.providerName),tariffName:de(A.tariffName),customerNumberAtProvider:de(A.customerNumberAtProvider),priceFirst12Months:de(A.priceFirst12Months),priceFrom13Months:de(A.priceFrom13Months),priceAfter24Months:de(A.priceAfter24Months),startDate:A.startDate?new Date(A.startDate):null,endDate:A.endDate?new Date(A.endDate):null,cancellationPeriodId:ne(A.cancellationPeriodId)??null,contractDurationId:ne(A.contractDurationId)??null,commission:A.commission?parseFloat(A.commission):null,portalUsername:z==="manual"?de(A.portalUsername):null,stressfreiEmailId:z==="stressfrei"&&j?parseInt(j):null,portalPassword:A.portalPassword||void 0,notes:de(A.notes),cancellationConfirmationDate:A.cancellationConfirmationDate?new Date(A.cancellationConfirmationDate):null,cancellationConfirmationOptionsDate:A.cancellationConfirmationOptionsDate?new Date(A.cancellationConfirmationOptionsDate):null,wasSpecialCancellation:A.wasSpecialCancellation||!1};["ELECTRICITY","GAS"].includes(A.type)&&(Ge.energyDetails={meterId:ne(A.meterId)??null,annualConsumption:A.annualConsumption?parseFloat(A.annualConsumption):null,basePrice:A.basePrice?parseFloat(A.basePrice):null,unitPrice:A.unitPrice?parseFloat(A.unitPrice):null,bonus:A.bonus?parseFloat(A.bonus):null,previousProviderName:de(A.previousProviderName),previousCustomerNumber:de(A.previousCustomerNumber)}),["DSL","CABLE","FIBER"].includes(A.type)&&(Ge.internetDetails={downloadSpeed:ne(A.downloadSpeed)??null,uploadSpeed:ne(A.uploadSpeed)??null,routerModel:de(A.routerModel),routerSerialNumber:de(A.routerSerialNumber),installationDate:A.installationDate?new Date(A.installationDate):null,internetUsername:de(A.internetUsername),internetPassword:A.internetPassword||void 0,homeId:de(A.homeId),activationCode:de(A.activationCode),phoneNumbers:_.length>0?_.map(je=>({id:je.id,phoneNumber:je.phoneNumber||"",isMain:je.isMain??!1,sipUsername:de(je.sipUsername),sipPassword:je.sipPassword||void 0,sipServer:de(je.sipServer)})):void 0}),A.type==="MOBILE"&&(Ge.mobileDetails={requiresMultisim:A.requiresMultisim||!1,dataVolume:A.dataVolume?parseFloat(A.dataVolume):null,includedMinutes:ne(A.includedMinutes)??null,includedSMS:ne(A.includedSMS)??null,deviceModel:de(A.deviceModel),deviceImei:de(A.deviceImei),phoneNumber:de(A.phoneNumber),simCardNumber:de(A.simCardNumber),simCards:L.length>0?L.map(je=>({id:je.id,phoneNumber:de(je.phoneNumber),simCardNumber:de(je.simCardNumber),pin:je.pin||void 0,puk:je.puk||void 0,isMultisim:je.isMultisim,isMain:je.isMain})):void 0}),A.type==="TV"&&(Ge.tvDetails={receiverModel:de(A.receiverModel),smartcardNumber:de(A.smartcardNumber),package:de(A.tvPackage)}),A.type==="CAR_INSURANCE"&&(Ge.carInsuranceDetails={licensePlate:de(A.licensePlate),hsn:de(A.hsn),tsn:de(A.tsn),vin:de(A.vin),vehicleType:de(A.vehicleType),firstRegistration:A.firstRegistration?new Date(A.firstRegistration):null,noClaimsClass:de(A.noClaimsClass),insuranceType:A.insuranceType,deductiblePartial:A.deductiblePartial?parseFloat(A.deductiblePartial):null,deductibleFull:A.deductibleFull?parseFloat(A.deductibleFull):null,policyNumber:de(A.policyNumber),previousInsurer:de(A.previousInsurer)}),a?Gn.mutate(Ge):Xt.mutate(Ge)},hn=Xt.isPending||Gn.isPending,Dr=Xt.error||Gn.error,mt=b==null?void 0:b.data,Zo=(mt==null?void 0:mt.addresses)||[],Yo=((gs=mt==null?void 0:mt.bankCards)==null?void 0:gs.filter(A=>A.isActive))||[],vh=((Ji=mt==null?void 0:mt.identityDocuments)==null?void 0:Ji.filter(A=>A.isActive))||[],Yi=((Pr=mt==null?void 0:mt.meters)==null?void 0:Pr.filter(A=>A.isActive))||[],E=((Ar=mt==null?void 0:mt.stressfreiEmails)==null?void 0:Ar.filter(A=>A.isActive))||[],M=(y==null?void 0:y.data)||[],U=(v==null?void 0:v.data)||[],se=(x==null?void 0:x.data)||[],G=((Xi=N==null?void 0:N.data)==null?void 0:Xi.filter(A=>A.isActive))||[],H=((Fa=k==null?void 0:k.data)==null?void 0:Fa.filter(A=>A.isActive).sort((A,ne)=>A.sortOrder-ne.sortOrder))||[],ce=H.map(A=>({value:A.code,label:A.name})),we=G.find(A=>A.id===parseInt(D||"0")),Ae=((el=we==null?void 0:we.tariffs)==null?void 0:el.filter(A=>A.isActive))||[],ft=A=>{const ne=A.companyName||`${A.firstName} ${A.lastName}`,fe=A.birthDate?` (geb. ${new Date(A.birthDate).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"})})`:"";return`${A.customerNumber} - ${ne}${fe}`},Bs=(()=>{var fe;const ne=((g==null?void 0:g.data)||[]).map(ie=>({value:ie.id.toString(),label:ft(ie)}));if(a&&((fe=f==null?void 0:f.data)!=null&&fe.customer)){const ie=f.data.customer;ne.some(Ge=>Ge.value===ie.id.toString())||ne.unshift({value:ie.id.toString(),label:ft(ie)})}return ne})();return n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold mb-6",children:a?"Vertrag bearbeiten":"Neuer Vertrag"}),Dr&&n.jsx("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 text-red-700 rounded-lg",children:Dr instanceof Error?Dr.message:"Ein Fehler ist aufgetreten"}),n.jsxs("form",{onSubmit:o(Er),children:[n.jsx(Z,{className:"mb-6",title:"Vertragsdaten",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(Le,{label:"Kunde *",...l("customerId",{required:"Kunde erforderlich"}),options:Bs,error:(Ia=m.customerId)==null?void 0:Ia.message}),n.jsx(Le,{label:"Vertragstyp *",...l("type",{required:"Typ erforderlich"}),options:ce}),n.jsx(Le,{label:"Status",...l("status"),options:IS}),n.jsx(Le,{label:"Vertriebsplattform",...l("salesPlatformId"),options:M.map(A=>({value:A.id,label:A.name}))})]})}),h&&n.jsx(Z,{className:"mb-6",title:"Kundendaten verknüpfen",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.jsx(Le,{label:"Adresse",...l("addressId"),options:Zo.map(A=>({value:A.id,label:`${A.street} ${A.houseNumber}, ${A.postalCode} ${A.city} (${A.type==="BILLING"?"Rechnung":"Liefer"})`}))}),n.jsx(Le,{label:"Bankkarte",...l("bankCardId"),options:Yo.map(A=>({value:A.id,label:`${A.iban} (${A.accountHolder})`}))}),n.jsx(Le,{label:"Ausweis",...l("identityDocumentId"),options:vh.map(A=>({value:A.id,label:`${A.documentNumber} (${A.type})`}))})]})}),n.jsx(Z,{className:"mb-6",title:"Anbieter & Tarif",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(Le,{label:"Anbieter",...l("providerId"),options:G.map(A=>({value:A.id,label:A.name}))}),n.jsx(Le,{label:"Tarif",...l("tariffId"),options:Ae.map(A=>({value:A.id,label:A.name})),disabled:!D}),n.jsx($,{label:"Kundennummer beim Anbieter",...l("customerNumberAtProvider")}),n.jsx($,{label:"Provision (€)",type:"number",step:"0.01",...l("commission")}),n.jsx($,{label:"Preis erste 12 Monate",...l("priceFirst12Months"),placeholder:"z.B. 29,99 €/Monat"}),n.jsx($,{label:"Preis ab 13. Monat",...l("priceFrom13Months"),placeholder:"z.B. 39,99 €/Monat"}),n.jsx($,{label:"Preis nach 24 Monaten",...l("priceAfter24Months"),placeholder:"z.B. 49,99 €/Monat"})]})}),n.jsxs(Z,{className:"mb-6",title:"Laufzeit und Kündigung",children:[n.jsxs("p",{className:"text-sm text-gray-500 mb-4 bg-blue-50 border border-blue-200 rounded-lg p-3",children:[n.jsx("strong",{children:"Hinweis:"})," Ist die Laufzeit ≤ 4 Wochen, 1 Monat oder 30 Tage, gilt der Vertrag als unbefristet mit der jeweiligen Kündigungsfrist."]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx($,{label:"Vertragsbeginn",type:"date",...l("startDate"),value:u("startDate")||"",onClear:()=>d("startDate","")}),n.jsx($,{label:"Vertragsende (berechnet)",type:"date",...l("endDate"),disabled:!0,className:"bg-gray-50"}),n.jsx(Le,{label:"Vertragslaufzeit",...l("contractDurationId"),options:se.map(A=>({value:A.id,label:A.description}))}),n.jsx(Le,{label:"Kündigungsfrist",...l("cancellationPeriodId"),options:U.map(A=>({value:A.id,label:A.description}))}),n.jsx($,{label:"Kündigungsbestätigungsdatum",type:"date",...l("cancellationConfirmationDate"),value:u("cancellationConfirmationDate")||"",onClear:()=>d("cancellationConfirmationDate","")}),n.jsx($,{label:"Kündigungsbestätigungsoptionendatum",type:"date",...l("cancellationConfirmationOptionsDate"),value:u("cancellationConfirmationOptionsDate")||"",onClear:()=>d("cancellationConfirmationOptionsDate","")}),n.jsx("div",{className:"col-span-2",children:n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx("input",{type:"checkbox",...l("wasSpecialCancellation"),className:"rounded border-gray-300"}),n.jsx("span",{children:"Wurde sondergekündigt?"})]})})]})]}),n.jsx(Z,{className:"mb-6",title:"Zugangsdaten (verschlüsselt gespeichert)",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Portal Benutzername"}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx("input",{type:"radio",name:"usernameType",checked:z==="manual",onChange:()=>{P("manual"),B("")},className:"text-blue-600"}),n.jsx("span",{className:"text-sm",children:"Manuell eingeben"})]}),z==="manual"&&n.jsx($,{...l("portalUsername"),placeholder:"Benutzername eingeben..."}),n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx("input",{type:"radio",name:"usernameType",checked:z==="stressfrei",onChange:()=>{P("stressfrei"),d("portalUsername","")},className:"text-blue-600"}),n.jsx("span",{className:"text-sm",children:"Stressfrei-Wechseln Adresse"})]}),z==="stressfrei"&&n.jsx(Le,{value:j,onChange:A=>B(A.target.value),options:E.map(A=>({value:A.id,label:A.email+(A.notes?` (${A.notes})`:"")})),placeholder:E.length===0?"Keine Stressfrei-Adressen vorhanden":"Adresse auswählen..."}),z==="stressfrei"&&E.length===0&&n.jsx("p",{className:"text-xs text-amber-600",children:"Keine Stressfrei-Wechseln Adressen für diesen Kunden vorhanden. Bitte zuerst beim Kunden anlegen."})]})]}),n.jsxs("div",{className:"mt-8",children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer lassen = unverändert)":"Portal Passwort"}),n.jsxs("div",{className:"relative",children:[n.jsx("input",{type:J?"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"}),n.jsx("button",{type:"button",onClick:()=>ee(!J),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:J?n.jsx(Pt,{className:"w-4 h-4"}):n.jsx(Ee,{className:"w-4 h-4"})})]})]})]})}),["ELECTRICITY","GAS"].includes(p)&&n.jsx(Z,{className:"mb-6",title:p==="ELECTRICITY"?"Strom-Details":"Gas-Details",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(Le,{label:"Zähler",...l("meterId"),options:Yi.filter(A=>A.type===p).map(A=>({value:A.id,label:`${A.meterNumber}${A.location?` (${A.location})`:""}`}))}),n.jsx($,{label:`Jahresverbrauch (${p==="ELECTRICITY"?"kWh":"m³"})`,type:"number",...l("annualConsumption")}),n.jsx($,{label:"Grundpreis (€/Monat)",type:"number",step:"0.01",...l("basePrice")}),n.jsx($,{label:`Arbeitspreis (ct/${p==="ELECTRICITY"?"kWh":"m³"})`,type:"number",step:"0.01",...l("unitPrice")}),n.jsx($,{label:"Bonus (€)",type:"number",step:"0.01",...l("bonus")}),n.jsx($,{label:"Vorversorger",...l("previousProviderName")}),n.jsx($,{label:"Kundennr. beim Vorversorger",...l("previousCustomerNumber")})]})}),["DSL","CABLE","FIBER"].includes(p)&&n.jsxs(n.Fragment,{children:[n.jsx(Z,{className:"mb-6",title:p==="DSL"?"DSL-Details":p==="CABLE"?"Kabelinternet-Details":"Glasfaser-Details",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx($,{label:"Download (Mbit/s)",type:"number",...l("downloadSpeed")}),n.jsx($,{label:"Upload (Mbit/s)",type:"number",...l("uploadSpeed")}),n.jsx($,{label:"Router Modell",...l("routerModel")}),n.jsx($,{label:"Router Seriennummer",...l("routerSerialNumber")}),n.jsx($,{label:"Installationsdatum",type:"date",...l("installationDate"),value:u("installationDate")||"",onClear:()=>d("installationDate","")}),p==="FIBER"&&n.jsx($,{label:"Home-ID",...l("homeId")}),((jh=we==null?void 0:we.name)==null?void 0:jh.toLowerCase().includes("vodafone"))&&["DSL","CABLE"].includes(p)&&n.jsx($,{label:"Aktivierungscode",...l("activationCode")})]})}),n.jsx(Z,{className:"mb-6",title:"Internet-Zugangsdaten (verschlüsselt)",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx($,{label:"Benutzername",...l("internetUsername")}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer = beibehalten)":"Passwort"}),n.jsxs("div",{className:"relative",children:[n.jsx("input",{type:me?"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"}),n.jsx("button",{type:"button",onClick:()=>ve(!me),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:me?n.jsx(Pt,{className:"w-4 h-4"}):n.jsx(Ee,{className:"w-4 h-4"})})]})]})]})}),n.jsxs(Z,{className:"mb-6",title:"Rufnummern & SIP-Zugangsdaten",children:[n.jsx("p",{className:"text-sm text-gray-500 mb-4",children:"Hier können Sie Festnetz-Rufnummern mit SIP-Zugangsdaten erfassen."}),_.length>0&&n.jsx("div",{className:"space-y-4 mb-4",children:_.map((A,ne)=>n.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[n.jsxs("div",{className:"flex justify-between items-center mb-3",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("span",{className:"font-medium",children:["Rufnummer ",ne+1]}),n.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[n.jsx("input",{type:"checkbox",checked:A.isMain,onChange:fe=>{const ie=[..._];fe.target.checked?ie.forEach((de,Ge)=>de.isMain=Ge===ne):ie[ne].isMain=!1,K(ie)},className:"rounded border-gray-300"}),"Hauptnummer"]})]}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>{K(_.filter((fe,ie)=>ie!==ne))},children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[n.jsx($,{label:"Rufnummer",value:A.phoneNumber,onChange:fe=>{const ie=[..._];ie[ne].phoneNumber=fe.target.value,K(ie)},placeholder:"z.B. 030 123456"}),n.jsx($,{label:"SIP-Benutzername",value:A.sipUsername,onChange:fe=>{const ie=[..._];ie[ne].sipUsername=fe.target.value,K(ie)}}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:A.hasExistingSipPassword?"SIP-Passwort (bereits hinterlegt)":"SIP-Passwort"}),n.jsxs("div",{className:"relative",children:[n.jsx("input",{type:it[ne]?"text":"password",value:A.sipPassword,onChange:fe=>{const ie=[..._];ie[ne].sipPassword=fe.target.value,K(ie)},placeholder:A.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"}),n.jsx("button",{type:"button",onClick:()=>V(fe=>({...fe,[ne]:!fe[ne]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:it[ne]?n.jsx(Pt,{className:"w-4 h-4"}):n.jsx(Ee,{className:"w-4 h-4"})})]})]}),n.jsx($,{label:"SIP-Server",value:A.sipServer,onChange:fe=>{const ie=[..._];ie[ne].sipServer=fe.target.value,K(ie)},placeholder:"z.B. sip.provider.de"})]})]},ne))}),n.jsxs(I,{type:"button",variant:"secondary",onClick:()=>{K([..._,{phoneNumber:"",sipUsername:"",sipPassword:"",sipServer:"",isMain:_.length===0}])},children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Rufnummer hinzufügen"]})]})]}),p==="MOBILE"&&n.jsxs(n.Fragment,{children:[n.jsxs(Z,{className:"mb-6",title:"Mobilfunk-Details",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx($,{label:"Datenvolumen (GB)",type:"number",...l("dataVolume")}),n.jsx($,{label:"Inklusiv-Minuten",type:"number",...l("includedMinutes")}),n.jsx($,{label:"Inklusiv-SMS",type:"number",...l("includedSMS")}),n.jsx($,{label:"Gerät (Modell)",...l("deviceModel")}),n.jsx($,{label:"Gerät (IMEI)",...l("deviceImei")})]}),n.jsx("div",{className:"mt-4 pt-4 border-t",children:n.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[n.jsx("input",{type:"checkbox",...l("requiresMultisim"),className:"mt-1 rounded border-gray-300"}),n.jsxs("div",{children:[n.jsx("span",{className:"font-medium",children:"Multisim erforderlich"}),n.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."})]})]})})]}),n.jsxs(Z,{className:"mb-6",title:"SIM-Karten",children:[n.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)."}),L.length>0&&n.jsx("div",{className:"space-y-4 mb-4",children:L.map((A,ne)=>n.jsxs("div",{className:"p-4 border rounded-lg bg-gray-50",children:[n.jsxs("div",{className:"flex justify-between items-center mb-3",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("span",{className:"font-medium",children:["SIM-Karte ",ne+1]}),n.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[n.jsx("input",{type:"checkbox",checked:A.isMain,onChange:fe=>{const ie=[...L];fe.target.checked?ie.forEach((de,Ge)=>de.isMain=Ge===ne):ie[ne].isMain=!1,T(ie)},className:"rounded border-gray-300"}),"Hauptkarte"]}),n.jsxs("label",{className:"flex items-center gap-1 text-sm",children:[n.jsx("input",{type:"checkbox",checked:A.isMultisim,onChange:fe=>{const ie=[...L];ie[ne].isMultisim=fe.target.checked,T(ie)},className:"rounded border-gray-300"}),"Multisim"]})]}),n.jsx(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>{T(L.filter((fe,ie)=>ie!==ne))},children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[n.jsx($,{label:"Rufnummer",value:A.phoneNumber,onChange:fe=>{const ie=[...L];ie[ne].phoneNumber=fe.target.value,T(ie)},placeholder:"z.B. 0171 1234567"}),n.jsx($,{label:"SIM-Kartennummer",value:A.simCardNumber,onChange:fe=>{const ie=[...L];ie[ne].simCardNumber=fe.target.value,T(ie)},placeholder:"ICCID"}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:A.hasExistingPin?"PIN (bereits hinterlegt)":"PIN"}),n.jsxs("div",{className:"relative",children:[n.jsx("input",{type:Ce[ne]?"text":"password",value:A.pin,onChange:fe=>{const ie=[...L];ie[ne].pin=fe.target.value,T(ie)},placeholder:A.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"}),n.jsx("button",{type:"button",onClick:()=>Me(fe=>({...fe,[ne]:!fe[ne]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:Ce[ne]?n.jsx(Pt,{className:"w-4 h-4"}):n.jsx(Ee,{className:"w-4 h-4"})})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:A.hasExistingPuk?"PUK (bereits hinterlegt)":"PUK"}),n.jsxs("div",{className:"relative",children:[n.jsx("input",{type:ht[ne]?"text":"password",value:A.puk,onChange:fe=>{const ie=[...L];ie[ne].puk=fe.target.value,T(ie)},placeholder:A.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"}),n.jsx("button",{type:"button",onClick:()=>Tt(fe=>({...fe,[ne]:!fe[ne]})),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:ht[ne]?n.jsx(Pt,{className:"w-4 h-4"}):n.jsx(Ee,{className:"w-4 h-4"})})]})]})]})]},ne))}),n.jsxs(I,{type:"button",variant:"secondary",onClick:()=>{T([...L,{phoneNumber:"",simCardNumber:"",pin:"",puk:"",isMultisim:!1,isMain:L.length===0}])},children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"SIM-Karte hinzufügen"]})]})]}),p==="TV"&&n.jsx(Z,{className:"mb-6",title:"TV-Details",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx($,{label:"Receiver Modell",...l("receiverModel")}),n.jsx($,{label:"Smartcard-Nummer",...l("smartcardNumber")}),n.jsx($,{label:"Paket",...l("tvPackage"),placeholder:"z.B. Basis, Premium, Sport"})]})}),p==="CAR_INSURANCE"&&n.jsx(Z,{className:"mb-6",title:"KFZ-Versicherung Details",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.jsx($,{label:"Kennzeichen",...l("licensePlate")}),n.jsx($,{label:"HSN",...l("hsn")}),n.jsx($,{label:"TSN",...l("tsn")}),n.jsx($,{label:"FIN (VIN)",...l("vin")}),n.jsx($,{label:"Fahrzeugtyp",...l("vehicleType")}),n.jsx($,{label:"Erstzulassung",type:"date",...l("firstRegistration"),value:u("firstRegistration")||"",onClear:()=>d("firstRegistration","")}),n.jsx($,{label:"SF-Klasse",...l("noClaimsClass")}),n.jsx(Le,{label:"Versicherungsart",...l("insuranceType"),options:[{value:"LIABILITY",label:"Haftpflicht"},{value:"PARTIAL",label:"Teilkasko"},{value:"FULL",label:"Vollkasko"}]}),n.jsx($,{label:"SB Teilkasko (€)",type:"number",...l("deductiblePartial")}),n.jsx($,{label:"SB Vollkasko (€)",type:"number",...l("deductibleFull")}),n.jsx($,{label:"Versicherungsscheinnummer",...l("policyNumber")}),n.jsx($,{label:"Vorversicherer",...l("previousInsurer")})]})}),n.jsx(Z,{className:"mb-6",title:"Notizen",children:n.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..."})}),n.jsxs("div",{className:"flex justify-end gap-4",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:()=>s(-1),children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:hn,children:hn?"Speichern...":"Speichern"})]})]})]})}const MS={ELECTRICITY:mh,GAS:Jy,DSL:ea,CABLE:ea,FIBER:ea,MOBILE:dh,TV:sv,CAR_INSURANCE:Hy},LS={ELECTRICITY:"Strom",GAS:"Gas",DSL:"DSL",CABLE:"Kabel",FIBER:"Glasfaser",MOBILE:"Mobilfunk",TV:"TV",CAR_INSURANCE:"KFZ"},RS={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"},OS={critical:"danger",warning:"warning",ok:"success",none:"default"},_S={cancellation_deadline:Qy,contract_ending:qn,missing_cancellation_letter:vt,missing_cancellation_confirmation:vt,missing_portal_credentials:y1,missing_customer_number:vt,missing_provider:vt,missing_address:vt,missing_bank:vt,missing_meter:mh,missing_sim:dh,open_tasks:Ii,pending_status:qn,draft_status:vt},zS={cancellationDeadlines:"Kündigungsfristen",contractEnding:"Vertragsenden",missingCredentials:"Fehlende Zugangsdaten",missingData:"Fehlende Daten",openTasks:"Offene Aufgaben",pendingContracts:"Wartende Verträge"};function US(){var g;const[e,t]=Uo(),[s,r]=w.useState(new Set),a=e.get("filter"),[i,l]=w.useState(a||"all");w.useEffect(()=>{i==="all"?e.delete("filter"):e.set("filter",i),t(e,{replace:!0})},[i,e,t]);const{data:o,isLoading:c,error:u}=ge({queryKey:["contract-cockpit"],queryFn:()=>$e.getCockpit(),staleTime:0}),d=b=>{r(y=>{const v=new Set(y);return v.has(b)?v.delete(b):v.add(b),v})},m=w.useMemo(()=>{var y;if(!((y=o==null?void 0:o.data)!=null&&y.contracts))return[];const b=o.data.contracts;switch(i){case"critical":return b.filter(v=>v.highestUrgency==="critical");case"warning":return b.filter(v=>v.highestUrgency==="warning");case"ok":return b.filter(v=>v.highestUrgency==="ok");case"deadlines":return b.filter(v=>v.issues.some(x=>["cancellation_deadline","contract_ending"].includes(x.type)));case"credentials":return b.filter(v=>v.issues.some(x=>x.type.includes("credentials")));case"data":return b.filter(v=>v.issues.some(x=>x.type.startsWith("missing_")&&!x.type.includes("credentials")));case"tasks":return b.filter(v=>v.issues.some(x=>["open_tasks","pending_status","draft_status"].includes(x.type)));default:return b}},[(g=o==null?void 0:o.data)==null?void 0:g.contracts,i]);if(c)return n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx("div",{className:"text-gray-500",children:"Laden..."})});if(u||!(o!=null&&o.data))return n.jsx("div",{className:"text-center py-12",children:n.jsx("p",{className:"text-red-500",children:"Fehler beim Laden des Cockpits"})});const{summary:p,thresholds:h}=o.data,f=b=>{var x,N,k,D;const y=s.has(b.id),v=MS[b.type]||vt;return n.jsxs("div",{className:`border rounded-lg mb-2 ${RS[b.highestUrgency]}`,children:[n.jsxs("div",{className:"flex items-center p-4 cursor-pointer hover:bg-opacity-50",onClick:()=>d(b.id),children:[n.jsx("div",{className:"w-6 mr-2",children:y?n.jsx(Qo,{className:"w-5 h-5"}):n.jsx(Ys,{className:"w-5 h-5"})}),n.jsx(v,{className:"w-5 h-5 mr-3"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx(Se,{to:`/contracts/${b.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"font-medium hover:underline",onClick:F=>F.stopPropagation(),children:b.contractNumber}),n.jsxs(he,{variant:OS[b.highestUrgency],children:[b.issues.length," ",b.highestUrgency==="ok"?b.issues.length===1?"Hinweis":"Hinweise":b.issues.length===1?"Problem":"Probleme"]}),n.jsx("span",{className:"text-sm",children:LS[b.type]})]}),n.jsxs("div",{className:"text-sm mt-1",children:[n.jsxs(Se,{to:`/customers/${b.customer.id}`,className:"hover:underline",onClick:F=>F.stopPropagation(),children:[b.customer.customerNumber," - ",b.customer.name]}),(((x=b.provider)==null?void 0:x.name)||b.providerName)&&n.jsxs("span",{className:"ml-2",children:["| ",((N=b.provider)==null?void 0:N.name)||b.providerName,(((k=b.tariff)==null?void 0:k.name)||b.tariffName)&&` - ${((D=b.tariff)==null?void 0:D.name)||b.tariffName}`]})]})]}),n.jsx(Se,{to:`/contracts/${b.id}`,state:{from:"cockpit",filter:i!=="all"?i:void 0},className:"ml-4 p-2 hover:bg-white hover:bg-opacity-50 rounded",onClick:F=>F.stopPropagation(),title:"Zum Vertrag",children:n.jsx(Ee,{className:"w-4 h-4"})})]}),y&&n.jsx("div",{className:"border-t px-4 py-3 bg-white bg-opacity-50",children:n.jsx("div",{className:"space-y-2",children:b.issues.map((F,S)=>{const L=_S[F.type]||en,T=F.urgency==="critical"?en:F.urgency==="warning"?Li:F.urgency==="ok"?hs:qn;return n.jsxs("div",{className:"flex items-start gap-3 text-sm",children:[n.jsx(T,{className:`w-4 h-4 mt-0.5 flex-shrink-0 ${F.urgency==="critical"?"text-red-500":F.urgency==="warning"?"text-yellow-500":F.urgency==="ok"?"text-green-500":"text-gray-500"}`}),n.jsx(L,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-gray-500"}),n.jsxs("div",{children:[n.jsx("span",{className:"font-medium",children:F.label}),F.details&&n.jsx("span",{className:"text-gray-600 ml-2",children:F.details})]})]},S)})})})]},b.id)};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(en,{className:"w-6 h-6 text-red-500"}),n.jsx("h1",{className:"text-2xl font-bold",children:"Vertrags-Cockpit"})]}),n.jsx(Se,{to:"/settings/deadlines",className:"text-sm text-blue-600 hover:underline",children:"Fristenschwellen anpassen"})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[n.jsx(Z,{className:"!p-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"p-2 bg-red-100 rounded-lg",children:n.jsx(en,{className:"w-6 h-6 text-red-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl font-bold text-red-600",children:p.criticalCount}),n.jsxs("p",{className:"text-sm text-gray-500",children:["Kritisch (<",h.criticalDays," Tage)"]})]})]})}),n.jsx(Z,{className:"!p-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"p-2 bg-yellow-100 rounded-lg",children:n.jsx(Li,{className:"w-6 h-6 text-yellow-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl font-bold text-yellow-600",children:p.warningCount}),n.jsxs("p",{className:"text-sm text-gray-500",children:["Warnung (<",h.warningDays," Tage)"]})]})]})}),n.jsx(Z,{className:"!p-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"p-2 bg-green-100 rounded-lg",children:n.jsx(hs,{className:"w-6 h-6 text-green-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl font-bold text-green-600",children:p.okCount}),n.jsxs("p",{className:"text-sm text-gray-500",children:["OK (<",h.okDays," Tage)"]})]})]})}),n.jsx(Z,{className:"!p-4",children:n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"p-2 bg-gray-100 rounded-lg",children:n.jsx(vt,{className:"w-6 h-6 text-gray-500"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-2xl font-bold text-gray-600",children:p.totalContracts}),n.jsx("p",{className:"text-sm text-gray-500",children:"Verträge mit Handlungsbedarf"})]})]})})]}),n.jsx(Z,{className:"mb-6",children:n.jsx("div",{className:"flex flex-wrap gap-4",children:Object.entries(p.byCategory).map(([b,y])=>y>0&&n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsxs("span",{className:"font-medium",children:[zS[b]||b,":"]}),n.jsx(he,{variant:"default",children:y})]},b))})}),n.jsx(Z,{className:"mb-6",children:n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("span",{className:"text-sm text-gray-600",children:"Filter:"}),n.jsx(Le,{value:i,onChange:b=>l(b.target.value),options:[{value:"all",label:`Alle (${o.data.contracts.length})`},{value:"critical",label:`Kritisch (${p.criticalCount})`},{value:"warning",label:`Warnung (${p.warningCount})`},{value:"ok",label:`OK (${p.okCount})`},{value:"deadlines",label:`Fristen (${p.byCategory.cancellationDeadlines+p.byCategory.contractEnding})`},{value:"credentials",label:`Zugangsdaten (${p.byCategory.missingCredentials})`},{value:"data",label:`Fehlende Daten (${p.byCategory.missingData})`},{value:"tasks",label:`Aufgaben/Status (${p.byCategory.openTasks+p.byCategory.pendingContracts})`}],className:"w-64"}),n.jsxs("span",{className:"text-sm text-gray-500",children:[m.length," Verträge angezeigt"]})]})}),m.length===0?n.jsx(Z,{children:n.jsx("div",{className:"text-center py-8 text-gray-500",children:i==="all"?n.jsxs(n.Fragment,{children:[n.jsx(hs,{className:"w-12 h-12 mx-auto mb-4 text-green-500"}),n.jsx("p",{className:"text-lg font-medium",children:"Alles in Ordnung!"}),n.jsx("p",{children:"Keine Verträge mit Handlungsbedarf gefunden."})]}):n.jsx("p",{children:"Keine Verträge für diesen Filter gefunden."})})}):n.jsx("div",{children:m.map(f)})]})}const Cp={OPEN:"Offen",COMPLETED:"Erledigt"},$S={OPEN:"warning",COMPLETED:"success"};function BS(){var Q;const e=Ut(),t=pe(),{isCustomerPortal:s,user:r,hasPermission:a}=st(),[i,l]=w.useState("OPEN"),[o,c]=w.useState(new Set),[u,d]=w.useState(!1),[m,p]=w.useState({}),h=s?"Support-Anfragen":"Aufgaben",f=s?"Anfrage":"Aufgabe",{data:g,isLoading:b}=ge({queryKey:["app-settings-public"],queryFn:()=>Sr.getPublic(),enabled:s,staleTime:0}),y=!b&&((Q=g==null?void 0:g.data)==null?void 0:Q.customerSupportTicketsEnabled)==="true",{data:v,isLoading:x}=ge({queryKey:["all-tasks",i],queryFn:()=>Xe.getAll({status:i||void 0}),staleTime:0}),N=Y({mutationFn:z=>Xe.completeSubtask(z),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),k=Y({mutationFn:z=>Xe.reopenSubtask(z),onSuccess:()=>{t.invalidateQueries({queryKey:["all-tasks"]}),t.invalidateQueries({queryKey:["task-stats"]})}}),D=Y({mutationFn:({taskId:z,title:P})=>s?Xe.createReply(z,P):Xe.createSubtask(z,P),onSuccess:(z,{taskId:P})=>{t.invalidateQueries({queryKey:["all-tasks"]}),p(j=>({...j,[P]:""}))}}),F=w.useMemo(()=>{var B;if(!(v!=null&&v.data))return{ownTasks:[],representedTasks:[],allTasks:[]};const z=v.data;if(!s)return{allTasks:z,ownTasks:[],representedTasks:[]};const P=[],j=[];for(const J of z)((B=J.contract)==null?void 0:B.customerId)===(r==null?void 0:r.customerId)?P.push(J):j.push(J);return{ownTasks:P,representedTasks:j,allTasks:[]}},[v==null?void 0:v.data,s,r==null?void 0:r.customerId]),S=z=>{c(P=>{const j=new Set(P);return j.has(z)?j.delete(z):j.add(z),j})},L=z=>{N.isPending||k.isPending||(z.status==="COMPLETED"?k.mutate(z.id):N.mutate(z.id))},T=z=>{var j;const P=(j=m[z])==null?void 0:j.trim();P&&D.mutate({taskId:z,title:P})},_=!s&&a("contracts:update"),K=(z,P=!1)=>{var V,Ce,Me,ht,Tt,Jt;const j=o.has(z.id),B=z.subtasks&&z.subtasks.length>0,J=((V=z.subtasks)==null?void 0:V.filter(Pe=>Pe.status==="COMPLETED").length)||0,ee=((Ce=z.subtasks)==null?void 0:Ce.length)||0,me=z.status==="COMPLETED",ve=z.contract?`${z.contract.contractNumber} - ${((Me=z.contract.provider)==null?void 0:Me.name)||z.contract.providerName||"Kein Anbieter"}`:`Vertrag #${z.contractId}`,it=(ht=z.contract)!=null&&ht.customer?z.contract.customer.companyName||`${z.contract.customer.firstName} ${z.contract.customer.lastName}`:"";return n.jsxs("div",{className:"border rounded-lg mb-2",children:[n.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50 cursor-pointer",onClick:()=>S(z.id),children:[n.jsx("div",{className:"w-6 mr-2",children:j?n.jsx(Qo,{className:"w-5 h-5 text-gray-400"}):n.jsx(Ys,{className:"w-5 h-5 text-gray-400"})}),n.jsx("div",{className:"mr-3",children:z.status==="COMPLETED"?n.jsx(hs,{className:"w-5 h-5 text-green-500"}):n.jsx(qn,{className:"w-5 h-5 text-yellow-500"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"font-medium",children:z.title}),n.jsx(he,{variant:$S[z.status],children:Cp[z.status]}),B&&n.jsxs("span",{className:"text-xs text-gray-500",children:["(",J,"/",ee," erledigt)"]})]}),n.jsxs("div",{className:"text-sm text-gray-500 mt-1 flex items-center gap-2",children:[n.jsx(vt,{className:"w-4 h-4"}),n.jsx(Se,{to:`/contracts/${z.contractId}`,className:"text-blue-600 hover:underline",onClick:Pe=>Pe.stopPropagation(),children:ve}),P&&it&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"text-gray-400",children:"|"}),n.jsx("span",{children:it})]})]}),z.description&&n.jsx("p",{className:"text-sm text-gray-600 mt-1 line-clamp-2",children:z.description})]}),n.jsx("div",{className:"ml-4 flex gap-2",children:n.jsx(I,{variant:"ghost",size:"sm",onClick:Pe=>{Pe.stopPropagation(),e(`/contracts/${z.contractId}`)},title:"Zum Vertrag",children:n.jsx(Ee,{className:"w-4 h-4"})})})]}),j&&n.jsxs("div",{className:"border-t bg-gray-50 px-4 py-3",children:[B&&n.jsx("div",{className:"space-y-2 mb-4",children:(Tt=z.subtasks)==null?void 0:Tt.map(Pe=>{const Xt=new Date(Pe.createdAt).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"numeric"});return n.jsxs("div",{className:`flex items-start gap-2 text-sm ml-6 ${_?"cursor-pointer hover:bg-gray-100 rounded px-2 py-1 -mx-2":""}`,onClick:_?()=>L(Pe):void 0,children:[n.jsx("span",{className:"flex-shrink-0 mt-0.5",children:Pe.status==="COMPLETED"?n.jsx(hs,{className:"w-4 h-4 text-green-500"}):n.jsx(_l,{className:"w-4 h-4 text-gray-400"})}),n.jsxs("span",{className:Pe.status==="COMPLETED"?"text-gray-500 line-through":"",children:[Pe.title,n.jsxs("span",{className:"text-xs text-gray-400 ml-2",children:[Pe.createdBy," • ",Xt]})]})]},Pe.id)})}),!me&&(_||s)&&n.jsxs("div",{className:"flex gap-2 ml-6",children:[n.jsx($,{placeholder:s?"Antwort schreiben...":"Neue Unteraufgabe...",value:m[z.id]||"",onChange:Pe=>p(Xt=>({...Xt,[z.id]:Pe.target.value})),onKeyDown:Pe=>{Pe.key==="Enter"&&!Pe.shiftKey&&(Pe.preventDefault(),T(z.id))},className:"flex-1"}),n.jsx(I,{size:"sm",onClick:()=>T(z.id),disabled:!((Jt=m[z.id])!=null&&Jt.trim())||D.isPending,children:n.jsx(k1,{className:"w-4 h-4"})})]}),!B&&me&&n.jsx("p",{className:"text-gray-500 text-sm text-center py-2",children:"Keine Unteraufgaben vorhanden."})]})]},z.id)},W=s?y:a("contracts:update");return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h1",{className:"text-2xl font-bold",children:h}),W&&n.jsxs(I,{onClick:()=>d(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Neue ",f]})]}),n.jsx(Z,{className:"mb-6",children:n.jsx("div",{className:"flex gap-4 flex-wrap items-center",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-gray-600",children:"Status:"}),n.jsx(Le,{value:i,onChange:z=>l(z.target.value),options:[{value:"",label:"Alle"},...Object.entries(Cp).map(([z,P])=>({value:z,label:P}))],className:"w-40"})]})})}),x?n.jsx(Z,{children:n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."})}):n.jsx(n.Fragment,{children:s?n.jsxs("div",{className:"space-y-6",children:[n.jsxs(Z,{children:[n.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[n.jsx(hh,{className:"w-5 h-5 text-blue-600"}),n.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Meine ",h]}),n.jsx(he,{variant:"default",children:F.ownTasks.length})]}),F.ownTasks.length>0?n.jsx("div",{children:F.ownTasks.map(z=>K(z,!1))}):n.jsxs("p",{className:"text-gray-500 text-center py-4",children:["Keine eigenen ",h.toLowerCase()," vorhanden."]})]}),F.representedTasks.length>0&&n.jsxs(Z,{children:[n.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b",children:[n.jsx(Xr,{className:"w-5 h-5 text-purple-600"}),n.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:[h," freigegebener Kunden"]}),n.jsx(he,{variant:"default",children:F.representedTasks.length})]}),n.jsx("div",{children:F.representedTasks.map(z=>K(z,!0))})]})]}):n.jsx(Z,{children:F.allTasks&&F.allTasks.length>0?n.jsx("div",{children:F.allTasks.map(z=>K(z,!0))}):n.jsxs("div",{className:"text-center py-8 text-gray-500",children:["Keine ",h.toLowerCase()," gefunden."]})})}),s?n.jsx(KS,{isOpen:u,onClose:()=>d(!1)}):n.jsx(VS,{isOpen:u,onClose:()=>d(!1)})]})}function KS({isOpen:e,onClose:t}){const{user:s}=st(),r=Ut(),a=pe(),[i,l]=w.useState("own"),[o,c]=w.useState(null),[u,d]=w.useState(""),[m,p]=w.useState(""),[h,f]=w.useState(!1),[g,b]=w.useState(""),{data:y}=ge({queryKey:["contracts",s==null?void 0:s.customerId],queryFn:()=>$e.getAll({customerId:s==null?void 0:s.customerId}),enabled:e}),v=w.useMemo(()=>{if(!(y!=null&&y.data))return{own:[],represented:{}};const S=[],L={};for(const T of y.data)if(T.customerId===(s==null?void 0:s.customerId))S.push(T);else{if(!L[T.customerId]){const _=T.customer?T.customer.companyName||`${T.customer.firstName} ${T.customer.lastName}`:`Kunde ${T.customerId}`;L[T.customerId]={name:_,contracts:[]}}L[T.customerId].contracts.push(T)}return{own:S,represented:L}},[y==null?void 0:y.data,s==null?void 0:s.customerId]),x=Object.keys(v.represented).length>0,N=w.useMemo(()=>{var S;return i==="own"?v.own:((S=v.represented[i])==null?void 0:S.contracts)||[]},[i,v]),k=w.useMemo(()=>{if(!g)return N;const S=g.toLowerCase();return N.filter(L=>L.contractNumber.toLowerCase().includes(S)||(L.providerName||"").toLowerCase().includes(S)||(L.tariffName||"").toLowerCase().includes(S))},[N,g]),D=async()=>{if(!(!o||!u.trim())){f(!0);try{await Xe.createSupportTicket(o,{title:u.trim(),description:m.trim()||void 0}),a.invalidateQueries({queryKey:["all-tasks"]}),a.invalidateQueries({queryKey:["task-stats"]}),t(),d(""),p(""),c(null),l("own"),r(`/contracts/${o}`)}catch(S){console.error("Fehler beim Erstellen der Support-Anfrage:",S),alert("Fehler beim Erstellen der Support-Anfrage. Bitte versuchen Sie es erneut.")}finally{f(!1)}}},F=()=>{d(""),p(""),c(null),l("own"),b(""),t()};return n.jsx(dt,{isOpen:e,onClose:F,title:"Neue Support-Anfrage",children:n.jsxs("div",{className:"space-y-4",children:[x&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde"}),n.jsxs("select",{value:i,onChange:S=>{const L=S.target.value;l(L==="own"?"own":parseInt(L)),c(null),b("")},className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500",children:[n.jsx("option",{value:"own",children:"Eigene Verträge"}),Object.entries(v.represented).map(([S,{name:L}])=>n.jsx("option",{value:S,children:L},S))]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),n.jsx($,{placeholder:"Vertrag suchen...",value:g,onChange:S=>b(S.target.value),className:"mb-2"}),n.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-lg",children:k.length>0?k.map(S=>n.jsxs("div",{onClick:()=>c(S.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${o===S.id?"bg-blue-50 border-blue-200":""}`,children:[n.jsx("div",{className:"font-medium",children:S.contractNumber}),n.jsxs("div",{className:"text-sm text-gray-500",children:[S.providerName||"Kein Anbieter",S.tariffName&&` - ${S.tariffName}`]})]},S.id)):n.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Verträge gefunden."})})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),n.jsx($,{value:u,onChange:S=>d(S.target.value),placeholder:"Kurze Beschreibung Ihres Anliegens"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),n.jsx("textarea",{value:m,onChange:S=>p(S.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"})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[n.jsx(I,{variant:"secondary",onClick:F,children:"Abbrechen"}),n.jsx(I,{onClick:D,disabled:!o||!u.trim()||h,children:h?"Wird erstellt...":"Anfrage erstellen"})]})]})})}function VS({isOpen:e,onClose:t}){const s=Ut(),r=pe(),[a,i]=w.useState(null),[l,o]=w.useState(null),[c,u]=w.useState(""),[d,m]=w.useState(""),[p,h]=w.useState(!1),[f,g]=w.useState(!1),[b,y]=w.useState(""),[v,x]=w.useState(""),{data:N}=ge({queryKey:["customers-for-task"],queryFn:()=>yt.getAll({limit:100}),enabled:e}),{data:k}=ge({queryKey:["contracts-for-task",a],queryFn:()=>$e.getAll({customerId:a}),enabled:e&&a!==null}),D=w.useMemo(()=>{if(!(N!=null&&N.data))return[];if(!b)return N.data;const _=b.toLowerCase();return N.data.filter(K=>K.customerNumber.toLowerCase().includes(_)||K.firstName.toLowerCase().includes(_)||K.lastName.toLowerCase().includes(_)||(K.companyName||"").toLowerCase().includes(_))},[N==null?void 0:N.data,b]),F=w.useMemo(()=>{if(!(k!=null&&k.data))return[];if(!v)return k.data;const _=v.toLowerCase();return k.data.filter(K=>K.contractNumber.toLowerCase().includes(_)||(K.providerName||"").toLowerCase().includes(_)||(K.tariffName||"").toLowerCase().includes(_))},[k==null?void 0:k.data,v]),S=async()=>{if(!(!l||!c.trim())){g(!0);try{await Xe.create(l,{title:c.trim(),description:d.trim()||void 0,visibleInPortal:p}),r.invalidateQueries({queryKey:["all-tasks"]}),r.invalidateQueries({queryKey:["task-stats"]}),t(),u(""),m(""),h(!1),o(null),i(null),s(`/contracts/${l}`)}catch(_){console.error("Fehler beim Erstellen der Aufgabe:",_),alert("Fehler beim Erstellen der Aufgabe. Bitte versuchen Sie es erneut.")}finally{g(!1)}}},L=()=>{u(""),m(""),h(!1),o(null),i(null),y(""),x(""),t()},T=_=>{const K=_.companyName||`${_.firstName} ${_.lastName}`;return`${_.customerNumber} - ${K}`};return n.jsx(dt,{isOpen:e,onClose:L,title:"Neue Aufgabe",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kunde *"}),n.jsx($,{placeholder:"Kunde suchen...",value:b,onChange:_=>y(_.target.value),className:"mb-2"}),n.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:D.length>0?D.map(_=>n.jsx("div",{onClick:()=>{i(_.id),o(null),x("")},className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${a===_.id?"bg-blue-50 border-blue-200":""}`,children:n.jsx("div",{className:"font-medium",children:T(_)})},_.id)):n.jsx("div",{className:"p-3 text-gray-500 text-center",children:"Keine Kunden gefunden."})})]}),a&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Vertrag *"}),n.jsx($,{placeholder:"Vertrag suchen...",value:v,onChange:_=>x(_.target.value),className:"mb-2"}),n.jsx("div",{className:"max-h-40 overflow-y-auto border rounded-lg",children:F.length>0?F.map(_=>n.jsxs("div",{onClick:()=>o(_.id),className:`p-3 cursor-pointer border-b last:border-b-0 hover:bg-gray-50 ${l===_.id?"bg-blue-50 border-blue-200":""}`,children:[n.jsx("div",{className:"font-medium",children:_.contractNumber}),n.jsxs("div",{className:"text-sm text-gray-500",children:[_.providerName||"Kein Anbieter",_.tariffName&&` - ${_.tariffName}`]})]},_.id)):n.jsx("div",{className:"p-3 text-gray-500 text-center",children:k?"Keine Verträge gefunden.":"Laden..."})})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Titel *"}),n.jsx($,{value:c,onChange:_=>u(_.target.value),placeholder:"Aufgabentitel"})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Beschreibung"}),n.jsx("textarea",{value:d,onChange:_=>m(_.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"})]}),n.jsx("div",{children:n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:p,onChange:_=>h(_.target.checked),className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500"}),n.jsx("span",{className:"text-sm text-gray-700",children:"Im Kundenportal sichtbar"})]})}),n.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[n.jsx(I,{variant:"secondary",onClick:L,children:"Abbrechen"}),n.jsx(I,{onClick:S,disabled:!l||!c.trim()||f,children:f?"Wird erstellt...":"Aufgabe erstellen"})]})]})})}function qS(){const[e,t]=w.useState(!1),[s,r]=w.useState(null),[a,i]=w.useState(!1),{hasPermission:l}=st(),o=pe(),{data:c,isLoading:u}=ge({queryKey:["platforms",a],queryFn:()=>Pi.getAll(a)}),d=Y({mutationFn:Pi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["platforms"]})}}),m=h=>{r(h),t(!0)},p=()=>{t(!1),r(null)};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Vertriebsplattformen"}),l("platforms:create")&&n.jsxs(I,{onClick:()=>t(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Neue Plattform"]})]}),n.jsxs(Z,{children:[n.jsx("div",{className:"mb-4",children:n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"checkbox",checked:a,onChange:h=>i(h.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),u?n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b",children:[n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Kontakt"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),n.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),n.jsx("tbody",{children:c.data.map(h=>n.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[n.jsx("td",{className:"py-3 px-4 font-medium",children:h.name}),n.jsx("td",{className:"py-3 px-4 text-gray-500",children:h.contactInfo||"-"}),n.jsx("td",{className:"py-3 px-4",children:n.jsx(he,{variant:h.isActive?"success":"danger",children:h.isActive?"Aktiv":"Inaktiv"})}),n.jsx("td",{className:"py-3 px-4 text-right",children:n.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>m(h),children:n.jsx(We,{className:"w-4 h-4"})}),l("platforms:delete")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Plattform wirklich löschen?")&&d.mutate(h.id)},children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},h.id))})]})}):n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Plattformen vorhanden."})]}),n.jsx(QS,{isOpen:e,onClose:p,platform:s})]})}function QS({isOpen:e,onClose:t,platform:s}){const r=pe(),[a,i]=w.useState({name:"",contactInfo:"",isActive:!0});w.useState(()=>{i(s?{name:s.name,contactInfo:s.contactInfo||"",isActive:s.isActive}:{name:"",contactInfo:"",isActive:!0})}),s&&a.name!==s.name?i({name:s.name,contactInfo:s.contactInfo||"",isActive:s.isActive}):!s&&a.name;const l=Y({mutationFn:Pi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t(),i({name:"",contactInfo:"",isActive:!0})}}),o=Y({mutationFn:d=>Pi.update(s.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["platforms"]}),t()}}),c=d=>{d.preventDefault(),s?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return n.jsx(dt,{isOpen:e,onClose:t,title:s?"Plattform bearbeiten":"Neue Plattform",children:n.jsxs("form",{onSubmit:c,className:"space-y-4",children:[n.jsx($,{label:"Name *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Kontaktinformationen"}),n.jsx("textarea",{value:a.contactInfo,onChange:d=>i({...a,contactInfo:d.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..."})]}),s&&n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function HS(){const[e,t]=w.useState(!1),[s,r]=w.useState(null),[a,i]=w.useState(!1),{hasPermission:l}=st(),o=pe(),{data:c,isLoading:u}=ge({queryKey:["cancellation-periods",a],queryFn:()=>Ai.getAll(a)}),d=Y({mutationFn:Ai.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["cancellation-periods"]})}}),m=h=>{r(h),t(!0)},p=()=>{t(!1),r(null)};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[n.jsx(Se,{to:"/settings",children:n.jsx(I,{variant:"ghost",size:"sm",children:n.jsx($s,{className:"w-4 h-4"})})}),n.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Kündigungsfristen"}),l("platforms:create")&&n.jsxs(I,{onClick:()=>t(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Neue Frist"]})]}),n.jsxs(Z,{children:[n.jsx("div",{className:"mb-4",children:n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"checkbox",checked:a,onChange:h=>i(h.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),n.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[n.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",n.jsx("br",{}),n.jsx("strong",{children:"Beispiele:"})," 14T = 14 Tage, 3M = 3 Monate, 1J = 1 Jahr"]}),u?n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b",children:[n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),n.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),n.jsx("tbody",{children:c.data.map(h=>n.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[n.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:h.code}),n.jsx("td",{className:"py-3 px-4",children:h.description}),n.jsx("td",{className:"py-3 px-4",children:n.jsx(he,{variant:h.isActive?"success":"danger",children:h.isActive?"Aktiv":"Inaktiv"})}),n.jsx("td",{className:"py-3 px-4 text-right",children:n.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>m(h),children:n.jsx(We,{className:"w-4 h-4"})}),l("platforms:delete")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Kündigungsfrist wirklich löschen?")&&d.mutate(h.id)},children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},h.id))})]})}):n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Kündigungsfristen vorhanden."})]}),n.jsx(WS,{isOpen:e,onClose:p,period:s})]})}function WS({isOpen:e,onClose:t,period:s}){const r=pe(),[a,i]=w.useState({code:"",description:"",isActive:!0});w.useEffect(()=>{e&&i(s?{code:s.code,description:s.description,isActive:s.isActive}:{code:"",description:"",isActive:!0})},[e,s]);const l=Y({mutationFn:Ai.create,onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t(),i({code:"",description:"",isActive:!0})}}),o=Y({mutationFn:d=>Ai.update(s.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["cancellation-periods"]}),t()}}),c=d=>{d.preventDefault(),s?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return n.jsx(dt,{isOpen:e,onClose:t,title:s?"Kündigungsfrist bearbeiten":"Neue Kündigungsfrist",children:n.jsxs("form",{onSubmit:c,className:"space-y-4",children:[n.jsx($,{label:"Code *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 14T, 3M, 1J"}),n.jsx($,{label:"Beschreibung *",value:a.description,onChange:d=>i({...a,description:d.target.value}),required:!0,placeholder:"z.B. 14 Tage, 3 Monate, 1 Jahr"}),s&&n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function GS(){const[e,t]=w.useState(!1),[s,r]=w.useState(null),[a,i]=w.useState(!1),{hasPermission:l}=st(),o=pe(),{data:c,isLoading:u}=ge({queryKey:["contract-durations",a],queryFn:()=>Ti.getAll(a)}),d=Y({mutationFn:Ti.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-durations"]})}}),m=h=>{r(h),t(!0)},p=()=>{t(!1),r(null)};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[n.jsx(Se,{to:"/settings",children:n.jsx(I,{variant:"ghost",size:"sm",children:n.jsx($s,{className:"w-4 h-4"})})}),n.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragslaufzeiten"}),l("platforms:create")&&n.jsxs(I,{onClick:()=>t(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Neue Laufzeit"]})]}),n.jsxs(Z,{children:[n.jsx("div",{className:"mb-4",children:n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"checkbox",checked:a,onChange:h=>i(h.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),n.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg text-sm",children:[n.jsx("strong",{children:"Code-Format:"})," Zahl + Buchstabe (T=Tage, M=Monate, J=Jahre)",n.jsx("br",{}),n.jsx("strong",{children:"Beispiele:"})," 12M = 12 Monate, 24M = 24 Monate, 2J = 2 Jahre"]}),u?n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b",children:[n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Code"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Beschreibung"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),n.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),n.jsx("tbody",{children:c.data.map(h=>n.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[n.jsx("td",{className:"py-3 px-4 font-mono font-medium",children:h.code}),n.jsx("td",{className:"py-3 px-4",children:h.description}),n.jsx("td",{className:"py-3 px-4",children:n.jsx(he,{variant:h.isActive?"success":"danger",children:h.isActive?"Aktiv":"Inaktiv"})}),n.jsx("td",{className:"py-3 px-4 text-right",children:n.jsxs("div",{className:"flex justify-end gap-2",children:[l("platforms:update")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>m(h),children:n.jsx(We,{className:"w-4 h-4"})}),l("platforms:delete")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Laufzeit wirklich löschen?")&&d.mutate(h.id)},children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},h.id))})]})}):n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Laufzeiten vorhanden."})]}),n.jsx(ZS,{isOpen:e,onClose:p,duration:s})]})}function ZS({isOpen:e,onClose:t,duration:s}){const r=pe(),[a,i]=w.useState({code:"",description:"",isActive:!0});w.useEffect(()=>{e&&i(s?{code:s.code,description:s.description,isActive:s.isActive}:{code:"",description:"",isActive:!0})},[e,s]);const l=Y({mutationFn:Ti.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t(),i({code:"",description:"",isActive:!0})}}),o=Y({mutationFn:d=>Ti.update(s.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-durations"]}),t()}}),c=d=>{d.preventDefault(),s?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return n.jsx(dt,{isOpen:e,onClose:t,title:s?"Laufzeit bearbeiten":"Neue Laufzeit",children:n.jsxs("form",{onSubmit:c,className:"space-y-4",children:[n.jsx($,{label:"Code *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase()}),required:!0,placeholder:"z.B. 12M, 24M, 2J"}),n.jsx($,{label:"Beschreibung *",value:a.description,onChange:d=>i({...a,description:d.target.value}),required:!0,placeholder:"z.B. 12 Monate, 24 Monate, 2 Jahre"}),s&&n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function YS(){const[e,t]=w.useState(!1),[s,r]=w.useState(null),[a,i]=w.useState(!1),[l,o]=w.useState(new Set),{hasPermission:c}=st(),u=pe(),{data:d,isLoading:m}=ge({queryKey:["providers",a],queryFn:()=>Na.getAll(a)}),p=Y({mutationFn:Na.delete,onSuccess:()=>{u.invalidateQueries({queryKey:["providers"]})},onError:b=>{alert(b.message)}}),h=b=>{o(y=>{const v=new Set(y);return v.has(b)?v.delete(b):v.add(b),v})},f=b=>{r(b),t(!0)},g=()=>{t(!1),r(null)};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[n.jsx(Se,{to:"/settings",children:n.jsx(I,{variant:"ghost",size:"sm",children:n.jsx($s,{className:"w-4 h-4"})})}),n.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Anbieter & Tarife"}),c("providers:create")&&n.jsxs(I,{onClick:()=>t(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Neuer Anbieter"]})]}),n.jsxs(Z,{children:[n.jsx("div",{className:"mb-4",children:n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"checkbox",checked:a,onChange:b=>i(b.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),m?n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):d!=null&&d.data&&d.data.length>0?n.jsx("div",{className:"space-y-2",children:d.data.map(b=>n.jsx(JS,{provider:b,isExpanded:l.has(b.id),onToggle:()=>h(b.id),onEdit:()=>f(b),onDelete:()=>{confirm("Anbieter wirklich löschen?")&&p.mutate(b.id)},hasPermission:c,showInactive:a},b.id))}):n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Anbieter vorhanden."})]}),n.jsx(XS,{isOpen:e,onClose:g,provider:s})]})}function JS({provider:e,isExpanded:t,onToggle:s,onEdit:r,onDelete:a,hasPermission:i,showInactive:l}){var f,g;const[o,c]=w.useState(!1),[u,d]=w.useState(null),m=pe(),p=Y({mutationFn:$y.delete,onSuccess:()=>{m.invalidateQueries({queryKey:["providers"]})},onError:b=>{alert(b.message)}}),h=((f=e.tariffs)==null?void 0:f.filter(b=>l||b.isActive))||[];return n.jsxs("div",{className:"border rounded-lg",children:[n.jsxs("div",{className:"flex items-center p-4 hover:bg-gray-50",children:[n.jsx("button",{onClick:s,className:"mr-3 p-1 hover:bg-gray-200 rounded",children:t?n.jsx(Qo,{className:"w-5 h-5 text-gray-400"}):n.jsx(Ys,{className:"w-5 h-5 text-gray-400"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"font-medium",children:e.name}),n.jsx(he,{variant:e.isActive?"success":"danger",children:e.isActive?"Aktiv":"Inaktiv"}),n.jsxs("span",{className:"text-sm text-gray-500",children:["(",h.length," Tarife, ",((g=e._count)==null?void 0:g.contracts)||0," Verträge)"]})]}),e.portalUrl&&n.jsxs("a",{href:e.portalUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:underline flex items-center gap-1 mt-1",children:[n.jsx(Yy,{className:"w-3 h-3"}),e.portalUrl]})]}),n.jsxs("div",{className:"flex gap-2 ml-4",children:[i("providers:update")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:r,title:"Bearbeiten",children:n.jsx(We,{className:"w-4 h-4"})}),i("providers:delete")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:a,title:"Löschen",children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]}),t&&n.jsxs("div",{className:"border-t bg-gray-50 p-4",children:[n.jsxs("div",{className:"flex justify-between items-center mb-3",children:[n.jsx("h4",{className:"font-medium text-gray-700",children:"Tarife"}),i("providers:create")&&n.jsxs(I,{size:"sm",onClick:()=>c(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-1"}),"Tarif hinzufügen"]})]}),h.length>0?n.jsx("div",{className:"space-y-2",children:h.map(b=>{var y;return n.jsxs("div",{className:"flex items-center justify-between bg-white p-3 rounded border",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{children:b.name}),n.jsx(he,{variant:b.isActive?"success":"danger",className:"text-xs",children:b.isActive?"Aktiv":"Inaktiv"}),((y=b._count)==null?void 0:y.contracts)!==void 0&&n.jsxs("span",{className:"text-xs text-gray-500",children:["(",b._count.contracts," Verträge)"]})]}),n.jsxs("div",{className:"flex gap-1",children:[i("providers:update")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{d(b),c(!0)},title:"Bearbeiten",children:n.jsx(We,{className:"w-3 h-3"})}),i("providers:delete")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Tarif wirklich löschen?")&&p.mutate(b.id)},title:"Löschen",children:n.jsx(be,{className:"w-3 h-3 text-red-500"})})]})]},b.id)})}):n.jsx("p",{className:"text-sm text-gray-500",children:"Keine Tarife vorhanden."})]}),n.jsx(e2,{isOpen:o,onClose:()=>{c(!1),d(null)},providerId:e.id,tariff:u})]})}function XS({isOpen:e,onClose:t,provider:s}){const r=pe(),[a,i]=w.useState({name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0});w.useEffect(()=>{e&&i(s?{name:s.name,portalUrl:s.portalUrl||"",usernameFieldName:s.usernameFieldName||"",passwordFieldName:s.passwordFieldName||"",isActive:s.isActive}:{name:"",portalUrl:"",usernameFieldName:"",passwordFieldName:"",isActive:!0})},[e,s]);const l=Y({mutationFn:Na.create,onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:d=>{alert(d.message)}}),o=Y({mutationFn:d=>Na.update(s.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["providers"]}),t()},onError:d=>{alert(d.message)}}),c=d=>{d.preventDefault(),s?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return n.jsx(dt,{isOpen:e,onClose:t,title:s?"Anbieter bearbeiten":"Neuer Anbieter",children:n.jsxs("form",{onSubmit:c,className:"space-y-4",children:[n.jsx($,{label:"Anbietername *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0,placeholder:"z.B. Vodafone, E.ON, Allianz"}),n.jsx($,{label:"Portal-URL (Login-Seite)",value:a.portalUrl,onChange:d=>i({...a,portalUrl:d.target.value}),placeholder:"https://kundenportal.anbieter.de/login"}),n.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg space-y-3",children:[n.jsxs("p",{className:"text-sm text-gray-600",children:[n.jsx("strong",{children:"Auto-Login Felder"})," (optional)",n.jsx("br",{}),"Feldnamen für URL-Parameter beim Auto-Login:"]}),n.jsx($,{label:"Benutzername-Feldname",value:a.usernameFieldName,onChange:d=>i({...a,usernameFieldName:d.target.value}),placeholder:"z.B. username, email, login"}),n.jsx($,{label:"Passwort-Feldname",value:a.passwordFieldName,onChange:d=>i({...a,passwordFieldName:d.target.value}),placeholder:"z.B. password, pwd, kennwort"})]}),s&&n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}function e2({isOpen:e,onClose:t,providerId:s,tariff:r}){const a=pe(),[i,l]=w.useState({name:"",isActive:!0});w.useEffect(()=>{e&&l(r?{name:r.name,isActive:r.isActive}:{name:"",isActive:!0})},[e,r]);const o=Y({mutationFn:m=>Na.createTariff(s,m),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:m=>{alert(m.message)}}),c=Y({mutationFn:m=>$y.update(r.id,m),onSuccess:()=>{a.invalidateQueries({queryKey:["providers"]}),t()},onError:m=>{alert(m.message)}}),u=m=>{m.preventDefault(),r?c.mutate(i):o.mutate(i)},d=o.isPending||c.isPending;return n.jsx(dt,{isOpen:e,onClose:t,title:r?"Tarif bearbeiten":"Neuer Tarif",children:n.jsxs("form",{onSubmit:u,className:"space-y-4",children:[n.jsx($,{label:"Tarifname *",value:i.name,onChange:m=>l({...i,name:m.target.value}),required:!0,placeholder:"z.B. Comfort Plus, Basic 100"}),r&&n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:i.isActive,onChange:m=>l({...i,isActive:m.target.checked}),className:"rounded"}),"Aktiv"]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:d,children:d?"Speichern...":"Speichern"})]})]})})}const sd={Zap:n.jsx(mh,{className:"w-5 h-5"}),Flame:n.jsx(Jy,{className:"w-5 h-5"}),Wifi:n.jsx(ea,{className:"w-5 h-5"}),Cable:n.jsx(m1,{className:"w-5 h-5"}),Smartphone:n.jsx(dh,{className:"w-5 h-5"}),Tv:n.jsx(sv,{className:"w-5 h-5"}),Car:n.jsx(Hy,{className:"w-5 h-5"}),FileText:n.jsx(vt,{className:"w-5 h-5"})},t2=[{value:"Zap",label:"Blitz (Strom)"},{value:"Flame",label:"Flamme (Gas)"},{value:"Wifi",label:"WLAN (DSL)"},{value:"Cable",label:"Kabel (Glasfaser)"},{value:"Smartphone",label:"Smartphone (Mobilfunk)"},{value:"Tv",label:"TV"},{value:"Car",label:"Auto (KFZ)"},{value:"FileText",label:"Dokument (Sonstige)"}],s2=[{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 n2(){const[e,t]=w.useState(!1),[s,r]=w.useState(null),[a,i]=w.useState(!1),{hasPermission:l}=st(),o=pe(),{data:c,isLoading:u}=ge({queryKey:["contract-categories",a],queryFn:()=>Fi.getAll(a)}),d=Y({mutationFn:Fi.delete,onSuccess:()=>{o.invalidateQueries({queryKey:["contract-categories"]})},onError:h=>{alert(h.message)}}),m=h=>{r(h),t(!0)},p=()=>{t(!1),r(null)};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[n.jsx(Se,{to:"/settings",children:n.jsx(I,{variant:"ghost",size:"sm",children:n.jsx($s,{className:"w-4 h-4"})})}),n.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Vertragstypen"}),l("platforms:create")&&n.jsxs(I,{onClick:()=>t(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Neuer Vertragstyp"]})]}),n.jsxs(Z,{children:[n.jsx("div",{className:"mb-4",children:n.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[n.jsx("input",{type:"checkbox",checked:a,onChange:h=>i(h.target.checked),className:"rounded"}),"Inaktive anzeigen"]})}),u?n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):c!=null&&c.data&&c.data.length>0?n.jsx("div",{className:"space-y-2",children:c.data.map(h=>{var f;return n.jsxs("div",{className:"flex items-center p-4 border rounded-lg hover:bg-gray-50",children:[n.jsx("div",{className:"mr-3 text-gray-400",children:n.jsx(x1,{className:"w-5 h-5"})}),n.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center mr-4",style:{backgroundColor:h.color||"#E5E7EB",color:"#fff"},children:h.icon&&sd[h.icon]?sd[h.icon]:n.jsx(vt,{className:"w-5 h-5"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"font-medium",children:h.name}),n.jsx(he,{variant:h.isActive?"success":"danger",children:h.isActive?"Aktiv":"Inaktiv"}),n.jsxs("span",{className:"text-sm text-gray-500",children:["(",((f=h._count)==null?void 0:f.contracts)||0," Verträge)"]})]}),n.jsxs("div",{className:"text-sm text-gray-500",children:["Code: ",n.jsx("span",{className:"font-mono",children:h.code})]})]}),n.jsxs("div",{className:"flex gap-2 ml-4",children:[l("platforms:update")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>m(h),title:"Bearbeiten",children:n.jsx(We,{className:"w-4 h-4"})}),l("platforms:delete")&&n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>{confirm("Vertragstyp wirklich löschen?")&&d.mutate(h.id)},title:"Löschen",children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]},h.id)})}):n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Vertragstypen vorhanden."})]}),n.jsx(r2,{isOpen:e,onClose:p,category:s})]})}function r2({isOpen:e,onClose:t,category:s}){const r=pe(),[a,i]=w.useState({code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0});w.useEffect(()=>{e&&i(s?{code:s.code,name:s.name,icon:s.icon||"FileText",color:s.color||"#607D8B",sortOrder:s.sortOrder,isActive:s.isActive}:{code:"",name:"",icon:"FileText",color:"#607D8B",sortOrder:0,isActive:!0})},[e,s]);const l=Y({mutationFn:Fi.create,onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:d=>{alert(d.message)}}),o=Y({mutationFn:d=>Fi.update(s.id,d),onSuccess:()=>{r.invalidateQueries({queryKey:["contract-categories"]}),t()},onError:d=>{alert(d.message)}}),c=d=>{d.preventDefault(),s?o.mutate(a):l.mutate(a)},u=l.isPending||o.isPending;return n.jsx(dt,{isOpen:e,onClose:t,title:s?"Vertragstyp bearbeiten":"Neuer Vertragstyp",children:n.jsxs("form",{onSubmit:c,className:"space-y-4",children:[n.jsx($,{label:"Code (technisch) *",value:a.code,onChange:d=>i({...a,code:d.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"")}),required:!0,placeholder:"z.B. ELECTRICITY, MOBILE_BUSINESS",disabled:!!s}),n.jsx($,{label:"Anzeigename *",value:a.name,onChange:d=>i({...a,name:d.target.value}),required:!0,placeholder:"z.B. Strom, Mobilfunk Business"}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Icon"}),n.jsx("div",{className:"grid grid-cols-4 gap-2",children:t2.map(d=>n.jsxs("button",{type:"button",onClick:()=>i({...a,icon:d.value}),className:`p-3 border rounded-lg flex flex-col items-center gap-1 text-xs ${a.icon===d.value?"border-blue-500 bg-blue-50":"border-gray-200 hover:bg-gray-50"}`,children:[sd[d.value],n.jsx("span",{className:"truncate w-full text-center",children:d.label.split(" ")[0]})]},d.value))})]}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Farbe"}),n.jsx("div",{className:"flex flex-wrap gap-2",children:s2.map(d=>n.jsx("button",{type:"button",onClick:()=>i({...a,color:d.value}),className:`w-8 h-8 rounded-full border-2 ${a.color===d.value?"border-gray-800 ring-2 ring-offset-2 ring-gray-400":"border-transparent"}`,style:{backgroundColor:d.value},title:d.label},d.value))})]}),n.jsx($,{label:"Sortierung",type:"number",value:a.sortOrder,onChange:d=>i({...a,sortOrder:parseInt(d.target.value)||0}),placeholder:"0"}),s&&n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:a.isActive,onChange:d=>i({...a,isActive:d.target.checked}),className:"rounded"}),"Aktiv"]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:u,children:u?"Speichern...":"Speichern"})]})]})})}const a2=[{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 i2(){const{settings:e,updateSettings:t}=Vy();return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[n.jsx(Se,{to:"/settings",className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:n.jsx($s,{className:"w-5 h-5"})}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Ee,{className:"w-6 h-6"}),n.jsx("h1",{className:"text-2xl font-bold",children:"Ansicht"})]})]}),n.jsx(Z,{title:"Scroll-Verhalten",children:n.jsx("div",{className:"space-y-6",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-medium",children:"Nach-oben-Button"}),n.jsx("p",{className:"text-sm text-gray-500",children:"Ab welcher Scroll-Position der Button unten rechts erscheinen soll"})]}),n.jsx("div",{className:"w-48",children:n.jsx(Le,{options:a2,value:e.scrollToTopThreshold.toString(),onChange:s=>t({scrollToTopThreshold:parseFloat(s.target.value)})})})]})})})]})}function l2(){const e=pe(),{data:t,isLoading:s}=ge({queryKey:["app-settings"],queryFn:()=>Sr.getAll()}),[r,a]=w.useState(!1);w.useEffect(()=>{t!=null&&t.data&&a(t.data.customerSupportTicketsEnabled==="true")},[t]);const i=Y({mutationFn:o=>Sr.update(o),onSuccess:()=>{e.invalidateQueries({queryKey:["app-settings"]}),e.invalidateQueries({queryKey:["app-settings-public"]})}}),l=o=>{a(o),i.mutate({customerSupportTicketsEnabled:o?"true":"false"})};return s?n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx("div",{className:"text-gray-500",children:"Laden..."})}):n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[n.jsx(Se,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:n.jsx($s,{className:"w-5 h-5"})}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(uh,{className:"w-6 h-6"}),n.jsx("h1",{className:"text-2xl font-bold",children:"Kundenportal"})]})]}),n.jsxs(Z,{title:"Support-Anfragen",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Mi,{className:"w-5 h-5 text-gray-500"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-medium",children:"Kunden können Support-Anfragen erstellen"}),n.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."})]})]}),n.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:r,onChange:o=>l(o.target.checked),disabled:i.isPending,className:"sr-only peer"}),n.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"})]})]}),r&&n.jsx("div",{className:"mt-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:n.jsxs("p",{className:"text-sm text-blue-800",children:[n.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 o2(){const e=pe(),{data:t,isLoading:s}=ge({queryKey:["app-settings"],queryFn:()=>Sr.getAll()}),[r,a]=w.useState("14"),[i,l]=w.useState("42"),[o,c]=w.useState("90"),[u,d]=w.useState(!1);w.useEffect(()=>{t!=null&&t.data&&(a(t.data.deadlineCriticalDays||"14"),l(t.data.deadlineWarningDays||"42"),c(t.data.deadlineOkDays||"90"),d(!1))},[t]);const m=Y({mutationFn:f=>Sr.update(f),onSuccess:()=>{e.invalidateQueries({queryKey:["app-settings"]}),e.invalidateQueries({queryKey:["contract-cockpit"]}),d(!1)}}),p=()=>{const f=parseInt(r),g=parseInt(i),b=parseInt(o);if(isNaN(f)||isNaN(g)||isNaN(b)){alert("Bitte gültige Zahlen eingeben");return}if(f>=g||g>=b){alert("Die Werte müssen aufsteigend sein: Kritisch < Warnung < OK");return}m.mutate({deadlineCriticalDays:r,deadlineWarningDays:i,deadlineOkDays:o})},h=(f,g)=>{f(g),d(!0)};return s?n.jsx("div",{className:"flex items-center justify-center py-12",children:n.jsx("div",{className:"text-gray-500",children:"Laden..."})}):n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[n.jsx(Se,{to:"/settings",className:"text-gray-500 hover:text-gray-700",children:n.jsx($s,{className:"w-5 h-5"})}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(qn,{className:"w-6 h-6"}),n.jsx("h1",{className:"text-2xl font-bold",children:"Fristenschwellen"})]})]}),n.jsxs(Z,{title:"Farbkodierung für Fristen",children:[n.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."}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center gap-4 p-4 bg-red-50 border border-red-200 rounded-lg",children:[n.jsx(en,{className:"w-8 h-8 text-red-500 flex-shrink-0"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("label",{className:"block font-medium text-red-800 mb-1",children:"Kritisch (Rot)"}),n.jsx("p",{className:"text-sm text-red-600 mb-2",children:"Fristen mit weniger als X Tagen werden rot markiert"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx($,{type:"number",min:"1",value:r,onChange:f=>h(a,f.target.value),className:"w-24"}),n.jsx("span",{className:"text-red-700",children:"Tage"})]})]})]}),n.jsxs("div",{className:"flex items-center gap-4 p-4 bg-yellow-50 border border-yellow-200 rounded-lg",children:[n.jsx(Li,{className:"w-8 h-8 text-yellow-500 flex-shrink-0"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("label",{className:"block font-medium text-yellow-800 mb-1",children:"Warnung (Gelb)"}),n.jsx("p",{className:"text-sm text-yellow-600 mb-2",children:"Fristen mit weniger als X Tagen werden gelb markiert"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx($,{type:"number",min:"1",value:i,onChange:f=>h(l,f.target.value),className:"w-24"}),n.jsx("span",{className:"text-yellow-700",children:"Tage"})]})]})]}),n.jsxs("div",{className:"flex items-center gap-4 p-4 bg-green-50 border border-green-200 rounded-lg",children:[n.jsx(hs,{className:"w-8 h-8 text-green-500 flex-shrink-0"}),n.jsxs("div",{className:"flex-1",children:[n.jsx("label",{className:"block font-medium text-green-800 mb-1",children:"OK (Grün)"}),n.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)"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx($,{type:"number",min:"1",value:o,onChange:f=>h(c,f.target.value),className:"w-24"}),n.jsx("span",{className:"text-green-700",children:"Tage"})]})]})]})]}),n.jsxs("div",{className:"mt-6 pt-4 border-t flex justify-between items-center",children:[n.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."}),n.jsx(I,{onClick:p,disabled:!u||m.isPending,children:m.isPending?"Speichere...":"Speichern"})]})]})]})}const c2=[{value:"PLESK",label:"Plesk"},{value:"CPANEL",label:"cPanel"},{value:"DIRECTADMIN",label:"DirectAdmin"}],Lc={name:"",type:"PLESK",apiUrl:"",apiKey:"",username:"",password:"",domain:"stressfrei-wechseln.de",defaultForwardEmail:"",isActive:!0,isDefault:!1};function u2(){const e=Ut(),t=pe(),[s,r]=w.useState(!1),[a,i]=w.useState(null),[l,o]=w.useState(Lc),[c,u]=w.useState(!1),[d,m]=w.useState(null),[p,h]=w.useState(!1),[f,g]=w.useState({}),[b,y]=w.useState(null),{data:v,isLoading:x}=ge({queryKey:["email-provider-configs"],queryFn:()=>xn.getConfigs()}),N=Y({mutationFn:P=>xn.createConfig(P),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),T()}}),k=Y({mutationFn:({id:P,data:j})=>xn.updateConfig(P,j),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]}),T()}}),D=Y({mutationFn:P=>xn.deleteConfig(P),onSuccess:()=>{t.invalidateQueries({queryKey:["email-provider-configs"]})}}),F=(v==null?void 0:v.data)||[],S=()=>{o(Lc),i(null),u(!1),m(null),r(!0)},L=P=>{o({name:P.name,type:P.type,apiUrl:P.apiUrl,apiKey:P.apiKey||"",username:P.username||"",password:"",domain:P.domain,defaultForwardEmail:P.defaultForwardEmail||"",isActive:P.isActive,isDefault:P.isDefault}),i(P.id),u(!1),m(null),r(!0)},T=()=>{r(!1),i(null),o(Lc),u(!1),m(null)},_=async P=>{var j,B,J;y(P.id),g(ee=>({...ee,[P.id]:null}));try{const ee=await xn.testConnection({id:P.id}),me={success:((j=ee.data)==null?void 0:j.success)||!1,message:(B=ee.data)==null?void 0:B.message,error:(J=ee.data)==null?void 0:J.error};g(ve=>({...ve,[P.id]:me}))}catch(ee){g(me=>({...me,[P.id]:{success:!1,error:ee instanceof Error?ee.message:"Unbekannter Fehler beim Testen"}}))}finally{y(null)}},K=async()=>{var P,j,B;if(!l.apiUrl||!l.domain){m({success:!1,error:"Bitte geben Sie API-URL und Domain ein."});return}if(a&&!l.password&&!l.apiKey){m({success:!1,error:"Um die Verbindung zu testen, geben Sie bitte entweder einen API-Key oder das Passwort ein."});return}if(!a&&!l.apiKey&&(!l.username||!l.password)){m({success:!1,error:"Bitte geben Sie entweder einen API-Key oder Benutzername und Passwort ein."});return}h(!0),m(null);try{const J=await xn.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}});m({success:((P=J.data)==null?void 0:P.success)||!1,message:(j=J.data)==null?void 0:j.message,error:(B=J.data)==null?void 0:B.error})}catch(J){m({success:!1,error:J instanceof Error?J.message:"Unbekannter Fehler beim Verbindungstest"})}finally{h(!1)}},W=P=>{P.preventDefault();const j={name:l.name,type:l.type,apiUrl:l.apiUrl,apiKey:l.apiKey||void 0,username:l.username||void 0,domain:l.domain,defaultForwardEmail:l.defaultForwardEmail||void 0,isActive:l.isActive,isDefault:l.isDefault};l.password&&(j.password=l.password),a?k.mutate({id:a,data:j}):N.mutate(j)},Q=(P,j)=>{confirm(`Möchten Sie den Provider "${j}" wirklich löschen?`)&&D.mutate(P)},z=P=>P.error?P.error:P.message?P.message:"Verbindung fehlgeschlagen";return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[n.jsxs(I,{variant:"ghost",onClick:()=>e("/settings"),children:[n.jsx($s,{className:"w-4 h-4 mr-2"}),"Zurück"]}),n.jsx("h1",{className:"text-2xl font-bold",children:"Email-Provisionierung"})]}),n.jsxs(Z,{className:"mb-6",children:[n.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.'}),n.jsxs(I,{onClick:S,children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Provider hinzufügen"]})]}),x?n.jsx("div",{className:"text-center py-8",children:"Laden..."}):F.length===0?n.jsx(Z,{children:n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Noch keine Email-Provider konfiguriert."})}):n.jsx("div",{className:"space-y-4",children:F.map(P=>{const j=f[P.id],B=b===P.id;return n.jsx(Z,{children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("h3",{className:"font-semibold text-lg",children:P.name}),n.jsx("span",{className:"px-2 py-1 text-xs rounded bg-blue-100 text-blue-800",children:P.type}),P.isDefault&&n.jsx("span",{className:"px-2 py-1 text-xs rounded bg-green-100 text-green-800",children:"Standard"}),!P.isActive&&n.jsx("span",{className:"px-2 py-1 text-xs rounded bg-gray-100 text-gray-600",children:"Inaktiv"})]}),n.jsxs("dl",{className:"mt-3 grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"API-URL"}),n.jsx("dd",{className:"font-mono text-xs truncate",children:P.apiUrl})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"Domain"}),n.jsx("dd",{children:P.domain})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"Benutzer"}),n.jsx("dd",{children:P.username||"-"})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-gray-500",children:"Standard-Weiterleitung"}),n.jsx("dd",{className:"truncate",children:P.defaultForwardEmail||"-"})]})]}),j&&n.jsx("div",{className:`mt-3 p-3 rounded-lg text-sm ${j.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:j.success?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Xu,{className:"w-4 h-4 flex-shrink-0"}),n.jsx("span",{children:"Verbindung erfolgreich!"})]}):n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(np,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),n.jsx("span",{children:z(j)})]})})]}),n.jsxs("div",{className:"flex gap-2 ml-4",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>_(P),disabled:B,title:"Verbindung testen",children:B?n.jsx("span",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}):n.jsx(ea,{className:"w-4 h-4 text-blue-500"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>L(P),children:n.jsx(We,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>Q(P.id,P.name),children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})]})},P.id)})}),s&&n.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:n.jsx("div",{className:"bg-white rounded-lg shadow-xl w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto",children:n.jsxs("div",{className:"p-6",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsx("h2",{className:"text-xl font-semibold",children:a?"Provider bearbeiten":"Neuer Provider"}),n.jsx("button",{onClick:T,className:"text-gray-400 hover:text-gray-600",children:n.jsx(wa,{className:"w-5 h-5"})})]}),(N.error||k.error)&&n.jsx("div",{className:"mb-4 p-3 rounded-lg bg-red-50 text-red-800 text-sm",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(wa,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),n.jsx("span",{children:N.error instanceof Error?N.error.message:k.error instanceof Error?k.error.message:"Fehler beim Speichern"})]})}),n.jsxs("form",{onSubmit:W,className:"space-y-4",children:[n.jsx($,{label:"Name *",value:l.name,onChange:P=>o({...l,name:P.target.value}),placeholder:"z.B. Plesk Hauptserver",required:!0}),n.jsx(Le,{label:"Provider-Typ *",value:l.type,onChange:P=>o({...l,type:P.target.value}),options:c2}),n.jsx($,{label:"API-URL *",value:l.apiUrl,onChange:P=>o({...l,apiUrl:P.target.value}),placeholder:"https://server.de:8443",required:!0}),n.jsx($,{label:"API-Key",value:l.apiKey,onChange:P=>o({...l,apiKey:P.target.value}),placeholder:"Optional - alternativ zu Benutzername/Passwort"}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx($,{label:"Benutzername",value:l.username,onChange:P=>o({...l,username:P.target.value}),placeholder:"admin"}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:a?"Neues Passwort (leer = beibehalten)":"Passwort"}),n.jsxs("div",{className:"relative",children:[n.jsx("input",{type:c?"text":"password",value:l.password,onChange:P=>o({...l,password:P.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"}),n.jsx("button",{type:"button",onClick:()=>u(!c),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600",children:c?n.jsx(Pt,{className:"w-4 h-4"}):n.jsx(Ee,{className:"w-4 h-4"})})]})]})]}),n.jsx($,{label:"Domain *",value:l.domain,onChange:P=>o({...l,domain:P.target.value}),placeholder:"stressfrei-wechseln.de",required:!0}),n.jsx($,{label:"Standard-Weiterleitungsadresse",value:l.defaultForwardEmail,onChange:P=>o({...l,defaultForwardEmail:P.target.value}),placeholder:"info@meinefirma.de",type:"email"}),n.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."}),n.jsxs("div",{className:"flex gap-4",children:[n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:l.isActive,onChange:P=>o({...l,isActive:P.target.checked}),className:"rounded border-gray-300"}),n.jsx("span",{className:"text-sm",children:"Aktiv"})]}),n.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:l.isDefault,onChange:P=>o({...l,isDefault:P.target.checked}),className:"rounded border-gray-300"}),n.jsx("span",{className:"text-sm",children:"Als Standard verwenden"})]})]}),n.jsxs("div",{className:"pt-4 border-t",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:K,disabled:p,className:"w-full",children:p?"Teste Verbindung...":n.jsxs(n.Fragment,{children:[n.jsx(ea,{className:"w-4 h-4 mr-2"}),"Verbindung testen"]})}),d&&n.jsx("div",{className:`mt-2 p-3 rounded-lg text-sm ${d.success?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:d.success?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Xu,{className:"w-4 h-4 flex-shrink-0"}),n.jsx("span",{children:"Verbindung erfolgreich!"})]}):n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(np,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),n.jsx("span",{children:z(d)})]})})]}),n.jsxs("div",{className:"flex justify-end gap-3 pt-4 border-t",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:T,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:N.isPending||k.isPending,children:N.isPending||k.isPending?"Speichern...":"Speichern"})]})]})]})})})]})}function d2(){var v;const[e,t]=w.useState(""),[s,r]=w.useState(1),[a,i]=w.useState(!1),[l,o]=w.useState(null),c=pe(),{refreshUser:u}=st(),{data:d,isLoading:m}=ge({queryKey:["users",e,s],queryFn:()=>ii.getAll({search:e||void 0,page:s,limit:20})}),{data:p}=ge({queryKey:["roles"],queryFn:()=>ii.getRoles()}),h=Y({mutationFn:ii.delete,onSuccess:()=>{c.invalidateQueries({queryKey:["users"]})},onError:x=>{alert((x==null?void 0:x.message)||"Fehler beim Löschen des Benutzers")}}),f=x=>{var N;return(N=x.roles)==null?void 0:N.some(k=>k.name==="Admin")},g=((v=d==null?void 0:d.data)==null?void 0:v.filter(x=>x.isActive&&f(x)).length)||0,b=x=>{o(x),i(!0)},y=()=>{i(!1),o(null)};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[n.jsx(Se,{to:"/settings",children:n.jsx(I,{variant:"ghost",size:"sm",children:n.jsx($s,{className:"w-4 h-4"})})}),n.jsx("h1",{className:"text-2xl font-bold flex-1",children:"Benutzer"}),n.jsxs(I,{onClick:()=>i(!0),children:[n.jsx(Oe,{className:"w-4 h-4 mr-2"}),"Neuer Benutzer"]})]}),n.jsx(Z,{className:"mb-6",children:n.jsxs("div",{className:"flex gap-4",children:[n.jsx("div",{className:"flex-1",children:n.jsx($,{placeholder:"Suchen...",value:e,onChange:x=>t(x.target.value)})}),n.jsx(I,{variant:"secondary",children:n.jsx(Wo,{className:"w-4 h-4"})})]})}),n.jsx(Z,{children:m?n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Laden..."}):d!=null&&d.data&&d.data.length>0?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b",children:[n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Name"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"E-Mail"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Rollen"}),n.jsx("th",{className:"text-left py-3 px-4 font-medium text-gray-600",children:"Status"}),n.jsx("th",{className:"text-right py-3 px-4 font-medium text-gray-600",children:"Aktionen"})]})}),n.jsx("tbody",{children:d.data.map(x=>{var N;return n.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[n.jsxs("td",{className:"py-3 px-4",children:[x.firstName," ",x.lastName]}),n.jsx("td",{className:"py-3 px-4",children:x.email}),n.jsx("td",{className:"py-3 px-4",children:n.jsx("div",{className:"flex gap-1 flex-wrap",children:(N=x.roles)==null?void 0:N.filter(k=>k.name!=="Developer").map(k=>n.jsx(he,{variant:"info",children:k.name},k.id||k.name))})}),n.jsx("td",{className:"py-3 px-4",children:n.jsxs("div",{className:"flex gap-2",children:[n.jsx(he,{variant:x.isActive?"success":"danger",children:x.isActive?"Aktiv":"Inaktiv"}),x.hasDeveloperAccess&&n.jsxs(he,{variant:"warning",className:"flex items-center gap-1",children:[n.jsx(Ho,{className:"w-3 h-3"}),"Dev"]})]})}),n.jsx("td",{className:"py-3 px-4 text-right",children:n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>b(x),children:n.jsx(We,{className:"w-4 h-4"})}),(()=>{const k=f(x)&&x.isActive&&g<=1;return n.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?")&&h.mutate(x.id)},children:n.jsx(be,{className:`w-4 h-4 ${k?"text-gray-300":"text-red-500"}`})})})()]})})]},x.id)})})]})}),d.pagination&&d.pagination.totalPages>1&&n.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[n.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",d.pagination.page," von ",d.pagination.totalPages]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(I,{variant:"secondary",size:"sm",onClick:()=>r(x=>Math.max(1,x-1)),disabled:s===1,children:"Zurück"}),n.jsx(I,{variant:"secondary",size:"sm",onClick:()=>r(x=>x+1),disabled:s>=d.pagination.totalPages,children:"Weiter"})]})]})]}):n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Keine Benutzer gefunden."})}),n.jsx(h2,{isOpen:a,onClose:y,user:l,roles:(p==null?void 0:p.data)||[],onUserUpdated:u})]})}function h2({isOpen:e,onClose:t,user:s,roles:r,onUserUpdated:a}){const i=pe(),[l,o]=w.useState(null),[c,u]=w.useState({email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1});w.useEffect(()=>{var g;e&&(o(null),u(s?{email:s.email,password:"",firstName:s.firstName,lastName:s.lastName,roleIds:((g=s.roles)==null?void 0:g.filter(b=>b.name!=="Developer").map(b=>b.id))||[],isActive:s.isActive??!0,hasDeveloperAccess:s.hasDeveloperAccess??!1}:{email:"",password:"",firstName:"",lastName:"",roleIds:[],isActive:!0,hasDeveloperAccess:!1}))},[e,s]);const d=Y({mutationFn:ii.create,onSuccess:()=>{i.invalidateQueries({queryKey:["users"]}),t()},onError:g=>{o((g==null?void 0:g.message)||"Fehler beim Erstellen des Benutzers")}}),m=Y({mutationFn:g=>ii.update(s.id,g),onSuccess:async()=>{i.invalidateQueries({queryKey:["users"]}),await a(),t()},onError:g=>{o((g==null?void 0:g.message)||"Fehler beim Aktualisieren des Benutzers")}}),p=g=>{if(g.preventDefault(),s){const b={email:c.email,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds,isActive:c.isActive,hasDeveloperAccess:c.hasDeveloperAccess};c.password&&(b.password=c.password),m.mutate(b)}else d.mutate({email:c.email,password:c.password,firstName:c.firstName,lastName:c.lastName,roleIds:c.roleIds})},h=g=>{u(b=>({...b,roleIds:b.roleIds.includes(g)?b.roleIds.filter(y=>y!==g):[...b.roleIds,g]}))},f=d.isPending||m.isPending;return n.jsx(dt,{isOpen:e,onClose:t,title:s?"Benutzer bearbeiten":"Neuer Benutzer",children:n.jsxs("form",{onSubmit:p,className:"space-y-4",children:[l&&n.jsxs("div",{className:"bg-red-50 border border-red-200 rounded-lg p-3 flex items-start gap-2",children:[n.jsx(Li,{className:"w-5 h-5 text-red-500 flex-shrink-0 mt-0.5"}),n.jsx("p",{className:"text-red-700 text-sm",children:l})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx($,{label:"Vorname *",value:c.firstName,onChange:g=>u({...c,firstName:g.target.value}),required:!0}),n.jsx($,{label:"Nachname *",value:c.lastName,onChange:g=>u({...c,lastName:g.target.value}),required:!0})]}),n.jsx($,{label:"E-Mail *",type:"email",value:c.email,onChange:g=>u({...c,email:g.target.value}),required:!0}),n.jsx($,{label:s?"Neues Passwort (leer = unverändert)":"Passwort *",type:"password",value:c.password,onChange:g=>u({...c,password:g.target.value}),required:!s}),n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Rollen"}),n.jsx("div",{className:"space-y-2",children:r.filter(g=>g.name!=="Developer").map(g=>n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:c.roleIds.includes(g.id),onChange:()=>h(g.id),className:"rounded"}),n.jsx("span",{children:g.name}),g.description&&n.jsxs("span",{className:"text-sm text-gray-500",children:["(",g.description,")"]})]},g.id))})]}),s&&n.jsxs("div",{className:"space-y-3 pt-3 border-t",children:[n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:c.isActive,onChange:g=>u({...c,isActive:g.target.checked}),className:"rounded"}),"Aktiv"]}),n.jsxs("label",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",checked:c.hasDeveloperAccess,onChange:g=>u({...c,hasDeveloperAccess:g.target.checked}),className:"rounded border-purple-300 text-purple-600 focus:ring-purple-500"}),n.jsxs("span",{className:"flex items-center gap-1",children:[n.jsx(Ho,{className:"w-4 h-4 text-purple-600"}),"Entwicklerzugriff"]}),n.jsx("span",{className:"text-sm text-gray-500",children:"(Datenbanktools)"})]})]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(I,{type:"button",variant:"secondary",onClick:t,children:"Abbrechen"}),n.jsx(I,{type:"submit",disabled:f,children:f?"Speichern...":"Speichern"})]})]})})}function m2(){const{hasPermission:e,developerMode:t,setDeveloperMode:s}=st(),r=[{to:"/settings/users",icon:P1,title:"Benutzer",description:"Verwalten Sie Benutzerkonten, Rollen und Berechtigungen.",show:e("users:read")},{to:"/settings/platforms",icon:C1,title:"Vertriebsplattformen",description:"Verwalten Sie die Plattformen, über die Verträge abgeschlossen werden.",show:e("platforms:read")},{to:"/settings/cancellation-periods",icon:qn,title:"Kündigungsfristen",description:"Konfigurieren Sie die verfügbaren Kündigungsfristen für Verträge.",show:e("platforms:read")},{to:"/settings/contract-durations",icon:Qy,title:"Vertragslaufzeiten",description:"Konfigurieren Sie die verfügbaren Laufzeiten für Verträge.",show:e("platforms:read")},{to:"/settings/providers",icon:h1,title:"Anbieter & Tarife",description:"Verwalten Sie Anbieter und deren Tarife für Verträge.",show:e("providers:read")||e("platforms:read")},{to:"/settings/contract-categories",icon:g1,title:"Vertragstypen",description:"Konfigurieren Sie die verfügbaren Vertragstypen (Strom, Gas, Mobilfunk, etc.).",show:e("platforms:read")}];return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[n.jsx(tv,{className:"w-6 h-6"}),n.jsx("h1",{className:"text-2xl font-bold",children:"Einstellungen"})]}),n.jsxs("div",{className:"mb-8",children:[n.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Stammdaten"}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:r.filter(a=>a.show).map(a=>n.jsx(Se,{to:a.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:n.jsxs("div",{className:"flex items-start gap-4",children:[n.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:n.jsx(a.icon,{className:"w-6 h-6 text-blue-600"})}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:[a.title,n.jsx(Ys,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),n.jsx("p",{className:"text-sm text-gray-500 mt-1",children:a.description})]})]})},a.to))})]}),e("settings:update")&&n.jsxs("div",{className:"mb-8",children:[n.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"System"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(Se,{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:n.jsxs("div",{className:"flex items-start gap-4",children:[n.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:n.jsx(uh,{className:"w-6 h-6 text-blue-600"})}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Kundenportal",n.jsx(Ys,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),n.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie das Kundenportal und Support-Anfragen."})]})]})}),n.jsx(Se,{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:n.jsxs("div",{className:"flex items-start gap-4",children:[n.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:n.jsx(qn,{className:"w-6 h-6 text-blue-600"})}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Fristenschwellen",n.jsx(Ys,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),n.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die Farbkodierung für Vertragsfristen im Cockpit."})]})]})}),n.jsx(Se,{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:n.jsxs("div",{className:"flex items-start gap-4",children:[n.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:n.jsx(ev,{className:"w-6 h-6 text-blue-600"})}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Email-Provisionierung",n.jsx(Ys,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),n.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Konfigurieren Sie die automatische E-Mail-Erstellung für Stressfrei-Wechseln Adressen."})]})]})})]})]}),n.jsxs("div",{className:"mb-8",children:[n.jsx("h2",{className:"text-lg font-semibold mb-4 text-gray-700",children:"Persönlich"}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:n.jsx(Se,{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:n.jsxs("div",{className:"flex items-start gap-4",children:[n.jsx("div",{className:"p-2 bg-blue-50 rounded-lg group-hover:bg-blue-100 transition-colors",children:n.jsx(Ee,{className:"w-6 h-6 text-blue-600"})}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("h3",{className:"font-semibold text-gray-900 group-hover:text-blue-600 transition-colors flex items-center gap-2",children:["Ansicht",n.jsx(Ys,{className:"w-4 h-4 opacity-0 group-hover:opacity-100 transition-opacity"})]}),n.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Passen Sie die Darstellung der Anwendung an."})]})]})})})]}),e("developer:access")&&n.jsxs(Z,{title:"Entwickleroptionen",className:"mb-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Ho,{className:"w-5 h-5 text-gray-500"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-medium",children:"Entwicklermodus"}),n.jsx("p",{className:"text-sm text-gray-500",children:"Aktiviert erweiterte Funktionen wie direkten Datenbankzugriff"})]})]}),n.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:t,onChange:a=>s(a.target.checked),className:"sr-only peer"}),n.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"})]})]}),t&&n.jsx("div",{className:"mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:n.jsxs("p",{className:"text-sm text-yellow-800",children:[n.jsx("strong",{children:"Warnung:"})," Der Entwicklermodus ermöglicht direkten Zugriff auf die Datenbank. Unsachgemäße Änderungen können zu Datenverlust oder Inkonsistenzen führen."]})})]}),n.jsx(Z,{title:"Über",children:n.jsxs("dl",{className:"space-y-3",children:[n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"Version"}),n.jsx("dd",{children:"1.0.0"})]}),n.jsxs("div",{children:[n.jsx("dt",{className:"text-sm text-gray-500",children:"System"}),n.jsx("dd",{children:"OpenCRM"})]})]})})]})}function f2({onSelectTable:e}){const t=w.useRef(null),[s,r]=w.useState(1),[a,i]=w.useState({x:0,y:0}),[l,o]=w.useState(!1),[c,u]=w.useState({x:0,y:0}),[d,m]=w.useState({}),[p,h]=w.useState(null),{data:f,isLoading:g}=ge({queryKey:["developer-schema"],queryFn:Za.getSchema}),b=(f==null?void 0:f.data)||[];w.useEffect(()=>{if(b.length>0&&Object.keys(d).length===0){const S=Math.ceil(Math.sqrt(b.length)),L={x:280,y:200},T={};b.forEach((_,K)=>{const W=K%S,Q=Math.floor(K/S);T[_.name]={x:50+W*L.x,y:50+Q*L.y}}),m(T)}},[b,d]);const y=w.useCallback(S=>{(S.target===S.currentTarget||S.target.tagName==="svg")&&(o(!0),u({x:S.clientX-a.x,y:S.clientY-a.y}))},[a]),v=w.useCallback(S=>{var L;if(l&&!p)i({x:S.clientX-c.x,y:S.clientY-c.y});else if(p){const T=(L=t.current)==null?void 0:L.getBoundingClientRect();T&&m(_=>({..._,[p]:{x:(S.clientX-T.left-a.x)/s-100,y:(S.clientY-T.top-a.y)/s-20}}))}},[l,p,c,a,s]),x=w.useCallback(()=>{o(!1),h(null)},[]),N=S=>{r(L=>Math.min(2,Math.max(.3,L+S)))},k=()=>{r(1),i({x:0,y:0})},D=w.useCallback(()=>{const S=[];return b.forEach(L=>{const T=d[L.name];T&&L.foreignKeys.forEach(_=>{const K=d[_.targetTable];if(!K)return;const W=b.find(z=>z.name===_.targetTable),Q=W==null?void 0:W.relations.find(z=>z.targetTable===L.name);S.push({from:{table:L.name,x:T.x+100,y:T.y+60},to:{table:_.targetTable,x:K.x+100,y:K.y+60},type:(Q==null?void 0:Q.type)||"one",label:_.field})})}),S},[b,d]);if(g)return n.jsx("div",{className:"flex items-center justify-center h-full",children:"Laden..."});const F=D();return n.jsxs("div",{className:"relative h-full w-full bg-gray-50 overflow-hidden",ref:t,children:[n.jsxs("div",{className:"absolute top-4 right-4 z-10 flex gap-2 bg-white rounded-lg shadow-md p-2",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>N(.1),title:"Vergrößern",children:n.jsx(T1,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>N(-.1),title:"Verkleinern",children:n.jsx(F1,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:k,title:"Zurücksetzen",children:n.jsx(N1,{className:"w-4 h-4"})}),n.jsxs("div",{className:"text-xs text-gray-500 flex items-center px-2",children:[Math.round(s*100),"%"]})]}),n.jsxs("div",{className:"absolute top-4 left-4 z-10 bg-white rounded-lg shadow-md p-2 text-xs text-gray-500",children:[n.jsx(w1,{className:"w-3 h-3 inline mr-1"}),"Tabellen ziehen zum Verschieben"]}),n.jsx("svg",{className:"w-full h-full cursor-grab",style:{cursor:l?"grabbing":"grab"},onMouseDown:y,onMouseMove:v,onMouseUp:x,onMouseLeave:x,children:n.jsxs("g",{transform:`translate(${a.x}, ${a.y}) scale(${s})`,children:[n.jsxs("defs",{children:[n.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:n.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6b7280"})}),n.jsx("marker",{id:"many-marker",markerWidth:"12",markerHeight:"12",refX:"6",refY:"6",orient:"auto",children:n.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"#6b7280"})})]}),F.map((S,L)=>{const T=S.to.x-S.from.x,_=S.to.y-S.from.y,K=S.from.x+T/2,W=S.from.y+_/2,Q=S.from.x+T*.25,z=S.from.y,P=S.from.x+T*.75,j=S.to.y;return n.jsxs("g",{children:[n.jsx("path",{d:`M ${S.from.x} ${S.from.y} C ${Q} ${z}, ${P} ${j}, ${S.to.x} ${S.to.y}`,fill:"none",stroke:"#9ca3af",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),n.jsx("text",{x:K,y:W-8,fontSize:"10",fill:"#6b7280",textAnchor:"middle",className:"select-none",children:S.type==="many"?"1:n":"1:1"})]},L)}),b.map(S=>{const L=d[S.name];if(!L)return null;const T=200,_=32,K=20,W=[...new Set([S.primaryKey,...S.foreignKeys.map(z=>z.field)])],Q=_+Math.min(W.length,5)*K+8;return n.jsxs("g",{transform:`translate(${L.x}, ${L.y})`,style:{cursor:"move"},onMouseDown:z=>{z.stopPropagation(),h(S.name)},children:[n.jsx("rect",{x:"3",y:"3",width:T,height:Q,rx:"6",fill:"rgba(0,0,0,0.1)"}),n.jsx("rect",{x:"0",y:"0",width:T,height:Q,rx:"6",fill:"white",stroke:"#e5e7eb",strokeWidth:"1"}),n.jsx("rect",{x:"0",y:"0",width:T,height:_,rx:"6",fill:"#3b82f6",className:"cursor-pointer",onClick:()=>e==null?void 0:e(S.name)}),n.jsx("rect",{x:"0",y:_-6,width:T,height:"6",fill:"#3b82f6"}),n.jsx("text",{x:T/2,y:"21",fontSize:"13",fontWeight:"bold",fill:"white",textAnchor:"middle",className:"select-none pointer-events-none",children:S.name}),W.slice(0,5).map((z,P)=>{const j=z===S.primaryKey||S.primaryKey.includes(z),B=S.foreignKeys.some(J=>J.field===z);return n.jsx("g",{transform:`translate(8, ${_+4+P*K})`,children:n.jsxs("text",{x:"0",y:"14",fontSize:"11",fill:j?"#dc2626":B?"#2563eb":"#374151",fontFamily:"monospace",className:"select-none",children:[j&&"🔑 ",B&&!j&&"🔗 ",z]})},z)}),W.length>5&&n.jsxs("text",{x:T/2,y:Q-4,fontSize:"10",fill:"#9ca3af",textAnchor:"middle",className:"select-none",children:["+",W.length-5," mehr..."]})]},S.name)})]})}),n.jsxs("div",{className:"absolute bottom-4 left-4 bg-white rounded-lg shadow-md p-3 text-xs",children:[n.jsx("div",{className:"font-medium mb-2",children:"Legende"}),n.jsxs("div",{className:"space-y-1",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-red-600",children:"🔑"}),n.jsx("span",{children:"Primary Key"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-blue-600",children:"🔗"}),n.jsx("span",{children:"Foreign Key"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-0.5 bg-gray-400"}),n.jsx("span",{children:"Beziehung"})]})]})]})]})}function p2(){var F;const[e,t]=w.useState(null),[s,r]=w.useState(1),[a,i]=w.useState(null),[l,o]=w.useState(!1),c=pe(),{data:u,isLoading:d,error:m}=ge({queryKey:["developer-schema"],queryFn:Za.getSchema});console.log("Schema data:",u),console.log("Schema error:",m);const{data:p,isLoading:h}=ge({queryKey:["developer-table",e,s],queryFn:()=>Za.getTableData(e,s),enabled:!!e}),f=Y({mutationFn:({tableName:S,id:L,data:T})=>Za.updateRow(S,L,T),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]}),i(null)},onError:S=>{var L,T;alert(((T=(L=S.response)==null?void 0:L.data)==null?void 0:T.error)||"Fehler beim Speichern")}}),g=Y({mutationFn:({tableName:S,id:L})=>Za.deleteRow(S,L),onSuccess:()=>{c.invalidateQueries({queryKey:["developer-table",e]})},onError:S=>{var L,T;alert(((T=(L=S.response)==null?void 0:L.data)==null?void 0:T.error)||"Fehler beim Löschen")}}),b=(u==null?void 0:u.data)||[],y=b.find(S=>S.name===e),v=(S,L)=>L.primaryKey.includes(",")?L.primaryKey.split(",").map(T=>S[T]).join("-"):String(S[L.primaryKey]),x=S=>S==null?"-":typeof S=="boolean"?S?"Ja":"Nein":typeof S=="object"?S instanceof Date||typeof S=="string"&&S.match(/^\d{4}-\d{2}-\d{2}/)?new Date(S).toLocaleString("de-DE"):JSON.stringify(S):String(S),N=()=>{!a||!e||f.mutate({tableName:e,id:a.id,data:a.data})},k=S=>{e&&confirm("Datensatz wirklich löschen?")&&g.mutate({tableName:e,id:S})};if(d)return n.jsx("div",{className:"text-center py-8",children:"Laden..."});const D=S=>{t(S),r(1),o(!1)};return n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Zy,{className:"w-6 h-6"}),n.jsx("h1",{className:"text-2xl font-bold",children:"Datenbankstruktur"})]}),n.jsxs(I,{onClick:()=>o(!0),children:[n.jsx(sp,{className:"w-4 h-4 mr-2"}),"ER-Diagramm"]})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6",children:[n.jsx(Z,{title:"Tabellen",className:"lg:col-span-1",children:n.jsx("div",{className:"space-y-1 max-h-[600px] overflow-y-auto",children:b.map(S=>n.jsxs("button",{onClick:()=>{t(S.name),r(1)},className:`w-full text-left px-3 py-2 rounded-lg flex items-center gap-2 transition-colors ${e===S.name?"bg-blue-100 text-blue-700":"hover:bg-gray-100"}`,children:[n.jsx(E1,{className:"w-4 h-4"}),n.jsx("span",{className:"text-sm font-mono",children:S.name})]},S.name))})}),n.jsx("div",{className:"lg:col-span-3 space-y-6",children:e&&y?n.jsxs(n.Fragment,{children:[n.jsxs(Z,{title:`${e} - Beziehungen`,children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Fremdschlüssel (referenziert)"}),y.foreignKeys.length>0?n.jsx("div",{className:"space-y-1",children:y.foreignKeys.map(S=>n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx("span",{className:"font-mono text-gray-600",children:S.field}),n.jsx(d1,{className:"w-4 h-4 text-gray-400"}),n.jsx(he,{variant:"info",className:"cursor-pointer",onClick:()=>{t(S.targetTable),r(1)},children:S.targetTable})]},S.field))}):n.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]}),n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-medium text-gray-500 mb-2",children:"Relationen (wird referenziert von)"}),y.relations.length>0?n.jsx("div",{className:"space-y-1",children:y.relations.map(S=>n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx("span",{className:"font-mono text-gray-600",children:S.field}),n.jsx(he,{variant:S.type==="many"?"warning":"default",children:S.type==="many"?"1:n":"1:1"}),n.jsx(he,{variant:"info",className:"cursor-pointer",onClick:()=>{t(S.targetTable),r(1)},children:S.targetTable})]},S.field))}):n.jsx("p",{className:"text-sm text-gray-400",children:"Keine"})]})]}),n.jsx("div",{className:"mt-4 pt-4 border-t",children:n.jsxs("div",{className:"flex gap-4 text-sm",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500",children:"Primary Key:"})," ",n.jsx("span",{className:"font-mono",children:y.primaryKey})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500",children:"Readonly:"})," ",n.jsx("span",{className:"font-mono text-red-600",children:y.readonlyFields.join(", ")||"-"})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-gray-500",children:"Required:"})," ",n.jsx("span",{className:"font-mono text-green-600",children:y.requiredFields.join(", ")||"-"})]})]})})]}),n.jsx(Z,{title:`${e} - Daten`,children:h?n.jsx("div",{className:"text-center py-4",children:"Laden..."}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full text-sm",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"border-b bg-gray-50",children:[(p==null?void 0:p.data)&&p.data.length>0&&Object.keys(p.data[0]).map(S=>n.jsxs("th",{className:"text-left py-2 px-3 font-medium text-gray-600 whitespace-nowrap",children:[S,y.readonlyFields.includes(S)&&n.jsx("span",{className:"ml-1 text-red-400 text-xs",children:"*"}),y.requiredFields.includes(S)&&n.jsx("span",{className:"ml-1 text-green-400 text-xs",children:"!"})]},S)),n.jsx("th",{className:"text-right py-2 px-3 font-medium text-gray-600",children:"Aktionen"})]})}),n.jsxs("tbody",{children:[(F=p==null?void 0:p.data)==null?void 0:F.map(S=>{const L=v(S,y);return n.jsxs("tr",{className:"border-b hover:bg-gray-50",children:[Object.entries(S).map(([T,_])=>n.jsx("td",{className:"py-2 px-3 font-mono text-xs max-w-[200px] truncate",children:x(_)},T)),n.jsx("td",{className:"py-2 px-3 text-right whitespace-nowrap",children:n.jsxs("div",{className:"flex justify-end gap-1",children:[n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>i({id:L,data:{...S}}),children:n.jsx(We,{className:"w-4 h-4"})}),n.jsx(I,{variant:"ghost",size:"sm",onClick:()=>k(L),children:n.jsx(be,{className:"w-4 h-4 text-red-500"})})]})})]},L)}),(!(p!=null&&p.data)||p.data.length===0)&&n.jsx("tr",{children:n.jsx("td",{colSpan:100,className:"py-4 text-center text-gray-500",children:"Keine Daten vorhanden"})})]})]})}),(p==null?void 0:p.pagination)&&p.pagination.totalPages>1&&n.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[n.jsxs("p",{className:"text-sm text-gray-500",children:["Seite ",p.pagination.page," von ",p.pagination.totalPages," (",p.pagination.total," Einträge)"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(I,{variant:"secondary",size:"sm",onClick:()=>r(S=>Math.max(1,S-1)),disabled:s===1,children:n.jsx(f1,{className:"w-4 h-4"})}),n.jsx(I,{variant:"secondary",size:"sm",onClick:()=>r(S=>S+1),disabled:s>=p.pagination.totalPages,children:n.jsx(Ys,{className:"w-4 h-4"})})]})]})]})})]}):n.jsx(Z,{children:n.jsx("div",{className:"text-center py-8 text-gray-500",children:"Wähle eine Tabelle aus der Liste aus"})})})]}),n.jsx(dt,{isOpen:!!a,onClose:()=>i(null),title:`${e} bearbeiten`,children:a&&y&&n.jsxs("div",{className:"space-y-4 max-h-[60vh] overflow-y-auto",children:[Object.entries(a.data).map(([S,L])=>{const T=y.readonlyFields.includes(S),_=y.requiredFields.includes(S);return n.jsxs("div",{children:[n.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:[S,T&&n.jsx("span",{className:"ml-1 text-red-400",children:"(readonly)"}),_&&n.jsx("span",{className:"ml-1 text-green-600",children:"*"})]}),T?n.jsx("div",{className:"px-3 py-2 bg-gray-100 rounded-lg font-mono text-sm",children:x(L)}):typeof L=="boolean"?n.jsxs("select",{value:String(a.data[S]),onChange:K=>i({...a,data:{...a.data,[S]:K.target.value==="true"}}),className:"w-full px-3 py-2 border rounded-lg",children:[n.jsx("option",{value:"true",children:"Ja"}),n.jsx("option",{value:"false",children:"Nein"})]}):n.jsx("input",{type:typeof L=="number"?"number":"text",value:a.data[S]??"",onChange:K=>i({...a,data:{...a.data,[S]:typeof L=="number"?K.target.value?Number(K.target.value):null:K.target.value||null}}),className:"w-full px-3 py-2 border rounded-lg font-mono text-sm",disabled:T})]},S)}),n.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[n.jsxs(I,{variant:"secondary",onClick:()=>i(null),children:[n.jsx(wa,{className:"w-4 h-4 mr-2"}),"Abbrechen"]}),n.jsxs(I,{onClick:N,disabled:f.isPending,children:[n.jsx(S1,{className:"w-4 h-4 mr-2"}),f.isPending?"Speichern...":"Speichern"]})]})]})}),l&&n.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[n.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>o(!1)}),n.jsxs("div",{className:"relative bg-white rounded-xl shadow-2xl w-[90vw] h-[85vh] flex flex-col",children:[n.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(sp,{className:"w-5 h-5 text-blue-600"}),n.jsx("h2",{className:"text-lg font-semibold",children:"ER-Diagramm - Datenbankbeziehungen"})]}),n.jsx("button",{onClick:()=>o(!1),className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:n.jsx(wa,{className:"w-5 h-5"})})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(f2,{onSelectTable:D})})]})]})]})}function g2({children:e}){const{isAuthenticated:t,isLoading:s}=st();return s?n.jsx("div",{className:"min-h-screen flex items-center justify-center",children:n.jsx("div",{className:"text-gray-500",children:"Laden..."})}):t?n.jsx(n.Fragment,{children:e}):n.jsx(Qr,{to:"/login",replace:!0})}function x2({children:e}){const{hasPermission:t,developerMode:s}=st();return!t("developer:access")||!s?n.jsx(Qr,{to:"/",replace:!0}):n.jsx(n.Fragment,{children:e})}function y2(){const{isAuthenticated:e,isLoading:t}=st();return t?n.jsx("div",{className:"min-h-screen flex items-center justify-center",children:n.jsx("div",{className:"text-gray-500",children:"Laden..."})}):n.jsxs(n.Fragment,{children:[n.jsx(l1,{}),n.jsxs(Ib,{children:[n.jsx(Fe,{path:"/login",element:e?n.jsx(Qr,{to:"/",replace:!0}):n.jsx(R1,{})}),n.jsxs(Fe,{path:"/",element:n.jsx(g2,{children:n.jsx(L1,{})}),children:[n.jsx(Fe,{index:!0,element:n.jsx(O1,{})}),n.jsx(Fe,{path:"customers",element:n.jsx(z1,{})}),n.jsx(Fe,{path:"customers/new",element:n.jsx(Np,{})}),n.jsx(Fe,{path:"customers/:id",element:n.jsx($1,{})}),n.jsx(Fe,{path:"customers/:id/edit",element:n.jsx(Np,{})}),n.jsx(Fe,{path:"contracts",element:n.jsx(NS,{})}),n.jsx(Fe,{path:"contracts/cockpit",element:n.jsx(US,{})}),n.jsx(Fe,{path:"contracts/new",element:n.jsx(kp,{})}),n.jsx(Fe,{path:"contracts/:id",element:n.jsx(FS,{})}),n.jsx(Fe,{path:"contracts/:id/edit",element:n.jsx(kp,{})}),n.jsx(Fe,{path:"tasks",element:n.jsx(BS,{})}),n.jsx(Fe,{path:"settings",element:n.jsx(m2,{})}),n.jsx(Fe,{path:"settings/users",element:n.jsx(d2,{})}),n.jsx(Fe,{path:"settings/platforms",element:n.jsx(qS,{})}),n.jsx(Fe,{path:"settings/cancellation-periods",element:n.jsx(HS,{})}),n.jsx(Fe,{path:"settings/contract-durations",element:n.jsx(GS,{})}),n.jsx(Fe,{path:"settings/providers",element:n.jsx(YS,{})}),n.jsx(Fe,{path:"settings/contract-categories",element:n.jsx(n2,{})}),n.jsx(Fe,{path:"settings/view",element:n.jsx(i2,{})}),n.jsx(Fe,{path:"settings/portal",element:n.jsx(l2,{})}),n.jsx(Fe,{path:"settings/deadlines",element:n.jsx(o2,{})}),n.jsx(Fe,{path:"settings/email-providers",element:n.jsx(u2,{})}),n.jsx(Fe,{path:"users",element:n.jsx(Qr,{to:"/settings/users",replace:!0})}),n.jsx(Fe,{path:"platforms",element:n.jsx(Qr,{to:"/settings/platforms",replace:!0})}),n.jsx(Fe,{path:"developer/database",element:n.jsx(x2,{children:n.jsx(p2,{})})})]}),n.jsx(Fe,{path:"*",element:n.jsx(Qr,{to:"/",replace:!0})})]})]})}const v2=new xN({defaultOptions:{queries:{retry:1,staleTime:5*60*1e3}}});Rc.createRoot(document.getElementById("root")).render(n.jsx(Nt.StrictMode,{children:n.jsx(yN,{client:v2,children:n.jsx(Bb,{children:n.jsx(i1,{children:n.jsx(a1,{children:n.jsx(y2,{})})})})})}));